diff --git a/.gitignore b/.gitignore index 0743489f8ec..b6b4a1a559a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ NashornProfile.txt **/JTreport/** **/JTwork/** /src/utils/LogCompilation/target/ +/src/utils/LogCompilation/logc.jar /.project/ /.settings/ /compile_commands.json diff --git a/make/CompileInterimLangtools.gmk b/make/CompileInterimLangtools.gmk index c7d1c3796f6..8254b8fc0a7 100644 --- a/make/CompileInterimLangtools.gmk +++ b/make/CompileInterimLangtools.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2026, 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 @@ -68,17 +68,19 @@ java.compiler.interim_EXTRA_FILES := \ TARGETS += $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java ################################################################################ -# Use the up-to-date PreviewFeature.java and NoPreview.java from the current -# sources, instead of the versions from the boot JDK, as javac may be referring -# to constants from the up-to-date versions. +# Create a hybrid PreviewFeature.java that combines constants +# from the current sources, as those can be used in javac APIs, and from the +# bootstrap JDK, as those can be used from bootstrap JDK classfiles. -$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \ - FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \ - $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \ - DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/, \ -)) +$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/PreviewFeature.java: \ + $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java + $(call LogInfo, Generating $@) + $(JAVA) $(TOPDIR)/make/langtools/tools/previewfeature/SetupPreviewFeature.java \ + $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \ + $@ -TARGETS += $(COPY_PREVIEW_FEATURES) + +TARGETS += $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/PreviewFeature.java ################################################################################ # Setup the rules to build interim langtools, which is compiled by the boot @@ -123,7 +125,8 @@ define SetupInterimModule $1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \ $$(INTERIM_LANGTOOLS_BASE_MODULES), $$(call FindTransitiveDepsForModule, $1))) - $$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d)) $(COPY_PREVIEW_FEATURES) + $$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d)) \ + $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/PreviewFeature.java TARGETS += $$(BUILD_$1.interim) endef diff --git a/make/GenerateLinkOptData.gmk b/make/GenerateLinkOptData.gmk index 6f6e1f29b4c..d615a34e71a 100644 --- a/make/GenerateLinkOptData.gmk +++ b/make/GenerateLinkOptData.gmk @@ -70,12 +70,15 @@ CLASSLIST_FILE_VM_OPTS = \ # Save the stderr output of the command and print it along with stdout in case # something goes wrong. +# The classlists must be generated with -Xint to avoid non-determinism +# introduced by JIT compiled code $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST_JAR) $(call MakeDir, $(LINK_OPT_DIR)) $(call LogInfo, Generating $(patsubst $(OUTPUTDIR)/%, %, $@)) $(call LogInfo, Generating $(patsubst $(OUTPUTDIR)/%, %, $(JLI_TRACE_FILE))) $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.raw \ $(CLASSLIST_FILE_VM_OPTS) \ + -Xint \ -Xlog:aot=off \ -Xlog:cds=off \ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ @@ -90,6 +93,7 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST -XX:SharedClassListFile=$@.interim -XX:SharedArchiveFile=$@.jsa \ -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \ $(CLASSLIST_FILE_VM_OPTS) \ + -Xint \ --module-path $(SUPPORT_OUTPUTDIR)/classlist.jar \ -Xlog:aot=off \ -Xlog:cds=off \ diff --git a/make/PreInit.gmk b/make/PreInit.gmk index 3df44308dd9..8152587781c 100644 --- a/make/PreInit.gmk +++ b/make/PreInit.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2026, 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 @@ -66,7 +66,8 @@ CALLED_SPEC_TARGETS := $(filter-out $(ALL_GLOBAL_TARGETS), $(CALLED_TARGETS)) ifeq ($(CALLED_SPEC_TARGETS), ) SKIP_SPEC := true endif -ifeq ($(findstring p, $(MAKEFLAGS))$(findstring q, $(MAKEFLAGS)), pq) +MFLAGS_SINGLE := $(filter-out --%, $(MFLAGS)) +ifeq ($(findstring p, $(MFLAGS_SINGLE))$(findstring q, $(MFLAGS_SINGLE)), pq) SKIP_SPEC := true endif diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index 8e42f9205a4..66ef94d48a8 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, 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 @@ -369,6 +369,10 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], IS_GNU_DATE=yes else AC_MSG_RESULT([no]) + # Likely at the AIX provided version of the date utility here, which is not compatible + if test "x$OPENJDK_TARGET_OS" = "xaix"; then + AC_MSG_ERROR([gnu date from AIX toolbox is required]) + fi IS_GNU_DATE=no fi AC_SUBST(IS_GNU_DATE) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 0cdf02c61c6..ab9cd8be19b 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -214,6 +214,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], WARNINGS_ENABLE_ADDITIONAL_CXX="" WARNINGS_ENABLE_ADDITIONAL_JVM="" DISABLED_WARNINGS="4800 5105" + CFLAGS_CONVERSION_WARNINGS= ;; gcc) @@ -239,6 +240,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], if test "x$OPENJDK_TARGET_CPU_ARCH" = "xppc"; then DISABLED_WARNINGS="$DISABLED_WARNINGS psabi" fi + CFLAGS_CONVERSION_WARNINGS="-Wconversion -Wno-float-conversion" ;; clang) @@ -258,6 +260,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], # These warnings will never be turned on, since they generate too many # false positives. DISABLED_WARNINGS="unknown-warning-option unused-parameter" + CFLAGS_CONVERSION_WARNINGS="-Wimplicit-int-conversion" ;; esac WARNINGS_ENABLE_ALL="$WARNINGS_ENABLE_ALL_NORMAL $WARNINGS_ENABLE_ADDITIONAL" @@ -270,6 +273,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], AC_SUBST(DISABLED_WARNINGS) AC_SUBST(DISABLED_WARNINGS_C) AC_SUBST(DISABLED_WARNINGS_CXX) + AC_SUBST(CFLAGS_CONVERSION_WARNINGS) ]) AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS], @@ -574,6 +578,11 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX fi + if test "x$ENABLE_LINKTIME_GC" = xtrue; then + TOOLCHAIN_CFLAGS_JDK="$TOOLCHAIN_CFLAGS_JDK -ffunction-sections -fdata-sections" + TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -fdata-sections" + fi + if test "x$OPENJDK_TARGET_OS" = xaix; then TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -ftls-model -fno-math-errno" TOOLCHAIN_CFLAGS_JDK="-ffunction-sections -fsigned-char" diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index 466ff1beaf4..7782735be25 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -80,6 +80,10 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], if test "x$CXX_IS_USER_SUPPLIED" = xfalse && test "x$CC_IS_USER_SUPPLIED" = xfalse; then UTIL_REQUIRE_TOOLCHAIN_PROGS(LLD, lld) fi + + if test "x$ENABLE_LINKTIME_GC" = xtrue; then + BASIC_LDFLAGS_JDK_ONLY="$BASIC_LDFLAGS_JDK_ONLY -Wl,--gc-sections" + fi fi if test "x$OPENJDK_TARGET_OS" = xaix; then BASIC_LDFLAGS="-Wl,-b64 -Wl,-brtl -Wl,-bnorwexec -Wl,-blibpath:/usr/lib:lib -Wl,-bnoexpall \ diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 87d147d4f07..89fcbc88521 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -102,9 +102,20 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], CHECKING_MSG: [if we should build headless-only (no GUI)]) AC_SUBST(ENABLE_HEADLESS_ONLY) + # Avoid headless-only on macOS and Windows, it is not supported there + if test "x$ENABLE_HEADLESS_ONLY" = xtrue; then + if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then + AC_MSG_ERROR([headless-only is not supported on macOS and Windows]) + fi + fi + # should we linktime gc unused code sections in the JDK build ? - if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = xs390x; then - LINKTIME_GC_DEFAULT=true + if test "x$OPENJDK_TARGET_OS" = "xlinux"; then + if test "x$OPENJDK_TARGET_CPU" = "xs390x" || test "x$OPENJDK_TARGET_CPU" = "xppc64le"; then + LINKTIME_GC_DEFAULT=true + else + LINKTIME_GC_DEFAULT=false + fi else LINKTIME_GC_DEFAULT=false fi diff --git a/make/autoconf/lib-bundled.m4 b/make/autoconf/lib-bundled.m4 index a6266bec014..7aa5fdf2589 100644 --- a/make/autoconf/lib-bundled.m4 +++ b/make/autoconf/lib-bundled.m4 @@ -267,8 +267,8 @@ AC_DEFUN_ONCE([LIB_SETUP_ZLIB], LIBZ_LIBS="" if test "x$USE_EXTERNAL_LIBZ" = "xfalse"; then LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" - if test "x$OPENJDK_TARGET_OS" = xmacosx; then - LIBZ_CFLAGS="$LIBZ_CFLAGS -DHAVE_UNISTD_H" + if test "x$OPENJDK_TARGET_OS" = xmacosx -o "x$OPENJDK_TARGET_OS" = xaix -o "x$OPENJDK_TARGET_OS" = xlinux; then + LIBZ_CFLAGS="$LIBZ_CFLAGS -DHAVE_UNISTD_H=1 -DHAVE_STDARG_H=1" fi else LIBZ_LIBS="-lz" diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4 index 1b247e159ac..90d5d795626 100644 --- a/make/autoconf/platform.m4 +++ b/make/autoconf/platform.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, 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 @@ -311,6 +311,12 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], else OPENJDK_BUILD_OS_ENV="$VAR_OS" fi + # Special handling for MSYS2 that reports a Cygwin triplet as the default host triplet. + case `uname` in + MSYS*) + OPENJDK_BUILD_OS_ENV=windows.msys2 + ;; + esac OPENJDK_BUILD_CPU="$VAR_CPU" OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH" OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS" diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index b3d58704c50..c4e5a23d31a 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, 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 @@ -529,6 +529,7 @@ CFLAGS_WARNINGS_ARE_ERRORS := @CFLAGS_WARNINGS_ARE_ERRORS@ DISABLED_WARNINGS := @DISABLED_WARNINGS@ DISABLED_WARNINGS_C := @DISABLED_WARNINGS_C@ DISABLED_WARNINGS_CXX := @DISABLED_WARNINGS_CXX@ +CFLAGS_CONVERSION_WARNINGS := @CFLAGS_CONVERSION_WARNINGS@ # A global flag (true or false) determining if native warnings are considered errors. WARNINGS_AS_ERRORS := @WARNINGS_AS_ERRORS@ diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 97ef88932cb..45cc3c77dea 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, 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 @@ -141,6 +141,66 @@ endef # Make sure logging is setup for everyone that includes MakeBase.gmk. $(eval $(call SetupLogging)) +################################################################################ +# Make does not have support for VARARGS, you can send variable amount +# of arguments, but you can for example not append a list at the end. +# It is therefore not easy to send the elements of a list of unknown +# length as argument to a function. This can somewhat be worked around +# by sending a list as an argument, and then interpreting each element +# of the list as an argument to the function. However, Make is +# limited, and using this method you can not easily send spaces. +# +# We need to quote strings for two reasons when sending them as +# "variable append packs": +# +# 1) variable appends can include spaces, and those must be preserved +# 2) variable appends can include assignment strings ":=", and those +# must be quoted to a form so that we can recognise the "append pack". +# We recognise an "append pack" by its lack of strict assignment ":=" + +Q := $(HASH) +SpaceQ := $(Q)s +AppendQ := $(Q)+ +AssignQ := $(Q)a +QQ := $(Q)$(Q) + +# $(call Quote,echo "#trala:=") -> echo#s"##trala#a" +Quote = $(subst :=,$(AssignQ),$(subst $(SPACE),$(SpaceQ),$(subst $(Q),$(QQ),$1))) + +# $(call Unquote,echo#s"##trala#a") -> echo "#trala:=" +Unquote = $(subst $(QQ),$(Q),$(subst $(SpaceQ),$(SPACE),$(subst $(AssignQ),:=,$1))) + +# $(call QuoteAppend,name,some value) -> name#+some#svalue +# $(call QuoteAppend,bad+=name,some value) -> error +QuoteAppend = $(if $(findstring +=,$1),$(error you can not have += in a variable name: "$1"),$(call Quote,$1)$(AppendQ)$(call Quote,$2)) + +# $(call UnquoteAppendIndex,name#+some#svalue,1) -> name +# $(call UnquoteAppendIndex,name#+some#svalue,2) -> some value +UnquoteAppendIndex = $(call Unquote,$(word $2,$(subst $(AppendQ),$(SPACE),$1))) + +# $(call FilterFiles,dir,%.cpp) -> file1.cpp file2.cpp (without path) +FilterFiles = $(filter $2,$(notdir $(call FindFiles,$1))) + +# $(call Unpack module_,file1.cpp_CXXFLAGS#+-Wconversion file2.cpp_CXXFLAGS#+-Wconversion) -> module_file1.cpp_CXXFLAGS += -Wconversion +# module_file2.cpp_CXXFLAGS += -Wconversion +Unpack = $(foreach pair,$2,$1$(call UnquoteAppendIndex,$(pair),1) += $(call UnquoteAppendIndex,$(pair),2)$(NEWLINE)) + +# This macro takes four arguments: +# $1: directory where to find files (striped), example: $(TOPDIR)/src/hotspot/share/gc/g1 +# $2: filter to match what to keep (striped), example: g1Concurrent%.cpp +# $3: what flags to override (striped), example: _CXXFLAGS +# $4: what value to append to the flag (striped), example: $(CFLAGS_CONVERSION_WARNINGS) +# +# The result will be a quoted string that can be unpacked to a list of +# variable appendings (see macro Unpack above). You do not need to take +# care of unpacking, it is done in NamedParamsMacroTemplate. +# +# This feature should only be used for warnings that we want to +# incrementally add to the rest of the code base. +# +# $(call ExtendFlags,dir,%.cpp,_CXXFLAGS,-Wconversion) -> file1.cpp_CXXFLAGS#+-Wconversion file2.cpp_CXXFLAGS#+-Wconversion +ExtendFlags = $(foreach file,$(call FilterFiles,$(strip $1),$(strip $2)),$(call QuoteAppend,$(file)$(strip $3),$(strip $4))) + ################################################################################ MAX_PARAMS := 96 @@ -166,7 +226,10 @@ define NamedParamsMacroTemplate Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk)) # Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix $(foreach i, $(PARAM_SEQUENCE), $(if $(strip $($i)), \ - $(strip $1)_$(strip $(call EscapeHash, $(call DoubleDollar, $($i))))$(NEWLINE))) + $(if $(findstring :=,$($i)), \ + $(strip $1)_$(strip $(call EscapeHash, $(call DoubleDollar, $($i))))$(NEWLINE), \ + $(call Unpack,$(strip $1)_,$($i))))) + # Debug print all named parameter names and values $(if $(findstring $(LOG_LEVEL), trace), \ $(info $0 $(strip $1) $(foreach i, $(PARAM_SEQUENCE), \ diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index 7682ffbb95c..859494861b2 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,14 @@ include ProcessMarkdown.gmk include $(TOPDIR)/make/ToolsJdk.gmk LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher + +ifeq ($(call isTargetOs, aix), true) + ADD_PLATFORM_INCLUDE_DIR := -I$(TOPDIR)/src/java.base/aix/native/include +endif + LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \ -I$(TOPDIR)/src/java.base/share/native/libjli \ + $(ADD_PLATFORM_INCLUDE_DIR) \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \ # diff --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk index 327014b1e9d..4b21d481049 100644 --- a/make/hotspot/lib/CompileGtest.gmk +++ b/make/hotspot/lib/CompileGtest.gmk @@ -63,6 +63,10 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBGTEST, \ unused-result zero-as-null-pointer-constant, \ DISABLED_WARNINGS_clang := format-nonliteral undef unused-result \ zero-as-null-pointer-constant, \ + $(comment Disable deprecated-declarations warnings to workaround) \ + $(comment clang18+glibc12 bug https://github.com/llvm/llvm-project/issues/76515) \ + $(comment until the clang bug has been fixed) \ + DISABLED_WARNINGS_clang_gtest-all.cc := deprecated-declarations, \ DISABLED_WARNINGS_microsoft := 4530, \ DEFAULT_CFLAGS := false, \ CFLAGS := $(JVM_CFLAGS) \ diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 39a549b7db0..f41693e05fb 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2026, 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 @@ -105,7 +105,7 @@ DISABLED_WARNINGS_gcc := array-bounds comment delete-non-virtual-dtor \ DISABLED_WARNINGS_clang := delete-non-abstract-non-virtual-dtor \ invalid-offsetof missing-braces \ sometimes-uninitialized unknown-pragmas unused-but-set-variable \ - unused-function unused-local-typedef unused-private-field unused-variable + unused-local-typedef unused-private-field unused-variable ifneq ($(DEBUG_LEVEL), release) # Assert macro gives warning @@ -190,6 +190,8 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ whitebox.cpp_CXXFLAGS := $(CFLAGS_SHIP_DEBUGINFO), \ + $(call ExtendFlags, $(TOPDIR)/src/hotspot/share/gc/g1, \ + g1Numa.cpp, _CXXFLAGS, $(CFLAGS_CONVERSION_WARNINGS)), \ DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \ DISABLED_WARNINGS_gcc_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp := nonnull, \ DISABLED_WARNINGS_gcc_bytecodeInterpreter.cpp := unused-label, \ diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index 57b632ee532..27a96cc4865 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2026, 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,10 +43,15 @@ JVM_SRC_DIRS += $(call uniq, $(wildcard $(foreach d, $(JVM_SRC_ROOTS), \ $(JVM_VARIANT_OUTPUTDIR)/gensrc # +ifeq ($(call isTargetOs, aix), true) + ADD_PLATFORM_INCLUDE_DIR := -I$(TOPDIR)/src/java.base/aix/native/include +endif + JVM_CFLAGS_INCLUDES += \ $(patsubst %,-I%,$(JVM_SRC_DIRS)) \ -I$(TOPDIR)/src/hotspot/share/include \ -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \ + $(ADD_PLATFORM_INCLUDE_DIR) \ -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I$(TOPDIR)/src/java.base/share/native/libjimage \ diff --git a/make/jdk/src/classes/build/tools/intpoly/FieldGen.java b/make/jdk/src/classes/build/tools/intpoly/FieldGen.java index fcc45db0219..c29a315f368 100644 --- a/make/jdk/src/classes/build/tools/intpoly/FieldGen.java +++ b/make/jdk/src/classes/build/tools/intpoly/FieldGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,36 +34,6 @@ import java.util.*; public class FieldGen { - static FieldParams Curve25519 = new FieldParams( - "IntegerPolynomial25519", 26, 10, 1, 255, - Arrays.asList( - new Term(0, -19) - ), - Curve25519CrSequence(), simpleSmallCrSequence(10) - ); - - private static List Curve25519CrSequence() { - List result = new ArrayList(); - - // reduce(7,2) - result.add(new Reduce(17)); - result.add(new Reduce(18)); - - // carry(8,2) - result.add(new Carry(8)); - result.add(new Carry(9)); - - // reduce(0,7) - for (int i = 10; i < 17; i++) { - result.add(new Reduce(i)); - } - - // carry(0,9) - result.addAll(fullCarry(10)); - - return result; - } - static FieldParams Curve448 = new FieldParams( "IntegerPolynomial448", 28, 16, 1, 448, Arrays.asList( @@ -224,8 +194,7 @@ public class FieldGen { } static final FieldParams[] ALL_FIELDS = { - Curve25519, Curve448, - P256, P384, P521, O256, O384, O521, O25519, O448 + Curve448, P256, P384, P521, O256, O384, O521, O25519, O448 }; public static class Term { diff --git a/make/langtools/tools/previewfeature/SetupPreviewFeature.java b/make/langtools/tools/previewfeature/SetupPreviewFeature.java new file mode 100644 index 00000000000..2d5207f0e17 --- /dev/null +++ b/make/langtools/tools/previewfeature/SetupPreviewFeature.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2026, 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 previewfeature; + +import com.sun.source.util.JavacTask; +import com.sun.source.util.Trees; +import java.io.StringWriter; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import javax.lang.model.element.ElementKind; +import javax.tools.ToolProvider; + +/* Construct a hybrid PreviewFeature.Feature enum that includes constants both + * from the current JDK sources (so that they can be used in the javac API sources), + * and from the bootstrap JDK (so that they can be used in the bootstrap classfiles). + * + * This hybrid enum is only used for the interim javac. + */ +public class SetupPreviewFeature { + public static void main(String... args) throws Exception { + Class runtimeFeature = Class.forName("jdk.internal.javac.PreviewFeature$Feature"); + Set constantsToAdd = new HashSet<>(); + for (Field runtimeField : runtimeFeature.getDeclaredFields()) { + if (runtimeField.isEnumConstant()) { + constantsToAdd.add(runtimeField.getName()); + } + } + var dummy = new StringWriter(); + var compiler = ToolProvider.getSystemJavaCompiler(); + var source = Path.of(args[0]); + try (var fm = compiler.getStandardFileManager(null, null, null)) { + JavacTask task = + (JavacTask) compiler.getTask(dummy, null, null, null, null, fm.getJavaFileObjects(source)); + task.analyze(); + var sourceFeature = task.getElements() + .getTypeElement("jdk.internal.javac.PreviewFeature.Feature"); + int insertPosition = -1; + for (var el : sourceFeature.getEnclosedElements()) { + if (el.getKind() == ElementKind.ENUM_CONSTANT) { + constantsToAdd.remove(el.getSimpleName().toString()); + if (insertPosition == (-1)) { + var trees = Trees.instance(task); + var elPath = trees.getPath(el); + insertPosition = (int) trees.getSourcePositions() + .getStartPosition(elPath.getCompilationUnit(), + elPath.getLeaf()); + } + } + } + var target = Path.of(args[1]); + Files.createDirectories(target.getParent()); + if (constantsToAdd.isEmpty()) { + Files.copy(source, target); + } else { + String sourceCode = Files.readString(source); + try (var out = Files.newBufferedWriter(target)) { + out.write(sourceCode, 0, insertPosition); + out.write(constantsToAdd.stream() + .collect(Collectors.joining(", ", + "/*compatibility constants:*/ ", + ",\n"))); + out.write(sourceCode, insertPosition, sourceCode.length() - insertPosition); + } + } + } + } +} \ No newline at end of file diff --git a/make/modules/java.base/Copy.gmk b/make/modules/java.base/Copy.gmk index b8c1f2c05fa..43b9db651e0 100644 --- a/make/modules/java.base/Copy.gmk +++ b/make/modules/java.base/Copy.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2026, 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 @@ -172,6 +172,10 @@ ifeq ($(USE_EXTERNAL_LIBZ), true) LEGAL_EXCLUDES += zlib.md endif +ifneq ($(TOOLCHAIN_TYPE), gcc) + LEGAL_EXCLUDES += gcc.md +endif + $(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \ EXCLUDES := $(LEGAL_EXCLUDES), \ )) diff --git a/make/modules/java.base/Launcher.gmk b/make/modules/java.base/Launcher.gmk index 3a3920acb12..bfae0925c07 100644 --- a/make/modules/java.base/Launcher.gmk +++ b/make/modules/java.base/Launcher.gmk @@ -95,7 +95,8 @@ ifeq ($(call isTargetOsType, unix), true) CFLAGS := $(VERSION_CFLAGS), \ EXTRA_HEADER_DIRS := libjava, \ EXTRA_OBJECT_FILES := \ - $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc$(OBJ_SUFFIX), \ + $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc$(OBJ_SUFFIX) \ + $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc_errorcodes$(OBJ_SUFFIX), \ LD_SET_ORIGIN := false, \ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \ )) diff --git a/make/modules/java.desktop/lib/AwtLibraries.gmk b/make/modules/java.desktop/lib/AwtLibraries.gmk index 8b6b50b9e62..887dfab01df 100644 --- a/make/modules/java.desktop/lib/AwtLibraries.gmk +++ b/make/modules/java.desktop/lib/AwtLibraries.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, 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 @@ -99,14 +99,16 @@ ifeq ($(call isTargetOs, windows), true) $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc endif -# This is the object file to provide the dladdr API, which is not -# part of AIX. It occurs several times in the jdk code base. -# Do not include it. When statically linking the java -# launcher with all JDK and VM static libraries, we use the -# --whole-archive linker option. The duplicate objects in different -# static libraries cause linking errors due to duplicate symbols. ifeq ($(call isTargetOs, aix), true) + # This is the object file to provide the dladdr API, which is not + # part of AIX. It occurs several times in the jdk code base. + # Do not include it. When statically linking the java + # launcher with all JDK and VM static libraries, we use the + # --whole-archive linker option. The duplicate objects in different + # static libraries cause linking errors due to duplicate symbols. LIBAWT_STATIC_EXCLUDE_OBJS := porting_aix.o + + LIBAWT_CFLAGS += -I$(TOPDIR)/src/java.base/aix/native/include endif # -fgcse-after-reload improves performance of MaskFill in Java2D by 20% for @@ -423,6 +425,9 @@ endif ifeq ($(call isTargetOs, linux)+$(ENABLE_HEADLESS_ONLY), true+true) LIBJAWT_CFLAGS += -DHEADLESS endif +ifeq ($(call isTargetOs, aix)+$(ENABLE_HEADLESS_ONLY), true+true) + LIBJAWT_CFLAGS += -DHEADLESS +endif ifeq ($(call isTargetOs, windows)+$(call isTargetCpu, x86), true+true) LIBJAWT_LIBS_windows := kernel32.lib diff --git a/make/modules/java.desktop/lib/ClientLibraries.gmk b/make/modules/java.desktop/lib/ClientLibraries.gmk index b76cb8dc4e3..13a74ab409f 100644 --- a/make/modules/java.desktop/lib/ClientLibraries.gmk +++ b/make/modules/java.desktop/lib/ClientLibraries.gmk @@ -338,11 +338,8 @@ else # noexcept-type required for GCC 7 builds. Not required for GCC 8+. # expansion-to-defined required for GCC 9 builds. Not required for GCC 10+. # maybe-uninitialized required for GCC 8 builds. Not required for GCC 9+. - # calloc-transposed-args required for GCC 14 builds. (fixed upstream in - # Harfbuzz 032c931e1c0cfb20f18e5acb8ba005775242bd92) HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := class-memaccess noexcept-type \ - expansion-to-defined dangling-reference maybe-uninitialized \ - calloc-transposed-args + expansion-to-defined dangling-reference maybe-uninitialized HARFBUZZ_DISABLED_WARNINGS_clang := missing-field-initializers \ range-loop-analysis unused-variable HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244 diff --git a/make/modules/jdk.jpackage/Java.gmk b/make/modules/jdk.jpackage/Java.gmk index da66fc14009..1fd4d527217 100644 --- a/make/modules/jdk.jpackage/Java.gmk +++ b/make/modules/jdk.jpackage/Java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2026, 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,7 +29,7 @@ DISABLED_WARNINGS_java += dangling-doc-comments COPY += .gif .png .txt .spec .script .prerm .preinst \ .postrm .postinst .list .sh .desktop .copyright .control .plist .template \ - .icns .scpt .wxs .wxl .wxi .wxf .ico .bmp .tiff .service .xsl + .icns .scpt .wxs .wxl .wxi .wxf .ico .bmp .tiff .service .xsl .js CLEAN += .properties diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 0482011f561..6774e708f99 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2026, 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 @@ -63,7 +63,8 @@ ifeq ($(call isTargetOs, windows), true) BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c \ libExplicitAttach.c libImplicitAttach.c \ exelauncher.c libFDLeaker.c exeFDLeakTester.c \ - libChangeSignalDisposition.c exePrintSignalDisposition.c + libChangeSignalDisposition.c exePrintSignalDisposition.c \ + libConcNativeFork.c libPipesCloseOnExec.c BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX) BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib @@ -77,6 +78,9 @@ else BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerUnnamed := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerModule := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread + BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libConcNativeFork := -pthread + BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libPipesCloseOnExec := -pthread + BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libExplicitAttach := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libImplicitAttach := -pthread diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index a9ca91d9309..05b2514a456 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2014, 2024, Red Hat, Inc. All rights reserved. // Copyright 2025 Arm Limited and/or its affiliates. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -2233,15 +2233,9 @@ uint BoxLockNode::size(PhaseRegAlloc *ra_) const { void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const { st->print_cr("# MachUEPNode"); - if (UseCompressedClassPointers) { - st->print_cr("\tldrw rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tldrw r10, [rscratch2 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); - st->print_cr("\tcmpw rscratch1, r10"); - } else { - st->print_cr("\tldr rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tldr r10, [rscratch2 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); - st->print_cr("\tcmp rscratch1, r10"); - } + st->print_cr("\tldrw rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); + st->print_cr("\tldrw r10, [rscratch2 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); + st->print_cr("\tcmpw rscratch1, r10"); st->print_cr("\tbne, SharedRuntime::_ic_miss_stub"); } #endif @@ -2467,11 +2461,8 @@ bool Matcher::is_generic_vector(MachOper* opnd) { return opnd->opcode() == VREG; } +#ifdef ASSERT // Return whether or not this register is ever used as an argument. -// This function is used on startup to build the trampoline stubs in -// generateOptoStub. Registers not mentioned will be killed by the VM -// call in the trampoline, and arguments in those registers not be -// available to the callee. bool Matcher::can_be_java_arg(int reg) { return @@ -2492,11 +2483,7 @@ bool Matcher::can_be_java_arg(int reg) reg == V6_num || reg == V6_H_num || reg == V7_num || reg == V7_H_num; } - -bool Matcher::is_spillable_arg(int reg) -{ - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -2531,10 +2518,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? _FLOAT_REG_mask.size() : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con(jlong divisor) { - return false; -} - const RegMask& Matcher::divI_proj_mask() { ShouldNotReachHere(); return RegMask::EMPTY; @@ -3403,11 +3386,13 @@ encode %{ } else if (rtype == relocInfo::metadata_type) { __ mov_metadata(dst_reg, (Metadata*)con); } else { - assert(rtype == relocInfo::none, "unexpected reloc type"); + assert(rtype == relocInfo::none || rtype == relocInfo::external_word_type, "unexpected reloc type"); + // load fake address constants using a normal move if (! __ is_valid_AArch64_address(con) || con < (address)(uintptr_t)os::vm_page_size()) { __ mov(dst_reg, con); } else { + // no reloc so just use adrp and add uint64_t offset; __ adrp(dst_reg, con, offset); __ add(dst_reg, dst_reg, offset); @@ -3812,11 +3797,6 @@ frame %{ // Compiled code's Frame Pointer frame_pointer(R31); - // Interpreter stores its frame pointer in a register which is - // stored to the stack by I2CAdaptors. - // I2CAdaptors convert from interpreted java to compiled java. - interpreter_frame_pointer(R29); - // Stack alignment requirement stack_alignment(StackAlignmentInBytes); // Alignment size in bytes (128-bit -> 16 bytes) @@ -4535,6 +4515,18 @@ operand immP_1() interface(CONST_INTER); %} +// AOT Runtime Constants Address +operand immAOTRuntimeConstantsAddress() +%{ + // Check if the address is in the range of AOT Runtime Constants + predicate(AOTRuntimeConstants::contains((address)(n->get_ptr()))); + match(ConP); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + // Float and Double operands // Double Immediate operand immD() @@ -6898,6 +6890,20 @@ instruct loadConP1(iRegPNoSp dst, immP_1 con) ins_pipe(ialu_imm); %} +instruct loadAOTRCAddress(iRegPNoSp dst, immAOTRuntimeConstantsAddress con) +%{ + match(Set dst con); + + ins_cost(INSN_COST); + format %{ "adr $dst, $con\t# AOT Runtime Constants Address" %} + + ins_encode %{ + __ load_aotrc_address($dst$$Register, (address)$con$$constant); + %} + + ins_pipe(ialu_imm); +%} + // Load Narrow Pointer Constant instruct loadConN(iRegNNoSp dst, immN con) @@ -8008,6 +8014,21 @@ instruct membar_release_lock() %{ ins_pipe(pipe_serial); %} +instruct membar_storeload() %{ + match(MemBarStoreLoad); + ins_cost(VOLATILE_REF_COST*100); + + format %{ "MEMBAR-store-load\n\t" + "dmb ish" %} + + ins_encode %{ + __ block_comment("membar_storeload"); + __ membar(Assembler::StoreLoad); + %} + + ins_pipe(pipe_serial); +%} + instruct unnecessary_membar_volatile() %{ predicate(unnecessary_volatile(n)); match(MemBarVolatile); @@ -8037,6 +8058,20 @@ instruct membar_volatile() %{ ins_pipe(pipe_serial); %} +instruct membar_full() %{ + match(MemBarFull); + ins_cost(VOLATILE_REF_COST*100); + + format %{ "membar_full\n\t" + "dmb ish" %} + ins_encode %{ + __ block_comment("membar_full"); + __ membar(Assembler::AnyAny); + %} + + ins_pipe(pipe_serial); +%} + // ============================================================================ // Cast/Convert Instructions diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 19b3bb1a65b..67cf77989d2 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -3814,8 +3814,8 @@ public: } private: - void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, - bool isMerge, bool isFloat) { + void _sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, + bool isMerge, bool isFloat) { starti; assert(T != Q, "invalid size"); int sh = 0; @@ -3839,11 +3839,11 @@ private: public: // SVE copy signed integer immediate to vector elements (predicated) void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, bool isMerge) { - sve_cpy(Zd, T, Pg, imm8, isMerge, /*isFloat*/false); + _sve_cpy(Zd, T, Pg, imm8, isMerge, /*isFloat*/false); } // SVE copy floating-point immediate to vector elements (predicated) void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, double d) { - sve_cpy(Zd, T, Pg, checked_cast(pack(d)), /*isMerge*/true, /*isFloat*/true); + _sve_cpy(Zd, T, Pg, checked_cast(pack(d)), /*isMerge*/true, /*isFloat*/true); } // SVE conditionally select elements from two vectors diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp index c0621cbd5c2..e7d8c2d3648 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,6 +33,7 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" +#include "code/aotCodeCache.hpp" #include "code/compiledIC.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/gc_globals.hpp" @@ -58,22 +59,6 @@ const Register SHIFT_count = r0; // where count for shift operations must be #define __ _masm-> -static void select_different_registers(Register preserve, - Register extra, - Register &tmp1, - Register &tmp2) { - if (tmp1 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp1 = extra; - } else if (tmp2 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp2 = extra; - } - assert_different_registers(preserve, tmp1, tmp2); -} - - - static void select_different_registers(Register preserve, Register extra, Register &tmp1, @@ -532,6 +517,15 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod case T_LONG: { assert(patch_code == lir_patch_none, "no patching handled here"); +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + address b = c->as_pointer(); + if (AOTRuntimeConstants::contains(b)) { + __ load_aotrc_address(dest->as_register_lo(), b); + break; + } + } +#endif __ mov(dest->as_register_lo(), (intptr_t)c->as_jlong()); break; } @@ -1259,12 +1253,9 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } else if (obj == klass_RInfo) { klass_RInfo = dst; } - if (k->is_loaded() && !UseCompressedClassPointers) { - select_different_registers(obj, dst, k_RInfo, klass_RInfo); - } else { - Rtmp1 = op->tmp3()->as_register(); - select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); - } + + Rtmp1 = op->tmp3()->as_register(); + select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); assert_different_registers(obj, k_RInfo, klass_RInfo); diff --git a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp index ad26d494b2d..f10c5197d91 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1287,9 +1287,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ checkcast(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), info_for_exception, patching_info, stub, @@ -1308,9 +1306,7 @@ void LIRGenerator::do_InstanceOf(InstanceOf* x) { } obj.load_item(); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ instanceof(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); diff --git a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp index e934632715c..89a9422ea48 100644 --- a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -105,12 +105,8 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register } else { mov(t1, checked_cast(markWord::prototype().value())); str(t1, Address(obj, oopDesc::mark_offset_in_bytes())); - if (UseCompressedClassPointers) { // Take care not to kill klass - encode_klass_not_null(t1, klass); - strw(t1, Address(obj, oopDesc::klass_offset_in_bytes())); - } else { - str(klass, Address(obj, oopDesc::klass_offset_in_bytes())); - } + encode_klass_not_null(t1, klass); // Take care not to kill klass + strw(t1, Address(obj, oopDesc::klass_offset_in_bytes())); } if (len->is_valid()) { @@ -121,7 +117,7 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register // Clear gap/first 4 bytes following the length field. strw(zr, Address(obj, base_offset)); } - } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) { + } else if (!UseCompactObjectHeaders) { store_klass_gap(obj, zr); } } diff --git a/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp b/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp index 938a64dd399..bb6b3ce907e 100644 --- a/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp @@ -42,7 +42,6 @@ define_pd_global(bool, TieredCompilation, false); define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(intx, NewSizeThreadIncrease, 4*K ); define_pd_global(size_t, InitialCodeCacheSize, 160*K); define_pd_global(size_t, ReservedCodeCacheSize, 32*M ); define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M ); @@ -52,7 +51,6 @@ define_pd_global(bool, ProfileInterpreter, false); define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true ); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 958855c7685..7aab7d389e1 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -30,7 +30,9 @@ #include "opto/matcher.hpp" #include "opto/output.hpp" #include "opto/subnode.hpp" +#include "runtime/objectMonitorTable.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/synchronizer.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/powerOfTwo.hpp" @@ -221,37 +223,52 @@ void C2_MacroAssembler::fast_lock(Register obj, Register box, Register t1, if (!UseObjectMonitorTable) { assert(t1_monitor == t1_mark, "should be the same here"); } else { + const Register t1_hash = t1; Label monitor_found; - // Load cache address - lea(t3_t, Address(rthread, JavaThread::om_cache_oops_offset())); + // Save the mark, we might need it to extract the hash. + mov(t3, t1_mark); - const int num_unrolled = 2; + // Look for the monitor in the om_cache. + + ByteSize cache_offset = JavaThread::om_cache_oops_offset(); + ByteSize monitor_offset = OMCache::oop_to_monitor_difference(); + const int num_unrolled = OMCache::CAPACITY; for (int i = 0; i < num_unrolled; i++) { - ldr(t1, Address(t3_t)); - cmp(obj, t1); + ldr(t1_monitor, Address(rthread, cache_offset + monitor_offset)); + ldr(t2, Address(rthread, cache_offset)); + cmp(obj, t2); br(Assembler::EQ, monitor_found); - increment(t3_t, in_bytes(OMCache::oop_to_oop_difference())); + cache_offset = cache_offset + OMCache::oop_to_oop_difference(); } - Label loop; + // Look for the monitor in the table. - // Search for obj in cache. - bind(loop); + // Get the hash code. + ubfx(t1_hash, t3, markWord::hash_shift, markWord::hash_bits); - // Check for match. - ldr(t1, Address(t3_t)); - cmp(obj, t1); - br(Assembler::EQ, monitor_found); + // Get the table and calculate the bucket's address + lea(t3, ExternalAddress(ObjectMonitorTable::current_table_address())); + ldr(t3, Address(t3)); + ldr(t2, Address(t3, ObjectMonitorTable::table_capacity_mask_offset())); + ands(t1_hash, t1_hash, t2); + ldr(t3, Address(t3, ObjectMonitorTable::table_buckets_offset())); - // Search until null encountered, guaranteed _null_sentinel at end. - increment(t3_t, in_bytes(OMCache::oop_to_oop_difference())); - cbnz(t1, loop); - // Cache Miss, NE set from cmp above, cbnz does not set flags - b(slow_path); + // Read the monitor from the bucket. + ldr(t1_monitor, Address(t3, t1_hash, Address::lsl(LogBytesPerWord))); + + // Check if the monitor in the bucket is special (empty, tombstone or removed). + cmp(t1_monitor, (unsigned char)ObjectMonitorTable::SpecialPointerValues::below_is_special); + br(Assembler::LO, slow_path); + + // Check if object matches. + ldr(t3, Address(t1_monitor, ObjectMonitor::object_offset())); + BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); + bs_asm->try_resolve_weak_handle_in_c2(this, t3, t2, slow_path); + cmp(t3, obj); + br(Assembler::NE, slow_path); bind(monitor_found); - ldr(t1_monitor, Address(t3_t, OMCache::oop_to_monitor_difference())); } const Register t2_owner_addr = t2; @@ -2858,3 +2875,24 @@ void C2_MacroAssembler::vector_expand_sve(FloatRegister dst, FloatRegister src, // dst = 00 87 00 65 00 43 00 21 sve_tbl(dst, size, src, dst); } + +// Optimized SVE cpy (imm, zeroing) instruction. +// +// `movi; cpy(imm, merging)` and `cpy(imm, zeroing)` have the same +// functionality, but test results show that `movi; cpy(imm, merging)` has +// higher throughput on some microarchitectures. This would depend on +// microarchitecture and so may vary between implementations. +void C2_MacroAssembler::sve_cpy(FloatRegister dst, SIMD_RegVariant T, + PRegister pg, int imm8, bool isMerge) { + if (VM_Version::prefer_sve_merging_mode_cpy() && !isMerge) { + // Generates a NEON instruction `movi V.2d, #0`. + // On AArch64, Z and V registers alias in the low 128 bits, so V is + // the low 128 bits of Z. A write to V also clears all bits of + // Z above 128, so this `movi` instruction effectively zeroes the + // entire Z register. According to the Arm Software Optimization + // Guide, `movi` is zero latency. + movi(dst, T2D, 0); + isMerge = true; + } + Assembler::sve_cpy(dst, T, pg, imm8, isMerge); +} diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp index 4f3a41da402..5c05832afbe 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp @@ -75,6 +75,8 @@ unsigned vector_length_in_bytes); public: + using Assembler::sve_cpy; + // jdk.internal.util.ArraysSupport.vectorizedHashCode address arrays_hashcode(Register ary, Register cnt, Register result, FloatRegister vdata0, FloatRegister vdata1, FloatRegister vdata2, FloatRegister vdata3, @@ -244,4 +246,7 @@ void vector_expand_sve(FloatRegister dst, FloatRegister src, PRegister pg, FloatRegister tmp1, FloatRegister tmp2, BasicType bt, int vector_length_in_bytes); + + void sve_cpy(FloatRegister dst, SIMD_RegVariant T, PRegister pg, int imm8, + bool isMerge); #endif // CPU_AARCH64_C2_MACROASSEMBLER_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp index a0dea3643a1..192461d1a61 100644 --- a/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp @@ -47,7 +47,6 @@ define_pd_global(intx, ConditionalMoveLimit, 3); define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, MinJumpTableSize, 10); define_pd_global(intx, InteriorEntryAlignment, 16); -define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, LoopUnrollLimit, 60); define_pd_global(intx, LoopPercentProfileLimit, 10); // InitialCodeCacheSize derived from specjbb2000 run. @@ -75,9 +74,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheMinBlockLength, 6); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed. #endif // CPU_AARCH64_C2_GLOBALS_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp b/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp index 65d448f908c..130d2949800 100644 --- a/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -146,10 +146,10 @@ void DowncallLinker::StubGenerator::generate() { bool should_save_return_value = !_needs_return_buffer; RegSpiller out_reg_spiller(_output_registers); - int spill_offset = -1; + int out_spill_offset = -1; if (should_save_return_value) { - spill_offset = 0; + out_spill_offset = 0; // spill area can be shared with shadow space and out args, // since they are only used before the call, // and spill area is only used after. @@ -174,6 +174,9 @@ void DowncallLinker::StubGenerator::generate() { // FP-> | | // |---------------------| = frame_bottom_offset = frame_size // | (optional) | + // | in_reg_spiller area | + // |---------------------| + // | (optional) | // | capture state buf | // |---------------------| = StubLocations::CAPTURED_STATE_BUFFER // | (optional) | @@ -187,6 +190,19 @@ void DowncallLinker::StubGenerator::generate() { GrowableArray out_regs = ForeignGlobals::replace_place_holders(_input_registers, locs); ArgumentShuffle arg_shuffle(filtered_java_regs, out_regs, shuffle_reg); + // Need to spill for state capturing runtime call. + // The area spilled into is distinct from the capture state buffer. + RegSpiller in_reg_spiller(out_regs); + int in_spill_offset = -1; + if (_captured_state_mask != 0) { + // The spill area cannot be shared with the out_spill since + // spilling needs to happen before the call. Allocate a new + // region in the stack for this spill space. + in_spill_offset = allocated_frame_size; + allocated_frame_size += in_reg_spiller.spill_size_bytes(); + } + + #ifndef PRODUCT LogTarget(Trace, foreign, downcall) lt; if (lt.is_enabled()) { @@ -228,6 +244,20 @@ void DowncallLinker::StubGenerator::generate() { arg_shuffle.generate(_masm, shuffle_reg, 0, _abi._shadow_space_bytes); __ block_comment("} argument shuffle"); + if (_captured_state_mask != 0) { + assert(in_spill_offset != -1, "must be"); + __ block_comment("{ load initial thread local"); + in_reg_spiller.generate_spill(_masm, in_spill_offset); + + // Copy the contents of the capture state buffer into thread local + __ ldr(c_rarg0, Address(sp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); + __ movw(c_rarg1, _captured_state_mask); + __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_pre), tmp1); + + in_reg_spiller.generate_fill(_masm, in_spill_offset); + __ block_comment("} load initial thread local"); + } + __ blr(as_Register(locs.get(StubLocations::TARGET_ADDRESS))); // this call is assumed not to have killed rthread @@ -254,15 +284,15 @@ void DowncallLinker::StubGenerator::generate() { __ block_comment("{ save thread local"); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ ldr(c_rarg0, Address(sp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); __ movw(c_rarg1, _captured_state_mask); - __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state), tmp1); + __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_post), tmp1); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ block_comment("} save thread local"); @@ -321,7 +351,7 @@ void DowncallLinker::StubGenerator::generate() { if (should_save_return_value) { // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ mov(c_rarg0, rthread); @@ -330,7 +360,7 @@ void DowncallLinker::StubGenerator::generate() { __ blr(tmp1); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ b(L_after_safepoint_poll); @@ -342,13 +372,13 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_reguard); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ rt_call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), tmp1); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ b(L_after_reguard); diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp b/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp index cb53d8663ad..748ab0e0e2b 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -245,8 +245,8 @@ inline bool frame::equal(frame other) const { // Return unique id for this frame. The id must have a value where we can distinguish // identity and younger/older relationship. null represents an invalid (incomparable) -// frame. -inline intptr_t* frame::id(void) const { return unextended_sp(); } +// frame. Should not be called for heap frames. +inline intptr_t* frame::id(void) const { return real_fp(); } // Return true if the frame is older (less recent activation) than the frame represented by id inline bool frame::is_older(intptr_t* id) const { assert(this->id() != nullptr && id != nullptr, "null frame id"); @@ -412,6 +412,9 @@ inline frame frame::sender(RegisterMap* map) const { StackWatermarkSet::on_iteration(map->thread(), result); } + // Calling frame::id() is currently not supported for heap frames. + assert(result._on_heap || this->_on_heap || result.is_older(this->id()), "Must be"); + return result; } diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp index d7884c27a2c..68291720208 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp @@ -23,6 +23,7 @@ */ #include "asm/macroAssembler.inline.hpp" +#include "code/aotCodeCache.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" @@ -243,9 +244,25 @@ static void generate_post_barrier(MacroAssembler* masm, assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, noreg, rscratch1); // Does store cross heap regions? - __ eor(tmp1, store_addr, new_val); // tmp1 := store address ^ new value - __ lsr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); // tmp1 := ((store address ^ new value) >> LogOfHRGrainBytes) - __ cbz(tmp1, done); + #if INCLUDE_CDS + // AOT code needs to load the barrier grain shift from the aot + // runtime constants area in the code cache otherwise we can compile + // it as an immediate operand + if (AOTCodeCache::is_on_for_dump()) { + address grain_shift_address = (address)AOTRuntimeConstants::grain_shift_address(); + __ eor(tmp1, store_addr, new_val); + __ lea(tmp2, ExternalAddress(grain_shift_address)); + __ ldrb(tmp2, tmp2); + __ lsrv(tmp1, tmp1, tmp2); + __ cbz(tmp1, done); + } else +#endif + { + __ eor(tmp1, store_addr, new_val); // tmp1 := store address ^ new value + __ lsr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); // tmp1 := ((store address ^ new value) >> LogOfHRGrainBytes) + __ cbz(tmp1, done); + } + // Crosses regions, storing null? if (new_val_may_be_null) { __ cbz(new_val, done); diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp index 021af3e5698..2a78d688097 100644 --- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -441,6 +441,11 @@ OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Na return opto_reg; } +void BarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Load the oop from the weak handle. + __ ldr(obj, Address(obj)); +} + #undef __ #define __ _masm-> diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp index e69be999f00..c2581b2f962 100644 --- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -135,6 +135,7 @@ public: OptoReg::Name opto_reg); OptoReg::Name refine_register(const Node* node, OptoReg::Name opto_reg); + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); #endif // COMPILER2 }; diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp index ad7bac4e067..2f7707227b4 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -442,6 +443,30 @@ void ShenandoahBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler __ bind(done); } +#ifdef COMPILER2 +void ShenandoahBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, + Register tmp, Label& slow_path) { + assert_different_registers(obj, tmp); + + Label done; + + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, tmp, slow_path); + + // Check if the reference is null, and if it is, take the fast path. + __ cbz(obj, done); + + Address gc_state(rthread, ShenandoahThreadLocalData::gc_state_offset()); + __ lea(tmp, gc_state); + __ ldrb(tmp, __ legitimize_address(gc_state, 1, tmp)); + + // Check if the heap is under weak-reference/roots processing, in + // which case we need to take the slow path. + __ tbnz(tmp, ShenandoahHeap::WEAK_ROOTS_BITPOS, slow_path); + __ bind(done); +} +#endif + // Special Shenandoah CAS implementation that handles false negatives due // to concurrent evacuation. The service is more complex than a // traditional CAS operation because the CAS operation is intended to diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp index 362fcae1ccd..d5d5ce8950e 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,6 +80,9 @@ public: Address dst, Register val, Register tmp1, Register tmp2, Register tmp3); virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); +#ifdef COMPILER2 + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); +#endif void cmpxchg_oop(MacroAssembler* masm, Register addr, Register expected, Register new_val, bool acquire, bool release, bool is_cae, Register result); }; diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp index 07a2d6fbfa0..4f0977a414f 100644 --- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -1326,6 +1326,23 @@ void ZStoreBarrierStubC2Aarch64::emit_code(MacroAssembler& masm) { register_stub(this); } +#undef __ +#define __ masm-> + +void ZBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, tmp, slow_path); + + // Check if the oop is bad, in which case we need to take the slow path. + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatMarkBadBeforeMov); + __ movzw(tmp, barrier_Relocation::unpatched); + __ tst(obj, tmp); + __ br(Assembler::NE, slow_path); + + // Oop is okay, so we uncolor it. + __ lsr(obj, obj, ZPointerLoadShift); +} + #undef __ #endif // COMPILER2 diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp index 487970ab0c5..fbbc5c1b517 100644 --- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -191,6 +191,7 @@ public: ZLoadBarrierStubC2* stub) const; void generate_c2_store_barrier_stub(MacroAssembler* masm, ZStoreBarrierStubC2* stub) const; + void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); #endif // COMPILER2 void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error); diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp index a59e83c4b69..e6de2c798b1 100644 --- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -95,7 +95,7 @@ define_pd_global(intx, InlineSmallCode, 1000); "Use simplest and shortest implementation for array equals") \ product(bool, UseSIMDForBigIntegerShiftIntrinsics, true, \ "Use SIMD instructions for left/right shift of BigInteger") \ - product(bool, UseSIMDForSHA3Intrinsic, true, \ + product(bool, UseSIMDForSHA3Intrinsic, false, \ "Use SIMD SHA3 instructions for SHA3 intrinsic") \ product(bool, AvoidUnalignedAccesses, false, \ "Avoid generating unaligned memory accesses") \ diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp index 2b506b241e0..980fedb406d 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -989,26 +989,15 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) { void InterpreterMacroAssembler::profile_virtual_call(Register receiver, - Register mdp, - bool receiver_can_be_null) { + Register mdp) { if (ProfileInterpreter) { Label profile_continue; // If no method data exists, go to profile_continue. test_method_data_pointer(mdp, profile_continue); - Label skip_receiver_profile; - if (receiver_can_be_null) { - Label not_null; - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); - b(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. profile_receiver_type(receiver, mdp, 0); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp index 74d4430000d..9a074f1ce69 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -285,8 +285,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_not_taken_branch(Register mdp); void profile_call(Register mdp); void profile_final_call(Register mdp); - void profile_virtual_call(Register receiver, Register mdp, - bool receiver_can_be_null = false); + void profile_virtual_call(Register receiver, Register mdp); void profile_ret(Register return_bci, Register mdp); void profile_null_seen(Register mdp); void profile_typecheck(Register mdp, Register klass); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 409343b6b8d..732d94180ae 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -406,7 +406,6 @@ public: offset <<= shift; uint64_t target_page = ((uint64_t)insn_addr) + offset; target_page &= ((uint64_t)-1) << shift; - uint32_t insn2 = insn_at(insn_addr, 1); target = address(target_page); precond(inner != nullptr); inner(insn_addr, target); @@ -520,13 +519,6 @@ int MacroAssembler::patch_narrow_klass(address insn_addr, narrowKlass n) { return 2 * NativeInstruction::instruction_size; } -address MacroAssembler::target_addr_for_insn_or_null(address insn_addr) { - if (NativeInstruction::is_ldrw_to_zr(insn_addr)) { - return nullptr; - } - return MacroAssembler::target_addr_for_insn(insn_addr); -} - void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp) { ldr(tmp, Address(rthread, JavaThread::polling_word_offset())); if (at_return) { @@ -770,7 +762,7 @@ void MacroAssembler::call_VM_base(Register oop_result, assert(java_thread == rthread, "unexpected register"); #ifdef ASSERT // TraceBytecodes does not use r12 but saves it over the call, so don't verify - // if ((UseCompressedOops || UseCompressedClassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?"); + // if (!TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?"); #endif // ASSERT assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result"); @@ -1010,14 +1002,10 @@ int MacroAssembler::ic_check(int end_alignment) { load_narrow_klass_compact(tmp1, receiver); ldrw(tmp2, Address(data, CompiledICData::speculated_klass_offset())); cmpw(tmp1, tmp2); - } else if (UseCompressedClassPointers) { + } else { ldrw(tmp1, Address(receiver, oopDesc::klass_offset_in_bytes())); ldrw(tmp2, Address(data, CompiledICData::speculated_klass_offset())); cmpw(tmp1, tmp2); - } else { - ldr(tmp1, Address(receiver, oopDesc::klass_offset_in_bytes())); - ldr(tmp2, Address(data, CompiledICData::speculated_klass_offset())); - cmp(tmp1, tmp2); } Label dont; @@ -1960,9 +1948,7 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass, const Register r_array_base = temp1, - r_array_length = temp2, - r_array_index = noreg, // unused - r_bitmap = noreg; // unused + r_array_length = temp2; BLOCK_COMMENT("verify_secondary_supers_table {"); @@ -3288,7 +3274,6 @@ int MacroAssembler::pop_p(unsigned int bitset, Register stack) { #ifdef ASSERT void MacroAssembler::verify_heapbase(const char* msg) { #if 0 - assert (UseCompressedOops || UseCompressedClassPointers, "should be compressed"); assert (Universe::heap() != nullptr, "java heap should be initialized"); if (!UseCompressedOops || Universe::ptr_base() == nullptr) { // rheapbase is allocated as general register @@ -3611,9 +3596,8 @@ extern "C" void findpc(intptr_t x); void MacroAssembler::debug64(char* msg, int64_t pc, int64_t regs[]) { // In order to get locks to work, we need to fake a in_VM state - if (ShowMessageBoxOnError ) { + if (ShowMessageBoxOnError) { JavaThread* thread = JavaThread::current(); - JavaThreadState saved_state = thread->thread_state(); thread->set_thread_state(_thread_in_vm); #ifndef PRODUCT if (CountBytecodes || TraceBytecodes || StopInterpreterAt) { @@ -5078,13 +5062,10 @@ void MacroAssembler::load_narrow_klass_compact(Register dst, Register src) { void MacroAssembler::load_klass(Register dst, Register src) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(dst, src); - decode_klass_not_null(dst); - } else if (UseCompressedClassPointers) { - ldrw(dst, Address(src, oopDesc::klass_offset_in_bytes())); - decode_klass_not_null(dst); } else { - ldr(dst, Address(src, oopDesc::klass_offset_in_bytes())); + ldrw(dst, Address(src, oopDesc::klass_offset_in_bytes())); } + decode_klass_not_null(dst); } void MacroAssembler::restore_cpu_control_state_after_jni(Register tmp1, Register tmp2) { @@ -5136,25 +5117,21 @@ void MacroAssembler::load_mirror(Register dst, Register method, Register tmp1, R void MacroAssembler::cmp_klass(Register obj, Register klass, Register tmp) { assert_different_registers(obj, klass, tmp); - if (UseCompressedClassPointers) { - if (UseCompactObjectHeaders) { - load_narrow_klass_compact(tmp, obj); - } else { - ldrw(tmp, Address(obj, oopDesc::klass_offset_in_bytes())); - } - if (CompressedKlassPointers::base() == nullptr) { - cmp(klass, tmp, LSL, CompressedKlassPointers::shift()); - return; - } else if (((uint64_t)CompressedKlassPointers::base() & 0xffffffff) == 0 - && CompressedKlassPointers::shift() == 0) { - // Only the bottom 32 bits matter - cmpw(klass, tmp); - return; - } - decode_klass_not_null(tmp); + if (UseCompactObjectHeaders) { + load_narrow_klass_compact(tmp, obj); } else { - ldr(tmp, Address(obj, oopDesc::klass_offset_in_bytes())); + ldrw(tmp, Address(obj, oopDesc::klass_offset_in_bytes())); } + if (CompressedKlassPointers::base() == nullptr) { + cmp(klass, tmp, LSL, CompressedKlassPointers::shift()); + return; + } else if (((uint64_t)CompressedKlassPointers::base() & 0xffffffff) == 0 + && CompressedKlassPointers::shift() == 0) { + // Only the bottom 32 bits matter + cmpw(klass, tmp); + return; + } + decode_klass_not_null(tmp); cmp(klass, tmp); } @@ -5162,36 +5139,25 @@ void MacroAssembler::cmp_klasses_from_objects(Register obj1, Register obj2, Regi if (UseCompactObjectHeaders) { load_narrow_klass_compact(tmp1, obj1); load_narrow_klass_compact(tmp2, obj2); - cmpw(tmp1, tmp2); - } else if (UseCompressedClassPointers) { + } else { ldrw(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); ldrw(tmp2, Address(obj2, oopDesc::klass_offset_in_bytes())); - cmpw(tmp1, tmp2); - } else { - ldr(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); - ldr(tmp2, Address(obj2, oopDesc::klass_offset_in_bytes())); - cmp(tmp1, tmp2); } + cmpw(tmp1, tmp2); } void MacroAssembler::store_klass(Register dst, Register src) { // FIXME: Should this be a store release? concurrent gcs assumes // klass length is valid if klass field is not null. assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - encode_klass_not_null(src); - strw(src, Address(dst, oopDesc::klass_offset_in_bytes())); - } else { - str(src, Address(dst, oopDesc::klass_offset_in_bytes())); - } + encode_klass_not_null(src); + strw(src, Address(dst, oopDesc::klass_offset_in_bytes())); } void MacroAssembler::store_klass_gap(Register dst, Register src) { assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - // Store to klass gap in destination - strw(src, Address(dst, oopDesc::klass_gap_offset_in_bytes())); - } + // Store to klass gap in destination + strw(src, Address(dst, oopDesc::klass_gap_offset_in_bytes())); } // Algorithm must match CompressedOops::encode. @@ -5337,8 +5303,6 @@ MacroAssembler::KlassDecodeMode MacroAssembler::klass_decode_mode() { } MacroAssembler::KlassDecodeMode MacroAssembler::klass_decode_mode(address base, int shift, const size_t range) { - assert(UseCompressedClassPointers, "not using compressed class pointers"); - // KlassDecodeMode shouldn't be set already. assert(_klass_decode_mode == KlassDecodeNone, "set once"); @@ -5468,8 +5432,6 @@ void MacroAssembler::decode_klass_not_null_for_aot(Register dst, Register src) { } void MacroAssembler::decode_klass_not_null(Register dst, Register src) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); - if (AOTCodeCache::is_on_for_dump()) { decode_klass_not_null_for_aot(dst, src); return; @@ -5536,7 +5498,6 @@ void MacroAssembler::set_narrow_oop(Register dst, jobject obj) { } void MacroAssembler::set_narrow_klass(Register dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int index = oop_recorder()->find_index(k); @@ -5738,7 +5699,6 @@ address MacroAssembler::read_polling_page(Register r, relocInfo::relocType rtype } void MacroAssembler::adrp(Register reg1, const Address &dest, uint64_t &byte_offset) { - relocInfo::relocType rtype = dest.rspec().reloc()->type(); uint64_t low_page = (uint64_t)CodeCache::low_bound() >> 12; uint64_t high_page = (uint64_t)(CodeCache::high_bound()-1) >> 12; uint64_t dest_page = (uint64_t)dest.target() >> 12; @@ -5766,6 +5726,14 @@ void MacroAssembler::adrp(Register reg1, const Address &dest, uint64_t &byte_off } void MacroAssembler::load_byte_map_base(Register reg) { +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + address byte_map_base_adr = AOTRuntimeConstants::card_table_base_address(); + lea(reg, ExternalAddress(byte_map_base_adr)); + ldr(reg, Address(reg)); + return; + } +#endif CardTableBarrierSet* ctbs = CardTableBarrierSet::barrier_set(); // Strictly speaking the card table base isn't an address at all, and it might @@ -5773,6 +5741,20 @@ void MacroAssembler::load_byte_map_base(Register reg) { mov(reg, (uint64_t)ctbs->card_table_base_const()); } +void MacroAssembler::load_aotrc_address(Register reg, address a) { +#if INCLUDE_CDS + assert(AOTRuntimeConstants::contains(a), "address out of range for data area"); + if (AOTCodeCache::is_on_for_dump()) { + // all aotrc field addresses should be registered in the AOTCodeCache address table + lea(reg, ExternalAddress(a)); + } else { + mov(reg, (uint64_t)a); + } +#else + ShouldNotReachHere(); +#endif +} + void MacroAssembler::build_frame(int framesize) { assert(framesize >= 2 * wordSize, "framesize must include space for FP/LR"); assert(framesize % (2*wordSize) == 0, "must preserve 2*wordSize alignment"); @@ -6114,7 +6096,6 @@ void MacroAssembler::string_equals(Register a1, Register a2, Label SAME, DONE, SHORT, NEXT_WORD; Register tmp1 = rscratch1; Register tmp2 = rscratch2; - Register cnt2 = tmp2; // cnt2 only used in array length compare assert_different_registers(a1, a2, result, cnt1, rscratch1, rscratch2); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index 7eb6cea0614..fa32f3055b9 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -678,7 +678,6 @@ public: static bool uses_implicit_null_check(void* address); static address target_addr_for_insn(address insn_addr); - static address target_addr_for_insn_or_null(address insn_addr); // Required platform-specific helpers for Label::patch_instructions. // They _shadow_ the declarations in AbstractAssembler, which are undefined. @@ -1477,6 +1476,9 @@ public: // Load the base of the cardtable byte map into reg. void load_byte_map_base(Register reg); + // Load a constant address in the AOT Runtime Constants area + void load_aotrc_address(Register reg, address a); + // Prolog generator routines to support switch between x86 code and // generated ARM code diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp index 0cdf36f0bc5..8b76b96d345 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -192,7 +192,6 @@ int NativeMovRegMem::offset() const { void NativeMovRegMem::set_offset(int x) { address pc = instruction_address(); - unsigned insn = *(unsigned*)pc; if (maybe_cpool_ref(pc)) { address addr = MacroAssembler::target_addr_for_insn(pc); *(int64_t*)addr = x; @@ -204,7 +203,7 @@ void NativeMovRegMem::set_offset(int x) { void NativeMovRegMem::verify() { #ifdef ASSERT - address dest = MacroAssembler::target_addr_for_insn_or_null(instruction_address()); + MacroAssembler::target_addr_for_insn(instruction_address()); #endif } @@ -213,7 +212,7 @@ void NativeMovRegMem::verify() { void NativeJump::verify() { ; } address NativeJump::jump_destination() const { - address dest = MacroAssembler::target_addr_for_insn_or_null(instruction_address()); + address dest = MacroAssembler::target_addr_for_insn(instruction_address()); // We use jump to self as the unresolved address which the inline // cache code (and relocs) know about diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp index 15b6c9ff215..fc7274714ad 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2025, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -78,7 +78,6 @@ public: inline bool is_nop() const; bool is_jump(); bool is_general_jump(); - inline bool is_jump_or_nop(); inline bool is_cond_jump(); bool is_safepoint_poll(); bool is_movz(); @@ -420,10 +419,6 @@ inline bool NativeInstruction::is_jump() { return false; } -inline bool NativeInstruction::is_jump_or_nop() { - return is_nop() || is_jump(); -} - // Call trampoline stubs. class NativeCallTrampolineStub : public NativeInstruction { public: diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index a459a28b09e..21a1124a8ec 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -11876,16 +11876,13 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_sha512_implCompress = generate_sha512_implCompress(StubId::stubgen_sha512_implCompress_id); StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(StubId::stubgen_sha512_implCompressMB_id); } - if (UseSHA3Intrinsics) { - + if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) { StubRoutines::_double_keccak = generate_double_keccak(); - if (UseSIMDForSHA3Intrinsic) { - StubRoutines::_sha3_implCompress = generate_sha3_implCompress(StubId::stubgen_sha3_implCompress_id); - StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress(StubId::stubgen_sha3_implCompressMB_id); - } else { - StubRoutines::_sha3_implCompress = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompress_id); - StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompressMB_id); - } + StubRoutines::_sha3_implCompress = generate_sha3_implCompress(StubId::stubgen_sha3_implCompress_id); + StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress(StubId::stubgen_sha3_implCompressMB_id); + } else if (UseSHA3Intrinsics) { + StubRoutines::_sha3_implCompress = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompress_id); + StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompressMB_id); } if (UsePoly1305Intrinsics) { diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index 5d4f7103a84..69769fb8441 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -96,10 +96,6 @@ static inline Address aaddress(Register r) { return iaddress(r); } -static inline Address at_rsp() { - return Address(esp, 0); -} - // At top of Java expression stack which may be different than esp(). It // isn't for category 1 objects. static inline Address at_tos () { diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index 0a7bc5a8962..4423d9c5b58 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Red Hat Inc. All rights reserved. * Copyright 2025 Arm Limited and/or its affiliates. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -365,16 +365,28 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseSHA && VM_Version::supports_sha3()) { - // Auto-enable UseSHA3Intrinsics on hardware with performance benefit. - // Note that the evaluation of UseSHA3Intrinsics shows better performance + if (UseSHA) { + // No need to check VM_Version::supports_sha3(), since a fallback GPR intrinsic implementation is provided. + if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA3Intrinsics, true); + } + } else if (UseSHA3Intrinsics) { + // Matches the documented and tested behavior: the -UseSHA option disables all SHA intrinsics. + warning("UseSHA3Intrinsics requires that UseSHA is enabled."); + FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); + } + + if (UseSHA3Intrinsics && VM_Version::supports_sha3()) { + // Auto-enable UseSIMDForSHA3Intrinsic on hardware with performance benefit. + // Note that the evaluation of SHA3 extension Intrinsics shows better performance // on Apple and Qualcomm silicon but worse performance on Neoverse V1 and N2. if (_cpu == CPU_APPLE || _cpu == CPU_QUALCOMM) { // Apple or Qualcomm silicon - if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) { - FLAG_SET_DEFAULT(UseSHA3Intrinsics, true); + if (FLAG_IS_DEFAULT(UseSIMDForSHA3Intrinsic)) { + FLAG_SET_DEFAULT(UseSIMDForSHA3Intrinsic, true); } } - } else if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) { + } + if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic && !VM_Version::supports_sha3()) { warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU."); FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); } @@ -446,7 +458,9 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(BlockZeroingLowLimit, 4 * VM_Version::zva_length()); } } else if (UseBlockZeroing) { - warning("DC ZVA is not available on this CPU"); + if (!FLAG_IS_DEFAULT(UseBlockZeroing)) { + warning("DC ZVA is not available on this CPU"); + } FLAG_SET_DEFAULT(UseBlockZeroing, false); } @@ -664,16 +678,52 @@ void VM_Version::initialize() { void VM_Version::insert_features_names(uint64_t features, stringStream& ss) { int i = 0; ss.join([&]() { - while (i < MAX_CPU_FEATURES) { - if (supports_feature((VM_Version::Feature_Flag)i)) { - return _features_names[i++]; + const char* str = nullptr; + while ((i < MAX_CPU_FEATURES) && (str == nullptr)) { + if (supports_feature(features, (VM_Version::Feature_Flag)i)) { + str = _features_names[i]; } i += 1; } - return (const char*)nullptr; + return str; }, ", "); } +void VM_Version::get_cpu_features_name(void* features_buffer, stringStream& ss) { + uint64_t features = *(uint64_t*)features_buffer; + insert_features_names(features, ss); +} + +void VM_Version::get_missing_features_name(void* features_set1, void* features_set2, stringStream& ss) { + uint64_t vm_features_set1 = *(uint64_t*)features_set1; + uint64_t vm_features_set2 = *(uint64_t*)features_set2; + int i = 0; + ss.join([&]() { + const char* str = nullptr; + while ((i < MAX_CPU_FEATURES) && (str == nullptr)) { + Feature_Flag flag = (Feature_Flag)i; + if (supports_feature(vm_features_set1, flag) && !supports_feature(vm_features_set2, flag)) { + str = _features_names[i]; + } + i += 1; + } + return str; + }, ", "); +} + +int VM_Version::cpu_features_size() { + return sizeof(_features); +} + +void VM_Version::store_cpu_features(void* buf) { + *(uint64_t*)buf = _features; +} + +bool VM_Version::supports_features(void* features_buffer) { + uint64_t features_to_test = *(uint64_t*)features_buffer; + return (_features & features_to_test) == features_to_test; +} + #if defined(LINUX) static bool check_info_file(const char* fpath, const char* virt1, VirtualizationType vt1, diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp index 38b112d9936..e8681611234 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -55,6 +55,9 @@ protected: static int _max_supported_sve_vector_length; static bool _rop_protection; static uintptr_t _pac_mask; + // When _prefer_sve_merging_mode_cpy is true, `cpy (imm, zeroing)` is + // implemented as `movi; cpy(imm, merging)`. + static constexpr bool _prefer_sve_merging_mode_cpy = true; static SpinWait _spin_wait; @@ -184,6 +187,9 @@ public: static bool supports_feature(Feature_Flag flag) { return (_features & BIT_MASK(flag)) != 0; } + static bool supports_feature(uint64_t features, Feature_Flag flag) { + return (features & BIT_MASK(flag)) != 0; + } static int cpu_family() { return _cpu; } static int cpu_model() { return _model; } @@ -204,7 +210,7 @@ public: return false; } - static bool is_zva_enabled() { return 0 <= _zva_length; } + static bool is_zva_enabled() { return 0 < _zva_length; } static int zva_length() { assert(is_zva_enabled(), "ZVA not available"); return _zva_length; @@ -239,11 +245,27 @@ public: static bool use_rop_protection() { return _rop_protection; } + static bool prefer_sve_merging_mode_cpy() { return _prefer_sve_merging_mode_cpy; } + // For common 64/128-bit unpredicated vector operations, we may prefer // emitting NEON instructions rather than the corresponding SVE instructions. static bool use_neon_for_vector(int vector_length_in_bytes) { return vector_length_in_bytes <= 16; } + + static void get_cpu_features_name(void* features_buffer, stringStream& ss); + + // Returns names of features present in features_set1 but not in features_set2 + static void get_missing_features_name(void* features_set1, void* features_set2, stringStream& ss); + + // Returns number of bytes required to store cpu features representation + static int cpu_features_size(); + + // Stores cpu features representation in the provided buffer. This representation is arch dependent. + // Size of the buffer must be same as returned by cpu_features_size() + static void store_cpu_features(void* buf); + + static bool supports_features(void* features_to_test); }; #endif // CPU_AARCH64_VM_VERSION_AARCH64_HPP diff --git a/src/hotspot/cpu/arm/arm.ad b/src/hotspot/cpu/arm/arm.ad index 606275d7666..60a0ef307b5 100644 --- a/src/hotspot/cpu/arm/arm.ad +++ b/src/hotspot/cpu/arm/arm.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2008, 2026, 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 @@ -1088,10 +1088,8 @@ bool Matcher::pd_clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, return clone_base_plus_offset_address(m, mstack, address_visited); } -// Return whether or not this register is ever used as an argument. This -// function is used on startup to build the trampoline stubs in generateOptoStub. -// Registers not mentioned will be killed by the VM call in the trampoline, and -// arguments in those registers not be available to the callee. +#ifdef ASSERT +// Return whether or not this register is ever used as an argument. bool Matcher::can_be_java_arg( int reg ) { if (reg == R_R0_num || reg == R_R1_num || @@ -1102,10 +1100,7 @@ bool Matcher::can_be_java_arg( int reg ) { reg <= R_S13_num) return true; return false; } - -bool Matcher::is_spillable_arg( int reg ) { - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -1117,10 +1112,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? 30 : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) { - return false; -} - // Register for DIVI projection of divmodI const RegMask& Matcher::divI_proj_mask() { ShouldNotReachHere(); @@ -4445,6 +4436,18 @@ instruct membar_release_lock() %{ ins_pipe(empty); %} +instruct membar_storeload() %{ + match(MemBarStoreLoad); + ins_cost(4*MEMORY_REF_COST); + + size(4); + format %{ "MEMBAR-storeload" %} + ins_encode %{ + __ membar(MacroAssembler::StoreLoad, noreg); + %} + ins_pipe(long_memory_op); +%} + instruct membar_volatile() %{ match(MemBarVolatile); ins_cost(4*MEMORY_REF_COST); @@ -4468,6 +4471,18 @@ instruct unnecessary_membar_volatile() %{ ins_pipe(empty); %} +instruct membar_full() %{ + match(MemBarFull); + ins_cost(4*MEMORY_REF_COST); + + size(4); + format %{ "MEMBAR-full" %} + ins_encode %{ + __ membar(MacroAssembler::StoreLoad, noreg); + %} + ins_pipe(long_memory_op); +%} + //----------Register Move Instructions----------------------------------------- // Cast Index to Pointer for unsafe natives diff --git a/src/hotspot/cpu/arm/c1_globals_arm.hpp b/src/hotspot/cpu/arm/c1_globals_arm.hpp index 1fe5f1a23ee..9db999e81b3 100644 --- a/src/hotspot/cpu/arm/c1_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c1_globals_arm.hpp @@ -43,7 +43,6 @@ define_pd_global(bool, TieredCompilation, false); define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(size_t, NewSizeThreadIncrease, 4*K ); define_pd_global(size_t, InitialCodeCacheSize, 160*K); define_pd_global(size_t, ReservedCodeCacheSize, 32*M ); define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M ); @@ -53,7 +52,6 @@ define_pd_global(bool, ProfileInterpreter, false); define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true); define_pd_global(bool, CICompileOSR, true ); #endif // COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/arm/c2_globals_arm.hpp b/src/hotspot/cpu/arm/c2_globals_arm.hpp index 0849bd594f0..34da47792ae 100644 --- a/src/hotspot/cpu/arm/c2_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c2_globals_arm.hpp @@ -47,7 +47,6 @@ define_pd_global(intx, ConditionalMoveLimit, 4); // C2 gets to use all the float/double registers define_pd_global(intx, FreqInlineSize, 175); define_pd_global(intx, InteriorEntryAlignment, 16); // = CodeEntryAlignment -define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K)); // The default setting 16/16 seems to work best. // (For _228_jack 16/16 is 2% better than 4/4, 16/4, 32/32, 32/16, or 16/32.) //define_pd_global(intx, OptoLoopAlignment, 16); // = 4*wordSize @@ -94,7 +93,4 @@ define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - #endif // CPU_ARM_C2_GLOBALS_ARM_HPP diff --git a/src/hotspot/cpu/arm/interp_masm_arm.cpp b/src/hotspot/cpu/arm/interp_masm_arm.cpp index 23ecea24eb2..aee407864ee 100644 --- a/src/hotspot/cpu/arm/interp_masm_arm.cpp +++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -1210,7 +1210,7 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) { // Sets mdp, blows Rtemp. -void InterpreterMacroAssembler::profile_virtual_call(Register mdp, Register receiver, bool receiver_can_be_null) { +void InterpreterMacroAssembler::profile_virtual_call(Register mdp, Register receiver) { assert_different_registers(mdp, receiver, Rtemp); if (ProfileInterpreter) { @@ -1219,19 +1219,8 @@ void InterpreterMacroAssembler::profile_virtual_call(Register mdp, Register rece // If no method data exists, go to profile_continue. test_method_data_pointer(mdp, profile_continue); - Label skip_receiver_profile; - if (receiver_can_be_null) { - Label not_null; - cbnz(receiver, not_null); - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()), Rtemp); - b(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. record_klass_in_profile(receiver, mdp, Rtemp, true); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); diff --git a/src/hotspot/cpu/arm/interp_masm_arm.hpp b/src/hotspot/cpu/arm/interp_masm_arm.hpp index 530be1c577e..147cd252b2c 100644 --- a/src/hotspot/cpu/arm/interp_masm_arm.hpp +++ b/src/hotspot/cpu/arm/interp_masm_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -239,8 +239,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_call(Register mdp); // Sets mdp, blows Rtemp. void profile_final_call(Register mdp); // Sets mdp, blows Rtemp. - void profile_virtual_call(Register mdp, Register receiver, // Sets mdp, blows Rtemp. - bool receiver_can_be_null = false); + void profile_virtual_call(Register mdp, Register receiver); // Sets mdp, blows Rtemp. void profile_ret(Register mdp, Register return_bci); // Sets mdp, blows R0-R3/R0-R18, Rtemp, LR void profile_null_seen(Register mdp); // Sets mdp. void profile_typecheck(Register mdp, Register klass); // Sets mdp, blows Rtemp. diff --git a/src/hotspot/cpu/arm/matcher_arm.hpp b/src/hotspot/cpu/arm/matcher_arm.hpp index 6c818e1f20d..7978a5b7090 100644 --- a/src/hotspot/cpu/arm/matcher_arm.hpp +++ b/src/hotspot/cpu/arm/matcher_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +75,6 @@ static bool narrow_klass_use_complex_address() { NOT_LP64(ShouldNotCallThis()); - assert(UseCompressedClassPointers, "only for compressed klass code"); return false; } diff --git a/src/hotspot/cpu/ppc/assembler_ppc.hpp b/src/hotspot/cpu/ppc/assembler_ppc.hpp index 23775a3a52e..378e01fc1cc 100644 --- a/src/hotspot/cpu/ppc/assembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -599,6 +599,9 @@ class Assembler : public AbstractAssembler { XVMAXSP_OPCODE = (60u << OPCODE_SHIFT | 192u << 3), XVMAXDP_OPCODE = (60u << OPCODE_SHIFT | 224u << 3), + XSMINJDP_OPCODE = (60u << OPCODE_SHIFT | 152u << 3), + XSMAXJDP_OPCODE = (60u << OPCODE_SHIFT | 144u << 3), + // Deliver A Random Number (introduced with POWER9) DARN_OPCODE = (31u << OPCODE_SHIFT | 755u << 1), @@ -1577,10 +1580,6 @@ class Assembler : public AbstractAssembler { static bool is_nop(int x) { return x == 0x60000000; } - // endgroup opcode for Power6 - static bool is_endgroup(int x) { - return is_ori(x) && inv_ra_field(x) == 1 && inv_rs_field(x) == 1 && inv_d1_field(x) == 0; - } private: @@ -1656,9 +1655,6 @@ class Assembler : public AbstractAssembler { inline void ori_opt( Register d, int ui16); inline void oris_opt(Register d, int ui16); - // endgroup opcode for Power6 - inline void endgroup(); - // count instructions inline void cntlzw( Register a, Register s); inline void cntlzw_( Register a, Register s); @@ -2455,6 +2451,9 @@ class Assembler : public AbstractAssembler { inline void xvrdpim( VectorSRegister d, VectorSRegister b); inline void xvrdpip( VectorSRegister d, VectorSRegister b); + inline void xsminjdp( VectorSRegister d, VectorSRegister a, VectorSRegister b); // Requires Power 9 + inline void xsmaxjdp( VectorSRegister d, VectorSRegister a, VectorSRegister b); // Requires Power 9 + // The following functions do not match exactly the Java.math semantics. inline void xvminsp( VectorSRegister d, VectorSRegister a, VectorSRegister b); inline void xvmindp( VectorSRegister d, VectorSRegister a, VectorSRegister b); diff --git a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp index 4cda782067e..d349bbc6f87 100644 --- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -253,8 +253,6 @@ inline void Assembler::mr( Register d, Register s) { Assembler::orr(d, s, inline void Assembler::ori_opt( Register d, int ui16) { if (ui16!=0) Assembler::ori( d, d, ui16); } inline void Assembler::oris_opt(Register d, int ui16) { if (ui16!=0) Assembler::oris(d, d, ui16); } -inline void Assembler::endgroup() { Assembler::ori(R1, R1, 0); } - // count instructions inline void Assembler::cntlzw( Register a, Register s) { emit_int32(CNTLZW_OPCODE | rta(a) | rs(s) | rc(0)); } inline void Assembler::cntlzw_( Register a, Register s) { emit_int32(CNTLZW_OPCODE | rta(a) | rs(s) | rc(1)); } @@ -908,6 +906,9 @@ inline void Assembler::xvrdpic( VectorSRegister d, VectorSRegister b) inline void Assembler::xvrdpim( VectorSRegister d, VectorSRegister b) { emit_int32( XVRDPIM_OPCODE | vsrt(d) | vsrb(b)); } inline void Assembler::xvrdpip( VectorSRegister d, VectorSRegister b) { emit_int32( XVRDPIP_OPCODE | vsrt(d) | vsrb(b)); } +inline void Assembler::xsminjdp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XSMINJDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xsmaxjdp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XSMAXJDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } + inline void Assembler::xvminsp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMINSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } inline void Assembler::xvmindp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMINDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } inline void Assembler::xvmaxsp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMAXSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp index 798451446e5..4d7af0e4a71 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -144,7 +144,7 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register if (len->is_valid()) { stw(len, arrayOopDesc::length_offset_in_bytes(), obj); - } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) { + } else if (!UseCompactObjectHeaders) { // Otherwise length is in the class gap. store_klass_gap(obj); } diff --git a/src/hotspot/cpu/ppc/c1_globals_ppc.hpp b/src/hotspot/cpu/ppc/c1_globals_ppc.hpp index 77d9acd1cd1..c6fe15aac07 100644 --- a/src/hotspot/cpu/ppc/c1_globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/c1_globals_ppc.hpp @@ -51,8 +51,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheExpansionSize, 32*K); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true); -define_pd_global(size_t, NewSizeThreadIncrease, 16*K); define_pd_global(size_t, InitialCodeCacheSize, 160*K); #endif // !COMPILER2 diff --git a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp index 73b6b132895..8bbffc22c54 100644 --- a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. 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 @@ -600,19 +601,21 @@ void C2_MacroAssembler::count_positives(Register src, Register cnt, Register res orr(tmp0, tmp2, tmp0); and_(tmp0, tmp0, tmp1); - bne(CR0, Lslow); // Found negative byte. + bne(CR0, Lslow); // Found negative byte. addi(result, result, 16); bdnz(Lfastloop); bind(Lslow); // Fallback to slow version. subf(tmp0, src, result); // Bytes known positive. - subf_(tmp0, tmp0, cnt); // Remaining Bytes. + clrldi(tmp1, cnt, 32); // Clear garbage from upper 32 bits. + subf_(tmp0, tmp0, tmp1); // Remaining Bytes. beq(CR0, Ldone); mtctr(tmp0); + bind(Lloop); lbz(tmp0, 0, result); andi_(tmp0, tmp0, 0x80); - bne(CR0, Ldone); // Found negative byte. + bne(CR0, Ldone); // Found negative byte. addi(result, result, 1); bdnz(Lloop); diff --git a/src/hotspot/cpu/ppc/c2_globals_ppc.hpp b/src/hotspot/cpu/ppc/c2_globals_ppc.hpp index caef322d4a1..e4942fa1850 100644 --- a/src/hotspot/cpu/ppc/c2_globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/c2_globals_ppc.hpp @@ -47,7 +47,6 @@ define_pd_global(intx, ConditionalMoveLimit, 3); define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, MinJumpTableSize, 10); define_pd_global(intx, InteriorEntryAlignment, 16); -define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, RegisterCostAreaRatio, 16000); define_pd_global(intx, LoopUnrollLimit, 60); define_pd_global(intx, LoopPercentProfileLimit, 10); @@ -91,7 +90,4 @@ define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, TrapBasedRangeChecks, true); -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - #endif // CPU_PPC_C2_GLOBALS_PPC_HPP diff --git a/src/hotspot/cpu/ppc/disassembler_ppc.cpp b/src/hotspot/cpu/ppc/disassembler_ppc.cpp index fb3cb50cdec..2e16e1a301f 100644 --- a/src/hotspot/cpu/ppc/disassembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/disassembler_ppc.cpp @@ -119,9 +119,6 @@ address Disassembler::decode_instruction0(address here, outputStream * st, addre } else if (instruction == 0xbadbabe) { st->print(".data 0xbadbabe"); next = here + Assembler::instr_len(here); - } else if (Assembler::is_endgroup(instruction)) { - st->print("endgroup"); - next = here + Assembler::instr_len(here); } else { next = here; } diff --git a/src/hotspot/cpu/ppc/downcallLinker_ppc.cpp b/src/hotspot/cpu/ppc/downcallLinker_ppc.cpp index f12d25ac611..d149fc33ac3 100644 --- a/src/hotspot/cpu/ppc/downcallLinker_ppc.cpp +++ b/src/hotspot/cpu/ppc/downcallLinker_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, 2025 SAP SE. All rights reserved. - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -135,10 +135,10 @@ void DowncallLinker::StubGenerator::generate() { bool should_save_return_value = !_needs_return_buffer; RegSpiller out_reg_spiller(_output_registers); - int spill_offset = -1; + int out_spill_offset = -1; if (should_save_return_value) { - spill_offset = frame::native_abi_reg_args_size; + out_spill_offset = frame::native_abi_reg_args_size; // Spill area can be shared with additional out args (>8), // since it is only used after the call. int frame_size_including_spill_area = frame::native_abi_reg_args_size + out_reg_spiller.spill_size_bytes(); @@ -170,6 +170,18 @@ void DowncallLinker::StubGenerator::generate() { ArgumentShuffle arg_shuffle(filtered_java_regs, out_regs, _abi._scratch1); + // Need to spill for state capturing runtime call. + // The area spilled into is distinct from the capture state buffer. + RegSpiller in_reg_spiller(out_regs); + int in_spill_offset = -1; + if (_captured_state_mask != 0) { + // The spill area cannot be shared with the out_spill since + // spilling needs to happen before the call. Allocate a new + // region in the stack for this spill space. + in_spill_offset = allocated_frame_size; + allocated_frame_size += in_reg_spiller.spill_size_bytes(); + } + #ifndef PRODUCT LogTarget(Trace, foreign, downcall) lt; if (lt.is_enabled()) { @@ -211,6 +223,21 @@ void DowncallLinker::StubGenerator::generate() { arg_shuffle.generate(_masm, as_VMStorage(callerSP), frame::jit_out_preserve_size, frame::native_abi_minframe_size); __ block_comment("} argument shuffle"); + if (_captured_state_mask != 0) { + assert(in_spill_offset != -1, "must be"); + __ block_comment("{ load initial thread local"); + in_reg_spiller.generate_spill(_masm, in_spill_offset); + + // Copy the contents of the capture state buffer into thread local + __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state_pre), R0); + __ ld(R3_ARG1, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER), R1_SP); + __ load_const_optimized(R4_ARG2, _captured_state_mask, R0); + __ call_c(call_target_address); + + in_reg_spiller.generate_fill(_masm, in_spill_offset); + __ block_comment("} load initial thread local"); + } + __ call_c(call_target_address); if (_needs_return_buffer) { @@ -247,16 +274,16 @@ void DowncallLinker::StubGenerator::generate() { __ block_comment("{ save thread local"); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } - __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state), R0); + __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state_post), R0); __ ld(R3_ARG1, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER), R1_SP); __ load_const_optimized(R4_ARG2, _captured_state_mask, R0); __ call_c(call_target_address); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ block_comment("} save thread local"); @@ -310,7 +337,7 @@ void DowncallLinker::StubGenerator::generate() { if (should_save_return_value) { // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, JavaThread::check_special_condition_for_native_trans), R0); @@ -318,7 +345,7 @@ void DowncallLinker::StubGenerator::generate() { __ call_c(call_target_address); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ b(L_after_safepoint_poll); @@ -330,14 +357,14 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_reguard); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, SharedRuntime::reguard_yellow_pages), R0); __ call_c(call_target_address); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ b(L_after_reguard); diff --git a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp index bb711f2d053..3c05f950d0c 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -137,10 +137,10 @@ inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address // Return unique id for this frame. The id must have a value where we // can distinguish identity and younger/older relationship. null -// represents an invalid (incomparable) frame. +// represents an invalid (incomparable) frame. Should not be called for heap frames. inline intptr_t* frame::id(void) const { // Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing. - return _fp; + return real_fp(); } // Return true if this frame is older (less recent activation) than @@ -319,6 +319,9 @@ inline frame frame::sender(RegisterMap* map) const { StackWatermarkSet::on_iteration(map->thread(), result); } + // Calling frame::id() is currently not supported for heap frames. + assert(result._on_heap || this->_on_heap || result.is_older(this->id()), "Must be"); + return result; } diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp index 8712c75711d..3692b247989 100644 --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2025 SAP SE. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026 SAP SE. 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 @@ -179,6 +179,11 @@ void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Re __ ld(dst, 0, dst); // Resolve (untagged) jobject. } +void BarrierSetAssembler::try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Load the oop from the weak handle. + __ ld(obj, 0, obj); +} + void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Register tmp) { BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); assert_different_registers(tmp, R0); diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp index 2bf26bd5010..8112542d761 100644 --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2022 SAP SE. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026 SAP SE. 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,6 +70,12 @@ public: virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, Register obj, Register tmp, Label& slowpath); + // Can be used in nmethods including native wrappers. + // Attention: obj will only be valid until next safepoint (no SATB barrier). + // TODO: maybe rename to try_peek_weak_handle on all platforms (try: operation may fail, peek: obj is not kept alive) + // (other platforms currently use it for C2 only: try_resolve_weak_handle_in_c2) + virtual void try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); + virtual void barrier_stubs_init() {} virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::stw_instruction_and_data_patch; } diff --git a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp index c3bb1811031..8e99d23cc99 100644 --- a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp @@ -1,6 +1,7 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2025, Red Hat, Inc. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -662,6 +663,31 @@ void ShenandoahBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler __ block_comment("} try_resolve_jobject_in_native (shenandoahgc)"); } +void ShenandoahBarrierSetAssembler::try_resolve_weak_handle(MacroAssembler *masm, Register obj, + Register tmp, Label &slow_path) { + __ block_comment("try_resolve_weak_handle (shenandoahgc) {"); + + assert_different_registers(obj, tmp); + + Label done; + + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle(masm, obj, tmp, slow_path); + + // Check if the reference is null, and if it is, take the fast path. + __ cmpdi(CR0, obj, 0); + __ beq(CR0, done); + + // Check if the heap is under weak-reference/roots processing, in + // which case we need to take the slow path. + __ lbz(tmp, in_bytes(ShenandoahThreadLocalData::gc_state_offset()), R16_thread); + __ andi_(tmp, tmp, ShenandoahHeap::WEAK_ROOTS); + __ bne(CR0, slow_path); + __ bind(done); + + __ block_comment("} try_resolve_weak_handle (shenandoahgc)"); +} + // Special shenandoah CAS implementation that handles false negatives due // to concurrent evacuation. That is, the CAS operation is intended to succeed in // the following scenarios (success criteria): diff --git a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.hpp index 52615a740af..58180c49642 100644 --- a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.hpp @@ -1,6 +1,7 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved. - * Copyright (c) 2012, 2022 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -121,6 +122,8 @@ public: virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, Register obj, Register tmp, Label& slowpath); + + virtual void try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); }; #endif // CPU_PPC_GC_SHENANDOAH_SHENANDOAHBARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp index 0aa5858c8e6..3e74dfb88cb 100644 --- a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, 2025 SAP SE. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026 SAP SE. 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 @@ -627,6 +627,19 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, R __ block_comment("} try_resolve_jobject_in_native (zgc)"); } +void ZBarrierSetAssembler::try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle(masm, obj, tmp, slow_path); + + // Check if the oop is bad, in which case we need to take the slow path. + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatMarkBadMask); + __ andi_(R0, obj, barrier_Relocation::unpatched); + __ bne(CR0, slow_path); + + // Oop is okay, so we uncolor it. + __ srdi(obj, obj, ZPointerLoadShift); +} + #undef __ #ifdef COMPILER1 diff --git a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.hpp index 27203e7b01c..655184cf6a3 100644 --- a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, 2022 SAP SE. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,8 @@ public: virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, Register obj, Register tmp, Label& slowpath); + virtual void try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); + virtual void check_oop(MacroAssembler *masm, Register obj, const char* msg); virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::conc_instruction_and_data_patch; } diff --git a/src/hotspot/cpu/ppc/icache_ppc.cpp b/src/hotspot/cpu/ppc/icache_ppc.cpp index 05ad3c7a30d..f3d51bad18c 100644 --- a/src/hotspot/cpu/ppc/icache_ppc.cpp +++ b/src/hotspot/cpu/ppc/icache_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2018 SAP SE. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ #include "runtime/icache.hpp" +#include "runtime/vm_version.hpp" // Use inline assembler to implement icache flush. int ICache::ppc64_flush_icache(address start, int lines, int magic) { @@ -67,6 +68,9 @@ int ICache::ppc64_flush_icache(address start, int lines, int magic) { void ICacheStubGenerator::generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub) { + guarantee(VM_Version::get_icache_line_size() >= ICache::line_size, + "processors with smaller cache line size are no longer supported"); + *flush_icache_stub = (ICache::flush_icache_stub_t)ICache::ppc64_flush_icache; // First call to flush itself. diff --git a/src/hotspot/cpu/ppc/icache_ppc.hpp b/src/hotspot/cpu/ppc/icache_ppc.hpp index d348cad1c72..024f706182a 100644 --- a/src/hotspot/cpu/ppc/icache_ppc.hpp +++ b/src/hotspot/cpu/ppc/icache_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2013 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,9 +35,8 @@ class ICache : public AbstractICache { public: enum { - // Actually, cache line size is 64, but keeping it as it is to be - // on the safe side on ALL PPC64 implementations. - log2_line_size = 5, + // Cache line size is 128 on all supported PPC64 implementations. + log2_line_size = 7, line_size = 1 << log2_line_size }; diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp index 4ea33ebaf63..275ff92c699 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -258,7 +258,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_not_taken_branch(Register scratch1, Register scratch2); void profile_call(Register scratch1, Register scratch2); void profile_final_call(Register scratch1, Register scratch2); - void profile_virtual_call(Register Rreceiver, Register Rscratch1, Register Rscratch2, bool receiver_can_be_null); + void profile_virtual_call(Register Rreceiver, Register Rscratch1, Register Rscratch2); void profile_typecheck(Register Rklass, Register Rscratch1, Register Rscratch2); void profile_ret(TosState state, Register return_bci, Register scratch1, Register scratch2); void profile_switch_default(Register scratch1, Register scratch2); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index f7bf457f72c..56eade8e533 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1340,28 +1340,15 @@ void InterpreterMacroAssembler::profile_final_call(Register scratch1, Register s // Count a virtual call in the bytecodes. void InterpreterMacroAssembler::profile_virtual_call(Register Rreceiver, Register Rscratch1, - Register Rscratch2, - bool receiver_can_be_null) { + Register Rscratch2) { if (!ProfileInterpreter) { return; } Label profile_continue; // If no method data exists, go to profile_continue. test_method_data_pointer(profile_continue); - Label skip_receiver_profile; - if (receiver_can_be_null) { - Label not_null; - cmpdi(CR0, Rreceiver, 0); - bne(CR0, not_null); - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(in_bytes(CounterData::count_offset()), Rscratch1, Rscratch2); - b(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. record_klass_in_profile(Rreceiver, Rscratch1, Rscratch2); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size())); diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index 809285afddb..5fbcce94029 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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,6 +42,7 @@ #include "runtime/icache.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/objectMonitor.hpp" +#include "runtime/objectMonitorTable.hpp" #include "runtime/os.hpp" #include "runtime/safepoint.hpp" #include "runtime/safepointMechanism.hpp" @@ -482,7 +483,7 @@ void MacroAssembler::set_dest_of_bc_far_at(address instruction_addr, address des // variant 3, far cond branch to the next instruction, already patched to nops: // // nop - // endgroup + // nop // SKIP/DEST: // return; @@ -499,7 +500,7 @@ void MacroAssembler::set_dest_of_bc_far_at(address instruction_addr, address des if (is_bc_far_variant2_at(instruction_addr) && dest == instruction_addr + 8) { // Far branch to next instruction: Optimize it by patching nops (produce variant 3). masm.nop(); - masm.endgroup(); + masm.nop(); } else { if (is_bc_far_variant1_at(instruction_addr)) { // variant 1, the 1st instruction contains the destination address: @@ -2756,39 +2757,54 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register addi(owner_addr, mark, in_bytes(ObjectMonitor::owner_offset()) - monitor_tag); mark = noreg; } else { + const Register tmp3_bucket = tmp3; + const Register tmp2_hash = tmp2; Label monitor_found; - Register cache_addr = tmp2; - // Load cache address - addi(cache_addr, R16_thread, in_bytes(JavaThread::om_cache_oops_offset())); + // Save the mark, we might need it to extract the hash. + mr(tmp2_hash, mark); - const int num_unrolled = 2; + // Look for the monitor in the om_cache. + + ByteSize cache_offset = JavaThread::om_cache_oops_offset(); + ByteSize monitor_offset = OMCache::oop_to_monitor_difference(); + const int num_unrolled = OMCache::CAPACITY; for (int i = 0; i < num_unrolled; i++) { - ld(R0, 0, cache_addr); + ld(R0, in_bytes(cache_offset), R16_thread); + ld(monitor, in_bytes(cache_offset + monitor_offset), R16_thread); cmpd(CR0, R0, obj); beq(CR0, monitor_found); - addi(cache_addr, cache_addr, in_bytes(OMCache::oop_to_oop_difference())); + cache_offset = cache_offset + OMCache::oop_to_oop_difference(); } - Label loop; + // Look for the monitor in the table. - // Search for obj in cache. - bind(loop); + // Get the hash code. + srdi(tmp2_hash, tmp2_hash, markWord::hash_shift); - // Check for match. - ld(R0, 0, cache_addr); - cmpd(CR0, R0, obj); - beq(CR0, monitor_found); + // Get the table and calculate the bucket's address + int simm16_rest = load_const_optimized(tmp3, ObjectMonitorTable::current_table_address(), R0, true); + ld_ptr(tmp3, simm16_rest, tmp3); + ld(tmp1, in_bytes(ObjectMonitorTable::table_capacity_mask_offset()), tmp3); + andr(tmp2_hash, tmp2_hash, tmp1); + ld(tmp3_bucket, in_bytes(ObjectMonitorTable::table_buckets_offset()), tmp3); - // Search until null encountered, guaranteed _null_sentinel at end. - addi(cache_addr, cache_addr, in_bytes(OMCache::oop_to_oop_difference())); - cmpdi(CR1, R0, 0); - bne(CR1, loop); - // Cache Miss, CR0.NE set from cmp above - b(slow_path); + // Read the monitor from the bucket. + sldi(tmp2_hash, tmp2_hash, LogBytesPerWord); + ldx(monitor, tmp3_bucket, tmp2_hash); + + // Check if the monitor in the bucket is special (empty, tombstone or removed). + cmpldi(CR0, monitor, ObjectMonitorTable::SpecialPointerValues::below_is_special); + blt(CR0, slow_path); + + // Check if object matches. + ld(tmp3, in_bytes(ObjectMonitor::object_offset()), monitor); + BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); + bs_asm->try_resolve_weak_handle(this, tmp3, tmp2, slow_path); + cmpd(CR0, tmp3, obj); + bne(CR0, slow_path); bind(monitor_found); - ld(monitor, in_bytes(OMCache::oop_to_monitor_difference()), cache_addr); // Compute owner address. addi(owner_addr, monitor, in_bytes(ObjectMonitor::owner_offset())); @@ -3185,23 +3201,17 @@ Register MacroAssembler::encode_klass_not_null(Register dst, Register src) { void MacroAssembler::store_klass(Register dst_oop, Register klass, Register ck) { assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - Register compressedKlass = encode_klass_not_null(ck, klass); - stw(compressedKlass, oopDesc::klass_offset_in_bytes(), dst_oop); - } else { - std(klass, oopDesc::klass_offset_in_bytes(), dst_oop); - } + Register compressedKlass = encode_klass_not_null(ck, klass); + stw(compressedKlass, oopDesc::klass_offset_in_bytes(), dst_oop); } void MacroAssembler::store_klass_gap(Register dst_oop, Register val) { assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - if (val == noreg) { - val = R0; - li(val, 0); - } - stw(val, oopDesc::klass_gap_offset_in_bytes(), dst_oop); + if (val == noreg) { + val = R0; + li(val, 0); } + stw(val, oopDesc::klass_gap_offset_in_bytes(), dst_oop); } int MacroAssembler::instr_size_for_decode_klass_not_null() { @@ -3210,17 +3220,13 @@ int MacroAssembler::instr_size_for_decode_klass_not_null() { // Not yet computed? if (computed_size == -1) { - if (!UseCompressedClassPointers) { - computed_size = 0; - } else { - // Determine by scratch emit. - ResourceMark rm; - int code_size = 8 * BytesPerInstWord; - CodeBuffer cb("decode_klass_not_null scratch buffer", code_size, 0); - MacroAssembler* a = new MacroAssembler(&cb); - a->decode_klass_not_null(R11_scratch1); - computed_size = a->offset(); - } + // Determine by scratch emit. + ResourceMark rm; + int code_size = 8 * BytesPerInstWord; + CodeBuffer cb("decode_klass_not_null scratch buffer", code_size, 0); + MacroAssembler* a = new MacroAssembler(&cb); + a->decode_klass_not_null(R11_scratch1); + computed_size = a->offset(); } return computed_size; @@ -3243,18 +3249,14 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src) { void MacroAssembler::load_klass_no_decode(Register dst, Register src) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(dst, src); - } else if (UseCompressedClassPointers) { - lwz(dst, oopDesc::klass_offset_in_bytes(), src); } else { - ld(dst, oopDesc::klass_offset_in_bytes(), src); + lwz(dst, oopDesc::klass_offset_in_bytes(), src); } } void MacroAssembler::load_klass(Register dst, Register src) { load_klass_no_decode(dst, src); - if (UseCompressedClassPointers) { // also true for UseCompactObjectHeaders - decode_klass_not_null(dst); - } + decode_klass_not_null(dst); } // Loads the obj's Klass* into dst. @@ -3270,18 +3272,13 @@ void MacroAssembler::load_narrow_klass_compact(Register dst, Register src) { void MacroAssembler::cmp_klass(ConditionRegister dst, Register obj, Register klass, Register tmp, Register tmp2) { assert_different_registers(obj, klass, tmp); - if (UseCompressedClassPointers) { - if (UseCompactObjectHeaders) { - load_narrow_klass_compact(tmp, obj); - } else { - lwz(tmp, oopDesc::klass_offset_in_bytes(), obj); - } - Register encoded_klass = encode_klass_not_null(tmp2, klass); - cmpw(dst, tmp, encoded_klass); + if (UseCompactObjectHeaders) { + load_narrow_klass_compact(tmp, obj); } else { - ld(tmp, oopDesc::klass_offset_in_bytes(), obj); - cmpd(dst, tmp, klass); + lwz(tmp, oopDesc::klass_offset_in_bytes(), obj); } + Register encoded_klass = encode_klass_not_null(tmp2, klass); + cmpw(dst, tmp, encoded_klass); } void MacroAssembler::cmp_klasses_from_objects(ConditionRegister dst, Register obj1, Register obj2, Register tmp1, Register tmp2) { @@ -3289,14 +3286,10 @@ void MacroAssembler::cmp_klasses_from_objects(ConditionRegister dst, Register ob load_narrow_klass_compact(tmp1, obj1); load_narrow_klass_compact(tmp2, obj2); cmpw(dst, tmp1, tmp2); - } else if (UseCompressedClassPointers) { + } else { lwz(tmp1, oopDesc::klass_offset_in_bytes(), obj1); lwz(tmp2, oopDesc::klass_offset_in_bytes(), obj2); cmpw(dst, tmp1, tmp2); - } else { - ld(tmp1, oopDesc::klass_offset_in_bytes(), obj1); - ld(tmp2, oopDesc::klass_offset_in_bytes(), obj2); - cmpd(dst, tmp1, tmp2); } } diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 875602cae58..4be62098bdf 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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,14 +70,6 @@ class MacroAssembler: public Assembler { // Move register if destination register and target register are different inline void mr_if_needed(Register rd, Register rs, bool allow_invalid = false); inline void fmr_if_needed(FloatRegister rd, FloatRegister rs); - // This is dedicated for emitting scheduled mach nodes. For better - // readability of the ad file I put it here. - // Endgroups are not needed if - // - the scheduler is off - // - the scheduler found that there is a natural group end, in that - // case it reduced the size of the instruction used in the test - // yielding 'needed'. - inline void endgroup_if_needed(bool needed); // Memory barriers. inline void membar(int bits); diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp index 2b19d84c69c..cdeb8527bea 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,11 +72,6 @@ inline void MacroAssembler::mr_if_needed(Register rd, Register rs, bool allow_no inline void MacroAssembler::fmr_if_needed(FloatRegister rd, FloatRegister rs) { if (rs != rd) fmr(rd, rs); } -inline void MacroAssembler::endgroup_if_needed(bool needed) { - if (needed) { - endgroup(); - } -} inline void MacroAssembler::membar(int bits) { // Comment: Usage of elemental_membar(bits) is not recommended for Power 8. @@ -240,13 +235,13 @@ inline bool MacroAssembler::is_bc_far_variant3_at(address instruction_addr) { // Variant 3, far cond branch to the next instruction, already patched to nops: // // nop - // endgroup + // nop // SKIP/DEST: // const int instruction_1 = *(int*)(instruction_addr); const int instruction_2 = *(int*)(instruction_addr + 4); return is_nop(instruction_1) && - is_endgroup(instruction_2); + is_nop(instruction_2); } // set dst to -1, 0, +1 as follows: if CR0bi is "greater than", dst is set to 1, diff --git a/src/hotspot/cpu/ppc/matcher_ppc.hpp b/src/hotspot/cpu/ppc/matcher_ppc.hpp index b50de6323de..cbe882648b8 100644 --- a/src/hotspot/cpu/ppc/matcher_ppc.hpp +++ b/src/hotspot/cpu/ppc/matcher_ppc.hpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. 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 @@ -86,7 +87,6 @@ static bool narrow_klass_use_complex_address() { NOT_LP64(ShouldNotCallThis()); - assert(UseCompressedClassPointers, "only for compressed klass code"); // TODO: PPC port if (MatchDecodeNodes) return true; return false; } diff --git a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp index 803bb6bfe69..45537e0ea96 100644 --- a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp +++ b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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,11 +49,6 @@ #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") -// Workaround for C++ overloading nastiness on '0' for RegisterOrConstant. -inline static RegisterOrConstant constant(int value) { - return RegisterOrConstant(value); -} - void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg) { if (VerifyMethodHandles) { diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad index d926fabd353..f3d33b4305d 100644 --- a/src/hotspot/cpu/ppc/ppc.ad +++ b/src/hotspot/cpu/ppc/ppc.ad @@ -1,6 +1,6 @@ // -// Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2012, 2025 SAP SE. All rights reserved. +// Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2012, 2026 SAP SE. 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 @@ -2234,6 +2234,12 @@ bool Matcher::match_rule_supported(int opcode) { case Op_FmaVD: return (SuperwordUseVSX && UseFMA); + case Op_MinF: + case Op_MaxF: + case Op_MinD: + case Op_MaxD: + return (PowerArchitecturePPC64 >= 9); + case Op_Digit: return vmIntrinsics::is_intrinsic_available(vmIntrinsics::_isDigit); case Op_LowerCase: @@ -2406,10 +2412,8 @@ bool Matcher::is_generic_vector(MachOper* opnd) { return false; } -// Return whether or not this register is ever used as an argument. This -// function is used on startup to build the trampoline stubs in generateOptoStub. -// Registers not mentioned will be killed by the VM call in the trampoline, and -// arguments in those registers not be available to the callee. +#ifdef ASSERT +// Return whether or not this register is ever used as an argument. bool Matcher::can_be_java_arg(int reg) { // We must include the virtual halves in order to get STDs and LDs // instead of STWs and LWs in the trampoline stubs. @@ -2441,10 +2445,7 @@ bool Matcher::can_be_java_arg(int reg) { return false; } - -bool Matcher::is_spillable_arg(int reg) { - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -2456,10 +2457,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? 28 : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con(jlong divisor) { - return false; -} - // Register for DIVI projection of divmodI. const RegMask& Matcher::divI_proj_mask() { ShouldNotReachHere(); @@ -3709,13 +3706,6 @@ frame %{ // Compiled code's Frame Pointer. frame_pointer(R1); // R1_SP - // Interpreter stores its frame pointer in a register which is - // stored to the stack by I2CAdaptors. I2CAdaptors convert from - // interpreted java to compiled java. - // - // R14_state holds pointer to caller's cInterpreter. - interpreter_frame_pointer(R14); // R14_state - stack_alignment(frame::alignment_in_bytes); // Number of outgoing stack slots killed above the @@ -6333,36 +6323,8 @@ instruct loadConD_Ex(regD dst, immD src) %{ // Prefetch instructions. // Must be safe to execute with invalid address (cannot fault). -// Special prefetch versions which use the dcbz instruction. -instruct prefetch_alloc_zero(indirectMemory mem, iRegLsrc src) %{ - match(PrefetchAllocation (AddP mem src)); - predicate(AllocatePrefetchStyle == 3); - ins_cost(MEMORY_REF_COST); - - format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many with zero" %} - size(4); - ins_encode %{ - __ dcbz($src$$Register, $mem$$base$$Register); - %} - ins_pipe(pipe_class_memory); -%} - -instruct prefetch_alloc_zero_no_offset(indirectMemory mem) %{ - match(PrefetchAllocation mem); - predicate(AllocatePrefetchStyle == 3); - ins_cost(MEMORY_REF_COST); - - format %{ "PREFETCH $mem, 2 \t// Prefetch write-many with zero" %} - size(4); - ins_encode %{ - __ dcbz($mem$$base$$Register); - %} - ins_pipe(pipe_class_memory); -%} - instruct prefetch_alloc(indirectMemory mem, iRegLsrc src) %{ match(PrefetchAllocation (AddP mem src)); - predicate(AllocatePrefetchStyle != 3); ins_cost(MEMORY_REF_COST); format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many" %} @@ -6375,7 +6337,6 @@ instruct prefetch_alloc(indirectMemory mem, iRegLsrc src) %{ instruct prefetch_alloc_no_offset(indirectMemory mem) %{ match(PrefetchAllocation mem); - predicate(AllocatePrefetchStyle != 3); ins_cost(MEMORY_REF_COST); format %{ "PREFETCH $mem, 2 \t// Prefetch write-many" %} @@ -7169,6 +7130,18 @@ instruct membar_release_lock() %{ ins_pipe(pipe_class_default); %} +instruct membar_storeload() %{ + match(MemBarStoreLoad); + ins_cost(4*MEMORY_REF_COST); + + format %{ "MEMBAR-store-load" %} + size(4); + ins_encode %{ + __ fence(); + %} + ins_pipe(pipe_class_default); +%} + instruct membar_volatile() %{ match(MemBarVolatile); ins_cost(4*MEMORY_REF_COST); @@ -7211,6 +7184,18 @@ instruct membar_volatile() %{ // ins_pipe(pipe_class_default); //%} +instruct membar_full() %{ + match(MemBarFull); + ins_cost(4*MEMORY_REF_COST); + + format %{ "MEMBAR-full" %} + size(4); + ins_encode %{ + __ fence(); + %} + ins_pipe(pipe_class_default); +%} + instruct membar_CPUOrder() %{ match(MemBarCPUOrder); ins_cost(0); @@ -10318,7 +10303,7 @@ instruct cmovI_bso_stackSlotL(iRegIdst dst, flagsRegSrc crx, stackSlotL src) %{ ins_variable_size_depending_on_alignment(true); - format %{ "cmovI $crx, $dst, $src" %} + format %{ "CMOVI $crx, $dst, $src" %} size(8); ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) ); ins_pipe(pipe_class_default); @@ -10331,7 +10316,7 @@ instruct cmovI_bso_reg(iRegIdst dst, flagsRegSrc crx, regD src) %{ ins_variable_size_depending_on_alignment(true); - format %{ "cmovI $crx, $dst, $src" %} + format %{ "CMOVI $crx, $dst, $src" %} size(8); ins_encode( enc_cmove_bso_reg(dst, crx, src) ); ins_pipe(pipe_class_default); @@ -10343,7 +10328,7 @@ instruct cmovI_bso_reg_conLvalue0_Ex(iRegIdst dst, flagsRegSrc crx, regD src) %{ effect(DEF dst, USE crx, USE src); predicate(false); - format %{ "CmovI $dst, $crx, $src \t// postalloc expanded" %} + format %{ "CMOVI $dst, $crx, $src \t// postalloc expanded" %} postalloc_expand %{ // // replaces @@ -10493,7 +10478,7 @@ instruct cmovL_bso_stackSlotL(iRegLdst dst, flagsRegSrc crx, stackSlotL src) %{ ins_variable_size_depending_on_alignment(true); - format %{ "cmovL $crx, $dst, $src" %} + format %{ "CMOVL $crx, $dst, $src" %} size(8); ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) ); ins_pipe(pipe_class_default); @@ -10506,7 +10491,7 @@ instruct cmovL_bso_reg(iRegLdst dst, flagsRegSrc crx, regD src) %{ ins_variable_size_depending_on_alignment(true); - format %{ "cmovL $crx, $dst, $src" %} + format %{ "CMOVL $crx, $dst, $src" %} size(8); ins_encode( enc_cmove_bso_reg(dst, crx, src) ); ins_pipe(pipe_class_default); @@ -10518,7 +10503,7 @@ instruct cmovL_bso_reg_conLvalue0_Ex(iRegLdst dst, flagsRegSrc crx, regD src) %{ effect(DEF dst, USE crx, USE src); predicate(false); - format %{ "CmovL $dst, $crx, $src \t// postalloc expanded" %} + format %{ "CMOVL $dst, $crx, $src \t// postalloc expanded" %} postalloc_expand %{ // // replaces @@ -10719,9 +10704,9 @@ instruct convF2HF_reg_reg(iRegIdst dst, regF src, regF tmp) %{ effect(TEMP tmp); ins_cost(3 * DEFAULT_COST); size(12); - format %{ "xscvdphp $tmp, $src\t# convert to half precision\n\t" - "mffprd $dst, $tmp\t# move result from $tmp to $dst\n\t" - "extsh $dst, $dst\t# make it a proper short" + format %{ "XSCVDPHP $tmp, $src\t# convert to half precision\n\t" + "MFFPRD $dst, $tmp\t# move result from $tmp to $dst\n\t" + "EXTSH $dst, $dst\t# make it a proper short" %} ins_encode %{ __ f2hf($dst$$Register, $src$$FloatRegister, $tmp$$FloatRegister); @@ -10733,8 +10718,8 @@ instruct convHF2F_reg_reg(regF dst, iRegIsrc src) %{ match(Set dst (ConvHF2F src)); ins_cost(2 * DEFAULT_COST); size(8); - format %{ "mtfprd $dst, $src\t# move source from $src to $dst\n\t" - "xscvhpdp $dst, $dst\t# convert from half precision" + format %{ "MTFPRD $dst, $src\t# move source from $src to $dst\n\t" + "XSCVHPDP $dst, $dst\t# convert from half precision" %} ins_encode %{ __ hf2f($dst$$FloatRegister, $src$$Register); @@ -11132,7 +11117,7 @@ instruct cmov_bns_less(flagsReg crx) %{ ins_variable_size_depending_on_alignment(true); - format %{ "cmov $crx" %} + format %{ "CMOV $crx" %} size(12); ins_encode %{ Label done; @@ -11160,7 +11145,7 @@ instruct cmpF_reg_reg_Ex(flagsReg crx, regF src1, regF src2) %{ match(Set crx (CmpF src1 src2)); ins_cost(DEFAULT_COST+BRANCH_COST); - format %{ "CmpF $crx, $src1, $src2 \t// postalloc expanded" %} + format %{ "CMPF $crx, $src1, $src2 \t// postalloc expanded" %} postalloc_expand %{ // // replaces @@ -12313,6 +12298,58 @@ instruct maxI_reg_reg_isel(iRegIdst dst, iRegIsrc src1, iRegIsrc src2, flagsRegC ins_pipe(pipe_class_default); %} +instruct minF(regF dst, regF src1, regF src2) %{ + match(Set dst (MinF src1 src2)); + predicate(PowerArchitecturePPC64 >= 9); + ins_cost(DEFAULT_COST); + + format %{ "XSMINJDP $dst, $src1, $src2\t// MinF" %} + size(4); + ins_encode %{ + __ xsminjdp($dst$$FloatRegister->to_vsr(), $src1$$FloatRegister->to_vsr(), $src2$$FloatRegister->to_vsr()); + %} + ins_pipe(pipe_class_default); +%} + +instruct minD(regD dst, regD src1, regD src2) %{ + match(Set dst (MinD src1 src2)); + predicate(PowerArchitecturePPC64 >= 9); + ins_cost(DEFAULT_COST); + + format %{ "XSMINJDP $dst, $src1, $src2\t// MinD" %} + size(4); + ins_encode %{ + __ xsminjdp($dst$$FloatRegister->to_vsr(), $src1$$FloatRegister->to_vsr(), $src2$$FloatRegister->to_vsr()); + %} + ins_pipe(pipe_class_default); +%} + +instruct maxF(regF dst, regF src1, regF src2) %{ + match(Set dst (MaxF src1 src2)); + predicate(PowerArchitecturePPC64 >= 9); + ins_cost(DEFAULT_COST); + + format %{ "XSMAXJDP $dst, $src1, $src2\t// MaxF" %} + size(4); + ins_encode %{ + __ xsmaxjdp($dst$$FloatRegister->to_vsr(), $src1$$FloatRegister->to_vsr(), $src2$$FloatRegister->to_vsr()); + %} + ins_pipe(pipe_class_default); +%} + +instruct maxD(regD dst, regD src1, regD src2) %{ + match(Set dst (MaxD src1 src2)); + predicate(PowerArchitecturePPC64 >= 9); + ins_cost(DEFAULT_COST); + + format %{ "XSMAXJDP $dst, $src1, $src2\t// MaxD" %} + size(4); + ins_encode %{ + __ xsmaxjdp($dst$$FloatRegister->to_vsr(), $src1$$FloatRegister->to_vsr(), $src2$$FloatRegister->to_vsr()); + %} + ins_pipe(pipe_class_default); +%} + //---------- Population Count Instructions ------------------------------------ instruct popCountI(iRegIdst dst, iRegIsrc src) %{ @@ -13835,7 +13872,7 @@ instruct vfma2D_neg2(vecX dst, vecX src1, vecX src2) %{ instruct overflowAddL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{ match(Set cr0 (OverflowAddL op1 op2)); - format %{ "add_ $op1, $op2\t# overflow check long" %} + format %{ "ADD_ $op1, $op2\t# overflow check long" %} size(12); ins_encode %{ __ li(R0, 0); @@ -13848,7 +13885,7 @@ instruct overflowAddL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{ instruct overflowSubL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{ match(Set cr0 (OverflowSubL op1 op2)); - format %{ "subfo_ R0, $op2, $op1\t# overflow check long" %} + format %{ "SUBFO_ R0, $op2, $op1\t# overflow check long" %} size(12); ins_encode %{ __ li(R0, 0); @@ -13861,7 +13898,7 @@ instruct overflowSubL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{ instruct overflowNegL_reg(flagsRegCR0 cr0, immL_0 zero, iRegLsrc op2) %{ match(Set cr0 (OverflowSubL zero op2)); - format %{ "nego_ R0, $op2\t# overflow check long" %} + format %{ "NEGO_ R0, $op2\t# overflow check long" %} size(12); ins_encode %{ __ li(R0, 0); @@ -13874,7 +13911,7 @@ instruct overflowNegL_reg(flagsRegCR0 cr0, immL_0 zero, iRegLsrc op2) %{ instruct overflowMulL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{ match(Set cr0 (OverflowMulL op1 op2)); - format %{ "mulldo_ R0, $op1, $op2\t# overflow check long" %} + format %{ "MULLDO_ R0, $op1, $op2\t# overflow check long" %} size(12); ins_encode %{ __ li(R0, 0); @@ -14251,7 +14288,7 @@ instruct ForwardExceptionjmp() match(ForwardException); ins_cost(CALL_COST); - format %{ "Jmp forward_exception_stub" %} + format %{ "JMP forward_exception_stub" %} ins_encode %{ __ set_inst_mark(); __ b64_patchable(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type); @@ -14279,7 +14316,7 @@ instruct RethrowException() %{ match(Rethrow); ins_cost(CALL_COST); - format %{ "Jmp rethrow_stub" %} + format %{ "JMP rethrow_stub" %} ins_encode %{ __ set_inst_mark(); __ b64_patchable((address)OptoRuntime::rethrow_stub(), relocInfo::runtime_call_type); @@ -14321,20 +14358,6 @@ instruct tlsLoadP(threadRegP dst) %{ //---Some PPC specific nodes--------------------------------------------------- -// Stop a group. -instruct endGroup() %{ - ins_cost(0); - - ins_is_nop(true); - - format %{ "End Bundle (ori r1, r1, 0)" %} - size(4); - ins_encode %{ - __ endgroup(); - %} - ins_pipe(pipe_class_default); -%} - // Nop instructions instruct fxNop() %{ diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 8a3af748fa1..37f780535b4 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -3489,7 +3489,7 @@ void TemplateTable::invokevirtual(int byte_no) { // Get receiver klass. __ load_klass_check_null_throw(Rrecv_klass, Rrecv, R11_scratch1); __ verify_klass_ptr(Rrecv_klass); - __ profile_virtual_call(Rrecv_klass, R11_scratch1, R12_scratch2, false); + __ profile_virtual_call(Rrecv_klass, R11_scratch1, R12_scratch2); generate_vtable_call(Rrecv_klass, Rvtableindex_or_method, Rret_addr, R11_scratch1); } @@ -3596,7 +3596,7 @@ void TemplateTable::invokeinterface_object_method(Register Rrecv_klass, // Non-final callc case. __ bind(LnotFinal); __ lhz(Rindex, in_bytes(ResolvedMethodEntry::table_index_offset()), Rcache); - __ profile_virtual_call(Rrecv_klass, Rtemp1, Rscratch, false); + __ profile_virtual_call(Rrecv_klass, Rtemp1, Rscratch); generate_vtable_call(Rrecv_klass, Rindex, Rret, Rscratch); } @@ -3664,7 +3664,7 @@ void TemplateTable::invokeinterface(int byte_no) { __ lookup_interface_method(Rrecv_klass, Rinterface_klass, noreg, noreg, Rscratch1, Rscratch2, L_no_such_interface, /*return_method=*/false); - __ profile_virtual_call(Rrecv_klass, Rscratch1, Rscratch2, false); + __ profile_virtual_call(Rrecv_klass, Rscratch1, Rscratch2); // Find entry point to call. diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/hotspot/cpu/ppc/vm_version_ppc.cpp index 75feb389298..e471f5a6e4f 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -475,19 +475,12 @@ void VM_Version::print_features() { void VM_Version::determine_features() { #if defined(ABI_ELFv2) - // 1 InstWord per call for the blr instruction. - const int code_size = (num_features+1+2*1)*BytesPerInstWord; + const int code_size = (num_features + 1 /*blr*/) * BytesPerInstWord; #else - // 7 InstWords for each call (function descriptor + blr instruction). - const int code_size = (num_features+1+2*7)*BytesPerInstWord; + const int code_size = (num_features + 1 /*blr*/ + 6 /* fd */) * BytesPerInstWord; #endif int features = 0; - // create test area - enum { BUFFER_SIZE = 2*4*K }; // Needs to be >=2* max cache line size (cache line size can't exceed min page size). - char test_area[BUFFER_SIZE]; - char *mid_of_test_area = &test_area[BUFFER_SIZE>>1]; - // Allocate space for the code. ResourceMark rm; CodeBuffer cb("detect_cpu_features", code_size, 0); @@ -497,20 +490,13 @@ void VM_Version::determine_features() { _features = VM_Version::all_features_m; // Emit code. - void (*test)(address addr, uint64_t offset)=(void(*)(address addr, uint64_t offset))(void *)a->function_entry(); + void (*test)() = (void(*)())(void *)a->function_entry(); uint32_t *code = (uint32_t *)a->pc(); - // Keep R3_ARG1 unmodified, it contains &field (see below). - // Keep R4_ARG2 unmodified, it contains offset = 0 (see below). a->mfdscr(R0); a->darn(R7); a->brw(R5, R6); a->blr(); - // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. - void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry(); - a->dcbz(R3_ARG1); // R3_ARG1 = addr - a->blr(); - uint32_t *code_end = (uint32_t *)a->pc(); a->flush(); _features = VM_Version::unknown_m; @@ -522,18 +508,9 @@ void VM_Version::determine_features() { Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } - // Measure cache line size. - memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF. - (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle. - int count = 0; // count zeroed bytes - for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++; - guarantee(is_power_of_2(count), "cache line size needs to be a power of 2"); - _L1_data_cache_line_size = count; - // Execute code. Illegal instructions will be replaced by 0 in the signal handler. VM_Version::_is_determine_features_test_running = true; - // We must align the first argument to 16 bytes because of the lqarx check. - (*test)(align_up((address)mid_of_test_area, 16), 0); + (*test)(); VM_Version::_is_determine_features_test_running = false; // determine which instructions are legal. @@ -550,6 +527,10 @@ void VM_Version::determine_features() { } _features = features; + + _L1_data_cache_line_size = VM_Version::get_dcache_line_size(); + assert(_L1_data_cache_line_size >= DEFAULT_CACHE_LINE_SIZE, + "processors with smaller cache line size are no longer supported"); } // Power 8: Configure Data Stream Control Register. diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.hpp b/src/hotspot/cpu/ppc/vm_version_ppc.hpp index 11dce83bed0..0f4eb3593a3 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.hpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. 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 @@ -81,6 +81,9 @@ public: static uint64_t _dscr_val; static void initialize_cpu_information(void); + + static int get_dcache_line_size(); + static int get_icache_line_size(); }; #endif // CPU_PPC_VM_VERSION_PPC_HPP diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp index 819d6c05654..58eb1a55553 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -196,12 +196,9 @@ void LIR_Assembler::arraycopy_type_check(Register src, Register src_pos, Registe if (UseCompactObjectHeaders) { __ load_narrow_klass_compact(tmp, src); __ load_narrow_klass_compact(t0, dst); - } else if (UseCompressedClassPointers) { + } else { __ lwu(tmp, Address(src, oopDesc::klass_offset_in_bytes())); __ lwu(t0, Address(dst, oopDesc::klass_offset_in_bytes())); - } else { - __ ld(tmp, Address(src, oopDesc::klass_offset_in_bytes())); - __ ld(t0, Address(dst, oopDesc::klass_offset_in_bytes())); } __ bne(tmp, t0, *stub->entry(), /* is_far */ true); } else { @@ -257,9 +254,7 @@ void LIR_Assembler::arraycopy_assert(Register src, Register dst, Register tmp, c // but not necessarily exactly of type default_type. Label known_ok, halt; __ mov_metadata(tmp, default_type->constant_encoding()); - if (UseCompressedClassPointers) { - __ encode_klass_not_null(tmp); - } + __ encode_klass_not_null(tmp); if (basic_type != T_OBJECT) { __ cmp_klass_compressed(dst, tmp, t0, halt, false); diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp index 63e2fd015d7..29e5d86d0cc 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -55,20 +55,6 @@ const Register SHIFT_count = x10; // where count for shift operations must be #define __ _masm-> -static void select_different_registers(Register preserve, - Register extra, - Register &tmp1, - Register &tmp2) { - if (tmp1 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp1 = extra; - } else if (tmp2 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp2 = extra; - } - assert_different_registers(preserve, tmp1, tmp2); -} - static void select_different_registers(Register preserve, Register extra, Register &tmp1, @@ -1155,12 +1141,8 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } else if (obj == klass_RInfo) { klass_RInfo = dst; } - if (k->is_loaded() && !UseCompressedClassPointers) { - select_different_registers(obj, dst, k_RInfo, klass_RInfo); - } else { - Rtmp1 = op->tmp3()->as_register(); - select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); - } + Rtmp1 = op->tmp3()->as_register(); + select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); assert_different_registers(obj, k_RInfo, klass_RInfo); diff --git a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp index 88565d9136f..f290708a231 100644 --- a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1073,9 +1073,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ checkcast(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), info_for_exception, patching_info, stub, @@ -1094,9 +1092,7 @@ void LIRGenerator::do_InstanceOf(InstanceOf* x) { } obj.load_item(); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ instanceof(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); diff --git a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp index aeb077ba0a0..abcc070b253 100644 --- a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,12 +92,8 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register // This assumes that all prototype bits fitr in an int32_t mv(tmp1, checked_cast(markWord::prototype().value())); sd(tmp1, Address(obj, oopDesc::mark_offset_in_bytes())); - if (UseCompressedClassPointers) { // Take care not to kill klass - encode_klass_not_null(tmp1, klass, tmp2); - sw(tmp1, Address(obj, oopDesc::klass_offset_in_bytes())); - } else { - sd(klass, Address(obj, oopDesc::klass_offset_in_bytes())); - } + encode_klass_not_null(tmp1, klass, tmp2); + sw(tmp1, Address(obj, oopDesc::klass_offset_in_bytes())); } if (len->is_valid()) { @@ -108,7 +104,7 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register // Clear gap/first 4 bytes following the length field. sw(zr, Address(obj, base_offset)); } - } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) { + } else if (!UseCompactObjectHeaders) { store_klass_gap(obj, zr); } } diff --git a/src/hotspot/cpu/riscv/c1_globals_riscv.hpp b/src/hotspot/cpu/riscv/c1_globals_riscv.hpp index b15bb5c23c3..b940393f063 100644 --- a/src/hotspot/cpu/riscv/c1_globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/c1_globals_riscv.hpp @@ -42,7 +42,6 @@ define_pd_global(bool, TieredCompilation, false); define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(intx, NewSizeThreadIncrease, 4*K ); define_pd_global(size_t, InitialCodeCacheSize, 160*K); define_pd_global(size_t, ReservedCodeCacheSize, 32*M ); define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M ); @@ -52,7 +51,6 @@ define_pd_global(bool, ProfileInterpreter, false); define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true ); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index b4e0ba69042..0d06fd469de 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -30,7 +30,9 @@ #include "opto/intrinsicnode.hpp" #include "opto/output.hpp" #include "opto/subnode.hpp" +#include "runtime/objectMonitorTable.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/synchronizer.hpp" #include "utilities/globalDefinitions.hpp" #ifdef PRODUCT @@ -123,35 +125,52 @@ void C2_MacroAssembler::fast_lock(Register obj, Register box, if (!UseObjectMonitorTable) { assert(tmp1_monitor == tmp1_mark, "should be the same here"); } else { + const Register tmp2_hash = tmp2; + const Register tmp3_bucket = tmp3; Label monitor_found; - // Load cache address - la(tmp3_t, Address(xthread, JavaThread::om_cache_oops_offset())); + // Save the mark, we might need it to extract the hash. + mv(tmp2_hash, tmp1_mark); - const int num_unrolled = 2; + // Look for the monitor in the om_cache. + + ByteSize cache_offset = JavaThread::om_cache_oops_offset(); + ByteSize monitor_offset = OMCache::oop_to_monitor_difference(); + const int num_unrolled = OMCache::CAPACITY; for (int i = 0; i < num_unrolled; i++) { - ld(tmp1, Address(tmp3_t)); - beq(obj, tmp1, monitor_found); - add(tmp3_t, tmp3_t, in_bytes(OMCache::oop_to_oop_difference())); + ld(tmp1_monitor, Address(xthread, cache_offset + monitor_offset)); + ld(tmp4, Address(xthread, cache_offset)); + beq(obj, tmp4, monitor_found); + cache_offset = cache_offset + OMCache::oop_to_oop_difference(); } - Label loop; + // Look for the monitor in the table. - // Search for obj in cache. - bind(loop); + // Get the hash code. + srli(tmp2_hash, tmp2_hash, markWord::hash_shift); - // Check for match. - ld(tmp1, Address(tmp3_t)); - beq(obj, tmp1, monitor_found); + // Get the table and calculate the bucket's address. + la(tmp3_t, ExternalAddress(ObjectMonitorTable::current_table_address())); + ld(tmp3_t, Address(tmp3_t)); + ld(tmp1, Address(tmp3_t, ObjectMonitorTable::table_capacity_mask_offset())); + andr(tmp2_hash, tmp2_hash, tmp1); + ld(tmp3_t, Address(tmp3_t, ObjectMonitorTable::table_buckets_offset())); - // Search until null encountered, guaranteed _null_sentinel at end. - add(tmp3_t, tmp3_t, in_bytes(OMCache::oop_to_oop_difference())); - bnez(tmp1, loop); - // Cache Miss. Take the slowpath. - j(slow_path); + // Read the monitor from the bucket. + shadd(tmp3_bucket, tmp2_hash, tmp3_t, tmp4, LogBytesPerWord); + ld(tmp1_monitor, Address(tmp3_bucket)); + + // Check if the monitor in the bucket is special (empty, tombstone or removed). + mv(tmp2, ObjectMonitorTable::SpecialPointerValues::below_is_special); + bltu(tmp1_monitor, tmp2, slow_path); + + // Check if object matches. + ld(tmp3, Address(tmp1_monitor, ObjectMonitor::object_offset())); + BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); + bs_asm->try_resolve_weak_handle_in_c2(this, tmp3, tmp2, slow_path); + bne(tmp3, obj, slow_path); bind(monitor_found); - ld(tmp1_monitor, Address(tmp3_t, OMCache::oop_to_monitor_difference())); } const Register tmp2_owner_addr = tmp2; @@ -1156,8 +1175,7 @@ void C2_MacroAssembler::string_compare_long_same_encoding(Register result, Regis Label TAIL_CHECK, TAIL, NEXT_WORD, DIFFERENCE; const int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); const int minCharsInWord = isLL ? wordSize : wordSize / 2; @@ -1250,8 +1268,7 @@ void C2_MacroAssembler::string_compare_long_different_encoding(Register result, Label TAIL, NEXT_WORD, DIFFERENCE; const int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); Register strL = isLU ? str1 : str2; Register strU = isLU ? str2 : str1; @@ -1466,8 +1483,7 @@ void C2_MacroAssembler::arrays_equals(Register a1, Register a2, int length_offset = arrayOopDesc::length_offset_in_bytes(); int base_offset = arrayOopDesc::base_offset_in_bytes(elem_size == 2 ? T_CHAR : T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); Register cnt1 = tmp3; Register cnt2 = tmp1; // cnt2 only used in array length compare @@ -1592,8 +1608,7 @@ void C2_MacroAssembler::string_equals(Register a1, Register a2, int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); BLOCK_COMMENT("string_equals {"); @@ -2680,8 +2695,7 @@ void C2_MacroAssembler::arrays_equals_v(Register a1, Register a2, Register resul int length_offset = arrayOopDesc::length_offset_in_bytes(); int base_offset = arrayOopDesc::base_offset_in_bytes(elem_size == 2 ? T_CHAR : T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); BLOCK_COMMENT("arrays_equals_v {"); diff --git a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp index 648c24ee98b..73ef97939ed 100644 --- a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp @@ -47,7 +47,6 @@ define_pd_global(intx, ConditionalMoveLimit, 3); define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, MinJumpTableSize, 10); define_pd_global(intx, InteriorEntryAlignment, 16); -define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, LoopUnrollLimit, 60); define_pd_global(intx, LoopPercentProfileLimit, 10); // InitialCodeCacheSize derived from specjbb2000 run. @@ -75,9 +74,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M ); define_pd_global(size_t, CodeCacheMinBlockLength, 6); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed. #endif // CPU_RISCV_C2_GLOBALS_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/downcallLinker_riscv.cpp b/src/hotspot/cpu/riscv/downcallLinker_riscv.cpp index cc685645ec5..f9d7ce78ff0 100644 --- a/src/hotspot/cpu/riscv/downcallLinker_riscv.cpp +++ b/src/hotspot/cpu/riscv/downcallLinker_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,10 +140,10 @@ void DowncallLinker::StubGenerator::generate() { bool should_save_return_value = !_needs_return_buffer; RegSpiller out_reg_spiller(_output_registers); - int spill_offset = -1; + int out_spill_offset = -1; if (should_save_return_value) { - spill_offset = 0; + out_spill_offset = 0; // spill area can be shared with shadow space and out args, // since they are only used before the call, // and spill area is only used after. @@ -168,6 +168,9 @@ void DowncallLinker::StubGenerator::generate() { // FP-> | | // |---------------------| = frame_bottom_offset = frame_size // | (optional) | + // | in_reg_spiller area | + // |---------------------| + // | (optional) | // | capture state buf | // |---------------------| = StubLocations::CAPTURED_STATE_BUFFER // | (optional) | @@ -181,6 +184,18 @@ void DowncallLinker::StubGenerator::generate() { GrowableArray out_regs = ForeignGlobals::replace_place_holders(_input_registers, locs); ArgumentShuffle arg_shuffle(filtered_java_regs, out_regs, shuffle_reg); + // Need to spill for state capturing runtime call. + // The area spilled into is distinct from the capture state buffer. + RegSpiller in_reg_spiller(out_regs); + int in_spill_offset = -1; + if (_captured_state_mask != 0) { + // The spill area cannot be shared with the out_spill since + // spilling needs to happen before the call. Allocate a new + // region in the stack for this spill space. + in_spill_offset = allocated_frame_size; + allocated_frame_size += in_reg_spiller.spill_size_bytes(); + } + #ifndef PRODUCT LogTarget(Trace, foreign, downcall) lt; if (lt.is_enabled()) { @@ -226,6 +241,20 @@ void DowncallLinker::StubGenerator::generate() { arg_shuffle.generate(_masm, shuffle_reg, 0, _abi._shadow_space_bytes); __ block_comment("} argument shuffle"); + if (_captured_state_mask != 0) { + assert(in_spill_offset != -1, "must be"); + __ block_comment("{ load initial thread local"); + in_reg_spiller.generate_spill(_masm, in_spill_offset); + + // Copy the contents of the capture state buffer into thread local + __ ld(c_rarg0, Address(sp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); + __ mv(c_rarg1, _captured_state_mask); + __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_pre)); + + in_reg_spiller.generate_fill(_masm, in_spill_offset); + __ block_comment("} load initial thread local"); + } + __ jalr(as_Register(locs.get(StubLocations::TARGET_ADDRESS))); // this call is assumed not to have killed xthread @@ -254,15 +283,15 @@ void DowncallLinker::StubGenerator::generate() { __ block_comment("{ save thread local"); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ ld(c_rarg0, Address(sp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); __ mv(c_rarg1, _captured_state_mask); - __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state)); + __ rt_call(CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_post)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ block_comment("} save thread local"); @@ -319,7 +348,7 @@ void DowncallLinker::StubGenerator::generate() { if (should_save_return_value) { // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ mv(c_rarg0, xthread); @@ -327,7 +356,7 @@ void DowncallLinker::StubGenerator::generate() { __ rt_call(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ j(L_after_safepoint_poll); __ block_comment("} L_safepoint_poll_slow_path"); @@ -339,13 +368,13 @@ void DowncallLinker::StubGenerator::generate() { if (should_save_return_value) { // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); } __ rt_call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); } __ j(L_after_reguard); diff --git a/src/hotspot/cpu/riscv/frame_riscv.inline.hpp b/src/hotspot/cpu/riscv/frame_riscv.inline.hpp index 51a203c548c..d1841a347e9 100644 --- a/src/hotspot/cpu/riscv/frame_riscv.inline.hpp +++ b/src/hotspot/cpu/riscv/frame_riscv.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -236,8 +236,8 @@ inline bool frame::equal(frame other) const { // Return unique id for this frame. The id must have a value where we can distinguish // identity and younger/older relationship. null represents an invalid (incomparable) -// frame. -inline intptr_t* frame::id(void) const { return unextended_sp(); } +// frame. Should not be called for heap frames. +inline intptr_t* frame::id(void) const { return real_fp(); } // Return true if the frame is older (less recent activation) than the frame represented by id inline bool frame::is_older(intptr_t* id) const { assert(this->id() != nullptr && id != nullptr, "null frame id"); @@ -398,6 +398,9 @@ frame frame::sender(RegisterMap* map) const { StackWatermarkSet::on_iteration(map->thread(), result); } + // Calling frame::id() is currently not supported for heap frames. + assert(result._on_heap || this->_on_heap || result.is_older(this->id()), "Must be"); + return result; } diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp index f5916000890..aeb9df06de6 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -369,6 +369,11 @@ OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Na return opto_reg; } +void BarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Load the oop from the weak handle. + __ ld(obj, Address(obj)); +} + #undef __ #define __ _masm-> diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp index e50fa1dae36..bbb2a5af824 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -110,6 +110,8 @@ public: #ifdef COMPILER2 OptoReg::Name refine_register(const Node* node, OptoReg::Name opto_reg); + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, + Register tmp, Label& slow_path); #endif // COMPILER2 }; diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp index 3cbbb783258..8d530d15ee5 100644 --- a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved. * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -461,6 +462,30 @@ void ShenandoahBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler __ bind(done); } +#ifdef COMPILER2 +void ShenandoahBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler *masm, Register obj, + Register tmp, Label& slow_path) { + assert_different_registers(obj, tmp); + + Label done; + + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, tmp, slow_path); + + // Check if the reference is null, and if it is, take the fast path. + __ beqz(obj, done); + + Address gc_state(xthread, ShenandoahThreadLocalData::gc_state_offset()); + __ lbu(tmp, gc_state); + + // Check if the heap is under weak-reference/roots processing, in + // which case we need to take the slow path. + __ test_bit(tmp, tmp, ShenandoahHeap::WEAK_ROOTS_BITPOS); + __ bnez(tmp, slow_path); + __ bind(done); +} +#endif + // Special Shenandoah CAS implementation that handles false negatives due // to concurrent evacuation. The service is more complex than a // traditional CAS operation because the CAS operation is intended to diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.hpp index 5085be26b2e..e35e09c93da 100644 --- a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.hpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -84,7 +85,9 @@ public: virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); - +#ifdef COMPILER2 + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); +#endif void cmpxchg_oop(MacroAssembler* masm, Register addr, Register expected, Register new_val, Assembler::Aqrl acquire, Assembler::Aqrl release, bool is_cae, Register result); }; diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp index 09dea62b6d1..163271a2f11 100644 --- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -602,6 +602,27 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, BLOCK_COMMENT("} ZBarrierSetAssembler::try_resolve_jobject_in_native"); } +#ifdef COMPILER2 +void ZBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + BLOCK_COMMENT("ZBarrierSetAssembler::try_resolve_weak_handle_in_c2 {"); + + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, tmp, slow_path); + + // Check if the oop is bad, in which case we need to take the slow path. + __ relocate(barrier_Relocation::spec(), [&] { + __ li16u(tmp, barrier_Relocation::unpatched); + }, ZBarrierRelocationFormatMarkBadMask); + __ andr(tmp, obj, tmp); + __ bnez(tmp, slow_path); + + // Oop is okay, so we uncolor it. + __ srli(obj, obj, ZPointerLoadShift); + + BLOCK_COMMENT("} ZBarrierSetAssembler::try_resolve_weak_handle_in_c2"); +} +#endif + static uint16_t patch_barrier_relocation_value(int format) { switch (format) { case ZBarrierRelocationFormatLoadBadMask: diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp index 190d81acd0c..648cb3bf63d 100644 --- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -170,6 +170,10 @@ public: ZLoadBarrierStubC2* stub) const; void generate_c2_store_barrier_stub(MacroAssembler* masm, ZStoreBarrierStubC2* stub) const; + void try_resolve_weak_handle_in_c2(MacroAssembler* masm, + Register obj, + Register tmp, + Label& slow_path); #endif // COMPILER2 void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error); diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index 744590bec2b..804c2072ba5 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1040,26 +1040,15 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) { void InterpreterMacroAssembler::profile_virtual_call(Register receiver, - Register mdp, - bool receiver_can_be_null) { + Register mdp) { if (ProfileInterpreter) { Label profile_continue; // If no method data exists, go to profile_continue. test_method_data_pointer(mdp, profile_continue); - Label skip_receiver_profile; - if (receiver_can_be_null) { - Label not_null; - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); - j(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. profile_receiver_type(receiver, mdp, 0); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.hpp b/src/hotspot/cpu/riscv/interp_masm_riscv.hpp index 59cc76b022f..df86f0dc532 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.hpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -274,8 +274,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_not_taken_branch(Register mdp); void profile_call(Register mdp); void profile_final_call(Register mdp); - void profile_virtual_call(Register receiver, Register mdp, - bool receiver_can_be_null = false); + void profile_virtual_call(Register receiver, Register mdp); void profile_ret(Register return_bci, Register mdp); void profile_null_seen(Register mdp); void profile_typecheck(Register mdp, Register klass); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 4f5e7afc166..b0305fa2977 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -3514,10 +3514,8 @@ void MacroAssembler::orptr(Address adr, RegisterOrConstant src, Register tmp1, R void MacroAssembler::cmp_klass_compressed(Register oop, Register trial_klass, Register tmp, Label &L, bool equal) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(tmp, oop); - } else if (UseCompressedClassPointers) { - lwu(tmp, Address(oop, oopDesc::klass_offset_in_bytes())); } else { - ld(tmp, Address(oop, oopDesc::klass_offset_in_bytes())); + lwu(tmp, Address(oop, oopDesc::klass_offset_in_bytes())); } if (equal) { beq(trial_klass, tmp, L); @@ -3741,11 +3739,9 @@ void MacroAssembler::load_klass(Register dst, Register src, Register tmp) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(dst, src); decode_klass_not_null(dst, tmp); - } else if (UseCompressedClassPointers) { + } else { lwu(dst, Address(src, oopDesc::klass_offset_in_bytes())); decode_klass_not_null(dst, tmp); - } else { - ld(dst, Address(src, oopDesc::klass_offset_in_bytes())); } } @@ -3753,20 +3749,15 @@ void MacroAssembler::store_klass(Register dst, Register src, Register tmp) { // FIXME: Should this be a store release? concurrent gcs assumes // klass length is valid if klass field is not null. assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - encode_klass_not_null(src, tmp); - sw(src, Address(dst, oopDesc::klass_offset_in_bytes())); - } else { - sd(src, Address(dst, oopDesc::klass_offset_in_bytes())); - } + encode_klass_not_null(src, tmp); + sw(src, Address(dst, oopDesc::klass_offset_in_bytes())); + } void MacroAssembler::store_klass_gap(Register dst, Register src) { assert(!UseCompactObjectHeaders, "not with compact headers"); - if (UseCompressedClassPointers) { - // Store to klass gap in destination - sw(src, Address(dst, oopDesc::klass_gap_offset_in_bytes())); - } + // Store to klass gap in destination + sw(src, Address(dst, oopDesc::klass_gap_offset_in_bytes())); } void MacroAssembler::decode_klass_not_null(Register r, Register tmp) { @@ -3775,7 +3766,6 @@ void MacroAssembler::decode_klass_not_null(Register r, Register tmp) { } void MacroAssembler::decode_klass_not_null(Register dst, Register src, Register tmp) { - assert(UseCompressedClassPointers, "should only be used for compressed headers"); assert_different_registers(dst, tmp); assert_different_registers(src, tmp); @@ -3806,8 +3796,6 @@ void MacroAssembler::encode_klass_not_null(Register r, Register tmp) { } void MacroAssembler::encode_klass_not_null(Register dst, Register src, Register tmp) { - assert(UseCompressedClassPointers, "should only be used for compressed headers"); - if (CompressedKlassPointers::base() == nullptr) { if (CompressedKlassPointers::shift() != 0) { srli(dst, src, CompressedKlassPointers::shift()); @@ -5337,7 +5325,6 @@ void MacroAssembler::set_narrow_oop(Register dst, jobject obj) { } void MacroAssembler::set_narrow_klass(Register dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int index = oop_recorder()->find_index(k); @@ -5417,12 +5404,9 @@ int MacroAssembler::ic_check(int end_alignment) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(tmp1, receiver); lwu(tmp2, Address(data, CompiledICData::speculated_klass_offset())); - } else if (UseCompressedClassPointers) { + } else { lwu(tmp1, Address(receiver, oopDesc::klass_offset_in_bytes())); lwu(tmp2, Address(data, CompiledICData::speculated_klass_offset())); - } else { - ld(tmp1, Address(receiver, oopDesc::klass_offset_in_bytes())); - ld(tmp2, Address(data, CompiledICData::speculated_klass_offset())); } Label ic_hit; diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 730dd68dd88..e236d03e6d2 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. // Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1801,13 +1801,8 @@ void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const { assert_cond(st != nullptr); st->print_cr("# MachUEPNode"); - if (UseCompressedClassPointers) { - st->print_cr("\tlwu t1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tlwu t2, [t0 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); - } else { - st->print_cr("\tld t1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tld t2, [t0 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); - } + st->print_cr("\tlwu t1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); + st->print_cr("\tlwu t2, [t0 + CompiledICData::speculated_klass_offset()]\t# compressed klass"); st->print_cr("\tbeq t1, t2, ic_hit"); st->print_cr("\tj, SharedRuntime::_ic_miss_stub\t # Inline cache check"); st->print_cr("\tic_hit:"); @@ -2060,11 +2055,8 @@ bool Matcher::is_generic_vector(MachOper* opnd) { return false; } +#ifdef ASSERT // Return whether or not this register is ever used as an argument. -// This function is used on startup to build the trampoline stubs in -// generateOptoStub. Registers not mentioned will be killed by the VM -// call in the trampoline, and arguments in those registers not be -// available to the callee. bool Matcher::can_be_java_arg(int reg) { return @@ -2085,11 +2077,7 @@ bool Matcher::can_be_java_arg(int reg) reg == F16_num || reg == F16_H_num || reg == F17_num || reg == F17_H_num; } - -bool Matcher::is_spillable_arg(int reg) -{ - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -2118,10 +2106,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? _FLOAT_REG_mask.size() : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con(jlong divisor) { - return false; -} - const RegMask& Matcher::divI_proj_mask() { ShouldNotReachHere(); return RegMask::EMPTY; @@ -2274,7 +2258,7 @@ encode %{ } else if (rtype == relocInfo::metadata_type) { __ mov_metadata(dst_reg, (Metadata*)con); } else { - assert(rtype == relocInfo::none, "unexpected reloc type"); + assert(rtype == relocInfo::none || rtype == relocInfo::external_word_type, "unexpected reloc type"); __ mv(dst_reg, $src$$constant); } } @@ -2559,11 +2543,6 @@ frame %{ // Compiled code's Frame Pointer frame_pointer(R2); - // Interpreter stores its frame pointer in a register which is - // stored to the stack by I2CAdaptors. - // I2CAdaptors convert from interpreted java to compiled java. - interpreter_frame_pointer(R8); - // Stack alignment requirement stack_alignment(StackAlignmentInBytes); // Alignment size in bytes (128-bit -> 16 bytes) @@ -8168,6 +8147,22 @@ instruct unnecessary_membar_rvtso() %{ ins_pipe(real_empty); %} +instruct membar_storeload_rvtso() %{ + predicate(UseZtso); + match(MemBarStoreLoad); + ins_cost(VOLATILE_REF_COST); + + format %{ "#@membar_storeload_rvtso\n\t" + "fence w, r"%} + + ins_encode %{ + __ block_comment("membar_storeload_rvtso"); + __ membar(MacroAssembler::StoreLoad); + %} + + ins_pipe(pipe_slow); +%} + instruct membar_volatile_rvtso() %{ predicate(UseZtso); match(MemBarVolatile); @@ -8198,6 +8193,22 @@ instruct unnecessary_membar_volatile_rvtso() %{ ins_pipe(real_empty); %} +instruct membar_full_rvtso() %{ + predicate(UseZtso); + match(MemBarFull); + ins_cost(VOLATILE_REF_COST); + + format %{ "#@membar_full_rvtso\n\t" + "fence rw, rw" %} + + ins_encode %{ + __ block_comment("membar_full_rvtso"); + __ membar(MacroAssembler::AnyAny); + %} + + ins_pipe(pipe_slow); +%} + // RVWMO instruct membar_aqcuire_rvwmo() %{ @@ -8247,6 +8258,22 @@ instruct membar_storestore_rvwmo() %{ ins_pipe(pipe_serial); %} +instruct membar_storeload_rvwmo() %{ + predicate(!UseZtso); + match(MemBarStoreLoad); + ins_cost(VOLATILE_REF_COST); + + format %{ "#@membar_storeload_rvwmo\n\t" + "fence w, r"%} + + ins_encode %{ + __ block_comment("membar_storeload_rvwmo"); + __ membar(MacroAssembler::StoreLoad); + %} + + ins_pipe(pipe_serial); +%} + instruct membar_volatile_rvwmo() %{ predicate(!UseZtso); match(MemBarVolatile); @@ -8291,6 +8318,22 @@ instruct unnecessary_membar_volatile_rvwmo() %{ ins_pipe(real_empty); %} +instruct membar_full_rvwmo() %{ + predicate(!UseZtso); + match(MemBarFull); + ins_cost(VOLATILE_REF_COST); + + format %{ "#@membar_full_rvwmo\n\t" + "fence rw, rw" %} + + ins_encode %{ + __ block_comment("membar_full_rvwmo"); + __ membar(MacroAssembler::AnyAny); + %} + + ins_pipe(pipe_serial); +%} + instruct spin_wait() %{ predicate(UseZihintpause); match(OnSpinWait); diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 127ac9f6951..964c6d98e9c 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2025, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2025, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -3070,8 +3070,7 @@ class StubGenerator: public StubCodeGenerator { const Register tmp = x30, tmpLval = x12; int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); #ifdef ASSERT if (AvoidUnalignedAccesses) { @@ -3128,8 +3127,7 @@ class StubGenerator: public StubCodeGenerator { tmp1 = x28, tmp2 = x29, tmp3 = x30, tmp4 = x12; int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE); - assert((base_offset % (UseCompactObjectHeaders ? 4 : - (UseCompressedClassPointers ? 8 : 4))) == 0, "Must be"); + assert((base_offset % (UseCompactObjectHeaders ? 4 : 8)) == 0, "Must be"); Register strU = isLU ? str2 : str1, strL = isLU ? str1 : str2, diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index 03c843efc69..11a88dfedd7 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -55,7 +55,7 @@ class VM_Version : public Abstract_VM_Version { public: RVFeatureValue(const char* pretty, int linux_bit_num, bool fstring) : - _pretty(pretty), _feature_string(fstring), _linux_feature_bit(nth_bit(linux_bit_num)) { + _pretty(pretty), _feature_string(fstring), _linux_feature_bit(nth_bit(linux_bit_num)) { } virtual void enable_feature(int64_t value = 0) = 0; virtual void disable_feature() = 0; diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 93d6051aa76..e1d8d062c23 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -2251,9 +2251,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { // but not necessarily exactly of type default_type. NearLabel known_ok, halt; metadata2reg(default_type->constant_encoding(), tmp); - if (UseCompressedClassPointers) { - __ encode_klass_not_null(tmp); - } + __ encode_klass_not_null(tmp); if (basic_type != T_OBJECT) { __ cmp_klass(tmp, dst, Z_R1_scratch); @@ -2540,13 +2538,8 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L // Get object class. // Not a safepoint as obj null check happens earlier. if (op->fast_check()) { - if (UseCompressedClassPointers) { - __ load_klass(klass_RInfo, obj); - __ compareU64_and_branch(k_RInfo, klass_RInfo, Assembler::bcondNotEqual, *failure_target); - } else { - __ z_cg(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); - __ branch_optimized(Assembler::bcondNotEqual, *failure_target); - } + __ load_klass(klass_RInfo, obj); + __ compareU64_and_branch(k_RInfo, klass_RInfo, Assembler::bcondNotEqual, *failure_target); // Successful cast, fall through to profile or jump. } else { bool need_slow_path = !k->is_loaded() || diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index 993c1a1b552..813143938f9 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -107,10 +107,10 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register } if (len->is_valid()) { - // Length will be in the klass gap, if one exists. + // Length will be in the klass gap. z_st(len, Address(obj, arrayOopDesc::length_offset_in_bytes())); - } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) { - store_klass_gap(Rzero, obj); // Zero klass gap for compressed oops. + } else if (!UseCompactObjectHeaders) { + store_klass_gap(Rzero, obj); // Zero klass gap. } } diff --git a/src/hotspot/cpu/s390/c1_globals_s390.hpp b/src/hotspot/cpu/s390/c1_globals_s390.hpp index 25e46cd1509..64cc239800a 100644 --- a/src/hotspot/cpu/s390/c1_globals_s390.hpp +++ b/src/hotspot/cpu/s390/c1_globals_s390.hpp @@ -51,8 +51,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M); define_pd_global(size_t, CodeCacheExpansionSize, 32*K); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true); -define_pd_global(size_t, NewSizeThreadIncrease, 16*K); define_pd_global(size_t, InitialCodeCacheSize, 160*K); #endif // !COMPILER2 diff --git a/src/hotspot/cpu/s390/c2_globals_s390.hpp b/src/hotspot/cpu/s390/c2_globals_s390.hpp index 431a36cda07..eee3a8588c3 100644 --- a/src/hotspot/cpu/s390/c2_globals_s390.hpp +++ b/src/hotspot/cpu/s390/c2_globals_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,9 +44,8 @@ define_pd_global(intx, CompileThreshold, 10000); define_pd_global(intx, OnStackReplacePercentage, 140); define_pd_global(intx, ConditionalMoveLimit, 4); -define_pd_global(intx, FreqInlineSize, 175); +define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, InteriorEntryAlignment, 4); -define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, RegisterCostAreaRatio, 12000); define_pd_global(intx, LoopUnrollLimit, 60); define_pd_global(intx, LoopPercentProfileLimit, 10); @@ -79,7 +78,4 @@ define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed on z/Architecture. -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - #endif // CPU_S390_C2_GLOBALS_S390_HPP diff --git a/src/hotspot/cpu/s390/compiledIC_s390.cpp b/src/hotspot/cpu/s390/compiledIC_s390.cpp index 8501a0cb346..43f5d80250e 100644 --- a/src/hotspot/cpu/s390/compiledIC_s390.cpp +++ b/src/hotspot/cpu/s390/compiledIC_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,9 +29,6 @@ #include "memory/resourceArea.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" -#ifdef COMPILER2 -#include "opto/matcher.hpp" -#endif // ---------------------------------------------------------------------------- @@ -39,7 +36,6 @@ #define __ masm-> address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address mark/* = nullptr*/) { -#ifdef COMPILER2 // Stub is fixed up when the corresponding call is converted from calling // compiled code to calling interpreted code. if (mark == nullptr) { @@ -55,7 +51,7 @@ address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address ma __ relocate(static_stub_Relocation::spec(mark)); AddressLiteral meta = __ allocate_metadata_address(nullptr); - bool success = __ load_const_from_toc(as_Register(Matcher::inline_cache_reg_encode()), meta); + bool success = __ load_const_from_toc(Z_inline_cache, meta); __ set_inst_mark(); AddressLiteral a((address)-1); @@ -67,10 +63,6 @@ address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address ma __ z_br(Z_R1); __ end_a_stub(); // Update current stubs pointer and restore insts_end. return stub; -#else - ShouldNotReachHere(); - return nullptr; -#endif } #undef __ diff --git a/src/hotspot/cpu/s390/downcallLinker_s390.cpp b/src/hotspot/cpu/s390/downcallLinker_s390.cpp index ccd8002da37..f1c41d05b5c 100644 --- a/src/hotspot/cpu/s390/downcallLinker_s390.cpp +++ b/src/hotspot/cpu/s390/downcallLinker_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -129,7 +129,7 @@ void DowncallLinker::StubGenerator::generate() { assert(!_needs_return_buffer, "unexpected needs_return_buffer"); RegSpiller out_reg_spiller(_output_registers); - int spill_offset = allocated_frame_size; + int out_spill_offset = allocated_frame_size; allocated_frame_size += BytesPerWord; StubLocations locs; @@ -153,6 +153,18 @@ void DowncallLinker::StubGenerator::generate() { GrowableArray out_regs = ForeignGlobals::replace_place_holders(_input_registers, locs); ArgumentShuffle arg_shuffle(filtered_java_regs, out_regs, _abi._scratch1); + // Need to spill for state capturing runtime call. + // The area spilled into is distinct from the capture state buffer. + RegSpiller in_reg_spiller(out_regs); + int in_spill_offset = -1; + if (_captured_state_mask != 0) { + // The spill area cannot be shared with the out_spill since + // spilling needs to happen before the call. Allocate a new + // region in the stack for this spill space. + in_spill_offset = allocated_frame_size; + allocated_frame_size += in_reg_spiller.spill_size_bytes(); + } + #ifndef PRODUCT LogTarget(Trace, foreign, downcall) lt; if (lt.is_enabled()) { @@ -192,6 +204,21 @@ void DowncallLinker::StubGenerator::generate() { arg_shuffle.generate(_masm, shuffle_reg, frame::z_jit_out_preserve_size, _abi._shadow_space_bytes); __ block_comment("} argument_shuffle"); + if (_captured_state_mask != 0) { + assert(in_spill_offset != -1, "must be"); + __ block_comment("{ load initial thread local"); + in_reg_spiller.generate_spill(_masm, in_spill_offset); + + // Copy the contents of the capture state buffer into thread local + __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state_pre)); + __ z_lg(Z_ARG1, Address(Z_SP, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); + __ load_const_optimized(Z_ARG2, _captured_state_mask); + __ call(call_target_address); + + in_reg_spiller.generate_fill(_masm, in_spill_offset); + __ block_comment("} load initial thread local"); + } + __ call(as_Register(locs.get(StubLocations::TARGET_ADDRESS))); ////////////////////////////////////////////////////////////////////////////// @@ -199,14 +226,14 @@ void DowncallLinker::StubGenerator::generate() { if (_captured_state_mask != 0) { __ block_comment("save_thread_local {"); - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); - __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state)); + __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, DowncallLinker::capture_state_post)); __ z_lg(Z_ARG1, Address(Z_SP, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); __ load_const_optimized(Z_ARG2, _captured_state_mask); __ call(call_target_address); - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); __ block_comment("} save_thread_local"); } @@ -259,13 +286,13 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_safepoint_poll_slow_path); // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, JavaThread::check_special_condition_for_native_trans)); __ z_lgr(Z_ARG1, Z_thread); __ call(call_target_address); - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); __ z_bru(L_after_safepoint_poll); __ block_comment("} L_safepoint_poll_slow_path"); @@ -275,12 +302,12 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_reguard); // Need to save the native result registers around any runtime calls. - out_reg_spiller.generate_spill(_masm, spill_offset); + out_reg_spiller.generate_spill(_masm, out_spill_offset); __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, SharedRuntime::reguard_yellow_pages)); __ call(call_target_address); - out_reg_spiller.generate_fill(_masm, spill_offset); + out_reg_spiller.generate_fill(_masm, out_spill_offset); __ z_bru(L_after_reguard); diff --git a/src/hotspot/cpu/s390/frame_s390.hpp b/src/hotspot/cpu/s390/frame_s390.hpp index ad754706367..bcdeec43e1a 100644 --- a/src/hotspot/cpu/s390/frame_s390.hpp +++ b/src/hotspot/cpu/s390/frame_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -463,7 +463,7 @@ // Accessors - inline intptr_t* fp() const { return _fp; } + inline intptr_t* fp() const { assert_absolute(); return _fp; } private: diff --git a/src/hotspot/cpu/s390/frame_s390.inline.hpp b/src/hotspot/cpu/s390/frame_s390.inline.hpp index dea0e72581f..6fcd36c57d1 100644 --- a/src/hotspot/cpu/s390/frame_s390.inline.hpp +++ b/src/hotspot/cpu/s390/frame_s390.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -133,10 +133,10 @@ inline void frame::interpreter_frame_set_monitors(BasicObjectLock* monitors) { // Return unique id for this frame. The id must have a value where we // can distinguish identity and younger/older relationship. null -// represents an invalid (incomparable) frame. +// represents an invalid (incomparable) frame. Should not be called for heap frames. inline intptr_t* frame::id(void) const { // Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing. - return _fp; + return real_fp(); } // Return true if this frame is older (less recent activation) than diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp index c6f5a4e119c..9fac231df47 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -169,6 +169,11 @@ void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Re __ z_lg(obj, 0, obj); // Resolve (untagged) jobject. } +void BarrierSetAssembler::try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) { + // Load the oop from the weak handle. + __ z_lg(obj, Address(obj)); +} + void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) { BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); __ align(4, __ offset() + OFFSET_TO_PATCHABLE_DATA); // must align the following block which requires atomic updates diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp index 65db915b672..8e76ec2f4b4 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -58,6 +58,11 @@ public: virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); + // Can be used in nmethods including native wrappers. + // Attention: obj will only be valid until next safepoint (no SATB barrier). + // (other platforms currently use it for C2 only: try_resolve_weak_handle_in_c2) + virtual void try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path); + virtual void nmethod_entry_barrier(MacroAssembler* masm); virtual void barrier_stubs_init() {} diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index a80ca26239b..d5239898dd7 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1259,27 +1259,15 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) { void InterpreterMacroAssembler::profile_virtual_call(Register receiver, Register mdp, - Register reg2, - bool receiver_can_be_null) { + Register reg2) { if (ProfileInterpreter) { NearLabel profile_continue; // If no method data exists, go to profile_continue. test_method_data_pointer(mdp, profile_continue); - NearLabel skip_receiver_profile; - if (receiver_can_be_null) { - NearLabel not_null; - compareU64_and_branch(receiver, (intptr_t)0L, bcondNotEqual, not_null); - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); - z_bru(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. record_klass_in_profile(receiver, mdp, reg2); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); diff --git a/src/hotspot/cpu/s390/interp_masm_s390.hpp b/src/hotspot/cpu/s390/interp_masm_s390.hpp index d981f9ea01e..b816185b065 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.hpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -296,8 +296,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_call(Register mdp); void profile_final_call(Register mdp); void profile_virtual_call(Register receiver, Register mdp, - Register scratch2, - bool receiver_can_be_null = false); + Register scratch2); void profile_ret(Register return_bci, Register mdp); void profile_null_seen(Register mdp); void profile_typecheck(Register mdp, Register klass, Register scratch); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index f35e18c7398..de3608e74ba 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -1,7 +1,7 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. - * Copyright 2024 IBM Corporation. All rights reserved. + * Copyright 2024, 2026 IBM Corporation. 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 @@ -44,6 +44,7 @@ #include "runtime/icache.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/objectMonitor.hpp" +#include "runtime/objectMonitorTable.hpp" #include "runtime/os.hpp" #include "runtime/safepoint.hpp" #include "runtime/safepointMechanism.hpp" @@ -1236,7 +1237,6 @@ void MacroAssembler::load_narrow_oop(Register t, narrowOop a) { // Load narrow klass constant, compression required. void MacroAssembler::load_narrow_klass(Register t, Klass* k) { - assert(UseCompressedClassPointers, "must be on to call this method"); narrowKlass encoded_k = CompressedKlassPointers::encode(k); load_const_32to64(t, encoded_k, false /*sign_extend*/); } @@ -1254,7 +1254,6 @@ void MacroAssembler::compare_immediate_narrow_oop(Register oop1, narrowOop oop2) // Compare narrow oop in reg with narrow oop constant, no decompression. void MacroAssembler::compare_immediate_narrow_klass(Register klass1, Klass* klass2) { - assert(UseCompressedClassPointers, "must be on to call this method"); narrowKlass encoded_k = CompressedKlassPointers::encode(klass2); Assembler::z_clfi(klass1, encoded_k); @@ -1347,8 +1346,6 @@ int MacroAssembler::patch_load_narrow_oop(address pos, oop o) { // Patching the immediate value of CPU version dependent load_narrow_klass sequence. // The passed ptr must NOT be in compressed format! int MacroAssembler::patch_load_narrow_klass(address pos, Klass* k) { - assert(UseCompressedClassPointers, "Can only patch compressed klass pointers"); - narrowKlass nk = CompressedKlassPointers::encode(k); return patch_load_const_32to64(pos, nk); } @@ -1363,8 +1360,6 @@ int MacroAssembler::patch_compare_immediate_narrow_oop(address pos, oop o) { // Patching the immediate value of CPU version dependent compare_immediate_narrow_klass sequence. // The passed ptr must NOT be in compressed format! int MacroAssembler::patch_compare_immediate_narrow_klass(address pos, Klass* k) { - assert(UseCompressedClassPointers, "Can only patch compressed klass pointers"); - narrowKlass nk = CompressedKlassPointers::encode(k); return patch_compare_immediate_32(pos, nk); } @@ -2234,10 +2229,8 @@ int MacroAssembler::ic_check(int end_alignment) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(R1_scratch, R2_receiver); - } else if (UseCompressedClassPointers) { - z_llgf(R1_scratch, Address(R2_receiver, oopDesc::klass_offset_in_bytes())); } else { - z_lg(R1_scratch, Address(R2_receiver, oopDesc::klass_offset_in_bytes())); + z_llgf(R1_scratch, Address(R2_receiver, oopDesc::klass_offset_in_bytes())); } z_cg(R1_scratch, Address(R9_data, in_bytes(CompiledICData::speculated_klass_offset()))); z_bre(success); @@ -3915,7 +3908,6 @@ void MacroAssembler::encode_klass_not_null(Register dst, Register src) { address base = CompressedKlassPointers::base(); int shift = CompressedKlassPointers::shift(); bool need_zero_extend = base != nullptr; - assert(UseCompressedClassPointers, "only for compressed klass ptrs"); BLOCK_COMMENT("cKlass encoder {"); @@ -4012,7 +4004,6 @@ int MacroAssembler::instr_size_for_decode_klass_not_null() { address base = CompressedKlassPointers::base(); int shift_size = CompressedKlassPointers::shift() == 0 ? 0 : 6; /* sllg */ int addbase_size = 0; - assert(UseCompressedClassPointers, "only for compressed klass ptrs"); if (base != nullptr) { unsigned int base_h = ((unsigned long)base)>>32; @@ -4042,7 +4033,6 @@ void MacroAssembler::decode_klass_not_null(Register dst) { address base = CompressedKlassPointers::base(); int shift = CompressedKlassPointers::shift(); int beg_off = offset(); - assert(UseCompressedClassPointers, "only for compressed klass ptrs"); BLOCK_COMMENT("cKlass decoder (const size) {"); @@ -4084,7 +4074,6 @@ void MacroAssembler::decode_klass_not_null(Register dst) { void MacroAssembler::decode_klass_not_null(Register dst, Register src) { address base = CompressedKlassPointers::base(); int shift = CompressedKlassPointers::shift(); - assert(UseCompressedClassPointers, "only for compressed klass ptrs"); BLOCK_COMMENT("cKlass decoder {"); @@ -4124,13 +4113,9 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src) { } void MacroAssembler::load_klass(Register klass, Address mem) { - if (UseCompressedClassPointers) { - z_llgf(klass, mem); - // Attention: no null check here! - decode_klass_not_null(klass); - } else { - z_lg(klass, mem); - } + z_llgf(klass, mem); + // Attention: no null check here! + decode_klass_not_null(klass); } // Loads the obj's Klass* into dst. @@ -4153,10 +4138,8 @@ void MacroAssembler::cmp_klass(Register klass, Register obj, Register tmp) { assert_different_registers(klass, obj, tmp); load_narrow_klass_compact(tmp, obj); z_cr(klass, tmp); - } else if (UseCompressedClassPointers) { - z_c(klass, Address(obj, oopDesc::klass_offset_in_bytes())); } else { - z_cg(klass, Address(obj, oopDesc::klass_offset_in_bytes())); + z_c(klass, Address(obj, oopDesc::klass_offset_in_bytes())); } BLOCK_COMMENT("} cmp_klass"); } @@ -4169,12 +4152,9 @@ void MacroAssembler::cmp_klasses_from_objects(Register obj1, Register obj2, Regi load_narrow_klass_compact(tmp1, obj1); load_narrow_klass_compact(tmp2, obj2); z_cr(tmp1, tmp2); - } else if (UseCompressedClassPointers) { + } else { z_l(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); z_c(tmp1, Address(obj2, oopDesc::klass_offset_in_bytes())); - } else { - z_lg(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); - z_cg(tmp1, Address(obj2, oopDesc::klass_offset_in_bytes())); } BLOCK_COMMENT("} cmp_klasses_from_objects"); } @@ -4183,36 +4163,28 @@ void MacroAssembler::load_klass(Register klass, Register src_oop) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(klass, src_oop); decode_klass_not_null(klass); - } else if (UseCompressedClassPointers) { + } else { z_llgf(klass, oopDesc::klass_offset_in_bytes(), src_oop); decode_klass_not_null(klass); - } else { - z_lg(klass, oopDesc::klass_offset_in_bytes(), src_oop); } } void MacroAssembler::store_klass(Register klass, Register dst_oop, Register ck) { assert(!UseCompactObjectHeaders, "Don't use with compact headers"); - if (UseCompressedClassPointers) { - assert_different_registers(dst_oop, klass, Z_R0); - if (ck == noreg) ck = klass; - encode_klass_not_null(ck, klass); - z_st(ck, Address(dst_oop, oopDesc::klass_offset_in_bytes())); - } else { - z_stg(klass, Address(dst_oop, oopDesc::klass_offset_in_bytes())); - } + assert_different_registers(dst_oop, klass, Z_R0); + if (ck == noreg) ck = klass; + encode_klass_not_null(ck, klass); + z_st(ck, Address(dst_oop, oopDesc::klass_offset_in_bytes())); } void MacroAssembler::store_klass_gap(Register s, Register d) { assert(!UseCompactObjectHeaders, "Don't use with compact headers"); - if (UseCompressedClassPointers) { - assert(s != d, "not enough registers"); - // Support s = noreg. - if (s != noreg) { - z_st(s, Address(d, oopDesc::klass_gap_offset_in_bytes())); - } else { - z_mvhi(Address(d, oopDesc::klass_gap_offset_in_bytes()), 0); - } + assert(s != d, "not enough registers"); + // Support s = noreg. + if (s != noreg) { + z_st(s, Address(d, oopDesc::klass_gap_offset_in_bytes())); + } else { + z_mvhi(Address(d, oopDesc::klass_gap_offset_in_bytes()), 0); } } @@ -4226,67 +4198,64 @@ void MacroAssembler::compare_klass_ptr(Register Rop1, int64_t disp, Register Rba BLOCK_COMMENT("compare klass ptr {"); - if (UseCompressedClassPointers) { - const int shift = CompressedKlassPointers::shift(); - address base = CompressedKlassPointers::base(); + const int shift = CompressedKlassPointers::shift(); + address base = CompressedKlassPointers::base(); - if (UseCompactObjectHeaders) { - assert(shift >= 3, "cKlass encoder detected bad shift"); - } else { - assert((shift == 0) || (shift == 3), "cKlass encoder detected bad shift"); - } - assert_different_registers(Rop1, Z_R0); - assert_different_registers(Rop1, Rbase, Z_R1); - - // First encode register oop and then compare with cOop in memory. - // This sequence saves an unnecessary cOop load and decode. - if (base == nullptr) { - if (shift == 0) { - z_cl(Rop1, disp, Rbase); // Unscaled - } else { - z_srlg(Z_R0, Rop1, shift); // ZeroBased - z_cl(Z_R0, disp, Rbase); - } - } else { // HeapBased -#ifdef ASSERT - bool used_R0 = true; - bool used_R1 = true; -#endif - Register current = Rop1; - Label done; - - if (maybenull) { // null pointer must be preserved! - z_ltgr(Z_R0, current); - z_bre(done); - current = Z_R0; - } - - unsigned int base_h = ((unsigned long)base)>>32; - unsigned int base_l = (unsigned int)((unsigned long)base); - if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) { - lgr_if_needed(Z_R0, current); - z_aih(Z_R0, -((int)base_h)); // Base has no set bits in lower half. - } else if ((base_h == 0) && (base_l != 0)) { - lgr_if_needed(Z_R0, current); - z_agfi(Z_R0, -(int)base_l); - } else { - int pow2_offset = get_oop_base_complement(Z_R1, ((uint64_t)(intptr_t)base)); - add2reg_with_index(Z_R0, pow2_offset, Z_R1, Rop1); // Subtract base by adding complement. - } - - if (shift != 0) { - z_srlg(Z_R0, Z_R0, shift); - } - bind(done); - z_cl(Z_R0, disp, Rbase); -#ifdef ASSERT - if (used_R0) preset_reg(Z_R0, 0xb05bUL, 2); - if (used_R1) preset_reg(Z_R1, 0xb06bUL, 2); -#endif - } + if (UseCompactObjectHeaders) { + assert(shift >= 3, "cKlass encoder detected bad shift"); } else { - z_clg(Rop1, disp, Z_R0, Rbase); + assert((shift == 0) || (shift == 3), "cKlass encoder detected bad shift"); } + assert_different_registers(Rop1, Z_R0); + assert_different_registers(Rop1, Rbase, Z_R1); + + // First encode register oop and then compare with cOop in memory. + // This sequence saves an unnecessary cOop load and decode. + if (base == nullptr) { + if (shift == 0) { + z_cl(Rop1, disp, Rbase); // Unscaled + } else { + z_srlg(Z_R0, Rop1, shift); // ZeroBased + z_cl(Z_R0, disp, Rbase); + } + } else { // HeapBased +#ifdef ASSERT + bool used_R0 = true; + bool used_R1 = true; +#endif + Register current = Rop1; + Label done; + + if (maybenull) { // null pointer must be preserved! + z_ltgr(Z_R0, current); + z_bre(done); + current = Z_R0; + } + + unsigned int base_h = ((unsigned long)base)>>32; + unsigned int base_l = (unsigned int)((unsigned long)base); + if ((base_h != 0) && (base_l == 0) && VM_Version::has_HighWordInstr()) { + lgr_if_needed(Z_R0, current); + z_aih(Z_R0, -((int)base_h)); // Base has no set bits in lower half. + } else if ((base_h == 0) && (base_l != 0)) { + lgr_if_needed(Z_R0, current); + z_agfi(Z_R0, -(int)base_l); + } else { + int pow2_offset = get_oop_base_complement(Z_R1, ((uint64_t)(intptr_t)base)); + add2reg_with_index(Z_R0, pow2_offset, Z_R1, Rop1); // Subtract base by adding complement. + } + + if (shift != 0) { + z_srlg(Z_R0, Z_R0, shift); + } + bind(done); + z_cl(Z_R0, disp, Rbase); +#ifdef ASSERT + if (used_R0) preset_reg(Z_R0, 0xb05bUL, 2); + if (used_R1) preset_reg(Z_R1, 0xb06bUL, 2); +#endif + } + BLOCK_COMMENT("} compare klass ptr"); } @@ -6372,45 +6341,55 @@ void MacroAssembler::compiler_fast_lock_object(Register obj, Register box, Regis if (!UseObjectMonitorTable) { assert(tmp1_monitor == mark, "should be the same here"); } else { + const Register tmp1_bucket = tmp1; + const Register hash = Z_R0_scratch; NearLabel monitor_found; - // load cache address - z_la(tmp1, Address(Z_thread, JavaThread::om_cache_oops_offset())); + // Save the mark, we might need it to extract the hash. + z_lgr(hash, mark); - const int num_unrolled = 2; + // Look for the monitor in the om_cache. + + ByteSize cache_offset = JavaThread::om_cache_oops_offset(); + ByteSize monitor_offset = OMCache::oop_to_monitor_difference(); + const int num_unrolled = OMCache::CAPACITY; for (int i = 0; i < num_unrolled; i++) { - z_cg(obj, Address(tmp1)); + z_lg(tmp1_monitor, Address(Z_thread, cache_offset + monitor_offset)); + z_cg(obj, Address(Z_thread, cache_offset)); z_bre(monitor_found); - add2reg(tmp1, in_bytes(OMCache::oop_to_oop_difference())); + cache_offset = cache_offset + OMCache::oop_to_oop_difference(); } - NearLabel loop; - // Search for obj in cache + // Get the hash code. + z_srlg(hash, hash, markWord::hash_shift); - bind(loop); + // Get the table and calculate the bucket's address. + load_const_optimized(tmp2, ObjectMonitorTable::current_table_address()); + z_lg(tmp2, Address(tmp2)); + z_ng(hash, Address(tmp2, ObjectMonitorTable::table_capacity_mask_offset())); + z_lg(tmp1_bucket, Address(tmp2, ObjectMonitorTable::table_buckets_offset())); + z_sllg(hash, hash, LogBytesPerWord); + z_agr(tmp1_bucket, hash); - // check for match. - z_cg(obj, Address(tmp1)); - z_bre(monitor_found); + // Read the monitor from the bucket. + z_lg(tmp1_monitor, Address(tmp1_bucket)); - // search until null encountered, guaranteed _null_sentinel at end. - add2reg(tmp1, in_bytes(OMCache::oop_to_oop_difference())); - z_cghsi(0, tmp1, 0); - z_brne(loop); // if not EQ to 0, go for another loop + // Check if the monitor in the bucket is special (empty, tombstone or removed). + z_clgfi(tmp1_monitor, ObjectMonitorTable::SpecialPointerValues::below_is_special); + z_brl(slow_path); - // we reached to the end, cache miss - z_ltgr(obj, obj); // set CC to NE - z_bru(slow_path); + // Check if object matches. + z_lg(tmp2, Address(tmp1_monitor, ObjectMonitor::object_offset())); + BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); + bs_asm->try_resolve_weak_handle(this, tmp2, Z_R0_scratch, slow_path); + z_cgr(obj, tmp2); + z_brne(slow_path); - // cache hit bind(monitor_found); - z_lg(tmp1_monitor, Address(tmp1, OMCache::oop_to_monitor_difference())); } NearLabel monitor_locked; // lock the monitor - // mark contains the tagged ObjectMonitor*. - const Register tagged_monitor = mark; const Register zero = tmp2; const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index da24ae80d45..32e484d4790 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * Copyright (c) 2024 IBM Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -842,8 +842,7 @@ class MacroAssembler: public Assembler { void store_klass(Register klass, Register dst_oop, Register ck = noreg); // Klass will get compressed if ck not provided. void store_klass_gap(Register s, Register dst_oop); void load_narrow_klass_compact(Register dst, Register src); - // Compares the Klass pointer of an object to a given Klass (which might be narrow, - // depending on UseCompressedClassPointers). + // Compares the narrow Klass pointer of an object to a given narrow Klass void cmp_klass(Register klass, Register obj, Register tmp); // Compares the Klass pointer of two objects obj1 and obj2. Result is in the condition flags. // Uses tmp1 and tmp2 as temporary registers. diff --git a/src/hotspot/cpu/s390/matcher_s390.hpp b/src/hotspot/cpu/s390/matcher_s390.hpp index 99461e33e3c..b04a6566d41 100644 --- a/src/hotspot/cpu/s390/matcher_s390.hpp +++ b/src/hotspot/cpu/s390/matcher_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -82,7 +82,6 @@ static bool narrow_klass_use_complex_address() { NOT_LP64(ShouldNotCallThis()); - assert(UseCompressedClassPointers, "only for compressed klass code"); // TODO HS25: z port if (MatchDecodeNodes) return true; return false; } diff --git a/src/hotspot/cpu/s390/s390.ad b/src/hotspot/cpu/s390/s390.ad index 19bd3620228..2208a197ac9 100644 --- a/src/hotspot/cpu/s390/s390.ad +++ b/src/hotspot/cpu/s390/s390.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2017, 2024 SAP SE. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // @@ -1890,10 +1890,8 @@ const int z_num_iarg_registers = sizeof(z_iarg_reg) / sizeof(z_iarg_reg[0]); const int z_num_farg_registers = sizeof(z_farg_reg) / sizeof(z_farg_reg[0]); -// Return whether or not this register is ever used as an argument. This -// function is used on startup to build the trampoline stubs in generateOptoStub. -// Registers not mentioned will be killed by the VM call in the trampoline, and -// arguments in those registers not be available to the callee. +#ifdef ASSERT +// Return whether or not this register is ever used as an argument. bool Matcher::can_be_java_arg(int reg) { // We return true for all registers contained in z_iarg_reg[] and // z_farg_reg[] and their virtual halves. @@ -1917,10 +1915,7 @@ bool Matcher::can_be_java_arg(int reg) { return false; } - -bool Matcher::is_spillable_arg(int reg) { - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -1934,10 +1929,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? 15 : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con(jlong divisor) { - return false; -} - // Register for DIVI projection of divmodI const RegMask& Matcher::divI_proj_mask() { return _Z_RARG4_INT_REG_mask; @@ -2606,13 +2597,6 @@ frame %{ // z/Architecture stack pointer frame_pointer(Z_R15); // Z_SP - // Interpreter stores its frame pointer in a register which is - // stored to the stack by I2CAdaptors. I2CAdaptors convert from - // interpreted java to compiled java. - // - // Z_state holds pointer to caller's cInterpreter. - interpreter_frame_pointer(Z_R7); // Z_state - // Use alignment_in_bytes instead of log_2_of_alignment_in_bits. stack_alignment(frame::alignment_in_bytes); @@ -5251,6 +5235,15 @@ instruct membar_release_lock() %{ ins_pipe(pipe_class_dummy); %} +instruct membar_storeload() %{ + match(MemBarStoreLoad); + ins_cost(4 * MEMORY_REF_COST); + size(2); + format %{ "MEMBAR-storeload" %} + ins_encode %{ __ z_fence(); %} + ins_pipe(pipe_class_dummy); +%} + instruct membar_volatile() %{ match(MemBarVolatile); ins_cost(4 * MEMORY_REF_COST); @@ -5270,6 +5263,15 @@ instruct unnecessary_membar_volatile() %{ ins_pipe(pipe_class_dummy); %} +instruct membar_full() %{ + match(MemBarFull); + ins_cost(4 * MEMORY_REF_COST); + size(2); + format %{ "MEMBAR-full" %} + ins_encode %{ __ z_fence(); %} + ins_pipe(pipe_class_dummy); +%} + instruct membar_CPUOrder() %{ match(MemBarCPUOrder); ins_cost(0); diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 3c8defe62d9..38a28a6ec49 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -5442,6 +5442,13 @@ void Assembler::pmovsxwd(XMMRegister dst, XMMRegister src) { emit_int16(0x23, (0xC0 | encode)); } +void Assembler::pmovzxwd(XMMRegister dst, XMMRegister src) { + assert(VM_Version::supports_sse4_1(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x33, (0xC0 | encode)); +} + void Assembler::vpmovzxbw(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionMark im(this); diff --git a/src/hotspot/cpu/x86/assembler_x86.hpp b/src/hotspot/cpu/x86/assembler_x86.hpp index 97854f712cf..57a5e25d7a6 100644 --- a/src/hotspot/cpu/x86/assembler_x86.hpp +++ b/src/hotspot/cpu/x86/assembler_x86.hpp @@ -1965,6 +1965,7 @@ private: void pmovsxbq(XMMRegister dst, XMMRegister src); void pmovsxbw(XMMRegister dst, XMMRegister src); void pmovsxwd(XMMRegister dst, XMMRegister src); + void pmovzxwd(XMMRegister dst, XMMRegister src); void vpmovsxbd(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbq(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbw(XMMRegister dst, XMMRegister src, int vector_len); diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index 37ee9451405..5397a230642 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +32,7 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" +#include "code/aotCodeCache.hpp" #include "compiler/oopMap.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/gc_globals.hpp" @@ -76,23 +77,6 @@ const Register SHIFT_count = rcx; // where count for shift operations must be #define __ _masm-> - -static void select_different_registers(Register preserve, - Register extra, - Register &tmp1, - Register &tmp2) { - if (tmp1 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp1 = extra; - } else if (tmp2 == preserve) { - assert_different_registers(tmp1, tmp2, extra); - tmp2 = extra; - } - assert_different_registers(preserve, tmp1, tmp2); -} - - - static void select_different_registers(Register preserve, Register extra, Register &tmp1, @@ -535,6 +519,15 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod case T_LONG: { assert(patch_code == lir_patch_none, "no patching handled here"); +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + address b = c->as_pointer(); + if (AOTRuntimeConstants::contains(b)) { + __ load_aotrc_address(dest->as_register_lo(), b); + break; + } + } +#endif __ movptr(dest->as_register_lo(), (intptr_t)c->as_jlong()); break; } @@ -1299,12 +1292,8 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } else if (obj == klass_RInfo) { klass_RInfo = dst; } - if (k->is_loaded() && !UseCompressedClassPointers) { - select_different_registers(obj, dst, k_RInfo, klass_RInfo); - } else { - Rtmp1 = op->tmp3()->as_register(); - select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); - } + Rtmp1 = op->tmp3()->as_register(); + select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1); assert_different_registers(obj, k_RInfo, klass_RInfo); @@ -1338,12 +1327,8 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L if (op->fast_check()) { // get object class // not a safepoint as obj null check happens earlier - if (UseCompressedClassPointers) { - __ load_klass(Rtmp1, obj, tmp_load_klass); - __ cmpptr(k_RInfo, Rtmp1); - } else { - __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); - } + __ load_klass(Rtmp1, obj, tmp_load_klass); + __ cmpptr(k_RInfo, Rtmp1); __ jcc(Assembler::notEqual, *failure_target); // successful cast, fall through to profile or jump } else { @@ -2641,9 +2626,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { // but not necessarily exactly of type default_type. Label known_ok, halt; __ mov_metadata(tmp, default_type->constant_encoding()); - if (UseCompressedClassPointers) { - __ encode_klass_not_null(tmp, rscratch1); - } + __ encode_klass_not_null(tmp, rscratch1); if (basic_type != T_OBJECT) { __ cmp_klass(tmp, dst, tmp2); diff --git a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp index 5459e8df229..f448e4ee17f 100644 --- a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -1291,9 +1291,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ checkcast(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), info_for_exception, patching_info, stub, @@ -1313,9 +1311,7 @@ void LIRGenerator::do_InstanceOf(InstanceOf* x) { } obj.load_item(); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; - if (!x->klass()->is_loaded() || UseCompressedClassPointers) { - tmp3 = new_register(objectType); - } + tmp3 = new_register(objectType); __ instanceof(reg, obj.result(), x->klass(), new_register(objectType), new_register(objectType), tmp3, x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index 88e2e6c8ba9..7adaea48ff1 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -85,14 +85,11 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register if (UseCompactObjectHeaders) { movptr(t1, Address(klass, Klass::prototype_header_offset())); movptr(Address(obj, oopDesc::mark_offset_in_bytes()), t1); - } else if (UseCompressedClassPointers) { // Take care not to kill klass + } else { // Take care not to kill klass movptr(Address(obj, oopDesc::mark_offset_in_bytes()), checked_cast(markWord::prototype().value())); movptr(t1, klass); encode_klass_not_null(t1, rscratch1); movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1); - } else { - movptr(Address(obj, oopDesc::mark_offset_in_bytes()), checked_cast(markWord::prototype().value())); - movptr(Address(obj, oopDesc::klass_offset_in_bytes()), klass); } if (len->is_valid()) { @@ -104,7 +101,7 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register xorl(t1, t1); movl(Address(obj, base_offset), t1); } - } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) { + } else if (!UseCompactObjectHeaders) { xorptr(t1, t1); store_klass_gap(obj, t1); } diff --git a/src/hotspot/cpu/x86/c1_globals_x86.hpp b/src/hotspot/cpu/x86/c1_globals_x86.hpp index 978b233bb63..bb75a31a77c 100644 --- a/src/hotspot/cpu/x86/c1_globals_x86.hpp +++ b/src/hotspot/cpu/x86/c1_globals_x86.hpp @@ -41,7 +41,6 @@ define_pd_global(bool, TieredCompilation, false); define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(size_t, NewSizeThreadIncrease, 4*K ); define_pd_global(size_t, InitialCodeCacheSize, 160*K); define_pd_global(size_t, ReservedCodeCacheSize, 32*M ); define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M ); @@ -51,7 +50,6 @@ define_pd_global(bool, ProfileInterpreter, false); define_pd_global(size_t, CodeCacheExpansionSize, 32*K ); define_pd_global(size_t, CodeCacheMinBlockLength, 1 ); define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(bool, NeverActAsServerClassMachine, true ); define_pd_global(bool, CICompileOSR, true ); #endif // !COMPILER2 define_pd_global(bool, UseTypeProfile, false); diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index c65b439604b..5b5fb02967c 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -34,7 +34,9 @@ #include "opto/subnode.hpp" #include "runtime/globals.hpp" #include "runtime/objectMonitor.hpp" +#include "runtime/objectMonitorTable.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/synchronizer.hpp" #include "utilities/checkedCast.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/powerOfTwo.hpp" @@ -217,7 +219,6 @@ inline Assembler::AvxVectorLen C2_MacroAssembler::vector_length_encoding(int vle // In the case of failure, the node will branch directly to the // FailureLabel - // obj: object to lock // box: on-stack box address -- KILLED // rax: tmp -- KILLED @@ -286,7 +287,7 @@ void C2_MacroAssembler::fast_lock(Register obj, Register box, Register rax_reg, // After successful lock, push object on lock-stack. movptr(Address(thread, top), obj); addl(Address(thread, JavaThread::lock_stack_top_offset()), oopSize); - jmpb(locked); + jmp(locked); } { // Handle inflated monitor. @@ -297,38 +298,49 @@ void C2_MacroAssembler::fast_lock(Register obj, Register box, Register rax_reg, if (!UseObjectMonitorTable) { assert(mark == monitor, "should be the same here"); } else { - // Uses ObjectMonitorTable. Look for the monitor in the om_cache. - // Fetch ObjectMonitor* from the cache or take the slow-path. + const Register hash = t; Label monitor_found; - // Load cache address - lea(t, Address(thread, JavaThread::om_cache_oops_offset())); + // Look for the monitor in the om_cache. - const int num_unrolled = 2; + ByteSize cache_offset = JavaThread::om_cache_oops_offset(); + ByteSize monitor_offset = OMCache::oop_to_monitor_difference(); + const int num_unrolled = OMCache::CAPACITY; for (int i = 0; i < num_unrolled; i++) { - cmpptr(obj, Address(t)); + movptr(monitor, Address(thread, cache_offset + monitor_offset)); + cmpptr(obj, Address(thread, cache_offset)); jccb(Assembler::equal, monitor_found); - increment(t, in_bytes(OMCache::oop_to_oop_difference())); + cache_offset = cache_offset + OMCache::oop_to_oop_difference(); } - Label loop; + // Look for the monitor in the table. - // Search for obj in cache. - bind(loop); + // Get the hash code. + movptr(hash, Address(obj, oopDesc::mark_offset_in_bytes())); + shrq(hash, markWord::hash_shift); + andq(hash, markWord::hash_mask); - // Check for match. - cmpptr(obj, Address(t)); - jccb(Assembler::equal, monitor_found); + // Get the table and calculate the bucket's address. + lea(rax_reg, ExternalAddress(ObjectMonitorTable::current_table_address())); + movptr(rax_reg, Address(rax_reg)); + andq(hash, Address(rax_reg, ObjectMonitorTable::table_capacity_mask_offset())); + movptr(rax_reg, Address(rax_reg, ObjectMonitorTable::table_buckets_offset())); - // Search until null encountered, guaranteed _null_sentinel at end. - cmpptr(Address(t), 1); - jcc(Assembler::below, slow_path); // 0 check, but with ZF=0 when *t == 0 - increment(t, in_bytes(OMCache::oop_to_oop_difference())); - jmpb(loop); + // Read the monitor from the bucket. + movptr(monitor, Address(rax_reg, hash, Address::times_ptr)); + + // Check if the monitor in the bucket is special (empty, tombstone or removed) + cmpptr(monitor, ObjectMonitorTable::SpecialPointerValues::below_is_special); + jcc(Assembler::below, slow_path); + + // Check if object matches. + movptr(rax_reg, Address(monitor, ObjectMonitor::object_offset())); + BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); + bs_asm->try_resolve_weak_handle_in_c2(this, rax_reg, slow_path); + cmpptr(rax_reg, obj); + jcc(Assembler::notEqual, slow_path); - // Cache hit. bind(monitor_found); - movptr(monitor, Address(t, OMCache::oop_to_monitor_difference())); } const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); const Address recursions_address(monitor, ObjectMonitor::recursions_offset() - monitor_tag); @@ -487,14 +499,14 @@ void C2_MacroAssembler::fast_unlock(Register obj, Register reg_rax, Register t, cmpl(top, in_bytes(JavaThread::lock_stack_base_offset())); jcc(Assembler::below, check_done); cmpptr(obj, Address(thread, top)); - jccb(Assembler::notEqual, inflated_check_lock_stack); + jcc(Assembler::notEqual, inflated_check_lock_stack); stop("Fast Unlock lock on stack"); bind(check_done); if (UseObjectMonitorTable) { movptr(mark, Address(obj, oopDesc::mark_offset_in_bytes())); } testptr(mark, markWord::monitor_value); - jccb(Assembler::notZero, inflated); + jcc(Assembler::notZero, inflated); stop("Fast Unlock not monitor"); #endif @@ -519,7 +531,7 @@ void C2_MacroAssembler::fast_unlock(Register obj, Register reg_rax, Register t, // Check if recursive. cmpptr(recursions_address, 0); - jccb(Assembler::notZero, recursive); + jcc(Assembler::notZero, recursive); // Set owner to null. // Release to satisfy the JMM @@ -530,11 +542,11 @@ void C2_MacroAssembler::fast_unlock(Register obj, Register reg_rax, Register t, // Check if the entry_list is empty. cmpptr(entry_list_address, NULL_WORD); - jccb(Assembler::zero, unlocked); // If so we are done. + jcc(Assembler::zero, unlocked); // If so we are done. // Check if there is a successor. cmpptr(succ_address, NULL_WORD); - jccb(Assembler::notZero, unlocked); // If so we are done. + jcc(Assembler::notZero, unlocked); // If so we are done. // Save the monitor pointer in the current thread, so we can try to // reacquire the lock in SharedRuntime::monitor_exit_helper(). @@ -1717,6 +1729,24 @@ void C2_MacroAssembler::reduce_operation_128(BasicType typ, int opcode, XMMRegis default: assert(false, "wrong type"); } break; + case Op_UMinReductionV: + switch (typ) { + case T_BYTE: vpminub(dst, dst, src, Assembler::AVX_128bit); break; + case T_SHORT: vpminuw(dst, dst, src, Assembler::AVX_128bit); break; + case T_INT: vpminud(dst, dst, src, Assembler::AVX_128bit); break; + case T_LONG: evpminuq(dst, k0, dst, src, true, Assembler::AVX_128bit); break; + default: assert(false, "wrong type"); + } + break; + case Op_UMaxReductionV: + switch (typ) { + case T_BYTE: vpmaxub(dst, dst, src, Assembler::AVX_128bit); break; + case T_SHORT: vpmaxuw(dst, dst, src, Assembler::AVX_128bit); break; + case T_INT: vpmaxud(dst, dst, src, Assembler::AVX_128bit); break; + case T_LONG: evpmaxuq(dst, k0, dst, src, true, Assembler::AVX_128bit); break; + default: assert(false, "wrong type"); + } + break; case Op_AddReductionVF: addss(dst, src); break; case Op_AddReductionVD: addsd(dst, src); break; case Op_AddReductionVI: @@ -1780,6 +1810,24 @@ void C2_MacroAssembler::reduce_operation_256(BasicType typ, int opcode, XMMRegis default: assert(false, "wrong type"); } break; + case Op_UMinReductionV: + switch (typ) { + case T_BYTE: vpminub(dst, src1, src2, vector_len); break; + case T_SHORT: vpminuw(dst, src1, src2, vector_len); break; + case T_INT: vpminud(dst, src1, src2, vector_len); break; + case T_LONG: evpminuq(dst, k0, src1, src2, true, vector_len); break; + default: assert(false, "wrong type"); + } + break; + case Op_UMaxReductionV: + switch (typ) { + case T_BYTE: vpmaxub(dst, src1, src2, vector_len); break; + case T_SHORT: vpmaxuw(dst, src1, src2, vector_len); break; + case T_INT: vpmaxud(dst, src1, src2, vector_len); break; + case T_LONG: evpmaxuq(dst, k0, src1, src2, true, vector_len); break; + default: assert(false, "wrong type"); + } + break; case Op_AddReductionVI: switch (typ) { case T_BYTE: vpaddb(dst, src1, src2, vector_len); break; @@ -2046,7 +2094,11 @@ void C2_MacroAssembler::reduce8B(int opcode, Register dst, Register src1, XMMReg psrldq(vtmp2, 1); reduce_operation_128(T_BYTE, opcode, vtmp1, vtmp2); movdl(vtmp2, src1); - pmovsxbd(vtmp1, vtmp1); + if (opcode == Op_UMinReductionV || opcode == Op_UMaxReductionV) { + pmovzxbd(vtmp1, vtmp1); + } else { + pmovsxbd(vtmp1, vtmp1); + } reduce_operation_128(T_INT, opcode, vtmp1, vtmp2); pextrb(dst, vtmp1, 0x0); movsbl(dst, dst); @@ -2123,7 +2175,11 @@ void C2_MacroAssembler::reduce4S(int opcode, Register dst, Register src1, XMMReg reduce_operation_128(T_SHORT, opcode, vtmp1, vtmp2); } movdl(vtmp2, src1); - pmovsxwd(vtmp1, vtmp1); + if (opcode == Op_UMinReductionV || opcode == Op_UMaxReductionV) { + pmovzxwd(vtmp1, vtmp1); + } else { + pmovsxwd(vtmp1, vtmp1); + } reduce_operation_128(T_INT, opcode, vtmp1, vtmp2); pextrw(dst, vtmp1, 0x0); movswl(dst, dst); diff --git a/src/hotspot/cpu/x86/c2_globals_x86.hpp b/src/hotspot/cpu/x86/c2_globals_x86.hpp index 3f616cb4578..11d8c03d0ca 100644 --- a/src/hotspot/cpu/x86/c2_globals_x86.hpp +++ b/src/hotspot/cpu/x86/c2_globals_x86.hpp @@ -46,7 +46,6 @@ define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, MinJumpTableSize, 10); define_pd_global(intx, LoopPercentProfileLimit, 10); define_pd_global(intx, InteriorEntryAlignment, 16); -define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, LoopUnrollLimit, 60); // InitialCodeCacheSize derived from specjbb2000 run. define_pd_global(size_t, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize @@ -74,7 +73,4 @@ define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K); define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed on x86. -// Ergonomics related flags -define_pd_global(bool, NeverActAsServerClassMachine, false); - #endif // CPU_X86_C2_GLOBALS_X86_HPP diff --git a/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp b/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp index c48940198ea..e3bf5f17fe9 100644 --- a/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp +++ b/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -145,10 +145,10 @@ void DowncallLinker::StubGenerator::generate() { // when we don't use a return buffer we need to spill the return value around our slow path calls bool should_save_return_value = !_needs_return_buffer; RegSpiller out_reg_spiller(_output_registers); - int spill_rsp_offset = -1; + int out_spill_rsp_offset = -1; if (should_save_return_value) { - spill_rsp_offset = 0; + out_spill_rsp_offset = 0; // spill area can be shared with shadow space and out args, // since they are only used before the call, // and spill area is only used after. @@ -173,6 +173,9 @@ void DowncallLinker::StubGenerator::generate() { // FP-> | | // |---------------------| = frame_bottom_offset = frame_size // | (optional) | + // | in_reg_spiller area | + // |---------------------| + // | (optional) | // | capture state buf | // |---------------------| = StubLocations::CAPTURED_STATE_BUFFER // | (optional) | @@ -188,6 +191,18 @@ void DowncallLinker::StubGenerator::generate() { VMStorage shuffle_reg = as_VMStorage(rbx); ArgumentShuffle arg_shuffle(filtered_java_regs, out_regs, shuffle_reg); + // Need to spill for state capturing runtime call. + // The area spilled into is distinct from the capture state buffer. + RegSpiller in_reg_spiller(out_regs); + int in_spill_rsp_offset = -1; + if (_captured_state_mask != 0) { + // The spill area cannot be shared with the shadow/out args space + // since spilling needs to happen before the call. Allocate a new + // region in the stack for this spill space. + in_spill_rsp_offset = allocated_frame_size; + allocated_frame_size += in_reg_spiller.spill_size_bytes(); + } + #ifndef PRODUCT LogTarget(Trace, foreign, downcall) lt; if (lt.is_enabled()) { @@ -232,6 +247,19 @@ void DowncallLinker::StubGenerator::generate() { arg_shuffle.generate(_masm, shuffle_reg, 0, _abi._shadow_space_bytes); __ block_comment("} argument shuffle"); + if (_captured_state_mask != 0) { + assert(in_spill_rsp_offset != -1, "must be"); + __ block_comment("{ load initial thread local"); + in_reg_spiller.generate_spill(_masm, in_spill_rsp_offset); + + // Copy the contents of the capture state buffer into thread local + __ movptr(c_rarg0, Address(rsp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); + __ movl(c_rarg1, _captured_state_mask); + runtime_call(_masm, CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_pre)); + + in_reg_spiller.generate_fill(_masm, in_spill_rsp_offset); + __ block_comment("} load initial thread local"); + } __ call(as_Register(locs.get(StubLocations::TARGET_ADDRESS))); assert(!_abi.is_volatile_reg(r15_thread), "Call assumed not to kill r15"); @@ -258,15 +286,15 @@ void DowncallLinker::StubGenerator::generate() { __ block_comment("{ save thread local"); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_rsp_offset); + out_reg_spiller.generate_spill(_masm, out_spill_rsp_offset); } __ movptr(c_rarg0, Address(rsp, locs.data_offset(StubLocations::CAPTURED_STATE_BUFFER))); __ movl(c_rarg1, _captured_state_mask); - runtime_call(_masm, CAST_FROM_FN_PTR(address, DowncallLinker::capture_state)); + runtime_call(_masm, CAST_FROM_FN_PTR(address, DowncallLinker::capture_state_post)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_rsp_offset); + out_reg_spiller.generate_fill(_masm, out_spill_rsp_offset); } __ block_comment("} save thread local"); @@ -319,14 +347,14 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_safepoint_poll_slow_path); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_rsp_offset); + out_reg_spiller.generate_spill(_masm, out_spill_rsp_offset); } __ mov(c_rarg0, r15_thread); runtime_call(_masm, CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_rsp_offset); + out_reg_spiller.generate_fill(_masm, out_spill_rsp_offset); } __ jmp(L_after_safepoint_poll); @@ -338,13 +366,13 @@ void DowncallLinker::StubGenerator::generate() { __ bind(L_reguard); if (should_save_return_value) { - out_reg_spiller.generate_spill(_masm, spill_rsp_offset); + out_reg_spiller.generate_spill(_masm, out_spill_rsp_offset); } runtime_call(_masm, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)); if (should_save_return_value) { - out_reg_spiller.generate_fill(_masm, spill_rsp_offset); + out_reg_spiller.generate_fill(_masm, out_spill_rsp_offset); } __ jmp(L_after_reguard); diff --git a/src/hotspot/cpu/x86/frame_x86.inline.hpp b/src/hotspot/cpu/x86/frame_x86.inline.hpp index dcd766545d3..3f3b951edc8 100644 --- a/src/hotspot/cpu/x86/frame_x86.inline.hpp +++ b/src/hotspot/cpu/x86/frame_x86.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -231,8 +231,8 @@ inline bool frame::equal(frame other) const { // Return unique id for this frame. The id must have a value where we can distinguish // identity and younger/older relationship. null represents an invalid (incomparable) -// frame. -inline intptr_t* frame::id(void) const { return unextended_sp(); } +// frame. Should not be called for heap frames. +inline intptr_t* frame::id(void) const { return real_fp(); } // Return true if the frame is older (less recent activation) than the frame represented by id inline bool frame::is_older(intptr_t* id) const { assert(this->id() != nullptr && id != nullptr, "null frame id"); @@ -397,6 +397,9 @@ inline frame frame::sender(RegisterMap* map) const { StackWatermarkSet::on_iteration(map->thread(), result); } + // Calling frame::id() is currently not supported for heap frames. + assert(result._on_heap || this->_on_heap || result.is_older(this->id()), "Must be"); + return result; } diff --git a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp index 34de9403ccf..b20d7b5cd07 100644 --- a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp @@ -23,6 +23,7 @@ */ #include "asm/macroAssembler.inline.hpp" +#include "code/aotCodeCache.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" @@ -268,6 +269,16 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, __ bind(done); } +#if INCLUDE_CDS +// return a register that differs from reg1, reg2, reg3 and reg4 + +static Register pick_different_reg(Register reg1, Register reg2 = noreg, Register reg3= noreg, Register reg4 = noreg) { + RegSet available = (RegSet::of(rscratch1, rscratch2, rax, rbx) + rdx - + RegSet::of(reg1, reg2, reg3, reg4)); + return *(available.begin()); +} +#endif // INCLUDE_CDS + static void generate_post_barrier(MacroAssembler* masm, const Register store_addr, const Register new_val, @@ -280,10 +291,32 @@ static void generate_post_barrier(MacroAssembler* masm, Label L_done; // Does store cross heap regions? - __ movptr(tmp1, store_addr); // tmp1 := store address - __ xorptr(tmp1, new_val); // tmp1 := store address ^ new value - __ shrptr(tmp1, G1HeapRegion::LogOfHRGrainBytes); // ((store address ^ new value) >> LogOfHRGrainBytes) == 0? - __ jccb(Assembler::equal, L_done); +#if INCLUDE_CDS + // AOT code needs to load the barrier grain shift from the aot + // runtime constants area in the code cache otherwise we can compile + // it as an immediate operand + + if (AOTCodeCache::is_on_for_dump()) { + address grain_shift_addr = AOTRuntimeConstants::grain_shift_address(); + Register save = pick_different_reg(rcx, tmp1, new_val, store_addr); + __ push(save); + __ movptr(save, store_addr); + __ xorptr(save, new_val); + __ push(rcx); + __ lea(rcx, ExternalAddress(grain_shift_addr)); + __ movl(rcx, Address(rcx, 0)); + __ shrptr(save); + __ pop(rcx); + __ pop(save); + __ jcc(Assembler::equal, L_done); + } else +#endif // INCLUDE_CDS + { + __ movptr(tmp1, store_addr); // tmp1 := store address + __ xorptr(tmp1, new_val); // tmp1 := store address ^ new value + __ shrptr(tmp1, G1HeapRegion::LogOfHRGrainBytes); // ((store address ^ new value) >> LogOfHRGrainBytes) == 0? + __ jccb(Assembler::equal, L_done); + } // Crosses regions, storing null? if (new_val_may_be_null) { diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp index 09c5d93dbb3..215dc30f7fd 100644 --- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -395,6 +395,11 @@ OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Na extern void vec_spill_helper(C2_MacroAssembler *masm, bool is_load, int stack_offset, int reg, uint ireg, outputStream* st); +void BarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slowpath) { + // Load the oop from the weak handle. + __ movptr(obj, Address(obj)); +} + #undef __ #define __ _masm-> diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp index c5bf17c3b4e..6aff29850e3 100644 --- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -109,6 +109,8 @@ public: #ifdef COMPILER2 OptoReg::Name refine_register(const Node* node, OptoReg::Name opto_reg); + + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slowpath); #endif // COMPILER2 }; diff --git a/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp index 65e6b4e01fc..0ea769dd488 100644 --- a/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp @@ -23,6 +23,7 @@ */ #include "asm/macroAssembler.inline.hpp" +#include "code/aotCodeCache.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" @@ -111,7 +112,15 @@ void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembl __ shrptr(end, CardTable::card_shift()); __ subptr(end, addr); // end --> cards count - __ mov64(tmp, (intptr_t)ctbs->card_table_base_const()); +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + __ lea(tmp, ExternalAddress(AOTRuntimeConstants::card_table_base_address())); + __ movq(tmp, Address(tmp, 0)); + } else +#endif + { + __ mov64(tmp, (intptr_t)ctbs->card_table_base_const()); + } __ addptr(addr, tmp); __ BIND(L_loop); __ movb(Address(addr, count, Address::times_1), 0); @@ -121,7 +130,7 @@ __ BIND(L_loop); __ BIND(L_done); } -void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) { +void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst, Register rscratch) { // Does a store check for the oop in register obj. The content of // register obj is destroyed afterwards. CardTableBarrierSet* ctbs = CardTableBarrierSet::barrier_set(); @@ -136,6 +145,13 @@ void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register ob // never need to be relocated. On 64bit however the value may be too // large for a 32bit displacement. intptr_t byte_map_base = (intptr_t)ctbs->card_table_base_const(); +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + __ lea(rscratch, ExternalAddress(AOTRuntimeConstants::card_table_base_address())); + __ movq(rscratch, Address(rscratch, 0)); + card_addr = Address(rscratch, obj, Address::times_1, 0); + } else +#endif if (__ is_simm32(byte_map_base)) { card_addr = Address(noreg, obj, Address::times_1, byte_map_base); } else { @@ -174,10 +190,10 @@ void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorS if (needs_post_barrier) { // flatten object address if needed if (!precise || (dst.index() == noreg && dst.disp() == 0)) { - store_check(masm, dst.base(), dst); + store_check(masm, dst.base(), dst, tmp2); } else { __ lea(tmp1, dst); - store_check(masm, tmp1, dst); + store_check(masm, tmp1, dst, tmp2); } } } diff --git a/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.hpp index 0a36571c757..201c11062f2 100644 --- a/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.hpp @@ -33,7 +33,7 @@ protected: virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count) {} - void store_check(MacroAssembler* masm, Register obj, Address dst); + void store_check(MacroAssembler* masm, Register obj, Address dst, Register rscratch); virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, Register tmp); diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp index 97829a10a3b..67510fac58f 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -618,6 +619,27 @@ void ShenandoahBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler __ bind(done); } +#ifdef COMPILER2 +void ShenandoahBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slowpath) { + Label done; + + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, slowpath); + + // Check if the reference is null, and if it is, take the fast path. + __ testptr(obj, obj); + __ jcc(Assembler::zero, done); + + Address gc_state(r15_thread, ShenandoahThreadLocalData::gc_state_offset()); + + // Check if the heap is under weak-reference/roots processing, in + // which case we need to take the slow path. + __ testb(gc_state, ShenandoahHeap::WEAK_ROOTS); + __ jcc(Assembler::notZero, slowpath); + __ bind(done); +} +#endif // COMPILER2 + // Special Shenandoah CAS implementation that handles false negatives // due to concurrent evacuation. void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm, diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp index b5cc5c8d834..79540aa19e1 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -77,6 +78,9 @@ public: Address dst, Register val, Register tmp1, Register tmp2, Register tmp3); virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); +#ifdef COMPILER2 + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slowpath); +#endif // COMPILER2 }; #endif // CPU_X86_GC_SHENANDOAH_SHENANDOAHBARRIERSETASSEMBLER_X86_HPP diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp index ae93cca8c19..47a3dad54e7 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -1328,6 +1328,19 @@ void ZBarrierSetAssembler::generate_c2_store_barrier_stub(MacroAssembler* masm, __ jmp(slow_continuation); } +void ZBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slow_path) { + // Resolve weak handle using the standard implementation. + BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, slow_path); + + // Check if the oop is bad, in which case we need to take the slow path. + __ testptr(obj, Address(r15_thread, ZThreadLocalData::mark_bad_mask_offset())); + __ jcc(Assembler::notZero, slow_path); + + // Oop is okay, so we uncolor it. + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); + __ shrq(obj, barrier_Relocation::unpatched); +} + #undef __ #endif // COMPILER2 diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp index 19902500f93..e91e2b9ea20 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -167,6 +167,8 @@ public: ZLoadBarrierStubC2* stub) const; void generate_c2_store_barrier_stub(MacroAssembler* masm, ZStoreBarrierStubC2* stub) const; + + virtual void try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Label& slow_path); #endif // COMPILER2 void store_barrier_fast(MacroAssembler* masm, diff --git a/src/hotspot/cpu/x86/globals_x86.hpp b/src/hotspot/cpu/x86/globals_x86.hpp index 4f5b6d31e75..6de46752790 100644 --- a/src/hotspot/cpu/x86/globals_x86.hpp +++ b/src/hotspot/cpu/x86/globals_x86.hpp @@ -117,9 +117,6 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); product(bool, UseIncDec, true, DIAGNOSTIC, \ "Use INC, DEC instructions on x86") \ \ - product(bool, UseNewLongLShift, false, \ - "Use optimized bitwise shift left") \ - \ product(bool, UseAddressNop, false, \ "Use '0F 1F [addr]' NOP instructions on x86 cpus") \ \ @@ -168,16 +165,27 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); "Perform Ecore Optimization") \ \ /* Minimum array size in bytes to use AVX512 intrinsics */ \ - /* for copy, inflate and fill which don't bail out early based on any */ \ + /* for inflate and fill which don't bail out early based on any */ \ /* condition. When this value is set to zero compare operations like */ \ /* compare, vectorizedMismatch, compress can also use AVX512 intrinsics.*/\ product(int, AVX3Threshold, 4096, DIAGNOSTIC, \ "Minimum array size in bytes to use AVX512 intrinsics" \ - "for copy, inflate and fill. When this value is set as zero" \ + "for inflate and fill. When this value is set as zero" \ "compare operations can also use AVX512 intrinsics.") \ range(0, max_jint) \ constraint(AVX3ThresholdConstraintFunc,AfterErgo) \ \ + /* Minimum array size in bytes to use AVX512 intrinsics */ \ + /* for copy and fill which don't bail out early based on any */ \ + /* condition. When this value is set to zero clear operations that */ \ + /* work on memory blocks can also use AVX512 intrinsics. */ \ + product(int, CopyAVX3Threshold, 4096, DIAGNOSTIC, \ + "Minimum array size in bytes to use AVX512 intrinsics" \ + "for copy and fill. When this value is set as zero" \ + "clear operations can also use AVX512 intrinsics.") \ + range(0, max_jint) \ + constraint(CopyAVX3ThresholdConstraintFunc,AfterErgo) \ + \ product(bool, IntelJccErratumMitigation, true, DIAGNOSTIC, \ "Turn off JVM mitigations related to Intel micro code " \ "mitigations for the Intel JCC erratum") \ diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp index b2ea4143ac4..a38971c86fb 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -1392,28 +1392,15 @@ void InterpreterMacroAssembler::profile_final_call(Register mdp) { void InterpreterMacroAssembler::profile_virtual_call(Register receiver, - Register mdp, - bool receiver_can_be_null) { + Register mdp) { if (ProfileInterpreter) { Label profile_continue; // If no method data exists, go to profile_continue. test_method_data_pointer(mdp, profile_continue); - Label skip_receiver_profile; - if (receiver_can_be_null) { - Label not_null; - testptr(receiver, receiver); - jccb(Assembler::notZero, not_null); - // We are making a call. Increment the count for null receiver. - increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); - jmp(skip_receiver_profile); - bind(not_null); - } - // Record the receiver type. profile_receiver_type(receiver, mdp, 0); - bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); diff --git a/src/hotspot/cpu/x86/interp_masm_x86.hpp b/src/hotspot/cpu/x86/interp_masm_x86.hpp index 4114028f78e..dfbd7ab64e0 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.hpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -243,8 +243,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_not_taken_branch(Register mdp); void profile_call(Register mdp); void profile_final_call(Register mdp); - void profile_virtual_call(Register receiver, Register mdp, - bool receiver_can_be_null = false); + void profile_virtual_call(Register receiver, Register mdp); void profile_ret(Register return_bci, Register mdp); void profile_null_seen(Register mdp); void profile_typecheck(Register mdp, Register klass); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 83169df3456..a0f08145d55 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -961,7 +961,7 @@ void MacroAssembler::call(AddressLiteral entry, Register rscratch) { void MacroAssembler::ic_call(address entry, jint method_index) { RelocationHolder rh = virtual_call_Relocation::spec(pc(), method_index); // Needs full 64-bit immediate for later patching. - mov64(rax, (int64_t)Universe::non_oop_word()); + Assembler::mov64(rax, (int64_t)Universe::non_oop_word()); call(AddressLiteral(entry, rh)); } @@ -985,12 +985,9 @@ int MacroAssembler::ic_check(int end_alignment) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(temp, receiver); cmpl(temp, Address(data, CompiledICData::speculated_klass_offset())); - } else if (UseCompressedClassPointers) { + } else { movl(temp, Address(receiver, oopDesc::klass_offset_in_bytes())); cmpl(temp, Address(data, CompiledICData::speculated_klass_offset())); - } else { - movptr(temp, Address(receiver, oopDesc::klass_offset_in_bytes())); - cmpptr(temp, Address(data, CompiledICData::speculated_klass_offset())); } // if inline cache check fails, then jump to runtime routine @@ -1961,6 +1958,20 @@ void MacroAssembler::movflt(XMMRegister dst, AddressLiteral src, Register rscrat } } +void MacroAssembler::mov64(Register dst, int64_t imm64) { + if (is_uimm32(imm64)) { + movl(dst, checked_cast(imm64)); + } else if (is_simm32(imm64)) { + movq(dst, checked_cast(imm64)); + } else { + Assembler::mov64(dst, imm64); + } +} + +void MacroAssembler::mov64(Register dst, int64_t imm64, relocInfo::relocType rtype, int format) { + Assembler::mov64(dst, imm64, rtype, format); +} + void MacroAssembler::movptr(Register dst, Register src) { movq(dst, src); } @@ -1971,13 +1982,7 @@ void MacroAssembler::movptr(Register dst, Address src) { // src should NEVER be a real pointer. Use AddressLiteral for true pointers void MacroAssembler::movptr(Register dst, intptr_t src) { - if (is_uimm32(src)) { - movl(dst, checked_cast(src)); - } else if (is_simm32(src)) { - movq(dst, checked_cast(src)); - } else { - mov64(dst, src); - } + mov64(dst, src); } void MacroAssembler::movptr(Address dst, Register src) { @@ -5376,11 +5381,9 @@ void MacroAssembler::load_klass(Register dst, Register src, Register tmp) { if (UseCompactObjectHeaders) { load_narrow_klass_compact(dst, src); decode_klass_not_null(dst, tmp); - } else if (UseCompressedClassPointers) { + } else { movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); decode_klass_not_null(dst, tmp); - } else { - movptr(dst, Address(src, oopDesc::klass_offset_in_bytes())); } } @@ -5388,12 +5391,8 @@ void MacroAssembler::store_klass(Register dst, Register src, Register tmp) { assert(!UseCompactObjectHeaders, "not with compact headers"); assert_different_registers(src, tmp); assert_different_registers(dst, tmp); - if (UseCompressedClassPointers) { - encode_klass_not_null(src, tmp); - movl(Address(dst, oopDesc::klass_offset_in_bytes()), src); - } else { - movptr(Address(dst, oopDesc::klass_offset_in_bytes()), src); - } + encode_klass_not_null(src, tmp); + movl(Address(dst, oopDesc::klass_offset_in_bytes()), src); } void MacroAssembler::cmp_klass(Register klass, Register obj, Register tmp) { @@ -5402,10 +5401,8 @@ void MacroAssembler::cmp_klass(Register klass, Register obj, Register tmp) { assert_different_registers(klass, obj, tmp); load_narrow_klass_compact(tmp, obj); cmpl(klass, tmp); - } else if (UseCompressedClassPointers) { - cmpl(klass, Address(obj, oopDesc::klass_offset_in_bytes())); } else { - cmpptr(klass, Address(obj, oopDesc::klass_offset_in_bytes())); + cmpl(klass, Address(obj, oopDesc::klass_offset_in_bytes())); } } @@ -5416,12 +5413,9 @@ void MacroAssembler::cmp_klasses_from_objects(Register obj1, Register obj2, Regi load_narrow_klass_compact(tmp1, obj1); load_narrow_klass_compact(tmp2, obj2); cmpl(tmp1, tmp2); - } else if (UseCompressedClassPointers) { + } else { movl(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); cmpl(tmp1, Address(obj2, oopDesc::klass_offset_in_bytes())); - } else { - movptr(tmp1, Address(obj1, oopDesc::klass_offset_in_bytes())); - cmpptr(tmp1, Address(obj2, oopDesc::klass_offset_in_bytes())); } } @@ -5470,10 +5464,8 @@ void MacroAssembler::store_heap_oop_null(Address dst) { void MacroAssembler::store_klass_gap(Register dst, Register src) { assert(!UseCompactObjectHeaders, "Don't use with compact headers"); - if (UseCompressedClassPointers) { - // Store to klass gap in destination - movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); - } + // Store to klass gap in destination + movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); } #ifdef ASSERT @@ -5663,7 +5655,6 @@ void MacroAssembler::decode_klass_not_null(Register r, Register tmp) { BLOCK_COMMENT("decode_klass_not_null {"); assert_different_registers(r, tmp); // Note: it will change flags - assert(UseCompressedClassPointers, "should only be used for compressed headers"); // Cannot assert, unverified entry point counts instructions (see .ad file) // vtableStubs also counts instructions in pd_code_size_limit. // Also do not verify_oop as this is called by verify_oop. @@ -5685,7 +5676,6 @@ void MacroAssembler::decode_and_move_klass_not_null(Register dst, Register src) BLOCK_COMMENT("decode_and_move_klass_not_null {"); assert_different_registers(src, dst); // Note: it will change flags - assert (UseCompressedClassPointers, "should only be used for compressed headers"); // Cannot assert, unverified entry point counts instructions (see .ad file) // vtableStubs also counts instructions in pd_code_size_limit. // Also do not verify_oop as this is called by verify_oop. @@ -5742,7 +5732,6 @@ void MacroAssembler::set_narrow_oop(Address dst, jobject obj) { } void MacroAssembler::set_narrow_klass(Register dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int klass_index = oop_recorder()->find_index(k); RelocationHolder rspec = metadata_Relocation::spec(klass_index); @@ -5750,7 +5739,6 @@ void MacroAssembler::set_narrow_klass(Register dst, Klass* k) { } void MacroAssembler::set_narrow_klass(Address dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int klass_index = oop_recorder()->find_index(k); RelocationHolder rspec = metadata_Relocation::spec(klass_index); @@ -5776,7 +5764,6 @@ void MacroAssembler::cmp_narrow_oop(Address dst, jobject obj) { } void MacroAssembler::cmp_narrow_klass(Register dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int klass_index = oop_recorder()->find_index(k); RelocationHolder rspec = metadata_Relocation::spec(klass_index); @@ -5784,7 +5771,6 @@ void MacroAssembler::cmp_narrow_klass(Register dst, Klass* k) { } void MacroAssembler::cmp_narrow_klass(Address dst, Klass* k) { - assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert (oop_recorder() != nullptr, "this assembler needs an OopRecorder"); int klass_index = oop_recorder()->find_index(k); RelocationHolder rspec = metadata_Relocation::spec(klass_index); @@ -5812,7 +5798,7 @@ void MacroAssembler::xmm_clear_mem(Register base, Register cnt, Register rtmp, X // cnt - number of qwords (8-byte words). // base - start address, qword aligned. Label L_zero_64_bytes, L_loop, L_sloop, L_tail, L_end; - bool use64byteVector = (MaxVectorSize == 64) && (VM_Version::avx3_threshold() == 0); + bool use64byteVector = (MaxVectorSize == 64) && (CopyAVX3Threshold == 0); if (use64byteVector) { vpxor(xtmp, xtmp, xtmp, AVX_512bit); } else if (MaxVectorSize >= 32) { @@ -5876,7 +5862,7 @@ void MacroAssembler::xmm_clear_mem(Register base, Register cnt, Register rtmp, X // Clearing constant sized memory using YMM/ZMM registers. void MacroAssembler::clear_mem(Register base, int cnt, Register rtmp, XMMRegister xtmp, KRegister mask) { assert(UseAVX > 2 && VM_Version::supports_avx512vl(), ""); - bool use64byteVector = (MaxVectorSize > 32) && (VM_Version::avx3_threshold() == 0); + bool use64byteVector = (MaxVectorSize > 32) && (CopyAVX3Threshold == 0); int vector64_count = (cnt & (~0x7)) >> 3; cnt = cnt & 0x7; @@ -6101,8 +6087,8 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, // Fill 64-byte chunks Label L_fill_64_bytes_loop_avx3, L_check_fill_64_bytes_avx2; - // If number of bytes to fill < VM_Version::avx3_threshold(), perform fill using AVX2 - cmpptr(count, VM_Version::avx3_threshold()); + // If number of bytes to fill < CopyAVX3Threshold, perform fill using AVX2 + cmpptr(count, CopyAVX3Threshold); jccb(Assembler::below, L_check_fill_64_bytes_avx2); vpbroadcastd(xtmp, xtmp, Assembler::AVX_512bit); @@ -9475,7 +9461,6 @@ void MacroAssembler::generate_fill_avx3(BasicType type, Register to, Register va Label L_fill_zmm_sequence; int shift = -1; - int avx3threshold = VM_Version::avx3_threshold(); switch(type) { case T_BYTE: shift = 0; break; @@ -9491,10 +9476,10 @@ void MacroAssembler::generate_fill_avx3(BasicType type, Register to, Register va fatal("Unhandled type: %s\n", type2name(type)); } - if ((avx3threshold != 0) || (MaxVectorSize == 32)) { + if ((CopyAVX3Threshold != 0) || (MaxVectorSize == 32)) { if (MaxVectorSize == 64) { - cmpq(count, avx3threshold >> shift); + cmpq(count, CopyAVX3Threshold >> shift); jcc(Assembler::greater, L_fill_zmm_sequence); } @@ -10034,6 +10019,20 @@ void MacroAssembler::restore_legacy_gprs() { addq(rsp, 16 * wordSize); } +void MacroAssembler::load_aotrc_address(Register reg, address a) { +#if INCLUDE_CDS + assert(AOTRuntimeConstants::contains(a), "address out of range for data area"); + if (AOTCodeCache::is_on_for_dump()) { + // all aotrc field addresses should be registered in the AOTCodeCache address table + lea(reg, ExternalAddress(a)); + } else { + mov64(reg, (uint64_t)a); + } +#else + ShouldNotReachHere(); +#endif +} + void MacroAssembler::setcc(Assembler::Condition comparison, Register dst) { if (VM_Version::supports_apx_f()) { esetzucc(comparison, dst); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp index eb23199ca63..3bdd1e4477a 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -351,8 +351,7 @@ class MacroAssembler: public Assembler { void load_klass(Register dst, Register src, Register tmp); void store_klass(Register dst, Register src, Register tmp); - // Compares the Klass pointer of an object to a given Klass (which might be narrow, - // depending on UseCompressedClassPointers). + // Compares the narrow Klass pointer of an object to a given narrow Klass. void cmp_klass(Register klass, Register obj, Register tmp); // Compares the Klass pointer of two objects obj1 and obj2. Result is in the condition flags. @@ -1869,6 +1868,9 @@ public: void mov_metadata(Register dst, Metadata* obj); void mov_metadata(Address dst, Metadata* obj, Register rscratch); + void mov64(Register dst, int64_t imm64); + void mov64(Register dst, int64_t imm64, relocInfo::relocType rtype, int format); + void movptr(Register dst, Register src); void movptr(Register dst, Address src); void movptr(Register dst, AddressLiteral src); @@ -2070,6 +2072,7 @@ public: void save_legacy_gprs(); void restore_legacy_gprs(); + void load_aotrc_address(Register reg, address a); void setcc(Assembler::Condition comparison, Register dst); }; diff --git a/src/hotspot/cpu/x86/matcher_x86.hpp b/src/hotspot/cpu/x86/matcher_x86.hpp index f7973a8564e..62a5d2827bc 100644 --- a/src/hotspot/cpu/x86/matcher_x86.hpp +++ b/src/hotspot/cpu/x86/matcher_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +75,6 @@ } static bool narrow_klass_use_complex_address() { - assert(UseCompressedClassPointers, "only for compressed klass code"); return (CompressedKlassPointers::shift() <= 3); } diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp index 36315535d16..332add6dcd4 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -166,12 +166,12 @@ class StubGenerator: public StubCodeGenerator { // - If target supports AVX3 features (BW+VL+F) then implementation uses 32 byte vectors (YMMs) // for both special cases (various small block sizes) and aligned copy loop. This is the // default configuration. - // - If copy length is above AVX3Threshold, then implementation use 64 byte vectors (ZMMs) + // - If copy length is above CopyAVX3Threshold, then implementation use 64 byte vectors (ZMMs) // for main copy loop (and subsequent tail) since bulk of the cycles will be consumed in it. // - If user forces MaxVectorSize=32 then above 4096 bytes its seen that REP MOVs shows a // better performance for disjoint copies. For conjoint/backward copy vector based // copy performs better. - // - If user sets AVX3Threshold=0, then special cases for small blocks sizes operate over + // - If user sets CopyAVX3Threshold=0, then special cases for small blocks sizes operate over // 64 byte vector registers (ZMMs). address generate_disjoint_copy_avx3_masked(StubId stub_id, address* entry); @@ -330,6 +330,19 @@ class StubGenerator: public StubCodeGenerator { void aesecb_decrypt(Register source_addr, Register dest_addr, Register key, Register len); + // Shared implementation for ECB/AES Encrypt and Decrypt, which does 4 blocks + // in a loop at a time to hide instruction latency. Set is_encrypt=true for + // encryption, false for decryption. + address generate_electronicCodeBook_AESCrypt_Parallel(bool is_encrypt); + + // A version of ECB/AES Encrypt which does 4 blocks in a loop at a time + // to hide instruction latency + address generate_electronicCodeBook_encryptAESCrypt_Parallel(); + + // A version of ECB/AES Decrypt which does 4 blocks in a loop at a time + // to hide instruction latency + address generate_electronicCodeBook_decryptAESCrypt_Parallel(); + // Vector AES Galois Counter Mode implementation address generate_galoisCounterMode_AESCrypt(); void aesgcm_encrypt(Register in, Register len, Register ct, Register out, Register key, diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_adler.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_adler.cpp index 2799997a761..1d3e7afde1d 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_adler.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_adler.cpp @@ -144,7 +144,7 @@ address StubGenerator::generate_updateBytesAdler32() { __ align32(); if (VM_Version::supports_avx512vl()) { // AVX2 performs better for smaller inputs because of leaner post loop reduction sequence.. - __ cmpl(s, MAX2(128, VM_Version::avx3_threshold())); + __ cmpl(s, MAX2(128, CopyAVX3Threshold)); __ jcc(Assembler::belowEqual, SLOOP1A_AVX2); __ lea(end, Address(s, data, Address::times_1, - (2*CHUNKSIZE -1))); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp index 24de32a6fe7..1fa80c9d967 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, 2025, Intel Corporation. All rights reserved. +* Copyright (c) 2019, 2026, Intel Corporation. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -218,6 +218,8 @@ void StubGenerator::generate_aes_stubs() { StubRoutines::_galoisCounterMode_AESCrypt = generate_galoisCounterMode_AESCrypt(); } else { StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel(); + StubRoutines::_electronicCodeBook_encryptAESCrypt = generate_electronicCodeBook_encryptAESCrypt_Parallel(); + StubRoutines::_electronicCodeBook_decryptAESCrypt = generate_electronicCodeBook_decryptAESCrypt_Parallel(); if (VM_Version::supports_avx2()) { StubRoutines::_galoisCounterMode_AESCrypt = generate_avx2_galoisCounterMode_AESCrypt(); } @@ -1399,6 +1401,200 @@ address StubGenerator::generate_cipherBlockChaining_encryptAESCrypt() { return start; } +// This is a version of ECB/AES Encrypt/Decrypt which does 4 blocks in a loop +// at a time to hide instruction latency. +// +// For encryption (is_encrypt=true): +// pxor key[0], aesenc key[1..rounds-1], aesenclast key[rounds] +// For decryption (is_encrypt=false): +// pxor key[1], aesdec key[2..rounds], aesdeclast key[0] +// +// Arguments: +// +// Inputs: +// c_rarg0 - source byte array address +// c_rarg1 - destination byte array address +// c_rarg2 - session key (Ke/Kd) in little endian int array +// c_rarg3 - input length (must be multiple of blocksize 16) +// +// Output: +// rax - input length +// +address StubGenerator::generate_electronicCodeBook_AESCrypt_Parallel(bool is_encrypt) { + assert(UseAES, "need AES instructions and misaligned SSE support"); + __ align(CodeEntryAlignment); + StubId stub_id = is_encrypt ? StubId::stubgen_electronicCodeBook_encryptAESCrypt_id + : StubId::stubgen_electronicCodeBook_decryptAESCrypt_id; + StubCodeMark mark(this, stub_id); + address start = __ pc(); + + const Register from = c_rarg0; // source array address + const Register to = c_rarg1; // destination array address + const Register key = c_rarg2; // key array address + const Register len_reg = c_rarg3; // src len (must be multiple of blocksize 16) + const Register pos = rax; + const Register keylen = r11; + + const XMMRegister xmm_result0 = xmm0; + const XMMRegister xmm_result1 = xmm1; + const XMMRegister xmm_result2 = xmm2; + const XMMRegister xmm_result3 = xmm3; + const XMMRegister xmm_key_shuf_mask = xmm4; + const XMMRegister xmm_key_tmp = xmm5; + // keys 0-9 pre-loaded into xmm6-xmm15 + const int XMM_REG_NUM_KEY_FIRST = 6; + const int XMM_REG_NUM_KEY_LAST = 15; + const XMMRegister xmm_key_first = as_XMMRegister(XMM_REG_NUM_KEY_FIRST); + + // for key_128, key_192, key_256 + const int ROUNDS[3] = {10, 12, 14}; + + Label L_exit; + Label L_loop4[3], L_single[3], L_done[3]; + +#ifdef DoFour +#undef DoFour +#endif +#ifdef DoOne +#undef DoOne +#endif + +#define DoFour(opc, reg) \ +__ opc(xmm_result0, reg); \ +__ opc(xmm_result1, reg); \ +__ opc(xmm_result2, reg); \ +__ opc(xmm_result3, reg); + +#define DoOne(opc, reg) \ +__ opc(xmm_result0, reg); + + __ enter(); // required for proper stackwalking of RuntimeStub frame + __ push(len_reg); // save original length for return value + + __ movl(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); + + __ movdqu(xmm_key_shuf_mask, ExternalAddress(key_shuffle_mask_addr()), r10 /*rscratch*/); + // load up xmm regs 6 thru 15 with keys 0x00 - 0x90 + for (int rnum = XMM_REG_NUM_KEY_FIRST, offset = 0x00; rnum <= XMM_REG_NUM_KEY_LAST; rnum++, offset += 0x10) { + load_key(as_XMMRegister(rnum), key, offset, xmm_key_shuf_mask); + } + __ xorptr(pos, pos); + + // key length could be only {11, 13, 15} * 4 = {44, 52, 60} + __ cmpl(keylen, 52); + __ jcc(Assembler::equal, L_loop4[1]); + __ cmpl(keylen, 60); + __ jcc(Assembler::equal, L_loop4[2]); + + // k == 0: generate code for key_128 + // k == 1: generate code for key_192 + // k == 2: generate code for key_256 + for (int k = 0; k < 3; ++k) { + __ align(OptoLoopAlignment); + __ BIND(L_loop4[k]); + __ cmpptr(len_reg, 4 * AESBlockSize); + __ jcc(Assembler::less, L_single[k]); + + __ movdqu(xmm_result0, Address(from, pos, Address::times_1, 0 * AESBlockSize)); + __ movdqu(xmm_result1, Address(from, pos, Address::times_1, 1 * AESBlockSize)); + __ movdqu(xmm_result2, Address(from, pos, Address::times_1, 2 * AESBlockSize)); + __ movdqu(xmm_result3, Address(from, pos, Address::times_1, 3 * AESBlockSize)); + + if (is_encrypt) { + DoFour(pxor, xmm_key_first); + for (int rnum = 1; rnum < 10; rnum++) { + DoFour(aesenc, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST)); + } + for (int i = 10; i < ROUNDS[k]; i++) { + load_key(xmm_key_tmp, key, i * 0x10, xmm_key_shuf_mask); + DoFour(aesenc, xmm_key_tmp); + } + load_key(xmm_key_tmp, key, ROUNDS[k] * 0x10, xmm_key_shuf_mask); + DoFour(aesenclast, xmm_key_tmp); + } else { + DoFour(pxor, as_XMMRegister(1 + XMM_REG_NUM_KEY_FIRST)); + for (int rnum = 2; rnum < 10; rnum++) { + DoFour(aesdec, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST)); + } + for (int i = 10; i <= ROUNDS[k]; i++) { + load_key(xmm_key_tmp, key, i * 0x10, xmm_key_shuf_mask); + DoFour(aesdec, xmm_key_tmp); + } + DoFour(aesdeclast, xmm_key_first); + } + + __ movdqu(Address(to, pos, Address::times_1, 0 * AESBlockSize), xmm_result0); + __ movdqu(Address(to, pos, Address::times_1, 1 * AESBlockSize), xmm_result1); + __ movdqu(Address(to, pos, Address::times_1, 2 * AESBlockSize), xmm_result2); + __ movdqu(Address(to, pos, Address::times_1, 3 * AESBlockSize), xmm_result3); + + __ addptr(pos, 4 * AESBlockSize); + __ subptr(len_reg, 4 * AESBlockSize); + __ jmp(L_loop4[k]); + + __ align(OptoLoopAlignment); + __ BIND(L_single[k]); + __ cmpptr(len_reg, AESBlockSize); + __ jcc(Assembler::less, L_done[k]); + + __ movdqu(xmm_result0, Address(from, pos, Address::times_1, 0)); + + if (is_encrypt) { + DoOne(pxor, xmm_key_first); + for (int rnum = 1; rnum < 10; rnum++) { + DoOne(aesenc, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST)); + } + for (int i = 10; i < ROUNDS[k]; i++) { + load_key(xmm_key_tmp, key, i * 0x10, xmm_key_shuf_mask); + DoOne(aesenc, xmm_key_tmp); + } + load_key(xmm_key_tmp, key, ROUNDS[k] * 0x10, xmm_key_shuf_mask); + DoOne(aesenclast, xmm_key_tmp); + } else { + DoOne(pxor, as_XMMRegister(1 + XMM_REG_NUM_KEY_FIRST)); + for (int rnum = 2; rnum < 10; rnum++) { + DoOne(aesdec, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST)); + } + for (int i = 10; i <= ROUNDS[k]; i++) { + load_key(xmm_key_tmp, key, i * 0x10, xmm_key_shuf_mask); + DoOne(aesdec, xmm_key_tmp); + } + DoOne(aesdeclast, xmm_key_first); + } + + __ movdqu(Address(to, pos, Address::times_1, 0), xmm_result0); + __ addptr(pos, AESBlockSize); + __ subptr(len_reg, AESBlockSize); + __ jmp(L_single[k]); + + __ BIND(L_done[k]); + if (k < 2) __ jmp(L_exit); + } //for key_128/192/256 + + __ BIND(L_exit); + // Clear all XMM registers holding sensitive key material before returning + __ pxor(xmm_key_tmp, xmm_key_tmp); + for (int rnum = XMM_REG_NUM_KEY_FIRST; rnum <= XMM_REG_NUM_KEY_LAST; rnum++) { + __ pxor(as_XMMRegister(rnum), as_XMMRegister(rnum)); + } + __ pop(rax); + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; + +#undef DoFour +#undef DoOne +} + +address StubGenerator::generate_electronicCodeBook_encryptAESCrypt_Parallel() { + return generate_electronicCodeBook_AESCrypt_Parallel(true); +} + +address StubGenerator::generate_electronicCodeBook_decryptAESCrypt_Parallel() { + return generate_electronicCodeBook_AESCrypt_Parallel(false); +} + // This is a version of CBC/AES Decrypt which does 4 blocks in a loop at a time // to hide instruction latency // @@ -1493,7 +1689,7 @@ address StubGenerator::generate_cipherBlockChaining_decryptAESCrypt_Parallel() { __ opc(xmm_result0, src_reg); \ __ opc(xmm_result1, src_reg); \ __ opc(xmm_result2, src_reg); \ -__ opc(xmm_result3, src_reg); \ +__ opc(xmm_result3, src_reg); for (int k = 0; k < 3; ++k) { __ BIND(L_multiBlock_loopTopHead[k]); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp index d53fafafdb4..01e004b7b43 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp @@ -511,12 +511,12 @@ void StubGenerator::copy_bytes_backward(Register from, Register dest, // - If target supports AVX3 features (BW+VL+F) then implementation uses 32 byte vectors (YMMs) // for both special cases (various small block sizes) and aligned copy loop. This is the // default configuration. -// - If copy length is above AVX3Threshold, then implementation use 64 byte vectors (ZMMs) +// - If copy length is above CopyAVX3Threshold, then implementation use 64 byte vectors (ZMMs) // for main copy loop (and subsequent tail) since bulk of the cycles will be consumed in it. // - If user forces MaxVectorSize=32 then above 4096 bytes its seen that REP MOVs shows a // better performance for disjoint copies. For conjoint/backward copy vector based // copy performs better. -// - If user sets AVX3Threshold=0, then special cases for small blocks sizes operate over +// - If user sets CopyAVX3Threshold=0, then special cases for small blocks sizes operate over // 64 byte vector registers (ZMMs). // Inputs: @@ -575,8 +575,7 @@ address StubGenerator::generate_disjoint_copy_avx3_masked(StubId stub_id, addres StubCodeMark mark(this, stub_id); address start = __ pc(); - int avx3threshold = VM_Version::avx3_threshold(); - bool use64byteVector = (MaxVectorSize > 32) && (avx3threshold == 0); + bool use64byteVector = (MaxVectorSize > 32) && (CopyAVX3Threshold == 0); const int large_threshold = 2621440; // 2.5 MB Label L_main_loop, L_main_loop_64bytes, L_tail, L_tail64, L_exit, L_entry; Label L_repmovs, L_main_pre_loop, L_main_pre_loop_64bytes, L_pre_main_post_64; @@ -647,7 +646,7 @@ address StubGenerator::generate_disjoint_copy_avx3_masked(StubId stub_id, addres __ cmpq(temp2, large_threshold); __ jcc(Assembler::greaterEqual, L_copy_large); } - if (avx3threshold != 0) { + if (CopyAVX3Threshold != 0) { __ cmpq(count, threshold[shift]); if (MaxVectorSize == 64) { // Copy using 64 byte vectors. @@ -659,7 +658,7 @@ address StubGenerator::generate_disjoint_copy_avx3_masked(StubId stub_id, addres } } - if ((MaxVectorSize < 64) || (avx3threshold != 0)) { + if ((MaxVectorSize < 64) || (CopyAVX3Threshold != 0)) { // Partial copy to make dst address 32 byte aligned. __ movq(temp2, to); __ andq(temp2, 31); @@ -913,8 +912,7 @@ address StubGenerator::generate_conjoint_copy_avx3_masked(StubId stub_id, addres StubCodeMark mark(this, stub_id); address start = __ pc(); - int avx3threshold = VM_Version::avx3_threshold(); - bool use64byteVector = (MaxVectorSize > 32) && (avx3threshold == 0); + bool use64byteVector = (MaxVectorSize > 32) && (CopyAVX3Threshold == 0); Label L_main_pre_loop, L_main_pre_loop_64bytes, L_pre_main_post_64; Label L_main_loop, L_main_loop_64bytes, L_tail, L_tail64, L_exit, L_entry; @@ -979,12 +977,12 @@ address StubGenerator::generate_conjoint_copy_avx3_masked(StubId stub_id, addres // PRE-MAIN-POST loop for aligned copy. __ BIND(L_entry); - if ((MaxVectorSize > 32) && (avx3threshold != 0)) { + if ((MaxVectorSize > 32) && (CopyAVX3Threshold != 0)) { __ cmpq(temp1, threshold[shift]); __ jcc(Assembler::greaterEqual, L_pre_main_post_64); } - if ((MaxVectorSize < 64) || (avx3threshold != 0)) { + if ((MaxVectorSize < 64) || (CopyAVX3Threshold != 0)) { // Partial copy to make dst address 32 byte aligned. __ leaq(temp2, Address(to, temp1, (Address::ScaleFactor)(shift), 0)); __ andq(temp2, 31); @@ -1199,7 +1197,7 @@ void StubGenerator::arraycopy_avx3_special_cases_conjoint(XMMRegister xmm, KRegi bool use64byteVector, Label& L_entry, Label& L_exit) { Label L_entry_64, L_entry_96, L_entry_128; Label L_entry_160, L_entry_192; - bool avx3 = (MaxVectorSize > 32) && (VM_Version::avx3_threshold() == 0); + bool avx3 = (MaxVectorSize > 32) && (CopyAVX3Threshold == 0); int size_mat[][6] = { /* T_BYTE */ {32 , 64, 96 , 128 , 160 , 192 }, diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index ef62a29c834..4301bd328d6 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -48,7 +48,7 @@ int VM_Version::_stepping; bool VM_Version::_has_intel_jcc_erratum; VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; -#define DECLARE_CPU_FEATURE_NAME(id, name, bit) name, +#define DECLARE_CPU_FEATURE_NAME(id, name, bit) XSTR(name), const char* VM_Version::_features_names[] = { CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_NAME)}; #undef DECLARE_CPU_FEATURE_NAME @@ -958,9 +958,17 @@ void VM_Version::get_processor_features() { if (UseSSE < 1) _features.clear_feature(CPU_SSE); - //since AVX instructions is slower than SSE in some ZX cpus, force USEAVX=0. - if (is_zx() && ((cpu_family() == 6) || (cpu_family() == 7))) { - UseAVX = 0; + // ZX cpus specific settings + if (is_zx() && FLAG_IS_DEFAULT(UseAVX)) { + if (cpu_family() == 7) { + if (extended_cpu_model() == 0x5B || extended_cpu_model() == 0x6B) { + UseAVX = 1; + } else if (extended_cpu_model() == 0x1B || extended_cpu_model() == 0x3B) { + UseAVX = 0; + } + } else if (cpu_family() == 6) { + UseAVX = 0; + } } // UseSSE is set to the smaller of what hardware supports and what @@ -1500,9 +1508,6 @@ void VM_Version::get_processor_features() { MaxLoopPad = 11; } #endif // COMPILER2 - if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { - UseXMMForArrayCopy = true; // use SSE2 movq on new ZX cpus - } if (supports_sse4_2()) { // new ZX cpus if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { UseUnalignedLoadStores = true; // use movdqu on newest ZX cpus @@ -1520,10 +1525,6 @@ void VM_Version::get_processor_features() { // Use it on new AMD cpus starting from Opteron. UseAddressNop = true; } - if (supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift)) { - // Use it on new AMD cpus starting from Opteron. - UseNewLongLShift = true; - } if (FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper)) { if (supports_sse4a()) { UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron @@ -1563,10 +1564,6 @@ void VM_Version::get_processor_features() { if (FLAG_IS_DEFAULT(AllocatePrefetchInstr)) { FLAG_SET_DEFAULT(AllocatePrefetchInstr, 3); } - // On family 15h processors use XMM and UnalignedLoadStores for Array Copy - if (supports_sse2() && FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { - FLAG_SET_DEFAULT(UseXMMForArrayCopy, true); - } if (supports_sse2() && FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { FLAG_SET_DEFAULT(UseUnalignedLoadStores, true); } @@ -1583,9 +1580,6 @@ void VM_Version::get_processor_features() { if (cpu_family() >= 0x17) { // On family >=17h processors use XMM and UnalignedLoadStores // for Array Copy - if (supports_sse2() && FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { - FLAG_SET_DEFAULT(UseXMMForArrayCopy, true); - } if (supports_sse2() && FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { FLAG_SET_DEFAULT(UseUnalignedLoadStores, true); } @@ -1632,9 +1626,6 @@ void VM_Version::get_processor_features() { } #endif // COMPILER2 - if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) { - UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus - } if ((supports_sse4_2() && supports_ht()) || supports_avx()) { // Newest Intel cpus if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus @@ -1959,6 +1950,18 @@ void VM_Version::get_processor_features() { if (FLAG_IS_DEFAULT(UseCopySignIntrinsic)) { FLAG_SET_DEFAULT(UseCopySignIntrinsic, true); } + // CopyAVX3Threshold is the threshold at which 64-byte instructions are used + // for implementing the array copy and clear operations. + // The Intel platforms that supports the serialize instruction + // have improved implementation of 64-byte load/stores and so the default + // threshold is set to 0 for these platforms. + if (FLAG_IS_DEFAULT(CopyAVX3Threshold)) { + if (is_intel() && is_intel_server_family() && supports_serialize()) { + FLAG_SET_DEFAULT(CopyAVX3Threshold, 0); + } else { + FLAG_SET_DEFAULT(CopyAVX3Threshold, AVX3Threshold); + } + } } void VM_Version::print_platform_virtualization_info(outputStream* st) { @@ -2114,17 +2117,6 @@ bool VM_Version::is_intel_darkmont() { return is_intel() && is_intel_server_family() && (_model == 0xCC || _model == 0xDD); } -// avx3_threshold() sets the threshold at which 64-byte instructions are used -// for implementing the array copy and clear operations. -// The Intel platforms that supports the serialize instruction -// has improved implementation of 64-byte load/stores and so the default -// threshold is set to 0 for these platforms. -int VM_Version::avx3_threshold() { - return (is_intel_server_family() && - supports_serialize() && - FLAG_IS_DEFAULT(AVX3Threshold)) ? 0 : AVX3Threshold; -} - void VM_Version::clear_apx_test_state() { clear_apx_test_state_stub(); } @@ -2623,6 +2615,23 @@ const char* VM_Version::cpu_family_description(void) { return _family_id_intel[cpu_family_id]; } } + if (is_zx()) { + int cpu_model_id = extended_cpu_model(); + if (cpu_family_id == 7) { + switch (cpu_model_id) { + case 0x1B: + return "wudaokou"; + case 0x3B: + return "lujiazui"; + case 0x5B: + return "yongfeng"; + case 0x6B: + return "shijidadao"; + } + } else if (cpu_family_id == 6) { + return "zhangjiang"; + } + } if (is_hygon()) { return "Dhyana"; } @@ -2642,6 +2651,9 @@ int VM_Version::cpu_type_description(char* const buf, size_t buf_len) { } else if (is_amd()) { cpu_type = "AMD"; x64 = cpu_is_em64t() ? " AMD64" : ""; + } else if (is_zx()) { + cpu_type = "Zhaoxin"; + x64 = cpu_is_em64t() ? " x86_64" : ""; } else if (is_hygon()) { cpu_type = "Hygon"; x64 = cpu_is_em64t() ? " AMD64" : ""; @@ -3259,6 +3271,12 @@ int VM_Version::allocate_prefetch_distance(bool use_watermark_prefetch) { } else { return 128; // Athlon } + } else if (is_zx()) { + if (supports_sse2()) { + return 256; + } else { + return 128; + } } else { // Intel if (supports_sse3() && is_intel_server_family()) { if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus @@ -3297,12 +3315,50 @@ bool VM_Version::is_intrinsic_supported(vmIntrinsicID id) { void VM_Version::insert_features_names(VM_Version::VM_Features features, stringStream& ss) { int i = 0; ss.join([&]() { - while (i < MAX_CPU_FEATURES) { - if (_features.supports_feature((VM_Version::Feature_Flag)i)) { - return _features_names[i++]; + const char* str = nullptr; + while ((i < MAX_CPU_FEATURES) && (str == nullptr)) { + if (features.supports_feature((VM_Version::Feature_Flag)i)) { + str = _features_names[i]; } i += 1; } - return (const char*)nullptr; + return str; }, ", "); } + +void VM_Version::get_cpu_features_name(void* features_buffer, stringStream& ss) { + VM_Features* features = (VM_Features*)features_buffer; + insert_features_names(*features, ss); +} + +void VM_Version::get_missing_features_name(void* features_set1, void* features_set2, stringStream& ss) { + VM_Features* vm_features_set1 = (VM_Features*)features_set1; + VM_Features* vm_features_set2 = (VM_Features*)features_set2; + int i = 0; + ss.join([&]() { + const char* str = nullptr; + while ((i < MAX_CPU_FEATURES) && (str == nullptr)) { + Feature_Flag flag = (Feature_Flag)i; + if (vm_features_set1->supports_feature(flag) && !vm_features_set2->supports_feature(flag)) { + str = _features_names[i]; + } + i += 1; + } + return str; + }, ", "); +} + +int VM_Version::cpu_features_size() { + return sizeof(VM_Features); +} + +void VM_Version::store_cpu_features(void* buf) { + VM_Features copy = _features; + copy.clear_feature(CPU_HT); // HT does not result in incompatibility of aot code cache + memcpy(buf, ©, sizeof(VM_Features)); +} + +bool VM_Version::supports_features(void* features_buffer) { + VM_Features* features_to_test = (VM_Features*)features_buffer; + return _features.supports_features(features_to_test); +} diff --git a/src/hotspot/cpu/x86/vm_version_x86.hpp b/src/hotspot/cpu/x86/vm_version_x86.hpp index a3f2a801198..a42558a8023 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.hpp +++ b/src/hotspot/cpu/x86/vm_version_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -377,84 +377,84 @@ protected: */ enum Feature_Flag { #define CPU_FEATURE_FLAGS(decl) \ - decl(CX8, "cx8", 0) /* next bits are from cpuid 1 (EDX) */ \ - decl(CMOV, "cmov", 1) \ - decl(FXSR, "fxsr", 2) \ - decl(HT, "ht", 3) \ + decl(CX8, cx8, 0) /* next bits are from cpuid 1 (EDX) */ \ + decl(CMOV, cmov, 1) \ + decl(FXSR, fxsr, 2) \ + decl(HT, ht, 3) \ \ - decl(MMX, "mmx", 4) \ - decl(3DNOW_PREFETCH, "3dnowpref", 5) /* Processor supports 3dnow prefetch and prefetchw instructions */ \ + decl(MMX, mmx, 4) \ + decl(3DNOW_PREFETCH, 3dnowpref, 5) /* Processor supports 3dnow prefetch and prefetchw instructions */ \ /* may not necessarily support other 3dnow instructions */ \ - decl(SSE, "sse", 6) \ - decl(SSE2, "sse2", 7) \ + decl(SSE, sse, 6) \ + decl(SSE2, sse2, 7) \ \ - decl(SSE3, "sse3", 8 ) /* SSE3 comes from cpuid 1 (ECX) */ \ - decl(SSSE3, "ssse3", 9 ) \ - decl(SSE4A, "sse4a", 10) \ - decl(SSE4_1, "sse4.1", 11) \ + decl(SSE3, sse3, 8 ) /* SSE3 comes from cpuid 1 (ECX) */ \ + decl(SSSE3, ssse3, 9 ) \ + decl(SSE4A, sse4a, 10) \ + decl(SSE4_1, sse4.1, 11) \ \ - decl(SSE4_2, "sse4.2", 12) \ - decl(POPCNT, "popcnt", 13) \ - decl(LZCNT, "lzcnt", 14) \ - decl(TSC, "tsc", 15) \ + decl(SSE4_2, sse4.2, 12) \ + decl(POPCNT, popcnt, 13) \ + decl(LZCNT, lzcnt, 14) \ + decl(TSC, tsc, 15) \ \ - decl(TSCINV_BIT, "tscinvbit", 16) \ - decl(TSCINV, "tscinv", 17) \ - decl(AVX, "avx", 18) \ - decl(AVX2, "avx2", 19) \ + decl(TSCINV_BIT, tscinvbit, 16) \ + decl(TSCINV, tscinv, 17) \ + decl(AVX, avx, 18) \ + decl(AVX2, avx2, 19) \ \ - decl(AES, "aes", 20) \ - decl(ERMS, "erms", 21) /* enhanced 'rep movsb/stosb' instructions */ \ - decl(CLMUL, "clmul", 22) /* carryless multiply for CRC */ \ - decl(BMI1, "bmi1", 23) \ + decl(AES, aes, 20) \ + decl(ERMS, erms, 21) /* enhanced 'rep movsb/stosb' instructions */ \ + decl(CLMUL, clmul, 22) /* carryless multiply for CRC */ \ + decl(BMI1, bmi1, 23) \ \ - decl(BMI2, "bmi2", 24) \ - decl(RTM, "rtm", 25) /* Restricted Transactional Memory instructions */ \ - decl(ADX, "adx", 26) \ - decl(AVX512F, "avx512f", 27) /* AVX 512bit foundation instructions */ \ + decl(BMI2, bmi2, 24) \ + decl(RTM, rtm, 25) /* Restricted Transactional Memory instructions */ \ + decl(ADX, adx, 26) \ + decl(AVX512F, avx512f, 27) /* AVX 512bit foundation instructions */ \ \ - decl(AVX512DQ, "avx512dq", 28) \ - decl(AVX512PF, "avx512pf", 29) \ - decl(AVX512ER, "avx512er", 30) \ - decl(AVX512CD, "avx512cd", 31) \ + decl(AVX512DQ, avx512dq, 28) \ + decl(AVX512PF, avx512pf, 29) \ + decl(AVX512ER, avx512er, 30) \ + decl(AVX512CD, avx512cd, 31) \ \ - decl(AVX512BW, "avx512bw", 32) /* Byte and word vector instructions */ \ - decl(AVX512VL, "avx512vl", 33) /* EVEX instructions with smaller vector length */ \ - decl(SHA, "sha", 34) /* SHA instructions */ \ - decl(FMA, "fma", 35) /* FMA instructions */ \ + decl(AVX512BW, avx512bw, 32) /* Byte and word vector instructions */ \ + decl(AVX512VL, avx512vl, 33) /* EVEX instructions with smaller vector length */ \ + decl(SHA, sha, 34) /* SHA instructions */ \ + decl(FMA, fma, 35) /* FMA instructions */ \ \ - decl(VZEROUPPER, "vzeroupper", 36) /* Vzeroupper instruction */ \ - decl(AVX512_VPOPCNTDQ, "avx512_vpopcntdq", 37) /* Vector popcount */ \ - decl(AVX512_VPCLMULQDQ, "avx512_vpclmulqdq", 38) /* Vector carryless multiplication */ \ - decl(AVX512_VAES, "avx512_vaes", 39) /* Vector AES instruction */ \ + decl(VZEROUPPER, vzeroupper, 36) /* Vzeroupper instruction */ \ + decl(AVX512_VPOPCNTDQ, avx512_vpopcntdq, 37) /* Vector popcount */ \ + decl(AVX512_VPCLMULQDQ, avx512_vpclmulqdq, 38) /* Vector carryless multiplication */ \ + decl(AVX512_VAES, avx512_vaes, 39) /* Vector AES instruction */ \ \ - decl(AVX512_VNNI, "avx512_vnni", 40) /* Vector Neural Network Instructions */ \ - decl(FLUSH, "clflush", 41) /* flush instruction */ \ - decl(FLUSHOPT, "clflushopt", 42) /* flusopth instruction */ \ - decl(CLWB, "clwb", 43) /* clwb instruction */ \ + decl(AVX512_VNNI, avx512_vnni, 40) /* Vector Neural Network Instructions */ \ + decl(FLUSH, clflush, 41) /* flush instruction */ \ + decl(FLUSHOPT, clflushopt, 42) /* flusopth instruction */ \ + decl(CLWB, clwb, 43) /* clwb instruction */ \ \ - decl(AVX512_VBMI2, "avx512_vbmi2", 44) /* VBMI2 shift left double instructions */ \ - decl(AVX512_VBMI, "avx512_vbmi", 45) /* Vector BMI instructions */ \ - decl(HV, "hv", 46) /* Hypervisor instructions */ \ - decl(SERIALIZE, "serialize", 47) /* CPU SERIALIZE */ \ - decl(RDTSCP, "rdtscp", 48) /* RDTSCP instruction */ \ - decl(RDPID, "rdpid", 49) /* RDPID instruction */ \ - decl(FSRM, "fsrm", 50) /* Fast Short REP MOV */ \ - decl(GFNI, "gfni", 51) /* Vector GFNI instructions */ \ - decl(AVX512_BITALG, "avx512_bitalg", 52) /* Vector sub-word popcount and bit gather instructions */\ - decl(F16C, "f16c", 53) /* Half-precision and single precision FP conversion instructions*/ \ - decl(PKU, "pku", 54) /* Protection keys for user-mode pages */ \ - decl(OSPKE, "ospke", 55) /* OS enables protection keys */ \ - decl(CET_IBT, "cet_ibt", 56) /* Control Flow Enforcement - Indirect Branch Tracking */ \ - decl(CET_SS, "cet_ss", 57) /* Control Flow Enforcement - Shadow Stack */ \ - decl(AVX512_IFMA, "avx512_ifma", 58) /* Integer Vector FMA instructions*/ \ - decl(AVX_IFMA, "avx_ifma", 59) /* 256-bit VEX-coded variant of AVX512-IFMA*/ \ - decl(APX_F, "apx_f", 60) /* Intel Advanced Performance Extensions*/ \ - decl(SHA512, "sha512", 61) /* SHA512 instructions*/ \ - decl(AVX512_FP16, "avx512_fp16", 62) /* AVX512 FP16 ISA support*/ \ - decl(AVX10_1, "avx10_1", 63) /* AVX10 512 bit vector ISA Version 1 support*/ \ - decl(AVX10_2, "avx10_2", 64) /* AVX10 512 bit vector ISA Version 2 support*/ \ - decl(HYBRID, "hybrid", 65) /* Hybrid architecture */ + decl(AVX512_VBMI2, avx512_vbmi2, 44) /* VBMI2 shift left double instructions */ \ + decl(AVX512_VBMI, avx512_vbmi, 45) /* Vector BMI instructions */ \ + decl(HV, hv, 46) /* Hypervisor instructions */ \ + decl(SERIALIZE, serialize, 47) /* CPU SERIALIZE */ \ + decl(RDTSCP, rdtscp, 48) /* RDTSCP instruction */ \ + decl(RDPID, rdpid, 49) /* RDPID instruction */ \ + decl(FSRM, fsrm, 50) /* Fast Short REP MOV */ \ + decl(GFNI, gfni, 51) /* Vector GFNI instructions */ \ + decl(AVX512_BITALG, avx512_bitalg, 52) /* Vector sub-word popcount and bit gather instructions */\ + decl(F16C, f16c, 53) /* Half-precision and single precision FP conversion instructions*/ \ + decl(PKU, pku, 54) /* Protection keys for user-mode pages */ \ + decl(OSPKE, ospke, 55) /* OS enables protection keys */ \ + decl(CET_IBT, cet_ibt, 56) /* Control Flow Enforcement - Indirect Branch Tracking */ \ + decl(CET_SS, cet_ss, 57) /* Control Flow Enforcement - Shadow Stack */ \ + decl(AVX512_IFMA, avx512_ifma, 58) /* Integer Vector FMA instructions*/ \ + decl(AVX_IFMA, avx_ifma, 59) /* 256-bit VEX-coded variant of AVX512-IFMA*/ \ + decl(APX_F, apx_f, 60) /* Intel Advanced Performance Extensions*/ \ + decl(SHA512, sha512, 61) /* SHA512 instructions*/ \ + decl(AVX512_FP16, avx512_fp16, 62) /* AVX512 FP16 ISA support*/ \ + decl(AVX10_1, avx10_1, 63) /* AVX10 512 bit vector ISA Version 1 support*/ \ + decl(AVX10_2, avx10_2, 64) /* AVX10 512 bit vector ISA Version 2 support*/ \ + decl(HYBRID, hybrid, 65) /* Hybrid architecture */ #define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (bit), CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_FLAG) @@ -516,6 +516,15 @@ protected: int idx = index(feature); return (_features_bitmap[idx] & bit_mask(feature)) != 0; } + + bool supports_features(VM_Features* features_to_test) { + for (int i = 0; i < features_bitmap_element_count(); i++) { + if ((_features_bitmap[i] & features_to_test->_features_bitmap[i]) != features_to_test->_features_bitmap[i]) { + return false; + } + } + return true; + } }; // CPU feature flags vector, can be affected by VM settings. @@ -819,7 +828,7 @@ public: static uint32_t cpu_stepping() { return _cpuid_info.cpu_stepping(); } static int cpu_family() { return _cpu;} static bool is_P6() { return cpu_family() >= 6; } - static bool is_intel_server_family() { return cpu_family() == 6 || cpu_family() == 19; } + static bool is_intel_server_family() { return cpu_family() == 6 || cpu_family() == 18 || cpu_family() == 19; } static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA' static bool is_hygon() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x6F677948; } // 'ogyH' static bool is_amd_family() { return is_amd() || is_hygon(); } @@ -949,8 +958,6 @@ public: static bool is_intel_darkmont(); - static int avx3_threshold(); - static bool is_intel_tsc_synched_at_init(); static void insert_features_names(VM_Version::VM_Features features, stringStream& ss); @@ -1103,6 +1110,20 @@ public: static bool supports_tscinv_ext(void); static void initialize_cpu_information(void); + + static void get_cpu_features_name(void* features_buffer, stringStream& ss); + + // Returns names of features present in features_set1 but not in features_set2 + static void get_missing_features_name(void* features_set1, void* features_set2, stringStream& ss); + + // Returns number of bytes required to store cpu features representation + static int cpu_features_size(); + + // Stores cpu features representation in the provided buffer. This representation is arch dependent. + // Size of the buffer must be same as returned by cpu_features_size() + static void store_cpu_features(void* buf); + + static bool supports_features(void* features_to_test); }; #endif // CPU_X86_VM_VERSION_X86_HPP diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index aed54fe93d4..f31d64f3d7e 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -2605,13 +2605,8 @@ uint BoxLockNode::size(PhaseRegAlloc *ra_) const #ifndef PRODUCT void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const { - if (UseCompressedClassPointers) { - st->print_cr("movl rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tcmpl rscratch1, [rax + CompiledICData::speculated_klass_offset()]\t # Inline cache check"); - } else { - st->print_cr("movq rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); - st->print_cr("\tcmpq rscratch1, [rax + CompiledICData::speculated_klass_offset()]\t # Inline cache check"); - } + st->print_cr("movl rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); + st->print_cr("\tcmpl rscratch1, [rax + CompiledICData::speculated_klass_offset()]\t # Inline cache check"); st->print_cr("\tjne SharedRuntime::_ic_miss_stub"); } #endif @@ -2726,11 +2721,8 @@ bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) { return (-128 <= offset && offset <= 127); } +#ifdef ASSERT // Return whether or not this register is ever used as an argument. -// This function is used on startup to build the trampoline stubs in -// generateOptoStub. Registers not mentioned will be killed by the VM -// call in the trampoline, and arguments in those registers not be -// available to the callee. bool Matcher::can_be_java_arg(int reg) { return @@ -2750,11 +2742,7 @@ bool Matcher::can_be_java_arg(int reg) reg == XMM6_num || reg == XMM6b_num || reg == XMM7_num || reg == XMM7b_num; } - -bool Matcher::is_spillable_arg(int reg) -{ - return can_be_java_arg(reg); -} +#endif uint Matcher::int_pressure_limit() { @@ -2770,13 +2758,6 @@ uint Matcher::float_pressure_limit() return (FLOATPRESSURE == -1) ? default_float_pressure_threshold : FLOATPRESSURE; } -bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) { - // In 64 bit mode a code which use multiply when - // devisor is constant is faster than hardware - // DIV instruction (it uses MulHiL). - return false; -} - // Register for DIVI projection of divmodI const RegMask& Matcher::divI_proj_mask() { return INT_RAX_REG_mask(); @@ -3341,6 +3322,18 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; + case Op_UMinReductionV: + case Op_UMaxReductionV: + if (UseAVX == 0) { + return false; + } + if (bt == T_LONG && !VM_Version::supports_avx512vl()) { + return false; + } + if (UseAVX > 2 && size_in_bits == 512 && !VM_Version::supports_avx512vl()) { + return false; + } + break; case Op_MaxV: case Op_MinV: if (UseSSE < 4 && is_integral_type(bt)) { @@ -4679,11 +4672,6 @@ frame // Compiled code's Frame Pointer frame_pointer(RSP); - // Interpreter stores its frame pointer in a register which is - // stored to the stack by I2CAdaptors. - // I2CAdaptors convert from interpreted java to compiled java. - interpreter_frame_pointer(RBP); - // Stack alignment requirement stack_alignment(StackAlignmentInBytes); // Alignment size in bytes (128-bit -> 16 bytes) @@ -5187,6 +5175,18 @@ operand immL_65535() interface(CONST_INTER); %} +// AOT Runtime Constants Address +operand immAOTRuntimeConstantsAddress() +%{ + // Check if the address is in the range of AOT Runtime Constants + predicate(AOTRuntimeConstants::contains((address)(n->get_ptr()))); + match(ConP); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + operand kReg() %{ constraint(ALLOC_IN_RC(vectmask_reg)); @@ -7332,6 +7332,19 @@ instruct loadD(regD dst, memory mem) ins_pipe(pipe_slow); // XXX %} +instruct loadAOTRCAddress(rRegP dst, immAOTRuntimeConstantsAddress con) +%{ + match(Set dst con); + + format %{ "leaq $dst, $con\t# AOT Runtime Constants Address" %} + + ins_encode %{ + __ load_aotrc_address($dst$$Register, (address)$con$$constant); + %} + + ins_pipe(ialu_reg_fat); +%} + // max = java.lang.Math.max(float a, float b) instruct maxF_reg_avx10_2(regF dst, regF a, regF b) %{ predicate(VM_Version::supports_avx10_2()); @@ -8827,6 +8840,21 @@ instruct membar_release_lock() ins_pipe(empty); %} +instruct membar_storeload(rFlagsReg cr) %{ + match(MemBarStoreLoad); + effect(KILL cr); + ins_cost(400); + + format %{ + $$template + $$emit$$"lock addl [rsp + #0], 0\t! membar_storeload" + %} + ins_encode %{ + __ membar(Assembler::StoreLoad); + %} + ins_pipe(pipe_slow); +%} + instruct membar_volatile(rFlagsReg cr) %{ match(MemBarVolatile); effect(KILL cr); @@ -8854,6 +8882,21 @@ instruct unnecessary_membar_volatile() ins_pipe(empty); %} +instruct membar_full(rFlagsReg cr) %{ + match(MemBarFull); + effect(KILL cr); + ins_cost(400); + + format %{ + $$template + $$emit$$"lock addl [rsp + #0], 0\t! membar_full" + %} + ins_encode %{ + __ membar(Assembler::StoreLoad); + %} + ins_pipe(pipe_slow); +%} + instruct membar_storestore() %{ match(MemBarStoreStore); match(StoreStoreFence); @@ -19346,6 +19389,8 @@ instruct reductionI(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_int $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19367,6 +19412,8 @@ instruct reductionL(rRegL dst, rRegL src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_long $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19386,6 +19433,8 @@ instruct reductionL_avx512dq(rRegL dst, rRegL src1, vec src2, vec vtmp1, vec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_long $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19614,6 +19663,8 @@ instruct reductionB(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_byte $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19632,6 +19683,8 @@ instruct reductionB_avx512bw(rRegI dst, rRegI src1, vec src2, vec vtmp1, vec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_byte $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19653,6 +19706,8 @@ instruct reductionS(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_short $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ diff --git a/src/hotspot/cpu/zero/bytecodeInterpreter_zero.inline.hpp b/src/hotspot/cpu/zero/bytecodeInterpreter_zero.inline.hpp index 4d813cd53c6..4c73368b673 100644 --- a/src/hotspot/cpu/zero/bytecodeInterpreter_zero.inline.hpp +++ b/src/hotspot/cpu/zero/bytecodeInterpreter_zero.inline.hpp @@ -26,6 +26,8 @@ #ifndef CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP #define CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP +#include "sanitizers/ub.hpp" + // Inline interpreter functions for zero inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { @@ -40,6 +42,7 @@ inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { return op1 * op2; } +ATTRIBUTE_NO_UBSAN // IEEE-754 division by zero is well-defined inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { return op1 / op2; } @@ -68,7 +71,7 @@ inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], } inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) { - return op1 + op2; + return java_add(op1, op2); } inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) { @@ -82,7 +85,7 @@ inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) { } inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) { - return op1 * op2; + return java_multiply(op1, op2); } inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) { @@ -90,7 +93,7 @@ inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) { } inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) { - return op1 - op2; + return java_subtract(op1, op2); } inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) { @@ -104,19 +107,19 @@ inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) { } inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) { - return ((unsigned long long) op1) >> (op2 & 0x3F); + return java_shift_right_unsigned(op1, op2); } inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) { - return op1 >> (op2 & 0x3F); + return java_shift_right(op1, op2); } inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) { - return op1 << (op2 & 0x3F); + return java_shift_left(op1, op2); } inline jlong BytecodeInterpreter::VMlongNeg(jlong op) { - return -op; + return java_negate(op); } inline jlong BytecodeInterpreter::VMlongNot(jlong op) { @@ -183,8 +186,8 @@ inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) { return op1 + op2; } +ATTRIBUTE_NO_UBSAN // IEEE-754 division by zero is well-defined inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) { - // Divide by zero... QQQ return op1 / op2; } @@ -228,7 +231,7 @@ inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) { // Integer Arithmetic inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) { - return op1 + op2; + return java_add(op1, op2); } inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) { @@ -242,11 +245,11 @@ inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) { } inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) { - return op1 * op2; + return java_multiply(op1, op2); } inline jint BytecodeInterpreter::VMintNeg(jint op) { - return -op; + return java_negate(op); } inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) { @@ -260,19 +263,19 @@ inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) { } inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) { - return op1 << (op2 & 0x1F); + return java_shift_left(op1, op2); } inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) { - return op1 >> (op2 & 0x1F); + return java_shift_right(op1, op2); } inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) { - return op1 - op2; + return java_subtract(op1, op2); } inline juint BytecodeInterpreter::VMintUshr(jint op1, jint op2) { - return ((juint) op1) >> (op2 & 0x1F); + return java_shift_right_unsigned(op1, op2); } inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) { diff --git a/src/hotspot/cpu/zero/register_zero.hpp b/src/hotspot/cpu/zero/register_zero.hpp index fd30f206762..846b649eebd 100644 --- a/src/hotspot/cpu/zero/register_zero.hpp +++ b/src/hotspot/cpu/zero/register_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -48,7 +48,6 @@ class RegisterImpl : public AbstractRegisterImpl { }; // construction - inline friend Register as_Register(int encoding); VMReg as_VMReg(); // derived registers, offsets, and addresses @@ -113,7 +112,6 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl { static const int max_fpr; }; -CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); -#define noreg ((Register)(noreg_RegisterEnumValue)) +const Register noreg = as_Register(-1); #endif // CPU_ZERO_REGISTER_ZERO_HPP diff --git a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp index 28c2364315e..1b20761f6e4 100644 --- a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp +++ b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp @@ -368,12 +368,15 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) { goto unlock_unwind_and_return; void **arguments; - void *mirror; { + // These locals must remain on stack until call completes + void *mirror; + void *env; + { arguments = (void **) stack->alloc(handler->argument_count() * sizeof(void **)); void **dst = arguments; - void *env = thread->jni_environment(); + env = thread->jni_environment(); *(dst++) = &env; if (method->is_static()) { diff --git a/src/hotspot/os/aix/globals_aix.hpp b/src/hotspot/os/aix/globals_aix.hpp index 14b956235e8..adc189666ef 100644 --- a/src/hotspot/os/aix/globals_aix.hpp +++ b/src/hotspot/os/aix/globals_aix.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2024 SAP SE. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,16 +37,6 @@ range, \ constraint) \ \ - /* Whether to allow the VM to run if EXTSHM=ON. EXTSHM is an environment */ \ - /* variable used on AIX to activate certain hacks which allow more shm segments */\ - /* for 32bit processes. For 64bit processes, it is pointless and may have */ \ - /* harmful side effects (e.g. for some reasonn prevents allocation of 64k pages */\ - /* via shmctl). */ \ - /* Per default we quit with an error if that variable is found; for certain */ \ - /* customer scenarios, we may want to be able to run despite that variable. */ \ - product(bool, AllowExtshm, false, DIAGNOSTIC, \ - "Allow VM to run with EXTSHM=ON.") \ - \ /* Maximum expected size of the data segment. That correlates with the */ \ /* maximum C Heap consumption we expect. */ \ /* We need to leave "breathing space" for the data segment when */ \ @@ -61,10 +51,6 @@ product(bool, OptimizePollingPageLocation, true, DIAGNOSTIC, \ "Optimize the location of the polling page used for Safepoints") \ \ - /* Use 64K pages for virtual memory (shmat). */ \ - product(bool, Use64KPages, true, DIAGNOSTIC, \ - "Use 64K pages if available.") \ - \ /* Normally AIX commits memory on touch, but sometimes it is helpful to have */ \ /* explicit commit behaviour. This flag, if true, causes the VM to touch */ \ /* memory on os::commit_memory() (which normally is a noop). */ \ @@ -79,7 +65,6 @@ // // UseLargePages means nothing, for now, on AIX. -// Use Use64KPages or Use16MPages instead. define_pd_global(size_t, PreTouchParallelChunkSize, 1 * G); define_pd_global(bool, UseLargePages, false); define_pd_global(bool, UseLargePagesIndividualAllocation, false); diff --git a/src/hotspot/os/aix/libodm_aix.cpp b/src/hotspot/os/aix/libodm_aix.cpp index 38e8067181a..57eee47c098 100644 --- a/src/hotspot/os/aix/libodm_aix.cpp +++ b/src/hotspot/os/aix/libodm_aix.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2019 SAP SE. All rights reserved. + * Copyright (c) 2015, 2026 SAP SE. 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 @@ -63,13 +63,12 @@ dynamicOdm::~dynamicOdm() { void odmWrapper::clean_data() { if (_data) { permit_forbidden_function::free(_data); _data = nullptr; } } -int odmWrapper::class_offset(const char *field, bool is_aix_5) +int odmWrapper::class_offset(const char *field) { assert(has_class(), "initialization"); for (int i = 0; i < odm_class()->nelem; i++) { if (strcmp(odm_class()->elem[i].elemname, field) == 0) { int offset = odm_class()->elem[i].offset; - if (is_aix_5) { offset += LINK_VAL_OFFSET; } return offset; } } @@ -88,11 +87,10 @@ void odmWrapper::determine_os_kernel_version(uint32_t* p_ver) { return; } int voff, roff, moff, foff; - bool is_aix_5 = (major_aix_version == 5); - voff = odm.class_offset("ver", is_aix_5); - roff = odm.class_offset("rel", is_aix_5); - moff = odm.class_offset("mod", is_aix_5); - foff = odm.class_offset("fix", is_aix_5); + voff = odm.class_offset("ver"); + roff = odm.class_offset("rel"); + moff = odm.class_offset("mod"); + foff = odm.class_offset("fix"); if (voff == -1 || roff == -1 || moff == -1 || foff == -1) { trcVerbose("try_determine_os_kernel_version: could not get offsets"); return; diff --git a/src/hotspot/os/aix/libodm_aix.hpp b/src/hotspot/os/aix/libodm_aix.hpp index 924ccaf8c51..11e67a4f5ae 100644 --- a/src/hotspot/os/aix/libodm_aix.hpp +++ b/src/hotspot/os/aix/libodm_aix.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2024 SAP SE. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ class odmWrapper : private dynamicOdm { CLASS_SYMBOL odm_class() { return _odm_class; } bool has_class() { return odm_class() != (CLASS_SYMBOL)-1; } - int class_offset(const char *field, bool is_aix_5); + int class_offset(const char *field); char* data() { return _data; } char* retrieve_obj(const char* name = nullptr) { diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 327508e1118..3cad24d388c 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,17 +122,10 @@ extern "C" int mread_real_time(timebasestruct_t *t, size_t size_of_timebasestruct_t); -#if !defined(_AIXVERSION_610) -extern "C" int getthrds64(pid_t, struct thrdentry64*, int, tid64_t*, int); -extern "C" int getprocs64(procentry64*, int, fdsinfo*, int, pid_t*, int); -extern "C" int getargs(procsinfo*, int, char*, int); -#endif - #define MAX_PATH (2 * K) // for multipage initialization error analysis (in 'g_multipage_error') #define ERROR_MP_OS_TOO_OLD 100 -#define ERROR_MP_EXTSHM_ACTIVE 101 #define ERROR_MP_VMGETINFO_FAILED 102 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103 @@ -184,9 +177,6 @@ uint32_t os::Aix::_os_version = 0; // -1 = uninitialized, 0 - no, 1 - yes int os::Aix::_xpg_sus_mode = -1; -// -1 = uninitialized, 0 - no, 1 - yes -int os::Aix::_extshm = -1; - //////////////////////////////////////////////////////////////////////////////// // local variables @@ -216,7 +206,7 @@ static address g_brk_at_startup = nullptr; // shmctl(). Different shared memory regions can have different page // sizes. // -// More information can be found at AIBM info center: +// More information can be found at IBM info center: // http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm // static struct { @@ -1201,13 +1191,6 @@ void os::print_memory_info(outputStream* st) { const char* const ldr_cntrl = ::getenv("LDR_CNTRL"); st->print_cr(" LDR_CNTRL=%s.", ldr_cntrl ? ldr_cntrl : ""); - // Print out EXTSHM because it is an unsupported setting. - const char* const extshm = ::getenv("EXTSHM"); - st->print_cr(" EXTSHM=%s.", extshm ? extshm : ""); - if ( (strcmp(extshm, "on") == 0) || (strcmp(extshm, "ON") == 0) ) { - st->print_cr(" *** Unsupported! Please remove EXTSHM from your environment! ***"); - } - // Print out AIXTHREAD_GUARDPAGES because it affects the size of pthread stacks. const char* const aixthread_guardpages = ::getenv("AIXTHREAD_GUARDPAGES"); st->print_cr(" AIXTHREAD_GUARDPAGES=%s.", @@ -1956,11 +1939,6 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ return nullptr; } -bool os::pd_release_memory_special(char* base, size_t bytes) { - fatal("os::release_memory_special should not be called on AIX."); - return false; -} - size_t os::large_page_size() { return _large_page_size; } @@ -2142,46 +2120,10 @@ void os::init(void) { // 64k no --- AIX 5.2 ? --- // 64k yes 64k new systems and standard java loader (we set datapsize=64k when linking) - // We explicitly leave no option to change page size, because only upgrading would work, - // not downgrading (if stack page size is 64k you cannot pretend its 4k). - - if (g_multipage_support.datapsize == 4*K) { - // datapsize = 4K. Data segment, thread stacks are 4K paged. - if (g_multipage_support.can_use_64K_pages || g_multipage_support.can_use_64K_mmap_pages) { - // .. but we are able to use 64K pages dynamically. - // This would be typical for java launchers which are not linked - // with datapsize=64K (like, any other launcher but our own). - // - // In this case it would be smart to allocate the java heap with 64K - // to get the performance benefit, and to fake 64k pages for the - // data segment (when dealing with thread stacks). - // - // However, leave a possibility to downgrade to 4K, using - // -XX:-Use64KPages. - if (Use64KPages) { - trcVerbose("64K page mode (faked for data segment)"); - set_page_size(64*K); - } else { - trcVerbose("4K page mode (Use64KPages=off)"); - set_page_size(4*K); - } - } else { - // .. and not able to allocate 64k pages dynamically. Here, just - // fall back to 4K paged mode and use mmap for everything. - trcVerbose("4K page mode"); - set_page_size(4*K); - FLAG_SET_ERGO(Use64KPages, false); - } - } else { - // datapsize = 64k. Data segment, thread stacks are 64k paged. - // This normally means that we can allocate 64k pages dynamically. - // (There is one special case where this may be false: EXTSHM=on. - // but we decided to not support that mode). - assert0(g_multipage_support.can_use_64K_pages || g_multipage_support.can_use_64K_mmap_pages); - set_page_size(64*K); - trcVerbose("64K page mode"); - FLAG_SET_ERGO(Use64KPages, true); - } + // datapsize = 64k. Data segment, thread stacks are 64k paged. + // This normally means that we can allocate 64k pages dynamically. + assert0(g_multipage_support.can_use_64K_pages || g_multipage_support.can_use_64K_mmap_pages); + set_page_size(64*K); // For now UseLargePages is just ignored. FLAG_SET_ERGO(UseLargePages, false); @@ -2564,23 +2506,18 @@ void os::Aix::initialize_os_info() { assert(minor > 0, "invalid OS release"); _os_version = (major << 24) | (minor << 16); char ver_str[20] = {0}; - const char* name_str = "unknown OS"; - if (strcmp(uts.sysname, "AIX") == 0) { - // We run on AIX. We do not support versions older than AIX 7.1. - // Determine detailed AIX version: Version, Release, Modification, Fix Level. - odmWrapper::determine_os_kernel_version(&_os_version); - if (os_version_short() < 0x0701) { - log_warning(os)("AIX releases older than AIX 7.1 are not supported."); - assert(false, "AIX release too old."); - } - name_str = "AIX"; - jio_snprintf(ver_str, sizeof(ver_str), "%u.%u.%u.%u", - major, minor, (_os_version >> 8) & 0xFF, _os_version & 0xFF); - } else { - assert(false, "%s", name_str); + // We do not support versions older than AIX 7.2 TL 5. + // Determine detailed AIX version: Version, Release, Modification, Fix Level. + odmWrapper::determine_os_kernel_version(&_os_version); + if (_os_version < 0x07020500) { + log_warning(os)("AIX releases older than AIX 7.2 TL 5 are not supported."); + assert(false, "AIX release too old."); } - log_info(os)("We run on %s %s", name_str, ver_str); + + jio_snprintf(ver_str, sizeof(ver_str), "%u.%u.%u.%u", + major, minor, (_os_version >> 8) & 0xFF, _os_version & 0xFF); + log_info(os)("We run on AIX %s", ver_str); } guarantee(_os_version, "Could not determine AIX release"); @@ -2593,28 +2530,13 @@ void os::Aix::initialize_os_info() { void os::Aix::scan_environment() { char* p; - int rc; - // Warn explicitly if EXTSHM=ON is used. That switch changes how - // System V shared memory behaves. One effect is that page size of - // shared memory cannot be change dynamically, effectivly preventing - // large pages from working. - // This switch was needed on AIX 32bit, but on AIX 64bit the general - // recommendation is (in OSS notes) to switch it off. + // Reject EXTSHM=ON. That switch changes how System V shared memory behaves + // and prevents allocation of 64k pages for the heap. p = ::getenv("EXTSHM"); trcVerbose("EXTSHM=%s.", p ? p : ""); if (p && strcasecmp(p, "ON") == 0) { - _extshm = 1; - log_warning(os)("*** Unsupported mode! Please remove EXTSHM from your environment! ***"); - if (!AllowExtshm) { - // We allow under certain conditions the user to continue. However, we want this - // to be a fatal error by default. On certain AIX systems, leaving EXTSHM=ON means - // that the VM is not able to allocate 64k pages for the heap. - // We do not want to run with reduced performance. - vm_exit_during_initialization("EXTSHM is ON. Please remove EXTSHM from your environment."); - } - } else { - _extshm = 0; + vm_exit_during_initialization("EXTSHM is ON. Please remove EXTSHM from your environment."); } // SPEC1170 behaviour: will change the behaviour of a number of POSIX APIs. @@ -2745,3 +2667,7 @@ void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {} void os::jfr_report_memory_info() {} #endif // INCLUDE_JFR + +void os::print_open_file_descriptors(outputStream* st) { + // File descriptor counting not implemented on AIX +} diff --git a/src/hotspot/os/aix/os_aix.hpp b/src/hotspot/os/aix/os_aix.hpp index a30e2077fc2..e21d2cf81bb 100644 --- a/src/hotspot/os/aix/os_aix.hpp +++ b/src/hotspot/os/aix/os_aix.hpp @@ -49,11 +49,6 @@ class os::Aix { // 1 - SPEC1170 requested (XPG_SUS_ENV is ON) static int _xpg_sus_mode; - // -1 = uninitialized, - // 0 - EXTSHM=OFF or not set - // 1 - EXTSHM=ON - static int _extshm; - static bool available_memory(physical_memory_size_type& value); static bool free_memory(physical_memory_size_type& value); static physical_memory_size_type physical_memory() { return _physical_memory; } @@ -111,12 +106,6 @@ class os::Aix { return _xpg_sus_mode; } - // Returns true if EXTSHM=ON. - static bool extshm() { - assert(_extshm != -1, "not initialized"); - return _extshm; - } - // result struct for get_meminfo() struct meminfo_t { diff --git a/src/hotspot/os/aix/os_perf_aix.cpp b/src/hotspot/os/aix/os_perf_aix.cpp index aa8819d035f..cbf78083483 100644 --- a/src/hotspot/os/aix/os_perf_aix.cpp +++ b/src/hotspot/os/aix/os_perf_aix.cpp @@ -143,12 +143,6 @@ static OSReturn get_jvm_load(double* jvm_uload, double* jvm_sload) { return OS_OK; } -static void update_prev_time(jvm_time_store_t* from, jvm_time_store_t* to) { - if (from && to) { - memcpy(to, from, sizeof(jvm_time_store_t)); - } -} - static void update_prev_ticks(cpu_tick_store_t* from, cpu_tick_store_t* to) { if (from && to) { memcpy(to, from, sizeof(cpu_tick_store_t)); diff --git a/src/hotspot/os/aix/porting_aix.hpp b/src/hotspot/os/aix/porting_aix.hpp index a1a22d81471..0bd71079d0a 100644 --- a/src/hotspot/os/aix/porting_aix.hpp +++ b/src/hotspot/os/aix/porting_aix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,25 +37,9 @@ // (see http://linux.die.net/man/3/dladdr) // dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. // -// Differences between AIX dladdr and Linux dladdr: -// -// 1) Dl_info.dli_fbase: can never work, is disabled. -// A loaded image on AIX is divided in multiple segments, at least two -// (text and data) but potentially also far more. This is because the loader may -// load each member into an own segment, as for instance happens with the libC.a -// 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a -// zero-length string is returned (""). -// 3) Dl_info.dli_saddr: For code, this will return the entry point of the function, -// not the function descriptor. -typedef struct { - const char *dli_fname; // file path of loaded library - // void *dli_fbase; - const char *dli_sname; // symbol name; "" if not known - void *dli_saddr; // address of *entry* of function; not function descriptor; -} Dl_info; +#include "dl_info.h" -// Note: we export this to use it inside J2se too #ifdef __cplusplus extern "C" #endif diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 0ed5335adc3..a4d9a2197a5 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -76,6 +76,7 @@ # include # include # include +# include # include # include # include @@ -102,6 +103,7 @@ #endif #ifdef __APPLE__ + #include #include #include #endif @@ -1885,11 +1887,6 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ return nullptr; } -bool os::pd_release_memory_special(char* base, size_t bytes) { - fatal("os::release_memory_special should not be called on BSD."); - return false; -} - size_t os::large_page_size() { return _large_page_size; } @@ -2601,3 +2598,45 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { return res; } // end: os::pd_dll_unload() + +void os::print_open_file_descriptors(outputStream* st) { +#ifdef __APPLE__ + char buf[1024 * sizeof(struct proc_fdinfo)]; + os::Bsd::print_open_file_descriptors(st, buf, sizeof(buf)); +#else + st->print_cr("Open File Descriptors: unknown"); +#endif +} + +void os::Bsd::print_open_file_descriptors(outputStream* st, char* buf, size_t buflen) { +#ifdef __APPLE__ + pid_t my_pid; + + // ensure the scratch buffer is big enough for at least one FD info struct + precond(buflen >= sizeof(struct proc_fdinfo)); + kern_return_t kres = pid_for_task(mach_task_self(), &my_pid); + if (kres != KERN_SUCCESS) { + st->print_cr("Open File Descriptors: unknown"); + return; + } + size_t max_fds = buflen / sizeof(struct proc_fdinfo); + struct proc_fdinfo* fds = reinterpret_cast(buf); + + // fill our buffer with FD info, up to the available buffer size + int res = proc_pidinfo(my_pid, PROC_PIDLISTFDS, 0, fds, max_fds * sizeof(struct proc_fdinfo)); + if (res <= 0) { + st->print_cr("Open File Descriptors: unknown"); + return; + } + + // print lower threshold if count exceeds buffer size + int nfiles = res / sizeof(struct proc_fdinfo); + if ((size_t)nfiles >= max_fds) { + st->print_cr("Open File Descriptors: > %zu", max_fds); + return; + } + st->print_cr("Open File Descriptors: %d", nfiles); +#else + st->print_cr("Open File Descriptors: unknown"); +#endif +} diff --git a/src/hotspot/os/bsd/os_bsd.hpp b/src/hotspot/os/bsd/os_bsd.hpp index da73211b9a7..e87a680b2d2 100644 --- a/src/hotspot/os/bsd/os_bsd.hpp +++ b/src/hotspot/os/bsd/os_bsd.hpp @@ -123,6 +123,8 @@ class os::Bsd { static int get_node_by_cpu(int cpu_id); static void print_uptime_info(outputStream* st); + static void print_open_file_descriptors(outputStream* st, char* buf, size_t buflen); + static void print_open_file_descriptors(outputStream* st); }; #endif // OS_BSD_OS_BSD_HPP diff --git a/src/hotspot/os/bsd/semaphore_bsd.cpp b/src/hotspot/os/bsd/semaphore_bsd.cpp index 827c955677e..c35712ff2da 100644 --- a/src/hotspot/os/bsd/semaphore_bsd.cpp +++ b/src/hotspot/os/bsd/semaphore_bsd.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -81,27 +81,37 @@ bool OSXSemaphore::timedwait(int64_t millis) { // kernel semaphores take a relative timeout mach_timespec_t waitspec; - int secs = millis / MILLIUNITS; - int nsecs = millis_to_nanos(millis % MILLIUNITS); - waitspec.tv_sec = secs; - waitspec.tv_nsec = nsecs; + int64_t starttime; + const bool is_trywait = millis == 0; - int64_t starttime = os::javaTimeNanos(); + if (!is_trywait) { + int secs = millis / MILLIUNITS; + int nsecs = millis_to_nanos(millis % MILLIUNITS); + waitspec.tv_sec = secs; + waitspec.tv_nsec = nsecs; + + starttime = os::javaTimeNanos(); + } else { + waitspec.tv_sec = 0; + waitspec.tv_nsec = 0; + } kr = semaphore_timedwait(_semaphore, waitspec); while (kr == KERN_ABORTED) { - // reduce the timeout and try again - int64_t totalwait = millis_to_nanos(millis); - int64_t current = os::javaTimeNanos(); - int64_t passedtime = current - starttime; + if (!is_trywait) { + // reduce the timeout and try again + int64_t totalwait = millis_to_nanos(millis); + int64_t current = os::javaTimeNanos(); + int64_t passedtime = current - starttime; - if (passedtime >= totalwait) { - waitspec.tv_sec = 0; - waitspec.tv_nsec = 0; - } else { - int64_t waittime = totalwait - (current - starttime); - waitspec.tv_sec = waittime / NANOSECS_PER_SEC; - waitspec.tv_nsec = waittime % NANOSECS_PER_SEC; + if (passedtime >= totalwait) { + waitspec.tv_sec = 0; + waitspec.tv_nsec = 0; + } else { + int64_t waittime = totalwait - (current - starttime); + waitspec.tv_sec = waittime / NANOSECS_PER_SEC; + waitspec.tv_nsec = waittime % NANOSECS_PER_SEC; + } } kr = semaphore_timedwait(_semaphore, waitspec); diff --git a/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index e49d070890e..13a005591fb 100644 --- a/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -28,7 +28,6 @@ #include "cgroupV2Subsystem_linux.hpp" #include "logging/log.hpp" #include "memory/allocation.hpp" -#include "os_linux.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" #include "utilities/globalDefinitions.hpp" @@ -605,6 +604,11 @@ void CgroupSubsystemFactory::cleanup(CgroupInfo* cg_infos) { } } +void CgroupSubsystem::adjust_controllers(physical_memory_size_type upper_mem_bound, int upper_cpu_bound) { + CgroupUtil::adjust_controller(memory_controller()->controller(), upper_mem_bound); + CgroupUtil::adjust_controller(cpu_controller()->controller(), upper_cpu_bound); +} + /* active_processor_count * * Calculate an appropriate number of active processors for the @@ -631,7 +635,7 @@ void CgroupSubsystemFactory::cleanup(CgroupInfo* cg_infos) { * return: * true if there were no errors. false otherwise. */ -bool CgroupSubsystem::active_processor_count(double& value) { +bool CgroupSubsystem::active_processor_count(int (*cpu_bound_func)(), double& value) { // We use a cache with a timeout to avoid performing expensive // computations in the event this function is called frequently. // [See 8227006]. @@ -643,7 +647,7 @@ bool CgroupSubsystem::active_processor_count(double& value) { return true; } - int cpu_count = os::Linux::active_processor_count(); + int cpu_count = cpu_bound_func(); double result = -1; if (!CgroupUtil::processor_count(contrl->controller(), cpu_count, result)) { return false; diff --git a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index d083a9985c2..adde37e1c77 100644 --- a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -278,7 +278,7 @@ class CgroupMemoryController: public CHeapObj { class CgroupSubsystem: public CHeapObj { public: bool memory_limit_in_bytes(physical_memory_size_type upper_bound, physical_memory_size_type& value); - bool active_processor_count(double& value); + bool active_processor_count(int (*cpu_bound_func)(), double& value); virtual bool pids_max(uint64_t& value) = 0; virtual bool pids_current(uint64_t& value) = 0; @@ -291,6 +291,8 @@ class CgroupSubsystem: public CHeapObj { virtual CachingCgroupController* cpu_controller() = 0; virtual CgroupCpuacctController* cpuacct_controller() = 0; + void adjust_controllers(physical_memory_size_type upper_mem_bound, int upper_cpu_bound); + bool cpu_quota(int& value); bool cpu_period(int& value); bool cpu_shares(int& value); diff --git a/src/hotspot/os/linux/cgroupUtil_linux.cpp b/src/hotspot/os/linux/cgroupUtil_linux.cpp index 570b335940b..f166f6cd5e4 100644 --- a/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -24,7 +24,6 @@ */ #include "cgroupUtil_linux.hpp" -#include "os_linux.hpp" bool CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int upper_bound, double& value) { assert(upper_bound > 0, "upper bound of cpus must be positive"); @@ -82,7 +81,7 @@ double CgroupUtil::get_updated_cpu_limit(CgroupCpuController* cpu, return lowest; } -void CgroupUtil::adjust_controller(CgroupMemoryController* mem) { +void CgroupUtil::adjust_controller(CgroupMemoryController* mem, physical_memory_size_type upper_bound) { assert(mem->cgroup_path() != nullptr, "invariant"); if (strstr(mem->cgroup_path(), "../") != nullptr) { log_warning(os, container)("Cgroup memory controller path at '%s' seems to have moved " @@ -100,17 +99,16 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) { char* cg_path = os::strdup(orig); char* last_slash; assert(cg_path[0] == '/', "cgroup path must start with '/'"); - physical_memory_size_type phys_mem = os::Linux::physical_memory(); char* limit_cg_path = nullptr; physical_memory_size_type limit = value_unlimited; - physical_memory_size_type lowest_limit = phys_mem; - lowest_limit = get_updated_mem_limit(mem, lowest_limit, phys_mem); - physical_memory_size_type orig_limit = lowest_limit != phys_mem ? lowest_limit : phys_mem; + physical_memory_size_type lowest_limit = upper_bound; + lowest_limit = get_updated_mem_limit(mem, lowest_limit, upper_bound); + physical_memory_size_type orig_limit = lowest_limit != upper_bound ? lowest_limit : upper_bound; while ((last_slash = strrchr(cg_path, '/')) != cg_path) { *last_slash = '\0'; // strip path // update to shortened path and try again mem->set_subsystem_path(cg_path); - limit = get_updated_mem_limit(mem, lowest_limit, phys_mem); + limit = get_updated_mem_limit(mem, lowest_limit, upper_bound); if (limit < lowest_limit) { lowest_limit = limit; os::free(limit_cg_path); // handles nullptr @@ -119,13 +117,13 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) { } // need to check limit at mount point mem->set_subsystem_path("/"); - limit = get_updated_mem_limit(mem, lowest_limit, phys_mem); + limit = get_updated_mem_limit(mem, lowest_limit, upper_bound); if (limit < lowest_limit) { lowest_limit = limit; os::free(limit_cg_path); // handles nullptr limit_cg_path = os::strdup("/"); } - assert(lowest_limit <= phys_mem, "limit must not exceed host memory"); + assert(lowest_limit <= upper_bound, "limit must not exceed upper bound"); if (lowest_limit != orig_limit) { // we've found a lower limit anywhere in the hierarchy, // set the path to the limit path @@ -147,7 +145,7 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) { os::free(limit_cg_path); } -void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { +void CgroupUtil::adjust_controller(CgroupCpuController* cpu, int upper_bound) { assert(cpu->cgroup_path() != nullptr, "invariant"); if (strstr(cpu->cgroup_path(), "../") != nullptr) { log_warning(os, container)("Cgroup cpu controller path at '%s' seems to have moved " @@ -165,17 +163,16 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { char* cg_path = os::strdup(orig); char* last_slash; assert(cg_path[0] == '/', "cgroup path must start with '/'"); - int host_cpus = os::Linux::active_processor_count(); - int lowest_limit = host_cpus; - double cpus = get_updated_cpu_limit(cpu, lowest_limit, host_cpus); - int orig_limit = lowest_limit != host_cpus ? lowest_limit : host_cpus; + int lowest_limit = upper_bound; + double cpus = get_updated_cpu_limit(cpu, lowest_limit, upper_bound); + int orig_limit = lowest_limit != upper_bound ? lowest_limit : upper_bound; char* limit_cg_path = nullptr; while ((last_slash = strrchr(cg_path, '/')) != cg_path) { *last_slash = '\0'; // strip path // update to shortened path and try again cpu->set_subsystem_path(cg_path); - cpus = get_updated_cpu_limit(cpu, lowest_limit, host_cpus); - if (cpus != host_cpus && cpus < lowest_limit) { + cpus = get_updated_cpu_limit(cpu, lowest_limit, upper_bound); + if (cpus != upper_bound && cpus < lowest_limit) { lowest_limit = cpus; os::free(limit_cg_path); // handles nullptr limit_cg_path = os::strdup(cg_path); @@ -183,8 +180,8 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { } // need to check limit at mount point cpu->set_subsystem_path("/"); - cpus = get_updated_cpu_limit(cpu, lowest_limit, host_cpus); - if (cpus != host_cpus && cpus < lowest_limit) { + cpus = get_updated_cpu_limit(cpu, lowest_limit, upper_bound); + if (cpus != upper_bound && cpus < lowest_limit) { lowest_limit = cpus; os::free(limit_cg_path); // handles nullptr limit_cg_path = os::strdup(cg_path); diff --git a/src/hotspot/os/linux/cgroupUtil_linux.hpp b/src/hotspot/os/linux/cgroupUtil_linux.hpp index 1fd2a7d872b..68585c22c2d 100644 --- a/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -35,10 +35,10 @@ class CgroupUtil: AllStatic { static bool processor_count(CgroupCpuController* cpu, int upper_bound, double& value); // Given a memory controller, adjust its path to a point in the hierarchy // that represents the closest memory limit. - static void adjust_controller(CgroupMemoryController* m); + static void adjust_controller(CgroupMemoryController* m, physical_memory_size_type upper_bound); // Given a cpu controller, adjust its path to a point in the hierarchy // that represents the closest cpu limit. - static void adjust_controller(CgroupCpuController* c); + static void adjust_controller(CgroupCpuController* c, int upper_bound); private: static physical_memory_size_type get_updated_mem_limit(CgroupMemoryController* m, physical_memory_size_type lowest, diff --git a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index c8f5a290c99..e42b7a13391 100644 --- a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -326,8 +326,6 @@ CgroupV1Subsystem::CgroupV1Subsystem(CgroupV1Controller* cpuset, _cpuset(cpuset), _cpuacct(cpuacct), _pids(pids) { - CgroupUtil::adjust_controller(memory); - CgroupUtil::adjust_controller(cpu); _memory = new CachingCgroupController(memory); _cpu = new CachingCgroupController(cpu); } diff --git a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index 30e1affc646..edd80bb7427 100644 --- a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -154,8 +154,6 @@ CgroupV2Subsystem::CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuacctController* cpuacct, CgroupV2Controller unified) : _unified(unified) { - CgroupUtil::adjust_controller(memory); - CgroupUtil::adjust_controller(cpu); _memory = new CachingCgroupController(memory); _cpu = new CachingCgroupController(cpu); _cpuacct = cpuacct; diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp index 5472c093d3f..b065f7b1496 100644 --- a/src/hotspot/os/linux/hugepages.cpp +++ b/src/hotspot/os/linux/hugepages.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,11 +35,16 @@ #include ExplicitHugePageSupport::ExplicitHugePageSupport() : - _initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX), _inconsistent(false) {} + _initialized{false}, _os_supported{}, _pre_allocated{}, _default_hugepage_size{0}, _inconsistent{false} {} -os::PageSizes ExplicitHugePageSupport::pagesizes() const { +os::PageSizes ExplicitHugePageSupport::os_supported() const { assert(_initialized, "Not initialized"); - return _pagesizes; + return _os_supported; +} + +os::PageSizes ExplicitHugePageSupport::pre_allocated() const { + assert(_initialized, "Not initialized"); + return _pre_allocated; } size_t ExplicitHugePageSupport::default_hugepage_size() const { @@ -63,7 +68,7 @@ static size_t scan_default_hugepagesize() { // format has been changed), we'll set largest page size to 0 FILE *fp = os::fopen("/proc/meminfo", "r"); - if (fp) { + if (fp != nullptr) { while (!feof(fp)) { int x = 0; char buf[16]; @@ -76,7 +81,7 @@ static size_t scan_default_hugepagesize() { // skip to next line for (;;) { int ch = fgetc(fp); - if (ch == EOF || ch == (int)'\n') break; + if (ch == EOF || ch == '\n') break; } } } @@ -129,10 +134,24 @@ static os::PageSizes scan_hugepages() { return pagesizes; } +static os::PageSizes filter_pre_allocated_hugepages(os::PageSizes pagesizes) { + os::PageSizes pre_allocated{}; + char filename[PATH_MAX]; + for (size_t ps = pagesizes.smallest(); ps != 0; ps = pagesizes.next_larger(ps)) { + os::snprintf_checked(filename, sizeof(filename), "%s/hugepages-%zukB/nr_hugepages", sys_hugepages, ps / K); + size_t pages; + bool read_success = read_number_file(filename, &pages); + if (read_success && pages > 0) { + pre_allocated.add(ps); + } + } + return pre_allocated; +} + void ExplicitHugePageSupport::print_on(outputStream* os) { if (_initialized) { os->print_cr("Explicit hugepage support:"); - for (size_t s = _pagesizes.smallest(); s != 0; s = _pagesizes.next_larger(s)) { + for (size_t s = _os_supported.smallest(); s != 0; s = _os_supported.next_larger(s)) { os->print_cr(" hugepage size: " EXACTFMT, EXACTFMTARGS(s)); } os->print_cr(" default hugepage size: " EXACTFMT, EXACTFMTARGS(_default_hugepage_size)); @@ -147,14 +166,15 @@ void ExplicitHugePageSupport::print_on(outputStream* os) { void ExplicitHugePageSupport::scan_os() { _default_hugepage_size = scan_default_hugepagesize(); if (_default_hugepage_size > 0) { - _pagesizes = scan_hugepages(); + _os_supported = scan_hugepages(); + _pre_allocated = filter_pre_allocated_hugepages(_os_supported); // See https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt: /proc/meminfo should match // /sys/kernel/mm/hugepages/hugepages-xxxx. However, we may run on a broken kernel (e.g. on WSL) // that only exposes /proc/meminfo but not /sys/kernel/mm/hugepages. In that case, we are not // sure about the state of hugepage support by the kernel, so we won't use explicit hugepages. - if (!_pagesizes.contains(_default_hugepage_size)) { + if (!_os_supported.contains(_default_hugepage_size)) { log_info(pagesize)("Unexpected configuration: default pagesize (%zu) " - "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + "has no associated directory in /sys/kernel/mm/hugepages.", _default_hugepage_size); _inconsistent = true; } } @@ -167,7 +187,7 @@ void ExplicitHugePageSupport::scan_os() { } THPSupport::THPSupport() : - _initialized(false), _mode(THPMode::never), _pagesize(SIZE_MAX) {} + _initialized{false}, _mode{THPMode::never}, _pagesize{0} {} THPMode THPSupport::mode() const { @@ -201,7 +221,6 @@ void THPSupport::scan_os() { } // Scan large page size for THP from hpage_pmd_size - _pagesize = 0; if (read_number_file("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", &_pagesize)) { assert(_pagesize > 0, "Expected"); } diff --git a/src/hotspot/os/linux/hugepages.hpp b/src/hotspot/os/linux/hugepages.hpp index efd27c55fd6..5a9767b4ff8 100644 --- a/src/hotspot/os/linux/hugepages.hpp +++ b/src/hotspot/os/linux/hugepages.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,7 +45,10 @@ class ExplicitHugePageSupport { // All supported hugepage sizes (sizes for which entries exist // in /sys/kernel/mm/hugepages/hugepage-xxx) - os::PageSizes _pagesizes; + os::PageSizes _os_supported; + + // Above pages filtered for where the contents of file nr_hugepages was larger than zero + os::PageSizes _pre_allocated; // Contains the default hugepage. The "default hugepage size" is the one that // - is marked in /proc/meminfo as "Hugepagesize" @@ -60,7 +63,8 @@ public: void scan_os(); - os::PageSizes pagesizes() const; + os::PageSizes os_supported() const; + os::PageSizes pre_allocated() const; size_t default_hugepage_size() const; void print_on(outputStream* os); diff --git a/src/hotspot/os/linux/osContainer_linux.cpp b/src/hotspot/os/linux/osContainer_linux.cpp index b46263efd99..da2cbf381e6 100644 --- a/src/hotspot/os/linux/osContainer_linux.cpp +++ b/src/hotspot/os/linux/osContainer_linux.cpp @@ -59,6 +59,11 @@ void OSContainer::init() { if (cgroup_subsystem == nullptr) { return; // Required subsystem files not found or other error } + // Adjust controller paths once subsystem is initialized + physical_memory_size_type phys_mem = os::Linux::physical_memory(); + int host_cpus = os::Linux::active_processor_count(); + cgroup_subsystem->adjust_controllers(phys_mem, host_cpus); + /* * In order to avoid a false positive on is_containerized() on * Linux systems outside a container *and* to ensure compatibility @@ -252,7 +257,7 @@ char * OSContainer::cpu_cpuset_memory_nodes() { bool OSContainer::active_processor_count(double& value) { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); - return cgroup_subsystem->active_processor_count(value); + return cgroup_subsystem->active_processor_count(&os::Linux::active_processor_count, value); } bool OSContainer::cpu_quota(int& value) { diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 09c514e3d05..bf096897aa7 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -83,6 +83,7 @@ #endif # include +# include # include # include # include @@ -113,6 +114,7 @@ # include # include # include +# include # include #ifdef __GLIBC__ # include @@ -1311,7 +1313,7 @@ bool os::is_primordial_thread(void) { // Find the virtual memory area that contains addr static bool find_vma(address addr, address* vma_low, address* vma_high) { FILE *fp = os::fopen("/proc/self/maps", "r"); - if (fp) { + if (fp != nullptr) { address low, high; while (!feof(fp)) { if (fscanf(fp, "%p-%p", &low, &high) == 2) { @@ -1324,7 +1326,7 @@ static bool find_vma(address addr, address* vma_low, address* vma_high) { } for (;;) { int ch = fgetc(fp); - if (ch == EOF || ch == (int)'\n') break; + if (ch == EOF || ch == '\n') break; } } fclose(fp); @@ -2161,6 +2163,8 @@ void os::print_os_info(outputStream* st) { os::Posix::print_rlimit_info(st); + os::print_open_file_descriptors(st); + os::Posix::print_load_average(st); st->cr(); @@ -3814,8 +3818,8 @@ static int hugetlbfs_page_size_flag(size_t page_size) { } static bool hugetlbfs_sanity_check(size_t page_size) { - const os::PageSizes page_sizes = HugePages::explicit_hugepage_info().pagesizes(); - assert(page_sizes.contains(page_size), "Invalid page sizes passed"); + const os::PageSizes os_supported = HugePages::explicit_hugepage_info().os_supported(); + assert(os_supported.contains(page_size), "Invalid page sizes passed (%zu)", page_size); // Include the page size flag to ensure we sanity check the correct page size. int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB | hugetlbfs_page_size_flag(page_size); @@ -3829,16 +3833,16 @@ static bool hugetlbfs_sanity_check(size_t page_size) { log_info(pagesize)("Large page size (" EXACTFMT ") failed sanity check, " "checking if smaller large page sizes are usable", EXACTFMTARGS(page_size)); - for (size_t page_size_ = page_sizes.next_smaller(page_size); - page_size_ > os::vm_page_size(); - page_size_ = page_sizes.next_smaller(page_size_)) { - flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB | hugetlbfs_page_size_flag(page_size_); - p = mmap(nullptr, page_size_, PROT_READ|PROT_WRITE, flags, -1, 0); + for (size_t size = os_supported.next_smaller(page_size); + size > os::vm_page_size(); + size = os_supported.next_smaller(size)) { + flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB | hugetlbfs_page_size_flag(size); + p = mmap(nullptr, size, PROT_READ|PROT_WRITE, flags, -1, 0); if (p != MAP_FAILED) { // Mapping succeeded, sanity check passed. - munmap(p, page_size_); + munmap(p, size); log_info(pagesize)("Large page size (" EXACTFMT ") passed sanity check", - EXACTFMTARGS(page_size_)); + EXACTFMTARGS(size)); return true; } } @@ -4020,7 +4024,7 @@ void os::Linux::large_page_init() { // - os::large_page_size() is the default explicit hugepage size (/proc/meminfo "Hugepagesize") // - os::pagesizes() contains all hugepage sizes the kernel supports, regardless whether there // are pages configured in the pool or not (from /sys/kernel/hugepages/hugepage-xxxx ...) - os::PageSizes all_large_pages = HugePages::explicit_hugepage_info().pagesizes(); + os::PageSizes all_large_pages = HugePages::explicit_hugepage_info().os_supported(); const size_t default_large_page_size = HugePages::default_explicit_hugepage_size(); // 3) Consistency check and post-processing @@ -4062,10 +4066,10 @@ void os::Linux::large_page_init() { _large_page_size = large_page_size; - // Populate _page_sizes with large page sizes less than or equal to - // _large_page_size. - for (size_t page_size = _large_page_size; page_size != 0; - page_size = all_large_pages.next_smaller(page_size)) { + // Populate _page_sizes with _large_page_size (default large page size) even if not pre-allocated. + // Then, populate _page_sizes with all smaller large page sizes that have been pre-allocated. + os::PageSizes pre_allocated = HugePages::explicit_hugepage_info().pre_allocated(); + for (size_t page_size = _large_page_size; page_size != 0; page_size = pre_allocated.next_smaller(page_size)) { _page_sizes.add(page_size); } } @@ -4129,12 +4133,12 @@ static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t page_size, char* req_addr, bool exec) { - const os::PageSizes page_sizes = HugePages::explicit_hugepage_info().pagesizes(); + const os::PageSizes os_supported = HugePages::explicit_hugepage_info().os_supported(); assert(UseLargePages, "only for Huge TLBFS large pages"); assert(is_aligned(req_addr, alignment), "Must be"); assert(is_aligned(req_addr, page_size), "Must be"); assert(is_aligned(alignment, os::vm_allocation_granularity()), "Must be"); - assert(page_sizes.contains(page_size), "Must be a valid page size"); + assert(os_supported.contains(page_size), "Must be a valid page size"); assert(page_size > os::vm_page_size(), "Must be a large page size"); assert(bytes >= page_size, "Shouldn't allocate large pages for small sizes"); @@ -4208,12 +4212,6 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ return addr; } -bool os::pd_release_memory_special(char* base, size_t bytes) { - assert(UseLargePages, "only for large pages"); - // Plain munmap is sufficient - return pd_release_memory(base, bytes); -} - size_t os::large_page_size() { return _large_page_size; } @@ -4386,7 +4384,7 @@ int os::Linux::get_namespace_pid(int vmid) { os::snprintf_checked(fname, sizeof(fname), "/proc/%d/status", vmid); FILE *fp = os::fopen(fname, "r"); - if (fp) { + if (fp != nullptr) { int pid, nspid; int ret; while (!feof(fp) && !ferror(fp)) { @@ -4400,7 +4398,7 @@ int os::Linux::get_namespace_pid(int vmid) { } for (;;) { int ch = fgetc(fp); - if (ch == EOF || ch == (int)'\n') break; + if (ch == EOF || ch == '\n') break; } } fclose(fp); @@ -4555,6 +4553,7 @@ void os::Linux::numa_init() { FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true); } +#if INCLUDE_PARALLELGC if (UseParallelGC && UseNUMA && UseLargePages && !can_commit_large_page_memory()) { // With static large pages we cannot uncommit a page, so there's no way // we can make the adaptive lgrp chunk resizing work. If the user specified both @@ -4566,6 +4565,7 @@ void os::Linux::numa_init() { UseAdaptiveNUMAChunkSizing = false; } } +#endif } void os::Linux::disable_numa(const char* reason, bool warning) { @@ -5433,3 +5433,31 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) { return res; } // end: os::pd_dll_unload() + +void os::print_open_file_descriptors(outputStream* st) { + DIR* dirp = opendir("/proc/self/fd"); + int fds = 0; + struct dirent* dentp; + const jlong TIMEOUT_NS = 50000000L; // 50 ms in nanoseconds + bool timed_out = false; + + // limit proc file read to 50ms + jlong start = os::javaTimeNanos(); + assert(dirp != nullptr, "No proc fs?"); + while ((dentp = readdir(dirp)) != nullptr && !timed_out) { + if (isdigit(dentp->d_name[0])) fds++; + if (fds % 100 == 0) { + jlong now = os::javaTimeNanos(); + if ((now - start) > TIMEOUT_NS) { + timed_out = true; + } + } + } + + closedir(dirp); + if (timed_out) { + st->print_cr("Open File Descriptors: > %d", fds); + } else { + st->print_cr("Open File Descriptors: %d", fds); + } +} diff --git a/src/hotspot/os/posix/dtrace/hotspot_jni.d b/src/hotspot/os/posix/dtrace/hotspot_jni.d index c5676921b37..1937769dcb2 100644 --- a/src/hotspot/os/posix/dtrace/hotspot_jni.d +++ b/src/hotspot/os/posix/dtrace/hotspot_jni.d @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -366,6 +366,8 @@ provider hotspot_jni { probe IsInstanceOf__return(uintptr_t); probe IsSameObject__entry(void*, void*, void*); probe IsSameObject__return(uintptr_t); + probe IsVirtualThread__entry(void*, void*); + probe IsVirtualThread__return(uintptr_t); probe MonitorEnter__entry(void*, void*); probe MonitorEnter__return(uint32_t); probe MonitorExit__entry(void*, void*); diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 5412e2bc92d..1fb2a248bec 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -888,6 +888,14 @@ void* os::lookup_function(const char* name) { return dlsym(RTLD_DEFAULT, name); } +int64_t os::ftell(FILE* file) { + return ::ftell(file); +} + +int os::fseek(FILE* file, int64_t offset, int whence) { + return ::fseek(file, offset, whence); +} + jlong os::lseek(int fd, jlong offset, int whence) { return (jlong) ::lseek(fd, offset, whence); } @@ -906,8 +914,25 @@ FILE* os::fdopen(int fd, const char* mode) { ssize_t os::pd_write(int fd, const void *buf, size_t nBytes) { ssize_t res; +#ifdef __APPLE__ + // macOS fails for individual write operations > 2GB. + // See https://gitlab.haskell.org/ghc/ghc/-/issues/17414 + ssize_t total = 0; + while (nBytes > 0) { + size_t bytes_to_write = MIN2(nBytes, (size_t)INT_MAX); + RESTARTABLE(::write(fd, buf, bytes_to_write), res); + if (res == OS_ERR) { + return OS_ERR; + } + buf = (const char*)buf + res; + nBytes -= res; + total += res; + } + return total; +#else RESTARTABLE(::write(fd, buf, nBytes), res); return res; +#endif } ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) { diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp index ce9c2a4f031..b8be77c5e05 100644 --- a/src/hotspot/os/posix/perfMemory_posix.cpp +++ b/src/hotspot/os/posix/perfMemory_posix.cpp @@ -494,6 +494,7 @@ static char* get_user_name(uid_t uid) { return user_name; } +#ifndef __APPLE__ // return the name of the user that owns the process identified by vmid. // // This method uses a slow directory search algorithm to find the backing @@ -657,6 +658,7 @@ static char* get_user_name(int vmid, int *nspid, TRAPS) { #endif return result; } +#endif // return the file name of the backing store file for the named // shared memory region for the given user name and vmid. @@ -1082,18 +1084,9 @@ static char* mmap_create_shared(size_t size) { // release a named shared memory region that was mmap-ed. // static void unmap_shared(char* addr, size_t bytes) { - int res; - if (MemTracker::enabled()) { - MemTracker::NmtVirtualMemoryLocker nvml; - res = ::munmap(addr, bytes); - if (res == 0) { - MemTracker::record_virtual_memory_release(addr, bytes); - } - } else { - res = ::munmap(addr, bytes); - } - if (res != 0) { - log_info(os)("os::release_memory failed (" PTR_FORMAT ", %zu)", p2i(addr), bytes); + MemTracker::record_virtual_memory_release(addr, bytes); + if (::munmap(addr, bytes) != 0) { + fatal("os::release_memory failed (" PTR_FORMAT ", %zu)", p2i(addr), bytes); } } diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 2e819e26e37..18d047348cb 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -3517,11 +3517,6 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ return reserve_large_pages(bytes, addr, exec); } -bool os::pd_release_memory_special(char* base, size_t bytes) { - assert(base != nullptr, "Sanity check"); - return pd_release_memory(base, bytes); -} - static void warn_fail_commit_memory(char* addr, size_t bytes, bool exec) { int err = os::get_last_error(); char buf[256]; @@ -5119,6 +5114,13 @@ jlong os::seek_to_file_offset(int fd, jlong offset) { return (jlong)::_lseeki64(fd, (__int64)offset, SEEK_SET); } +int64_t os::ftell(FILE* file) { + return ::_ftelli64(file); +} + +int os::fseek(FILE* file, int64_t offset, int whence) { + return ::_fseeki64(file,offset, whence); +} jlong os::lseek(int fd, jlong offset, int whence) { return (jlong) ::_lseeki64(fd, offset, whence); @@ -6281,6 +6283,10 @@ const void* os::get_saved_assert_context(const void** sigInfo) { return nullptr; } +void os::print_open_file_descriptors(outputStream* st) { + // File descriptor counting not supported on Windows. +} + /* * Windows/x64 does not use stack frames the way expected by Java: * [1] in most cases, there is no frame pointer. All locals are addressed via RSP diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp index f54a2b52cca..dad2804f18a 100644 --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -1682,12 +1682,7 @@ void PerfMemory::detach(char* addr, size_t bytes) { return; } - if (MemTracker::enabled()) { - // it does not go through os api, the operation has to record from here - MemTracker::NmtVirtualMemoryLocker nvml; - remove_file_mapping(addr); - MemTracker::record_virtual_memory_release(addr, bytes); - } else { - remove_file_mapping(addr); - } + // it does not go through os api, the operation has to record from here + MemTracker::record_virtual_memory_release(addr, bytes); + remove_file_mapping(addr); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodDataInterface.java b/src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp similarity index 66% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodDataInterface.java rename to src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp index 8e6b131ee9d..8cc8b715201 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodDataInterface.java +++ b/src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. 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,18 +23,14 @@ * */ -package sun.jvm.hotspot.oops; +#include "runtime/vm_version.hpp" -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +#include -public interface MethodDataInterface { - K getKlassAtAddress(Address addr); - M getMethodAtAddress(Address addr); - void printKlassValueOn(K klass, PrintStream st); - void printMethodValueOn(M klass, PrintStream st); +int VM_Version::get_dcache_line_size() { + return _system_configuration.dcache_line; +} + +int VM_Version::get_icache_line_size() { + return _system_configuration.icache_line; } diff --git a/src/hotspot/os_cpu/bsd_zero/atomicAccess_bsd_zero.hpp b/src/hotspot/os_cpu/bsd_zero/atomicAccess_bsd_zero.hpp index 6c8684718fc..8e45490e5b6 100644 --- a/src/hotspot/os_cpu/bsd_zero/atomicAccess_bsd_zero.hpp +++ b/src/hotspot/os_cpu/bsd_zero/atomicAccess_bsd_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2011, 2015, Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,6 @@ #define OS_CPU_BSD_ZERO_ATOMICACCESS_BSD_ZERO_HPP #include "orderAccess_bsd_zero.hpp" -#include "runtime/os.hpp" // Implementation of class AtomicAccess diff --git a/src/hotspot/os_cpu/linux_arm/atomicAccess_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/atomicAccess_linux_arm.hpp index 390207f9e5e..c03f5ed1c8b 100644 --- a/src/hotspot/os_cpu/linux_arm/atomicAccess_linux_arm.hpp +++ b/src/hotspot/os_cpu/linux_arm/atomicAccess_linux_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,6 @@ #define OS_CPU_LINUX_ARM_ATOMICACCESS_LINUX_ARM_HPP #include "memory/allStatic.hpp" -#include "runtime/os.hpp" -#include "runtime/vm_version.hpp" // Implementation of class AtomicAccess diff --git a/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp index 3bb357704fb..49c6942b8e0 100644 --- a/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp +++ b/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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,7 +27,6 @@ // Included in orderAccess.hpp header file. -#include "runtime/os.hpp" #include "runtime/vm_version.hpp" // Implementation of class OrderAccess. diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntriesAtCall.java b/src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp similarity index 52% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntriesAtCall.java rename to src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp index 2891f91c69e..d64340edf5c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntriesAtCall.java +++ b/src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. 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,33 +23,22 @@ * */ -package sun.jvm.hotspot.oops; +#include "runtime/vm_version.hpp" -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +#include -// Entries to collect type information at a call: contains arguments -// (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a -// number of cells. -public abstract class TypeEntriesAtCall { - - static int stackSlotLocalOffset(int i) { - return headerCellCount() + TypeStackSlotEntries.stackSlotLocalOffset(i); - } - - static int argumentTypeLocalOffset(int i) { - return headerCellCount() + TypeStackSlotEntries.typeLocalOffset(i); - } - - static int headerCellCount() { - return 1; - } - - static int cellCountLocalOffset() { - return 0; - } +int VM_Version::get_dcache_line_size() { + // This should work on all modern linux versions: + int size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + // It may fail with very old linux / glibc versions. We use DEFAULT_CACHE_LINE_SIZE in this case. + // That is the correct value for all currently supported processors. + return (size <= 0) ? DEFAULT_CACHE_LINE_SIZE : size; +} + +int VM_Version::get_icache_line_size() { + // This should work on all modern linux versions: + int size = sysconf(_SC_LEVEL1_ICACHE_LINESIZE); + // It may fail with very old linux / glibc versions. We use DEFAULT_CACHE_LINE_SIZE in this case. + // That is the correct value for all currently supported processors. + return (size <= 0) ? DEFAULT_CACHE_LINE_SIZE : size; } diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 35cbb75e8ff..648131b94a3 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -36,40 +36,42 @@ #include #include +static constexpr uint64_t feature_bit(int n) { return nth_bit(n); } + #ifndef HWCAP_ISA_I -#define HWCAP_ISA_I nth_bit('I' - 'A') +#define HWCAP_ISA_I feature_bit('I' - 'A') #endif #ifndef HWCAP_ISA_M -#define HWCAP_ISA_M nth_bit('M' - 'A') +#define HWCAP_ISA_M feature_bit('M' - 'A') #endif #ifndef HWCAP_ISA_A -#define HWCAP_ISA_A nth_bit('A' - 'A') +#define HWCAP_ISA_A feature_bit('A' - 'A') #endif #ifndef HWCAP_ISA_F -#define HWCAP_ISA_F nth_bit('F' - 'A') +#define HWCAP_ISA_F feature_bit('F' - 'A') #endif #ifndef HWCAP_ISA_D -#define HWCAP_ISA_D nth_bit('D' - 'A') +#define HWCAP_ISA_D feature_bit('D' - 'A') #endif #ifndef HWCAP_ISA_C -#define HWCAP_ISA_C nth_bit('C' - 'A') +#define HWCAP_ISA_C feature_bit('C' - 'A') #endif #ifndef HWCAP_ISA_Q -#define HWCAP_ISA_Q nth_bit('Q' - 'A') +#define HWCAP_ISA_Q feature_bit('Q' - 'A') #endif #ifndef HWCAP_ISA_H -#define HWCAP_ISA_H nth_bit('H' - 'A') +#define HWCAP_ISA_H feature_bit('H' - 'A') #endif #ifndef HWCAP_ISA_V -#define HWCAP_ISA_V nth_bit('V' - 'A') +#define HWCAP_ISA_V feature_bit('V' - 'A') #endif #define read_csr(csr) \ diff --git a/src/hotspot/os_cpu/linux_s390/atomicAccess_linux_s390.hpp b/src/hotspot/os_cpu/linux_s390/atomicAccess_linux_s390.hpp index f3c1e8f1a2c..492ccf73bdf 100644 --- a/src/hotspot/os_cpu/linux_s390/atomicAccess_linux_s390.hpp +++ b/src/hotspot/os_cpu/linux_s390/atomicAccess_linux_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,10 +26,6 @@ #ifndef OS_CPU_LINUX_S390_ATOMICACCESS_LINUX_S390_HPP #define OS_CPU_LINUX_S390_ATOMICACCESS_LINUX_S390_HPP -#include "runtime/atomicAccess.hpp" -#include "runtime/os.hpp" -#include "runtime/vm_version.hpp" - // Note that the compare-and-swap instructions on System z perform // a serialization function before the storage operand is fetched // and again after the operation is completed. diff --git a/src/hotspot/os_cpu/windows_aarch64/atomicAccess_windows_aarch64.hpp b/src/hotspot/os_cpu/windows_aarch64/atomicAccess_windows_aarch64.hpp index f8119654c50..9238043f7a4 100644 --- a/src/hotspot/os_cpu/windows_aarch64/atomicAccess_windows_aarch64.hpp +++ b/src/hotspot/os_cpu/windows_aarch64/atomicAccess_windows_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Microsoft Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,9 +27,7 @@ #define OS_CPU_WINDOWS_AARCH64_ATOMICACCESS_WINDOWS_AARCH64_HPP #include -#include "runtime/os.hpp" -#include "runtime/vm_version.hpp" - +#include // As per atomicAccess.hpp all read-modify-write operations have to provide two-way // barriers semantics. The memory_order parameter is ignored - we always provide diff --git a/src/hotspot/os_cpu/windows_aarch64/vm_version_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/vm_version_windows_aarch64.cpp index a20feadcba4..93beb549366 100644 --- a/src/hotspot/os_cpu/windows_aarch64/vm_version_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/vm_version_windows_aarch64.cpp @@ -27,22 +27,30 @@ #include "runtime/vm_version.hpp" int VM_Version::get_current_sve_vector_length() { - assert(_features & CPU_SVE, "should not call this"); + assert(VM_Version::supports_sve(), "should not call this"); ShouldNotReachHere(); return 0; } int VM_Version::set_and_get_current_sve_vector_length(int length) { - assert(_features & CPU_SVE, "should not call this"); + assert(VM_Version::supports_sve(), "should not call this"); ShouldNotReachHere(); return 0; } void VM_Version::get_os_cpu_info() { - if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE)) _features |= CPU_CRC32; - if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)) _features |= CPU_AES | CPU_SHA1 | CPU_SHA2; - if (IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE)) _features |= CPU_ASIMD; + if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE)) { + set_feature(CPU_CRC32); + } + if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)) { + set_feature(CPU_AES); + set_feature(CPU_SHA1); + set_feature(CPU_SHA2); + } + if (IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE)) { + set_feature(CPU_ASIMD); + } // No check for CPU_PMULL, CPU_SVE, CPU_SVE2 __int64 dczid_el0 = _ReadStatusReg(0x5807 /* ARM64_DCZID_EL0 */); diff --git a/src/hotspot/os_cpu/windows_x86/atomicAccess_windows_x86.hpp b/src/hotspot/os_cpu/windows_x86/atomicAccess_windows_x86.hpp index aa78a401235..252411f62bc 100644 --- a/src/hotspot/os_cpu/windows_x86/atomicAccess_windows_x86.hpp +++ b/src/hotspot/os_cpu/windows_x86/atomicAccess_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #define OS_CPU_WINDOWS_X86_ATOMICACCESS_WINDOWS_X86_HPP #include -#include "runtime/os.hpp" +#include // Note that in MSVC, volatile memory accesses are explicitly // guaranteed to have acquire release semantics (w.r.t. compiler diff --git a/src/hotspot/share/adlc/adlparse.cpp b/src/hotspot/share/adlc/adlparse.cpp index 356c24760e8..b49efa34be8 100644 --- a/src/hotspot/share/adlc/adlparse.cpp +++ b/src/hotspot/share/adlc/adlparse.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -993,9 +993,6 @@ void ADLParser::frame_parse(void) { if (strcmp(token,"frame_pointer")==0) { frame_pointer_parse(frame, false); } - if (strcmp(token,"interpreter_frame_pointer")==0) { - interpreter_frame_pointer_parse(frame, false); - } if (strcmp(token,"inline_cache_reg")==0) { inline_cache_parse(frame, false); } @@ -1119,11 +1116,6 @@ void ADLParser::frame_pointer_parse(FrameForm *frame, bool native) { else { frame->_frame_pointer = frame_pointer; } } -//------------------------------interpreter_frame_pointer_parse---------------------------- -void ADLParser::interpreter_frame_pointer_parse(FrameForm *frame, bool native) { - frame->_interpreter_frame_pointer_reg = parse_one_arg("interpreter frame pointer entry"); -} - //------------------------------inline_cache_parse----------------------------- void ADLParser::inline_cache_parse(FrameForm *frame, bool native) { frame->_inline_cache_reg = parse_one_arg("inline cache reg entry"); diff --git a/src/hotspot/share/adlc/adlparse.hpp b/src/hotspot/share/adlc/adlparse.hpp index 02baec53262..89296193612 100644 --- a/src/hotspot/share/adlc/adlparse.hpp +++ b/src/hotspot/share/adlc/adlparse.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -120,7 +120,6 @@ protected: // Parse the components of the frame section void sync_stack_slots_parse(FrameForm *frame); void frame_pointer_parse(FrameForm *frame, bool native); - void interpreter_frame_pointer_parse(FrameForm *frame, bool native); void inline_cache_parse(FrameForm *frame, bool native); void interpreter_arg_ptr_parse(FrameForm *frame, bool native); void interpreter_method_parse(FrameForm *frame, bool native); diff --git a/src/hotspot/share/adlc/formsopt.cpp b/src/hotspot/share/adlc/formsopt.cpp index fbd1043492e..091e34f40f4 100644 --- a/src/hotspot/share/adlc/formsopt.cpp +++ b/src/hotspot/share/adlc/formsopt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -476,7 +476,6 @@ void AllocClass::forms_do(FormClosure* f) { FrameForm::FrameForm() { _sync_stack_slots = nullptr; _inline_cache_reg = nullptr; - _interpreter_frame_pointer_reg = nullptr; _cisc_spilling_operand_name = nullptr; _frame_pointer = nullptr; _c_frame_pointer = nullptr; diff --git a/src/hotspot/share/adlc/formsopt.hpp b/src/hotspot/share/adlc/formsopt.hpp index 9e0c9db854d..087ab1e2653 100644 --- a/src/hotspot/share/adlc/formsopt.hpp +++ b/src/hotspot/share/adlc/formsopt.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -347,7 +347,6 @@ public: // Public Data char *_sync_stack_slots; char *_inline_cache_reg; - char *_interpreter_frame_pointer_reg; char *_cisc_spilling_operand_name; char *_frame_pointer; char *_c_frame_pointer; diff --git a/src/hotspot/share/adlc/formssel.cpp b/src/hotspot/share/adlc/formssel.cpp index 182587d2f2f..4dd2bff7c89 100644 --- a/src/hotspot/share/adlc/formssel.cpp +++ b/src/hotspot/share/adlc/formssel.cpp @@ -4276,7 +4276,9 @@ bool MatchRule::is_ideal_membar() const { !strcmp(_opType,"LoadFence" ) || !strcmp(_opType,"StoreFence") || !strcmp(_opType,"StoreStoreFence") || + !strcmp(_opType,"MemBarStoreLoad") || !strcmp(_opType,"MemBarVolatile") || + !strcmp(_opType,"MemBarFull") || !strcmp(_opType,"MemBarCPUOrder") || !strcmp(_opType,"MemBarStoreStore") || !strcmp(_opType,"OnSpinWait"); diff --git a/src/hotspot/share/adlc/main.cpp b/src/hotspot/share/adlc/main.cpp index 4e8a96617e8..8e6ea5bbec9 100644 --- a/src/hotspot/share/adlc/main.cpp +++ b/src/hotspot/share/adlc/main.cpp @@ -213,6 +213,7 @@ int main(int argc, char *argv[]) AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._VM_file._name)); AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._HPP_file._name)); AD.addInclude(AD._CPP_file, "memory/allocation.inline.hpp"); + AD.addInclude(AD._CPP_file, "code/aotCodeCache.hpp"); AD.addInclude(AD._CPP_file, "code/codeCache.hpp"); AD.addInclude(AD._CPP_file, "code/compiledIC.hpp"); AD.addInclude(AD._CPP_file, "code/nativeInst.hpp"); @@ -257,6 +258,7 @@ int main(int argc, char *argv[]) AD.addInclude(AD._CPP_PEEPHOLE_file, "adfiles", get_basename(AD._HPP_file._name)); AD.addInclude(AD._CPP_PIPELINE_file, "adfiles", get_basename(AD._HPP_file._name)); AD.addInclude(AD._DFA_file, "adfiles", get_basename(AD._HPP_file._name)); + AD.addInclude(AD._DFA_file, "code/aotCodeCache.hpp"); AD.addInclude(AD._DFA_file, "oops/compressedOops.hpp"); AD.addInclude(AD._DFA_file, "opto/cfgnode.hpp"); // Use PROB_MAX in predicate. AD.addInclude(AD._DFA_file, "opto/intrinsicnode.hpp"); diff --git a/src/hotspot/share/adlc/output_c.cpp b/src/hotspot/share/adlc/output_c.cpp index 9cbd6aaf66f..45b3d6bda63 100644 --- a/src/hotspot/share/adlc/output_c.cpp +++ b/src/hotspot/share/adlc/output_c.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -4212,14 +4212,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) { fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {"); fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n"); - // Interpreter's Frame Pointer Register - fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {"); - if (_frame->_interpreter_frame_pointer_reg == nullptr) - fprintf(fp_cpp," return OptoReg::Bad; }\n\n"); - else - fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", - _frame->_interpreter_frame_pointer_reg); - // Frame Pointer definition /* CNC - I can not contemplate having a different frame pointer between Java and native code; makes my head hurt to think about it. diff --git a/src/hotspot/share/asm/register.hpp b/src/hotspot/share/asm/register.hpp index f406995b8ac..95c7c7922cf 100644 --- a/src/hotspot/share/asm/register.hpp +++ b/src/hotspot/share/asm/register.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,15 +49,7 @@ class AbstractRegisterImpl { // Macros to help define all kinds of registers -#ifndef USE_POINTERS_TO_REGISTER_IMPL_ARRAY - -#define AS_REGISTER(type,name) ((type)name##_##type##EnumValue) - -#define CONSTANT_REGISTER_DECLARATION(type, name, value) \ -const type name = ((type)value); \ -enum { name##_##type##EnumValue = (value) } - -#else // USE_POINTERS_TO_REGISTER_IMPL_ARRAY +#ifdef USE_POINTERS_TO_REGISTER_IMPL_ARRAY #define REGISTER_IMPL_DECLARATION(type, impl_type, reg_count) \ inline constexpr type as_ ## type(int encoding) { \ @@ -69,16 +61,8 @@ inline constexpr type impl_type::first() { return all_ ## type ## s + 1; } #define REGISTER_IMPL_DEFINITION(type, impl_type, reg_count) \ impl_type all_ ## type ## s[reg_count + 1]; -#define CONSTANT_REGISTER_DECLARATION(type, name, value) \ -constexpr type name = as_ ## type(value); - #endif // USE_POINTERS_TO_REGISTER_IMPL_ARRAY - -#define REGISTER_DECLARATION(type, name, value) \ -const type name = ((type)value) - - // For definitions of RegisterImpl* instances. To be redefined in an // OS-specific way. #ifdef __GNUC__ diff --git a/src/hotspot/share/cds/aotArtifactFinder.cpp b/src/hotspot/share/cds/aotArtifactFinder.cpp index f85f1e46520..bd69b18a1aa 100644 --- a/src/hotspot/share/cds/aotArtifactFinder.cpp +++ b/src/hotspot/share/cds/aotArtifactFinder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +32,7 @@ #include "cds/lambdaProxyClassDictionary.hpp" #include "cds/regeneratedClasses.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "logging/log.hpp" #include "memory/metaspaceClosure.hpp" #include "oops/instanceKlass.hpp" @@ -169,6 +170,7 @@ void AOTArtifactFinder::find_artifacts() { end_scanning_for_oops(); TrainingData::cleanup_training_data(); + check_critical_classes(); } void AOTArtifactFinder::start_scanning_for_oops() { @@ -233,6 +235,7 @@ void AOTArtifactFinder::add_cached_instance_class(InstanceKlass* ik) { bool created; _seen_classes->put_if_absent(ik, &created); if (created) { + check_critical_class(ik); append_to_all_cached_classes(ik); // All super types must be added. @@ -310,3 +313,25 @@ void AOTArtifactFinder::all_cached_classes_do(MetaspaceClosure* it) { it->push(_all_cached_classes->adr_at(i)); } } + +void AOTArtifactFinder::check_critical_classes() { + if (CDSConfig::is_dumping_static_archive()) { + // vmClasses are store in the AOT cache (or AOT config file, or static archive). + // If any of the vmClasses is excluded, (usually due to incompatible JVMTI agent), + // the resulting cache/config/archive is unusable. + for (auto id : EnumRange{}) { + check_critical_class(vmClasses::klass_at(id)); + } + } +} + +void AOTArtifactFinder::check_critical_class(InstanceKlass* ik) { + if (SystemDictionaryShared::is_excluded_class(ik)) { + ResourceMark rm; + const char* msg = err_msg("Critical class %s has been excluded. %s cannot be written.", + ik->external_name(), + CDSConfig::type_of_archive_being_written()); + AOTMetaspace::unrecoverable_writing_error(msg); + } +} + diff --git a/src/hotspot/share/cds/aotArtifactFinder.hpp b/src/hotspot/share/cds/aotArtifactFinder.hpp index 05bcde6b0ac..50057b6caee 100644 --- a/src/hotspot/share/cds/aotArtifactFinder.hpp +++ b/src/hotspot/share/cds/aotArtifactFinder.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -81,12 +81,14 @@ class AOTArtifactFinder : AllStatic { static void add_cached_type_array_class(TypeArrayKlass* tak); static void add_cached_instance_class(InstanceKlass* ik); static void append_to_all_cached_classes(Klass* k); + static void check_critical_class(InstanceKlass* ik); public: static void initialize(); static void find_artifacts(); static void add_cached_class(Klass* k); static void add_aot_inited_class(InstanceKlass* ik); static void all_cached_classes_do(MetaspaceClosure* it); + static void check_critical_classes(); static void dispose(); }; diff --git a/src/hotspot/share/cds/aotClassInitializer.cpp b/src/hotspot/share/cds/aotClassInitializer.cpp index 06fc3af6f30..41fdeb537cc 100644 --- a/src/hotspot/share/cds/aotClassInitializer.cpp +++ b/src/hotspot/share/cds/aotClassInitializer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -234,7 +234,8 @@ bool AOTClassInitializer::can_archive_initialized_mirror(InstanceKlass* ik) { } void AOTClassInitializer::call_runtime_setup(JavaThread* current, InstanceKlass* ik) { - assert(ik->has_aot_initialized_mirror(), "sanity"); + precond(ik->has_aot_initialized_mirror()); + precond(!AOTLinkedClassBulkLoader::is_initializing_classes_early()); if (ik->is_runtime_setup_required()) { if (log_is_enabled(Info, aot, init)) { ResourceMark rm; diff --git a/src/hotspot/share/cds/aotClassLocation.cpp b/src/hotspot/share/cds/aotClassLocation.cpp index f77aac3540c..9275b914ef9 100644 --- a/src/hotspot/share/cds/aotClassLocation.cpp +++ b/src/hotspot/share/cds/aotClassLocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -426,7 +426,8 @@ bool AOTClassLocation::check(const char* runtime_path, bool has_aot_linked_class bool size_differs = _filesize != st.st_size; bool time_differs = _check_time && (_timestamp != st.st_mtime); if (size_differs || time_differs) { - aot_log_warning(aot)("This file is not the one used while building the shared archive file: '%s'%s%s", + aot_log_warning(aot)("This file is not the one used while building the %s: '%s'%s%s", + CDSConfig::type_of_archive_being_loaded(), runtime_path, time_differs ? ", timestamp has changed" : "", size_differs ? ", size has changed" : ""); @@ -448,6 +449,13 @@ void AOTClassLocationConfig::dumptime_init(JavaThread* current) { java_lang_Throwable::print(current->pending_exception(), tty); vm_exit_during_initialization("AOTClassLocationConfig::dumptime_init_helper() failed unexpectedly"); } + + if (CDSConfig::is_dumping_final_static_archive()) { + // The _max_used_index is usually updated by ClassLoader::record_result(). However, + // when dumping the final archive, the classes are loaded from their images in + // the AOT config file, so we don't go through ClassLoader::record_result(). + dumptime_update_max_used_index(runtime()->_max_used_index); // Same value as recorded in the training run. + } } void AOTClassLocationConfig::dumptime_init_helper(TRAPS) { diff --git a/src/hotspot/share/cds/aotCompressedPointers.hpp b/src/hotspot/share/cds/aotCompressedPointers.hpp index ead48ef9948..a3919fb95a9 100644 --- a/src/hotspot/share/cds/aotCompressedPointers.hpp +++ b/src/hotspot/share/cds/aotCompressedPointers.hpp @@ -36,16 +36,17 @@ class AOTCompressedPointers: public AllStatic { public: // For space saving, we can encode the location of metadata objects in the "rw" and "ro" - // regions using a 32-bit offset from the bottom of the mapped AOT metaspace. - // Currently we allow only up to 2GB total size in the rw and ro regions (which are - // contiguous to each other). + // regions using a 32-bit offset from the bottom of the mapped AOT metaspace. Since metadata + // objects are 8-byte aligned, we store scaled offset units (offset_bytes >> 3) to address + // up to ~32GB on 64-bit platforms. We currently limit the MaxMetadataOffsetBytes to about + // 3.5 GB to be compatible with +CompactObjectHeaders. enum class narrowPtr : u4; - static constexpr size_t MaxMetadataOffsetBytes = 0x7FFFFFFF; + static constexpr size_t MetadataOffsetShift = LP64_ONLY(3) NOT_LP64(0); + static constexpr size_t MaxMetadataOffsetBytes = LP64_ONLY(3584ULL * M) NOT_LP64(0x7FFFFFFF); - // In the future, this could return a different numerical value than - // narrowp if the encoding contains shifts. + // Convert the encoded narrowPtr to a byte offset by applying the shift. inline static size_t get_byte_offset(narrowPtr narrowp) { - return checked_cast(narrowp); + return ((size_t)checked_cast(narrowp)) << MetadataOffsetShift; } inline static narrowPtr null() { @@ -122,7 +123,8 @@ private: static narrowPtr encode_byte_offset(size_t offset) { assert(offset != 0, "offset 0 is in protection zone"); precond(offset <= MaxMetadataOffsetBytes); - return checked_cast(offset); + assert(is_aligned(offset, (size_t)1 << MetadataOffsetShift), "offset not aligned"); + return checked_cast(offset >> MetadataOffsetShift); } }; diff --git a/src/hotspot/share/cds/aotConstantPoolResolver.cpp b/src/hotspot/share/cds/aotConstantPoolResolver.cpp index 93145940955..f1a704d4bee 100644 --- a/src/hotspot/share/cds/aotConstantPoolResolver.cpp +++ b/src/hotspot/share/cds/aotConstantPoolResolver.cpp @@ -81,6 +81,7 @@ bool AOTConstantPoolResolver::is_resolution_deterministic(ConstantPool* cp, int bool AOTConstantPoolResolver::is_class_resolution_deterministic(InstanceKlass* cp_holder, Klass* resolved_class) { assert(!is_in_archivebuilder_buffer(cp_holder), "sanity"); assert(!is_in_archivebuilder_buffer(resolved_class), "sanity"); + assert_at_safepoint(); // try_add_candidate() is called below and requires to be at safepoint. if (resolved_class->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(resolved_class); @@ -346,7 +347,15 @@ void AOTConstantPoolResolver::maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m break; case Bytecodes::_invokehandle: - InterpreterRuntime::cds_resolve_invokehandle(raw_index, cp, CHECK); + if (CDSConfig::is_dumping_method_handles()) { + ResolvedMethodEntry* method_entry = cp->resolved_method_entry_at(raw_index); + int cp_index = method_entry->constant_pool_index(); + Symbol* sig = cp->uncached_signature_ref_at(cp_index); + Klass* k; + if (check_methodtype_signature(cp(), sig, &k, true)) { + InterpreterRuntime::cds_resolve_invokehandle(raw_index, cp, CHECK); + } + } break; default: @@ -400,7 +409,7 @@ void AOTConstantPoolResolver::preresolve_indy_cp_entries(JavaThread* current, In // Check the MethodType signatures used by parameters to the indy BSMs. Make sure we don't // use types that have been excluded, or else we might end up creating MethodTypes that cannot be stored // in the AOT cache. -bool AOTConstantPoolResolver::check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret) { +bool AOTConstantPoolResolver::check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret, bool is_invokehandle) { ResourceMark rm; for (SignatureStream ss(sig); !ss.is_done(); ss.next()) { if (ss.is_reference()) { @@ -413,11 +422,18 @@ bool AOTConstantPoolResolver::check_methodtype_signature(ConstantPool* cp, Symbo if (SystemDictionaryShared::should_be_excluded(k)) { if (log_is_enabled(Warning, aot, resolve)) { ResourceMark rm; - log_warning(aot, resolve)("Cannot aot-resolve Lambda proxy because %s is excluded", k->external_name()); + log_warning(aot, resolve)("Cannot aot-resolve %s because %s is excluded", + is_invokehandle ? "invokehandle" : "Lambda proxy", + k->external_name()); } return false; } + // cp->pool_holder() must be able to resolve k in production run + precond(CDSConfig::is_dumping_aot_linked_classes()); + precond(SystemDictionaryShared::is_builtin_loader(cp->pool_holder()->class_loader_data())); + precond(SystemDictionaryShared::is_builtin_loader(k->class_loader_data())); + if (ss.at_return_type() && return_type_ret != nullptr) { *return_type_ret = k; } @@ -475,11 +491,44 @@ bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(Constant return false; } + // klass and sigature of the method (no need to check the method name) Symbol* sig = cp->method_handle_signature_ref_at(mh_index); + Symbol* klass_name = cp->klass_name_at(cp->method_handle_klass_index_at(mh_index)); + if (log_is_enabled(Debug, aot, resolve)) { ResourceMark rm; log_debug(aot, resolve)("Checking MethodType of MethodHandle for LambdaMetafactory BSM arg %d: %s", arg_i, sig->as_C_string()); } + + { + Klass* k = find_loaded_class(Thread::current(), cp->pool_holder()->class_loader(), klass_name); + if (k == nullptr) { + // Dumping AOT cache: all classes should have been loaded by FinalImageRecipes::load_all_classes(). k must have + // been a class that was excluded when FinalImageRecipes recorded all classes at the end of the training run. + // + // Dumping static CDS archive: all classes in the classlist have already been loaded, before we resolve + // constants. k must have been a class that was excluded when the classlist was written + // at the end of the training run. + if (log_is_enabled(Warning, aot, resolve)) { + ResourceMark rm; + log_warning(aot, resolve)("Cannot aot-resolve Lambda proxy because %s is not loaded", klass_name->as_C_string()); + } + return false; + } + if (SystemDictionaryShared::should_be_excluded(k)) { + if (log_is_enabled(Warning, aot, resolve)) { + ResourceMark rm; + log_warning(aot, resolve)("Cannot aot-resolve Lambda proxy because %s is excluded", k->external_name()); + } + return false; + } + + // cp->pool_holder() must be able to resolve k in production run + precond(CDSConfig::is_dumping_aot_linked_classes()); + precond(SystemDictionaryShared::is_builtin_loader(cp->pool_holder()->class_loader_data())); + precond(SystemDictionaryShared::is_builtin_loader(k->class_loader_data())); + } + return check_methodtype_signature(cp, sig); } diff --git a/src/hotspot/share/cds/aotConstantPoolResolver.hpp b/src/hotspot/share/cds/aotConstantPoolResolver.hpp index e49d9d1ad0b..ecf2ac27061 100644 --- a/src/hotspot/share/cds/aotConstantPoolResolver.hpp +++ b/src/hotspot/share/cds/aotConstantPoolResolver.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -74,7 +74,10 @@ class AOTConstantPoolResolver : AllStatic { static void maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m, Bytecodes::Code bc, int raw_index, GrowableArray* resolve_fmi_list, TRAPS); - static bool check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret = nullptr); +public: + static bool check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret = nullptr, bool is_invokehandle = false); + +private: static bool check_lambda_metafactory_signature(ConstantPool* cp, Symbol* sig); static bool check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i); static bool check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i); diff --git a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp index 3653f9d518c..6a60177fc40 100644 --- a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp +++ b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,11 +116,24 @@ void AOTLinkedClassBulkLoader::preload_classes_in_table(Array* c } } +#ifdef ASSERT +// true iff we are inside AOTLinkedClassBulkLoader::link_classes(), when +// we are moving classes into the fully_initialized state before the +// JVM is able to execute any bytecodes. +static bool _is_initializing_classes_early = false; +bool AOTLinkedClassBulkLoader::is_initializing_classes_early() { + return _is_initializing_classes_early; +} +#endif + // Some cached heap objects may hold references to methods in aot-linked // classes (via MemberName). We need to make sure all classes are // linked before executing any bytecode. void AOTLinkedClassBulkLoader::link_classes(JavaThread* current) { + DEBUG_ONLY(_is_initializing_classes_early = true); link_classes_impl(current); + DEBUG_ONLY(_is_initializing_classes_early = false); + if (current->has_pending_exception()) { exit_on_exception(current); } @@ -135,6 +148,13 @@ void AOTLinkedClassBulkLoader::link_classes_impl(TRAPS) { link_classes_in_table(table->boot2(), CHECK); link_classes_in_table(table->platform(), CHECK); link_classes_in_table(table->app(), CHECK); + + init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->boot1(), /*early_only=*/true, CHECK); + init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->boot2(), /*early_only=*/true, CHECK); + init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->platform(), /*early_only=*/true, CHECK); + init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->app(), /*early_only=*/true, CHECK); + + log_info(aot, init)("------ finished early class init"); } void AOTLinkedClassBulkLoader::link_classes_in_table(Array* classes, TRAPS) { @@ -216,7 +236,7 @@ void AOTLinkedClassBulkLoader::validate_module(Klass* k, const char* category_na #endif void AOTLinkedClassBulkLoader::init_javabase_classes(JavaThread* current) { - init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->boot1(), current); + init_classes_for_loader(Handle(), AOTLinkedClassTable::get()->boot1(), /*early_only=*/false, current); if (current->has_pending_exception()) { exit_on_exception(current); } @@ -246,9 +266,9 @@ void AOTLinkedClassBulkLoader::init_non_javabase_classes_impl(TRAPS) { assert(h_system_loader() != nullptr, "must be"); AOTLinkedClassTable* table = AOTLinkedClassTable::get(); - init_classes_for_loader(Handle(), table->boot2(), CHECK); - init_classes_for_loader(h_platform_loader, table->platform(), CHECK); - init_classes_for_loader(h_system_loader, table->app(), CHECK); + init_classes_for_loader(Handle(), table->boot2(), /*early_only=*/false, CHECK); + init_classes_for_loader(h_platform_loader, table->platform(), /*early_only=*/false, CHECK); + init_classes_for_loader(h_system_loader, table->app(), /*early_only=*/false, CHECK); if (Universe::is_fully_initialized() && VerifyDuringStartup) { // Make sure we're still in a clean state. @@ -324,22 +344,80 @@ void AOTLinkedClassBulkLoader::initiate_loading(JavaThread* current, const char* } } -// Some AOT-linked classes for must be initialized early. This includes -// - classes that were AOT-initialized by AOTClassInitializer -// - the classes of all objects that are reachable from the archived mirrors of -// the AOT-linked classes for . -void AOTLinkedClassBulkLoader::init_classes_for_loader(Handle class_loader, Array* classes, TRAPS) { +// Can we move ik into fully_initialized state before the JVM is able to execute +// bytecodes? +static bool is_early_init_possible(InstanceKlass* ik) { + if (ik->is_runtime_setup_required()) { + // Bytecodes need to be executed in order to initialize this class. + if (log_is_enabled(Debug, aot, init)) { + ResourceMark rm; + log_debug(aot, init)("No early init %s: needs runtimeSetup()", + ik->external_name()); + } + return false; + } + + if (ik->super() != nullptr && !ik->super()->is_initialized()) { + // is_runtime_setup_required() == true for a super type + if (log_is_enabled(Debug, aot, init)) { + ResourceMark rm; + log_debug(aot, init)("No early init %s: super type %s not initialized", + ik->external_name(), ik->super()->external_name()); + } + return false; + } + + Array* interfaces = ik->local_interfaces(); + int num_interfaces = interfaces->length(); + for (int i = 0; i < num_interfaces; i++) { + InstanceKlass* intf = interfaces->at(i); + if (!intf->is_initialized() && intf->interface_needs_clinit_execution_as_super(/*also_check_supers*/false)) { + // is_runtime_setup_required() == true for this interface + if (log_is_enabled(Debug, aot, init)) { + ResourceMark rm; + log_debug(aot, init)("No early init %s: interface type %s not initialized", + ik->external_name(), intf->external_name()); + } + return false; + } + } + + return true; +} + +// Normally, classes are initialized on demand. However, some AOT-linked classes +// for the class_loader must be proactively intialized, including: +// - Classes that have an AOT-initialized mirror (they were AOT-initialized by +// AOTClassInitializer during the assembly phase). +// - The classes of all objects that are reachable from the archived mirrors of +// the AOT-linked classes for the class_loader. These are recorded in the special +// subgraph. +// +// (early_only == true) means that this function is called before the JVM +// is capable of executing Java bytecodes. +void AOTLinkedClassBulkLoader::init_classes_for_loader(Handle class_loader, Array* classes, + bool early_only, TRAPS) { if (classes != nullptr) { for (int i = 0; i < classes->length(); i++) { InstanceKlass* ik = classes->at(i); assert(ik->class_loader_data() != nullptr, "must be"); - if (ik->has_aot_initialized_mirror()) { - ik->initialize_with_aot_initialized_mirror(CHECK); + + bool do_init = ik->has_aot_initialized_mirror(); + if (do_init && early_only && !is_early_init_possible(ik)) { + // ik will be proactively initialized later when init_classes_for_loader() + // is called again with (early_only == false). + do_init = false; + } + + if (do_init) { + ik->initialize_with_aot_initialized_mirror(early_only, CHECK); } } } - HeapShared::init_classes_for_special_subgraph(class_loader, CHECK); + if (!early_only) { + HeapShared::init_classes_for_special_subgraph(class_loader, CHECK); + } } void AOTLinkedClassBulkLoader::replay_training_at_init(Array* classes, TRAPS) { diff --git a/src/hotspot/share/cds/aotLinkedClassBulkLoader.hpp b/src/hotspot/share/cds/aotLinkedClassBulkLoader.hpp index 31fdac386fe..24ff61cea1e 100644 --- a/src/hotspot/share/cds/aotLinkedClassBulkLoader.hpp +++ b/src/hotspot/share/cds/aotLinkedClassBulkLoader.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -56,7 +56,7 @@ class AOTLinkedClassBulkLoader : AllStatic { static void link_classes_impl(TRAPS); static void link_classes_in_table(Array* classes, TRAPS); static void init_non_javabase_classes_impl(TRAPS); - static void init_classes_for_loader(Handle class_loader, Array* classes, TRAPS); + static void init_classes_for_loader(Handle class_loader, Array* classes, bool early_only, TRAPS); static void replay_training_at_init(Array* classes, TRAPS) NOT_CDS_RETURN; #ifdef ASSERT @@ -73,8 +73,9 @@ public: static void init_javabase_classes(JavaThread* current) NOT_CDS_RETURN; static void init_non_javabase_classes(JavaThread* current) NOT_CDS_RETURN; static void exit_on_exception(JavaThread* current); - static void replay_training_at_init_for_preloaded_classes(TRAPS) NOT_CDS_RETURN; + + static bool is_initializing_classes_early() NOT_DEBUG({return false;}); }; #endif // SHARE_CDS_AOTLINKEDCLASSBULKLOADER_HPP diff --git a/src/hotspot/share/cds/aotMapLogger.cpp b/src/hotspot/share/cds/aotMapLogger.cpp index fa769aee1bf..9f338826fd6 100644 --- a/src/hotspot/share/cds/aotMapLogger.cpp +++ b/src/hotspot/share/cds/aotMapLogger.cpp @@ -98,8 +98,8 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo, DumpRegion* rw_region = &builder->_rw_region; DumpRegion* ro_region = &builder->_ro_region; - dumptime_log_metaspace_region("rw region", rw_region, &builder->_rw_src_objs); - dumptime_log_metaspace_region("ro region", ro_region, &builder->_ro_src_objs); + dumptime_log_metaspace_region("rw region", rw_region, &builder->_rw_src_objs, &builder->_ro_src_objs); + dumptime_log_metaspace_region("ro region", ro_region, &builder->_rw_src_objs, &builder->_ro_src_objs); address bitmap_end = address(bitmap + bitmap_size_in_bytes); log_region_range("bitmap", address(bitmap), bitmap_end, nullptr); @@ -122,17 +122,6 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo, class AOTMapLogger::RuntimeGatherArchivedMetaspaceObjs : public UniqueMetaspaceClosure { GrowableArrayCHeap _objs; - static int compare_objs_by_addr(ArchivedObjInfo* a, ArchivedObjInfo* b) { - intx diff = a->_src_addr - b->_src_addr; - if (diff < 0) { - return -1; - } else if (diff == 0) { - return 0; - } else { - return 1; - } - } - public: GrowableArrayCHeap* objs() { return &_objs; } @@ -152,7 +141,7 @@ public: void finish() { UniqueMetaspaceClosure::finish(); - _objs.sort(compare_objs_by_addr); + _objs.sort(compare_by_address); } }; // AOTMapLogger::RuntimeGatherArchivedMetaspaceObjs @@ -203,24 +192,47 @@ void AOTMapLogger::runtime_log(FileMapInfo* mapinfo, GrowableArrayCHeapbase()); address region_top = address(region->top()); log_region_range(name, region_base, region_top, region_base + _buffer_to_requested_delta); if (log_is_enabled(Debug, aot, map)) { GrowableArrayCHeap objs; - for (int i = 0; i < src_objs->objs()->length(); i++) { - ArchiveBuilder::SourceObjInfo* src_info = src_objs->at(i); + // With -XX:+UseCompactObjectHeaders, it's possible for small objects (including some from + // ro_objs) to be allocated in the gaps in the RW region. + collect_metaspace_objs(&objs, region_base, region_top, rw_objs); + collect_metaspace_objs(&objs, region_base, region_top, ro_objs); + objs.sort(compare_by_address); + log_metaspace_objects_impl(address(region->base()), address(region->end()), &objs, 0, objs.length()); + } +} + +void AOTMapLogger::collect_metaspace_objs(GrowableArrayCHeap* objs, + address region_base, address region_top , + const ArchiveBuilder::SourceObjList* src_objs) { + for (int i = 0; i < src_objs->objs()->length(); i++) { + ArchiveBuilder::SourceObjInfo* src_info = src_objs->at(i); + address buf_addr = src_info->buffered_addr(); + if (region_base <= buf_addr && buf_addr < region_top) { ArchivedObjInfo info; info._src_addr = src_info->source_addr(); - info._buffered_addr = src_info->buffered_addr(); + info._buffered_addr = buf_addr; info._requested_addr = info._buffered_addr + _buffer_to_requested_delta; info._bytes = src_info->size_in_bytes(); info._type = src_info->type(); - objs.append(info); + objs->append(info); } + } +} - log_metaspace_objects_impl(address(region->base()), address(region->end()), &objs, 0, objs.length()); +int AOTMapLogger::compare_by_address(ArchivedObjInfo* a, ArchivedObjInfo* b) { + if (a->_buffered_addr < b->_buffered_addr) { + return -1; + } else if (a->_buffered_addr > b->_buffered_addr) { + return 1; + } else { + return 0; } } @@ -577,7 +589,6 @@ public: } Klass* real_klass() { - assert(UseCompressedClassPointers, "heap archiving requires UseCompressedClassPointers"); return _data._klass; } diff --git a/src/hotspot/share/cds/aotMapLogger.hpp b/src/hotspot/share/cds/aotMapLogger.hpp index f495ed97f40..0a89f1e5012 100644 --- a/src/hotspot/share/cds/aotMapLogger.hpp +++ b/src/hotspot/share/cds/aotMapLogger.hpp @@ -127,7 +127,12 @@ private: static void runtime_log(FileMapInfo* mapinfo, GrowableArrayCHeap* objs); static void runtime_log_metaspace_regions(FileMapInfo* mapinfo, GrowableArrayCHeap* objs); static void dumptime_log_metaspace_region(const char* name, DumpRegion* region, - const ArchiveBuilder::SourceObjList* src_objs); + const ArchiveBuilder::SourceObjList* rw_objs, + const ArchiveBuilder::SourceObjList* ro_objs); + static void collect_metaspace_objs(GrowableArrayCHeap* objs, + address region_base, address region_top , + const ArchiveBuilder::SourceObjList* src_objs); + static int compare_by_address(ArchivedObjInfo* a, ArchivedObjInfo* b); // Common code for dumptime/runtime static void log_file_header(FileMapInfo* mapinfo); diff --git a/src/hotspot/share/cds/aotMappedHeapLoader.hpp b/src/hotspot/share/cds/aotMappedHeapLoader.hpp index 7c5ca1b1f9e..10f5ce3124f 100644 --- a/src/hotspot/share/cds/aotMappedHeapLoader.hpp +++ b/src/hotspot/share/cds/aotMappedHeapLoader.hpp @@ -54,7 +54,7 @@ public: // Can this VM map archived heap region? Currently only G1+compressed{oops,cp} static bool can_map() { - CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedClassPointers);) + CDS_JAVA_HEAP_ONLY(return UseG1GC;) NOT_CDS_JAVA_HEAP(return false;) } diff --git a/src/hotspot/share/cds/aotMappedHeapWriter.cpp b/src/hotspot/share/cds/aotMappedHeapWriter.cpp index 64c0e3c40e8..8f810ef5244 100644 --- a/src/hotspot/share/cds/aotMappedHeapWriter.cpp +++ b/src/hotspot/share/cds/aotMappedHeapWriter.cpp @@ -64,6 +64,11 @@ HeapRootSegments AOTMappedHeapWriter::_heap_root_segments; address AOTMappedHeapWriter::_requested_bottom; address AOTMappedHeapWriter::_requested_top; +static size_t _num_strings = 0; +static size_t _string_bytes = 0; +static size_t _num_packages = 0; +static size_t _num_protection_domains = 0; + GrowableArrayCHeap* AOTMappedHeapWriter::_native_pointers; GrowableArrayCHeap* AOTMappedHeapWriter::_source_objs; GrowableArrayCHeap* AOTMappedHeapWriter::_source_objs_order; @@ -71,8 +76,6 @@ GrowableArrayCHeap* AOTMappedH AOTMappedHeapWriter::BufferOffsetToSourceObjectTable* AOTMappedHeapWriter::_buffer_offset_to_source_obj_table = nullptr; -DumpedInternedStrings *AOTMappedHeapWriter::_dumped_interned_strings = nullptr; - typedef HashTable< size_t, // offset of a filler from AOTMappedHeapWriter::buffer_bottom() size_t, // size of this filler (in bytes) @@ -87,7 +90,6 @@ void AOTMappedHeapWriter::init() { Universe::heap()->collect(GCCause::_java_lang_system_gc); _buffer_offset_to_source_obj_table = new (mtClassShared) BufferOffsetToSourceObjectTable(/*size (prime)*/36137, /*max size*/1 * M); - _dumped_interned_strings = new (mtClass)DumpedInternedStrings(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE); _fillers = new (mtClassShared) FillersTable(); _requested_bottom = nullptr; _requested_top = nullptr; @@ -141,9 +143,6 @@ int AOTMappedHeapWriter::narrow_oop_shift() { void AOTMappedHeapWriter::delete_tables_with_raw_oops() { delete _source_objs; _source_objs = nullptr; - - delete _dumped_interned_strings; - _dumped_interned_strings = nullptr; } void AOTMappedHeapWriter::add_source_obj(oop src_obj) { @@ -181,25 +180,6 @@ bool AOTMappedHeapWriter::is_too_large_to_archive(size_t size) { } } -// Keep track of the contents of the archived interned string table. This table -// is used only by CDSHeapVerifier. -void AOTMappedHeapWriter::add_to_dumped_interned_strings(oop string) { - assert_at_safepoint(); // DumpedInternedStrings uses raw oops - assert(!is_string_too_large_to_archive(string), "must be"); - bool created; - _dumped_interned_strings->put_if_absent(string, true, &created); - if (created) { - // Prevent string deduplication from changing the value field to - // something not in the archive. - java_lang_String::set_deduplication_forbidden(string); - _dumped_interned_strings->maybe_grow(); - } -} - -bool AOTMappedHeapWriter::is_dumped_interned_string(oop o) { - return _dumped_interned_strings->get(o) != nullptr; -} - // Various lookup functions between source_obj, buffered_obj and requested_obj bool AOTMappedHeapWriter::is_in_requested_range(oop o) { assert(_requested_bottom != nullptr, "do not call before _requested_bottom is initialized"); @@ -430,6 +410,7 @@ void AOTMappedHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeapset_buffer_offset(buffer_offset); + assert(buffer_offset <= 0x7fffffff, "sanity"); OopHandle handle(Universe::vm_global(), src_obj); _buffer_offset_to_source_obj_table->put_when_absent(buffer_offset, handle); @@ -442,6 +423,9 @@ void AOTMappedHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeaplength() + 1, roots->length(), _num_native_ptrs); + log_info(aot)(" strings = %8zu (%zu bytes)", _num_strings, _string_bytes); + log_info(aot)(" packages = %8zu", _num_packages); + log_info(aot)(" protection domains = %8zu", _num_protection_domains); } size_t AOTMappedHeapWriter::filler_array_byte_size(int length) { @@ -466,7 +450,6 @@ int AOTMappedHeapWriter::filler_array_length(size_t fill_bytes) { } HeapWord* AOTMappedHeapWriter::init_filler_array_at_buffer_top(int array_length, size_t fill_bytes) { - assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses"); Klass* oak = Universe::objectArrayKlass(); // already relocated to point to archived klass HeapWord* mem = offset_to_buffered_address(_buffer_used); memset(mem, 0, fill_bytes); @@ -530,7 +513,25 @@ void update_buffered_object_field(address buffered_obj, int field_offset, T valu *field_addr = value; } +void AOTMappedHeapWriter::update_stats(oop src_obj) { + if (java_lang_String::is_instance(src_obj)) { + _num_strings ++; + _string_bytes += src_obj->size() * HeapWordSize; + _string_bytes += java_lang_String::value(src_obj)->size() * HeapWordSize; + } else { + Klass* k = src_obj->klass(); + Symbol* name = k->name(); + if (name->equals("java/lang/NamedPackage") || name->equals("java/lang/Package")) { + _num_packages ++; + } else if (name->equals("java/security/ProtectionDomain")) { + _num_protection_domains ++; + } + } +} + size_t AOTMappedHeapWriter::copy_one_source_obj_to_buffer(oop src_obj) { + update_stats(src_obj); + assert(!is_too_large_to_archive(src_obj), "already checked"); size_t byte_size = src_obj->size() * HeapWordSize; assert(byte_size > 0, "no zero-size objects"); @@ -722,7 +723,6 @@ template void AOTMappedHeapWriter::mark_oop_pointer(T* buffered_add } void AOTMappedHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj, Klass* src_klass) { - assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses"); narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass); address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop
(requested_obj)); @@ -896,8 +896,14 @@ void AOTMappedHeapWriter::compute_ptrmap(AOTMappedHeapInfo* heap_info) { native_ptr = RegeneratedClasses::get_regenerated_object(native_ptr); } - guarantee(ArchiveBuilder::current()->has_been_archived((address)native_ptr), - "Metadata %p should have been archived", native_ptr); + if (!ArchiveBuilder::current()->has_been_archived((address)native_ptr)) { + ResourceMark rm; + LogStreamHandle(Error, aot) log; + log.print("Marking native pointer for oop %p (type = %s, offset = %d)", + cast_from_oop(src_obj), src_obj->klass()->external_name(), field_offset); + src_obj->print_on(&log); + fatal("Metadata %p should have been archived", native_ptr); + } address buffered_native_ptr = ArchiveBuilder::current()->get_buffered_addr((address)native_ptr); address requested_native_ptr = ArchiveBuilder::current()->to_requested(buffered_native_ptr); diff --git a/src/hotspot/share/cds/aotMappedHeapWriter.hpp b/src/hotspot/share/cds/aotMappedHeapWriter.hpp index 7481e7922a0..2420e68d9fe 100644 --- a/src/hotspot/share/cds/aotMappedHeapWriter.hpp +++ b/src/hotspot/share/cds/aotMappedHeapWriter.hpp @@ -40,20 +40,6 @@ class MemRegion; #if INCLUDE_CDS_JAVA_HEAP -class DumpedInternedStrings : - public ResizeableHashTable -{ -public: - DumpedInternedStrings(unsigned size, unsigned max_size) : - ResizeableHashTable(size, max_size) {} -}; - class AOTMappedHeapWriter : AllStatic { friend class HeapShared; friend class AOTMappedHeapLoader; @@ -131,7 +117,6 @@ private: static GrowableArrayCHeap* _native_pointers; static GrowableArrayCHeap* _source_objs; - static DumpedInternedStrings *_dumped_interned_strings; // We sort _source_objs_order to minimize the number of bits in ptrmap and oopmap. // See comments near the body of AOTMappedHeapWriter::compare_objs_by_oop_fields(). @@ -190,6 +175,7 @@ private: static void copy_roots_to_buffer(GrowableArrayCHeap* roots); static void copy_source_objs_to_buffer(GrowableArrayCHeap* roots); static size_t copy_one_source_obj_to_buffer(oop src_obj); + static void update_stats(oop src_obj); static void maybe_fill_gc_region_gap(size_t required_byte_size); static size_t filler_array_byte_size(int length); @@ -227,8 +213,6 @@ public: static bool is_too_large_to_archive(size_t size); static bool is_too_large_to_archive(oop obj); static bool is_string_too_large_to_archive(oop string); - static bool is_dumped_interned_string(oop o); - static void add_to_dumped_interned_strings(oop string); static void write(GrowableArrayCHeap*, AOTMappedHeapInfo* heap_info); static address requested_address(); // requested address of the lowest achived heap object static size_t get_filler_size_at(address buffered_addr); diff --git a/src/hotspot/share/cds/aotMetaspace.cpp b/src/hotspot/share/cds/aotMetaspace.cpp index 544eaa07a4d..55e9f93b3ab 100644 --- a/src/hotspot/share/cds/aotMetaspace.cpp +++ b/src/hotspot/share/cds/aotMetaspace.cpp @@ -250,9 +250,9 @@ static bool shared_base_too_high(char* specified_base, char* aligned_base, size_ static char* compute_shared_base(size_t cds_max) { char* specified_base = (char*)SharedBaseAddress; size_t alignment = AOTMetaspace::core_region_alignment(); - if (UseCompressedClassPointers && CompressedKlassPointers::needs_class_space()) { - alignment = MAX2(alignment, Metaspace::reserve_alignment()); - } +#if INCLUDE_CLASS_SPACE + alignment = MAX2(alignment, Metaspace::reserve_alignment()); +#endif if (SharedBaseAddress == 0) { // Special meaning of -XX:SharedBaseAddress=0 -> Always map archive at os-selected address. @@ -1148,7 +1148,7 @@ void AOTMetaspace::dump_static_archive_impl(StaticArchiveBuilder& builder, TRAPS if (CDSConfig::is_dumping_full_module_graph()) { ClassLoaderDataShared::ensure_module_entry_tables_exist(); ClassLoaderDataShared::build_tables(CHECK); - HeapShared::reset_archived_object_states(CHECK); + HeapShared::prepare_for_archiving(CHECK); } AOTReferenceObjSupport::initialize(CHECK); @@ -1187,8 +1187,8 @@ void AOTMetaspace::dump_static_archive_impl(StaticArchiveBuilder& builder, TRAPS CDSConfig::enable_dumping_aot_code(); { builder.start_ac_region(); - // Write the contents to AOT code region and close AOTCodeCache before packing the region - AOTCodeCache::close(); + // Write the contents to AOT code region before packing the region + AOTCodeCache::dump(); builder.end_ac_region(); } CDSConfig::disable_dumping_aot_code(); @@ -1637,32 +1637,29 @@ MapArchiveResult AOTMetaspace::map_archives(FileMapInfo* static_mapinfo, FileMap aot_log_debug(aot)("Failed to reserve spaces (use_requested_addr=%u)", (unsigned)use_requested_addr); } else { - if (Metaspace::using_class_space()) { - prot_zone_size = protection_zone_size(); - } + CLASS_SPACE_ONLY(prot_zone_size = protection_zone_size();) -#ifdef ASSERT // Some sanity checks after reserving address spaces for archives // and class space. assert(archive_space_rs.is_reserved(), "Sanity"); - if (Metaspace::using_class_space()) { - assert(archive_space_rs.base() == mapped_base_address && - archive_space_rs.size() > protection_zone_size(), - "Archive space must lead and include the protection zone"); - // Class space must closely follow the archive space. Both spaces - // must be aligned correctly. - assert(class_space_rs.is_reserved() && class_space_rs.size() > 0, - "A class space should have been reserved"); - assert(class_space_rs.base() >= archive_space_rs.end(), - "class space should follow the cds archive space"); - assert(is_aligned(archive_space_rs.base(), - core_region_alignment()), - "Archive space misaligned"); - assert(is_aligned(class_space_rs.base(), - Metaspace::reserve_alignment()), - "class space misaligned"); - } -#endif // ASSERT + +#if INCLUDE_CLASS_SPACE + assert(archive_space_rs.base() == mapped_base_address && + archive_space_rs.size() > protection_zone_size(), + "Archive space must lead and include the protection zone"); + // Class space must closely follow the archive space. Both spaces + // must be aligned correctly. + assert(class_space_rs.is_reserved() && class_space_rs.size() > 0, + "A class space should have been reserved"); + assert(class_space_rs.base() >= archive_space_rs.end(), + "class space should follow the cds archive space"); + assert(is_aligned(archive_space_rs.base(), + core_region_alignment()), + "Archive space misaligned"); + assert(is_aligned(class_space_rs.base(), + Metaspace::reserve_alignment()), + "class space misaligned"); +#endif // INCLUDE_CLASS_SPACE aot_log_info(aot)("Reserved archive_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes%s", p2i(archive_space_rs.base()), p2i(archive_space_rs.end()), archive_space_rs.size(), @@ -1764,67 +1761,60 @@ MapArchiveResult AOTMetaspace::map_archives(FileMapInfo* static_mapinfo, FileMap if (result == MAP_ARCHIVE_SUCCESS) { SharedBaseAddress = (size_t)mapped_base_address; -#ifdef _LP64 - if (Metaspace::using_class_space()) { - assert(prot_zone_size > 0 && - *(mapped_base_address) == 'P' && - *(mapped_base_address + prot_zone_size - 1) == 'P', - "Protection zone was overwritten?"); - // Set up ccs in metaspace. - Metaspace::initialize_class_space(class_space_rs); +#if INCLUDE_CLASS_SPACE + assert(prot_zone_size > 0 && + *(mapped_base_address) == 'P' && + *(mapped_base_address + prot_zone_size - 1) == 'P', + "Protection zone was overwritten?"); + // Set up ccs in metaspace. + Metaspace::initialize_class_space(class_space_rs); - // Set up compressed Klass pointer encoding: the encoding range must - // cover both archive and class space. - const address klass_range_start = (address)mapped_base_address; - const size_t klass_range_size = (address)class_space_rs.end() - klass_range_start; - if (INCLUDE_CDS_JAVA_HEAP || UseCompactObjectHeaders) { - // The CDS archive may contain narrow Klass IDs that were precomputed at archive generation time: - // - every archived java object header (only if INCLUDE_CDS_JAVA_HEAP) - // - every archived Klass' prototype (only if +UseCompactObjectHeaders) - // - // In order for those IDs to still be valid, we need to dictate base and shift: base should be the - // mapping start (including protection zone), shift should be the shift used at archive generation time. - CompressedKlassPointers::initialize_for_given_encoding( - klass_range_start, klass_range_size, - klass_range_start, ArchiveBuilder::precomputed_narrow_klass_shift() // precomputed encoding, see ArchiveBuilder - ); - assert(CompressedKlassPointers::base() == klass_range_start, "must be"); - } else { - // Let JVM freely choose encoding base and shift - CompressedKlassPointers::initialize(klass_range_start, klass_range_size); - assert(CompressedKlassPointers::base() == nullptr || - CompressedKlassPointers::base() == klass_range_start, "must be"); - } - // Establish protection zone, but only if we need one - if (CompressedKlassPointers::base() == klass_range_start) { - CompressedKlassPointers::establish_protection_zone(klass_range_start, prot_zone_size); - } + // Set up compressed Klass pointer encoding: the encoding range must + // cover both archive and class space. + const address klass_range_start = (address)mapped_base_address; + const size_t klass_range_size = (address)class_space_rs.end() - klass_range_start; + if (INCLUDE_CDS_JAVA_HEAP || UseCompactObjectHeaders) { + // The CDS archive may contain narrow Klass IDs that were precomputed at archive generation time: + // - every archived java object header (only if INCLUDE_CDS_JAVA_HEAP) + // - every archived Klass' prototype (only if +UseCompactObjectHeaders) + // + // In order for those IDs to still be valid, we need to dictate base and shift: base should be the + // mapping start (including protection zone), shift should be the shift used at archive generation time. + CompressedKlassPointers::initialize_for_given_encoding( + klass_range_start, klass_range_size, + klass_range_start, ArchiveBuilder::precomputed_narrow_klass_shift() // precomputed encoding, see ArchiveBuilder + ); + assert(CompressedKlassPointers::base() == klass_range_start, "must be"); + } else { + // Let JVM freely choose encoding base and shift + CompressedKlassPointers::initialize(klass_range_start, klass_range_size); + assert(CompressedKlassPointers::base() == nullptr || + CompressedKlassPointers::base() == klass_range_start, "must be"); + } + // Establish protection zone, but only if we need one + if (CompressedKlassPointers::base() == klass_range_start) { + CompressedKlassPointers::establish_protection_zone(klass_range_start, prot_zone_size); + } - if (static_mapinfo->can_use_heap_region()) { - if (static_mapinfo->object_streaming_mode()) { - HeapShared::initialize_loading_mode(HeapArchiveMode::_streaming); - } else { - // map_or_load_heap_region() compares the current narrow oop and klass encodings - // with the archived ones, so it must be done after all encodings are determined. - static_mapinfo->map_or_load_heap_region(); - HeapShared::initialize_loading_mode(HeapArchiveMode::_mapping); - } + if (static_mapinfo->can_use_heap_region()) { + if (static_mapinfo->object_streaming_mode()) { + HeapShared::initialize_loading_mode(HeapArchiveMode::_streaming); } else { - FileMapRegion* r = static_mapinfo->region_at(AOTMetaspace::hp); - if (r->used() > 0) { - if (static_mapinfo->object_streaming_mode()) { - AOTMetaspace::report_loading_error("Cannot use CDS heap data."); - } else { - if (!UseCompressedOops && !AOTMappedHeapLoader::can_map()) { - AOTMetaspace::report_loading_error("Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"); - } else { - AOTMetaspace::report_loading_error("Cannot use CDS heap data. UseEpsilonGC, UseG1GC, UseSerialGC, UseParallelGC, or UseShenandoahGC are required."); - } - } - } + // map_or_load_heap_region() compares the current narrow oop and klass encodings + // with the archived ones, so it must be done after all encodings are determined. + static_mapinfo->map_or_load_heap_region(); + HeapShared::initialize_loading_mode(HeapArchiveMode::_mapping); + } + } else { + FileMapRegion* r = static_mapinfo->region_at(AOTMetaspace::hp); + if (r->used() > 0) { + AOTMetaspace::report_loading_error("Cannot use CDS heap data."); + } + if (!CDSConfig::is_dumping_static_archive()) { + CDSConfig::stop_using_full_module_graph("No CDS heap data"); } } -#endif // _LP64 +#endif // INCLUDE_CLASS_SPACE log_info(aot)("initial optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); log_info(aot)("initial full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); } else { @@ -1857,8 +1847,13 @@ MapArchiveResult AOTMetaspace::map_archives(FileMapInfo* static_mapinfo, FileMap // (The gap may result from different alignment requirements between metaspace // and CDS) // -// If UseCompressedClassPointers is disabled, only one address space will be -// reserved: +// The range encompassing both spaces will be suitable to en/decode narrow Klass +// pointers: the base will be valid for encoding the range [Base, End) and not +// surpass the max. range for that encoding. +// +// On 32-bit, a "narrow" Klass is just the pointer itself, and the Klass encoding +// range encompasses the whole address range. Consequently, we can "decode" and +// "encode" any pointer anywhere, and so are free to place the CDS archive anywhere: // // +-- Base address End // | | @@ -1872,27 +1867,21 @@ MapArchiveResult AOTMetaspace::map_archives(FileMapInfo* static_mapinfo, FileMap // use_archive_base_addr address is false, this base address is determined // by the platform. // -// If UseCompressedClassPointers=1, the range encompassing both spaces will be -// suitable to en/decode narrow Klass pointers: the base will be valid for -// encoding, the range [Base, End) and not surpass the max. range for that encoding. -// // Return: // // - On success: // - total_space_rs will be reserved as whole for archive_space_rs and -// class_space_rs if UseCompressedClassPointers is true. +// class_space_rs on 64-bit. // On Windows, try reserve archive_space_rs and class_space_rs // separately first if use_archive_base_addr is true. // - archive_space_rs will be reserved and large enough to host static and // if needed dynamic archive: [Base, A). // archive_space_rs.base and size will be aligned to CDS reserve // granularity. -// - class_space_rs: If UseCompressedClassPointers=1, class_space_rs will -// be reserved. Its start address will be aligned to metaspace reserve -// alignment, which may differ from CDS alignment. It will follow the cds -// archive space, close enough such that narrow class pointer encoding -// covers both spaces. -// If UseCompressedClassPointers=0, class_space_rs remains unreserved. +// - class_space_rs: On 64-bit, class_space_rs will be reserved. Its start +// address will be aligned to metaspace reserve alignment, which may differ +// from CDS alignment. It will follow the cds archive space, close enough +// such that narrow class pointer encoding covers both spaces. // - On error: null is returned and the spaces remain unreserved. char* AOTMetaspace::reserve_address_space_for_archives(FileMapInfo* static_mapinfo, FileMapInfo* dynamic_mapinfo, @@ -1908,32 +1897,34 @@ char* AOTMetaspace::reserve_address_space_for_archives(FileMapInfo* static_mapin size_t archive_end_offset = (dynamic_mapinfo == nullptr) ? static_mapinfo->mapping_end_offset() : dynamic_mapinfo->mapping_end_offset(); size_t archive_space_size = align_up(archive_end_offset, archive_space_alignment); - if (!Metaspace::using_class_space()) { - // Get the simple case out of the way first: - // no compressed class space, simple allocation. +#if !INCLUDE_CLASS_SPACE - // When running without class space, requested archive base should be aligned to cds core alignment. - assert(is_aligned(base_address, archive_space_alignment), - "Archive base address unaligned: " PTR_FORMAT ", needs alignment: %zu.", - p2i(base_address), archive_space_alignment); + // Get the simple case out of the way first: + // no compressed class space, simple allocation. - archive_space_rs = MemoryReserver::reserve((char*)base_address, - archive_space_size, - archive_space_alignment, - os::vm_page_size(), - mtNone); - if (archive_space_rs.is_reserved()) { - assert(base_address == nullptr || - (address)archive_space_rs.base() == base_address, "Sanity"); - // Register archive space with NMT. - MemTracker::record_virtual_memory_tag(archive_space_rs, mtClassShared); - return archive_space_rs.base(); - } - return nullptr; + // When running without class space, requested archive base should be aligned to cds core alignment. + assert(is_aligned(base_address, archive_space_alignment), + "Archive base address unaligned: " PTR_FORMAT ", needs alignment: %zu.", + p2i(base_address), archive_space_alignment); + + archive_space_rs = MemoryReserver::reserve((char*)base_address, + archive_space_size, + archive_space_alignment, + os::vm_page_size(), + mtNone); + if (archive_space_rs.is_reserved()) { + assert(base_address == nullptr || + (address)archive_space_rs.base() == base_address, "Sanity"); + // Register archive space with NMT. + MemTracker::record_virtual_memory_tag(archive_space_rs, mtClassShared); + return archive_space_rs.base(); } -#ifdef _LP64 + return nullptr; +#else + + // INCLUDE_CLASS_SPACE=1 // Complex case: two spaces adjacent to each other, both to be addressable // with narrow class pointers. // We reserve the whole range spanning both spaces, then split that range up. @@ -2045,11 +2036,7 @@ char* AOTMetaspace::reserve_address_space_for_archives(FileMapInfo* static_mapin return archive_space_rs.base(); -#else - ShouldNotReachHere(); - return nullptr; -#endif - +#endif // INCLUDE_CLASS_SPACE } void AOTMetaspace::release_reserved_spaces(ReservedSpace& total_space_rs, diff --git a/src/hotspot/share/cds/aotReferenceObjSupport.cpp b/src/hotspot/share/cds/aotReferenceObjSupport.cpp index 0c27c8ce5f0..2d5fc8c7f21 100644 --- a/src/hotspot/share/cds/aotReferenceObjSupport.cpp +++ b/src/hotspot/share/cds/aotReferenceObjSupport.cpp @@ -96,7 +96,7 @@ class KeepAliveObjectsTable : public HashTable {}; + HeapShared::oop_address_hash> {}; static KeepAliveObjectsTable* _keep_alive_objs_table; static OopHandle _keep_alive_objs_array; diff --git a/src/hotspot/share/cds/aotStreamedHeapWriter.cpp b/src/hotspot/share/cds/aotStreamedHeapWriter.cpp index f52532b2f2a..25bef10a673 100644 --- a/src/hotspot/share/cds/aotStreamedHeapWriter.cpp +++ b/src/hotspot/share/cds/aotStreamedHeapWriter.cpp @@ -242,20 +242,6 @@ void AOTStreamedHeapWriter::copy_roots_max_dfs_to_buffer(int roots_length) { } } -static bool is_interned_string(oop obj) { - if (!java_lang_String::is_instance(obj)) { - return false; - } - - ResourceMark rm; - int len; - jchar* name = java_lang_String::as_unicode_string_or_null(obj, len); - if (name == nullptr) { - fatal("Insufficient memory for dumping"); - } - return StringTable::lookup(name, len) == obj; -} - static BitMap::idx_t bit_idx_for_buffer_offset(size_t buffer_offset) { if (UseCompressedOops) { return BitMap::idx_t(buffer_offset / sizeof(narrowOop)); @@ -264,10 +250,6 @@ static BitMap::idx_t bit_idx_for_buffer_offset(size_t buffer_offset) { } } -bool AOTStreamedHeapWriter::is_dumped_interned_string(oop obj) { - return is_interned_string(obj) && HeapShared::get_cached_oop_info(obj) != nullptr; -} - void AOTStreamedHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeap* roots) { for (int i = 0; i < _source_objs->length(); i++) { oop src_obj = _source_objs->at(i); @@ -325,7 +307,7 @@ size_t AOTStreamedHeapWriter::copy_one_source_obj_to_buffer(oop src_obj) { ensure_buffer_space(new_used); - if (is_interned_string(src_obj)) { + if (HeapShared::is_interned_string(src_obj)) { java_lang_String::hash_code(src_obj); // Sets the hash code field(s) java_lang_String::set_deduplication_forbidden(src_obj); // Allows faster interning at runtime assert(java_lang_String::hash_is_set(src_obj), "hash must be set"); @@ -387,7 +369,6 @@ template void AOTStreamedHeapWriter::map_oop_field_in_buffer(oop ob } void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_addr, oop src_obj, Klass* src_klass) { - assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses"); narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass); markWord mw = markWord::prototype(); @@ -402,7 +383,7 @@ void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_add mw = mw.copy_set_hash(src_hash); } - if (is_interned_string(src_obj)) { + if (HeapShared::is_interned_string(src_obj)) { // Mark the mark word of interned string so the loader knows to link these to // the string table at runtime. mw = mw.set_marked(); diff --git a/src/hotspot/share/cds/aotStreamedHeapWriter.hpp b/src/hotspot/share/cds/aotStreamedHeapWriter.hpp index ab5aec0327b..c3cc9f2c092 100644 --- a/src/hotspot/share/cds/aotStreamedHeapWriter.hpp +++ b/src/hotspot/share/cds/aotStreamedHeapWriter.hpp @@ -148,8 +148,6 @@ public: return size_t(buffered_addr) - size_t(buffer_bottom()); } - static bool is_dumped_interned_string(oop obj); - static size_t source_obj_to_buffered_offset(oop src_obj); static address source_obj_to_buffered_addr(oop src_obj); diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index cb9459172b3..21eef3d7b0b 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -321,8 +321,10 @@ void ArchiveBuilder::sort_klasses() { } address ArchiveBuilder::reserve_buffer() { - // AOTCodeCache::max_aot_code_size() accounts for aot code region. - size_t buffer_size = LP64_ONLY(CompressedClassSpaceSize) NOT_LP64(256 * M) + AOTCodeCache::max_aot_code_size(); + // On 64-bit: reserve address space for archives up to the max encoded offset limit. + // On 32-bit: use 256MB + AOT code size due to limited virtual address space. + size_t buffer_size = LP64_ONLY(AOTCompressedPointers::MaxMetadataOffsetBytes) + NOT_LP64(256 * M + AOTCodeCache::max_aot_code_size()); ReservedSpace rs = MemoryReserver::reserve(buffer_size, AOTMetaspace::core_region_alignment(), os::vm_page_size(), @@ -625,6 +627,7 @@ void ArchiveBuilder::dump_ro_metadata() { start_dump_region(&_ro_region); make_shallow_copies(&_ro_region, &_ro_src_objs); RegeneratedClasses::record_regenerated_objects(); + DumpRegion::report_gaps(&_alloc_stats); } void ArchiveBuilder::make_shallow_copies(DumpRegion *dump_region, @@ -637,33 +640,10 @@ void ArchiveBuilder::make_shallow_copies(DumpRegion *dump_region, void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info) { address src = src_info->source_addr(); - int bytes = src_info->size_in_bytes(); // word-aligned - size_t alignment = SharedSpaceObjectAlignment; // alignment for the dest pointer + int bytes = src_info->size_in_bytes(); + char* dest = dump_region->allocate_metaspace_obj(bytes, src, src_info->type(), + src_info->read_only(), &_alloc_stats); - char* oldtop = dump_region->top(); - if (src_info->type() == MetaspaceClosureType::ClassType) { - // Allocate space for a pointer directly in front of the future InstanceKlass, so - // we can do a quick lookup from InstanceKlass* -> RunTimeClassInfo* - // without building another hashtable. See RunTimeClassInfo::get_for() - // in systemDictionaryShared.cpp. - Klass* klass = (Klass*)src; - if (klass->is_instance_klass()) { - SystemDictionaryShared::validate_before_archiving(InstanceKlass::cast(klass)); - dump_region->allocate(sizeof(address)); - } -#ifdef _LP64 - // More strict alignments needed for UseCompressedClassPointers - if (UseCompressedClassPointers) { - alignment = nth_bit(ArchiveBuilder::precomputed_narrow_klass_shift()); - } -#endif - } else if (src_info->type() == MetaspaceClosureType::SymbolType) { - // Symbols may be allocated by using AllocateHeap, so their sizes - // may be less than size_in_bytes() indicates. - bytes = ((Symbol*)src)->byte_size(); - } - - char* dest = dump_region->allocate(bytes, alignment); memcpy(dest, src, bytes); // Update the hash of buffered sorted symbols for static dump so that the symbols have deterministic contents @@ -690,11 +670,6 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s log_trace(aot)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(src), p2i(dest), bytes); src_info->set_buffered_addr((address)dest); - - char* newtop = dump_region->top(); - _alloc_stats.record(src_info->type(), int(newtop - oldtop), src_info->read_only()); - - DEBUG_ONLY(_alloc_stats.verify((int)dump_region->used(), src_info->read_only())); } // This is used by code that hand-assembles data structures, such as the LambdaProxyClassKey, that are @@ -1117,20 +1092,17 @@ class RelocateBufferToRequested : public BitMapClosure { } }; -#ifdef _LP64 int ArchiveBuilder::precomputed_narrow_klass_shift() { - // Legacy Mode: - // We use 32 bits for narrowKlass, which should cover the full 4G Klass range. Shift can be 0. + // Standard Mode: + // We use 32 bits for narrowKlass, which should cover a full 4G Klass range. Shift can be 0. // CompactObjectHeader Mode: // narrowKlass is much smaller, and we use the highest possible shift value to later get the maximum // Klass encoding range. // // Note that all of this may change in the future, if we decide to correct the pre-calculated // narrow Klass IDs at archive load time. - assert(UseCompressedClassPointers, "Only needed for compressed class pointers"); return UseCompactObjectHeaders ? CompressedKlassPointers::max_shift() : 0; } -#endif // _LP64 void ArchiveBuilder::relocate_to_requested() { if (!ro_region()->is_packed()) { diff --git a/src/hotspot/share/cds/archiveBuilder.hpp b/src/hotspot/share/cds/archiveBuilder.hpp index b3667ea11b4..6a9df87092b 100644 --- a/src/hotspot/share/cds/archiveBuilder.hpp +++ b/src/hotspot/share/cds/archiveBuilder.hpp @@ -484,7 +484,6 @@ public: void print_stats(); void report_out_of_space(const char* name, size_t needed_bytes); -#ifdef _LP64 // The CDS archive contains pre-computed narrow Klass IDs. It carries them in the headers of // archived heap objects. With +UseCompactObjectHeaders, it also carries them in prototypes // in Klass. @@ -504,7 +503,6 @@ public: // TinyClassPointer Mode: // We use the highest possible shift value to maximize the encoding range size. static int precomputed_narrow_klass_shift(); -#endif // _LP64 }; diff --git a/src/hotspot/share/cds/archiveUtils.cpp b/src/hotspot/share/cds/archiveUtils.cpp index c13b447bb87..6e0608e196b 100644 --- a/src/hotspot/share/cds/archiveUtils.cpp +++ b/src/hotspot/share/cds/archiveUtils.cpp @@ -30,6 +30,7 @@ #include "cds/cdsConfig.hpp" #include "cds/classListParser.hpp" #include "cds/classListWriter.hpp" +#include "cds/dumpAllocStats.hpp" #include "cds/dynamicArchive.hpp" #include "cds/filemap.hpp" #include "cds/heapShared.hpp" @@ -46,6 +47,7 @@ #include "utilities/debug.hpp" #include "utilities/formatBuffer.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/rbTree.inline.hpp" #include "utilities/spinYield.hpp" CHeapBitMap* ArchivePtrMarker::_ptrmap = nullptr; @@ -116,13 +118,17 @@ void ArchivePtrMarker::mark_pointer(address* ptr_loc) { if (ptr_base() <= ptr_loc && ptr_loc < ptr_end()) { address value = *ptr_loc; - // We don't want any pointer that points to very bottom of the archive, otherwise when - // AOTMetaspace::default_base_address()==0, we can't distinguish between a pointer - // to nothing (null) vs a pointer to an objects that happens to be at the very bottom - // of the archive. - assert(value != (address)ptr_base(), "don't point to the bottom of the archive"); - if (value != nullptr) { + // We don't want any pointer that points to very bottom of the AOT metaspace, otherwise + // when AOTMetaspace::default_base_address()==0, we can't distinguish between a pointer + // to nothing (null) vs a pointer to an objects that happens to be at the very bottom + // of the AOT metaspace. + // + // This should never happen because the protection zone prevents any valid objects from + // being allocated at the bottom of the AOT metaspace. + assert(AOTMetaspace::protection_zone_size() > 0, "must be"); + assert(ArchiveBuilder::current()->any_to_offset(value) > 0, "cannot point to bottom of AOT metaspace"); + assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses"); size_t idx = ptr_loc - ptr_base(); if (_ptrmap->size() <= idx) { @@ -130,7 +136,6 @@ void ArchivePtrMarker::mark_pointer(address* ptr_loc) { } assert(idx < _ptrmap->size(), "must be"); _ptrmap->set_bit(idx); - //tty->print_cr("Marking pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ %5zu", p2i(ptr_loc), p2i(*ptr_loc), idx); } } } @@ -144,7 +149,6 @@ void ArchivePtrMarker::clear_pointer(address* ptr_loc) { size_t idx = ptr_loc - ptr_base(); assert(idx < _ptrmap->size(), "cannot clear pointers that have not been marked"); _ptrmap->clear_bit(idx); - //tty->print_cr("Clearing pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ %5zu", p2i(ptr_loc), p2i(*ptr_loc), idx); } class ArchivePtrBitmapCleaner: public BitMapClosure { @@ -249,16 +253,179 @@ void DumpRegion::commit_to(char* newtop) { which, commit, _vs->actual_committed_size(), _vs->high()); } +// Basic allocation. Any alignment gaps will be wasted. char* DumpRegion::allocate(size_t num_bytes, size_t alignment) { // Always align to at least minimum alignment alignment = MAX2(SharedSpaceObjectAlignment, alignment); char* p = (char*)align_up(_top, alignment); - char* newtop = p + align_up(num_bytes, (size_t)SharedSpaceObjectAlignment); + char* newtop = p + align_up(num_bytes, SharedSpaceObjectAlignment); expand_top_to(newtop); memset(p, 0, newtop - p); return p; } +class DumpRegion::AllocGap { + size_t _gap_bytes; // size of this gap in bytes + char* _gap_bottom; // must be SharedSpaceObjectAlignment aligned +public: + size_t gap_bytes() const { return _gap_bytes; } + char* gap_bottom() const { return _gap_bottom; } + + AllocGap(size_t bytes, char* bottom) : _gap_bytes(bytes), _gap_bottom(bottom) { + precond(is_aligned(gap_bytes(), SharedSpaceObjectAlignment)); + precond(is_aligned(gap_bottom(), SharedSpaceObjectAlignment)); + } +}; + +struct DumpRegion::AllocGapCmp { + static RBTreeOrdering cmp(AllocGap a, AllocGap b) { + RBTreeOrdering order = rbtree_primitive_cmp(a.gap_bytes(), b.gap_bytes()); + if (order == RBTreeOrdering::EQ) { + order = rbtree_primitive_cmp(a.gap_bottom(), b.gap_bottom()); + } + return order; + } +}; + +struct Empty {}; +using AllocGapNode = RBNode; + +class DumpRegion::AllocGapTree : public RBTreeCHeap { +public: + size_t add_gap(char* gap_bottom, char* gap_top) { + precond(gap_bottom < gap_top); + size_t gap_bytes = pointer_delta(gap_top, gap_bottom, 1); + precond(gap_bytes > 0); + + _total_gap_bytes += gap_bytes; + + AllocGap gap(gap_bytes, gap_bottom); // constructor checks alignment + AllocGapNode* node = allocate_node(gap, Empty{}); + insert(gap, node); + + log_trace(aot, alloc)("adding a gap of %zu bytes @ %p (total = %zu) in %zu blocks", gap_bytes, gap_bottom, _total_gap_bytes, size()); + return gap_bytes; + } + + char* allocate_from_gap(size_t num_bytes) { + // The gaps are sorted in ascending order of their sizes. When two gaps have the same + // size, the one with a lower gap_bottom comes first. + // + // Find the first gap that's big enough, with the lowest gap_bottom. + AllocGap target(num_bytes, nullptr); + AllocGapNode* node = closest_ge(target); + if (node == nullptr) { + return nullptr; // Didn't find any usable gap. + } + + size_t gap_bytes = node->key().gap_bytes(); + char* gap_bottom = node->key().gap_bottom(); + char* result = gap_bottom; + precond(is_aligned(result, SharedSpaceObjectAlignment)); + + remove(node); + + precond(_total_gap_bytes >= num_bytes); + _total_gap_bytes -= num_bytes; + _total_gap_bytes_used += num_bytes; + _total_gap_allocs++; + DEBUG_ONLY(node = nullptr); // Don't use it anymore! + + precond(gap_bytes >= num_bytes); + if (gap_bytes > num_bytes) { + gap_bytes -= num_bytes; + gap_bottom += num_bytes; + + AllocGap gap(gap_bytes, gap_bottom); // constructor checks alignment + AllocGapNode* new_node = allocate_node(gap, Empty{}); + insert(gap, new_node); + } + log_trace(aot, alloc)("%zu bytes @ %p in a gap of %zu bytes (used gaps %zu times, remain gap = %zu bytes in %zu blocks)", + num_bytes, result, gap_bytes, _total_gap_allocs, _total_gap_bytes, size()); + return result; + } +}; + +size_t DumpRegion::_total_gap_bytes = 0; +size_t DumpRegion::_total_gap_bytes_used = 0; +size_t DumpRegion::_total_gap_allocs = 0; +DumpRegion::AllocGapTree DumpRegion::_gap_tree; + +// Alignment gaps happen only for the RW space. Collect the gaps into the _gap_tree so they can be +// used for future small object allocation. +char* DumpRegion::allocate_metaspace_obj(size_t num_bytes, address src, MetaspaceClosureType type, bool read_only, DumpAllocStats* stats) { + num_bytes = align_up(num_bytes, SharedSpaceObjectAlignment); + size_t alignment = SharedSpaceObjectAlignment; // alignment for the dest pointer + bool is_class = (type == MetaspaceClosureType::ClassType); + bool is_instance_class = is_class && ((Klass*)src)->is_instance_klass(); + +#ifdef _LP64 + // More strict alignments needed for Klass objects + if (is_class) { + size_t klass_alignment = checked_cast(nth_bit(ArchiveBuilder::precomputed_narrow_klass_shift())); + alignment = MAX2(alignment, klass_alignment); + precond(is_aligned(alignment, SharedSpaceObjectAlignment)); + } +#endif + + if (alignment == SharedSpaceObjectAlignment && type != MetaspaceClosureType::SymbolType) { + // The addresses of Symbols must be in the same order as they are in ArchiveBuilder::SourceObjList. + // If we put them in gaps, their order will change. + // + // We have enough small objects that all gaps are usually filled. + char* p = _gap_tree.allocate_from_gap(num_bytes); + if (p != nullptr) { + // Already memset to 0 when adding the gap + stats->record(type, checked_cast(num_bytes), /*read_only=*/false); // all gaps are from RW space (for classes) + return p; + } + } + + // Reserve space for a pointer directly in front of the buffered InstanceKlass, so + // we can do a quick lookup from InstanceKlass* -> RunTimeClassInfo* + // without building another hashtable. See RunTimeClassInfo::get_for() + // in systemDictionaryShared.cpp. + const size_t RuntimeClassInfoPtrSize = is_instance_class ? sizeof(address) : 0; + + if (is_class && !is_aligned(top() + RuntimeClassInfoPtrSize, alignment)) { + // We need to add a gap to align the buffered Klass. Save the gap for future small allocations. + assert(read_only == false, "only gaps in RW region are reusable"); + char* gap_bottom = top(); + char* gap_top = align_up(gap_bottom + RuntimeClassInfoPtrSize, alignment) - RuntimeClassInfoPtrSize; + size_t gap_bytes = _gap_tree.add_gap(gap_bottom, gap_top); + allocate(gap_bytes); + } + + char* oldtop = top(); + if (is_instance_class) { + SystemDictionaryShared::validate_before_archiving((InstanceKlass*)src); + allocate(RuntimeClassInfoPtrSize); + } + + precond(is_aligned(top(), alignment)); + char* result = allocate(num_bytes); + log_trace(aot, alloc)("%zu bytes @ %p", num_bytes, result); + stats->record(type, pointer_delta_as_int(top(), oldtop), read_only); // includes RuntimeClassInfoPtrSize for classes + + return result; +} + +// Usually we have no gaps left. +void DumpRegion::report_gaps(DumpAllocStats* stats) { + _gap_tree.visit_in_order([&](const AllocGapNode* node) { + stats->record_gap(checked_cast(node->key().gap_bytes())); + return true; + }); + if (_gap_tree.size() > 0) { + log_warning(aot)("Unexpected %zu gaps (%zu bytes) for Klass alignment", + _gap_tree.size(), _total_gap_bytes); + } + if (_total_gap_allocs > 0) { + log_info(aot)("Allocated %zu objects of %zu bytes in gaps (remain = %zu bytes)", + _total_gap_allocs, _total_gap_bytes_used, _total_gap_bytes); + } +} + void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) { assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment"); intptr_t *p = (intptr_t*)_top; @@ -312,22 +479,9 @@ void DumpRegion::pack(DumpRegion* next) { } void WriteClosure::do_ptr(void** p) { - // Write ptr into the archive; ptr can be: - // (a) null -> written as 0 - // (b) a "buffered" address -> written as is - // (c) a "source" address -> convert to "buffered" and write - // The common case is (c). E.g., when writing the vmClasses into the archive. - // We have (b) only when we don't have a corresponding source object. E.g., - // the archived c++ vtable entries. address ptr = *(address*)p; - if (ptr != nullptr && !ArchiveBuilder::current()->is_in_buffer_space(ptr)) { - ptr = ArchiveBuilder::current()->get_buffered_addr(ptr); - } - // null pointers do not need to be converted to offsets - if (ptr != nullptr) { - ptr = (address)ArchiveBuilder::current()->buffer_to_offset(ptr); - } - _dump_region->append_intptr_t((intptr_t)ptr, false); + AOTCompressedPointers::narrowPtr narrowp = AOTCompressedPointers::encode(ptr); + _dump_region->append_intptr_t(checked_cast(narrowp), false); } void ReadClosure::do_ptr(void** p) { diff --git a/src/hotspot/share/cds/archiveUtils.hpp b/src/hotspot/share/cds/archiveUtils.hpp index e5d1efa5eab..84ad8e6bdf3 100644 --- a/src/hotspot/share/cds/archiveUtils.hpp +++ b/src/hotspot/share/cds/archiveUtils.hpp @@ -28,7 +28,9 @@ #include "cds/cds_globals.hpp" #include "cds/serializeClosure.hpp" #include "logging/log.hpp" +#include "memory/allocation.hpp" #include "memory/metaspace.hpp" +#include "memory/metaspaceClosureType.hpp" #include "memory/virtualspace.hpp" #include "runtime/nonJavaThread.hpp" #include "runtime/semaphore.hpp" @@ -37,6 +39,7 @@ #include "utilities/macros.hpp" class BootstrapInfo; +class DumpAllocStats; class ReservedSpace; class VirtualSpace; @@ -159,6 +162,18 @@ private: void commit_to(char* newtop); +public: + // Allocation gaps (due to Klass alignment) + class AllocGapTree; + class AllocGap; + struct AllocGapCmp; + +private: + static AllocGapTree _gap_tree; + static size_t _total_gap_bytes; + static size_t _total_gap_bytes_used; + static size_t _total_gap_allocs; + public: DumpRegion(const char* name) : _name(name), _base(nullptr), _top(nullptr), _end(nullptr), @@ -167,6 +182,7 @@ public: char* expand_top_to(char* newtop); char* allocate(size_t num_bytes, size_t alignment = 0); + char* allocate_metaspace_obj(size_t num_bytes, address src, MetaspaceClosureType type, bool read_only, DumpAllocStats* stats); void append_intptr_t(intptr_t n, bool need_to_mark = false) NOT_CDS_RETURN; @@ -191,6 +207,8 @@ public: bool contains(char* p) { return base() <= p && p < top(); } + + static void report_gaps(DumpAllocStats* stats); }; // Closure for serializing initialization data out to a data area to be diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index f4ef3c66f7a..ecf3c6d2231 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -108,6 +108,8 @@ void CDSConfig::ergo_initialize() { } AOTMapLogger::ergo_initialize(); + + setup_compiler_args(); } const char* CDSConfig::default_archive_path() { @@ -635,8 +637,6 @@ bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_fla FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true); } - setup_compiler_args(); - if (AOTClassLinking) { // If AOTClassLinking is specified, enable all AOT optimizations by default. FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true); @@ -891,10 +891,6 @@ const char* CDSConfig::type_of_archive_being_written() { // If an incompatible VM options is found, return a text message that explains why static const char* check_options_incompatible_with_dumping_heap() { #if INCLUDE_CDS_JAVA_HEAP - if (!UseCompressedClassPointers) { - return "UseCompressedClassPointers must be true"; - } - return nullptr; #else return "JVM not configured for writing Java heap objects"; @@ -972,17 +968,27 @@ bool CDSConfig::is_loading_heap() { } bool CDSConfig::is_dumping_klass_subgraphs() { - if (is_dumping_classic_static_archive() || is_dumping_final_static_archive()) { + if (is_dumping_aot_linked_classes()) { // KlassSubGraphs (see heapShared.cpp) is a legacy mechanism for archiving oops. It // has been superceded by AOT class linking. This feature is used only when // AOT class linking is disabled. - // - // KlassSubGraphs are disabled in the preimage static archive, which contains a very - // limited set of oops. - return is_dumping_heap() && !is_dumping_aot_linked_classes(); - } else { return false; } + + if (is_dumping_preimage_static_archive()) { + // KlassSubGraphs are disabled in the preimage static archive, which contains a very + // limited set of oops. + return false; + } + + if (!is_dumping_full_module_graph()) { + // KlassSubGraphs cannot be partially disabled. Since some of the KlassSubGraphs + // are used for (legacy support) of the archived full module graph, if + // is_dumping_full_module_graph() is calse, we must disable all KlassSubGraphs. + return false; + } + + return is_dumping_heap(); } bool CDSConfig::is_using_klass_subgraphs() { diff --git a/src/hotspot/share/cds/cdsHeapVerifier.hpp b/src/hotspot/share/cds/cdsHeapVerifier.hpp index 7f1bdb1d249..f8e090801bb 100644 --- a/src/hotspot/share/cds/cdsHeapVerifier.hpp +++ b/src/hotspot/share/cds/cdsHeapVerifier.hpp @@ -53,7 +53,7 @@ class CDSHeapVerifier : public KlassClosure { 15889, // prime number AnyObj::C_HEAP, mtClassShared, - HeapShared::oop_hash> _table; + HeapShared::oop_address_hash> _table; GrowableArray _exclusions; GrowableArray _shared_secret_accessors; diff --git a/src/hotspot/share/cds/cppVtables.cpp b/src/hotspot/share/cds/cppVtables.cpp index da68fa70761..dc5a777d7b1 100644 --- a/src/hotspot/share/cds/cppVtables.cpp +++ b/src/hotspot/share/cds/cppVtables.cpp @@ -140,7 +140,7 @@ void CppVtableCloner::initialize(const char* name, CppVtableInfo* info) { // We already checked (and, if necessary, adjusted n) when the vtables were allocated, so we are // safe to do memcpy. - log_debug(aot, vtables)("Copying %3d vtable entries for %s", n, name); + log_debug(aot, vtables)("Copying %3d vtable entries for %s to " INTPTR_FORMAT, n, name, p2i(dstvtable)); memcpy(dstvtable, srcvtable, sizeof(intptr_t) * n); } diff --git a/src/hotspot/share/cds/dumpAllocStats.cpp b/src/hotspot/share/cds/dumpAllocStats.cpp index 5f324566103..ddd4bac6086 100644 --- a/src/hotspot/share/cds/dumpAllocStats.cpp +++ b/src/hotspot/share/cds/dumpAllocStats.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -129,15 +129,3 @@ void DumpAllocStats::print_stats(int ro_all, int rw_all) { _bytes [RW][MethodTrainingDataType]); } - -#ifdef ASSERT -void DumpAllocStats::verify(int expected_byte_size, bool read_only) const { - int bytes = 0; - const int what = (int)(read_only ? RO : RW); - for (int type = 0; type < int(_number_of_types); type ++) { - bytes += _bytes[what][type]; - } - assert(bytes == expected_byte_size, "counter mismatch (%s: %d vs %d)", - (read_only ? "RO" : "RW"), bytes, expected_byte_size); -} -#endif // ASSERT diff --git a/src/hotspot/share/cds/dumpAllocStats.hpp b/src/hotspot/share/cds/dumpAllocStats.hpp index 4553f0f6a01..4daef9195a6 100644 --- a/src/hotspot/share/cds/dumpAllocStats.hpp +++ b/src/hotspot/share/cds/dumpAllocStats.hpp @@ -41,6 +41,7 @@ public: f(StringHashentry) \ f(StringBucket) \ f(CppVTables) \ + f(Gap) \ f(Other) #define DUMPED_TYPE_DECLARE(name) name ## Type, @@ -111,12 +112,19 @@ public: _bytes [which][t] += byte_size; } + void record_gap(int byte_size) { + _counts[RW][GapType] += 1; + _bytes [RW][GapType] += byte_size; + } + void record_other_type(int byte_size, bool read_only) { int which = (read_only) ? RO : RW; + _counts[which][OtherType] += 1; _bytes [which][OtherType] += byte_size; } void record_cpp_vtables(int byte_size) { + _counts[RW][CppVTablesType] += 1; _bytes[RW][CppVTablesType] += byte_size; } @@ -145,9 +153,6 @@ public: } void print_stats(int ro_all, int rw_all); - - DEBUG_ONLY(void verify(int expected_byte_size, bool read_only) const); - }; #endif // SHARE_CDS_DUMPALLOCSTATS_HPP diff --git a/src/hotspot/share/cds/dumpTimeClassInfo.hpp b/src/hotspot/share/cds/dumpTimeClassInfo.hpp index c2f83b22337..d2de8148bea 100644 --- a/src/hotspot/share/cds/dumpTimeClassInfo.hpp +++ b/src/hotspot/share/cds/dumpTimeClassInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,6 @@ class Symbol; class DumpTimeClassInfo: public CHeapObj { bool _excluded; bool _is_aot_tooling_class; - bool _is_early_klass; bool _has_checked_exclusion; class DTLoaderConstraint { @@ -143,7 +142,6 @@ public: _clsfile_crc32 = -1; _excluded = false; _is_aot_tooling_class = false; - _is_early_klass = JvmtiExport::is_early_phase(); _verifier_constraints = nullptr; _verifier_constraint_flags = nullptr; _loader_constraints = nullptr; @@ -219,11 +217,6 @@ public: _is_aot_tooling_class = true; } - // Was this class loaded while JvmtiExport::is_early_phase()==true - bool is_early_klass() { - return _is_early_klass; - } - // simple accessors void set_excluded() { _excluded = true; } bool has_checked_exclusion() const { return _has_checked_exclusion; } diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index da2d4f6dac2..38502b2b2d8 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -225,15 +225,9 @@ void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment, } #endif _compressed_oops = UseCompressedOops; - _compressed_class_ptrs = UseCompressedClassPointers; - if (UseCompressedClassPointers) { -#ifdef _LP64 - _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits(); - _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift(); -#endif - } else { - _narrow_klass_pointer_bits = _narrow_klass_shift = -1; - } + _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits(); + _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift(); + // Which JIT compier is used _compiler_type = (u1)CompilerConfig::compiler_type(); _type_profile_level = TypeProfileLevel; @@ -295,7 +289,6 @@ void FileMapHeader::print(outputStream* st) { st->print_cr("- max_heap_size: %zu", _max_heap_size); st->print_cr("- narrow_oop_mode: %d", _narrow_oop_mode); st->print_cr("- compressed_oops: %d", _compressed_oops); - st->print_cr("- compressed_class_ptrs: %d", _compressed_class_ptrs); st->print_cr("- narrow_klass_pointer_bits: %d", _narrow_klass_pointer_bits); st->print_cr("- narrow_klass_shift: %d", _narrow_klass_shift); st->print_cr("- cloned_vtables: %u", cast_to_u4(_cloned_vtables)); @@ -717,8 +710,8 @@ bool FileMapInfo::init_from_file(int fd) { } void FileMapInfo::seek_to_position(size_t pos) { - if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) { - aot_log_error(aot)("Unable to seek to position %zu", pos); + if (os::lseek(_fd, (jlong)pos, SEEK_SET) < 0) { + aot_log_error(aot)("Unable to seek to position %zu (errno=%d: %s)", pos, errno, os::strerror(errno)); AOTMetaspace::unrecoverable_loading_error(); } } @@ -1535,10 +1528,34 @@ bool FileMapInfo::can_use_heap_region() { if (!has_heap_region()) { return false; } - if (!object_streaming_mode() && !Universe::heap()->can_load_archived_objects() && !UseG1GC) { - // Incompatible object format + + if (!object_streaming_mode() && !AOTMappedHeapLoader::can_use()) { + // Currently this happens only when using ZGC with an AOT cache generated with -XX:-AOTStreamableObjects + AOTMetaspace::report_loading_error("CDS heap data cannot be used by the selected GC. " + "Please choose a different GC or rebuild AOT cache " + "with -XX:+AOTStreamableObjects"); return false; } + + if (CDSConfig::is_using_aot_linked_classes()) { + assert(!JvmtiExport::should_post_class_file_load_hook(), "already checked"); + assert(CDSConfig::is_using_full_module_graph(), "already checked"); + } else { + if (JvmtiExport::should_post_class_file_load_hook()) { + AOTMetaspace::report_loading_error("CDS heap data is disabled because JVMTI ClassFileLoadHook is in use."); + return false; + } + if (!CDSConfig::is_using_full_module_graph()) { + if (CDSConfig::is_dumping_final_static_archive()) { + // We are loading the preimage static archive, which has no KlassSubGraphs. + // See CDSConfig::is_dumping_klass_subgraphs() + } else { + AOTMetaspace::report_loading_error("CDS heap data is disabled because archived full module graph is not used."); + return false; + } + } + } + if (JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()) { ShouldNotReachHere(); // CDS should have been disabled. // The archived objects are mapped at JVM start-up, but we don't know if @@ -1902,11 +1919,12 @@ bool FileMapHeader::validate() { _has_platform_or_app_classes = false; } - aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d", - file_type, compressed_oops(), compressed_class_pointers(), compact_headers()); - if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) { - aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is " - "different from runtime, CDS will be disabled.", file_type); + aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompactObjectHeaders = %d", + file_type, compressed_oops(), compact_headers()); + if (compressed_oops() != UseCompressedOops) { + aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops (%d) is " + "different from runtime (%d), CDS will be disabled.", file_type, + compressed_oops(), UseCompressedOops); return false; } diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index 56b88df378a..bae08bd5bc7 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -120,7 +120,6 @@ private: CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode bool _object_streaming_mode; // dump was created for object streaming bool _compressed_oops; // save the flag UseCompressedOops - bool _compressed_class_ptrs; // save the flag UseCompressedClassPointers int _narrow_klass_pointer_bits; // save number of bits in narrowKlass int _narrow_klass_shift; // save shift width used to pre-compute narrowKlass IDs in archived heap objects narrowPtr _cloned_vtables; // The address of the first cloned vtable @@ -200,7 +199,6 @@ public: bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; } bool has_aot_linked_classes() const { return _has_aot_linked_classes; } bool compressed_oops() const { return _compressed_oops; } - bool compressed_class_pointers() const { return _compressed_class_ptrs; } int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; } int narrow_klass_shift() const { return _narrow_klass_shift; } bool has_full_module_graph() const { return _has_full_module_graph; } diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index c01e6ded25a..3d10e7e1f88 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -131,17 +131,14 @@ static ArchivableStaticFieldInfo archive_subgraph_entry_fields[] = { {"java/lang/module/Configuration", "EMPTY_CONFIGURATION"}, {"jdk/internal/math/FDBigInteger", "archivedCaches"}, -#ifndef PRODUCT - {nullptr, nullptr}, // Extra slot for -XX:ArchiveHeapTestClass -#endif - {nullptr, nullptr}, -}; - -// full module graph -static ArchivableStaticFieldInfo fmg_archive_subgraph_entry_fields[] = { + // full module graph support {"jdk/internal/loader/ArchivedClassLoaders", "archivedClassLoaders"}, {ARCHIVED_BOOT_LAYER_CLASS, ARCHIVED_BOOT_LAYER_FIELD}, {"java/lang/Module$ArchivedData", "archivedData"}, + +#ifndef PRODUCT + {nullptr, nullptr}, // Extra slot for -XX:ArchiveHeapTestClass +#endif {nullptr, nullptr}, }; @@ -164,8 +161,7 @@ bool HeapShared::is_subgraph_root_class(InstanceKlass* ik) { assert(CDSConfig::is_dumping_heap(), "dump-time only"); if (CDSConfig::is_dumping_klass_subgraphs()) { // Legacy CDS archive support (to be deprecated) - return is_subgraph_root_class_of(archive_subgraph_entry_fields, ik) || - is_subgraph_root_class_of(fmg_archive_subgraph_entry_fields, ik); + return is_subgraph_root_class_of(archive_subgraph_entry_fields, ik); } else { return false; } @@ -175,23 +171,39 @@ oop HeapShared::CachedOopInfo::orig_referrer() const { return _orig_referrer.resolve(); } -unsigned HeapShared::oop_hash(oop const& p) { +// This is a simple hashing of the oop's address. This function is used +// while copying the oops into the AOT heap region. We don't want to +// have any side effects during the copying, so we avoid calling +// p->identity_hash() which can update the object header. +unsigned HeapShared::oop_address_hash(oop const& p) { assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current()->is_in_no_safepoint_scope(), "sanity"); - // Do not call p->identity_hash() as that will update the - // object header. return primitive_hash(cast_from_oop(p)); } -unsigned int HeapShared::oop_handle_hash_raw(const OopHandle& oh) { - return oop_hash(oh.resolve()); -} - -unsigned int HeapShared::oop_handle_hash(const OopHandle& oh) { +// About the hashcode in the cached objects: +// - If a source object has a hashcode, it must be copied into the cache. +// That's because some cached hashtables are laid out using this hashcode. +// - If a source object doesn't have a hashcode, we avoid computing it while +// copying the objects into the cache. This will allow the hashcode to be +// dynamically and randomly computed in each production, which generally +// desirable to make the hashcodes more random between runs. +unsigned HeapShared::archived_object_cache_hash(OopHandle const& oh) { oop o = oh.resolve(); if (o == nullptr) { return 0; + } + if (!_use_identity_hash_for_archived_object_cache) { + // This is called while we are copying the objects. Don't call o->identity_hash() + // as that will update the object header. + return oop_address_hash(o); } else { + // This is called after all objects are copied. It's OK to update + // the object's hashcode. + // + // This may be called after we have left the AOT dumping safepoint. + // Objects in archived_object_cache() may be moved by the GC, so we + // can't use the address of o for computing the hash. return o->identity_hash(); } } @@ -247,8 +259,36 @@ void HeapShared::reset_archived_object_states(TRAPS) { reset_states(boot_loader(), CHECK); } +void HeapShared::ensure_determinism(TRAPS) { + TempNewSymbol class_name = SymbolTable::new_symbol("jdk/internal/util/WeakReferenceKey"); + TempNewSymbol method_name = SymbolTable::new_symbol("ensureDeterministicAOTCache"); + + Klass* weak_ref_key_class = SystemDictionary::resolve_or_fail(class_name, true, CHECK); + precond(weak_ref_key_class != nullptr); + + log_debug(aot)("Calling WeakReferenceKey::ensureDeterministicAOTCache(Object.class)"); + JavaValue result(T_BOOLEAN); + JavaCalls::call_static(&result, + weak_ref_key_class, + method_name, + vmSymbols::void_boolean_signature(), + CHECK); + assert(result.get_jboolean() == false, "sanity"); +} + +void HeapShared::prepare_for_archiving(TRAPS) { + reset_archived_object_states(CHECK); + ensure_determinism(CHECK); +} + HeapShared::ArchivedObjectCache* HeapShared::_archived_object_cache = nullptr; +// Controls the hashing method for the _archived_object_cache. +// Changes from false to true once, after all objects are copied, +// inside make_archived_object_cache_gc_safe(). +// See archived_object_cache_hash() for more details. +bool HeapShared::_use_identity_hash_for_archived_object_cache = false; + bool HeapShared::is_archived_heap_in_use() { if (HeapShared::is_loading()) { if (HeapShared::is_loading_streaming_mode()) { @@ -362,9 +402,8 @@ void HeapShared::materialize_thread_object() { } } -void HeapShared::add_to_dumped_interned_strings(oop string) { +void HeapShared::archive_interned_string(oop string) { assert(HeapShared::is_writing_mapping_mode(), "Only used by this mode"); - AOTMappedHeapWriter::add_to_dumped_interned_strings(string); bool success = archive_reachable_objects_from(1, _dump_time_special_subgraph, string); assert(success, "shared strings array must not point to arrays or strings that are too large to archive"); } @@ -382,6 +421,24 @@ void HeapShared::finalize_initialization(FileMapInfo* static_mapinfo) { } } +void HeapShared::make_archived_object_cache_gc_safe() { + ArchivedObjectCache* new_cache = new (mtClass)ArchivedObjectCache(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE); + + // It's safe to change the behavior of the hash function now, because iterate_all() + // doesn't call the hash function. + // See archived_object_cache_hash() for more details. + assert(_use_identity_hash_for_archived_object_cache == false, "happens only once"); + _use_identity_hash_for_archived_object_cache = true; + + // Copy all CachedOopInfo into a new table using a different hashing algorithm + archived_object_cache()->iterate_all([&] (OopHandle oh, CachedOopInfo info) { + new_cache->put_when_absent(oh, info); + }); + + destroy_archived_object_cache(); + _archived_object_cache = new_cache; +} + HeapShared::CachedOopInfo* HeapShared::get_cached_oop_info(oop obj) { OopHandle oh(Universe::vm_global(), obj); CachedOopInfo* result = _archived_object_cache->get(oh); @@ -395,14 +452,53 @@ bool HeapShared::has_been_archived(oop obj) { } int HeapShared::append_root(oop obj) { + assert(SafepointSynchronize::is_at_safepoint(), "sanity"); assert(CDSConfig::is_dumping_heap(), "dump-time only"); - if (obj != nullptr) { - assert(has_been_archived(obj), "must be"); - } - // No GC should happen since we aren't scanning _pending_roots. - assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread"); + assert(_pending_roots != nullptr, "sanity"); - return _pending_roots->append(obj); + if (obj == nullptr) { + assert(_pending_roots->at(0) == nullptr, "root index 0 always maps to null"); + return 0; + } else if (CDSConfig::is_dumping_aot_linked_classes()) { + // The AOT compiler may refer the same obj many times, so we + // should use the same index for this oop to avoid excessive entries + // in the roots array. + CachedOopInfo* obj_info = get_cached_oop_info(obj); + assert(obj_info != nullptr, "must be archived"); + + if (obj_info->root_index() > 0) { + return obj_info->root_index(); + } else { + assert(obj_info->root_index() < 0, "must not be zero"); + int i = _pending_roots->append(obj); + obj_info->set_root_index(i); + return i; + } + } else { + return _pending_roots->append(obj); + } +} + +int HeapShared::get_root_index(oop obj) { + if (java_lang_Class::is_instance(obj)) { + obj = scratch_java_mirror(obj); + } + + CachedOopInfo* obj_info = get_cached_oop_info(obj); + const char* error = nullptr; + if (obj_info == nullptr) { + error = "Not a cached oop"; + } else if (obj_info->root_index() < 0) { + error = "Not a cached oop root"; + } else { + return obj_info->root_index(); + } + + ResourceMark rm; + log_debug(aot, codecache, oops)("%s: " INTPTR_FORMAT " (%s)", error, + cast_from_oop(obj), + obj->klass()->external_name()); + return -1; } oop HeapShared::get_root(int index, bool clear) { @@ -431,6 +527,13 @@ void HeapShared::finish_materialize_objects() { } void HeapShared::clear_root(int index) { + if (CDSConfig::is_using_aot_linked_classes()) { + // When AOT linked classes are in use, all roots will be in use all + // the time, there's no benefit for clearing the roots. Also, we + // can't clear the roots as they can be shared. + return; + } + assert(index >= 0, "sanity"); assert(CDSConfig::is_using_archive(), "must be"); if (is_archived_heap_in_use()) { @@ -461,6 +564,7 @@ bool HeapShared::archive_object(oop obj, oop referrer, KlassSubGraphInfo* subgra return false; } + AOTArtifactFinder::add_cached_class(obj->klass()); AOTOopChecker::check(obj); // Make sure contents of this oop are safe. count_allocation(obj->size()); @@ -578,9 +682,10 @@ objArrayOop HeapShared::scratch_resolved_references(ConstantPool* src) { return (objArrayOop)_scratch_objects_table->get_oop(src); } - void HeapShared::init_dumping() { - _scratch_objects_table = new (mtClass)MetaspaceObjToOopHandleTable(); - _pending_roots = new GrowableArrayCHeap(500); +void HeapShared::init_dumping() { + _scratch_objects_table = new (mtClass)MetaspaceObjToOopHandleTable(); + _pending_roots = new GrowableArrayCHeap(500); + _pending_roots->append(nullptr); // root index 0 represents a null oop } void HeapShared::init_scratch_objects_for_basic_type_mirrors(TRAPS) { @@ -817,7 +922,7 @@ void HeapShared::start_scanning_for_oops() { // The special subgraph doesn't belong to any class. We use Object_klass() here just // for convenience. - _dump_time_special_subgraph = init_subgraph_info(vmClasses::Object_klass(), false); + _dump_time_special_subgraph = init_subgraph_info(vmClasses::Object_klass()); // Cache for recording where the archived objects are copied to create_archived_object_cache(); @@ -861,6 +966,11 @@ void HeapShared::write_heap(AOTMappedHeapInfo* mapped_heap_info, AOTStreamedHeap ArchiveBuilder::OtherROAllocMark mark; write_subgraph_info_table(); + + delete _pending_roots; + _pending_roots = nullptr; + + make_archived_object_cache_gc_safe(); } void HeapShared::scan_java_mirror(oop orig_mirror) { @@ -890,12 +1000,7 @@ void HeapShared::archive_subgraphs() { assert(CDSConfig::is_dumping_heap(), "must be"); if (CDSConfig::is_dumping_klass_subgraphs()) { - archive_object_subgraphs(archive_subgraph_entry_fields, - false /* is_full_module_graph */); - if (CDSConfig::is_dumping_full_module_graph()) { - archive_object_subgraphs(fmg_archive_subgraph_entry_fields, - true /* is_full_module_graph */); - } + archive_object_subgraphs(archive_subgraph_entry_fields); } } @@ -908,12 +1013,11 @@ HeapShared::RunTimeKlassSubGraphInfoTable HeapShared::_run_time_subgraph_info_ // Get the subgraph_info for Klass k. A new subgraph_info is created if // there is no existing one for k. The subgraph_info records the "buffered" // address of the class. -KlassSubGraphInfo* HeapShared::init_subgraph_info(Klass* k, bool is_full_module_graph) { +KlassSubGraphInfo* HeapShared::init_subgraph_info(Klass* k) { assert(CDSConfig::is_dumping_heap(), "dump time only"); bool created; KlassSubGraphInfo* info = - _dump_time_subgraph_info_table->put_if_absent(k, KlassSubGraphInfo(k, is_full_module_graph), - &created); + _dump_time_subgraph_info_table->put_if_absent(k, KlassSubGraphInfo(k), &created); assert(created, "must not initialize twice"); return info; } @@ -1001,7 +1105,6 @@ void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k) { } _subgraph_object_klasses->append_if_missing(orig_k); - _has_non_early_klasses |= is_non_early_klass(orig_k); } void KlassSubGraphInfo::check_allowed_klass(InstanceKlass* ik) { @@ -1044,45 +1147,11 @@ void KlassSubGraphInfo::check_allowed_klass(InstanceKlass* ik) { AOTMetaspace::unrecoverable_writing_error(); } -bool KlassSubGraphInfo::is_non_early_klass(Klass* k) { - if (k->is_objArray_klass()) { - k = ObjArrayKlass::cast(k)->bottom_klass(); - } - if (k->is_instance_klass()) { - if (!SystemDictionaryShared::is_early_klass(InstanceKlass::cast(k))) { - ResourceMark rm; - log_info(aot, heap)("non-early: %s", k->external_name()); - return true; - } else { - return false; - } - } else { - return false; - } -} - // Initialize an archived subgraph_info_record from the given KlassSubGraphInfo. void ArchivedKlassSubGraphInfoRecord::init(KlassSubGraphInfo* info) { _k = ArchiveBuilder::get_buffered_klass(info->klass()); _entry_field_records = nullptr; _subgraph_object_klasses = nullptr; - _is_full_module_graph = info->is_full_module_graph(); - - if (_is_full_module_graph) { - // Consider all classes referenced by the full module graph as early -- we will be - // allocating objects of these classes during JVMTI early phase, so they cannot - // be processed by (non-early) JVMTI ClassFileLoadHook - _has_non_early_klasses = false; - } else { - _has_non_early_klasses = info->has_non_early_klasses(); - } - - if (_has_non_early_klasses) { - ResourceMark rm; - log_info(aot, heap)( - "Subgraph of klass %s has non-early klasses and cannot be used when JVMTI ClassFileLoadHook is enabled", - _k->external_name()); - } // populate the entry fields GrowableArray* entry_fields = info->subgraph_entry_fields(); @@ -1240,15 +1309,10 @@ static void verify_the_heap(Klass* k, const char* which) { // Before GC can execute, we must ensure that all oops reachable from HeapShared::roots() // have a valid klass. I.e., oopDesc::klass() must have already been resolved. -// -// Note: if a ArchivedKlassSubGraphInfoRecord contains non-early classes, and JVMTI -// ClassFileLoadHook is enabled, it's possible for this class to be dynamically replaced. In -// this case, we will not load the ArchivedKlassSubGraphInfoRecord and will clear its roots. void HeapShared::resolve_classes(JavaThread* current) { assert(CDSConfig::is_using_archive(), "runtime only!"); if (CDSConfig::is_using_klass_subgraphs()) { resolve_classes_for_subgraphs(current, archive_subgraph_entry_fields); - resolve_classes_for_subgraphs(current, fmg_archive_subgraph_entry_fields); } } @@ -1396,24 +1460,6 @@ HeapShared::resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAP } return nullptr; } else { - if (record->is_full_module_graph() && !CDSConfig::is_using_full_module_graph()) { - if (log_is_enabled(Info, aot, heap)) { - ResourceMark rm(THREAD); - log_info(aot, heap)("subgraph %s cannot be used because full module graph is disabled", - k->external_name()); - } - return nullptr; - } - - if (record->has_non_early_klasses() && JvmtiExport::should_post_class_file_load_hook()) { - if (log_is_enabled(Info, aot, heap)) { - ResourceMark rm(THREAD); - log_info(aot, heap)("subgraph %s cannot be used because JVMTI ClassFileLoadHook is enabled", - k->external_name()); - } - return nullptr; - } - if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; log_info(aot, heap)("%s subgraph %s ", do_init ? "init" : "resolve", k->external_name()); @@ -1495,8 +1541,8 @@ void HeapShared::init_archived_fields_for(Klass* k, const ArchivedKlassSubGraphI // mirror after this point. if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; - log_info(aot, heap)("initialize_from_archived_subgraph %s " PTR_FORMAT "%s%s", - k->external_name(), p2i(k), JvmtiExport::is_early_phase() ? " (early)" : "", + log_info(aot, heap)("initialize_from_archived_subgraph %s " PTR_FORMAT "%s", + k->external_name(), p2i(k), k->has_aot_initialized_mirror() ? " (aot-inited)" : ""); } } @@ -1889,6 +1935,11 @@ void HeapShared::verify_subgraph_from(oop orig_obj) { void HeapShared::verify_reachable_objects_from(oop obj) { _num_total_verifications ++; if (java_lang_Class::is_instance(obj)) { + Klass* k = java_lang_Class::as_Klass(obj); + if (RegeneratedClasses::has_been_regenerated(k)) { + k = RegeneratedClasses::get_regenerated_object(k); + obj = k->java_mirror(); + } obj = scratch_java_mirror(obj); assert(obj != nullptr, "must be"); } @@ -1957,9 +2008,9 @@ void HeapShared::set_has_been_seen_during_subgraph_recording(oop obj) { ++ _num_new_walked_objs; } -void HeapShared::start_recording_subgraph(InstanceKlass *k, const char* class_name, bool is_full_module_graph) { +void HeapShared::start_recording_subgraph(InstanceKlass *k, const char* class_name) { log_info(aot, heap)("Start recording subgraph(s) for archived fields in %s", class_name); - init_subgraph_info(k, is_full_module_graph); + init_subgraph_info(k); init_seen_objects_table(); _num_new_walked_objs = 0; _num_new_archived_objs = 0; @@ -2091,9 +2142,6 @@ void HeapShared::init_subgraph_entry_fields(TRAPS) { _dump_time_subgraph_info_table = new (mtClass)DumpTimeKlassSubGraphInfoTable(); if (CDSConfig::is_dumping_klass_subgraphs()) { init_subgraph_entry_fields(archive_subgraph_entry_fields, CHECK); - if (CDSConfig::is_dumping_full_module_graph()) { - init_subgraph_entry_fields(fmg_archive_subgraph_entry_fields, CHECK); - } } } @@ -2192,8 +2240,7 @@ void HeapShared::init_heap_writer() { } } -void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[], - bool is_full_module_graph) { +void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[]) { _num_total_subgraph_recordings = 0; _num_total_walked_objs = 0; _num_total_archived_objs = 0; @@ -2209,7 +2256,7 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[], for (int i = 0; fields[i].valid(); ) { ArchivableStaticFieldInfo* info = &fields[i]; const char* klass_name = info->klass_name; - start_recording_subgraph(info->klass, klass_name, is_full_module_graph); + start_recording_subgraph(info->klass, klass_name); // If you have specified consecutive fields of the same klass in // fields[], these will be archived in the same @@ -2242,12 +2289,22 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[], #endif } -bool HeapShared::is_dumped_interned_string(oop o) { - if (is_writing_mapping_mode()) { - return AOTMappedHeapWriter::is_dumped_interned_string(o); - } else { - return AOTStreamedHeapWriter::is_dumped_interned_string(o); +bool HeapShared::is_interned_string(oop obj) { + if (!java_lang_String::is_instance(obj)) { + return false; } + + ResourceMark rm; + int len = 0; + jchar* name = java_lang_String::as_unicode_string_or_null(obj, len); + if (name == nullptr) { + fatal("Insufficient memory for dumping"); + } + return StringTable::lookup(name, len) == obj; +} + +bool HeapShared::is_dumped_interned_string(oop o) { + return is_interned_string(o) && has_been_archived(o); } // These tables should be used only within the CDS safepoint, so diff --git a/src/hotspot/share/cds/heapShared.hpp b/src/hotspot/share/cds/heapShared.hpp index ba17ddda267..c3ad1f666b1 100644 --- a/src/hotspot/share/cds/heapShared.hpp +++ b/src/hotspot/share/cds/heapShared.hpp @@ -40,7 +40,6 @@ #include "utilities/hashTable.hpp" #if INCLUDE_CDS_JAVA_HEAP -class DumpedInternedStrings; class FileMapInfo; class KlassSubGraphInfo; class MetaspaceObjToOopHandleTable; @@ -67,21 +66,12 @@ class KlassSubGraphInfo: public CHeapObj { // For each entry field, it is a tuple of field_offset, field_value GrowableArray* _subgraph_entry_fields; - // Does this KlassSubGraphInfo belong to the archived full module graph - bool _is_full_module_graph; - - // Does this KlassSubGraphInfo references any classes that were loaded while - // JvmtiExport::is_early_phase()!=true. If so, this KlassSubGraphInfo cannot be - // used at runtime if JVMTI ClassFileLoadHook is enabled. - bool _has_non_early_klasses; static bool is_non_early_klass(Klass* k); static void check_allowed_klass(InstanceKlass* ik); public: - KlassSubGraphInfo(Klass* k, bool is_full_module_graph) : + KlassSubGraphInfo(Klass* k) : _k(k), _subgraph_object_klasses(nullptr), - _subgraph_entry_fields(nullptr), - _is_full_module_graph(is_full_module_graph), - _has_non_early_klasses(false) {} + _subgraph_entry_fields(nullptr) {} ~KlassSubGraphInfo() { if (_subgraph_object_klasses != nullptr) { @@ -105,8 +95,6 @@ class KlassSubGraphInfo: public CHeapObj { return _subgraph_object_klasses == nullptr ? 0 : _subgraph_object_klasses->length(); } - bool is_full_module_graph() const { return _is_full_module_graph; } - bool has_non_early_klasses() const { return _has_non_early_klasses; } }; // An archived record of object sub-graphs reachable from static @@ -115,7 +103,6 @@ class KlassSubGraphInfo: public CHeapObj { class ArchivedKlassSubGraphInfoRecord { private: Klass* _k; - bool _is_full_module_graph; bool _has_non_early_klasses; // contains pairs of field offset and value for each subgraph entry field @@ -131,7 +118,6 @@ class ArchivedKlassSubGraphInfoRecord { Klass* klass() const { return _k; } Array* entry_field_records() const { return _entry_field_records; } Array* subgraph_object_klasses() const { return _subgraph_object_klasses; } - bool is_full_module_graph() const { return _is_full_module_graph; } bool has_non_early_klasses() const { return _has_non_early_klasses; } }; #endif // INCLUDE_CDS_JAVA_HEAP @@ -176,7 +162,7 @@ public: static void initialize_streaming() NOT_CDS_JAVA_HEAP_RETURN; static void enable_gc() NOT_CDS_JAVA_HEAP_RETURN; static void materialize_thread_object() NOT_CDS_JAVA_HEAP_RETURN; - static void add_to_dumped_interned_strings(oop string) NOT_CDS_JAVA_HEAP_RETURN; + static void archive_interned_string(oop string); static void finalize_initialization(FileMapInfo* static_mapinfo) NOT_CDS_JAVA_HEAP_RETURN; private: @@ -195,13 +181,8 @@ private: static void print_stats(); public: static void debug_trace(); - static unsigned oop_hash(oop const& p); - static unsigned oop_handle_hash(OopHandle const& oh); - static unsigned oop_handle_hash_raw(OopHandle const& oh); + static unsigned oop_address_hash(oop const& p); static bool oop_handle_equals(const OopHandle& a, const OopHandle& b); - static unsigned string_oop_hash(oop const& string) { - return java_lang_String::hash_code(string); - } class CopyKlassSubGraphInfoToArchive; @@ -217,27 +198,37 @@ public: // One or more fields in this object are pointing to MetaspaceObj bool _has_native_pointers; + + // >= 0 if this oop has been append to the list of roots + int _root_index; public: CachedOopInfo(OopHandle orig_referrer, bool has_oop_pointers) : _orig_referrer(orig_referrer), _buffer_offset(0), _has_oop_pointers(has_oop_pointers), - _has_native_pointers(false) {} + _has_native_pointers(false), + _root_index(-1) {} oop orig_referrer() const; void set_buffer_offset(size_t offset) { _buffer_offset = offset; } size_t buffer_offset() const { return _buffer_offset; } bool has_oop_pointers() const { return _has_oop_pointers; } bool has_native_pointers() const { return _has_native_pointers; } void set_has_native_pointers() { _has_native_pointers = true; } + int root_index() const { return _root_index; } + void set_root_index(int i) { _root_index = i; } }; private: static const int INITIAL_TABLE_SIZE = 15889; // prime number static const int MAX_TABLE_SIZE = 1000000; + static bool _use_identity_hash_for_archived_object_cache; + + static unsigned archived_object_cache_hash(OopHandle const& oh); + typedef ResizeableHashTable ArchivedObjectCache; static ArchivedObjectCache* _archived_object_cache; @@ -266,8 +257,7 @@ private: static CachedOopInfo make_cached_oop_info(oop obj, oop referrer); static ArchivedKlassSubGraphInfoRecord* archive_subgraph_info(KlassSubGraphInfo* info); - static void archive_object_subgraphs(ArchivableStaticFieldInfo fields[], - bool is_full_module_graph); + static void archive_object_subgraphs(ArchivableStaticFieldInfo fields[]); // Archive object sub-graph starting from the given static field // in Klass k's mirror. @@ -281,7 +271,7 @@ private: static void verify_subgraph_from(oop orig_obj) PRODUCT_RETURN; static void check_special_subgraph_classes(); - static KlassSubGraphInfo* init_subgraph_info(Klass *k, bool is_full_module_graph); + static KlassSubGraphInfo* init_subgraph_info(Klass *k); static KlassSubGraphInfo* get_subgraph_info(Klass *k); static void init_subgraph_entry_fields(TRAPS) NOT_CDS_JAVA_HEAP_RETURN; @@ -297,7 +287,7 @@ private: typedef ResizeableHashTable SeenObjectsTable; + HeapShared::oop_address_hash> SeenObjectsTable; static SeenObjectsTable *_seen_objects_table; @@ -336,8 +326,7 @@ private: static size_t _num_total_recorded_klasses; static size_t _num_total_verifications; - static void start_recording_subgraph(InstanceKlass *k, const char* klass_name, - bool is_full_module_graph); + static void start_recording_subgraph(InstanceKlass *k, const char* klass_name); static void done_recording_subgraph(InstanceKlass *k, const char* klass_name); static bool has_been_seen_during_subgraph_recording(oop obj); @@ -382,8 +371,10 @@ private: static bool walk_one_object(PendingOopStack* stack, int level, KlassSubGraphInfo* subgraph_info, oop orig_obj, oop referrer); - public: static void reset_archived_object_states(TRAPS); + static void ensure_determinism(TRAPS); + public: + static void prepare_for_archiving(TRAPS); static void create_archived_object_cache() { _archived_object_cache = new (mtClass)ArchivedObjectCache(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE); @@ -392,6 +383,7 @@ private: delete _archived_object_cache; _archived_object_cache = nullptr; } + static void make_archived_object_cache_gc_safe(); static ArchivedObjectCache* archived_object_cache() { return _archived_object_cache; } @@ -404,6 +396,7 @@ private: KlassSubGraphInfo* subgraph_info, oop orig_obj); + static bool is_interned_string(oop obj); static bool is_dumped_interned_string(oop o); // Scratch objects for archiving Klass::java_mirror() @@ -435,6 +428,11 @@ private: // Dump-time only. Returns the index of the root, which can be used at run time to read // the root using get_root(index, ...). static int append_root(oop obj); + + // AOT-compile time only. + // Returns -1 if obj is not in the heap root set. + static int get_root_index(oop obj) NOT_CDS_JAVA_HEAP_RETURN_(-1); + static GrowableArrayCHeap* pending_roots() { return _pending_roots; } // Dump-time and runtime @@ -443,9 +441,7 @@ private: // Run-time only static void clear_root(int index); - static void get_segment_indexes(int index, int& segment_index, int& internal_index); - static void setup_test_class(const char* test_class_name) PRODUCT_RETURN; #endif // INCLUDE_CDS_JAVA_HEAP diff --git a/src/hotspot/share/classfile/classPrinter.cpp b/src/hotspot/share/classfile/classPrinter.cpp index 3ed0a5e9840..6cf89f7357f 100644 --- a/src/hotspot/share/classfile/classPrinter.cpp +++ b/src/hotspot/share/classfile/classPrinter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -224,6 +224,7 @@ void ClassPrinter::print_flags_help(outputStream* os) { os->print_cr(" 0x%02x - print info for invokehandle", PRINT_METHOD_HANDLE); os->print_cr(" 0x%02x - print details of the C++ and Java objects that represent classes", PRINT_CLASS_DETAILS); os->print_cr(" 0x%02x - print details of the C++ objects that represent methods", PRINT_METHOD_DETAILS); + os->print_cr(" 0x%02x - print MethodData", PRINT_METHOD_DATA); os->cr(); } diff --git a/src/hotspot/share/classfile/classPrinter.hpp b/src/hotspot/share/classfile/classPrinter.hpp index 470e82ddc0e..b09a1a1ef3b 100644 --- a/src/hotspot/share/classfile/classPrinter.hpp +++ b/src/hotspot/share/classfile/classPrinter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,6 +54,7 @@ public: PRINT_METHOD_HANDLE = 1 << 4, // extra information for invokehandle PRINT_CLASS_DETAILS = 1 << 5, // print details of the C++ and Java objects that represent classes PRINT_METHOD_DETAILS = 1 << 6, // print details of the C++ objects that represent methods + PRINT_METHOD_DATA = 1 << 7, // print MethodData - requires MDO lock }; static bool has_mode(int flags, Mode mode) { return (flags & static_cast(mode)) != 0; diff --git a/src/hotspot/share/classfile/compactHashtable.cpp b/src/hotspot/share/classfile/compactHashtable.cpp index 6808ae7bb8f..de67971c403 100644 --- a/src/hotspot/share/classfile/compactHashtable.cpp +++ b/src/hotspot/share/classfile/compactHashtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -96,14 +96,16 @@ void CompactHashtableWriter::allocate_table() { "Too many entries."); } - _compact_buckets = ArchiveBuilder::new_ro_array(_num_buckets + 1); - _compact_entries = ArchiveBuilder::new_ro_array(entries_space); + _num_compact_buckets = checked_cast(_num_buckets + 1); // extra slot for TABLEEND_BUCKET_TYPE + _num_compact_entries = checked_cast(entries_space); + _compact_buckets = (u4*)ArchiveBuilder::ro_region_alloc(_num_compact_buckets * sizeof(u4)); + _compact_entries = (u4*)ArchiveBuilder::ro_region_alloc(_num_compact_entries * sizeof(u4)); _stats->bucket_count = _num_buckets; - _stats->bucket_bytes = align_up(_compact_buckets->size() * BytesPerWord, + _stats->bucket_bytes = align_up(checked_cast(_num_compact_buckets * sizeof(u4)), SharedSpaceObjectAlignment); _stats->hashentry_count = _num_entries_written; - _stats->hashentry_bytes = align_up(_compact_entries->size() * BytesPerWord, + _stats->hashentry_bytes = align_up(checked_cast(_num_compact_entries * sizeof(u4)), SharedSpaceObjectAlignment); } @@ -114,21 +116,21 @@ void CompactHashtableWriter::dump_table(NumberSeq* summary) { GrowableArray* bucket = _buckets[index]; int bucket_size = bucket->length(); if (bucket_size == 1) { - _compact_buckets->at_put(index, BUCKET_INFO(offset, VALUE_ONLY_BUCKET_TYPE)); + compact_buckets_set(index, BUCKET_INFO(offset, VALUE_ONLY_BUCKET_TYPE)); Entry ent = bucket->at(0); // bucket with one entry is value_only and only has the encoded_value - _compact_entries->at_put(offset++, ent.encoded_value()); + compact_entries_set(offset++, ent.encoded_value()); _num_value_only_buckets++; } else { // regular bucket, it could contain zero or more than one entry, // each entry is a pair - _compact_buckets->at_put(index, BUCKET_INFO(offset, REGULAR_BUCKET_TYPE)); + compact_buckets_set(index, BUCKET_INFO(offset, REGULAR_BUCKET_TYPE)); for (int i=0; iat(i); - _compact_entries->at_put(offset++, u4(ent.hash())); // write entry hash - _compact_entries->at_put(offset++, ent.encoded_value()); // write entry encoded_value + compact_entries_set(offset++, u4(ent.hash())); // write entry hash + compact_entries_set(offset++, ent.encoded_value()); // write entry encoded_value } if (bucket_size == 0) { _num_empty_buckets++; @@ -140,10 +142,19 @@ void CompactHashtableWriter::dump_table(NumberSeq* summary) { } // Mark the end of the buckets - _compact_buckets->at_put(_num_buckets, BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE)); - assert(offset == (u4)_compact_entries->length(), "sanity"); + compact_buckets_set(_num_buckets, BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE)); + assert(offset == checked_cast(_num_compact_entries), "sanity"); } +void CompactHashtableWriter::compact_buckets_set(u4 index, u4 value) { + precond(index < _num_compact_buckets); + _compact_buckets[index] = value; +} + +void CompactHashtableWriter::compact_entries_set(u4 index, u4 value) { + precond(index < _num_compact_entries); + _compact_entries[index] = value; +} // Write the compact table void CompactHashtableWriter::dump(SimpleCompactHashtable *cht, const char* table_name) { @@ -154,7 +165,7 @@ void CompactHashtableWriter::dump(SimpleCompactHashtable *cht, const char* table int table_bytes = _stats->bucket_bytes + _stats->hashentry_bytes; address base_address = address(SharedBaseAddress); cht->init(base_address, _num_entries_written, _num_buckets, - _compact_buckets->data(), _compact_entries->data()); + _compact_buckets, _compact_entries); LogMessage(aot, hashtables) msg; if (msg.is_info()) { diff --git a/src/hotspot/share/classfile/compactHashtable.hpp b/src/hotspot/share/classfile/compactHashtable.hpp index 2fe92be0f6d..81f2951289d 100644 --- a/src/hotspot/share/classfile/compactHashtable.hpp +++ b/src/hotspot/share/classfile/compactHashtable.hpp @@ -115,8 +115,13 @@ private: int _num_other_buckets; GrowableArray** _buckets; CompactHashtableStats* _stats; - Array* _compact_buckets; - Array* _compact_entries; + u4* _compact_buckets; + size_t _num_compact_buckets; + u4* _compact_entries; + size_t _num_compact_entries; + + void compact_buckets_set(u4 index, u4 value); + void compact_entries_set(u4 index, u4 value); public: // This is called at dump-time only diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index c6b0fcb90e0..ef1eeec14dd 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -1925,16 +1925,13 @@ oop java_lang_Thread::async_get_stack_trace(jobject jthread, TRAPS) { public: const Handle _thread_h; int _depth; - GrowableArray* _methods; - GrowableArray* _bcis; + enum InitLength { len = 64 }; // Minimum length that covers most cases + GrowableArrayCHeap _methods; + GrowableArrayCHeap _bcis; GetStackTraceHandshakeClosure(Handle thread_h) : HandshakeClosure("GetStackTraceHandshakeClosure"), _thread_h(thread_h), _depth(0), - _methods(nullptr), _bcis(nullptr) { - } - ~GetStackTraceHandshakeClosure() { - delete _methods; - delete _bcis; + _methods(InitLength::len), _bcis(InitLength::len) { } void do_thread(Thread* th) { @@ -1950,11 +1947,6 @@ oop java_lang_Thread::async_get_stack_trace(jobject jthread, TRAPS) { const int max_depth = MaxJavaStackTraceDepth; const bool skip_hidden = !ShowHiddenFrames; - // Pick minimum length that will cover most cases - int init_length = 64; - _methods = new (mtInternal) GrowableArray(init_length, mtInternal); - _bcis = new (mtInternal) GrowableArray(init_length, mtInternal); - int total_count = 0; vframeStream vfst(java_thread != nullptr ? vframeStream(java_thread, false, false, vthread_carrier) // we don't process frames as we don't care about oops @@ -1968,8 +1960,8 @@ oop java_lang_Thread::async_get_stack_trace(jobject jthread, TRAPS) { continue; } - _methods->push(vfst.method()); - _bcis->push(vfst.bci()); + _methods.push(vfst.method()); + _bcis.push(vfst.bci()); total_count++; } @@ -2001,9 +1993,9 @@ oop java_lang_Thread::async_get_stack_trace(jobject jthread, TRAPS) { objArrayHandle trace = oopFactory::new_objArray_handle(k, gsthc._depth, CHECK_NULL); for (int i = 0; i < gsthc._depth; i++) { - methodHandle method(THREAD, gsthc._methods->at(i)); + methodHandle method(THREAD, gsthc._methods.at(i)); oop element = java_lang_StackTraceElement::create(method, - gsthc._bcis->at(i), + gsthc._bcis.at(i), CHECK_NULL); trace->obj_at_put(i, element); } diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index 2b8b7780a41..c3f60487b9c 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -946,7 +946,7 @@ void StringTable::init_shared_table() { // so we are all good. // - If there's a reference to it, we will report an error inside HeapShared.cpp and // dumping will fail. - HeapShared::add_to_dumped_interned_strings(string); + HeapShared::archive_interned_string(string); } n++; return true; diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index cfb20412ab8..58d432a628c 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -89,11 +89,9 @@ DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;) #ifdef ASSERT static void check_klass_after_loading(const Klass* k) { -#ifdef _LP64 - if (k != nullptr && UseCompressedClassPointers) { + if (k != nullptr) { CompressedKlassPointers::check_encodable(k); } -#endif } #endif @@ -373,11 +371,6 @@ bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) { return false; } -bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) { - DumpTimeClassInfo* info = _dumptime_table->get(ik); - return (info != nullptr) ? info->is_early_klass() : false; -} - bool SystemDictionaryShared::check_self_exclusion(InstanceKlass* k) { bool log_warning = false; const char* error = check_self_exclusion_helper(k, log_warning); diff --git a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp index 2619a642fd1..33b245e26fc 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.hpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -199,7 +199,6 @@ private: static void iterate_verification_constraint_names(InstanceKlass* k, DumpTimeClassInfo* info, Function func); public: - static bool is_early_klass(InstanceKlass* k); // Was k loaded while JvmtiExport::is_early_phase()==true static bool has_archived_enum_objs(InstanceKlass* ik); static void set_has_archived_enum_objs(InstanceKlass* ik); diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 30f147b9ae7..48be24c20dc 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -620,9 +620,6 @@ TypeOrigin ClassVerifier::ref_ctx(const char* sig) { void ClassVerifier::verify_class(TRAPS) { log_info(verification)("Verifying class %s with new format", _klass->external_name()); - // Either verifying both local and remote classes or just remote classes. - assert(BytecodeVerificationRemote, "Should not be here"); - Array* methods = _klass->methods(); int num_methods = methods->length(); @@ -1610,12 +1607,12 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) { case Bytecodes::_if_acmpeq : case Bytecodes::_if_acmpne : current_frame.pop_stack( - VerificationType::reference_check(), CHECK_VERIFY(this)); + object_type(), CHECK_VERIFY(this)); // fall through case Bytecodes::_ifnull : case Bytecodes::_ifnonnull : current_frame.pop_stack( - VerificationType::reference_check(), CHECK_VERIFY(this)); + object_type(), CHECK_VERIFY(this)); stackmap_table.check_jump_target (¤t_frame, bcs.bci(), bcs.get_offset_s2(), CHECK_VERIFY(this)); no_control_flow = false; break; diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 75592fd61c8..e84acd62284 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -257,6 +257,7 @@ class methodHandle; do_intrinsic(_bitCount_i, java_lang_Integer, bitCount_name, int_int_signature, F_S) \ do_intrinsic(_bitCount_l, java_lang_Long, bitCount_name, long_int_signature, F_S) \ do_intrinsic(_compress_i, java_lang_Integer, compress_name, int2_int_signature, F_S) \ + do_name( compress_name, "compress") \ do_intrinsic(_compress_l, java_lang_Long, compress_name, long2_long_signature, F_S) \ do_intrinsic(_expand_i, java_lang_Integer, expand_name, int2_int_signature, F_S) \ do_intrinsic(_expand_l, java_lang_Long, expand_name, long2_long_signature, F_S) \ @@ -358,19 +359,19 @@ class methodHandle; do_name( vectorizedHashCode_name, "vectorizedHashCode") \ do_signature(vectorizedHashCode_signature, "(Ljava/lang/Object;IIII)I") \ \ - do_intrinsic(_compressStringC, java_lang_StringUTF16, compress_name, encodeISOArray_signature, F_S) \ - do_name( compress_name, "compress") \ - do_intrinsic(_compressStringB, java_lang_StringUTF16, compress_name, indexOfI_signature, F_S) \ + do_intrinsic(_compressStringC, java_lang_StringUTF16, compressString_name, encodeISOArray_signature, F_S) \ + do_name( compressString_name, "compress0") \ + do_intrinsic(_compressStringB, java_lang_StringUTF16, compressString_name, indexOfI_signature, F_S) \ do_intrinsic(_inflateStringC, java_lang_StringLatin1, inflate_name, inflateC_signature, F_S) \ - do_name( inflate_name, "inflate") \ + do_name( inflate_name, "inflate0") \ do_signature(inflateC_signature, "([BI[CII)V") \ do_intrinsic(_inflateStringB, java_lang_StringLatin1, inflate_name, inflateB_signature, F_S) \ do_signature(inflateB_signature, "([BI[BII)V") \ do_intrinsic(_toBytesStringU, java_lang_StringUTF16, toBytes_name, toBytesU_signature, F_S) \ - do_name( toBytes_name, "toBytes") \ + do_name( toBytes_name, "toBytes0") \ do_signature(toBytesU_signature, "([CII)[B") \ do_intrinsic(_getCharsStringU, java_lang_StringUTF16, getCharsU_name, getCharsU_signature, F_S) \ - do_name( getCharsU_name, "getChars") \ + do_name( getCharsU_name, "getChars0") \ do_signature(getCharsU_signature, "([BII[CI)V") \ do_intrinsic(_getCharStringU, java_lang_StringUTF16, getChar_name, getCharStringU_signature, F_S) \ do_signature(getCharStringU_signature, "([BI)C") \ @@ -381,9 +382,9 @@ class methodHandle; do_intrinsic(_compareToLU, java_lang_StringLatin1,compareToLU_name, compareTo_indexOf_signature, F_S) \ do_intrinsic(_compareToUL, java_lang_StringUTF16, compareToUL_name, compareTo_indexOf_signature, F_S) \ do_signature(compareTo_indexOf_signature, "([B[B)I") \ - do_name( compareTo_name, "compareTo") \ - do_name( compareToLU_name, "compareToUTF16") \ - do_name( compareToUL_name, "compareToLatin1") \ + do_name( compareTo_name, "compareTo0") \ + do_name( compareToLU_name, "compareToUTF16_0") \ + do_name( compareToUL_name, "compareToLatin1_0") \ do_intrinsic(_indexOfL, java_lang_StringLatin1,indexOf_name, compareTo_indexOf_signature, F_S) \ do_intrinsic(_indexOfU, java_lang_StringUTF16, indexOf_name, compareTo_indexOf_signature, F_S) \ do_intrinsic(_indexOfUL, java_lang_StringUTF16, indexOfUL_name, compareTo_indexOf_signature, F_S) \ @@ -392,12 +393,13 @@ class methodHandle; do_intrinsic(_indexOfIUL, java_lang_StringUTF16, indexOfUL_name, indexOfI_signature, F_S) \ do_intrinsic(_indexOfU_char, java_lang_StringUTF16, indexOfChar_name, indexOfChar_signature, F_S) \ do_intrinsic(_indexOfL_char, java_lang_StringLatin1,indexOfChar_name, indexOfChar_signature, F_S) \ - do_name( indexOf_name, "indexOf") \ - do_name( indexOfChar_name, "indexOfChar") \ - do_name( indexOfUL_name, "indexOfLatin1") \ + do_name( indexOf_name, "indexOf0") \ + do_name( indexOfChar_name, "indexOfChar0") \ + do_name( indexOfUL_name, "indexOfLatin1_0") \ do_signature(indexOfI_signature, "([BI[BII)I") \ do_signature(indexOfChar_signature, "([BIII)I") \ - do_intrinsic(_equalsL, java_lang_StringLatin1,equals_name, equalsB_signature, F_S) \ + do_intrinsic(_equalsL, java_lang_StringLatin1,equalsString_name, equalsB_signature, F_S) \ + do_name( equalsString_name, "equals0") \ \ do_intrinsic(_isDigit, java_lang_CharacterDataLatin1, isDigit_name, int_bool_signature, F_R) \ do_name( isDigit_name, "isDigit") \ @@ -1027,7 +1029,7 @@ class methodHandle; do_intrinsic(_VectorUnaryLibOp, jdk_internal_vm_vector_VectorSupport, vector_unary_lib_op_name, vector_unary_lib_op_sig, F_S) \ do_signature(vector_unary_lib_op_sig,"(J" \ "Ljava/lang/Class;" \ - "Ljava/lang/Class;" \ + "I" \ "I" \ "Ljava/lang/String;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ @@ -1038,7 +1040,7 @@ class methodHandle; do_intrinsic(_VectorBinaryLibOp, jdk_internal_vm_vector_VectorSupport, vector_binary_lib_op_name, vector_binary_lib_op_sig, F_S) \ do_signature(vector_binary_lib_op_sig,"(J" \ "Ljava/lang/Class;" \ - "Ljava/lang/Class;" \ + "I" \ "I" \ "Ljava/lang/String;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorPayload;" \ diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 0054b7ba3f2..2ae42bebcfd 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -98,6 +98,7 @@ class SerializeClosure; template(jdk_internal_vm_vector_VectorMask, "jdk/internal/vm/vector/VectorSupport$VectorMask") \ template(jdk_internal_vm_vector_VectorShuffle, "jdk/internal/vm/vector/VectorSupport$VectorShuffle") \ template(payload_name, "payload") \ + template(CTYPE_name, "CTYPE") \ template(ETYPE_name, "ETYPE") \ template(VLENGTH_name, "VLENGTH") \ \ diff --git a/src/hotspot/share/code/aotCodeCache.cpp b/src/hotspot/share/code/aotCodeCache.cpp index f51c068f1e7..4ad5e12d808 100644 --- a/src/hotspot/share/code/aotCodeCache.cpp +++ b/src/hotspot/share/code/aotCodeCache.cpp @@ -29,9 +29,11 @@ #include "cds/cds_globals.hpp" #include "cds/cdsConfig.hpp" #include "cds/heapShared.hpp" +#include "ci/ciUtilities.hpp" #include "classfile/javaAssertions.hpp" #include "code/aotCodeCache.hpp" #include "code/codeCache.hpp" +#include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/gcConfig.hpp" #include "logging/logStream.hpp" #include "memory/memoryReserver.hpp" @@ -53,6 +55,7 @@ #endif #if INCLUDE_G1GC #include "gc/g1/g1BarrierSetRuntime.hpp" +#include "gc/g1/g1HeapRegion.hpp" #endif #if INCLUDE_SHENANDOAHGC #include "gc/shenandoah/shenandoahRuntime.hpp" @@ -258,6 +261,9 @@ void AOTCodeCache::init2() { return; } + // initialize aot runtime constants as appropriate to this runtime + AOTRuntimeConstants::initialize_from_runtime(); + // initialize the table of external routines so we can save // generated code blobs that reference them AOTCodeAddressTable* table = opened_cache->_table; @@ -278,11 +284,11 @@ bool AOTCodeCache::open_cache(bool is_dumping, bool is_using) { return true; } -void AOTCodeCache::close() { +void AOTCodeCache::dump() { if (is_on()) { - delete _cache; // Free memory - _cache = nullptr; - opened_cache = nullptr; + assert(is_on_for_dump(), "should be called only when dumping AOT code"); + MutexLocker ml(Compile_lock); + _cache->finish_write(); } } @@ -298,7 +304,6 @@ AOTCodeCache::AOTCodeCache(bool is_dumping, bool is_using) : _store_size(0), _for_use(is_using), _for_dump(is_dumping), - _closing(false), _failed(false), _lookup_failed(false), _table(nullptr), @@ -375,31 +380,7 @@ void AOTCodeCache::init_early_c1_table() { } } -AOTCodeCache::~AOTCodeCache() { - if (_closing) { - return; // Already closed - } - // Stop any further access to cache. - _closing = true; - - MutexLocker ml(Compile_lock); - if (for_dump()) { // Finalize cache - finish_write(); - } - _load_buffer = nullptr; - if (_C_store_buffer != nullptr) { - FREE_C_HEAP_ARRAY(char, _C_store_buffer); - _C_store_buffer = nullptr; - _store_buffer = nullptr; - } - if (_table != nullptr) { - MutexLocker ml(AOTCodeCStrings_lock, Mutex::_no_safepoint_check_flag); - delete _table; - _table = nullptr; - } -} - -void AOTCodeCache::Config::record() { +void AOTCodeCache::Config::record(uint cpu_features_offset) { _flags = 0; #ifdef ASSERT _flags |= debugVM; @@ -407,9 +388,6 @@ void AOTCodeCache::Config::record() { if (UseCompressedOops) { _flags |= compressedOops; } - if (UseCompressedClassPointers) { - _flags |= compressedClassPointers; - } if (UseTLAB) { _flags |= useTLAB; } @@ -430,9 +408,50 @@ void AOTCodeCache::Config::record() { _compressedKlassShift = CompressedKlassPointers::shift(); _contendedPaddingWidth = ContendedPaddingWidth; _gc = (uint)Universe::heap()->kind(); + _cpu_features_offset = cpu_features_offset; } -bool AOTCodeCache::Config::verify() const { +bool AOTCodeCache::Config::verify_cpu_features(AOTCodeCache* cache) const { + LogStreamHandle(Debug, aot, codecache, init) log; + uint offset = _cpu_features_offset; + uint cpu_features_size = *(uint *)cache->addr(offset); + assert(cpu_features_size == (uint)VM_Version::cpu_features_size(), "must be"); + offset += sizeof(uint); + + void* cached_cpu_features_buffer = (void *)cache->addr(offset); + if (log.is_enabled()) { + ResourceMark rm; // required for stringStream::as_string() + stringStream ss; + VM_Version::get_cpu_features_name(cached_cpu_features_buffer, ss); + log.print_cr("CPU features recorded in AOTCodeCache: %s", ss.as_string()); + } + + if (VM_Version::supports_features(cached_cpu_features_buffer)) { + if (log.is_enabled()) { + ResourceMark rm; // required for stringStream::as_string() + stringStream ss; + char* runtime_cpu_features = NEW_RESOURCE_ARRAY(char, VM_Version::cpu_features_size()); + VM_Version::store_cpu_features(runtime_cpu_features); + VM_Version::get_missing_features_name(runtime_cpu_features, cached_cpu_features_buffer, ss); + if (!ss.is_empty()) { + log.print_cr("Additional runtime CPU features: %s", ss.as_string()); + } + } + } else { + if (log.is_enabled()) { + ResourceMark rm; // required for stringStream::as_string() + stringStream ss; + char* runtime_cpu_features = NEW_RESOURCE_ARRAY(char, VM_Version::cpu_features_size()); + VM_Version::store_cpu_features(runtime_cpu_features); + VM_Version::get_missing_features_name(cached_cpu_features_buffer, runtime_cpu_features, ss); + log.print_cr("AOT Code Cache disabled: required cpu features are missing: %s", ss.as_string()); + } + return false; + } + return true; +} + +bool AOTCodeCache::Config::verify(AOTCodeCache* cache) const { // First checks affect all cached AOT code #ifdef ASSERT if ((_flags & debugVM) == 0) { @@ -452,10 +471,6 @@ bool AOTCodeCache::Config::verify() const { return false; } - if (((_flags & compressedClassPointers) != 0) != UseCompressedClassPointers) { - log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with UseCompressedClassPointers = %s", UseCompressedClassPointers ? "false" : "true"); - return false; - } if (_compressedKlassShift != (uint)CompressedKlassPointers::shift()) { log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with CompressedKlassPointers::shift() = %d vs current %d", _compressedKlassShift, CompressedKlassPointers::shift()); return false; @@ -478,6 +493,9 @@ bool AOTCodeCache::Config::verify() const { AOTStubCaching = false; } + if (!verify_cpu_features(cache)) { + return false; + } return true; } @@ -679,6 +697,17 @@ extern "C" { } } +void AOTCodeCache::store_cpu_features(char*& buffer, uint buffer_size) { + uint* size_ptr = (uint *)buffer; + *size_ptr = buffer_size; + buffer += sizeof(uint); + + VM_Version::store_cpu_features(buffer); + log_debug(aot, codecache, exit)("CPU features recorded in AOTCodeCache: %s", VM_Version::features_string()); + buffer += buffer_size; + buffer = align_up(buffer, DATA_ALIGNMENT); +} + bool AOTCodeCache::finish_write() { if (!align_write()) { return false; @@ -698,23 +727,32 @@ bool AOTCodeCache::finish_write() { uint store_count = _store_entries_cnt; if (store_count > 0) { - uint header_size = (uint)align_up(sizeof(AOTCodeCache::Header), DATA_ALIGNMENT); + uint header_size = (uint)align_up(sizeof(AOTCodeCache::Header), DATA_ALIGNMENT); uint code_count = store_count; uint search_count = code_count * 2; uint search_size = search_count * sizeof(uint); uint entries_size = (uint)align_up(code_count * sizeof(AOTCodeEntry), DATA_ALIGNMENT); // In bytes // _write_position includes size of code and strings uint code_alignment = code_count * DATA_ALIGNMENT; // We align_up code size when storing it. - uint total_size = header_size + _write_position + code_alignment + search_size + entries_size; + uint cpu_features_size = VM_Version::cpu_features_size(); + uint total_cpu_features_size = sizeof(uint) + cpu_features_size; // sizeof(uint) to store cpu_features_size + uint total_size = header_size + _write_position + code_alignment + search_size + entries_size + + align_up(total_cpu_features_size, DATA_ALIGNMENT); assert(total_size < max_aot_code_size(), "AOT Code size (" UINT32_FORMAT " bytes) is greater than AOTCodeMaxSize(" UINT32_FORMAT " bytes).", total_size, max_aot_code_size()); - // Create ordered search table for entries [id, index]; - uint* search = NEW_C_HEAP_ARRAY(uint, search_count, mtCode); // Allocate in AOT Cache buffer char* buffer = (char *)AOTCacheAccess::allocate_aot_code_region(total_size + DATA_ALIGNMENT); char* start = align_up(buffer, DATA_ALIGNMENT); char* current = start + header_size; // Skip header + uint cpu_features_offset = current - start; + store_cpu_features(current, cpu_features_size); + assert(is_aligned(current, DATA_ALIGNMENT), "sanity check"); + assert(current < start + total_size, "sanity check"); + + // Create ordered search table for entries [id, index]; + uint* search = NEW_C_HEAP_ARRAY(uint, search_count, mtCode); + AOTCodeEntry* entries_address = _store_entries; // Pointer to latest entry uint adapters_count = 0; uint shared_blobs_count = 0; @@ -790,7 +828,7 @@ bool AOTCodeCache::finish_write() { header->init(size, (uint)strings_count, strings_offset, entries_count, new_entries_offset, adapters_count, shared_blobs_count, - C1_blobs_count, C2_blobs_count); + C1_blobs_count, C2_blobs_count, cpu_features_offset); log_info(aot, codecache, exit)("Wrote %d AOT code entries to AOT Code Cache", entries_count); } @@ -1383,6 +1421,12 @@ void AOTCodeAddressTable::init_extrs() { #endif #endif // ZERO + // addresses of fields in AOT runtime constants area + address* p = AOTRuntimeConstants::field_addresses_list(); + while (*p != nullptr) { + SET_ADDRESS(_extrs, *p++); + } + _extrs_complete = true; log_debug(aot, codecache, init)("External addresses recorded"); } @@ -1469,18 +1513,6 @@ void AOTCodeAddressTable::init_early_c1() { #undef SET_ADDRESS -AOTCodeAddressTable::~AOTCodeAddressTable() { - if (_extrs_addr != nullptr) { - FREE_C_HEAP_ARRAY(address, _extrs_addr); - } - if (_stubs_addr != nullptr) { - FREE_C_HEAP_ARRAY(address, _stubs_addr); - } - if (_shared_blobs_addr != nullptr) { - FREE_C_HEAP_ARRAY(address, _shared_blobs_addr); - } -} - #ifdef PRODUCT #define MAX_STR_COUNT 200 #else @@ -1665,6 +1697,11 @@ int AOTCodeAddressTable::id_for_address(address addr, RelocIterator reloc, CodeB if (addr == (address)-1) { // Static call stub has jump to itself return id; } + // Check card_table_base address first since it can point to any address + BarrierSet* bs = BarrierSet::barrier_set(); + bool is_const_card_table_base = !UseG1GC && !UseShenandoahGC && bs->is_a(BarrierSet::CardTableBarrierSet); + guarantee(!is_const_card_table_base || addr != ci_card_table_address_const(), "sanity"); + // Seach for C string id = id_for_C_string(addr); if (id >= 0) { @@ -1734,6 +1771,44 @@ int AOTCodeAddressTable::id_for_address(address addr, RelocIterator reloc, CodeB return id; } +AOTRuntimeConstants AOTRuntimeConstants::_aot_runtime_constants; + +void AOTRuntimeConstants::initialize_from_runtime() { + BarrierSet* bs = BarrierSet::barrier_set(); + address card_table_base = nullptr; + uint grain_shift = 0; +#if INCLUDE_G1GC + if (bs->is_a(BarrierSet::G1BarrierSet)) { + grain_shift = G1HeapRegion::LogOfHRGrainBytes; + } else +#endif +#if INCLUDE_SHENANDOAHGC + if (bs->is_a(BarrierSet::ShenandoahBarrierSet)) { + grain_shift = 0; + } else +#endif + if (bs->is_a(BarrierSet::CardTableBarrierSet)) { + CardTable::CardValue* base = ci_card_table_address_const(); + assert(base != nullptr, "unexpected byte_map_base"); + card_table_base = base; + CardTableBarrierSet* ctbs = barrier_set_cast(bs); + grain_shift = ctbs->grain_shift(); + } + _aot_runtime_constants._card_table_base = card_table_base; + _aot_runtime_constants._grain_shift = grain_shift; +} + +address AOTRuntimeConstants::_field_addresses_list[] = { + ((address)&_aot_runtime_constants._card_table_base), + ((address)&_aot_runtime_constants._grain_shift), + nullptr +}; + +address AOTRuntimeConstants::card_table_base_address() { + assert(UseSerialGC || UseParallelGC, "Only these GCs have constant card table base"); + return (address)&_aot_runtime_constants._card_table_base; +} + // This is called after initialize() but before init2() // and _cache is not set yet. void AOTCodeCache::print_on(outputStream* st) { diff --git a/src/hotspot/share/code/aotCodeCache.hpp b/src/hotspot/share/code/aotCodeCache.hpp index 778ad34e448..7996388faa6 100644 --- a/src/hotspot/share/code/aotCodeCache.hpp +++ b/src/hotspot/share/code/aotCodeCache.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,6 +25,7 @@ #ifndef SHARE_CODE_AOTCODECACHE_HPP #define SHARE_CODE_AOTCODECACHE_HPP +#include "gc/shared/gc_globals.hpp" #include "runtime/stubInfo.hpp" /* @@ -151,7 +152,6 @@ public: _early_c1_complete(false), _complete(false) { } - ~AOTCodeAddressTable(); void init_extrs(); void init_early_stubs(); void init_shared_blobs(); @@ -177,18 +177,19 @@ protected: none = 0, debugVM = 1, compressedOops = 2, - compressedClassPointers = 4, - useTLAB = 8, - systemClassAssertions = 16, - userClassAssertions = 32, - enableContendedPadding = 64, - restrictContendedPadding = 128 + useTLAB = 4, + systemClassAssertions = 8, + userClassAssertions = 16, + enableContendedPadding = 32, + restrictContendedPadding = 64 }; uint _flags; + uint _cpu_features_offset; // offset in the cache where cpu features are stored public: - void record(); - bool verify() const; + void record(uint cpu_features_offset); + bool verify_cpu_features(AOTCodeCache* cache) const; + bool verify(AOTCodeCache* cache) const; }; class Header : public CHeapObj { @@ -206,14 +207,15 @@ protected: uint _shared_blobs_count; uint _C1_blobs_count; uint _C2_blobs_count; - Config _config; + Config _config; // must be the last element as there is trailing data stored immediately after Config public: void init(uint cache_size, uint strings_count, uint strings_offset, uint entries_count, uint entries_offset, uint adapters_count, uint shared_blobs_count, - uint C1_blobs_count, uint C2_blobs_count) { + uint C1_blobs_count, uint C2_blobs_count, + uint cpu_features_offset) { _version = AOT_CODE_VERSION; _cache_size = cache_size; _strings_count = strings_count; @@ -224,7 +226,7 @@ protected: _shared_blobs_count = shared_blobs_count; _C1_blobs_count = C1_blobs_count; _C2_blobs_count = C2_blobs_count; - _config.record(); + _config.record(cpu_features_offset); } @@ -239,8 +241,8 @@ protected: uint C2_blobs_count() const { return _C2_blobs_count; } bool verify(uint load_size) const; - bool verify_config() const { // Called after Universe initialized - return _config.verify(); + bool verify_config(AOTCodeCache* cache) const { // Called after Universe initialized + return _config.verify(cache); } }; @@ -256,7 +258,6 @@ private: uint _store_size; // Used when writing cache bool _for_use; // AOT cache is open for using AOT code bool _for_dump; // AOT cache is open for dumping AOT code - bool _closing; // Closing cache file bool _failed; // Failed read/write to/from cache (cache is broken?) bool _lookup_failed; // Failed to lookup for info (skip only this code load) @@ -286,7 +287,6 @@ private: public: AOTCodeCache(bool is_dumping, bool is_using); - ~AOTCodeCache(); const char* cache_buffer() const { return _load_buffer; } bool failed() const { return _failed; } @@ -310,8 +310,6 @@ public: bool for_use() const { return _for_use && !_failed; } bool for_dump() const { return _for_dump && !_failed; } - bool closing() const { return _closing; } - AOTCodeEntry* add_entry() { _store_entries_cnt++; _store_entries -= 1; @@ -320,6 +318,8 @@ public: AOTCodeEntry* find_entry(AOTCodeEntry::Kind kind, uint id); + void store_cpu_features(char*& buffer, uint buffer_size); + bool finish_write(); bool write_relocations(CodeBlob& code_blob); @@ -361,7 +361,7 @@ private: static bool open_cache(bool is_dumping, bool is_using); bool verify_config() { if (for_use()) { - return _load_header->verify_config(); + return _load_header->verify_config(this); } return true; } @@ -369,8 +369,8 @@ public: static AOTCodeCache* cache() { assert(_passed_init2, "Too early to ask"); return _cache; } static void initialize() NOT_CDS_RETURN; static void init2() NOT_CDS_RETURN; - static void close() NOT_CDS_RETURN; - static bool is_on() CDS_ONLY({ return cache() != nullptr && !_cache->closing(); }) NOT_CDS_RETURN_(false); + static void dump() NOT_CDS_RETURN; + static bool is_on() CDS_ONLY({ return cache() != nullptr; }) NOT_CDS_RETURN_(false); static bool is_on_for_use() CDS_ONLY({ return is_on() && _cache->for_use(); }) NOT_CDS_RETURN_(false); static bool is_on_for_dump() CDS_ONLY({ return is_on() && _cache->for_dump(); }) NOT_CDS_RETURN_(false); static bool is_dumping_stub() NOT_CDS_RETURN_(false); @@ -417,4 +417,36 @@ public: #endif // PRODUCT }; +// code cache internal runtime constants area used by AOT code +class AOTRuntimeConstants { + friend class AOTCodeCache; + private: + address _card_table_base; + uint _grain_shift; + static address _field_addresses_list[]; + static AOTRuntimeConstants _aot_runtime_constants; + // private constructor for unique singleton + AOTRuntimeConstants() { } + // private for use by friend class AOTCodeCache + static void initialize_from_runtime(); + public: +#if INCLUDE_CDS + static bool contains(address adr) { + address base = (address)&_aot_runtime_constants; + address hi = base + sizeof(AOTRuntimeConstants); + return (base <= adr && adr < hi); + } + static address card_table_base_address(); + static address grain_shift_address() { return (address)&_aot_runtime_constants._grain_shift; } + static address* field_addresses_list() { + return _field_addresses_list; + } +#else + static bool contains(address adr) { return false; } + static address card_table_base_address() { return nullptr; } + static address grain_shift_address() { return nullptr; } + static address* field_addresses_list() { return nullptr; } +#endif +}; + #endif // SHARE_CODE_AOTCODECACHE_HPP diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index 094b4f82cf0..fcc0b42a461 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -336,6 +336,7 @@ RuntimeBlob::RuntimeBlob( void RuntimeBlob::free(RuntimeBlob* blob) { assert(blob != nullptr, "caller must check for nullptr"); + MACOS_AARCH64_ONLY(os::thread_wx_enable_write()); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock blob->purge(); { diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 5f5c9711441..07d96d6cd44 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,11 +76,7 @@ CompiledICData::CompiledICData() // Inline cache callsite info is initialized once the first time it is resolved void CompiledICData::initialize(CallInfo* call_info, Klass* receiver_klass) { _speculated_method = call_info->selected_method(); - if (UseCompressedClassPointers) { - _speculated_klass = (uintptr_t)CompressedKlassPointers::encode_not_null(receiver_klass); - } else { - _speculated_klass = (uintptr_t)receiver_klass; - } + _speculated_klass = (uintptr_t)CompressedKlassPointers::encode_not_null(receiver_klass); if (call_info->call_kind() == CallInfo::itable_call) { assert(call_info->resolved_method() != nullptr, "virtual or interface method must be found"); _itable_defc_klass = call_info->resolved_method()->method_holder(); @@ -133,12 +129,7 @@ Klass* CompiledICData::speculated_klass() const { if (is_speculated_klass_unloaded()) { return nullptr; } - - if (UseCompressedClassPointers) { - return CompressedKlassPointers::decode_not_null((narrowKlass)_speculated_klass); - } else { - return (Klass*)_speculated_klass; - } + return CompressedKlassPointers::decode_not_null((narrowKlass)_speculated_klass); } //----------------------------------------------------------------------------- diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 13eb1ff1604..5a6ed8ab3ed 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -938,7 +938,8 @@ address nmethod::continuation_for_implicit_exception(address pc, bool for_div0_c stringStream ss; ss.print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); print_on(&ss); - method()->print_codes_on(&ss); + // Buffering to a stringStream, disable internal buffering so it's not done twice. + method()->print_codes_on(&ss, 0, false); print_code_on(&ss); print_pcs_on(&ss); tty->print("%s", ss.as_string()); // print all at once @@ -1305,9 +1306,7 @@ nmethod::nmethod( _deopt_handler_entry_offset = 0; _unwind_handler_offset = 0; - CHECKED_CAST(_oops_size, uint16_t, align_up(code_buffer->total_oop_size(), oopSize)); - uint16_t metadata_size; - CHECKED_CAST(metadata_size, uint16_t, align_up(code_buffer->total_metadata_size(), wordSize)); + int metadata_size = align_up(code_buffer->total_metadata_size(), wordSize); JVMCI_ONLY( _metadata_size = metadata_size; ) assert(_mutable_data_size == _relocation_size + metadata_size, "wrong mutable data size: %d != %d + %d", @@ -1445,7 +1444,6 @@ nmethod::nmethod(const nmethod &nm) : CodeBlob(nm._name, nm._kind, nm._size, nm. _deopt_handler_entry_offset = nm._deopt_handler_entry_offset; _unwind_handler_offset = nm._unwind_handler_offset; _num_stack_arg_slots = nm._num_stack_arg_slots; - _oops_size = nm._oops_size; #if INCLUDE_JVMCI _metadata_size = nm._metadata_size; #endif @@ -1748,9 +1746,7 @@ nmethod::nmethod( _unwind_handler_offset = -1; } - CHECKED_CAST(_oops_size, uint16_t, align_up(code_buffer->total_oop_size(), oopSize)); - uint16_t metadata_size; - CHECKED_CAST(metadata_size, uint16_t, align_up(code_buffer->total_metadata_size(), wordSize)); + int metadata_size = align_up(code_buffer->total_metadata_size(), wordSize); JVMCI_ONLY( _metadata_size = metadata_size; ) int jvmci_data_size = 0 JVMCI_ONLY( + align_up(compiler->is_jvmci() ? jvmci_data->size() : 0, oopSize)); assert(_mutable_data_size == _relocation_size + metadata_size + jvmci_data_size, diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index 2391bc6d830..092da181f12 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -235,11 +235,10 @@ class nmethod : public CodeBlob { // Number of arguments passed on the stack uint16_t _num_stack_arg_slots; - uint16_t _oops_size; #if INCLUDE_JVMCI // _metadata_size is not specific to JVMCI. In the non-JVMCI case, it can be derived as: // _metadata_size = mutable_data_size - relocation_size - uint16_t _metadata_size; + int _metadata_size; #endif // Offset in immutable data section diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index 75d84bedcc6..0e4e211453b 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -185,49 +185,6 @@ intx CompilerConfig::scaled_freq_log(intx freq_log, double scale) { } } -void CompilerConfig::set_client_emulation_mode_flags() { - assert(has_c1(), "Must have C1 compiler present"); - CompilationModeFlag::set_quick_only(); - - FLAG_SET_ERGO(ProfileInterpreter, false); -#if INCLUDE_JVMCI - FLAG_SET_ERGO(EnableJVMCI, false); - FLAG_SET_ERGO(UseJVMCICompiler, false); -#endif - if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) { - FLAG_SET_ERGO(NeverActAsServerClassMachine, true); - } - if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) { - FLAG_SET_ERGO(InitialCodeCacheSize, 160*K); - } - if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { - FLAG_SET_ERGO(ReservedCodeCacheSize, 32*M); - } - if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) { - FLAG_SET_ERGO(NonProfiledCodeHeapSize, 27*M); - } - if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) { - FLAG_SET_ERGO(ProfiledCodeHeapSize, 0); - } - if (FLAG_IS_DEFAULT(NonNMethodCodeHeapSize)) { - FLAG_SET_ERGO(NonNMethodCodeHeapSize, 5*M); - } - if (FLAG_IS_DEFAULT(CodeCacheExpansionSize)) { - FLAG_SET_ERGO(CodeCacheExpansionSize, 32*K); - } - if (FLAG_IS_DEFAULT(CICompilerCount)) { - FLAG_SET_ERGO(CICompilerCount, 1); - } -} - -bool CompilerConfig::is_compilation_mode_selected() { - return !FLAG_IS_DEFAULT(TieredCompilation) || - !FLAG_IS_DEFAULT(TieredStopAtLevel) || - !FLAG_IS_DEFAULT(CompilationMode) - JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI) - || !FLAG_IS_DEFAULT(UseJVMCICompiler)); -} - static bool check_legacy_flags() { JVMFlag* compile_threshold_flag = JVMFlag::flag_from_enum(FLAG_MEMBER_ENUM(CompileThreshold)); if (JVMFlagAccess::check_constraint(compile_threshold_flag, JVMFlagLimit::get_constraint(compile_threshold_flag)->constraint_func(), false) != JVMFlag::SUCCESS) { @@ -404,14 +361,12 @@ void CompilerConfig::set_compilation_policy_flags() { #endif if (CompilerConfig::is_tiered() && CompilerConfig::is_c2_enabled()) { -#ifdef COMPILER2 - // Some inlining tuning -#if defined(X86) || defined(AARCH64) || defined(RISCV64) || defined(PPC64) +#if defined(COMPILER2) && defined(_LP64) + // LP64 specific inlining tuning for C2 if (FLAG_IS_DEFAULT(InlineSmallCode)) { FLAG_SET_DEFAULT(InlineSmallCode, 2500); } #endif -#endif // COMPILER2 } } @@ -449,9 +404,6 @@ void CompilerConfig::set_jvmci_specific_flags() { if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) { FLAG_SET_DEFAULT(InitialCodeCacheSize, MAX2(16*M, InitialCodeCacheSize)); } - if (FLAG_IS_DEFAULT(NewSizeThreadIncrease)) { - FLAG_SET_DEFAULT(NewSizeThreadIncrease, MAX2(4*K, NewSizeThreadIncrease)); - } if (FLAG_IS_DEFAULT(Tier3DelayOn)) { // This effectively prevents the compile broker scheduling tier 2 // (i.e., limited C1 profiling) compilations instead of tier 3 @@ -548,36 +500,11 @@ bool CompilerConfig::check_args_consistency(bool status) { return status; } -bool CompilerConfig::should_set_client_emulation_mode_flags() { -#if !COMPILER1_OR_COMPILER2 - return false; -#endif - - if (has_c1()) { - if (!is_compilation_mode_selected()) { - if (NeverActAsServerClassMachine) { - return true; - } - } else if (!has_c2() && !is_jvmci_compiler()) { - return true; - } - } - - return false; -} - void CompilerConfig::ergo_initialize() { #if !COMPILER1_OR_COMPILER2 return; #endif - // This property is also checked when selecting the heap size. Since client - // emulation mode influences Java heap memory usage, part of the logic must - // occur before choosing the heap size. - if (should_set_client_emulation_mode_flags()) { - set_client_emulation_mode_flags(); - } - set_legacy_emulation_flags(); set_compilation_policy_flags(); @@ -596,9 +523,6 @@ void CompilerConfig::ergo_initialize() { } if (ProfileInterpreter && CompilerConfig::is_c1_simple_only()) { - if (!FLAG_IS_DEFAULT(ProfileInterpreter)) { - warning("ProfileInterpreter disabled due to client emulation mode"); - } FLAG_SET_CMDLINE(ProfileInterpreter, false); } diff --git a/src/hotspot/share/compiler/compilerDefinitions.hpp b/src/hotspot/share/compiler/compilerDefinitions.hpp index a9b052ff782..e8ba977f705 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.hpp +++ b/src/hotspot/share/compiler/compilerDefinitions.hpp @@ -151,14 +151,10 @@ public: inline static CompilerType compiler_type(); - static bool should_set_client_emulation_mode_flags(); - private: - static bool is_compilation_mode_selected(); static void set_compilation_policy_flags(); static void set_jvmci_specific_flags(); static void set_legacy_emulation_flags(); - static void set_client_emulation_mode_flags(); }; #endif // SHARE_COMPILER_COMPILERDEFINITIONS_HPP diff --git a/src/hotspot/share/compiler/compiler_globals_pd.hpp b/src/hotspot/share/compiler/compiler_globals_pd.hpp index 6a87fdaaaf1..8ac4b53d6cd 100644 --- a/src/hotspot/share/compiler/compiler_globals_pd.hpp +++ b/src/hotspot/share/compiler/compiler_globals_pd.hpp @@ -58,7 +58,6 @@ define_pd_global(bool, TieredCompilation, false); define_pd_global(intx, CompileThreshold, 0); define_pd_global(intx, OnStackReplacePercentage, 0); -define_pd_global(size_t, NewSizeThreadIncrease, 4*K); define_pd_global(bool, InlineClassNatives, true); define_pd_global(bool, InlineUnsafeOps, true); define_pd_global(size_t, InitialCodeCacheSize, 160*K); @@ -70,13 +69,6 @@ define_pd_global(size_t, NonNMethodCodeHeapSize, 32*M); define_pd_global(size_t, CodeCacheExpansionSize, 32*K); define_pd_global(size_t, CodeCacheMinBlockLength, 1); define_pd_global(size_t, CodeCacheMinimumUseSpace, 200*K); -#ifndef ZERO -define_pd_global(bool, NeverActAsServerClassMachine, true); -#else -// Zero runs without compilers. Do not let this code to force -// the GC mode and default heap settings. -define_pd_global(bool, NeverActAsServerClassMachine, false); -#endif #define CI_COMPILER_COUNT 0 #else diff --git a/src/hotspot/share/compiler/disassembler.hpp b/src/hotspot/share/compiler/disassembler.hpp index db7066c9023..b9de9c3d27d 100644 --- a/src/hotspot/share/compiler/disassembler.hpp +++ b/src/hotspot/share/compiler/disassembler.hpp @@ -112,7 +112,7 @@ class Disassembler : public AbstractDisassembler { // interpreter code, by riding on the customary __ macro in the interpreter generator. // See templateTable_x86.cpp for an example. template inline static T* hook(const char* file, int line, T* masm) { - if (PrintInterpreter) { + if (PrintInterpreter NOT_PRODUCT(|| true)) { _hook(file, line, masm); } return masm; diff --git a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp index 59ab69b2427..e32daa3d79e 100644 --- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,7 +34,6 @@ #include "memory/metaspaceUtils.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/globals.hpp" #include "utilities/ostream.hpp" @@ -75,6 +74,10 @@ jint EpsilonHeap::initialize() { void EpsilonHeap::initialize_serviceability() { _pool = new EpsilonMemoryPool(this); _memory_manager.add_pool(_pool); +} + +void EpsilonHeap::post_initialize() { + CollectedHeap::post_initialize(); _monitoring_support->mark_ready(); } diff --git a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp index 8d7aa7960fd..ef75f7c1bb9 100644 --- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp @@ -69,6 +69,7 @@ public: jint initialize() override; void initialize_serviceability() override; + void post_initialize() override; GrowableArray memory_managers() override; GrowableArray memory_pools() override; diff --git a/src/hotspot/share/gc/g1/g1Arguments.cpp b/src/hotspot/share/gc/g1/g1Arguments.cpp index ffb06a7d822..8bec6e7e86f 100644 --- a/src/hotspot/share/gc/g1/g1Arguments.cpp +++ b/src/hotspot/share/gc/g1/g1Arguments.cpp @@ -242,10 +242,6 @@ void G1Arguments::initialize() { FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); } - if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) { - FLAG_SET_DEFAULT(ParallelRefProcEnabled, true); - } - #ifdef COMPILER2 // Enable loop strip mining to offer better pause time guarantees if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) { diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp index 406096acf10..c5c7058471c 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_GC_G1_G1BARRIERSET_HPP #define SHARE_GC_G1_G1BARRIERSET_HPP +#include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/shared/bufferNode.hpp" #include "gc/shared/cardTable.hpp" @@ -116,6 +117,8 @@ class G1BarrierSet: public CardTableBarrierSet { virtual void print_on(outputStream* st) const; + virtual uint grain_shift() { return G1HeapRegion::LogOfHRGrainBytes; } + // Callbacks for runtime accesses. template class AccessBarrier: public CardTableBarrierSet::AccessBarrier { diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp index c695ad977fe..7f0e5e86cd9 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp @@ -24,10 +24,9 @@ #include "gc/g1/g1BlockOffsetTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1HeapRegion.inline.hpp" +#include "gc/g1/g1RegionToSpaceMapper.hpp" +#include "gc/shared/memset_with_concurrent_readers.hpp" #include "logging/log.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/java.hpp" #include "runtime/os.hpp" size_t G1BlockOffsetTable::compute_size(size_t mem_region_words) { @@ -52,6 +51,12 @@ void G1BlockOffsetTable::set_offset_array(Atomic* addr, uint8_t offset) addr->store_relaxed(offset); } +static void check_offset(size_t offset, const char* msg) { + assert(offset < CardTable::card_size_in_words(), + "%s - offset: %zu, N_words: %u", + msg, offset, CardTable::card_size_in_words()); +} + void G1BlockOffsetTable::set_offset_array(Atomic* addr, HeapWord* high, HeapWord* low) { assert(high >= low, "addresses out of order"); size_t offset = pointer_delta(high, low); @@ -68,8 +73,8 @@ void G1BlockOffsetTable::set_offset_array(Atomic* left, Atomic #ifdef ASSERT void G1BlockOffsetTable::check_address(Atomic* addr, const char* msg) const { - Atomic* start_addr = const_cast*>(_offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift())); - Atomic* end_addr = const_cast*>(_offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift())); + Atomic* start_addr = _offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift()); + Atomic* end_addr = _offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift()); assert(addr >= start_addr && addr <= end_addr, "%s - offset address: " PTR_FORMAT ", start address: " PTR_FORMAT ", end address: " PTR_FORMAT, msg, (p2i(addr)), (p2i(start_addr)), (p2i(end_addr))); diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp index 89c68ce96d2..21d447549a6 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp @@ -37,19 +37,12 @@ // for each such subregion indicates how far back one must go to find the // start of the chunk that includes the first word of the subregion. class G1BlockOffsetTable : public CHeapObj { -private: // The reserved region covered by the table. MemRegion _reserved; // Biased array-start of BOT array for fast BOT entry translation Atomic* _offset_base; - void check_offset(size_t offset, const char* msg) const { - assert(offset < CardTable::card_size_in_words(), - "%s - offset: %zu, N_words: %u", - msg, offset, CardTable::card_size_in_words()); - } - // Bounds checking accessors: // For performance these have to devolve to array accesses in product builds. inline uint8_t offset_array(Atomic* addr) const; @@ -85,7 +78,6 @@ private: } public: - // Return the number of slots needed for an offset array // that covers mem_region_words words. static size_t compute_size(size_t mem_region_words); @@ -99,22 +91,14 @@ public: // in the heap parameter. G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage); - static bool is_crossing_card_boundary(HeapWord* const obj_start, - HeapWord* const obj_end) { - HeapWord* cur_card_boundary = align_up_by_card_size(obj_start); - // strictly greater-than - return obj_end > cur_card_boundary; - } + inline static bool is_crossing_card_boundary(HeapWord* const obj_start, + HeapWord* const obj_end); // Returns the address of the start of the block reaching into the card containing // "addr". inline HeapWord* block_start_reaching_into_card(const void* addr) const; - void update_for_block(HeapWord* blk_start, HeapWord* blk_end) { - if (is_crossing_card_boundary(blk_start, blk_end)) { - update_for_block_work(blk_start, blk_end); - } - } + inline void update_for_block(HeapWord* blk_start, HeapWord* blk_end); }; #endif // SHARE_GC_G1_G1BLOCKOFFSETTABLE_HPP diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 0d809b65526..1236d24bb03 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -27,10 +27,7 @@ #include "gc/g1/g1BlockOffsetTable.hpp" -#include "gc/g1/g1HeapRegion.hpp" #include "gc/shared/cardTable.hpp" -#include "gc/shared/memset_with_concurrent_readers.hpp" -#include "oops/oop.inline.hpp" inline HeapWord* G1BlockOffsetTable::block_start_reaching_into_card(const void* addr) const { assert(_reserved.contains(addr), "invalid address"); @@ -57,7 +54,7 @@ uint8_t G1BlockOffsetTable::offset_array(Atomic* addr) const { inline Atomic* G1BlockOffsetTable::entry_for_addr(const void* const p) const { assert(_reserved.contains(p), "out of bounds access to block offset table"); - Atomic* result = const_cast*>(&_offset_base[uintptr_t(p) >> CardTable::card_shift()]); + Atomic* result = &_offset_base[uintptr_t(p) >> CardTable::card_shift()]; return result; } @@ -70,4 +67,17 @@ inline HeapWord* G1BlockOffsetTable::addr_for_entry(const Atomic* const return result; } +inline bool G1BlockOffsetTable::is_crossing_card_boundary(HeapWord* const obj_start, + HeapWord* const obj_end) { + HeapWord* cur_card_boundary = align_up_by_card_size(obj_start); + // strictly greater-than + return obj_end > cur_card_boundary; +} + +inline void G1BlockOffsetTable::update_for_block(HeapWord* blk_start, HeapWord* blk_end) { + if (is_crossing_card_boundary(blk_start, blk_end)) { + update_for_block_work(blk_start, blk_end); + } +} + #endif // SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 8fc2c7c9941..be9ecf19123 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -42,7 +42,6 @@ #include "gc/g1/g1FullCollector.hpp" #include "gc/g1/g1GCCounters.hpp" #include "gc/g1/g1GCParPhaseTimesTracker.hpp" -#include "gc/g1/g1GCPauseType.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionPrinter.hpp" @@ -1652,21 +1651,13 @@ jint G1CollectedHeap::initialize() { return JNI_OK; } -bool G1CollectedHeap::concurrent_mark_is_terminating() const { - assert(_cm != nullptr, "_cm must have been created"); - assert(_cm->is_fully_initialized(), "thread must exist in order to check if mark is terminating"); - return _cm->cm_thread()->should_terminate(); -} - void G1CollectedHeap::stop() { // Stop all concurrent threads. We do this to make sure these threads // do not continue to execute and access resources (e.g. logging) // that are destroyed during shutdown. _cr->stop(); _service_thread->stop(); - if (_cm->is_fully_initialized()) { - _cm->cm_thread()->stop(); - } + _cm->stop(); } void G1CollectedHeap::safepoint_synchronize_begin() { @@ -1723,8 +1714,7 @@ void G1CollectedHeap::ref_processing_init() { // * Reference discovery is MT (see below). // * Reference discovery requires a barrier (see below). // * Reference processing may or may not be MT - // (depending on the value of ParallelRefProcEnabled - // and ParallelGCThreads). + // (depending on the value of ParallelGCThreads). // * A full GC disables reference discovery by the CM // ref processor and abandons any entries on it's // discovered lists. @@ -1858,12 +1848,12 @@ void G1CollectedHeap::increment_old_marking_cycles_completed(bool concurrent, record_whole_heap_examined_timestamp(); } - // We need to clear the "in_progress" flag in the CM thread before + // We need to tell G1ConcurrentMark to update the state before // we wake up any waiters (especially when ExplicitInvokesConcurrent // is set) so that if a waiter requests another System.gc() it doesn't // incorrectly see that a marking cycle is still in progress. if (concurrent) { - _cm->cm_thread()->set_idle(); + _cm->notify_concurrent_cycle_completed(); } // Notify threads waiting in System.gc() (with ExplicitGCInvokesConcurrent) @@ -2490,7 +2480,7 @@ void G1CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) { void G1CollectedHeap::gc_prologue(bool full) { // Update common counters. increment_total_collections(full /* full gc */); - if (full || collector_state()->in_concurrent_start_gc()) { + if (full || collector_state()->is_in_concurrent_start_gc()) { increment_old_marking_cycles_started(); } } @@ -2563,14 +2553,12 @@ HeapWord* G1CollectedHeap::do_collection_pause(size_t word_size, void G1CollectedHeap::start_concurrent_cycle(bool concurrent_operation_is_full_mark) { assert(_cm->is_fully_initialized(), "sanity"); - assert(!_cm->in_progress(), "Can not start concurrent operation while in progress"); + assert(!collector_state()->is_in_concurrent_cycle(), "Can not start concurrent cycle when already running"); MutexLocker x(G1CGC_lock, Mutex::_no_safepoint_check_flag); if (concurrent_operation_is_full_mark) { - _cm->post_concurrent_mark_start(); - _cm->cm_thread()->start_full_mark(); + _cm->start_full_concurrent_cycle(); } else { - _cm->post_concurrent_undo_start(); - _cm->cm_thread()->start_undo_mark(); + _cm->start_undo_concurrent_cycle(); } G1CGC_lock->notify(); } @@ -2662,7 +2650,7 @@ void G1CollectedHeap::verify_after_young_collection(G1HeapVerifier::G1VerifyType verify_numa_regions("GC End"); _verifier->verify_region_sets_optional(); - if (collector_state()->in_concurrent_start_gc()) { + if (collector_state()->is_in_concurrent_start_gc()) { log_debug(gc, verify)("Marking state"); _verifier->verify_marking_state(); } @@ -2743,7 +2731,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint(size_t allocation_word_si // Record whether this pause may need to trigger a concurrent operation. Later, // when we signal the G1ConcurrentMarkThread, the collector state has already // been reset for the next pause. - bool should_start_concurrent_mark_operation = collector_state()->in_concurrent_start_gc(); + bool should_start_concurrent_mark_operation = collector_state()->is_in_concurrent_start_gc(); // Perform the collection. G1YoungCollector collector(gc_cause(), allocation_word_size); @@ -2838,7 +2826,7 @@ bool G1STWSubjectToDiscoveryClosure::do_object_b(oop obj) { } void G1CollectedHeap::make_pending_list_reachable() { - if (collector_state()->in_concurrent_start_gc()) { + if (collector_state()->is_in_concurrent_start_gc()) { oop pll_head = Universe::reference_pending_list(); if (pll_head != nullptr) { // Any valid worker id is fine here as we are in the VM thread and single-threaded. @@ -3223,7 +3211,7 @@ void G1CollectedHeap::retire_gc_alloc_region(G1HeapRegion* alloc_region, _survivor.add_used_bytes(allocated_bytes); } - bool const during_im = collector_state()->in_concurrent_start_gc(); + bool const during_im = collector_state()->is_in_concurrent_start_gc(); if (during_im && allocated_bytes > 0) { _cm->add_root_region(alloc_region); } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 8ff9d481000..b5cb9167d92 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -34,7 +34,6 @@ #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1EdenRegions.hpp" #include "gc/g1/g1EvacStats.hpp" -#include "gc/g1/g1GCPauseType.hpp" #include "gc/g1/g1HeapRegionAttr.hpp" #include "gc/g1/g1HeapRegionManager.hpp" #include "gc/g1/g1HeapRegionSet.hpp" @@ -915,9 +914,6 @@ public: // specified by the policy object. jint initialize() override; - // Returns whether concurrent mark threads (and the VM) are about to terminate. - bool concurrent_mark_is_terminating() const; - void safepoint_synchronize_begin() override; void safepoint_synchronize_end() override; diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp index 8782b65b6f9..90e87607b87 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp @@ -47,9 +47,9 @@ #include "utilities/bitMap.inline.hpp" inline bool G1STWIsAliveClosure::do_object_b(oop p) { - // An object is reachable if it is outside the collection set, - // or is inside and copied. - return !_g1h->is_in_cset(p) || p->is_forwarded(); + // An object is reachable if it is outside the collection set and not a + // humongous candidate, or is inside and copied. + return !_g1h->is_in_cset_or_humongous_candidate(p) || p->is_forwarded(); } inline JavaThread* const* G1JavaThreadsListClaimer::claim(uint& count) { diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp index abfddf860e6..978925d88cb 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -174,7 +174,6 @@ void G1CollectionSet::iterate(G1HeapRegionClosure* cl) const { G1HeapRegion* r = _g1h->region_at(_regions[i]); bool result = cl->do_heap_region(r); if (result) { - cl->set_incomplete(); return; } } @@ -326,7 +325,7 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi guarantee(target_pause_time_ms > 0.0, "target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms); - bool in_young_only_phase = _policy->collector_state()->in_young_only_phase(); + bool in_young_only_phase = _policy->collector_state()->is_in_young_only_phase(); size_t pending_cards = _policy->analytics()->predict_pending_cards(in_young_only_phase); log_trace(gc, ergo, cset)("Start choosing CSet. Pending cards: %zu target pause time: %1.2fms", @@ -379,7 +378,7 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { if (!candidates()->is_empty()) { candidates()->verify(); - if (collector_state()->in_mixed_phase()) { + if (collector_state()->is_in_mixed_phase()) { time_remaining_ms = select_candidates_from_marking(time_remaining_ms); } else { log_debug(gc, ergo, cset)("Do not add marking candidates to collection set due to pause type."); diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp index d71108d4d0e..2113db1163b 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +23,6 @@ */ #include "gc/g1/g1CollectionSetCandidates.inline.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "utilities/growableArray.hpp" @@ -250,8 +249,9 @@ void G1CollectionSetCandidates::sort_marking_by_efficiency() { _from_marking_groups.verify(); } -void G1CollectionSetCandidates::set_candidates_from_marking(G1HeapRegion** candidates, - uint num_candidates) { +void G1CollectionSetCandidates::set_candidates_from_marking(GrowableArrayCHeap* candidates) { + uint num_candidates = candidates->length(); + if (num_candidates == 0) { log_debug(gc, ergo, cset) ("No regions selected from marking."); return; @@ -264,7 +264,7 @@ void G1CollectionSetCandidates::set_candidates_from_marking(G1HeapRegion** candi // During each Mixed GC, we must collect at least G1Policy::calc_min_old_cset_length regions to meet // the G1MixedGCCountTarget. For the first collection in a Mixed GC cycle, we can add all regions // required to meet this threshold to the same remset group. We are certain these will be collected in - // the same MixedGC. + // the same Mixed GC. uint group_limit = p->calc_min_old_cset_length(num_candidates); G1CSetCandidateGroup::reset_next_group_id(); @@ -273,7 +273,7 @@ void G1CollectionSetCandidates::set_candidates_from_marking(G1HeapRegion** candi current = new G1CSetCandidateGroup(); for (uint i = 0; i < num_candidates; i++) { - G1HeapRegion* r = candidates[i]; + G1HeapRegion* r = candidates->at(i); assert(!contains(r), "must not contain region %u", r->hrm_index()); _contains_map[r->hrm_index()] = CandidateOrigin::Marking; diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp index 7e882de7e5a..8a2235cf89c 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -245,8 +245,7 @@ public: // Merge collection set candidates from marking into the current marking candidates // (which needs to be empty). - void set_candidates_from_marking(G1HeapRegion** candidates, - uint num_candidates); + void set_candidates_from_marking(GrowableArrayCHeap* selected); // The most recent length of the list that had been merged last via // set_candidates_from_marking(). Used for calculating minimum collection set // regions. diff --git a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp deleted file mode 100644 index e7bab32129e..00000000000 --- a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 2001, 2026, 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. - * - */ - -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectionSetCandidates.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" -#include "gc/g1/g1HeapRegionRemSet.inline.hpp" -#include "gc/shared/space.hpp" -#include "runtime/atomic.hpp" -#include "utilities/quickSort.hpp" - -// Determine collection set candidates (from marking): For all regions determine -// whether they should be a collection set candidate. Calculate their efficiency, -// sort, and put them into the collection set candidates. -// -// Threads calculate the GC efficiency of the regions they get to process, and -// put them into some work area without sorting. At the end that array is sorted and -// moved to the destination. -class G1BuildCandidateRegionsTask : public WorkerTask { - // Work area for building the set of collection set candidates. Contains references - // to heap regions with their GC efficiencies calculated. To reduce contention - // on claiming array elements, worker threads claim parts of this array in chunks; - // Array elements may be null as threads might not get enough regions to fill - // up their chunks completely. - // Final sorting will remove them. - class G1BuildCandidateArray : public StackObj { - uint const _max_size; - uint const _chunk_size; - - G1HeapRegion** _data; - - Atomic _cur_claim_idx; - - static int compare_region_gc_efficiency(G1HeapRegion** rr1, G1HeapRegion** rr2) { - G1HeapRegion* r1 = *rr1; - G1HeapRegion* r2 = *rr2; - // Make sure that null entries are moved to the end. - if (r1 == nullptr) { - if (r2 == nullptr) { - return 0; - } else { - return 1; - } - } else if (r2 == nullptr) { - return -1; - } - - G1Policy* p = G1CollectedHeap::heap()->policy(); - double gc_efficiency1 = p->predict_gc_efficiency(r1); - double gc_efficiency2 = p->predict_gc_efficiency(r2); - - if (gc_efficiency1 > gc_efficiency2) { - return -1; - } else if (gc_efficiency1 < gc_efficiency2) { - return 1; - } else { - return 0; - } - } - - // Calculates the maximum array size that will be used. - static uint required_array_size(uint num_regions, uint chunk_size, uint num_workers) { - uint const max_waste = num_workers * chunk_size; - // The array should be aligned with respect to chunk_size. - uint const aligned_num_regions = ((num_regions + chunk_size - 1) / chunk_size) * chunk_size; - - return aligned_num_regions + max_waste; - } - - public: - G1BuildCandidateArray(uint max_num_regions, uint chunk_size, uint num_workers) : - _max_size(required_array_size(max_num_regions, chunk_size, num_workers)), - _chunk_size(chunk_size), - _data(NEW_C_HEAP_ARRAY(G1HeapRegion*, _max_size, mtGC)), - _cur_claim_idx(0) { - for (uint i = 0; i < _max_size; i++) { - _data[i] = nullptr; - } - } - - ~G1BuildCandidateArray() { - FREE_C_HEAP_ARRAY(G1HeapRegion*, _data); - } - - // Claim a new chunk, returning its bounds [from, to[. - void claim_chunk(uint& from, uint& to) { - uint result = _cur_claim_idx.add_then_fetch(_chunk_size); - assert(_max_size > result - 1, - "Array too small, is %u should be %u with chunk size %u.", - _max_size, result, _chunk_size); - from = result - _chunk_size; - to = result; - } - - // Set element in array. - void set(uint idx, G1HeapRegion* hr) { - assert(idx < _max_size, "Index %u out of bounds %u", idx, _max_size); - assert(_data[idx] == nullptr, "Value must not have been set."); - _data[idx] = hr; - } - - void sort_by_gc_efficiency() { - uint length = _cur_claim_idx.load_relaxed(); - if (length == 0) { - return; - } - for (uint i = length; i < _max_size; i++) { - assert(_data[i] == nullptr, "must be"); - } - qsort(_data, length, sizeof(_data[0]), (_sort_Fn)compare_region_gc_efficiency); - for (uint i = length; i < _max_size; i++) { - assert(_data[i] == nullptr, "must be"); - } - } - - G1HeapRegion** array() const { return _data; } - }; - - // Per-region closure. In addition to determining whether a region should be - // added to the candidates, and calculating those regions' gc efficiencies, also - // gather additional statistics. - class G1BuildCandidateRegionsClosure : public G1HeapRegionClosure { - G1BuildCandidateArray* _array; - - uint _cur_chunk_idx; - uint _cur_chunk_end; - - uint _regions_added; - - void add_region(G1HeapRegion* hr) { - if (_cur_chunk_idx == _cur_chunk_end) { - _array->claim_chunk(_cur_chunk_idx, _cur_chunk_end); - } - assert(_cur_chunk_idx < _cur_chunk_end, "Must be"); - - _array->set(_cur_chunk_idx, hr); - _cur_chunk_idx++; - - _regions_added++; - } - - public: - G1BuildCandidateRegionsClosure(G1BuildCandidateArray* array) : - _array(array), - _cur_chunk_idx(0), - _cur_chunk_end(0), - _regions_added(0) { } - - bool do_heap_region(G1HeapRegion* r) { - // Candidates from marking are always old; also keep regions that are already - // collection set candidates (some retained regions) in that list. - if (!r->is_old() || r->is_collection_set_candidate()) { - // Keep remembered sets and everything for these regions. - return false; - } - - // Can not add a region without a remembered set to the candidates. - if (!r->rem_set()->is_tracked()) { - return false; - } - - // Skip any region that is currently used as an old GC alloc region. We should - // not consider those for collection before we fill them up as the effective - // gain from them is small. I.e. we only actually reclaim from the filled part, - // as the remainder is still eligible for allocation. These objects are also - // likely to have already survived a few collections, so they might be longer - // lived anyway. - // Otherwise the Old region must satisfy the liveness condition. - bool should_add = !G1CollectedHeap::heap()->is_old_gc_alloc_region(r) && - G1CollectionSetChooser::region_occupancy_low_enough_for_evac(r->live_bytes()); - if (should_add) { - add_region(r); - } else { - r->rem_set()->clear(true /* only_cardset */); - } - return false; - } - - uint regions_added() const { return _regions_added; } - }; - - G1CollectedHeap* _g1h; - G1HeapRegionClaimer _hrclaimer; - - Atomic _num_regions_added; - - G1BuildCandidateArray _result; - - void update_totals(uint num_regions) { - if (num_regions > 0) { - _num_regions_added.add_then_fetch(num_regions); - } - } - - // Early prune (remove) regions meeting the G1HeapWastePercent criteria. That - // is, either until only the minimum amount of old collection set regions are - // available (for forward progress in evacuation) or the waste accumulated by the - // removed regions is above the maximum allowed waste. - // Updates number of candidates and reclaimable bytes given. - void prune(G1HeapRegion** data) { - G1Policy* p = G1CollectedHeap::heap()->policy(); - - uint num_candidates = _num_regions_added.load_relaxed(); - - uint min_old_cset_length = p->calc_min_old_cset_length(num_candidates); - uint num_pruned = 0; - size_t wasted_bytes = 0; - - if (min_old_cset_length >= num_candidates) { - // We take all of the candidate regions to provide some forward progress. - return; - } - - size_t allowed_waste = p->allowed_waste_in_collection_set(); - uint max_to_prune = num_candidates - min_old_cset_length; - - while (true) { - G1HeapRegion* r = data[num_candidates - num_pruned - 1]; - size_t const reclaimable = r->reclaimable_bytes(); - if (num_pruned >= max_to_prune || - wasted_bytes + reclaimable > allowed_waste) { - break; - } - r->rem_set()->clear(true /* cardset_only */); - - wasted_bytes += reclaimable; - num_pruned++; - } - - log_debug(gc, ergo, cset)("Pruned %u regions out of %u, leaving %zu bytes waste (allowed %zu)", - num_pruned, - num_candidates, - wasted_bytes, - allowed_waste); - - _num_regions_added.sub_then_fetch(num_pruned, memory_order_relaxed); - } - -public: - G1BuildCandidateRegionsTask(uint max_num_regions, uint chunk_size, uint num_workers) : - WorkerTask("G1 Build Candidate Regions"), - _g1h(G1CollectedHeap::heap()), - _hrclaimer(num_workers), - _num_regions_added(0), - _result(max_num_regions, chunk_size, num_workers) { } - - void work(uint worker_id) { - G1BuildCandidateRegionsClosure cl(&_result); - _g1h->heap_region_par_iterate_from_worker_offset(&cl, &_hrclaimer, worker_id); - update_totals(cl.regions_added()); - } - - void sort_and_prune_into(G1CollectionSetCandidates* candidates) { - _result.sort_by_gc_efficiency(); - prune(_result.array()); - candidates->set_candidates_from_marking(_result.array(), - _num_regions_added.load_relaxed()); - } -}; - -uint G1CollectionSetChooser::calculate_work_chunk_size(uint num_workers, uint num_regions) { - assert(num_workers > 0, "Active gc workers should be greater than 0"); - return MAX2(num_regions / num_workers, 1U); -} - -void G1CollectionSetChooser::build(WorkerThreads* workers, uint max_num_regions, G1CollectionSetCandidates* candidates) { - uint num_workers = workers->active_workers(); - uint chunk_size = calculate_work_chunk_size(num_workers, max_num_regions); - - G1BuildCandidateRegionsTask cl(max_num_regions, chunk_size, num_workers); - workers->run_task(&cl, num_workers); - - cl.sort_and_prune_into(candidates); - candidates->verify(); -} diff --git a/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp deleted file mode 100644 index 4db8ed23c49..00000000000 --- a/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2001, 2025, 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. - * - */ - -#ifndef SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP -#define SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP - -#include "gc/g1/g1HeapRegion.hpp" -#include "gc/shared/gc_globals.hpp" -#include "memory/allStatic.hpp" -#include "runtime/globals.hpp" - -class G1CollectionSetCandidates; -class WorkerThreads; - -// Helper class to calculate collection set candidates, and containing some related -// methods. -class G1CollectionSetChooser : public AllStatic { - static uint calculate_work_chunk_size(uint num_workers, uint num_regions); - - static size_t mixed_gc_live_threshold_bytes() { - return G1HeapRegion::GrainBytes * (size_t)G1MixedGCLiveThresholdPercent / 100; - } - -public: - static bool region_occupancy_low_enough_for_evac(size_t live_bytes) { - return live_bytes < mixed_gc_live_threshold_bytes(); - } - - // Build and return set of collection set candidates sorted by decreasing gc - // efficiency. - static void build(WorkerThreads* workers, uint max_num_regions, G1CollectionSetCandidates* candidates); -}; - -#endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP diff --git a/src/hotspot/share/gc/g1/g1CollectorState.cpp b/src/hotspot/share/gc/g1/g1CollectorState.cpp index d41ee22fdce..2b550f36904 100644 --- a/src/hotspot/share/gc/g1/g1CollectorState.cpp +++ b/src/hotspot/share/gc/g1/g1CollectorState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,25 +22,42 @@ * */ +#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectorState.hpp" -#include "gc/g1/g1GCPauseType.hpp" +#include "gc/g1/g1ConcurrentMarkThread.inline.hpp" +#include "runtime/safepoint.hpp" -G1GCPauseType G1CollectorState::young_gc_pause_type(bool concurrent_operation_is_full_mark) const { - assert(!in_full_gc(), "must be"); - if (in_concurrent_start_gc()) { - assert(!in_young_gc_before_mixed(), "must be"); - return concurrent_operation_is_full_mark ? G1GCPauseType::ConcurrentStartMarkGC : - G1GCPauseType::ConcurrentStartUndoGC; - } else if (in_young_gc_before_mixed()) { - assert(!in_concurrent_start_gc(), "must be"); - return G1GCPauseType::LastYoungGC; - } else if (in_mixed_phase()) { - assert(!in_concurrent_start_gc(), "must be"); - assert(!in_young_gc_before_mixed(), "must be"); - return G1GCPauseType::MixedGC; - } else { - assert(!in_concurrent_start_gc(), "must be"); - assert(!in_young_gc_before_mixed(), "must be"); - return G1GCPauseType::YoungGC; +G1CollectorState::Pause G1CollectorState::gc_pause_type(bool concurrent_operation_is_full_mark) const { + assert(SafepointSynchronize::is_at_safepoint(), "must be"); + switch (_phase) { + case Phase::YoungNormal: return Pause::Normal; + case Phase::YoungPrepareMixed: return Pause::PrepareMixed; + case Phase::YoungConcurrentStart: + return concurrent_operation_is_full_mark ? Pause::ConcurrentStartFull : + Pause::ConcurrentStartUndo; + case Phase::Mixed: return Pause::Mixed; + case Phase::FullGC: return Pause::Full; + default: ShouldNotReachHere(); } } + +bool G1CollectorState::is_in_concurrent_cycle() const { + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + return cm->is_in_concurrent_cycle(); +} + +bool G1CollectorState::is_in_marking() const { + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + return cm->is_in_marking(); +} + +bool G1CollectorState::is_in_mark_or_rebuild() const { + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + return is_in_marking() || cm->is_in_rebuild_or_scrub(); +} + +bool G1CollectorState::is_in_reset_for_next_cycle() const { + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + return cm->is_in_reset_for_next_cycle(); +} + diff --git a/src/hotspot/share/gc/g1/g1CollectorState.hpp b/src/hotspot/share/gc/g1/g1CollectorState.hpp index fca30792344..64c848959ae 100644 --- a/src/hotspot/share/gc/g1/g1CollectorState.hpp +++ b/src/hotspot/share/gc/g1/g1CollectorState.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,98 +25,134 @@ #ifndef SHARE_GC_G1_G1COLLECTORSTATE_HPP #define SHARE_GC_G1_G1COLLECTORSTATE_HPP -#include "gc/g1/g1GCPauseType.hpp" +#include "utilities/debug.hpp" +#include "utilities/enumIterator.hpp" #include "utilities/globalDefinitions.hpp" // State of the G1 collection. +// +// The rough phasing is Young-Only, Mixed / Space Reclamation and +// Full GC "phase". +// +// We split the Young-only phase into three parts to cover interesting +// sub-phases and avoid separate tracking. class G1CollectorState { - // Indicates whether we are in the phase where we do partial gcs that only contain - // the young generation. Not set while _in_full_gc is set. - bool _in_young_only_phase; + enum class Phase { + // Indicates that the next GC in the Young-Only phase will (likely) be a "Normal" + // young GC. + YoungNormal, + // We are in a concurrent start GC during the Young-Only phase. This is only set + // during that GC because we only decide whether we do this type of GC at the start + // of the pause. + YoungConcurrentStart, + // Indicates that we are about to start or in the prepare mixed gc in the Young-Only + // phase before the Mixed phase. This GC is required to keep pause time requirements. + YoungPrepareMixed, + // Doing extra old generation evacuation. + Mixed, + // The Full GC phase (that coincides with the Full GC pause). + FullGC + } _phase; - // Indicates whether we are in the last young gc before the mixed gc phase. This GC - // is required to keep pause time requirements. - bool _in_young_gc_before_mixed; - - // If _initiate_conc_mark_if_possible is set at the beginning of a - // pause, it is a suggestion that the pause should start a marking - // cycle by doing the concurrent start work. However, it is possible - // that the concurrent marking thread is still finishing up the - // previous marking cycle (e.g., clearing the marking bitmap). - // If that is the case we cannot start a new cycle and - // we'll have to wait for the concurrent marking thread to finish - // what it is doing. In this case we will postpone the marking cycle - // initiation decision for the next pause. When we eventually decide - // to start a cycle, we will set _in_concurrent_start_gc which - // will stay true until the end of the concurrent start pause doing the - // concurrent start work. - volatile bool _in_concurrent_start_gc; - - // At the end of a pause we check the heap occupancy and we decide - // whether we will start a marking cycle during the next pause. If - // we decide that we want to do that, set this parameter. This parameter will - // stay set until the beginning of a subsequent pause (not necessarily - // the next one) when we decide that we will indeed start a marking cycle and - // do the concurrent start phase work. + // _initiate_conc_mark_if_possible indicates that there has been a request to start + // a concurrent cycle but we have not been able to fulfill it because another one + // has been in progress when the request came in. + // + // This flag remembers that there is an unfullfilled request. volatile bool _initiate_conc_mark_if_possible; - // Marking is in progress. Set from start of the concurrent start pause to the - // end of the Remark pause. - bool _mark_in_progress; - // Marking or rebuilding remembered set work is in progress. Set from the end - // of the concurrent start pause to the end of the Cleanup pause. - bool _mark_or_rebuild_in_progress; - - // The marking bitmap is currently being cleared or about to be cleared. - bool _clear_bitmap_in_progress; - - // Set during a full gc pause. - bool _in_full_gc; - public: G1CollectorState() : - _in_young_only_phase(true), - _in_young_gc_before_mixed(false), - - _in_concurrent_start_gc(false), - _initiate_conc_mark_if_possible(false), - - _mark_in_progress(false), - _mark_or_rebuild_in_progress(false), - _clear_bitmap_in_progress(false), - _in_full_gc(false) { } + _phase(Phase::YoungNormal), + _initiate_conc_mark_if_possible(false) { } // Phase setters - void set_in_young_only_phase(bool v) { _in_young_only_phase = v; } + void set_in_normal_young_gc() { _phase = Phase::YoungNormal; } + void set_in_space_reclamation_phase() { _phase = Phase::Mixed; } + void set_in_full_gc() { _phase = Phase::FullGC; } // Pause setters - void set_in_young_gc_before_mixed(bool v) { _in_young_gc_before_mixed = v; } - void set_in_concurrent_start_gc(bool v) { _in_concurrent_start_gc = v; } - void set_in_full_gc(bool v) { _in_full_gc = v; } + void set_in_concurrent_start_gc() { _phase = Phase::YoungConcurrentStart; _initiate_conc_mark_if_possible = false; } + void set_in_prepare_mixed_gc() { _phase = Phase::YoungPrepareMixed; } void set_initiate_conc_mark_if_possible(bool v) { _initiate_conc_mark_if_possible = v; } - void set_mark_in_progress(bool v) { _mark_in_progress = v; } - void set_mark_or_rebuild_in_progress(bool v) { _mark_or_rebuild_in_progress = v; } - void set_clear_bitmap_in_progress(bool v) { _clear_bitmap_in_progress = v; } - // Phase getters - bool in_young_only_phase() const { return _in_young_only_phase && !_in_full_gc; } - bool in_mixed_phase() const { return !_in_young_only_phase && !_in_full_gc; } + bool is_in_young_only_phase() const { return _phase == Phase::YoungNormal || _phase == Phase::YoungConcurrentStart || _phase == Phase::YoungPrepareMixed; } + bool is_in_mixed_phase() const { return _phase == Phase::Mixed; } // Specific pauses - bool in_young_gc_before_mixed() const { return _in_young_gc_before_mixed; } - bool in_full_gc() const { return _in_full_gc; } - bool in_concurrent_start_gc() const { return _in_concurrent_start_gc; } + bool is_in_concurrent_start_gc() const { return _phase == Phase::YoungConcurrentStart; } + bool is_in_prepare_mixed_gc() const { return _phase == Phase::YoungPrepareMixed; } + bool is_in_full_gc() const { return _phase == Phase::FullGC; } bool initiate_conc_mark_if_possible() const { return _initiate_conc_mark_if_possible; } - bool mark_in_progress() const { return _mark_in_progress; } - bool mark_or_rebuild_in_progress() const { return _mark_or_rebuild_in_progress; } - bool clear_bitmap_in_progress() const { return _clear_bitmap_in_progress; } + bool is_in_concurrent_cycle() const; + bool is_in_marking() const; + bool is_in_mark_or_rebuild() const; + bool is_in_reset_for_next_cycle() const; + + enum class Pause : uint { + Normal, + ConcurrentStartFull, + ConcurrentStartUndo, + PrepareMixed, + Cleanup, + Remark, + Mixed, + Full + }; // Calculate GC Pause Type from internal state. - G1GCPauseType young_gc_pause_type(bool concurrent_operation_is_full_mark) const; + Pause gc_pause_type(bool concurrent_operation_is_full_mark) const; + + static const char* to_string(Pause type) { + static const char* pause_strings[] = { "Normal", + "Concurrent Start", // Do not distinguish between the different + "Concurrent Start", // Concurrent Start pauses. + "Prepare Mixed", + "Cleanup", + "Remark", + "Mixed", + "Full" }; + return pause_strings[static_cast(type)]; + } + + static void assert_is_young_pause(Pause type) { + assert(type != Pause::Full, "must be"); + assert(type != Pause::Remark, "must be"); + assert(type != Pause::Cleanup, "must be"); + } + + static bool is_young_only_pause(Pause type) { + assert_is_young_pause(type); + return type == Pause::ConcurrentStartUndo || + type == Pause::ConcurrentStartFull || + type == Pause::PrepareMixed || + type == Pause::Normal; + } + + static bool is_mixed_pause(Pause type) { + assert_is_young_pause(type); + return type == Pause::Mixed; + } + + static bool is_prepare_mixed_pause(Pause type) { + assert_is_young_pause(type); + return type == Pause::PrepareMixed; + } + + static bool is_concurrent_start_pause(Pause type) { + assert_is_young_pause(type); + return type == Pause::ConcurrentStartFull || type == Pause::ConcurrentStartUndo; + } + + static bool is_concurrent_cycle_pause(Pause type) { + return type == Pause::Cleanup || type == Pause::Remark; + } }; +ENUMERATOR_RANGE(G1CollectorState::Pause, G1CollectorState::Pause::Normal, G1CollectorState::Pause::Full) + #endif // SHARE_GC_G1_G1COLLECTORSTATE_HPP diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 8f3cafe1f5b..8fd355615d0 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -24,12 +24,12 @@ #include "classfile/classLoaderData.hpp" #include "classfile/classLoaderDataGraph.hpp" +#include "cppstdlib/new.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BatchedTask.hpp" #include "gc/g1/g1CardSetMemory.hpp" #include "gc/g1/g1CardTableClaimTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1ConcurrentMarkRemarkTasks.hpp" @@ -519,8 +519,8 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h, _max_concurrent_workers(0), _region_mark_stats(NEW_C_HEAP_ARRAY(G1RegionMarkStats, _g1h->max_num_regions(), mtGC)), - _top_at_mark_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_num_regions(), mtGC)), - _top_at_rebuild_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_num_regions(), mtGC)), + _top_at_mark_starts(NEW_C_HEAP_ARRAY(Atomic, _g1h->max_num_regions(), mtGC)), + _top_at_rebuild_starts(NEW_C_HEAP_ARRAY(Atomic, _g1h->max_num_regions(), mtGC)), _needs_remembered_set_rebuild(false) { assert(G1CGC_lock != nullptr, "CGC_lock must be initialized"); @@ -564,19 +564,41 @@ void G1ConcurrentMark::fully_initialize() { _tasks[i] = new G1CMTask(i, this, task_queue, _region_mark_stats); } + uint max_num_regions = _g1h->max_num_regions(); + ::new (_region_mark_stats) G1RegionMarkStats[max_num_regions]{}; + ::new (_top_at_mark_starts) Atomic[max_num_regions]{}; + ::new (_top_at_rebuild_starts) Atomic[max_num_regions]{}; + reset_at_marking_complete(); } -bool G1ConcurrentMark::in_progress() const { - return is_fully_initialized() ? _cm_thread->in_progress() : false; +bool G1ConcurrentMark::is_in_concurrent_cycle() const { + return is_fully_initialized() ? _cm_thread->is_in_progress() : false; +} + +bool G1ConcurrentMark::is_in_marking() const { + return is_fully_initialized() ? cm_thread()->is_in_marking() : false; +} + +bool G1ConcurrentMark::is_in_rebuild_or_scrub() const { + return cm_thread()->is_in_rebuild_or_scrub(); +} + +bool G1ConcurrentMark::is_in_reset_for_next_cycle() const { + return cm_thread()->is_in_reset_for_next_cycle(); } PartialArrayStateManager* G1ConcurrentMark::partial_array_state_manager() const { return _partial_array_state_manager; } +G1ConcurrentMarkThread* G1ConcurrentMark::cm_thread() const { + assert(is_fully_initialized(), "must be"); + return _cm_thread; +} + void G1ConcurrentMark::reset() { - _has_aborted = false; + _has_aborted.store_relaxed(false); reset_marking_for_restart(); @@ -587,8 +609,8 @@ void G1ConcurrentMark::reset() { } uint max_num_regions = _g1h->max_num_regions(); + ::new (_top_at_rebuild_starts) Atomic[max_num_regions]{}; for (uint i = 0; i < max_num_regions; i++) { - _top_at_rebuild_starts[i] = nullptr; _region_mark_stats[i].clear(); } @@ -600,7 +622,7 @@ void G1ConcurrentMark::clear_statistics(G1HeapRegion* r) { for (uint j = 0; j < _max_num_tasks; ++j) { _tasks[j]->clear_mark_stats_cache(region_idx); } - _top_at_rebuild_starts[region_idx] = nullptr; + _top_at_rebuild_starts[region_idx].store_relaxed(nullptr); _region_mark_stats[region_idx].clear(); } @@ -611,7 +633,7 @@ void G1ConcurrentMark::humongous_object_eagerly_reclaimed(G1HeapRegion* r) { // Need to clear mark bit of the humongous object. Doing this unconditionally is fine. mark_bitmap()->clear(r->bottom()); - if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) { + if (!_g1h->collector_state()->is_in_mark_or_rebuild()) { return; } @@ -636,7 +658,7 @@ void G1ConcurrentMark::reset_marking_for_restart() { } clear_has_overflown(); - _finger = _heap.start(); + _finger.store_relaxed(_heap.start()); for (uint i = 0; i < _max_num_tasks; ++i) { _tasks[i]->reset_for_restart(); @@ -657,28 +679,28 @@ void G1ConcurrentMark::set_concurrency(uint active_tasks) { void G1ConcurrentMark::set_concurrency_and_phase(uint active_tasks, bool concurrent) { set_concurrency(active_tasks); - _concurrent = concurrent; + _concurrent.store_relaxed(concurrent); if (!concurrent) { // At this point we should be in a STW phase, and completed marking. assert_at_safepoint_on_vm_thread(); assert(out_of_regions(), "only way to get here: _finger: " PTR_FORMAT ", _heap_end: " PTR_FORMAT, - p2i(_finger), p2i(_heap.end())); + p2i(finger()), p2i(_heap.end())); } } #if TASKQUEUE_STATS void G1ConcurrentMark::print_and_reset_taskqueue_stats() { - _task_queues->print_and_reset_taskqueue_stats("G1ConcurrentMark Oop Queue"); + _task_queues->print_and_reset_taskqueue_stats("Concurrent Mark"); auto get_pa_stats = [&](uint i) { return _tasks[i]->partial_array_task_stats(); }; PartialArrayTaskStats::log_set(_max_num_tasks, get_pa_stats, - "G1ConcurrentMark Partial Array Task Stats"); + "Concurrent Mark Partial Array"); for (uint i = 0; i < _max_num_tasks; ++i) { get_pa_stats(i)->reset(); @@ -695,8 +717,8 @@ void G1ConcurrentMark::reset_at_marking_complete() { } G1ConcurrentMark::~G1ConcurrentMark() { - FREE_C_HEAP_ARRAY(HeapWord*, _top_at_mark_starts); - FREE_C_HEAP_ARRAY(HeapWord*, _top_at_rebuild_starts); + FREE_C_HEAP_ARRAY(Atomic, _top_at_mark_starts); + FREE_C_HEAP_ARRAY(Atomic, _top_at_rebuild_starts); FREE_C_HEAP_ARRAY(G1RegionMarkStats, _region_mark_stats); // The G1ConcurrentMark instance is never freed. ShouldNotReachHere(); @@ -709,7 +731,6 @@ public: private: // Heap region closure used for clearing the _mark_bitmap. class G1ClearBitmapHRClosure : public G1HeapRegionClosure { - private: G1ConcurrentMark* _cm; G1CMBitMap* _bitmap; bool _suspendible; // If suspendible, do yield checks. @@ -719,7 +740,7 @@ private: } bool is_clear_concurrent_undo() { - return suspendible() && _cm->cm_thread()->in_undo_mark(); + return suspendible() && _cm->cm_thread()->is_in_undo_cycle(); } bool has_aborted() { @@ -775,8 +796,7 @@ private: // as asserts here to minimize their overhead on the product. However, we // will have them as guarantees at the beginning / end of the bitmap // clearing to get some checking in the product. - assert(!suspendible() || _cm->in_progress(), "invariant"); - assert(!suspendible() || !G1CollectedHeap::heap()->collector_state()->mark_or_rebuild_in_progress(), "invariant"); + assert(!suspendible() || _cm->is_in_reset_for_next_cycle(), "invariant"); // Abort iteration if necessary. if (has_aborted()) { @@ -807,10 +827,6 @@ public: SuspendibleThreadSetJoiner sts_join(_suspendible); G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&_cl, &_hr_claimer, worker_id); } - - bool is_complete() { - return _cl.is_complete(); - } }; void G1ConcurrentMark::clear_bitmap(WorkerThreads* workers, bool may_yield) { @@ -825,29 +841,19 @@ void G1ConcurrentMark::clear_bitmap(WorkerThreads* workers, bool may_yield) { log_debug(gc, ergo)("Running %s with %u workers for %zu work units.", cl.name(), num_workers, num_chunks); workers->run_task(&cl, num_workers); - guarantee(may_yield || cl.is_complete(), "Must have completed iteration when not yielding."); } void G1ConcurrentMark::cleanup_for_next_mark() { // Make sure that the concurrent mark thread looks to still be in // the current cycle. - guarantee(is_fully_initialized(), "should be initializd"); - guarantee(in_progress(), "invariant"); - - // We are finishing up the current cycle by clearing the next - // marking bitmap and getting it ready for the next cycle. During - // this time no other cycle can start. So, let's make sure that this - // is the case. - guarantee(!_g1h->collector_state()->mark_or_rebuild_in_progress(), "invariant"); + guarantee(is_in_reset_for_next_cycle(), "invariant"); clear_bitmap(_concurrent_workers, true); reset_partial_array_state_manager(); - // Repeat the asserts from above. - guarantee(is_fully_initialized(), "should be initializd"); - guarantee(in_progress(), "invariant"); - guarantee(!_g1h->collector_state()->mark_or_rebuild_in_progress(), "invariant"); + // Should not have changed state yet (even if a Full GC interrupted us). + guarantee(is_in_reset_for_next_cycle(), "invariant"); } void G1ConcurrentMark::reset_partial_array_state_manager() { @@ -892,9 +898,26 @@ public: }; class G1PreConcurrentStartTask::NoteStartOfMarkTask : public G1AbstractSubTask { + + class NoteStartOfMarkHRClosure : public G1HeapRegionClosure { + G1ConcurrentMark* _cm; + + public: + NoteStartOfMarkHRClosure() : G1HeapRegionClosure(), _cm(G1CollectedHeap::heap()->concurrent_mark()) { } + + bool do_heap_region(G1HeapRegion* r) override { + if (r->is_old_or_humongous() && !r->is_collection_set_candidate() && !r->in_collection_set()) { + _cm->update_top_at_mark_start(r); + } else { + _cm->reset_top_at_mark_start(r); + } + return false; + } + } _region_cl; + G1HeapRegionClaimer _claimer; public: - NoteStartOfMarkTask() : G1AbstractSubTask(G1GCPhaseTimes::NoteStartOfMark), _claimer(0) { } + NoteStartOfMarkTask() : G1AbstractSubTask(G1GCPhaseTimes::NoteStartOfMark), _region_cl(), _claimer(0) { } double worker_cost() const override { // The work done per region is very small, therefore we choose this magic number to cap the number @@ -903,8 +926,13 @@ public: return _claimer.n_regions() / regions_per_thread; } - void set_max_workers(uint max_workers) override; - void do_work(uint worker_id) override; + void set_max_workers(uint max_workers) override { + _claimer.set_n_workers(max_workers); + } + + void do_work(uint worker_id) override { + G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&_region_cl, &_claimer, worker_id); + } }; void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) { @@ -912,29 +940,6 @@ void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) { _cm->reset(); } -class NoteStartOfMarkHRClosure : public G1HeapRegionClosure { - G1ConcurrentMark* _cm; - -public: - NoteStartOfMarkHRClosure() : G1HeapRegionClosure(), _cm(G1CollectedHeap::heap()->concurrent_mark()) { } - - bool do_heap_region(G1HeapRegion* r) override { - if (r->is_old_or_humongous() && !r->is_collection_set_candidate() && !r->in_collection_set()) { - _cm->update_top_at_mark_start(r); - } - return false; - } -}; - -void G1PreConcurrentStartTask::NoteStartOfMarkTask::do_work(uint worker_id) { - NoteStartOfMarkHRClosure start_cl; - G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&start_cl, &_claimer, worker_id); -} - -void G1PreConcurrentStartTask::NoteStartOfMarkTask::set_max_workers(uint max_workers) { - _claimer.set_n_workers(max_workers); -} - G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1ConcurrentMark* cm) : G1BatchedTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) { add_serial_task(new ResetMarkingStateTask(cm)); @@ -954,8 +959,7 @@ void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) { _gc_tracer_cm->set_gc_cause(cause); } - -void G1ConcurrentMark::post_concurrent_mark_start() { +void G1ConcurrentMark::start_full_concurrent_cycle() { // Start Concurrent Marking weak-reference discovery. ReferenceProcessor* rp = _g1h->ref_processor_cm(); rp->start_discovery(false /* always_clear */); @@ -972,10 +976,26 @@ void G1ConcurrentMark::post_concurrent_mark_start() { // when marking is on. So, it's also called at the end of the // concurrent start pause to update the heap end, if the heap expands // during it. No need to call it here. + + // Signal the thread to start work. + cm_thread()->start_full_cycle(); } -void G1ConcurrentMark::post_concurrent_undo_start() { +void G1ConcurrentMark::start_undo_concurrent_cycle() { root_regions()->cancel_scan(); + + // Signal the thread to start work. + cm_thread()->start_undo_cycle(); +} + +void G1ConcurrentMark::notify_concurrent_cycle_completed() { + cm_thread()->set_idle(); +} + +void G1ConcurrentMark::stop() { + if (is_fully_initialized()) { + cm_thread()->stop(); + } } /* @@ -1163,16 +1183,14 @@ void G1ConcurrentMark::concurrent_cycle_start() { } uint G1ConcurrentMark::completed_mark_cycles() const { - return AtomicAccess::load(&_completed_mark_cycles); + return _completed_mark_cycles.load_relaxed(); } void G1ConcurrentMark::concurrent_cycle_end(bool mark_cycle_completed) { - _g1h->collector_state()->set_clear_bitmap_in_progress(false); - _g1h->trace_heap_after_gc(_gc_tracer_cm); if (mark_cycle_completed) { - AtomicAccess::inc(&_completed_mark_cycles, memory_order_relaxed); + _completed_mark_cycles.add_then_fetch(1u, memory_order_relaxed); } if (has_aborted()) { @@ -1186,7 +1204,7 @@ void G1ConcurrentMark::concurrent_cycle_end(bool mark_cycle_completed) { } void G1ConcurrentMark::mark_from_roots() { - _restart_for_overflow = false; + _restart_for_overflow.store_relaxed(false); uint active_workers = calc_active_marking_workers(); @@ -1309,14 +1327,13 @@ void G1ConcurrentMark::remark() { _g1h->workers()->run_task(&cl, num_workers); log_debug(gc, remset, tracking)("Remembered Set Tracking update regions total %u, selected %u", - _g1h->num_committed_regions(), cl.total_selected_for_rebuild()); + _g1h->num_committed_regions(), cl.total_selected_for_rebuild()); _needs_remembered_set_rebuild = (cl.total_selected_for_rebuild() > 0); if (_needs_remembered_set_rebuild) { - // Prune rebuild candidates based on G1HeapWastePercent. - // Improves rebuild time in addition to remembered set memory usage. - G1CollectionSetChooser::build(_g1h->workers(), _g1h->num_committed_regions(), _g1h->policy()->candidates()); + GrowableArrayCHeap* selected = cl.sort_and_prune_old_selected(); + _g1h->policy()->candidates()->set_candidates_from_marking(selected); } } @@ -1353,9 +1370,12 @@ void G1ConcurrentMark::remark() { G1ObjectCountIsAliveClosure is_alive(_g1h); _gc_tracer_cm->report_object_count_after_gc(&is_alive, _g1h->workers()); } + + // Successfully completed marking, advance state. + cm_thread()->set_full_cycle_rebuild_and_scrub(); } else { // We overflowed. Restart concurrent marking. - _restart_for_overflow = true; + _restart_for_overflow.store_relaxed(true); verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyLocation::RemarkOverflow); @@ -1373,6 +1393,8 @@ void G1ConcurrentMark::remark() { _g1h->update_perf_counter_cpu_time(); policy->record_concurrent_mark_remark_end(); + + return; } void G1ConcurrentMark::compute_new_sizes() { @@ -1435,6 +1457,10 @@ void G1ConcurrentMark::cleanup() { GCTraceTime(Debug, gc, phases) debug("Finalize Concurrent Mark Cleanup", _gc_timer_cm); policy->record_concurrent_mark_cleanup_end(needs_remembered_set_rebuild()); } + + // Advance state. + cm_thread()->set_full_cycle_reset_for_next_cycle(); + return; } // 'Keep Alive' oop closure used by both serial parallel reference processing. @@ -1784,44 +1810,45 @@ void G1ConcurrentMark::clear_bitmap_for_region(G1HeapRegion* hr) { } G1HeapRegion* G1ConcurrentMark::claim_region(uint worker_id) { - // "checkpoint" the finger - HeapWord* finger = _finger; + // "Checkpoint" the finger. + HeapWord* local_finger = finger(); - while (finger < _heap.end()) { - assert(_g1h->is_in_reserved(finger), "invariant"); + while (local_finger < _heap.end()) { + assert(_g1h->is_in_reserved(local_finger), "invariant"); - G1HeapRegion* curr_region = _g1h->heap_region_containing_or_null(finger); + G1HeapRegion* curr_region = _g1h->heap_region_containing_or_null(local_finger); // Make sure that the reads below do not float before loading curr_region. OrderAccess::loadload(); // Above heap_region_containing may return null as we always scan claim // until the end of the heap. In this case, just jump to the next region. - HeapWord* end = curr_region != nullptr ? curr_region->end() : finger + G1HeapRegion::GrainWords; + HeapWord* end = curr_region != nullptr ? curr_region->end() : local_finger + G1HeapRegion::GrainWords; // Is the gap between reading the finger and doing the CAS too long? - HeapWord* res = AtomicAccess::cmpxchg(&_finger, finger, end); - if (res == finger && curr_region != nullptr) { - // we succeeded + HeapWord* res = _finger.compare_exchange(local_finger, end); + if (res == local_finger && curr_region != nullptr) { + // We succeeded. HeapWord* bottom = curr_region->bottom(); HeapWord* limit = top_at_mark_start(curr_region); log_trace(gc, marking)("Claim region %u bottom " PTR_FORMAT " tams " PTR_FORMAT, curr_region->hrm_index(), p2i(curr_region->bottom()), p2i(top_at_mark_start(curr_region))); - // notice that _finger == end cannot be guaranteed here since, - // someone else might have moved the finger even further - assert(_finger >= end, "the finger should have moved forward"); + // Notice that _finger == end cannot be guaranteed here since, + // someone else might have moved the finger even further. + assert(finger() >= end, "The finger should have moved forward"); if (limit > bottom) { return curr_region; } else { assert(limit == bottom, - "the region limit should be at bottom"); + "The region limit should be at bottom"); // We return null and the caller should try calling // claim_region() again. return nullptr; } } else { - assert(_finger > finger, "the finger should have moved forward"); - // read it again - finger = _finger; + // Read the finger again. + HeapWord* next_finger = finger(); + assert(next_finger > local_finger, "The finger should have moved forward " PTR_FORMAT " " PTR_FORMAT, p2i(local_finger), p2i(next_finger)); + local_finger = next_finger; } } @@ -1860,7 +1887,7 @@ public: void G1ConcurrentMark::verify_no_collection_set_oops() { assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), "should be at a safepoint or initializing"); - if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) { + if (!is_fully_initialized() || !_g1h->collector_state()->is_in_mark_or_rebuild()) { return; } @@ -1938,7 +1965,7 @@ bool G1ConcurrentMark::concurrent_cycle_abort() { // has been signalled is already rare), and this work should be negligible compared // to actual full gc work. - if (!is_fully_initialized() || (!cm_thread()->in_progress() && !_g1h->concurrent_mark_is_terminating())) { + if (!is_fully_initialized() || (!cm_thread()->is_in_progress() && !cm_thread()->should_terminate())) { return false; } @@ -1957,7 +1984,7 @@ bool G1ConcurrentMark::concurrent_cycle_abort() { void G1ConcurrentMark::abort_marking_threads() { assert(!_root_regions.scan_in_progress(), "still doing root region scan"); - _has_aborted = true; + _has_aborted.store_relaxed(true); _first_overflow_barrier_sync.abort(); _second_overflow_barrier_sync.abort(); } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp index 0271e6a4208..de97179d210 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp @@ -352,6 +352,8 @@ class G1ConcurrentMark : public CHeapObj { friend class G1CMRemarkTask; friend class G1CMRootRegionScanTask; friend class G1CMTask; + friend class G1ClearBitMapTask; + friend class G1CollectorState; friend class G1ConcurrentMarkThread; G1ConcurrentMarkThread* _cm_thread; // The thread doing the work @@ -368,7 +370,7 @@ class G1ConcurrentMark : public CHeapObj { // For grey objects G1CMMarkStack _global_mark_stack; // Grey objects behind global finger - HeapWord* volatile _finger; // The global finger, region aligned, + Atomic _finger; // The global finger, region aligned, // always pointing to the end of the // last claimed region @@ -395,19 +397,19 @@ class G1ConcurrentMark : public CHeapObj { WorkerThreadsBarrierSync _second_overflow_barrier_sync; // Number of completed mark cycles. - volatile uint _completed_mark_cycles; + Atomic _completed_mark_cycles; // This is set by any task, when an overflow on the global data // structures is detected - volatile bool _has_overflown; + Atomic _has_overflown; // True: marking is concurrent, false: we're in remark - volatile bool _concurrent; + Atomic _concurrent; // Set at the end of a Full GC so that marking aborts - volatile bool _has_aborted; + Atomic _has_aborted; // Used when remark aborts due to an overflow to indicate that // another concurrent marking phase should start - volatile bool _restart_for_overflow; + Atomic _restart_for_overflow; ConcurrentGCTimer* _gc_timer_cm; @@ -461,8 +463,8 @@ class G1ConcurrentMark : public CHeapObj { void print_and_reset_taskqueue_stats(); - HeapWord* finger() { return _finger; } - bool concurrent() { return _concurrent; } + HeapWord* finger() { return _finger.load_relaxed(); } + bool concurrent() { return _concurrent.load_relaxed(); } uint active_tasks() { return _num_active_tasks; } TaskTerminator* terminator() { return &_terminator; } @@ -487,7 +489,7 @@ class G1ConcurrentMark : public CHeapObj { // to satisfy an allocation without doing a GC. This is fine, because all // objects in those regions will be considered live anyway because of // SATB guarantees (i.e. their TAMS will be equal to bottom). - bool out_of_regions() { return _finger >= _heap.end(); } + bool out_of_regions() { return finger() >= _heap.end(); } // Returns the task with the given id G1CMTask* task(uint id) { @@ -499,10 +501,10 @@ class G1ConcurrentMark : public CHeapObj { // Access / manipulation of the overflow flag which is set to // indicate that the global stack has overflown - bool has_overflown() { return _has_overflown; } - void set_has_overflown() { _has_overflown = true; } - void clear_has_overflown() { _has_overflown = false; } - bool restart_for_overflow() { return _restart_for_overflow; } + bool has_overflown() { return _has_overflown.load_relaxed(); } + void set_has_overflown() { _has_overflown.store_relaxed(true); } + void clear_has_overflown() { _has_overflown.store_relaxed(false); } + bool restart_for_overflow() { return _restart_for_overflow.load_relaxed(); } // Methods to enter the two overflow sync barriers void enter_first_sync_barrier(uint worker_id); @@ -516,14 +518,23 @@ class G1ConcurrentMark : public CHeapObj { G1RegionMarkStats* _region_mark_stats; // Top pointer for each region at the start of marking. Must be valid for all committed // regions. - HeapWord* volatile* _top_at_mark_starts; + Atomic* _top_at_mark_starts; // Top pointer for each region at the start of the rebuild remembered set process // for regions which remembered sets need to be rebuilt. A null for a given region // means that this region does not be scanned during the rebuilding remembered // set phase at all. - HeapWord* volatile* _top_at_rebuild_starts; + Atomic* _top_at_rebuild_starts; // True when Remark pause selected regions for rebuilding. bool _needs_remembered_set_rebuild; + + G1ConcurrentMarkThread* cm_thread() const; + + // Concurrent cycle state queries. + bool is_in_concurrent_cycle() const; + bool is_in_marking() const; + bool is_in_rebuild_or_scrub() const; + bool is_in_reset_for_next_cycle() const; + public: // To be called when an object is marked the first time, e.g. after a successful // mark_in_bitmap call. Updates various statistics data. @@ -557,7 +568,7 @@ public: void fully_initialize(); bool is_fully_initialized() const { return _cm_thread != nullptr; } - bool in_progress() const; + uint max_num_tasks() const {return _max_num_tasks; } // Clear statistics gathered during the concurrent cycle for the given region after @@ -602,8 +613,6 @@ public: G1RegionToSpaceMapper* bitmap_storage); ~G1ConcurrentMark(); - G1ConcurrentMarkThread* cm_thread() { return _cm_thread; } - G1CMBitMap* mark_bitmap() const { return (G1CMBitMap*)&_mark_bitmap; } // Calculates the number of concurrent GC threads to be used in the marking phase. @@ -632,8 +641,15 @@ public: // These two methods do the work that needs to be done at the start and end of the // concurrent start pause. void pre_concurrent_start(GCCause::Cause cause); - void post_concurrent_mark_start(); - void post_concurrent_undo_start(); + + // Start the particular type of concurrent cycle. After this call threads may be running. + void start_full_concurrent_cycle(); + void start_undo_concurrent_cycle(); + + void notify_concurrent_cycle_completed(); + + // Stop active components/the concurrent mark thread. + void stop(); // Scan all the root regions and mark everything reachable from // them. @@ -657,8 +673,10 @@ public: // Do concurrent preclean work. void preclean(); + // Executes the Remark pause. void remark(); + // Executes the Cleanup pause. void cleanup(); // Mark in the marking bitmap. Used during evacuation failure to @@ -679,7 +697,7 @@ public: uint completed_mark_cycles() const; - bool has_aborted() { return _has_aborted; } + bool has_aborted() { return _has_aborted.load_relaxed(); } void print_summary_info(); diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp index 2f4824e4cae..21167d5cae9 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp @@ -194,11 +194,11 @@ inline void G1CMTask::process_array_chunk(objArrayOop obj, size_t start, size_t inline void G1ConcurrentMark::update_top_at_mark_start(G1HeapRegion* r) { uint const region = r->hrm_index(); assert(region < _g1h->max_num_regions(), "Tried to access TAMS for region %u out of bounds", region); - _top_at_mark_starts[region] = r->top(); + _top_at_mark_starts[region].store_relaxed(r->top()); } inline void G1ConcurrentMark::reset_top_at_mark_start(G1HeapRegion* r) { - _top_at_mark_starts[r->hrm_index()] = r->bottom(); + _top_at_mark_starts[r->hrm_index()].store_relaxed(r->bottom()); } inline HeapWord* G1ConcurrentMark::top_at_mark_start(const G1HeapRegion* r) const { @@ -207,7 +207,7 @@ inline HeapWord* G1ConcurrentMark::top_at_mark_start(const G1HeapRegion* r) cons inline HeapWord* G1ConcurrentMark::top_at_mark_start(uint region) const { assert(region < _g1h->max_num_regions(), "Tried to access TARS for region %u out of bounds", region); - return _top_at_mark_starts[region]; + return _top_at_mark_starts[region].load_relaxed(); } inline bool G1ConcurrentMark::obj_allocated_since_mark_start(oop obj) const { @@ -217,7 +217,7 @@ inline bool G1ConcurrentMark::obj_allocated_since_mark_start(oop obj) const { } inline HeapWord* G1ConcurrentMark::top_at_rebuild_start(G1HeapRegion* r) const { - return _top_at_rebuild_starts[r->hrm_index()]; + return _top_at_rebuild_starts[r->hrm_index()].load_relaxed(); } inline void G1ConcurrentMark::update_top_at_rebuild_start(G1HeapRegion* r) { @@ -225,10 +225,10 @@ inline void G1ConcurrentMark::update_top_at_rebuild_start(G1HeapRegion* r) { uint const region = r->hrm_index(); assert(region < _g1h->max_num_regions(), "Tried to access TARS for region %u out of bounds", region); - assert(_top_at_rebuild_starts[region] == nullptr, + assert(top_at_rebuild_start(r) == nullptr, "TARS for region %u has already been set to " PTR_FORMAT " should be null", - region, p2i(_top_at_rebuild_starts[region])); - _top_at_rebuild_starts[region] = r->top(); + region, p2i(top_at_rebuild_start(r))); + _top_at_rebuild_starts[region].store_relaxed(r->top()); } inline void G1CMTask::update_liveness(oop const obj, const size_t obj_size) { diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.cpp index 4eb11f6d8f6..3eda7200e25 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.cpp @@ -31,28 +31,32 @@ #include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "logging/log.hpp" #include "runtime/mutexLocker.hpp" +#include "utilities/growableArray.hpp" struct G1UpdateRegionLivenessAndSelectForRebuildTask::G1OnRegionClosure : public G1HeapRegionClosure { G1CollectedHeap* _g1h; G1ConcurrentMark* _cm; - // The number of regions actually selected for rebuild. - uint _num_selected_for_rebuild; size_t _freed_bytes; uint _num_old_regions_removed; uint _num_humongous_regions_removed; - G1FreeRegionList* _local_cleanup_list; + + GrowableArrayCHeap _old_selected_for_rebuild; + uint _num_humongous_selected_for_rebuild; + + G1FreeRegionList* _cleanup_list; G1OnRegionClosure(G1CollectedHeap* g1h, G1ConcurrentMark* cm, G1FreeRegionList* local_cleanup_list) : _g1h(g1h), _cm(cm), - _num_selected_for_rebuild(0), _freed_bytes(0), _num_old_regions_removed(0), _num_humongous_regions_removed(0), - _local_cleanup_list(local_cleanup_list) {} + _old_selected_for_rebuild(16), + _num_humongous_selected_for_rebuild(0), + _cleanup_list(local_cleanup_list) {} void reclaim_empty_region_common(G1HeapRegion* hr) { assert(!hr->has_pinned_objects(), "precondition"); @@ -74,7 +78,7 @@ struct G1UpdateRegionLivenessAndSelectForRebuildTask::G1OnRegionClosure : public _num_humongous_regions_removed++; reclaim_empty_region_common(hr); - _g1h->free_humongous_region(hr, _local_cleanup_list); + _g1h->free_humongous_region(hr, _cleanup_list); }; _g1h->humongous_obj_regions_iterate(hr, on_humongous_region); @@ -85,7 +89,7 @@ struct G1UpdateRegionLivenessAndSelectForRebuildTask::G1OnRegionClosure : public _num_old_regions_removed++; reclaim_empty_region_common(hr); - _g1h->free_region(hr, _local_cleanup_list); + _g1h->free_region(hr, _cleanup_list); } bool do_heap_region(G1HeapRegion* hr) override { @@ -98,13 +102,13 @@ struct G1UpdateRegionLivenessAndSelectForRebuildTask::G1OnRegionClosure : public || hr->has_pinned_objects(); if (is_live) { const bool selected_for_rebuild = tracker->update_humongous_before_rebuild(hr); + auto on_humongous_region = [&] (G1HeapRegion* hr) { if (selected_for_rebuild) { - _num_selected_for_rebuild++; + _num_humongous_selected_for_rebuild++; } _cm->update_top_at_rebuild_start(hr); }; - _g1h->humongous_obj_regions_iterate(hr, on_humongous_region); } else { reclaim_empty_humongous_region(hr); @@ -118,7 +122,7 @@ struct G1UpdateRegionLivenessAndSelectForRebuildTask::G1OnRegionClosure : public if (is_live) { const bool selected_for_rebuild = tracker->update_old_before_rebuild(hr); if (selected_for_rebuild) { - _num_selected_for_rebuild++; + _old_selected_for_rebuild.push(hr); } _cm->update_top_at_rebuild_start(hr); } else { @@ -137,7 +141,8 @@ G1UpdateRegionLivenessAndSelectForRebuildTask::G1UpdateRegionLivenessAndSelectFo _g1h(g1h), _cm(cm), _hrclaimer(num_workers), - _total_selected_for_rebuild(0), + _old_selected_for_rebuild(128), + _num_humongous_selected_for_rebuild(0), _cleanup_list("Empty Regions After Mark List") {} G1UpdateRegionLivenessAndSelectForRebuildTask::~G1UpdateRegionLivenessAndSelectForRebuildTask() { @@ -153,8 +158,6 @@ void G1UpdateRegionLivenessAndSelectForRebuildTask::work(uint worker_id) { G1OnRegionClosure on_region_cl(_g1h, _cm, &local_cleanup_list); _g1h->heap_region_par_iterate_from_worker_offset(&on_region_cl, &_hrclaimer, worker_id); - _total_selected_for_rebuild.add_then_fetch(on_region_cl._num_selected_for_rebuild); - // Update the old/humongous region sets _g1h->remove_from_old_gen_sets(on_region_cl._num_old_regions_removed, on_region_cl._num_humongous_regions_removed); @@ -163,6 +166,9 @@ void G1UpdateRegionLivenessAndSelectForRebuildTask::work(uint worker_id) { MutexLocker x(G1RareEvent_lock, Mutex::_no_safepoint_check_flag); _g1h->decrement_summary_bytes(on_region_cl._freed_bytes); + _old_selected_for_rebuild.appendAll(&on_region_cl._old_selected_for_rebuild); + _num_humongous_selected_for_rebuild += on_region_cl._num_humongous_selected_for_rebuild; + _cleanup_list.add_ordered(&local_cleanup_list); assert(local_cleanup_list.is_empty(), "post-condition"); } @@ -172,3 +178,78 @@ uint G1UpdateRegionLivenessAndSelectForRebuildTask::desired_num_workers(uint num const uint num_regions_per_worker = 384; return (num_regions + num_regions_per_worker - 1) / num_regions_per_worker; } + +// Early prune (remove) regions meeting the G1HeapWastePercent criteria. That +// is, either until only the minimum amount of old collection set regions are +// available (for forward progress in evacuation) or the waste accumulated by the +// removed regions is above the maximum allowed waste. +// Updates number of candidates and reclaimable bytes given. +void G1UpdateRegionLivenessAndSelectForRebuildTask::prune(GrowableArrayCHeap* old_regions) { + G1Policy* p = G1CollectedHeap::heap()->policy(); + + uint num_candidates = (uint)old_regions->length(); + + uint min_old_cset_length = p->calc_min_old_cset_length(num_candidates); + uint num_pruned = 0; + size_t wasted_bytes = 0; + + if (min_old_cset_length >= num_candidates) { + // We take all of the candidate regions to provide some forward progress. + return; + } + + size_t allowed_waste = p->allowed_waste_in_collection_set(); + uint max_to_prune = num_candidates - min_old_cset_length; + + while (true) { + G1HeapRegion* r = old_regions->at(num_candidates - num_pruned - 1); + size_t const reclaimable = r->reclaimable_bytes(); + if (num_pruned >= max_to_prune || + wasted_bytes + reclaimable > allowed_waste) { + break; + } + r->rem_set()->clear(true /* cardset_only */); + + wasted_bytes += reclaimable; + num_pruned++; + } + + log_debug(gc, ergo, cset)("Pruned %u regions out of %u, leaving %zu bytes waste (allowed %zu)", + num_pruned, + num_candidates, + wasted_bytes, + allowed_waste); + + old_regions->trunc_to(num_candidates - num_pruned); +} + +static int compare_region_gc_efficiency(G1HeapRegion** rr1, G1HeapRegion** rr2) { + G1HeapRegion* r1 = *rr1; + G1HeapRegion* r2 = *rr2; + + assert(r1 != nullptr, "must be"); + assert(r2 != nullptr, "must be"); + + G1Policy* p = G1CollectedHeap::heap()->policy(); + double gc_efficiency1 = p->predict_gc_efficiency(r1); + double gc_efficiency2 = p->predict_gc_efficiency(r2); + + if (gc_efficiency1 > gc_efficiency2) { + return -1; + } else if (gc_efficiency1 < gc_efficiency2) { + return 1; + } else { + return 0; + } +} + +GrowableArrayCHeap* G1UpdateRegionLivenessAndSelectForRebuildTask::sort_and_prune_old_selected() { + // Nothing to do for the humongous candidates here. Old selected need to be pruned. + + if (_old_selected_for_rebuild.length() != 0) { + _old_selected_for_rebuild.sort(compare_region_gc_efficiency); + prune(&_old_selected_for_rebuild); + } + + return &_old_selected_for_rebuild; +} diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.hpp index a256693ff1d..6905419e2cc 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkRemarkTasks.hpp @@ -29,7 +29,7 @@ #include "gc/g1/g1HeapRegionManager.hpp" #include "gc/g1/g1HeapRegionSet.hpp" #include "gc/shared/workerThread.hpp" -#include "runtime/atomic.hpp" +#include "utilities/growableArray.hpp" class G1CollectedHeap; class G1ConcurrentMark; @@ -42,13 +42,15 @@ class G1UpdateRegionLivenessAndSelectForRebuildTask : public WorkerTask { G1ConcurrentMark* _cm; G1HeapRegionClaimer _hrclaimer; - Atomic _total_selected_for_rebuild; + GrowableArrayCHeap _old_selected_for_rebuild; + uint _num_humongous_selected_for_rebuild; // Reclaimed empty regions G1FreeRegionList _cleanup_list; struct G1OnRegionClosure; + void prune(GrowableArrayCHeap* old_regions); public: G1UpdateRegionLivenessAndSelectForRebuildTask(G1CollectedHeap* g1h, G1ConcurrentMark* cm, @@ -59,9 +61,14 @@ public: void work(uint worker_id) override; uint total_selected_for_rebuild() const { - return _total_selected_for_rebuild.load_relaxed(); + return (uint)_old_selected_for_rebuild.length() + _num_humongous_selected_for_rebuild; } + // Sort selected old regions by efficiency and prune them based on G1HeapWastePercent. + // This pruning improves rebuild time in addition to remembered set memory usage. + // Returns the set of regions selected in efficiency order. + GrowableArrayCHeap* sort_and_prune_old_selected(); + static uint desired_num_workers(uint num_regions); }; diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp index 629cbae935e..31d61b8b388 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,22 +112,22 @@ class G1ConcPhaseTimer : public GCTraceConcTimeImpl title("Concurrent %s Cycle", _state == FullMark ? "Mark" : "Undo"); + FormatBuffer<128> title("Concurrent %s Cycle", is_in_full_concurrent_cycle() ? "Mark" : "Undo"); GCTraceConcTime(Info, gc) tt(title); concurrent_cycle_start(); - if (_state == FullMark) { + if (_state == FullCycleMarking) { concurrent_mark_cycle_do(); } else { - assert(_state == UndoMark, "Must do undo mark but is %d", _state); + assert(_state == UndoCycleResetForNextCycle, "Must do undo mark but is %d", _state); concurrent_undo_cycle_do(); } - concurrent_cycle_end(_state == FullMark && !_cm->has_aborted()); + concurrent_cycle_end(is_in_full_concurrent_cycle() && !_cm->has_aborted()); update_perf_counter_cpu_time(); } @@ -135,7 +135,7 @@ void G1ConcurrentMarkThread::run_service() { } void G1ConcurrentMarkThread::stop_service() { - if (in_progress()) { + if (is_in_progress()) { // We are not allowed to abort the marking threads during root region scan. // Needs to be done separately. _cm->root_region_scan_abort_and_wait(); @@ -149,7 +149,7 @@ void G1ConcurrentMarkThread::stop_service() { bool G1ConcurrentMarkThread::wait_for_next_cycle() { MonitorLocker ml(G1CGC_lock, Mutex::_no_safepoint_check_flag); - while (!in_progress() && !should_terminate()) { + while (!is_in_progress() && !should_terminate()) { ml.wait(); } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp index 22be7d9ffbb..e75298fdcb4 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,25 +32,34 @@ class G1Policy; // The concurrent mark thread triggers the various steps of the concurrent marking // cycle, including various marking cleanup. +// +// The concurrent cycle may either be "Full" (i.e. include marking, rebuilding and +// scrubbing, resetting for the next cycle) or "Undo", i.e. shortened to just the +// reset part. class G1ConcurrentMarkThread: public ConcurrentGCThread { G1ConcurrentMark* _cm; enum ServiceState : uint { Idle, - FullMark, - UndoMark + FullCycleMarking, + FullCycleRebuildOrScrub, + FullCycleResetForNextCycle, + UndoCycleResetForNextCycle }; volatile ServiceState _state; + // Returns whether we are in a "Full" cycle. + bool is_in_full_concurrent_cycle() const; + // Wait for next cycle. Returns the command passed over. bool wait_for_next_cycle(); bool mark_loop_needs_restart() const; - // Phases and subphases for the full concurrent marking cycle in order. + // Phases and subphases for the full concurrent cycle in order. // - // All these methods return true if the marking should be aborted. + // All these methods return true if the cycle should be aborted. bool phase_clear_cld_claimed_marks(); bool phase_scan_root_regions(); @@ -88,22 +97,25 @@ class G1ConcurrentMarkThread: public ConcurrentGCThread { double total_mark_cpu_time_s(); // Cpu time used by all marking worker threads in seconds. double worker_threads_cpu_time_s(); - - G1ConcurrentMark* cm() { return _cm; } - + // State management. void set_idle(); - void start_full_mark(); - void start_undo_mark(); + void start_full_cycle(); + void start_undo_cycle(); - bool idle() const; + void set_full_cycle_rebuild_and_scrub(); + void set_full_cycle_reset_for_next_cycle(); + + bool is_idle() const; // Returns true from the moment a concurrent cycle is - // initiated (during the concurrent start pause when started() is set) - // to the moment when the cycle completes (just after the next - // marking bitmap has been cleared and in_progress() is - // cleared). - bool in_progress() const; + // initiated (during the concurrent start pause when calling one of the + // start_*_cycle() methods) to the moment when the cycle completes. + bool is_in_progress() const; - bool in_undo_mark() const; + bool is_in_marking() const; + bool is_in_rebuild_or_scrub() const; + bool is_in_reset_for_next_cycle() const; + + bool is_in_undo_cycle() const; // Update the perf data counter for concurrent mark. void update_perf_counter_cpu_time(); diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.inline.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.inline.hpp index 254eaf62bb2..8cb7881e000 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.inline.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,7 @@ // Total virtual time so far. inline double G1ConcurrentMarkThread::total_mark_cpu_time_s() { - return os::thread_cpu_time(this) + worker_threads_cpu_time_s(); + return static_cast(os::thread_cpu_time(this)) + worker_threads_cpu_time_s(); } // Marking virtual time so far @@ -40,29 +40,64 @@ inline double G1ConcurrentMarkThread::worker_threads_cpu_time_s() { return _cm->worker_threads_cpu_time_s(); } +inline bool G1ConcurrentMarkThread::is_in_full_concurrent_cycle() const { + ServiceState state = _state; + return (state == FullCycleMarking || state == FullCycleRebuildOrScrub || state == FullCycleResetForNextCycle); +} + inline void G1ConcurrentMarkThread::set_idle() { - assert(_state == FullMark || _state == UndoMark, "must not be starting a new cycle"); + // Concurrent cycle may be aborted any time. + assert(!is_idle(), "must not be idle"); _state = Idle; } -inline void G1ConcurrentMarkThread::start_full_mark() { - assert(_state == Idle, "cycle in progress"); - _state = FullMark; +inline void G1ConcurrentMarkThread::start_full_cycle() { + assert(SafepointSynchronize::is_at_safepoint(), "must be"); + assert(is_idle(), "cycle in progress"); + _state = FullCycleMarking; } -inline void G1ConcurrentMarkThread::start_undo_mark() { - assert(_state == Idle, "cycle in progress"); - _state = UndoMark; +inline void G1ConcurrentMarkThread::start_undo_cycle() { + assert(SafepointSynchronize::is_at_safepoint(), "must be"); + assert(is_idle(), "cycle in progress"); + _state = UndoCycleResetForNextCycle; } -inline bool G1ConcurrentMarkThread::idle() const { return _state == Idle; } - -inline bool G1ConcurrentMarkThread::in_progress() const { - return !idle(); +inline void G1ConcurrentMarkThread::set_full_cycle_rebuild_and_scrub() { + assert(SafepointSynchronize::is_at_safepoint(), "must be"); + assert(_state == FullCycleMarking, "must be"); + _state = FullCycleRebuildOrScrub; } -inline bool G1ConcurrentMarkThread::in_undo_mark() const { - return _state == UndoMark; +inline void G1ConcurrentMarkThread::set_full_cycle_reset_for_next_cycle() { + assert(SafepointSynchronize::is_at_safepoint(), "must be"); + assert(_state == FullCycleRebuildOrScrub, "must be"); + _state = FullCycleResetForNextCycle; +} + +inline bool G1ConcurrentMarkThread::is_in_marking() const { + return _state == FullCycleMarking; +} + +inline bool G1ConcurrentMarkThread::is_in_rebuild_or_scrub() const { + return _state == FullCycleRebuildOrScrub; +} + +inline bool G1ConcurrentMarkThread::is_in_reset_for_next_cycle() const { + ServiceState state = _state; + return state == FullCycleResetForNextCycle || state == UndoCycleResetForNextCycle; +} + +inline bool G1ConcurrentMarkThread::is_idle() const { + return _state == Idle; +} + +inline bool G1ConcurrentMarkThread::is_in_progress() const { + return !is_idle(); +} + +inline bool G1ConcurrentMarkThread::is_in_undo_cycle() const { + return _state == UndoCycleResetForNextCycle; } #endif // SHARE_GC_G1_G1CONCURRENTMARKTHREAD_INLINE_HPP diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.cpp index 5160d5ed036..7da0066e2f1 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.cpp @@ -23,21 +23,8 @@ */ #include "gc/g1/g1ConcurrentRefineStats.inline.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/timer.hpp" -G1ConcurrentRefineStats::G1ConcurrentRefineStats() : - _sweep_duration(0), - _yield_during_sweep_duration(0), - _cards_scanned(0), - _cards_clean(0), - _cards_not_parsable(0), - _cards_already_refer_to_cset(0), - _cards_refer_to_cset(0), - _cards_no_cross_region(0), - _refine_duration(0) -{} - void G1ConcurrentRefineStats::add_atomic(G1ConcurrentRefineStats* other) { _sweep_duration.add_then_fetch(other->_sweep_duration.load_relaxed(), memory_order_relaxed); _yield_during_sweep_duration.add_then_fetch(other->yield_during_sweep_duration(), memory_order_relaxed); diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.hpp b/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.hpp index 5f57c56ba6c..a91ad0eb2e4 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefineStats.hpp @@ -47,8 +47,6 @@ class G1ConcurrentRefineStats : public CHeapObj { Atomic _refine_duration; // Time spent during actual refinement. public: - G1ConcurrentRefineStats(); - // Time spent performing sweeping the refinement table (includes actual refinement, // but not yield time). inline jlong sweep_duration() const; diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index b6388c2f722..c835dd159a6 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -23,6 +23,7 @@ */ #include "classfile/classLoaderDataGraph.hpp" +#include "cppstdlib/new.hpp" #include "gc/g1/g1CollectedHeap.hpp" #include "gc/g1/g1FullCollector.inline.hpp" #include "gc/g1/g1FullGCAdjustTask.hpp" @@ -134,12 +135,13 @@ G1FullCollector::G1FullCollector(G1CollectedHeap* heap, _compaction_points = NEW_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _num_workers, mtGC); _live_stats = NEW_C_HEAP_ARRAY(G1RegionMarkStats, _heap->max_num_regions(), mtGC); - _compaction_tops = NEW_C_HEAP_ARRAY(Atomic, _heap->max_num_regions(), mtGC); for (uint j = 0; j < heap->max_num_regions(); j++) { _live_stats[j].clear(); - ::new (&_compaction_tops[j]) Atomic{}; } + _compaction_tops = NEW_C_HEAP_ARRAY(Atomic, _heap->max_num_regions(), mtGC); + ::new (_compaction_tops) Atomic[heap->max_num_regions()]{}; + _partial_array_state_manager = new PartialArrayStateManager(_num_workers); for (uint i = 0; i < _num_workers; i++) { @@ -351,7 +353,13 @@ void G1FullCollector::phase1_mark_live_objects() { scope()->tracer()->report_object_count_after_gc(&_is_alive, _heap->workers()); } #if TASKQUEUE_STATS - marking_task_queues()->print_and_reset_taskqueue_stats("Marking Task Queue"); + marking_task_queues()->print_and_reset_taskqueue_stats("Full GC"); + + auto get_stats = [&](uint i) { + return marker(i)->partial_array_splitter().stats(); + }; + PartialArrayTaskStats::log_set(_num_workers, get_stats, + "Full GC Partial Array"); #endif } diff --git a/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp b/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp index 0c201f0e43f..ef6344d349d 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp @@ -30,7 +30,6 @@ #include "gc/g1/g1FullGCHeapRegionAttr.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "oops/oopsHierarchy.hpp" -#include "runtime/atomicAccess.hpp" bool G1FullCollector::is_compacting(oop obj) const { return _region_attr_table.is_compacting(cast_from_oop(obj)); diff --git a/src/hotspot/share/gc/g1/g1FullGCMarker.hpp b/src/hotspot/share/gc/g1/g1FullGCMarker.hpp index 5973cc841c5..82fe3655319 100644 --- a/src/hotspot/share/gc/g1/g1FullGCMarker.hpp +++ b/src/hotspot/share/gc/g1/g1FullGCMarker.hpp @@ -89,6 +89,7 @@ public: ~G1FullGCMarker(); G1MarkTasksQueue* task_queue() { return &_task_queue; } + PartialArraySplitter& partial_array_splitter() { return _partial_array_splitter; } // Marking entry points template inline void mark_and_push(T* p); diff --git a/src/hotspot/share/gc/g1/g1GCPauseType.hpp b/src/hotspot/share/gc/g1/g1GCPauseType.hpp deleted file mode 100644 index 254edb28fea..00000000000 --- a/src/hotspot/share/gc/g1/g1GCPauseType.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2021, 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. - * - */ - -#ifndef SHARE_GC_G1_G1GCPAUSETYPES_HPP -#define SHARE_GC_G1_G1GCPAUSETYPES_HPP - -#include "utilities/debug.hpp" -#include "utilities/enumIterator.hpp" - -enum class G1GCPauseType : uint { - YoungGC, - LastYoungGC, - ConcurrentStartMarkGC, - ConcurrentStartUndoGC, - Cleanup, - Remark, - MixedGC, - FullGC -}; - -ENUMERATOR_RANGE(G1GCPauseType, G1GCPauseType::YoungGC, G1GCPauseType::FullGC) - -class G1GCPauseTypeHelper { -public: - - static void assert_is_young_pause(G1GCPauseType type) { - assert(type != G1GCPauseType::FullGC, "must be"); - assert(type != G1GCPauseType::Remark, "must be"); - assert(type != G1GCPauseType::Cleanup, "must be"); - } - - static bool is_young_only_pause(G1GCPauseType type) { - assert_is_young_pause(type); - return type == G1GCPauseType::ConcurrentStartUndoGC || - type == G1GCPauseType::ConcurrentStartMarkGC || - type == G1GCPauseType::LastYoungGC || - type == G1GCPauseType::YoungGC; - } - - static bool is_mixed_pause(G1GCPauseType type) { - assert_is_young_pause(type); - return type == G1GCPauseType::MixedGC; - } - - static bool is_last_young_pause(G1GCPauseType type) { - assert_is_young_pause(type); - return type == G1GCPauseType::LastYoungGC; - } - - static bool is_concurrent_start_pause(G1GCPauseType type) { - assert_is_young_pause(type); - return type == G1GCPauseType::ConcurrentStartMarkGC || type == G1GCPauseType::ConcurrentStartUndoGC; - } - - static const char* to_string(G1GCPauseType type) { - static const char* pause_strings[] = { "Normal", - "Prepare Mixed", - "Concurrent Start", // Do not distinguish between the different - "Concurrent Start", // Concurrent Start pauses. - "Cleanup", - "Remark", - "Mixed", - "Full" }; - return pause_strings[static_cast(type)]; - } -}; - -#endif // SHARE_GC_G1_G1GCPAUSETYPES_HPP diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.hpp b/src/hotspot/share/gc/g1/g1HeapRegion.hpp index 2b4b640d52b..ec9cab26049 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.hpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.hpp @@ -567,41 +567,15 @@ public: // G1HeapRegionClosure is used for iterating over regions. // Terminates the iteration when the "do_heap_region" method returns "true". class G1HeapRegionClosure : public StackObj { - friend class G1HeapRegionManager; - friend class G1CollectionSet; - friend class G1CollectionSetCandidates; - - bool _is_complete; - void set_incomplete() { _is_complete = false; } - public: - G1HeapRegionClosure(): _is_complete(true) {} - // Typically called on each region until it returns true. virtual bool do_heap_region(G1HeapRegion* r) = 0; - - // True after iteration if the closure was applied to all heap regions - // and returned "false" in all cases. - bool is_complete() { return _is_complete; } }; class G1HeapRegionIndexClosure : public StackObj { - friend class G1HeapRegionManager; - friend class G1CollectionSet; - friend class G1CollectionSetCandidates; - - bool _is_complete; - void set_incomplete() { _is_complete = false; } - public: - G1HeapRegionIndexClosure(): _is_complete(true) {} - // Typically called on each region until it returns true. virtual bool do_heap_region_index(uint region_index) = 0; - - // True after iteration if the closure was applied to all heap regions - // and returned "false" in all cases. - bool is_complete() { return _is_complete; } }; #endif // SHARE_GC_G1_G1HEAPREGION_HPP diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp index 4f242b7a537..f92e37fee3c 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp @@ -42,6 +42,11 @@ #include "utilities/globalDefinitions.hpp" inline HeapWord* G1HeapRegion::block_start(const void* addr) const { + if (is_young()) { + // We are here because of BlockLocationPrinter. + // Can be invoked in any context, so this region might not be parsable. + return nullptr; + } return block_start(addr, parsable_bottom_acquire()); } @@ -64,6 +69,7 @@ inline HeapWord* G1HeapRegion::advance_to_block_containing_addr(const void* addr inline HeapWord* G1HeapRegion::block_start(const void* addr, HeapWord* const pb) const { assert(addr >= bottom() && addr < top(), "invalid address"); + assert(!is_young(), "Only non-young regions have BOT"); HeapWord* first_block = _bot->block_start_reaching_into_card(addr); return advance_to_block_containing_addr(addr, pb, first_block); } diff --git a/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp b/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp index 44897c8a277..3c0318827ef 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp @@ -34,7 +34,6 @@ #include "jfr/jfrEvents.hpp" #include "logging/logStream.hpp" #include "memory/allocation.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/orderAccess.hpp" #include "utilities/bitMap.inline.hpp" @@ -512,7 +511,6 @@ void G1HeapRegionManager::iterate(G1HeapRegionClosure* blk) const { guarantee(at(i) != nullptr, "Tried to access region %u that has a null G1HeapRegion*", i); bool res = blk->do_heap_region(at(i)); if (res) { - blk->set_incomplete(); return; } } @@ -527,7 +525,6 @@ void G1HeapRegionManager::iterate(G1HeapRegionIndexClosure* blk) const { } bool res = blk->do_heap_region_index(i); if (res) { - blk->set_incomplete(); return; } } diff --git a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp index 4dd0a509bcd..1b9704e8ad3 100644 --- a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -366,6 +366,12 @@ static size_t target_heap_capacity(size_t used_bytes, uintx free_ratio) { } size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand, size_t allocation_word_size) { + // User-requested Full GCs introduce GC load unrelated to heap size; reset CPU + // usage tracking so heap resizing heuristics are driven only by GC pressure. + if (GCCause::is_user_requested_gc(_g1h->gc_cause())) { + reset_cpu_usage_tracking_data(); + } + const size_t capacity_after_gc = _g1h->capacity(); // Capacity, free and used after the GC counted as full regions to // include the waste in the following calculations. diff --git a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp index a2a9bc8e857..dd7a8aa117d 100644 --- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp +++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -236,7 +236,7 @@ private: VerifyOption _vo; bool _failures; - bool is_in_full_gc() const { return G1CollectedHeap::heap()->collector_state()->in_full_gc(); } + bool is_in_full_gc() const { return G1CollectedHeap::heap()->collector_state()->is_in_full_gc(); } public: VerifyRegionClosure(VerifyOption vo) @@ -349,7 +349,7 @@ void G1HeapVerifier::verify(VerifyOption vo) { bool failures = rootsCl.failures() || codeRootsCl.failures(); - if (!_g1h->policy()->collector_state()->in_full_gc()) { + if (!_g1h->policy()->collector_state()->is_in_full_gc()) { // If we're verifying during a full GC then the region sets // will have been torn down at the start of the GC. Therefore // verifying the region sets will fail. So we only verify @@ -494,7 +494,7 @@ public: }; void G1HeapVerifier::verify_marking_state() { - assert(G1CollectedHeap::heap()->collector_state()->in_concurrent_start_gc(), "must be"); + assert(G1CollectedHeap::heap()->collector_state()->is_in_concurrent_start_gc(), "must be"); // Verify TAMSes, bitmaps and liveness statistics. // diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp index 75a8ef1a336..cb857dc6eab 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp @@ -741,7 +741,7 @@ void G1ParScanThreadStateSet::print_partial_array_task_stats() { return state_for_worker(i)->partial_array_task_stats(); }; PartialArrayTaskStats::log_set(_num_workers, get_stats, - "Partial Array Task Stats"); + "Young GC Partial Array"); } #endif // TASKQUEUE_STATS diff --git a/src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp b/src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp index f280d76f3c7..ee11bbd961f 100644 --- a/src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp +++ b/src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -38,8 +38,8 @@ bool G1PeriodicGCTask::should_start_periodic_gc(G1CollectedHeap* g1h, // Ensure no GC safepoints while we're doing the checks, to avoid data races. SuspendibleThreadSetJoiner sts; - // If we are currently in a concurrent mark we are going to uncommit memory soon. - if (g1h->concurrent_mark()->in_progress()) { + // If we are currently in a concurrent cycle we are going to uncommit memory soon. + if (g1h->collector_state()->is_in_concurrent_cycle()) { log_debug(gc, periodic)("Concurrent cycle in progress. Skipping."); return false; } diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index 98e6acc1d77..05caff1257a 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -28,7 +28,6 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectionSetCandidates.inline.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" @@ -177,7 +176,7 @@ uint G1Policy::calculate_desired_eden_length_by_mmu() const { void G1Policy::update_young_length_bounds() { assert(!Universe::is_fully_initialized() || SafepointSynchronize::is_at_safepoint(), "must be"); - bool for_young_only_phase = collector_state()->in_young_only_phase(); + bool for_young_only_phase = collector_state()->is_in_young_only_phase(); update_young_length_bounds(_analytics->predict_pending_cards(for_young_only_phase), _analytics->predict_card_rs_length(for_young_only_phase), _analytics->predict_code_root_rs_length(for_young_only_phase)); @@ -505,7 +504,7 @@ uint G1Policy::calculate_desired_eden_length_before_mixed(double base_time_ms, double G1Policy::predict_survivor_regions_evac_time() const { double survivor_regions_evac_time = predict_young_region_other_time_ms(_g1h->survivor()->length()); for (G1HeapRegion* r : _g1h->survivor()->regions()) { - survivor_regions_evac_time += predict_region_copy_time_ms(r, _g1h->collector_state()->in_young_only_phase()); + survivor_regions_evac_time += predict_region_copy_time_ms(r, _g1h->collector_state()->is_in_young_only_phase()); } return survivor_regions_evac_time; @@ -561,8 +560,7 @@ void G1Policy::revise_young_list_target_length(size_t pending_cards, size_t card void G1Policy::record_full_collection_start() { record_pause_start_time(); // Release the future to-space so that it is available for compaction into. - collector_state()->set_in_young_only_phase(false); - collector_state()->set_in_full_gc(true); + collector_state()->set_in_full_gc(); _collection_set->abandon_all_candidates(); } @@ -571,17 +569,10 @@ void G1Policy::record_full_collection_end(size_t allocation_word_size) { // since last pause. double end_sec = os::elapsedTime(); - collector_state()->set_in_full_gc(false); - // "Nuke" the heuristics that control the young/mixed GC // transitions and make sure we start with young GCs after the Full GC. - collector_state()->set_in_young_only_phase(true); - collector_state()->set_in_young_gc_before_mixed(false); + collector_state()->set_in_normal_young_gc(); collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", allocation_word_size)); - collector_state()->set_in_concurrent_start_gc(false); - collector_state()->set_mark_in_progress(false); - collector_state()->set_mark_or_rebuild_in_progress(false); - collector_state()->set_clear_bitmap_in_progress(false); _eden_surv_rate_group->start_adding_regions(); // also call this on any additional surv rate groups @@ -593,7 +584,7 @@ void G1Policy::record_full_collection_end(size_t allocation_word_size) { _old_gen_alloc_tracker.reset_after_gc(_g1h->humongous_regions_count() * G1HeapRegion::GrainBytes); double start_time_sec = cur_pause_start_sec(); - record_pause(G1GCPauseType::FullGC, start_time_sec, end_sec); + record_pause(Pause::Full, start_time_sec, end_sec); } static void log_refinement_stats(const G1ConcurrentRefineStats& stats) { @@ -700,7 +691,7 @@ void G1Policy::record_young_collection_start() { void G1Policy::record_concurrent_mark_init_end() { assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now"); - collector_state()->set_in_concurrent_start_gc(false); + collector_state()->set_in_normal_young_gc(); } void G1Policy::record_concurrent_mark_remark_end() { @@ -708,8 +699,7 @@ void G1Policy::record_concurrent_mark_remark_end() { double start_time_sec = cur_pause_start_sec(); double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0; _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); - record_pause(G1GCPauseType::Remark, start_time_sec, end_time_sec); - collector_state()->set_mark_in_progress(false); + record_pause(Pause::Remark, start_time_sec, end_time_sec); } G1CollectionSetCandidates* G1Policy::candidates() const { @@ -739,7 +729,7 @@ double G1Policy::constant_other_time_ms(double pause_time_ms) const { } bool G1Policy::about_to_start_mixed_phase() const { - return _g1h->concurrent_mark()->in_progress() || collector_state()->in_young_gc_before_mixed(); + return collector_state()->is_in_concurrent_cycle() || collector_state()->is_in_prepare_mixed_gc(); } bool G1Policy::need_to_start_conc_mark(const char* source, size_t allocation_word_size) { @@ -752,7 +742,7 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t allocation_wor bool result = false; if (non_young_occupancy > marking_initiating_used_threshold) { - result = collector_state()->in_young_only_phase(); + result = collector_state()->is_in_young_only_phase(); log_debug(gc, ergo, ihop)("%s non-young occupancy: %zuB allocation request: %zuB threshold: %zuB (%1.2f) source: %s", result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)", non_young_occupancy, allocation_word_size * HeapWordSize, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1h->capacity() * 100, source); @@ -761,7 +751,7 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t allocation_wor } bool G1Policy::concurrent_operation_is_full_mark(const char* msg, size_t allocation_word_size) { - return collector_state()->in_concurrent_start_gc() && + return collector_state()->is_in_concurrent_start_gc() && ((_g1h->gc_cause() != GCCause::_g1_humongous_allocation) || need_to_start_conc_mark(msg, allocation_word_size)); } @@ -800,10 +790,10 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar double end_time_sec = Ticks::now().seconds(); double pause_time_ms = (end_time_sec - start_time_sec) * 1000.0; - G1GCPauseType this_pause = collector_state()->young_gc_pause_type(concurrent_operation_is_full_mark); - bool is_young_only_pause = G1GCPauseTypeHelper::is_young_only_pause(this_pause); + Pause this_pause = collector_state()->gc_pause_type(concurrent_operation_is_full_mark); + bool is_young_only_pause = G1CollectorState::is_young_only_pause(this_pause); - if (G1GCPauseTypeHelper::is_concurrent_start_pause(this_pause)) { + if (G1CollectorState::is_concurrent_start_pause(this_pause)) { record_concurrent_mark_init_end(); } else { maybe_start_marking(allocation_word_size); @@ -945,20 +935,19 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar record_pause(this_pause, start_time_sec, end_time_sec); - if (G1GCPauseTypeHelper::is_last_young_pause(this_pause)) { - assert(!G1GCPauseTypeHelper::is_concurrent_start_pause(this_pause), + if (G1CollectorState::is_prepare_mixed_pause(this_pause)) { + assert(!G1CollectorState::is_concurrent_start_pause(this_pause), "The young GC before mixed is not allowed to be concurrent start GC"); // This has been the young GC before we start doing mixed GCs. We already // decided to start mixed GCs much earlier, so there is nothing to do except // advancing the state. - collector_state()->set_in_young_only_phase(false); - collector_state()->set_in_young_gc_before_mixed(false); - } else if (G1GCPauseTypeHelper::is_mixed_pause(this_pause)) { + collector_state()->set_in_space_reclamation_phase(); + } else if (G1CollectorState::is_mixed_pause(this_pause)) { // This is a mixed GC. Here we decide whether to continue doing more // mixed GCs or not. if (!next_gc_should_be_mixed()) { log_debug(gc, ergo)("do not continue mixed GCs (candidate old regions not available)"); - collector_state()->set_in_young_only_phase(true); + collector_state()->set_in_normal_young_gc(); assert(!candidates()->has_more_marking_candidates(), "only end mixed if all candidates from marking were processed"); @@ -971,12 +960,8 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar _eden_surv_rate_group->start_adding_regions(); - assert(!(G1GCPauseTypeHelper::is_concurrent_start_pause(this_pause) && collector_state()->mark_or_rebuild_in_progress()), - "If the last pause has been concurrent start, we should not have been in the marking window"); - if (G1GCPauseTypeHelper::is_concurrent_start_pause(this_pause)) { - collector_state()->set_mark_in_progress(concurrent_operation_is_full_mark); - collector_state()->set_mark_or_rebuild_in_progress(concurrent_operation_is_full_mark); - } + assert(!(G1CollectorState::is_concurrent_start_pause(this_pause) && collector_state()->is_in_concurrent_cycle()), + "If the last pause has been concurrent start, we should not have been in the marking cycle"); _free_regions_at_end_of_collection = _g1h->num_free_regions(); @@ -987,7 +972,7 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar _old_gen_alloc_tracker.reset_after_gc(_g1h->humongous_regions_count() * G1HeapRegion::GrainBytes); if (update_ihop_prediction(app_time_ms / 1000.0, - G1GCPauseTypeHelper::is_young_only_pause(this_pause))) { + G1CollectorState::is_young_only_pause(this_pause))) { _ihop_control->report_statistics(_g1h->gc_tracer_stw(), _g1h->non_young_occupancy_after_allocation(allocation_word_size)); } } else { @@ -1081,7 +1066,7 @@ void G1Policy::record_young_gc_pause_end(bool evacuation_failed) { double G1Policy::predict_base_time_ms(size_t pending_cards, size_t card_rs_length, size_t code_root_rs_length) const { - bool in_young_only_phase = collector_state()->in_young_only_phase(); + bool in_young_only_phase = collector_state()->is_in_young_only_phase(); // Cards from the refinement table and the cards from the young gen remset are // unique to each other as they are located on the card table. @@ -1105,7 +1090,7 @@ double G1Policy::predict_base_time_ms(size_t pending_cards, } double G1Policy::predict_base_time_ms(size_t pending_cards, size_t card_rs_length) const { - bool for_young_only_phase = collector_state()->in_young_only_phase(); + bool for_young_only_phase = collector_state()->is_in_young_only_phase(); size_t code_root_rs_length = _analytics->predict_code_root_rs_length(for_young_only_phase); return predict_base_time_ms(pending_cards, card_rs_length, code_root_rs_length); } @@ -1145,7 +1130,7 @@ double G1Policy::predict_eden_copy_time_ms(uint count, size_t* bytes_to_copy) co if (bytes_to_copy != nullptr) { *bytes_to_copy = expected_bytes; } - return _analytics->predict_object_copy_time_ms(expected_bytes, collector_state()->in_young_only_phase()); + return _analytics->predict_object_copy_time_ms(expected_bytes, collector_state()->is_in_young_only_phase()); } double G1Policy::predict_region_copy_time_ms(G1HeapRegion* hr, bool for_young_only_phase) const { @@ -1235,7 +1220,7 @@ bool G1Policy::force_concurrent_start_if_outside_cycle(GCCause::Cause gc_cause) // We actually check whether we are marking here and not if we are in a // reclamation phase. This means that we will schedule a concurrent mark // even while we are still in the process of reclaiming memory. - bool during_cycle = _g1h->concurrent_mark()->in_progress(); + bool during_cycle = collector_state()->is_in_concurrent_cycle(); if (!during_cycle) { log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). " "GC cause: %s", @@ -1251,8 +1236,7 @@ bool G1Policy::force_concurrent_start_if_outside_cycle(GCCause::Cause gc_cause) } void G1Policy::initiate_conc_mark() { - collector_state()->set_in_concurrent_start_gc(true); - collector_state()->set_initiate_conc_mark_if_possible(false); + collector_state()->set_in_concurrent_start_gc(); } static const char* requester_for_mixed_abort(GCCause::Cause cause) { @@ -1274,7 +1258,7 @@ void G1Policy::decide_on_concurrent_start_pause() { // will set it here if we have to. However, it should be cleared by // the end of the pause (it's only set for the duration of a // concurrent start pause). - assert(!collector_state()->in_concurrent_start_gc(), "pre-condition"); + assert(!collector_state()->is_in_concurrent_start_gc(), "pre-condition"); if (collector_state()->initiate_conc_mark_if_possible()) { // We had noticed on a previous pause that the heap occupancy has @@ -1287,7 +1271,7 @@ void G1Policy::decide_on_concurrent_start_pause() { if ((cause != GCCause::_wb_breakpoint) && ConcurrentGCBreakpoints::is_controlled()) { log_debug(gc, ergo)("Do not initiate concurrent cycle (whitebox controlled)"); - } else if (!about_to_start_mixed_phase() && collector_state()->in_young_only_phase()) { + } else if (!about_to_start_mixed_phase() && collector_state()->is_in_young_only_phase()) { // Initiate a new concurrent start if there is no marking or reclamation going on. initiate_conc_mark(); log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)"); @@ -1296,8 +1280,7 @@ void G1Policy::decide_on_concurrent_start_pause() { (cause == GCCause::_wb_breakpoint)) { // Initiate a concurrent start. A concurrent start must be a young only // GC, so the collector state must be updated to reflect this. - collector_state()->set_in_young_only_phase(true); - collector_state()->set_in_young_gc_before_mixed(false); + collector_state()->set_in_normal_young_gc(); // We might have ended up coming here about to start a mixed phase with a collection set // active. The following remark might change the change the "evacuation efficiency" of @@ -1326,10 +1309,10 @@ void G1Policy::decide_on_concurrent_start_pause() { } // Result consistency checks. // We do not allow concurrent start to be piggy-backed on a mixed GC. - assert(!collector_state()->in_concurrent_start_gc() || - collector_state()->in_young_only_phase(), "sanity"); - // We also do not allow mixed GCs during marking. - assert(!collector_state()->mark_or_rebuild_in_progress() || collector_state()->in_young_only_phase(), "sanity"); + assert(!collector_state()->is_in_concurrent_start_gc() || + collector_state()->is_in_young_only_phase(), "sanity"); + // We also do not allow mixed GCs during marking/rebuilding. + assert(!collector_state()->is_in_mark_or_rebuild() || collector_state()->is_in_young_only_phase(), "sanity %d %d", collector_state()->is_in_concurrent_cycle(), collector_state()->is_in_young_only_phase()); } void G1Policy::record_concurrent_mark_cleanup_end(bool has_rebuilt_remembered_sets) { @@ -1348,16 +1331,16 @@ void G1Policy::record_concurrent_mark_cleanup_end(bool has_rebuilt_remembered_se abort_time_to_mixed_tracking(); log_debug(gc, ergo)("request young-only gcs (candidate old regions not available)"); } - collector_state()->set_in_young_gc_before_mixed(mixed_gc_pending); - collector_state()->set_mark_or_rebuild_in_progress(false); - collector_state()->set_clear_bitmap_in_progress(true); + if (mixed_gc_pending) { + collector_state()->set_in_prepare_mixed_gc(); + } double end_sec = os::elapsedTime(); double start_sec = cur_pause_start_sec(); double elapsed_time_ms = (end_sec - start_sec) * 1000.0; _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms); - record_pause(G1GCPauseType::Cleanup, start_sec, end_sec); + record_pause(Pause::Cleanup, start_sec, end_sec); } void G1Policy::abandon_collection_set_candidates() { @@ -1373,25 +1356,25 @@ void G1Policy::maybe_start_marking(size_t allocation_word_size) { } } -void G1Policy::update_gc_pause_time_ratios(G1GCPauseType gc_type, double start_time_sec, double end_time_sec) { +void G1Policy::update_gc_pause_time_ratios(Pause gc_type, double start_time_sec, double end_time_sec) { double pause_time_sec = end_time_sec - start_time_sec; double pause_time_ms = pause_time_sec * 1000.0; _analytics->update_gc_time_ratios(end_time_sec, pause_time_ms); - if (gc_type == G1GCPauseType::Cleanup || gc_type == G1GCPauseType::Remark) { + if (G1CollectorState::is_concurrent_cycle_pause(gc_type)) { _analytics->append_prev_collection_pause_end_ms(pause_time_ms); } else { _analytics->set_prev_collection_pause_end_ms(end_time_sec * 1000.0); } } -void G1Policy::record_pause(G1GCPauseType gc_type, +void G1Policy::record_pause(Pause gc_type, double start, double end) { // Manage the MMU tracker. For some reason it ignores Full GCs. - if (gc_type != G1GCPauseType::FullGC) { + if (gc_type != Pause::Full) { _mmu_tracker->add_pause(start, end); } @@ -1403,21 +1386,21 @@ void G1Policy::record_pause(G1GCPauseType gc_type, _analytics->set_gc_cpu_time_at_pause_end_ms(elapsed_gc_cpu_time); } -void G1Policy::update_time_to_mixed_tracking(G1GCPauseType gc_type, +void G1Policy::update_time_to_mixed_tracking(Pause gc_type, double start, double end) { // Manage the mutator time tracking from concurrent start to first mixed gc. switch (gc_type) { - case G1GCPauseType::FullGC: + case Pause::Full: abort_time_to_mixed_tracking(); break; - case G1GCPauseType::Cleanup: - case G1GCPauseType::Remark: - case G1GCPauseType::YoungGC: - case G1GCPauseType::LastYoungGC: + case Pause::Cleanup: + case Pause::Remark: + case Pause::Normal: + case Pause::PrepareMixed: _concurrent_start_to_mixed.add_pause(end - start); break; - case G1GCPauseType::ConcurrentStartMarkGC: + case Pause::ConcurrentStartFull: // Do not track time-to-mixed time for periodic collections as they are likely // to be not representative to regular operation as the mutators are idle at // that time. Also only track full concurrent mark cycles. @@ -1425,12 +1408,12 @@ void G1Policy::update_time_to_mixed_tracking(G1GCPauseType gc_type, _concurrent_start_to_mixed.record_concurrent_start_end(end); } break; - case G1GCPauseType::ConcurrentStartUndoGC: + case Pause::ConcurrentStartUndo: assert(_g1h->gc_cause() == GCCause::_g1_humongous_allocation, "GC cause must be humongous allocation but is %d", _g1h->gc_cause()); break; - case G1GCPauseType::MixedGC: + case Pause::Mixed: _concurrent_start_to_mixed.record_mixed_gc_start(start); break; default: diff --git a/src/hotspot/share/gc/g1/g1Policy.hpp b/src/hotspot/share/gc/g1/g1Policy.hpp index 9513c79869e..585e26441d5 100644 --- a/src/hotspot/share/gc/g1/g1Policy.hpp +++ b/src/hotspot/share/gc/g1/g1Policy.hpp @@ -56,7 +56,7 @@ class GCPolicyCounters; class STWGCTimer; class G1Policy: public CHeapObj { - private: + using Pause = G1CollectorState::Pause; static G1IHOPControl* create_ihop_control(const G1OldGenAllocationTracker* old_gen_alloc_tracker, const G1Predictions* predictor); @@ -115,7 +115,7 @@ class G1Policy: public CHeapObj { G1ConcurrentStartToMixedTimeTracker _concurrent_start_to_mixed; bool should_update_surv_rate_group_predictors() { - return collector_state()->in_young_only_phase() && !collector_state()->mark_or_rebuild_in_progress(); + return collector_state()->is_in_young_only_phase() && !collector_state()->is_in_mark_or_rebuild(); } double pending_cards_processing_time() const; @@ -268,13 +268,13 @@ private: // Sets up marking if proper conditions are met. void maybe_start_marking(size_t allocation_word_size); // Manage time-to-mixed tracking. - void update_time_to_mixed_tracking(G1GCPauseType gc_type, double start, double end); + void update_time_to_mixed_tracking(Pause gc_type, double start, double end); // Record the given STW pause with the given start and end times (in s). - void record_pause(G1GCPauseType gc_type, + void record_pause(Pause gc_type, double start, double end); - void update_gc_pause_time_ratios(G1GCPauseType gc_type, double start_sec, double end_sec); + void update_gc_pause_time_ratios(Pause gc_type, double start_sec, double end_sec); // Indicate that we aborted marking before doing any mixed GCs. void abort_time_to_mixed_tracking(); diff --git a/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp b/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp index 4dcdd33846e..df76147f4b1 100644 --- a/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp +++ b/src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp @@ -95,7 +95,7 @@ private: // Evict a given element of the statistics cache. void evict(uint idx); - size_t _num_cache_entries_mask; + const uint _num_cache_entries_mask; uint hash(uint idx) { return idx & _num_cache_entries_mask; diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index 0c9a0fad8f2..4b4a8a68c30 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -1026,7 +1026,7 @@ class G1MergeHeapRootsTask : public WorkerTask { // the pause occurs during the Concurrent Cleanup for Next Mark phase. // Only at that point the region's bitmap may contain marks while being in the collection // set at the same time. - return _g1h->collector_state()->clear_bitmap_in_progress() && + return _g1h->collector_state()->is_in_reset_for_next_cycle() && hr->is_old(); } diff --git a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp index 0c9973c520d..94f5466b8e0 100644 --- a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,12 +23,16 @@ */ #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionRemSet.inline.hpp" #include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "runtime/safepoint.hpp" +static bool region_occupancy_low_enough_for_evac(size_t live_bytes) { + size_t mixed_gc_live_threshold_bytes = G1HeapRegion::GrainBytes * (size_t)G1MixedGCLiveThresholdPercent / 100; + return live_bytes < mixed_gc_live_threshold_bytes; +} + void G1RemSetTrackingPolicy::update_at_allocate(G1HeapRegion* r) { assert(r->is_young() || r->is_humongous() || r->is_old(), "Region %u with unexpected heap region type %s", r->hrm_index(), r->get_type_str()); @@ -75,7 +79,8 @@ bool G1RemSetTrackingPolicy::update_old_before_rebuild(G1HeapRegion* r) { bool selected_for_rebuild = false; - if (G1CollectionSetChooser::region_occupancy_low_enough_for_evac(r->live_bytes()) && + if (region_occupancy_low_enough_for_evac(r->live_bytes()) && + !G1CollectedHeap::heap()->is_old_gc_alloc_region(r) && !r->rem_set()->is_tracked()) { r->rem_set()->set_state_updating(); selected_for_rebuild = true; diff --git a/src/hotspot/share/gc/g1/g1RootClosures.cpp b/src/hotspot/share/gc/g1/g1RootClosures.cpp index f03681487cb..2d5150c27aa 100644 --- a/src/hotspot/share/gc/g1/g1RootClosures.cpp +++ b/src/hotspot/share/gc/g1/g1RootClosures.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1Colle G1ParScanThreadState* pss, bool process_only_dirty_klasses) { G1EvacuationRootClosures* res = nullptr; - if (g1h->collector_state()->in_concurrent_start_gc()) { + if (g1h->collector_state()->is_in_concurrent_start_gc()) { if (ClassUnloadingWithConcurrentMark) { res = new G1ConcurrentStartMarkClosures(g1h, pss); } else { diff --git a/src/hotspot/share/gc/g1/g1Trace.cpp b/src/hotspot/share/gc/g1/g1Trace.cpp index ed6a91f41ed..242a97ca4e3 100644 --- a/src/hotspot/share/gc/g1/g1Trace.cpp +++ b/src/hotspot/share/gc/g1/g1Trace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +23,6 @@ */ #include "gc/g1/g1EvacInfo.hpp" -#include "gc/g1/g1GCPauseType.hpp" #include "gc/g1/g1HeapRegionTraceType.hpp" #include "gc/g1/g1Trace.hpp" #include "gc/shared/gcHeapSummary.hpp" @@ -48,12 +47,12 @@ public: class G1YCTypeConstant : public JfrSerializer { public: void serialize(JfrCheckpointWriter& writer) { - constexpr EnumRange types{}; + constexpr EnumRange types{}; static const u4 nof_entries = static_cast(types.size()); writer.write_count(nof_entries); for (auto index : types) { writer.write_key(static_cast(index)); - writer.write(G1GCPauseTypeHelper::to_string(index)); + writer.write(G1CollectorState::to_string(index)); } } }; @@ -72,8 +71,8 @@ void G1NewTracer::initialize() { JFR_ONLY(register_jfr_type_constants();) } -void G1NewTracer::report_young_gc_pause(G1GCPauseType pause) { - G1GCPauseTypeHelper::assert_is_young_pause(pause); +void G1NewTracer::report_young_gc_pause(G1CollectorState::Pause pause) { + G1CollectorState::assert_is_young_pause(pause); _pause = pause; } @@ -128,7 +127,7 @@ void G1NewTracer::report_adaptive_ihop_statistics(size_t threshold, void G1NewTracer::send_g1_young_gc_event() { // Check that the pause type has been updated to something valid for this event. - G1GCPauseTypeHelper::assert_is_young_pause(_pause); + G1CollectorState::assert_is_young_pause(_pause); EventG1GarbageCollection e(UNTIMED); if (e.should_commit()) { diff --git a/src/hotspot/share/gc/g1/g1Trace.hpp b/src/hotspot/share/gc/g1/g1Trace.hpp index a2e11ed4496..bfcc275d2ca 100644 --- a/src/hotspot/share/gc/g1/g1Trace.hpp +++ b/src/hotspot/share/gc/g1/g1Trace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +25,7 @@ #ifndef SHARE_GC_G1_G1TRACE_HPP #define SHARE_GC_G1_G1TRACE_HPP -#include "gc/g1/g1GCPauseType.hpp" +#include "gc/g1/g1CollectorState.hpp" #include "gc/shared/gcTrace.hpp" class G1EvacInfo; @@ -33,17 +33,17 @@ class G1HeapSummary; class G1EvacSummary; class G1NewTracer : public YoungGCTracer, public CHeapObj { - G1GCPauseType _pause; + G1CollectorState::Pause _pause; public: G1NewTracer() : YoungGCTracer(G1New), - _pause(G1GCPauseType::FullGC) // Initialize to something invalid. For this event, which + _pause(G1CollectorState::Pause::Full) // Initialize to something invalid. For this event, which // is about young collections, FullGC is not a valid value. { } void initialize(); - void report_young_gc_pause(G1GCPauseType pause); + void report_young_gc_pause(G1CollectorState::Pause pause); void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); void report_evacuation_info(G1EvacInfo* info); void report_evacuation_failed(EvacuationFailedInfo& ef_info); diff --git a/src/hotspot/share/gc/g1/g1VMOperations.cpp b/src/hotspot/share/gc/g1/g1VMOperations.cpp index 56ab3a4b0fe..f98f0b078f3 100644 --- a/src/hotspot/share/gc/g1/g1VMOperations.cpp +++ b/src/hotspot/share/gc/g1/g1VMOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -84,8 +84,9 @@ void VM_G1TryInitiateConcMark::doit() { GCCauseSetter x(g1h, _gc_cause); - _mark_in_progress = g1h->collector_state()->mark_in_progress(); - _cycle_already_in_progress = g1h->concurrent_mark()->in_progress(); + G1CollectorState* state = g1h->collector_state(); + _mark_in_progress = state->is_in_marking(); + _cycle_already_in_progress = state->is_in_concurrent_cycle(); if (!g1h->policy()->force_concurrent_start_if_outside_cycle(_gc_cause)) { // Failure to force the next GC pause to be a concurrent start indicates @@ -166,11 +167,11 @@ void VM_G1PauseConcurrent::doit_epilogue() { } void VM_G1PauseRemark::work() { - G1CollectedHeap* g1h = G1CollectedHeap::heap(); - g1h->concurrent_mark()->remark(); + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + cm->remark(); } void VM_G1PauseCleanup::work() { - G1CollectedHeap* g1h = G1CollectedHeap::heap(); - g1h->concurrent_mark()->cleanup(); + G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); + cm->cleanup(); } diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.cpp b/src/hotspot/share/gc/g1/g1YoungCollector.cpp index a9db9a7c269..04ccac5ff05 100644 --- a/src/hotspot/share/gc/g1/g1YoungCollector.cpp +++ b/src/hotspot/share/gc/g1/g1YoungCollector.cpp @@ -70,7 +70,7 @@ class G1YoungGCTraceTime { G1YoungCollector* _collector; - G1GCPauseType _pause_type; + G1CollectorState::Pause _pause_type; GCCause::Cause _pause_cause; static const uint MaxYoungGCNameLength = 128; @@ -93,7 +93,7 @@ class G1YoungGCTraceTime { os::snprintf_checked(_young_gc_name_data, MaxYoungGCNameLength, "Pause Young (%s) (%s)%s", - G1GCPauseTypeHelper::to_string(_pause_type), + G1CollectorState::to_string(_pause_type), GCCause::to_string(_pause_cause), evacuation_failed_string); return _young_gc_name_data; @@ -105,7 +105,7 @@ public: // Take snapshot of current pause type at start as it may be modified during gc. // The strings for all Concurrent Start pauses are the same, so the parameter // does not matter here. - _pause_type(_collector->collector_state()->young_gc_pause_type(false /* concurrent_operation_is_full_mark */)), + _pause_type(_collector->collector_state()->gc_pause_type(false /* concurrent_operation_is_full_mark */)), _pause_cause(cause), // Fake a "no cause" and manually add the correct string in update_young_gc_name() // to make the string look more natural. @@ -142,7 +142,7 @@ public: G1YoungGCJFRTracerMark(STWGCTimer* gc_timer_stw, G1NewTracer* gc_tracer_stw, GCCause::Cause cause) : G1JFRTracerMark(gc_timer_stw, gc_tracer_stw), _evacuation_info() { } - void report_pause_type(G1GCPauseType type) { + void report_pause_type(G1CollectorState::Pause type) { tracer()->report_young_gc_pause(type); } @@ -160,9 +160,9 @@ class G1YoungGCVerifierMark : public StackObj { static G1HeapVerifier::G1VerifyType young_collection_verify_type() { G1CollectorState* state = G1CollectedHeap::heap()->collector_state(); - if (state->in_concurrent_start_gc()) { + if (state->is_in_concurrent_start_gc()) { return G1HeapVerifier::G1VerifyConcurrentStart; - } else if (state->in_young_only_phase()) { + } else if (state->is_in_young_only_phase()) { return G1HeapVerifier::G1VerifyYoungNormal; } else { return G1HeapVerifier::G1VerifyMixed; @@ -391,7 +391,7 @@ class G1PrepareEvacuationTask : public WorkerTask { if (!obj->is_typeArray()) { // All regions that were allocated before marking have a TAMS != bottom. bool allocated_before_mark_start = region->bottom() != _g1h->concurrent_mark()->top_at_mark_start(region); - bool mark_in_progress = _g1h->collector_state()->mark_in_progress(); + bool mark_in_progress = _g1h->collector_state()->is_in_marking(); if (allocated_before_mark_start && mark_in_progress) { return false; @@ -530,7 +530,7 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info) // Needs log buffers flushed. calculate_collection_set(evacuation_info, policy()->max_pause_time_ms()); - if (collector_state()->in_concurrent_start_gc()) { + if (collector_state()->is_in_concurrent_start_gc()) { Ticks start = Ticks::now(); concurrent_mark()->pre_concurrent_start(_gc_cause); phase_times()->record_prepare_concurrent_task_time_ms((Ticks::now() - start).seconds() * 1000.0); @@ -896,17 +896,10 @@ public: assert(obj != nullptr, "the caller should have filtered out null values"); const G1HeapRegionAttr region_attr =_g1h->region_attr(obj); - if (!region_attr.is_in_cset_or_humongous_candidate()) { - return; - } + assert(!region_attr.is_humongous_candidate(), "Humongous candidates should never be considered alive"); if (region_attr.is_in_cset()) { assert(obj->is_forwarded(), "invariant" ); *p = obj->forwardee(); - } else { - assert(!obj->is_forwarded(), "invariant" ); - assert(region_attr.is_humongous_candidate(), - "Only allowed G1HeapRegionAttr state is IsHumongous, but is %d", region_attr.type()); - _g1h->set_humongous_is_live(obj); } } }; @@ -932,7 +925,8 @@ public: template void do_oop_work(T* p) { oop obj = RawAccess<>::oop_load(p); - if (_g1h->is_in_cset_or_humongous_candidate(obj)) { + assert(!_g1h->region_attr(obj).is_humongous_candidate(), "Humongous candidates should never be considered alive"); + if (_g1h->is_in_cset(obj)) { // If the referent object has been forwarded (either copied // to a new location or to itself in the event of an // evacuation failure) then we need to update the reference @@ -1043,7 +1037,7 @@ void G1YoungCollector::post_evacuate_cleanup_2(G1ParScanThreadStateSet* per_thre } void G1YoungCollector::enqueue_candidates_as_root_regions() { - assert(collector_state()->in_concurrent_start_gc(), "must be"); + assert(collector_state()->is_in_concurrent_start_gc(), "must be"); G1CollectionSetCandidates* candidates = collection_set()->candidates(); candidates->iterate_regions([&] (G1HeapRegion* r) { @@ -1070,6 +1064,7 @@ void G1YoungCollector::post_evacuate_collection_set(G1EvacInfo* evacuation_info, allocator()->release_gc_alloc_regions(evacuation_info); #if TASKQUEUE_STATS + _g1h->task_queues()->print_and_reset_taskqueue_stats("Young GC"); // Logging uses thread states, which are deleted by cleanup, so this must // be done before cleanup. per_thread_states->print_partial_array_task_stats(); @@ -1082,7 +1077,7 @@ void G1YoungCollector::post_evacuate_collection_set(G1EvacInfo* evacuation_info, // Regions in the collection set candidates are roots for the marking (they are // not marked through considering they are very likely to be reclaimed soon. // They need to be enqueued explicitly compared to survivor regions. - if (collector_state()->in_concurrent_start_gc()) { + if (collector_state()->is_in_concurrent_start_gc()) { enqueue_candidates_as_root_regions(); } @@ -1185,9 +1180,8 @@ void G1YoungCollector::collect() { // Need to report the collection pause now since record_collection_pause_end() // modifies it to the next state. - jtm.report_pause_type(collector_state()->young_gc_pause_type(_concurrent_operation_is_full_mark)); + jtm.report_pause_type(collector_state()->gc_pause_type(_concurrent_operation_is_full_mark)); policy()->record_young_collection_end(_concurrent_operation_is_full_mark, evacuation_alloc_failed(), _allocation_word_size); } - TASKQUEUE_STATS_ONLY(_g1h->task_queues()->print_and_reset_taskqueue_stats("Oop Queue");) } diff --git a/src/hotspot/share/gc/g1/g1YoungGCAllocationFailureInjector.cpp b/src/hotspot/share/gc/g1/g1YoungGCAllocationFailureInjector.cpp index 75cff2b339b..2291a755cd3 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCAllocationFailureInjector.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCAllocationFailureInjector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,9 +61,9 @@ void G1YoungGCAllocationFailureInjector::select_allocation_failure_regions() { bool G1YoungGCAllocationFailureInjector::arm_if_needed_for_gc_type(bool for_young_only_phase, bool during_concurrent_start, - bool mark_or_rebuild_in_progress) { + bool in_concurrent_cycle) { bool res = false; - if (mark_or_rebuild_in_progress) { + if (in_concurrent_cycle) { res |= G1GCAllocationFailureALotDuringConcMark; } if (during_concurrent_start) { @@ -89,14 +89,14 @@ void G1YoungGCAllocationFailureInjector::arm_if_needed() { // Now check if evacuation failure injection should be enabled for the current GC. G1CollectorState* collector_state = g1h->collector_state(); - const bool in_young_only_phase = collector_state->in_young_only_phase(); - const bool in_concurrent_start_gc = collector_state->in_concurrent_start_gc(); - const bool mark_or_rebuild_in_progress = collector_state->mark_or_rebuild_in_progress(); + const bool in_young_only_phase = collector_state->is_in_young_only_phase(); + const bool in_concurrent_start_gc = collector_state->is_in_concurrent_start_gc(); + const bool in_concurrent_cycle = collector_state->is_in_concurrent_cycle(); _inject_allocation_failure_for_current_gc &= arm_if_needed_for_gc_type(in_young_only_phase, in_concurrent_start_gc, - mark_or_rebuild_in_progress); + in_concurrent_cycle); if (_inject_allocation_failure_for_current_gc) { select_allocation_failure_regions(); diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp index 3f47d386015..3d49b8f025b 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp @@ -24,6 +24,7 @@ #include "compiler/oopMap.hpp" +#include "cppstdlib/new.hpp" #include "gc/g1/g1CardSetMemory.hpp" #include "gc/g1/g1CardTableEntryClosure.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" @@ -394,7 +395,7 @@ public: { ResourceMark rm; bool allocated_after_mark_start = r->bottom() == _g1h->concurrent_mark()->top_at_mark_start(r); - bool mark_in_progress = _g1h->collector_state()->mark_in_progress(); + bool mark_in_progress = _g1h->collector_state()->is_in_marking(); guarantee(obj->is_typeArray() || (allocated_after_mark_start || !mark_in_progress), "Only eagerly reclaiming primitive arrays is supported, other humongous objects only if allocated after mark start, but the object " PTR_FORMAT " (%s) is not (mark %d allocated after mark: %d).", @@ -497,14 +498,10 @@ class G1PostEvacuateCollectionSetCleanupTask2::ProcessEvacuationFailedRegionsTas G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1ConcurrentMark* cm = g1h->concurrent_mark(); - HeapWord* top_at_mark_start = cm->top_at_mark_start(r); - assert(top_at_mark_start == r->bottom(), "TAMS must not have been set for region %u", r->hrm_index()); - assert(cm->live_bytes(r->hrm_index()) == 0, "Marking live bytes must not be set for region %u", r->hrm_index()); - // Concurrent mark does not mark through regions that we retain (they are root // regions wrt to marking), so we must clear their mark data (tams, bitmap, ...) // set eagerly or during evacuation failure. - bool clear_mark_data = !g1h->collector_state()->in_concurrent_start_gc() || + bool clear_mark_data = !g1h->collector_state()->is_in_concurrent_start_gc() || g1h->policy()->should_retain_evac_failed_region(r); if (clear_mark_data) { @@ -818,9 +815,7 @@ public: void set_max_workers(uint max_workers) override { _active_workers = max_workers; _worker_stats = NEW_C_HEAP_ARRAY(FreeCSetStats, max_workers, mtGC); - for (uint worker = 0; worker < _active_workers; worker++) { - ::new (&_worker_stats[worker]) FreeCSetStats(); - } + ::new (_worker_stats) FreeCSetStats[_active_workers]{}; _claimer.set_n_workers(_active_workers); } diff --git a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp index c0870b7a726..936457659b6 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,7 @@ * */ +#include "cppstdlib/new.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1ThreadLocalData.hpp" @@ -89,10 +90,7 @@ public: void set_max_workers(uint max_workers) override { _num_workers = max_workers; _local_tlab_stats = NEW_C_HEAP_ARRAY(ThreadLocalAllocStats, _num_workers, mtGC); - - for (uint i = 0; i < _num_workers; i++) { - ::new (&_local_tlab_stats[i]) ThreadLocalAllocStats(); - } + ::new (_local_tlab_stats) ThreadLocalAllocStats[_num_workers]{}; } ThreadLocalAllocStats tlab_stats() const { diff --git a/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp b/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp index 4b8bca430f8..36de38c34bb 100644 --- a/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp +++ b/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_PARALLEL_MUTABLENUMASPACE_HPP #include "gc/parallel/mutableSpace.hpp" +#include "gc/shared/gc_globals.hpp" #include "gc/shared/gcUtil.hpp" #include "runtime/globals.hpp" #include "utilities/growableArray.hpp" diff --git a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp index c613c8615f0..bbd6669df8d 100644 --- a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp +++ b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +28,6 @@ #include "memory/memoryReserver.hpp" #include "nmt/memTracker.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" #include "utilities/bitMap.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/parallelArguments.cpp b/src/hotspot/share/gc/parallel/parallelArguments.cpp index be9673224f5..a856078edab 100644 --- a/src/hotspot/share/gc/parallel/parallelArguments.cpp +++ b/src/hotspot/share/gc/parallel/parallelArguments.cpp @@ -128,10 +128,6 @@ void ParallelArguments::initialize() { } } - if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) { - FLAG_SET_DEFAULT(ParallelRefProcEnabled, true); - } - FullGCForwarding::initialize_flags(heap_reserved_size_bytes()); } diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp index f49419595e1..b77294a2ac1 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp @@ -272,7 +272,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate(size_t size) { HeapWord* ParallelScavengeHeap::mem_allocate_cas_noexpand(size_t size, bool is_tlab) { // Try young-gen first. - HeapWord* result = young_gen()->allocate(size); + HeapWord* result = young_gen()->cas_allocate(size); if (result != nullptr) { return result; } @@ -932,7 +932,7 @@ void ParallelScavengeHeap::resize_after_full_gc() { } HeapWord* ParallelScavengeHeap::allocate_loaded_archive_space(size_t size) { - return _old_gen->allocate(size); + return _old_gen->cas_allocate_with_expansion(size); } void ParallelScavengeHeap::complete_loaded_archive_space(MemRegion archive_space) { diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp index f257f4c9177..0f00b3ec2f9 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp @@ -30,8 +30,11 @@ #include "gc/parallel/psScavenge.hpp" inline bool ParallelScavengeHeap::should_alloc_in_eden(const size_t size) const { - const size_t eden_size = young_gen()->eden_space()->capacity_in_words(); - return size < eden_size / 2; + const size_t max_young_gen_bytes = young_gen()->max_gen_size(); + const size_t survivor_size_bytes = young_gen()->from_space()->capacity_in_bytes(); + const size_t max_eden_size_bytes = max_young_gen_bytes - survivor_size_bytes * 2; + const size_t max_eden_size_words = max_eden_size_bytes / HeapWordSize; + return size < max_eden_size_words / 2; } inline bool ParallelScavengeHeap::is_in_young(const void* p) const { diff --git a/src/hotspot/share/gc/parallel/parallel_globals.hpp b/src/hotspot/share/gc/parallel/parallel_globals.hpp index 64e2effdeae..ba4a79f9254 100644 --- a/src/hotspot/share/gc/parallel/parallel_globals.hpp +++ b/src/hotspot/share/gc/parallel/parallel_globals.hpp @@ -31,6 +31,19 @@ product_pd, \ range, \ constraint) \ + product(uintx, NUMAChunkResizeWeight, 20, \ + "Percentage (0-100) used to weight the current sample when " \ + "computing exponentially decaying average for " \ + "AdaptiveNUMAChunkSizing") \ + range(0, 100) \ + \ + product(size_t, NUMASpaceResizeRate, 1*G, \ + "Do not reallocate more than this amount per collection") \ + range(0, max_uintx) \ + \ + product(bool, UseAdaptiveNUMAChunkSizing, true, \ + "Enable adaptive chunk sizing for NUMA") \ + \ product(bool, UseMaximumCompactionOnSystemGC, true, \ "Use maximum compaction in the Parallel Old garbage collector " \ "for a system GC") diff --git a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp index 7515031f01f..ff7a0aee088 100644 --- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ #include "gc/shared/gcPolicyCounters.hpp" #include "gc/shared/gcUtil.hpp" #include "logging/log.hpp" +#include "runtime/atomicAccess.hpp" #include "runtime/timer.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp index b8ea47eeb09..0108f1a9762 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp @@ -203,13 +203,13 @@ void ParCompactionManager::remove_all_shadow_regions() { #if TASKQUEUE_STATS void ParCompactionManager::print_and_reset_taskqueue_stats() { - marking_stacks()->print_and_reset_taskqueue_stats("Marking Stacks"); + marking_stacks()->print_and_reset_taskqueue_stats("Full GC"); auto get_pa_stats = [&](uint i) { return _manager_array[i]->partial_array_task_stats(); }; PartialArrayTaskStats::log_set(ParallelGCThreads, get_pa_stats, - "Partial Array Task Stats"); + "Full GC Partial Array"); uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().max_workers(); for (uint i = 0; i < parallel_gc_threads; ++i) { get_pa_stats(i)->reset(); diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp index 974cd6aca59..6a9f8bfeedc 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.cpp +++ b/src/hotspot/share/gc/parallel/psOldGen.cpp @@ -30,6 +30,7 @@ #include "gc/parallel/psOldGen.hpp" #include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/gcLocker.hpp" +#include "gc/shared/hSpaceCounters.hpp" #include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" @@ -113,9 +114,11 @@ void PSOldGen::initialize_performance_counters() { const char* perf_data_name = "old"; _gen_counters = new GenerationCounters(perf_data_name, 1, 1, min_gen_size(), max_gen_size(), virtual_space()->committed_size()); - _space_counters = new SpaceCounters(perf_data_name, 0, - virtual_space()->reserved_size(), - _object_space, _gen_counters); + _space_counters = new HSpaceCounters(_gen_counters->name_space(), + perf_data_name, + 0, + virtual_space()->reserved_size(), + _object_space->capacity_in_bytes()); } HeapWord* PSOldGen::expand_and_allocate(size_t word_size) { @@ -266,7 +269,7 @@ bool PSOldGen::expand_by(size_t bytes) { } post_resize(); if (UsePerfData) { - _space_counters->update_capacity(); + _space_counters->update_capacity(_object_space->capacity_in_bytes()); _gen_counters->update_capacity(_virtual_space->committed_size()); } } @@ -394,7 +397,7 @@ void PSOldGen::print_on(outputStream* st) const { void PSOldGen::update_counters() { if (UsePerfData) { - _space_counters->update_all(); + _space_counters->update_all(_object_space->capacity_in_bytes(), _object_space->used_in_bytes()); _gen_counters->update_capacity(_virtual_space->committed_size()); } } diff --git a/src/hotspot/share/gc/parallel/psOldGen.hpp b/src/hotspot/share/gc/parallel/psOldGen.hpp index 05359b12836..c8e6ada3ebd 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.hpp +++ b/src/hotspot/share/gc/parallel/psOldGen.hpp @@ -28,7 +28,8 @@ #include "gc/parallel/mutableSpace.hpp" #include "gc/parallel/objectStartArray.hpp" #include "gc/parallel/psVirtualspace.hpp" -#include "gc/parallel/spaceCounters.hpp" +#include "gc/shared/generationCounters.hpp" +#include "gc/shared/hSpaceCounters.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" @@ -43,7 +44,7 @@ class PSOldGen : public CHeapObj { // Performance Counters GenerationCounters* _gen_counters; - SpaceCounters* _space_counters; + HSpaceCounters* _space_counters; // Sizing information, in bytes, set in constructor const size_t _min_gen_size; @@ -109,7 +110,7 @@ class PSOldGen : public CHeapObj { void shrink(size_t bytes); // Used by GC-workers during GC or for CDS at startup. - HeapWord* allocate(size_t word_size) { + HeapWord* cas_allocate_with_expansion(size_t word_size) { HeapWord* res; do { res = cas_allocate_noexpand(word_size); diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 4c6ea01e45f..d03bc3cda45 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -84,7 +84,6 @@ #include "oops/methodData.hpp" #include "oops/objArrayKlass.inline.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" #include "runtime/safepoint.hpp" diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.cpp b/src/hotspot/share/gc/parallel/psPromotionManager.cpp index d6208755374..39fcc5556c6 100644 --- a/src/hotspot/share/gc/parallel/psPromotionManager.cpp +++ b/src/hotspot/share/gc/parallel/psPromotionManager.cpp @@ -138,13 +138,13 @@ bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) { #if TASKQUEUE_STATS void PSPromotionManager::print_and_reset_taskqueue_stats() { - stack_array_depth()->print_and_reset_taskqueue_stats("Oop Queue"); + stack_array_depth()->print_and_reset_taskqueue_stats("Young GC"); auto get_pa_stats = [&](uint i) { return manager_array(i)->partial_array_task_stats(); }; PartialArrayTaskStats::log_set(ParallelGCThreads, get_pa_stats, - "Partial Array Task Stats"); + "Young GC Partial Array"); for (uint i = 0; i < ParallelGCThreads; ++i) { get_pa_stats(i)->reset(); } diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp index 9e904e44b22..68370a33a54 100644 --- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp +++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp @@ -204,13 +204,13 @@ inline HeapWord* PSPromotionManager::allocate_in_old_gen(Klass* klass, // Do we allocate directly, or flush and refill? if (obj_size > (OldPLABSize / 2)) { // Allocate this object directly - result = old_gen()->allocate(obj_size); + result = old_gen()->cas_allocate_with_expansion(obj_size); promotion_trace_event(cast_to_oop(result), klass, obj_size, age, true, nullptr); } else { // Flush and fill _old_lab.flush(); - HeapWord* lab_base = old_gen()->allocate(OldPLABSize); + HeapWord* lab_base = old_gen()->cas_allocate_with_expansion(OldPLABSize); if (lab_base != nullptr) { _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); // Try the old lab allocation again. diff --git a/src/hotspot/share/gc/parallel/psYoungGen.cpp b/src/hotspot/share/gc/parallel/psYoungGen.cpp index 593df38e985..870e912f51e 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.cpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp @@ -28,6 +28,7 @@ #include "gc/parallel/psYoungGen.hpp" #include "gc/shared/gcUtil.hpp" #include "gc/shared/genArguments.hpp" +#include "gc/shared/hSpaceCounters.hpp" #include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" @@ -133,12 +134,21 @@ void PSYoungGen::initialize_work() { max_eden_size = size - 2 * max_survivor_size; } - _eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space, - _gen_counters); - _from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space, - _gen_counters); - _to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space, - _gen_counters); + _eden_counters = new HSpaceCounters(_gen_counters->name_space(), + "eden", + 0, + max_eden_size, + _eden_space->capacity_in_bytes()); + _from_counters = new HSpaceCounters(_gen_counters->name_space(), + "s0", + 1, + max_survivor_size, + _from_space->capacity_in_bytes()); + _to_counters = new HSpaceCounters(_gen_counters->name_space(), + "s1", + 2, + max_survivor_size, + _to_space->capacity_in_bytes()); compute_initial_space_boundaries(); } @@ -161,9 +171,9 @@ void PSYoungGen::compute_initial_space_boundaries() { space_invariants(); if (UsePerfData) { - _eden_counters->update_capacity(); - _from_counters->update_capacity(); - _to_counters->update_capacity(); + _eden_counters->update_capacity(_eden_space->capacity_in_bytes()); + _from_counters->update_capacity(_from_space->capacity_in_bytes()); + _to_counters->update_capacity(_to_space->capacity_in_bytes()); } } @@ -606,9 +616,9 @@ void PSYoungGen::post_resize() { void PSYoungGen::update_counters() { if (UsePerfData) { - _eden_counters->update_all(); - _from_counters->update_all(); - _to_counters->update_all(); + _eden_counters->update_all(_eden_space->capacity_in_bytes(), _eden_space->used_in_bytes()); + _from_counters->update_all(_from_space->capacity_in_bytes(), _from_space->used_in_bytes()); + _to_counters->update_all(_to_space->capacity_in_bytes(), _to_space->used_in_bytes()); _gen_counters->update_capacity(_virtual_space->committed_size()); } } diff --git a/src/hotspot/share/gc/parallel/psYoungGen.hpp b/src/hotspot/share/gc/parallel/psYoungGen.hpp index 98337d53184..ed10806ac99 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.hpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.hpp @@ -28,7 +28,8 @@ #include "gc/parallel/mutableSpace.hpp" #include "gc/parallel/objectStartArray.hpp" #include "gc/parallel/psVirtualspace.hpp" -#include "gc/parallel/spaceCounters.hpp" +#include "gc/shared/generationCounters.hpp" +#include "gc/shared/hSpaceCounters.hpp" class ReservedSpace; @@ -51,9 +52,9 @@ class PSYoungGen : public CHeapObj { // Performance counters GenerationCounters* _gen_counters; - SpaceCounters* _eden_counters; - SpaceCounters* _from_counters; - SpaceCounters* _to_counters; + HSpaceCounters* _eden_counters; + HSpaceCounters* _from_counters; + HSpaceCounters* _to_counters; // Initialize the space boundaries void compute_initial_space_boundaries(); @@ -127,7 +128,7 @@ class PSYoungGen : public CHeapObj { size_t max_gen_size() const { return _max_gen_size; } // Allocation - HeapWord* allocate(size_t word_size) { + HeapWord* cas_allocate(size_t word_size) { HeapWord* result = eden_space()->cas_allocate(word_size); return result; } diff --git a/src/hotspot/share/gc/parallel/spaceCounters.cpp b/src/hotspot/share/gc/parallel/spaceCounters.cpp deleted file mode 100644 index 8f24373abcb..00000000000 --- a/src/hotspot/share/gc/parallel/spaceCounters.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2002, 2025, 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. - * - */ - -#include "gc/parallel/spaceCounters.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/atomicAccess.hpp" -#include "runtime/mutex.hpp" -#include "runtime/mutexLocker.hpp" -#include "utilities/debug.hpp" -#include "utilities/macros.hpp" - -SpaceCounters::SpaceCounters(const char* name, int ordinal, size_t max_size, - MutableSpace* m, GenerationCounters* gc) - : _object_space(m) { - if (UsePerfData) { - EXCEPTION_MARK; - ResourceMark rm; - - const char* cns = PerfDataManager::name_space(gc->name_space(), "space", - ordinal); - - _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC); - strcpy(_name_space, cns); - - const char* cname = PerfDataManager::counter_name(_name_space, "name"); - PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK); - - cname = PerfDataManager::counter_name(_name_space, "maxCapacity"); - PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, - (jlong)max_size, CHECK); - - cname = PerfDataManager::counter_name(_name_space, "capacity"); - _capacity = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Bytes, - _object_space->capacity_in_bytes(), - CHECK); - - cname = PerfDataManager::counter_name(_name_space, "used"); - _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - _object_space->used_in_bytes(), - CHECK); - - cname = PerfDataManager::counter_name(_name_space, "initCapacity"); - PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, - _object_space->capacity_in_bytes(), CHECK); - } -} - -SpaceCounters::~SpaceCounters() { - FREE_C_HEAP_ARRAY(char, _name_space); -} - -void SpaceCounters::update_used() { - _used->set_value(_object_space->used_in_bytes()); -} diff --git a/src/hotspot/share/gc/parallel/spaceCounters.hpp b/src/hotspot/share/gc/parallel/spaceCounters.hpp deleted file mode 100644 index 86fc8438b23..00000000000 --- a/src/hotspot/share/gc/parallel/spaceCounters.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2002, 2025, 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. - * - */ - -#ifndef SHARE_GC_PARALLEL_SPACECOUNTERS_HPP -#define SHARE_GC_PARALLEL_SPACECOUNTERS_HPP - -#include "gc/parallel/mutableSpace.hpp" -#include "gc/shared/generationCounters.hpp" -#include "runtime/perfData.hpp" -#include "utilities/macros.hpp" - -// A SpaceCounter is a holder class for performance counters -// that track a space; - -class SpaceCounters: public CHeapObj { - friend class VMStructs; - - private: - PerfVariable* _capacity; - PerfVariable* _used; - - // Constant PerfData types don't need to retain a reference. - // However, it's a good idea to document them here. - // PerfConstant* _size; - - MutableSpace* _object_space; - char* _name_space; - - public: - - SpaceCounters(const char* name, int ordinal, size_t max_size, - MutableSpace* m, GenerationCounters* gc); - - ~SpaceCounters(); - - inline void update_capacity() { - _capacity->set_value(_object_space->capacity_in_bytes()); - } - - void update_used(); - - inline void update_all() { - update_used(); - update_capacity(); - } - - const char* name_space() const { return _name_space; } -}; - -#endif // SHARE_GC_PARALLEL_SPACECOUNTERS_HPP diff --git a/src/hotspot/share/gc/serial/cSpaceCounters.cpp b/src/hotspot/share/gc/serial/cSpaceCounters.cpp deleted file mode 100644 index f6bcee99423..00000000000 --- a/src/hotspot/share/gc/serial/cSpaceCounters.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2002, 2025, 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. - * - */ - -#include "gc/serial/cSpaceCounters.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/resourceArea.hpp" - -CSpaceCounters::CSpaceCounters(const char* name, int ordinal, size_t max_size, - ContiguousSpace* s, GenerationCounters* gc) - : _space(s) { - if (UsePerfData) { - EXCEPTION_MARK; - ResourceMark rm; - - const char* cns = PerfDataManager::name_space(gc->name_space(), "space", - ordinal); - - _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC); - strcpy(_name_space, cns); - - const char* cname = PerfDataManager::counter_name(_name_space, "name"); - PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK); - - cname = PerfDataManager::counter_name(_name_space, "maxCapacity"); - _max_capacity = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Bytes, - (jlong)max_size, - CHECK); - - cname = PerfDataManager::counter_name(_name_space, "capacity"); - _capacity = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Bytes, - _space->capacity(), - CHECK); - - cname = PerfDataManager::counter_name(_name_space, "used"); - _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - _space->used(), - CHECK); - - cname = PerfDataManager::counter_name(_name_space, "initCapacity"); - PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, - _space->capacity(), CHECK); - } -} - -CSpaceCounters::~CSpaceCounters() { - FREE_C_HEAP_ARRAY(char, _name_space); -} - -void CSpaceCounters::update_capacity() { - _capacity->set_value(_space->capacity()); -} - -void CSpaceCounters::update_used() { - _used->set_value(_space->used()); -} - -void CSpaceCounters::update_all() { - update_used(); - update_capacity(); -} diff --git a/src/hotspot/share/gc/serial/cSpaceCounters.hpp b/src/hotspot/share/gc/serial/cSpaceCounters.hpp deleted file mode 100644 index 22a51cbbd20..00000000000 --- a/src/hotspot/share/gc/serial/cSpaceCounters.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2002, 2025, 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. - * - */ - -#ifndef SHARE_GC_SERIAL_CSPACECOUNTERS_HPP -#define SHARE_GC_SERIAL_CSPACECOUNTERS_HPP - -#include "gc/shared/generationCounters.hpp" -#include "gc/shared/space.hpp" -#include "runtime/perfData.hpp" - -// A CSpaceCounters is a holder class for performance counters -// that track a space; - -class CSpaceCounters: public CHeapObj { - private: - PerfVariable* _capacity; - PerfVariable* _used; - PerfVariable* _max_capacity; - - // Constant PerfData types don't need to retain a reference. - // However, it's a good idea to document them here. - // PerfConstant* _size; - - ContiguousSpace* _space; - char* _name_space; - - public: - - CSpaceCounters(const char* name, int ordinal, size_t max_size, - ContiguousSpace* s, GenerationCounters* gc); - - ~CSpaceCounters(); - - void update_capacity(); - void update_used(); - void update_all(); - - const char* name_space() const { return _name_space; } -}; - -#endif // SHARE_GC_SERIAL_CSPACECOUNTERS_HPP diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index 9ccc7b95529..ec3726d1dce 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -39,6 +39,7 @@ #include "gc/shared/gcTimer.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/gcTraceTime.inline.hpp" +#include "gc/shared/hSpaceCounters.hpp" #include "gc/shared/oopStorageSet.inline.hpp" #include "gc/shared/referencePolicy.hpp" #include "gc/shared/referenceProcessorPhaseTimes.hpp" @@ -248,12 +249,12 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs, min_size, max_size, _virtual_space.committed_size()); _gc_counters = new CollectorCounters(policy, 0); - _eden_counters = new CSpaceCounters("eden", 0, _max_eden_size, _eden_space, - _gen_counters); - _from_counters = new CSpaceCounters("s0", 1, _max_survivor_size, _from_space, - _gen_counters); - _to_counters = new CSpaceCounters("s1", 2, _max_survivor_size, _to_space, - _gen_counters); + _eden_counters = new HSpaceCounters(_gen_counters->name_space(), "eden", 0, + _max_eden_size, _eden_space->capacity()); + _from_counters = new HSpaceCounters(_gen_counters->name_space(), "s0", 1, + _max_survivor_size, _from_space->capacity()); + _to_counters = new HSpaceCounters(_gen_counters->name_space(), "s1", 2, + _max_survivor_size, _to_space->capacity()); update_counters(); _old_gen = nullptr; @@ -319,7 +320,7 @@ void DefNewGeneration::swap_spaces() { _to_space = s; if (UsePerfData) { - CSpaceCounters* c = _from_counters; + HSpaceCounters* c = _from_counters; _from_counters = _to_counters; _to_counters = c; } @@ -348,38 +349,6 @@ void DefNewGeneration::expand_eden_by(size_t delta_bytes) { post_resize(); } -size_t DefNewGeneration::calculate_thread_increase_size(int threads_count) const { - size_t thread_increase_size = 0; - // Check an overflow at 'threads_count * NewSizeThreadIncrease'. - if (threads_count > 0 && NewSizeThreadIncrease <= max_uintx / threads_count) { - thread_increase_size = threads_count * NewSizeThreadIncrease; - } - return thread_increase_size; -} - -size_t DefNewGeneration::adjust_for_thread_increase(size_t new_size_candidate, - size_t new_size_before, - size_t alignment, - size_t thread_increase_size) const { - size_t desired_new_size = new_size_before; - - if (NewSizeThreadIncrease > 0 && thread_increase_size > 0) { - - // 1. Check an overflow at 'new_size_candidate + thread_increase_size'. - if (new_size_candidate <= max_uintx - thread_increase_size) { - new_size_candidate += thread_increase_size; - - // 2. Check an overflow at 'align_up'. - size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); - if (new_size_candidate <= aligned_max) { - desired_new_size = align_up(new_size_candidate, alignment); - } - } - } - - return desired_new_size; -} - size_t DefNewGeneration::calculate_desired_young_gen_bytes() const { size_t old_size = SerialHeap::heap()->old_gen()->capacity(); size_t new_size_before = _virtual_space.committed_size(); @@ -391,14 +360,8 @@ size_t DefNewGeneration::calculate_desired_young_gen_bytes() const { // All space sizes must be multiples of Generation::GenGrain. size_t alignment = Generation::GenGrain; - int threads_count = Threads::number_of_non_daemon_threads(); - size_t thread_increase_size = calculate_thread_increase_size(threads_count); - size_t new_size_candidate = old_size / NewRatio; - // Compute desired new generation size based on NewRatio and NewSizeThreadIncrease - // and reverts to previous value if any overflow happens - size_t desired_new_size = adjust_for_thread_increase(new_size_candidate, new_size_before, - alignment, thread_increase_size); + size_t desired_new_size = align_up(new_size_candidate, alignment); // Adjust new generation size desired_new_size = clamp(desired_new_size, min_new_size, max_new_size); @@ -821,9 +784,9 @@ void DefNewGeneration::gc_epilogue() { void DefNewGeneration::update_counters() { if (UsePerfData) { - _eden_counters->update_all(); - _from_counters->update_all(); - _to_counters->update_all(); + _eden_counters->update_all(_eden_space->capacity(), _eden_space->used()); + _from_counters->update_all(_from_space->capacity(), _from_space->used()); + _to_counters->update_all(_to_space->capacity(), _to_space->used()); _gen_counters->update_capacity(_virtual_space.committed_size()); } } diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index e0c7b6bba37..21241ec00ef 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_GC_SERIAL_DEFNEWGENERATION_HPP #define SHARE_GC_SERIAL_DEFNEWGENERATION_HPP -#include "gc/serial/cSpaceCounters.hpp" #include "gc/serial/generation.hpp" #include "gc/serial/tenuredGeneration.hpp" #include "gc/shared/ageTable.hpp" @@ -38,7 +37,7 @@ #include "utilities/stack.hpp" class ContiguousSpace; -class CSpaceCounters; +class HSpaceCounters; class OldGenScanClosure; class YoungGenScanClosure; class DefNewTracer; @@ -102,9 +101,9 @@ class DefNewGeneration: public Generation { // Performance Counters GenerationCounters* _gen_counters; - CSpaceCounters* _eden_counters; - CSpaceCounters* _from_counters; - CSpaceCounters* _to_counters; + HSpaceCounters* _eden_counters; + HSpaceCounters* _from_counters; + HSpaceCounters* _to_counters; // sizing information size_t _max_eden_size; @@ -230,15 +229,6 @@ class DefNewGeneration: public Generation { // Initialize eden/from/to spaces. void init_spaces(); - // Return adjusted new size for NewSizeThreadIncrease. - // If any overflow happens, revert to previous new size. - size_t adjust_for_thread_increase(size_t new_size_candidate, - size_t new_size_before, - size_t alignment, - size_t thread_increase_size) const; - - size_t calculate_thread_increase_size(int threads_count) const; - // Scavenge support void swap_spaces(); diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp index f68847ed1a6..95a996a98c1 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -32,6 +32,7 @@ #include "gc/shared/gcTimer.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/genArguments.hpp" +#include "gc/shared/hSpaceCounters.hpp" #include "gc/shared/space.hpp" #include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" @@ -330,9 +331,9 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs, _gc_counters = new CollectorCounters("Serial full collection pauses", 1); - _space_counters = new CSpaceCounters(gen_name, 0, + _space_counters = new HSpaceCounters(_gen_counters->name_space(), gen_name, 0, _virtual_space.reserved_size(), - _the_space, _gen_counters); + _the_space->capacity()); } void TenuredGeneration::gc_prologue() { @@ -367,7 +368,7 @@ void TenuredGeneration::update_promote_stats() { void TenuredGeneration::update_counters() { if (UsePerfData) { - _space_counters->update_all(); + _space_counters->update_all(_the_space->capacity(), _the_space->used()); _gen_counters->update_capacity(_virtual_space.committed_size()); } } diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp index ff73ab72b2c..1e3576d5ae7 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_GC_SERIAL_TENUREDGENERATION_HPP #define SHARE_GC_SERIAL_TENUREDGENERATION_HPP -#include "gc/serial/cSpaceCounters.hpp" #include "gc/serial/generation.hpp" #include "gc/serial/serialBlockOffsetTable.hpp" #include "gc/shared/generationCounters.hpp" @@ -34,6 +33,7 @@ class CardTableRS; class ContiguousSpace; +class HSpaceCounters; // TenuredGeneration models the heap containing old (promoted/tenured) objects // contained in a single contiguous space. This generation is covered by a card @@ -68,7 +68,7 @@ class TenuredGeneration: public Generation { ContiguousSpace* _the_space; // Actual space holding objects GenerationCounters* _gen_counters; - CSpaceCounters* _space_counters; + HSpaceCounters* _space_counters; // Avg amount promoted; used for avoiding promotion undo // This class does not update deviations if the sample is zero. diff --git a/src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp b/src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp index 914358760aa..86b74aa5736 100644 --- a/src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp +++ b/src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp @@ -22,6 +22,7 @@ * */ +#include "code/aotCodeCache.hpp" #include "gc/shared/c1/cardTableBarrierSetC1.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" @@ -123,6 +124,7 @@ void CardTableBarrierSetC1::post_barrier(LIRAccess& access, LIR_Opr addr, LIR_Op assert(addr->is_register(), "must be a register at this point"); #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER + assert(!AOTCodeCache::is_on(), "this path is not implemented"); gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base); #else LIR_Opr tmp = gen->new_pointer_register(); @@ -135,6 +137,17 @@ void CardTableBarrierSetC1::post_barrier(LIRAccess& access, LIR_Opr addr, LIR_Op } LIR_Address* card_addr; +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + // load the card table address from the AOT Runtime Constants area + LIR_Opr byte_map_base_adr = LIR_OprFact::intptrConst(AOTRuntimeConstants::card_table_base_address()); + LIR_Opr byte_map_base_reg = gen->new_pointer_register(); + __ move(byte_map_base_adr, byte_map_base_reg); + LIR_Address* byte_map_base_indirect = new LIR_Address(byte_map_base_reg, 0, T_LONG); + __ move(byte_map_base_indirect, byte_map_base_reg); + card_addr = new LIR_Address(tmp, byte_map_base_reg, T_BYTE); + } else +#endif if (gen->can_inline_as_constant(card_table_base)) { card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE); } else { diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp index 53577bad1d8..afe7d2acfa7 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -708,7 +708,6 @@ int BarrierSetC2::arraycopy_payload_base_offset(bool is_array) { // 12 - 64-bit VM, compressed klass // 16 - 64-bit VM, normal klass if (base_off % BytesPerLong != 0) { - assert(UseCompressedClassPointers, ""); assert(!UseCompactObjectHeaders, ""); if (is_array) { // Exclude length to copy by 8 bytes words. @@ -758,8 +757,8 @@ Node* BarrierSetC2::obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobi assert(UseTLAB, "Only for TLAB enabled allocations"); Node* thread = macro->transform_later(new ThreadLocalNode()); - Node* tlab_top_adr = macro->basic_plus_adr(macro->top()/*not oop*/, thread, in_bytes(JavaThread::tlab_top_offset())); - Node* tlab_end_adr = macro->basic_plus_adr(macro->top()/*not oop*/, thread, in_bytes(JavaThread::tlab_end_offset())); + Node* tlab_top_adr = macro->off_heap_plus_addr(thread, in_bytes(JavaThread::tlab_top_offset())); + Node* tlab_end_adr = macro->off_heap_plus_addr(thread, in_bytes(JavaThread::tlab_end_offset())); // Load TLAB end. // @@ -778,7 +777,7 @@ Node* BarrierSetC2::obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobi macro->transform_later(old_tlab_top); // Add to heap top to get a new TLAB top - Node* new_tlab_top = new AddPNode(macro->top(), old_tlab_top, size_in_bytes); + Node* new_tlab_top = AddPNode::make_off_heap(old_tlab_top, size_in_bytes); macro->transform_later(new_tlab_top); // Check against TLAB end @@ -813,7 +812,10 @@ Node* BarrierSetC2::obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobi return old_tlab_top; } -static const TypeFunc* clone_type() { +const TypeFunc* BarrierSetC2::_clone_type_Type = nullptr; + +void BarrierSetC2::make_clone_type() { + assert(BarrierSetC2::_clone_type_Type == nullptr, "should be"); // Create input type (domain) int argcnt = NOT_LP64(3) LP64_ONLY(4); const Type** const domain_fields = TypeTuple::fields(argcnt); @@ -829,7 +831,12 @@ static const TypeFunc* clone_type() { const Type** const range_fields = TypeTuple::fields(0); const TypeTuple* const range = TypeTuple::make(TypeFunc::Parms + 0, range_fields); - return TypeFunc::make(domain, range); + BarrierSetC2::_clone_type_Type = TypeFunc::make(domain, range); +} + +inline const TypeFunc* BarrierSetC2::clone_type() { + assert(BarrierSetC2::_clone_type_Type != nullptr, "should be initialized"); + return BarrierSetC2::_clone_type_Type; } #define XTOP LP64_ONLY(COMMA phase->top()) diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp index 7b9cb985cff..a486a88c48f 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp @@ -270,6 +270,9 @@ public: // various GC barrier sets inherit from the BarrierSetC2 class to sprinkle // barriers into the accesses. class BarrierSetC2: public CHeapObj { +private: + static const TypeFunc* _clone_type_Type; + protected: virtual void resolve_address(C2Access& access) const; virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; @@ -379,6 +382,9 @@ public: static int arraycopy_payload_base_offset(bool is_array); + static void make_clone_type(); + static const TypeFunc* clone_type(); + #ifndef PRODUCT virtual void dump_barrier_data(const MachNode* mach, outputStream* st) const { st->print("%x", mach->barrier_data()); diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp index 42af77ebdf4..f7445ff254f 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp @@ -23,6 +23,7 @@ */ #include "ci/ciUtilities.hpp" +#include "code/aotCodeCache.hpp" #include "gc/shared/c2/cardTableBarrierSetC2.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" @@ -114,13 +115,20 @@ Node* CardTableBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access return result; } -Node* CardTableBarrierSetC2::byte_map_base_node(GraphKit* kit) const { +Node* CardTableBarrierSetC2::byte_map_base_node(IdealKit* kit) const { // Get base of card map +#if INCLUDE_CDS + if (AOTCodeCache::is_on_for_dump()) { + // load the card table address from the AOT Runtime Constants area + Node* byte_map_base_adr = kit->makecon(TypeRawPtr::make(AOTRuntimeConstants::card_table_base_address())); + return kit->load_aot_const(byte_map_base_adr, TypeRawPtr::NOTNULL); + } +#endif CardTable::CardValue* card_table_base = ci_card_table_address_const(); if (card_table_base != nullptr) { return kit->makecon(TypeRawPtr::make((address)card_table_base)); } else { - return kit->null(); + return kit->makecon(Type::get_zero_type(T_ADDRESS)); } } @@ -168,7 +176,7 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit, Node* card_offset = __ URShiftX(cast, __ ConI(CardTable::card_shift())); // Combine card table base and card offset - Node* card_adr = __ AddP(__ top(), byte_map_base_node(kit), card_offset); + Node* card_adr = __ AddP(__ top(), byte_map_base_node(&ideal), card_offset); // Get the alias_index for raw card-mark memory int adr_type = Compile::AliasIdxRaw; diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp index 84876808f0d..8f5bae8c6dd 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp @@ -43,7 +43,7 @@ protected: Node* new_val, const Type* value_type) const; virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const; - Node* byte_map_base_node(GraphKit* kit) const; + Node* byte_map_base_node(IdealKit* kit) const; public: virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const; diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp index 3a9b46d9df8..5d355318b21 100644 --- a/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp +++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.hpp @@ -103,6 +103,10 @@ public: virtual void print_on(outputStream* st) const; + // The AOT code cache manager needs to know the region grain size + // shift for some barrier sets. + virtual uint grain_shift() { return 0; } + template class AccessBarrier: public BarrierSet::AccessBarrier { typedef BarrierSet::AccessBarrier Raw; diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index a59ea3745ab..9db23df7ace 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -598,7 +598,6 @@ void CollectedHeap::initialize_reserved_region(const ReservedHeapSpace& rs) { void CollectedHeap::post_initialize() { StringDedup::initialize(); - initialize_serviceability(); } bool CollectedHeap::is_shutting_down() { diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index 363ccf321b2..100866bb528 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -241,6 +241,10 @@ protected: */ virtual jint initialize() = 0; + // Initialize serviceability support. This should prepare the implementation + // for accepting serviceability-related calls, like memory_managers(), memory_pools(). + virtual void initialize_serviceability() = 0; + // In many heaps, there will be a need to perform some initialization activities // after the Universe is fully formed, but before general heap allocation is allowed. // This is the correct place to place such initialization methods. @@ -285,7 +289,7 @@ protected: DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == nullptr || is_in(p); }) void set_gc_cause(GCCause::Cause v); - GCCause::Cause gc_cause() { return _gc_cause; } + GCCause::Cause gc_cause() const { return _gc_cause; } oop obj_allocate(Klass* klass, size_t size, TRAPS); virtual oop array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS); @@ -419,8 +423,6 @@ protected: // Generate any dumps preceding or following a full gc void full_gc_dump(GCTimer* timer, bool before); - virtual void initialize_serviceability() = 0; - void print_relative_to_gc(GCWhen::Type when) const; public: diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.cpp b/src/hotspot/share/gc/shared/concurrentGCThread.cpp index ed6c1b4d283..c7765631cd9 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.cpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.cpp @@ -33,9 +33,8 @@ ConcurrentGCThread::ConcurrentGCThread() : _should_terminate(false), _has_terminated(false) {} -void ConcurrentGCThread::create_and_start(ThreadPriority prio) { +void ConcurrentGCThread::create_and_start() { if (os::create_thread(this, os::gc_thread)) { - os::set_priority(this, prio); os::start_thread(this); } } diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.hpp b/src/hotspot/share/gc/shared/concurrentGCThread.hpp index 0c764546045..5322d676493 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.hpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.hpp @@ -36,7 +36,7 @@ private: Atomic _has_terminated; protected: - void create_and_start(ThreadPriority prio = NearMaxPriority); + void create_and_start(); virtual void run_service() = 0; virtual void stop_service() = 0; diff --git a/src/hotspot/share/gc/shared/gcTrace.cpp b/src/hotspot/share/gc/shared/gcTrace.cpp index bad9c707b1e..5d0627e779e 100644 --- a/src/hotspot/share/gc/shared/gcTrace.cpp +++ b/src/hotspot/share/gc/shared/gcTrace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,11 +122,10 @@ void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& he void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const { send_meta_space_summary_event(when, summary); - send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary()); - if (UseCompressedClassPointers) { - send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary()); - } +#if INCLUDE_CLASS_SPACE + send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary()); +#endif } void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 6aa1fcf066b..66ca10f1fb6 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -198,13 +198,6 @@ constraint(MarkStackSizeConstraintFunc,AfterErgo) \ range(1, (INT_MAX - 1)) \ \ - product(bool, ParallelRefProcEnabled, false, \ - "(Deprecated) Enable parallel reference processing " \ - "whenever possible") \ - \ - product(bool, ParallelRefProcBalancingEnabled, true, \ - "(Deprecated) Enable balancing of reference processing queues") \ - \ product(size_t, ReferencesPerThread, 1000, EXPERIMENTAL, \ "Ergonomically start one thread for this amount of " \ "references for reference processing if " \ @@ -263,24 +256,13 @@ "before pushing a continuation entry") \ range(1, INT_MAX/2) \ \ - product_pd(bool, NeverActAsServerClassMachine, \ - "(Deprecated) Never act like a server-class machine") \ - \ - product(bool, AlwaysActAsServerClassMachine, false, \ - "(Deprecated) Always act like a server-class machine") \ - \ - product(uint64_t, MaxRAM, 0, \ - "(Deprecated) Real memory size (in bytes) used to set maximum " \ - "heap size") \ - range(0, 0XFFFFFFFFFFFFFFFF) \ - \ product(bool, AggressiveHeap, false, \ "(Deprecated) Optimize heap options for long-running memory " \ "intensive apps") \ \ product(size_t, ErgoHeapSizeLimit, 0, \ "Maximum ergonomically set heap size (in bytes); zero means use " \ - "MaxRAM * MaxRAMPercentage / 100") \ + "(System RAM) * MaxRAMPercentage / 100") \ range(0, max_uintx) \ \ product(double, MaxRAMPercentage, 25.0, \ @@ -492,11 +474,6 @@ "Ratio of old/new generation sizes") \ range(0, max_uintx-1) \ \ - product_pd(size_t, NewSizeThreadIncrease, \ - "Additional size added to desired new generation size per " \ - "non-daemon thread (in bytes)") \ - range(0, max_uintx) \ - \ product(uintx, QueuedAllocationWarningCount, 0, \ "Number of times an allocation that queues behind a GC " \ "will retry before printing a warning") \ diff --git a/src/hotspot/share/gc/shared/hSpaceCounters.cpp b/src/hotspot/share/gc/shared/hSpaceCounters.cpp index 818d7422fba..a873bc2f45c 100644 --- a/src/hotspot/share/gc/shared/hSpaceCounters.cpp +++ b/src/hotspot/share/gc/shared/hSpaceCounters.cpp @@ -81,14 +81,3 @@ void HSpaceCounters::update_all(size_t capacity, size_t used) { update_capacity(capacity); update_used(used); } - -DEBUG_ONLY( - // for security reasons, we do not allow arbitrary reads from - // the counters as they may live in shared memory. - jlong HSpaceCounters::used() { - return _used->get_value(); - } - jlong HSpaceCounters::capacity() { - return _used->get_value(); - } -) diff --git a/src/hotspot/share/gc/shared/hSpaceCounters.hpp b/src/hotspot/share/gc/shared/hSpaceCounters.hpp index b9a6011bd65..cd008ac6dd3 100644 --- a/src/hotspot/share/gc/shared/hSpaceCounters.hpp +++ b/src/hotspot/share/gc/shared/hSpaceCounters.hpp @@ -54,13 +54,6 @@ class HSpaceCounters: public CHeapObj { void update_all(size_t capacity, size_t used); - DEBUG_ONLY( - // for security reasons, we do not allow arbitrary reads from - // the counters as they may live in shared memory. - jlong used(); - jlong capacity(); - ) - const char* name_space() const { return _name_space; } }; #endif // SHARE_GC_SHARED_HSPACECOUNTERS_HPP diff --git a/src/hotspot/share/gc/shared/parallelCleaning.cpp b/src/hotspot/share/gc/shared/parallelCleaning.cpp index 1a0d536f3b3..8e275564a9f 100644 --- a/src/hotspot/share/gc/shared/parallelCleaning.cpp +++ b/src/hotspot/share/gc/shared/parallelCleaning.cpp @@ -28,7 +28,6 @@ #include "gc/shared/parallelCleaning.hpp" #include "logging/log.hpp" #include "oops/klass.inline.hpp" -#include "runtime/atomicAccess.hpp" CodeCacheUnloadingTask::CodeCacheUnloadingTask(bool unloading_occurred) : _unloading_occurred(unloading_occurred), diff --git a/src/hotspot/share/gc/shared/partialArrayTaskStats.cpp b/src/hotspot/share/gc/shared/partialArrayTaskStats.cpp index ac8a380ec9a..090430963c6 100644 --- a/src/hotspot/share/gc/shared/partialArrayTaskStats.cpp +++ b/src/hotspot/share/gc/shared/partialArrayTaskStats.cpp @@ -64,7 +64,7 @@ static const char* const stats_hdr[] = { }; void PartialArrayTaskStats::print_header(outputStream* s, const char* title) { - s->print_cr("%s:", title); + s->print_cr("GC Task Stats %s", title); for (uint i = 0; i < ARRAY_SIZE(stats_hdr); ++i) { s->print_cr("%s", stats_hdr[i]); } diff --git a/src/hotspot/share/gc/shared/plab.hpp b/src/hotspot/share/gc/shared/plab.hpp index 5200f022633..d893a720e2a 100644 --- a/src/hotspot/share/gc/shared/plab.hpp +++ b/src/hotspot/share/gc/shared/plab.hpp @@ -147,14 +147,14 @@ public: // PLAB book-keeping. class PLABStats : public CHeapObj { -protected: - const char* _description; // Identifying string. - Atomic _allocated; // Total allocated Atomic _wasted; // of which wasted (internal fragmentation) Atomic _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size) Atomic _unused; // Unused in last buffer +protected: + const char* _description; // Identifying string. + virtual void reset() { _allocated.store_relaxed(0); _wasted.store_relaxed(0); @@ -164,11 +164,11 @@ protected: public: PLABStats(const char* description) : - _description(description), _allocated(0), _wasted(0), _undo_wasted(0), - _unused(0) + _unused(0), + _description(description) { } virtual ~PLABStats() { } diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index 0153ee13287..b82db08ecbd 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -122,7 +122,7 @@ void ReferenceProcessor::verify_no_references_recorded() { #endif bool ReferenceProcessor::processing_is_mt() const { - return ParallelRefProcEnabled && _num_queues > 1; + return _num_queues > 1; } void ReferenceProcessor::weak_oops_do(OopClosure* f) { @@ -586,33 +586,9 @@ void ReferenceProcessor::set_active_mt_degree(uint v) { _next_id = 0; } -bool ReferenceProcessor::need_balance_queues(DiscoveredList refs_lists[]) { - assert(processing_is_mt(), "why balance non-mt processing?"); - // _num_queues is the processing degree. Only list entries up to - // _num_queues will be processed, so any non-empty lists beyond - // that must be redistributed to lists in that range. Even if not - // needed for that, balancing may be desirable to eliminate poor - // distribution of references among the lists. - if (ParallelRefProcBalancingEnabled) { - return true; // Configuration says do it. - } else { - // Configuration says don't balance, but if there are non-empty - // lists beyond the processing degree, then must ignore the - // configuration and balance anyway. - for (uint i = _num_queues; i < _max_num_queues; ++i) { - if (!refs_lists[i].is_empty()) { - return true; // Must balance despite configuration. - } - } - return false; // Safe to obey configuration and not balance. - } -} - void ReferenceProcessor::maybe_balance_queues(DiscoveredList refs_lists[]) { assert(processing_is_mt(), "Should not call this otherwise"); - if (need_balance_queues(refs_lists)) { - balance_queues(refs_lists); - } + balance_queues(refs_lists); } // Balances reference queues. diff --git a/src/hotspot/share/gc/shared/referenceProcessor.hpp b/src/hotspot/share/gc/shared/referenceProcessor.hpp index b211b94a85d..67bf3d7de36 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.hpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp @@ -366,7 +366,6 @@ private: // Balances reference queues. void balance_queues(DiscoveredList refs_lists[]); - bool need_balance_queues(DiscoveredList refs_lists[]); // If there is need to balance the given queue, do it. void maybe_balance_queues(DiscoveredList refs_lists[]); diff --git a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp index 0371ed2c73b..fc7ef75c1be 100644 --- a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp @@ -152,7 +152,15 @@ RefProcTotalPhaseTimesTracker::~RefProcTotalPhaseTimesTracker() { } ReferenceProcessorPhaseTimes::ReferenceProcessorPhaseTimes(GCTimer* gc_timer, uint max_gc_threads) : - _processing_is_mt(false), _gc_timer(gc_timer) { + _sub_phases_worker_time_sec{}, + _balance_queues_time_ms{}, + _soft_weak_final_refs_phase_worker_time_sec(nullptr), + _total_time_ms(0.0), + _ref_dropped{}, + _ref_discovered{}, + _processing_is_mt(false), + _gc_timer(gc_timer) { + assert(gc_timer != nullptr, "pre-condition"); for (uint i = 0; i < ReferenceProcessor::RefSubPhaseMax; i++) { _sub_phases_worker_time_sec[i] = new WorkerDataArray(nullptr, SubPhasesParWorkTitle[i], max_gc_threads); diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index 84ba21527fd..093fa4432e2 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -51,7 +51,7 @@ void ContiguousSpace::initialize(MemRegion mr, set_bottom(bottom); set_end(end); if (clear_space) { - clear(SpaceDecorator::DontMangle); + set_top(bottom); } if (ZapUnusedHeapArea) { mangle_unused_area(); diff --git a/src/hotspot/share/gc/shared/taskqueue.inline.hpp b/src/hotspot/share/gc/shared/taskqueue.inline.hpp index e77645f4fcf..b142aadc580 100644 --- a/src/hotspot/share/gc/shared/taskqueue.inline.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -279,13 +279,11 @@ typename GenericTaskQueue::PopResult GenericTaskQueue::pop_g // Increment top; if it wraps, also increment tag, to distinguish it // from any recent _age for the same top() index. idx_t new_top = increment_index(oldAge.top()); + // Don't use bottom, since a pop_local might have decremented it. + assert_not_underflow(localBot, new_top); idx_t new_tag = oldAge.tag() + ((new_top == 0) ? 1 : 0); Age newAge(new_top, new_tag); bool result = par_set_age(oldAge, newAge); - - // Note that using "bottom" here might fail, since a pop_local might - // have decremented it. - assert_not_underflow(localBot, newAge.top()); return result ? PopResult::Success : PopResult::Contended; } diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp index d99544c0573..f9b8694eb04 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp @@ -37,8 +37,7 @@ #include "utilities/copy.hpp" size_t ThreadLocalAllocBuffer::_max_size = 0; -int ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0; -unsigned int ThreadLocalAllocBuffer::_target_refills = 0; +unsigned int ThreadLocalAllocBuffer::_target_num_refills = 0; ThreadLocalAllocBuffer::ThreadLocalAllocBuffer() : _start(nullptr), @@ -49,10 +48,10 @@ ThreadLocalAllocBuffer::ThreadLocalAllocBuffer() : _desired_size(0), _refill_waste_limit(0), _allocated_before_last_gc(0), - _number_of_refills(0), + _num_refills(0), _refill_waste(0), _gc_waste(0), - _slow_allocations(0), + _num_slow_allocations(0), _allocated_size(0), _allocation_fraction(TLABAllocationWeight) { @@ -76,13 +75,13 @@ void ThreadLocalAllocBuffer::accumulate_and_reset_statistics(ThreadLocalAllocSta size_t used = Universe::heap()->tlab_used(); _gc_waste += (unsigned)remaining(); - size_t total_allocated = (size_t)thread()->allocated_bytes(); - size_t allocated_since_last_gc = total_allocated - _allocated_before_last_gc; + uint64_t total_allocated = thread()->allocated_bytes(); + uint64_t allocated_since_last_gc = total_allocated - _allocated_before_last_gc; _allocated_before_last_gc = total_allocated; print_stats("gc"); - if (_number_of_refills > 0) { + if (_num_refills > 0) { // Update allocation history if a reasonable amount of eden was allocated. bool update_allocation_history = used > 0.5 * capacity; @@ -99,16 +98,16 @@ void ThreadLocalAllocBuffer::accumulate_and_reset_statistics(ThreadLocalAllocSta _allocation_fraction.sample(alloc_frac); } - stats->update_fast_allocations(_number_of_refills, + stats->update_fast_allocations(_num_refills, _allocated_size, _gc_waste, _refill_waste); } else { - assert(_number_of_refills == 0 && _refill_waste == 0 && _gc_waste == 0, + assert(_num_refills == 0 && _refill_waste == 0 && _gc_waste == 0, "tlab stats == 0"); } - stats->update_slow_allocations(_slow_allocations); + stats->update_num_slow_allocations(_num_slow_allocations); reset_statistics(); } @@ -148,7 +147,7 @@ void ThreadLocalAllocBuffer::resize() { assert(ResizeTLAB, "Should not call this otherwise"); size_t alloc = (size_t)(_allocation_fraction.average() * (Universe::heap()->tlab_capacity() / HeapWordSize)); - size_t new_size = alloc / _target_refills; + size_t new_size = alloc / _target_num_refills; new_size = clamp(new_size, min_size(), max_size()); @@ -157,24 +156,24 @@ void ThreadLocalAllocBuffer::resize() { log_trace(gc, tlab)("TLAB new size: thread: " PTR_FORMAT " [id: %2d]" " refills %d alloc: %8.6f desired_size: %zu -> %zu", p2i(thread()), thread()->osthread()->thread_id(), - _target_refills, _allocation_fraction.average(), desired_size(), aligned_new_size); + _target_num_refills, _allocation_fraction.average(), desired_size(), aligned_new_size); set_desired_size(aligned_new_size); set_refill_waste_limit(initial_refill_waste_limit()); } void ThreadLocalAllocBuffer::reset_statistics() { - _number_of_refills = 0; - _refill_waste = 0; - _gc_waste = 0; - _slow_allocations = 0; - _allocated_size = 0; + _num_refills = 0; + _refill_waste = 0; + _gc_waste = 0; + _num_slow_allocations = 0; + _allocated_size = 0; } void ThreadLocalAllocBuffer::fill(HeapWord* start, HeapWord* top, size_t new_size) { - _number_of_refills++; + _num_refills++; _allocated_size += new_size; print_stats("fill"); assert(top <= start + new_size - alignment_reserve(), "size too small"); @@ -206,7 +205,7 @@ void ThreadLocalAllocBuffer::initialize() { size_t capacity = Universe::heap()->tlab_capacity() / HeapWordSize; if (capacity > 0) { // Keep alloc_frac as float and not double to avoid the double to float conversion - float alloc_frac = desired_size() * target_refills() / (float)capacity; + float alloc_frac = desired_size() * target_num_refills() / (float)capacity; _allocation_fraction.sample(alloc_frac); } @@ -220,34 +219,10 @@ void ThreadLocalAllocBuffer::startup_initialization() { // Assuming each thread's active tlab is, on average, // 1/2 full at a GC - _target_refills = 100 / (2 * TLABWasteTargetPercent); - // We need to set initial target refills to 2 to avoid a GC which causes VM + _target_num_refills = 100 / (2 * TLABWasteTargetPercent); + // We need to set the initial target number of refills to 2 to avoid a GC which causes VM // abort during VM initialization. - _target_refills = MAX2(_target_refills, 2U); - -#ifdef COMPILER2 - // If the C2 compiler is present, extra space is needed at the end of - // TLABs, otherwise prefetching instructions generated by the C2 - // compiler will fault (due to accessing memory outside of heap). - // The amount of space is the max of the number of lines to - // prefetch for array and for instance allocations. (Extra space must be - // reserved to accommodate both types of allocations.) - // - // Only SPARC-specific BIS instructions are known to fault. (Those - // instructions are generated if AllocatePrefetchStyle==3 and - // AllocatePrefetchInstr==1). To be on the safe side, however, - // extra space is reserved for all combinations of - // AllocatePrefetchStyle and AllocatePrefetchInstr. - // - // If the C2 compiler is not present, no space is reserved. - - // +1 for rounding up to next cache line, +1 to be safe - if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) { - int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2; - _reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) / - (int)HeapWordSize; - } -#endif + _target_num_refills = MAX2(_target_num_refills, 2U); // During jvm startup, the main thread is initialized // before the heap is initialized. So reinitialize it now. @@ -265,10 +240,10 @@ size_t ThreadLocalAllocBuffer::initial_desired_size() { init_sz = TLABSize / HeapWordSize; } else { // Initial size is a function of the average number of allocating threads. - unsigned int nof_threads = ThreadLocalAllocStats::allocating_threads_avg(); + unsigned int num_threads = ThreadLocalAllocStats::num_allocating_threads_avg(); init_sz = (Universe::heap()->tlab_capacity() / HeapWordSize) / - (nof_threads * target_refills()); + (num_threads * target_num_refills()); init_sz = align_object_size(init_sz); } // We can't use clamp() between min_size() and max_size() here because some @@ -296,10 +271,10 @@ void ThreadLocalAllocBuffer::print_stats(const char* tag) { " slow: %dB", tag, p2i(thrd), thrd->osthread()->thread_id(), _desired_size / (K / HeapWordSize), - _slow_allocations, _refill_waste_limit * HeapWordSize, + _num_slow_allocations, _refill_waste_limit * HeapWordSize, _allocation_fraction.average(), _allocation_fraction.average() * tlab_used / K, - _number_of_refills, waste_percent, + _num_refills, waste_percent, _gc_waste * HeapWordSize, _refill_waste * HeapWordSize); } @@ -324,17 +299,17 @@ HeapWord* ThreadLocalAllocBuffer::hard_end() { return _allocation_end + alignment_reserve(); } -PerfVariable* ThreadLocalAllocStats::_perf_allocating_threads; -PerfVariable* ThreadLocalAllocStats::_perf_total_refills; -PerfVariable* ThreadLocalAllocStats::_perf_max_refills; -PerfVariable* ThreadLocalAllocStats::_perf_total_allocations; +PerfVariable* ThreadLocalAllocStats::_perf_num_allocating_threads; +PerfVariable* ThreadLocalAllocStats::_perf_total_num_refills; +PerfVariable* ThreadLocalAllocStats::_perf_max_num_refills; +PerfVariable* ThreadLocalAllocStats::_perf_total_allocated_size; PerfVariable* ThreadLocalAllocStats::_perf_total_gc_waste; PerfVariable* ThreadLocalAllocStats::_perf_max_gc_waste; PerfVariable* ThreadLocalAllocStats::_perf_total_refill_waste; PerfVariable* ThreadLocalAllocStats::_perf_max_refill_waste; -PerfVariable* ThreadLocalAllocStats::_perf_total_slow_allocations; -PerfVariable* ThreadLocalAllocStats::_perf_max_slow_allocations; -AdaptiveWeightedAverage ThreadLocalAllocStats::_allocating_threads_avg(0); +PerfVariable* ThreadLocalAllocStats::_perf_total_num_slow_allocations; +PerfVariable* ThreadLocalAllocStats::_perf_max_num_slow_allocations; +AdaptiveWeightedAverage ThreadLocalAllocStats::_num_allocating_threads_avg(0); static PerfVariable* create_perf_variable(const char* name, PerfData::Units unit, TRAPS) { ResourceMark rm; @@ -342,120 +317,119 @@ static PerfVariable* create_perf_variable(const char* name, PerfData::Units unit } void ThreadLocalAllocStats::initialize() { - _allocating_threads_avg = AdaptiveWeightedAverage(TLABAllocationWeight); - _allocating_threads_avg.sample(1); // One allocating thread at startup + _num_allocating_threads_avg = AdaptiveWeightedAverage(TLABAllocationWeight); + _num_allocating_threads_avg.sample(1); // One allocating thread at startup if (UsePerfData) { EXCEPTION_MARK; - _perf_allocating_threads = create_perf_variable("allocThreads", PerfData::U_None, CHECK); - _perf_total_refills = create_perf_variable("fills", PerfData::U_None, CHECK); - _perf_max_refills = create_perf_variable("maxFills", PerfData::U_None, CHECK); - _perf_total_allocations = create_perf_variable("alloc", PerfData::U_Bytes, CHECK); - _perf_total_gc_waste = create_perf_variable("gcWaste", PerfData::U_Bytes, CHECK); - _perf_max_gc_waste = create_perf_variable("maxGcWaste", PerfData::U_Bytes, CHECK); - _perf_total_refill_waste = create_perf_variable("refillWaste", PerfData::U_Bytes, CHECK); - _perf_max_refill_waste = create_perf_variable("maxRefillWaste", PerfData::U_Bytes, CHECK); - _perf_total_slow_allocations = create_perf_variable("slowAlloc", PerfData::U_None, CHECK); - _perf_max_slow_allocations = create_perf_variable("maxSlowAlloc", PerfData::U_None, CHECK); + _perf_num_allocating_threads = create_perf_variable("allocThreads", PerfData::U_None, CHECK); + _perf_total_num_refills = create_perf_variable("fills", PerfData::U_None, CHECK); + _perf_max_num_refills = create_perf_variable("maxFills", PerfData::U_None, CHECK); + _perf_total_allocated_size = create_perf_variable("alloc", PerfData::U_Bytes, CHECK); + _perf_total_gc_waste = create_perf_variable("gcWaste", PerfData::U_Bytes, CHECK); + _perf_max_gc_waste = create_perf_variable("maxGcWaste", PerfData::U_Bytes, CHECK); + _perf_total_refill_waste = create_perf_variable("refillWaste", PerfData::U_Bytes, CHECK); + _perf_max_refill_waste = create_perf_variable("maxRefillWaste", PerfData::U_Bytes, CHECK); + _perf_total_num_slow_allocations = create_perf_variable("slowAlloc", PerfData::U_None, CHECK); + _perf_max_num_slow_allocations = create_perf_variable("maxSlowAlloc", PerfData::U_None, CHECK); } } ThreadLocalAllocStats::ThreadLocalAllocStats() : - _allocating_threads(0), - _total_refills(0), - _max_refills(0), - _total_allocations(0), + _num_allocating_threads(0), + _total_num_refills(0), + _max_num_refills(0), + _total_allocated_size(0), _total_gc_waste(0), _max_gc_waste(0), _total_refill_waste(0), _max_refill_waste(0), - _total_slow_allocations(0), - _max_slow_allocations(0) {} + _total_num_slow_allocations(0), + _max_num_slow_allocations(0) {} -unsigned int ThreadLocalAllocStats::allocating_threads_avg() { - return MAX2((unsigned int)(_allocating_threads_avg.average() + 0.5), 1U); +unsigned int ThreadLocalAllocStats::num_allocating_threads_avg() { + return MAX2((unsigned int)(_num_allocating_threads_avg.average() + 0.5), 1U); } -void ThreadLocalAllocStats::update_fast_allocations(unsigned int refills, - size_t allocations, - size_t gc_waste, - size_t refill_waste) { - _allocating_threads += 1; - _total_refills += refills; - _max_refills = MAX2(_max_refills, refills); - _total_allocations += allocations; +void ThreadLocalAllocStats::update_fast_allocations(unsigned int num_refills, + size_t allocated_size, + size_t gc_waste, + size_t refill_waste) { + _num_allocating_threads += 1; + _total_num_refills += num_refills; + _max_num_refills = MAX2(_max_num_refills, num_refills); + _total_allocated_size += allocated_size; _total_gc_waste += gc_waste; _max_gc_waste = MAX2(_max_gc_waste, gc_waste); _total_refill_waste += refill_waste; _max_refill_waste = MAX2(_max_refill_waste, refill_waste); } -void ThreadLocalAllocStats::update_slow_allocations(unsigned int allocations) { - _total_slow_allocations += allocations; - _max_slow_allocations = MAX2(_max_slow_allocations, allocations); +void ThreadLocalAllocStats::update_num_slow_allocations(unsigned int num_slow_allocations) { + _total_num_slow_allocations += num_slow_allocations; + _max_num_slow_allocations = MAX2(_max_num_slow_allocations, num_slow_allocations); } void ThreadLocalAllocStats::update(const ThreadLocalAllocStats& other) { - _allocating_threads += other._allocating_threads; - _total_refills += other._total_refills; - _max_refills = MAX2(_max_refills, other._max_refills); - _total_allocations += other._total_allocations; - _total_gc_waste += other._total_gc_waste; - _max_gc_waste = MAX2(_max_gc_waste, other._max_gc_waste); - _total_refill_waste += other._total_refill_waste; - _max_refill_waste = MAX2(_max_refill_waste, other._max_refill_waste); - _total_slow_allocations += other._total_slow_allocations; - _max_slow_allocations = MAX2(_max_slow_allocations, other._max_slow_allocations); + _num_allocating_threads += other._num_allocating_threads; + _total_num_refills += other._total_num_refills; + _max_num_refills = MAX2(_max_num_refills, other._max_num_refills); + _total_allocated_size += other._total_allocated_size; + _total_gc_waste += other._total_gc_waste; + _max_gc_waste = MAX2(_max_gc_waste, other._max_gc_waste); + _total_refill_waste += other._total_refill_waste; + _max_refill_waste = MAX2(_max_refill_waste, other._max_refill_waste); + _total_num_slow_allocations += other._total_num_slow_allocations; + _max_num_slow_allocations = MAX2(_max_num_slow_allocations, other._max_num_slow_allocations); } void ThreadLocalAllocStats::reset() { - _allocating_threads = 0; - _total_refills = 0; - _max_refills = 0; - _total_allocations = 0; - _total_gc_waste = 0; - _max_gc_waste = 0; - _total_refill_waste = 0; - _max_refill_waste = 0; - _total_slow_allocations = 0; - _max_slow_allocations = 0; + _num_allocating_threads = 0; + _total_num_refills = 0; + _max_num_refills = 0; + _total_allocated_size = 0; + _total_gc_waste = 0; + _max_gc_waste = 0; + _total_refill_waste = 0; + _max_refill_waste = 0; + _total_num_slow_allocations = 0; + _max_num_slow_allocations = 0; } void ThreadLocalAllocStats::publish() { - if (_total_allocations == 0) { + if (_total_allocated_size == 0) { return; } - _allocating_threads_avg.sample(_allocating_threads); + _num_allocating_threads_avg.sample(_num_allocating_threads); const size_t waste = _total_gc_waste + _total_refill_waste; - const double waste_percent = percent_of(waste, _total_allocations); + const double waste_percent = percent_of(waste, _total_allocated_size); log_debug(gc, tlab)("TLAB totals: thrds: %d refills: %d max: %d" " slow allocs: %d max %d waste: %4.1f%%" " gc: %zuB max: %zuB" " slow: %zuB max: %zuB", - _allocating_threads, _total_refills, _max_refills, - _total_slow_allocations, _max_slow_allocations, waste_percent, + _num_allocating_threads, _total_num_refills, _max_num_refills, + _total_num_slow_allocations, _max_num_slow_allocations, waste_percent, _total_gc_waste * HeapWordSize, _max_gc_waste * HeapWordSize, _total_refill_waste * HeapWordSize, _max_refill_waste * HeapWordSize); if (UsePerfData) { - _perf_allocating_threads ->set_value(_allocating_threads); - _perf_total_refills ->set_value(_total_refills); - _perf_max_refills ->set_value(_max_refills); - _perf_total_allocations ->set_value(_total_allocations); - _perf_total_gc_waste ->set_value(_total_gc_waste); - _perf_max_gc_waste ->set_value(_max_gc_waste); - _perf_total_refill_waste ->set_value(_total_refill_waste); - _perf_max_refill_waste ->set_value(_max_refill_waste); - _perf_total_slow_allocations ->set_value(_total_slow_allocations); - _perf_max_slow_allocations ->set_value(_max_slow_allocations); + _perf_num_allocating_threads ->set_value(_num_allocating_threads); + _perf_total_num_refills ->set_value(_total_num_refills); + _perf_max_num_refills ->set_value(_max_num_refills); + _perf_total_allocated_size ->set_value(_total_allocated_size); + _perf_total_gc_waste ->set_value(_total_gc_waste); + _perf_max_gc_waste ->set_value(_max_gc_waste); + _perf_total_refill_waste ->set_value(_total_refill_waste); + _perf_max_refill_waste ->set_value(_max_refill_waste); + _perf_total_num_slow_allocations ->set_value(_total_num_slow_allocations); + _perf_max_num_slow_allocations ->set_value(_max_num_slow_allocations); } } size_t ThreadLocalAllocBuffer::end_reserve() { - size_t reserve_size = CollectedHeap::lab_alignment_reserve(); - return MAX2(reserve_size, (size_t)_reserve_for_allocation_prefetch); + return CollectedHeap::lab_alignment_reserve(); } size_t ThreadLocalAllocBuffer::estimated_used_bytes() const { diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp index 61caac7ec51..67bc149013e 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp @@ -54,16 +54,15 @@ private: size_t _desired_size; // desired size (including alignment_reserve) size_t _refill_waste_limit; // hold onto tlab if free() is larger than this - size_t _allocated_before_last_gc; // total bytes allocated up until the last gc + uint64_t _allocated_before_last_gc; // total bytes allocated up until the last gc - static size_t _max_size; // maximum size of any TLAB - static int _reserve_for_allocation_prefetch; // Reserve at the end of the TLAB - static unsigned _target_refills; // expected number of refills between GCs + static size_t _max_size; // maximum size of any TLAB + static unsigned _target_num_refills; // expected number of refills between GCs - unsigned _number_of_refills; + unsigned _num_refills; unsigned _refill_waste; unsigned _gc_waste; - unsigned _slow_allocations; + unsigned _num_slow_allocations; size_t _allocated_size; AdaptiveWeightedAverage _allocation_fraction; // fraction of eden allocated in tlabs @@ -80,7 +79,7 @@ private: size_t initial_refill_waste_limit(); - static int target_refills() { return _target_refills; } + static int target_num_refills() { return _target_num_refills; } size_t initial_desired_size(); size_t remaining(); @@ -99,9 +98,9 @@ private: // statistics - int number_of_refills() const { return _number_of_refills; } - int gc_waste() const { return _gc_waste; } - int slow_allocations() const { return _slow_allocations; } + int num_refills() const { return _num_refills; } + int gc_waste() const { return _gc_waste; } + int num_slow_allocations() const { return _num_slow_allocations; } public: ThreadLocalAllocBuffer(); @@ -180,41 +179,41 @@ public: class ThreadLocalAllocStats : public StackObj { private: - static PerfVariable* _perf_allocating_threads; - static PerfVariable* _perf_total_refills; - static PerfVariable* _perf_max_refills; - static PerfVariable* _perf_total_allocations; + static PerfVariable* _perf_num_allocating_threads; + static PerfVariable* _perf_total_num_refills; + static PerfVariable* _perf_max_num_refills; + static PerfVariable* _perf_total_allocated_size; static PerfVariable* _perf_total_gc_waste; static PerfVariable* _perf_max_gc_waste; static PerfVariable* _perf_total_refill_waste; static PerfVariable* _perf_max_refill_waste; - static PerfVariable* _perf_total_slow_allocations; - static PerfVariable* _perf_max_slow_allocations; + static PerfVariable* _perf_total_num_slow_allocations; + static PerfVariable* _perf_max_num_slow_allocations; - static AdaptiveWeightedAverage _allocating_threads_avg; + static AdaptiveWeightedAverage _num_allocating_threads_avg; - unsigned int _allocating_threads; - unsigned int _total_refills; - unsigned int _max_refills; - size_t _total_allocations; + unsigned int _num_allocating_threads; + unsigned int _total_num_refills; + unsigned int _max_num_refills; + size_t _total_allocated_size; size_t _total_gc_waste; size_t _max_gc_waste; size_t _total_refill_waste; size_t _max_refill_waste; - unsigned int _total_slow_allocations; - unsigned int _max_slow_allocations; + unsigned int _total_num_slow_allocations; + unsigned int _max_num_slow_allocations; public: static void initialize(); - static unsigned int allocating_threads_avg(); + static unsigned int num_allocating_threads_avg(); ThreadLocalAllocStats(); - void update_fast_allocations(unsigned int refills, - size_t allocations, + void update_fast_allocations(unsigned int num_refills, + size_t allocated_size, size_t gc_waste, size_t refill_waste); - void update_slow_allocations(unsigned int allocations); + void update_num_slow_allocations(unsigned int num_slow_allocations); void update(const ThreadLocalAllocStats& other); void reset(); diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp index 441686c5c4c..727467f98d0 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp @@ -82,7 +82,7 @@ void ThreadLocalAllocBuffer::record_slow_allocation(size_t obj_size) { set_refill_waste_limit(refill_waste_limit() + refill_waste_limit_increment()); - _slow_allocations++; + _num_slow_allocations++; log_develop_trace(gc, tlab)("TLAB: %s thread: " PTR_FORMAT " [id: %2d]" " obj: %zu" diff --git a/src/hotspot/share/gc/shared/weakProcessor.cpp b/src/hotspot/share/gc/shared/weakProcessor.cpp index bc7e9ad6375..071a004454a 100644 --- a/src/hotspot/share/gc/shared/weakProcessor.cpp +++ b/src/hotspot/share/gc/shared/weakProcessor.cpp @@ -72,7 +72,6 @@ void WeakProcessor::oops_do(OopClosure* closure) { } uint WeakProcessor::ergo_workers(uint max_workers) { - // Ignore ParallelRefProcEnabled; that's for j.l.r.Reference processing. if (ReferencesPerThread == 0) { // Configuration says always use all the threads. return max_workers; diff --git a/src/hotspot/share/gc/shared/workerThread.cpp b/src/hotspot/share/gc/shared/workerThread.cpp index 2f6f003608f..2738c98e5c3 100644 --- a/src/hotspot/share/gc/shared/workerThread.cpp +++ b/src/hotspot/share/gc/shared/workerThread.cpp @@ -210,8 +210,6 @@ WorkerThread::WorkerThread(const char* name_prefix, uint name_suffix, WorkerTask } void WorkerThread::run() { - os::set_priority(this, NearMaxPriority); - while (true) { _dispatcher->worker_run_task(); } diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index fdfde866cd7..f721c3cd001 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2026, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -519,7 +519,33 @@ void ShenandoahBarrierSetC2::post_barrier(GraphKit* kit, #undef __ -const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() { +const TypeFunc* ShenandoahBarrierSetC2::_write_barrier_pre_Type = nullptr; +const TypeFunc* ShenandoahBarrierSetC2::_clone_barrier_Type = nullptr; +const TypeFunc* ShenandoahBarrierSetC2::_load_reference_barrier_Type = nullptr; + +inline const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() { + assert(ShenandoahBarrierSetC2::_write_barrier_pre_Type != nullptr, "should be initialized"); + return ShenandoahBarrierSetC2::_write_barrier_pre_Type; +} + +inline const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() { + assert(ShenandoahBarrierSetC2::_clone_barrier_Type != nullptr, "should be initialized"); + return ShenandoahBarrierSetC2::_clone_barrier_Type; +} + +const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() { + assert(ShenandoahBarrierSetC2::_load_reference_barrier_Type != nullptr, "should be initialized"); + return ShenandoahBarrierSetC2::_load_reference_barrier_Type; +} + +void ShenandoahBarrierSetC2::init() { + ShenandoahBarrierSetC2::make_write_barrier_pre_Type(); + ShenandoahBarrierSetC2::make_clone_barrier_Type(); + ShenandoahBarrierSetC2::make_load_reference_barrier_Type(); +} + +void ShenandoahBarrierSetC2::make_write_barrier_pre_Type() { + assert(ShenandoahBarrierSetC2::_write_barrier_pre_Type == nullptr, "should be"); const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); @@ -528,10 +554,11 @@ const TypeFunc* ShenandoahBarrierSetC2::write_barrier_pre_Type() { fields = TypeTuple::fields(0); const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); - return TypeFunc::make(domain, range); + ShenandoahBarrierSetC2::_write_barrier_pre_Type = TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() { +void ShenandoahBarrierSetC2::make_clone_barrier_Type() { + assert(ShenandoahBarrierSetC2::_clone_barrier_Type == nullptr, "should be"); const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeOopPtr::NOTNULL; // src oop const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); @@ -540,10 +567,11 @@ const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() { fields = TypeTuple::fields(0); const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); - return TypeFunc::make(domain, range); + ShenandoahBarrierSetC2::_clone_barrier_Type = TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() { +void ShenandoahBarrierSetC2::make_load_reference_barrier_Type() { + assert(ShenandoahBarrierSetC2::_load_reference_barrier_Type == nullptr, "should be"); const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeOopPtr::BOTTOM; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address @@ -555,7 +583,7 @@ const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() { fields[TypeFunc::Parms+0] = TypeOopPtr::BOTTOM; const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); - return TypeFunc::make(domain, range); + ShenandoahBarrierSetC2::_load_reference_barrier_Type = TypeFunc::make(domain, range); } Node* ShenandoahBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const { @@ -890,7 +918,7 @@ void ShenandoahBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCo Node* thread = phase->transform_later(new ThreadLocalNode()); Node* offset = phase->igvn().MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset())); - Node* gc_state_addr = phase->transform_later(new AddPNode(phase->C->top(), thread, offset)); + Node* gc_state_addr = phase->transform_later(AddPNode::make_off_heap(thread, offset)); uint gc_state_idx = Compile::AliasIdxRaw; const TypePtr* gc_state_adr_type = nullptr; // debug-mode-only argument diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index dd9e9bcc1a5..108eaa0998b 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -82,6 +82,13 @@ private: static bool clone_needs_barrier(Node* src, PhaseGVN& gvn); + static const TypeFunc* _write_barrier_pre_Type; + static const TypeFunc* _clone_barrier_Type; + static const TypeFunc* _load_reference_barrier_Type; + static void make_write_barrier_pre_Type(); + static void make_clone_barrier_Type(); + static void make_load_reference_barrier_Type(); + protected: virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; @@ -106,6 +113,8 @@ public: static const TypeFunc* write_barrier_pre_Type(); static const TypeFunc* clone_barrier_Type(); static const TypeFunc* load_reference_barrier_Type(); + static void init(); + virtual bool has_load_barrier_nodes() const { return true; } // This is the entry-point for the backend to perform accesses through the Access API. diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 40fe0c00490..015276feb5c 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Red Hat, Inc. All rights reserved. + * Copyright (c) 2015, 2026, Red Hat, Inc. All rights reserved. * Copyright (C) 2022, Tencent. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -871,7 +871,7 @@ void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node* Node* thread = new ThreadLocalNode(); Node* gc_state_offset = igvn.MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset())); - Node* gc_state_addr = new AddPNode(phase->C->top(), thread, gc_state_offset); + Node* gc_state_addr = AddPNode::make_off_heap(thread, gc_state_offset); Node* gc_state = new LoadBNode(old_ctrl, raw_mem, gc_state_addr, DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(nullptr), TypeInt::BYTE, MemNode::unordered); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp index 7a8bd55c795..6b327d7e4af 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp @@ -33,6 +33,7 @@ #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" #include "runtime/globals.hpp" @@ -59,14 +60,95 @@ const double ShenandoahAdaptiveHeuristics::HIGHEST_EXPECTED_AVAILABLE_AT_END = 0 const double ShenandoahAdaptiveHeuristics::MINIMUM_CONFIDENCE = 0.319; // 25% const double ShenandoahAdaptiveHeuristics::MAXIMUM_CONFIDENCE = 3.291; // 99.9% + +// To enable detection of GC time trends, we keep separate track of the recent history of gc time. During initialization, +// for example, the amount of live memory may be increasing, which is likely to cause the GC times to increase. This history +// allows us to predict increasing GC times rather than always assuming average recent GC time is the best predictor. +const size_t ShenandoahAdaptiveHeuristics::GC_TIME_SAMPLE_SIZE = 3; + +// We also keep separate track of recently sampled allocation rates for two purposes: +// 1. The number of samples examined to determine acceleration of allocation is represented by +// ShenandoahRateAccelerationSampleSize +// 2. The number of most recent samples averaged to determine a momentary allocation spike is represented by +// ShenandoahMomentaryAllocationRateSpikeSampleSize + +// Allocation rates are sampled by the regulator thread, which typically runs every ms. There may be jitter in the scheduling +// of the regulator thread. To reduce signal noise and synchronization overhead, we do not sample allocation rate with every +// iteration of the regulator. We prefer sample time longer than 1 ms so that there can be a statistically significant number +// of allocations occuring within each sample period. The regulator thread samples allocation rate only if at least +// ShenandoahAccelerationSamplePeriod ms have passed since it previously sampled the allocation rate. +// +// This trigger responds much more quickly than the traditional trigger, which monitors 100 ms spans. When acceleration is +// detected, the impact of acceleration on anticipated consumption of available memory is also much more impactful +// than the assumed constant allocation rate consumption of available memory. + ShenandoahAdaptiveHeuristics::ShenandoahAdaptiveHeuristics(ShenandoahSpaceInfo* space_info) : ShenandoahHeuristics(space_info), _margin_of_error_sd(ShenandoahAdaptiveInitialConfidence), _spike_threshold_sd(ShenandoahAdaptiveInitialSpikeThreshold), _last_trigger(OTHER), - _available(Moving_Average_Samples, ShenandoahAdaptiveDecayFactor) { } + _available(Moving_Average_Samples, ShenandoahAdaptiveDecayFactor), + _free_set(nullptr), + _previous_acceleration_sample_timestamp(0.0), + _gc_time_first_sample_index(0), + _gc_time_num_samples(0), + _gc_time_timestamps(NEW_C_HEAP_ARRAY(double, GC_TIME_SAMPLE_SIZE, mtGC)), + _gc_time_samples(NEW_C_HEAP_ARRAY(double, GC_TIME_SAMPLE_SIZE, mtGC)), + _gc_time_xy(NEW_C_HEAP_ARRAY(double, GC_TIME_SAMPLE_SIZE, mtGC)), + _gc_time_xx(NEW_C_HEAP_ARRAY(double, GC_TIME_SAMPLE_SIZE, mtGC)), + _gc_time_sum_of_timestamps(0), + _gc_time_sum_of_samples(0), + _gc_time_sum_of_xy(0), + _gc_time_sum_of_xx(0), + _gc_time_m(0.0), + _gc_time_b(0.0), + _gc_time_sd(0.0), + _spike_acceleration_buffer_size(MAX2(ShenandoahRateAccelerationSampleSize, 1+ShenandoahMomentaryAllocationRateSpikeSampleSize)), + _spike_acceleration_first_sample_index(0), + _spike_acceleration_num_samples(0), + _spike_acceleration_rate_samples(NEW_C_HEAP_ARRAY(double, _spike_acceleration_buffer_size, mtGC)), + _spike_acceleration_rate_timestamps(NEW_C_HEAP_ARRAY(double, _spike_acceleration_buffer_size, mtGC)) { + } -ShenandoahAdaptiveHeuristics::~ShenandoahAdaptiveHeuristics() {} +ShenandoahAdaptiveHeuristics::~ShenandoahAdaptiveHeuristics() { + FREE_C_HEAP_ARRAY(double, _spike_acceleration_rate_samples); + FREE_C_HEAP_ARRAY(double, _spike_acceleration_rate_timestamps); + FREE_C_HEAP_ARRAY(double, _gc_time_timestamps); + FREE_C_HEAP_ARRAY(double, _gc_time_samples); + FREE_C_HEAP_ARRAY(double, _gc_time_xy); + FREE_C_HEAP_ARRAY(double, _gc_time_xx); +} + +void ShenandoahAdaptiveHeuristics::initialize() { + ShenandoahHeuristics::initialize(); +} + +void ShenandoahAdaptiveHeuristics::post_initialize() { + ShenandoahHeuristics::post_initialize(); + _free_set = ShenandoahHeap::heap()->free_set(); + assert(!ShenandoahHeap::heap()->mode()->is_generational(), "ShenandoahGenerationalHeuristics overrides this method"); + compute_headroom_adjustment(); +} + +void ShenandoahAdaptiveHeuristics::compute_headroom_adjustment() { + // The trigger threshold represents mutator available - "head room". + // We plan for GC to finish before the amount of allocated memory exceeds trigger threshold. This is the same as saying we + // intend to finish GC before the amount of available memory is less than the allocation headroom. Headroom is the planned + // safety buffer to allow a small amount of additional allocation to take place in case we were overly optimistic in delaying + // our trigger. + size_t capacity = ShenandoahHeap::heap()->soft_max_capacity(); + size_t spike_headroom = capacity / 100 * ShenandoahAllocSpikeFactor; + size_t penalties = capacity / 100 * _gc_time_penalties; + _headroom_adjustment = spike_headroom + penalties; +} + +void ShenandoahAdaptiveHeuristics::start_idle_span() { + compute_headroom_adjustment(); +} + +void ShenandoahAdaptiveHeuristics::adjust_penalty(intx step) { + ShenandoahHeuristics::adjust_penalty(step); +} void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset, RegionData* data, size_t size, @@ -76,8 +158,8 @@ void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(Shenand // The logic for cset selection in adaptive is as follows: // // 1. We cannot get cset larger than available free space. Otherwise we guarantee OOME - // during evacuation, and thus guarantee full GC. In practice, we also want to let - // application to allocate something. This is why we limit CSet to some fraction of + // during evacuation, and thus guarantee full GC. In practice, we also want to let the + // application allocate during concurrent GC. This is why we limit CSet to some fraction of // available space. In non-overloaded heap, max_cset would contain all plausible candidates // over garbage threshold. // @@ -108,6 +190,7 @@ void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(Shenand size_t cur_cset = 0; size_t cur_garbage = 0; + // Regions are sorted in order of decreasing garbage for (size_t idx = 0; idx < size; idx++) { ShenandoahHeapRegion* r = data[idx].get_region(); @@ -126,6 +209,88 @@ void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(Shenand } } +void ShenandoahAdaptiveHeuristics::add_degenerated_gc_time(double timestamp, double gc_time) { + // Conservatively add sample into linear model If this time is above the predicted concurrent gc time + if (predict_gc_time(timestamp) < gc_time) { + add_gc_time(timestamp, gc_time); + } +} + +void ShenandoahAdaptiveHeuristics::add_gc_time(double timestamp, double gc_time) { + // Update best-fit linear predictor of GC time + uint index = (_gc_time_first_sample_index + _gc_time_num_samples) % GC_TIME_SAMPLE_SIZE; + if (_gc_time_num_samples == GC_TIME_SAMPLE_SIZE) { + _gc_time_sum_of_timestamps -= _gc_time_timestamps[index]; + _gc_time_sum_of_samples -= _gc_time_samples[index]; + _gc_time_sum_of_xy -= _gc_time_xy[index]; + _gc_time_sum_of_xx -= _gc_time_xx[index]; + } + _gc_time_timestamps[index] = timestamp; + _gc_time_samples[index] = gc_time; + _gc_time_xy[index] = timestamp * gc_time; + _gc_time_xx[index] = timestamp * timestamp; + + _gc_time_sum_of_timestamps += _gc_time_timestamps[index]; + _gc_time_sum_of_samples += _gc_time_samples[index]; + _gc_time_sum_of_xy += _gc_time_xy[index]; + _gc_time_sum_of_xx += _gc_time_xx[index]; + + if (_gc_time_num_samples < GC_TIME_SAMPLE_SIZE) { + _gc_time_num_samples++; + } else { + _gc_time_first_sample_index = (_gc_time_first_sample_index + 1) % GC_TIME_SAMPLE_SIZE; + } + + if (_gc_time_num_samples == 1) { + // The predictor is constant (horizontal line) + _gc_time_m = 0; + _gc_time_b = gc_time; + _gc_time_sd = 0.0; + } else if (_gc_time_num_samples == 2) { + // Two points define a line + double delta_y = gc_time - _gc_time_samples[_gc_time_first_sample_index]; + double delta_x = timestamp - _gc_time_timestamps[_gc_time_first_sample_index]; + _gc_time_m = delta_y / delta_x; + + // y = mx + b + // so b = y0 - mx0 + _gc_time_b = gc_time - _gc_time_m * timestamp; + _gc_time_sd = 0.0; + } else { + _gc_time_m = ((_gc_time_num_samples * _gc_time_sum_of_xy - _gc_time_sum_of_timestamps * _gc_time_sum_of_samples) / + (_gc_time_num_samples * _gc_time_sum_of_xx - _gc_time_sum_of_timestamps * _gc_time_sum_of_timestamps)); + _gc_time_b = (_gc_time_sum_of_samples - _gc_time_m * _gc_time_sum_of_timestamps) / _gc_time_num_samples; + double sum_of_squared_deviations = 0.0; + for (size_t i = 0; i < _gc_time_num_samples; i++) { + uint index = (_gc_time_first_sample_index + i) % GC_TIME_SAMPLE_SIZE; + double x = _gc_time_timestamps[index]; + double predicted_y = _gc_time_m * x + _gc_time_b; + double deviation = predicted_y - _gc_time_samples[index]; + sum_of_squared_deviations += deviation * deviation; + } + _gc_time_sd = sqrt(sum_of_squared_deviations / _gc_time_num_samples); + } +} + +double ShenandoahAdaptiveHeuristics::predict_gc_time(double timestamp_at_start) { + return _gc_time_m * timestamp_at_start + _gc_time_b + _gc_time_sd * _margin_of_error_sd; +} + +void ShenandoahAdaptiveHeuristics::add_rate_to_acceleration_history(double timestamp, double rate) { + uint new_sample_index = + (_spike_acceleration_first_sample_index + _spike_acceleration_num_samples) % _spike_acceleration_buffer_size; + _spike_acceleration_rate_timestamps[new_sample_index] = timestamp; + _spike_acceleration_rate_samples[new_sample_index] = rate; + if (_spike_acceleration_num_samples == _spike_acceleration_buffer_size) { + _spike_acceleration_first_sample_index++; + if (_spike_acceleration_first_sample_index == _spike_acceleration_buffer_size) { + _spike_acceleration_first_sample_index = 0; + } + } else { + _spike_acceleration_num_samples++; + } +} + void ShenandoahAdaptiveHeuristics::record_cycle_start() { ShenandoahHeuristics::record_cycle_start(); _allocation_rate.allocation_counter_reset(); @@ -133,6 +298,10 @@ void ShenandoahAdaptiveHeuristics::record_cycle_start() { void ShenandoahAdaptiveHeuristics::record_success_concurrent() { ShenandoahHeuristics::record_success_concurrent(); + double now = os::elapsedTime(); + + // Should we not add GC time if this was an abbreviated cycle? + add_gc_time(_cycle_start, elapsed_cycle_time()); size_t available = _space_info->available(); @@ -185,6 +354,7 @@ void ShenandoahAdaptiveHeuristics::record_success_concurrent() { void ShenandoahAdaptiveHeuristics::record_degenerated() { ShenandoahHeuristics::record_degenerated(); + add_degenerated_gc_time(_precursor_cycle_start, elapsed_degenerated_cycle_time()); // Adjust both trigger's parameters in the case of a degenerated GC because // either of them should have triggered earlier to avoid this case. adjust_margin_of_error(DEGENERATE_PENALTY_SD); @@ -236,6 +406,24 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { size_t available = _space_info->soft_mutator_available(); size_t allocated = _space_info->bytes_allocated_since_gc_start(); + double avg_cycle_time = 0; + double avg_alloc_rate = 0; + double now = get_most_recent_wake_time(); + size_t allocatable_words = this->allocatable(available); + double predicted_future_accelerated_gc_time = 0.0; + size_t allocated_bytes_since_last_sample = 0; + double instantaneous_rate_words_per_second = 0.0; + size_t consumption_accelerated = 0; + double acceleration = 0.0; + double current_rate_by_acceleration = 0.0; + size_t min_threshold = min_free_threshold(); + double predicted_future_gc_time = 0; + double future_planned_gc_time = 0; + bool future_planned_gc_time_is_average = false; + double avg_time_to_deplete_available = 0.0; + bool is_spiking = false; + double spike_time_to_deplete_available = 0.0; + log_debug(gc, ergo)("should_start_gc calculation: available: " PROPERFMT ", soft_max_capacity: " PROPERFMT ", " "allocated_since_gc_start: " PROPERFMT, PROPERFMTARGS(available), PROPERFMTARGS(capacity), PROPERFMTARGS(allocated)); @@ -250,7 +438,6 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { _last_trigger = OTHER; - size_t min_threshold = min_free_threshold(); if (available < min_threshold) { log_trigger("Free (Soft) (" PROPERFMT ") is below minimum threshold (" PROPERFMT ")", PROPERFMTARGS(available), PROPERFMTARGS(min_threshold)); @@ -271,55 +458,227 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { return true; } } - // Check if allocation headroom is still okay. This also factors in: - // 1. Some space to absorb allocation spikes (ShenandoahAllocSpikeFactor) - // 2. Accumulated penalties from Degenerated and Full GC - size_t allocation_headroom = available; - size_t spike_headroom = capacity / 100 * ShenandoahAllocSpikeFactor; - size_t penalties = capacity / 100 * _gc_time_penalties; + // The test (3 * allocated > available) below is intended to prevent triggers from firing so quickly that there + // has not been sufficient time to create garbage that can be reclaimed during the triggered GC cycle. If we trigger before + // garbage has been created, the concurrent GC will find no garbage. This has been observed to result in degens which + // experience OOM during evac or that experience "bad progress", both of which escalate to Full GC. Note that garbage that + // was allocated following the start of the current GC cycle cannot be reclaimed in this GC cycle. Here is the derivation + // of the expression: + // + // Let R (runway) represent the total amount of memory that can be allocated following the start of GC(N). The runway + // represents memory available at the start of the current GC plus garbage reclaimed by the current GC. In a balanced, + // fully utilized configuration, we will be starting each new GC cycle immediately following completion of the preceding + // GC cycle. In this configuration, we would expect half of R to be consumed during concurrent cycle GC(N) and half + // to be consumed during concurrent GC(N+1). + // + // Assume we want to delay GC trigger until: A/V > 0.33 + // This is equivalent to enforcing that: A > 0.33V + // which is: 3A > V + // Since A+V equals R, we have: A + 3A > A + V = R + // which is to say that: A > R/4 + // + // Postponing the trigger until at least 1/4 of the runway has been consumed helps to improve the efficiency of the + // triggered GC. Under heavy steady state workload, this delay condition generally has no effect: if the allocation + // runway is divided "equally" between the current GC and the next GC, then at any potential trigger point (which cannot + // happen any sooner than completion of the first GC), it is already the case that roughly A > R/2. + if (3 * allocated <= available) { + // Even though we will not issue an adaptive trigger unless a minimum threshold of memory has been allocated, + // we still allow more generic triggers, such as guaranteed GC intervals, to act. + return ShenandoahHeuristics::should_start_gc(); + } - allocation_headroom -= MIN2(allocation_headroom, spike_headroom); - allocation_headroom -= MIN2(allocation_headroom, penalties); + avg_cycle_time = _gc_cycle_time_history->davg() + (_margin_of_error_sd * _gc_cycle_time_history->dsd()); + avg_alloc_rate = _allocation_rate.upper_bound(_margin_of_error_sd); + if ((now - _previous_acceleration_sample_timestamp) >= (ShenandoahAccelerationSamplePeriod / 1000.0)) { + predicted_future_accelerated_gc_time = + predict_gc_time(now + MAX2(get_planned_sleep_interval(), ShenandoahAccelerationSamplePeriod / 1000.0)); + double future_accelerated_planned_gc_time; + bool future_accelerated_planned_gc_time_is_average; + if (predicted_future_accelerated_gc_time > avg_cycle_time) { + future_accelerated_planned_gc_time = predicted_future_accelerated_gc_time; + future_accelerated_planned_gc_time_is_average = false; + } else { + future_accelerated_planned_gc_time = avg_cycle_time; + future_accelerated_planned_gc_time_is_average = true; + } + allocated_bytes_since_last_sample = _free_set->get_bytes_allocated_since_previous_sample(); + instantaneous_rate_words_per_second = + (allocated_bytes_since_last_sample / HeapWordSize) / (now - _previous_acceleration_sample_timestamp); - double avg_cycle_time = _gc_cycle_time_history->davg() + (_margin_of_error_sd * _gc_cycle_time_history->dsd()); - double avg_alloc_rate = _allocation_rate.upper_bound(_margin_of_error_sd); + _previous_acceleration_sample_timestamp = now; + add_rate_to_acceleration_history(now, instantaneous_rate_words_per_second); + current_rate_by_acceleration = instantaneous_rate_words_per_second; + consumption_accelerated = + accelerated_consumption(acceleration, current_rate_by_acceleration, avg_alloc_rate / HeapWordSize, + (ShenandoahAccelerationSamplePeriod / 1000.0) + future_accelerated_planned_gc_time); - log_debug(gc)("average GC time: %.2f ms, allocation rate: %.0f %s/s", - avg_cycle_time * 1000, byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate)); - if (avg_cycle_time * avg_alloc_rate > allocation_headroom) { - log_trigger("Average GC time (%.2f ms) is above the time for average allocation rate (%.0f %sB/s)" - " to deplete free headroom (%zu%s) (margin of error = %.2f)", - avg_cycle_time * 1000, - byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate), - byte_size_in_proper_unit(allocation_headroom), proper_unit_for_byte_size(allocation_headroom), - _margin_of_error_sd); - log_info(gc, ergo)("Free headroom: %zu%s (free) - %zu%s (spike) - %zu%s (penalties) = %zu%s", - byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), - byte_size_in_proper_unit(spike_headroom), proper_unit_for_byte_size(spike_headroom), - byte_size_in_proper_unit(penalties), proper_unit_for_byte_size(penalties), - byte_size_in_proper_unit(allocation_headroom), proper_unit_for_byte_size(allocation_headroom)); + // Note that even a single thread that wakes up and begins to allocate excessively can manifest as accelerating allocation + // rate. This thread will initially allocate a TLAB of minimum size. Then it will allocate a TLAB twice as big a bit later, + // and then twice as big again after another short delay. When a phase change causes many threads to increase their + // allocation behavior, this effect is multiplied, and compounded by jitter in the times that individual threads experience + // the phase change. + // + // The following trace represents an actual workload, with allocation rates sampled at 10 Hz, the default behavior before + // introduction of accelerated allocation rate detection. Though the allocation rate is seen to be increasing at times + // 101.907 and 102.007 and 102.108, the newly sampled allocation rate is not enough to trigger GC because the headroom is + // still quite large. In fact, GC is not triggered until time 102.409s, and this GC degenerates. + // + // Sample Time (s) Allocation Rate (MB/s) Headroom (GB) + // 101.807 0.0 26.93 + // <--- accelerated spike can trigger here, around time 101.9s + // 101.907 477.6 26.85 + // 102.007 3,206.0 26.35 + // 102.108 23,797.8 24.19 + // 102.208 24,164.5 21.83 + // 102.309 23,965.0 19.47 + // 102.409 24,624.35 17.05 <--- without accelerated rate detection, we trigger here + // + // Though the above measurements are from actual workload, the following details regarding sampled allocation rates at 3ms + // period were not measured directly for this run-time sample. These are hypothetical, though they represent a plausible + // result that correlates with the actual measurements. + // + // For most of the 100 ms time span that precedes the sample at 101.907, the allocation rate still remains at zero. The phase + // change that causes increasing allocations occurs near the end ot this time segment. When sampled with a 3 ms period, + // acceration of allocation can be triggered at approximately time 101.88s. + // + // In the default configuration, accelerated allocation rate is detected by examining a sequence of 8 allocation rate samples. + // + // Even a single allocation rate sample above the norm can be interpreted as acceleration of allocation rate. For example, the + // the best-fit line for the following samples has an acceleration rate of 3,553.3 MB/s/s. This is not enough to trigger GC, + // especially given the abundance of Headroom at this moment in time. + // + // TimeStamp (s) Alloc rate (MB/s) + // 101.857 0 + // 101.860 0 + // 101.863 0 + // 101.866 0 + // 101.869 53.3 + // + // At the next sample time, we will compute a slightly higher acceration, 9,150 MB/s/s. This is also insufficient to trigger + // GC. + // + // TimeStamp (s) Alloc rate (MB/s) + // 101.860 0 + // 101.863 0 + // 101.866 0 + // 101.869 53.3 + // 101.872 110.6 + // + // Eventually, we will observe a full history of accelerating rate samples, computing acceleration of 18,500 MB/s/s. This will + // trigger GC over 500 ms earlier than was previously possible. + // + // TimeStamp (s) Alloc rate (MB/s) + // 101.866 0 + // 101.869 53.3 + // 101.872 110.6 + // 101.875 165.9 + // 101.878 221.2 + // + // The accelerated rate heuristic is based on the following idea: + // + // Assume allocation rate is accelerating at a constant rate. If we postpone the spike trigger until the subsequent + // sample point, will there be enough memory to satisfy allocations that occur during the anticipated concurrent GC + // cycle? If not, we should trigger right now. + // + // Outline of this heuristic triggering technique: + // + // 1. We remember the N (e.g. N=3) most recent samples of spike allocation rate r0, r1, r2 samples at t0, t1, and t2 + // 2. if r1 < r0 or r2 < r1, approximate Acceleration = 0.0, Rate = Average(r0, r1, r2) + // 3. Otherwise, use least squares method to compute best-fit line of rate vs time + // 4. The slope of this line represents Acceleration. The y-intercept of this line represents "initial rate" + // 5. Use r2 to rrpresent CurrentRate + // 6. Use Consumption = CurrentRate * GCTime + 1/2 * Acceleration * GCTime * GCTime + // (See High School physics discussions on constant acceleration: D = v0 * t + 1/2 * a * t^2) + // 7. if Consumption exceeds headroom, trigger now + // + // Though larger sample size may improve quality of predictor, it also delays trigger response. Smaller sample sizes + // are more susceptible to false triggers based on random noise. The default configuration uses a sample size of 8 and + // a sample period of roughly 15 ms, spanning approximately 120 ms of execution. + if (consumption_accelerated > allocatable_words) { + size_t size_t_alloc_rate = (size_t) current_rate_by_acceleration * HeapWordSize; + if (acceleration > 0) { + size_t size_t_acceleration = (size_t) acceleration * HeapWordSize; + log_trigger("Accelerated consumption (" PROPERFMT ") exceeds free headroom (" PROPERFMT ") at " + "current rate (" PROPERFMT "/s) with acceleration (" PROPERFMT "/s/s) for planned %s GC time (%.2f ms)", + PROPERFMTARGS(consumption_accelerated * HeapWordSize), + PROPERFMTARGS(allocatable_words * HeapWordSize), + PROPERFMTARGS(size_t_alloc_rate), + PROPERFMTARGS(size_t_acceleration), + future_accelerated_planned_gc_time_is_average? "(from average)": "(by linear prediction)", + future_accelerated_planned_gc_time * 1000); + } else { + log_trigger("Momentary spike consumption (" PROPERFMT ") exceeds free headroom (" PROPERFMT ") at " + "current rate (" PROPERFMT "/s) for planned %s GC time (%.2f ms) (spike threshold = %.2f)", + PROPERFMTARGS(consumption_accelerated * HeapWordSize), + PROPERFMTARGS(allocatable_words * HeapWordSize), + PROPERFMTARGS(size_t_alloc_rate), + future_accelerated_planned_gc_time_is_average? "(from average)": "(by linear prediction)", + future_accelerated_planned_gc_time * 1000, _spike_threshold_sd); + + + } + _spike_acceleration_num_samples = 0; + _spike_acceleration_first_sample_index = 0; + + // Count this as a form of RATE trigger for purposes of adjusting heuristic triggering configuration because this + // trigger is influenced more by margin_of_error_sd than by spike_threshold_sd. + accept_trigger_with_type(RATE); + return true; + } + } + + // Suppose we don't trigger now, but decide to trigger in the next regulator cycle. What will be the GC time then? + predicted_future_gc_time = predict_gc_time(now + get_planned_sleep_interval()); + if (predicted_future_gc_time > avg_cycle_time) { + future_planned_gc_time = predicted_future_gc_time; + future_planned_gc_time_is_average = false; + } else { + future_planned_gc_time = avg_cycle_time; + future_planned_gc_time_is_average = true; + } + + log_debug(gc)("%s: average GC time: %.2f ms, predicted GC time: %.2f ms, allocation rate: %.0f %s/s", + _space_info->name(), avg_cycle_time * 1000, predicted_future_gc_time * 1000, + byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate)); + size_t allocatable_bytes = allocatable_words * HeapWordSize; + avg_time_to_deplete_available = allocatable_bytes / avg_alloc_rate; + + if (future_planned_gc_time > avg_time_to_deplete_available) { + log_trigger("%s GC time (%.2f ms) is above the time for average allocation rate (%.0f %sB/s)" + " to deplete free headroom (%zu%s) (margin of error = %.2f)", + future_planned_gc_time_is_average? "Average": "Linear prediction of", future_planned_gc_time * 1000, + byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate), + byte_size_in_proper_unit(allocatable_bytes), proper_unit_for_byte_size(allocatable_bytes), + _margin_of_error_sd); + + size_t spike_headroom = capacity / 100 * ShenandoahAllocSpikeFactor; + size_t penalties = capacity / 100 * _gc_time_penalties; + size_t allocation_headroom = available; + allocation_headroom -= MIN2(allocation_headroom, spike_headroom); + allocation_headroom -= MIN2(allocation_headroom, penalties); + log_info(gc, ergo)("Free headroom: " PROPERFMT " (free) - " PROPERFMT "(spike) - " PROPERFMT " (penalties) = " PROPERFMT, + PROPERFMTARGS(available), + PROPERFMTARGS(spike_headroom), + PROPERFMTARGS(penalties), + PROPERFMTARGS(allocation_headroom)); accept_trigger_with_type(RATE); return true; } - bool is_spiking = _allocation_rate.is_spiking(rate, _spike_threshold_sd); - if (is_spiking && avg_cycle_time > allocation_headroom / rate) { - log_trigger("Average GC time (%.2f ms) is above the time for instantaneous allocation rate (%.0f %sB/s) to deplete free headroom (%zu%s) (spike threshold = %.2f)", - avg_cycle_time * 1000, - byte_size_in_proper_unit(rate), proper_unit_for_byte_size(rate), - byte_size_in_proper_unit(allocation_headroom), proper_unit_for_byte_size(allocation_headroom), - _spike_threshold_sd); + is_spiking = _allocation_rate.is_spiking(rate, _spike_threshold_sd); + spike_time_to_deplete_available = (rate == 0)? 0: allocatable_bytes / rate; + if (is_spiking && (rate != 0) && (future_planned_gc_time > spike_time_to_deplete_available)) { + log_trigger("%s GC time (%.2f ms) is above the time for instantaneous allocation rate (%.0f %sB/s)" + " to deplete free headroom (%zu%s) (spike threshold = %.2f)", + future_planned_gc_time_is_average? "Average": "Linear prediction of", future_planned_gc_time * 1000, + byte_size_in_proper_unit(rate), proper_unit_for_byte_size(rate), + byte_size_in_proper_unit(allocatable_bytes), proper_unit_for_byte_size(allocatable_bytes), + _spike_threshold_sd); accept_trigger_with_type(SPIKE); return true; } - - if (ShenandoahHeuristics::should_start_gc()) { - _start_gc_is_pending = true; - return true; - } else { - return false; - } + return ShenandoahHeuristics::should_start_gc(); } void ShenandoahAdaptiveHeuristics::adjust_last_trigger_parameters(double amount) { @@ -352,6 +711,112 @@ size_t ShenandoahAdaptiveHeuristics::min_free_threshold() { return ShenandoahHeap::heap()->soft_max_capacity() / 100 * ShenandoahMinFreeThreshold; } +// This is called each time a new rate sample has been gathered, as governed by ShenandoahAccelerationSamplePeriod. +// Unlike traditional calculation of average allocation rate, there is no adjustment for standard deviation of the +// accelerated rate prediction. +size_t ShenandoahAdaptiveHeuristics::accelerated_consumption(double& acceleration, double& current_rate, + double avg_alloc_rate_words_per_second, + double predicted_cycle_time) const +{ + double *x_array = (double *) alloca(ShenandoahRateAccelerationSampleSize * sizeof(double)); + double *y_array = (double *) alloca(ShenandoahRateAccelerationSampleSize * sizeof(double)); + double x_sum = 0.0; + double y_sum = 0.0; + + assert(_spike_acceleration_num_samples > 0, "At minimum, we should have sample from this period"); + + double weighted_average_alloc; + if (_spike_acceleration_num_samples >= ShenandoahRateAccelerationSampleSize) { + double weighted_y_sum = 0; + double total_weight = 0; + double previous_x = 0; + uint delta = _spike_acceleration_num_samples - ShenandoahRateAccelerationSampleSize; + for (uint i = 0; i < ShenandoahRateAccelerationSampleSize; i++) { + uint index = (_spike_acceleration_first_sample_index + delta + i) % _spike_acceleration_buffer_size; + x_array[i] = _spike_acceleration_rate_timestamps[index]; + x_sum += x_array[i]; + y_array[i] = _spike_acceleration_rate_samples[index]; + if (i > 0) { + // first sample not included in weighted average because it has no weight. + double sample_weight = x_array[i] - x_array[i-1]; + weighted_y_sum += y_array[i] * sample_weight; + total_weight += sample_weight; + } + y_sum += y_array[i]; + } + weighted_average_alloc = (total_weight > 0)? weighted_y_sum / total_weight: 0; + } else { + weighted_average_alloc = 0; + } + + double momentary_rate; + if (_spike_acceleration_num_samples > ShenandoahMomentaryAllocationRateSpikeSampleSize) { + // Num samples must be strictly greater than sample size, because we need one extra sample to compute rate and weights + // In this context, the weight of a y value (an allocation rate) is the duration for which this allocation rate was + // active (the time since previous y value was reported). An allocation rate measured over a span of 300 ms (e.g. during + // concurrent GC) has much more "weight" than an allocation rate measured over a span of 15 s. + double weighted_y_sum = 0; + double total_weight = 0; + double sum_for_average = 0.0; + uint delta = _spike_acceleration_num_samples - ShenandoahMomentaryAllocationRateSpikeSampleSize; + for (uint i = 0; i < ShenandoahMomentaryAllocationRateSpikeSampleSize; i++) { + uint sample_index = (_spike_acceleration_first_sample_index + delta + i) % _spike_acceleration_buffer_size; + uint preceding_index = (sample_index == 0)? _spike_acceleration_buffer_size - 1: sample_index - 1; + double sample_weight = (_spike_acceleration_rate_timestamps[sample_index] + - _spike_acceleration_rate_timestamps[preceding_index]); + weighted_y_sum += _spike_acceleration_rate_samples[sample_index] * sample_weight; + total_weight += sample_weight; + } + momentary_rate = weighted_y_sum / total_weight; + bool is_spiking = _allocation_rate.is_spiking(momentary_rate, _spike_threshold_sd); + if (!is_spiking) { + // Disable momentary spike trigger unless allocation rate delta from average exceeds sd + momentary_rate = 0.0; + } + } else { + momentary_rate = 0.0; + } + + // By default, use momentary_rate for current rate and zero acceleration. Overwrite iff best-fit line has positive slope. + current_rate = momentary_rate; + acceleration = 0.0; + if ((_spike_acceleration_num_samples >= ShenandoahRateAccelerationSampleSize) + && (weighted_average_alloc >= avg_alloc_rate_words_per_second)) { + // If the average rate across the acceleration samples is below the overall average, this sample is not eligible to + // represent acceleration of allocation rate. We may just be catching up with allocations after a lull. + + double *xy_array = (double *) alloca(ShenandoahRateAccelerationSampleSize * sizeof(double)); + double *x2_array = (double *) alloca(ShenandoahRateAccelerationSampleSize * sizeof(double)); + double xy_sum = 0.0; + double x2_sum = 0.0; + for (uint i = 0; i < ShenandoahRateAccelerationSampleSize; i++) { + xy_array[i] = x_array[i] * y_array[i]; + xy_sum += xy_array[i]; + x2_array[i] = x_array[i] * x_array[i]; + x2_sum += x2_array[i]; + } + // Find the best-fit least-squares linear representation of rate vs time + double m; /* slope */ + double b; /* y-intercept */ + + m = ((ShenandoahRateAccelerationSampleSize * xy_sum - x_sum * y_sum) + / (ShenandoahRateAccelerationSampleSize * x2_sum - x_sum * x_sum)); + b = (y_sum - m * x_sum) / ShenandoahRateAccelerationSampleSize; + + if (m > 0) { + double proposed_current_rate = m * x_array[ShenandoahRateAccelerationSampleSize - 1] + b; + acceleration = m; + current_rate = proposed_current_rate; + } + // else, leave current_rate = momentary_rate, acceleration = 0 + } + // and here also, leave current_rate = momentary_rate, acceleration = 0 + + double time_delta = get_planned_sleep_interval() + predicted_cycle_time; + size_t words_to_be_consumed = (size_t) (current_rate * time_delta + 0.5 * acceleration * time_delta * time_delta); + return words_to_be_consumed; +} + ShenandoahAllocationRate::ShenandoahAllocationRate() : _last_sample_time(os::elapsedTime()), _last_sample_value(0), @@ -363,7 +828,7 @@ ShenandoahAllocationRate::ShenandoahAllocationRate() : double ShenandoahAllocationRate::force_sample(size_t allocated, size_t &unaccounted_bytes_allocated) { const double MinSampleTime = 0.002; // Do not sample if time since last update is less than 2 ms double now = os::elapsedTime(); - double time_since_last_update = now -_last_sample_time; + double time_since_last_update = now - _last_sample_time; if (time_since_last_update < MinSampleTime) { unaccounted_bytes_allocated = allocated - _last_sample_value; _last_sample_value = 0; @@ -412,8 +877,10 @@ bool ShenandoahAllocationRate::is_spiking(double rate, double threshold) const { double sd = _rate.sd(); if (sd > 0) { - // There is a small chance that that rate has already been sampled, but it - // seems not to matter in practice. + // There is a small chance that that rate has already been sampled, but it seems not to matter in practice. + // Note that z_score reports how close the rate is to the average. A value between -1 and 1 means we are within one + // standard deviation. A value between -3 and +3 means we are within 3 standard deviations. We only check for z_score + // greater than threshold because we are looking for an allocation spike which is greater than the mean. double z_score = (rate - _rate.avg()) / sd; if (z_score > threshold) { return true; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp index 9b7824a50d7..c761f2a82f3 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp @@ -27,7 +27,9 @@ #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" +#include "gc/shenandoah/shenandoahRegulatorThread.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "memory/allocation.hpp" #include "utilities/numberSeq.hpp" @@ -108,6 +110,26 @@ public: virtual ~ShenandoahAdaptiveHeuristics(); + virtual void initialize() override; + + virtual void post_initialize() override; + + virtual void adjust_penalty(intx step) override; + + // At the end of GC(N), we idle GC until necessary to start the next GC. Compute the threshold of memory that can be allocated + // before we need to start the next GC. + void start_idle_span() override; + + // Having observed a new allocation rate sample, add this to the acceleration history so that we can determine if allocation + // rate is accelerating. + void add_rate_to_acceleration_history(double timestamp, double rate); + + // Compute and return the current allocation rate, the current rate of acceleration, and the amount of memory that we expect + // to consume if we start GC right now and gc takes predicted_cycle_time to complete. + size_t accelerated_consumption(double& acceleration, double& current_rate, + double avg_rate_words_per_sec, double predicted_cycle_time) const; + + void choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset, RegionData* data, size_t size, size_t actual_free) override; @@ -136,6 +158,8 @@ public: const static double LOWEST_EXPECTED_AVAILABLE_AT_END; const static double HIGHEST_EXPECTED_AVAILABLE_AT_END; + const static size_t GC_TIME_SAMPLE_SIZE; + friend class ShenandoahAllocationRate; // Used to record the last trigger that signaled to start a GC. @@ -150,9 +174,19 @@ public: void adjust_margin_of_error(double amount); void adjust_spike_threshold(double amount); + // Returns number of words that can be allocated before we need to trigger next GC, given available in bytes. + inline size_t allocatable(size_t available) const { + return (available > _headroom_adjustment)? (available - _headroom_adjustment) / HeapWordSize: 0; + } + protected: ShenandoahAllocationRate _allocation_rate; + // Invocations of should_start_gc() happen approximately once per ms. Queries of allocation rate only happen if a + // a certain amount of time has passed since the previous query. + size_t _allocated_at_previous_query; + double _time_of_previous_allocation_query; + // The margin of error expressed in standard deviations to add to our // average cycle time and allocation rate. As this value increases we // tend to overestimate the rate at which mutators will deplete the @@ -179,6 +213,48 @@ protected: // source of feedback to adjust trigger parameters. TruncatedSeq _available; + ShenandoahFreeSet* _free_set; + + // This represents the time at which the allocation rate was most recently sampled for the purpose of detecting acceleration. + double _previous_acceleration_sample_timestamp; + size_t _total_allocations_at_start_of_idle; + + // bytes of headroom at which we should trigger GC + size_t _headroom_adjustment; + + // Keep track of GC_TIME_SAMPLE_SIZE most recent concurrent GC cycle times + uint _gc_time_first_sample_index; + uint _gc_time_num_samples; + double* const _gc_time_timestamps; + double* const _gc_time_samples; + double* const _gc_time_xy; // timestamp * sample + double* const _gc_time_xx; // timestamp squared + double _gc_time_sum_of_timestamps; + double _gc_time_sum_of_samples; + double _gc_time_sum_of_xy; + double _gc_time_sum_of_xx; + + double _gc_time_m; // slope + double _gc_time_b; // y-intercept + double _gc_time_sd; // sd on deviance from prediction + + // In preparation for a span during which GC will be idle, compute the headroom adjustment that will be used to + // detect when GC needs to trigger. + void compute_headroom_adjustment() override; + + void add_gc_time(double timestamp_at_start, double duration); + void add_degenerated_gc_time(double timestamp_at_start, double duration); + double predict_gc_time(double timestamp_at_start); + + // Keep track of SPIKE_ACCELERATION_SAMPLE_SIZE most recent spike allocation rate measurements. Note that it is + // typical to experience a small spike following end of GC cycle, as mutator threads refresh their TLABs. But + // there is generally an abundance of memory at this time as well, so this will not generally trigger GC. + uint _spike_acceleration_buffer_size; + uint _spike_acceleration_first_sample_index; + uint _spike_acceleration_num_samples; + double* const _spike_acceleration_rate_samples; // holds rates in words/second + double* const _spike_acceleration_rate_timestamps; + // A conservative minimum threshold of free space that we'll try to maintain when possible. // For example, we might trigger a concurrent gc if we are likely to drop below // this threshold, or we might consider this when dynamically resizing generations diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp index 029b917deab..d5622ed5d79 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp @@ -25,7 +25,6 @@ #include "gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" -#include "gc/shenandoah/shenandoahCollectionSetPreselector.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.inline.hpp" @@ -52,6 +51,12 @@ static int compare_by_aged_live(AgedRegionData a, AgedRegionData b) { return 0; } +void ShenandoahGenerationalHeuristics::post_initialize() { + ShenandoahHeuristics::post_initialize(); + _free_set = ShenandoahHeap::heap()->free_set(); + compute_headroom_adjustment(); +} + inline void assert_no_in_place_promotions() { #ifdef ASSERT class ShenandoahNoInPlacePromotions : public ShenandoahHeapRegionClosure { @@ -70,25 +75,16 @@ ShenandoahGenerationalHeuristics::ShenandoahGenerationalHeuristics(ShenandoahGen } void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set) { - ShenandoahHeap* heap = ShenandoahHeap::heap(); + ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap(); + + assert(collection_set->is_empty(), "Collection set must be empty here"); _add_regions_to_old = 0; - // Seed the collection set with resource area-allocated - // preselected regions, which are removed when we exit this scope. - ShenandoahCollectionSetPreselector preselector(collection_set, heap->num_regions()); - - // Find the amount that will be promoted, regions that will be promoted in - // place, and preselected older regions that will be promoted by evacuation. - compute_evacuation_budgets(heap); - - // Choose the collection set, including the regions preselected above for promotion into the old generation. + // Choose the collection set filter_regions(collection_set); - // Even if collection_set->is_empty(), we want to adjust budgets, making reserves available to mutator. - adjust_evacuation_budgets(heap, collection_set); - - if (_generation->is_global()) { + if (!collection_set->is_empty() && _generation->is_global()) { // We have just chosen a collection set for a global cycle. The mark bitmap covering old regions is complete, so // the remembered set scan can use that to avoid walking into garbage. When the next old mark begins, we will // use the mark bitmap to make the old regions parsable by coalescing and filling any unmarked objects. Thus, @@ -102,7 +98,8 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio } } -void ShenandoahGenerationalHeuristics::compute_evacuation_budgets(ShenandoahHeap* const heap) { +void ShenandoahGenerationalHeuristics::compute_evacuation_budgets(ShenandoahInPlacePromotionPlanner& in_place_promotions, + ShenandoahHeap* const heap) { shenandoah_assert_generational(); ShenandoahOldGeneration* const old_generation = heap->old_generation(); @@ -200,7 +197,7 @@ void ShenandoahGenerationalHeuristics::compute_evacuation_budgets(ShenandoahHeap // If is_global(), we let garbage-first heuristic determine cset membership. Otherwise, we give priority // to tenurable regions by preselecting regions for promotion by evacuation (obtaining the live data to seed promoted_reserve). // This also identifies regions that will be promoted in place. These use the tenuring threshold. - const size_t consumed_by_advance_promotion = select_aged_regions(_generation->is_global()? 0: old_promo_reserve); + const size_t consumed_by_advance_promotion = select_aged_regions(in_place_promotions, _generation->is_global()? 0: old_promo_reserve); assert(consumed_by_advance_promotion <= old_promo_reserve, "Do not promote more than budgeted"); // The young evacuation reserve can be no larger than young_unaffiliated. Planning to evacuate into partially consumed @@ -225,23 +222,19 @@ void ShenandoahGenerationalHeuristics::compute_evacuation_budgets(ShenandoahHeap } void ShenandoahGenerationalHeuristics::filter_regions(ShenandoahCollectionSet* collection_set) { - assert(collection_set->is_empty(), "Must be empty"); - auto heap = ShenandoahGenerationalHeap::heap(); - size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes(); - + const size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes(); // Check all pinned regions have updated status before choosing the collection set. heap->assert_pinned_region_status(_generation); // Step 1. Build up the region candidates we care about, rejecting losers and accepting winners right away. - size_t num_regions = heap->num_regions(); + const size_t num_regions = heap->num_regions(); RegionData* candidates = _region_data; size_t cand_idx = 0; - size_t preselected_candidates = 0; size_t total_garbage = 0; @@ -251,23 +244,12 @@ void ShenandoahGenerationalHeuristics::filter_regions(ShenandoahCollectionSet* c size_t free = 0; size_t free_regions = 0; - // This counts number of humongous regions that we intend to promote in this cycle. - size_t humongous_regions_promoted = 0; - // This counts number of regular regions that will be promoted in place. - size_t regular_regions_promoted_in_place = 0; - // This counts bytes of memory used by regular regions to be promoted in place. - size_t regular_regions_promoted_usage = 0; - // This counts bytes of memory free in regular regions to be promoted in place. - size_t regular_regions_promoted_free = 0; - // This counts bytes of garbage memory in regular regions to be promoted in place. - size_t regular_regions_promoted_garbage = 0; - for (size_t i = 0; i < num_regions; i++) { ShenandoahHeapRegion* region = heap->get_region(i); if (!_generation->contains(region)) { continue; } - size_t garbage = region->garbage(); + const size_t garbage = region->garbage(); total_garbage += garbage; if (region->is_empty()) { free_regions++; @@ -279,106 +261,67 @@ void ShenandoahGenerationalHeuristics::filter_regions(ShenandoahCollectionSet* c immediate_garbage += garbage; region->make_trash_immediate(); } else { - bool is_candidate; - // This is our candidate for later consideration. - if (collection_set->is_preselected(i)) { - assert(heap->is_tenurable(region), "Preselection filter"); - is_candidate = true; - preselected_candidates++; - // Set garbage value to maximum value to force this into the sorted collection set. - garbage = region_size_bytes; - } else if (region->is_young() && heap->is_tenurable(region)) { - // Note that for GLOBAL GC, region may be OLD, and OLD regions do not qualify for pre-selection - - // This region is old enough to be promoted but it was not preselected, either because its garbage is below - // old garbage threshold so it will be promoted in place, or because there is not sufficient room - // in old gen to hold the evacuated copies of this region's live data. In both cases, we choose not to - // place this region into the collection set. - if (region->get_top_before_promote() != nullptr) { - // Region was included for promotion-in-place - regular_regions_promoted_in_place++; - regular_regions_promoted_usage += region->used_before_promote(); - regular_regions_promoted_free += region->free(); - regular_regions_promoted_garbage += region->garbage(); - } - is_candidate = false; - } else { - is_candidate = true; - } - if (is_candidate) { - candidates[cand_idx].set_region_and_garbage(region, garbage); - cand_idx++; - } + // This is our candidate for later consideration. Note that this region + // could still be promoted in place and may not necessarily end up in the + // collection set. + assert(region->get_top_before_promote() == nullptr, "Cannot add region %zu scheduled for in-place-promotion to the collection set", i); + candidates[cand_idx].set_region_and_garbage(region, garbage); + cand_idx++; } } else if (region->is_humongous_start()) { // Reclaim humongous regions here, and count them as the immediate garbage -#ifdef ASSERT - bool reg_live = region->has_live(); - bool bm_live = _generation->complete_marking_context()->is_marked(cast_to_oop(region->bottom())); - assert(reg_live == bm_live, - "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: %zu", - BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words()); -#endif + DEBUG_ONLY(assert_humongous_mark_consistency(region)); if (!region->has_live()) { heap->trash_humongous_region_at(region); // Count only the start. Continuations would be counted on "trash" path immediate_regions++; immediate_garbage += garbage; - } else { - if (region->is_young() && heap->is_tenurable(region)) { - oop obj = cast_to_oop(region->bottom()); - size_t humongous_regions = ShenandoahHeapRegion::required_regions(obj->size() * HeapWordSize); - humongous_regions_promoted += humongous_regions; - } } } else if (region->is_trash()) { - // Count in just trashed collection set, during coalesced CM-with-UR + // Count in just trashed humongous continuation regions immediate_regions++; immediate_garbage += garbage; } } - heap->old_generation()->set_expected_humongous_region_promotions(humongous_regions_promoted); - heap->old_generation()->set_expected_regular_region_promotions(regular_regions_promoted_in_place); - log_info(gc, ergo)("Planning to promote in place %zu humongous regions and %zu" - " regular regions, spanning a total of %zu used bytes", - humongous_regions_promoted, regular_regions_promoted_in_place, - humongous_regions_promoted * ShenandoahHeapRegion::region_size_bytes() + - regular_regions_promoted_usage); // Step 2. Look back at garbage statistics, and decide if we want to collect anything, // given the amount of immediately reclaimable garbage. If we do, figure out the collection set. + assert(immediate_garbage <= total_garbage, + "Cannot have more immediate garbage than total garbage: " PROPERFMT " vs " PROPERFMT, + PROPERFMTARGS(immediate_garbage), PROPERFMTARGS(total_garbage)); - assert (immediate_garbage <= total_garbage, - "Cannot have more immediate garbage than total garbage: %zu%s vs %zu%s", - byte_size_in_proper_unit(immediate_garbage), proper_unit_for_byte_size(immediate_garbage), - byte_size_in_proper_unit(total_garbage), proper_unit_for_byte_size(total_garbage)); + const size_t immediate_percent = (total_garbage == 0) ? 0 : (immediate_garbage * 100 / total_garbage); + ShenandoahInPlacePromotionPlanner in_place_promotions(heap); + if (immediate_percent <= ShenandoahImmediateThreshold) { - size_t immediate_percent = (total_garbage == 0) ? 0 : (immediate_garbage * 100 / total_garbage); - bool doing_promote_in_place = (humongous_regions_promoted + regular_regions_promoted_in_place > 0); + // Find the amount that will be promoted, regions that will be promoted in + // place, and preselected older regions that will be promoted by evacuation. + compute_evacuation_budgets(in_place_promotions, heap); - if (doing_promote_in_place || (preselected_candidates > 0) || (immediate_percent <= ShenandoahImmediateThreshold)) { // Call the subclasses to add young-gen regions into the collection set. choose_collection_set_from_regiondata(collection_set, candidates, cand_idx, immediate_garbage + free); - } - if (collection_set->has_old_regions()) { - heap->shenandoah_policy()->record_mixed_cycle(); + // Even if collection_set->is_empty(), we want to adjust budgets, making reserves available to mutator. + adjust_evacuation_budgets(heap, collection_set); + + if (collection_set->has_old_regions()) { + heap->shenandoah_policy()->record_mixed_cycle(); + } } collection_set->summarize(total_garbage, immediate_garbage, immediate_regions); - ShenandoahTracer::report_evacuation_info(collection_set, free_regions, - humongous_regions_promoted, - regular_regions_promoted_in_place, - regular_regions_promoted_garbage, - regular_regions_promoted_free, + in_place_promotions.humongous_region_stats().count, + in_place_promotions.regular_region_stats().count, + in_place_promotions.regular_region_stats().garbage, + in_place_promotions.regular_region_stats().free, immediate_regions, immediate_garbage); } -// Preselect for inclusion into the collection set all regions whose age is at or above tenure age and for which the +// Select for inclusion into the collection set all regions whose age is at or above tenure age and for which the // garbage percentage exceeds a dynamically adjusted threshold (known as the old-garbage threshold percentage). We // identify these regions by setting the appropriate entry of the collection set's preselected regions array to true. // All entries are initialized to false before calling this function. @@ -394,15 +337,13 @@ void ShenandoahGenerationalHeuristics::filter_regions(ShenandoahCollectionSet* c // that this allows us to more accurately budget memory to hold the results of evacuation. Memory for evacuation // of aged regions must be reserved in the old generation. Memory for evacuation of all other regions must be // reserved in the young generation. -size_t ShenandoahGenerationalHeuristics::select_aged_regions(const size_t old_promotion_reserve) { +size_t ShenandoahGenerationalHeuristics::select_aged_regions(ShenandoahInPlacePromotionPlanner& in_place_promotions, + const size_t old_promotion_reserve) { // There should be no regions configured for subsequent in-place-promotions carried over from the previous cycle. assert_no_in_place_promotions(); auto const heap = ShenandoahGenerationalHeap::heap(); - ShenandoahFreeSet* free_set = heap->free_set(); - bool* const candidate_regions_for_promotion_by_copy = heap->collection_set()->preselected_regions(); - ShenandoahMarkingContext* const ctx = heap->marking_context(); size_t promo_potential = 0; size_t candidates = 0; @@ -415,14 +356,21 @@ size_t ShenandoahGenerationalHeuristics::select_aged_regions(const size_t old_pr ResourceMark rm; AgedRegionData* sorted_regions = NEW_RESOURCE_ARRAY(AgedRegionData, num_regions); - ShenandoahInPlacePromotionPlanner in_place_promotions(heap); - for (idx_t i = 0; i < num_regions; i++) { ShenandoahHeapRegion* const r = heap->get_region(i); - if (r->is_empty() || !r->has_live() || !r->is_young() || !r->is_regular()) { - // skip over regions that aren't regular young with some live data + if (r->is_empty() || !r->has_live() || !r->is_young()) { + // skip over regions that aren't young with some live data continue; } + + if (!r->is_regular()) { + if (r->is_humongous_start() && heap->is_tenurable(r)) { + in_place_promotions.prepare(r); + } + // Nothing else to be done for humongous regions + continue; + } + if (heap->is_tenurable(r)) { if (in_place_promotions.is_eligible(r)) { // We prefer to promote this region in place because it has a small amount of garbage and a large usage. @@ -464,7 +412,7 @@ size_t ShenandoahGenerationalHeuristics::select_aged_regions(const size_t old_pr // Subsequent regions may be selected if they have smaller live data. } - in_place_promotions.update_free_set(); + in_place_promotions.complete_planning(); // Sort in increasing order according to live data bytes. Note that candidates represents the number of regions // that qualify to be promoted by evacuation. @@ -479,14 +427,14 @@ size_t ShenandoahGenerationalHeuristics::select_aged_regions(const size_t old_pr const size_t promotion_need = (size_t) (region_live_data * ShenandoahPromoEvacWaste); if (old_consumed + promotion_need <= old_promotion_reserve) { old_consumed += promotion_need; - candidate_regions_for_promotion_by_copy[region->index()] = true; + heap->collection_set()->add_region(region); selected_regions++; selected_live += region_live_data; } else { // We rejected this promotable region from the collection set because we had no room to hold its copy. // Add this region to promo potential for next GC. promo_potential += region_live_data; - assert(!candidate_regions_for_promotion_by_copy[region->index()], "Shouldn't be selected"); + assert(!heap->collection_set()->is_in(region), "Region %zu shouldn't be in the collection set", region->index()); } // We keep going even if one region is excluded from selection because we need to accumulate all eligible // regions that are not preselected into promo_potential @@ -550,12 +498,16 @@ void ShenandoahGenerationalHeuristics::adjust_evacuation_budgets(ShenandoahHeap* size_t young_evacuated = collection_set->get_live_bytes_in_untenurable_regions(); size_t young_evacuated_reserve_used = (size_t) (ShenandoahEvacWaste * double(young_evacuated)); - size_t total_young_available = young_generation->available_with_reserve() - _add_regions_to_old * region_size_bytes;; + // In top_off_collection_set(), we shrunk planned future reserve by _add_regions_to_old * region_size_bytes, but we + // didn't shrink available. The current reserve is not affected by the planned future reserve. Current available is + // larger than planned available by the planned adjustment amount. + size_t total_young_available = young_generation->available_with_reserve() - _add_regions_to_old * region_size_bytes; + assert(young_evacuated_reserve_used <= total_young_available, "Cannot evacuate (%zu) more than is available in young (%zu)", young_evacuated_reserve_used, total_young_available); young_generation->set_evacuation_reserve(young_evacuated_reserve_used); - // We have not yet rebuilt the free set. Some of the memory that is thought to be avaiable within old may no + // We have not yet rebuilt the free set. Some of the memory that is thought to be available within old may no // longer be available if that memory had been free within regions that were selected for the collection set. // Make the necessary adjustments to old_available. size_t old_available = @@ -634,24 +586,3 @@ void ShenandoahGenerationalHeuristics::adjust_evacuation_budgets(ShenandoahHeap* old_generation->set_promoted_reserve(total_promotion_reserve); old_generation->reset_promoted_expended(); } - -size_t ShenandoahGenerationalHeuristics::add_preselected_regions_to_collection_set(ShenandoahCollectionSet* cset, - const RegionData* data, - size_t size) const { - // cur_young_garbage represents the amount of memory to be reclaimed from young-gen. In the case that live objects - // are known to be promoted out of young-gen, we count this as cur_young_garbage because this memory is reclaimed - // from young-gen and becomes available to serve future young-gen allocation requests. - size_t cur_young_garbage = 0; - for (size_t idx = 0; idx < size; idx++) { - ShenandoahHeapRegion* r = data[idx].get_region(); - if (cset->is_preselected(r->index())) { - assert(ShenandoahGenerationalHeap::heap()->is_tenurable(r), "Preselected regions must have tenure age"); - // Entire region will be promoted, This region does not impact young-gen or old-gen evacuation reserve. - // This region has been pre-selected and its impact on promotion reserve is already accounted for. - cur_young_garbage += r->garbage(); - cset->add_region(r); - } - } - return cur_young_garbage; -} - diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp index 74d657feab7..d6551cffb73 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp @@ -27,6 +27,7 @@ #include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp" +#include "gc/shenandoah/shenandoahInPlacePromoter.hpp" class ShenandoahGeneration; class ShenandoahHeap; @@ -49,9 +50,11 @@ public: void choose_collection_set(ShenandoahCollectionSet* collection_set) override; + virtual void post_initialize() override; + private: // Compute evacuation budgets prior to choosing collection set. - void compute_evacuation_budgets(ShenandoahHeap* const heap); + void compute_evacuation_budgets(ShenandoahInPlacePromotionPlanner& in_place_promotions, ShenandoahHeap* const heap); // Preselect for possible inclusion into the collection set exactly the most // garbage-dense regions, including those that satisfy criteria 1 & 2 below, @@ -68,12 +71,12 @@ private: // regions, which are marked in the preselected_regions() indicator // array of the heap's collection set, which should be initialized // to false. - size_t select_aged_regions(const size_t old_promotion_reserve); + size_t select_aged_regions(ShenandoahInPlacePromotionPlanner& in_place_promotions, const size_t old_promotion_reserve); // Filter and sort remaining regions before adding to collection set. void filter_regions(ShenandoahCollectionSet* collection_set); - // Adjust evacuation budgets after choosing collection set. The argument regions_to_xfer + // Adjust evacuation budgets after choosing collection set. On entry, the instance variable _regions_to_xfer // represents regions to be transferred to old based on decisions made in top_off_collection_set() void adjust_evacuation_budgets(ShenandoahHeap* const heap, ShenandoahCollectionSet* const collection_set); @@ -82,10 +85,6 @@ protected: ShenandoahGeneration* _generation; size_t _add_regions_to_old; - - size_t add_preselected_regions_to_collection_set(ShenandoahCollectionSet* cset, - const RegionData* data, - size_t size) const; }; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp index dd2ad28aa4b..ed25cd2e1a9 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp @@ -31,21 +31,94 @@ #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "utilities/quickSort.hpp" +bool ShenandoahEvacuationBudget::try_reserve(size_t bytes) { + size_t new_consumption = _consumed + bytes; + if (new_consumption <= _reserve) { + return true; + } + // Try expanding from shared pool + size_t new_reserve = _reserve; + size_t new_committed = _shared->committed; + while ((new_consumption > new_reserve) && (new_committed < _shared->limit)) { + new_committed += _region_size_bytes; + new_reserve += _region_size_bytes; + } + if (new_consumption <= new_reserve) { + _reserve = new_reserve; + _shared->committed = new_committed; + return true; + } + return false; +} + +void ShenandoahEvacuationBudget::commit(size_t consumption, size_t live) { + _consumed += consumption; + _live_bytes += live; + _region_count++; +} + +ShenandoahGlobalRegionDisposition ShenandoahGlobalCSetBudget::try_add_region( + const ShenandoahGlobalRegionAttributes& region) { + + size_t region_garbage = region.garbage; + size_t new_garbage = _cur_garbage + region_garbage; + bool add_regardless = (region_garbage > _ignore_threshold) && (new_garbage < _min_garbage); + + if (!add_regardless && (region_garbage < _garbage_threshold)) { + return ShenandoahGlobalRegionDisposition::SKIP; + } + + size_t live_bytes = region.live_data_bytes; + + if (region.is_old) { + size_t evac_need = old_evac.anticipated_consumption(live_bytes); + size_t promo_loss = region.free_bytes; + + // Snapshot state for rollback — old branch does two reservations + size_t saved_committed = _shared.committed; + size_t saved_old_reserve = old_evac.reserve(); + size_t saved_promo_reserve = promo.reserve(); + + if (old_evac.try_reserve(evac_need) && promo.try_reserve(promo_loss)) { + old_evac.commit(evac_need, live_bytes); + promo.commit_raw(promo_loss); + _cur_garbage = new_garbage; + return ShenandoahGlobalRegionDisposition::ADD_OLD_EVAC; + } + _shared.committed = saved_committed; + old_evac.set_reserve(saved_old_reserve); + promo.set_reserve(saved_promo_reserve); + return ShenandoahGlobalRegionDisposition::SKIP; + } else if (region.is_tenurable) { + size_t promo_need = promo.anticipated_consumption(live_bytes); + if (promo.try_reserve(promo_need)) { + promo.commit(promo_need, live_bytes); + _cur_garbage = new_garbage; + return ShenandoahGlobalRegionDisposition::ADD_PROMO; + } + return ShenandoahGlobalRegionDisposition::SKIP; + } else { + size_t evac_need = young_evac.anticipated_consumption(live_bytes); + if (young_evac.try_reserve(evac_need)) { + young_evac.commit(evac_need, live_bytes); + _cur_garbage = new_garbage; + return ShenandoahGlobalRegionDisposition::ADD_YOUNG_EVAC; + } + return ShenandoahGlobalRegionDisposition::SKIP; + } +} + ShenandoahGlobalHeuristics::ShenandoahGlobalHeuristics(ShenandoahGlobalGeneration* generation) : ShenandoahGenerationalHeuristics(generation) { } - void ShenandoahGlobalHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset, RegionData* data, size_t size, size_t actual_free) { - // Better select garbage-first regions QuickSort::sort(data, size, compare_by_garbage); - - choose_global_collection_set(cset, data, size, actual_free, 0 /* cur_young_garbage */); + choose_global_collection_set(cset, data, size, actual_free, 0); } - void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollectionSet* cset, const ShenandoahHeuristics::RegionData* data, size_t size, size_t actual_free, @@ -80,8 +153,7 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti if (young_evac_reserve > unaffiliated_young_memory) { shared_reserve_regions += unaffiliated_young_regions; } else { - size_t delta_regions = young_evac_reserve / region_size_bytes; - shared_reserve_regions += delta_regions; + shared_reserve_regions += young_evac_reserve / region_size_bytes; } young_evac_reserve = 0; size_t total_old_reserve = old_evac_reserve + old_promo_reserve; @@ -90,24 +162,15 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti shared_reserve_regions += unaffiliated_old_regions; old_promo_reserve = total_old_reserve - unaffiliated_old_memory; } else { - size_t delta_regions = old_evac_reserve / region_size_bytes; - shared_reserve_regions += delta_regions; + shared_reserve_regions += old_evac_reserve / region_size_bytes; } old_evac_reserve = 0; assert(shared_reserve_regions <= (heap->young_generation()->free_unaffiliated_regions() + heap->old_generation()->free_unaffiliated_regions()), - "simple math"); - - size_t shared_reserves = shared_reserve_regions * region_size_bytes; - size_t committed_from_shared_reserves = 0; - - size_t promo_bytes = 0; - size_t old_evac_bytes = 0; - size_t young_evac_bytes = 0; - - size_t consumed_by_promo = 0; // promo_bytes * ShenandoahPromoEvacWaste - size_t consumed_by_old_evac = 0; // old_evac_bytes * ShenandoahOldEvacWaste - size_t consumed_by_young_evac = 0; // young_evac_bytes * ShenandoahEvacWaste + "Shared reserve regions (%zu) should not exceed total unaffiliated regions (young: %zu, old: %zu)", + shared_reserve_regions, + heap->young_generation()->free_unaffiliated_regions(), + heap->old_generation()->free_unaffiliated_regions()); // Of the memory reclaimed by GC, some of this will need to be reserved for the next GC collection. Use the current // young reserve as an approximation of the future Collector reserve requirement. Try to end with at least @@ -115,147 +178,93 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti size_t free_target = (capacity * ShenandoahMinFreeThreshold) / 100 + original_young_evac_reserve; size_t min_garbage = (free_target > actual_free) ? (free_target - actual_free) : 0; - size_t aged_regions_promoted = 0; - size_t young_regions_evacuated = 0; - size_t old_regions_evacuated = 0; + ShenandoahGlobalCSetBudget budget(region_size_bytes, + shared_reserve_regions * region_size_bytes, + garbage_threshold, ignore_threshold, min_garbage, + young_evac_reserve, ShenandoahEvacWaste, + old_evac_reserve, ShenandoahOldEvacWaste, + old_promo_reserve, ShenandoahPromoEvacWaste); + budget.set_cur_garbage(cur_young_garbage); - log_info(gc, ergo)("Adaptive CSet Selection for GLOBAL. Discretionary evacuation budget (for either old or young): %zu%s" - ", Actual Free: %zu%s.", - byte_size_in_proper_unit(shared_reserves), proper_unit_for_byte_size(shared_reserves), - byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free)); + log_info(gc, ergo)("Adaptive CSet Selection for global cycle. Discretionary evacuation budget (for either old or young): " PROPERFMT ", Actual Free: " PROPERFMT, + PROPERFMTARGS(budget.shared_reserves()), PROPERFMTARGS(actual_free)); - size_t cur_garbage = cur_young_garbage; for (size_t idx = 0; idx < size; idx++) { ShenandoahHeapRegion* r = data[idx].get_region(); - assert(!cset->is_preselected(r->index()), "There should be no preselected regions during GLOBAL GC"); - bool add_region = false; - size_t region_garbage = r->garbage(); - size_t new_garbage = cur_garbage + region_garbage; - bool add_regardless = (region_garbage > ignore_threshold) && (new_garbage < min_garbage); - size_t live_bytes = r->get_live_data_bytes(); - if (add_regardless || (region_garbage >= garbage_threshold)) { - if (r->is_old()) { - size_t anticipated_consumption = (size_t) (live_bytes * ShenandoahOldEvacWaste); - size_t new_old_consumption = consumed_by_old_evac + anticipated_consumption; - size_t new_old_evac_reserve = old_evac_reserve; - size_t proposed_old_region_expansion = 0; - while ((new_old_consumption > new_old_evac_reserve) && (committed_from_shared_reserves < shared_reserves)) { - committed_from_shared_reserves += region_size_bytes; - proposed_old_region_expansion++; - new_old_evac_reserve += region_size_bytes; - } - // If this region has free memory and we choose to place it in the collection set, its free memory is no longer - // available to hold promotion results. So we behave as if its free memory is consumed within the promotion reserve. - size_t anticipated_loss_from_promo_reserve = r->free(); - size_t new_promo_consumption = consumed_by_promo + anticipated_loss_from_promo_reserve; - size_t new_promo_reserve = old_promo_reserve; - while ((new_promo_consumption > new_promo_reserve) && (committed_from_shared_reserves < shared_reserves)) { - committed_from_shared_reserves += region_size_bytes; - proposed_old_region_expansion++; - new_promo_reserve += region_size_bytes; - } - if ((new_old_consumption <= new_old_evac_reserve) && (new_promo_consumption <= new_promo_reserve)) { - add_region = true; - old_evac_reserve = new_old_evac_reserve; - old_promo_reserve = new_promo_reserve; - old_evac_bytes += live_bytes; - consumed_by_old_evac = new_old_consumption; - consumed_by_promo = new_promo_consumption; - cur_garbage = new_garbage; - old_regions_evacuated++; - } else { - // We failed to sufficiently expand old so unwind proposed expansion - committed_from_shared_reserves -= proposed_old_region_expansion * region_size_bytes; - } - } else if (heap->is_tenurable(r)) { - size_t anticipated_consumption = (size_t) (live_bytes * ShenandoahPromoEvacWaste); - size_t new_promo_consumption = consumed_by_promo + anticipated_consumption; - size_t new_promo_reserve = old_promo_reserve; - size_t proposed_old_region_expansion = 0; - while ((new_promo_consumption > new_promo_reserve) && (committed_from_shared_reserves < shared_reserves)) { - committed_from_shared_reserves += region_size_bytes; - proposed_old_region_expansion++; - new_promo_reserve += region_size_bytes; - } - if (new_promo_consumption <= new_promo_reserve) { - add_region = true; - old_promo_reserve = new_promo_reserve; - promo_bytes += live_bytes; - consumed_by_promo = new_promo_consumption; - cur_garbage = new_garbage; - aged_regions_promoted++; - } else { - // We failed to sufficiently expand old so unwind proposed expansion - committed_from_shared_reserves -= proposed_old_region_expansion * region_size_bytes; - } - } else { - assert(r->is_young() && !heap->is_tenurable(r), "DeMorgan's law (assuming r->is_affiliated)"); - size_t anticipated_consumption = (size_t) (live_bytes * ShenandoahEvacWaste); - size_t new_young_evac_consumption = consumed_by_young_evac + anticipated_consumption; - size_t new_young_evac_reserve = young_evac_reserve; - size_t proposed_young_region_expansion = 0; - while ((new_young_evac_consumption > new_young_evac_reserve) && (committed_from_shared_reserves < shared_reserves)) { - committed_from_shared_reserves += region_size_bytes; - proposed_young_region_expansion++; - new_young_evac_reserve += region_size_bytes; - } - if (new_young_evac_consumption <= new_young_evac_reserve) { - add_region = true; - young_evac_reserve = new_young_evac_reserve; - young_evac_bytes += live_bytes; - consumed_by_young_evac = new_young_evac_consumption; - cur_garbage = new_garbage; - young_regions_evacuated++; - } else { - // We failed to sufficiently expand old so unwind proposed expansion - committed_from_shared_reserves -= proposed_young_region_expansion * region_size_bytes; - } - } + if (cset->is_in(r) || r->get_top_before_promote() != nullptr) { + assert(heap->is_tenurable(r), "Region %zu already selected for promotion must be tenurable", idx); + continue; } - if (add_region) { + + ShenandoahGlobalRegionAttributes attrs; + attrs.garbage = r->garbage(); + attrs.live_data_bytes = r->get_live_data_bytes(); + attrs.free_bytes = r->free(); + attrs.is_old = r->is_old(); + attrs.is_tenurable = !r->is_old() && heap->is_tenurable(r); + + if (budget.try_add_region(attrs) != ShenandoahGlobalRegionDisposition::SKIP) { cset->add_region(r); } } - if (committed_from_shared_reserves < shared_reserves) { - // Give all the rest to promotion - old_promo_reserve += (shared_reserves - committed_from_shared_reserves); - // dead code: committed_from_shared_reserves = shared_reserves; - } + budget.finish(); - // Consider the effects of round-off: - // 1. We know that the sum over each evacuation mutiplied by Evacuation Waste is <= total evacuation reserve - // 2. However, the reserve for each individual evacuation may be rounded down. In the worst case, we will be over budget - // by the number of regions evacuated, since each region's reserve might be under-estimated by at most 1 - // 3. Likewise, if we take the sum of bytes evacuated and multiply this by the Evacuation Waste and then round down - // to nearest integer, the calculated reserve will underestimate the true reserve needs by at most 1. - // 4. This explains the adjustments to subtotals in the assert statements below. - assert(young_evac_bytes * ShenandoahEvacWaste <= young_evac_reserve + young_regions_evacuated, - "budget: %zu <= %zu", (size_t) (young_evac_bytes * ShenandoahEvacWaste), young_evac_reserve); - assert(old_evac_bytes * ShenandoahOldEvacWaste <= old_evac_reserve + old_regions_evacuated, - "budget: %zu <= %zu", (size_t) (old_evac_bytes * ShenandoahOldEvacWaste), old_evac_reserve); - assert(promo_bytes * ShenandoahPromoEvacWaste <= old_promo_reserve + aged_regions_promoted, - "budget: %zu <= %zu", (size_t) (promo_bytes * ShenandoahPromoEvacWaste), old_promo_reserve); - assert(young_evac_reserve + old_evac_reserve + old_promo_reserve <= - heap->young_generation()->get_evacuation_reserve() + heap->old_generation()->get_evacuation_reserve() + - heap->old_generation()->get_promoted_reserve(), "Exceeded budget"); + DEBUG_ONLY(budget.assert_budget_constraints_hold( + heap->young_generation()->get_evacuation_reserve() + + heap->old_generation()->get_evacuation_reserve() + + heap->old_generation()->get_promoted_reserve())); - if (heap->young_generation()->get_evacuation_reserve() < young_evac_reserve) { - size_t delta_bytes = young_evac_reserve - heap->young_generation()->get_evacuation_reserve(); + if (heap->young_generation()->get_evacuation_reserve() < budget.young_evac.reserve()) { + size_t delta_bytes = budget.young_evac.reserve() - heap->young_generation()->get_evacuation_reserve(); size_t delta_regions = delta_bytes / region_size_bytes; size_t regions_to_transfer = MIN2(unaffiliated_old_regions, delta_regions); log_info(gc)("Global GC moves %zu unaffiliated regions from old collector to young collector reserves", regions_to_transfer); ssize_t negated_regions = -regions_to_transfer; heap->free_set()->move_unaffiliated_regions_from_collector_to_old_collector(negated_regions); - } else if (heap->young_generation()->get_evacuation_reserve() > young_evac_reserve) { - size_t delta_bytes = heap->young_generation()->get_evacuation_reserve() - young_evac_reserve; + } else if (heap->young_generation()->get_evacuation_reserve() > budget.young_evac.reserve()) { + size_t delta_bytes = heap->young_generation()->get_evacuation_reserve() - budget.young_evac.reserve(); size_t delta_regions = delta_bytes / region_size_bytes; size_t regions_to_transfer = MIN2(unaffiliated_young_regions, delta_regions); log_info(gc)("Global GC moves %zu unaffiliated regions from young collector to old collector reserves", regions_to_transfer); heap->free_set()->move_unaffiliated_regions_from_collector_to_old_collector(regions_to_transfer); } - heap->young_generation()->set_evacuation_reserve(young_evac_reserve); - heap->old_generation()->set_evacuation_reserve(old_evac_reserve); - heap->old_generation()->set_promoted_reserve(old_promo_reserve); + heap->young_generation()->set_evacuation_reserve(budget.young_evac.reserve()); + heap->old_generation()->set_evacuation_reserve(budget.old_evac.reserve()); + heap->old_generation()->set_promoted_reserve(budget.promo.reserve()); } + +#ifdef ASSERT +void ShenandoahGlobalCSetBudget::assert_budget_constraints_hold(size_t original_total_reserves) const { + // Consider the effects of round-off: + // 1. We know that the sum over each evacuation multiplied by Evacuation Waste is <= total evacuation reserve + // 2. However, the reserve for each individual evacuation may be rounded down. In the worst case, we will be + // over budget by the number of regions evacuated, since each region's reserve might be under-estimated by + // at most 1. + // 3. Likewise, if we take the sum of bytes evacuated and multiply this by the Evacuation Waste and then round + // down to nearest integer, the calculated reserve will underestimate the true reserve needs by at most 1. + // 4. This explains the adjustments to subtotals in the assert statements below. + assert(young_evac.live_bytes() * young_evac.waste_factor() <= + young_evac.reserve() + young_evac.region_count(), + "Young evac consumption (%zu) exceeds reserve (%zu) + region count (%zu)", + (size_t)(young_evac.live_bytes() * young_evac.waste_factor()), + young_evac.reserve(), young_evac.region_count()); + assert(old_evac.live_bytes() * old_evac.waste_factor() <= + old_evac.reserve() + old_evac.region_count(), + "Old evac consumption (%zu) exceeds reserve (%zu) + region count (%zu)", + (size_t)(old_evac.live_bytes() * old_evac.waste_factor()), + old_evac.reserve(), old_evac.region_count()); + assert(promo.live_bytes() * promo.waste_factor() <= + promo.reserve() + promo.region_count(), + "Promo consumption (%zu) exceeds reserve (%zu) + region count (%zu)", + (size_t)(promo.live_bytes() * promo.waste_factor()), + promo.reserve(), promo.region_count()); + + size_t total_post_reserves = young_evac.reserve() + old_evac.reserve() + promo.reserve(); + assert(total_post_reserves <= original_total_reserves, + "Total post-cset reserves (%zu + %zu + %zu = %zu) exceed original reserves (%zu)", + young_evac.reserve(), old_evac.reserve(), promo.reserve(), + total_post_reserves, original_total_reserves); +} +#endif diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp index 1f95f75c521..8102fa24d14 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp @@ -25,16 +25,138 @@ #ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHGLOBALHEURISTICS_HPP #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHGLOBALHEURISTICS_HPP - #include "gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp" class ShenandoahGlobalGeneration; -/* - * This is a specialization of the generational heuristics which is aware - * of old and young regions and respects the configured evacuation parameters - * for such regions during a global collection of a generational heap. - */ +enum class ShenandoahGlobalRegionDisposition { + SKIP, + ADD_OLD_EVAC, + ADD_PROMO, + ADD_YOUNG_EVAC +}; + +// A shared pool of evacuation reserves that can be drawn from by any +// evacuation category. Owned by ShenandoahGlobalCSetBudget; each +// ShenandoahEvacuationBudget holds a pointer to it. +struct ShenandoahSharedEvacReserve { + size_t limit; + size_t committed; + + ShenandoahSharedEvacReserve(size_t limit) : limit(limit), committed(0) {} +}; + +// Tracks the budget for a single evacuation category. +class ShenandoahEvacuationBudget { + size_t _reserve; + size_t _consumed; + size_t _live_bytes; + size_t _region_count; + size_t _region_size_bytes; + double _waste_factor; + ShenandoahSharedEvacReserve* _shared; + +public: + ShenandoahEvacuationBudget(size_t reserve, double waste_factor, + size_t region_size_bytes, + ShenandoahSharedEvacReserve* shared) + : _reserve(reserve), _consumed(0), _live_bytes(0), + _region_count(0), _region_size_bytes(region_size_bytes), + _waste_factor(waste_factor), _shared(shared) {} + + size_t anticipated_consumption(size_t live_bytes) const { + return (size_t)(live_bytes * _waste_factor); + } + + // Try to reserve 'bytes' from this budget, expanding from the shared + // pool if necessary. On success, updates _reserve and shared->committed + // and returns true. On failure, nothing is modified. + bool try_reserve(size_t bytes); + + // Record that a region was accepted. + void commit(size_t consumption, size_t live_bytes); + + // Record a raw consumption (e.g. free bytes lost from promo reserve). + void commit_raw(size_t bytes) { _consumed += bytes; } + + size_t reserve() const { return _reserve; } + size_t consumed() const { return _consumed; } + size_t live_bytes() const { return _live_bytes; } + size_t region_count() const { return _region_count; } + double waste_factor() const { return _waste_factor; } + + void add_to_reserve(size_t bytes) { _reserve += bytes; } + void set_reserve(size_t bytes) { _reserve = bytes; } +}; + +// These are the attributes of a region required to decide if it can be +// added to the collection set or not. +struct ShenandoahGlobalRegionAttributes { + size_t garbage; + size_t live_data_bytes; + size_t free_bytes; + bool is_old; + bool is_tenurable; +}; + +// This class consolidates all of the data required to build a global +// collection set. Critically, it takes no dependencies on any classes +// that themselves depend on ShenandoahHeap. This makes it possible to +// write extensive unit tests for this complex code. +class ShenandoahGlobalCSetBudget { + size_t _region_size_bytes; + size_t _garbage_threshold; + size_t _ignore_threshold; + size_t _min_garbage; + size_t _cur_garbage; + + ShenandoahSharedEvacReserve _shared; + +public: + ShenandoahEvacuationBudget young_evac; + ShenandoahEvacuationBudget old_evac; + ShenandoahEvacuationBudget promo; + + ShenandoahGlobalCSetBudget(size_t region_size_bytes, + size_t shared_reserves, + size_t garbage_threshold, + size_t ignore_threshold, + size_t min_garbage, + size_t young_evac_reserve, double young_waste, + size_t old_evac_reserve, double old_waste, + size_t promo_reserve, double promo_waste) + : _region_size_bytes(region_size_bytes), + _garbage_threshold(garbage_threshold), + _ignore_threshold(ignore_threshold), + _min_garbage(min_garbage), + _cur_garbage(0), + _shared(shared_reserves), + young_evac(young_evac_reserve, young_waste, region_size_bytes, &_shared), + old_evac(old_evac_reserve, old_waste, region_size_bytes, &_shared), + promo(promo_reserve, promo_waste, region_size_bytes, &_shared) {} + + ShenandoahGlobalRegionDisposition try_add_region(const ShenandoahGlobalRegionAttributes& region); + + // Any remaining shared budget is given to the promotion reserve. + void finish() { + if (_shared.committed < _shared.limit) { + promo.add_to_reserve(_shared.limit - _shared.committed); + } + } + + // Verify that the budget invariants hold after collection set selection. + // original_total_reserves is the sum of the young, old, and promo evacuation + // reserves as they were before the budget was constructed. + DEBUG_ONLY(void assert_budget_constraints_hold(size_t original_total_reserves) const;) + + size_t region_size_bytes() const { return _region_size_bytes; } + size_t shared_reserves() const { return _shared.limit; } + size_t committed_from_shared() const { return _shared.committed; } + size_t cur_garbage() const { return _cur_garbage; } + + void set_cur_garbage(size_t g) { _cur_garbage = g; } +}; + class ShenandoahGlobalHeuristics : public ShenandoahGenerationalHeuristics { public: ShenandoahGlobalHeuristics(ShenandoahGlobalGeneration* generation); @@ -50,5 +172,4 @@ private: size_t cur_young_garbage) const; }; - #endif // SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHGLOBALHEURISTICS_HPP diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp index 8fc744112bf..895088381ee 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp @@ -46,13 +46,16 @@ int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) { } ShenandoahHeuristics::ShenandoahHeuristics(ShenandoahSpaceInfo* space_info) : + _most_recent_trigger_evaluation_time(os::elapsedTime()), + _most_recent_planned_sleep_interval(0.0), _start_gc_is_pending(false), _declined_trigger_count(0), _most_recent_declined_trigger_count(0), _space_info(space_info), _region_data(nullptr), _guaranteed_gc_interval(0), - _cycle_start(os::elapsedTime()), + _precursor_cycle_start(os::elapsedTime()), + _cycle_start(_precursor_cycle_start), _last_cycle_end(0), _gc_times_learned(0), _gc_time_penalties(0), @@ -119,13 +122,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec } } else if (region->is_humongous_start()) { // Reclaim humongous regions here, and count them as the immediate garbage -#ifdef ASSERT - bool reg_live = region->has_live(); - bool bm_live = heap->global_generation()->complete_marking_context()->is_marked(cast_to_oop(region->bottom())); - assert(reg_live == bm_live, - "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: %zu", - BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words()); -#endif + DEBUG_ONLY(assert_humongous_mark_consistency(region)); if (!region->has_live()) { heap->trash_humongous_region_at(region); @@ -134,7 +131,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec immediate_garbage += garbage; } } else if (region->is_trash()) { - // Count in just trashed collection set, during coalesced CM-with-UR + // Count in just trashed humongous continuation regions immediate_regions++; immediate_garbage += garbage; } @@ -142,13 +139,11 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec // Step 2. Look back at garbage statistics, and decide if we want to collect anything, // given the amount of immediately reclaimable garbage. If we do, figure out the collection set. + assert(immediate_garbage <= total_garbage, + "Cannot have more immediate garbage than total garbage: " PROPERFMT " vs " PROPERFMT, + PROPERFMTARGS(immediate_garbage), PROPERFMTARGS(total_garbage)); - assert (immediate_garbage <= total_garbage, - "Cannot have more immediate garbage than total garbage: %zu%s vs %zu%s", - byte_size_in_proper_unit(immediate_garbage), proper_unit_for_byte_size(immediate_garbage), - byte_size_in_proper_unit(total_garbage), proper_unit_for_byte_size(total_garbage)); - - size_t immediate_percent = (total_garbage == 0) ? 0 : (immediate_garbage * 100 / total_garbage); + const size_t immediate_percent = (total_garbage == 0) ? 0 : (immediate_garbage * 100 / total_garbage); if (immediate_percent <= ShenandoahImmediateThreshold) { choose_collection_set_from_regiondata(collection_set, candidates, cand_idx, immediate_garbage + free); @@ -156,6 +151,19 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec collection_set->summarize(total_garbage, immediate_garbage, immediate_regions); } +void ShenandoahHeuristics::start_idle_span() { + // do nothing +} + +void ShenandoahHeuristics::record_degenerated_cycle_start(bool out_of_cycle) { + if (out_of_cycle) { + _precursor_cycle_start = _cycle_start = os::elapsedTime(); + } else { + _precursor_cycle_start = _cycle_start; + _cycle_start = os::elapsedTime(); + } +} + void ShenandoahHeuristics::record_cycle_start() { _cycle_start = os::elapsedTime(); } @@ -197,7 +205,6 @@ bool ShenandoahHeuristics::should_degenerate_cycle() { void ShenandoahHeuristics::adjust_penalty(intx step) { assert(0 <= _gc_time_penalties && _gc_time_penalties <= 100, "In range before adjustment: %zd", _gc_time_penalties); - if ((_most_recent_declined_trigger_count <= Penalty_Free_Declinations) && (step > 0)) { // Don't penalize if heuristics are not responsible for a negative outcome. Allow Penalty_Free_Declinations following // previous GC for self calibration without penalty. @@ -274,6 +281,30 @@ void ShenandoahHeuristics::initialize() { // Nothing to do by default. } +void ShenandoahHeuristics::post_initialize() { + // Nothing to do by default. +} + double ShenandoahHeuristics::elapsed_cycle_time() const { return os::elapsedTime() - _cycle_start; } + + +// Includes the time spent in abandoned concurrent GC cycle that may have triggered this degenerated cycle. +double ShenandoahHeuristics::elapsed_degenerated_cycle_time() const { + double now = os::elapsedTime(); + return now - _precursor_cycle_start; +} + +#ifdef ASSERT +void ShenandoahHeuristics::assert_humongous_mark_consistency(ShenandoahHeapRegion* region) { + assert(region->is_humongous(), "Region %zu must be humongous", region->index()); + const oop humongous_oop = cast_to_oop(region->bottom()); + ShenandoahGeneration* generation = ShenandoahHeap::heap()->generation_for(region->affiliation()); + const bool bm_live = generation->complete_marking_context()->is_marked(humongous_oop); + const bool reg_live = region->has_live(); + assert(reg_live == bm_live, + "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: %zu", + BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words()); +} +#endif diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp index 633c4e87126..9066cdfccac 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp @@ -78,6 +78,10 @@ class ShenandoahHeuristics : public CHeapObj { }; #endif +private: + double _most_recent_trigger_evaluation_time; + double _most_recent_planned_sleep_interval; + protected: static const uint Moving_Average_Samples = 10; // Number of samples to store in moving averages @@ -85,14 +89,13 @@ protected: size_t _declined_trigger_count; // This counts how many times since previous GC finished that this // heuristic has answered false to should_start_gc(). size_t _most_recent_declined_trigger_count; - ; // This represents the value of _declined_trigger_count as captured at the + // This represents the value of _declined_trigger_count as captured at the // moment the most recent GC effort was triggered. In case the most recent // concurrent GC effort degenerates, the value of this variable allows us to // differentiate between degeneration because heuristic was overly optimistic // in delaying the trigger vs. degeneration for other reasons (such as the // most recent GC triggered "immediately" after previous GC finished, but the // free headroom has already been depleted). - class RegionData { private: ShenandoahHeapRegion* _region; @@ -103,6 +106,7 @@ protected: #ifdef ASSERT UnionTag _union_tag; #endif + public: inline void clear() { @@ -171,6 +175,7 @@ protected: size_t _guaranteed_gc_interval; + double _precursor_cycle_start; double _cycle_start; double _last_cycle_end; @@ -188,7 +193,7 @@ protected: RegionData* data, size_t data_size, size_t free) = 0; - void adjust_penalty(intx step); + virtual void adjust_penalty(intx step); inline void accept_trigger() { _most_recent_declined_trigger_count = _declined_trigger_count; @@ -200,6 +205,14 @@ protected: _declined_trigger_count++; } + inline double get_most_recent_wake_time() const { + return _most_recent_trigger_evaluation_time; + } + + inline double get_planned_sleep_interval() const { + return _most_recent_planned_sleep_interval; + } + public: ShenandoahHeuristics(ShenandoahSpaceInfo* space_info); virtual ~ShenandoahHeuristics(); @@ -212,10 +225,22 @@ public: _guaranteed_gc_interval = guaranteed_gc_interval; } + virtual void start_idle_span(); + virtual void compute_headroom_adjustment() { + // Default implementation does nothing. + } + virtual void record_cycle_start(); + void record_degenerated_cycle_start(bool out_of_cycle); + virtual void record_cycle_end(); + void update_should_start_query_times(double now, double planned_sleep_interval) { + _most_recent_trigger_evaluation_time = now; + _most_recent_planned_sleep_interval = planned_sleep_interval; + } + virtual bool should_start_gc(); inline void cancel_trigger_request() { @@ -248,8 +273,10 @@ public: virtual bool is_diagnostic() = 0; virtual bool is_experimental() = 0; virtual void initialize(); + virtual void post_initialize(); double elapsed_cycle_time() const; + double elapsed_degenerated_cycle_time() const; virtual size_t force_alloc_rate_sample(size_t bytes_allocated) { // do nothing @@ -258,6 +285,8 @@ public: // Format prefix and emit log message indicating a GC cycle hs been triggered void log_trigger(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3); + + DEBUG_ONLY(static void assert_humongous_mark_consistency(ShenandoahHeapRegion* region)); }; #endif // SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp index e0cab781674..33c91e27be5 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp @@ -79,7 +79,6 @@ ShenandoahOldHeuristics::ShenandoahOldHeuristics(ShenandoahOldGeneration* genera } bool ShenandoahOldHeuristics::prime_collection_set(ShenandoahCollectionSet* collection_set) { - _mixed_evac_cset = collection_set; _included_old_regions = 0; _evacuated_old_bytes = 0; _collected_old_bytes = 0; @@ -106,10 +105,6 @@ bool ShenandoahOldHeuristics::prime_collection_set(ShenandoahCollectionSet* coll _first_pinned_candidate = NOT_FOUND; - uint included_old_regions = 0; - size_t evacuated_old_bytes = 0; - size_t collected_old_bytes = 0; - // If a region is put into the collection set, then this region's free (not yet used) bytes are no longer // "available" to hold the results of other evacuations. This may cause a decrease in the remaining amount // of memory that can still be evacuated. We address this by reducing the evacuation budget by the amount @@ -152,7 +147,7 @@ bool ShenandoahOldHeuristics::prime_collection_set(ShenandoahCollectionSet* coll log_debug(gc)("Choose old regions for mixed collection: old evacuation budget: " PROPERFMT ", candidates: %u", PROPERFMTARGS(_old_evacuation_budget), unprocessed_old_collection_candidates()); - return add_old_regions_to_cset(); + return add_old_regions_to_cset(collection_set); } bool ShenandoahOldHeuristics::all_candidates_are_pinned() { @@ -226,7 +221,7 @@ void ShenandoahOldHeuristics::slide_pinned_regions_to_front() { _next_old_collection_candidate = write_index + 1; } -bool ShenandoahOldHeuristics::add_old_regions_to_cset() { +bool ShenandoahOldHeuristics::add_old_regions_to_cset(ShenandoahCollectionSet* collection_set) { if (unprocessed_old_collection_candidates() == 0) { return false; } @@ -310,7 +305,7 @@ bool ShenandoahOldHeuristics::add_old_regions_to_cset() { break; } } - _mixed_evac_cset->add_region(r); + collection_set->add_region(r); _included_old_regions++; _evacuated_old_bytes += live_data_for_evacuation; _collected_old_bytes += r->garbage(); @@ -356,7 +351,7 @@ bool ShenandoahOldHeuristics::finalize_mixed_evacs() { return (_included_old_regions > 0); } -bool ShenandoahOldHeuristics::top_off_collection_set(size_t &add_regions_to_old) { +bool ShenandoahOldHeuristics::top_off_collection_set(ShenandoahCollectionSet* collection_set, size_t &add_regions_to_old) { if (unprocessed_old_collection_candidates() == 0) { add_regions_to_old = 0; return false; @@ -367,15 +362,13 @@ bool ShenandoahOldHeuristics::top_off_collection_set(size_t &add_regions_to_old) // We have budgeted to assure the live_bytes_in_tenurable_regions() get evacuated into old generation. Young reserves // only for untenurable region evacuations. - size_t planned_young_evac = _mixed_evac_cset->get_live_bytes_in_untenurable_regions(); + size_t planned_young_evac = collection_set->get_live_bytes_in_untenurable_regions(); size_t consumed_from_young_cset = (size_t) (planned_young_evac * ShenandoahEvacWaste); size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes(); - size_t regions_required_for_collector_reserve = (consumed_from_young_cset + region_size_bytes - 1) / region_size_bytes; assert(consumed_from_young_cset <= max_young_cset, "sanity"); assert(max_young_cset <= young_unaffiliated_regions * region_size_bytes, "sanity"); - size_t regions_for_old_expansion; if (consumed_from_young_cset < max_young_cset) { size_t excess_young_reserves = max_young_cset - consumed_from_young_cset; @@ -398,8 +391,11 @@ bool ShenandoahOldHeuristics::top_off_collection_set(size_t &add_regions_to_old) _unspent_unfragmented_old_budget += supplement_without_waste; _old_generation->augment_evacuation_reserve(budget_supplement); young_generation->set_evacuation_reserve(max_young_cset - budget_supplement); - - return add_old_regions_to_cset(); + assert(young_generation->get_evacuation_reserve() >= + collection_set->get_live_bytes_in_untenurable_regions() * ShenandoahEvacWaste, + "adjusted evac reserve (%zu) must be large enough for planned evacuation (%zu)", + young_generation->get_evacuation_reserve(), collection_set->get_live_bytes_in_untenurable_regions()); + return add_old_regions_to_cset(collection_set); } else { add_regions_to_old = 0; return false; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp index e657ac58ae4..04a92d28248 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp @@ -106,7 +106,6 @@ private: // when client code invokes prime_collection_set(). They are consulted, and sometimes modified, when client code // calls top_off_collection_set() to possibly expand the number of old-gen regions in a mixed evacuation cset, and by // finalize_mixed_evacs(), which prepares the way for mixed evacuations to begin. - ShenandoahCollectionSet* _mixed_evac_cset; size_t _evacuated_old_bytes; size_t _collected_old_bytes; size_t _included_old_regions; @@ -163,7 +162,7 @@ private: // a conservative old evacuation budget, and the second time with a larger more aggressive old evacuation budget. Returns // true iff we need to finalize mixed evacs. (If no regions are added to the collection set, there is no need to finalize // mixed evacuations.) - bool add_old_regions_to_cset(); + bool add_old_regions_to_cset(ShenandoahCollectionSet* collection_set); public: explicit ShenandoahOldHeuristics(ShenandoahOldGeneration* generation, ShenandoahGenerationalHeap* gen_heap); @@ -180,7 +179,7 @@ public: // evacuation candidate regions into the collection set as will fit within this excess repurposed reserved. // Returns true iff we need to finalize mixed evacs. Upon return, the var parameter regions_to_xfer holds the // number of regions to transfer from young to old. - bool top_off_collection_set(size_t &add_regions_to_old); + bool top_off_collection_set(ShenandoahCollectionSet* collection_set, size_t &add_regions_to_old); // Having added all eligible mixed-evacuation candidates to the collection set, this function updates the total count // of how much old-gen memory remains to be evacuated and adjusts the representation of old-gen regions that remain to diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp index beff2200d90..68ffb6592db 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp @@ -54,15 +54,13 @@ void ShenandoahYoungHeuristics::choose_collection_set_from_regiondata(Shenandoah // Better select garbage-first regions QuickSort::sort(data, size, compare_by_garbage); - size_t cur_young_garbage = add_preselected_regions_to_collection_set(cset, data, size); - - choose_young_collection_set(cset, data, size, actual_free, cur_young_garbage); + choose_young_collection_set(cset, data, size, actual_free); // Especially when young-gen trigger is expedited in order to finish mixed evacuations, there may not be // enough consolidated garbage to make effective use of young-gen evacuation reserve. If there is still // young-gen reserve available following selection of the young-gen collection set, see if we can use // this memory to expand the old-gen evacuation collection set. - need_to_finalize_mixed |= heap->old_generation()->heuristics()->top_off_collection_set(_add_regions_to_old); + need_to_finalize_mixed |= heap->old_generation()->heuristics()->top_off_collection_set(cset, _add_regions_to_old); if (need_to_finalize_mixed) { heap->old_generation()->heuristics()->finalize_mixed_evacs(); } @@ -70,8 +68,7 @@ void ShenandoahYoungHeuristics::choose_collection_set_from_regiondata(Shenandoah void ShenandoahYoungHeuristics::choose_young_collection_set(ShenandoahCollectionSet* cset, const RegionData* data, - size_t size, size_t actual_free, - size_t cur_young_garbage) const { + size_t size, size_t actual_free) const { const auto heap = ShenandoahGenerationalHeap::heap(); @@ -82,23 +79,23 @@ void ShenandoahYoungHeuristics::choose_young_collection_set(ShenandoahCollection // This is young-gen collection or a mixed evacuation. // If this is mixed evacuation, the old-gen candidate regions have already been added. size_t cur_cset = 0; + size_t cur_young_garbage = cset->garbage(); const size_t max_cset = (size_t) (heap->young_generation()->get_evacuation_reserve() / ShenandoahEvacWaste); const size_t free_target = (capacity * ShenandoahMinFreeThreshold) / 100 + max_cset; const size_t min_garbage = (free_target > actual_free) ? (free_target - actual_free) : 0; - log_info(gc, ergo)( - "Adaptive CSet Selection for YOUNG. Max Evacuation: %zu%s, Actual Free: %zu%s.", - byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset), - byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free)); + "Adaptive CSet Selection for YOUNG. Max Evacuation: " PROPERFMT ", Actual Free: " PROPERFMT, + PROPERFMTARGS(max_cset), PROPERFMTARGS(actual_free)); for (size_t idx = 0; idx < size; idx++) { ShenandoahHeapRegion* r = data[idx].get_region(); - if (cset->is_preselected(r->index())) { + if (cset->is_in(r) || r->get_top_before_promote() != nullptr) { + assert(heap->is_tenurable(r), "Region %zu already selected for promotion must be tenurable", idx); continue; } - // Note that we do not add tenurable regions if they were not pre-selected. They were not preselected + // Note that we do not add tenurable regions if they were not pre-selected. They were not selected // because there is insufficient room in old-gen to hold their to-be-promoted live objects or because // they are to be promoted in place. if (!heap->is_tenurable(r)) { @@ -137,6 +134,7 @@ bool ShenandoahYoungHeuristics::should_start_gc() { // inherited triggers have already decided to start a cycle, so no further evaluation is required if (ShenandoahAdaptiveHeuristics::should_start_gc()) { + // ShenandoahAdaptiveHeuristics::should_start_gc() has already accepted trigger, or declined it. return true; } @@ -178,11 +176,9 @@ size_t ShenandoahYoungHeuristics::bytes_of_allocation_runway_before_gc_trigger(s size_t capacity = _space_info->max_capacity(); size_t usage = _space_info->used(); size_t available = (capacity > usage)? capacity - usage: 0; - size_t allocated = _space_info->bytes_allocated_since_gc_start(); + size_t allocated = _free_set->get_bytes_allocated_since_gc_start(); + size_t anticipated_available = available + young_regions_to_be_reclaimed * ShenandoahHeapRegion::region_size_bytes(); - size_t available_young_collected = ShenandoahHeap::heap()->collection_set()->get_young_available_bytes_collected(); - size_t anticipated_available = - available + young_regions_to_be_reclaimed * ShenandoahHeapRegion::region_size_bytes() - available_young_collected; size_t spike_headroom = capacity * ShenandoahAllocSpikeFactor / 100; size_t penalties = capacity * _gc_time_penalties / 100; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp index b9d64059680..806cef673d5 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp @@ -49,8 +49,7 @@ public: private: void choose_young_collection_set(ShenandoahCollectionSet* cset, const RegionData* data, - size_t size, size_t actual_free, - size_t cur_young_garbage) const; + size_t size, size_t actual_free) const; }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp index 86ff6f22c72..71fd6e37614 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp @@ -57,21 +57,13 @@ ShenandoahAgeCensus::ShenandoahAgeCensus(uint max_workers) // Sentinel value _tenuring_threshold[i] = MAX_COHORTS; } - if (ShenandoahGenerationalAdaptiveTenuring) { - _local_age_tables = NEW_C_HEAP_ARRAY(AgeTable*, _max_workers, mtGC); - CENSUS_NOISE(_local_noise = NEW_C_HEAP_ARRAY(ShenandoahNoiseStats, max_workers, mtGC);) - for (uint i = 0; i < _max_workers; i++) { - _local_age_tables[i] = new AgeTable(false); - CENSUS_NOISE(_local_noise[i].clear();) - } - } else { - _local_age_tables = nullptr; + _local_age_tables = NEW_C_HEAP_ARRAY(AgeTable*, _max_workers, mtGC); + CENSUS_NOISE(_local_noise = NEW_C_HEAP_ARRAY(ShenandoahNoiseStats, max_workers, mtGC);) + for (uint i = 0; i < _max_workers; i++) { + _local_age_tables[i] = new AgeTable(false); + CENSUS_NOISE(_local_noise[i].clear();) } _epoch = MAX_SNAPSHOTS - 1; // see prepare_for_census_update() - - if (!ShenandoahGenerationalAdaptiveTenuring) { - _tenuring_threshold[_epoch] = InitialTenuringThreshold; - } } ShenandoahAgeCensus::~ShenandoahAgeCensus() { @@ -154,7 +146,6 @@ void ShenandoahAgeCensus::prepare_for_census_update() { // and compute the new tenuring threshold. void ShenandoahAgeCensus::update_census(size_t age0_pop) { prepare_for_census_update(); - assert(ShenandoahGenerationalAdaptiveTenuring, "Only update census when adaptive tenuring is enabled"); assert(_global_age_tables[_epoch]->is_clear(), "Dirty decks"); CENSUS_NOISE(assert(_global_noise[_epoch].is_clear(), "Dirty decks");) @@ -195,10 +186,6 @@ void ShenandoahAgeCensus::reset_global() { // Reset the local age tables, clearing any partial census. void ShenandoahAgeCensus::reset_local() { - if (!ShenandoahGenerationalAdaptiveTenuring) { - assert(_local_age_tables == nullptr, "Error"); - return; - } for (uint i = 0; i < _max_workers; i++) { _local_age_tables[i]->clear(); CENSUS_NOISE(_local_noise[i].clear();) @@ -221,10 +208,6 @@ bool ShenandoahAgeCensus::is_clear_global() { // Is local census information clear? bool ShenandoahAgeCensus::is_clear_local() { - if (!ShenandoahGenerationalAdaptiveTenuring) { - assert(_local_age_tables == nullptr, "Error"); - return true; - } for (uint i = 0; i < _max_workers; i++) { bool clear = _local_age_tables[i]->is_clear(); CENSUS_NOISE(clear |= _local_noise[i].is_clear();) @@ -258,7 +241,6 @@ void ShenandoahAgeCensus::update_total() { #endif // !PRODUCT void ShenandoahAgeCensus::update_tenuring_threshold() { - assert(ShenandoahGenerationalAdaptiveTenuring, "Only update when adaptive tenuring is enabled"); uint tt = compute_tenuring_threshold(); assert(tt <= MAX_COHORTS, "Out of bounds"); _tenuring_threshold[_epoch] = tt; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.hpp b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.hpp index 39ea4ee9002..9c5baaedcd6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.hpp @@ -97,6 +97,8 @@ struct ShenandoahNoiseStats { // once the per-worker data is consolidated into the appropriate population vector // per minor collection. The _local_age_table is thus C x N, for N GC workers. class ShenandoahAgeCensus: public CHeapObj { + friend class ShenandoahTenuringOverride; + AgeTable** _global_age_tables; // Global age tables used for adapting tenuring threshold, one per snapshot AgeTable** _local_age_tables; // Local scratch age tables to track object ages, one per worker @@ -148,6 +150,10 @@ class ShenandoahAgeCensus: public CHeapObj { return _tenuring_threshold[prev]; } + // Override the tenuring threshold for the current epoch. This is used to + // cause everything to be promoted for a whitebox full gc request. + void set_tenuring_threshold(uint threshold) { _tenuring_threshold[_epoch] = threshold; } + #ifndef PRODUCT // Return the sum of size of objects of all ages recorded in the // census at snapshot indexed by snap. @@ -173,7 +179,6 @@ class ShenandoahAgeCensus: public CHeapObj { ~ShenandoahAgeCensus(); // Return the local age table (population vector) for worker_id. - // Only used in the case of ShenandoahGenerationalAdaptiveTenuring AgeTable* get_local_age_table(uint worker_id) const { return _local_age_tables[worker_id]; } @@ -233,4 +238,26 @@ class ShenandoahAgeCensus: public CHeapObj { void print(); }; +// RAII object that temporarily overrides the tenuring threshold for the +// duration of a scope, restoring the original value on destruction. +// Used to force promotion of all young objects during whitebox full GCs. +class ShenandoahTenuringOverride : public StackObj { + ShenandoahAgeCensus* _census; + uint _saved_threshold; + bool _active; +public: + ShenandoahTenuringOverride(bool active, ShenandoahAgeCensus* census) : + _census(census), _saved_threshold(0), _active(active) { + if (_active) { + _saved_threshold = _census->tenuring_threshold(); + _census->set_tenuring_threshold(0); + } + } + ~ShenandoahTenuringOverride() { + if (_active) { + _census->set_tenuring_threshold(_saved_threshold); + } + } +}; + #endif // SHARE_GC_SHENANDOAH_SHENANDOAHAGECENSUS_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp index baeaffb9c7b..268f5b13035 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp @@ -559,26 +559,24 @@ bool ShenandoahAsserts::extract_klass_safely(oop obj, narrowKlass& nk, const Kla if (!os::is_readable_pointer(obj)) { return false; } - if (UseCompressedClassPointers) { - if (UseCompactObjectHeaders) { // look in forwardee - markWord mark = obj->mark(); - if (mark.is_marked()) { - oop fwd = cast_to_oop(mark.clear_lock_bits().to_pointer()); - if (!os::is_readable_pointer(fwd)) { - return false; - } - mark = fwd->mark(); + + if (UseCompactObjectHeaders) { // look in forwardee + markWord mark = obj->mark(); + if (mark.is_marked()) { + oop fwd = cast_to_oop(mark.clear_lock_bits().to_pointer()); + if (!os::is_readable_pointer(fwd)) { + return false; } - nk = mark.narrow_klass(); - } else { - nk = obj->narrow_klass(); + mark = fwd->mark(); } - if (!CompressedKlassPointers::is_valid_narrow_klass_id(nk)) { - return false; - } - k = CompressedKlassPointers::decode_not_null_without_asserts(nk); + nk = mark.narrow_klass(); } else { - k = obj->klass(); + nk = obj->narrow_klass(); } + if (!CompressedKlassPointers::is_valid_narrow_klass_id(nk)) { + return false; + } + k = CompressedKlassPointers::decode_not_null_without_asserts(nk); + return k != nullptr; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp index 004558a9fa8..cb6ff795c07 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp @@ -166,10 +166,9 @@ void ShenandoahBarrierSet::on_thread_detach(Thread *thread) { gclab->retire(); } - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - if (plab != nullptr) { - // This will assert if plab is not null in non-generational mode - ShenandoahGenerationalHeap::heap()->retire_plab(plab); + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + if (shenandoah_plab != nullptr) { + shenandoah_plab->retire(); } // SATB protocol requires to keep alive reachable oops from roots at the beginning of GC diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp index c6e6108fda8..2be5722f7f9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp @@ -41,9 +41,9 @@ bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) { return true; } - ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm); + ShenandoahNMethodLock* lock = ShenandoahNMethod::lock_for_nmethod(nm); assert(lock != nullptr, "Must be"); - ShenandoahReentrantLocker locker(lock); + ShenandoahNMethodLocker locker(lock); if (!is_armed(nm)) { // Some other thread managed to complete while we were diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp index 07d339eb32e..64e135e9a4e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp @@ -136,13 +136,13 @@ public: assert(!nm_data->is_unregistered(), "Should not see unregistered entry"); if (nm->is_unloading()) { - ShenandoahReentrantLocker locker(nm_data->lock()); + ShenandoahNMethodLocker locker(nm_data->lock()); nm->unlink(); return; } { - ShenandoahReentrantLocker locker(nm_data->lock()); + ShenandoahNMethodLocker locker(nm_data->lock()); // Heal oops if (_bs->is_armed(nm)) { @@ -154,7 +154,7 @@ public: } // Clear compiled ICs and exception caches - ShenandoahReentrantLocker locker(nm_data->ic_lock()); + ShenandoahNMethodLocker locker(nm_data->ic_lock()); nm->unload_nmethod_caches(_unloading_occurred); } }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp index c1c6b876d90..d2a489a15be 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp @@ -49,7 +49,6 @@ ShenandoahCollectionSet::ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedS _live(0), _region_count(0), _old_garbage(0), - _preselected_regions(nullptr), _young_available_bytes_collected(0), _old_available_bytes_collected(0), _current_index(0) { @@ -136,7 +135,7 @@ void ShenandoahCollectionSet::clear() { _live = 0; _region_count = 0; - _current_index = 0; + _current_index.store_relaxed(0); _young_bytes_to_evacuate = 0; _young_bytes_to_promote = 0; @@ -154,11 +153,11 @@ ShenandoahHeapRegion* ShenandoahCollectionSet::claim_next() { // before hitting the (potentially contended) atomic index. size_t max = _heap->num_regions(); - size_t old = AtomicAccess::load(&_current_index); + size_t old = _current_index.load_relaxed(); for (size_t index = old; index < max; index++) { if (is_in(index)) { - size_t cur = AtomicAccess::cmpxchg(&_current_index, old, index + 1, memory_order_relaxed); + size_t cur = _current_index.compare_exchange(old, index + 1, memory_order_relaxed); assert(cur >= old, "Always move forward"); if (cur == old) { // Successfully moved the claim index, this is our region. @@ -178,9 +177,9 @@ ShenandoahHeapRegion* ShenandoahCollectionSet::next() { assert(Thread::current()->is_VM_thread(), "Must be VMThread"); size_t max = _heap->num_regions(); - for (size_t index = _current_index; index < max; index++) { + for (size_t index = _current_index.load_relaxed(); index < max; index++) { if (is_in(index)) { - _current_index = index + 1; + _current_index.store_relaxed(index + 1); return _heap->get_region(index); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp index c99271de1fb..7722423709d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp @@ -32,16 +32,10 @@ #include "memory/allocation.hpp" #include "memory/reservedSpace.hpp" #include "memory/virtualspace.hpp" +#include "runtime/atomic.hpp" class ShenandoahCollectionSet : public CHeapObj { friend class ShenandoahHeap; - friend class ShenandoahCollectionSetPreselector; - - void establish_preselected(bool *preselected) { - assert(_preselected_regions == nullptr, "Over-writing"); - _preselected_regions = preselected; - } - void abandon_preselected() { _preselected_regions = nullptr; } private: size_t const _map_size; @@ -66,11 +60,6 @@ private: // How many bytes of old garbage are present in a mixed collection set? size_t _old_garbage; - // Points to array identifying which tenure-age regions have been preselected - // for inclusion in collection set. This field is only valid during brief - // spans of time while collection set is being constructed. - bool* _preselected_regions; - // When a region having memory available to be allocated is added to the collection set, the region's available memory // should be subtracted from what's available. size_t _young_available_bytes_collected; @@ -80,7 +69,7 @@ private: size_t _old_available_bytes_collected; shenandoah_padding(0); - volatile size_t _current_index; + Atomic _current_index; shenandoah_padding(1); public: @@ -99,7 +88,7 @@ public: bool is_empty() const { return _region_count == 0; } void clear_current_index() { - _current_index = 0; + _current_index.store_relaxed(0); } inline bool is_in(ShenandoahHeapRegion* r) const; @@ -131,16 +120,6 @@ public: // Returns the amount of garbage in old regions in the collection set. inline size_t get_old_garbage() const; - bool is_preselected(size_t region_idx) { - assert(_preselected_regions != nullptr, "Missing establish after abandon"); - return _preselected_regions[region_idx]; - } - - bool* preselected_regions() { - assert(_preselected_regions != nullptr, "Null ptr"); - return _preselected_regions; - } - bool has_old_regions() const { return _has_old_regions; } size_t used() const { return _used; } size_t live() const { return _live; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSetPreselector.hpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSetPreselector.hpp deleted file mode 100644 index b78259dd85b..00000000000 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSetPreselector.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright Amazon.com Inc. 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. - * - */ - -#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSETPRESELECTOR_HPP -#define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSETPRESELECTOR_HPP - -#include "gc/shenandoah/shenandoahCollectionSet.hpp" -#include "memory/resourceArea.hpp" - -class ShenandoahCollectionSetPreselector : public StackObj { - ShenandoahCollectionSet* _cset; - bool* _pset; - ResourceMark _rm; - -public: - ShenandoahCollectionSetPreselector(ShenandoahCollectionSet* cset, size_t num_regions): - _cset(cset) { - _pset = NEW_RESOURCE_ARRAY(bool, num_regions); - for (unsigned int i = 0; i < num_regions; i++) { - _pset[i] = false; - } - _cset->establish_preselected(_pset); - } - - ~ShenandoahCollectionSetPreselector() { - _cset->abandon_preselected(); - } -}; - -#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSETPRESELECTOR_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index 364279deafe..f0125c38cae 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -1023,7 +1023,7 @@ public: void do_nmethod(nmethod* n) { ShenandoahNMethod* data = ShenandoahNMethod::gc_data(n); - ShenandoahReentrantLocker locker(data->lock()); + ShenandoahNMethodLocker locker(data->lock()); // Setup EvacOOM scope below reentrant lock to avoid deadlock with // nmethod_entry_barrier ShenandoahEvacOOMScope oom; @@ -1215,6 +1215,7 @@ void ShenandoahConcurrentGC::op_final_update_refs() { } heap->rebuild_free_set(true /*concurrent*/); + _generation->heuristics()->start_idle_span(); { ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::final_update_refs_propagate_gc_state); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index bc11659c5e5..4c6e82c86a5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -45,7 +45,7 @@ ShenandoahControlThread::ShenandoahControlThread() : _requested_gc_cause(GCCause::_no_gc), _degen_point(ShenandoahGC::_degenerated_outside_cycle), _control_lock(CONTROL_LOCK_RANK, "ShenandoahControl_lock", true) { - set_name("Shenandoah Control Thread"); + set_name("ShenControl"); create_and_start(); } @@ -59,6 +59,7 @@ void ShenandoahControlThread::run_service() { ShenandoahCollectorPolicy* const policy = heap->shenandoah_policy(); ShenandoahHeuristics* const heuristics = heap->heuristics(); + double most_recent_wake_time = os::elapsedTime(); while (!should_terminate()) { const GCCause::Cause cancelled_cause = heap->cancelled_cause(); if (cancelled_cause == GCCause::_shenandoah_stop_vm) { @@ -137,7 +138,10 @@ void ShenandoahControlThread::run_service() { heuristics->cancel_trigger_request(); - heap->reset_bytes_allocated_since_gc_start(); + if (mode != stw_degenerated) { + // If mode is stw_degenerated, count bytes allocated from the start of the conc GC that experienced alloc failure. + heap->reset_bytes_allocated_since_gc_start(); + } MetaspaceCombinedStats meta_sizes = MetaspaceUtils::get_combined_statistics(); @@ -222,16 +226,26 @@ void ShenandoahControlThread::run_service() { // Wait before performing the next action. If allocation happened during this wait, // we exit sooner, to let heuristics re-evaluate new conditions. If we are at idle, // back off exponentially. - const double current = os::elapsedTime(); + const double before_sleep = most_recent_wake_time; if (heap->has_changed()) { sleep = ShenandoahControlIntervalMin; - } else if ((current - last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){ + } else if ((before_sleep - last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){ sleep = MIN2(ShenandoahControlIntervalMax, MAX2(1, sleep * 2)); - last_sleep_adjust_time = current; + last_sleep_adjust_time = before_sleep; } - MonitorLocker ml(&_control_lock, Mutex::_no_safepoint_check_flag); ml.wait(sleep); + // Record a conservative estimate of the longest anticipated sleep duration until we sample again. + double planned_sleep_interval = MIN2(ShenandoahControlIntervalMax, MAX2(1, sleep * 2)) / 1000.0; + most_recent_wake_time = os::elapsedTime(); + heuristics->update_should_start_query_times(most_recent_wake_time, planned_sleep_interval); + if (LogTarget(Debug, gc, thread)::is_enabled()) { + double elapsed = most_recent_wake_time - before_sleep; + double hiccup = elapsed - double(sleep); + if (hiccup > 0.001) { + log_debug(gc, thread)("Control Thread hiccup time: %.3fs", hiccup); + } + } } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp index 220f3df8d4f..50aabad7d42 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp @@ -31,11 +31,11 @@ void ShenandoahController::update_gc_id() { - AtomicAccess::inc(&_gc_id); + _gc_id.add_then_fetch((size_t)1); } size_t ShenandoahController::get_gc_id() { - return AtomicAccess::load(&_gc_id); + return _gc_id.load_relaxed(); } void ShenandoahController::handle_alloc_failure(const ShenandoahAllocRequest& req, bool block) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp index b8ff4df4771..60b41a5fe99 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp @@ -29,6 +29,7 @@ #include "gc/shared/gcCause.hpp" #include "gc/shenandoah/shenandoahAllocRequest.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" +#include "runtime/atomic.hpp" /** * This interface exposes methods necessary for the heap to interact @@ -38,7 +39,7 @@ class ShenandoahController: public ConcurrentGCThread { private: shenandoah_padding(0); // A monotonically increasing GC count. - volatile size_t _gc_id; + Atomic _gc_id; shenandoah_padding(1); protected: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index 99776e38bfe..8cd8a390c4a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -314,6 +314,7 @@ void ShenandoahDegenGC::op_degenerated() { if (progress) { heap->notify_gc_progress(); _generation->heuristics()->record_degenerated(); + heap->start_idle_span(); } else if (policy->should_upgrade_degenerated_gc()) { // Upgrade to full GC, register full-GC impact on heuristics. op_degenerated_futile(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp index dd09bec8a7c..5b24140ac1c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp @@ -37,22 +37,22 @@ ShenandoahEvacOOMCounter::ShenandoahEvacOOMCounter() : void ShenandoahEvacOOMCounter::decrement() { assert(unmasked_count() > 0, "sanity"); // NOTE: It's ok to simply decrement, even with mask set, because unmasked value is positive. - AtomicAccess::dec(&_bits); + _bits.fetch_then_sub(1); } void ShenandoahEvacOOMCounter::clear() { assert(unmasked_count() == 0, "sanity"); - AtomicAccess::release_store_fence(&_bits, (jint)0); + _bits.release_store_fence((jint)0); } void ShenandoahEvacOOMCounter::set_oom_bit(bool decrement) { - jint threads_in_evac = AtomicAccess::load_acquire(&_bits); + jint threads_in_evac = _bits.load_acquire(); while (true) { jint newval = decrement ? (threads_in_evac - 1) | OOM_MARKER_MASK : threads_in_evac | OOM_MARKER_MASK; - jint other = AtomicAccess::cmpxchg(&_bits, threads_in_evac, newval); + jint other = _bits.compare_exchange(threads_in_evac, newval); if (other == threads_in_evac) { // Success: wait for other threads to get out of the protocol and return. break; @@ -65,7 +65,7 @@ void ShenandoahEvacOOMCounter::set_oom_bit(bool decrement) { bool ShenandoahEvacOOMCounter::try_increment() { - jint threads_in_evac = AtomicAccess::load_acquire(&_bits); + jint threads_in_evac = _bits.load_acquire(); while (true) { // Cannot enter evacuation if OOM_MARKER_MASK is set. @@ -73,7 +73,7 @@ bool ShenandoahEvacOOMCounter::try_increment() return false; } - jint other = AtomicAccess::cmpxchg(&_bits, threads_in_evac, threads_in_evac + 1); + jint other = _bits.compare_exchange(threads_in_evac, threads_in_evac + 1); if (other == threads_in_evac) { // Success: caller may safely enter evacuation return true; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp index dd77f6216e0..3e28d9ac88e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp @@ -27,6 +27,7 @@ #include "gc/shenandoah/shenandoahPadding.hpp" #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "utilities/globalDefinitions.hpp" @@ -36,7 +37,7 @@ class ShenandoahEvacOOMCounter { private: // Combination of a 31-bit counter and 1-bit OOM marker. - volatile jint _bits; + Atomic _bits; // This class must be at least a cache line in size to prevent false sharing. shenandoah_padding_minus_size(0, sizeof(jint)); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp index 11509ec9d2d..4bd4381068a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp @@ -29,14 +29,13 @@ #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "runtime/atomicAccess.hpp" jint ShenandoahEvacOOMCounter::load_acquire() { - return AtomicAccess::load_acquire(&_bits); + return _bits.load_acquire(); } jint ShenandoahEvacOOMCounter::unmasked_count() { - return AtomicAccess::load_acquire(&_bits) & ~OOM_MARKER_MASK; + return _bits.load_acquire() & ~OOM_MARKER_MASK; } void ShenandoahEvacOOMHandler::enter_evacuation(Thread* thr) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp index c4fe9103fcb..a579d6d3694 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp @@ -287,9 +287,25 @@ void ShenandoahFreeSet::resize_old_collector_capacity(size_t regions) { // else, old generation is already appropriately sized } + void ShenandoahFreeSet::reset_bytes_allocated_since_gc_start(size_t initial_bytes_allocated) { shenandoah_assert_heaplocked(); + // Future inquiries of get_total_bytes_allocated() will return the sum of + // _total_bytes_previously_allocated and _mutator_bytes_allocated_since_gc_start. + // Since _mutator_bytes_allocated_since_gc_start does not start at zero, we subtract initial_bytes_allocated so as + // to not double count these allocated bytes. + size_t original_mutator_bytes_allocated_since_gc_start = _mutator_bytes_allocated_since_gc_start; + + // Setting _mutator_bytes_allocated_since_gc_start before _total_bytes_previously_allocated reduces the damage + // in the case that the control or regulator thread queries get_bytes_allocated_since_previous_sample() between + // the two assignments. + // + // These are not declared as volatile so the compiler or hardware may reorder the assignments. The implementation of + // get_bytes_allocated_since_previous_cycle() is robust to this possibility, as are triggering heuristics. The current + // implementation assumes we are better off to tolerate the very rare race rather than impose a synchronization penalty + // on every update and fetch. (Perhaps it would be better to make the opposite tradeoff for improved maintainability.) _mutator_bytes_allocated_since_gc_start = initial_bytes_allocated; + _total_bytes_previously_allocated += original_mutator_bytes_allocated_since_gc_start - initial_bytes_allocated; } void ShenandoahFreeSet::increase_bytes_allocated(size_t bytes) { @@ -332,7 +348,7 @@ void ShenandoahRegionPartitions::make_all_regions_unavailable() { _leftmosts[partition_id] = _max; _rightmosts[partition_id] = -1; _leftmosts_empty[partition_id] = _max; - _rightmosts_empty[partition_id] = -1;; + _rightmosts_empty[partition_id] = -1; _capacity[partition_id] = 0; _region_counts[partition_id] = 0; _empty_region_counts[partition_id] = 0; @@ -429,7 +445,7 @@ void ShenandoahRegionPartitions::increase_humongous_waste(ShenandoahFreeSetParti size_t ShenandoahRegionPartitions::get_humongous_waste(ShenandoahFreeSetPartitionId which_partition) { assert (which_partition < NumPartitions, "Partition must be valid"); - return _humongous_waste[int(which_partition)];; + return _humongous_waste[int(which_partition)]; } void ShenandoahRegionPartitions::set_capacity_of(ShenandoahFreeSetPartitionId which_partition, size_t value) { @@ -494,7 +510,7 @@ void ShenandoahRegionPartitions::decrease_available(ShenandoahFreeSetPartitionId size_t ShenandoahRegionPartitions::get_available(ShenandoahFreeSetPartitionId which_partition) { assert (which_partition < NumPartitions, "Partition must be valid"); - return _available[int(which_partition)];; + return _available[int(which_partition)]; } void ShenandoahRegionPartitions::increase_region_counts(ShenandoahFreeSetPartitionId which_partition, size_t regions) { @@ -1194,11 +1210,25 @@ void ShenandoahRegionPartitions::assert_bounds() { assert(_humongous_waste[int(ShenandoahFreeSetPartitionId::Mutator)] == young_humongous_waste, "Mutator humongous waste must match"); } + +inline void ShenandoahRegionPartitions::assert_bounds_sanity() { + for (uint8_t i = 0; i < UIntNumPartitions; i++) { + ShenandoahFreeSetPartitionId partition = static_cast(i); + assert(leftmost(partition) == _max || membership(leftmost(partition)) == partition, "Left most boundry must be sane"); + assert(rightmost(partition) == -1 || membership(rightmost(partition)) == partition, "Right most boundry must be sane"); + + assert(leftmost_empty(partition) == _max || leftmost_empty(partition) >= leftmost(partition), "Left most empty must be sane"); + assert(rightmost_empty(partition) == -1 || rightmost_empty(partition) <= rightmost(partition), "Right most empty must be sane"); + } +} + #endif ShenandoahFreeSet::ShenandoahFreeSet(ShenandoahHeap* heap, size_t max_regions) : _heap(heap), _partitions(max_regions, this), + _total_bytes_previously_allocated(0), + _mutator_bytes_at_last_sample(0), _total_humongous_waste(0), _alloc_bias_weight(0), _total_young_used(0), @@ -1654,23 +1684,22 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah // Not old collector alloc, so this is a young collector gclab or shared allocation orig_partition = ShenandoahFreeSetPartitionId::Collector; } + DEBUG_ONLY(bool boundary_changed = false;) + if ((result != nullptr) && in_new_region) { + _partitions.one_region_is_no_longer_empty(orig_partition); + DEBUG_ONLY(boundary_changed = true;) + } + if (alloc_capacity(r) < PLAB::min_size() * HeapWordSize) { // Regardless of whether this allocation succeeded, if the remaining memory is less than PLAB:min_size(), retire this region. // Note that retire_from_partition() increases used to account for waste. - // Also, if this allocation request failed and the consumed within this region * ShenandoahEvacWaste > region size, - // then retire the region so that subsequent searches can find available memory more quickly. - size_t idx = r->index(); - if ((result != nullptr) && in_new_region) { - _partitions.one_region_is_no_longer_empty(orig_partition); - } size_t waste_bytes = _partitions.retire_from_partition(orig_partition, idx, r->used()); + DEBUG_ONLY(boundary_changed = true;) if (req.is_mutator_alloc() && (waste_bytes > 0)) { increase_bytes_allocated(waste_bytes); } - } else if ((result != nullptr) && in_new_region) { - _partitions.one_region_is_no_longer_empty(orig_partition); } switch (orig_partition) { @@ -1711,7 +1740,13 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah default: assert(false, "won't happen"); } - _partitions.assert_bounds(); +#ifdef ASSERT + if (boundary_changed) { + _partitions.assert_bounds(); + } else { + _partitions.assert_bounds_sanity(); + } +#endif return result; } @@ -1776,7 +1811,6 @@ HeapWord* ShenandoahFreeSet::allocate_contiguous(ShenandoahAllocRequest& req, bo // found the match break; } - end++; } @@ -2016,7 +2050,8 @@ void ShenandoahFreeSet::clear_internal() { _partitions.set_bias_from_left_to_right(ShenandoahFreeSetPartitionId::OldCollector, false); } -void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_trashed_regions, size_t &old_trashed_regions, +// Returns total allocatable words in Mutator partition +size_t ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_trashed_regions, size_t &old_trashed_regions, size_t &first_old_region, size_t &last_old_region, size_t &old_region_count) { // This resets all state information, removing all regions from all sets. @@ -2034,6 +2069,8 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_trashed_r size_t region_size_bytes = _partitions.region_size_bytes(); size_t max_regions = _partitions.max(); + size_t mutator_alloc_capacity_in_words = 0; + size_t mutator_leftmost = max_regions; size_t mutator_rightmost = 0; size_t mutator_leftmost_empty = max_regions; @@ -2103,6 +2140,7 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_trashed_r if (region->is_trash() || !region->is_old()) { // Both young and old (possibly immediately) collected regions (trashed) are placed into the Mutator set _partitions.raw_assign_membership(idx, ShenandoahFreeSetPartitionId::Mutator); + mutator_alloc_capacity_in_words += ac / HeapWordSize; if (idx < mutator_leftmost) { mutator_leftmost = idx; } @@ -2259,6 +2297,7 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_trashed_r _partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector), _partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector)); + return mutator_alloc_capacity_in_words; } void ShenandoahFreeSet::transfer_humongous_regions_from_mutator_to_old_collector(size_t xfer_regions, @@ -2563,19 +2602,20 @@ void ShenandoahFreeSet::prepare_to_rebuild(size_t &young_trashed_regions, size_t clear(); log_debug(gc, free)("Rebuilding FreeSet"); - // This places regions that have alloc_capacity into the old_collector set if they identify as is_old() or the - // mutator set otherwise. All trashed (cset) regions are affiliated young and placed in mutator set. - find_regions_with_alloc_capacity(young_trashed_regions, old_trashed_regions, - first_old_region, last_old_region, old_region_count); + // Place regions that have alloc_capacity into the old_collector set if they identify as is_old() or the + // mutator set otherwise. All trashed (cset) regions are affiliated young and placed in mutator set. Save the + // allocatable words in mutator partition in state variable. + _prepare_to_rebuild_mutator_free = find_regions_with_alloc_capacity(young_trashed_regions, old_trashed_regions, + first_old_region, last_old_region, old_region_count); } - -void ShenandoahFreeSet::finish_rebuild(size_t young_cset_regions, size_t old_cset_regions, size_t old_region_count) { +// Return mutator free +void ShenandoahFreeSet::finish_rebuild(size_t young_trashed_regions, size_t old_trashed_regions, size_t old_region_count) { shenandoah_assert_heaplocked(); size_t young_reserve(0), old_reserve(0); if (_heap->mode()->is_generational()) { - compute_young_and_old_reserves(young_cset_regions, old_cset_regions, young_reserve, old_reserve); + compute_young_and_old_reserves(young_trashed_regions, old_trashed_regions, young_reserve, old_reserve); } else { young_reserve = (_heap->max_capacity() / 100) * ShenandoahEvacReserve; old_reserve = 0; @@ -2724,10 +2764,13 @@ void ShenandoahFreeSet::compute_young_and_old_reserves(size_t young_trashed_regi // into the collector set or old collector set in order to assure that the memory available for allocations within // the collector set is at least to_reserve and the memory available for allocations within the old collector set // is at least to_reserve_old. -void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old, size_t &old_region_count, - size_t &young_used_regions, size_t &old_used_regions, - size_t &young_used_bytes, size_t &old_used_bytes) { +// +// Returns total mutator alloc capacity, in words. +size_t ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old, size_t &old_region_count, + size_t &young_used_regions, size_t &old_used_regions, + size_t &young_used_bytes, size_t &old_used_bytes) { const size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes(); + size_t mutator_allocatable_words = _prepare_to_rebuild_mutator_free; young_used_regions = 0; old_used_regions = 0; @@ -2756,7 +2799,7 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old size_t empty_regions_to_collector = 0; size_t empty_regions_to_old_collector = 0; - size_t old_collector_available = _partitions.available_in(ShenandoahFreeSetPartitionId::OldCollector);; + size_t old_collector_available = _partitions.available_in(ShenandoahFreeSetPartitionId::OldCollector); size_t collector_available = _partitions.available_in(ShenandoahFreeSetPartitionId::Collector); for (size_t i = _heap->num_regions(); i > 0; i--) { @@ -2805,6 +2848,8 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old _partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector), _partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector)); old_region_count++; + assert(ac == ShenandoahHeapRegion::region_size_bytes(), "Cannot move to old unless entire region is in alloc capacity"); + mutator_allocatable_words -= ShenandoahHeapRegion::region_size_words(); continue; } } @@ -2848,8 +2893,10 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old " Collector range [%zd, %zd]", _partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator), - _partitions.leftmost(ShenandoahFreeSetPartitionId::Collector), - _partitions.rightmost(ShenandoahFreeSetPartitionId::Collector)); + _partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector), + _partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector)); + + mutator_allocatable_words -= ac / HeapWordSize; continue; } @@ -2957,6 +3004,7 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old PROPERFMTARGS(to_reserve), PROPERFMTARGS(reserve)); } } + return mutator_allocatable_words; } void ShenandoahFreeSet::establish_old_collector_alloc_bias() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp index 4e0aea80a9b..eeff0fde87c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp @@ -32,8 +32,8 @@ #include "gc/shenandoah/shenandoahSimpleBitMap.hpp" #include "logging/logStream.hpp" -typedef ShenandoahLock ShenandoahRebuildLock; -typedef ShenandoahLocker ShenandoahRebuildLocker; +typedef ShenandoahLock ShenandoahRebuildLock; +typedef ShenandoahLocker ShenandoahRebuildLocker; // Each ShenandoahHeapRegion is associated with a ShenandoahFreeSetPartitionId. enum class ShenandoahFreeSetPartitionId : uint8_t { @@ -402,6 +402,9 @@ public: // idx <= rightmost // } void assert_bounds() NOT_DEBUG_RETURN; + // this checks certain sanity conditions related to the bounds with much less effort than is required to + // more rigorously enforce correctness as is done by assert_bounds() + inline void assert_bounds_sanity() NOT_DEBUG_RETURN; }; // Publicly, ShenandoahFreeSet represents memory that is available to mutator threads. The public capacity(), used(), @@ -434,6 +437,12 @@ private: ShenandoahHeap* const _heap; ShenandoahRegionPartitions _partitions; + size_t _total_bytes_previously_allocated; + size_t _mutator_bytes_at_last_sample; + + // Temporarily holds mutator_Free allocatable bytes between prepare_to_rebuild() and finish_rebuild() + size_t _prepare_to_rebuild_mutator_free; + // This locks the rebuild process (in combination with the global heap lock). Whenever we rebuild the free set, // we first acquire the global heap lock and then we acquire this _rebuild_lock in a nested context. Threads that // need to check available, acquire only the _rebuild_lock to make sure that they are not obtaining the value of @@ -443,10 +452,10 @@ private: // locks will acquire them in the same order: first the global heap lock and then the rebuild lock. ShenandoahRebuildLock _rebuild_lock; - size_t _total_humongous_waste; - HeapWord* allocate_aligned_plab(size_t size, ShenandoahAllocRequest& req, ShenandoahHeapRegion* r); + size_t _total_humongous_waste; + // We re-evaluate the left-to-right allocation bias whenever _alloc_bias_weight is less than zero. Each time // we allocate an object, we decrement the count of this value. Each time we re-evaluate whether to allocate // from right-to-left or left-to-right, we reset the value of this counter to _InitialAllocBiasWeight. @@ -659,10 +668,47 @@ public: void increase_bytes_allocated(size_t bytes); + // Return an approximation of the bytes allocated since GC start. The value returned is monotonically non-decreasing + // in time within each GC cycle. For certain GC cycles, the value returned may include some bytes allocated before + // the start of the current GC cycle. inline size_t get_bytes_allocated_since_gc_start() const { return _mutator_bytes_allocated_since_gc_start; } + inline size_t get_total_bytes_allocated() { + return _mutator_bytes_allocated_since_gc_start + _total_bytes_previously_allocated; + } + + inline size_t get_bytes_allocated_since_previous_sample() { + size_t total_bytes = get_total_bytes_allocated(); + size_t result; + if (total_bytes < _mutator_bytes_at_last_sample) { + // This rare condition may occur if bytes allocated overflows (wraps around) size_t tally of allocations. + // This may also occur in the very rare situation that get_total_bytes_allocated() is queried in the middle of + // reset_bytes_allocated_since_gc_start(). Note that there is no lock to assure that the two global variables + // it modifies are modified atomically (_total_bytes_previously_allocated and _mutator_byts_allocated_since_gc_start) + // This has been observed to occur when an out-of-cycle degenerated cycle is starting (and thus calls + // reset_bytes_allocated_since_gc_start()) at the same time that the control (non-generational mode) or + // regulator (generational-mode) thread calls should_start_gc() (which invokes get_bytes_allocated_since_previous_sample()). + // + // Handle this rare situation by responding with the "innocent" value 0 and resetting internal state so that the + // the next query can recalibrate. + result = 0; + } else { + // Note: there's always the possibility that the tally of total allocations exceeds the 64-bit capacity of our size_t + // counter. We assume that the difference between relevant samples does not exceed this count. Example: + // Suppose _mutator_words_at_last_sample is 0xffff_ffff_ffff_fff0 (18,446,744,073,709,551,600 Decimal) + // and _total_words is 0x0000_0000_0000_0800 ( 32,768 Decimal) + // Then, total_words - _mutator_words_at_last_sample can be done adding 1's complement of subtrahend: + // 1's complement of _mutator_words_at_last_sample is: 0x0000_0000_0000_0010 ( 16 Decimal)) + // plus total_words: 0x0000_0000_0000_0800 (32,768 Decimal) + // sum: 0x0000_0000_0000_0810 (32,784 Decimal) + result = total_bytes - _mutator_bytes_at_last_sample; + } + _mutator_bytes_at_last_sample = total_bytes; + return result; + } + // Public because ShenandoahRegionPartitions assertions require access. inline size_t alloc_capacity(ShenandoahHeapRegion *r) const; inline size_t alloc_capacity(size_t idx) const; @@ -778,15 +824,15 @@ public: // Acquire heap lock and log status, assuming heap lock is not acquired by the caller. void log_status_under_lock(); - // Note that capacity is the number of regions that had available memory at most recent rebuild. It is not the - // entire size of the young or global generation. (Regions within the generation that were fully utilized at time of - // rebuild are not counted as part of capacity.) - - // All three of the following functions may produce stale data if called without owning the global heap lock. + // All four of the following functions may produce stale data if called without owning the global heap lock. // Changes to the values of these variables are performed with a lock. A change to capacity or used "atomically" // adjusts available with respect to lock holders. However, sequential calls to these three functions may produce // inconsistent data: available may not equal capacity - used because the intermediate states of any "atomic" // locked action can be seen by these unlocked functions. + + // Note that capacity is the number of regions that had available memory at most recent rebuild. It is not the + // entire size of the young or global generation. (Regions within the generation that were fully utilized at time of + // rebuild are not counted as part of capacity.) inline size_t capacity_holding_lock() const { shenandoah_assert_heaplocked(); return _partitions.capacity_of(ShenandoahFreeSetPartitionId::Mutator); @@ -805,6 +851,7 @@ public: ShenandoahRebuildLocker locker(rebuild_lock()); return _partitions.used_by(ShenandoahFreeSetPartitionId::Mutator); } + inline size_t reserved() const { return _partitions.capacity_of(ShenandoahFreeSetPartitionId::Collector); } inline size_t available() { shenandoah_assert_not_heaplocked(); ShenandoahRebuildLocker locker(rebuild_lock()); @@ -816,6 +863,10 @@ public: return _partitions.available_in(ShenandoahFreeSetPartitionId::Mutator); } + inline size_t collector_available_locked() const { + return _partitions.available_in(ShenandoahFreeSetPartitionId::Collector); + } + inline size_t total_humongous_waste() const { return _total_humongous_waste; } inline size_t humongous_waste_in_mutator() const { return _partitions.humongous_waste(ShenandoahFreeSetPartitionId::Mutator); @@ -877,13 +928,17 @@ public: // first_old_region is the index of the first region that is part of the OldCollector set // last_old_region is the index of the last region that is part of the OldCollector set // old_region_count is the number of regions in the OldCollector set that have memory available to be allocated - void find_regions_with_alloc_capacity(size_t &young_cset_regions, size_t &old_cset_regions, - size_t &first_old_region, size_t &last_old_region, size_t &old_region_count); + // + // Returns allocatable memory within Mutator partition, in words. + size_t find_regions_with_alloc_capacity(size_t &young_cset_regions, size_t &old_cset_regions, + size_t &first_old_region, size_t &last_old_region, size_t &old_region_count); // Ensure that Collector has at least to_reserve bytes of available memory, and OldCollector has at least old_reserve // bytes of available memory. On input, old_region_count holds the number of regions already present in the // OldCollector partition. Upon return, old_region_count holds the updated number of regions in the OldCollector partition. - void reserve_regions(size_t to_reserve, size_t old_reserve, size_t &old_region_count, + // + // Returns allocatable memory within Mutator partition, in words. + size_t reserve_regions(size_t to_reserve, size_t old_reserve, size_t &old_region_count, size_t &young_used_regions, size_t &old_used_regions, size_t &young_used_bytes, size_t &old_used_bytes); // Reserve space for evacuations, with regions reserved for old evacuations placed to the right diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp index 3c92750cc0c..21b1fd9e0a8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp @@ -252,6 +252,7 @@ void ShenandoahFullGC::do_it(GCCause::Cause gc_cause) { phase5_epilog(); } + heap->start_idle_span(); // Resize metaspace MetaspaceGC::compute_new_size(); @@ -877,8 +878,11 @@ public: Copy::aligned_conjoint_words(compact_from, compact_to, size); oop new_obj = cast_to_oop(compact_to); - ContinuationGCSupport::relativize_stack_chunk(new_obj); + // Restore the mark word before relativizing the stack chunk. The copy's + // mark word contains the full GC forwarding encoding, which would cause + // is_stackChunk() to read garbage (especially with compact headers). new_obj->init_mark(); + ContinuationGCSupport::relativize_stack_chunk(new_obj); } } }; @@ -1124,8 +1128,9 @@ void ShenandoahFullGC::phase5_epilog() { if (heap->mode()->is_generational()) { ShenandoahGenerationalFullGC::compute_balances(); } - free_set->finish_rebuild(young_trashed_regions, old_trashed_regions, num_old); + heap->free_set()->finish_rebuild(young_trashed_regions, old_trashed_regions, num_old); } + // Set mark incomplete because the marking bitmaps have been reset except pinned regions. _generation->set_mark_incomplete(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp index ddb50ee0020..3d592e9f9be 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp @@ -151,6 +151,10 @@ ShenandoahHeuristics* ShenandoahGeneration::initialize_heuristics(ShenandoahMode return _heuristics; } +void ShenandoahGeneration::post_initialize_heuristics() { + _heuristics->post_initialize(); +} + void ShenandoahGeneration::set_evacuation_reserve(size_t new_val) { shenandoah_assert_heaplocked(); _evacuation_reserve = new_val; @@ -268,7 +272,7 @@ void ShenandoahGeneration::prepare_regions_and_collection_set(bool concurrent) { } // Tally the census counts and compute the adaptive tenuring threshold - if (is_generational && ShenandoahGenerationalAdaptiveTenuring) { + if (is_generational) { // Objects above TAMS weren't included in the age census. Since they were all // allocated in this cycle they belong in the age 0 cohort. We walk over all // young regions and sum the volume of objects between TAMS and top. @@ -311,8 +315,8 @@ void ShenandoahGeneration::prepare_regions_and_collection_set(bool concurrent) { _free_set->prepare_to_rebuild(young_trashed_regions, old_trashed_regions, first_old, last_old, num_old); if (heap->mode()->is_generational()) { ShenandoahGenerationalHeap* gen_heap = ShenandoahGenerationalHeap::heap(); - size_t allocation_runway = - gen_heap->young_generation()->heuristics()->bytes_of_allocation_runway_before_gc_trigger(young_trashed_regions); + size_t allocation_runway = + gen_heap->young_generation()->heuristics()->bytes_of_allocation_runway_before_gc_trigger(young_trashed_regions); gen_heap->compute_old_generation_balance(allocation_runway, old_trashed_regions, young_trashed_regions); } _free_set->finish_rebuild(young_trashed_regions, old_trashed_regions, num_old); @@ -358,8 +362,7 @@ void ShenandoahGeneration::cancel_marking() { set_concurrent_mark_in_progress(false); } -ShenandoahGeneration::ShenandoahGeneration(ShenandoahGenerationType type, - uint max_workers) : +ShenandoahGeneration::ShenandoahGeneration(ShenandoahGenerationType type, uint max_workers) : _type(type), _task_queues(new ShenandoahObjToScanQueueSet(max_workers)), _ref_processor(new ShenandoahReferenceProcessor(this, MAX2(max_workers, 1U))), @@ -420,12 +423,6 @@ size_t ShenandoahGeneration::available() const { return result; } -// For ShenandoahYoungGeneration, Include the young available that may have been reserved for the Collector. -size_t ShenandoahGeneration::available_with_reserve() const { - size_t result = available(max_capacity()); - return result; -} - size_t ShenandoahGeneration::soft_mutator_available() const { size_t result = available(ShenandoahHeap::heap()->soft_max_capacity() * (100.0 - ShenandoahEvacReserve) / 100); return result; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp index 946f2b91520..6f32d101152 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp @@ -63,7 +63,7 @@ private: // Return available assuming that we can allocate no more than capacity bytes within this generation. size_t available(size_t capacity) const; - public: +public: ShenandoahGeneration(ShenandoahGenerationType type, uint max_workers); ~ShenandoahGeneration(); @@ -83,10 +83,10 @@ private: ShenandoahReferenceProcessor* ref_processor() { return _ref_processor; } virtual ShenandoahHeuristics* initialize_heuristics(ShenandoahMode* gc_mode); + virtual void post_initialize_heuristics(); virtual void post_initialize(ShenandoahHeap* heap); - virtual size_t bytes_allocated_since_gc_start() const override = 0; virtual size_t used() const override = 0; virtual size_t used_regions() const = 0; virtual size_t used_regions_size() const = 0; @@ -96,7 +96,6 @@ private: virtual size_t max_capacity() const override = 0; size_t available() const override; - size_t available_with_reserve() const; // Returns the memory available based on the _soft_ max heap capacity (soft_max_heap - used). // The soft max heap size may be adjusted lower than the max heap size to cause the trigger diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp index 3b57190cc75..ec33e671053 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp @@ -24,6 +24,7 @@ * */ +#include "gc/shenandoah/shenandoahAgeCensus.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentGC.hpp" @@ -55,7 +56,7 @@ ShenandoahGenerationalControlThread::ShenandoahGenerationalControlThread() : _heap(ShenandoahGenerationalHeap::heap()), _age_period(0) { shenandoah_assert_generational(); - set_name("Shenandoah Control Thread"); + set_name("ShenControl"); create_and_start(); } @@ -186,7 +187,7 @@ ShenandoahGenerationalControlThread::GCMode ShenandoahGenerationalControlThread: global_heuristics->record_requested_gc(); if (ShenandoahCollectorPolicy::should_run_full_gc(request.cause)) { - return stw_full;; + return stw_full; } else { // Unload and clean up everything. Note that this is an _explicit_ request and so does not use // the same `should_unload_classes` call as the regulator's concurrent gc request. @@ -254,7 +255,8 @@ void ShenandoahGenerationalControlThread::run_gc_cycle(const ShenandoahGCRequest GCIdMark gc_id_mark; - if (gc_mode() != servicing_old) { + if ((gc_mode() != servicing_old) && (gc_mode() != stw_degenerated)) { + // If mode is stw_degenerated, count bytes allocated from the start of the conc GC that experienced alloc failure. _heap->reset_bytes_allocated_since_gc_start(); } @@ -271,6 +273,12 @@ void ShenandoahGenerationalControlThread::run_gc_cycle(const ShenandoahGCRequest // Cannot uncommit bitmap slices during concurrent reset ShenandoahNoUncommitMark forbid_region_uncommit(_heap); + // When a whitebox full GC is requested, set the tenuring threshold to zero + // so that all young objects are promoted to old. This ensures that tests + // using WB.fullGC() to promote objects to old gen will not loop forever. + ShenandoahTenuringOverride tenuring_override(request.cause == GCCause::_wb_full_gc, + _heap->age_census()); + _heap->print_before_gc(); switch (gc_mode()) { case concurrent_normal: { @@ -622,10 +630,11 @@ void ShenandoahGenerationalControlThread::service_stw_full_cycle(GCCause::Cause void ShenandoahGenerationalControlThread::service_stw_degenerated_cycle(const ShenandoahGCRequest& request) { assert(_degen_point != ShenandoahGC::_degenerated_unset, "Degenerated point should be set"); + request.generation->heuristics()->record_degenerated_cycle_start(ShenandoahGC::ShenandoahDegenPoint::_degenerated_outside_cycle + == _degen_point); _heap->increment_total_collections(false); ShenandoahGCSession session(request.cause, request.generation); - ShenandoahDegenGC gc(_degen_point, request.generation); gc.collect(request.cause); _degen_point = ShenandoahGC::_degenerated_unset; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp index 36ea0b9e497..d5cfa4b7fb9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp @@ -90,11 +90,23 @@ ShenandoahGenerationalHeap::ShenandoahGenerationalHeap(ShenandoahCollectorPolicy assert(is_aligned(_max_plab_size, CardTable::card_size_in_words()), "max_plab_size must be aligned"); } +void ShenandoahGenerationalHeap::initialize_generations() { + ShenandoahHeap::initialize_generations(); + _young_generation->post_initialize(this); + _old_generation->post_initialize(this); +} + void ShenandoahGenerationalHeap::post_initialize() { ShenandoahHeap::post_initialize(); _age_census = new ShenandoahAgeCensus(); } +void ShenandoahGenerationalHeap::post_initialize_heuristics() { + ShenandoahHeap::post_initialize_heuristics(); + _young_generation->post_initialize_heuristics(); + _old_generation->post_initialize_heuristics(); +} + void ShenandoahGenerationalHeap::print_init_logger() const { ShenandoahGenerationalInitLogger logger; logger.print_all(); @@ -110,12 +122,6 @@ void ShenandoahGenerationalHeap::initialize_heuristics() { _old_generation->initialize_heuristics(mode()); } -void ShenandoahGenerationalHeap::post_initialize_heuristics() { - ShenandoahHeap::post_initialize_heuristics(); - _young_generation->post_initialize(this); - _old_generation->post_initialize(this); -} - void ShenandoahGenerationalHeap::initialize_serviceability() { assert(mode()->is_generational(), "Only for the generational mode"); _young_gen_memory_pool = new ShenandoahYoungGenMemoryPool(this); @@ -152,6 +158,10 @@ void ShenandoahGenerationalHeap::stop() { regulator_thread()->stop(); } +void ShenandoahGenerationalHeap::start_idle_span() { + young_generation()->heuristics()->start_idle_span(); +} + bool ShenandoahGenerationalHeap::requires_barriers(stackChunkOop obj) const { if (is_idle()) { return false; @@ -259,27 +269,25 @@ oop ShenandoahGenerationalHeap::try_evacuate_object(oop p, Thread* thread, uint break; } case OLD_GENERATION: { - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - if (plab != nullptr) { + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + if (shenandoah_plab != nullptr) { has_plab = true; - copy = allocate_from_plab(thread, size, is_promotion); - if ((copy == nullptr) && (size < ShenandoahThreadLocalData::plab_size(thread)) && - ShenandoahThreadLocalData::plab_retries_enabled(thread)) { + copy = shenandoah_plab->allocate(size, is_promotion); + if (copy == nullptr && size < shenandoah_plab->desired_size() && shenandoah_plab->retries_enabled()) { // PLAB allocation failed because we are bumping up against the limit on old evacuation reserve or because // the requested object does not fit within the current plab but the plab still has an "abundance" of memory, // where abundance is defined as >= ShenGenHeap::plab_min_size(). In the former case, we try shrinking the // desired PLAB size to the minimum and retry PLAB allocation to avoid cascading of shared memory allocations. // Shrinking the desired PLAB size may allow us to eke out a small PLAB while staying beneath evacuation reserve. - if (plab->words_remaining() < plab_min_size()) { - ShenandoahThreadLocalData::set_plab_size(thread, plab_min_size()); - copy = allocate_from_plab(thread, size, is_promotion); - // If we still get nullptr, we'll try a shared allocation below. + if (shenandoah_plab->plab()->words_remaining() < plab_min_size()) { + shenandoah_plab->set_desired_size(plab_min_size()); + copy = shenandoah_plab->allocate(size, is_promotion); if (copy == nullptr) { - // If retry fails, don't continue to retry until we have success (probably in next GC pass) - ShenandoahThreadLocalData::disable_plab_retries(thread); + // If we still get nullptr, we'll try a shared allocation below. + // However, don't continue to retry until we have success (probably in next GC pass) + shenandoah_plab->disable_retries(); } } - // else, copy still equals nullptr. this causes shared allocation below, preserving this plab for future needs. } } break; @@ -338,18 +346,19 @@ oop ShenandoahGenerationalHeap::try_evacuate_object(oop p, Thread* thread, uint increase_object_age(copy_val, from_region_age + 1); } + // Relativize stack chunks before publishing the copy. After the forwarding CAS, + // mutators can see the copy and thaw it via the fast path if flags == 0. We must + // relativize derived pointers and set gc_mode before that happens. Skip if the + // copy's mark word is already a forwarding pointer (another thread won the race + // and overwrote the original's header before we copied it). + if (!ShenandoahForwarding::is_forwarded(copy_val)) { + ContinuationGCSupport::relativize_stack_chunk(copy_val); + } + // Try to install the new forwarding pointer. oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val); if (result == copy_val) { // Successfully evacuated. Our copy is now the public one! - - // This is necessary for virtual thread support. This uses the mark word without - // considering that it may now be a forwarding pointer (and could therefore crash). - // Secondarily, we do not want to spend cycles relativizing stack chunks for oops - // that lost the evacuation race (and will therefore not become visible). It is - // safe to do this on the public copy (this is also done during concurrent mark). - ContinuationGCSupport::relativize_stack_chunk(copy_val); - if (ShenandoahEvacTracking) { // Record that the evacuation succeeded evac_tracker()->end_evacuation(thread, size * HeapWordSize, FROM_GENERATION, TO_GENERATION); @@ -374,9 +383,9 @@ oop ShenandoahGenerationalHeap::try_evacuate_object(oop p, Thread* thread, uint break; } case OLD_GENERATION: { - ShenandoahThreadLocalData::plab(thread)->undo_allocation(copy, size); + ShenandoahThreadLocalData::shenandoah_plab(thread)->plab()->undo_allocation(copy, size); if (is_promotion) { - ShenandoahThreadLocalData::subtract_from_plab_promoted(thread, size * HeapWordSize); + ShenandoahThreadLocalData::shenandoah_plab(thread)->subtract_from_promoted(size * HeapWordSize); } break; } @@ -401,179 +410,6 @@ template oop ShenandoahGenerationalHeap::try_evacuate_object(oop p, Thread* thread, uint from_region_age); template oop ShenandoahGenerationalHeap::try_evacuate_object(oop p, Thread* thread, uint from_region_age); -inline HeapWord* ShenandoahGenerationalHeap::allocate_from_plab(Thread* thread, size_t size, bool is_promotion) { - assert(UseTLAB, "TLABs should be enabled"); - - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - HeapWord* obj; - - if (plab == nullptr) { - assert(!thread->is_Java_thread() && !thread->is_Worker_thread(), "Performance: thread should have PLAB: %s", thread->name()); - // No PLABs in this thread, fallback to shared allocation - return nullptr; - } else if (is_promotion && !ShenandoahThreadLocalData::allow_plab_promotions(thread)) { - return nullptr; - } - // if plab->word_size() <= 0, thread's plab not yet initialized for this pass, so allow_plab_promotions() is not trustworthy - obj = plab->allocate(size); - if ((obj == nullptr) && (plab->words_remaining() < plab_min_size())) { - // allocate_from_plab_slow will establish allow_plab_promotions(thread) for future invocations - obj = allocate_from_plab_slow(thread, size, is_promotion); - } - // if plab->words_remaining() >= ShenGenHeap::heap()->plab_min_size(), just return nullptr so we can use a shared allocation - if (obj == nullptr) { - return nullptr; - } - - if (is_promotion) { - ShenandoahThreadLocalData::add_to_plab_promoted(thread, size * HeapWordSize); - } - return obj; -} - -// Establish a new PLAB and allocate size HeapWords within it. -HeapWord* ShenandoahGenerationalHeap::allocate_from_plab_slow(Thread* thread, size_t size, bool is_promotion) { - assert(mode()->is_generational(), "PLABs only relevant to generational GC"); - - const size_t plab_min_size = this->plab_min_size(); - // PLABs are aligned to card boundaries to avoid synchronization with concurrent - // allocations in other PLABs. - const size_t min_size = (size > plab_min_size)? align_up(size, CardTable::card_size_in_words()): plab_min_size; - - // Figure out size of new PLAB, using value determined at last refill. - size_t cur_size = ShenandoahThreadLocalData::plab_size(thread); - if (cur_size == 0) { - cur_size = plab_min_size; - } - - // Expand aggressively, doubling at each refill in this epoch, ceiling at plab_max_size() - const size_t future_size = MIN2(cur_size * 2, plab_max_size()); - // Doubling, starting at a card-multiple, should give us a card-multiple. (Ceiling and floor - // are card multiples.) - assert(is_aligned(future_size, CardTable::card_size_in_words()), "Card multiple by construction, future_size: %zu" - ", card_size: %u, cur_size: %zu, max: %zu", - future_size, CardTable::card_size_in_words(), cur_size, plab_max_size()); - - // Record new heuristic value even if we take any shortcut. This captures - // the case when moderately-sized objects always take a shortcut. At some point, - // heuristics should catch up with them. Note that the requested cur_size may - // not be honored, but we remember that this is the preferred size. - log_debug(gc, plab)("Set next PLAB refill size: %zu bytes", future_size * HeapWordSize); - ShenandoahThreadLocalData::set_plab_size(thread, future_size); - - if (cur_size < size) { - // The PLAB to be allocated is still not large enough to hold the object. Fall back to shared allocation. - // This avoids retiring perfectly good PLABs in order to represent a single large object allocation. - log_debug(gc, plab)("Current PLAB size (%zu) is too small for %zu", cur_size * HeapWordSize, size * HeapWordSize); - return nullptr; - } - - // Retire current PLAB, and allocate a new one. - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - if (plab->words_remaining() < plab_min_size) { - // Retire current PLAB. This takes care of any PLAB book-keeping. - // retire_plab() registers the remnant filler object with the remembered set scanner without a lock. - // Since PLABs are card-aligned, concurrent registrations in other PLABs don't interfere. - retire_plab(plab, thread); - - size_t actual_size = 0; - HeapWord* plab_buf = allocate_new_plab(min_size, cur_size, &actual_size); - if (plab_buf == nullptr) { - if (min_size == plab_min_size) { - // Disable PLAB promotions for this thread because we cannot even allocate a minimal PLAB. This allows us - // to fail faster on subsequent promotion attempts. - ShenandoahThreadLocalData::disable_plab_promotions(thread); - } - return nullptr; - } else { - ShenandoahThreadLocalData::enable_plab_retries(thread); - } - // Since the allocated PLAB may have been down-sized for alignment, plab->allocate(size) below may still fail. - if (ZeroTLAB) { - // ... and clear it. - Copy::zero_to_words(plab_buf, actual_size); - } else { - // ...and zap just allocated object. -#ifdef ASSERT - // Skip mangling the space corresponding to the object header to - // ensure that the returned space is not considered parsable by - // any concurrent GC thread. - size_t hdr_size = oopDesc::header_size(); - Copy::fill_to_words(plab_buf + hdr_size, actual_size - hdr_size, badHeapWordVal); -#endif // ASSERT - } - assert(is_aligned(actual_size, CardTable::card_size_in_words()), "Align by design"); - plab->set_buf(plab_buf, actual_size); - if (is_promotion && !ShenandoahThreadLocalData::allow_plab_promotions(thread)) { - return nullptr; - } - return plab->allocate(size); - } else { - // If there's still at least min_size() words available within the current plab, don't retire it. Let's nibble - // away on this plab as long as we can. Meanwhile, return nullptr to force this particular allocation request - // to be satisfied with a shared allocation. By packing more promotions into the previously allocated PLAB, we - // reduce the likelihood of evacuation failures, and we reduce the need for downsizing our PLABs. - return nullptr; - } -} - -HeapWord* ShenandoahGenerationalHeap::allocate_new_plab(size_t min_size, size_t word_size, size_t* actual_size) { - // Align requested sizes to card-sized multiples. Align down so that we don't violate max size of TLAB. - assert(is_aligned(min_size, CardTable::card_size_in_words()), "Align by design"); - assert(word_size >= min_size, "Requested PLAB is too small"); - - ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab(min_size, word_size); - // Note that allocate_memory() sets a thread-local flag to prohibit further promotions by this thread - // if we are at risk of infringing on the old-gen evacuation budget. - HeapWord* res = allocate_memory(req); - if (res != nullptr) { - *actual_size = req.actual_size(); - } else { - *actual_size = 0; - } - assert(is_aligned(res, CardTable::card_size_in_words()), "Align by design"); - return res; -} - -void ShenandoahGenerationalHeap::retire_plab(PLAB* plab, Thread* thread) { - // We don't enforce limits on plab evacuations. We let it consume all available old-gen memory in order to reduce - // probability of an evacuation failure. We do enforce limits on promotion, to make sure that excessive promotion - // does not result in an old-gen evacuation failure. Note that a failed promotion is relatively harmless. Any - // object that fails to promote in the current cycle will be eligible for promotion in a subsequent cycle. - - // When the plab was instantiated, its entirety was treated as if the entire buffer was going to be dedicated to - // promotions. Now that we are retiring the buffer, we adjust for the reality that the plab is not entirely promotions. - // 1. Some of the plab may have been dedicated to evacuations. - // 2. Some of the plab may have been abandoned due to waste (at the end of the plab). - size_t not_promoted = - ShenandoahThreadLocalData::get_plab_actual_size(thread) - ShenandoahThreadLocalData::get_plab_promoted(thread); - ShenandoahThreadLocalData::reset_plab_promoted(thread); - ShenandoahThreadLocalData::set_plab_actual_size(thread, 0); - if (not_promoted > 0) { - log_debug(gc, plab)("Retire PLAB, unexpend unpromoted: %zu", not_promoted * HeapWordSize); - old_generation()->unexpend_promoted(not_promoted); - } - const size_t original_waste = plab->waste(); - HeapWord* const top = plab->top(); - - // plab->retire() overwrites unused memory between plab->top() and plab->hard_end() with a dummy object to make memory parsable. - // It adds the size of this unused memory, in words, to plab->waste(). - plab->retire(); - if (top != nullptr && plab->waste() > original_waste && is_in_old(top)) { - // If retiring the plab created a filler object, then we need to register it with our card scanner so it can - // safely walk the region backing the plab. - log_debug(gc, plab)("retire_plab() is registering remnant of size %zu at " PTR_FORMAT, - (plab->waste() - original_waste) * HeapWordSize, p2i(top)); - // No lock is necessary because the PLAB memory is aligned on card boundaries. - old_generation()->card_scan()->register_object_without_lock(top); - } -} - -void ShenandoahGenerationalHeap::retire_plab(PLAB* plab) { - Thread* thread = Thread::current(); - retire_plab(plab, thread); -} - // Make sure old-generation is large enough, but no larger than is necessary, to hold mixed evacuations // and promotions, if we anticipate either. Any deficit is provided by the young generation, subject to // mutator_xfer_limit, and any surplus is transferred to the young generation. mutator_xfer_limit is @@ -605,7 +441,8 @@ void ShenandoahGenerationalHeap::compute_old_generation_balance(size_t mutator_x ShenandoahOldGeneration* old_gen = old_generation(); size_t old_capacity = old_gen->max_capacity(); size_t old_usage = old_gen->used(); // includes humongous waste - size_t old_available = ((old_capacity >= old_usage)? old_capacity - old_usage: 0) + old_trashed_regions * region_size_bytes; + size_t old_currently_available = + ((old_capacity >= old_usage)? old_capacity - old_usage: 0) + old_trashed_regions * region_size_bytes; ShenandoahYoungGeneration* young_gen = young_generation(); size_t young_capacity = young_gen->max_capacity(); @@ -621,78 +458,120 @@ void ShenandoahGenerationalHeap::compute_old_generation_balance(size_t mutator_x size_t young_reserve = (young_generation()->max_capacity() * ShenandoahEvacReserve) / 100; // If ShenandoahOldEvacPercent equals 100, max_old_reserve is limited only by mutator_xfer_limit and young_reserve - const size_t bound_on_old_reserve = ((old_available + mutator_xfer_limit + young_reserve) * ShenandoahOldEvacPercent) / 100; + const size_t bound_on_old_reserve = + ((old_currently_available + mutator_xfer_limit + young_reserve) * ShenandoahOldEvacPercent) / 100; size_t proposed_max_old = ((ShenandoahOldEvacPercent == 100)? bound_on_old_reserve: MIN2((young_reserve * ShenandoahOldEvacPercent) / (100 - ShenandoahOldEvacPercent), bound_on_old_reserve)); - if (young_reserve > young_available) { - young_reserve = young_available; + assert(mutator_xfer_limit <= young_available, + "Cannot transfer (%zu) memory that is not available (%zu)", mutator_xfer_limit, young_available); + // Young reserves are to be taken out of the mutator_xfer_limit. + if (young_reserve > mutator_xfer_limit) { + young_reserve = mutator_xfer_limit; } + mutator_xfer_limit -= young_reserve; // Decide how much old space we should reserve for a mixed collection - size_t reserve_for_mixed = 0; + size_t proposed_reserve_for_mixed = 0; const size_t old_fragmented_available = - old_available - (old_generation()->free_unaffiliated_regions() + old_trashed_regions) * region_size_bytes; + old_currently_available - (old_generation()->free_unaffiliated_regions() + old_trashed_regions) * region_size_bytes; if (old_fragmented_available > proposed_max_old) { - // After we've promoted regions in place, there may be an abundance of old-fragmented available memory, - // even more than the desired percentage for old reserve. We cannot transfer these fragmented regions back - // to young. Instead we make the best of the situation by using this fragmented memory for both promotions - // and evacuations. + // In this case, the old_fragmented_available is greater than the desired amount of evacuation to old. + // We'll use all of this memory to hold results of old evacuation, and we'll give back to the young generation + // any old regions that are not fragmented. + // + // This scenario may happen after we have promoted many regions in place, and each of these regions had non-zero + // unused memory, so there is now an abundance of old-fragmented available memory, even more than the desired + // percentage for old reserve. We cannot transfer these fragmented regions back to young. Instead we make the + // best of the situation by using this fragmented memory for both promotions and evacuations. + proposed_max_old = old_fragmented_available; } - size_t reserve_for_promo = old_fragmented_available; + // Otherwise: old_fragmented_available <= proposed_max_old. Do not shrink proposed_max_old from the original computation. + + // Though we initially set proposed_reserve_for_promo to equal the entirety of old fragmented available, we have the + // opportunity below to shift some of this memory into the proposed_reserve_for_mixed. + size_t proposed_reserve_for_promo = old_fragmented_available; const size_t max_old_reserve = proposed_max_old; + const size_t mixed_candidate_live_memory = old_generation()->unprocessed_collection_candidates_live_memory(); const bool doing_mixed = (mixed_candidate_live_memory > 0); if (doing_mixed) { - // We want this much memory to be unfragmented in order to reliably evacuate old. This is conservative because we - // may not evacuate the entirety of unprocessed candidates in a single mixed evacuation. + // In the ideal, all of the memory reserved for mixed evacuation would be unfragmented, but we don't enforce + // this. Note that the initial value of max_evac_need is conservative because we may not evacuate all of the + // remaining mixed evacuation candidates in a single cycle. const size_t max_evac_need = (size_t) (mixed_candidate_live_memory * ShenandoahOldEvacWaste); - assert(old_available >= old_generation()->free_unaffiliated_regions() * region_size_bytes, + assert(old_currently_available >= old_generation()->free_unaffiliated_regions() * region_size_bytes, "Unaffiliated available must be less than total available"); // We prefer to evacuate all of mixed into unfragmented memory, and will expand old in order to do so, unless // we already have too much fragmented available memory in old. - reserve_for_mixed = max_evac_need; - if (reserve_for_mixed + reserve_for_promo > max_old_reserve) { - // In this case, we'll allow old-evac to target some of the fragmented old memory. - size_t excess_reserves = (reserve_for_mixed + reserve_for_promo) - max_old_reserve; - if (reserve_for_promo > excess_reserves) { - reserve_for_promo -= excess_reserves; + proposed_reserve_for_mixed = max_evac_need; + if (proposed_reserve_for_mixed + proposed_reserve_for_promo > max_old_reserve) { + // We're trying to reserve more memory than is available. So we need to shrink our reserves. + size_t excess_reserves = (proposed_reserve_for_mixed + proposed_reserve_for_promo) - max_old_reserve; + // We need to shrink reserves by excess_reserves. We prefer to shrink by reducing promotion, giving priority to mixed + // evacuation. If the promotion reserve is larger than the amount we need to shrink by, do all the shrinkage there. + if (proposed_reserve_for_promo > excess_reserves) { + proposed_reserve_for_promo -= excess_reserves; } else { - excess_reserves -= reserve_for_promo; - reserve_for_promo = 0; - reserve_for_mixed -= excess_reserves; + // Otherwise, we'll shrink promotion reserve to zero and we'll shrink the mixed-evac reserve by the remaining excess. + excess_reserves -= proposed_reserve_for_promo; + proposed_reserve_for_promo = 0; + proposed_reserve_for_mixed -= excess_reserves; } } } + assert(proposed_reserve_for_mixed + proposed_reserve_for_promo <= max_old_reserve, + "Reserve for mixed (%zu) plus reserve for promotions (%zu) must be less than maximum old reserve (%zu)", + proposed_reserve_for_mixed, proposed_reserve_for_promo, max_old_reserve); // Decide how much additional space we should reserve for promotions from young. We give priority to mixed evacations // over promotions. const size_t promo_load = old_generation()->get_promotion_potential(); const bool doing_promotions = promo_load > 0; - if (doing_promotions) { - // We've already set aside all of the fragmented available memory within old-gen to represent old objects - // to be promoted from young generation. promo_load represents the memory that we anticipate to be promoted - // from regions that have reached tenure age. In the ideal, we will always use fragmented old-gen memory - // to hold individually promoted objects and will use unfragmented old-gen memory to represent the old-gen - // evacuation workloa. - // We're promoting and have an estimate of memory to be promoted from aged regions - assert(max_old_reserve >= (reserve_for_mixed + reserve_for_promo), "Sanity"); - const size_t available_for_additional_promotions = max_old_reserve - (reserve_for_mixed + reserve_for_promo); - size_t promo_need = (size_t)(promo_load * ShenandoahPromoEvacWaste); - if (promo_need > reserve_for_promo) { - reserve_for_promo += MIN2(promo_need - reserve_for_promo, available_for_additional_promotions); + // promo_load represents the combined total of live memory within regions that have reached tenure age. The true + // promotion potential is larger than this, because individual objects within regions that have not yet reached tenure + // age may be promotable. On the other hand, some of the objects that we intend to promote in the next GC cycle may + // die before they are next marked. In the future, the promo_load will include the total size of tenurable objects + // residing in regions that have not yet reached tenure age. + + if (doing_promotions) { + // We are always doing promotions, even when old_generation->get_promotion_potential() returns 0. As currently implemented, + // get_promotion_potential() only knows the total live memory contained within young-generation regions whose age is + // tenurable. It does not know whether that memory will still be live at the end of the next mark cycle, and it doesn't + // know how much memory is contained within objects whose individual ages are tenurable, which reside in regions with + // non-tenurable age. We use this, as adjusted by ShenandoahPromoEvacWaste, as an approximation of the total amount of + // memory to be promoted. In the near future, we expect to implement a change that will allow get_promotion_potential() + // to account also for the total memory contained within individual objects that are tenure-ready even when they do + // not reside in aged regions. This will represent a conservative over approximation of promotable memory because + // some of these objects may die before the next GC cycle executes. + + // Be careful not to ask for too much promotion reserves. We have observed jtreg test failures under which a greedy + // promotion reserve causes a humongous allocation which is awaiting a full GC to fail (specifically + // gc/TestAllocHumongousFragment.java). This happens if too much of the memory reclaimed by the full GC + // is immediately reserved so that it cannot be allocated by the waiting mutator. It's not clear that this + // particular test is representative of the needs of typical GenShen users. It is really a test of high frequency + // Full GCs under heap fragmentation stress. + + size_t promo_need = (size_t) (promo_load * ShenandoahPromoEvacWaste); + if (promo_need > proposed_reserve_for_promo) { + const size_t available_for_additional_promotions = + max_old_reserve - (proposed_reserve_for_mixed + proposed_reserve_for_promo); + if (proposed_reserve_for_promo + available_for_additional_promotions >= promo_need) { + proposed_reserve_for_promo = promo_need; + } else { + proposed_reserve_for_promo += available_for_additional_promotions; + } } - // We've already reserved all the memory required for the promo_load, and possibly more. The excess - // can be consumed by objects promoted from regions that have not yet reached tenure age. } + // else, leave proposed_reserve_for_promo as is. By default, it is initialized to represent old_fragmented_available. // This is the total old we want to reserve (initialized to the ideal reserve) - size_t old_reserve = reserve_for_mixed + reserve_for_promo; + size_t proposed_old_reserve = proposed_reserve_for_mixed + proposed_reserve_for_promo; // We now check if the old generation is running a surplus or a deficit. size_t old_region_deficit = 0; @@ -702,68 +581,70 @@ void ShenandoahGenerationalHeap::compute_old_generation_balance(size_t mutator_x // align the mutator_xfer_limit on region size mutator_xfer_limit = mutator_region_xfer_limit * region_size_bytes; - if (old_available >= old_reserve) { + if (old_currently_available >= proposed_old_reserve) { // We are running a surplus, so the old region surplus can go to young - const size_t old_surplus = old_available - old_reserve; + const size_t old_surplus = old_currently_available - proposed_old_reserve; old_region_surplus = old_surplus / region_size_bytes; const size_t unaffiliated_old_regions = old_generation()->free_unaffiliated_regions() + old_trashed_regions; old_region_surplus = MIN2(old_region_surplus, unaffiliated_old_regions); old_generation()->set_region_balance(checked_cast(old_region_surplus)); - } else if (old_available + mutator_xfer_limit >= old_reserve) { - // Mutator's xfer limit is sufficient to satisfy our need: transfer all memory from there - size_t old_deficit = old_reserve - old_available; + old_currently_available -= old_region_surplus * region_size_bytes; + young_available += old_region_surplus * region_size_bytes; + } else if (old_currently_available + mutator_xfer_limit >= proposed_old_reserve) { + // We know that old_currently_available < proposed_old_reserve because above test failed. Expand old_currently_available. + // Mutator's xfer limit is sufficient to satisfy our need: transfer all memory from there. + size_t old_deficit = proposed_old_reserve - old_currently_available; old_region_deficit = (old_deficit + region_size_bytes - 1) / region_size_bytes; old_generation()->set_region_balance(0 - checked_cast(old_region_deficit)); + old_currently_available += old_region_deficit * region_size_bytes; + young_available -= old_region_deficit * region_size_bytes; } else { - // We'll try to xfer from both mutator excess and from young collector reserve - size_t available_reserves = old_available + young_reserve + mutator_xfer_limit; - size_t old_entitlement = (available_reserves * ShenandoahOldEvacPercent) / 100; + // We know that (old_currently_available < proposed_old_reserve) and + // (old_currently_available + mutator_xfer_limit < proposed_old_reserve) because above tests failed. + // We need to shrink proposed_old_reserves. - // Round old_entitlement down to nearest multiple of regions to be transferred to old - size_t entitled_xfer = old_entitlement - old_available; - entitled_xfer = region_size_bytes * (entitled_xfer / region_size_bytes); - size_t unaffiliated_young_regions = young_generation()->free_unaffiliated_regions(); - size_t unaffiliated_young_memory = unaffiliated_young_regions * region_size_bytes; - if (entitled_xfer > unaffiliated_young_memory) { - entitled_xfer = unaffiliated_young_memory; - } - old_entitlement = old_available + entitled_xfer; - if (old_entitlement < old_reserve) { - // There's not enough memory to satisfy our desire. Scale back our old-gen intentions. - size_t budget_overrun = old_reserve - old_entitlement;; - if (reserve_for_promo > budget_overrun) { - reserve_for_promo -= budget_overrun; - old_reserve -= budget_overrun; - } else { - budget_overrun -= reserve_for_promo; - reserve_for_promo = 0; - reserve_for_mixed = (reserve_for_mixed > budget_overrun)? reserve_for_mixed - budget_overrun: 0; - old_reserve = reserve_for_promo + reserve_for_mixed; - } - } + // We could potentially shrink young_reserves in order to further expand proposed_old_reserves. Let's not bother. The + // important thing is that we keep a total amount of memory in reserve in preparation for the next GC cycle. At + // the time we choose the next collection set, we'll have an opportunity to shift some of these young reserves + // into old reserves if that makes sense. - // Because of adjustments above, old_reserve may be smaller now than it was when we tested the branch - // condition above: "(old_available + mutator_xfer_limit >= old_reserve) - // Therefore, we do NOT know that: mutator_xfer_limit < old_reserve - old_available - - size_t old_deficit = old_reserve - old_available; - old_region_deficit = (old_deficit + region_size_bytes - 1) / region_size_bytes; - - // Shrink young_reserve to account for loan to old reserve - const size_t reserve_xfer_regions = old_region_deficit - mutator_region_xfer_limit; - young_reserve -= reserve_xfer_regions * region_size_bytes; + // Start by taking all of mutator_xfer_limit into old_currently_available. + size_t old_region_deficit = mutator_region_xfer_limit; old_generation()->set_region_balance(0 - checked_cast(old_region_deficit)); + old_currently_available += old_region_deficit * region_size_bytes; + young_available -= old_region_deficit * region_size_bytes; + + assert(old_currently_available < proposed_old_reserve, + "Old currently available (%zu) must be less than old reserve (%zu)", old_currently_available, proposed_old_reserve); + + // There's not enough memory to satisfy our desire. Scale back our old-gen intentions. We prefer to satisfy + // the budget_overrun entirely from the promotion reserve, if that is large enough. Otherwise, we'll satisfy + // the overrun from a combination of promotion and mixed-evacuation reserves. + size_t budget_overrun = proposed_old_reserve - old_currently_available; + if (proposed_reserve_for_promo > budget_overrun) { + proposed_reserve_for_promo -= budget_overrun; + // Dead code: + // proposed_old_reserve -= budget_overrun; + } else { + budget_overrun -= proposed_reserve_for_promo; + proposed_reserve_for_promo = 0; + proposed_reserve_for_mixed = (proposed_reserve_for_mixed > budget_overrun)? proposed_reserve_for_mixed - budget_overrun: 0; + // Dead code: + // Note: proposed_reserve_for_promo is 0 and proposed_reserve_for_mixed may equal 0. + // proposed_old_reserve = proposed_reserve_for_mixed; + } } - assert(old_region_deficit == 0 || old_region_surplus == 0, "Only surplus or deficit, never both"); - assert(young_reserve + reserve_for_mixed + reserve_for_promo <= old_available + young_available, + assert(old_region_deficit == 0 || old_region_surplus == 0, + "Only surplus (%zu) or deficit (%zu), never both", old_region_surplus, old_region_deficit); + assert(young_reserve + proposed_reserve_for_mixed + proposed_reserve_for_promo <= old_currently_available + young_available, "Cannot reserve more memory than is available: %zu + %zu + %zu <= %zu + %zu", - young_reserve, reserve_for_mixed, reserve_for_promo, old_available, young_available); + young_reserve, proposed_reserve_for_mixed, proposed_reserve_for_promo, old_currently_available, young_available); // deficit/surplus adjustments to generation sizes will precede rebuild young_generation()->set_evacuation_reserve(young_reserve); - old_generation()->set_evacuation_reserve(reserve_for_mixed); - old_generation()->set_promoted_reserve(reserve_for_promo); + old_generation()->set_evacuation_reserve(proposed_reserve_for_mixed); + old_generation()->set_promoted_reserve(proposed_reserve_for_promo); } void ShenandoahGenerationalHeap::coalesce_and_fill_old_regions(bool concurrent) { @@ -1108,6 +989,8 @@ void ShenandoahGenerationalHeap::complete_degenerated_cycle() { ShenandoahGCPhase phase(ShenandoahPhaseTimings::degen_gc_coalesce_and_fill); coalesce_and_fill_old_regions(false); } + + old_generation()->maybe_log_promotion_failure_stats(false); } void ShenandoahGenerationalHeap::complete_concurrent_cycle() { @@ -1121,6 +1004,8 @@ void ShenandoahGenerationalHeap::complete_concurrent_cycle() { // throw off the heuristics. entry_global_coalesce_and_fill(); } + + old_generation()->maybe_log_promotion_failure_stats(true); } void ShenandoahGenerationalHeap::entry_global_coalesce_and_fill() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp index 719bae52a83..d6893dc011e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp @@ -40,6 +40,7 @@ class ShenandoahGenerationalHeap : public ShenandoahHeap { public: explicit ShenandoahGenerationalHeap(ShenandoahCollectorPolicy* policy); void post_initialize() override; + void initialize_generations() override; void initialize_heuristics() override; void post_initialize_heuristics() override; @@ -82,6 +83,8 @@ public: inline bool is_tenurable(const ShenandoahHeapRegion* r) const; + void start_idle_span() override; + // Ages regions that haven't been used for allocations in the current cycle. // Resets ages for regions that have been used for allocations. void update_region_ages(ShenandoahMarkingContext* ctx); @@ -99,9 +102,6 @@ public: size_t plab_min_size() const { return _min_plab_size; } size_t plab_max_size() const { return _max_plab_size; } - void retire_plab(PLAB* plab); - void retire_plab(PLAB* plab, Thread* thread); - // ---------- Update References // // In the generational mode, we will use this function for young, mixed, and global collections. @@ -110,10 +110,6 @@ public: void final_update_refs_update_region_states() override; private: - HeapWord* allocate_from_plab(Thread* thread, size_t size, bool is_promotion); - HeapWord* allocate_from_plab_slow(Thread* thread, size_t size, bool is_promotion); - HeapWord* allocate_new_plab(size_t min_size, size_t word_size, size_t* actual_size); - const size_t _min_plab_size; const size_t _max_plab_size; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 767da5f9bf3..5bf76505506 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -86,6 +86,7 @@ #include "nmt/memTracker.hpp" #include "oops/compressedOops.inline.hpp" #include "prims/jvmtiTagMap.hpp" +#include "runtime/atomic.hpp" #include "runtime/atomicAccess.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -201,9 +202,9 @@ jint ShenandoahHeap::initialize() { assert(num_min_regions <= _num_regions, "sanity"); _minimum_size = num_min_regions * reg_size_bytes; - _soft_max_size = clamp(SoftMaxHeapSize, min_capacity(), max_capacity()); + _soft_max_size.store_relaxed(clamp(SoftMaxHeapSize, min_capacity(), max_capacity())); - _committed = _initial_size; + _committed.store_relaxed(_initial_size); size_t heap_page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); size_t bitmap_page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); @@ -260,7 +261,7 @@ jint ShenandoahHeap::initialize() { // // Worker threads must be initialized after the barrier is configured // - _workers = new ShenandoahWorkerThreads("Shenandoah GC Threads", _max_workers); + _workers = new ShenandoahWorkerThreads("ShenWorker", _max_workers); if (_workers == nullptr) { vm_exit_during_initialization("Failed necessary allocation."); } else { @@ -434,7 +435,7 @@ jint ShenandoahHeap::initialize() { } _free_set = new ShenandoahFreeSet(this, _num_regions); - post_initialize_heuristics(); + initialize_generations(); // We are initializing free set. We ignore cset region tallies. size_t young_trashed_regions, old_trashed_regions, first_old, last_old, num_old; @@ -491,16 +492,17 @@ jint ShenandoahHeap::initialize() { _phase_timings = new ShenandoahPhaseTimings(max_workers()); ShenandoahCodeRoots::initialize(); + // Initialization of controller makes use of variables established by initialize_heuristics. initialize_controller(); + // Certain initialization of heuristics must be deferred until after controller is initialized. + post_initialize_heuristics(); + start_idle_span(); if (ShenandoahUncommit) { _uncommit_thread = new ShenandoahUncommitThread(this); } - print_init_logger(); - FullGCForwarding::initialize(_heap_region); - return JNI_OK; } @@ -544,10 +546,6 @@ void ShenandoahHeap::initialize_heuristics() { _global_generation->initialize_heuristics(mode()); } -void ShenandoahHeap::post_initialize_heuristics() { - _global_generation->post_initialize(this); -} - #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable:4355 ) // 'this' : used in base member initializer list @@ -689,6 +687,11 @@ public: } }; +void ShenandoahHeap::initialize_generations() { + _global_generation->post_initialize(this); +} + +// We do not call this explicitly It is called by Hotspot infrastructure. void ShenandoahHeap::post_initialize() { CollectedHeap::post_initialize(); @@ -716,6 +719,10 @@ void ShenandoahHeap::post_initialize() { JFR_ONLY(ShenandoahJFRSupport::register_jfr_type_serializers();) } +void ShenandoahHeap::post_initialize_heuristics() { + _global_generation->post_initialize_heuristics(); +} + ShenandoahHeuristics* ShenandoahHeap::heuristics() { return _global_generation->heuristics(); } @@ -725,17 +732,17 @@ size_t ShenandoahHeap::used() const { } size_t ShenandoahHeap::committed() const { - return AtomicAccess::load(&_committed); + return _committed.load_relaxed(); } void ShenandoahHeap::increase_committed(size_t bytes) { shenandoah_assert_heaplocked_or_safepoint(); - _committed += bytes; + _committed.fetch_then_add(bytes, memory_order_relaxed); } void ShenandoahHeap::decrease_committed(size_t bytes) { shenandoah_assert_heaplocked_or_safepoint(); - _committed -= bytes; + _committed.fetch_then_sub(bytes, memory_order_relaxed); } size_t ShenandoahHeap::capacity() const { @@ -747,7 +754,7 @@ size_t ShenandoahHeap::max_capacity() const { } size_t ShenandoahHeap::soft_max_capacity() const { - size_t v = AtomicAccess::load(&_soft_max_size); + size_t v = _soft_max_size.load_relaxed(); assert(min_capacity() <= v && v <= max_capacity(), "Should be in bounds: %zu <= %zu <= %zu", min_capacity(), v, max_capacity()); @@ -758,7 +765,8 @@ void ShenandoahHeap::set_soft_max_capacity(size_t v) { assert(min_capacity() <= v && v <= max_capacity(), "Should be in bounds: %zu <= %zu <= %zu", min_capacity(), v, max_capacity()); - AtomicAccess::store(&_soft_max_size, v); + _soft_max_size.store_relaxed(v); + heuristics()->compute_headroom_adjustment(); } size_t ShenandoahHeap::min_capacity() const { @@ -834,6 +842,10 @@ void ShenandoahHeap::notify_heap_changed() { _heap_changed.try_set(); } +void ShenandoahHeap::start_idle_span() { + heuristics()->start_idle_span(); +} + void ShenandoahHeap::set_forced_counters_update(bool value) { monitoring_support()->set_forced_counters_update(value); } @@ -1170,20 +1182,20 @@ public: } if (ShenandoahHeap::heap()->mode()->is_generational()) { - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - assert(plab != nullptr, "PLAB should be initialized for %s", thread->name()); + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + assert(shenandoah_plab != nullptr, "PLAB should be initialized for %s", thread->name()); // There are two reasons to retire all plabs between old-gen evacuation passes. // 1. We need to make the plab memory parsable by remembered-set scanning. // 2. We need to establish a trustworthy UpdateWaterMark value within each old-gen heap region - ShenandoahGenerationalHeap::heap()->retire_plab(plab, thread); + shenandoah_plab->retire(); // Re-enable promotions for the next evacuation phase. - ShenandoahThreadLocalData::enable_plab_promotions(thread); + shenandoah_plab->enable_promotions(); // Reset the fill size for next evacuation phase. - if (_resize && ShenandoahThreadLocalData::plab_size(thread) > 0) { - ShenandoahThreadLocalData::set_plab_size(thread, 0); + if (_resize && shenandoah_plab->desired_size() > 0) { + shenandoah_plab->set_desired_size(0); } } } @@ -1341,12 +1353,21 @@ oop ShenandoahHeap::try_evacuate_object(oop p, Thread* thread, ShenandoahHeapReg // Copy the object: Copy::aligned_disjoint_words(cast_from_oop(p), copy, size); - // Try to install the new forwarding pointer. oop copy_val = cast_to_oop(copy); + + // Relativize stack chunks before publishing the copy. After the forwarding CAS, + // mutators can see the copy and thaw it via the fast path if flags == 0. We must + // relativize derived pointers and set gc_mode before that happens. Skip if the + // copy's mark word is already a forwarding pointer (another thread won the race + // and overwrote the original's header before we copied it). + if (!ShenandoahForwarding::is_forwarded(copy_val)) { + ContinuationGCSupport::relativize_stack_chunk(copy_val); + } + + // Try to install the new forwarding pointer. oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val); if (result == copy_val) { // Successfully evacuated. Our copy is now the public one! - ContinuationGCSupport::relativize_stack_chunk(copy_val); shenandoah_assert_correct(nullptr, copy_val); if (ShenandoahEvacTracking) { evac_tracker()->end_evacuation(thread, size * HeapWordSize, from_region->affiliation(), target_gen); @@ -1453,9 +1474,9 @@ public: assert(gclab->words_remaining() == 0, "GCLAB should not need retirement"); if (ShenandoahHeap::heap()->mode()->is_generational()) { - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - assert(plab != nullptr, "PLAB should be initialized for %s", thread->name()); - assert(plab->words_remaining() == 0, "PLAB should not need retirement"); + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + assert(shenandoah_plab != nullptr, "PLAB should be initialized for %s", thread->name()); + assert(shenandoah_plab->plab()->words_remaining() == 0, "PLAB should not need retirement"); } } }; @@ -1941,7 +1962,7 @@ private: size_t const _stride; shenandoah_padding(0); - volatile size_t _index; + Atomic _index; shenandoah_padding(1); public: @@ -1954,8 +1975,8 @@ public: size_t stride = _stride; size_t max = _heap->num_regions(); - while (AtomicAccess::load(&_index) < max) { - size_t cur = AtomicAccess::fetch_then_add(&_index, stride, memory_order_relaxed); + while (_index.load_relaxed() < max) { + size_t cur = _index.fetch_then_add(stride, memory_order_relaxed); size_t start = cur; size_t end = MIN2(cur + stride, max); if (start >= max) break; @@ -2688,10 +2709,7 @@ GrowableArray ShenandoahHeap::memory_pools() { } MemoryUsage ShenandoahHeap::memory_usage() { - assert(_initial_size <= ShenandoahHeap::heap()->max_capacity(), "sanity"); - assert(used() <= ShenandoahHeap::heap()->max_capacity(), "sanity"); - assert(committed() <= ShenandoahHeap::heap()->max_capacity(), "sanity"); - return MemoryUsage(_initial_size, used(), committed(), max_capacity()); + return shenandoah_memory_usage(_initial_size, used(), committed(), max_capacity()); } ShenandoahRegionIterator::ShenandoahRegionIterator() : @@ -2703,11 +2721,11 @@ ShenandoahRegionIterator::ShenandoahRegionIterator(ShenandoahHeap* heap) : _index(0) {} void ShenandoahRegionIterator::reset() { - _index = 0; + _index.store_relaxed(0); } bool ShenandoahRegionIterator::has_next() const { - return _index < _heap->num_regions(); + return _index.load_relaxed() < _heap->num_regions(); } ShenandoahLiveData* ShenandoahHeap::get_liveness_cache(uint worker_id) { @@ -2833,3 +2851,13 @@ void ShenandoahHeap::log_heap_status(const char* msg) const { global_generation()->log_status(msg); } } + +ShenandoahHeapLocker::ShenandoahHeapLocker(ShenandoahHeapLock* lock, bool allow_block_for_safepoint) : _lock(lock) { +#ifdef ASSERT + ShenandoahFreeSet* free_set = ShenandoahHeap::heap()->free_set(); + // free_set is nullptr only at pre-initialized state + assert(free_set == nullptr || !free_set->rebuild_lock()->owned_by_self(), "Dead lock, can't acquire heap lock while holding free-set rebuild lock"); + assert(_lock != nullptr, "Must not"); +#endif + _lock->lock(allow_block_for_safepoint); +} diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 9240091070b..d4604be0aec 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -88,7 +88,7 @@ private: ShenandoahHeap* _heap; shenandoah_padding(0); - volatile size_t _index; + Atomic _index; shenandoah_padding(1); // No implicit copying: iterators should be passed by reference to capture the state @@ -117,9 +117,23 @@ public: virtual bool is_thread_safe() { return false; } }; -typedef ShenandoahLock ShenandoahHeapLock; -typedef ShenandoahLocker ShenandoahHeapLocker; -typedef Stack ShenandoahScanObjectStack; +typedef ShenandoahLock ShenandoahHeapLock; +// ShenandoahHeapLocker implements locker to assure mutually exclusive access to the global heap data structures. +// Asserts in the implementation detect potential deadlock usage with regards the rebuild lock that is present +// in ShenandoahFreeSet. Whenever both locks are acquired, this lock should be acquired before the +// ShenandoahFreeSet rebuild lock. +class ShenandoahHeapLocker : public StackObj { +private: + ShenandoahHeapLock* _lock; +public: + ShenandoahHeapLocker(ShenandoahHeapLock* lock, bool allow_block_for_safepoint = false); + + ~ShenandoahHeapLocker() { + _lock->unlock(); + } +}; + +typedef Stack ShenandoahScanObjectStack; // Shenandoah GC is low-pause concurrent GC that uses a load reference barrier // for concurent evacuation and a snapshot-at-the-beginning write barrier for @@ -181,6 +195,7 @@ public: ShenandoahHeap(ShenandoahCollectorPolicy* policy); jint initialize() override; void post_initialize() override; + virtual void initialize_generations(); void initialize_mode(); virtual void initialize_heuristics(); virtual void post_initialize_heuristics(); @@ -208,9 +223,9 @@ private: size_t _initial_size; size_t _minimum_size; - volatile size_t _soft_max_size; + Atomic _soft_max_size; shenandoah_padding(0); - volatile size_t _committed; + Atomic _committed; shenandoah_padding(1); public: @@ -340,7 +355,7 @@ private: ShenandoahSharedFlag _full_gc_move_in_progress; ShenandoahSharedFlag _concurrent_strong_root_in_progress; - size_t _gc_no_progress_count; + Atomic _gc_no_progress_count; // This updates the singular, global gc state. This call must happen on a safepoint. void set_gc_state_at_safepoint(uint mask, bool value); @@ -379,6 +394,8 @@ public: return _heap_changed.try_unset(); } + virtual void start_idle_span(); + void set_concurrent_young_mark_in_progress(bool in_progress); void set_concurrent_old_mark_in_progress(bool in_progress); void set_evacuation_in_progress(bool in_progress); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index e35f116b843..6d77cccaa6a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -49,7 +49,7 @@ #include "gc/shenandoah/shenandoahWorkGroup.hpp" #include "oops/compressedOops.inline.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/objectMonitor.inline.hpp" #include "runtime/prefetch.inline.hpp" @@ -61,7 +61,7 @@ inline ShenandoahHeap* ShenandoahHeap::heap() { } inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() { - size_t new_index = AtomicAccess::add(&_index, (size_t) 1, memory_order_relaxed); + size_t new_index = _index.add_then_fetch((size_t) 1, memory_order_relaxed); // get_region() provides the bounds-check and returns null on OOB. return _heap->get_region(new_index - 1); } @@ -75,15 +75,15 @@ inline WorkerThreads* ShenandoahHeap::safepoint_workers() { } inline void ShenandoahHeap::notify_gc_progress() { - AtomicAccess::store(&_gc_no_progress_count, (size_t) 0); + _gc_no_progress_count.store_relaxed((size_t) 0); } inline void ShenandoahHeap::notify_gc_no_progress() { - AtomicAccess::inc(&_gc_no_progress_count); + _gc_no_progress_count.add_then_fetch((size_t) 1); } inline size_t ShenandoahHeap::get_gc_no_progress_count() const { - return AtomicAccess::load(&_gc_no_progress_count); + return _gc_no_progress_count.load_relaxed(); } inline size_t ShenandoahHeap::heap_region_index_containing(const void* addr) const { @@ -344,6 +344,8 @@ uint ShenandoahHeap::get_object_age(oop obj) { } if (w.has_monitor()) { w = w.monitor()->header(); + } else { + assert(!w.has_displaced_mark_helper(), "Mark word should not be displaced"); } assert(w.age() <= markWord::max_age, "Impossible!"); return w.age(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp index aed3faef906..ff1e3368e87 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp @@ -32,7 +32,6 @@ #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/perfData.inline.hpp" #include "utilities/defaultStream.hpp" @@ -106,8 +105,8 @@ void ShenandoahHeapRegionCounters::write_snapshot(PerfLongVariable** regions, void ShenandoahHeapRegionCounters::update() { if (ShenandoahRegionSampling) { jlong current = nanos_to_millis(os::javaTimeNanos()); - jlong last = _last_sample_millis; - if (current - last > ShenandoahRegionSamplingRate && AtomicAccess::cmpxchg(&_last_sample_millis, last, current) == last) { + jlong last = _last_sample_millis.load_relaxed(); + if (current - last > ShenandoahRegionSamplingRate && _last_sample_millis.compare_exchange(last, current) == last) { ShenandoahHeap* heap = ShenandoahHeap::heap(); _status->set_value(encode_heap_status(heap)); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp index 508b40e49a8..d50188bf70c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp @@ -28,6 +28,7 @@ #include "logging/logFileStreamOutput.hpp" #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" /** * This provides the following in JVMStat: @@ -88,7 +89,7 @@ private: PerfLongVariable** _regions_data; PerfLongVariable* _timestamp; PerfLongVariable* _status; - volatile jlong _last_sample_millis; + Atomic _last_sample_millis; void write_snapshot(PerfLongVariable** regions, PerfLongVariable* ts, diff --git a/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.cpp b/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.cpp index 83f4217df83..10d61221e87 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.cpp @@ -26,38 +26,11 @@ #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahInPlacePromoter.hpp" #include "gc/shenandoah/shenandoahMarkingContext.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -ShenandoahInPlacePromotionPlanner::RegionPromotions::RegionPromotions(ShenandoahFreeSet* free_set) - : _low_idx(free_set->max_regions()) - , _high_idx(-1) - , _regions(0) - , _bytes(0) - , _free_set(free_set) -{ -} - -void ShenandoahInPlacePromotionPlanner::RegionPromotions::increment(idx_t region_index, size_t remnant_bytes) { - if (region_index < _low_idx) { - _low_idx = region_index; - } - if (region_index > _high_idx) { - _high_idx = region_index; - } - _regions++; - _bytes += remnant_bytes; -} - -void ShenandoahInPlacePromotionPlanner::RegionPromotions::update_free_set(ShenandoahFreeSetPartitionId partition_id) const { - if (_regions > 0) { - _free_set->shrink_interval_if_range_modifies_either_boundary(partition_id, _low_idx, _high_idx, _regions); - } -} - ShenandoahInPlacePromotionPlanner::ShenandoahInPlacePromotionPlanner(const ShenandoahGenerationalHeap* heap) : _old_garbage_threshold(ShenandoahHeapRegion::region_size_bytes() * heap->old_generation()->heuristics()->get_old_garbage_threshold() / 100) , _pip_used_threshold(ShenandoahHeapRegion::region_size_bytes() * ShenandoahGenerationalMinPIPUsage / 100) @@ -75,6 +48,7 @@ bool ShenandoahInPlacePromotionPlanner::is_eligible(const ShenandoahHeapRegion* } void ShenandoahInPlacePromotionPlanner::prepare(ShenandoahHeapRegion* r) { + assert(!r->is_humongous_continuation(), "Should not call for humongous continuations"); HeapWord* tams = _marking_context->top_at_mark_start(r); HeapWord* original_top = r->top(); @@ -86,6 +60,20 @@ void ShenandoahInPlacePromotionPlanner::prepare(ShenandoahHeapRegion* r) { return; } + if (r->is_humongous_start()) { + if (const oop obj = cast_to_oop(r->bottom()); !obj->is_typeArray()) { + // Nothing else to do for humongous, we just update the stats and move on. The humongous regions + // themselves will be discovered and promoted by gc workers during evacuation. Note that humongous + // primitive arrays are not promoted. + const size_t num_regions = ShenandoahHeapRegion::required_regions(obj->size() * HeapWordSize); + for (size_t i = r->index(); i < r->index() + num_regions; i++) { + _pip_humongous_stats.update(_heap->get_region(i)); + } + } + return; + } + + _pip_regular_stats.update(r); // No allocations from this region have been made during concurrent mark. It meets all the criteria // for in-place-promotion. Though we only need the value of top when we fill the end of the region, // we use this field to indicate that this region should be promoted in place during the evacuation @@ -128,8 +116,14 @@ void ShenandoahInPlacePromotionPlanner::prepare(ShenandoahHeapRegion* r) { } } -void ShenandoahInPlacePromotionPlanner::update_free_set() const { +void ShenandoahInPlacePromotionPlanner::complete_planning() const { _heap->old_generation()->set_pad_for_promote_in_place(_pip_padding_bytes); + _heap->old_generation()->set_expected_humongous_region_promotions(_pip_humongous_stats.count); + _heap->old_generation()->set_expected_regular_region_promotions(_pip_regular_stats.count); + log_info(gc, ergo)("Planning to promote in place %zu humongous regions and %zu" + " regular regions, spanning a total of %zu used bytes", + _pip_humongous_stats.count, _pip_regular_stats.count, + _pip_humongous_stats.usage + _pip_regular_stats.usage); if (_mutator_regions._regions + _collector_regions._regions > 0) { _free_set->account_for_pip_regions(_mutator_regions._regions, _mutator_regions._bytes, diff --git a/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.hpp b/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.hpp index 939107dd3ac..d2cb644a59e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahInPlacePromoter.hpp @@ -25,16 +25,21 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHINPLACEPROMOTER_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHINPLACEPROMOTER_HPP +#include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahSimpleBitMap.hpp" -class ShenandoahFreeSet; class ShenandoahMarkingContext; class ShenandoahGenerationalHeap; -class ShenandoahHeapRegion; +// This class is responsible for identifying regions that can be +// promoted in place. It also prepares these regions by preventing +// them from being used for allocations. Finally, it notifies the +// freeset which regions are to be promoted in place. class ShenandoahInPlacePromotionPlanner { using idx_t = ShenandoahSimpleBitMap::idx_t; + // Used to inform free set of regions being promoted struct RegionPromotions { idx_t _low_idx; idx_t _high_idx; @@ -42,9 +47,47 @@ class ShenandoahInPlacePromotionPlanner { size_t _bytes; ShenandoahFreeSet* _free_set; - explicit RegionPromotions(ShenandoahFreeSet* free_set); - void increment(idx_t region_index, size_t remnant_bytes); - void update_free_set(ShenandoahFreeSetPartitionId partition_id) const; + explicit RegionPromotions(ShenandoahFreeSet* free_set) + : _low_idx(free_set->max_regions()) + , _high_idx(-1) + , _regions(0) + , _bytes(0) + , _free_set(free_set) + { + } + + void increment(idx_t region_index, size_t remnant_bytes) { + if (region_index < _low_idx) { + _low_idx = region_index; + } + if (region_index > _high_idx) { + _high_idx = region_index; + } + _regions++; + _bytes += remnant_bytes; + } + + void update_free_set(ShenandoahFreeSetPartitionId partition_id) const { + if (_regions > 0) { + _free_set->shrink_interval_if_range_modifies_either_boundary(partition_id, _low_idx, _high_idx, _regions); + } + } + }; + + // Used to track metrics about the regions being promoted in place + struct RegionPromotionStats { + size_t count; + size_t usage; + size_t free; + size_t garbage; + + RegionPromotionStats() : count(0), usage(0), free(0), garbage(0) {} + void update(ShenandoahHeapRegion* region) { + count++; + usage += region->used(); + free += region->free(); + garbage += region->garbage(); + } }; const size_t _old_garbage_threshold; @@ -60,6 +103,11 @@ class ShenandoahInPlacePromotionPlanner { // Tracks the padding of space above top in regions eligible for promotion in place size_t _pip_padding_bytes; + + // Tracks stats for in place promotions + RegionPromotionStats _pip_regular_stats; + RegionPromotionStats _pip_humongous_stats; + public: explicit ShenandoahInPlacePromotionPlanner(const ShenandoahGenerationalHeap* heap); @@ -69,12 +117,17 @@ public: // Prepares the region for promotion by moving top to the end to prevent allocations void prepare(ShenandoahHeapRegion* region); - // Notifies the free set of in place promotions - void update_free_set() const; + // Notifies the free set and old generation of in place promotions + void complete_planning() const; + + const RegionPromotionStats& regular_region_stats() const { return _pip_regular_stats; } + const RegionPromotionStats& humongous_region_stats() const { return _pip_humongous_stats; } size_t old_garbage_threshold() const { return _old_garbage_threshold; } }; +// For regions that have been selected and prepared for promotion, this class +// will perform the actual promotion. class ShenandoahInPlacePromoter { ShenandoahGenerationalHeap* _heap; public: @@ -89,3 +142,4 @@ private: }; #endif // SHARE_GC_SHENANDOAH_SHENANDOAHINPLACEPROMOTER_HPP + diff --git a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp index 7eec0b9af64..7e317f53424 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp @@ -93,7 +93,7 @@ ShenandoahSimpleLock::ShenandoahSimpleLock() { assert(os::mutex_init_done(), "Too early!"); } -void ShenandoahSimpleLock::lock() { +void ShenandoahSimpleLock::lock(bool allow_block_for_safepoint) { _lock.lock(); } @@ -101,28 +101,31 @@ void ShenandoahSimpleLock::unlock() { _lock.unlock(); } -ShenandoahReentrantLock::ShenandoahReentrantLock() : - ShenandoahSimpleLock(), _owner(nullptr), _count(0) { - assert(os::mutex_init_done(), "Too early!"); +template +ShenandoahReentrantLock::ShenandoahReentrantLock() : + Lock(), _owner(nullptr), _count(0) { } -ShenandoahReentrantLock::~ShenandoahReentrantLock() { +template +ShenandoahReentrantLock::~ShenandoahReentrantLock() { assert(_count == 0, "Unbalance"); } -void ShenandoahReentrantLock::lock() { +template +void ShenandoahReentrantLock::lock(bool allow_block_for_safepoint) { Thread* const thread = Thread::current(); Thread* const owner = _owner.load_relaxed(); if (owner != thread) { - ShenandoahSimpleLock::lock(); + Lock::lock(allow_block_for_safepoint); _owner.store_relaxed(thread); } _count++; } -void ShenandoahReentrantLock::unlock() { +template +void ShenandoahReentrantLock::unlock() { assert(owned_by_self(), "Invalid owner"); assert(_count > 0, "Invalid count"); @@ -130,12 +133,17 @@ void ShenandoahReentrantLock::unlock() { if (_count == 0) { _owner.store_relaxed((Thread*)nullptr); - ShenandoahSimpleLock::unlock(); + Lock::unlock(); } } -bool ShenandoahReentrantLock::owned_by_self() const { +template +bool ShenandoahReentrantLock::owned_by_self() const { Thread* const thread = Thread::current(); Thread* const owner = _owner.load_relaxed(); return owner == thread; } + +// Explicit template instantiation +template class ShenandoahReentrantLock; +template class ShenandoahReentrantLock; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp b/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp index 2e44810cd5d..7c91df191e5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp @@ -31,7 +31,7 @@ #include "runtime/javaThread.hpp" #include "runtime/safepoint.hpp" -class ShenandoahLock { +class ShenandoahLock { private: enum LockState { unlocked = 0, locked = 1 }; @@ -48,7 +48,7 @@ private: public: ShenandoahLock() : _state(unlocked), _owner(nullptr) {}; - void lock(bool allow_block_for_safepoint) { + void lock(bool allow_block_for_safepoint = false) { assert(_owner.load_relaxed() != Thread::current(), "reentrant locking attempt, would deadlock"); if ((allow_block_for_safepoint && SafepointSynchronize::is_synchronizing()) || @@ -83,34 +83,19 @@ public: } }; -class ShenandoahLocker : public StackObj { -private: - ShenandoahLock* const _lock; -public: - ShenandoahLocker(ShenandoahLock* lock, bool allow_block_for_safepoint = false) : _lock(lock) { - if (_lock != nullptr) { - _lock->lock(allow_block_for_safepoint); - } - } - - ~ShenandoahLocker() { - if (_lock != nullptr) { - _lock->unlock(); - } - } -}; - +// Simple lock using PlatformMonitor class ShenandoahSimpleLock { private: PlatformMonitor _lock; // native lock public: ShenandoahSimpleLock(); - - virtual void lock(); - virtual void unlock(); + void lock(bool allow_block_for_safepoint = false); + void unlock(); }; -class ShenandoahReentrantLock : public ShenandoahSimpleLock { +// templated reentrant lock +template +class ShenandoahReentrantLock : public Lock { private: Atomic _owner; uint64_t _count; @@ -119,30 +104,25 @@ public: ShenandoahReentrantLock(); ~ShenandoahReentrantLock(); - virtual void lock(); - virtual void unlock(); + void lock(bool allow_block_for_safepoint = false); + void unlock(); // If the lock already owned by this thread bool owned_by_self() const ; }; -class ShenandoahReentrantLocker : public StackObj { -private: - ShenandoahReentrantLock* const _lock; - +// template based ShenandoahLocker +template +class ShenandoahLocker : public StackObj { + Lock* const _lock; public: - ShenandoahReentrantLocker(ShenandoahReentrantLock* lock) : - _lock(lock) { - if (_lock != nullptr) { - _lock->lock(); - } + ShenandoahLocker(Lock* lock, bool allow_block_for_safepoint = false) : _lock(lock) { + assert(_lock != nullptr, "Must not"); + _lock->lock(allow_block_for_safepoint); } - ~ShenandoahReentrantLocker() { - if (_lock != nullptr) { - assert(_lock->owned_by_self(), "Must be owner"); - _lock->unlock(); - } + ~ShenandoahLocker() { + _lock->unlock(); } }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp index ba24e890769..0d42b95164b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp @@ -77,10 +77,9 @@ void ShenandoahMark::do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveD if (task->is_not_chunked()) { if (obj->is_instance()) { // Case 1: Normal oop, process as usual. - if (ContinuationGCSupport::relativize_stack_chunk(obj)) { - // Loom doesn't support mixing of weak marking and strong marking of - // stack chunks. - cl->set_weak(false); + if (obj->is_stackChunk()) { + // Loom doesn't support mixing of weak marking and strong marking of stack chunks. + cl->set_weak(false); } obj->oop_iterate(cl); @@ -118,13 +117,11 @@ inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop ob // Age census for objects in the young generation if (GENERATION == YOUNG || (GENERATION == GLOBAL && region->is_young())) { assert(heap->mode()->is_generational(), "Only if generational"); - if (ShenandoahGenerationalAdaptiveTenuring) { - assert(region->is_young(), "Only for young objects"); - uint age = ShenandoahHeap::get_object_age(obj); - ShenandoahAgeCensus* const census = ShenandoahGenerationalHeap::heap()->age_census(); - CENSUS_NOISE(census->add(age, region->age(), region->youth(), size, worker_id);) - NO_CENSUS_NOISE(census->add(age, region->age(), size, worker_id);) - } + assert(region->is_young(), "Only for young objects"); + const uint age = ShenandoahHeap::get_object_age(obj); + ShenandoahAgeCensus* const census = ShenandoahGenerationalHeap::heap()->age_census(); + CENSUS_NOISE(census->add(age, region->age(), region->youth(), size, worker_id);) + NO_CENSUS_NOISE(census->add(age, region->age(), size, worker_id);) } if (!region->is_humongous_start()) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp index d55d1bd8147..dfc34dcc3c3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp @@ -48,25 +48,7 @@ ShenandoahMemoryPool::ShenandoahMemoryPool(ShenandoahHeap* heap, MemoryUsage ShenandoahMemoryPool::get_memory_usage() { - size_t initial = initial_size(); - size_t max = max_size(); - size_t used = used_in_bytes(); - size_t committed = _heap->committed(); - - // These asserts can never fail: max is stable, and all updates to other values never overflow max. - assert(initial <= max, "initial: %zu, max: %zu", initial, max); - assert(used <= max, "used: %zu, max: %zu", used, max); - assert(committed <= max, "committed: %zu, max: %zu", committed, max); - - // Committed and used are updated concurrently and independently. They can momentarily break - // the assert below, which would also fail in downstream code. To avoid that, adjust values - // to make sense under the race. See JDK-8207200. - committed = MAX2(used, committed); - assert(used <= committed, "used: %zu, committed: %zu", used, committed); - assert(initial <= _heap->max_capacity(), "sanity"); - assert(committed <= _heap->max_capacity(), "sanity"); - assert(max <= _heap->max_capacity(), "sanity"); - return MemoryUsage(initial, used, committed, max); + return shenandoah_memory_usage(initial_size(), used_in_bytes(), _heap->committed(), max_size()); } size_t ShenandoahMemoryPool::used_in_bytes() { @@ -83,16 +65,7 @@ ShenandoahGenerationalMemoryPool::ShenandoahGenerationalMemoryPool(ShenandoahHea _generation(generation) { } MemoryUsage ShenandoahGenerationalMemoryPool::get_memory_usage() { - size_t initial = initial_size(); - size_t max = max_size(); - size_t used = used_in_bytes(); - size_t committed = _generation->used_regions_size(); - - assert(initial <= _heap->max_capacity(), "sanity"); - assert(used <= _heap->max_capacity(), "sanity"); - assert(committed <= _heap->max_capacity(), "sanity"); - assert(max <= _heap->max_capacity(), "sanity"); - return MemoryUsage(initial, used, committed, max); + return shenandoah_memory_usage(initial_size(), used_in_bytes(), _generation->used_regions_size(), max_size()); } size_t ShenandoahGenerationalMemoryPool::used_in_bytes() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.hpp index ccdfdddede9..d466087b9b7 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.hpp @@ -30,6 +30,17 @@ #include "services/memoryPool.hpp" #include "services/memoryUsage.hpp" +// Constructs a MemoryUsage from concurrently sampled values, clamping committed +// to be at least as large as used to account for concurrent updates. See JDK-8207200. +inline MemoryUsage shenandoah_memory_usage(size_t initial, size_t used, size_t committed, size_t max) { + assert(initial <= max, "initial: %zu, max: %zu", initial, max); + assert(used <= max, "used: %zu, max: %zu", used, max); + assert(committed <= max, "committed: %zu, max: %zu", committed, max); + committed = MAX2(used, committed); + assert(used <= committed, "used: %zu, committed: %zu", used, committed); + return MemoryUsage(initial, used, committed, max); +} + class ShenandoahMemoryPool : public CollectedMemoryPool { protected: ShenandoahHeap* _heap; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp index 55cec63f045..594ad614d90 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp @@ -241,7 +241,7 @@ void ShenandoahNMethodTable::register_nmethod(nmethod* nm) { assert(nm == data->nm(), "Must be same nmethod"); // Prevent updating a nmethod while concurrent iteration is in progress. wait_until_concurrent_iteration_done(); - ShenandoahReentrantLocker data_locker(data->lock()); + ShenandoahNMethodLocker data_locker(data->lock()); data->update(); } else { // For a new nmethod, we can safely append it to the list, because @@ -433,8 +433,8 @@ void ShenandoahNMethodTableSnapshot::parallel_nmethods_do(NMethodClosure *f) { ShenandoahNMethod** const list = _list->list(); size_t max = (size_t)_limit; - while (_claimed < max) { - size_t cur = AtomicAccess::fetch_then_add(&_claimed, stride, memory_order_relaxed); + while (_claimed.load_relaxed() < max) { + size_t cur = _claimed.fetch_then_add(stride, memory_order_relaxed); size_t start = cur; size_t end = MIN2(cur + stride, max); if (start >= max) break; @@ -457,8 +457,8 @@ void ShenandoahNMethodTableSnapshot::concurrent_nmethods_do(NMethodClosure* cl) ShenandoahNMethod** list = _list->list(); size_t max = (size_t)_limit; - while (_claimed < max) { - size_t cur = AtomicAccess::fetch_then_add(&_claimed, stride, memory_order_relaxed); + while (_claimed.load_relaxed() < max) { + size_t cur = _claimed.fetch_then_add(stride, memory_order_relaxed); size_t start = cur; size_t end = MIN2(cur + stride, max); if (start >= max) break; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp index 5387870c9dc..2686b4f4985 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp @@ -30,8 +30,13 @@ #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" #include "utilities/growableArray.hpp" +// Use ShenandoahReentrantLock as ShenandoahNMethodLock +typedef ShenandoahReentrantLock ShenandoahNMethodLock; +typedef ShenandoahLocker ShenandoahNMethodLocker; + // ShenandoahNMethod tuple records the internal locations of oop slots within reclocation stream in // the nmethod. This allows us to quickly scan the oops without doing the nmethod-internal scans, // that sometimes involves parsing the machine code. Note it does not record the oops themselves, @@ -43,16 +48,16 @@ private: int _oops_count; bool _has_non_immed_oops; bool _unregistered; - ShenandoahReentrantLock _lock; - ShenandoahReentrantLock _ic_lock; + ShenandoahNMethodLock _lock; + ShenandoahNMethodLock _ic_lock; public: ShenandoahNMethod(nmethod *nm, GrowableArray& oops, bool has_non_immed_oops); ~ShenandoahNMethod(); inline nmethod* nm() const; - inline ShenandoahReentrantLock* lock(); - inline ShenandoahReentrantLock* ic_lock(); + inline ShenandoahNMethodLock* lock(); + inline ShenandoahNMethodLock* ic_lock(); inline void oops_do(OopClosure* oops, bool fix_relocations = false); // Update oops when the nmethod is re-registered void update(); @@ -60,8 +65,8 @@ public: inline bool is_unregistered() const; static ShenandoahNMethod* for_nmethod(nmethod* nm); - static inline ShenandoahReentrantLock* lock_for_nmethod(nmethod* nm); - static inline ShenandoahReentrantLock* ic_lock_for_nmethod(nmethod* nm); + static inline ShenandoahNMethodLock* lock_for_nmethod(nmethod* nm); + static inline ShenandoahNMethodLock* ic_lock_for_nmethod(nmethod* nm); static void heal_nmethod(nmethod* nm); static inline void heal_nmethod_metadata(ShenandoahNMethod* nmethod_data); @@ -115,7 +120,7 @@ private: int _limit; shenandoah_padding(0); - volatile size_t _claimed; + Atomic _claimed; shenandoah_padding(1); public: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp index 6758298675b..ef9e347b821 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp @@ -35,11 +35,11 @@ nmethod* ShenandoahNMethod::nm() const { return _nm; } -ShenandoahReentrantLock* ShenandoahNMethod::lock() { +ShenandoahNMethodLock* ShenandoahNMethod::lock() { return &_lock; } -ShenandoahReentrantLock* ShenandoahNMethod::ic_lock() { +ShenandoahNMethodLock* ShenandoahNMethod::ic_lock() { return &_ic_lock; } @@ -85,11 +85,11 @@ void ShenandoahNMethod::attach_gc_data(nmethod* nm, ShenandoahNMethod* gc_data) nm->set_gc_data(gc_data); } -ShenandoahReentrantLock* ShenandoahNMethod::lock_for_nmethod(nmethod* nm) { +ShenandoahNMethodLock* ShenandoahNMethod::lock_for_nmethod(nmethod* nm) { return gc_data(nm)->lock(); } -ShenandoahReentrantLock* ShenandoahNMethod::ic_lock_for_nmethod(nmethod* nm) { +ShenandoahNMethodLock* ShenandoahNMethod::ic_lock_for_nmethod(nmethod* nm) { return gc_data(nm)->ic_lock(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp index 32c63e9b186..1ddd8e1c032 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp @@ -198,11 +198,11 @@ void BinaryMagnitudeSeq::clear() { for (int c = 0; c < BitsPerSize_t; c++) { _mags[c] = 0; } - _sum = 0; + _sum.store_relaxed(0); } void BinaryMagnitudeSeq::add(size_t val) { - AtomicAccess::add(&_sum, val); + _sum.add_then_fetch(val); int mag = log2i_graceful(val) + 1; @@ -237,7 +237,7 @@ size_t BinaryMagnitudeSeq::num() const { } size_t BinaryMagnitudeSeq::sum() const { - return _sum; + return _sum.load_relaxed(); } int BinaryMagnitudeSeq::min_level() const { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.hpp b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.hpp index 68f3cfba97a..1a14f930174 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHNUMBERSEQ_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHNUMBERSEQ_HPP +#include "runtime/atomic.hpp" #include "utilities/numberSeq.hpp" // HDR sequence stores the low-resolution high-dynamic-range values. @@ -59,7 +60,7 @@ public: // is not needed, it is preferred over HdrSeq. class BinaryMagnitudeSeq : public CHeapObj { private: - size_t _sum; + Atomic _sum; size_t* _mags; public: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp index d5e34d02b13..16a24da8b1c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp @@ -38,6 +38,7 @@ #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" +#include "gc/shenandoah/shenandoahThreadLocalData.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahWorkerPolicy.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" @@ -109,8 +110,6 @@ ShenandoahOldGeneration::ShenandoahOldGeneration(uint max_queues) _promoted_expended(0), _promotion_potential(0), _pad_for_promote_in_place(0), - _promotion_failure_count(0), - _promotion_failure_words(0), _promotable_humongous_regions(0), _promotable_regular_regions(0), _is_parsable(true), @@ -148,8 +147,50 @@ void ShenandoahOldGeneration::augment_promoted_reserve(size_t increment) { void ShenandoahOldGeneration::reset_promoted_expended() { shenandoah_assert_heaplocked_or_safepoint(); _promoted_expended.store_relaxed(0); - _promotion_failure_count.store_relaxed(0); - _promotion_failure_words.store_relaxed(0); +} + +void ShenandoahOldGeneration::maybe_log_promotion_failure_stats(bool concurrent) const { + LogTarget(Info, gc, plab) plab_info; + if (plab_info.is_enabled()) { + size_t failed_count = 0; + size_t failed_words = 0; + + class AggregatePromotionFailuresClosure : public ThreadClosure { + private: + size_t _total_count; + size_t _total_words; + public: + AggregatePromotionFailuresClosure() : _total_count(0), _total_words(0) {} + + void do_thread(Thread* thread) override { + ShenandoahPLAB* plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + if (plab != nullptr) { + _total_count += plab->get_promotion_failure_count(); + _total_words += plab->get_promotion_failure_words(); + plab->reset_promotion_failures(); + } + } + + size_t total_count() const { return _total_count; } + size_t total_words() const { return _total_words; } + }; + + AggregatePromotionFailuresClosure cl; + if (concurrent) { + MutexLocker lock(Threads_lock); + Threads::threads_do(&cl); + } else { + Threads::threads_do(&cl); + } + + failed_count = cl.total_count(); + failed_words = cl.total_words(); + + LogStream ls(plab_info); + ls.print_cr("Cycle complete, promotions reserved: %zu, promotions expended: %zu, failed count: %zu, failed bytes: %zu", + get_promoted_reserve(), get_promoted_expended(), + failed_count, failed_words * HeapWordSize); + } } size_t ShenandoahOldGeneration::expend_promoted(size_t increment) { @@ -199,7 +240,8 @@ ShenandoahOldGeneration::configure_plab_for_current_thread(const ShenandoahAlloc // We've created a new plab. Now we configure it whether it will be used for promotions // and evacuations - or just evacuations. Thread* thread = Thread::current(); - ShenandoahThreadLocalData::reset_plab_promoted(thread); + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + shenandoah_plab->reset_promoted(); // The actual size of the allocation may be larger than the requested bytes (due to alignment on card boundaries). // If this puts us over our promotion budget, we need to disable future PLAB promotions for this thread. @@ -209,12 +251,12 @@ ShenandoahOldGeneration::configure_plab_for_current_thread(const ShenandoahAlloc log_debug(gc, plab)("Thread can promote using PLAB of %zu bytes. Expended: %zu, available: %zu", actual_size, get_promoted_expended(), get_promoted_reserve()); expend_promoted(actual_size); - ShenandoahThreadLocalData::enable_plab_promotions(thread); - ShenandoahThreadLocalData::set_plab_actual_size(thread, actual_size); + shenandoah_plab->enable_promotions(); + shenandoah_plab->set_actual_size(actual_size); } else { // Disable promotions in this thread because entirety of this PLAB must be available to hold old-gen evacuations. - ShenandoahThreadLocalData::disable_plab_promotions(thread); - ShenandoahThreadLocalData::set_plab_actual_size(thread, 0); + shenandoah_plab->disable_promotions(); + shenandoah_plab->set_actual_size(0); log_debug(gc, plab)("Thread cannot promote using PLAB of %zu bytes. Expended: %zu, available: %zu, mixed evacuations? %s", actual_size, get_promoted_expended(), get_promoted_reserve(), BOOL_TO_STR(ShenandoahHeap::heap()->collection_set()->has_old_regions())); } @@ -422,6 +464,7 @@ void ShenandoahOldGeneration::prepare_regions_and_collection_set(bool concurrent // At the end of old-gen, we may find that we have reclaimed immediate garbage, allowing a longer allocation runway. // We may also find that we have accumulated canddiate regions for mixed evacuation. If so, we will want to expand // the OldCollector reserve in order to make room for these mixed evacuations. + assert(ShenandoahHeap::heap()->mode()->is_generational(), "sanity"); assert(young_trash_regions == 0, "sanity"); ShenandoahGenerationalHeap* gen_heap = ShenandoahGenerationalHeap::heap(); @@ -581,13 +624,21 @@ void ShenandoahOldGeneration::handle_failed_evacuation() { } } -void ShenandoahOldGeneration::handle_failed_promotion(Thread* thread, size_t size) { - _promotion_failure_count.add_then_fetch(1UL); - _promotion_failure_words.and_then_fetch(size); +void ShenandoahOldGeneration::handle_failed_promotion(Thread* thread, size_t size) const { + LogTarget(Info, gc, plab) plab_info; + if (plab_info.is_enabled()) { + ShenandoahPLAB* plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + if (plab != nullptr) { + plab->record_promotion_failure(size); + } else { + ResourceMark for_thread_name; + log_debug(gc, plab)("Thread: %s has no plab", thread->name()); + } + } - LogTarget(Debug, gc, plab) lt; - LogStream ls(lt); - if (lt.is_enabled()) { + LogTarget(Debug, gc, plab) plab_debug; + if (plab_debug.is_enabled()) { + LogStream ls(plab_debug); log_failed_promotion(ls, thread, size); } } @@ -602,9 +653,10 @@ void ShenandoahOldGeneration::log_failed_promotion(LogStream& ls, Thread* thread const size_t gc_id = heap->control_thread()->get_gc_id(); if ((gc_id != last_report_epoch) || (epoch_report_count++ < MaxReportsPerEpoch)) { // Promotion failures should be very rare. Invest in providing useful diagnostic info. - PLAB* const plab = ShenandoahThreadLocalData::plab(thread); + ShenandoahPLAB* const shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + PLAB* const plab = (shenandoah_plab == nullptr)? nullptr: shenandoah_plab->plab(); const size_t words_remaining = (plab == nullptr)? 0: plab->words_remaining(); - const char* promote_enabled = ShenandoahThreadLocalData::allow_plab_promotions(thread)? "enabled": "disabled"; + const char* promote_enabled = (shenandoah_plab != nullptr && shenandoah_plab->allows_promotion())? "enabled": "disabled"; // Promoted reserve is only changed by vm or control thread. Promoted expended is always accessed atomically. const size_t promotion_reserve = get_promoted_reserve(); @@ -765,6 +817,7 @@ size_t ShenandoahOldGeneration::used_regions_size() const { return used_regions * ShenandoahHeapRegion::region_size_bytes(); } +// For the old generation, max_capacity() equals soft_max_capacity() size_t ShenandoahOldGeneration::max_capacity() const { size_t total_regions = _free_set->total_old_regions(); return total_regions * ShenandoahHeapRegion::region_size_bytes(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.hpp index 5ebad461f3c..12e046a1afc 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.hpp @@ -76,11 +76,6 @@ private: // objects). This field records the total amount of padding used for such regions. size_t _pad_for_promote_in_place; - // Keep track of the number and size of promotions that failed. Perhaps we should use this to increase - // the size of the old generation for the next collection cycle. - Atomic _promotion_failure_count; - Atomic _promotion_failure_words; - // During construction of the collection set, we keep track of regions that are eligible // for promotion in place. These fields track the count of those humongous and regular regions. // This data is used to force the evacuation phase even when the collection set is otherwise @@ -125,9 +120,8 @@ public: // This is used on the allocation path to gate promotions that would exceed the reserve size_t get_promoted_expended() const; - // Return the count and size (in words) of failed promotions since the last reset - size_t get_promotion_failed_count() const { return _promotion_failure_count.load_relaxed(); } - size_t get_promotion_failed_words() const { return _promotion_failure_words.load_relaxed(); } + // Aggregate and log promotion failure stats if logging is enabled + void maybe_log_promotion_failure_stats(bool concurrent) const; // Test if there is enough memory reserved for this promotion bool can_promote(size_t requested_bytes) const { @@ -175,7 +169,7 @@ public: void handle_failed_evacuation(); // Increment promotion failure counters, optionally log a more detailed message - void handle_failed_promotion(Thread* thread, size_t size); + void handle_failed_promotion(Thread* thread, size_t size) const; void log_failed_promotion(LogStream& ls, Thread* thread, size_t size) const; // A successful evacuation re-dirties the cards and registers the object with the remembered set diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPLAB.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPLAB.cpp new file mode 100644 index 00000000000..412cfa9447e --- /dev/null +++ b/src/hotspot/share/gc/shenandoah/shenandoahPLAB.cpp @@ -0,0 +1,221 @@ +/* + * Copyright Amazon.com Inc. 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. + * + */ + +#include "gc/shared/cardTable.hpp" +#include "gc/shenandoah/shenandoahAllocRequest.hpp" +#include "gc/shenandoah/shenandoahGenerationalHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahOldGeneration.hpp" +#include "gc/shenandoah/shenandoahPLAB.hpp" +#include "logging/log.hpp" +#include "runtime/globals.hpp" +#include "runtime/javaThread.hpp" +#include "utilities/copy.hpp" + +ShenandoahPLAB::ShenandoahPLAB() : + _plab(nullptr), + _desired_size(0), + _actual_size(0), + _promoted(0), + _promotion_failure_count(0), + _promotion_failure_words(0), + _allows_promotion(false), + _retries_enabled(false), + _heap(ShenandoahGenerationalHeap::heap()) { + _plab = new PLAB(align_up(PLAB::min_size(), CardTable::card_size_in_words())); +} + +ShenandoahPLAB::~ShenandoahPLAB() { + if (_plab != nullptr) { + delete _plab; + } +} + +void ShenandoahPLAB::subtract_from_promoted(size_t increment) { + assert(_promoted >= increment, "Cannot subtract more than remaining promoted"); + _promoted -= increment; +} + +HeapWord* ShenandoahPLAB::allocate(size_t size, bool is_promotion) { + assert(UseTLAB, "TLABs should be enabled"); + + if (_plab == nullptr) { + // No PLABs in this thread, fallback to shared allocation + return nullptr; + } + + if (is_promotion && !_allows_promotion) { + // Thread is not allowed to promote + return nullptr; + } + + HeapWord* obj = _plab->allocate(size); + if (obj == nullptr) { + if (_plab->words_remaining() < _heap->plab_min_size()) { + // allocate_slow will establish _allows_promotion for future invocations + obj = allocate_slow(size, is_promotion); + } + } + + // if plab->words_remaining() >= ShenGenHeap::heap()->plab_min_size(), just return nullptr so we can use a shared allocation + if (obj == nullptr) { + return nullptr; + } + + if (is_promotion) { + add_to_promoted(size * HeapWordSize); + } + return obj; +} + +// Establish a new PLAB and allocate size HeapWords within it. +HeapWord* ShenandoahPLAB::allocate_slow(size_t size, bool is_promotion) { + assert(_heap->mode()->is_generational(), "PLABs only relevant to generational GC"); + + // PLABs are aligned to card boundaries to avoid synchronization with concurrent + // allocations in other PLABs. + const size_t plab_min_size = _heap->plab_min_size(); + const size_t min_size = (size > plab_min_size)? align_up(size, CardTable::card_size_in_words()): plab_min_size; + + // Figure out size of new PLAB, using value determined at last refill. + size_t cur_size = _desired_size; + if (cur_size == 0) { + cur_size = plab_min_size; + } + + // Expand aggressively, doubling at each refill in this epoch, ceiling at plab_max_size() + // Doubling, starting at a card-multiple, should give us a card-multiple. (Ceiling and floor + // are card multiples.) + const size_t future_size = MIN2(cur_size * 2, _heap->plab_max_size()); + assert(is_aligned(future_size, CardTable::card_size_in_words()), "Card multiple by construction, future_size: %zu" + ", card_size: %u, cur_size: %zu, max: %zu", + future_size, CardTable::card_size_in_words(), cur_size, _heap->plab_max_size()); + + // Record new heuristic value even if we take any shortcut. This captures + // the case when moderately-sized objects always take a shortcut. At some point, + // heuristics should catch up with them. Note that the requested cur_size may + // not be honored, but we remember that this is the preferred size. + log_debug(gc, plab)("Set next PLAB refill size: %zu bytes", future_size * HeapWordSize); + set_desired_size(future_size); + + if (cur_size < size) { + // The PLAB to be allocated is still not large enough to hold the object. Fall back to shared allocation. + // This avoids retiring perfectly good PLABs in order to represent a single large object allocation. + log_debug(gc, plab)("Current PLAB size (%zu) is too small for %zu", cur_size * HeapWordSize, size * HeapWordSize); + return nullptr; + } + + if (_plab->words_remaining() < plab_min_size) { + // Retire current PLAB. This takes care of any PLAB book-keeping. + // retire_plab() registers the remnant filler object with the remembered set scanner without a lock. + // Since PLABs are card-aligned, concurrent registrations in other PLABs don't interfere. + retire(); + + size_t actual_size = 0; + HeapWord* plab_buf = allocate_new_plab(min_size, cur_size, &actual_size); + if (plab_buf == nullptr) { + if (min_size == plab_min_size) { + // Disable PLAB promotions for this thread because we cannot even allocate a minimal PLAB. This allows us + // to fail faster on subsequent promotion attempts. + disable_promotions(); + } + return nullptr; + } + + enable_retries(); + + // Since the allocated PLAB may have been down-sized for alignment, plab->allocate(size) below may still fail. + if (ZeroTLAB) { + // Skip mangling the space corresponding to the object header to + // ensure that the returned space is not considered parsable by + // any concurrent GC thread. + Copy::zero_to_words(plab_buf, actual_size); + } else { +#ifdef ASSERT + size_t hdr_size = oopDesc::header_size(); + Copy::fill_to_words(plab_buf + hdr_size, actual_size - hdr_size, badHeapWordVal); +#endif + } + assert(is_aligned(actual_size, CardTable::card_size_in_words()), "Align by design"); + _plab->set_buf(plab_buf, actual_size); + if (is_promotion && !_allows_promotion) { + return nullptr; + } + return _plab->allocate(size); + } + + // If there's still at least min_size() words available within the current plab, don't retire it. Let's nibble + // away on this plab as long as we can. Meanwhile, return nullptr to force this particular allocation request + // to be satisfied with a shared allocation. By packing more promotions into the previously allocated PLAB, we + // reduce the likelihood of evacuation failures, and we reduce the need for downsizing our PLABs. + return nullptr; +} + +HeapWord* ShenandoahPLAB::allocate_new_plab(size_t min_size, size_t word_size, size_t* actual_size) { + assert(is_aligned(min_size, CardTable::card_size_in_words()), "Align by design"); + assert(word_size >= min_size, "Requested PLAB is too small"); + + ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab(min_size, word_size); + HeapWord* res = _heap->allocate_memory(req); + if (res != nullptr) { + *actual_size = req.actual_size(); + } else { + *actual_size = 0; + } + assert(is_aligned(res, CardTable::card_size_in_words()), "Align by design"); + return res; +} + +void ShenandoahPLAB::retire() { + // We don't enforce limits on plab evacuations. We let it consume all available old-gen memory in order to reduce + // probability of an evacuation failure. We do enforce limits on promotion, to make sure that excessive promotion + // does not result in an old-gen evacuation failure. Note that a failed promotion is relatively harmless. Any + // object that fails to promote in the current cycle will be eligible for promotion in a subsequent cycle. + + // When the plab was instantiated, its entirety was treated as if the entire buffer was going to be dedicated to + // promotions. Now that we are retiring the buffer, we adjust for the reality that the plab is not entirely promotions. + // 1. Some of the plab may have been dedicated to evacuations. + // 2. Some of the plab may have been abandoned due to waste (at the end of the plab). + size_t not_promoted = _actual_size - _promoted; + reset_promoted(); + set_actual_size(0); + if (not_promoted > 0) { + log_debug(gc, plab)("Retire PLAB, unexpend unpromoted: %zu", not_promoted * HeapWordSize); + _heap->old_generation()->unexpend_promoted(not_promoted); + } + const size_t original_waste = _plab->waste(); + HeapWord* const top = _plab->top(); + + // plab->retire() overwrites unused memory between plab->top() and plab->hard_end() with a dummy object to make memory parsable. + // It adds the size of this unused memory, in words, to plab->waste(). + _plab->retire(); + if (top != nullptr && _plab->waste() > original_waste && _heap->is_in_old(top)) { + // If retiring the plab created a filler object, then we need to register it with our card scanner so it can + // safely walk the region backing the plab. + log_debug(gc, plab)("retire_plab() is registering remnant of size %zu at " PTR_FORMAT, + (_plab->waste() - original_waste) * HeapWordSize, p2i(top)); + // No lock is necessary because the PLAB memory is aligned on card boundaries. + _heap->old_generation()->card_scan()->register_object_without_lock(top); + } +} diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPLAB.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPLAB.hpp new file mode 100644 index 00000000000..4278eb65b10 --- /dev/null +++ b/src/hotspot/share/gc/shenandoah/shenandoahPLAB.hpp @@ -0,0 +1,130 @@ +/* + * Copyright Amazon.com Inc. 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. + * + */ + +#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHPLAB_HPP +#define SHARE_GC_SHENANDOAH_SHENANDOAHPLAB_HPP + +#include "gc/shared/plab.hpp" +#include "memory/allocation.hpp" + +class ShenandoahGenerationalHeap; + +class ShenandoahPLAB : public CHeapObj { +private: + // The actual allocation buffer + PLAB* _plab; + + // Heuristics will grow the desired size of plabs. + size_t _desired_size; + + // Once the plab has been allocated, and we know the actual size, we record it here. + size_t _actual_size; + + // As the plab is used for promotions, this value is incremented. When the plab is + // retired, the difference between 'actual_size' and 'promoted' will be returned to + // the old generation's promotion reserve (i.e., it will be 'unexpended'). + size_t _promoted; + + // Track failed promotion attempts per thread + size_t _promotion_failure_count; + size_t _promotion_failure_words; + + // If false, no more promotion by this thread during this evacuation phase. + bool _allows_promotion; + + // If true, evacuations may attempt to allocate a smaller plab if the original size fails. + bool _retries_enabled; + + // Use for allocations, min/max plab sizes + ShenandoahGenerationalHeap* _heap; + + // Enable retry logic for PLAB allocation failures + void enable_retries() { _retries_enabled = true; } + + // Establish a new PLAB and allocate from it + HeapWord* allocate_slow(size_t size, bool is_promotion); + // Allocate a new PLAB buffer from the heap + HeapWord* allocate_new_plab(size_t min_size, size_t word_size, size_t* actual_size); + +public: + ShenandoahPLAB(); + ~ShenandoahPLAB(); + + // Access the underlying PLAB buffer + PLAB* plab() const { return _plab; } + + // Heuristic size for next PLAB allocation + size_t desired_size() const { return _desired_size; } + // Update heuristic size for next PLAB allocation + void set_desired_size(size_t v) { _desired_size = v; } + + // Check if retry logic is enabled + bool retries_enabled() const { return _retries_enabled; } + // Disable retry logic for PLAB allocation failures + void disable_retries() { _retries_enabled = false; } + + // Allow this thread to promote objects + void enable_promotions() { _allows_promotion = true; } + // Prevent this thread from promoting objects + void disable_promotions() { _allows_promotion = false; } + // Check if this thread is allowed to promote objects + bool allows_promotion() const { return _allows_promotion; } + + // Reset promotion tracking for new evacuation phase + void reset_promoted() { _promoted = 0; } + // When a plab is retired, subtract from the expended promotion budget + void subtract_from_promoted(size_t increment); + // Bytes promoted through this PLAB + size_t get_promoted() const { return _promoted; } + // Track promoted bytes in this PLAB + void add_to_promoted(size_t increment) { _promoted += increment; } + + // Track failed promotion attempts + void record_promotion_failure(size_t size) { + _promotion_failure_count++; + _promotion_failure_words += size; + } + // Get failed promotion count for aggregation + size_t get_promotion_failure_count() const { return _promotion_failure_count; } + // Get failed promotion words for aggregation + size_t get_promotion_failure_words() const { return _promotion_failure_words; } + // Reset failure tracking for new evacuation phase + void reset_promotion_failures() { + _promotion_failure_count = 0; + _promotion_failure_words = 0; + } + + // Record actual allocated PLAB size + void set_actual_size(size_t value) { _actual_size = value; } + // Actual allocated PLAB size + size_t get_actual_size() const { return _actual_size; } + + // Allocate from this PLAB + HeapWord* allocate(size_t size, bool is_promotion); + + // Retire this PLAB and return unused promotion budget + void retire(); +}; + +#endif // SHARE_GC_SHENANDOAH_SHENANDOAHPLAB_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp index 7187431c8f8..37e9729b7ff 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp @@ -504,7 +504,7 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc if (!CompressedOops::is_null(*list)) { oop head = lrb(CompressedOops::decode_not_null(*list)); shenandoah_assert_not_in_cset_except(&head, head, ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahLoadRefBarrier); - oop prev = AtomicAccess::xchg(&_pending_list, head); + oop prev = _pending_list.exchange(head); set_oop_field(p, prev); if (prev == nullptr) { // First to prepend to list, record tail @@ -519,14 +519,14 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahRefProcThreadLoc void ShenandoahReferenceProcessor::work() { // Process discovered references uint max_workers = ShenandoahHeap::heap()->max_workers(); - uint worker_id = AtomicAccess::add(&_iterate_discovered_list_id, 1U, memory_order_relaxed) - 1; + uint worker_id = _iterate_discovered_list_id.fetch_then_add(1U, memory_order_relaxed); while (worker_id < max_workers) { if (UseCompressedOops) { process_references(_ref_proc_thread_locals[worker_id], worker_id); } else { process_references(_ref_proc_thread_locals[worker_id], worker_id); } - worker_id = AtomicAccess::add(&_iterate_discovered_list_id, 1U, memory_order_relaxed) - 1; + worker_id = _iterate_discovered_list_id.fetch_then_add(1U, memory_order_relaxed); } } @@ -559,7 +559,7 @@ public: void ShenandoahReferenceProcessor::process_references(ShenandoahPhaseTimings::Phase phase, WorkerThreads* workers, bool concurrent) { - AtomicAccess::release_store_fence(&_iterate_discovered_list_id, 0U); + _iterate_discovered_list_id.release_store_fence(0U); // Process discovered lists ShenandoahReferenceProcessorTask task(phase, concurrent, this); @@ -576,7 +576,7 @@ void ShenandoahReferenceProcessor::process_references(ShenandoahPhaseTimings::Ph void ShenandoahReferenceProcessor::enqueue_references_locked() { // Prepend internal pending list to external pending list - shenandoah_assert_not_in_cset_except(&_pending_list, _pending_list, ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahLoadRefBarrier); + shenandoah_assert_not_in_cset_except(&_pending_list, _pending_list.load_relaxed(), ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahLoadRefBarrier); // During reference processing, we maintain a local list of references that are identified by // _pending_list and _pending_list_tail. _pending_list_tail points to the next field of the last Reference object on @@ -589,7 +589,7 @@ void ShenandoahReferenceProcessor::enqueue_references_locked() { // 2. Overwriting the next field of the last Reference on my local list to point at the previous head of the // global Universe::_reference_pending_list - oop former_head_of_global_list = Universe::swap_reference_pending_list(_pending_list); + oop former_head_of_global_list = Universe::swap_reference_pending_list(_pending_list.load_relaxed()); if (UseCompressedOops) { set_oop_field(reinterpret_cast(_pending_list_tail), former_head_of_global_list); } else { @@ -598,7 +598,7 @@ void ShenandoahReferenceProcessor::enqueue_references_locked() { } void ShenandoahReferenceProcessor::enqueue_references(bool concurrent) { - if (_pending_list == nullptr) { + if (_pending_list.load_relaxed() == nullptr) { // Nothing to enqueue return; } @@ -616,7 +616,7 @@ void ShenandoahReferenceProcessor::enqueue_references(bool concurrent) { } // Reset internal pending list - _pending_list = nullptr; + _pending_list.store_relaxed(nullptr); _pending_list_tail = &_pending_list; } @@ -640,9 +640,9 @@ void ShenandoahReferenceProcessor::abandon_partial_discovery() { clean_discovered_list(_ref_proc_thread_locals[index].discovered_list_addr()); } } - if (_pending_list != nullptr) { - oop pending = _pending_list; - _pending_list = nullptr; + if (_pending_list.load_relaxed() != nullptr) { + oop pending = _pending_list.load_relaxed(); + _pending_list.store_relaxed(nullptr); if (UseCompressedOops) { narrowOop* list = reference_discovered_addr(pending); clean_discovered_list(list); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp index 14adb924585..01c79029132 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp @@ -31,6 +31,7 @@ #include "gc/shared/referenceProcessorStats.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" class ShenandoahMarkRefsSuperClosure; class WorkerThreads; @@ -133,10 +134,10 @@ private: ShenandoahRefProcThreadLocal* _ref_proc_thread_locals; - oop _pending_list; + Atomic _pending_list; void* _pending_list_tail; // T* - volatile uint _iterate_discovered_list_id; + Atomic _iterate_discovered_list_id; ReferenceProcessorStats _stats; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp index ec4b7c7217c..28094a1d57d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp @@ -36,13 +36,14 @@ ShenandoahRegulatorThread::ShenandoahRegulatorThread(ShenandoahGenerationalContr _heap(ShenandoahHeap::heap()), _control_thread(control_thread), _sleep(ShenandoahControlIntervalMin), - _last_sleep_adjust_time(os::elapsedTime()) { + _most_recent_wake_time(os::elapsedTime()), + _last_sleep_adjust_time(_most_recent_wake_time) { shenandoah_assert_generational(); _old_heuristics = _heap->old_generation()->heuristics(); _young_heuristics = _heap->young_generation()->heuristics(); _global_heuristics = _heap->global_generation()->heuristics(); - set_name("Shenandoah Regulator Thread"); + set_name("ShenRegulator"); create_and_start(); } @@ -115,19 +116,22 @@ void ShenandoahRegulatorThread::regulator_sleep() { // Wait before performing the next action. If allocation happened during this wait, // we exit sooner, to let heuristics re-evaluate new conditions. If we are at idle, // back off exponentially. - double current = os::elapsedTime(); - + double before_sleep_time = _most_recent_wake_time; if (ShenandoahHeap::heap()->has_changed()) { _sleep = ShenandoahControlIntervalMin; - } else if ((current - _last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){ + } else if ((before_sleep_time - _last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){ _sleep = MIN2(ShenandoahControlIntervalMax, MAX2(1u, _sleep * 2)); - _last_sleep_adjust_time = current; + _last_sleep_adjust_time = before_sleep_time; } SuspendibleThreadSetLeaver leaver; os::naked_short_sleep(_sleep); + double wake_time = os::elapsedTime(); + _most_recent_period = wake_time - _most_recent_wake_time; + _most_recent_wake_time = wake_time; + _young_heuristics->update_should_start_query_times(_most_recent_wake_time, double(_sleep) / 1000.0); if (LogTarget(Debug, gc, thread)::is_enabled()) { - double elapsed = os::elapsedTime() - current; + double elapsed = _most_recent_wake_time - before_sleep_time; double hiccup = elapsed - double(_sleep); if (hiccup > 0.001) { log_debug(gc, thread)("Regulator hiccup time: %.3fs", hiccup); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.hpp index 2519025b6fb..cc41bc2c65b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.hpp @@ -79,7 +79,10 @@ class ShenandoahRegulatorThread: public ConcurrentGCThread { ShenandoahOldHeuristics* _old_heuristics; ShenandoahHeuristics* _global_heuristics; + // duration of planned regulator sleep period, in ms uint _sleep; + double _most_recent_wake_time; + double _most_recent_period; double _last_sleep_adjust_time; }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp index 9e6b1960708..7b68e6ac625 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp @@ -45,7 +45,7 @@ ShenandoahJavaThreadsIterator::ShenandoahJavaThreadsIterator(ShenandoahPhaseTimi } uint ShenandoahJavaThreadsIterator::claim() { - return AtomicAccess::fetch_then_add(&_claimed, _stride, memory_order_relaxed); + return _claimed.fetch_then_add(_stride, memory_order_relaxed); } void ShenandoahJavaThreadsIterator::threads_do(ThreadClosure* cl, uint worker_id) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp index 29d8c9fac2d..55367e706a2 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp @@ -33,6 +33,7 @@ #include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "memory/iterator.hpp" +#include "runtime/atomic.hpp" #include "runtime/threads.hpp" template @@ -73,7 +74,7 @@ private: ThreadsListHandle _threads; uint const _length; uint const _stride; - volatile uint _claimed; + Atomic _claimed; ShenandoahPhaseTimings::Phase _phase; uint claim(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp index 05af25f13ad..9e160d5b294 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp @@ -1024,7 +1024,7 @@ ShenandoahRegionChunkIterator::ShenandoahRegionChunkIterator(ShenandoahHeap* hea } void ShenandoahRegionChunkIterator::reset() { - _index = 0; + _index.store_relaxed(0); } ShenandoahReconstructRememberedSetTask::ShenandoahReconstructRememberedSetTask(ShenandoahRegionIterator* regions) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.hpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.hpp index c758873a040..c2c117e86e6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.hpp @@ -973,7 +973,7 @@ private: const size_t _total_chunks; shenandoah_padding(0); - volatile size_t _index; + Atomic _index; shenandoah_padding(1); size_t _region_index[_maximum_groups]; // The region index for the first region spanned by this group diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp index e394daa68c0..3c82efee16c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp @@ -380,14 +380,14 @@ ShenandoahScanRemembered::process_region_slice(ShenandoahHeapRegion *region, siz } inline bool ShenandoahRegionChunkIterator::has_next() const { - return _index < _total_chunks; + return _index.load_relaxed() < _total_chunks; } inline bool ShenandoahRegionChunkIterator::next(struct ShenandoahRegionChunk *assignment) { - if (_index >= _total_chunks) { + if (_index.load_relaxed() >= _total_chunks) { return false; } - size_t new_index = AtomicAccess::add(&_index, (size_t) 1, memory_order_relaxed); + size_t new_index = _index.add_then_fetch((size_t) 1, memory_order_relaxed); if (new_index > _total_chunks) { // First worker that hits new_index == _total_chunks continues, other // contending workers return false. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp index 969edafbf75..dbae1b35c6f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Red Hat, Inc. All rights reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ #include "gc/shared/taskTerminator.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "nmt/memTag.hpp" +#include "runtime/atomic.hpp" #include "runtime/atomicAccess.hpp" #include "runtime/javaThread.hpp" #include "runtime/mutex.hpp" @@ -306,7 +307,7 @@ template class ParallelClaimableQueueSet: public GenericTaskQueueSet { private: shenandoah_padding(0); - volatile jint _claimed_index; + Atomic _claimed_index; shenandoah_padding(1); DEBUG_ONLY(uint _reserved; ) @@ -319,13 +320,13 @@ public: DEBUG_ONLY(_reserved = 0; ) } - void clear_claimed() { _claimed_index = 0; } + void clear_claimed() { _claimed_index.store_relaxed(0); } T* claim_next(); // reserve queues that not for parallel claiming void reserve(uint n) { assert(n <= size(), "Sanity"); - _claimed_index = (jint)n; + _claimed_index.store_relaxed((jint)n); DEBUG_ONLY(_reserved = n;) } @@ -336,11 +337,11 @@ template T* ParallelClaimableQueueSet::claim_next() { jint size = (jint)GenericTaskQueueSet::size(); - if (_claimed_index >= size) { + if (_claimed_index.load_relaxed() >= size) { return nullptr; } - jint index = AtomicAccess::add(&_claimed_index, 1, memory_order_relaxed); + jint index = _claimed_index.add_then_fetch(1, memory_order_relaxed); if (index <= size) { return GenericTaskQueueSet::queue((uint)index - 1); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.cpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.cpp index ace5ab5e69a..1f3ce76cc1c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.cpp @@ -37,12 +37,7 @@ ShenandoahThreadLocalData::ShenandoahThreadLocalData() : _card_table(nullptr), _gclab(nullptr), _gclab_size(0), - _plab(nullptr), - _plab_desired_size(0), - _plab_actual_size(0), - _plab_promoted(0), - _plab_allows_promotion(true), - _plab_retries_enabled(true), + _shenandoah_plab(nullptr), _evacuation_stats(new ShenandoahEvacuationStats()) { } @@ -50,9 +45,9 @@ ShenandoahThreadLocalData::~ShenandoahThreadLocalData() { if (_gclab != nullptr) { delete _gclab; } - if (_plab != nullptr) { - ShenandoahGenerationalHeap::heap()->retire_plab(_plab); - delete _plab; + if (_shenandoah_plab != nullptr) { + _shenandoah_plab->retire(); + delete _shenandoah_plab; } delete _evacuation_stats; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp index f54a65b0785..b1b923bbfce 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -36,6 +36,7 @@ #include "gc/shenandoah/shenandoahCodeRoots.hpp" #include "gc/shenandoah/shenandoahEvacTracker.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" +#include "gc/shenandoah/shenandoahPLAB.hpp" #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp" #include "runtime/javaThread.hpp" #include "utilities/debug.hpp" @@ -62,24 +63,7 @@ private: // Used both by mutator threads and by GC worker threads // for evacuations within the old generation and // for promotions from the young generation into the old generation. - PLAB* _plab; - - // Heuristics will grow the desired size of plabs. - size_t _plab_desired_size; - - // Once the plab has been allocated, and we know the actual size, we record it here. - size_t _plab_actual_size; - - // As the plab is used for promotions, this value is incremented. When the plab is - // retired, the difference between 'actual_size' and 'promoted' will be returned to - // the old generation's promotion reserve (i.e., it will be 'unexpended'). - size_t _plab_promoted; - - // If false, no more promotion by this thread during this evacuation phase. - bool _plab_allows_promotion; - - // If true, evacuations may attempt to allocate a smaller plab if the original size fails. - bool _plab_retries_enabled; + ShenandoahPLAB* _shenandoah_plab; ShenandoahEvacuationStats* _evacuation_stats; @@ -141,8 +125,7 @@ public: data(thread)->_gclab_size = 0; if (ShenandoahHeap::heap()->mode()->is_generational()) { - data(thread)->_plab = new PLAB(align_up(PLAB::min_size(), CardTable::card_size_in_words())); - data(thread)->_plab_desired_size = 0; + data(thread)->_shenandoah_plab = new ShenandoahPLAB(); } } @@ -170,65 +153,8 @@ public: return data(thread)->_evacuation_stats; } - static PLAB* plab(Thread* thread) { - return data(thread)->_plab; - } - - static size_t plab_size(Thread* thread) { - return data(thread)->_plab_desired_size; - } - - static void set_plab_size(Thread* thread, size_t v) { - data(thread)->_plab_desired_size = v; - } - - static void enable_plab_retries(Thread* thread) { - data(thread)->_plab_retries_enabled = true; - } - - static void disable_plab_retries(Thread* thread) { - data(thread)->_plab_retries_enabled = false; - } - - static bool plab_retries_enabled(Thread* thread) { - return data(thread)->_plab_retries_enabled; - } - - static void enable_plab_promotions(Thread* thread) { - data(thread)->_plab_allows_promotion = true; - } - - static void disable_plab_promotions(Thread* thread) { - data(thread)->_plab_allows_promotion = false; - } - - static bool allow_plab_promotions(Thread* thread) { - return data(thread)->_plab_allows_promotion; - } - - static void reset_plab_promoted(Thread* thread) { - data(thread)->_plab_promoted = 0; - } - - static void add_to_plab_promoted(Thread* thread, size_t increment) { - data(thread)->_plab_promoted += increment; - } - - static void subtract_from_plab_promoted(Thread* thread, size_t increment) { - assert(data(thread)->_plab_promoted >= increment, "Cannot subtract more than remaining promoted"); - data(thread)->_plab_promoted -= increment; - } - - static size_t get_plab_promoted(Thread* thread) { - return data(thread)->_plab_promoted; - } - - static void set_plab_actual_size(Thread* thread, size_t value) { - data(thread)->_plab_actual_size = value; - } - - static size_t get_plab_actual_size(Thread* thread) { - return data(thread)->_plab_actual_size; + static ShenandoahPLAB* shenandoah_plab(Thread* thread) { + return data(thread)->_shenandoah_plab; } // Evacuation OOM handling diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.cpp index ec708b198e7..f2fcd39daf5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.cpp @@ -32,7 +32,7 @@ ShenandoahUncommitThread::ShenandoahUncommitThread(ShenandoahHeap* heap) : _heap(heap), _uncommit_lock(Mutex::safepoint - 2, "ShenandoahUncommit_lock", true) { - set_name("Shenandoah Uncommit Thread"); + set_name("ShenUncommit"); create_and_start(); // Allow uncommits. This is managed by the control thread during a GC. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp index b248fab7958..ac7fe1f9a3a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp @@ -80,7 +80,7 @@ public: virtual bool has_dead_oop(nmethod* nm) const { assert(ShenandoahHeap::heap()->is_concurrent_weak_root_in_progress(), "Only for this phase"); ShenandoahNMethod* data = ShenandoahNMethod::gc_data(nm); - ShenandoahReentrantLocker locker(data->lock()); + ShenandoahNMethodLocker locker(data->lock()); ShenandoahIsUnloadingOopClosure cl; data->oops_do(&cl); return cl.is_unloading(); @@ -90,14 +90,14 @@ public: class ShenandoahCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour { public: virtual bool lock(nmethod* nm) { - ShenandoahReentrantLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); + ShenandoahNMethodLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); assert(lock != nullptr, "Not yet registered?"); lock->lock(); return true; } virtual void unlock(nmethod* nm) { - ShenandoahReentrantLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); + ShenandoahNMethodLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); assert(lock != nullptr, "Not yet registered?"); lock->unlock(); } @@ -107,7 +107,7 @@ public: return true; } - ShenandoahReentrantLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); + ShenandoahNMethodLock* const lock = ShenandoahNMethod::ic_lock_for_nmethod(nm); assert(lock != nullptr, "Not yet registered?"); return lock->owned_by_self(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp index 176baa133c8..dea47fcbf4f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp @@ -40,6 +40,22 @@ ShenandoahPhaseTimings::Phase ShenandoahTimingsTracker::_current_phase = ShenandoahPhaseTimings::_invalid_phase; +const char* ShenandoahGCSession::cycle_end_message(ShenandoahGenerationType type) { + switch (type) { + case NON_GEN: + return "end of GC cycle"; + case GLOBAL: + return "end of Global GC cycle"; + case YOUNG: + return "end of Young GC cycle"; + case OLD: + return "end of Old GC cycle"; + default: + ShouldNotReachHere(); + return "end of GC cycle"; + } +} + ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause, ShenandoahGeneration* generation) : _heap(ShenandoahHeap::heap()), _generation(generation), @@ -54,7 +70,7 @@ ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause, ShenandoahGenerat _heap->trace_heap_before_gc(_tracer); _trace_cycle.initialize(_heap->cycle_memory_manager(), cause, - "end of GC cycle", + cycle_end_message(_generation->type()), /* allMemoryPoolsAffected */ true, /* recordGCBeginTime = */ true, /* recordPreGCUsage = */ true, diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp index 8a508c4afd8..6ef4cd7c702 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp @@ -67,6 +67,8 @@ private: GCTracer* const _tracer; TraceMemoryManagerStats _trace_cycle; + + static const char* cycle_end_message(ShenandoahGenerationType type); public: ShenandoahGCSession(GCCause::Cause cause, ShenandoahGeneration* generation); ~ShenandoahGCSession(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index 225339a3219..afef11640c9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -1086,7 +1086,7 @@ void ShenandoahVerifier::verify_generic(ShenandoahGeneration* generation, Verify _verify_cset_disable, // cset may be inconsistent _verify_liveness_disable, // no reliable liveness data _verify_regions_disable, // no reliable region data - _verify_size_exact, // expect generation and heap sizes to match exactly + _verify_size_disable, // no reliable sizing data _verify_gcstate_disable // no data about gcstate ); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp index f00ce16136f..7a76bc50078 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp @@ -131,6 +131,14 @@ size_t ShenandoahYoungGeneration::free_unaffiliated_regions() const { return _free_set->young_unaffiliated_regions(); } +size_t ShenandoahYoungGeneration::available_with_reserve() const { + shenandoah_assert_heaplocked(); + ShenandoahFreeSet* free_set = ShenandoahHeap::heap()->free_set(); + size_t mutator_available = free_set->available_locked(); + size_t collector_available = free_set->collector_available_locked(); + return mutator_available + collector_available; +} + size_t ShenandoahYoungGeneration::available() const { // The collector reserve may eat into what the mutator is allowed to use. Make sure we are looking // at what is available to the mutator when reporting how much memory is available. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp index 930c5ff1747..c3b6944ec80 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp @@ -82,6 +82,8 @@ public: size_t get_affiliated_region_count() const override; size_t max_capacity() const override; + // Return sum of bytes available to mutator and to Collector, assuming heap lock is held. + size_t available_with_reserve() const; size_t available() const override; size_t soft_mutator_available() const override; diff --git a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp index 3eb1a06a911..bbfa19934d9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp @@ -34,6 +34,59 @@ range, \ constraint) \ \ + product(uint, ShenandoahAccelerationSamplePeriod, 15, EXPERIMENTAL, \ + "When at least this much time (measured in ms) has passed " \ + "since the acceleration allocation rate was most recently " \ + "sampled, capture another allocation rate sample for the purpose "\ + "of detecting acceleration or momentary spikes in allocation " \ + "rate. A smaller value allows quicker response to changes in " \ + "allocation rates but is more vulnerable to noise and requires " \ + "more monitoring effort.") \ + range(1, 1000) \ + \ + product(uint, ShenandoahRateAccelerationSampleSize, 8, EXPERIMENTAL, \ + "In selected ShenandoahControlIntervals " \ + "(if ShenandoahAccelerationSamplePeriod ms have passed " \ + "since previous allocation rate sample), " \ + "we compute the allocation rate since the previous rate was " \ + "sampled. This many samples are analyzed to determine whether " \ + "allocation rates are accelerating. Acceleration may occur " \ + "due to increasing client demand or due to phase changes in " \ + "an application. A larger value reduces sensitivity to " \ + "noise and delays recognition of the accelerating trend. A " \ + "larger value may also cause the heuristic to miss detection " \ + "of very quick accelerations. Smaller values may cause random " \ + "noise to be perceived as acceleration of allocation rate, " \ + "triggering excess collections. Note that the acceleration " \ + "need not last the entire span of the sampled duration to be " \ + "detected. If the last several of all samples are signficantly " \ + "larger than the other samples, the best fit line through all " \ + "sampled values will have an upward slope, manifesting as " \ + "acceleration.") \ + range(1,64) \ + \ + product(uint, ShenandoahMomentaryAllocationRateSpikeSampleSize, \ + 2, EXPERIMENTAL, \ + "In selected ShenandoahControlIntervals " \ + "(if ShenandoahAccelerationSamplePeriod ms have passed " \ + "since previous allocation rate sample), we compute " \ + "the allocation rate since the previous rate was sampled. " \ + "The weighted average of this " \ + "many most recent momentary allocation rate samples is compared " \ + "against current allocation runway and anticipated GC time to " \ + "determine whether a spike in momentary allocation rate " \ + "justifies an early GC trigger. Momentary allocation spike " \ + "detection is in addition to previously implemented " \ + "ShenandoahAdaptiveInitialSpikeThreshold, the latter of which " \ + "is more effective at detecting slower spikes. The latter " \ + "spike detection samples at the rate specifieid by " \ + "ShenandoahAdaptiveSampleFrequencyHz. The value of this " \ + "parameter must be less than the value of " \ + "ShenandoahRateAccelerationSampleSize. A larger value makes " \ + "momentary spike detection less sensitive. A smaller value " \ + "may result in excessive GC triggers.") \ + range(1,64) \ + \ product(uintx, ShenandoahGenerationalMinPIPUsage, 30, EXPERIMENTAL, \ "(Generational mode only) What percent of a heap region " \ "should be used before we consider promoting a region in " \ @@ -99,9 +152,6 @@ "evvort even if the usage of old generation is below " \ "ShenandoahIgnoreOldGrowthBelowPercentage.") \ \ - product(bool, ShenandoahGenerationalAdaptiveTenuring, true, EXPERIMENTAL, \ - "(Generational mode only) Dynamically adapt tenuring age.") \ - \ product(bool, ShenandoahGenerationalCensusIgnoreOlderCohorts, true, \ EXPERIMENTAL,\ "(Generational mode only) Ignore mortality rates older than the " \ @@ -126,8 +176,7 @@ "(Generational mode only) Cohort mortality rates below this " \ "value will be treated as indicative of longevity, leading to " \ "tenuring. A lower value delays tenuring, a higher value hastens "\ - "it. Used only when ShenandoahGenerationalhenAdaptiveTenuring is "\ - "enabled.") \ + "it.") \ range(0.001,0.999) \ \ product(size_t, ShenandoahGenerationalTenuringCohortPopulationThreshold, \ diff --git a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp index e5e2b14a3a1..4299bdb8126 100644 --- a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp +++ b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp @@ -36,7 +36,7 @@ nonstatic_field(ShenandoahHeap, _regions, ShenandoahHeapRegion**) \ nonstatic_field(ShenandoahHeap, _log_min_obj_alignment_in_bytes, int) \ nonstatic_field(ShenandoahHeap, _free_set, ShenandoahFreeSet*) \ - volatile_nonstatic_field(ShenandoahHeap, _committed, size_t) \ + volatile_nonstatic_field(ShenandoahHeap, _committed, Atomic) \ static_field(ShenandoahHeapRegion, RegionSizeBytes, size_t) \ static_field(ShenandoahHeapRegion, RegionSizeBytesShift, size_t) \ nonstatic_field(ShenandoahHeapRegion, _state, Atomic) \ diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp index 650918e2d30..0a3dac1e100 100644 --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -442,7 +442,7 @@ void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* a assert(src_offset == dest_offset, "should be equal"); const jlong offset = src_offset->get_long(); if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) { - assert(!UseCompressedClassPointers || UseCompactObjectHeaders, "should only happen without compressed class pointers"); + assert(UseCompactObjectHeaders, "should only happen with COH"); assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset"); length = phase->transform_later(new SubLNode(length, phase->longcon(1))); // Size is in longs src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT)); diff --git a/src/hotspot/share/gc/z/zBitField.hpp b/src/hotspot/share/gc/z/zBitField.hpp index 9bec4e05594..b68f5b92ce1 100644 --- a/src/hotspot/share/gc/z/zBitField.hpp +++ b/src/hotspot/share/gc/z/zBitField.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -74,7 +74,7 @@ public: static ContainerType encode(ValueType value) { assert(((ContainerType)value & (FieldMask << ValueShift)) == (ContainerType)value, "Invalid value"); - return ((ContainerType)value >> ValueShift) << FieldShift; + return checked_cast(((ContainerType)value >> ValueShift) << FieldShift); } }; diff --git a/src/hotspot/share/gc/z/zDebug.gdb b/src/hotspot/share/gc/z/zDebug.gdb index d502eea7ce3..df087c4a42d 100644 --- a/src/hotspot/share/gc/z/zDebug.gdb +++ b/src/hotspot/share/gc/z/zDebug.gdb @@ -50,11 +50,7 @@ define zpo end printf "\t Page: %llu\n", ((uintptr_t)$obj & ZAddressOffsetMask) >> ZGranuleSizeShift x/16gx $obj - if (UseCompressedClassPointers) - set $klass = (Klass*)(void*)((uintptr_t)CompressedKlassPointers::_base +((uintptr_t)$obj->_metadata->_compressed_klass << CompressedKlassPointers::_shift)) - else - set $klass = $obj->_metadata->_klass - end + set $klass = (Klass*)(void*)((uintptr_t)CompressedKlassPointers::_base +((uintptr_t)$obj->_compressed_klass << CompressedKlassPointers::_shift)) printf "Mark: 0x%016llx\tKlass: %s\n", (uintptr_t)$obj->_mark, (char*)$klass->_name->_body end diff --git a/src/hotspot/share/gc/z/zNMT.cpp b/src/hotspot/share/gc/z/zNMT.cpp index 1019bcfdd96..b82afac47bc 100644 --- a/src/hotspot/share/gc/z/zNMT.cpp +++ b/src/hotspot/share/gc/z/zNMT.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,9 +45,7 @@ void ZNMT::unreserve(zaddress_unsafe start, size_t size) { if (MemTracker::enabled()) { // We are the owner of the reserved memory, and any failure to unreserve - // are fatal, so so we don't need to hold a lock while unreserving memory. - - MemTracker::NmtVirtualMemoryLocker nvml; + // are fatal, so we don't need to hold a lock while unreserving memory. // The current NMT implementation does not support unreserving a memory // region that was built up from smaller memory reservations. Workaround diff --git a/src/hotspot/share/interpreter/bytecodeTracer.cpp b/src/hotspot/share/interpreter/bytecodeTracer.cpp index 69fc93b6c0f..2610a8a2bd6 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.cpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.cpp @@ -78,7 +78,7 @@ class BytecodePrinter { void print_field_or_method(int cp_index, outputStream* st); void print_dynamic(int cp_index, outputStream* st); void print_attributes(int bci, outputStream* st); - void bytecode_epilog(int bci, outputStream* st); + void print_method_data_at(int bci, outputStream* st); public: BytecodePrinter(int flags = 0) : _is_wide(false), _code(Bytecodes::_illegal), _flags(flags) {} @@ -171,7 +171,9 @@ class BytecodePrinter { } _next_pc = is_wide() ? bcp+2 : bcp+1; print_attributes(bci, st); - bytecode_epilog(bci, st); + if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_METHOD_DATA)) { + print_method_data_at(bci, st); + } } }; @@ -185,7 +187,9 @@ static Method* _method_currently_being_printed = nullptr; void BytecodeTracer::trace_interpreter(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) { if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) { BytecodePrinter printer(AtomicAccess::load_acquire(&_method_currently_being_printed)); - printer.trace(method, bcp, tos, tos2, st); + stringStream buf; + printer.trace(method, bcp, tos, tos2, &buf); + st->print("%s", buf.freeze()); // Save method currently being printed to detect when method printing changes. AtomicAccess::release_store(&_method_currently_being_printed, method()); } @@ -596,7 +600,7 @@ void BytecodePrinter::print_attributes(int bci, outputStream* st) { } -void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) { +void BytecodePrinter::print_method_data_at(int bci, outputStream* st) { MethodData* mdo = method()->method_data(); if (mdo != nullptr) { diff --git a/src/hotspot/share/interpreter/bytecodeTracer.hpp b/src/hotspot/share/interpreter/bytecodeTracer.hpp index e199a2b7ea2..ab66030b6cd 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.hpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.hpp @@ -38,7 +38,7 @@ class outputStream; class BytecodeClosure; class BytecodeTracer: AllStatic { public: - NOT_PRODUCT(static void trace_interpreter(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st = tty);) + NOT_PRODUCT(static void trace_interpreter(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st);) static void print_method_codes(const methodHandle& method, int from, int to, outputStream* st, int flags, bool buffered = true); }; diff --git a/src/hotspot/share/interpreter/bytecodes.cpp b/src/hotspot/share/interpreter/bytecodes.cpp index 1526b3c330e..a7914b6b93a 100644 --- a/src/hotspot/share/interpreter/bytecodes.cpp +++ b/src/hotspot/share/interpreter/bytecodes.cpp @@ -402,7 +402,7 @@ int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) case _fast_binaryswitch: // fall through case _fast_linearswitch: { address aligned_bcp = align_up(bcp + 1, jintSize); - if (end != nullptr && aligned_bcp + 2*jintSize >= end) { + if (end != nullptr && aligned_bcp + 2*jintSize > end) { return -1; // don't read past end of code buffer } // Promote calculation to 64 bits to do range checks, used by the verifier. diff --git a/src/hotspot/share/interpreter/interpreter.cpp b/src/hotspot/share/interpreter/interpreter.cpp index 2cc163186e8..1f327152e0c 100644 --- a/src/hotspot/share/interpreter/interpreter.cpp +++ b/src/hotspot/share/interpreter/interpreter.cpp @@ -61,10 +61,10 @@ void InterpreterCodelet::initialize(const char* description, Bytecodes::Code byt void InterpreterCodelet::verify() {} -void InterpreterCodelet::print_on(outputStream* st) const { +void InterpreterCodelet::print_on(outputStream* st, bool print_code) const { ttyLocker ttyl; - if (AbstractInterpreter::should_print_instructions()) { + if (print_code) { st->cr(); st->print_cr("----------------------------------------------------------------------"); } @@ -74,12 +74,16 @@ void InterpreterCodelet::print_on(outputStream* st) const { st->print_cr("[" INTPTR_FORMAT ", " INTPTR_FORMAT "] %d bytes", p2i(code_begin()), p2i(code_end()), code_size()); - if (AbstractInterpreter::should_print_instructions()) { + if (print_code) { st->cr(); Disassembler::decode(code_begin(), code_end(), st NOT_PRODUCT(COMMA &_asm_remarks)); } } +void InterpreterCodelet::print_on(outputStream* st) const { + print_on(st, AbstractInterpreter::should_print_instructions()); +} + void InterpreterCodelet::print() const { print_on(tty); } CodeletMark::CodeletMark(InterpreterMacroAssembler*& masm, diff --git a/src/hotspot/share/interpreter/interpreter.hpp b/src/hotspot/share/interpreter/interpreter.hpp index f7d42fcb4da..fb368638332 100644 --- a/src/hotspot/share/interpreter/interpreter.hpp +++ b/src/hotspot/share/interpreter/interpreter.hpp @@ -67,6 +67,7 @@ class InterpreterCodelet: public Stub { // Debugging void verify(); + void print_on(outputStream* st, bool print_code) const; void print_on(outputStream* st) const; void print() const; diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index b985d2af6ff..e7b35b121a2 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -55,7 +55,6 @@ #include "prims/jvmtiExport.hpp" #include "prims/methodHandles.hpp" #include "prims/nativeLookup.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/continuation.hpp" #include "runtime/deoptimization.hpp" #include "runtime/fieldDescriptor.inline.hpp" @@ -75,6 +74,7 @@ #include "utilities/checkedCast.hpp" #include "utilities/copy.hpp" #include "utilities/events.hpp" +#include "utilities/exceptions.hpp" #if INCLUDE_JFR #include "jfr/jfr.inline.hpp" #endif @@ -243,9 +243,9 @@ JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* fi // We may want to pass in more arguments - could make this slightly faster LastFrameAccessor last_frame(current); ConstantPool* constants = last_frame.method()->constants(); - int i = last_frame.get_index_u2(Bytecodes::_multianewarray); - Klass* klass = constants->klass_at(i, CHECK); - int nof_dims = last_frame.number_of_dimensions(); + int i = last_frame.get_index_u2(Bytecodes::_multianewarray); + Klass* klass = constants->klass_at(i, CHECK); + int nof_dims = last_frame.number_of_dimensions(); assert(klass->is_klass(), "not a class"); assert(nof_dims >= 1, "multianewarray rank must be nonzero"); @@ -352,7 +352,7 @@ JRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* current vmClasses::StackOverflowError_klass(), CHECK); // Increment counter for hs_err file reporting - AtomicAccess::inc(&Exceptions::_stack_overflow_errors); + Exceptions::increment_stack_overflow_errors(); // Remove the ScopedValue bindings in case we got a StackOverflowError // while we were trying to manipulate ScopedValue bindings. current->clear_scopedValueBindings(); @@ -366,7 +366,7 @@ JRT_ENTRY(void, InterpreterRuntime::throw_delayed_StackOverflowError(JavaThread* java_lang_Throwable::set_message(exception(), Universe::delayed_stack_overflow_error_message()); // Increment counter for hs_err file reporting - AtomicAccess::inc(&Exceptions::_stack_overflow_errors); + Exceptions::increment_stack_overflow_errors(); // Remove the ScopedValue bindings in case we got a StackOverflowError // while we were trying to manipulate ScopedValue bindings. current->clear_scopedValueBindings(); @@ -711,9 +711,7 @@ void InterpreterRuntime::resolve_get_put(Bytecodes::Code bytecode, int field_ind } ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index); - entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile()); - entry->fill_in(info.field_holder(), info.offset(), - checked_cast(info.index()), checked_cast(state), + entry->fill_in(info, checked_cast(state), static_cast(get_code), static_cast(put_code)); } @@ -758,12 +756,10 @@ JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem)) elem->set_obj(nullptr); JRT_END - JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current)) THROW(vmSymbols::java_lang_IllegalMonitorStateException()); JRT_END - JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current)) // Returns an illegal exception to install into the current thread. The // pending_exception flag is cleared so normal exception handling does not @@ -1189,10 +1185,9 @@ JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current)) JRT_END JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj, - ResolvedFieldEntry *entry)) + ResolvedFieldEntry* entry)) // check the access_flags for the field in the klass - InstanceKlass* ik = entry->field_holder(); int index = entry->field_index(); if (!ik->field_status(index).is_access_watched()) return; @@ -1212,11 +1207,10 @@ JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDe JRT_END JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj, - ResolvedFieldEntry *entry, jvalue *value)) - - InstanceKlass* ik = entry->field_holder(); + ResolvedFieldEntry* entry, jvalue* value)) // check the access_flags for the field in the klass + InstanceKlass* ik = entry->field_holder(); int index = entry->field_index(); // bail out if field modifications are not watched if (!ik->field_status(index).is_modification_watched()) return; @@ -1522,7 +1516,7 @@ JRT_LEAF(intptr_t, InterpreterRuntime::trace_bytecode(JavaThread* current, intpt LastFrameAccessor last_frame(current); assert(last_frame.is_interpreted_frame(), "must be an interpreted frame"); methodHandle mh(current, last_frame.method()); - BytecodeTracer::trace_interpreter(mh, last_frame.bcp(), tos, tos2); + BytecodeTracer::trace_interpreter(mh, last_frame.bcp(), tos, tos2, tty); return preserve_this_value; JRT_END #endif // !PRODUCT diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp index c82398b654c..25fff580c9d 100644 --- a/src/hotspot/share/interpreter/linkResolver.cpp +++ b/src/hotspot/share/interpreter/linkResolver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -1045,7 +1045,7 @@ void LinkResolver::resolve_field(fieldDescriptor& fd, stringStream ss; ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class", is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(), - current_klass->external_name()); + current_klass->external_name()); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); } @@ -1260,7 +1260,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle sel_method(THREAD, resolved_method()); if (link_info.check_access() && - // check if the method is not + // check if the method is not , which is never inherited resolved_method->name() != vmSymbols::object_initializer_name()) { Klass* current_klass = link_info.current_klass(); @@ -1724,8 +1724,8 @@ void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantP } void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, - const methodHandle& attached_method, - Bytecodes::Code byte, TRAPS) { + const methodHandle& attached_method, + Bytecodes::Code byte, TRAPS) { Klass* defc = attached_method->method_holder(); Symbol* name = attached_method->name(); Symbol* type = attached_method->signature(); diff --git a/src/hotspot/share/interpreter/oopMapCache.cpp b/src/hotspot/share/interpreter/oopMapCache.cpp index 29d6825d3e5..5a1ad7b7883 100644 --- a/src/hotspot/share/interpreter/oopMapCache.cpp +++ b/src/hotspot/share/interpreter/oopMapCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -78,14 +78,10 @@ class OopMapForCacheEntry: public GenerateOopMap { int _stack_top; virtual bool report_results() const { return false; } - virtual bool possible_gc_point (BytecodeStream *bcs); - virtual void fill_stackmap_prolog (int nof_gc_points); - virtual void fill_stackmap_epilog (); virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs, CellTypeState* vars, CellTypeState* stack, int stack_top); - virtual void fill_init_vars (GrowableArray *init_vars); public: OopMapForCacheEntry(const methodHandle& method, int bci, OopMapCacheEntry *entry); @@ -120,26 +116,6 @@ bool OopMapForCacheEntry::compute_map(Thread* current) { } -bool OopMapForCacheEntry::possible_gc_point(BytecodeStream *bcs) { - return false; // We are not reporting any result. We call result_for_basicblock directly -} - - -void OopMapForCacheEntry::fill_stackmap_prolog(int nof_gc_points) { - // Do nothing -} - - -void OopMapForCacheEntry::fill_stackmap_epilog() { - // Do nothing -} - - -void OopMapForCacheEntry::fill_init_vars(GrowableArray *init_vars) { - // Do nothing -} - - void OopMapForCacheEntry::fill_stackmap_for_opcodes(BytecodeStream *bcs, CellTypeState* vars, CellTypeState* stack, @@ -280,8 +256,8 @@ bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, in if (log) st.print("Locals (%d): ", max_locals); for(int i = 0; i < max_locals; i++) { - bool v1 = is_oop(i) ? true : false; - bool v2 = vars[i].is_reference() ? true : false; + bool v1 = is_oop(i); + bool v2 = vars[i].is_reference(); assert(v1 == v2, "locals oop mask generation error"); if (log) st.print("%d", v1 ? 1 : 0); } @@ -289,8 +265,8 @@ bool OopMapCacheEntry::verify_mask(CellTypeState* vars, CellTypeState* stack, in if (log) st.print("Stack (%d): ", stack_top); for(int j = 0; j < stack_top; j++) { - bool v1 = is_oop(max_locals + j) ? true : false; - bool v2 = stack[j].is_reference() ? true : false; + bool v1 = is_oop(max_locals + j); + bool v2 = stack[j].is_reference(); assert(v1 == v2, "stack oop mask generation error"); if (log) st.print("%d", v1 ? 1 : 0); } @@ -374,7 +350,7 @@ void OopMapCacheEntry::set_mask(CellTypeState *vars, CellTypeState *stack, int s } // set oop bit - if ( cell->is_reference()) { + if (cell->is_reference()) { value |= (mask << oop_bit_number ); _num_oops++; } diff --git a/src/hotspot/share/interpreter/rewriter.hpp b/src/hotspot/share/interpreter/rewriter.hpp index b5a4ad4870f..92e8e7db534 100644 --- a/src/hotspot/share/interpreter/rewriter.hpp +++ b/src/hotspot/share/interpreter/rewriter.hpp @@ -78,9 +78,6 @@ class Rewriter: public StackObj { _resolved_reference_limit = _resolved_references_map.length(); } - int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map.at(i); } - bool has_cp_cache(int i) { return (uint) i < (uint) _cp_map.length() && _cp_map.at(i) >= 0; } - int add_map_entry(int cp_index, GrowableArray* cp_map, GrowableArray* cp_cache_map) { assert(cp_map->at(cp_index) == -1, "not twice on same cp_index"); int cache_index = cp_cache_map->append(cp_index); diff --git a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp index 59a9d8a9090..a6e97ab227a 100644 --- a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp +++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp @@ -228,7 +228,7 @@ void JfrJavaSupport::new_object_global_ref(JfrJavaArguments* args, TRAPS) { jstring JfrJavaSupport::new_string(const char* c_str, TRAPS) { assert(c_str != nullptr, "invariant"); DEBUG_ONLY(check_java_thread_in_vm(THREAD)); - const oop result = java_lang_String::create_oop_from_str(c_str, THREAD); + const oop result = java_lang_String::create_oop_from_str(c_str, CHECK_NULL); return (jstring)local_jni_handle(result, THREAD); } diff --git a/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp b/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp index 83eee96091e..8b5819e92c4 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.cpp @@ -34,6 +34,7 @@ #include "memory/resourceArea.hpp" #include "oops/access.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/os.hpp" #include "utilities/align.hpp" UnifiedOopRef DFSClosure::_reference_stack[max_dfs_depth]; @@ -67,9 +68,27 @@ void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store, rs.process(); } +static address calculate_headroom_limit() { + static constexpr size_t required_headroom = K * 64; + const Thread* const t = Thread::current_or_null(); + return t->stack_end() + required_headroom; +} + DFSClosure::DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge) :_edge_store(edge_store), _mark_bits(mark_bits), _start_edge(start_edge), - _max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false) { + _max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false), + _headroom_limit(calculate_headroom_limit()) { +} + +bool DFSClosure::have_headroom() const { + const address sp = (address) os::current_stack_pointer(); +#ifdef ASSERT + const Thread* const t = Thread::current_or_null(); + assert(t->is_VM_thread(), "invariant"); + assert(t->is_in_full_stack(_headroom_limit), "invariant"); + assert(t->is_in_full_stack(sp), "invariant"); +#endif + return sp > _headroom_limit; } void DFSClosure::closure_impl(UnifiedOopRef reference, const oop pointee) { @@ -97,7 +116,7 @@ void DFSClosure::closure_impl(UnifiedOopRef reference, const oop pointee) { } } assert(_max_depth >= 1, "invariant"); - if (_depth < _max_depth - 1) { + if (_depth < _max_depth - 1 && have_headroom()) { _depth++; pointee->oop_iterate(this); assert(_depth > 0, "invariant"); diff --git a/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp b/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp index 98364690422..9ee15ff07e0 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp @@ -46,12 +46,15 @@ class DFSClosure : public BasicOopIterateClosure { size_t _max_depth; size_t _depth; bool _ignore_root_set; + const address _headroom_limit; DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge); void add_chain(); void closure_impl(UnifiedOopRef reference, const oop pointee); + bool have_headroom() const; + public: virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; } diff --git a/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.cpp b/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.cpp index 9aef92c4182..2c341f2385e 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.cpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,10 @@ #include "jfr/leakprofiler/chains/edgeUtils.hpp" #include "jfr/leakprofiler/sampling/objectSample.hpp" #include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp" +#include "jfr/recorder/service/jfrOptionSet.hpp" #include "oops/oop.inline.hpp" #include "runtime/safepoint.hpp" +#include "utilities/resizableHashTable.hpp" StoredEdge::StoredEdge(const Edge* parent, UnifiedOopRef reference) : Edge(parent, reference), _gc_root_id(0), _skip_length(0) {} @@ -216,84 +218,62 @@ bool EdgeStore::put_edges(StoredEdge** previous, const Edge** current, size_t li return nullptr == *current; } -static GrowableArray* _leak_context_edges = nullptr; +typedef ResizeableHashTable SampleToLeakContextEdgeMap; +static SampleToLeakContextEdgeMap* _sample_to_leak_context_edge_map = nullptr; EdgeStore::EdgeStore() : _edges(new EdgeHashTable(this)) {} EdgeStore::~EdgeStore() { assert(_edges != nullptr, "invariant"); delete _edges; - delete _leak_context_edges; - _leak_context_edges = nullptr; + delete _sample_to_leak_context_edge_map; + _sample_to_leak_context_edge_map = nullptr; } -static int leak_context_edge_idx(const ObjectSample* sample) { +static const StoredEdge* leak_context_edge(const ObjectSample* sample) { assert(sample != nullptr, "invariant"); - return static_cast(sample->object()->mark().value()) >> markWord::lock_bits; + assert(_sample_to_leak_context_edge_map != nullptr, "invariant"); + const StoredEdge** edge = _sample_to_leak_context_edge_map->get(p2u(sample->object())); + return edge != nullptr ? *edge : nullptr; } bool EdgeStore::has_leak_context(const ObjectSample* sample) const { - const int idx = leak_context_edge_idx(sample); - if (idx == 0) { - return false; - } - assert(idx > 0, "invariant"); - assert(_leak_context_edges != nullptr, "invariant"); - assert(idx < _leak_context_edges->length(), "invariant"); - assert(_leak_context_edges->at(idx) != nullptr, "invariant"); - return true; + return _sample_to_leak_context_edge_map != nullptr && leak_context_edge(sample) != nullptr; } const StoredEdge* EdgeStore::get(const ObjectSample* sample) const { assert(sample != nullptr, "invariant"); - if (_leak_context_edges != nullptr) { + if (_sample_to_leak_context_edge_map != nullptr) { assert(SafepointSynchronize::is_at_safepoint(), "invariant"); - const int idx = leak_context_edge_idx(sample); - if (idx > 0) { - assert(idx < _leak_context_edges->length(), "invariant"); - const StoredEdge* const edge =_leak_context_edges->at(idx); - assert(edge != nullptr, "invariant"); + const StoredEdge* const edge = leak_context_edge(sample); + if (edge != nullptr) { return edge; } } return get(UnifiedOopRef::encode_in_native(sample->object_addr())); } -#ifdef ASSERT -// max_idx to ensure idx fit in lower 32-bits of markword together with lock bits. -static constexpr const int max_idx = right_n_bits(32 - markWord::lock_bits); +static constexpr const unsigned max_map_size = max_jint >> 1; -static void store_idx_precondition(oop sample_object, int idx) { - assert(sample_object != nullptr, "invariant"); - assert(sample_object->mark().is_marked(), "invariant"); - assert(idx > 0, "invariant"); - assert(idx <= max_idx, "invariant"); -} -#endif - -static void store_idx_in_markword(oop sample_object, int idx) { - DEBUG_ONLY(store_idx_precondition(sample_object, idx);) - const markWord idx_mark_word(sample_object->mark().value() | idx << markWord::lock_bits); - sample_object->set_mark(idx_mark_word); - assert(sample_object->mark().is_marked(), "must still be marked"); -} - -static const int initial_size = 64; - -static int save(const StoredEdge* edge) { - assert(edge != nullptr, "invariant"); - if (_leak_context_edges == nullptr) { - _leak_context_edges = new (mtTracing) GrowableArray(initial_size, mtTracing); - _leak_context_edges->append(nullptr); // next idx now at 1, for disambiguation in markword. +static inline unsigned map_size() { + assert(JfrOptionSet::old_object_queue_size() > 0, "invariant"); + unsigned size = JfrOptionSet::old_object_queue_size(); + size = round_up_power_of_2(size); + if (size < 1024) { + return 1024; } - return _leak_context_edges->append(edge); + size <<= 1; + return size >= max_map_size ? max_map_size : size; } -// We associate the leak context edge with the leak candidate object by saving the -// edge in an array and storing the array idx (shifted) into the markword of the candidate object. static void associate_with_candidate(const StoredEdge* leak_context_edge) { assert(leak_context_edge != nullptr, "invariant"); - store_idx_in_markword(leak_context_edge->pointee(), save(leak_context_edge)); + if (_sample_to_leak_context_edge_map == nullptr) { + const unsigned size = map_size(); + _sample_to_leak_context_edge_map = new (mtTracing) SampleToLeakContextEdgeMap(size, size); + } + assert(_sample_to_leak_context_edge_map != nullptr, "invariant"); + _sample_to_leak_context_edge_map->put(p2u(leak_context_edge->pointee()), leak_context_edge); } StoredEdge* EdgeStore::associate_leak_context_with_candidate(const Edge* edge) { diff --git a/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.hpp b/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.hpp index e920fd64ea9..460314854b7 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.hpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,7 +39,6 @@ class StoredEdge : public Edge { size_t _skip_length; public: - StoredEdge(); StoredEdge(const Edge* parent, UnifiedOopRef reference); StoredEdge(const Edge& edge); StoredEdge(const StoredEdge& edge); diff --git a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp index b30ebd8108c..426ba4e7650 100644 --- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp +++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp @@ -493,7 +493,7 @@ TRACE_REQUEST_FUNC(InitialSystemProperty) { TRACE_REQUEST_FUNC(ThreadAllocationStatistics) { ResourceMark rm; int initial_size = Threads::number_of_threads(); - GrowableArray allocated(initial_size); + GrowableArray allocated(initial_size); GrowableArray thread_ids(initial_size); JfrTicks time_stamp = JfrTicks::now(); JfrJavaThreadIterator iter; diff --git a/src/hotspot/share/jfr/periodic/sampling/jfrSampleRequest.cpp b/src/hotspot/share/jfr/periodic/sampling/jfrSampleRequest.cpp index 7049df0198b..68a47193e55 100644 --- a/src/hotspot/share/jfr/periodic/sampling/jfrSampleRequest.cpp +++ b/src/hotspot/share/jfr/periodic/sampling/jfrSampleRequest.cpp @@ -58,29 +58,22 @@ static inline bool in_stack(intptr_t* ptr, JavaThread* jt) { return jt->is_in_full_stack_checked(reinterpret_cast
(ptr)); } +#ifdef ASSERT static inline bool sp_in_stack(const JfrSampleRequest& request, JavaThread* jt) { return in_stack(static_cast(request._sample_sp), jt); } +#endif // ASSERT static inline bool fp_in_stack(const JfrSampleRequest& request, JavaThread* jt) { return in_stack(static_cast(request._sample_bcp), jt); } -static inline void update_interpreter_frame_sender_pc(JfrSampleRequest& request, intptr_t* fp) { - request._sample_pc = frame::interpreter_return_address(fp); -} - static inline void update_interpreter_frame_pc(JfrSampleRequest& request, JavaThread* jt) { assert(fp_in_stack(request, jt), "invariant"); assert(is_interpreter(request), "invariant"); request._sample_pc = frame::interpreter_return_address(static_cast(request._sample_bcp)); } -static inline address interpreter_frame_return_address(const JfrSampleRequest& request) { - assert(is_interpreter(request), "invariant"); - return frame::interpreter_return_address(static_cast(request._sample_bcp)); -} - static inline intptr_t* frame_sender_sp(const JfrSampleRequest& request, JavaThread* jt) { assert(fp_in_stack(request, jt), "invariant"); return frame::sender_sp(static_cast(request._sample_bcp)); @@ -90,29 +83,10 @@ static inline void update_frame_sender_sp(JfrSampleRequest& request, JavaThread* request._sample_sp = frame_sender_sp(request, jt); } -static inline void update_frame_sender_sp(JfrSampleRequest& request, intptr_t* fp) { - request._sample_sp = frame::sender_sp(fp); -} - static inline intptr_t* frame_link(const JfrSampleRequest& request) { return frame::link(static_cast(request._sample_bcp)); } -static inline void update_sp(JfrSampleRequest& request, int frame_size) { - assert(frame_size >= 0, "invariant"); - request._sample_sp = static_cast(request._sample_sp) + frame_size; -} - -static inline void update_pc(JfrSampleRequest& request) { - assert(request._sample_sp != nullptr, "invariant"); - request._sample_pc = frame::return_address(static_cast(request._sample_sp)); -} - -static inline void update_fp(JfrSampleRequest& request) { - assert(request._sample_sp != nullptr, "invariant"); - request._sample_bcp = is_interpreter(request) ? frame::fp(static_cast(request._sample_sp)) : nullptr; -} - // Less extensive sanity checks for an interpreter frame. static bool is_valid_interpreter_frame(const JfrSampleRequest& request, JavaThread* jt) { assert(sp_in_stack(request, jt), "invariant"); diff --git a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampling.cpp b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampling.cpp index 534c9996cfe..7c0f8c02e69 100644 --- a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampling.cpp +++ b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampling.cpp @@ -66,10 +66,6 @@ static inline void send_safepoint_latency_event(const JfrSampleRequest& request, } } -static inline bool is_interpreter(address pc) { - return Interpreter::contains(pc); -} - static inline bool is_interpreter(const JfrSampleRequest& request) { return request._sample_bcp != nullptr; } diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp index ff688a297ed..c6c1b4cad60 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp @@ -176,6 +176,7 @@ static inline bool is_global(ConstBufferPtr buffer) { return buffer->context() == JFR_GLOBAL; } +#ifdef ASSERT static inline bool is_thread_local(ConstBufferPtr buffer) { assert(buffer != nullptr, "invariant"); return buffer->context() == JFR_THREADLOCAL; @@ -185,6 +186,7 @@ static inline bool is_virtual_thread_local(ConstBufferPtr buffer) { assert(buffer != nullptr, "invariant"); return buffer->context() == JFR_VIRTUAL_THREADLOCAL; } +#endif // ASSERT BufferPtr JfrCheckpointManager::lease_global(Thread* thread, bool previous_epoch /* false */, size_t size /* 0 */) { JfrCheckpointMspace* const mspace = instance()._global_mspace; diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp index b1c502e17f8..3dd9ea41d3d 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp @@ -1265,7 +1265,7 @@ static size_t teardown() { JfrKlassUnloading::clear(); _artifacts->clear(); _initial_type_set = true; - } else { + } else if (is_initial_typeset_for_chunk()) { _initial_type_set = false; } return total_count; diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp index 9c57374d6c6..eab7de20545 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +75,7 @@ static size_t element_size(bool compressed) { } static bool can_compress_element(traceid id) { - return Metaspace::using_class_space() && id < uncompressed_threshold; + return INCLUDE_CLASS_SPACE == 1 && id < uncompressed_threshold; } static size_t element_size(const Klass* klass) { diff --git a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp index 061e3feac6f..5c12d5213ca 100644 --- a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp +++ b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp @@ -102,6 +102,9 @@ bool JfrRecorder::on_create_vm_1() { if (!create_checkpoint_manager()) { return false; } + if (!JfrSymbolTable::create()) { + return false; + } } // fast time initialization @@ -316,10 +319,7 @@ bool JfrRecorder::create_components() { if (!create_thread_group_manager()) { return false; } - if (!create_symbol_table()) { - return false; - } - return true; + return create_symbol_table(); } // subsystems @@ -418,7 +418,13 @@ bool JfrRecorder::create_thread_group_manager() { } bool JfrRecorder::create_symbol_table() { - return JfrSymbolTable::create(); + return !is_started_on_commandline() ? JfrSymbolTable::create() : true; +} + +void JfrRecorder::destroy_symbol_table() { + if (!is_started_on_commandline()) { + JfrSymbolTable::destroy(); + } } void JfrRecorder::destroy_components() { @@ -461,7 +467,7 @@ void JfrRecorder::destroy_components() { } JfrEventThrottler::destroy(); JfrThreadGroupManager::destroy(); - JfrSymbolTable::destroy(); + destroy_symbol_table(); } bool JfrRecorder::create_recorder_thread() { diff --git a/src/hotspot/share/jfr/recorder/jfrRecorder.hpp b/src/hotspot/share/jfr/recorder/jfrRecorder.hpp index 8cc4521669d..fa1b677b31a 100644 --- a/src/hotspot/share/jfr/recorder/jfrRecorder.hpp +++ b/src/hotspot/share/jfr/recorder/jfrRecorder.hpp @@ -59,6 +59,7 @@ class JfrRecorder : public JfrCHeapObj { static bool create_event_throttler(); static bool create_symbol_table(); static bool create_components(); + static void destroy_symbol_table(); static void destroy_components(); static void on_recorder_thread_exit(); diff --git a/src/hotspot/share/jfr/support/jfrDeprecationManager.cpp b/src/hotspot/share/jfr/support/jfrDeprecationManager.cpp index 8886f412bb2..23e4cf839bd 100644 --- a/src/hotspot/share/jfr/support/jfrDeprecationManager.cpp +++ b/src/hotspot/share/jfr/support/jfrDeprecationManager.cpp @@ -194,9 +194,11 @@ static inline bool is_not_jdk_module(const ModuleEntry* module, JavaThread* jt) return !is_jdk_module(module, jt); } +#ifdef ASSERT static inline bool jfr_is_started_on_command_line() { return JfrRecorder::is_started_on_commandline(); } +#endif // ASSERT static bool should_record(const Method* method, const Method* sender, JavaThread* jt) { assert(method != nullptr, "invariant"); diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 6214f6a2746..6048c19d911 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -206,13 +206,8 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { Universe_narrow_oop_base = nullptr; Universe_narrow_oop_shift = 0; } - if (UseCompressedClassPointers) { - Universe_narrow_klass_base = CompressedKlassPointers::base(); - Universe_narrow_klass_shift = CompressedKlassPointers::shift(); - } else { - Universe_narrow_klass_base = nullptr; - Universe_narrow_klass_shift = 0; - } + Universe_narrow_klass_base = CompressedKlassPointers::base(); + Universe_narrow_klass_shift = CompressedKlassPointers::shift(); Universe_non_oop_bits = Universe::non_oop_word(); Universe_verify_oop_mask = Universe::verify_oop_mask(); Universe_verify_oop_bits = Universe::verify_oop_bits(); @@ -390,7 +385,6 @@ JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) { X86_ONLY(do_int_flag(UseAVX)) \ do_bool_flag(UseCRC32Intrinsics) \ do_bool_flag(UseAdler32Intrinsics) \ - do_bool_flag(UseCompressedClassPointers) \ do_bool_flag(UseCompressedOops) \ X86_ONLY(do_bool_flag(UseCountLeadingZerosInstruction)) \ X86_ONLY(do_bool_flag(UseCountTrailingZerosInstruction)) \ diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 91482e825cd..1fdf98588fd 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -342,7 +342,7 @@ volatile_nonstatic_field(ObjectMonitor, _succ, int64_t) \ \ volatile_nonstatic_field(oopDesc, _mark, markWord) \ - volatile_nonstatic_field(oopDesc, _metadata._klass, Klass*) \ + volatile_nonstatic_field(oopDesc, _compressed_klass, narrowKlass) \ \ static_field(StubRoutines, _verify_oop_count, jint) \ \ @@ -432,7 +432,7 @@ \ nonstatic_field(Thread, _poll_data, SafepointMechanism::ThreadData) \ nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \ - nonstatic_field(Thread, _allocated_bytes, jlong) \ + nonstatic_field(Thread, _allocated_bytes, uint64_t) \ JFR_ONLY(nonstatic_field(Thread, _jfr_thread_local, JfrThreadLocal)) \ \ static_field(java_lang_Thread, _tid_offset, int) \ @@ -450,8 +450,8 @@ nonstatic_field(ThreadLocalAllocBuffer, _pf_top, HeapWord*) \ nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \ nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \ - nonstatic_field(ThreadLocalAllocBuffer, _number_of_refills, unsigned) \ - nonstatic_field(ThreadLocalAllocBuffer, _slow_allocations, unsigned) \ + nonstatic_field(ThreadLocalAllocBuffer, _num_refills, unsigned) \ + nonstatic_field(ThreadLocalAllocBuffer, _num_slow_allocations, unsigned) \ \ nonstatic_field(SafepointMechanism::ThreadData, _polling_word, volatile uintptr_t) \ nonstatic_field(SafepointMechanism::ThreadData, _polling_page, volatile uintptr_t) \ diff --git a/src/hotspot/share/logging/logTag.hpp b/src/hotspot/share/logging/logTag.hpp index 3ad6a197d07..20d61b542b0 100644 --- a/src/hotspot/share/logging/logTag.hpp +++ b/src/hotspot/share/logging/logTag.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -90,6 +90,7 @@ class outputStream; LOG_TAG(freelist) \ LOG_TAG(gc) \ NOT_PRODUCT(LOG_TAG(generate)) \ + LOG_TAG(generateoopmap) \ LOG_TAG(handshake) \ LOG_TAG(hashtables) \ LOG_TAG(heap) \ diff --git a/src/hotspot/share/memory/classLoaderMetaspace.cpp b/src/hotspot/share/memory/classLoaderMetaspace.cpp index c1ff172071d..af3b8b1b77f 100644 --- a/src/hotspot/share/memory/classLoaderMetaspace.cpp +++ b/src/hotspot/share/memory/classLoaderMetaspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -162,10 +162,12 @@ void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size) { MetaBlock bl(ptr, word_size); // Add to class arena only if block is usable for encodable Klass storage. MetaspaceArena* receiving_arena = non_class_space_arena(); - if (Metaspace::using_class_space() && Metaspace::is_in_class_space(ptr) && +#if INCLUDE_CLASS_SPACE + if (Metaspace::is_in_class_space(ptr) && is_aligned(ptr, class_space_arena()->allocation_alignment_bytes())) { receiving_arena = class_space_arena(); } +#endif receiving_arena->deallocate(bl); DEBUG_ONLY(InternalStats::inc_num_deallocs();) } diff --git a/src/hotspot/share/memory/classLoaderMetaspace.hpp b/src/hotspot/share/memory/classLoaderMetaspace.hpp index aa43e171708..dc782611e98 100644 --- a/src/hotspot/share/memory/classLoaderMetaspace.hpp +++ b/src/hotspot/share/memory/classLoaderMetaspace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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,9 +40,10 @@ namespace metaspace { // A ClassLoaderMetaspace manages MetaspaceArena(s) for a CLD. // -// A CLD owns one MetaspaceArena if UseCompressedClassPointers is false. Otherwise -// it owns two - one for the Klass* objects from the class space, one for the other -// types of MetaspaceObjs from the non-class space. +// 64-bit: +// +// A CLD owns two MetaspaceArenas - one for the Klass* objects from the class space, +// one for the other types of MetaspaceObjs from the non-class space. // // +------+ +----------------------+ +-------------------+ // | CLD | ---> | ClassLoaderMetaspace | ----> | (non class) Arena | @@ -58,6 +59,11 @@ namespace metaspace { // ^ // alloc top // +// 32-bit: +// +// A CLD owns just one MetaspaceArena. In that arena all metadata - Klass and other - +// are placed. + class ClassLoaderMetaspace : public CHeapObj { friend class metaspace::ClmsTester; // for gtests @@ -67,11 +73,10 @@ class ClassLoaderMetaspace : public CHeapObj { const Metaspace::MetaspaceType _space_type; // Arena for allocations from non-class metaspace - // (resp. for all allocations if -XX:-UseCompressedClassPointers). metaspace::MetaspaceArena* _non_class_space_arena; // Arena for allocations from class space - // (null if -XX:-UseCompressedClassPointers). + // (null for 32-bit). metaspace::MetaspaceArena* _class_space_arena; Mutex* lock() const { return _lock; } diff --git a/src/hotspot/share/memory/memoryReserver.cpp b/src/hotspot/share/memory/memoryReserver.cpp index 59e8f30707d..1c44f76ed11 100644 --- a/src/hotspot/share/memory/memoryReserver.cpp +++ b/src/hotspot/share/memory/memoryReserver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -231,12 +231,7 @@ ReservedSpace MemoryReserver::reserve(size_t size, void MemoryReserver::release(const ReservedSpace& reserved) { assert(reserved.is_reserved(), "Precondition"); - - if (reserved.special()) { - os::release_memory_special(reserved.base(), reserved.size()); - } else { - os::release_memory(reserved.base(), reserved.size()); - } + os::release_memory(reserved.base(), reserved.size()); } static char* map_memory_to_file(char* requested_address, @@ -372,11 +367,7 @@ ReservedSpace HeapReserver::Instance::reserve_memory(size_t size, void HeapReserver::Instance::release(const ReservedSpace& reserved) { if (reserved.is_reserved()) { if (_fd == -1) { - if (reserved.special()) { - os::release_memory_special(reserved.base(), reserved.size()); - } else{ - os::release_memory(reserved.base(), reserved.size()); - } + os::release_memory(reserved.base(), reserved.size()); } else { os::unmap_memory(reserved.base(), reserved.size()); } diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index e686b324004..da6ebc991c8 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021 SAP SE. All rights reserved. * Copyright (c) 2023, 2025, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -166,33 +166,33 @@ void MetaspaceUtils::print_metaspace_change(const MetaspaceCombinedStats& pre_me // it is a constant (to uninformed users, often confusingly large). For non-class space, it would // be interesting since free chunks can be uncommitted, but for now it is left out. - if (Metaspace::using_class_space()) { - log_info(gc, metaspace)(HEAP_CHANGE_FORMAT" " - HEAP_CHANGE_FORMAT" " - HEAP_CHANGE_FORMAT, - HEAP_CHANGE_FORMAT_ARGS("Metaspace", - pre_meta_values.used(), - pre_meta_values.committed(), - meta_values.used(), - meta_values.committed()), - HEAP_CHANGE_FORMAT_ARGS("NonClass", - pre_meta_values.non_class_used(), - pre_meta_values.non_class_committed(), - meta_values.non_class_used(), - meta_values.non_class_committed()), - HEAP_CHANGE_FORMAT_ARGS("Class", - pre_meta_values.class_used(), - pre_meta_values.class_committed(), - meta_values.class_used(), - meta_values.class_committed())); - } else { - log_info(gc, metaspace)(HEAP_CHANGE_FORMAT, - HEAP_CHANGE_FORMAT_ARGS("Metaspace", - pre_meta_values.used(), - pre_meta_values.committed(), - meta_values.used(), - meta_values.committed())); - } +#if INCLUDE_CLASS_SPACE + log_info(gc, metaspace)(HEAP_CHANGE_FORMAT" " + HEAP_CHANGE_FORMAT" " + HEAP_CHANGE_FORMAT, + HEAP_CHANGE_FORMAT_ARGS("Metaspace", + pre_meta_values.used(), + pre_meta_values.committed(), + meta_values.used(), + meta_values.committed()), + HEAP_CHANGE_FORMAT_ARGS("NonClass", + pre_meta_values.non_class_used(), + pre_meta_values.non_class_committed(), + meta_values.non_class_used(), + meta_values.non_class_committed()), + HEAP_CHANGE_FORMAT_ARGS("Class", + pre_meta_values.class_used(), + pre_meta_values.class_committed(), + meta_values.class_used(), + meta_values.class_committed())); +#else + log_info(gc, metaspace)(HEAP_CHANGE_FORMAT, + HEAP_CHANGE_FORMAT_ARGS("Metaspace", + pre_meta_values.used(), + pre_meta_values.committed(), + meta_values.used(), + meta_values.committed())); +#endif // INCLUDE_CLASS_SPACE } // This will print out a basic metaspace usage report but @@ -226,41 +226,36 @@ void MetaspaceUtils::print_on(outputStream* out) { stats.committed()/K, stats.reserved()/K); - if (Metaspace::using_class_space()) { - StreamIndentor si(out, 1); - out->print("class space "); - out->fill_to(17); - out->print_cr("used %zuK, " - "committed %zuK, " - "reserved %zuK", - stats.class_space_stats().used()/K, - stats.class_space_stats().committed()/K, - stats.class_space_stats().reserved()/K); - } +#if INCLUDE_CLASS_SPACE + StreamIndentor si(out, 1); + out->print("class space "); + out->fill_to(17); + out->print_cr("used %zuK, " + "committed %zuK, " + "reserved %zuK", + stats.class_space_stats().used()/K, + stats.class_space_stats().committed()/K, + stats.class_space_stats().reserved()/K); +#endif // INCLUDE_CLASS_SPACE } #ifdef ASSERT void MetaspaceUtils::verify() { if (Metaspace::initialized()) { - // Verify non-class chunkmanager... ChunkManager* cm = ChunkManager::chunkmanager_nonclass(); cm->verify(); - // ... and space list. VirtualSpaceList* vsl = VirtualSpaceList::vslist_nonclass(); vsl->verify(); - if (Metaspace::using_class_space()) { - // If we use compressed class pointers, verify class chunkmanager... - cm = ChunkManager::chunkmanager_class(); - cm->verify(); - - // ... and class spacelist. - vsl = VirtualSpaceList::vslist_class(); - vsl->verify(); - } +#if INCLUDE_CLASS_SPACE + cm = ChunkManager::chunkmanager_class(); + cm->verify(); + vsl = VirtualSpaceList::vslist_class(); + vsl->verify(); +#endif // INCLUDE_CLASS_SPACE } } #endif @@ -387,7 +382,8 @@ void MetaspaceGC::post_initialize() { bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { // Check if the compressed class space is full. - if (is_class && Metaspace::using_class_space()) { +#if INCLUDE_CLASS_SPACE + if (is_class) { size_t class_committed = MetaspaceUtils::committed_bytes(Metaspace::ClassType); if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) { log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by %zu words (CompressedClassSpaceSize = %zu words)", @@ -395,6 +391,7 @@ bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { return false; } } +#endif // INCLUDE_CLASS_SPACE // Check if the user has imposed a limit on the metaspace memory. size_t committed_bytes = MetaspaceUtils::committed_bytes(); @@ -548,7 +545,7 @@ const void* Metaspace::_class_space_end = nullptr; bool Metaspace::initialized() { return metaspace::MetaspaceContext::context_nonclass() != nullptr - LP64_ONLY(&& (using_class_space() ? Metaspace::class_space_is_initialized() : true)); + CLASS_SPACE_ONLY(&& Metaspace::class_space_is_initialized()); } #ifdef _LP64 @@ -566,9 +563,9 @@ void Metaspace::print_compressed_class_space(outputStream* st) { // Given a prereserved space, use that to set up the compressed class space list. void Metaspace::initialize_class_space(ReservedSpace rs) { + STATIC_ASSERT(INCLUDE_CLASS_SPACE == 1); assert(rs.size() >= CompressedClassSpaceSize, "%zu != %zu", rs.size(), CompressedClassSpaceSize); - assert(using_class_space(), "Must be using class space"); assert(rs.size() == CompressedClassSpaceSize, "%zu != %zu", rs.size(), CompressedClassSpaceSize); @@ -658,49 +655,51 @@ void Metaspace::ergo_initialize() { MaxMetaspaceSize = MAX2(MaxMetaspaceSize, commit_alignment()); - if (UseCompressedClassPointers) { - // Let Class Space not be larger than 80% of MaxMetaspaceSize. Note that is - // grossly over-dimensioned for most usage scenarios; typical ratio of - // class space : non class space usage is about 1:6. With many small classes, - // it can get as low as 1:2. It is not a big deal though since ccs is only - // reserved and will be committed on demand only. - const size_t max_ccs_size = 8 * (MaxMetaspaceSize / 10); +#if INCLUDE_CLASS_SPACE - // Sanity check. - const size_t max_klass_range = CompressedKlassPointers::max_klass_range_size(); - assert(max_klass_range >= reserve_alignment(), - "Klass range (%zu) must cover at least a full root chunk (%zu)", - max_klass_range, reserve_alignment()); + // Let Class Space not be larger than 80% of MaxMetaspaceSize. Note that is + // grossly over-dimensioned for most usage scenarios; typical ratio of + // class space : non class space usage is about 1:6. With many small classes, + // it can get as low as 1:2. It is not a big deal though since ccs is only + // reserved and will be committed on demand only. + const size_t max_ccs_size = 8 * (MaxMetaspaceSize / 10); - size_t adjusted_ccs_size = MIN3(CompressedClassSpaceSize, max_ccs_size, max_klass_range); + // Sanity check. + const size_t max_klass_range = CompressedKlassPointers::max_klass_range_size(); + assert(max_klass_range >= reserve_alignment(), + "Klass range (%zu) must cover at least a full root chunk (%zu)", + max_klass_range, reserve_alignment()); - // CCS must be aligned to root chunk size, and be at least the size of one - // root chunk. - adjusted_ccs_size = align_up(adjusted_ccs_size, reserve_alignment()); - adjusted_ccs_size = MAX2(adjusted_ccs_size, reserve_alignment()); + size_t adjusted_ccs_size = MIN3(CompressedClassSpaceSize, max_ccs_size, max_klass_range); - // Print a warning if the adjusted size differs from the users input - if (CompressedClassSpaceSize != adjusted_ccs_size) { - #define X "CompressedClassSpaceSize adjusted from user input " \ - "%zu bytes to %zu bytes", CompressedClassSpaceSize, adjusted_ccs_size - if (FLAG_IS_CMDLINE(CompressedClassSpaceSize)) { - log_warning(metaspace)(X); - } else { - log_info(metaspace)(X); - } - #undef X - } - - // Note: re-adjusting may have us left with a CompressedClassSpaceSize - // larger than MaxMetaspaceSize for very small values of MaxMetaspaceSize. - // Lets just live with that, its not a big deal. - if (adjusted_ccs_size != CompressedClassSpaceSize) { - FLAG_SET_ERGO(CompressedClassSpaceSize, adjusted_ccs_size); - log_info(metaspace)("Setting CompressedClassSpaceSize to %zu.", - CompressedClassSpaceSize); + // CCS must be aligned to root chunk size, and be at least the size of one + // root chunk. + adjusted_ccs_size = align_up(adjusted_ccs_size, reserve_alignment()); + adjusted_ccs_size = MAX2(adjusted_ccs_size, reserve_alignment()); + + // Print a warning if the adjusted size differs from the users input + if (CompressedClassSpaceSize != adjusted_ccs_size) { + #define X "CompressedClassSpaceSize adjusted from user input " \ + "%zu bytes to %zu bytes", CompressedClassSpaceSize, adjusted_ccs_size + if (FLAG_IS_CMDLINE(CompressedClassSpaceSize)) { + log_warning(metaspace)(X); + } else { + log_info(metaspace)(X); } + #undef X } + // Note: re-adjusting may have us left with a CompressedClassSpaceSize + // larger than MaxMetaspaceSize for very small values of MaxMetaspaceSize. + // Lets just live with that, its not a big deal. + if (adjusted_ccs_size != CompressedClassSpaceSize) { + FLAG_SET_ERGO(CompressedClassSpaceSize, adjusted_ccs_size); + log_info(metaspace)("Setting CompressedClassSpaceSize to %zu.", + CompressedClassSpaceSize); + } + +#endif // INCLUDE_CLASS_SPACE + // Set MetaspaceSize, MinMetaspaceExpansion and MaxMetaspaceExpansion if (MetaspaceSize > MaxMetaspaceSize) { MetaspaceSize = MaxMetaspaceSize; @@ -724,15 +723,12 @@ void Metaspace::global_initialize() { AOTMetaspace::initialize_for_static_dump(); } - // If UseCompressedClassPointers=1, we have two cases: + // We have two cases: // a) if CDS is active (runtime, Xshare=on), it will create the class space - // for us, initialize it and set up CompressedKlassPointers encoding. - // Class space will be reserved above the mapped archives. + // for us. It then will set up encoding to cover both CDS archive space and class space. // b) if CDS either deactivated (Xshare=off) or a static dump is to be done (Xshare:dump), - // we will create the class space on our own. It will be placed above the java heap, - // since we assume it has been placed in low - // address regions. We may rethink this (see JDK-8244943). Failing that, - // it will be placed anywhere. + // we will create the class space on our own and set up encoding to only cover the + // class space. #if INCLUDE_CDS // case (a) @@ -746,9 +742,9 @@ void Metaspace::global_initialize() { } #endif // INCLUDE_CDS -#ifdef _LP64 +#if INCLUDE_CLASS_SPACE - if (using_class_space() && !class_space_is_initialized()) { + if (!class_space_is_initialized()) { assert(!CDSConfig::is_using_archive(), "CDS archive is not mapped at this point"); // case (b) (No CDS) @@ -835,28 +831,23 @@ void Metaspace::global_initialize() { } #else - // +UseCompressedClassPointers on 32-bit: does not need class space. Klass can live wherever. - if (UseCompressedClassPointers) { - const address start = (address)os::vm_min_address(); // but not in the zero page - const address end = (address)CompressedKlassPointers::max_klass_range_size(); - CompressedKlassPointers::initialize(start, end - start); - } -#endif // __LP64 + // 32-bit: + const address start = (address)os::vm_min_address(); // but not in the zero page + const address end = (address)CompressedKlassPointers::max_klass_range_size(); + CompressedKlassPointers::initialize(start, end - start); +#endif // INCLUDE_CLASS_SPACE // Initialize non-class virtual space list, and its chunk manager: MetaspaceContext::initialize_nonclass_space_context(); _tracer = new MetaspaceTracer(); - if (UseCompressedClassPointers) { - // Note: "cds" would be a better fit but keep this for backward compatibility. - LogTarget(Info, gc, metaspace) lt; - if (lt.is_enabled()) { - LogStream ls(lt); - CDS_ONLY(AOTMetaspace::print_on(&ls);) - Metaspace::print_compressed_class_space(&ls); - CompressedKlassPointers::print_mode(&ls); - } + LogTarget(Info, gc, metaspace) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + CDS_ONLY(AOTMetaspace::print_on(&ls);) + Metaspace::print_compressed_class_space(&ls); + CompressedKlassPointers::print_mode(&ls); } } @@ -888,15 +879,13 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); if (result != nullptr) { -#ifdef ASSERT - if (using_class_space() && mdtype == ClassType) { + if (INCLUDE_CLASS_SPACE == 1 && mdtype == ClassType) { assert(is_in_class_space(result) && is_aligned(result, CompressedKlassPointers::klass_alignment_in_bytes()), "Sanity"); } else { assert((is_in_class_space(result) || is_in_nonclass_metaspace(result)) && is_aligned(result, Metaspace::min_allocation_alignment_bytes), "Sanity"); } -#endif // Zero initialize. Copy::fill_to_words((HeapWord*)result, word_size, 0); log_trace(metaspace)("Metaspace::allocate: type %d return " PTR_FORMAT ".", (int)type, p2i(result)); @@ -1017,12 +1006,12 @@ void Metaspace::purge(bool classes_unloaded) { if (cm != nullptr) { cm->purge(); } - if (using_class_space()) { - cm = ChunkManager::chunkmanager_class(); - if (cm != nullptr) { - cm->purge(); - } +#if INCLUDE_CLASS_SPACE + cm = ChunkManager::chunkmanager_class(); + if (cm != nullptr) { + cm->purge(); } +#endif // INCLUDE_CLASS_SPACE } // Try to satisfy queued metaspace allocation requests. diff --git a/src/hotspot/share/memory/metaspace.hpp b/src/hotspot/share/memory/metaspace.hpp index 01ef4b4dd49..96f5a2459ce 100644 --- a/src/hotspot/share/memory/metaspace.hpp +++ b/src/hotspot/share/memory/metaspace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -164,18 +164,12 @@ public: static void print_compressed_class_space(outputStream* st) NOT_LP64({}); - // Return TRUE only if UseCompressedClassPointers is True. - static bool using_class_space() { - return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers); - } - static bool is_class_space_allocation(MetadataType mdType) { - return mdType == ClassType && using_class_space(); + return CLASS_SPACE_ONLY(mdType == ClassType) NOT_CLASS_SPACE(false); } static bool initialized(); }; - #endif // SHARE_MEMORY_METASPACE_HPP diff --git a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp index 3cff2a50d03..f6683f50fd1 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -59,39 +59,39 @@ static void print_vs(outputStream* out, size_t scale) { const size_t committed_nc = RunningCounters::committed_words_nonclass(); const int num_nodes_nc = VirtualSpaceList::vslist_nonclass()->num_nodes(); - if (Metaspace::using_class_space()) { - const size_t reserved_c = RunningCounters::reserved_words_class(); - const size_t committed_c = RunningCounters::committed_words_class(); - const int num_nodes_c = VirtualSpaceList::vslist_class()->num_nodes(); +#if INCLUDE_CLASS_SPACE + const size_t reserved_c = RunningCounters::reserved_words_class(); + const size_t committed_c = RunningCounters::committed_words_class(); + const int num_nodes_c = VirtualSpaceList::vslist_class()->num_nodes(); - out->print(" Non-class space: "); - print_scaled_words(out, reserved_nc, scale, 7); - out->print(" reserved, "); - print_scaled_words_and_percentage(out, committed_nc, reserved_nc, scale, 7); - out->print(" committed, "); - out->print(" %d nodes.", num_nodes_nc); - out->cr(); - out->print(" Class space: "); - print_scaled_words(out, reserved_c, scale, 7); - out->print(" reserved, "); - print_scaled_words_and_percentage(out, committed_c, reserved_c, scale, 7); - out->print(" committed, "); - out->print(" %d nodes.", num_nodes_c); - out->cr(); - out->print(" Both: "); - print_scaled_words(out, reserved_c + reserved_nc, scale, 7); - out->print(" reserved, "); - print_scaled_words_and_percentage(out, committed_c + committed_nc, reserved_c + reserved_nc, scale, 7); - out->print(" committed. "); - out->cr(); - } else { - print_scaled_words(out, reserved_nc, scale, 7); - out->print(" reserved, "); - print_scaled_words_and_percentage(out, committed_nc, reserved_nc, scale, 7); - out->print(" committed, "); - out->print(" %d nodes.", num_nodes_nc); - out->cr(); - } + out->print(" Non-class space: "); + print_scaled_words(out, reserved_nc, scale, 7); + out->print(" reserved, "); + print_scaled_words_and_percentage(out, committed_nc, reserved_nc, scale, 7); + out->print(" committed, "); + out->print(" %d nodes.", num_nodes_nc); + out->cr(); + out->print(" Class space: "); + print_scaled_words(out, reserved_c, scale, 7); + out->print(" reserved, "); + print_scaled_words_and_percentage(out, committed_c, reserved_c, scale, 7); + out->print(" committed, "); + out->print(" %d nodes.", num_nodes_c); + out->cr(); + out->print(" Both: "); + print_scaled_words(out, reserved_c + reserved_nc, scale, 7); + out->print(" reserved, "); + print_scaled_words_and_percentage(out, committed_c + committed_nc, reserved_c + reserved_nc, scale, 7); + out->print(" committed. "); + out->cr(); +#else + print_scaled_words(out, reserved_nc, scale, 7); + out->print(" reserved, "); + print_scaled_words_and_percentage(out, committed_nc, reserved_nc, scale, 7); + out->print(" committed, "); + out->print(" %d nodes.", num_nodes_nc); + out->cr(); +#endif // INCLUDE_CLASS_SPACE } static void print_settings(outputStream* out, size_t scale) { @@ -102,12 +102,12 @@ static void print_settings(outputStream* out, size_t scale) { print_human_readable_size(out, MaxMetaspaceSize, scale); } out->cr(); - if (Metaspace::using_class_space()) { - out->print("CompressedClassSpaceSize: "); - print_human_readable_size(out, CompressedClassSpaceSize, scale); - } else { - out->print("No class space"); - } +#if INCLUDE_CLASS_SPACE + out->print("CompressedClassSpaceSize: "); + print_human_readable_size(out, CompressedClassSpaceSize, scale); +#else + out->print("No class space"); +#endif // INCLUDE_CLASS_SPACE out->cr(); out->print("Initial GC threshold: "); print_human_readable_size(out, MetaspaceSize, scale); @@ -117,9 +117,7 @@ static void print_settings(outputStream* out, size_t scale) { out->cr(); out->print_cr("CDS: %s", (CDSConfig::is_using_archive() ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off"))); Settings::print_on(out); -#ifdef _LP64 CompressedKlassPointers::print_mode(out); -#endif } // This will print out a basic metaspace usage report but @@ -131,9 +129,7 @@ void MetaspaceReporter::print_basic_report(outputStream* out, size_t scale) { } out->cr(); out->print_cr("Usage:"); - if (Metaspace::using_class_space()) { - out->print(" Non-class: "); - } + CLASS_SPACE_ONLY(out->print(" Non-class: ");) // Note: since we want to purely rely on counters, without any locking or walking the CLDG, // for Usage stats (statistics over in-use chunks) all we can print is the @@ -144,37 +140,35 @@ void MetaspaceReporter::print_basic_report(outputStream* out, size_t scale) { print_scaled_words(out, used_nc, scale, 5); out->print(" used."); out->cr(); - if (Metaspace::using_class_space()) { - const size_t used_c = MetaspaceUtils::used_words(Metaspace::ClassType); - out->print(" Class: "); - print_scaled_words(out, used_c, scale, 5); - out->print(" used."); - out->cr(); - out->print(" Both: "); - const size_t used = used_nc + used_c; - print_scaled_words(out, used, scale, 5); - out->print(" used."); - out->cr(); - } +#if INCLUDE_CLASS_SPACE + const size_t used_c = MetaspaceUtils::used_words(Metaspace::ClassType); + out->print(" Class: "); + print_scaled_words(out, used_c, scale, 5); + out->print(" used."); + out->cr(); + out->print(" Both: "); + const size_t used = used_nc + used_c; + print_scaled_words(out, used, scale, 5); + out->print(" used."); + out->cr(); +#endif // INCLUDE_CLASS_SPACE out->cr(); out->print_cr("Virtual space:"); print_vs(out, scale); out->cr(); out->print_cr("Chunk freelists:"); - if (Metaspace::using_class_space()) { - out->print(" Non-Class: "); - } + CLASS_SPACE_ONLY(out->print(" Non-Class: ");) print_scaled_words(out, ChunkManager::chunkmanager_nonclass()->total_word_size(), scale); out->cr(); - if (Metaspace::using_class_space()) { - out->print(" Class: "); - print_scaled_words(out, ChunkManager::chunkmanager_class()->total_word_size(), scale); - out->cr(); - out->print(" Both: "); - print_scaled_words(out, ChunkManager::chunkmanager_nonclass()->total_word_size() + - ChunkManager::chunkmanager_class()->total_word_size(), scale); - out->cr(); - } +#if INCLUDE_CLASS_SPACE + out->print(" Class: "); + print_scaled_words(out, ChunkManager::chunkmanager_class()->total_word_size(), scale); + out->cr(); + out->print(" Both: "); + print_scaled_words(out, ChunkManager::chunkmanager_nonclass()->total_word_size() + + ChunkManager::chunkmanager_class()->total_word_size(), scale); + out->cr(); +#endif // INCLUDE_CLASS_SPACE out->cr(); // Print basic settings @@ -256,70 +250,70 @@ void MetaspaceReporter::print_report(outputStream* out, size_t scale, int flags) // -- Print VirtualSpaceList details. if ((flags & (int)Option::ShowVSList) > 0) { out->cr(); - out->print_cr("Virtual space list%s:", Metaspace::using_class_space() ? "s" : ""); - - if (Metaspace::using_class_space()) { - out->print_cr(" Non-Class:"); - } +#if INCLUDE_CLASS_SPACE + out->print_cr("Virtual space lists:"); + out->print_cr(" Non-Class:"); VirtualSpaceList::vslist_nonclass()->print_on(out); out->cr(); - if (Metaspace::using_class_space()) { - out->print_cr(" Class:"); - VirtualSpaceList::vslist_class()->print_on(out); - out->cr(); - } + out->print_cr(" Class:"); + VirtualSpaceList::vslist_class()->print_on(out); + out->cr(); +#else + out->print_cr("Virtual space list:"); + VirtualSpaceList::vslist_nonclass()->print_on(out); + out->cr(); +#endif // INCLUDE_CLASS_SPACE } out->cr(); //////////// Freelists (ChunkManager) section /////////////////////////// - out->cr(); - out->print_cr("Chunk freelist%s:", Metaspace::using_class_space() ? "s" : ""); - ChunkManagerStats non_class_cm_stat; ChunkManagerStats class_cm_stat; ChunkManagerStats total_cm_stat; ChunkManager::chunkmanager_nonclass()->add_to_statistics(&non_class_cm_stat); - if (Metaspace::using_class_space()) { - ChunkManager::chunkmanager_nonclass()->add_to_statistics(&non_class_cm_stat); - ChunkManager::chunkmanager_class()->add_to_statistics(&class_cm_stat); - total_cm_stat.add(non_class_cm_stat); - total_cm_stat.add(class_cm_stat); +#if INCLUDE_CLASS_SPACE + ChunkManager::chunkmanager_class()->add_to_statistics(&class_cm_stat); + total_cm_stat.add(non_class_cm_stat); + total_cm_stat.add(class_cm_stat); - out->print_cr(" Non-Class:"); - non_class_cm_stat.print_on(out, scale); - out->cr(); - out->print_cr(" Class:"); - class_cm_stat.print_on(out, scale); - out->cr(); - out->print_cr(" Both:"); - total_cm_stat.print_on(out, scale); - out->cr(); - } else { - ChunkManager::chunkmanager_nonclass()->add_to_statistics(&non_class_cm_stat); - non_class_cm_stat.print_on(out, scale); - out->cr(); - } + out->print_cr("Chunk freelists:"); + out->cr(); + out->print_cr(" Non-Class:"); + non_class_cm_stat.print_on(out, scale); + out->cr(); + out->print_cr(" Class:"); + class_cm_stat.print_on(out, scale); + out->cr(); + out->print_cr(" Both:"); + total_cm_stat.print_on(out, scale); + out->cr(); +#else + out->print_cr("Chunk freelist:"); + ChunkManager::chunkmanager_nonclass()->add_to_statistics(&non_class_cm_stat); + non_class_cm_stat.print_on(out, scale); + out->cr(); +#endif // INCLUDE_CLASS_SPACE // -- Print Chunkmanager details. if ((flags & (int)Option::ShowChunkFreeList) > 0) { out->cr(); out->print_cr("Chunk freelist details:"); - if (Metaspace::using_class_space()) { - out->print_cr(" Non-Class:"); - } +#if INCLUDE_CLASS_SPACE + out->print_cr(" Non-Class:"); ChunkManager::chunkmanager_nonclass()->print_on(out); out->cr(); - if (Metaspace::using_class_space()) { - out->print_cr(" Class:"); - ChunkManager::chunkmanager_class()->print_on(out); - out->cr(); - } + out->print_cr(" Class:"); + ChunkManager::chunkmanager_class()->print_on(out); + out->cr(); +#else + ChunkManager::chunkmanager_nonclass()->print_on(out); + out->cr(); +#endif // INCLUDE_CLASS_SPACE } out->cr(); - //////////// Waste section /////////////////////////// // As a convenience, print a summary of common waste. out->cr(); diff --git a/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp b/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp index aab46d64db5..d90e8ed090d 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -205,28 +205,26 @@ ArenaStats ClmsStats::totals() const { void ClmsStats::print_on(outputStream* st, size_t scale, bool detailed) const { StreamIndentor si(st, 2); st->cr(); - if (Metaspace::using_class_space()) { - st->print("Non-Class: "); - } + CLASS_SPACE_ONLY(st->print("Non-Class: ");) _arena_stats_nonclass.print_on(st, scale, detailed); if (detailed) { st->cr(); } - if (Metaspace::using_class_space()) { +#if INCLUDE_CLASS_SPACE + st->cr(); + st->print(" Class: "); + _arena_stats_class.print_on(st, scale, detailed); + if (detailed) { st->cr(); - st->print(" Class: "); - _arena_stats_class.print_on(st, scale, detailed); - if (detailed) { - st->cr(); - } - st->cr(); - st->print(" Both: "); - totals().print_on(st, scale, detailed); - if (detailed) { - st->cr(); - } } st->cr(); + st->print(" Both: "); + totals().print_on(st, scale, detailed); + if (detailed) { + st->cr(); + } +#endif // INCLUDE_CLASS_SPACE + st->cr(); } #ifdef ASSERT diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp index df4e507b104..a934a628582 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -259,12 +259,11 @@ VirtualSpaceNode* VirtualSpaceNode::create_node(size_t word_size, } #ifndef _LP64 - // On 32-bit, with +UseCompressedClassPointers, the whole address space is the encoding range. We therefore - // don't need a class space. However, as a pragmatic workaround for pesty overflow problems on 32-bit, we leave - // a small area at the end of the address space out of the encoding range. We just assume no Klass will ever live + // On 32-bit, the whole address space is the encoding range. We therefore don't need a class space. + // However, as a pragmatic workaround for pesty overflow problems on 32-bit, we leave a small area + // at the end of the address space out of the encoding range. We just assume no Klass will ever live // there (it won't, for no OS we support on 32-bit has user-addressable memory up there). - assert(!UseCompressedClassPointers || - rs.end() <= (char*)CompressedKlassPointers::max_klass_range_size(), "Weirdly high address"); + assert(rs.end() <= (char*)CompressedKlassPointers::max_klass_range_size(), "Weirdly high address"); #endif // _LP64 MemTracker::record_virtual_memory_tag(rs, mtMetaspace); diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index cfbab1b8afb..a78b245cc07 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -1182,13 +1182,12 @@ bool universe_post_init() { Universe::heap()->update_capacity_and_used_at_gc(); } - // ("weak") refs processing infrastructure initialization + // Initialize serviceability + MemoryService::initialize(Universe::heap()); + + // Complete initialization Universe::heap()->post_initialize(); - MemoryService::add_metaspace_memory_pools(); - - MemoryService::set_universe_heap(Universe::heap()); - #if INCLUDE_CDS AOTMetaspace::post_initialize(CHECK_false); #endif diff --git a/src/hotspot/share/nmt/memBaseline.cpp b/src/hotspot/share/nmt/memBaseline.cpp index 118e3ec64c0..65168fd4e09 100644 --- a/src/hotspot/share/nmt/memBaseline.cpp +++ b/src/hotspot/share/nmt/memBaseline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -168,12 +168,13 @@ int compare_allocation_site(const VirtualMemoryAllocationSite& s1, } bool MemBaseline::aggregate_virtual_memory_allocation_sites() { + SortedLinkedList allocation_sites; VirtualMemoryAllocationSite* site; bool failed_oom = false; - _vma_allocations->visit_reserved_regions([&](ReservedMemoryRegion& rgn) { - VirtualMemoryAllocationSite tmp(*rgn.call_stack(), rgn.mem_tag()); + _vma_allocations->visit_reserved_regions([&](VirtualMemoryRegion& rgn) { + VirtualMemoryAllocationSite tmp(*rgn.reserved_call_stack(), rgn.mem_tag()); site = allocation_sites.find(tmp); if (site == nullptr) { LinkedListNode* node = diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 9a2fe166d3d..639e06292fc 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -149,7 +149,7 @@ public: } } - bool do_allocation_site(const ReservedMemoryRegion* rgn) override { + bool do_allocation_site(const VirtualMemoryRegion* rgn) override { // Cancel iteration if we run out of memory (add returns false); return add(rgn->base(), rgn->end(), rgn->mem_tag()); } diff --git a/src/hotspot/share/nmt/memReporter.cpp b/src/hotspot/share/nmt/memReporter.cpp index 772bda2885b..429db6ad31f 100644 --- a/src/hotspot/share/nmt/memReporter.cpp +++ b/src/hotspot/share/nmt/memReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -272,9 +272,7 @@ void MemSummaryReporter::report_summary_of_tag(MemTag mem_tag, } else if (mem_tag == mtClass) { // Metadata information report_metadata(Metaspace::NonClassType); - if (Metaspace::using_class_space()) { - report_metadata(Metaspace::ClassType); - } + CLASS_SPACE_ONLY(report_metadata(Metaspace::ClassType);) } out->cr(); } @@ -395,14 +393,14 @@ int MemDetailReporter::report_virtual_memory_allocation_sites() { void MemDetailReporter::report_virtual_memory_map() { // Virtual memory map always in base address order output()->print_cr("Virtual memory map:"); - _baseline.virtual_memory_allocations()->visit_reserved_regions([&](ReservedMemoryRegion& rgn) { + _baseline.virtual_memory_allocations()->visit_reserved_regions([&](VirtualMemoryRegion& rgn) { report_virtual_memory_region(&rgn); return true; }); } -void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) { - assert(reserved_rgn != nullptr, "null pointer"); +void MemDetailReporter::report_virtual_memory_region(const VirtualMemoryRegion* rgn) { + assert(rgn != nullptr, "null pointer"); // We don't bother about reporting peaks here. // That is because peaks - in the context of virtual memory, peak of committed areas - make little sense @@ -414,16 +412,16 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* // usage *by callsite*. // Don't report if size is too small. - if (amount_in_current_scale(reserved_rgn->size()) == 0) return; + if (amount_in_current_scale(rgn->size()) == 0) return; outputStream* out = output(); const char* scale = current_scale(); - const NativeCallStack* stack = reserved_rgn->call_stack(); - bool all_committed = reserved_rgn->size() == _baseline.virtual_memory_allocations()->committed_size(*reserved_rgn); + const NativeCallStack* stack = rgn->reserved_call_stack(); + bool all_committed = rgn->size() == _baseline.virtual_memory_allocations()->committed_size(*rgn); const char* region_type = (all_committed ? "reserved and committed" : "reserved"); out->cr(); - print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); - out->print(" for %s", NMTUtil::tag_to_name(reserved_rgn->mem_tag())); + print_virtual_memory_region(region_type, rgn->base(), rgn->size()); + out->print(" for %s", NMTUtil::tag_to_name(rgn->mem_tag())); if (stack->is_empty()) { out->cr(); } else { @@ -433,9 +431,9 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* if (all_committed) { bool reserved_and_committed = false; - _baseline.virtual_memory_allocations()->visit_committed_regions(*reserved_rgn, - [&](CommittedMemoryRegion& committed_rgn) { - if (committed_rgn.equals(*reserved_rgn)) { + _baseline.virtual_memory_allocations()->visit_committed_regions(*rgn, + [&](VirtualMemoryRegion& committed_rgn) { + if (committed_rgn.equals(*rgn)) { // One region spanning the entire reserved region, with the same stack trace. // Don't print this regions because the "reserved and committed" line above // already indicates that the region is committed. @@ -450,13 +448,13 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* } } - auto print_committed_rgn = [&](const CommittedMemoryRegion& crgn) { + auto print_committed_rgn = [&](const VirtualMemoryRegion& rgn) { // Don't report if size is too small - if (amount_in_current_scale(crgn.size()) == 0) return; - stack = crgn.call_stack(); + if (amount_in_current_scale(rgn.size()) == 0) return; + stack = rgn.committed_call_stack(); out->cr(); INDENT_BY(8, - print_virtual_memory_region("committed", crgn.base(), crgn.size()); + print_virtual_memory_region("committed", rgn.base(), rgn.size()); if (stack->is_empty()) { out->cr(); } else { @@ -466,9 +464,9 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* ) }; - _baseline.virtual_memory_allocations()->visit_committed_regions(*reserved_rgn, - [&](CommittedMemoryRegion& crgn) { - print_committed_rgn(crgn); + _baseline.virtual_memory_allocations()->visit_committed_regions(*rgn, + [&](VirtualMemoryRegion& committed_rgn) { + print_committed_rgn(committed_rgn); return true; }); } @@ -754,9 +752,9 @@ void MemSummaryDiffReporter::diff_summary_of_tag(MemTag mem_tag, void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceCombinedStats& current_ms, const MetaspaceCombinedStats& early_ms) const { print_metaspace_diff("Metadata", current_ms.non_class_space_stats(), early_ms.non_class_space_stats()); - if (Metaspace::using_class_space()) { - print_metaspace_diff("Class space", current_ms.class_space_stats(), early_ms.class_space_stats()); - } +#if INCLUDE_CLASS_SPACE + print_metaspace_diff("Class space", current_ms.class_space_stats(), early_ms.class_space_stats()); +#endif } void MemSummaryDiffReporter::print_metaspace_diff(const char* header, diff --git a/src/hotspot/share/nmt/memReporter.hpp b/src/hotspot/share/nmt/memReporter.hpp index bab8de138d0..0d7e7344608 100644 --- a/src/hotspot/share/nmt/memReporter.hpp +++ b/src/hotspot/share/nmt/memReporter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -178,7 +178,7 @@ class MemDetailReporter : public MemSummaryReporter { int report_virtual_memory_allocation_sites(); // Report a virtual memory region - void report_virtual_memory_region(const ReservedMemoryRegion* rgn); + void report_virtual_memory_region(const VirtualMemoryRegion* rgn); }; /* diff --git a/src/hotspot/share/nmt/memTracker.hpp b/src/hotspot/share/nmt/memTracker.hpp index d9ebf4dc30e..6b5b6affa14 100644 --- a/src/hotspot/share/nmt/memTracker.hpp +++ b/src/hotspot/share/nmt/memTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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 @@ -140,6 +140,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { + NmtVirtualMemoryLocker nvml; VirtualMemoryTracker::Instance::remove_released_region((address)addr, size); } } diff --git a/src/hotspot/share/nmt/memoryFileTracker.cpp b/src/hotspot/share/nmt/memoryFileTracker.cpp index fe723d09364..0a458347169 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.cpp +++ b/src/hotspot/share/nmt/memoryFileTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -44,21 +44,21 @@ void MemoryFileTracker::allocate_memory(MemoryFile* file, size_t offset, VMATree::RegionData regiondata(sidx, mem_tag); VMATree::SummaryDiff diff; file->_tree.commit_mapping(offset, size, regiondata, diff); - for (int i = 0; i < mt_number_of_tags; i++) { - VirtualMemory* summary = file->_summary.by_tag(NMTUtil::index_to_tag(i)); - summary->reserve_memory(diff.tag[i].commit); - summary->commit_memory(diff.tag[i].commit); - } + diff.visit([&](MemTag mt, const VMATree::SingleDiff& single_diff) { + VirtualMemory* summary = file->_summary.by_tag(mt); + summary->reserve_memory(single_diff.commit); + summary->commit_memory(single_diff.commit); + }); } void MemoryFileTracker::free_memory(MemoryFile* file, size_t offset, size_t size) { VMATree::SummaryDiff diff; file->_tree.release_mapping(offset, size, diff); - for (int i = 0; i < mt_number_of_tags; i++) { - VirtualMemory* summary = file->_summary.by_tag(NMTUtil::index_to_tag(i)); - summary->reserve_memory(diff.tag[i].commit); - summary->commit_memory(diff.tag[i].commit); - } + diff.visit([&](MemTag mt, const VMATree::SingleDiff& single_diff) { + VirtualMemory* summary = file->_summary.by_tag(mt); + summary->reserve_memory(single_diff.commit); + summary->commit_memory(single_diff.commit); + }); } void MemoryFileTracker::print_report_on(const MemoryFile* file, outputStream* stream, size_t scale) { diff --git a/src/hotspot/share/nmt/regionsTree.cpp b/src/hotspot/share/nmt/regionsTree.cpp index 83306cbc14f..1a87d051928 100644 --- a/src/hotspot/share/nmt/regionsTree.cpp +++ b/src/hotspot/share/nmt/regionsTree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,9 +58,9 @@ void RegionsTree::print_on(outputStream* st) { } #endif -size_t RegionsTree::committed_size(const ReservedMemoryRegion& rgn) { +size_t RegionsTree::committed_size(const VirtualMemoryRegion& rgn) { size_t result = 0; - visit_committed_regions(rgn, [&](CommittedMemoryRegion& crgn) { + visit_committed_regions(rgn, [&](VirtualMemoryRegion& crgn) { result += crgn.size(); return true; }); diff --git a/src/hotspot/share/nmt/regionsTree.hpp b/src/hotspot/share/nmt/regionsTree.hpp index 2e1b37d0c1a..4b27423db8c 100644 --- a/src/hotspot/share/nmt/regionsTree.hpp +++ b/src/hotspot/share/nmt/regionsTree.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,8 +29,7 @@ #include "nmt/vmatree.hpp" -class ReservedMemoryRegion; -class CommittedMemoryRegion; +class VirtualMemoryRegion; // RegionsTree extends VMATree to add some more specific API and also defines a helper // for processing the tree nodes in a shorter and more meaningful way. class RegionsTree : public VMATree { @@ -46,7 +45,7 @@ class RegionsTree : public VMATree { _with_storage(other._with_storage) {} RegionsTree& operator=(const RegionsTree& other) = delete; - ReservedMemoryRegion find_reserved_region(address addr); + VirtualMemoryRegion find_reserved_region(address addr); void commit_region(address addr, size_t size, const NativeCallStack& stack, SummaryDiff& diff); void uncommit_region(address addr, size_t size, SummaryDiff& diff); @@ -71,6 +70,7 @@ class RegionsTree : public VMATree { return position() - other.position(); } inline NativeCallStackStorage::StackIndex out_stack_index() const { return _node->val().out.reserved_stack(); } + inline NativeCallStackStorage::StackIndex out_committed_stack_index() const { return _node->val().out.committed_stack(); } inline MemTag in_tag() const { return _node->val().in.mem_tag(); } inline MemTag out_tag() const { return _node->val().out.mem_tag(); } inline void set_in_tag(MemTag tag) { _node->val().in.set_tag(tag); } @@ -81,7 +81,7 @@ class RegionsTree : public VMATree { DEBUG_ONLY(void print_on(outputStream* st);) template - void visit_committed_regions(const ReservedMemoryRegion& rgn, F func); + void visit_committed_regions(const VirtualMemoryRegion& rgn, F func); template void visit_reserved_regions(F func); @@ -90,7 +90,7 @@ class RegionsTree : public VMATree { return RegionData(_ncs_storage.push(ncs), tag); } - inline const NativeCallStack stack(NodeHelper& node) { + inline const NativeCallStack reserved_stack(NodeHelper& node) { if (!_with_storage) { return NativeCallStack::empty_stack(); } @@ -98,7 +98,15 @@ class RegionsTree : public VMATree { return _ncs_storage.get(si); } - size_t committed_size(const ReservedMemoryRegion& rgn); + inline const NativeCallStack committed_stack(NodeHelper& node) { + if (!_with_storage) { + return NativeCallStack::empty_stack(); + } + NativeCallStackStorage::StackIndex si = node.out_committed_stack_index(); + return _ncs_storage.get(si); + } + + size_t committed_size(const VirtualMemoryRegion& rgn); }; #endif // NMT_REGIONSTREE_HPP diff --git a/src/hotspot/share/nmt/regionsTree.inline.hpp b/src/hotspot/share/nmt/regionsTree.inline.hpp index 98cfa0e7f2c..793a5c5f1fa 100644 --- a/src/hotspot/share/nmt/regionsTree.inline.hpp +++ b/src/hotspot/share/nmt/regionsTree.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +29,7 @@ #include "nmt/virtualMemoryTracker.hpp" template -void RegionsTree::visit_committed_regions(const ReservedMemoryRegion& rgn, F func) { +void RegionsTree::visit_committed_regions(const VirtualMemoryRegion& rgn, F func) { position start = (position)rgn.base(); size_t end = reinterpret_cast(rgn.end()) + 1; size_t comm_size = 0; @@ -38,8 +38,12 @@ void RegionsTree::visit_committed_regions(const ReservedMemoryRegion& rgn, F fun visit_range_in_order(start, end, [&](Node* node) { NodeHelper curr(node); if (prev.is_valid() && prev.is_committed_begin()) { - CommittedMemoryRegion cmr((address)prev.position(), curr.distance_from(prev), stack(prev)); - if (!func(cmr)) { + VirtualMemoryRegion rgn((address)prev.position(), + curr.distance_from(prev), + reserved_stack(prev), + committed_stack(prev), + prev.out_tag()); + if (!func(rgn)) { return false; } } @@ -63,13 +67,13 @@ void RegionsTree::visit_reserved_regions(F func) { } prev = curr; if (curr.is_released_begin() || begin_node.out_tag() != curr.out_tag()) { - auto st = stack(begin_node); + auto st = reserved_stack(begin_node); if (rgn_size == 0) { prev.clear_node(); return true; } - ReservedMemoryRegion rmr((address)begin_node.position(), rgn_size, st, begin_node.out_tag()); - if (!func(rmr)) { + VirtualMemoryRegion rgn((address)begin_node.position(), rgn_size, st, begin_node.out_tag()); + if (!func(rgn)) { return false; } rgn_size = 0; diff --git a/src/hotspot/share/nmt/threadStackTracker.cpp b/src/hotspot/share/nmt/threadStackTracker.cpp index 3e649d882c4..6fb17c93782 100644 --- a/src/hotspot/share/nmt/threadStackTracker.cpp +++ b/src/hotspot/share/nmt/threadStackTracker.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2019, 2024, Red Hat, Inc. All rights reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +60,6 @@ void ThreadStackTracker::delete_thread_stack(void* base, size_t size) { assert(base != nullptr, "Should have been filtered"); align_thread_stack_boundaries_inward(base, size); - MemTracker::NmtVirtualMemoryLocker nvml; MemTracker::record_virtual_memory_release((address)base, size); _thread_count--; } diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.cpp b/src/hotspot/share/nmt/virtualMemoryTracker.cpp index d676d93e040..dc68664f34f 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.cpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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 @@ -80,16 +80,17 @@ void VirtualMemoryTracker::Instance::set_reserved_region_tag(address addr, size_ } void VirtualMemoryTracker::set_reserved_region_tag(address addr, size_t size, MemTag mem_tag) { - VMATree::SummaryDiff diff = tree()->set_tag((VMATree::position) addr, size, mem_tag); - apply_summary_diff(diff); + VMATree::SummaryDiff diff; + tree()->set_tag((VMATree::position)addr, size, mem_tag, diff); + apply_summary_diff(diff); } -void VirtualMemoryTracker::Instance::apply_summary_diff(VMATree::SummaryDiff diff) { +void VirtualMemoryTracker::Instance::apply_summary_diff(VMATree::SummaryDiff& diff) { assert(_tracker != nullptr, "Sanity check"); _tracker->apply_summary_diff(diff); } -void VirtualMemoryTracker::apply_summary_diff(VMATree::SummaryDiff diff) { +void VirtualMemoryTracker::apply_summary_diff(VMATree::SummaryDiff& diff) { VMATree::SingleDiff::delta reserve_delta, commit_delta; size_t reserved, committed; MemTag tag = mtNone; @@ -104,10 +105,9 @@ void VirtualMemoryTracker::apply_summary_diff(VMATree::SummaryDiff diff) { #endif }; - for (int i = 0; i < mt_number_of_tags; i++) { - reserve_delta = diff.tag[i].reserve; - commit_delta = diff.tag[i].commit; - tag = NMTUtil::index_to_tag(i); + diff.visit([&](MemTag tag, const VMATree::SingleDiff& single_diff) { + reserve_delta = single_diff.reserve; + commit_delta = single_diff.commit; reserved = VirtualMemorySummary::as_snapshot()->by_tag(tag)->reserved(); committed = VirtualMemorySummary::as_snapshot()->by_tag(tag)->committed(); if (reserve_delta != 0) { @@ -138,7 +138,7 @@ void VirtualMemoryTracker::apply_summary_diff(VMATree::SummaryDiff diff) { } } } - } + }); } void VirtualMemoryTracker::Instance::add_committed_region(address addr, size_t size, @@ -193,14 +193,14 @@ bool VirtualMemoryTracker::Instance::print_containing_region(const void* p, outp } bool VirtualMemoryTracker::print_containing_region(const void* p, outputStream* st) { - ReservedMemoryRegion rmr = tree()->find_reserved_region((address)p); - if (!rmr.contain_address((address)p)) { + VirtualMemoryRegion rgn = tree()->find_reserved_region((address)p); + if (!rgn.is_valid() || !rgn.contain_address((address)p)) { return false; } st->print_cr(PTR_FORMAT " in mmap'd memory region [" PTR_FORMAT " - " PTR_FORMAT "], tag %s", - p2i(p), p2i(rmr.base()), p2i(rmr.end()), NMTUtil::tag_to_enum_name(rmr.mem_tag())); + p2i(p), p2i(rgn.base()), p2i(rgn.end()), NMTUtil::tag_to_enum_name(rgn.mem_tag())); if (MemTracker::tracking_level() == NMT_detail) { - rmr.call_stack()->print_on(st); + rgn.reserved_call_stack()->print_on(st); } st->cr(); return true; @@ -213,7 +213,7 @@ bool VirtualMemoryTracker::Instance::walk_virtual_memory(VirtualMemoryWalker* wa bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { bool ret = true; - tree()->visit_reserved_regions([&](ReservedMemoryRegion& rgn) { + tree()->visit_reserved_regions([&](VirtualMemoryRegion& rgn) { if (!walker->do_allocation_site(&rgn)) { ret = false; return false; @@ -223,29 +223,29 @@ bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { return ret; } -size_t VirtualMemoryTracker::committed_size(const ReservedMemoryRegion* rmr) { +size_t VirtualMemoryTracker::committed_size(const VirtualMemoryRegion* rgn) { size_t result = 0; - tree()->visit_committed_regions(*rmr, [&](CommittedMemoryRegion& crgn) { + tree()->visit_committed_regions(*rgn, [&](VirtualMemoryRegion& crgn) { result += crgn.size(); return true; }); return result; } -size_t VirtualMemoryTracker::Instance::committed_size(const ReservedMemoryRegion* rmr) { +size_t VirtualMemoryTracker::Instance::committed_size(const VirtualMemoryRegion* rgn) { assert(_tracker != nullptr, "Sanity check"); - return _tracker->committed_size(rmr); + return _tracker->committed_size(rgn); } -address VirtualMemoryTracker::Instance::thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr) { +address VirtualMemoryTracker::Instance::thread_stack_uncommitted_bottom(const VirtualMemoryRegion* rgn) { assert(_tracker != nullptr, "Sanity check"); - return _tracker->thread_stack_uncommitted_bottom(rmr); + return _tracker->thread_stack_uncommitted_bottom(rgn); } -address VirtualMemoryTracker::thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr) { - address bottom = rmr->base(); - address top = rmr->end(); - tree()->visit_committed_regions(*rmr, [&](CommittedMemoryRegion& crgn) { +address VirtualMemoryTracker::thread_stack_uncommitted_bottom(const VirtualMemoryRegion* rgn) { + address bottom = rgn->base(); + address top = rgn->end(); + tree()->visit_committed_regions(*rgn, [&](VirtualMemoryRegion& crgn) { address committed_top = crgn.base() + crgn.size(); if (committed_top < top) { // committed stack guard pages, skip them @@ -299,7 +299,7 @@ class SnapshotThreadStackWalker : public VirtualMemoryWalker { public: SnapshotThreadStackWalker() {} - bool do_allocation_site(const ReservedMemoryRegion* rgn) { + bool do_allocation_site(const VirtualMemoryRegion* rgn) { if (MemTracker::NmtVirtualMemoryLocker::is_safe_to_use()) { assert_lock_strong(NmtVirtualMemory_lock); } @@ -340,19 +340,19 @@ void VirtualMemoryTracker::Instance::snapshot_thread_stacks() { walk_virtual_memory(&walker); } -ReservedMemoryRegion RegionsTree::find_reserved_region(address addr) { - ReservedMemoryRegion rmr; - auto contain_region = [&](ReservedMemoryRegion& region_in_tree) { +VirtualMemoryRegion RegionsTree::find_reserved_region(address addr) { + VirtualMemoryRegion rgn; + auto contain_region = [&](VirtualMemoryRegion& region_in_tree) { if (region_in_tree.contain_address(addr)) { - rmr = region_in_tree; + rgn = region_in_tree; return false; } return true; }; visit_reserved_regions(contain_region); - return rmr; + return rgn; } -bool CommittedMemoryRegion::equals(const ReservedMemoryRegion& rmr) const { - return size() == rmr.size() && call_stack()->equals(*(rmr.call_stack())); +bool VirtualMemoryRegion::equals_including_stacks(const VirtualMemoryRegion& rgn) const { + return size() == rgn.size() && committed_call_stack()->equals(*(rgn.reserved_call_stack())); } diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.hpp b/src/hotspot/share/nmt/virtualMemoryTracker.hpp index c51b53194e6..f6cb18983a3 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.hpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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 @@ -194,15 +194,38 @@ class VirtualMemorySummary : AllStatic { */ class VirtualMemoryRegion { private: - address _base_address; - size_t _size; + address _base_address; + size_t _size; + MemTag _mem_tag; + NativeCallStack _reserved_stack; + NativeCallStack _committed_stack; public: + VirtualMemoryRegion() : + _base_address(nullptr), _size(0), _mem_tag(mtNone), + _reserved_stack(NativeCallStack::empty_stack()) , + _committed_stack(NativeCallStack::empty_stack()) {} + VirtualMemoryRegion(address addr, size_t size) : - _base_address(addr), _size(size) { + _base_address(addr), _size(size), _mem_tag(mtNone), + _reserved_stack(NativeCallStack::empty_stack()) , + _committed_stack(NativeCallStack::empty_stack()) { assert(addr != nullptr, "Invalid address"); assert(size > 0, "Invalid size"); - } + } + + VirtualMemoryRegion(address addr, size_t size, const NativeCallStack& reserved_stack, const NativeCallStack& committed_stack, MemTag mem_tag = mtNone) : + _base_address(addr), _size(size), _mem_tag(mem_tag), + _reserved_stack(reserved_stack), + _committed_stack(committed_stack) { + assert(addr != nullptr, "Invalid address"); + assert(size > 0, "Invalid size"); + } + + VirtualMemoryRegion(address addr, size_t size, const NativeCallStack& stack, MemTag mem_tag = mtNone) + : _base_address(addr), _size(size), _mem_tag(mem_tag), + _reserved_stack(stack), + _committed_stack(NativeCallStack::empty_stack()) {} inline address base() const { return _base_address; } inline address end() const { return base() + size(); } @@ -211,48 +234,18 @@ class VirtualMemoryRegion { inline bool is_empty() const { return size() == 0; } inline bool contain_address(address addr) const { + assert(is_valid(), "sanity"); return (addr >= base() && addr < end()); } - - inline bool contain_region(address addr, size_t size) const { - return contain_address(addr) && contain_address(addr + size - 1); - } - - inline bool same_region(address addr, size_t sz) const { - return (addr == base() && sz == size()); - } - - + private: inline bool overlap_region(address addr, size_t sz) const { assert(sz > 0, "Invalid size"); assert(size() > 0, "Invalid size"); + assert(is_valid(), "sanity"); return MAX2(addr, base()) < MIN2(addr + sz, end()); } - inline bool adjacent_to(address addr, size_t sz) const { - return (addr == end() || (addr + sz) == base()); - } - - void exclude_region(address addr, size_t sz) { - assert(contain_region(addr, sz), "Not containment"); - assert(addr == base() || addr + sz == end(), "Can not exclude from middle"); - size_t new_size = size() - sz; - - if (addr == base()) { - set_base(addr + sz); - } - set_size(new_size); - } - - void expand_region(address addr, size_t sz) { - assert(adjacent_to(addr, sz), "Not adjacent regions"); - if (base() == addr + sz) { - set_base(addr); - } - set_size(size() + sz); - } - // Returns 0 if regions overlap; 1 if this region follows rgn; // -1 if this region precedes rgn. inline int compare(const VirtualMemoryRegion& rgn) const { @@ -266,86 +259,27 @@ class VirtualMemoryRegion { } } + public: // Returns true if regions overlap, false otherwise. inline bool equals(const VirtualMemoryRegion& rgn) const { return compare(rgn) == 0; } - protected: - void set_base(address base) { - assert(base != nullptr, "Sanity check"); - _base_address = base; - } + bool equals_including_stacks(const VirtualMemoryRegion& other) const; + inline const NativeCallStack* committed_call_stack() const { return &_committed_stack; } - void set_size(size_t size) { - assert(size > 0, "Sanity check"); - _size = size; - } -}; + bool is_valid() const { return base() != nullptr && size() != 0;} + inline const NativeCallStack* reserved_call_stack() const { return &_reserved_stack; } -class CommittedMemoryRegion : public VirtualMemoryRegion { - private: - NativeCallStack _stack; - - public: - CommittedMemoryRegion() - : VirtualMemoryRegion((address)1, 1), _stack(NativeCallStack::empty_stack()) { } - - CommittedMemoryRegion(address addr, size_t size, const NativeCallStack& stack) - : VirtualMemoryRegion(addr, size), _stack(stack) { } - - inline void set_call_stack(const NativeCallStack& stack) { _stack = stack; } - inline const NativeCallStack* call_stack() const { return &_stack; } - bool equals(const ReservedMemoryRegion& other) const; -}; - -class ReservedMemoryRegion : public VirtualMemoryRegion { - private: - NativeCallStack _stack; - MemTag _mem_tag; - - public: - bool is_valid() { return base() != (address)1 && size() != 1;} - - ReservedMemoryRegion() - : VirtualMemoryRegion((address)1, 1), _stack(NativeCallStack::empty_stack()), _mem_tag(mtNone) { } - - ReservedMemoryRegion(address base, size_t size, const NativeCallStack& stack, - MemTag mem_tag = mtNone) - : VirtualMemoryRegion(base, size), _stack(stack), _mem_tag(mem_tag) { } - - - ReservedMemoryRegion(address base, size_t size) - : VirtualMemoryRegion(base, size), _stack(NativeCallStack::empty_stack()), _mem_tag(mtNone) { } - - // Copy constructor - ReservedMemoryRegion(const ReservedMemoryRegion& rr) - : VirtualMemoryRegion(rr.base(), rr.size()) { - *this = rr; - } - - inline void set_call_stack(const NativeCallStack& stack) { _stack = stack; } - inline const NativeCallStack* call_stack() const { return &_stack; } - - inline MemTag mem_tag() const { return _mem_tag; } - - ReservedMemoryRegion& operator= (const ReservedMemoryRegion& other) { - set_base(other.base()); - set_size(other.size()); - - _stack = *other.call_stack(); - _mem_tag = other.mem_tag(); - - return *this; - } + inline MemTag mem_tag() const { return _mem_tag; } const char* tag_name() const { return NMTUtil::tag_to_name(_mem_tag); } }; class VirtualMemoryWalker : public StackObj { public: - virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; } + virtual bool do_allocation_site(const VirtualMemoryRegion* rgn) { return false; } }; @@ -375,9 +309,9 @@ class VirtualMemoryTracker { // Snapshot current thread stacks void snapshot_thread_stacks(); - void apply_summary_diff(VMATree::SummaryDiff diff); - size_t committed_size(const ReservedMemoryRegion* rmr); - address thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr); + void apply_summary_diff(VMATree::SummaryDiff& diff); + size_t committed_size(const VirtualMemoryRegion* rmr); + address thread_stack_uncommitted_bottom(const VirtualMemoryRegion* rmr); RegionsTree* tree() { return &_tree; } @@ -400,10 +334,10 @@ class VirtualMemoryTracker { static bool walk_virtual_memory(VirtualMemoryWalker* walker); static bool print_containing_region(const void* p, outputStream* st); static void snapshot_thread_stacks(); - static void apply_summary_diff(VMATree::SummaryDiff diff); - static size_t committed_size(const ReservedMemoryRegion* rmr); + static void apply_summary_diff(VMATree::SummaryDiff& diff); + static size_t committed_size(const VirtualMemoryRegion* rmr); // uncommitted thread stack bottom, above guard pages if there is any. - static address thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr); + static address thread_stack_uncommitted_bottom(const VirtualMemoryRegion* rgn); static RegionsTree* tree() { return _tracker->tree(); } }; diff --git a/src/hotspot/share/nmt/vmatree.cpp b/src/hotspot/share/nmt/vmatree.cpp index df7b1ac867e..6c5ab691f6d 100644 --- a/src/hotspot/share/nmt/vmatree.cpp +++ b/src/hotspot/share/nmt/vmatree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #include "nmt/vmatree.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" +#include "utilities/powerOfTwo.hpp" // Semantics @@ -192,8 +193,8 @@ void VMATree::compute_summary_diff(const SingleDiff::delta region_size, {0,a, 0,a, -a,a }, // op == Commit {0,0, 0,0, -a,0 } // op == Uncommit }; - SingleDiff& from_rescom = diff.tag[NMTUtil::tag_to_index(current_tag)]; - SingleDiff& to_rescom = diff.tag[NMTUtil::tag_to_index(operation_tag)]; + SingleDiff& from_rescom = diff.tag(current_tag); + SingleDiff& to_rescom = diff.tag(operation_tag); int st = state_to_index(ex); from_rescom.reserve += reserve[op][st * 2 ]; to_rescom.reserve += reserve[op][st * 2 + 1]; @@ -657,7 +658,7 @@ void VMATree::print_on(outputStream* out) { } #endif -VMATree::SummaryDiff VMATree::set_tag(const position start, const size size, const MemTag tag) { +void VMATree::set_tag(const position start, const size size, const MemTag tag, SummaryDiff& diff) { auto pos = [](TNode* n) { return n->key(); }; position from = start; position end = from+size; @@ -689,14 +690,13 @@ VMATree::SummaryDiff VMATree::set_tag(const position start, const size size, con }; bool success = find_next_range(); - if (!success) return SummaryDiff(); + if (!success) return; assert(range.start != nullptr && range.end != nullptr, "must be"); end = MIN2(from + remsize, pos(range.end)); IntervalState& out = out_state(range.start); StateType type = out.type(); - SummaryDiff diff; // Ignore any released ranges, these must be mtNone and have no stack if (type != StateType::Released) { RegionData new_data = RegionData(out.reserved_stack(), tag); @@ -713,7 +713,7 @@ VMATree::SummaryDiff VMATree::set_tag(const position start, const size size, con // Using register_mapping may invalidate the already found range, so we must // use find_next_range repeatedly bool success = find_next_range(); - if (!success) return diff; + if (!success) return; assert(range.start != nullptr && range.end != nullptr, "must be"); end = MIN2(from + remsize, pos(range.end)); @@ -729,25 +729,131 @@ VMATree::SummaryDiff VMATree::set_tag(const position start, const size size, con remsize = remsize - (end - from); from = end; } - - return diff; } #ifdef ASSERT void VMATree::SummaryDiff::print_on(outputStream* out) { - for (int i = 0; i < mt_number_of_tags; i++) { - if (tag[i].reserve == 0 && tag[i].commit == 0) { - continue; - } - out->print_cr("Tag %s R: " INT64_FORMAT " C: " INT64_FORMAT, NMTUtil::tag_to_enum_name((MemTag)i), tag[i].reserve, - tag[i].commit); - } + visit([&](MemTag mt, const SingleDiff& sd) { + out->print_cr("Tag %s R: " INT64_FORMAT " C: " INT64_FORMAT, + NMTUtil::tag_to_enum_name(mt), sd.reserve, sd.commit); + }); } #endif void VMATree::clear() { _tree.remove_all(); -}; +} + bool VMATree::is_empty() { return _tree.size() == 0; -}; +} + +VMATree::SummaryDiff::KVEntry& +VMATree::SummaryDiff::hash_insert_or_get(const KVEntry& kv, bool* found) { + DEBUG_ONLY(int counter = 0); + // If the length is large (picked as 32) + // then we apply a load-factor check and rehash if it exceeds it. + // When the length is small we're OK with a full linear search for an empty space + // to avoid a grow and rehash. + constexpr float load_factor = 0.5; + constexpr int load_factor_cutoff_length = 32; + if (_length > load_factor_cutoff_length && + (float)_occupied / _length > load_factor) { + grow_and_rehash(); + } + while (true) { + DEBUG_ONLY(counter++); + assert(counter < 8, "Infinite loop?"); + int i = hash_to_bucket(kv.mem_tag); + while (i < _length && _members[i].marker == Marker::Occupied) { + if (_members[i].mem_tag == kv.mem_tag) { + // Found previous + *found = true; + return _members[i]; + } + i++; + } + *found = false; + // We didn't find it but ran out of space, grow and rehash + // Then look at again + if (i >= _length) { + assert(_length < std::numeric_limits>::max(), ""); + grow_and_rehash(); + continue; + } + // We didn't find it, but _members[i] is empty, allocate a new one + assert(_members[i].marker == Marker::Empty, "must be"); + _members[i] = kv; + _occupied++; + return _members[i]; + } +} + +void VMATree::SummaryDiff::grow_and_rehash() { + assert(is_power_of_2(_length), "must be"); + constexpr int length_limit = std::numeric_limits>::max() + 1; + assert(is_power_of_2(length_limit), "must be"); + if (_length == length_limit) { + // If we are at MemTag's maximum size, then just continue with the current size. + return; + } + + int new_len = _length * 2; + // Save old entries (can't use ResourceMark, too early) + GrowableArrayCHeap tmp(_length); + for (int i = 0; i < _length; i++) { + tmp.push(_members[i]); + } + + // Clear previous -- if applicable + if (_members != _small) { + FREE_C_HEAP_ARRAY(KVEntry, _members); + } + + _members = NEW_C_HEAP_ARRAY(KVEntry, new_len, mtNMT); + // Clear new array + memset(_members, 0, sizeof(KVEntry) * new_len); + _length = new_len; + _occupied = 0; + + for (int i = 0; i < tmp.length(); i++) { + bool _found = false; + hash_insert_or_get(tmp.at(i), &_found); + } +} + +VMATree::SingleDiff& VMATree::SummaryDiff::tag(MemTag tag) { + KVEntry kv{Marker::Occupied, tag, {}}; + bool _found = false; + KVEntry& inserted = hash_insert_or_get(kv, &_found); + return inserted.single_diff; +} + +VMATree::SingleDiff& VMATree::SummaryDiff::tag(int mt_index) { + return tag((MemTag)mt_index); +} + +void VMATree::SummaryDiff::add(const SummaryDiff& other) { + other.visit([&](MemTag mt, const SingleDiff& single_diff) { + bool found = false; + KVEntry other_kv = {Marker::Occupied, mt, single_diff}; + KVEntry& this_kv = hash_insert_or_get(other_kv, &found); + if (found) { + this_kv.single_diff.reserve += other_kv.single_diff.reserve; + this_kv.single_diff.commit += other_kv.single_diff.commit; + } + }); +} + +void VMATree::SummaryDiff::clear() { + if (_members != _small) { + FREE_C_HEAP_ARRAY(KVEntry, _members); + } + memset(_small, 0, sizeof(_small)); +} + +uint32_t VMATree::SummaryDiff::hash_to_bucket(MemTag mt) { + uint32_t hash = primitive_hash((uint32_t)mt); + assert(is_power_of_2(_length), "must be"); + return hash & ((uint32_t)_length - 1); +} diff --git a/src/hotspot/share/nmt/vmatree.hpp b/src/hotspot/share/nmt/vmatree.hpp index f7ca8f4c7e0..ae732a4b0d3 100644 --- a/src/hotspot/share/nmt/vmatree.hpp +++ b/src/hotspot/share/nmt/vmatree.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,6 +26,7 @@ #ifndef SHARE_NMT_VMATREE_HPP #define SHARE_NMT_VMATREE_HPP +#include "memory/resourceArea.hpp" #include "nmt/memTag.hpp" #include "nmt/nmtNativeCallStackStorage.hpp" #include "utilities/globalDefinitions.hpp" @@ -238,24 +239,57 @@ public: delta commit; }; - struct SummaryDiff { - SingleDiff tag[mt_number_of_tags]; - SummaryDiff() { + class SummaryDiff { + enum class Marker { Empty, Occupied }; + static_assert((int)Marker::Empty == 0, "We memset the array to 0, so this must be true"); + + struct KVEntry { + Marker marker; + MemTag mem_tag; + SingleDiff single_diff; + }; + + static constexpr const int _init_size = 4; + KVEntry _small[_init_size]; + KVEntry* _members; + int _length; + int _occupied; + KVEntry& hash_insert_or_get(const KVEntry& kv, bool* found); + void grow_and_rehash(); + uint32_t hash_to_bucket(MemTag mt); + + public: + SummaryDiff() : _small(), _members(_small), _length(_init_size), _occupied(0) { clear(); } - void clear() { - for (int i = 0; i < mt_number_of_tags; i++) { - tag[i] = SingleDiff{0, 0}; + ~SummaryDiff() { + if (_members != _small) { + FREE_C_HEAP_ARRAY(KVEntry, _members); } } - void add(SummaryDiff& other) { - for (int i = 0; i < mt_number_of_tags; i++) { - tag[i].reserve += other.tag[i].reserve; - tag[i].commit += other.tag[i].commit; + SingleDiff& tag(MemTag tag); + SingleDiff& tag(int mt_index); + + template + void visit(F f) const { + int hits = 0; + for (int i = 0; i < _length; i++) { + const KVEntry& kv = _members[i]; + if (kv.marker == Marker::Occupied) { + f(kv.mem_tag, kv.single_diff); + hits++; + } + if (hits == _occupied) { + // Early exit + return; + } } } + void add(const SummaryDiff& other); + void clear(); + #ifdef ASSERT void print_on(outputStream* out); #endif @@ -313,7 +347,7 @@ public: // partially contained within that interval and set their tag to the one provided. // This may cause merging and splitting of ranges. // Released regions are ignored. - SummaryDiff set_tag(position from, size size, MemTag tag); + void set_tag(position from, size size, MemTag tag, SummaryDiff& diff); void uncommit_mapping(position from, size size, const RegionData& metadata, SummaryDiff& diff) { register_mapping(from, from + size, StateType::Reserved, metadata, diff, true); diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp index 30a2bc5102a..8a73f58b46a 100644 --- a/src/hotspot/share/oops/arrayKlass.cpp +++ b/src/hotspot/share/oops/arrayKlass.cpp @@ -41,7 +41,7 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" -ArrayKlass::ArrayKlass() { +ArrayKlass::ArrayKlass() : _dimension() { assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } @@ -88,9 +88,9 @@ Method* ArrayKlass::uncached_lookup_method(const Symbol* name, return super()->uncached_lookup_method(name, signature, OverpassLookupMode::skip, private_mode); } -ArrayKlass::ArrayKlass(Symbol* name, KlassKind kind) : +ArrayKlass::ArrayKlass(int n, Symbol* name, KlassKind kind) : Klass(kind), - _dimension(1), + _dimension(n), _higher_dimension(nullptr), _lower_dimension(nullptr) { // Arrays don't add any new methods, so their vtable is the same size as diff --git a/src/hotspot/share/oops/arrayKlass.hpp b/src/hotspot/share/oops/arrayKlass.hpp index b9b100f18a8..738387c57b4 100644 --- a/src/hotspot/share/oops/arrayKlass.hpp +++ b/src/hotspot/share/oops/arrayKlass.hpp @@ -38,7 +38,7 @@ class ArrayKlass: public Klass { private: // If you add a new field that points to any metaspace object, you // must add this field to ArrayKlass::metaspace_pointers_do(). - int _dimension; // This is n'th-dimensional array. + const int _dimension; // This is n'th-dimensional array. ObjArrayKlass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present). ArrayKlass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present). @@ -46,7 +46,7 @@ class ArrayKlass: public Klass { // Constructors // The constructor with the Symbol argument does the real array // initialization, the other is a dummy - ArrayKlass(Symbol* name, KlassKind kind); + ArrayKlass(int n, Symbol* name, KlassKind kind); ArrayKlass(); public: @@ -63,7 +63,6 @@ class ArrayKlass: public Klass { // Instance variables int dimension() const { return _dimension; } - void set_dimension(int dimension) { _dimension = dimension; } ObjArrayKlass* higher_dimension() const { return _higher_dimension; } inline ObjArrayKlass* higher_dimension_acquire() const; // load with acquire semantics diff --git a/src/hotspot/share/oops/arrayOop.hpp b/src/hotspot/share/oops/arrayOop.hpp index f0c476a2486..836a1b9250d 100644 --- a/src/hotspot/share/oops/arrayOop.hpp +++ b/src/hotspot/share/oops/arrayOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -80,8 +80,7 @@ private: // The _length field is not declared in C++. It is allocated after the // mark-word when using compact headers (+UseCompactObjectHeaders), otherwise - // after the compressed Klass* when running with compressed class-pointers - // (+UseCompressedClassPointers), or else after the full Klass*. + // after the compressed Klass*. static int length_offset_in_bytes() { return oopDesc::base_offset_in_bytes(); } diff --git a/src/hotspot/share/oops/bsmAttribute.hpp b/src/hotspot/share/oops/bsmAttribute.hpp index a28d2757fb0..32bc58b5b07 100644 --- a/src/hotspot/share/oops/bsmAttribute.hpp +++ b/src/hotspot/share/oops/bsmAttribute.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,18 +61,18 @@ public: _argv_offset = 2 }; - int bootstrap_method_index() const { + u2 bootstrap_method_index() const { return _bootstrap_method_index; } - int argument_count() const { + u2 argument_count() const { return _argument_count; } - int argument(int n) const { - assert(checked_cast(n) < _argument_count, "oob"); + u2 argument(u2 n) const { + assert(n < _argument_count, "oob"); return argument_indexes()[n]; } - void set_argument(int index, u2 value) { + void set_argument(u2 index, u2 value) { assert(index >= 0 && index < argument_count(), "invariant"); argument_indexes()[index] = value; } diff --git a/src/hotspot/share/oops/bsmAttribute.inline.hpp b/src/hotspot/share/oops/bsmAttribute.inline.hpp index e678c280c26..8e048704e08 100644 --- a/src/hotspot/share/oops/bsmAttribute.inline.hpp +++ b/src/hotspot/share/oops/bsmAttribute.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 @@ inline BSMAttributeEntry* BSMAttributeEntries::InsertionIterator::reserve_new_en inline void BSMAttributeEntry::copy_args_into(BSMAttributeEntry* entry) const { assert(entry->argument_count() == this->argument_count(), "must be same"); - for (int i = 0; i < argument_count(); i++) { + for (u2 i = 0; i < argument_count(); i++) { entry->set_argument(i, this->argument(i)); } } diff --git a/src/hotspot/share/oops/compressedKlass.cpp b/src/hotspot/share/oops/compressedKlass.cpp index b32d10c74d2..ca1c46d4095 100644 --- a/src/hotspot/share/oops/compressedKlass.cpp +++ b/src/hotspot/share/oops/compressedKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -95,7 +95,7 @@ void CompressedKlassPointers::sanity_check_after_initialization() { // We should need a class space if address space is larger than what narrowKlass can address const bool should_need_class_space = (BytesPerWord * BitsPerByte) > narrow_klass_pointer_bits(); - ASSERT_HERE(should_need_class_space == needs_class_space()); + ASSERT_HERE(should_need_class_space == (INCLUDE_CLASS_SPACE ? true : false)); const size_t klass_align = klass_alignment_in_bytes(); @@ -318,24 +318,19 @@ void CompressedKlassPointers::initialize(address addr, size_t len) { } void CompressedKlassPointers::print_mode(outputStream* st) { - st->print_cr("UseCompressedClassPointers %d, UseCompactObjectHeaders %d", - UseCompressedClassPointers, UseCompactObjectHeaders); - if (UseCompressedClassPointers) { - st->print_cr("Narrow klass pointer bits %d, Max shift %d", - _narrow_klass_pointer_bits, _max_shift); - st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d", - p2i(base()), shift()); - st->print_cr("Encoding Range: " RANGE2FMT, RANGE2FMTARGS(_base, encoding_range_end())); - st->print_cr("Klass Range: " RANGE2FMT, RANGE2FMTARGS(_klass_range_start, _klass_range_end)); - st->print_cr("Klass ID Range: [%u - %u) (%u)", _lowest_valid_narrow_klass_id, _highest_valid_narrow_klass_id + 1, - _highest_valid_narrow_klass_id + 1 - _lowest_valid_narrow_klass_id); - if (_protection_zone_size > 0) { - st->print_cr("Protection zone: " RANGEFMT, RANGEFMTARGS(_base, _protection_zone_size)); - } else { - st->print_cr("No protection zone."); - } + st->print_cr("UseCompactObjectHeaders %d", UseCompactObjectHeaders); + st->print_cr("Narrow klass pointer bits %d, Max shift %d", + _narrow_klass_pointer_bits, _max_shift); + st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d", + p2i(base()), shift()); + st->print_cr("Encoding Range: " RANGE2FMT, RANGE2FMTARGS(_base, encoding_range_end())); + st->print_cr("Klass Range: " RANGE2FMT, RANGE2FMTARGS(_klass_range_start, _klass_range_end)); + st->print_cr("Klass ID Range: [%u - %u) (%u)", _lowest_valid_narrow_klass_id, _highest_valid_narrow_klass_id + 1, + _highest_valid_narrow_klass_id + 1 - _lowest_valid_narrow_klass_id); + if (_protection_zone_size > 0) { + st->print_cr("Protection zone: " RANGEFMT, RANGEFMTARGS(_base, _protection_zone_size)); } else { - st->print_cr("UseCompressedClassPointers off"); + st->print_cr("No protection zone."); } } diff --git a/src/hotspot/share/oops/compressedKlass.hpp b/src/hotspot/share/oops/compressedKlass.hpp index 64b9fcf9c82..fe1ce9e07ae 100644 --- a/src/hotspot/share/oops/compressedKlass.hpp +++ b/src/hotspot/share/oops/compressedKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -98,7 +98,6 @@ class Klass; // If compressed klass pointers then use narrowKlass. typedef juint narrowKlass; -// For UseCompressedClassPointers. class CompressedKlassPointers : public AllStatic { friend class VMStructs; friend class ArchiveBuilder; @@ -161,7 +160,6 @@ public: // Initialization sequence: // 1) Parse arguments. The following arguments take a role: - // - UseCompressedClassPointers // - UseCompactObjectHeaders // - Xshare on off dump // - CompressedClassSpaceSize @@ -192,12 +190,6 @@ public: // resulting from the current encoding settings (base, shift), capped to a certain max. value. static size_t max_klass_range_size(); - // On 64-bit, we need the class space to confine Klass structures to the encoding range, which is determined - // by bit size of narrowKlass IDs and the shift. On 32-bit, we support compressed class pointer only - // "pro-forma": narrowKlass have the same size as addresses (32 bits), and therefore the encoding range is - // equal to the address space size. Here, we don't need a class space. - static constexpr bool needs_class_space() { return LP64_ONLY(true) NOT_LP64(false); } - // Reserve a range of memory that is to contain Klass strucutures which are referenced by narrow Klass IDs. // If optimize_for_zero_base is true, the implementation will attempt to reserve optimized for zero-based encoding. static char* reserve_address_space_for_compressed_classes(size_t size, bool aslr, bool optimize_for_zero_base); @@ -231,7 +223,7 @@ public: // Returns the alignment a Klass* is guaranteed to have. // Note: *Not* the same as 1 << shift ! Klass are always guaranteed to be at least 64-bit aligned, // so this will return 8 even if shift is 0. - static int klass_alignment_in_bytes() { return nth_bit(MAX2(3, _shift)); } + static int klass_alignment_in_bytes() { return static_cast(nth_bit(MAX2(3, _shift))); } static int klass_alignment_in_words() { return klass_alignment_in_bytes() / BytesPerWord; } // Returns the highest possible narrowKlass value given the current Klass range diff --git a/src/hotspot/share/oops/compressedKlass.inline.hpp b/src/hotspot/share/oops/compressedKlass.inline.hpp index 65732b3b289..834264286bc 100644 --- a/src/hotspot/share/oops/compressedKlass.inline.hpp +++ b/src/hotspot/share/oops/compressedKlass.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +75,6 @@ inline narrowKlass CompressedKlassPointers::encode(const Klass* v) { #ifdef ASSERT inline void CompressedKlassPointers::check_encodable(const void* addr) { - assert(UseCompressedClassPointers, "Only call for +UseCCP"); assert(addr != nullptr, "Null Klass?"); assert(is_encodable(addr), "Address " PTR_FORMAT " is not encodable (Klass range: " RANGEFMT ", klass alignment: %d)", @@ -84,7 +83,6 @@ inline void CompressedKlassPointers::check_encodable(const void* addr) { inline void CompressedKlassPointers::check_valid_narrow_klass_id(narrowKlass nk) { check_init(_base); - assert(UseCompressedClassPointers, "Only call for +UseCCP"); assert(nk > 0, "narrow Klass ID is 0"); const uint64_t nk_mask = ~right_n_bits(narrow_klass_pointer_bits()); assert(((uint64_t)nk & nk_mask) == 0, "narrow klass id bit spillover (%u)", nk); diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 640b2f2460f..456333efad0 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -310,8 +310,9 @@ void ConstantPool::iterate_archivable_resolved_references(Function function) { if (method_entries != nullptr) { for (int i = 0; i < method_entries->length(); i++) { ResolvedMethodEntry* rme = method_entries->adr_at(i); + const char* rejection_reason = nullptr; if (rme->is_resolved(Bytecodes::_invokehandle) && rme->has_appendix() && - cache()->can_archive_resolved_method(this, rme)) { + cache()->can_archive_resolved_method(this, rme, rejection_reason)) { int rr_index = rme->resolved_references_index(); assert(resolved_reference_at(rr_index) != nullptr, "must exist"); function(rr_index); diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index 6c519945f4d..b4cff2bbbe6 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -554,8 +554,8 @@ class ConstantPool : public Metadata { u2 bootstrap_argument_index_at(int cp_index, int j) { int bsmai = bootstrap_methods_attribute_index(cp_index); BSMAttributeEntry* bsme = bsm_attribute_entry(bsmai); - assert((uint)j < (uint)bsme->argument_count(), "oob"); - return bsm_attribute_entry(bsmai)->argument(j); + assert(j < bsme->argument_count(), "oob"); + return bsm_attribute_entry(bsmai)->argument(checked_cast(j)); } // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve, diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp index 75cdcb5310a..edb5f6714c0 100644 --- a/src/hotspot/share/oops/cpCache.cpp +++ b/src/hotspot/share/oops/cpCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -450,12 +450,15 @@ void ConstantPoolCache::remove_resolved_field_entries_if_non_deterministic() { Symbol* klass_name = cp->klass_name_at(klass_cp_index); Symbol* name = cp->uncached_name_ref_at(cp_index); Symbol* signature = cp->uncached_signature_ref_at(cp_index); - log.print("%s field CP entry [%3d]: %s => %s.%s:%s%s", - (archived ? "archived" : "reverted"), - cp_index, - cp->pool_holder()->name()->as_C_string(), - klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(), - rfi->is_resolved(Bytecodes::_getstatic) || rfi->is_resolved(Bytecodes::_putstatic) ? " *** static" : ""); + if (resolved) { + log.print("%s field CP entry [%3d]: %s => %s.%s:%s%s%s", + (archived ? "archived" : "reverted"), + cp_index, + cp->pool_holder()->name()->as_C_string(), + klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(), + rfi->is_resolved(Bytecodes::_getstatic) || rfi->is_resolved(Bytecodes::_putstatic) ? " *** static" : "", + (archived ? "" : " (resolution is not deterministic)")); + } } ArchiveBuilder::alloc_stats()->record_field_cp_entry(archived, resolved && !archived); } @@ -474,32 +477,40 @@ void ConstantPoolCache::remove_resolved_method_entries_if_non_deterministic() { rme->is_resolved(Bytecodes::_invokehandle) || (rme->is_resolved(Bytecodes::_invokestatic) && VM_Version::supports_fast_class_init_checks()); + const char* rejection_reason = nullptr; if (resolved && !CDSConfig::is_dumping_preimage_static_archive() - && can_archive_resolved_method(src_cp, rme)) { + && can_archive_resolved_method(src_cp, rme, rejection_reason)) { rme->mark_and_relocate(src_cp); archived = true; } else { rme->remove_unshareable_info(); } - LogStreamHandle(Trace, aot, resolve) log; - if (log.is_enabled()) { + LogTarget(Trace, aot, resolve) lt; + if (lt.is_enabled()) { ResourceMark rm; int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index); Symbol* klass_name = cp->klass_name_at(klass_cp_index); Symbol* name = cp->uncached_name_ref_at(cp_index); Symbol* signature = cp->uncached_signature_ref_at(cp_index); - log.print("%s%s method CP entry [%3d]: %s %s.%s:%s", + LogStream ls(lt); + if (resolved) { + ls.print("%s%s method CP entry [%3d]: %s %s.%s:%s", (archived ? "archived" : "reverted"), (rme->is_resolved(Bytecodes::_invokeinterface) ? " interface" : ""), cp_index, cp->pool_holder()->name()->as_C_string(), klass_name->as_C_string(), name->as_C_string(), signature->as_C_string()); + if (rejection_reason != nullptr) { + ls.print(" %s", rejection_reason); + } + } if (archived) { Klass* resolved_klass = cp->resolved_klass_at(klass_cp_index); - log.print(" => %s%s", + ls.print(" => %s%s", resolved_klass->name()->as_C_string(), (rme->is_resolved(Bytecodes::_invokestatic) ? " *** static" : "")); } + ls.cr(); } ArchiveBuilder::alloc_stats()->record_method_cp_entry(archived, resolved && !archived); } @@ -528,50 +539,75 @@ void ConstantPoolCache::remove_resolved_indy_entries_if_non_deterministic() { Symbol* bsm_name = cp->uncached_name_ref_at(bsm_ref); Symbol* bsm_signature = cp->uncached_signature_ref_at(bsm_ref); Symbol* bsm_klass = cp->klass_name_at(cp->uncached_klass_ref_index_at(bsm_ref)); - log.print("%s indy CP entry [%3d]: %s (%d)", - (archived ? "archived" : "reverted"), - cp_index, cp->pool_holder()->name()->as_C_string(), i); - log.print(" %s %s.%s:%s", (archived ? "=>" : " "), bsm_klass->as_C_string(), - bsm_name->as_C_string(), bsm_signature->as_C_string()); + if (resolved) { + log.print("%s indy CP entry [%3d]: %s (%d)", + (archived ? "archived" : "reverted"), + cp_index, cp->pool_holder()->name()->as_C_string(), i); + log.print(" %s %s.%s:%s%s", (archived ? "=>" : " "), bsm_klass->as_C_string(), + bsm_name->as_C_string(), bsm_signature->as_C_string(), + (archived ? "" : " (resolution is not deterministic)")); + } } ArchiveBuilder::alloc_stats()->record_indy_cp_entry(archived, resolved && !archived); } } -bool ConstantPoolCache::can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry) { - LogStreamHandle(Trace, aot, resolve) log; +bool ConstantPoolCache::can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry, const char*& rejection_reason) { InstanceKlass* pool_holder = constant_pool()->pool_holder(); if (pool_holder->defined_by_other_loaders()) { // Archiving resolved cp entries for classes from non-builtin loaders // is not yet supported. + rejection_reason = "(pool holder comes from a non-builtin loader)"; return false; } if (CDSConfig::is_dumping_dynamic_archive()) { // InstanceKlass::methods() has been resorted. We need to // update the vtable_index in method_entry (not implemented) + rejection_reason = "(InstanceKlass::methods() has been resorted)"; return false; } + int cp_index = method_entry->constant_pool_index(); + if (!method_entry->is_resolved(Bytecodes::_invokevirtual)) { if (method_entry->method() == nullptr) { + rejection_reason = "(method entry is not resolved)"; return false; } if (method_entry->method()->is_continuation_native_intrinsic()) { + rejection_reason = "(corresponding stub is generated on demand during method resolution)"; return false; // FIXME: corresponding stub is generated on demand during method resolution (see LinkResolver::resolve_static_call). } - if (method_entry->is_resolved(Bytecodes::_invokehandle) && !CDSConfig::is_dumping_method_handles()) { - return false; + if (method_entry->is_resolved(Bytecodes::_invokehandle)) { + if (!CDSConfig::is_dumping_method_handles()) { + rejection_reason = "(not dumping method handles)"; + return false; + } + + Symbol* sig = constant_pool()->uncached_signature_ref_at(cp_index); + Klass* k; + if (!AOTConstantPoolResolver::check_methodtype_signature(constant_pool(), sig, &k, true)) { + // invokehandles that were resolved in the training run should have been filtered in + // AOTConstantPoolResolver::maybe_resolve_fmi_ref so we shouldn't come to here. + // + // If we come here it's because the AOT assembly phase has executed an invokehandle + // that uses an excluded type like jdk.jfr.Event. This should not happen because the + // AOT assembly phase should execute only a very limited set of Java code. + ResourceMark rm; + fatal("AOT assembly phase must not resolve any invokehandles whose signatures include an excluded type"); + } } if (method_entry->method()->is_method_handle_intrinsic() && !CDSConfig::is_dumping_method_handles()) { + rejection_reason = "(not dumping intrinsic method handles)"; return false; } } - int cp_index = method_entry->constant_pool_index(); assert(src_cp->tag_at(cp_index).is_method() || src_cp->tag_at(cp_index).is_interface_method(), "sanity"); if (!AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) { + rejection_reason = "(resolution is not deterministic)"; return false; } return true; diff --git a/src/hotspot/share/oops/cpCache.hpp b/src/hotspot/share/oops/cpCache.hpp index e9e4f9a40e5..f698f50d3a8 100644 --- a/src/hotspot/share/oops/cpCache.hpp +++ b/src/hotspot/share/oops/cpCache.hpp @@ -196,7 +196,7 @@ class ConstantPoolCache: public MetaspaceObj { #endif public: - static int size() { return align_metadata_size(sizeof(ConstantPoolCache) / wordSize); } + static int size() { return align_metadata_size(sizeof_auto(ConstantPoolCache) / wordSize); } private: // Helpers @@ -226,7 +226,7 @@ class ConstantPoolCache: public MetaspaceObj { void remove_resolved_field_entries_if_non_deterministic(); void remove_resolved_indy_entries_if_non_deterministic(); void remove_resolved_method_entries_if_non_deterministic(); - bool can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry); + bool can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry, const char*& rejection_reason); #endif // RedefineClasses support diff --git a/src/hotspot/share/oops/fieldInfo.hpp b/src/hotspot/share/oops/fieldInfo.hpp index b6d9c4d34e5..88c982e9d1f 100644 --- a/src/hotspot/share/oops/fieldInfo.hpp +++ b/src/hotspot/share/oops/fieldInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -302,7 +302,7 @@ class FieldStatus { // boilerplate: u1 _flags; - static constexpr u1 flag_mask(FieldStatusBitPosition pos) { return (u1)1 << (int)pos; } + static constexpr u1 flag_mask(FieldStatusBitPosition pos) { return checked_cast(1 << pos); } bool test_flag(FieldStatusBitPosition pos) { return (_flags & flag_mask(pos)) != 0; } // this performs an atomic update on a live status byte! void update_flag(FieldStatusBitPosition pos, bool z); diff --git a/src/hotspot/share/oops/generateOopMap.cpp b/src/hotspot/share/oops/generateOopMap.cpp index 97d8bf3d526..09912aeaf63 100644 --- a/src/hotspot/share/oops/generateOopMap.cpp +++ b/src/hotspot/share/oops/generateOopMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -391,7 +391,6 @@ void CellTypeState::print(outputStream *os) { // void GenerateOopMap::initialize_bb() { - _gc_points = 0; _bb_count = 0; _bb_hdr_bits.reinitialize(method()->code_size()); } @@ -401,15 +400,13 @@ void GenerateOopMap::bb_mark_fct(GenerateOopMap *c, int bci, int *data) { if (c->is_bb_header(bci)) return; - if (TraceNewOopMapGeneration) { - tty->print_cr("Basicblock#%d begins at: %d", c->_bb_count, bci); - } + log_debug(generateoopmap)( "Basicblock#%d begins at: %d", c->_bb_count, bci); c->set_bbmark_bit(bci); c->_bb_count++; } -void GenerateOopMap::mark_bbheaders_and_count_gc_points() { +void GenerateOopMap::mark_bbheaders() { initialize_bb(); bool fellThrough = false; // False to get first BB marked. @@ -445,9 +442,6 @@ void GenerateOopMap::mark_bbheaders_and_count_gc_points() { default: break; } - - if (possible_gc_point(&bcs)) - _gc_points++; } } @@ -917,13 +911,12 @@ void GenerateOopMap::do_interpretation() // iterated more than once. int i = 0; do { -#ifndef PRODUCT - if (TraceNewOopMapGeneration) { - tty->print("\n\nIteration #%d of do_interpretation loop, method:\n", i); - method()->print_name(tty); - tty->print("\n\n"); + if (log_is_enabled(Trace, generateoopmap)) { + LogStream st(Log(generateoopmap)::trace()); + st.print("Iteration #%d of do_interpretation loop, method:", i); + method()->print_name(&st); + st.print("\n\n"); } -#endif _conflict = false; _monitor_safe = true; // init_state is now called from init_basic_blocks. The length of a @@ -1088,8 +1081,7 @@ void GenerateOopMap::initialize_vars() { void GenerateOopMap::add_to_ref_init_set(int localNo) { - if (TraceNewOopMapGeneration) - tty->print_cr("Added init vars: %d", localNo); + log_debug(generateoopmap)("Added init vars: %d", localNo); // Is it already in the set? if (_init_vars->contains(localNo) ) @@ -1288,13 +1280,13 @@ void GenerateOopMap::report_monitor_mismatch(const char *msg) { void GenerateOopMap::print_states(outputStream *os, CellTypeState* vec, int num) { for (int i = 0; i < num; i++) { - vec[i].print(tty); + vec[i].print(os); } } // Print the state values at the current bytecode. -void GenerateOopMap::print_current_state(outputStream *os, - BytecodeStream *currentBC, +void GenerateOopMap::print_current_state(outputStream* os, + BytecodeStream* currentBC, bool detailed) { if (detailed) { os->print(" %4d vars = ", currentBC->bci()); @@ -1316,6 +1308,7 @@ void GenerateOopMap::print_current_state(outputStream *os, case Bytecodes::_invokestatic: case Bytecodes::_invokedynamic: case Bytecodes::_invokeinterface: { + ResourceMark rm; int idx = currentBC->has_index_u4() ? currentBC->get_index_u4() : currentBC->get_index_u2(); ConstantPool* cp = method()->constants(); int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx, currentBC->code()); @@ -1346,8 +1339,9 @@ void GenerateOopMap::print_current_state(outputStream *os, // Sets the current state to be the state after executing the // current instruction, starting in the current state. void GenerateOopMap::interp1(BytecodeStream *itr) { - if (TraceNewOopMapGeneration) { - print_current_state(tty, itr, TraceNewOopMapGenerationDetailed); + if (log_is_enabled(Trace, generateoopmap)) { + LogStream st(Log(generateoopmap)::trace()); + print_current_state(&st, itr, Verbose); } // Should we report the results? Result is reported *before* the instruction at the current bci is executed. @@ -2030,9 +2024,7 @@ void GenerateOopMap::ret_jump_targets_do(BytecodeStream *bcs, jmpFct_t jmpFct, i DEBUG_ONLY(BasicBlock* target_bb = &jsr_bb[1];) assert(target_bb == get_basic_block_at(target_bci), "wrong calc. of successor basicblock"); bool alive = jsr_bb->is_alive(); - if (TraceNewOopMapGeneration) { - tty->print("pc = %d, ret -> %d alive: %s\n", bci, target_bci, alive ? "true" : "false"); - } + log_debug(generateoopmap)("pc = %d, ret -> %d alive: %s", bci, target_bci, alive ? "true" : "false"); if (alive) jmpFct(this, target_bci, data); } } @@ -2050,6 +2042,7 @@ char* GenerateOopMap::state_vec_to_string(CellTypeState* vec, int len) { return _state_vec_buf; } +#ifndef PRODUCT void GenerateOopMap::print_time() { tty->print_cr ("Accumulated oopmap times:"); tty->print_cr ("---------------------------"); @@ -2057,6 +2050,7 @@ void GenerateOopMap::print_time() { tty->print_cr (" (%3.0f bytecodes per sec) ", (double)GenerateOopMap::_total_byte_count / GenerateOopMap::_total_oopmap_time.seconds()); } +#endif // // ============ Main Entry Point =========== @@ -2066,27 +2060,16 @@ GenerateOopMap::GenerateOopMap(const methodHandle& method) { _method = method; _max_locals=0; _init_vars = nullptr; - -#ifndef PRODUCT - // If we are doing a detailed trace, include the regular trace information. - if (TraceNewOopMapGenerationDetailed) { - TraceNewOopMapGeneration = true; - } -#endif } bool GenerateOopMap::compute_map(Thread* current) { #ifndef PRODUCT - if (TimeOopMap2) { - method()->print_short_name(tty); - tty->print(" "); - } if (TimeOopMap) { _total_byte_count += method()->code_size(); + TraceTime t_all(nullptr, &_total_oopmap_time, TimeOopMap); } #endif - TraceTime t_single("oopmap time", TimeOopMap2); - TraceTime t_all(nullptr, &_total_oopmap_time, TimeOopMap); + TraceTime t_single("oopmap time", TRACETIME_LOG(Debug, generateoopmap)); // Initialize values _got_error = false; @@ -2103,24 +2086,22 @@ bool GenerateOopMap::compute_map(Thread* current) { _did_rewriting = false; _did_relocation = false; - if (TraceNewOopMapGeneration) { - tty->print("Method name: %s\n", method()->name()->as_C_string()); - if (Verbose) { - _method->print_codes(); - tty->print_cr("Exception table:"); - ExceptionTable excps(method()); - for(int i = 0; i < excps.length(); i ++) { - tty->print_cr("[%d - %d] -> %d", - excps.start_pc(i), excps.end_pc(i), excps.handler_pc(i)); - } + if (log_is_enabled(Debug, generateoopmap)) { + ResourceMark rm; + LogStream st(Log(generateoopmap)::debug()); + st.print_cr("Method name: %s\n", method()->name()->as_C_string()); + _method->print_codes_on(&st); + st.print_cr("Exception table:"); + ExceptionTable excps(method()); + for (int i = 0; i < excps.length(); i ++) { + st.print_cr("[%d - %d] -> %d", + excps.start_pc(i), excps.end_pc(i), excps.handler_pc(i)); } } // if no code - do nothing // compiler needs info if (method()->code_size() == 0 || _max_locals + method()->max_stack() == 0) { - fill_stackmap_prolog(0); - fill_stackmap_epilog(); return true; } // Step 1: Compute all jump targets and their return value @@ -2129,7 +2110,7 @@ bool GenerateOopMap::compute_map(Thread* current) { // Step 2: Find all basic blocks and count GC points if (!_got_error) - mark_bbheaders_and_count_gc_points(); + mark_bbheaders(); // Step 3: Calculate stack maps if (!_got_error) @@ -2181,14 +2162,11 @@ void GenerateOopMap::verify_error(const char *format, ...) { // void GenerateOopMap::report_result() { - if (TraceNewOopMapGeneration) tty->print_cr("Report result pass"); + log_debug(generateoopmap)("Report result pass"); // We now want to report the result of the parse _report_result = true; - // Prolog code - fill_stackmap_prolog(_gc_points); - // Mark everything changed, then do one interpretation pass. for (int i = 0; i<_bb_count; i++) { if (_basic_blocks[i].is_reachable()) { @@ -2197,19 +2175,11 @@ void GenerateOopMap::report_result() { } } - // Note: Since we are skipping dead-code when we are reporting results, then - // the no. of encountered gc-points might be fewer than the previously number - // we have counted. (dead-code is a pain - it should be removed before we get here) - fill_stackmap_epilog(); - - // Report initvars - fill_init_vars(_init_vars); - _report_result = false; } void GenerateOopMap::result_for_basicblock(int bci) { - if (TraceNewOopMapGeneration) tty->print_cr("Report result pass for basicblock"); + log_debug(generateoopmap)("Report result pass for basicblock"); // We now want to report the result of the parse _report_result = true; @@ -2217,7 +2187,7 @@ void GenerateOopMap::result_for_basicblock(int bci) { // Find basicblock and report results BasicBlock* bb = get_basic_block_containing(bci); guarantee(bb != nullptr, "no basic block for bci"); - assert(bb->is_reachable(), "getting result from unreachable basicblock"); + assert(bb->is_reachable(), "getting result from unreachable basicblock %d", bci); bb->set_changed(true); interp_bb(bb); } @@ -2229,9 +2199,7 @@ void GenerateOopMap::result_for_basicblock(int bci) { void GenerateOopMap::record_refval_conflict(int varNo) { assert(varNo>=0 && varNo< _max_locals, "index out of range"); - if (TraceOopMapRewrites) { - tty->print("### Conflict detected (local no: %d)\n", varNo); - } + log_trace(generateoopmap)("### Conflict detected (local no: %d)", varNo); if (!_new_var_map) { _new_var_map = NEW_RESOURCE_ARRAY(int, _max_locals); @@ -2270,10 +2238,12 @@ void GenerateOopMap::rewrite_refval_conflicts() // Tracing flag _did_rewriting = true; - if (TraceOopMapRewrites) { - tty->print_cr("ref/value conflict for method %s - bytecodes are getting rewritten", method()->name()->as_C_string()); - method()->print(); - method()->print_codes(); + if (log_is_enabled(Trace, generateoopmap)) { + ResourceMark rm; + LogStream st(Log(generateoopmap)::trace()); + st.print_cr("ref/value conflict for method %s - bytecodes are getting rewritten", method()->name()->as_C_string()); + method()->print_on(&st); + method()->print_codes_on(&st); } assert(_new_var_map!=nullptr, "nothing to rewrite"); @@ -2283,9 +2253,7 @@ void GenerateOopMap::rewrite_refval_conflicts() if (!_got_error) { for (int k = 0; k < _max_locals && !_got_error; k++) { if (_new_var_map[k] != k) { - if (TraceOopMapRewrites) { - tty->print_cr("Rewriting: %d -> %d", k, _new_var_map[k]); - } + log_trace(generateoopmap)("Rewriting: %d -> %d", k, _new_var_map[k]); rewrite_refval_conflict(k, _new_var_map[k]); if (_got_error) return; nof_conflicts++; @@ -2336,22 +2304,16 @@ bool GenerateOopMap::rewrite_refval_conflict_inst(BytecodeStream *itr, int from, int bci = itr->bci(); if (is_aload(itr, &index) && index == from) { - if (TraceOopMapRewrites) { - tty->print_cr("Rewriting aload at bci: %d", bci); - } + log_trace(generateoopmap)("Rewriting aload at bci: %d", bci); return rewrite_load_or_store(itr, Bytecodes::_aload, Bytecodes::_aload_0, to); } if (is_astore(itr, &index) && index == from) { if (!stack_top_holds_ret_addr(bci)) { - if (TraceOopMapRewrites) { - tty->print_cr("Rewriting astore at bci: %d", bci); - } + log_trace(generateoopmap)("Rewriting astore at bci: %d", bci); return rewrite_load_or_store(itr, Bytecodes::_astore, Bytecodes::_astore_0, to); } else { - if (TraceOopMapRewrites) { - tty->print_cr("Suppress rewriting of astore at bci: %d", bci); - } + log_trace(generateoopmap)("Suppress rewriting of astore at bci: %d", bci); } } @@ -2519,9 +2481,7 @@ void GenerateOopMap::compute_ret_adr_at_TOS() { // TDT: should this be is_good_address() ? if (_stack_top > 0 && stack()[_stack_top-1].is_address()) { _ret_adr_tos->append(bcs.bci()); - if (TraceNewOopMapGeneration) { - tty->print_cr("Ret_adr TOS at bci: %d", bcs.bci()); - } + log_debug(generateoopmap)("Ret_adr TOS at bci: %d", bcs.bci()); } interp1(&bcs); } diff --git a/src/hotspot/share/oops/generateOopMap.hpp b/src/hotspot/share/oops/generateOopMap.hpp index 0da3779d463..783e295f08a 100644 --- a/src/hotspot/share/oops/generateOopMap.hpp +++ b/src/hotspot/share/oops/generateOopMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -348,17 +348,15 @@ class GenerateOopMap { // Basicblock info BasicBlock * _basic_blocks; // Array of basicblock info - int _gc_points; int _bb_count; ResourceBitMap _bb_hdr_bits; // Basicblocks methods void initialize_bb (); - void mark_bbheaders_and_count_gc_points(); + void mark_bbheaders(); bool is_bb_header (int bci) const { return _bb_hdr_bits.at(bci); } - int gc_points () const { return _gc_points; } int bb_count () const { return _bb_count; } void set_bbmark_bit (int bci); BasicBlock * get_basic_block_at (int bci) const; @@ -450,7 +448,7 @@ class GenerateOopMap { int binsToHold (int no) { return ((no+(BitsPerWord-1))/BitsPerWord); } char *state_vec_to_string (CellTypeState* vec, int len); - // Helper method. Can be used in subclasses to fx. calculate gc_points. If the current instruction + // Helper method. If the current instruction // is a control transfer, then calls the jmpFct all possible destinations. void ret_jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int varNo,int *data); bool jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int *data); @@ -480,14 +478,7 @@ class GenerateOopMap { bool monitor_safe() { return _monitor_safe; } // Specialization methods. Intended use: - // - possible_gc_point must return true for every bci for which the stackmaps must be returned - // - fill_stackmap_prolog is called just before the result is reported. The arguments tells the estimated - // number of gc points // - fill_stackmap_for_opcodes is called once for each bytecode index in order (0...code_length-1) - // - fill_stackmap_epilog is called after all results has been reported. Note: Since the algorithm does not report - // stackmaps for deadcode, fewer gc_points might have been encountered than assumed during the epilog. It is the - // responsibility of the subclass to count the correct number. - // - fill_init_vars are called once with the result of the init_vars computation // // All these methods are used during a call to: compute_map. Note: Non of the return results are valid // after compute_map returns, since all values are allocated as resource objects. @@ -496,14 +487,10 @@ class GenerateOopMap { virtual bool allow_rewrites () const { return false; } virtual bool report_results () const { return true; } virtual bool report_init_vars () const { return true; } - virtual bool possible_gc_point (BytecodeStream *bcs) { ShouldNotReachHere(); return false; } - virtual void fill_stackmap_prolog (int nof_gc_points) { ShouldNotReachHere(); } - virtual void fill_stackmap_epilog () { ShouldNotReachHere(); } virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs, CellTypeState* vars, CellTypeState* stack, int stackTop) { ShouldNotReachHere(); } - virtual void fill_init_vars (GrowableArray *init_vars) { ShouldNotReachHere();; } }; // @@ -513,19 +500,13 @@ class GenerateOopMap { class ResolveOopMapConflicts: public GenerateOopMap { private: - bool _must_clear_locals; - virtual bool report_results() const { return false; } virtual bool report_init_vars() const { return true; } virtual bool allow_rewrites() const { return true; } - virtual bool possible_gc_point (BytecodeStream *bcs) { return false; } - virtual void fill_stackmap_prolog (int nof_gc_points) {} - virtual void fill_stackmap_epilog () {} virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs, CellTypeState* vars, CellTypeState* stack, int stack_top) {} - virtual void fill_init_vars (GrowableArray *init_vars) { _must_clear_locals = init_vars->length() > 0; } #ifndef PRODUCT // Statistics @@ -535,10 +516,8 @@ class ResolveOopMapConflicts: public GenerateOopMap { #endif public: - ResolveOopMapConflicts(const methodHandle& method) : GenerateOopMap(method) { _must_clear_locals = false; }; - + ResolveOopMapConflicts(const methodHandle& method) : GenerateOopMap(method) { } methodHandle do_potential_rewrite(TRAPS); - bool must_clear_locals() const { return _must_clear_locals; } }; @@ -551,14 +530,10 @@ class GeneratePairingInfo: public GenerateOopMap { virtual bool report_results() const { return false; } virtual bool report_init_vars() const { return false; } virtual bool allow_rewrites() const { return false; } - virtual bool possible_gc_point (BytecodeStream *bcs) { return false; } - virtual void fill_stackmap_prolog (int nof_gc_points) {} - virtual void fill_stackmap_epilog () {} virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs, CellTypeState* vars, CellTypeState* stack, int stack_top) {} - virtual void fill_init_vars (GrowableArray *init_vars) {} public: GeneratePairingInfo(const methodHandle& method) : GenerateOopMap(method) {}; diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 1963327fc78..d3333e72c2a 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -23,6 +23,7 @@ */ #include "cds/aotClassInitializer.hpp" +#include "cds/aotLinkedClassBulkLoader.hpp" #include "cds/aotMetaspace.hpp" #include "cds/archiveUtils.hpp" #include "cds/cdsConfig.hpp" @@ -150,6 +151,7 @@ #endif // ndef DTRACE_ENABLED bool InstanceKlass::_finalization_enabled = true; +static int call_class_initializer_counter = 0; // for debugging static inline bool is_class_loader(const Symbol* class_name, const ClassFileParser& parser) { @@ -484,10 +486,8 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par ik = new (loader_data, size, THREAD) InstanceKlass(parser); } - if (ik != nullptr && UseCompressedClassPointers) { - assert(CompressedKlassPointers::is_encodable(ik), - "Klass " PTR_FORMAT "needs a narrow Klass ID, but is not encodable", p2i(ik)); - } + assert(ik == nullptr || CompressedKlassPointers::is_encodable(ik), + "Klass " PTR_FORMAT "needs a narrow Klass ID, but is not encodable", p2i(ik)); // Check for pending exception before adding to the loader data and incrementing // class count. Can get OOM here. @@ -884,7 +884,9 @@ void InstanceKlass::assert_no_clinit_will_run_for_aot_initialized_class() const #endif #if INCLUDE_CDS -void InstanceKlass::initialize_with_aot_initialized_mirror(TRAPS) { +// early_init -- we are moving this class into the fully_initialized state before the +// JVM is able to execute any bytecodes. See AOTLinkedClassBulkLoader::is_initializing_classes_early(). +void InstanceKlass::initialize_with_aot_initialized_mirror(bool early_init, TRAPS) { assert(has_aot_initialized_mirror(), "must be"); assert(CDSConfig::is_loading_heap(), "must be"); assert(CDSConfig::is_using_aot_linked_classes(), "must be"); @@ -894,15 +896,36 @@ void InstanceKlass::initialize_with_aot_initialized_mirror(TRAPS) { return; } + if (log_is_enabled(Info, aot, init)) { + ResourceMark rm; + log_info(aot, init)("%s (aot-inited%s)", external_name(), early_init ? ", early" : ""); + } + if (is_runtime_setup_required()) { + assert(!early_init, "must not call"); // Need to take the slow path, which will call the runtimeSetup() function instead // of initialize(CHECK); return; } - if (log_is_enabled(Info, aot, init)) { - ResourceMark rm; - log_info(aot, init)("%s (aot-inited)", external_name()); + + LogTarget(Info, class, init) lt; + if (lt.is_enabled()) { + ResourceMark rm(THREAD); + LogStream ls(lt); + ls.print("%d Initializing ", call_class_initializer_counter++); + name()->print_value_on(&ls); + ls.print_cr("(aot-inited) (" PTR_FORMAT ") by thread \"%s\"", + p2i(this), THREAD->name()); + } + + if (early_init) { + precond(AOTLinkedClassBulkLoader::is_initializing_classes_early()); + precond(is_linked()); + precond(init_thread() == nullptr); + set_init_state(fully_initialized); + fence_and_clear_init_lock(); + return; } link_class(CHECK); @@ -1699,8 +1722,6 @@ ArrayKlass* InstanceKlass::array_klass_or_null() { return array_klass_or_null(1); } -static int call_class_initializer_counter = 0; // for debugging - Method* InstanceKlass::class_initializer() const { Method* clinit = find_method( vmSymbols::class_initializer_name(), vmSymbols::void_method_signature()); diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index e370a3b7a7c..dd563ad3492 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -556,7 +556,7 @@ public: // initialization (virtuals from Klass) bool should_be_initialized() const override; // means that initialize should be called - void initialize_with_aot_initialized_mirror(TRAPS); + void initialize_with_aot_initialized_mirror(bool early_init, TRAPS); void assert_no_clinit_will_run_for_aot_initialized_class() const NOT_DEBUG_RETURN; void initialize(TRAPS) override; void initialize_preemptable(TRAPS) override; diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index 001e9eba790..84a1766a702 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -1055,14 +1055,8 @@ void Klass::verify_on(outputStream* st) { // This can be expensive, but it is worth checking that this klass is actually // in the CLD graph but not in production. -#ifdef ASSERT - if (UseCompressedClassPointers) { - // Stricter checks for both correct alignment and placement - CompressedKlassPointers::check_encodable(this); - } else { - assert(Metaspace::contains((address)this), "Should be"); - } -#endif // ASSERT + // Stricter checks for both correct alignment and placement + DEBUG_ONLY(CompressedKlassPointers::check_encodable(this)); guarantee(this->is_klass(),"should be klass"); diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index add8e59b2be..e7479671dcf 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -465,7 +465,7 @@ public: bool contains(address bcp) const { return constMethod()->contains(bcp); } // prints byte codes - void print_codes(int flags = 0) const { print_codes_on(tty, flags); } + void print_codes(int flags = 0, bool buffered = true) const { print_codes_on(tty, flags, buffered); } void print_codes_on(outputStream* st, int flags = 0, bool buffered = true) const; void print_codes_on(int from, int to, outputStream* st, int flags = 0, bool buffered = true) const; diff --git a/src/hotspot/share/oops/objArrayKlass.cpp b/src/hotspot/share/oops/objArrayKlass.cpp index 2bbe898adbd..fccd02f14e6 100644 --- a/src/hotspot/share/oops/objArrayKlass.cpp +++ b/src/hotspot/share/oops/objArrayKlass.cpp @@ -120,8 +120,7 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da return oak; } -ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, Kind) { - set_dimension(n); +ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(n, name, Kind) { set_element_klass(element_klass); Klass* bk; diff --git a/src/hotspot/share/oops/objLayout.cpp b/src/hotspot/share/oops/objLayout.cpp index b8cd8249da1..2c426a7ddff 100644 --- a/src/hotspot/share/oops/objLayout.cpp +++ b/src/hotspot/share/oops/objLayout.cpp @@ -38,21 +38,17 @@ void ObjLayout::initialize() { _klass_mode = Compact; _oop_base_offset_in_bytes = sizeof(markWord); _oop_has_klass_gap = false; - } else if (UseCompressedClassPointers) { + } else { _klass_mode = Compressed; _oop_base_offset_in_bytes = sizeof(markWord) + sizeof(narrowKlass); _oop_has_klass_gap = true; - } else { - _klass_mode = Uncompressed; - _oop_base_offset_in_bytes = sizeof(markWord) + sizeof(Klass*); - _oop_has_klass_gap = false; } #else assert(_klass_mode == Undefined, "ObjLayout initialized twice"); assert(!UseCompactObjectHeaders, "COH unsupported on 32-bit"); - // We support +-UseCompressedClassPointers on 32-bit, but the layout + // We support narrow Klass pointers on 32-bit, but the layout // is exactly the same as it was with uncompressed klass pointers - _klass_mode = UseCompressedClassPointers ? Compressed : Uncompressed; + _klass_mode = Compressed; _oop_base_offset_in_bytes = sizeof(markWord) + sizeof(Klass*); _oop_has_klass_gap = false; #endif diff --git a/src/hotspot/share/oops/objLayout.hpp b/src/hotspot/share/oops/objLayout.hpp index e434524d4b0..37ed0b7a532 100644 --- a/src/hotspot/share/oops/objLayout.hpp +++ b/src/hotspot/share/oops/objLayout.hpp @@ -27,8 +27,8 @@ /* * This class helps to avoid loading more than one flag in some - * operations that require checking UseCompressedClassPointers, - * UseCompactObjectHeaders and possibly more. + * operations that require checking UseCompactObjectHeaders and - in the future - + * possibly more. * * This is important on some performance critical paths, e.g. where * the Klass* is accessed frequently, especially by GC oop iterators @@ -37,12 +37,10 @@ class ObjLayout { public: enum Mode { - // +UseCompactObjectHeaders (implies +UseCompressedClassPointers) + // +UseCompactObjectHeaders Compact, - // +UseCompressedClassPointers (-UseCompactObjectHeaders) + // -UseCompactObjectHeaders (compressed Klass pointers) Compressed, - // -UseCompressedClassPointers (-UseCompactObjectHeaders) - Uncompressed, // Not yet initialized Undefined }; diff --git a/src/hotspot/share/oops/objLayout.inline.hpp b/src/hotspot/share/oops/objLayout.inline.hpp index 6aa9e39ce28..adad490378d 100644 --- a/src/hotspot/share/oops/objLayout.inline.hpp +++ b/src/hotspot/share/oops/objLayout.inline.hpp @@ -32,10 +32,8 @@ inline ObjLayout::Mode ObjLayout::klass_mode() { assert(_klass_mode != Undefined, "KlassMode not yet initialized"); if (UseCompactObjectHeaders) { assert(_klass_mode == Compact, "Klass mode does not match flags"); - } else if (UseCompressedClassPointers) { - assert(_klass_mode == Compressed, "Klass mode does not match flags"); } else { - assert(_klass_mode == Uncompressed, "Klass mode does not match flags"); + assert(_klass_mode == Compressed, "Klass mode does not match flags"); } #endif return _klass_mode; diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp index 5f453241c3d..415732af4f6 100644 --- a/src/hotspot/share/oops/oop.cpp +++ b/src/hotspot/share/oops/oop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,8 +152,7 @@ bool oopDesc::is_typeArray_noinline() const { return is_typeArray(); } #if INCLUDE_CDS_JAVA_HEAP void oopDesc::set_narrow_klass(narrowKlass nk) { assert(CDSConfig::is_dumping_heap(), "Used by CDS only. Do not abuse!"); - assert(UseCompressedClassPointers, "must be"); - _metadata._compressed_klass = nk; + _compressed_klass = nk; } #endif diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index 0dc6590750e..d6cc71a60d8 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,10 +49,7 @@ class oopDesc { friend class JVMCIVMStructs; private: volatile markWord _mark; - union _metadata { - Klass* _klass; - narrowKlass _compressed_klass; - } _metadata; + narrowKlass _compressed_klass; // There may be ordering constraints on the initialization of fields that // make use of the C++ copy/assign incorrect. @@ -338,7 +335,7 @@ class oopDesc { } else #endif { - return (int)offset_of(oopDesc, _metadata._klass); + return (int)offset_of(oopDesc, _compressed_klass); } } static int klass_gap_offset_in_bytes() { diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp index b445eae933b..d5cb80e1122 100644 --- a/src/hotspot/share/oops/oop.inline.hpp +++ b/src/hotspot/share/oops/oop.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -99,9 +99,9 @@ Klass* oopDesc::klass() const { case ObjLayout::Compact: return mark().klass(); case ObjLayout::Compressed: - return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass); + return CompressedKlassPointers::decode_not_null(_compressed_klass); default: - return _metadata._klass; + ShouldNotReachHere(); } } @@ -110,9 +110,9 @@ Klass* oopDesc::klass_or_null() const { case ObjLayout::Compact: return mark().klass_or_null(); case ObjLayout::Compressed: - return CompressedKlassPointers::decode(_metadata._compressed_klass); + return CompressedKlassPointers::decode(_compressed_klass); default: - return _metadata._klass; + ShouldNotReachHere(); } } @@ -121,11 +121,11 @@ Klass* oopDesc::klass_or_null_acquire() const { case ObjLayout::Compact: return mark_acquire().klass(); case ObjLayout::Compressed: { - narrowKlass narrow_klass = AtomicAccess::load_acquire(&_metadata._compressed_klass); + narrowKlass narrow_klass = AtomicAccess::load_acquire(&_compressed_klass); return CompressedKlassPointers::decode(narrow_klass); } default: - return AtomicAccess::load_acquire(&_metadata._klass); + ShouldNotReachHere(); } } @@ -134,9 +134,9 @@ Klass* oopDesc::klass_without_asserts() const { case ObjLayout::Compact: return mark().klass_without_asserts(); case ObjLayout::Compressed: - return CompressedKlassPointers::decode_without_asserts(_metadata._compressed_klass); + return CompressedKlassPointers::decode_without_asserts(_compressed_klass); default: - return _metadata._klass; + ShouldNotReachHere(); } } @@ -145,7 +145,7 @@ narrowKlass oopDesc::narrow_klass() const { case ObjLayout::Compact: return mark().narrow_klass(); case ObjLayout::Compressed: - return _metadata._compressed_klass; + return _compressed_klass; default: ShouldNotReachHere(); } @@ -154,23 +154,14 @@ narrowKlass oopDesc::narrow_klass() const { void oopDesc::set_klass(Klass* k) { assert(Universe::is_bootstrapping() || (k != nullptr && k->is_klass()), "incorrect Klass"); assert(!UseCompactObjectHeaders, "don't set Klass* with compact headers"); - if (UseCompressedClassPointers) { - _metadata._compressed_klass = CompressedKlassPointers::encode_not_null(k); - } else { - _metadata._klass = k; - } + _compressed_klass = CompressedKlassPointers::encode_not_null(k); } void oopDesc::release_set_klass(HeapWord* mem, Klass* k) { assert(Universe::is_bootstrapping() || (k != nullptr && k->is_klass()), "incorrect Klass"); assert(!UseCompactObjectHeaders, "don't set Klass* with compact headers"); char* raw_mem = ((char*)mem + klass_offset_in_bytes()); - if (UseCompressedClassPointers) { - AtomicAccess::release_store((narrowKlass*)raw_mem, - CompressedKlassPointers::encode_not_null(k)); - } else { - AtomicAccess::release_store((Klass**)raw_mem, k); - } + AtomicAccess::release_store((narrowKlass*)raw_mem, CompressedKlassPointers::encode_not_null(k)); } void oopDesc::set_klass_gap(HeapWord* mem, int v) { diff --git a/src/hotspot/share/oops/resolvedFieldEntry.cpp b/src/hotspot/share/oops/resolvedFieldEntry.cpp index 83f1a6919a6..122ecf092d8 100644 --- a/src/hotspot/share/oops/resolvedFieldEntry.cpp +++ b/src/hotspot/share/oops/resolvedFieldEntry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,12 @@ #include "cds/archiveBuilder.hpp" #include "cppstdlib/type_traits.hpp" +#include "oops/instanceKlass.hpp" +#include "oops/instanceOop.hpp" #include "oops/resolvedFieldEntry.hpp" +#include "runtime/fieldDescriptor.inline.hpp" +#include "utilities/checkedCast.hpp" +#include "utilities/globalDefinitions.hpp" static_assert(std::is_trivially_copyable_v); @@ -34,6 +39,19 @@ class ResolvedFieldEntryWithExtra : public ResolvedFieldEntry { }; static_assert(sizeof(ResolvedFieldEntryWithExtra) > sizeof(ResolvedFieldEntry)); +void ResolvedFieldEntry::fill_in(const fieldDescriptor& info, u1 tos_state, u1 get_code, u1 put_code) { + set_flags(info.access_flags().is_final(), info.access_flags().is_volatile()); + _field_holder = info.field_holder(); + _field_offset = info.offset(); + _field_index = checked_cast(info.index()); + _tos_state = tos_state; + + // These must be set after the other fields + set_bytecode(&_get_code, get_code); + set_bytecode(&_put_code, put_code); + assert_is_valid(); +} + void ResolvedFieldEntry::print_on(outputStream* st) const { st->print_cr("Field Entry:"); @@ -52,6 +70,23 @@ void ResolvedFieldEntry::print_on(outputStream* st) const { st->print_cr(" - Put Bytecode: %s", Bytecodes::name((Bytecodes::Code)put_code())); } +#ifdef ASSERT +void ResolvedFieldEntry::assert_is_valid() const { + assert(field_holder()->is_instance_klass(), "should be instanceKlass"); + assert(field_offset() >= instanceOopDesc::base_offset_in_bytes(), + "field offset out of range %d >= %d", field_offset(), instanceOopDesc::base_offset_in_bytes()); + assert(as_BasicType((TosState)tos_state()) != T_ILLEGAL, "tos_state is ILLEGAL"); + assert(_flags < (1 << (max_flag_shift + 1)), "flags are too large %d", _flags); + + // Read each bytecode once. + volatile Bytecodes::Code g = (Bytecodes::Code)get_code(); + assert(g == 0 || g == Bytecodes::_getstatic || g == Bytecodes::_getfield, "invalid get bytecode %d", g); + + volatile Bytecodes::Code p = (Bytecodes::Code)put_code(); + assert(p == 0 || p == Bytecodes::_putstatic || p == Bytecodes::_putfield, "invalid put bytecode %d", p); +} +#endif + #if INCLUDE_CDS void ResolvedFieldEntry::remove_unshareable_info() { *this = ResolvedFieldEntry(_cpool_index); diff --git a/src/hotspot/share/oops/resolvedFieldEntry.hpp b/src/hotspot/share/oops/resolvedFieldEntry.hpp index 77ad4815730..bdd9999dd63 100644 --- a/src/hotspot/share/oops/resolvedFieldEntry.hpp +++ b/src/hotspot/share/oops/resolvedFieldEntry.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #define SHARE_OOPS_RESOLVEDFIELDENTRY_HPP #include "interpreter/bytecodes.hpp" -#include "oops/instanceKlass.hpp" #include "runtime/atomicAccess.hpp" #include "utilities/checkedCast.hpp" #include "utilities/sizes.hpp" @@ -46,7 +45,8 @@ // The explicit paddings are necessary for generating deterministic CDS archives. They prevent // the C++ compiler from potentially inserting random values in unused gaps. -//class InstanceKlass; +class InstanceKlass; + class ResolvedFieldEntry { friend class VMStructs; @@ -84,6 +84,7 @@ public: enum { is_volatile_shift = 0, is_final_shift = 1, // unused + max_flag_shift = is_final_shift }; // Getters @@ -113,6 +114,7 @@ public: // Printing void print_on(outputStream* st) const; + private: void set_flags(bool is_final_flag, bool is_volatile_flag) { int new_flags = (is_final_flag << is_final_shift) | static_cast(is_volatile_flag); _flags = checked_cast(new_flags); @@ -129,17 +131,12 @@ public: AtomicAccess::release_store(code, new_code); } - // Populate the strucutre with resolution information - void fill_in(InstanceKlass* klass, int offset, u2 index, u1 tos_state, u1 b1, u1 b2) { - _field_holder = klass; - _field_offset = offset; - _field_index = index; - _tos_state = tos_state; + // Debug help + void assert_is_valid() const NOT_DEBUG_RETURN; - // These must be set after the other fields - set_bytecode(&_get_code, b1); - set_bytecode(&_put_code, b2); - } + public: + // Populate the strucutre with resolution information + void fill_in(const fieldDescriptor& info, u1 tos_state, u1 get_code, u1 put_code); // CDS #if INCLUDE_CDS @@ -155,7 +152,6 @@ public: static ByteSize put_code_offset() { return byte_offset_of(ResolvedFieldEntry, _put_code); } static ByteSize type_offset() { return byte_offset_of(ResolvedFieldEntry, _tos_state); } static ByteSize flags_offset() { return byte_offset_of(ResolvedFieldEntry, _flags); } - }; #endif //SHARE_OOPS_RESOLVEDFIELDENTRY_HPP diff --git a/src/hotspot/share/oops/typeArrayKlass.cpp b/src/hotspot/share/oops/typeArrayKlass.cpp index bdf37c7db49..7dbea9ce475 100644 --- a/src/hotspot/share/oops/typeArrayKlass.cpp +++ b/src/hotspot/share/oops/typeArrayKlass.cpp @@ -78,7 +78,7 @@ u2 TypeArrayKlass::compute_modifier_flags() const { return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; } -TypeArrayKlass::TypeArrayKlass(BasicType type, Symbol* name) : ArrayKlass(name, Kind) { +TypeArrayKlass::TypeArrayKlass(BasicType type, Symbol* name) : ArrayKlass(1, name, Kind) { set_layout_helper(array_layout_helper(type)); assert(is_array_klass(), "sanity"); assert(is_typeArray_klass(), "sanity"); diff --git a/src/hotspot/share/opto/addnode.cpp b/src/hotspot/share/opto/addnode.cpp index e04da430ef0..5520e4ae977 100644 --- a/src/hotspot/share/opto/addnode.cpp +++ b/src/hotspot/share/opto/addnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -816,7 +816,7 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) { offset = phase->MakeConX(t2->get_con() + t12->get_con()); } else { // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) - address = phase->transform(new AddPNode(in(Base),addp->in(Address),in(Offset))); + address = phase->transform(AddPNode::make_with_base(in(Base), addp->in(Address), in(Offset))); offset = addp->in(Offset); } set_req_X(Address, address, phase); @@ -838,11 +838,11 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Convert: (ptr + (offset+con)) into (ptr+offset)+con. // The idea is to merge array_base+scaled_index groups together, // and only have different constant offsets from the same base. - const Node *add = in(Offset); - if( add->Opcode() == Op_AddX && add->in(1) != add ) { - const Type *t22 = phase->type( add->in(2) ); - if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? - set_req(Address, phase->transform(new AddPNode(in(Base),in(Address),add->in(1)))); + const Node* add = in(Offset); + if (add->Opcode() == Op_AddX && add->in(1) != add) { + const Type* t22 = phase->type(add->in(2)); + if (t22->singleton() && (t22 != Type::TOP)) { // Right input is an add of a constant? + set_req(Address, phase->transform(AddPNode::make_with_base(in(Base), in(Address), add->in(1)))); set_req_X(Offset, add->in(2), phase); // puts add on igvn worklist if needed return this; // Made progress } diff --git a/src/hotspot/share/opto/addnode.hpp b/src/hotspot/share/opto/addnode.hpp index 6128de00efb..793eff8dd5d 100644 --- a/src/hotspot/share/opto/addnode.hpp +++ b/src/hotspot/share/opto/addnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -221,17 +221,19 @@ public: // So not really an AddNode. Lives here, because people associate it with // an add. class AddPNode : public Node { +private: + AddPNode(Node* base, Node* ptr, Node* off) : Node(nullptr, base, ptr, off) { + init_class_id(Class_AddP); + assert((ptr->bottom_type() == Type::TOP) || + ((base == Compile::current()->top()) == (ptr->bottom_type()->make_ptr()->isa_oopptr() == nullptr)), + "base input only needed for heap addresses"); + } + public: enum { Control, // When is it safe to do this add? Base, // Base oop, for GC purposes Address, // Actually address, derived from base Offset } ; // Offset added to address - AddPNode(Node *base, Node *ptr, Node *off) : Node(nullptr,base,ptr,off) { - init_class_id(Class_AddP); - assert((ptr->bottom_type() == Type::TOP) || - ((base == Compile::current()->top()) == (ptr->bottom_type()->make_ptr()->isa_oopptr() == nullptr)), - "base input only needed for heap addresses"); - } virtual int Opcode() const; virtual Node* Identity(PhaseGVN* phase); virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); @@ -243,6 +245,18 @@ public: // second return value: intptr_t& offset); + static AddPNode* make_with_base(Node* base, Node* ptr, Node* offset) { + return new AddPNode(base, ptr, offset); + } + + static AddPNode* make_with_base(Node* base, Node* offset) { + return make_with_base(base, base, offset); + } + + static AddPNode* make_off_heap(Node* ptr, Node* offset) { + return make_with_base(Compile::current()->top(), ptr, offset); + } + // Collect the AddP offset values into the elements array, giving up // if there are more than length. int unpack_offsets(Node* elements[], int length) const; diff --git a/src/hotspot/share/opto/arraycopynode.cpp b/src/hotspot/share/opto/arraycopynode.cpp index 4ee6107fe54..82d17440c56 100644 --- a/src/hotspot/share/opto/arraycopynode.cpp +++ b/src/hotspot/share/opto/arraycopynode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -226,8 +226,8 @@ Node* ArrayCopyNode::try_clone_instance(PhaseGVN *phase, bool can_reshape, int c ciField* field = ik->nonstatic_field_at(i); const TypePtr* adr_type = phase->C->alias_type(field)->adr_type(); Node* off = phase->MakeConX(field->offset_in_bytes()); - Node* next_src = phase->transform(new AddPNode(base_src,base_src,off)); - Node* next_dest = phase->transform(new AddPNode(base_dest,base_dest,off)); + Node* next_src = phase->transform(AddPNode::make_with_base(base_src, off)); + Node* next_dest = phase->transform(AddPNode::make_with_base(base_dest, off)); assert(phase->C->get_alias_index(adr_type) == phase->C->get_alias_index(phase->type(next_src)->isa_ptr()), "slice of address and input slice don't match"); assert(phase->C->get_alias_index(adr_type) == phase->C->get_alias_index(phase->type(next_dest)->isa_ptr()), @@ -332,11 +332,11 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape, Node* dest_scale = phase->transform(new LShiftXNode(dest_offset, phase->intcon(shift))); - adr_src = phase->transform(new AddPNode(base_src, base_src, src_scale)); - adr_dest = phase->transform(new AddPNode(base_dest, base_dest, dest_scale)); + adr_src = phase->transform(AddPNode::make_with_base(base_src, src_scale)); + adr_dest = phase->transform(AddPNode::make_with_base(base_dest, dest_scale)); - adr_src = phase->transform(new AddPNode(base_src, adr_src, phase->MakeConX(header))); - adr_dest = phase->transform(new AddPNode(base_dest, adr_dest, phase->MakeConX(header))); + adr_src = phase->transform(AddPNode::make_with_base(base_src, adr_src, phase->MakeConX(header))); + adr_dest = phase->transform(AddPNode::make_with_base(base_dest, adr_dest, phase->MakeConX(header))); copy_type = dest_elem; } else { @@ -355,8 +355,8 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape, return false; } - adr_src = phase->transform(new AddPNode(base_src, base_src, src_offset)); - adr_dest = phase->transform(new AddPNode(base_dest, base_dest, dest_offset)); + adr_src = phase->transform(AddPNode::make_with_base(base_src, src_offset)); + adr_dest = phase->transform(AddPNode::make_with_base(base_dest, dest_offset)); // The address is offsetted to an aligned address where a raw copy would start. // If the clone copy is decomposed into load-stores - the address is adjusted to @@ -366,8 +366,8 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape, int diff = arrayOopDesc::base_offset_in_bytes(elem) - offset; assert(diff >= 0, "clone should not start after 1st array element"); if (diff > 0) { - adr_src = phase->transform(new AddPNode(base_src, adr_src, phase->MakeConX(diff))); - adr_dest = phase->transform(new AddPNode(base_dest, adr_dest, phase->MakeConX(diff))); + adr_src = phase->transform(AddPNode::make_with_base(base_src, adr_src, phase->MakeConX(diff))); + adr_dest = phase->transform(AddPNode::make_with_base(base_dest, adr_dest, phase->MakeConX(diff))); } copy_type = elem; value_type = ary_src->elem(); @@ -425,8 +425,14 @@ Node* ArrayCopyNode::array_copy_forward(PhaseGVN *phase, store(bs, phase, forward_ctl, mm, adr_dest, atp_dest, v, value_type, copy_type); for (int i = 1; i < count; i++) { Node* off = phase->MakeConX(type2aelembytes(copy_type) * i); - Node* next_src = phase->transform(new AddPNode(base_src,adr_src,off)); - Node* next_dest = phase->transform(new AddPNode(base_dest,adr_dest,off)); + Node* next_src = phase->transform(AddPNode::make_with_base(base_src,adr_src,off)); + // We may have narrowed the type of next_src right before calling this method but because this runs with + // PhaseIterGVN::_delay_transform true, explicitly update the type of the AddP so it's consistent with its + // base and load() picks the right memory slice. + phase->set_type(next_src, next_src->Value(phase)); + Node* next_dest = phase->transform(AddPNode::make_with_base(base_dest,adr_dest,off)); + // Same as above + phase->set_type(next_dest, next_dest->Value(phase)); v = load(bs, phase, forward_ctl, mm, next_src, atp_src, value_type, copy_type); store(bs, phase, forward_ctl, mm, next_dest, atp_dest, v, value_type, copy_type); } @@ -463,8 +469,13 @@ Node* ArrayCopyNode::array_copy_backward(PhaseGVN *phase, if (count > 0) { for (int i = count-1; i >= 1; i--) { Node* off = phase->MakeConX(type2aelembytes(copy_type) * i); - Node* next_src = phase->transform(new AddPNode(base_src,adr_src,off)); - Node* next_dest = phase->transform(new AddPNode(base_dest,adr_dest,off)); + Node* next_src = phase->transform(AddPNode::make_with_base(base_src,adr_src,off)); + // We may have narrowed the type of next_src right before calling this method but because this runs with + // PhaseIterGVN::_delay_transform true, explicitly update the type of the AddP so it's consistent with its + // base and store() picks the right memory slice. + phase->set_type(next_src, next_src->Value(phase)); + Node* next_dest = phase->transform(AddPNode::make_with_base(base_dest,adr_dest,off)); + phase->set_type(next_dest, next_dest->Value(phase)); Node* v = load(bs, phase, backward_ctl, mm, next_src, atp_src, value_type, copy_type); store(bs, phase, backward_ctl, mm, next_dest, atp_dest, v, value_type, copy_type); } @@ -592,6 +603,17 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) { const Type* value_type = nullptr; bool disjoint_bases = false; + Node* src = in(ArrayCopyNode::Src); + Node* dest = in(ArrayCopyNode::Dest); + // EA may have moved an input to a new slice. EA stores the new address types in the ArrayCopy node itself + // (_src_type/_dest_type). phase->type(src) and _src_type or phase->type(dest) and _dest_type may be different + // when this transformation runs if igvn hasn't had a chance to propagate the new types yet. Make sure the new + // types are taken into account so new Load/Store nodes are created on the right slice. + const TypePtr* atp_src = get_address_type(phase, _src_type, src); + const TypePtr* atp_dest = get_address_type(phase, _dest_type, dest); + phase->set_type(src, phase->type(src)->join_speculative(atp_src)); + phase->set_type(dest, phase->type(dest)->join_speculative(atp_dest)); + if (!prepare_array_copy(phase, can_reshape, adr_src, base_src, adr_dest, base_dest, copy_type, value_type, disjoint_bases)) { @@ -600,10 +622,6 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) { return nullptr; } - Node* src = in(ArrayCopyNode::Src); - Node* dest = in(ArrayCopyNode::Dest); - const TypePtr* atp_src = get_address_type(phase, _src_type, src); - const TypePtr* atp_dest = get_address_type(phase, _dest_type, dest); Node* in_mem = in(TypeFunc::Memory); if (can_reshape) { diff --git a/src/hotspot/share/opto/buildOopMap.cpp b/src/hotspot/share/opto/buildOopMap.cpp index 675113163e8..e3a94f78d9c 100644 --- a/src/hotspot/share/opto/buildOopMap.cpp +++ b/src/hotspot/share/opto/buildOopMap.cpp @@ -377,6 +377,9 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i worklist.push(u); } } + if (m->is_SpillCopy()) { + worklist.push(m->in(1)); + } } } #endif diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 1662f808286..a4f6d04f6a3 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -249,6 +249,9 @@ develop(bool, TraceLoopOpts, false, \ "Trace executed loop optimizations") \ \ + develop(bool, TraceSplitIf, false, \ + "Trace Split-If optimization") \ + \ develop(bool, TraceLoopLimitCheck, false, \ "Trace generation of loop limits checks") \ \ @@ -334,6 +337,15 @@ product(bool, PartialPeelLoop, true, \ "Partial peel (rotate) loops") \ \ + product(uint, LoopPeeling, 1, DIAGNOSTIC, \ + "Control loop peeling optimization: " \ + "0 = always disable loop peeling, " \ + "1 = enable loop peeling (default), " \ + "2 = disable loop peeling as a standalone optimization but " \ + "allow it as a helper to other loop optimizations like removing " \ + "empty loops") \ + range(0, 2) \ + \ product(intx, PartialPeelNewPhiDelta, 0, \ "Additional phis that can be created by partial peeling") \ range(0, max_jint) \ @@ -895,6 +907,9 @@ \ develop(bool, StressLoopPeeling, false, \ "Randomize loop peeling decision") \ + \ + develop(bool, StressCountedLoop, false, \ + "Randomly delay conversion to counted loops") \ // end of C2_FLAGS diff --git a/src/hotspot/share/opto/callnode.cpp b/src/hotspot/share/opto/callnode.cpp index 9b3d7b38d15..c7c0810ae85 100644 --- a/src/hotspot/share/opto/callnode.cpp +++ b/src/hotspot/share/opto/callnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,6 +43,7 @@ #include "opto/rootnode.hpp" #include "opto/runtime.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/stubRoutines.hpp" #include "utilities/powerOfTwo.hpp" // Portions of code courtesy of Clifford Click @@ -844,6 +845,10 @@ bool CallNode::may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) { } } guarantee(dest != nullptr, "Call had only one ptr in, broken IR!"); + if (phase->type(dest)->isa_rawptr()) { + // may happen for an arraycopy that initializes a newly allocated object. Conservatively return true; + return true; + } if (!dest->is_top() && may_modify_arraycopy_helper(phase->type(dest)->is_oopptr(), t_oop, phase)) { return true; } @@ -1367,6 +1372,25 @@ TupleNode* CallLeafPureNode::make_tuple_of_input_state_and_top_return_values(con return tuple; } +CallLeafPureNode* CallLeafPureNode::inline_call_leaf_pure_node(Node* control) const { + Node* top = Compile::current()->top(); + if (control == nullptr) { + control = in(TypeFunc::Control); + } + + CallLeafPureNode* call = new CallLeafPureNode(tf(), entry_point(), _name); + call->init_req(TypeFunc::Control, control); + call->init_req(TypeFunc::I_O, top); + call->init_req(TypeFunc::Memory, top); + call->init_req(TypeFunc::ReturnAdr, top); + call->init_req(TypeFunc::FramePtr, top); + for (unsigned int i = 0; i < tf()->domain()->cnt() - TypeFunc::Parms; i++) { + call->init_req(TypeFunc::Parms + i, in(TypeFunc::Parms + i)); + } + + return call; +} + Node* CallLeafPureNode::Ideal(PhaseGVN* phase, bool can_reshape) { if (is_dead()) { return nullptr; @@ -1741,8 +1765,8 @@ Node *AllocateNode::make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem) { Node* mark_node = nullptr; if (UseCompactObjectHeaders) { Node* klass_node = in(AllocateNode::KlassNode); - Node* proto_adr = phase->transform(new AddPNode(phase->C->top(), klass_node, phase->MakeConX(in_bytes(Klass::prototype_header_offset())))); - mark_node = LoadNode::make(*phase, control, mem, proto_adr, TypeRawPtr::BOTTOM, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); + Node* proto_adr = phase->transform(AddPNode::make_off_heap(klass_node, phase->MakeConX(in_bytes(Klass::prototype_header_offset())))); + mark_node = LoadNode::make(*phase, control, mem, proto_adr, phase->type(proto_adr)->is_ptr(), TypeX_X, TypeX_X->basic_type(), MemNode::unordered); } else { // For now only enable fast locking for non-array types mark_node = phase->MakeConX(markWord::prototype().value()); @@ -2433,3 +2457,157 @@ bool CallNode::may_modify_arraycopy_helper(const TypeOopPtr* dest_t, const TypeO return true; } + +PowDNode::PowDNode(Compile* C, Node* base, Node* exp) + : CallLeafPureNode( + OptoRuntime::Math_DD_D_Type(), + StubRoutines::dpow() != nullptr ? StubRoutines::dpow() : CAST_FROM_FN_PTR(address, SharedRuntime::dpow), + "pow") { + add_flag(Flag_is_macro); + C->add_macro_node(this); + + init_req(TypeFunc::Parms + 0, base); + init_req(TypeFunc::Parms + 1, C->top()); // double slot padding + init_req(TypeFunc::Parms + 2, exp); + init_req(TypeFunc::Parms + 3, C->top()); // double slot padding +} + +const Type* PowDNode::Value(PhaseGVN* phase) const { + const Type* t_base = phase->type(base()); + const Type* t_exp = phase->type(exp()); + + if (t_base == Type::TOP || t_exp == Type::TOP) { + return Type::TOP; + } + + const TypeD* base_con = t_base->isa_double_constant(); + const TypeD* exp_con = t_exp->isa_double_constant(); + const TypeD* result_t = nullptr; + + // constant folding: both inputs are constants + if (base_con != nullptr && exp_con != nullptr) { + result_t = TypeD::make(SharedRuntime::dpow(base_con->getd(), exp_con->getd())); + } + + // Special cases when only the exponent is known: + if (exp_con != nullptr) { + double e = exp_con->getd(); + + // If the second argument is positive or negative zero, then the result is 1.0. + // i.e., pow(x, +/-0.0D) => 1.0 + if (e == 0.0) { // true for both -0.0 and +0.0 + result_t = TypeD::ONE; + } + + // If the second argument is NaN, then the result is NaN. + // i.e., pow(x, NaN) => NaN + if (g_isnan(e)) { + result_t = TypeD::make(NAN); + } + } + + if (result_t != nullptr) { + // We can't simply return a TypeD here, it must be a tuple type to be compatible with call nodes. + const Type** fields = TypeTuple::fields(2); + fields[TypeFunc::Parms + 0] = result_t; + fields[TypeFunc::Parms + 1] = Type::HALF; + return TypeTuple::make(TypeFunc::Parms + 2, fields); + } + + return tf()->range(); +} + +Node* PowDNode::Ideal(PhaseGVN* phase, bool can_reshape) { + if (!can_reshape) { + return nullptr; // wait for igvn + } + + PhaseIterGVN* igvn = phase->is_IterGVN(); + Node* base = this->base(); + Node* exp = this->exp(); + + const Type* t_exp = phase->type(exp); + const TypeD* exp_con = t_exp->isa_double_constant(); + + // Special cases when only the exponent is known: + if (exp_con != nullptr) { + double e = exp_con->getd(); + + // If the second argument is 1.0, then the result is the same as the first argument. + // i.e., pow(x, 1.0) => x + if (e == 1.0) { + return make_tuple_of_input_state_and_result(igvn, base); + } + + // If the second argument is 2.0, then strength reduce to multiplications. + // i.e., pow(x, 2.0) => x * x + if (e == 2.0) { + Node* mul = igvn->transform(new MulDNode(base, base)); + return make_tuple_of_input_state_and_result(igvn, mul); + } + + // If the second argument is 0.5, the strength reduce to square roots. + // i.e., pow(x, 0.5) => sqrt(x) iff x > 0 + if (e == 0.5 && Matcher::match_rule_supported(Op_SqrtD)) { + Node* ctrl = in(TypeFunc::Control); + Node* zero = igvn->zerocon(T_DOUBLE); + + // According to the API specs, pow(-0.0, 0.5) = 0.0 and sqrt(-0.0) = -0.0. + // So pow(-0.0, 0.5) shouldn't be replaced with sqrt(-0.0). + // -0.0/+0.0 are both excluded since floating-point comparison doesn't distinguish -0.0 from +0.0. + Node* cmp = igvn->register_new_node_with_optimizer(new CmpDNode(base, zero)); + Node* test = igvn->register_new_node_with_optimizer(new BoolNode(cmp, BoolTest::le)); + + IfNode* iff = new IfNode(ctrl, test, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); + igvn->register_new_node_with_optimizer(iff); + Node* if_slow = igvn->register_new_node_with_optimizer(new IfTrueNode(iff)); // x <= 0 + Node* if_fast = igvn->register_new_node_with_optimizer(new IfFalseNode(iff)); // x > 0 + + // slow path: call pow(x, 0.5) + Node* call = igvn->register_new_node_with_optimizer(inline_call_leaf_pure_node(if_slow)); + Node* call_ctrl = igvn->register_new_node_with_optimizer(new ProjNode(call, TypeFunc::Control)); + Node* call_result = igvn->register_new_node_with_optimizer(new ProjNode(call, TypeFunc::Parms + 0)); + + // fast path: sqrt(x) + Node* sqrt = igvn->register_new_node_with_optimizer(new SqrtDNode(igvn->C, if_fast, base)); + + // merge paths + RegionNode* region = new RegionNode(3); + igvn->register_new_node_with_optimizer(region); + region->init_req(1, call_ctrl); // slow path + region->init_req(2, if_fast); // fast path + + PhiNode* phi = new PhiNode(region, Type::DOUBLE); + igvn->register_new_node_with_optimizer(phi); + phi->init_req(1, call_result); // slow: pow() result + phi->init_req(2, sqrt); // fast: sqrt() result + + igvn->C->set_has_split_ifs(true); // Has chance for split-if optimization + + return make_tuple_of_input_state_and_result(igvn, phi, region); + } + } + + return CallLeafPureNode::Ideal(phase, can_reshape); +} + +// We can't simply have Ideal() returning a Con or MulNode since the users are still expecting a Call node, but we could +// produce a tuple that follows the same pattern so users can still get control, io, memory, etc.. +TupleNode* PowDNode::make_tuple_of_input_state_and_result(PhaseIterGVN* phase, Node* result, Node* control) { + if (control == nullptr) { + control = in(TypeFunc::Control); + } + + Compile* C = phase->C; + C->remove_macro_node(this); + TupleNode* tuple = TupleNode::make( + tf()->range(), + control, + in(TypeFunc::I_O), + in(TypeFunc::Memory), + in(TypeFunc::FramePtr), + in(TypeFunc::ReturnAdr), + result, + C->top()); + return tuple; +} diff --git a/src/hotspot/share/opto/callnode.hpp b/src/hotspot/share/opto/callnode.hpp index 41d0c9f5aac..a5131676347 100644 --- a/src/hotspot/share/opto/callnode.hpp +++ b/src/hotspot/share/opto/callnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -120,7 +120,6 @@ public: virtual int Opcode() const; virtual bool is_CFG() const { return true; } virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash - virtual bool depends_only_on_test() const { return false; } virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type* Value(PhaseGVN* phase) const; virtual uint ideal_reg() const { return NotAMachineReg; } @@ -141,7 +140,6 @@ class RethrowNode : public Node { virtual int Opcode() const; virtual bool is_CFG() const { return true; } virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash - virtual bool depends_only_on_test() const { return false; } virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type* Value(PhaseGVN* phase) const; virtual uint match_edge(uint idx) const; @@ -950,6 +948,8 @@ public: } int Opcode() const override; Node* Ideal(PhaseGVN* phase, bool can_reshape) override; + + CallLeafPureNode* inline_call_leaf_pure_node(Node* control = nullptr) const; }; //------------------------------CallLeafNoFPNode------------------------------- @@ -1301,4 +1301,19 @@ public: JVMState* dbg_jvms() const { return nullptr; } #endif }; + +//------------------------------PowDNode-------------------------------------- +class PowDNode : public CallLeafPureNode { + TupleNode* make_tuple_of_input_state_and_result(PhaseIterGVN* phase, Node* result, Node* control = nullptr); + +public: + PowDNode(Compile* C, Node* base, Node* exp); + int Opcode() const override; + const Type* Value(PhaseGVN* phase) const override; + Node* Ideal(PhaseGVN* phase, bool can_reshape) override; + + Node* base() const { return in(TypeFunc::Parms + 0); } + Node* exp() const { return in(TypeFunc::Parms + 2); } +}; + #endif // SHARE_OPTO_CALLNODE_HPP diff --git a/src/hotspot/share/opto/castnode.cpp b/src/hotspot/share/opto/castnode.cpp index 2ebbdd7cdb3..54269a56c19 100644 --- a/src/hotspot/share/opto/castnode.cpp +++ b/src/hotspot/share/opto/castnode.cpp @@ -207,6 +207,11 @@ bool ConstraintCastNode::higher_equal_types(PhaseGVN* phase, const Node* other) return true; } +Node* ConstraintCastNode::pin_node_under_control_impl() const { + assert(_dependency.is_floating(), "already pinned"); + return make_cast_for_type(in(0), in(1), bottom_type(), _dependency.with_pinned_dependency(), _extra_types); +} + #ifndef PRODUCT void ConstraintCastNode::dump_spec(outputStream *st) const { TypeNode::dump_spec(st); @@ -277,12 +282,9 @@ void CastIINode::dump_spec(outputStream* st) const { } #endif -CastIINode* CastIINode::pin_array_access_node() const { +CastIINode* CastIINode::pin_node_under_control_impl() const { assert(_dependency.is_floating(), "already pinned"); - if (has_range_check()) { - return new CastIINode(in(0), in(1), bottom_type(), _dependency.with_pinned_dependency(), has_range_check()); - } - return nullptr; + return new CastIINode(in(0), in(1), bottom_type(), _dependency.with_pinned_dependency(), _range_check_dependency, _extra_types); } void CastIINode::remove_range_check_cast(Compile* C) { @@ -468,9 +470,7 @@ static inline Node* addP_of_X2P(PhaseGVN *phase, if (negate) { dispX = phase->transform(new SubXNode(phase->MakeConX(0), dispX)); } - return new AddPNode(phase->C->top(), - phase->transform(new CastX2PNode(base)), - dispX); + return AddPNode::make_off_heap(phase->transform(new CastX2PNode(base)), dispX); } Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { diff --git a/src/hotspot/share/opto/castnode.hpp b/src/hotspot/share/opto/castnode.hpp index f22df546f41..38545fd6f41 100644 --- a/src/hotspot/share/opto/castnode.hpp +++ b/src/hotspot/share/opto/castnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -166,8 +166,6 @@ protected: virtual int Opcode() const; virtual uint ideal_reg() const = 0; bool carry_dependency() const { return !_dependency.cmp(DependencyType::FloatingNarrowing); } - // A cast node depends_only_on_test if and only if it is floating - virtual bool depends_only_on_test() const { return _dependency.is_floating(); } const DependencyType& dependency() const { return _dependency; } TypeNode* dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const; static Node* make_cast_for_basic_type(Node* c, Node* n, const Type* t, const DependencyType& dependency, BasicType bt); @@ -191,6 +189,12 @@ protected: const Type* extra_type_at(int i) const { return _extra_types->field_at(i); } + +protected: + virtual bool depends_only_on_test_impl() const { return _dependency.is_floating(); } + +private: + virtual Node* pin_node_under_control_impl() const; }; //------------------------------CastIINode------------------------------------- @@ -222,13 +226,15 @@ class CastIINode: public ConstraintCastNode { #endif } - CastIINode* pin_array_access_node() const; CastIINode* make_with(Node* parent, const TypeInteger* type, const DependencyType& dependency) const; void remove_range_check_cast(Compile* C); #ifndef PRODUCT virtual void dump_spec(outputStream* st) const; #endif + +private: + virtual CastIINode* pin_node_under_control_impl() const; }; class CastLLNode: public ConstraintCastNode { @@ -320,8 +326,10 @@ class CheckCastPPNode: public ConstraintCastNode { virtual const Type* Value(PhaseGVN* phase) const; virtual int Opcode() const; virtual uint ideal_reg() const { return Op_RegP; } - bool depends_only_on_test() const { return !type()->isa_rawptr() && ConstraintCastNode::depends_only_on_test(); } - }; + +private: + virtual bool depends_only_on_test_impl() const { return !type()->isa_rawptr() && ConstraintCastNode::depends_only_on_test_impl(); } +}; //------------------------------CastX2PNode------------------------------------- @@ -349,8 +357,10 @@ class CastP2XNode : public Node { virtual Node* Identity(PhaseGVN* phase); virtual uint ideal_reg() const { return Op_RegX; } virtual const Type *bottom_type() const { return TypeX_X; } + +private: // Return false to keep node from moving away from an associated card mark. - virtual bool depends_only_on_test() const { return false; } + virtual bool depends_only_on_test_impl() const { return false; } }; diff --git a/src/hotspot/share/opto/cfgnode.cpp b/src/hotspot/share/opto/cfgnode.cpp index c65bc391792..0915f79a503 100644 --- a/src/hotspot/share/opto/cfgnode.cpp +++ b/src/hotspot/share/opto/cfgnode.cpp @@ -2480,7 +2480,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } phase->is_IterGVN()->register_new_node_with_optimizer(offset); } - return new AddPNode(base, address, offset); + return AddPNode::make_with_base(base, address, offset); } } } @@ -2675,6 +2675,10 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { for( uint i=1; ias_If()->proj_out(1 - _con)->as_IfProj(); } - void pin_array_access_nodes(PhaseIterGVN* igvn); + void pin_dependent_nodes(PhaseIterGVN* igvn); protected: // Type of If input when this branch is always taken diff --git a/src/hotspot/share/opto/chaitin.cpp b/src/hotspot/share/opto/chaitin.cpp index 3ba3ffc1045..ef017ee15ec 100644 --- a/src/hotspot/share/opto/chaitin.cpp +++ b/src/hotspot/share/opto/chaitin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -2633,7 +2633,7 @@ void PhaseChaitin::verify_base_ptrs(ResourceArea* a) const { #ifdef _LP64 (UseCompressedOops && check->as_Mach()->ideal_Opcode() == Op_CastPP) || (UseCompressedOops && check->as_Mach()->ideal_Opcode() == Op_DecodeN) || - (UseCompressedClassPointers && check->as_Mach()->ideal_Opcode() == Op_DecodeNKlass) || + (check->as_Mach()->ideal_Opcode() == Op_DecodeNKlass) || #endif // _LP64 check->as_Mach()->ideal_Opcode() == Op_LoadP || check->as_Mach()->ideal_Opcode() == Op_LoadKlass))) { diff --git a/src/hotspot/share/opto/classes.hpp b/src/hotspot/share/opto/classes.hpp index abd93fdd876..d9290492337 100644 --- a/src/hotspot/share/opto/classes.hpp +++ b/src/hotspot/share/opto/classes.hpp @@ -239,8 +239,10 @@ macro(MemBarRelease) macro(StoreFence) macro(StoreStoreFence) macro(MemBarReleaseLock) +macro(MemBarStoreLoad) macro(MemBarVolatile) macro(MemBarStoreStore) +macro(MemBarFull) macro(MergeMem) macro(MinI) macro(MinL) @@ -284,6 +286,7 @@ macro(OpaqueZeroTripGuard) macro(OpaqueConstantBool) macro(OpaqueInitializedAssertionPredicate) macro(OpaqueTemplateAssertionPredicate) +macro(PowD) macro(ProfileBoolean) macro(OrI) macro(OrL) diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index 80bb1dcf408..7ab384a29c7 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -741,7 +741,7 @@ Compile::Compile(ciEnv* ci_env, ciMethod* target, int osr_bci, if (StressLCM || StressGCM || StressIGVN || StressCCP || StressIncrementalInlining || StressMacroExpansion || StressMacroElimination || StressUnstableIfTraps || - StressBailout || StressLoopPeeling) { + StressBailout || StressLoopPeeling || StressCountedLoop) { initialize_stress_seed(directive); } @@ -1369,72 +1369,37 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { cast_to_ptr_type(ptr)-> with_offset(offset); } - } else if (ta) { - // For arrays indexed by constant indices, we flatten the alias - // space to include all of the array body. Only the header, klass - // and array length can be accessed un-aliased. - if( offset != Type::OffsetBot ) { - if( ta->const_oop() ) { // MethodData* or Method* - offset = Type::OffsetBot; // Flatten constant access into array body - tj = ta = ta-> - remove_speculative()-> - cast_to_ptr_type(ptr)-> - cast_to_exactness(false)-> - with_offset(offset); - } else if( offset == arrayOopDesc::length_offset_in_bytes() ) { - // range is OK as-is. - tj = ta = TypeAryPtr::RANGE; - } else if( offset == oopDesc::klass_offset_in_bytes() ) { - tj = TypeInstPtr::KLASS; // all klass loads look alike - ta = TypeAryPtr::RANGE; // generic ignored junk - ptr = TypePtr::BotPTR; - } else if( offset == oopDesc::mark_offset_in_bytes() ) { - tj = TypeInstPtr::MARK; - ta = TypeAryPtr::RANGE; // generic ignored junk - ptr = TypePtr::BotPTR; - } else { // Random constant offset into array body - offset = Type::OffsetBot; // Flatten constant access into array body - tj = ta = ta-> - remove_speculative()-> - cast_to_ptr_type(ptr)-> - cast_to_exactness(false)-> - with_offset(offset); - } + } else if (ta != nullptr) { + // Common slices + if (offset == arrayOopDesc::length_offset_in_bytes()) { + return TypeAryPtr::RANGE; + } else if (offset == oopDesc::klass_offset_in_bytes()) { + return TypeInstPtr::KLASS; + } else if (offset == oopDesc::mark_offset_in_bytes()) { + return TypeInstPtr::MARK; } - // Arrays of fixed size alias with arrays of unknown size. - if (ta->size() != TypeInt::POS) { - const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS); - tj = ta = ta-> - remove_speculative()-> - cast_to_ptr_type(ptr)-> - with_ary(tary)-> - cast_to_exactness(false); - } - // Arrays of known objects become arrays of unknown objects. - if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) { - const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size()); - tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,nullptr,false,offset); - } - if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) { - const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size()); - tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,nullptr,false,offset); + + // Remove size and stability + const TypeAry* normalized_ary = TypeAry::make(ta->elem(), TypeInt::POS, false); + // Remove ptr, const_oop, and offset + if (ta->elem() == Type::BOTTOM) { + // Bottom array (meet of int[] and byte[] for example), accesses to it will be done with + // Unsafe. This should alias with all arrays. For now just leave it as it is (this is + // incorrect, see JDK-8331133). + tj = ta = TypeAryPtr::make(TypePtr::BotPTR, nullptr, normalized_ary, nullptr, false, Type::OffsetBot); + } else if (ta->elem()->make_oopptr() != nullptr) { + // Object arrays, all of them share the same slice + const TypeAry* tary = TypeAry::make(TypeInstPtr::BOTTOM, TypeInt::POS, false); + tj = ta = TypeAryPtr::make(TypePtr::BotPTR, nullptr, tary, nullptr, false, Type::OffsetBot); + } else { + // Primitive arrays + tj = ta = TypeAryPtr::make(TypePtr::BotPTR, nullptr, normalized_ary, ta->exact_klass(), true, Type::OffsetBot); } + // Arrays of bytes and of booleans both use 'bastore' and 'baload' so // cannot be distinguished by bytecode alone. if (ta->elem() == TypeInt::BOOL) { - const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size()); - ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE); - tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,offset); - } - // During the 2nd round of IterGVN, NotNull castings are removed. - // Make sure the Bottom and NotNull variants alias the same. - // Also, make sure exact and non-exact variants alias the same. - if (ptr == TypePtr::NotNull || ta->klass_is_exact() || ta->speculative() != nullptr) { - tj = ta = ta-> - remove_speculative()-> - cast_to_ptr_type(TypePtr::BotPTR)-> - cast_to_exactness(false)-> - with_offset(offset); + tj = ta = TypeAryPtr::BYTES; } } @@ -2292,7 +2257,9 @@ bool Compile::optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode) { PhaseIdealLoop::optimize(igvn, mode); _loop_opts_cnt--; if (failing()) return false; - if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); + if (major_progress()) { + print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); + } } } return true; @@ -3447,8 +3414,7 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f Node *addp = n->in(AddPNode::Address); assert(n->as_AddP()->address_input_has_same_base(), "Base pointers must match (addp %u)", addp->_idx ); #ifdef _LP64 - if ((UseCompressedOops || UseCompressedClassPointers) && - addp->Opcode() == Op_ConP && + if (addp->Opcode() == Op_ConP && addp == n->in(AddPNode::Base) && n->in(AddPNode::Offset)->is_Con()) { // If the transformation of ConP to ConN+DecodeN is beneficial depends @@ -3461,7 +3427,7 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f bool is_klass = t->isa_klassptr() != nullptr; if ((is_oop && UseCompressedOops && Matcher::const_oop_prefer_decode() ) || - (is_klass && UseCompressedClassPointers && Matcher::const_klass_prefer_decode() && + (is_klass && Matcher::const_klass_prefer_decode() && t->isa_klassptr()->exact_klass()->is_in_encoding_range())) { Node* nn = nullptr; @@ -3833,7 +3799,11 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f } break; case Op_Loop: - assert(!n->as_Loop()->is_loop_nest_inner_loop() || _loop_opts_cnt == 0, "should have been turned into a counted loop"); + // When StressCountedLoop is enabled, this loop may intentionally avoid a counted loop conversion. + // This is expected behavior for the stress mode, which exercises alternative compilation paths. + if (!StressCountedLoop) { + assert(!n->as_Loop()->is_loop_nest_inner_loop() || _loop_opts_cnt == 0, "should have been turned into a counted loop"); + } case Op_CountedLoop: case Op_LongCountedLoop: case Op_OuterStripMinedLoop: @@ -4004,8 +3974,7 @@ void Compile::final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_R } // Skip next transformation if compressed oops are not used. - if ((UseCompressedOops && !Matcher::gen_narrow_oop_implicit_null_checks()) || - (!UseCompressedOops && !UseCompressedClassPointers)) + if (UseCompressedOops && !Matcher::gen_narrow_oop_implicit_null_checks()) return; // Go over safepoints nodes to skip DecodeN/DecodeNKlass nodes for debug edges. diff --git a/src/hotspot/share/opto/divnode.cpp b/src/hotspot/share/opto/divnode.cpp index ed72d8a11cf..b398ec27b80 100644 --- a/src/hotspot/share/opto/divnode.cpp +++ b/src/hotspot/share/opto/divnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -419,8 +419,7 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis if (!d_pos) { q = new SubLNode(phase->longcon(0), phase->transform(q)); } - } else if ( !Matcher::use_asm_for_ldiv_by_con(d) ) { // Use hardware DIV instruction when - // it is faster than code generated below. + } else { // Attempt the jlong constant divide -> multiply transform found in // "Division by Invariant Integers using Multiplication" // by Granlund and Montgomery @@ -1592,41 +1591,25 @@ const Type* ModDNode::get_result_if_constant(const Type* dividend, const Type* d return TypeD::make(jdouble_cast(xr)); } -Node* ModFloatingNode::Ideal(PhaseGVN* phase, bool can_reshape) { - if (can_reshape) { - PhaseIterGVN* igvn = phase->is_IterGVN(); - - // Either input is TOP ==> the result is TOP - const Type* dividend_type = phase->type(dividend()); - const Type* divisor_type = phase->type(divisor()); - if (dividend_type == Type::TOP || divisor_type == Type::TOP) { - return phase->C->top(); - } - const Type* constant_result = get_result_if_constant(dividend_type, divisor_type); - if (constant_result != nullptr) { - return make_tuple_of_input_state_and_constant_result(igvn, constant_result); - } +const Type* ModFloatingNode::Value(PhaseGVN* phase) const { + const Type* t = CallLeafPureNode::Value(phase); + if (t == Type::TOP) { return Type::TOP; } + const Type* dividend_type = phase->type(dividend()); + const Type* divisor_type = phase->type(divisor()); + if (dividend_type == Type::TOP || divisor_type == Type::TOP) { + return Type::TOP; } - - return CallLeafPureNode::Ideal(phase, can_reshape); -} - -/* Give a tuple node for ::Ideal to return, made of the input state (control to return addr) - * and the given constant result. Idealization of projections will make sure to transparently - * propagate the input state and replace the result by the said constant. - */ -TupleNode* ModFloatingNode::make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const { - Node* con_node = phase->makecon(con); - TupleNode* tuple = TupleNode::make( - tf()->range(), - in(TypeFunc::Control), - in(TypeFunc::I_O), - in(TypeFunc::Memory), - in(TypeFunc::FramePtr), - in(TypeFunc::ReturnAdr), - con_node); - - return tuple; + const Type* constant_result = get_result_if_constant(dividend_type, divisor_type); + if (constant_result != nullptr) { + const TypeTuple* tt = t->is_tuple(); + uint cnt = tt->cnt(); + uint param_cnt = cnt - TypeFunc::Parms; + const Type** fields = TypeTuple::fields(param_cnt); + fields[TypeFunc::Parms] = constant_result; + if (param_cnt > 1) { fields[TypeFunc::Parms + 1] = Type::HALF; } + return TypeTuple::make(cnt, fields); + } + return t; } //============================================================================= diff --git a/src/hotspot/share/opto/divnode.hpp b/src/hotspot/share/opto/divnode.hpp index b13460c89f5..2598429716f 100644 --- a/src/hotspot/share/opto/divnode.hpp +++ b/src/hotspot/share/opto/divnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,15 +35,33 @@ // Optimization - Graph Style +class DivModIntegerNode : public Node { +private: + bool _pinned; + +protected: + DivModIntegerNode(Node* c, Node* dividend, Node* divisor) : Node(c, dividend, divisor), _pinned(false) {} + +private: + virtual uint size_of() const override { return sizeof(DivModIntegerNode); } + virtual uint hash() const override { return Node::hash() + _pinned; } + virtual bool cmp(const Node& o) const override { return Node::cmp(o) && _pinned == static_cast(o)._pinned; } + virtual bool depends_only_on_test_impl() const override { return !_pinned; } + virtual DivModIntegerNode* pin_node_under_control_impl() const override { + DivModIntegerNode* res = static_cast(clone()); + res->_pinned = true; + return res; + } +}; //------------------------------DivINode--------------------------------------- // Integer division // Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt. // On processors which don't naturally support this special case (e.g., x86), // the matcher or runtime system must take care of this. -class DivINode : public Node { +class DivINode : public DivModIntegerNode { public: - DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} + DivINode(Node* c, Node* dividend, Node* divisor) : DivModIntegerNode(c, dividend, divisor) {} virtual int Opcode() const; virtual Node* Identity(PhaseGVN* phase); virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); @@ -54,9 +72,9 @@ public: //------------------------------DivLNode--------------------------------------- // Long division -class DivLNode : public Node { +class DivLNode : public DivModIntegerNode { public: - DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} + DivLNode(Node* c, Node* dividend, Node* divisor) : DivModIntegerNode(c, dividend, divisor) {} virtual int Opcode() const; virtual Node* Identity(PhaseGVN* phase); virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); @@ -107,9 +125,9 @@ public: //------------------------------UDivINode--------------------------------------- // Unsigned integer division -class UDivINode : public Node { +class UDivINode : public DivModIntegerNode { public: - UDivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} + UDivINode(Node* c, Node* dividend, Node* divisor) : DivModIntegerNode(c, dividend, divisor) {} virtual int Opcode() const; virtual Node* Identity(PhaseGVN* phase); virtual const Type* Value(PhaseGVN* phase) const; @@ -120,9 +138,9 @@ public: //------------------------------UDivLNode--------------------------------------- // Unsigned long division -class UDivLNode : public Node { +class UDivLNode : public DivModIntegerNode { public: - UDivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} + UDivLNode(Node* c, Node* dividend, Node* divisor) : DivModIntegerNode(c, dividend, divisor) {} virtual int Opcode() const; virtual Node* Identity(PhaseGVN* phase); virtual const Type* Value(PhaseGVN* phase) const; @@ -133,9 +151,9 @@ public: //------------------------------ModINode--------------------------------------- // Integer modulus -class ModINode : public Node { +class ModINode : public DivModIntegerNode { public: - ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} + ModINode(Node* c, Node* in1, Node* in2) : DivModIntegerNode(c, in1, in2) {} virtual int Opcode() const; virtual const Type* Value(PhaseGVN* phase) const; virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); @@ -145,9 +163,9 @@ public: //------------------------------ModLNode--------------------------------------- // Long modulus -class ModLNode : public Node { +class ModLNode : public DivModIntegerNode { public: - ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} + ModLNode(Node* c, Node* in1, Node* in2) : DivModIntegerNode(c, in1, in2) {} virtual int Opcode() const; virtual const Type* Value(PhaseGVN* phase) const; virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); @@ -157,8 +175,6 @@ public: // Base class for float and double modulus class ModFloatingNode : public CallLeafPureNode { - TupleNode* make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const; - protected: virtual Node* dividend() const = 0; virtual Node* divisor() const = 0; @@ -166,7 +182,7 @@ protected: public: ModFloatingNode(Compile* C, const TypeFunc* tf, address addr, const char* name); - Node* Ideal(PhaseGVN* phase, bool can_reshape) override; + const Type* Value(PhaseGVN* phase) const override; }; // Float Modulus @@ -199,9 +215,9 @@ public: //------------------------------UModINode--------------------------------------- // Unsigned integer modulus -class UModINode : public Node { +class UModINode : public DivModIntegerNode { public: - UModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} + UModINode(Node* c, Node* in1, Node* in2) : DivModIntegerNode(c, in1, in2) {} virtual int Opcode() const; virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type *bottom_type() const { return TypeInt::INT; } @@ -211,9 +227,9 @@ public: //------------------------------UModLNode--------------------------------------- // Unsigned long modulus -class UModLNode : public Node { +class UModLNode : public DivModIntegerNode { public: - UModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} + UModLNode(Node* c, Node* in1, Node* in2) : DivModIntegerNode(c, in1, in2) {} virtual int Opcode() const; virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type *bottom_type() const { return TypeLong::LONG; } @@ -243,6 +259,9 @@ public: ProjNode* div_proj() { return proj_out_or_null(div_proj_num); } ProjNode* mod_proj() { return proj_out_or_null(mod_proj_num); } + +private: + virtual bool depends_only_on_test() const { return false; } }; //------------------------------DivModINode--------------------------------------- diff --git a/src/hotspot/share/opto/escape.cpp b/src/hotspot/share/opto/escape.cpp index 5befdd924ff..7041eb0b810 100644 --- a/src/hotspot/share/opto/escape.cpp +++ b/src/hotspot/share/opto/escape.cpp @@ -780,7 +780,7 @@ Node* ConnectionGraph::split_castpp_load_through_phi(Node* curr_addp, Node* curr base = base->find_out_with(Op_CastPP); } - Node* addr = _igvn->transform(new AddPNode(base, base, curr_addp->in(AddPNode::Offset))); + Node* addr = _igvn->transform(AddPNode::make_with_base(base, curr_addp->in(AddPNode::Offset))); Node* mem = (memory->is_Phi() && (memory->in(0) == region)) ? memory->in(i) : memory; Node* load = curr_load->clone(); load->set_req(0, nullptr); diff --git a/src/hotspot/share/opto/generateOptoStub.cpp b/src/hotspot/share/opto/generateOptoStub.cpp index 77633857cdf..d719c301dc6 100644 --- a/src/hotspot/share/opto/generateOptoStub.cpp +++ b/src/hotspot/share/opto/generateOptoStub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -88,18 +88,17 @@ void GraphKit::gen_stub(address C_function, const int NoAlias = Compile::AliasIdxBot; - Node* adr_last_Java_pc = basic_plus_adr(top(), - thread, - in_bytes(JavaThread::frame_anchor_offset()) + - in_bytes(JavaFrameAnchor::last_Java_pc_offset())); + Node* adr_last_Java_pc = off_heap_plus_addr(thread, + in_bytes(JavaThread::frame_anchor_offset()) + + in_bytes(JavaFrameAnchor::last_Java_pc_offset())); // Drop in the last_Java_sp. last_Java_fp is not touched. // Always do this after the other "last_Java_frame" fields are set since // as soon as last_Java_sp != nullptr the has_last_Java_frame is true and // users will look at the other fields. // - Node *adr_sp = basic_plus_adr(top(), thread, in_bytes(JavaThread::last_Java_sp_offset())); - Node *last_sp = frameptr(); + Node* adr_sp = off_heap_plus_addr(thread, in_bytes(JavaThread::last_Java_sp_offset())); + Node* last_sp = frameptr(); store_to_memory(control(), adr_sp, last_sp, T_ADDRESS, MemNode::unordered); // Set _thread_in_native @@ -228,7 +227,7 @@ void GraphKit::gen_stub(address C_function, Node* target = map()->in(TypeFunc::Parms); // Runtime call returning oop in TLS? Fetch it out if( pass_tls ) { - Node* adr = basic_plus_adr(top(), thread, in_bytes(JavaThread::vm_result_oop_offset())); + Node* adr = off_heap_plus_addr(thread, in_bytes(JavaThread::vm_result_oop_offset())); Node* vm_result = make_load(nullptr, adr, TypeOopPtr::BOTTOM, T_OBJECT, MemNode::unordered); map()->set_req(TypeFunc::Parms, vm_result); // vm_result passed as result // clear thread-local-storage(tls) @@ -237,7 +236,7 @@ void GraphKit::gen_stub(address C_function, //----------------------------- // check exception - Node* adr = basic_plus_adr(top(), thread, in_bytes(Thread::pending_exception_offset())); + Node* adr = off_heap_plus_addr(thread, in_bytes(Thread::pending_exception_offset())); Node* pending = make_load(nullptr, adr, TypeOopPtr::BOTTOM, T_OBJECT, MemNode::unordered); Node* exit_memory = reset_memory(); diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index 084b137f313..e297292770e 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -508,7 +508,7 @@ void GraphKit::uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptR // first must access the should_post_on_exceptions_flag in this thread's JavaThread Node* jthread = _gvn.transform(new ThreadLocalNode()); - Node* adr = basic_plus_adr(top(), jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset())); + Node* adr = off_heap_plus_addr(jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset())); Node* should_post_flag = make_load(control(), adr, TypeInt::INT, T_INT, MemNode::unordered); // Test the should_post_on_exceptions_flag vs. 0 @@ -670,6 +670,48 @@ ciInstance* GraphKit::builtin_throw_exception(Deoptimization::DeoptReason reason } } +GraphKit::SavedState::SavedState(GraphKit* kit) : + _kit(kit), + _sp(kit->sp()), + _jvms(kit->jvms()), + _map(kit->clone_map()), + _discarded(false) +{ + for (DUIterator_Fast imax, i = kit->control()->fast_outs(imax); i < imax; i++) { + Node* out = kit->control()->fast_out(i); + if (out->is_CFG()) { + _ctrl_succ.push(out); + } + } +} + +GraphKit::SavedState::~SavedState() { + if (_discarded) { + _kit->destruct_map_clone(_map); + return; + } + _kit->jvms()->set_map(_map); + _kit->jvms()->set_sp(_sp); + _map->set_jvms(_kit->jvms()); + _kit->set_map(_map); + _kit->set_sp(_sp); + for (DUIterator_Fast imax, i = _kit->control()->fast_outs(imax); i < imax; i++) { + Node* out = _kit->control()->fast_out(i); + if (out->is_CFG() && out->in(0) == _kit->control() && out != _kit->map() && !_ctrl_succ.member(out)) { + _kit->_gvn.hash_delete(out); + out->set_req(0, _kit->C->top()); + _kit->C->record_for_igvn(out); + --i; --imax; + _kit->_gvn.hash_find_insert(out); + } + } +} + +void GraphKit::SavedState::discard() { + _discarded = true; +} + + //----------------------------PreserveJVMState--------------------------------- PreserveJVMState::PreserveJVMState(GraphKit* kit, bool clone_map) { DEBUG_ONLY(kit->verify_map()); @@ -1177,8 +1219,22 @@ bool GraphKit::compute_stack_effects(int& inputs, int& depth) { //------------------------------basic_plus_adr--------------------------------- Node* GraphKit::basic_plus_adr(Node* base, Node* ptr, Node* offset) { // short-circuit a common case - if (offset == intcon(0)) return ptr; - return _gvn.transform( new AddPNode(base, ptr, offset) ); + if (offset == MakeConX(0)) { + return ptr; + } +#ifdef ASSERT + // Both 32-bit and 64-bit zeros should have been handled by the previous `if` + // statement, so if we see either 32-bit or 64-bit zeros here, then we have a + // problem. + if (offset->is_Con()) { + const Type* t = offset->bottom_type(); + bool is_zero_int = t->isa_int() && t->is_int()->get_con() == 0; + bool is_zero_long = t->isa_long() && t->is_long()->get_con() == 0; + assert(!is_zero_int && !is_zero_long, + "Unexpected zero offset - should have matched MakeConX(0)"); + } +#endif + return _gvn.transform(AddPNode::make_with_base(base, ptr, offset)); } Node* GraphKit::ConvI2L(Node* offset) { @@ -1664,13 +1720,22 @@ Node* GraphKit::access_load_at(Node* obj, // containing obj return top(); // Dead path ? } + SavedState old_state(this); C2AccessValuePtr addr(adr, adr_type); C2ParseAccess access(this, decorators | C2_READ_ACCESS, bt, obj, addr); + Node* load; if (access.is_raw()) { - return _barrier_set->BarrierSetC2::load_at(access, val_type); + load = _barrier_set->BarrierSetC2::load_at(access, val_type); } else { - return _barrier_set->load_at(access, val_type); + load = _barrier_set->load_at(access, val_type); } + + // Restore the previous state only if the load got folded to a constant + // and we can discard any barriers that might have been added. + if (load == nullptr || !load->is_Con()) { + old_state.discard(); + } + return load; } Node* GraphKit::access_load(Node* adr, // actual address to load val at @@ -1681,13 +1746,22 @@ Node* GraphKit::access_load(Node* adr, // actual address to load val at return top(); // Dead path ? } + SavedState old_state(this); C2AccessValuePtr addr(adr, adr->bottom_type()->is_ptr()); C2ParseAccess access(this, decorators | C2_READ_ACCESS, bt, nullptr, addr); + Node* load; if (access.is_raw()) { - return _barrier_set->BarrierSetC2::load_at(access, val_type); + load = _barrier_set->BarrierSetC2::load_at(access, val_type); } else { - return _barrier_set->load_at(access, val_type); + load = _barrier_set->load_at(access, val_type); } + + // Restore the previous state only if the load got folded to a constant + // and we can discard any barriers that might have been added. + if (load == nullptr || !load->is_Con()) { + old_state.discard(); + } + return load; } Node* GraphKit::access_atomic_cmpxchg_val_at(Node* obj, @@ -2743,9 +2817,9 @@ Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, No // will always succeed. We could leave a dependency behind to ensure this. // First load the super-klass's check-offset - Node *p1 = gvn.transform(new AddPNode(C->top(), superklass, gvn.MakeConX(in_bytes(Klass::super_check_offset_offset())))); + Node* p1 = gvn.transform(AddPNode::make_off_heap(superklass, gvn.MakeConX(in_bytes(Klass::super_check_offset_offset())))); Node* m = C->immutable_memory(); - Node *chk_off = gvn.transform(new LoadINode(nullptr, m, p1, gvn.type(p1)->is_ptr(), TypeInt::INT, MemNode::unordered)); + Node* chk_off = gvn.transform(new LoadINode(nullptr, m, p1, gvn.type(p1)->is_ptr(), TypeInt::INT, MemNode::unordered)); int cacheoff_con = in_bytes(Klass::secondary_super_cache_offset()); const TypeInt* chk_off_t = chk_off->Value(&gvn)->isa_int(); int chk_off_con = (chk_off_t != nullptr && chk_off_t->is_con()) ? chk_off_t->get_con() : cacheoff_con; @@ -2761,11 +2835,11 @@ Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, No #ifdef _LP64 chk_off_X = gvn.transform(new ConvI2LNode(chk_off_X)); #endif - Node* p2 = gvn.transform(new AddPNode(C->top(), subklass, chk_off_X)); + Node* p2 = gvn.transform(AddPNode::make_off_heap(subklass, chk_off_X)); // For some types like interfaces the following loadKlass is from a 1-word // cache which is mutable so can't use immutable memory. Other // types load from the super-class display table which is immutable. - Node *kmem = C->immutable_memory(); + Node* kmem = C->immutable_memory(); // secondary_super_cache is not immutable but can be treated as such because: // - no ideal node writes to it in a way that could cause an // incorrect/missed optimization of the following Load. @@ -3002,7 +3076,7 @@ bool GraphKit::seems_never_null(Node* obj, ciProfileData* data, bool& speculatin void GraphKit::guard_klass_being_initialized(Node* klass) { int init_state_off = in_bytes(InstanceKlass::init_state_offset()); - Node* adr = basic_plus_adr(top(), klass, init_state_off); + Node* adr = off_heap_plus_addr(klass, init_state_off); Node* init_state = LoadNode::make(_gvn, nullptr, immutable_memory(), adr, adr->bottom_type()->is_ptr(), TypeInt::BYTE, T_BYTE, MemNode::acquire); @@ -3020,7 +3094,7 @@ void GraphKit::guard_klass_being_initialized(Node* klass) { void GraphKit::guard_init_thread(Node* klass) { int init_thread_off = in_bytes(InstanceKlass::init_thread_offset()); - Node* adr = basic_plus_adr(top(), klass, init_thread_off); + Node* adr = off_heap_plus_addr(klass, init_thread_off); Node* init_thread = LoadNode::make(_gvn, nullptr, immutable_memory(), adr, adr->bottom_type()->is_ptr(), TypePtr::NOTNULL, @@ -3598,7 +3672,7 @@ Node* GraphKit::get_layout_helper(Node* klass_node, jint& constant_value) { } } constant_value = Klass::_lh_neutral_value; // put in a known value - Node* lhp = basic_plus_adr(top(), klass_node, in_bytes(Klass::layout_helper_offset())); + Node* lhp = off_heap_plus_addr(klass_node, in_bytes(Klass::layout_helper_offset())); return make_load(nullptr, lhp, TypeInt::INT, T_INT, MemNode::unordered); } diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index 0537d31ae36..273009ca7ce 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -320,6 +320,13 @@ class GraphKit : public Phase { } Node* basic_plus_adr(Node* base, Node* ptr, Node* offset); + Node* off_heap_plus_addr(Node* ptr, intptr_t offset) { + return basic_plus_adr(top(), ptr, MakeConX(offset)); + } + + Node* off_heap_plus_addr(Node* ptr, Node* offset) { + return basic_plus_adr(top(), ptr, offset); + } // Some convenient shortcuts for common nodes Node* IfTrue(IfNode* iff) { return _gvn.transform(new IfTrueNode(iff)); } @@ -346,7 +353,7 @@ class GraphKit : public Phase { Node* CmpP(Node* l, Node* r) { return _gvn.transform(new CmpPNode(l, r)); } Node* Bool(Node* cmp, BoolTest::mask relop) { return _gvn.transform(new BoolNode(cmp, relop)); } - Node* AddP(Node* b, Node* a, Node* o) { return _gvn.transform(new AddPNode(b, a, o)); } + Node* AddP(Node* b, Node* a, Node* o) { return _gvn.transform(AddPNode::make_with_base(b, a, o)); } // Convert between int and long, and size_t. // (See macros ConvI2X, etc., in type.hpp for ConvI2X, etc.) @@ -876,6 +883,29 @@ class GraphKit : public Phase { Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false); Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem); Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem); + + // Helper class to support reverting to a previous parsing state. + // When an intrinsic makes changes before bailing out, it's necessary to restore the graph + // as it was. See JDK-8359344 for what can happen wrong. It's also not always possible to + // bailout before making changes because the bailing out decision might depend on new nodes + // (their types, for instance). + // + // So, if an intrinsic might cause this situation, one must start by saving the state in a + // SavedState by constructing it, and the state will be restored on destruction. If the + // intrinsic is not bailing out, one need to call discard to prevent restoring the old state. + class SavedState : public StackObj { + GraphKit* _kit; + int _sp; + JVMState* _jvms; + SafePointNode* _map; + Unique_Node_List _ctrl_succ; + bool _discarded; + + public: + SavedState(GraphKit*); + ~SavedState(); + void discard(); + }; }; // Helper class to support building of control flow branches. Upon diff --git a/src/hotspot/share/opto/idealGraphPrinter.cpp b/src/hotspot/share/opto/idealGraphPrinter.cpp index 5070a9f00e1..563a914ea5c 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.cpp +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp @@ -40,16 +40,60 @@ class PrintProperties { private: IdealGraphPrinter* _printer; + void print_alias_properties(Node* node); + void print_escape_properties(Node* node); public: PrintProperties(IdealGraphPrinter* printer) : _printer(printer) {} void print_node_properties(Node* node); + void print_node_details(Node* node); void print_lrg_properties(const LRG& lrg, const char* buffer); void print_property(int flag, const char* name); void print_property(int flag, const char* name, const char* val); void print_property(int flag, const char* name, int val); }; +void PrintProperties::print_alias_properties(Node* node) { + const TypePtr* adr_type = node->adr_type(); + Compile* C = _printer->C; + if (adr_type != nullptr && C->have_alias_type(adr_type)) { + Compile::AliasType* at = C->alias_type(adr_type); + if (at != nullptr) { + print_property(true, "alias_index", at->index()); + // The value of at->field(), if present, is already dumped in the + // "source"/"destination" properties. + const Type* element = at->element(); + if (element != nullptr) { + stringStream element_stream; + element->dump_on(&element_stream); + print_property(true, "alias_element", element_stream.freeze()); + } + print_property(at->is_rewritable(), "alias_is_rewritable"); + print_property(at->is_volatile(), "alias_is_volatile"); + print_property(at->general_index() != at->index(), "alias_general_index", at->general_index()); + } + } +} + +void PrintProperties::print_escape_properties(Node* node) { + // Dump escape analysis state for relevant nodes. + if (node->is_Allocate()) { + AllocateNode* alloc = node->as_Allocate(); + print_property(alloc->_is_scalar_replaceable, "is_scalar_replaceable"); + print_property(alloc->_is_non_escaping, "is_non_escaping"); + print_property(alloc->does_not_escape_thread(), "does_not_escape_thread"); + } + if (node->is_SafePoint() && node->as_SafePoint()->has_ea_local_in_scope()) { + print_property(true, "has_ea_local_in_scope"); + } + if (node->is_CallJava() && node->as_CallJava()->arg_escape()) { + print_property(true, "arg_escape"); + } + if (node->is_Initialize() && node->as_Initialize()->does_not_escape()) { + print_property(true, "does_not_escape"); + } +} + void PrintProperties::print_node_properties(Node* node) { const jushort flags = node->flags(); print_property((flags & Node::Flag_is_Copy), "is_copy"); @@ -75,6 +119,15 @@ void PrintProperties::print_node_properties(Node* node) { } } +void PrintProperties::print_node_details(Node* node) { + print_alias_properties(node); + + print_escape_properties(node); + + print_property(node->is_block_proj() != nullptr, "is_block_proj"); + print_property(node->is_block_start(), "is_block_start"); +} + void PrintProperties::print_lrg_properties(const LRG &lrg, const char *buffer) { print_property(true, "mask", buffer); print_property(true, "mask_size", lrg.mask_size()); @@ -651,61 +704,7 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) { assert(s2.size() < sizeof(buffer), "size in range"); print_prop("dump_spec", buffer); - const TypePtr* adr_type = node->adr_type(); - if (adr_type != nullptr && C->have_alias_type(adr_type)) { - Compile::AliasType* at = C->alias_type(adr_type); - if (at != nullptr) { - print_prop("alias_index", at->index()); - // The value of at->field(), if present, is already dumped in the - // "source"/"destination" properties. - const Type* element = at->element(); - if (element != nullptr) { - stringStream element_stream; - element->dump_on(&element_stream); - print_prop("alias_element", element_stream.freeze()); - } - if (at->is_rewritable()) { - print_prop("alias_is_rewritable", "true"); - } - if (at->is_volatile()) { - print_prop("alias_is_volatile", "true"); - } - if (at->general_index() != at->index()) { - print_prop("alias_general_index", at->general_index()); - } - } - } - - if (node->is_block_proj()) { - print_prop("is_block_proj", "true"); - } - - if (node->is_block_start()) { - print_prop("is_block_start", "true"); - } - - // Dump escape analysis state for relevant nodes. - if (node->is_Allocate()) { - AllocateNode* alloc = node->as_Allocate(); - if (alloc->_is_scalar_replaceable) { - print_prop("is_scalar_replaceable", "true"); - } - if (alloc->_is_non_escaping) { - print_prop("is_non_escaping", "true"); - } - if (alloc->does_not_escape_thread()) { - print_prop("does_not_escape_thread", "true"); - } - } - if (node->is_SafePoint() && node->as_SafePoint()->has_ea_local_in_scope()) { - print_prop("has_ea_local_in_scope", "true"); - } - if (node->is_CallJava() && node->as_CallJava()->arg_escape()) { - print_prop("arg_escape", "true"); - } - if (node->is_Initialize() && node->as_Initialize()->does_not_escape()) { - print_prop("does_not_escape", "true"); - } + print_node.print_node_details(node); const char *short_name = "short_name"; if (strcmp(node->Name(), "Parm") == 0 && node->as_Proj()->_con >= TypeFunc::Parms) { diff --git a/src/hotspot/share/opto/idealKit.cpp b/src/hotspot/share/opto/idealKit.cpp index dd7e9ae52b7..fbb61bfdf72 100644 --- a/src/hotspot/share/opto/idealKit.cpp +++ b/src/hotspot/share/opto/idealKit.cpp @@ -360,6 +360,17 @@ Node* IdealKit::load(Node* ctl, return transform(ld); } +// Load AOT runtime constant +Node* IdealKit::load_aot_const(Node* adr, const Type* t) { + BasicType bt = t->basic_type(); + const TypePtr* adr_type = nullptr; // debug-mode-only argument + DEBUG_ONLY(adr_type = C->get_adr_type(Compile::AliasIdxRaw)); + Node* ctl = (Node*)C->root(); // Raw memory access needs control + Node* ld = LoadNode::make(_gvn, ctl, C->immutable_memory(), adr, adr_type, t, bt, MemNode::unordered, + LoadNode::DependsOnlyOnTest, false, false, false, false, 0); + return transform(ld); +} + Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt, int adr_idx, MemNode::MemOrd mo, bool require_atomic_access, diff --git a/src/hotspot/share/opto/idealKit.hpp b/src/hotspot/share/opto/idealKit.hpp index 280f61fd9a9..a2ac9e204ba 100644 --- a/src/hotspot/share/opto/idealKit.hpp +++ b/src/hotspot/share/opto/idealKit.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -200,7 +200,7 @@ class IdealKit: public StackObj { // Raw address should be transformed regardless 'delay_transform' flag // to produce canonical form CastX2P(offset). - Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new AddPNode(base, ptr, off)); } + Node* AddP(Node* base, Node* ptr, Node* off) { return _gvn.transform(AddPNode::make_with_base(base, ptr, off)); } Node* CmpP(Node* l, Node* r) { return transform(new CmpPNode(l, r)); } #ifdef _LP64 @@ -224,6 +224,9 @@ class IdealKit: public StackObj { MemNode::MemOrd mo = MemNode::unordered, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest); + // Load AOT runtime constant + Node* load_aot_const(Node* adr, const Type* t); + // Return the new StoreXNode Node* store(Node* ctl, Node* adr, diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp index cd8017f9fb3..762791d467d 100644 --- a/src/hotspot/share/opto/ifnode.cpp +++ b/src/hotspot/share/opto/ifnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -604,7 +604,7 @@ static void adjust_check(IfProjNode* proj, Node* range, Node* index, // at the lowest/nearest dominating check in the graph. To ensure that these Loads/Casts do not float above any of the // dominating checks (even when the lowest dominating check is later replaced by yet another dominating check), we // need to pin them at the lowest dominating check. - proj->pin_array_access_nodes(igvn); + proj->pin_dependent_nodes(igvn); } //------------------------------up_one_dom------------------------------------- @@ -1539,7 +1539,7 @@ Node* IfNode::Ideal(PhaseGVN *phase, bool can_reshape) { } //------------------------------dominated_by----------------------------------- -Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool pin_array_access_nodes) { +Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool prev_dom_not_imply_this) { #ifndef PRODUCT if (TraceIterativeGVN) { tty->print(" Removing IfNode: "); this->dump(); @@ -1570,20 +1570,16 @@ Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool pin_array_ac // Loop ends when projection has no more uses. for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) { Node* s = ifp->last_out(j); // Get child of IfTrue/IfFalse - if (s->depends_only_on_test() && igvn->no_dependent_zero_check(s)) { - // For control producers. - // Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check. + if (s->depends_only_on_test()) { + // For control producers igvn->replace_input_of(s, 0, data_target); // Move child to data-target - if (pin_array_access_nodes && data_target != top) { - // As a result of range check smearing, Loads and range check Cast nodes that are control dependent on this - // range check (that is about to be removed) now depend on multiple dominating range checks. After the removal - // of this range check, these control dependent nodes end up at the lowest/nearest dominating check in the - // graph. To ensure that these Loads/Casts do not float above any of the dominating checks (even when the - // lowest dominating check is later replaced by yet another dominating check), we need to pin them at the - // lowest dominating check. - Node* clone = s->pin_array_access_node(); + if (prev_dom_not_imply_this && data_target != top) { + // If prev_dom_not_imply_this, s now depends on multiple tests with prev_dom being the + // lowest dominating one. As a result, it must be pinned there. Otherwise, it can be + // incorrectly moved to a dominating test equivalent to the lowest one here. + Node* clone = s->pin_node_under_control(); if (clone != nullptr) { - clone = igvn->transform(clone); + igvn->register_new_node_with_optimizer(clone, s); igvn->replace_node(s, clone); } } @@ -1831,16 +1827,15 @@ bool IfNode::is_zero_trip_guard() const { return false; } -void IfProjNode::pin_array_access_nodes(PhaseIterGVN* igvn) { +void IfProjNode::pin_dependent_nodes(PhaseIterGVN* igvn) { for (DUIterator i = outs(); has_out(i); i++) { Node* u = out(i); if (!u->depends_only_on_test()) { continue; } - Node* clone = u->pin_array_access_node(); + Node* clone = u->pin_node_under_control(); if (clone != nullptr) { - clone = igvn->transform(clone); - assert(clone != u, "shouldn't common"); + igvn->register_new_node_with_optimizer(clone, u); igvn->replace_node(u, clone); --i; } diff --git a/src/hotspot/share/opto/intrinsicnode.cpp b/src/hotspot/share/opto/intrinsicnode.cpp index c3e003ad8d3..3e235738e0f 100644 --- a/src/hotspot/share/opto/intrinsicnode.cpp +++ b/src/hotspot/share/opto/intrinsicnode.cpp @@ -273,7 +273,7 @@ static const Type* bitshuffle_value(const TypeInteger* src_type, const TypeInteg // result.lo = 0 if (maskcon != -1L) { int bitcount = population_count(static_cast(bt == T_INT ? maskcon & 0xFFFFFFFFL : maskcon)); - hi = right_n_bits_typed(bitcount); + hi = right_n_bits(bitcount); lo = 0L; } else { // preserve originally assigned hi (MAX_INT/LONG) and lo (MIN_INT/LONG) values @@ -376,7 +376,7 @@ static const Type* bitshuffle_value(const TypeInteger* src_type, const TypeInteg // Rule 3: // We can further constrain the upper bound of bit compression if the number of bits // which can be set(one) is less than the maximum number of bits of integral type. - hi = MIN2(right_n_bits_typed(result_bit_width), hi); + hi = MIN2(right_n_bits(result_bit_width), hi); } } else { assert(opc == Op_ExpandBits, ""); diff --git a/src/hotspot/share/opto/intrinsicnode.hpp b/src/hotspot/share/opto/intrinsicnode.hpp index 2672402881e..d81e7bed7e9 100644 --- a/src/hotspot/share/opto/intrinsicnode.hpp +++ b/src/hotspot/share/opto/intrinsicnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +41,9 @@ class PartialSubtypeCheckNode : public Node { virtual int Opcode() const; virtual const Type* bottom_type() const { return TypeRawPtr::BOTTOM; } virtual uint ideal_reg() const { return Op_RegP; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------StrIntrinsic------------------------------- @@ -74,13 +77,15 @@ class StrIntrinsicNode: public Node { Node(control, char_array_mem, s1, s2), _encoding(encoding) { } - virtual bool depends_only_on_test() const { return false; } virtual const TypePtr* adr_type() const { return TypeAryPtr::BYTES; } virtual uint match_edge(uint idx) const; virtual uint ideal_reg() const { return Op_RegI; } virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); virtual const Type* Value(PhaseGVN* phase) const; ArgEncoding encoding() const { return _encoding; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------StrComp------------------------------------- @@ -172,13 +177,15 @@ class VectorizedHashCodeNode: public Node { VectorizedHashCodeNode(Node* control, Node* ary_mem, Node* arg1, Node* cnt1, Node* result, Node* basic_type) : Node(control, ary_mem, arg1, cnt1, result, basic_type) {}; virtual int Opcode() const; - virtual bool depends_only_on_test() const { return false; } virtual const Type* bottom_type() const { return TypeInt::INT; } virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; } virtual uint match_edge(uint idx) const; virtual uint ideal_reg() const { return Op_RegI; } virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); virtual const Type* Value(PhaseGVN* phase) const; + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------EncodeISOArray-------------------------------- @@ -191,7 +198,6 @@ class EncodeISOArrayNode: public Node { bool is_ascii() { return _ascii; } virtual int Opcode() const; - virtual bool depends_only_on_test() const { return false; } virtual const Type* bottom_type() const { return TypeInt::INT; } virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; } virtual uint match_edge(uint idx) const; @@ -203,6 +209,9 @@ class EncodeISOArrayNode: public Node { virtual bool cmp(const Node& n) const { return Node::cmp(n) && _ascii == ((EncodeISOArrayNode&)n).is_ascii(); } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //-------------------------------DigitNode---------------------------------------- @@ -212,6 +221,9 @@ public: virtual int Opcode() const; const Type* bottom_type() const { return TypeInt::BOOL; } virtual uint ideal_reg() const { return Op_RegI; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------LowerCaseNode------------------------------------ @@ -221,6 +233,9 @@ public: virtual int Opcode() const; const Type* bottom_type() const { return TypeInt::BOOL; } virtual uint ideal_reg() const { return Op_RegI; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------UpperCaseNode------------------------------------ @@ -230,6 +245,9 @@ public: virtual int Opcode() const; const Type* bottom_type() const { return TypeInt::BOOL; } virtual uint ideal_reg() const { return Op_RegI; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------WhitespaceCode----------------------------------- @@ -239,6 +257,9 @@ public: virtual int Opcode() const; const Type* bottom_type() const { return TypeInt::BOOL; } virtual uint ideal_reg() const { return Op_RegI; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------CopySign----------------------------------------- diff --git a/src/hotspot/share/opto/lcm.cpp b/src/hotspot/share/opto/lcm.cpp index 53a503866fa..450d267e821 100644 --- a/src/hotspot/share/opto/lcm.cpp +++ b/src/hotspot/share/opto/lcm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -306,8 +306,7 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo // cannot reason about it; is probably not implicit null exception } else { const TypePtr* tptr; - if ((UseCompressedOops && CompressedOops::shift() == 0) || - (UseCompressedClassPointers && CompressedKlassPointers::shift() == 0)) { + if ((UseCompressedOops && CompressedOops::shift() == 0) || CompressedKlassPointers::shift() == 0) { // 32-bits narrow oop can be the base of address expressions tptr = base->get_ptr_type(); } else { diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index b4e18b596e4..e0f95377cde 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -843,6 +843,22 @@ void LibraryCallKit::set_result(RegionNode* region, PhiNode* value) { assert(value->type()->basic_type() == result()->bottom_type()->basic_type(), "sanity"); } +RegionNode* LibraryCallKit::create_bailout() { + RegionNode* bailout = new RegionNode(1); + record_for_igvn(bailout); + return bailout; +} + +bool LibraryCallKit::check_bailout(RegionNode* bailout) { + if (bailout->req() > 1) { + bailout = _gvn.transform(bailout)->as_Region(); + Node* frame = _gvn.transform(new ParmNode(C->start(), TypeFunc::FramePtr)); + Node* halt = _gvn.transform(new HaltNode(bailout, frame, "unexpected guard failure in intrinsic")); + C->root()->add_req(halt); + } + return stopped(); +} + //------------------------------generate_guard--------------------------- // Helper function for generating guarded fast-slow graph structures. // The given 'test', if true, guards a slow path. If the test fails @@ -951,36 +967,19 @@ void LibraryCallKit::generate_string_range_check(Node* array, Node* offset, Node* count, bool char_count, - bool halt_on_oob) { + RegionNode* region) { if (stopped()) { return; // already stopped } - RegionNode* bailout = new RegionNode(1); - record_for_igvn(bailout); if (char_count) { // Convert char count to byte count count = _gvn.transform(new LShiftINode(count, intcon(1))); } - // Offset and count must not be negative - generate_negative_guard(offset, bailout, nullptr, halt_on_oob); - generate_negative_guard(count, bailout, nullptr, halt_on_oob); + generate_negative_guard(offset, region, nullptr, true); + generate_negative_guard(count, region, nullptr, true); // Offset + count must not exceed length of array - generate_limit_guard(offset, count, load_array_length(array), bailout, halt_on_oob); - - if (bailout->req() > 1) { - if (halt_on_oob) { - bailout = _gvn.transform(bailout)->as_Region(); - Node* frame = _gvn.transform(new ParmNode(C->start(), TypeFunc::FramePtr)); - Node* halt = _gvn.transform(new HaltNode(bailout, frame, "unexpected guard failure in intrinsic")); - C->root()->add_req(halt); - } else { - PreserveJVMState pjvms(this); - set_control(_gvn.transform(bailout)); - uncommon_trap(Deoptimization::Reason_intrinsic, - Deoptimization::Action_maybe_recompile); - } - } + generate_limit_guard(offset, count, load_array_length(array), region, true); } Node* LibraryCallKit::current_thread_helper(Node*& tls_output, ByteSize handle_offset, @@ -990,7 +989,7 @@ Node* LibraryCallKit::current_thread_helper(Node*& tls_output, ByteSize handle_o = TypeOopPtr::make_from_klass(thread_klass)->cast_to_ptr_type(TypePtr::NotNull); Node* thread = _gvn.transform(new ThreadLocalNode()); - Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(handle_offset)); + Node* p = off_heap_plus_addr(thread, in_bytes(handle_offset)); tls_output = thread; Node* thread_obj_handle @@ -1139,10 +1138,6 @@ bool LibraryCallKit::inline_array_equals(StrIntrinsicNode::ArgEnc ae) { //------------------------------inline_countPositives------------------------------ // int java.lang.StringCoding#countPositives0(byte[] ba, int off, int len) bool LibraryCallKit::inline_countPositives() { - if (too_many_traps(Deoptimization::Reason_intrinsic)) { - return false; - } - assert(callee()->signature()->size() == 3, "countPositives has 3 parameters"); // no receiver since it is static method Node* ba = argument(0); @@ -1150,8 +1145,9 @@ bool LibraryCallKit::inline_countPositives() { Node* len = argument(2); ba = must_be_not_null(ba, true); - generate_string_range_check(ba, offset, len, false, true); - if (stopped()) { + RegionNode* bailout = create_bailout(); + generate_string_range_check(ba, offset, len, false, bailout); + if (check_bailout(bailout)) { return true; } @@ -1283,9 +1279,6 @@ bool LibraryCallKit::inline_string_indexOf(StrIntrinsicNode::ArgEnc ae) { //-----------------------------inline_string_indexOfI----------------------- bool LibraryCallKit::inline_string_indexOfI(StrIntrinsicNode::ArgEnc ae) { - if (too_many_traps(Deoptimization::Reason_intrinsic)) { - return false; - } if (!Matcher::match_rule_supported(Op_StrIndexOf)) { return false; } @@ -1307,9 +1300,10 @@ bool LibraryCallKit::inline_string_indexOfI(StrIntrinsicNode::ArgEnc ae) { Node* tgt_start = array_element_address(tgt, intcon(0), T_BYTE); // Range checks - generate_string_range_check(src, src_offset, src_count, ae != StrIntrinsicNode::LL); - generate_string_range_check(tgt, intcon(0), tgt_count, ae == StrIntrinsicNode::UU); - if (stopped()) { + RegionNode* bailout = create_bailout(); + generate_string_range_check(src, src_offset, src_count, ae != StrIntrinsicNode::LL, bailout); + generate_string_range_check(tgt, intcon(0), tgt_count, ae == StrIntrinsicNode::UU, bailout); + if (check_bailout(bailout)) { return true; } @@ -1404,7 +1398,11 @@ bool LibraryCallKit::inline_string_indexOfChar(StrIntrinsicNode::ArgEnc ae) { Node* src_count = _gvn.transform(new SubINode(max, from_index)); // Range checks - generate_string_range_check(src, src_offset, src_count, ae == StrIntrinsicNode::U); + RegionNode* bailout = create_bailout(); + generate_string_range_check(src, src_offset, src_count, ae == StrIntrinsicNode::U, bailout); + if (check_bailout(bailout)) { + return true; + } // Check for int_ch >= 0 Node* int_ch_cmp = _gvn.transform(new CmpINode(int_ch, intcon(0))); @@ -1448,15 +1446,12 @@ bool LibraryCallKit::inline_string_indexOfChar(StrIntrinsicNode::ArgEnc ae) { } //---------------------------inline_string_copy--------------------- // compressIt == true --> generate a compressed copy operation (compress char[]/byte[] to byte[]) -// int StringUTF16.compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) -// int StringUTF16.compress(byte[] src, int srcOff, byte[] dst, int dstOff, int len) +// int StringUTF16.compress0(char[] src, int srcOff, byte[] dst, int dstOff, int len) +// int StringUTF16.compress0(byte[] src, int srcOff, byte[] dst, int dstOff, int len) // compressIt == false --> generate an inflated copy operation (inflate byte[] to char[]/byte[]) -// void StringLatin1.inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) -// void StringLatin1.inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) +// void StringLatin1.inflate0(byte[] src, int srcOff, char[] dst, int dstOff, int len) +// void StringLatin1.inflate0(byte[] src, int srcOff, byte[] dst, int dstOff, int len) bool LibraryCallKit::inline_string_copy(bool compress) { - if (too_many_traps(Deoptimization::Reason_intrinsic)) { - return false; - } int nargs = 5; // 2 oops, 3 ints assert(callee()->signature()->size() == nargs, "string copy has 5 arguments"); @@ -1495,9 +1490,10 @@ bool LibraryCallKit::inline_string_copy(bool compress) { } // Range checks - generate_string_range_check(src, src_offset, length, convert_src); - generate_string_range_check(dst, dst_offset, length, convert_dst); - if (stopped()) { + RegionNode* bailout = create_bailout(); + generate_string_range_check(src, src_offset, length, convert_src, bailout); + generate_string_range_check(dst, dst_offset, length, convert_dst, bailout); + if (check_bailout(bailout)) { return true; } @@ -1545,12 +1541,10 @@ bool LibraryCallKit::inline_string_copy(bool compress) { #endif //_LP64 //------------------------inline_string_toBytesU-------------------------- -// public static byte[] StringUTF16.toBytes(char[] value, int off, int len) +// public static byte[] StringUTF16.toBytes0(char[] value, int off, int len) bool LibraryCallKit::inline_string_toBytesU() { - if (too_many_traps(Deoptimization::Reason_intrinsic)) { - return false; - } // Get the arguments. + assert(callee()->signature()->size() == 3, "character array encoder requires 3 arguments"); Node* value = argument(0); Node* offset = argument(1); Node* length = argument(2); @@ -1558,30 +1552,18 @@ bool LibraryCallKit::inline_string_toBytesU() { Node* newcopy = nullptr; // Set the original stack and the reexecute bit for the interpreter to reexecute - // the bytecode that invokes StringUTF16.toBytes() if deoptimization happens. + // the bytecode that invokes StringUTF16.toBytes0() if deoptimization happens. { PreserveReexecuteState preexecs(this); jvms()->set_should_reexecute(true); - // Check if a null path was taken unconditionally. - value = null_check(value); - - RegionNode* bailout = new RegionNode(1); - record_for_igvn(bailout); - - // Range checks - generate_negative_guard(offset, bailout); - generate_negative_guard(length, bailout); - generate_limit_guard(offset, length, load_array_length(value), bailout); + value = must_be_not_null(value, true); + RegionNode* bailout = create_bailout(); + generate_negative_guard(offset, bailout, nullptr, true); + generate_negative_guard(length, bailout, nullptr, true); + generate_limit_guard(offset, length, load_array_length(value), bailout, true); // Make sure that resulting byte[] length does not overflow Integer.MAX_VALUE - generate_limit_guard(length, intcon(0), intcon(max_jint/2), bailout); - - if (bailout->req() > 1) { - PreserveJVMState pjvms(this); - set_control(_gvn.transform(bailout)); - uncommon_trap(Deoptimization::Reason_intrinsic, - Deoptimization::Action_maybe_recompile); - } - if (stopped()) { + generate_limit_guard(length, intcon(0), intcon(max_jint/2), bailout, true); + if (check_bailout(bailout)) { return true; } @@ -1640,12 +1622,9 @@ bool LibraryCallKit::inline_string_toBytesU() { } //------------------------inline_string_getCharsU-------------------------- -// public void StringUTF16.getChars(byte[] src, int srcBegin, int srcEnd, char dst[], int dstBegin) +// public void StringUTF16.getChars0(byte[] src, int srcBegin, int srcEnd, char dst[], int dstBegin) bool LibraryCallKit::inline_string_getCharsU() { - if (too_many_traps(Deoptimization::Reason_intrinsic)) { - return false; - } - + assert(callee()->signature()->size() == 5, "StringUTF16.getChars0() has 5 arguments"); // Get the arguments. Node* src = argument(0); Node* src_begin = argument(1); @@ -1658,8 +1637,8 @@ bool LibraryCallKit::inline_string_getCharsU() { AllocateArrayNode* alloc = tightly_coupled_allocation(dst); // Check if a null path was taken unconditionally. - src = null_check(src); - dst = null_check(dst); + src = must_be_not_null(src, true); + dst = must_be_not_null(dst, true); if (stopped()) { return true; } @@ -1669,51 +1648,50 @@ bool LibraryCallKit::inline_string_getCharsU() { src_begin = _gvn.transform(new LShiftINode(src_begin, intcon(1))); // Range checks - generate_string_range_check(src, src_begin, length, true); - generate_string_range_check(dst, dst_begin, length, false); - if (stopped()) { + RegionNode* bailout = create_bailout(); + generate_string_range_check(src, src_begin, length, true, bailout); + generate_string_range_check(dst, dst_begin, length, false, bailout); + if (check_bailout(bailout)) { return true; } - if (!stopped()) { - // Calculate starting addresses. - Node* src_start = array_element_address(src, src_begin, T_BYTE); - Node* dst_start = array_element_address(dst, dst_begin, T_CHAR); + // Calculate starting addresses. + Node* src_start = array_element_address(src, src_begin, T_BYTE); + Node* dst_start = array_element_address(dst, dst_begin, T_CHAR); - // Check if array addresses are aligned to HeapWordSize - const TypeInt* tsrc = gvn().type(src_begin)->is_int(); - const TypeInt* tdst = gvn().type(dst_begin)->is_int(); - bool aligned = tsrc->is_con() && ((arrayOopDesc::base_offset_in_bytes(T_BYTE) + tsrc->get_con() * type2aelembytes(T_BYTE)) % HeapWordSize == 0) && - tdst->is_con() && ((arrayOopDesc::base_offset_in_bytes(T_CHAR) + tdst->get_con() * type2aelembytes(T_CHAR)) % HeapWordSize == 0); + // Check if array addresses are aligned to HeapWordSize + const TypeInt* tsrc = gvn().type(src_begin)->is_int(); + const TypeInt* tdst = gvn().type(dst_begin)->is_int(); + bool aligned = tsrc->is_con() && ((arrayOopDesc::base_offset_in_bytes(T_BYTE) + tsrc->get_con() * type2aelembytes(T_BYTE)) % HeapWordSize == 0) && + tdst->is_con() && ((arrayOopDesc::base_offset_in_bytes(T_CHAR) + tdst->get_con() * type2aelembytes(T_CHAR)) % HeapWordSize == 0); - // Figure out which arraycopy runtime method to call (disjoint, uninitialized). - const char* copyfunc_name = "arraycopy"; - address copyfunc_addr = StubRoutines::select_arraycopy_function(T_CHAR, aligned, true, copyfunc_name, true); - Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, - OptoRuntime::fast_arraycopy_Type(), - copyfunc_addr, copyfunc_name, TypeRawPtr::BOTTOM, - src_start, dst_start, ConvI2X(length) XTOP); - // Do not let reads from the cloned object float above the arraycopy. - if (alloc != nullptr) { - if (alloc->maybe_set_complete(&_gvn)) { - // "You break it, you buy it." - InitializeNode* init = alloc->initialization(); - assert(init->is_complete(), "we just did this"); - init->set_complete_with_arraycopy(); - assert(dst->is_CheckCastPP(), "sanity"); - assert(dst->in(0)->in(0) == init, "dest pinned"); - } - // Do not let stores that initialize this object be reordered with - // a subsequent store that would make this object accessible by - // other threads. - // Record what AllocateNode this StoreStore protects so that - // escape analysis can go from the MemBarStoreStoreNode to the - // AllocateNode and eliminate the MemBarStoreStoreNode if possible - // based on the escape status of the AllocateNode. - insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out_or_null(AllocateNode::RawAddress)); - } else { - insert_mem_bar(Op_MemBarCPUOrder); + // Figure out which arraycopy runtime method to call (disjoint, uninitialized). + const char* copyfunc_name = "arraycopy"; + address copyfunc_addr = StubRoutines::select_arraycopy_function(T_CHAR, aligned, true, copyfunc_name, true); + Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, + OptoRuntime::fast_arraycopy_Type(), + copyfunc_addr, copyfunc_name, TypeRawPtr::BOTTOM, + src_start, dst_start, ConvI2X(length) XTOP); + // Do not let reads from the cloned object float above the arraycopy. + if (alloc != nullptr) { + if (alloc->maybe_set_complete(&_gvn)) { + // "You break it, you buy it." + InitializeNode* init = alloc->initialization(); + assert(init->is_complete(), "we just did this"); + init->set_complete_with_arraycopy(); + assert(dst->is_CheckCastPP(), "sanity"); + assert(dst->in(0)->in(0) == init, "dest pinned"); } + // Do not let stores that initialize this object be reordered with + // a subsequent store that would make this object accessible by + // other threads. + // Record what AllocateNode this StoreStore protects so that + // escape analysis can go from the MemBarStoreStoreNode to the + // AllocateNode and eliminate the MemBarStoreStoreNode if possible + // based on the escape status of the AllocateNode. + insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out_or_null(AllocateNode::RawAddress)); + } else { + insert_mem_bar(Op_MemBarCPUOrder); } C->set_has_split_ifs(true); // Has chance for split-if optimization @@ -1725,9 +1703,16 @@ bool LibraryCallKit::inline_string_getCharsU() { // static void StringUTF16.putChar(byte[] val, int index, int c) // static char StringUTF16.getChar(byte[] val, int index) bool LibraryCallKit::inline_string_char_access(bool is_store) { + Node* ch; + if (is_store) { + assert(callee()->signature()->size() == 3, "StringUTF16.putChar() has 3 arguments"); + ch = argument(2); + } else { + assert(callee()->signature()->size() == 2, "StringUTF16.getChar() has 2 arguments"); + ch = nullptr; + } Node* value = argument(0); Node* index = argument(1); - Node* ch = is_store ? argument(2) : nullptr; // This intrinsic accesses byte[] array as char[] array. Computing the offsets // correctly requires matched array shapes. @@ -1834,61 +1819,17 @@ bool LibraryCallKit::runtime_math(const TypeFunc* call_type, address funcAddr, c //------------------------------inline_math_pow----------------------------- bool LibraryCallKit::inline_math_pow() { + Node* base = argument(0); Node* exp = argument(2); - const TypeD* d = _gvn.type(exp)->isa_double_constant(); - if (d != nullptr) { - if (d->getd() == 2.0) { - // Special case: pow(x, 2.0) => x * x - Node* base = argument(0); - set_result(_gvn.transform(new MulDNode(base, base))); - return true; - } else if (d->getd() == 0.5 && Matcher::match_rule_supported(Op_SqrtD)) { - // Special case: pow(x, 0.5) => sqrt(x) - Node* base = argument(0); - Node* zero = _gvn.zerocon(T_DOUBLE); - RegionNode* region = new RegionNode(3); - Node* phi = new PhiNode(region, Type::DOUBLE); - - Node* cmp = _gvn.transform(new CmpDNode(base, zero)); - // According to the API specs, pow(-0.0, 0.5) = 0.0 and sqrt(-0.0) = -0.0. - // So pow(-0.0, 0.5) shouldn't be replaced with sqrt(-0.0). - // -0.0/+0.0 are both excluded since floating-point comparison doesn't distinguish -0.0 from +0.0. - Node* test = _gvn.transform(new BoolNode(cmp, BoolTest::le)); - - Node* if_pow = generate_slow_guard(test, nullptr); - Node* value_sqrt = _gvn.transform(new SqrtDNode(C, control(), base)); - phi->init_req(1, value_sqrt); - region->init_req(1, control()); - - if (if_pow != nullptr) { - set_control(if_pow); - address target = StubRoutines::dpow() != nullptr ? StubRoutines::dpow() : - CAST_FROM_FN_PTR(address, SharedRuntime::dpow); - const TypePtr* no_memory_effects = nullptr; - Node* trig = make_runtime_call(RC_LEAF, OptoRuntime::Math_DD_D_Type(), target, "POW", - no_memory_effects, base, top(), exp, top()); - Node* value_pow = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+0)); -#ifdef ASSERT - Node* value_top = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+1)); - assert(value_top == top(), "second value must be top"); -#endif - phi->init_req(2, value_pow); - region->init_req(2, _gvn.transform(new ProjNode(trig, TypeFunc::Control))); - } - - C->set_has_split_ifs(true); // Has chance for split-if optimization - set_control(_gvn.transform(region)); - record_for_igvn(region); - set_result(_gvn.transform(phi)); - - return true; - } - } - - return StubRoutines::dpow() != nullptr ? - runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(), "dpow") : - runtime_math(OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); + CallNode* pow = new PowDNode(C, base, exp); + set_predefined_input_for_runtime_call(pow); + pow = _gvn.transform(pow)->as_CallLeafPure(); + set_predefined_output_for_runtime_call(pow); + Node* result = _gvn.transform(new ProjNode(pow, TypeFunc::Parms + 0)); + record_for_igvn(pow); + set_result(result); + return true; } //------------------------------inline_math_native----------------------------- @@ -2176,7 +2117,7 @@ Node* LibraryCallKit::make_unsafe_address(Node*& base, Node* offset, BasicType t Node* uncasted_base = base; int kind = classify_unsafe_addr(uncasted_base, offset, type); if (kind == Type::RawPtr) { - return basic_plus_adr(top(), uncasted_base, offset); + return off_heap_plus_addr(uncasted_base, offset); } else if (kind == Type::AnyPtr) { assert(base == uncasted_base, "unexpected base change"); if (can_cast) { @@ -2196,13 +2137,13 @@ Node* LibraryCallKit::make_unsafe_address(Node*& base, Node* offset, BasicType t base = null_assert(base); Node* raw_base = _gvn.transform(new CastX2PNode(offset)); offset = MakeConX(0); - return basic_plus_adr(top(), raw_base, offset); + return off_heap_plus_addr(raw_base, offset); } } // We don't know if it's an on heap or off heap access. Fall back // to raw memory access. Node* raw = _gvn.transform(new CheckCastPPNode(control(), base, TypeRawPtr::BOTTOM)); - return basic_plus_adr(top(), raw, offset); + return off_heap_plus_addr(raw, offset); } else { assert(base == uncasted_base, "unexpected base change"); // We know it's an on heap access so base can't be null @@ -2393,47 +2334,6 @@ DecoratorSet LibraryCallKit::mo_decorator_for_access_kind(AccessKind kind) { } } -LibraryCallKit::SavedState::SavedState(LibraryCallKit* kit) : - _kit(kit), - _sp(kit->sp()), - _jvms(kit->jvms()), - _map(kit->clone_map()), - _discarded(false) -{ - for (DUIterator_Fast imax, i = kit->control()->fast_outs(imax); i < imax; i++) { - Node* out = kit->control()->fast_out(i); - if (out->is_CFG()) { - _ctrl_succ.push(out); - } - } -} - -LibraryCallKit::SavedState::~SavedState() { - if (_discarded) { - _kit->destruct_map_clone(_map); - return; - } - _kit->jvms()->set_map(_map); - _kit->jvms()->set_sp(_sp); - _map->set_jvms(_kit->jvms()); - _kit->set_map(_map); - _kit->set_sp(_sp); - for (DUIterator_Fast imax, i = _kit->control()->fast_outs(imax); i < imax; i++) { - Node* out = _kit->control()->fast_out(i); - if (out->is_CFG() && out->in(0) == _kit->control() && out != _kit->map() && !_ctrl_succ.member(out)) { - _kit->_gvn.hash_delete(out); - out->set_req(0, _kit->C->top()); - _kit->C->record_for_igvn(out); - --i; --imax; - _kit->_gvn.hash_find_insert(out); - } - } -} - -void LibraryCallKit::SavedState::discard() { - _discarded = true; -} - bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, const AccessKind kind, const bool unaligned) { if (callee()->is_static()) return false; // caller must have the capability! DecoratorSet decorators = C2_UNSAFE_ACCESS; @@ -2900,7 +2800,7 @@ bool LibraryCallKit::inline_unsafe_fence(vmIntrinsics::ID id) { insert_mem_bar(Op_StoreStoreFence); return true; case vmIntrinsics::_fullFence: - insert_mem_bar(Op_MemBarVolatile); + insert_mem_bar(Op_MemBarFull); return true; default: fatal_unexpected_iid(id); @@ -3018,7 +2918,7 @@ bool LibraryCallKit::inline_unsafe_allocate() { // Note: The argument might still be an illegal value like // Serializable.class or Object[].class. The runtime will handle it. // But we must make an explicit check for initialization. - Node* insp = basic_plus_adr(top(), kls, in_bytes(InstanceKlass::init_state_offset())); + Node* insp = off_heap_plus_addr(kls, in_bytes(InstanceKlass::init_state_offset())); // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler // can generate code to load it as unsigned byte. Node* inst = make_load(nullptr, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::acquire); @@ -3062,26 +2962,27 @@ bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* func // slow path: runtime call // } bool LibraryCallKit::inline_native_vthread_start_transition(address funcAddr, const char* funcName, bool is_final_transition) { - Node* vt_oop = _gvn.transform(must_be_not_null(argument(0), true)); // VirtualThread this argument + Node* vt_oop = must_be_not_null(argument(0), true); // VirtualThread this argument IdealKit ideal(this); Node* thread = ideal.thread(); - Node* jt_addr = basic_plus_adr(top(), thread, in_bytes(JavaThread::is_in_vthread_transition_offset())); + Node* jt_addr = off_heap_plus_addr(thread, in_bytes(JavaThread::is_in_vthread_transition_offset())); Node* vt_addr = basic_plus_adr(vt_oop, java_lang_Thread::is_in_vthread_transition_offset()); access_store_at(nullptr, jt_addr, _gvn.type(jt_addr)->is_ptr(), ideal.ConI(1), TypeInt::BOOL, T_BOOLEAN, IN_NATIVE | MO_UNORDERED); access_store_at(nullptr, vt_addr, _gvn.type(vt_addr)->is_ptr(), ideal.ConI(1), TypeInt::BOOL, T_BOOLEAN, IN_NATIVE | MO_UNORDERED); - insert_mem_bar(Op_MemBarVolatile); + insert_mem_bar(Op_MemBarStoreLoad); ideal.sync_kit(this); Node* global_disable_addr = makecon(TypeRawPtr::make((address)MountUnmountDisabler::global_vthread_transition_disable_count_address())); Node* global_disable = ideal.load(ideal.ctrl(), global_disable_addr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, true /*require_atomic_access*/); Node* vt_disable_addr = basic_plus_adr(vt_oop, java_lang_Thread::vthread_transition_disable_count_offset()); - Node* vt_disable = ideal.load(ideal.ctrl(), vt_disable_addr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, true /*require_atomic_access*/); + const TypePtr* vt_disable_addr_t = _gvn.type(vt_disable_addr)->is_ptr(); + Node* vt_disable = ideal.load(ideal.ctrl(), vt_disable_addr, TypeInt::INT, T_INT, C->get_alias_index(vt_disable_addr_t), true /*require_atomic_access*/); Node* disabled = _gvn.transform(new AddINode(global_disable, vt_disable)); ideal.if_then(disabled, BoolTest::ne, ideal.ConI(0)); { sync_kit(ideal); - Node* is_mount = is_final_transition ? ideal.ConI(0) : _gvn.transform(argument(1)); + Node* is_mount = is_final_transition ? ideal.ConI(0) : argument(1); const TypeFunc* tf = OptoRuntime::vthread_transition_Type(); make_runtime_call(RC_NO_LEAF, tf, funcAddr, funcName, TypePtr::BOTTOM, vt_oop, is_mount); ideal.sync_kit(this); @@ -3093,7 +2994,7 @@ bool LibraryCallKit::inline_native_vthread_start_transition(address funcAddr, co } bool LibraryCallKit::inline_native_vthread_end_transition(address funcAddr, const char* funcName, bool is_first_transition) { - Node* vt_oop = _gvn.transform(must_be_not_null(argument(0), true)); // VirtualThread this argument + Node* vt_oop = must_be_not_null(argument(0), true); // VirtualThread this argument IdealKit ideal(this); Node* _notify_jvmti_addr = makecon(TypeRawPtr::make((address)MountUnmountDisabler::notify_jvmti_events_address())); @@ -3101,13 +3002,13 @@ bool LibraryCallKit::inline_native_vthread_end_transition(address funcAddr, cons ideal.if_then(_notify_jvmti, BoolTest::eq, ideal.ConI(1)); { sync_kit(ideal); - Node* is_mount = is_first_transition ? ideal.ConI(1) : _gvn.transform(argument(1)); + Node* is_mount = is_first_transition ? ideal.ConI(1) : argument(1); const TypeFunc* tf = OptoRuntime::vthread_transition_Type(); make_runtime_call(RC_NO_LEAF, tf, funcAddr, funcName, TypePtr::BOTTOM, vt_oop, is_mount); ideal.sync_kit(this); } ideal.else_(); { Node* thread = ideal.thread(); - Node* jt_addr = basic_plus_adr(top(), thread, in_bytes(JavaThread::is_in_vthread_transition_offset())); + Node* jt_addr = off_heap_plus_addr(thread, in_bytes(JavaThread::is_in_vthread_transition_offset())); Node* vt_addr = basic_plus_adr(vt_oop, java_lang_Thread::is_in_vthread_transition_offset()); sync_kit(ideal); @@ -3132,8 +3033,8 @@ bool LibraryCallKit::inline_native_notify_jvmti_sync() { { // unconditionally update the is_disable_suspend bit in current JavaThread Node* thread = ideal.thread(); - Node* arg = _gvn.transform(argument(0)); // argument for notification - Node* addr = basic_plus_adr(top(), thread, in_bytes(JavaThread::is_disable_suspend_offset())); + Node* arg = argument(0); // argument for notification + Node* addr = off_heap_plus_addr(thread, in_bytes(JavaThread::is_disable_suspend_offset())); const TypePtr *addr_type = _gvn.type(addr)->isa_ptr(); sync_kit(ideal); @@ -3212,7 +3113,7 @@ bool LibraryCallKit::inline_native_classID() { ideal.set(result, _gvn.transform(new AddLNode(array_kls_trace_id, longcon(1)))); } __ else_(); { // void class case - ideal.set(result, _gvn.transform(longcon(LAST_TYPE_ID + 1))); + ideal.set(result, longcon(LAST_TYPE_ID + 1)); } __ end_if(); Node* signaled_flag_address = makecon(TypeRawPtr::make(JfrIntrinsicSupport::signal_address())); @@ -3240,12 +3141,12 @@ bool LibraryCallKit::inline_native_jvm_commit() { // TLS. Node* tls_ptr = _gvn.transform(new ThreadLocalNode()); // Jfr java buffer. - Node* java_buffer_offset = _gvn.transform(new AddPNode(top(), tls_ptr, _gvn.transform(MakeConX(in_bytes(JAVA_BUFFER_OFFSET_JFR))))); + Node* java_buffer_offset = _gvn.transform(AddPNode::make_off_heap(tls_ptr, MakeConX(in_bytes(JAVA_BUFFER_OFFSET_JFR)))); Node* java_buffer = _gvn.transform(new LoadPNode(control(), input_memory_state, java_buffer_offset, TypePtr::BOTTOM, TypeRawPtr::NOTNULL, MemNode::unordered)); - Node* java_buffer_pos_offset = _gvn.transform(new AddPNode(top(), java_buffer, _gvn.transform(MakeConX(in_bytes(JFR_BUFFER_POS_OFFSET))))); + Node* java_buffer_pos_offset = _gvn.transform(AddPNode::make_off_heap(java_buffer, MakeConX(in_bytes(JFR_BUFFER_POS_OFFSET)))); // Load the current value of the notified field in the JfrThreadLocal. - Node* notified_offset = basic_plus_adr(top(), tls_ptr, in_bytes(NOTIFY_OFFSET_JFR)); + Node* notified_offset = off_heap_plus_addr(tls_ptr, in_bytes(NOTIFY_OFFSET_JFR)); Node* notified = make_load(control(), notified_offset, TypeInt::BOOL, T_BOOLEAN, MemNode::unordered); // Test for notification. @@ -3264,7 +3165,7 @@ bool LibraryCallKit::inline_native_jvm_commit() { // Iff notified, the return address of the commit method is the current position of the backing java buffer. This is used to reset the event writer. Node* current_pos_X = _gvn.transform(new LoadXNode(control(), input_memory_state, java_buffer_pos_offset, TypeRawPtr::NOTNULL, TypeX_X, MemNode::unordered)); // Convert the machine-word to a long. - Node* current_pos = _gvn.transform(ConvX2L(current_pos_X)); + Node* current_pos = ConvX2L(current_pos_X); // False branch, not notified. Node* not_notified = _gvn.transform(new IfFalseNode(iff_notified)); @@ -3274,7 +3175,7 @@ bool LibraryCallKit::inline_native_jvm_commit() { // Arg is the next position as a long. Node* arg = argument(0); // Convert long to machine-word. - Node* next_pos_X = _gvn.transform(ConvL2X(arg)); + Node* next_pos_X = ConvL2X(arg); // Store the next_position to the underlying jfr java buffer. store_to_memory(control(), java_buffer_pos_offset, next_pos_X, LP64_ONLY(T_LONG) NOT_LP64(T_INT), MemNode::release); @@ -3283,9 +3184,9 @@ bool LibraryCallKit::inline_native_jvm_commit() { set_all_memory(commit_memory); // Now load the flags from off the java buffer and decide if the buffer is a lease. If so, it needs to be returned post-commit. - Node* java_buffer_flags_offset = _gvn.transform(new AddPNode(top(), java_buffer, _gvn.transform(MakeConX(in_bytes(JFR_BUFFER_FLAGS_OFFSET))))); + Node* java_buffer_flags_offset = _gvn.transform(AddPNode::make_off_heap(java_buffer, MakeConX(in_bytes(JFR_BUFFER_FLAGS_OFFSET)))); Node* flags = make_load(control(), java_buffer_flags_offset, TypeInt::UBYTE, T_BYTE, MemNode::unordered); - Node* lease_constant = _gvn.transform(_gvn.intcon(4)); + Node* lease_constant = _gvn.intcon(4); // And flags with lease constant. Node* lease = _gvn.transform(new AndINode(flags, lease_constant)); @@ -3322,7 +3223,7 @@ bool LibraryCallKit::inline_native_jvm_commit() { lease_compare_rgn->init_req(_true_path, call_return_lease_control); lease_compare_rgn->init_req(_false_path, not_lease); - lease_compare_mem->init_req(_true_path, _gvn.transform(reset_memory())); + lease_compare_mem->init_req(_true_path, reset_memory()); lease_compare_mem->init_req(_false_path, commit_memory); lease_compare_io->init_req(_true_path, i_o()); @@ -3415,7 +3316,7 @@ bool LibraryCallKit::inline_native_getEventWriter() { Node* tls_ptr = _gvn.transform(new ThreadLocalNode()); // Load the address of java event writer jobject handle from the jfr_thread_local structure. - Node* jobj_ptr = basic_plus_adr(top(), tls_ptr, in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR)); + Node* jobj_ptr = off_heap_plus_addr(tls_ptr, in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR)); // Load the eventwriter jobject handle. Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered); @@ -3480,10 +3381,10 @@ bool LibraryCallKit::inline_native_getEventWriter() { IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD); // Mask off the excluded information from the epoch. - Node * vthread_is_excluded = _gvn.transform(new AndINode(vthread_epoch_raw, _gvn.transform(excluded_mask))); + Node * vthread_is_excluded = _gvn.transform(new AndINode(vthread_epoch_raw, excluded_mask)); // Branch on excluded to conditionalize updating the epoch for the virtual thread. - Node* is_excluded_cmp = _gvn.transform(new CmpINode(vthread_is_excluded, _gvn.transform(excluded_mask))); + Node* is_excluded_cmp = _gvn.transform(new CmpINode(vthread_is_excluded, excluded_mask)); Node* test_not_excluded = _gvn.transform(new BoolNode(is_excluded_cmp, BoolTest::ne)); IfNode* iff_not_excluded = create_and_map_if(control(), test_not_excluded, PROB_MAX, COUNT_UNKNOWN); @@ -3495,7 +3396,7 @@ bool LibraryCallKit::inline_native_getEventWriter() { set_control(included); // Get epoch value. - Node* epoch = _gvn.transform(new AndINode(vthread_epoch_raw, _gvn.transform(epoch_mask))); + Node* epoch = _gvn.transform(new AndINode(vthread_epoch_raw, epoch_mask)); // Load the current epoch generation. The value is unsigned 16-bit, so we type it as T_CHAR. Node* epoch_generation_address = makecon(TypeRawPtr::make(JfrIntrinsicSupport::epoch_generation_address())); @@ -3533,7 +3434,7 @@ bool LibraryCallKit::inline_native_getEventWriter() { // Update control and phi nodes. epoch_compare_rgn->init_req(_true_path, call_write_checkpoint_control); epoch_compare_rgn->init_req(_false_path, epoch_is_equal); - epoch_compare_mem->init_req(_true_path, _gvn.transform(reset_memory())); + epoch_compare_mem->init_req(_true_path, reset_memory()); epoch_compare_mem->init_req(_false_path, input_memory_state); epoch_compare_io->init_req(_true_path, i_o()); epoch_compare_io->init_req(_false_path, input_io_state); @@ -3574,11 +3475,11 @@ bool LibraryCallKit::inline_native_getEventWriter() { vthread_compare_mem->init_req(_false_path, input_memory_state); vthread_compare_io->init_req(_true_path, _gvn.transform(exclude_compare_io)); vthread_compare_io->init_req(_false_path, input_io_state); - tid->init_req(_true_path, _gvn.transform(vthread_tid)); - tid->init_req(_false_path, _gvn.transform(thread_obj_tid)); - exclusion->init_req(_true_path, _gvn.transform(vthread_is_excluded)); - exclusion->init_req(_false_path, _gvn.transform(threadObj_is_excluded)); - pinVirtualThread->init_req(_true_path, _gvn.transform(continuation_support)); + tid->init_req(_true_path, vthread_tid); + tid->init_req(_false_path, thread_obj_tid); + exclusion->init_req(_true_path, vthread_is_excluded); + exclusion->init_req(_false_path, threadObj_is_excluded); + pinVirtualThread->init_req(_true_path, continuation_support); pinVirtualThread->init_req(_false_path, _gvn.intcon(0)); // Update branch state. @@ -3592,7 +3493,7 @@ bool LibraryCallKit::inline_native_getEventWriter() { ciInstanceKlass* const instklass_EventWriter = klass_EventWriter->as_instance_klass(); const TypeKlassPtr* const aklass = TypeKlassPtr::make(instklass_EventWriter); const TypeOopPtr* const xtype = aklass->as_instance_type(); - Node* jobj_untagged = _gvn.transform(new AddPNode(top(), jobj, _gvn.MakeConX(-JNIHandles::TypeTag::global))); + Node* jobj_untagged = _gvn.transform(AddPNode::make_off_heap(jobj, _gvn.MakeConX(-JNIHandles::TypeTag::global))); Node* event_writer = access_load(jobj_untagged, xtype, T_OBJECT, IN_NATIVE | C2_CONTROL_DEPENDENT_LOAD); // Load the current thread id from the event writer object. @@ -3636,9 +3537,9 @@ bool LibraryCallKit::inline_native_getEventWriter() { // Update control and phi nodes. event_writer_tid_compare_rgn->init_req(_true_path, tid_is_not_equal); event_writer_tid_compare_rgn->init_req(_false_path, tid_is_equal); - event_writer_tid_compare_mem->init_req(_true_path, _gvn.transform(reset_memory())); + event_writer_tid_compare_mem->init_req(_true_path, reset_memory()); event_writer_tid_compare_mem->init_req(_false_path, _gvn.transform(vthread_compare_mem)); - event_writer_tid_compare_io->init_req(_true_path, _gvn.transform(i_o())); + event_writer_tid_compare_io->init_req(_true_path, i_o()); event_writer_tid_compare_io->init_req(_false_path, _gvn.transform(vthread_compare_io)); // Result of top level CFG, Memory, IO and Value. @@ -3653,14 +3554,14 @@ bool LibraryCallKit::inline_native_getEventWriter() { // Result memory. result_mem->init_req(_true_path, _gvn.transform(event_writer_tid_compare_mem)); - result_mem->init_req(_false_path, _gvn.transform(input_memory_state)); + result_mem->init_req(_false_path, input_memory_state); // Result IO. result_io->init_req(_true_path, _gvn.transform(event_writer_tid_compare_io)); - result_io->init_req(_false_path, _gvn.transform(input_io_state)); + result_io->init_req(_false_path, input_io_state); // Result value. - result_value->init_req(_true_path, _gvn.transform(event_writer)); // return event writer oop + result_value->init_req(_true_path, event_writer); // return event writer oop result_value->init_req(_false_path, null()); // return null // Set output state. @@ -3707,7 +3608,7 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { IfNode* iff_thread_not_equal_carrierThread = create_and_map_if(control(), test_thread_not_equal_carrierThread, PROB_FAIR, COUNT_UNKNOWN); - Node* vthread_offset = basic_plus_adr(top(), jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_OFFSET_JFR)); + Node* vthread_offset = off_heap_plus_addr(jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_OFFSET_JFR)); // False branch, is carrierThread. Node* thread_equal_carrierThread = _gvn.transform(new IfFalseNode(iff_thread_not_equal_carrierThread)); @@ -3726,17 +3627,17 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD); // Mask off the excluded information from the epoch. - Node * const is_excluded = _gvn.transform(new AndINode(epoch_raw, _gvn.transform(excluded_mask))); + Node * const is_excluded = _gvn.transform(new AndINode(epoch_raw, excluded_mask)); // Load the tid field from the thread. Node* tid = load_field_from_object(thread, "tid", "J"); // Store the vthread tid to the jfr thread local. - Node* thread_id_offset = basic_plus_adr(top(), jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_ID_OFFSET_JFR)); + Node* thread_id_offset = off_heap_plus_addr(jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_ID_OFFSET_JFR)); Node* tid_memory = store_to_memory(control(), thread_id_offset, tid, T_LONG, MemNode::unordered, true); // Branch is_excluded to conditionalize updating the epoch . - Node* excluded_cmp = _gvn.transform(new CmpINode(is_excluded, _gvn.transform(excluded_mask))); + Node* excluded_cmp = _gvn.transform(new CmpINode(is_excluded, excluded_mask)); Node* test_excluded = _gvn.transform(new BoolNode(excluded_cmp, BoolTest::eq)); IfNode* iff_excluded = create_and_map_if(control(), test_excluded, PROB_MIN, COUNT_UNKNOWN); @@ -3751,10 +3652,10 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { Node* vthread_is_included = _gvn.intcon(0); // Get epoch value. - Node* epoch = _gvn.transform(new AndINode(epoch_raw, _gvn.transform(epoch_mask))); + Node* epoch = _gvn.transform(new AndINode(epoch_raw, epoch_mask)); // Store the vthread epoch to the jfr thread local. - Node* vthread_epoch_offset = basic_plus_adr(top(), jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_EPOCH_OFFSET_JFR)); + Node* vthread_epoch_offset = off_heap_plus_addr(jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_EPOCH_OFFSET_JFR)); Node* included_memory = store_to_memory(control(), vthread_epoch_offset, epoch, T_CHAR, MemNode::unordered, true); RegionNode* excluded_rgn = new RegionNode(PATH_LIMIT); @@ -3769,15 +3670,15 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { excluded_rgn->init_req(_false_path, included); excluded_mem->init_req(_true_path, tid_memory); excluded_mem->init_req(_false_path, included_memory); - exclusion->init_req(_true_path, _gvn.transform(vthread_is_excluded)); - exclusion->init_req(_false_path, _gvn.transform(vthread_is_included)); + exclusion->init_req(_true_path, vthread_is_excluded); + exclusion->init_req(_false_path, vthread_is_included); // Set intermediate state. set_control(_gvn.transform(excluded_rgn)); set_all_memory(excluded_mem); // Store the vthread exclusion state to the jfr thread local. - Node* thread_local_excluded_offset = basic_plus_adr(top(), jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_EXCLUDED_OFFSET_JFR)); + Node* thread_local_excluded_offset = off_heap_plus_addr(jt, in_bytes(THREAD_LOCAL_OFFSET_JFR + VTHREAD_EXCLUDED_OFFSET_JFR)); store_to_memory(control(), thread_local_excluded_offset, _gvn.transform(exclusion), T_BOOLEAN, MemNode::unordered, true); // Store release @@ -3823,16 +3724,15 @@ bool LibraryCallKit::inline_native_setCurrentThread() { "method changes current Thread but is not annotated ChangesCurrentThread"); Node* arr = argument(1); Node* thread = _gvn.transform(new ThreadLocalNode()); - Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::vthread_offset())); + Node* p = off_heap_plus_addr(thread, in_bytes(JavaThread::vthread_offset())); Node* thread_obj_handle = make_load(nullptr, p, p->bottom_type()->is_ptr(), T_OBJECT, MemNode::unordered); - thread_obj_handle = _gvn.transform(thread_obj_handle); const TypePtr *adr_type = _gvn.type(thread_obj_handle)->isa_ptr(); access_store_at(nullptr, thread_obj_handle, adr_type, arr, _gvn.type(arr), T_OBJECT, IN_NATIVE | MO_UNORDERED); // Change the _monitor_owner_id of the JavaThread Node* tid = load_field_from_object(arr, "tid", "J"); - Node* monitor_owner_id_offset = basic_plus_adr(top(), thread, in_bytes(JavaThread::monitor_owner_id_offset())); + Node* monitor_owner_id_offset = off_heap_plus_addr(thread, in_bytes(JavaThread::monitor_owner_id_offset())); store_to_memory(control(), monitor_owner_id_offset, tid, T_LONG, MemNode::unordered, true); JFR_ONLY(extend_setCurrentThread(thread, arr);) @@ -3853,7 +3753,7 @@ const Type* LibraryCallKit::scopedValueCache_type() { Node* LibraryCallKit::scopedValueCache_helper() { Node* thread = _gvn.transform(new ThreadLocalNode()); - Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::scopedValueCache_offset())); + Node* p = off_heap_plus_addr(thread, in_bytes(JavaThread::scopedValueCache_offset())); // We cannot use immutable_memory() because we might flip onto a // different carrier thread, at which point we'll need to use that // carrier thread's cache. @@ -3895,7 +3795,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) { // TLS Node* tls_ptr = _gvn.transform(new ThreadLocalNode()); - Node* last_continuation_offset = basic_plus_adr(top(), tls_ptr, in_bytes(JavaThread::cont_entry_offset())); + Node* last_continuation_offset = off_heap_plus_addr(tls_ptr, in_bytes(JavaThread::cont_entry_offset())); Node* last_continuation = make_load(control(), last_continuation_offset, last_continuation_offset->get_ptr_type(), T_ADDRESS, MemNode::unordered); // Null check the last continuation object. @@ -3912,7 +3812,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) { set_control(continuation_is_not_null); // Load the pin count from the last continuation. - Node* pin_count_offset = basic_plus_adr(top(), last_continuation, in_bytes(ContinuationEntry::pin_count_offset())); + Node* pin_count_offset = off_heap_plus_addr(last_continuation, in_bytes(ContinuationEntry::pin_count_offset())); Node* pin_count = make_load(control(), pin_count_offset, TypeInt::INT, T_INT, MemNode::unordered); // The loaded pin count is compared against a context specific rhs for over/underflow detection. @@ -3922,7 +3822,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) { } else { pin_count_rhs = _gvn.intcon(UINT32_MAX); } - Node* pin_count_cmp = _gvn.transform(new CmpUNode(_gvn.transform(pin_count), pin_count_rhs)); + Node* pin_count_cmp = _gvn.transform(new CmpUNode(pin_count, pin_count_rhs)); Node* test_pin_count_over_underflow = _gvn.transform(new BoolNode(pin_count_cmp, BoolTest::eq)); IfNode* iff_pin_count_over_underflow = create_and_map_if(control(), test_pin_count_over_underflow, PROB_MIN, COUNT_UNKNOWN); @@ -3959,10 +3859,10 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) { PhiNode* result_mem = new PhiNode(result_rgn, Type::MEMORY, TypePtr::BOTTOM); record_for_igvn(result_mem); - result_rgn->init_req(_true_path, _gvn.transform(valid_pin_count)); - result_rgn->init_req(_false_path, _gvn.transform(continuation_is_null)); - result_mem->init_req(_true_path, _gvn.transform(reset_memory())); - result_mem->init_req(_false_path, _gvn.transform(input_memory_state)); + result_rgn->init_req(_true_path, valid_pin_count); + result_rgn->init_req(_false_path, continuation_is_null); + result_mem->init_req(_true_path, reset_memory()); + result_mem->init_req(_false_path, input_memory_state); // Set output state. set_control(_gvn.transform(result_rgn)); @@ -3974,7 +3874,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) { //---------------------------load_mirror_from_klass---------------------------- // Given a klass oop, load its java mirror (a java.lang.Class oop). Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { - Node* p = basic_plus_adr(top(), klass, in_bytes(Klass::java_mirror_offset())); + Node* p = off_heap_plus_addr(klass, in_bytes(Klass::java_mirror_offset())); Node* load = make_load(nullptr, p, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); // mirror = ((OopHandle)mirror)->resolve(); return access_load(load, TypeInstPtr::MIRROR, T_OBJECT, IN_NATIVE); @@ -4014,7 +3914,7 @@ Node* LibraryCallKit::generate_klass_flags_guard(Node* kls, int modifier_mask, i ByteSize offset, const Type* type, BasicType bt) { // Branch around if the given klass has the given modifier bit set. // Like generate_guard, adds a new path onto the region. - Node* modp = basic_plus_adr(top(), kls, in_bytes(offset)); + Node* modp = off_heap_plus_addr(kls, in_bytes(offset)); Node* mods = make_load(nullptr, modp, type, bt, MemNode::unordered); Node* mask = intcon(modifier_mask); Node* bits = intcon(modifier_bits); @@ -4148,7 +4048,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { phi->add_req(null()); } // If we fall through, it's a plain class. Get its _super. - p = basic_plus_adr(top(), kls, in_bytes(Klass::super_offset())); + p = off_heap_plus_addr(kls, in_bytes(Klass::super_offset())); kls = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeInstKlassPtr::OBJECT_OR_NULL)); null_ctl = top(); kls = null_check_oop(kls, &null_ctl); @@ -4683,10 +4583,10 @@ Node* LibraryCallKit::generate_virtual_guard(Node* obj_klass, assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "bad index %d", vtable_index); // Get the Method* out of the appropriate vtable entry. - int entry_offset = in_bytes(Klass::vtable_start_offset()) + + int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index*vtableEntry::size_in_bytes() + in_bytes(vtableEntry::method_offset()); - Node* entry_addr = basic_plus_adr(top(), obj_klass, entry_offset); + Node* entry_addr = off_heap_plus_addr(obj_klass, entry_offset); Node* target_call = make_load(nullptr, entry_addr, TypePtr::NOTNULL, T_ADDRESS, MemNode::unordered); // Compare the target method with the expected method (e.g., Object.hashCode). @@ -5161,7 +5061,7 @@ bool LibraryCallKit::inline_unsafe_copyMemory() { Node* dst_addr = make_unsafe_address(dst_base, dst_off); Node* thread = _gvn.transform(new ThreadLocalNode()); - Node* doing_unsafe_access_addr = basic_plus_adr(top(), thread, in_bytes(JavaThread::doing_unsafe_access_offset())); + Node* doing_unsafe_access_addr = off_heap_plus_addr(thread, in_bytes(JavaThread::doing_unsafe_access_offset())); BasicType doing_unsafe_access_bt = T_BYTE; assert((sizeof(bool) * CHAR_BIT) == 8, "not implemented"); @@ -5216,7 +5116,7 @@ bool LibraryCallKit::inline_unsafe_setMemory() { Node* dst_addr = make_unsafe_address(dst_base, dst_off); Node* thread = _gvn.transform(new ThreadLocalNode()); - Node* doing_unsafe_access_addr = basic_plus_adr(top(), thread, in_bytes(JavaThread::doing_unsafe_access_offset())); + Node* doing_unsafe_access_addr = off_heap_plus_addr(thread, in_bytes(JavaThread::doing_unsafe_access_offset())); BasicType doing_unsafe_access_bt = T_BYTE; assert((sizeof(bool) * CHAR_BIT) == 8, "not implemented"); @@ -6225,9 +6125,10 @@ bool LibraryCallKit::inline_encodeISOArray(bool ascii) { } // Check source & target bounds - generate_string_range_check(src, src_offset, length, src_elem == T_BYTE, true); - generate_string_range_check(dst, dst_offset, length, false, true); - if (stopped()) { + RegionNode* bailout = create_bailout(); + generate_string_range_check(src, src_offset, length, src_elem == T_BYTE, bailout); + generate_string_range_check(dst, dst_offset, length, false, bailout); + if (check_bailout(bailout)) { return true; } @@ -6751,7 +6652,7 @@ bool LibraryCallKit::inline_updateCRC32() { Node* base = makecon(TypeRawPtr::make(StubRoutines::crc_table_addr())); Node* offset = _gvn.transform(new LShiftINode(result, intcon(0x2))); - Node* adr = basic_plus_adr(top(), base, ConvI2X(offset)); + Node* adr = off_heap_plus_addr(base, ConvI2X(offset)); result = make_load(control(), adr, TypeInt::INT, T_INT, MemNode::unordered); crc = _gvn.transform(new URShiftINode(crc, intcon(8))); @@ -6823,7 +6724,7 @@ bool LibraryCallKit::inline_updateByteBufferCRC32() { offset = ConvI2X(offset); // 'src_start' points to src array + scaled offset - Node* src_start = basic_plus_adr(top(), base, offset); + Node* src_start = off_heap_plus_addr(base, offset); // Call the stub. address stubAddr = StubRoutines::updateBytesCRC32(); @@ -6920,7 +6821,7 @@ bool LibraryCallKit::inline_updateDirectByteBufferCRC32C() { offset = ConvI2X(offset); // 'src_start' points to src array + scaled offset - Node* src_start = basic_plus_adr(top(), base, offset); + Node* src_start = off_heap_plus_addr(base, offset); // static final int[] byteTable in class CRC32C Node* table = get_table_from_crc32c_class(callee()->holder()); @@ -7004,7 +6905,7 @@ bool LibraryCallKit::inline_updateByteBufferAdler32() { offset = ConvI2X(offset); // 'src_start' points to src array + scaled offset - Node* src_start = basic_plus_adr(top(), base, offset); + Node* src_start = off_heap_plus_addr(base, offset); // Call the stub. address stubAddr = StubRoutines::updateBytesAdler32(); diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp index 56141be2362..9b87df645e1 100644 --- a/src/hotspot/share/opto/library_call.hpp +++ b/src/hotspot/share/opto/library_call.hpp @@ -129,30 +129,9 @@ class LibraryCallKit : public GraphKit { virtual int reexecute_sp() { return _reexecute_sp; } - /* When an intrinsic makes changes before bailing out, it's necessary to restore the graph - * as it was. See JDK-8359344 for what can happen wrong. It's also not always possible to - * bailout before making changes because the bailing out decision might depend on new nodes - * (their types, for instance). - * - * So, if an intrinsic might cause this situation, one must start by saving the state in a - * SavedState by constructing it, and the state will be restored on destruction. If the - * intrinsic is not bailing out, one need to call discard to prevent restoring the old state. - */ - class SavedState { - LibraryCallKit* _kit; - uint _sp; - JVMState* _jvms; - SafePointNode* _map; - Unique_Node_List _ctrl_succ; - bool _discarded; - - public: - SavedState(LibraryCallKit*); - ~SavedState(); - void discard(); - }; - // Helper functions to inline natives + RegionNode* create_bailout(); + bool check_bailout(RegionNode* bailout); Node* generate_guard(Node* test, RegionNode* region, float true_prob); Node* generate_slow_guard(Node* test, RegionNode* region); Node* generate_fair_guard(Node* test, RegionNode* region); @@ -166,7 +145,7 @@ class LibraryCallKit : public GraphKit { bool with_opaque = false); void generate_string_range_check(Node* array, Node* offset, Node* length, bool char_count, - bool halt_on_oob = false); + RegionNode* region); Node* current_thread_helper(Node* &tls_output, ByteSize handle_offset, bool is_immutable); Node* generate_current_thread(Node* &tls_output); diff --git a/src/hotspot/share/opto/locknode.hpp b/src/hotspot/share/opto/locknode.hpp index ee54e893e59..7d1507ae998 100644 --- a/src/hotspot/share/opto/locknode.hpp +++ b/src/hotspot/share/opto/locknode.hpp @@ -147,6 +147,9 @@ public: virtual int Opcode() const; virtual const Type* Value(PhaseGVN* phase) const { return TypeInt::CC; } const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; @@ -169,6 +172,8 @@ public: virtual const Type* Value(PhaseGVN* phase) const { return TypeInt::CC; } const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} +private: + virtual bool depends_only_on_test_impl() const { return false; } }; #endif // SHARE_OPTO_LOCKNODE_HPP diff --git a/src/hotspot/share/opto/loopPredicate.cpp b/src/hotspot/share/opto/loopPredicate.cpp index 61a7ed29c3e..be099747fc0 100644 --- a/src/hotspot/share/opto/loopPredicate.cpp +++ b/src/hotspot/share/opto/loopPredicate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -334,7 +334,7 @@ class Invariance : public StackObj { // loop, it was marked invariant but n is only invariant if // it depends only on that test. Otherwise, unless that test // is out of the loop, it's not invariant. - if (n->is_CFG() || (n->depends_only_on_test() && _phase->igvn().no_dependent_zero_check(n)) || n->in(0) == nullptr || !_phase->is_member(_lpt, n->in(0))) { + if (n->is_CFG() || n->in(0) == nullptr || n->depends_only_on_test() || !_phase->is_member(_lpt, n->in(0))) { _invariant.set(n->_idx); // I am a invariant too } } diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 4e221a9a0ef..80b17efb998 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -524,6 +524,9 @@ bool IdealLoopTree::policy_peeling(PhaseIdealLoop *phase) { // return the estimated loop size if peeling is applicable, otherwise return // zero. No node budget is allocated. uint IdealLoopTree::estimate_peeling(PhaseIdealLoop *phase) { + if (LoopPeeling != 1) { + return 0; + } // If nodes are depleted, some transform has miscalculated its needs. assert(!phase->exceeding_node_budget(), "sanity"); @@ -775,6 +778,7 @@ void PhaseIdealLoop::peeled_dom_test_elim(IdealLoopTree* loop, Node_List& old_ne // exit // void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) { + assert(LoopPeeling != 0, "do_peeling called with loop peeling always disabled"); C->set_major_progress(); // Peeling a 'main' loop in a pre/main/post situation obfuscates the @@ -2201,6 +2205,15 @@ void PhaseIdealLoop::do_maximally_unroll(IdealLoopTree *loop, Node_List &old_new // If loop is tripping an odd number of times, peel odd iteration if ((cl->trip_count() & 1) == 1) { + if (LoopPeeling == 0) { +#ifndef PRODUCT + if (TraceLoopOpts) { + tty->print("MaxUnroll cancelled since LoopPeeling is always disabled"); + loop->dump_head(); + } +#endif + return; + } do_peeling(loop, old_new); } @@ -3243,6 +3256,15 @@ bool IdealLoopTree::do_remove_empty_loop(PhaseIdealLoop *phase) { #endif if (needs_guard) { + if (LoopPeeling == 0) { +#ifndef PRODUCT + if (TraceLoopOpts) { + tty->print("Empty loop not removed since LoopPeeling is always disabled"); + this->dump_head(); + } +#endif + return false; + } // Peel the loop to ensure there's a zero trip guard Node_List old_new; phase->do_peeling(this, old_new); @@ -3969,7 +3991,7 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { index = new LShiftXNode(index, shift->in(2)); _igvn.register_new_node_with_optimizer(index); } - Node* from = new AddPNode(base, base, index); + Node* from = AddPNode::make_with_base(base, index); _igvn.register_new_node_with_optimizer(from); // For normal array fills, C2 uses two AddP nodes for array element // addressing. But for array fills with Unsafe call, there's only one @@ -3977,7 +3999,7 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { assert(offset != nullptr || C->has_unsafe_access(), "Only array fills with unsafe have no extra offset"); if (offset != nullptr) { - from = new AddPNode(base, from, offset); + from = AddPNode::make_with_base(base, from, offset); _igvn.register_new_node_with_optimizer(from); } // Compute the number of elements to copy diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index d68505836d4..23186a25320 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -375,17 +375,20 @@ IdealLoopTree* PhaseIdealLoop::create_outer_strip_mined_loop(Node* init_control, return outer_ilt; } -void PhaseIdealLoop::insert_loop_limit_check_predicate(ParsePredicateSuccessProj* loop_limit_check_parse_proj, - Node* cmp_limit, Node* bol) { + +void CountedLoopConverter::insert_loop_limit_check_predicate(const ParsePredicateSuccessProj* loop_limit_check_parse_proj, + Node* bol) const { assert(loop_limit_check_parse_proj->in(0)->is_ParsePredicate(), "must be parse predicate"); - Node* new_predicate_proj = create_new_if_for_predicate(loop_limit_check_parse_proj, nullptr, - Deoptimization::Reason_loop_limit_check, - Op_If); + Node* new_predicate_proj = _phase->create_new_if_for_predicate(loop_limit_check_parse_proj, nullptr, + Deoptimization::Reason_loop_limit_check, + Op_If); + + PhaseIterGVN& igvn = _phase->igvn(); Node* iff = new_predicate_proj->in(0); - cmp_limit = _igvn.register_new_node_with_optimizer(cmp_limit); - bol = _igvn.register_new_node_with_optimizer(bol); - set_subtree_ctrl(bol, false); - _igvn.replace_input_of(iff, 1, bol); + Node* cmp_limit = igvn.register_new_node_with_optimizer(bol->in(1)); + bol = igvn.register_new_node_with_optimizer(bol); + _phase->set_subtree_ctrl(bol, false); + igvn.replace_input_of(iff, 1, bol); #ifndef PRODUCT // report that the loop predication has been actually performed @@ -397,14 +400,38 @@ void PhaseIdealLoop::insert_loop_limit_check_predicate(ParsePredicateSuccessProj #endif } -Node* PhaseIdealLoop::loop_exit_control(Node* x, IdealLoopTree* loop) { +void CountedLoopConverter::insert_stride_overflow_limit_check() const { + const jlong stride_con = _structure.stride_con(); + + jlong adjusted_stride_con = (stride_con > 0 + ? max_signed_integer(_iv_bt) + : min_signed_integer(_iv_bt)) - _structure.final_limit_correction(); + Node* cmp_limit = CmpNode::make(_structure.limit(), + _phase->igvn().integercon(adjusted_stride_con, _iv_bt), _iv_bt); + Node* bol = new BoolNode(cmp_limit, stride_con > 0 ? BoolTest::le : BoolTest::ge); + + insert_loop_limit_check_predicate(_head->in(LoopNode::EntryControl)->as_IfTrue(), bol); +} + +void CountedLoopConverter::insert_init_trip_limit_check() const { + const jlong stride_con = _structure.stride_con(); + + Node* cmp_limit = CmpNode::make(_structure.phi()->in(LoopNode::EntryControl), _structure.limit(), _iv_bt); + Node* bol = new BoolNode(cmp_limit, stride_con > 0 ? BoolTest::lt : BoolTest::gt); + + insert_loop_limit_check_predicate(_head->in(LoopNode::EntryControl)->as_IfTrue(), bol); +} + +Node* PhaseIdealLoop::loop_exit_control(const IdealLoopTree* loop) const { + Node* head = loop->_head; + // Counted loop head must be a good RegionNode with only 3 not null // control input edges: Self, Entry, LoopBack. - if (x->in(LoopNode::Self) == nullptr || x->req() != 3 || loop->_irreducible) { + if (head->in(LoopNode::Self) == nullptr || head->req() != 3 || loop->_irreducible) { return nullptr; } - Node *init_control = x->in(LoopNode::EntryControl); - Node *back_control = x->in(LoopNode::LoopBackControl); + Node* init_control = head->in(LoopNode::EntryControl); + Node* back_control = head->in(LoopNode::LoopBackControl); if (init_control == nullptr || back_control == nullptr) { // Partially dead return nullptr; } @@ -437,77 +464,7 @@ Node* PhaseIdealLoop::loop_exit_control(Node* x, IdealLoopTree* loop) { return iftrue; } -Node* PhaseIdealLoop::loop_exit_test(Node* back_control, IdealLoopTree* loop, Node*& incr, Node*& limit, BoolTest::mask& bt, float& cl_prob) { - Node* iftrue = back_control; - uint iftrue_op = iftrue->Opcode(); - Node* iff = iftrue->in(0); - BoolNode* test = iff->in(1)->as_Bool(); - bt = test->_test._test; - cl_prob = iff->as_If()->_prob; - if (iftrue_op == Op_IfFalse) { - bt = BoolTest(bt).negate(); - cl_prob = 1.0 - cl_prob; - } - // Get backedge compare - Node* cmp = test->in(1); - if (!cmp->is_Cmp()) { - return nullptr; - } - - // Find the trip-counter increment & limit. Limit must be loop invariant. - incr = cmp->in(1); - limit = cmp->in(2); - - // --------- - // need 'loop()' test to tell if limit is loop invariant - // --------- - - if (!ctrl_is_member(loop, incr)) { // Swapped trip counter and limit? - Node* tmp = incr; // Then reverse order into the CmpI - incr = limit; - limit = tmp; - bt = BoolTest(bt).commute(); // And commute the exit test - } - if (ctrl_is_member(loop, limit)) { // Limit must be loop-invariant - return nullptr; - } - if (!ctrl_is_member(loop, incr)) { // Trip counter must be loop-variant - return nullptr; - } - return cmp; -} - -Node* PhaseIdealLoop::loop_iv_incr(Node* incr, Node* x, IdealLoopTree* loop, Node*& phi_incr) { - if (incr->is_Phi()) { - if (incr->as_Phi()->region() != x || incr->req() != 3) { - return nullptr; // Not simple trip counter expression - } - phi_incr = incr; - incr = phi_incr->in(LoopNode::LoopBackControl); // Assume incr is on backedge of Phi - if (!ctrl_is_member(loop, incr)) { // Trip counter must be loop-variant - return nullptr; - } - } - return incr; -} - -Node* PhaseIdealLoop::loop_iv_stride(Node* incr, Node*& xphi) { - assert(incr->Opcode() == Op_AddI || incr->Opcode() == Op_AddL, "caller resp."); - // Get merge point - xphi = incr->in(1); - Node *stride = incr->in(2); - if (!stride->is_Con()) { // Oops, swap these - if (!xphi->is_Con()) { // Is the other guy a constant? - return nullptr; // Nope, unknown stride, bail out - } - Node *tmp = xphi; // 'incr' is commutative, so ok to swap - xphi = stride; - stride = tmp; - } - return stride; -} - -PhiNode* PhaseIdealLoop::loop_iv_phi(Node* xphi, Node* phi_incr, Node* x) { +PhiNode* PhaseIdealLoop::loop_iv_phi(const Node* xphi, const Node* phi_incr, const Node* head) { if (!xphi->is_Phi()) { return nullptr; // Too much math on the trip counter } @@ -517,44 +474,31 @@ PhiNode* PhaseIdealLoop::loop_iv_phi(Node* xphi, Node* phi_incr, Node* x) { PhiNode *phi = xphi->as_Phi(); // Phi must be of loop header; backedge must wrap to increment - if (phi->region() != x) { + if (phi->region() != head) { return nullptr; } return phi; } -static int check_stride_overflow(jlong final_correction, const TypeInteger* limit_t, BasicType bt) { +CountedLoopConverter::StrideOverflowState CountedLoopConverter::check_stride_overflow(jlong final_correction, + const TypeInteger* limit_t, + BasicType bt) { if (final_correction > 0) { if (limit_t->lo_as_long() > (max_signed_integer(bt) - final_correction)) { - return -1; + return Overflow; } if (limit_t->hi_as_long() > (max_signed_integer(bt) - final_correction)) { - return 1; + return RequireLimitCheck; } } else { if (limit_t->hi_as_long() < (min_signed_integer(bt) - final_correction)) { - return -1; + return Overflow; } if (limit_t->lo_as_long() < (min_signed_integer(bt) - final_correction)) { - return 1; + return RequireLimitCheck; } } - return 0; -} - -static bool condition_stride_ok(BoolTest::mask bt, jlong stride_con) { - // If the condition is inverted and we will be rolling - // through MININT to MAXINT, then bail out. - if (bt == BoolTest::eq || // Bail out, but this loop trips at most twice! - // Odd stride - (bt == BoolTest::ne && stride_con != 1 && stride_con != -1) || - // Count down loop rolls through MAXINT - ((bt == BoolTest::le || bt == BoolTest::lt) && stride_con < 0) || - // Count up loop rolls through MININT - ((bt == BoolTest::ge || bt == BoolTest::gt) && stride_con > 0)) { - return false; // Bail out - } - return true; + return NoOverflow; } Node* PhaseIdealLoop::loop_nest_replace_iv(Node* iv_to_replace, Node* inner_iv, Node* outer_phi, Node* inner_head, @@ -647,10 +591,10 @@ void PhaseIdealLoop::add_parse_predicate(Deoptimization::DeoptReason reason, Nod // Find a safepoint node that dominates the back edge. We need a // SafePointNode so we can use its jvm state to create empty // predicates. -static bool no_side_effect_since_safepoint(Compile* C, Node* x, Node* mem, MergeMemNode* mm, PhaseIdealLoop* phase) { +static bool no_side_effect_since_safepoint(Compile* C, const Node* head, const Node* mem, MergeMemNode* mm, const PhaseIdealLoop* phase) { SafePointNode* safepoint = nullptr; - for (DUIterator_Fast imax, i = x->fast_outs(imax); i < imax; i++) { - Node* u = x->fast_out(i); + for (DUIterator_Fast imax, i = head->fast_outs(imax); i < imax; i++) { + Node* u = head->fast_out(i); if (u->is_memory_phi()) { Node* m = u->in(LoopNode::LoopBackControl); if (u->adr_type() == TypePtr::BOTTOM) { @@ -700,14 +644,14 @@ static bool no_side_effect_since_safepoint(Compile* C, Node* x, Node* mem, Merge return true; } -SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, Node* x, IdealLoopTree* loop) { +SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, const Node* head, const IdealLoopTree* loop) { IfNode* exit_test = back_control->in(0)->as_If(); SafePointNode* safepoint = nullptr; if (exit_test->in(0)->is_SafePoint() && exit_test->in(0)->outcnt() == 1) { safepoint = exit_test->in(0)->as_SafePoint(); } else { Node* c = back_control; - while (c != x && c->Opcode() != Op_SafePoint) { + while (c != head && c->Opcode() != Op_SafePoint) { c = idom(c); } @@ -746,7 +690,7 @@ SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, Node* x, Ideal } } #endif - if (!no_side_effect_since_safepoint(C, x, mem, mm, this)) { + if (!no_side_effect_since_safepoint(C, head, mem, mm, this)) { safepoint = nullptr; } else { assert(mm == nullptr|| _igvn.transform(mm) == mem->as_MergeMem()->base_memory(), "all memory state should have been processed"); @@ -952,11 +896,11 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) { // Loop is strip mined: use the safepoint of the outer strip mined loop OuterStripMinedLoopNode* outer_loop = head->as_CountedLoop()->outer_loop(); assert(outer_loop != nullptr, "no outer loop"); - safepoint = outer_loop->outer_safepoint(); + safepoint = LoopPeeling == 0 ? nullptr : outer_loop->outer_safepoint(); outer_loop->transform_to_counted_loop(&_igvn, this); exit_test = head->loopexit(); } else { - safepoint = find_safepoint(back_control, x, loop); + safepoint = LoopPeeling == 0 ? nullptr : find_safepoint(back_control, x, loop); } IfFalseNode* exit_branch = exit_test->false_proj(); @@ -1130,8 +1074,8 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) { // Peel one iteration of the loop and use the safepoint at the end // of the peeled iteration to insert Parse Predicates. If no well // positioned safepoint peel to guarantee a safepoint in the outer - // loop. - if (safepoint != nullptr || !loop->_has_call) { + // loop. When loop peeling is disabled, skip the peeling step altogether. + if (LoopPeeling != 0 && (safepoint != nullptr || !loop->_has_call)) { old_new.clear(); do_peeling(loop, old_new); } else { @@ -1744,51 +1688,275 @@ LoopNode* PhaseIdealLoop::create_inner_head(IdealLoopTree* loop, BaseCountedLoop } #ifdef ASSERT -void PhaseIdealLoop::check_counted_loop_shape(IdealLoopTree* loop, Node* x, BasicType bt) { - Node* back_control = loop_exit_control(x, loop); +void PhaseIdealLoop::check_counted_loop_shape(IdealLoopTree* loop, Node* head, BasicType bt) { + Node* back_control = loop_exit_control(loop); assert(back_control != nullptr, "no back control"); - BoolTest::mask mask = BoolTest::illegal; - float cl_prob = 0; - Node* incr = nullptr; - Node* limit = nullptr; + LoopExitTest exit_test(back_control, loop, this); + exit_test.build(); + assert(exit_test.is_valid_with_bt(bt), "no exit test"); - Node* cmp = loop_exit_test(back_control, loop, incr, limit, mask, cl_prob); - assert(cmp != nullptr && cmp->Opcode() == Op_Cmp(bt), "no exit test"); + LoopIVIncr iv_incr(head, loop); + iv_incr.build(exit_test.incr()); + assert(iv_incr.is_valid_with_bt(bt), "no incr"); - Node* phi_incr = nullptr; - incr = loop_iv_incr(incr, x, loop, phi_incr); - assert(incr != nullptr && incr->Opcode() == Op_Add(bt), "no incr"); + LoopIVStride stride = LoopIVStride(bt); + stride.build(iv_incr.incr()); + assert(stride.is_valid(), "no stride"); - Node* xphi = nullptr; - Node* stride = loop_iv_stride(incr, xphi); + PhiNode* phi = loop_iv_phi(stride.xphi(), iv_incr.phi_incr(), head); + assert(phi != nullptr && phi->in(LoopNode::LoopBackControl) == iv_incr.incr(), "No phi"); - assert(stride != nullptr, "no stride"); + assert(stride.compute_non_zero_stride_con(exit_test.mask(), bt) != 0, "illegal condition"); - PhiNode* phi = loop_iv_phi(xphi, phi_incr, x); - - assert(phi != nullptr && phi->in(LoopNode::LoopBackControl) == incr, "No phi"); - - jlong stride_con = stride->get_integer_as_long(bt); - - assert(condition_stride_ok(mask, stride_con), "illegal condition"); - - assert(mask != BoolTest::ne, "unexpected condition"); - assert(phi_incr == nullptr, "bad loop shape"); - assert(cmp->in(1) == incr, "bad exit test shape"); + assert(exit_test.mask() != BoolTest::ne, "unexpected condition"); + assert(iv_incr.phi_incr() == nullptr, "bad loop shape"); + assert(exit_test.cmp()->in(1) == iv_incr.incr(), "bad exit test shape"); // Safepoint on backedge not supported - assert(x->in(LoopNode::LoopBackControl)->Opcode() != Op_SafePoint, "no safepoint on backedge"); + assert(head->in(LoopNode::LoopBackControl)->Opcode() != Op_SafePoint, "no safepoint on backedge"); } #endif +void PhaseIdealLoop::LoopExitTest::build() { + _is_valid = false; + + const Node* iftrue = _back_control; + uint iftrue_op = iftrue->Opcode(); + Node* iff = iftrue->in(0); + BoolNode* test = iff->in(1)->as_Bool(); + _mask = test->_test._test; + _cl_prob = iff->as_If()->_prob; + if (iftrue_op == Op_IfFalse) { + _mask = BoolTest(_mask).negate(); + _cl_prob = 1.0f - _cl_prob; + } + // Get backedge compare + _cmp = test->in(1); + if (!_cmp->is_Cmp()) { + return; + } + + // Find the trip-counter increment & limit. Limit must be loop invariant. + _incr = _cmp->in(1); + _limit = _cmp->in(2); + + // --------- + // need 'loop()' test to tell if limit is loop invariant + // --------- + + if (_loop->is_invariant(_incr)) { // Swapped trip counter and limit? + swap(_incr, _limit); // Then reverse order into the CmpI + _mask = BoolTest(_mask).commute(); // And commute the exit test + } + + if (!_loop->is_invariant(_limit)) { // Limit must be loop-invariant + return; + } + if (_loop->is_invariant(_incr)) { // Trip counter must be loop-variant + return; + } + + _is_valid = true; +} + +// Canonicalize the loop condition if it is 'ne'. +void PhaseIdealLoop::LoopExitTest::canonicalize_mask(jlong stride_con) { + if (_mask != BoolTest::ne) { + return; + } + + assert(stride_con == 1 || stride_con == -1, "simple increment only - checked in CountedLoopConverter"); + + if (stride_con == 1) { + // 'ne' can be replaced with 'lt' only when init < limit. + // This is ensured by the inserted predicate in CountedLoopConverter + _mask = BoolTest::lt; + } else { + // 'ne' can be replaced with 'gt' only when init > limit. + // This is ensured by the inserted predicate in CountedLoopConverter. + _mask = BoolTest::gt; + } +} + +void PhaseIdealLoop::LoopIVIncr::build(Node* old_incr) { + _is_valid = false; + + Node* incr = old_incr; + // Trip-counter increment must be commutative & associative. + if (incr->is_Phi()) { + if (incr->as_Phi()->region() != _head || incr->req() != 3) { + return; // Not simple trip counter expression + } + Node* phi_incr = incr; + Node* back_control = phi_incr->in(LoopNode::LoopBackControl); // Assume incr is on backedge of Phi + if (_loop->_phase->ctrl_is_member(_loop, back_control)) { // Trip counter must be loop-variant + _incr = back_control; + _phi_incr = phi_incr; + _is_valid = true; + return; + } + } + _incr = incr; + _phi_incr = nullptr; + + _is_valid = true; +} + +void PhaseIdealLoop::LoopIVStride::build(const Node* incr) { + _is_valid = false; + + assert(incr->Opcode() == Op_AddI || incr->Opcode() == Op_AddL, "caller resp."); + // Get merge point + _xphi = incr->in(1); + _stride_node = incr->in(2); + if (!_stride_node->is_Con()) { // Oops, swap these + if (!_xphi->is_Con()) { // Is the other guy a constant? + return; // Nope, unknown stride, bail out + } + swap(_xphi, _stride_node); // 'incr' is commutative, so ok to swap + } + + // Iteratively uncast the loop induction variable + // until no more CastII/CastLL nodes are found. + while (_xphi->Opcode() == Op_Cast(_iv_bt)) { + _xphi = _xphi->in(1); + } + + _is_valid = true; +} + +jlong PhaseIdealLoop::LoopIVStride::compute_non_zero_stride_con(const BoolTest::mask mask, const BasicType iv_bt) const { + jlong stride_con = stride_node()->get_integer_as_long(iv_bt); + assert(stride_con != 0, "missed some peephole opt"); // stride constant can never be 0! + + // If the condition is inverted and we will be rolling + // through MININT to MAXINT, then bail out. + if (mask == BoolTest::eq || // Bail out, but this loop trips at most twice! + // Odd stride + (mask == BoolTest::ne && stride_con != 1 && stride_con != -1) || + // Count down loop rolls through MAXINT + ((mask == BoolTest::le || mask == BoolTest::lt) && stride_con < 0) || + // Count up loop rolls through MININT + ((mask == BoolTest::ge || mask == BoolTest::gt) && stride_con > 0)) { + return 0; // Bail out with sentinel = 0 + } + + // Bail out if the stride is too big. + if (stride_con == min_signed_integer(iv_bt) || (ABS(stride_con) > max_signed_integer(iv_bt) / 2)) { + return 0; // Bail out with sentinel = 0 + } + + return stride_con; +} + +void CountedLoopConverter::LoopStructure::build() { + _is_valid = false; + + if (_back_control == nullptr) { + return; + } + + _exit_test.build(); + if (!_exit_test.is_valid_with_bt(_iv_bt)) { + return; // Avoid pointer & float & 64-bit compares + } + + Node* incr = _exit_test.incr(); + if (_exit_test.incr()->Opcode() == Op_Cast(_iv_bt)) { + incr = incr->in(1); + } + + _iv_incr.build(incr); + if (!_iv_incr.is_valid()) { + return; + } + + _truncated_increment.build(_iv_incr.incr()); + if (!_truncated_increment.is_valid()) { + return; // Funny increment opcode + } + assert(_truncated_increment.incr()->Opcode() == Op_Add(_iv_bt), "wrong increment code"); + + _stride.build(_truncated_increment.incr()); + if (!_stride.is_valid()) { + return; + } + + _phi = PhaseIdealLoop::loop_iv_phi(_stride.xphi(), _iv_incr.phi_incr(), _head); + if (_phi == nullptr || + (_truncated_increment.outer_trunc() == nullptr && _phi->in(LoopNode::LoopBackControl) != _truncated_increment.incr()) || + (_truncated_increment.outer_trunc() != nullptr && _phi->in(LoopNode::LoopBackControl) != _truncated_increment.outer_trunc())) { + return; + } + + Node* safepoint = _back_control->in(0)->in(0); + if (_loop->_child != nullptr) { + if (safepoint->Opcode() == Op_SafePoint) { + _safepoint = safepoint->as_SafePoint(); + } else { + _safepoint = nullptr; + } + } else { + _safepoint = _phase->find_safepoint(_back_control, _head, _loop); + } + + _is_valid = true; +} + +// We need to canonicalize the loop exit check by using different values for adjusted_limit: +// (LE1) iv_post_i < limit: Already canonicalized. We can directly use limit as adjusted_limit. +// -> adjusted_limit = limit. +// (LE2) iv_post_i <= limit: +// iv_post_i < limit + 1 +// -> adjusted limit = limit + 1 +// (LE3) iv_pre_i < limit: +// iv_pre_i + stride < limit + stride +// iv_post_i < limit + stride +// -> adjusted_limit = limit + stride +// (LE4) iv_pre_i <= limit: +// iv_pre_i < limit + 1 +// iv_pre_i + stride < limit + stride + 1 +// iv_post_i < limit + stride + 1 +// -> adjusted_limit = limit + stride + 1 +// +// Note that: +// (AL) limit <= adjusted_limit. +jlong CountedLoopConverter::LoopStructure::final_limit_correction() const { + const jlong stride_con = _stride.compute_non_zero_stride_con(_exit_test.mask(), _iv_bt); + + // Accounting for (LE3) and (LE4) where we use pre-incremented phis in the loop exit check. + const jlong limit_correction_for_pre_iv_exit_check = _iv_incr.phi_incr() != nullptr ? stride_con : 0; + + // Accounting for (LE2) and (LE4) where we use <= or >= in the loop exit check. + const jlong limit_correction_for_le_ge_exit_check = _exit_test.should_include_limit() + ? (stride_con > 0 ? 1 : -1) + : 0; + + const jlong limit_correction = limit_correction_for_pre_iv_exit_check + limit_correction_for_le_ge_exit_check; + const jlong canonicalized_correction = stride_con + (stride_con > 0 ? -1 : 1); + + return canonicalized_correction + limit_correction; // final_correction +} + #ifdef ASSERT -// convert an int counted loop to a long counted to stress handling of -// long counted loops -bool PhaseIdealLoop::convert_to_long_loop(Node* cmp, Node* phi, IdealLoopTree* loop) { +bool CountedLoopConverter::should_stress_long_counted_loop() { + assert(_checked_for_counted_loop, "must check for counted loop before stressing"); + + return StressLongCountedLoop > 0 && + _iv_bt == T_INT && + !_head->as_Loop()->is_loop_nest_inner_loop() && + _structure.truncated_increment().trunc_type() == TypeInt::INT; // Only stress an int loop (i.e., not char, byte or short) +} + +// Convert an int counted loop to a long counted to stress handling of long counted loops. Returns true upon success. +bool CountedLoopConverter::stress_long_counted_loop() { + assert(should_stress_long_counted_loop(), "stress condition not satisfied"); + + PhaseIterGVN* igvn = &_phase->igvn(); Unique_Node_List iv_nodes; Node_List old_new; - iv_nodes.push(cmp); + iv_nodes.push(_structure.exit_test().cmp()); bool failed = false; for (uint i = 0; i < iv_nodes.size() && !failed; i++) { @@ -1818,12 +1986,12 @@ bool PhaseIdealLoop::convert_to_long_loop(Node* cmp, Node* phi, IdealLoopTree* l fatal("unexpected"); } - for (uint i = 1; i < n->req(); i++) { - Node* in = n->in(i); + for (uint j = 1; j < n->req(); j++) { + Node* in = n->in(j); if (in == nullptr) { continue; } - if (ctrl_is_member(loop, in)) { + if (_loop->is_member(_phase->get_loop(_phase->get_ctrl(in)))) { iv_nodes.push(in); } } @@ -1834,243 +2002,141 @@ bool PhaseIdealLoop::convert_to_long_loop(Node* cmp, Node* phi, IdealLoopTree* l Node* n = iv_nodes.at(i); Node* clone = old_new[n->_idx]; if (clone != nullptr) { - _igvn.remove_dead_node(clone); + igvn->remove_dead_node(clone); } } return false; } + // Make sure we have loop limit checks in place to preserve overflows behaviour after casting to long. + if (_should_insert_stride_overflow_limit_check) { + insert_stride_overflow_limit_check(); + } + + if (_should_insert_init_trip_limit_check) { + insert_init_trip_limit_check(); + } + for (uint i = 0; i < iv_nodes.size(); i++) { Node* n = iv_nodes.at(i); Node* clone = old_new[n->_idx]; - for (uint i = 1; i < n->req(); i++) { - Node* in = n->in(i); + for (uint j = 1; j < n->req(); j++) { + Node* in = n->in(j); if (in == nullptr) { continue; } Node* in_clone = old_new[in->_idx]; if (in_clone == nullptr) { - assert(_igvn.type(in)->isa_int(), ""); + assert(igvn->type(in)->isa_int(), ""); in_clone = new ConvI2LNode(in); - _igvn.register_new_node_with_optimizer(in_clone); - set_subtree_ctrl(in_clone, false); + igvn->register_new_node_with_optimizer(in_clone); + _phase->set_subtree_ctrl(in_clone, false); } if (in_clone->in(0) == nullptr) { - in_clone->set_req(0, C->top()); - clone->set_req(i, in_clone); + in_clone->set_req(0, _phase->C->top()); + clone->set_req(j, in_clone); in_clone->set_req(0, nullptr); } else { - clone->set_req(i, in_clone); + clone->set_req(j, in_clone); } } - _igvn.register_new_node_with_optimizer(clone); + igvn->register_new_node_with_optimizer(clone); } - set_ctrl(old_new[phi->_idx], phi->in(0)); + _phase->set_ctrl(old_new[_structure.phi()->_idx], _structure.phi()->in(0)); for (uint i = 0; i < iv_nodes.size(); i++) { Node* n = iv_nodes.at(i); Node* clone = old_new[n->_idx]; - set_subtree_ctrl(clone, false); + _phase->set_subtree_ctrl(clone, false); Node* m = n->Opcode() == Op_CmpI ? clone : nullptr; - for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { - Node* u = n->fast_out(i); + for (DUIterator_Fast imax, j = n->fast_outs(imax); j < imax; j++) { + Node* u = n->fast_out(j); if (iv_nodes.member(u)) { continue; } if (m == nullptr) { m = new ConvL2INode(clone); - _igvn.register_new_node_with_optimizer(m); - set_subtree_ctrl(m, false); + igvn->register_new_node_with_optimizer(m); + _phase->set_subtree_ctrl(m, false); } - _igvn.rehash_node_delayed(u); - int nb = u->replace_edge(n, m, &_igvn); - --i, imax -= nb; + igvn->rehash_node_delayed(u); + int nb = u->replace_edge(n, m, igvn); + --j, imax -= nb; } } return true; } #endif -//------------------------------is_counted_loop-------------------------------- -bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv_bt) { - PhaseGVN *gvn = &_igvn; +bool PhaseIdealLoop::try_convert_to_counted_loop(Node* head, IdealLoopTree*& loop, const BasicType iv_bt) { + CountedLoopConverter converter(this, head, loop, iv_bt); + if (converter.is_counted_loop()) { +#ifdef ASSERT + // Stress by converting int counted loops to long counted loops + if (converter.should_stress_long_counted_loop() && converter.stress_long_counted_loop()) { + return false; + } +#endif - Node* back_control = loop_exit_control(x, loop); - if (back_control == nullptr) { + loop = converter.convert(); + return true; + } + + return false; +} + +bool CountedLoopConverter::is_counted_loop() { + PhaseIterGVN* igvn = &_phase->igvn(); + + _structure.build(); + if (!_structure.is_valid()) { return false; } - BoolTest::mask bt = BoolTest::illegal; - float cl_prob = 0; - Node* incr = nullptr; - Node* limit = nullptr; - Node* cmp = loop_exit_test(back_control, loop, incr, limit, bt, cl_prob); - if (cmp == nullptr || cmp->Opcode() != Op_Cmp(iv_bt)) { - return false; // Avoid pointer & float & 64-bit compares - } + // ================================================= + // ---- Is the loop trip counted? ---- - // Trip-counter increment must be commutative & associative. - if (incr->Opcode() == Op_Cast(iv_bt)) { - incr = incr->in(1); - } - - Node* phi_incr = nullptr; - incr = loop_iv_incr(incr, x, loop, phi_incr); - if (incr == nullptr) { + // Check trip counter will end up higher than the limit + if (_structure.is_infinite_loop()) { return false; } - Node* trunc1 = nullptr; - Node* trunc2 = nullptr; - const TypeInteger* iv_trunc_t = nullptr; - Node* orig_incr = incr; - if (!(incr = CountedLoopNode::match_incr_with_optional_truncation(incr, &trunc1, &trunc2, &iv_trunc_t, iv_bt))) { - return false; // Funny increment opcode - } - assert(incr->Opcode() == Op_Add(iv_bt), "wrong increment code"); - - Node* xphi = nullptr; - Node* stride = loop_iv_stride(incr, xphi); - - if (stride == nullptr) { - return false; - } - - // Iteratively uncast the loop induction variable - // until no more CastII/CastLL nodes are found. - while (xphi->Opcode() == Op_Cast(iv_bt)) { - xphi = xphi->in(1); - } - // Stride must be constant - jlong stride_con = stride->get_integer_as_long(iv_bt); - assert(stride_con != 0, "missed some peephole opt"); - - PhiNode* phi = loop_iv_phi(xphi, phi_incr, x); - - if (phi == nullptr || - (trunc1 == nullptr && phi->in(LoopNode::LoopBackControl) != incr) || - (trunc1 != nullptr && phi->in(LoopNode::LoopBackControl) != trunc1)) { + const jlong stride_con = _structure.stride_con(); + if (stride_con == 0) { return false; } - Node* iftrue = back_control; - uint iftrue_op = iftrue->Opcode(); - Node* iff = iftrue->in(0); - BoolNode* test = iff->in(1)->as_Bool(); - - const TypeInteger* limit_t = gvn->type(limit)->is_integer(iv_bt); - if (trunc1 != nullptr) { - // When there is a truncation, we must be sure that after the truncation - // the trip counter will end up higher than the limit, otherwise we are looking - // at an endless loop. Can happen with range checks. - - // Example: - // int i = 0; - // while (true) - // sum + = array[i]; - // i++; - // i = i && 0x7fff; - // } - // - // If the array is shorter than 0x8000 this exits through a AIOOB - // - Counted loop transformation is ok - // If the array is longer then this is an endless loop - // - No transformation can be done. - - const TypeInteger* incr_t = gvn->type(orig_incr)->is_integer(iv_bt); - if (limit_t->hi_as_long() > incr_t->hi_as_long()) { - // if the limit can have a higher value than the increment (before the phi) - return false; - } - } - - Node *init_trip = phi->in(LoopNode::EntryControl); - - // If iv trunc type is smaller than int, check for possible wrap. - if (!TypeInteger::bottom(iv_bt)->higher_equal(iv_trunc_t)) { - assert(trunc1 != nullptr, "must have found some truncation"); - - // Get a better type for the phi (filtered thru if's) - const TypeInteger* phi_ft = filtered_type(phi); - - // Can iv take on a value that will wrap? - // - // Ensure iv's limit is not within "stride" of the wrap value. - // - // Example for "short" type - // Truncation ensures value is in the range -32768..32767 (iv_trunc_t) - // If the stride is +10, then the last value of the induction - // variable before the increment (phi_ft->_hi) must be - // <= 32767 - 10 and (phi_ft->_lo) must be >= -32768 to - // ensure no truncation occurs after the increment. - - if (stride_con > 0) { - if (iv_trunc_t->hi_as_long() - phi_ft->hi_as_long() < stride_con || - iv_trunc_t->lo_as_long() > phi_ft->lo_as_long()) { - return false; // truncation may occur - } - } else if (stride_con < 0) { - if (iv_trunc_t->lo_as_long() - phi_ft->lo_as_long() > stride_con || - iv_trunc_t->hi_as_long() < phi_ft->hi_as_long()) { - return false; // truncation may occur - } - } - // No possibility of wrap so truncation can be discarded - // Promote iv type to Int - } else { - assert(trunc1 == nullptr && trunc2 == nullptr, "no truncation for int"); - } - - if (!condition_stride_ok(bt, stride_con)) { + // Check iv type can be promoted to int for short/char/byte loops + if (has_truncation_wrap(_structure.truncated_increment(), _structure.phi(), stride_con)) { return false; } - const TypeInteger* init_t = gvn->type(init_trip)->is_integer(iv_bt); - - if (stride_con > 0) { - if (init_t->lo_as_long() > max_signed_integer(iv_bt) - stride_con) { - return false; // cyclic loop - } - } else { - if (init_t->hi_as_long() < min_signed_integer(iv_bt) - stride_con) { - return false; // cyclic loop - } - } - - if (phi_incr != nullptr && bt != BoolTest::ne) { - // check if there is a possibility of IV overflowing after the first increment - if (stride_con > 0) { - if (init_t->hi_as_long() > max_signed_integer(iv_bt) - stride_con) { - return false; - } - } else { - if (init_t->lo_as_long() < min_signed_integer(iv_bt) - stride_con) { - return false; - } - } + // Check iv is not overflowing + Node* init_trip = _structure.phi()->in(LoopNode::EntryControl); + const TypeInteger* init_t = igvn->type(init_trip)->is_integer(_iv_bt); + if (is_iv_overflowing(init_t, stride_con, _structure.iv_incr().phi_incr(), _structure.exit_test().mask())) { + return false; } // ================================================= // ---- SUCCESS! Found A Trip-Counted Loop! ----- - // - if (x->Opcode() == Op_Region) { - // x has not yet been transformed to Loop or LongCountedLoop. + if (_head->Opcode() == Op_Region) { + // head has not yet been transformed to Loop or LongCountedLoop. // This should only happen if we are inside an infinite loop. // It happens like this: // build_loop_tree -> do not attach infinite loop and nested loops // beautify_loops -> does not transform the infinite and nested loops to LoopNode, because not attached yet // build_loop_tree -> find and attach infinite and nested loops // counted_loop -> nested Regions are not yet transformed to LoopNodes, we land here - assert(x->as_Region()->is_in_infinite_subgraph(), - "x can only be a Region and not Loop if inside infinite loop"); + assert(_head->as_Region()->is_in_infinite_subgraph(), + "head can only be a Region and not Loop if inside infinite loop"); // Come back later when Region is transformed to LoopNode return false; } - assert(x->Opcode() == Op_Loop || x->Opcode() == Op_LongCountedLoop, "regular loops only"); - C->print_method(PHASE_BEFORE_CLOOPS, 3, x); + assert(_head->Opcode() == Op_Loop || _head->Opcode() == Op_LongCountedLoop, "regular loops only"); // =================================================== // We can only convert this loop to a counted loop if we can guarantee that the iv phi will never overflow at runtime. @@ -2123,23 +2189,10 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv // When converting a loop to a counted loop, we want to have a canonicalized loop exit check of the form: // iv_post_i < adjusted_limit // - // If that is not the case, we need to canonicalize the loop exit check by using different values for adjusted_limit: - // (LE1) iv_post_i < limit: Already canonicalized. We can directly use limit as adjusted_limit. - // -> adjusted_limit = limit. - // (LE2) iv_post_i <= limit: - // iv_post_i < limit + 1 - // -> adjusted limit = limit + 1 - // (LE3) iv_pre_i < limit: - // iv_pre_i + stride < limit + stride - // iv_post_i < limit + stride - // -> adjusted_limit = limit + stride - // (LE4) iv_pre_i <= limit: - // iv_pre_i < limit + 1 - // iv_pre_i + stride < limit + stride + 1 - // iv_post_i < limit + stride + 1 - // -> adjusted_limit = limit + stride + 1 + // If that is not the case, we need to canonicalize the loop exit check by using different values for adjusted_limit + // (see LoopStructure::final_limit_correction()). // - // Note that: + // Note that after canonicalization: // (AL) limit <= adjusted_limit. // // The following loop invariant has to hold for counted loops with n iterations (i.e. loop exit check true after n-th @@ -2259,78 +2312,63 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv // there is no overflow of the iv phi after the first iteration. In this case, we don't need to check (ii) // again and can skip the predicate. - // Check (vi) and bail out if the stride is too big. - if (stride_con == min_signed_integer(iv_bt) || (ABS(stride_con) > max_signed_integer(iv_bt) / 2)) { - return false; + const TypeInteger* limit_t = igvn->type(_structure.limit())->is_integer(_iv_bt); + StrideOverflowState stride_overflow_state = check_stride_overflow(_structure.final_limit_correction(), limit_t, _iv_bt); + + Node* init_control = _head->in(LoopNode::EntryControl); + const Predicates predicates(init_control); + const PredicateBlock* loop_limit_check_predicate_block = predicates.loop_limit_check_predicate_block(); + + if (stride_overflow_state == Overflow) { + return false; // Bailout: integer overflow is certain. } - // Accounting for (LE3) and (LE4) where we use pre-incremented phis in the loop exit check. - const jlong limit_correction_for_pre_iv_exit_check = (phi_incr != nullptr) ? stride_con : 0; - - // Accounting for (LE2) and (LE4) where we use <= or >= in the loop exit check. - const bool includes_limit = (bt == BoolTest::le || bt == BoolTest::ge); - const jlong limit_correction_for_le_ge_exit_check = (includes_limit ? (stride_con > 0 ? 1 : -1) : 0); - - const jlong limit_correction = limit_correction_for_pre_iv_exit_check + limit_correction_for_le_ge_exit_check; - const jlong canonicalized_correction = stride_con + (stride_con > 0 ? -1 : 1); - const jlong final_correction = canonicalized_correction + limit_correction; - - int sov = check_stride_overflow(final_correction, limit_t, iv_bt); - Node* init_control = x->in(LoopNode::EntryControl); - - // If sov==0, limit's type always satisfies the condition, for + // If stride_overflow_state == NO_OVERFLOW, limit's type always satisfies the condition, for // example, when it is an array length. - if (sov != 0) { - if (sov < 0) { - return false; // Bailout: integer overflow is certain. - } + + _should_insert_stride_overflow_limit_check = false; + if (stride_overflow_state == RequireLimitCheck) { // (1) Loop Limit Check Predicate is required because we could not statically prove that // limit + final_correction = adjusted_limit - 1 + stride <= max_int - assert(!x->as_Loop()->is_loop_nest_inner_loop(), "loop was transformed"); - const Predicates predicates(init_control); - const PredicateBlock* loop_limit_check_predicate_block = predicates.loop_limit_check_predicate_block(); + assert(!_head->as_Loop()->is_loop_nest_inner_loop(), "loop was transformed"); if (!loop_limit_check_predicate_block->has_parse_predicate()) { // The Loop Limit Check Parse Predicate is not generated if this method trapped here before. #ifdef ASSERT if (TraceLoopLimitCheck) { tty->print("Missing Loop Limit Check Parse Predicate:"); - loop->dump_head(); - x->dump(1); + _loop->dump_head(); + _head->dump(1); } #endif return false; } ParsePredicateNode* loop_limit_check_parse_predicate = loop_limit_check_predicate_block->parse_predicate(); - if (!is_dominator(get_ctrl(limit), loop_limit_check_parse_predicate->in(0))) { + if (!_phase->is_dominator(_phase->get_ctrl(_structure.limit()), loop_limit_check_parse_predicate->in(0))) { return false; } - Node* cmp_limit; - Node* bol; - - if (stride_con > 0) { - cmp_limit = CmpNode::make(limit, _igvn.integercon(max_signed_integer(iv_bt) - final_correction, iv_bt), iv_bt); - bol = new BoolNode(cmp_limit, BoolTest::le); - } else { - cmp_limit = CmpNode::make(limit, _igvn.integercon(min_signed_integer(iv_bt) - final_correction, iv_bt), iv_bt); - bol = new BoolNode(cmp_limit, BoolTest::ge); - } - - insert_loop_limit_check_predicate(init_control->as_IfTrue(), cmp_limit, bol); + _should_insert_stride_overflow_limit_check = true; } // (2.3) const bool init_plus_stride_could_overflow = - (stride_con > 0 && init_t->hi_as_long() > max_signed_integer(iv_bt) - stride_con) || - (stride_con < 0 && init_t->lo_as_long() < min_signed_integer(iv_bt) - stride_con); - // (2.1) - const bool init_gte_limit = (stride_con > 0 && init_t->hi_as_long() >= limit_t->lo_as_long()) || - (stride_con < 0 && init_t->lo_as_long() <= limit_t->hi_as_long()); + (stride_con > 0 && init_t->hi_as_long() > max_signed_integer(_iv_bt) - stride_con) || + (stride_con < 0 && init_t->lo_as_long() < min_signed_integer(_iv_bt) - stride_con); + // (2.1) + const bool init_gte_limit = + (stride_con > 0 && init_t->hi_as_long() >= limit_t->lo_as_long()) || + (stride_con < 0 && init_t->lo_as_long() <= limit_t->hi_as_long()); + + _should_insert_init_trip_limit_check = false; if (init_gte_limit && // (2.1) - ((bt == BoolTest::ne || init_plus_stride_could_overflow) && // (2.3) - !has_dominating_loop_limit_check(init_trip, limit, stride_con, iv_bt, init_control))) { // (2.2) + ((_structure.exit_test().mask() == BoolTest::ne || init_plus_stride_could_overflow) && // (2.3) + !has_dominating_loop_limit_check(init_trip, + _structure.limit(), + stride_con, + _iv_bt, + init_control))) { // (2.2) // (2) Iteration Loop Limit Check Predicate is required because neither (2.1), (2.2), nor (2.3) holds. // We use the following condition: // - stride > 0: init < limit @@ -2340,15 +2378,13 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv // a requirement). We transform the loop exit check by using a less-than-operator. By doing so, we must always // check that init < limit. Otherwise, we could have a different number of iterations at runtime. - const Predicates predicates(init_control); - const PredicateBlock* loop_limit_check_predicate_block = predicates.loop_limit_check_predicate_block(); if (!loop_limit_check_predicate_block->has_parse_predicate()) { // The Loop Limit Check Parse Predicate is not generated if this method trapped here before. #ifdef ASSERT if (TraceLoopLimitCheck) { tty->print("Missing Loop Limit Check Parse Predicate:"); - loop->dump_head(); - x->dump(1); + _loop->dump_head(); + _head->dump(1); } #endif return false; @@ -2356,81 +2392,196 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv ParsePredicateNode* loop_limit_check_parse_predicate = loop_limit_check_predicate_block->parse_predicate(); Node* parse_predicate_entry = loop_limit_check_parse_predicate->in(0); - if (!is_dominator(get_ctrl(limit), parse_predicate_entry) || - !is_dominator(get_ctrl(init_trip), parse_predicate_entry)) { + if (!_phase->is_dominator(_phase->get_ctrl(_structure.limit()), parse_predicate_entry) || + !_phase->is_dominator(_phase->get_ctrl(init_trip), parse_predicate_entry)) { return false; } - Node* cmp_limit; - Node* bol; - - if (stride_con > 0) { - cmp_limit = CmpNode::make(init_trip, limit, iv_bt); - bol = new BoolNode(cmp_limit, BoolTest::lt); - } else { - cmp_limit = CmpNode::make(init_trip, limit, iv_bt); - bol = new BoolNode(cmp_limit, BoolTest::gt); - } - - insert_loop_limit_check_predicate(init_control->as_IfTrue(), cmp_limit, bol); + _should_insert_init_trip_limit_check = true; } - if (bt == BoolTest::ne) { - // Now we need to canonicalize the loop condition if it is 'ne'. - assert(stride_con == 1 || stride_con == -1, "simple increment only - checked before"); - if (stride_con > 0) { - // 'ne' can be replaced with 'lt' only when init < limit. This is ensured by the inserted predicate above. - bt = BoolTest::lt; - } else { - assert(stride_con < 0, "must be"); - // 'ne' can be replaced with 'gt' only when init > limit. This is ensured by the inserted predicate above. - bt = BoolTest::gt; - } + _structure.exit_test().canonicalize_mask(stride_con); + + if (is_safepoint_invalid(_structure.sfpt())) { + return false; } - Node* sfpt = nullptr; - if (loop->_child == nullptr) { - sfpt = find_safepoint(back_control, x, loop); +#ifdef ASSERT + _checked_for_counted_loop = true; +#endif + +#ifndef PRODUCT + if (StressCountedLoop && (_phase->C->random() % 2 == 0)) { + return false; + } +#endif + + return true; +} + +bool CountedLoopConverter::is_iv_overflowing(const TypeInteger* init_t, jlong stride_con, Node* phi_increment, + BoolTest::mask mask) const { + if (stride_con > 0) { + if (init_t->lo_as_long() > max_signed_integer(_iv_bt) - stride_con) { + return true; // cyclic loop + } } else { - sfpt = iff->in(0); - if (sfpt->Opcode() != Op_SafePoint) { - sfpt = nullptr; + if (init_t->hi_as_long() < min_signed_integer(_iv_bt) - stride_con) { + return true; // cyclic loop } } - if (x->in(LoopNode::LoopBackControl)->Opcode() == Op_SafePoint) { - Node* backedge_sfpt = x->in(LoopNode::LoopBackControl); - if (((iv_bt == T_INT && LoopStripMiningIter != 0) || - iv_bt == T_LONG) && + if (phi_increment != nullptr && mask != BoolTest::ne) { + // check if there is a possibility of IV overflowing after the first increment + if (stride_con > 0) { + if (init_t->hi_as_long() > max_signed_integer(_iv_bt) - stride_con) { + return true; + } + } else { + if (init_t->lo_as_long() < min_signed_integer(_iv_bt) - stride_con) { + return true; + } + } + } + + return false; +} + +bool CountedLoopConverter::LoopStructure::is_infinite_loop() const { + PhaseIterGVN& igvn = _phase->igvn(); + const TypeInteger* limit_t = igvn.type(limit())->is_integer(_iv_bt); + + if (_truncated_increment.outer_trunc() != nullptr) { + // When there is a truncation, we must be sure that after the truncation + // the trip counter will end up higher than the limit, otherwise we are looking + // at an endless loop. Can happen with range checks. + + // Example: + // int i = 0; + // while (true) { + // sum + = array[i]; + // i++; + // i = i && 0x7fff; + // } + // + // If the array is shorter than 0x8000 this exits through an AIOOB + // - Counted loop transformation is ok + // If the array is longer then this is an endless loop + // - No transformation can be done. + + const TypeInteger* incr_t = igvn.type(_iv_incr.incr())->is_integer(_iv_bt); + if (limit_t->hi_as_long() > incr_t->hi_as_long()) { + // if the limit can have a higher value than the increment (before the phi) + return true; + } + } + + return false; +} + +bool CountedLoopConverter::has_truncation_wrap(const TruncatedIncrement& truncation, Node* phi, jlong stride_con) { + // If iv trunc type is smaller than int (i.e., short/char/byte), check for possible wrap. + if (!TypeInteger::bottom(_iv_bt)->higher_equal(truncation.trunc_type())) { + assert(truncation.outer_trunc() != nullptr, "must have found some truncation"); + + // Get a better type for the phi (filtered thru if's) + const TypeInteger* phi_ft = filtered_type(phi); + + // Can iv take on a value that will wrap? + // + // Ensure iv's limit is not within "stride" of the wrap value. + // + // Example for "short" type + // Truncation ensures value is in the range -32768..32767 (iv_trunc_t) + // If the stride is +10, then the last value of the induction + // variable before the increment (phi_ft->_hi) must be + // <= 32767 - 10 and (phi_ft->_lo) must be >= -32768 to + // ensure no truncation occurs after the increment. + + if (stride_con > 0) { + if (truncation.trunc_type()->hi_as_long() - phi_ft->hi_as_long() < stride_con || + truncation.trunc_type()->lo_as_long() > phi_ft->lo_as_long()) { + return true; // truncation may occur + } + } else if (stride_con < 0) { + if (truncation.trunc_type()->lo_as_long() - phi_ft->lo_as_long() > stride_con || + truncation.trunc_type()->hi_as_long() < phi_ft->hi_as_long()) { + return true; // truncation may occur + } + } + + // No possibility of wrap so truncation can be discarded + // Promote iv type to Int + } else { + assert(Type::equals(truncation.trunc_type(), TypeInt::INT) || Type::equals(truncation.trunc_type(), TypeLong::LONG), + "unexpected truncation type"); + assert(truncation.outer_trunc() == nullptr && truncation.inner_trunc() == nullptr, "no truncation for int"); + } + + return false; +} + +SafePointNode* CountedLoopConverter::find_safepoint(Node* iftrue) { + Node* iff = iftrue->in(0); + + if (_loop->_child == nullptr) { + return _phase->find_safepoint(iftrue, _head, _loop); + } + + Node* sfpt = iff->in(0); + if (sfpt->Opcode() == Op_SafePoint) { + return sfpt->as_SafePoint(); + } + return nullptr; +} + +bool CountedLoopConverter::is_safepoint_invalid(SafePointNode* sfpt) const { + if (_head->in(LoopNode::LoopBackControl)->Opcode() == Op_SafePoint) { + if (((_iv_bt == T_INT && LoopStripMiningIter != 0) || + _iv_bt == T_LONG) && sfpt == nullptr) { // Leaving the safepoint on the backedge and creating a // CountedLoop will confuse optimizations. We can't move the // safepoint around because its jvm state wouldn't match a new // location. Give up on that loop. - return false; - } - if (is_deleteable_safept(backedge_sfpt)) { - replace_node_and_forward_ctrl(backedge_sfpt, iftrue); - if (loop->_safepts != nullptr) { - loop->_safepts->yank(backedge_sfpt); - } - loop->_tail = iftrue; + return true; } } + return false; +} +IdealLoopTree* CountedLoopConverter::convert() { #ifdef ASSERT - if (iv_bt == T_INT && - !x->as_Loop()->is_loop_nest_inner_loop() && - StressLongCountedLoop > 0 && - trunc1 == nullptr && - convert_to_long_loop(cmp, phi, loop)) { - return false; - } + assert(_checked_for_counted_loop, "must check for counted loop before conversion"); #endif - Node* adjusted_limit = limit; - if (phi_incr != nullptr) { + PhaseIterGVN* igvn = &_phase->igvn(); + + _phase->C->print_method(PHASE_BEFORE_CLOOPS, 3, _head); + + if (_should_insert_stride_overflow_limit_check) { + insert_stride_overflow_limit_check(); + } + + if (_should_insert_init_trip_limit_check) { + insert_init_trip_limit_check(); + } + + Node* back_control = _phase->loop_exit_control(_loop); + if (_head->in(LoopNode::LoopBackControl)->Opcode() == Op_SafePoint) { + Node* backedge_sfpt = _head->in(LoopNode::LoopBackControl); + if (_phase->is_deleteable_safept(backedge_sfpt)) { + _phase->replace_node_and_forward_ctrl(backedge_sfpt, back_control); + if (_loop->_safepts != nullptr) { + _loop->_safepts->yank(backedge_sfpt); + } + _loop->_tail = back_control; + } + } + + Node* adjusted_limit = _structure.limit(); + if (_structure.iv_incr().phi_incr() != nullptr) { // If compare points directly to the phi we need to adjust // the compare so that it points to the incr. Limit have // to be adjusted to keep trip count the same and we @@ -2440,128 +2591,147 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv // is converted to // i = init; do {} while(++i < limit+1); // - adjusted_limit = gvn->transform(AddNode::make(limit, stride, iv_bt)); + adjusted_limit = igvn->transform(AddNode::make(_structure.limit(), _structure.stride().stride_node(), _iv_bt)); } - if (includes_limit) { + BoolTest::mask mask = _structure.exit_test().mask(); + if (_structure.exit_test().should_include_limit()) { // The limit check guaranties that 'limit <= (max_jint - stride)' so // we can convert 'i <= limit' to 'i < limit+1' since stride != 0. - // - Node* one = (stride_con > 0) ? gvn->integercon( 1, iv_bt) : gvn->integercon(-1, iv_bt); - adjusted_limit = gvn->transform(AddNode::make(adjusted_limit, one, iv_bt)); - if (bt == BoolTest::le) - bt = BoolTest::lt; - else if (bt == BoolTest::ge) - bt = BoolTest::gt; - else + Node* one = (_structure.stride_con() > 0) ? igvn->integercon(1, _iv_bt) : igvn->integercon(-1, _iv_bt); + adjusted_limit = igvn->transform(AddNode::make(adjusted_limit, one, _iv_bt)); + if (mask == BoolTest::le) { + mask = BoolTest::lt; + } else if (mask == BoolTest::ge) { + mask = BoolTest::gt; + } else { ShouldNotReachHere(); + } } - set_subtree_ctrl(adjusted_limit, false); + _phase->set_subtree_ctrl(adjusted_limit, false); // Build a canonical trip test. // Clone code, as old values may be in use. - incr = incr->clone(); - incr->set_req(1,phi); - incr->set_req(2,stride); - incr = _igvn.register_new_node_with_optimizer(incr); - set_early_ctrl(incr, false); - _igvn.rehash_node_delayed(phi); - phi->set_req_X( LoopNode::LoopBackControl, incr, &_igvn ); + Node* incr = _structure.truncated_increment().incr()->clone(); + incr->set_req(1, _structure.phi()); + incr->set_req(2, _structure.stride().stride_node()); + incr = igvn->register_new_node_with_optimizer(incr); + _phase->set_early_ctrl(incr, false); + igvn->rehash_node_delayed(_structure.phi()); + _structure.phi()->set_req_X(LoopNode::LoopBackControl, incr, igvn); // If phi type is more restrictive than Int, raise to // Int to prevent (almost) infinite recursion in igvn // which can only handle integer types for constants or minint..maxint. - if (!TypeInteger::bottom(iv_bt)->higher_equal(phi->bottom_type())) { - Node* nphi = PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInteger::bottom(iv_bt)); + Node* phi = _structure.phi(); + if (!TypeInteger::bottom(_iv_bt)->higher_equal(phi->bottom_type())) { + Node* nphi = + PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInteger::bottom(_iv_bt)); nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl)); - nphi = _igvn.register_new_node_with_optimizer(nphi); - set_ctrl(nphi, get_ctrl(phi)); - _igvn.replace_node(phi, nphi); + nphi = igvn->register_new_node_with_optimizer(nphi); + _phase->set_ctrl(nphi, _phase->get_ctrl(phi)); + igvn->replace_node(phi, nphi); phi = nphi->as_Phi(); } - cmp = cmp->clone(); - cmp->set_req(1,incr); - cmp->set_req(2, adjusted_limit); - cmp = _igvn.register_new_node_with_optimizer(cmp); - set_ctrl(cmp, iff->in(0)); - test = test->clone()->as_Bool(); - (*(BoolTest*)&test->_test)._test = bt; - test->set_req(1,cmp); - _igvn.register_new_node_with_optimizer(test); - set_ctrl(test, iff->in(0)); + Node* iftrue = back_control; + const uint iftrue_op = iftrue->Opcode(); + Node* iff = iftrue->in(0); + + // Replace the old CmpNode with new adjusted_limit + Node* new_cmp = _structure.exit_test().cmp()->clone(); + new_cmp->set_req(1, incr); + new_cmp->set_req(2, adjusted_limit); + new_cmp = igvn->register_new_node_with_optimizer(new_cmp); + _phase->set_ctrl(new_cmp, iff->in(0)); + + // Replace the old BoolNode with new CmpNode + BoolNode* new_test = iff->in(1)->clone()->as_Bool(); + const_cast(&new_test->_test)->_test = mask; // Yes, it's a const, but it's a newly cloned node so we should be fine. + new_test->set_req(1, new_cmp); + igvn->register_new_node_with_optimizer(new_test); + _phase->set_ctrl(new_test, iff->in(0)); // Replace the old IfNode with a new LoopEndNode - Node *lex = _igvn.register_new_node_with_optimizer(BaseCountedLoopEndNode::make(iff->in(0), test, cl_prob, iff->as_If()->_fcnt, iv_bt)); - IfNode *le = lex->as_If(); - uint dd = dom_depth(iff); - set_idom(le, le->in(0), dd); // Update dominance for loop exit - set_loop(le, loop); + Node* loop_end = igvn->register_new_node_with_optimizer(BaseCountedLoopEndNode::make(iff->in(0), + new_test, + _structure.exit_test().cl_prob(), + iff->as_If()->_fcnt, + _iv_bt)); + IfNode* loop_end_exit = loop_end->as_If(); + const uint dd = _phase->dom_depth(iff); + _phase->set_idom(loop_end_exit, loop_end_exit->in(0), dd); // Update dominance for loop exit + _phase->set_loop(loop_end_exit, _loop); // Get the loop-exit control - Node *iffalse = iff->as_If()->proj_out(!(iftrue_op == Op_IfTrue)); + Node* iffalse = iff->as_If()->proj_out(!(iftrue_op == Op_IfTrue)); // Need to swap loop-exit and loop-back control? if (iftrue_op == Op_IfFalse) { - Node *ift2=_igvn.register_new_node_with_optimizer(new IfTrueNode (le)); - Node *iff2=_igvn.register_new_node_with_optimizer(new IfFalseNode(le)); + Node* ift2 = igvn->register_new_node_with_optimizer(new IfTrueNode(loop_end_exit)); + Node* iff2 = igvn->register_new_node_with_optimizer(new IfFalseNode(loop_end_exit)); - loop->_tail = back_control = ift2; - set_loop(ift2, loop); - set_loop(iff2, get_loop(iffalse)); + _loop->_tail = back_control = ift2; + _phase->set_loop(ift2, _loop); + _phase->set_loop(iff2, _phase->get_loop(iffalse)); // Lazy update of 'get_ctrl' mechanism. - replace_node_and_forward_ctrl(iffalse, iff2); - replace_node_and_forward_ctrl(iftrue, ift2); + _phase->replace_node_and_forward_ctrl(iffalse, iff2); + _phase->replace_node_and_forward_ctrl(iftrue, ift2); // Swap names iffalse = iff2; - iftrue = ift2; + iftrue = ift2; } else { - _igvn.rehash_node_delayed(iffalse); - _igvn.rehash_node_delayed(iftrue); - iffalse->set_req_X( 0, le, &_igvn ); - iftrue ->set_req_X( 0, le, &_igvn ); + igvn->rehash_node_delayed(iffalse); + igvn->rehash_node_delayed(iftrue); + iffalse->set_req_X(0, loop_end_exit, igvn); + iftrue->set_req_X(0, loop_end_exit, igvn); } - set_idom(iftrue, le, dd+1); - set_idom(iffalse, le, dd+1); + _phase->set_idom(iftrue, loop_end_exit, dd + 1); + _phase->set_idom(iffalse, loop_end_exit, dd + 1); assert(iff->outcnt() == 0, "should be dead now"); - replace_node_and_forward_ctrl(iff, le); // fix 'get_ctrl' + _phase->replace_node_and_forward_ctrl(iff, loop_end_exit); // fix 'get_ctrl' + Node* init_control = _head->in(LoopNode::EntryControl); Node* entry_control = init_control; - bool strip_mine_loop = iv_bt == T_INT && - loop->_child == nullptr && - sfpt != nullptr && - !loop->_has_call && - is_deleteable_safept(sfpt); + bool strip_mine_loop = _iv_bt == T_INT && + _loop->_child == nullptr && + _structure.sfpt() != nullptr && + !_loop->_has_call && + _phase->is_deleteable_safept(_structure.sfpt()); IdealLoopTree* outer_ilt = nullptr; if (strip_mine_loop) { - outer_ilt = create_outer_strip_mined_loop(init_control, loop, cl_prob, le->_fcnt, - entry_control, iffalse); + outer_ilt = _phase->create_outer_strip_mined_loop(init_control, + _loop, + _structure.exit_test().cl_prob(), + loop_end_exit->_fcnt, + entry_control, + iffalse); } // Now setup a new CountedLoopNode to replace the existing LoopNode - BaseCountedLoopNode *l = BaseCountedLoopNode::make(entry_control, back_control, iv_bt); - l->set_unswitch_count(x->as_Loop()->unswitch_count()); // Preserve + BaseCountedLoopNode* l = BaseCountedLoopNode::make(entry_control, back_control, _iv_bt); + l->set_unswitch_count(_head->as_Loop()->unswitch_count()); // Preserve // The following assert is approximately true, and defines the intention // of can_be_counted_loop. It fails, however, because phase->type // is not yet initialized for this loop and its parts. //assert(l->can_be_counted_loop(this), "sanity"); - _igvn.register_new_node_with_optimizer(l); - set_loop(l, loop); - loop->_head = l; + igvn->register_new_node_with_optimizer(l); + _phase->set_loop(l, _loop); + _loop->_head = l; // Fix all data nodes placed at the old loop head. // Uses the lazy-update mechanism of 'get_ctrl'. - replace_node_and_forward_ctrl(x, l); - set_idom(l, entry_control, dom_depth(entry_control) + 1); + _phase->replace_node_and_forward_ctrl(_head, l); + _phase->set_idom(l, entry_control, _phase->dom_depth(entry_control) + 1); - if (iv_bt == T_INT && (LoopStripMiningIter == 0 || strip_mine_loop)) { + if (_iv_bt == T_INT && (LoopStripMiningIter == 0 || strip_mine_loop)) { // Check for immediately preceding SafePoint and remove - if (sfpt != nullptr && (strip_mine_loop || is_deleteable_safept(sfpt))) { + if (_structure.sfpt() != nullptr && (strip_mine_loop || _phase->is_deleteable_safept(_structure.sfpt()))) { if (strip_mine_loop) { Node* outer_le = outer_ilt->_tail->in(0); - Node* sfpt_clone = sfpt->clone(); + Node* sfpt_clone = _structure.sfpt()->clone(); sfpt_clone->set_req(0, iffalse); outer_le->set_req(0, sfpt_clone); @@ -2570,40 +2740,42 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv // Polling load should be pinned outside inner loop. Node* new_polladdr = polladdr->clone(); new_polladdr->set_req(0, iffalse); - _igvn.register_new_node_with_optimizer(new_polladdr, polladdr); - set_ctrl(new_polladdr, iffalse); + igvn->register_new_node_with_optimizer(new_polladdr, polladdr); + _phase->set_ctrl(new_polladdr, iffalse); sfpt_clone->set_req(TypeFunc::Parms, new_polladdr); } // When this code runs, loop bodies have not yet been populated. const bool body_populated = false; - register_control(sfpt_clone, outer_ilt, iffalse, body_populated); - set_idom(outer_le, sfpt_clone, dom_depth(sfpt_clone)); + _phase->register_control(sfpt_clone, outer_ilt, iffalse, body_populated); + _phase->set_idom(outer_le, sfpt_clone, _phase->dom_depth(sfpt_clone)); } - replace_node_and_forward_ctrl(sfpt, sfpt->in(TypeFunc::Control)); - if (loop->_safepts != nullptr) { - loop->_safepts->yank(sfpt); + _phase->replace_node_and_forward_ctrl(_structure.sfpt(), _structure.sfpt()->in(TypeFunc::Control)); + if (_loop->_safepts != nullptr) { + _loop->_safepts->yank(_structure.sfpt()); } } } #ifdef ASSERT - assert(l->is_valid_counted_loop(iv_bt), "counted loop shape is messed up"); - assert(l == loop->_head && l->phi() == phi && l->loopexit_or_null() == lex, "" ); + assert(l->is_valid_counted_loop(_iv_bt), "counted loop shape is messed up"); + assert(l == _loop->_head && l->phi() == phi && l->loopexit_or_null() == loop_end, "" ); #endif + #ifndef PRODUCT if (TraceLoopOpts) { tty->print("Counted "); - loop->dump_head(); + _loop->dump_head(); } #endif - C->print_method(PHASE_AFTER_CLOOPS, 3, l); - // Capture bounds of the loop in the induction variable Phi before // subsequent transformation (iteration splitting) obscures the // bounds - l->phi()->as_Phi()->set_type(l->phi()->Value(&_igvn)); + l->phi()->as_Phi()->set_type(l->phi()->Value(igvn)); + _phase->C->print_method(PHASE_AFTER_CLOOPS, 3, l); + + IdealLoopTree* loop = _loop; if (strip_mine_loop) { l->mark_strip_mined(); l->verify_strip_mined(1); @@ -2612,21 +2784,24 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*& loop, BasicType iv } #ifndef PRODUCT - if (x->as_Loop()->is_loop_nest_inner_loop() && iv_bt == T_LONG) { + if (_head->as_Loop()->is_loop_nest_inner_loop() && _iv_bt == T_LONG) { AtomicAccess::inc(&_long_loop_counted_loops); } #endif - if (iv_bt == T_LONG && x->as_Loop()->is_loop_nest_outer_loop()) { + + if (_iv_bt == T_LONG && _head->as_Loop()->is_loop_nest_outer_loop()) { l->mark_loop_nest_outer_loop(); } - return true; + return loop; } // Check if there is a dominating loop limit check of the form 'init < limit' starting at the loop entry. // If there is one, then we do not need to create an additional Loop Limit Check Predicate. -bool PhaseIdealLoop::has_dominating_loop_limit_check(Node* init_trip, Node* limit, const jlong stride_con, - const BasicType iv_bt, Node* loop_entry) { +bool CountedLoopConverter::has_dominating_loop_limit_check(Node* init_trip, Node* limit, const jlong stride_con, + const BasicType iv_bt, Node* loop_entry) const { + PhaseIterGVN& _igvn = _phase->igvn(); + // Eagerly call transform() on the Cmp and Bool node to common them up if possible. This is required in order to // successfully find a dominated test with the If node below. Node* cmp_limit; @@ -2649,8 +2824,8 @@ bool PhaseIdealLoop::has_dominating_loop_limit_check(Node* init_trip, Node* limi const bool found_dominating_test = dominated_iff != nullptr && dominated_iff->is_ConI(); // Kill the If with its projections again in the next IGVN round by cutting it off from the graph. - _igvn.replace_input_of(iff, 0, C->top()); - _igvn.replace_input_of(iff, 1, C->top()); + _igvn.replace_input_of(iff, 0, _phase->C->top()); + _igvn.replace_input_of(iff, 1, _phase->C->top()); return found_dominating_test; } @@ -2953,24 +3128,23 @@ Node* LoopLimitNode::Identity(PhaseGVN* phase) { return this; } -//============================================================================= -//----------------------match_incr_with_optional_truncation-------------------- // Match increment with optional truncation: // CHAR: (i+1)&0x7fff, BYTE: ((i+1)<<8)>>8, or SHORT: ((i+1)<<16)>>16 -// Return null for failure. Success returns the increment node. -Node* CountedLoopNode::match_incr_with_optional_truncation(Node* expr, Node** trunc1, Node** trunc2, - const TypeInteger** trunc_type, - BasicType bt) { - // Quick cutouts: - if (expr == nullptr || expr->req() != 3) return nullptr; +void CountedLoopConverter::TruncatedIncrement::build(Node* expr) { + _is_valid = false; - Node *t1 = nullptr; - Node *t2 = nullptr; + // Quick cutouts: + if (expr == nullptr || expr->req() != 3) { + return; + } + + Node* t1 = nullptr; + Node* t2 = nullptr; Node* n1 = expr; int n1op = n1->Opcode(); - const TypeInteger* trunc_t = TypeInteger::bottom(bt); + const TypeInteger* trunc_t = TypeInteger::bottom(_bt); - if (bt == T_INT) { + if (_bt == T_INT) { // Try to strip (n1 & M) or (n1 << N >> N) from n1. if (n1op == Op_AndI && n1->in(2)->is_Con() && @@ -3002,15 +3176,14 @@ Node* CountedLoopNode::match_incr_with_optional_truncation(Node* expr, Node** tr } // If (maybe after stripping) it is an AddI, we won: - if (n1op == Op_Add(bt)) { - *trunc1 = t1; - *trunc2 = t2; - *trunc_type = trunc_t; - return n1; - } + if (n1op == Op_Add(_bt)) { + _incr = n1; + _outer_trunc = t1; + _inner_trunc = t2; + _trunc_type = trunc_t; - // failed - return nullptr; + _is_valid = true; + } } IfNode* CountedLoopNode::find_multiversion_if_from_multiversion_fast_main_loop() { @@ -3662,18 +3835,18 @@ Node *OuterStripMinedLoopEndNode::Ideal(PhaseGVN *phase, bool can_reshape) { // i = ? // } while ( i < 10) // -const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) { +const TypeInt* CountedLoopConverter::filtered_type(Node* n, Node* n_ctrl) { assert(n && n->bottom_type()->is_int(), "must be int"); const TypeInt* filtered_t = nullptr; if (!n->is_Phi()) { - assert(n_ctrl != nullptr || n_ctrl == C->top(), "valid control"); + assert(n_ctrl != nullptr || n_ctrl == _phase->C->top(), "valid control"); filtered_t = filtered_type_from_dominators(n, n_ctrl); } else { Node* phi = n->as_Phi(); Node* region = phi->in(0); assert(n_ctrl == nullptr || n_ctrl == region, "ctrl parameter must be region"); - if (region && region != C->top()) { + if (region && region != _phase->C->top()) { for (uint i = 1; i < phi->req(); i++) { Node* val = phi->in(i); Node* use_c = region->in(i); @@ -3688,7 +3861,7 @@ const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) { } } } - const TypeInt* n_t = _igvn.type(n)->is_int(); + const TypeInt* n_t = _phase->igvn().type(n)->is_int(); if (filtered_t != nullptr) { n_t = n_t->join(filtered_t)->is_int(); } @@ -3698,22 +3871,22 @@ const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) { //------------------------------filtered_type_from_dominators-------------------------------- // Return a possibly more restrictive type for val based on condition control flow of dominators -const TypeInt* PhaseIdealLoop::filtered_type_from_dominators( Node* val, Node *use_ctrl) { +const TypeInt* CountedLoopConverter::filtered_type_from_dominators(Node* val, Node* use_ctrl) { if (val->is_Con()) { return val->bottom_type()->is_int(); } uint if_limit = 10; // Max number of dominating if's visited const TypeInt* rtn_t = nullptr; - if (use_ctrl && use_ctrl != C->top()) { - Node* val_ctrl = get_ctrl(val); - uint val_dom_depth = dom_depth(val_ctrl); + if (use_ctrl && use_ctrl != _phase->C->top()) { + Node* val_ctrl = _phase->get_ctrl(val); + uint val_dom_depth = _phase->dom_depth(val_ctrl); Node* pred = use_ctrl; uint if_cnt = 0; while (if_cnt < if_limit) { if ((pred->Opcode() == Op_IfTrue || pred->Opcode() == Op_IfFalse)) { if_cnt++; - const TypeInt* if_t = IfNode::filtered_int_type(&_igvn, val, pred); + const TypeInt* if_t = IfNode::filtered_int_type(&_phase->igvn(), val, pred); if (if_t != nullptr) { if (rtn_t == nullptr) { rtn_t = if_t; @@ -3722,12 +3895,12 @@ const TypeInt* PhaseIdealLoop::filtered_type_from_dominators( Node* val, Node *u } } } - pred = idom(pred); - if (pred == nullptr || pred == C->top()) { + pred = _phase->idom(pred); + if (pred == nullptr || pred == _phase->C->top()) { break; } // Stop if going beyond definition block of val - if (dom_depth(pred) < val_dom_depth) { + if (_phase->dom_depth(pred) < val_dom_depth) { break; } } @@ -4172,8 +4345,13 @@ void IdealLoopTree::allpaths_check_safepts(VectorSet &visited, Node_List &stack) visited.set(_head->_idx); while (stack.size() > 0) { Node* n = stack.pop(); - if (n->is_Call() && n->as_Call()->guaranteed_safepoint()) { - // Terminate this path + if (n->is_Call() && n->as_Call()->guaranteed_safepoint() + && !(n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method())) { + // Terminate this path: guaranteed safepoint found. + // Boxing CallStaticJava calls are excluded as they may lack a safepoint on the fast path. This is + // not done via CallStaticJavaNode::guaranteed_safepoint() as that also controls PcDesc emission. + // In the future, guaranteed_safepoint() should be reworked to correctly handle boxing methods + // to avoid this additional check. } else if (n->Opcode() == Op_SafePoint) { if (_phase->get_loop(n) != this) { if (_required_safept == nullptr) _required_safept = new Node_List(); @@ -4271,7 +4449,12 @@ void IdealLoopTree::check_safepts(VectorSet &visited, Node_List &stack) { if (!_irreducible) { // Scan the dom-path nodes from tail to head for (Node* n = tail(); n != _head; n = _phase->idom(n)) { - if (n->is_Call() && n->as_Call()->guaranteed_safepoint()) { + // Boxing CallStaticJava calls are excluded as they may lack a safepoint on the fast path. This is + // not done via CallStaticJavaNode::guaranteed_safepoint() as that also controls PcDesc emission. + // In the future, guaranteed_safepoint() should be reworked to correctly handle boxing methods + // to avoid this additional check. + if (n->is_Call() && n->as_Call()->guaranteed_safepoint() + && !(n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method())) { has_call = true; _has_sfpt = 1; // Then no need for a safept! break; @@ -4335,7 +4518,7 @@ void IdealLoopTree::check_safepts(VectorSet &visited, Node_List &stack) { //---------------------------is_deleteable_safept---------------------------- // Is safept not required by an outer loop? -bool PhaseIdealLoop::is_deleteable_safept(Node* sfpt) { +bool PhaseIdealLoop::is_deleteable_safept(Node* sfpt) const { assert(sfpt->Opcode() == Op_SafePoint, ""); IdealLoopTree* lp = get_loop(sfpt)->_parent; while (lp != nullptr) { @@ -4553,9 +4736,7 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) { } IdealLoopTree* loop = this; - if (_head->is_CountedLoop() || - phase->is_counted_loop(_head, loop, T_INT)) { - + if (_head->is_CountedLoop() || phase->try_convert_to_counted_loop(_head, loop, T_INT)) { if (LoopStripMiningIter == 0 || _head->as_CountedLoop()->is_strip_mined()) { // Indicate we do not need a safepoint here _has_sfpt = 1; @@ -4567,11 +4748,14 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) { // Look for induction variables phase->replace_parallel_iv(this); - } else if (_head->is_LongCountedLoop() || - phase->is_counted_loop(_head, loop, T_LONG)) { + } else if (_head->is_LongCountedLoop() || phase->try_convert_to_counted_loop(_head, loop, T_LONG)) { remove_safepoints(phase, true); } else { - assert(!_head->is_Loop() || !_head->as_Loop()->is_loop_nest_inner_loop(), "transformation to counted loop should not fail"); + // When StressCountedLoop is enabled, this loop may intentionally avoid a counted loop conversion. + // This is expected behavior for the stress mode, which exercises alternative compilation paths. + if (!StressCountedLoop) { + assert(!_head->is_Loop() || !_head->as_Loop()->is_loop_nest_inner_loop(), "transformation to counted loop should not fail"); + } if (_parent != nullptr && !_irreducible) { // Not a counted loop. Keep one safepoint. bool keep_one_sfpt = true; @@ -5373,9 +5557,15 @@ int PhaseIdealLoop::_loop_invokes=0;// Count of PhaseIdealLoop invokes int PhaseIdealLoop::_loop_work=0; // Sum of PhaseIdealLoop x unique volatile int PhaseIdealLoop::_long_loop_candidates=0; // Number of long loops seen volatile int PhaseIdealLoop::_long_loop_nests=0; // Number of long loops successfully transformed to a nest -volatile int PhaseIdealLoop::_long_loop_counted_loops=0; // Number of long loops successfully transformed to a counted loop +// Number of long loops successfully transformed to a counted loop +volatile int CountedLoopConverter::_long_loop_counted_loops = 0; void PhaseIdealLoop::print_statistics() { - tty->print_cr("PhaseIdealLoop=%d, sum _unique=%d, long loops=%d/%d/%d", _loop_invokes, _loop_work, _long_loop_counted_loops, _long_loop_nests, _long_loop_candidates); + tty->print_cr("PhaseIdealLoop=%d, sum _unique=%d, long loops=%d/%d/%d", + _loop_invokes, + _loop_work, + CountedLoopConverter::_long_loop_counted_loops, + _long_loop_nests, + _long_loop_candidates); } #endif diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 5b06f0555ab..6667c71511c 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -273,11 +273,6 @@ public: CountedLoopEndNode* loopexit() const { return (CountedLoopEndNode*) BaseCountedLoopNode::loopexit(); } int stride_con() const; - // Match increment with optional truncation - static Node* - match_incr_with_optional_truncation(Node* expr, Node** trunc1, Node** trunc2, const TypeInteger** trunc_type, - BasicType bt); - // A 'main' loop has a pre-loop and a post-loop. The 'main' loop // can run short a few iterations and may start a few iterations in. // It will be RCE'd and unrolled and aligned. @@ -1029,8 +1024,6 @@ private: void rewire_old_target_loop_entry_dependency_to_new_entry(CountedLoopNode* target_loop_head, const Node* old_target_loop_entry, uint node_index_before_new_assertion_predicate_nodes); - void insert_loop_limit_check_predicate(ParsePredicateSuccessProj* loop_limit_check_parse_proj, Node* cmp_limit, - Node* bol); void log_loop_tree(); public: @@ -1294,7 +1287,7 @@ public: void recompute_dom_depth(); // Is safept not required by an outer loop? - bool is_deleteable_safept(Node* sfpt); + bool is_deleteable_safept(Node* sfpt) const; // Replace parallel induction variable (parallel to trip counter) void replace_parallel_iv(IdealLoopTree *loop); @@ -1345,21 +1338,109 @@ public: // Per-Node transform virtual Node* transform(Node* n) { return nullptr; } - Node* loop_exit_control(Node* x, IdealLoopTree* loop); - Node* loop_exit_test(Node* back_control, IdealLoopTree* loop, Node*& incr, Node*& limit, BoolTest::mask& bt, float& cl_prob); - Node* loop_iv_incr(Node* incr, Node* x, IdealLoopTree* loop, Node*& phi_incr); - Node* loop_iv_stride(Node* incr, Node*& xphi); - PhiNode* loop_iv_phi(Node* xphi, Node* phi_incr, Node* x); + Node* loop_exit_control(const IdealLoopTree* loop) const; - bool is_counted_loop(Node* x, IdealLoopTree*&loop, BasicType iv_bt); + class LoopExitTest { + bool _is_valid; + + const Node* _back_control; + const IdealLoopTree* _loop; + PhaseIdealLoop* _phase; + + Node* _cmp; + Node* _incr; + Node* _limit; + BoolTest::mask _mask; + float _cl_prob; + + public: + LoopExitTest(const Node* back_control, const IdealLoopTree* loop, PhaseIdealLoop* phase) : + _is_valid(false), + _back_control(back_control), + _loop(loop), + _phase(phase), + _cmp(nullptr), + _incr(nullptr), + _limit(nullptr), + _mask(BoolTest::illegal), + _cl_prob(0.0f) {} + + void build(); + void canonicalize_mask(jlong stride_con); + + bool is_valid_with_bt(BasicType bt) const { + return _is_valid && _cmp != nullptr && _cmp->Opcode() == Op_Cmp(bt); + } + + bool should_include_limit() const { return _mask == BoolTest::le || _mask == BoolTest::ge; } + + CmpNode* cmp() const { return _cmp->as_Cmp(); } + Node* incr() const { return _incr; } + Node* limit() const { return _limit; } + BoolTest::mask mask() const { return _mask; } + float cl_prob() const { return _cl_prob; } + }; + + class LoopIVIncr { + bool _is_valid; + + const Node* _head; + const IdealLoopTree* _loop; + + Node* _incr; + Node* _phi_incr; + + public: + LoopIVIncr(const Node* head, const IdealLoopTree* loop) : + _is_valid(false), + _head(head), + _loop(loop), + _incr(nullptr), + _phi_incr(nullptr) {} + + void build(Node* old_incr); + + bool is_valid() const { return _is_valid; } + bool is_valid_with_bt(const BasicType bt) const { + return _is_valid && _incr->Opcode() == Op_Add(bt); + } + + Node* incr() const { return _incr; } + Node* phi_incr() const { return _phi_incr; } + }; + + class LoopIVStride { + bool _is_valid; + + BasicType _iv_bt; + Node* _stride_node; + Node* _xphi; + + public: + LoopIVStride(BasicType iv_bt) : + _is_valid(false), + _iv_bt(iv_bt), + _stride_node(nullptr), + _xphi(nullptr) {} + + void build(const Node* incr); + + bool is_valid() const { return _is_valid && _stride_node != nullptr; } + Node* stride_node() const { return _stride_node; } + Node* xphi() const { return _xphi; } + + jlong compute_non_zero_stride_con(BoolTest::mask mask, BasicType iv_bt) const; + }; + + static PhiNode* loop_iv_phi(const Node* xphi, const Node* phi_incr, const Node* head); + + bool try_convert_to_counted_loop(Node* head, IdealLoopTree*& loop, BasicType iv_bt); Node* loop_nest_replace_iv(Node* iv_to_replace, Node* inner_iv, Node* outer_phi, Node* inner_head, BasicType bt); bool create_loop_nest(IdealLoopTree* loop, Node_List &old_new); -#ifdef ASSERT - bool convert_to_long_loop(Node* cmp, Node* phi, IdealLoopTree* loop); -#endif + void add_parse_predicate(Deoptimization::DeoptReason reason, Node* inner_head, IdealLoopTree* loop, SafePointNode* sfpt); - SafePointNode* find_safepoint(Node* back_control, Node* x, IdealLoopTree* loop); + SafePointNode* find_safepoint(Node* back_control, const Node* head, const IdealLoopTree* loop); void add_parse_predicates(IdealLoopTree* outer_ilt, LoopNode* inner_head, SafePointNode* cloned_sfpt); @@ -1496,8 +1577,6 @@ public: Node* clone_nodes_with_same_ctrl(Node* start_node, ProjNode* old_uncommon_proj, Node* new_uncommon_proj); void fix_cloned_data_node_controls(const ProjNode* orig, Node* new_uncommon_proj, const OrigToNewHashtable& orig_to_clone); - bool has_dominating_loop_limit_check(Node* init_trip, Node* limit, jlong stride_con, BasicType iv_bt, - Node* loop_entry); public: void register_control(Node* n, IdealLoopTree *loop, Node* pred, bool update_body = true); @@ -1676,8 +1755,8 @@ public: Node *has_local_phi_input( Node *n ); // Mark an IfNode as being dominated by a prior test, // without actually altering the CFG (and hence IDOM info). - void dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip = false, bool pin_array_access_nodes = false); - void rewire_safe_outputs_to_dominator(Node* source, Node* dominator, bool pin_array_access_nodes); + void dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip = false, bool prev_dom_not_imply_this = false); + void rewire_safe_outputs_to_dominator(Node* source, Node* dominator, bool dominator_not_imply_source); // Split Node 'n' through merge point RegionNode* split_thru_region(Node* n, RegionNode* region); @@ -1755,12 +1834,6 @@ public: Node*& shift, Node*& offset); private: - // Return a type based on condition control flow - const TypeInt* filtered_type( Node *n, Node* n_ctrl); - const TypeInt* filtered_type( Node *n ) { return filtered_type(n, nullptr); } - // Helpers for filtered type - const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl); - // Helper functions Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache ); Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ); @@ -1889,7 +1962,6 @@ public: static int _loop_work; // Sum of PhaseIdealLoop x _unique static volatile int _long_loop_candidates; static volatile int _long_loop_nests; - static volatile int _long_loop_counted_loops; #endif #ifdef ASSERT @@ -1901,7 +1973,7 @@ public: void rpo(Node* start, Node_Stack &stk, VectorSet &visited, Node_List &rpo_list) const; - void check_counted_loop_shape(IdealLoopTree* loop, Node* x, BasicType bt) NOT_DEBUG_RETURN; + void check_counted_loop_shape(IdealLoopTree* loop, Node* head, BasicType bt) NOT_DEBUG_RETURN; LoopNode* create_inner_head(IdealLoopTree* loop, BaseCountedLoopNode* head, IfNode* exit_test); @@ -1960,7 +2032,7 @@ public: bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x); - void pin_array_access_nodes_dependent_on(Node* ctrl); + void pin_nodes_dependent_on(Node* ctrl, bool old_iff_is_rangecheck); Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node); @@ -1979,6 +2051,146 @@ public: ConNode* zerocon(BasicType bt); }; +class CountedLoopConverter { + friend class PhaseIdealLoop; + + // Match increment with optional truncation + class TruncatedIncrement { + bool _is_valid; + + BasicType _bt; + + Node* _incr; + Node* _outer_trunc; + Node* _inner_trunc; + const TypeInteger* _trunc_type; + + public: + TruncatedIncrement(BasicType bt) : + _is_valid(false), + _bt(bt), + _incr(nullptr), + _outer_trunc(nullptr), + _inner_trunc(nullptr), + _trunc_type(nullptr) {} + + void build(Node* expr); + + bool is_valid() const { return _is_valid; } + Node* incr() const { return _incr; } + + // Optional truncation for: CHAR: (i+1)&0x7fff, BYTE: ((i+1)<<8)>>8, or SHORT: ((i+1)<<16)>>16 + Node* outer_trunc() const { return _outer_trunc; } // the outermost truncating node (either the & or the final >>) + Node* inner_trunc() const { return _inner_trunc; } // the inner truncating node, if applicable (the << in a <> pair) + const TypeInteger* trunc_type() const { return _trunc_type; } + }; + + class LoopStructure { + bool _is_valid; + + const Node* _head; + const IdealLoopTree* _loop; + PhaseIdealLoop* _phase; + BasicType _iv_bt; + + Node* _back_control; + PhaseIdealLoop::LoopExitTest _exit_test; + PhaseIdealLoop::LoopIVIncr _iv_incr; + TruncatedIncrement _truncated_increment; + PhaseIdealLoop::LoopIVStride _stride; + PhiNode* _phi; + SafePointNode* _safepoint; + + public: + LoopStructure(const Node* head, const IdealLoopTree* loop, PhaseIdealLoop* phase, const BasicType iv_bt) : + _is_valid(false), + _head(head), + _loop(loop), + _phase(phase), + _iv_bt(iv_bt), + _back_control(_phase->loop_exit_control(_loop)), + _exit_test(_back_control, _loop, _phase), + _iv_incr(_head, _loop), + _truncated_increment(_iv_bt), + _stride(PhaseIdealLoop::LoopIVStride(_iv_bt)), + _phi(nullptr), + _safepoint(nullptr) {} + + void build(); + + jlong final_limit_correction() const; // compute adjusted loop limit correction + bool is_infinite_loop() const; + + bool is_valid() const { return _is_valid; } + + Node* back_control() const { return _back_control; } + PhaseIdealLoop::LoopExitTest& exit_test() { return _exit_test; } + PhaseIdealLoop::LoopIVIncr& iv_incr() { return _iv_incr; } + TruncatedIncrement& truncated_increment() { return _truncated_increment; } + PhaseIdealLoop::LoopIVStride& stride() { return _stride; } + PhiNode* phi() const { return _phi; } + SafePointNode* sfpt() const { return _safepoint; } + jlong stride_con() const { return _stride.compute_non_zero_stride_con(_exit_test.mask(), _iv_bt); } + Node* limit() const { return _exit_test.limit(); } + }; + + PhaseIdealLoop* const _phase; + Node* const _head; + IdealLoopTree* const _loop; + const BasicType _iv_bt; + + LoopStructure _structure; + bool _should_insert_stride_overflow_limit_check = false; + bool _should_insert_init_trip_limit_check = false; + + DEBUG_ONLY(bool _checked_for_counted_loop = false;) + + // stats for PhaseIdealLoop::print_statistics() + static volatile int _long_loop_counted_loops; + + // Return a type based on condition control flow + const TypeInt* filtered_type(Node* n, Node* n_ctrl); + const TypeInt* filtered_type(Node* n) { return filtered_type(n, nullptr); } + // Helpers for filtered type + const TypeInt* filtered_type_from_dominators(Node* val, Node* val_ctrl); + + void insert_loop_limit_check_predicate(const ParsePredicateSuccessProj* loop_limit_check_parse_proj, Node* bol) const; + void insert_stride_overflow_limit_check() const; + void insert_init_trip_limit_check() const; + bool has_dominating_loop_limit_check(Node* init_trip, Node* limit, jlong stride_con, BasicType iv_bt, + Node* loop_entry) const; + + bool is_iv_overflowing(const TypeInteger* init_t, jlong stride_con, Node* phi_increment, BoolTest::mask mask) const; + bool has_truncation_wrap(const TruncatedIncrement& truncation, Node* phi, jlong stride_con); + SafePointNode* find_safepoint(Node* iftrue); + bool is_safepoint_invalid(SafePointNode* sfpt) const; + + public: + CountedLoopConverter(PhaseIdealLoop* phase, Node* head, IdealLoopTree* loop, const BasicType iv_bt) + : _phase(phase), + _head(head), + _loop(loop), + _iv_bt(iv_bt), + _structure(LoopStructure(_head, _loop, _phase, _iv_bt)) { + assert(phase != nullptr, "must be"); // Fail early if mandatory parameters are null. + assert(head != nullptr, "must be"); + assert(loop != nullptr, "must be"); + assert(iv_bt == T_INT || iv_bt == T_LONG, "either int or long loops"); + } + + bool is_counted_loop(); + IdealLoopTree* convert(); + + DEBUG_ONLY(bool should_stress_long_counted_loop();) + DEBUG_ONLY(bool stress_long_counted_loop();) + + enum StrideOverflowState { + Overflow = -1, + NoOverflow = 0, + RequireLimitCheck = 1 + }; + static StrideOverflowState check_stride_overflow(jlong final_correction, const TypeInteger* limit_t, BasicType bt); +}; class AutoNodeBudget : public StackObj { diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 2b48780f9b0..4e447edee8d 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -345,7 +345,7 @@ bool PhaseIdealLoop::loop_phi_backedge_type_contains_zero(const Node* phi_diviso // Replace the dominated test with an obvious true or false. Place it on the // IGVN worklist for later cleanup. Move control-dependent data Nodes on the // live path up to the dominating control. -void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, bool pin_array_access_nodes) { +void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, bool prevdom_not_imply_this) { if (VerifyLoopOptimizations && PrintOpto) { tty->print_cr("dominating test"); } // prevdom is the dominating projection of the dominating test. @@ -386,26 +386,25 @@ void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, b return; } - rewire_safe_outputs_to_dominator(dp, prevdom, pin_array_access_nodes); + rewire_safe_outputs_to_dominator(dp, prevdom, prevdom_not_imply_this); } -void PhaseIdealLoop::rewire_safe_outputs_to_dominator(Node* source, Node* dominator, const bool pin_array_access_nodes) { +void PhaseIdealLoop::rewire_safe_outputs_to_dominator(Node* source, Node* dominator, const bool dominator_not_imply_source) { IdealLoopTree* old_loop = get_loop(source); for (DUIterator_Fast imax, i = source->fast_outs(imax); i < imax; i++) { Node* out = source->fast_out(i); // Control-dependent node - // Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check. - if (out->depends_only_on_test() && _igvn.no_dependent_zero_check(out)) { + if (out->depends_only_on_test()) { assert(out->in(0) == source, "must be control dependent on source"); _igvn.replace_input_of(out, 0, dominator); - if (pin_array_access_nodes) { + if (dominator_not_imply_source) { // Because of Loop Predication, Loads and range check Cast nodes that are control dependent on this range // check (that is about to be removed) now depend on multiple dominating Hoisted Check Predicates. After the // removal of this range check, these control dependent nodes end up at the lowest/nearest dominating predicate // in the graph. To ensure that these Loads/Casts do not float above any of the dominating checks (even when the // lowest dominating check is later replaced by yet another dominating check), we need to pin them at the lowest // dominating check. - Node* clone = out->pin_array_access_node(); + Node* clone = out->pin_node_under_control(); if (clone != nullptr) { clone = _igvn.register_new_node_with_optimizer(clone, out); _igvn.replace_node(out, clone); @@ -621,10 +620,10 @@ Node* PhaseIdealLoop::remix_address_expressions(Node* n) { IdealLoopTree* n23_loop = get_loop(n23_ctrl); if (n22loop != n_loop && n22loop->is_member(n_loop) && n23_loop == n_loop) { - Node* add1 = new AddPNode(n->in(1), n->in(2)->in(2), n->in(3)); + Node* add1 = AddPNode::make_with_base(n->in(1), n->in(2)->in(2), n->in(3)); // Stuff new AddP in the loop preheader register_new_node(add1, n_loop->_head->as_Loop()->skip_strip_mined(1)->in(LoopNode::EntryControl)); - Node* add2 = new AddPNode(n->in(1), add1, n->in(2)->in(3)); + Node* add2 = AddPNode::make_with_base(n->in(1), add1, n->in(2)->in(3)); register_new_node(add2, n_ctrl); _igvn.replace_node(n, add2); return add2; @@ -642,10 +641,10 @@ Node* PhaseIdealLoop::remix_address_expressions(Node* n) { Node *tmp = V; V = I; I = tmp; } if (!ctrl_is_member(n_loop, I)) { - Node* add1 = new AddPNode(n->in(1), n->in(2), I); + Node* add1 = AddPNode::make_with_base(n->in(1), n->in(2), I); // Stuff new AddP in the loop preheader register_new_node(add1, n_loop->_head->as_Loop()->skip_strip_mined(1)->in(LoopNode::EntryControl)); - Node* add2 = new AddPNode(n->in(1), add1, V); + Node* add2 = AddPNode::make_with_base(n->in(1), add1, V); register_new_node(add2, n_ctrl); _igvn.replace_node(n, add2); return add2; @@ -1479,9 +1478,11 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) { // Now split the IF C->print_method(PHASE_BEFORE_SPLIT_IF, 4, iff); - if (TraceLoopOpts) { - tty->print_cr("Split-If"); +#ifndef PRODUCT + if (TraceLoopOpts || TraceSplitIf) { + tty->print_cr("Split-If: %d %s", iff->_idx, iff->Name()); } +#endif do_split_if(iff); C->print_method(PHASE_AFTER_SPLIT_IF, 4, iff); return; @@ -1591,6 +1592,11 @@ bool PhaseIdealLoop::try_merge_identical_ifs(Node* n) { // Now split the IF RegionNode* new_false_region; RegionNode* new_true_region; +#ifndef PRODUCT + if (TraceLoopOpts || TraceSplitIf) { + tty->print_cr("Split-If Merging Identical Ifs: Dom-If: %d %s, If: %d %s", dom_if->_idx, dom_if->Name(), n->_idx, n->Name()); + } +#endif do_split_if(n, &new_false_region, &new_true_region); assert(new_false_region->req() == new_true_region->req(), ""); #ifdef ASSERT @@ -1644,7 +1650,7 @@ bool PhaseIdealLoop::try_merge_identical_ifs(Node* n) { void PhaseIdealLoop::push_pinned_nodes_thru_region(IfNode* dom_if, Node* region) { for (DUIterator i = region->outs(); region->has_out(i); i++) { Node* u = region->out(i); - if (!has_ctrl(u) || u->is_Phi() || !u->depends_only_on_test() || !_igvn.no_dependent_zero_check(u)) { + if (!has_ctrl(u) || u->is_Phi() || !u->depends_only_on_test()) { continue; } assert(u->in(0) == region, "not a control dependent node?"); @@ -1724,11 +1730,11 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { Node* outside_ctrl = place_outside_loop(n_ctrl, loop_ctrl); if (!would_sink_below_pre_loop_exit(loop_ctrl, outside_ctrl)) { if (n->depends_only_on_test()) { - Node* pinned_clone = n->pin_array_access_node(); + // If this node depends_only_on_test, it will be rewired to a control input that is not + // the correct test. As a result, it must be pinned otherwise it can be incorrectly + // rewired to a dominating test equivalent to the new control. + Node* pinned_clone = n->pin_node_under_control(); if (pinned_clone != nullptr) { - // Pin array access nodes: if this is an array load, it's going to be dependent on a condition that's not a - // range check for that access. If that condition is replaced by an identical dominating one, then an - // unpinned load would risk floating above its range check. register_new_node(pinned_clone, n_ctrl); maybe_pinned_n = pinned_clone; _igvn.replace_node(n, pinned_clone); @@ -1754,11 +1760,11 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { Node* u = n->last_out(j); // Clone private computation per use _igvn.rehash_node_delayed(u); Node* x = nullptr; - if (n->depends_only_on_test()) { - // Pin array access nodes: if this is an array load, it's going to be dependent on a condition that's not a - // range check for that access. If that condition is replaced by an identical dominating one, then an - // unpinned load would risk floating above its range check. - x = n->pin_array_access_node(); + if (n->in(0) != nullptr && n->depends_only_on_test()) { + // If this node depends_only_on_test, it will be rewired to a control input that is not + // the correct test. As a result, it must be pinned otherwise it can be incorrectly + // rewired to a dominating test equivalent to the new control. + x = n->pin_node_under_control(); } if (x == nullptr) { x = n->clone(); @@ -2328,14 +2334,12 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, // We notify all uses of old, including use, and the indirect uses, // that may now be optimized because we have replaced old with phi. _igvn.add_users_to_worklist(old); - if (idx == 0 && - use->depends_only_on_test()) { - Node* pinned_clone = use->pin_array_access_node(); + if (idx == 0 && use->depends_only_on_test()) { + // If this node depends_only_on_test, it will be rewired to a control input that is not the + // correct test. As a result, it must be pinned otherwise it can be incorrectly rewired to + // a dominating test equivalent to the new control. + Node* pinned_clone = use->pin_node_under_control(); if (pinned_clone != nullptr) { - // Pin array access nodes: control is updated here to a region. If, after some transformations, only one path - // into the region is left, an array load could become dependent on a condition that's not a range check for - // that access. If that condition is replaced by an identical dominating one, then an unpinned load would risk - // floating above its range check. pinned_clone->set_req(0, phi); register_new_node_with_ctrl_of(pinned_clone, use); _igvn.replace_node(use, pinned_clone); @@ -2832,8 +2836,6 @@ void PhaseIdealLoop::clone_loop_body(const Node_List& body, Node_List &old_new, // with an optional truncation (left-shift followed by a right-shift) // of the add. Returns zero if not an iv. int PhaseIdealLoop::stride_of_possible_iv(Node* iff) { - Node* trunc1 = nullptr; - Node* trunc2 = nullptr; const TypeInteger* ttype = nullptr; if (!iff->is_If() || iff->in(1) == nullptr || !iff->in(1)->is_Bool()) { return 0; @@ -2854,23 +2856,23 @@ int PhaseIdealLoop::stride_of_possible_iv(Node* iff) { Node* phi = cmp1; for (uint i = 1; i < phi->req(); i++) { Node* in = phi->in(i); - Node* add = CountedLoopNode::match_incr_with_optional_truncation(in, - &trunc1, &trunc2, &ttype, T_INT); - if (add && add->in(1) == phi) { - add2 = add->in(2); + CountedLoopConverter::TruncatedIncrement add(T_INT); + add.build(in); + if (add.is_valid() && add.incr()->in(1) == phi) { + add2 = add.incr()->in(2); break; } } } else { // (If (Bool (CmpX addtrunc:(Optional-trunc((AddI (Phi ...addtrunc...) add2)) ))) Node* addtrunc = cmp1; - Node* add = CountedLoopNode::match_incr_with_optional_truncation(addtrunc, - &trunc1, &trunc2, &ttype, T_INT); - if (add && add->in(1)->is_Phi()) { - Node* phi = add->in(1); + CountedLoopConverter::TruncatedIncrement add(T_INT); + add.build(addtrunc); + if (add.is_valid() && add.incr()->in(1)->is_Phi()) { + Node* phi = add.incr()->in(1); for (uint i = 1; i < phi->req(); i++) { if (phi->in(i) == addtrunc) { - add2 = add->in(2); + add2 = add.incr()->in(2); break; } } @@ -4102,11 +4104,9 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { not_peel.test(n->_idx) && peel.test(n->in(0)->_idx)) { Node* n_clone = old_new[n->_idx]; if (n_clone->depends_only_on_test()) { - // Pin array access nodes: control is updated here to the loop head. If, after some transformations, the - // backedge is removed, an array load could become dependent on a condition that's not a range check for that - // access. If that condition is replaced by an identical dominating one, then an unpinned load would risk - // floating above its range check. - Node* pinned_clone = n_clone->pin_array_access_node(); + // If this node depends_only_on_test, it will be rewire to the loop head, which is not the + // correct test + Node* pinned_clone = n_clone->pin_node_under_control(); if (pinned_clone != nullptr) { register_new_node_with_ctrl_of(pinned_clone, n_clone); old_new.map(n->_idx, pinned_clone); @@ -4299,54 +4299,50 @@ bool PhaseIdealLoop::duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old #endif //ASSERT { // Is the shape of the loop that of a counted loop... - Node* back_control = loop_exit_control(head, loop); + Node* back_control = loop_exit_control(loop); if (back_control == nullptr) { return false; } - BoolTest::mask bt = BoolTest::illegal; - float cl_prob = 0; - Node* incr = nullptr; - Node* limit = nullptr; - Node* cmp = loop_exit_test(back_control, loop, incr, limit, bt, cl_prob); - if (cmp == nullptr || cmp->Opcode() != Op_CmpI) { + LoopExitTest loop_exit(back_control, loop, this); + loop_exit.build(); + if (!loop_exit.is_valid_with_bt(T_INT)) { return false; } + const Node* loop_incr = loop_exit.incr(); + // With an extra phi for the candidate iv? // Or the region node is the loop head - if (!incr->is_Phi() || incr->in(0) == head) { + if (!loop_incr->is_Phi() || loop_incr->in(0) == head) { return false; } PathFrequency pf(head, this); - region = incr->in(0); + region = loop_incr->in(0); // Go over all paths for the extra phi's region and see if that // path is frequent enough and would match the expected iv shape // if the extra phi is removed inner = 0; - for (uint i = 1; i < incr->req(); ++i) { - Node* in = incr->in(i); - Node* trunc1 = nullptr; - Node* trunc2 = nullptr; - const TypeInteger* iv_trunc_t = nullptr; - Node* orig_in = in; - if (!(in = CountedLoopNode::match_incr_with_optional_truncation(in, &trunc1, &trunc2, &iv_trunc_t, T_INT))) { + for (uint i = 1; i < loop_incr->req(); ++i) { + CountedLoopConverter::TruncatedIncrement increment(T_INT); + increment.build(loop_incr->in(i)); + if (!increment.is_valid()) { continue; } - assert(in->Opcode() == Op_AddI, "wrong increment code"); - Node* xphi = nullptr; - Node* stride = loop_iv_stride(in, xphi); + assert(increment.incr()->Opcode() == Op_AddI, "wrong increment code"); - if (stride == nullptr) { + LoopIVStride stride = LoopIVStride(T_INT); + stride.build(increment.incr()); + if (!stride.is_valid()) { continue; } - PhiNode* phi = loop_iv_phi(xphi, nullptr, head); + PhiNode* phi = loop_iv_phi(stride.xphi(), nullptr, head); if (phi == nullptr || - (trunc1 == nullptr && phi->in(LoopNode::LoopBackControl) != incr) || - (trunc1 != nullptr && phi->in(LoopNode::LoopBackControl) != trunc1)) { + (increment.outer_trunc() == nullptr && phi->in(LoopNode::LoopBackControl) != loop_exit.incr()) || + (increment.outer_trunc() != nullptr && phi->in(LoopNode::LoopBackControl) != increment.outer_trunc())) { return false; } diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp index ef38a511a88..c78f6533840 100644 --- a/src/hotspot/share/opto/macro.cpp +++ b/src/hotspot/share/opto/macro.cpp @@ -274,7 +274,7 @@ Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, if (ac->is_clonebasic()) { assert(ac->in(ArrayCopyNode::Src) != ac->in(ArrayCopyNode::Dest), "clone source equals destination"); Node* base = ac->in(ArrayCopyNode::Src); - Node* adr = _igvn.transform(new AddPNode(base, base, _igvn.MakeConX(offset))); + Node* adr = _igvn.transform(AddPNode::make_with_base(base, _igvn.MakeConX(offset))); const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset); MergeMemNode* mergemen = _igvn.transform(MergeMemNode::make(mem))->as_MergeMem(); BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); @@ -293,7 +293,7 @@ Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, if (src_pos_t->is_con() && dest_pos_t->is_con()) { intptr_t off = ((src_pos_t->get_con() - dest_pos_t->get_con()) << shift) + offset; Node* base = ac->in(ArrayCopyNode::Src); - adr = _igvn.transform(new AddPNode(base, base, _igvn.MakeConX(off))); + adr = _igvn.transform(AddPNode::make_with_base(base, _igvn.MakeConX(off))); adr_type = _igvn.type(base)->is_ptr()->add_offset(off); if (ac->in(ArrayCopyNode::Src) == ac->in(ArrayCopyNode::Dest)) { // Don't emit a new load from src if src == dst but try to get the value from memory instead @@ -308,7 +308,7 @@ Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, Node* off = _igvn.transform(new AddXNode(_igvn.MakeConX(offset), diff)); Node* base = ac->in(ArrayCopyNode::Src); - adr = _igvn.transform(new AddPNode(base, base, off)); + adr = _igvn.transform(AddPNode::make_with_base(base, off)); adr_type = _igvn.type(base)->is_ptr()->add_offset(Type::OffsetBot); if (ac->in(ArrayCopyNode::Src) == ac->in(ArrayCopyNode::Dest)) { // Non constant offset in the array: we can't statically @@ -1199,7 +1199,7 @@ bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) { Node* PhaseMacroExpand::make_load_raw(Node* ctl, Node* mem, Node* base, int offset, const Type* value_type, BasicType bt) { - Node* adr = basic_plus_adr(top(), base, offset); + Node* adr = off_heap_plus_addr(base, offset); const TypePtr* adr_type = adr->bottom_type()->is_ptr(); Node* value = LoadNode::make(_igvn, ctl, mem, adr, adr_type, value_type, bt, MemNode::unordered); transform_later(value); @@ -1208,7 +1208,7 @@ Node* PhaseMacroExpand::make_load_raw(Node* ctl, Node* mem, Node* base, int offs Node* PhaseMacroExpand::make_store_raw(Node* ctl, Node* mem, Node* base, int offset, Node* value, BasicType bt) { - Node* adr = basic_plus_adr(top(), base, offset); + Node* adr = off_heap_plus_addr(base, offset); mem = StoreNode::make(_igvn, ctl, mem, adr, nullptr, value, bt, MemNode::unordered); transform_later(mem); return mem; @@ -1313,7 +1313,9 @@ void PhaseMacroExpand::expand_allocate_common( initial_slow_test = nullptr; } - bool allocation_has_use = (alloc->result_cast() != nullptr); + // ArrayCopyNode right after an allocation operates on the raw result projection for the Allocate node so it's not + // safe to remove such an allocation even if it has no result cast. + bool allocation_has_use = (alloc->result_cast() != nullptr) || (alloc->initialization() != nullptr && alloc->initialization()->is_complete_with_arraycopy()); if (!allocation_has_use) { InitializeNode* init = alloc->initialization(); if (init != nullptr) { @@ -1818,81 +1820,81 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, Node* old_eden_top, Node* new_eden_top, intx lines) { enum { fall_in_path = 1, pf_path = 2 }; - if( UseTLAB && AllocatePrefetchStyle == 2 ) { + if (UseTLAB && AllocatePrefetchStyle == 2) { // Generate prefetch allocation with watermark check. // As an allocation hits the watermark, we will prefetch starting // at a "distance" away from watermark. - Node *pf_region = new RegionNode(3); - Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY, - TypeRawPtr::BOTTOM ); + Node* pf_region = new RegionNode(3); + Node* pf_phi_rawmem = new PhiNode(pf_region, Type::MEMORY, + TypeRawPtr::BOTTOM); // I/O is used for Prefetch - Node *pf_phi_abio = new PhiNode( pf_region, Type::ABIO ); + Node* pf_phi_abio = new PhiNode(pf_region, Type::ABIO); - Node *thread = new ThreadLocalNode(); + Node* thread = new ThreadLocalNode(); transform_later(thread); - Node *eden_pf_adr = new AddPNode( top()/*not oop*/, thread, - _igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset())) ); + Node* eden_pf_adr = AddPNode::make_off_heap(thread, + _igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset()))); transform_later(eden_pf_adr); - Node *old_pf_wm = new LoadPNode(needgc_false, + Node* old_pf_wm = new LoadPNode(needgc_false, contended_phi_rawmem, eden_pf_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered); transform_later(old_pf_wm); // check against new_eden_top - Node *need_pf_cmp = new CmpPNode( new_eden_top, old_pf_wm ); + Node* need_pf_cmp = new CmpPNode(new_eden_top, old_pf_wm); transform_later(need_pf_cmp); - Node *need_pf_bol = new BoolNode( need_pf_cmp, BoolTest::ge ); + Node* need_pf_bol = new BoolNode(need_pf_cmp, BoolTest::ge); transform_later(need_pf_bol); - IfNode *need_pf_iff = new IfNode( needgc_false, need_pf_bol, - PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN ); + IfNode* need_pf_iff = new IfNode(needgc_false, need_pf_bol, + PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN); transform_later(need_pf_iff); // true node, add prefetchdistance - Node *need_pf_true = new IfTrueNode( need_pf_iff ); + Node* need_pf_true = new IfTrueNode(need_pf_iff); transform_later(need_pf_true); - Node *need_pf_false = new IfFalseNode( need_pf_iff ); + Node* need_pf_false = new IfFalseNode(need_pf_iff); transform_later(need_pf_false); - Node *new_pf_wmt = new AddPNode( top(), old_pf_wm, - _igvn.MakeConX(AllocatePrefetchDistance) ); - transform_later(new_pf_wmt ); + Node* new_pf_wmt = AddPNode::make_off_heap(old_pf_wm, + _igvn.MakeConX(AllocatePrefetchDistance)); + transform_later(new_pf_wmt); new_pf_wmt->set_req(0, need_pf_true); - Node *store_new_wmt = new StorePNode(need_pf_true, + Node* store_new_wmt = new StorePNode(need_pf_true, contended_phi_rawmem, eden_pf_adr, TypeRawPtr::BOTTOM, new_pf_wmt, MemNode::unordered); transform_later(store_new_wmt); // adding prefetches - pf_phi_abio->init_req( fall_in_path, i_o ); + pf_phi_abio->init_req(fall_in_path, i_o); - Node *prefetch_adr; - Node *prefetch; + Node* prefetch_adr; + Node* prefetch; uint step_size = AllocatePrefetchStepSize; uint distance = 0; - for ( intx i = 0; i < lines; i++ ) { - prefetch_adr = new AddPNode( old_pf_wm, new_pf_wmt, - _igvn.MakeConX(distance) ); + for (intx i = 0; i < lines; i++) { + prefetch_adr = AddPNode::make_off_heap(new_pf_wmt, + _igvn.MakeConX(distance)); transform_later(prefetch_adr); - prefetch = new PrefetchAllocationNode( i_o, prefetch_adr ); + prefetch = new PrefetchAllocationNode(i_o, prefetch_adr); transform_later(prefetch); distance += step_size; i_o = prefetch; } - pf_phi_abio->set_req( pf_path, i_o ); + pf_phi_abio->set_req(pf_path, i_o); - pf_region->init_req( fall_in_path, need_pf_false ); - pf_region->init_req( pf_path, need_pf_true ); + pf_region->init_req(fall_in_path, need_pf_false); + pf_region->init_req(pf_path, need_pf_true); - pf_phi_rawmem->init_req( fall_in_path, contended_phi_rawmem ); - pf_phi_rawmem->init_req( pf_path, store_new_wmt ); + pf_phi_rawmem->init_req(fall_in_path, contended_phi_rawmem); + pf_phi_rawmem->init_req(pf_path, store_new_wmt); transform_later(pf_region); transform_later(pf_phi_rawmem); @@ -1901,7 +1903,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, needgc_false = pf_region; contended_phi_rawmem = pf_phi_rawmem; i_o = pf_phi_abio; - } else if( UseTLAB && AllocatePrefetchStyle == 3 ) { + } else if (UseTLAB && AllocatePrefetchStyle == 3) { // Insert a prefetch instruction for each allocation. // This code is used to generate 1 prefetch instruction per cache line. @@ -1910,13 +1912,12 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, uint distance = AllocatePrefetchDistance; // Next cache address. - Node *cache_adr = new AddPNode(old_eden_top, old_eden_top, - _igvn.MakeConX(step_size + distance)); + Node* cache_adr = AddPNode::make_off_heap(old_eden_top, + _igvn.MakeConX(step_size + distance)); transform_later(cache_adr); cache_adr = new CastP2XNode(needgc_false, cache_adr); transform_later(cache_adr); - // Address is aligned to execute prefetch to the beginning of cache line size - // (it is important when BIS instruction is used on SPARC as prefetch). + // Address is aligned to execute prefetch to the beginning of cache line size. Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1)); cache_adr = new AndXNode(cache_adr, mask); transform_later(cache_adr); @@ -1924,36 +1925,36 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, transform_later(cache_adr); // Prefetch - Node *prefetch = new PrefetchAllocationNode( contended_phi_rawmem, cache_adr ); + Node* prefetch = new PrefetchAllocationNode(contended_phi_rawmem, cache_adr); prefetch->set_req(0, needgc_false); transform_later(prefetch); contended_phi_rawmem = prefetch; - Node *prefetch_adr; + Node* prefetch_adr; distance = step_size; - for ( intx i = 1; i < lines; i++ ) { - prefetch_adr = new AddPNode( cache_adr, cache_adr, - _igvn.MakeConX(distance) ); + for (intx i = 1; i < lines; i++) { + prefetch_adr = AddPNode::make_off_heap(cache_adr, + _igvn.MakeConX(distance)); transform_later(prefetch_adr); - prefetch = new PrefetchAllocationNode( contended_phi_rawmem, prefetch_adr ); + prefetch = new PrefetchAllocationNode(contended_phi_rawmem, prefetch_adr); transform_later(prefetch); distance += step_size; contended_phi_rawmem = prefetch; } - } else if( AllocatePrefetchStyle > 0 ) { + } else if (AllocatePrefetchStyle > 0) { // Insert a prefetch for each allocation only on the fast-path - Node *prefetch_adr; - Node *prefetch; + Node* prefetch_adr; + Node* prefetch; // Generate several prefetch instructions. uint step_size = AllocatePrefetchStepSize; uint distance = AllocatePrefetchDistance; - for ( intx i = 0; i < lines; i++ ) { - prefetch_adr = new AddPNode( top(), new_eden_top, - _igvn.MakeConX(distance) ); + for (intx i = 0; i < lines; i++) { + prefetch_adr = AddPNode::make_off_heap(new_eden_top, + _igvn.MakeConX(distance)); transform_later(prefetch_adr); - prefetch = new PrefetchAllocationNode( i_o, prefetch_adr ); + prefetch = new PrefetchAllocationNode(i_o, prefetch_adr); // Do not let it float too high, since if eden_top == eden_end, // both might be null. - if( i == 0 ) { // Set control for first prefetch, next follows it + if (i == 0) { // Set control for first prefetch, next follows it prefetch->init_req(0, needgc_false); } transform_later(prefetch); @@ -2499,6 +2500,7 @@ void PhaseMacroExpand::eliminate_macro_nodes() { assert(n->Opcode() == Op_LoopLimit || n->Opcode() == Op_ModD || n->Opcode() == Op_ModF || + n->Opcode() == Op_PowD || n->is_OpaqueConstantBool() || n->is_OpaqueInitializedAssertionPredicate() || n->Opcode() == Op_MaxL || @@ -2655,18 +2657,11 @@ bool PhaseMacroExpand::expand_macro_nodes() { default: switch (n->Opcode()) { case Op_ModD: - case Op_ModF: { - CallNode* mod_macro = n->as_Call(); - CallNode* call = new CallLeafPureNode(mod_macro->tf(), mod_macro->entry_point(), mod_macro->_name); - call->init_req(TypeFunc::Control, mod_macro->in(TypeFunc::Control)); - call->init_req(TypeFunc::I_O, C->top()); - call->init_req(TypeFunc::Memory, C->top()); - call->init_req(TypeFunc::ReturnAdr, C->top()); - call->init_req(TypeFunc::FramePtr, C->top()); - for (unsigned int i = 0; i < mod_macro->tf()->domain()->cnt() - TypeFunc::Parms; i++) { - call->init_req(TypeFunc::Parms + i, mod_macro->in(TypeFunc::Parms + i)); - } - _igvn.replace_node(mod_macro, call); + case Op_ModF: + case Op_PowD: { + CallLeafPureNode* call_macro = n->as_CallLeafPure(); + CallLeafPureNode* call = call_macro->inline_call_leaf_pure_node(); + _igvn.replace_node(call_macro, call); transform_later(call); break; } diff --git a/src/hotspot/share/opto/macro.hpp b/src/hotspot/share/opto/macro.hpp index 0f8d8fb5172..59a455cae6d 100644 --- a/src/hotspot/share/opto/macro.hpp +++ b/src/hotspot/share/opto/macro.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,19 +40,32 @@ private: public: // Helper methods roughly modeled after GraphKit: - Node* basic_plus_adr(Node* base, int offset) { - return (offset == 0)? base: basic_plus_adr(base, MakeConX(offset)); + Node* basic_plus_adr(Node* ptr, int offset, bool raw_base = false) { + return basic_plus_adr(ptr, MakeConX(offset), raw_base); } + Node* basic_plus_adr(Node* base, Node* ptr, int offset) { - return (offset == 0)? ptr: basic_plus_adr(base, ptr, MakeConX(offset)); + return basic_plus_adr(base, ptr, MakeConX(offset)); } - Node* basic_plus_adr(Node* base, Node* offset) { - return basic_plus_adr(base, base, offset); + + Node* basic_plus_adr(Node* ptr, Node* offset, bool raw_base = false) { + Node* base = raw_base ? top() : ptr; + return basic_plus_adr(base, ptr, offset); } + Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) { - Node* adr = new AddPNode(base, ptr, offset); - return transform_later(adr); + return (offset == MakeConX(0)) ? + ptr : transform_later(AddPNode::make_with_base(base, ptr, offset)); } + + Node* off_heap_plus_addr(Node* ptr, int offset) { + return basic_plus_adr(top(), ptr, MakeConX(offset)); + } + + Node* off_heap_plus_addr(Node* ptr, Node* offset) { + return basic_plus_adr(top(), ptr, offset); + } + Node* transform_later(Node* n) { // equivalent to _gvn.transform in GraphKit, Ideal, etc. _igvn.register_new_node_with_optimizer(n); @@ -109,7 +122,7 @@ private: // More helper methods modeled after GraphKit for array copy void insert_mem_bar(Node** ctrl, Node** mem, int opcode, int alias_idx, Node* precedent = nullptr); - Node* array_element_address(Node* ary, Node* idx, BasicType elembt); + Node* array_element_address(Node* ary, Node* idx, BasicType elembt, bool raw_base); Node* ConvI2L(Node* offset); // helper methods modeled after LibraryCallKit for array copy diff --git a/src/hotspot/share/opto/macroArrayCopy.cpp b/src/hotspot/share/opto/macroArrayCopy.cpp index 0719ffc45a5..139775506db 100644 --- a/src/hotspot/share/opto/macroArrayCopy.cpp +++ b/src/hotspot/share/opto/macroArrayCopy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -55,10 +55,10 @@ void PhaseMacroExpand::insert_mem_bar(Node** ctrl, Node** mem, int opcode, int a } } -Node* PhaseMacroExpand::array_element_address(Node* ary, Node* idx, BasicType elembt) { +Node* PhaseMacroExpand::array_element_address(Node* ary, Node* idx, BasicType elembt, bool raw_base) { uint shift = exact_log2(type2aelembytes(elembt)); uint header = arrayOopDesc::base_offset_in_bytes(elembt); - Node* base = basic_plus_adr(ary, header); + Node* base = basic_plus_adr(ary, header, raw_base); #ifdef _LP64 // see comment in GraphKit::array_element_address int index_max = max_jint - 1; // array size is max_jint, index is one less @@ -67,7 +67,7 @@ Node* PhaseMacroExpand::array_element_address(Node* ary, Node* idx, BasicType el #endif Node* scale = new LShiftXNode(idx, intcon(shift)); transform_later(scale); - return basic_plus_adr(ary, base, scale); + return basic_plus_adr(raw_base ? top() : ary, base, scale); } Node* PhaseMacroExpand::ConvI2L(Node* offset) { @@ -379,6 +379,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode* bool disjoint_bases, bool length_never_negative, RegionNode* slow_region) { + Node* orig_dest = dest; if (slow_region == nullptr) { slow_region = new RegionNode(1); transform_later(slow_region); @@ -411,6 +412,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode* assert(dest->is_CheckCastPP(), "sanity"); assert(dest->in(0)->in(0) == init, "dest pinned"); adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory + dest = dest->in(1); // writing to raw memory requires a raw base // From this point on, every exit path is responsible for // initializing any non-copied parts of the object to zero. // Also, if this flag is set we make sure that arraycopy interacts properly @@ -638,7 +640,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode* // (At this point we can assume disjoint_bases, since types differ.) int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset()); - Node* p1 = basic_plus_adr(top(), dest_klass, ek_offset); + Node* p1 = off_heap_plus_addr(dest_klass, ek_offset); Node* n1 = LoadKlassNode::make(_igvn, C->immutable_memory(), p1, TypeRawPtr::BOTTOM); Node* dest_elem_klass = transform_later(n1); Node* cv = generate_checkcast_arraycopy(&local_ctrl, &local_mem, @@ -771,7 +773,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode* local_mem = generate_slow_arraycopy(ac, &local_ctrl, local_mem, &local_io, adr_type, - src, src_offset, dest, dest_offset, + src, src_offset, orig_dest, dest_offset, copy_length, /*dest_uninitialized*/false); result_region->init_req(slow_call_path, local_ctrl); @@ -839,7 +841,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode* _igvn.replace_node(_callprojs.fallthrough_catchproj, *ctrl); #ifdef ASSERT - const TypeOopPtr* dest_t = _igvn.type(dest)->is_oopptr(); + const TypeOopPtr* dest_t = _igvn.type(orig_dest)->is_oopptr(); if (dest_t->is_known_instance()) { ArrayCopyNode* ac = nullptr; assert(ArrayCopyNode::may_modify(dest_t, (*ctrl)->in(0)->as_MemBar(), &_igvn, ac), "dependency on arraycopy lost"); @@ -915,12 +917,12 @@ void PhaseMacroExpand::generate_clear_array(Node* ctrl, MergeMemNode* merge_mem, if (start_con >= 0 && end_con >= 0) { // Constant start and end. Simple. mem = ClearArrayNode::clear_memory(ctrl, mem, dest, - start_con, end_con, false, &_igvn); + start_con, end_con, adr_type == TypeRawPtr::BOTTOM, &_igvn); } else if (start_con >= 0 && dest_size != top()) { // Constant start, pre-rounded end after the tail of the array. Node* end = dest_size; mem = ClearArrayNode::clear_memory(ctrl, mem, dest, - start_con, end, false, &_igvn); + start_con, end, adr_type == TypeRawPtr::BOTTOM, &_igvn); } else if (start_con >= 0 && slice_len != top()) { // Constant start, non-constant end. End needs rounding up. // End offset = round_up(abase + ((slice_idx_con + slice_len) << scale), 8) @@ -933,7 +935,7 @@ void PhaseMacroExpand::generate_clear_array(Node* ctrl, MergeMemNode* merge_mem, end = transform_later(new AddXNode(end, MakeConX(end_base)) ); end = transform_later(new AndXNode(end, MakeConX(~end_round)) ); mem = ClearArrayNode::clear_memory(ctrl, mem, dest, - start_con, end, false, &_igvn); + start_con, end, adr_type == TypeRawPtr::BOTTOM, &_igvn); } else if (start_con < 0 && dest_size != top()) { // Non-constant start, pre-rounded end after the tail of the array. // This is almost certainly a "round-to-end" operation. @@ -960,14 +962,14 @@ void PhaseMacroExpand::generate_clear_array(Node* ctrl, MergeMemNode* merge_mem, if (bump_bit != 0) { // Store a zero to the immediately preceding jint: Node* x1 = transform_later(new AddXNode(start, MakeConX(-bump_bit)) ); - Node* p1 = basic_plus_adr(dest, x1); + Node* p1 = basic_plus_adr(dest, x1, adr_type == TypeRawPtr::BOTTOM); mem = StoreNode::make(_igvn, ctrl, mem, p1, adr_type, intcon(0), T_INT, MemNode::unordered); mem = transform_later(mem); } } Node* end = dest_size; // pre-rounded mem = ClearArrayNode::clear_memory(ctrl, mem, dest, - start, end, false, &_igvn); + start, end, adr_type == TypeRawPtr::BOTTOM, &_igvn); } else { // Non-constant start, unrounded non-constant end. // (Nobody zeroes a random midsection of an array using this routine.) @@ -1009,7 +1011,7 @@ bool PhaseMacroExpand::generate_block_arraycopy(Node** ctrl, MergeMemNode** mem, if (((src_off | dest_off) & (BytesPerLong-1)) == BytesPerInt && ((src_off ^ dest_off) & (BytesPerLong-1)) == 0) { Node* sptr = basic_plus_adr(src, src_off); - Node* dptr = basic_plus_adr(dest, dest_off); + Node* dptr = basic_plus_adr(dest, dest_off, adr_type == TypeRawPtr::BOTTOM); const TypePtr* s_adr_type = _igvn.type(sptr)->is_ptr(); assert(s_adr_type->isa_aryptr(), "impossible slice"); uint s_alias_idx = C->get_alias_index(s_adr_type); @@ -1037,7 +1039,7 @@ bool PhaseMacroExpand::generate_block_arraycopy(Node** ctrl, MergeMemNode** mem, // Do this copy by giant steps. Node* sptr = basic_plus_adr(src, src_off); - Node* dptr = basic_plus_adr(dest, dest_off); + Node* dptr = basic_plus_adr(dest, dest_off, adr_type == TypeRawPtr::BOTTOM); Node* countx = dest_size; countx = transform_later(new SubXNode(countx, MakeConX(dest_off))); countx = transform_later(new URShiftXNode(countx, intcon(LogBytesPerLong))); @@ -1129,13 +1131,13 @@ Node* PhaseMacroExpand::generate_checkcast_arraycopy(Node** ctrl, MergeMemNode** // look in each non-null element's class, at the desired klass's // super_check_offset, for the desired klass. int sco_offset = in_bytes(Klass::super_check_offset_offset()); - Node* p3 = basic_plus_adr(top(), dest_elem_klass, sco_offset); + Node* p3 = off_heap_plus_addr(dest_elem_klass, sco_offset); Node* n3 = new LoadINode(nullptr, *mem /*memory(p3)*/, p3, _igvn.type(p3)->is_ptr(), TypeInt::INT, MemNode::unordered); Node* check_offset = ConvI2X(transform_later(n3)); Node* check_value = dest_elem_klass; - Node* src_start = array_element_address(src, src_offset, T_OBJECT); - Node* dest_start = array_element_address(dest, dest_offset, T_OBJECT); + Node* src_start = array_element_address(src, src_offset, T_OBJECT, false); + Node* dest_start = array_element_address(dest, dest_offset, T_OBJECT, adr_type == TypeRawPtr::BOTTOM); const TypeFunc* call_type = OptoRuntime::checkcast_arraycopy_Type(); Node* call = make_leaf_call(*ctrl, *mem, call_type, copyfunc_addr, "checkcast_arraycopy", adr_type, @@ -1190,8 +1192,8 @@ void PhaseMacroExpand::generate_unchecked_arraycopy(Node** ctrl, MergeMemNode** Node* src_start = src; Node* dest_start = dest; if (src_offset != nullptr || dest_offset != nullptr) { - src_start = array_element_address(src, src_offset, basic_elem_type); - dest_start = array_element_address(dest, dest_offset, basic_elem_type); + src_start = array_element_address(src, src_offset, basic_elem_type, false); + dest_start = array_element_address(dest, dest_offset, basic_elem_type, adr_type == TypeRawPtr::BOTTOM); } // Figure out which arraycopy runtime method to call. diff --git a/src/hotspot/share/opto/matcher.hpp b/src/hotspot/share/opto/matcher.hpp index 9579af84f24..4de41d6f2ef 100644 --- a/src/hotspot/share/opto/matcher.hpp +++ b/src/hotspot/share/opto/matcher.hpp @@ -221,12 +221,12 @@ public: // Convert a machine register to a machine register type, so-as to // properly match spill code. const int *_register_save_type; + #ifdef ASSERT // Maps from machine register to boolean; true if machine register can // be holding a call argument in some signature. static bool can_be_java_arg( int reg ); - // Maps from machine register to boolean; true if machine register holds - // a spillable argument. - static bool is_spillable_arg( int reg ); + #endif + // Number of integer live ranges that constitute high register pressure static uint int_pressure_limit(); // Number of float live ranges that constitute high register pressure @@ -429,10 +429,6 @@ public: // Register for MODL projection of divmodL static const RegMask& modL_proj_mask(); - // Use hardware DIV instruction when it is faster than - // a code which use multiply for division by constant. - static bool use_asm_for_ldiv_by_con( jlong divisor ); - // Java-Interpreter calling convention // (what you use when calling between compiled-Java and Interpreted-Java @@ -443,9 +439,6 @@ public: // The Method-klass-holder may be passed in the inline_cache_reg // and then expanded into the inline_cache_reg and a method_ptr register - // Interpreter's Frame Pointer Register - static OptoReg::Name interpreter_frame_pointer_reg(); - // Java-Native calling convention // (what you use when intercalling between Java and C++ code) diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 7f152eddd65..46f6729c82f 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,6 +44,7 @@ #include "opto/mempointer.hpp" #include "opto/mulnode.hpp" #include "opto/narrowptrnode.hpp" +#include "opto/opcodes.hpp" #include "opto/phaseX.hpp" #include "opto/regalloc.hpp" #include "opto/regmask.hpp" @@ -552,6 +553,18 @@ Node::DomResult MemNode::maybe_all_controls_dominate(Node* dom, Node* sub) { bool MemNode::detect_ptr_independence(Node* p1, AllocateNode* a1, Node* p2, AllocateNode* a2, PhaseTransform* phase) { + // Trivial case: Non-overlapping values. Be careful, we can cast a raw pointer to an oop (e.g. in + // the allocation pattern) so joining the types only works if both are oops. join may also give + // an incorrect result when both pointers are nullable and the result is supposed to be + // TypePtr::NULL_PTR, so we exclude that case. + const Type* p1_type = p1->bottom_type(); + const Type* p2_type = p2->bottom_type(); + if (p1_type->isa_oopptr() && p2_type->isa_oopptr() && + (!p1_type->maybe_null() || !p2_type->maybe_null()) && + p1_type->join(p2_type)->empty()) { + return true; + } + // Attempt to prove that these two pointers cannot be aliased. // They may both manifestly be allocations, and they should differ. // Or, if they are not both allocations, they can be distinct constants. @@ -569,7 +582,6 @@ bool MemNode::detect_ptr_independence(Node* p1, AllocateNode* a1, return false; } - // Find an arraycopy ac that produces the memory state represented by parameter mem. // Return ac if // (a) can_see_stored_value=true and ac must have set the value for this load or if @@ -684,149 +696,32 @@ ArrayCopyNode* MemNode::find_array_copy_clone(Node* ld_alloc, Node* mem) const { // (Currently, only LoadNode::Ideal has steps (c), (d). More later.) // Node* MemNode::find_previous_store(PhaseValues* phase) { - Node* ctrl = in(MemNode::Control); - Node* adr = in(MemNode::Address); - intptr_t offset = 0; - Node* base = AddPNode::Ideal_base_and_offset(adr, phase, offset); - AllocateNode* alloc = AllocateNode::Ideal_allocation(base); + AccessAnalyzer analyzer(phase, this); - if (offset == Type::OffsetBot) - return nullptr; // cannot unalias unless there are precise offsets - - const bool adr_maybe_raw = check_if_adr_maybe_raw(adr); - const TypeOopPtr *addr_t = adr->bottom_type()->isa_oopptr(); - - intptr_t size_in_bytes = memory_size(); - - Node* mem = in(MemNode::Memory); // start searching here... - - int cnt = 50; // Cycle limiter - for (;;) { // While we can dance past unrelated stores... - if (--cnt < 0) break; // Caught in cycle or a complicated dance? - - Node* prev = mem; - if (mem->is_Store()) { - Node* st_adr = mem->in(MemNode::Address); - intptr_t st_offset = 0; - Node* st_base = AddPNode::Ideal_base_and_offset(st_adr, phase, st_offset); - if (st_base == nullptr) - break; // inscrutable pointer - - // For raw accesses it's not enough to prove that constant offsets don't intersect. - // We need the bases to be the equal in order for the offset check to make sense. - if ((adr_maybe_raw || check_if_adr_maybe_raw(st_adr)) && st_base != base) { - break; - } - - if (st_offset != offset && st_offset != Type::OffsetBot) { - const int MAX_STORE = MAX2(BytesPerLong, (int)MaxVectorSize); - assert(mem->as_Store()->memory_size() <= MAX_STORE, ""); - if (st_offset >= offset + size_in_bytes || - st_offset <= offset - MAX_STORE || - st_offset <= offset - mem->as_Store()->memory_size()) { - // Success: The offsets are provably independent. - // (You may ask, why not just test st_offset != offset and be done? - // The answer is that stores of different sizes can co-exist - // in the same sequence of RawMem effects. We sometimes initialize - // a whole 'tile' of array elements with a single jint or jlong.) - mem = mem->in(MemNode::Memory); - continue; // (a) advance through independent store memory - } - } - if (st_base != base && - detect_ptr_independence(base, alloc, - st_base, - AllocateNode::Ideal_allocation(st_base), - phase)) { - // Success: The bases are provably independent. - mem = mem->in(MemNode::Memory); - continue; // (a) advance through independent store memory - } - - // (b) At this point, if the bases or offsets do not agree, we lose, - // since we have not managed to prove 'this' and 'mem' independent. - if (st_base == base && st_offset == offset) { - return mem; // let caller handle steps (c), (d) - } - - } else if (mem->is_Proj() && mem->in(0)->is_Initialize()) { - InitializeNode* st_init = mem->in(0)->as_Initialize(); - AllocateNode* st_alloc = st_init->allocation(); - if (st_alloc == nullptr) { - break; // something degenerated - } - bool known_identical = false; - bool known_independent = false; - if (alloc == st_alloc) { - known_identical = true; - } else if (alloc != nullptr) { - known_independent = true; - } else if (all_controls_dominate(this, st_alloc)) { - known_independent = true; - } - - if (known_independent) { - // The bases are provably independent: Either they are - // manifestly distinct allocations, or else the control - // of this load dominates the store's allocation. - int alias_idx = phase->C->get_alias_index(adr_type()); - if (alias_idx == Compile::AliasIdxRaw) { - mem = st_alloc->in(TypeFunc::Memory); - } else { - mem = st_init->memory(alias_idx); - } - continue; // (a) advance through independent store memory - } - - // (b) at this point, if we are not looking at a store initializing - // the same allocation we are loading from, we lose. - if (known_identical) { - // From caller, can_see_stored_value will consult find_captured_store. - return mem; // let caller handle steps (c), (d) - } - - } else if (find_previous_arraycopy(phase, alloc, mem, false) != nullptr) { - if (prev != mem) { - // Found an arraycopy but it doesn't affect that load - continue; - } - // Found an arraycopy that may affect that load - return mem; - } else if (addr_t != nullptr && addr_t->is_known_instance_field()) { - // Can't use optimize_simple_memory_chain() since it needs PhaseGVN. - if (mem->is_Proj() && mem->in(0)->is_Call()) { - // ArrayCopyNodes processed here as well. - CallNode *call = mem->in(0)->as_Call(); - if (!call->may_modify(addr_t, phase)) { - mem = call->in(TypeFunc::Memory); - continue; // (a) advance through independent call memory - } - } else if (mem->is_Proj() && mem->in(0)->is_MemBar()) { - ArrayCopyNode* ac = nullptr; - if (ArrayCopyNode::may_modify(addr_t, mem->in(0)->as_MemBar(), phase, ac)) { - break; - } - mem = mem->in(0)->in(TypeFunc::Memory); - continue; // (a) advance through independent MemBar memory - } else if (mem->is_ClearArray()) { - if (ClearArrayNode::step_through(&mem, (uint)addr_t->instance_id(), phase)) { - // (the call updated 'mem' value) - continue; // (a) advance through independent allocation memory - } else { - // Can not bypass initialization of the instance - // we are looking for. - return mem; - } - } else if (mem->is_MergeMem()) { - int alias_idx = phase->C->get_alias_index(adr_type()); - mem = mem->as_MergeMem()->memory_at(alias_idx); - continue; // (a) advance through independent MergeMem memory - } + Node* mem = in(MemNode::Memory); // start searching here... + int cnt = 50; // Cycle limiter + for (;; cnt--) { + // While we can dance past unrelated stores... + if (phase->type(mem) == Type::TOP) { + // Encounter a dead node + return phase->C->top(); + } else if (cnt <= 0) { + // Caught in cycle or a complicated dance? + return nullptr; + } else if (mem->is_Phi()) { + return nullptr; } - // Unless there is an explicit 'continue', we must bail out here, - // because 'mem' is an inscrutable memory state (e.g., a call). - break; + AccessAnalyzer::AccessIndependence independence = analyzer.detect_access_independence(mem); + if (independence.independent) { + // (a) advance through the independent store + mem = independence.mem; + assert(mem != nullptr, "must not be nullptr"); + } else { + // (b) found the store that this access observes if this is not null + // Otherwise, give up if it is null + return independence.mem; + } } return nullptr; // bail out @@ -876,6 +771,174 @@ uint8_t MemNode::barrier_data(const Node* n) { return 0; } +AccessAnalyzer::AccessAnalyzer(PhaseValues* phase, MemNode* n) + : _phase(phase), _n(n), _memory_size(n->memory_size()), _alias_idx(-1) { + Node* adr = _n->in(MemNode::Address); + _offset = 0; + _base = AddPNode::Ideal_base_and_offset(adr, _phase, _offset); + _maybe_raw = MemNode::check_if_adr_maybe_raw(adr); + _alloc = AllocateNode::Ideal_allocation(_base); + _adr_type = _n->adr_type(); + + if (_adr_type != nullptr && _adr_type->base() != TypePtr::AnyPtr) { + // Avoid the cases that will upset Compile::get_alias_index + _alias_idx = _phase->C->get_alias_index(_adr_type); + assert(_alias_idx != Compile::AliasIdxTop, "must not be a dead node"); + assert(_alias_idx != Compile::AliasIdxBot || !phase->C->do_aliasing(), "must not be a very wide access"); + } +} + +// Decide whether the memory accessed by '_n' and 'other' may overlap. This function may be used +// when we want to walk the memory graph to fold a load, or when we want to hoist a load above a +// loop when there are no stores that may overlap with the load inside the loop. +AccessAnalyzer::AccessIndependence AccessAnalyzer::detect_access_independence(Node* other) const { + assert(_phase->type(other) == Type::MEMORY, "must be a memory node %s", other->Name()); + assert(!other->is_Phi(), "caller must handle Phi"); + + if (_adr_type == nullptr) { + // This means the access is dead + return {false, _phase->C->top()}; + } else if (_adr_type->base() == TypePtr::AnyPtr) { + // An example for this case is an access into the memory address 0 performed using Unsafe + assert(_adr_type->ptr() == TypePtr::Null, "MemNode should never access a wide memory"); + return {false, nullptr}; + } + + if (_offset == Type::OffsetBot) { + // cannot unalias unless there are precise offsets + return {false, nullptr}; + } + + const TypeOopPtr* adr_oop_type = _adr_type->isa_oopptr(); + Node* prev = other; + if (other->is_Store()) { + Node* st_adr = other->in(MemNode::Address); + intptr_t st_offset = 0; + Node* st_base = AddPNode::Ideal_base_and_offset(st_adr, _phase, st_offset); + if (st_base == nullptr) { + // inscrutable pointer + return {false, nullptr}; + } + + // If the bases are the same and the offsets are the same, it seems that this is the exact + // store we are looking for, the caller will check if the type of the store matches using + // MemNode::can_see_stored_value + if (st_base == _base && st_offset == _offset) { + return {false, other}; + } + + // If it is provable that the memory accessed by 'other' does not overlap the memory accessed + // by '_n', we may walk past 'other'. + // For raw accesses, 2 accesses are independent if they have the same base and the offsets + // say that they do not overlap. + // For heap accesses, 2 accesses are independent if either the bases are provably different + // at runtime or the offsets say that the accesses do not overlap. + if ((_maybe_raw || MemNode::check_if_adr_maybe_raw(st_adr)) && st_base != _base) { + // Raw accesses can only be provably independent if they have the same base + return {false, nullptr}; + } + + // If the offsets say that the accesses do not overlap, then it is provable that 'other' and + // '_n' do not overlap. For example, a LoadI from Object+8 is independent from a StoreL into + // Object+12, no matter what the bases are. + if (st_offset != _offset && st_offset != Type::OffsetBot) { + const int MAX_STORE = MAX2(BytesPerLong, (int)MaxVectorSize); + assert(other->as_Store()->memory_size() <= MAX_STORE, ""); + if (st_offset >= _offset + _memory_size || + st_offset <= _offset - MAX_STORE || + st_offset <= _offset - other->as_Store()->memory_size()) { + // Success: The offsets are provably independent. + // (You may ask, why not just test st_offset != offset and be done? + // The answer is that stores of different sizes can co-exist + // in the same sequence of RawMem effects. We sometimes initialize + // a whole 'tile' of array elements with a single jint or jlong.) + return {true, other->in(MemNode::Memory)}; + } + } + + // Same base and overlapping offsets, it seems provable that the accesses overlap, give up + if (st_base == _base) { + return {false, nullptr}; + } + + // Try to prove that 2 different base nodes at compile time are different values at runtime + bool known_independent = false; + if (MemNode::detect_ptr_independence(_base, _alloc, st_base, AllocateNode::Ideal_allocation(st_base), _phase)) { + known_independent = true; + } + + if (known_independent) { + return {true, other->in(MemNode::Memory)}; + } + } else if (other->is_Proj() && other->in(0)->is_Initialize()) { + InitializeNode* st_init = other->in(0)->as_Initialize(); + AllocateNode* st_alloc = st_init->allocation(); + if (st_alloc == nullptr) { + // Something degenerated + return {false, nullptr}; + } + bool known_identical = false; + bool known_independent = false; + if (_alloc == st_alloc) { + known_identical = true; + } else if (_alloc != nullptr) { + known_independent = true; + } else if (MemNode::all_controls_dominate(_n, st_alloc)) { + known_independent = true; + } + + if (known_independent) { + // The bases are provably independent: Either they are + // manifestly distinct allocations, or else the control + // of _n dominates the store's allocation. + if (_alias_idx == Compile::AliasIdxRaw) { + other = st_alloc->in(TypeFunc::Memory); + } else { + other = st_init->memory(_alias_idx); + } + return {true, other}; + } + + // If we are not looking at a store initializing the same + // allocation we are loading from, we lose. + if (known_identical) { + // From caller, can_see_stored_value will consult find_captured_store. + return {false, other}; + } + + } else if (_n->find_previous_arraycopy(_phase, _alloc, other, false) != nullptr) { + // Find an arraycopy that may or may not affect the MemNode + return {prev != other, other}; + } else if (other->is_MergeMem()) { + return {true, other->as_MergeMem()->memory_at(_alias_idx)}; + } else if (adr_oop_type != nullptr && adr_oop_type->is_known_instance_field()) { + // Can't use optimize_simple_memory_chain() since it needs PhaseGVN. + if (other->is_Proj() && other->in(0)->is_Call()) { + // ArrayCopyNodes processed here as well. + CallNode* call = other->in(0)->as_Call(); + if (!call->may_modify(adr_oop_type, _phase)) { + return {true, call->in(TypeFunc::Memory)}; + } + } else if (other->is_Proj() && other->in(0)->is_MemBar()) { + ArrayCopyNode* ac = nullptr; + if (!ArrayCopyNode::may_modify(adr_oop_type, other->in(0)->as_MemBar(), _phase, ac)) { + return {true, other->in(0)->in(TypeFunc::Memory)}; + } + } else if (other->is_ClearArray()) { + if (ClearArrayNode::step_through(&other, (uint)adr_oop_type->instance_id(), _phase)) { + // (the call updated 'other' value) + return {true, other}; + } else { + // Can not bypass initialization of the instance + // we are looking for. + return {false, other}; + } + } + } + + return {false, nullptr}; +} + //============================================================================= // Should LoadNode::Ideal() attempt to remove control edges? bool LoadNode::can_remove_control() const { @@ -900,7 +963,7 @@ void LoadNode::dump_spec(outputStream *st) const { // standard dump does this in Verbose and WizardMode st->print(" #"); _type->dump_on(st); } - if (!depends_only_on_test()) { + if (in(0) != nullptr && !depends_only_on_test()) { st->print(" (does not depend only on test, "); if (control_dependency() == UnknownControl) { st->print("unknown control"); @@ -947,6 +1010,7 @@ bool LoadNode::is_immutable_value(Node* adr) { Node* LoadNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, BasicType bt, MemOrd mo, ControlDependency control_dependency, bool require_atomic_access, bool unaligned, bool mismatched, bool unsafe, uint8_t barrier_data) { Compile* C = gvn.C; + assert(adr->is_top() || C->get_alias_index(gvn.type(adr)->is_ptr()) == C->get_alias_index(adr_type), "adr and adr_type must agree"); // sanity check the alias category against the created node type assert(!(adr_type->isa_oopptr() && @@ -1025,14 +1089,6 @@ static bool skip_through_membars(Compile::AliasType* atp, const TypeInstPtr* tp, return false; } -LoadNode* LoadNode::pin_array_access_node() const { - const TypePtr* adr_type = this->adr_type(); - if (adr_type != nullptr && adr_type->isa_aryptr()) { - return clone_pinned(); - } - return nullptr; -} - // Is the value loaded previously stored by an arraycopy? If so return // a load node that reads from the source array so we may be able to // optimize out the ArrayCopy node later. @@ -1194,8 +1250,13 @@ Node* MemNode::can_see_stored_value(Node* st, PhaseValues* phase) const { } // LoadVector/StoreVector needs additional check to ensure the types match. if (st->is_StoreVector()) { - const TypeVect* in_vt = st->as_StoreVector()->vect_type(); - const TypeVect* out_vt = as_LoadVector()->vect_type(); + if ((Opcode() != Op_LoadVector && Opcode() != Op_StoreVector) || st->Opcode() != Op_StoreVector) { + // Some kind of masked access or gather/scatter + return nullptr; + } + + const TypeVect* in_vt = st->as_StoreVector()->vect_type(); + const TypeVect* out_vt = is_Load() ? as_LoadVector()->vect_type() : as_StoreVector()->vect_type(); if (in_vt != out_vt) { return nullptr; } @@ -1351,8 +1412,12 @@ Node* LoadNode::convert_to_unsigned_load(PhaseGVN& gvn) { assert(false, "no unsigned variant: %s", Name()); return nullptr; } + const Type* mem_t = gvn.type(in(MemNode::Address)); + if (mem_t == Type::TOP) { + return gvn.C->top(); + } return LoadNode::make(gvn, in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), - raw_adr_type(), rt, bt, _mo, _control_dependency, + mem_t->is_ptr(), rt, bt, _mo, _control_dependency, false /*require_atomic_access*/, is_unaligned_access(), is_mismatched_access()); } @@ -1371,8 +1436,12 @@ Node* LoadNode::convert_to_signed_load(PhaseGVN& gvn) { assert(false, "no signed variant: %s", Name()); return nullptr; } + const Type* mem_t = gvn.type(in(MemNode::Address)); + if (mem_t == Type::TOP) { + return gvn.C->top(); + } return LoadNode::make(gvn, in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), - raw_adr_type(), rt, bt, _mo, _control_dependency, + mem_t->is_ptr(), rt, bt, _mo, _control_dependency, false /*require_atomic_access*/, is_unaligned_access(), is_mismatched_access()); } @@ -1399,8 +1468,12 @@ Node* LoadNode::convert_to_reinterpret_load(PhaseGVN& gvn, const Type* rt) { const int op = Opcode(); bool require_atomic_access = (op == Op_LoadL && ((LoadLNode*)this)->require_atomic_access()) || (op == Op_LoadD && ((LoadDNode*)this)->require_atomic_access()); + const Type* mem_t = gvn.type(in(MemNode::Address)); + if (mem_t == Type::TOP) { + return gvn.C->top(); + } return LoadNode::make(gvn, in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), - raw_adr_type(), rt, bt, _mo, _control_dependency, + mem_t->is_ptr(), rt, bt, _mo, _control_dependency, require_atomic_access, is_unaligned_access(), is_mismatched); } @@ -1422,8 +1495,12 @@ Node* StoreNode::convert_to_reinterpret_store(PhaseGVN& gvn, Node* val, const Ty const int op = Opcode(); bool require_atomic_access = (op == Op_StoreL && ((StoreLNode*)this)->require_atomic_access()) || (op == Op_StoreD && ((StoreDNode*)this)->require_atomic_access()); + const Type* mem_t = gvn.type(in(MemNode::Address)); + if (mem_t == Type::TOP) { + return gvn.C->top(); + } StoreNode* st = StoreNode::make(gvn, in(MemNode::Control), in(MemNode::Memory), in(MemNode::Address), - raw_adr_type(), val, bt, _mo, require_atomic_access); + mem_t->is_ptr(), val, bt, _mo, require_atomic_access); bool is_mismatched = is_mismatched_access(); const TypeRawPtr* raw_type = gvn.type(in(MemNode::Memory))->isa_rawptr(); @@ -1769,7 +1846,7 @@ Node* LoadNode::split_through_phi(PhaseGVN* phase, bool ignore_missing_instance_ } if (base_is_phi && (base->in(0) == region)) { Node* base_x = base->in(i); // Clone address for loads from boxed objects. - Node* adr_x = phase->transform(new AddPNode(base_x,base_x,address->in(AddPNode::Offset))); + Node* adr_x = phase->transform(AddPNode::make_with_base(base_x, address->in(AddPNode::Offset))); x->set_req(Address, adr_x); } } @@ -1851,7 +1928,6 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* ctrl = in(MemNode::Control); Node* address = in(MemNode::Address); - bool progress = false; bool addr_mark = ((phase->type(address)->isa_oopptr() || phase->type(address)->isa_narrowoop()) && phase->type(address)->is_ptr()->offset() == oopDesc::mark_offset_in_bytes()); @@ -1864,7 +1940,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { (depends_only_on_test() || has_unknown_control_dependency())) { ctrl = ctrl->in(0); set_req(MemNode::Control,ctrl); - progress = true; + return this; } intptr_t ignore = 0; @@ -1878,7 +1954,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { && all_controls_dominate(base, phase->C->start())) { // A method-invariant, non-null address (constant or 'this' argument). set_req(MemNode::Control, nullptr); - progress = true; + return this; } } @@ -1951,6 +2027,10 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { // the alias index stuff. So instead, peek through Stores and IFF we can // fold up, do so. Node* prev_mem = find_previous_store(phase); + if (prev_mem != nullptr && prev_mem->is_top()) { + // find_previous_store returns top when the access is dead + return prev_mem; + } if (prev_mem != nullptr) { Node* value = can_see_arraycopy_value(prev_mem, phase); if (value != nullptr) { @@ -1969,7 +2049,11 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { } } - return progress ? this : nullptr; + if (!can_reshape) { + phase->record_for_igvn(this); + } + + return nullptr; } // Helper to recognize certain Klass fields which are invariant across @@ -2402,7 +2486,6 @@ Node* LoadKlassNode::make(PhaseGVN& gvn, Node* mem, Node* adr, const TypePtr* at assert(adr_type != nullptr, "expecting TypeKlassPtr"); #ifdef _LP64 if (adr_type->is_ptr_to_narrowklass()) { - assert(UseCompressedClassPointers, "no compressed klasses"); Node* load_klass = gvn.transform(new LoadNKlassNode(mem, adr, at, tk->make_narrowklass(), MemNode::unordered)); return new DecodeNKlassNode(load_klass, load_klass->bottom_type()->make_ptr()); } @@ -2585,6 +2668,21 @@ LoadNode* LoadNode::clone_pinned() const { return ld; } +// Pin a LoadNode if it carries a dependency on its control input. There are cases when the node +// does not actually have any dependency on its control input. For example, if we have a LoadNode +// being used only outside a loop but it must be scheduled inside the loop, we can clone the node +// for each of its use so that all the clones can be scheduled outside the loop. Then, to prevent +// the clones from being GVN-ed again, we add a control input for each of them at the loop exit. In +// those case, since there is not a dependency between the node and its control input, we do not +// need to pin it. +LoadNode* LoadNode::pin_node_under_control_impl() const { + const TypePtr* adr_type = this->adr_type(); + if (adr_type != nullptr && adr_type->isa_aryptr()) { + // Only array accesses have dependencies on their control input + return clone_pinned(); + } + return nullptr; +} //------------------------------Value------------------------------------------ const Type* LoadNKlassNode::Value(PhaseGVN* phase) const { @@ -2696,6 +2794,7 @@ Node* LoadRangeNode::Identity(PhaseGVN* phase) { StoreNode* StoreNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, BasicType bt, MemOrd mo, bool require_atomic_access) { assert((mo == unordered || mo == release), "unexpected"); Compile* C = gvn.C; + assert(adr_type == nullptr || adr->is_top() || C->get_alias_index(gvn.type(adr)->is_ptr()) == C->get_alias_index(adr_type), "adr and adr_type must agree"); assert(C->get_alias_index(adr_type) != Compile::AliasIdxRaw || ctl != nullptr, "raw memory operations should have control edge"); @@ -2716,8 +2815,7 @@ StoreNode* StoreNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const val = gvn.transform(new EncodePNode(val, val->bottom_type()->make_narrowoop())); return new StoreNNode(ctl, mem, adr, adr_type, val, mo); } else if (adr->bottom_type()->is_ptr_to_narrowklass() || - (UseCompressedClassPointers && val->bottom_type()->isa_klassptr() && - adr->bottom_type()->isa_rawptr())) { + (val->bottom_type()->isa_klassptr() && adr->bottom_type()->isa_rawptr())) { val = gvn.transform(new EncodePKlassNode(val, val->bottom_type()->make_narrowklass())); return new StoreNKlassNode(ctl, mem, adr, adr_type, val, mo); } @@ -3511,8 +3609,11 @@ Node* StoreNode::Identity(PhaseGVN* phase) { val->in(MemNode::Address)->eqv_uncast(adr) && val->in(MemNode::Memory )->eqv_uncast(mem) && val->as_Load()->store_Opcode() == Opcode()) { - // Ensure vector type is the same - if (!is_StoreVector() || (mem->is_LoadVector() && as_StoreVector()->vect_type() == mem->as_LoadVector()->vect_type())) { + if (!is_StoreVector()) { + result = mem; + } else if (Opcode() == Op_StoreVector && val->Opcode() == Op_LoadVector && + as_StoreVector()->vect_type() == val->as_LoadVector()->vect_type()) { + // Ensure both are not masked accesses or gathers/scatters and vector types are the same result = mem; } } @@ -3558,6 +3659,10 @@ Node* StoreNode::Identity(PhaseGVN* phase) { Node* prev_mem = find_previous_store(phase); // Steps (a), (b): Walk past independent stores to find an exact match. if (prev_mem != nullptr) { + if (prev_mem->is_top()) { + // find_previous_store returns top when the access is dead + return prev_mem; + } Node* prev_val = can_see_stored_value(prev_mem, phase); if (prev_val != nullptr && prev_val == val) { // prev_val and val might differ by a cast; it would be good @@ -4084,10 +4189,10 @@ Node *ClearArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *off = phase->MakeConX(BytesPerLong); mem = new StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); count--; - while( count-- ) { + while (count--) { mem = phase->transform(mem); - adr = phase->transform(new AddPNode(base,adr,off)); - mem = new StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); + adr = phase->transform(AddPNode::make_with_base(base, adr, off)); + mem = new StoreLNode(in(0), mem, adr, atp, zero, MemNode::unordered, false); } return mem; } @@ -4124,7 +4229,7 @@ Node* ClearArrayNode::make_address(Node* dest, Node* offset, bool raw_base, Phas // May be called as part of the initialization of a just allocated object base = phase->C->top(); } - return phase->transform(new AddPNode(base, dest, offset)); + return phase->transform(AddPNode::make_with_base(base, dest, offset)); } //----------------------------clear_memory------------------------------------- @@ -4242,7 +4347,9 @@ MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) { case Op_StoreStoreFence: return new StoreStoreFenceNode(C, atp, pn); case Op_MemBarAcquireLock: return new MemBarAcquireLockNode(C, atp, pn); case Op_MemBarReleaseLock: return new MemBarReleaseLockNode(C, atp, pn); + case Op_MemBarStoreLoad: return new MemBarStoreLoadNode(C, atp, pn); case Op_MemBarVolatile: return new MemBarVolatileNode(C, atp, pn); + case Op_MemBarFull: return new MemBarFullNode(C, atp, pn); case Op_MemBarCPUOrder: return new MemBarCPUOrderNode(C, atp, pn); case Op_OnSpinWait: return new OnSpinWaitNode(C, atp, pn); case Op_Initialize: return new InitializeNode(C, atp, pn); @@ -4933,8 +5040,7 @@ Node* InitializeNode::make_raw_address(intptr_t offset, Node* addr = in(RawAddress); if (offset != 0) { Compile* C = phase->C; - addr = phase->transform( new AddPNode(C->top(), addr, - phase->MakeConX(offset)) ); + addr = phase->transform(AddPNode::make_off_heap(addr, phase->MakeConX(offset))); } return addr; } @@ -4981,7 +5087,7 @@ Node* InitializeNode::capture_store(StoreNode* st, intptr_t start, else ins_req(i, C->top()); // build a new edge } - Node* new_st = st->clone(); + Node* new_st = st->clone_with_adr_type(TypeRawPtr::BOTTOM); BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); new_st->set_req(MemNode::Control, in(Control)); new_st->set_req(MemNode::Memory, prev_mem); diff --git a/src/hotspot/share/opto/memnode.hpp b/src/hotspot/share/opto/memnode.hpp index 249df51beb9..7fa238f574d 100644 --- a/src/hotspot/share/opto/memnode.hpp +++ b/src/hotspot/share/opto/memnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,6 +26,7 @@ #ifndef SHARE_OPTO_MEMNODE_HPP #define SHARE_OPTO_MEMNODE_HPP +#include "memory/allocation.hpp" #include "opto/multnode.hpp" #include "opto/node.hpp" #include "opto/opcodes.hpp" @@ -46,6 +47,8 @@ private: bool _unsafe_access; // Access of unsafe origin. uint8_t _barrier_data; // Bit field with barrier information + friend class AccessAnalyzer; + protected: #ifdef ASSERT const TypePtr* _adr_type; // What kind of memory is being addressed? @@ -170,6 +173,53 @@ public: static void dump_adr_type(const TypePtr* adr_type, outputStream* st); virtual void dump_spec(outputStream *st) const; #endif + + MemNode* clone_with_adr_type(const TypePtr* adr_type) const { + MemNode* new_node = clone()->as_Mem(); +#ifdef ASSERT + new_node->_adr_type = adr_type; +#endif + return new_node; + } +}; + +// Analyze a MemNode to try to prove that it is independent from other memory accesses +class AccessAnalyzer : StackObj { +private: + PhaseValues* const _phase; + MemNode* const _n; + Node* _base; + intptr_t _offset; + const int _memory_size; + bool _maybe_raw; + AllocateNode* _alloc; + const TypePtr* _adr_type; + int _alias_idx; + +public: + AccessAnalyzer(PhaseValues* phase, MemNode* n); + + // The result of deciding whether a memory node 'other' writes into the memory which '_n' + // observes. + class AccessIndependence { + public: + // Whether 'other' writes into the memory which '_n' observes. This value is conservative, that + // is, it is only true when it is provable that the memory accessed by the nodes is + // non-overlapping. + bool independent; + + // If 'independent' is true, this is the memory input of 'other' that corresponds to the memory + // location that '_n' observes. For example, if 'other' is a StoreNode, then 'mem' is its + // memory input, if 'other' is a MergeMemNode, then 'mem' is the memory input corresponding to + // the alias class of '_n'. + // If 'independent' is false, + // - 'mem' is non-nullptr if it seems that 'other' writes to the exact memory location '_n' + // observes. + // - 'mem' is nullptr otherwise. + Node* mem; + }; + + AccessIndependence detect_access_independence(Node* other) const; }; //------------------------------LoadNode--------------------------------------- @@ -299,8 +349,6 @@ public: bool has_unknown_control_dependency() const { return _control_dependency == UnknownControl; } bool has_pinned_control_dependency() const { return _control_dependency == Pinned; } - LoadNode* pin_array_access_node() const; - #ifndef PRODUCT virtual void dump_spec(outputStream *st) const; #endif @@ -314,6 +362,7 @@ protected: Node* can_see_arraycopy_value(Node* st, PhaseGVN* phase) const; +private: // depends_only_on_test is almost always true, and needs to be almost always // true to enable key hoisting & commoning optimizations. However, for the // special case of RawPtr loads from TLS top & end, and other loads performed by @@ -323,11 +372,12 @@ protected: // which produce results (new raw memory state) inside of loops preventing all // manner of other optimizations). Basically, it's ugly but so is the alternative. // See comment in macro.cpp, around line 125 expand_allocate_common(). - virtual bool depends_only_on_test() const { + virtual bool depends_only_on_test_impl() const { return adr_type() != TypeRawPtr::BOTTOM && _control_dependency == DependsOnlyOnTest; } LoadNode* clone_pinned() const; + virtual LoadNode* pin_node_under_control_impl() const; }; //------------------------------LoadBNode-------------------------------------- @@ -534,7 +584,6 @@ public: virtual int Opcode() const; virtual const Type* Value(PhaseGVN* phase) const; virtual Node* Identity(PhaseGVN* phase); - virtual bool depends_only_on_test() const { return true; } // Polymorphic factory method: static Node* make(PhaseGVN& gvn, Node* mem, Node* adr, const TypePtr* at, @@ -563,7 +612,6 @@ public: virtual const Type* Value(PhaseGVN* phase) const; virtual Node* Identity(PhaseGVN* phase); - virtual bool depends_only_on_test() const { return true; } }; @@ -580,7 +628,6 @@ private: virtual uint size_of() const { return sizeof(*this); } protected: virtual bool cmp( const Node &n ) const; - virtual bool depends_only_on_test() const { return false; } Node *Ideal_masked_input (PhaseGVN *phase, uint mask); Node* Ideal_sign_extended_input(PhaseGVN* phase, int num_rejected_bits); @@ -660,6 +707,9 @@ public: Node* convert_to_reinterpret_store(PhaseGVN& gvn, Node* val, const Type* vt); MemBarNode* trailing_membar() const; + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------StoreBNode------------------------------------- @@ -816,7 +866,6 @@ private: #endif // ASSERT public: LoadStoreNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* rt, uint required ); - virtual bool depends_only_on_test() const { return false; } virtual uint match_edge(uint idx) const { return idx == MemNode::Address || idx == MemNode::ValueIn; } virtual const Type *bottom_type() const { return _type; } @@ -829,6 +878,9 @@ public: uint8_t barrier_data() { return _barrier_data; } void set_barrier_data(uint8_t barrier_data) { _barrier_data = barrier_data; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; class LoadStoreConditionalNode : public LoadStoreNode { @@ -1115,6 +1167,9 @@ public: // Return allocation input memory edge if it is different instance // or itself if it is the one we are looking for. static bool step_through(Node** np, uint instance_id, PhaseValues* phase); + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------MemBar----------------------------------------- @@ -1266,6 +1321,13 @@ public: virtual int Opcode() const; }; +class MemBarStoreLoadNode : public MemBarNode { +public: + MemBarStoreLoadNode(Compile* C, int alias_idx, Node* precedent) + : MemBarNode(C, alias_idx, precedent) {} + virtual int Opcode() const; +}; + // Ordering between a volatile store and a following volatile load. // Requires multi-CPU visibility? class MemBarVolatileNode: public MemBarNode { @@ -1275,6 +1337,14 @@ public: virtual int Opcode() const; }; +// A full barrier blocks all loads and stores from moving across it +class MemBarFullNode : public MemBarNode { +public: + MemBarFullNode(Compile* C, int alias_idx, Node* precedent) + : MemBarNode(C, alias_idx, precedent) {} + virtual int Opcode() const; +}; + // Ordering within the same CPU. Used to order unsafe memory references // inside the compiler when we lack alias info. Not needed "outside" the // compiler because the CPU does all the ordering for us. @@ -1677,6 +1747,9 @@ public: virtual uint match_edge(uint idx) const { return (idx == 2); } virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; } virtual const Type *bottom_type() const { return Type::MEMORY; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; // cachewb pre sync node for ensuring that writebacks are serialised @@ -1689,6 +1762,9 @@ public: virtual uint match_edge(uint idx) const { return false; } virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; } virtual const Type *bottom_type() const { return Type::MEMORY; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; // cachewb pre sync node for ensuring that writebacks are serialised @@ -1701,6 +1777,9 @@ public: virtual uint match_edge(uint idx) const { return false; } virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; } virtual const Type *bottom_type() const { return Type::MEMORY; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------Prefetch--------------------------------------- @@ -1713,6 +1792,9 @@ public: virtual uint ideal_reg() const { return NotAMachineReg; } virtual uint match_edge(uint idx) const { return idx==2; } virtual const Type *bottom_type() const { return ( AllocatePrefetchStyle == 3 ) ? Type::MEMORY : Type::ABIO; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; #endif // SHARE_OPTO_MEMNODE_HPP diff --git a/src/hotspot/share/opto/mulnode.cpp b/src/hotspot/share/opto/mulnode.cpp index aa8d6cfce2e..d7022b5f7ec 100644 --- a/src/hotspot/share/opto/mulnode.cpp +++ b/src/hotspot/share/opto/mulnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -651,31 +651,19 @@ Node* AndINode::Identity(PhaseGVN* phase) { return in(1); } - Node* in1 = in(1); - uint op = in1->Opcode(); - const TypeInt* t2 = phase->type(in(2))->isa_int(); - if (t2 && t2->is_con()) { - int con = t2->get_con(); - // Masking off high bits which are always zero is useless. - const TypeInt* t1 = phase->type(in(1))->isa_int(); - if (t1 != nullptr && t1->_lo >= 0) { - jint t1_support = right_n_bits(1 + log2i_graceful(t1->_hi)); - if ((t1_support & con) == t1_support) - return in1; - } - // Masking off the high bits of a unsigned-shift-right is not - // needed either. - if (op == Op_URShiftI) { - const TypeInt* t12 = phase->type(in1->in(2))->isa_int(); - if (t12 && t12->is_con()) { // Shift is by a constant - int shift = t12->get_con(); - shift &= BitsPerJavaInteger - 1; // semantics of Java shifts - int mask = max_juint >> shift; - if ((mask & con) == mask) // If AND is useless, skip it - return in1; - } - } + const TypeInt* t1 = phase->type(in(1))->is_int(); + const TypeInt* t2 = phase->type(in(2))->is_int(); + + if ((~t1->_bits._ones & ~t2->_bits._zeros) == 0) { + // All bits that might be 0 in in1 are known to be 0 in in2 + return in(2); } + + if ((~t2->_bits._ones & ~t1->_bits._zeros) == 0) { + // All bits that might be 0 in in2 are known to be 0 in in1 + return in(1); + } + return MulNode::Identity(phase); } @@ -779,32 +767,19 @@ Node* AndLNode::Identity(PhaseGVN* phase) { return in(1); } - Node *usr = in(1); - const TypeLong *t2 = phase->type( in(2) )->isa_long(); - if( t2 && t2->is_con() ) { - jlong con = t2->get_con(); - // Masking off high bits which are always zero is useless. - const TypeLong* t1 = phase->type( in(1) )->isa_long(); - if (t1 != nullptr && t1->_lo >= 0) { - int bit_count = log2i_graceful(t1->_hi) + 1; - jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count)); - if ((t1_support & con) == t1_support) - return usr; - } - uint lop = usr->Opcode(); - // Masking off the high bits of a unsigned-shift-right is not - // needed either. - if( lop == Op_URShiftL ) { - const TypeInt *t12 = phase->type( usr->in(2) )->isa_int(); - if( t12 && t12->is_con() ) { // Shift is by a constant - int shift = t12->get_con(); - shift &= BitsPerJavaLong - 1; // semantics of Java shifts - jlong mask = max_julong >> shift; - if( (mask&con) == mask ) // If AND is useless, skip it - return usr; - } - } + const TypeLong* t1 = phase->type(in(1))->is_long(); + const TypeLong* t2 = phase->type(in(2))->is_long(); + + if ((~t1->_bits._ones & ~t2->_bits._zeros) == 0) { + // All bits that might be 0 in in1 are known to be 0 in in2 + return in(2); } + + if ((~t2->_bits._ones & ~t1->_bits._zeros) == 0) { + // All bits that might be 0 in in2 are known to be 0 in in1 + return in(1); + } + return MulNode::Identity(phase); } @@ -902,27 +877,28 @@ static bool mask_shift_amount(PhaseGVN* phase, const Node* shift_node, uint nBit } // Use this in ::Ideal only with shiftNode == this! -// Returns the masked shift amount if constant or 0 if not constant. -static uint mask_and_replace_shift_amount(PhaseGVN* phase, Node* shift_node, uint nBits) { +// Sets masked_shift to the masked shift amount if constant or 0 if not constant. +// Returns shift_node if the shift amount input node was modified, nullptr otherwise. +static Node* mask_and_replace_shift_amount(PhaseGVN* phase, Node* shift_node, uint nBits, uint& masked_shift) { int real_shift; - uint masked_shift; if (mask_shift_amount(phase, shift_node, nBits, real_shift, masked_shift)) { if (masked_shift == 0) { // Let Identity() handle 0 shift count. - return 0; + return nullptr; } if (real_shift != (int)masked_shift) { - PhaseIterGVN* igvn = phase->is_IterGVN(); - if (igvn != nullptr) { - igvn->_worklist.push(shift_node); - } shift_node->set_req(2, phase->intcon(masked_shift)); // Replace shift count with masked value. + + // We need to notify the caller that the graph was reshaped, as Ideal needs + // to return the root of the reshaped graph if any change was made. + return shift_node; } - return masked_shift; + } else { + // Not a shift by a constant. + masked_shift = 0; } - // Not a shift by a constant. - return 0; + return nullptr; } // Called with @@ -974,7 +950,8 @@ Node* LShiftINode::Identity(PhaseGVN* phase) { } Node* LShiftNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { - uint con = mask_and_replace_shift_amount(phase, this, bits_per_java_integer(bt)); + uint con; + Node* progress = mask_and_replace_shift_amount(phase, this, bits_per_java_integer(bt), con); if (con == 0) { return nullptr; } @@ -1113,7 +1090,7 @@ Node* LShiftNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { return doubleShift; } - return nullptr; + return progress; } //------------------------------Ideal------------------------------------------ @@ -1141,21 +1118,24 @@ const Type* LShiftNode::ValueIL(PhaseGVN* phase, BasicType bt) const { return t1; } - // Either input is BOTTOM ==> the result is BOTTOM - if ((t1 == TypeInteger::bottom(bt)) || (t2 == TypeInt::INT) || - (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM)) { + // If nothing is known about the shift amount then the result is BOTTOM + if (t2 == TypeInt::INT) { return TypeInteger::bottom(bt); } const TypeInteger* r1 = t1->is_integer(bt); // Handy access - const TypeInt* r2 = t2->is_int(); // Handy access + // Since the shift semantics in Java take into account only the bottom five + // bits for ints and the bottom six bits for longs, we can further constrain + // the range of values of the shift amount by ANDing with the right mask based + // on whether the type is int or long. + const TypeInt* mask = TypeInt::make(bits_per_java_integer(bt) - 1); + const TypeInt* r2 = RangeInference::infer_and(t2->is_int(), mask); if (!r2->is_con()) { return TypeInteger::bottom(bt); } uint shift = r2->get_con(); - shift &= bits_per_java_integer(bt) - 1; // semantics of Java shifts // Shift by a multiple of 32/64 does nothing: if (shift == 0) { return t1; @@ -1164,22 +1144,20 @@ const Type* LShiftNode::ValueIL(PhaseGVN* phase, BasicType bt) const { // If the shift is a constant, shift the bounds of the type, // unless this could lead to an overflow. if (!r1->is_con()) { - jlong lo = r1->lo_as_long(), hi = r1->hi_as_long(); #ifdef ASSERT if (bt == T_INT) { + jlong lo = r1->lo_as_long(), hi = r1->hi_as_long(); jint lo_int = r1->is_int()->_lo, hi_int = r1->is_int()->_hi; assert((java_shift_right(java_shift_left(lo, shift, bt), shift, bt) == lo) == (((lo_int << shift) >> shift) == lo_int), "inconsistent"); assert((java_shift_right(java_shift_left(hi, shift, bt), shift, bt) == hi) == (((hi_int << shift) >> shift) == hi_int), "inconsistent"); } #endif - if (java_shift_right(java_shift_left(lo, shift, bt), shift, bt) == lo && - java_shift_right(java_shift_left(hi, shift, bt), shift, bt) == hi) { - // No overflow. The range shifts up cleanly. - return TypeInteger::make(java_shift_left(lo, shift, bt), - java_shift_left(hi, shift, bt), - MAX2(r1->_widen, r2->_widen), bt); + + if (bt == T_INT) { + return RangeInference::infer_lshift(r1->is_int(), shift); } - return TypeInteger::bottom(bt); + + return RangeInference::infer_lshift(r1->is_long(), shift); } return TypeInteger::make(java_shift_left(r1->get_con_as_long(bt), shift, bt), bt); @@ -1238,20 +1216,26 @@ Node* RShiftNode::IdentityIL(PhaseGVN* phase, BasicType bt) { return in(1); } // Check for useless sign-masking + int lshift_count = 0; if (in(1)->Opcode() == Op_LShift(bt) && in(1)->req() == 3 && - in(1)->in(2) == in(2)) { + // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized + // negative constant (e.g. -1 vs 31) + const_shift_count(phase, in(1), &lshift_count)) { count &= bits_per_java_integer(bt) - 1; // semantics of Java shifts - // Compute masks for which this shifting doesn't change - jlong lo = (CONST64(-1) << (bits_per_java_integer(bt) - ((uint)count)-1)); // FFFF8000 - jlong hi = ~lo; // 00007FFF - const TypeInteger* t11 = phase->type(in(1)->in(1))->isa_integer(bt); - if (t11 == nullptr) { - return this; - } - // Does actual value fit inside of mask? - if (lo <= t11->lo_as_long() && t11->hi_as_long() <= hi) { - return in(1)->in(1); // Then shifting is a nop + lshift_count &= bits_per_java_integer(bt) - 1; + if (count == lshift_count) { + // Compute masks for which this shifting doesn't change + jlong lo = (CONST64(-1) << (bits_per_java_integer(bt) - ((uint)count)-1)); // FFFF8000 + jlong hi = ~lo; // 00007FFF + const TypeInteger* t11 = phase->type(in(1)->in(1))->isa_integer(bt); + if (t11 == nullptr) { + return this; + } + // Does actual value fit inside of mask? + if (lo <= t11->lo_as_long() && t11->hi_as_long() <= hi) { + return in(1)->in(1); // Then shifting is a nop + } } } } @@ -1268,7 +1252,9 @@ Node* RShiftNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { if (t1 == nullptr) { return NodeSentinel; // Left input is an integer } - int shift = mask_and_replace_shift_amount(phase, this, bits_per_java_integer(bt)); + + uint shift; + Node* progress = mask_and_replace_shift_amount(phase, this, bits_per_java_integer(bt), shift); if (shift == 0) { return NodeSentinel; } @@ -1278,7 +1264,7 @@ Node* RShiftNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { // Such expressions arise normally from shift chains like (byte)(x >> 24). const Node* and_node = in(1); if (and_node->Opcode() != Op_And(bt)) { - return nullptr; + return progress; } const TypeInteger* mask_t = phase->type(and_node->in(2))->isa_integer(bt); if (mask_t != nullptr && mask_t->is_con()) { @@ -1287,7 +1273,8 @@ Node* RShiftNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { Node* shr_nomask = phase->transform(RShiftNode::make(and_node->in(1), in(2), bt)); return MulNode::make_and(shr_nomask, phase->integercon(maskbits >> shift, bt), bt); } - return nullptr; + + return progress; } Node* RShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { @@ -1298,18 +1285,19 @@ Node* RShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { if (progress != nullptr) { return progress; } - int shift = mask_and_replace_shift_amount(phase, this, BitsPerJavaInteger); + uint shift; + progress = mask_and_replace_shift_amount(phase, this, BitsPerJavaInteger, shift); assert(shift != 0, "handled by IdealIL"); // Check for "(short[i] <<16)>>16" which simply sign-extends const Node *shl = in(1); if (shl->Opcode() != Op_LShiftI) { - return nullptr; + return progress; } const TypeInt* left_shift_t = phase->type(shl->in(2))->isa_int(); if (left_shift_t == nullptr) { - return nullptr; + return progress; } if (shift == 16 && left_shift_t->is_con(16)) { Node *ld = shl->in(1); @@ -1341,7 +1329,7 @@ Node* RShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { } } - return nullptr; + return progress; } const Type* RShiftNode::ValueIL(PhaseGVN* phase, BasicType bt) const { @@ -1497,7 +1485,8 @@ Node* URShiftINode::Identity(PhaseGVN* phase) { //------------------------------Ideal------------------------------------------ Node* URShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { - int con = mask_and_replace_shift_amount(phase, this, BitsPerJavaInteger); + uint con; + Node* progress = mask_and_replace_shift_amount(phase, this, BitsPerJavaInteger, con); if (con == 0) { return nullptr; } @@ -1524,14 +1513,22 @@ Node* URShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { // If Q is "X << z" the rounding is useless. Look for patterns like // ((X<>> Z and replace with (X + Y>>>Z) & Z-mask. Node *add = in(1); - const TypeInt *t2 = phase->type(in(2))->isa_int(); if (in1_op == Op_AddI) { Node *lshl = add->in(1); - if( lshl->Opcode() == Op_LShiftI && - phase->type(lshl->in(2)) == t2 ) { - Node *y_z = phase->transform( new URShiftINode(add->in(2),in(2)) ); - Node *sum = phase->transform( new AddINode( lshl->in(1), y_z ) ); - return new AndINode( sum, phase->intcon(mask) ); + Node *y = add->in(2); + if (lshl->Opcode() != Op_LShiftI) { + lshl = add->in(2); + y = add->in(1); + } + // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized + // negative constant (e.g. -1 vs 31) + int lshl_con = 0; + if (lshl->Opcode() == Op_LShiftI && + const_shift_count(phase, lshl, &lshl_con) && + (lshl_con & (BitsPerJavaInteger - 1)) == con) { + Node *y_z = phase->transform(new URShiftINode(y, in(2))); + Node *sum = phase->transform(new AddINode(lshl->in(1), y_z)); + return new AndINode(sum, phase->intcon(mask)); } } @@ -1555,11 +1552,16 @@ Node* URShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { // Check for "(X << z ) >>> z" which simply zero-extends Node *shl = in(1); - if( in1_op == Op_LShiftI && - phase->type(shl->in(2)) == t2 ) - return new AndINode( shl->in(1), phase->intcon(mask) ); + // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized + // negative constant (e.g. -1 vs 31) + int shl_con = 0; + if (in1_op == Op_LShiftI && + const_shift_count(phase, shl, &shl_con) && + (shl_con & (BitsPerJavaInteger - 1)) == con) + return new AndINode(shl->in(1), phase->intcon(mask)); // Check for (x >> n) >>> 31. Replace with (x >>> 31) + const TypeInt* t2 = phase->type(in(2))->isa_int(); Node *shr = in(1); if ( in1_op == Op_RShiftI ) { Node *in11 = shr->in(1); @@ -1571,7 +1573,7 @@ Node* URShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { } } - return nullptr; + return progress; } //------------------------------Value------------------------------------------ @@ -1661,7 +1663,8 @@ Node* URShiftLNode::Identity(PhaseGVN* phase) { //------------------------------Ideal------------------------------------------ Node* URShiftLNode::Ideal(PhaseGVN* phase, bool can_reshape) { - int con = mask_and_replace_shift_amount(phase, this, BitsPerJavaLong); + uint con; + Node* progress = mask_and_replace_shift_amount(phase, this, BitsPerJavaLong, con); if (con == 0) { return nullptr; } @@ -1677,11 +1680,20 @@ Node* URShiftLNode::Ideal(PhaseGVN* phase, bool can_reshape) { const TypeInt *t2 = phase->type(in(2))->isa_int(); if (add->Opcode() == Op_AddL) { Node *lshl = add->in(1); - if( lshl->Opcode() == Op_LShiftL && - phase->type(lshl->in(2)) == t2 ) { - Node *y_z = phase->transform( new URShiftLNode(add->in(2),in(2)) ); - Node *sum = phase->transform( new AddLNode( lshl->in(1), y_z ) ); - return new AndLNode( sum, phase->longcon(mask) ); + Node *y = add->in(2); + if (lshl->Opcode() != Op_LShiftL) { + lshl = add->in(2); + y = add->in(1); + } + // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized + // negative constant (e.g. -1 vs 63) + int lshl_con = 0; + if (lshl->Opcode() == Op_LShiftL && + const_shift_count(phase, lshl, &lshl_con) && + (lshl_con & (BitsPerJavaLong - 1)) == con) { + Node* y_z = phase->transform(new URShiftLNode(y, in(2))); + Node* sum = phase->transform(new AddLNode(lshl->in(1), y_z)); + return new AndLNode(sum, phase->longcon(mask)); } } @@ -1701,9 +1713,14 @@ Node* URShiftLNode::Ideal(PhaseGVN* phase, bool can_reshape) { // Check for "(X << z ) >>> z" which simply zero-extends Node *shl = in(1); - if( shl->Opcode() == Op_LShiftL && - phase->type(shl->in(2)) == t2 ) - return new AndLNode( shl->in(1), phase->longcon(mask) ); + // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized + // negative constant (e.g. -1 vs 63) + int shl_con = 0; + if (shl->Opcode() == Op_LShiftL && + const_shift_count(phase, shl, &shl_con) && + (shl_con & (BitsPerJavaLong - 1)) == con) { + return new AndLNode(shl->in(1), phase->longcon(mask)); + } // Check for (x >> n) >>> 63. Replace with (x >>> 63) Node *shr = in(1); @@ -1716,7 +1733,8 @@ Node* URShiftLNode::Ideal(PhaseGVN* phase, bool can_reshape) { return new URShiftLNode(in11, phase->intcon(63)); } } - return nullptr; + + return progress; } //------------------------------Value------------------------------------------ diff --git a/src/hotspot/share/opto/multnode.hpp b/src/hotspot/share/opto/multnode.hpp index 20ab59aeabc..b63d418b742 100644 --- a/src/hotspot/share/opto/multnode.hpp +++ b/src/hotspot/share/opto/multnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +42,6 @@ public: virtual const Type *bottom_type() const = 0; virtual bool is_CFG() const { return true; } virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash - virtual bool depends_only_on_test() const { return false; } virtual const RegMask &out_RegMask() const; virtual Node *match( const ProjNode *proj, const Matcher *m ); virtual uint ideal_reg() const { return NotAMachineReg; } @@ -176,8 +175,7 @@ public: const bool _is_io_use; // Used to distinguish between the projections // used on the control and io paths from a macro node virtual int Opcode() const; - virtual bool is_CFG() const; - virtual bool depends_only_on_test() const { return false; } + virtual bool is_CFG() const; virtual const Type *bottom_type() const; virtual const TypePtr *adr_type() const; virtual bool pinned() const; diff --git a/src/hotspot/share/opto/narrowptrnode.cpp b/src/hotspot/share/opto/narrowptrnode.cpp index 7f86b8caecf..8b91bfaa944 100644 --- a/src/hotspot/share/opto/narrowptrnode.cpp +++ b/src/hotspot/share/opto/narrowptrnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ const Type* EncodePKlassNode::Value(PhaseGVN* phase) const { if (t == Type::TOP) return Type::TOP; assert (t != TypePtr::NULL_PTR, "null klass?"); - assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here"); + assert(t->isa_klassptr(), "only klass ptr here"); return t->make_narrowklass(); } diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp index e65578924d1..46b89aa2c5f 100644 --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -1059,14 +1059,135 @@ public: virtual bool is_CFG() const { return false; } - // If this node is control-dependent on a test, can it be - // rerouted to a dominating equivalent test? This is usually - // true of non-CFG nodes, but can be false for operations which - // depend for their correct sequencing on more than one test. - // (In that case, hoisting to a dominating test may silently - // skip some other important test.) - virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; }; + // If this node is control-dependent on a test, can it be rerouted to a dominating equivalent + // test? This means that the node can be executed safely as long as it happens after the test + // that is its control input without worrying about the whole control flow. On the contrary, if + // the node depends on a test that is not its control input, or if it depends on more than one + // tests, then this method must return false. + // + // Pseudocode examples: + // 1. if (y != 0) { + // x / y; + // } + // The division depends only on the test y != 0 and can be executed anywhere y != 0 holds true. + // As a result, depends_only_on_test returns true. + // 2. if (y != 0) { + // if (x > 1) { + // x / y; + // } + // } + // If the division x / y has its control input being the IfTrueNode of the test y != 0, then + // depends_only_on_test returns true. Otherwise, if the division has its control input being the + // IfTrueNode of the test x > 1, then depends_only_on_test returns false. + // 3. if (y > z) { + // if (z > 0) { + // x / y + // } + // } + // The division depends on both tests y > z and z > 0. As a result, depends_only_on_test returns + // false. + // + // This method allows more freedom in certain nodes with regards to scheduling, for example it + // allows nodes to float out of loops together with its test. + // + // This method is pessimistic, this means that it may return false even if the node satisfy the + // requirements. However, it must return false if the node does not satisfy the requirements. + // When a test is decomposed into multiple tests, all nodes that depend on the decomposed test + // must be pinned at the lowest dominating test of those. For example, when a zero check of a + // division is split through a region but the division itself is not, it must be pinned at the + // merge point by returning false when calling this method. + bool depends_only_on_test() const { + if (is_CFG() || pinned()) { + return false; + } + assert(in(0) != nullptr, "must have a control input"); + return depends_only_on_test_impl(); + } + // Return a clone of the current node that's pinned. The current node must return true for + // depends_only_on_test, and the retuned node must return false. This method is called when the + // node is disconnected from its test. + // + // Examples: + // 1. for (int i = start; i <= limit; i++) { + // if (!rangecheck(i, a)) { + // trap; + // } + // a[i]; + // } + // Loop predication can then hoist the range check out of the loop: + // if (!rangecheck(start, a)) { + // trap; + // } + // if (!rangecheck(limit, a)) { + // trap; + // } + // for (int i = start; i <= limit; i++) { + // a[i]; + // } + // As the load a[i] now depends on both tests rangecheck(start, a) and rangecheck(limit, a), it + // must be pinned at the lowest dominating test of those. + // + // 2. if (y > x) { + // if (x >= 0) { + // if (y != 0) { + // x / y; + // } + // } + // } + // The test (y != 0) == true can be deduced from (y > x) == true and (x >= 0) == true, so we may + // choose to elide it. In such cases, the division x / y now depends on both tests + // (y > x) == true and (x >= 0) == true, so it must be pinned at the lowest dominating test of + // those. + // + // 3. if (b) { + // ... + // } else { + // ... + // } + // if (y == 0) { + // trap; + // } + // x / y; + // The division x / y depends only on the test (y == 0) == false, but if we split the test + // through the merge point but not the division: + // if (b) { + // ... + // if (y == 0) { + // trap; + // } + // } else { + // ... + // if (y == 0) { + // trap; + // } + // } + // x / y; + // The division now has the control input being the RegionNode merge the branches of if(b) + // instead of a test that proves y != 0. As a result, it must be pinned at that node. + // + // There are cases where the node does not actually have a dependency on its control input. For + // example, when we try to sink a LoadNode out of a loop in PhaseIdealLoop::try_sink_out_of_loop, + // we clone the node so that all of the clones can be scheduled out of the loop. To prevent the + // clones from being GVN-ed again, we add a control input for the node at the loop exit. For the + // cases when the node does provably not depend on its control input, this method can return + // nullptr. + Node* pin_node_under_control() const { + assert(depends_only_on_test(), "must be a depends_only_on_test node"); + Node* res = pin_node_under_control_impl(); + if (res == nullptr) { + assert(is_Load(), "unexpected failure to pin for %s", Name()); + return nullptr; + } + assert(!res->depends_only_on_test(), "the result must not depends_only_on_test"); + return res; + } + +private: + virtual bool depends_only_on_test_impl() const { assert(false, "%s", Name()); return false; } + virtual Node* pin_node_under_control_impl() const { assert(false, "%s", Name()); return nullptr; } + +public: // When building basic blocks, I need to have a notion of block beginning // Nodes, next block selector Nodes (block enders), and next block // projections. These calls need to work on their machine equivalents. The @@ -1201,13 +1322,6 @@ public: template void visit_uses(Callback callback, Check is_boundary) const; - // Returns a clone of the current node that's pinned (if the current node is not) for nodes found in array accesses - // (Load and range check CastII nodes). - // This is used when an array access is made dependent on 2 or more range checks (range check smearing or Loop Predication). - virtual Node* pin_array_access_node() const { - return nullptr; - } - //----------------- Code Generation // Ideal register class for Matching. Zero means unmatched instruction diff --git a/src/hotspot/share/opto/output.cpp b/src/hotspot/share/opto/output.cpp index 136fc8ac864..a70620fac5b 100644 --- a/src/hotspot/share/opto/output.cpp +++ b/src/hotspot/share/opto/output.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -363,15 +363,6 @@ bool PhaseOutput::need_stack_bang(int frame_size_in_bytes) const { DEBUG_ONLY(|| true))); } -bool PhaseOutput::need_register_stack_bang() const { - // Determine if we need to generate a register stack overflow check. - // This is only used on architectures which have split register - // and memory stacks. - // Bang if the method is not a stub function and has java calls - return (C->stub_function() == nullptr && C->has_java_calls()); -} - - // Compute the size of first NumberOfLoopInstrToAlign instructions at the top // of a loop. When aligning a loop we need to provide enough instructions // in cpu's fetch buffer to feed decoders. The loop alignment could be @@ -2923,17 +2914,30 @@ void Scheduling::ComputeRegisterAntidependencies(Block *b) { Node *m = b->get_node(i); - // Add precedence edge from following safepoint to use of derived pointer - if( last_safept_node != end_node && + if (last_safept_node != end_node && m != last_safept_node) { + bool need_safept_prec = false; + // Add precedence edge from following safepoint to use of derived pointer for (uint k = 1; k < m->req(); k++) { const Type *t = m->in(k)->bottom_type(); - if( t->isa_oop_ptr() && - t->is_ptr()->offset() != 0 ) { - last_safept_node->add_prec( m ); + if (t->isa_oop_ptr() && + t->is_ptr()->offset() != 0) { + need_safept_prec = true; break; } } + // A CheckCastPP whose input is still RawPtr must stay above the following safepoint. + // Otherwise post-regalloc block-local scheduling can leave a live raw oop at the safepoint. + if (!need_safept_prec && m->is_Mach() && + m->as_Mach()->ideal_Opcode() == Op_CheckCastPP) { + Node* def = m->in(1); + if (def != nullptr && def->bottom_type()->base() == Type::RawPtr) { + need_safept_prec = true; + } + } + if (need_safept_prec) { + last_safept_node->add_prec(m); + } } if( n->jvms() ) { // Precedence edge from derived to safept diff --git a/src/hotspot/share/opto/output.hpp b/src/hotspot/share/opto/output.hpp index 432ad3638b2..5cca59ea0e4 100644 --- a/src/hotspot/share/opto/output.hpp +++ b/src/hotspot/share/opto/output.hpp @@ -109,7 +109,6 @@ public: // Convert Nodes to instruction bits and pass off to the VM void Output(); bool need_stack_bang(int frame_size_in_bytes) const; - bool need_register_stack_bang() const; void compute_loop_first_inst_sizes(); void install_code(ciMethod* target, diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 2f699650037..647e8515b30 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -104,9 +104,9 @@ void Parse::print_statistics() { Node *Parse::fetch_interpreter_state(int index, BasicType bt, Node* local_addrs) { - Node *mem = memory(Compile::AliasIdxRaw); - Node *adr = basic_plus_adr(top(), local_addrs, -index*wordSize); - Node *ctl = control(); + Node* mem = memory(Compile::AliasIdxRaw); + Node* adr = off_heap_plus_addr(local_addrs, -index*wordSize); + Node* ctl = control(); // Very similar to LoadNode::make, except we handle un-aligned longs and // doubles on Sparc. Intel can handle them just fine directly. @@ -120,7 +120,7 @@ Node *Parse::fetch_interpreter_state(int index, case T_DOUBLE: { // Since arguments are in reverse order, the argument address 'adr' // refers to the back half of the long/double. Recompute adr. - adr = basic_plus_adr(top(), local_addrs, -(index+1)*wordSize); + adr = off_heap_plus_addr(local_addrs, -(index+1)*wordSize); if (Matcher::misaligned_doubles_ok) { l = (bt == T_DOUBLE) ? (Node*)new LoadDNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::DOUBLE, MemNode::unordered) @@ -219,7 +219,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { // Commute monitors from interpreter frame to compiler frame. assert(jvms()->monitor_depth() == 0, "should be no active locks at beginning of osr"); int mcnt = osr_block->flow()->monitor_count(); - Node *monitors_addr = basic_plus_adr(top(), osr_buf, (max_locals+mcnt*2-1)*wordSize); + Node* monitors_addr = off_heap_plus_addr(osr_buf, (max_locals+mcnt*2-1)*wordSize); for (index = 0; index < mcnt; index++) { // Make a BoxLockNode for the monitor. BoxLockNode* osr_box = new BoxLockNode(next_monitor()); @@ -270,7 +270,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { } // Extract the needed locals from the interpreter frame. - Node *locals_addr = basic_plus_adr(top(), osr_buf, (max_locals-1)*wordSize); + Node* locals_addr = off_heap_plus_addr(osr_buf, (max_locals-1)*wordSize); // find all the locals that the interpreter thinks contain live oops const ResourceBitMap live_oops = method()->live_local_oops_at_bci(osr_bci()); @@ -2127,7 +2127,7 @@ void Parse::call_register_finalizer() { Node* klass_addr = basic_plus_adr( receiver, receiver, oopDesc::klass_offset_in_bytes() ); Node* klass = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), klass_addr, TypeInstPtr::KLASS)); - Node* access_flags_addr = basic_plus_adr(top(), klass, in_bytes(Klass::misc_flags_offset())); + Node* access_flags_addr = off_heap_plus_addr(klass, in_bytes(Klass::misc_flags_offset())); Node* access_flags = make_load(nullptr, access_flags_addr, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); Node* mask = _gvn.transform(new AndINode(access_flags, intcon(KlassFlags::_misc_has_finalizer))); @@ -2273,9 +2273,9 @@ void Parse::add_safepoint() { sfpnt->init_req(TypeFunc::FramePtr , top() ); // Create a node for the polling address - Node *polladr; - Node *thread = _gvn.transform(new ThreadLocalNode()); - Node *polling_page_load_addr = _gvn.transform(basic_plus_adr(top(), thread, in_bytes(JavaThread::polling_page_offset()))); + Node* polladr; + Node* thread = _gvn.transform(new ThreadLocalNode()); + Node* polling_page_load_addr = _gvn.transform(off_heap_plus_addr(thread, in_bytes(JavaThread::polling_page_offset()))); polladr = make_load(control(), polling_page_load_addr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered); sfpnt->init_req(TypeFunc::Parms+0, _gvn.transform(polladr)); diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index eac2b3e863a..7f41870ccea 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -966,12 +966,28 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, _max_switch_depth = 0; _est_switch_depth = log2i_graceful((hi - lo + 1) - 1) + 1; } + SwitchRange* orig_lo = lo; + SwitchRange* orig_hi = hi; #endif - assert(lo <= hi, "must be a non-empty set of ranges"); - if (lo == hi) { - jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); - } else { + // The lower-range processing is done iteratively to avoid O(N) stack depth + // when the profiling-based pivot repeatedly selects mid==lo (JDK-8366138). + // The upper-range processing remains recursive but is only reached for + // balanced splits, bounding its depth to O(log N). + // Termination: every iteration either exits or strictly decreases hi-lo: + // lo == mid && mid < hi, increments lo + // lo < mid <= hi, sets hi = mid - 1. + for (int depth = switch_depth;; depth++) { +#ifndef PRODUCT + _max_switch_depth = MAX2(depth, _max_switch_depth); +#endif + + assert(lo <= hi, "must be a non-empty set of ranges"); + if (lo == hi) { + jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); + break; + } + assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges"); assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges"); @@ -981,7 +997,12 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, float total_cnt = sum_of_cnts(lo, hi); int nr = hi - lo + 1; - if (UseSwitchProfiling) { + // With total_cnt==0 the profiling pivot degenerates to mid==lo + // (0 >= 0/2), producing a linear chain of If nodes instead of a + // balanced tree. A balanced tree is strictly better here: all paths + // are cold, so a balanced split gives fewer comparisons at runtime + // and avoids pathological memory usage in the optimizer. + if (UseSwitchProfiling && total_cnt > 0) { // Don't keep the binary search tree balanced: pick up mid point // that split frequencies in half. float cnt = 0; @@ -1002,7 +1023,7 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, assert(nr != 2 || mid == hi, "should pick higher of 2"); assert(nr != 3 || mid == hi-1, "should pick middle of 3"); } - + assert(mid != nullptr, "mid must be set"); Node *test_val = _gvn.intcon(mid == lo ? mid->hi() : mid->lo()); @@ -1025,7 +1046,7 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, Node *iffalse = _gvn.transform( new IfFalseNode(iff_lt) ); { PreserveJVMState pjvms(this); set_control(iffalse); - jump_switch_ranges(key_val, mid+1, hi, switch_depth+1); + jump_switch_ranges(key_val, mid+1, hi, depth+1); } set_control(iftrue); } @@ -1043,21 +1064,22 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, Node *iffalse = _gvn.transform( new IfFalseNode(iff_ge) ); { PreserveJVMState pjvms(this); set_control(iftrue); - jump_switch_ranges(key_val, mid == lo ? mid+1 : mid, hi, switch_depth+1); + jump_switch_ranges(key_val, mid == lo ? mid+1 : mid, hi, depth+1); } set_control(iffalse); } } - // in any case, process the lower range + // Process the lower range: iterate instead of recursing. if (mid == lo) { if (mid->is_singleton()) { - jump_switch_ranges(key_val, lo+1, hi, switch_depth+1); + lo++; } else { jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); + break; } } else { - jump_switch_ranges(key_val, lo, mid-1, switch_depth+1); + hi = mid - 1; } } @@ -1072,23 +1094,22 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, } #ifndef PRODUCT - _max_switch_depth = MAX2(switch_depth, _max_switch_depth); if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) { SwitchRange* r; int nsing = 0; - for( r = lo; r <= hi; r++ ) { + for (r = orig_lo; r <= orig_hi; r++) { if( r->is_singleton() ) nsing++; } tty->print(">>> "); _method->print_short_name(); tty->print_cr(" switch decision tree"); tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d", - (int) (hi-lo+1), nsing, _max_switch_depth, _est_switch_depth); + (int) (orig_hi-orig_lo+1), nsing, _max_switch_depth, _est_switch_depth); if (_max_switch_depth > _est_switch_depth) { tty->print_cr("******** BAD SWITCH DEPTH ********"); } tty->print(" "); - for( r = lo; r <= hi; r++ ) { + for (r = orig_lo; r <= orig_hi; r++) { r->print(); } tty->cr(); diff --git a/src/hotspot/share/opto/parseHelper.cpp b/src/hotspot/share/opto/parseHelper.cpp index 2e8fca68a8d..232f5d6c89a 100644 --- a/src/hotspot/share/opto/parseHelper.cpp +++ b/src/hotspot/share/opto/parseHelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ void Parse::array_store_check() { // Extract the array element class int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset()); - Node* p2 = basic_plus_adr(top(), array_klass, element_klass_offset); + Node* p2 = off_heap_plus_addr(array_klass, element_klass_offset); Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p2, tak)); assert(array_klass->is_Con() == a_e_klass->is_Con() || StressReflectiveCode, "a constant array type must come with a constant element type"); diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp index be92d4116b0..29961e152b3 100644 --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -31,6 +31,7 @@ #include "opto/callnode.hpp" #include "opto/castnode.hpp" #include "opto/cfgnode.hpp" +#include "opto/convertnode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" @@ -359,6 +360,16 @@ NodeHash::~NodeHash() { } #endif +// Add users of 'n' that match 'predicate' to worklist +template +static void add_users_to_worklist_if(Unique_Node_List& worklist, const Node* n, Predicate predicate) { + for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { + Node* u = n->fast_out(i); + if (predicate(u)) { + worklist.push(u); + } + } +} //============================================================================= //------------------------------PhaseRemoveUseless----------------------------- @@ -1722,11 +1733,6 @@ void PhaseIterGVN::verify_Ideal_for(Node* n, bool can_reshape) { case Op_MergeMem: return; - // URShiftINode::Ideal - // Found in tier1-3. Did not investigate further yet. - case Op_URShiftI: - return; - // CMoveINode::Ideal // Found in tier1-3. Did not investigate further yet. case Op_CMoveI: @@ -2011,40 +2017,6 @@ void PhaseIterGVN::verify_Identity_for(Node* n) { case Op_ConvI2L: return; - // MaxNode::find_identity_operation - // Finds patterns like Max(A, Max(A, B)) -> Max(A, B) - // This can be a 2-hop search, so maybe notification is not - // good enough. - // - // Found with: - // compiler/codegen/TestBooleanVect.java - // -XX:VerifyIterativeGVN=1110 - case Op_MaxL: - case Op_MinL: - case Op_MaxI: - case Op_MinI: - case Op_MaxF: - case Op_MinF: - case Op_MaxHF: - case Op_MinHF: - case Op_MaxD: - case Op_MinD: - return; - - - // AddINode::Identity - // Converts (x-y)+y to x - // Could be issue with notification - // - // Turns out AddL does the same. - // - // Found with: - // compiler/c2/Test6792161.java - // -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:VerifyIterativeGVN=1110 - case Op_AddI: - case Op_AddL: - return; - // AbsINode::Identity // Not investigated yet. case Op_AbsI: @@ -2336,12 +2308,7 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { // A Load that directly follows an InitializeNode is // going away. The Stores that follow are candidates // again to be captured by the InitializeNode. - for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) { - Node *n = in->fast_out(j); - if (n->is_Store()) { - _worklist.push(n); - } - } + add_users_to_worklist_if(_worklist, in, [](Node* n) { return n->is_Store(); }); } } // if (in != nullptr && in != C->top()) } // for (uint i = 0; i < dead->req(); i++) @@ -2594,41 +2561,52 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ auto is_boundary = [](Node* n){ return !n->is_ConstraintCast(); }; use->visit_uses(push_the_uses_to_worklist, is_boundary); } - // If changed LShift inputs, check RShift users for useless sign-ext + // If changed LShift inputs, check RShift/URShift users for + // "(X << C) >> C" sign-ext and "(X << C) >>> C" zero-ext optimizations. if (use_op == Op_LShiftI || use_op == Op_LShiftL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL) - worklist.push(u); - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || + u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); } // If changed LShift inputs, check And users for shift and mask (And) operation if (use_op == Op_LShiftI || use_op == Op_LShiftL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_AndI || u->Opcode() == Op_AndL) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_AndI || u->Opcode() == Op_AndL; + }); } // If changed AddI/SubI inputs, check CmpU for range check optimization. if (use_op == Op_AddI || use_op == Op_SubI) { + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_CmpU; + }); + } + // If changed AddI/AddL inputs, check URShift users for + // "((X << z) + Y) >>> z" optimization in URShift{I,L}Node::Ideal. + if (use_op == Op_AddI || use_op == Op_AddL) { + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); + } + // If changed LShiftI/LShiftL inputs, check AddI/AddL users for their + // URShiftI/URShiftL users for "((x << z) + y) >>> z" optimization opportunity + // (see URShiftINode::Ideal). Handles the case where the LShift input changes. + if (use_op == Op_LShiftI || use_op == Op_LShiftL) { for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_Cmp() && (u->Opcode() == Op_CmpU)) { - worklist.push(u); + Node* add = use->fast_out(i2); + if (add->Opcode() == Op_AddI || add->Opcode() == Op_AddL) { + add_users_to_worklist_if(worklist, add, [](Node* u) { + return u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); } } } // If changed AndI/AndL inputs, check RShift/URShift users for "(x & mask) >> shift" optimization opportunity if (use_op == Op_AndI || use_op == Op_AndL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || - u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || + u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); } // Check for redundant conversion patterns: // ConvD2L->ConvL2D->ConvD2L @@ -2641,15 +2619,22 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ use_op == Op_ConvI2F || use_op == Op_ConvL2F || use_op == Op_ConvF2I) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if ((use_op == Op_ConvL2D && u->Opcode() == Op_ConvD2L) || - (use_op == Op_ConvI2F && u->Opcode() == Op_ConvF2I) || - (use_op == Op_ConvL2F && u->Opcode() == Op_ConvF2L) || - (use_op == Op_ConvF2I && u->Opcode() == Op_ConvI2F)) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [=](Node* u) { + return (use_op == Op_ConvL2D && u->Opcode() == Op_ConvD2L) || + (use_op == Op_ConvI2F && u->Opcode() == Op_ConvF2I) || + (use_op == Op_ConvL2F && u->Opcode() == Op_ConvF2L) || + (use_op == Op_ConvF2I && u->Opcode() == Op_ConvI2F); + }); + } + // ConvD2F::Ideal matches ConvD2F(SqrtD(ConvF2D(x))) => SqrtF(x). + // Notify ConvD2F users of SqrtD when any input of the SqrtD changes. + if (use_op == Op_SqrtD) { + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_ConvD2F; }); + } + // ConvF2HF::Ideal matches ConvF2HF(binopF(ConvHF2F(...))) => FP16BinOp(...). + // Notify ConvF2HF users of float binary ops when any input changes. + if (Float16NodeFactory::is_float32_binary_oper(use_op)) { + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_ConvF2HF; }); } // If changed AddP inputs: // - check Stores for loop invariant, and @@ -2657,33 +2642,21 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ // address expression flattening. if (use_op == Op_AddP) { bool offset_changed = n == use->in(AddPNode::Offset); - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_Mem()) { - worklist.push(u); - } else if (offset_changed && u->is_AddP() && u->in(AddPNode::Offset)->is_Con()) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [=](Node* u) { + return u->is_Mem() || + (offset_changed && u->is_AddP() && u->in(AddPNode::Offset)->is_Con()); + }); } // Check for "abs(0-x)" into "abs(x)" conversion if (use->is_Sub()) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_AbsD || u->Opcode() == Op_AbsF || - u->Opcode() == Op_AbsL || u->Opcode() == Op_AbsI) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_AbsD || u->Opcode() == Op_AbsF || + u->Opcode() == Op_AbsL || u->Opcode() == Op_AbsI; + }); } // Check for Max/Min(A, Max/Min(B, C)) where A == B or A == C if (use->is_MinMax()) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_MinMax()) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->is_MinMax(); }); } auto enqueue_init_mem_projs = [&](ProjNode* proj) { add_users_to_worklist0(proj, worklist); @@ -2722,12 +2695,9 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ if (u->Opcode() == Op_LoadP && ut->isa_instptr()) { if (has_load_barrier_nodes) { // Search for load barriers behind the load - for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { - Node* b = u->fast_out(i3); - if (bs->is_gc_barrier_node(b)) { - worklist.push(b); - } - } + add_users_to_worklist_if(worklist, u, [&](Node* b) { + return bs->is_gc_barrier_node(b); + }); } worklist.push(u); } @@ -2740,17 +2710,17 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ worklist.push(cmp); } } + // VectorMaskToLongNode::Ideal_MaskAll looks through VectorStoreMask + // to fold constant masks. + if (use_op == Op_VectorStoreMask) { + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_VectorMaskToLong; }); + } // From CastX2PNode::Ideal // CastX2P(AddX(x, y)) // CastX2P(SubX(x, y)) if (use->Opcode() == Op_AddX || use->Opcode() == Op_SubX) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_CastX2P) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_CastX2P; }); } /* AndNode has a special handling when one of the operands is a LShiftNode: @@ -2780,6 +2750,13 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ }; use->visit_uses(push_and_to_worklist, is_boundary); } + + // If changed Sub inputs, check Add for identity. + // e.g., (x - y) + y -> x; x + (y - x) -> y. + if (use_op == Op_SubI || use_op == Op_SubL) { + const int add_op = (use_op == Op_SubI) ? Op_AddI : Op_AddL; + add_users_to_worklist_if(worklist, use, [=](Node* u) { return u->Opcode() == add_op; }); + } } /** @@ -2796,37 +2773,6 @@ void PhaseIterGVN::remove_speculative_types() { _table.check_no_speculative_types(); } -// Check if the type of a divisor of a Div or Mod node includes zero. -bool PhaseIterGVN::no_dependent_zero_check(Node* n) const { - switch (n->Opcode()) { - case Op_DivI: - case Op_ModI: - case Op_UDivI: - case Op_UModI: { - // Type of divisor includes 0? - if (type(n->in(2)) == Type::TOP) { - // 'n' is dead. Treat as if zero check is still there to avoid any further optimizations. - return false; - } - const TypeInt* type_divisor = type(n->in(2))->is_int(); - return (type_divisor->_hi < 0 || type_divisor->_lo > 0); - } - case Op_DivL: - case Op_ModL: - case Op_UDivL: - case Op_UModL: { - // Type of divisor includes 0? - if (type(n->in(2)) == Type::TOP) { - // 'n' is dead. Treat as if zero check is still there to avoid any further optimizations. - return false; - } - const TypeLong* type_divisor = type(n->in(2))->is_long(); - return (type_divisor->_hi < 0 || type_divisor->_lo > 0); - } - } - return true; -} - //============================================================================= #ifndef PRODUCT uint PhaseCCP::_total_invokes = 0; @@ -2994,6 +2940,10 @@ void PhaseCCP::dump_type_and_node(const Node* n, const Type* t) { } #endif +bool PhaseCCP::not_bottom_type(Node* n) const { + return n->bottom_type() != type(n); +} + // We need to propagate the type change of 'n' to all its uses. Depending on the kind of node, additional nodes // (grandchildren or even further down) need to be revisited as their types could also be improved as a result // of the new type of 'n'. Push these nodes to the worklist. @@ -3006,7 +2956,7 @@ void PhaseCCP::push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) } void PhaseCCP::push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const { - if (n->bottom_type() != type(n)) { + if (not_bottom_type(n)) { worklist.push(n); } } @@ -3029,9 +2979,9 @@ void PhaseCCP::push_more_uses(Unique_Node_List& worklist, Node* parent, const No // We must recheck Phis too if use is a Region. void PhaseCCP::push_phis(Unique_Node_List& worklist, const Node* use) const { if (use->is_Region()) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - push_if_not_bottom_type(worklist, use->fast_out(i)); - } + add_users_to_worklist_if(worklist, use, [&](Node* u) { + return not_bottom_type(u); + }); } } @@ -3058,14 +3008,11 @@ void PhaseCCP::push_catch(Unique_Node_List& worklist, const Node* use) { void PhaseCCP::push_cmpu(Unique_Node_List& worklist, const Node* use) const { uint use_op = use->Opcode(); if (use_op == Op_AddI || use_op == Op_SubI) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* cmpu = use->fast_out(i); - const uint cmpu_opcode = cmpu->Opcode(); - if (cmpu_opcode == Op_CmpU || cmpu_opcode == Op_CmpU3) { - // Got a CmpU or CmpU3 which might need the new type information from node n. - push_if_not_bottom_type(worklist, cmpu); - } - } + // Got a CmpU or CmpU3 which might need the new type information from node n. + add_users_to_worklist_if(worklist, use, [&](Node* u) { + uint op = u->Opcode(); + return (op == Op_CmpU || op == Op_CmpU3) && not_bottom_type(u); + }); } } @@ -3154,12 +3101,9 @@ void PhaseCCP::push_loadp(Unique_Node_List& worklist, const Node* use) const { } void PhaseCCP::push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* barrier_node = use->fast_out(i); - if (barrier_set->is_gc_barrier_node(barrier_node)) { - worklist.push(barrier_node); - } - } + add_users_to_worklist_if(worklist, use, [&](Node* u) { + return barrier_set->is_gc_barrier_node(u); + }); } // AndI/L::Value() optimizes patterns similar to (v << 2) & 3, or CON & 3 to zero if they are bitwise disjoint. @@ -3195,12 +3139,9 @@ void PhaseCCP::push_and(Unique_Node_List& worklist, const Node* parent, const No void PhaseCCP::push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const { if (use->Opcode() == Op_CmpI && use->in(2) == parent) { Node* other_cmp_input = use->in(1); - for (DUIterator_Fast imax, i = other_cmp_input->fast_outs(imax); i < imax; i++) { - Node* cast_ii = other_cmp_input->fast_out(i); - if (cast_ii->is_CastII()) { - push_if_not_bottom_type(worklist, cast_ii); - } - } + add_users_to_worklist_if(worklist, other_cmp_input, [&](Node* u) { + return u->is_CastII() && not_bottom_type(u); + }); } } diff --git a/src/hotspot/share/opto/phaseX.hpp b/src/hotspot/share/opto/phaseX.hpp index cc0d47bd634..94890c250c4 100644 --- a/src/hotspot/share/opto/phaseX.hpp +++ b/src/hotspot/share/opto/phaseX.hpp @@ -604,7 +604,6 @@ public: } bool is_dominator(Node *d, Node *n) { return is_dominator_helper(d, n, false); } - bool no_dependent_zero_check(Node* n) const; #ifndef PRODUCT static bool is_verify_def_use() { @@ -653,6 +652,7 @@ class PhaseCCP : public PhaseIterGVN { Node* fetch_next_node(Unique_Node_List& worklist); static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN; + bool not_bottom_type(Node* n) const; void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const; void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const; void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const; diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index f388dc6cdc6..ce432fbfc01 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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,6 +25,7 @@ #ifndef SHARE_OPTO_PHASETYPE_HPP #define SHARE_OPTO_PHASETYPE_HPP +#include "memory/allocation.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/stringUtils.hpp" diff --git a/src/hotspot/share/opto/rangeinference.hpp b/src/hotspot/share/opto/rangeinference.hpp index 66ea741a2da..7c0f12f6ef7 100644 --- a/src/hotspot/share/opto/rangeinference.hpp +++ b/src/hotspot/share/opto/rangeinference.hpp @@ -28,6 +28,7 @@ #include "cppstdlib/limits.hpp" #include "cppstdlib/type_traits.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/intn_t.hpp" class outputStream; class Type; @@ -407,6 +408,40 @@ public: return TypeIntMirror, U>::make(TypeIntPrototype, U>{{lo, hi}, {ulo, uhi}, {zeros, ones}}); }); } + + // Compute `known_bits` by shifting known bits of `t1` left and setting the + // low `shift` bits to zeros. Also update the signed and unsigned ranges when + // the shift operation does not cause an overflow. The caller is responsible + // for normalizing the shift amount (i.e. masking with 31 for ints or 63 for + // longs). + template + static CTP infer_lshift(CTP t1, int masked_shift) { + assert(masked_shift >= 0 && + masked_shift < HotSpotNumerics::type_width>(), + "shift is out of range"); + + U pattern = (U(1) << masked_shift) - U(1); + U known_one_bits = t1->_bits._ones << masked_shift; + U known_zero_bits = (t1->_bits._zeros << masked_shift) | pattern; + KnownBits> known_bits{known_zero_bits, known_one_bits}; + + S shifted_slo = S(U(t1->_lo) << masked_shift); + S shifted_shi = S(U(t1->_hi) << masked_shift); + bool s_overflow = (shifted_slo >> masked_shift) != t1->_lo || + (shifted_shi >> masked_shift) != t1->_hi; + S slo = s_overflow ? std::numeric_limits>::min() : shifted_slo; + S shi = s_overflow ? std::numeric_limits>::max() : shifted_shi; + + U shifted_ulo = t1->_ulo << masked_shift; + U shifted_uhi = t1->_uhi << masked_shift; + bool u_overflow = (shifted_ulo >> masked_shift) != t1->_ulo || + (shifted_uhi >> masked_shift) != t1->_uhi; + U ulo = u_overflow ? std::numeric_limits>::min() : shifted_ulo; + U uhi = u_overflow ? std::numeric_limits>::max() : shifted_uhi; + + TypeIntPrototype, U> proto{{slo, shi}, {ulo, uhi}, known_bits}; + return CT::make(proto, t1->_widen); + } }; #endif // SHARE_OPTO_RANGEINFERENCE_HPP diff --git a/src/hotspot/share/opto/rootnode.hpp b/src/hotspot/share/opto/rootnode.hpp index 3838578b4db..76f0ec440a9 100644 --- a/src/hotspot/share/opto/rootnode.hpp +++ b/src/hotspot/share/opto/rootnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -63,7 +63,6 @@ public: virtual const Type *bottom_type() const; virtual bool is_CFG() const { return true; } virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash - virtual bool depends_only_on_test() const { return false; } virtual const Node *is_block_proj() const { return this; } virtual const RegMask &out_RegMask() const; virtual uint ideal_reg() const { return NotAMachineReg; } diff --git a/src/hotspot/share/opto/split_if.cpp b/src/hotspot/share/opto/split_if.cpp index de9ddb60b0c..91595c57a10 100644 --- a/src/hotspot/share/opto/split_if.cpp +++ b/src/hotspot/share/opto/split_if.cpp @@ -29,6 +29,7 @@ #include "opto/movenode.hpp" #include "opto/node.hpp" #include "opto/opaquenode.hpp" +#include "opto/opcodes.hpp" #include "opto/predicates.hpp" //------------------------------split_thru_region------------------------------ @@ -37,6 +38,11 @@ RegionNode* PhaseIdealLoop::split_thru_region(Node* n, RegionNode* region) { assert(n->is_CFG(), ""); RegionNode* r = new RegionNode(region->req()); IdealLoopTree* loop = get_loop(n); +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Splitting %d %s through %d %s", n->_idx, n->Name(), region->_idx, region->Name()); + } +#endif for (uint i = 1; i < region->req(); i++) { Node* x = n->clone(); Node* in0 = n->in(0); @@ -144,6 +150,11 @@ bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) { } // Now actually split-up this guy. One copy per control path merging. +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Splitting up: %d %s", n->_idx, n->Name()); + } +#endif Node *phi = PhiNode::make_blank(blk1, n); for( uint j = 1; j < blk1->req(); j++ ) { Node *x = n->clone(); @@ -184,6 +195,11 @@ bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) { // AddP and CheckCastPP have the same obj input after split if. bool PhaseIdealLoop::clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2) { if (n->Opcode() == Op_AddP && at_relevant_ctrl(n, blk1, blk2)) { +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Cloning down (LoadKlass): %d %s", n->_idx, n->Name()); + } +#endif Node_List cmp_nodes; uint old = C->unique(); for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { @@ -300,6 +316,11 @@ bool PhaseIdealLoop::clone_cmp_down(Node* n, const Node* blk1, const Node* blk2) at_relevant_ctrl(cmov, blk1, blk2)))) { // Must clone down +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Cloning down (Cmp): %d %s", n->_idx, n->Name()); + } +#endif if (!n->is_FastLock()) { // Clone down any block-local BoolNode uses of this CmpNode for (DUIterator i = n->outs(); n->has_out(i); i++) { @@ -400,6 +421,12 @@ void PhaseIdealLoop::clone_template_assertion_expression_down(Node* node) { return; } +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Cloning down (Template Assertion Expression): %d %s", node->_idx, node->Name()); + } +#endif + TemplateAssertionExpressionNode template_assertion_expression_node(node); auto clone_expression = [&](IfNode* template_assertion_predicate) { OpaqueTemplateAssertionPredicateNode* opaque_node = @@ -458,6 +485,11 @@ Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, No Node *phi_post; if( prior_n == new_false || prior_n == new_true ) { phi_post = def->clone(); +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Spinup: cloning def to sink: %d %s -> %d %s", def->_idx, def->Name(), phi_post->_idx, phi_post->Name()); + } +#endif phi_post->set_req(0, prior_n ); register_new_node(phi_post, prior_n); } else { @@ -471,6 +503,11 @@ Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, No } else { assert( def->is_Phi(), "" ); assert( prior_n->is_Region(), "must be a post-dominating merge point" ); +#ifndef PRODUCT + if (TraceSplitIf) { + tty->print_cr(" Spinup: creating new Phi for merge: %d %s", def->_idx, def->Name()); + } +#endif // Need a Phi here phi_post = PhiNode::make_blank(prior_n, def); @@ -716,14 +753,11 @@ void PhaseIdealLoop::do_split_if(Node* iff, RegionNode** new_false_region, Regio } // End of while merge point has phis _igvn.remove_dead_node(region); - if (iff->Opcode() == Op_RangeCheck) { - // Pin array access nodes: control is updated here to a region. If, after some transformations, only one path - // into the region is left, an array load could become dependent on a condition that's not a range check for - // that access. If that condition is replaced by an identical dominating one, then an unpinned load would risk - // floating above its range check. - pin_array_access_nodes_dependent_on(new_true); - pin_array_access_nodes_dependent_on(new_false); - } + + // Control is updated here to a region, which is not a test, so any node that + // depends_only_on_test must be pinned + pin_nodes_dependent_on(new_true, iff->Opcode() == Op_RangeCheck); + pin_nodes_dependent_on(new_false, iff->Opcode() == Op_RangeCheck); if (new_false_region != nullptr) { *new_false_region = new_false; @@ -735,13 +769,22 @@ void PhaseIdealLoop::do_split_if(Node* iff, RegionNode** new_false_region, Regio DEBUG_ONLY( if (VerifyLoopOptimizations) { verify(); } ); } -void PhaseIdealLoop::pin_array_access_nodes_dependent_on(Node* ctrl) { +void PhaseIdealLoop::pin_nodes_dependent_on(Node* ctrl, bool old_iff_is_rangecheck) { for (DUIterator i = ctrl->outs(); ctrl->has_out(i); i++) { Node* use = ctrl->out(i); if (!use->depends_only_on_test()) { continue; } - Node* pinned_clone = use->pin_array_access_node(); + + + // When a RangeCheckNode is folded because its condition is a constant, IfProjNode::Identity + // returns the control input of the RangeCheckNode. As a result, when the old IfNode is not a + // RangeCheckNode, and a Load output of it depends_only_on_test, we don't need to pin the Load. + if (use->is_Load() && !old_iff_is_rangecheck) { + continue; + } + + Node* pinned_clone = use->pin_node_under_control(); if (pinned_clone != nullptr) { register_new_node_with_ctrl_of(pinned_clone, use); _igvn.replace_node(use, pinned_clone); diff --git a/src/hotspot/share/opto/subnode.hpp b/src/hotspot/share/opto/subnode.hpp index 463d9e020cb..54cb1d20cd0 100644 --- a/src/hotspot/share/opto/subnode.hpp +++ b/src/hotspot/share/opto/subnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -507,6 +507,9 @@ public: virtual int Opcode() const; const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; @@ -522,6 +525,9 @@ public: const Type *bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } virtual const Type* Value(PhaseGVN* phase) const; + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------SqrtFNode-------------------------------------- @@ -541,6 +547,9 @@ public: const Type *bottom_type() const { return Type::FLOAT; } virtual uint ideal_reg() const { return Op_RegF; } virtual const Type* Value(PhaseGVN* phase) const; + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; //------------------------------SqrtHFNode------------------------------------- @@ -555,6 +564,9 @@ public: const Type* bottom_type() const { return Type::HALF_FLOAT; } virtual uint ideal_reg() const { return Op_RegF; } virtual const Type* Value(PhaseGVN* phase) const; + +private: + virtual bool depends_only_on_test_impl() const { return false; } }; diff --git a/src/hotspot/share/opto/subtypenode.cpp b/src/hotspot/share/opto/subtypenode.cpp index 8e4c7d829a7..69b7058d053 100644 --- a/src/hotspot/share/opto/subtypenode.cpp +++ b/src/hotspot/share/opto/subtypenode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -182,7 +182,7 @@ bool SubTypeCheckNode::verify(PhaseGVN* phase) { return verify_helper(phase, load_klass(phase), cached_t); } case Compile::SSC_full_test: { - Node* p1 = phase->transform(new AddPNode(C->top(), superklass, phase->MakeConX(in_bytes(Klass::super_check_offset_offset())))); + Node* p1 = phase->transform(AddPNode::make_off_heap(superklass, phase->MakeConX(in_bytes(Klass::super_check_offset_offset())))); Node* chk_off = phase->transform(new LoadINode(nullptr, C->immutable_memory(), p1, phase->type(p1)->is_ptr(), TypeInt::INT, MemNode::unordered)); record_for_cleanup(chk_off, phase); @@ -194,7 +194,7 @@ bool SubTypeCheckNode::verify(PhaseGVN* phase) { #ifdef _LP64 chk_off_X = phase->transform(new ConvI2LNode(chk_off_X)); #endif - Node* p2 = phase->transform(new AddPNode(C->top(), subklass, chk_off_X)); + Node* p2 = phase->transform(AddPNode::make_off_heap(subklass, chk_off_X)); Node* nkls = phase->transform(LoadKlassNode::make(*phase, C->immutable_memory(), p2, phase->type(p2)->is_ptr(), TypeInstKlassPtr::OBJECT_OR_NULL)); return verify_helper(phase, nkls, cached_t); @@ -217,7 +217,7 @@ Node* SubTypeCheckNode::load_klass(PhaseGVN* phase) const { const Type* sub_t = phase->type(obj_or_subklass); Node* subklass = nullptr; if (sub_t->isa_oopptr()) { - Node* adr = phase->transform(new AddPNode(obj_or_subklass, obj_or_subklass, phase->MakeConX(oopDesc::klass_offset_in_bytes()))); + Node* adr = phase->transform(AddPNode::make_with_base(obj_or_subklass, phase->MakeConX(oopDesc::klass_offset_in_bytes()))); subklass = phase->transform(LoadKlassNode::make(*phase, phase->C->immutable_memory(), adr, TypeInstPtr::KLASS)); record_for_cleanup(subklass, phase); } else { diff --git a/src/hotspot/share/opto/subtypenode.hpp b/src/hotspot/share/opto/subtypenode.hpp index abf9cad4844..2dac3866209 100644 --- a/src/hotspot/share/opto/subtypenode.hpp +++ b/src/hotspot/share/opto/subtypenode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,6 @@ public: virtual int Opcode() const; const Type* bottom_type() const { return TypeInt::CC; } - bool depends_only_on_test() const { return false; } ciMethod* method() const { return _method; } int bci() const { return _bci; } @@ -71,6 +70,8 @@ private: static bool is_oop(PhaseGVN* phase, Node* n); Node* load_klass(PhaseGVN* phase) const; + + virtual bool depends_only_on_test_impl() const { return false; } #endif // ASSERT }; diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index 31cc8fa0460..d878b2b1d3d 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -2214,7 +2214,7 @@ bool SuperWord::is_vector_use(Node* use, int u_idx) const { return true; } - if (!is_velt_basic_type_compatible_use_def(use, def)) { + if (!is_velt_basic_type_compatible_use_def(use, def, d_pk->size())) { return false; } @@ -2280,7 +2280,7 @@ Node_List* PackSet::strided_pack_input_at_index_or_null(const Node_List* pack, c // Check if the output type of def is compatible with the input type of use, i.e. if the // types have the same size. -bool SuperWord::is_velt_basic_type_compatible_use_def(Node* use, Node* def) const { +bool SuperWord::is_velt_basic_type_compatible_use_def(Node* use, Node* def, const uint pack_size) const { assert(in_bb(def) && in_bb(use), "both use and def are in loop"); // Conversions are trivially compatible. @@ -2306,8 +2306,17 @@ bool SuperWord::is_velt_basic_type_compatible_use_def(Node* use, Node* def) cons type2aelembytes(use_bt) == 4; } - // Default case: input size of use equals output size of def. - return type2aelembytes(use_bt) == type2aelembytes(def_bt); + // Input size of use equals output size of def + if (type2aelembytes(use_bt) == type2aelembytes(def_bt)) { + return true; + } + + // Subword cast: Element sizes differ, but the platform supports a cast to change the def shape to the use shape. + if (VectorCastNode::is_supported_subword_cast(def_bt, use_bt, pack_size)) { + return true; + } + + return false; } // Return nullptr if success, else failure message diff --git a/src/hotspot/share/opto/superword.hpp b/src/hotspot/share/opto/superword.hpp index 9654465220b..4e6fce70e5c 100644 --- a/src/hotspot/share/opto/superword.hpp +++ b/src/hotspot/share/opto/superword.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, 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 @@ -653,7 +653,7 @@ private: // Is use->in(u_idx) a vector use? bool is_vector_use(Node* use, int u_idx) const; - bool is_velt_basic_type_compatible_use_def(Node* use, Node* def) const; + bool is_velt_basic_type_compatible_use_def(Node* use, Node* def, const uint pack_size) const; bool do_vtransform() const; }; diff --git a/src/hotspot/share/opto/superwordVTransformBuilder.cpp b/src/hotspot/share/opto/superwordVTransformBuilder.cpp index 832e91603d9..f8b8bfe2ed0 100644 --- a/src/hotspot/share/opto/superwordVTransformBuilder.cpp +++ b/src/hotspot/share/opto/superwordVTransformBuilder.cpp @@ -254,6 +254,20 @@ VTransformNode* SuperWordVTransformBuilder::get_or_make_vtnode_vector_input_at_i Node_List* pack_in = _packset.pack_input_at_index_or_null(pack, index); if (pack_in != nullptr) { + Node* in_p0 = pack_in->at(0); + BasicType def_bt = _vloop_analyzer.types().velt_basic_type(in_p0); + BasicType use_bt = _vloop_analyzer.types().velt_basic_type(p0); + + // If the use and def types are different, emit a cast node + if (use_bt != def_bt && !p0->is_Convert() && VectorCastNode::is_supported_subword_cast(def_bt, use_bt, pack->size())) { + VTransformNode* in = get_vtnode(pack_in->at(0)); + const VTransformVectorNodeProperties properties = VTransformVectorNodeProperties::make_from_pack(pack, _vloop_analyzer); + VTransformNode* cast = new (_vtransform.arena()) VTransformElementWiseVectorNode(_vtransform, 2, properties, VectorCastNode::opcode(-1, def_bt)); + cast->set_req(1, in); + + return cast; + } + // Input is a matching pack -> vtnode already exists. assert(index != 2 || !VectorNode::is_shift(p0), "shift's count cannot be vector"); return get_vtnode(pack_in->at(0)); diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp index c637737eef9..308ec819773 100644 --- a/src/hotspot/share/opto/type.cpp +++ b/src/hotspot/share/opto/type.cpp @@ -49,6 +49,9 @@ #include "utilities/ostream.hpp" #include "utilities/powerOfTwo.hpp" #include "utilities/stringUtils.hpp" +#if INCLUDE_SHENANDOAHGC +#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" +#endif // INCLUDE_SHENANDOAHGC // Portions of code courtesy of Clifford Click @@ -97,7 +100,7 @@ const Type::TypeInfo Type::_type_info[Type::lastype] = { { Bad, T_ILLEGAL, "vectorz:", false, Op_VecZ, relocInfo::none }, // VectorZ #endif { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr - { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr + { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::external_word_type }, // RawPtr { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr @@ -732,6 +735,11 @@ void Type::Initialize_shared(Compile* current) { mreg2type[Op_VecY] = TypeVect::VECTY; mreg2type[Op_VecZ] = TypeVect::VECTZ; +#if INCLUDE_SHENANDOAHGC + ShenandoahBarrierSetC2::init(); +#endif //INCLUDE_SHENANDOAHGC + + BarrierSetC2::make_clone_type(); LockNode::initialize_lock_Type(); ArrayCopyNode::initialize_arraycopy_Type(); OptoRuntime::initialize_types(); @@ -3481,7 +3489,7 @@ TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* inter #ifdef _LP64 if (_offset > 0 || _offset == Type::OffsetTop || _offset == Type::OffsetBot) { if (_offset == oopDesc::klass_offset_in_bytes()) { - _is_ptr_to_narrowklass = UseCompressedClassPointers; + _is_ptr_to_narrowklass = true; } else if (klass() == nullptr) { // Array with unknown body type assert(this->isa_aryptr(), "only arrays without klass"); diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 9df10fefdd1..7fc06db4b78 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -42,7 +42,7 @@ static bool check_vbox(const TypeInstPtr* vbox_type) { ciInstanceKlass* ik = vbox_type->instance_klass(); assert(is_vector(ik), "not a vector"); - ciField* fd1 = ik->get_field_by_name(ciSymbols::ETYPE_name(), ciSymbols::class_signature(), /* is_static */ true); + ciField* fd1 = ik->get_field_by_name(ciSymbols::CTYPE_name(), ciSymbols::class_signature(), /* is_static */ true); assert(fd1 != nullptr, "element type info is missing"); ciConstant val1 = fd1->constant_value(); @@ -301,9 +301,9 @@ static bool is_primitive_lane_type(VectorSupport::LaneType laneType) { return laneType >= VectorSupport::LT_FLOAT && laneType <= VectorSupport::LT_LONG; } -static BasicType get_vector_primitive_lane_type(VectorSupport::LaneType lane_type) { - assert(is_primitive_lane_type(lane_type), ""); - switch (lane_type) { +static BasicType get_vector_primitive_lane_type(VectorSupport::LaneType lanetype) { + assert(is_primitive_lane_type(lanetype), ""); + switch (lanetype) { case VectorSupport::LaneType::LT_FLOAT: return T_FLOAT; case VectorSupport::LaneType::LT_DOUBLE: return T_DOUBLE; case VectorSupport::LaneType::LT_LONG: return T_LONG; diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index ba88ae9496f..6012bdef86e 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -1561,6 +1561,13 @@ bool VectorCastNode::implemented(int opc, uint vlen, BasicType src_type, BasicTy return false; } +bool VectorCastNode::is_supported_subword_cast(BasicType def_bt, BasicType use_bt, const uint pack_size) { + assert(def_bt != use_bt, "use and def types must be different"); + + // Opcode is only required to disambiguate half float, so we pass -1 as it can't be encountered here. + return (is_subword_type(def_bt) || is_subword_type(use_bt)) && VectorCastNode::implemented(-1, pack_size, def_bt, use_bt); +} + Node* VectorCastNode::Identity(PhaseGVN* phase) { if (!in(1)->is_top()) { BasicType in_bt = in(1)->bottom_type()->is_vect()->element_basic_type(); @@ -2013,26 +2020,21 @@ Node* VectorLongToMaskNode::Ideal(PhaseGVN* phase, bool can_reshape) { uint vlen = dst_type->length(); const TypeVectMask* is_mask = dst_type->isa_vectmask(); + // Pattern: (VectorLongToMask (AndL (VectorMaskToLong src) mask)) + // Replace with: (VectorMaskCast src) + // The cast is needed if there are different mask types, and can be folded otherwise. + // The mask has exactly the vlen first bits on: mask = (2 << vlen - 1) if (in(1)->Opcode() == Op_AndL && in(1)->in(1)->Opcode() == Op_VectorMaskToLong && in(1)->in(2)->bottom_type()->isa_long() && in(1)->in(2)->bottom_type()->is_long()->is_con() && - in(1)->in(2)->bottom_type()->is_long()->get_con() == ((1L << vlen) - 1)) { - // Different src/dst mask length represents a re-interpretation operation, - // we can however generate a mask casting operation if length matches. - Node* src = in(1)->in(1)->in(1); - if (is_mask == nullptr) { - if (src->Opcode() != Op_VectorStoreMask) { - return nullptr; - } - src = src->in(1); - } - const TypeVect* src_type = src->bottom_type()->is_vect(); - if (src_type->length() == vlen && - ((src_type->isa_vectmask() == nullptr && is_mask == nullptr) || - (src_type->isa_vectmask() && is_mask))) { - return new VectorMaskCastNode(src, dst_type); - } + in(1)->in(2)->bottom_type()->is_long()->get_con() == ((1LL << vlen) - 1)) { + Node* src = in(1)->in(1)->in(1); + const TypeVect* src_type = src->bottom_type()->is_vect(); + if (src_type->length() == vlen && + ((src_type->isa_vectmask() == nullptr) == (is_mask == nullptr))) { + return new VectorMaskCastNode(src, dst_type); + } } // VectorLongToMask(-1/0) => MaskAll(-1/0) diff --git a/src/hotspot/share/opto/vectornode.hpp b/src/hotspot/share/opto/vectornode.hpp index edbceb30635..dce43f92905 100644 --- a/src/hotspot/share/opto/vectornode.hpp +++ b/src/hotspot/share/opto/vectornode.hpp @@ -1798,13 +1798,23 @@ class VectorStoreMaskNode : public VectorNode { static VectorStoreMaskNode* make(PhaseGVN& gvn, Node* in, BasicType in_type, uint num_elem); }; -// Lane-wise type cast a vector mask to the given vector type. The vector length -// of the input and output must be the same. +// Lane-wise type cast a vector mask to the given vector type. +// The vector length of the input and output must be the same. +// We can only cast between: +// - BVectMask and BVectMask (0x00/0x01) +// - NVectMask and NVectMask (0x0..0/0xF..F of different bit lengths) +// - PVectMask and PVectMask (specialized predicate/mask registers) +// Casting N/PVectMask <-> BVectMask needs to be done by +// VectorStoreMask and VectorLoadMask. class VectorMaskCastNode : public VectorNode { public: VectorMaskCastNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { const TypeVect* in_vt = in->bottom_type()->is_vect(); assert(in_vt->length() == vt->length(), "vector length must match"); + assert((in_vt->element_basic_type() == T_BOOLEAN) == (vt->element_basic_type() == T_BOOLEAN), + "Cast from/to BVectMask not allowed, use VectorLoadMask/VectorStoreMask instead"); + assert((in_vt->isa_vectmask() == nullptr) == (vt->isa_vectmask() == nullptr), + "Both BVectMask, or both NVectMask, or both PVectMask"); } Node* Identity(PhaseGVN* phase); virtual int Opcode() const; @@ -1846,6 +1856,7 @@ class VectorCastNode : public VectorNode { static VectorNode* make(int vopc, Node* n1, BasicType bt, uint vlen); static int opcode(int opc, BasicType bt, bool is_signed = true); static bool implemented(int opc, uint vlen, BasicType src_type, BasicType dst_type); + static bool is_supported_subword_cast(BasicType def_bt, BasicType use_bt, const uint pack_size); virtual Node* Identity(PhaseGVN* phase); }; diff --git a/src/hotspot/share/opto/vtransform.hpp b/src/hotspot/share/opto/vtransform.hpp index b60c71945e1..2c535eca6d1 100644 --- a/src/hotspot/share/opto/vtransform.hpp +++ b/src/hotspot/share/opto/vtransform.hpp @@ -975,4 +975,5 @@ public: virtual VTransformApplyResult apply(VTransformApplyState& apply_state) const override; NOT_PRODUCT(virtual const char* name() const override { return "StoreVector"; };) }; + #endif // SHARE_OPTO_VTRANSFORM_HPP diff --git a/src/hotspot/share/prims/downcallLinker.cpp b/src/hotspot/share/prims/downcallLinker.cpp index 5dde825d75f..cbef9841652 100644 --- a/src/hotspot/share/prims/downcallLinker.cpp +++ b/src/hotspot/share/prims/downcallLinker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,15 +30,34 @@ #include #endif +// keep in synch with jdk.internal.foreign.abi.CapturableState +enum PreservableValues { + NONE = 0, + GET_LAST_ERROR = 1, + WSA_GET_LAST_ERROR = 1 << 1, + ERRNO = 1 << 2 +}; + +// We call this from _thread_in_native, right before a downcall +JVM_LEAF(void, DowncallLinker::capture_state_pre(int32_t* value_ptr, int captured_state_mask)) +#ifdef _WIN64 + if (captured_state_mask & GET_LAST_ERROR) { + SetLastError(*value_ptr); + } + value_ptr++; + if (captured_state_mask & WSA_GET_LAST_ERROR) { + WSASetLastError(*value_ptr); + *value_ptr = WSAGetLastError(); + } + value_ptr++; +#endif + if (captured_state_mask & ERRNO) { + errno = *value_ptr; + } +JVM_END + // We call this from _thread_in_native, right after a downcall -JVM_LEAF(void, DowncallLinker::capture_state(int32_t* value_ptr, int captured_state_mask)) - // keep in synch with jdk.internal.foreign.abi.CapturableState - enum PreservableValues { - NONE = 0, - GET_LAST_ERROR = 1, - WSA_GET_LAST_ERROR = 1 << 1, - ERRNO = 1 << 2 - }; +JVM_LEAF(void, DowncallLinker::capture_state_post(int32_t* value_ptr, int captured_state_mask)) #ifdef _WIN64 if (captured_state_mask & GET_LAST_ERROR) { *value_ptr = GetLastError(); diff --git a/src/hotspot/share/prims/downcallLinker.hpp b/src/hotspot/share/prims/downcallLinker.hpp index 01ee5c56776..2c2cf053033 100644 --- a/src/hotspot/share/prims/downcallLinker.hpp +++ b/src/hotspot/share/prims/downcallLinker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,8 +41,9 @@ public: int captured_state_mask, bool needs_transition); - // This is defined as JVM_LEAF which adds the JNICALL modifier. - static void JNICALL capture_state(int32_t* value_ptr, int captured_state_mask); + // These are defined as JVM_LEAF which adds the JNICALL modifier. + static void JNICALL capture_state_pre(int32_t* value_ptr, int captured_state_mask); + static void JNICALL capture_state_post(int32_t* value_ptr, int captured_state_mask); class StubGenerator : public StubCodeGenerator { BasicType* _signature; diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 2297ce9b790..85207fddf29 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2024 Red Hat, Inc. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -3129,16 +3129,21 @@ JNI_END JNI_ENTRY(jobject, jni_GetModule(JNIEnv* env, jclass clazz)) - return Modules::get_module(clazz, THREAD); + HOTSPOT_JNI_GETMODULE_ENTRY(env, clazz); + jobject ret = Modules::get_module(clazz, THREAD); + HOTSPOT_JNI_GETMODULE_RETURN(ret); + return ret; JNI_END JNI_ENTRY(jboolean, jni_IsVirtualThread(JNIEnv* env, jobject obj)) + HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY(env, obj); + jboolean ret = JNI_FALSE; oop thread_obj = JNIHandles::resolve_external_guard(obj); if (thread_obj != nullptr && thread_obj->is_a(vmClasses::BaseVirtualThread_klass())) { - return JNI_TRUE; - } else { - return JNI_FALSE; + ret = JNI_TRUE; } + HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN(ret); + return ret; JNI_END diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 2b3a2966c27..423e1a5a1f4 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -3641,7 +3641,9 @@ JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env)) int index = 0; for (int j = 0; j < num_flags; j++, index++) { - Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL); + stringStream prefixed; + prefixed.print("-XX:%s", vm_flags[j]); + Handle h = java_lang_String::create_from_platform_dependent_str(prefixed.base(), CHECK_NULL); result_h->obj_at_put(index, h()); } for (int i = 0; i < num_args; i++, index++) { diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index e0863c07f4f..9c5abdf790b 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -1077,11 +1077,19 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list JvmtiVTSuspender::register_vthread_resume(thread_oop); } } + // Restore resumed state for current thread if it is virtual. + // It must be suspended in the suspend_thread call out of disabler context. + oop cur_oop = self_tobj(); + if (cur_oop != nullptr) { + assert(JvmtiVTSuspender::is_vthread_suspended(cur_oop), "sanity check"); + JvmtiVTSuspender::register_vthread_resume(cur_oop); + } } // Self suspend after all other suspends if necessary. // Do not use MountUnmountDisabler in context of self suspend to avoid deadlocks. if (self_tobj() != nullptr) { - suspend_thread(self_tobj(), current, /* single_suspend */ false); + // Register current vthread as suspended with the suspend_thread call. + suspend_thread(self_tobj(), current, /* single_suspend */ true); } return JVMTI_ERROR_NONE; } /* end SuspendAllVirtualThreads */ diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 4894a4dd21a..886c2da1dee 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -1529,7 +1529,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec GrowableArray* wantList = nullptr; ObjectMonitor* mon = mark.has_monitor() - ? ObjectSynchronizer::read_monitor(current_thread, hobj(), mark) + ? ObjectSynchronizer::read_monitor(hobj(), mark) : nullptr; if (mon != nullptr) { @@ -2491,7 +2491,7 @@ SetOrClearFramePopClosure::do_thread(Thread *target) { _result = JVMTI_ERROR_NO_MORE_FRAMES; return; } - assert(_state->get_thread_or_saved() == java_thread, "Must be"); + assert(_state->get_thread() == java_thread, "Must be"); RegisterMap reg_map(java_thread, RegisterMap::UpdateMap::include, diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp index 571c4ca5528..303923076b1 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -151,11 +151,6 @@ bool JvmtiEnvThreadState::is_virtual() { return _state->is_virtual(); } -// Use _thread_saved if cthread is detached from JavaThread (_thread == nullptr). -JavaThread* JvmtiEnvThreadState::get_thread_or_saved() { - return _state->get_thread_or_saved(); -} - JavaThread* JvmtiEnvThreadState::get_thread() { return _state->get_thread(); } @@ -344,7 +339,7 @@ void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool ena if (enabled) { // If enabling breakpoint, no need to reset. // Can't do anything if empty stack. - JavaThread* thread = get_thread_or_saved(); + JavaThread* thread = get_thread(); if (event_type == JVMTI_EVENT_SINGLE_STEP && ((thread == nullptr && is_virtual()) || thread->has_last_Java_frame())) { diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.hpp b/src/hotspot/share/prims/jvmtiEnvThreadState.hpp index a2ab25a59dd..16b369e0857 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.hpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -170,8 +170,6 @@ public: inline JvmtiThreadState* jvmti_thread_state() { return _state; } - // use _thread_saved if cthread is detached from JavaThread - JavaThread *get_thread_or_saved(); JavaThread *get_thread(); inline JvmtiEnv *get_env() { return _env; } diff --git a/src/hotspot/share/prims/jvmtiEventController.cpp b/src/hotspot/share/prims/jvmtiEventController.cpp index 9df3bbb4b3e..cb44b833c48 100644 --- a/src/hotspot/share/prims/jvmtiEventController.cpp +++ b/src/hotspot/share/prims/jvmtiEventController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -217,6 +217,10 @@ class EnterInterpOnlyModeClosure : public HandshakeClosure { assert(state != nullptr, "sanity check"); assert(state->get_thread() == jt, "handshake unsafe conditions"); + assert(jt->jvmti_thread_state() == state, "sanity check"); + assert(!jt->is_interp_only_mode(), "sanity check"); + assert(!state->is_interp_only_mode(), "sanity check"); + if (!state->is_pending_interp_only_mode()) { _completed = true; return; // The pending flag has been already cleared, so bail out. @@ -361,7 +365,8 @@ void VM_ChangeSingleStep::doit() { void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) { EC_TRACE(("[%s] # Entering interpreter only mode", - JvmtiTrace::safe_get_thread_name(state->get_thread_or_saved()))); + JvmtiTrace::safe_get_thread_name(state->get_thread()))); + JavaThread *target = state->get_thread(); Thread *current = Thread::current(); @@ -371,8 +376,13 @@ void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state } // This flag will be cleared in EnterInterpOnlyModeClosure handshake. state->set_pending_interp_only_mode(true); - if (target == nullptr) { // an unmounted virtual thread - return; // EnterInterpOnlyModeClosure will be executed right after mount. + + // There are two cases when entering interp_only_mode is postponed: + // 1. Unmounted virtual thread - EnterInterpOnlyModeClosure::do_thread will be executed at mount; + // 2. Carrier thread with mounted virtual thread - EnterInterpOnlyModeClosure::do_thread will be executed at unmount. + if (target == nullptr || // an unmounted virtual thread + JvmtiEnvBase::is_thread_carrying_vthread(target, state->get_thread_oop())) { // a vthread carrying thread + return; // EnterInterpOnlyModeClosure will be executed right after mount or unmount. } EnterInterpOnlyModeClosure hs(state); if (target->is_handshake_safe_for(current)) { @@ -388,7 +398,8 @@ void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state void JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) { EC_TRACE(("[%s] # Leaving interpreter only mode", - JvmtiTrace::safe_get_thread_name(state->get_thread_or_saved()))); + JvmtiTrace::safe_get_thread_name(state->get_thread()))); + if (state->is_pending_interp_only_mode()) { state->set_pending_interp_only_mode(false); // Just clear the pending flag. assert(!state->is_interp_only_mode(), "sanity check"); @@ -409,7 +420,7 @@ JvmtiEventControllerPrivate::trace_changed(JvmtiThreadState *state, jlong now_en if (changed & bit) { // it changed, print it log_trace(jvmti)("[%s] # %s event %s", - JvmtiTrace::safe_get_thread_name(state->get_thread_or_saved()), + JvmtiTrace::safe_get_thread_name(state->get_thread()), (now_enabled & bit)? "Enabling" : "Disabling", JvmtiTrace::event_name((jvmtiEvent)ei)); } } @@ -932,7 +943,7 @@ JvmtiEventControllerPrivate::set_user_enabled(JvmtiEnvBase *env, JavaThread *thr void JvmtiEventControllerPrivate::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { EC_TRACE(("[%s] # set frame pop - frame=%d", - JvmtiTrace::safe_get_thread_name(ets->get_thread_or_saved()), + JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number() )); ets->get_frame_pops()->set(fpop); @@ -943,7 +954,7 @@ JvmtiEventControllerPrivate::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFrameP void JvmtiEventControllerPrivate::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { EC_TRACE(("[%s] # clear frame pop - frame=%d", - JvmtiTrace::safe_get_thread_name(ets->get_thread_or_saved()), + JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number() )); ets->get_frame_pops()->clear(fpop); @@ -953,7 +964,7 @@ JvmtiEventControllerPrivate::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFram void JvmtiEventControllerPrivate::clear_all_frame_pops(JvmtiEnvThreadState *ets) { EC_TRACE(("[%s] # clear all frame pops", - JvmtiTrace::safe_get_thread_name(ets->get_thread_or_saved()) + JvmtiTrace::safe_get_thread_name(ets->get_thread()) )); ets->get_frame_pops()->clear_all(); @@ -965,7 +976,7 @@ JvmtiEventControllerPrivate::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiF int cleared_cnt = ets->get_frame_pops()->clear_to(fpop); EC_TRACE(("[%s] # clear to frame pop - frame=%d, count=%d", - JvmtiTrace::safe_get_thread_name(ets->get_thread_or_saved()), + JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number(), cleared_cnt )); diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 13b239b4df0..c594cfc6816 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -1481,6 +1481,8 @@ jvmtiError VM_RedefineClasses::load_new_class_versions() { } else { return JVMTI_ERROR_INTERNAL; } + } else if (res != JVMTI_ERROR_NONE) { + return res; } #ifdef ASSERT @@ -2045,7 +2047,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_record_attribute(InstanceKlass* scra AnnotationArray* type_annotations = component->type_annotations(); if (type_annotations != nullptr && type_annotations->length() != 0) { int byte_i = 0; // byte index into annotations - if (!rewrite_cp_refs_in_annotations_typeArray(type_annotations, byte_i)) { + if (!rewrite_cp_refs_in_type_annotations_typeArray(type_annotations, byte_i, "record_info")) { log_debug(redefine, class, annotation)("bad record_component_type_annotations at %d", i); // propagate failure back to caller return false; diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp index fc965e568f7..32bf2c4e98e 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiThreadState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,13 +51,12 @@ static const int UNKNOWN_STACK_DEPTH = -99; // JvmtiThreadState *JvmtiThreadState::_head = nullptr; -bool JvmtiThreadState::_seen_interp_only_mode = false; +Atomic JvmtiThreadState::_seen_interp_only_mode{false}; JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) : _thread_event_enable() { assert(JvmtiThreadState_lock->is_locked(), "sanity check"); _thread = thread; - _thread_saved = nullptr; _exception_state = ES_CLEARED; _hide_single_stepping = false; _pending_interp_only_mode = false; @@ -118,11 +117,11 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) if (thread != nullptr) { if (thread_oop == nullptr || thread->jvmti_vthread() == nullptr || thread->jvmti_vthread() == thread_oop) { - // The JavaThread for carrier or mounted virtual thread case. + // The JavaThread for an active carrier or a mounted virtual thread case. // Set this only if thread_oop is current thread->jvmti_vthread(). thread->set_jvmti_thread_state(this); + assert(!thread->is_interp_only_mode(), "sanity check"); } - thread->set_interp_only_mode(false); } } @@ -135,7 +134,10 @@ JvmtiThreadState::~JvmtiThreadState() { } // clear this as the state for the thread + assert(get_thread() != nullptr, "sanity check"); + assert(get_thread()->jvmti_thread_state() == this, "sanity check"); get_thread()->set_jvmti_thread_state(nullptr); + get_thread()->set_interp_only_mode(false); // zap our env thread states { @@ -321,18 +323,21 @@ void JvmtiThreadState::add_env(JvmtiEnvBase *env) { void JvmtiThreadState::enter_interp_only_mode() { assert(_thread != nullptr, "sanity check"); + assert(JvmtiThreadState_lock->is_locked(), "sanity check"); assert(!is_interp_only_mode(), "entering interp only when in interp only mode"); - _seen_interp_only_mode = true; + assert(_thread->jvmti_vthread() == nullptr || _thread->jvmti_vthread() == get_thread_oop(), "sanity check"); + assert(_thread->jvmti_thread_state() == this, "sanity check"); + _saved_interp_only_mode = true; _thread->set_interp_only_mode(true); invalidate_cur_stack_depth(); } void JvmtiThreadState::leave_interp_only_mode() { + assert(JvmtiThreadState_lock->is_locked(), "sanity check"); assert(is_interp_only_mode(), "leaving interp only when not in interp only mode"); - if (_thread == nullptr) { - // Unmounted virtual thread updates the saved value. - _saved_interp_only_mode = false; - } else { + _saved_interp_only_mode = false; + if (_thread != nullptr && _thread->jvmti_thread_state() == this) { + assert(_thread->jvmti_vthread() == nullptr || _thread->jvmti_vthread() == get_thread_oop(), "sanity check"); _thread->set_interp_only_mode(false); } } @@ -340,7 +345,7 @@ void JvmtiThreadState::leave_interp_only_mode() { // Helper routine used in several places int JvmtiThreadState::count_frames() { - JavaThread* thread = get_thread_or_saved(); + JavaThread* thread = get_thread(); javaVFrame *jvf; ResourceMark rm; if (thread == nullptr) { @@ -479,8 +484,6 @@ void JvmtiThreadState::update_for_pop_top_frame() { } // force stack depth to be recalculated invalidate_cur_stack_depth(); - } else { - assert(!is_enabled(JVMTI_EVENT_FRAME_POP), "Must have no framepops set"); } } @@ -579,11 +582,8 @@ void JvmtiThreadState::update_thread_oop_during_vm_start() { } } +// For virtual threads only. void JvmtiThreadState::set_thread(JavaThread* thread) { - _thread_saved = nullptr; // Common case. - if (!_is_virtual && thread == nullptr) { - // Save JavaThread* if carrier thread is being detached. - _thread_saved = _thread; - } + assert(is_virtual(), "sanity check"); _thread = thread; } diff --git a/src/hotspot/share/prims/jvmtiThreadState.hpp b/src/hotspot/share/prims/jvmtiThreadState.hpp index 43b568cf1fc..fa77518a8b6 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.hpp +++ b/src/hotspot/share/prims/jvmtiThreadState.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -123,8 +123,11 @@ class JvmtiVTSuspender : AllStatic { class JvmtiThreadState : public CHeapObj { private: friend class JvmtiEnv; + // The _thread field is a link to the JavaThread associated with JvmtiThreadState. + // A platform (including carrier) thread should always have a stable link to its JavaThread. + // The _thread field of a virtual thread should point to the JavaThread when + // virtual thread is mounted. It should be set to null when it is unmounted. JavaThread *_thread; - JavaThread *_thread_saved; OopHandle _thread_oop_h; // Jvmti Events that cannot be posted in their current context. JvmtiDeferredEventQueue* _jvmti_event_queue; @@ -181,7 +184,7 @@ class JvmtiThreadState : public CHeapObj { inline JvmtiEnvThreadState* head_env_thread_state(); inline void set_head_env_thread_state(JvmtiEnvThreadState* ets); - static bool _seen_interp_only_mode; // interp_only_mode was requested at least once + static Atomic _seen_interp_only_mode; // interp_only_mode was requested at least once public: ~JvmtiThreadState(); @@ -204,19 +207,22 @@ class JvmtiThreadState : public CHeapObj { // Return true if any thread has entered interp_only_mode at any point during the JVMs execution. static bool seen_interp_only_mode() { - return _seen_interp_only_mode; + return _seen_interp_only_mode.load_acquire(); } void add_env(JvmtiEnvBase *env); // The pending_interp_only_mode is set when the interp_only_mode is triggered. // It is cleared by EnterInterpOnlyModeClosure handshake. - bool is_pending_interp_only_mode() { return _pending_interp_only_mode; } - void set_pending_interp_only_mode(bool val) { _pending_interp_only_mode = val; } + bool is_pending_interp_only_mode() { return _pending_interp_only_mode; } + void set_pending_interp_only_mode(bool val) { + _seen_interp_only_mode.release_store(true); + _pending_interp_only_mode = val; + } // Used by the interpreter for fullspeed debugging support bool is_interp_only_mode() { - return _thread == nullptr ? _saved_interp_only_mode : _thread->is_interp_only_mode(); + return _saved_interp_only_mode; } void enter_interp_only_mode(); void leave_interp_only_mode(); @@ -245,8 +251,10 @@ class JvmtiThreadState : public CHeapObj { int count_frames(); - inline JavaThread *get_thread() { return _thread; } - inline JavaThread *get_thread_or_saved(); // return _thread_saved if _thread is null + inline JavaThread *get_thread() { + assert(is_virtual() || _thread != nullptr, "sanity check"); + return _thread; + } // Needed for virtual threads as they can migrate to different JavaThread's. // Also used for carrier threads to clear/restore _thread. diff --git a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp index 2b060f1a2e4..aa81463a696 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp +++ b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2026, 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 @@ -130,22 +130,21 @@ inline JvmtiThreadState* JvmtiThreadState::state_for(JavaThread *thread, Handle return state; } -inline JavaThread* JvmtiThreadState::get_thread_or_saved() { - // Use _thread_saved if cthread is detached from JavaThread (_thread == null). - return (_thread == nullptr && !is_virtual()) ? _thread_saved : _thread; -} - inline void JvmtiThreadState::set_should_post_on_exceptions(bool val) { - get_thread_or_saved()->set_should_post_on_exceptions_flag(val ? JNI_TRUE : JNI_FALSE); + get_thread()->set_should_post_on_exceptions_flag(val ? JNI_TRUE : JNI_FALSE); } inline void JvmtiThreadState::unbind_from(JvmtiThreadState* state, JavaThread* thread) { if (state == nullptr) { + assert(!thread->is_interp_only_mode(), "sanity check"); return; } - // Save thread's interp_only_mode. - state->_saved_interp_only_mode = thread->is_interp_only_mode(); - state->set_thread(nullptr); // Make sure stale _thread value is never used. + assert(thread->jvmti_thread_state() == state, "sanity check"); + assert(state->get_thread() == thread, "sanity check"); + assert(thread->is_interp_only_mode() == state->_saved_interp_only_mode, "sanity check"); + if (state->is_virtual()) { // clean _thread link for virtual threads only + state->set_thread(nullptr); // make sure stale _thread value is never used + } } inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* thread) { @@ -158,7 +157,7 @@ inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* threa // Bind JavaThread to JvmtiThreadState. thread->set_jvmti_thread_state(state); - if (state != nullptr) { + if (state != nullptr && state->is_virtual()) { // Bind to JavaThread. state->set_thread(thread); } @@ -167,8 +166,13 @@ inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* threa inline void JvmtiThreadState::process_pending_interp_only(JavaThread* current) { JvmtiThreadState* state = current->jvmti_thread_state(); - if (state != nullptr && state->is_pending_interp_only_mode()) { - JvmtiEventController::enter_interp_only_mode(state); + if (state != nullptr && seen_interp_only_mode()) { // avoid MutexLocker if possible + MutexLocker mu(JvmtiThreadState_lock); + if (state->is_pending_interp_only_mode()) { + assert(state->get_thread() == current, "sanity check"); + assert(!state->is_interp_only_mode(), "sanity check"); + JvmtiEventController::enter_interp_only_mode(state); + } } } #endif // SHARE_PRIMS_JVMTITHREADSTATE_INLINE_HPP diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index 9c0ec113a02..7d80ed327fd 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -54,8 +54,8 @@ bool VectorSupport::is_vector_mask(Klass* klass) { BasicType VectorSupport::klass2bt(InstanceKlass* ik) { assert(ik->is_subclass_of(vmClasses::vector_VectorPayload_klass()), "%s not a VectorPayload", ik->name()->as_C_string()); fieldDescriptor fd; // find_field initializes fd if found - // static final Class ETYPE; - Klass* holder = ik->find_field(vmSymbols::ETYPE_name(), vmSymbols::class_signature(), &fd); + // static final Class CTYPE; + Klass* holder = ik->find_field(vmSymbols::CTYPE_name(), vmSymbols::class_signature(), &fd); assert(holder != nullptr, "sanity"); assert(fd.is_static(), ""); @@ -200,7 +200,6 @@ bool VectorSupport::is_unsigned_op(jint id) { } const char* VectorSupport::lanetype2name(LaneType lane_type) { - assert(lane_type >= LT_FLOAT && lane_type <= LT_LONG, ""); const char* lanetype2name[] = { "float", "double", @@ -209,7 +208,11 @@ const char* VectorSupport::lanetype2name(LaneType lane_type) { "int", "long" }; - return lanetype2name[lane_type]; + if (lane_type >= LT_FLOAT && lane_type <= LT_LONG) { + return lanetype2name[lane_type]; + } + assert(false, "unknown lane type: %d", (int)lane_type); + return "illegal"; } int VectorSupport::vop2ideal(jint id, LaneType lt) { diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 35e0b83d25f..a13d0ba47c8 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -333,7 +333,6 @@ WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o)) WB_END WB_ENTRY(void, WB_DecodeNKlassAndAccessKlass(JNIEnv* env, jobject o, jint nKlass)) - assert(UseCompressedClassPointers, "Should only call for UseCompressedClassPointers"); const narrowKlass nk = (narrowKlass)nKlass; const Klass* const k = CompressedKlassPointers::decode_not_null_without_asserts(nKlass); printf("WB_DecodeNKlassAndAccessKlass: nk %u k " PTR_FORMAT "\n", nk, p2i(k)); @@ -578,7 +577,7 @@ WB_END WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o)) if (UseG1GC) { G1CollectedHeap* g1h = G1CollectedHeap::heap(); - return g1h->concurrent_mark()->in_progress(); + return g1h->collector_state()->is_in_concurrent_cycle(); } THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1InConcurrentMark: G1 GC is not enabled"); WB_END @@ -2215,25 +2214,10 @@ WB_ENTRY(jboolean, WB_CDSMemoryMappingFailed(JNIEnv* env, jobject wb)) return FileMapInfo::memory_mapping_failed(); WB_END -WB_ENTRY(jboolean, WB_IsSharedInternedString(JNIEnv* env, jobject wb, jobject str)) - if (!HeapShared::is_loading_mapping_mode()) { - return false; - } - ResourceMark rm(THREAD); - oop str_oop = JNIHandles::resolve(str); - int length; - jchar* chars = java_lang_String::as_unicode_string(str_oop, length, CHECK_(false)); - return StringTable::lookup_shared(chars, length) == str_oop; -WB_END - WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz)) return (jboolean)AOTMetaspace::in_aot_cache(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); WB_END -WB_ENTRY(jboolean, WB_AreSharedStringsMapped(JNIEnv* env)) - return AOTMappedHeapLoader::is_mapped(); -WB_END - WB_ENTRY(void, WB_LinkClass(JNIEnv* env, jobject wb, jclass clazz)) Klass *k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); if (!k->is_instance_klass()) { @@ -3058,9 +3042,7 @@ static JNINativeMethod methods[] = { {CC"getCDSGenericHeaderMinVersion", CC"()I", (void*)&WB_GetCDSGenericHeaderMinVersion}, {CC"getCurrentCDSVersion", CC"()I", (void*)&WB_GetCDSCurrentVersion}, {CC"isSharingEnabled", CC"()Z", (void*)&WB_IsSharingEnabled}, - {CC"isSharedInternedString", CC"(Ljava/lang/String;)Z", (void*)&WB_IsSharedInternedString }, {CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass }, - {CC"areSharedStringsMapped", CC"()Z", (void*)&WB_AreSharedStringsMapped }, {CC"linkClass", CC"(Ljava/lang/Class;)V", (void*)&WB_LinkClass}, {CC"areOpenArchiveHeapObjectsMapped", CC"()Z", (void*)&WB_AreOpenArchiveHeapObjectsMapped}, {CC"isCDSIncluded", CC"()Z", (void*)&WB_IsCDSIncluded }, diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp index 4051ba3f9d6..37c5815f60e 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp @@ -152,28 +152,14 @@ const char* Abstract_VM_Version::vm_info_string() { } case Arguments::_mixed: if (is_vm_statically_linked()) { - if (CompilationModeFlag::quick_only()) { - return CDSConfig::is_using_archive() ? "mixed mode, emulated-client, static, sharing" : "mixed mode, emulated-client, static"; - } else { - return CDSConfig::is_using_archive() ? "mixed mode, static, sharing" : "mixed mode, static"; - } + return CDSConfig::is_using_archive() ? "mixed mode, static, sharing" : "mixed mode, static"; } else { - if (CompilationModeFlag::quick_only()) { - return CDSConfig::is_using_archive() ? "mixed mode, emulated-client, sharing" : "mixed mode, emulated-client"; - } else { - return CDSConfig::is_using_archive() ? "mixed mode, sharing" : "mixed mode"; - } + return CDSConfig::is_using_archive() ? "mixed mode, sharing" : "mixed mode"; } case Arguments::_comp: if (is_vm_statically_linked()) { - if (CompilationModeFlag::quick_only()) { - return CDSConfig::is_using_archive() ? "compiled mode, emulated-client, static, sharing" : "compiled mode, emulated-client, static"; - } return CDSConfig::is_using_archive() ? "compiled mode, static, sharing" : "compiled mode, static"; } else { - if (CompilationModeFlag::quick_only()) { - return CDSConfig::is_using_archive() ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client"; - } return CDSConfig::is_using_archive() ? "compiled mode, sharing" : "compiled mode"; } } diff --git a/src/hotspot/share/runtime/abstract_vm_version.hpp b/src/hotspot/share/runtime/abstract_vm_version.hpp index 5a6b41506c7..17ade2c068d 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.hpp +++ b/src/hotspot/share/runtime/abstract_vm_version.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,6 +42,7 @@ typedef enum { } VirtualizationType; class outputStream; +class stringStream; enum class vmIntrinsicID; // Abstract_VM_Version provides information about the VM. @@ -226,6 +227,21 @@ class Abstract_VM_Version: AllStatic { static const char* cpu_name(void); static const char* cpu_description(void); + + static void get_cpu_features_name(void* features_buffer, stringStream& ss) { return; } + + // Returns names of features present in features_set1 but not in features_set2 + static void get_missing_features_name(void* features_set1, void* features_set2, stringStream& ss) { return; } + + // Returns number of bytes required to store cpu features representation + static int cpu_features_size() { return 0; } + + // Stores arch dependent cpu features representation in the provided buffer. + // Size of the buffer must be same as returned by cpu_features_size() + static void store_cpu_features(void* buf) { return; } + + // features_to_test is an opaque object that stores arch specific representation of cpu features + static bool supports_features(void* features_to_test) { return false; }; }; #endif // SHARE_RUNTIME_ABSTRACT_VM_VERSION_HPP diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 546ae610769..1d79c4d0488 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -536,12 +536,7 @@ static SpecialFlag const special_jvm_flags[] = { #ifdef _LP64 { "UseCompressedClassPointers", JDK_Version::jdk(25), JDK_Version::jdk(27), JDK_Version::undefined() }, #endif - { "ParallelRefProcEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, - { "ParallelRefProcBalancingEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, - { "MaxRAM", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, { "AggressiveHeap", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, - { "NeverActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, - { "AlwaysActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, @@ -553,6 +548,14 @@ static SpecialFlag const special_jvm_flags[] = { #endif { "PSChunkLargeArrays", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "ParallelRefProcEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "ParallelRefProcBalancingEnabled", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "MaxRAM", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "NewSizeThreadIncrease", JDK_Version::undefined(), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "NeverActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "AlwaysActAsServerClassMachine", JDK_Version::jdk(26), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "UseXMMForArrayCopy", JDK_Version::undefined(), JDK_Version::jdk(27), JDK_Version::jdk(28) }, + { "UseNewLongLShift", JDK_Version::undefined(), JDK_Version::jdk(27), JDK_Version::jdk(28) }, #ifdef ASSERT { "DummyObsoleteTestFlag", JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() }, @@ -1510,25 +1513,16 @@ void Arguments::set_heap_size() { // Check if the user has configured any limit on the amount of RAM we may use. bool has_ram_limit = !FLAG_IS_DEFAULT(MaxRAMPercentage) || !FLAG_IS_DEFAULT(MinRAMPercentage) || - !FLAG_IS_DEFAULT(InitialRAMPercentage) || - !FLAG_IS_DEFAULT(MaxRAM); + !FLAG_IS_DEFAULT(InitialRAMPercentage); - if (FLAG_IS_DEFAULT(MaxRAM)) { - if (CompilerConfig::should_set_client_emulation_mode_flags()) { - // Limit the available memory if client emulation mode is enabled. - FLAG_SET_ERGO(MaxRAM, 1ULL*G); - } else { - // Use the available physical memory on the system. - FLAG_SET_ERGO(MaxRAM, os::physical_memory()); - } - } + const size_t avail_mem = os::physical_memory(); // If the maximum heap size has not been set with -Xmx, then set it as // fraction of the size of physical memory, respecting the maximum and // minimum sizes of the heap. if (FLAG_IS_DEFAULT(MaxHeapSize)) { - uint64_t min_memory = (uint64_t)(((double)MaxRAM * MinRAMPercentage) / 100); - uint64_t max_memory = (uint64_t)(((double)MaxRAM * MaxRAMPercentage) / 100); + uint64_t min_memory = (uint64_t)(((double)avail_mem * MinRAMPercentage) / 100); + uint64_t max_memory = (uint64_t)(((double)avail_mem * MaxRAMPercentage) / 100); const size_t reasonable_min = clamp_by_size_t_max(min_memory); size_t reasonable_max = clamp_by_size_t_max(max_memory); @@ -1560,7 +1554,7 @@ void Arguments::set_heap_size() { } #ifdef _LP64 - if (UseCompressedOops || UseCompressedClassPointers) { + if (UseCompressedOops) { // HeapBaseMinAddress can be greater than default but not less than. if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) { if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) { @@ -1573,9 +1567,7 @@ void Arguments::set_heap_size() { FLAG_SET_ERGO(HeapBaseMinAddress, DefaultHeapBaseMinAddress); } } - } - if (UseCompressedOops) { uintptr_t heap_end = HeapBaseMinAddress + MaxHeapSize; uintptr_t max_coop_heap = max_heap_for_compressed_oops(); @@ -1615,7 +1607,7 @@ void Arguments::set_heap_size() { reasonable_minimum = limit_heap_by_allocatable_memory(reasonable_minimum); if (InitialHeapSize == 0) { - uint64_t initial_memory = (uint64_t)(((double)MaxRAM * InitialRAMPercentage) / 100); + uint64_t initial_memory = (uint64_t)(((double)avail_mem * InitialRAMPercentage) / 100); size_t reasonable_initial = clamp_by_size_t_max(initial_memory); reasonable_initial = limit_heap_by_allocatable_memory(reasonable_initial); @@ -3788,10 +3780,6 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { void Arguments::set_compact_headers_flags() { #ifdef _LP64 - if (UseCompactObjectHeaders && FLAG_IS_CMDLINE(UseCompressedClassPointers) && !UseCompressedClassPointers) { - warning("Compact object headers require compressed class pointers. Disabling compact object headers."); - FLAG_SET_DEFAULT(UseCompactObjectHeaders, false); - } if (UseCompactObjectHeaders && !UseObjectMonitorTable) { // If UseCompactObjectHeaders is on the command line, turn on UseObjectMonitorTable. if (FLAG_IS_CMDLINE(UseCompactObjectHeaders)) { @@ -3805,9 +3793,6 @@ void Arguments::set_compact_headers_flags() { FLAG_SET_DEFAULT(UseObjectMonitorTable, true); } } - if (UseCompactObjectHeaders && !UseCompressedClassPointers) { - FLAG_SET_DEFAULT(UseCompressedClassPointers, true); - } #endif } @@ -3823,9 +3808,7 @@ jint Arguments::apply_ergo() { set_compact_headers_flags(); - if (UseCompressedClassPointers) { - CompressedKlassPointers::pre_initialize(); - } + CompressedKlassPointers::pre_initialize(); CDSConfig::ergo_initialize(); @@ -3870,10 +3853,6 @@ jint Arguments::apply_ergo() { DebugNonSafepoints = true; } - if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) { - warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used"); - } - // Treat the odd case where local verification is enabled but remote // verification is not as if both were enabled. if (BytecodeVerificationLocal && !BytecodeVerificationRemote) { diff --git a/src/hotspot/share/runtime/atomicAccess.hpp b/src/hotspot/share/runtime/atomicAccess.hpp index c9a2dfb9383..46330cffdb2 100644 --- a/src/hotspot/share/runtime/atomicAccess.hpp +++ b/src/hotspot/share/runtime/atomicAccess.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #define SHARE_RUNTIME_ATOMICACCESS_HPP #include "cppstdlib/type_traits.hpp" -#include "memory/allocation.hpp" +#include "memory/allStatic.hpp" #include "metaprogramming/enableIf.hpp" #include "metaprogramming/primitiveConversions.hpp" #include "runtime/orderAccess.hpp" @@ -829,7 +829,7 @@ class AtomicAccess::PlatformBitops {}; template -class ScopedFenceGeneral: public StackObj { +class ScopedFenceGeneral { public: void prefix() {} void postfix() {} diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 2beba9abb06..5fbe2842a2b 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -1686,7 +1686,7 @@ bool Deoptimization::relock_objects(JavaThread* thread, GrowableArrayowner()->is_locked(), "object must be locked now"); assert(obj->mark().has_monitor(), "must be"); assert(!deoptee_thread->lock_stack().contains(obj()), "must be"); - assert(ObjectSynchronizer::read_monitor(thread, obj(), obj->mark())->has_owner(deoptee_thread), "must be"); + assert(ObjectSynchronizer::read_monitor(obj(), obj->mark())->has_owner(deoptee_thread), "must be"); } } } @@ -2155,7 +2155,9 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr // Lock to read ProfileData, and ensure lock is not broken by a safepoint // We must do this already now, since we cannot acquire this lock while // holding the tty lock (lock ordering by rank). - MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml((trap_mdo != nullptr) ? trap_mdo->extra_data_lock() : nullptr, + (trap_mdo != nullptr), + Mutex::_no_safepoint_check_flag); ttyLocker ttyl; diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp index 444ce321759..36eece6f013 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp @@ -274,6 +274,17 @@ JVMFlag::Error AVX3ThresholdConstraintFunc(int value, bool verbose) { return JVMFlag::SUCCESS; } +JVMFlag::Error CopyAVX3ThresholdConstraintFunc(int value, bool verbose) { + if (value != 0 && !is_power_of_2(value)) { + JVMFlag::printError(verbose, + "CopyAVX3Threshold ( %d ) must be 0 or " + "a power of two value between 0 and MAX_INT\n", value); + return JVMFlag::VIOLATES_CONSTRAINT; + } + + return JVMFlag::SUCCESS; +} + JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { if (value >= 4032) { JVMFlag::printError(verbose, diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp index cf785800cfc..45e91058e0b 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp @@ -46,6 +46,7 @@ f(uintx, ArraycopyDstPrefetchDistanceConstraintFunc) \ f(uintx, ArraycopySrcPrefetchDistanceConstraintFunc) \ f(int, AVX3ThresholdConstraintFunc) \ + f(int, CopyAVX3ThresholdConstraintFunc) \ f(uint, TypeProfileLevelConstraintFunc) \ f(uint, VerifyIterativeGVNConstraintFunc) \ f(intx, InitArrayShortSizeConstraintFunc) \ diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 6d4b9908e1c..b5c19d8aa36 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -199,19 +199,6 @@ const int ObjectAlignmentInBytes = 8; "Granularity to use for NUMA interleaving on Windows OS") \ constraint(NUMAInterleaveGranularityConstraintFunc, AtParse) \ \ - product(uintx, NUMAChunkResizeWeight, 20, \ - "Percentage (0-100) used to weight the current sample when " \ - "computing exponentially decaying average for " \ - "AdaptiveNUMAChunkSizing") \ - range(0, 100) \ - \ - product(size_t, NUMASpaceResizeRate, 1*G, \ - "Do not reallocate more than this amount per collection") \ - range(0, max_uintx) \ - \ - product(bool, UseAdaptiveNUMAChunkSizing, true, \ - "Enable adaptive chunk sizing for NUMA") \ - \ product(bool, NUMAStats, false, \ "Print NUMA stats in detailed heap information") \ \ @@ -811,9 +798,6 @@ const int ObjectAlignmentInBytes = 8; "Number of OutOfMemoryErrors preallocated with backtrace") \ range(0, 1024) \ \ - product(bool, UseXMMForArrayCopy, false, \ - "Use SSE2 MOVQ instruction for Arraycopy") \ - \ develop(bool, PrintFieldLayout, false, \ "Print field layout for each class") \ \ @@ -884,21 +868,9 @@ const int ObjectAlignmentInBytes = 8; develop(bool, VerifyDependencies, trueInDebug, \ "Exercise and verify the compilation dependency mechanism") \ \ - develop(bool, TraceNewOopMapGeneration, false, \ - "Trace OopMapGeneration") \ - \ - develop(bool, TraceNewOopMapGenerationDetailed, false, \ - "Trace OopMapGeneration: print detailed cell states") \ - \ develop(bool, TimeOopMap, false, \ "Time calls to GenerateOopMap::compute_map() in sum") \ \ - develop(bool, TimeOopMap2, false, \ - "Time calls to GenerateOopMap::compute_map() individually") \ - \ - develop(bool, TraceOopMapRewrites, false, \ - "Trace rewriting of methods during oop map generation") \ - \ develop(bool, TraceFinalizerRegistration, false, \ "Trace registration of final references") \ \ @@ -1396,9 +1368,6 @@ const int ObjectAlignmentInBytes = 8; "Maximum size of Metaspaces (in bytes)") \ constraint(MaxMetaspaceSizeConstraintFunc,AfterErgo) \ \ - product(bool, UseCompressedClassPointers, true, \ - "(Deprecated) Use 32-bit class pointers.") \ - \ product(size_t, CompressedClassSpaceSize, 1*G, \ "Maximum size of class area in Metaspace when compressed " \ "class pointers are used") \ @@ -1957,7 +1926,7 @@ const int ObjectAlignmentInBytes = 8; "Mark all threads after a safepoint, and clear on a modify " \ "fence. Add cleanliness checks.") \ \ - product(bool, UseObjectMonitorTable, false, DIAGNOSTIC, \ + product(bool, UseObjectMonitorTable, true, DIAGNOSTIC, \ "Use a table to record inflated monitors rather than the first " \ "word of the object.") \ \ diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index ee4f776df06..758051a7351 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -151,7 +151,8 @@ static void print_method_profiling_data() { ss.fill_to(2); m->method_data()->parameters_type_data()->print_data_on(&ss); } - m->print_codes_on(&ss); + // Buffering to a stringStream, disable internal buffering so it's not done twice. + m->print_codes_on(&ss, 0, false); tty->print("%s", ss.as_string()); // print all at once total_size += m->method_data()->size_in_bytes(); } diff --git a/src/hotspot/share/runtime/lockStack.cpp b/src/hotspot/share/runtime/lockStack.cpp index a88a84eb9f8..58b9c58a329 100644 --- a/src/hotspot/share/runtime/lockStack.cpp +++ b/src/hotspot/share/runtime/lockStack.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -118,7 +118,4 @@ void LockStack::print_on(outputStream* st) { OMCache::OMCache(JavaThread* jt) : _entries() { STATIC_ASSERT(std::is_standard_layout::value); STATIC_ASSERT(std::is_standard_layout::value); - STATIC_ASSERT(offsetof(OMCache, _null_sentinel) == offsetof(OMCache, _entries) + - offsetof(OMCache::OMCacheEntry, _oop) + - OMCache::CAPACITY * in_bytes(oop_to_oop_difference())); } diff --git a/src/hotspot/share/runtime/lockStack.hpp b/src/hotspot/share/runtime/lockStack.hpp index dbc958a71e2..a32364b1774 100644 --- a/src/hotspot/share/runtime/lockStack.hpp +++ b/src/hotspot/share/runtime/lockStack.hpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -132,14 +132,13 @@ class LockStack { class OMCache { friend class VMStructs; public: - static constexpr int CAPACITY = 8; + static constexpr int CAPACITY = 2; private: struct OMCacheEntry { oop _oop = nullptr; ObjectMonitor* _monitor = nullptr; } _entries[CAPACITY]; - const oop _null_sentinel = nullptr; public: static ByteSize entries_offset() { return byte_offset_of(OMCache, _entries); } diff --git a/src/hotspot/share/runtime/lockStack.inline.hpp b/src/hotspot/share/runtime/lockStack.inline.hpp index 27eb07fcec8..a9ad3553db8 100644 --- a/src/hotspot/share/runtime/lockStack.inline.hpp +++ b/src/hotspot/share/runtime/lockStack.inline.hpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -254,7 +254,7 @@ inline void OMCache::set_monitor(ObjectMonitor *monitor) { oop obj = monitor->object_peek(); assert(obj != nullptr, "must be alive"); - assert(monitor == ObjectSynchronizer::get_monitor_from_table(JavaThread::current(), obj), "must exist in table"); + assert(monitor == ObjectSynchronizer::get_monitor_from_table(obj), "must exist in table"); OMCacheEntry to_insert = {obj, monitor}; diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index 144533cd959..94399088464 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -329,13 +329,18 @@ void ObjectMonitor::set_object_strong() { void ObjectMonitor::ExitOnSuspend::operator()(JavaThread* current) { if (current->is_suspended()) { + // There could be an ongoing safepoint/handshake operation. + // Process them, except suspend requests, before exiting the + // monitor, as this may involve touching oops if the successor + // is a virtual thread. Before processing pending operations, + // set the monitor as pending again. + current->set_current_pending_monitor(_om); + SafepointMechanism::process_if_requested(current, false /*allow_suspend*/, false /*check_async_exception*/); _om->_recursions = 0; _om->clear_successor(); // Don't need a full fence after clearing successor here because of the call to exit(). _om->exit(current, false /* not_suspended */); _om_exited = true; - - current->set_current_pending_monitor(_om); } } @@ -588,12 +593,15 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread* current, ObjectMonito OSThreadContendState osts(current->osthread()); assert(current->thread_state() == _thread_in_vm, "invariant"); + ObjectWaiter node(current); for (;;) { ExitOnSuspend eos(this); { ThreadBlockInVMPreprocess tbivs(current, eos, true /* allow_suspend */); - enter_internal(current); + if (!try_enter_fast(current, &node)) { + enter_internal(current, &node, false /* reenter_path */); + } current->set_current_pending_monitor(nullptr); // We can go to a safepoint at the end of this block. If we // do a thread dump during that safepoint, then this thread will show @@ -849,7 +857,7 @@ bool ObjectMonitor::deflate_monitor(Thread* current) { } if (UseObjectMonitorTable) { - ObjectSynchronizer::deflate_monitor(current, obj, this); + ObjectSynchronizer::deflate_monitor(obj, this); } else if (obj != nullptr) { // Install the old mark word if nobody else has already done it. install_displaced_markword_in_object(obj); @@ -937,14 +945,17 @@ const char* ObjectMonitor::is_busy_to_string(stringStream* ss) { return ss->base(); } -void ObjectMonitor::enter_internal(JavaThread* current) { +bool ObjectMonitor::try_enter_fast(JavaThread* current, ObjectWaiter* current_node) { + assert(current != nullptr, "invariant"); assert(current->thread_state() == _thread_blocked, "invariant"); + assert(current_node != nullptr, "invariant"); + assert(current_node->_thread == current, "invariant"); // Try the lock - TATAS if (try_lock(current) == TryLockResult::Success) { assert(!has_successor(current), "invariant"); assert(has_owner(current), "invariant"); - return; + return true; } assert(InitDone, "Unexpectedly not initialized"); @@ -959,7 +970,7 @@ void ObjectMonitor::enter_internal(JavaThread* current) { if (try_spin(current)) { assert(has_owner(current), "invariant"); assert(!has_successor(current), "invariant"); - return; + return true; } // The Spin failed -- Enqueue and park the thread ... @@ -968,54 +979,67 @@ void ObjectMonitor::enter_internal(JavaThread* current) { // Enqueue "current" on ObjectMonitor's _entry_list. // - // Node acts as a proxy for current. + // current_node acts as a proxy for current. // As an aside, if were to ever rewrite the synchronization code mostly // in Java, WaitNodes, ObjectMonitors, and Events would become 1st-class // Java objects. This would avoid awkward lifecycle and liveness issues, // as well as eliminate a subset of ABA issues. // TODO: eliminate ObjectWaiter and enqueue either Threads or Events. - ObjectWaiter node(current); current->_ParkEvent->reset(); - if (try_lock_or_add_to_entry_list(current, &node)) { - return; // We got the lock. + if (try_lock_or_add_to_entry_list(current, current_node)) { + return true; // We got the lock. } + // This thread is now added to the _entry_list. // The lock might have been released while this thread was occupied queueing // itself onto _entry_list. To close the race and avoid "stranding" and - // progress-liveness failure we must resample-retry _owner before parking. + // progress-liveness failure the caller must resample-retry _owner before parking. // Note the Dekker/Lamport duality: ST _entry_list; MEMBAR; LD Owner. - // In this case the ST-MEMBAR is accomplished with CAS(). - // - // TODO: Defer all thread state transitions until park-time. - // Since state transitions are heavy and inefficient we'd like - // to defer the state transitions until absolutely necessary, - // and in doing so avoid some transitions ... + // In this case the ST-MEMBAR is accomplished with CAS() in try_lock_or_add_to_entry_list. + return false; +} + +void ObjectMonitor::enter_internal(JavaThread* current, ObjectWaiter* current_node, bool reenter_path) { + assert(current != nullptr, "invariant"); + assert(current->thread_state() == _thread_blocked, "invariant"); + assert(current_node != nullptr, "invariant"); + assert(current_node->_thread == current, "invariant"); // If there are unmounted virtual threads ahead in the _entry_list we want // to do a timed-park instead to alleviate some deadlock cases where one // of them is picked as the successor but cannot run due to having run out // of carriers. This can happen, for example, if this is a pinned virtual - // thread currently loading or initializining a class, and all other carriers + // thread currently loading or initializing a class, and all other carriers // have a pinned vthread waiting for said class to be loaded/initialized. // Read counter *after* adding this thread to the _entry_list. Adding to // _entry_list uses Atomic::cmpxchg() which already provides a fence that - // prevents this load from floating up previous store. + // prevents this load from floating up past a previous store. // Note that we can have false positives where timed-park is not necessary. - bool do_timed_parked = has_unmounted_vthreads(); + bool do_timed_park = has_unmounted_vthreads(); jlong recheck_interval = 1; for (;;) { + ObjectWaiter::TStates v = current_node->TState; + guarantee(v == ObjectWaiter::TS_ENTER, "invariant"); if (try_lock(current) == TryLockResult::Success) { break; } assert(!has_owner(current), "invariant"); + if (reenter_path) { + // If try_lock failed, spin again - we expect the notifier to release the monitor quickly. + // Note that spin count may be zero so the above try_lock is necessary. + if (try_spin(current)) { + break; + } + } + // park self - if (do_timed_parked) { + if (do_timed_park) { current->_ParkEvent->park(recheck_interval); // Increase the recheck_interval, but clamp the value. recheck_interval *= 8; @@ -1026,125 +1050,6 @@ void ObjectMonitor::enter_internal(JavaThread* current) { current->_ParkEvent->park(); } - if (try_lock(current) == TryLockResult::Success) { - break; - } - - // The lock is still contested. - - // Assuming this is not a spurious wakeup we'll normally find _succ == current. - // We can defer clearing _succ until after the spin completes - // try_spin() must tolerate being called with _succ == current. - // Try yet another round of adaptive spinning. - if (try_spin(current)) { - break; - } - - // We can find that we were unpark()ed and redesignated _succ while - // we were spinning. That's harmless. If we iterate and call park(), - // park() will consume the event and return immediately and we'll - // just spin again. This pattern can repeat, leaving _succ to simply - // spin on a CPU. - - if (has_successor(current)) clear_successor(); - - // Invariant: after clearing _succ a thread *must* retry _owner before parking. - OrderAccess::fence(); - } - - // Egress : - // Current has acquired the lock -- Unlink current from the _entry_list. - unlink_after_acquire(current, &node); - if (has_successor(current)) { - clear_successor(); - // Note that we don't need to do OrderAccess::fence() after clearing - // _succ here, since we own the lock. - } - - // We've acquired ownership with CAS(). - // CAS is serializing -- it has MEMBAR/FENCE-equivalent semantics. - // But since the CAS() this thread may have also stored into _succ - // or entry_list. These meta-data updates must be visible __before - // this thread subsequently drops the lock. - // Consider what could occur if we didn't enforce this constraint -- - // STs to monitor meta-data and user-data could reorder with (become - // visible after) the ST in exit that drops ownership of the lock. - // Some other thread could then acquire the lock, but observe inconsistent - // or old monitor meta-data and heap data. That violates the JMM. - // To that end, the exit() operation must have at least STST|LDST - // "release" barrier semantics. Specifically, there must be at least a - // STST|LDST barrier in exit() before the ST of null into _owner that drops - // the lock. The barrier ensures that changes to monitor meta-data and data - // protected by the lock will be visible before we release the lock, and - // therefore before some other thread (CPU) has a chance to acquire the lock. - // See also: http://gee.cs.oswego.edu/dl/jmm/cookbook.html. - // - // Critically, any prior STs to _succ or entry_list must be visible before - // the ST of null into _owner in the *subsequent* (following) corresponding - // monitorexit. - - return; -} - -// reenter_internal() is a specialized inline form of the latter half of the -// contended slow-path from enter_internal(). We use reenter_internal() only for -// monitor reentry in wait(). -// -// In the future we should reconcile enter_internal() and reenter_internal(). - -void ObjectMonitor::reenter_internal(JavaThread* current, ObjectWaiter* currentNode) { - assert(current != nullptr, "invariant"); - assert(current->thread_state() == _thread_blocked, "invariant"); - assert(currentNode != nullptr, "invariant"); - assert(currentNode->_thread == current, "invariant"); - assert(_waiters > 0, "invariant"); - - // If there are unmounted virtual threads ahead in the _entry_list we want - // to do a timed-park instead to alleviate some deadlock cases where one - // of them is picked as the successor but cannot run due to having run out - // of carriers. This can happen, for example, if a mixed of unmounted and - // pinned vthreads taking up all the carriers are waiting for a class to be - // initialized, and the selected successor is one of the unmounted vthreads. - // Although this method is used for the "notification" case, it could be - // that this thread reached here without been added to the _entry_list yet. - // This can happen if it was interrupted or the wait timed-out at the same - // time. In that case we rely on currentNode->_do_timed_park, which will be - // read on the next loop iteration, after consuming the park permit set by - // the notifier in notify_internal. - // Note that we can have false positives where timed-park is not necessary. - bool do_timed_parked = has_unmounted_vthreads(); - jlong recheck_interval = 1; - - for (;;) { - ObjectWaiter::TStates v = currentNode->TState; - guarantee(v == ObjectWaiter::TS_ENTER, "invariant"); - assert(!has_owner(current), "invariant"); - - // This thread has been notified so try to reacquire the lock. - if (try_lock(current) == TryLockResult::Success) { - break; - } - - // If that fails, spin again. Note that spin count may be zero so the above TryLock - // is necessary. - if (try_spin(current)) { - break; - } - - { - OSThreadContendState osts(current->osthread()); - if (do_timed_parked) { - current->_ParkEvent->park(recheck_interval); - // Increase the recheck_interval, but clamp the value. - recheck_interval *= 8; - if (recheck_interval > MAX_RECHECK_INTERVAL) { - recheck_interval = MAX_RECHECK_INTERVAL; - } - } else { - current->_ParkEvent->park(); - } - } - // Try again, but just so we distinguish between futile wakeups and // successful wakeups. The following test isn't algorithmically // necessary, but it helps us maintain sensible statistics. @@ -1154,25 +1059,68 @@ void ObjectMonitor::reenter_internal(JavaThread* current, ObjectWaiter* currentN // The lock is still contested. - // Assuming this is not a spurious wakeup we'll normally - // find that _succ == current. - if (has_successor(current)) clear_successor(); + if (!reenter_path) { + // Assuming this is not a spurious wakeup we'll normally find _succ == current. + // We can defer clearing _succ until after the spin completes and + // try_spin() must tolerate being called with _succ == current. + // Try yet another round of adaptive spinning. + if (try_spin(current)) { + break; + } + } - // Invariant: after clearing _succ a contending thread - // *must* retry _owner before parking. + // We can find that we were unpark()ed and redesignated _succ while + // we were spinning. That's harmless. If we iterate and call park(), + // park() will consume the event and return immediately and we'll + // just spin again. This pattern can repeat, leaving _succ to simply + // spin on a CPU. + + if (has_successor(current)) { + clear_successor(); + } + + // Invariant: after clearing _succ a thread *must* retry _owner before parking. OrderAccess::fence(); - // See comment in notify_internal - do_timed_parked |= currentNode->_do_timed_park; + // Will only potentially change on the reenter path - see comment in notify_internal. + do_timed_park |= current_node->_do_timed_park; } - // Current has acquired the lock -- Unlink current from the _entry_list. assert(has_owner(current), "invariant"); - unlink_after_acquire(current, currentNode); - if (has_successor(current)) clear_successor(); - assert(!has_successor(current), "invariant"); - currentNode->TState = ObjectWaiter::TS_RUN; - OrderAccess::fence(); // see comments at the end of enter_internal() + + // Egress : + // Current has acquired the lock -- Unlink current from the _entry_list. + unlink_after_acquire(current, current_node); + if (has_successor(current)) { + clear_successor(); + // Note that we don't need to do OrderAccess::fence() after clearing + // _succ here, since we own the lock. + } + + // We've acquired ownership with CAS(). + // CAS is serializing -- it has MEMBAR/FENCE-equivalent semantics. + // But since the CAS() this thread may have also stored into _succ + // or entry_list. These meta-data updates must be visible __before + // this thread subsequently drops the lock. + // Consider what could occur if we didn't enforce this constraint -- + // STs to monitor meta-data and user-data could reorder with (become + // visible after) the ST in exit that drops ownership of the lock. + // Some other thread could then acquire the lock, but observe inconsistent + // or old monitor meta-data and heap data. That violates the JMM. + // To that end, the exit() operation must have at least STST|LDST + // "release" barrier semantics. Specifically, there must be at least a + // STST|LDST barrier in exit() before the ST of null into _owner that drops + // the lock. The barrier ensures that changes to monitor meta-data and data + // protected by the lock will be visible before we release the lock, and + // therefore before some other thread (CPU) has a chance to acquire the lock. + // See also: http://gee.cs.oswego.edu/dl/jmm/cookbook.html. + // + // Critically, any prior STs to _succ or entry_list must be visible before + // the ST of null into _owner in the *subsequent* (following) corresponding + // monitorexit. + + current_node->TState = ObjectWaiter::TS_RUN; + return; } // This method is called from two places: @@ -1644,6 +1592,7 @@ void ObjectMonitor::exit_epilog(JavaThread* current, ObjectWaiter* Wakee) { Trigger = t->_ParkEvent; set_successor(t); } else { + assert_not_at_safepoint(); vthread = Wakee->vthread(); assert(vthread != nullptr, ""); Trigger = ObjectMonitor::vthread_unparker_ParkEvent(); @@ -1965,7 +1914,9 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { ExitOnSuspend eos(this); { ThreadBlockInVMPreprocess tbivs(current, eos, true /* allow_suspend */); - reenter_internal(current, &node); + assert( _waiters > 0, "invariant"); + OSThreadContendState osts(current->osthread()); + enter_internal(current, &node, true /* reenter_path */); // We can go to a safepoint at the end of this block. If we // do a thread dump during that safepoint, then this thread will show // as having "-locked" the monitor, but the OS and java.lang.Thread @@ -2076,12 +2027,12 @@ bool ObjectMonitor::notify_internal(JavaThread* current) { // Wake up the thread to alleviate some deadlock cases where the successor // that will be picked up when this thread releases the monitor is an unmounted // virtual thread that cannot run due to having run out of carriers. Upon waking - // up, the thread will call reenter_internal() which will use timed-park in case + // up, the thread will call enter_internal(..., true) which will use timed-park in case // there is contention and there are still vthreads in the _entry_list. // If the target was interrupted or the wait timed-out at the same time, it could - // have reached reenter_internal and read a false value of has_unmounted_vthreads() + // have reached enter_internal and read a false value of has_unmounted_vthreads() // before we added it to the _entry_list above. To deal with that case, we set _do_timed_park - // which will be read by the target on the next loop iteration in reenter_internal. + // which will be read by the target on the next loop iteration in enter_internal. iterator->_do_timed_park = true; JavaThread* t = iterator->thread(); t->_ParkEvent->unpark(); @@ -2535,19 +2486,19 @@ bool ObjectMonitor::try_spin(JavaThread* current) { // ----------------------------------------------------------------------------- // wait_set management ... -ObjectWaiter::ObjectWaiter(JavaThread* current) { - _next = nullptr; - _prev = nullptr; - _thread = current; - _monitor = nullptr; - _notifier_tid = 0; - _recursions = 0; - TState = TS_RUN; - _is_wait = false; - _at_reenter = false; - _interrupted = false; - _do_timed_park = false; - _active = false; +ObjectWaiter::ObjectWaiter(JavaThread* current) + : _next(nullptr), + _prev(nullptr), + _thread(current), + _monitor(nullptr), + _notifier_tid(0), + _recursions(0), + TState(TS_RUN), + _is_wait(false), + _at_reenter(false), + _interrupted(false), + _do_timed_park(false), + _active(false) { } const char* ObjectWaiter::getTStateName(ObjectWaiter::TStates state) { diff --git a/src/hotspot/share/runtime/objectMonitor.hpp b/src/hotspot/share/runtime/objectMonitor.hpp index 574a652f230..842aa1b374e 100644 --- a/src/hotspot/share/runtime/objectMonitor.hpp +++ b/src/hotspot/share/runtime/objectMonitor.hpp @@ -217,6 +217,7 @@ class ObjectMonitor : public CHeapObj { static int Knob_SpinLimit; + static ByteSize object_offset() { return byte_offset_of(ObjectMonitor, _object); } static ByteSize metadata_offset() { return byte_offset_of(ObjectMonitor, _metadata); } static ByteSize owner_offset() { return byte_offset_of(ObjectMonitor, _owner); } static ByteSize recursions_offset() { return byte_offset_of(ObjectMonitor, _recursions); } @@ -393,8 +394,8 @@ class ObjectMonitor : public CHeapObj { bool notify_internal(JavaThread* current); ObjectWaiter* dequeue_waiter(); void dequeue_specific_waiter(ObjectWaiter* waiter); - void enter_internal(JavaThread* current); - void reenter_internal(JavaThread* current, ObjectWaiter* current_node); + void enter_internal(JavaThread* current, ObjectWaiter* current_node, bool reenter_path); + bool try_enter_fast(JavaThread* current, ObjectWaiter* current_node); void entry_list_build_dll(JavaThread* current); void unlink_after_acquire(JavaThread* current, ObjectWaiter* current_node); ObjectWaiter* entry_list_tail(JavaThread* current); diff --git a/src/hotspot/share/runtime/objectMonitorTable.cpp b/src/hotspot/share/runtime/objectMonitorTable.cpp index 9b522720a28..bc173992d7a 100644 --- a/src/hotspot/share/runtime/objectMonitorTable.cpp +++ b/src/hotspot/share/runtime/objectMonitorTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,278 +31,640 @@ #include "runtime/thread.hpp" #include "runtime/timerTrace.hpp" #include "runtime/trimNativeHeap.hpp" -#include "utilities/concurrentHashTableTasks.inline.hpp" +#include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" // ----------------------------------------------------------------------------- -// ConcurrentHashTable storing links from objects to ObjectMonitors +// Theory of operations -- Object Monitor Table: +// +// The OMT (Object Monitor Table) is a concurrent hash table specifically +// designed so that it (in the normal case) can be searched from C2 generated +// code. +// +// In its simplest form it consists of: +// 1. An array of pointers. +// 2. The size (capacity) of the array, which is always a power of two. +// +// When you want to find a monitor associated with an object, you extract the +// hash value of the object. Then calculate an index by taking the hash value +// and bit-wise AND it with the capacity mask (i.e., size-1) of the OMT. Now +// use that index into the OMT's array of pointers. If the pointer is non +// null, check if it's a monitor pointer that is associated with the object. +// If so you're done. If the pointer is non null, but associated with another +// object, you start looking at (index+1), (index+2) and so on, until you +// either find the correct monitor, or a null pointer. Finding a null pointer +// means that the monitor is simply not in the OMT. +// +// If the size of the pointer array is significantly larger than the number of +// pointers in it, the chance of finding the monitor at the hash index +// (without any further linear searching) is quite high. It is also straight +// forward to generate C2 code for this, which for the fast path doesn't +// contain any branching at all. See: C2_MacroAssembler::fast_lock(). +// +// When the number of monitors (pointers in the array) reaches above the +// allowed limit (defined by the GROW_LOAD_FACTOR symbol) we need to grow the +// table. +// +// A simple description of how growing the OMT is done, is to say that we +// allocate a new table (twice as large as the old one), and then copy all the +// old monitor pointers from the old table to the new. +// +// But since the OMT is a concurrent hash table and things need to work for +// other clients of the OMT while we grow it, it gets a bit more +// complicated. +// +// The new and (potentially several) old table(s) may exist at the same +// time. The newest is always called the "current", and the older ones are +// singly linked using a "prev" pointer. +// +// As soon as we have allocated and linked in the new "current" OMT, all new +// monitor pointers will be added to the new table. Effectively making the +// atomic switch from "old current" to "new current" a linearization point. +// +// After that we start to go through all the indexes in the old table. If the +// index is empty (the pointer is null) we put a "tombstone" into that index, +// which will prevent any future concurrent insert from ending up in that +// index. +// +// If the index contains a monitor pointer, we insert that monitor pointer +// into the OMT which can be considered as one generation newer. If the index +// contains a "removed" pointer, we just ignore it. +// +// We use special pointer values for "tombstone" and "removed". Any pointer +// that is not null, not a tombstone and not removed, is considered to be a +// pointer to a monitor. +// +// When all the monitor pointers from an old OMT have been transferred to the +// new OMT, the old table is unlinked. +// +// This copying from an old OMT to one generation newer OMT, will continue +// until all the monitor pointers from old OMTs have been transferred to the +// newest "current" OMT. +// +// The memory for old, unlinked OMTs will be freed after a thread-local +// handshake with all Java threads. +// +// Searching the OMT for a monitor pointer while there are several generations +// of the OMT, will start from the oldest OMT. +// +// A note about the GROW_LOAD_FACTOR: In order to guarantee that the add and +// search algorithms can't loop forever, we must make sure that there is at +// least one null pointer in the array to stop them from dead looping. +// Furthermore, when we grow the OMT, we must make sure that the new "current" +// can accommodate all the monitors from all older OMTs, while still being so +// sparsely populated that the C2 generated code will likely find what it's +// searching for at the hash index, without needing further linear searching. +// The grow load factor is set to 12.5%, which satisfies the above +// requirements. Don't change it for fun, it might backfire. +// ----------------------------------------------------------------------------- -using ConcurrentTable = ConcurrentHashTable; +Atomic ObjectMonitorTable::_curr; -static ConcurrentTable* _table = nullptr; -static volatile size_t _items_count = 0; -static size_t _table_size = 0; -static volatile bool _resize = false; +class ObjectMonitorTable::Table : public CHeapObj { + friend class ObjectMonitorTable; -class ObjectMonitorTableConfig : public AllStatic { - public: - using Value = ObjectMonitor*; - static uintx get_hash(Value const& value, bool* is_dead) { - return (uintx)value->hash(); - } - static void* allocate_node(void* context, size_t size, Value const& value) { - ObjectMonitorTable::inc_items_count(); - return AllocateHeap(size, mtObjectMonitor); - }; - static void free_node(void* context, void* memory, Value const& value) { - ObjectMonitorTable::dec_items_count(); - FreeHeap(memory); - } -}; + DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0); + const size_t _capacity_mask; // One less than its power-of-two capacity + Atomic _prev; // Set while growing/rebuilding + Atomic* _buckets; // The payload + DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(_capacity_mask) + sizeof(_prev) + sizeof(_buckets)); + Atomic _items_count; + DEFINE_PAD_MINUS_SIZE(2, DEFAULT_CACHE_LINE_SIZE, sizeof(_items_count)); -class Lookup : public StackObj { - oop _obj; - - public: - explicit Lookup(oop obj) : _obj(obj) {} - - uintx get_hash() const { - uintx hash = _obj->mark().hash(); - assert(hash != 0, "should have a hash"); - return hash; + static Entry as_entry(ObjectMonitor* monitor) { + Entry entry = static_cast((uintptr_t)monitor); + assert(entry >= Entry::below_is_special, "Must be! (entry: " PTR_FORMAT ")", intptr_t(entry)); + return entry; } - bool equals(ObjectMonitor** value) { - assert(*value != nullptr, "must be"); - return (*value)->object_refers_to(_obj); + static ObjectMonitor* as_monitor(Entry entry) { + assert(entry >= Entry::below_is_special, "Must be! (entry: " PTR_FORMAT ")", intptr_t(entry)); + return reinterpret_cast(entry); } - bool is_dead(ObjectMonitor** value) { - assert(*value != nullptr, "must be"); - return false; - } -}; - -class LookupMonitor : public StackObj { - ObjectMonitor* _monitor; - - public: - explicit LookupMonitor(ObjectMonitor* monitor) : _monitor(monitor) {} - - uintx get_hash() const { - return _monitor->hash(); + static Entry empty() { + return Entry::empty; } - bool equals(ObjectMonitor** value) { - return (*value) == _monitor; + static Entry tombstone() { + return Entry::tombstone; } - bool is_dead(ObjectMonitor** value) { - assert(*value != nullptr, "must be"); - return (*value)->object_is_dead(); + static Entry removed() { + return Entry::removed; } -}; -void ObjectMonitorTable::inc_items_count() { - AtomicAccess::inc(&_items_count, memory_order_relaxed); -} - -void ObjectMonitorTable::dec_items_count() { - AtomicAccess::dec(&_items_count, memory_order_relaxed); -} - -double ObjectMonitorTable::get_load_factor() { - size_t count = AtomicAccess::load(&_items_count); - return (double)count / (double)_table_size; -} - -size_t ObjectMonitorTable::table_size(Thread* current) { - return ((size_t)1) << _table->get_size_log2(current); -} - -size_t ObjectMonitorTable::max_log_size() { - // TODO[OMTable]: Evaluate the max size. - // TODO[OMTable]: Need to fix init order to use Universe::heap()->max_capacity(); - // Using MaxHeapSize directly this early may be wrong, and there - // are definitely rounding errors (alignment). - const size_t max_capacity = MaxHeapSize; - const size_t min_object_size = CollectedHeap::min_dummy_object_size() * HeapWordSize; - const size_t max_objects = max_capacity / MAX2(MinObjAlignmentInBytes, checked_cast(min_object_size)); - const size_t log_max_objects = log2i_graceful(max_objects); - - return MAX2(MIN2(SIZE_BIG_LOG2, log_max_objects), min_log_size()); -} - -// ~= log(AvgMonitorsPerThreadEstimate default) -size_t ObjectMonitorTable::min_log_size() { - return 10; -} - -template -size_t ObjectMonitorTable::clamp_log_size(V log_size) { - return MAX2(MIN2(log_size, checked_cast(max_log_size())), checked_cast(min_log_size())); -} - -size_t ObjectMonitorTable::initial_log_size() { - const size_t estimate = log2i(MAX2(os::processor_count(), 1)) + log2i(MAX2(AvgMonitorsPerThreadEstimate, size_t(1))); - return clamp_log_size(estimate); -} - -size_t ObjectMonitorTable::grow_hint() { - return ConcurrentTable::DEFAULT_GROW_HINT; -} - -void ObjectMonitorTable::create() { - _table = new ConcurrentTable(initial_log_size(), max_log_size(), grow_hint()); - _items_count = 0; - _table_size = table_size(Thread::current()); - _resize = false; -} - -void ObjectMonitorTable::verify_monitor_get_result(oop obj, ObjectMonitor* monitor) { -#ifdef ASSERT - if (SafepointSynchronize::is_at_safepoint()) { - bool has_monitor = obj->mark().has_monitor(); - assert(has_monitor == (monitor != nullptr), - "Inconsistency between markWord and ObjectMonitorTable has_monitor: %s monitor: " PTR_FORMAT, - BOOL_TO_STR(has_monitor), p2i(monitor)); - } -#endif -} - -ObjectMonitor* ObjectMonitorTable::monitor_get(Thread* current, oop obj) { - ObjectMonitor* result = nullptr; - Lookup lookup_f(obj); - auto found_f = [&](ObjectMonitor** found) { - assert((*found)->object_peek() == obj, "must be"); - result = *found; - }; - _table->get(current, lookup_f, found_f); - verify_monitor_get_result(obj, result); - return result; -} - -void ObjectMonitorTable::try_notify_grow() { - if (!_table->is_max_size_reached() && !AtomicAccess::load(&_resize)) { - AtomicAccess::store(&_resize, true); - if (Service_lock->try_lock()) { - Service_lock->notify(); - Service_lock->unlock(); + // Make sure we leave space for previous versions to relocate too. + bool try_inc_items_count() { + for (;;) { + size_t population = _items_count.load_relaxed(); + if (should_grow(population)) { + return false; + } + if (_items_count.compare_set(population, population + 1, memory_order_relaxed)) { + return true; + } } } -} -bool ObjectMonitorTable::should_grow() { - return get_load_factor() > GROW_LOAD_FACTOR && !_table->is_max_size_reached(); -} + double get_load_factor(size_t count) { + return (double)count / (double)capacity(); + } -bool ObjectMonitorTable::should_resize() { - return should_grow() || should_shrink() || AtomicAccess::load(&_resize); -} + void inc_items_count() { + _items_count.add_then_fetch(1u, memory_order_relaxed); + } -template -bool ObjectMonitorTable::run_task(JavaThread* current, Task& task, const char* task_name, Args&... args) { - if (task.prepare(current)) { - log_trace(monitortable)("Started to %s", task_name); - TraceTime timer(task_name, TRACETIME_LOG(Debug, monitortable, perf)); - while (task.do_task(current, args...)) { - task.pause(current); - { + void dec_items_count() { + _items_count.sub_then_fetch(1u, memory_order_relaxed); + } + +public: + Table(size_t capacity, Table* prev) + : _capacity_mask(capacity - 1), + _prev(prev), + _buckets(NEW_C_HEAP_ARRAY(Atomic, capacity, mtObjectMonitor)), + _items_count(0) + { + for (size_t i = 0; i < capacity; ++i) { + ::new (_buckets + i) Atomic(empty()); + } + } + + ~Table() { + FREE_C_HEAP_ARRAY(Atomic, _buckets); + } + + Table* prev() { + return _prev.load_relaxed(); + } + + size_t capacity() { + return _capacity_mask + 1; + } + + bool should_grow(size_t population) { + return get_load_factor(population) > GROW_LOAD_FACTOR; + } + + bool should_grow() { + return should_grow(_items_count.load_relaxed()); + } + + size_t total_items() { + size_t current_items = _items_count.load_relaxed(); + Table* prev = _prev.load_relaxed(); + if (prev != nullptr) { + return prev->total_items() + current_items; + } + return current_items; + } + + ObjectMonitor* get(oop obj, intptr_t hash) { + // Acquire tombstones and relocations in case prev transitioned to null + Table* prev = _prev.load_acquire(); + if (prev != nullptr) { + ObjectMonitor* result = prev->get(obj, hash); + if (result != nullptr) { + return result; + } + } + + const size_t start_index = size_t(hash) & _capacity_mask; + size_t index = start_index; + + for (;;) { + Atomic& bucket = _buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == tombstone() || entry == empty()) { + // Not found + break; + } + + if (entry != removed() && as_monitor(entry)->object_peek() == obj) { + // Found matching monitor. + return as_monitor(entry); + } + + index = (index + 1) & _capacity_mask; + assert(index != start_index, "invariant"); + } + + // Rebuilding could have started by now, but if a monitor has been inserted + // in a newer table, it was inserted after the get linearization point. + return nullptr; + } + + ObjectMonitor* prepare_insert(oop obj, intptr_t hash) { + // Acquire any tombstones and relocations if prev transitioned to null. + Table* prev = _prev.load_acquire(); + if (prev != nullptr) { + ObjectMonitor* result = prev->prepare_insert(obj, hash); + if (result != nullptr) { + return result; + } + } + + const size_t start_index = size_t(hash) & _capacity_mask; + size_t index = start_index; + + for (;;) { + Atomic& bucket = _buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == empty()) { + // Found an empty slot to install the new monitor in. + // To avoid concurrent inserts succeeding, place a tombstone here. + Entry result = bucket.compare_exchange(entry, tombstone(), memory_order_relaxed); + if (result == entry) { + // Success! Nobody will try to insert here again, except reinsert from rebuilding. + return nullptr; + } + entry = result; + } + + if (entry == tombstone()) { + // Can't insert into this table. + return nullptr; + } + + if (entry != removed() && as_monitor(entry)->object_peek() == obj) { + // Found matching monitor. + return as_monitor(entry); + } + + index = (index + 1) & _capacity_mask; + assert(index != start_index, "invariant"); + } + } + + ObjectMonitor* get_set(oop obj, Entry new_monitor, intptr_t hash) { + // Acquire any tombstones and relocations if prev transitioned to null. + Table* prev = _prev.load_acquire(); + if (prev != nullptr) { + // Sprinkle tombstones in previous tables to force concurrent inserters + // to the latest table. We only really want to try inserting in the + // latest table. + ObjectMonitor* result = prev->prepare_insert(obj, hash); + if (result != nullptr) { + return result; + } + } + + const size_t start_index = size_t(hash) & _capacity_mask; + size_t index = start_index; + + for (;;) { + Atomic& bucket = _buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == empty()) { + // Empty slot to install the new monitor + if (try_inc_items_count()) { + // Succeeding in claiming an item. + Entry result = bucket.compare_exchange(entry, new_monitor, memory_order_acq_rel); + if (result == entry) { + // Success - already incremented. + return as_monitor(new_monitor); + } + + // Something else was installed in place. + dec_items_count(); + entry = result; + } else { + // Out of allowance; leave space for rebuilding to succeed. + // To avoid concurrent inserts succeeding, place a tombstone here. + Entry result = bucket.compare_exchange(entry, tombstone(), memory_order_acq_rel); + if (result == entry) { + // Success; nobody will try to insert here again, except reinsert from rebuilding. + return nullptr; + } + entry = result; + } + } + + if (entry == tombstone()) { + // Can't insert into this table. + return nullptr; + } + + if (entry != removed() && as_monitor(entry)->object_peek() == obj) { + // Found matching monitor. + return as_monitor(entry); + } + + index = (index + 1) & _capacity_mask; + assert(index != start_index, "invariant"); + } + } + + void remove(oop obj, Entry old_monitor, intptr_t hash) { + assert(old_monitor >= Entry::below_is_special, + "Must be! (old_monitor: " PTR_FORMAT ")", intptr_t(old_monitor)); + + const size_t start_index = size_t(hash) & _capacity_mask; + size_t index = start_index; + + for (;;) { + Atomic& bucket = _buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == empty()) { + // The monitor does not exist in this table. + break; + } + + if (entry == tombstone()) { + // Stop searching at tombstones. + break; + } + + if (entry == old_monitor) { + // Found matching entry; remove it + bool result = bucket.compare_set(entry, removed(), memory_order_relaxed); + assert(result, "should not fail"); + break; + } + + index = (index + 1) & _capacity_mask; + assert(index != start_index, "invariant"); + } + + // Old versions are removed after newer versions to ensure that observing + // the monitor removed and then doing a subsequent lookup results in there + // still not being a monitor, instead of flickering back to being there. + // Only the deflation thread rebuilds and unlinks tables, so we do not need + // any concurrency safe prev read below. + if (_prev.load_relaxed() != nullptr) { + _prev.load_relaxed()->remove(obj, old_monitor, hash); + } + } + + void reinsert(oop obj, Entry new_monitor) { + intptr_t hash = obj->mark().hash(); + + const size_t start_index = size_t(hash) & _capacity_mask; + size_t index = start_index; + + for (;;) { + Atomic& bucket = _buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == empty()) { + // Empty slot to install the new monitor. + Entry result = bucket.compare_exchange(entry, new_monitor, memory_order_acq_rel); + if (result == entry) { + // Success - unconditionally increment. + inc_items_count(); + return; + } + + // Another monitor was installed. + entry = result; + } + + if (entry == tombstone()) { + // A concurrent inserter did not get enough allowance in the table. + // But reinsert always succeeds - we will take the spot. + Entry result = bucket.compare_exchange(entry, new_monitor, memory_order_acq_rel); + if (result == entry) { + // Success - unconditionally increment. + inc_items_count(); + return; + } + + // Another monitor was installed. + entry = result; + } + + if (entry == removed()) { + // A removed entry can be flipped back with reinsertion. + Entry result = bucket.compare_exchange(entry, new_monitor, memory_order_release); + if (result == entry) { + // Success - but don't increment; the initial entry did that for us. + return; + } + + // Another monitor was installed. + entry = result; + } + + assert(entry != empty(), "invariant"); + assert(entry != tombstone(), "invariant"); + assert(entry != removed(), "invariant"); + assert(as_monitor(entry)->object_peek() != obj, "invariant"); + index = (index + 1) & _capacity_mask; + assert(index != start_index, "invariant"); + } + } + + void rebuild() { + Table* prev = _prev.load_relaxed(); + if (prev == nullptr) { + // Base case for recursion - no previous version. + return; + } + + // Finish rebuilding up to prev as target so we can use prev as source. + prev->rebuild(); + + JavaThread* current = JavaThread::current(); + + // Relocate entries from prev. + for (size_t index = 0; index <= prev->_capacity_mask; index++) { + if ((index & 127) == 0) { + // Poll for safepoints to improve time to safepoint ThreadBlockInVM tbivm(current); } - task.cont(current); + + Atomic& bucket = prev->_buckets[index]; + Entry entry = bucket.load_acquire(); + + if (entry == empty()) { + // Empty slot; put a tombstone there. + Entry result = bucket.compare_exchange(entry, tombstone(), memory_order_acq_rel); + if (result == empty()) { + // Success; move to next entry. + continue; + } + + // Concurrent insert; relocate. + entry = result; + } + + if (entry != tombstone() && entry != removed()) { + // A monitor + ObjectMonitor* monitor = as_monitor(entry); + oop obj = monitor->object_peek(); + if (obj != nullptr) { + // In the current implementation the deflation thread drives + // the rebuilding, and it will already have removed any entry + // it has deflated. The assert is only here to make sure. + assert(!monitor->is_being_async_deflated(), "Should be"); + // Re-insert still live monitor. + reinsert(obj, entry); + } + } } - task.done(current); - return true; + + // Unlink this table, releasing the tombstones and relocations. + _prev.release_store(nullptr); } - return false; +}; + +void ObjectMonitorTable::create() { + _curr.store_relaxed(new Table(128, nullptr)); } -bool ObjectMonitorTable::grow(JavaThread* current) { - ConcurrentTable::GrowTask grow_task(_table); - if (run_task(current, grow_task, "Grow")) { - _table_size = table_size(current); - log_info(monitortable)("Grown to size: %zu", _table_size); - return true; +ObjectMonitor* ObjectMonitorTable::monitor_get(oop obj) { + const intptr_t hash = obj->mark().hash(); + Table* curr = _curr.load_acquire(); + ObjectMonitor* monitor = curr->get(obj, hash); + return monitor; +} + +// Returns a new table to try inserting into. +ObjectMonitorTable::Table* ObjectMonitorTable::grow_table(Table* curr) { + Table* result; + Table* new_table = _curr.load_acquire(); + if (new_table != curr) { + // Table changed; no need to try further + return new_table; } - return false; -} -bool ObjectMonitorTable::clean(JavaThread* current) { - ConcurrentTable::BulkDeleteTask clean_task(_table); - auto is_dead = [&](ObjectMonitor** monitor) { - return (*monitor)->object_is_dead(); - }; - auto do_nothing = [&](ObjectMonitor** monitor) {}; - NativeHeapTrimmer::SuspendMark sm("ObjectMonitorTable"); - return run_task(current, clean_task, "Clean", is_dead, do_nothing); -} + { + // Use MonitorDeflation_lock to only allow one inflating thread to + // attempt to allocate the new table. + MonitorLocker ml(MonitorDeflation_lock, Mutex::_no_safepoint_check_flag); -bool ObjectMonitorTable::resize(JavaThread* current) { - LogTarget(Info, monitortable) lt; - bool success = false; - - if (should_grow()) { - lt.print("Start growing with load factor %f", get_load_factor()); - success = grow(current); - } else { - if (!_table->is_max_size_reached() && AtomicAccess::load(&_resize)) { - lt.print("WARNING: Getting resize hints with load factor %f", get_load_factor()); + new_table = _curr.load_acquire(); + if (new_table != curr) { + // Table changed; no need to try further + return new_table; + } + + new_table = new Table(curr->capacity() << 1, curr); + result = _curr.compare_exchange(curr, new_table, memory_order_acq_rel); + if (result == curr) { + log_info(monitorinflation)("Growing object monitor table (capacity: %zu)", + new_table->capacity()); + // Since we grew the table (we have a new current) we need to + // notify the deflation thread to rebuild the table (to get rid of + // old currents). + ObjectSynchronizer::set_is_async_deflation_requested(true); + ml.notify_all(); + return new_table; } - lt.print("Start cleaning with load factor %f", get_load_factor()); - success = clean(current); } - AtomicAccess::store(&_resize, false); + // Somebody else started rebuilding; restart in their new table. + delete new_table; - return success; -} - -ObjectMonitor* ObjectMonitorTable::monitor_put_get(Thread* current, ObjectMonitor* monitor, oop obj) { - // Enter the monitor into the concurrent hashtable. - ObjectMonitor* result = monitor; - Lookup lookup_f(obj); - auto found_f = [&](ObjectMonitor** found) { - assert((*found)->object_peek() == obj, "must be"); - result = *found; - }; - bool grow; - _table->insert_get(current, lookup_f, monitor, found_f, &grow); - verify_monitor_get_result(obj, result); - if (grow) { - try_notify_grow(); - } return result; } -bool ObjectMonitorTable::remove_monitor_entry(Thread* current, ObjectMonitor* monitor) { - LookupMonitor lookup_f(monitor); - return _table->remove(current, lookup_f); -} +ObjectMonitor* ObjectMonitorTable::monitor_put_get(ObjectMonitor* monitor, oop obj) { + const intptr_t hash = obj->mark().hash(); + Table* curr = _curr.load_acquire(); -bool ObjectMonitorTable::contains_monitor(Thread* current, ObjectMonitor* monitor) { - LookupMonitor lookup_f(monitor); - bool result = false; - auto found_f = [&](ObjectMonitor** found) { - result = true; - }; - _table->get(current, lookup_f, found_f); - return result; -} - -void ObjectMonitorTable::print_on(outputStream* st) { - auto printer = [&] (ObjectMonitor** entry) { - ObjectMonitor* om = *entry; - oop obj = om->object_peek(); - st->print("monitor=" PTR_FORMAT ", ", p2i(om)); - st->print("object=" PTR_FORMAT, p2i(obj)); - assert(obj->mark().hash() == om->hash(), "hash must match"); - st->cr(); - return true; - }; - if (SafepointSynchronize::is_at_safepoint()) { - _table->do_safepoint_scan(printer); - } else { - _table->do_scan(Thread::current(), printer); + for (;;) { + // Curr is the latest table and is reasonably loaded. + ObjectMonitor* result = curr->get_set(obj, curr->as_entry(monitor), hash); + if (result != nullptr) { + return result; + } + // The table's limit was reached, we need to grow it. + curr = grow_table(curr); } } + +void ObjectMonitorTable::remove_monitor_entry(ObjectMonitor* monitor) { + oop obj = monitor->object_peek(); + if (obj == nullptr) { + // Defer removal until subsequent rebuilding. + return; + } + const intptr_t hash = obj->mark().hash(); + Table* curr = _curr.load_acquire(); + curr->remove(obj, curr->as_entry(monitor), hash); + assert(monitor_get(obj) != monitor, "should have been removed"); +} + +// Before handshake; rebuild and unlink tables. +void ObjectMonitorTable::rebuild(GrowableArray* delete_list) { + Table* new_table; + { + // Concurrent inserts while in the middle of rebuilding can result + // in the population count increasing past the load factor limit. + // For this to be okay we need to bound how much it may exceed the + // limit. A sequence of tables with doubling capacity may + // eventually, after rebuilding, reach the maximum population of + // max_population(table_1) + max_population(table_1*2) + ... + + // max_population(table_1*2^n). + // I.e. max_population(2*table_1 *2^n) - max_population(table_1). + // With a 12.5% load factor, the implication is that as long as + // rebuilding a table will double its capacity, the maximum load + // after rebuilding is less than 25%. However, we can't always + // double the size each time we rebuild the table. Instead we + // recursively estimate the population count of the chain of + // tables (the current, and all the previous currents). If the sum + // of the population is less than the growing factor, we do not + // need to grow the table. If the new concurrently rebuilding + // table is immediately filled up by concurrent inserts, then the + // worst case load factor after the rebuild may be twice as large, + // which is still guaranteed to be less than a 50% load. If this + // happens, it will cause subsequent rebuilds to increase the + // table capacity, keeping the worst case less than 50%, until the + // load factor eventually becomes less than 12.5% again. So in + // some sense this allows us to be fooled once, but not twice. So, + // given the growing threshold of 12.5%, it is impossible for the + // tables to reach a load factor above 50%. Which is more than + // enough to guarantee the function of this concurrent hash table. + Table* curr = _curr.load_acquire(); + size_t need_to_accomodate = curr->total_items(); + size_t new_capacity = curr->should_grow(need_to_accomodate) + ? curr->capacity() << 1 + : curr->capacity(); + new_table = new Table(new_capacity, curr); + Table* result = _curr.compare_exchange(curr, new_table, memory_order_acq_rel); + if (result != curr) { + // Somebody else racingly started rebuilding. Delete the + // new_table and treat somebody else's table as the new one. + delete new_table; + new_table = result; + } + log_info(monitorinflation)("Rebuilding object monitor table (capacity: %zu)", + new_table->capacity()); + } + + for (Table* curr = new_table->prev(); curr != nullptr; curr = curr->prev()) { + delete_list->append(curr); + } + + // Rebuild with the new table as target. + new_table->rebuild(); +} + +// After handshake; destroy old tables +void ObjectMonitorTable::destroy(GrowableArray* delete_list) { + for (ObjectMonitorTable::Table* table: *delete_list) { + delete table; + } +} + +address ObjectMonitorTable::current_table_address() { + return reinterpret_cast
(&_curr) + _curr.value_offset_in_bytes(); +} + +ByteSize ObjectMonitorTable::table_capacity_mask_offset() { + return byte_offset_of(Table, _capacity_mask); +} + +ByteSize ObjectMonitorTable::table_buckets_offset() { + // Assumptions made from the emitted code about the layout. + STATIC_ASSERT(sizeof(Atomic) == sizeof(Entry*)); + STATIC_ASSERT(Atomic::value_offset_in_bytes() == 0); + + return byte_offset_of(Table, _buckets); +} diff --git a/src/hotspot/share/runtime/objectMonitorTable.hpp b/src/hotspot/share/runtime/objectMonitorTable.hpp index 146468d46b2..1ec372883b2 100644 --- a/src/hotspot/share/runtime/objectMonitorTable.hpp +++ b/src/hotspot/share/runtime/objectMonitorTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,8 +27,11 @@ #include "memory/allStatic.hpp" #include "oops/oopsHierarchy.hpp" +#include "runtime/atomic.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/sizes.hpp" +template class GrowableArray; class JavaThread; class ObjectMonitor; class ObjectMonitorTableConfig; @@ -36,42 +39,39 @@ class outputStream; class Thread; class ObjectMonitorTable : AllStatic { - friend class ObjectMonitorTableConfig; + static constexpr double GROW_LOAD_FACTOR = 0.125; - private: - static void inc_items_count(); - static void dec_items_count(); - static double get_load_factor(); - static size_t table_size(Thread* current); - static size_t max_log_size(); - static size_t min_log_size(); +public: + class Table; - template - static size_t clamp_log_size(V log_size); - static size_t initial_log_size(); - static size_t grow_hint(); +private: + static Atomic _curr; + static Table* grow_table(Table* curr); + + enum class Entry : uintptr_t { + empty = 0, + tombstone = 1, + removed = 2, + below_is_special = (removed + 1) + }; + +public: + typedef enum { + // Used in the platform code. See: C2_MacroAssembler::fast_lock(). + below_is_special = (int)Entry::below_is_special + } SpecialPointerValues; - public: static void create(); - static void verify_monitor_get_result(oop obj, ObjectMonitor* monitor); - static ObjectMonitor* monitor_get(Thread* current, oop obj); - static void try_notify_grow(); - static bool should_shrink() { return false; } // Not implemented + static ObjectMonitor* monitor_get(oop obj); + static ObjectMonitor* monitor_put_get(ObjectMonitor* monitor, oop obj); + static void rebuild(GrowableArray* delete_list); + static void destroy(GrowableArray* delete_list); + static void remove_monitor_entry(ObjectMonitor* monitor); - static constexpr double GROW_LOAD_FACTOR = 0.75; - - static bool should_grow(); - static bool should_resize(); - - template - static bool run_task(JavaThread* current, Task& task, const char* task_name, Args&... args); - static bool grow(JavaThread* current); - static bool clean(JavaThread* current); - static bool resize(JavaThread* current); - static ObjectMonitor* monitor_put_get(Thread* current, ObjectMonitor* monitor, oop obj); - static bool remove_monitor_entry(Thread* current, ObjectMonitor* monitor); - static bool contains_monitor(Thread* current, ObjectMonitor* monitor); - static void print_on(outputStream* st); + // Compiler support + static address current_table_address(); + static ByteSize table_capacity_mask_offset(); + static ByteSize table_buckets_offset(); }; #endif // SHARE_RUNTIME_OBJECTMONITORTABLE_HPP diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 58774e59a34..d55cf454256 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -1285,7 +1285,7 @@ void os::print_location(outputStream* st, intptr_t x, bool verbose) { bool accessible = is_readable_pointer(addr); // Check if addr points into the narrow Klass protection zone - if (UseCompressedClassPointers && CompressedKlassPointers::is_in_protection_zone(addr)) { + if (CompressedKlassPointers::is_in_protection_zone(addr)) { st->print_cr(PTR_FORMAT " points into nKlass protection zone", p2i(addr)); return; } @@ -1339,8 +1339,9 @@ void os::print_location(outputStream* st, intptr_t x, bool verbose) { } // Compressed klass needs to be decoded first. + // Todo: questionable for COH - can we do this better? #ifdef _LP64 - if (UseCompressedClassPointers && ((uintptr_t)addr &~ (uintptr_t)max_juint) == 0) { + if (((uintptr_t)addr &~ (uintptr_t)max_juint) == 0) { narrowKlass narrow_klass = (narrowKlass)(uintptr_t)addr; Klass* k = CompressedKlassPointers::decode_without_asserts(narrow_klass); @@ -1912,17 +1913,7 @@ void os::trace_page_sizes_for_requested_size(const char* str, // as was done for logical processors here, or replicate and // specialize this method for each platform. (Or fix os to have // some inheritance structure and use subclassing. Sigh.) -// If you want some platform to always or never behave as a server -// class machine, change the setting of AlwaysActAsServerClassMachine -// and NeverActAsServerClassMachine in globals*.hpp. bool os::is_server_class_machine() { - // First check for the early returns - if (NeverActAsServerClassMachine) { - return false; - } - if (AlwaysActAsServerClassMachine) { - return true; - } // Then actually look at the machine bool result = false; const unsigned int server_processors = 2; @@ -2312,24 +2303,13 @@ void os::uncommit_memory(char* addr, size_t bytes, bool executable) { log_debug(os, map)("Uncommitted " RANGEFMT, RANGEFMTARGS(addr, bytes)); } -// The scope of NmtVirtualMemoryLocker covers both pd_release_memory and record_virtual_memory_release because -// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. -// We do not have the same lock protection for pd_reserve_memory and record_virtual_memory_reserve. -// We assume that there is some external synchronization that prevents a region from being released -// before it is finished being reserved. +// pd_release_memory is called outside the protection of the NMT lock. +// Until pd_release_memory is called, The OS is unable to give away the about-to-be-released range to another thread. +// So there is no risk of another thread re-reserving the range before this function is done with it. void os::release_memory(char* addr, size_t bytes) { assert_nonempty_range(addr, bytes); - bool res; - if (MemTracker::enabled()) { - MemTracker::NmtVirtualMemoryLocker nvml; - res = pd_release_memory(addr, bytes); - if (res) { - MemTracker::record_virtual_memory_release(addr, bytes); - } - } else { - res = pd_release_memory(addr, bytes); - } - if (!res) { + MemTracker::record_virtual_memory_release(addr, bytes); + if (!pd_release_memory(addr, bytes)) { fatal("Failed to release " RANGEFMT, RANGEFMTARGS(addr, bytes)); } log_debug(os, map)("Released " RANGEFMT, RANGEFMTARGS(addr, bytes)); @@ -2402,17 +2382,8 @@ char* os::map_memory(int fd, const char* file_name, size_t file_offset, } void os::unmap_memory(char *addr, size_t bytes) { - bool result; - if (MemTracker::enabled()) { - MemTracker::NmtVirtualMemoryLocker nvml; - result = pd_unmap_memory(addr, bytes); - if (result) { - MemTracker::record_virtual_memory_release(addr, bytes); - } - } else { - result = pd_unmap_memory(addr, bytes); - } - if (!result) { + MemTracker::record_virtual_memory_release(addr, bytes); + if (!pd_unmap_memory(addr, bytes)) { fatal("Failed to unmap memory " RANGEFMT, RANGEFMTARGS(addr, bytes)); } } @@ -2442,22 +2413,6 @@ char* os::reserve_memory_special(size_t size, size_t alignment, size_t page_size return result; } -void os::release_memory_special(char* addr, size_t bytes) { - bool res; - if (MemTracker::enabled()) { - MemTracker::NmtVirtualMemoryLocker nvml; - res = pd_release_memory_special(addr, bytes); - if (res) { - MemTracker::record_virtual_memory_release(addr, bytes); - } - } else { - res = pd_release_memory_special(addr, bytes); - } - if (!res) { - fatal("Failed to release memory special " RANGEFMT, RANGEFMTARGS(addr, bytes)); - } -} - // Convenience wrapper around naked_short_sleep to allow for longer sleep // times. Only for use by non-JavaThreads. void os::naked_sleep(jlong millis) { diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index e773b40cb14..c883b828456 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -245,9 +245,7 @@ class os: AllStatic { static size_t pd_pretouch_memory(void* first, void* last, size_t page_size); static char* pd_reserve_memory_special(size_t size, size_t alignment, size_t page_size, - char* addr, bool executable); - static bool pd_release_memory_special(char* addr, size_t bytes); static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned); @@ -456,7 +454,7 @@ class os: AllStatic { static size_t align_down_vm_page_size(size_t size) { return align_down(size, os::vm_page_size()); } // The set of page sizes which the VM is allowed to use (may be a subset of - // the page sizes actually available on the platform). + // the page sizes actually available on the platform). static const PageSizes& page_sizes() { return _page_sizes; } // Returns the page size to use for a region of memory. @@ -605,7 +603,6 @@ class os: AllStatic { // reserve, commit and pin the entire memory region static char* reserve_memory_special(size_t size, size_t alignment, size_t page_size, char* addr, bool executable); - static void release_memory_special(char* addr, size_t bytes); static void large_page_init(); static size_t large_page_size(); static bool can_commit_large_page_memory(); @@ -724,6 +721,8 @@ class os: AllStatic { static int open(const char *path, int oflag, int mode); static FILE* fdopen(int fd, const char* mode); static FILE* fopen(const char* path, const char* mode); + static int64_t ftell(FILE* file); + static int fseek(FILE* file, int64_t offset, int whence); static jlong lseek(int fd, jlong offset, int whence); static bool file_exists(const char* file); @@ -896,6 +895,9 @@ class os: AllStatic { static void print_date_and_time(outputStream* st, char* buf, size_t buflen); static void print_elapsed_time(outputStream* st, double time); + // Prints the number of open file descriptors for the current process + static void print_open_file_descriptors(outputStream* st); + static void print_user_info(outputStream* st); static void print_active_locale(outputStream* st); diff --git a/src/hotspot/share/runtime/perfData.hpp b/src/hotspot/share/runtime/perfData.hpp index ca1f1f410ad..d910f8662fe 100644 --- a/src/hotspot/share/runtime/perfData.hpp +++ b/src/hotspot/share/runtime/perfData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -716,7 +716,7 @@ class PerfDataManager : AllStatic { // Utility Classes /* - * this class will administer a PerfCounter used as a time accumulator + * This class will administer a PerfCounter used as a time accumulator * for a basic block much like the TraceTime class. * * Example: @@ -731,6 +731,9 @@ class PerfDataManager : AllStatic { * Note: use of this class does not need to occur within a guarded * block. The UsePerfData guard is used with the implementation * of this class. + * + * But also note this class does not guard against shutdown races - + * see SafePerfTraceTime below. */ class PerfTraceTime : public StackObj { @@ -756,6 +759,26 @@ class PerfTraceTime : public StackObj { } }; +/* A variant of PerfTraceTime that guards against use during shutdown - + * see PerfDataManager::destroy. + */ +class SafePerfTraceTime : public StackObj { + + protected: + elapsedTimer _t; + PerfLongCounter* _timerp; + + public: + inline SafePerfTraceTime(PerfLongCounter* timerp); + + const char* name() const { + assert(_timerp != nullptr, "sanity"); + return _timerp->name(); + } + + inline ~SafePerfTraceTime(); +}; + /* The PerfTraceTimedEvent class is responsible for counting the * occurrence of some event and measuring the elapsed time of * the event in two separate PerfCounter instances. diff --git a/src/hotspot/share/runtime/perfData.inline.hpp b/src/hotspot/share/runtime/perfData.inline.hpp index 5212691b924..ca0b27e25bc 100644 --- a/src/hotspot/share/runtime/perfData.inline.hpp +++ b/src/hotspot/share/runtime/perfData.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,6 +27,7 @@ #include "runtime/perfData.hpp" +#include "utilities/globalCounter.inline.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" @@ -50,4 +51,23 @@ inline bool PerfDataManager::exists(const char* name) { } } +inline SafePerfTraceTime::SafePerfTraceTime(PerfLongCounter* timerp) : _timerp(timerp) { + GlobalCounter::CriticalSection cs(Thread::current()); + if (!UsePerfData || !PerfDataManager::has_PerfData() || timerp == nullptr) { + return; + } + _t.start(); +} + +inline SafePerfTraceTime::~SafePerfTraceTime() { + GlobalCounter::CriticalSection cs(Thread::current()); + if (!UsePerfData || !PerfDataManager::has_PerfData() || !_t.is_active()) { + return; + } + + _t.stop(); + _timerp->inc(_t.ticks()); +} + + #endif // SHARE_RUNTIME_PERFDATA_INLINE_HPP diff --git a/src/hotspot/share/runtime/serviceThread.cpp b/src/hotspot/share/runtime/serviceThread.cpp index 27958885a7f..95e672984fa 100644 --- a/src/hotspot/share/runtime/serviceThread.cpp +++ b/src/hotspot/share/runtime/serviceThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -85,7 +85,6 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { bool cldg_cleanup_work = false; bool jvmti_tagmap_work = false; bool oopmap_cache_work = false; - bool object_monitor_table_work = false; { // Need state transition ThreadBlockInVM so that this thread // will be handled by safepoint correctly when this thread is @@ -112,8 +111,7 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { (oop_handles_to_release = JavaThread::has_oop_handles_to_release()) | (cldg_cleanup_work = ClassLoaderDataGraph::should_clean_metaspaces_and_reset()) | (jvmti_tagmap_work = JvmtiTagMap::has_object_free_events_and_reset()) | - (oopmap_cache_work = OopMapCache::has_cleanup_work()) | - (object_monitor_table_work = ObjectSynchronizer::needs_resize()) + (oopmap_cache_work = OopMapCache::has_cleanup_work()) ) == 0) { // Wait until notified that there is some work to do or timer expires. // Some cleanup requests don't notify the ServiceThread so work needs to be done at periodic intervals. @@ -171,10 +169,6 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { if (oopmap_cache_work) { OopMapCache::cleanup(); } - - if (object_monitor_table_work) { - ObjectSynchronizer::resize_table(jt); - } } } diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index ae3835dd344..917ff5b4545 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -82,6 +82,7 @@ #include "utilities/copy.hpp" #include "utilities/dtrace.hpp" #include "utilities/events.hpp" +#include "utilities/exceptions.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/hashTable.hpp" #include "utilities/macros.hpp" @@ -931,7 +932,7 @@ void SharedRuntime::throw_StackOverflowError_common(JavaThread* current, bool de // bindings. current->clear_scopedValueBindings(); // Increment counter for hs_err file reporting - AtomicAccess::inc(&Exceptions::_stack_overflow_errors); + Exceptions::increment_stack_overflow_errors(); throw_and_post_jvmti_exception(current, exception); } diff --git a/src/hotspot/share/runtime/stubDeclarations.hpp b/src/hotspot/share/runtime/stubDeclarations.hpp index c478eda3e7c..7dc0f2d2bed 100644 --- a/src/hotspot/share/runtime/stubDeclarations.hpp +++ b/src/hotspot/share/runtime/stubDeclarations.hpp @@ -667,16 +667,6 @@ do_entry(initial, dcbrt, dcbrt, dcbrt) \ do_stub(initial, fmod) \ do_entry(initial, fmod, fmod, fmod) \ - /* following generic entries should really be x86_32 only */ \ - do_stub(initial, dlibm_sin_cos_huge) \ - do_entry(initial, dlibm_sin_cos_huge, dlibm_sin_cos_huge, \ - dlibm_sin_cos_huge) \ - do_stub(initial, dlibm_reduce_pi04l) \ - do_entry(initial, dlibm_reduce_pi04l, dlibm_reduce_pi04l, \ - dlibm_reduce_pi04l) \ - do_stub(initial, dlibm_tan_cot_huge) \ - do_entry(initial, dlibm_tan_cot_huge, dlibm_tan_cot_huge, \ - dlibm_tan_cot_huge) \ /* merge in stubs and entries declared in arch header */ \ STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, do_arch_blob, \ do_arch_entry, do_arch_entry_init) \ diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp index 5246613738e..56d832d3fef 100644 --- a/src/hotspot/share/runtime/stubRoutines.cpp +++ b/src/hotspot/share/runtime/stubRoutines.cpp @@ -219,12 +219,12 @@ static BufferBlob* initialize_stubs(BlobId blob_id, if (STUBGEN_BLOB_FIELD_NAME(blob_name) == nullptr) { \ BlobId blob_id = BlobId:: JOIN3(stubgen, blob_name, id); \ int size = _ ## blob_name ## _code_size; \ - int max_aligned_size = 10; \ + int max_aligned_stubs = StubInfo::stub_count(blob_id); \ const char* timer_msg = "StubRoutines generation " # blob_name " stubs"; \ const char* name = "StubRoutines (" # blob_name " stubs)"; \ const char* assert_msg = "_" # blob_name "_code_size"; \ STUBGEN_BLOB_FIELD_NAME(blob_name) = \ - initialize_stubs(blob_id, size, max_aligned_size, timer_msg, \ + initialize_stubs(blob_id, size, max_aligned_stubs, timer_msg, \ name, assert_msg); \ } \ } diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index fde1aa50400..e3293f94eeb 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -350,7 +350,7 @@ bool ObjectSynchronizer::quick_notify(oopDesc* obj, JavaThread* current, bool al } if (mark.has_monitor()) { - ObjectMonitor* const mon = read_monitor(current, obj, mark); + ObjectMonitor* const mon = read_monitor(obj, mark); if (mon == nullptr) { // Racing with inflation/deflation go slow path return false; @@ -485,7 +485,7 @@ ObjectLocker::ObjectLocker(Handle obj, TRAPS) : _thread(THREAD), _obj(obj), // otherwise just force other vthreads to preempt in case they try // to acquire this monitor. _skip_exit = !_thread->preemption_cancelled(); - ObjectSynchronizer::read_monitor(_thread, _obj())->set_object_strong(); + ObjectSynchronizer::read_monitor(_obj())->set_object_strong(); _thread->set_pending_preempted_exception(); } @@ -502,7 +502,7 @@ void ObjectLocker::wait_uninterruptibly(TRAPS) { ObjectSynchronizer::waitUninterruptibly(_obj, 0, _thread); if (_thread->preempting()) { _skip_exit = true; - ObjectSynchronizer::read_monitor(_thread, _obj())->set_object_strong(); + ObjectSynchronizer::read_monitor(_obj())->set_object_strong(); _thread->set_pending_preempted_exception(); } } @@ -749,7 +749,7 @@ bool ObjectSynchronizer::current_thread_holds_lock(JavaThread* current, } while (mark.has_monitor()) { - ObjectMonitor* monitor = read_monitor(current, obj, mark); + ObjectMonitor* monitor = read_monitor(obj, mark); if (monitor != nullptr) { return monitor->is_entered(current) != 0; } @@ -778,7 +778,7 @@ JavaThread* ObjectSynchronizer::get_lock_owner(ThreadsList * t_list, Handle h_ob } while (mark.has_monitor()) { - ObjectMonitor* monitor = read_monitor(Thread::current(), obj, mark); + ObjectMonitor* monitor = read_monitor(obj, mark); if (monitor != nullptr) { return Threads::owning_thread_from_monitor(t_list, monitor); } @@ -1195,13 +1195,10 @@ size_t ObjectSynchronizer::deflate_idle_monitors() { GrowableArray delete_list((int)deflated_count); unlinked_count = _in_use_list.unlink_deflated(deflated_count, &delete_list, &safepointer); -#ifdef ASSERT + GrowableArray table_delete_list; if (UseObjectMonitorTable) { - for (ObjectMonitor* monitor : delete_list) { - assert(!ObjectSynchronizer::contains_monitor(current, monitor), "Should have been removed"); - } + ObjectMonitorTable::rebuild(&table_delete_list); } -#endif log.before_handshake(unlinked_count); @@ -1222,6 +1219,9 @@ size_t ObjectSynchronizer::deflate_idle_monitors() { // Delete the unlinked ObjectMonitors. deleted_count = delete_monitors(&delete_list, &safepointer); + if (UseObjectMonitorTable) { + ObjectMonitorTable::destroy(&table_delete_list); + } assert(unlinked_count == deleted_count, "must be"); } @@ -1416,7 +1416,11 @@ void ObjectSynchronizer::chk_in_use_entry(ObjectMonitor* n, outputStream* out, } const markWord mark = obj->mark(); - if (!mark.has_monitor()) { + // Note: When using ObjectMonitorTable we may observe an intermediate state, + // where the monitor is globally visible, but no thread has yet transitioned + // the markWord. To avoid reporting a false positive during this transition, we + // skip the `!mark.has_monitor()` test if we are using the ObjectMonitorTable. + if (!UseObjectMonitorTable && !mark.has_monitor()) { out->print_cr("ERROR: monitor=" INTPTR_FORMAT ": in-use monitor's " "object does not think it has a monitor: obj=" INTPTR_FORMAT ", mark=" INTPTR_FORMAT, p2i(n), @@ -1425,7 +1429,7 @@ void ObjectSynchronizer::chk_in_use_entry(ObjectMonitor* n, outputStream* out, return; } - ObjectMonitor* const obj_mon = read_monitor(Thread::current(), obj, mark); + ObjectMonitor* const obj_mon = read_monitor(obj, mark); if (n != obj_mon) { out->print_cr("ERROR: monitor=" INTPTR_FORMAT ": in-use monitor's " "object does not refer to the same monitor: obj=" @@ -1471,8 +1475,8 @@ void ObjectSynchronizer::log_in_use_monitor_details(outputStream* out, bool log_ out->flush(); } -ObjectMonitor* ObjectSynchronizer::get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted) { - ObjectMonitor* monitor = get_monitor_from_table(current, object); +ObjectMonitor* ObjectSynchronizer::get_or_insert_monitor_from_table(oop object, bool* inserted) { + ObjectMonitor* monitor = get_monitor_from_table(object); if (monitor != nullptr) { *inserted = false; return monitor; @@ -1482,7 +1486,7 @@ ObjectMonitor* ObjectSynchronizer::get_or_insert_monitor_from_table(oop object, alloced_monitor->set_anonymous_owner(); // Try insert monitor - monitor = add_monitor(current, alloced_monitor, object); + monitor = add_monitor(alloced_monitor, object); *inserted = alloced_monitor == monitor; if (!*inserted) { @@ -1522,7 +1526,7 @@ ObjectMonitor* ObjectSynchronizer::get_or_insert_monitor(oop object, JavaThread* EventJavaMonitorInflate event; bool inserted; - ObjectMonitor* monitor = get_or_insert_monitor_from_table(object, current, &inserted); + ObjectMonitor* monitor = get_or_insert_monitor_from_table(object, &inserted); if (inserted) { log_inflate(current, object, cause); @@ -1538,7 +1542,7 @@ ObjectMonitor* ObjectSynchronizer::get_or_insert_monitor(oop object, JavaThread* } // Add the hashcode to the monitor to match the object and put it in the hashtable. -ObjectMonitor* ObjectSynchronizer::add_monitor(JavaThread* current, ObjectMonitor* monitor, oop obj) { +ObjectMonitor* ObjectSynchronizer::add_monitor(ObjectMonitor* monitor, oop obj) { assert(UseObjectMonitorTable, "must be"); assert(obj == monitor->object(), "must be"); @@ -1546,14 +1550,14 @@ ObjectMonitor* ObjectSynchronizer::add_monitor(JavaThread* current, ObjectMonito assert(hash != 0, "must be set when claiming the object monitor"); monitor->set_hash(hash); - return ObjectMonitorTable::monitor_put_get(current, monitor, obj); + return ObjectMonitorTable::monitor_put_get(monitor, obj); } -bool ObjectSynchronizer::remove_monitor(Thread* current, ObjectMonitor* monitor, oop obj) { +void ObjectSynchronizer::remove_monitor(ObjectMonitor* monitor, oop obj) { assert(UseObjectMonitorTable, "must be"); assert(monitor->object_peek() == obj, "must be, cleared objects are removed by is_dead"); - return ObjectMonitorTable::remove_monitor_entry(current, monitor); + ObjectMonitorTable::remove_monitor_entry(monitor); } void ObjectSynchronizer::deflate_mark_word(oop obj) { @@ -1575,20 +1579,6 @@ void ObjectSynchronizer::create_om_table() { ObjectMonitorTable::create(); } -bool ObjectSynchronizer::needs_resize() { - if (!UseObjectMonitorTable) { - return false; - } - return ObjectMonitorTable::should_resize(); -} - -bool ObjectSynchronizer::resize_table(JavaThread* current) { - if (!UseObjectMonitorTable) { - return true; - } - return ObjectMonitorTable::resize(current); -} - class ObjectSynchronizer::LockStackInflateContendedLocks : private OopClosure { private: oop _contended_oops[LockStack::CAPACITY]; @@ -1735,7 +1725,7 @@ bool ObjectSynchronizer::fast_lock_spin_enter(oop obj, LockStack& lock_stack, Ja return true; } else if (observed_deflation) { // Spin while monitor is being deflated. - ObjectMonitor* monitor = ObjectSynchronizer::read_monitor(current, obj, mark); + ObjectMonitor* monitor = ObjectSynchronizer::read_monitor(obj, mark); return monitor == nullptr || monitor->is_being_async_deflated(); } // Else stop spinning. @@ -1895,7 +1885,7 @@ void ObjectSynchronizer::exit(oop object, BasicLock* lock, JavaThread* current) if (UseObjectMonitorTable) { monitor = read_caches(current, lock, object); if (monitor == nullptr) { - monitor = get_monitor_from_table(current, object); + monitor = get_monitor_from_table(object); } } else { monitor = ObjectSynchronizer::read_monitor(mark); @@ -1939,7 +1929,7 @@ ObjectMonitor* ObjectSynchronizer::inflate_locked_or_imse(oop obj, ObjectSynchro } assert(mark.has_monitor(), "must be"); - ObjectMonitor* monitor = ObjectSynchronizer::read_monitor(current, obj, mark); + ObjectMonitor* monitor = ObjectSynchronizer::read_monitor(obj, mark); if (monitor != nullptr) { if (monitor->has_anonymous_owner()) { LockStack& lock_stack = current->lock_stack(); @@ -2101,7 +2091,7 @@ ObjectMonitor* ObjectSynchronizer::inflate_fast_locked_object(oop object, Object // contains a deflating monitor it must be anonymously owned. if (monitor->has_anonymous_owner()) { // The monitor must be anonymously owned if it was added - assert(monitor == get_monitor_from_table(current, object), "The monitor must be found"); + assert(monitor == get_monitor_from_table(object), "The monitor must be found"); // New fresh monitor break; } @@ -2293,39 +2283,31 @@ ObjectMonitor* ObjectSynchronizer::inflate_and_enter(oop object, BasicLock* lock return monitor; } -void ObjectSynchronizer::deflate_monitor(Thread* current, oop obj, ObjectMonitor* monitor) { +void ObjectSynchronizer::deflate_monitor(oop obj, ObjectMonitor* monitor) { if (obj != nullptr) { deflate_mark_word(obj); - } - bool removed = remove_monitor(current, monitor, obj); - if (obj != nullptr) { - assert(removed, "Should have removed the entry if obj was alive"); + remove_monitor(monitor, obj); } } -ObjectMonitor* ObjectSynchronizer::get_monitor_from_table(Thread* current, oop obj) { +ObjectMonitor* ObjectSynchronizer::get_monitor_from_table(oop obj) { assert(UseObjectMonitorTable, "must be"); - return ObjectMonitorTable::monitor_get(current, obj); -} - -bool ObjectSynchronizer::contains_monitor(Thread* current, ObjectMonitor* monitor) { - assert(UseObjectMonitorTable, "must be"); - return ObjectMonitorTable::contains_monitor(current, monitor); + return ObjectMonitorTable::monitor_get(obj); } ObjectMonitor* ObjectSynchronizer::read_monitor(markWord mark) { return mark.monitor(); } -ObjectMonitor* ObjectSynchronizer::read_monitor(Thread* current, oop obj) { - return ObjectSynchronizer::read_monitor(current, obj, obj->mark()); +ObjectMonitor* ObjectSynchronizer::read_monitor(oop obj) { + return ObjectSynchronizer::read_monitor(obj, obj->mark()); } -ObjectMonitor* ObjectSynchronizer::read_monitor(Thread* current, oop obj, markWord mark) { +ObjectMonitor* ObjectSynchronizer::read_monitor(oop obj, markWord mark) { if (!UseObjectMonitorTable) { return read_monitor(mark); } else { - return ObjectSynchronizer::get_monitor_from_table(current, obj); + return ObjectSynchronizer::get_monitor_from_table(obj); } } diff --git a/src/hotspot/share/runtime/synchronizer.hpp b/src/hotspot/share/runtime/synchronizer.hpp index a10e44b3092..58d0e88a026 100644 --- a/src/hotspot/share/runtime/synchronizer.hpp +++ b/src/hotspot/share/runtime/synchronizer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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,8 +126,8 @@ public: static const char* inflate_cause_name(const InflateCause cause); static ObjectMonitor* read_monitor(markWord mark); - static ObjectMonitor* read_monitor(Thread* current, oop obj); - static ObjectMonitor* read_monitor(Thread* current, oop obj, markWord mark); + static ObjectMonitor* read_monitor(oop obj); + static ObjectMonitor* read_monitor(oop obj, markWord mark); // Returns the identity hash value for an oop // NOTE: It may cause monitor inflation @@ -209,11 +209,11 @@ public: static void handle_sync_on_value_based_class(Handle obj, JavaThread* locking_thread); - static ObjectMonitor* get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted); + static ObjectMonitor* get_or_insert_monitor_from_table(oop object, bool* inserted); static ObjectMonitor* get_or_insert_monitor(oop object, JavaThread* current, ObjectSynchronizer::InflateCause cause); - static ObjectMonitor* add_monitor(JavaThread* current, ObjectMonitor* monitor, oop obj); - static bool remove_monitor(Thread* current, ObjectMonitor* monitor, oop obj); + static ObjectMonitor* add_monitor(ObjectMonitor* monitor, oop obj); + static void remove_monitor(ObjectMonitor* monitor, oop obj); static void deflate_mark_word(oop object); @@ -239,9 +239,9 @@ public: static ObjectMonitor* inflate_fast_locked_object(oop object, ObjectSynchronizer::InflateCause cause, JavaThread* locking_thread, JavaThread* current); static ObjectMonitor* inflate_and_enter(oop object, BasicLock* lock, ObjectSynchronizer::InflateCause cause, JavaThread* locking_thread, JavaThread* current); - static void deflate_monitor(Thread* current, oop obj, ObjectMonitor* monitor); + static void deflate_monitor(oop obj, ObjectMonitor* monitor); - static ObjectMonitor* get_monitor_from_table(Thread* current, oop obj); + static ObjectMonitor* get_monitor_from_table(oop obj); static bool contains_monitor(Thread* current, ObjectMonitor* monitor); diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index f27d355f56e..6de56c30d5f 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -485,8 +485,8 @@ void Thread::print_on(outputStream* st, bool print_extended_info) const { (double)_statistical_info.getElapsedTime() / 1000.0 ); if (is_Java_thread() && (PrintExtendedThreadInfo || print_extended_info)) { - size_t allocated_bytes = checked_cast(cooked_allocated_bytes()); - st->print("allocated=%zu%s ", + uint64_t allocated_bytes = cooked_allocated_bytes(); + st->print("allocated=" UINT64_FORMAT "%s ", byte_size_in_proper_unit(allocated_bytes), proper_unit_for_byte_size(allocated_bytes) ); diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 0225fa808cb..bef31a70170 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -257,7 +257,7 @@ class Thread: public ThreadShadow { private: ThreadLocalAllocBuffer _tlab; // Thread-local eden - jlong _allocated_bytes; // Cumulative number of bytes allocated on + uint64_t _allocated_bytes; // Cumulative number of bytes allocated on // the Java heap ThreadHeapSampler _heap_sampler; // For use when sampling the memory. @@ -410,9 +410,9 @@ class Thread: public ThreadShadow { void retire_tlab(ThreadLocalAllocStats* stats = nullptr); void fill_tlab(HeapWord* start, size_t pre_reserved, size_t new_size); - jlong allocated_bytes() { return _allocated_bytes; } - void incr_allocated_bytes(jlong size) { _allocated_bytes += size; } - inline jlong cooked_allocated_bytes() const; + uint64_t allocated_bytes() { return _allocated_bytes; } + void incr_allocated_bytes(uint64_t size) { _allocated_bytes += size; } + inline uint64_t cooked_allocated_bytes() const; ThreadHeapSampler& heap_sampler() { return _heap_sampler; } diff --git a/src/hotspot/share/runtime/thread.inline.hpp b/src/hotspot/share/runtime/thread.inline.hpp index d2ac34c3e46..b4cf3ec589a 100644 --- a/src/hotspot/share/runtime/thread.inline.hpp +++ b/src/hotspot/share/runtime/thread.inline.hpp @@ -36,8 +36,8 @@ #include "runtime/os.hpp" #endif -inline jlong Thread::cooked_allocated_bytes() const { - jlong allocated_bytes = AtomicAccess::load_acquire(&_allocated_bytes); +inline uint64_t Thread::cooked_allocated_bytes() const { + uint64_t allocated_bytes = AtomicAccess::load_acquire(&_allocated_bytes); size_t used_bytes = 0; if (UseTLAB) { // cooked_used_bytes() does its best to not return implausible values, but diff --git a/src/hotspot/share/runtime/threadSMR.cpp b/src/hotspot/share/runtime/threadSMR.cpp index 418f7707118..4c68648fec8 100644 --- a/src/hotspot/share/runtime/threadSMR.cpp +++ b/src/hotspot/share/runtime/threadSMR.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -726,7 +726,8 @@ JavaThread* ThreadsList::find_JavaThread_from_java_tid(jlong java_tid) const { } } } - } else if (!thread->is_exiting()) { + } else if (includes(thread) && !thread->is_exiting()) { + // The thread is protected by this list and has not yet exited return thread; } return nullptr; @@ -883,7 +884,7 @@ void ThreadsSMRSupport::add_thread(JavaThread *thread){ ThreadsList *old_list = xchg_java_thread_list(new_list); free_list(old_list); - if (ThreadIdTable::is_initialized()) { + if (ThreadIdTable::is_initialized_acquire()) { jlong tid = SharedRuntime::get_java_tid(thread); ThreadIdTable::add_thread(tid, thread); } diff --git a/src/hotspot/share/runtime/threadWXSetters.inline.hpp b/src/hotspot/share/runtime/threadWXSetters.inline.hpp index e7e37fcde1b..87f8d38e4dc 100644 --- a/src/hotspot/share/runtime/threadWXSetters.inline.hpp +++ b/src/hotspot/share/runtime/threadWXSetters.inline.hpp @@ -42,7 +42,7 @@ class ThreadWXEnable { public: ThreadWXEnable(WXMode* new_mode, Thread* thread) : _thread(thread), _this_wx_mode(new_mode) { - NOT_PRODUCT(PerfTraceTime ptt(ClassLoader::perf_change_wx_time());) + NOT_PRODUCT(SafePerfTraceTime ptt(ClassLoader::perf_change_wx_time());) JavaThread* javaThread = _thread && _thread->is_Java_thread() ? JavaThread::cast(_thread) : nullptr; @@ -55,7 +55,7 @@ public: } ThreadWXEnable(WXMode new_mode, Thread* thread) : _thread(thread), _this_wx_mode(nullptr) { - NOT_PRODUCT(PerfTraceTime ptt(ClassLoader::perf_change_wx_time());) + NOT_PRODUCT(SafePerfTraceTime ptt(ClassLoader::perf_change_wx_time());) JavaThread* javaThread = _thread && _thread->is_Java_thread() ? JavaThread::cast(_thread) : nullptr; @@ -68,7 +68,7 @@ public: } ~ThreadWXEnable() { - NOT_PRODUCT(PerfTraceTime ptt(ClassLoader::perf_change_wx_time());) + NOT_PRODUCT(SafePerfTraceTime ptt(ClassLoader::perf_change_wx_time());) if (_thread) { _thread->enable_wx(_old_mode); JavaThread* javaThread @@ -86,4 +86,3 @@ public: #endif // MACOS_AARCH64 #endif // SHARE_RUNTIME_THREADWXSETTERS_INLINE_HPP - diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp index f7f755a37b3..442b68e596a 100644 --- a/src/hotspot/share/runtime/threads.cpp +++ b/src/hotspot/share/runtime/threads.cpp @@ -1127,7 +1127,7 @@ void Threads::remove(JavaThread* p, bool is_daemon) { ConditionalMutexLocker throttle_ml(ThreadsLockThrottle_lock, UseThreadsLockThrottleLock); MonitorLocker ml(Threads_lock); - if (ThreadIdTable::is_initialized()) { + if (ThreadIdTable::is_initialized_acquire()) { // This cleanup must be done before the current thread's GC barrier // is detached since we need to touch the threadObj oop. jlong tid = SharedRuntime::get_java_tid(p); diff --git a/src/hotspot/share/runtime/vframe.cpp b/src/hotspot/share/runtime/vframe.cpp index 604ff1f751a..c9628255e45 100644 --- a/src/hotspot/share/runtime/vframe.cpp +++ b/src/hotspot/share/runtime/vframe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,7 +248,7 @@ void javaVFrame::print_lock_info_on(outputStream* st, bool is_virtual, int frame // The first stage of async deflation does not affect any field // used by this comparison so the ObjectMonitor* is usable here. if (mark.has_monitor()) { - ObjectMonitor* mon = ObjectSynchronizer::read_monitor(current, monitor->owner(), mark); + ObjectMonitor* mon = ObjectSynchronizer::read_monitor(monitor->owner(), mark); if (// if the monitor is null we must be in the process of locking mon == nullptr || // we have marked ourself as pending on this monitor diff --git a/src/hotspot/share/runtime/vframe.inline.hpp b/src/hotspot/share/runtime/vframe.inline.hpp index 54dbb44ebd4..6bd83e7f7c9 100644 --- a/src/hotspot/share/runtime/vframe.inline.hpp +++ b/src/hotspot/share/runtime/vframe.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -176,7 +176,8 @@ inline void vframeStreamCommon::fill_from_compiled_frame(int decode_offset) { INTPTR_FORMAT " not found or invalid at %d", p2i(_frame.pc()), decode_offset); nm()->print_on(&ss); - nm()->method()->print_codes_on(&ss); + // Buffering to a stringStream, disable internal buffering so it's not done twice. + nm()->method()->print_codes_on(&ss, 0, false); nm()->print_code_on(&ss); nm()->print_pcs_on(&ss); tty->print("%s", ss.as_string()); // print all at once diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 36c55bd2ecc..ad9463443b2 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -159,14 +159,13 @@ unchecked_nonstatic_field) \ \ /******************************************************************/ \ - /* OopDesc and Klass hierarchies (NOTE: MethodData* incomplete) */ \ + /* OopDesc and Klass hierarchies */ \ /******************************************************************/ \ \ volatile_nonstatic_field(oopDesc, _mark, markWord) \ - volatile_nonstatic_field(oopDesc, _metadata._klass, Klass*) \ - volatile_nonstatic_field(oopDesc, _metadata._compressed_klass, narrowKlass) \ + volatile_nonstatic_field(oopDesc, _compressed_klass, narrowKlass) \ static_field(BarrierSet, _barrier_set, BarrierSet*) \ - nonstatic_field(ArrayKlass, _dimension, int) \ + nonstatic_field(ArrayKlass, _dimension, const int) \ volatile_nonstatic_field(ArrayKlass, _higher_dimension, ObjArrayKlass*) \ volatile_nonstatic_field(ArrayKlass, _lower_dimension, ArrayKlass*) \ nonstatic_field(BSMAttributeEntries, _offsets, Array*) \ @@ -233,27 +232,7 @@ nonstatic_field(Klass, _vtable_len, int) \ nonstatic_field(Klass, _class_loader_data, ClassLoaderData*) \ nonstatic_field(vtableEntry, _method, Method*) \ - nonstatic_field(MethodData, _size, int) \ nonstatic_field(MethodData, _method, Method*) \ - nonstatic_field(MethodData, _data_size, int) \ - nonstatic_field(MethodData, _data[0], intptr_t) \ - nonstatic_field(MethodData, _parameters_type_data_di, int) \ - nonstatic_field(MethodData, _compiler_counters._nof_decompiles, uint) \ - nonstatic_field(MethodData, _compiler_counters._nof_overflow_recompiles, uint) \ - nonstatic_field(MethodData, _compiler_counters._nof_overflow_traps, uint) \ - nonstatic_field(MethodData, _compiler_counters._trap_hist._array[0], u1) \ - nonstatic_field(MethodData, _eflags, intx) \ - nonstatic_field(MethodData, _arg_local, intx) \ - nonstatic_field(MethodData, _arg_stack, intx) \ - nonstatic_field(MethodData, _arg_returned, intx) \ - nonstatic_field(MethodData, _tenure_traps, uint) \ - nonstatic_field(MethodData, _invoke_mask, int) \ - nonstatic_field(MethodData, _backedge_mask, int) \ - nonstatic_field(DataLayout, _header._struct._tag, u1) \ - nonstatic_field(DataLayout, _header._struct._flags, u1) \ - nonstatic_field(DataLayout, _header._struct._bci, u2) \ - nonstatic_field(DataLayout, _header._struct._traps, u4) \ - nonstatic_field(DataLayout, _cells[0], intptr_t) \ nonstatic_field(MethodCounters, _invoke_mask, int) \ nonstatic_field(MethodCounters, _backedge_mask, int) \ COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count, u2)) \ @@ -355,12 +334,11 @@ nonstatic_field(ThreadLocalAllocBuffer, _pf_top, HeapWord*) \ nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \ nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \ - static_field(ThreadLocalAllocBuffer, _reserve_for_allocation_prefetch, int) \ - static_field(ThreadLocalAllocBuffer, _target_refills, unsigned) \ - nonstatic_field(ThreadLocalAllocBuffer, _number_of_refills, unsigned) \ + static_field(ThreadLocalAllocBuffer, _target_num_refills, unsigned) \ + nonstatic_field(ThreadLocalAllocBuffer, _num_refills, unsigned) \ nonstatic_field(ThreadLocalAllocBuffer, _refill_waste, unsigned) \ nonstatic_field(ThreadLocalAllocBuffer, _gc_waste, unsigned) \ - nonstatic_field(ThreadLocalAllocBuffer, _slow_allocations, unsigned) \ + nonstatic_field(ThreadLocalAllocBuffer, _num_slow_allocations, unsigned) \ nonstatic_field(VirtualSpace, _low_boundary, char*) \ nonstatic_field(VirtualSpace, _high_boundary, char*) \ nonstatic_field(VirtualSpace, _low, char*) \ @@ -428,6 +406,8 @@ volatile_nonstatic_field(ClassLoaderData, _klasses, Klass*) \ nonstatic_field(ClassLoaderData, _has_class_mirror_holder, bool) \ \ + static_field(ClassLoaderData, _the_null_class_loader_data, ClassLoaderData*) \ + \ volatile_static_field(ClassLoaderDataGraph, _head, ClassLoaderData*) \ \ /**********/ \ @@ -494,6 +474,7 @@ /***********************************/ \ \ static_field(StubRoutines, _call_stub_return_address, address) \ + static_field(StubRoutines, _cont_returnBarrier, address) \ \ /***************************************/ \ /* PcDesc and other compiled code info */ \ @@ -596,7 +577,7 @@ nonstatic_field(ThreadShadow, _exception_file, const char*) \ nonstatic_field(ThreadShadow, _exception_line, int) \ nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \ - nonstatic_field(Thread, _allocated_bytes, jlong) \ + nonstatic_field(Thread, _allocated_bytes, uint64_t) \ nonstatic_field(JavaThread, _lock_stack, LockStack) \ nonstatic_field(LockStack, _top, uint32_t) \ nonstatic_field(LockStack, _base[0], oop) \ @@ -805,6 +786,7 @@ static_field(Mutex, _mutex_array, Mutex**) \ static_field(Mutex, _num_mutex, int) \ volatile_nonstatic_field(Mutex, _owner, Thread*) \ + nonstatic_field(ContinuationEntry, _parent, ContinuationEntry*) \ static_field(ContinuationEntry, _return_pc, address) //-------------------------------------------------------------------------------- @@ -961,8 +943,6 @@ declare_type(ConstMethod, MetaspaceObj) \ declare_type(Annotations, MetaspaceObj) \ \ - declare_toplevel_type(MethodData::CompilerCounters) \ - \ declare_toplevel_type(narrowKlass) \ \ declare_toplevel_type(vtableEntry) \ @@ -971,7 +951,6 @@ declare_toplevel_type(Symbol*) \ declare_toplevel_type(volatile Metadata*) \ \ - declare_toplevel_type(DataLayout) \ declare_toplevel_type(BSMAttributeEntries) \ \ /********/ \ @@ -1311,6 +1290,12 @@ VM_INT_CONSTANTS_GC(declare_constant, \ declare_constant_with_value) \ \ + /*****************/ \ + /* CDS constants */ \ + /*****************/ \ + \ + CDS_ONLY(declare_constant(AOTCompressedPointers::MetadataOffsetShift)) \ + \ /******************/ \ /* Useful globals */ \ /******************/ \ @@ -2158,4 +2143,3 @@ void vmStructs_init() { VMStructs::init(); } #endif // ASSERT - diff --git a/src/hotspot/share/sanitizers/address.cpp b/src/hotspot/share/sanitizers/address.cpp index 7d129feab0a..26de106ebcb 100644 --- a/src/hotspot/share/sanitizers/address.cpp +++ b/src/hotspot/share/sanitizers/address.cpp @@ -30,6 +30,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/vmError.hpp" +#ifndef _WINDOWS #include #include @@ -118,4 +119,11 @@ void Asan::report(outputStream* st) { } } +#else // defined windows + +void Asan::initialize() {} +bool Asan::had_error() { return false; } +void Asan::report(outputStream* st) {} +#endif // ifndef _WINDOWS + #endif // ADDRESS_SANITIZER diff --git a/src/hotspot/share/sanitizers/ub.hpp b/src/hotspot/share/sanitizers/ub.hpp index d5901f6821c..8a6bfa50f51 100644 --- a/src/hotspot/share/sanitizers/ub.hpp +++ b/src/hotspot/share/sanitizers/ub.hpp @@ -33,12 +33,9 @@ // Useful if the function or method is known to do something special or even 'dangerous', for // example causing desired signals/crashes. #ifdef UNDEFINED_BEHAVIOR_SANITIZER -#if defined(__clang__) +#if defined(__clang__) || defined(__GNUC__) #define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined","float-divide-by-zero"))) #endif -#if defined(__GNUC__) && !defined(__clang__) -#define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined"))) -#endif #endif #ifndef ATTRIBUTE_NO_UBSAN diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp index 290e4839c96..664fb5a8ef3 100644 --- a/src/hotspot/share/services/management.cpp +++ b/src/hotspot/share/services/management.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -1146,6 +1146,7 @@ JVM_ENTRY(jint, jmm_GetThreadInfo(JNIEnv *env, jlongArray ids, jint maxDepth, jo // create dummy snapshot dump_result.add_thread_snapshot(); } else { + assert(dump_result.t_list()->includes(jt), "Must be protected"); dump_result.add_thread_snapshot(jt); } } @@ -2124,12 +2125,12 @@ JVM_ENTRY(jlong, jmm_GetTotalThreadAllocatedMemory(JNIEnv *env)) // We keep a high water mark to ensure monotonicity in case threads counted // on a previous call end up in state (2). - static jlong high_water_result = 0; + static uint64_t high_water_result = 0; JavaThreadIteratorWithHandle jtiwh; - jlong result = ThreadService::exited_allocated_bytes(); + uint64_t result = ThreadService::exited_allocated_bytes(); for (; JavaThread* thread = jtiwh.next();) { - jlong size = thread->cooked_allocated_bytes(); + uint64_t size = thread->cooked_allocated_bytes(); result += size; } @@ -2144,7 +2145,7 @@ JVM_ENTRY(jlong, jmm_GetTotalThreadAllocatedMemory(JNIEnv *env)) high_water_result = result; } } - return result; + return checked_cast(result); JVM_END // Gets the amount of memory allocated on the Java heap for a single thread. @@ -2156,13 +2157,13 @@ JVM_ENTRY(jlong, jmm_GetOneThreadAllocatedMemory(JNIEnv *env, jlong thread_id)) } if (thread_id == 0) { // current thread - return thread->cooked_allocated_bytes(); + return checked_cast(thread->cooked_allocated_bytes()); } ThreadsListHandle tlh; JavaThread* java_thread = tlh.list()->find_JavaThread_from_java_tid(thread_id); if (is_platform_thread(java_thread)) { - return java_thread->cooked_allocated_bytes(); + return checked_cast(java_thread->cooked_allocated_bytes()); } return -1; JVM_END diff --git a/src/hotspot/share/services/memoryService.cpp b/src/hotspot/share/services/memoryService.cpp index cd53f44e053..4636f125079 100644 --- a/src/hotspot/share/services/memoryService.cpp +++ b/src/hotspot/share/services/memoryService.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -66,7 +66,13 @@ void GcThreadCountClosure::do_thread(Thread* thread) { _count++; } -void MemoryService::set_universe_heap(CollectedHeap* heap) { +void MemoryService::initialize(CollectedHeap* heap) { + // Prepare metaspace pools + add_metaspace_memory_pools(); + + // Ask heap to initialize its memory pools/managers + heap->initialize_serviceability(); + ResourceMark rm; // For internal allocations in GrowableArray. GrowableArray gc_mem_pools = heap->memory_pools(); @@ -113,11 +119,11 @@ void MemoryService::add_metaspace_memory_pools() { mgr->add_pool(_metaspace_pool); _pools_list->append(_metaspace_pool); - if (UseCompressedClassPointers) { - _compressed_class_pool = new CompressedKlassSpacePool(); - mgr->add_pool(_compressed_class_pool); - _pools_list->append(_compressed_class_pool); - } +#if INCLUDE_CLASS_SPACE + _compressed_class_pool = new CompressedKlassSpacePool(); + mgr->add_pool(_compressed_class_pool); + _pools_list->append(_compressed_class_pool); +#endif _managers_list->append(mgr); } diff --git a/src/hotspot/share/services/memoryService.hpp b/src/hotspot/share/services/memoryService.hpp index d10c3d2e9d9..1a947ec1d0c 100644 --- a/src/hotspot/share/services/memoryService.hpp +++ b/src/hotspot/share/services/memoryService.hpp @@ -60,7 +60,7 @@ private: static MemoryPool* _compressed_class_pool; public: - static void set_universe_heap(CollectedHeap* heap); + static void initialize(CollectedHeap* heap); static void add_code_heap_memory_pool(CodeHeap* heap, const char* name); static void add_metaspace_memory_pools(); diff --git a/src/hotspot/share/services/threadIdTable.cpp b/src/hotspot/share/services/threadIdTable.cpp index 1604927a0ac..585cc6377ec 100644 --- a/src/hotspot/share/services/threadIdTable.cpp +++ b/src/hotspot/share/services/threadIdTable.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2019, 2026, 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,7 +23,7 @@ */ #include "classfile/javaClasses.inline.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/handles.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaThread.inline.hpp" #include "runtime/threadSMR.hpp" @@ -44,7 +44,7 @@ static ThreadIdTableHash* volatile _local_table = nullptr; static volatile size_t _current_size = 0; static volatile size_t _items_count = 0; -volatile bool ThreadIdTable::_is_initialized = false; +Atomic ThreadIdTable::_is_initialized {false}; volatile bool ThreadIdTable::_has_work = false; class ThreadIdTableEntry : public CHeapObj { @@ -81,24 +81,25 @@ class ThreadIdTableConfig : public AllStatic { // Lazily creates the table and populates it with the given // thread list void ThreadIdTable::lazy_initialize(const ThreadsList *threads) { - if (!_is_initialized) { + if (!_is_initialized.load_acquire()) { { // There is no obvious benefit in allowing the thread table // to be concurrently populated during initialization. MutexLocker ml(ThreadIdTableCreate_lock); - if (_is_initialized) { + if (_is_initialized.load_relaxed()) { return; } create_table(threads->length()); - _is_initialized = true; + _is_initialized.release_store(true); } + for (uint i = 0; i < threads->length(); i++) { JavaThread* thread = threads->thread_at(i); - oop tobj = thread->threadObj(); + Handle tobj = Handle(JavaThread::current(), thread->threadObj()); if (tobj != nullptr) { - jlong java_tid = java_lang_Thread::thread_id(tobj); MutexLocker ml(Threads_lock); if (!thread->is_exiting()) { + jlong java_tid = java_lang_Thread::thread_id(tobj()); // Must be inside the lock to ensure that we don't add a thread to the table // that has just passed the removal point in Threads::remove(). add_thread(java_tid, thread); @@ -211,7 +212,7 @@ public: }; void ThreadIdTable::do_concurrent_work(JavaThread* jt) { - assert(_is_initialized, "Thread table is not initialized"); + assert(_is_initialized.load_relaxed(), "Thread table is not initialized"); _has_work = false; double load_factor = get_load_factor(); log_debug(thread, table)("Concurrent work, load factor: %g", load_factor); @@ -221,7 +222,8 @@ void ThreadIdTable::do_concurrent_work(JavaThread* jt) { } JavaThread* ThreadIdTable::add_thread(jlong tid, JavaThread* java_thread) { - assert(_is_initialized, "Thread table is not initialized"); + assert(Threads_lock->owned_by_self(), "Must hold Threads_lock"); + assert(_is_initialized.load_relaxed(), "Thread table is not initialized"); Thread* thread = Thread::current(); ThreadIdTableLookup lookup(tid); ThreadGet tg; @@ -240,7 +242,7 @@ JavaThread* ThreadIdTable::add_thread(jlong tid, JavaThread* java_thread) { } JavaThread* ThreadIdTable::find_thread_by_tid(jlong tid) { - assert(_is_initialized, "Thread table is not initialized"); + assert(_is_initialized.load_relaxed(), "Thread table is not initialized"); Thread* thread = Thread::current(); ThreadIdTableLookup lookup(tid); ThreadGet tg; @@ -249,7 +251,8 @@ JavaThread* ThreadIdTable::find_thread_by_tid(jlong tid) { } bool ThreadIdTable::remove_thread(jlong tid) { - assert(_is_initialized, "Thread table is not initialized"); + assert(Threads_lock->owned_by_self(), "Must hold Threads_lock"); + assert(_is_initialized.load_relaxed(), "Thread table is not initialized"); Thread* thread = Thread::current(); ThreadIdTableLookup lookup(tid); return _local_table->remove(thread, lookup); diff --git a/src/hotspot/share/services/threadIdTable.hpp b/src/hotspot/share/services/threadIdTable.hpp index 15dfb89d670..256484cce2d 100644 --- a/src/hotspot/share/services/threadIdTable.hpp +++ b/src/hotspot/share/services/threadIdTable.hpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #define SHARE_SERVICES_THREADIDTABLE_HPP #include "memory/allStatic.hpp" +#include "runtime/atomic.hpp" class JavaThread; class ThreadsList; @@ -34,13 +35,15 @@ class ThreadIdTableConfig; class ThreadIdTable : public AllStatic { friend class ThreadIdTableConfig; - static volatile bool _is_initialized; + static Atomic _is_initialized; static volatile bool _has_work; public: // Initialization static void lazy_initialize(const ThreadsList* threads); - static bool is_initialized() { return _is_initialized; } + static bool is_initialized_acquire() { + return _is_initialized.load_acquire(); + } // Lookup and list management static JavaThread* find_thread_by_tid(jlong tid); diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index 4dc6abe54b7..35c7de48d2e 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -74,7 +74,7 @@ PerfVariable* ThreadService::_daemon_threads_count = nullptr; volatile int ThreadService::_atomic_threads_count = 0; volatile int ThreadService::_atomic_daemon_threads_count = 0; -volatile jlong ThreadService::_exited_allocated_bytes = 0; +volatile uint64_t ThreadService::_exited_allocated_bytes = 0; ThreadDumpResult* ThreadService::_threaddump_list = nullptr; @@ -1252,7 +1252,7 @@ private: // The first stage of async deflation does not affect any field // used by this comparison so the ObjectMonitor* is usable here. if (mark.has_monitor()) { - ObjectMonitor* mon = ObjectSynchronizer::read_monitor(current, monitor->owner(), mark); + ObjectMonitor* mon = ObjectSynchronizer::read_monitor(monitor->owner(), mark); if (// if the monitor is null we must be in the process of locking mon == nullptr || // we have marked ourself as pending on this monitor diff --git a/src/hotspot/share/services/threadService.hpp b/src/hotspot/share/services/threadService.hpp index 4b0e76658b6..ddfc78e6315 100644 --- a/src/hotspot/share/services/threadService.hpp +++ b/src/hotspot/share/services/threadService.hpp @@ -63,7 +63,7 @@ private: // As could this... // Number of heap bytes allocated by terminated threads. - static volatile jlong _exited_allocated_bytes; + static volatile uint64_t _exited_allocated_bytes; // These 2 counters are like the above thread counts, but are // atomically decremented in ThreadService::current_thread_exiting instead of @@ -106,8 +106,8 @@ public: static int get_live_thread_count() { return _atomic_threads_count; } static int get_daemon_thread_count() { return _atomic_daemon_threads_count; } - static jlong exited_allocated_bytes() { return AtomicAccess::load(&_exited_allocated_bytes); } - static void incr_exited_allocated_bytes(jlong size) { + static uint64_t exited_allocated_bytes() { return AtomicAccess::load(&_exited_allocated_bytes); } + static void incr_exited_allocated_bytes(uint64_t size) { // No need for an atomic add because called under the Threads_lock, // but because _exited_allocated_bytes is read concurrently, need // atomic store to avoid readers seeing a partial update. diff --git a/src/hotspot/share/utilities/bitMap.hpp b/src/hotspot/share/utilities/bitMap.hpp index 5ee462bbe47..17bf437ecae 100644 --- a/src/hotspot/share/utilities/bitMap.hpp +++ b/src/hotspot/share/utilities/bitMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ #include "utilities/globalDefinitions.hpp" // Forward decl; +class Arena; class BitMapClosure; // Operations for bitmaps represented as arrays of unsigned integers. diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index 504b923237e..23e8281f000 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -40,7 +40,7 @@ #include "nmt/memTracker.hpp" #include "oops/klass.inline.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" @@ -80,7 +80,7 @@ static char g_dummy; char* g_assert_poison = &g_dummy; const char* g_assert_poison_read_only = &g_dummy; -static intx g_asserting_thread = 0; +static Atomic g_asserting_thread{0}; #endif // CAN_SHOW_REGISTERS_ON_ASSERT int DebuggingContext::_enabled = 0; // Initially disabled. @@ -193,7 +193,7 @@ void report_vm_error(const char* file, int line, const char* error_msg, const ch const void* siginfo = nullptr; #ifdef CAN_SHOW_REGISTERS_ON_ASSERT - if (os::current_thread_id() == g_asserting_thread) { + if (os::current_thread_id() == g_asserting_thread.load_relaxed()) { context = os::get_saved_assert_context(&siginfo); } #endif // CAN_SHOW_REGISTERS_ON_ASSERT @@ -220,7 +220,7 @@ void report_fatal(VMErrorType error_type, const char* file, int line, const char const void* siginfo = nullptr; #ifdef CAN_SHOW_REGISTERS_ON_ASSERT - if (os::current_thread_id() == g_asserting_thread) { + if (os::current_thread_id() == g_asserting_thread.load_relaxed()) { context = os::get_saved_assert_context(&siginfo); } #endif // CAN_SHOW_REGISTERS_ON_ASSERT @@ -265,15 +265,15 @@ void report_untested(const char* file, int line, const char* message) { } void report_java_out_of_memory(const char* message) { - static int out_of_memory_reported = 0; + static Atomic out_of_memory_reported{false}; JFR_ONLY(Jfr::on_report_java_out_of_memory();) // A number of threads may attempt to report OutOfMemoryError at around the // same time. To avoid dumping the heap or executing the data collection - // commands multiple times we just do it once when the first threads reports + // commands multiple times we just do it once when the first thread that reports // the error. - if (AtomicAccess::cmpxchg(&out_of_memory_reported, 0, 1) == 0) { + if (out_of_memory_reported.compare_set(false, true)) { // create heap dump before OnOutOfMemoryError commands are executed if (HeapDumpOnOutOfMemoryError) { tty->print_cr("java.lang.OutOfMemoryError: %s", message); @@ -342,20 +342,20 @@ class Command : public StackObj { int Command::level = 0; -extern "C" DEBUGEXPORT void blob(CodeBlob* cb) { +extern "C" NOINLINE void blob(CodeBlob* cb) { Command c("blob"); cb->print(); } -extern "C" DEBUGEXPORT void dump_vtable(address p) { +extern "C" NOINLINE void dump_vtable(address p) { Command c("dump_vtable"); Klass* k = (Klass*)p; k->vtable().print(); } -extern "C" DEBUGEXPORT void nm(intptr_t p) { +extern "C" NOINLINE void nm(intptr_t p) { // Actually we look through all CodeBlobs (the nm name has been kept for backwards compatibility) Command c("nm"); CodeBlob* cb = CodeCache::find_blob((address)p); @@ -367,7 +367,7 @@ extern "C" DEBUGEXPORT void nm(intptr_t p) { } -extern "C" DEBUGEXPORT void disnm(intptr_t p) { +extern "C" NOINLINE void disnm(intptr_t p) { Command c("disnm"); CodeBlob* cb = CodeCache::find_blob((address) p); if (cb != nullptr) { @@ -382,7 +382,7 @@ extern "C" DEBUGEXPORT void disnm(intptr_t p) { } -extern "C" DEBUGEXPORT void printnm(intptr_t p) { +extern "C" NOINLINE void printnm(intptr_t p) { char buffer[256]; os::snprintf_checked(buffer, sizeof(buffer), "printnm: " INTPTR_FORMAT, p); Command c(buffer); @@ -396,14 +396,14 @@ extern "C" DEBUGEXPORT void printnm(intptr_t p) { } -extern "C" DEBUGEXPORT void universe() { +extern "C" NOINLINE void universe() { Command c("universe"); if (!c.onThread()) return; Universe::print_on(tty); } -extern "C" DEBUGEXPORT void verify() { +extern "C" NOINLINE void verify() { // try to run a verify on the entire system // note: this may not be safe if we're not at a safepoint; for debugging, // this manipulates the safepoint settings to avoid assertion failures @@ -421,7 +421,7 @@ extern "C" DEBUGEXPORT void verify() { } -extern "C" DEBUGEXPORT void pp(void* p) { +extern "C" NOINLINE void pp(void* p) { Command c("pp"); if (!c.onThread()) return; FlagSetting fl(DisplayVMOutput, true); @@ -445,7 +445,7 @@ extern "C" DEBUGEXPORT void pp(void* p) { } -extern "C" DEBUGEXPORT void ps() { // print stack +extern "C" NOINLINE void ps() { // print stack // Prints the stack of the current Java thread Command c("ps"); if (!c.onThread()) return; @@ -477,7 +477,7 @@ extern "C" DEBUGEXPORT void ps() { // print stack } } -extern "C" DEBUGEXPORT void pfl() { +extern "C" NOINLINE void pfl() { // print frame layout Command c("pfl"); if (!c.onThread()) return; @@ -494,7 +494,7 @@ extern "C" DEBUGEXPORT void pfl() { } } -extern "C" DEBUGEXPORT void psf() { // print stack frames +extern "C" NOINLINE void psf() { // print stack frames Command c("psf"); if (!c.onThread()) return; JavaThread* p = JavaThread::active(); @@ -511,21 +511,21 @@ extern "C" DEBUGEXPORT void psf() { // print stack frames } -extern "C" DEBUGEXPORT void threads() { +extern "C" NOINLINE void threads() { Command c("threads"); if (!c.onThread()) return; Threads::print(false, true); } -extern "C" DEBUGEXPORT void psd() { +extern "C" NOINLINE void psd() { Command c("psd"); if (!c.onThread()) return; SystemDictionary::print(); } -extern "C" DEBUGEXPORT void pss() { // print all stacks +extern "C" NOINLINE void pss() { // print all stacks Command c("pss"); if (!c.onThread()) return; Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true)); @@ -533,7 +533,7 @@ extern "C" DEBUGEXPORT void pss() { // print all stacks // #ifndef PRODUCT -extern "C" DEBUGEXPORT void debug() { // to set things up for compiler debugging +extern "C" NOINLINE void debug() { // to set things up for compiler debugging Command c("debug"); NOT_PRODUCT(WizardMode = true;) PrintCompilation = true; @@ -542,7 +542,7 @@ extern "C" DEBUGEXPORT void debug() { // to set things up for comp } -extern "C" DEBUGEXPORT void ndebug() { // undo debug() +extern "C" NOINLINE void ndebug() { // undo debug() Command c("ndebug"); PrintCompilation = false; PrintInlining = PrintAssembly = false; @@ -550,36 +550,36 @@ extern "C" DEBUGEXPORT void ndebug() { // undo debug() } -extern "C" DEBUGEXPORT void flush() { +extern "C" NOINLINE void flush() { Command c("flush"); tty->flush(); } -extern "C" DEBUGEXPORT void events() { +extern "C" NOINLINE void events() { Command c("events"); Events::print(); } -extern "C" DEBUGEXPORT Method* findm(intptr_t pc) { +extern "C" NOINLINE Method* findm(intptr_t pc) { Command c("findm"); nmethod* nm = CodeCache::find_nmethod((address)pc); return (nm == nullptr) ? (Method*)nullptr : nm->method(); } -extern "C" DEBUGEXPORT nmethod* findnm(intptr_t addr) { +extern "C" NOINLINE nmethod* findnm(intptr_t addr) { Command c("findnm"); return CodeCache::find_nmethod((address)addr); } -extern "C" DEBUGEXPORT void find(intptr_t x) { +extern "C" NOINLINE void find(intptr_t x) { Command c("find"); if (!c.onThread()) return; os::print_location(tty, x, false); } -extern "C" DEBUGEXPORT void findpc(intptr_t x) { +extern "C" NOINLINE void findpc(intptr_t x) { Command c("findpc"); if (!c.onThread()) return; os::print_location(tty, x, true); @@ -591,15 +591,14 @@ extern "C" DEBUGEXPORT void findpc(intptr_t x) { // call findclass("java/lang/Object", 0x3) -> find j.l.Object and disasm all of its methods // call findmethod("*ang/Object*", "wait", 0xff) -> detailed disasm of all "wait" methods in j.l.Object // call findmethod("*ang/Object*", "wait:(*J*)V", 0x1) -> list all "wait" methods in j.l.Object that have a long parameter -extern "C" DEBUGEXPORT void findclass(const char* class_name_pattern, int flags) { +extern "C" NOINLINE void findclass(const char* class_name_pattern, int flags) { Command c("findclass"); if (!c.onThread()) return; ClassPrinter::print_flags_help(tty); ClassPrinter::print_classes(class_name_pattern, flags, tty); } -extern "C" DEBUGEXPORT void findmethod(const char* class_name_pattern, - const char* method_pattern, int flags) { +extern "C" NOINLINE void findmethod(const char* class_name_pattern, const char* method_pattern, int flags) { Command c("findmethod"); if (!c.onThread()) return; ClassPrinter::print_flags_help(tty); @@ -607,7 +606,7 @@ extern "C" DEBUGEXPORT void findmethod(const char* class_name_pattern, } // Need method pointer to find bcp -extern "C" DEBUGEXPORT void findbcp(intptr_t method, intptr_t bcp) { +extern "C" NOINLINE void findbcp(intptr_t method, intptr_t bcp) { Command c("findbcp"); Method* mh = (Method*)method; if (!mh->is_native()) { @@ -618,7 +617,7 @@ extern "C" DEBUGEXPORT void findbcp(intptr_t method, intptr_t bcp) { } // check and decode a single u5 value -extern "C" DEBUGEXPORT u4 u5decode(intptr_t addr) { +extern "C" NOINLINE u4 u5decode(intptr_t addr) { Command c("u5decode"); u1* arr = (u1*)addr; size_t off = 0, lim = 5; @@ -635,9 +634,7 @@ extern "C" DEBUGEXPORT u4 u5decode(intptr_t addr) { // there is no limit on the count of items printed; the // printing stops when an null is printed or at limit. // See documentation for UNSIGNED5::Reader::print(count). -extern "C" DEBUGEXPORT intptr_t u5p(intptr_t addr, - intptr_t limit, - int count) { +extern "C" NOINLINE intptr_t u5p(intptr_t addr, intptr_t limit, int count) { Command c("u5p"); u1* arr = (u1*)addr; if (limit && limit < addr) limit = addr; @@ -650,10 +647,10 @@ extern "C" DEBUGEXPORT intptr_t u5p(intptr_t addr, // int versions of all methods to avoid having to type type casts in the debugger -void pp(intptr_t p) { pp((void*)p); } -void pp(oop p) { pp((void*)p); } +NOINLINE void pp(intptr_t p) { pp((void*)p); } +NOINLINE void pp(oop p) { pp((void*)p); } -extern "C" DEBUGEXPORT void help() { +extern "C" NOINLINE void help() { Command c("help"); tty->print_cr("basic"); tty->print_cr(" pp(void* p) - try to make sense of p"); @@ -709,7 +706,7 @@ extern "C" DEBUGEXPORT void help() { } #ifndef PRODUCT -extern "C" DEBUGEXPORT void pns(void* sp, void* fp, void* pc) { // print native stack +extern "C" NOINLINE void pns(void* sp, void* fp, void* pc) { // print native stack Command c("pns"); if (!c.onThread()) return; static char buf[O_BUFLEN]; @@ -728,7 +725,7 @@ extern "C" DEBUGEXPORT void pns(void* sp, void* fp, void* pc) { // print native // WARNING: Only intended for use when debugging. Do not leave calls to // pns2() in committed source (product or debug). // -extern "C" DEBUGEXPORT void pns2() { // print native stack +extern "C" NOINLINE void pns2() { // print native stack Command c("pns2"); if (!c.onThread()) return; static char buf[O_BUFLEN]; @@ -739,6 +736,43 @@ extern "C" DEBUGEXPORT void pns2() { // print native stack } #endif +// just an exported helper; to avoid link time elimination of the referenced functions +extern "C" JNIEXPORT void JVM_debug_helpers_keeper(void* p1, void* p2, void* p3, intptr_t ip, oop oh, address adr) { + blob((CodeBlob*)p1); + dump_vtable(adr); + nm(ip); + disnm(ip); + printnm(ip); + universe(); + verify(); + pp(p1); + ps(); + pfl(); + psf(); + threads(); + psd(); + pss(); + debug(); + ndebug(); + flush(); + events(); + findm(ip); + findnm(ip); + find(ip); + findpc(ip); + findclass("", 0); + findmethod("", "", 0); + findbcp(ip, ip); + u5decode(ip); + u5p(ip, ip, 0); + pp(ip); + pp(oh); + help(); +#ifndef PRODUCT + pns(p1, p2, p3); + pns2(); +#endif +} // Returns true iff the address p is readable and *(intptr_t*)p != errvalue extern "C" bool dbg_is_safe(const void* p, intptr_t errvalue) { @@ -813,7 +847,7 @@ bool handle_assert_poison_fault(const void* ucVoid) { if (ucVoid != nullptr) { // Save context. const intx my_tid = os::current_thread_id(); - if (AtomicAccess::cmpxchg(&g_asserting_thread, (intx)0, my_tid) == 0) { + if (g_asserting_thread.compare_set(0, my_tid)) { os::save_assert_context(ucVoid); } } diff --git a/src/hotspot/share/utilities/dtrace_disabled.hpp b/src/hotspot/share/utilities/dtrace_disabled.hpp index 6cbd79326ac..99d7cbb2f75 100644 --- a/src/hotspot/share/utilities/dtrace_disabled.hpp +++ b/src/hotspot/share/utilities/dtrace_disabled.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -683,6 +683,10 @@ #define HOTSPOT_JNI_GETMETHODID_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_GETMETHODID_RETURN(arg0) #define HOTSPOT_JNI_GETMETHODID_RETURN_ENABLED() 0 +#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1) +#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0 +#define HOTSPOT_JNI_GETMODULE_RETURN(arg0) +#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED() 0 #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(arg0, arg1, arg2) #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(arg0) @@ -811,6 +815,10 @@ #define HOTSPOT_JNI_ISSAMEOBJECT_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_ISSAMEOBJECT_RETURN(arg0) #define HOTSPOT_JNI_ISSAMEOBJECT_RETURN_ENABLED() 0 +#define HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY(arg0, arg1) +#define HOTSPOT_JNI_ISVIRTUALTHREAD_ENTRY_ENABLED() 0 +#define HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN(arg0) +#define HOTSPOT_JNI_ISVIRTUALTHREAD_RETURN_ENABLED() 0 #define HOTSPOT_JNI_MONITORENTER_ENTRY(arg0, arg1) #define HOTSPOT_JNI_MONITORENTER_ENTRY_ENABLED() 0 #define HOTSPOT_JNI_MONITORENTER_RETURN(arg0) @@ -1080,12 +1088,6 @@ #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0) #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED() 0 -/* Modules */ -#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1) -#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED() 0 -#define HOTSPOT_JNI_GETMODULE_RETURN(arg0) -#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED() - #else /* !defined(DTRACE_ENABLED) */ #error This file should only be included when dtrace is not enabled #endif /* !defined(DTRACE_ENABLED) */ diff --git a/src/hotspot/share/utilities/events.cpp b/src/hotspot/share/utilities/events.cpp index 6adb5311cb5..d2b8e7ba5da 100644 --- a/src/hotspot/share/utilities/events.cpp +++ b/src/hotspot/share/utilities/events.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,15 @@ #include "memory/allocation.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/symbol.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/osThread.hpp" #include "runtime/timer.hpp" #include "utilities/events.hpp" -EventLog* Events::_logs = nullptr; +static Atomic event_logs_list{}; + StringEventLog* Events::_messages = nullptr; StringEventLog* Events::_memprotect_messages = nullptr; StringEventLog* Events::_nmethod_flush_messages = nullptr; @@ -51,15 +52,15 @@ EventLog::EventLog() { // but use lock free add because there are some events that are created later. EventLog* old_head; do { - old_head = AtomicAccess::load(&Events::_logs); + old_head = event_logs_list.load_relaxed(); _next = old_head; - } while (AtomicAccess::cmpxchg(&Events::_logs, old_head, this) != old_head); + } while (!event_logs_list.compare_set(old_head, this)); } // For each registered event logger, print out the current contents of // the buffer. void Events::print_all(outputStream* out, int max) { - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); while (log != nullptr) { log->print_log_on(out, max); log = log->next(); @@ -68,7 +69,7 @@ void Events::print_all(outputStream* out, int max) { // Print a single event log specified by name. void Events::print_one(outputStream* out, const char* log_name, int max) { - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); int num_printed = 0; while (log != nullptr) { if (log->matches_name_or_handle(log_name)) { @@ -81,7 +82,7 @@ void Events::print_one(outputStream* out, const char* log_name, int max) { if (num_printed == 0) { out->print_cr("The name \"%s\" did not match any known event log. " "Valid event log names are:", log_name); - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); while (log != nullptr) { log->print_names(out); out->cr(); diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp index cbbed7232fb..0d1c08548ff 100644 --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -214,10 +214,7 @@ class ExceptionsEventLog : public ExtendedStringEventLog { class Events : AllStatic { - friend class EventLog; - private: - static EventLog* _logs; // A log for generic messages that aren't well categorized. static StringEventLog* _messages; diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index b54474ea6d6..4455ab801cb 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/java.hpp" @@ -203,7 +202,7 @@ void Exceptions::_throw(JavaThread* thread, const char* file, int line, Handle h } if (h_exception->is_a(vmClasses::LinkageError_klass())) { - AtomicAccess::inc(&_linkage_errors, memory_order_relaxed); + _linkage_errors.add_then_fetch(1, memory_order_relaxed); } assert(h_exception->is_a(vmClasses::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); @@ -268,6 +267,10 @@ void Exceptions::_throw_cause(JavaThread* thread, const char* file, int line, Sy } +void Exceptions::increment_stack_overflow_errors() { + Exceptions::_stack_overflow_errors.add_then_fetch(1, memory_order_relaxed); +} + void Exceptions::throw_stack_overflow_exception(JavaThread* THREAD, const char* file, int line, const methodHandle& method) { Handle exception; if (!THREAD->has_pending_exception()) { @@ -279,7 +282,7 @@ void Exceptions::throw_stack_overflow_exception(JavaThread* THREAD, const char* java_lang_Throwable::fill_in_stack_trace(exception, method); } // Increment counter for hs_err file reporting - AtomicAccess::inc(&Exceptions::_stack_overflow_errors, memory_order_relaxed); + increment_stack_overflow_errors(); } else { // if prior exception, throw that one instead exception = Handle(THREAD, THREAD->pending_exception()); @@ -518,20 +521,20 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) { } // Exception counting for hs_err file -volatile int Exceptions::_stack_overflow_errors = 0; -volatile int Exceptions::_linkage_errors = 0; -volatile int Exceptions::_out_of_memory_error_java_heap_errors = 0; -volatile int Exceptions::_out_of_memory_error_metaspace_errors = 0; -volatile int Exceptions::_out_of_memory_error_class_metaspace_errors = 0; +Atomic Exceptions::_stack_overflow_errors{0}; +Atomic Exceptions::_linkage_errors{0}; +Atomic Exceptions::_out_of_memory_error_java_heap_errors{0}; +Atomic Exceptions::_out_of_memory_error_metaspace_errors{0}; +Atomic Exceptions::_out_of_memory_error_class_metaspace_errors{0}; void Exceptions::count_out_of_memory_exceptions(Handle exception) { if (Universe::is_out_of_memory_error_metaspace(exception())) { - AtomicAccess::inc(&_out_of_memory_error_metaspace_errors, memory_order_relaxed); + _out_of_memory_error_metaspace_errors.add_then_fetch(1, memory_order_relaxed); } else if (Universe::is_out_of_memory_error_class_metaspace(exception())) { - AtomicAccess::inc(&_out_of_memory_error_class_metaspace_errors, memory_order_relaxed); + _out_of_memory_error_class_metaspace_errors.add_then_fetch(1, memory_order_relaxed); } else { - // everything else reported as java heap OOM - AtomicAccess::inc(&_out_of_memory_error_java_heap_errors, memory_order_relaxed); + // everything else reported as java heap OOM + _out_of_memory_error_java_heap_errors.add_then_fetch(1, memory_order_relaxed); } } @@ -542,19 +545,24 @@ static void print_oom_count(outputStream* st, const char *err, int count) { } bool Exceptions::has_exception_counts() { - return (_stack_overflow_errors + _out_of_memory_error_java_heap_errors + - _out_of_memory_error_metaspace_errors + _out_of_memory_error_class_metaspace_errors) > 0; + return (_stack_overflow_errors.load_relaxed() + + _out_of_memory_error_java_heap_errors.load_relaxed() + + _out_of_memory_error_metaspace_errors.load_relaxed() + + _out_of_memory_error_class_metaspace_errors.load_relaxed()) > 0; } void Exceptions::print_exception_counts_on_error(outputStream* st) { - print_oom_count(st, "java_heap_errors", _out_of_memory_error_java_heap_errors); - print_oom_count(st, "metaspace_errors", _out_of_memory_error_metaspace_errors); - print_oom_count(st, "class_metaspace_errors", _out_of_memory_error_class_metaspace_errors); - if (_stack_overflow_errors > 0) { - st->print_cr("StackOverflowErrors=%d", _stack_overflow_errors); + print_oom_count(st, "java_heap_errors", + _out_of_memory_error_java_heap_errors.load_relaxed()); + print_oom_count(st, "metaspace_errors", + _out_of_memory_error_metaspace_errors.load_relaxed()); + print_oom_count(st, "class_metaspace_errors", + _out_of_memory_error_class_metaspace_errors.load_relaxed()); + if (_stack_overflow_errors.load_relaxed() > 0) { + st->print_cr("StackOverflowErrors=%d", _stack_overflow_errors.load_relaxed()); } - if (_linkage_errors > 0) { - st->print_cr("LinkageErrors=%d", _linkage_errors); + if (_linkage_errors.load_relaxed() > 0) { + st->print_cr("LinkageErrors=%d", _linkage_errors.load_relaxed()); } } diff --git a/src/hotspot/share/utilities/exceptions.hpp b/src/hotspot/share/utilities/exceptions.hpp index e76a0041d20..0299dedf2e6 100644 --- a/src/hotspot/share/utilities/exceptions.hpp +++ b/src/hotspot/share/utilities/exceptions.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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,6 +27,7 @@ #include "memory/allocation.hpp" #include "oops/oopsHierarchy.hpp" +#include "runtime/atomic.hpp" #include "utilities/ostream.hpp" #include "utilities/sizes.hpp" @@ -113,12 +114,16 @@ class Exceptions { static bool special_exception(JavaThread* thread, const char* file, int line, Handle exception, Symbol* name = nullptr, const char* message = nullptr); // Count out of memory errors that are interesting in error diagnosis - static volatile int _out_of_memory_error_java_heap_errors; - static volatile int _out_of_memory_error_metaspace_errors; - static volatile int _out_of_memory_error_class_metaspace_errors; + static Atomic _out_of_memory_error_java_heap_errors; + static Atomic _out_of_memory_error_metaspace_errors; + static Atomic _out_of_memory_error_class_metaspace_errors; // Count linkage errors - static volatile int _linkage_errors; + static Atomic _linkage_errors; + + // Count stack overflow errors. + static Atomic _stack_overflow_errors; + public: // this enum is defined to indicate whether it is safe to // ignore the encoding scheme of the original message string. @@ -179,10 +184,9 @@ class Exceptions { static void wrap_dynamic_exception(bool is_indy, JavaThread* thread); - // Exception counting for error files of interesting exceptions that may have - // caused a problem for the jvm - static volatile int _stack_overflow_errors; - + // Exception counting of interesting exceptions that may have caused a + // problem for the JVM, for reporting in the hs_err file. + static void increment_stack_overflow_errors(); static bool has_exception_counts(); static void count_out_of_memory_exceptions(Handle exception); static void print_exception_counts_on_error(outputStream* st); diff --git a/src/hotspot/share/utilities/filterQueue.hpp b/src/hotspot/share/utilities/filterQueue.hpp index 141c40f09c8..ea47f07b7b8 100644 --- a/src/hotspot/share/utilities/filterQueue.hpp +++ b/src/hotspot/share/utilities/filterQueue.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #define SHARE_UTILITIES_FILTERQUEUE_HPP #include "memory/allocation.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" // The FilterQueue is FIFO with the ability to skip over queued items. // The skipping is controlled by using a filter when popping. @@ -42,9 +42,9 @@ class FilterQueue { E _data; }; - Node* _first; + Atomic _first; Node* load_first() { - return AtomicAccess::load_acquire(&_first); + return _first.load_acquire(); } static bool match_all(E d) { return true; } diff --git a/src/hotspot/share/utilities/filterQueue.inline.hpp b/src/hotspot/share/utilities/filterQueue.inline.hpp index 18b40b81c6c..7fa1bc94b7b 100644 --- a/src/hotspot/share/utilities/filterQueue.inline.hpp +++ b/src/hotspot/share/utilities/filterQueue.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ void FilterQueue::push(E data) { while (true){ head = load_first(); insnode->_next = head; - if (AtomicAccess::cmpxchg(&_first, head, insnode) == head) { + if (_first.compare_set(head, insnode)) { break; } yield.wait(); @@ -91,7 +91,7 @@ E FilterQueue::pop(MATCH_FUNC& match_func) { if (match_prev == nullptr) { // Working on first - if (AtomicAccess::cmpxchg(&_first, match, match->_next) == match) { + if (_first.compare_set(match, match->_next)) { E ret = match->_data; delete match; return ret; diff --git a/src/hotspot/share/utilities/globalCounter.inline.hpp b/src/hotspot/share/utilities/globalCounter.inline.hpp index ed37b8a878d..0d05096716a 100644 --- a/src/hotspot/share/utilities/globalCounter.inline.hpp +++ b/src/hotspot/share/utilities/globalCounter.inline.hpp @@ -29,6 +29,7 @@ #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" +#include "runtime/safepointVerifiers.hpp" inline GlobalCounter::CSContext GlobalCounter::critical_section_begin(Thread *thread) { @@ -53,11 +54,13 @@ GlobalCounter::critical_section_end(Thread *thread, CSContext context) { } class GlobalCounter::CriticalSection { - private: + NoSafepointVerifier _nsv; Thread* _thread; CSContext _context; - public: + +public: inline CriticalSection(Thread* thread) : + _nsv(), _thread(thread), _context(GlobalCounter::critical_section_begin(_thread)) {} diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index ea4f6f99ae6..40691de518e 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -168,6 +168,29 @@ class oopDesc; #define SIZE_FORMAT_X_0 "0x%08" PRIxPTR #endif // _LP64 + +template +constexpr auto sizeof_auto_impl() { + if constexpr (N <= std::numeric_limits::max()) return uint8_t(N); + else if constexpr (N <= std::numeric_limits::max()) return uint16_t(N); + else if constexpr (N <= std::numeric_limits::max()) return uint32_t(N); + else return uint64_t(N); +} + +// Yields the size (in bytes) of the operand, using the smallest +// unsigned type that can represent the size value. The operand may be +// an expression, which is an unevaluated operand, or it may be a +// type. All of the restrictions for sizeof operands apply to the +// operand. The result is a constant expression. +// +// Example of correct usage of sizeof/sizeof_auto: +// // this will wrap using sizeof_auto, use sizeof to ensure computation using size_t +// size_t size = std::numeric_limits::max() * sizeof(uint16_t); +// // implicit narrowing conversion or compiler warning/error using stricter compiler flags when using sizeof +// int count = 42 / sizeof_auto(uint16_t); + +#define sizeof_auto(...) sizeof_auto_impl() + // Convert pointer to intptr_t, for use in printing pointers. inline intptr_t p2i(const volatile void* p) { return (intptr_t) p; @@ -1049,18 +1072,26 @@ const intptr_t NoBits = 0; // no bits set in a word const jlong NoLongBits = 0; // no bits set in a long const intptr_t OneBit = 1; // only right_most bit set in a word -// get a word with the n.th or the right-most or left-most n bits set -// (note: #define used only so that they can be used in enum constant definitions) -#define nth_bit(n) (((n) >= BitsPerWord) ? 0 : (OneBit << (n))) -#define right_n_bits(n) (nth_bit(n) - 1) - -// same as nth_bit(n), but allows handing in a type as template parameter. Allows -// us to use nth_bit with 64-bit types on 32-bit platforms -template inline T nth_bit_typed(int n) { - return ((T)1) << n; +// Return a value of type T with the n.th bit set and all other bits zero. +// T must be an integral or enum type. n must be non-negative. If n is at +// least the bitwise size of T then all bits in the result are zero. +template +constexpr T nth_bit(int n) { + assert(n >= 0, "n must be non-negative"); + using U = std::make_unsigned_t; + constexpr size_t size = sizeof(U) * BitsPerByte; + return T((size_t(n) >= size) ? U(0) : (U(1) << n)); } -template inline T right_n_bits_typed(int n) { - return nth_bit_typed(n) - 1; + +// Return a value of type T with all bits below the n.th bit set and all +// other bits zero. T must be an integral or enum type. n must be +// non-negative. If n is at least the bitwise size of T then all bits in +// the result are set. +template +constexpr T right_n_bits(int n) { + assert(n >= 0, "n must be non-negative"); + using U = std::make_unsigned_t; + return T(nth_bit(n) - 1); } // bit-operations using a mask m diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index dfd6f2f1880..f106d325c68 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp @@ -69,7 +69,9 @@ inline int strncasecmp(const char *s1, const char *s2, size_t n) { // *not* the same as the C99 Annex K strtok_s. VS provides that function // under the name strtok_s_l. Make strtok_r a synonym so we can use that name // in shared code. -const auto strtok_r = strtok_s; +inline char* strtok_r(char* str, const char* delim, char** saveptr) { + return strtok_s(str, delim, saveptr); +} // VS doesn't provide POSIX macros S_ISFIFO or S_IFIFO. It doesn't even // provide _S_ISFIFO, per its usual naming convention for POSIX stuff. But it diff --git a/src/hotspot/share/utilities/integerCast.hpp b/src/hotspot/share/utilities/integerCast.hpp new file mode 100644 index 00000000000..0715cab18d5 --- /dev/null +++ b/src/hotspot/share/utilities/integerCast.hpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2026, 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. + * + */ + +#ifndef SHARE_UTILITIES_INTEGERCAST_HPP +#define SHARE_UTILITIES_INTEGERCAST_HPP + +#include "cppstdlib/limits.hpp" +#include "cppstdlib/type_traits.hpp" +#include "metaprogramming/enableIf.hpp" +#include "utilities/debug.hpp" +#include "utilities/macros.hpp" + +#include + +// Tests whether all values for the From type are within the range of values +// for the To Type. From and To must be integral types. This is used by +// integer_cast to test for tautological conversions. +template), + ENABLE_IF(std::is_integral_v)> +constexpr bool is_always_integer_convertible() { + if constexpr (std::is_signed_v == std::is_signed_v) { + // signed => signed or unsigned => unsigned. + return sizeof(To) >= sizeof(From); + } else if constexpr (std::is_signed_v) { + // signed => unsigned is never tautological, because of negative values. + return false; + } else { + // unsigned => signed. + return sizeof(To) > sizeof(From); + } +} + +// Tests whether the value of from is within the range of values for the To +// type. To and From must be integral types. This is used by integer_cast +// to test whether the conversion should be performed. +template), + ENABLE_IF(std::is_integral_v)> +constexpr bool is_integer_convertible(From from) { + if constexpr (is_always_integer_convertible()) { + // This clause simplifies direct calls and the implementation below. It + // isn't needed by integer_cast, where a tautological call is discarded. + return true; + } else if constexpr (std::is_unsigned_v) { + // unsigned => signed or unsigned => unsigned. + // Convert To::max to corresponding unsigned for compare. + using U = std::make_unsigned_t; + return from <= static_cast(std::numeric_limits::max()); + } else if constexpr (std::is_signed_v) { + // signed => signed. + return ((std::numeric_limits::min() <= from) && + (from <= std::numeric_limits::max())); + } else { + // signed => unsigned. Convert from to corresponding unsigned for compare. + using U = std::make_unsigned_t; + return (0 <= from) && (static_cast(from) <= std::numeric_limits::max()); + } +} + +// Convert the from value to the To type, after a debug-only check that the +// value of from is within the range of values for the To type. To and From +// must be integral types. +// +// permit_tautology determines the behavior when a conversion will always +// succeed because the range of values for the From type is enclosed by the +// range of values for the To type (is_always_integer_convertible() +// is true). If true, the conversion will be performed as requested. If +// false, a compile-time error is produced. The default is false for 64bit +// platforms, true for 32bit platforms. See integer_cast_permit_tautology as +// the preferred way to override the default and always provide a true value. +// +// Unnecessary integer_casts make code harder to understand. Hence the +// compile-time failure for tautological conversions, to alert that a code +// change is making a integer_cast unnecessary. This can be suppressed on a +// per-call basis, because there are cases where a conversion might only +// sometimes be tautological. For example, the types involved may vary by +// platform. Another case is if the operation is in a template with dependent +// types, with the operation only being tautological for some instantiations. +// Suppressing the tautology check is an alternative to possibly complex +// metaprogramming to only perform the integer_cast when necessary. +// +// Despite that, for 32bit platforms the default is to not reject unnecessary +// integer_casts. This is because 64bit platforms are the primary target, and +// are likely to require conversions in some places. However, some of those +// conversions will be tautological on 32bit platforms, such as size_t => uint. +template), + ENABLE_IF(std::is_integral_v)> +constexpr To integer_cast(From from) { + if constexpr (is_always_integer_convertible()) { + static_assert(permit_tautology, "tautological integer_cast"); + } else { +#ifdef ASSERT + if (!is_integer_convertible(from)) { + if constexpr (std::is_signed_v) { + fatal("integer_cast failed: %jd", static_cast(from)); + } else { + fatal("integer_cast failed: %ju", static_cast(from)); + } + } +#endif // ASSERT + } + return static_cast(from); +} + +// Equivalent to "integer_cast(from)", disabling the compile-time +// check for tautological casts. Using this function is prefered to direct +// use of the permit_tautology template parameter for integer_cast, unless the +// choice is computed. +template), + ENABLE_IF(std::is_integral_v)> +constexpr To integer_cast_permit_tautology(From from) { + return integer_cast(from); +} + +// Convert an enumerator to an integral value via static_cast, after a +// debug-only check that the value is within the range for the destination +// type. This is mostly for compatibility with old code. Class scoped enums +// were used to work around ancient compilers that didn't implement class +// scoped static integral constants properly, and HotSpot code still has many +// examples of this. For others it might be sufficient to provide an explicit +// underlying type and either permit implicit conversions or use +// PrimitiveConversion::cast. +template), + ENABLE_IF(std::is_enum_v)> +constexpr To integer_cast(From from) { + using U = std::underlying_type_t; + return integer_cast(static_cast(from)); +} + +#endif // SHARE_UTILITIES_INTEGERCAST_HPP diff --git a/src/hotspot/share/utilities/intn_t.hpp b/src/hotspot/share/utilities/intn_t.hpp index 594e62a1694..1b8e7de652e 100644 --- a/src/hotspot/share/utilities/intn_t.hpp +++ b/src/hotspot/share/utilities/intn_t.hpp @@ -84,6 +84,7 @@ public: constexpr bool operator>(intn_t o) const { return int(*this) > int(o); } constexpr bool operator<=(intn_t o) const { return int(*this) <= int(o); } constexpr bool operator>=(intn_t o) const { return int(*this) >= int(o); } + constexpr intn_t operator>>(unsigned int s) const { return intn_t(int(*this) >> s); } }; template @@ -163,4 +164,35 @@ inline unsigned count_leading_zeros(uintn_t v) { return count_leading_zeros(v._v & uintn_t::_mask) - (32 - nbits); } +class HotSpotNumerics { +private: + template + static constexpr int type_width_impl(T value) { + // Count the number of 1s in `value`. We can't use population_count() from + // utilities/population_count.hpp, since it requires `std::is_integral`, which + // fails for `uintn_t`. Since this is a constexpr function, this function + // does not impose a runtime performance overhead. + return value == T(0) ? 0 : 1 + type_width_impl(value >> 1); + } + +public: + // Returns true if T is a signed type. We can't rely on std::is_signed + // because it returns false for intn_t, which is not a standard integral + // type. Instead, we check whether T(-1) is less than T(0). + template + static constexpr bool is_signed() { + return T(-1) < T(0); + } + + // Returns the bit width of the unsigned type T. We can't use sizeof() on T, + // since sizeof(uintn_t) returns the size of the underlying storage rather + // than the logical type width. So we instead compute the number of 1s in the + // maximum value. + template + static constexpr int type_width() { + static_assert(!is_signed(), "type_width requires an unsigned type"); + return type_width_impl(std::numeric_limits::max()); + } +}; + #endif // SHARE_UTILITIES_INTN_T_HPP diff --git a/src/hotspot/share/utilities/macros.hpp b/src/hotspot/share/utilities/macros.hpp index a03255b5cf3..3621f675ecb 100644 --- a/src/hotspot/share/utilities/macros.hpp +++ b/src/hotspot/share/utilities/macros.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -586,6 +586,18 @@ #define BIG_ENDIAN_ONLY(code) code #endif +#ifdef _LP64 +#define INCLUDE_CLASS_SPACE 1 +#define CLASS_SPACE_ONLY(x) x +#define NOT_CLASS_SPACE(x) +#else +// On 32-bit we use fake "narrow class pointers" which are really just 32-bit pointers, +// but we don't use a class space (would cause too much address space fragmentation) +#define INCLUDE_CLASS_SPACE 0 +#define CLASS_SPACE_ONLY(x) +#define NOT_CLASS_SPACE(x) x +#endif + #define define_pd_global(type, name, value) const type pd_##name = value; // Helper macros for constructing file names for includes. diff --git a/src/hotspot/share/utilities/ostream.cpp b/src/hotspot/share/utilities/ostream.cpp index 5e339a700cb..ded233d48bf 100644 --- a/src/hotspot/share/utilities/ostream.cpp +++ b/src/hotspot/share/utilities/ostream.cpp @@ -611,15 +611,15 @@ void fileStream::write(const char* s, size_t len) { } } -long fileStream::fileSize() { - long size = -1; +int64_t fileStream::fileSize() { + int64_t size = -1; if (_file != nullptr) { - long pos = ::ftell(_file); + int64_t pos = os::ftell(_file); if (pos < 0) return pos; - if (::fseek(_file, 0, SEEK_END) == 0) { - size = ::ftell(_file); + if (os::fseek(_file, 0, SEEK_END) == 0) { + size = os::ftell(_file); } - ::fseek(_file, pos, SEEK_SET); + os::fseek(_file, pos, SEEK_SET); } return size; } diff --git a/src/hotspot/share/utilities/ostream.hpp b/src/hotspot/share/utilities/ostream.hpp index e971ac4d125..c3a4026f4d9 100644 --- a/src/hotspot/share/utilities/ostream.hpp +++ b/src/hotspot/share/utilities/ostream.hpp @@ -312,7 +312,7 @@ class fileStream : public outputStream { fclose(_file); _need_close = false; } - long fileSize(); + int64_t fileSize(); void flush(); }; diff --git a/src/hotspot/share/utilities/rbTree.hpp b/src/hotspot/share/utilities/rbTree.hpp index a2f84ac2373..9c04ccbe9ab 100644 --- a/src/hotspot/share/utilities/rbTree.hpp +++ b/src/hotspot/share/utilities/rbTree.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,8 @@ #define SHARE_UTILITIES_RBTREE_HPP #include "cppstdlib/type_traits.hpp" -#include "metaprogramming/enableIf.hpp" +#include "memory/allocation.hpp" #include "nmt/memTag.hpp" -#include "runtime/os.hpp" #include "utilities/globalDefinitions.hpp" // An intrusive red-black tree is constructed with two template parameters: @@ -64,8 +63,9 @@ enum class RBTreeOrdering : int { LT, EQ, GT }; template class AbstractRBTree; - +class Arena; class outputStream; +class ResourceArea; class IntrusiveRBNode { template @@ -81,7 +81,7 @@ class IntrusiveRBNode { DEBUG_ONLY(mutable bool _visited); public: - IntrusiveRBNode() : _parent(0), _left(nullptr), _right(nullptr) DEBUG_ONLY(COMMA _visited(false)) {} + IntrusiveRBNode(); // Gets the previous in-order node in the tree. // nullptr is returned if there is no previous node. @@ -96,22 +96,18 @@ public: void print_on(outputStream* st, int depth = 0) const; private: - bool is_black() const { return (_parent & 0x1) != 0; } - bool is_red() const { return (_parent & 0x1) == 0; } + bool is_black() const; + bool is_red() const; - void set_black() { _parent |= 0x1; } - void set_red() { _parent &= ~0x1; } + void set_black(); + void set_red(); - IntrusiveRBNode* parent() const { return (IntrusiveRBNode*)(_parent & ~0x1); } - void set_parent(IntrusiveRBNode* new_parent) { _parent = (_parent & 0x1) | (uintptr_t)new_parent; } + IntrusiveRBNode* parent() const; + void set_parent(IntrusiveRBNode* new_parent); - bool is_right_child() const { - return parent() != nullptr && parent()->_right == this; - } + bool is_right_child() const; - bool is_left_child() const { - return parent() != nullptr && parent()->_left == this; - } + bool is_left_child() const; void replace_child(IntrusiveRBNode* old_child, IntrusiveRBNode* new_child); @@ -142,20 +138,20 @@ private: V _value; public: - const K& key() const { return _key; } + const K& key() const; - V& val() { return _value; } - const V& val() const { return _value; } - void set_val(const V& v) { _value = v; } + V& val(); + const V& val() const; + void set_val(const V& v); - RBNode() {} - RBNode(const K& key) : IntrusiveRBNode(), _key(key) {} - RBNode(const K& key, const V& val) : IntrusiveRBNode(), _key(key), _value(val) {} + RBNode(); + RBNode(const K& key); + RBNode(const K& key, const V& val); - const RBNode* prev() const { return (RBNode*)IntrusiveRBNode::prev(); } - const RBNode* next() const { return (RBNode*)IntrusiveRBNode::next(); } - RBNode* prev() { return (RBNode*)IntrusiveRBNode::prev(); } - RBNode* next() { return (RBNode*)IntrusiveRBNode::next(); } + const RBNode* prev() const; + const RBNode* next() const; + RBNode* prev(); + RBNode* next(); void print_on(outputStream* st, int depth = 0) const; @@ -176,17 +172,15 @@ public: friend AbstractRBTree; NodeType** _insert_location; NodeType* _parent; - Cursor() : _insert_location(nullptr), _parent(nullptr) {} - Cursor(NodeType** insert_location, NodeType* parent) - : _insert_location(insert_location), _parent(parent) {} - Cursor(NodeType* const* insert_location, NodeType* parent) - : _insert_location((NodeType**)insert_location), _parent(parent) {} + Cursor(); + Cursor(NodeType** insert_location, NodeType* parent); + Cursor(NodeType* const* insert_location, NodeType* parent); public: - bool valid() const { return _insert_location != nullptr; } - bool found() const { return *_insert_location != nullptr; } - NodeType* node() { return _insert_location == nullptr ? nullptr : *_insert_location; } - NodeType* node() const { return _insert_location == nullptr ? nullptr : *_insert_location; } + bool valid() const; + bool found() const; + NodeType* node(); + NodeType* node() const; }; protected: @@ -212,36 +206,16 @@ private: static constexpr bool HasNodeVerifier = HasNodeVerifierImpl::value; - RBTreeOrdering cmp(const K& a, const NodeType* b) const { - if constexpr (HasNodeComparator) { - return COMPARATOR::cmp(a, b); - } else if constexpr (HasKeyComparator) { - return COMPARATOR::cmp(a, b->key()); - } - } + RBTreeOrdering cmp(const K& a, const NodeType* b) const; - bool less_than(const NodeType* a, const NodeType* b) const { - if constexpr (HasNodeVerifier) { - return COMPARATOR::less_than(a, b); - } else { - return true; - } - } + bool less_than(const NodeType* a, const NodeType* b) const; - void assert_key_leq(K a, K b) const { - if constexpr (HasKeyComparator) { // Cannot assert if no key comparator exist. - assert(COMPARATOR::cmp(a, b) != RBTreeOrdering::GT, "key a must be less or equal to key b"); - } - } + void assert_key_leq(K a, K b) const; // True if node is black (nil nodes count as black) - static inline bool is_black(const IntrusiveRBNode* node) { - return node == nullptr || node->is_black(); - } + static inline bool is_black(const IntrusiveRBNode* node); - static inline bool is_red(const IntrusiveRBNode* node) { - return node != nullptr && node->is_red(); - } + static inline bool is_red(const IntrusiveRBNode* node); void fix_insert_violations(IntrusiveRBNode* node); @@ -251,18 +225,14 @@ private: void remove_from_tree(IntrusiveRBNode* node); struct empty_verifier { - bool operator()(const NodeType* n) const { - return true; - } + bool operator()(const NodeType* n) const; }; template void verify_self(NODE_VERIFIER verifier, const USER_VERIFIER& extra_verifier) const; struct default_printer { - void operator()(outputStream* st, const NodeType* n, int depth) const { - n->print_on(st, depth); - } + void operator()(outputStream* st, const NodeType* n, int depth) const; }; template @@ -271,12 +241,9 @@ private: public: NONCOPYABLE(AbstractRBTree); - AbstractRBTree() : _num_nodes(0), _root(nullptr) DEBUG_ONLY(COMMA _expected_visited(false)) { - static_assert(std::is_trivially_destructible::value, "key type must be trivially destructable"); - static_assert(HasKeyComparator || HasNodeComparator, "comparator must be of correct type"); - } + AbstractRBTree(); - size_t size() const { return _num_nodes; } + size_t size() const; // Gets the cursor associated with the given node or key. Cursor cursor(const K& key, const NodeType* hint_node = nullptr); @@ -311,87 +278,39 @@ public: void replace_at_cursor(NodeType* new_node, const Cursor& node_cursor); // Finds the node associated with the given key. - NodeType* find_node(const K& key, const NodeType* hint_node = nullptr) const { - Cursor node_cursor = cursor(key, hint_node); - return node_cursor.node(); - } - - NodeType* find_node(const K& key, const NodeType* hint_node = nullptr) { - Cursor node_cursor = cursor(key, hint_node); - return node_cursor.node(); - } + NodeType* find_node(const K& key, const NodeType* hint_node = nullptr); + NodeType* find_node(const K& key, const NodeType* hint_node = nullptr) const; // Inserts the given node into the tree. - void insert(const K& key, NodeType* node, const NodeType* hint_node = nullptr) { - Cursor node_cursor = cursor(key, hint_node); - insert_at_cursor(node, node_cursor); - } + void insert(const K& key, NodeType* node, const NodeType* hint_node = nullptr); - void remove(NodeType* node) { - Cursor node_cursor = cursor(node); - remove_at_cursor(node_cursor); - } + // Removes the given node from the tree. + void remove(NodeType* node); // Finds the node with the closest key <= the given key. // If no node is found, null is returned instead. - NodeType* closest_leq(const K& key) const { - Cursor node_cursor = cursor(key); - return node_cursor.found() ? node_cursor.node() : prev(node_cursor).node(); - } - - NodeType* closest_leq(const K& key) { - Cursor node_cursor = cursor(key); - return node_cursor.found() ? node_cursor.node() : prev(node_cursor).node(); - } + NodeType* closest_leq(const K& key); + NodeType* closest_leq(const K& key) const; // Finds the node with the closest key > the given key. // If no node is found, null is returned instead. - NodeType* closest_gt(const K& key) const { - Cursor node_cursor = cursor(key); - return next(node_cursor).node(); - } - - NodeType* closest_gt(const K& key) { - Cursor node_cursor = cursor(key); - return next(node_cursor).node(); - } + NodeType* closest_gt(const K& key); + NodeType* closest_gt(const K& key) const; // Finds the node with the closest key >= the given key. // If no node is found, null is returned instead. - NodeType* closest_ge(const K& key) const { - Cursor node_cursor = cursor(key); - return node_cursor.found() ? node_cursor.node() : next(node_cursor).node(); - } - - NodeType* closest_ge(const K& key) { - Cursor node_cursor = cursor(key); - return node_cursor.found() ? node_cursor.node() : next(node_cursor).node(); - } + NodeType* closest_ge(const K& key); + NodeType* closest_ge(const K& key) const; // Returns leftmost node, nullptr if tree is empty. // If COMPARATOR::cmp(a, b) behaves canonically (positive value for a > b), this will the smallest key value. - const NodeType* leftmost() const { - IntrusiveRBNode* n = _root, *n2 = nullptr; - while (n != nullptr) { - n2 = n; - n = n->_left; - } - return (NodeType*)n2; - } + NodeType* leftmost(); + const NodeType* leftmost() const; // Returns rightmost node, nullptr if tree is empty. // If COMPARATOR::cmp(a, b) behaves canonically (positive value for a > b), this will the largest key value. - const NodeType* rightmost() const { - IntrusiveRBNode* n = _root, *n2 = nullptr; - while (n != nullptr) { - n2 = n; - n = n->_right; - } - return (NodeType*)n2; - } - - NodeType* leftmost() { return const_cast(static_cast(this)->leftmost()); } - NodeType* rightmost() { return const_cast(static_cast(this)->rightmost()); } + NodeType* rightmost(); + const NodeType* rightmost() const; struct Range { NodeType* start; @@ -403,11 +322,7 @@ public: // Return the range [start, end) // where start->key() <= addr < end->key(). // Failure to find the range leads to start and/or end being null. - Range find_enclosing_range(K key) const { - NodeType* start = closest_leq(key); - NodeType* end = closest_gt(key); - return Range(start, end); - } + Range find_enclosing_range(K key) const; // Visit all RBNodes in ascending order, calling f on each node. // If f returns `true` the iteration continues, otherwise it is stopped at the current node. @@ -417,7 +332,6 @@ public: template void visit_in_order(F f); - // Visit all RBNodes in ascending order whose keys are in range [from, to], calling f on each node. // If f returns `true` the iteration continues, otherwise it is stopped at the current node. template @@ -433,15 +347,7 @@ public: // This should return true if the node is valid. // If provided, each node is also verified through this callable. template - void verify_self(const USER_VERIFIER& extra_verifier = USER_VERIFIER()) const { - if constexpr (HasNodeVerifier) { - verify_self([](const NodeType* a, const NodeType* b){ return COMPARATOR::less_than(a, b);}, extra_verifier); - } else if constexpr (HasKeyComparator) { - verify_self([](const NodeType* a, const NodeType* b){ return COMPARATOR::cmp(a->key(), b->key()) == RBTreeOrdering::LT; }, extra_verifier); - } else { - verify_self([](const NodeType*, const NodeType*){ return true;}, extra_verifier); - } - } + void verify_self(const USER_VERIFIER& extra_verifier = USER_VERIFIER()) const; // Accepts an optional printing callable `void node_printer(outputStream* st, const Node* n, int depth)`. // If provided, each node is printed through this callable rather than the default `print_on`. @@ -458,131 +364,87 @@ class RBTree : public AbstractRBTree, COMPARATOR> { ALLOCATOR _allocator; public: - RBTree() : BaseType(), _allocator() {} + template + RBTree(AllocArgs... alloc_args); + ~RBTree(); NONCOPYABLE(RBTree); - ~RBTree() { remove_all(); } bool copy_into(RBTree& other) const; typedef typename BaseType::Cursor Cursor; using BaseType::cursor; using BaseType::insert_at_cursor; - using BaseType::remove_at_cursor; using BaseType::next; using BaseType::prev; - void replace_at_cursor(RBNode* new_node, const Cursor& node_cursor) { - RBNode* old_node = node_cursor.node(); - BaseType::replace_at_cursor(new_node, node_cursor); - free_node(old_node); - } + void remove_at_cursor(const Cursor& node_cursor); + void replace_at_cursor(RBNode* new_node, const Cursor& node_cursor); - RBNode* allocate_node(const K& key) { - void* node_place = _allocator.allocate(sizeof(RBNode)); - if (node_place == nullptr) { - return nullptr; - } - return new (node_place) RBNode(key); - } + RBNode* allocate_node(const K& key); + RBNode* allocate_node(const K& key, const V& val); - RBNode* allocate_node(const K& key, const V& val) { - void* node_place = _allocator.allocate(sizeof(RBNode)); - if (node_place == nullptr) { - return nullptr; - } - return new (node_place) RBNode(key, val); - } - - void free_node(RBNode* node) { - node->_value.~V(); - _allocator.free(node); - } + void free_node(RBNode* node); // Inserts a node with the given key/value into the tree, // if the key already exist, the value is updated instead. // Returns false if and only if allocation of a new node failed. - bool upsert(const K& key, const V& val, const RBNode* hint_node = nullptr) { - Cursor node_cursor = cursor(key, hint_node); - RBNode* node = node_cursor.node(); - if (node != nullptr) { - node->set_val(val); - return true; - } - - node = allocate_node(key, val); - if (node == nullptr) { - return false; - } - insert_at_cursor(node, node_cursor); - return true; - } + bool upsert(const K& key, const V& val, const RBNode* hint_node = nullptr); // Finds the value of the node associated with the given key. - V* find(const K& key) { - Cursor node_cursor = cursor(key); - return node_cursor.found() ? &node_cursor.node()->_value : nullptr; - } + V* find(const K& key); + V* find(const K& key) const; - V* find(const K& key) const { - const Cursor node_cursor = cursor(key); - return node_cursor.found() ? &node_cursor.node()->_value : nullptr; - } - - void remove(RBNode* node) { - Cursor node_cursor = cursor(node); - remove_at_cursor(node_cursor); - free_node(node); - } + void remove(RBNode* node); // Removes the node with the given key from the tree if it exists. // Returns true if the node was successfully removed, false otherwise. - bool remove(const K& key) { - Cursor node_cursor = cursor(key); - if (!node_cursor.found()) { - return false; - } - RBNode* node = node_cursor.node(); - remove_at_cursor(node_cursor); - free_node((RBNode*)node); - return true; - } + bool remove(const K& key); // Removes all existing nodes from the tree. - void remove_all() { - IntrusiveRBNode* to_delete[64]; - int stack_idx = 0; - to_delete[stack_idx++] = BaseType::_root; - - while (stack_idx > 0) { - IntrusiveRBNode* head = to_delete[--stack_idx]; - if (head == nullptr) continue; - to_delete[stack_idx++] = head->_left; - to_delete[stack_idx++] = head->_right; - free_node((RBNode*)head); - } - BaseType::_num_nodes = 0; - BaseType::_root = nullptr; - } + void remove_all(); }; template class RBTreeCHeapAllocator { public: - void* allocate(size_t sz) { - void* allocation = os::malloc(sz, mem_tag); - if (allocation == nullptr && strategy == AllocFailStrategy::EXIT_OOM) { - vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, - "red-black tree failed allocation"); - } - return allocation; - } - - void free(void* ptr) { os::free(ptr); } + void* allocate(size_t sz); + void free(void* ptr); }; +template +class RBTreeArenaAllocator { + Arena* _arena; +public: + RBTreeArenaAllocator(Arena* arena); + void* allocate(size_t sz); + void free(void* ptr); +}; + +template +class RBTreeResourceAreaAllocator { + ResourceArea* _rarea; +public: + RBTreeResourceAreaAllocator(ResourceArea* rarea); + void* allocate(size_t sz); + void free(void* ptr); +}; + +template +RBTreeOrdering rbtree_primitive_cmp(T a, T b) { // handy function + if (a < b) return RBTreeOrdering::LT; + if (a > b) return RBTreeOrdering::GT; + return RBTreeOrdering::EQ; +} + template using RBTreeCHeap = RBTree>; +template +using RBTreeArena = RBTree>; + +template +using RBTreeResourceArea = RBTree>; + template using IntrusiveRBTree = AbstractRBTree; diff --git a/src/hotspot/share/utilities/rbTree.inline.hpp b/src/hotspot/share/utilities/rbTree.inline.hpp index 6e01f92d12a..381cb916405 100644 --- a/src/hotspot/share/utilities/rbTree.inline.hpp +++ b/src/hotspot/share/utilities/rbTree.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,49 @@ #include "utilities/rbTree.hpp" +#include "memory/allocation.hpp" +#include "memory/arena.hpp" +#include "memory/resourceArea.hpp" #include "metaprogramming/enableIf.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/ostream.hpp" #include "utilities/powerOfTwo.hpp" +inline IntrusiveRBNode::IntrusiveRBNode() + : _parent(0), _left(nullptr), _right(nullptr) DEBUG_ONLY(COMMA _visited(false)) {} + +inline bool IntrusiveRBNode::is_black() const { + return (_parent & 0x1) != 0; +} + +inline bool IntrusiveRBNode::is_red() const { + return (_parent & 0x1) == 0; +} + +inline void IntrusiveRBNode::set_black() { + _parent |= 0x1; +} +inline void IntrusiveRBNode::set_red() { + _parent &= ~0x1; +} + +inline IntrusiveRBNode* IntrusiveRBNode::parent() const { + return reinterpret_cast(_parent & ~0x1); +} + +inline void IntrusiveRBNode::set_parent(IntrusiveRBNode* new_parent) { + _parent = (_parent & 0x1) | reinterpret_cast(new_parent); +} + +inline bool IntrusiveRBNode::is_right_child() const { + return parent() != nullptr && parent()->_right == this; +} + +inline bool IntrusiveRBNode::is_left_child() const { + return parent() != nullptr && parent()->_left == this; +} + inline void IntrusiveRBNode::replace_child(IntrusiveRBNode* old_child, IntrusiveRBNode* new_child) { if (_left == old_child) { _left = new_child; @@ -185,6 +222,144 @@ inline void IntrusiveRBNode::verify( } +template +inline const K& RBNode::key() const { + return _key; +} + +template +inline V& RBNode::val() { + return _value; +} + +template +inline const V& RBNode::val() const { + return _value; +} + +template +inline void RBNode::set_val(const V& v) { + _value = v; +} + +template +inline RBNode::RBNode() {} + +template +inline RBNode::RBNode(const K& key) : IntrusiveRBNode(), _key(key) {} + +template +inline RBNode::RBNode(const K& key, const V& val) : IntrusiveRBNode(), _key(key), _value(val) {} + +template +inline const RBNode* RBNode::prev() const { + return static_cast*>(IntrusiveRBNode::prev()); +} + +template +inline const RBNode* RBNode::next() const { + return static_cast*>(IntrusiveRBNode::next()); +} + +template +inline RBNode* RBNode::prev() { + return static_cast*>(IntrusiveRBNode::prev()); +} + +template +inline RBNode* RBNode::next() { + return static_cast*>(IntrusiveRBNode::next()); +} + +template +inline AbstractRBTree::Cursor::Cursor() + : _insert_location(nullptr), _parent(nullptr) {} + +template +inline AbstractRBTree::Cursor::Cursor(NodeType** insert_location, NodeType* parent) + : _insert_location(insert_location), _parent(parent) {} + +template +inline AbstractRBTree::Cursor::Cursor(NodeType* const* insert_location, NodeType* parent) + : _insert_location(const_cast(insert_location)), _parent(parent) {} + +template +inline bool AbstractRBTree::Cursor::valid() const { + return _insert_location != nullptr; +} + +template +inline bool AbstractRBTree::Cursor::found() const { + return *_insert_location != nullptr; +} + +template +inline NodeType* AbstractRBTree::Cursor::node() { + return _insert_location == nullptr ? nullptr : *_insert_location; +} + +template +inline NodeType* AbstractRBTree::Cursor::node() const { + return _insert_location == nullptr ? nullptr : *_insert_location; +} + +template +inline RBTreeOrdering AbstractRBTree::cmp(const K& a, const NodeType* b) const { + if constexpr (HasNodeComparator) { + return COMPARATOR::cmp(a, b); + } else if constexpr (HasKeyComparator) { + return COMPARATOR::cmp(a, b->key()); + } +} + +template +inline bool AbstractRBTree::less_than(const NodeType* a, const NodeType* b) const { + if constexpr (HasNodeVerifier) { + return COMPARATOR::less_than(a, b); + } else { + return true; + } +} + +template +inline void AbstractRBTree::assert_key_leq(K a, K b) const { + if constexpr (HasKeyComparator) { // Cannot assert if no key comparator exist. + assert(COMPARATOR::cmp(a, b) != RBTreeOrdering::GT, "key a must be less or equal to key b"); + } +} + +template +inline bool AbstractRBTree::is_black(const IntrusiveRBNode* node) { + return node == nullptr || node->is_black(); +} + +template +inline bool AbstractRBTree::is_red(const IntrusiveRBNode* node) { + return node != nullptr && node->is_red(); +} + +template +inline bool AbstractRBTree::empty_verifier::operator()(const NodeType* n) const { + return true; +} + +template +inline void AbstractRBTree::default_printer::operator()(outputStream* st, const NodeType* n, int depth) const { + n->print_on(st, depth); +} + +template +inline AbstractRBTree::AbstractRBTree() + : _num_nodes(0), _root(nullptr) DEBUG_ONLY(COMMA _expected_visited(false)) { + static_assert(std::is_trivially_destructible::value, "key type must be trivially destructable"); + static_assert(HasKeyComparator || HasNodeComparator, "comparator must be of correct type"); +} + +template +inline size_t AbstractRBTree::size() const { + return _num_nodes; +} + template inline const typename AbstractRBTree::Cursor AbstractRBTree::cursor(const K& key, const NodeType* hint_node) const { @@ -233,7 +408,9 @@ AbstractRBTree::cursor(const K& key, const NodeType* hi template inline void AbstractRBTree::insert_at_cursor(NodeType* node, const Cursor& node_cursor) { - assert(node_cursor.valid() && !node_cursor.found(), "must be"); + precond(node != nullptr); + precond(node_cursor.valid()); + precond(!node_cursor.found()); _num_nodes++; *node_cursor._insert_location = node; @@ -447,7 +624,8 @@ inline void AbstractRBTree::remove_from_tree(IntrusiveR template inline void AbstractRBTree::remove_at_cursor(const Cursor& node_cursor) { - assert(node_cursor.valid() && node_cursor.found(), "must be"); + precond(node_cursor.valid()); + precond(node_cursor.found()); _num_nodes--; IntrusiveRBNode* node = node_cursor.node(); @@ -543,7 +721,9 @@ AbstractRBTree::prev(const Cursor& node_cursor) const { template inline void AbstractRBTree::replace_at_cursor(NodeType* new_node, const Cursor& node_cursor) { - assert(node_cursor.valid() && node_cursor.found(), "must be"); + precond(new_node != nullptr); + precond(node_cursor.valid()); + precond(node_cursor.found()); NodeType* old_node = node_cursor.node(); if (old_node == new_node) { return; @@ -596,6 +776,106 @@ AbstractRBTree::prev(const Cursor& node_cursor) { return static_cast*>(this)->prev(node_cursor); } +template +inline NodeType* AbstractRBTree::find_node(const K& key, const NodeType* hint_node) const { + Cursor node_cursor = cursor(key, hint_node); + return node_cursor.node(); +} + +template +inline NodeType* AbstractRBTree::find_node(const K& key, const NodeType* hint_node) { + Cursor node_cursor = cursor(key, hint_node); + return node_cursor.node(); +} + +template +inline void AbstractRBTree::insert(const K& key, NodeType* node, const NodeType* hint_node) { + precond(node != nullptr); + Cursor node_cursor = cursor(key, hint_node); + insert_at_cursor(node, node_cursor); +} + +template +inline void AbstractRBTree::remove(NodeType* node) { + precond(node != nullptr); + Cursor node_cursor = cursor(node); + remove_at_cursor(node_cursor); +} + +template +inline NodeType* AbstractRBTree::closest_leq(const K& key) const { + Cursor node_cursor = cursor(key); + return node_cursor.found() ? node_cursor.node() : prev(node_cursor).node(); +} + +template +inline NodeType* AbstractRBTree::closest_leq(const K& key) { + Cursor node_cursor = cursor(key); + return node_cursor.found() ? node_cursor.node() : prev(node_cursor).node(); +} + +template +inline NodeType* AbstractRBTree::closest_gt(const K& key) const { + Cursor node_cursor = cursor(key); + return next(node_cursor).node(); +} + +template +inline NodeType* AbstractRBTree::closest_gt(const K& key) { + Cursor node_cursor = cursor(key); + return next(node_cursor).node(); +} + +template +inline NodeType* AbstractRBTree::closest_ge(const K& key) const { + Cursor node_cursor = cursor(key); + return node_cursor.found() ? node_cursor.node() : next(node_cursor).node(); +} + +template +inline NodeType* AbstractRBTree::closest_ge(const K& key) { + Cursor node_cursor = cursor(key); + return node_cursor.found() ? node_cursor.node() : next(node_cursor).node(); +} + +template +inline const NodeType* AbstractRBTree::leftmost() const { + IntrusiveRBNode* n = _root, *n2 = nullptr; + while (n != nullptr) { + n2 = n; + n = n->_left; + } + return static_cast(n2); +} + +template +inline const NodeType* AbstractRBTree::rightmost() const { + IntrusiveRBNode* n = _root, *n2 = nullptr; + while (n != nullptr) { + n2 = n; + n = n->_right; + } + return static_cast(n2); +} + +template +inline NodeType* AbstractRBTree::leftmost() { + return const_cast(static_cast*>(this)->leftmost()); +} + +template +inline NodeType* AbstractRBTree::rightmost() { + return const_cast(static_cast*>(this)->rightmost()); +} + +template +inline typename AbstractRBTree::Range +AbstractRBTree::find_enclosing_range(K key) const { + NodeType* start = closest_leq(key); + NodeType* end = closest_gt(key); + return Range(start, end); +} + template template inline void AbstractRBTree::visit_in_order(F f) const { @@ -662,6 +942,18 @@ inline void AbstractRBTree::visit_range_in_order(const } } +template +template +inline void AbstractRBTree::verify_self(const USER_VERIFIER& extra_verifier) const { + if constexpr (HasNodeVerifier) { + verify_self([](const NodeType* a, const NodeType* b){ return COMPARATOR::less_than(a, b);}, extra_verifier); + } else if constexpr (HasKeyComparator) { + verify_self([](const NodeType* a, const NodeType* b){ return COMPARATOR::cmp(a->key(), b->key()) == RBTreeOrdering::LT; }, extra_verifier); + } else { + verify_self([](const NodeType*, const NodeType*){ return true;}, extra_verifier); + } +} + template template inline void AbstractRBTree::verify_self(NODE_VERIFIER verifier, const USER_VERIFIER& extra_verifier) const { @@ -753,11 +1045,20 @@ void AbstractRBTree::print_on(outputStream* st, const P } } +template +template +inline RBTree::RBTree(AllocArgs... alloc_args) : BaseType(), _allocator(alloc_args...) {} + +template +inline RBTree::~RBTree() { + remove_all(); +} + template bool RBTree::copy_into(RBTree& other) const { - assert(other.size() == 0, "You can only copy into an empty RBTree"); - assert(std::is_copy_constructible::value, "Key type must be copy-constructible when copying a RBTree"); - assert(std::is_copy_constructible::value, "Value type must be copy-constructible when copying a RBTree"); + precond(other.size() == 0); + precond(std::is_copy_constructible::value); + precond(std::is_copy_constructible::value); enum class Dir { Left, Right }; struct node_pair { const IntrusiveRBNode* current; IntrusiveRBNode* other_parent; Dir dir; }; struct stack { @@ -802,4 +1103,145 @@ bool RBTree::copy_into(RBTree& other) const { return true; } +template +inline void RBTree::remove_at_cursor(const Cursor& node_cursor) { + precond(node_cursor.valid()); + precond(node_cursor.found()); + RBNode* old_node = node_cursor.node(); + BaseType::remove_at_cursor(node_cursor); + free_node(old_node); +} + +template +inline void RBTree::replace_at_cursor(RBNode* new_node, const Cursor& node_cursor) { + precond(new_node != nullptr); + precond(node_cursor.valid()); + precond(node_cursor.found()); + RBNode* old_node = node_cursor.node(); + BaseType::replace_at_cursor(new_node, node_cursor); + free_node(old_node); +} + +template +inline RBNode* RBTree::allocate_node(const K& key) { + void* node_place = _allocator.allocate(sizeof(RBNode)); + if (node_place == nullptr) { + return nullptr; + } + return new (node_place) RBNode(key); +} + +template +inline RBNode* RBTree::allocate_node(const K& key, const V& val) { + void* node_place = _allocator.allocate(sizeof(RBNode)); + if (node_place == nullptr) { + return nullptr; + } + return new (node_place) RBNode(key, val); +} + +template +inline void RBTree::free_node(RBNode* node) { + precond(node != nullptr); + node->_value.~V(); + _allocator.free(node); +} + +template +inline bool RBTree::upsert(const K& key, const V& val, const RBNode* hint_node) { + Cursor node_cursor = cursor(key, hint_node); + RBNode* node = node_cursor.node(); + if (node != nullptr) { + node->set_val(val); + return true; + } + + node = allocate_node(key, val); + if (node == nullptr) { + return false; + } + insert_at_cursor(node, node_cursor); + return true; +} + +template +inline V* RBTree::find(const K& key) { + Cursor node_cursor = cursor(key); + return node_cursor.found() ? &node_cursor.node()->_value : nullptr; +} + +template +inline V* RBTree::find(const K& key) const { + const Cursor node_cursor = cursor(key); + return node_cursor.found() ? &node_cursor.node()->_value : nullptr; +} + +template +inline void RBTree::remove(RBNode* node) { + Cursor node_cursor = cursor(node); + BaseType::remove_at_cursor(node_cursor); + free_node(node); +} + +template +inline bool RBTree::remove(const K& key) { + Cursor node_cursor = cursor(key); + if (!node_cursor.found()) { + return false; + } + RBNode* node = node_cursor.node(); + BaseType::remove_at_cursor(node_cursor); + free_node((RBNode*)node); + return true; +} + +template +inline void RBTree::remove_all() { + IntrusiveRBNode* to_delete[64]; + int stack_idx = 0; + to_delete[stack_idx++] = BaseType::_root; + + while (stack_idx > 0) { + IntrusiveRBNode* head = to_delete[--stack_idx]; + if (head == nullptr) continue; + to_delete[stack_idx++] = head->_left; + to_delete[stack_idx++] = head->_right; + free_node((RBNode*)head); + } + BaseType::_num_nodes = 0; + BaseType::_root = nullptr; +} + +template +inline void* RBTreeCHeapAllocator::allocate(size_t sz) { + return AllocateHeap(sz, mem_tag, strategy); +} + +template +inline void RBTreeCHeapAllocator::free(void* ptr) { + FreeHeap(ptr); +} + +template +inline RBTreeArenaAllocator::RBTreeArenaAllocator(Arena* arena) : _arena(arena) {} + +template +inline void* RBTreeArenaAllocator::allocate(size_t sz) { + return _arena->Amalloc(sz, strategy); +} + +template +inline void RBTreeArenaAllocator::free(void* ptr) { /* NOP */ } + +template +inline RBTreeResourceAreaAllocator::RBTreeResourceAreaAllocator(ResourceArea* rarea) : _rarea(rarea) {} + +template +inline void* RBTreeResourceAreaAllocator::allocate(size_t sz) { + return _rarea->Amalloc(sz, strategy); +} + +template +inline void RBTreeResourceAreaAllocator::free(void* ptr) { /* NOP */ } + #endif // SHARE_UTILITIES_RBTREE_INLINE_HPP diff --git a/src/hotspot/share/utilities/singleWriterSynchronizer.hpp b/src/hotspot/share/utilities/singleWriterSynchronizer.hpp index 450c7e89233..c21c9d4ee5e 100644 --- a/src/hotspot/share/utilities/singleWriterSynchronizer.hpp +++ b/src/hotspot/share/utilities/singleWriterSynchronizer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +27,7 @@ #include "memory/allocation.hpp" #include "runtime/atomic.hpp" +#include "runtime/safepointVerifiers.hpp" #include "runtime/semaphore.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -101,12 +102,14 @@ inline void SingleWriterSynchronizer::exit(uint enter_value) { } class SingleWriterSynchronizer::CriticalSection : public StackObj { + NoSafepointVerifier _nsv; SingleWriterSynchronizer* _synchronizer; uint _enter_value; public: // Enter synchronizer's critical section. explicit CriticalSection(SingleWriterSynchronizer* synchronizer) : + _nsv(), _synchronizer(synchronizer), _enter_value(synchronizer->enter()) {} diff --git a/src/hotspot/share/utilities/stringUtils.hpp b/src/hotspot/share/utilities/stringUtils.hpp index c3d21233808..66c8d30c7c0 100644 --- a/src/hotspot/share/utilities/stringUtils.hpp +++ b/src/hotspot/share/utilities/stringUtils.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,7 @@ #define SHARE_UTILITIES_STRINGUTILS_HPP #include "memory/allStatic.hpp" - -#ifdef _WINDOWS - // strtok_s is the Windows thread-safe equivalent of POSIX strtok_r -# define strtok_r strtok_s -#endif +#include "utilities/globalDefinitions.hpp" class StringUtils : AllStatic { public: diff --git a/src/hotspot/share/utilities/tableStatistics.cpp b/src/hotspot/share/utilities/tableStatistics.cpp index 331652becd5..34d0969969a 100644 --- a/src/hotspot/share/utilities/tableStatistics.cpp +++ b/src/hotspot/share/utilities/tableStatistics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,6 @@ * */ -#include "runtime/atomicAccess.hpp" #include "runtime/os.hpp" #include "utilities/debug.hpp" #include "utilities/macros.hpp" @@ -42,7 +41,7 @@ TableRateStatistics::~TableRateStatistics() { }; void TableRateStatistics::add() { #if INCLUDE_JFR if (Jfr::is_recording()) { - AtomicAccess::inc(&_added_items); + _added_items.add_then_fetch(1u); } #endif } @@ -50,7 +49,7 @@ void TableRateStatistics::add() { void TableRateStatistics::remove() { #if INCLUDE_JFR if (Jfr::is_recording()) { - AtomicAccess::inc(&_removed_items); + _removed_items.add_then_fetch(1u); } #endif } @@ -61,8 +60,8 @@ void TableRateStatistics::stamp() { _added_items_stamp_prev = _added_items_stamp; _removed_items_stamp_prev = _removed_items_stamp; - _added_items_stamp = _added_items; - _removed_items_stamp = _removed_items; + _added_items_stamp = _added_items.load_relaxed(); + _removed_items_stamp = _removed_items.load_relaxed(); if (_time_stamp == 0) { _time_stamp = now - 1000000000; diff --git a/src/hotspot/share/utilities/tableStatistics.hpp b/src/hotspot/share/utilities/tableStatistics.hpp index d4fd3302922..95856114833 100644 --- a/src/hotspot/share/utilities/tableStatistics.hpp +++ b/src/hotspot/share/utilities/tableStatistics.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #define SHARE_UTILITIES_TABLE_STATISTICS_HPP #include "memory/allocation.hpp" +#include "runtime/atomic.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/numberSeq.hpp" @@ -35,8 +36,8 @@ class TableRateStatistics : public CHeapObj { friend class TableStatistics; private: - volatile size_t _added_items; - volatile size_t _removed_items; + Atomic _added_items; + Atomic _removed_items; jlong _time_stamp; double _seconds_stamp; diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 6088eafbda4..d78fd331b56 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -43,7 +43,6 @@ #include "oops/compressedOops.hpp" #include "prims/whitebox.hpp" #include "runtime/arguments.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/flags/jvmFlag.hpp" #include "runtime/frame.inline.hpp" #include "runtime/init.hpp" @@ -86,12 +85,12 @@ bool VMError::coredump_status; char VMError::coredump_message[O_BUFLEN]; int VMError::_current_step; const char* VMError::_current_step_info; -volatile jlong VMError::_reporting_start_time = -1; -volatile bool VMError::_reporting_did_timeout = false; -volatile jlong VMError::_step_start_time = -1; -volatile bool VMError::_step_did_timeout = false; -volatile bool VMError::_step_did_succeed = false; -volatile intptr_t VMError::_first_error_tid = -1; +Atomic VMError::_reporting_start_time{-1}; +Atomic VMError::_reporting_did_timeout{false}; +Atomic VMError::_step_start_time{-1}; +Atomic VMError::_step_did_timeout{false}; +Atomic VMError::_step_did_succeed{false}; +Atomic VMError::_first_error_tid{-1}; int VMError::_id; const char* VMError::_message; char VMError::_detail_msg[1024]; @@ -105,8 +104,8 @@ int VMError::_lineno; size_t VMError::_size; const size_t VMError::_reattempt_required_stack_headroom = 64 * K; const intptr_t VMError::segfault_address = pd_segfault_address; -Thread* volatile VMError::_handshake_timed_out_thread = nullptr; -Thread* volatile VMError::_safepoint_timed_out_thread = nullptr; +Atomic VMError::_handshake_timed_out_thread{}; +Atomic VMError::_safepoint_timed_out_thread{}; // List of environment variables that should be reported in error log file. static const char* env_list[] = { @@ -248,7 +247,7 @@ bool VMError::can_reattempt_step(const char* &stop_reason) { return false; } - if (_step_did_timeout) { + if (_step_did_timeout.load_relaxed()) { stop_reason = "Step time limit reached"; return false; } @@ -534,8 +533,7 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) { "", "", #endif UseCompressedOops ? ", compressed oops" : "", - UseCompactObjectHeaders ? ", compact obj headers" - : (UseCompressedClassPointers ? ", compressed class ptrs" : ""), + UseCompactObjectHeaders ? ", compact obj headers" : "", GCConfig::hs_err_name(), VM_Version::vm_platform_string() ); @@ -543,12 +541,12 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) { // Returns true if at least one thread reported a fatal error and fatal error handling is in process. bool VMError::is_error_reported() { - return _first_error_tid != -1; + return _first_error_tid.load_relaxed() != -1; } // Returns true if the current thread reported a fatal error. bool VMError::is_error_reported_in_current_thread() { - return _first_error_tid == os::current_thread_id(); + return _first_error_tid.load_relaxed() == os::current_thread_id(); } // Helper, return current timestamp for timeout handling. @@ -560,24 +558,24 @@ jlong VMError::get_current_timestamp() { void VMError::record_reporting_start_time() { const jlong now = get_current_timestamp(); - AtomicAccess::store(&_reporting_start_time, now); + _reporting_start_time.store_relaxed(now); } jlong VMError::get_reporting_start_time() { - return AtomicAccess::load(&_reporting_start_time); + return _reporting_start_time.load_relaxed(); } void VMError::record_step_start_time() { const jlong now = get_current_timestamp(); - AtomicAccess::store(&_step_start_time, now); + _step_start_time.store_relaxed(now); } jlong VMError::get_step_start_time() { - return AtomicAccess::load(&_step_start_time); + return _step_start_time.load_relaxed(); } void VMError::clear_step_start_time() { - return AtomicAccess::store(&_step_start_time, (jlong)0); + return _step_start_time.store_relaxed(0); } // This is the main function to report a fatal error. Only one thread can @@ -612,31 +610,31 @@ void VMError::report(outputStream* st, bool _verbose) { const char* stop_reattempt_reason = nullptr; # define BEGIN \ if (_current_step == 0) { \ - _step_did_succeed = false; \ + _step_did_succeed.store_relaxed(false); \ _current_step = __LINE__; \ { // [Begin logic] # define STEP_IF(s, cond) \ } \ - _step_did_succeed = true; \ + _step_did_succeed.store_relaxed(true); \ } \ if (_current_step < __LINE__) { \ - _step_did_succeed = false; \ + _step_did_succeed.store_relaxed(false); \ _current_step = __LINE__; \ _current_step_info = s; \ if ((cond)) { \ record_step_start_time(); \ - _step_did_timeout = false; + _step_did_timeout.store_relaxed(false); // [Step logic] # define STEP(s) STEP_IF(s, true) # define REATTEMPT_STEP_IF(s, cond) \ } \ - _step_did_succeed = true; \ + _step_did_succeed.store_relaxed(true); \ } \ - if (_current_step < __LINE__ && !_step_did_succeed) { \ + if (_current_step < __LINE__ && !_step_did_succeed.load_relaxed()) { \ _current_step = __LINE__; \ _current_step_info = s; \ const bool cond_value = (cond); \ @@ -650,7 +648,7 @@ void VMError::report(outputStream* st, bool _verbose) { # define END \ } \ - _step_did_succeed = true; \ + _step_did_succeed.store_relaxed(true); \ clear_step_start_time(); \ } @@ -1216,7 +1214,7 @@ void VMError::report(outputStream* st, bool _verbose) { CompressedOops::print_mode(st); st->cr(); - STEP_IF("printing compressed klass pointers mode", _verbose && UseCompressedClassPointers) + STEP_IF("printing compressed klass pointers mode", _verbose) CDS_ONLY(AOTMetaspace::print_on(st);) Metaspace::print_compressed_class_space(st); CompressedKlassPointers::print_mode(st); @@ -1330,6 +1328,13 @@ void VMError::report(outputStream* st, bool _verbose) { STEP_IF("printing OS information", _verbose) os::print_os_info(st); st->cr(); +#ifdef __APPLE__ + // Avoid large stack allocation on Mac for FD count during signal-handling. + os::Bsd::print_open_file_descriptors(st, buf, sizeof(buf)); + st->cr(); +#else + os::print_open_file_descriptors(st); +#endif STEP_IF("printing CPU info", _verbose) os::print_cpu_info(st, buf, sizeof(buf)); @@ -1359,21 +1364,21 @@ void VMError::report(outputStream* st, bool _verbose) { void VMError::set_handshake_timed_out_thread(Thread* thread) { // Only preserve the first thread to time-out this way. The atomic operation ensures // visibility to the target thread. - AtomicAccess::replace_if_null(&_handshake_timed_out_thread, thread); + _handshake_timed_out_thread.compare_exchange(nullptr, thread); } void VMError::set_safepoint_timed_out_thread(Thread* thread) { // Only preserve the first thread to time-out this way. The atomic operation ensures // visibility to the target thread. - AtomicAccess::replace_if_null(&_safepoint_timed_out_thread, thread); + _safepoint_timed_out_thread.compare_exchange(nullptr, thread); } Thread* VMError::get_handshake_timed_out_thread() { - return AtomicAccess::load(&_handshake_timed_out_thread); + return _handshake_timed_out_thread.load_relaxed(); } Thread* VMError::get_safepoint_timed_out_thread() { - return AtomicAccess::load(&_safepoint_timed_out_thread); + return _safepoint_timed_out_thread.load_relaxed(); } // Report for the vm_info_cmd. This prints out the information above omitting @@ -1431,12 +1436,10 @@ void VMError::print_vm_info(outputStream* st) { #endif // STEP("printing compressed class ptrs mode") - if (UseCompressedClassPointers) { - CDS_ONLY(AOTMetaspace::print_on(st);) - Metaspace::print_compressed_class_space(st); - CompressedKlassPointers::print_mode(st); - st->cr(); - } + CDS_ONLY(AOTMetaspace::print_on(st);) + Metaspace::print_compressed_class_space(st); + CompressedKlassPointers::print_mode(st); + st->cr(); // Take heap lock over heap, GC and metaspace printing so that information // is consistent. @@ -1551,6 +1554,8 @@ void VMError::print_vm_info(outputStream* st) { os::print_os_info(st); st->cr(); + os::print_open_file_descriptors(st); + st->cr(); // STEP("printing CPU info") @@ -1708,8 +1713,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt static bool log_done = false; // done saving error log intptr_t mytid = os::current_thread_id(); - if (_first_error_tid == -1 && - AtomicAccess::cmpxchg(&_first_error_tid, (intptr_t)-1, mytid) == -1) { + if (_first_error_tid.compare_set(-1, mytid)) { if (SuppressFatalErrorMessage) { os::abort(CreateCoredumpOnCrash); @@ -1756,7 +1760,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt } else { // This is not the first error, see if it happened in a different thread // or in the same thread during error reporting. - if (_first_error_tid != mytid) { + if (_first_error_tid.load_relaxed() != mytid) { if (!SuppressFatalErrorMessage) { char msgbuf[64]; jio_snprintf(msgbuf, sizeof(msgbuf), @@ -1788,19 +1792,19 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt st->cr(); // Timeout handling. - if (_step_did_timeout) { + if (_step_did_timeout.load_relaxed()) { // The current step had a timeout. Lets continue reporting with the next step. st->print_raw("[timeout occurred during error reporting in step \""); st->print_raw(_current_step_info); st->print_cr("\"] after " INT64_FORMAT " s.", (int64_t) - ((get_current_timestamp() - _step_start_time) / TIMESTAMP_TO_SECONDS_FACTOR)); - } else if (_reporting_did_timeout) { + ((get_current_timestamp() - get_step_start_time()) / TIMESTAMP_TO_SECONDS_FACTOR)); + } else if (_reporting_did_timeout.load_relaxed()) { // We hit ErrorLogTimeout. Reporting will stop altogether. Let's wrap things // up, the process is about to be stopped by the WatcherThread. st->print_cr("------ Timeout during error reporting after " INT64_FORMAT " s. ------", (int64_t) - ((get_current_timestamp() - _reporting_start_time) / TIMESTAMP_TO_SECONDS_FACTOR)); + ((get_current_timestamp() - get_reporting_start_time()) / TIMESTAMP_TO_SECONDS_FACTOR)); st->flush(); // Watcherthread is about to call os::die. Lets just wait. os::infinite_sleep(); @@ -2100,10 +2104,10 @@ bool VMError::check_timeout() { // Timestamp is stored in nanos. if (reporting_start_time > 0) { const jlong end = reporting_start_time + (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR; - if (end <= now && !_reporting_did_timeout) { + if (end <= now && !_reporting_did_timeout.load_relaxed()) { // We hit ErrorLogTimeout and we haven't interrupted the reporting // thread yet. - _reporting_did_timeout = true; + _reporting_did_timeout.store_relaxed(true); interrupt_reporting_thread(); return true; // global timeout } @@ -2119,10 +2123,10 @@ bool VMError::check_timeout() { const int max_step_timeout_secs = 5; const jlong timeout_duration = MAX2((jlong)max_step_timeout_secs, (jlong)ErrorLogTimeout * TIMESTAMP_TO_SECONDS_FACTOR / 4); const jlong end = step_start_time + timeout_duration; - if (end <= now && !_step_did_timeout) { + if (end <= now && !_step_did_timeout.load_relaxed()) { // The step timed out and we haven't interrupted the reporting // thread yet. - _step_did_timeout = true; + _step_did_timeout.store_relaxed(true); interrupt_reporting_thread(); return false; // (Not a global timeout) } diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index 04cea6de47c..b46ba208788 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2022 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #define SHARE_UTILITIES_VMERROR_HPP #include "memory/allStatic.hpp" +#include "runtime/atomic.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/ostream.hpp" @@ -73,7 +74,7 @@ class VMError : public AllStatic { // Thread id of the first error. We must be able to handle native thread, // so use thread id instead of Thread* to identify thread. - static volatile intptr_t _first_error_tid; + static Atomic _first_error_tid; // Core dump status, false if we have been unable to write a core/minidump for some reason static bool coredump_status; @@ -85,16 +86,16 @@ class VMError : public AllStatic { // Timeout handling: // Timestamp at which error reporting started; -1 if no error reporting in progress. - static volatile jlong _reporting_start_time; + static Atomic _reporting_start_time; // Whether or not error reporting did timeout. - static volatile bool _reporting_did_timeout; + static Atomic _reporting_did_timeout; // Timestamp at which the last error reporting step started; -1 if no error reporting // in progress. - static volatile jlong _step_start_time; + static Atomic _step_start_time; // Whether or not the last error reporting step did timeout. - static volatile bool _step_did_timeout; + static Atomic _step_did_timeout; // Whether or not the last error reporting step did succeed. - static volatile bool _step_did_succeed; + static Atomic _step_did_succeed; // Install secondary signal handler to handle secondary faults during error reporting // (see VMError::crash_handler) @@ -143,8 +144,8 @@ class VMError : public AllStatic { static void clear_step_start_time(); // Handshake/safepoint timed out threads - static Thread* volatile _handshake_timed_out_thread; - static Thread* volatile _safepoint_timed_out_thread; + static Atomic _handshake_timed_out_thread; + static Atomic _safepoint_timed_out_thread; WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(const void* exrecord, const void* context);) diff --git a/src/hotspot/share/utilities/zipLibrary.cpp b/src/hotspot/share/utilities/zipLibrary.cpp index 54875516a0f..ad6bb82d43f 100644 --- a/src/hotspot/share/utilities/zipLibrary.cpp +++ b/src/hotspot/share/utilities/zipLibrary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "jvm_io.h" #include "runtime/arguments.hpp" +#include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/os.inline.hpp" #include "runtime/semaphore.inline.hpp" @@ -50,10 +51,10 @@ static ZIP_GZip_InitParams_t ZIP_GZip_InitParams = nullptr; static ZIP_GZip_Fully_t ZIP_GZip_Fully = nullptr; static void* _zip_handle = nullptr; -static bool _loaded = false; +static Atomic _loaded{false}; static inline bool is_loaded() { - return AtomicAccess::load_acquire(&_loaded); + return _loaded.load_acquire(); } static inline bool not_loaded() { @@ -111,7 +112,7 @@ static void load_zip_library(bool vm_exit_on_failure) { } store_function_pointers(&path[0], vm_exit_on_failure); - AtomicAccess::release_store(&_loaded, true); + _loaded.release_store(true); assert(is_loaded(), "invariant"); } diff --git a/src/java.base/aix/native/include/dl_info.h b/src/java.base/aix/native/include/dl_info.h new file mode 100644 index 00000000000..0ea10149300 --- /dev/null +++ b/src/java.base/aix/native/include/dl_info.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1996, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. 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. + */ + +#ifndef AIX_INCLUDE_DL_INFO_H +#define AIX_INCLUDE_DL_INFO_H + +/* struct for dladdr + * Differences between AIX dladdr and Linux dladdr: + * + * 1) Dl_info.dli_fbase: can never work, is not included in our struct + * A loaded image on AIX is divided in multiple segments, at least two + * (text and data) but potentially also far more. This is because the loader may + * load each member into an own segment, as for instance happens with the libC.a + * 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a + * zero-length string is returned (""). + * 3) Dl_info.dli_saddr: For code, this will return the entry point of the function, + * not the function descriptor. + */ + +typedef struct { + const char *dli_fname; /* file path of loaded library */ + const char *dli_sname; /* symbol name; "" if not known */ + void *dli_saddr; /* address of *entry* of function; not function descriptor; */ +} Dl_info; + +#endif diff --git a/src/java.base/aix/native/libjli/java_md_aix.h b/src/java.base/aix/native/libjli/java_md_aix.h index d319a1d6353..d63030fc65e 100644 --- a/src/java.base/aix/native/libjli/java_md_aix.h +++ b/src/java.base/aix/native/libjli/java_md_aix.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 SAP SE. All rights reserved. + * Copyright (c) 2016, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,12 +37,7 @@ * in the hotspot implementation which is not available at this place, though. */ -typedef struct { - const char *dli_fname; /* file path of loaded library */ - void *dli_fbase; /* unsupported */ - const char *dli_sname; /* unsupported */ - void *dli_saddr; /* unsupported */ -} Dl_info; +#include "dl_info.h" int dladdr(void *addr, Dl_info *info); diff --git a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java index 44e957f54fb..ec3e135b8b1 100644 --- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -139,10 +139,7 @@ class LinuxFileSystem extends UnixFileSystem { int size, long addressToPollForCancel) throws UnixException { - int advice = POSIX_FADV_SEQUENTIAL | // sequential data access - POSIX_FADV_NOREUSE | // will access only once - POSIX_FADV_WILLNEED; // will access in near future - posix_fadvise(src, 0, 0, advice); + posix_fadvise(src, 0, 0, POSIX_FADV_SEQUENTIAL); super.bufferedCopy(dst, src, address, size, addressToPollForCancel); } @@ -151,10 +148,7 @@ class LinuxFileSystem extends UnixFileSystem { int directCopy(int dst, int src, long addressToPollForCancel) throws UnixException { - int advice = POSIX_FADV_SEQUENTIAL | // sequential data access - POSIX_FADV_NOREUSE | // will access only once - POSIX_FADV_WILLNEED; // will access in near future - posix_fadvise(src, 0, 0, advice); + posix_fadvise(src, 0, 0, POSIX_FADV_SEQUENTIAL); return directCopy0(dst, src, addressToPollForCancel); } diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index daed5f3cce5..cd6bd7683f7 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -2219,7 +2219,7 @@ public class ObjectInputStream * mechanism marks the record as having an exception. * Null is returned from readRecord and later the exception is thrown at * the exit of {@link #readObject(Class)}. - **/ + */ private Object readRecord(ObjectStreamClass desc) throws IOException { ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout(); if (slots.length != 1) { diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index 4c24e98a549..49ab80edfea 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -28,14 +28,10 @@ package java.lang; import jdk.internal.vm.annotation.IntrinsicCandidate; import java.lang.constant.Constable; -import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDescs; import java.lang.constant.DynamicConstantDesc; import java.util.Optional; -import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL; -import static java.lang.constant.ConstantDescs.CD_Boolean; - /** * The {@code Boolean} class is the {@linkplain * java.lang##wrapperClass wrapper class} for values of the primitive diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index 0f3f7f40d05..c2c03e7a3c2 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -36,7 +36,6 @@ import java.util.Optional; import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; import static java.lang.constant.ConstantDescs.CD_byte; -import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; /** diff --git a/src/java.base/share/classes/java/lang/Character.java b/src/java.base/share/classes/java/lang/Character.java index ffda729a45a..158c3126ab3 100644 --- a/src/java.base/share/classes/java/lang/Character.java +++ b/src/java.base/share/classes/java/lang/Character.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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 @@ -67,9 +67,13 @@ import static java.lang.constant.ConstantDescs.DEFAULT_NAME; * Character information is based on the Unicode Standard, version 17.0. *

* The Java platform has supported different versions of the Unicode - * Standard over time. Upgrades to newer versions of the Unicode Standard - * occurred in the following Java releases, each indicating the new version: + * Standard over time. The following tables list the version of Unicode used + * in each Java release. Unless otherwise specified, all update releases in a + * given Java release family use the same Unicode version. * + * * * * @@ -78,26 +82,56 @@ import static java.lang.constant.ConstantDescs.DEFAULT_NAME; * * * + * + * + * + * + * + * + * + * + * + * + * + *
Shows Java releases and supported Unicode versions
Java release
Java SE 26Unicode 17.0
Java SE 25Unicode 16.0
Java SE 21Unicode 15.0
Java SE 17Unicode 13.0
Java SE 11Unicode 10.0
Java SE 8Unicode 6.2
+ *

+ * Show other Java releases + *

Java releases prior to Java SE 8 are listed only if they upgraded the + * Unicode version

+ * + * + * + * + * + * + * * * + * + * * * * * * * + * + * + * + * * * + * + * * * * * - * - * + * + * * * - * - * * * * @@ -110,6 +144,8 @@ import static java.lang.constant.ConstantDescs.DEFAULT_NAME; * * *
Shows other Java releases and supported Unicode + * versions
Java releaseUnicode version
Java SE 24Unicode 16.0
Java SE 23Unicode 15.1
Java SE 22Unicode 15.1
Java SE 20Unicode 15.0
Java SE 19Unicode 14.0
Java SE 18Unicode 13.0
Java SE 16Unicode 13.0
Java SE 15Unicode 13.0
Java SE 14Unicode 12.1
Java SE 13Unicode 12.1
Java SE 12Unicode 11.0
Java SE 11Unicode 10.0
Java SE 10Unicode 8.0
Java SE 9Unicode 8.0
Java SE 8Unicode 6.2
Java SE 7Unicode 6.0
Java SE 5.0Unicode 1.1.5
+ *
+ *

* Variations from these base Unicode versions, such as recognized appendixes, * are documented elsewhere. *

Unicode Character Representations

@@ -11233,7 +11269,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is an Emoji; * {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isEmoji(int codePoint) { @@ -11252,7 +11288,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character has the Emoji Presentation * property; {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isEmojiPresentation(int codePoint) { @@ -11271,7 +11307,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is an Emoji Modifier; * {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isEmojiModifier(int codePoint) { @@ -11290,7 +11326,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is an Emoji Modifier Base; * {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isEmojiModifierBase(int codePoint) { @@ -11309,7 +11345,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is an Emoji Component; * {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isEmojiComponent(int codePoint) { @@ -11328,7 +11364,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is an Extended Pictographic; * {@code false} otherwise. - * @spec https://unicode.org/reports/tr51/ Unicode Emoji + * @spec https://www.unicode.org/reports/tr51/ Unicode Emoji * @since 21 */ public static boolean isExtendedPictographic(int codePoint) { diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index eab1993a2b4..8a2f722f3dd 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -224,9 +224,9 @@ public final class Class implements java.io.Serializable, AnnotatedElement, TypeDescriptor.OfField>, Constable { - private static final int ANNOTATION= 0x00002000; - private static final int ENUM = 0x00004000; - private static final int SYNTHETIC = 0x00001000; + private static final int ANNOTATION = 0x00002000; + private static final int ENUM = 0x00004000; + private static final int SYNTHETIC = 0x00001000; private static native void registerNatives(); static { @@ -1390,6 +1390,7 @@ public final class Class implements java.io.Serializable, // INNER_CLASS forbids. INNER_CLASS allows PRIVATE, PROTECTED, // and STATIC, which are not allowed on Location.CLASS. // Use getClassFileAccessFlags to expose SUPER status. + // Arrays need to use PRIVATE/PROTECTED from its component modifiers. var location = (isMemberClass() || isLocalClass() || isAnonymousClass() || isArray()) ? AccessFlag.Location.INNER_CLASS : @@ -3779,7 +3780,7 @@ public final class Class implements java.io.Serializable, * @since 1.8 */ public AnnotatedType[] getAnnotatedInterfaces() { - return TypeAnnotationParser.buildAnnotatedInterfaces(getRawTypeAnnotations(), getConstantPool(), this); + return TypeAnnotationParser.buildAnnotatedInterfaces(getRawTypeAnnotations(), getConstantPool(), this); } private native Class getNestHost0(); diff --git a/src/java.base/share/classes/java/lang/FdLibm.java b/src/java.base/share/classes/java/lang/FdLibm.java index 78090be2b05..5a6bdc9b94e 100644 --- a/src/java.base/share/classes/java/lang/FdLibm.java +++ b/src/java.base/share/classes/java/lang/FdLibm.java @@ -3561,4 +3561,98 @@ final class FdLibm { return hx > 0 ? w : -w; } } + + /** + * Return the Inverse Hyperbolic Cosine of x + * + * Method : + * + * + * acosh(x) is defined so that acosh(cosh(alpha)) = alpha, -∞ < alpha < ∞ + * and cosh(acosh(x)) = x, 1 <= x < ∞. + * It can be written as acosh(x) = log(x + sqrt(x^2 - 1)), 1 <= x < ∞. + * acosh(x) := log(x)+ln2, if x is large; else + * := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else + * := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. + * + * + * + * Special cases: + * acosh(x) is NaN with signal if x < 1. + * acosh(NaN) is NaN without signal. + */ + static final class Acosh { + private static final double ln2 = 6.93147180559945286227e-01; + + static double compute(double x) { + double t; + int hx; + hx = __HI(x); + if (hx < 0x3ff0_0000) { // x < 1 */ + return (x - x) / (x - x); + } else if (hx >= 0x41b0_0000) { // x > 2**28 + if (hx >= 0x7ff0_0000) { // x is inf of NaN + return x + x; + } else { + return Log.compute(x) + ln2; // acosh(huge) = log(2x) + } + } else if (((hx - 0x3ff0_0000) | __LO(x)) == 0) { + return 0.0; // acosh(1) = 0 + } else if (hx > 0x4000_0000) { // 2**28 > x > 2 + t = x * x; + return Log.compute(2.0 * x - 1.0 / (x + Sqrt.compute(t - 1.0))); + } else { // 1< x <2 + t = x - 1.0; + return Log1p.compute(t + Sqrt.compute(2.0 * t + t * t)); + } + } + } + + /** + * Return the Inverse Hyperbolic Tangent of x + * Method : + * + * + * atanh(x) is defined so that atanh(tanh(alpha)) = alpha, -∞ < alpha < ∞ + * and tanh(atanh(x)) = x, -1 < x < 1; + * It can be written as atanh(x) = 0.5 * log1p(2 * x/(1-x)), -1 < x < 1; + * 1. + * atanh(x) := 0.5 * log1p(2 * x/(1 - x)), if |x| >= 0.5, + * := 0.5 * log1p(2x + 2x * x/(1 - x)), if |x| < 0.5. + * + * + * + * Special cases: + * only atanh(±0)=±0 is exact for finite x. + * atanh(NaN) is NaN + * atanh(±1) is ±∞ + */ + static final class Atanh { + + static double compute(double x) { + double t; + int hx,ix; + int lx; // unsigned + hx = __HI(x); // high word + lx = __LO(x); // low word + ix = hx & 0x7fff_ffff; + if ((ix | ((lx | (-lx)) >>> 31)) > 0x3ff0_0000) { // |x| > 1 + return (x - x) / (x - x); + } + if (ix == 0x3ff0_0000) { + return x / 0.0; + } + if (ix < 0x3e30_0000 && (HUGE + x) > 0.0) { + return x; // x<2**-28 + } + x = __HI(x, ix); // x <- |x| + if (ix < 0x3fe0_0000) { // x < 0.5 + t = x + x; + t = 0.5 * Log1p.compute(t + t * x / (1.0 - x)); + } else { + t = 0.5 * Log1p.compute((x + x) / (1.0 - x)); + } + return hx >= 0 ? t : -t; + } + } } diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java index 7add99f9325..38a5328fa0b 100644 --- a/src/java.base/share/classes/java/lang/Math.java +++ b/src/java.base/share/classes/java/lang/Math.java @@ -109,10 +109,10 @@ import static java.lang.Double.*; * acos acos}, {@link atan atan}, {@link exp exp}, {@link expm1 * expm1}, {@link log log}, {@link log10 log10}, {@link log1p log1p}, * {@link sinh sinh}, {@link cosh cosh}, {@link tanh tanh}, {@link asinh asinh}, - * {@link hypot hypot}, and {@link pow pow}. (The {@link sqrt sqrt} - * operation is a required part of IEEE 754 from a different section - * of the standard.) The special case behavior of the recommended - * operations generally follows the guidance of the IEEE 754 + * {@link acosh acosh}, {@link atanh atanh}, {@link hypot hypot}, and {@link pow pow}. + * (The {@link sqrt sqrt} operation is a required part of IEEE 754 + * from a different section of the standard.) The special case behavior + * of the recommended operations generally follows the guidance of the IEEE 754 * standard. However, the {@code pow} method defines different * behavior for some arguments, as noted in its {@linkplain pow * specification}. The IEEE 754 standard defines its operations to be @@ -2785,6 +2785,67 @@ public final class Math { return StrictMath.asinh(x); } + + + /** + * Returns the inverse hyperbolic cosine of a {@code double} value. + * The inverse hyperbolic cosine of x is defined to be the function such that + * acosh({@linkplain Math#cosh cosh(x)}) = x for any x >= 0. + * Note that range of the exact acosh(x) is >= 0. + *

Special cases: + *

    + * + *
  • If the argument is positive infinity, then the result is + * positive infinity + * + *
  • If the argument less than 1, then the result is NaN. + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is {@code 1.0}, then the result is positive zero. + * + *
+ *

The computed result must be within 2.5 ulps of the exact result. + * @param x The number whose inverse hyperbolic cosine is to be returned. + * @return The inverse hyperbolic cosine of {@code x}. + * @since 27 + */ + public static double acosh(double x) { + return StrictMath.acosh(x); + } + + /** + * Returns the inverse hyperbolic tangent of a {@code double} value. + * The inverse hyperbolic tangent of x is defined to be the function such that + * atanh({@linkplain Math#tanh tanh(x)}) = x for any x. + * Note that the domain of the exact atanh is (-1; 1), the range is unrestricted. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
  • If the argument is {@code +1.0}, then the result is + * positive infinity. + * + *
  • If the argument is {@code -1.0}, then the result is + * negative infinity. + * + *
  • If the argument is greater than {@code 1.0} in magnitude, then the result is NaN. + * + *
+ *

The computed result must be within 2.5 ulps of the exact result. + * @param x The number whose inverse hyperbolic tangent is to be returned. + * @return The inverse hyperbolic tangent of {@code x}. + * @since 27 + */ + public static double atanh(double x) { + return StrictMath.atanh(x); + } + /** * Returns sqrt(x2 +y2) * without intermediate overflow or underflow. diff --git a/src/java.base/share/classes/java/lang/ProcessBuilder.java b/src/java.base/share/classes/java/lang/ProcessBuilder.java index d461818eedf..bc92ea4ee82 100644 --- a/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -930,6 +930,12 @@ public final class ProcessBuilder * command interpreters, or the standard C library function * {@code system()}. * + * @implNote + * When the process is {@link #start started}, + * if {#code System.out} and/or {#code System.err} have been + * closed in the current process, the corresponding output + * in the subprocess will be discarded. + * * @return this process builder * @since 1.7 */ diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index 920500a7fa3..14f7a267165 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -35,7 +35,6 @@ import java.lang.constant.DynamicConstantDesc; import java.util.Optional; import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; -import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.CD_short; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; diff --git a/src/java.base/share/classes/java/lang/Shutdown.java b/src/java.base/share/classes/java/lang/Shutdown.java index 87c4732a5ce..a9d4d6a28a9 100644 --- a/src/java.base/share/classes/java/lang/Shutdown.java +++ b/src/java.base/share/classes/java/lang/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -55,11 +55,10 @@ class Shutdown { private static int currentRunningHook = -1; /* The preceding static fields are protected by this lock */ - private static class Lock { }; - private static Object lock = new Lock(); + private static final Object lock = new Object(); /* Lock object for the native halt method */ - private static Object haltLock = new Lock(); + private static final Object haltLock = new Object(); /** * Add a new system shutdown hook. Checks the shutdown state and diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java index 9540c4b05b4..a8f67ef58ba 100644 --- a/src/java.base/share/classes/java/lang/StrictMath.java +++ b/src/java.base/share/classes/java/lang/StrictMath.java @@ -76,8 +76,8 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * {@code exp}, {@code log}, {@code log10}, * {@code cbrt}, {@code atan2}, {@code pow}, * {@code sinh}, {@code cosh}, {@code tanh}, - * {@code asinh}, {@code hypot}, {@code expm1}, - * and {@code log1p}. + * {@code asinh}, {@code acosh},{@code atanh}, + * {@code hypot}, {@code expm1}, and {@code log1p}. * *

* The platform uses signed two's complement integer arithmetic with @@ -2196,6 +2196,64 @@ public final class StrictMath { return FdLibm.Asinh.compute(x); } + /** + * Returns the inverse hyperbolic cosine of a {@code double} value. + * The inverse hyperbolic cosine of x is defined to be the function such that + * acosh({@linkplain Math#cosh cosh(x)}) = x for any x >= 0. + * Note that range of the exact acosh(x) is >= 0. + *

Special cases: + *

    + * + *
  • If the argument is positive infinity, then the result is + * positive infinity + * + *
  • If the argument less than {@code 1.0}, then the result is NaN. + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is {@code 1.0}, then the result is positive zero. + * + *
+ * @param x The number whose inverse hyperbolic cosine is to be returned. + * @return The inverse hyperbolic cosine of {@code x}. + * @since 27 + */ + public static double acosh(double x) { + return FdLibm.Acosh.compute(x); + } + + /** + * Returns the inverse hyperbolic tangent of a {@code double} value. + * The inverse hyperbolic tangent of x is defined to be the function such that + * atanh({@linkplain Math#tanh tanh(x)}) = x for any x. + * Note that the domain of the exact atanh is (-1; 1), the range is unrestricted. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
  • If the argument is {@code +1.0}, then the result is + * positive infinity. + * + *
  • If the argument is {@code -1.0}, then the result is + * negative infinity. + * + *
  • If the argument is greater than {@code 1.0} in magnitude, then the result is NaN. + * + *
+ * + * @param x The number whose inverse hyperbolic tangent is to be returned. + * @return The inverse hyperbolic tangent of {@code x}. + * @since 27 + */ + public static double atanh(double x) { + return FdLibm.Atanh.compute(x); + } + /** * Returns sqrt(x2 +y2) * without intermediate overflow or underflow. diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index fc05febdb45..c6c08ed4473 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1133,6 +1133,34 @@ public final class String return Arrays.copyOf(dst, dp); } + // This follows the implementation of encodeASCII and encode8859_1 + private static int encodedLengthASCIIor8859_1(byte coder, byte[] val) { + if (coder == LATIN1) { + return val.length; + } + int len = val.length >> 1; + int dp = 0; + int sp = 0; + int sl = len; + while (sp < sl) { + char c = StringUTF16.getChar(val, sp); + if (c >= Character.MIN_HIGH_SURROGATE) { + break; + } + dp++; + sp++; + } + while (sp < sl) { + char c = StringUTF16.getChar(val, sp++); + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { + sp++; + } + dp++; + } + return dp; + } + //------------------------------ utf8 ------------------------------------ /** @@ -1467,6 +1495,27 @@ public final class String return Arrays.copyOf(dst, dp); } + // This follows the implementation of encodeUTF8 + private static int encodedLengthUTF8(byte coder, byte[] val) { + if (coder == UTF16) { + return encodedLengthUTF8_UTF16(val, null); + } + int positives = StringCoding.countPositives(val, 0, val.length); + if (positives == val.length) { + return positives; + } + int dp = positives; + for (int i = dp; i < val.length; i++) { + byte c = val[i]; + if (c < 0) { + dp += 2; + } else { + dp++; + } + } + return dp; + } + /** * {@return the byte array obtained by first decoding {@code val} with * UTF-16, and then encoding the result with UTF-8} @@ -1484,11 +1533,8 @@ public final class String int sl = val.length >> 1; // UTF-8 encoded can be as much as 3 times the string length // For very large estimate, (as in overflow of 32 bit int), precompute the exact size - long allocLen = (sl * 3 < 0) ? computeSizeUTF8_UTF16(val, exClass) : sl * 3; - if (allocLen > (long)Integer.MAX_VALUE) { - throw new OutOfMemoryError("Required length exceeds implementation limit"); - } - byte[] dst = new byte[(int) allocLen]; + int allocLen = (sl * 3 < 0) ? encodedLengthUTF8_UTF16(val, exClass) : sl * 3; + byte[] dst = new byte[allocLen]; while (sp < sl) { // ascii fast loop; char c = StringUTF16.getChar(val, sp); @@ -1547,11 +1593,20 @@ public final class String * @param The exception type parameter to enable callers to avoid * having to declare the exception */ - private static long computeSizeUTF8_UTF16(byte[] val, Class exClass) throws E { + private static int encodedLengthUTF8_UTF16(byte[] val, Class exClass) throws E { long dp = 0L; int sp = 0; int sl = val.length >> 1; + while (sp < sl) { + // ascii fast loop; + char c = StringUTF16.getChar(val, sp); + if (c >= '\u0080') { + break; + } + dp++; + sp++; + } while (sp < sl) { char c = StringUTF16.getChar(val, sp++); if (c < 0x80) { @@ -1580,7 +1635,10 @@ public final class String dp += 3; } } - return dp; + if (dp > (long)Integer.MAX_VALUE) { + throw new OutOfMemoryError("Required length exceeds implementation limit"); + } + return (int) dp; } /** @@ -2045,6 +2103,29 @@ public final class String return encode(Charset.defaultCharset(), coder(), value); } + /** + * {@return the length in bytes of this {@code String} encoded with the given {@link Charset}} + * + *

The returned length accounts for the replacement of malformed-input and unmappable-character + * sequences with the charset's default replacement byte array. The result will be the same value + * as {@link #getBytes(Charset) getBytes(cs).length}. + * + * @apiNote This method provides equivalent or better performance than {@link #getBytes(Charset) + * getBytes(cs).length}. + * + * @param cs The {@link Charset} used to the compute the length + * @since 27 + */ + public int encodedLength(Charset cs) { + Objects.requireNonNull(cs); + if (cs == UTF_8.INSTANCE) { + return encodedLengthUTF8(coder, value); + } else if (cs == ISO_8859_1.INSTANCE || cs == US_ASCII.INSTANCE) { + return encodedLengthASCIIor8859_1(coder, value); + } + return getBytes(cs).length; + } + boolean bytesCompatible(Charset charset, int srcIndex, int numChars) { if (isLatin1()) { if (charset == ISO_8859_1.INSTANCE) { diff --git a/src/java.base/share/classes/java/lang/StringLatin1.java b/src/java.base/share/classes/java/lang/StringLatin1.java index 21a8b2dd61a..adfd9c6dbab 100644 --- a/src/java.base/share/classes/java/lang/StringLatin1.java +++ b/src/java.base/share/classes/java/lang/StringLatin1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +27,7 @@ package java.lang; import java.util.Arrays; import java.util.Locale; +import java.util.Objects; import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.IntConsumer; @@ -39,12 +40,22 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; import static java.lang.String.LATIN1; import static java.lang.String.UTF16; -import static java.lang.String.checkIndex; -import static java.lang.String.checkOffset; +/** + * Latin-1 string operations. + *

+ * Unless stated otherwise, all methods assume that + *

    + *
  • {@code byte[]} arguments denote a Latin-1 string byte array + *
  • indices, offsets, and lengths (typically of type {@code int}) are in + * number of characters, i.e., the number of {@code byte}s/{@code char}s for + * Latin-1 strings, and the number of Unicode + * code units for UTF-16 strings + *
+ */ final class StringLatin1 { static char charAt(byte[] value, int index) { - checkIndex(index, value.length); + String.checkIndex(index, value.length); return (char)(value[index] & 0xff); } @@ -84,8 +95,23 @@ final class StringLatin1 { System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin); } - @IntrinsicCandidate + /** + * {@return {@code true} if provided byte arrays contain identical content; {@code false} otherwise}. + * + * @param value a byte array + * @param other a byte array + * + * @throws NullPointerException if {@code value} or {@code other} is null + */ static boolean equals(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); + return equals0(value, other); + } + + // vmIntrinsics::_equalsL + @IntrinsicCandidate + private static boolean equals0(byte[] value, byte[] other) { if (value.length == other.length) { for (int i = 0; i < value.length; i++) { if (value[i] != other[i]) { @@ -97,33 +123,102 @@ final class StringLatin1 { return false; } - @IntrinsicCandidate + /** + * Lexicographically compares two Latin-1 strings as specified in + * {@link String#compareTo(String) String::compareTo}. + * + * @param value a Latin-1 string byte array + * @param other a Latin-1 string byte array + * + * @return {@code 0} if {@code value} is equal to {@code other}, a value + * less than {@code 0} if {@code value} is lexicographically less than + * {@code other}; a value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + */ static int compareTo(byte[] value, byte[] other) { - int len1 = value.length; - int len2 = other.length; - return compareTo(value, other, len1, len2); + Objects.requireNonNull(value); + Objects.requireNonNull(other); + return compareTo0(value, other); } + // vmIntrinsics::_compareToL + @IntrinsicCandidate + private static int compareTo0(byte[] value, byte[] other) { + return compareTo(value, other, value.length, other.length); + } + + /** + * Lexicographically compares two Latin-1 string prefixes as specified in + * {@link String#compareTo(String) String::compareTo}. + * + * @param value a Latin-1 string byte array + * @param other a Latin-1 string byte array + * @param len1 the number of characters in {@code value} to compare + * @param len2 the number of characters in {@code other} to compare + * + * @return {@code 0} if the {@code value} prefix is equal to the + * {@code other} prefix, a value less than {@code 0} if the {@code value} + * prefix is lexicographically less than the {@code other} prefix; a + * value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static int compareTo(byte[] value, byte[] other, int len1, int len2) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); + String.checkOffset(len1, length(value)); + String.checkOffset(len2, length(other)); int lim = Math.min(len1, len2); int k = ArraysSupport.mismatch(value, other, lim); return (k < 0) ? len1 - len2 : getChar(value, k) - getChar(other, k); } - @IntrinsicCandidate + /** + * Lexicographically compares a Latin-1 string to a UTF-16 string as + * specified in {@link String#compareTo(String) String::compareTo}. + * + * @param value a Latin-1 string byte array + * @param other a UTF-16 string byte array + * + * @return {@code 0} if the {@code value} is equal to the {@code other}, a + * value less than {@code 0} if the {@code value} is lexicographically less + * than the {@code other}; a value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + */ static int compareToUTF16(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); + return compareToUTF16_0(value, other); + } + + // vmIntrinsics::_compareToLU + @IntrinsicCandidate + private static int compareToUTF16_0(byte[] value, byte[] other) { int len1 = length(value); int len2 = StringUTF16.length(other); return compareToUTF16Values(value, other, len1, len2); } - /* - * Checks the boundary and then compares the byte arrays. + /** + * Lexicographically compares a Latin-1 string prefix to a UTF-16 one as + * specified in {@link String#compareTo(String) String::compareTo}. + * + * @param value a Latin-1 string byte array + * @param other a UTF-16 string byte array + * @param len1 the number of characters in {@code value} to compare + * @param len2 the number of characters in {@code other} to compare + * + * @throws NullPointerException if {@code value} or {@code other} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds */ static int compareToUTF16(byte[] value, byte[] other, int len1, int len2) { - checkOffset(len1, length(value)); - checkOffset(len2, StringUTF16.length(other)); - + Objects.requireNonNull(value); + Objects.requireNonNull(other); + String.checkOffset(len1, length(value)); + String.checkOffset(len2, StringUTF16.length(other)); return compareToUTF16Values(value, other, len1, len2); } @@ -139,9 +234,12 @@ final class StringLatin1 { return len1 - len2; } + /** + * Case-insensitive {@link #compareTo(byte[], byte[]) compareTo}. + */ static int compareToCI(byte[] value, byte[] other) { - int len1 = value.length; - int len2 = other.length; + int len1 = value.length; // Implicit null check on `value` + int len2 = other.length; // Implicit null check on `other` int lim = Math.min(len1, len2); for (int k = 0; k < lim; k++) { if (value[k] != other[k]) { @@ -159,7 +257,12 @@ final class StringLatin1 { return len1 - len2; } + /** + * Case-insensitive {@link #compareToUTF16(byte[], byte[]) compareToUTF16}. + */ static int compareToCI_UTF16(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); int len1 = length(value); int len2 = StringUTF16.length(other); int lim = Math.min(len1, len2); @@ -307,16 +410,34 @@ final class StringLatin1 { return ArraysSupport.hashCodeOfUnsigned(value, 0, value.length, 0); } - // Caller must ensure that from- and toIndex are within bounds + /** + * Finds the index of the first character matching the provided one in the + * given Latin-1 string byte array sub-range. {@code -1} is returned if the + * provided character cannot be encoded in Latin-1, or cannot be found in + * the target string sub-range. + * + * @param value a Latin-1 string byte array to search in + * @param ch a character to search for + * @param fromIndex the index (inclusive) of the first character in the sub-range + * @param toIndex the index (exclusive) of the last character in the sub-range + * + * @return the index of the first character matching the provided one in the + * given target string sub-range; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} is null + * @throws StringIndexOutOfBoundsException if the sub-range is out of bounds + */ static int indexOf(byte[] value, int ch, int fromIndex, int toIndex) { + String.checkBoundsBeginEnd(fromIndex, toIndex, value.length); // Implicit null check on `value` if (!canEncode(ch)) { return -1; } - return indexOfChar(value, ch, fromIndex, toIndex); + return indexOfChar0(value, ch, fromIndex, toIndex); } + // vmIntrinsics::_indexOfL_char @IntrinsicCandidate - private static int indexOfChar(byte[] value, int ch, int fromIndex, int max) { + private static int indexOfChar0(byte[] value, int ch, int fromIndex, int max) { byte c = (byte)ch; for (int i = fromIndex; i < max; i++) { if (value[i] == c) { @@ -326,22 +447,67 @@ final class StringLatin1 { return -1; } - @IntrinsicCandidate + /** + * Searches for the first occurrence of {@code str} in {@code value}, and, + * if found, returns the index of the first character of the matching + * {@code value} sub-range; {@code -1} otherwise. + * + * @param value a Latin-1 string byte array to search in + * @param str a Latin-1 string byte array to search for + * + * @return the index of the first character of the matching {@code value} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} or {@code str} is null + */ static int indexOf(byte[] value, byte[] str) { - if (str.length == 0) { - return 0; - } - if (value.length == 0) { - return -1; - } - return indexOf(value, value.length, str, str.length, 0); + Objects.requireNonNull(value); + Objects.requireNonNull(str); + return indexOf0(value, str); } + // vmIntrinsics::_indexOfL @IntrinsicCandidate - static int indexOf(byte[] value, int valueCount, byte[] str, int strCount, int fromIndex) { + private static int indexOf0(byte[] value, byte[] str) { + return indexOf0(value, value.length, str, str.length, 0); + } + + /** + * Searches for the first occurrence of the given {@code str} sub-range in + * the given {@code value} sub-range, and, if found, returns the index of + * the first character of the matching {@code value} sub-range; {@code -1} + * otherwise. + * + * @param value a Latin-1 string byte array to search in + * @param valueToIndex the index (exclusive) of the last character in {@code value} + * @param str a Latin-1 string byte array to search for + * @param strToIndex the index (exclusive) of the last character in {@code str} + * @param valueFromIndex the index (inclusive) of the first character in {@code value} + * + * @return the index of the first character of the matching {@code value} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} or {@code str} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ + static int indexOf(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex) { + String.checkBoundsBeginEnd(valueFromIndex, valueToIndex, value.length); // Implicit null check on `value` + String.checkBoundsBeginEnd(0, strToIndex, str.length); // Implicit null check on `str` + return indexOf0(value, valueToIndex, str, strToIndex, valueFromIndex); + } + + // vmIntrinsics::_indexOfIL + @IntrinsicCandidate + private static int indexOf0(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex) { + if (strToIndex == 0) { + return 0; + } + if ((valueToIndex - valueFromIndex) < strToIndex) { + return -1; + } byte first = str[0]; - int max = (valueCount - strCount); - for (int i = fromIndex; i <= max; i++) { + int max = (valueToIndex - strToIndex); + for (int i = valueFromIndex; i <= max; i++) { // Look for first character. if (value[i] != first) { while (++i <= max && value[i] != first); @@ -349,7 +515,7 @@ final class StringLatin1 { // Found first character, now look at the rest of value if (i <= max) { int j = i + 1; - int end = j + strCount - 1; + int end = j + strToIndex - 1; for (int k = 1; j < end && value[j] == str[k]; j++, k++); if (j == end) { // Found whole string. @@ -855,18 +1021,65 @@ final class StringLatin1 { LATIN1); } - // inflatedCopy byte[] -> char[] - @IntrinsicCandidate + /** + * Copies characters from a Latin-1 string byte array sub-range to the + * given {@code char} array sub-range. + *

+ * This effectively inflates the content from a 1 byte per + * character representation to a 2 byte one. + * + * @param src the source Latin-1 string byte array + * @param srcOff the index (inclusive) of the first character in {@code src} + * @param dst the target {@code char} array + * @param dstOff the index (inclusive) of the first character in {@code dst} + * @param len the maximum number of characters to copy + * + * @throws NullPointerException if {@code src} or {@code dst} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) { + String.checkBoundsOffCount(srcOff, len, src.length); // Implicit null check on `src` + String.checkBoundsOffCount(dstOff, len, dst.length); // Implicit null check on `dst` + inflate0(src, srcOff, dst, dstOff, len); + } + + // vmIntrinsics::_inflateStringC + @IntrinsicCandidate + private static void inflate0(byte[] src, int srcOff, char[] dst, int dstOff, int len) { for (int i = 0; i < len; i++) { dst[dstOff++] = (char)(src[srcOff++] & 0xff); } } - // inflatedCopy byte[] -> byte[] - @IntrinsicCandidate + /** + * Copies characters from a Latin-1 string byte array sub-range to a UTF-16 + * one. + *

+ * This effectively inflates the content from a 1 byte per + * character representation to a 2 byte one. + * + * @param src the source Latin-1 string byte array + * @param srcOff the index (inclusive) of the first character in {@code src} + * @param dst the target UTF-16 string byte array + * @param dstOff the index (inclusive) of the first character in {@code dst} + * @param len the maximum number of characters to copy + * + * @throws NullPointerException if {@code src} or {@code dst} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - StringUTF16.inflate(src, srcOff, dst, dstOff, len); + String.checkBoundsOffCount(srcOff, len, src.length); // Implicit null check on `src` + Objects.requireNonNull(dst); + String.checkBoundsOffCount(dstOff, len, StringUTF16.length(dst)); + inflate0(src, srcOff, dst, dstOff, len); + } + + // vmIntrinsics::_inflateStringB + @IntrinsicCandidate + private static void inflate0(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { + for (int i = 0; i < len; i++) { + StringUTF16.putChar(dst, dstOff++, src[srcOff++] & 0xff); + } } static class CharsSpliterator implements Spliterator.OfInt { diff --git a/src/java.base/share/classes/java/lang/StringUTF16.java b/src/java.base/share/classes/java/lang/StringUTF16.java index 75c9e8239ba..23de31a61b7 100644 --- a/src/java.base/share/classes/java/lang/StringUTF16.java +++ b/src/java.base/share/classes/java/lang/StringUTF16.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, Alibaba Group Holding Limited. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,6 +28,7 @@ package java.lang; import java.util.Arrays; import java.util.Locale; +import java.util.Objects; import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.IntConsumer; @@ -49,8 +50,13 @@ import static java.lang.String.UTF16; /// it has the same endianness as a char, which is the platform endianness. /// This is ensured in the static initializer of StringUTF16. /// -/// All indices and sizes for byte arrays carrying UTF16 data are in number of -/// chars instead of number of bytes. +/// Unless stated otherwise, all methods assume that +/// +/// - `byte[]` arguments denote a UTF-16 string byte array +/// - indices, offsets, and lengths (typically of type `int`) are in number of +/// characters, i.e., the number of +/// [Unicode code units](Character.html#unicode) for UTF-16 strings, and the +/// number of `byte`s/`char`s for Latin-1 strings final class StringUTF16 { // Return a new byte array for a UTF16-coded string for len chars @@ -61,30 +67,61 @@ final class StringUTF16 { // Check the size of a UTF16-coded string // Throw an exception if out of range - static int newBytesLength(int len) { - if (len < 0) { - throw new NegativeArraySizeException(); - } - if (len >= MAX_LENGTH) { - throw new OutOfMemoryError("UTF16 String size is " + len + - ", should be less than " + MAX_LENGTH); - } + private static int newBytesLength(int len) { + checkBytesLength(len); return len << 1; } + /** + * Checks if the provided length is a valid UTF-16 string byte array length. + * + * @param length a UTF-16 string byte array length + * + * @throws NegativeArraySizeException if {@code length < 0} + * @throws OutOfMemoryError if {@code length > (Integer.MAX_VALUE / 2)} + */ + private static void checkBytesLength(int length) { + if (length < 0) { + throw new NegativeArraySizeException(); + } + if (length >= MAX_LENGTH) { + throw new OutOfMemoryError("UTF16 String size is " + length + + ", should be less than " + MAX_LENGTH); + } + } + + /** + * Writes the given code point to the specified position of the provided + * UTF-16 string byte array. + *

+ * WARNING: This method does not perform any input validations. + * + * @param val a UTF-16 string byte array + * @param index the index of the character to write the code point to + * @param c a code point + */ + // vmIntrinsics::_putCharStringU @IntrinsicCandidate - // intrinsic performs no bounds checks static void putChar(byte[] val, int index, int c) { - assert index >= 0 && index < length(val) : "Trusted caller missed bounds check"; + assert val != null && index >= 0 && index < length(val) : "Trusted caller violated input constraints"; index <<= 1; val[index++] = (byte)(c >> HI_BYTE_SHIFT); val[index] = (byte)(c >> LO_BYTE_SHIFT); } + /** + * {@return the code point at the the specified position of the provided + * UTF-16 string byte array} + *

+ * WARNING: This method does not perform any input validations. + * + * @param val a UTF-16 string byte array + * @param index the index of the character to get the code point from + */ + // vmIntrinsics::_getCharStringU @IntrinsicCandidate - // intrinsic performs no bounds checks static char getChar(byte[] val, int index) { - assert index >= 0 && index < length(val) : "Trusted caller missed bounds check"; + assert val != null && index >= 0 && index < length(val) : "Trusted caller violated input constraints"; index <<= 1; return (char)(((val[index++] & 0xff) << HI_BYTE_SHIFT) | ((val[index] & 0xff) << LO_BYTE_SHIFT)); @@ -167,14 +204,27 @@ final class StringUTF16 { } /** - * {@return an encoded byte[] for the UTF16 characters in char[]} - * No checking is done on the characters, some may or may not be latin1. - * @param value a char array - * @param off an offset - * @param len a length + * {@return a UTF-16 string byte array produced by encoding the characters + * in the provided character array sub-range} + * + * @param value a character array to encode + * @param off the index of the character to start encoding from + * @param len the number of characters to encode + * + * @throws NegativeArraySizeException if {@code len < 0} + * @throws NullPointerException if {@code value} is null + * @throws OutOfMemoryError if {@code len > (Integer.MAX_VALUE / 2)} + * @throws StringIndexOutOfBoundsException if the sub-range is out of bounds */ - @IntrinsicCandidate static byte[] toBytes(char[] value, int off, int len) { + checkBytesLength(len); + String.checkBoundsOffCount(off, len, value.length); // Implicit null check on `value` + return toBytes0(value, off, len); + } + + // vmIntrinsics::_toBytesStringU + @IntrinsicCandidate + private static byte[] toBytes0(char[] value, int off, int len) { byte[] val = newBytesFor(len); for (int i = 0; i < len; i++) { putChar(val, i, value[off]); @@ -388,9 +438,33 @@ final class StringUTF16 { return n; } - // compressedCopy char[] -> byte[] - @IntrinsicCandidate + /** + * Copies the prefix of Latin-1 characters from a {@code char} array + * sub-range to a Latin-1 string byte array sub-range. + *

+ * This effectively compresses the content from a 2 byte per + * character representation to a 1 byte one. + * + * @param src the source {@code char} array + * @param srcOff the index (inclusive) of the first character in {@code src} + * @param dst the target Latin-1 string byte array + * @param dstOff the index (inclusive) of the first character in {@code dst} + * @param len the maximum number of characters to copy + * + * @return the number of characters copied + * + * @throws NullPointerException if {@code src} or {@code dst} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) { + String.checkBoundsOffCount(srcOff, len, src.length); // Implicit null check on `src` + String.checkBoundsOffCount(dstOff, len, dst.length); // Implicit null check on `dst` + return compress0(src, srcOff, dst, dstOff, len); + } + + // vmIntrinsics::_compressStringC + @IntrinsicCandidate + private static int compress0(char[] src, int srcOff, byte[] dst, int dstOff, int len) { for (int i = 0; i < len; i++) { char c = src[srcOff]; if (c > 0xff) { @@ -403,11 +477,34 @@ final class StringUTF16 { return len; } - // compressedCopy byte[] -> byte[] - @IntrinsicCandidate + /** + * Copies the prefix of Latin-1 characters from a UTF-16 string byte array + * sub-range to a Latin-1 one. + *

+ * This effectively compresses the content from a 2 byte per + * character representation to a 1 byte one. + * + * @param src the source UTF-16 string byte array + * @param srcOff the index (inclusive) of the first character in {@code src} + * @param dst the target Latin-1 string byte array + * @param dstOff the index (inclusive) of the first character in {@code dst} + * @param len the maximum number of characters to copy + * + * @return the number of characters copied + * + * @throws NullPointerException if {@code src} or {@code dst} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static int compress(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - // We need a range check here because 'getChar' has no checks - checkBoundsOffCount(srcOff, len, src); + Objects.requireNonNull(src); + String.checkBoundsOffCount(srcOff, len, length(src)); + String.checkBoundsOffCount(dstOff, len, dst.length); // Implicit null check on `dst` + return compress0(src, srcOff, dst, dstOff, len); + } + + // vmIntrinsics::_compressStringB + @IntrinsicCandidate + private static int compress0(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { for (int i = 0; i < len; i++) { char c = getChar(src, srcOff); if (c > 0xff) { @@ -442,12 +539,28 @@ final class StringUTF16 { return result; } - @IntrinsicCandidate + /** + * Copies the specified sub-range of characters from a UTF-16 string byte + * array to the specified character array sub-range. + * + * @param value the source UTF-16 string byte array to copy from + * @param srcBegin the index (inclusive) of the first character in the source sub-range + * @param srcEnd the index (exclusive) of the last character in the source sub-range + * @param dst the target character array to copy to + * @param dstBegin the index (inclusive) of the first character in the target sub-range + * + * @throws NullPointerException if {@code value} or {@code dst} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static void getChars(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) { - // We need a range check here because 'getChar' has no checks - if (srcBegin < srcEnd) { - checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value); - } + checkBoundsBeginEnd(srcBegin, srcEnd, value); // Implicit null check on `value` via `checkBoundsBeginEnd()` + String.checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length); // Implicit null check on `dst` + getChars0(value, srcBegin, srcEnd, dst, dstBegin); + } + + // vmIntrinsics::_getCharsStringU + @IntrinsicCandidate + private static void getChars0(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) { for (int i = srcBegin; i < srcEnd; i++) { dst[dstBegin++] = getChar(value, i); } @@ -462,20 +575,50 @@ final class StringUTF16 { } } - @IntrinsicCandidate + /** + * Lexicographically compares two UTF-16 strings as specified in + * {@link String#compareTo(String) String::compareTo}. + * + * @param value a UTF-16 string byte array + * @param other a UTF-16 string byte array + * + * @return {@code 0} if {@code value} is equal to {@code other}, a value + * less than {@code 0} if {@code value} is lexicographically less than + * {@code other}; a value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + */ static int compareTo(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); + return compareTo0(value, other); + } + + // vmIntrinsics::_compareToU + @IntrinsicCandidate + private static int compareTo0(byte[] value, byte[] other) { int len1 = length(value); int len2 = length(other); return compareValues(value, other, len1, len2); } - /* - * Checks the boundary and then compares the byte arrays. + /** + * Lexicographically compares two UTF-16 string prefixes as specified in + * {@link String#compareTo(String) String::compareTo}. + * + * @param value a UTF-16 string byte array + * @param other a UTF-16 string byte array + * @param len1 the number of characters in {@code value} to compare + * @param len2 the number of characters in {@code other} to compare + * + * @throws NullPointerException if {@code value} or {@code other} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds */ static int compareTo(byte[] value, byte[] other, int len1, int len2) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); checkOffset(len1, value); checkOffset(len2, other); - return compareValues(value, other, len1, len2); } @@ -491,16 +634,58 @@ final class StringUTF16 { return len1 - len2; } - @IntrinsicCandidate + /** + * Lexicographically compares a UTF-16 string to a Latin-1 one as specified + * in {@link String#compareTo(String) String::compareTo}. + * + * @param value a UTF-16 string byte array + * @param other a Latin-1 string byte array + * + * @return {@code 0} if {@code value} is equal to {@code other}, a value + * less than {@code 0} if {@code value} is lexicographically less than + * {@code other}; a value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + */ static int compareToLatin1(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); + return compareToLatin1_0(value, other); + } + + // vmIntrinsics::_compareToUL + @IntrinsicCandidate + private static int compareToLatin1_0(byte[] value, byte[] other) { return -StringLatin1.compareToUTF16(other, value); } + /** + * Lexicographically compares a UTF-16 string prefix to a Latin-1 one as + * specified in {@link String#compareTo(String) String::compareTo}. + * + * @param value a UTF-16 string byte array + * @param other a Latin-1 string byte array + * @param len1 the number of characters from {@code value} to compare + * @param len2 the number of characters from {@code other} to compare + * + * @return {@code 0} if the {@code value} prefix is equal to the + * {@code other} prefix, a value less than {@code 0} if the {@code value} + * prefix is lexicographically less than the {@code other} prefix; a + * value greater than {@code 0} otherwise. + * + * @throws NullPointerException if {@code value} or {@code other} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ static int compareToLatin1(byte[] value, byte[] other, int len1, int len2) { return -StringLatin1.compareToUTF16(other, value, len2, len1); } + /** + * Case-insensitive {@link #compareTo(byte[], byte[]) compareTo}. + */ static int compareToCI(byte[] value, byte[] other) { + Objects.requireNonNull(value); + Objects.requireNonNull(other); return compareToCIImpl(value, 0, length(value), other, 0, length(other)); } @@ -589,11 +774,14 @@ final class StringUTF16 { return cp; } + /** + * Case-insensitive {@link #compareToLatin1(byte[], byte[]) compareToLatin1}. + */ static int compareToCI_Latin1(byte[] value, byte[] other) { return -StringLatin1.compareToCI_UTF16(other, value); } - public static int compareToFC_Latin1(byte[] value, byte[] other) { + static int compareToFC_Latin1(byte[] value, byte[] other) { return -StringLatin1.compareToFC_UTF16(other, value); } @@ -641,7 +829,7 @@ final class StringUTF16 { return 0; } - public static int compareToFC(byte[] value, byte[] other) { + static int compareToFC(byte[] value, byte[] other) { int tlast = length(value); int olast = length(other); int lim = Math.min(tlast, olast); @@ -668,19 +856,52 @@ final class StringUTF16 { return ArraysSupport.hashCodeOfUTF16(value, 0, value.length >> 1, 0); } - // Caller must ensure that from- and toIndex are within bounds + /** + * {@return the index of the first character matching the provided one in + * the given UTF-16 string byte array sub-range; {@code -1} otherwise} + * + * @param value a UTF-16 string byte array to search in + * @param ch a character to search for + * @param fromIndex the index (inclusive) of the first character in the sub-range + * @param toIndex the index (exclusive) of the last character in the sub-range + * + * @throws NullPointerException if {@code value} is null + * @throws StringIndexOutOfBoundsException if the sub-range is out of bounds + */ static int indexOf(byte[] value, int ch, int fromIndex, int toIndex) { + Objects.requireNonNull(value); + checkBoundsBeginEnd(fromIndex, toIndex, value); if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) { // handle most cases here (ch is a BMP code point or a // negative value (invalid code point)) - return indexOfChar(value, ch, fromIndex, toIndex); + return indexOfChar0(value, ch, fromIndex, toIndex); } else { return indexOfSupplementary(value, ch, fromIndex, toIndex); } } - @IntrinsicCandidate + /** + * Searches for the first occurrence of {@code str} in {@code value}, and, + * if found, returns the index of the first character of the matching + * {@code value} sub-range; {@code -1} otherwise. + * + * @param value a UTF-16 string byte array to search in + * @param str a UTF-16 string byte array to search for + * + * @return the index of the first character of the matching {@code value} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} or {@code str} is null + */ static int indexOf(byte[] value, byte[] str) { + Objects.requireNonNull(value); + Objects.requireNonNull(str); + return indexOf0(value, str); + } + + // vmIntrinsics::_indexOfU + @IntrinsicCandidate + private static int indexOf0(byte[] value, byte[] str) { if (str.length == 0) { return 0; } @@ -690,22 +911,58 @@ final class StringUTF16 { return indexOfUnsafe(value, length(value), str, length(str), 0); } - @IntrinsicCandidate - static int indexOf(byte[] value, int valueCount, byte[] str, int strCount, int fromIndex) { - checkBoundsBeginEnd(fromIndex, valueCount, value); - checkBoundsBeginEnd(0, strCount, str); - return indexOfUnsafe(value, valueCount, str, strCount, fromIndex); + /** + * Searches for the first occurrence of the given {@code str} sub-range in + * the given {@code value} sub-range, and, if found, returns the index of + * the first character of the matching {@code value} sub-range; {@code -1} + * otherwise. + * + * @param value a UTF-16 string byte array to search in + * @param valueToIndex the index (exclusive) of the last character in {@code value} + * @param str a UTF-16 string byte array to search for + * @param strToIndex the index (exclusive) of the last character in {@code str} + * @param valueFromIndex the index (inclusive) of the first character in {@code value} + * + * @return the index of the first character of the matching {@code value} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} or {@code str} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ + static int indexOf(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex) { + Objects.requireNonNull(value); + checkBoundsBeginEnd(valueFromIndex, valueToIndex, value); + Objects.requireNonNull(str); + checkBoundsBeginEnd(0, strToIndex, str); + return indexOf0(value, valueToIndex, str, strToIndex, valueFromIndex); } + // vmIntrinsics::_indexOfIU + @IntrinsicCandidate + private static int indexOf0(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex) { + if (strToIndex == 0) { + return 0; + } + if ((valueToIndex - valueFromIndex) < strToIndex) { + return -1; + } + return indexOfUnsafe(value, valueToIndex, str, strToIndex, valueFromIndex); + } - private static int indexOfUnsafe(byte[] value, int valueCount, byte[] str, int strCount, int fromIndex) { - assert fromIndex >= 0; - assert strCount > 0; - assert strCount <= length(str); - assert valueCount >= strCount; + // This method has the following assumptions on its inputs: + // + // - Arrays are not null + // - Sub-ranges are valid + // - The `str` sub-range is not empty + // - The `value` sub-range length is greater than or equal to the `str` sub-range length + private static int indexOfUnsafe(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex) { + assert valueFromIndex >= 0; + assert strToIndex > 0; + assert strToIndex <= length(str); + assert (valueToIndex - valueFromIndex) >= strToIndex; char first = getChar(str, 0); - int max = (valueCount - strCount); - for (int i = fromIndex; i <= max; i++) { + int max = (valueToIndex - strToIndex); + for (int i = valueFromIndex; i <= max; i++) { // Look for first character. if (getChar(value, i) != first) { while (++i <= max && getChar(value, i) != first); @@ -713,7 +970,7 @@ final class StringUTF16 { // Found first character, now look at the rest of value if (i <= max) { int j = i + 1; - int end = j + strCount - 1; + int end = j + strToIndex - 1; for (int k = 1; j < end && getChar(value, j) == getChar(str, k); j++, k++); if (j == end) { // Found whole string. @@ -724,12 +981,29 @@ final class StringUTF16 { return -1; } - /** - * Handles indexOf Latin1 substring in UTF16 string. + * Searches for the first occurrence of the given Latin-1 string byte array + * {@code str} in the given UTF-16 string byte array {@code value}, and, if + * found, returns the index of the first character of the matching + * {@code value} sub-range; {@code -1} otherwise. + * + * @param value a UTF-16 string byte array to search in + * @param str a Latin-1 string byte array to search for + * + * @return the index of the first character of the matching {@code value} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code value} or {@code str} is null */ - @IntrinsicCandidate static int indexOfLatin1(byte[] value, byte[] str) { + Objects.requireNonNull(value); + Objects.requireNonNull(str); + return indexOfLatin1_0(value, str); + } + + // vmIntrinsics::_indexOfUL + @IntrinsicCandidate + private static int indexOfLatin1_0(byte[] value, byte[] str) { if (str.length == 0) { return 0; } @@ -739,18 +1013,54 @@ final class StringUTF16 { return indexOfLatin1Unsafe(value, length(value), str, str.length, 0); } - @IntrinsicCandidate - static int indexOfLatin1(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { - checkBoundsBeginEnd(fromIndex, srcCount, src); - String.checkBoundsBeginEnd(0, tgtCount, tgt.length); - return indexOfLatin1Unsafe(src, srcCount, tgt, tgtCount, fromIndex); + /** + * Searches for the first occurrence of the given Latin-1 string byte array + * {@code tgt} sub-range in the given UTF-16 string byte array {@code src} + * sub-range, and, if found, returns the index of the first character in + * {@code src}; {@code -1} otherwise. + * + * @param src a UTF-16 string byte array to search in + * @param srcToIndex the index (exclusive) of the last character in {@code src} + * @param tgt a Latin-1 string byte array to search for + * @param tgtToIndex the index (exclusive) of the last character in {@code tgt} + * @param tgtFromIndex the index (inclusive) of the first character in {@code src} + * + * @return the index of the first character of the matching {@code src} + * sub-range if a match is found; {@code -1} otherwise + * + * @throws NullPointerException if {@code src} or {@code tgt} is null + * @throws StringIndexOutOfBoundsException if the sub-ranges are out of bounds + */ + static int indexOfLatin1(byte[] src, int srcToIndex, byte[] tgt, int tgtToIndex, int tgtFromIndex) { + Objects.requireNonNull(src); + checkBoundsBeginEnd(tgtFromIndex, srcToIndex, src); + String.checkBoundsBeginEnd(0, tgtToIndex, tgt.length); + return indexOfLatin1_0(src, srcToIndex, tgt, tgtToIndex, tgtFromIndex); } - static int indexOfLatin1Unsafe(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { + // vmIntrinsics::_indexOfIUL + @IntrinsicCandidate + private static int indexOfLatin1_0(byte[] src, int srcToIndex, byte[] tgt, int tgtToIndex, int srcFromIndex) { + if (tgtToIndex == 0) { + return 0; + } + if ((srcToIndex - srcFromIndex) < tgtToIndex) { + return -1; + } + return indexOfLatin1Unsafe(src, srcToIndex, tgt, tgtToIndex, srcFromIndex); + } + + // This method has the following assumptions on its inputs: + // + // - Arrays are not null + // - Sub-ranges are valid + // - The `tgt` sub-range is not empty + // - The `src` sub-range length is greater than or equal to the `tgt` sub-range length + private static int indexOfLatin1Unsafe(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { assert fromIndex >= 0; assert tgtCount > 0; assert tgtCount <= tgt.length; - assert srcCount >= tgtCount; + assert (srcCount - fromIndex) >= tgtCount; char first = (char)(tgt[0] & 0xff); int max = (srcCount - tgtCount); for (int i = fromIndex; i <= max; i++) { @@ -774,8 +1084,9 @@ final class StringUTF16 { return -1; } + // vmIntrinsics::_indexOfU_char @IntrinsicCandidate - private static int indexOfChar(byte[] value, int ch, int fromIndex, int max) { + private static int indexOfChar0(byte[] value, int ch, int fromIndex, int max) { for (int i = fromIndex; i < max; i++) { if (getChar(value, i) == ch) { return i; @@ -1590,7 +1901,7 @@ final class StringUTF16 { } static boolean contentEquals(byte[] v1, byte[] v2, int len) { - checkBoundsOffCount(0, len, v2); + String.checkBoundsOffCount(0, len, length(v2)); for (int i = 0; i < len; i++) { if ((char)(v1[i] & 0xff) != getChar(v2, i)) { return false; @@ -1667,15 +1978,6 @@ final class StringUTF16 { } } - // inflatedCopy byte[] -> byte[] - static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - // We need a range check here because 'putChar' has no checks - checkBoundsOffCount(dstOff, len, dst); - for (int i = 0; i < len; i++) { - putChar(dst, dstOff++, src[srcOff++] & 0xff); - } - } - // srcCoder == UTF16 && tgtCoder == LATIN1 static int lastIndexOfLatin1(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { @@ -1728,13 +2030,13 @@ final class StringUTF16 { } } - static final int MAX_LENGTH = Integer.MAX_VALUE >> 1; + private static final int MAX_LENGTH = Integer.MAX_VALUE >> 1; - static void checkIndex(int off, byte[] val) { + private static void checkIndex(int off, byte[] val) { String.checkIndex(off, length(val)); } - static void checkOffset(int off, byte[] val) { + private static void checkOffset(int off, byte[] val) { String.checkOffset(off, length(val)); } @@ -1742,8 +2044,4 @@ final class StringUTF16 { String.checkBoundsBeginEnd(begin, end, length(val)); } - static void checkBoundsOffCount(int offset, int count, byte[] val) { - String.checkBoundsOffCount(offset, count, length(val)); - } - } diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index 57d28aca5f4..4890c1af45b 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -1881,8 +1881,8 @@ public class Thread implements Runnable { * been {@link #start() started}. * * @implNote - * For platform threads, the implementation uses a loop of {@code this.wait} - * calls conditioned on {@code this.isAlive}. As a thread terminates the + * This implementation uses a loop of {@code this.wait} calls + * conditioned on {@code this.isAlive}. As a thread terminates the * {@code this.notifyAll} method is invoked. It is recommended that * applications not use {@code wait}, {@code notify}, or * {@code notifyAll} on {@code Thread} instances. @@ -1901,13 +1901,12 @@ public class Thread implements Runnable { public final void join(long millis) throws InterruptedException { if (millis < 0) throw new IllegalArgumentException("timeout value is negative"); - - if (this instanceof VirtualThread vthread) { - if (isAlive()) { - long nanos = MILLISECONDS.toNanos(millis); - vthread.joinNanos(nanos); - } + if (!isAlive()) return; + + // ensure there is a notifyAll to wake up waiters when this thread terminates + if (this instanceof VirtualThread vthread) { + vthread.beforeJoin(); } synchronized (this) { @@ -1936,8 +1935,8 @@ public class Thread implements Runnable { * been {@link #start() started}. * * @implNote - * For platform threads, the implementation uses a loop of {@code this.wait} - * calls conditioned on {@code this.isAlive}. As a thread terminates the + * This implementation uses a loop of {@code this.wait} calls + * conditioned on {@code this.isAlive}. As a thread terminates the * {@code this.notifyAll} method is invoked. It is recommended that * applications not use {@code wait}, {@code notify}, or * {@code notifyAll} on {@code Thread} instances. @@ -1966,16 +1965,6 @@ public class Thread implements Runnable { throw new IllegalArgumentException("nanosecond timeout value out of range"); } - if (this instanceof VirtualThread vthread) { - if (isAlive()) { - // convert arguments to a total in nanoseconds - long totalNanos = MILLISECONDS.toNanos(millis); - totalNanos += Math.min(Long.MAX_VALUE - totalNanos, nanos); - vthread.joinNanos(totalNanos); - } - return; - } - if (nanos > 0 && millis < Long.MAX_VALUE) { millis++; } @@ -2035,10 +2024,6 @@ public class Thread implements Runnable { if (nanos <= 0) return false; - if (this instanceof VirtualThread vthread) { - return vthread.joinNanos(nanos); - } - // convert to milliseconds long millis = MILLISECONDS.convert(nanos, NANOSECONDS); if (nanos > NANOSECONDS.convert(millis, MILLISECONDS)) { diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index 6cd7ccbbba1..f058f967b91 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.java @@ -26,7 +26,6 @@ package java.lang; import java.util.Locale; import java.util.Objects; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; @@ -68,7 +67,6 @@ final class VirtualThread extends BaseVirtualThread { private static final long STATE = U.objectFieldOffset(VirtualThread.class, "state"); private static final long PARK_PERMIT = U.objectFieldOffset(VirtualThread.class, "parkPermit"); private static final long CARRIER_THREAD = U.objectFieldOffset(VirtualThread.class, "carrierThread"); - private static final long TERMINATION = U.objectFieldOffset(VirtualThread.class, "termination"); private static final long ON_WAITING_LIST = U.objectFieldOffset(VirtualThread.class, "onWaitingList"); // scheduler and continuation @@ -184,8 +182,8 @@ final class VirtualThread extends BaseVirtualThread { // carrier thread when mounted, accessed by VM private volatile Thread carrierThread; - // termination object when joining, created lazily if needed - private volatile CountDownLatch termination; + // true to notifyAll after this virtual thread terminates + private volatile boolean notifyAllAfterTerminate; /** * Returns the default scheduler. @@ -677,11 +675,11 @@ final class VirtualThread extends BaseVirtualThread { assert carrierThread == null; setState(TERMINATED); - // notify anyone waiting for this virtual thread to terminate - CountDownLatch termination = this.termination; - if (termination != null) { - assert termination.getCount() == 1; - termination.countDown(); + // notifyAll to wakeup any threads waiting for this thread to terminate + if (notifyAllAfterTerminate) { + synchronized (this) { + notifyAll(); + } } // notify container @@ -740,6 +738,13 @@ final class VirtualThread extends BaseVirtualThread { // do nothing } + /** + * Invoked by Thread.join before a thread waits for this virtual thread to terminate. + */ + void beforeJoin() { + notifyAllAfterTerminate = true; + } + /** * Parks until unparked or interrupted. If already unparked then the parking * permit is consumed and this method completes immediately (meaning it doesn't @@ -999,36 +1004,6 @@ final class VirtualThread extends BaseVirtualThread { } } - /** - * Waits up to {@code nanos} nanoseconds for this virtual thread to terminate. - * A timeout of {@code 0} means to wait forever. - * - * @throws InterruptedException if interrupted while waiting - * @return true if the thread has terminated - */ - boolean joinNanos(long nanos) throws InterruptedException { - if (state() == TERMINATED) - return true; - - // ensure termination object exists, then re-check state - CountDownLatch termination = getTermination(); - if (state() == TERMINATED) - return true; - - // wait for virtual thread to terminate - if (nanos == 0) { - termination.await(); - } else { - boolean terminated = termination.await(nanos, NANOSECONDS); - if (!terminated) { - // waiting time elapsed - return false; - } - } - assert state() == TERMINATED; - return true; - } - @Override void blockedOn(Interruptible b) { disableSuspendAndPreempt(); @@ -1239,20 +1214,6 @@ final class VirtualThread extends BaseVirtualThread { return obj == this; } - /** - * Returns the termination object, creating it if needed. - */ - private CountDownLatch getTermination() { - CountDownLatch termination = this.termination; - if (termination == null) { - termination = new CountDownLatch(1); - if (!U.compareAndSetReference(this, TERMINATION, null, termination)) { - termination = this.termination; - } - } - return termination; - } - /** * Returns the lock object to synchronize on when accessing carrierThread. * The lock prevents carrierThread from being reset to null during unmount. diff --git a/src/java.base/share/classes/java/lang/doc-files/ValueBased.html b/src/java.base/share/classes/java/lang/doc-files/ValueBased.html index 6a935afe04b..3b860ce0534 100644 --- a/src/java.base/share/classes/java/lang/doc-files/ValueBased.html +++ b/src/java.base/share/classes/java/lang/doc-files/ValueBased.html @@ -30,35 +30,35 @@

{@index "Value-based Classes"}

-Some classes, such as java.lang.Integer and -java.time.LocalDate, are value-based. +Some classes, such as {@code java.lang.Integer} and +{@code java.time.LocalDate}, are value-based. A value-based class has the following properties:
  • the class declares only final instance fields (though these may contain references to mutable objects);
  • -
  • the class's implementations of equals, hashCode, - and toString compute their results solely from the values +
  • the class's implementations of {@code equals}, {@code hashCode}, + and {@code toString} compute their results solely from the values of the class's instance fields (and the members of the objects they reference), not from the instance's identity;
  • the class's methods treat instances as freely substitutable - when equal, meaning that interchanging any two instances x and - y that are equal according to equals() produces no + when equal, meaning that interchanging any two instances {@code x} and + {@code y} that are equal according to {@code equals()} produces no visible change in the behavior of the class's methods;
  • the class performs no synchronization using an instance's monitor;
  • -
  • the class does not declare (or has deprecated any) accessible constructors;
  • +
  • the class does not declare (or discourages use of) accessible constructors;
  • the class does not provide any instance creation mechanism that promises a unique identity on each method call—in particular, any factory method's contract must allow for the possibility that if two independently-produced - instances are equal according to equals(), they may also be - equal according to ==;
  • -
  • the class is final, and extends either Object or a hierarchy of + instances are equal according to {@code equals()}, they may also be + equal according to {@code ==};
  • +
  • the class is final, and extends either {@code Object} or a hierarchy of abstract classes that declare no instance fields or instance initializers and whose constructors are empty.

When two instances of a value-based class are equal (according to `equals`), a program should not attempt to distinguish between their identities, whether directly via reference - equality or indirectly via an appeal to synchronization, identity hashing, + equality {@code ==} or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism.

Synchronization on instances of value-based classes is strongly discouraged, 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 cfa03090299..1a7d33266aa 100644 --- a/src/java.base/share/classes/java/lang/foreign/Linker.java +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -813,25 +813,28 @@ public sealed interface Linker permits AbstractLinker { } /** - * {@return a linker option used to save portions of the execution state - * immediately after calling a foreign function associated with a - * downcall method handle, before it can be overwritten by the Java - * runtime, or read through conventional means} + * {@return a linker option used to initialize portions of the execution + * state immediately before, and save portions of the execution + * state immediately after calling a foreign function associated + * with a downcall method handle, before it can be overwritten by the + * Java runtime, or read through conventional means} *

- * Execution state is captured by a downcall method handle on invocation, by - * writing it to a native segment provided by the user to the downcall method - * handle. For this purpose, a downcall method handle linked with this option - * will feature an additional {@link MemorySegment} parameter directly following - * the target address, and optional {@link SegmentAllocator} parameters. This - * parameter, the capture state segment, represents the native segment - * into which the captured state is written. + * Execution state is initialized from, or saved to a native segment provided by + * the user to the downcall method handle. For this purpose, a downcall method + * handle linked with this option will feature an additional {@link MemorySegment} + * parameter directly following the target address, and optional {@link SegmentAllocator} + * parameters. This parameter, the capture state segment, represents the + * native segment from which the capture state is initialized, and into which the + * capture state is saved. *

* The capture state segment must have size and alignment compatible with the * layout returned by {@linkplain #captureStateLayout}. This layout is a struct * layout which has a named field for each captured value. *

- * Captured state can be retrieved from the capture state segment by constructing - * var handles from the {@linkplain #captureStateLayout capture state layout}. + * Captured state can be stored in, or retrieved from the capture state segment by + * constructing var handles from the {@linkplain #captureStateLayout capture state layout}. + * Some functions require this state the be initialized to a particular value before + * invoking the downcall. *

* The following example demonstrates the use of this linker option: * {@snippet lang = "java": @@ -843,6 +846,7 @@ public sealed interface Linker permits AbstractLinker { * VarHandle errnoHandle = capturedStateLayout.varHandle(PathElement.groupElement("errno")); * try (Arena arena = Arena.ofConfined()) { * MemorySegment capturedState = arena.allocate(capturedStateLayout); + * errnoHandle.set(capturedState, 0L, 0); // set errno to 0 * handle.invoke(capturedState); * int errno = (int) errnoHandle.get(capturedState, 0L); * // use errno diff --git a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java index 4b6d74b1b2e..be3805cf5b1 100644 --- a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java +++ b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -746,15 +746,7 @@ abstract class ClassSpecializer.SpeciesDat new Consumer<>() { @Override public void accept(CodeBuilder cob) { - cob.aload(0); // this - final List ctorArgs = AFTER_THIS.fromTypes(superCtorType.parameterList()); - for (Var ca : ctorArgs) { - ca.emitLoadInstruction(cob); - } - - // super(ca...) - cob.invokespecial(superClassDesc, INIT_NAME, methodDesc(superCtorType)); // store down fields Var lastFV = AFTER_THIS.lastOf(ctorArgs); @@ -766,6 +758,12 @@ abstract class ClassSpecializer.SpeciesDat cob.putfield(classDesc, f.name, f.desc); } + // super(ca...) + cob.aload(0); // this + for (Var ca : ctorArgs) { + ca.emitLoadInstruction(cob); + } + cob.invokespecial(superClassDesc, INIT_NAME, methodDesc(superCtorType)); cob.return_(); } }); diff --git a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 4dac59771e8..d5cfc6f11a2 100644 --- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -391,15 +391,15 @@ import sun.invoke.util.Wrapper; new Consumer<>() { @Override public void accept(CodeBuilder cob) { - cob.aload(0) - .invokespecial(CD_Object, INIT_NAME, MTD_void); int parameterCount = factoryType.parameterCount(); for (int i = 0; i < parameterCount; i++) { cob.aload(0) .loadLocal(TypeKind.from(factoryType.parameterType(i)), cob.parameterSlot(i)) .putfield(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(argName(i), argDescs[i]))); } - cob.return_(); + cob.aload(0) + .invokespecial(CD_Object, INIT_NAME, MTD_void) + .return_(); } }); } diff --git a/src/java.base/share/classes/java/lang/invoke/MemberName.java b/src/java.base/share/classes/java/lang/invoke/MemberName.java index 918d1b10791..d320ad11ade 100644 --- a/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -408,11 +408,12 @@ final class MemberName implements Member, Cloneable { // let the rest (native, volatile, transient, etc.) be tested via Modifier.isFoo // unofficial modifier flags, used by HotSpot: - static final int BRIDGE = 0x00000040; - static final int VARARGS = 0x00000080; - static final int SYNTHETIC = 0x00001000; - static final int ANNOTATION= 0x00002000; - static final int ENUM = 0x00004000; + static final int BRIDGE = 0x00000040; + static final int VARARGS = 0x00000080; + static final int SYNTHETIC = 0x00001000; + static final int ANNOTATION = 0x00002000; + static final int ENUM = 0x00004000; + /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ public boolean isBridge() { return allFlagsSet(IS_METHOD | BRIDGE); @@ -426,19 +427,19 @@ final class MemberName implements Member, Cloneable { return allFlagsSet(SYNTHETIC); } - static final String CONSTRUCTOR_NAME = ""; // the ever-popular + static final String CONSTRUCTOR_NAME = ""; // modifiers exported by the JVM: static final int RECOGNIZED_MODIFIERS = 0xFFFF; // private flags, not part of RECOGNIZED_MODIFIERS: static final int - IS_METHOD = MN_IS_METHOD, // method (not constructor) - IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor - IS_FIELD = MN_IS_FIELD, // field - IS_TYPE = MN_IS_TYPE, // nested type - CALLER_SENSITIVE = MN_CALLER_SENSITIVE, // @CallerSensitive annotation detected - TRUSTED_FINAL = MN_TRUSTED_FINAL; // trusted final field + IS_METHOD = MN_IS_METHOD, // method (not constructor) + IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor + IS_FIELD = MN_IS_FIELD, // field + IS_TYPE = MN_IS_TYPE, // nested type + CALLER_SENSITIVE = MN_CALLER_SENSITIVE, // @CallerSensitive annotation detected + TRUSTED_FINAL = MN_TRUSTED_FINAL; // trusted final field static final int ALL_ACCESS = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED; static final int ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java index 70592351827..8dac21c8968 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -344,7 +344,7 @@ public final class MethodHandleProxies { ClassLoaders.platformClassLoader() : loader))) .build(proxyDesc, clb -> { clb.withSuperclass(CD_Object) - .withFlags(ACC_FINAL | ACC_SYNTHETIC) + .withFlags(ACC_SUPER | ACC_FINAL | ACC_SYNTHETIC) .withInterfaceSymbols(ifaceDesc) // static and instance fields .withField(TYPE_NAME, CD_Class, ACC_PRIVATE | ACC_STATIC | ACC_FINAL) @@ -362,10 +362,8 @@ public final class MethodHandleProxies { // (Lookup, MethodHandle target, MethodHandle callerBoundTarget) clb.withMethodBody(INIT_NAME, MTD_void_Lookup_MethodHandle_MethodHandle, 0, cob -> { - cob.aload(0) - .invokespecial(CD_Object, INIT_NAME, MTD_void) - // call ensureOriginalLookup to verify the given Lookup has access - .aload(1) + // call ensureOriginalLookup to verify the given Lookup has access + cob.aload(1) .invokestatic(proxyDesc, ENSURE_ORIGINAL_LOOKUP, MTD_void_Lookup) // this.target = target; .aload(0) @@ -383,7 +381,9 @@ public final class MethodHandleProxies { } // complete - cob.return_(); + cob.aload(0) + .invokespecial(CD_Object, INIT_NAME, MTD_void) + .return_(); }); // private static void ensureOriginalLookup(Lookup) checks if the given Lookup diff --git a/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java b/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java index d3879d4a8fc..ee1892e8878 100644 --- a/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java +++ b/src/java.base/share/classes/java/lang/ref/ReferenceQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,8 +60,7 @@ public class ReferenceQueue<@jdk.internal.RequiresIdentity T> { private volatile Reference head; private long queueLength = 0; - private static class Lock { }; - private final Lock lock = new Lock(); + private final Object lock = new Object(); /** * Constructs a new reference-object queue. diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java index b811deb863d..6ce8e80cdca 100644 --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,6 +25,7 @@ package java.lang.reflect; +import java.lang.classfile.ClassFile; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -467,7 +468,7 @@ public class Proxy implements java.io.Serializable { * Generate the specified proxy class. */ byte[] proxyClassFile = ProxyGenerator.generateProxyClass(loader, proxyName, interfaces, - context.accessFlags() | Modifier.FINAL); + context.accessFlags() | Modifier.FINAL | ClassFile.ACC_SUPER); try { Class pc = JLA.defineClass(loader, proxyName, proxyClassFile, null, "__dynamic_proxy__"); diff --git a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java index 18aa6f29f1f..e4b2886404f 100644 --- a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java +++ b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -363,9 +363,9 @@ public final class ObjectMethods { * @return the method handle */ private static MethodHandle makeToString(MethodHandles.Lookup lookup, - Class receiverClass, - MethodHandle[] getters, - List names) { + Class receiverClass, + MethodHandle[] getters, + List names) { assert getters.length == names.size(); if (getters.length == 0) { // special case @@ -516,8 +516,8 @@ public final class ObjectMethods { requireNonNull(type); requireNonNull(recordClass); requireNonNull(names); - requireNonNull(getters); - Arrays.stream(getters).forEach(Objects::requireNonNull); + List getterList = List.of(getters); // deep null check + MethodType methodType; if (type instanceof MethodType mt) methodType = mt; @@ -526,7 +526,14 @@ public final class ObjectMethods { if (!MethodHandle.class.equals(type)) throw new IllegalArgumentException(type.toString()); } - List getterList = List.of(getters); + + for (MethodHandle getter : getterList) { + var getterType = getter.type(); + if (getterType.parameterCount() != 1 || getterType.returnType() == void.class || getterType.parameterType(0) != recordClass) { + throw new IllegalArgumentException("Illegal getter type %s for recordClass %s".formatted(getterType, recordClass.getTypeName())); + } + } + MethodHandle handle = switch (methodName) { case "equals" -> { if (methodType != null && !methodType.equals(MethodType.methodType(boolean.class, recordClass, Object.class))) @@ -541,7 +548,7 @@ public final class ObjectMethods { case "toString" -> { if (methodType != null && !methodType.equals(MethodType.methodType(String.class, recordClass))) throw new IllegalArgumentException("Bad method type: " + methodType); - List nameList = "".equals(names) ? List.of() : List.of(names.split(";")); + List nameList = names.isEmpty() ? List.of() : List.of(names.split(";")); if (nameList.size() != getterList.size()) throw new IllegalArgumentException("Name list and accessor list do not match"); yield makeToString(lookup, recordClass, getters, nameList); diff --git a/src/java.base/share/classes/java/net/URLStreamHandler.java b/src/java.base/share/classes/java/net/URLStreamHandler.java index f66902a451e..76807d27cee 100644 --- a/src/java.base/share/classes/java/net/URLStreamHandler.java +++ b/src/java.base/share/classes/java/net/URLStreamHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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 @@ -481,14 +481,33 @@ public abstract class URLStreamHandler { * @return a string representation of the {@code URL} argument. */ protected String toExternalForm(URL u) { - String s; + // The fast paths and branch-free concatenations in this method are here for + // a reason and should not be updated without checking performance figures. + + // Optionality, subtly different for authority + boolean emptyAuth = u.getAuthority() == null || u.getAuthority().isEmpty(); + boolean emptyPath = u.getPath() == null; + boolean emptyQuery = u.getQuery() == null; + boolean emptyRef = u.getRef() == null; + var path = emptyPath ? "" : u.getPath(); + // Fast paths for empty components + if (emptyQuery && emptyRef) { + return emptyAuth + ? (u.getProtocol() + ":" + path) + : (u.getProtocol() + "://" + u.getAuthority() + path); + } + // Prefer locals for efficient concatenation + var authSep = emptyAuth ? ":" : "://"; + var auth = emptyAuth ? "" : u.getAuthority(); + var querySep = emptyQuery ? "" : "?"; + var query = emptyQuery ? "" : u.getQuery(); + var refSep = emptyRef ? "" : "#"; + var ref = emptyRef ? "" : u.getRef(); return u.getProtocol() - + ':' - + ((s = u.getAuthority()) != null && !s.isEmpty() - ? "//" + s : "") - + ((s = u.getPath()) != null ? s : "") - + ((s = u.getQuery()) != null ? '?' + s : "") - + ((s = u.getRef()) != null ? '#' + s : ""); + + authSep + auth + + path + + querySep + query + + refSep + ref; } /** diff --git a/src/java.base/share/classes/java/security/KeyStore.java b/src/java.base/share/classes/java/security/KeyStore.java index 83414082cab..434aa57e3ac 100644 --- a/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/java.base/share/classes/java/security/KeyStore.java @@ -1870,6 +1870,7 @@ public class KeyStore { } KeyStore keystore = null; + String matched = null; try (DataInputStream dataStream = new DataInputStream( @@ -1893,8 +1894,10 @@ public class KeyStore { if (CryptoAlgorithmConstraints.permits( "KEYSTORE", ksAlgo)) { keystore = new KeyStore(impl, p, ksAlgo); - break; + } else { + matched = ksAlgo; } + break; } } catch (NoSuchAlgorithmException e) { // ignore @@ -1924,9 +1927,14 @@ public class KeyStore { return keystore; } } - - throw new KeyStoreException("Unrecognized keystore format. " - + "Please load it with a specified type"); + if (matched == null) { + throw new KeyStoreException("Unrecognized keystore format. " + + "Please load it with a specified type"); + } else { + throw new KeyStoreException("Keystore format " + + matched + + " disabled by jdk.crypto.disabledAlgorithms property"); + } } /** diff --git a/src/java.base/share/classes/java/time/ZoneOffset.java b/src/java.base/share/classes/java/time/ZoneOffset.java index 2a45e7cbf82..3bcb75db3e4 100644 --- a/src/java.base/share/classes/java/time/ZoneOffset.java +++ b/src/java.base/share/classes/java/time/ZoneOffset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, Alibaba Group Holding Limited. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -87,9 +87,9 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReferenceArray; +import java.util.function.Supplier; import jdk.internal.util.DecimalDigits; -import jdk.internal.vm.annotation.Stable; /** * A time-zone offset from Greenwich/UTC, such as {@code +02:00}. @@ -178,8 +178,13 @@ public final class ZoneOffset /** * The zone rules for an offset will always return this offset. Cache it for efficiency. */ - @Stable - private transient ZoneRules rules; + private final transient LazyConstant rules = + LazyConstant.of(new Supplier() { + @Override + public ZoneRules get() { + return ZoneRules.of(ZoneOffset.this); + } + }); //----------------------------------------------------------------------- /** @@ -521,11 +526,7 @@ public final class ZoneOffset */ @Override public ZoneRules getRules() { - ZoneRules rules = this.rules; - if (rules == null) { - rules = this.rules = ZoneRules.of(this); - } - return rules; + return rules.get(); } @Override diff --git a/src/java.base/share/classes/java/util/Base64.java b/src/java.base/share/classes/java/util/Base64.java index ed1a4a8d638..fd714050149 100644 --- a/src/java.base/share/classes/java/util/Base64.java +++ b/src/java.base/share/classes/java/util/Base64.java @@ -32,6 +32,8 @@ import java.io.OutputStream; import java.nio.ByteBuffer; import sun.nio.cs.ISO_8859_1; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.IntrinsicCandidate; @@ -201,6 +203,7 @@ public final class Base64 { * @since 1.8 */ public static class Encoder { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private final byte[] newline; private final int linemax; @@ -344,10 +347,9 @@ public final class Base64 { * the byte array to encode * @return A String containing the resulting Base64 encoded characters */ - @SuppressWarnings("deprecation") public String encodeToString(byte[] src) { byte[] encoded = encode(src); - return new String(encoded, 0, 0, encoded.length); + return JLA.uncheckedNewStringWithLatin1Bytes(encoded); } /** diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index f45a52c14fa..682476d8082 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -176,7 +176,10 @@ import sun.util.locale.provider.TimeZoneNameUtility; * SUBTAG (('_'|'-') SUBTAG)*} where {@code SUBTAG = * [0-9][0-9a-zA-Z]{3} | [0-9a-zA-Z]{5,8}}. *

BCP 47 deviation: BCP 47 only - * uses hyphen ('-') as a delimiter, {@code Locale} is more lenient.
+ * uses hyphen ('-') as a delimiter and APIs provided by {@code Locale} which accept + * BCP 47 language tags expect as such. However, for backwards compatibility, + * {@link Locale.Builder#setVariant(String)} also accepts underscore ('_'). + * {@link Locale#of(String, String, String)} accepts only underscore ('_'). * *
Example: "polyton" (Polytonic Greek), "POSIX"
* diff --git a/src/java.base/share/classes/java/util/Scanner.java b/src/java.base/share/classes/java/util/Scanner.java index 3e27325aa0d..948fa595114 100644 --- a/src/java.base/share/classes/java/util/Scanner.java +++ b/src/java.base/share/classes/java/util/Scanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.StringReader; +import java.io.Reader; import java.math.BigDecimal; import java.math.BigInteger; import java.nio.CharBuffer; @@ -800,7 +800,7 @@ public final class Scanner implements Iterator, Closeable { * @param source A string to scan */ public Scanner(String source) { - this(new StringReader(source), WHITESPACE_PATTERN); + this(Reader.of(source), WHITESPACE_PATTERN); } /** diff --git a/src/java.base/share/classes/java/util/TreeMap.java b/src/java.base/share/classes/java/util/TreeMap.java index f8eea8c8d8f..8b6e9dc0bd6 100644 --- a/src/java.base/share/classes/java/util/TreeMap.java +++ b/src/java.base/share/classes/java/util/TreeMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -2138,10 +2138,12 @@ public class TreeMap return null; } public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); while (hasNext()) action.accept(next()); } public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); if (hasNext()) { action.accept(next()); return true; @@ -2176,10 +2178,12 @@ public class TreeMap return null; } public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); while (hasNext()) action.accept(next()); } public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); if (hasNext()) { action.accept(next()); return true; diff --git a/src/java.base/share/classes/java/util/WeakHashMap.java b/src/java.base/share/classes/java/util/WeakHashMap.java index b5a27593840..1412d8f6ff9 100644 --- a/src/java.base/share/classes/java/util/WeakHashMap.java +++ b/src/java.base/share/classes/java/util/WeakHashMap.java @@ -25,8 +25,8 @@ package java.util; -import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 9295f0deb59..c4e1839e9fb 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -3310,7 +3310,7 @@ public class ConcurrentHashMap extends AbstractMap return false; if (tr != null && (tr.parent != t || tr.hash < t.hash)) return false; - if (t.red && tl != null && tl.red && tr != null && tr.red) + if (t.red && (tl != null && tl.red || tr != null && tr.red)) return false; if (tl != null && !checkInvariants(tl)) return false; diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index f289186e0ad..e83a92e5e6f 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -560,70 +560,89 @@ public class ForkJoinPool extends AbstractExecutorService * access (which is usually needed anyway). * * Signalling. Signals (in signalWork) cause new or reactivated - * workers to scan for tasks. SignalWork is invoked in two cases: - * (1) When a task is pushed onto an empty queue, and (2) When a - * worker takes a top-level task from a queue that has additional - * tasks. Together, these suffice in O(log(#threads)) steps to - * fully activate with at least enough workers, and ideally no - * more than required. This ideal is unobtainable: Callers do not - * know whether another worker will finish its current task and - * poll for others without need of a signal (which is otherwise an - * advantage of work-stealing vs other schemes), and also must - * conservatively estimate the triggering conditions of emptiness - * or non-emptiness; all of which usually cause more activations - * than necessary (see below). (Method signalWork is also used as - * failsafe in case of Thread failures in deregisterWorker, to - * activate or create a new worker to replace them). + * workers to scan for tasks. Method signalWork and its callers + * try to approximate the unattainable goal of having the right + * number of workers activated for the tasks at hand, but must err + * on the side of too many workers vs too few to avoid stalls: * - * Top-Level scheduling - * ==================== + * * If computations are purely tree structured, it suffices for + * every worker to activate another when it pushes a task into + * an empty queue, resulting in O(log(#threads)) steps to full + * activation. Emptiness must be conservatively approximated, + * which may result in unnecessary signals. Also, to reduce + * resource usages in some cases, at the expense of slower + * startup in others, activation of an idle thread is preferred + * over creating a new one, here and elsewhere. + * + * * At the other extreme, if "flat" tasks (those that do not in + * turn generate others) come in serially from only a single + * producer, each worker taking a task from a queue should + * propagate a signal if there are more tasks in that + * queue. This is equivalent to, but generally faster than, + * arranging the stealer take multiple tasks, re-pushing one or + * more on its own queue, and signalling (because its queue is + * empty), also resulting in logarithmic full activation + * time. If tasks do not not engage in unbounded loops based on + * the actions of other workers with unknown dependencies loop, + * this form of proagation can be limited to one signal per + * activation (phase change). We distinguish the cases by + * further signalling only if the task is an InterruptibleTask + * (see below), which are the only supported forms of task that + * may do so. + * + * * Because we don't know about usage patterns (or most commonly, + * mixtures), we use both approaches, which present even more + * opportunities to over-signal. (Failure to distinguish these + * cases in terms of submission methods was arguably an early + * design mistake.) Note that in either of these contexts, + * signals may be (and often are) unnecessary because active + * workers continue scanning after running tasks without the + * need to be signalled (which is one reason work stealing is + * often faster than alternatives), so additional workers + * aren't needed. + * + * * For rapidly branching tasks that require full pool resources, + * oversignalling is OK, because signalWork will soon have no + * more workers to create or reactivate. But for others (mainly + * externally submitted tasks), overprovisioning may cause very + * noticeable slowdowns due to contention and resource + * wastage. We reduce impact by deactivating workers when + * queues don't have accessible tasks, but reactivating and + * rescanning if other tasks remain. + * + * * Despite these, signal contention and overhead effects still + * occur during ramp-up and ramp-down of small computations. * * Scanning. Method runWorker performs top-level scanning for (and * execution of) tasks by polling a pseudo-random permutation of * the array (by starting at a given index, and using a constant * cyclically exhaustive stride.) It uses the same basic polling * method as WorkQueue.poll(), but restarts with a different - * permutation on each rescan. The pseudorandom generator need - * not have high-quality statistical properties in the long + * permutation on each invocation. The pseudorandom generator + * need not have high-quality statistical properties in the long * term. We use Marsaglia XorShifts, seeded with the Weyl sequence - * from ThreadLocalRandom probes, which are cheap and suffice. + * from ThreadLocalRandom probes, which are cheap and + * suffice. Each queue's polling attempts to avoid becoming stuck + * when other scanners/pollers stall. Scans do not otherwise + * explicitly take into account core affinities, loads, cache + * localities, etc, However, they do exploit temporal locality + * (which usually approximates these) by preferring to re-poll + * from the same queue after a successful poll before trying + * others, which also reduces bookkeeping, cache traffic, and + * scanning overhead. But it also reduces fairness, which is + * partially counteracted by giving up on detected interference + * (which also reduces contention when too many workers try to + * take small tasks from the same queue). * * Deactivation. When no tasks are found by a worker in runWorker, - * it invokes deactivate, that first deactivates (to an IDLE - * phase). Avoiding missed signals during deactivation requires a - * (conservative) rescan, reactivating if there may be tasks to - * poll. Because idle workers are often not yet blocked (parked), - * we use a WorkQueue field to advertise that a waiter actually - * needs unparking upon signal. - * - * When tasks are constructed as (recursive) DAGs, top-level - * scanning is usually infrequent, and doesn't encounter most - * of the following problems addressed by runWorker and awaitWork: - * - * Locality. Polls are organized into "runs", continuing until - * empty or contended, while also minimizing interference by - * postponing bookeeping to ends of runs. This may reduce - * fairness. - * - * Contention. When many workers try to poll few queues, they - * often collide, generating CAS failures and disrupting locality - * of workers already running their tasks. This also leads to - * stalls when tasks cannot be taken because other workers have - * not finished poll operations, which is detected by reading - * ahead in queue arrays. In both cases, workers restart scans in a - * way that approximates randomized backoff. - * - * Oversignalling. When many short top-level tasks are present in - * a small number of queues, the above signalling strategy may - * activate many more workers than needed, worsening locality and - * contention problems, while also generating more global - * contention (field ctl is CASed on every activation and - * deactivation). We filter out (both in runWorker and - * signalWork) attempted signals that are surely not needed - * because the signalled tasks are already taken. - * - * Shutdown and Quiescence - * ======================= + * it tries to deactivate()), giving up (and rescanning) on "ctl" + * contention. To avoid missed signals during deactivation, the + * method rescans and reactivates if there may have been a missed + * signal during deactivation. To reduce false-alarm reactivations + * while doing so, we scan multiple times (analogously to method + * quiescent()) before trying to reactivate. Because idle workers + * are often not yet blocked (parked), we use a WorkQueue field to + * advertise that a waiter actually needs unparking upon signal. * * Quiescence. Workers scan looking for work, giving up when they * don't find any, without being sure that none are available. @@ -873,7 +892,9 @@ public class ForkJoinPool extends AbstractExecutorService * shutdown, runners are interrupted so they can cancel. Since * external joining callers never run these tasks, they must await * cancellation by others, which can occur along several different - * paths. + * paths. The inability to rely on caller-runs may also require + * extra signalling (resulting in scanning and contention) so is + * done only conditionally in methods push and runworker. * * Across these APIs, rules for reporting exceptions for tasks * with results accessed via join() differ from those via get(), @@ -940,13 +961,9 @@ public class ForkJoinPool extends AbstractExecutorService * less-contended applications. To help arrange this, some * non-reference fields are declared as "long" even when ints or * shorts would suffice. For class WorkQueue, an - * embedded @Contended isolates the very busy top index, along - * with status and bookkeeping fields written (mostly) by owners, - * that otherwise interfere with reading array and base - * fields. There are other variables commonly contributing to - * false-sharing-related performance issues (including fields of - * class Thread), but we can't do much about this except try to - * minimize access. + * embedded @Contended region segregates fields most heavily + * updated by owners from those most commonly read by stealers or + * other management. * * Initial sizing and resizing of WorkQueue arrays is an even more * delicate tradeoff because the best strategy systematically @@ -955,11 +972,13 @@ public class ForkJoinPool extends AbstractExecutorService * direct false-sharing and indirect cases due to GC bookkeeping * (cardmarks etc), and reduce the number of resizes, which are * not especially fast because they require atomic transfers. - * Currently, arrays are initialized to be just large enough to - * avoid resizing in most tree-structured tasks, but grow rapidly - * until large. (Maintenance note: any changes in fields, queues, - * or their uses, or JVM layout policies, must be accompanied by - * re-evaluation of these placement and sizing decisions.) + * Currently, arrays for workers are initialized to be just large + * enough to avoid resizing in most tree-structured tasks, but + * larger for external queues where both false-sharing problems + * and the need for resizing are more common. (Maintenance note: + * any changes in fields, queues, or their uses, or JVM layout + * policies, must be accompanied by re-evaluation of these + * placement and sizing decisions.) * * Style notes * =========== @@ -1042,11 +1061,17 @@ public class ForkJoinPool extends AbstractExecutorService static final int DEFAULT_COMMON_MAX_SPARES = 256; /** - * Initial capacity of work-stealing queue array. + * Initial capacity of work-stealing queue array for workers. * Must be a power of two, at least 2. See above. */ static final int INITIAL_QUEUE_CAPACITY = 1 << 6; + /** + * Initial capacity of work-stealing queue array for external queues. + * Must be a power of two, at least 2. See above. + */ + static final int INITIAL_EXTERNAL_QUEUE_CAPACITY = 1 << 9; + // conversions among short, int, long static final int SMASK = 0xffff; // (unsigned) short bits static final long LMASK = 0xffffffffL; // lower 32 bits of long @@ -1186,11 +1211,11 @@ public class ForkJoinPool extends AbstractExecutorService @jdk.internal.vm.annotation.Contended("w") int stackPred; // pool stack (ctl) predecessor link @jdk.internal.vm.annotation.Contended("w") - volatile int parking; // nonzero if parked in awaitWork - @jdk.internal.vm.annotation.Contended("w") volatile int source; // source queue id (or DROPPED) @jdk.internal.vm.annotation.Contended("w") int nsteals; // number of steals from other queues + @jdk.internal.vm.annotation.Contended("w") + volatile int parking; // nonzero if parked in awaitWork // Support for atomic operations private static final Unsafe U; @@ -1223,11 +1248,11 @@ public class ForkJoinPool extends AbstractExecutorService */ WorkQueue(ForkJoinWorkerThread owner, int id, int cfg, boolean clearThreadLocals) { + array = new ForkJoinTask[owner == null ? + INITIAL_EXTERNAL_QUEUE_CAPACITY : + INITIAL_QUEUE_CAPACITY]; + this.owner = owner; this.config = (clearThreadLocals) ? cfg | CLEAR_TLS : cfg; - if ((this.owner = owner) == null) { - array = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; - phase = id | IDLE; - } } /** @@ -1254,27 +1279,27 @@ public class ForkJoinPool extends AbstractExecutorService * @throws RejectedExecutionException if array could not be resized */ final void push(ForkJoinTask task, ForkJoinPool pool, boolean internal) { - int s = top, b = base, m, cap, room; ForkJoinTask[] a, na; - if ((a = array) != null && (cap = a.length) > 0) { // else disabled - int k = (m = cap - 1) & s; - if ((room = m - (s - b)) >= 0) { + int s = top, b = base, m, cap, room; ForkJoinTask[] a; + if ((a = array) != null && (cap = a.length) > 0 && // else disabled + task != null) { + int pk = task.noUserHelp() + 1; // prev slot offset + if ((room = (m = cap - 1) - (s - b)) >= 0) { top = s + 1; - long pos = slotOffset(k); + long pos = slotOffset(m & s); if (!internal) U.putReference(a, pos, task); // inside lock else U.getAndSetReference(a, pos, task); // fully fenced - if (room == 0 && (na = growArray(a, cap, s)) != null) - k = ((a = na).length - 1) & s; // resize + if (room == 0) // resize + growArray(a, cap, s); } if (!internal) unlockPhase(); if (room < 0) throw new RejectedExecutionException("Queue capacity exceeded"); - if (pool != null && - (room == 0 || - U.getReferenceAcquire(a, slotOffset(m & (s - 1))) == null)) - pool.signalWork(a, k); // may have appeared empty + if ((room == 0 || U.getReferenceAcquire(a, slotOffset(m & (s - pk))) == null) && + pool != null) + pool.signalWork(); // may have appeared empty } } @@ -1283,12 +1308,11 @@ public class ForkJoinPool extends AbstractExecutorService * @param a old array * @param cap old array capacity * @param s current top - * @return new array, or null on failure */ - private ForkJoinTask[] growArray(ForkJoinTask[] a, int cap, int s) { - int newCap = (cap >= 1 << 16) ? cap << 1 : cap << 2; - ForkJoinTask[] newArray = null; + private void growArray(ForkJoinTask[] a, int cap, int s) { + int newCap = cap << 1; if (a != null && a.length == cap && cap > 0 && newCap > 0) { + ForkJoinTask[] newArray = null; try { newArray = new ForkJoinTask[newCap]; } catch (OutOfMemoryError ex) { @@ -1305,45 +1329,34 @@ public class ForkJoinPool extends AbstractExecutorService updateArray(newArray); // fully fenced } } - return newArray; } /** - * Takes next task, if one exists, in lifo order. + * Takes next task, if one exists, in order specified by mode, + * so acts as either local-pop or local-poll. Called only by owner. + * @param fifo nonzero if FIFO mode */ - private ForkJoinTask localPop() { + private ForkJoinTask nextLocalTask(int fifo) { ForkJoinTask t = null; - int s = top - 1, cap; long k; ForkJoinTask[] a; - if ((a = array) != null && (cap = a.length) > 0 && - U.getReference(a, k = slotOffset((cap - 1) & s)) != null && - (t = (ForkJoinTask)U.getAndSetReference(a, k, null)) != null) - updateTop(s); - return t; - } - - /** - * Takes next task, if one exists, in fifo order. - */ - private ForkJoinTask localPoll() { - ForkJoinTask t = null; - int p = top, cap; ForkJoinTask[] a; - if ((a = array) != null && (cap = a.length) > 0) { - for (int b = base; p - b > 0; ) { - int nb = b + 1; - long k = slotOffset((cap - 1) & b); - if (U.getReference(a, k) == null) { - if (nb == p) - break; // else base is lagging - while (b == (b = U.getIntAcquire(this, BASE))) - Thread.onSpinWait(); // spin to reduce memory traffic + ForkJoinTask[] a = array; + int b = base, p = top, cap; + if (p - b > 0 && a != null && (cap = a.length) > 0) { + for (int m = cap - 1, s, nb;;) { + if (fifo == 0 || (nb = b + 1) == p) { + if ((t = (ForkJoinTask)U.getAndSetReference( + a, slotOffset(m & (s = p - 1)), null)) != null) + updateTop(s); // else lost race for only task + break; } - else if ((t = (ForkJoinTask) - U.getAndSetReference(a, k, null)) != null) { + if ((t = (ForkJoinTask)U.getAndSetReference( + a, slotOffset(m & b), null)) != null) { updateBase(nb); break; } - else - b = base; + while (b == (b = U.getIntAcquire(this, BASE))) + Thread.onSpinWait(); // spin to reduce memory traffic + if (p - b <= 0) + break; } } return t; @@ -1351,9 +1364,10 @@ public class ForkJoinPool extends AbstractExecutorService /** * Takes next task, if one exists, using configured mode. + * (Always internal, never called for Common pool.) */ final ForkJoinTask nextLocalTask() { - return (config & FIFO) == 0 ? localPop() : localPoll(); + return nextLocalTask(config & FIFO); } /** @@ -1429,12 +1443,12 @@ public class ForkJoinPool extends AbstractExecutorService // specialized execution methods /** - * Runs the given task, as well as remaining local tasks + * Runs the given task, as well as remaining local tasks. */ final void topLevelExec(ForkJoinTask task, int fifo) { while (task != null) { task.doExec(); - task = (fifo != 0) ? localPoll() : localPop(); + task = nextLocalTask(fifo); } } @@ -1564,7 +1578,7 @@ public class ForkJoinPool extends AbstractExecutorService * Cancels all local tasks. Called only by owner. */ final void cancelTasks() { - for (ForkJoinTask t; (t = localPop()) != null; ) { + for (ForkJoinTask t; (t = nextLocalTask(0)) != null; ) { try { t.cancel(false); } catch (Throwable ignore) { @@ -1766,8 +1780,7 @@ public class ForkJoinPool extends AbstractExecutorService * @param w caller's WorkQueue */ final void registerWorker(WorkQueue w) { - if (w != null) { - w.array = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; + if (w != null && (runState & STOP) == 0L) { ThreadLocalRandom.localInit(); int seed = w.stackPred = ThreadLocalRandom.getProbe(); int phaseSeq = seed & ~((IDLE << 1) - 1); // initial phase tag @@ -1845,18 +1858,17 @@ public class ForkJoinPool extends AbstractExecutorService } if ((tryTerminate(false, false) & STOP) == 0L && phase != 0 && w != null && w.source != DROPPED) { + signalWork(); // possibly replace w.cancelTasks(); // clean queue - signalWork(null, 0); // possibly replace } if (ex != null) ForkJoinTask.rethrow(ex); } /** - * Releases an idle worker, or creates one if not enough exist, - * giving up if array a is nonnull and task at a[k] already taken. + * Releases an idle worker, or creates one if not enough exist. */ - final void signalWork(ForkJoinTask[] a, int k) { + final void signalWork() { int pc = parallelism; for (long c = ctl;;) { WorkQueue[] qs = queues; @@ -1872,15 +1884,13 @@ public class ForkJoinPool extends AbstractExecutorService if (sp == 0) { if ((short)(c >>> TC_SHIFT) >= pc) break; - nc = ((c + TC_UNIT) & TC_MASK) | ac; + nc = ((c + TC_UNIT) & TC_MASK); } else if ((v = w) == null) break; else - nc = (v.stackPred & LMASK) | (c & TC_MASK) | ac; - if (a != null && k < a.length && k >= 0 && a[k] == null) - break; - if (c == (c = ctl) && c == (c = compareAndExchangeCtl(c, nc))) { + nc = (v.stackPred & LMASK) | (c & TC_MASK); + if (c == (c = compareAndExchangeCtl(c, nc | ac))) { if (v == null) createWorker(); else { @@ -1963,196 +1973,178 @@ public class ForkJoinPool extends AbstractExecutorService * @param w caller's WorkQueue (may be null on failed initialization) */ final void runWorker(WorkQueue w) { - if (w != null && w.phase != 0) { // else unregistered - WorkQueue[] qs; - int r = w.stackPred; // seed from registerWorker - int fifo = (int)config & FIFO, rescans = 0, inactive = 0, taken = 0, n; - while ((runState & STOP) == 0L && (qs = queues) != null && - (n = qs.length) > 0) { - int i = r, step = (r >>> 16) | 1; + if (w != null) { + int phase = w.phase, r = w.stackPred; // seed from registerWorker + int fifo = w.config & FIFO, nsteals = 0, src = -1; + for (;;) { + WorkQueue[] qs; r ^= r << 13; r ^= r >>> 17; r ^= r << 5; // xorshift - scan: for (int j = n; j != 0; --j, i += step) { - WorkQueue q; int qid; - if ((q = qs[qid = i & (n - 1)]) != null) { - ForkJoinTask[] a; int cap; // poll queue - while ((a = q.array) != null && (cap = a.length) > 0) { - int b, nb, nk; long bp; ForkJoinTask t; + if ((runState & STOP) != 0L || (qs = queues) == null) + break; + int n = qs.length, i = r, step = (r >>> 16) | 1; + boolean rescan = false; + scan: for (int l = n; l > 0; --l, i += step) { // scan queues + int j, cap; WorkQueue q; ForkJoinTask[] a; + if ((q = qs[j = i & (n - 1)]) != null && + (a = q.array) != null && (cap = a.length) > 0) { + for (int m = cap - 1, pb = -1, b = q.base;;) { + ForkJoinTask t; long k; t = (ForkJoinTask)U.getReferenceAcquire( - a, bp = slotOffset((cap - 1) & (b = q.base))); - long np = slotOffset(nk = (nb = b + 1) & (cap - 1)); - if (q.base == b) { // else inconsistent - if (t == null) { - if (q.array == a) { // else resized - if (rescans > 0) // ran or stalled - break scan; - if (U.getReference(a, np) == null && - (rescans >= 0 || - (U.getReferenceAcquire(a, bp) == null && - q.top == q.base))) - break; - rescans = 1; // may be stalled + a, k = slotOffset(m & b)); + if (b != (b = q.base) || t == null || + !U.compareAndSetReference(a, k, t, null)) { + if (a[b & m] == null) { + if (rescan) // end of run + break scan; + if (a[(b + 1) & m] == null && + a[(b + 2) & m] == null) { + break; // probably empty } - } - else if (inactive != 0) { - if ((inactive = tryReactivate(w)) != 0) { - rescans = 1; // can't take yet + if (pb == (pb = b)) { // track progress + rescan = true; // stalled; reorder scan break scan; } } - else if (U.compareAndSetReference(a, bp, t, null)) { - q.base = nb; - Object nt = U.getReferenceAcquire(a, np); - w.source = qid; - rescans = 1; - ++taken; - if (nt != null && // confirm a[nk] - U.getReferenceAcquire(a, np) == nt) - signalWork(a, nk); // propagate - w.topLevelExec(t, fifo); - } + } + else { + boolean propagate; + int nb = q.base = b + 1, prevSrc = src; + w.nsteals = ++nsteals; + w.source = src = j; // volatile + rescan = true; + int nh = t.noUserHelp(); + if (propagate = + (prevSrc != src || nh != 0) && a[nb & m] != null) + signalWork(); + w.topLevelExec(t, fifo); + if ((b = q.base) != nb && !propagate) + break scan; // reduce interference } } } } - if (rescans >= 0) - --rescans; - else if (inactive == 0) { - if ((inactive = deactivate(w, taken)) != 0) - taken = 0; + if (!rescan) { + if (((phase = deactivate(w, phase)) & IDLE) != 0) + break; + src = -1; // re-enable propagation } - else if (awaitWork(w) == 0) - inactive = rescans = 0; - else - break; } } } /** - * Tries to deactivate worker, keeping active on contention + * Deactivates and if necessary awaits signal or termination. * - * @param w the work queue - * @param taken number of stolen tasks since last deactivation - * @return nonzero if inactive + * @param w the worker + * @param phase current phase + * @return current phase, with IDLE set if worker should exit */ - private int deactivate(WorkQueue w, int taken) { - int inactive = 0, phase; - if (w != null && (inactive = (phase = w.phase) & IDLE) == 0) { - long sp = (phase + (IDLE << 1)) & LMASK, pc, c; - w.phase = phase | IDLE; - w.stackPred = (int)(pc = ctl); // set ctl stack link - if (!compareAndSetCtl( // try to enqueue - pc, c = ((pc - RC_UNIT) & UMASK) | sp)) - w.phase = phase; // back out on contention - else { - if (taken != 0) { - w.nsteals += taken; - if ((w.config & CLEAR_TLS) != 0 && - (Thread.currentThread() instanceof ForkJoinWorkerThread f)) - f.resetThreadLocals(); // (instanceof check always true) - } - if (((c & RC_MASK) == 0L && quiescent() > 0) || taken == 0) - inactive = w.phase & IDLE; // check quiescent termination - else { // spin for approx 1 scan cost - int tc = (short)(c >>> TC_SHIFT); - int spins = Math.max((tc << 1) + tc, SPIN_WAITS); - while ((inactive = w.phase & IDLE) != 0 && --spins != 0) - Thread.onSpinWait(); - } - } - } - return inactive; - } + private int deactivate(WorkQueue w, int phase) { + if (w == null) // currently impossible + return IDLE; + int p = phase | IDLE, activePhase = phase + (IDLE << 1); + long pc = ctl, qc = (activePhase & LMASK) | ((pc - RC_UNIT) & UMASK); + int sp = w.stackPred = (int)pc; // set ctl stack link + w.phase = p; + if (!compareAndSetCtl(pc, qc)) // try to enqueue + return w.phase = phase; // back out on possible signal + int ac = (short)(qc >>> RC_SHIFT), n; long e; WorkQueue[] qs; + if (((e = runState) & STOP) != 0L || + ((e & SHUTDOWN) != 0L && ac == 0 && quiescent() > 0) || + (qs = queues) == null || (n = qs.length) <= 0) + return IDLE; // terminating - /** - * Reactivates worker w if it is currently top of ctl stack - * - * @param w the work queue - * @return 0 if now active - */ - private int tryReactivate(WorkQueue w) { - int inactive = 0; - if (w != null) { // always true; hoist checks - int sp = w.stackPred, phase, activePhase; long c; - if ((inactive = (phase = w.phase) & IDLE) != 0 && - (int)(c = ctl) == (activePhase = phase + IDLE) && - compareAndSetCtl(c, (sp & LMASK) | ((c + RC_UNIT) & UMASK))) { - w.phase = activePhase; - inactive = 0; - } + for (int prechecks = Math.min(ac, 2), // reactivation threshold + k = Math.max(n + (n << 1), SPIN_WAITS << 1);;) { + WorkQueue q; int cap; ForkJoinTask[] a; long c; + if (w.phase == activePhase) + return activePhase; + if (--k < 0) + return awaitWork(w, p); // block, drop, or exit + if ((q = qs[k & (n - 1)]) == null) + Thread.onSpinWait(); + else if ((a = q.array) != null && (cap = a.length) > 0 && + a[q.base & (cap - 1)] != null && --prechecks < 0 && + (int)(c = ctl) == activePhase && + compareAndSetCtl(c, (sp & LMASK) | ((c + RC_UNIT) & UMASK))) + return w.phase = activePhase; // reactivate } - return inactive; } /** * Awaits signal or termination. * * @param w the work queue - * @return 0 if now active + * @param p current phase (known to be idle) + * @return current phase, with IDLE set if worker should exit */ - private int awaitWork(WorkQueue w) { - int inactive = 0, phase; - if (w != null) { // always true; hoist checks - long waitTime = (w.source == INVALID_ID) ? 0L : keepAlive; - if ((inactive = (phase = w.phase) & IDLE) != 0) { + private int awaitWork(WorkQueue w, int p) { + if (w != null) { + ForkJoinWorkerThread t; long deadline; + if ((w.config & CLEAR_TLS) != 0 && (t = w.owner) != null) + t.resetThreadLocals(); // clear before reactivate + if ((ctl & RC_MASK) > 0L) + deadline = 0L; + else if ((deadline = + (((w.source != INVALID_ID) ? keepAlive : TIMEOUT_SLOP)) + + System.currentTimeMillis()) == 0L) + deadline = 1L; // avoid zero + int activePhase = p + IDLE; + if ((p = w.phase) != activePhase && (runState & STOP) == 0L) { LockSupport.setCurrentBlocker(this); - int activePhase = phase + IDLE; - for (long deadline = 0L;;) { - Thread.interrupted(); // clear status + w.parking = 1; // enable unpark + while ((p = w.phase) != activePhase) { + boolean trimmable = false; int trim; + Thread.interrupted(); // clear status if ((runState & STOP) != 0L) break; - boolean trimmable = false; // use timed wait if trimmable - long d = 0L, c; - if (((c = ctl) & RC_MASK) == 0L && (int)c == activePhase) { - long now = System.currentTimeMillis(); - if (deadline == 0L) - deadline = waitTime + now; - if (deadline - now <= TIMEOUT_SLOP) { - if (tryTrim(w, c, activePhase)) - break; - continue; // lost race to trim - } - d = deadline; - trimmable = true; + if (deadline != 0L) { + if ((trim = tryTrim(w, p, deadline)) > 0) + break; + else if (trim < 0) + deadline = 0L; + else + trimmable = true; } - w.parking = 1; // enable unpark and recheck - if ((inactive = w.phase & IDLE) != 0) - U.park(trimmable, d); - w.parking = 0; // close unpark window - if (inactive == 0 || (inactive = w.phase & IDLE) == 0) - break; + U.park(trimmable, deadline); } + w.parking = 0; LockSupport.setCurrentBlocker(null); } } - return inactive; + return p; } /** * Tries to remove and deregister worker after timeout, and release - * another to do the same unless new tasks are found. + * another to do the same. + * @return > 0: trimmed, < 0 : not trimmable, else 0 */ - private boolean tryTrim(WorkQueue w, long c, int activePhase) { - if (w != null) { - int vp, i; WorkQueue[] vs; WorkQueue v; - long nc = ((w.stackPred & LMASK) | - ((RC_MASK & c) | (TC_MASK & (c - TC_UNIT)))); - if (compareAndSetCtl(c, nc)) { - w.source = DROPPED; - w.phase = activePhase; - if ((vp = (int)nc) != 0 && (vs = queues) != null && - vs.length > (i = vp & SMASK) && (v = vs[i]) != null && - compareAndSetCtl( // try to wake up next waiter - nc, ((v.stackPred & LMASK) | - ((UMASK & (nc + RC_UNIT)) | (nc & TC_MASK))))) { - v.source = INVALID_ID; // enable cascaded timeouts - v.phase = vp; - U.unpark(v.owner); - } - return true; + private int tryTrim(WorkQueue w, int phase, long deadline) { + long c, nc; int stat, activePhase, vp, i; WorkQueue[] vs; WorkQueue v; + if ((activePhase = phase + IDLE) != (int)(c = ctl) || w == null) + stat = -1; // no longer ctl top + else if (deadline - System.currentTimeMillis() >= TIMEOUT_SLOP) + stat = 0; // spurious wakeup + else if (!compareAndSetCtl( + c, nc = ((w.stackPred & LMASK) | (RC_MASK & c) | + (TC_MASK & (c - TC_UNIT))))) + stat = -1; // lost race to signaller + else { + stat = 1; + w.source = DROPPED; + w.phase = activePhase; + if ((vp = (int)nc) != 0 && (vs = queues) != null && + vs.length > (i = vp & SMASK) && (v = vs[i]) != null && + compareAndSetCtl( // try to wake up next waiter + nc, ((UMASK & (nc + RC_UNIT)) | + (nc & TC_MASK) | (v.stackPred & LMASK)))) { + v.source = INVALID_ID; // enable cascaded timeouts + v.phase = vp; + U.unpark(v.owner); } } - return false; + return stat; } /** @@ -2569,35 +2561,52 @@ public class ForkJoinPool extends AbstractExecutorService /** * Finds and locks a WorkQueue for an external submitter, or - * throws RejectedExecutionException if shutdown + * throws RejectedExecutionException if shutdown or terminating. + * @param r current ThreadLocalRandom.getProbe() value * @param rejectOnShutdown true if RejectedExecutionException - * should be thrown when shutdown + * should be thrown when shutdown (else only if terminating) */ - final WorkQueue externalSubmissionQueue(boolean rejectOnShutdown) { - int r; - if ((r = ThreadLocalRandom.getProbe()) == 0) { - ThreadLocalRandom.localInit(); // initialize caller's probe + private WorkQueue submissionQueue(int r, boolean rejectOnShutdown) { + int reuse; // nonzero if prefer create + if ((reuse = r) == 0) { + ThreadLocalRandom.localInit(); // initialize caller's probe r = ThreadLocalRandom.getProbe(); } - for (;;) { - WorkQueue q; WorkQueue[] qs; int n, id, i; - if ((qs = queues) == null || (n = qs.length) <= 0) + for (int probes = 0; ; ++probes) { + int n, i, id; WorkQueue[] qs; WorkQueue q; + if ((qs = queues) == null) + break; + if ((n = qs.length) <= 0) break; if ((q = qs[i = (id = r & EXTERNAL_ID_MASK) & (n - 1)]) == null) { - WorkQueue newq = new WorkQueue(null, id, 0, false); - lockRunState(); - if (qs[i] == null && queues == qs) - q = qs[i] = newq; // else lost race to install + WorkQueue w = new WorkQueue(null, id, 0, false); + w.phase = id; + boolean reject = ((lockRunState() & SHUTDOWN) != 0 && + rejectOnShutdown); + if (!reject && queues == qs && qs[i] == null) + q = qs[i] = w; // else lost race to install unlockRunState(); - } - if (q != null && q.tryLockPhase()) { - if (rejectOnShutdown && (runState & SHUTDOWN) != 0L) { - q.unlockPhase(); // check while q lock held + if (q != null) + return q; + if (reject) break; - } - return q; + reuse = 0; } - r = ThreadLocalRandom.advanceProbe(r); // move + if (reuse == 0 || !q.tryLockPhase()) { // move index + if (reuse == 0) { + if (probes >= n >> 1) + reuse = r; // stop prefering free slot + } + else if (q != null) + reuse = 0; // probe on collision + r = ThreadLocalRandom.advanceProbe(r); + } + else if (rejectOnShutdown && (runState & SHUTDOWN) != 0L) { + q.unlockPhase(); // check while q lock held + break; + } + else + return q; } throw new RejectedExecutionException(); } @@ -2611,12 +2620,24 @@ public class ForkJoinPool extends AbstractExecutorService } else { // find and lock queue internal = false; - q = externalSubmissionQueue(true); + q = submissionQueue(ThreadLocalRandom.getProbe(), true); } q.push(task, signalIfEmpty ? this : null, internal); return task; } + /** + * Returns queue for an external submission, bypassing call to + * submissionQueue if already established and unlocked. + */ + final WorkQueue externalSubmissionQueue(boolean rejectOnShutdown) { + WorkQueue[] qs; WorkQueue q; int n; + int r = ThreadLocalRandom.getProbe(); + return (((qs = queues) != null && (n = qs.length) > 0 && + (q = qs[r & EXTERNAL_ID_MASK & (n - 1)]) != null && r != 0 && + q.tryLockPhase()) ? q : submissionQueue(r, rejectOnShutdown)); + } + /** * Returns queue for an external thread, if one exists that has * possibly ever submitted to the given pool (nonzero probe), or @@ -3295,7 +3316,7 @@ public class ForkJoinPool extends AbstractExecutorService if ((config & PRESET_SIZE) != 0) throw new UnsupportedOperationException("Cannot override System property"); if ((prevSize = getAndSetParallelism(size)) < size) - signalWork(null, 0); // trigger worker activation + signalWork(); // trigger worker activation return prevSize; } diff --git a/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java b/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java index 5e7b61e6c57..abb9f3aca38 100644 --- a/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java +++ b/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -166,7 +166,7 @@ import java.util.Locale; * Common Locale Data Repository (CLDR) * to implement locale-sensitive APIs in the {@code java.util} and * {@code java.text} packages. This locale data derives the set of locales - * supported by the Java runtime environment. The following table lists the + * supported by the Java runtime environment. The following tables list the * version of CLDR used in each JDK release. Unless otherwise specified, all * update releases in a given JDK release family use the same CLDR version. * Note that the CLDR locale data are subject to change. Users should not assume @@ -175,6 +175,9 @@ import java.util.Locale; * Refer to CLDR Releases * for the deltas between their releases. * + * * * * @@ -185,22 +188,38 @@ import java.util.Locale; * * * + * + * + * + * + * + * + * + * + * + *
JDK releases and supported CLDR versions
JDK releaseCLDR 48
JDK 25CLDR 47
JDK 21CLDR 43
JDK 17CLDR 39
JDK 11CLDR 33
JDK 8CLDR 21.0.1
+ *
+ * Show other JDK releases + * + * + * + * + * + * + * * * * * * * - * - * * * * * * * - * - * * * * @@ -211,16 +230,13 @@ import java.util.Locale; * * * - * - * * * * * - * - * * *
Other JDK releases and supported CLDR + * versions
JDK releaseCLDR version
JDK 24CLDR 46
JDK 23CLDR 45
JDK 22CLDR 44
JDK 21CLDR 43
JDK 20CLDR 42
JDK 19CLDR 41
JDK 18CLDR 39
JDK 17CLDR 39
JDK 16CLDR 38
JDK 15CLDR 35.1
JDK 12CLDR 33
JDK 11CLDR 33
JDK 10CLDR 29
JDK 9CLDR 29
JDK 8CLDR 21.0.1
+ *
* * @since 1.6 */ diff --git a/src/java.base/share/classes/java/util/zip/InflaterOutputStream.java b/src/java.base/share/classes/java/util/zip/InflaterOutputStream.java index 31c51509a76..abe4e069915 100644 --- a/src/java.base/share/classes/java/util/zip/InflaterOutputStream.java +++ b/src/java.base/share/classes/java/util/zip/InflaterOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,14 +31,14 @@ import java.io.OutputStream; import java.util.Objects; /** - * Implements an output stream filter for uncompressing data stored in the + * Implements an output stream filter for decompressing data stored in the * "deflate" compression format. * *

Decompressor Usage

* An {@code InflaterOutputStream} created without * specifying a {@linkplain Inflater decompressor} will create a decompressor * at construction time, and close the decompressor when the output stream - * is {@linkplain #close closed}. + * is {@linkplain #close closed} or when {@link #finish()} is called. *

* If a decompressor is specified when creating a {@code InflaterOutputStream}, it is the * responsibility of the caller to {@linkplain Inflater#close close} the @@ -49,7 +49,6 @@ import java.util.Objects; * stream, either directly, or with the {@code try}-with-resources statement. * * @since 1.6 - * @author David R Tribble (david@tribble.com) * * @see InflaterInputStream * @see DeflaterInputStream @@ -60,7 +59,7 @@ public class InflaterOutputStream extends FilterOutputStream { /** Decompressor for this stream. */ protected final Inflater inf; - /** Output buffer for writing uncompressed data. */ + /** Output buffer for writing decompressed data. */ protected final byte[] buf; /** Temporary write buffer. */ @@ -72,6 +71,10 @@ public class InflaterOutputStream extends FilterOutputStream { /** true iff {@link #close()} has been called. */ private boolean closed = false; + // set to true if finish() was called and this InflaterOutputStream + // had created its own Inflater at construction time. + private boolean defaultInflaterClosed; + /** * Checks to make sure that this stream has not been closed. */ @@ -88,7 +91,7 @@ public class InflaterOutputStream extends FilterOutputStream { * The decompressor will be closed when this output stream * is {@linkplain #close() closed}. * - * @param out output stream to write the uncompressed data to + * @param out output stream to write the decompressed data to * @throws NullPointerException if {@code out} is null */ public InflaterOutputStream(OutputStream out) { @@ -104,7 +107,7 @@ public class InflaterOutputStream extends FilterOutputStream { * {@linkplain ##decompressor-usage will not close} the given * {@linkplain Inflater decompressor}. * - * @param out output stream to write the uncompressed data to + * @param out output stream to write the decompressed data to * @param infl decompressor ("inflater") for this stream * @throws NullPointerException if {@code out} or {@code infl} is null */ @@ -120,7 +123,7 @@ public class InflaterOutputStream extends FilterOutputStream { * {@linkplain ##decompressor-usage will not close} the given * {@linkplain Inflater decompressor}. * - * @param out output stream to write the uncompressed data to + * @param out output stream to write the decompressed data to * @param infl decompressor ("inflater") for this stream * @param bufLen decompression buffer size * @throws IllegalArgumentException if {@code bufLen <= 0} @@ -143,27 +146,45 @@ public class InflaterOutputStream extends FilterOutputStream { } /** - * Writes any remaining uncompressed data to the output stream and closes + * Writes any remaining decompressed data to the output stream and closes * the underlying output stream. * + * @implSpec If not already closed, this method calls {@link #finish()} before + * closing the underlying output stream. + * * @throws IOException if an I/O error occurs */ @Override public void close() throws IOException { - if (!closed) { - // Complete the uncompressed output + if (closed) { + return; + } + IOException toThrow = null; + // Complete the decompressed output + try { + finish(); + } catch (IOException ioe) { + toThrow = ioe; + } finally { try { - finish(); - } finally { out.close(); - closed = true; + } catch (IOException ioe) { + if (toThrow == null) { + toThrow = ioe; + } else if (toThrow != ioe) { + toThrow.addSuppressed(ioe); + } } + closed = true; + } + if (toThrow != null) { + throw toThrow; } } /** - * Flushes this output stream, forcing any pending buffered output bytes to be - * written. + * Flushes this output stream, writing any pending buffered decompressed data to + * the underlying output stream. * * @throws IOException if an I/O error occurs or this stream is already * closed @@ -184,7 +205,7 @@ public class InflaterOutputStream extends FilterOutputStream { break; } - // Write the uncompressed output data block + // Write the decompressed output data block out.write(buf, 0, n); } super.flush(); @@ -200,12 +221,18 @@ public class InflaterOutputStream extends FilterOutputStream { } /** - * Finishes writing uncompressed data to the output stream without closing - * the underlying stream. Use this method when applying multiple filters in - * succession to the same output stream. + * Writes any pending buffered decompressed data to the underlying output stream, + * without closing the underlying stream. * - * @throws IOException if an I/O error occurs or this stream is already - * closed + * @implSpec This method calls {@link #flush()} to write any pending buffered + * decompressed data. + *

+ * If this {@code InflaterOutputStream} was created without specifying + * a {@linkplain Inflater decompressor}, then this method closes the decompressor + * that was created at construction time. The {@code InflaterOutputStream} cannot + * then be used for any further writes. + * + * @throws IOException if an I/O error occurs or this stream is already closed */ public void finish() throws IOException { ensureOpen(); @@ -214,11 +241,12 @@ public class InflaterOutputStream extends FilterOutputStream { flush(); if (usesDefaultInflater) { inf.end(); + this.defaultInflaterClosed = true; } } /** - * Writes a byte to the uncompressed output stream. + * Writes a byte to the decompressed output stream. * * @param b a single byte of compressed data to decompress and write to * the output stream @@ -234,7 +262,7 @@ public class InflaterOutputStream extends FilterOutputStream { } /** - * Writes an array of bytes to the uncompressed output stream. + * Writes an array of bytes to the decompressed output stream. * * @param b buffer containing compressed data to decompress and write to * the output stream @@ -251,15 +279,22 @@ public class InflaterOutputStream extends FilterOutputStream { public void write(byte[] b, int off, int len) throws IOException { // Sanity checks ensureOpen(); + // check if this InflaterOutputStream had constructed its own + // Inflater at construction time and has been + // rendered unusable for writes due to finish() being called + // on it. + if (usesDefaultInflater && defaultInflaterClosed) { + throw new IOException("Inflater closed"); + } if (b == null) { - throw new NullPointerException("Null buffer for read"); + throw new NullPointerException("Null input buffer"); } Objects.checkFromIndexSize(off, len, b.length); if (len == 0) { return; } - // Write uncompressed data to the output stream + // Write decompressed data to the output stream try { for (;;) { int n; diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index a198c35c366..140d76c8c91 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -692,7 +692,7 @@ public class ZipFile implements ZipConstants, Closeable { final Set istreams; // List of cached Inflater objects for decompression - Deque inflaterCache; + List inflaterCache; final Cleanable cleanable; @@ -702,7 +702,7 @@ public class ZipFile implements ZipConstants, Closeable { assert zipCoder != null : "null ZipCoder"; this.cleanable = CleanerFactory.cleaner().register(zf, this); this.istreams = Collections.newSetFromMap(new WeakHashMap<>()); - this.inflaterCache = new ArrayDeque<>(); + this.inflaterCache = new ArrayList<>(); this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0, zipCoder); } @@ -715,10 +715,10 @@ public class ZipFile implements ZipConstants, Closeable { * a new one. */ Inflater getInflater() { - Inflater inf; synchronized (inflaterCache) { - if ((inf = inflaterCache.poll()) != null) { - return inf; + if (!inflaterCache.isEmpty()) { + // return the most recently used Inflater from the cache of not-in-use Inflaters + return inflaterCache.removeLast(); } } return new Inflater(true); @@ -728,7 +728,7 @@ public class ZipFile implements ZipConstants, Closeable { * Releases the specified inflater to the list of available inflaters. */ void releaseInflater(Inflater inf) { - Deque inflaters = this.inflaterCache; + List inflaters = this.inflaterCache; if (inflaters != null) { synchronized (inflaters) { // double checked! @@ -747,13 +747,12 @@ public class ZipFile implements ZipConstants, Closeable { IOException ioe = null; // Release cached inflaters and close the cache first - Deque inflaters = this.inflaterCache; + List inflaters = this.inflaterCache; if (inflaters != null) { synchronized (inflaters) { // no need to double-check as only one thread gets a // chance to execute run() (Cleaner guarantee)... - Inflater inf; - while ((inf = inflaters.poll()) != null) { + for (Inflater inf : inflaters) { inf.end(); } // close inflaters cache @@ -762,23 +761,22 @@ public class ZipFile implements ZipConstants, Closeable { } // Close streams, release their inflaters - if (istreams != null) { - synchronized (istreams) { - if (!istreams.isEmpty()) { - InputStream[] copy = istreams.toArray(new InputStream[0]); - istreams.clear(); - for (InputStream is : copy) { - try { - is.close(); - } catch (IOException e) { - if (ioe == null) ioe = e; - else ioe.addSuppressed(e); - } + synchronized (istreams) { + if (!istreams.isEmpty()) { + InputStream[] copy = istreams.toArray(new InputStream[0]); + istreams.clear(); + for (InputStream is : copy) { + try { + is.close(); + } catch (IOException e) { + if (ioe == null) ioe = e; + else ioe.addSuppressed(e); } } } } + // Release ZIP src if (zsrc != null) { synchronized (zsrc) { @@ -1721,8 +1719,10 @@ public class ZipFile implements ZipConstants, Closeable { this.cen = null; return; // only END header present } - if (end.cenlen > end.endpos) + // Validate END header + if (end.cenlen > end.endpos) { zerror("invalid END header (bad central directory size)"); + } long cenpos = end.endpos - end.cenlen; // position of CEN table // Get position of first local file (LOC) header, taking into // account that there may be a stub prefixed to the ZIP file. @@ -1730,18 +1730,22 @@ public class ZipFile implements ZipConstants, Closeable { if (locpos < 0) { zerror("invalid END header (bad central directory offset)"); } - // read in the CEN if (end.cenlen > MAX_CEN_SIZE) { zerror("invalid END header (central directory size too large)"); } if (end.centot < 0 || end.centot > end.cenlen / CENHDR) { zerror("invalid END header (total entries count too large)"); } - cen = this.cen = new byte[(int)end.cenlen]; - if (readFullyAt(cen, 0, cen.length, cenpos) != end.cenlen) { + // Validation ensures these are <= Integer.MAX_VALUE + int cenlen = Math.toIntExact(end.cenlen); + int centot = Math.toIntExact(end.centot); + + // read in the CEN + cen = this.cen = new byte[cenlen]; + if (readFullyAt(cen, 0, cen.length, cenpos) != cenlen) { zerror("read CEN tables failed"); } - this.total = Math.toIntExact(end.centot); + this.total = centot; } else { cen = this.cen; this.total = knownTotal; diff --git a/src/java.base/share/classes/javax/crypto/spec/HKDFParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/HKDFParameterSpec.java index c4ca9e1e183..c5d4f4e5f8f 100644 --- a/src/java.base/share/classes/javax/crypto/spec/HKDFParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/HKDFParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -50,7 +50,8 @@ import java.util.Objects; *

* Examples: * {@snippet lang = java: - * // this usage depicts the initialization of an HKDF-Extract AlgorithmParameterSpec + * // this usage depicts the initialization of an HKDF-Extract + * // AlgorithmParameterSpec * AlgorithmParameterSpec derivationSpec = * HKDFParameterSpec.ofExtract() * .addIKM(label) @@ -58,12 +59,14 @@ import java.util.Objects; * .addSalt(salt).extractOnly(); *} * {@snippet lang = java: - * // this usage depicts the initialization of an HKDF-Expand AlgorithmParameterSpec + * // this usage depicts the initialization of an HKDF-Expand + * // AlgorithmParameterSpec * AlgorithmParameterSpec derivationSpec = * HKDFParameterSpec.expandOnly(prk, info, 32); *} * {@snippet lang = java: - * // this usage depicts the initialization of an HKDF-ExtractExpand AlgorithmParameterSpec + * // this usage depicts the initialization of an HKDF-ExtractExpand + * // AlgorithmParameterSpec * AlgorithmParameterSpec derivationSpec = * HKDFParameterSpec.ofExtract() * .addIKM(ikm) @@ -112,8 +115,8 @@ public interface HKDFParameterSpec extends AlgorithmParameterSpec { * * @implNote HKDF implementations will enforce that the length * is not greater than 255 * HMAC length. HKDF implementations - * will also enforce that a {code null} info value is treated as - * zero-length byte array. + * will also enforce that a {@code null} info value is + * treated as zero-length byte array. * * @param info * the optional context and application specific information @@ -261,8 +264,8 @@ public interface HKDFParameterSpec extends AlgorithmParameterSpec { * @implNote HKDF implementations will enforce that the length is * not greater than 255 * HMAC length. Implementations will also * enforce that the prk argument is at least as many bytes as the - * HMAC length. Implementations will also enforce that a {code null} - * info value is treated as zero-length byte array. + * HMAC length. Implementations will also enforce that a + * {@code null} info value is treated as zero-length byte array. * * @param prk * the pseudorandom key (PRK); must not be {@code null} @@ -358,7 +361,7 @@ public interface HKDFParameterSpec extends AlgorithmParameterSpec { * @param prk * the pseudorandom key (PRK); in the case of * {@code ExtractThenExpand}, the {@code prk} argument may be - * {@null} since the output of extract phase is used + * {@code null} since the output of extract phase is used * @param info * the optional context and application specific information * (may be {@code null}); the byte array is cloned to prevent diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java index 0e82c545359..79c623bc31d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java @@ -168,7 +168,6 @@ public final class DirectClassBuilder this.sizeHint = sizeHint; } - public byte[] build() { // The logic of this is very carefully ordered. We want to avoid diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java index 04276b8eeb8..eb3f5ee913d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java @@ -321,7 +321,7 @@ class VerificationTable { return frame; } int offset_delta = _stream.get_u2(); - if (frame_type < SAME_LOCALS_1_STACK_ITEM_EXTENDED) { + if (frame_type <= RESERVED_END) { _verifier.classError("reserved frame type"); } if (frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) { diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java index 07406b2ee7f..adc595813ee 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -1047,13 +1047,11 @@ public final class VerifierImpl { no_control_flow = false; break; case IF_ACMPEQ : case IF_ACMPNE : - current_frame.pop_stack( - VerificationType.reference_check); + current_frame.pop_stack(object_type()); // fall through case IFNULL : case IFNONNULL : - current_frame.pop_stack( - VerificationType.reference_check); + current_frame.pop_stack(object_type()); target = bcs.dest(); stackmap_table.check_jump_target (current_frame, target); diff --git a/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java b/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java index 5942cefa2a1..a698440c15d 100644 --- a/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java +++ b/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,25 +64,6 @@ public @interface PreviewFeature { * Values should be annotated with the feature's {@code JEP}. */ public enum Feature { - // The JDK build process involves creating an interim javac which is then - // used to compile the rest of the JDK. The jdk.internal.javac.PreviewFeature - // annotation from the current sources is used when compiling interim javac. - // That's because the javac APIs of the current sources may be annotated with - // this annotation and they may be using the enum constants of the current sources. - // Furthermore, when compiling interim javac, the class files from the bootstrap JDK get - // used and those may also contain the PreviewFeature annotation. However, they may be - // using the enum constants of the bootstrap JDK's PreviewFeature annotation. - // If javac sees an annotation with an unknown enum constant, it produces a warning, - // and that in turn fails the build. - // So, in the current sources, we need to preserve the PreviewFeature enum constants - // for as long as the interim javac build needs it. As a result, we retain PreviewFeature - // enum constants for preview features that are present in the bootstrap JDK. - // Older constants can be removed. - // - // For example, Class-File API became final in JDK 24. As soon as JDK 23 was dropped as - // the bootstrap JDK, the CLASSFILE_API enum constant became eligible for removal. - - //--- @JEP(number=525, title="Structured Concurrency", status="Sixth Preview") STRUCTURED_CONCURRENCY, @JEP(number = 526, title = "Lazy Constants", status = "Second Preview") diff --git a/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java index 10aa0397f0c..1c565a52c0f 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java @@ -195,10 +195,9 @@ public class BasicImageReader implements AutoCloseable { } if (result.getMajorVersion() != ImageHeader.MAJOR_VERSION || - result.getMinorVersion() != ImageHeader.MINOR_VERSION) { - throw new IOException("The image file \"" + name + "\" is not " + - "the correct version. Major: " + result.getMajorVersion() + - ". Minor: " + result.getMinorVersion()); + result.getMinorVersion() != ImageHeader.MINOR_VERSION) { + throw new ImageVersionMismatchException( + name, result.getMajorVersion(), result.getMinorVersion()); } return result; @@ -447,4 +446,14 @@ public class BasicImageReader implements AutoCloseable { return new ByteArrayInputStream(bytes); } + + public static final class ImageVersionMismatchException extends IOException { + @Deprecated + private static final long serialVersionUID = 1L; + // If needed we could capture major/minor version for use by JImageTask. + ImageVersionMismatchException(String name, int majorVersion, int minorVersion) { + super("The image file \"" + name + "\" is not the correct version. " + + "Major: " + majorVersion + ". Minor: " + minorVersion); + } + } } diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index c36e265ee2f..4c358820166 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -821,6 +821,7 @@ public final class ImageReader implements AutoCloseable { this.children = Collections.unmodifiableList(children); } } + /** * Resource node (e.g. a ".class" entry, or any other data resource). * diff --git a/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template b/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template index 24a183c8da0..24f48151f21 100644 --- a/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template +++ b/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +188,12 @@ public final class CaseFolding { } private static long getDefined(int cp) { + // Exclude code point U+0000, which is guaranteed to have no + // case-folding mapping. + if (cp == 0) { + return -1; + } + var hashes = CASE_FOLDING_HASHES; var length = CASE_FOLDING_CPS.length; // hashed based on total defined. var hash = cp % length; diff --git a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java index de7a5e44b91..3bd2486fa39 100644 --- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java +++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -478,7 +478,7 @@ public class ArraysSupport { // Bytes /** - * Find the index of a mismatch between two arrays. + * Find the smallest index of a mismatch between two arrays. * *

This method does not perform bounds checks. It is the responsibility * of the caller to perform such bounds checks before calling this method. @@ -486,9 +486,9 @@ public class ArraysSupport { * @param a the first array to be tested for a mismatch * @param b the second array to be tested for a mismatch * @param length the number of bytes from each array to check - * @return the index of a mismatch between the two arrays, otherwise -1 if - * no mismatch. The index will be within the range of (inclusive) 0 to - * (exclusive) the smaller of the two array lengths. + * @return the smallest index of a mismatch between the two arrays, + * otherwise -1 if no mismatch. The index will be within the range of + * (inclusive) 0 to (exclusive) the smaller of the two array lengths. */ public static int mismatch(byte[] a, byte[] b, @@ -520,8 +520,8 @@ public class ArraysSupport { } /** - * Find the relative index of a mismatch between two arrays starting from - * given indexes. + * Find the smallest relative index of a mismatch between two arrays + * starting from given indexes. * *

This method does not perform bounds checks. It is the responsibility * of the caller to perform such bounds checks before calling this method. @@ -533,7 +533,7 @@ public class ArraysSupport { * @param bFromIndex the index of the first element (inclusive) in the * second array to be compared * @param length the number of bytes from each array to check - * @return the relative index of a mismatch between the two arrays, + * @return the smallest relative index of a mismatch between the two arrays, * otherwise -1 if no mismatch. The index will be within the range of * (inclusive) 0 to (exclusive) the smaller of the two array bounds. */ @@ -599,8 +599,8 @@ public class ArraysSupport { if (length > 3) { if (a[aFromIndex] != b[bFromIndex]) return 0; - long aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -648,8 +648,8 @@ public class ArraysSupport { if (length > 3) { if (a[aFromIndex] != b[bFromIndex]) return 0; - long aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -697,8 +697,8 @@ public class ArraysSupport { if (length > 1) { if (a[aFromIndex] != b[bFromIndex]) return 0; - long aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -729,8 +729,8 @@ public class ArraysSupport { int i = 0; if (length > 1) { if (Float.floatToRawIntBits(a[aFromIndex]) == Float.floatToRawIntBits(b[bFromIndex])) { - long aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -787,8 +787,8 @@ public class ArraysSupport { } if (a[aFromIndex] != b[bFromIndex]) return 0; - long aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); int i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -813,8 +813,8 @@ public class ArraysSupport { } int i = 0; if (Double.doubleToRawLongBits(a[aFromIndex]) == Double.doubleToRawLongBits(b[bFromIndex])) { - long aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); - long bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + ((long) aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + ((long) bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, diff --git a/src/java.base/share/classes/jdk/internal/util/WeakReferenceKey.java b/src/java.base/share/classes/jdk/internal/util/WeakReferenceKey.java index 3fe6d6026d7..0b26aa40c0d 100644 --- a/src/java.base/share/classes/jdk/internal/util/WeakReferenceKey.java +++ b/src/java.base/share/classes/jdk/internal/util/WeakReferenceKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -88,4 +88,18 @@ final class WeakReferenceKey extends WeakReference implements ReferenceKey public String toString() { return this.getClass().getCanonicalName() + "#" + System.identityHashCode(this); } + + // WeakReferenceKey.equals() is usually executed in the AOT assembly phase. However, + // in some rare occasions, it's not executed (due to peculiarity of hash code and + // memory addressing??). As a result, the constant pool entries used by + // equals() are not resolved. + // + // The JVM calls ensureDeterministicAOTCache() during the AOT assembly phase to ensure + // that the constant pool entries used by equals() are resolved, so that the + // the JDK's default CDS archives have deterministic contents. + private static boolean ensureDeterministicAOTCache() { + WeakReferenceKey k1 = new WeakReferenceKey<>("1", null); + WeakReferenceKey k2 = new WeakReferenceKey<>("2", null); + return k1.equals(k2); + } } diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java index 03f95222a52..23a787971c0 100644 --- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java @@ -336,7 +336,7 @@ public class VectorSupport { @IntrinsicCandidate public static , E> - V libraryUnaryOp(long addr, Class vClass, Class eClass, int length, String debugName, + V libraryUnaryOp(long addr, Class vClass, int laneType, int length, String debugName, V v, UnaryOperation defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; @@ -374,7 +374,7 @@ public class VectorSupport { @IntrinsicCandidate public static - V libraryBinaryOp(long addr, Class vClass, Class eClass, int length, String debugName, + V libraryBinaryOp(long addr, Class vClass, int laneType, int length, String debugName, V v1, V v2, BinaryOperation defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index d20f6311bca..665b3a3b98d 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -135,7 +135,6 @@ module java.base { exports javax.security.auth.x500; exports javax.security.cert; - // additional qualified exports may be inserted at build time // see make/gensrc/GenModuleInfo.gmk @@ -147,11 +146,11 @@ module java.base { java.security.sasl; exports jdk.internal to jdk.incubator.vector; - // Note: all modules in the exported list participate in preview features - // and therefore if they use preview features they do not need to be - // compiled with "--enable-preview". + // Note: all modules in the exported list participate in preview features, + // normal or reflective. They do not need to be compiled with "--enable-preview" + // to use preview features and do not need to suppress "preview" warnings. // It is recommended for any modules that do participate that their - // module declaration be annotated with jdk.internal.javac.ParticipatesInPreview + // module declaration be annotated with jdk.internal.javac.ParticipatesInPreview. exports jdk.internal.javac to java.compiler, jdk.compiler; diff --git a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java b/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java index 45738550f59..7e4a6cb90d4 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java +++ b/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java @@ -30,10 +30,12 @@ import java.net.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.security.cert.Certificate; import java.util.*; import java.util.jar.*; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; +import java.security.CodeSigner; import sun.net.www.ParseUtil; /* URL jar file is a common JarFile subtype used for JarURLConnection */ @@ -163,9 +165,11 @@ public class URLJarFile extends JarFile { } private class URLJarFileEntry extends JarEntry { + private final JarEntry je; URLJarFileEntry(JarEntry je) { super(je); + this.je = je; } @Override @@ -180,6 +184,30 @@ public class URLJarFile extends JarFile { } return null; } + + @Override + public Certificate[] getCertificates() { + // super.getCertificates() returns Certificates that were + // captured by reading the "JarEntry.certs" field when + // the super instance was created. Some JarEntry + // implementations (like java.util.jar.JarFile$JarFileEntry) + // compute certificates lazily, so we explicitly + // call getCertificates() on the underlying JarEntry instead of + // super.getCertificates() + return je.getCertificates(); + } + + @Override + public CodeSigner[] getCodeSigners() { + // super.getCodeSigners() returns CodeSigners that were + // captured by reading the "JarEntry.signers" field when + // the super instance was created. Some JarEntry + // implementations (like java.util.jar.JarFile$JarFileEntry) + // compute codesigners lazily, so we explicitly + // call getCodeSigners() on the underlying JarEntry instead of + // super.getCodeSigners() + return je.getCodeSigners(); + } } public interface URLJarFileCloseController { diff --git a/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java b/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java index 9500a737af7..dc0c8e4d8c9 100644 --- a/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java +++ b/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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.nio.fs; -import java.lang.ref.Cleaner.Cleanable; import jdk.internal.misc.Unsafe; -import jdk.internal.ref.CleanerFactory; /** * A light-weight buffer in native memory. @@ -38,27 +36,17 @@ class NativeBuffer implements AutoCloseable { private final long address; private final int size; - private final Cleanable cleanable; // optional "owner" to avoid copying // (only safe for use by thread-local caches) private Object owner; - private static class Deallocator implements Runnable { - private final long address; - Deallocator(long address) { - this.address = address; - } - public void run() { - unsafe.freeMemory(address); - } - } + // owner thread ID + private long ownerTid; NativeBuffer(int size) { this.address = unsafe.allocateMemory(size); this.size = size; - this.cleanable = CleanerFactory.cleaner() - .register(this, new Deallocator(address)); } @Override @@ -79,16 +67,26 @@ class NativeBuffer implements AutoCloseable { } void free() { - cleanable.clean(); + unsafe.freeMemory(address); } // not synchronized; only safe for use by thread-local caches void setOwner(Object owner) { + Thread thread = Thread.currentThread(); + assert !thread.isVirtual(); + assert ownerTid == 0 || ownerTid == thread.threadId(); this.owner = owner; + this.ownerTid = (owner != null) ? thread.threadId() : 0; } // not synchronized; only safe for use by thread-local caches Object owner() { - return owner; + long tid = Thread.currentThread().threadId(); + assert ownerTid == 0 || ownerTid == tid; + if (ownerTid == tid) { + return owner; + } else { + return null; + } } } diff --git a/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java b/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java index 9b93cce9114..750da8c1a3d 100644 --- a/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java +++ b/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -92,7 +92,8 @@ class NativeBuffers { static NativeBuffer getNativeBuffer(int size) { NativeBuffer buffer = getNativeBufferFromCache(size); if (buffer != null) { - buffer.setOwner(null); + if (!Thread.currentThread().isVirtual()) + buffer.setOwner(null); return buffer; } else { return allocNativeBuffer(size); diff --git a/src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java b/src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java index e6f8961f412..e161880f883 100644 --- a/src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java +++ b/src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,11 @@ public final class XDHPublicKeyImpl extends X509Key implements XECPublicKey { this.paramSpec = new NamedParameterSpec(params.getName()); this.algid = new AlgorithmId(params.getOid()); - this.u = u.mod(params.getP()); + + // RFC 7748 Section 5 requires the MSB of `u` to be zeroed for X25519 + this.u = (params == XECParameters.X448) ? + u.mod(params.getP()) : + u.clearBit(255).mod(params.getP()); byte[] u_arr = this.u.toByteArray(); reverse(u_arr); @@ -72,6 +76,7 @@ public final class XDHPublicKeyImpl extends X509Key implements XECPublicKey { XECParameters params = XECParameters.get(InvalidKeyException::new, algid); this.paramSpec = new NamedParameterSpec(params.getName()); + // construct the BigInteger representation byte[] u_arr = getKey().toByteArray(); reverse(u_arr); diff --git a/src/java.base/share/classes/sun/security/ec/XECOperations.java b/src/java.base/share/classes/sun/security/ec/XECOperations.java index dd8aa482cc3..0ea39a10d40 100644 --- a/src/java.base/share/classes/sun/security/ec/XECOperations.java +++ b/src/java.base/share/classes/sun/security/ec/XECOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,11 @@ public class XECOperations { */ public byte[] encodedPointMultiply(byte[] k, BigInteger u) { pruneK(k); - ImmutableIntegerModuloP elemU = field.getElement(u); + + ImmutableIntegerModuloP elemU = (params == XECParameters.X448) ? + field.getElement(u) : + field.getElement(u.clearBit(255)); + return pointMultiply(k, elemU).asByteArray(params.getBytes()); } diff --git a/src/java.base/share/classes/sun/security/ssl/DHasKEM.java b/src/java.base/share/classes/sun/security/ssl/DHasKEM.java index 763013f280c..ef5c5b82f06 100644 --- a/src/java.base/share/classes/sun/security/ssl/DHasKEM.java +++ b/src/java.base/share/classes/sun/security/ssl/DHasKEM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -101,7 +101,18 @@ public class DHasKEM implements KEMSpi { return new KEM.Encapsulated( sub(dh, from, to), pkEm, null); + + } catch (IllegalArgumentException e) { + // ECDH validation failure + // all-zero shared secret + throw e; + } catch (InvalidKeyException e) { + // Invalid peer public key + // Convert InvalidKeyException to an unchecked exception + throw new IllegalArgumentException("Invalid peer public key", + e); } catch (Exception e) { + // Unexpected internal failure throw new ProviderException("internal error", e); } } @@ -126,6 +137,11 @@ public class DHasKEM implements KEMSpi { PublicKey pkE = params.DeserializePublicKey(encapsulation); SecretKey dh = params.DH(algorithm, skR, pkE); return sub(dh, from, to); + + } catch (IllegalArgumentException e) { + // ECDH validation failure + // all-zero shared secret + throw e; } catch (IOException | InvalidKeyException e) { throw new DecapsulateException("Cannot decapsulate", e); } catch (Exception e) { @@ -248,7 +264,24 @@ public class DHasKEM implements KEMSpi { KeyAgreement ka = KeyAgreement.getInstance(kaAlgorithm); ka.init(skE); ka.doPhase(pkR, true); - return ka.generateSecret(alg); + SecretKey secret = ka.generateSecret(alg); + + // RFC 8446 section 7.4.2: checks for all-zero + // X25519/X448 shared secret. + if (kaAlgorithm.equals("X25519") || + kaAlgorithm.equals("X448")) { + byte[] s = secret.getEncoded(); + for (byte b : s) { + if (b != 0) { + return secret; + } + } + // Trigger ILLEGAL_PARAMETER alert + throw new IllegalArgumentException( + "All-zero shared secret"); + } + + return secret; } } } diff --git a/src/java.base/share/classes/sun/security/ssl/Hybrid.java b/src/java.base/share/classes/sun/security/ssl/Hybrid.java index e3e2cfa0b23..43634ce2f34 100644 --- a/src/java.base/share/classes/sun/security/ssl/Hybrid.java +++ b/src/java.base/share/classes/sun/security/ssl/Hybrid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -355,7 +355,7 @@ public class Hybrid { int to, String algorithm) throws DecapsulateException { int expectedEncSize = engineEncapsulationSize(); if (encapsulation.length != expectedEncSize) { - throw new IllegalArgumentException( + throw new DecapsulateException( "Invalid key encapsulation message length: " + encapsulation.length + ", expected = " + expectedEncSize); diff --git a/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java b/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java index 39e82b50435..dea86351cc8 100644 --- a/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java +++ b/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package sun.security.ssl; import sun.security.util.RawKeySpec; +import javax.crypto.DecapsulateException; import javax.crypto.KDF; import javax.crypto.KEM; import javax.crypto.KeyAgreement; @@ -35,6 +36,7 @@ import javax.net.ssl.SSLHandshakeException; import java.io.IOException; import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.Provider; @@ -173,6 +175,9 @@ public class KAKeyDerivation implements SSLKeyDerivation { "encapsulation"); } + // All exceptions thrown during KEM encapsulation are mapped + // to TLS fatal alerts: + // illegal_parameter alert or internal_error alert. try { KeyFactory kf = (provider != null) ? KeyFactory.getInstance(algorithmName, provider) : @@ -189,8 +194,18 @@ public class KAKeyDerivation implements SSLKeyDerivation { SecretKey derived = deriveHandshakeSecret(algorithm, sharedSecret); return new KEM.Encapsulated(derived, enc.encapsulation(), null); - } catch (GeneralSecurityException gse) { - throw new SSLHandshakeException("Could not generate secret", gse); + } catch (IllegalArgumentException | InvalidKeyException e) { + // Peer validation failure + // ECDH all-zero shared secret (RFC 8446 section 7.4.2), + // ML-KEM encapsulation key check failure (FIPS-203 section 7.2) + throw context.conContext.fatal(Alert.ILLEGAL_PARAMETER, e); + } catch (GeneralSecurityException e) { + // Cryptographic failure, + // deriveHandshakeSecret failure. + throw context.conContext.fatal(Alert.INTERNAL_ERROR, e); + } catch (RuntimeException e) { + // unexpected provider/runtime failure + throw context.conContext.fatal(Alert.INTERNAL_ERROR, e); } finally { KeyUtil.destroySecretKeys(sharedSecret); } @@ -208,13 +223,30 @@ public class KAKeyDerivation implements SSLKeyDerivation { // Using KEM: called by the client after receiving the KEM // ciphertext (keyshare) from the server in ServerHello. // The client decapsulates it using its private key. - KEM kem = (provider != null) - ? KEM.getInstance(algorithmName, provider) - : KEM.getInstance(algorithmName); - var decapsulator = kem.newDecapsulator(localPrivateKey); - sharedSecret = decapsulator.decapsulate( - keyshare, 0, decapsulator.secretSize(), - "TlsPremasterSecret"); + + // All exceptions thrown during KEM decapsulation are mapped + // to TLS fatal alerts: + // illegal_parameter alert or internal_error alert. + try { + KEM kem = (provider != null) + ? KEM.getInstance(algorithmName, provider) + : KEM.getInstance(algorithmName); + var decapsulator = kem.newDecapsulator(localPrivateKey); + sharedSecret = decapsulator.decapsulate( + keyshare, 0, decapsulator.secretSize(), + "TlsPremasterSecret"); + } catch (IllegalArgumentException | InvalidKeyException | + DecapsulateException e) { + // Peer validation failure + // ECDH all-zero shared secret (RFC 8446 section 7.4.2) + throw context.conContext.fatal(Alert.ILLEGAL_PARAMETER, e); + } catch (GeneralSecurityException e) { + // cryptographic failure + throw context.conContext.fatal(Alert.INTERNAL_ERROR, e); + } catch (RuntimeException e) { + // unexpected provider/runtime failure + throw context.conContext.fatal(Alert.INTERNAL_ERROR, e); + } } else { // Using traditional DH-style Key Agreement KeyAgreement ka = KeyAgreement.getInstance(algorithmName); @@ -225,6 +257,7 @@ public class KAKeyDerivation implements SSLKeyDerivation { return deriveHandshakeSecret(type, sharedSecret); } catch (GeneralSecurityException gse) { + // deriveHandshakeSecret() failure throw new SSLHandshakeException("Could not generate secret", gse); } finally { KeyUtil.destroySecretKeys(sharedSecret); diff --git a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 8df72711dff..a1cc3ee112f 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.security.*; import java.security.cert.*; import java.util.*; import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; import javax.net.ssl.*; import sun.security.provider.certpath.AlgorithmChecker; import sun.security.ssl.SSLAlgorithmConstraints.SIGNATURE_CONSTRAINTS_MODE; @@ -366,13 +367,24 @@ public abstract class SSLContextImpl extends SSLContextSpi { Collection allowedCipherSuites, List protocols) { LinkedHashSet suites = new LinkedHashSet<>(); + List disabledSuites = null; + List unAvailableSuites = null; + + if (SSLLogger.isOn() && SSLLogger.isOn(SSLLogger.Opt.SSLCTX)) { + disabledSuites = new ArrayList<>(); + unAvailableSuites = new ArrayList<>(); + } + if (protocols != null && (!protocols.isEmpty())) { for (CipherSuite suite : allowedCipherSuites) { if (!suite.isAvailable()) { + if (SSLLogger.isOn() && + SSLLogger.isOn(SSLLogger.Opt.SSLCTX)) { + unAvailableSuites.add(suite.name); + } continue; } - boolean isSupported = false; for (ProtocolVersion protocol : protocols) { if (!suite.supports(protocol) || !suite.bulkCipher.isAvailable()) { @@ -383,27 +395,43 @@ public abstract class SSLContextImpl extends SSLContextSpi { EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { suites.add(suite); - isSupported = true; } else if (SSLLogger.isOn() && - SSLLogger.isOn(SSLLogger.Opt.HANDSHAKE)) { - SSLLogger.fine( - "Ignore disabled cipher suite: " + suite.name); + SSLLogger.isOn(SSLLogger.Opt.SSLCTX)) { + disabledSuites.add(suite.name); } break; } - - if (!isSupported && SSLLogger.isOn() && - SSLLogger.isOn(SSLLogger.Opt.HANDSHAKE)) { - SSLLogger.finest( - "Ignore unsupported cipher suite: " + suite); - } } } + if(SSLLogger.isOn() && SSLLogger.isOn(SSLLogger.Opt.SSLCTX)) { + logSuites("Ignore disabled cipher suites for protocols: ", + protocols, disabledSuites); + logSuites("Ignore unavailable cipher suites for protocols: ", + protocols, unAvailableSuites); + logSuites("Available cipher suites for protocols: ", + protocols, suites); + + } return new ArrayList<>(suites); } + private static void logSuites(String message, + List protocols, + Collection suites) { + if (suites.isEmpty()) { + return; + } + String protocolStr = protocols.stream() + .map(pv -> pv.name) + .collect(Collectors.joining(", ", "[", "]")); + String suiteStr = String.join(", ", + suites.stream().map(Object::toString).collect(Collectors.toList())); + SSLLogger.finest(message + protocolStr + System.lineSeparator() + + Utilities.wrapText("[" + suiteStr + "]", 140)); + } + /* * Get the customized cipher suites specified by the given system property. */ @@ -459,10 +487,14 @@ public abstract class SSLContextImpl extends SSLContextSpi { } } } - + if (cipherSuites.isEmpty() && SSLLogger.isOn() + && SSLLogger.isOn(SSLLogger.Opt.SSLCTX)) { + SSLLogger.fine( + "No cipher suites satisfy property: " + propertyName + + ". Returning empty list"); + } return cipherSuites; } - return Collections.emptyList(); } @@ -530,9 +562,6 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List supportedProtocols; private static final List serverDefaultProtocols; - private static final List supportedCipherSuites; - private static final List serverDefaultCipherSuites; - static { supportedProtocols = Arrays.asList( ProtocolVersion.TLS13, @@ -550,13 +579,15 @@ public abstract class SSLContextImpl extends SSLContextSpi { ProtocolVersion.TLS11, ProtocolVersion.TLS10 }); - - supportedCipherSuites = getApplicableSupportedCipherSuites( - supportedProtocols); - serverDefaultCipherSuites = getApplicableEnabledCipherSuites( - serverDefaultProtocols, false); } + private static final LazyConstant> + supportedCipherSuites = LazyConstant.of(() -> + getApplicableSupportedCipherSuites(supportedProtocols)); + private static final LazyConstant> + serverDefaultCipherSuites = LazyConstant.of(() -> + getApplicableEnabledCipherSuites(serverDefaultProtocols, false)); + @Override List getSupportedProtocolVersions() { return supportedProtocols; @@ -564,7 +595,7 @@ public abstract class SSLContextImpl extends SSLContextSpi { @Override List getSupportedCipherSuites() { - return supportedCipherSuites; + return supportedCipherSuites.get(); } @Override @@ -574,7 +605,7 @@ public abstract class SSLContextImpl extends SSLContextSpi { @Override List getServerDefaultCipherSuites() { - return serverDefaultCipherSuites; + return serverDefaultCipherSuites.get(); } @Override @@ -814,10 +845,18 @@ public abstract class SSLContextImpl extends SSLContextSpi { clientDefaultCipherSuites = getApplicableEnabledCipherSuites( clientDefaultProtocols, true); - serverDefaultCipherSuites = - getApplicableEnabledCipherSuites( - serverDefaultProtocols, false); - + // getApplicableEnabledCipherSuites returns same CS List if + // no customized CS in use and protocols are same. Can avoid + // the getApplicableEnabledCipherSuites call + if (clientCustomizedCipherSuites.isEmpty() && + serverCustomizedCipherSuites.isEmpty() && + clientDefaultProtocols.equals(serverDefaultProtocols)) { + serverDefaultCipherSuites = clientDefaultCipherSuites; + } else { + serverDefaultCipherSuites = + getApplicableEnabledCipherSuites( + serverDefaultProtocols, false); + } } else { // unlikely to be used clientDefaultProtocols = null; diff --git a/src/java.base/share/classes/sun/security/ssl/Utilities.java b/src/java.base/share/classes/sun/security/ssl/Utilities.java index e289a9e1bd6..cfd39aecac2 100644 --- a/src/java.base/share/classes/sun/security/ssl/Utilities.java +++ b/src/java.base/share/classes/sun/security/ssl/Utilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -168,6 +168,35 @@ final class Utilities { return builder.toString(); } + static String wrapText(String text, int maxWidth) { + if (text == null || text.isEmpty() || maxWidth <= 0) { + return ""; + } + StringBuilder result = new StringBuilder(); + String[] values = text.split(",\\s*"); + StringBuilder line = new StringBuilder(); + + for (int i = 0; i < values.length; i++) { + String value = values[i]; + // If adding this value would exceed maxWidth + if (line.length() > 0) { + // +1 for the comma + if (line.length() + 1 + value.length() > maxWidth) { + result.append(line).append(LINE_SEP); + line.setLength(0); + } else { + line.append(","); + } + } + line.append(value); + } + // Append any remaining line + if (line.length() > 0) { + result.append(line); + } + return result.toString(); + } + static String byte16HexString(int id) { return "0x" + HEX_FORMATTER.toHexDigits((short)id); } diff --git a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java index 6d26558847c..e0203128962 100644 --- a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java +++ b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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 @@ -512,13 +512,13 @@ abstract class X509KeyManagerCertChecking extends X509ExtendedKeyManager { chain[1].getPublicKey().getAlgorithm()); } else { // Check the signature algorithm of the certificate itself. - // Look for the "withRSA" in "SHA1withRSA", etc. + // Look for the "withEC" in "SHA256withECDSA", etc. X509Certificate issuer = (X509Certificate) chain[0]; String sigAlgName = issuer.getSigAlgName().toUpperCase(Locale.ENGLISH); String pattern = "WITH" + sigKeyAlgorithm.toUpperCase(Locale.ENGLISH); - return sigAlgName.endsWith(pattern); + return sigAlgName.contains(pattern); } } } diff --git a/src/java.base/share/classes/sun/security/util/KeyChoices.java b/src/java.base/share/classes/sun/security/util/KeyChoices.java index da3c611750e..00c4463d098 100644 --- a/src/java.base/share/classes/sun/security/util/KeyChoices.java +++ b/src/java.base/share/classes/sun/security/util/KeyChoices.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +45,7 @@ import java.util.function.BiFunction; * * This class supports reading, writing, and converting between them. *

- * Current code follows draft-ietf-lamps-kyber-certificates-11 and RFC 9881. + * Current code follows RFC 9935 and RFC 9881. */ public final class KeyChoices { diff --git a/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial25519.java b/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial25519.java new file mode 100644 index 00000000000..c8f23da417e --- /dev/null +++ b/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial25519.java @@ -0,0 +1,531 @@ +/* + * Copyright (c) 2026, 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.math.intpoly; + +import java.math.BigInteger; + +public final class IntegerPolynomial25519 extends IntegerPolynomial { + private static final int BITS_PER_LIMB = 51; + private static final int NUM_LIMBS = 5; + private static final int MAX_ADDS = 1; + public static final BigInteger MODULUS = evaluateModulus(); + private static final long CARRY_ADD = 1L << (BITS_PER_LIMB - 1); + private static final long LIMB_MASK = -1L >>> (64 - BITS_PER_LIMB); + + public static final IntegerPolynomial25519 ONE = + new IntegerPolynomial25519(); + + private IntegerPolynomial25519() { + super(BITS_PER_LIMB, NUM_LIMBS, MAX_ADDS, MODULUS); + } + + private static BigInteger evaluateModulus() { + BigInteger result = BigInteger.valueOf(2).pow(255); + result = result.subtract(BigInteger.valueOf(19)); + + return result; + } + + /** + * Carry from a range of limb positions. + * Override for performance (unnesting). + * + * @param limbs [in|out] the limbs for carry operation. + * @param start [in] the starting position of carry. + * @param end [in] the ending position of carry. + */ + @Override + protected void carry(long[] limbs, int start, int end) { + long carry; + + for (int i = start; i < end; i++) { + carry = (limbs[i] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[i] -= (carry << BITS_PER_LIMB); + limbs[i + 1] += carry; + } + } + + /** + * Carry operation for all limb positions. + * Override for performance (unroll and unnesting). + * + * @param limbs [in|out] the limbs for carry operation. + */ + @Override + protected void carry(long[] limbs) { + long carry = (limbs[0] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[0] -= carry << BITS_PER_LIMB; + limbs[1] += carry; + + carry = (limbs[1] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[1] -= carry << BITS_PER_LIMB; + limbs[2] += carry; + + carry = (limbs[2] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[2] -= carry << BITS_PER_LIMB; + limbs[3] += carry; + + carry = (limbs[3] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[3] -= carry << BITS_PER_LIMB; + limbs[4] += carry; + } + + /** + * Multiply limbs by scalar value. + * Superclass assumes that limb primitive radix > (bits per limb * 2) + * + * @param a [in|out] the limbs to multiply a carry operation. 'a' is + * assumed to be reduced. + * @param b [in] the scalar value to be muliplied with the limbs. + */ + @Override + protected void multByInt(long[] a, long b) { + long aa0 = a[0]; + long aa1 = a[1]; + long aa2 = a[2]; + long aa3 = a[3]; + long aa4 = a[4]; + + long bb0 = b; + + final long shift1 = 64 - BITS_PER_LIMB; + final long shift2 = BITS_PER_LIMB; + + long d0; // low digit from multiplication + long dd0; // high digit from multiplication + // multiplication result digits for each column + long c0, c1, c2, c3, c4, c5; + + // Row 0 - multiply by aa0 + d0 = aa0 * bb0; + dd0 = Math.multiplyHigh(aa0, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + c0 = d0; + c1 = dd0; + + // Row 1 - multiply by aa1 + d0 = aa1 * bb0; + dd0 = Math.multiplyHigh(aa1, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + c1 += d0; + c2 = dd0; + + // Row 2 - multiply by aa2 + d0 = aa2 * bb0; + dd0 = Math.multiplyHigh(aa2, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + c2 += d0; + c3 = dd0; + + // Row 3 - multiply by aa3 + d0 = aa3 * bb0; + dd0 = Math.multiplyHigh(aa3, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + c3 += d0; + c4 = dd0; + + // Row 4 - multiply by aa4 + d0 = aa4 * bb0; + dd0 = Math.multiplyHigh(aa4, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + c4 += d0; + c5 = dd0; + + // Perform pseudo-Mersenne reduction + a[0] = c0 + (19 * c5); + + a[1] = c1; + a[2] = c2; + a[3] = c3; + a[4] = c4; + + reduce(a); + } + + /** + * Carry in all positions and reduce high order limb. + * + * @param limbs [in|out] the limbs to carry and reduce. + */ + protected void reduce(long[] limbs) { + long carry = (limbs[3] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[3] -= carry << BITS_PER_LIMB; + limbs[4] += carry; + + carry = (limbs[4] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[4] -= carry << BITS_PER_LIMB; + + limbs[0] += 19 * carry; + + carry = (limbs[0] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[0] -= carry << BITS_PER_LIMB; + limbs[1] += carry; + + carry = (limbs[1] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[1] -= carry << BITS_PER_LIMB; + limbs[2] += carry; + + carry = (limbs[2] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[2] -= carry << BITS_PER_LIMB; + limbs[3] += carry; + + carry = (limbs[3] + CARRY_ADD) >> BITS_PER_LIMB; + limbs[3] -= carry << BITS_PER_LIMB; + limbs[4] += carry; + } + + /** + * Reduces digit 'v' at limb position 'i' to a lower limb. + * + * @param limbs [in|out] the limbs to reduce in. + * @param v [in] the digit to reduce to the lower limb. + * @param i [in] the limbs to reduce from. + */ + protected void reduceIn(long[] limbs, long v, int i) { + limbs[i - NUM_LIMBS] += 19 * v; + } + + /** + * Carry from high order limb and reduce to the lower order limb. Assumed + * to be called two times to propagate the carries. + * + * @param limbs [in|out] the limbs to fully carry and reduce. + */ + protected void finalCarryReduceLast(long[] limbs) { + long carry = limbs[4] >> BITS_PER_LIMB; + + limbs[4] -= carry << BITS_PER_LIMB; + limbs[0] += 19 * carry; + } + + /** + * Multiply two limbs using a high/low digit technique that allows for + * larger limb sizes. It is assumed that both limbs have already been + * reduced. + * + * @param a [in] the limb operand to multiply. + * @param b [in] the limb operand to multiply. + * @param r [out] the product of the limbs operands that is fully reduced. + */ + protected void mult(long[] a, long[] b, long[] r) { + long aa0 = a[0]; + long aa1 = a[1]; + long aa2 = a[2]; + long aa3 = a[3]; + long aa4 = a[4]; + + long bb0 = b[0]; + long bb1 = b[1]; + long bb2 = b[2]; + long bb3 = b[3]; + long bb4 = b[4]; + + final long shift1 = 64 - BITS_PER_LIMB; + final long shift2 = BITS_PER_LIMB; + + long d0, d1, d2, d3, d4; // low digits from multiplication + long dd0, dd1, dd2, dd3, dd4; // high digits from multiplication + // multiplication result digits for each column + long c0, c1, c2, c3, c4, c5, c6, c7, c8, c9; + + // Row 0 - multiply by aa0 + d0 = aa0 * bb0; + dd0 = Math.multiplyHigh(aa0, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa0 * bb1; + dd1 = Math.multiplyHigh(aa0, bb1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa0 * bb2; + dd2 = Math.multiplyHigh(aa0, bb2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa0 * bb3; + dd3 = Math.multiplyHigh(aa0, bb3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa0 * bb4; + dd4 = Math.multiplyHigh(aa0, bb4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c0 = d0; + c1 = d1 + dd0; + c2 = d2 + dd1; + c3 = d3 + dd2; + c4 = d4 + dd3; + c5 = dd4; + + // Row 1 - multiply by aa1 + d0 = aa1 * bb0; + dd0 = Math.multiplyHigh(aa1, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa1 * bb1; + dd1 = Math.multiplyHigh(aa1, bb1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa1 * bb2; + dd2 = Math.multiplyHigh(aa1, bb2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa1 * bb3; + dd3 = Math.multiplyHigh(aa1, bb3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa1 * bb4; + dd4 = Math.multiplyHigh(aa1, bb4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c1 += d0; + c2 += d1 + dd0; + c3 += d2 + dd1; + c4 += d3 + dd2; + c5 += d4 + dd3; + c6 = dd4; + + // Row 2 - multiply by aa2 + d0 = aa2 * bb0; + dd0 = Math.multiplyHigh(aa2, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa2 * bb1; + dd1 = Math.multiplyHigh(aa2, bb1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa2 * bb2; + dd2 = Math.multiplyHigh(aa2, bb2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa2 * bb3; + dd3 = Math.multiplyHigh(aa2, bb3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa2 * bb4; + dd4 = Math.multiplyHigh(aa2, bb4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c2 += d0; + c3 += d1 + dd0; + c4 += d2 + dd1; + c5 += d3 + dd2; + c6 += d4 + dd3; + c7 = dd4; + + // Row 3 - multiply by aa3 + d0 = aa3 * bb0; + dd0 = Math.multiplyHigh(aa3, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa3 * bb1; + dd1 = Math.multiplyHigh(aa3, bb1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa3 * bb2; + dd2 = Math.multiplyHigh(aa3, bb2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa3 * bb3; + dd3 = Math.multiplyHigh(aa3, bb3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa3 * bb4; + dd4 = Math.multiplyHigh(aa3, bb4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c3 += d0; + c4 += d1 + dd0; + c5 += d2 + dd1; + c6 += d3 + dd2; + c7 += d4 + dd3; + c8 = dd4; + + // Row 4 - multiply by aa4 + d0 = aa4 * bb0; + dd0 = Math.multiplyHigh(aa4, bb0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa4 * bb1; + dd1 = Math.multiplyHigh(aa4, bb1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa4 * bb2; + dd2 = Math.multiplyHigh(aa4, bb2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa4 * bb3; + dd3 = Math.multiplyHigh(aa4, bb3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa4 * bb4; + dd4 = Math.multiplyHigh(aa4, bb4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c4 += d0; + c5 += d1 + dd0; + c6 += d2 + dd1; + c7 += d3 + dd2; + c8 += d4 + dd3; + c9 = dd4; + + // Perform pseudo-Mersenne reduction + r[0] = c0 + (19 * c5); + r[1] = c1 + (19 * c6); + r[2] = c2 + (19 * c7); + r[3] = c3 + (19 * c8); + r[4] = c4 + (19 * c9); + + reduce(r); + } + + /** + * Takes a single limb and squares it using a high/low digit technique that + * allows for larger limb sizes. It is assumed that the limb input has + * already been reduced. + * + * @param a [in] the limb operand to square. + * @param r [out] the resulting square of the limb which is fully reduced. + */ + protected void square(long[] a, long[] r) { + long aa0 = a[0]; + long aa1 = a[1]; + long aa2 = a[2]; + long aa3 = a[3]; + long aa4 = a[4]; + + final long shift1 = 64 - BITS_PER_LIMB; + final long shift2 = BITS_PER_LIMB; + + long d0, d1, d2, d3, d4; // low digits from multiplication + long dd0, dd1, dd2, dd3, dd4; // high digits from multiplication + // multiplication result digits for each column + long c0, c1, c2, c3, c4, c5, c6, c7, c8, c9; + + // Row 0 - multiply by aa0 + d0 = aa0 * aa0; + dd0 = Math.multiplyHigh(aa0, aa0) << shift1 | (d0 >>> shift2); + d0 &= LIMB_MASK; + + d1 = aa0 * aa1; + dd1 = Math.multiplyHigh(aa0, aa1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa0 * aa2; + dd2 = Math.multiplyHigh(aa0, aa2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa0 * aa3; + dd3 = Math.multiplyHigh(aa0, aa3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa0 * aa4; + dd4 = Math.multiplyHigh(aa0, aa4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c0 = d0; + c1 = (d1 << 1) + dd0; + c2 = (d2 + dd1) << 1; + c3 = (d3 + dd2) << 1; + c4 = (d4 + dd3) << 1; + c5 = dd4 << 1; + + // Row 1 - multiply by aa1 + d1 = aa1 * aa1; + dd1 = Math.multiplyHigh(aa1, aa1) << shift1 | (d1 >>> shift2); + d1 &= LIMB_MASK; + + d2 = aa1 * aa2; + dd2 = Math.multiplyHigh(aa1, aa2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa1 * aa3; + dd3 = Math.multiplyHigh(aa1, aa3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa1 * aa4; + dd4 = Math.multiplyHigh(aa1, aa4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c2 += d1; + c3 += (d2 << 1) + dd1; + c4 += (d3 + dd2) << 1; + c5 += (d4 + dd3) << 1; + c6 = dd4 << 1; + + // Row 2 - multiply by aa2 + d2 = aa2 * aa2; + dd2 = Math.multiplyHigh(aa2, aa2) << shift1 | (d2 >>> shift2); + d2 &= LIMB_MASK; + + d3 = aa2 * aa3; + dd3 = Math.multiplyHigh(aa2, aa3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa2 * aa4; + dd4 = Math.multiplyHigh(aa2, aa4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c4 += d2; + c5 += (d3 << 1) + dd2; + c6 += (d4 + dd3) << 1; + c7 = dd4 << 1; + + // Row 3 - multiply by aa3 + d3 = aa3 * aa3; + dd3 = Math.multiplyHigh(aa3, aa3) << shift1 | (d3 >>> shift2); + d3 &= LIMB_MASK; + + d4 = aa3 * aa4; + dd4 = Math.multiplyHigh(aa3, aa4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c6 += d3; + c7 += (d4 << 1) + dd3; + c8 = dd4 << 1; + + // Row 4 - multiply by aa4 + d4 = aa4 * aa4; + dd4 = Math.multiplyHigh(aa4, aa4) << shift1 | (d4 >>> shift2); + d4 &= LIMB_MASK; + + c8 += d4; + c9 = dd4; + + // Perform pseudo-Mersenne reduction + r[0] = c0 + (19 * c5); + r[1] = c1 + (19 * c6); + r[2] = c2 + (19 * c7); + r[3] = c3 + (19 * c8); + r[4] = c4 + (19 * c9); + + reduce(r); + } +} diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security index ef4d7285f51..d5d0488a004 100644 --- a/src/java.base/share/conf/security/java.security +++ b/src/java.base/share/conf/security/java.security @@ -1704,7 +1704,7 @@ com.sun.security.allowedAIALocations= # # PKCS #8 encoding format for newly created ML-KEM and ML-DSA private keys # -# draft-ietf-lamps-kyber-certificates-11 and RFC 9881 define three possible formats for a private key: +# RFC 9935 and RFC 9881 define three possible formats for a private key: # a seed (64 bytes for ML-KEM, 32 bytes for ML-DSA), an expanded private key, # or a sequence containing both. # diff --git a/src/java.base/share/data/tzdata/VERSION b/src/java.base/share/data/tzdata/VERSION index ce25e7653b0..a2974d757c8 100644 --- a/src/java.base/share/data/tzdata/VERSION +++ b/src/java.base/share/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2025c +tzdata2026a diff --git a/src/java.base/share/data/tzdata/etcetera b/src/java.base/share/data/tzdata/etcetera index 41660b05dba..9b030fdb8d4 100644 --- a/src/java.base/share/data/tzdata/etcetera +++ b/src/java.base/share/data/tzdata/etcetera @@ -43,7 +43,8 @@ # which load the "UTC" file to handle seconds properly. Zone Etc/UTC 0 - UTC -# Functions like gmtime load the "GMT" file to handle leap seconds properly. +# If leap second support is enabled, functions like gmtime +# load the "GMT" file to handle leap seconds properly. # Vanguard section, which works with most .zi parsers. #Zone GMT 0 - GMT # Rearguard section, for TZUpdater 2.3.2 and earlier. diff --git a/src/java.base/share/data/tzdata/europe b/src/java.base/share/data/tzdata/europe index b82ca6f67bb..a66d40834cd 100644 --- a/src/java.base/share/data/tzdata/europe +++ b/src/java.base/share/data/tzdata/europe @@ -1064,9 +1064,19 @@ Zone Atlantic/Faroe -0:27:04 - LMT 1908 Jan 11 # Tórshavn # Greenland # -# From Paul Eggert (2004-10-31): +# From Paul Eggert (2026-01-22): +# During World War II, Greenland was effectively independent of Denmark and +# observed daylight saving time. TIME, volume 37, page 23 (1941-04-21) +# says, +# "Penfield and West made their way to the U.S.'s most northerly consulate. +# They were astonished to find that Greenlanders, with almost 24 hours of +# sunlight a day during the summer, have daylight saving time." +# As the details are unknown they are omitted from the data for now. +# # During World War II, Germany maintained secret manned weather stations in # East Greenland and Franz Josef Land, but we don't know their time zones. +# Also, they're likely out of scope for the database +# as we lack resources to track every bit of military activity. # My source for this is Wilhelm Dege's book mentioned under Svalbard. # # From Paul Eggert (2017-12-10): @@ -1980,7 +1990,6 @@ Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 # Valletta # From Stepan Golosunov (2016-03-07): # the act of the government of the Republic of Moldova Nr. 132 from 1990-05-04 -# http://lex.justice.md/viewdoc.php?action=view&view=doc&id=298782&lang=2 # ... says that since 1990-05-06 on the territory of the Moldavian SSR # time would be calculated as the standard time of the second time belt # plus one hour of the "summer" time. To implement that clocks would be @@ -2035,9 +2044,61 @@ Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 # Valletta # says the 2014-03-30 spring-forward transition was at 02:00 local time. # Guess that since 1997 Moldova has switched one hour before the EU. +# From Heitor David Pinto (2026-02-22): +# Soviet Moldovan resolution 132 of 1990 defined the summer time period from +# the last Sunday in March at 2:00 to the last Sunday in September at 3:00, +# matching the dates used in most of Europe at the time: +# https://web.archive.org/web/20211107050832/http://lex.justice.md/viewdoc.php?action=view&view=doc&id=298782&lang=1 +# +# It seems that in 1996 Moldova changed the end date to October like most of +# Europe, but kept the transitions at 2:00 and 3:00 rather than 1:00 UTC, +# which would have been locally 3:00 and 4:00.... +# +# The notices in the Moldovan government website and broadcaster showed the +# transitions at 2:00 and 3:00 until 2021: +# 2015 https://old.gov.md/en/node/7304 +# 2016 https://old.gov.md/en/node/12587 +# 2017 https://old.gov.md/en/node/20654 +# 2017 https://old.gov.md/en/content/moldova-upholds-winter-time-night-28-29-october +# 2018 https://old.gov.md/en/content/moldova-switch-summer-time +# 2018 https://old.gov.md/en/content/cabinet-ministers-informs-about-switch-winter-time-28-october +# 2019 https://old.gov.md/en/content/moldova-switch-summer-time-31-march +# 2019 https://old.gov.md/en/node/31122 +# 2020 https://old.gov.md/en/node/32771 +# 2020 https://old.gov.md/en/node/34497 +# 2021 https://trm.md/ro/social/moldova-trece-in-aceasta-noapte-la-ora-de-vara +# 2021 https://trm.md/en/social/republica-moldova-trece-la-ora-de-iarna1 +# +# However, since 2022, the notices showed the transitions at 3:00 and 4:00, +# matching the EU rule at 1:00 UTC: +# 2022 https://trm.md/en/social/in-acest-weekend-republica-moldova-trece-la-ora-de-vara +# 2022 https://old.gov.md/en/content/moldova-switch-winter-time +# 2023 https://moldova1.md/p/6587/ora-de-vara-2023-cum-schimbam-acele-ceasornicelor-si-cand-trecem-la-ora-de-vara +# 2023 https://old.gov.md/en/node/46662 +# 2024 https://moldova1.md/p/26535/republica-moldova-trece-la-ora-de-vara-in-acest-weekend +# 2024 https://moldova1.md/p/37768/republica-moldova-trece-in-aceasta-noapte-la-ora-de-iarna +# 2025 https://moldova1.md/p/46349/republica-moldova-trece-la-ora-de-vara-pe-30-martie-cum-ne-afecteaza-si-ce-recomanda-medicii +# 2025 https://moldova1.md/p/60469/republica-moldova-trece-la-ora-de-iarna-ceasurile-se-dau-inapoi-cu-o-ora +# +# It seems that the changes to the end date and transition times were just +# done in practice without formally changing the resolution. In late 2025, the +# government said that the Soviet resolution was still in force, and proposed +# a new resolution to replace it and formally establish the EU rule: +# ... based on the notices, it seems that in practice Moldova already +# uses the EU rule since 2022. This was also the year when Moldova applied to +# join the EU. +# +# From Robert Bastian (2026-02-26): +# This has been approved and published in the government gazette: +# https://monitorul.gov.md/ro/monitorul/view/pdf/3234/part/2#page=27 +# +# From Paul Eggert (2026-02-24): +# Also see Svetlana Rudenko, "Moldova abandons the 'Soviet era'", Logos Press, +# 2026-02-21 . + # Rule NAME FROM TO - IN ON AT SAVE LETTER/S -Rule Moldova 1997 max - Mar lastSun 2:00 1:00 S -Rule Moldova 1997 max - Oct lastSun 3:00 0 - +Rule Moldova 1997 2021 - Mar lastSun 2:00 1:00 S +Rule Moldova 1997 2021 - Oct lastSun 3:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Chisinau 1:55:20 - LMT 1880 @@ -2050,7 +2111,8 @@ Zone Europe/Chisinau 1:55:20 - LMT 1880 2:00 Russia EE%sT 1992 2:00 E-Eur EE%sT 1997 # See Romania commentary for the guessed 1997 transition to EU rules. - 2:00 Moldova EE%sT + 2:00 Moldova EE%sT 2022 + 2:00 EU EE%sT # Poland @@ -2436,7 +2498,7 @@ Zone Atlantic/Madeira -1:07:36 - LMT 1884 # Funchal # Nine O'clock # (1998-10-23) reports that the switch occurred at # 04:00 local time in fall 1998. For lack of better info, -# assume that Romania and Moldova switched to EU rules in 1997, +# assume that Romania switched to EU rules in 1997, # the same year as Bulgaria. # # Rule NAME FROM TO - IN ON AT SAVE LETTER/S diff --git a/src/java.base/share/data/tzdata/leapseconds b/src/java.base/share/data/tzdata/leapseconds index 9426b40f07e..d431a7d3607 100644 --- a/src/java.base/share/data/tzdata/leapseconds +++ b/src/java.base/share/data/tzdata/leapseconds @@ -93,7 +93,7 @@ Leap 2016 Dec 31 23:59:60 + S # Any additional leap seconds will come after this. # This Expires line is commented out for now, # so that pre-2020a zic implementations do not reject this file. -#Expires 2026 Jun 28 00:00:00 +#Expires 2026 Dec 28 00:00:00 # Here are POSIX timestamps for the data in this file. # "#updated" gives the last time the leap seconds data changed @@ -102,8 +102,8 @@ Leap 2016 Dec 31 23:59:60 + S # "#expires" gives the first time this file might be wrong; # if this file was derived from the IERS leap-seconds.list, # this is typically a bit less than one year after "updated". -#updated 1751846400 (2025-07-07 00:00:00 UTC) -#expires 1782604800 (2026-06-28 00:00:00 UTC) +#updated 1767698058 (2026-01-06 11:14:18 UTC) +#expires 1798416000 (2026-12-28 00:00:00 UTC) # Updated through IERS Bulletin C (https://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat) -# File expires on 28 June 2026 +# File expires on 28 December 2026 diff --git a/src/java.base/share/legal/zlib.md b/src/java.base/share/legal/zlib.md index fcc5457bf5b..c729c4248d4 100644 --- a/src/java.base/share/legal/zlib.md +++ b/src/java.base/share/legal/zlib.md @@ -1,9 +1,9 @@ -## zlib v1.3.1 +## zlib v1.3.2 ### zlib License

 
-Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
+Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
 
 This software is provided 'as-is', without any express or implied
 warranty.  In no event will the authors be held liable for any damages
diff --git a/src/java.base/share/man/java.md b/src/java.base/share/man/java.md
index 956a6aa144b..18d64b3a4c2 100644
--- a/src/java.base/share/man/java.md
+++ b/src/java.base/share/man/java.md
@@ -2454,8 +2454,8 @@ Java HotSpot VM.
 
 [`-XX:InitialRAMPercentage=`]{#-XX_InitialRAMPercentage}*percent*
 :   Sets the initial amount of memory that the JVM will use for the Java heap
-    before applying ergonomics heuristics as a percentage of the maximum amount
-    determined as described in the `-XX:MaxRAM` option.
+    before applying ergonomics heuristics as a percentage of the available memory
+    to the JVM process.
 
     The following example shows how to set the percentage of the initial
     amount of memory used for the Java heap:
@@ -2575,9 +2575,8 @@ Java HotSpot VM.
 
 [`-XX:MaxRAMPercentage=`]{#-XX_MaxRAMPercentage}*percent*
 :   Sets the maximum amount of memory that the JVM may use for the Java heap
-    before applying ergonomics heuristics as a percentage of the maximum amount
-    determined as described in the `-XX:MaxRAM` option. The default value is 25
-    percent.
+    before applying ergonomics heuristics as a percentage of the available memory
+    to the JVM process. The default value is 25 percent.
 
     Specifying this option disables automatic use of compressed oops if
     the combined result of this and other options influencing the maximum amount
@@ -2591,9 +2590,9 @@ Java HotSpot VM.
 
 [`-XX:MinRAMPercentage=`]{#-XX_MinRAMPercentage}*percent*
 :   Sets the maximum amount of memory that the JVM may use for the Java heap
-    before applying ergonomics heuristics as a percentage of the maximum amount
-    determined as described in the `-XX:MaxRAM` option for small heaps. A small
-    heap is a heap of approximately 125 MB. The default value is 50 percent.
+    before applying ergonomics heuristics as a percentage of the available memory
+    to the JVM process for small heaps. A small heap is a heap of approximately
+    125 MB. The default value is 50 percent.
 
     The following example shows how to set the percentage of the maximum amount
     of memory used for the Java heap for small heaps:
@@ -2939,51 +2938,12 @@ they're used.
     (`-XX:+UseParallelGC` or `-XX:+UseG1GC`). Other collectors employing multiple
     threads always perform reference processing in parallel.
 
-[`-XX:MaxRAM=`]{#-XX_MaxRAM}*size*
-:   Sets the maximum amount of memory that the JVM may use for the Java heap
-    before applying ergonomics heuristics. The default value is the amount of
-    available memory to the JVM process.
-
-    The maximum amount of available memory to the JVM process is the minimum
-    of the machine's physical memory and any constraints set by the environment
-    (e.g. container).
-
-    Specifying this option disables automatic use of compressed oops if
-    the combined result of this and other options influencing the maximum amount
-    of memory is larger than the range of memory addressable by compressed oops.
-    See `-XX:UseCompressedOops` for further information about compressed oops.
-
-    The following example shows how to set the maximum amount of available
-    memory for sizing the Java heap to 2 GB:
-
-    >   `-XX:MaxRAM=2G`
-
 [`-XX:+AggressiveHeap`]{#-XX__AggressiveHeap}
 :   Enables Java heap optimization. This sets various parameters to be
     optimal for long-running jobs with intensive memory allocation, based on
     the configuration of the computer (RAM and CPU). By default, the option
     is disabled and the heap sizes are configured less aggressively.
 
-[`-XX:+NeverActAsServerClassMachine`]{#-XX__NeverActAsServerClassMachine}
-:   Enable the "Client VM emulation" mode which only uses the C1 JIT compiler,
-    a 32Mb CodeCache and the Serial GC. The maximum amount of memory that the
-    JVM may use (controlled by the `-XX:MaxRAM=n` flag) is set to 1GB by default.
-    The string "emulated-client" is added to the JVM version string.
-
-    By default the flag is set to `true` only on Windows in 32-bit mode and
-    `false` in all other cases.
-
-    The "Client VM emulation" mode will not be enabled if any of the following
-    flags are used on the command line:
-
-    ```
-    -XX:{+|-}TieredCompilation
-    -XX:CompilationMode=mode
-    -XX:TieredStopAtLevel=n
-    -XX:{+|-}EnableJVMCI
-    -XX:{+|-}UseJVMCICompiler
-    ```
-
 ## Obsolete Java Options
 
 These `java` options are still accepted but ignored, and a warning is issued
@@ -2996,6 +2956,26 @@ when they're used.
     396](https://openjdk.org/jeps/396) and made obsolete in JDK 17
     by [JEP 403](https://openjdk.org/jeps/403).
 
+[`-XX:+NeverActAsServerClassMachine`]{#-XX__NeverActAsServerClassMachine}
+:   Enabled the "Client VM emulation" mode, which used only the C1 JIT compiler,
+    a 32Mb CodeCache, and the Serial GC. The maximum amount of memory that the
+    JVM could use was set to 1GB by default. The string "emulated-client" was added
+    to the JVM version string.
+
+    By default the flag was set to `true` only on Windows in 32-bit mode and
+    `false` in all other cases.
+
+    The "Client VM emulation" mode was not enabled if any of the following
+    flags were used on the command line:
+
+    ```
+    -XX:{+|-}TieredCompilation
+    -XX:CompilationMode=mode
+    -XX:TieredStopAtLevel=n
+    -XX:{+|-}EnableJVMCI
+    -XX:{+|-}UseJVMCICompiler
+    ```
+
 ## Removed Java Options
 
 No documented java options have been removed in JDK @@VERSION_SPECIFICATION@@.
diff --git a/src/java.base/share/native/include/classfile_constants.h.template b/src/java.base/share/native/include/classfile_constants.h.template
index fb022ec1fd4..4f96a0673ef 100644
--- a/src/java.base/share/native/include/classfile_constants.h.template
+++ b/src/java.base/share/native/include/classfile_constants.h.template
@@ -111,7 +111,7 @@ enum {
     JVM_CONSTANT_InvokeDynamic          = 18,
     JVM_CONSTANT_Module                 = 19,
     JVM_CONSTANT_Package                = 20,
-    JVM_CONSTANT_ExternalMax            = 20 
+    JVM_CONSTANT_ExternalMax            = 20
 };
 
 /* JVM_CONSTANT_MethodHandle subtypes */
diff --git a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c
index 3f57a2b97cf..7519efd93bb 100644
--- a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c
+++ b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2026, 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
@@ -87,14 +87,32 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_ffi_1get_1struct_1offsets(JNI
   return ffi_get_struct_offsets((ffi_abi) abi, jlong_to_ptr(type), jlong_to_ptr(offsets));
 }
 
-static void do_capture_state(int32_t* value_ptr, int captured_state_mask) {
-    // keep in synch with jdk.internal.foreign.abi.CapturableState
-  enum PreservableValues {
-    NONE = 0,
-    GET_LAST_ERROR = 1,
-    WSA_GET_LAST_ERROR = 1 << 1,
-    ERRNO = 1 << 2
-  };
+// keep in synch with jdk.internal.foreign.abi.CapturableState
+enum PreservableValues {
+  NONE = 0,
+  GET_LAST_ERROR = 1,
+  WSA_GET_LAST_ERROR = 1 << 1,
+  ERRNO = 1 << 2
+};
+
+static void do_capture_state_pre(int32_t* value_ptr, int captured_state_mask) {
+#ifdef _WIN64
+  if (captured_state_mask & GET_LAST_ERROR) {
+    SetLastError(*value_ptr);
+  }
+  value_ptr++;
+  if (captured_state_mask & WSA_GET_LAST_ERROR) {
+    WSASetLastError(*value_ptr);
+    *value_ptr = WSAGetLastError();
+  }
+  value_ptr++;
+#endif
+  if (captured_state_mask & ERRNO) {
+    errno = *value_ptr;
+  }
+}
+
+static void do_capture_state_post(int32_t* value_ptr, int captured_state_mask) {
 #ifdef _WIN64
   if (captured_state_mask & GET_LAST_ERROR) {
     *value_ptr = GetLastError();
@@ -142,10 +160,15 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclas
     }
   }
 
+  if (captured_state_mask != 0) {
+    // Copy the contents of the capture state buffer into thread local
+    do_capture_state_pre(captured_state_addr, captured_state_mask);
+  }
+
   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);
+    do_capture_state_post(captured_state_addr, captured_state_mask);
   }
 
   if (heapBases != NULL) {
diff --git a/src/java.base/share/native/libverify/check_code.c b/src/java.base/share/native/libverify/check_code.c
index 5a8f50cd0a0..4830fedb97b 100644
--- a/src/java.base/share/native/libverify/check_code.c
+++ b/src/java.base/share/native/libverify/check_code.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2026, 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
@@ -2162,8 +2162,7 @@ pop_stack(context_type *context, unsigned int inumber, stack_info_type *new_stac
                         break;
                     if (   (GET_ITEM_TYPE(top_type) == ITEM_NewObject
                             || (GET_ITEM_TYPE(top_type) == ITEM_InitObject))
-                        && ((opcode == JVM_OPC_astore) || (opcode == JVM_OPC_aload)
-                            || (opcode == JVM_OPC_ifnull) || (opcode == JVM_OPC_ifnonnull)))
+                        && ((opcode == JVM_OPC_astore) || (opcode == JVM_OPC_aload)))
                         break;
                     /* The 2nd edition VM of the specification allows field
                      * initializations before the superclass initializer,
diff --git a/src/java.base/share/native/libzip/zlib/ChangeLog b/src/java.base/share/native/libzip/zlib/ChangeLog
index b801a1031ec..312753edade 100644
--- a/src/java.base/share/native/libzip/zlib/ChangeLog
+++ b/src/java.base/share/native/libzip/zlib/ChangeLog
@@ -1,6 +1,57 @@
 
                 ChangeLog file for zlib
 
+Changes in 1.3.2 (17 Feb 2026)
+- Continued rewrite of CMake build [Vollstrecker]
+- Various portability improvements
+- Various github workflow additions and improvements
+- Check for negative lengths in crc32_combine functions
+- Copy only the initialized window contents in inflateCopy
+- Prevent the use of insecure functions without an explicit request
+- Add compressBound_z and deflateBound_z functions for large values
+- Use atomics to build inflate fixed tables once
+- Add definition of ZLIB_INSECURE to build tests with c89 and c94
+- Add --undefined option to ./configure for UBSan checker
+- Copy only the initialized deflate state in deflateCopy
+- Zero inflate state on allocation
+- Remove untgz from contrib
+- Add _z versions of the compress and uncompress functions
+- Vectorize the CRC-32 calculation on the s390x
+- Set bit 11 of the zip header flags in minizip if UTF-8
+- Update OS/400 support
+- Add a test to configure to check for a working compiler
+- Check for invalid NULL pointer inputs to zlib operations
+- Add --mandir to ./configure to specify manual directory
+- Add LICENSE.Info-Zip to contrib/minizip
+- Remove vstudio projects in lieu of cmake-generated projects
+- Replace strcpy() with memcpy() in contrib/minizip
+
+Changes in 1.3.1.2 (8 Dec 2025)
+- Improve portability to RISC OS
+- Permit compiling contrib/minizip/unzip.c with decryption
+- Enable build of shared library on AIX
+- Make deflateBound() more conservative and handle Z_STREAM_END
+- Add zipAlreadyThere() to minizip zip.c to help avoid duplicates
+- Make z_off_t 64 bits by default
+- Add deflateUsed() function to get the used bits in the last byte
+- Avoid out-of-bounds pointer arithmetic in inflateCopy()
+- Add Haiku to configure for proper LDSHARED settings
+- Add Bazel targets
+- Complete rewrite of CMake build [Vollstrecker]
+- Clarify the use of errnum in gzerror()
+- Note that gzseek() requests are deferred until the next operation
+- Note the use of gzungetc() to run a deferred seek while reading
+- Fix bug in inflatePrime() for 16-bit ints
+- Add a "G" option to force gzip, disabling transparency in gzread()
+- Improve the discrimination between trailing garbage and bad gzip
+- Allow gzflush() to write empty gzip members
+- Remove redundant frees of point list on error in examples/zran.c
+- Clarify the use of inflateGetHeader()
+- Update links to the RFCs
+- Return all available uncompressed data on error in gzread.c
+- Support non-blocking devices in the gz* routines
+- Various other small improvements
+
 Changes in 1.3.1 (22 Jan 2024)
 - Reject overflows of zip header fields in minizip
 - Fix bug in inflateSync() for data held in bit buffer
diff --git a/src/java.base/share/native/libzip/zlib/README b/src/java.base/share/native/libzip/zlib/README
index c5f917540b6..2b1e6f36fe3 100644
--- a/src/java.base/share/native/libzip/zlib/README
+++ b/src/java.base/share/native/libzip/zlib/README
@@ -1,10 +1,10 @@
 ZLIB DATA COMPRESSION LIBRARY
 
-zlib 1.3.1 is a general purpose data compression library.  All the code is
-thread safe.  The data format used by the zlib library is described by RFCs
-(Request for Comments) 1950 to 1952 in the files
-http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
-rfc1952 (gzip format).
+zlib 1.3.2 is a general purpose data compression library.  All the code is
+thread safe (though see the FAQ for caveats).  The data format used by the zlib
+library is described by RFCs (Request for Comments) 1950 to 1952 at
+https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
+format) and rfc1952 (gzip format).
 
 All functions of the compression library are documented in the file zlib.h
 (volunteer to write man pages welcome, contact zlib@gzip.org).  A usage example
@@ -21,17 +21,17 @@ make_vms.com.
 
 Questions about zlib should be sent to , or to Gilles Vollant
  for the Windows DLL version.  The zlib home page is
-http://zlib.net/ .  Before reporting a problem, please check this site to
+https://zlib.net/ .  Before reporting a problem, please check this site to
 verify that you have the latest version of zlib; otherwise get the latest
 version and check whether the problem still exists or not.
 
-PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
+PLEASE read the zlib FAQ https://zlib.net/zlib_faq.html before asking for help.
 
 Mark Nelson  wrote an article about zlib for the Jan.  1997
 issue of Dr.  Dobb's Journal; a copy of the article is available at
-https://marknelson.us/posts/1997/01/01/zlib-engine.html .
+https://zlib.net/nelson/ .
 
-The changes made in version 1.3.1 are documented in the file ChangeLog.
+The changes made in version 1.3.2 are documented in the file ChangeLog.
 
 Unsupported third party contributions are provided in directory contrib/ .
 
@@ -43,9 +43,9 @@ can be found at https://github.com/pmqs/IO-Compress .
 
 A Python interface to zlib written by A.M. Kuchling  is
 available in Python 1.5 and later versions, see
-http://docs.python.org/library/zlib.html .
+https://docs.python.org/3/library/zlib.html .
 
-zlib is built into tcl: http://wiki.tcl.tk/4610 .
+zlib is built into tcl: https://wiki.tcl-lang.org/page/zlib .
 
 An experimental package to read and write files in .zip format, written on top
 of zlib by Gilles Vollant , is available in the
@@ -69,9 +69,7 @@ Notes for some targets:
 - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
   other compilers. Use "make test" to check your compiler.
 
-- gzdopen is not supported on RISCOS or BEOS.
-
-- For PalmOs, see http://palmzlib.sourceforge.net/
+- For PalmOs, see https://palmzlib.sourceforge.net/
 
 
 Acknowledgments:
@@ -83,7 +81,7 @@ Acknowledgments:
 
 Copyright notice:
 
- (C) 1995-2024 Jean-loup Gailly and Mark Adler
+ (C) 1995-2026 Jean-loup Gailly and Mark Adler
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
diff --git a/src/java.base/share/native/libzip/zlib/compress.c b/src/java.base/share/native/libzip/zlib/compress.c
index d7421379673..54346ad2a2f 100644
--- a/src/java.base/share/native/libzip/zlib/compress.c
+++ b/src/java.base/share/native/libzip/zlib/compress.c
@@ -23,7 +23,7 @@
  */
 
 /* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -42,13 +42,19 @@
      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    Z_STREAM_ERROR if the level parameter is invalid.
+
+     The _z versions of the functions take size_t length arguments.
 */
-int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
-                      uLong sourceLen, int level) {
+int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
+                        z_size_t sourceLen, int level) {
     z_stream stream;
     int err;
     const uInt max = (uInt)-1;
-    uLong left;
+    z_size_t left;
+
+    if ((sourceLen > 0 && source == NULL) ||
+        destLen == NULL || (*destLen > 0 && dest == NULL))
+        return Z_STREAM_ERROR;
 
     left = *destLen;
     *destLen = 0;
@@ -67,23 +73,36 @@ int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
 
     do {
         if (stream.avail_out == 0) {
-            stream.avail_out = left > (uLong)max ? max : (uInt)left;
+            stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
             left -= stream.avail_out;
         }
         if (stream.avail_in == 0) {
-            stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
+            stream.avail_in = sourceLen > (z_size_t)max ? max :
+                                                          (uInt)sourceLen;
             sourceLen -= stream.avail_in;
         }
         err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
     } while (err == Z_OK);
 
-    *destLen = stream.total_out;
+    *destLen = (z_size_t)(stream.next_out - dest);
     deflateEnd(&stream);
     return err == Z_STREAM_END ? Z_OK : err;
 }
-
+int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
+                      uLong sourceLen, int level) {
+    int ret;
+    z_size_t got = *destLen;
+    ret = compress2_z(dest, &got, source, sourceLen, level);
+    *destLen = (uLong)got;
+    return ret;
+}
 /* ===========================================================================
  */
+int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
+                       z_size_t sourceLen) {
+    return compress2_z(dest, destLen, source, sourceLen,
+                       Z_DEFAULT_COMPRESSION);
+}
 int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
                      uLong sourceLen) {
     return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
@@ -93,7 +112,12 @@ int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
      If the default memLevel or windowBits for deflateInit() is changed, then
    this function needs to be updated.
  */
-uLong ZEXPORT compressBound(uLong sourceLen) {
-    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
-           (sourceLen >> 25) + 13;
+z_size_t ZEXPORT compressBound_z(z_size_t sourceLen) {
+    z_size_t bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+                     (sourceLen >> 25) + 13;
+    return bound < sourceLen ? (z_size_t)-1 : bound;
+}
+uLong ZEXPORT compressBound(uLong sourceLen) {
+    z_size_t bound = compressBound_z(sourceLen);
+    return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
 }
diff --git a/src/java.base/share/native/libzip/zlib/deflate.c b/src/java.base/share/native/libzip/zlib/deflate.c
index 57fc6802bb8..0ec56ec5691 100644
--- a/src/java.base/share/native/libzip/zlib/deflate.c
+++ b/src/java.base/share/native/libzip/zlib/deflate.c
@@ -23,7 +23,7 @@
  */
 
 /* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -61,7 +61,7 @@
  *  REFERENCES
  *
  *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- *      Available in http://tools.ietf.org/html/rfc1951
+ *      Available at https://datatracker.ietf.org/doc/html/rfc1951
  *
  *      A description of the Rabin and Karp algorithm is given in the book
  *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
@@ -76,7 +76,7 @@
 #include "deflate.h"
 
 const char deflate_copyright[] =
-   " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
+   " deflate 1.3.2 Copyright 1995-2026 Jean-loup Gailly and Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -194,8 +194,8 @@ local const config configuration_table[10] = {
 #define CLEAR_HASH(s) \
     do { \
         s->head[s->hash_size - 1] = NIL; \
-        zmemzero((Bytef *)s->head, \
-                 (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \
+        zmemzero(s->head, (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \
+        s->slid = 0; \
     } while (0)
 
 /* ===========================================================================
@@ -219,8 +219,8 @@ local void slide_hash(deflate_state *s) {
         m = *--p;
         *p = (Pos)(m >= wsize ? m - wsize : NIL);
     } while (--n);
-    n = wsize;
 #ifndef FASTEST
+    n = wsize;
     p = &s->prev[n];
     do {
         m = *--p;
@@ -230,6 +230,7 @@ local void slide_hash(deflate_state *s) {
          */
     } while (--n);
 #endif
+    s->slid = 1;
 }
 
 /* ===========================================================================
@@ -283,7 +284,14 @@ local void fill_window(deflate_state *s) {
         more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
 
         /* Deal with !@#$% 64K limit: */
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4127)
+#endif
         if (sizeof(int) <= 2) {
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
             if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
                 more = wsize;
 
@@ -455,6 +463,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
     if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */
     s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
     if (s == Z_NULL) return Z_MEM_ERROR;
+    zmemzero(s, sizeof(deflate_state));
     strm->state = (struct internal_state FAR *)s;
     s->strm = strm;
     s->status = INIT_STATE;     /* to pass state test in deflateReset() */
@@ -736,10 +745,23 @@ int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) {
 /* ========================================================================= */
 int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
     if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
-    if (pending != Z_NULL)
-        *pending = strm->state->pending;
     if (bits != Z_NULL)
         *bits = strm->state->bi_valid;
+    if (pending != Z_NULL) {
+        *pending = (unsigned)strm->state->pending;
+        if (*pending != strm->state->pending) {
+            *pending = (unsigned)-1;
+            return Z_BUF_ERROR;
+        }
+    }
+    return Z_OK;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
+    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
+    if (bits != Z_NULL)
+        *bits = strm->state->bi_used;
     return Z_OK;
 }
 
@@ -855,28 +877,34 @@ int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
  *
  * Shifts are used to approximate divisions, for speed.
  */
-uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
+z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen) {
     deflate_state *s;
-    uLong fixedlen, storelen, wraplen;
+    z_size_t fixedlen, storelen, wraplen, bound;
 
     /* upper bound for fixed blocks with 9-bit literals and length 255
        (memLevel == 2, which is the lowest that may not use stored blocks) --
        ~13% overhead plus a small constant */
     fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
                (sourceLen >> 9) + 4;
+    if (fixedlen < sourceLen)
+        fixedlen = (z_size_t)-1;
 
     /* upper bound for stored blocks with length 127 (memLevel == 1) --
        ~4% overhead plus a small constant */
     storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
                (sourceLen >> 11) + 7;
+    if (storelen < sourceLen)
+        storelen = (z_size_t)-1;
 
-    /* if can't get parameters, return larger bound plus a zlib wrapper */
-    if (deflateStateCheck(strm))
-        return (fixedlen > storelen ? fixedlen : storelen) + 6;
+    /* if can't get parameters, return larger bound plus a wrapper */
+    if (deflateStateCheck(strm)) {
+        bound = fixedlen > storelen ? fixedlen : storelen;
+        return bound + 18 < bound ? (z_size_t)-1 : bound + 18;
+    }
 
     /* compute wrapper length */
     s = strm->state;
-    switch (s->wrap) {
+    switch (s->wrap < 0 ? -s->wrap : s->wrap) {
     case 0:                                 /* raw deflate */
         wraplen = 0;
         break;
@@ -906,18 +934,25 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
         break;
 #endif
     default:                                /* for compiler happiness */
-        wraplen = 6;
+        wraplen = 18;
     }
 
     /* if not default parameters, return one of the conservative bounds */
-    if (s->w_bits != 15 || s->hash_bits != 8 + 7)
-        return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
-               wraplen;
+    if (s->w_bits != 15 || s->hash_bits != 8 + 7) {
+        bound = s->w_bits <= s->hash_bits && s->level ? fixedlen :
+                                                        storelen;
+        return bound + wraplen < bound ? (z_size_t)-1 : bound + wraplen;
+    }
 
     /* default settings: return tight bound for that case -- ~0.03% overhead
        plus a small constant */
-    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
-           (sourceLen >> 25) + 13 - 6 + wraplen;
+    bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+            (sourceLen >> 25) + 13 - 6 + wraplen;
+    return bound < sourceLen ? (z_size_t)-1 : bound;
+}
+uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
+    z_size_t bound = deflateBound_z(strm, sourceLen);
+    return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
 }
 
 /* =========================================================================
@@ -941,8 +976,8 @@ local void flush_pending(z_streamp strm) {
     deflate_state *s = strm->state;
 
     _tr_flush_bits(s);
-    len = s->pending;
-    if (len > strm->avail_out) len = strm->avail_out;
+    len = s->pending > strm->avail_out ? strm->avail_out :
+                                         (unsigned)s->pending;
     if (len == 0) return;
 
     zmemcpy(strm->next_out, s->pending_out, len);
@@ -962,8 +997,8 @@ local void flush_pending(z_streamp strm) {
 #define HCRC_UPDATE(beg) \
     do { \
         if (s->gzhead->hcrc && s->pending > (beg)) \
-            strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
-                                s->pending - (beg)); \
+            strm->adler = crc32_z(strm->adler, s->pending_buf + (beg), \
+                                  s->pending - (beg)); \
     } while (0)
 
 /* ========================================================================= */
@@ -1097,8 +1132,8 @@ int ZEXPORT deflate(z_streamp strm, int flush) {
                 put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
             }
             if (s->gzhead->hcrc)
-                strm->adler = crc32(strm->adler, s->pending_buf,
-                                    s->pending);
+                strm->adler = crc32_z(strm->adler, s->pending_buf,
+                                      s->pending);
             s->gzindex = 0;
             s->status = EXTRA_STATE;
         }
@@ -1106,9 +1141,9 @@ int ZEXPORT deflate(z_streamp strm, int flush) {
     if (s->status == EXTRA_STATE) {
         if (s->gzhead->extra != Z_NULL) {
             ulg beg = s->pending;   /* start of bytes to update crc */
-            uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
+            ulg left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
             while (s->pending + left > s->pending_buf_size) {
-                uInt copy = s->pending_buf_size - s->pending;
+                ulg copy = s->pending_buf_size - s->pending;
                 zmemcpy(s->pending_buf + s->pending,
                         s->gzhead->extra + s->gzindex, copy);
                 s->pending = s->pending_buf_size;
@@ -1319,12 +1354,13 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
 
     ss = source->state;
 
-    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
+    zmemcpy(dest, source, sizeof(z_stream));
 
     ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
     if (ds == Z_NULL) return Z_MEM_ERROR;
+    zmemzero(ds, sizeof(deflate_state));
     dest->state = (struct internal_state FAR *) ds;
-    zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
+    zmemcpy(ds, ss, sizeof(deflate_state));
     ds->strm = dest;
 
     ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
@@ -1337,18 +1373,23 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
         deflateEnd (dest);
         return Z_MEM_ERROR;
     }
-    /* following zmemcpy do not work for 16-bit MSDOS */
-    zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
-    zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
-    zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
-    zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
+    /* following zmemcpy's do not work for 16-bit MSDOS */
+    zmemcpy(ds->window, ss->window, ss->high_water);
+    zmemcpy(ds->prev, ss->prev,
+            (ss->slid || ss->strstart - ss->insert > ds->w_size ? ds->w_size :
+                ss->strstart - ss->insert) * sizeof(Pos));
+    zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
 
     ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
+    zmemcpy(ds->pending_out, ss->pending_out, ss->pending);
 #ifdef LIT_MEM
     ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
     ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
+    zmemcpy(ds->d_buf, ss->d_buf, ss->sym_next * sizeof(ush));
+    zmemcpy(ds->l_buf, ss->l_buf, ss->sym_next);
 #else
     ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
+    zmemcpy(ds->sym_buf, ss->sym_buf, ss->sym_next);
 #endif
 
     ds->l_desc.dyn_tree = ds->dyn_ltree;
@@ -1371,9 +1412,9 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
  */
 local uInt longest_match(deflate_state *s, IPos cur_match) {
     unsigned chain_length = s->max_chain_length;/* max hash chain length */
-    register Bytef *scan = s->window + s->strstart; /* current string */
-    register Bytef *match;                      /* matched string */
-    register int len;                           /* length of current match */
+    Bytef *scan = s->window + s->strstart;      /* current string */
+    Bytef *match;                               /* matched string */
+    int len;                                    /* length of current match */
     int best_len = (int)s->prev_length;         /* best match length so far */
     int nice_match = s->nice_match;             /* stop if match long enough */
     IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
@@ -1388,13 +1429,13 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
     /* Compare two bytes at a time. Note: this is not always beneficial.
      * Try with and without -DUNALIGNED_OK to check.
      */
-    register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
-    register ush scan_start = *(ushf*)scan;
-    register ush scan_end   = *(ushf*)(scan + best_len - 1);
+    Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
+    ush scan_start = *(ushf*)scan;
+    ush scan_end   = *(ushf*)(scan + best_len - 1);
 #else
-    register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-    register Byte scan_end1  = scan[best_len - 1];
-    register Byte scan_end   = scan[best_len];
+    Bytef *strend = s->window + s->strstart + MAX_MATCH;
+    Byte scan_end1  = scan[best_len - 1];
+    Byte scan_end   = scan[best_len];
 #endif
 
     /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
@@ -1518,10 +1559,10 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
  * Optimized version for FASTEST only
  */
 local uInt longest_match(deflate_state *s, IPos cur_match) {
-    register Bytef *scan = s->window + s->strstart; /* current string */
-    register Bytef *match;                       /* matched string */
-    register int len;                           /* length of current match */
-    register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+    Bytef *scan = s->window + s->strstart;      /* current string */
+    Bytef *match;                               /* matched string */
+    int len;                                    /* length of current match */
+    Bytef *strend = s->window + s->strstart + MAX_MATCH;
 
     /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
      * It is easy to get rid of this optimization if necessary.
@@ -1581,7 +1622,7 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
 local void check_match(deflate_state *s, IPos start, IPos match, int length) {
     /* check that the match is indeed a match */
     Bytef *back = s->window + (int)match, *here = s->window + start;
-    IPos len = length;
+    IPos len = (IPos)length;
     if (match == (IPos)-1) {
         /* match starts one byte before the current window -- just compare the
            subsequent length-1 bytes */
@@ -1653,13 +1694,14 @@ local block_state deflate_stored(deflate_state *s, int flush) {
      * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
      * large input and output buffers, the stored block size will be larger.
      */
-    unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
+    unsigned min_block = (unsigned)(MIN(s->pending_buf_size - 5, s->w_size));
 
     /* Copy as many min_block or larger stored blocks directly to next_out as
      * possible. If flushing, copy the remaining available input to next_out as
      * stored blocks, if there is enough space.
      */
-    unsigned len, left, have, last = 0;
+    int last = 0;
+    unsigned len, left, have;
     unsigned used = s->strm->avail_in;
     do {
         /* Set len to the maximum size block that we can copy directly with the
@@ -1667,12 +1709,12 @@ local block_state deflate_stored(deflate_state *s, int flush) {
          * would be copied from what's left in the window.
          */
         len = MAX_STORED;       /* maximum deflate stored block length */
-        have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
+        have = ((unsigned)s->bi_valid + 42) >> 3;   /* bytes in header */
         if (s->strm->avail_out < have)          /* need room for header */
             break;
             /* maximum stored block length that will fit in avail_out: */
         have = s->strm->avail_out - have;
-        left = s->strstart - s->block_start;    /* bytes left in window */
+        left = (unsigned)(s->strstart - s->block_start);    /* window bytes */
         if (len > (ulg)left + s->strm->avail_in)
             len = left + s->strm->avail_in;     /* limit len to the input */
         if (len > have)
@@ -1695,10 +1737,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
         _tr_stored_block(s, (char *)0, 0L, last);
 
         /* Replace the lengths in the dummy stored block with len. */
-        s->pending_buf[s->pending - 4] = len;
-        s->pending_buf[s->pending - 3] = len >> 8;
-        s->pending_buf[s->pending - 2] = ~len;
-        s->pending_buf[s->pending - 1] = ~len >> 8;
+        s->pending_buf[s->pending - 4] = (Bytef)len;
+        s->pending_buf[s->pending - 3] = (Bytef)(len >> 8);
+        s->pending_buf[s->pending - 2] = (Bytef)~len;
+        s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8);
 
         /* Write the stored block header bytes. */
         flush_pending(s->strm);
@@ -1769,8 +1811,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
         s->high_water = s->strstart;
 
     /* If the last block was written to next_out, then done. */
-    if (last)
+    if (last) {
+        s->bi_used = 8;
         return finish_done;
+    }
 
     /* If flushing and all input has been consumed, then done. */
     if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
@@ -1778,7 +1822,7 @@ local block_state deflate_stored(deflate_state *s, int flush) {
         return block_done;
 
     /* Fill the window with any remaining input. */
-    have = s->window_size - s->strstart;
+    have = (unsigned)(s->window_size - s->strstart);
     if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
         /* Slide the window down. */
         s->block_start -= s->w_size;
@@ -1805,11 +1849,11 @@ local block_state deflate_stored(deflate_state *s, int flush) {
      * have enough input for a worthy block, or if flushing and there is enough
      * room for the remaining input as a stored block in the pending buffer.
      */
-    have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
+    have = ((unsigned)s->bi_valid + 42) >> 3;   /* bytes in header */
         /* maximum stored block length that will fit in pending: */
-    have = MIN(s->pending_buf_size - have, MAX_STORED);
+    have = (unsigned)MIN(s->pending_buf_size - have, MAX_STORED);
     min_block = MIN(have, s->w_size);
-    left = s->strstart - s->block_start;
+    left = (unsigned)(s->strstart - s->block_start);
     if (left >= min_block ||
         ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
          s->strm->avail_in == 0 && left <= have)) {
@@ -1822,6 +1866,8 @@ local block_state deflate_stored(deflate_state *s, int flush) {
     }
 
     /* We've done all we can with the available input and output. */
+    if (last)
+        s->bi_used = 8;
     return last ? finish_started : need_more;
 }
 
@@ -1870,7 +1916,7 @@ local block_state deflate_fast(deflate_state *s, int flush) {
             /* longest_match() sets match_start */
         }
         if (s->match_length >= MIN_MATCH) {
-            check_match(s, s->strstart, s->match_start, s->match_length);
+            check_match(s, s->strstart, s->match_start, (int)s->match_length);
 
             _tr_tally_dist(s, s->strstart - s->match_start,
                            s->match_length - MIN_MATCH, bflush);
@@ -1992,7 +2038,7 @@ local block_state deflate_slow(deflate_state *s, int flush) {
             uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
             /* Do not insert strings in hash table beyond this. */
 
-            check_match(s, s->strstart - 1, s->prev_match, s->prev_length);
+            check_match(s, s->strstart - 1, s->prev_match, (int)s->prev_length);
 
             _tr_tally_dist(s, s->strstart - 1 - s->prev_match,
                            s->prev_length - MIN_MATCH, bflush);
@@ -2100,7 +2146,7 @@ local block_state deflate_rle(deflate_state *s, int flush) {
 
         /* Emit match if have run of MIN_MATCH or longer, else emit literal */
         if (s->match_length >= MIN_MATCH) {
-            check_match(s, s->strstart, s->strstart - 1, s->match_length);
+            check_match(s, s->strstart, s->strstart - 1, (int)s->match_length);
 
             _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
 
diff --git a/src/java.base/share/native/libzip/zlib/deflate.h b/src/java.base/share/native/libzip/zlib/deflate.h
index 830d46b8894..5b6246ee3c4 100644
--- a/src/java.base/share/native/libzip/zlib/deflate.h
+++ b/src/java.base/share/native/libzip/zlib/deflate.h
@@ -23,7 +23,7 @@
  */
 
 /* deflate.h -- internal compression state
- * Copyright (C) 1995-2024 Jean-loup Gailly
+ * Copyright (C) 1995-2026 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -295,6 +295,9 @@ typedef struct internal_state {
     /* Number of valid bits in bi_buf.  All bits above the last valid bit
      * are always zero.
      */
+    int bi_used;
+    /* Last number of used bits when going to a byte boundary.
+     */
 
     ulg high_water;
     /* High water mark offset in window for initialized bytes -- bytes above
@@ -303,6 +306,9 @@ typedef struct internal_state {
      * updated to the new high water mark.
      */
 
+    int slid;
+    /* True if the hash table has been slid since it was cleared. */
+
 } FAR deflate_state;
 
 /* Output a byte on the stream.
diff --git a/src/java.base/share/native/libzip/zlib/gzguts.h b/src/java.base/share/native/libzip/zlib/gzguts.h
index 8cce2c69d24..0be646016ed 100644
--- a/src/java.base/share/native/libzip/zlib/gzguts.h
+++ b/src/java.base/share/native/libzip/zlib/gzguts.h
@@ -23,7 +23,7 @@
  */
 
 /* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004-2024 Mark Adler
+ * Copyright (C) 2004-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -41,6 +41,18 @@
 #  define ZLIB_INTERNAL
 #endif
 
+#if defined(_WIN32)
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  ifndef _CRT_SECURE_NO_WARNINGS
+#    define _CRT_SECURE_NO_WARNINGS
+#  endif
+#  ifndef _CRT_NONSTDC_NO_DEPRECATE
+#    define _CRT_NONSTDC_NO_DEPRECATE
+#  endif
+#endif
+
 #include 
 #include "zlib.h"
 #ifdef STDC
@@ -49,8 +61,8 @@
 #  include 
 #endif
 
-#ifndef _POSIX_SOURCE
-#  define _POSIX_SOURCE
+#ifndef _POSIX_C_SOURCE
+#  define _POSIX_C_SOURCE 200112L
 #endif
 #include 
 
@@ -60,19 +72,13 @@
 
 #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
 #  include 
+#  include 
 #endif
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(WIDECHAR)
 #  define WIDECHAR
 #endif
 
-#ifdef WINAPI_FAMILY
-#  define open _open
-#  define read _read
-#  define write _write
-#  define close _close
-#endif
-
 #ifdef NO_DEFLATE       /* for compatibility with old definition */
 #  define NO_GZCOMPRESS
 #endif
@@ -96,33 +102,28 @@
 #endif
 
 #ifndef HAVE_VSNPRINTF
-#  ifdef MSDOS
+#  if !defined(NO_vsnprintf) && \
+      (defined(MSDOS) || defined(__TURBOC__) || defined(__SASC) || \
+       defined(VMS) || defined(__OS400) || defined(__MVS__))
 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
    but for now we just assume it doesn't. */
 #    define NO_vsnprintf
 #  endif
-#  ifdef __TURBOC__
-#    define NO_vsnprintf
-#  endif
 #  ifdef WIN32
 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
-#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
-#         define vsnprintf _vsnprintf
+#    if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+#      ifndef vsnprintf
+#        define vsnprintf _vsnprintf
 #      endif
 #    endif
-#  endif
-#  ifdef __SASC
-#    define NO_vsnprintf
-#  endif
-#  ifdef VMS
-#    define NO_vsnprintf
-#  endif
-#  ifdef __OS400__
-#    define NO_vsnprintf
-#  endif
-#  ifdef __MVS__
-#    define NO_vsnprintf
+#  elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
+/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
+#    ifndef NO_snprintf
+#      define NO_snprintf
+#    endif
+#    ifndef NO_vsnprintf
+#      define NO_vsnprintf
+#    endif
 #  endif
 #endif
 
@@ -206,7 +207,9 @@ typedef struct {
     unsigned char *out;     /* output buffer (double-sized when reading) */
     int direct;             /* 0 if processing gzip, 1 if transparent */
         /* just for reading */
+    int junk;               /* -1 = start, 1 = junk candidate, 0 = in gzip */
     int how;                /* 0: get header, 1: copy, 2: decompress */
+    int again;              /* true if EAGAIN or EWOULDBLOCK on last i/o */
     z_off64_t start;        /* where the gzip data started, for rewinding */
     int eof;                /* true if end of input file reached */
     int past;               /* true if read requested past end */
@@ -216,7 +219,6 @@ typedef struct {
     int reset;              /* true if a reset is pending after a Z_FINISH */
         /* seek request */
     z_off64_t skip;         /* amount to skip (already rewound if backwards) */
-    int seek;               /* true if seek request pending */
         /* error information */
     int err;                /* error code */
     char *msg;              /* error message */
diff --git a/src/java.base/share/native/libzip/zlib/gzlib.c b/src/java.base/share/native/libzip/zlib/gzlib.c
index 0f4dfae64a0..9489bcc1f12 100644
--- a/src/java.base/share/native/libzip/zlib/gzlib.c
+++ b/src/java.base/share/native/libzip/zlib/gzlib.c
@@ -23,21 +23,21 @@
  */
 
 /* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004-2024 Mark Adler
+ * Copyright (C) 2004-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
 #include "gzguts.h"
 
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(__DJGPP__)
+#  define LSEEK llseek
+#elif defined(_WIN32) && !defined(__BORLANDC__) && !defined(UNDER_CE)
 #  define LSEEK _lseeki64
-#else
-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
 #  define LSEEK lseek64
 #else
 #  define LSEEK lseek
 #endif
-#endif
 
 #if defined UNDER_CE
 
@@ -76,7 +76,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
             msgbuf[chars] = 0;
         }
 
-        wcstombs(buf, msgbuf, chars + 1);
+        wcstombs(buf, msgbuf, chars + 1);       /* assumes buf is big enough */
         LocalFree(msgbuf);
     }
     else {
@@ -96,10 +96,12 @@ local void gz_reset(gz_statep state) {
         state->eof = 0;             /* not at end of file */
         state->past = 0;            /* have not read past end yet */
         state->how = LOOK;          /* look for gzip header */
+        state->junk = -1;           /* mark first member */
     }
     else                            /* for writing ... */
         state->reset = 0;           /* no deflateReset pending */
-    state->seek = 0;                /* no seek request pending */
+    state->again = 0;               /* no stalled i/o yet */
+    state->skip = 0;                /* no seek request pending */
     gz_error(state, Z_OK, NULL);    /* clear error */
     state->x.pos = 0;               /* no uncompressed data yet */
     state->strm.avail_in = 0;       /* no input data yet */
@@ -109,16 +111,13 @@ local void gz_reset(gz_statep state) {
 local gzFile gz_open(const void *path, int fd, const char *mode) {
     gz_statep state;
     z_size_t len;
-    int oflag;
-#ifdef O_CLOEXEC
-    int cloexec = 0;
-#endif
+    int oflag = 0;
 #ifdef O_EXCL
     int exclusive = 0;
 #endif
 
     /* check input */
-    if (path == NULL)
+    if (path == NULL || mode == NULL)
         return NULL;
 
     /* allocate gzFile structure to return */
@@ -127,6 +126,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
         return NULL;
     state->size = 0;            /* no buffers allocated yet */
     state->want = GZBUFSIZE;    /* requested buffer size */
+    state->err = Z_OK;          /* no error yet */
     state->msg = NULL;          /* no error message yet */
 
     /* interpret mode */
@@ -157,7 +157,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
                 break;
 #ifdef O_CLOEXEC
             case 'e':
-                cloexec = 1;
+                oflag |= O_CLOEXEC;
                 break;
 #endif
 #ifdef O_EXCL
@@ -177,6 +177,14 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
             case 'F':
                 state->strategy = Z_FIXED;
                 break;
+            case 'G':
+                state->direct = -1;
+                break;
+#ifdef O_NONBLOCK
+            case 'N':
+                oflag |= O_NONBLOCK;
+                break;
+#endif
             case 'T':
                 state->direct = 1;
                 break;
@@ -192,22 +200,30 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
         return NULL;
     }
 
-    /* can't force transparent read */
+    /* direct is 0, 1 if "T", or -1 if "G" (last "G" or "T" wins) */
     if (state->mode == GZ_READ) {
-        if (state->direct) {
+        if (state->direct == 1) {
+            /* can't force a transparent read */
             free(state);
             return NULL;
         }
-        state->direct = 1;      /* for empty file */
+        if (state->direct == 0)
+            /* default when reading is auto-detect of gzip vs. transparent --
+               start with a transparent assumption in case of an empty file */
+            state->direct = 1;
     }
+    else if (state->direct == -1) {
+        /* "G" has no meaning when writing -- disallow it */
+        free(state);
+        return NULL;
+    }
+    /* if reading, direct == 1 for auto-detect, -1 for gzip only; if writing or
+       appending, direct == 0 for gzip, 1 for transparent (copy in to out) */
 
     /* save the path name for error messages */
 #ifdef WIDECHAR
-    if (fd == -2) {
+    if (fd == -2)
         len = wcstombs(NULL, path, 0);
-        if (len == (z_size_t)-1)
-            len = 0;
-    }
     else
 #endif
         len = strlen((const char *)path);
@@ -217,29 +233,29 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
         return NULL;
     }
 #ifdef WIDECHAR
-    if (fd == -2)
+    if (fd == -2) {
         if (len)
             wcstombs(state->path, path, len + 1);
         else
             *(state->path) = 0;
+    }
     else
 #endif
+    {
 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
         (void)snprintf(state->path, len + 1, "%s", (const char *)path);
 #else
         strcpy(state->path, path);
 #endif
+    }
 
     /* compute the flags for open() */
-    oflag =
+    oflag |=
 #ifdef O_LARGEFILE
         O_LARGEFILE |
 #endif
 #ifdef O_BINARY
         O_BINARY |
-#endif
-#ifdef O_CLOEXEC
-        (cloexec ? O_CLOEXEC : 0) |
 #endif
         (state->mode == GZ_READ ?
          O_RDONLY :
@@ -252,11 +268,23 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
            O_APPEND)));
 
     /* open the file with the appropriate flags (or just use fd) */
-    state->fd = fd > -1 ? fd : (
+    if (fd == -1)
+        state->fd = open((const char *)path, oflag, 0666);
 #ifdef WIDECHAR
-        fd == -2 ? _wopen(path, oflag, 0666) :
+    else if (fd == -2)
+        state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE);
 #endif
-        open((const char *)path, oflag, 0666));
+    else {
+#ifdef O_NONBLOCK
+        if (oflag & O_NONBLOCK)
+            fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+#endif
+#ifdef O_CLOEXEC
+        if (oflag & O_CLOEXEC)
+            fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_CLOEXEC);
+#endif
+        state->fd = fd;
+    }
     if (state->fd == -1) {
         free(state->path);
         free(state);
@@ -383,9 +411,10 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
     /* normalize offset to a SEEK_CUR specification */
     if (whence == SEEK_SET)
         offset -= state->x.pos;
-    else if (state->seek)
-        offset += state->skip;
-    state->seek = 0;
+    else {
+        offset += state->past ? 0 : state->skip;
+        state->skip = 0;
+    }
 
     /* if within raw area while reading, just go there */
     if (state->mode == GZ_READ && state->how == COPY &&
@@ -396,7 +425,7 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
         state->x.have = 0;
         state->eof = 0;
         state->past = 0;
-        state->seek = 0;
+        state->skip = 0;
         gz_error(state, Z_OK, NULL);
         state->strm.avail_in = 0;
         state->x.pos += offset;
@@ -425,10 +454,7 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
     }
 
     /* request skip (if not zero) */
-    if (offset) {
-        state->seek = 1;
-        state->skip = offset;
-    }
+    state->skip = offset;
     return state->x.pos + offset;
 }
 
@@ -452,7 +478,7 @@ z_off64_t ZEXPORT gztell64(gzFile file) {
         return -1;
 
     /* return position */
-    return state->x.pos + (state->seek ? state->skip : 0);
+    return state->x.pos + (state->past ? 0 : state->skip);
 }
 
 /* -- see zlib.h -- */
@@ -559,7 +585,7 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
     }
 
     /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
-    if (err != Z_OK && err != Z_BUF_ERROR)
+    if (err != Z_OK && err != Z_BUF_ERROR && !state->again)
         state->x.have = 0;
 
     /* set error code, and if no message, then done */
@@ -596,6 +622,7 @@ unsigned ZLIB_INTERNAL gz_intmax(void) {
     return INT_MAX;
 #else
     unsigned p = 1, q;
+
     do {
         q = p;
         p <<= 1;
diff --git a/src/java.base/share/native/libzip/zlib/gzread.c b/src/java.base/share/native/libzip/zlib/gzread.c
index 7b9c9df5fa1..89144d2e56f 100644
--- a/src/java.base/share/native/libzip/zlib/gzread.c
+++ b/src/java.base/share/native/libzip/zlib/gzread.c
@@ -23,7 +23,7 @@
  */
 
 /* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004-2017 Mark Adler
+ * Copyright (C) 2004-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -32,23 +32,36 @@
 /* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
    state->fd, and update state->eof, state->err, and state->msg as appropriate.
    This function needs to loop on read(), since read() is not guaranteed to
-   read the number of bytes requested, depending on the type of descriptor. */
+   read the number of bytes requested, depending on the type of descriptor. It
+   also needs to loop to manage the fact that read() returns an int. If the
+   descriptor is non-blocking and read() returns with no data in order to avoid
+   blocking, then gz_load() will return 0 if some data has been read, or -1 if
+   no data has been read. Either way, state->again is set true to indicate a
+   non-blocking event. If errno is non-zero on return, then there was an error
+   signaled from read().  *have is set to the number of bytes read. */
 local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
                   unsigned *have) {
     int ret;
     unsigned get, max = ((unsigned)-1 >> 2) + 1;
 
+    state->again = 0;
+    errno = 0;
     *have = 0;
     do {
         get = len - *have;
         if (get > max)
             get = max;
-        ret = read(state->fd, buf + *have, get);
+        ret = (int)read(state->fd, buf + *have, get);
         if (ret <= 0)
             break;
         *have += (unsigned)ret;
     } while (*have < len);
     if (ret < 0) {
+        if (errno == EAGAIN || errno == EWOULDBLOCK) {
+            state->again = 1;
+            if (*have != 0)
+                return 0;
+        }
         gz_error(state, Z_ERRNO, zstrerror());
         return -1;
     }
@@ -74,10 +87,14 @@ local int gz_avail(gz_statep state) {
         if (strm->avail_in) {       /* copy what's there to the start */
             unsigned char *p = state->in;
             unsigned const char *q = strm->next_in;
-            unsigned n = strm->avail_in;
-            do {
-                *p++ = *q++;
-            } while (--n);
+
+            if (q != p) {
+                unsigned n = strm->avail_in;
+
+                do {
+                    *p++ = *q++;
+                } while (--n);
+            }
         }
         if (gz_load(state, state->in + strm->avail_in,
                     state->size - strm->avail_in, &got) == -1)
@@ -128,39 +145,44 @@ local int gz_look(gz_statep state) {
         }
     }
 
-    /* get at least the magic bytes in the input buffer */
-    if (strm->avail_in < 2) {
-        if (gz_avail(state) == -1)
-            return -1;
-        if (strm->avail_in == 0)
-            return 0;
-    }
-
-    /* look for gzip magic bytes -- if there, do gzip decoding (note: there is
-       a logical dilemma here when considering the case of a partially written
-       gzip file, to wit, if a single 31 byte is written, then we cannot tell
-       whether this is a single-byte file, or just a partially written gzip
-       file -- for here we assume that if a gzip file is being written, then
-       the header will be written in a single operation, so that reading a
-       single byte is sufficient indication that it is not a gzip file) */
-    if (strm->avail_in > 1 &&
-            strm->next_in[0] == 31 && strm->next_in[1] == 139) {
+    /* if transparent reading is disabled, which would only be at the start, or
+       if we're looking for a gzip member after the first one, which is not at
+       the start, then proceed directly to look for a gzip member next */
+    if (state->direct == -1 || state->junk == 0) {
         inflateReset(strm);
         state->how = GZIP;
+        state->junk = state->junk != -1;
         state->direct = 0;
         return 0;
     }
 
-    /* no gzip header -- if we were decoding gzip before, then this is trailing
-       garbage.  Ignore the trailing garbage and finish. */
-    if (state->direct == 0) {
-        strm->avail_in = 0;
-        state->eof = 1;
-        state->x.have = 0;
+    /* otherwise we're at the start with auto-detect -- we check to see if the
+       first four bytes could be gzip header in order to decide whether or not
+       this will be a transparent read */
+
+    /* load any header bytes into the input buffer -- if the input is empty,
+       then it's not an error as this is a transparent read of zero bytes */
+    if (gz_avail(state) == -1)
+        return -1;
+    if (strm->avail_in == 0 || (state->again && strm->avail_in < 4))
+        /* if non-blocking input stalled before getting four bytes, then
+           return and wait until a later call has accumulated enough */
+        return 0;
+
+    /* see if this is (likely) gzip input -- if the first four bytes are
+       consistent with a gzip header, then go look for the first gzip member,
+       otherwise proceed to copy the input transparently */
+    if (strm->avail_in > 3 &&
+            strm->next_in[0] == 31 && strm->next_in[1] == 139 &&
+            strm->next_in[2] == 8 && strm->next_in[3] < 32) {
+        inflateReset(strm);
+        state->how = GZIP;
+        state->junk = 1;
+        state->direct = 0;
         return 0;
     }
 
-    /* doing raw i/o, copy any leftover input to output -- this assumes that
+    /* doing raw i/o: copy any leftover input to output -- this assumes that
        the output buffer is larger than the input buffer, which also assures
        space for gzungetc() */
     state->x.next = state->out;
@@ -168,15 +190,17 @@ local int gz_look(gz_statep state) {
     state->x.have = strm->avail_in;
     strm->avail_in = 0;
     state->how = COPY;
-    state->direct = 1;
     return 0;
 }
 
 /* Decompress from input to the provided next_out and avail_out in the state.
    On return, state->x.have and state->x.next point to the just decompressed
-   data.  If the gzip stream completes, state->how is reset to LOOK to look for
-   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
-   on success, -1 on failure. */
+   data. If the gzip stream completes, state->how is reset to LOOK to look for
+   the next gzip stream or raw data, once state->x.have is depleted. Returns 0
+   on success, -1 on failure. If EOF is reached when looking for more input to
+   complete the gzip member, then an unexpected end of file error is raised.
+   If there is no more input, but state->again is true, then EOF has not been
+   reached, and no error is raised. */
 local int gz_decomp(gz_statep state) {
     int ret = Z_OK;
     unsigned had;
@@ -186,28 +210,41 @@ local int gz_decomp(gz_statep state) {
     had = strm->avail_out;
     do {
         /* get more input for inflate() */
-        if (strm->avail_in == 0 && gz_avail(state) == -1)
-            return -1;
+        if (strm->avail_in == 0 && gz_avail(state) == -1) {
+            ret = state->err;
+            break;
+        }
         if (strm->avail_in == 0) {
-            gz_error(state, Z_BUF_ERROR, "unexpected end of file");
+            if (!state->again)
+                gz_error(state, Z_BUF_ERROR, "unexpected end of file");
             break;
         }
 
         /* decompress and handle errors */
         ret = inflate(strm, Z_NO_FLUSH);
+        if (strm->avail_out < had)
+            /* any decompressed data marks this as a real gzip stream */
+            state->junk = 0;
         if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
             gz_error(state, Z_STREAM_ERROR,
                      "internal error: inflate stream corrupt");
-            return -1;
+            break;
         }
         if (ret == Z_MEM_ERROR) {
             gz_error(state, Z_MEM_ERROR, "out of memory");
-            return -1;
+            break;
         }
         if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
+            if (state->junk == 1) {             /* trailing garbage is ok */
+                strm->avail_in = 0;
+                state->eof = 1;
+                state->how = LOOK;
+                ret = Z_OK;
+                break;
+            }
             gz_error(state, Z_DATA_ERROR,
                      strm->msg == NULL ? "compressed data error" : strm->msg);
-            return -1;
+            break;
         }
     } while (strm->avail_out && ret != Z_STREAM_END);
 
@@ -216,11 +253,14 @@ local int gz_decomp(gz_statep state) {
     state->x.next = strm->next_out - state->x.have;
 
     /* if the gzip stream completed successfully, look for another */
-    if (ret == Z_STREAM_END)
+    if (ret == Z_STREAM_END) {
+        state->junk = 0;
         state->how = LOOK;
+        return 0;
+    }
 
-    /* good decompression */
-    return 0;
+    /* return decompression status */
+    return ret != Z_OK ? -1 : 0;
 }
 
 /* Fetch data and put it in the output buffer.  Assumes state->x.have is 0.
@@ -251,25 +291,31 @@ local int gz_fetch(gz_statep state) {
             strm->next_out = state->out;
             if (gz_decomp(state) == -1)
                 return -1;
+            break;
+        default:
+            gz_error(state, Z_STREAM_ERROR, "state corrupt");
+            return -1;
         }
     } while (state->x.have == 0 && (!state->eof || strm->avail_in));
     return 0;
 }
 
-/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
-local int gz_skip(gz_statep state, z_off64_t len) {
+/* Skip state->skip (> 0) uncompressed bytes of output.  Return -1 on error, 0
+   on success. */
+local int gz_skip(gz_statep state) {
     unsigned n;
 
     /* skip over len bytes or reach end-of-file, whichever comes first */
-    while (len)
+    do {
         /* skip over whatever is in output buffer */
         if (state->x.have) {
-            n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
-                (unsigned)len : state->x.have;
+            n = GT_OFF(state->x.have) ||
+                (z_off64_t)state->x.have > state->skip ?
+                (unsigned)state->skip : state->x.have;
             state->x.have -= n;
             state->x.next += n;
             state->x.pos += n;
-            len -= n;
+            state->skip -= n;
         }
 
         /* output buffer empty -- return if we're at the end of the input */
@@ -282,30 +328,32 @@ local int gz_skip(gz_statep state, z_off64_t len) {
             if (gz_fetch(state) == -1)
                 return -1;
         }
+    } while (state->skip);
     return 0;
 }
 
 /* Read len bytes into buf from file, or less than len up to the end of the
-   input.  Return the number of bytes read.  If zero is returned, either the
-   end of file was reached, or there was an error.  state->err must be
-   consulted in that case to determine which. */
+   input. Return the number of bytes read. If zero is returned, either the end
+   of file was reached, or there was an error. state->err must be consulted in
+   that case to determine which. If there was an error, but some uncompressed
+   bytes were read before the error, then that count is returned. The error is
+   still recorded, and so is deferred until the next call. */
 local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
     z_size_t got;
     unsigned n;
+    int err;
 
     /* if len is zero, avoid unnecessary operations */
     if (len == 0)
         return 0;
 
     /* process a skip request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_skip(state, state->skip) == -1)
-            return 0;
-    }
+    if (state->skip && gz_skip(state) == -1)
+        return 0;
 
     /* get len bytes to buf, or less than len if at the end */
     got = 0;
+    err = 0;
     do {
         /* set n to the maximum amount of len that fits in an unsigned int */
         n = (unsigned)-1;
@@ -319,37 +367,36 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
             memcpy(buf, state->x.next, n);
             state->x.next += n;
             state->x.have -= n;
+            if (state->err != Z_OK)
+                /* caught deferred error from gz_fetch() */
+                err = -1;
         }
 
         /* output buffer empty -- return if we're at the end of the input */
-        else if (state->eof && state->strm.avail_in == 0) {
-            state->past = 1;        /* tried to read past end */
+        else if (state->eof && state->strm.avail_in == 0)
             break;
-        }
 
         /* need output data -- for small len or new stream load up our output
-           buffer */
+           buffer, so that gzgetc() can be fast */
         else if (state->how == LOOK || n < (state->size << 1)) {
             /* get more output, looking for header if required */
-            if (gz_fetch(state) == -1)
-                return 0;
+            if (gz_fetch(state) == -1 && state->x.have == 0)
+                /* if state->x.have != 0, error will be caught after copy */
+                err = -1;
             continue;       /* no progress yet -- go back to copy above */
             /* the copy above assures that we will leave with space in the
                output buffer, allowing at least one gzungetc() to succeed */
         }
 
         /* large len -- read directly into user buffer */
-        else if (state->how == COPY) {      /* read directly */
-            if (gz_load(state, (unsigned char *)buf, n, &n) == -1)
-                return 0;
-        }
+        else if (state->how == COPY)        /* read directly */
+            err = gz_load(state, (unsigned char *)buf, n, &n);
 
         /* large len -- decompress directly into user buffer */
         else {  /* state->how == GZIP */
             state->strm.avail_out = n;
             state->strm.next_out = (unsigned char *)buf;
-            if (gz_decomp(state) == -1)
-                return 0;
+            err = gz_decomp(state);
             n = state->x.have;
             state->x.have = 0;
         }
@@ -359,7 +406,11 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
         buf = (char *)buf + n;
         got += n;
         state->x.pos += n;
-    } while (len);
+    } while (len && !err);
+
+    /* note read past eof */
+    if (len && state->eof)
+        state->past = 1;
 
     /* return number of bytes read into user buffer */
     return got;
@@ -369,16 +420,18 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
 int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
     gz_statep state;
 
-    /* get internal structure */
+    /* get internal structure and check that it's for reading */
     if (file == NULL)
         return -1;
     state = (gz_statep)file;
-
-    /* check that we're reading and that there's no (serious) error */
-    if (state->mode != GZ_READ ||
-            (state->err != Z_OK && state->err != Z_BUF_ERROR))
+    if (state->mode != GZ_READ)
         return -1;
 
+    /* check that there was no (serious) error */
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+        return -1;
+    gz_error(state, Z_OK, NULL);
+
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids a flaw in the interface) */
     if ((int)len < 0) {
@@ -390,28 +443,40 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
     len = (unsigned)gz_read(state, buf, len);
 
     /* check for an error */
-    if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
-        return -1;
+    if (len == 0) {
+        if (state->err != Z_OK && state->err != Z_BUF_ERROR)
+            return -1;
+        if (state->again) {
+            /* non-blocking input stalled after some input was read, but no
+               uncompressed bytes were produced -- let the application know
+               this isn't EOF */
+            gz_error(state, Z_ERRNO, zstrerror());
+            return -1;
+        }
+    }
 
-    /* return the number of bytes read (this is assured to fit in an int) */
+    /* return the number of bytes read */
     return (int)len;
 }
 
 /* -- see zlib.h -- */
-z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
+z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
+                         gzFile file) {
     z_size_t len;
     gz_statep state;
 
-    /* get internal structure */
+    /* get internal structure and check that it's for reading */
     if (file == NULL)
         return 0;
     state = (gz_statep)file;
-
-    /* check that we're reading and that there's no (serious) error */
-    if (state->mode != GZ_READ ||
-            (state->err != Z_OK && state->err != Z_BUF_ERROR))
+    if (state->mode != GZ_READ)
         return 0;
 
+    /* check that there was no (serious) error */
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+        return 0;
+    gz_error(state, Z_OK, NULL);
+
     /* compute bytes to read -- error on overflow */
     len = nitems * size;
     if (size && len / size != nitems) {
@@ -433,16 +498,18 @@ int ZEXPORT gzgetc(gzFile file) {
     unsigned char buf[1];
     gz_statep state;
 
-    /* get internal structure */
+    /* get internal structure and check that it's for reading */
     if (file == NULL)
         return -1;
     state = (gz_statep)file;
-
-    /* check that we're reading and that there's no (serious) error */
-    if (state->mode != GZ_READ ||
-        (state->err != Z_OK && state->err != Z_BUF_ERROR))
+    if (state->mode != GZ_READ)
         return -1;
 
+    /* check that there was no (serious) error */
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+        return -1;
+    gz_error(state, Z_OK, NULL);
+
     /* try output buffer (no need to check for skip request) */
     if (state->x.have) {
         state->x.have--;
@@ -462,26 +529,25 @@ int ZEXPORT gzgetc_(gzFile file) {
 int ZEXPORT gzungetc(int c, gzFile file) {
     gz_statep state;
 
-    /* get internal structure */
+    /* get internal structure and check that it's for reading */
     if (file == NULL)
         return -1;
     state = (gz_statep)file;
-
-    /* in case this was just opened, set up the input buffer */
-    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
-        (void)gz_look(state);
-
-    /* check that we're reading and that there's no (serious) error */
-    if (state->mode != GZ_READ ||
-        (state->err != Z_OK && state->err != Z_BUF_ERROR))
+    if (state->mode != GZ_READ)
         return -1;
 
+    /* in case this was just opened, set up the input buffer */
+    if (state->how == LOOK && state->x.have == 0)
+        (void)gz_look(state);
+
+    /* check that there was no (serious) error */
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+        return -1;
+    gz_error(state, Z_OK, NULL);
+
     /* process a skip request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_skip(state, state->skip) == -1)
-            return -1;
-    }
+    if (state->skip && gz_skip(state) == -1)
+        return -1;
 
     /* can't push EOF */
     if (c < 0)
@@ -507,6 +573,7 @@ int ZEXPORT gzungetc(int c, gzFile file) {
     if (state->x.next == state->out) {
         unsigned char *src = state->out + state->x.have;
         unsigned char *dest = state->out + (state->size << 1);
+
         while (src > state->out)
             *--dest = *--src;
         state->x.next = dest;
@@ -526,32 +593,31 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
     unsigned char *eol;
     gz_statep state;
 
-    /* check parameters and get internal structure */
+    /* check parameters, get internal structure, and check that it's for
+       reading */
     if (file == NULL || buf == NULL || len < 1)
         return NULL;
     state = (gz_statep)file;
-
-    /* check that we're reading and that there's no (serious) error */
-    if (state->mode != GZ_READ ||
-        (state->err != Z_OK && state->err != Z_BUF_ERROR))
+    if (state->mode != GZ_READ)
         return NULL;
 
-    /* process a skip request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_skip(state, state->skip) == -1)
-            return NULL;
-    }
+    /* check that there was no (serious) error */
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+        return NULL;
+    gz_error(state, Z_OK, NULL);
 
-    /* copy output bytes up to new line or len - 1, whichever comes first --
-       append a terminating zero to the string (we don't check for a zero in
-       the contents, let the user worry about that) */
+    /* process a skip request */
+    if (state->skip && gz_skip(state) == -1)
+        return NULL;
+
+    /* copy output up to a new line, len-1 bytes, or there is no more output,
+       whichever comes first */
     str = buf;
     left = (unsigned)len - 1;
     if (left) do {
         /* assure that something is in the output buffer */
         if (state->x.have == 0 && gz_fetch(state) == -1)
-            return NULL;                /* error */
+            break;                      /* error */
         if (state->x.have == 0) {       /* end of file */
             state->past = 1;            /* read past end */
             break;                      /* return what we have */
@@ -572,7 +638,9 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
         buf += n;
     } while (left && eol == NULL);
 
-    /* return terminated string, or if nothing, end of file */
+    /* append a terminating zero to the string (we don't check for a zero in
+       the contents, let the user worry about that) -- return the terminated
+       string, or if nothing was read, NULL */
     if (buf == str)
         return NULL;
     buf[0] = 0;
@@ -594,7 +662,7 @@ int ZEXPORT gzdirect(gzFile file) {
         (void)gz_look(state);
 
     /* return 1 if transparent, 0 if processing a gzip stream */
-    return state->direct;
+    return state->direct == 1;
 }
 
 /* -- see zlib.h -- */
@@ -602,12 +670,10 @@ int ZEXPORT gzclose_r(gzFile file) {
     int ret, err;
     gz_statep state;
 
-    /* get internal structure */
+    /* get internal structure and check that it's for reading */
     if (file == NULL)
         return Z_STREAM_ERROR;
     state = (gz_statep)file;
-
-    /* check that we're reading */
     if (state->mode != GZ_READ)
         return Z_STREAM_ERROR;
 
diff --git a/src/java.base/share/native/libzip/zlib/gzwrite.c b/src/java.base/share/native/libzip/zlib/gzwrite.c
index 008b03e7021..b11c318d543 100644
--- a/src/java.base/share/native/libzip/zlib/gzwrite.c
+++ b/src/java.base/share/native/libzip/zlib/gzwrite.c
@@ -23,7 +23,7 @@
  */
 
 /* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004-2019 Mark Adler
+ * Copyright (C) 2004-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -98,9 +98,13 @@ local int gz_comp(gz_statep state, int flush) {
     /* write directly if requested */
     if (state->direct) {
         while (strm->avail_in) {
+            errno = 0;
+            state->again = 0;
             put = strm->avail_in > max ? max : strm->avail_in;
-            writ = write(state->fd, strm->next_in, put);
+            writ = (int)write(state->fd, strm->next_in, put);
             if (writ < 0) {
+                if (errno == EAGAIN || errno == EWOULDBLOCK)
+                    state->again = 1;
                 gz_error(state, Z_ERRNO, zstrerror());
                 return -1;
             }
@@ -112,8 +116,9 @@ local int gz_comp(gz_statep state, int flush) {
 
     /* check for a pending reset */
     if (state->reset) {
-        /* don't start a new gzip member unless there is data to write */
-        if (strm->avail_in == 0)
+        /* don't start a new gzip member unless there is data to write and
+           we're not flushing */
+        if (strm->avail_in == 0 && flush == Z_NO_FLUSH)
             return 0;
         deflateReset(strm);
         state->reset = 0;
@@ -127,10 +132,14 @@ local int gz_comp(gz_statep state, int flush) {
         if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
             (flush != Z_FINISH || ret == Z_STREAM_END))) {
             while (strm->next_out > state->x.next) {
+                errno = 0;
+                state->again = 0;
                 put = strm->next_out - state->x.next > (int)max ? max :
                       (unsigned)(strm->next_out - state->x.next);
-                writ = write(state->fd, state->x.next, put);
+                writ = (int)write(state->fd, state->x.next, put);
                 if (writ < 0) {
+                    if (errno == EAGAIN || errno == EWOULDBLOCK)
+                        state->again = 1;
                     gz_error(state, Z_ERRNO, zstrerror());
                     return -1;
                 }
@@ -162,10 +171,12 @@ local int gz_comp(gz_statep state, int flush) {
     return 0;
 }
 
-/* Compress len zeros to output.  Return -1 on a write error or memory
-   allocation failure by gz_comp(), or 0 on success. */
-local int gz_zero(gz_statep state, z_off64_t len) {
-    int first;
+/* Compress state->skip (> 0) zeros to output.  Return -1 on a write error or
+   memory allocation failure by gz_comp(), or 0 on success. state->skip is
+   updated with the number of successfully written zeros, in case there is a
+   stall on a non-blocking write destination. */
+local int gz_zero(gz_statep state) {
+    int first, ret;
     unsigned n;
     z_streamp strm = &(state->strm);
 
@@ -173,29 +184,34 @@ local int gz_zero(gz_statep state, z_off64_t len) {
     if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
         return -1;
 
-    /* compress len zeros (len guaranteed > 0) */
+    /* compress state->skip zeros */
     first = 1;
-    while (len) {
-        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
-            (unsigned)len : state->size;
+    do {
+        n = GT_OFF(state->size) || (z_off64_t)state->size > state->skip ?
+            (unsigned)state->skip : state->size;
         if (first) {
             memset(state->in, 0, n);
             first = 0;
         }
         strm->avail_in = n;
         strm->next_in = state->in;
+        ret = gz_comp(state, Z_NO_FLUSH);
+        n -= strm->avail_in;
         state->x.pos += n;
-        if (gz_comp(state, Z_NO_FLUSH) == -1)
+        state->skip -= n;
+        if (ret == -1)
             return -1;
-        len -= n;
-    }
+    } while (state->skip);
     return 0;
 }
 
 /* Write len bytes from buf to file.  Return the number of bytes written.  If
-   the returned value is less than len, then there was an error. */
+   the returned value is less than len, then there was an error. If the error
+   was a non-blocking stall, then the number of bytes consumed is returned.
+   For any other error, 0 is returned. */
 local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
     z_size_t put = len;
+    int ret;
 
     /* if len is zero, avoid unnecessary operations */
     if (len == 0)
@@ -206,16 +222,13 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
         return 0;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return 0;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return 0;
 
     /* for small len, copy to input buffer, otherwise compress directly */
     if (len < state->size) {
         /* copy to input buffer, compress when full */
-        do {
+        for (;;) {
             unsigned have, copy;
 
             if (state->strm.avail_in == 0)
@@ -230,9 +243,11 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
             state->x.pos += copy;
             buf = (const char *)buf + copy;
             len -= copy;
-            if (len && gz_comp(state, Z_NO_FLUSH) == -1)
-                return 0;
-        } while (len);
+            if (len == 0)
+                break;
+            if (gz_comp(state, Z_NO_FLUSH) == -1)
+                return state->again ? put - len : 0;
+        }
     }
     else {
         /* consume whatever's left in the input buffer */
@@ -243,13 +258,16 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
         state->strm.next_in = (z_const Bytef *)buf;
         do {
             unsigned n = (unsigned)-1;
+
             if (n > len)
                 n = (unsigned)len;
             state->strm.avail_in = n;
+            ret = gz_comp(state, Z_NO_FLUSH);
+            n -= state->strm.avail_in;
             state->x.pos += n;
-            if (gz_comp(state, Z_NO_FLUSH) == -1)
-                return 0;
             len -= n;
+            if (ret == -1)
+                return state->again ? put - len : 0;
         } while (len);
     }
 
@@ -266,9 +284,10 @@ int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
         return 0;
     state = (gz_statep)file;
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return 0;
+    gz_error(state, Z_OK, NULL);
 
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids a flaw in the interface) */
@@ -292,9 +311,10 @@ z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
         return 0;
     state = (gz_statep)file;
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return 0;
+    gz_error(state, Z_OK, NULL);
 
     /* compute bytes to read -- error on overflow */
     len = nitems * size;
@@ -320,16 +340,14 @@ int ZEXPORT gzputc(gzFile file, int c) {
     state = (gz_statep)file;
     strm = &(state->strm);
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return -1;
+    gz_error(state, Z_OK, NULL);
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return -1;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return -1;
 
     /* try writing to input buffer for speed (state->size == 0 if buffer not
        initialized) */
@@ -362,9 +380,10 @@ int ZEXPORT gzputs(gzFile file, const char *s) {
         return -1;
     state = (gz_statep)file;
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return -1;
+    gz_error(state, Z_OK, NULL);
 
     /* write string */
     len = strlen(s);
@@ -373,16 +392,47 @@ int ZEXPORT gzputs(gzFile file, const char *s) {
         return -1;
     }
     put = gz_write(state, s, len);
-    return put < len ? -1 : (int)len;
+    return len && put == 0 ? -1 : (int)put;
 }
 
+#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || !defined(NO_vsnprintf)) && \
+     (defined(STDC) || defined(Z_HAVE_STDARG_H) || !defined(NO_snprintf))) || \
+    defined(ZLIB_INSECURE)
+/* If the second half of the input buffer is occupied, write out the contents.
+   If there is any input remaining due to a non-blocking stall on write, move
+   it to the start of the buffer. Return true if this did not open up the
+   second half of the buffer.  state->err should be checked after this to
+   handle a gz_comp() error. */
+local int gz_vacate(gz_statep state) {
+    z_streamp strm;
+
+    strm = &(state->strm);
+    if (strm->next_in + strm->avail_in <= state->in + state->size)
+        return 0;
+    (void)gz_comp(state, Z_NO_FLUSH);
+    if (strm->avail_in == 0) {
+        strm->next_in = state->in;
+        return 0;
+    }
+    memmove(state->in, strm->next_in, strm->avail_in);
+    strm->next_in = state->in;
+    return strm->avail_in > state->size;
+}
+#endif
+
 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
 #include 
 
 /* -- see zlib.h -- */
 int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
-    int len;
-    unsigned left;
+#if defined(NO_vsnprintf) && !defined(ZLIB_INSECURE)
+#warning "vsnprintf() not available -- gzprintf() stub returns Z_STREAM_ERROR"
+#warning "you can recompile with ZLIB_INSECURE defined to use vsprintf()"
+    /* prevent use of insecure vsprintf(), unless purposefully requested */
+    (void)file, (void)format, (void)va;
+    return Z_STREAM_ERROR;
+#else
+    int len, ret;
     char *next;
     gz_statep state;
     z_streamp strm;
@@ -393,24 +443,34 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
     state = (gz_statep)file;
     strm = &(state->strm);
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return Z_STREAM_ERROR;
+    gz_error(state, Z_OK, NULL);
 
     /* make sure we have some buffer space */
     if (state->size == 0 && gz_init(state) == -1)
         return state->err;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return state->err;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return state->err;
 
     /* do the printf() into the input buffer, put length in len -- the input
-       buffer is double-sized just for this function, so there is guaranteed to
-       be state->size bytes available after the current contents */
+       buffer is double-sized just for this function, so there should be
+       state->size bytes available after the current contents */
+    ret = gz_vacate(state);
+    if (state->err) {
+        if (ret && state->again) {
+            /* There was a non-blocking stall on write, resulting in the part
+               of the second half of the output buffer being occupied.  Return
+               a Z_BUF_ERROR to let the application know that this gzprintf()
+               needs to be retried. */
+            gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+        }
+        if (!state->again)
+            return state->err;
+    }
     if (strm->avail_in == 0)
         strm->next_in = state->in;
     next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
@@ -436,19 +496,16 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
     if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
         return 0;
 
-    /* update buffer and position, compress first half if past that */
+    /* update buffer and position */
     strm->avail_in += (unsigned)len;
     state->x.pos += len;
-    if (strm->avail_in >= state->size) {
-        left = strm->avail_in - state->size;
-        strm->avail_in = state->size;
-        if (gz_comp(state, Z_NO_FLUSH) == -1)
-            return state->err;
-        memmove(state->in, state->in + state->size, left);
-        strm->next_in = state->in;
-        strm->avail_in = left;
-    }
+
+    /* write out buffer if more than half is occupied */
+    ret = gz_vacate(state);
+    if (state->err && !state->again)
+        return state->err;
     return len;
+#endif
 }
 
 int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
@@ -468,6 +525,17 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
                        int a4, int a5, int a6, int a7, int a8, int a9, int a10,
                        int a11, int a12, int a13, int a14, int a15, int a16,
                        int a17, int a18, int a19, int a20) {
+#if defined(NO_snprintf) && !defined(ZLIB_INSECURE)
+#warning "snprintf() not available -- gzprintf() stub returns Z_STREAM_ERROR"
+#warning "you can recompile with ZLIB_INSECURE defined to use sprintf()"
+    /* prevent use of insecure sprintf(), unless purposefully requested */
+    (void)file, (void)format, (void)a1, (void)a2, (void)a3, (void)a4, (void)a5,
+    (void)a6, (void)a7, (void)a8, (void)a9, (void)a10, (void)a11, (void)a12,
+    (void)a13, (void)a14, (void)a15, (void)a16, (void)a17, (void)a18,
+    (void)a19, (void)a20;
+    return Z_STREAM_ERROR;
+#else
+    int ret;
     unsigned len, left;
     char *next;
     gz_statep state;
@@ -483,24 +551,34 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
     if (sizeof(int) != sizeof(void *))
         return Z_STREAM_ERROR;
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return Z_STREAM_ERROR;
+    gz_error(state, Z_OK, NULL);
 
     /* make sure we have some buffer space */
     if (state->size == 0 && gz_init(state) == -1)
-        return state->error;
+        return state->err;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return state->error;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return state->err;
 
     /* do the printf() into the input buffer, put length in len -- the input
        buffer is double-sized just for this function, so there is guaranteed to
        be state->size bytes available after the current contents */
+    ret = gz_vacate(state);
+    if (state->err) {
+        if (ret && state->again) {
+            /* There was a non-blocking stall on write, resulting in the part
+               of the second half of the output buffer being occupied.  Return
+               a Z_BUF_ERROR to let the application know that this gzprintf()
+               needs to be retried. */
+            gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+        }
+        if (!state->again)
+            return state->err;
+    }
     if (strm->avail_in == 0)
         strm->next_in = state->in;
     next = (char *)(strm->next_in + strm->avail_in);
@@ -534,16 +612,13 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
     /* update buffer and position, compress first half if past that */
     strm->avail_in += len;
     state->x.pos += len;
-    if (strm->avail_in >= state->size) {
-        left = strm->avail_in - state->size;
-        strm->avail_in = state->size;
-        if (gz_comp(state, Z_NO_FLUSH) == -1)
-            return state->err;
-        memmove(state->in, state->in + state->size, left);
-        strm->next_in = state->in;
-        strm->avail_in = left;
-    }
+
+    /* write out buffer if more than half is occupied */
+    ret = gz_vacate(state);
+    if (state->err && !state->again)
+        return state->err;
     return (int)len;
+#endif
 }
 
 #endif
@@ -557,20 +632,18 @@ int ZEXPORT gzflush(gzFile file, int flush) {
         return Z_STREAM_ERROR;
     state = (gz_statep)file;
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
+    /* check that we're writing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
         return Z_STREAM_ERROR;
+    gz_error(state, Z_OK, NULL);
 
     /* check flush parameter */
     if (flush < 0 || flush > Z_FINISH)
         return Z_STREAM_ERROR;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return state->err;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return state->err;
 
     /* compress remaining data with requested flush */
     (void)gz_comp(state, flush);
@@ -588,20 +661,19 @@ int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
     state = (gz_statep)file;
     strm = &(state->strm);
 
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
+    /* check that we're compressing and that there's no (serious) error */
+    if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again) ||
+            state->direct)
         return Z_STREAM_ERROR;
+    gz_error(state, Z_OK, NULL);
 
     /* if no change is requested, then do nothing */
     if (level == state->level && strategy == state->strategy)
         return Z_OK;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return state->err;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        return state->err;
 
     /* change compression parameters for subsequent input */
     if (state->size) {
@@ -630,11 +702,8 @@ int ZEXPORT gzclose_w(gzFile file) {
         return Z_STREAM_ERROR;
 
     /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            ret = state->err;
-    }
+    if (state->skip && gz_zero(state) == -1)
+        ret = state->err;
 
     /* flush, free memory, and close file */
     if (gz_comp(state, Z_FINISH) == -1)
diff --git a/src/java.base/share/native/libzip/zlib/infback.c b/src/java.base/share/native/libzip/zlib/infback.c
index f680e2cdbdc..0becbb9eb4f 100644
--- a/src/java.base/share/native/libzip/zlib/infback.c
+++ b/src/java.base/share/native/libzip/zlib/infback.c
@@ -23,7 +23,7 @@
  */
 
 /* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2022 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -70,7 +70,7 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
 #ifdef Z_SOLO
         return Z_STREAM_ERROR;
 #else
-    strm->zfree = zcfree;
+        strm->zfree = zcfree;
 #endif
     state = (struct inflate_state FAR *)ZALLOC(strm, 1,
                                                sizeof(struct inflate_state));
@@ -87,57 +87,6 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
     return Z_OK;
 }
 
-/*
-   Return state with length and distance decoding tables and index sizes set to
-   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
-   If BUILDFIXED is defined, then instead this routine builds the tables the
-   first time it's called, and returns those tables the first time and
-   thereafter.  This reduces the size of the code by about 2K bytes, in
-   exchange for a little execution time.  However, BUILDFIXED should not be
-   used for threaded applications, since the rewriting of the tables and virgin
-   may not be thread-safe.
- */
-local void fixedtables(struct inflate_state FAR *state) {
-#ifdef BUILDFIXED
-    static int virgin = 1;
-    static code *lenfix, *distfix;
-    static code fixed[544];
-
-    /* build fixed huffman tables if first call (may not be thread safe) */
-    if (virgin) {
-        unsigned sym, bits;
-        static code *next;
-
-        /* literal/length table */
-        sym = 0;
-        while (sym < 144) state->lens[sym++] = 8;
-        while (sym < 256) state->lens[sym++] = 9;
-        while (sym < 280) state->lens[sym++] = 7;
-        while (sym < 288) state->lens[sym++] = 8;
-        next = fixed;
-        lenfix = next;
-        bits = 9;
-        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
-        /* distance table */
-        sym = 0;
-        while (sym < 32) state->lens[sym++] = 5;
-        distfix = next;
-        bits = 5;
-        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
-        /* do this just once */
-        virgin = 0;
-    }
-#else /* !BUILDFIXED */
-#   include "inffixed.h"
-#endif /* BUILDFIXED */
-    state->lencode = lenfix;
-    state->lenbits = 9;
-    state->distcode = distfix;
-    state->distbits = 5;
-}
-
 /* Macros for inflateBack(): */
 
 /* Load returned state from inflate_fast() */
@@ -317,7 +266,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
                 state->mode = STORED;
                 break;
             case 1:                             /* fixed block */
-                fixedtables(state);
+                inflate_fixed(state);
                 Tracev((stderr, "inflate:     fixed codes block%s\n",
                         state->last ? " (last)" : ""));
                 state->mode = LEN;              /* decode codes */
@@ -327,8 +276,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
                         state->last ? " (last)" : ""));
                 state->mode = TABLE;
                 break;
-            case 3:
-                strm->msg = (char *)"invalid block type";
+            default:
+                strm->msg = (z_const char *)"invalid block type";
                 state->mode = BAD;
             }
             DROPBITS(2);
@@ -339,7 +288,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             BYTEBITS();                         /* go to byte boundary */
             NEEDBITS(32);
             if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
-                strm->msg = (char *)"invalid stored block lengths";
+                strm->msg = (z_const char *)"invalid stored block lengths";
                 state->mode = BAD;
                 break;
             }
@@ -377,7 +326,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             DROPBITS(4);
 #ifndef PKZIP_BUG_WORKAROUND
             if (state->nlen > 286 || state->ndist > 30) {
-                strm->msg = (char *)"too many length or distance symbols";
+                strm->msg = (z_const char *)
+                    "too many length or distance symbols";
                 state->mode = BAD;
                 break;
             }
@@ -399,7 +349,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             ret = inflate_table(CODES, state->lens, 19, &(state->next),
                                 &(state->lenbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid code lengths set";
+                strm->msg = (z_const char *)"invalid code lengths set";
                 state->mode = BAD;
                 break;
             }
@@ -422,7 +372,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
                         NEEDBITS(here.bits + 2);
                         DROPBITS(here.bits);
                         if (state->have == 0) {
-                            strm->msg = (char *)"invalid bit length repeat";
+                            strm->msg = (z_const char *)
+                                "invalid bit length repeat";
                             state->mode = BAD;
                             break;
                         }
@@ -445,7 +396,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
                         DROPBITS(7);
                     }
                     if (state->have + copy > state->nlen + state->ndist) {
-                        strm->msg = (char *)"invalid bit length repeat";
+                        strm->msg = (z_const char *)
+                            "invalid bit length repeat";
                         state->mode = BAD;
                         break;
                     }
@@ -459,7 +411,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
 
             /* check for end-of-block code (better have one) */
             if (state->lens[256] == 0) {
-                strm->msg = (char *)"invalid code -- missing end-of-block";
+                strm->msg = (z_const char *)
+                    "invalid code -- missing end-of-block";
                 state->mode = BAD;
                 break;
             }
@@ -473,7 +426,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
                                 &(state->lenbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid literal/lengths set";
+                strm->msg = (z_const char *)"invalid literal/lengths set";
                 state->mode = BAD;
                 break;
             }
@@ -482,7 +435,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
                             &(state->next), &(state->distbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid distances set";
+                strm->msg = (z_const char *)"invalid distances set";
                 state->mode = BAD;
                 break;
             }
@@ -541,7 +494,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
 
             /* invalid code */
             if (here.op & 64) {
-                strm->msg = (char *)"invalid literal/length code";
+                strm->msg = (z_const char *)"invalid literal/length code";
                 state->mode = BAD;
                 break;
             }
@@ -573,7 +526,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             }
             DROPBITS(here.bits);
             if (here.op & 64) {
-                strm->msg = (char *)"invalid distance code";
+                strm->msg = (z_const char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
@@ -588,7 +541,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
             }
             if (state->offset > state->wsize - (state->whave < state->wsize ?
                                                 left : 0)) {
-                strm->msg = (char *)"invalid distance too far back";
+                strm->msg = (z_const char *)"invalid distance too far back";
                 state->mode = BAD;
                 break;
             }
diff --git a/src/java.base/share/native/libzip/zlib/inffast.c b/src/java.base/share/native/libzip/zlib/inffast.c
index e86dd78d801..1ce89512ec4 100644
--- a/src/java.base/share/native/libzip/zlib/inffast.c
+++ b/src/java.base/share/native/libzip/zlib/inffast.c
@@ -23,7 +23,7 @@
  */
 
 /* inffast.c -- fast decoding
- * Copyright (C) 1995-2017 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -179,7 +179,8 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
                 dist += (unsigned)hold & ((1U << op) - 1);
 #ifdef INFLATE_STRICT
                 if (dist > dmax) {
-                    strm->msg = (char *)"invalid distance too far back";
+                    strm->msg = (z_const char *)
+                        "invalid distance too far back";
                     state->mode = BAD;
                     break;
                 }
@@ -192,8 +193,8 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
                     op = dist - op;             /* distance back in window */
                     if (op > whave) {
                         if (state->sane) {
-                            strm->msg =
-                                (char *)"invalid distance too far back";
+                            strm->msg = (z_const char *)
+                                "invalid distance too far back";
                             state->mode = BAD;
                             break;
                         }
@@ -289,7 +290,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
                 goto dodist;
             }
             else {
-                strm->msg = (char *)"invalid distance code";
+                strm->msg = (z_const char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
@@ -304,7 +305,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
             break;
         }
         else {
-            strm->msg = (char *)"invalid literal/length code";
+            strm->msg = (z_const char *)"invalid literal/length code";
             state->mode = BAD;
             break;
         }
diff --git a/src/java.base/share/native/libzip/zlib/inffixed.h b/src/java.base/share/native/libzip/zlib/inffixed.h
index f0a4ef1c4e8..d234b018c87 100644
--- a/src/java.base/share/native/libzip/zlib/inffixed.h
+++ b/src/java.base/share/native/libzip/zlib/inffixed.h
@@ -22,97 +22,97 @@
  * questions.
  */
 
-    /* inffixed.h -- table for decoding fixed codes
-     * Generated automatically by makefixed().
-     */
+/* inffixed.h -- table for decoding fixed codes
+ * Generated automatically by makefixed().
+ */
 
-    /* WARNING: this file should *not* be used by applications.
-       It is part of the implementation of this library and is
-       subject to change. Applications should only use zlib.h.
-     */
+/* WARNING: this file should *not* be used by applications.
+   It is part of the implementation of this library and is
+   subject to change. Applications should only use zlib.h.
+ */
 
-    static const code lenfix[512] = {
-        {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
-        {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
-        {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
-        {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
-        {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
-        {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
-        {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
-        {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
-        {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
-        {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
-        {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
-        {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
-        {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
-        {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
-        {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
-        {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
-        {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
-        {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
-        {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
-        {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
-        {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
-        {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
-        {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
-        {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
-        {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
-        {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
-        {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
-        {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
-        {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
-        {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
-        {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
-        {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
-        {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
-        {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
-        {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
-        {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
-        {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
-        {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
-        {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
-        {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
-        {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
-        {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
-        {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
-        {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
-        {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
-        {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
-        {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
-        {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
-        {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
-        {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
-        {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
-        {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
-        {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
-        {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
-        {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
-        {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
-        {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
-        {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
-        {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
-        {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
-        {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
-        {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
-        {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
-        {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
-        {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
-        {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
-        {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
-        {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
-        {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
-        {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
-        {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
-        {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
-        {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
-        {0,9,255}
-    };
+static const code lenfix[512] = {
+    {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
+    {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
+    {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
+    {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
+    {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
+    {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
+    {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
+    {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
+    {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
+    {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
+    {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
+    {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
+    {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
+    {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
+    {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
+    {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
+    {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
+    {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
+    {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
+    {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
+    {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
+    {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
+    {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
+    {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
+    {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
+    {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
+    {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
+    {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
+    {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
+    {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
+    {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
+    {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
+    {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
+    {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
+    {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
+    {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
+    {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
+    {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
+    {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
+    {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
+    {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
+    {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
+    {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
+    {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
+    {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
+    {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
+    {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
+    {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
+    {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
+    {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
+    {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
+    {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
+    {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
+    {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
+    {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
+    {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
+    {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
+    {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
+    {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
+    {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
+    {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
+    {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
+    {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
+    {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
+    {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
+    {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
+    {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
+    {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
+    {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
+    {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
+    {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
+    {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
+    {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
+    {0,9,255}
+};
 
-    static const code distfix[32] = {
-        {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
-        {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
-        {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
-        {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
-        {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
-        {22,5,193},{64,5,0}
-    };
+static const code distfix[32] = {
+    {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
+    {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
+    {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
+    {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
+    {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
+    {22,5,193},{64,5,0}
+};
diff --git a/src/java.base/share/native/libzip/zlib/inflate.c b/src/java.base/share/native/libzip/zlib/inflate.c
index 3370cfe9565..c548f98f6de 100644
--- a/src/java.base/share/native/libzip/zlib/inflate.c
+++ b/src/java.base/share/native/libzip/zlib/inflate.c
@@ -23,7 +23,7 @@
  */
 
 /* inflate.c -- zlib decompression
- * Copyright (C) 1995-2022 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -109,12 +109,6 @@
 #include "inflate.h"
 #include "inffast.h"
 
-#ifdef MAKEFIXED
-#  ifndef BUILDFIXED
-#    define BUILDFIXED
-#  endif
-#endif
-
 local int inflateStateCheck(z_streamp strm) {
     struct inflate_state FAR *state;
     if (strm == Z_NULL ||
@@ -134,6 +128,7 @@ int ZEXPORT inflateResetKeep(z_streamp strm) {
     state = (struct inflate_state FAR *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
     strm->msg = Z_NULL;
+    strm->data_type = 0;
     if (state->wrap)        /* to support ill-conceived Java test suite */
         strm->adler = state->wrap & 1;
     state->mode = HEAD;
@@ -226,6 +221,7 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
     state = (struct inflate_state FAR *)
             ZALLOC(strm, 1, sizeof(struct inflate_state));
     if (state == Z_NULL) return Z_MEM_ERROR;
+    zmemzero(state, sizeof(struct inflate_state));
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state FAR *)state;
     state->strm = strm;
@@ -258,123 +254,11 @@ int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
     }
     if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
     value &= (1L << bits) - 1;
-    state->hold += (unsigned)value << state->bits;
+    state->hold += (unsigned long)value << state->bits;
     state->bits += (uInt)bits;
     return Z_OK;
 }
 
-/*
-   Return state with length and distance decoding tables and index sizes set to
-   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
-   If BUILDFIXED is defined, then instead this routine builds the tables the
-   first time it's called, and returns those tables the first time and
-   thereafter.  This reduces the size of the code by about 2K bytes, in
-   exchange for a little execution time.  However, BUILDFIXED should not be
-   used for threaded applications, since the rewriting of the tables and virgin
-   may not be thread-safe.
- */
-local void fixedtables(struct inflate_state FAR *state) {
-#ifdef BUILDFIXED
-    static int virgin = 1;
-    static code *lenfix, *distfix;
-    static code fixed[544];
-
-    /* build fixed huffman tables if first call (may not be thread safe) */
-    if (virgin) {
-        unsigned sym, bits;
-        static code *next;
-
-        /* literal/length table */
-        sym = 0;
-        while (sym < 144) state->lens[sym++] = 8;
-        while (sym < 256) state->lens[sym++] = 9;
-        while (sym < 280) state->lens[sym++] = 7;
-        while (sym < 288) state->lens[sym++] = 8;
-        next = fixed;
-        lenfix = next;
-        bits = 9;
-        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
-        /* distance table */
-        sym = 0;
-        while (sym < 32) state->lens[sym++] = 5;
-        distfix = next;
-        bits = 5;
-        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
-        /* do this just once */
-        virgin = 0;
-    }
-#else /* !BUILDFIXED */
-#   include "inffixed.h"
-#endif /* BUILDFIXED */
-    state->lencode = lenfix;
-    state->lenbits = 9;
-    state->distcode = distfix;
-    state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include 
-
-/*
-   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also
-   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes
-   those tables to stdout, which would be piped to inffixed.h.  A small program
-   can simply call makefixed to do this:
-
-    void makefixed(void);
-
-    int main(void)
-    {
-        makefixed();
-        return 0;
-    }
-
-   Then that can be linked with zlib built with MAKEFIXED defined and run:
-
-    a.out > inffixed.h
- */
-void makefixed(void)
-{
-    unsigned low, size;
-    struct inflate_state state;
-
-    fixedtables(&state);
-    puts("    /* inffixed.h -- table for decoding fixed codes");
-    puts("     * Generated automatically by makefixed().");
-    puts("     */");
-    puts("");
-    puts("    /* WARNING: this file should *not* be used by applications.");
-    puts("       It is part of the implementation of this library and is");
-    puts("       subject to change. Applications should only use zlib.h.");
-    puts("     */");
-    puts("");
-    size = 1U << 9;
-    printf("    static const code lenfix[%u] = {", size);
-    low = 0;
-    for (;;) {
-        if ((low % 7) == 0) printf("\n        ");
-        printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
-               state.lencode[low].bits, state.lencode[low].val);
-        if (++low == size) break;
-        putchar(',');
-    }
-    puts("\n    };");
-    size = 1U << 5;
-    printf("\n    static const code distfix[%u] = {", size);
-    low = 0;
-    for (;;) {
-        if ((low % 6) == 0) printf("\n        ");
-        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
-               state.distcode[low].val);
-        if (++low == size) break;
-        putchar(',');
-    }
-    puts("\n    };");
-}
-#endif /* MAKEFIXED */
-
 /*
    Update the window with the last wsize (normally 32K) bytes written before
    returning.  If window does not exist yet, create it.  This is only called
@@ -666,12 +550,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             if (
 #endif
                 ((BITS(8) << 8) + (hold >> 8)) % 31) {
-                strm->msg = (char *)"incorrect header check";
+                strm->msg = (z_const char *)"incorrect header check";
                 state->mode = BAD;
                 break;
             }
             if (BITS(4) != Z_DEFLATED) {
-                strm->msg = (char *)"unknown compression method";
+                strm->msg = (z_const char *)"unknown compression method";
                 state->mode = BAD;
                 break;
             }
@@ -680,7 +564,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             if (state->wbits == 0)
                 state->wbits = len;
             if (len > 15 || len > state->wbits) {
-                strm->msg = (char *)"invalid window size";
+                strm->msg = (z_const char *)"invalid window size";
                 state->mode = BAD;
                 break;
             }
@@ -696,12 +580,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             NEEDBITS(16);
             state->flags = (int)(hold);
             if ((state->flags & 0xff) != Z_DEFLATED) {
-                strm->msg = (char *)"unknown compression method";
+                strm->msg = (z_const char *)"unknown compression method";
                 state->mode = BAD;
                 break;
             }
             if (state->flags & 0xe000) {
-                strm->msg = (char *)"unknown header flags set";
+                strm->msg = (z_const char *)"unknown header flags set";
                 state->mode = BAD;
                 break;
             }
@@ -817,7 +701,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             if (state->flags & 0x0200) {
                 NEEDBITS(16);
                 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
-                    strm->msg = (char *)"header crc mismatch";
+                    strm->msg = (z_const char *)"header crc mismatch";
                     state->mode = BAD;
                     break;
                 }
@@ -864,7 +748,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                 state->mode = STORED;
                 break;
             case 1:                             /* fixed block */
-                fixedtables(state);
+                inflate_fixed(state);
                 Tracev((stderr, "inflate:     fixed codes block%s\n",
                         state->last ? " (last)" : ""));
                 state->mode = LEN_;             /* decode codes */
@@ -878,8 +762,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                         state->last ? " (last)" : ""));
                 state->mode = TABLE;
                 break;
-            case 3:
-                strm->msg = (char *)"invalid block type";
+            default:
+                strm->msg = (z_const char *)"invalid block type";
                 state->mode = BAD;
             }
             DROPBITS(2);
@@ -888,7 +772,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             BYTEBITS();                         /* go to byte boundary */
             NEEDBITS(32);
             if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
-                strm->msg = (char *)"invalid stored block lengths";
+                strm->msg = (z_const char *)"invalid stored block lengths";
                 state->mode = BAD;
                 break;
             }
@@ -929,7 +813,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             DROPBITS(4);
 #ifndef PKZIP_BUG_WORKAROUND
             if (state->nlen > 286 || state->ndist > 30) {
-                strm->msg = (char *)"too many length or distance symbols";
+                strm->msg = (z_const char *)
+                    "too many length or distance symbols";
                 state->mode = BAD;
                 break;
             }
@@ -947,12 +832,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             while (state->have < 19)
                 state->lens[order[state->have++]] = 0;
             state->next = state->codes;
-            state->lencode = (const code FAR *)(state->next);
+            state->lencode = state->distcode = (const code FAR *)(state->next);
             state->lenbits = 7;
             ret = inflate_table(CODES, state->lens, 19, &(state->next),
                                 &(state->lenbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid code lengths set";
+                strm->msg = (z_const char *)"invalid code lengths set";
                 state->mode = BAD;
                 break;
             }
@@ -976,7 +861,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                         NEEDBITS(here.bits + 2);
                         DROPBITS(here.bits);
                         if (state->have == 0) {
-                            strm->msg = (char *)"invalid bit length repeat";
+                            strm->msg = (z_const char *)
+                                "invalid bit length repeat";
                             state->mode = BAD;
                             break;
                         }
@@ -999,7 +885,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                         DROPBITS(7);
                     }
                     if (state->have + copy > state->nlen + state->ndist) {
-                        strm->msg = (char *)"invalid bit length repeat";
+                        strm->msg = (z_const char *)
+                            "invalid bit length repeat";
                         state->mode = BAD;
                         break;
                     }
@@ -1013,7 +900,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
 
             /* check for end-of-block code (better have one) */
             if (state->lens[256] == 0) {
-                strm->msg = (char *)"invalid code -- missing end-of-block";
+                strm->msg = (z_const char *)
+                    "invalid code -- missing end-of-block";
                 state->mode = BAD;
                 break;
             }
@@ -1027,7 +915,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
                                 &(state->lenbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid literal/lengths set";
+                strm->msg = (z_const char *)"invalid literal/lengths set";
                 state->mode = BAD;
                 break;
             }
@@ -1036,7 +924,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
                             &(state->next), &(state->distbits), state->work);
             if (ret) {
-                strm->msg = (char *)"invalid distances set";
+                strm->msg = (z_const char *)"invalid distances set";
                 state->mode = BAD;
                 break;
             }
@@ -1090,7 +978,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                 break;
             }
             if (here.op & 64) {
-                strm->msg = (char *)"invalid literal/length code";
+                strm->msg = (z_const char *)"invalid literal/length code";
                 state->mode = BAD;
                 break;
             }
@@ -1128,7 +1016,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             DROPBITS(here.bits);
             state->back += here.bits;
             if (here.op & 64) {
-                strm->msg = (char *)"invalid distance code";
+                strm->msg = (z_const char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
@@ -1145,7 +1033,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             }
 #ifdef INFLATE_STRICT
             if (state->offset > state->dmax) {
-                strm->msg = (char *)"invalid distance too far back";
+                strm->msg = (z_const char *)"invalid distance too far back";
                 state->mode = BAD;
                 break;
             }
@@ -1160,7 +1048,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                 copy = state->offset - copy;
                 if (copy > state->whave) {
                     if (state->sane) {
-                        strm->msg = (char *)"invalid distance too far back";
+                        strm->msg = (z_const char *)
+                            "invalid distance too far back";
                         state->mode = BAD;
                         break;
                     }
@@ -1219,7 +1108,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
                      state->flags ? hold :
 #endif
                      ZSWAP32(hold)) != state->check) {
-                    strm->msg = (char *)"incorrect data check";
+                    strm->msg = (z_const char *)"incorrect data check";
                     state->mode = BAD;
                     break;
                 }
@@ -1233,7 +1122,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
             if (state->wrap && state->flags) {
                 NEEDBITS(32);
                 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
-                    strm->msg = (char *)"incorrect length check";
+                    strm->msg = (z_const char *)"incorrect length check";
                     state->mode = BAD;
                     break;
                 }
@@ -1464,7 +1353,6 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
     struct inflate_state FAR *state;
     struct inflate_state FAR *copy;
     unsigned char FAR *window;
-    unsigned wsize;
 
     /* check input */
     if (inflateStateCheck(source) || dest == Z_NULL)
@@ -1475,6 +1363,7 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
     copy = (struct inflate_state FAR *)
            ZALLOC(source, 1, sizeof(struct inflate_state));
     if (copy == Z_NULL) return Z_MEM_ERROR;
+    zmemzero(copy, sizeof(struct inflate_state));
     window = Z_NULL;
     if (state->window != Z_NULL) {
         window = (unsigned char FAR *)
@@ -1486,8 +1375,8 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
     }
 
     /* copy state */
-    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
-    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
+    zmemcpy(dest, source, sizeof(z_stream));
+    zmemcpy(copy, state, sizeof(struct inflate_state));
     copy->strm = dest;
     if (state->lencode >= state->codes &&
         state->lencode <= state->codes + ENOUGH - 1) {
@@ -1495,10 +1384,8 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
         copy->distcode = copy->codes + (state->distcode - state->codes);
     }
     copy->next = copy->codes + (state->next - state->codes);
-    if (window != Z_NULL) {
-        wsize = 1U << state->wbits;
-        zmemcpy(window, state->window, wsize);
-    }
+    if (window != Z_NULL)
+        zmemcpy(window, state->window, state->whave);
     copy->window = window;
     dest->state = (struct internal_state FAR *)copy;
     return Z_OK;
diff --git a/src/java.base/share/native/libzip/zlib/inflate.h b/src/java.base/share/native/libzip/zlib/inflate.h
index 2cc56dd7fd4..7828fb5db38 100644
--- a/src/java.base/share/native/libzip/zlib/inflate.h
+++ b/src/java.base/share/native/libzip/zlib/inflate.h
@@ -124,7 +124,7 @@ struct inflate_state {
     unsigned char FAR *window;  /* allocated sliding window, if needed */
         /* bit accumulator */
     unsigned long hold;         /* input bit accumulator */
-    unsigned bits;              /* number of bits in "in" */
+    unsigned bits;              /* number of bits in hold */
         /* for string and stored block copying */
     unsigned length;            /* literal or length of data to copy */
     unsigned offset;            /* distance back to copy string from */
diff --git a/src/java.base/share/native/libzip/zlib/inftrees.c b/src/java.base/share/native/libzip/zlib/inftrees.c
index c4913bc4359..5f5d6b4baef 100644
--- a/src/java.base/share/native/libzip/zlib/inftrees.c
+++ b/src/java.base/share/native/libzip/zlib/inftrees.c
@@ -23,17 +23,31 @@
  */
 
 /* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2024 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
+#ifdef MAKEFIXED
+#  ifndef BUILDFIXED
+#    define BUILDFIXED
+#  endif
+#endif
+#ifdef BUILDFIXED
+#  define Z_ONCE
+#endif
+
 #include "zutil.h"
 #include "inftrees.h"
+#include "inflate.h"
+
+#ifndef NULL
+#  define NULL 0
+#endif
 
 #define MAXBITS 15
 
 const char inflate_copyright[] =
-   " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
+   " inflate 1.3.2 Copyright 1995-2026 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -71,9 +85,9 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
     unsigned mask;              /* mask for low root bits */
     code here;                  /* table entry for duplication */
     code FAR *next;             /* next available space in table */
-    const unsigned short FAR *base;     /* base value table to use */
-    const unsigned short FAR *extra;    /* extra bits table to use */
-    unsigned match;             /* use base and extra for symbol >= match */
+    const unsigned short FAR *base = NULL;  /* base value table to use */
+    const unsigned short FAR *extra = NULL; /* extra bits table to use */
+    unsigned match = 0;         /* use base and extra for symbol >= match */
     unsigned short count[MAXBITS+1];    /* number of codes of each length */
     unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
     static const unsigned short lbase[31] = { /* Length codes 257..285 base */
@@ -81,7 +95,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
+        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -199,7 +213,6 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
     /* set up for code type */
     switch (type) {
     case CODES:
-        base = extra = work;    /* dummy value--not used */
         match = 20;
         break;
     case LENS:
@@ -207,10 +220,9 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
         extra = lext;
         match = 257;
         break;
-    default:    /* DISTS */
+    case DISTS:
         base = dbase;
         extra = dext;
-        match = 0;
     }
 
     /* initialize state for loop */
@@ -321,3 +333,116 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
     *bits = root;
     return 0;
 }
+
+#ifdef BUILDFIXED
+/*
+  If this is compiled with BUILDFIXED defined, and if inflate will be used in
+  multiple threads, and if atomics are not available, then inflate() must be
+  called with a fixed block (e.g. 0x03 0x00) to initialize the tables and must
+  return before any other threads are allowed to call inflate.
+ */
+
+static code *lenfix, *distfix;
+static code fixed[544];
+
+/* State for z_once(). */
+local z_once_t built = Z_ONCE_INIT;
+
+local void buildtables(void) {
+    unsigned sym, bits;
+    static code *next;
+    unsigned short lens[288], work[288];
+
+    /* literal/length table */
+    sym = 0;
+    while (sym < 144) lens[sym++] = 8;
+    while (sym < 256) lens[sym++] = 9;
+    while (sym < 280) lens[sym++] = 7;
+    while (sym < 288) lens[sym++] = 8;
+    next = fixed;
+    lenfix = next;
+    bits = 9;
+    inflate_table(LENS, lens, 288, &(next), &(bits), work);
+
+    /* distance table */
+    sym = 0;
+    while (sym < 32) lens[sym++] = 5;
+    distfix = next;
+    bits = 5;
+    inflate_table(DISTS, lens, 32, &(next), &(bits), work);
+}
+#else /* !BUILDFIXED */
+#  include "inffixed.h"
+#endif /* BUILDFIXED */
+
+/*
+   Return state with length and distance decoding tables and index sizes set to
+   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
+   If BUILDFIXED is defined, then instead this routine builds the tables the
+   first time it's called, and returns those tables the first time and
+   thereafter.  This reduces the size of the code by about 2K bytes, in
+   exchange for a little execution time.  However, BUILDFIXED should not be
+   used for threaded applications if atomics are not available, as it will
+   not be thread-safe.
+ */
+void inflate_fixed(struct inflate_state FAR *state) {
+#ifdef BUILDFIXED
+    z_once(&built, buildtables);
+#endif /* BUILDFIXED */
+    state->lencode = lenfix;
+    state->lenbits = 9;
+    state->distcode = distfix;
+    state->distbits = 5;
+}
+
+#ifdef MAKEFIXED
+#include 
+
+/*
+   Write out the inffixed.h that will be #include'd above.  Defining MAKEFIXED
+   also defines BUILDFIXED, so the tables are built on the fly.  main() writes
+   those tables to stdout, which would directed to inffixed.h. Compile this
+   along with zutil.c:
+
+       cc -DMAKEFIXED -o fix inftrees.c zutil.c
+       ./fix > inffixed.h
+ */
+int main(void) {
+    unsigned low, size;
+    struct inflate_state state;
+
+    inflate_fixed(&state);
+    puts("/* inffixed.h -- table for decoding fixed codes");
+    puts(" * Generated automatically by makefixed().");
+    puts(" */");
+    puts("");
+    puts("/* WARNING: this file should *not* be used by applications.");
+    puts("   It is part of the implementation of this library and is");
+    puts("   subject to change. Applications should only use zlib.h.");
+    puts(" */");
+    puts("");
+    size = 1U << 9;
+    printf("static const code lenfix[%u] = {", size);
+    low = 0;
+    for (;;) {
+        if ((low % 7) == 0) printf("\n    ");
+        printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
+               state.lencode[low].bits, state.lencode[low].val);
+        if (++low == size) break;
+        putchar(',');
+    }
+    puts("\n};");
+    size = 1U << 5;
+    printf("\nstatic const code distfix[%u] = {", size);
+    low = 0;
+    for (;;) {
+        if ((low % 6) == 0) printf("\n    ");
+        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
+               state.distcode[low].val);
+        if (++low == size) break;
+        putchar(',');
+    }
+    puts("\n};");
+    return 0;
+}
+#endif /* MAKEFIXED */
diff --git a/src/java.base/share/native/libzip/zlib/inftrees.h b/src/java.base/share/native/libzip/zlib/inftrees.h
index 3e2e889301d..b9b4fc2fb2b 100644
--- a/src/java.base/share/native/libzip/zlib/inftrees.h
+++ b/src/java.base/share/native/libzip/zlib/inftrees.h
@@ -23,7 +23,7 @@
  */
 
 /* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005, 2010 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -84,3 +84,5 @@ typedef enum {
 int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
                                 unsigned codes, code FAR * FAR *table,
                                 unsigned FAR *bits, unsigned short FAR *work);
+struct inflate_state;
+void ZLIB_INTERNAL inflate_fixed(struct inflate_state FAR *state);
diff --git a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
index 3296c5f2fad..dfde58f0122 100644
--- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
+++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
@@ -1,4 +1,4 @@
-Changes from zlib 1.3.1
+Changes in JDK's in-tree zlib compared to upstream zlib 1.3.2
 
 (1) renamed adler32.c -> zadler32.c, crc32c -> zcrc32.c
 
diff --git a/src/java.base/share/native/libzip/zlib/trees.c b/src/java.base/share/native/libzip/zlib/trees.c
index bbfa9deee5b..cc7b136bcf6 100644
--- a/src/java.base/share/native/libzip/zlib/trees.c
+++ b/src/java.base/share/native/libzip/zlib/trees.c
@@ -23,7 +23,7 @@
  */
 
 /* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2024 Jean-loup Gailly
+ * Copyright (C) 1995-2026 Jean-loup Gailly
  * detect_data_type() function provided freely by Cosmin Truta, 2006
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
@@ -136,7 +136,7 @@ local int base_dist[D_CODES];
 
 #else
 #  include "trees.h"
-#endif /* GEN_TREES_H */
+#endif /* defined(GEN_TREES_H) || !defined(STDC) */
 
 struct static_tree_desc_s {
     const ct_data *static_tree;  /* static tree or NULL */
@@ -176,7 +176,7 @@ local TCONST static_tree_desc static_bl_desc =
  * IN assertion: 1 <= len <= 15
  */
 local unsigned bi_reverse(unsigned code, int len) {
-    register unsigned res = 0;
+    unsigned res = 0;
     do {
         res |= code & 1;
         code >>= 1, res <<= 1;
@@ -208,10 +208,11 @@ local void bi_windup(deflate_state *s) {
     } else if (s->bi_valid > 0) {
         put_byte(s, (Byte)s->bi_buf);
     }
+    s->bi_used = ((s->bi_valid - 1) & 7) + 1;
     s->bi_buf = 0;
     s->bi_valid = 0;
 #ifdef ZLIB_DEBUG
-    s->bits_sent = (s->bits_sent + 7) & ~7;
+    s->bits_sent = (s->bits_sent + 7) & ~(ulg)7;
 #endif
 }
 
@@ -490,6 +491,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
 
     s->bi_buf = 0;
     s->bi_valid = 0;
+    s->bi_used = 0;
 #ifdef ZLIB_DEBUG
     s->compressed_len = 0L;
     s->bits_sent = 0L;
@@ -748,7 +750,7 @@ local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
         if (++count < max_count && curlen == nextlen) {
             continue;
         } else if (count < min_count) {
-            s->bl_tree[curlen].Freq += count;
+            s->bl_tree[curlen].Freq += (ush)count;
         } else if (curlen != 0) {
             if (curlen != prevlen) s->bl_tree[curlen].Freq++;
             s->bl_tree[REP_3_6].Freq++;
@@ -841,7 +843,7 @@ local int build_bl_tree(deflate_state *s) {
     }
     /* Update opt_len to include the bit length tree and counts */
     s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4;
-    Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
+    Tracev((stderr, "\ndyn trees: dyn %lu, stat %lu",
             s->opt_len, s->static_len));
 
     return max_blindex;
@@ -867,13 +869,13 @@ local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
         Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
         send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
     }
-    Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
+    Tracev((stderr, "\nbl tree: sent %lu", s->bits_sent));
 
     send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1);  /* literal tree */
-    Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
+    Tracev((stderr, "\nlit tree: sent %lu", s->bits_sent));
 
     send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1);  /* distance tree */
-    Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
+    Tracev((stderr, "\ndist tree: sent %lu", s->bits_sent));
 }
 
 /* ===========================================================================
@@ -956,7 +958,7 @@ local void compress_block(deflate_state *s, const ct_data *ltree,
             extra = extra_dbits[code];
             if (extra != 0) {
                 dist -= (unsigned)base_dist[code];
-                send_bits(s, dist, extra);   /* send the extra distance bits */
+                send_bits(s, (int)dist, extra); /* send the extra bits */
             }
         } /* literal or match pair ? */
 
@@ -1030,11 +1032,11 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
 
         /* Construct the literal and distance trees */
         build_tree(s, (tree_desc *)(&(s->l_desc)));
-        Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
+        Tracev((stderr, "\nlit data: dyn %lu, stat %lu", s->opt_len,
                 s->static_len));
 
         build_tree(s, (tree_desc *)(&(s->d_desc)));
-        Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
+        Tracev((stderr, "\ndist data: dyn %lu, stat %lu", s->opt_len,
                 s->static_len));
         /* At this point, opt_len and static_len are the total bit lengths of
          * the compressed block data, excluding the tree representations.
@@ -1107,7 +1109,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
 #endif
     }
     Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3,
-           s->compressed_len - 7*last));
+           s->compressed_len - 7*(ulg)last));
 }
 
 /* ===========================================================================
diff --git a/src/java.base/share/native/libzip/zlib/uncompr.c b/src/java.base/share/native/libzip/zlib/uncompr.c
index 219c1d264d5..25da59461c3 100644
--- a/src/java.base/share/native/libzip/zlib/uncompr.c
+++ b/src/java.base/share/native/libzip/zlib/uncompr.c
@@ -23,7 +23,7 @@
  */
 
 /* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -47,24 +47,24 @@
    memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
    Z_DATA_ERROR if the input data was corrupted, including if the input data is
    an incomplete zlib stream.
+
+     The _z versions of the functions take size_t length arguments.
 */
-int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
-                        uLong *sourceLen) {
+int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
+                          z_size_t *sourceLen) {
     z_stream stream;
     int err;
     const uInt max = (uInt)-1;
-    uLong len, left;
-    Byte buf[1];    /* for detection of incomplete stream when *destLen == 0 */
+    z_size_t len, left;
+
+    if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
+        destLen == NULL || (*destLen > 0 && dest == NULL))
+        return Z_STREAM_ERROR;
 
     len = *sourceLen;
-    if (*destLen) {
-        left = *destLen;
-        *destLen = 0;
-    }
-    else {
-        left = 1;
-        dest = buf;
-    }
+    left = *destLen;
+    if (left == 0 && dest == Z_NULL)
+        dest = (Bytef *)&stream.reserved;       /* next_out cannot be NULL */
 
     stream.next_in = (z_const Bytef *)source;
     stream.avail_in = 0;
@@ -80,30 +80,46 @@ int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
 
     do {
         if (stream.avail_out == 0) {
-            stream.avail_out = left > (uLong)max ? max : (uInt)left;
+            stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
             left -= stream.avail_out;
         }
         if (stream.avail_in == 0) {
-            stream.avail_in = len > (uLong)max ? max : (uInt)len;
+            stream.avail_in = len > (z_size_t)max ? max : (uInt)len;
             len -= stream.avail_in;
         }
         err = inflate(&stream, Z_NO_FLUSH);
     } while (err == Z_OK);
 
-    *sourceLen -= len + stream.avail_in;
-    if (dest != buf)
-        *destLen = stream.total_out;
-    else if (stream.total_out && err == Z_BUF_ERROR)
-        left = 1;
+    /* Set len and left to the unused input data and unused output space. Set
+       *sourceLen to the amount of input consumed. Set *destLen to the amount
+       of data produced. */
+    len += stream.avail_in;
+    left += stream.avail_out;
+    *sourceLen -= len;
+    *destLen -= left;
 
     inflateEnd(&stream);
     return err == Z_STREAM_END ? Z_OK :
            err == Z_NEED_DICT ? Z_DATA_ERROR  :
-           err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
+           err == Z_BUF_ERROR && len == 0 ? Z_DATA_ERROR :
            err;
 }
-
+int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
+                        uLong *sourceLen) {
+    int ret;
+    z_size_t got = *destLen, used = *sourceLen;
+    ret = uncompress2_z(dest, &got, source, &used);
+    *sourceLen = (uLong)used;
+    *destLen = (uLong)got;
+    return ret;
+}
+int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
+                         z_size_t sourceLen) {
+    z_size_t used = sourceLen;
+    return uncompress2_z(dest, destLen, source, &used);
+}
 int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
                        uLong sourceLen) {
-    return uncompress2(dest, destLen, source, &sourceLen);
+    uLong used = sourceLen;
+    return uncompress2(dest, destLen, source, &used);
 }
diff --git a/src/java.base/share/native/libzip/zlib/zconf.h b/src/java.base/share/native/libzip/zlib/zconf.h
index 46204222f5d..d4589739a0a 100644
--- a/src/java.base/share/native/libzip/zlib/zconf.h
+++ b/src/java.base/share/native/libzip/zlib/zconf.h
@@ -23,7 +23,7 @@
  */
 
 /* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -57,7 +57,10 @@
 #  ifndef Z_SOLO
 #    define compress              z_compress
 #    define compress2             z_compress2
+#    define compress_z            z_compress_z
+#    define compress2_z           z_compress2_z
 #    define compressBound         z_compressBound
+#    define compressBound_z       z_compressBound_z
 #  endif
 #  define crc32                 z_crc32
 #  define crc32_combine         z_crc32_combine
@@ -68,6 +71,7 @@
 #  define crc32_z               z_crc32_z
 #  define deflate               z_deflate
 #  define deflateBound          z_deflateBound
+#  define deflateBound_z        z_deflateBound_z
 #  define deflateCopy           z_deflateCopy
 #  define deflateEnd            z_deflateEnd
 #  define deflateGetDictionary  z_deflateGetDictionary
@@ -83,6 +87,7 @@
 #  define deflateSetDictionary  z_deflateSetDictionary
 #  define deflateSetHeader      z_deflateSetHeader
 #  define deflateTune           z_deflateTune
+#  define deflateUsed           z_deflateUsed
 #  define deflate_copyright     z_deflate_copyright
 #  define get_crc_table         z_get_crc_table
 #  ifndef Z_SOLO
@@ -152,9 +157,12 @@
 #  define inflate_copyright     z_inflate_copyright
 #  define inflate_fast          z_inflate_fast
 #  define inflate_table         z_inflate_table
+#  define inflate_fixed         z_inflate_fixed
 #  ifndef Z_SOLO
 #    define uncompress            z_uncompress
 #    define uncompress2           z_uncompress2
+#    define uncompress_z          z_uncompress_z
+#    define uncompress2_z         z_uncompress2_z
 #  endif
 #  define zError                z_zError
 #  ifndef Z_SOLO
@@ -258,10 +266,12 @@
 #  endif
 #endif
 
-#if defined(ZLIB_CONST) && !defined(z_const)
-#  define z_const const
-#else
-#  define z_const
+#ifndef z_const
+#  ifdef ZLIB_CONST
+#    define z_const const
+#  else
+#    define z_const
+#  endif
 #endif
 
 #ifdef Z_SOLO
@@ -457,11 +467,11 @@ typedef uLong FAR uLongf;
    typedef unsigned long z_crc_t;
 #endif
 
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#if HAVE_UNISTD_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#if HAVE_STDARG_H-0     /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_STDARG_H
 #endif
 
@@ -494,12 +504,8 @@ typedef uLong FAR uLongf;
 #endif
 
 #ifndef Z_HAVE_UNISTD_H
-#  ifdef __WATCOMC__
-#    define Z_HAVE_UNISTD_H
-#  endif
-#endif
-#ifndef Z_HAVE_UNISTD_H
-#  if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
+#  if defined(__WATCOMC__) || defined(__GO32__) || \
+      (defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
 #    define Z_HAVE_UNISTD_H
 #  endif
 #endif
@@ -534,17 +540,19 @@ typedef uLong FAR uLongf;
 #endif
 
 #ifndef z_off_t
-#  define z_off_t long
+#  define z_off_t long long
 #endif
 
 #if !defined(_WIN32) && defined(Z_LARGE64)
 #  define z_off64_t off64_t
+#elif defined(__MINGW32__)
+#  define z_off64_t long long
+#elif defined(_WIN32) && !defined(__GNUC__)
+#  define z_off64_t __int64
+#elif defined(__GO32__)
+#  define z_off64_t offset_t
 #else
-#  if defined(_WIN32) && !defined(__GNUC__)
-#    define z_off64_t __int64
-#  else
-#    define z_off64_t z_off_t
-#  endif
+#  define z_off64_t z_off_t
 #endif
 
 /* MVS linker does not support external names larger than 8 bytes */
diff --git a/src/java.base/share/native/libzip/zlib/zcrc32.c b/src/java.base/share/native/libzip/zlib/zcrc32.c
index 3f918f76b7c..133cbe158aa 100644
--- a/src/java.base/share/native/libzip/zlib/zcrc32.c
+++ b/src/java.base/share/native/libzip/zlib/zcrc32.c
@@ -23,7 +23,7 @@
  */
 
 /* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2022 Mark Adler
+ * Copyright (C) 1995-2026 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  *
  * This interleaved implementation of a CRC makes use of pipelined multiple
@@ -48,11 +48,18 @@
 #  include 
 #  ifndef DYNAMIC_CRC_TABLE
 #    define DYNAMIC_CRC_TABLE
-#  endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
+#  endif
+#endif
+#ifdef DYNAMIC_CRC_TABLE
+#  define Z_ONCE
+#endif
 
 #include "zutil.h"      /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */
 
+#ifdef HAVE_S390X_VX
+#  include "contrib/crc32vx/crc32_vx_hooks.h"
+#endif
+
  /*
   A CRC of a message is computed on N braids of words in the message, where
   each word consists of W bytes (4 or 8). If N is 3, for example, then three
@@ -123,7 +130,8 @@
 #endif
 
 /* If available, use the ARM processor CRC32 instruction. */
-#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
+#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && \
+    defined(W) && W == 8
 #  define ARMCRC32
 #endif
 
@@ -176,10 +184,10 @@ local z_word_t byte_swap(z_word_t word) {
   Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
   reflected. For speed, this requires that a not be zero.
  */
-local z_crc_t multmodp(z_crc_t a, z_crc_t b) {
-    z_crc_t m, p;
+local uLong multmodp(uLong a, uLong b) {
+    uLong m, p;
 
-    m = (z_crc_t)1 << 31;
+    m = (uLong)1 << 31;
     p = 0;
     for (;;) {
         if (a & m) {
@@ -195,12 +203,12 @@ local z_crc_t multmodp(z_crc_t a, z_crc_t b) {
 
 /*
   Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
-  initialized.
+  initialized. n must not be negative.
  */
-local z_crc_t x2nmodp(z_off64_t n, unsigned k) {
-    z_crc_t p;
+local uLong x2nmodp(z_off64_t n, unsigned k) {
+    uLong p;
 
-    p = (z_crc_t)1 << 31;           /* x^0 == 1 */
+    p = (uLong)1 << 31;             /* x^0 == 1 */
     while (n) {
         if (n & 1)
             p = multmodp(x2n_table[k & 31], p);
@@ -228,83 +236,8 @@ local z_crc_t FAR crc_table[256];
    local void write_table64(FILE *, const z_word_t FAR *, int);
 #endif /* MAKECRCH */
 
-/*
-  Define a once() function depending on the availability of atomics. If this is
-  compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in
-  multiple threads, and if atomics are not available, then get_crc_table() must
-  be called to initialize the tables and must return before any threads are
-  allowed to compute or combine CRCs.
- */
-
-/* Definition of once functionality. */
-typedef struct once_s once_t;
-
-/* Check for the availability of atomics. */
-#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
-    !defined(__STDC_NO_ATOMICS__)
-
-#include 
-
-/* Structure for once(), which must be initialized with ONCE_INIT. */
-struct once_s {
-    atomic_flag begun;
-    atomic_int done;
-};
-#define ONCE_INIT {ATOMIC_FLAG_INIT, 0}
-
-/*
-  Run the provided init() function exactly once, even if multiple threads
-  invoke once() at the same time. The state must be a once_t initialized with
-  ONCE_INIT.
- */
-local void once(once_t *state, void (*init)(void)) {
-    if (!atomic_load(&state->done)) {
-        if (atomic_flag_test_and_set(&state->begun))
-            while (!atomic_load(&state->done))
-                ;
-        else {
-            init();
-            atomic_store(&state->done, 1);
-        }
-    }
-}
-
-#else   /* no atomics */
-
-/* Structure for once(), which must be initialized with ONCE_INIT. */
-struct once_s {
-    volatile int begun;
-    volatile int done;
-};
-#define ONCE_INIT {0, 0}
-
-/* Test and set. Alas, not atomic, but tries to minimize the period of
-   vulnerability. */
-local int test_and_set(int volatile *flag) {
-    int was;
-
-    was = *flag;
-    *flag = 1;
-    return was;
-}
-
-/* Run the provided init() function once. This is not thread-safe. */
-local void once(once_t *state, void (*init)(void)) {
-    if (!state->done) {
-        if (test_and_set(&state->begun))
-            while (!state->done)
-                ;
-        else {
-            init();
-            state->done = 1;
-        }
-    }
-}
-
-#endif
-
 /* State for once(). */
-local once_t made = ONCE_INIT;
+local z_once_t made = Z_ONCE_INIT;
 
 /*
   Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -350,7 +283,7 @@ local void make_crc_table(void) {
     p = (z_crc_t)1 << 30;         /* x^1 */
     x2n_table[0] = p;
     for (n = 1; n < 32; n++)
-        x2n_table[n] = p = multmodp(p, p);
+        x2n_table[n] = p = (z_crc_t)multmodp(p, p);
 
 #ifdef W
     /* initialize the braiding tables -- needs x2n_table[] */
@@ -553,11 +486,11 @@ local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
     int k;
     z_crc_t i, p, q;
     for (k = 0; k < w; k++) {
-        p = x2nmodp((n * w + 3 - k) << 3, 0);
+        p = (z_crc_t)x2nmodp((n * w + 3 - k) << 3, 0);
         ltl[k][0] = 0;
         big[w - 1 - k][0] = 0;
         for (i = 1; i < 256; i++) {
-            ltl[k][i] = q = multmodp(i << 24, p);
+            ltl[k][i] = q = (z_crc_t)multmodp(i << 24, p);
             big[w - 1 - k][i] = byte_swap(q);
         }
     }
@@ -572,7 +505,7 @@ local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
  */
 const z_crc_t FAR * ZEXPORT get_crc_table(void) {
 #ifdef DYNAMIC_CRC_TABLE
-    once(&made, make_crc_table);
+    z_once(&made, make_crc_table);
 #endif /* DYNAMIC_CRC_TABLE */
     return (const z_crc_t FAR *)crc_table;
 }
@@ -596,9 +529,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table(void) {
 #define Z_BATCH_ZEROS 0xa10d3d0c    /* computed from Z_BATCH = 3990 */
 #define Z_BATCH_MIN 800             /* fewest words in a final batch */
 
-unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
-                              z_size_t len) {
-    z_crc_t val;
+uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
+    uLong val;
     z_word_t crc1, crc2;
     const z_word_t *word;
     z_word_t val0, val1, val2;
@@ -609,7 +541,7 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
     if (buf == Z_NULL) return 0;
 
 #ifdef DYNAMIC_CRC_TABLE
-    once(&made, make_crc_table);
+    z_once(&made, make_crc_table);
 #endif /* DYNAMIC_CRC_TABLE */
 
     /* Pre-condition the CRC */
@@ -664,7 +596,7 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
         }
         word += 3 * last;
         num -= 3 * last;
-        val = x2nmodp(last, 6);
+        val = x2nmodp((int)last, 6);
         crc = multmodp(val, crc) ^ crc1;
         crc = multmodp(val, crc) ^ crc2;
     }
@@ -715,13 +647,12 @@ local z_word_t crc_word_big(z_word_t data) {
 #endif
 
 /* ========================================================================= */
-unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
-                              z_size_t len) {
+uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
     /* Return initial CRC, if requested. */
     if (buf == Z_NULL) return 0;
 
 #ifdef DYNAMIC_CRC_TABLE
-    once(&made, make_crc_table);
+    z_once(&made, make_crc_table);
 #endif /* DYNAMIC_CRC_TABLE */
 
     /* Pre-condition the CRC */
@@ -1036,28 +967,19 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
 #endif
 
 /* ========================================================================= */
-unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
-                            uInt len) {
+uLong ZEXPORT crc32(uLong crc, const unsigned char FAR *buf, uInt len) {
+    #ifdef HAVE_S390X_VX
+    return crc32_z_hook(crc, buf, len);
+    #endif
     return crc32_z(crc, buf, len);
 }
 
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
-#ifdef DYNAMIC_CRC_TABLE
-    once(&made, make_crc_table);
-#endif /* DYNAMIC_CRC_TABLE */
-    return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
-    return crc32_combine64(crc1, crc2, (z_off64_t)len2);
-}
-
 /* ========================================================================= */
 uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
+    if (len2 < 0)
+        return 0;
 #ifdef DYNAMIC_CRC_TABLE
-    once(&made, make_crc_table);
+    z_once(&made, make_crc_table);
 #endif /* DYNAMIC_CRC_TABLE */
     return x2nmodp(len2, 3);
 }
@@ -1069,5 +991,17 @@ uLong ZEXPORT crc32_combine_gen(z_off_t len2) {
 
 /* ========================================================================= */
 uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) {
-    return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
+    if (op == 0)
+        return 0;
+    return multmodp(op, crc1 & 0xffffffff) ^ (crc2 & 0xffffffff);
+}
+
+/* ========================================================================= */
+uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
+    return crc32_combine_op(crc1, crc2, crc32_combine_gen64(len2));
+}
+
+/* ========================================================================= */
+uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
+    return crc32_combine64(crc1, crc2, (z_off64_t)len2);
 }
diff --git a/src/java.base/share/native/libzip/zlib/zlib.h b/src/java.base/share/native/libzip/zlib/zlib.h
index 07496b5f981..90230f4f23f 100644
--- a/src/java.base/share/native/libzip/zlib/zlib.h
+++ b/src/java.base/share/native/libzip/zlib/zlib.h
@@ -23,9 +23,9 @@
  */
 
 /* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.3.1, January 22nd, 2024
+  version 1.3.2, February 17th, 2026
 
-  Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
+  Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -48,24 +48,28 @@
 
 
   The data format used by the zlib library is described by RFCs (Request for
-  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+  Comments) 1950 to 1952 at https://datatracker.ietf.org/doc/html/rfc1950
   (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
 */
 
 #ifndef ZLIB_H
 #define ZLIB_H
 
-#include "zconf.h"
+#ifdef ZLIB_BUILD
+#  include 
+#else
+# include "zconf.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define ZLIB_VERSION "1.3.1"
-#define ZLIB_VERNUM 0x1310
+#define ZLIB_VERSION "1.3.2"
+#define ZLIB_VERNUM 0x1320
 #define ZLIB_VER_MAJOR 1
 #define ZLIB_VER_MINOR 3
-#define ZLIB_VER_REVISION 1
+#define ZLIB_VER_REVISION 2
 #define ZLIB_VER_SUBREVISION 0
 
 /*
@@ -465,7 +469,7 @@ ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush);
 
     The Z_BLOCK option assists in appending to or combining deflate streams.
   To assist in this, on return inflate() always sets strm->data_type to the
-  number of unused bits in the last byte taken from strm->next_in, plus 64 if
+  number of unused bits in the input taken from strm->next_in, plus 64 if
   inflate() is currently decoding the last block in the deflate stream, plus
   128 if inflate() returned immediately after decoding an end-of-block code or
   decoding the complete header up to just before the first byte of the deflate
@@ -611,18 +615,21 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
 
      The strategy parameter is used to tune the compression algorithm.  Use the
    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
-   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
-   string match), or Z_RLE to limit match distances to one (run-length
-   encoding).  Filtered data consists mostly of small values with a somewhat
-   random distribution.  In this case, the compression algorithm is tuned to
-   compress them better.  The effect of Z_FILTERED is to force more Huffman
-   coding and less string matching; it is somewhat intermediate between
-   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
-   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
-   strategy parameter only affects the compression ratio but not the
-   correctness of the compressed output even if it is not set appropriately.
-   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
-   decoder for special applications.
+   filter (or predictor), Z_RLE to limit match distances to one (run-length
+   encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string
+   matching).  Filtered data consists mostly of small values with a somewhat
+   random distribution, as produced by the PNG filters.  In this case, the
+   compression algorithm is tuned to compress them better.  The effect of
+   Z_FILTERED is to force more Huffman coding and less string matching than the
+   default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.
+   Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better
+   compression for PNG image data than Huffman only.  The degree of string
+   matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then
+   Z_HUFFMAN_ONLY. The strategy parameter affects the compression ratio but
+   never the correctness of the compressed output, even if it is not set
+   optimally for the given data.  Z_FIXED uses the default string matching, but
+   prevents the use of dynamic Huffman codes, allowing for a simpler decoder
+   for special applications.
 
      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
@@ -782,8 +789,8 @@ ZEXTERN int ZEXPORT deflateTune(z_streamp strm,
    returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
  */
 
-ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm,
-                                   uLong sourceLen);
+ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen);
+ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen);
 /*
      deflateBound() returns an upper bound on the compressed size after
    deflation of sourceLen bytes.  It must be called after deflateInit() or
@@ -795,6 +802,9 @@ ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm,
    to return Z_STREAM_END.  Note that it is possible for the compressed size to
    be larger than the value returned by deflateBound() if flush options other
    than Z_FINISH or Z_NO_FLUSH are used.
+
+     delfateBound_z() is the same, but takes and returns a size_t length.  Note
+   that a long is 32 bits on Windows.
 */
 
 ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
@@ -809,6 +819,21 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
    or bits are Z_NULL, then those values are not set.
 
      deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.  If an int is 16 bits and memLevel is 9, then
+   it is possible for the number of pending bytes to not fit in an unsigned. In
+   that case Z_BUF_ERROR is returned and *pending is set to the maximum value
+   of an unsigned.
+ */
+
+ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
+                                int *bits);
+/*
+     deflateUsed() returns in *bits the most recent number of deflate bits used
+   in the last byte when flushing to a byte boundary. The result is in 1..8, or
+   0 if there has not yet been a flush. This helps determine the location of
+   the last bit of a deflate stream.
+
+     deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
  */
 
@@ -1011,13 +1036,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
                                  int bits,
                                  int value);
 /*
-     This function inserts bits in the inflate input stream.  The intent is
-   that this function is used to start inflating at a bit position in the
-   middle of a byte.  The provided bits will be used before any bytes are used
-   from next_in.  This function should only be used with raw inflate, and
-   should be used before the first inflate() call after inflateInit2() or
-   inflateReset().  bits must be less than or equal to 16, and that many of the
-   least significant bits of value will be inserted in the input.
+     This function inserts bits in the inflate input stream.  The intent is to
+   use inflatePrime() to start inflating at a bit position in the middle of a
+   byte.  The provided bits will be used before any bytes are used from
+   next_in.  This function should be used with raw inflate, before the first
+   inflate() call, after inflateInit2() or inflateReset().  It can also be used
+   after an inflate() return indicates the end of a deflate block or header
+   when using Z_BLOCK.  bits must be less than or equal to 16, and that many of
+   the least significant bits of value will be inserted in the input.  The
+   other bits in value can be non-zero, and will be ignored.
 
      If bits is negative, then the input stream bit buffer is emptied.  Then
    inflatePrime() can be called again to put bits in the buffer.  This is used
@@ -1025,7 +1052,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
    to feeding inflate codes.
 
      inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
+   stream state was inconsistent, or if bits is out of range.  If inflate was
+   in the middle of processing a header, trailer, or stored block lengths, then
+   it is possible for there to be only eight bits available in the bit buffer.
+   In that case, bits > 8 is considered out of range.  However, when used as
+   outlined above, there will always be 16 bits available in the buffer for
+   insertion.  As noted in its documentation above, inflate records the number
+   of bits in the bit buffer on return in data_type. 32 minus that is the
+   number of bits available for insertion.  inflatePrime does not update
+   data_type with the new number of bits in buffer.
 */
 
 ZEXTERN long ZEXPORT inflateMark(z_streamp strm);
@@ -1071,20 +1106,22 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
 
      The text, time, xflags, and os fields are filled in with the gzip header
    contents.  hcrc is set to true if there is a header CRC.  (The header CRC
-   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
-   contains the maximum number of bytes to write to extra.  Once done is true,
-   extra_len contains the actual extra field length, and extra contains the
-   extra field, or that field truncated if extra_max is less than extra_len.
-   If name is not Z_NULL, then up to name_max characters are written there,
-   terminated with a zero unless the length is greater than name_max.  If
-   comment is not Z_NULL, then up to comm_max characters are written there,
-   terminated with a zero unless the length is greater than comm_max.  When any
-   of extra, name, or comment are not Z_NULL and the respective field is not
-   present in the header, then that field is set to Z_NULL to signal its
-   absence.  This allows the use of deflateSetHeader() with the returned
-   structure to duplicate the header.  However if those fields are set to
-   allocated memory, then the application will need to save those pointers
-   elsewhere so that they can be eventually freed.
+   was valid if done is set to one.)  The extra, name, and comment pointers
+   much each be either Z_NULL or point to space to store that information from
+   the header.  If extra is not Z_NULL, then extra_max contains the maximum
+   number of bytes that can be written to extra.  Once done is true, extra_len
+   contains the actual extra field length, and extra contains the extra field,
+   or that field truncated if extra_max is less than extra_len.  If name is not
+   Z_NULL, then up to name_max characters, including the terminating zero, are
+   written there.  If comment is not Z_NULL, then up to comm_max characters,
+   including the terminating zero, are written there.  The application can tell
+   that the name or comment did not fit in the provided space by the absence of
+   a terminating zero.  If any of extra, name, or comment are not present in
+   the header, then that field's pointer is set to Z_NULL.  This allows the use
+   of deflateSetHeader() with the returned structure to duplicate the header.
+   Note that if those fields initially pointed to allocated memory, then the
+   application will need to save them elsewhere so that they can be eventually
+   freed.
 
      If inflateGetHeader is not used, then the header information is simply
    discarded.  The header is always checked for validity, including the header
@@ -1232,13 +1269,14 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
      21: FASTEST -- deflate algorithm with only one, lowest compression level
      22,23: 0 (reserved)
 
-    The sprintf variant used by gzprintf (zero is best):
+    The sprintf variant used by gzprintf (all zeros is best):
      24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
-     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() is not secure!
      26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+     27: 0 = gzprintf() present, 1 = not -- 1 means gzprintf() returns an error
 
     Remainder:
-     27-31: 0 (reserved)
+     28-31: 0 (reserved)
  */
 
 #ifndef Z_SOLO
@@ -1250,11 +1288,14 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
    stream-oriented functions.  To simplify the interface, some default options
    are assumed (compression level and memory usage, standard memory allocation
    functions).  The source code of these utility functions can be modified if
-   you need special options.
+   you need special options.  The _z versions of the functions use the size_t
+   type for lengths.  Note that a long is 32 bits on Windows.
 */
 
-ZEXTERN int ZEXPORT compress(Bytef *dest,   uLongf *destLen,
+ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen,
                              const Bytef *source, uLong sourceLen);
+ZEXTERN int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen,
+                               const Bytef *source, z_size_t sourceLen);
 /*
      Compresses the source buffer into the destination buffer.  sourceLen is
    the byte length of the source buffer.  Upon entry, destLen is the total size
@@ -1268,9 +1309,12 @@ ZEXTERN int ZEXPORT compress(Bytef *dest,   uLongf *destLen,
    buffer.
 */
 
-ZEXTERN int ZEXPORT compress2(Bytef *dest,   uLongf *destLen,
+ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen,
                               const Bytef *source, uLong sourceLen,
                               int level);
+ZEXTERN int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen,
+                                const Bytef *source, z_size_t sourceLen,
+                                int level);
 /*
      Compresses the source buffer into the destination buffer.  The level
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
@@ -1285,21 +1329,24 @@ ZEXTERN int ZEXPORT compress2(Bytef *dest,   uLongf *destLen,
 */
 
 ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
+ZEXTERN z_size_t ZEXPORT compressBound_z(z_size_t sourceLen);
 /*
      compressBound() returns an upper bound on the compressed size after
    compress() or compress2() on sourceLen bytes.  It would be used before a
    compress() or compress2() call to allocate the destination buffer.
 */
 
-ZEXTERN int ZEXPORT uncompress(Bytef *dest,   uLongf *destLen,
+ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen,
                                const Bytef *source, uLong sourceLen);
+ZEXTERN int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen,
+                                 const Bytef *source, z_size_t sourceLen);
 /*
      Decompresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer.  Upon entry, destLen is the total size
+   the byte length of the source buffer.  On entry, *destLen is the total size
    of the destination buffer, which must be large enough to hold the entire
    uncompressed data.  (The size of the uncompressed data must have been saved
    previously by the compressor and transmitted to the decompressor by some
-   mechanism outside the scope of this compression library.) Upon exit, destLen
+   mechanism outside the scope of this compression library.)  On exit, *destLen
    is the actual size of the uncompressed data.
 
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
@@ -1309,8 +1356,10 @@ ZEXTERN int ZEXPORT uncompress(Bytef *dest,   uLongf *destLen,
    buffer with the uncompressed data up to that point.
 */
 
-ZEXTERN int ZEXPORT uncompress2(Bytef *dest,   uLongf *destLen,
+ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen,
                                 const Bytef *source, uLong *sourceLen);
+ZEXTERN int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen,
+                                  const Bytef *source, z_size_t *sourceLen);
 /*
      Same as uncompress, except that sourceLen is a pointer, where the
    length of the source is *sourceLen.  On return, *sourceLen is the number of
@@ -1338,13 +1387,17 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
    'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
    as in "wb9F".  (See the description of deflateInit2 for more information
    about the strategy parameter.)  'T' will request transparent writing or
-   appending with no compression and not using the gzip format.
+   appending with no compression and not using the gzip format. 'T' cannot be
+   used to force transparent reading. Transparent reading is automatically
+   performed if there is no gzip header at the start. Transparent reading can
+   be disabled with the 'G' option, which will instead return an error if there
+   is no gzip header. 'N' will open the file in non-blocking mode.
 
-     "a" can be used instead of "w" to request that the gzip stream that will
-   be written be appended to the file.  "+" will result in an error, since
+     'a' can be used instead of 'w' to request that the gzip stream that will
+   be written be appended to the file.  '+' will result in an error, since
    reading and writing to the same gzip file is not supported.  The addition of
-   "x" when writing will create the file exclusively, which fails if the file
-   already exists.  On systems that support it, the addition of "e" when
+   'x' when writing will create the file exclusively, which fails if the file
+   already exists.  On systems that support it, the addition of 'e' when
    reading or writing will set the flag to close the file on an execve() call.
 
      These functions, as well as gzip, will read and decode a sequence of gzip
@@ -1363,14 +1416,22 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
    insufficient memory to allocate the gzFile state, or if an invalid mode was
    specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
    errno can be checked to determine if the reason gzopen failed was that the
-   file could not be opened.
+   file could not be opened. Note that if 'N' is in mode for non-blocking, the
+   open() itself can fail in order to not block. In that case gzopen() will
+   return NULL and errno will be EAGAIN or ENONBLOCK. The call to gzopen() can
+   then be re-tried. If the application would like to block on opening the
+   file, then it can use open() without O_NONBLOCK, and then gzdopen() with the
+   resulting file descriptor and 'N' in the mode, which will set it to non-
+   blocking.
 */
 
 ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode);
 /*
      Associate a gzFile with the file descriptor fd.  File descriptors are
    obtained from calls like open, dup, creat, pipe or fileno (if the file has
-   been previously opened with fopen).  The mode parameter is as in gzopen.
+   been previously opened with fopen).  The mode parameter is as in gzopen. An
+   'e' in mode will set fd's flag to close the file on an execve() call. An 'N'
+   in mode will set fd's non-blocking flag.
 
      The next call of gzclose on the returned gzFile will also close the file
    descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
@@ -1440,10 +1501,16 @@ ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len);
    stream.  Alternatively, gzerror can be used before gzclose to detect this
    case.
 
+     gzread can be used to read a gzip file on a non-blocking device. If the
+   input stalls and there is no uncompressed data to return, then gzread() will
+   return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
+   called again.
+
      gzread returns the number of uncompressed bytes actually read, less than
    len for end of file, or -1 for error.  If len is too large to fit in an int,
    then nothing is read, -1 is returned, and the error state is set to
-   Z_STREAM_ERROR.
+   Z_STREAM_ERROR. If some data was read before an error, then that data is
+   returned until exhausted, after which the next call will signal the error.
 */
 
 ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
@@ -1467,15 +1534,20 @@ ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
    multiple of size, then the final partial item is nevertheless read into buf
    and the end-of-file flag is set.  The length of the partial item read is not
    provided, but could be inferred from the result of gztell().  This behavior
-   is the same as the behavior of fread() implementations in common libraries,
-   but it prevents the direct use of gzfread() to read a concurrently written
-   file, resetting and retrying on end-of-file, when size is not 1.
+   is the same as that of fread() implementations in common libraries. This
+   could result in data loss if used with size != 1 when reading a concurrently
+   written file or a non-blocking file. In that case, use size == 1 or gzread()
+   instead.
 */
 
 ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len);
 /*
      Compress and write the len uncompressed bytes at buf to file. gzwrite
-   returns the number of uncompressed bytes written or 0 in case of error.
+   returns the number of uncompressed bytes written, or 0 in case of error or
+   if len is 0.  If the write destination is non-blocking, then gzwrite() may
+   return a number of bytes written that is not 0 and less than len.
+
+     If len does not fit in an int, then 0 is returned and nothing is written.
 */
 
 ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
@@ -1490,9 +1562,18 @@ ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
    if there was an error.  If the multiplication of size and nitems overflows,
    i.e. the product does not fit in a z_size_t, then nothing is written, zero
    is returned, and the error state is set to Z_STREAM_ERROR.
+
+     If writing a concurrently read file or a non-blocking file with size != 1,
+   a partial item could be written, with no way of knowing how much of it was
+   not written, resulting in data loss.  In that case, use size == 1 or
+   gzwrite() instead.
 */
 
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
 ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
+#else
+ZEXTERN int ZEXPORTVA gzprintf();
+#endif
 /*
      Convert, format, compress, and write the arguments (...) to file under
    control of the string format, as in fprintf.  gzprintf returns the number of
@@ -1500,11 +1581,19 @@ ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
    of error.  The number of uncompressed bytes written is limited to 8191, or
    one less than the buffer size given to gzbuffer().  The caller should assure
    that this limit is not exceeded.  If it is exceeded, then gzprintf() will
-   return an error (0) with nothing written.  In this case, there may also be a
-   buffer overflow with unpredictable consequences, which is possible only if
-   zlib was compiled with the insecure functions sprintf() or vsprintf(),
-   because the secure snprintf() or vsnprintf() functions were not available.
-   This can be determined using zlibCompileFlags().
+   return an error (0) with nothing written.
+
+     In that last case, there may also be a buffer overflow with unpredictable
+   consequences, which is possible only if zlib was compiled with the insecure
+   functions sprintf() or vsprintf(), because the secure snprintf() and
+   vsnprintf() functions were not available. That would only be the case for
+   a non-ANSI C compiler. zlib may have been built without gzprintf() because
+   secure functions were not available and having gzprintf() be insecure was
+   not an option, in which case, gzprintf() returns Z_STREAM_ERROR. All of
+   these possibilities can be determined using zlibCompileFlags().
+
+     If a Z_BUF_ERROR is returned, then nothing was written due to a stall on
+   the non-blocking write destination.
 */
 
 ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
@@ -1513,6 +1602,11 @@ ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
    the terminating null character.
 
      gzputs returns the number of characters written, or -1 in case of error.
+   The number of characters written may be less than the length of the string
+   if the write destination is non-blocking.
+
+     If the length of the string does not fit in an int, then -1 is returned
+   and nothing is written.
 */
 
 ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
@@ -1525,8 +1619,13 @@ ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
    left untouched.
 
      gzgets returns buf which is a null-terminated string, or it returns NULL
-   for end-of-file or in case of error.  If there was an error, the contents at
-   buf are indeterminate.
+   for end-of-file or in case of error. If some data was read before an error,
+   then that data is returned until exhausted, after which the next call will
+   return NULL to signal the error.
+
+     gzgets can be used on a file being concurrently written, and on a non-
+   blocking device, both as for gzread(). However lines may be broken in the
+   middle, leaving it up to the application to reassemble them as needed.
 */
 
 ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
@@ -1537,11 +1636,19 @@ ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
 
 ZEXTERN int ZEXPORT gzgetc(gzFile file);
 /*
-     Read and decompress one byte from file.  gzgetc returns this byte or -1
-   in case of end of file or error.  This is implemented as a macro for speed.
-   As such, it does not do all of the checking the other functions do.  I.e.
-   it does not check to see if file is NULL, nor whether the structure file
-   points to has been clobbered or not.
+     Read and decompress one byte from file. gzgetc returns this byte or -1 in
+   case of end of file or error. If some data was read before an error, then
+   that data is returned until exhausted, after which the next call will return
+   -1 to signal the error.
+
+     This is implemented as a macro for speed. As such, it does not do all of
+   the checking the other functions do. I.e. it does not check to see if file
+   is NULL, nor whether the structure file points to has been clobbered or not.
+
+     gzgetc can be used to read a gzip file on a non-blocking device. If the
+   input stalls and there is no uncompressed data to return, then gzgetc() will
+   return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
+   called again.
 */
 
 ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
@@ -1554,6 +1661,11 @@ ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
    output buffer size of pushed characters is allowed.  (See gzbuffer above.)
    The pushed character will be discarded if the stream is repositioned with
    gzseek() or gzrewind().
+
+     gzungetc(-1, file) will force any pending seek to execute. Then gztell()
+   will report the position, even if the requested seek reached end of file.
+   This can be used to determine the number of uncompressed bytes in a gzip
+   file without having to read it into a buffer.
 */
 
 ZEXTERN int ZEXPORT gzflush(gzFile file, int flush);
@@ -1583,7 +1695,8 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
      If the file is opened for reading, this function is emulated but can be
    extremely slow.  If the file is opened for writing, only forward seeks are
    supported; gzseek then compresses a sequence of zeroes up to the new
-   starting position.
+   starting position. For reading or writing, any actual seeking is deferred
+   until the next read or write operation, or close operation when writing.
 
      gzseek returns the resulting offset location as measured in bytes from
    the beginning of the uncompressed stream, or -1 in case of error, in
@@ -1591,7 +1704,7 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
    would be before the current position.
 */
 
-ZEXTERN int ZEXPORT    gzrewind(gzFile file);
+ZEXTERN int ZEXPORT gzrewind(gzFile file);
 /*
      Rewind file. This function is supported only for reading.
 
@@ -1599,7 +1712,7 @@ ZEXTERN int ZEXPORT    gzrewind(gzFile file);
 */
 
 /*
-ZEXTERN z_off_t ZEXPORT    gztell(gzFile file);
+ZEXTERN z_off_t ZEXPORT gztell(gzFile file);
 
      Return the starting position for the next gzread or gzwrite on file.
    This position represents a number of bytes in the uncompressed data stream,
@@ -1644,8 +1757,11 @@ ZEXTERN int ZEXPORT gzdirect(gzFile file);
 
      If gzdirect() is used immediately after gzopen() or gzdopen() it will
    cause buffers to be allocated to allow reading the file to determine if it
-   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
-   gzdirect().
+   is a gzip file. Therefore if gzbuffer() is used, it should be called before
+   gzdirect(). If the input is being written concurrently or the device is non-
+   blocking, then gzdirect() may give a different answer once four bytes of
+   input have been accumulated, which is what is needed to confirm or deny a
+   gzip header. Before this, gzdirect() will return true (1).
 
      When writing, gzdirect() returns true (1) if transparent writing was
    requested ("wT" for the gzopen() mode), or false (0) otherwise.  (Note:
@@ -1655,7 +1771,7 @@ ZEXTERN int ZEXPORT gzdirect(gzFile file);
    gzip file reading and decompression, which may not be desired.)
 */
 
-ZEXTERN int ZEXPORT    gzclose(gzFile file);
+ZEXTERN int ZEXPORT gzclose(gzFile file);
 /*
      Flush all pending output for file, if necessary, close file and
    deallocate the (de)compression state.  Note that once file is closed, you
@@ -1683,9 +1799,10 @@ ZEXTERN int ZEXPORT gzclose_w(gzFile file);
 ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
 /*
      Return the error message for the last error which occurred on file.
-   errnum is set to zlib error number.  If an error occurred in the file system
-   and not in the compression library, errnum is set to Z_ERRNO and the
-   application may consult errno to get the exact error code.
+   If errnum is not NULL, *errnum is set to zlib error number.  If an error
+   occurred in the file system and not in the compression library, *errnum is
+   set to Z_ERRNO and the application may consult errno to get the exact error
+   code.
 
      The application must not modify the returned string.  Future calls to
    this function may invalidate the previously returned string.  If file is
@@ -1736,7 +1853,8 @@ ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len);
 ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf,
                                 z_size_t len);
 /*
-     Same as adler32(), but with a size_t length.
+     Same as adler32(), but with a size_t length.  Note that a long is 32 bits
+   on Windows.
 */
 
 /*
@@ -1772,7 +1890,8 @@ ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len);
 ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf,
                               z_size_t len);
 /*
-     Same as crc32(), but with a size_t length.
+     Same as crc32(), but with a size_t length.  Note that a long is 32 bits on
+   Windows.
 */
 
 /*
@@ -1782,14 +1901,14 @@ ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
    seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
    calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
    check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
-   len2. len2 must be non-negative.
+   len2. len2 must be non-negative, otherwise zero is returned.
 */
 
 /*
 ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
 
      Return the operator corresponding to length len2, to be used with
-   crc32_combine_op(). len2 must be non-negative.
+   crc32_combine_op(). len2 must be non-negative, otherwise zero is returned.
 */
 
 ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
@@ -1912,9 +2031,9 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file);       /* backward compatibility */
      ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
      ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
      ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
-     ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
-     ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
-     ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
+     ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
+     ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
+     ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
 #  endif
 #else
    ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
diff --git a/src/java.base/share/native/libzip/zlib/zutil.c b/src/java.base/share/native/libzip/zlib/zutil.c
index 92dda78497b..c57c162ffde 100644
--- a/src/java.base/share/native/libzip/zlib/zutil.c
+++ b/src/java.base/share/native/libzip/zlib/zutil.c
@@ -23,7 +23,7 @@
  */
 
 /* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2017 Jean-loup Gailly
+ * Copyright (C) 1995-2026 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -110,28 +110,36 @@ uLong ZEXPORT zlibCompileFlags(void) {
     flags += 1L << 21;
 #endif
 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifdef NO_vsnprintf
-    flags += 1L << 25;
-#    ifdef HAS_vsprintf_void
-    flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_vsnprintf_void
-    flags += 1L << 26;
-#    endif
-#  endif
+#   ifdef NO_vsnprintf
+#       ifdef ZLIB_INSECURE
+            flags += 1L << 25;
+#       else
+            flags += 1L << 27;
+#       endif
+#       ifdef HAS_vsprintf_void
+            flags += 1L << 26;
+#       endif
+#   else
+#       ifdef HAS_vsnprintf_void
+            flags += 1L << 26;
+#       endif
+#   endif
 #else
     flags += 1L << 24;
-#  ifdef NO_snprintf
-    flags += 1L << 25;
-#    ifdef HAS_sprintf_void
-    flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_snprintf_void
-    flags += 1L << 26;
-#    endif
-#  endif
+#   ifdef NO_snprintf
+#       ifdef ZLIB_INSECURE
+            flags += 1L << 25;
+#       else
+            flags += 1L << 27;
+#       endif
+#       ifdef HAS_sprintf_void
+            flags += 1L << 26;
+#       endif
+#   else
+#       ifdef HAS_snprintf_void
+            flags += 1L << 26;
+#       endif
+#   endif
 #endif
     return flags;
 }
@@ -166,28 +174,34 @@ const char * ZEXPORT zError(int err) {
 
 #ifndef HAVE_MEMCPY
 
-void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
-    if (len == 0) return;
-    do {
-        *dest++ = *source++; /* ??? to be unrolled */
-    } while (--len != 0);
+void ZLIB_INTERNAL zmemcpy(void FAR *dst, const void FAR *src, z_size_t n) {
+    uchf *p = dst;
+    const uchf *q = src;
+    while (n) {
+        *p++ = *q++;
+        n--;
+    }
 }
 
-int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
-    uInt j;
-
-    for (j = 0; j < len; j++) {
-        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
+int ZLIB_INTERNAL zmemcmp(const void FAR *s1, const void FAR *s2, z_size_t n) {
+    const uchf *p = s1, *q = s2;
+    while (n) {
+        if (*p++ != *q++)
+            return (int)p[-1] - (int)q[-1];
+        n--;
     }
     return 0;
 }
 
-void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
+void ZLIB_INTERNAL zmemzero(void FAR *b, z_size_t len) {
+    uchf *p = b;
     if (len == 0) return;
-    do {
-        *dest++ = 0;  /* ??? to be unrolled */
-    } while (--len != 0);
+    while (len) {
+        *p++ = 0;
+        len--;
+    }
 }
+
 #endif
 
 #ifndef Z_SOLO
diff --git a/src/java.base/share/native/libzip/zlib/zutil.h b/src/java.base/share/native/libzip/zlib/zutil.h
index 2b7e697bef9..b337065875d 100644
--- a/src/java.base/share/native/libzip/zlib/zutil.h
+++ b/src/java.base/share/native/libzip/zlib/zutil.h
@@ -23,7 +23,7 @@
  */
 
 /* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -60,6 +60,10 @@
    define "local" for the non-static meaning of "static", for readability
    (compile with -Dlocal if your debugger can't find static symbols) */
 
+extern const char deflate_copyright[];
+extern const char inflate_copyright[];
+extern const char inflate9_copyright[];
+
 typedef unsigned char  uch;
 typedef uch FAR uchf;
 typedef unsigned short ush;
@@ -72,6 +76,8 @@ typedef unsigned long  ulg;
 #    define Z_U8 unsigned long
 #  elif (ULLONG_MAX == 0xffffffffffffffff)
 #    define Z_U8 unsigned long long
+#  elif (ULONG_LONG_MAX == 0xffffffffffffffff)
+#    define Z_U8 unsigned long long
 #  elif (UINT_MAX == 0xffffffffffffffff)
 #    define Z_U8 unsigned
 #  endif
@@ -87,7 +93,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 /* To be used only when the state is known to be valid */
 
         /* common constants */
-
+#if MAX_WBITS < 9 || MAX_WBITS > 15
+#  error MAX_WBITS must be in 9..15
+#endif
 #ifndef DEF_WBITS
 #  define DEF_WBITS MAX_WBITS
 #endif
@@ -165,7 +173,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  define OS_CODE  7
 #endif
 
-#ifdef __acorn
+#if defined(__acorn) || defined(__riscos)
 #  define OS_CODE 13
 #endif
 
@@ -192,11 +200,10 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #endif
 
 /* provide prototypes for these when building zlib without LFS */
-#if !defined(_WIN32) && \
-    (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
-    ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
-    ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
-    ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
+#ifndef Z_LARGE64
+   ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
+   ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
+   ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
 #endif
 
         /* common defaults */
@@ -235,9 +242,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #    define zmemzero(dest, len) memset(dest, 0, len)
 #  endif
 #else
-   void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
-   int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
-   void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
+   void ZLIB_INTERNAL zmemcpy(void FAR *, const void FAR *, z_size_t);
+   int ZLIB_INTERNAL zmemcmp(const void FAR *, const void FAR *, z_size_t);
+   void ZLIB_INTERNAL zmemzero(void FAR *, z_size_t);
 #endif
 
 /* Diagnostic functions */
@@ -275,4 +282,74 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
                     (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
 
+#ifdef Z_ONCE
+/*
+  Create a local z_once() function depending on the availability of atomics.
+ */
+
+/* Check for the availability of atomics. */
+#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
+    !defined(__STDC_NO_ATOMICS__)
+
+#include 
+typedef struct {
+    atomic_flag begun;
+    atomic_int done;
+} z_once_t;
+#define Z_ONCE_INIT {ATOMIC_FLAG_INIT, 0}
+
+/*
+  Run the provided init() function exactly once, even if multiple threads
+  invoke once() at the same time. The state must be a once_t initialized with
+  Z_ONCE_INIT.
+ */
+local void z_once(z_once_t *state, void (*init)(void)) {
+    if (!atomic_load(&state->done)) {
+        if (atomic_flag_test_and_set(&state->begun))
+            while (!atomic_load(&state->done))
+                ;
+        else {
+            init();
+            atomic_store(&state->done, 1);
+        }
+    }
+}
+
+#else   /* no atomics */
+
+#warning zlib not thread-safe
+
+typedef struct z_once_s {
+    volatile int begun;
+    volatile int done;
+} z_once_t;
+#define Z_ONCE_INIT {0, 0}
+
+/* Test and set. Alas, not atomic, but tries to limit the period of
+   vulnerability. */
+local int test_and_set(int volatile *flag) {
+    int was;
+
+    was = *flag;
+    *flag = 1;
+    return was;
+}
+
+/* Run the provided init() function once. This is not thread-safe. */
+local void z_once(z_once_t *state, void (*init)(void)) {
+    if (!state->done) {
+        if (test_and_set(&state->begun))
+            while (!state->done)
+                ;
+        else {
+            init();
+            state->done = 1;
+        }
+    }
+}
+
+#endif /* ?atomics */
+
+#endif /* Z_ONCE */
+
 #endif /* ZUTIL_H */
diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template b/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
index 6823833582f..7a9a22ac40d 100644
--- a/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2026, 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
@@ -173,7 +173,5 @@ class UnixConstants {
 #ifdef __linux__
     // advice flags used with posix_fadvise(2)
     static final int PREFIX_POSIX_FADV_SEQUENTIAL = POSIX_FADV_SEQUENTIAL;
-    static final int PREFIX_POSIX_FADV_NOREUSE    = POSIX_FADV_NOREUSE;
-    static final int PREFIX_POSIX_FADV_WILLNEED   = POSIX_FADV_WILLNEED;
 #endif
 }
diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
index 77dc1851478..2d72aeb2ee9 100644
--- a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2026, 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,8 @@ class UnixNativeDispatcher {
                 return buffer;
         }
         NativeBuffers.copyCStringToNativeBuffer(cstr, buffer);
-        buffer.setOwner(path);
+        if (!Thread.currentThread().isVirtual())
+            buffer.setOwner(path);
         return buffer;
     }
 
diff --git a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c
index d2302d0c2e7..2523fb30acc 100644
--- a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c
+++ b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,16 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "childproc.h"
+#include "childproc_errorcodes.h"
 
 extern int errno;
 
@@ -41,36 +43,34 @@ extern int errno;
     void *mptr; \
     mptr = malloc (Y); \
     if (mptr == 0) { \
-        error (fdout, ERR_MALLOC); \
+        sendErrorCodeAndExit (fdout, ESTEP_JSPAWN_ALLOC_FAILED, (int)Y, errno); \
     } \
     X = mptr; \
 }
 
-#define ERR_MALLOC 1
-#define ERR_PIPE 2
-#define ERR_ARGS 3
-
 #ifndef VERSION_STRING
 #error VERSION_STRING must be defined
 #endif
 
-void error (int fd, int err) {
-    if (write (fd, &err, sizeof(err)) != sizeof(err)) {
-        /* Not sure what to do here. I have no one to speak to. */
-        exit(0x80 + err);
+/* Attempts to send an error code to the parent (which may or may not
+ * work depending on whether the fail pipe exists); then exits with an
+ * error code corresponding to the fail step. */
+void sendErrorCodeAndExit(int failpipe_fd, int step, int hint, int errno_) {
+    errcode_t errcode;
+    buildErrorCode(&errcode, step, hint, errno_);
+    if (failpipe_fd == -1 || !sendErrorCode(failpipe_fd, errcode)) {
+        /* Write error code to stdout, in the hope someone reads this. */
+        printf("jspawnhelper fail: " ERRCODE_FORMAT "\n", ERRCODE_FORMAT_ARGS(errcode));
     }
-    exit (1);
+    exit(exitCodeFromErrorCode(errcode));
 }
 
-void shutItDown() {
-    fprintf(stdout, "jspawnhelper version %s\n", VERSION_STRING);
-    fprintf(stdout, "This command is not for general use and should ");
-    fprintf(stdout, "only be run as the result of a call to\n");
-    fprintf(stdout, "ProcessBuilder.start() or Runtime.exec() in a java ");
-    fprintf(stdout, "application\n");
-    fflush(stdout);
-    _exit(1);
-}
+static const char* usageErrorText =
+    "jspawnhelper version " VERSION_STRING "\n"
+    "This command is not for general use and should "
+    "only be run as the result of a call to\n"
+    "ProcessBuilder.start() or Runtime.exec() in a java "
+    "application\n";
 
 /*
  * read the following off the pipefd
@@ -84,22 +84,31 @@ void initChildStuff (int fdin, int fdout, ChildStuff *c) {
     int bufsize, offset=0;
     int magic;
     int res;
+    const int step = ESTEP_JSPAWN_RCV_CHILDSTUFF_COMM_FAIL;
+    int substep = 0;
 
     res = readFully (fdin, &magic, sizeof(magic));
-    if (res != 4 || magic != magicNumber()) {
-        error (fdout, ERR_PIPE);
+    if (res != 4) {
+        sendErrorCodeAndExit(fdout, step, substep, errno);
+    }
+
+    substep ++;
+    if (magic != magicNumber()) {
+        sendErrorCodeAndExit(fdout, step, substep, errno);
     }
 
 #ifdef DEBUG
     jtregSimulateCrash(0, 5);
 #endif
 
+    substep ++;
     if (readFully (fdin, c, sizeof(*c)) != sizeof(*c)) {
-        error (fdout, ERR_PIPE);
+        sendErrorCodeAndExit(fdout, step, substep, errno);
     }
 
+    substep ++;
     if (readFully (fdin, &sp, sizeof(sp)) != sizeof(sp)) {
-        error (fdout, ERR_PIPE);
+        sendErrorCodeAndExit(fdout, step, substep, errno);
     }
 
     bufsize = sp.argvBytes + sp.envvBytes +
@@ -107,8 +116,9 @@ void initChildStuff (int fdin, int fdout, ChildStuff *c) {
 
     ALLOC(buf, bufsize);
 
+    substep++;
     if (readFully (fdin, buf, bufsize) != bufsize) {
-        error (fdout, ERR_PIPE);
+        sendErrorCodeAndExit(fdout, step, substep, errno);
     }
 
     /* Initialize argv[] */
@@ -139,50 +149,63 @@ void initChildStuff (int fdin, int fdout, ChildStuff *c) {
     offset += sp.parentPathvBytes;
 }
 
+#ifdef DEBUG
+static void checkIsValid(int fd) {
+    if (!fdIsValid(fd)) {
+        puts(usageErrorText);
+        sendErrorCodeAndExit(-1, ESTEP_JSPAWN_INVALID_FD, fd, errno);
+    }
+}
+static void checkIsPipe(int fd) {
+    checkIsValid(fd);
+    if (!fdIsPipe(fd)) {
+        puts(usageErrorText);
+        sendErrorCodeAndExit(-1, ESTEP_JSPAWN_NOT_A_PIPE, fd, errno);
+    }
+}
+static void checkFileDescriptorSetup() {
+    checkIsValid(STDIN_FILENO);
+    checkIsValid(STDOUT_FILENO);
+    checkIsValid(STDERR_FILENO);
+    checkIsPipe(FAIL_FILENO);
+    checkIsPipe(CHILDENV_FILENO);
+}
+#endif // DEBUG
+
 int main(int argc, char *argv[]) {
     ChildStuff c;
-    struct stat buf;
-    /* argv[1] contains the fd number to read all the child info */
-    int r, fdinr, fdinw, fdout;
 
 #ifdef DEBUG
     jtregSimulateCrash(0, 4);
 #endif
 
-    if (argc != 3) {
-        fprintf(stdout, "Incorrect number of arguments: %d\n", argc);
-        shutItDown();
+    if (argc != 2) {
+        printf("Incorrect number of arguments: %d\n", argc);
+        puts(usageErrorText);
+        sendErrorCodeAndExit(-1, ESTEP_JSPAWN_ARG_ERROR, 0, 0);
     }
 
     if (strcmp(argv[1], VERSION_STRING) != 0) {
-        fprintf(stdout, "Incorrect Java version: %s\n", argv[1]);
-        shutItDown();
+        printf("Incorrect Java version: %s\n", argv[1]);
+        puts(usageErrorText);
+        sendErrorCodeAndExit(-1, ESTEP_JSPAWN_VERSION_ERROR, 0, 0);
     }
 
-    r = sscanf (argv[2], "%d:%d:%d", &fdinr, &fdinw, &fdout);
-    if (r == 3 && fcntl(fdinr, F_GETFD) != -1 && fcntl(fdinw, F_GETFD) != -1) {
-        fstat(fdinr, &buf);
-        if (!S_ISFIFO(buf.st_mode)) {
-            fprintf(stdout, "Incorrect input pipe\n");
-            shutItDown();
-        }
-    } else {
-        fprintf(stdout, "Incorrect FD array data: %s\n", argv[2]);
-        shutItDown();
-    }
+#ifdef DEBUG
+    /* Check expected file descriptors */
+    checkFileDescriptorSetup();
+#endif
 
-    // Close the writing end of the pipe we use for reading from the parent.
-    // We have to do this before we start reading from the parent to avoid
-    // blocking in the case the parent exits before we finished reading from it.
-    close(fdinw); // Deliberately ignore errors (see https://lwn.net/Articles/576478/).
-    initChildStuff (fdinr, fdout, &c);
-    // Now set the file descriptor for the pipe's writing end to -1
-    // for the case that somebody tries to close it again.
-    assert(c.childenv[1] == fdinw);
-    c.childenv[1] = -1;
-    // The file descriptor for reporting errors back to our parent we got on the command
-    // line should be the same like the one in the ChildStuff struct we've just read.
-    assert(c.fail[1] == fdout);
+    initChildStuff(CHILDENV_FILENO, FAIL_FILENO, &c);
+
+#ifdef DEBUG
+    /* Not needed in spawn mode */
+    assert(c.in[0] == -1 && c.in[1] == -1 &&
+           c.out[0] == -1 && c.out[1] == -1 &&
+           c.err[0] == -1 && c.err[1] == -1 &&
+           c.fail[0] == -1 && c.fail[1] == -1 &&
+           c.fds[0] == -1 && c.fds[1] == -1 && c.fds[2] == -1);
+#endif
 
     childProcess (&c);
     return 0; /* NOT REACHED */
diff --git a/src/java.base/unix/native/libjava/ProcessImpl_md.c b/src/java.base/unix/native/libjava/ProcessImpl_md.c
index 12597fbb650..f7d91166e76 100644
--- a/src/java.base/unix/native/libjava/ProcessImpl_md.c
+++ b/src/java.base/unix/native/libjava/ProcessImpl_md.c
@@ -43,10 +43,13 @@
 #include 
 #include 
 #include 
-
+#include 
+#include 
+#include 
 #include 
 
 #include "childproc.h"
+#include "childproc_errorcodes.h"
 
 /*
  *
@@ -527,27 +530,46 @@ forkChild(ChildStuff *c) {
     return resultPid;
 }
 
+/* Given two fds, one of which has to be -1, the other one has to be valid,
+ * return the valid one. */
+static int eitherOneOf(int fd1, int fd2) {
+    if (fd2 == -1) {
+        assert(fdIsValid(fd1));
+        return fd1;
+    }
+    assert(fd1 == -1);
+    assert(fdIsValid(fd2));
+    return fd2;
+}
+
+static int call_posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions, int filedes, int newfiledes) {
+#ifdef __APPLE__
+    /* MacOS is not POSIX-compliant: dup2 file actions specifying the same fd as source and destination
+     * should be handled as no-op according to spec, but they cause EBADF. */
+    if (filedes == newfiledes) {
+        return 0;
+    }
+#endif
+    return posix_spawn_file_actions_adddup2(file_actions, filedes, newfiledes);
+}
+
 static pid_t
 spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) {
     pid_t resultPid;
-    int i, offset, rval, bufsize, magic;
-    char *buf, buf1[(3 * 11) + 3]; // "%d:%d:%d\0"
-    char *hlpargs[4];
+    int offset, rval, bufsize, magic;
+    char* buf;
+    char* hlpargs[3];
     SpawnInfo sp;
+    posix_spawn_file_actions_t file_actions;
+    int child_stdin, child_stdout, child_stderr, child_childenv, child_fail = -1;
 
-    /* need to tell helper which fd is for receiving the childstuff
-     * and which fd to send response back on
-     */
-    snprintf(buf1, sizeof(buf1), "%d:%d:%d", c->childenv[0], c->childenv[1], c->fail[1]);
     /* NULL-terminated argv array.
      * argv[0] contains path to jspawnhelper, to follow conventions.
      * argv[1] contains the version string as argument to jspawnhelper
-     * argv[2] contains the fd string as argument to jspawnhelper
      */
     hlpargs[0] = (char*)helperpath;
     hlpargs[1] = VERSION_STRING;
-    hlpargs[2] = buf1;
-    hlpargs[3] = NULL;
+    hlpargs[2] = NULL;
 
     /* Following items are sent down the pipe to the helper
      * after it is spawned.
@@ -570,19 +592,79 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
     bufsize += sp.dirlen;
     arraysize(parentPathv, &sp.nparentPathv, &sp.parentPathvBytes);
     bufsize += sp.parentPathvBytes;
-    /* We need to clear FD_CLOEXEC if set in the fds[].
-     * Files are created FD_CLOEXEC in Java.
-     * Otherwise, they will be closed when the target gets exec'd */
-    for (i=0; i<3; i++) {
-        if (c->fds[i] != -1) {
-            int flags = fcntl(c->fds[i], F_GETFD);
-            if (flags & FD_CLOEXEC) {
-                fcntl(c->fds[i], F_SETFD, flags & (~FD_CLOEXEC));
-            }
-        }
+
+    /* Prepare file descriptors for jspawnhelper and the target binary. */
+
+    /* 0: copy of either "in" pipe read fd or the stdin redirect fd */
+    child_stdin = eitherOneOf(c->fds[0], c->in[0]);
+
+    /* 1: copy of either "out" pipe write fd or the stdout redirect fd */
+    child_stdout = eitherOneOf(c->fds[1], c->out[1]);
+
+    /* 2: redirectErrorStream=1: redirected to child's stdout (Order matters!)
+     *    redirectErrorStream=0: copy of either "err" pipe write fd or stderr redirect fd. */
+    if (c->redirectErrorStream) {
+        child_stderr = STDOUT_FILENO; /* Note: this refers to the future stdout in the child process */
+    } else {
+        child_stderr = eitherOneOf(c->fds[2], c->err[1]);
     }
 
-    rval = posix_spawn(&resultPid, helperpath, 0, 0, (char * const *) hlpargs, environ);
+    /* 3: copy of the "fail" pipe write fd */
+    child_fail = c->fail[1];
+
+    /* 4: copy of the "childenv" pipe read end */
+    child_childenv = c->childenv[0];
+
+    assert(fdIsValid(child_stdin));
+    assert(fdIsValid(child_stdout));
+    assert(fdIsValid(child_stderr));
+    assert(fdIsPipe(child_fail));
+    assert(fdIsPipe(child_childenv));
+    /* This must always hold true, unless someone deliberately closed 0, 1, or 2 in the parent JVM. */
+    assert(child_fail > STDERR_FILENO);
+    assert(child_childenv > STDERR_FILENO);
+
+    /* Slot in dup2 file actions. */
+    posix_spawn_file_actions_init(&file_actions);
+
+#ifdef __APPLE__
+    /* On MacOS, posix_spawn does not behave in a POSIX-conform way in that the
+     * kernel closes CLOEXEC file descriptors too early for dup2 file actions to
+     * copy them after the fork. We have to explicitly prevent that by calling a
+     * propietary API. */
+    posix_spawn_file_actions_addinherit_np(&file_actions, child_stdin);
+    posix_spawn_file_actions_addinherit_np(&file_actions, child_stdout);
+    posix_spawn_file_actions_addinherit_np(&file_actions, child_stderr);
+    posix_spawn_file_actions_addinherit_np(&file_actions, child_fail);
+    posix_spawn_file_actions_addinherit_np(&file_actions, child_childenv);
+#endif
+
+    /* First dup2 stdin/out/err to 0,1,2. After this, we can safely dup2 over the
+     * original stdin/out/err. */
+    if (call_posix_spawn_file_actions_adddup2(&file_actions, child_stdin, STDIN_FILENO) != 0 ||
+        call_posix_spawn_file_actions_adddup2(&file_actions, child_stdout, STDOUT_FILENO) != 0 ||
+        /* Order matters: stderr may be redirected to stdout, so this dup2 must happen after the stdout one. */
+        call_posix_spawn_file_actions_adddup2(&file_actions, child_stderr, STDERR_FILENO) != 0)
+    {
+        return -1;
+    }
+
+    /* We dup2 with one intermediary step to prevent accidentally dup2'ing over child_childenv. */
+    const int tmp_child_childenv = child_fail < 10 ? 10 : child_fail - 1;
+    if (call_posix_spawn_file_actions_adddup2(&file_actions, child_childenv, tmp_child_childenv) != 0 ||
+        call_posix_spawn_file_actions_adddup2(&file_actions, child_fail, FAIL_FILENO) != 0 ||
+        call_posix_spawn_file_actions_adddup2(&file_actions, tmp_child_childenv, CHILDENV_FILENO) != 0)
+    {
+        return -1;
+    }
+
+    /* Since we won't use these in jspawnhelper, reset them all */
+    c->in[0] = c->in[1] = c->out[0] = c->out[1] =
+    c->err[0] = c->err[1] = c->fail[0] = c->fail[1] =
+    c->fds[0] = c->fds[1] = c->fds[2] = -1;
+    c->redirectErrorStream = false;
+
+    rval = posix_spawn(&resultPid, helperpath, &file_actions, 0, (char * const *) hlpargs, environ);
 
     if (rval != 0) {
         return -1;
@@ -666,6 +748,30 @@ startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
     }
 }
 
+static int pipeSafely(int fd[2]) {
+    /* Pipe filedescriptors must be CLOEXEC as early as possible - ideally from the point of
+     * creation on - since at any moment a concurrent (third-party) fork() could inherit copies
+     * of these descriptors and accidentally keep the pipes open. That could cause the parent
+     * process to hang (see e.g. JDK-8377907).
+     * We use pipe2(2), if we have it. If we don't, we use pipe(2) + fcntl(2) immediately.
+     * The latter is still racy and can therefore still cause hangs as described in JDK-8377907,
+     * but at least the dangerous time window is as short as we can make it.
+     */
+    int rc = -1;
+#ifdef HAVE_PIPE2
+    rc = pipe2(fd, O_CLOEXEC);
+#else
+    rc = pipe(fd);
+    if (rc == 0) {
+        fcntl(fd[0], F_SETFD, FD_CLOEXEC);
+        fcntl(fd[1], F_SETFD, FD_CLOEXEC);
+    }
+#endif /* HAVE_PIPE2 */
+    assert(fdIsCloexec(fd[0]));
+    assert(fdIsCloexec(fd[1]));
+    return rc;
+}
+
 JNIEXPORT jint JNICALL
 Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
                                        jobject process,
@@ -678,7 +784,6 @@ Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
                                        jintArray std_fds,
                                        jboolean redirectErrorStream)
 {
-    int errnum;
     int resultPid = -1;
     int in[2], out[2], err[2], fail[2], childenv[2];
     jint *fds = NULL;
@@ -727,11 +832,11 @@ Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
     fds = (*env)->GetIntArrayElements(env, std_fds, NULL);
     if (fds == NULL) goto Catch;
 
-    if ((fds[0] == -1 && pipe(in)  < 0) ||
-        (fds[1] == -1 && pipe(out) < 0) ||
-        (fds[2] == -1 && !redirectErrorStream && pipe(err) < 0) || // if not redirecting create the pipe
-        (pipe(childenv) < 0) ||
-        (pipe(fail) < 0)) {
+    if ((fds[0] == -1 && pipeSafely(in)  < 0) ||
+        (fds[1] == -1 && pipeSafely(out) < 0) ||
+        (fds[2] == -1 && !redirectErrorStream && pipeSafely(err) < 0) ||
+        (pipeSafely(childenv) < 0) ||
+        (pipeSafely(fail) < 0)) {
         throwInternalIOException(env, errno, "Bad file descriptor", mode);
         goto Catch;
     }
@@ -782,9 +887,11 @@ Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
     }
     close(fail[1]); fail[1] = -1; /* See: WhyCantJohnnyExec  (childproc.c)  */
 
+    errcode_t errcode;
+
     /* If we expect the child to ping aliveness, wait for it. */
     if (c->sendAlivePing) {
-        switch(readFully(fail[0], &errnum, sizeof(errnum))) {
+        switch(readFully(fail[0], &errcode, sizeof(errcode))) {
         case 0: /* First exec failed; */
             {
                 int tmpStatus = 0;
@@ -792,13 +899,15 @@ Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
                 throwExitCause(env, p, tmpStatus, c->mode);
                 goto Catch;
             }
-        case sizeof(errnum):
-            if (errnum != CHILD_IS_ALIVE) {
-                /* This can happen if the spawn helper encounters an error
-                 * before or during the handshake with the parent. */
-                throwInternalIOException(env, 0,
-                                         "Bad code from spawn helper (Failed to exec spawn helper)",
-                                         c->mode);
+        case sizeof(errcode):
+            if (errcode.step != ESTEP_CHILD_ALIVE) {
+                /* This can happen if the child process encounters an error
+                 * before or during initial handshake with the parent. */
+                char msg[256];
+                snprintf(msg, sizeof(msg),
+                         "Bad early code from spawn helper " ERRCODE_FORMAT " (Failed to exec spawn helper)",
+                         ERRCODE_FORMAT_ARGS(errcode));
+                throwInternalIOException(env, 0, msg, c->mode);
                 goto Catch;
             }
             break;
@@ -808,11 +917,29 @@ Java_java_lang_ProcessImpl_forkAndExec(JNIEnv *env,
         }
     }
 
-    switch (readFully(fail[0], &errnum, sizeof(errnum))) {
+    switch (readFully(fail[0], &errcode, sizeof(errcode))) {
     case 0: break; /* Exec succeeded */
-    case sizeof(errnum):
+    case sizeof(errcode):
+        /* Always reap first! */
         waitpid(resultPid, NULL, 0);
-        throwIOException(env, errnum, "Exec failed");
+        /* Most of these errors are implementation errors and should result in an internal IOE, but
+         * a few can be caused by bad user input and need to be communicated to the end user. */
+        switch(errcode.step) {
+        case ESTEP_CHDIR_FAIL:
+            throwIOException(env, errcode.errno_, "Failed to access working directory");
+            break;
+        case ESTEP_EXEC_FAIL:
+            throwIOException(env, errcode.errno_, "Exec failed");
+            break;
+        default: {
+            /* Probably implementation error */
+            char msg[256];
+            snprintf(msg, sizeof(msg),
+                     "Bad code from spawn helper " ERRCODE_FORMAT " (Failed to exec spawn helper)",
+                     ERRCODE_FORMAT_ARGS(errcode));
+            throwInternalIOException(env, 0, msg, c->mode);
+        }
+        };
         goto Catch;
     default:
         throwInternalIOException(env, errno, "Read failed", c->mode);
diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c
index 9c6334e52d2..83ee782482f 100644
--- a/src/java.base/unix/native/libjava/childproc.c
+++ b/src/java.base/unix/native/libjava/childproc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2026, 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,27 +23,56 @@
  * questions.
  */
 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include "childproc.h"
+#include "childproc_errorcodes.h"
 #include "jni_util.h"
 
 const char * const *parentPathv;
 
+#ifdef DEBUG
+bool fdIsValid(int fd) {
+    return fcntl(fd, F_GETFD) != -1;
+}
+bool fdIsPipe(int fd) {
+    struct stat buf;
+    errno = 0;
+    return fstat(fd, &buf) != -1 && S_ISFIFO(buf.st_mode);
+}
+bool fdIsCloexec(int fd) {
+    errno = 0;
+    const int flags = fcntl(fd, F_GETFD);
+    return flags != -1 && (flags & FD_CLOEXEC);
+}
+#endif // DEBUG
+
 static int
-restartableDup2(int fd_from, int fd_to)
+restartableDup2(int fd_from, int fd_to, errcode_t* errcode)
+/* All functions taking an errcode_t* as output behave the same: upon error, they populate
+ * errcode_t::hint and errcode_t::errno, but leave errcode_t::step as ESTEP_UNKNOWN since
+ * this information will be provided by the outer caller */
 {
     int err;
     RESTARTABLE(dup2(fd_from, fd_to), err);
-    return err;
+    if (err == -1) {
+        /* use fd_to (the destination descriptor) as hint: it is a bit more telling
+         * than fd_from in our case */
+        buildErrorCode(errcode, ESTEP_UNKNOWN, fd_to, errno);
+        return false;
+    }
+    return true;
 }
 
 int
@@ -52,6 +81,16 @@ closeSafely(int fd)
     return (fd == -1) ? 0 : close(fd);
 }
 
+/* Like closeSafely, but sets errcode (hint = fd, errno) on error and returns false */
+static bool
+closeSafely2(int fd, errcode_t* errcode) {
+    if (closeSafely(fd) == -1) {
+        buildErrorCode(errcode, ESTEP_UNKNOWN, fd, errno);
+        return false;
+    }
+    return true;
+}
+
 int
 markCloseOnExec(int fd)
 {
@@ -128,15 +167,19 @@ markDescriptorsCloseOnExec(void)
     return 0;
 }
 
-static int
-moveDescriptor(int fd_from, int fd_to)
+static bool
+moveDescriptor(int fd_from, int fd_to, errcode_t* errcode)
 {
     if (fd_from != fd_to) {
-        if ((restartableDup2(fd_from, fd_to) == -1) ||
-            (close(fd_from) == -1))
-            return -1;
+        if (!restartableDup2(fd_from, fd_to, errcode)) {
+            return false;
+        }
+        if (close(fd_from) == -1) {
+            buildErrorCode(errcode, ESTEP_UNKNOWN, fd_from, errno);
+            return false;
+        }
     }
-    return 0;
+    return true;
 }
 
 int
@@ -367,54 +410,81 @@ int
 childProcess(void *arg)
 {
     const ChildStuff* p = (const ChildStuff*) arg;
-    int fail_pipe_fd = p->fail[1];
 
-    if (p->sendAlivePing) {
-        /* Child shall signal aliveness to parent at the very first
-         * moment. */
-        int code = CHILD_IS_ALIVE;
-        if (writeFully(fail_pipe_fd, &code, sizeof(code)) != sizeof(code)) {
-            goto WhyCantJohnnyExec;
-        }
+    int fail_pipe_fd = (p->mode == MODE_POSIX_SPAWN) ?
+        FAIL_FILENO : /* file descriptors already set up by posix_spawn(). */
+        p->fail[1];
+
+    /* error information for WhyCantJohnnyExec */
+    errcode_t errcode;
+
+    /* Child shall signal aliveness to parent at the very first
+     * moment. */
+    if (p->sendAlivePing && !sendAlivePing(fail_pipe_fd)) {
+        buildErrorCode(&errcode, ESTEP_SENDALIVE_FAIL, fail_pipe_fd, errno);
+        goto WhyCantJohnnyExec;
     }
 
 #ifdef DEBUG
     jtregSimulateCrash(0, 6);
 #endif
-    /* Close the parent sides of the pipes.
-       Closing pipe fds here is redundant, since markDescriptorsCloseOnExec()
-       would do it anyways, but a little paranoia is a good thing. */
-    if ((closeSafely(p->in[1])   == -1) ||
-        (closeSafely(p->out[0])  == -1) ||
-        (closeSafely(p->err[0])  == -1) ||
-        (closeSafely(p->childenv[0])  == -1) ||
-        (closeSafely(p->childenv[1])  == -1) ||
-        (closeSafely(p->fail[0]) == -1))
-        goto WhyCantJohnnyExec;
 
-    /* Give the child sides of the pipes the right fileno's. */
-    /* Note: it is possible for in[0] == 0 */
-    if ((moveDescriptor(p->in[0] != -1 ?  p->in[0] : p->fds[0],
-                        STDIN_FILENO) == -1) ||
-        (moveDescriptor(p->out[1]!= -1 ? p->out[1] : p->fds[1],
-                        STDOUT_FILENO) == -1))
-        goto WhyCantJohnnyExec;
+    /* File descriptor setup for non-Posix-spawn mode */
+    if (p->mode != MODE_POSIX_SPAWN) {
 
-    if (p->redirectErrorStream) {
-        if ((closeSafely(p->err[1]) == -1) ||
-            (restartableDup2(STDOUT_FILENO, STDERR_FILENO) == -1))
+        /* Close the parent sides of the pipes.
+           Closing pipe fds here is redundant, since markDescriptorsCloseOnExec()
+           would do it anyways, but a little paranoia is a good thing. */
+        if (!closeSafely2(p->in[1], &errcode)  ||
+            !closeSafely2(p->out[0], &errcode) ||
+            !closeSafely2(p->err[0], &errcode) ||
+            !closeSafely2(p->childenv[0], &errcode) ||
+            !closeSafely2(p->childenv[1], &errcode) ||
+            !closeSafely2(p->fail[0], &errcode))
+        {
+            errcode.step = ESTEP_PIPECLOSE_FAIL;
             goto WhyCantJohnnyExec;
-    } else {
-        if (moveDescriptor(p->err[1] != -1 ? p->err[1] : p->fds[2],
-                           STDERR_FILENO) == -1)
+        }
+
+        /* Give the child sides of the pipes the right fileno's. */
+        /* Note: it is possible for in[0] == 0 */
+        if (!moveDescriptor(p->in[0] != -1 ?  p->in[0] : p->fds[0],
+                                    STDIN_FILENO, &errcode)) {
+            errcode.step = ESTEP_DUP2_STDIN_FAIL;
             goto WhyCantJohnnyExec;
-    }
+        }
 
-    if (moveDescriptor(fail_pipe_fd, FAIL_FILENO) == -1)
-        goto WhyCantJohnnyExec;
+        if (!moveDescriptor(p->out[1] != -1 ?  p->out[1] : p->fds[1],
+                                    STDOUT_FILENO, &errcode)) {
+            errcode.step = ESTEP_DUP2_STDOUT_FAIL;
+            goto WhyCantJohnnyExec;
+        }
 
-    /* We moved the fail pipe fd */
-    fail_pipe_fd = FAIL_FILENO;
+        if (p->redirectErrorStream) {
+            if (!closeSafely2(p->err[1], &errcode) ||
+                !restartableDup2(STDOUT_FILENO, STDERR_FILENO, &errcode)) {
+                errcode.step = ESTEP_DUP2_STDERR_REDIRECT_FAIL;
+                goto WhyCantJohnnyExec;
+            }
+        } else {
+            if (!moveDescriptor(p->err[1] != -1 ? p->err[1] : p->fds[2],
+                                        STDERR_FILENO, &errcode)) {
+                errcode.step = ESTEP_DUP2_STDERR_REDIRECT_FAIL;
+                goto WhyCantJohnnyExec;
+            }
+        }
+
+        if (!moveDescriptor(fail_pipe_fd, FAIL_FILENO, &errcode)) {
+            errcode.step = ESTEP_DUP2_FAILPIPE_FAIL;
+            goto WhyCantJohnnyExec;
+        }
+
+        /* We moved the fail pipe fd */
+        fail_pipe_fd = FAIL_FILENO;
+
+    } /* end: FORK/VFORK mode */
+
+    assert(fail_pipe_fd == FAIL_FILENO);
 
     /* For AIX: The code in markDescriptorsCloseOnExec() relies on the current
      * semantic of this function. When this point here is reached only the
@@ -424,14 +494,19 @@ childProcess(void *arg)
     if (markDescriptorsCloseOnExec() == -1) { /* failed,  close the old way */
         int max_fd = (int)sysconf(_SC_OPEN_MAX);
         int fd;
-        for (fd = STDERR_FILENO + 1; fd < max_fd; fd++)
-            if (markCloseOnExec(fd) == -1 && errno != EBADF)
+        for (fd = STDERR_FILENO + 1; fd < max_fd; fd++) {
+            if (markCloseOnExec(fd) == -1 && errno != EBADF) {
+                buildErrorCode(&errcode, ESTEP_CLOEXEC_FAIL, fd, errno);
                 goto WhyCantJohnnyExec;
+            }
+        }
     }
 
     /* change to the new working directory */
-    if (p->pdir != NULL && chdir(p->pdir) < 0)
+    if (p->pdir != NULL && chdir(p->pdir) < 0) {
+        buildErrorCode(&errcode, ESTEP_CHDIR_FAIL, 0, errno);
         goto WhyCantJohnnyExec;
+    }
 
     // Reset any mask signals from parent, but not in VFORK mode
     if (p->mode != MODE_VFORK) {
@@ -442,28 +517,32 @@ childProcess(void *arg)
 
     // Children should be started with default signal disposition for SIGPIPE
     if (signal(SIGPIPE, SIG_DFL) == SIG_ERR) {
+        buildErrorCode(&errcode, ESTEP_SET_SIGPIPE, 0, errno);
         goto WhyCantJohnnyExec;
     }
 
     JDK_execvpe(p->mode, p->argv[0], p->argv, p->envv);
 
+    /* Still here. Hmm. */
+    buildErrorCode(&errcode, ESTEP_EXEC_FAIL, 0, errno);
+
  WhyCantJohnnyExec:
     /* We used to go to an awful lot of trouble to predict whether the
      * child would fail, but there is no reliable way to predict the
      * success of an operation without *trying* it, and there's no way
      * to try a chdir or exec in the parent.  Instead, all we need is a
      * way to communicate any failure back to the parent.  Easy; we just
-     * send the errno back to the parent over a pipe in case of failure.
+     * send the errorcode back to the parent over a pipe in case of failure.
      * The tricky thing is, how do we communicate the *success* of exec?
      * We use FD_CLOEXEC together with the fact that a read() on a pipe
      * yields EOF when the write ends (we have two of them!) are closed.
      */
-    {
-        int errnum = errno;
-        writeFully(fail_pipe_fd, &errnum, sizeof(errnum));
+    if (!sendErrorCode(fail_pipe_fd, errcode)) {
+        printf("childproc fail: " ERRCODE_FORMAT "\n", ERRCODE_FORMAT_ARGS(errcode));
     }
+    int exitcode = exitCodeFromErrorCode(errcode);
     close(fail_pipe_fd);
-    _exit(-1);
+    _exit(exitcode);
     return 0;  /* Suppress warning "no return value from function" */
 }
 
diff --git a/src/java.base/unix/native/libjava/childproc.h b/src/java.base/unix/native/libjava/childproc.h
index 974fac3bddd..27414e60137 100644
--- a/src/java.base/unix/native/libjava/childproc.h
+++ b/src/java.base/unix/native/libjava/childproc.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2026, 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,6 +27,7 @@
 #define CHILDPROC_MD_H
 
 #include 
+#include 
 
 #ifdef __APPLE__
 #include 
@@ -72,6 +73,9 @@ extern char **environ;
 
 #define FAIL_FILENO (STDERR_FILENO + 1)
 
+/* For POSIX_SPAWN mode */
+#define CHILDENV_FILENO (FAIL_FILENO + 1)
+
 /* These numbers must be the same as the Enum in ProcessImpl.java
  * Must be a better way of doing this.
  */
@@ -107,13 +111,6 @@ typedef struct _SpawnInfo {
     int parentPathvBytes; /* total number of bytes in parentPathv array */
 } SpawnInfo;
 
-/* If ChildStuff.sendAlivePing is true, child shall signal aliveness to
- * the parent the moment it gains consciousness, before any subsequent
- * pre-exec errors could happen.
- * This code must fit into an int and not be a valid errno value on any of
- * our platforms. */
-#define CHILD_IS_ALIVE      65535
-
 /**
  * The cached and split version of the JDK's effective PATH.
  * (We don't support putenv("PATH=...") in native code)
@@ -136,6 +133,17 @@ int childProcess(void *arg);
  * See: test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java
  */
 void jtregSimulateCrash(pid_t child, int stage);
+/* Helper functions to check the state of fds */
+bool fdIsValid(int fd);
+bool fdIsPipe(int fd);
+bool fdIsCloexec(int fd);
 #endif
 
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#define HAVE_PIPE2
+#else
+// Neither MacOS nor AIX support pipe2, unfortunately
+#undef HAVE_PIPE2
 #endif
+
+#endif /* CHILDPROC_MD_H */
diff --git a/src/java.base/unix/native/libjava/childproc_errorcodes.c b/src/java.base/unix/native/libjava/childproc_errorcodes.c
new file mode 100644
index 00000000000..4dc8e927616
--- /dev/null
+++ b/src/java.base/unix/native/libjava/childproc_errorcodes.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2026, 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.
+ */
+
+#include 
+#include 
+
+#include 
+#include "childproc.h"
+#include "childproc_errorcodes.h"
+
+void buildErrorCode(errcode_t* errcode, int step, int hint, int errno_) {
+    errcode_t e;
+
+    assert(step < (1 << 8));
+    e.step = step;
+
+    assert(errno_ < (1 << 8));
+    e.errno_ = errno_;
+
+    const int maxhint = (1 << 16);
+    e.hint = hint < maxhint ? hint : maxhint;
+
+    (*errcode) = e;
+}
+
+int exitCodeFromErrorCode(errcode_t errcode) {
+    /* We use the fail step number as exit code, but avoid 0 and 1
+     * and try to avoid the [128..256) range since that one is used by
+     * shells to codify abnormal kills by signal. */
+    return 0x10 + errcode.step;
+}
+
+bool sendErrorCode(int fd, errcode_t errcode) {
+    return writeFully(fd, &errcode, sizeof(errcode)) == sizeof(errcode);
+}
+
+bool sendAlivePing(int fd) {
+    errcode_t errcode;
+    buildErrorCode(&errcode, ESTEP_CHILD_ALIVE, getpid(), 0);
+    return sendErrorCode(fd, errcode);
+}
diff --git a/src/java.base/unix/native/libjava/childproc_errorcodes.h b/src/java.base/unix/native/libjava/childproc_errorcodes.h
new file mode 100644
index 00000000000..8379db4ad2b
--- /dev/null
+++ b/src/java.base/unix/native/libjava/childproc_errorcodes.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2026, 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.
+ */
+
+#ifndef CHILDPROC_ERRORCODES_H
+#define CHILDPROC_ERRORCODES_H
+
+#include 
+#include 
+
+typedef struct errcode_t_ {
+    unsigned step : 8;
+    unsigned hint : 16;
+    unsigned errno_ : 8;
+} errcode_t;
+
+/* Helper macros for printing an errcode_t */
+#define ERRCODE_FORMAT "(%u-%u-%u)"
+#define ERRCODE_FORMAT_ARGS(errcode) errcode.step, errcode.hint, errcode.errno_
+
+
+/* Builds up an error code.
+ * Note:
+ * - hint will be capped at 2^16
+ * - both step and errno_ must fit into 8 bits. */
+void buildErrorCode(errcode_t* errcode, int step, int hint, int errno_);
+
+/* Sends an error code down a pipe. Returns true if sent successfully. */
+bool sendErrorCode(int fd, errcode_t errcode);
+
+/* Build an exit code for an errcode (used as child process exit code
+ * in addition to the errcode being sent to parent). */
+int exitCodeFromErrorCode(errcode_t errcode);
+
+/* Sends alive ping down a pipe. Returns true if sent successfully. */
+bool sendAlivePing(int fd);
+
+#define ESTEP_UNKNOWN               0
+
+/* not an error code, but an "I am alive" ping from the child.
+ * hint is child pid, errno is 0. */
+#define ESTEP_CHILD_ALIVE           255
+
+/* JspawnHelper */
+#define ESTEP_JSPAWN_ARG_ERROR                  1
+#define ESTEP_JSPAWN_VERSION_ERROR              2
+
+/* Checking file descriptor setup
+ * hint is the (16-bit-capped) fd number */
+#define ESTEP_JSPAWN_INVALID_FD                 3
+#define ESTEP_JSPAWN_NOT_A_PIPE                 4
+
+/* Allocation fail in jspawnhelper.
+ * hint is the (16-bit-capped) fail size */
+#define ESTEP_JSPAWN_ALLOC_FAILED               5
+
+/* Receiving Childstuff from parent, communication error.
+ * hint is the substep. */
+#define ESTEP_JSPAWN_RCV_CHILDSTUFF_COMM_FAIL   6
+
+/* Expand if needed ... */
+
+/* childproc() */
+
+/* Failed to send aliveness ping
+ * hint is the (16-bit-capped) fd. */
+#define ESTEP_SENDALIVE_FAIL                    10
+
+/* Failed to close a pipe in fork mode
+ * hint is the (16-bit-capped) fd. */
+#define ESTEP_PIPECLOSE_FAIL                    11
+
+/* Failed to dup2 a file descriptor in fork mode.
+ * hint is the (16-bit-capped) fd_to (!) */
+#define ESTEP_DUP2_STDIN_FAIL                   13
+#define ESTEP_DUP2_STDOUT_FAIL                  14
+#define ESTEP_DUP2_STDERR_REDIRECT_FAIL         15
+#define ESTEP_DUP2_STDERR_FAIL                  16
+#define ESTEP_DUP2_FAILPIPE_FAIL                17
+
+/* Failed to mark a file descriptor as CLOEXEC
+ * hint is the (16-bit-capped) fd */
+#define ESTEP_CLOEXEC_FAIL                      18
+
+/* Failed to chdir into the target working directory */
+#define ESTEP_CHDIR_FAIL                        19
+
+/* Failed to change signal disposition for SIGPIPE to default */
+#define ESTEP_SET_SIGPIPE                       20
+
+/* Expand if needed ... */
+
+/* All modes: exec() failed */
+#define ESTEP_EXEC_FAIL                         30
+
+#endif /* CHILDPROC_MD_H */
diff --git a/src/java.base/windows/classes/java/lang/ProcessImpl.java b/src/java.base/windows/classes/java/lang/ProcessImpl.java
index 1a08aca52e9..26d7afc5363 100644
--- a/src/java.base/windows/classes/java/lang/ProcessImpl.java
+++ b/src/java.base/windows/classes/java/lang/ProcessImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2026, 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
@@ -119,6 +119,12 @@ final class ProcessImpl extends Process {
                     stdHandles[1] = -1L;
                 } else if (redirects[1] == Redirect.INHERIT) {
                     stdHandles[1] = fdAccess.getHandle(FileDescriptor.out);
+                    if (stdHandles[1] == -1L) {
+                        // FileDescriptor.out has been closed.
+                        f1 = newFileOutputStream(Redirect.DISCARD.file(),
+                                                 Redirect.DISCARD.append());
+                        stdHandles[1] = fdAccess.getHandle(f1.getFD());
+                    }
                 } else if (redirects[1] instanceof ProcessBuilder.RedirectPipeImpl) {
                     stdHandles[1] = fdAccess.getHandle(((ProcessBuilder.RedirectPipeImpl) redirects[1]).getFd());
                     // Force getInputStream to return a null stream,
@@ -134,6 +140,12 @@ final class ProcessImpl extends Process {
                     stdHandles[2] = -1L;
                 } else if (redirects[2] == Redirect.INHERIT) {
                     stdHandles[2] = fdAccess.getHandle(FileDescriptor.err);
+                    if (stdHandles[2] == -1L) {
+                        // FileDescriptor.err has been closed.
+                        f2 = newFileOutputStream(Redirect.DISCARD.file(),
+                                                 Redirect.DISCARD.append());
+                        stdHandles[2] = fdAccess.getHandle(f2.getFD());
+                    }
                 } else if (redirects[2] instanceof ProcessBuilder.RedirectPipeImpl) {
                     stdHandles[2] = fdAccess.getHandle(((ProcessBuilder.RedirectPipeImpl) redirects[2]).getFd());
                 } else {
diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java b/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
index 8e351b7e0ef..ba1b7b1aa9f 100644
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2026, 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
@@ -1085,7 +1085,8 @@ class WindowsNativeDispatcher {
         unsafe.copyMemory(chars, Unsafe.ARRAY_CHAR_BASE_OFFSET, null,
             buffer.address(), (long)stringLengthInBytes);
         unsafe.putChar(buffer.address() + stringLengthInBytes, (char)0);
-        buffer.setOwner(s);
+        if (!Thread.currentThread().isVirtual())
+            buffer.setOwner(s);
         return buffer;
     }
 
diff --git a/src/java.base/windows/native/libjava/java_props_md.c b/src/java.base/windows/native/libjava/java_props_md.c
index e152dbe9bef..6504891af34 100644
--- a/src/java.base/windows/native/libjava/java_props_md.c
+++ b/src/java.base/windows/native/libjava/java_props_md.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2026, 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
@@ -74,43 +74,32 @@ getEncodingInternal(LCID lcid)
     case 65001:
         strcpy(ret, "UTF-8");
         break;
-    case 874:     /*  9:Thai     */
-    case 932:     /* 10:Japanese */
-    case 949:     /* 12:Korean Extended Wansung */
-    case 950:     /* 13:Chinese (Taiwan, Hongkong, Macau) */
-    case 1361:    /* 15:Korean Johab */
+    case 874:     /* Thai     */
+    case 932:     /* Japanese */
+    case 936:     /* Chinese (Simplified) */
+    case 949:     /* Korean Extended Wansung */
+    case 950:     /* Chinese (Taiwan, Hongkong, Macau) */
+    case 1361:    /* Korean Johab */
         ret[0] = 'M';
         ret[1] = 'S';
-        break;
-    case 936:
-        strcpy(ret, "GBK");
-        break;
-    case 54936:
-        strcpy(ret, "GB18030");
-        break;
-    default:
-        ret[0] = 'C';
-        ret[1] = 'p';
-        break;
-    }
 
-    //Traditional Chinese Windows should use MS950_HKSCS_XP as the
-    //default encoding, if HKSCS patch has been installed.
-    // "old" MS950 0xfa41 -> u+e001
-    // "new" MS950 0xfa41 -> u+92db
-    if (strcmp(ret, "MS950") == 0) {
-        TCHAR  mbChar[2] = {(char)0xfa, (char)0x41};
-        WCHAR  unicodeChar;
-        MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1);
-        if (unicodeChar == 0x92db) {
-            strcpy(ret, "MS950_HKSCS_XP");
-        }
-    } else {
-        //SimpChinese Windows should use GB18030 as the default
-        //encoding, if gb18030 patch has been installed (on windows
-        //2000/XP, (1)Codepage 54936 will be available
-        //(2)simsun18030.ttc will exist under system fonts dir )
-        if (strcmp(ret, "GBK") == 0 && IsValidCodePage(54936)) {
+        // Special handling for Chinese
+        if (codepage == 950) {
+            //Traditional Chinese Windows should use MS950_HKSCS_XP as the
+            //default encoding, if HKSCS patch has been installed.
+            // "old" MS950 0xfa41 -> u+e001
+            // "new" MS950 0xfa41 -> u+92db
+            TCHAR  mbChar[2] = {(char)0xfa, (char)0x41};
+            WCHAR  unicodeChar;
+            MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1);
+            if (unicodeChar == 0x92db) {
+                strcpy(ret, "MS950_HKSCS_XP");
+            }
+        } else if (codepage == 936 && IsValidCodePage(54936)) {
+            //SimpChinese Windows should use GB18030 as the default
+            //encoding, if gb18030 patch has been installed (on windows
+            //2000/XP, (1)Codepage 54936 will be available
+            //(2)simsun18030.ttc will exist under system fonts dir )
             char systemPath[MAX_PATH + 1];
             char* gb18030Font = "\\FONTS\\SimSun18030.ttc";
             FILE *f = NULL;
@@ -123,6 +112,14 @@ getEncodingInternal(LCID lcid)
                 }
             }
         }
+        break;
+    case 54936:
+        strcpy(ret, "GB18030");
+        break;
+    default:
+        ret[0] = 'C';
+        ret[1] = 'p';
+        break;
     }
 
     return ret;
diff --git a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java
index 4be159868fa..2f2a9b285f6 100644
--- a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java
+++ b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2026, 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
@@ -101,28 +101,29 @@ import javax.lang.model.SourceVersion;
  * supports, possibly an empty set.
  *
  * For a given round, the tool computes the set of annotation
- * interfaces that are present on the elements enclosed within the
- * root elements.  If there is at least one annotation interface
- * present, then as processors claim annotation interfaces, they are
- * removed from the set of unmatched annotation interfaces.  When the
- * set is empty or no more processors are available, the round has run
- * to completion.  If there are no annotation interfaces present,
- * annotation processing still occurs but only universal
+ * interfaces that are present on the elements {@linkplain
+ * RoundEnvironment#getElementsAnnotatedWith(TypeElement) included}
+ * within the root elements.  If there is at least one annotation
+ * interface present, then as processors claim annotation interfaces,
+ * they are removed from the set of unmatched annotation interfaces.
+ * When the set is empty or no more processors are available, the
+ * round has run to completion.  If there are no annotation interfaces
+ * present, annotation processing still occurs but only universal
  * processors which support processing all annotation interfaces,
  * {@code "*"}, can claim the (empty) set of annotation interfaces.
  *
  * 

An annotation interface is considered present if there is at least - * one annotation of that interface present on an element enclosed within + * one annotation of that interface present on an element included within * the root elements of a round. For this purpose, a type parameter is - * considered to be enclosed by its {@linkplain + * considered to be included by its {@linkplain * TypeParameterElement#getGenericElement generic * element}. * For this purpose, a package element is not considered to - * enclose the top-level classes and interfaces within that + * include the top-level classes and interfaces within that * package. (A root element representing a package is created when a * {@code package-info} file is processed.) Likewise, for this - * purpose, a module element is not considered to enclose the + * purpose, a module element is not considered to include the * packages within that module. (A root element representing a module * is created when a {@code module-info} file is processed.) * diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java index e7212a7e0be..f632135a899 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java @@ -74,6 +74,7 @@ public interface Types { * Types without corresponding elements include: *

    *
  • {@linkplain TypeKind#isPrimitive() primitive types} + *
  • {@linkplain TypeKind#ARRAY array types} *
  • {@linkplain TypeKind#EXECUTABLE executable types} *
  • {@linkplain TypeKind#NONE "none"} pseudo-types *
  • {@linkplain TypeKind#NULL null types} diff --git a/src/java.desktop/aix/native/libawt/porting_aix.c b/src/java.desktop/aix/native/libawt/porting_aix.c index b506ef5a44b..d8688c212d7 100644 --- a/src/java.desktop/aix/native/libawt/porting_aix.c +++ b/src/java.desktop/aix/native/libawt/porting_aix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,15 +48,14 @@ static int dladdr_dont_reload(void* addr, Dl_info* info) { if (addr >= p->ldinfo_textorg && (char*)addr < (char*)(p->ldinfo_textorg) + p->ldinfo_textsize) { info->dli_fname = p->ldinfo_filename; - info->dli_fbase = p->ldinfo_textorg; - return 1; /* [sic] */ + return 1; } if (!p->ldinfo_next) { break; } p = (struct ld_info*)(((char*)p) + p->ldinfo_next); } - return 0; /* [sic] */ + return 0; } #ifdef __cplusplus @@ -69,14 +68,14 @@ int dladdr(void *addr, Dl_info *info) { loaded = 1; } if (!addr) { - return 0; /* [sic] */ + return 0; } /* Address could be AIX function descriptor? */ void* const addr0 = *( (void**) addr ); int rc = dladdr_dont_reload(addr, info); if (rc == 0) { rc = dladdr_dont_reload(addr0, info); - if (rc == 0) { /* [sic] */ + if (rc == 0) { fill_dll_info(); /* refill, maybe loadquery info is outdated */ rc = dladdr_dont_reload(addr, info); if (rc == 0) { diff --git a/src/java.desktop/aix/native/libawt/porting_aix.h b/src/java.desktop/aix/native/libawt/porting_aix.h index 719bbaf224e..04d11590915 100644 --- a/src/java.desktop/aix/native/libawt/porting_aix.h +++ b/src/java.desktop/aix/native/libawt/porting_aix.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 SAP SE. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,36 +24,15 @@ * */ -/* - * Header file to contain porting-relevant code which does not have a - * home anywhere else. - * This is initially based on hotspot/src/os/aix/vm/{loadlib,porting}_aix.{hpp,cpp} - */ - /* * Aix' own version of dladdr(). * This function tries to mimic dladdr(3) on Linux * (see http://linux.die.net/man/3/dladdr) * dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. * - * Differences between AIX dladdr and Linux dladdr: - * - * 1) Dl_info.dli_fbase: can never work, is disabled. - * A loaded image on AIX is divided in multiple segments, at least two - * (text and data) but potentially also far more. This is because the loader may - * load each member into an own segment, as for instance happens with the libC.a - * 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a - * zero-length string is returned (""). - * 3) Dl_info.dli_saddr: For code, this will return the entry point of the function, - * not the function descriptor. */ -typedef struct { - const char *dli_fname; /* file path of loaded library */ - void *dli_fbase; /* doesn't make sense on AIX */ - const char *dli_sname; /* symbol name; "" if not known */ - void *dli_saddr; /* address of *entry* of function; not function descriptor; */ -} Dl_info; +#include "dl_info.h" #ifdef __cplusplus extern "C" diff --git a/src/java.desktop/macosx/classes/sun/font/CStrike.java b/src/java.desktop/macosx/classes/sun/font/CStrike.java index bffb76fb1ad..f7fa00070ff 100644 --- a/src/java.desktop/macosx/classes/sun/font/CStrike.java +++ b/src/java.desktop/macosx/classes/sun/font/CStrike.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -174,7 +174,19 @@ public final class CStrike extends PhysicalStrike { @Override Point2D.Float getGlyphMetrics(final int glyphCode) { - return new Point2D.Float(getGlyphAdvance(glyphCode), 0.0f); + Point2D.Float metrics = new Point2D.Float(); + long glyphPtr = getGlyphImagePtr(glyphCode); + if (glyphPtr != 0L) { + metrics.x = StrikeCache.getGlyphXAdvance(glyphPtr); + metrics.y = StrikeCache.getGlyphYAdvance(glyphPtr); + /* advance is currently in device space, need to convert back + * into user space. + * This must not include the translation component. */ + if (invDevTx != null) { + invDevTx.deltaTransform(metrics, metrics); + } + } + return metrics; } @Override diff --git a/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java b/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java index 287de9e1801..0b5e37c5ce5 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -157,11 +157,6 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { while (getRunState() < STATE_SHUTDOWN) { try { platformRunMessage(); - if (Thread.currentThread().isInterrupted()) { - if (AppContext.getAppContext().isDisposed()) { - break; - } - } } catch (Throwable t) { // TODO: log System.err.println("Exception on the toolkit thread"); @@ -456,7 +451,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { public abstract LWCursorManager getCursorManager(); public static void postEvent(AWTEvent event) { - postEvent(targetToAppContext(event.getSource()), event); + SunToolkit.postEvent(event); } @Override diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java index 494995735e6..636d8240a55 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java @@ -116,7 +116,9 @@ final class CAccessibility implements PropertyChangeListener { if (newValue instanceof Accessible) { AccessibleContext nvAC = ((Accessible) newValue).getAccessibleContext(); AccessibleRole nvRole = nvAC.getAccessibleRole(); - if (!ignoredRoles.contains(roleKey(nvRole))) { + String roleStr = nvRole == null ? null : + AWTAccessor.getAccessibleBundleAccessor().getKey(nvRole); + if (!ignoredRoles.contains(roleStr)) { focusChanged(); } } @@ -1034,8 +1036,10 @@ final class CAccessibility implements PropertyChangeListener { // "ignored", and we should skip it and its descendants if (isShowing(context)) { final AccessibleRole role = context.getAccessibleRole(); - if (role != null && ignoredRoles != null && - ignoredRoles.contains(roleKey(role))) { + String roleStr = role == null ? null : + AWTAccessor.getAccessibleBundleAccessor().getKey(role); + if (roleStr != null && ignoredRoles != null && + ignoredRoles.contains(roleStr)) { // Get the child's unignored children. _addChildren(child, whichChildren, false, childrenAndRoles, ChildrenOperations.COMMON); @@ -1096,8 +1100,6 @@ final class CAccessibility implements PropertyChangeListener { return isShowing(parentContext); } - private static native String roleKey(AccessibleRole aRole); - public static Object[] getChildren(final Accessible a, final Component c) { if (a == null) return null; return invokeAndWait(new Callable() { diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java index 30ed1d1bba0..492c32b9703 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ public final class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuIt } }); ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED); - SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event); + SunToolkit.postEvent(event); } public void setIsIndeterminate(final boolean indeterminate) { diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java index 1eb896bf291..dd0ac6e64f7 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -450,7 +450,7 @@ public final class CInputMethod extends InputMethodAdapter { aString.length(), theCaret, theCaret); - LWCToolkit.postEvent(LWCToolkit.targetToAppContext(fAwtFocussedComponent), event); + LWCToolkit.postEvent(event); fCurrentText = null; fCurrentTextAsString = null; fCurrentTextLength = 0; @@ -563,7 +563,7 @@ public final class CInputMethod extends InputMethodAdapter { 0, theCaret, visiblePosition); - LWCToolkit.postEvent(LWCToolkit.targetToAppContext(fAwtFocussedComponent), event); + LWCToolkit.postEvent(event); if (pressAndHold) selectNextGlyph(); } @@ -583,7 +583,7 @@ public final class CInputMethod extends InputMethodAdapter { fCurrentTextLength, theCaret, visiblePosition); - LWCToolkit.postEvent(LWCToolkit.targetToAppContext(fAwtFocussedComponent), event); + LWCToolkit.postEvent(event); fCurrentText = null; fCurrentTextAsString = null; fCurrentTextLength = 0; diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java index c4b2640efb8..9e3fcdb0600 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -157,7 +157,7 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { public void run() { final String cmd = ((MenuItem)getTarget()).getActionCommand(); final ActionEvent event = new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED, cmd, when, modifiers); - SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event); + SunToolkit.postEvent(event); } }); } diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java index 77639a262d5..a25b3177063 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -224,7 +224,7 @@ public final class CTrayIcon extends CFRetainedResource implements TrayIconPeer private void postEvent(final AWTEvent event) { SunToolkit.executeOnEventHandlerThread(target, new Runnable() { public void run() { - SunToolkit.postEvent(SunToolkit.targetToAppContext(target), event); + SunToolkit.postEvent(event); } }); } diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 0e5bfc44bc5..8dad6335548 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -99,7 +99,6 @@ import javax.swing.UIManager; import com.apple.laf.AquaMenuBarUI; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.CGraphicsDevice; import sun.awt.LightweightFrame; import sun.awt.PlatformGraphicsInfo; @@ -700,10 +699,9 @@ public final class LWCToolkit extends LWToolkit { }, true); - AppContext appContext = SunToolkit.targetToAppContext(component); - SunToolkit.postEvent(appContext, invocationEvent); + SunToolkit.postEvent(invocationEvent); // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock - SunToolkit.flushPendingEvents(appContext); + SunToolkit.flushPendingEvents(); doAWTRunLoop(mediator, false); checkException(invocationEvent); @@ -715,10 +713,9 @@ public final class LWCToolkit extends LWToolkit { InvocationEvent invocationEvent = new InvocationEvent(component, event); - AppContext appContext = SunToolkit.targetToAppContext(component); - SunToolkit.postEvent(SunToolkit.targetToAppContext(component), invocationEvent); + SunToolkit.postEvent(invocationEvent); // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock - SunToolkit.flushPendingEvents(appContext); + SunToolkit.flushPendingEvents(); checkException(invocationEvent); } @@ -930,7 +927,6 @@ public final class LWCToolkit extends LWToolkit { @Override public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { //TODO: FileDialog blocks excluded windows... - //TODO: Test: 2 file dialogs, separate AppContexts: a) Dialog 1 blocked, shouldn't be. Frame 4 blocked (shouldn't be). return (modalityType == null) || (modalityType == Dialog.ModalityType.MODELESS) || (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) || diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m index 460749c363d..faacef5adea 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m @@ -70,6 +70,7 @@ JNI_COCOA_ENTER(env); dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout // Asynchronous call to openURL + dispatch_retain(semaphore); [[NSWorkspace sharedWorkspace] openURLs:urls withApplicationAtURL:appURI configuration:configuration @@ -78,9 +79,11 @@ JNI_COCOA_ENTER(env); status = (OSStatus) error.code; } dispatch_semaphore_signal(semaphore); + dispatch_release(semaphore); }]; dispatch_semaphore_wait(semaphore, timeout); + dispatch_release(semaphore); JNI_COCOA_EXIT(env); return status; @@ -146,6 +149,7 @@ JNI_COCOA_ENTER(env); dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)); // 1 second timeout // Asynchronous call - openURLs:withApplicationAtURL + dispatch_retain(semaphore); [[NSWorkspace sharedWorkspace] openURLs:urls withApplicationAtURL:appURI configuration:configuration @@ -154,9 +158,11 @@ JNI_COCOA_ENTER(env); status = (OSStatus) error.code; } dispatch_semaphore_signal(semaphore); + dispatch_release(semaphore); }]; dispatch_semaphore_wait(semaphore, timeout); + dispatch_release(semaphore); [urlToOpen release]; JNI_COCOA_EXIT(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m index 051588f95bf..fa534fff275 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -270,7 +270,7 @@ JNI_COCOA_ENTER(env); NSRect fromRect = NSMakeRect(0, 0, sw, sh); NSRect toRect = NSMakeRect(0, 0, dw, dh); CImage_CopyNSImageIntoArray(img, dst, fromRect, toRect); - (*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, 0); } JNI_COCOA_EXIT(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m index bf66df162d1..fcd330940cc 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m @@ -325,20 +325,6 @@ static BOOL JavaAccessibilityIsSupportedAttribute(id element, NSString *attribut return [[element accessibilityAttributeNames] indexOfObject:attribute] != NSNotFound; } -/* - * Class: sun_lwawt_macosx_CAccessibility - * Method: roleKey - * Signature: (Ljavax/accessibility/AccessibleRole;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_sun_lwawt_macosx_CAccessibility_roleKey -(JNIEnv *env, jclass clz, jobject axRole) -{ - DECLARE_CLASS_RETURN(sjc_AccessibleRole, "javax/accessibility/AccessibleRole", NULL); - DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", NULL); - return (*env)->GetObjectField(env, axRole, sjf_key); -} - - // errors from NSAccessibilityErrors void JavaAccessibilityRaiseSetAttributeToIllegalTypeException(const char *functionName, id element, NSString *attribute, id value) { diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m index 4e2c1ace969..0f0a395c597 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -132,7 +132,7 @@ static jobject sAccessibilityClass = NULL; [rolesMap setObject:@"ImageAccessibility" forKey:@"icon"]; [rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"]; [rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"]; - [rolesMap setObject:@"StaticTextAccessibility" forKey:@"hyperlink"]; + [rolesMap setObject:@"LinkAccessibility" forKey:@"hyperlink"]; [rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"]; [rolesMap setObject:@"RadiobuttonAccessibility" forKey:@"radiobutton"]; [rolesMap setObject:@"CheckboxAccessibility" forKey:@"checkbox"]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.h new file mode 100644 index 00000000000..968e96cbb2d --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2026, 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. + */ + +#ifndef LINK_ACCESSIBILITY +#define LINK_ACCESSIBILITY + +#import "CommonTextAccessibility.h" + +#import + + +@interface LinkAccessibility : CommonTextAccessibility { + +}; +- (NSAccessibilityRole _Nonnull)accessibilityRole; +- (NSString * _Nullable)accessibilityAttributedStringForRange:(NSRange)range; +- (NSString * _Nullable)accessibilityValue; +- (NSRange)accessibilityVisibleCharacterRange; +@end +#endif diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.m new file mode 100644 index 00000000000..0de0237d03e --- /dev/null +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/LinkAccessibility.m @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#import "LinkAccessibility.h" + +@implementation LinkAccessibility + +- (NSAccessibilityRole _Nonnull)accessibilityRole +{ + return NSAccessibilityLinkRole; +} + +- (NSString * _Nullable)accessibilityAttributedStringForRange:(NSRange)range +{ + return [self accessibilityStringForRangeAttribute:range]; +} + +- (NSString * _Nullable)accessibilityValue +{ + return [self accessibilityValueAttribute]; +} + +- (NSRange)accessibilityVisibleCharacterRange +{ + return [self accessibilityVisibleCharacterRangeAttribute]; +} + +- (NSRect)accessibilityFrame +{ + return [super accessibilityFrame]; +} + +- (id)accessibilityParent +{ + return [super accessibilityParent]; +} + +@end diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java index f9a1dd7bb50..d78bcb13577 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java @@ -36,8 +36,6 @@ import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRadioButtonUI; -import sun.awt.AppContext; - /** * RadioButtonUI implementation for MotifRadioButtonUI * @@ -45,7 +43,7 @@ import sun.awt.AppContext; */ public class MotifRadioButtonUI extends BasicRadioButtonUI { - private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object(); + private static final ComponentUI UI = new MotifRadioButtonUI(); protected Color focusColor; @@ -55,14 +53,7 @@ public class MotifRadioButtonUI extends BasicRadioButtonUI { // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { - AppContext appContext = AppContext.getAppContext(); - MotifRadioButtonUI motifRadioButtonUI = - (MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY); - if (motifRadioButtonUI == null) { - motifRadioButtonUI = new MotifRadioButtonUI(); - appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI); - } - return motifRadioButtonUI; + return UI; } // ******************************** diff --git a/src/java.desktop/share/classes/java/awt/AWTEvent.java b/src/java.desktop/share/classes/java/awt/AWTEvent.java index d48fae68cbe..f365393ffb1 100644 --- a/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -554,22 +554,9 @@ public abstract class AWTEvent extends EventObject { */ void copyPrivateDataInto(AWTEvent that) { that.bdata = this.bdata; - // Copy canAccessSystemClipboard value from this into that. - if (this instanceof InputEvent && that instanceof InputEvent) { - - AWTAccessor.InputEventAccessor accessor - = AWTAccessor.getInputEventAccessor(); - - boolean b = accessor.canAccessSystemClipboard((InputEvent) this); - accessor.setCanAccessSystemClipboard((InputEvent) that, b); - } that.isSystemGenerated = this.isSystemGenerated; } void dispatched() { - if (this instanceof InputEvent) { - AWTAccessor.getInputEventAccessor(). - setCanAccessSystemClipboard((InputEvent) this, false); - } } } // class AWTEvent diff --git a/src/java.desktop/share/classes/java/awt/Color.java b/src/java.desktop/share/classes/java/awt/Color.java index 923afb91866..e129cbae23a 100644 --- a/src/java.desktop/share/classes/java/awt/Color.java +++ b/src/java.desktop/share/classes/java/awt/Color.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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 @@ -334,7 +334,7 @@ public class Color implements Paint, java.io.Serializable { * The actual color used in rendering depends * on finding the best match given the color space * available for a given output device. - * Alpha is defaulted to 255. + * Alpha defaults to 255. * * @throws IllegalArgumentException if {@code r}, {@code g} * or {@code b} are outside of the range @@ -378,12 +378,15 @@ public class Color implements Paint, java.io.Serializable { } /** - * Creates an opaque sRGB color with the specified combined RGB value - * consisting of the red component in bits 16-23, the green component - * in bits 8-15, and the blue component in bits 0-7. The actual color - * used in rendering depends on finding the best match given the - * color space available for a particular output device. Alpha is - * defaulted to 255. + * Creates an opaque sRGB color with the specified RGB value consisting of + *
      + *
    • the red component in bits 16-23, + *
    • the green component in bits 8-15, and + *
    • the blue component in bits 0-7. + *
    + * The actual color used in rendering depends on finding the best match + * given the color space available for a particular output device. Alpha + * defaults to 255. * * @param rgb the combined RGB components * @see java.awt.image.ColorModel#getRGBdefault @@ -397,14 +400,17 @@ public class Color implements Paint, java.io.Serializable { } /** - * Creates an sRGB color with the specified combined RGBA value consisting - * of the alpha component in bits 24-31, the red component in bits 16-23, - * the green component in bits 8-15, and the blue component in bits 0-7. - * If the {@code hasalpha} argument is {@code false}, alpha - * is defaulted to 255. + * Creates an sRGB color with the specified ARGB value consisting of + *
      + *
    • the alpha component in bits 24-31, + *
    • the red component in bits 16-23, + *
    • the green component in bits 8-15, and + *
    • the blue component in bits 0-7. + *
    + * If the {@code hasAlpha} argument is {@code false}, alpha defaults to 255. * - * @param rgba the combined RGBA components - * @param hasalpha {@code true} if the alpha bits are valid; + * @param argb the combined ARGB components + * @param hasAlpha {@code true} if the alpha bits are valid; * {@code false} otherwise * @see java.awt.image.ColorModel#getRGBdefault * @see #getRed @@ -413,17 +419,17 @@ public class Color implements Paint, java.io.Serializable { * @see #getAlpha * @see #getRGB */ - public Color(int rgba, boolean hasalpha) { - if (hasalpha) { - value = rgba; + public Color(int argb, boolean hasAlpha) { + if (hasAlpha) { + value = argb; } else { - value = 0xff000000 | rgba; + value = 0xff000000 | argb; } } /** * Creates an opaque sRGB color with the specified red, green, and blue - * values in the range (0.0 - 1.0). Alpha is defaulted to 1.0. The + * values in the range (0.0 - 1.0). Alpha defaults to 1.0. The * actual color used in rendering depends on finding the best * match given the color space available for a particular output * device. @@ -570,9 +576,14 @@ public class Color implements Paint, java.io.Serializable { /** * Returns the RGB value representing the color in the default sRGB - * {@link ColorModel}. - * (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are - * blue). + * {@link ColorModel}, consisting of + *
      + *
    • the alpha component in bits 24-31, + *
    • the red component in bits 16-23, + *
    • the green component in bits 8-15, and + *
    • the blue component in bits 0-7. + *
    + * * @return the RGB value of the color in the default sRGB * {@code ColorModel}. * @see java.awt.image.ColorModel#getRGBdefault diff --git a/src/java.desktop/share/classes/java/awt/Desktop.java b/src/java.desktop/share/classes/java/awt/Desktop.java index 3f73fa6cd81..43bd1f9c11c 100644 --- a/src/java.desktop/share/classes/java/awt/Desktop.java +++ b/src/java.desktop/share/classes/java/awt/Desktop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -272,6 +272,8 @@ public class Desktop { } } + private static Desktop desktop; + /** * Returns the {@code Desktop} instance of the current * desktop context. On some platforms the Desktop API may not be @@ -292,12 +294,8 @@ public class Desktop { "supported on the current platform"); } - sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); - Desktop desktop = (Desktop)context.get(Desktop.class); - if (desktop == null) { desktop = new Desktop(); - context.put(Desktop.class, desktop); } return desktop; diff --git a/src/java.desktop/share/classes/java/awt/Font.java b/src/java.desktop/share/classes/java/awt/Font.java index 0614163fb7f..cb811d5d533 100644 --- a/src/java.desktop/share/classes/java/awt/Font.java +++ b/src/java.desktop/share/classes/java/awt/Font.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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 @@ -2709,7 +2709,7 @@ public class Font implements java.io.Serializable int limit, int flags) { - GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines + GlyphLayout gl = GlyphLayout.get(); StandardGlyphVector gv = gl.layout(this, frc, text, start, limit-start, flags, null); GlyphLayout.done(gl); diff --git a/src/java.desktop/share/classes/java/awt/MediaTracker.java b/src/java.desktop/share/classes/java/awt/MediaTracker.java index f77816dc2e7..02310586c97 100644 --- a/src/java.desktop/share/classes/java/awt/MediaTracker.java +++ b/src/java.desktop/share/classes/java/awt/MediaTracker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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 @@ -184,7 +184,7 @@ public class MediaTracker implements java.io.Serializable { * @serial * @see #MediaTracker(Component) */ - Component target; + final Component target; /** * The head of the list of {@code Images} that is being * tracked by the {@code MediaTracker}. @@ -194,7 +194,7 @@ public class MediaTracker implements java.io.Serializable { * @see #removeImage(Image) */ @SuppressWarnings("serial") // Not statically typed as Serializable - MediaEntry head; + private MediaEntry head; /** * Use serialVersionUID from JDK 1.1 for interoperability. @@ -864,8 +864,8 @@ public class MediaTracker implements java.io.Serializable { } abstract class MediaEntry { - MediaTracker tracker; - int ID; + final MediaTracker tracker; + final int ID; MediaEntry next; int status; @@ -897,7 +897,7 @@ abstract class MediaEntry { return head; } - int getID() { + final int getID() { return ID; } @@ -935,12 +935,12 @@ abstract class MediaEntry { * The entry of the list of {@code Images} that is being tracked by the * {@code MediaTracker}. */ -class ImageMediaEntry extends MediaEntry implements ImageObserver, +final class ImageMediaEntry extends MediaEntry implements ImageObserver, java.io.Serializable { @SuppressWarnings("serial") // Not statically typed as Serializable - Image image; - int width; - int height; + final Image image; + final int width; + final int height; /** * Use serialVersionUID from JDK 1.1 for interoperability. @@ -959,10 +959,12 @@ java.io.Serializable { return (image == img && width == w && height == h); } + @Override Object getMedia() { return image; } + @Override synchronized int getStatus(boolean doLoad, boolean doVerify) { if (doVerify) { int flags = tracker.target.checkImage(image, width, height, null); @@ -978,6 +980,7 @@ java.io.Serializable { return super.getStatus(doLoad, doVerify); } + @Override void startLoad() { if (tracker.target.prepareImage(image, width, height, this)) { setStatus(COMPLETE); @@ -995,6 +998,7 @@ java.io.Serializable { return 0; } + @Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) { if (cancelled) { diff --git a/src/java.desktop/share/classes/java/awt/MenuComponent.java b/src/java.desktop/share/classes/java/awt/MenuComponent.java index 1391a397f82..88ebbed96da 100644 --- a/src/java.desktop/share/classes/java/awt/MenuComponent.java +++ b/src/java.desktop/share/classes/java/awt/MenuComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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,6 @@ import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.ComponentFactory; /** @@ -60,12 +59,6 @@ public abstract class MenuComponent implements java.io.Serializable { transient volatile MenuComponentPeer peer; transient volatile MenuContainer parent; - /** - * The {@code AppContext} of the {@code MenuComponent}. - * This is set in the constructor and never changes. - */ - private transient volatile AppContext appContext; - /** * The menu component's font. This value can be * {@code null} at which point a default will be used. @@ -116,15 +109,6 @@ public abstract class MenuComponent implements java.io.Serializable { static { AWTAccessor.setMenuComponentAccessor( new AWTAccessor.MenuComponentAccessor() { - @Override - public AppContext getAppContext(MenuComponent menuComp) { - return menuComp.appContext; - } - @Override - public void setAppContext(MenuComponent menuComp, - AppContext appContext) { - menuComp.appContext = appContext; - } @Override @SuppressWarnings("unchecked") public T getPeer(MenuComponent menuComp) { @@ -154,7 +138,6 @@ public abstract class MenuComponent implements java.io.Serializable { */ public MenuComponent() throws HeadlessException { GraphicsEnvironment.checkHeadless(); - appContext = AppContext.getAppContext(); } /** @@ -428,8 +411,6 @@ public abstract class MenuComponent implements java.io.Serializable { GraphicsEnvironment.checkHeadless(); s.defaultReadObject(); - - appContext = AppContext.getAppContext(); } /* diff --git a/src/java.desktop/share/classes/java/awt/ModalEventFilter.java b/src/java.desktop/share/classes/java/awt/ModalEventFilter.java index 7941be89743..93956c34fc5 100644 --- a/src/java.desktop/share/classes/java/awt/ModalEventFilter.java +++ b/src/java.desktop/share/classes/java/awt/ModalEventFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,6 @@ package java.awt; import java.awt.event.*; -import sun.awt.AppContext; - abstract class ModalEventFilter implements EventFilter { protected Dialog modalDialog; @@ -129,20 +127,14 @@ abstract class ModalEventFilter implements EventFilter { private static class ToolkitModalEventFilter extends ModalEventFilter { - private AppContext appContext; - ToolkitModalEventFilter(Dialog modalDialog) { super(modalDialog); - appContext = modalDialog.appContext; } protected FilterAction acceptWindow(Window w) { if (w.isModalExcluded(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE)) { return FilterAction.ACCEPT; } - if (w.appContext != appContext) { - return FilterAction.REJECT; - } while (w != null) { if (w == modalDialog) { return FilterAction.ACCEPT_IMMEDIATELY; @@ -155,27 +147,21 @@ abstract class ModalEventFilter implements EventFilter { private static class ApplicationModalEventFilter extends ModalEventFilter { - private AppContext appContext; - ApplicationModalEventFilter(Dialog modalDialog) { super(modalDialog); - appContext = modalDialog.appContext; } protected FilterAction acceptWindow(Window w) { if (w.isModalExcluded(Dialog.ModalExclusionType.APPLICATION_EXCLUDE)) { return FilterAction.ACCEPT; } - if (w.appContext == appContext) { - while (w != null) { - if (w == modalDialog) { - return FilterAction.ACCEPT_IMMEDIATELY; - } - w = w.getOwner(); + while (w != null) { + if (w == modalDialog) { + return FilterAction.ACCEPT_IMMEDIATELY; } - return FilterAction.REJECT; + w = w.getOwner(); } - return FilterAction.ACCEPT; + return FilterAction.REJECT; } } diff --git a/src/java.desktop/share/classes/java/awt/Robot.java b/src/java.desktop/share/classes/java/awt/Robot.java index d887cad4f77..2a489a4cbf5 100644 --- a/src/java.desktop/share/classes/java/awt/Robot.java +++ b/src/java.desktop/share/classes/java/awt/Robot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -459,6 +459,9 @@ public class Robot { * @return Color of the pixel */ public synchronized Color getPixelColor(int x, int y) { + // need to sync the toolkit prior to grabbing the pixels since in some + // cases rendering to the screen may be delayed + Toolkit.getDefaultToolkit().sync(); Point point = peer.useAbsoluteCoordinates() ? toDeviceSpaceAbs(x, y) : toDeviceSpace(x, y); return new Color(peer.getRGBPixel(point.x, point.y)); diff --git a/src/java.desktop/share/classes/java/awt/SequencedEvent.java b/src/java.desktop/share/classes/java/awt/SequencedEvent.java index 13ec5317822..25fe72e1787 100644 --- a/src/java.desktop/share/classes/java/awt/SequencedEvent.java +++ b/src/java.desktop/share/classes/java/awt/SequencedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,12 +29,11 @@ import java.io.Serial; import java.util.LinkedList; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.SunToolkit; /** * A mechanism for ensuring that a series of AWTEvents are executed in a - * precise order, even across multiple AppContexts. The nested events will be + * precise order. The nested events will be * dispatched in the order in which their wrapping SequencedEvents were * constructed. The only exception to this rule is if the peer of the target of * the nested event was destroyed (with a call to Component.removeNotify) @@ -57,7 +56,6 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { private final AWTEvent nested; @SuppressWarnings("serial") // Not statically typed as Serializable - private AppContext appContext; private boolean disposed; private final LinkedList pendingEvents = new LinkedList<>(); @@ -145,7 +143,6 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { * dispatched or disposed. If this method is invoked before all previous nested events * have been dispatched, then this method blocks until such a point is * reached. - * While waiting disposes nested events to disposed AppContext * * NOTE: Locking protocol. Since dispose() can get EventQueue lock, * dispatch() shall never call dispose() while holding the lock on the list, @@ -154,8 +151,6 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { */ public final void dispatch() { try { - appContext = AppContext.getAppContext(); - if (getFirst() != this) { if (EventQueue.isDispatchThread()) { if (Thread.currentThread() instanceof EventDispatchThread) { @@ -201,19 +196,6 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { } } - /** - * true only if event exists and nested source appContext is disposed. - */ - private static final boolean isOwnerAppContextDisposed(SequencedEvent se) { - if (se != null) { - Object target = se.nested.getSource(); - if (target instanceof Component) { - return ((Component)target).appContext.isDisposed(); - } - } - return false; - } - /** * Sequenced events are dispatched in order, so we cannot dispatch * until we are the first sequenced event in the queue (i.e. it's our @@ -224,26 +206,13 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { if (disposed) { return true; } - // getFirstWithContext can dispose this - return this == getFirstWithContext() || disposed; + return this == getFirst(); } private static final synchronized SequencedEvent getFirst() { return list.getFirst(); } - /* Disposes all events from disposed AppContext - * return first valid event - */ - private static final SequencedEvent getFirstWithContext() { - SequencedEvent first = getFirst(); - while(isOwnerAppContextDisposed(first)) { - first.dispose(); - first = getFirst(); - } - return first; - } - /** * Disposes of this instance. This method is invoked once the nested event * has been dispatched and handled, or when the peer of the target of the @@ -283,12 +252,12 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { } } // Wake up waiting threads - if (next != null && next.appContext != null) { - SunToolkit.postEvent(next.appContext, new SentEvent()); + if (next != null) { + SunToolkit.postEvent(new SentEvent()); } for(AWTEvent e : pendingEvents) { - SunToolkit.postEvent(appContext, e); + SunToolkit.postEvent(e); } } } diff --git a/src/java.desktop/share/classes/java/awt/SystemTray.java b/src/java.desktop/share/classes/java/awt/SystemTray.java index bf1871765eb..c873d849213 100644 --- a/src/java.desktop/share/classes/java/awt/SystemTray.java +++ b/src/java.desktop/share/classes/java/awt/SystemTray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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.beans.PropertyChangeSupport; import java.util.Vector; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.HeadlessToolkit; import sun.awt.SunToolkit; @@ -213,6 +212,8 @@ public class SystemTray { } } + private Vector icons; + /** * Adds a {@code TrayIcon} to the {@code SystemTray}. * The tray icon becomes visible in the system tray once it is @@ -240,15 +241,10 @@ public class SystemTray { } TrayIcon[] oldArray; TrayIcon[] newArray; - Vector icons; synchronized (this) { oldArray = systemTray.getTrayIcons(); - @SuppressWarnings("unchecked") - Vector tmp = (Vector)AppContext.getAppContext().get(TrayIcon.class); - icons = tmp; if (icons == null) { icons = new Vector<>(3); - AppContext.getAppContext().put(TrayIcon.class, icons); } else if (icons.contains(trayIcon)) { throw new IllegalArgumentException("adding TrayIcon that is already added"); @@ -291,8 +287,6 @@ public class SystemTray { TrayIcon[] newArray; synchronized (this) { oldArray = systemTray.getTrayIcons(); - @SuppressWarnings("unchecked") - Vector icons = (Vector)AppContext.getAppContext().get(TrayIcon.class); // TrayIcon with no peer is not contained in the array. if (icons == null || !icons.remove(trayIcon)) { return; @@ -320,12 +314,12 @@ public class SystemTray { * @see TrayIcon */ public TrayIcon[] getTrayIcons() { - @SuppressWarnings("unchecked") - Vector icons = (Vector)AppContext.getAppContext().get(TrayIcon.class); - if (icons != null) { - return icons.toArray(EMPTY_TRAY_ARRAY); + synchronized (this) { + if (icons != null) { + return icons.toArray(EMPTY_TRAY_ARRAY); + } + return EMPTY_TRAY_ARRAY; } - return EMPTY_TRAY_ARRAY; } /** @@ -374,8 +368,6 @@ public class SystemTray { * * *

    - * The {@code listener} listens to property changes only in this context. - *

    * If {@code listener} is {@code null}, no exception is thrown * and no action is performed. * @@ -398,8 +390,6 @@ public class SystemTray { * Removes a {@code PropertyChangeListener} from the listener list * for a specific property. *

    - * The {@code PropertyChangeListener} must be from this context. - *

    * If {@code propertyName} or {@code listener} is {@code null} or invalid, * no exception is thrown and no action is taken. * @@ -421,8 +411,6 @@ public class SystemTray { /** * Returns an array of all the listeners that have been associated * with the named property. - *

    - * Only the listeners in this context are returned. * * @param propertyName the specified property * @return all of the {@code PropertyChangeListener}s associated with @@ -461,19 +449,16 @@ public class SystemTray { getCurrentChangeSupport().firePropertyChange(propertyName, oldValue, newValue); } + private PropertyChangeSupport changeSupport; + /** - * Returns the current PropertyChangeSupport instance for the - * calling thread's context. + * Returns the current PropertyChangeSupport instance * - * @return this thread's context's PropertyChangeSupport + * @return the current PropertyChangeSupport for this {@code SystemTray} */ private synchronized PropertyChangeSupport getCurrentChangeSupport() { - PropertyChangeSupport changeSupport = - (PropertyChangeSupport)AppContext.getAppContext().get(SystemTray.class); - if (changeSupport == null) { changeSupport = new PropertyChangeSupport(this); - AppContext.getAppContext().put(SystemTray.class, changeSupport); } return changeSupport; } diff --git a/src/java.desktop/share/classes/java/awt/Toolkit.java b/src/java.desktop/share/classes/java/awt/Toolkit.java index 1ca5cdd8112..4fc9dc8e82d 100644 --- a/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,6 @@ import java.util.stream.Collectors; import javax.accessibility.AccessibilityProvider; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.HeadlessToolkit; import sun.awt.PeerEvent; import sun.awt.PlatformGraphicsInfo; @@ -2046,8 +2045,6 @@ public abstract class Toolkit { @SuppressWarnings("serial") private static class DesktopPropertyChangeSupport extends PropertyChangeSupport { - private static final StringBuilder PROP_CHANGE_SUPPORT_KEY = - new StringBuilder("desktop property change support key"); private final Object source; public DesktopPropertyChangeSupport(Object sourceBean) { @@ -2055,16 +2052,14 @@ public abstract class Toolkit { source = sourceBean; } + private static PropertyChangeSupport pcs; @Override public synchronized void addPropertyChangeListener( String propertyName, PropertyChangeListener listener) { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null == pcs) { pcs = new PropertyChangeSupport(source); - AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs); } pcs.addPropertyChangeListener(propertyName, listener); } @@ -2074,8 +2069,6 @@ public abstract class Toolkit { String propertyName, PropertyChangeListener listener) { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(propertyName, listener); } @@ -2084,8 +2077,6 @@ public abstract class Toolkit { @Override public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(); } else { @@ -2096,8 +2087,6 @@ public abstract class Toolkit { @Override public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(propertyName); } else { @@ -2107,19 +2096,14 @@ public abstract class Toolkit { @Override public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null == pcs) { pcs = new PropertyChangeSupport(source); - AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs); } pcs.addPropertyChangeListener(listener); } @Override public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(listener); } @@ -2131,33 +2115,16 @@ public abstract class Toolkit { */ @Override public void firePropertyChange(final PropertyChangeEvent evt) { + if (pcs == null) { + return; + } Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); String propertyName = evt.getPropertyName(); if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; } - Runnable updater = new Runnable() { - public void run() { - PropertyChangeSupport pcs = (PropertyChangeSupport) - AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); - if (null != pcs) { - pcs.firePropertyChange(evt); - } - } - }; - final AppContext currentAppContext = AppContext.getAppContext(); - for (AppContext appContext : AppContext.getAppContexts()) { - if (null == appContext || appContext.isDisposed()) { - continue; - } - if (currentAppContext == appContext) { - updater.run(); - } else { - final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT); - SunToolkit.postEvent(appContext, e); - } - } + pcs.firePropertyChange(evt); } } diff --git a/src/java.desktop/share/classes/java/awt/TrayIcon.java b/src/java.desktop/share/classes/java/awt/TrayIcon.java index b53174ef05e..c72c018867c 100644 --- a/src/java.desktop/share/classes/java/awt/TrayIcon.java +++ b/src/java.desktop/share/classes/java/awt/TrayIcon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +27,6 @@ package java.awt; import java.awt.event.*; import java.awt.peer.TrayIconPeer; -import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.AWTAccessor; import sun.awt.HeadlessToolkit; @@ -126,7 +125,7 @@ public class TrayIcon { if (!SystemTray.isSupported()) { throw new UnsupportedOperationException(); } - SunToolkit.insertTargetMapping(this, AppContext.getAppContext()); + SunToolkit.insertTargetMapping(this); } /** diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java b/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java index f4a39c43e04..89cde4b0ef0 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -200,6 +200,7 @@ public class ICC_ColorSpace extends ColorSpace { * the number of components in this {@code ColorSpace} * @throws NullPointerException if {@code colorvalue} is {@code null} */ + @Override public float[] toRGB(float[] colorvalue) { if (this2srgb == null) { synchronized (this) { @@ -249,6 +250,7 @@ public class ICC_ColorSpace extends ColorSpace { * @throws ArrayIndexOutOfBoundsException if array length is not at least 3 * @throws NullPointerException if {@code rgbvalue} is {@code null} */ + @Override public float[] fromRGB(float[] rgbvalue) { if (srgb2this == null) { synchronized (this) { @@ -378,6 +380,7 @@ public class ICC_ColorSpace extends ColorSpace { * the number of components in this {@code ColorSpace} * @throws NullPointerException if {@code colorvalue} is {@code null} */ + @Override public float[] toCIEXYZ(float[] colorvalue) { if (this2xyz == null) { synchronized (this) { @@ -510,6 +513,7 @@ public class ICC_ColorSpace extends ColorSpace { * @throws ArrayIndexOutOfBoundsException if array length is not at least 3 * @throws NullPointerException if {@code colorvalue} is {@code null} */ + @Override public float[] fromCIEXYZ(float[] colorvalue) { if (xyz2this == null) { synchronized (this) { @@ -560,6 +564,7 @@ public class ICC_ColorSpace extends ColorSpace { * than {@code numComponents - 1} * @since 1.4 */ + @Override public float getMinValue(int component) { rangeCheck(component); return minVal[component]; @@ -583,6 +588,7 @@ public class ICC_ColorSpace extends ColorSpace { * than {@code numComponents - 1} * @since 1.4 */ + @Override public float getMaxValue(int component) { rangeCheck(component); return maxVal[component]; diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_ProfileGray.java b/src/java.desktop/share/classes/java/awt/color/ICC_ProfileGray.java index f8de7d1581d..85b4b28b487 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_ProfileGray.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_ProfileGray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -100,6 +100,7 @@ public final class ICC_ProfileGray extends ICC_Profile { * @return an array containing the components of the mediaWhitePointTag in * the ICC profile */ + @Override public float[] getMediaWhitePoint() { return super.getMediaWhitePoint(); } diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_ProfileRGB.java b/src/java.desktop/share/classes/java/awt/color/ICC_ProfileRGB.java index 1c7fab265ac..9069c898261 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_ProfileRGB.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_ProfileRGB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -135,6 +135,7 @@ public final class ICC_ProfileRGB extends ICC_Profile { * @return a 3-element {@code float} array containing the x, y, and z * components of the profile's {@code mediaWhitePointTag} */ + @Override public float[] getMediaWhitePoint() { return super.getMediaWhitePoint(); } @@ -186,6 +187,7 @@ public final class ICC_ProfileRGB extends ICC_Profile { * @throws ProfileDataException if the profile does not specify the * corresponding TRC as a single gamma value */ + @Override public float getGamma(int component) { return super.getGamma(toTag(component)); } @@ -218,6 +220,7 @@ public final class ICC_ProfileRGB extends ICC_Profile { * @throws ProfileDataException if the profile does not specify the * corresponding TRC as a table */ + @Override public short[] getTRC(int component) { return super.getTRC(toTag(component)); } diff --git a/src/java.desktop/share/classes/java/awt/event/FocusEvent.java b/src/java.desktop/share/classes/java/awt/event/FocusEvent.java index 27da2e8b4bb..e39e9c317b0 100644 --- a/src/java.desktop/share/classes/java/awt/event/FocusEvent.java +++ b/src/java.desktop/share/classes/java/awt/event/FocusEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ import java.io.ObjectStreamException; import java.io.Serial; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.SunToolkit; /** @@ -326,21 +325,14 @@ public class FocusEvent extends ComponentEvent { * FOCUS_GAINED event, this is the Component that lost focus. For a * FOCUS_LOST event, this is the Component that gained focus. If this * focus change occurs with a native application, with a Java application - * in a different VM or context, or with no other Component, then null is + * in a different VM, or with no other Component, then null is * returned. * * @return the other Component involved in the focus change, or null * @since 1.4 */ public Component getOppositeComponent() { - if (opposite == null) { - return null; - } - - return (SunToolkit.targetToAppContext(opposite) == - AppContext.getAppContext()) - ? opposite - : null; + return opposite; } /** @@ -407,4 +399,4 @@ public class FocusEvent extends ComponentEvent { } -} \ No newline at end of file +} diff --git a/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/src/java.desktop/share/classes/java/awt/event/InputEvent.java index 9f1172916df..7517ea810e3 100644 --- a/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -309,13 +309,6 @@ public abstract sealed class InputEvent extends ComponentEvent */ int modifiers; - /* - * A flag that indicates that this instance can be used to access - * the system clipboard. - * This should be false in a headless environment, true in a headful one. - */ - private transient boolean canAccessSystemClipboard; - static { /* ensure that the necessary native libraries are loaded */ NativeLibLoader.loadLibraries(); @@ -328,15 +321,6 @@ public abstract sealed class InputEvent extends ComponentEvent return InputEvent.getButtonDownMasks(); } - public boolean canAccessSystemClipboard(InputEvent event) { - return event.canAccessSystemClipboard; - } - - @Override - public void setCanAccessSystemClipboard(InputEvent event, - boolean canAccessSystemClipboard) { - event.canAccessSystemClipboard = canAccessSystemClipboard; - } }); } @@ -381,11 +365,6 @@ public abstract sealed class InputEvent extends ComponentEvent super(source, id); this.when = when; this.modifiers = modifiers; - canAccessSystemClipboard = canAccessSystemClipboard(); - } - - private boolean canAccessSystemClipboard() { - return !GraphicsEnvironment.isHeadless(); } /** diff --git a/src/java.desktop/share/classes/java/awt/event/InputMethodEvent.java b/src/java.desktop/share/classes/java/awt/event/InputMethodEvent.java index 12ad1a03171..429d0b819f4 100644 --- a/src/java.desktop/share/classes/java/awt/event/InputMethodEvent.java +++ b/src/java.desktop/share/classes/java/awt/event/InputMethodEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import java.text.AttributedCharacterIterator; import java.text.CharacterIterator; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.SunToolkit; /** @@ -444,8 +443,7 @@ public class InputMethodEvent extends AWTEvent { // throw the IllegalArgumentException to conform to EventObject spec throw new IllegalArgumentException("null source"); } - AppContext appContext = SunToolkit.targetToAppContext(source); - EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext); + EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(); return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue); } } diff --git a/src/java.desktop/share/classes/java/awt/event/WindowEvent.java b/src/java.desktop/share/classes/java/awt/event/WindowEvent.java index d898860f153..b2dbdb4f13f 100644 --- a/src/java.desktop/share/classes/java/awt/event/WindowEvent.java +++ b/src/java.desktop/share/classes/java/awt/event/WindowEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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,7 +29,6 @@ import java.awt.Window; import java.io.Serial; import java.lang.annotation.Native; -import sun.awt.AppContext; import sun.awt.SunToolkit; /** @@ -324,21 +323,14 @@ public class WindowEvent extends ComponentEvent { * WINDOW_LOST_FOCUS event, this is the Window that gained activation or * focus. For any other type of WindowEvent, or if the focus or activation * change occurs with a native application, with a Java application in a - * different VM or context, or with no other Window, null is returned. + * different VM, or with no other Window, null is returned. * * @return the other Window involved in the focus or activation change, or * null * @since 1.4 */ public Window getOppositeWindow() { - if (opposite == null) { - return null; - } - - return (SunToolkit.targetToAppContext(opposite) == - AppContext.getAppContext()) - ? opposite - : null; + return opposite; } /** diff --git a/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java b/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java index 3aa77048f8f..884b36d4b12 100644 --- a/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java +++ b/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java @@ -422,42 +422,54 @@ public class BeanContextSupport extends BeanContextChildSupport BeanContextChild cbcc = getChildBeanContextChild(targetChild); BeanContextChild bccp = null; - synchronized(targetChild) { + if (targetChild instanceof BeanContextProxy) { + bccp = ((BeanContextProxy)targetChild).getBeanContextProxy(); - if (targetChild instanceof BeanContextProxy) { - bccp = ((BeanContextProxy)targetChild).getBeanContextProxy(); + if (bccp == null) throw new NullPointerException("BeanContextPeer.getBeanContextProxy()"); + } - if (bccp == null) throw new NullPointerException("BeanContextPeer.getBeanContextProxy()"); - } + BCSChild bcsc = createBCSChild(targetChild, bccp); + BCSChild pbcsc = null; - BCSChild bcsc = createBCSChild(targetChild, bccp); - BCSChild pbcsc = null; + synchronized (children) { + children.put(targetChild, bcsc); - synchronized (children) { - children.put(targetChild, bcsc); + if (bccp != null) children.put(bccp, pbcsc = createBCSChild(bccp, targetChild)); + } - if (bccp != null) children.put(bccp, pbcsc = createBCSChild(bccp, targetChild)); - } + if (cbcc != null) synchronized(cbcc) { + try { + cbcc.setBeanContext(getBeanContextPeer()); + } catch (PropertyVetoException pve) { - if (cbcc != null) synchronized(cbcc) { - try { - cbcc.setBeanContext(getBeanContextPeer()); - } catch (PropertyVetoException pve) { + synchronized (children) { + children.remove(targetChild); - synchronized (children) { - children.remove(targetChild); - - if (bccp != null) children.remove(bccp); - } - - throw new IllegalStateException(); + if (bccp != null) children.remove(bccp); } - cbcc.addPropertyChangeListener("beanContext", childPCL); - cbcc.addVetoableChangeListener("beanContext", childVCL); + throw new IllegalStateException(); } - Visibility v = getChildVisibility(targetChild); + cbcc.addPropertyChangeListener("beanContext", childPCL); + cbcc.addVetoableChangeListener("beanContext", childVCL); + } + + Visibility v = getChildVisibility(targetChild); + + if (v != null) { + if (okToUseGui) + v.okToUseGui(); + else + v.dontUseGui(); + } + + if (getChildSerializable(targetChild) != null) serializable++; + + childJustAddedHook(targetChild, bcsc); + + if (bccp != null) { + v = getChildVisibility(bccp); if (v != null) { if (okToUseGui) @@ -466,26 +478,9 @@ public class BeanContextSupport extends BeanContextChildSupport v.dontUseGui(); } - if (getChildSerializable(targetChild) != null) serializable++; - - childJustAddedHook(targetChild, bcsc); - - if (bccp != null) { - v = getChildVisibility(bccp); - - if (v != null) { - if (okToUseGui) - v.okToUseGui(); - else - v.dontUseGui(); - } - - if (getChildSerializable(bccp) != null) serializable++; - - childJustAddedHook(bccp, pbcsc); - } - + if (getChildSerializable(bccp) != null) serializable++; + childJustAddedHook(bccp, pbcsc); } // The specification requires that we fire a notification of the change @@ -536,42 +531,40 @@ public class BeanContextSupport extends BeanContextChildSupport // we are required to notify the child that it is no longer nested here if // it implements java.beans.beancontext.BeanContextChild - synchronized(targetChild) { - if (callChildSetBC) { - BeanContextChild cbcc = getChildBeanContextChild(targetChild); - if (cbcc != null) synchronized(cbcc) { - cbcc.removePropertyChangeListener("beanContext", childPCL); - cbcc.removeVetoableChangeListener("beanContext", childVCL); - - try { - cbcc.setBeanContext(null); - } catch (PropertyVetoException pve1) { - cbcc.addPropertyChangeListener("beanContext", childPCL); - cbcc.addVetoableChangeListener("beanContext", childVCL); - throw new IllegalStateException(); - } + if (callChildSetBC) { + BeanContextChild cbcc = getChildBeanContextChild(targetChild); + if (cbcc != null) synchronized(cbcc) { + cbcc.removePropertyChangeListener("beanContext", childPCL); + cbcc.removeVetoableChangeListener("beanContext", childVCL); + try { + cbcc.setBeanContext(null); + } catch (PropertyVetoException pve1) { + cbcc.addPropertyChangeListener("beanContext", childPCL); + cbcc.addVetoableChangeListener("beanContext", childVCL); + throw new IllegalStateException(); } + } + } - synchronized (children) { - children.remove(targetChild); + synchronized (children) { + children.remove(targetChild); - if (bcsc.isProxyPeer()) { - pbcsc = children.get(peer = bcsc.getProxyPeer()); - children.remove(peer); - } + if (bcsc.isProxyPeer()) { + pbcsc = children.get(peer = bcsc.getProxyPeer()); + children.remove(peer); } + } - if (getChildSerializable(targetChild) != null) serializable--; + if (getChildSerializable(targetChild) != null) serializable--; - childJustRemovedHook(targetChild, bcsc); + childJustRemovedHook(targetChild, bcsc); - if (peer != null) { - if (getChildSerializable(peer) != null) serializable--; + if (peer != null) { + if (getChildSerializable(peer) != null) serializable--; - childJustRemovedHook(peer, pbcsc); - } + childJustRemovedHook(peer, pbcsc); } fireChildrenRemoved(new BeanContextMembershipEvent(getBeanContextPeer(), peer == null ? new Object[] { targetChild } : new Object[] { targetChild, peer } )); diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java index 0481060f73f..25dbb7ddaca 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -114,6 +114,7 @@ public final class Chromaticity extends EnumSyntax /** * Returns the string table for class {@code Chromaticity}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -121,6 +122,7 @@ public final class Chromaticity extends EnumSyntax /** * Returns the enumeration value table for class {@code Chromaticity}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -135,6 +137,7 @@ public final class Chromaticity extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Chromaticity.class; } @@ -148,6 +151,7 @@ public final class Chromaticity extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "chromaticity"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java index 6affb3e28dc..8ce2c5eef7c 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -104,6 +104,7 @@ public final class ColorSupported extends EnumSyntax /** * Returns the string table for class {@code ColorSupported}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -111,6 +112,7 @@ public final class ColorSupported extends EnumSyntax /** * Returns the enumeration value table for class {@code ColorSupported}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -125,6 +127,7 @@ public final class ColorSupported extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return ColorSupported.class; } @@ -138,6 +141,7 @@ public final class ColorSupported extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "color-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java index b1e7f1e89fc..9eeab5d9688 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,6 +106,7 @@ public class Compression extends EnumSyntax implements DocAttribute { /** * Returns the string table for class {@code Compression}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -113,6 +114,7 @@ public class Compression extends EnumSyntax implements DocAttribute { /** * Returns the enumeration value table for class {@code Compression}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -127,6 +129,7 @@ public class Compression extends EnumSyntax implements DocAttribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Compression.class; } @@ -140,6 +143,7 @@ public class Compression extends EnumSyntax implements DocAttribute { * * @return attribute category name */ + @Override public final String getName() { return "compression"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java index 33a98c035be..6292cc4c8c2 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -97,6 +97,7 @@ public final class Copies extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this copies * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return super.equals (object) && object instanceof Copies; } @@ -110,6 +111,7 @@ public final class Copies extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Copies.class; } @@ -122,6 +124,7 @@ public final class Copies extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "copies"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java index e7b411d8e55..3c2cf4bb550 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -105,6 +105,7 @@ public final class CopiesSupported extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this copies * supported attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return super.equals (object) && object instanceof CopiesSupported; } @@ -119,6 +120,7 @@ public final class CopiesSupported extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return CopiesSupported.class; } @@ -132,6 +134,7 @@ public final class CopiesSupported extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "copies-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java index 4e0a3b27259..a7a31dacd8d 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -88,6 +88,7 @@ public final class DateTimeAtCompleted extends DateTimeSyntax * @return {@code true} if {@code object} is equivalent to this date-time at * completed attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return(super.equals (object) && object instanceof DateTimeAtCompleted); @@ -105,6 +106,7 @@ public final class DateTimeAtCompleted extends DateTimeSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DateTimeAtCompleted.class; } @@ -118,6 +120,7 @@ public final class DateTimeAtCompleted extends DateTimeSyntax * * @return attribute category name */ + @Override public final String getName() { return "date-time-at-completed"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java index fc09f0672c2..53b85b7cf5c 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -88,6 +88,7 @@ public final class DateTimeAtCreation extends DateTimeSyntax * @return {@code true} if {@code object} is equivalent to this date-time at * creation attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return(super.equals (object) && object instanceof DateTimeAtCreation); @@ -103,6 +104,7 @@ public final class DateTimeAtCreation extends DateTimeSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DateTimeAtCreation.class; } @@ -116,6 +118,7 @@ public final class DateTimeAtCreation extends DateTimeSyntax * * @return attribute category name */ + @Override public final String getName() { return "date-time-at-creation"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java index 8b1f3efdc0f..310f3f756c7 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,7 @@ public final class DateTimeAtProcessing extends DateTimeSyntax * @return {@code true} if {@code object} is equivalent to this date-time at * processing attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return(super.equals (object) && object instanceof DateTimeAtProcessing); @@ -104,6 +105,7 @@ public final class DateTimeAtProcessing extends DateTimeSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DateTimeAtProcessing.class; } @@ -117,6 +119,7 @@ public final class DateTimeAtProcessing extends DateTimeSyntax * * @return attribute category name */ + @Override public final String getName() { return "date-time-at-processing"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java index bc1d240c9c1..655a314b136 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,7 @@ public final class Destination extends URISyntax * @return {@code true} if {@code object} is equivalent to this destination * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof Destination); @@ -104,6 +105,7 @@ public final class Destination extends URISyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Destination.class; } @@ -117,6 +119,7 @@ public final class Destination extends URISyntax * * @return attribute category name */ + @Override public final String getName() { return "spool-data-destination"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DialogOwner.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DialogOwner.java index 593e656cf6b..01a410d075b 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DialogOwner.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DialogOwner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -50,6 +50,7 @@ public final class DialogOwner implements PrintRequestAttribute { private static class Accessor extends DialogOwnerAccessor { + @Override public long getOwnerID(DialogOwner owner) { return owner.getID(); } @@ -133,6 +134,7 @@ public final class DialogOwner implements PrintRequestAttribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DialogOwner.class; } @@ -145,6 +147,7 @@ public final class DialogOwner implements PrintRequestAttribute { * {@code "dialog-owner"}. * */ + @Override public final String getName() { return "dialog-owner"; diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java index ae3195d0280..2cf003060b1 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -98,6 +98,7 @@ public final class DialogTypeSelection extends EnumSyntax /** * Returns the string table for class {@code DialogTypeSelection}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -106,6 +107,7 @@ public final class DialogTypeSelection extends EnumSyntax * Returns the enumeration value table for class * {@code DialogTypeSelection}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -120,6 +122,7 @@ public final class DialogTypeSelection extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DialogTypeSelection.class; } @@ -133,6 +136,7 @@ public final class DialogTypeSelection extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "dialog-type-selection"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java index eb2bd7a870d..bd1f574e4ba 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -86,6 +86,7 @@ public final class DocumentName extends TextSyntax implements DocAttribute { * @return {@code true} if {@code object} is equivalent to this document * name attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof DocumentName); } @@ -100,6 +101,7 @@ public final class DocumentName extends TextSyntax implements DocAttribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return DocumentName.class; } @@ -113,6 +115,7 @@ public final class DocumentName extends TextSyntax implements DocAttribute { * * @return attribute category name */ + @Override public final String getName() { return "document-name"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java index b0e4b70c87c..8c8941c76c4 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -101,6 +101,7 @@ public final class Fidelity extends EnumSyntax /** * Returns the string table for class {@code Fidelity}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -108,6 +109,7 @@ public final class Fidelity extends EnumSyntax /** * Returns the enumeration value table for class {@code Fidelity}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -122,6 +124,7 @@ public final class Fidelity extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Fidelity.class; } @@ -135,6 +138,7 @@ public final class Fidelity extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "ipp-attribute-fidelity"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java index 46d520ecb48..7d9d042b3e7 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -344,6 +344,7 @@ public class Finishings extends EnumSyntax /** * Returns the string table for class {@code Finishings}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -351,6 +352,7 @@ public class Finishings extends EnumSyntax /** * Returns the enumeration value table for class {@code Finishings}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -358,6 +360,7 @@ public class Finishings extends EnumSyntax /** * Returns the lowest integer value used by class {@code Finishings}. */ + @Override protected int getOffset() { return 3; } @@ -372,6 +375,7 @@ public class Finishings extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Finishings.class; } @@ -385,6 +389,7 @@ public class Finishings extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "finishings"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java index d4e2c2625df..2b9ede6940f 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -123,6 +123,7 @@ public final class JobHoldUntil extends DateTimeSyntax * @return {@code true} if {@code object} is equivalent to this job hold * until attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof JobHoldUntil); } @@ -137,6 +138,7 @@ public final class JobHoldUntil extends DateTimeSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobHoldUntil.class; } @@ -150,6 +152,7 @@ public final class JobHoldUntil extends DateTimeSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-hold-until"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java index ed9600838be..70d7c7e5e46 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -110,6 +110,7 @@ public final class JobImpressions extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job * impressions attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return super.equals (object) && object instanceof JobImpressions; } @@ -124,6 +125,7 @@ public final class JobImpressions extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobImpressions.class; } @@ -137,6 +139,7 @@ public final class JobImpressions extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-impressions"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java index 4974f9e13c9..e6fdeb93d05 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobImpressionsCompleted extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job * impressions completed attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return(super.equals (object) && object instanceof JobImpressionsCompleted); @@ -109,6 +110,7 @@ public final class JobImpressionsCompleted extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobImpressionsCompleted.class; } @@ -122,6 +124,7 @@ public final class JobImpressionsCompleted extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-impressions-completed"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java index 131b19f5ad2..82b3049b8bd 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this job * impressions supported attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobImpressionsSupported); @@ -109,6 +110,7 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobImpressionsSupported.class; } @@ -122,6 +124,7 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-impressions-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java index 454a30a3a28..acd04fab21d 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -159,6 +159,7 @@ public final class JobKOctets extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job K octets * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return super.equals(object) && object instanceof JobKOctets; } @@ -173,6 +174,7 @@ public final class JobKOctets extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobKOctets.class; } @@ -186,6 +188,7 @@ public final class JobKOctets extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-k-octets"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java index 9acc44f5777..efd9cac2441 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -104,6 +104,7 @@ public final class JobKOctetsProcessed extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job K octets * processed attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return(super.equals (object) && object instanceof JobKOctetsProcessed); @@ -119,6 +120,7 @@ public final class JobKOctetsProcessed extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobKOctetsProcessed.class; } @@ -132,6 +134,7 @@ public final class JobKOctetsProcessed extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-k-octets-processed"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java index 032d172d6e2..221328caeb8 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -93,6 +93,7 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this job K octets * supported attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobKOctetsSupported); @@ -108,6 +109,7 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobKOctetsSupported.class; } @@ -121,6 +123,7 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-k-octets-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java index a3720748f68..181bda79826 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -101,6 +101,7 @@ public class JobMediaSheets extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job media * sheets attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return super.equals(object) && object instanceof JobMediaSheets; } @@ -115,6 +116,7 @@ public class JobMediaSheets extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobMediaSheets.class; } @@ -128,6 +130,7 @@ public class JobMediaSheets extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-media-sheets"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java index e6f1eb9b4d8..fea87dc8ebd 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job media * sheets completed attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobMediaSheetsCompleted); @@ -109,6 +110,7 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobMediaSheetsCompleted.class; } @@ -122,6 +124,7 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-media-sheets-completed"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java index a942f277175..8feeafef18a 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this job media * sheets supported attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobMediaSheetsSupported); @@ -109,6 +110,7 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobMediaSheetsSupported.class; } @@ -122,6 +124,7 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-media-sheets-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java index cd944103d23..796fe37774c 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobMessageFromOperator extends TextSyntax * @return {@code true} if {@code object} is equivalent to this job message * from operator attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobMessageFromOperator); @@ -109,6 +110,7 @@ public final class JobMessageFromOperator extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobMessageFromOperator.class; } @@ -122,6 +124,7 @@ public final class JobMessageFromOperator extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-message-from-operator"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java index cceabd8b8f0..4fa9eaee6fd 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -92,6 +92,7 @@ public final class JobName extends TextSyntax * @return {@code true} if {@code object} is equivalent to this job name * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof JobName); } @@ -105,6 +106,7 @@ public final class JobName extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobName.class; } @@ -117,6 +119,7 @@ public final class JobName extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-name"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java index d8dfd56a920..eda27d142f9 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -91,6 +91,7 @@ public final class JobOriginatingUserName extends TextSyntax * @return {@code true} if {@code object} is equivalent to this job * originating user name attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobOriginatingUserName); @@ -106,6 +107,7 @@ public final class JobOriginatingUserName extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobOriginatingUserName.class; } @@ -119,6 +121,7 @@ public final class JobOriginatingUserName extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-originating-user-name"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java index 7c77a504673..5ca9990ec13 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +94,7 @@ public final class JobPriority extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job priority * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof JobPriority); } @@ -108,6 +109,7 @@ public final class JobPriority extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobPriority.class; } @@ -121,6 +123,7 @@ public final class JobPriority extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-priority"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java index 6df729a9813..422d823bff7 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -86,6 +86,7 @@ public final class JobPrioritySupported extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this job priority * supported attribute, {@code false} otherwise */ + @Override public boolean equals (Object object) { return (super.equals(object) && @@ -102,6 +103,7 @@ public final class JobPrioritySupported extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobPrioritySupported.class; } @@ -115,6 +117,7 @@ public final class JobPrioritySupported extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-priority-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java index 130b8eb27a3..59a31096d2a 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -101,6 +101,7 @@ public class JobSheets extends EnumSyntax /** * Returns the string table for class {@code JobSheets}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -108,6 +109,7 @@ public class JobSheets extends EnumSyntax /** * Returns the enumeration value table for class {@code JobSheets}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -122,6 +124,7 @@ public class JobSheets extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobSheets.class; } @@ -135,6 +138,7 @@ public class JobSheets extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "job-sheets"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java index 13499a9b2a7..0b0ba9d3276 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -206,6 +206,7 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * Returns the string table for class {@code JobState}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -213,6 +214,7 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * Returns the enumeration value table for class {@code JobState}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -227,6 +229,7 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobState.class; } @@ -240,6 +243,7 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { * * @return attribute category name */ + @Override public final String getName() { return "job-state"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java index 2f8526cb7b1..aba72ec9c1a 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -436,6 +436,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * Returns the string table for class {@code JobStateReason}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -443,6 +444,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * Returns the enumeration value table for class {@code JobStateReason}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -457,6 +459,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobStateReason.class; } @@ -470,6 +473,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { * * @return attribute category name */ + @Override public final String getName() { return "job-state-reason"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java b/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java index 22b438c02eb..4e3e66d0ea8 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -140,6 +140,7 @@ public final class JobStateReasons * class {@link JobStateReason JobStateReason} * @since 1.5 */ + @Override public boolean add(JobStateReason o) { if (o == null) { throw new NullPointerException(); @@ -157,6 +158,7 @@ public final class JobStateReasons * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return JobStateReasons.class; } @@ -170,6 +172,7 @@ public final class JobStateReasons * * @return attribute category name */ + @Override public final String getName() { return "job-state-reasons"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java index 6b62f1dbecd..0cb9a4c30c5 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,7 @@ public abstract class Media extends EnumSyntax * @return {@code true} if {@code object} is equivalent to this media * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return object instanceof Media other && object.getClass() == this.getClass() && @@ -105,6 +106,7 @@ public abstract class Media extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Media.class; } @@ -118,6 +120,7 @@ public abstract class Media extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "media"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java index 9c1b4060a34..4adb2839759 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -107,6 +107,7 @@ public class MediaName extends Media implements Attribute { * * @return the string table */ + @Override protected String[] getStringTable() { return myStringTable.clone(); @@ -117,6 +118,7 @@ public class MediaName extends Media implements Attribute { * * @return the enumeration value table */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java index 72a58f2b697..a9cc2bba195 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -241,6 +241,7 @@ public final class MediaPrintableArea * @return {@code true} if {@code object} is equivalent to this media * margins attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { boolean ret = false; if (object instanceof MediaPrintableArea) { @@ -262,6 +263,7 @@ public final class MediaPrintableArea * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return MediaPrintableArea.class; } @@ -277,6 +279,7 @@ public final class MediaPrintableArea * * @return attribute category name */ + @Override public final String getName() { return "media-printable-area"; } @@ -304,6 +307,7 @@ public final class MediaPrintableArea /** * Returns a string version of this rectangular size attribute in mm. */ + @Override public String toString() { return(toString(MM, "mm")); } @@ -311,6 +315,7 @@ public final class MediaPrintableArea /** * Returns a hash code value for this attribute. */ + @Override public int hashCode() { return x + 37*y + 43*w + 47*h; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java index 6a8db3b94c2..57c0d305809 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -243,6 +243,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { * @return {@code true} if {@code object} is equivalent to this media size * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof MediaSize); } @@ -257,6 +258,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return MediaSize.class; } @@ -270,6 +272,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { * * @return attribute category name */ + @Override public final String getName() { return "media-size"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java index f9dde495610..52b60b046bf 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -608,6 +608,7 @@ public class MediaSizeName extends Media { /** * Returns the string table for class {@code MediaSizeName}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); @@ -616,6 +617,7 @@ public class MediaSizeName extends Media { /** * Returns the enumeration value table for class {@code MediaSizeName}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java index 138aae6248a..bc20cbb8901 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -132,6 +132,7 @@ public class MediaTray extends Media implements Attribute { /** * Returns the string table for class {@code MediaTray}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); @@ -140,6 +141,7 @@ public class MediaTray extends Media implements Attribute { /** * Returns the enumeration value table for class {@code MediaTray}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java b/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java index 6d12597c88a..4937f379684 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -219,6 +219,7 @@ public class MultipleDocumentHandling extends EnumSyntax /** * Returns the string table for class {@code MultipleDocumentHandling}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -227,6 +228,7 @@ public class MultipleDocumentHandling extends EnumSyntax * Returns the enumeration value table for class * {@code MultipleDocumentHandling}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -242,6 +244,7 @@ public class MultipleDocumentHandling extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return MultipleDocumentHandling.class; } @@ -255,6 +258,7 @@ public class MultipleDocumentHandling extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "multiple-document-handling"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java index 18b8144fb89..901907620f9 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -77,6 +77,7 @@ public final class NumberOfDocuments extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this number of * documents attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof NumberOfDocuments); @@ -92,6 +93,7 @@ public final class NumberOfDocuments extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return NumberOfDocuments.class; } @@ -105,6 +107,7 @@ public final class NumberOfDocuments extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "number-of-documents"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java index 54cb4b85e7a..480de3b1b47 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -78,6 +78,7 @@ public final class NumberOfInterveningJobs extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this number of * intervening jobs attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof NumberOfInterveningJobs); @@ -93,6 +94,7 @@ public final class NumberOfInterveningJobs extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return NumberOfInterveningJobs.class; } @@ -106,6 +108,7 @@ public final class NumberOfInterveningJobs extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "number-of-intervening-jobs"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java index b3aabbc6cfd..0b019346c8e 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -145,6 +145,7 @@ public final class NumberUp extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this number up * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof NumberUp); } @@ -159,6 +160,7 @@ public final class NumberUp extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return NumberUp.class; } @@ -171,6 +173,7 @@ public final class NumberUp extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "number-up"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java index dfb79835e0f..cef65ed17a3 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -136,6 +136,7 @@ public final class NumberUpSupported extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this number up * supported attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof NumberUpSupported); @@ -151,6 +152,7 @@ public final class NumberUpSupported extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return NumberUpSupported.class; } @@ -164,6 +166,7 @@ public final class NumberUpSupported extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "number-up-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java b/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java index 253adfe1ff1..00e3de4a1de 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -150,6 +150,7 @@ public final class OrientationRequested extends EnumSyntax /** * Returns the string table for class {@code OrientationRequested}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -158,6 +159,7 @@ public final class OrientationRequested extends EnumSyntax * Returns the enumeration value table for class * {@code OrientationRequested}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -166,6 +168,7 @@ public final class OrientationRequested extends EnumSyntax * Returns the lowest integer value used by class * {@code OrientationRequested}. */ + @Override protected int getOffset() { return 3; } @@ -180,6 +183,7 @@ public final class OrientationRequested extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return OrientationRequested.class; } @@ -193,6 +197,7 @@ public final class OrientationRequested extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "orientation-requested"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java b/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java index c94a105e92d..bea5cd35060 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -92,6 +92,7 @@ public final class OutputDeviceAssigned extends TextSyntax * @return {@code true} if {@code object} is equivalent to this output * device assigned attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof OutputDeviceAssigned); @@ -107,6 +108,7 @@ public final class OutputDeviceAssigned extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return OutputDeviceAssigned.class; } @@ -120,6 +122,7 @@ public final class OutputDeviceAssigned extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "output-device-assigned"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java index 46b9e8493d3..d9862ff633b 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -97,6 +97,7 @@ public class PDLOverrideSupported extends EnumSyntax /** * Returns the string table for class {@code PDLOverrideSupported}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -105,6 +106,7 @@ public class PDLOverrideSupported extends EnumSyntax * Returns the enumeration value table for class * {@code PDLOverrideSupported}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -119,6 +121,7 @@ public class PDLOverrideSupported extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PDLOverrideSupported.class; } @@ -132,6 +135,7 @@ public class PDLOverrideSupported extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "pdl-override-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java index 3ba0fa8e07e..74325a3eb2f 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,6 +209,7 @@ public final class PageRanges extends SetOfIntegerSyntax * @return {@code true} if {@code object} is equivalent to this page ranges * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PageRanges); } @@ -223,6 +224,7 @@ public final class PageRanges extends SetOfIntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PageRanges.class; } @@ -235,6 +237,7 @@ public final class PageRanges extends SetOfIntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "page-ranges"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java index 184339fb978..4d05663d1db 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -78,6 +78,7 @@ public final class PagesPerMinute extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this pages per * minute attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof PagesPerMinute); @@ -93,6 +94,7 @@ public final class PagesPerMinute extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PagesPerMinute.class; } @@ -106,6 +108,7 @@ public final class PagesPerMinute extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "pages-per-minute"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java index 32f15a4f165..0dc3d0c9420 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -91,6 +91,7 @@ public final class PagesPerMinuteColor extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this pages per * minute color attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PagesPerMinuteColor); @@ -106,6 +107,7 @@ public final class PagesPerMinuteColor extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PagesPerMinuteColor.class; } @@ -119,6 +121,7 @@ public final class PagesPerMinuteColor extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "pages-per-minute-color"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java index d4ff8581a2d..c40b6f3390e 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -157,6 +157,7 @@ public final class PresentationDirection extends EnumSyntax /** * Returns the string table for class {@code PresentationDirection}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -165,6 +166,7 @@ public final class PresentationDirection extends EnumSyntax * Returns the enumeration value table for class * {@code PresentationDirection}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -179,6 +181,7 @@ public final class PresentationDirection extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PresentationDirection.class; } @@ -192,6 +195,7 @@ public final class PresentationDirection extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "presentation-direction"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java index d00637fe23c..2e64522da7c 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -100,6 +100,7 @@ public class PrintQuality extends EnumSyntax /** * Returns the string table for class {@code PrintQuality}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -107,6 +108,7 @@ public class PrintQuality extends EnumSyntax /** * Returns the enumeration value table for class {@code PrintQuality}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -114,6 +116,7 @@ public class PrintQuality extends EnumSyntax /** * Returns the lowest integer value used by class {@code PrintQuality}. */ + @Override protected int getOffset() { return 3; } @@ -128,6 +131,7 @@ public class PrintQuality extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrintQuality.class; } @@ -141,6 +145,7 @@ public class PrintQuality extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "print-quality"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java index 4d8d2cf0601..39b8759d34d 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -87,6 +87,7 @@ public final class PrinterInfo extends TextSyntax * @return {@code true} if {@code object} is equivalent to this printer info * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterInfo); } @@ -101,6 +102,7 @@ public final class PrinterInfo extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterInfo.class; } @@ -114,6 +116,7 @@ public final class PrinterInfo extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-info"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java index 92e0d1fcfcd..f8a99d4db46 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -100,6 +100,7 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax /** * Returns the string table for class {@code PrinterIsAcceptingJobs}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -108,6 +109,7 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax * Returns the enumeration value table for class * {@code PrinterIsAcceptingJobs}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -122,6 +124,7 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterIsAcceptingJobs.class; } @@ -135,6 +138,7 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-is-accepting-jobs"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java index a0cfed406ce..c23112c79d2 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,6 +83,7 @@ public final class PrinterLocation extends TextSyntax * @return {@code true} if {@code object} is equivalent to this printer * location attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterLocation); } @@ -97,6 +98,7 @@ public final class PrinterLocation extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterLocation.class; } @@ -110,6 +112,7 @@ public final class PrinterLocation extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-location"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java index b5fe4a6ee95..eff34c8bd59 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ public final class PrinterMakeAndModel extends TextSyntax * @return {@code true} if {@code object} is equivalent to this printer make * and model attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterMakeAndModel); @@ -97,6 +98,7 @@ public final class PrinterMakeAndModel extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterMakeAndModel.class; } @@ -110,6 +112,7 @@ public final class PrinterMakeAndModel extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-make-and-model"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java index 9ce0a098b80..e125d4955b3 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -95,6 +95,7 @@ public final class PrinterMessageFromOperator extends TextSyntax * @return {@code true} if {@code object} is equivalent to this printer * message from operator attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterMessageFromOperator); @@ -110,6 +111,7 @@ public final class PrinterMessageFromOperator extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterMessageFromOperator.class; } @@ -123,6 +125,7 @@ public final class PrinterMessageFromOperator extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-message-from-operator"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java index 501ffdb6cfb..7e94507cf8c 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -88,6 +88,7 @@ public final class PrinterMoreInfo extends URISyntax * @return {@code true} if {@code object} is equivalent to this printer more * info attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterMoreInfo); @@ -103,6 +104,7 @@ public final class PrinterMoreInfo extends URISyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterMoreInfo.class; } @@ -116,6 +118,7 @@ public final class PrinterMoreInfo extends URISyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-more-info"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java index b6f8b92fc83..be6952fa00b 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -88,6 +88,7 @@ public final class PrinterMoreInfoManufacturer extends URISyntax * @return {@code true} if {@code object} is equivalent to this printer more * info manufacturer attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterMoreInfoManufacturer); @@ -103,6 +104,7 @@ public final class PrinterMoreInfoManufacturer extends URISyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterMoreInfoManufacturer.class; } @@ -116,6 +118,7 @@ public final class PrinterMoreInfoManufacturer extends URISyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-more-info-manufacturer"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java index 9a066c5d005..019ef3c8911 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -85,6 +85,7 @@ public final class PrinterName extends TextSyntax * @return {@code true} if {@code object} is equivalent to this printer name * attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterName); } @@ -99,6 +100,7 @@ public final class PrinterName extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterName.class; } @@ -112,6 +114,7 @@ public final class PrinterName extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-name"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java index 3bba7feb751..a47d57209cd 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,6 +108,7 @@ public final class PrinterResolution extends ResolutionSyntax * @return {@code true} if {@code object} is equivalent to this printer * resolution attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof PrinterResolution); @@ -123,6 +124,7 @@ public final class PrinterResolution extends ResolutionSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterResolution.class; } @@ -136,6 +138,7 @@ public final class PrinterResolution extends ResolutionSyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-resolution"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java index 9cbb3da9473..f2c921360a4 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -114,6 +114,7 @@ implements PrintServiceAttribute { /** * Returns the string table for class {@code PrinterState}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -121,6 +122,7 @@ implements PrintServiceAttribute { /** * Returns the enumeration value table for class {@code PrinterState}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -135,6 +137,7 @@ implements PrintServiceAttribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterState.class; } @@ -148,6 +151,7 @@ implements PrintServiceAttribute { * * @return attribute category name */ + @Override public final String getName() { return "printer-state"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java index 5c3b98ee127..8586713ed65 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -403,6 +403,7 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { /** * Returns the string table for class {@code PrinterStateReason}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -410,6 +411,7 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { /** * Returns the enumeration value table for class {@code PrinterStateReason}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -424,6 +426,7 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterStateReason.class; } @@ -437,6 +440,7 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { * * @return attribute category name */ + @Override public final String getName() { return "printer-state-reason"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java index 8e46b145651..fca59ca4bba 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -165,6 +165,7 @@ public final class PrinterStateReasons * {@link Severity Severity} * @since 1.5 */ + @Override public Severity put(PrinterStateReason reason, Severity severity) { if (reason == null) { throw new NullPointerException("reason is null"); @@ -185,6 +186,7 @@ public final class PrinterStateReasons * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterStateReasons.class; } @@ -198,6 +200,7 @@ public final class PrinterStateReasons * * @return attribute category name */ + @Override public final String getName() { return "printer-state-reasons"; } @@ -240,6 +243,7 @@ public final class PrinterStateReasons myEntrySet = entrySet; } + @Override public int size() { int result = 0; for (PrinterStateReason ignored : this) { @@ -248,6 +252,7 @@ public final class PrinterStateReasons return result; } + @Override public Iterator iterator() { return new PrinterStateReasonSetIterator(mySeverity, myEntrySet.iterator()); @@ -276,10 +281,12 @@ public final class PrinterStateReasons } } + @Override public boolean hasNext() { return myEntry != null; } + @Override public PrinterStateReason next() { if (myEntry == null) { throw new NoSuchElementException(); @@ -289,6 +296,7 @@ public final class PrinterStateReasons return result; } + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java index dfe0bc5cc1f..d6934aae172 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -79,6 +79,7 @@ public final class PrinterURI extends URISyntax * @return {@code true} if {@code object} is equivalent to this * {@code PrinterURI} attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterURI); } @@ -93,6 +94,7 @@ public final class PrinterURI extends URISyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return PrinterURI.class; } @@ -106,6 +108,7 @@ public final class PrinterURI extends URISyntax * * @return attribute category name */ + @Override public final String getName() { return "printer-uri"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java b/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java index c56eeb35a83..e44ead9b7cf 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,6 +76,7 @@ public final class QueuedJobCount extends IntegerSyntax * @return {@code true} if {@code object} is equivalent to this queued job * count attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals (object) && object instanceof QueuedJobCount); @@ -91,6 +92,7 @@ public final class QueuedJobCount extends IntegerSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return QueuedJobCount.class; } @@ -104,6 +106,7 @@ public final class QueuedJobCount extends IntegerSyntax * * @return attribute category name */ + @Override public final String getName() { return "queued-job-count"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java b/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java index 9784742030b..426fe4db3c4 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -154,6 +154,7 @@ public class ReferenceUriSchemesSupported /** * Returns the string table for class {@code ReferenceUriSchemesSupported}. */ + @Override protected String[] getStringTable() { return myStringTable.clone(); } @@ -162,6 +163,7 @@ public class ReferenceUriSchemesSupported * Returns the enumeration value table for class * {@code ReferenceUriSchemesSupported}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } @@ -177,6 +179,7 @@ public class ReferenceUriSchemesSupported * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return ReferenceUriSchemesSupported.class; } @@ -191,6 +194,7 @@ public class ReferenceUriSchemesSupported * * @return attribute category name */ + @Override public final String getName() { return "reference-uri-schemes-supported"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java b/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java index 1d233eb7602..c2efb2da1d6 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -92,6 +92,7 @@ public final class RequestingUserName extends TextSyntax * @return {@code true} if {@code object} is equivalent to this requesting * user name attribute, {@code false} otherwise */ + @Override public boolean equals(Object object) { return (super.equals(object) && object instanceof RequestingUserName); @@ -107,6 +108,7 @@ public final class RequestingUserName extends TextSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return RequestingUserName.class; } @@ -120,6 +122,7 @@ public final class RequestingUserName extends TextSyntax * * @return attribute category name */ + @Override public final String getName() { return "requesting-user-name"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java index 7543d4503a9..c217f12292f 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,6 +124,7 @@ public final class Severity extends EnumSyntax implements Attribute { /** * Returns the string table for class {@code Severity}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -131,6 +132,7 @@ public final class Severity extends EnumSyntax implements Attribute { /** * Returns the enumeration value table for class {@code Severity}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -145,6 +147,7 @@ public final class Severity extends EnumSyntax implements Attribute { * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Severity.class; } @@ -157,6 +160,7 @@ public final class Severity extends EnumSyntax implements Attribute { * * @return attribute category name */ + @Override public final String getName() { return "severity"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java b/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java index 45ec5f5374b..1754a27c86f 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -191,6 +191,7 @@ public final class SheetCollate extends EnumSyntax /** * Returns the string table for class {@code SheetCollate}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -198,6 +199,7 @@ public final class SheetCollate extends EnumSyntax /** * Returns the enumeration value table for class {@code SheetCollate}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -212,6 +214,7 @@ public final class SheetCollate extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return SheetCollate.class; } @@ -225,6 +228,7 @@ public final class SheetCollate extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "sheet-collate"; } diff --git a/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java b/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java index 86d421045b0..0321cd876de 100644 --- a/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java +++ b/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -183,6 +183,7 @@ public final class Sides extends EnumSyntax /** * Returns the string table for class {@code Sides}. */ + @Override protected String[] getStringTable() { return myStringTable; } @@ -190,6 +191,7 @@ public final class Sides extends EnumSyntax /** * Returns the enumeration value table for class {@code Sides}. */ + @Override protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } @@ -203,6 +205,7 @@ public final class Sides extends EnumSyntax * @return printing attribute class (category), an instance of class * {@link Class java.lang.Class} */ + @Override public final Class getCategory() { return Sides.class; } @@ -215,6 +218,7 @@ public final class Sides extends EnumSyntax * * @return attribute category name */ + @Override public final String getName() { return "sides"; } diff --git a/src/java.desktop/share/classes/javax/swing/AbstractButton.java b/src/java.desktop/share/classes/javax/swing/AbstractButton.java index d4112b5ed04..a1961acce29 100644 --- a/src/java.desktop/share/classes/javax/swing/AbstractButton.java +++ b/src/java.desktop/share/classes/javax/swing/AbstractButton.java @@ -1070,13 +1070,13 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl Action oldValue = getAction(); if (action==null || !action.equals(a)) { action = a; - if (oldValue!=null) { + if (oldValue != null) { removeActionListener(oldValue); oldValue.removePropertyChangeListener(actionPropertyChangeListener); actionPropertyChangeListener = null; } configurePropertiesFromAction(action); - if (action!=null) { + if (action != null) { // Don't add if it is already a listener if (!isListener(ActionListener.class, action)) { addActionListener(action); diff --git a/src/java.desktop/share/classes/javax/swing/ActionPropertyChangeListener.java b/src/java.desktop/share/classes/javax/swing/ActionPropertyChangeListener.java index db12b6766b8..19b9152a1b5 100644 --- a/src/java.desktop/share/classes/javax/swing/ActionPropertyChangeListener.java +++ b/src/java.desktop/share/classes/javax/swing/ActionPropertyChangeListener.java @@ -111,7 +111,7 @@ abstract class ActionPropertyChangeListener while ((r = (OwnedWeakReference)queue.poll()) != null) { ActionPropertyChangeListener oldPCL = r.getOwner(); Action oldAction = oldPCL.getAction(); - if (oldAction!=null) { + if (oldAction != null) { oldAction.removePropertyChangeListener(oldPCL); } } diff --git a/src/java.desktop/share/classes/javax/swing/AncestorNotifier.java b/src/java.desktop/share/classes/javax/swing/AncestorNotifier.java index f3cfdd9d0ba..a3ed463d2d5 100644 --- a/src/java.desktop/share/classes/javax/swing/AncestorNotifier.java +++ b/src/java.desktop/share/classes/javax/swing/AncestorNotifier.java @@ -213,7 +213,7 @@ class AncestorNotifier implements ComponentListener, PropertyChangeListener, Ser public void propertyChange(PropertyChangeEvent evt) { String s = evt.getPropertyName(); - if (s!=null && (s.equals("parent") || s.equals("ancestor"))) { + if (s != null && (s.equals("parent") || s.equals("ancestor"))) { JComponent component = (JComponent)evt.getSource(); if (evt.getNewValue() != null) { diff --git a/src/java.desktop/share/classes/javax/swing/ArrayTable.java b/src/java.desktop/share/classes/javax/swing/ArrayTable.java index 7c38f9fb577..282bd3454ca 100644 --- a/src/java.desktop/share/classes/javax/swing/ArrayTable.java +++ b/src/java.desktop/share/classes/javax/swing/ArrayTable.java @@ -145,7 +145,7 @@ class ArrayTable implements Cloneable { */ public Object get(Object key) { Object value = null; - if (table !=null) { + if (table != null) { if (isArray()) { Object[] array = (Object[])table; for (int i = 0; i debugGraphicsInfoKey = DebugGraphicsInfo.class; + private static DebugGraphicsInfo debugGraphicsInfo; } diff --git a/src/java.desktop/share/classes/javax/swing/ImageIcon.java b/src/java.desktop/share/classes/javax/swing/ImageIcon.java index ee6c08ebb15..707a1766eee 100644 --- a/src/java.desktop/share/classes/javax/swing/ImageIcon.java +++ b/src/java.desktop/share/classes/javax/swing/ImageIcon.java @@ -53,8 +53,6 @@ import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; -import sun.awt.AWTAccessor; - /** * An implementation of the Icon interface that paints Icons * from Images. Images that are created from a URL, filename or byte array diff --git a/src/java.desktop/share/classes/javax/swing/JComboBox.java b/src/java.desktop/share/classes/javax/swing/JComboBox.java index 67600ad323a..af7c5a01a7e 100644 --- a/src/java.desktop/share/classes/javax/swing/JComboBox.java +++ b/src/java.desktop/share/classes/javax/swing/JComboBox.java @@ -1103,13 +1103,13 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { Action oldValue = getAction(); if (action==null || !action.equals(a)) { action = a; - if (oldValue!=null) { + if (oldValue != null) { removeActionListener(oldValue); oldValue.removePropertyChangeListener(actionPropertyChangeListener); actionPropertyChangeListener = null; } configurePropertiesFromAction(action); - if (action!=null) { + if (action != null) { // Don't add if it is already a listener if (!isListener(ActionListener.class, action)) { addActionListener(action); diff --git a/src/java.desktop/share/classes/javax/swing/JComponent.java b/src/java.desktop/share/classes/javax/swing/JComponent.java index f515115bade..87d6a41c2b0 100644 --- a/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.EventQueue; import java.awt.FocusTraversalPolicy; import java.awt.Font; import java.awt.FontMetrics; @@ -261,16 +262,6 @@ public abstract class JComponent extends Container implements Serializable, */ static boolean DEBUG_GRAPHICS_LOADED; - /** - * Key used to look up a value from the AppContext to determine the - * JComponent the InputVerifier is running for. That is, if - * AppContext.get(INPUT_VERIFIER_SOURCE_KEY) returns non-null, it - * indicates the EDT is calling into the InputVerifier from the - * returned component. - */ - private static final Object INPUT_VERIFIER_SOURCE_KEY = - new StringBuilder("InputVerifierSourceKey"); - /* The following fields support set methods for the corresponding * java.awt.Component properties. */ @@ -414,8 +405,7 @@ public abstract class JComponent extends Container implements Serializable, /** ActionMap. */ private ActionMap actionMap; - /** Key used to store the default locale in an AppContext **/ - private static final String defaultLocale = "JComponent.defaultLocale"; + private static volatile Locale defaultLocale; private static Component componentObtainingGraphicsFrom; private static Object componentObtainingGraphicsFromLock = new @@ -2841,12 +2831,12 @@ public abstract class JComponent extends Container implements Serializable, * @since 1.4 */ public static Locale getDefaultLocale() { - Locale l = (Locale) SwingUtilities.appContextGet(defaultLocale); - if( l == null ) { + Locale l = defaultLocale; + if (l == null) { //REMIND(bcb) choosing the default value is more complicated //than this. l = Locale.getDefault(); - JComponent.setDefaultLocale( l ); + JComponent.setDefaultLocale(l); } return l; } @@ -2865,8 +2855,8 @@ public abstract class JComponent extends Container implements Serializable, * @see #setLocale * @since 1.4 */ - public static void setDefaultLocale( Locale l ) { - SwingUtilities.appContextPut(defaultLocale, l); + public static void setDefaultLocale(Locale l) { + defaultLocale = l; } @@ -3507,7 +3497,7 @@ public abstract class JComponent extends Container implements Serializable, // This class is used by the KeyboardState class to provide a single - // instance that can be stored in the AppContext. + // instance. static final class IntVector { int[] array = null; int count = 0; @@ -3538,24 +3528,12 @@ public abstract class JComponent extends Container implements Serializable, } } + private static final IntVector intVector = new IntVector(); @SuppressWarnings("serial") static class KeyboardState implements Serializable { - private static final Object keyCodesKey = - JComponent.KeyboardState.class; - - // Get the array of key codes from the AppContext. - static IntVector getKeyCodeArray() { - IntVector iv = - (IntVector)SwingUtilities.appContextGet(keyCodesKey); - if (iv == null) { - iv = new IntVector(); - SwingUtilities.appContextPut(keyCodesKey, iv); - } - return iv; - } static void registerKeyPressed(int keyCode) { - IntVector kca = getKeyCodeArray(); + IntVector kca = intVector; int count = kca.size(); int i; for(i=0;i kitRegistry = getKitRegistry(); EditorKit k = kitRegistry.get(type); if (k == null) { // try to dynamically load the support - String classname = getKitTypeRegistry().get(type); - ClassLoader loader = getKitLoaderRegistry().get(type); + String classname = kitTypeRegistry.get(type); + ClassLoader loader = kitLoaderRegistry.get(type); try { Class c; if (loader != null) { @@ -1287,13 +1286,13 @@ public class JEditorPane extends JTextComponent { * @param loader the ClassLoader to use to load the name */ public static void registerEditorKitForContentType(String type, String classname, ClassLoader loader) { - getKitTypeRegistry().put(type, classname); + kitTypeRegistry.put(type, classname); if (loader != null) { - getKitLoaderRegistry().put(type, loader); + kitLoaderRegistry.put(type, loader); } else { - getKitLoaderRegistry().remove(type); + kitLoaderRegistry.remove(type); } - getKitRegistry().remove(type); + kitRegistry.remove(type); } /** @@ -1306,63 +1305,27 @@ public class JEditorPane extends JTextComponent { * @since 1.3 */ public static String getEditorKitClassNameForContentType(String type) { - return getKitTypeRegistry().get(type); + return kitTypeRegistry.get(type); } - private static Hashtable getKitTypeRegistry() { - loadDefaultKitsIfNecessary(); - @SuppressWarnings("unchecked") - Hashtable tmp = - (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey); - return tmp; - } + private static final Hashtable kitTypeRegistry = new Hashtable<>(); + private static final Hashtable kitLoaderRegistry = new Hashtable<>(); - private static Hashtable getKitLoaderRegistry() { - loadDefaultKitsIfNecessary(); - @SuppressWarnings("unchecked") - Hashtable tmp = - (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey); - return tmp; - } + private static final Hashtable kitRegistry = new Hashtable<>(3); - private static Hashtable getKitRegistry() { - @SuppressWarnings("unchecked") - Hashtable ht = - (Hashtable)SwingUtilities.appContextGet(kitRegistryKey); - if (ht == null) { - ht = new Hashtable<>(3); - SwingUtilities.appContextPut(kitRegistryKey, ht); - } - return ht; - } - - /** - * This is invoked every time the registries are accessed. Loading - * is done this way instead of via a static as the static is only - * called once when running in an AppContext. - */ - private static void loadDefaultKitsIfNecessary() { - if (SwingUtilities.appContextGet(kitTypeRegistryKey) == null) { - synchronized(defaultEditorKitMap) { - if (defaultEditorKitMap.size() == 0) { - defaultEditorKitMap.put("text/plain", - "javax.swing.JEditorPane$PlainEditorKit"); - defaultEditorKitMap.put("text/html", - "javax.swing.text.html.HTMLEditorKit"); - defaultEditorKitMap.put("text/rtf", - "javax.swing.text.rtf.RTFEditorKit"); - defaultEditorKitMap.put("application/rtf", - "javax.swing.text.rtf.RTFEditorKit"); - } - } - Hashtable ht = new Hashtable<>(); - SwingUtilities.appContextPut(kitTypeRegistryKey, ht); - ht = new Hashtable<>(); - SwingUtilities.appContextPut(kitLoaderRegistryKey, ht); - for (String key : defaultEditorKitMap.keySet()) { - registerEditorKitForContentType(key,defaultEditorKitMap.get(key)); - } + static final Map defaultEditorKitMap = new HashMap(0); + static { + defaultEditorKitMap.put("text/plain", + "javax.swing.JEditorPane$PlainEditorKit"); + defaultEditorKitMap.put("text/html", + "javax.swing.text.html.HTMLEditorKit"); + defaultEditorKitMap.put("text/rtf", + "javax.swing.text.rtf.RTFEditorKit"); + defaultEditorKitMap.put("application/rtf", + "javax.swing.text.rtf.RTFEditorKit"); + for (String key : defaultEditorKitMap.keySet()) { + registerEditorKitForContentType(key,defaultEditorKitMap.get(key)); } } @@ -1587,16 +1550,6 @@ public class JEditorPane extends JTextComponent { */ private Hashtable typeHandlers; - /* - * Private AppContext keys for this class's static variables. - */ - private static final Object kitRegistryKey = - new StringBuffer("JEditorPane.kitRegistry"); - private static final Object kitTypeRegistryKey = - new StringBuffer("JEditorPane.kitTypeRegistry"); - private static final Object kitLoaderRegistryKey = - new StringBuffer("JEditorPane.kitLoaderRegistry"); - /** * @see #getUIClassID * @see #readObject @@ -1633,8 +1586,6 @@ public class JEditorPane extends JTextComponent { */ public static final String HONOR_DISPLAY_PROPERTIES = "JEditorPane.honorDisplayProperties"; - static final Map defaultEditorKitMap = new HashMap(0); - /** * Returns a string representation of this JEditorPane. * This method diff --git a/src/java.desktop/share/classes/javax/swing/JFrame.java b/src/java.desktop/share/classes/javax/swing/JFrame.java index 8bde7e18f03..bab215625b9 100644 --- a/src/java.desktop/share/classes/javax/swing/JFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,13 +126,6 @@ public class JFrame extends Frame implements WindowConstants, RootPaneContainer, TransferHandler.HasGetTransferHandler { - /** - * Key into the AppContext, used to check if should provide decorations - * by default. - */ - private static final Object defaultLookAndFeelDecoratedKey = - new StringBuffer("JFrame.defaultLookAndFeelDecorated"); - private int defaultCloseOperation = HIDE_ON_CLOSE; /** @@ -755,6 +748,8 @@ public class JFrame extends Frame implements WindowConstants, } } + private static boolean defaultLAFDecorated; + /** * Provides a hint as to whether or not newly created JFrames * should have their Window decorations (such as borders, widgets to @@ -780,11 +775,7 @@ public class JFrame extends Frame implements WindowConstants, * @since 1.4 */ public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) { - if (defaultLookAndFeelDecorated) { - SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE); - } else { - SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE); - } + defaultLAFDecorated = defaultLookAndFeelDecorated; } @@ -797,12 +788,7 @@ public class JFrame extends Frame implements WindowConstants, * @since 1.4 */ public static boolean isDefaultLookAndFeelDecorated() { - Boolean defaultLookAndFeelDecorated = - (Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey); - if (defaultLookAndFeelDecorated == null) { - defaultLookAndFeelDecorated = Boolean.FALSE; - } - return defaultLookAndFeelDecorated.booleanValue(); + return defaultLAFDecorated; } /** diff --git a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java index 9611f991025..dec53d29e75 100644 --- a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,6 @@ import javax.swing.event.InternalFrameListener; import javax.swing.plaf.DesktopIconUI; import javax.swing.plaf.InternalFrameUI; -import sun.awt.AppContext; import sun.swing.SwingUtilities2; /** @@ -237,17 +236,13 @@ public class JInternalFrame extends JComponent implements /** Constrained property name indicating that the internal frame is iconified. */ public static final String IS_ICON_PROPERTY = "icon"; - private static final Object PROPERTY_CHANGE_LISTENER_KEY = - new StringBuilder("InternalFramePropertyChangeListener"); + private static PropertyChangeListener focusListener; private static void addPropertyChangeListenerIfNecessary() { - if (AppContext.getAppContext().get(PROPERTY_CHANGE_LISTENER_KEY) == - null) { - PropertyChangeListener focusListener = - new FocusPropertyChangeListener(); - - AppContext.getAppContext().put(PROPERTY_CHANGE_LISTENER_KEY, - focusListener); + synchronized (JInternalFrame.class) { + if (focusListener == null) { + focusListener = new FocusPropertyChangeListener(); + } KeyboardFocusManager.getCurrentKeyboardFocusManager(). addPropertyChangeListener(focusListener); @@ -992,6 +987,9 @@ public class JInternalFrame extends JComponent implements = "Indicates whether this internal frame is maximized.") public void setMaximum(boolean b) throws PropertyVetoException { if (isMaximum == b) { + if (!b) { + normalBounds = null; + } return; } @@ -1003,6 +1001,9 @@ public class JInternalFrame extends JComponent implements get it wrong... See, for example, getNormalBounds() */ isMaximum = b; firePropertyChange(IS_MAXIMUM_PROPERTY, oldValue, newValue); + if (!b) { + normalBounds = null; + } } /** diff --git a/src/java.desktop/share/classes/javax/swing/JList.java b/src/java.desktop/share/classes/javax/swing/JList.java index 8d4497d6f9a..f3620be02b4 100644 --- a/src/java.desktop/share/classes/javax/swing/JList.java +++ b/src/java.desktop/share/classes/javax/swing/JList.java @@ -2694,7 +2694,7 @@ public class JList extends JComponent implements Scrollable, Accessible } Rectangle newFirstRect = getCellBounds(newFirst,newFirst); Rectangle firstRect = getCellBounds(first,first); - if ((newFirstRect != null) && (firstRect!=null)) { + if ((newFirstRect != null) && (firstRect != null)) { while ( (newFirstRect.y + visibleRect.height < firstRect.y + firstRect.height) && (newFirstRect.y < firstRect.y) ) { diff --git a/src/java.desktop/share/classes/javax/swing/JOptionPane.java b/src/java.desktop/share/classes/javax/swing/JOptionPane.java index 707b9febf10..c41400b9b37 100644 --- a/src/java.desktop/share/classes/javax/swing/JOptionPane.java +++ b/src/java.desktop/share/classes/javax/swing/JOptionPane.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -1656,7 +1656,7 @@ public class JOptionPane extends JComponent implements Accessible return getDesktopPaneForComponent(parentComponent.getParent()); } - private static final Object sharedFrameKey = JOptionPane.class; + private static volatile Frame sharedRootFrame; /** * Sets the frame to use for class methods in which a frame is @@ -1668,11 +1668,7 @@ public class JOptionPane extends JComponent implements Accessible * @param newRootFrame the default Frame to use */ public static void setRootFrame(Frame newRootFrame) { - if (newRootFrame != null) { - SwingUtilities.appContextPut(sharedFrameKey, newRootFrame); - } else { - SwingUtilities.appContextRemove(sharedFrameKey); - } + sharedRootFrame = newRootFrame; } /** @@ -1687,13 +1683,10 @@ public class JOptionPane extends JComponent implements Accessible * @see java.awt.GraphicsEnvironment#isHeadless */ public static Frame getRootFrame() throws HeadlessException { - Frame sharedFrame = - (Frame)SwingUtilities.appContextGet(sharedFrameKey); - if (sharedFrame == null) { - sharedFrame = SwingUtilities.getSharedOwnerFrame(); - SwingUtilities.appContextPut(sharedFrameKey, sharedFrame); + if (sharedRootFrame == null) { + sharedRootFrame = SwingUtilities.getSharedOwnerFrame(); } - return sharedFrame; + return sharedRootFrame; } /** diff --git a/src/java.desktop/share/classes/javax/swing/JPopupMenu.java b/src/java.desktop/share/classes/javax/swing/JPopupMenu.java index 1b04e8c6169..f3d11a29b4a 100644 --- a/src/java.desktop/share/classes/javax/swing/JPopupMenu.java +++ b/src/java.desktop/share/classes/javax/swing/JPopupMenu.java @@ -112,12 +112,6 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { */ private static final String uiClassID = "PopupMenuUI"; - /** - * Key used in AppContext to determine if light way popups are the default. - */ - private static final Object defaultLWPopupEnabledKey = - new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey"); - /** Bug#4425878-Property javax.swing.adjustPopupLocationToFit introduced */ static boolean popupPositionFixDisabled = System.getProperty("javax.swing.adjustPopupLocationToFit","").equals("false"); @@ -153,6 +147,8 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { private static final boolean VERBOSE = false; // show reuse hits/misses private static final boolean DEBUG = false; // show bad params, misc. + private static boolean defaultLWPopupEnabled = true; + /** * Sets the default value of the lightWeightPopupEnabled * property. @@ -163,8 +159,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { * @see #setLightWeightPopupEnabled */ public static void setDefaultLightWeightPopupEnabled(boolean aFlag) { - SwingUtilities.appContextPut(defaultLWPopupEnabledKey, - Boolean.valueOf(aFlag)); + defaultLWPopupEnabled = aFlag; } /** @@ -177,14 +172,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { * @see #setDefaultLightWeightPopupEnabled */ public static boolean getDefaultLightWeightPopupEnabled() { - Boolean b = (Boolean) - SwingUtilities.appContextGet(defaultLWPopupEnabledKey); - if (b == null) { - SwingUtilities.appContextPut(defaultLWPopupEnabledKey, - Boolean.TRUE); - return true; - } - return b.booleanValue(); + return defaultLWPopupEnabled; } /** @@ -987,7 +975,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { if (newFrame != frame) { // Use the invoker's frame so that events // are propagated properly - if (newFrame!=null) { + if (newFrame != null) { this.frame = newFrame; if(popup != null) { setVisible(false); @@ -1024,7 +1012,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { */ JPopupMenu getRootPopupMenu() { JPopupMenu mp = this; - while((mp!=null) && (mp.isPopupMenu()!=true) && + while((mp != null) && (mp.isPopupMenu()!=true) && (mp.getInvoker() != null) && (mp.getInvoker().getParent() instanceof JPopupMenu popupMenu) ) { @@ -1194,7 +1182,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { private static Frame getFrame(Component c) { Component w = c; - while(!(w instanceof Frame) && (w!=null)) { + while(!(w instanceof Frame) && (w != null)) { w = w.getParent(); } return (Frame)w; diff --git a/src/java.desktop/share/classes/javax/swing/JTextField.java b/src/java.desktop/share/classes/javax/swing/JTextField.java index 0d66209d8af..b6d8639c994 100644 --- a/src/java.desktop/share/classes/javax/swing/JTextField.java +++ b/src/java.desktop/share/classes/javax/swing/JTextField.java @@ -581,13 +581,13 @@ public class JTextField extends JTextComponent implements SwingConstants { Action oldValue = getAction(); if (action==null || !action.equals(a)) { action = a; - if (oldValue!=null) { + if (oldValue != null) { removeActionListener(oldValue); oldValue.removePropertyChangeListener(actionPropertyChangeListener); actionPropertyChangeListener = null; } configurePropertiesFromAction(action); - if (action!=null) { + if (action != null) { // Don't add if it is already a listener if (!isListener(ActionListener.class, action)) { addActionListener(action); diff --git a/src/java.desktop/share/classes/javax/swing/JTree.java b/src/java.desktop/share/classes/javax/swing/JTree.java index 622c55e2ede..397584b6e4a 100644 --- a/src/java.desktop/share/classes/javax/swing/JTree.java +++ b/src/java.desktop/share/classes/javax/swing/JTree.java @@ -2087,7 +2087,7 @@ public class JTree extends JComponent implements Scrollable, Accessible value = expandedState.get(path); if (value == null || !value) return false; - } while( (path=path.getParentPath())!=null ); + } while( (path=path.getParentPath()) != null ); return true; } diff --git a/src/java.desktop/share/classes/javax/swing/KeyboardManager.java b/src/java.desktop/share/classes/javax/swing/KeyboardManager.java index 42a6403ddb5..8206ab5cea6 100644 --- a/src/java.desktop/share/classes/javax/swing/KeyboardManager.java +++ b/src/java.desktop/share/classes/javax/swing/KeyboardManager.java @@ -330,7 +330,7 @@ class KeyboardManager { return; } Hashtable keyMap = containerMap.get(topContainer); - if (keyMap!=null) { + if (keyMap != null) { Vector v = (Vector)keyMap.get(JMenuBar.class); if (v != null) { v.removeElement(mb); diff --git a/src/java.desktop/share/classes/javax/swing/MenuSelectionManager.java b/src/java.desktop/share/classes/javax/swing/MenuSelectionManager.java index c84a218b877..ba80fc3bc95 100644 --- a/src/java.desktop/share/classes/javax/swing/MenuSelectionManager.java +++ b/src/java.desktop/share/classes/javax/swing/MenuSelectionManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +29,6 @@ import java.util.*; import java.awt.event.*; import javax.swing.event.*; -import sun.awt.AppContext; import sun.awt.AWTAccessor; import sun.awt.AWTAccessor.MouseEventAccessor; import sun.swing.SwingUtilities2; @@ -48,8 +47,7 @@ public class MenuSelectionManager { private static final boolean VERBOSE = false; // show reuse hits/misses private static final boolean DEBUG = false; // show bad params, misc. - private static final StringBuilder MENU_SELECTION_MANAGER_KEY = - new StringBuilder("javax.swing.MenuSelectionManager"); + private static final MenuSelectionManager DEFAULT_MSM = new MenuSelectionManager(); /** * Constructs a {@code MenuSelectionManager}. @@ -62,23 +60,7 @@ public class MenuSelectionManager { * @return a MenuSelectionManager object */ public static MenuSelectionManager defaultManager() { - synchronized (MENU_SELECTION_MANAGER_KEY) { - AppContext context = AppContext.getAppContext(); - MenuSelectionManager msm = (MenuSelectionManager)context.get( - MENU_SELECTION_MANAGER_KEY); - if (msm == null) { - msm = new MenuSelectionManager(); - context.put(MENU_SELECTION_MANAGER_KEY, msm); - - // installing additional listener if found in the AppContext - Object o = context.get(SwingUtilities2.MENU_SELECTION_MANAGER_LISTENER_KEY); - if (o instanceof ChangeListener listener) { - msm.addChangeListener(listener); - } - } - - return msm; - } + return DEFAULT_MSM; } /** diff --git a/src/java.desktop/share/classes/javax/swing/PopupFactory.java b/src/java.desktop/share/classes/javax/swing/PopupFactory.java index 2b274c816b1..7245820c289 100644 --- a/src/java.desktop/share/classes/javax/swing/PopupFactory.java +++ b/src/java.desktop/share/classes/javax/swing/PopupFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -80,13 +80,6 @@ public class PopupFactory { } }); } - /** - * The shared instanceof PopupFactory is per - * AppContext. This is the key used in the - * AppContext to locate the PopupFactory. - */ - private static final Object SharedInstanceKey = - new StringBuffer("PopupFactory.SharedInstanceKey"); /** * Max number of items to store in any one particular cache. @@ -118,6 +111,7 @@ public class PopupFactory { */ public PopupFactory() {} + static PopupFactory sharedFactory; /** * Sets the PopupFactory that will be used to obtain * Popups. @@ -132,7 +126,9 @@ public class PopupFactory { if (factory == null) { throw new IllegalArgumentException("PopupFactory can not be null"); } - SwingUtilities.appContextPut(SharedInstanceKey, factory); + synchronized (PopupFactory.class) { + sharedFactory = factory; + } } /** @@ -142,14 +138,12 @@ public class PopupFactory { * @return Shared PopupFactory */ public static PopupFactory getSharedInstance() { - PopupFactory factory = (PopupFactory)SwingUtilities.appContextGet( - SharedInstanceKey); - - if (factory == null) { - factory = new PopupFactory(); - setSharedInstance(factory); + synchronized (PopupFactory.class) { + if (sharedFactory == null) { + sharedFactory = new PopupFactory(); + } + return sharedFactory; } - return factory; } @@ -351,8 +345,6 @@ public class PopupFactory { * Popup implementation that uses a Window as the popup. */ private static class HeavyWeightPopup extends Popup { - private static final Object heavyWeightPopupCacheKey = - new StringBuffer("PopupFactory.heavyWeightPopupCache"); private volatile boolean isCacheEnabled = true; @@ -434,21 +426,16 @@ public class PopupFactory { } } + private static Map> cache; /** * Returns the cache to use for heavy weight popups. Maps from * Window to a List of * HeavyWeightPopups. */ - @SuppressWarnings("unchecked") private static Map> getHeavyWeightPopupCache() { synchronized (HeavyWeightPopup.class) { - Map> cache = (Map>)SwingUtilities.appContextGet( - heavyWeightPopupCacheKey); - if (cache == null) { cache = new HashMap<>(2); - SwingUtilities.appContextPut(heavyWeightPopupCacheKey, - cache); } return cache; } @@ -728,18 +715,17 @@ public class PopupFactory { return popup; } + private static List cache; /** * Returns the cache to use for heavy weight popups. */ - @SuppressWarnings("unchecked") private static List getLightWeightPopupCache() { - List cache = (List)SwingUtilities.appContextGet( - lightWeightPopupCacheKey); - if (cache == null) { - cache = new ArrayList<>(); - SwingUtilities.appContextPut(lightWeightPopupCacheKey, cache); + synchronized (LightWeightPopup.class) { + if (cache == null) { + cache = new ArrayList<>(); + } + return cache; } - return cache; } /** @@ -849,8 +835,6 @@ public class PopupFactory { * Popup implementation that uses a Panel as the popup. */ private static class MediumWeightPopup extends ContainerPopup { - private static final Object mediumWeightPopupCacheKey = - new StringBuffer("PopupFactory.mediumPopupCache"); /** Child of the panel. The contents are added to this. */ private JRootPane rootPane; @@ -877,19 +861,18 @@ public class PopupFactory { return popup; } + private static List cache; /** * Returns the cache to use for medium weight popups. */ @SuppressWarnings("unchecked") private static List getMediumWeightPopupCache() { - List cache = (List)SwingUtilities.appContextGet( - mediumWeightPopupCacheKey); - - if (cache == null) { - cache = new ArrayList<>(); - SwingUtilities.appContextPut(mediumWeightPopupCacheKey, cache); + synchronized (MediumWeightPopup.class) { + if (cache == null) { + cache = new ArrayList<>(); + } + return cache; } - return cache; } /** @@ -942,7 +925,7 @@ public class PopupFactory { add to that, otherwise add to the window. */ while (!(parent instanceof Window) && - (parent!=null)) { + (parent != null)) { parent = parent.getParent(); } diff --git a/src/java.desktop/share/classes/javax/swing/RepaintManager.java b/src/java.desktop/share/classes/javax/swing/RepaintManager.java index dcc755cb4bc..b587cf2da84 100644 --- a/src/java.desktop/share/classes/javax/swing/RepaintManager.java +++ b/src/java.desktop/share/classes/javax/swing/RepaintManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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.util.*; import java.util.concurrent.atomic.AtomicInteger; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.DisplayChangedListener; import sun.awt.SunToolkit; import sun.java2d.SunGraphicsEnvironment; @@ -119,8 +118,6 @@ public class RepaintManager */ private PaintManager paintManager; - private static final Object repaintManagerKey = RepaintManager.class; - // Whether or not a VolatileImage should be used for double-buffered painting static boolean volatileImageBufferEnabled = true; /** @@ -236,8 +233,10 @@ public class RepaintManager } } + private static RepaintManager repaintManager; + /** - * Return the RepaintManager for the calling thread given a Component. + * Return the RepaintManager given a Component. * * @param c a Component -- unused in the default implementation, but could * be used by an overridden version to return a different RepaintManager @@ -249,21 +248,15 @@ public class RepaintManager // component is ever used to determine the current // RepaintManager, DisplayChangedRunnable will need to be modified // accordingly. - return currentManager(AppContext.getAppContext()); - } - /** - * Returns the RepaintManager for the specified AppContext. If - * a RepaintManager has not been created for the specified - * AppContext this will return null. - */ - static RepaintManager currentManager(AppContext appContext) { - RepaintManager rm = (RepaintManager)appContext.get(repaintManagerKey); - if (rm == null) { - rm = new RepaintManager(BUFFER_STRATEGY_TYPE); - appContext.put(repaintManagerKey, rm); + synchronized (RepaintManager.class) { + RepaintManager rm = repaintManager; + if (rm == null) { + rm = new RepaintManager(BUFFER_STRATEGY_TYPE); + repaintManager = rm; + } + return rm; } - return rm; } /** @@ -282,16 +275,12 @@ public class RepaintManager /** - * Set the RepaintManager that should be used for the calling - * thread. aRepaintManager will become the current RepaintManager - * for the calling thread's thread group. + * Set the RepaintManager. * @param aRepaintManager the RepaintManager object to use */ public static void setCurrentManager(RepaintManager aRepaintManager) { - if (aRepaintManager != null) { - SwingUtilities.appContextPut(repaintManagerKey, aRepaintManager); - } else { - SwingUtilities.appContextRemove(repaintManagerKey); + synchronized (RepaintManager.class) { + repaintManager = aRepaintManager; } } @@ -373,7 +362,7 @@ public class RepaintManager // Queue a Runnable to invoke paintDirtyRegions and // validateInvalidComponents. - scheduleProcessingRunnable(SunToolkit.targetToAppContext(invalidComponent)); + scheduleProcessingRunnable(); } @@ -460,7 +449,7 @@ public class RepaintManager // Queue a Runnable to invoke paintDirtyRegions and // validateInvalidComponents. - scheduleProcessingRunnable(SunToolkit.targetToAppContext(c)); + scheduleProcessingRunnable(); } /** @@ -530,8 +519,7 @@ public class RepaintManager // This is called from the toolkit thread when a native expose is // received. // - void nativeAddDirtyRegion(AppContext appContext, Container c, - int x, int y, int w, int h) { + void nativeAddDirtyRegion(Container c, int x, int y, int w, int h) { if (w > 0 && h > 0) { synchronized(this) { Rectangle dirty = hwDirtyComponents.get(c); @@ -543,7 +531,7 @@ public class RepaintManager x, y, w, h, dirty)); } } - scheduleProcessingRunnable(appContext); + scheduleProcessingRunnable(); } } @@ -551,8 +539,7 @@ public class RepaintManager // This is called from the toolkit thread when awt needs to run a // Runnable before we paint. // - void nativeQueueSurfaceDataRunnable(AppContext appContext, - final Component c, final Runnable r) + void nativeQueueSurfaceDataRunnable(final Component c, final Runnable r) { synchronized(this) { if (runnableList == null) { @@ -560,7 +547,7 @@ public class RepaintManager } runnableList.add(r); } - scheduleProcessingRunnable(appContext); + scheduleProcessingRunnable(); } /** @@ -1411,11 +1398,11 @@ public class RepaintManager return paintManager; } - private void scheduleProcessingRunnable(AppContext context) { + private void scheduleProcessingRunnable() { if (processingRunnable.markPending()) { Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { - SunToolkit.getSystemEventQueueImplPP(context). + SunToolkit.getSystemEventQueueImplPP(). postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), processingRunnable)); } else { @@ -1733,8 +1720,7 @@ public class RepaintManager /** * Listener installed to detect display changes. When display changes, * schedules a callback to notify all RepaintManagers of the display - * changes. Only one DisplayChangedHandler is ever installed. The - * singleton instance will schedule notification for all AppContexts. + * changes. Only one DisplayChangedHandler is ever installed. */ private static final class DisplayChangedHandler implements DisplayChangedListener { @@ -1746,21 +1732,14 @@ public class RepaintManager } private static void scheduleDisplayChanges() { - // To avoid threading problems, we notify each RepaintManager + // To avoid threading problems, we notify the RepaintManager // on the thread it was created on. - for (AppContext context : AppContext.getAppContexts()) { - synchronized(context) { - if (!context.isDisposed()) { - EventQueue eventQueue = (EventQueue)context.get( - AppContext.EVENT_QUEUE_KEY); - if (eventQueue != null) { - eventQueue.postEvent(new InvocationEvent( - Toolkit.getDefaultToolkit(), - new DisplayChangedRunnable())); - } - } - } - } + EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); + eventQueue.postEvent( + new InvocationEvent( + Toolkit.getDefaultToolkit(), + new DisplayChangedRunnable()) + ); } } diff --git a/src/java.desktop/share/classes/javax/swing/SwingPaintEventDispatcher.java b/src/java.desktop/share/classes/javax/swing/SwingPaintEventDispatcher.java index 4a7b0821a3d..8c904f7d00c 100644 --- a/src/java.desktop/share/classes/javax/swing/SwingPaintEventDispatcher.java +++ b/src/java.desktop/share/classes/javax/swing/SwingPaintEventDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +28,6 @@ import java.awt.Component; import java.awt.Container; import java.awt.Rectangle; import java.awt.event.PaintEvent; -import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.event.IgnorePaintEvent; @@ -52,12 +51,10 @@ class SwingPaintEventDispatcher extends sun.awt.PaintEventDispatcher { public PaintEvent createPaintEvent(Component component, int x, int y, int w, int h) { if (component instanceof RootPaneContainer) { - AppContext appContext = SunToolkit.targetToAppContext(component); - RepaintManager rm = RepaintManager.currentManager(appContext); + RepaintManager rm = RepaintManager.currentManager(component); if (!SHOW_FROM_DOUBLE_BUFFER || !rm.show((Container)component, x, y, w, h)) { - rm.nativeAddDirtyRegion(appContext, (Container)component, - x, y, w, h); + rm.nativeAddDirtyRegion((Container)component, x, y, w, h); } // For backward compatibility generate an empty paint // event. Not doing this broke parts of Netbeans. @@ -65,10 +62,8 @@ class SwingPaintEventDispatcher extends sun.awt.PaintEventDispatcher { new Rectangle(x, y, w, h)); } else if (component instanceof SwingHeavyWeight) { - AppContext appContext = SunToolkit.targetToAppContext(component); - RepaintManager rm = RepaintManager.currentManager(appContext); - rm.nativeAddDirtyRegion(appContext, (Container)component, - x, y, w, h); + RepaintManager rm = RepaintManager.currentManager(component); + rm.nativeAddDirtyRegion((Container)component, x, y, w, h); return new IgnorePaintEvent(component, PaintEvent.PAINT, new Rectangle(x, y, w, h)); } @@ -81,9 +76,7 @@ class SwingPaintEventDispatcher extends sun.awt.PaintEventDispatcher { public boolean queueSurfaceDataReplacing(Component c, Runnable r) { if (c instanceof RootPaneContainer) { - AppContext appContext = SunToolkit.targetToAppContext(c); - RepaintManager.currentManager(appContext). - nativeQueueSurfaceDataRunnable(appContext, c, r); + RepaintManager.currentManager(c).nativeQueueSurfaceDataRunnable(c, r); return true; } return super.queueSurfaceDataReplacing(c, r); diff --git a/src/java.desktop/share/classes/javax/swing/SwingUtilities.java b/src/java.desktop/share/classes/javax/swing/SwingUtilities.java index bc6441212de..3603292b0ca 100644 --- a/src/java.desktop/share/classes/javax/swing/SwingUtilities.java +++ b/src/java.desktop/share/classes/javax/swing/SwingUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -38,7 +38,6 @@ import javax.swing.event.MenuDragMouseEvent; import javax.swing.plaf.UIResource; import javax.swing.text.View; -import sun.awt.AppContext; import sun.awt.AWTAccessor; import sun.awt.AWTAccessor.MouseEventAccessor; @@ -506,7 +505,7 @@ public class SwingUtilities implements SwingConstants public static boolean isDescendingFrom(Component a,Component b) { if(a == b) return true; - for(Container p = a.getParent();p!=null;p=p.getParent()) + for(Container p = a.getParent(); p != null; p = p.getParent()) if(p == b) return true; return false; @@ -1899,11 +1898,6 @@ public class SwingUtilities implements SwingConstants return null; } - - // Don't use String, as it's not guaranteed to be unique in a Hashtable. - private static final Object sharedOwnerFrameKey = - new StringBuffer("SwingUtilities.sharedOwnerFrame"); - @SuppressWarnings("serial") // JDK-implementation class static class SharedOwnerFrame extends Frame implements WindowListener { public void addNotify() { @@ -1961,6 +1955,7 @@ public class SwingUtilities implements SwingConstants } } + private static Frame sharedOwnerFrame; /** * Returns a toolkit-private, shared, invisible Frame * to be the owner for JDialogs and JWindows created with @@ -1970,14 +1965,12 @@ public class SwingUtilities implements SwingConstants * @see java.awt.GraphicsEnvironment#isHeadless */ static Frame getSharedOwnerFrame() throws HeadlessException { - Frame sharedOwnerFrame = - (Frame)SwingUtilities.appContextGet(sharedOwnerFrameKey); - if (sharedOwnerFrame == null) { - sharedOwnerFrame = new SharedOwnerFrame(); - SwingUtilities.appContextPut(sharedOwnerFrameKey, - sharedOwnerFrame); + synchronized (SharedOwnerFrame.class) { + if (sharedOwnerFrame == null) { + sharedOwnerFrame = new SharedOwnerFrame(); + } + return sharedOwnerFrame; } - return sharedOwnerFrame; } /** @@ -1992,26 +1985,6 @@ public class SwingUtilities implements SwingConstants return (WindowListener)sharedOwnerFrame; } - /* Don't make these AppContext accessors public or protected -- - * since AppContext is in sun.awt in 1.2, we shouldn't expose it - * even indirectly with a public API. - */ - // REMIND(aim): phase out use of 4 methods below since they - // are just private covers for AWT methods (?) - - static Object appContextGet(Object key) { - return AppContext.getAppContext().get(key); - } - - static void appContextPut(Object key, Object value) { - AppContext.getAppContext().put(key, value); - } - - static void appContextRemove(Object key) { - AppContext.getAppContext().remove(key); - } - - static Class loadSystemClass(String className) throws ClassNotFoundException { return Class.forName(className, true, Thread.currentThread(). getContextClassLoader()); diff --git a/src/java.desktop/share/classes/javax/swing/SwingWorker.java b/src/java.desktop/share/classes/javax/swing/SwingWorker.java index 75f1700bded..dae695b4868 100644 --- a/src/java.desktop/share/classes/javax/swing/SwingWorker.java +++ b/src/java.desktop/share/classes/javax/swing/SwingWorker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +45,8 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import sun.awt.AppContext; +import sun.awt.util.ThreadGroupUtils; + import sun.swing.AccumulativeRunnable; /** @@ -266,7 +267,7 @@ public abstract class SwingWorker implements RunnableFuture { */ private AccumulativeRunnable doNotifyProgressChange; - private final AccumulativeRunnable doSubmit = getDoSubmit(); + private final AccumulativeRunnable doSubmit = new DoSubmitAccumulativeRunnable(); /** * Values for the {@code state} bound property. @@ -755,18 +756,16 @@ public abstract class SwingWorker implements RunnableFuture { } + private static ExecutorService executorService; + /** * returns workersExecutorService. * - * returns the service stored in the appContext or creates it if - * necessary. + * returns the service and creates it if necessary. * * @return ExecutorService for the {@code SwingWorkers} */ private static synchronized ExecutorService getWorkersExecutorService() { - final AppContext appContext = AppContext.getAppContext(); - ExecutorService executorService = - (ExecutorService) appContext.get(SwingWorker.class); if (executorService == null) { //this creates daemon threads. ThreadFactory threadFactory = @@ -788,46 +787,26 @@ public abstract class SwingWorker implements RunnableFuture { 10L, TimeUnit.MINUTES, new LinkedBlockingQueue(), threadFactory); - appContext.put(SwingWorker.class, executorService); - // Don't use ShutdownHook here as it's not enough. We should track - // AppContext disposal instead of JVM shutdown, see 6799345 for details - final ExecutorService es = executorService; - appContext.addPropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME, - new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent pce) { - boolean disposed = (Boolean)pce.getNewValue(); - if (disposed) { - final WeakReference executorServiceRef = - new WeakReference(es); - final ExecutorService executorService = - executorServiceRef.get(); - if (executorService != null) { - executorService.shutdown(); - } - } - } + final Runnable shutdownHook = new Runnable() { + final WeakReference executorServiceRef = + new WeakReference(executorService); + public void run() { + final ExecutorService executorService = executorServiceRef.get(); + if (executorService != null) { + executorService.shutdown(); + } } - ); + }; + ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); + Thread t = new Thread(rootTG, shutdownHook, + "SwingWorker ES", 0, false); + t.setContextClassLoader(null); + Runtime.getRuntime().addShutdownHook(t); } return executorService; } - private static final Object DO_SUBMIT_KEY = new StringBuilder("doSubmit"); - private static AccumulativeRunnable getDoSubmit() { - synchronized (DO_SUBMIT_KEY) { - final AppContext appContext = AppContext.getAppContext(); - Object doSubmit = appContext.get(DO_SUBMIT_KEY); - if (doSubmit == null) { - doSubmit = new DoSubmitAccumulativeRunnable(); - appContext.put(DO_SUBMIT_KEY, doSubmit); - } - @SuppressWarnings("unchecked") - AccumulativeRunnable tmp = (AccumulativeRunnable) doSubmit; - return tmp; - } - } private static class DoSubmitAccumulativeRunnable extends AccumulativeRunnable implements ActionListener { private static final int DELAY = 1000 / 30; diff --git a/src/java.desktop/share/classes/javax/swing/Timer.java b/src/java.desktop/share/classes/javax/swing/Timer.java index 2cb8381d7d3..1063532715c 100644 --- a/src/java.desktop/share/classes/javax/swing/Timer.java +++ b/src/java.desktop/share/classes/javax/swing/Timer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -173,8 +173,7 @@ public class Timer implements Serializable private final transient Lock lock = new ReentrantLock(); // This field is maintained by TimerQueue. - // eventQueued can also be reset by the TimerQueue, but will only ever - // happen in an AppContext case when TimerQueues thread is destroyed. + // eventQueued can also be reset by the TimerQueue // access to this field is synchronized on getLock() lock. transient TimerQueue.DelayedTimer delayedTimer = null; diff --git a/src/java.desktop/share/classes/javax/swing/TimerQueue.java b/src/java.desktop/share/classes/javax/swing/TimerQueue.java index 4ef2769652a..39c06e57479 100644 --- a/src/java.desktop/share/classes/javax/swing/TimerQueue.java +++ b/src/java.desktop/share/classes/javax/swing/TimerQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +28,7 @@ package javax.swing; import java.util.concurrent.*; import java.util.concurrent.locks.*; import java.util.concurrent.atomic.AtomicLong; -import sun.awt.AppContext; +import sun.awt.util.ThreadGroupUtils; /** * Internal class to manage all Timers using one thread. @@ -40,8 +40,7 @@ import sun.awt.AppContext; */ class TimerQueue implements Runnable { - private static final Object sharedInstanceKey = - new StringBuffer("TimerQueue.sharedInstanceKey"); + private static volatile TimerQueue sharedInstance; private final DelayQueue queue; private volatile boolean running; @@ -69,14 +68,10 @@ class TimerQueue implements Runnable public static TimerQueue sharedInstance() { synchronized (classLock) { - TimerQueue sharedInst = (TimerQueue) - SwingUtilities.appContextGet( - sharedInstanceKey); - if (sharedInst == null) { - sharedInst = new TimerQueue(); - SwingUtilities.appContextPut(sharedInstanceKey, sharedInst); + if (sharedInstance == null) { + sharedInstance = new TimerQueue(); } - return sharedInst; + return sharedInstance; } } @@ -88,9 +83,10 @@ class TimerQueue implements Runnable return; } try { - final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup(); + final ThreadGroup threadGroup = ThreadGroupUtils.getRootThreadGroup(); String name = "TimerQueue"; Thread timerThread = new Thread(threadGroup, this, name, 0, false); + timerThread.setContextClassLoader(null); timerThread.setDaemon(true); timerThread.setPriority(Thread.NORM_PRIORITY); timerThread.start(); @@ -183,11 +179,6 @@ class TimerQueue implements Runnable timer.getLock().unlock(); } } catch (InterruptedException ie) { - // Shouldn't ignore InterruptedExceptions here, so AppContext - // is disposed gracefully, see 6799345 for details - if (AppContext.getAppContext().isDisposed()) { - break; - } } } } finally { diff --git a/src/java.desktop/share/classes/javax/swing/ToolTipManager.java b/src/java.desktop/share/classes/javax/swing/ToolTipManager.java index a9e2c6e69bb..4c3d0209823 100644 --- a/src/java.desktop/share/classes/javax/swing/ToolTipManager.java +++ b/src/java.desktop/share/classes/javax/swing/ToolTipManager.java @@ -61,7 +61,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis JComponent insideComponent; MouseEvent mouseEvent; boolean showImmediately; - private static final Object TOOL_TIP_MANAGER_KEY = new Object(); transient Popup tipWindow; /** The Window tip is being displayed in. This will be non-null if * the Window tip is in differs from that of insideComponent's Window. @@ -394,19 +393,19 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis } } + private static ToolTipManager manager; /** * Returns a shared ToolTipManager instance. * * @return a shared ToolTipManager object */ public static ToolTipManager sharedInstance() { - Object value = SwingUtilities.appContextGet(TOOL_TIP_MANAGER_KEY); - if (value instanceof ToolTipManager) { - return (ToolTipManager) value; + synchronized(ToolTipManager.class) { + if (manager == null) { + manager = new ToolTipManager(); + } + return manager; } - ToolTipManager manager = new ToolTipManager(); - SwingUtilities.appContextPut(TOOL_TIP_MANAGER_KEY, manager); - return manager; } // add keylistener here to trigger tip for access diff --git a/src/java.desktop/share/classes/javax/swing/TransferHandler.java b/src/java.desktop/share/classes/javax/swing/TransferHandler.java index f412314b28f..0f2229482bc 100644 --- a/src/java.desktop/share/classes/javax/swing/TransferHandler.java +++ b/src/java.desktop/share/classes/javax/swing/TransferHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -38,7 +38,6 @@ import javax.swing.text.JTextComponent; import sun.reflect.misc.MethodUtil; import sun.swing.SwingUtilities2; -import sun.awt.AppContext; import sun.swing.*; import sun.awt.SunToolkit; @@ -1096,15 +1095,12 @@ public class TransferHandler implements Serializable { private String propertyName; private static SwingDragGestureRecognizer recognizer = null; + private static DropHandler handler; private static DropTargetListener getDropTargetListener() { synchronized(DropHandler.class) { - DropHandler handler = - (DropHandler)AppContext.getAppContext().get(DropHandler.class); - if (handler == null) { handler = new DropHandler(); - AppContext.getAppContext().put(DropHandler.class, handler); } return handler; @@ -1725,29 +1721,22 @@ public class TransferHandler implements Serializable { } } + private static Clipboard clipboard; /** * Returns the clipboard to use for cut/copy/paste. */ private Clipboard getClipboard(JComponent c) { - if (SwingUtilities2.canAccessSystemClipboard()) { + if (!GraphicsEnvironment.isHeadless()) { return c.getToolkit().getSystemClipboard(); } - Clipboard clipboard = (Clipboard)sun.awt.AppContext.getAppContext(). - get(SandboxClipboardKey); - if (clipboard == null) { - clipboard = new Clipboard("Sandboxed Component Clipboard"); - sun.awt.AppContext.getAppContext().put(SandboxClipboardKey, - clipboard); + // Likely it is impossible to be here in headless. + synchronized (TransferHandler.class) { + if (clipboard == null) { + clipboard = new Clipboard("Headless clipboard"); + } + return clipboard; } - return clipboard; } - - /** - * Key used in app context to lookup Clipboard to use if access to - * System clipboard is denied. - */ - private static Object SandboxClipboardKey = new Object(); - } } diff --git a/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/src/java.desktop/share/classes/javax/swing/UIDefaults.java index d59a46dba32..67a739360f9 100644 --- a/src/java.desktop/share/classes/javax/swing/UIDefaults.java +++ b/src/java.desktop/share/classes/javax/swing/UIDefaults.java @@ -1169,7 +1169,7 @@ public class UIDefaults extends Hashtable */ private Class[] getClassArray(Object[] args) { Class[] types = null; - if (args!=null) { + if (args != null) { types = new Class[args.length]; for (int i = 0; i< args.length; i++) { /* PENDING(ges): At present only the primitive types @@ -1199,7 +1199,7 @@ public class UIDefaults extends Hashtable private String printArgs(Object[] array) { String s = "{"; - if (array !=null) { + if (array != null) { for (int i = 0 ; i < array.length-1; i++) { s = s.concat(array[i] + ","); } diff --git a/src/java.desktop/share/classes/javax/swing/UIManager.java b/src/java.desktop/share/classes/javax/swing/UIManager.java index 69063c562e6..f323842ae49 100644 --- a/src/java.desktop/share/classes/javax/swing/UIManager.java +++ b/src/java.desktop/share/classes/javax/swing/UIManager.java @@ -56,7 +56,6 @@ import sun.awt.OSInfo; import sun.swing.SwingUtilities2; import java.util.HashMap; import java.util.Objects; -import sun.awt.AppContext; import sun.awt.AWTAccessor; import sun.swing.SwingAccessor; @@ -179,10 +178,7 @@ public class UIManager implements Serializable /** * This class defines the state managed by the UIManager. For * Swing applications the fields in this class could just as well - * be static members of UIManager however we give them - * "AppContext" - * scope instead so that potentially multiple lightweight - * applications running in a single VM have their own state. + * be static members of UIManager. */ private static class LAFState { @@ -206,8 +202,8 @@ public class UIManager implements Serializable void setSystemDefaults(UIDefaults x) { tables[1] = x; } /** - * Returns the SwingPropertyChangeSupport for the current - * AppContext. If create is a true, a non-null + * Returns the SwingPropertyChangeSupport instance. + * If create is a true, a non-null * SwingPropertyChangeSupport will be returned, if * create is false and this has not been invoked * with true, null will be returned. @@ -1366,18 +1362,7 @@ public class UIManager implements Serializable return; } - // Try to get default LAF from system property, then from AppContext - // (6653395), then use cross-platform one by default. - String lafName = null; - @SuppressWarnings("unchecked") - HashMap lafData = - (HashMap) AppContext.getAppContext().remove("swing.lafdata"); - if (lafData != null) { - lafName = lafData.remove("defaultlaf"); - } - if (lafName == null) { - lafName = getCrossPlatformLookAndFeelClassName(); - } + String lafName = getCrossPlatformLookAndFeelClassName(); lafName = swingProps.getProperty(defaultLAFKey, lafName); try { @@ -1385,13 +1370,6 @@ public class UIManager implements Serializable } catch (Exception e) { throw new Error("Cannot load " + lafName); } - - // Set any properties passed through AppContext (6653395). - if (lafData != null) { - for (Object key: lafData.keySet()) { - UIManager.put(key, lafData.get(key)); - } - } } @@ -1451,8 +1429,8 @@ public class UIManager implements Serializable /* * This method is called before any code that depends on the - * AppContext specific LAFState object runs. - * In some AppContext cases, it's possible for this method + * LAFState object runs. + * In some cases, it's possible for this method * to be re-entered, which is why we grab a lock before calling * initialize(). */ diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java index 38798d4c94f..42791772c2d 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java @@ -1070,11 +1070,11 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup { ComponentOrientation o =(ComponentOrientation)e.getNewValue(); JList list = getList(); - if (list!=null && list.getComponentOrientation()!=o) { + if (list != null && list.getComponentOrientation()!=o) { list.setComponentOrientation(o); } - if (scroller!=null && scroller.getComponentOrientation()!=o) { + if (scroller != null && scroller.getComponentOrientation()!=o) { scroller.setComponentOrientation(o); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java index 0a4aa03dce9..ab5fdb12c5a 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java @@ -876,7 +876,7 @@ public class BasicListUI extends ListUI } Long l = (Long)UIManager.get("List.timeFactor"); - timeFactor = (l!=null) ? l.longValue() : 1000L; + timeFactor = (l != null) ? l.longValue() : 1000L; updateIsFileList(); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java index 2079aafd3a2..b7310b56aef 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java @@ -125,7 +125,7 @@ public class BasicMenuBarUI extends MenuBarUI { for (int i = 0; i < menuBar.getMenuCount(); i++) { JMenu menu = menuBar.getMenu(i); - if (menu!=null) + if (menu != null) menu.getModel().addChangeListener(changeListener); } menuBar.addContainerListener(containerListener); @@ -167,7 +167,7 @@ public class BasicMenuBarUI extends MenuBarUI { * Uninstalls default properties. */ protected void uninstallDefaults() { - if (menuBar!=null) { + if (menuBar != null) { LookAndFeel.uninstallBorder(menuBar); } } @@ -180,7 +180,7 @@ public class BasicMenuBarUI extends MenuBarUI { for (int i = 0; i < menuBar.getMenuCount(); i++) { JMenu menu = menuBar.getMenu(i); - if (menu !=null) + if (menu != null) menu.getModel().removeChangeListener(changeListener); } @@ -240,7 +240,7 @@ public class BasicMenuBarUI extends MenuBarUI { int i,c; for(i=0,c = menuBar.getMenuCount() ; i < c ; i++) { JMenu menu = menuBar.getMenu(i); - if(menu !=null && menu.isSelected()) { + if(menu != null && menu.isSelected()) { menuBar.getSelectionModel().setSelectedIndex(i); break; } @@ -277,7 +277,7 @@ public class BasicMenuBarUI extends MenuBarUI { MenuElement[] me; MenuElement[] subElements; JMenu menu = menuBar.getMenu(0); - if (menu!=null) { + if (menu != null) { me = new MenuElement[3]; me[0] = (MenuElement) menuBar; me[1] = (MenuElement) menu; diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java index 8df27d3e3cb..b72a2d8a140 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java @@ -908,7 +908,7 @@ public class BasicPopupMenuUI extends PopupMenuUI { } boolean isInPopup(Component src) { - for (Component c=src; c!=null; c=c.getParent()) { + for (Component c=src; c != null; c=c.getParent()) { if (c instanceof Window) { break; } else if (c instanceof JPopupMenu) { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java index 2b871343697..7080fa3aac1 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java @@ -688,7 +688,7 @@ public class BasicSpinnerUI extends SpinnerUI arrowButton = (JButton)e.getSource(); } } else { - if (arrowButton!=null && !arrowButton.getModel().isPressed() + if (arrowButton != null && !arrowButton.getModel().isPressed() && autoRepeatTimer.isRunning()) { autoRepeatTimer.stop(); spinner = null; diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java index 270181f4600..1d8c471e9ec 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java @@ -2273,7 +2273,7 @@ public class BasicSplitPaneUI extends SplitPaneUI JSplitPane parentSplitPane = (JSplitPane)SwingUtilities.getAncestorOfClass( JSplitPane.class, splitPane); - if (parentSplitPane!=null) { + if (parentSplitPane != null) { parentSplitPane.requestFocus(); } } @@ -2307,7 +2307,7 @@ public class BasicSplitPaneUI extends SplitPaneUI } while (splitPane.isAncestorOf(focusOn) && !focusFrom.contains(focusOn)); } - if ( focusOn!=null && !splitPane.isAncestorOf(focusOn) ) { + if ( focusOn != null && !splitPane.isAncestorOf(focusOn) ) { focusOn.requestFocus(); } } @@ -2323,7 +2323,7 @@ public class BasicSplitPaneUI extends SplitPaneUI if (focusOn != null) { // don't change the focus if the new focused component belongs // to the same splitpane and the same side - if ( focus!=null && + if ( focus != null && ( (SwingUtilities.isDescendingFrom(focus, left) && SwingUtilities.isDescendingFrom(focusOn, left)) || (SwingUtilities.isDescendingFrom(focus, right) && @@ -2338,15 +2338,15 @@ public class BasicSplitPaneUI extends SplitPaneUI Component left = splitPane.getLeftComponent(); Component right = splitPane.getRightComponent(); Component next; - if (focus!=null && SwingUtilities.isDescendingFrom(focus, left) && - right!=null) { + if (focus != null && SwingUtilities.isDescendingFrom(focus, left) && + right != null) { next = getFirstAvailableComponent(right); if (next != null) { return next; } } JSplitPane parentSplitPane = (JSplitPane)SwingUtilities.getAncestorOfClass(JSplitPane.class, splitPane); - if (parentSplitPane!=null) { + if (parentSplitPane != null) { // focus next side of the parent split pane next = getNextSide(parentSplitPane, focus); } else { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java index 842e8892c76..6e0d0101b9c 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java @@ -528,7 +528,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { } tabPane.removeContainerListener(getHandler()); - if (htmlViews!=null) { + if (htmlViews != null) { htmlViews.removeAllElements(); htmlViews = null; } @@ -4090,7 +4090,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { setHtmlView(v, inserted, index); } } else { // Not HTML - if (htmlViews!=null) { // Add placeholder + if (htmlViews != null) { // Add placeholder setHtmlView(null, inserted, index); } // else nada! } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java index 41ab6137976..1bcd4a9be8d 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java @@ -980,7 +980,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants { toolBar.setOrientation( orientation ); - if (dragWindow !=null) + if (dragWindow != null) dragWindow.setOrientation(orientation); } @@ -1616,7 +1616,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants this.orientation = o; Dimension size = getSize(); setSize(new Dimension(size.height, size.width)); - if (offset!=null) { + if (offset != null) { if( BasicGraphicsUtils.isLeftToRight(toolBar) ) { setOffset(new Point(offset.y, offset.x)); } else if( o == JToolBar.HORIZONTAL ) { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java index 28beaee6929..096fe7cc5f7 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java @@ -943,7 +943,7 @@ public class BasicTreeUI extends TreeUI lineTypeDashed = UIManager.getBoolean("Tree.lineTypeDashed"); Long l = (Long)UIManager.get("Tree.timeFactor"); - timeFactor = (l!=null) ? l.longValue() : 1000L; + timeFactor = (l != null) ? l.longValue() : 1000L; Object showsRootHandles = UIManager.get("Tree.showsRootHandles"); if (showsRootHandles != null) { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java index abdd460e44b..517dad35d45 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,14 +29,12 @@ import java.awt.event.*; import java.awt.dnd.DragSource; import javax.swing.*; import sun.awt.dnd.SunDragSourceContextPeer; -import sun.awt.AppContext; /** * Drag gesture recognition support for classes that have a * TransferHandler. The gesture for a drag in this class is a mouse * press followed by movement by DragSource.getDragThreshold() - * pixels. An instance of this class is maintained per AppContext, and the - * public static methods call into the appropriate instance. + * pixels. * * @author Shannon Hickey */ @@ -53,19 +51,14 @@ class DragRecognitionSupport { public void dragStarting(MouseEvent me); } + private static DragRecognitionSupport support; /** - * Returns the DragRecognitionSupport for the caller's AppContext. + * Returns the DragRecognitionSupport instance. */ - private static DragRecognitionSupport getDragRecognitionSupport() { - DragRecognitionSupport support = - (DragRecognitionSupport)AppContext.getAppContext(). - get(DragRecognitionSupport.class); - + private static synchronized DragRecognitionSupport getDragRecognitionSupport() { if (support == null) { support = new DragRecognitionSupport(); - AppContext.getAppContext().put(DragRecognitionSupport.class, support); } - return support; } 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 35fc07de056..1d131c9d294 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; -import sun.awt.AppContext; import javax.swing.*; import javax.swing.plaf.*; diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTitlePane.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTitlePane.java index ae8b379a579..4ed6734df1f 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTitlePane.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTitlePane.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -437,6 +437,7 @@ class MetalTitlePane extends JComponent { */ private JMenu createMenu() { JMenu menu = new JMenu(""); + menu.setPreferredSize(new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT)); if (getWindowDecorationStyle() == JRootPane.FRAME) { addMenuItems(menu); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java index 1bdff19fa2d..cfcc014940a 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java @@ -660,7 +660,7 @@ public abstract class AbstractRegionPainter implements Painter { ImageScalingHelper.paint(g, 0, 0, w, h, img, insets, dstInsets, ImageScalingHelper.PaintType.PAINT9_STRETCH, ImageScalingHelper.PAINT_ALL); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - oldScalingHints!=null?oldScalingHints:RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + oldScalingHints != null ? oldScalingHints:RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); } else { // render directly paint0(g, c, w, h, extendedCacheKeys); diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java index c9340a62368..05fa3bbc9b6 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java @@ -531,7 +531,7 @@ public class NimbusLookAndFeel extends SynthLookAndFeel { public Object createValue(UIDefaults table) { Object obj = null; // check specified state - if (state!=null){ + if (state != null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java index ca19a74b6ac..1842073588b 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java @@ -63,13 +63,13 @@ class SynthPainterImpl extends SynthPainter { if (p != null) { if (g instanceof Graphics2D){ Graphics2D gfx = (Graphics2D)g; - if (transform!=null){ + if (transform != null) { gfx.transform(transform); } gfx.translate(x, y); p.paint(gfx, ctx.getComponent(), w, h); gfx.translate(-x, -y); - if (transform!=null){ + if (transform != null){ try { gfx.transform(transform.createInverse()); } catch (NoninvertibleTransformException e) { @@ -85,7 +85,7 @@ class SynthPainterImpl extends SynthPainter { BufferedImage img = new BufferedImage(w,h, BufferedImage.TYPE_INT_ARGB); Graphics2D gfx = img.createGraphics(); - if (transform!=null){ + if (transform != null){ gfx.transform(transform); } p.paint(gfx, ctx.getComponent(), w, h); diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java index 77ca2a1fc05..ad10e70a837 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java @@ -814,7 +814,7 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements public void propertyChange(PropertyChangeEvent evt) { ComboBoxEditor newEditor = comboBox.getEditor(); if (editor != newEditor){ - if (editorComponent!=null){ + if (editorComponent != null) { editorComponent.removeFocusListener(this); } editor = newEditor; diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java index 96541d51f67..0c3a17fbdbb 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java @@ -225,7 +225,7 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI private int getComponentState(JComponent c) { int baseState = SynthLookAndFeel.getComponentState(c); - if (viewportViewFocusHandler!=null && viewportViewHasFocus){ + if (viewportViewFocusHandler != null && viewportViewHasFocus) { baseState = baseState | FOCUSED; } return baseState; diff --git a/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java b/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java index 59cee1e12ee..f81ba9d66c2 100644 --- a/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java +++ b/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java @@ -1181,7 +1181,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A Hashtable h = new Hashtable(); for (Action a : actions) { String value = (String)a.getValue(Action.NAME); - h.put((value!=null ? value:""), a); + h.put((value != null ? value : ""), a); } for (KeyBinding binding : bindings) { Action a = h.get(binding.actionName); diff --git a/src/java.desktop/share/classes/javax/swing/text/TextAction.java b/src/java.desktop/share/classes/javax/swing/text/TextAction.java index 5c11c994ab2..d05f7e24a6b 100644 --- a/src/java.desktop/share/classes/javax/swing/text/TextAction.java +++ b/src/java.desktop/share/classes/javax/swing/text/TextAction.java @@ -107,11 +107,11 @@ public abstract class TextAction extends AbstractAction { Hashtable h = new Hashtable(); for (Action a : list1) { String value = (String)a.getValue(Action.NAME); - h.put((value!=null ? value:""), a); + h.put((value != null ? value : ""), a); } for (Action a : list2) { String value = (String)a.getValue(Action.NAME); - h.put((value!=null ? value:""), a); + h.put((value != null ? value : ""), a); } Action[] actions = new Action[h.size()]; int index = 0; diff --git a/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellEditor.java b/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellEditor.java index 4662c95c01f..3f3721dd30a 100644 --- a/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellEditor.java +++ b/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellEditor.java @@ -259,7 +259,7 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor, ((MouseEvent)event).getY()); editable = (lastPath != null && path != null && lastPath.equals(path)); - if (path!=null) { + if (path != null) { lastRow = tree.getRowForPath(path); Object value = path.getLastPathComponent(); boolean isSelected = tree.isRowSelected(lastRow); diff --git a/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index 3c63a390a81..f98118171b4 100644 --- a/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -361,13 +361,6 @@ public final class AWTAccessor { * Accessor for InputEvent.getButtonDownMasks() */ int[] getButtonDownMasks(); - - /* - * Accessor for InputEvent.canAccessSystemClipboard field - */ - boolean canAccessSystemClipboard(InputEvent event); - void setCanAccessSystemClipboard(InputEvent event, - boolean canAccessSystemClipboard); } /** @@ -451,16 +444,6 @@ public final class AWTAccessor { * An accessor for the MenuComponent class. */ public interface MenuComponentAccessor { - /** - * Returns the appContext of the menu component. - */ - AppContext getAppContext(MenuComponent menuComp); - - /** - * Sets the appContext of the menu component. - */ - void setAppContext(MenuComponent menuComp, AppContext appContext); - /** * Returns the peer of the menu component. */ diff --git a/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 9b2f756fd56..e97b654486f 100644 --- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -333,9 +333,6 @@ public abstract class SunToolkit extends Toolkit if (target instanceof Component) { AWTAccessor.getComponentAccessor(). setAppContext((Component)target, context); - } else if (target instanceof MenuComponent) { - AWTAccessor.getMenuComponentAccessor(). - setAppContext((MenuComponent)target, context); } else { return false; } @@ -351,8 +348,7 @@ public abstract class SunToolkit extends Toolkit return AWTAccessor.getComponentAccessor(). getAppContext((Component)target); } else if (target instanceof MenuComponent) { - return AWTAccessor.getMenuComponentAccessor(). - getAppContext((MenuComponent)target); + return AppContext.getAppContext(); } else { return null; } @@ -414,6 +410,11 @@ public abstract class SunToolkit extends Toolkit cont.setFocusTraversalPolicy(defaultPolicy); } + /* This method should be removed at the same time as targetToAppContext() */ + public static void insertTargetMapping(Object target) { + insertTargetMapping(target, AppContext.getAppContext()); + } + /* * Insert a mapping from target to AppContext, for later retrieval * via targetToAppContext() above. @@ -1033,8 +1034,7 @@ public abstract class SunToolkit extends Toolkit return getSystemEventQueueImplPP(); } - // Package private implementation - static EventQueue getSystemEventQueueImplPP() { + public static EventQueue getSystemEventQueueImplPP() { return getSystemEventQueueImplPP(AppContext.getAppContext()); } diff --git a/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java b/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java index 6c03fa83369..9f247ed7fbd 100644 --- a/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java +++ b/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -87,7 +87,6 @@ import javax.imageio.spi.ImageWriterSpi; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; -import sun.awt.AppContext; import sun.awt.ComponentFactory; import sun.awt.SunToolkit; import sun.awt.image.ImageRepresentation; @@ -154,9 +153,9 @@ public abstract class DataTransferer { Collections.synchronizedMap(new HashMap<>()); /** - * The key used to store pending data conversion requests for an AppContext. + * The Runnable for pending data conversion requests. */ - private static final String DATA_CONVERTER_KEY = "DATA_CONVERTER_KEY"; + private static volatile Runnable dataConverterInstance; static { DataFlavor tJavaTextEncodingFlavor = null; @@ -1769,13 +1768,9 @@ search: } }; - final AppContext appContext = SunToolkit.targetToAppContext(source); - getToolkitThreadBlockedHandler().lock(); - if (appContext != null) { - appContext.put(DATA_CONVERTER_KEY, dataConverter); - } + dataConverterInstance = dataConverter; SunToolkit.executeOnEventHandlerThread(source, dataConverter); @@ -1783,9 +1778,7 @@ search: getToolkitThreadBlockedHandler().enter(); } - if (appContext != null) { - appContext.remove(DATA_CONVERTER_KEY); - } + dataConverterInstance = null; ret = stack.pop(); } finally { @@ -1802,14 +1795,12 @@ search: public void processDataConversionRequests() { if (EventQueue.isDispatchThread()) { - AppContext appContext = AppContext.getAppContext(); getToolkitThreadBlockedHandler().lock(); try { - Runnable dataConverter = - (Runnable)appContext.get(DATA_CONVERTER_KEY); + Runnable dataConverter = dataConverterInstance; if (dataConverter != null) { dataConverter.run(); - appContext.remove(DATA_CONVERTER_KEY); + dataConverterInstance = null; } } finally { getToolkitThreadBlockedHandler().unlock(); diff --git a/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java b/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java index e96ca888ee3..4234dbad59a 100644 --- a/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java +++ b/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,7 +25,6 @@ package sun.awt.datatransfer; -import sun.awt.AppContext; import sun.datatransfer.DesktopDatatransferService; import java.awt.EventQueue; @@ -43,8 +42,6 @@ import java.util.function.Supplier; */ public class DesktopDatatransferServiceImpl implements DesktopDatatransferService { - private static final Object FLAVOR_MAP_KEY = new Object(); - @Override public void invokeOnEventThread(Runnable r) { EventQueue.invokeLater(r); @@ -59,13 +56,11 @@ public class DesktopDatatransferServiceImpl implements DesktopDatatransferServic return null; } + private FlavorMap fm; @Override - public FlavorMap getFlavorMap(Supplier supplier) { - AppContext context = AppContext.getAppContext(); - FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY); + public synchronized FlavorMap getFlavorMap(Supplier supplier) { if (fm == null) { fm = supplier.get(); - context.put(FLAVOR_MAP_KEY, fm); } return fm; } diff --git a/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java b/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java index bc8071a798b..4ccee481a9e 100644 --- a/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java +++ b/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java @@ -226,9 +226,6 @@ public abstract class SunClipboard extends Clipboard { * argument is not {@code null} and is not equal to the current * contents context. * - * @param disposedContext the AppContext that is disposed or - * {@code null} if the ownership is lost because another - * application acquired ownership. */ protected void lostOwnershipLater() { SunToolkit.postEvent(new PeerEvent(this, () -> lostOwnershipNow(), diff --git a/src/java.desktop/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java b/src/java.desktop/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java index 258cebd6616..4aad70961bc 100644 --- a/src/java.desktop/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java +++ b/src/java.desktop/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -264,8 +264,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer modifiers, x, y); EventDispatcher dispatcher = new EventDispatcher(dispatchType, event); - SunToolkit.invokeLaterOnAppContext( - SunToolkit.targetToAppContext(getComponent()), dispatcher); + SunToolkit.invokeLater(dispatcher); startSecondaryEventLoop(); } @@ -310,8 +309,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer EventDispatcher dispatcher = new EventDispatcher(DISPATCH_EXIT, event); - SunToolkit.invokeLaterOnAppContext( - SunToolkit.targetToAppContext(getComponent()), dispatcher); + SunToolkit.invokeLater(dispatcher); startSecondaryEventLoop(); } @@ -341,8 +339,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer EventDispatcher dispatcher = new EventDispatcher(DISPATCH_FINISH, event); - SunToolkit.invokeLaterOnAppContext( - SunToolkit.targetToAppContext(getComponent()), dispatcher); + SunToolkit.invokeLater(dispatcher); startSecondaryEventLoop(); setNativeContext(0); diff --git a/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java b/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java index 686c3166441..70d1bda9cd0 100644 --- a/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java +++ b/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -55,7 +55,6 @@ import sun.util.logging.PlatformLogger; import java.io.IOException; import java.io.InputStream; -import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.ToolkitThreadBlockedHandler; @@ -558,7 +557,6 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer, final long nativeCtxt, final int eventID, final boolean dispatchType) { - AppContext appContext = SunToolkit.targetToAppContext(component); EventDispatcher dispatcher = new EventDispatcher(this, dropAction, actions, formats, nativeCtxt, @@ -572,7 +570,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer, } // schedule callback - SunToolkit.postEvent(appContext, event); + SunToolkit.postEvent(event); eventPosted(event); diff --git a/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java b/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java index d8246a4947c..f67f560e004 100644 --- a/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java +++ b/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import java.awt.PopupMenu; import java.awt.Menu; import java.awt.MenuItem; import java.awt.Toolkit; -import sun.awt.AppContext; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InvocationEvent; @@ -177,9 +176,8 @@ class ExecutableInputMethodManager extends InputMethodManager lock, true); - AppContext requesterAppContext = SunToolkit.targetToAppContext(requester); synchronized (lock) { - SunToolkit.postEvent(requesterAppContext, event); + SunToolkit.postEvent(event); while (!event.isDispatched()) { lock.wait(); } diff --git a/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java b/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java index 0da7dbed6ea..c3968f19b60 100644 --- a/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java +++ b/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java @@ -35,7 +35,6 @@ import java.awt.PopupMenu; import java.awt.Menu; import java.awt.MenuItem; import java.awt.Toolkit; -import sun.awt.AppContext; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InvocationEvent; diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java index 917378389a4..986b79edde9 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2026, 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 @@ -314,10 +314,10 @@ class FetcherInfo { static final int MAX_NUM_FETCHERS = 4; static final FetcherInfo FETCHER_INFO = new FetcherInfo(); - Thread[] fetchers; + final Thread[] fetchers; int numFetchers; int numWaiting; - Vector waitList; + final Vector waitList; private FetcherInfo() { fetchers = new Thread[MAX_NUM_FETCHERS]; diff --git a/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java b/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java index bc025b87f3c..1b7cd41daa9 100644 --- a/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java +++ b/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java @@ -43,22 +43,25 @@ import static java.lang.Math.multiplyExact; /** * Parse files of the form: * + * {@snippet lang=c: * #define foo_width w * #define foo_height h * static char foo_bits[] = { * 0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn, * 0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn,0xnn, * 0xnn,0xnn,0xnn,0xnn}; + * } * * @author James Gosling */ public class XbmImageDecoder extends ImageDecoder { - private static byte[] XbmColormap = {(byte) 255, (byte) 255, (byte) 255, - 0, 0, 0}; - private static int XbmHints = (ImageConsumer.TOPDOWNLEFTRIGHT | - ImageConsumer.COMPLETESCANLINES | - ImageConsumer.SINGLEPASS | - ImageConsumer.SINGLEFRAME); + private static final byte[] XbmColormap = {(byte) 255, (byte) 255, (byte) 255, + 0, 0, 0}; + private static final int XbmHints = (ImageConsumer.TOPDOWNLEFTRIGHT | + ImageConsumer.COMPLETESCANLINES | + ImageConsumer.SINGLEPASS | + ImageConsumer.SINGLEFRAME); + private static final int MAX_XBM_SIZE = 16384; private static final int HEADER_SCAN_LIMIT = 100; @@ -110,20 +113,15 @@ public class XbmImageDecoder extends ImageDecoder { error("Error while parsing define statement"); } try { - if (!token[2].isBlank() && state == 0) { - if (token[1].endsWith("th")) { + if (state < 2) { + if (token[1].endsWith("h")) { W = Integer.parseInt(token[2]); - } else if (token[1].endsWith("t")) { + } else if (token[1].endsWith("ht")) { H = Integer.parseInt(token[2]); } - state = 1; // after first dimension is set - } else if (!token[2].isBlank() && state == 1) { - if (token[1].endsWith("th")) { - W = Integer.parseInt(token[2]); - } else if (token[1].endsWith("t")) { - H = Integer.parseInt(token[2]); - } - state = 2; // after second dimension is set + // After the 1st dimension is set, state becomes 1; + // after the 2nd dimension is set, state becomes 2 + ++state; } } catch (NumberFormatException nfe) { // parseInt() can throw NFE diff --git a/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java b/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java index 85c631d6e3e..f3569941321 100644 --- a/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java +++ b/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -399,7 +399,7 @@ class ExtendedTextSourceLabel implements TextLineComponent, Decoration.Label { int start = source.getStart(); int length = source.getLength(); - GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines + GlyphLayout gl = GlyphLayout.get(); gv = gl.layout(font, frc, context, start, length, flags, null); // ??? use textsource GlyphLayout.done(gl); diff --git a/src/java.desktop/share/classes/sun/font/GlyphLayout.java b/src/java.desktop/share/classes/sun/font/GlyphLayout.java index fe2a8bf2599..5bff127f143 100644 --- a/src/java.desktop/share/classes/sun/font/GlyphLayout.java +++ b/src/java.desktop/share/classes/sun/font/GlyphLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,7 +76,7 @@ import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Point2D; import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; +import java.util.WeakHashMap; import static java.lang.Character.*; @@ -87,7 +87,6 @@ public final class GlyphLayout { // cached glyph layout data for reuse private static volatile GlyphLayout cache; // reusable - private LayoutEngineFactory _lef; // set when get is called, unset when done is called private TextRecord _textRecord; // the text we're working on, used by iterators private ScriptRun _scriptRuns; // iterator over script runs private FontRunIterator _fontRuns; // iterator over physical fonts in a composite @@ -100,91 +99,10 @@ public final class GlyphLayout { private int _typo_flags; private int _offset; - public static final class LayoutEngineKey { - private Font2D font; - private int script; - private int lang; - - LayoutEngineKey() { - } - - LayoutEngineKey(Font2D font, int script, int lang) { - init(font, script, lang); - } - - void init(Font2D font, int script, int lang) { - this.font = font; - this.script = script; - this.lang = lang; - } - - LayoutEngineKey copy() { - return new LayoutEngineKey(font, script, lang); - } - - Font2D font() { - return font; - } - - int script() { - return script; - } - - int lang() { - return lang; - } - - public boolean equals(Object rhs) { - if (this == rhs) return true; - if (rhs == null) return false; - try { - LayoutEngineKey that = (LayoutEngineKey)rhs; - return this.script == that.script && - this.lang == that.lang && - this.font.equals(that.font); - } - catch (ClassCastException e) { - return false; - } - } - - public int hashCode() { - return script ^ lang ^ font.hashCode(); - } - } - - public static interface LayoutEngineFactory { - /** - * Given a font, script, and language, determine a layout engine to use. - */ - public LayoutEngine getEngine(Font2D font, int script, int lang); - - /** - * Given a key, determine a layout engine to use. - */ - public LayoutEngine getEngine(LayoutEngineKey key); - } - - public static interface LayoutEngine { - /** - * Given a strike descriptor, text, rtl flag, and starting point, append information about - * glyphs, positions, and character indices to the glyphvector data, and advance the point. - * - * If the GVData does not have room for the glyphs, throws an IndexOutOfBoundsException and - * leave pt and the gvdata unchanged. - */ - public void layout(FontStrikeDesc sd, float[] mat, float ptSize, int gmask, - int baseIndex, TextRecord text, int typo_flags, Point2D.Float pt, GVData data); - } - /** - * Return a new instance of GlyphLayout, using the provided layout engine factory. - * If null, the system layout engine factory will be used. + * Return a possibly recycled instance of GlyphLayout */ - public static GlyphLayout get(LayoutEngineFactory lef) { - if (lef == null) { - lef = SunLayoutEngine.instance(); - } + public static GlyphLayout get() { GlyphLayout result = null; synchronized(GlyphLayout.class) { if (cache != null) { @@ -195,7 +113,6 @@ public final class GlyphLayout { if (result == null) { result = new GlyphLayout(); } - result._lef = lef; return result; } @@ -204,23 +121,16 @@ public final class GlyphLayout { * of GlyphLayout objects. */ public static void done(GlyphLayout gl) { - gl._lef = null; cache = gl; // object reference assignment is thread safe, it says here... } private static final class SDCache { - public Font key_font; - public FontRenderContext key_frc; - public AffineTransform dtx; public AffineTransform gtx; public Point2D.Float delta; public FontStrikeDesc sd; private SDCache(Font font, FontRenderContext frc) { - key_font = font; - key_frc = frc; - // !!! add getVectorTransform and hasVectorTransform to frc? then // we could just skip this work... @@ -261,7 +171,7 @@ public final class GlyphLayout { private static final Point2D.Float ZERO_DELTA = new Point2D.Float(); private static - SoftReference> cacheRef; + SoftReference> cacheRef; private static final class SDKey { private final Font font; @@ -316,7 +226,7 @@ public final class GlyphLayout { } SDKey key = new SDKey(font, frc); // garbage, yuck... - ConcurrentHashMap cache = null; + WeakHashMap cache = null; SDCache res = null; if (cacheRef != null) { cache = cacheRef.get(); @@ -327,13 +237,17 @@ public final class GlyphLayout { if (res == null) { res = new SDCache(font, frc); if (cache == null) { - cache = new ConcurrentHashMap(10); + cache = new WeakHashMap(10); cacheRef = new - SoftReference>(cache); - } else if (cache.size() >= 512) { - cache.clear(); + SoftReference>(cache); + } else if (cache.size() >= 128) { + synchronized (SDCache.class) { + cache.clear(); + } + } + synchronized (SDCache.class) { + cache.put(key, res); } - cache.put(key, res); } return res; } @@ -398,8 +312,6 @@ public final class GlyphLayout { } } - int lang = -1; // default for now - Font2D font2D = FontUtilities.getFont2D(font); if (font2D instanceof FontSubstitution) { font2D = ((FontSubstitution)font2D).getCompositeFont2D(); @@ -426,7 +338,7 @@ public final class GlyphLayout { } int gmask = _fontRuns.getGlyphMask(); int pos = _fontRuns.getPos(); - nextEngineRecord(start, pos, script, lang, pfont, gmask); + nextEngineRecord(start, pos, script, pfont, gmask); start = pos; } } @@ -435,7 +347,7 @@ public final class GlyphLayout { while (_scriptRuns.next()) { int limit = _scriptRuns.getScriptLimit(); int script = _scriptRuns.getScriptCode(); - nextEngineRecord(start, limit, script, lang, font2D, 0); + nextEngineRecord(start, limit, script, font2D, 0); start = limit; } } @@ -508,7 +420,7 @@ public final class GlyphLayout { this._gvdata.init(capacity); } - private void nextEngineRecord(int start, int limit, int script, int lang, Font2D font, int gmask) { + private void nextEngineRecord(int start, int limit, int script, Font2D font, int gmask) { EngineRecord er = null; if (_ercount == _erecords.size()) { er = new EngineRecord(); @@ -516,7 +428,7 @@ public final class GlyphLayout { } else { er = _erecords.get(_ercount); } - er.init(start, limit, font, script, lang, gmask); + er.init(start, limit, font, script, gmask); ++_ercount; } @@ -627,18 +539,18 @@ public final class GlyphLayout { private int limit; private int gmask; private int eflags; - private LayoutEngineKey key; - private LayoutEngine engine; + private Font2D font; + private int script; EngineRecord() { - key = new LayoutEngineKey(); } - void init(int start, int limit, Font2D font, int script, int lang, int gmask) { + void init(int start, int limit, Font2D font, int script, int gmask) { this.start = start; this.limit = limit; + this.font = font; + this.script = script; this.gmask = gmask; - this.key.init(font, script, lang); this.eflags = 0; // only request canonical substitution if we have combining marks @@ -659,14 +571,12 @@ public final class GlyphLayout { break; } } - - this.engine = _lef.getEngine(key); // flags? } void layout() { _textRecord.start = start; _textRecord.limit = limit; - engine.layout(_sd, _mat, ptSize, gmask, start - _offset, _textRecord, + SunLayoutEngine.layout(font, script, _sd, _mat, ptSize, gmask, start - _offset, _textRecord, _typo_flags | eflags, _pt, _gvdata); } } diff --git a/src/java.desktop/share/classes/sun/font/HBShaper.java b/src/java.desktop/share/classes/sun/font/HBShaper.java index 7d3f58fb88f..3a532072004 100644 --- a/src/java.desktop/share/classes/sun/font/HBShaper.java +++ b/src/java.desktop/share/classes/sun/font/HBShaper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -138,6 +138,7 @@ public class HBShaper { private static final MemorySegment get_h_advance_stub; private static final MemorySegment get_v_advance_stub; private static final MemorySegment get_contour_pt_stub; + private static final MemorySegment get_table_data_fn_stub; private static final MemorySegment store_layout_results_stub; @@ -209,6 +210,12 @@ public class HBShaper { jdk_hb_shape_handle = tmp4; Arena garena = Arena.global(); // creating stubs that exist until VM exit. + + get_table_data_fn_stub = getUpcallStub(garena, + "getFontTableData", // method name + JAVA_INT, // return type + JAVA_INT, ADDRESS); // arg types + FunctionDescriptor get_var_glyph_fd = getFunctionDescriptor(JAVA_INT, // return type ADDRESS, ADDRESS, JAVA_INT, JAVA_INT, ADDRESS, ADDRESS); // arg types MethodHandle get_var_glyph_mh = @@ -303,15 +310,9 @@ public class HBShaper { clusterHandle = getVarHandle(GlyphInfoLayout, "cluster"); } - - /* - * This is expensive but it is done just once per font. - * The unbound stub could be cached but the savings would - * be very low in the only case it is used. - */ @SuppressWarnings("restricted") - private static MemorySegment getBoundUpcallStub - (Arena arena, Class clazz, Object bindArg, String mName, + private static MemorySegment getUpcallStub + (Arena arena, String mName, MemoryLayout retType, MemoryLayout... argTypes) { try { @@ -320,10 +321,8 @@ public class HBShaper { FunctionDescriptor.ofVoid(argTypes) : FunctionDescriptor.of(retType, argTypes); MethodType mType = nativeDescriptor.toMethodType(); - mType = mType.insertParameterTypes(0, clazz); MethodHandle mh = MH_LOOKUP.findStatic(HBShaper.class, mName, mType); - MethodHandle bound_handle = mh.bindTo(bindArg); - return LINKER.upcallStub(bound_handle, nativeDescriptor, arena); + return LINKER.upcallStub(mh, nativeDescriptor, arena); } catch (IllegalAccessException | NoSuchMethodException e) { return null; } @@ -480,15 +479,16 @@ public class HBShaper { }); } - private static int getFontTableData(Font2D font2D, - int tag, - MemorySegment data_ptr_out) { + private static int getFontTableData(int tag, MemorySegment data_ptr_out) { /* * On return, the data_out_ptr will point to memory allocated by native malloc, * so it will be freed by the caller using native free - when it is * done with it. */ + + Font2D font2D = scopedVars.get().font(); + @SuppressWarnings("restricted") MemorySegment data_ptr = data_ptr_out.reinterpret(ADDRESS.byteSize()); if (tag == 0) { @@ -539,10 +539,6 @@ public class HBShaper { private static class FaceRef implements DisposerRecord { private Font2D font2D; private MemorySegment face; - // get_table_data_fn uses an Arena managed by GC, - // so we need to keep a reference to it here until - // this FaceRef is collected. - private MemorySegment get_table_data_fn; private FaceRef(Font2D font) { this.font2D = font; @@ -561,16 +557,7 @@ public class HBShaper { private void createFace() { try { - get_table_data_fn = getBoundUpcallStub(Arena.ofAuto(), - Font2D.class, - font2D, // bind arg - "getFontTableData", // method name - JAVA_INT, // return type - JAVA_INT, ADDRESS); // arg types - if (get_table_data_fn == null) { - return; - } - face = (MemorySegment)create_face_handle.invokeExact(get_table_data_fn); + face = (MemorySegment)create_face_handle.invokeExact(get_table_data_fn_stub); } catch (Throwable t) { } } diff --git a/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java b/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java index f1d6de7d4bc..99d3987e5fd 100644 --- a/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java +++ b/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2003, 2026, 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 @@ -36,126 +37,22 @@ import sun.java2d.DisposerRecord; import java.awt.geom.Point2D; import java.lang.foreign.MemorySegment; -import java.lang.ref.SoftReference; import java.util.concurrent.ConcurrentHashMap; import java.util.WeakHashMap; -/* - * different ways to do this - * 1) each physical font2d keeps a hashtable mapping scripts to layout - * engines, we query and fill this cache. - * 2) we keep a mapping independent of font using the key Most likely - * few fonts will be used, so option 2 seems better - * - * Once we know which engine to use for a font, we always know, so we - * shouldn't have to recheck each time we do layout. So the cache is - * ok. - * - * Should we reuse engines? We could instantiate an engine for each - * font/script pair. The engine would hold onto the table(s) from the - * font that it needs. If we have multiple threads using the same - * engine, we still need to keep the state separate, so the native - * engines would still need to be allocated for each call, since they - * keep their state in themselves. If they used the passed-in GVData - * arrays directly (with some checks for space) then since each GVData - * is different per thread, we could reuse the layout engines. This - * still requires a separate layout engine per font, because of the - * table state in the engine. If we pushed that out too and passed it - * in with the native call as well, we'd be ok if the layout engines - * keep all their process state on the stack, but I don't know if this - * is true. Then we'd basically just be down to an engine index which - * we pass into native and then invoke the engine code (now a - * procedure call, not an object invocation) based on a switch on the - * index. There would be only half a dozen engine objects then, not - * potentially half a dozen per font. But we'd have to stack-allocate - * some state that included the pointer to the required font tables. - * - * Seems for now that the way to do things is to come in with a - * selector and the font. The selector indicates which engine to use, - * the engine is stack allocated and initialized with the required - * font tables (the selector indicates which). Then layout is called, - * the contents are copied (or not), and the stack is destroyed on - * exit. So the association is between the font/script (layout engine - * desc) and one of a few permanent engine objects, which are - * handed the key when they need to process something. In the native - * case, the engine holds an index, and just passes it together with - * the key info down to native. Some default cases are the 'default - * layout' case that just runs the c2gmapper, this stays in java and - * just uses the mapper from the font/strike. Another default case - * might be the unicode arabic shaper, since this doesn't care about - * the font (or script or lang?) it wouldn't need to extract this - * data. It could be (yikes) ported back to java even to avoid - * upcalls to check if the font supports a particular unicode - * character. - * - * I'd expect that the majority of scripts use the default mapper for - * a particular font. Loading the hashtable with 40 or so keys 30+ of - * which all map to the same object is unfortunate. It might be worth - * instead having a per-font list of 'scripts with non-default - * engines', e.g. the factory has a hashtable mapping fonts to 'script - * lists' (the factory has this since the design potentially has other - * factories, though I admit there's no client for this yet and no - * public api) and then the script list is queried for the script in - * question. it can be preloaded at creation time with all the - * scripts that don't have default engines-- either a list or a hash - * table, so a null return from the table means 'default' and not 'i - * don't know yet'. - * - * On the other hand, in most all cases the number of unique - * script/font combinations will be small, so a flat hashtable should - * suffice. - * */ -public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory { +public final class SunLayoutEngine { + static { FontManagerNativeLibrary.load(); } - private LayoutEngineKey key; - - private static LayoutEngineFactory instance; - - public static LayoutEngineFactory instance() { - if (instance == null) { - instance = new SunLayoutEngine(); - } - return instance; - } - private SunLayoutEngine() { - // actually a factory, key is null so layout cannot be called on it - } - - public LayoutEngine getEngine(Font2D font, int script, int lang) { - return getEngine(new LayoutEngineKey(font, script, lang)); - } - - // !!! don't need this unless we have more than one sun layout engine... - public LayoutEngine getEngine(LayoutEngineKey key) { - ConcurrentHashMap cache = cacheref.get(); - if (cache == null) { - cache = new ConcurrentHashMap<>(); - cacheref = new SoftReference<>(cache); - } - - LayoutEngine e = cache.get(key); - if (e == null) { - LayoutEngineKey copy = key.copy(); - e = new SunLayoutEngine(copy); - cache.put(copy, e); - } - return e; - } - private SoftReference> cacheref = - new SoftReference<>(null); - - private SunLayoutEngine(LayoutEngineKey key) { - this.key = key; } private static final WeakHashMap facePtr = new WeakHashMap<>(); - private long getFacePtr(Font2D font2D) { + private static long getFacePtr(Font2D font2D) { FaceRef ref; synchronized (facePtr) { ref = facePtr.computeIfAbsent(font2D, FaceRef::new); @@ -170,17 +67,16 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory } - public void layout(FontStrikeDesc desc, float[] mat, float ptSize, int gmask, + public static void layout(Font2D font, int script, FontStrikeDesc desc, float[] mat, float ptSize, int gmask, int baseIndex, TextRecord tr, int typo_flags, Point2D.Float pt, GVData data) { - Font2D font = key.font(); FontStrike strike = font.getStrike(desc); if (useFFM) { MemorySegment face = HBShaper.getFace(font); if (face != null) { HBShaper.shape(font, strike, ptSize, mat, face, - tr.text, data, key.script(), + tr.text, data, script, tr.start, tr.limit, baseIndex, pt, typo_flags, gmask); } @@ -188,7 +84,7 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory long pFace = getFacePtr(font); if (pFace != 0) { shape(font, strike, ptSize, mat, pFace, - tr.text, data, key.script(), + tr.text, data, script, tr.start, tr.limit, baseIndex, pt, typo_flags, gmask); } diff --git a/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java b/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java index 9815d657eee..891a15f24de 100644 --- a/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java +++ b/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -250,11 +250,6 @@ public final class SunGraphics2D private FontInfo glyphVectorFontInfo; private FontRenderContext glyphVectorFRC; - private static final int slowTextTransformMask = - AffineTransform.TYPE_GENERAL_TRANSFORM - | AffineTransform.TYPE_MASK_ROTATION - | AffineTransform.TYPE_FLIP; - static { if (PerformanceLogger.loggingEnabled()) { PerformanceLogger.setTime("SunGraphics2D static initialization"); @@ -453,13 +448,13 @@ public final class SunGraphics2D * or whether that shape must be "kept" unmodified. */ Shape intersectShapes(Shape s1, Shape s2, boolean keep1, boolean keep2) { - if (s1 instanceof Rectangle && s2 instanceof Rectangle) { - return ((Rectangle) s1).intersection((Rectangle) s2); + if (s1 instanceof Rectangle r1 && s2 instanceof Rectangle r2) { + return r1.intersection(r2); } - if (s1 instanceof Rectangle2D) { - return intersectRectShape((Rectangle2D) s1, s2, keep1, keep2); - } else if (s2 instanceof Rectangle2D) { - return intersectRectShape((Rectangle2D) s2, s1, keep2, keep1); + if (s1 instanceof Rectangle2D r1) { + return intersectRectShape(r1, s2, keep1, keep2); + } else if (s2 instanceof Rectangle2D r2) { + return intersectRectShape(r2, s1, keep2, keep1); } return intersectByArea(s1, s2, keep1, keep2); } @@ -473,8 +468,7 @@ public final class SunGraphics2D */ Shape intersectRectShape(Rectangle2D r, Shape s, boolean keep1, boolean keep2) { - if (s instanceof Rectangle2D) { - Rectangle2D r2 = (Rectangle2D) s; + if (s instanceof Rectangle2D r2) { Rectangle2D outrect; if (!keep1) { outrect = r; @@ -596,12 +590,10 @@ public final class SunGraphics2D } float ptSize = font.getSize2D(); - int txFontType; AffineTransform devAt, textAt=null; if (font.isTransformed()) { textAt = font.getTransform(); textAt.scale(ptSize, ptSize); - txFontType = textAt.getType(); info.originX = (float)textAt.getTranslateX(); info.originY = (float)textAt.getTranslateY(); textAt.translate(-info.originX, -info.originY); @@ -621,7 +613,6 @@ public final class SunGraphics2D } info.pixelHeight = (int)(Math.abs(scaley)+0.5); } else { - txFontType = AffineTransform.TYPE_IDENTITY; info.originX = info.originY = 0; if (transformState >= TRANSFORM_TRANSLATESCALE) { transform.getMatrix(info.devTx = new double[4]); @@ -783,18 +774,6 @@ public final class SunGraphics2D return info; } - public static boolean isRotated(double [] mtx) { - if ((mtx[0] == mtx[3]) && - (mtx[1] == 0.0) && - (mtx[2] == 0.0) && - (mtx[0] > 0.0)) - { - return false; - } - - return true; - } - public void setFont(Font font) { /* replacing the reference equality test font != this.font with * !font.equals(this.font) did not yield any measurable difference @@ -944,8 +923,7 @@ public final class SunGraphics2D } int newCompState; CompositeType newCompType; - if (comp instanceof AlphaComposite) { - AlphaComposite alphacomp = (AlphaComposite) comp; + if (comp instanceof AlphaComposite alphacomp) { newCompType = CompositeType.forAlphaComposite(alphacomp); if (newCompType == CompositeType.SrcOverNoEa) { if (paintState == PAINT_OPAQUECOLOR || @@ -1000,8 +978,8 @@ public final class SunGraphics2D * @see TexturePaint */ public void setPaint(Paint paint) { - if (paint instanceof Color) { - setColor((Color) paint); + if (paint instanceof Color c) { + setColor(c); return; } if (paint == null || this.paint == paint) { @@ -1162,8 +1140,8 @@ public final class SunGraphics2D } int saveStrokeState = strokeState; stroke = s; - if (s instanceof BasicStroke) { - validateBasicStroke((BasicStroke) s); + if (s instanceof BasicStroke bs) { + validateBasicStroke(bs); } else { strokeState = STROKE_CUSTOM; } @@ -1193,11 +1171,10 @@ public final class SunGraphics2D throw new IllegalArgumentException (hintValue+" is not compatible with "+hintKey); } - if (hintKey instanceof SunHints.Key) { + if (hintKey instanceof SunHints.Key sunKey) { boolean stateChanged; boolean textStateChanged = false; boolean recognized = true; - SunHints.Key sunKey = (SunHints.Key) hintKey; int newHint; if (sunKey == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST) { newHint = ((Integer)hintValue).intValue(); @@ -1297,7 +1274,6 @@ public final class SunGraphics2D hints.put(hintKey, hintValue); } - /** * Returns the preferences for the rendering algorithms. * @param hintKey The category of hint to be set. The strings @@ -1310,10 +1286,10 @@ public final class SunGraphics2D if (hints != null) { return hints.get(hintKey); } - if (!(hintKey instanceof SunHints.Key)) { + if (!(hintKey instanceof SunHints.Key shk)) { return null; } - int keyindex = ((SunHints.Key)hintKey).getIndex(); + int keyindex = shk.getIndex(); switch (keyindex) { case SunHints.INTKEY_RENDERING: return SunHints.Value.get(SunHints.INTKEY_RENDERING, @@ -1822,8 +1798,8 @@ public final class SunGraphics2D public Rectangle getClipBounds(Rectangle r) { if (clipState != CLIP_DEVICE) { if (transformState <= TRANSFORM_INT_TRANSLATE) { - if (usrClip instanceof Rectangle) { - r.setBounds((Rectangle) usrClip); + if (usrClip instanceof Rectangle usrClipRect) { + r.setBounds(usrClipRect); } else { r.setFrame(usrClip.getBounds2D()); } @@ -1970,8 +1946,7 @@ public final class SunGraphics2D r.translate(tx, ty); return r; } - if (s instanceof Rectangle2D) { - Rectangle2D rect = (Rectangle2D) s; + if (s instanceof Rectangle2D rect) { return new Rectangle2D.Double(rect.getX() + tx, rect.getY() + ty, rect.getWidth(), @@ -1991,10 +1966,9 @@ public final class SunGraphics2D return null; } - if (clip instanceof Rectangle2D && + if (clip instanceof Rectangle2D rect && (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0) { - Rectangle2D rect = (Rectangle2D) clip; double[] matrix = new double[4]; matrix[0] = rect.getX(); matrix[1] = rect.getY(); @@ -2180,65 +2154,6 @@ public final class SunGraphics2D } } - /* - public void XcopyArea(int x, int y, int w, int h, int dx, int dy) { - Rectangle rect = new Rectangle(x, y, w, h); - rect = transformBounds(rect, transform); - Point2D point = new Point2D.Float(dx, dy); - Point2D root = new Point2D.Float(0, 0); - point = transform.transform(point, point); - root = transform.transform(root, root); - int fdx = (int)(point.getX()-root.getX()); - int fdy = (int)(point.getY()-root.getY()); - - Rectangle r = getCompBounds().intersection(rect.getBounds()); - - if (r.isEmpty()) { - return; - } - - // Begin Rasterizer for Clip Shape - boolean skipClip = true; - byte[] clipAlpha = null; - - if (clipState == CLIP_SHAPE) { - - int box[] = new int[4]; - - clipRegion.getBounds(box); - Rectangle devR = new Rectangle(box[0], box[1], - box[2] - box[0], - box[3] - box[1]); - if (!devR.isEmpty()) { - OutputManager mgr = getOutputManager(); - RegionIterator ri = clipRegion.getIterator(); - while (ri.nextYRange(box)) { - int spany = box[1]; - int spanh = box[3] - spany; - while (ri.nextXBand(box)) { - int spanx = box[0]; - int spanw = box[2] - spanx; - mgr.copyArea(this, null, - spanw, 0, - spanx, spany, - spanw, spanh, - fdx, fdy, - null); - } - } - } - return; - } - // End Rasterizer for Clip Shape - - getOutputManager().copyArea(this, null, - r.width, 0, - r.x, r.y, r.width, - r.height, fdx, fdy, - null); - } - */ - public void drawLine(int x1, int y1, int x2, int y2) { try { drawpipe.drawLine(this, x1, y1, x2, y2); @@ -2465,8 +2380,8 @@ public final class SunGraphics2D if (paintState <= PAINT_ALPHACOLOR) { validateColor(); } - if (composite instanceof XORComposite) { - Color c = ((XORComposite) composite).getXorColor(); + if (composite instanceof XORComposite xorComp) { + Color c = xorComp.getXorColor(); setComposite(new XORComposite(c, surfaceData)); } validatePipe(); @@ -2668,8 +2583,7 @@ public final class SunGraphics2D } // BufferedImage case: use a simple drawImage call - if (img instanceof BufferedImage) { - BufferedImage bufImg = (BufferedImage)img; + if (img instanceof BufferedImage bufImg) { drawImage(bufImg,xform,null); return; } @@ -2905,21 +2819,6 @@ public final class SunGraphics2D drawRenderedImage(rendering,reverseTransform); } - - - /* - * Transform the bounding box of the BufferedImage - */ - protected Rectangle transformBounds(Rectangle rect, - AffineTransform tx) { - if (tx.isIdentity()) { - return rect; - } - - Shape s = transformShape(tx, rect); - return s.getBounds(); - } - // text rendering methods public void drawString(String str, int x, int y) { if (str == null) { @@ -3130,13 +3029,12 @@ public final class SunGraphics2D invalidateTransform(); } return result; - } else if (img instanceof MultiResolutionImage) { + } else if (img instanceof MultiResolutionImage mrImage) { // get scaled destination image size int width = img.getWidth(observer); int height = img.getHeight(observer); - MultiResolutionImage mrImage = (MultiResolutionImage) img; Image resolutionVariant = getResolutionVariant(mrImage, width, height, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, @@ -3311,8 +3209,7 @@ public final class SunGraphics2D Image resolutionVariant = img.getResolutionVariant(destImageWidth, destImageHeight); - if (resolutionVariant instanceof ToolkitImage - && ((ToolkitImage) resolutionVariant).hasError()) { + if (resolutionVariant instanceof ToolkitImage tki && tki.hasError()) { return null; } diff --git a/src/java.desktop/share/classes/sun/java2d/loops/FontInfo.java b/src/java.desktop/share/classes/sun/java2d/loops/FontInfo.java index 09aa05b785e..10e10a4adde 100644 --- a/src/java.desktop/share/classes/sun/java2d/loops/FontInfo.java +++ b/src/java.desktop/share/classes/sun/java2d/loops/FontInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package sun.java2d.loops; import java.awt.Font; +import java.util.Arrays; import sun.font.Font2D; import sun.font.FontStrike; @@ -41,7 +42,7 @@ import sun.font.FontStrike; * time. I am reluctant to add the overhead of that machinery here without * a proven benefit. */ -public class FontInfo implements Cloneable { +public final class FontInfo implements Cloneable { public Font font; public Font2D font2D; public FontStrike fontStrike; @@ -56,15 +57,7 @@ public class FontInfo implements Cloneable { /* lcdSubPixPos is used if FM is ON for HRGB/HBGR LCD text mode */ public boolean lcdSubPixPos; - public String mtx(double[] matrix) { - return ("["+ - matrix[0]+", "+ - matrix[1]+", "+ - matrix[2]+", "+ - matrix[3]+ - "]"); - } - + @Override public Object clone() { try { return super.clone(); @@ -73,15 +66,16 @@ public class FontInfo implements Cloneable { } } + @Override public String toString() { return ("FontInfo["+ "font="+font+", "+ - "devTx="+mtx(devTx)+", "+ - "glyphTx="+mtx(glyphTx)+", "+ + "devTx="+Arrays.toString(devTx)+", "+ + "glyphTx="+Arrays.toString(glyphTx)+", "+ "pixelHeight="+pixelHeight+", "+ "origin=("+originX+","+originY+"), "+ "aaHint="+aaHint+", "+ - "lcdRGBOrder="+(lcdRGBOrder ? "RGB" : "BGR")+ + "lcdRGBOrder="+(lcdRGBOrder ? "RGB" : "BGR")+", "+ "lcdSubPixPos="+lcdSubPixPos+ "]"); } diff --git a/src/java.desktop/share/classes/sun/print/PrintJobDelegate.java b/src/java.desktop/share/classes/sun/print/PrintJobDelegate.java index 5a88d4b9d45..bca3301b5c9 100644 --- a/src/java.desktop/share/classes/sun/print/PrintJobDelegate.java +++ b/src/java.desktop/share/classes/sun/print/PrintJobDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -526,8 +526,10 @@ public class PrintJobDelegate implements Printable, Runnable { } PageRanges range = (PageRanges)attributes.get(PageRanges.class); - int[][] members = range.getMembers(); - jobAttributes.setPageRanges(members); + if (range != null) { + int[][] members = range.getMembers(); + jobAttributes.setPageRanges(members); + } SheetCollate collation = (SheetCollate)attributes.get(SheetCollate.class); diff --git a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 754af87b94e..32728efde6c 100644 --- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -1610,6 +1610,11 @@ public abstract class RasterPrinterJob extends PrinterJob { cancelDoc(); } + } catch (PrinterException pe) { + throw pe; + } catch (Throwable printError) { + throw (PrinterException) + new PrinterException().initCause(printError.getCause()); } finally { // reset previousPaper in case this job is invoked again. previousPaper = null; diff --git a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index 27ad163e599..565fd9608ab 100644 --- a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -44,6 +44,7 @@ import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Toolkit; +import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -92,7 +93,6 @@ import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.font.FontDesignMetrics; import sun.font.FontUtilities; @@ -121,9 +121,6 @@ import static java.awt.geom.AffineTransform.TYPE_TRANSLATION; */ public class SwingUtilities2 { - public static final Object MENU_SELECTION_MANAGER_LISTENER_KEY = - new StringBuffer("MenuSelectionManager listener key"); - // Maintain a cache of CACHE_SIZE fonts and the left side bearing // of the characters falling into the range MIN_CHAR_INDEX to // MAX_CHAR_INDEX. The values in fontCache are created as needed. @@ -799,7 +796,7 @@ public class SwingUtilities2 { */ public static void adjustFocus(JComponent c) { if (!c.hasFocus() && c.isRequestFocusEnabled()) { - c.requestFocus(); + c.requestFocus(FocusEvent.Cause.MOUSE_EVENT); } } @@ -1244,7 +1241,7 @@ public class SwingUtilities2 { return null; } - private static final Object APP_CONTEXT_FRC_CACHE_KEY = new Object(); + private static final Map cache = new HashMap<>(); private static FontRenderContext getFRCFromCache(AffineTransform tx, Object aaHint) { @@ -1252,15 +1249,6 @@ public class SwingUtilities2 { return null; } - @SuppressWarnings("unchecked") - Map cache = (Map) - AppContext.getAppContext().get(APP_CONTEXT_FRC_CACHE_KEY); - - if (cache == null) { - cache = new HashMap<>(); - AppContext.getAppContext().put(APP_CONTEXT_FRC_CACHE_KEY, cache); - } - Object key = (tx == null) ? aaHint : (aaHint == null ? tx : new KeyPair(tx, aaHint)); @@ -1447,15 +1435,6 @@ public class SwingUtilities2 { } } - /** - * checks if the system clipboard can be accessed. - * This is true in a headful environment, false in a headless one - * - */ - public static boolean canAccessSystemClipboard() { - return !GraphicsEnvironment.isHeadless(); - } - public static String displayPropertiesToCSS(Font font, Color fg) { StringBuilder rule = new StringBuilder("body {"); if (font != null) { @@ -1658,24 +1637,24 @@ public class SwingUtilities2 { if (container.isFocusCycleRoot()) { FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); Component comp = policy.getDefaultComponent(container); - if (comp!=null) { - comp.requestFocus(); + if (comp != null) { + comp.requestFocus(FocusEvent.Cause.TRAVERSAL); return comp; } } Container rootAncestor = container.getFocusCycleRootAncestor(); - if (rootAncestor!=null) { + if (rootAncestor != null) { FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy(); Component comp = policy.getComponentAfter(rootAncestor, container); - if (comp!=null && SwingUtilities.isDescendingFrom(comp, container)) { - comp.requestFocus(); + if (comp != null && SwingUtilities.isDescendingFrom(comp, container)) { + comp.requestFocus(FocusEvent.Cause.TRAVERSAL); return comp; } } } if (component.isFocusable()) { - component.requestFocus(); + component.requestFocus(FocusEvent.Cause.TRAVERSAL); return component; } return null; diff --git a/src/java.desktop/share/classes/sun/swing/plaf/DesktopProperty.java b/src/java.desktop/share/classes/sun/swing/plaf/DesktopProperty.java index 8af75f98b83..6b33f0786a8 100644 --- a/src/java.desktop/share/classes/sun/swing/plaf/DesktopProperty.java +++ b/src/java.desktop/share/classes/sun/swing/plaf/DesktopProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,8 +42,6 @@ import javax.swing.UIManager; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.FontUIResource; -import sun.awt.AppContext; - /** * Wrapper for a value from the desktop. The value is lazily looked up, and * can be accessed using the UIManager.ActiveValue method @@ -52,8 +50,6 @@ import sun.awt.AppContext; * invalidate to force the value to be fetched again. */ public class DesktopProperty implements UIDefaults.ActiveValue { - private static final StringBuilder DESKTOP_PROPERTY_UPDATE_PENDING_KEY = - new StringBuilder("DesktopPropertyUpdatePending"); /** * ReferenceQueue of unreferenced WeakPCLs. @@ -90,23 +86,6 @@ public class DesktopProperty implements UIDefaults.ActiveValue { } } - - /** - * Sets whether or not an updateUI call is pending. - */ - private static synchronized void setUpdatePending(boolean update) { - AppContext.getAppContext() - .put(DESKTOP_PROPERTY_UPDATE_PENDING_KEY, update); - } - - /** - * Returns true if a UI update is pending. - */ - private static synchronized boolean isUpdatePending() { - return Boolean.TRUE.equals(AppContext.getAppContext() - .get(DESKTOP_PROPERTY_UPDATE_PENDING_KEY)); - } - /** * Updates the UIs of all the known Frames. */ @@ -202,6 +181,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue { value = null; } + private static volatile boolean updatePending; + /** * Requests that all components in the GUI hierarchy be updated * to reflect dynamic changes in this {@literal look&feel}. This update occurs @@ -210,14 +191,14 @@ public class DesktopProperty implements UIDefaults.ActiveValue { * many desktop properties will change at once. */ protected void updateUI() { - if (!isUpdatePending()) { - setUpdatePending(true); + if (!updatePending) { + updatePending = true; Runnable uiUpdater = new Runnable() { public void run() { try { updateAllUIs(); } finally { - setUpdatePending(false); + updatePending = false; } } }; diff --git a/src/java.desktop/share/legal/freetype.md b/src/java.desktop/share/legal/freetype.md index 5df525e2f67..7259c27183f 100644 --- a/src/java.desktop/share/legal/freetype.md +++ b/src/java.desktop/share/legal/freetype.md @@ -1,4 +1,4 @@ -## The FreeType Project: Freetype v2.13.3 +## The FreeType Project: Freetype v2.14.2 ### FreeType Notice @@ -21,25 +21,24 @@ which fits your needs best. ### FreeType License ``` -Copyright (C) 1996-2024 by David Turner, Robert Wilhelm, and Werner Lemberg. -Copyright (C) 2007-2024 by Dereg Clegg and Michael Toftdal. -Copyright (C) 1996-2024 by Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. -Copyright (C) 2022-2024 by David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and -Copyright (C) 2004-2024 by Masatake YAMATO and Redhat K.K. -Copyright (C) 2007-2024 by Derek Clegg and Michael Toftdal. -Copyright (C) 2003-2024 by Masatake YAMATO, Red Hat K.K., -Copyright (C) 1996-2024 by David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches. -Copyright (C) 2007-2024 by David Turner. -Copyright (C) 2022-2024 by David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti. -Copyright (C) 2007-2024 by Rahul Bhalerao , . -Copyright (C) 2008-2024 by David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. -Copyright (C) 2013-2024 by Google, Inc. -Copyright (C) 2019-2024 by Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg. -Copyright (C) 2009-2024 by Oran Agra and Mickey Gabel. -Copyright (C) 2018-2024 by David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg. -Copyright (C) 2004-2024 by David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. - - +Copyright (C) 1996-2025 by David Turner, Robert Wilhelm, and Werner Lemberg. +Copyright (C) 2007-2025 by Dereg Clegg and Michael Toftdal. +Copyright (C) 1996-2025 by Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. +Copyright (C) 2022-2025 by David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and +Copyright (C) 2004-2025 by Masatake YAMATO and Redhat K.K. +Copyright (C) 2007-2025 by Derek Clegg and Michael Toftdal. +Copyright (C) 2003-2025 by Masatake YAMATO, Red Hat K.K., +Copyright (C) 1996-2025 by David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches. +Copyright (C) 2007-2025 by David Turner. +Copyright (C) 2022-2025 by David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti. +Copyright (C) 2007-2025 by Rahul Bhalerao , . +Copyright (C) 2025 by Behdad Esfahbod. +Copyright (C) 2008-2025 by David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. +Copyright (C) 2013-2025 by Google, Inc. +Copyright (C) 2019-2025 by Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg. +Copyright (C) 2009-2025 by Oran Agra and Mickey Gabel. +Copyright (C) 2018-2025 by David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg. +Copyright (C) 2004-2025 by David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. The FreeType Project LICENSE ---------------------------- @@ -207,6 +206,7 @@ Legal Terms https://www.freetype.org + ``` ### GPL v2 diff --git a/src/java.desktop/share/legal/giflib.md b/src/java.desktop/share/legal/giflib.md index 5697dc7ca9a..781023dd334 100644 --- a/src/java.desktop/share/legal/giflib.md +++ b/src/java.desktop/share/legal/giflib.md @@ -1,9 +1,9 @@ -## GIFLIB v5.2.2 +## GIFLIB v6.1.2 ### GIFLIB License ``` -The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond += MIT LICENSE Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,9 +25,15 @@ THE SOFTWARE. --------------------------------- The below applies to the following file(s): +giflib/dgif_lib.c +giflib/gifalloc.c +giflib/gif_err.c giflib/openbsd-reallocarray.c +Copyright (C) 1989 Gershon Elber Copyright (C) 2008 Otto Moerbeek +Copyright (C) Eric S. Raymond + SPDX-License-Identifier: MIT diff --git a/src/java.desktop/share/legal/libpng.md b/src/java.desktop/share/legal/libpng.md index 80d12248ec4..a2ffcca1974 100644 --- a/src/java.desktop/share/legal/libpng.md +++ b/src/java.desktop/share/legal/libpng.md @@ -1,4 +1,4 @@ -## libpng v1.6.54 +## libpng v1.6.55 ### libpng License

    @@ -170,6 +170,7 @@ Authors, for copyright and licensing purposes.
      * Guy Eric Schalnat
      * James Yu
      * John Bowler
    + * Joshua Inscoe
      * Kevin Bracey
      * Lucas Chollet
      * Magnus Holmgren
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
    index 0667493fec6..d66c5df9976 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h
    @@ -4,7 +4,7 @@
      *
      *   ANSI-specific configuration file (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
    index f6ef2618ded..16eab9048fc 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h
    @@ -4,7 +4,7 @@
      *
      *   Build macros of the FreeType 2 library.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
    index d29a0a7cefb..a0a1a410b68 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h
    @@ -4,7 +4,7 @@
      *
      *   User-selectable configuration macros (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -158,12 +158,12 @@ FT_BEGIN_HEADER
     
       /**************************************************************************
        *
    -   * If this macro is defined, try to use an inlined assembler version of the
    -   * @FT_MulFix function, which is a 'hotspot' when loading and hinting
    -   * glyphs, and which should be executed as fast as possible.
    +   * If this macro is defined, try to use an inlined 64-bit or assembler
    +   * version of the @FT_MulFix function, which is a 'hotspot' when loading
    +   * and hinting glyphs, and which should be executed as fast as possible.
        *
    -   * Note that if your compiler or CPU is not supported, this will default to
    -   * the standard and portable implementation found in `ftcalc.c`.
    +   * If your compiler is not C99-compliant or CPU assembly is not supported,
    +   * you can disable this option.
        */
     #define FT_CONFIG_OPTION_INLINE_MULFIX
     
    @@ -293,6 +293,31 @@ FT_BEGIN_HEADER
     /* #define FT_CONFIG_OPTION_USE_HARFBUZZ */
     
     
    +  /**************************************************************************
    +   *
    +   * HarfBuzz dynamic support.
    +   *
    +   *   Define this macro if you want the HarfBuzz library to be loaded at
    +   *   runtime instead of being linked to FreeType.
    +   *
    +   *   This option has no effect if `FT_CONFIG_OPTION_USE_HARFBUZZ` is not
    +   *   defined.
    +   *
    +   *   When this option is enabled, FreeType will try to load the HarfBuzz
    +   *   library at runtime, using `dlopen` or `LoadLibrary`, depending on the
    +   *   platform.  On Microsoft platforms, the library name looked up is
    +   *   `libharfbuzz-0.dll`.  On Apple platforms, the library name looked up
    +   *   is `libharfbuzz.0.dylib`.  On all other platforms, the library name
    +   *   looked up is `libharfbuzz.so.0`.  This name can be overridden by
    +   *   defining the macro `FT_LIBHARFBUZZ` at FreeType compilation time.
    +   *
    +   *   If you use a build system like cmake or the `configure` script,
    +   *   options set by those programs have precedence, overwriting the value
    +   *   here with the configured one.
    +   */
    +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */
    +
    +
       /**************************************************************************
        *
        * Brotli support.
    @@ -679,7 +704,7 @@ FT_BEGIN_HEADER
        * defined.
        *
        * [1]
    -   * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
    +   * https://learn.microsoft.com/typography/cleartype/truetypecleartype
        */
     #define TT_CONFIG_OPTION_SUBPIXEL_HINTING
     
    @@ -697,7 +722,7 @@ FT_BEGIN_HEADER
        * flags array which can be used to disambiguate, but old fonts will not
        * have them.
        *
    -   *   https://www.microsoft.com/typography/otspec/glyf.htm
    +   *   https://learn.microsoft.com/typography/opentype/spec/glyf
        *   https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
        */
     #undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
    @@ -734,7 +759,13 @@ FT_BEGIN_HEADER
       /**************************************************************************
        *
        * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an
    -   * embedded 'BDF~' table within SFNT-based bitmap formats.
    +   * embedded 'BDF~' table within an SFNT-based `.otb` font file.  This table
    +   * is an extension used by X11 to preserve BDF properties after conversion
    +   * to SFNT containers.  See
    +   *
    +   *   https://fontforge.org/docs/techref/non-standard.html#non-standard-bdf
    +   *
    +   * for more details.
        */
     /* #define TT_CONFIG_OPTION_BDF */
     
    @@ -760,10 +791,10 @@ FT_BEGIN_HEADER
       /**************************************************************************
        *
        * Option `TT_CONFIG_OPTION_GPOS_KERNING` enables a basic GPOS kerning
    -   * implementation (for TrueType fonts only).  With this defined, FreeType
    -   * is able to get kerning pair data from the GPOS 'kern' feature as well as
    -   * legacy 'kern' tables; without this defined, FreeType will only be able
    -   * to use legacy 'kern' tables.
    +   * implementation (for TrueType and OpenType fonts only).  With this
    +   * defined, FreeType is able to get kerning pair data from the GPOS 'kern'
    +   * feature as well as legacy 'kern' tables; without this defined, FreeType
    +   * will only be able to use legacy 'kern' tables.
        *
        * Note that FreeType does not support more advanced GPOS layout features;
        * even the 'kern' feature implemented here doesn't handle more
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
    index e17aa7b89d5..f846b4456c1 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h
    @@ -5,7 +5,7 @@
      *   ANSI-specific library and header configuration file (specification
      *   only).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
    index c27505ffc4b..a0b892ece4b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/integer-types.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType integer types definitions.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -17,6 +17,8 @@
     #ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
     #define FREETYPE_CONFIG_INTEGER_TYPES_H_
     
    +FT_BEGIN_HEADER
    +
       /* There are systems (like the Texas Instruments 'C54x) where a `char`  */
       /* has 16~bits.  ANSI~C says that `sizeof(char)` is always~1.  Since an */
       /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which  */
    @@ -242,9 +244,34 @@
     #endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
     
     #ifdef FT_INT64
    +
       typedef FT_INT64   FT_Int64;
       typedef FT_UINT64  FT_UInt64;
    -#endif
     
    +#  define FT_INT64_ZERO  0
    +
    +#else  /* !FT_INT64 */
    +
    +  /* we need to emulate 64-bit data types if none are available */
    +
    +  typedef struct  FT_Int64_
    +  {
    +    FT_UInt32  lo;
    +    FT_UInt32  hi;
    +
    +  } FT_Int64;
    +
    +  typedef struct  FT_UInt64_
    +  {
    +    FT_UInt32  lo;
    +    FT_UInt32  hi;
    +
    +  } FT_UInt64;
    +
    +#  define FT_INT64_ZERO  { 0, 0 }
    +
    +#endif /* !FT_INT64 */
    +
    +FT_END_HEADER
     
     #endif  /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
    index 07b6f915bd8..bd350851d56 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h
    @@ -4,7 +4,7 @@
      *
      *   Mac/OS X support configuration header.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -24,6 +24,7 @@
        *   This is the only necessary change, so it is defined here instead
        *   providing a new configuration file.
        */
    +#ifdef FT_MACINTOSH
     #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
       /* No Carbon frameworks for 64bit 10.4.x.                         */
       /* `AvailabilityMacros.h` is available since Mac OS X 10.2,       */
    @@ -36,6 +37,7 @@
         ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
     #undef FT_MACINTOSH
     #endif
    +#endif  /* __APPLE__ ... */
     
     #elif defined( __SC__ ) || defined( __MRC__ )
       /* Classic MacOS compilers */
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
    index f56581a6ee7..9f28b394737 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/public-macros.h
    @@ -4,7 +4,7 @@
      *
      *   Define a set of compiler macros used in public FreeType headers.
      *
    - * Copyright (C) 2020-2024 by
    + * Copyright (C) 2020-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -62,8 +62,8 @@ FT_BEGIN_HEADER
        * because it is needed by `FT_EXPORT`.
        */
     
    -  /* Visual C, mingw */
    -#if defined( _WIN32 )
    +  /* Visual C, MinGW, Cygwin */
    +#if defined( _WIN32 ) || defined( __CYGWIN__ )
     
     #if defined( FT2_BUILD_LIBRARY ) && defined( DLL_EXPORT )
     #define FT_PUBLIC_FUNCTION_ATTRIBUTE  __declspec( dllexport )
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
    index 58fc33dfe60..e8a1b1e2f3e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType high-level API and common types (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -811,7 +811,7 @@ FT_BEGIN_HEADER
        *   FT_ENCODING_MS_SYMBOL ::
        *     Microsoft Symbol encoding, used to encode mathematical symbols and
        *     wingdings.  For more information, see
    -   *     'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
    +   *     'https://learn.microsoft.com/typography/opentype/spec/recom#non-standard-symbol-fonts',
        *     'http://www.kostis.net/charsets/symbol.htm', and
        *     'http://www.kostis.net/charsets/wingding.htm'.
        *
    @@ -1068,12 +1068,12 @@ FT_BEGIN_HEADER
        *     the face in the font file (starting with value~0).  They are set
        *     to~0 if there is only one face in the font file.
        *
    -   *     [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
    -   *     fonts only, holding the named instance index for the current face
    -   *     index (starting with value~1; value~0 indicates font access without
    -   *     a named instance).  For non-variation fonts, bits 16-30 are ignored.
    -   *     If we have the third named instance of face~4, say, `face_index` is
    -   *     set to 0x00030004.
    +   *     [Since 2.6.1] Bits 16-30 are relevant to TrueType GX and OpenType
    +   *     Font Variations only, holding the named instance index for the
    +   *     current face index (starting with value~1; value~0 indicates font
    +   *     access without a named instance).  For non-variation fonts, bits
    +   *     16-30 are ignored.  If we have the third named instance of face~4,
    +   *     say, `face_index` is set to 0x00030004.
        *
        *     Bit 31 is always zero (that is, `face_index` is always a positive
        *     value).
    @@ -1092,10 +1092,10 @@ FT_BEGIN_HEADER
        *     the face; see @FT_STYLE_FLAG_XXX for the details.
        *
        *     [Since 2.6.1] Bits 16-30 hold the number of named instances
    -   *     available for the current face if we have a GX or OpenType variation
    -   *     (sub)font.  Bit 31 is always zero (that is, `style_flags` is always
    -   *     a positive value).  Note that a variation font has always at least
    -   *     one named instance, namely the default instance.
    +   *     available for the current face if we have a TrueType GX or OpenType
    +   *     Font Variation.  Bit 31 is always zero (that is, `style_flags` is
    +   *     always a positive value).  Note that a variation font has always at
    +   *     least one named instance, namely the default instance.
        *
        *   num_glyphs ::
        *     The number of glyphs in the face.  If the face is scalable and has
    @@ -1159,7 +1159,7 @@ FT_BEGIN_HEADER
        *     Note that the bounding box might be off by (at least) one pixel for
        *     hinted fonts.  See @FT_Size_Metrics for further discussion.
        *
    -   *     Note that the bounding box does not vary in OpenType variation fonts
    +   *     Note that the bounding box does not vary in OpenType Font Variations
        *     and should only be used in relation to the default instance.
        *
        *   units_per_EM ::
    @@ -1218,7 +1218,7 @@ FT_BEGIN_HEADER
        *   Fields may be changed after a call to @FT_Attach_File or
        *   @FT_Attach_Stream.
        *
    -   *   For an OpenType variation font, the values of the following fields can
    +   *   For OpenType Font Variations, the values of the following fields can
        *   change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
        *   the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
        *   `underline_position`, and `underline_thickness`.
    @@ -1336,7 +1336,7 @@ FT_BEGIN_HEADER
        *   FT_FACE_FLAG_MULTIPLE_MASTERS ::
        *     The face contains multiple masters and is capable of interpolating
        *     between them.  Supported formats are Adobe MM, TrueType GX, and
    -   *     OpenType variation fonts.
    +   *     OpenType Font Variations.
        *
        *     See section @multiple_masters for API details.
        *
    @@ -1609,7 +1609,7 @@ FT_BEGIN_HEADER
        *
        * @description:
        *   A macro that returns true whenever a face object is a named instance
    -   *   of a GX or OpenType variation font.
    +   *   of a TrueType GX or OpenType Font Variations.
        *
        *   [Since 2.9] Changing the design coordinates with
        *   @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
    @@ -2147,7 +2147,7 @@ FT_BEGIN_HEADER
        *     freed.
        *
        *     [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of
    -   *     OpenType variation fonts for a selected instance are internally
    +   *     OpenType Font Variations for a selected instance are internally
        *     handled as 26.6 fractional font units but returned as (rounded)
        *     integers, as expected.  To get unrounded font units, don't use
        *     @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and
    @@ -2640,14 +2640,14 @@ FT_BEGIN_HEADER
        *     the face in the font file (starting with value~0).  Set it to~0 if
        *     there is only one face in the font file.
        *
    -   *     [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
    -   *     fonts only, specifying the named instance index for the current face
    -   *     index (starting with value~1; value~0 makes FreeType ignore named
    -   *     instances).  For non-variation fonts, bits 16-30 are ignored.
    -   *     Assuming that you want to access the third named instance in face~4,
    -   *     `face_index` should be set to 0x00030004.  If you want to access
    -   *     face~4 without variation handling, simply set `face_index` to
    -   *     value~4.
    +   *     [Since 2.6.1] Bits 16-30 are relevant to TrueType GX and OpenType
    +   *     Font Variations only, specifying the named instance index for the
    +   *     current face index (starting with value~1; value~0 makes FreeType
    +   *     ignore named instances).  For non-variation fonts, bits 16-30 are
    +   *     ignored.  Assuming that you want to access the third named instance
    +   *     in face~4, `face_index` should be set to 0x00030004.  If you want
    +   *     to access face~4 without variation handling, simply set
    +   *     `face_index` to value~4.
        *
        *     `FT_Open_Face` and its siblings can be used to quickly check whether
        *     the font format of a given font resource is supported by FreeType.
    @@ -2914,11 +2914,11 @@ FT_BEGIN_HEADER
        *   of the available glyphs at a given ppem value is available.  FreeType
        *   silently uses outlines if there is no bitmap for a given glyph index.
        *
    -   *   For GX and OpenType variation fonts, a bitmap strike makes sense only
    -   *   if the default instance is active (that is, no glyph variation takes
    -   *   place); otherwise, FreeType simply ignores bitmap strikes.  The same
    -   *   is true for all named instances that are different from the default
    -   *   instance.
    +   *   For TrueType GX and OpenType Font Variations, a bitmap strike makes
    +   *   sense only if the default instance is active (that is, no glyph
    +   *   variation takes place); otherwise, FreeType simply ignores bitmap
    +   *   strikes.  The same is true for all named instances that are different
    +   *   from the default instance.
        *
        *   Don't use this function if you are using the FreeType cache API.
        */
    @@ -3078,7 +3078,7 @@ FT_BEGIN_HEADER
        *   is dependent entirely on how the size is defined in the source face.
        *   The font designer chooses the final size of each glyph relative to
        *   this size.  For more information refer to
    -   *   'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
    +   *   'https://freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
        *
        *   Contrary to @FT_Set_Char_Size, this function doesn't have special code
        *   to normalize zero-valued widths, heights, or resolutions, which are
    @@ -3441,8 +3441,10 @@ FT_BEGIN_HEADER
        *     blending of the color glyph layers associated with the glyph index,
        *     using the same bitmap format as embedded color bitmap images.  This
        *     is mainly for convenience and works only for glyphs in 'COLR' v0
    -   *     tables (or glyphs in 'COLR' v1 tables that exclusively use v0
    -   *     features).  For full control of color layers use
    +   *     tables.  **There is no rendering support for 'COLR' v1** (with the
    +   *     exception of v1 tables that exclusively use v0 features)!  You need
    +   *     a graphics library like Skia or Cairo to interpret the graphics
    +   *     commands stored in v1 tables.  For full control of color layers use
        *     @FT_Get_Color_Glyph_Layer and FreeType's color functions like
        *     @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
        *     so that the client application can handle blending by itself.
    @@ -3895,8 +3897,10 @@ FT_BEGIN_HEADER
        *
        *   This process can cost performance.  There is an approximation that
        *   does not need to know about the background color; see
    -   *   https://bel.fi/alankila/lcd/ and
    -   *   https://bel.fi/alankila/lcd/alpcor.html for details.
    +   *   https://web.archive.org/web/20211019204945/https://bel.fi/alankila/lcd/
    +   *   and
    +   *   https://web.archive.org/web/20210211002939/https://bel.fi/alankila/lcd/alpcor.html
    +   *   for details.
        *
        *   **ATTENTION**: Linear blending is even more important when dealing
        *   with subpixel-rendered glyphs to prevent color-fringing!  A
    @@ -3993,13 +3997,13 @@ FT_BEGIN_HEADER
        *   out of the scope of this API function -- they can be implemented
        *   through format-specific interfaces.
        *
    -   *   Note that, for TrueType fonts only, this can extract data from both
    -   *   the 'kern' table and the basic, pair-wise kerning feature from the
    -   *   GPOS table (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though
    -   *   FreeType does not support the more advanced GPOS layout features; use
    -   *   a library like HarfBuzz for those instead.  If a font has both a
    -   *   'kern' table and kern features of a GPOS table, the 'kern' table will
    -   *   be used.
    +   *   Note that, for TrueType and OpenType fonts only, this can extract data
    +   *   from both the 'kern' table and the basic, pair-wise kerning feature
    +   *   from the GPOS table (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled),
    +   *   though FreeType does not support the more advanced GPOS layout
    +   *   features; use a library like HarfBuzz for those instead.  If a font
    +   *   has both a 'kern' table and kern features of a GPOS table, the 'kern'
    +   *   table will be used.
        *
        *   Also note for right-to-left scripts, the functionality may differ for
        *   fonts with GPOS tables vs. 'kern' tables.  For GPOS, right-to-left
    @@ -4314,14 +4318,13 @@ FT_BEGIN_HEADER
        *     property `no-stem-darkening` provided by the 'autofit', 'cff',
        *     'type1', and 't1cid' modules; see @no-stem-darkening).
        *
    -   *   * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
    -   *     to function @FT_Library_SetLcdFilterWeights).
    -   *
        *   * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
        *     'random' operator, corresponding to the `random-seed` property
        *     provided by the 'cff', 'type1', and 't1cid' modules; see
        *     @random-seed).
        *
    +   *   * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (no longer supported).
    +   *
        *   Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the
        *   option and use the library or module default again.
        *
    @@ -4348,25 +4351,17 @@ FT_BEGIN_HEADER
        *     FT_Bool              darken_stems = 1;
        *
        *     FT_Parameter         property2;
    -   *     FT_LcdFiveTapFilter  custom_weight =
    -   *                            { 0x11, 0x44, 0x56, 0x44, 0x11 };
    -   *
    -   *     FT_Parameter         property3;
        *     FT_Int32             random_seed = 314159265;
        *
    -   *     FT_Parameter         properties[3] = { property1,
    -   *                                            property2,
    -   *                                            property3 };
    +   *     FT_Parameter         properties[2] = { property1,
    +   *                                            property2 };
        *
        *
        *     property1.tag  = FT_PARAM_TAG_STEM_DARKENING;
        *     property1.data = &darken_stems;
        *
    -   *     property2.tag  = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
    -   *     property2.data = custom_weight;
    -   *
    -   *     property3.tag  = FT_PARAM_TAG_RANDOM_SEED;
    -   *     property3.data = &random_seed;
    +   *     property2.tag  = FT_PARAM_TAG_RANDOM_SEED;
    +   *     property2.data = &random_seed;
        *
        *     FT_Face_Properties( face, 3, properties );
        *   ```
    @@ -4377,7 +4372,7 @@ FT_BEGIN_HEADER
        *     FT_Parameter  property;
        *
        *
    -   *     property.tag  = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
    +   *     property.tag  = FT_PARAM_TAG_STEM_DARKENING;
        *     property.data = NULL;
        *
        *     FT_Face_Properties( face, 1, &property );
    @@ -4530,7 +4525,7 @@ FT_BEGIN_HEADER
        *   table description in the OpenType specification for the meaning of the
        *   various flags (which get synthesized for non-OpenType subglyphs).
        *
    -   *     https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
    +   *     https://learn.microsoft.com/typography/opentype/spec/glyf#composite-glyph-description
        *
        * @values:
        *   FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
    @@ -4593,7 +4588,7 @@ FT_BEGIN_HEADER
        *   interpreted depending on the flags returned in `*p_flags`.  See the
        *   OpenType specification for details.
        *
    -   *     https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
    +   *     https://learn.microsoft.com/typography/opentype/spec/glyf#composite-glyph-description
        *
        */
       FT_EXPORT( FT_Error )
    @@ -4619,7 +4614,7 @@ FT_BEGIN_HEADER
        *   associated with a font.
        *
        *   See
    -   *   https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf
    +   *   https://adobe-type-tools.github.io/font-tech-notes/pdfs/AcrobatDC_FontPolicies.pdf
        *   for more details.
        *
        * @values:
    @@ -5173,8 +5168,8 @@ FT_BEGIN_HEADER
        *
        */
     #define FREETYPE_MAJOR  2
    -#define FREETYPE_MINOR  13
    -#define FREETYPE_PATCH  3
    +#define FREETYPE_MINOR  14
    +#define FREETYPE_PATCH  2
     
     
       /**************************************************************************
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
    index 85b8ba2554b..62a856ccbd7 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h
    @@ -4,7 +4,7 @@
      *
      *   Quick computation of advance widths (specification only).
      *
    - * Copyright (C) 2008-2024 by
    + * Copyright (C) 2008-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
    index 12bbfa63a62..348b4b3a268 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType exact bbox computation (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
    index 6f63b0b1e78..ab142249217 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for accessing BDF-specific strings (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -44,7 +44,8 @@ FT_BEGIN_HEADER
        *
        * @description:
        *   This section contains the declaration of functions specific to BDF and
    -   *   PCF fonts.
    +   *   PCF fonts.  They also work for SFNT bitmap fonts that contain a 'BDF~'
    +   *   table like X11's `.otb` fonts.
        *
        */
     
    @@ -151,7 +152,9 @@ FT_BEGIN_HEADER
        *   FreeType error code.  0~means success.
        *
        * @note:
    -   *   This function only works with BDF faces, returning an error otherwise.
    +   *   This function only works with BDF faces and SFNT fonts that have a
    +   *   'BDF~' table, returning an error otherwise.  For the latter, a bitmap
    +   *   strike size must be selected first.
        */
       FT_EXPORT( FT_Error )
       FT_Get_BDF_Charset_ID( FT_Face       face,
    @@ -165,7 +168,7 @@ FT_BEGIN_HEADER
        *    FT_Get_BDF_Property
        *
        * @description:
    -   *    Retrieve a BDF property from a BDF or PCF font file.
    +   *    Retrieve a BDF property from a BDF or PCF font.
        *
        * @input:
        *    face ::
    @@ -196,6 +199,9 @@ FT_BEGIN_HEADER
        *
        *   In case of error, `aproperty->type` is always set to
        *   @BDF_PROPERTY_TYPE_NONE.
    +   *
    +   *   This also works with SFNT fonts that have a 'BDF~' table, after a
    +   *   bitmap strike size has been selected.
        */
       FT_EXPORT( FT_Error )
       FT_Get_BDF_Property( FT_Face           face,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
    index df9d462652e..a22d43adf14 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility functions for bitmaps (specification).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
    index 96b2a90fc59..7cda8ff3f39 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for accessing CID font information (specification).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * Dereg Clegg and Michael Toftdal.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
    index 420720ddf22..129b1a23fb0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType's glyph color management (specification).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -317,6 +317,15 @@ FT_BEGIN_HEADER
        * @description:
        *   The functions described here allow access of colored glyph layer data
        *   in OpenType's 'COLR' tables.
    +   *
    +   *   Note that FreeType does *not* provide rendering in general of glyphs
    +   *   that use a 'COLR' table!  While FreeType has very limited rendering
    +   *   support for 'COLR' v0 tables (without a possibility to change the
    +   *   color palette) via @FT_Render_Glyph, there is no such convenience
    +   *   code for 'COLR' v1 tables -- while it appears that v1 is simply an
    +   *   'improved' version of v0, this is not the case: it is a completely
    +   *   different color font format, and you need a dedicated graphics
    +   *   library like Skia or Cairo to handle a v1 table's drawing commands.
        */
     
     
    @@ -359,7 +368,7 @@ FT_BEGIN_HEADER
        *   iteratively retrieve the colored glyph layers associated with the
        *   current glyph slot.
        *
    -   *     https://docs.microsoft.com/en-us/typography/opentype/spec/colr
    +   *     https://learn.microsoft.com/typography/opentype/spec/colr
        *
        *   The glyph layer data for a given glyph index, if present, provides an
        *   alternative, multi-color glyph representation: Instead of rendering
    @@ -1518,7 +1527,7 @@ FT_BEGIN_HEADER
        *
        * @return:
        *   Value~1 if a clip box is found.  If no clip box is found or an error
    -   *   occured, value~0 is returned.
    +   *   occurred, value~0 is returned.
        *
        * @note:
        *   To retrieve the clip box in font units, reset scale to units-per-em
    @@ -1646,7 +1655,7 @@ FT_BEGIN_HEADER
        *
        * @return:
        *   Value~1 if everything is OK.  Value~0 if no details can be found for
    -   *   this paint or any other error occured.
    +   *   this paint or any other error occurred.
        *
        * @since:
        *   2.13
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
    index 1b7f539f5e2..b65a06ab69b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for controlling driver modules (specification only).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -282,7 +282,7 @@ FT_BEGIN_HEADER
        *   minimize hinting techniques that were problematic with the extra
        *   resolution of ClearType; see
        *   http://rastertragedy.com/RTRCh4.htm#Sec1 and
    -   *   https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx.
    +   *   https://learn.microsoft.com/typography/cleartype/truetypecleartype.
        *   This technique is not to be confused with ClearType compatible widths.
        *   ClearType backward compatibility has no direct impact on changing
        *   advance widths, but there might be an indirect impact on disabling
    @@ -784,7 +784,7 @@ FT_BEGIN_HEADER
        *
        *   Details on subpixel hinting and some of the necessary tweaks can be
        *   found in Greg Hitchcock's whitepaper at
    -   *   'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
    +   *   'https://learn.microsoft.com/typography/cleartype/truetypecleartype'.
        *   Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2,
        *   or 6x5 supersampling) like discussed in the paper.  Depending on the
        *   chosen interpreter, it simply ignores instructions on vertical stems
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h b/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
    index 710ca91bbdd..3e591bede8d 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType error codes (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h b/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
    index 27c0ece5c1c..eca494f90c0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType error code handling (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
    index 7c8b0874a81..5df82447d0e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h
    @@ -4,7 +4,7 @@
      *
      *   Support functions for font formats.
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
    index 30e5a9bf82b..77e5a7e7bfd 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h
    @@ -4,7 +4,7 @@
      *
      *   Access of TrueType's 'gasp' table (specification).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
    index dc1eb8873ae..3691781cf52 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType convenience functions to handle glyphs (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
    index 9516dc030ac..e26c334c11a 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h
    @@ -4,7 +4,7 @@
      *
      *   Gzip-compressed stream support.
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
    index 2b4b4ac60ae..a4dc724f349 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h
    @@ -5,7 +5,7 @@
      *   FreeType glyph image formats and default raster interface
      *   (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -267,6 +267,10 @@ FT_BEGIN_HEADER
        *   *logical* one.  For example, if @FT_Pixel_Mode is set to
        *   `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the
        *   physical one.
    +   *
    +   *   An empty bitmap with a NULL `buffer` is valid, with `rows` and/or
    +   *   `pitch` also set to 0.  Such bitmaps might be produced while rendering
    +   *   empty or degenerate outlines.
        */
       typedef struct  FT_Bitmap_
       {
    @@ -439,7 +443,7 @@ FT_BEGIN_HEADER
        *   rasterizer; see the `tags` field in @FT_Outline.
        *
        *   Please refer to the description of the 'SCANTYPE' instruction in the
    -   *   [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype)
    +   *   [OpenType specification](https://learn.microsoft.com/typography/opentype/spec/tt_instructions#scantype)
        *   how simple drop-outs, smart drop-outs, and stubs are defined.
        */
     #define FT_OUTLINE_NONE             0x0
    @@ -871,7 +875,7 @@ FT_BEGIN_HEADER
        */
       typedef struct  FT_Span_
       {
    -    short           x;
    +    unsigned short  x;
         unsigned short  len;
         unsigned char   coverage;
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
    index 816581b78eb..2233044754e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType incremental loading (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
    index 25274dc4ac2..37bb5e1b8fb 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h
    @@ -5,7 +5,7 @@
      *   FreeType API for color filtering of subpixel bitmap glyphs
      *   (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -145,16 +145,10 @@ FT_BEGIN_HEADER
        *
        *   FT_LCD_FILTER_LEGACY ::
        *   FT_LCD_FILTER_LEGACY1 ::
    -   *     This filter corresponds to the original libXft color filter.  It
    -   *     provides high contrast output but can exhibit really bad color
    -   *     fringes if glyphs are not extremely well hinted to the pixel grid.
    -   *     This filter is only provided for comparison purposes, and might be
    -   *     disabled or stay unsupported in the future. The second value is
    -   *     provided for compatibility with FontConfig, which historically used
    -   *     different enumeration, sometimes incorrectly forwarded to FreeType.
    +   *     The legacy libXft color filter is no longer supported and ignored.
        *
        * @since:
    -   *   2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2)
    +   *   2.3.0
        */
       typedef enum  FT_LcdFilter_
       {
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
    index 972fbfa2fe4..14958b0ff37 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h
    @@ -4,7 +4,7 @@
      *
      *   Generic list support for FreeType (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
    index 1813cfc2c27..d155171136c 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlogging.h
    @@ -4,7 +4,7 @@
      *
      *   Additional debugging APIs.
      *
    - * Copyright (C) 2020-2024 by
    + * Copyright (C) 2020-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
    index e4efde33dd8..c5ac49101a4 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h
    @@ -4,7 +4,7 @@
      *
      *   Additional Mac-specific API.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
    index 35ed039c89b..ff0bbab59f9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h
    @@ -2,9 +2,9 @@
      *
      * ftmm.h
      *
    - *   FreeType Multiple Master font interface (specification).
    + *   FreeType variation font interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -37,24 +37,79 @@ FT_BEGIN_HEADER
        *   multiple_masters
        *
        * @title:
    -   *   Multiple Masters
    +   *   OpenType Font Variations, TrueType GX, and Adobe MM Fonts
        *
        * @abstract:
    -   *   How to manage Multiple Masters fonts.
    +   *   How to manage variable fonts with multiple design axes.
        *
        * @description:
    -   *   The following types and functions are used to manage Multiple Master
    -   *   fonts, i.e., the selection of specific design instances by setting
    -   *   design axis coordinates.
    +   *   The following types and functions manage OpenType Font Variations,
    +   *   Adobe Multiple Master (MM) fonts, and Apple TrueType GX fonts.  These
    +   *   formats have in common that they allow the selection of specific
    +   *   design instances by setting design coordinates for one or more axes
    +   *   like font weight or width.
        *
    -   *   Besides Adobe MM fonts, the interface supports Apple's TrueType GX and
    -   *   OpenType variation fonts.  Some of the routines only work with Adobe
    -   *   MM fonts, others will work with all three types.  They are similar
    -   *   enough that a consistent interface makes sense.
    +   *   For historical reasons there are two interfaces.  The first, older one
    +   *   can be used with Adobe MM fonts only, and the second, newer one is a
    +   *   unified interface that handles all three font formats.  However, some
    +   *   differences remain and are documented accordingly; in particular,
    +   *   Adobe MM fonts don't have named instances (see below).
        *
    -   *   For Adobe MM fonts, macro @FT_IS_SFNT returns false.  For GX and
    -   *   OpenType variation fonts, it returns true.
    +   *   For Adobe MM fonts, macro @FT_IS_SFNT returns false.  For TrueType GX
    +   *   and OpenType Font Variations, it returns true.
        *
    +   *   We use mostly the terminology of the OpenType standard.  Here are some
    +   *   important technical terms.
    +   *
    +   *   * A 'named instance' is a tuple of design coordinates that has a
    +   *     string ID (i.e., an index into the font's 'name' table) associated
    +   *     with it.  The font can tell the user that, for example,
    +   *     [Weight=700,Width=110] is 'Bold'.  Another name for 'named instance'
    +   *     is 'named style'.
    +   *
    +   *       Adobe MM fonts don't have named instances.
    +   *
    +   *   * The 'default instance' of a variation font is that instance for
    +   *     which the nth axis coordinate is equal to the nth default axis
    +   *     coordinate (i.e., `axis[n].def` as specified in the @FT_MM_Var
    +   *     structure), with~n covering all axes.  In TrueType GX and OpenType
    +   *     Font Variations, the default instance is explicitly given.  In Adobe
    +   *     MM fonts, the `WeightVector` entry as found in the font file is
    +   *     taken as the default instance.
    +   *
    +   *       For TrueType GX and OpenType Font Variations, FreeType synthesizes
    +   *       a named instance for the default instance if the font does not
    +   *       contain such an entry.
    +   *
    +   *   * 'Design coordinates' are the axis values found in a variation font
    +   *      file.  Their meaning is specified by the font designer and the
    +   *      values are rather arbitrary.
    +   *
    +   *       For example, the 'weight' axis in design coordinates might vary
    +   *       between 100 (thin) and 900 (heavy) in font~A, while font~B
    +   *       contains values between 400 (normal) and 800 (extra bold).
    +   *
    +   *   * 'Normalized coordinates' are design coordinates mapped to a standard
    +   *     range; they are also called 'blend coordinates'.
    +   *
    +   *       For TrueType GX and OpenType Font Variations, the range is [-1;1],
    +   *       with the minimum mapped to value~-1, the default mapped to
    +   *       value~0, and the maximum mapped to value~1, and all other
    +   *       coordinates mapped to intervening points.  Please look up the
    +   *       [OpenType
    +   *       specification](https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview)
    +   *       on how this mapping works in detail.
    +   *
    +   *       For Adobe MM fonts, this standard range is [0;1], with the minimum
    +   *       mapped to value~0 and the maximum mapped to value~1, and all other
    +   *       coordinates mapped to intervening points.  Please look up [Adobe
    +   *       TechNote
    +   *       #5015](https://adobe-type-tools.github.io/font-tech-notes/pdfs/5015.Type1_Supp.pdf)
    +   *       on how this mapping works in detail.
    +   *
    +   *       Assuming that the two fonts in the previous example are OpenType
    +   *       Font Variations, both font~A's [100;900] and font~B's [400;800]
    +   *       coordinate ranges get mapped to [-1;1].
        */
     
     
    @@ -64,14 +119,14 @@ FT_BEGIN_HEADER
        *   T1_MAX_MM_XXX
        *
        * @description:
    -   *   Multiple Masters limits as defined in their specifications.
    +   *   Adobe MM font limits as defined in their specifications.
        *
        * @values:
        *   T1_MAX_MM_AXIS ::
    -   *     The maximum number of Multiple Masters axes.
    +   *     The maximum number of Adobe MM font axes.
        *
        *   T1_MAX_MM_DESIGNS ::
    -   *     The maximum number of Multiple Masters designs.
    +   *     The maximum number of Adobe MM font designs.
        *
        *   T1_MAX_MM_MAP_POINTS ::
        *     The maximum number of elements in a design map.
    @@ -88,11 +143,10 @@ FT_BEGIN_HEADER
        *   FT_MM_Axis
        *
        * @description:
    -   *   A structure to model a given axis in design space for Multiple Masters
    -   *   fonts.
    +   *   A structure to model a given axis in design space for Adobe MM fonts.
        *
    -   *   This structure can't be used for TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This structure can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @fields:
        *   name ::
    @@ -119,17 +173,17 @@ FT_BEGIN_HEADER
        *   FT_Multi_Master
        *
        * @description:
    -   *   A structure to model the axes and space of a Multiple Masters font.
    +   *   A structure to model the axes and space of an Adobe MM font.
        *
    -   *   This structure can't be used for TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This structure can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @fields:
        *   num_axis ::
        *     Number of axes.  Cannot exceed~4.
        *
        *   num_designs ::
    -   *     Number of designs; should be normally 2^num_axis even though the
    +   *     Number of designs; should be normally `2^num_axis` even though the
        *     Type~1 specification strangely allows for intermediate designs to be
        *     present.  This number cannot exceed~16.
        *
    @@ -151,13 +205,13 @@ FT_BEGIN_HEADER
        *   FT_Var_Axis
        *
        * @description:
    -   *   A structure to model a given axis in design space for Multiple
    -   *   Masters, TrueType GX, and OpenType variation fonts.
    +   *   A structure to model a given axis in design space for Adobe MM fonts,
    +   *   TrueType GX, and OpenType Font Variations.
        *
        * @fields:
        *   name ::
        *     The axis's name.  Not always meaningful for TrueType GX or OpenType
    -   *     variation fonts.
    +   *     Font Variations.
        *
        *   minimum ::
        *     The axis's minimum design coordinate.
    @@ -171,17 +225,17 @@ FT_BEGIN_HEADER
        *
        *   tag ::
        *     The axis's tag (the equivalent to 'name' for TrueType GX and
    -   *     OpenType variation fonts).  FreeType provides default values for
    +   *     OpenType Font Variations).  FreeType provides default values for
        *     Adobe MM fonts if possible.
        *
        *   strid ::
        *     The axis name entry in the font's 'name' table.  This is another
        *     (and often better) version of the 'name' field for TrueType GX or
    -   *     OpenType variation fonts.  Not meaningful for Adobe MM fonts.
    +   *     OpenType Font Variations.  Not meaningful for Adobe MM fonts.
        *
        * @note:
        *   The fields `minimum`, `def`, and `maximum` are 16.16 fractional values
    -   *   for TrueType GX and OpenType variation fonts.  For Adobe MM fonts, the
    +   *   for TrueType GX and OpenType Font Variations.  For Adobe MM fonts, the
        *   values are whole numbers (i.e., the fractional part is zero).
        */
       typedef struct  FT_Var_Axis_
    @@ -205,7 +259,7 @@ FT_BEGIN_HEADER
        *
        * @description:
        *   A structure to model a named instance in a TrueType GX or OpenType
    -   *   variation font.
    +   *   Font Variations.
        *
        *   This structure can't be used for Adobe MM fonts.
        *
    @@ -215,11 +269,11 @@ FT_BEGIN_HEADER
        *     entry for each axis.
        *
        *   strid ::
    -   *     The entry in 'name' table identifying this instance.
    +   *     An index into the 'name' table identifying this instance.
        *
        *   psid ::
    -   *     The entry in 'name' table identifying a PostScript name for this
    -   *     instance.  Value 0xFFFF indicates a missing entry.
    +   *     An index into the 'name' table identifying a PostScript name for
    +   *     this instance.  Value 0xFFFF indicates a missing entry.
        */
       typedef struct  FT_Var_Named_Style_
       {
    @@ -236,39 +290,33 @@ FT_BEGIN_HEADER
        *   FT_MM_Var
        *
        * @description:
    -   *   A structure to model the axes and space of an Adobe MM, TrueType GX,
    -   *   or OpenType variation font.
    +   *   A structure to model the axes and space of Adobe MM fonts, TrueType
    +   *   GX, or OpenType Font Variations.
        *
        *   Some fields are specific to one format and not to the others.
        *
        * @fields:
        *   num_axis ::
        *     The number of axes.  The maximum value is~4 for Adobe MM fonts; no
    -   *     limit in TrueType GX or OpenType variation fonts.
    +   *     limit in TrueType GX or OpenType Font Variations.
        *
        *   num_designs ::
    -   *     The number of designs; should be normally 2^num_axis for Adobe MM
    -   *     fonts.  Not meaningful for TrueType GX or OpenType variation fonts
    +   *     The number of designs; should be normally `2^num_axis` for Adobe MM
    +   *     fonts.  Not meaningful for TrueType GX or OpenType Font Variations
        *     (where every glyph could have a different number of designs).
        *
        *   num_namedstyles ::
    -   *     The number of named styles; a 'named style' is a tuple of design
    -   *     coordinates that has a string ID (in the 'name' table) associated
    -   *     with it.  The font can tell the user that, for example,
    -   *     [Weight=1.5,Width=1.1] is 'Bold'.  Another name for 'named style' is
    -   *     'named instance'.
    -   *
    -   *     For Adobe Multiple Masters fonts, this value is always zero because
    -   *     the format does not support named styles.
    +   *     The number of named instances.  For Adobe MM fonts, this value is
    +   *     always zero.
        *
        *   axis ::
    -   *     An axis descriptor table.  TrueType GX and OpenType variation fonts
    +   *     An axis descriptor table.  TrueType GX and OpenType Font Variations
        *     contain slightly more data than Adobe MM fonts.  Memory management
        *     of this pointer is done internally by FreeType.
        *
        *   namedstyle ::
    -   *     A named style (instance) table.  Only meaningful for TrueType GX and
    -   *     OpenType variation fonts.  Memory management of this pointer is done
    +   *     An array of named instances.  Only meaningful for TrueType GX and
    +   *     OpenType Font Variations.  Memory management of this pointer is done
        *     internally by FreeType.
        */
       typedef struct  FT_MM_Var_
    @@ -290,8 +338,8 @@ FT_BEGIN_HEADER
        * @description:
        *   Retrieve a variation descriptor of a given Adobe MM font.
        *
    -   *   This function can't be used with TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This function can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @input:
        *   face ::
    @@ -299,7 +347,7 @@ FT_BEGIN_HEADER
        *
        * @output:
        *   amaster ::
    -   *     The Multiple Masters descriptor.
    +   *     The Adobe MM font's variation descriptor.
        *
        * @return:
        *   FreeType error code.  0~means success.
    @@ -366,8 +414,8 @@ FT_BEGIN_HEADER
        *   For Adobe MM fonts, choose an interpolated font design through design
        *   coordinates.
        *
    -   *   This function can't be used with TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This function can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @inout:
        *   face ::
    @@ -391,8 +439,8 @@ FT_BEGIN_HEADER
        *
        *   [Since 2.9] If `num_coords` is larger than zero, this function sets
        *   the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
    -   *   (i.e., @FT_IS_VARIATION will return true).  If `num_coords` is zero,
    -   *   this bit flag gets unset.
    +   *   (i.e., @FT_IS_VARIATION returns true).  If `num_coords` is zero, this
    +   *   bit flag gets unset.
        */
       FT_EXPORT( FT_Error )
       FT_Set_MM_Design_Coordinates( FT_Face   face,
    @@ -428,7 +476,7 @@ FT_BEGIN_HEADER
        *
        * @note:
        *   The design coordinates are 16.16 fractional values for TrueType GX and
    -   *   OpenType variation fonts.  For Adobe MM fonts, the values are supposed
    +   *   OpenType Font Variations.  For Adobe MM fonts, the values are supposed
        *   to be whole numbers (i.e., the fractional part is zero).
        *
        *   [Since 2.8.1] To reset all axes to the default values, call the
    @@ -438,8 +486,14 @@ FT_BEGIN_HEADER
        *
        *   [Since 2.9] If `num_coords` is larger than zero, this function sets
        *   the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
    -   *   (i.e., @FT_IS_VARIATION will return true).  If `num_coords` is zero,
    -   *   this bit flag gets unset.
    +   *   (i.e., @FT_IS_VARIATION returns true).  If `num_coords` is zero, this
    +   *   bit flag gets unset.
    +   *
    +   *   [Since 2.14] This function also sets the @FT_FACE_FLAG_VARIATION bit
    +   *   in @FT_Face's `face_flags` field (i.e., @FT_IS_VARIATION returns
    +   *   true) if any of the provided coordinates is different from the face's
    +   *   default value for the corresponding axis, that is, the set up face is
    +   *   not at its default position.
        */
       FT_EXPORT( FT_Error )
       FT_Set_Var_Design_Coordinates( FT_Face    face,
    @@ -468,14 +522,14 @@ FT_BEGIN_HEADER
        *
        * @output:
        *   coords ::
    -   *     The design coordinates array.
    +   *     The design coordinates array, which must be allocated by the user.
        *
        * @return:
        *   FreeType error code.  0~means success.
        *
        * @note:
        *   The design coordinates are 16.16 fractional values for TrueType GX and
    -   *   OpenType variation fonts.  For Adobe MM fonts, the values are whole
    +   *   OpenType Font Variations.  For Adobe MM fonts, the values are whole
        *   numbers (i.e., the fractional part is zero).
        *
        * @since:
    @@ -493,8 +547,7 @@ FT_BEGIN_HEADER
        *   FT_Set_MM_Blend_Coordinates
        *
        * @description:
    -   *   Choose an interpolated font design through normalized blend
    -   *   coordinates.
    +   *   Choose an interpolated font design through normalized coordinates.
        *
        *   This function works with all supported variation formats.
        *
    @@ -509,9 +562,10 @@ FT_BEGIN_HEADER
        *     the number of axes, use default values for the remaining axes.
        *
        *   coords ::
    -   *     The design coordinates array.  Each element is a 16.16 fractional
    -   *     value and must be between 0 and 1.0 for Adobe MM fonts, and between
    -   *     -1.0 and 1.0 for TrueType GX and OpenType variation fonts.
    +   *     The normalized coordinates array.  Each element is a 16.16
    +   *     fractional value and must be between 0 and 1.0 for Adobe MM fonts,
    +   *     and between -1.0 and 1.0 for TrueType GX and OpenType Font
    +   *     Variations.
        *
        * @return:
        *   FreeType error code.  0~means success.
    @@ -524,8 +578,14 @@ FT_BEGIN_HEADER
        *
        *   [Since 2.9] If `num_coords` is larger than zero, this function sets
        *   the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
    -   *   (i.e., @FT_IS_VARIATION will return true).  If `num_coords` is zero,
    -   *   this bit flag gets unset.
    +   *   (i.e., @FT_IS_VARIATION returns true).  If `num_coords` is zero, this
    +   *   bit flag gets unset.
    +   *
    +   *   [Since 2.14] This function also sets the @FT_FACE_FLAG_VARIATION bit
    +   *   in @FT_Face's `face_flags` field (i.e., @FT_IS_VARIATION returns
    +   *   true) if any of the provided coordinates is different from the face's
    +   *   default value for the corresponding axis, that is, the set up face is
    +   *   not at its default position.
        */
       FT_EXPORT( FT_Error )
       FT_Set_MM_Blend_Coordinates( FT_Face    face,
    @@ -539,8 +599,8 @@ FT_BEGIN_HEADER
        *   FT_Get_MM_Blend_Coordinates
        *
        * @description:
    -   *   Get the normalized blend coordinates of the currently selected
    -   *   interpolated font.
    +   *   Get the normalized coordinates of the currently selected interpolated
    +   *   font.
        *
        *   This function works with all supported variation formats.
        *
    @@ -549,14 +609,14 @@ FT_BEGIN_HEADER
        *     A handle to the source face.
        *
        *   num_coords ::
    -   *     The number of normalized blend coordinates to retrieve.  If it is
    -   *     larger than the number of axes, set the excess values to~0.5 for
    -   *     Adobe MM fonts, and to~0 for TrueType GX and OpenType variation
    -   *     fonts.
    +   *     The number of normalized coordinates to retrieve.  If it is larger
    +   *     than the number of axes, set the excess values to~0.5 for Adobe MM
    +   *     fonts, and to~0 for TrueType GX and OpenType Font Variations.
        *
        * @output:
        *   coords ::
    -   *     The normalized blend coordinates array (as 16.16 fractional values).
    +   *     The normalized coordinates array (as 16.16 fractional values), which
    +   *     must be allocated by the user.
        *
        * @return:
        *   FreeType error code.  0~means success.
    @@ -610,8 +670,8 @@ FT_BEGIN_HEADER
        *   For Adobe MM fonts, choose an interpolated font design by directly
        *   setting the weight vector.
        *
    -   *   This function can't be used with TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This function can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @inout:
        *   face ::
    @@ -630,16 +690,16 @@ FT_BEGIN_HEADER
        *   FreeType error code.  0~means success.
        *
        * @note:
    -   *   Adobe Multiple Master fonts limit the number of designs, and thus the
    -   *   length of the weight vector to 16~elements.
    +   *   Adobe MM fonts limit the number of designs, and thus the length of the
    +   *   weight vector, to 16~elements.
        *
        *   If `len` is larger than zero, this function sets the
        *   @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field (i.e.,
    -   *   @FT_IS_VARIATION will return true).  If `len` is zero, this bit flag
    -   *   is unset and the weight vector array is reset to the default values.
    +   *   @FT_IS_VARIATION returns true).  If `len` is zero, this bit flag is
    +   *   unset and the weight vector array is reset to the default values.
        *
        *   The Adobe documentation also states that the values in the
    -   *   WeightVector array must total 1.0 +/-~0.001.  In practice this does
    +   *   `WeightVector` array must total 1.0 +/-~0.001.  In practice this does
        *   not seem to be enforced, so is not enforced here, either.
        *
        * @since:
    @@ -659,8 +719,8 @@ FT_BEGIN_HEADER
        * @description:
        *   For Adobe MM fonts, retrieve the current weight vector of the font.
        *
    -   *   This function can't be used with TrueType GX or OpenType variation
    -   *   fonts.
    +   *   This function can't be used with TrueType GX or OpenType Font
    +   *   Variations.
        *
        * @inout:
        *   face ::
    @@ -677,14 +737,14 @@ FT_BEGIN_HEADER
        *
        * @output:
        *   weightvector ::
    -   *     An array to be filled.
    +   *     An array to be filled; it must be allocated by the user.
        *
        * @return:
        *   FreeType error code.  0~means success.
        *
        * @note:
    -   *   Adobe Multiple Master fonts limit the number of designs, and thus the
    -   *   length of the WeightVector to~16.
    +   *   Adobe MM fonts limit the number of designs, and thus the length of the
    +   *   weight vector, to~16 elements.
        *
        * @since:
        *   2.10
    @@ -760,8 +820,8 @@ FT_BEGIN_HEADER
        *     A handle to the source face.
        *
        *   instance_index ::
    -   *     The index of the requested instance, starting with value 1.  If set
    -   *     to value 0, FreeType switches to font access without a named
    +   *     The index of the requested instance, starting with value~1.  If set
    +   *     to value~0, FreeType switches to font access without a named
        *     instance.
        *
        * @return:
    @@ -771,11 +831,11 @@ FT_BEGIN_HEADER
        *   The function uses the value of `instance_index` to set bits 16-30 of
        *   the face's `face_index` field.  It also resets any variation applied
        *   to the font, and the @FT_FACE_FLAG_VARIATION bit of the face's
    -   *   `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION will
    -   *   return false).
    +   *   `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION returns
    +   *   false).
        *
    -   *   For Adobe MM fonts (which don't have named instances) this function
    -   *   simply resets the current face to the default instance.
    +   *   For Adobe MM fonts, this function resets the current face to the
    +   *   default instance.
        *
        * @since:
        *   2.9
    @@ -794,10 +854,6 @@ FT_BEGIN_HEADER
        *   Retrieve the index of the default named instance, to be used with
        *   @FT_Set_Named_Instance.
        *
    -   *   The default instance of a variation font is that instance for which
    -   *   the nth axis coordinate is equal to `axis[n].def` (as specified in the
    -   *   @FT_MM_Var structure), with~n covering all axes.
    -   *
        *   FreeType synthesizes a named instance for the default instance if the
        *   font does not contain such an entry.
        *
    @@ -813,8 +869,8 @@ FT_BEGIN_HEADER
        *   FreeType error code.  0~means success.
        *
        * @note:
    -   *   For Adobe MM fonts (which don't have named instances) this function
    -   *   always returns zero for `instance_index`.
    +   *   For Adobe MM fonts, this function always returns zero for
    +   *   `instance_index`.
        *
        * @since:
        *   2.13.1
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
    index 0ee715898f7..2669e4a03b3 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType modules public interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
    index 6722fbf8b70..8e2ef2f01f8 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType module error offsets (specification).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
    index 44e94b4f5bb..2545ca8486b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
    @@ -5,7 +5,7 @@
      *   Support for the FT_Outline type used to store glyph shapes of
      *   most scalable font formats (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
    index 43bf69c202f..94dcd6399a6 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for possible FT_Parameter tags (specification only).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -133,11 +133,8 @@ FT_BEGIN_HEADER
        *   FT_PARAM_TAG_LCD_FILTER_WEIGHTS
        *
        * @description:
    -   *   An @FT_Parameter tag to be used with @FT_Face_Properties.  The
    -   *   corresponding argument specifies the five LCD filter weights for a
    -   *   given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the
    -   *   global default values or the values set up with
    -   *   @FT_Library_SetLcdFilterWeights.
    +   *   Overriding global LCD filter weights with custom values for a given
    +   *   face is no longer supported and ignored.
        *
        * @since:
        *   2.8
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
    index dc5018a1b54..cc3102073b1 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType renderer modules public interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
    index 4ef5c7955df..fdb89f24ccc 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType size objects management (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
    index d5d5cd93103..99728574db6 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h
    @@ -7,7 +7,7 @@
      *
      *   This is _not_ used to retrieve glyph names!
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
    index 41626dc9d7b..2c4761c768d 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType path stroker (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
    index 43081b6c330..93499a4b4f1 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h
    @@ -5,7 +5,7 @@
      *   FreeType synthesizing code for emboldening and slanting
      *   (specification).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
    index 1eacb3af398..1de9f8e603d 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType low-level system interface definition (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h b/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
    index a5299e938d4..ed7bd06a78f 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType trigonometric functions (specification).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
    index 27815143a64..e207c5ebe09 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType simple types definitions (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
    index 8865d53b389..987e704e9b0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h
    @@ -4,7 +4,7 @@
      *
      *   High-level 'autohint' module-specific interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
    index 36b0390a5a5..26ee43bb9a9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h
    @@ -4,7 +4,7 @@
      *
      *   Basic OpenType/CFF object type definitions (specification).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
    index ef2e8e7569c..754122fa646 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h
    @@ -5,7 +5,7 @@
      *   Basic OpenType/CFF type definitions and interface (specification
      *   only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -191,8 +191,8 @@ FT_BEGIN_HEADER
         FT_UInt    weight;
         FT_Bool    is_fixed_pitch;
         FT_Fixed   italic_angle;
    -    FT_Fixed   underline_position;
    -    FT_Fixed   underline_thickness;
    +    FT_Short   underline_position;
    +    FT_UShort  underline_thickness;
         FT_Int     paint_type;
         FT_Int     charstring_type;
         FT_Matrix  font_matrix;
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
    index 876f66e2561..e6d0166d888 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/compiler-macros.h
    @@ -4,7 +4,7 @@
      *
      *   Compiler-specific macro definitions used internally by FreeType.
      *
    - * Copyright (C) 2020-2024 by
    + * Copyright (C) 2020-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -128,8 +128,8 @@ FT_BEGIN_HEADER
        * before a function declaration.
        */
     
    -  /* Visual C, mingw */
    -#if defined( _WIN32 )
    +  /* Visual C, MinGW, Cygwin */
    +#if defined( _WIN32 ) || defined( __CYGWIN__ )
     #define FT_INTERNAL_FUNCTION_ATTRIBUTE  /* empty */
     
       /* gcc, clang */
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
    index 71128a2df90..16a732224ef 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h
    @@ -4,7 +4,7 @@
      *
      *   Arithmetic computations (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -27,17 +27,87 @@
     FT_BEGIN_HEADER
     
     
    +  /*
    +   * The following macros have two purposes.
    +   *
    +   * - Tag places where overflow is expected and harmless.
    +   *
    +   * - Avoid run-time undefined behavior sanitizer errors.
    +   *
    +   * Use with care!
    +   */
    +#define ADD_INT( a, b )                           \
    +          (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) )
    +#define SUB_INT( a, b )                           \
    +          (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
    +#define MUL_INT( a, b )                           \
    +          (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
    +#define NEG_INT( a )                              \
    +          (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) )
    +
    +#define ADD_LONG( a, b )                             \
    +          (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
    +#define SUB_LONG( a, b )                             \
    +          (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) )
    +#define MUL_LONG( a, b )                             \
    +          (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
    +#define NEG_LONG( a )                                \
    +          (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) )
    +
    +#define ADD_INT32( a, b )                               \
    +          (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
    +#define SUB_INT32( a, b )                               \
    +          (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) )
    +#define MUL_INT32( a, b )                               \
    +          (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
    +#define NEG_INT32( a )                                  \
    +          (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) )
    +
    +#ifdef FT_INT64
    +
    +#define ADD_INT64( a, b )                               \
    +          (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) )
    +#define SUB_INT64( a, b )                               \
    +          (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) )
    +#define MUL_INT64( a, b )                               \
    +          (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) )
    +#define NEG_INT64( a )                                  \
    +          (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) )
    +
    +#endif /* FT_INT64 */
    +
    +
       /**************************************************************************
        *
        * FT_MulDiv() and FT_MulFix() are declared in freetype.h.
        *
        */
     
    -#ifndef  FT_CONFIG_OPTION_NO_ASSEMBLER
    -  /* Provide assembler fragments for performance-critical functions. */
    -  /* These must be defined `static __inline__' with GCC.             */
    +#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
     
    -#if defined( __CC_ARM ) || defined( __ARMCC__ )  /* RVCT */
    +#ifdef FT_INT64
    +
    +  static inline FT_Long
    +  FT_MulFix_64( FT_Long  a,
    +                FT_Long  b )
    +  {
    +    FT_Int64  ab = MUL_INT64( a, b );
    +
    +
    +    ab = ADD_INT64( ab, 0x8000 + ( ab >> 63 ) );  /* rounding phase */
    +
    +    return (FT_Long)( ab >> 16 );
    +  }
    +
    +
    +#define FT_MulFix( a, b )  FT_MulFix_64( a, b )
    +
    +#elif !defined( FT_CONFIG_OPTION_NO_ASSEMBLER )
    +  /* Provide 32-bit assembler fragments for optimized FT_MulFix. */
    +  /* These must be defined `static __inline__' or similar.       */
    +
    +#if defined( __arm__ )                                 && \
    +    ( defined( __thumb2__ ) || !defined( __thumb__ ) )
     
     #define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
     
    @@ -49,6 +119,7 @@ FT_BEGIN_HEADER
       {
         FT_Int32  t, t2;
     
    +#if defined( __CC_ARM ) || defined( __ARMCC__ )  /* RVCT */
     
         __asm
         {
    @@ -60,28 +131,8 @@ FT_BEGIN_HEADER
           mov   a,  t2, lsr #16         /* a   = t2 >> 16 */
           orr   a,  a,  t,  lsl #16     /* a  |= t << 16 */
         }
    -    return a;
    -  }
    -
    -#endif /* __CC_ARM || __ARMCC__ */
    -
    -
    -#ifdef __GNUC__
    -
    -#if defined( __arm__ )                                 && \
    -    ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
    -    !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
    -
    -#define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
    -
    -  /* documentation is in freetype.h */
    -
    -  static __inline__ FT_Int32
    -  FT_MulFix_arm( FT_Int32  a,
    -                 FT_Int32  b )
    -  {
    -    FT_Int32  t, t2;
     
    +#elif defined( __GNUC__ )
     
         __asm__ __volatile__ (
           "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
    @@ -98,26 +149,25 @@ FT_BEGIN_HEADER
           : "=r"(a), "=&r"(t2), "=&r"(t)
           : "r"(a), "r"(b)
           : "cc" );
    +
    +#endif
    +
         return a;
       }
     
    -#endif /* __arm__                      && */
    -       /* ( __thumb2__ || !__thumb__ ) && */
    -       /* !( __CC_ARM || __ARMCC__ )      */
    -
    -
    -#if defined( __i386__ )
    +#elif defined( __i386__ ) || defined( _M_IX86 )
     
     #define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
     
       /* documentation is in freetype.h */
     
    -  static __inline__ FT_Int32
    +  static __inline FT_Int32
       FT_MulFix_i386( FT_Int32  a,
                       FT_Int32  b )
       {
         FT_Int32  result;
     
    +#if defined( __GNUC__ )
     
         __asm__ __volatile__ (
           "imul  %%edx\n"
    @@ -132,27 +182,8 @@ FT_BEGIN_HEADER
           : "=a"(result), "=d"(b)
           : "a"(a), "d"(b)
           : "%ecx", "cc" );
    -    return result;
    -  }
     
    -#endif /* i386 */
    -
    -#endif /* __GNUC__ */
    -
    -
    -#ifdef _MSC_VER /* Visual C++ */
    -
    -#ifdef _M_IX86
    -
    -#define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
    -
    -  /* documentation is in freetype.h */
    -
    -  static __inline FT_Int32
    -  FT_MulFix_i386( FT_Int32  a,
    -                  FT_Int32  b )
    -  {
    -    FT_Int32  result;
    +#elif defined( _MSC_VER )
     
         __asm
         {
    @@ -169,81 +200,21 @@ FT_BEGIN_HEADER
           add eax, edx
           mov result, eax
         }
    +
    +#endif
    +
         return result;
       }
     
    -#endif /* _M_IX86 */
    +#endif /* __i386__ || _M_IX86 */
     
    -#endif /* _MSC_VER */
    -
    -
    -#if defined( __GNUC__ ) && defined( __x86_64__ )
    -
    -#define FT_MULFIX_ASSEMBLER  FT_MulFix_x86_64
    -
    -  static __inline__ FT_Int32
    -  FT_MulFix_x86_64( FT_Int32  a,
    -                    FT_Int32  b )
    -  {
    -    /* Temporarily disable the warning that C90 doesn't support */
    -    /* `long long'.                                             */
    -#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
    -#pragma GCC diagnostic push
    -#pragma GCC diagnostic ignored "-Wlong-long"
    -#endif
    -
    -#if 1
    -    /* Technically not an assembly fragment, but GCC does a really good */
    -    /* job at inlining it and generating good machine code for it.      */
    -    long long  ret, tmp;
    -
    -
    -    ret  = (long long)a * b;
    -    tmp  = ret >> 63;
    -    ret += 0x8000 + tmp;
    -
    -    return (FT_Int32)( ret >> 16 );
    -#else
    -
    -    /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine  */
    -    /* code from the lines below.  The main issue is that `wide_a' is not  */
    -    /* properly initialized by sign-extending `a'.  Instead, the generated */
    -    /* machine code assumes that the register that contains `a' on input   */
    -    /* can be used directly as a 64-bit value, which is wrong most of the  */
    -    /* time.                                                               */
    -    long long  wide_a = (long long)a;
    -    long long  wide_b = (long long)b;
    -    long long  result;
    -
    -
    -    __asm__ __volatile__ (
    -      "imul %2, %1\n"
    -      "mov %1, %0\n"
    -      "sar $63, %0\n"
    -      "lea 0x8000(%1, %0), %0\n"
    -      "sar $16, %0\n"
    -      : "=&r"(result), "=&r"(wide_a)
    -      : "r"(wide_b)
    -      : "cc" );
    -
    -    return (FT_Int32)result;
    -#endif
    -
    -#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
    -#pragma GCC diagnostic pop
    -#endif
    -  }
    -
    -#endif /* __GNUC__ && __x86_64__ */
    -
    -#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
    -
    -
    -#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
     #ifdef FT_MULFIX_ASSEMBLER
     #define FT_MulFix( a, b )  FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) )
     #endif
    -#endif
    +
    +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
    +
    +#endif /* FT_CONFIG_OPTION_INLINE_MULFIX */
     
     
       /**************************************************************************
    @@ -278,40 +249,6 @@ FT_BEGIN_HEADER
                           FT_Long  c );
     
     
    -  /**************************************************************************
    -   *
    -   * @function:
    -   *   FT_MulAddFix
    -   *
    -   * @description:
    -   *   Compute `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`, where `s[n]` is
    -   *   usually a 16.16 scalar.
    -   *
    -   * @input:
    -   *   s ::
    -   *     The array of scalars.
    -   *   f ::
    -   *     The array of factors.
    -   *   count ::
    -   *     The number of entries in the array.
    -   *
    -   * @return:
    -   *   The result of `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`.
    -   *
    -   * @note:
    -   *   This function is currently used for the scaled delta computation of
    -   *   variation stores.  It internally uses 64-bit data types when
    -   *   available, otherwise it emulates 64-bit math by using 32-bit
    -   *   operations, which produce a correct result but most likely at a slower
    -   *   performance in comparison to the implementation base on `int64_t`.
    -   *
    -   */
    -  FT_BASE( FT_Int32 )
    -  FT_MulAddFix( FT_Fixed*  s,
    -                FT_Int32*  f,
    -                FT_UInt    count );
    -
    -
       /*
        * A variant of FT_Matrix_Multiply which scales its result afterwards.  The
        * idea is that both `a' and `b' are scaled by factors of 10 so that the
    @@ -455,6 +392,10 @@ FT_BEGIN_HEADER
     
     #define FT_MSB( x )  FT_MSB_i386( x )
     
    +#elif defined( __CC_ARM )
    +
    +#define FT_MSB( x )  ( 31 - __clz( x ) )
    +
     #elif defined( __SunOS_5_11 )
     
     #include 
    @@ -526,55 +467,6 @@ FT_BEGIN_HEADER
     
     #define ROUND_F26DOT6( x )     ( ( (x) + 32 - ( x < 0 ) ) & -64 )
     
    -  /*
    -   * The following macros have two purposes.
    -   *
    -   * - Tag places where overflow is expected and harmless.
    -   *
    -   * - Avoid run-time sanitizer errors.
    -   *
    -   * Use with care!
    -   */
    -#define ADD_INT( a, b )                           \
    -          (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) )
    -#define SUB_INT( a, b )                           \
    -          (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
    -#define MUL_INT( a, b )                           \
    -          (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
    -#define NEG_INT( a )                              \
    -          (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) )
    -
    -#define ADD_LONG( a, b )                             \
    -          (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
    -#define SUB_LONG( a, b )                             \
    -          (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) )
    -#define MUL_LONG( a, b )                             \
    -          (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
    -#define NEG_LONG( a )                                \
    -          (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) )
    -
    -#define ADD_INT32( a, b )                               \
    -          (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
    -#define SUB_INT32( a, b )                               \
    -          (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) )
    -#define MUL_INT32( a, b )                               \
    -          (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
    -#define NEG_INT32( a )                                  \
    -          (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) )
    -
    -#ifdef FT_INT64
    -
    -#define ADD_INT64( a, b )                               \
    -          (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) )
    -#define SUB_INT64( a, b )                               \
    -          (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) )
    -#define MUL_INT64( a, b )                               \
    -          (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) )
    -#define NEG_INT64( a )                                  \
    -          (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) )
    -
    -#endif /* FT_INT64 */
    -
     
     FT_END_HEADER
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
    index d7fa8dc93cf..d7facf40d12 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h
    @@ -4,7 +4,7 @@
      *
      *   Debugging and logging component (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
    index 5609b3ef12b..24be4dad36b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType internal font driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
    index f1c155b162c..8f2a54c015b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph loader (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h
    index 622ec76bb9a..642d21e21c6 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h
    @@ -117,6 +117,18 @@ FT_BEGIN_HEADER
                           FT_Hash    hash,
                           FT_Memory  memory );
     
    +  FT_Error
    +  ft_hash_str_insert_no_overwrite( const char*  key,
    +                                   size_t       data,
    +                                   FT_Hash      hash,
    +                                   FT_Memory    memory );
    +
    +  FT_Error
    +  ft_hash_num_insert_no_overwrite( FT_Int     num,
    +                                   size_t     data,
    +                                   FT_Hash    hash,
    +                                   FT_Memory  memory );
    +
       size_t*
       ft_hash_str_lookup( const char*  key,
                           FT_Hash      hash );
    @@ -125,6 +137,17 @@ FT_BEGIN_HEADER
       ft_hash_num_lookup( FT_Int   num,
                           FT_Hash  hash );
     
    +  FT_Bool
    +  ft_hash_num_iterator( FT_UInt  *idx,
    +                        FT_Int   *key,
    +                        size_t   *value,
    +                        FT_Hash   hash );
    +
    +  FT_Bool
    +  ft_hash_str_iterator( FT_UInt      *idx,
    +                        const char*  *key,
    +                        size_t       *value,
    +                        FT_Hash       hash );
     
     FT_END_HEADER
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
    index 4e05a29f13a..c75c33f2895 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType memory management macros (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
    index 8449e7a010d..be3747bbf94 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmmtypes.h
    @@ -5,7 +5,7 @@
      *   OpenType Variations type definitions for internal use
      *   with the multi-masters service (specification).
      *
    - * Copyright (C) 2022-2024 by
    + * Copyright (C) 2022-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
      * Dominik Röttsches.
      *
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
    index a1e93298fdb..d4d7bc00fe9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType private base classes (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -275,6 +275,28 @@ FT_BEGIN_HEADER
                       FT_GlyphSlot    slot,
                       FT_Render_Mode  mode );
     
    +
    +  /**************************************************************************
    +   *
    +   * @Function:
    +   *   find_unicode_charmap
    +   *
    +   * @Description:
    +   *   This function finds a Unicode charmap, if there is one.  And if there
    +   *   is more than one, it tries to favour the more extensive one, i.e., one
    +   *   that supports UCS-4 against those which are limited to the BMP (UCS-2
    +   *   encoding.)
    +   *
    +   *   If a unicode charmap is found, `face->charmap` is set to it.
    +   *
    +   *   This function is called from `open_face`, from `FT_Select_Charmap(...,
    +   *   FT_ENCODING_UNICODE)`, and also from `afadjust.c` in the 'autofit'
    +   *   module.
    +   */
    +  FT_BASE( FT_Error )
    +  find_unicode_charmap( FT_Face  face );
    +
    +
     #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
     
       typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
    @@ -343,11 +365,6 @@ FT_BEGIN_HEADER
        *     Value~0 means to use the font's value.  Value~-1 means to use the
        *     CFF driver's default.
        *
    -   *   lcd_weights ::
    -   *   lcd_filter_func ::
    -   *     These fields specify the LCD filtering weights and callback function
    -   *     for ClearType-style subpixel rendering.
    -   *
        *   refcount ::
        *     A counter initialized to~1 at the time an @FT_Face structure is
        *     created.  @FT_Reference_Face increments this counter, and
    @@ -369,11 +386,6 @@ FT_BEGIN_HEADER
         FT_Char              no_stem_darkening;
         FT_Int32             random_seed;
     
    -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    -    FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
    -    FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
    -#endif
    -
         FT_Int  refcount;
     
       } FT_Face_InternalRec;
    @@ -498,9 +510,9 @@ FT_BEGIN_HEADER
        */
       typedef struct  FT_ModuleRec_
       {
    -    FT_Module_Class*  clazz;
    -    FT_Library        library;
    -    FT_Memory         memory;
    +    const FT_Module_Class*  clazz;
    +    FT_Library              library;
    +    FT_Memory               memory;
     
       } FT_ModuleRec;
     
    @@ -702,9 +714,9 @@ FT_BEGIN_HEADER
                                   const FT_Vector*  origin );
     
       /* Allocate a new bitmap buffer in a glyph slot. */
    +  /* Dimensions must be preset in advance.         */
       FT_BASE( FT_Error )
    -  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
    -                             FT_ULong      size );
    +  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot );
     
     
       /* Set the bitmap buffer in a glyph slot to a given pointer.  The buffer */
    @@ -867,10 +879,6 @@ FT_BEGIN_HEADER
        *   lcd_weights ::
        *     The LCD filter weights for ClearType-style subpixel rendering.
        *
    -   *   lcd_filter_func ::
    -   *     The LCD filtering callback function for for ClearType-style subpixel
    -   *     rendering.
    -   *
        *   lcd_geometry ::
        *     This array specifies LCD subpixel geometry and controls Harmony LCD
        *     rendering technique, alternative to ClearType.
    @@ -904,7 +912,6 @@ FT_BEGIN_HEADER
     
     #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
         FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
    -    FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
     #else
         FT_Vector                lcd_geometry[3];  /* RGB subpixel positions */
     #endif
    @@ -973,17 +980,6 @@ FT_BEGIN_HEADER
     #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
     
     
    -  /* Define default raster's interface.  The default raster is located in  */
    -  /* `src/base/ftraster.c'.                                                */
    -  /*                                                                       */
    -  /* Client applications can register new rasters through the              */
    -  /* FT_Set_Raster() API.                                                  */
    -
    -#ifndef FT_NO_DEFAULT_RASTER
    -  FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
    -#endif
    -
    -
       /**************************************************************************
        *
        * @macro:
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
    index 4f11aa16ba1..18a954d22f5 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h
    @@ -4,7 +4,7 @@
      *
      *   Get and set properties of PostScript drivers (specification).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
    index 05c1d6c48b5..e077f98bfb9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h
    @@ -4,7 +4,7 @@
      *
      *   Embedded resource forks accessor (specification).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * Masatake YAMATO and Redhat K.K.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
    index 8c35dbd7139..ce11bba19b2 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType services (specification only).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
    index fd52f767ef7..20c1dd7c4b0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h
    @@ -4,7 +4,7 @@
      *
      *   Stream handling (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
    index 42595a29ff3..3fd592800e2 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h
    @@ -4,7 +4,7 @@
      *
      *   Tracing handling (specification only).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -19,7 +19,7 @@
       /* definitions of trace levels for FreeType 2 */
     
       /* the maximum string length (if the argument to `FT_TRACE_DEF` */
    -  /* gets used as a string) plus one charachter for ':' plus      */
    +  /* gets used as a string) plus one character for ':' plus       */
       /* another one for the trace level                              */
     #define FT_MAX_TRACE_LEVEL_LENGTH  (9 + 1 + 1)
     
    @@ -159,6 +159,7 @@ FT_TRACE_DEF( gxvprop )
     FT_TRACE_DEF( gxvtrak )
     
       /* autofit components */
    +FT_TRACE_DEF( afadjust )
     FT_TRACE_DEF( afcjk )
     FT_TRACE_DEF( afglobal )
     FT_TRACE_DEF( afhints )
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
    index a1312f2aba6..03a726c82cb 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType validation support (specification).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
    index 745d2cb56b7..344be0f19a7 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h
    @@ -5,7 +5,7 @@
      *   Auxiliary functions and data structures related to PostScript fonts
      *   (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
    index dba6c7303fd..96c5d84f058 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h
    @@ -6,7 +6,7 @@
      *   recorders (specification only).  These are used to support native
      *   T1/T2 hints in the 'type1', 'cid', and 'cff' font drivers.
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
    index 89e9c2e5de8..5bd51da23f4 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType BDF services (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
    index 3cb483c344f..c97bf84fb2e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType CFF tables loader service (specification).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
    index 8362cb8724d..748a8caf887 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType CID font services (specification).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * Derek Clegg and Michael Toftdal.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
    index 6b837e79fcd..690fdc2a24f 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType font format service (specification only).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
    index 6126ec9ada4..7128d6f3d7a 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph dictionary services (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
    index 29cf5528189..1ca3e0a031b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for validating TrueTypeGX/AAT tables (specification).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * Masatake YAMATO, Red Hat K.K.,
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
    index ac1bc30c412..8a3d59bec6d 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType Kerning service (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
    index 8b3563b25ca..4dde3a8151a 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType services for metrics variations (specification).
      *
    - * Copyright (C) 2016-2024 by
    + * Copyright (C) 2016-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -77,7 +77,7 @@ FT_BEGIN_HEADER
       typedef void
       (*FT_Metrics_Adjust_Func)( FT_Face  face );
     
    -  typedef FT_Error
    +  typedef void
       (*FT_Size_Reset_Func)( FT_Size  size );
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
    index 5288fadf375..9be133e2db0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType Multiple Masters and GX var services (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
    index 7aea7ec11f0..933e5de98da 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType OpenType validation service (specification).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
    index b2fac6d086b..c81b6a68a8b 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h
    @@ -4,7 +4,7 @@
      *
      *   Internal PFR service functions (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
    index d19f3adc6d5..33864ebc344 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType PostScript name services (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
    index ba39c0dd4da..0eb79c885d8 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType property service (specification).
      *
    - * Copyright (C) 2012-2024 by
    + * Copyright (C) 2012-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
    index d4908ee41aa..8f85d12157c 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType PostScript charmap service (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
    index 2aadcdd02a1..83de04478df 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType PostScript info service (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
    index 9e0f4ff202e..9bf5e3473c4 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType SFNT table loading service (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
    index 250886bcc5d..fc9b0aeb8e3 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType TrueType/sfnt cmap extra information service.
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * Masatake YAMATO, Redhat K.K.,
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
    index 14967529a9a..979e9ea102e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType TrueType engine query service (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
    index f190b3985d0..e4f54c10037 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType TrueType glyph service.
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * David Turner.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
    index 49f3fb7f775..ff887ffdc03 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType Windows FNT/FONT service (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
    index 35e4e73af02..adba2178877 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h
    @@ -4,7 +4,7 @@
      *
      *   High-level 'sfnt' driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -612,7 +612,7 @@ FT_BEGIN_HEADER
        *
        * @return:
        *   Value~1 if a ClipBox is found.  If no clip box is found or an
    -   *   error occured, value~0 is returned.
    +   *   error occurred, value~0 is returned.
        */
       typedef FT_Bool
       ( *TT_Get_Color_Glyph_ClipBox_Func )( TT_Face      face,
    @@ -707,7 +707,7 @@ FT_BEGIN_HEADER
        *
        * @return:
        *   Value~1 if everything is OK.  Value~0 if no details can be found for
    -   *   this paint or any other error occured.
    +   *   this paint or any other error occurred.
        */
       typedef FT_Bool
       ( *TT_Get_Paint_Func )( TT_Face         face,
    @@ -808,7 +808,7 @@ FT_BEGIN_HEADER
        *     corresponding (1,0) Apple entry.
        *
        * @return:
    -   *   1 if there is either a win or apple entry (or both), 0 otheriwse.
    +   *   1 if there is either a win or apple entry (or both), 0 otherwise.
        */
       typedef FT_Bool
       (*TT_Get_Name_ID_Func)( TT_Face    face,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
    index 68c99efb10a..20c73b2fbd2 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/svginterface.h
    @@ -4,7 +4,7 @@
      *
      *   Interface of ot-svg module (specification only).
      *
    - * Copyright (C) 2022-2024 by
    + * Copyright (C) 2022-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
    index 1821ae5cc83..5b26e4620d0 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h
    @@ -5,7 +5,7 @@
      *   Basic Type1/Type2 type definitions and interface (specification
      *   only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
    index 7053e656a7e..d0e5eee89bc 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h
    @@ -5,7 +5,7 @@
      *   Basic SFNT/TrueType type definitions and interface (specification
      *   only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -930,8 +930,8 @@ FT_BEGIN_HEADER
        *   resolution and scaling independent parts of a TrueType font resource.
        *
        * @note:
    -   *   The TT_Face structure is also used as a 'parent class' for the
    -   *   OpenType-CFF class (T2_Face).
    +   *   The TT_Face structure is also used for CFF support; see file
    +   *   `cffotypes.h`.
        */
       typedef struct TT_FaceRec_*  TT_Face;
     
    @@ -1276,10 +1276,6 @@ FT_BEGIN_HEADER
        *
        *     If varied by the `CVAR' table, non-integer values are possible.
        *
    -   *   interpreter ::
    -   *     A pointer to the TrueType bytecode interpreters field is also used
    -   *     to hook the debugger in 'ttdebug'.
    -   *
        *   extra ::
        *     Reserved for third-party font drivers.
        *
    @@ -1521,10 +1517,6 @@ FT_BEGIN_HEADER
         FT_ULong              cvt_size;
         FT_Int32*             cvt;
     
    -    /* A pointer to the bytecode interpreter to use.  This is also */
    -    /* used to hook the debugger for the `ttdebug' utility.        */
    -    TT_Interpreter        interpreter;
    -
     
         /************************************************************************
          *
    @@ -1582,11 +1574,6 @@ FT_BEGIN_HEADER
         FT_UInt32             kern_avail_bits;
         FT_UInt32             kern_order_bits;
     
    -#ifdef TT_CONFIG_OPTION_GPOS_KERNING
    -    FT_Byte*              gpos_table;
    -    FT_Bool               gpos_kerning_available;
    -#endif
    -
     #ifdef TT_CONFIG_OPTION_BDF
         TT_BDFRec             bdf;
     #endif /* TT_CONFIG_OPTION_BDF */
    @@ -1608,6 +1595,15 @@ FT_BEGIN_HEADER
         /* since 2.12 */
         void*                 svg;
     
    +#ifdef TT_CONFIG_OPTION_GPOS_KERNING
    +    /* since 2.13.3 */
    +    FT_Byte*              gpos_table;
    +    /* since 2.14 */
    +    /* This is actually an array of GPOS lookup subtables. */
    +    FT_UInt32*            gpos_lookups_kerning;
    +    FT_UInt               num_gpos_lookups_kerning;
    +#endif
    +
       } TT_FaceRec;
     
     
    @@ -1621,15 +1617,6 @@ FT_BEGIN_HEADER
        *   coordinates.
        *
        * @fields:
    -   *   memory ::
    -   *     A handle to the memory manager.
    -   *
    -   *   max_points ::
    -   *     The maximum size in points of the zone.
    -   *
    -   *   max_contours ::
    -   *     Max size in links contours of the zone.
    -   *
        *   n_points ::
        *     The current number of points in the zone.
        *
    @@ -1653,9 +1640,6 @@ FT_BEGIN_HEADER
        */
       typedef struct  TT_GlyphZoneRec_
       {
    -    FT_Memory   memory;
    -    FT_UShort   max_points;
    -    FT_UShort   max_contours;
         FT_UShort   n_points;    /* number of points in zone    */
         FT_UShort   n_contours;  /* number of contours          */
     
    @@ -1714,7 +1698,6 @@ FT_BEGIN_HEADER
         TT_GlyphZoneRec  zone;
     
         TT_ExecContext   exec;
    -    FT_Byte*         instructions;
         FT_ULong         ins_pos;
     
         /* for possible extensibility in other formats */
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
    index 4a169d12f57..7d5b7df0fa1 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/wofftypes.h
    @@ -5,7 +5,7 @@
      *   Basic WOFF/WOFF2 type definitions and interface (specification
      *   only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h b/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
    index 9d356938cc7..326bbcd0153 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/otsvg.h
    @@ -4,7 +4,7 @@
      *
      *   Interface for OT-SVG support related things (specification).
      *
    - * Copyright (C) 2022-2024 by
    + * Copyright (C) 2022-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
    index fbd558aa34d..fe769f607fa 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h
    @@ -5,7 +5,7 @@
      *   Basic Type 1/Type 2 tables definitions and interface (specification
      *   only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -92,7 +92,7 @@ FT_BEGIN_HEADER
         FT_String*  full_name;
         FT_String*  family_name;
         FT_String*  weight;
    -    FT_Long     italic_angle;
    +    FT_Fixed    italic_angle;
         FT_Bool     is_fixed_pitch;
         FT_Short    underline_position;
         FT_UShort   underline_thickness;
    @@ -645,7 +645,7 @@ FT_BEGIN_HEADER
         PS_DICT_UNDERLINE_POSITION,     /* FT_Short   */
         PS_DICT_UNDERLINE_THICKNESS,    /* FT_UShort  */
         PS_DICT_FS_TYPE,                /* FT_UShort  */
    -    PS_DICT_ITALIC_ANGLE,           /* FT_Long    */
    +    PS_DICT_ITALIC_ANGLE,           /* FT_Fixed   */
     
         PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h b/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
    index d5d470e380f..3ef61091cc9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType name ID definitions (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -436,7 +436,7 @@ FT_BEGIN_HEADER
        *
        *   The canonical source for Microsoft's IDs is
        *
    -   *     https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings ,
    +   *     https://learn.microsoft.com/windows/win32/intl/language-identifier-constants-and-strings ,
        *
        *   however, we only provide macros for language identifiers present in
        *   the OpenType specification: Microsoft has abandoned the concept of
    @@ -847,113 +847,113 @@ FT_BEGIN_HEADER
       /* --------------- */
     
       /* Bit  0   Basic Latin */
    -#define TT_UCR_BASIC_LATIN                     (1L <<  0) /* U+0020-U+007E */
    +#define TT_UCR_BASIC_LATIN                    (1UL <<  0) /* U+0020-U+007E */
       /* Bit  1   C1 Controls and Latin-1 Supplement */
    -#define TT_UCR_LATIN1_SUPPLEMENT               (1L <<  1) /* U+0080-U+00FF */
    +#define TT_UCR_LATIN1_SUPPLEMENT              (1UL <<  1) /* U+0080-U+00FF */
       /* Bit  2   Latin Extended-A */
    -#define TT_UCR_LATIN_EXTENDED_A                (1L <<  2) /* U+0100-U+017F */
    +#define TT_UCR_LATIN_EXTENDED_A               (1UL <<  2) /* U+0100-U+017F */
       /* Bit  3   Latin Extended-B */
    -#define TT_UCR_LATIN_EXTENDED_B                (1L <<  3) /* U+0180-U+024F */
    +#define TT_UCR_LATIN_EXTENDED_B               (1UL <<  3) /* U+0180-U+024F */
       /* Bit  4   IPA Extensions                 */
       /*          Phonetic Extensions            */
       /*          Phonetic Extensions Supplement */
    -#define TT_UCR_IPA_EXTENSIONS                  (1L <<  4) /* U+0250-U+02AF */
    +#define TT_UCR_IPA_EXTENSIONS                 (1UL <<  4) /* U+0250-U+02AF */
                                                               /* U+1D00-U+1D7F */
                                                               /* U+1D80-U+1DBF */
       /* Bit  5   Spacing Modifier Letters */
       /*          Modifier Tone Letters    */
    -#define TT_UCR_SPACING_MODIFIER                (1L <<  5) /* U+02B0-U+02FF */
    +#define TT_UCR_SPACING_MODIFIER               (1UL <<  5) /* U+02B0-U+02FF */
                                                               /* U+A700-U+A71F */
       /* Bit  6   Combining Diacritical Marks            */
       /*          Combining Diacritical Marks Supplement */
    -#define TT_UCR_COMBINING_DIACRITICAL_MARKS     (1L <<  6) /* U+0300-U+036F */
    +#define TT_UCR_COMBINING_DIACRITICAL_MARKS    (1UL <<  6) /* U+0300-U+036F */
                                                               /* U+1DC0-U+1DFF */
       /* Bit  7   Greek and Coptic */
    -#define TT_UCR_GREEK                           (1L <<  7) /* U+0370-U+03FF */
    +#define TT_UCR_GREEK                          (1UL <<  7) /* U+0370-U+03FF */
       /* Bit  8   Coptic */
    -#define TT_UCR_COPTIC                          (1L <<  8) /* U+2C80-U+2CFF */
    +#define TT_UCR_COPTIC                         (1UL <<  8) /* U+2C80-U+2CFF */
       /* Bit  9   Cyrillic            */
       /*          Cyrillic Supplement */
       /*          Cyrillic Extended-A */
       /*          Cyrillic Extended-B */
    -#define TT_UCR_CYRILLIC                        (1L <<  9) /* U+0400-U+04FF */
    +#define TT_UCR_CYRILLIC                       (1UL <<  9) /* U+0400-U+04FF */
                                                               /* U+0500-U+052F */
                                                               /* U+2DE0-U+2DFF */
                                                               /* U+A640-U+A69F */
       /* Bit 10   Armenian */
    -#define TT_UCR_ARMENIAN                        (1L << 10) /* U+0530-U+058F */
    +#define TT_UCR_ARMENIAN                       (1UL << 10) /* U+0530-U+058F */
       /* Bit 11   Hebrew */
    -#define TT_UCR_HEBREW                          (1L << 11) /* U+0590-U+05FF */
    +#define TT_UCR_HEBREW                         (1UL << 11) /* U+0590-U+05FF */
       /* Bit 12   Vai */
    -#define TT_UCR_VAI                             (1L << 12) /* U+A500-U+A63F */
    +#define TT_UCR_VAI                            (1UL << 12) /* U+A500-U+A63F */
       /* Bit 13   Arabic            */
       /*          Arabic Supplement */
    -#define TT_UCR_ARABIC                          (1L << 13) /* U+0600-U+06FF */
    +#define TT_UCR_ARABIC                         (1UL << 13) /* U+0600-U+06FF */
                                                               /* U+0750-U+077F */
       /* Bit 14   NKo */
    -#define TT_UCR_NKO                             (1L << 14) /* U+07C0-U+07FF */
    +#define TT_UCR_NKO                            (1UL << 14) /* U+07C0-U+07FF */
       /* Bit 15   Devanagari */
    -#define TT_UCR_DEVANAGARI                      (1L << 15) /* U+0900-U+097F */
    -  /* Bit 16   Bengali */
    -#define TT_UCR_BENGALI                         (1L << 16) /* U+0980-U+09FF */
    +#define TT_UCR_DEVANAGARI                     (1UL << 15) /* U+0900-U+097F */
    +  /* Bit 16   Bangla (Bengali) */
    +#define TT_UCR_BENGALI                        (1UL << 16) /* U+0980-U+09FF */
       /* Bit 17   Gurmukhi */
    -#define TT_UCR_GURMUKHI                        (1L << 17) /* U+0A00-U+0A7F */
    +#define TT_UCR_GURMUKHI                       (1UL << 17) /* U+0A00-U+0A7F */
       /* Bit 18   Gujarati */
    -#define TT_UCR_GUJARATI                        (1L << 18) /* U+0A80-U+0AFF */
    -  /* Bit 19   Oriya */
    -#define TT_UCR_ORIYA                           (1L << 19) /* U+0B00-U+0B7F */
    +#define TT_UCR_GUJARATI                       (1UL << 18) /* U+0A80-U+0AFF */
    +  /* Bit 19   Oriya (Odia) */
    +#define TT_UCR_ORIYA                          (1UL << 19) /* U+0B00-U+0B7F */
       /* Bit 20   Tamil */
    -#define TT_UCR_TAMIL                           (1L << 20) /* U+0B80-U+0BFF */
    +#define TT_UCR_TAMIL                          (1UL << 20) /* U+0B80-U+0BFF */
       /* Bit 21   Telugu */
    -#define TT_UCR_TELUGU                          (1L << 21) /* U+0C00-U+0C7F */
    +#define TT_UCR_TELUGU                         (1UL << 21) /* U+0C00-U+0C7F */
       /* Bit 22   Kannada */
    -#define TT_UCR_KANNADA                         (1L << 22) /* U+0C80-U+0CFF */
    +#define TT_UCR_KANNADA                        (1UL << 22) /* U+0C80-U+0CFF */
       /* Bit 23   Malayalam */
    -#define TT_UCR_MALAYALAM                       (1L << 23) /* U+0D00-U+0D7F */
    +#define TT_UCR_MALAYALAM                      (1UL << 23) /* U+0D00-U+0D7F */
       /* Bit 24   Thai */
    -#define TT_UCR_THAI                            (1L << 24) /* U+0E00-U+0E7F */
    +#define TT_UCR_THAI                           (1UL << 24) /* U+0E00-U+0E7F */
       /* Bit 25   Lao */
    -#define TT_UCR_LAO                             (1L << 25) /* U+0E80-U+0EFF */
    +#define TT_UCR_LAO                            (1UL << 25) /* U+0E80-U+0EFF */
       /* Bit 26   Georgian            */
       /*          Georgian Supplement */
    -#define TT_UCR_GEORGIAN                        (1L << 26) /* U+10A0-U+10FF */
    +#define TT_UCR_GEORGIAN                       (1UL << 26) /* U+10A0-U+10FF */
                                                               /* U+2D00-U+2D2F */
       /* Bit 27   Balinese */
    -#define TT_UCR_BALINESE                        (1L << 27) /* U+1B00-U+1B7F */
    +#define TT_UCR_BALINESE                       (1UL << 27) /* U+1B00-U+1B7F */
       /* Bit 28   Hangul Jamo */
    -#define TT_UCR_HANGUL_JAMO                     (1L << 28) /* U+1100-U+11FF */
    +#define TT_UCR_HANGUL_JAMO                    (1UL << 28) /* U+1100-U+11FF */
       /* Bit 29   Latin Extended Additional */
       /*          Latin Extended-C          */
       /*          Latin Extended-D          */
    -#define TT_UCR_LATIN_EXTENDED_ADDITIONAL       (1L << 29) /* U+1E00-U+1EFF */
    +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL      (1UL << 29) /* U+1E00-U+1EFF */
                                                               /* U+2C60-U+2C7F */
                                                               /* U+A720-U+A7FF */
       /* Bit 30   Greek Extended */
    -#define TT_UCR_GREEK_EXTENDED                  (1L << 30) /* U+1F00-U+1FFF */
    +#define TT_UCR_GREEK_EXTENDED                 (1UL << 30) /* U+1F00-U+1FFF */
       /* Bit 31   General Punctuation      */
       /*          Supplemental Punctuation */
    -#define TT_UCR_GENERAL_PUNCTUATION             (1L << 31) /* U+2000-U+206F */
    +#define TT_UCR_GENERAL_PUNCTUATION            (1UL << 31) /* U+2000-U+206F */
                                                               /* U+2E00-U+2E7F */
     
       /* ulUnicodeRange2 */
       /* --------------- */
     
       /* Bit 32   Superscripts And Subscripts */
    -#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS         (1L <<  0) /* U+2070-U+209F */
    +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS        (1UL <<  0) /* U+2070-U+209F */
       /* Bit 33   Currency Symbols */
    -#define TT_UCR_CURRENCY_SYMBOLS                (1L <<  1) /* U+20A0-U+20CF */
    +#define TT_UCR_CURRENCY_SYMBOLS               (1UL <<  1) /* U+20A0-U+20CF */
       /* Bit 34   Combining Diacritical Marks For Symbols */
     #define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
    -                                               (1L <<  2) /* U+20D0-U+20FF */
    +                                              (1UL <<  2) /* U+20D0-U+20FF */
       /* Bit 35   Letterlike Symbols */
    -#define TT_UCR_LETTERLIKE_SYMBOLS              (1L <<  3) /* U+2100-U+214F */
    +#define TT_UCR_LETTERLIKE_SYMBOLS             (1UL <<  3) /* U+2100-U+214F */
       /* Bit 36   Number Forms */
    -#define TT_UCR_NUMBER_FORMS                    (1L <<  4) /* U+2150-U+218F */
    +#define TT_UCR_NUMBER_FORMS                   (1UL <<  4) /* U+2150-U+218F */
       /* Bit 37   Arrows                           */
       /*          Supplemental Arrows-A            */
       /*          Supplemental Arrows-B            */
       /*          Miscellaneous Symbols and Arrows */
    -#define TT_UCR_ARROWS                          (1L <<  5) /* U+2190-U+21FF */
    +#define TT_UCR_ARROWS                         (1UL <<  5) /* U+2190-U+21FF */
                                                               /* U+27F0-U+27FF */
                                                               /* U+2900-U+297F */
                                                               /* U+2B00-U+2BFF */
    @@ -961,52 +961,52 @@ FT_BEGIN_HEADER
       /*          Supplemental Mathematical Operators  */
       /*          Miscellaneous Mathematical Symbols-A */
       /*          Miscellaneous Mathematical Symbols-B */
    -#define TT_UCR_MATHEMATICAL_OPERATORS          (1L <<  6) /* U+2200-U+22FF */
    +#define TT_UCR_MATHEMATICAL_OPERATORS         (1UL <<  6) /* U+2200-U+22FF */
                                                               /* U+2A00-U+2AFF */
                                                               /* U+27C0-U+27EF */
                                                               /* U+2980-U+29FF */
       /* Bit 39 Miscellaneous Technical */
    -#define TT_UCR_MISCELLANEOUS_TECHNICAL         (1L <<  7) /* U+2300-U+23FF */
    +#define TT_UCR_MISCELLANEOUS_TECHNICAL        (1UL <<  7) /* U+2300-U+23FF */
       /* Bit 40   Control Pictures */
    -#define TT_UCR_CONTROL_PICTURES                (1L <<  8) /* U+2400-U+243F */
    +#define TT_UCR_CONTROL_PICTURES               (1UL <<  8) /* U+2400-U+243F */
       /* Bit 41   Optical Character Recognition */
    -#define TT_UCR_OCR                             (1L <<  9) /* U+2440-U+245F */
    +#define TT_UCR_OCR                            (1UL <<  9) /* U+2440-U+245F */
       /* Bit 42   Enclosed Alphanumerics */
    -#define TT_UCR_ENCLOSED_ALPHANUMERICS          (1L << 10) /* U+2460-U+24FF */
    +#define TT_UCR_ENCLOSED_ALPHANUMERICS         (1UL << 10) /* U+2460-U+24FF */
       /* Bit 43   Box Drawing */
    -#define TT_UCR_BOX_DRAWING                     (1L << 11) /* U+2500-U+257F */
    +#define TT_UCR_BOX_DRAWING                    (1UL << 11) /* U+2500-U+257F */
       /* Bit 44   Block Elements */
    -#define TT_UCR_BLOCK_ELEMENTS                  (1L << 12) /* U+2580-U+259F */
    +#define TT_UCR_BLOCK_ELEMENTS                 (1UL << 12) /* U+2580-U+259F */
       /* Bit 45   Geometric Shapes */
    -#define TT_UCR_GEOMETRIC_SHAPES                (1L << 13) /* U+25A0-U+25FF */
    +#define TT_UCR_GEOMETRIC_SHAPES               (1UL << 13) /* U+25A0-U+25FF */
       /* Bit 46   Miscellaneous Symbols */
    -#define TT_UCR_MISCELLANEOUS_SYMBOLS           (1L << 14) /* U+2600-U+26FF */
    +#define TT_UCR_MISCELLANEOUS_SYMBOLS          (1UL << 14) /* U+2600-U+26FF */
       /* Bit 47   Dingbats */
    -#define TT_UCR_DINGBATS                        (1L << 15) /* U+2700-U+27BF */
    +#define TT_UCR_DINGBATS                       (1UL << 15) /* U+2700-U+27BF */
       /* Bit 48   CJK Symbols and Punctuation */
    -#define TT_UCR_CJK_SYMBOLS                     (1L << 16) /* U+3000-U+303F */
    +#define TT_UCR_CJK_SYMBOLS                    (1UL << 16) /* U+3000-U+303F */
       /* Bit 49   Hiragana */
    -#define TT_UCR_HIRAGANA                        (1L << 17) /* U+3040-U+309F */
    +#define TT_UCR_HIRAGANA                       (1UL << 17) /* U+3040-U+309F */
       /* Bit 50   Katakana                     */
       /*          Katakana Phonetic Extensions */
    -#define TT_UCR_KATAKANA                        (1L << 18) /* U+30A0-U+30FF */
    +#define TT_UCR_KATAKANA                       (1UL << 18) /* U+30A0-U+30FF */
                                                               /* U+31F0-U+31FF */
       /* Bit 51   Bopomofo          */
       /*          Bopomofo Extended */
    -#define TT_UCR_BOPOMOFO                        (1L << 19) /* U+3100-U+312F */
    +#define TT_UCR_BOPOMOFO                       (1UL << 19) /* U+3100-U+312F */
                                                               /* U+31A0-U+31BF */
       /* Bit 52   Hangul Compatibility Jamo */
    -#define TT_UCR_HANGUL_COMPATIBILITY_JAMO       (1L << 20) /* U+3130-U+318F */
    +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO      (1UL << 20) /* U+3130-U+318F */
       /* Bit 53   Phags-Pa */
    -#define TT_UCR_CJK_MISC                        (1L << 21) /* U+A840-U+A87F */
    -#define TT_UCR_KANBUN  TT_UCR_CJK_MISC /* deprecated */
    -#define TT_UCR_PHAGSPA
    +#define TT_UCR_PHAGSPA                        (1UL << 21) /* U+A840-U+A87F */
    +#define TT_UCR_KANBUN    TT_UCR_PHAGSPA  /* deprecated */
    +#define TT_UCR_CJK_MISC  TT_UCR_PHAGSPA  /* deprecated */
       /* Bit 54   Enclosed CJK Letters and Months */
    -#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS     (1L << 22) /* U+3200-U+32FF */
    +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS    (1UL << 22) /* U+3200-U+32FF */
       /* Bit 55   CJK Compatibility */
    -#define TT_UCR_CJK_COMPATIBILITY               (1L << 23) /* U+3300-U+33FF */
    +#define TT_UCR_CJK_COMPATIBILITY              (1UL << 23) /* U+3300-U+33FF */
       /* Bit 56   Hangul Syllables */
    -#define TT_UCR_HANGUL                          (1L << 24) /* U+AC00-U+D7A3 */
    +#define TT_UCR_HANGUL                         (1UL << 24) /* U+AC00-U+D7A3 */
       /* Bit 57   High Surrogates              */
       /*          High Private Use Surrogates  */
       /*          Low Surrogates               */
    @@ -1017,12 +1017,12 @@ FT_BEGIN_HEADER
       /* Basic Multilingual Plane that is      */
       /* supported by this font.  So it really */
       /* means >= U+10000.                     */
    -#define TT_UCR_SURROGATES                      (1L << 25) /* U+D800-U+DB7F */
    +#define TT_UCR_SURROGATES                     (1UL << 25) /* U+D800-U+DB7F */
                                                               /* U+DB80-U+DBFF */
                                                               /* U+DC00-U+DFFF */
     #define TT_UCR_NON_PLANE_0  TT_UCR_SURROGATES
       /* Bit 58  Phoenician */
    -#define TT_UCR_PHOENICIAN                      (1L << 26) /*U+10900-U+1091F*/
    +#define TT_UCR_PHOENICIAN                     (1UL << 26) /*U+10900-U+1091F*/
       /* Bit 59   CJK Unified Ideographs             */
       /*          CJK Radicals Supplement            */
       /*          Kangxi Radicals                    */
    @@ -1030,7 +1030,7 @@ FT_BEGIN_HEADER
       /*          CJK Unified Ideographs Extension A */
       /*          CJK Unified Ideographs Extension B */
       /*          Kanbun                             */
    -#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS          (1L << 27) /* U+4E00-U+9FFF */
    +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS         (1UL << 27) /* U+4E00-U+9FFF */
                                                               /* U+2E80-U+2EFF */
                                                               /* U+2F00-U+2FDF */
                                                               /* U+2FF0-U+2FFF */
    @@ -1038,178 +1038,178 @@ FT_BEGIN_HEADER
                                                               /*U+20000-U+2A6DF*/
                                                               /* U+3190-U+319F */
       /* Bit 60   Private Use */
    -#define TT_UCR_PRIVATE_USE                     (1L << 28) /* U+E000-U+F8FF */
    +#define TT_UCR_PRIVATE_USE                    (1UL << 28) /* U+E000-U+F8FF */
       /* Bit 61   CJK Strokes                             */
       /*          CJK Compatibility Ideographs            */
       /*          CJK Compatibility Ideographs Supplement */
    -#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS    (1L << 29) /* U+31C0-U+31EF */
    +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS   (1UL << 29) /* U+31C0-U+31EF */
                                                               /* U+F900-U+FAFF */
                                                               /*U+2F800-U+2FA1F*/
       /* Bit 62   Alphabetic Presentation Forms */
    -#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS   (1L << 30) /* U+FB00-U+FB4F */
    +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS  (1UL << 30) /* U+FB00-U+FB4F */
       /* Bit 63   Arabic Presentation Forms-A */
    -#define TT_UCR_ARABIC_PRESENTATION_FORMS_A     (1L << 31) /* U+FB50-U+FDFF */
    +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A    (1UL << 31) /* U+FB50-U+FDFF */
     
       /* ulUnicodeRange3 */
       /* --------------- */
     
       /* Bit 64   Combining Half Marks */
    -#define TT_UCR_COMBINING_HALF_MARKS            (1L <<  0) /* U+FE20-U+FE2F */
    +#define TT_UCR_COMBINING_HALF_MARKS           (1UL <<  0) /* U+FE20-U+FE2F */
       /* Bit 65   Vertical forms          */
       /*          CJK Compatibility Forms */
    -#define TT_UCR_CJK_COMPATIBILITY_FORMS         (1L <<  1) /* U+FE10-U+FE1F */
    +#define TT_UCR_CJK_COMPATIBILITY_FORMS        (1UL <<  1) /* U+FE10-U+FE1F */
                                                               /* U+FE30-U+FE4F */
       /* Bit 66   Small Form Variants */
    -#define TT_UCR_SMALL_FORM_VARIANTS             (1L <<  2) /* U+FE50-U+FE6F */
    +#define TT_UCR_SMALL_FORM_VARIANTS            (1UL <<  2) /* U+FE50-U+FE6F */
       /* Bit 67   Arabic Presentation Forms-B */
    -#define TT_UCR_ARABIC_PRESENTATION_FORMS_B     (1L <<  3) /* U+FE70-U+FEFE */
    +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B    (1UL <<  3) /* U+FE70-U+FEFF */
       /* Bit 68   Halfwidth and Fullwidth Forms */
    -#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS       (1L <<  4) /* U+FF00-U+FFEF */
    +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS      (1UL <<  4) /* U+FF00-U+FFEF */
       /* Bit 69   Specials */
    -#define TT_UCR_SPECIALS                        (1L <<  5) /* U+FFF0-U+FFFD */
    +#define TT_UCR_SPECIALS                       (1UL <<  5) /* U+FFF0-U+FFFF */
       /* Bit 70   Tibetan */
    -#define TT_UCR_TIBETAN                         (1L <<  6) /* U+0F00-U+0FFF */
    +#define TT_UCR_TIBETAN                        (1UL <<  6) /* U+0F00-U+0FFF */
       /* Bit 71   Syriac */
    -#define TT_UCR_SYRIAC                          (1L <<  7) /* U+0700-U+074F */
    +#define TT_UCR_SYRIAC                         (1UL <<  7) /* U+0700-U+074F */
       /* Bit 72   Thaana */
    -#define TT_UCR_THAANA                          (1L <<  8) /* U+0780-U+07BF */
    +#define TT_UCR_THAANA                         (1UL <<  8) /* U+0780-U+07BF */
       /* Bit 73   Sinhala */
    -#define TT_UCR_SINHALA                         (1L <<  9) /* U+0D80-U+0DFF */
    +#define TT_UCR_SINHALA                        (1UL <<  9) /* U+0D80-U+0DFF */
       /* Bit 74   Myanmar */
    -#define TT_UCR_MYANMAR                         (1L << 10) /* U+1000-U+109F */
    +#define TT_UCR_MYANMAR                        (1UL << 10) /* U+1000-U+109F */
       /* Bit 75   Ethiopic            */
       /*          Ethiopic Supplement */
       /*          Ethiopic Extended   */
    -#define TT_UCR_ETHIOPIC                        (1L << 11) /* U+1200-U+137F */
    +#define TT_UCR_ETHIOPIC                       (1UL << 11) /* U+1200-U+137F */
                                                               /* U+1380-U+139F */
                                                               /* U+2D80-U+2DDF */
       /* Bit 76   Cherokee */
    -#define TT_UCR_CHEROKEE                        (1L << 12) /* U+13A0-U+13FF */
    +#define TT_UCR_CHEROKEE                       (1UL << 12) /* U+13A0-U+13FF */
       /* Bit 77   Unified Canadian Aboriginal Syllabics */
    -#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS   (1L << 13) /* U+1400-U+167F */
    +#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS  (1UL << 13) /* U+1400-U+167F */
       /* Bit 78   Ogham */
    -#define TT_UCR_OGHAM                           (1L << 14) /* U+1680-U+169F */
    +#define TT_UCR_OGHAM                          (1UL << 14) /* U+1680-U+169F */
       /* Bit 79   Runic */
    -#define TT_UCR_RUNIC                           (1L << 15) /* U+16A0-U+16FF */
    +#define TT_UCR_RUNIC                          (1UL << 15) /* U+16A0-U+16FF */
       /* Bit 80   Khmer         */
       /*          Khmer Symbols */
    -#define TT_UCR_KHMER                           (1L << 16) /* U+1780-U+17FF */
    +#define TT_UCR_KHMER                          (1UL << 16) /* U+1780-U+17FF */
                                                               /* U+19E0-U+19FF */
       /* Bit 81   Mongolian */
    -#define TT_UCR_MONGOLIAN                       (1L << 17) /* U+1800-U+18AF */
    +#define TT_UCR_MONGOLIAN                      (1UL << 17) /* U+1800-U+18AF */
       /* Bit 82   Braille Patterns */
    -#define TT_UCR_BRAILLE                         (1L << 18) /* U+2800-U+28FF */
    +#define TT_UCR_BRAILLE                        (1UL << 18) /* U+2800-U+28FF */
       /* Bit 83   Yi Syllables */
       /*          Yi Radicals  */
    -#define TT_UCR_YI                              (1L << 19) /* U+A000-U+A48F */
    +#define TT_UCR_YI                             (1UL << 19) /* U+A000-U+A48F */
                                                               /* U+A490-U+A4CF */
       /* Bit 84   Tagalog  */
       /*          Hanunoo  */
       /*          Buhid    */
       /*          Tagbanwa */
    -#define TT_UCR_PHILIPPINE                      (1L << 20) /* U+1700-U+171F */
    +#define TT_UCR_PHILIPPINE                     (1UL << 20) /* U+1700-U+171F */
                                                               /* U+1720-U+173F */
                                                               /* U+1740-U+175F */
                                                               /* U+1760-U+177F */
       /* Bit 85   Old Italic */
    -#define TT_UCR_OLD_ITALIC                      (1L << 21) /*U+10300-U+1032F*/
    +#define TT_UCR_OLD_ITALIC                     (1UL << 21) /*U+10300-U+1032F*/
       /* Bit 86   Gothic */
    -#define TT_UCR_GOTHIC                          (1L << 22) /*U+10330-U+1034F*/
    +#define TT_UCR_GOTHIC                         (1UL << 22) /*U+10330-U+1034F*/
       /* Bit 87   Deseret */
    -#define TT_UCR_DESERET                         (1L << 23) /*U+10400-U+1044F*/
    +#define TT_UCR_DESERET                        (1UL << 23) /*U+10400-U+1044F*/
       /* Bit 88   Byzantine Musical Symbols      */
       /*          Musical Symbols                */
       /*          Ancient Greek Musical Notation */
    -#define TT_UCR_MUSICAL_SYMBOLS                 (1L << 24) /*U+1D000-U+1D0FF*/
    +#define TT_UCR_MUSICAL_SYMBOLS                (1UL << 24) /*U+1D000-U+1D0FF*/
                                                               /*U+1D100-U+1D1FF*/
                                                               /*U+1D200-U+1D24F*/
       /* Bit 89   Mathematical Alphanumeric Symbols */
    -#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS       (1L << 25) /*U+1D400-U+1D7FF*/
    +#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS      (1UL << 25) /*U+1D400-U+1D7FF*/
       /* Bit 90   Private Use (plane 15) */
       /*          Private Use (plane 16) */
    -#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY       (1L << 26) /*U+F0000-U+FFFFD*/
    +#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY      (1UL << 26) /*U+F0000-U+FFFFD*/
                                                             /*U+100000-U+10FFFD*/
       /* Bit 91   Variation Selectors            */
       /*          Variation Selectors Supplement */
    -#define TT_UCR_VARIATION_SELECTORS             (1L << 27) /* U+FE00-U+FE0F */
    +#define TT_UCR_VARIATION_SELECTORS            (1UL << 27) /* U+FE00-U+FE0F */
                                                               /*U+E0100-U+E01EF*/
       /* Bit 92   Tags */
    -#define TT_UCR_TAGS                            (1L << 28) /*U+E0000-U+E007F*/
    +#define TT_UCR_TAGS                           (1UL << 28) /*U+E0000-U+E007F*/
       /* Bit 93   Limbu */
    -#define TT_UCR_LIMBU                           (1L << 29) /* U+1900-U+194F */
    +#define TT_UCR_LIMBU                          (1UL << 29) /* U+1900-U+194F */
       /* Bit 94   Tai Le */
    -#define TT_UCR_TAI_LE                          (1L << 30) /* U+1950-U+197F */
    +#define TT_UCR_TAI_LE                         (1UL << 30) /* U+1950-U+197F */
       /* Bit 95   New Tai Lue */
    -#define TT_UCR_NEW_TAI_LUE                     (1L << 31) /* U+1980-U+19DF */
    +#define TT_UCR_NEW_TAI_LUE                    (1UL << 31) /* U+1980-U+19DF */
     
       /* ulUnicodeRange4 */
       /* --------------- */
     
       /* Bit 96   Buginese */
    -#define TT_UCR_BUGINESE                        (1L <<  0) /* U+1A00-U+1A1F */
    +#define TT_UCR_BUGINESE                       (1UL <<  0) /* U+1A00-U+1A1F */
       /* Bit 97   Glagolitic */
    -#define TT_UCR_GLAGOLITIC                      (1L <<  1) /* U+2C00-U+2C5F */
    +#define TT_UCR_GLAGOLITIC                     (1UL <<  1) /* U+2C00-U+2C5F */
       /* Bit 98   Tifinagh */
    -#define TT_UCR_TIFINAGH                        (1L <<  2) /* U+2D30-U+2D7F */
    +#define TT_UCR_TIFINAGH                       (1UL <<  2) /* U+2D30-U+2D7F */
       /* Bit 99   Yijing Hexagram Symbols */
    -#define TT_UCR_YIJING                          (1L <<  3) /* U+4DC0-U+4DFF */
    +#define TT_UCR_YIJING                         (1UL <<  3) /* U+4DC0-U+4DFF */
       /* Bit 100  Syloti Nagri */
    -#define TT_UCR_SYLOTI_NAGRI                    (1L <<  4) /* U+A800-U+A82F */
    +#define TT_UCR_SYLOTI_NAGRI                   (1UL <<  4) /* U+A800-U+A82F */
       /* Bit 101  Linear B Syllabary */
       /*          Linear B Ideograms */
       /*          Aegean Numbers     */
    -#define TT_UCR_LINEAR_B                        (1L <<  5) /*U+10000-U+1007F*/
    +#define TT_UCR_LINEAR_B                       (1UL <<  5) /*U+10000-U+1007F*/
                                                               /*U+10080-U+100FF*/
                                                               /*U+10100-U+1013F*/
       /* Bit 102  Ancient Greek Numbers */
    -#define TT_UCR_ANCIENT_GREEK_NUMBERS           (1L <<  6) /*U+10140-U+1018F*/
    +#define TT_UCR_ANCIENT_GREEK_NUMBERS          (1UL <<  6) /*U+10140-U+1018F*/
       /* Bit 103  Ugaritic */
    -#define TT_UCR_UGARITIC                        (1L <<  7) /*U+10380-U+1039F*/
    +#define TT_UCR_UGARITIC                       (1UL <<  7) /*U+10380-U+1039F*/
       /* Bit 104  Old Persian */
    -#define TT_UCR_OLD_PERSIAN                     (1L <<  8) /*U+103A0-U+103DF*/
    +#define TT_UCR_OLD_PERSIAN                    (1UL <<  8) /*U+103A0-U+103DF*/
       /* Bit 105  Shavian */
    -#define TT_UCR_SHAVIAN                         (1L <<  9) /*U+10450-U+1047F*/
    +#define TT_UCR_SHAVIAN                        (1UL <<  9) /*U+10450-U+1047F*/
       /* Bit 106  Osmanya */
    -#define TT_UCR_OSMANYA                         (1L << 10) /*U+10480-U+104AF*/
    +#define TT_UCR_OSMANYA                        (1UL << 10) /*U+10480-U+104AF*/
       /* Bit 107  Cypriot Syllabary */
    -#define TT_UCR_CYPRIOT_SYLLABARY               (1L << 11) /*U+10800-U+1083F*/
    +#define TT_UCR_CYPRIOT_SYLLABARY              (1UL << 11) /*U+10800-U+1083F*/
       /* Bit 108  Kharoshthi */
    -#define TT_UCR_KHAROSHTHI                      (1L << 12) /*U+10A00-U+10A5F*/
    +#define TT_UCR_KHAROSHTHI                     (1UL << 12) /*U+10A00-U+10A5F*/
       /* Bit 109  Tai Xuan Jing Symbols */
    -#define TT_UCR_TAI_XUAN_JING                   (1L << 13) /*U+1D300-U+1D35F*/
    +#define TT_UCR_TAI_XUAN_JING                  (1UL << 13) /*U+1D300-U+1D35F*/
       /* Bit 110  Cuneiform                         */
       /*          Cuneiform Numbers and Punctuation */
    -#define TT_UCR_CUNEIFORM                       (1L << 14) /*U+12000-U+123FF*/
    +#define TT_UCR_CUNEIFORM                      (1UL << 14) /*U+12000-U+123FF*/
                                                               /*U+12400-U+1247F*/
       /* Bit 111  Counting Rod Numerals */
    -#define TT_UCR_COUNTING_ROD_NUMERALS           (1L << 15) /*U+1D360-U+1D37F*/
    +#define TT_UCR_COUNTING_ROD_NUMERALS          (1UL << 15) /*U+1D360-U+1D37F*/
       /* Bit 112  Sundanese */
    -#define TT_UCR_SUNDANESE                       (1L << 16) /* U+1B80-U+1BBF */
    +#define TT_UCR_SUNDANESE                      (1UL << 16) /* U+1B80-U+1BBF */
       /* Bit 113  Lepcha */
    -#define TT_UCR_LEPCHA                          (1L << 17) /* U+1C00-U+1C4F */
    +#define TT_UCR_LEPCHA                         (1UL << 17) /* U+1C00-U+1C4F */
       /* Bit 114  Ol Chiki */
    -#define TT_UCR_OL_CHIKI                        (1L << 18) /* U+1C50-U+1C7F */
    +#define TT_UCR_OL_CHIKI                       (1UL << 18) /* U+1C50-U+1C7F */
       /* Bit 115  Saurashtra */
    -#define TT_UCR_SAURASHTRA                      (1L << 19) /* U+A880-U+A8DF */
    +#define TT_UCR_SAURASHTRA                     (1UL << 19) /* U+A880-U+A8DF */
       /* Bit 116  Kayah Li */
    -#define TT_UCR_KAYAH_LI                        (1L << 20) /* U+A900-U+A92F */
    +#define TT_UCR_KAYAH_LI                       (1UL << 20) /* U+A900-U+A92F */
       /* Bit 117  Rejang */
    -#define TT_UCR_REJANG                          (1L << 21) /* U+A930-U+A95F */
    +#define TT_UCR_REJANG                         (1UL << 21) /* U+A930-U+A95F */
       /* Bit 118  Cham */
    -#define TT_UCR_CHAM                            (1L << 22) /* U+AA00-U+AA5F */
    +#define TT_UCR_CHAM                           (1UL << 22) /* U+AA00-U+AA5F */
       /* Bit 119  Ancient Symbols */
    -#define TT_UCR_ANCIENT_SYMBOLS                 (1L << 23) /*U+10190-U+101CF*/
    +#define TT_UCR_ANCIENT_SYMBOLS                (1UL << 23) /*U+10190-U+101CF*/
       /* Bit 120  Phaistos Disc */
    -#define TT_UCR_PHAISTOS_DISC                   (1L << 24) /*U+101D0-U+101FF*/
    +#define TT_UCR_PHAISTOS_DISC                  (1UL << 24) /*U+101D0-U+101FF*/
       /* Bit 121  Carian */
       /*          Lycian */
       /*          Lydian */
    -#define TT_UCR_OLD_ANATOLIAN                   (1L << 25) /*U+102A0-U+102DF*/
    +#define TT_UCR_OLD_ANATOLIAN                  (1UL << 25) /*U+102A0-U+102DF*/
                                                               /*U+10280-U+1029F*/
                                                               /*U+10920-U+1093F*/
       /* Bit 122  Domino Tiles  */
       /*          Mahjong Tiles */
    -#define TT_UCR_GAME_TILES                      (1L << 26) /*U+1F030-U+1F09F*/
    +#define TT_UCR_GAME_TILES                     (1UL << 26) /*U+1F030-U+1F09F*/
                                                               /*U+1F000-U+1F02F*/
       /* Bit 123-127 Reserved for process-internal usage */
     
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h b/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
    index 2cf0ff1bc61..aa4336435d9 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h
    @@ -5,7 +5,7 @@
      *   Basic SFNT/TrueType tables definitions and interface
      *   (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -192,7 +192,7 @@ FT_BEGIN_HEADER
        *     A pointer into the 'hmtx' table.
        *
        * @note:
    -   *   For an OpenType variation font, the values of the following fields can
    +   *   For OpenType Font Variations, the values of the following fields can
        *   change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
        *   the font contains an 'MVAR' table: `caret_Slope_Rise`,
        *   `caret_Slope_Run`, and `caret_Offset`.
    @@ -310,7 +310,7 @@ FT_BEGIN_HEADER
        *     A pointer into the 'vmtx' table.
        *
        * @note:
    -   *   For an OpenType variation font, the values of the following fields can
    +   *   For OpenType Font Variations, the values of the following fields can
        *   change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
        *   the font contains an 'MVAR' table: `Ascender`, `Descender`,
        *   `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`.
    @@ -359,7 +359,7 @@ FT_BEGIN_HEADER
        *   table.  In this case, the `version` field is always set to 0xFFFF.
        *
        * @note:
    -   *   For an OpenType variation font, the values of the following fields can
    +   *   For OpenType Font Variations, the values of the following fields can
        *   change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
        *   the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`,
        *   `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`,
    @@ -442,7 +442,7 @@ FT_BEGIN_HEADER
        *   them.
        *
        * @note:
    -   *   For an OpenType variation font, the values of the following fields can
    +   *   For OpenType Font Variations, the values of the following fields can
        *   change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
        *   the font contains an 'MVAR' table: `underlinePosition` and
        *   `underlineThickness`.
    @@ -705,6 +705,9 @@ FT_BEGIN_HEADER
        *     definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
        *     one with @FT_MAKE_TAG.
        *
    +   *     [Since 2.14] Use value~1 if you want to access the table directory
    +   *     of the (currently selected) font.
    +   *
        *   offset ::
        *     The starting offset in the table (or file if tag~==~0).
        *
    diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h b/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
    index da0af5d3f23..56bb0a3ee5e 100644
    --- a/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
    +++ b/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h
    @@ -4,7 +4,7 @@
      *
      *   Tags for TrueType and OpenType tables (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/include/ft2build.h b/src/java.desktop/share/native/libfreetype/include/ft2build.h
    index d3d7685039c..3008aea7cf5 100644
    --- a/src/java.desktop/share/native/libfreetype/include/ft2build.h
    +++ b/src/java.desktop/share/native/libfreetype/include/ft2build.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType 2 build and setup macros.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c
    new file mode 100644
    index 00000000000..a1aa45914d0
    --- /dev/null
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c
    @@ -0,0 +1,1621 @@
    +/****************************************************************************
    + *
    + * afadjust.c
    + *
    + *   Auto-fitter routines to adjust components based on charcode (body).
    + *
    + * Copyright (C) 2023-2025 by
    + * David Turner, Robert Wilhelm, and Werner Lemberg.
    + *
    + * Written by Craig White .
    + *
    + * This file is part of the FreeType project, and may only be used,
    + * modified, and distributed under the terms of the FreeType project
    + * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    + * this file you indicate that you have read the license and
    + * understand and accept it fully.
    + *
    + */
    +
    +#include "afadjust.h"
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +#  include "afgsub.h"
    +#endif
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +#define AF_ADJUSTMENT_DATABASE_LENGTH           \
    +          ( sizeof ( adjustment_database ) /    \
    +            sizeof ( adjustment_database[0] ) )
    +
    +#undef  FT_COMPONENT
    +#define FT_COMPONENT  afadjust
    +
    +
    +  typedef struct  AF_AdjustmentDatabaseEntry_
    +  {
    +    FT_UInt32  codepoint;
    +    FT_UInt32  flags;
    +
    +  } AF_AdjustmentDatabaseEntry;
    +
    +
    +  /*
    +    All entries in this list must be sorted by ascending Unicode code
    +    points.  The table entries are 3 numbers consisting of:
    +
    +    - Unicode code point.
    +    - The vertical adjustment type.  This should be a combination of the
    +      AF_ADJUST_XXX and AF_IGNORE_XXX macros.
    +  */
    +  static AF_AdjustmentDatabaseEntry  adjustment_database[] =
    +  {
    +    /* C0 Controls and Basic Latin */
    +    { 0x21,  AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ! */
    +    { 0x51,  AF_IGNORE_CAPITAL_BOTTOM } , /* Q */
    +    { 0x3F,  AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ? */
    +    { 0x69,  AF_ADJUST_UP }, /* i */
    +    { 0x6A,  AF_ADJUST_UP }, /* j */
    +#if 0
    +    /* XXX TODO */
    +    { 0x7E,  AF_ADJUST_TILDE_TOP }, /* ~ */
    +#endif
    +
    +    /* C1 Controls and Latin-1 Supplement */
    +    { 0xA1,  AF_ADJUST_UP }, /* ¡ */
    +    { 0xA6,  AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ¦ */
    +    { 0xAA,  AF_ADJUST_UP }, /* ª */
    +    { 0xBA,  AF_ADJUST_UP }, /* º */
    +    { 0xBF,  AF_ADJUST_UP }, /* ¿ */
    +
    +    { 0xC0,  AF_ADJUST_UP }, /* À */
    +    { 0xC1,  AF_ADJUST_UP }, /* Á */
    +    { 0xC2,  AF_ADJUST_UP }, /* Â */
    +    { 0xC3,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ã */
    +    { 0xC4,  AF_ADJUST_UP }, /* Ä */
    +    { 0xC5,  AF_ADJUST_UP }, /* Å */
    +    { 0xC7,  AF_IGNORE_CAPITAL_BOTTOM }, /* Ç */
    +    { 0xC8,  AF_ADJUST_UP }, /* È */
    +    { 0xC9,  AF_ADJUST_UP }, /* É */
    +    { 0xCA,  AF_ADJUST_UP }, /* Ê */
    +    { 0xCB,  AF_ADJUST_UP }, /* Ë */
    +    { 0xCC,  AF_ADJUST_UP }, /* Ì */
    +    { 0xCD,  AF_ADJUST_UP }, /* Í */
    +    { 0xCE,  AF_ADJUST_UP }, /* Î */
    +    { 0xCF,  AF_ADJUST_UP }, /* Ï */
    +
    +    { 0xD1,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ñ */
    +    { 0xD2,  AF_ADJUST_UP }, /* Ò */
    +    { 0xD3,  AF_ADJUST_UP }, /* Ó */
    +    { 0xD4,  AF_ADJUST_UP }, /* Ô */
    +    { 0xD5,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Õ */
    +    { 0xD6,  AF_ADJUST_UP }, /* Ö */
    +    { 0xD8,  AF_IGNORE_CAPITAL_TOP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ø */
    +    { 0xD9,  AF_ADJUST_UP }, /* Ù */
    +    { 0xDA,  AF_ADJUST_UP }, /* Ú */
    +    { 0xDB,  AF_ADJUST_UP }, /* Û */
    +    { 0xDC,  AF_ADJUST_UP }, /* Ü */
    +    { 0xDD,  AF_ADJUST_UP }, /* Ý */
    +
    +    { 0xE0,  AF_ADJUST_UP }, /* à */
    +    { 0xE1,  AF_ADJUST_UP }, /* á */
    +    { 0xE2,  AF_ADJUST_UP }, /* â */
    +    { 0xE3,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ã */
    +    { 0xE4,  AF_ADJUST_UP }, /* ä */
    +    { 0xE5,  AF_ADJUST_UP }, /* å */
    +    { 0xE7,  AF_IGNORE_SMALL_BOTTOM }, /* ç */
    +    { 0xE8,  AF_ADJUST_UP }, /* è */
    +    { 0xE9,  AF_ADJUST_UP }, /* é */
    +    { 0xEA,  AF_ADJUST_UP }, /* ê */
    +    { 0xEB,  AF_ADJUST_UP }, /* ë */
    +    { 0xEC,  AF_ADJUST_UP }, /* ì */
    +    { 0xED,  AF_ADJUST_UP }, /* í */
    +    { 0xEE,  AF_ADJUST_UP }, /* î */
    +    { 0xEF,  AF_ADJUST_UP }, /* ï */
    +
    +    { 0xF1,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ñ */
    +    { 0xF2,  AF_ADJUST_UP }, /* ò */
    +    { 0xF3,  AF_ADJUST_UP }, /* ó */
    +    { 0xF4,  AF_ADJUST_UP }, /* ô */
    +    { 0xF5,  AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* õ */
    +    { 0xF6,  AF_ADJUST_UP }, /* ö */
    +    { 0xF8,  AF_IGNORE_SMALL_TOP | AF_IGNORE_SMALL_BOTTOM }, /* ø */
    +    { 0xF9,  AF_ADJUST_UP }, /* ù */
    +    { 0xFA,  AF_ADJUST_UP }, /* ú */
    +    { 0xFB,  AF_ADJUST_UP }, /* û */
    +    { 0xFC,  AF_ADJUST_UP }, /* ü */
    +    { 0xFD,  AF_ADJUST_UP }, /* ý */
    +    { 0xFF,  AF_ADJUST_UP }, /* ÿ */
    +
    +    /* Latin Extended-A */
    +    { 0x100, AF_ADJUST_UP }, /* Ā */
    +    { 0x101, AF_ADJUST_UP }, /* ā */
    +    { 0x102, AF_ADJUST_UP }, /* Ă */
    +    { 0x103, AF_ADJUST_UP }, /* ă */
    +    { 0x104, AF_IGNORE_CAPITAL_BOTTOM }, /* Ą */
    +    { 0x105, AF_IGNORE_SMALL_BOTTOM }, /* ą */
    +    { 0x106, AF_ADJUST_UP }, /* Ć */
    +    { 0x107, AF_ADJUST_UP }, /* ć */
    +    { 0x108, AF_ADJUST_UP }, /* Ĉ */
    +    { 0x109, AF_ADJUST_UP }, /* ĉ */
    +    { 0x10A, AF_ADJUST_UP }, /* Ċ */
    +    { 0x10B, AF_ADJUST_UP }, /* ċ */
    +    { 0x10C, AF_ADJUST_UP }, /* Č */
    +    { 0x10D, AF_ADJUST_UP }, /* č */
    +    { 0x10E, AF_ADJUST_UP }, /* Ď */
    +
    +    { 0x112, AF_ADJUST_UP }, /* Ē */
    +    { 0x113, AF_ADJUST_UP }, /* ē */
    +    { 0x114, AF_ADJUST_UP }, /* Ĕ */
    +    { 0x115, AF_ADJUST_UP }, /* ĕ */
    +    { 0x116, AF_ADJUST_UP }, /* Ė */
    +    { 0x117, AF_ADJUST_UP }, /* ė */
    +    { 0x118, AF_IGNORE_CAPITAL_BOTTOM }, /* Ę */
    +    { 0x119, AF_IGNORE_SMALL_BOTTOM }, /* ę */
    +    { 0x11A, AF_ADJUST_UP }, /* Ě */
    +    { 0x11B, AF_ADJUST_UP }, /* ě */
    +    { 0x11C, AF_ADJUST_UP }, /* Ĝ */
    +    { 0x11D, AF_ADJUST_UP }, /* ĝ */
    +    { 0x11E, AF_ADJUST_UP }, /* Ğ */
    +    { 0x11F, AF_ADJUST_UP }, /* ğ */
    +
    +    { 0x120, AF_ADJUST_UP }, /* Ġ */
    +    { 0x121, AF_ADJUST_UP }, /* ġ */
    +    { 0x122, AF_ADJUST_DOWN }, /* Ģ */
    +    { 0x123, AF_ADJUST_UP }, /* ģ */
    +    { 0x124, AF_ADJUST_UP }, /* Ĥ */
    +    { 0x125, AF_ADJUST_UP }, /* ĥ */
    +    { 0x128, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ĩ */
    +    { 0x129, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ĩ */
    +    { 0x12A, AF_ADJUST_UP }, /* Ī */
    +    { 0x12B, AF_ADJUST_UP }, /* ī */
    +    { 0x12C, AF_ADJUST_UP }, /* Ĭ */
    +    { 0x12D, AF_ADJUST_UP }, /* ĭ */
    +    { 0x12E, AF_IGNORE_CAPITAL_BOTTOM }, /* Į */
    +    { 0x12F, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* į */
    +
    +    { 0x130, AF_ADJUST_UP }, /* İ */
    +    { 0x133, AF_ADJUST_UP }, /* ij */
    +    { 0x134, AF_ADJUST_UP }, /* Ĵ */
    +    { 0x135, AF_ADJUST_UP }, /* ĵ */
    +    { 0x136, AF_ADJUST_DOWN }, /* Ķ */
    +    { 0x137, AF_ADJUST_DOWN }, /* ķ */
    +    { 0x139, AF_ADJUST_UP }, /* Ĺ */
    +    { 0x13A, AF_ADJUST_UP }, /* ĺ */
    +    { 0x13B, AF_ADJUST_DOWN }, /* Ļ */
    +    { 0x13C, AF_ADJUST_DOWN }, /* ļ */
    +
    +    { 0x143, AF_ADJUST_UP }, /* Ń */
    +    { 0x144, AF_ADJUST_UP }, /* ń */
    +    { 0x145, AF_ADJUST_DOWN }, /* Ņ */
    +    { 0x146, AF_ADJUST_DOWN }, /* ņ */
    +    { 0x147, AF_ADJUST_UP }, /* Ň */
    +    { 0x148, AF_ADJUST_UP }, /* ň */
    +    { 0x14C, AF_ADJUST_UP }, /* Ō */
    +    { 0x14D, AF_ADJUST_UP }, /* ō */
    +    { 0x14E, AF_ADJUST_UP }, /* Ŏ */
    +    { 0x14F, AF_ADJUST_UP }, /* ŏ */
    +
    +    { 0x150, AF_ADJUST_UP }, /* Ő */
    +    { 0x151, AF_ADJUST_UP }, /* ő */
    +    { 0x154, AF_ADJUST_UP }, /* Ŕ */
    +    { 0x155, AF_ADJUST_UP }, /* ŕ */
    +    { 0x156, AF_ADJUST_DOWN }, /* Ŗ */
    +    { 0x157, AF_ADJUST_DOWN }, /* ŗ */
    +    { 0x158, AF_ADJUST_UP }, /* Ř */
    +    { 0x159, AF_ADJUST_UP }, /* ř */
    +    { 0x15A, AF_ADJUST_UP }, /* Ś */
    +    { 0x15B, AF_ADJUST_UP }, /* ś */
    +    { 0x15C, AF_ADJUST_UP }, /* Ŝ */
    +    { 0x15D, AF_ADJUST_UP }, /* ŝ */
    +    { 0x15E, AF_IGNORE_CAPITAL_BOTTOM }, /* Ş */
    +    { 0x15F, AF_IGNORE_SMALL_BOTTOM }, /* ş */
    +
    +    { 0x160, AF_ADJUST_UP }, /* Š */
    +    { 0x161, AF_ADJUST_UP }, /* š */
    +    { 0x162, AF_IGNORE_CAPITAL_BOTTOM }, /* Ţ */
    +    { 0x163, AF_IGNORE_SMALL_BOTTOM }, /* ţ */
    +    { 0x164, AF_ADJUST_UP }, /* Ť */
    +    { 0x168, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ũ */
    +    { 0x169, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ũ */
    +    { 0x16A, AF_ADJUST_UP }, /* Ū */
    +    { 0x16B, AF_ADJUST_UP }, /* ū */
    +    { 0x16C, AF_ADJUST_UP }, /* Ŭ */
    +    { 0x16D, AF_ADJUST_UP }, /* ŭ */
    +    { 0x16E, AF_ADJUST_UP }, /* Ů */
    +    { 0x16F, AF_ADJUST_UP }, /* ů */
    +
    +    { 0x170, AF_ADJUST_UP }, /* Ű */
    +    { 0x171, AF_ADJUST_UP }, /* ű */
    +    { 0x172, AF_IGNORE_CAPITAL_BOTTOM }, /* Ų */
    +    { 0x173, AF_IGNORE_SMALL_BOTTOM }, /* ų */
    +    { 0x174, AF_ADJUST_UP }, /* Ŵ */
    +    { 0x175, AF_ADJUST_UP }, /* ŵ */
    +    { 0x176, AF_ADJUST_UP }, /* Ŷ */
    +    { 0x177, AF_ADJUST_UP }, /* ŷ */
    +    { 0x178, AF_ADJUST_UP }, /* Ÿ */
    +    { 0x179, AF_ADJUST_UP }, /* Ź */
    +    { 0x17A, AF_ADJUST_UP }, /* ź */
    +    { 0x17B, AF_ADJUST_UP }, /* Ż */
    +    { 0x17C, AF_ADJUST_UP }, /* ż */
    +    { 0x17D, AF_ADJUST_UP }, /* Ž */
    +    { 0x17E, AF_ADJUST_UP }, /* ž */
    +
    +    /* Latin Extended-B */
    +    { 0x187, AF_IGNORE_CAPITAL_TOP }, /* Ƈ */
    +    { 0x188, AF_IGNORE_SMALL_TOP }, /* ƈ */
    +
    +    { 0x1A0, AF_IGNORE_CAPITAL_TOP }, /* Ơ */
    +    { 0x1A1, AF_IGNORE_SMALL_TOP }, /* ơ */
    +    { 0x1A5, AF_IGNORE_SMALL_TOP }, /* ƥ */
    +    { 0x1AB, AF_IGNORE_SMALL_BOTTOM }, /* ƫ */
    +    { 0x1AE, AF_IGNORE_CAPITAL_BOTTOM }, /* Ʈ */
    +    { 0x1AF, AF_IGNORE_CAPITAL_TOP }, /* Ư */
    +
    +    { 0x1B0, AF_IGNORE_SMALL_TOP }, /* ư */
    +    { 0x1B4, AF_IGNORE_SMALL_TOP }, /* ƴ */
    +
    +    { 0x1C3, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ǃ */
    +    { 0x1C4, AF_ADJUST_UP }, /* DŽ */
    +#if 0
    +    { 0x1C5, AF_ADJUST_UP }, /* Dž */
    +    { 0x1C6, AF_ADJUST_UP }, /* dž */
    +    { 0x1C8, AF_ADJUST_UP }, /* Lj */
    +    { 0x1C9, AF_ADJUST_UP }, /* lj */
    +    { 0x1CB, AF_ADJUST_UP }, /* Nj */
    +#endif
    +    { 0x1CC, AF_ADJUST_UP }, /* nj */
    +    { 0x1CD, AF_ADJUST_UP }, /* Ǎ */
    +    { 0x1CE, AF_ADJUST_UP }, /* ǎ */
    +    { 0x1CF, AF_ADJUST_UP }, /* Ǐ */
    +
    +    { 0x1D0, AF_ADJUST_UP }, /* ǐ */
    +    { 0x1D1, AF_ADJUST_UP }, /* Ǒ */
    +    { 0x1D2, AF_ADJUST_UP }, /* ǒ */
    +    { 0x1D3, AF_ADJUST_UP }, /* Ǔ */
    +    { 0x1D4, AF_ADJUST_UP }, /* ǔ */
    +    { 0x1D5, AF_ADJUST_UP2 }, /* Ǖ */
    +    { 0x1D6, AF_ADJUST_UP2 }, /* ǖ */
    +    { 0x1D7, AF_ADJUST_UP2 }, /* Ǘ */
    +    { 0x1D8, AF_ADJUST_UP2 }, /* ǘ */
    +    { 0x1D9, AF_ADJUST_UP2 }, /* Ǚ */
    +    { 0x1DA, AF_ADJUST_UP2 }, /* ǚ */
    +    { 0x1DB, AF_ADJUST_UP2 }, /* Ǜ */
    +    { 0x1DC, AF_ADJUST_UP2 }, /* ǜ */
    +    { 0x1DE, AF_ADJUST_UP2 }, /* Ǟ */
    +    { 0x1DF, AF_ADJUST_UP2 }, /* ǟ */
    +
    +    { 0x1E0, AF_ADJUST_UP2 }, /* Ǡ */
    +    { 0x1E1, AF_ADJUST_UP2 }, /* ǡ */
    +    { 0x1E2, AF_ADJUST_UP }, /* Ǣ */
    +    { 0x1E3, AF_ADJUST_UP }, /* ǣ */
    +    { 0x1E6, AF_ADJUST_UP }, /* Ǧ */
    +    { 0x1E7, AF_ADJUST_UP }, /* ǧ */
    +    { 0x1E8, AF_ADJUST_UP }, /* Ǩ */
    +    { 0x1E9, AF_ADJUST_UP }, /* ǩ */
    +    { 0x1EA, AF_IGNORE_CAPITAL_BOTTOM }, /* Ǫ */
    +    { 0x1EB, AF_IGNORE_SMALL_BOTTOM }, /* ǫ */
    +    { 0x1EC, AF_ADJUST_UP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ǭ */
    +    { 0x1ED, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* ǭ */
    +    { 0x1EE, AF_ADJUST_UP }, /* Ǯ */
    +    { 0x1EF, AF_ADJUST_UP }, /* ǯ */
    +
    +    { 0x1F0, AF_ADJUST_UP }, /* ǰ */
    +    { 0x1F4, AF_ADJUST_UP }, /* Ǵ */
    +    { 0x1F5, AF_ADJUST_UP }, /* ǵ */
    +    { 0x1F8, AF_ADJUST_UP }, /* Ǹ */
    +    { 0x1F9, AF_ADJUST_UP }, /* ǹ */
    +    { 0x1FA, AF_ADJUST_UP2 }, /* Ǻ */
    +    { 0x1FB, AF_ADJUST_UP2 }, /* ǻ */
    +    { 0x1FC, AF_ADJUST_UP }, /* Ǽ */
    +    { 0x1FD, AF_ADJUST_UP }, /* ǽ */
    +    { 0x1FE, AF_ADJUST_UP }, /* Ǿ */
    +    { 0x1FF, AF_ADJUST_UP }, /* ǿ */
    +
    +    { 0x200, AF_ADJUST_UP }, /* Ȁ */
    +    { 0x201, AF_ADJUST_UP }, /* ȁ */
    +    { 0x202, AF_ADJUST_UP }, /* Ȃ */
    +    { 0x203, AF_ADJUST_UP }, /* ȃ */
    +    { 0x204, AF_ADJUST_UP }, /* Ȅ */
    +    { 0x205, AF_ADJUST_UP }, /* ȅ */
    +    { 0x206, AF_ADJUST_UP }, /* Ȇ */
    +    { 0x207, AF_ADJUST_UP }, /* ȇ */
    +    { 0x208, AF_ADJUST_UP }, /* Ȉ */
    +    { 0x209, AF_ADJUST_UP }, /* ȉ */
    +    { 0x20A, AF_ADJUST_UP }, /* Ȋ */
    +    { 0x20B, AF_ADJUST_UP }, /* ȋ */
    +    { 0x20C, AF_ADJUST_UP }, /* Ȍ */
    +    { 0x20D, AF_ADJUST_UP }, /* ȍ */
    +    { 0x20E, AF_ADJUST_UP }, /* Ȏ */
    +    { 0x20F, AF_ADJUST_UP }, /* ȏ */
    +
    +    { 0x210, AF_ADJUST_UP }, /* Ȑ */
    +    { 0x211, AF_ADJUST_UP }, /* ȑ */
    +    { 0x212, AF_ADJUST_UP }, /* Ȓ */
    +    { 0x213, AF_ADJUST_UP }, /* ȓ */
    +    { 0x214, AF_ADJUST_UP }, /* Ȕ */
    +    { 0x215, AF_ADJUST_UP }, /* ȕ */
    +    { 0x216, AF_ADJUST_UP }, /* Ȗ */
    +    { 0x217, AF_ADJUST_UP }, /* ȗ */
    +    { 0x218, AF_ADJUST_DOWN }, /* Ș */
    +    { 0x219, AF_ADJUST_DOWN }, /* ș */
    +    { 0x21A, AF_ADJUST_DOWN }, /* Ț */
    +    { 0x21B, AF_ADJUST_DOWN }, /* ț */
    +    { 0x21E, AF_ADJUST_UP }, /* Ȟ */
    +    { 0x21F, AF_ADJUST_UP }, /* ȟ */
    +
    +    { 0x224, AF_IGNORE_CAPITAL_BOTTOM }, /* Ȥ */
    +    { 0x225, AF_IGNORE_SMALL_BOTTOM }, /* ȥ */
    +    { 0x226, AF_ADJUST_UP }, /* Ȧ */
    +    { 0x227, AF_ADJUST_UP }, /* ȧ */
    +    { 0x228, AF_IGNORE_CAPITAL_BOTTOM }, /* Ȩ */
    +    { 0x229, AF_IGNORE_SMALL_BOTTOM }, /* ȩ */
    +    { 0x22A, AF_ADJUST_UP2 }, /* Ȫ */
    +    { 0x22B, AF_ADJUST_UP2 }, /* ȫ */
    +    { 0x22C, AF_ADJUST_UP2 }, /* Ȭ */
    +    { 0x22D, AF_ADJUST_UP2 }, /* ȭ */
    +    { 0x22E, AF_ADJUST_UP }, /* Ȯ */
    +    { 0x22F, AF_ADJUST_UP }, /* ȯ */
    +
    +    { 0x230, AF_ADJUST_UP2 }, /* Ȱ */
    +    { 0x231, AF_ADJUST_UP2 }, /* ȱ */
    +    { 0x232, AF_ADJUST_UP }, /* Ȳ */
    +    { 0x233, AF_ADJUST_UP }, /* ȳ */
    +    { 0x23A, AF_IGNORE_CAPITAL_TOP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ⱥ */
    +    { 0x23B, AF_IGNORE_CAPITAL_TOP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ȼ */
    +    { 0x23F, AF_IGNORE_SMALL_BOTTOM }, /* ȿ */
    +
    +    { 0x240, AF_IGNORE_SMALL_BOTTOM }, /* ɀ */
    +    { 0x249, AF_ADJUST_UP }, /* ɉ */
    +
    +    /* IPA Extensions */
    +    { 0x256, AF_IGNORE_SMALL_BOTTOM }, /* ɖ */
    +
    +    { 0x260, AF_IGNORE_SMALL_TOP }, /* ɠ */
    +    { 0x267, AF_IGNORE_SMALL_BOTTOM }, /* ɧ */
    +    { 0x268, AF_ADJUST_UP }, /* ɨ */
    +
    +    { 0x272, AF_IGNORE_SMALL_BOTTOM }, /* ɲ */
    +    { 0x273, AF_IGNORE_SMALL_BOTTOM }, /* ɳ */
    +    { 0x27B, AF_IGNORE_SMALL_BOTTOM }, /* ɻ */
    +    { 0x27D, AF_IGNORE_SMALL_BOTTOM }, /* ɽ */
    +
    +    { 0x282, AF_IGNORE_SMALL_BOTTOM }, /* ʂ */
    +    { 0x288, AF_IGNORE_SMALL_BOTTOM }, /* ʈ */
    +
    +    { 0x290, AF_IGNORE_SMALL_BOTTOM }, /* ʐ */
    +    { 0x29B, AF_IGNORE_SMALL_TOP }, /* ʛ */
    +
    +    { 0x2A0, AF_IGNORE_SMALL_TOP }, /* ʠ */
    +
    +    /* Spacing Modifier Letters */
    +    { 0x2B2, AF_ADJUST_UP }, /* ʲ */
    +    { 0x2B5, AF_IGNORE_SMALL_BOTTOM }, /* ʵ */
    +
    +    /* Greek and Coptic */
    +    { 0x390, AF_ADJUST_UP2 }, /* ΐ */
    +
    +    { 0x3AA, AF_ADJUST_UP }, /* Ϊ */
    +    { 0x3AB, AF_ADJUST_UP }, /* Ϋ */
    +    { 0x3AC, AF_ADJUST_UP }, /* ά */
    +    { 0x3AD, AF_ADJUST_UP }, /* έ */
    +    { 0x3AE, AF_ADJUST_UP }, /* ή */
    +    { 0x3AF, AF_ADJUST_UP }, /* ί */
    +
    +    { 0x3B0, AF_ADJUST_UP2 }, /* ΰ */
    +
    +    { 0x3CA, AF_ADJUST_UP }, /* ϊ */
    +    { 0x3CB, AF_ADJUST_UP }, /* ϋ */
    +    { 0x3CC, AF_ADJUST_UP }, /* ό */
    +    { 0x3CD, AF_ADJUST_UP }, /* ύ */
    +    { 0x3CE, AF_ADJUST_UP }, /* ώ */
    +    { 0x3CF, AF_IGNORE_CAPITAL_BOTTOM }, /* Ϗ */
    +
    +    { 0x3D4, AF_ADJUST_UP }, /* ϔ */
    +    { 0x3D7, AF_IGNORE_SMALL_BOTTOM }, /* ϗ */
    +    { 0x3D9, AF_IGNORE_SMALL_BOTTOM }, /* ϙ */
    +
    +    { 0x3E2, AF_IGNORE_CAPITAL_BOTTOM }, /* Ϣ */
    +    { 0x3E3, AF_IGNORE_SMALL_BOTTOM }, /* ϣ */
    +
    +    { 0x3F3, AF_ADJUST_UP }, /* ϳ */
    +
    +    /* Cyrillic */
    +    { 0x400, AF_ADJUST_UP }, /* Ѐ */
    +    { 0x401, AF_ADJUST_UP }, /* Ё */
    +    { 0x403, AF_ADJUST_UP }, /* Ѓ */
    +    { 0x407, AF_ADJUST_UP }, /* Ї */
    +    { 0x40C, AF_ADJUST_UP }, /* Ќ */
    +    { 0x40D, AF_ADJUST_UP }, /* Ѝ */
    +    { 0x40E, AF_ADJUST_UP }, /* Ў */
    +    { 0x40F, AF_IGNORE_CAPITAL_BOTTOM }, /* Џ */
    +
    +    { 0x419, AF_ADJUST_UP }, /* Й */
    +
    +    { 0x426, AF_IGNORE_CAPITAL_BOTTOM }, /* Ц */
    +    { 0x429, AF_IGNORE_CAPITAL_BOTTOM }, /* Щ */
    +
    +    { 0x439, AF_ADJUST_UP }, /* й */
    +
    +    { 0x446, AF_IGNORE_SMALL_BOTTOM }, /* ц */
    +    { 0x449, AF_IGNORE_SMALL_BOTTOM }, /* щ */
    +
    +    { 0x450, AF_ADJUST_UP }, /* ѐ */
    +    { 0x451, AF_ADJUST_UP }, /* ё */
    +    { 0x453, AF_ADJUST_UP }, /* ѓ */
    +    { 0x456, AF_ADJUST_UP }, /* і */
    +    { 0x457, AF_ADJUST_UP }, /* ї */
    +    { 0x458, AF_ADJUST_UP }, /* ј */
    +    { 0x45C, AF_ADJUST_UP }, /* ќ */
    +    { 0x45D, AF_ADJUST_UP }, /* ѝ */
    +    { 0x45E, AF_ADJUST_UP }, /* ў */
    +    { 0x45F, AF_IGNORE_SMALL_BOTTOM }, /* џ */
    +
    +    { 0x476, AF_ADJUST_UP }, /* Ѷ */
    +    { 0x477, AF_ADJUST_UP }, /* ѷ */
    +    { 0x47C, AF_ADJUST_UP2 }, /* Ѽ */
    +    { 0x47D, AF_ADJUST_UP2 }, /* ѽ */
    +    { 0x47E, AF_ADJUST_UP }, /* Ѿ */
    +    { 0x47F, AF_ADJUST_UP }, /* ѿ */
    +
    +    { 0x480, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҁ */
    +    { 0x481, AF_IGNORE_SMALL_BOTTOM }, /* ҁ */
    +    { 0x48A, AF_ADJUST_UP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ҋ */
    +    { 0x48B, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* ҋ */
    +
    +    { 0x490, AF_IGNORE_CAPITAL_TOP }, /* Ґ */
    +    { 0x491, AF_IGNORE_SMALL_TOP }, /* ґ */
    +    { 0x496, AF_IGNORE_CAPITAL_BOTTOM }, /* Җ */
    +    { 0x497, AF_IGNORE_SMALL_BOTTOM }, /* җ */
    +    { 0x498, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҙ */
    +    { 0x499, AF_IGNORE_SMALL_BOTTOM }, /* ҙ */
    +    { 0x49A, AF_IGNORE_CAPITAL_BOTTOM }, /* Қ */
    +    { 0x49B, AF_IGNORE_SMALL_BOTTOM }, /* қ */
    +
    +    { 0x4A2, AF_IGNORE_CAPITAL_BOTTOM }, /* Ң */
    +    { 0x4A3, AF_IGNORE_SMALL_BOTTOM }, /* ң */
    +    { 0x4AA, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҫ */
    +    { 0x4AB, AF_IGNORE_SMALL_BOTTOM }, /* ҫ */
    +    { 0x4AC, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҭ */
    +    { 0x4AD, AF_IGNORE_SMALL_BOTTOM }, /* ҭ */
    +
    +    { 0x4B2, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҳ */
    +    { 0x4B3, AF_IGNORE_SMALL_BOTTOM }, /* ҳ */
    +    { 0x4B4, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҵ */
    +    { 0x4B5, AF_IGNORE_SMALL_BOTTOM }, /* ҵ */
    +    { 0x4B6, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҷ */
    +    { 0x4B7, AF_IGNORE_SMALL_BOTTOM }, /* ҷ */
    +    { 0x4BE, AF_IGNORE_CAPITAL_BOTTOM }, /* Ҿ */
    +    { 0x4BF, AF_IGNORE_SMALL_BOTTOM }, /* ҿ */
    +
    +    { 0x4C1, AF_ADJUST_UP }, /* Ӂ */
    +    { 0x4C2, AF_ADJUST_UP }, /* ӂ */
    +    { 0x4C5, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӆ */
    +    { 0x4C6, AF_IGNORE_SMALL_BOTTOM }, /* ӆ */
    +    { 0x4C9, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӊ */
    +    { 0x4CA, AF_IGNORE_SMALL_BOTTOM }, /* ӊ */
    +    { 0x4CB, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӌ */
    +    { 0x4CC, AF_IGNORE_SMALL_BOTTOM }, /* ӌ */
    +    { 0x4CD, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӎ */
    +    { 0x4CE, AF_IGNORE_SMALL_BOTTOM }, /* ӎ */
    +
    +    { 0x4D0, AF_ADJUST_UP }, /* Ӑ */
    +    { 0x4D1, AF_ADJUST_UP }, /* ӑ */
    +    { 0x4D2, AF_ADJUST_UP }, /* Ӓ */
    +    { 0x4D3, AF_ADJUST_UP }, /* ӓ */
    +    { 0x4D6, AF_ADJUST_UP }, /* Ӗ */
    +    { 0x4D7, AF_ADJUST_UP }, /* ӗ */
    +    { 0x4DA, AF_ADJUST_UP }, /* Ӛ */
    +    { 0x4DB, AF_ADJUST_UP }, /* ӛ */
    +    { 0x4DC, AF_ADJUST_UP }, /* Ӝ */
    +    { 0x4DD, AF_ADJUST_UP }, /* ӝ */
    +    { 0x4DE, AF_ADJUST_UP }, /* Ӟ */
    +    { 0x4DF, AF_ADJUST_UP }, /* ӟ */
    +
    +    { 0x4E2, AF_ADJUST_UP }, /* Ӣ */
    +    { 0x4E3, AF_ADJUST_UP }, /* ӣ */
    +    { 0x4E4, AF_ADJUST_UP }, /* Ӥ */
    +    { 0x4E5, AF_ADJUST_UP }, /* ӥ */
    +    { 0x4E6, AF_ADJUST_UP }, /* Ӧ */
    +    { 0x4E7, AF_ADJUST_UP }, /* ӧ */
    +    { 0x4EA, AF_ADJUST_UP }, /* Ӫ */
    +    { 0x4EB, AF_ADJUST_UP }, /* ӫ */
    +    { 0x4EC, AF_ADJUST_UP }, /* Ӭ */
    +    { 0x4ED, AF_ADJUST_UP }, /* ӭ */
    +    { 0x4EE, AF_ADJUST_UP }, /* Ӯ */
    +    { 0x4EF, AF_ADJUST_UP }, /* ӯ */
    +
    +    { 0x4F0, AF_ADJUST_UP }, /* Ӱ */
    +    { 0x4F1, AF_ADJUST_UP }, /* ӱ */
    +    { 0x4F2, AF_ADJUST_UP }, /* Ӳ */
    +    { 0x4F3, AF_ADJUST_UP }, /* ӳ */
    +    { 0x4F4, AF_ADJUST_UP }, /* Ӵ */
    +    { 0x4F5, AF_ADJUST_UP }, /* ӵ */
    +    { 0x4F6, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӷ */
    +    { 0x4F7, AF_IGNORE_SMALL_BOTTOM }, /* ӷ */
    +    { 0x4F8, AF_ADJUST_UP }, /* Ӹ */
    +    { 0x4F9, AF_ADJUST_UP }, /* ӹ */
    +    { 0x4FA, AF_IGNORE_CAPITAL_BOTTOM }, /* Ӻ */
    +    { 0x4FB, AF_IGNORE_SMALL_BOTTOM }, /* ӻ */
    +
    +    /* Cyrillic Supplement */
    +    { 0x506, AF_IGNORE_CAPITAL_BOTTOM }, /* Ԇ */
    +    { 0x507, AF_IGNORE_SMALL_BOTTOM }, /* ԇ */
    +
    +    { 0x524, AF_IGNORE_CAPITAL_BOTTOM }, /* Ԥ */
    +    { 0x525, AF_IGNORE_SMALL_BOTTOM }, /* ԥ */
    +    { 0x526, AF_IGNORE_CAPITAL_BOTTOM }, /* Ԧ */
    +    { 0x527, AF_IGNORE_SMALL_BOTTOM }, /* ԧ */
    +    { 0x52E, AF_IGNORE_CAPITAL_BOTTOM }, /* Ԯ */
    +    { 0x52F, AF_IGNORE_SMALL_BOTTOM }, /* ԯ */
    +
    +    /* Cherokee */
    +    { 0x13A5, AF_ADJUST_UP }, /* Ꭵ */
    +
    +    /* Phonetic Extensions */
    +    { 0x1D09, AF_ADJUST_DOWN }, /* ᴉ */
    +
    +    { 0x1D4E, AF_ADJUST_DOWN }, /* ᵎ */
    +
    +    { 0x1D51, AF_IGNORE_SMALL_BOTTOM }, /* ᵑ */
    +
    +    { 0x1D62, AF_ADJUST_UP }, /* ᵢ */
    +
    +    /* Phonetic Extensions Supplement */
    +    { 0x1D80, AF_IGNORE_SMALL_BOTTOM }, /* ᶀ */
    +    { 0x1D81, AF_IGNORE_SMALL_BOTTOM }, /* ᶁ */
    +    { 0x1D82, AF_IGNORE_SMALL_BOTTOM }, /* ᶂ */
    +    { 0x1D84, AF_IGNORE_SMALL_BOTTOM }, /* ᶄ */
    +    { 0x1D85, AF_IGNORE_SMALL_BOTTOM }, /* ᶅ */
    +    { 0x1D86, AF_IGNORE_SMALL_BOTTOM }, /* ᶆ */
    +    { 0x1D87, AF_IGNORE_SMALL_BOTTOM }, /* ᶇ */
    +    { 0x1D89, AF_IGNORE_SMALL_BOTTOM }, /* ᶉ */
    +    { 0x1D8A, AF_IGNORE_SMALL_BOTTOM }, /* ᶊ */
    +    { 0x1D8C, AF_IGNORE_SMALL_BOTTOM }, /* ᶌ */
    +    { 0x1D8D, AF_IGNORE_SMALL_BOTTOM }, /* ᶍ */
    +    { 0x1D8E, AF_IGNORE_SMALL_BOTTOM }, /* ᶎ */
    +    { 0x1D8F, AF_IGNORE_SMALL_BOTTOM }, /* ᶏ */
    +
    +    { 0x1D90, AF_IGNORE_SMALL_BOTTOM }, /* ᶐ */
    +    { 0x1D91, AF_IGNORE_SMALL_BOTTOM }, /* ᶑ */
    +    { 0x1D92, AF_IGNORE_SMALL_BOTTOM }, /* ᶒ */
    +    { 0x1D93, AF_IGNORE_SMALL_BOTTOM }, /* ᶓ */
    +    { 0x1D94, AF_IGNORE_SMALL_BOTTOM }, /* ᶔ */
    +    { 0x1D95, AF_IGNORE_SMALL_BOTTOM }, /* ᶕ */
    +    { 0x1D96, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* ᶖ */
    +    { 0x1D97, AF_IGNORE_SMALL_BOTTOM }, /* ᶗ */
    +    { 0x1D98, AF_IGNORE_SMALL_BOTTOM }, /* ᶘ */
    +    { 0x1D99, AF_IGNORE_SMALL_BOTTOM }, /* ᶙ */
    +    { 0x1D9A, AF_IGNORE_SMALL_BOTTOM }, /* ᶚ */
    +
    +    { 0x1DA4, AF_ADJUST_UP }, /* ᶤ */
    +    { 0x1DA8, AF_ADJUST_UP }, /* ᶨ */
    +    { 0x1DA9, AF_IGNORE_SMALL_BOTTOM }, /* ᶩ */
    +    { 0x1DAA, AF_IGNORE_SMALL_BOTTOM }, /* ᶪ */
    +    { 0x1DAC, AF_IGNORE_SMALL_BOTTOM }, /* ᶬ */
    +    { 0x1DAE, AF_IGNORE_SMALL_BOTTOM }, /* ᶮ */
    +    { 0x1DAF, AF_IGNORE_SMALL_BOTTOM }, /* ᶯ */
    +
    +    { 0x1DB3, AF_IGNORE_SMALL_BOTTOM }, /* ᶳ */
    +    { 0x1DB5, AF_IGNORE_SMALL_BOTTOM }, /* ᶵ */
    +    { 0x1DBC, AF_IGNORE_SMALL_BOTTOM }, /* ᶼ */
    +
    +    /* Latin Extended Additional */
    +    { 0x1E00, AF_ADJUST_DOWN }, /* Ḁ */
    +    { 0x1E01, AF_ADJUST_DOWN }, /* ḁ */
    +    { 0x1E02, AF_ADJUST_UP }, /* Ḃ */
    +    { 0x1E03, AF_ADJUST_UP }, /* ḃ */
    +    { 0x1E04, AF_ADJUST_DOWN }, /* Ḅ */
    +    { 0x1E05, AF_ADJUST_DOWN }, /* ḅ */
    +    { 0x1E06, AF_ADJUST_DOWN }, /* Ḇ */
    +    { 0x1E07, AF_ADJUST_DOWN }, /* ḇ */
    +    { 0x1E08, AF_ADJUST_UP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ḉ */
    +    { 0x1E09, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* ḉ */
    +    { 0x1E0A, AF_ADJUST_UP }, /* Ḋ */
    +    { 0x1E0B, AF_ADJUST_UP }, /* ḋ */
    +    { 0x1E0C, AF_ADJUST_DOWN }, /* Ḍ */
    +    { 0x1E0D, AF_ADJUST_DOWN }, /* ḍ */
    +    { 0x1E0E, AF_ADJUST_DOWN }, /* Ḏ */
    +    { 0x1E0F, AF_ADJUST_DOWN }, /* ḏ */
    +
    +    { 0x1E10, AF_ADJUST_DOWN }, /* Ḑ */
    +    { 0x1E11, AF_ADJUST_DOWN }, /* ḑ */
    +    { 0x1E12, AF_ADJUST_DOWN }, /* Ḓ */
    +    { 0x1E13, AF_ADJUST_DOWN }, /* ḓ */
    +    { 0x1E14, AF_ADJUST_UP2 }, /* Ḕ */
    +    { 0x1E15, AF_ADJUST_UP2 }, /* ḕ */
    +    { 0x1E16, AF_ADJUST_UP2 }, /* Ḗ */
    +    { 0x1E17, AF_ADJUST_UP2 }, /* ḗ */
    +    { 0x1E18, AF_ADJUST_DOWN }, /* Ḙ */
    +    { 0x1E19, AF_ADJUST_DOWN }, /* ḙ */
    +    { 0x1E1A, AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* Ḛ */
    +    { 0x1E1B, AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* ḛ */
    +    { 0x1E1C, AF_ADJUST_UP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ḝ */
    +    { 0x1E1D, AF_ADJUST_UP | AF_IGNORE_SMALL_BOTTOM }, /* ḝ */
    +    { 0x1E1E, AF_ADJUST_UP }, /* Ḟ */
    +    { 0x1E1F, AF_ADJUST_UP }, /* ḟ */
    +
    +    { 0x1E20, AF_ADJUST_UP }, /* Ḡ */
    +    { 0x1E21, AF_ADJUST_UP }, /* ḡ */
    +    { 0x1E22, AF_ADJUST_UP }, /* Ḣ */
    +    { 0x1E23, AF_ADJUST_UP }, /* ḣ */
    +    { 0x1E24, AF_ADJUST_DOWN }, /* Ḥ */
    +    { 0x1E25, AF_ADJUST_DOWN }, /* ḥ */
    +    { 0x1E26, AF_ADJUST_UP }, /* Ḧ */
    +    { 0x1E27, AF_ADJUST_UP }, /* ḧ */
    +    { 0x1E28, AF_IGNORE_CAPITAL_BOTTOM }, /* Ḩ */
    +    { 0x1E29, AF_IGNORE_SMALL_BOTTOM }, /* ḩ */
    +    { 0x1E2A, AF_ADJUST_DOWN }, /* Ḫ */
    +    { 0x1E2B, AF_ADJUST_DOWN }, /* ḫ */
    +    { 0x1E2C, AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* Ḭ */
    +    { 0x1E2D, AF_ADJUST_UP | AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* ḭ */
    +    { 0x1E2E, AF_ADJUST_UP2 }, /* Ḯ */
    +    { 0x1E2F, AF_ADJUST_UP2 }, /* ḯ */
    +
    +    { 0x1E30, AF_ADJUST_UP }, /* Ḱ */
    +    { 0x1E31, AF_ADJUST_UP }, /* ḱ */
    +    { 0x1E32, AF_ADJUST_DOWN }, /* Ḳ */
    +    { 0x1E33, AF_ADJUST_DOWN }, /* ḳ */
    +    { 0x1E34, AF_ADJUST_DOWN }, /* Ḵ */
    +    { 0x1E35, AF_ADJUST_DOWN }, /* ḵ */
    +    { 0x1E36, AF_ADJUST_DOWN }, /* Ḷ */
    +    { 0x1E37, AF_ADJUST_DOWN }, /* ḷ */
    +    { 0x1E38, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ḹ */
    +    { 0x1E39, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ḹ */
    +    { 0x1E3A, AF_ADJUST_DOWN }, /* Ḻ */
    +    { 0x1E3B, AF_ADJUST_DOWN }, /* ḻ */
    +    { 0x1E3C, AF_ADJUST_DOWN }, /* Ḽ */
    +    { 0x1E3D, AF_ADJUST_DOWN }, /* ḽ */
    +    { 0x1E3E, AF_ADJUST_UP }, /* Ḿ */
    +    { 0x1E3F, AF_ADJUST_UP }, /* ḿ */
    +
    +    { 0x1E40, AF_ADJUST_UP }, /* Ṁ */
    +    { 0x1E41, AF_ADJUST_UP }, /* ṁ */
    +    { 0x1E42, AF_ADJUST_DOWN }, /* Ṃ */
    +    { 0x1E43, AF_ADJUST_DOWN }, /* ṃ */
    +    { 0x1E44, AF_ADJUST_UP }, /* Ṅ */
    +    { 0x1E45, AF_ADJUST_UP }, /* ṅ */
    +    { 0x1E46, AF_ADJUST_DOWN }, /* Ṇ */
    +    { 0x1E47, AF_ADJUST_DOWN }, /* ṇ */
    +    { 0x1E48, AF_ADJUST_DOWN }, /* Ṉ */
    +    { 0x1E49, AF_ADJUST_DOWN }, /* ṉ */
    +    { 0x1E4A, AF_ADJUST_DOWN }, /* Ṋ */
    +    { 0x1E4B, AF_ADJUST_DOWN }, /* ṋ */
    +    { 0x1E4C, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* Ṍ */
    +    { 0x1E4D, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* ṍ */
    +    { 0x1E4E, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* Ṏ */
    +    { 0x1E4F, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* ṏ */
    +
    +    { 0x1E50, AF_ADJUST_UP2 }, /* Ṑ */
    +    { 0x1E51, AF_ADJUST_UP2 }, /* ṑ */
    +    { 0x1E52, AF_ADJUST_UP2 }, /* Ṓ */
    +    { 0x1E53, AF_ADJUST_UP2 }, /* ṓ */
    +    { 0x1E54, AF_ADJUST_UP }, /* Ṕ */
    +    { 0x1E55, AF_ADJUST_UP }, /* ṕ */
    +    { 0x1E56, AF_ADJUST_UP }, /* Ṗ */
    +    { 0x1E57, AF_ADJUST_UP }, /* ṗ */
    +    { 0x1E58, AF_ADJUST_UP }, /* Ṙ */
    +    { 0x1E59, AF_ADJUST_UP }, /* ṙ */
    +    { 0x1E5A, AF_ADJUST_DOWN }, /* Ṛ */
    +    { 0x1E5B, AF_ADJUST_DOWN }, /* ṛ */
    +    { 0x1E5C, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ṝ */
    +    { 0x1E5D, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ṝ */
    +    { 0x1E5E, AF_ADJUST_DOWN }, /* Ṟ */
    +    { 0x1E5F, AF_ADJUST_DOWN }, /* ṟ */
    +
    +    { 0x1E60, AF_ADJUST_UP }, /* Ṡ */
    +    { 0x1E61, AF_ADJUST_UP }, /* ṡ */
    +    { 0x1E62, AF_ADJUST_DOWN }, /* Ṣ */
    +    { 0x1E63, AF_ADJUST_DOWN }, /* ṣ */
    +    { 0x1E64, AF_ADJUST_UP }, /* Ṥ */
    +    { 0x1E65, AF_ADJUST_UP }, /* ṥ */
    +    { 0x1E66, AF_ADJUST_UP }, /* Ṧ */
    +    { 0x1E67, AF_ADJUST_UP }, /* ṧ */
    +    { 0x1E68, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ṩ */
    +    { 0x1E69, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ṩ */
    +    { 0x1E6A, AF_ADJUST_UP }, /* Ṫ */
    +    { 0x1E6B, AF_ADJUST_UP }, /* ṫ */
    +    { 0x1E6C, AF_ADJUST_DOWN }, /* Ṭ */
    +    { 0x1E6D, AF_ADJUST_DOWN }, /* ṭ */
    +    { 0x1E6E, AF_ADJUST_DOWN }, /* Ṯ */
    +    { 0x1E6F, AF_ADJUST_DOWN }, /* ṯ */
    +
    +    { 0x1E70, AF_ADJUST_DOWN }, /* Ṱ */
    +    { 0x1E71, AF_ADJUST_DOWN }, /* ṱ */
    +    { 0x1E72, AF_ADJUST_DOWN }, /* Ṳ */
    +    { 0x1E73, AF_ADJUST_DOWN }, /* ṳ */
    +    { 0x1E74, AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* Ṵ */
    +    { 0x1E75, AF_ADJUST_DOWN | AF_ADJUST_TILDE_BOTTOM }, /* ṵ */
    +    { 0x1E76, AF_ADJUST_DOWN }, /* Ṷ */
    +    { 0x1E77, AF_ADJUST_DOWN }, /* ṷ */
    +    { 0x1E78, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* Ṹ */
    +    { 0x1E79, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP2 }, /* ṹ */
    +    { 0x1E7A, AF_ADJUST_UP2 }, /* Ṻ */
    +    { 0x1E7B, AF_ADJUST_UP2 }, /* ṻ */
    +    { 0x1E7C, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ṽ */
    +    { 0x1E7D, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ṽ */
    +    { 0x1E7E, AF_ADJUST_DOWN }, /* Ṿ */
    +    { 0x1E7F, AF_ADJUST_DOWN }, /* ṿ */
    +
    +    { 0x1E80, AF_ADJUST_UP }, /* Ẁ */
    +    { 0x1E81, AF_ADJUST_UP }, /* ẁ */
    +    { 0x1E82, AF_ADJUST_UP }, /* Ẃ */
    +    { 0x1E83, AF_ADJUST_UP }, /* ẃ */
    +    { 0x1E84, AF_ADJUST_UP }, /* Ẅ */
    +    { 0x1E85, AF_ADJUST_UP }, /* ẅ */
    +    { 0x1E86, AF_ADJUST_UP }, /* Ẇ */
    +    { 0x1E87, AF_ADJUST_UP }, /* ẇ */
    +    { 0x1E88, AF_ADJUST_DOWN }, /* Ẉ */
    +    { 0x1E89, AF_ADJUST_DOWN }, /* ẉ */
    +    { 0x1E8A, AF_ADJUST_UP }, /* Ẋ */
    +    { 0x1E8B, AF_ADJUST_UP }, /* ẋ */
    +    { 0x1E8C, AF_ADJUST_UP }, /* Ẍ */
    +    { 0x1E8D, AF_ADJUST_UP }, /* ẍ */
    +    { 0x1E8E, AF_ADJUST_UP }, /* Ẏ */
    +    { 0x1E8F, AF_ADJUST_UP }, /* ẏ */
    +
    +    { 0x1E90, AF_ADJUST_UP }, /* Ẑ */
    +    { 0x1E91, AF_ADJUST_UP }, /* ẑ */
    +    { 0x1E92, AF_ADJUST_DOWN }, /* Ẓ */
    +    { 0x1E93, AF_ADJUST_DOWN }, /* ẓ */
    +    { 0x1E94, AF_ADJUST_DOWN }, /* Ẕ */
    +    { 0x1E95, AF_ADJUST_DOWN }, /* ẕ */
    +    { 0x1E96, AF_ADJUST_DOWN }, /* ẖ */
    +    { 0x1E97, AF_ADJUST_UP }, /* ẗ */
    +    { 0x1E98, AF_ADJUST_UP }, /* ẘ */
    +    { 0x1E99, AF_ADJUST_UP }, /* ẙ */
    +    { 0x1E9A, AF_ADJUST_UP }, /* ẚ */
    +    { 0x1E9B, AF_ADJUST_UP }, /* ẛ */
    +
    +    { 0x1EA0, AF_ADJUST_DOWN }, /* Ạ */
    +    { 0x1EA1, AF_ADJUST_DOWN }, /* ạ */
    +    { 0x1EA2, AF_ADJUST_UP }, /* Ả */
    +    { 0x1EA3, AF_ADJUST_UP }, /* ả */
    +    { 0x1EA4, AF_ADJUST_UP2 }, /* Ấ */
    +    { 0x1EA5, AF_ADJUST_UP2 }, /* ấ */
    +    { 0x1EA6, AF_ADJUST_UP2 }, /* Ầ */
    +    { 0x1EA7, AF_ADJUST_UP2 }, /* ầ */
    +    { 0x1EA8, AF_ADJUST_UP2 }, /* Ẩ */
    +    { 0x1EA9, AF_ADJUST_UP2 }, /* ẩ */
    +    { 0x1EAA, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* Ẫ */
    +    { 0x1EAB, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ẫ */
    +    { 0x1EAC, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ậ */
    +    { 0x1EAD, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ậ */
    +    { 0x1EAE, AF_ADJUST_UP2 }, /* Ắ */
    +    { 0x1EAF, AF_ADJUST_UP2 }, /* ắ */
    +
    +    { 0x1EB0, AF_ADJUST_UP2 }, /* Ằ */
    +    { 0x1EB1, AF_ADJUST_UP2 }, /* ằ */
    +    { 0x1EB2, AF_ADJUST_UP2 }, /* Ẳ */
    +    { 0x1EB3, AF_ADJUST_UP2 }, /* ẳ */
    +    { 0x1EB4, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* Ẵ */
    +    { 0x1EB5, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ẵ */
    +    { 0x1EB6, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ặ */
    +    { 0x1EB7, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ặ */
    +    { 0x1EB8, AF_ADJUST_DOWN }, /* Ẹ */
    +    { 0x1EB9, AF_ADJUST_DOWN }, /* ẹ */
    +    { 0x1EBA, AF_ADJUST_UP }, /* Ẻ */
    +    { 0x1EBB, AF_ADJUST_UP }, /* ẻ */
    +    { 0x1EBC, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ẽ */
    +    { 0x1EBD, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ẽ */
    +    { 0x1EBE, AF_ADJUST_UP2 }, /* Ế */
    +    { 0x1EBF, AF_ADJUST_UP2 }, /* ế */
    +
    +    { 0x1EC0, AF_ADJUST_UP2 }, /* Ề */
    +    { 0x1EC1, AF_ADJUST_UP2 }, /* ề */
    +    { 0x1EC2, AF_ADJUST_UP2 }, /* Ể */
    +    { 0x1EC3, AF_ADJUST_UP2 }, /* ể */
    +    { 0x1EC4, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* Ễ */
    +    { 0x1EC5, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ễ */
    +    { 0x1EC6, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ệ */
    +    { 0x1EC7, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ệ */
    +    { 0x1EC8, AF_ADJUST_UP }, /* Ỉ */
    +    { 0x1EC9, AF_ADJUST_UP }, /* ỉ */
    +    { 0x1ECA, AF_ADJUST_DOWN }, /* Ị */
    +    { 0x1ECB, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ị */
    +    { 0x1ECC, AF_ADJUST_DOWN }, /* Ọ */
    +    { 0x1ECD, AF_ADJUST_DOWN }, /* ọ */
    +    { 0x1ECE, AF_ADJUST_UP }, /* Ỏ */
    +    { 0x1ECF, AF_ADJUST_UP }, /* ỏ */
    +
    +    { 0x1ED0, AF_ADJUST_UP2 }, /* Ố */
    +    { 0x1ED1, AF_ADJUST_UP2 }, /* ố */
    +    { 0x1ED2, AF_ADJUST_UP2 }, /* Ồ */
    +    { 0x1ED3, AF_ADJUST_UP2 }, /* ồ */
    +    { 0x1ED4, AF_ADJUST_UP2 }, /* Ổ */
    +    { 0x1ED5, AF_ADJUST_UP2 }, /* ổ */
    +    { 0x1ED6, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* Ỗ */
    +    { 0x1ED7, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ỗ */
    +    { 0x1ED8, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* Ộ */
    +    { 0x1ED9, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ộ */
    +    { 0x1EDA, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ớ */
    +    { 0x1EDB, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ớ */
    +    { 0x1EDC, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ờ */
    +    { 0x1EDD, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ờ */
    +    { 0x1EDE, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ở */
    +    { 0x1EDF, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ở */
    +
    +    { 0x1EE0, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_IGNORE_CAPITAL_TOP }, /* Ỡ */
    +    { 0x1EE1, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_IGNORE_SMALL_TOP }, /* ỡ */
    +    { 0x1EE2, AF_ADJUST_DOWN | AF_IGNORE_CAPITAL_TOP }, /* Ợ */
    +    { 0x1EE3, AF_ADJUST_DOWN | AF_IGNORE_SMALL_TOP }, /* ợ */
    +    { 0x1EE4, AF_ADJUST_DOWN }, /* Ụ */
    +    { 0x1EE5, AF_ADJUST_DOWN }, /* ụ */
    +    { 0x1EE6, AF_ADJUST_UP }, /* Ủ */
    +    { 0x1EE7, AF_ADJUST_UP }, /* ủ */
    +    { 0x1EE8, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ứ */
    +    { 0x1EE9, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ứ */
    +    { 0x1EEA, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ừ */
    +    { 0x1EEB, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ừ */
    +    { 0x1EEC, AF_ADJUST_UP | AF_IGNORE_CAPITAL_TOP }, /* Ử */
    +    { 0x1EED, AF_ADJUST_UP | AF_IGNORE_SMALL_TOP }, /* ử */
    +    { 0x1EEE, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_IGNORE_CAPITAL_TOP }, /* Ữ */
    +    { 0x1EEF, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_IGNORE_SMALL_TOP }, /* ữ */
    +
    +    { 0x1EF0, AF_ADJUST_DOWN | AF_IGNORE_CAPITAL_TOP }, /* Ự */
    +    { 0x1EF1, AF_ADJUST_DOWN | AF_IGNORE_SMALL_TOP }, /* ự */
    +    { 0x1EF2, AF_ADJUST_UP }, /* Ỳ */
    +    { 0x1EF3, AF_ADJUST_UP }, /* ỳ */
    +    { 0x1EF4, AF_ADJUST_DOWN }, /* Ỵ */
    +    { 0x1EF5, AF_ADJUST_DOWN }, /* ỵ */
    +    { 0x1EF6, AF_ADJUST_UP }, /* Ỷ */
    +    { 0x1EF7, AF_ADJUST_UP }, /* ỷ */
    +    { 0x1EF8, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* Ỹ */
    +    { 0x1EF9, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ỹ */
    +
    +    /* Greek Extended */
    +    { 0x1F00, AF_ADJUST_UP }, /* ἀ */
    +    { 0x1F01, AF_ADJUST_UP }, /* ἁ */
    +    { 0x1F02, AF_ADJUST_UP }, /* ἂ */
    +    { 0x1F03, AF_ADJUST_UP }, /* ἃ */
    +    { 0x1F04, AF_ADJUST_UP }, /* ἄ */
    +    { 0x1F05, AF_ADJUST_UP }, /* ἅ */
    +    { 0x1F06, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἆ */
    +    { 0x1F07, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἇ */
    +
    +    { 0x1F10, AF_ADJUST_UP }, /* ἐ */
    +    { 0x1F11, AF_ADJUST_UP }, /* ἑ */
    +    { 0x1F12, AF_ADJUST_UP }, /* ἒ */
    +    { 0x1F13, AF_ADJUST_UP }, /* ἓ */
    +    { 0x1F14, AF_ADJUST_UP }, /* ἔ */
    +    { 0x1F15, AF_ADJUST_UP }, /* ἕ */
    +
    +    { 0x1F20, AF_ADJUST_UP }, /* ἠ */
    +    { 0x1F21, AF_ADJUST_UP }, /* ἡ */
    +    { 0x1F22, AF_ADJUST_UP }, /* ἢ */
    +    { 0x1F23, AF_ADJUST_UP }, /* ἣ */
    +    { 0x1F24, AF_ADJUST_UP }, /* ἤ */
    +    { 0x1F25, AF_ADJUST_UP }, /* ἥ */
    +    { 0x1F26, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἦ */
    +    { 0x1F27, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἧ */
    +
    +    { 0x1F30, AF_ADJUST_UP }, /* ἰ */
    +    { 0x1F31, AF_ADJUST_UP }, /* ἱ */
    +    { 0x1F32, AF_ADJUST_UP }, /* ἲ */
    +    { 0x1F33, AF_ADJUST_UP }, /* ἳ */
    +    { 0x1F34, AF_ADJUST_UP }, /* ἴ */
    +    { 0x1F35, AF_ADJUST_UP }, /* ἵ */
    +    { 0x1F36, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἶ */
    +    { 0x1F37, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ἷ */
    +
    +    { 0x1F40, AF_ADJUST_UP }, /* ὀ */
    +    { 0x1F41, AF_ADJUST_UP }, /* ὁ */
    +    { 0x1F42, AF_ADJUST_UP }, /* ὂ */
    +    { 0x1F43, AF_ADJUST_UP }, /* ὃ */
    +    { 0x1F44, AF_ADJUST_UP }, /* ὄ */
    +    { 0x1F45, AF_ADJUST_UP }, /* ὅ */
    +
    +    { 0x1F50, AF_ADJUST_UP }, /* ὐ */
    +    { 0x1F51, AF_ADJUST_UP }, /* ὑ */
    +    { 0x1F52, AF_ADJUST_UP }, /* ὒ */
    +    { 0x1F53, AF_ADJUST_UP }, /* ὓ */
    +    { 0x1F54, AF_ADJUST_UP }, /* ὔ */
    +    { 0x1F55, AF_ADJUST_UP }, /* ὕ */
    +    { 0x1F56, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ὖ */
    +    { 0x1F57, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ὗ */
    +
    +    { 0x1F60, AF_ADJUST_UP }, /* ὠ */
    +    { 0x1F61, AF_ADJUST_UP }, /* ὡ */
    +    { 0x1F62, AF_ADJUST_UP }, /* ὢ */
    +    { 0x1F63, AF_ADJUST_UP }, /* ὣ */
    +    { 0x1F64, AF_ADJUST_UP }, /* ὤ */
    +    { 0x1F65, AF_ADJUST_UP }, /* ὥ */
    +    { 0x1F66, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ὦ */
    +    { 0x1F67, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ὧ */
    +
    +    { 0x1F70, AF_ADJUST_UP }, /* ὰ */
    +    { 0x1F71, AF_ADJUST_UP }, /* ά */
    +    { 0x1F72, AF_ADJUST_UP }, /* ὲ */
    +    { 0x1F73, AF_ADJUST_UP }, /* έ */
    +    { 0x1F74, AF_ADJUST_UP }, /* ὴ */
    +    { 0x1F75, AF_ADJUST_UP }, /* ή */
    +    { 0x1F76, AF_ADJUST_UP }, /* ὶ */
    +    { 0x1F77, AF_ADJUST_UP }, /* ί */
    +    { 0x1F78, AF_ADJUST_UP }, /* ὸ */
    +    { 0x1F79, AF_ADJUST_UP }, /* ό */
    +    { 0x1F7A, AF_ADJUST_UP }, /* ὺ */
    +    { 0x1F7B, AF_ADJUST_UP }, /* ύ */
    +    { 0x1F7C, AF_ADJUST_UP }, /* ὼ */
    +    { 0x1F7D, AF_ADJUST_UP }, /* ώ */
    +
    +    { 0x1F80, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾀ */
    +    { 0x1F81, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾁ */
    +    { 0x1F82, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾂ */
    +    { 0x1F83, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾃ */
    +    { 0x1F84, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾄ */
    +    { 0x1F85, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾅ */
    +    { 0x1F86, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾆ */
    +    { 0x1F87, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾇ */
    +    { 0x1F88, AF_ADJUST_DOWN }, /* ᾈ */
    +    { 0x1F89, AF_ADJUST_DOWN }, /* ᾉ */
    +    { 0x1F8A, AF_ADJUST_DOWN }, /* ᾊ */
    +    { 0x1F8B, AF_ADJUST_DOWN }, /* ᾋ */
    +    { 0x1F8C, AF_ADJUST_DOWN }, /* ᾌ */
    +    { 0x1F8D, AF_ADJUST_DOWN }, /* ᾍ */
    +    { 0x1F8E, AF_ADJUST_DOWN }, /* ᾎ */
    +    { 0x1F8F, AF_ADJUST_DOWN }, /* ᾏ */
    +
    +    { 0x1F90, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾐ */
    +    { 0x1F91, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾑ */
    +    { 0x1F92, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾒ */
    +    { 0x1F93, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾓ */
    +    { 0x1F94, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾔ */
    +    { 0x1F95, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾕ */
    +    { 0x1F96, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾖ */
    +    { 0x1F97, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾗ */
    +    { 0x1F98, AF_ADJUST_DOWN }, /* ᾘ */
    +    { 0x1F99, AF_ADJUST_DOWN }, /* ᾙ */
    +    { 0x1F9A, AF_ADJUST_DOWN }, /* ᾚ */
    +    { 0x1F9B, AF_ADJUST_DOWN }, /* ᾛ */
    +    { 0x1F9C, AF_ADJUST_DOWN }, /* ᾜ */
    +    { 0x1F9D, AF_ADJUST_DOWN }, /* ᾝ */
    +    { 0x1F9E, AF_ADJUST_DOWN }, /* ᾞ */
    +    { 0x1F9F, AF_ADJUST_DOWN }, /* ᾟ */
    +
    +    { 0x1FA0, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾠ */
    +    { 0x1FA1, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾡ */
    +    { 0x1FA2, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾢ */
    +    { 0x1FA3, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾣ */
    +    { 0x1FA4, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾤ */
    +    { 0x1FA5, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾥ */
    +    { 0x1FA6, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾦ */
    +    { 0x1FA7, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾧ */
    +    { 0x1FA8, AF_ADJUST_DOWN }, /* ᾨ */
    +    { 0x1FA9, AF_ADJUST_DOWN }, /* ᾩ */
    +    { 0x1FAA, AF_ADJUST_DOWN }, /* ᾪ */
    +    { 0x1FAB, AF_ADJUST_DOWN }, /* ᾫ */
    +    { 0x1FAC, AF_ADJUST_DOWN }, /* ᾬ */
    +    { 0x1FAD, AF_ADJUST_DOWN }, /* ᾭ */
    +    { 0x1FAE, AF_ADJUST_DOWN }, /* ᾮ */
    +    { 0x1FAF, AF_ADJUST_DOWN }, /* ᾯ */
    +
    +    { 0x1FB0, AF_ADJUST_UP }, /* ᾰ */
    +    { 0x1FB1, AF_ADJUST_UP }, /* ᾱ */
    +    { 0x1FB2, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾲ */
    +    { 0x1FB3, AF_ADJUST_DOWN }, /* ᾳ */
    +    { 0x1FB4, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ᾴ */
    +    { 0x1FB6, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ᾶ */
    +    { 0x1FB7, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ᾷ */
    +    { 0x1FB8, AF_ADJUST_UP }, /* Ᾰ */
    +    { 0x1FB9, AF_ADJUST_UP }, /* Ᾱ */
    +    { 0x1FBC, AF_ADJUST_DOWN }, /* ᾼ */
    +
    +    { 0x1FC2, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ῂ */
    +    { 0x1FC3, AF_ADJUST_DOWN }, /* ῃ */
    +    { 0x1FC4, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ῄ */
    +    { 0x1FC6, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ῆ */
    +    { 0x1FC7, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ῇ */
    +    { 0x1FCC, AF_ADJUST_DOWN }, /* ῌ */
    +
    +    { 0x1FD0, AF_ADJUST_UP }, /* ῐ */
    +    { 0x1FD1, AF_ADJUST_UP }, /* ῑ */
    +    { 0x1FD2, AF_ADJUST_UP2 }, /* ῒ */
    +    { 0x1FD3, AF_ADJUST_UP2 }, /* ΐ */
    +    { 0x1FD6, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ῖ */
    +    { 0x1FD7, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ῗ */
    +    { 0x1FD8, AF_ADJUST_UP }, /* Ῐ */
    +    { 0x1FD9, AF_ADJUST_UP }, /* Ῑ */
    +
    +    { 0x1FE0, AF_ADJUST_UP }, /* ῠ */
    +    { 0x1FE1, AF_ADJUST_UP }, /* ῡ */
    +    { 0x1FE2, AF_ADJUST_UP2 }, /* ῢ */
    +    { 0x1FE3, AF_ADJUST_UP2 }, /* ΰ */
    +    { 0x1FE4, AF_ADJUST_UP }, /* ῤ */
    +    { 0x1FE5, AF_ADJUST_UP }, /* ῥ */
    +    { 0x1FE6, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ῦ */
    +    { 0x1FE7, AF_ADJUST_UP2 | AF_ADJUST_TILDE_TOP }, /* ῧ */
    +    { 0x1FE8, AF_ADJUST_UP }, /* Ῠ */
    +    { 0x1FE9, AF_ADJUST_UP }, /* Ῡ */
    +    { 0x1FF2, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ῲ */
    +    { 0x1FF3, AF_ADJUST_DOWN }, /* ῳ */
    +    { 0x1FF4, AF_ADJUST_UP | AF_ADJUST_DOWN }, /* ῴ */
    +    { 0x1FF6, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP }, /* ῶ */
    +    { 0x1FF7, AF_ADJUST_UP | AF_ADJUST_TILDE_TOP | AF_ADJUST_DOWN }, /* ῷ */
    +    { 0x1FFC, AF_ADJUST_DOWN }, /* ῼ */
    +
    +    /* General Punctuation */
    +    { 0x203C, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ‼ */
    +    { 0x203D, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ‽ */
    +
    +    { 0x2047, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ⁇ */
    +    { 0x2048, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ⁈ */
    +    { 0x2049, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ⁉ */
    +
    +    /* Superscripts and Subscripts */
    +    { 0x2071, AF_ADJUST_UP }, /* ⁱ */
    +
    +    /* Currency Symbols */
    +    { 0x20AB, AF_ADJUST_DOWN }, /* ₫ */
    +
    +    { 0x20C0, AF_ADJUST_DOWN }, /* ⃀ */
    +
    +    /* Number Forms */
    +    { 0x2170, AF_ADJUST_UP }, /* ⅰ */
    +    { 0x2171, AF_ADJUST_UP }, /* ⅱ */
    +    { 0x2172, AF_ADJUST_UP }, /* ⅲ */
    +    { 0x2173, AF_ADJUST_UP }, /* ⅳ */
    +    { 0x2175, AF_ADJUST_UP }, /* ⅵ */
    +    { 0x2176, AF_ADJUST_UP }, /* ⅶ */
    +    { 0x2177, AF_ADJUST_UP }, /* ⅷ */
    +    { 0x2178, AF_ADJUST_UP }, /* ⅸ */
    +    { 0x217A, AF_ADJUST_UP }, /* ⅺ */
    +    { 0x217B, AF_ADJUST_UP }, /* ⅻ */
    +
    +    /* Latin Extended-C */
    +    { 0x2C64, AF_IGNORE_CAPITAL_BOTTOM } , /* Ɽ */
    +    { 0x2C67, AF_IGNORE_CAPITAL_BOTTOM } , /* Ⱨ */
    +    { 0x2C68, AF_IGNORE_SMALL_BOTTOM } , /* ⱨ */
    +    { 0x2C69, AF_IGNORE_CAPITAL_BOTTOM } , /* Ⱪ */
    +    { 0x2C6A, AF_IGNORE_SMALL_BOTTOM } , /* ⱪ */
    +    { 0x2C6B, AF_IGNORE_CAPITAL_BOTTOM } , /* Ⱬ */
    +    { 0x2C6C, AF_IGNORE_SMALL_BOTTOM } , /* ⱬ */
    +    { 0x2C6E, AF_IGNORE_CAPITAL_BOTTOM } , /* Ɱ */
    +
    +    { 0x2C7C, AF_ADJUST_UP }, /* ⱼ */
    +    { 0x2C7E, AF_IGNORE_CAPITAL_BOTTOM } , /* Ȿ */
    +    { 0x2C7F, AF_IGNORE_CAPITAL_BOTTOM } , /* Ɀ */
    +
    +    /* Coptic */
    +    { 0x2CC2, AF_ADJUST_UP }, /* Ⳃ */
    +    { 0x2CC3, AF_ADJUST_UP }, /* ⳃ */
    +
    +    /* Supplemental Punctuation */
    +    { 0x2E18, AF_ADJUST_UP }, /* ⸘ */
    +
    +    { 0x2E2E, AF_ADJUST_UP | AF_ADJUST_NO_HEIGHT_CHECK }, /* ⸮ */
    +
    +    /* Cyrillic Extended-B */
    +    { 0xA640, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꙁ */
    +    { 0xA641, AF_IGNORE_SMALL_BOTTOM } , /* ꙁ */
    +    { 0xA642, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꙃ */
    +    { 0xA643, AF_IGNORE_SMALL_BOTTOM } , /* ꙃ */
    +
    +    { 0xA680, AF_IGNORE_CAPITAL_TOP } , /* Ꚁ */
    +    { 0xA681, AF_IGNORE_SMALL_TOP } , /* ꚁ */
    +    { 0xA688, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꚉ */
    +    { 0xA689, AF_IGNORE_SMALL_BOTTOM } , /* ꚉ */
    +    { 0xA68A, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꚋ */
    +    { 0xA68B, AF_IGNORE_SMALL_BOTTOM } , /* ꚋ */
    +    { 0xA68E, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꚏ */
    +    { 0xA68F, AF_IGNORE_SMALL_BOTTOM } , /* ꚏ */
    +
    +    { 0xA690, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꚑ */
    +    { 0xA691, AF_IGNORE_SMALL_BOTTOM } , /* ꚑ */
    +    { 0xA696, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꚗ */
    +    { 0xA697, AF_IGNORE_SMALL_BOTTOM } , /* ꚗ */
    +
    +    /* Latin Extended-D */
    +    { 0xA726, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꜧ */
    +    { 0xA727, AF_IGNORE_SMALL_BOTTOM } , /* ꜧ */
    +
    +    { 0xA756, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꝗ */
    +    { 0xA758, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꝙ */
    +
    +    { 0xA771, AF_IGNORE_SMALL_BOTTOM } , /* ꝱ */
    +    { 0xA772, AF_IGNORE_SMALL_BOTTOM } , /* ꝲ */
    +    { 0xA773, AF_IGNORE_SMALL_BOTTOM } , /* ꝳ */
    +    { 0xA774, AF_IGNORE_SMALL_BOTTOM } , /* ꝴ */
    +    { 0xA776, AF_IGNORE_SMALL_BOTTOM } , /* ꝶ */
    +
    +    { 0xA790, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꞑ */
    +    { 0xA791, AF_IGNORE_SMALL_BOTTOM } , /* ꞑ */
    +    { 0xA794, AF_IGNORE_SMALL_BOTTOM } , /* ꞔ */
    +    { 0xA795, AF_IGNORE_SMALL_BOTTOM } , /* ꞕ */
    +
    +    { 0xA7C0, AF_IGNORE_CAPITAL_TOP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ꟁ */
    +    { 0xA7C1, AF_IGNORE_SMALL_TOP | AF_IGNORE_SMALL_BOTTOM }, /* ꟁ */
    +    { 0xA7C4, AF_IGNORE_CAPITAL_BOTTOM } , /* Ꞔ */
    +    { 0xA7C5, AF_IGNORE_CAPITAL_BOTTOM } , /* Ʂ */
    +    { 0xA7C6, AF_IGNORE_CAPITAL_BOTTOM } , /* Ᶎ */
    +    { 0xA7CC, AF_IGNORE_CAPITAL_TOP | AF_IGNORE_CAPITAL_BOTTOM }, /* Ꟍ */
    +    { 0xA7CD, AF_IGNORE_SMALL_TOP | AF_IGNORE_SMALL_BOTTOM }, /* ꟍ */
    +
    +    /* Latin Extended-E */
    +    { 0xAB3C, AF_IGNORE_SMALL_BOTTOM } , /* ꬼ */
    +
    +    { 0xAB46, AF_IGNORE_SMALL_BOTTOM } , /* ꭆ */
    +
    +    { 0xAB5C, AF_IGNORE_SMALL_BOTTOM } , /* ꭜ */
    +
    +    { 0xAB66, AF_IGNORE_SMALL_BOTTOM } , /* ꭦ */
    +    { 0xAB67, AF_IGNORE_SMALL_BOTTOM } , /* ꭧ */
    +  };
    +
    +
    +  FT_LOCAL_DEF( FT_UInt32 )
    +  af_adjustment_database_lookup( FT_UInt32  codepoint )
    +  {
    +    /* Binary search for database entry */
    +    FT_Offset  low  = 0;
    +    FT_Offset  high = AF_ADJUSTMENT_DATABASE_LENGTH - 1;
    +
    +
    +    while ( high >= low )
    +    {
    +      FT_Offset  mid           = ( low + high ) / 2;
    +      FT_UInt32  mid_codepoint = adjustment_database[mid].codepoint;
    +
    +
    +      if ( mid_codepoint < codepoint )
    +        low = mid + 1;
    +      else if ( mid_codepoint > codepoint )
    +        high = mid - 1;
    +      else
    +        return adjustment_database[mid].flags;
    +    }
    +
    +    return 0;
    +  }
    +
    +
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +
    +  static FT_Error
    +  add_substitute( FT_Int     glyph_idx,
    +                  size_t     value,
    +                  FT_UInt32  codepoint,
    +                  FT_Hash    reverse_map,
    +                  FT_Hash    subst_map,
    +                  FT_Memory  memory )
    +  {
    +    FT_Error  error;
    +
    +    FT_Int  first_substitute = (FT_Int)( value & 0xFFFF );
    +
    +    FT_UInt  used = reverse_map->used;
    +
    +
    +    /*
    +      OpenType features like 'unic' map lowercase letter glyphs to uppercase
    +      forms (and vice versa), which could lead to the use of wrong entries
    +      in the adjustment database.  For this reason we don't overwrite,
    +      prioritizing cmap entries.
    +
    +      XXX Note, however, that this cannot cover all cases since there might
    +      be contradictory entries for glyphs not in the cmap.  A possible
    +      solution might be to specially mark pairs of related lowercase and
    +      uppercase characters in the adjustment database that have diacritics
    +      on different vertical sides (for example, U+0122 'Ģ' and U+0123 'ģ').
    +      The auto-hinter could then perform a topological analysis to do the
    +      right thing.
    +    */
    +    error = ft_hash_num_insert_no_overwrite( first_substitute, codepoint,
    +                                             reverse_map, memory );
    +    if ( error )
    +      return error;
    +
    +    if ( reverse_map->used > used )
    +    {
    +      size_t*  subst = ft_hash_num_lookup( first_substitute, subst_map );
    +
    +
    +      if ( subst )
    +      {
    +        error = add_substitute( first_substitute, *subst, codepoint,
    +                                reverse_map, subst_map, memory );
    +        if ( error )
    +          return error;
    +      }
    +    }
    +
    +    /* The remaining substitutes. */
    +    if ( value & 0xFFFF0000U )
    +    {
    +      FT_UInt  num_substitutes = value >> 16;
    +
    +      FT_UInt  i;
    +
    +
    +      for ( i = 1; i <= num_substitutes; i++ )
    +      {
    +        FT_Int   idx        = glyph_idx + (FT_Int)( i << 16 );
    +        size_t*  substitute = ft_hash_num_lookup( idx, subst_map );
    +
    +
    +        used = reverse_map->used;
    +
    +        error = ft_hash_num_insert_no_overwrite( *substitute,
    +                                                 codepoint,
    +                                                 reverse_map,
    +                                                 memory );
    +        if ( error )
    +          return error;
    +
    +        if ( reverse_map->used > used )
    +        {
    +          size_t*  subst = ft_hash_num_lookup( *substitute, subst_map );
    +
    +
    +          if ( subst )
    +          {
    +            error = add_substitute( *substitute, *subst, codepoint,
    +                                    reverse_map, subst_map, memory );
    +            if ( error )
    +              return error;
    +          }
    +        }
    +      }
    +    }
    +
    +    return FT_Err_Ok;
    +  }
    +
    +#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */
    +
    +
    +  /* Construct a 'reverse cmap' (i.e., a mapping from glyph indices to   */
    +  /* character codes) for all glyphs that an input code point could turn */
    +  /* into.                                                               */
    +  /*                                                                     */
    +  /* If HarfBuzz support is not available, this is the direct inversion  */
    +  /* of the cmap table, otherwise the mapping gets extended with data    */
    +  /* from the 'GSUB' table.                                              */
    +  FT_LOCAL_DEF( FT_Error )
    +  af_reverse_character_map_new( FT_Hash         *map,
    +                                AF_StyleMetrics  metrics )
    +  {
    +    FT_Error  error;
    +
    +    AF_FaceGlobals  globals = metrics->globals;
    +    FT_Face         face    = globals->face;
    +    FT_Memory       memory  = face->memory;
    +
    +    FT_CharMap  old_charmap;
    +
    +    FT_UInt32  codepoint;
    +    FT_Offset  i;
    +
    +
    +    FT_TRACE4(( "af_reverse_character_map_new:"
    +                " building reverse character map (style `%s')\n",
    +                af_style_names[metrics->style_class->style] ));
    +
    +    /* Search for a unicode charmap.           */
    +    /* If there isn't one, create a blank map. */
    +
    +    /* Back up `face->charmap` because `find_unicode_charmap` sets it. */
    +    old_charmap = face->charmap;
    +
    +    if ( ( error = find_unicode_charmap( face ) ) )
    +      goto Exit;
    +
    +    *map = NULL;
    +    if ( FT_QNEW( *map ) )
    +      goto Exit;
    +
    +    error = ft_hash_num_init( *map, memory );
    +    if ( error )
    +      goto Exit;
    +
    +    /* Initialize reverse cmap with data directly from the cmap table. */
    +    for ( i = 0; i < AF_ADJUSTMENT_DATABASE_LENGTH; i++ )
    +    {
    +      FT_Int  cmap_glyph;
    +
    +
    +      /*
    +        We cannot restrict `codepoint` to character ranges; we have no
    +        control what data the script-specific portion of the GSUB table
    +        actually holds.
    +
    +        An example is `arial.ttf` version 7.00; in this font, there are
    +        lookups for Cyrillic (lookup 43), Greek (lookup 44), and Latin
    +        (lookup 45) that map capital letter glyphs to small capital glyphs.
    +        It is tempting to expect that script-specific versions of the 'c2sc'
    +        feature only use script-specific lookups.  However, this is not the
    +        case in this font: the feature uses all three lookups regardless of
    +        the script.
    +
    +        The auto-hinter, while assigning glyphs to styles, uses the first
    +        coverage result it encounters for a particular glyph.  For example,
    +        if the coverage for Cyrillic is tested before Latin (as is currently
    +        the case), glyphs without a cmap entry that are covered in 'c2sc'
    +        are treated as Cyrillic.
    +
    +        If we now look at glyph 3498, which is a small-caps version of the
    +        Latin character 'A grave' (U+00C0, glyph 172), we can see that it is
    +        registered as belonging to a Cyrillic style due to the algorithm
    +        just described.  As a result, checking only for characters from the
    +        Latin range would miss this glyph; we thus have to test all
    +        character codes in the database.
    +      */
    +      codepoint = adjustment_database[i].codepoint;
    +
    +      cmap_glyph = (FT_Int)FT_Get_Char_Index( face, codepoint );
    +      if ( cmap_glyph == 0 )
    +        continue;
    +
    +      error = ft_hash_num_insert( cmap_glyph, codepoint, *map, memory );
    +      if ( error )
    +        goto Exit;
    +    }
    +
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +
    +    if ( ft_hb_enabled( globals ) )
    +    {
    +      hb_font_t  *hb_font;
    +      hb_face_t  *hb_face;
    +
    +      hb_set_t    *gsub_lookups;
    +      hb_script_t  script;
    +
    +      unsigned int  script_count   = 1;
    +      hb_tag_t      script_tags[2] = { HB_TAG_NONE, HB_TAG_NONE };
    +
    +      FT_Hash  subst_map = NULL;
    +
    +      hb_codepoint_t  idx;
    +      FT_UInt         hash_idx;
    +      FT_Int          glyph_idx;
    +      size_t          value;
    +
    +
    +      /* No need to check whether HarfBuzz has allocation issues; */
    +      /* it continues to work in such cases and simply returns    */
    +      /* 'empty' objects that do nothing.                         */
    +
    +      hb_font = globals->hb_font;
    +      hb_face = hb( font_get_face )( hb_font );
    +
    +      gsub_lookups = hb( set_create )();
    +
    +      script = af_hb_scripts[metrics->style_class->script];
    +
    +      hb( ot_tags_from_script_and_language )( script, NULL,
    +                                              &script_count, script_tags,
    +                                              NULL, NULL );
    +
    +      /* Compute set of all script-specific GSUB lookups. */
    +      hb( ot_layout_collect_lookups )( hb_face,
    +                                       HB_OT_TAG_GSUB,
    +                                       script_tags, NULL, NULL,
    +                                       gsub_lookups );
    +
    +#ifdef FT_DEBUG_LEVEL_TRACE
    +      {
    +        FT_Bool  have_idx = FALSE;
    +
    +
    +        FT_TRACE4(( "  GSUB lookups to check:\n" ));
    +
    +        FT_TRACE4(( "  " ));
    +        idx = HB_SET_VALUE_INVALID;
    +        while ( hb( set_next )( gsub_lookups, &idx ) )
    +          if ( idx < globals->gsub_lookup_count            &&
    +               globals->gsub_lookups_single_alternate[idx] )
    +          {
    +            have_idx = TRUE;
    +            FT_TRACE4(( "  %u", idx ));
    +          }
    +        if ( !have_idx )
    +          FT_TRACE4(( "  (none)" ));
    +        FT_TRACE4(( "\n" ));
    +
    +        FT_TRACE4(( "\n" ));
    +      }
    +#endif
    +
    +      if ( FT_QNEW( subst_map ) )
    +        goto Exit_HarfBuzz;
    +
    +      error = ft_hash_num_init( subst_map, memory );
    +      if ( error )
    +        goto Exit_HarfBuzz;
    +
    +      idx = HB_SET_VALUE_INVALID;
    +      while ( hb( set_next )( gsub_lookups, &idx ) )
    +      {
    +        FT_UInt32  offset;
    +
    +
    +        /* HarfBuzz only validates lookup indices while   */
    +        /* processing lookups, not while collecting them, */
    +        /* so we have to do that by ourselves.            */
    +        if ( idx < globals->gsub_lookup_count )
    +          offset = globals->gsub_lookups_single_alternate[idx];
    +        else
    +          offset = 0;
    +
    +        /* Put all substitutions into a single hash table.  Note that   */
    +        /* the hash values usually contain more than a single character */
    +        /* code; this can happen if different 'SingleSubst' subtables   */
    +        /* map a given glyph index to different substitutions, or if    */
    +        /* 'AlternateSubst' subtable entries are present.               */
    +        if ( offset )
    +          af_map_lookup( globals, subst_map, offset );
    +      }
    +
    +      /*
    +        Now iterate over the collected substitution data in `subst_map`
    +        (using recursion to resolve one-to-many mappings) and insert the
    +        data into the reverse cmap.
    +
    +        As an example, suppose we have the following cmap and substitution
    +        data:
    +
    +          cmap: X -> a
    +                Y -> b
    +                Z -> c
    +
    +          substitutions: a -> b
    +                         b -> c, d
    +                         d -> e
    +
    +        The reverse map now becomes as follows.
    +
    +          a -> X
    +          b -> Y
    +          c -> Z (via cmap, ignoring mapping from 'b')
    +          d -> Y (via 'b')
    +          e -> Y (via 'b' and 'd')
    +      */
    +
    +      hash_idx = 0;
    +      while ( ft_hash_num_iterator( &hash_idx,
    +                                    &glyph_idx,
    +                                    &value,
    +                                    subst_map ) )
    +      {
    +        size_t*  val;
    +
    +
    +        /* Ignore keys that do not point to the first substitute. */
    +        if ( (FT_UInt)glyph_idx & 0xFFFF0000U )
    +          continue;
    +
    +        /* Ignore glyph indices that are not related to accents. */
    +        val = ft_hash_num_lookup( glyph_idx, *map );
    +        if ( !val )
    +          continue;
    +
    +        codepoint = *val;
    +
    +        error = add_substitute( glyph_idx, value, codepoint,
    +                                *map, subst_map, memory );
    +        if ( error )
    +          break;
    +      }
    +
    +    Exit_HarfBuzz:
    +      hb( set_destroy )( gsub_lookups );
    +
    +      ft_hash_num_free( subst_map, memory );
    +      FT_FREE( subst_map );
    +
    +      if ( error )
    +        goto Exit;
    +    }
    +
    +#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */
    +
    +    FT_TRACE4(( "    reverse character map built successfully"
    +                " with %u entries\n", ( *map )->used ));
    +
    +#ifdef FT_DEBUG_LEVEL_TRACE
    +
    +    {
    +      FT_UInt  cnt;
    +
    +
    +      FT_TRACE7(( "       gidx   code    flags\n" ));
    +               /* "      XXXXX  0xXXXX  XXXXXXXXXXX..." */
    +      FT_TRACE7(( "     ------------------------------\n" ));
    +
    +      for ( cnt = 0; cnt < globals->glyph_count; cnt++ )
    +      {
    +        size_t*    val;
    +        FT_UInt32  adj_type;
    +
    +        const char*  flag_names[] =
    +        {
    +          "up",          /* AF_ADJUST_UP    */
    +          "down",        /* AF_ADJUST_DOWN  */
    +          "double up",   /* AF_ADJUST_UP2   */
    +          "double down", /* AF_ADJUST_DOWN2 */
    +
    +          "top tilde",          /* AF_ADJUST_TILDE_TOP     */
    +          "bottom tilde",       /* AF_ADJUST_TILDE_BOTTOM  */
    +          "below-top tilde",    /* AF_ADJUST_TILDE_TOP2    */
    +          "above-bottom tilde", /* AF_ADJUST_TILDE_BOTTOM2 */
    +
    +          "ignore capital top",    /* AF_IGNORE_CAPITAL_TOP    */
    +          "ignore capital bottom", /* AF_IGNORE_CAPITAL_BOTTOM */
    +          "ignore small top",      /* AF_IGNORE_SMALL_TOP      */
    +          "ignore small bottom",   /* AF_IGNORE_SMALL_BOTTOM   */
    +        };
    +        size_t  flag_names_size = sizeof ( flag_names ) / sizeof ( char* );
    +
    +        char  flag_str[256];
    +        int   need_comma;
    +
    +        size_t  j;
    +
    +
    +        val = ft_hash_num_lookup( (FT_Int)cnt, *map );
    +        if ( !val )
    +          continue;
    +        codepoint = *val;
    +
    +        adj_type = af_adjustment_database_lookup( codepoint );
    +        if ( !adj_type )
    +          continue;
    +
    +        flag_str[0] = '\0';
    +        need_comma  = 0;
    +
    +        for ( j = 0; j < flag_names_size; j++ )
    +        {
    +          if ( adj_type & (1 << j ) )
    +          {
    +            if ( !need_comma )
    +              need_comma = 1;
    +            else
    +              strcat( flag_str, ", " );
    +            strcat( flag_str, flag_names[j] );
    +          }
    +        }
    +
    +        FT_TRACE7(( "      %5u  0x%04X  %s\n", cnt, codepoint, flag_str ));
    +      }
    +    }
    +
    +#endif /* FT_DEBUG_LEVEL_TRACE */
    +
    +
    +  Exit:
    +    face->charmap = old_charmap;
    +
    +    if ( error )
    +    {
    +      FT_TRACE4(( "    error while building reverse character map."
    +                  " Using blank map.\n" ));
    +
    +      if ( *map )
    +        ft_hash_num_free( *map, memory );
    +
    +      FT_FREE( *map );
    +      *map = NULL;
    +      return error;
    +    }
    +
    +    return FT_Err_Ok;
    +  }
    +
    +
    +  FT_LOCAL_DEF( FT_Error )
    +  af_reverse_character_map_done( FT_Hash    map,
    +                                 FT_Memory  memory )
    +  {
    +    if ( map )
    +      ft_hash_num_free( map, memory );
    +    FT_FREE( map );
    +
    +    return FT_Err_Ok;
    +  }
    +
    +
    +/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.h b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.h
    new file mode 100644
    index 00000000000..4837451ae4c
    --- /dev/null
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.h
    @@ -0,0 +1,130 @@
    +/****************************************************************************
    + *
    + * afadjust.h
    + *
    + *   Auto-fitter routines to adjust components based on charcode (header).
    + *
    + * Copyright (C) 2023-2025 by
    + * David Turner, Robert Wilhelm, and Werner Lemberg.
    + *
    + * Written by Craig White .
    + *
    + * This file is part of the FreeType project, and may only be used,
    + * modified, and distributed under the terms of the FreeType project
    + * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    + * this file you indicate that you have read the license and
    + * understand and accept it fully.
    + *
    + */
    +
    +
    +#ifndef AFADJUST_H_
    +#define AFADJUST_H_
    +
    +#include 
    +
    +#include "afglobal.h"
    +#include "aftypes.h"
    +
    +
    +FT_BEGIN_HEADER
    +
    +  /*
    +   * Adjustment type flags.
    +   *
    +   * They also specify topological constraints that the auto-hinter relies
    +   * on.  For example, using `AF_ADJUST_UP` implies that we have two
    +   * enclosing contours, one for the base glyph and one for the diacritic
    +   * above, and no other contour inbetween or above.  With 'enclosing' it is
    +   * meant that such a contour can contain more inner contours.
    +   *
    +   */
    +
    +  /* Find the topmost contour and push it up until its lowest point is */
    +  /* one pixel above the highest point not enclosed by that contour.   */
    +#define AF_ADJUST_UP  0x01
    +
    +  /* Find the bottommost contour and push it down until its highest point */
    +  /* is one pixel below the lowest point not enclosed by that contour.    */
    +#define AF_ADJUST_DOWN  0x02
    +
    +  /* Find the contour below the topmost contour and push it up, together */
    +  /* with the topmost contour, until its lowest point is one pixel above */
    +  /* the highest point not enclosed by that contour.  This flag is       */
    +  /* mutually exclusive with `AF_ADJUST_UP`.                             */
    +#define AF_ADJUST_UP2  0x04
    +
    +  /* Find the contour above the bottommost contour and push it down,  */
    +  /* together with the bottommost contour, until its highest point is */
    +  /* one pixel below the lowest point not enclosed by that contour.   */
    +  /* This flag is mutually exclusive with `AF_ADJUST_DOWN`.           */
    +#define AF_ADJUST_DOWN2  0x08
    +
    +  /* The topmost contour is a tilde.  Enlarge it vertically so that it    */
    +  /* stays legible at small sizes, not degenerating to a horizontal line. */
    +#define AF_ADJUST_TILDE_TOP  0x10
    +
    +  /* The bottommost contour is a tilde.  Enlarge it vertically so that it */
    +  /* stays legible at small sizes, not degenerating to a horizontal line. */
    +#define AF_ADJUST_TILDE_BOTTOM  0x20
    +
    +  /* The contour below the topmost contour is a tilde.  Enlarge it        */
    +  /* vertically so that it stays legible at small sizes, not degenerating */
    +  /* to a horizontal line.  To be used with `AF_ADJUST_UP2` only.         */
    +#define AF_ADJUST_TILDE_TOP2  0x40
    +
    +  /* The contour above the bottommost contour is a tilde.  Enlarge it     */
    +  /* vertically so that it stays legible at small sizes, not degenerating */
    +  /* to a horizontal line.  To be used with `AF_ADJUST_DOWN2` only.       */
    +#define AF_ADJUST_TILDE_BOTTOM2  0x80
    +
    +  /* Make the auto-hinter ignore any diacritic (either a separate contour */
    +  /* or part of the base character outline) that is attached to the top   */
    +  /* of an uppercase base character.                                      */
    +#define AF_IGNORE_CAPITAL_TOP  0x100
    +
    +  /* Make the auto-hinter ignore any diacritic (either a separate contour */
    +  /* or part of the base character outline) that is attached to the       */
    +  /* bottom of an uppercase base character.                               */
    +#define AF_IGNORE_CAPITAL_BOTTOM  0x200
    +
    +  /* Make the auto-hinter ignore any diacritic (either a separate contour */
    +  /* or part of the base character outline) that is attached to the top   */
    +  /* of a lowercase base character.                                       */
    +#define AF_IGNORE_SMALL_TOP  0x400
    +
    +  /* Make the auto-hinter ignore any diacritic (either a separate contour */
    +  /* or part of the base character outline) that is attached to the       */
    +  /* bottom of a lowercase base character.                                */
    +#define AF_IGNORE_SMALL_BOTTOM  0x800
    +
    +  /* By default, the AF_ADJUST_XXX flags are applied only if diacritics */
    +  /* have a 'small' height (based on some heuristic checks).  If this   */
    +  /* flag is set, no such check is performed.                           */
    +#define AF_ADJUST_NO_HEIGHT_CHECK  0x1000
    +
    +  /* No adjustment, i.e., no flag is set. */
    +#define AF_ADJUST_NONE  0x00
    +
    +
    +  FT_LOCAL( FT_UInt32 )
    +  af_adjustment_database_lookup( FT_UInt32  codepoint );
    +
    +  /* Allocate and populate the reverse character map, */
    +  /* using the character map within the face.         */
    +  FT_LOCAL( FT_Error )
    +  af_reverse_character_map_new( FT_Hash         *map,
    +                                AF_StyleMetrics  metrics );
    +
    +  /* Free the reverse character map. */
    +  FT_LOCAL( FT_Error )
    +  af_reverse_character_map_done( FT_Hash    map,
    +                                 FT_Memory  memory );
    +
    +
    +FT_END_HEADER
    +
    +#endif /* AFADJUST_H_ */
    +
    +
    +/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
    index ea83969cdc9..a6219bdfe41 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c
    @@ -7,7 +7,7 @@
      *
      *   Auto-fitter data for blue strings (body).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -467,24 +467,24 @@
       af_blue_stringsets[] =
       {
         /* */
    -    { AF_BLUE_STRING_ADLAM_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0                                 },
    +    { AF_BLUE_STRING_ADLAM_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
         { AF_BLUE_STRING_ADLAM_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM,   0                                 },
    -    { AF_BLUE_STRING_MAX,                  0                                 },
    +                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_MAX,                  0                                     },
         { AF_BLUE_STRING_ARABIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP     },
         { AF_BLUE_STRING_ARABIC_BOTTOM, 0                              },
         { AF_BLUE_STRING_ARABIC_JOIN,   AF_BLUE_PROPERTY_LATIN_NEUTRAL },
         { AF_BLUE_STRING_MAX,           0                              },
    -    { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP        },
    +    { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_ARMENIAN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM,    0                                 },
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                      0                                 },
    +                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                      0                                     },
         { AF_BLUE_STRING_AVESTAN_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_AVESTAN_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,            0                          },
    @@ -508,14 +508,14 @@
         { AF_BLUE_STRING_CHAKMA_BOTTOM,    0                          },
         { AF_BLUE_STRING_CHAKMA_DESCENDER, 0                          },
         { AF_BLUE_STRING_MAX,              0                          },
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM,       0                                 },
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          },
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM,       0                                   },
         { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                      AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0                                 },
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_MAX,                             0                                 },
    +                                                      AF_BLUE_PROPERTY_LATIN_X_HEIGHT     },
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM },
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP,     AF_BLUE_PROPERTY_LATIN_TOP          },
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM,  0                                   },
    +    { AF_BLUE_STRING_MAX,                             0                                   },
         { AF_BLUE_STRING_CARIAN_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_CARIAN_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,           0                          },
    @@ -527,24 +527,24 @@
         { AF_BLUE_STRING_CHEROKEE_SMALL,           0                                 },
         { AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0                                 },
         { AF_BLUE_STRING_MAX,                      0                                 },
    -    { AF_BLUE_STRING_COPTIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0                                 },
    +    { AF_BLUE_STRING_COPTIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
         { AF_BLUE_STRING_COPTIC_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM,   0                                 },
    -    { AF_BLUE_STRING_MAX,                   0                                 },
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_MAX,                   0                                     },
         { AF_BLUE_STRING_CYPRIOT_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_CYPRIOT_BOTTOM, 0                          },
         { AF_BLUE_STRING_CYPRIOT_SMALL,  AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_CYPRIOT_SMALL,  0                          },
         { AF_BLUE_STRING_MAX,            0                          },
    -    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 },
    +    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
         { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 },
    -    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                      0                                 },
    +                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                     },
    +    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                      0                                     },
         { AF_BLUE_STRING_DEVANAGARI_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
         { AF_BLUE_STRING_DEVANAGARI_HEAD,   AF_BLUE_PROPERTY_LATIN_TOP        },
         { AF_BLUE_STRING_DEVANAGARI_BASE,   AF_BLUE_PROPERTY_LATIN_TOP      |
    @@ -553,12 +553,12 @@
         { AF_BLUE_STRING_DEVANAGARI_BASE,   0                                 },
         { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0                                 },
         { AF_BLUE_STRING_MAX,               0                                 },
    -    { AF_BLUE_STRING_DESERET_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0                                 },
    +    { AF_BLUE_STRING_DESERET_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
         { AF_BLUE_STRING_DESERET_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_DESERET_SMALL_BOTTOM,   0                                 },
    -    { AF_BLUE_STRING_MAX,                    0                                 },
    +                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_DESERET_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_MAX,                    0                                     },
         { AF_BLUE_STRING_ETHIOPIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,             0                          },
    @@ -578,23 +578,23 @@
         { AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP        },
         { AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0                                 },
         { AF_BLUE_STRING_MAX,                         0                                 },
    -    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0                                 },
    +    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
         { AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM,   0                                 },
    -    { AF_BLUE_STRING_MAX,                       0                                 },
    +                                                AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_MAX,                       0                                     },
         { AF_BLUE_STRING_GOTHIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_GOTHIC_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,           0                          },
    -    { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP        },
    +    { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_GREEK_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_GREEK_SMALL,           0                                 },
    -    { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                   0                                 },
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_GREEK_SMALL,           0                                     },
    +    { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                   0                                     },
         { AF_BLUE_STRING_GUJARATI_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
                                              AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
         { AF_BLUE_STRING_GUJARATI_BOTTOM,    0                                 },
    @@ -643,45 +643,45 @@
         { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP        },
         { AF_BLUE_STRING_LAO_DESCENDER,      0                                 },
         { AF_BLUE_STRING_MAX,                0                                 },
    -    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    +    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_LATIN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_LATIN_SMALL_BOTTOM,    0                                 },
    -    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                   0                                 },
    -    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_LATIN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                   0                                     },
    +    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_LATIN_SUBS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                 },
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                        0                                 },
    -    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    +                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                     },
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                        0                                     },
    +    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_LATIN_SUPS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                 },
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MAX,                        0                                 },
    +                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                     },
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MAX,                        0                                     },
         { AF_BLUE_STRING_LISU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_LISU_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,         0                          },
         { AF_BLUE_STRING_MALAYALAM_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,              0                          },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM,  0                                 },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            },
         { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                  AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM,    0                                 },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0                                 },
    -    { AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP,       AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_MAX,                         0                                 },
    +                                                  AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP,       AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_MAX,                         0                                     },
         { AF_BLUE_STRING_MONGOLIAN_TOP_BASE,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0                          },
         { AF_BLUE_STRING_MAX,                   0                          },
    @@ -691,12 +691,12 @@
         { AF_BLUE_STRING_MYANMAR_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP        },
         { AF_BLUE_STRING_MYANMAR_DESCENDER, 0                                 },
         { AF_BLUE_STRING_MAX,               0                                 },
    -    { AF_BLUE_STRING_NKO_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_NKO_BOTTOM,       0                                 },
    +    { AF_BLUE_STRING_NKO_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          },
    +    { AF_BLUE_STRING_NKO_BOTTOM,       0                                   },
         { AF_BLUE_STRING_NKO_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                       AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0                                 },
    -    { AF_BLUE_STRING_MAX,              0                                 },
    +                                       AF_BLUE_PROPERTY_LATIN_X_HEIGHT     },
    +    { AF_BLUE_STRING_NKO_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM },
    +    { AF_BLUE_STRING_MAX,              0                                   },
         { AF_BLUE_STRING_MAX, 0 },
         { AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_OL_CHIKI, 0                          },
    @@ -704,15 +704,15 @@
         { AF_BLUE_STRING_OLD_TURKIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,               0                          },
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP       },
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM,    0                                },
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0                                },
    -    { AF_BLUE_STRING_OSAGE_SMALL_TOP,         AF_BLUE_PROPERTY_LATIN_TOP     |
    -                                              AF_BLUE_PROPERTY_LATIN_X_HEIGHT  },
    -    { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM,      0                                },
    -    { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER,    AF_BLUE_PROPERTY_LATIN_TOP       },
    -    { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER,   0                                },
    -    { AF_BLUE_STRING_MAX,                     0                                },
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM },
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0                                     },
    +    { AF_BLUE_STRING_OSAGE_SMALL_TOP,         AF_BLUE_PROPERTY_LATIN_TOP      |
    +                                              AF_BLUE_PROPERTY_LATIN_X_HEIGHT       },
    +    { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM,      AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   },
    +    { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER,    AF_BLUE_PROPERTY_LATIN_TOP            },
    +    { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER,   0                                     },
    +    { AF_BLUE_STRING_MAX,                     0                                     },
         { AF_BLUE_STRING_OSMANYA_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_OSMANYA_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,            0                          },
    @@ -723,13 +723,13 @@
         { AF_BLUE_STRING_SAURASHTRA_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0                          },
         { AF_BLUE_STRING_MAX,               0                          },
    -    { AF_BLUE_STRING_SHAVIAN_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        },
    -    { AF_BLUE_STRING_SHAVIAN_BOTTOM,       0                                 },
    -    { AF_BLUE_STRING_SHAVIAN_DESCENDER,    0                                 },
    +    { AF_BLUE_STRING_SHAVIAN_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          },
    +    { AF_BLUE_STRING_SHAVIAN_BOTTOM,       0                                   },
    +    { AF_BLUE_STRING_SHAVIAN_DESCENDER,    0                                   },
         { AF_BLUE_STRING_SHAVIAN_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
    -    { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0                                 },
    -    { AF_BLUE_STRING_MAX,                  0                                 },
    +                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT     },
    +    { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM },
    +    { AF_BLUE_STRING_MAX,                  0                                   },
         { AF_BLUE_STRING_SINHALA_TOP,       AF_BLUE_PROPERTY_LATIN_TOP },
         { AF_BLUE_STRING_SINHALA_BOTTOM,    0                          },
         { AF_BLUE_STRING_SINHALA_DESCENDER, 0                          },
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
    index d2270fac744..786c6b3b9e6 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter data for blue strings (body).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
    index 88bab2632ab..f6e96ff8189 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat
    @@ -2,7 +2,7 @@
     //
     //   Auto-fitter data for blue strings.
     //
    -// Copyright (C) 2013-2024 by
    +// Copyright (C) 2013-2025 by
     // David Turner, Robert Wilhelm, and Werner Lemberg.
     //
     // This file is part of the FreeType project, and may only be used,
    @@ -699,12 +699,12 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
     AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
     
       AF_BLUE_STRINGSET_ADLM
    -    { AF_BLUE_STRING_ADLAM_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0                                 }
    +    { AF_BLUE_STRING_ADLAM_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
         { AF_BLUE_STRING_ADLAM_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM,   0                                 }
    -    { AF_BLUE_STRING_MAX,                  0                                 }
    +                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_MAX,                  0                                     }
     
       AF_BLUE_STRINGSET_ARAB
         { AF_BLUE_STRING_ARABIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP     }
    @@ -713,14 +713,14 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,           0                              }
     
       AF_BLUE_STRINGSET_ARMN
    -    { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER,  AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_ARMENIAN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM,    0                                 }
    -    { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                      0                                 }
    +                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                      0                                     }
     
       AF_BLUE_STRINGSET_AVST
         { AF_BLUE_STRING_AVESTAN_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -756,14 +756,14 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,              0                          }
     
       AF_BLUE_STRINGSET_CANS
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM,       0                                 }
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          }
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM,       0                                   }
         { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                      AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0                                 }
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_MAX,                             0                                 }
    +                                                      AF_BLUE_PROPERTY_LATIN_X_HEIGHT     }
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM }
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP,     AF_BLUE_PROPERTY_LATIN_TOP          }
    +    { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM,  0                                   }
    +    { AF_BLUE_STRING_MAX,                             0                                   }
     
       AF_BLUE_STRINGSET_CARI
         { AF_BLUE_STRING_CARIAN_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -781,12 +781,12 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,                      0                                 }
     
       AF_BLUE_STRINGSET_COPT
    -    { AF_BLUE_STRING_COPTIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0                                 }
    +    { AF_BLUE_STRING_COPTIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
         { AF_BLUE_STRING_COPTIC_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM,   0                                 }
    -    { AF_BLUE_STRING_MAX,                   0                                 }
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_MAX,                   0                                     }
     
       AF_BLUE_STRINGSET_CPRT
         { AF_BLUE_STRING_CYPRIOT_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -796,13 +796,13 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,            0                          }
     
       AF_BLUE_STRINGSET_CYRL
    -    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 }
    +    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
         { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 }
    -    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                      0                                 }
    +                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                     }
    +    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                      0                                     }
     
       AF_BLUE_STRINGSET_DEVA
         { AF_BLUE_STRING_DEVANAGARI_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    @@ -815,12 +815,12 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,               0                                 }
     
       AF_BLUE_STRINGSET_DSRT
    -    { AF_BLUE_STRING_DESERET_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0                                 }
    +    { AF_BLUE_STRING_DESERET_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
         { AF_BLUE_STRING_DESERET_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_DESERET_SMALL_BOTTOM,   0                                 }
    -    { AF_BLUE_STRING_MAX,                    0                                 }
    +                                             AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_DESERET_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_MAX,                    0                                     }
     
       AF_BLUE_STRINGSET_ETHI
         { AF_BLUE_STRING_ETHIOPIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -848,12 +848,12 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,                         0                                 }
     
       AF_BLUE_STRINGSET_GLAG
    -    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0                                 }
    +    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
         { AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP,      AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM,   0                                 }
    -    { AF_BLUE_STRING_MAX,                       0                                 }
    +                                                AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM,   AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_MAX,                       0                                     }
     
       AF_BLUE_STRINGSET_GOTH
         { AF_BLUE_STRING_GOTHIC_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -861,14 +861,14 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,           0                          }
     
       AF_BLUE_STRINGSET_GREK
    -    { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_GREEK_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_GREEK_SMALL,           0                                 }
    -    { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                   0                                 }
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_GREEK_SMALL,           0                                     }
    +    { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                   0                                     }
     
       AF_BLUE_STRINGSET_GUJR
         { AF_BLUE_STRING_GUJARATI_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    @@ -935,34 +935,34 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,                0                                 }
     
       AF_BLUE_STRINGSET_LATN
    -    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_LATIN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_LATIN_SMALL_BOTTOM,    0                                 }
    -    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                   0                                 }
    +                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_LATIN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                   0                                     }
     
       AF_BLUE_STRINGSET_LATB
    -    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_LATIN_SUBS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                 }
    -    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                        0                                 }
    +                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                     }
    +    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                        0                                     }
     
       AF_BLUE_STRINGSET_LATP
    -    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_LATIN_SUPS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                 }
    -    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MAX,                        0                                 }
    +                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                     }
    +    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MAX,                        0                                     }
     
       AF_BLUE_STRINGSET_LISU
         { AF_BLUE_STRING_LISU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -975,15 +975,15 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,              0                          }
     
       AF_BLUE_STRINGSET_MEDF
    -    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM,  0                                 }
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM,  AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP            }
         { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                                  AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM,    0                                 }
    -    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0                                 }
    -    { AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP,       AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_MAX,                         0                                 }
    +                                                  AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP,       AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_MAX,                         0                                     }
     
       AF_BLUE_STRINGSET_MONG
         { AF_BLUE_STRING_MONGOLIAN_TOP_BASE,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -999,12 +999,12 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,               0                                 }
     
       AF_BLUE_STRINGSET_NKOO
    -    { AF_BLUE_STRING_NKO_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_NKO_BOTTOM,       0                                 }
    +    { AF_BLUE_STRING_NKO_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          }
    +    { AF_BLUE_STRING_NKO_BOTTOM,       0                                   }
         { AF_BLUE_STRING_NKO_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                       AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0                                 }
    -    { AF_BLUE_STRING_MAX,              0                                 }
    +                                       AF_BLUE_PROPERTY_LATIN_X_HEIGHT     }
    +    { AF_BLUE_STRING_NKO_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM }
    +    { AF_BLUE_STRING_MAX,              0                                   }
     
       AF_BLUE_STRINGSET_NONE
         { AF_BLUE_STRING_MAX, 0 }
    @@ -1020,15 +1020,15 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,               0                          }
     
       AF_BLUE_STRINGSET_OSGE
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP       }
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM,    0                                }
    -    { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0                                }
    -    { AF_BLUE_STRING_OSAGE_SMALL_TOP,         AF_BLUE_PROPERTY_LATIN_TOP     |
    -                                              AF_BLUE_PROPERTY_LATIN_X_HEIGHT  }
    -    { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM,      0                                }
    -    { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER,    AF_BLUE_PROPERTY_LATIN_TOP       }
    -    { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER,   0                                }
    -    { AF_BLUE_STRING_MAX,                     0                                }
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_TOP,       AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM,    AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM }
    +    { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0                                     }
    +    { AF_BLUE_STRING_OSAGE_SMALL_TOP,         AF_BLUE_PROPERTY_LATIN_TOP      |
    +                                              AF_BLUE_PROPERTY_LATIN_X_HEIGHT       }
    +    { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM,      AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM   }
    +    { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER,    AF_BLUE_PROPERTY_LATIN_TOP            }
    +    { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER,   0                                     }
    +    { AF_BLUE_STRING_MAX,                     0                                     }
     
       AF_BLUE_STRINGSET_OSMA
         { AF_BLUE_STRING_OSMANYA_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
    @@ -1047,13 +1047,13 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
         { AF_BLUE_STRING_MAX,               0                          }
     
       AF_BLUE_STRINGSET_SHAW
    -    { AF_BLUE_STRING_SHAVIAN_TOP,          AF_BLUE_PROPERTY_LATIN_TOP        }
    -    { AF_BLUE_STRING_SHAVIAN_BOTTOM,       0                                 }
    -    { AF_BLUE_STRING_SHAVIAN_DESCENDER,    0                                 }
    +    { AF_BLUE_STRING_SHAVIAN_TOP,          AF_BLUE_PROPERTY_LATIN_TOP          }
    +    { AF_BLUE_STRING_SHAVIAN_BOTTOM,       0                                   }
    +    { AF_BLUE_STRING_SHAVIAN_DESCENDER,    0                                   }
         { AF_BLUE_STRING_SHAVIAN_SMALL_TOP,    AF_BLUE_PROPERTY_LATIN_TOP      |
    -                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
    -    { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0                                 }
    -    { AF_BLUE_STRING_MAX,                  0                                 }
    +                                           AF_BLUE_PROPERTY_LATIN_X_HEIGHT     }
    +    { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM }
    +    { AF_BLUE_STRING_MAX,                  0                                   }
     
       AF_BLUE_STRINGSET_SINH
         { AF_BLUE_STRING_SINHALA_TOP,       AF_BLUE_PROPERTY_LATIN_TOP }
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
    index 2aa9d0984ef..5bb8406dc2b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h
    @@ -7,7 +7,7 @@
      *
      *   Auto-fitter data for blue strings (specification).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -314,14 +314,17 @@ FT_BEGIN_HEADER
       /* Properties are specific to a writing system.  We assume that a given  */
       /* blue string can't be used in more than a single writing system, which */
       /* is a safe bet.                                                        */
    -#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1U << 0 )  /* must have value 1 */
    +#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1U << 0 )    /* must be value 1 */
     #define AF_BLUE_PROPERTY_LATIN_SUB_TOP   ( 1U << 1 )
     #define AF_BLUE_PROPERTY_LATIN_NEUTRAL   ( 1U << 2 )
     #define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1U << 3 )
     #define AF_BLUE_PROPERTY_LATIN_LONG      ( 1U << 4 )
     
    -#define AF_BLUE_PROPERTY_CJK_TOP    ( 1U << 0 )       /* must have value 1 */
    -#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1U << 1 )       /* must have value 2 */
    +#define AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM  ( 1U << 5 )
    +#define AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM    ( 1U << 6 )
    +
    +#define AF_BLUE_PROPERTY_CJK_TOP    ( 1U << 0 )         /* must be value 1 */
    +#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1U << 1 )         /* must be value 2 */
     #define AF_BLUE_PROPERTY_CJK_RIGHT  AF_BLUE_PROPERTY_CJK_TOP
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
    index 38031505a85..dbac14548d5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter data for blue strings (specification).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -99,14 +99,17 @@ FT_BEGIN_HEADER
       /* Properties are specific to a writing system.  We assume that a given  */
       /* blue string can't be used in more than a single writing system, which */
       /* is a safe bet.                                                        */
    -#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1U << 0 )  /* must have value 1 */
    +#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1U << 0 )    /* must be value 1 */
     #define AF_BLUE_PROPERTY_LATIN_SUB_TOP   ( 1U << 1 )
     #define AF_BLUE_PROPERTY_LATIN_NEUTRAL   ( 1U << 2 )
     #define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1U << 3 )
     #define AF_BLUE_PROPERTY_LATIN_LONG      ( 1U << 4 )
     
    -#define AF_BLUE_PROPERTY_CJK_TOP    ( 1U << 0 )       /* must have value 1 */
    -#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1U << 1 )       /* must have value 2 */
    +#define AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM  ( 1U << 5 )
    +#define AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM    ( 1U << 6 )
    +
    +#define AF_BLUE_PROPERTY_CJK_TOP    ( 1U << 0 )         /* must be value 1 */
    +#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1U << 1 )         /* must be value 2 */
     #define AF_BLUE_PROPERTY_CJK_RIGHT  AF_BLUE_PROPERTY_CJK_TOP
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
    index 869b60487c2..7086601838c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines for CJK writing system (body).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -90,12 +90,8 @@
     
           /* If HarfBuzz is not available, we need a pointer to a single */
           /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -      void*     shaper_buf;
    -#else
           FT_ULong  shaper_buf_;
           void*     shaper_buf = &shaper_buf_;
    -#endif
     
           const char*  p;
     
    @@ -105,9 +101,8 @@
     
           p = script_class->standard_charstring;
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -      shaper_buf = af_shaper_buf_create( face );
    -#endif
    +      if ( ft_hb_enabled( metrics->root.globals ) )
    +        shaper_buf = af_shaper_buf_create( metrics->root.globals );
     
           /* We check a list of standard characters.  The first match wins. */
     
    @@ -144,7 +139,7 @@
               break;
           }
     
    -      af_shaper_buf_destroy( face, shaper_buf );
    +      af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
           if ( !glyph_index )
             goto Exit;
    @@ -152,7 +147,7 @@
           if ( !glyph_index )
             goto Exit;
     
    -      FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
    +      FT_TRACE5(( "standard character: U+%04lX (glyph index %lu)\n",
                       ch, glyph_index ));
     
           error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
    @@ -297,12 +292,8 @@
     
         /* If HarfBuzz is not available, we need a pointer to a single */
         /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    void*     shaper_buf;
    -#else
         FT_ULong  shaper_buf_;
         void*     shaper_buf = &shaper_buf_;
    -#endif
     
     
         /* we walk over the blue character strings as specified in the   */
    @@ -313,9 +304,8 @@
         FT_TRACE5(( "==========================\n" ));
         FT_TRACE5(( "\n" ));
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    shaper_buf = af_shaper_buf_create( face );
    -#endif
    +    if ( ft_hb_enabled( metrics->root.globals ) )
    +      shaper_buf = af_shaper_buf_create( metrics->root.globals );
     
         for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
         {
    @@ -340,7 +330,7 @@
             };
     
     
    -        FT_TRACE5(( "blue zone %d (%s):\n",
    +        FT_TRACE5(( "blue zone %u (%s):\n",
                         axis->blue_count,
                         cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
                                       AF_CJK_IS_TOP_BLUE( bs )   ] ));
    @@ -553,7 +543,7 @@
     
         } /* end for loop */
     
    -    af_shaper_buf_destroy( face, shaper_buf );
    +    af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
         FT_TRACE5(( "\n" ));
     
    @@ -572,23 +562,20 @@
     
         /* If HarfBuzz is not available, we need a pointer to a single */
         /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    void*     shaper_buf;
    -#else
         FT_ULong  shaper_buf_;
         void*     shaper_buf = &shaper_buf_;
    -#endif
     
         /* in all supported charmaps, digits have character codes 0x30-0x39 */
         const char   digits[] = "0 1 2 3 4 5 6 7 8 9";
         const char*  p;
     
    +    FT_UNUSED( face );
    +
     
         p = digits;
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    shaper_buf = af_shaper_buf_create( face );
    -#endif
    +    if ( ft_hb_enabled( metrics->root.globals ) )
    +      shaper_buf = af_shaper_buf_create( metrics->root.globals );
     
         while ( *p )
         {
    @@ -624,7 +611,7 @@
           }
         }
     
    -    af_shaper_buf_destroy( face, shaper_buf );
    +    af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
         metrics->root.digits_have_same_width = same_width;
       }
    @@ -710,7 +697,7 @@
             FT_Pos  delta1, delta2;
     
     
    -        blue->ref.fit  = FT_PIX_ROUND( blue->ref.cur );
    +        blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
     
             /* shoot is under shoot for cjk */
             delta1 = FT_DivFix( blue->ref.fit, scale ) - blue->shoot.org;
    @@ -736,7 +723,7 @@
     
             blue->shoot.fit = blue->ref.fit - delta2;
     
    -        FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n",
    +        FT_TRACE5(( ">> active cjk blue zone %c%u[%ld/%ld]:\n",
                         ( dim == AF_DIMENSION_HORZ ) ? 'H' : 'V',
                         nn, blue->ref.org, blue->shoot.org ));
             FT_TRACE5(( "     ref:   cur=%.2f fit=%.2f\n",
    @@ -1378,7 +1365,7 @@
       }
     
     
    -  /* Initalize hinting engine. */
    +  /* Initialize hinting engine. */
     
       FT_LOCAL_DEF( FT_Error )
       af_cjk_hints_init( AF_GlyphHints    hints,
    @@ -2185,7 +2172,7 @@
       af_cjk_align_edge_points( AF_GlyphHints  hints,
                                 AF_Dimension   dim )
       {
    -    AF_AxisHints  axis       = & hints->axis[dim];
    +    AF_AxisHints  axis       = &hints->axis[dim];
         AF_Edge       edges      = axis->edges;
         AF_Edge       edge_limit = FT_OFFSET( edges, axis->num_edges );
         AF_Edge       edge;
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
    index bc5aaf12e6e..bd1b39358e0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines for CJK writing system (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h b/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
    index 7980cf2e979..b93bcd1a2c5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter coverages (specification only).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
    index ad667d2edc7..8613544f913 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c
    @@ -5,7 +5,7 @@
      *   Auto-fitter dummy routines to be used if no hinting should be
      *   performed (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
    index 613c2f88a38..78a79439d95 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h
    @@ -5,7 +5,7 @@
      *   Auto-fitter dummy routines to be used if no hinting should be
      *   performed (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h b/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
    index ae584ff06db..f3093fc90df 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h
    @@ -4,7 +4,7 @@
      *
      *   Autofitter error codes (specification only).
      *
    - * Copyright (C) 2005-2024 by
    + * Copyright (C) 2005-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
    index b7403fa65e1..e74d8141161 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter routines to compute global hinting values (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -22,6 +22,11 @@
     #include "afws-decl.h"
     #include 
     
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +#  include "afgsub.h"
    +#  include "ft-hb-ft.h"
    +#endif
    +
     
       /**************************************************************************
        *
    @@ -184,7 +189,7 @@
               if ( gindex != 0                                                &&
                    gindex < globals->glyph_count                              &&
                    ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
    -            gstyles[gindex] = ss;
    +            gstyles[gindex] = ss | AF_HAS_CMAP_ENTRY;
     
               for (;;)
               {
    @@ -195,7 +200,7 @@
     
                 if ( gindex < globals->glyph_count                              &&
                      ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
    -              gstyles[gindex] = ss;
    +              gstyles[gindex] = ss | AF_HAS_CMAP_ENTRY;
               }
             }
     
    @@ -301,7 +306,7 @@
               if ( !( count % 10 ) )
                 FT_TRACE4(( " " ));
     
    -          FT_TRACE4(( " %d", idx ));
    +          FT_TRACE4(( " %u", idx ));
               count++;
     
               if ( !( count % 10 ) )
    @@ -356,8 +361,21 @@
         globals->scale_down_factor         = 0;
     
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    globals->hb_font = hb_ft_font_create_( face, NULL );
    -    globals->hb_buf  = hb_buffer_create();
    +    if ( ft_hb_enabled ( globals ) )
    +    {
    +      globals->hb_font = ft_hb_ft_font_create( globals );
    +      globals->hb_buf  = hb( buffer_create )();
    +
    +      af_parse_gsub( globals );
    +    }
    +    else
    +    {
    +      globals->hb_font = NULL;
    +      globals->hb_buf  = NULL;
    +
    +      globals->gsub                          = NULL;
    +      globals->gsub_lookups_single_alternate = NULL;
    +    }
     #endif
     
         error = af_face_globals_compute_style_coverage( globals );
    @@ -405,8 +423,14 @@
           }
     
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -      hb_font_destroy( globals->hb_font );
    -      hb_buffer_destroy( globals->hb_buf );
    +      if ( ft_hb_enabled ( globals ) )
    +      {
    +        hb( font_destroy )( globals->hb_font );
    +        hb( buffer_destroy )( globals->hb_buf );
    +
    +        FT_FREE( globals->gsub );
    +        FT_FREE( globals->gsub_lookups_single_alternate );
    +      }
     #endif
     
           /* no need to free `globals->glyph_styles'; */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
    index ddb54c89b27..dc061159492 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h
    @@ -5,7 +5,7 @@
      *   Auto-fitter routines to compute global hinting values
      *   (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -73,15 +73,17 @@ FT_BEGIN_HEADER
       /* default script for OpenType; ignored if HarfBuzz isn't used */
     #define AF_SCRIPT_DEFAULT    AF_SCRIPT_LATN
     
    -  /* a bit mask for AF_DIGIT and AF_NONBASE */
    -#define AF_STYLE_MASK        0x3FFF
    +  /* a bit mask for AF_DIGIT, AF_NONBASE, and AF_HAS_CMAP_ENTRY */
    +#define AF_STYLE_MASK        0x1FFF
       /* an uncovered glyph      */
     #define AF_STYLE_UNASSIGNED  AF_STYLE_MASK
     
    -  /* if this flag is set, we have an ASCII digit   */
    +  /* if this flag is set, we have an ASCII digit */
     #define AF_DIGIT             0x8000U
       /* if this flag is set, we have a non-base character */
     #define AF_NONBASE           0x4000U
    +  /* if this flag is set, the glyph has a (direct) cmap entry */
    +#define AF_HAS_CMAP_ENTRY    0x2000U
     
       /* `increase-x-height' property */
     #define AF_PROP_INCREASE_X_HEIGHT_MIN  6
    @@ -111,6 +113,13 @@ FT_BEGIN_HEADER
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
         hb_font_t*       hb_font;
         hb_buffer_t*     hb_buf;           /* for feature comparison */
    +
    +    /* The GSUB table. */
    +    FT_Byte*         gsub;
    +    /* An array of lookup offsets (of `gsub_lookup_count` elements), */
    +    /* with only SingleSubst and AlternateSubst lookups non-NULL.    */
    +    FT_UShort        gsub_lookup_count;
    +    FT_UInt32*       gsub_lookups_single_alternate;
     #endif
     
         /* per-face auto-hinter properties */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
    index 96ffe343aa4..11faa655f62 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -840,6 +840,10 @@
     
         if ( hints->contours != hints->embedded.contours )
           FT_FREE( hints->contours );
    +    if ( hints->contour_y_minima != hints->embedded.contour_y_minima )
    +      FT_FREE( hints->contour_y_minima );
    +    if ( hints->contour_y_maxima != hints->embedded.contour_y_maxima )
    +      FT_FREE( hints->contour_y_maxima );
         hints->max_contours = 0;
         hints->num_contours = 0;
     
    @@ -896,19 +900,30 @@
         {
           if ( !hints->contours )
           {
    -        hints->contours     = hints->embedded.contours;
    +        hints->contours         = hints->embedded.contours;
    +        hints->contour_y_minima = hints->embedded.contour_y_minima;
    +        hints->contour_y_maxima = hints->embedded.contour_y_maxima;
    +
             hints->max_contours = AF_CONTOURS_EMBEDDED;
           }
         }
         else if ( new_max > old_max )
         {
           if ( hints->contours == hints->embedded.contours )
    -        hints->contours = NULL;
    +      {
    +        hints->contours         = NULL;
    +        hints->contour_y_minima = NULL;
    +        hints->contour_y_maxima = NULL;
    +      }
     
           new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
     
           if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
             goto Exit;
    +      if ( FT_RENEW_ARRAY( hints->contour_y_minima, old_max, new_max ) )
    +        goto Exit;
    +      if ( FT_RENEW_ARRAY( hints->contour_y_maxima, old_max, new_max ) )
    +        goto Exit;
     
           hints->max_contours = new_max;
         }
    @@ -1324,7 +1339,7 @@
       af_glyph_hints_align_edge_points( AF_GlyphHints  hints,
                                         AF_Dimension   dim )
       {
    -    AF_AxisHints  axis          = & hints->axis[dim];
    +    AF_AxisHints  axis          = &hints->axis[dim];
         AF_Segment    segments      = axis->segments;
         AF_Segment    segment_limit = FT_OFFSET( segments, axis->num_segments );
         AF_Segment    seg;
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
    index 76fe83006a5..46b3ed3366f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -222,6 +222,9 @@ FT_BEGIN_HEADER
       /* the distance to the next point is very small */
     #define AF_FLAG_NEAR  ( 1U << 5 )
     
    +  /* prevent the auto-hinter from adding such a point to a segment */
    +#define AF_FLAG_IGNORE  ( 1U << 6 )
    +
     
       /* edge hint flags */
     #define AF_EDGE_NORMAL  0
    @@ -229,6 +232,7 @@ FT_BEGIN_HEADER
     #define AF_EDGE_SERIF    ( 1U << 1 )
     #define AF_EDGE_DONE     ( 1U << 2 )
     #define AF_EDGE_NEUTRAL  ( 1U << 3 ) /* edge aligns to a neutral blue zone */
    +#define AF_EDGE_NO_BLUE  ( 1U << 4 ) /* do not align edge to blue zone     */
     
     
       typedef struct AF_PointRec_*    AF_Point;
    @@ -303,6 +307,7 @@ FT_BEGIN_HEADER
     
       } AF_EdgeRec;
     
    +
     #define AF_SEGMENTS_EMBEDDED  18   /* number of embedded segments   */
     #define AF_EDGES_EMBEDDED     12   /* number of embedded edges      */
     
    @@ -346,9 +351,11 @@ FT_BEGIN_HEADER
         FT_Int           num_points;    /* number of used points      */
         AF_Point         points;        /* points array               */
     
    -    FT_Int           max_contours;  /* number of allocated contours */
    -    FT_Int           num_contours;  /* number of used contours      */
    -    AF_Point*        contours;      /* contours array               */
    +    FT_Int           max_contours;     /* number of allocated contours    */
    +    FT_Int           num_contours;     /* number of used contours         */
    +    AF_Point*        contours;         /* contours array                  */
    +    FT_Pos*          contour_y_minima; /* array with y maxima of contours */
    +    FT_Pos*          contour_y_maxima; /* array with y minima of contours */
     
         AF_AxisHintsRec  axis[AF_DIMENSION_MAX];
     
    @@ -357,11 +364,13 @@ FT_BEGIN_HEADER
                                         /* implementations         */
         AF_StyleMetrics  metrics;
     
    -    /* Two arrays to avoid allocation penalty.            */
    +    /* Some arrays to avoid allocation penalty.           */
         /* The `embedded' structure must be the last element! */
         struct
         {
           AF_Point       contours[AF_CONTOURS_EMBEDDED];
    +      FT_Pos         contour_y_minima[AF_CONTOURS_EMBEDDED];
    +      FT_Pos         contour_y_maxima[AF_CONTOURS_EMBEDDED];
           AF_PointRec    points[AF_POINTS_EMBEDDED];
         } embedded;
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
    index c6d23efd86f..a2cd14f8817 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines for Indic writing system (body).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * Rahul Bhalerao , .
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
    index a7f73f25153..a2e825e9f86 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h
    @@ -5,7 +5,7 @@
      *   Auto-fitter hinting routines for Indic writing system
      *   (specification).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * Rahul Bhalerao , .
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
    index 89287f7ea5a..4a42d919474 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter hinting routines for latin writing system (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -22,6 +22,7 @@
     #include "afglobal.h"
     #include "aflatin.h"
     #include "aferrors.h"
    +#include "afadjust.h"
     
     
       /**************************************************************************
    @@ -81,12 +82,8 @@
     
           /* If HarfBuzz is not available, we need a pointer to a single */
           /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -      void*     shaper_buf;
    -#else
           FT_ULong  shaper_buf_;
           void*     shaper_buf = &shaper_buf_;
    -#endif
     
           const char*  p;
     
    @@ -97,9 +94,9 @@
     
           p = script_class->standard_charstring;
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -      shaper_buf = af_shaper_buf_create( face );
    -#endif
    +      if ( ft_hb_enabled ( metrics->root.globals ) )
    +        shaper_buf = af_shaper_buf_create( metrics->root.globals );
    +
           /*
            * We check a list of standard characters to catch features like
            * `c2sc' (small caps from caps) that don't contain lowercase letters
    @@ -140,7 +137,7 @@
               break;
           }
     
    -      af_shaper_buf_destroy( face, shaper_buf );
    +      af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
           if ( !glyph_index )
           {
    @@ -149,7 +146,7 @@
             goto Exit;
           }
     
    -      FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
    +      FT_TRACE5(( "standard character: U+%04lX (glyph index %lu)\n",
                       ch, glyph_index ));
     
           error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
    @@ -334,12 +331,8 @@
     
         /* If HarfBuzz is not available, we need a pointer to a single */
         /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    void*     shaper_buf;
    -#else
         FT_ULong  shaper_buf_;
         void*     shaper_buf = &shaper_buf_;
    -#endif
     
     
         /* we walk over the blue character strings as specified in the */
    @@ -349,9 +342,8 @@
         FT_TRACE5(( "============================\n" ));
         FT_TRACE5(( "\n" ));
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    shaper_buf = af_shaper_buf_create( face );
    -#endif
    +    if ( ft_hb_enabled ( metrics->root.globals ) )
    +      shaper_buf = af_shaper_buf_create( metrics->root.globals );
     
         for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
         {
    @@ -367,7 +359,7 @@
             FT_Bool  have_flag = 0;
     
     
    -        FT_TRACE5(( "blue zone %d", axis->blue_count ));
    +        FT_TRACE5(( "blue zone %u", axis->blue_count ));
     
             if ( bs->properties )
             {
    @@ -407,6 +399,20 @@
                 FT_TRACE5(( "long" ));
               }
     
    +          if ( AF_LATIN_IS_CAPITAL_BOTTOM_BLUE( bs ) )
    +          {
    +            if ( have_flag )
    +              FT_TRACE5(( ", " ));
    +            FT_TRACE5(( "capital bottom" ));
    +          }
    +
    +          if ( AF_LATIN_IS_SMALL_BOTTOM_BLUE( bs ) )
    +          {
    +            if ( have_flag )
    +              FT_TRACE5(( ", " ));
    +            FT_TRACE5(( "small bottom" ));
    +          }
    +
               FT_TRACE5(( ")" ));
             }
     
    @@ -454,9 +460,9 @@
             }
     
             if ( AF_LATIN_IS_TOP_BLUE( bs ) )
    -          best_y_extremum = FT_INT_MIN;
    +          best_y_extremum = FT_LONG_MIN;
             else
    -          best_y_extremum = FT_INT_MAX;
    +          best_y_extremum = FT_LONG_MAX;
     
             /* iterate over all glyph elements of the character cluster */
             /* and get the data of the `biggest' one                    */
    @@ -487,7 +493,7 @@
                 if ( num_idx == 1 )
                   FT_TRACE5(( "  U+%04lX contains no (usable) outlines\n", ch ));
                 else
    -              FT_TRACE5(( "  component %d of cluster starting with U+%04lX"
    +              FT_TRACE5(( "  component %u of cluster starting with U+%04lX"
                               " contains no (usable) outlines\n", i, ch ));
     #endif
                 continue;
    @@ -825,7 +831,7 @@
                 if ( num_idx == 1 )
                   FT_TRACE5(( "  U+%04lX: best_y = %5ld", ch, best_y ));
                 else
    -              FT_TRACE5(( "  component %d of cluster starting with U+%04lX:"
    +              FT_TRACE5(( "  component %u of cluster starting with U+%04lX:"
                               " best_y = %5ld", i, ch, best_y ));
     #endif
     
    @@ -879,8 +885,8 @@
     
             } /* end for loop */
     
    -        if ( !( best_y_extremum == FT_INT_MIN ||
    -                best_y_extremum == FT_INT_MAX ) )
    +        if ( !( best_y_extremum == FT_LONG_MIN ||
    +                best_y_extremum == FT_LONG_MAX ) )
             {
               if ( best_round )
                 rounds[num_rounds++] = best_y_extremum;
    @@ -959,6 +965,10 @@
             blue->flags |= AF_LATIN_BLUE_SUB_TOP;
           if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
             blue->flags |= AF_LATIN_BLUE_NEUTRAL;
    +      if ( AF_LATIN_IS_CAPITAL_BOTTOM_BLUE( bs ) )
    +        blue->flags |= AF_LATIN_BLUE_BOTTOM;
    +      if ( AF_LATIN_IS_SMALL_BOTTOM_BLUE( bs ) )
    +        blue->flags |= AF_LATIN_BLUE_BOTTOM_SMALL;
     
           /*
            * The following flag is used later to adjust the y and x scales
    @@ -973,7 +983,7 @@
     
         } /* end for loop */
     
    -    af_shaper_buf_destroy( face, shaper_buf );
    +    af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
         if ( axis->blue_count )
         {
    @@ -1070,23 +1080,20 @@
     
         /* If HarfBuzz is not available, we need a pointer to a single */
         /* unsigned long value.                                        */
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    void*     shaper_buf;
    -#else
         FT_ULong  shaper_buf_;
         void*     shaper_buf = &shaper_buf_;
    -#endif
     
         /* in all supported charmaps, digits have character codes 0x30-0x39 */
         const char   digits[] = "0 1 2 3 4 5 6 7 8 9";
         const char*  p;
     
    +    FT_UNUSED( face );
    +
     
         p = digits;
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -    shaper_buf = af_shaper_buf_create( face );
    -#endif
    +    if ( ft_hb_enabled ( metrics->root.globals ) )
    +      shaper_buf = af_shaper_buf_create( metrics->root.globals );
     
         while ( *p )
         {
    @@ -1122,7 +1129,7 @@
           }
         }
     
    -    af_shaper_buf_destroy( face, shaper_buf );
    +    af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
     
         metrics->root.digits_have_same_width = same_width;
       }
    @@ -1155,6 +1162,9 @@
           af_latin_metrics_check_digits( metrics, face );
         }
     
    +    af_reverse_character_map_new( &metrics->root.reverse_charmap,
    +                                  &metrics->root );
    +
       Exit:
         face->charmap = oldmap;
         return error;
    @@ -1263,7 +1273,7 @@
                   max_height = FT_MAX( max_height, -Axis->blues[nn].descender );
                 }
     
    -            dist  = FT_MulFix( max_height, new_scale - scale );
    +            dist = FT_MulFix( max_height, new_scale - scale );
     
                 if ( -128 < dist && dist < 128 )
                 {
    @@ -1466,13 +1476,13 @@
             AF_LatinBlue  blue = &axis->blues[nn];
     
     
    -        FT_TRACE5(( "  reference %d: %ld scaled to %.2f%s\n",
    +        FT_TRACE5(( "  reference %u: %ld scaled to %.2f%s\n",
                         nn,
                         blue->ref.org,
                         (double)blue->ref.fit / 64,
                         ( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? ""
                                                                : " (inactive)" ));
    -        FT_TRACE5(( "  overshoot %d: %ld scaled to %.2f%s\n",
    +        FT_TRACE5(( "  overshoot %u: %ld scaled to %.2f%s\n",
                         nn,
                         blue->shoot.org,
                         (double)blue->shoot.fit / 64,
    @@ -1484,6 +1494,17 @@
       }
     
     
    +  FT_CALLBACK_DEF( void )
    +  af_latin_metrics_done( AF_StyleMetrics  metrics_ )
    +  {
    +    AF_LatinMetrics  metrics = (AF_LatinMetrics)metrics_;
    +
    +
    +    af_reverse_character_map_done( metrics->root.reverse_charmap,
    +                                   metrics->root.globals->face->memory );
    +  }
    +
    +
       /* Scale global values in both directions. */
     
       FT_LOCAL_DEF( void )
    @@ -1617,7 +1638,8 @@
           FT_Pos     prev_max_on_coord = max_on_coord;
     
     
    -      if ( FT_ABS( last->out_dir )  == major_dir &&
    +      if ( !( point->flags & AF_FLAG_IGNORE )    &&
    +           FT_ABS( last->out_dir )  == major_dir &&
                FT_ABS( point->out_dir ) == major_dir )
           {
             /* we are already on an edge, try to locate its start */
    @@ -1676,13 +1698,17 @@
                   max_on_coord = v;
               }
     
    -          if ( point->out_dir != segment_dir || point == last )
    +          if ( point->flags & AF_FLAG_IGNORE ||
    +               point->out_dir != segment_dir ||
    +               point == last )
               {
                 /* check whether the new segment's start point is identical to */
                 /* the previous segment's end point; for example, this might   */
                 /* happen for spikes                                           */
     
    -            if ( !prev_segment || segment->first != prev_segment->last )
    +            if ( point->flags & AF_FLAG_IGNORE        ||
    +                 !prev_segment                        ||
    +                 segment->first != prev_segment->last )
                 {
                   /* points are different: we are just leaving an edge, thus */
                   /* record a new segment                                    */
    @@ -1842,7 +1868,8 @@
             /* if we are not on an edge, check whether the major direction */
             /* coincides with the current point's `out' direction, or      */
             /* whether we have a single-point contour                      */
    -        if ( !on_edge                                  &&
    +        if ( !( point->flags & AF_FLAG_IGNORE )        &&
    +             !on_edge                                  &&
                  ( FT_ABS( point->out_dir ) == major_dir ||
                    point == point->prev                  ) )
             {
    @@ -2521,6 +2548,9 @@
           FT_Pos    best_dist;                 /* initial threshold */
     
     
    +      if ( edge->flags & AF_EDGE_NO_BLUE )
    +        continue;
    +
           /* compute the initial threshold as a fraction of the EM size */
           /* (the value 40 is heuristic)                                */
           best_dist = FT_MulFix( metrics->units_per_em / 40, scale );
    @@ -2610,7 +2640,7 @@
       }
     
     
    -  /* Initalize hinting engine. */
    +  /* Initialize hinting engine. */
     
       static FT_Error
       af_latin_hints_init( AF_GlyphHints    hints,
    @@ -2737,6 +2767,1198 @@
       }
     
     
    +#undef  FT_COMPONENT
    +#define FT_COMPONENT  afadjust
    +
    +
    +  static void
    +  af_move_contour_vertically( AF_Point  contour,
    +                              FT_Int    movement )
    +  {
    +    AF_Point  point       = contour;
    +    AF_Point  first_point = point;
    +
    +
    +    if ( point )
    +    {
    +      do
    +      {
    +        point->y += movement;
    +        point     = point->next;
    +
    +      } while ( point != first_point );
    +    }
    +  }
    +
    +
    +  /* Move all contours higher than `limit` by `delta`. */
    +  static void
    +  af_move_contours_up( AF_GlyphHints  hints,
    +                       FT_Pos         limit,
    +                       FT_Pos         delta )
    +  {
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  min_y = hints->contour_y_minima[contour];
    +      FT_Pos  max_y = hints->contour_y_maxima[contour];
    +
    +
    +      if ( min_y < max_y &&
    +           min_y > limit )
    +        af_move_contour_vertically( hints->contours[contour],
    +                                    delta );
    +    }
    +  }
    +
    +
    +  static void
    +  af_move_contours_down( AF_GlyphHints  hints,
    +                         FT_Pos         limit,
    +                         FT_Pos         delta )
    +  {
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  min_y = hints->contour_y_minima[contour];
    +      FT_Pos  max_y = hints->contour_y_maxima[contour];
    +
    +
    +      if ( min_y < max_y &&
    +           max_y < limit )
    +        af_move_contour_vertically( hints->contours[contour],
    +                                    -delta );
    +    }
    +  }
    +
    +
    +  /* Compute vertical extrema of all contours and store them in the */
    +  /* `contour_y_minima` and `contour_y_maxima` arrays of `hints`.   */
    +  static void
    +  af_compute_vertical_extrema( AF_GlyphHints  hints )
    +  {
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  min_y = FT_LONG_MAX;
    +      FT_Pos  max_y = FT_LONG_MIN;
    +
    +      AF_Point  first_point = hints->contours[contour];
    +      AF_Point  point       = first_point;
    +
    +
    +      if ( !first_point || first_point->next->next == first_point )
    +        goto End_loop;
    +
    +      do
    +      {
    +        if ( point->y < min_y )
    +          min_y = point->y;
    +        if ( point->y > max_y )
    +          max_y = point->y;
    +
    +        point = point->next;
    +
    +      } while ( point != first_point );
    +
    +    End_loop:
    +      hints->contour_y_minima[contour] = min_y;
    +      hints->contour_y_maxima[contour] = max_y;
    +    }
    +  }
    +
    +
    +  static FT_Int
    +  af_find_highest_contour( AF_GlyphHints  hints )
    +  {
    +    FT_Int  highest_contour = 0;
    +    FT_Pos  highest_min_y   = FT_LONG_MAX;
    +    FT_Pos  highest_max_y   = FT_LONG_MIN;
    +
    +    FT_Int  contour;
    +
    +
    +    /* At this point we have one 'lower' (usually the base glyph)   */
    +    /* and one 'upper' object (usually the diacritic glyph).  If    */
    +    /* there are more contours, they must be enclosed within either */
    +    /* 'lower' or 'upper'.  To find this enclosing 'upper' contour  */
    +    /* it is thus sufficient to search for the contour with the     */
    +    /* highest y maximum value.                                     */
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  current_min_y = hints->contour_y_minima[contour];
    +      FT_Pos  current_max_y = hints->contour_y_maxima[contour];
    +
    +
    +      /* If we have two contours with the same maximum value, take */
    +      /* the one that has a smaller height.                        */
    +      if ( current_max_y > highest_max_y      ||
    +           ( current_max_y == highest_max_y &&
    +             current_min_y > highest_min_y  ) )
    +      {
    +        highest_min_y   = current_min_y;
    +        highest_max_y   = current_max_y;
    +        highest_contour = contour;
    +      }
    +    }
    +
    +    return highest_contour;
    +  }
    +
    +
    +  static FT_Int
    +  af_find_second_highest_contour( AF_GlyphHints  hints )
    +  {
    +    FT_Int  highest_contour;
    +    FT_Pos  highest_min_y;
    +
    +    FT_Int  second_highest_contour = 0;
    +    FT_Pos  second_highest_max_y   = FT_LONG_MIN;
    +
    +    FT_Int  contour;
    +
    +
    +    if ( hints->num_contours < 3 )
    +      return 0;
    +
    +    highest_contour = af_find_highest_contour( hints );
    +    highest_min_y   = hints->contour_y_minima[highest_contour];
    +
    +    /* Search the contour with the largest vertical maximum that has a */
    +    /* vertical minimum lower than the vertical minimum of the topmost */
    +    /* contour.                                                        */
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  current_min_y;
    +      FT_Pos  current_max_y;
    +
    +
    +      if ( contour == highest_contour )
    +        continue;
    +
    +      current_min_y = hints->contour_y_minima[contour];
    +      current_max_y = hints->contour_y_maxima[contour];
    +
    +      if ( current_max_y > second_highest_max_y &&
    +           current_min_y < highest_min_y        )
    +      {
    +        second_highest_max_y   = current_max_y;
    +        second_highest_contour = contour;
    +      }
    +    }
    +
    +    return second_highest_contour;
    +  }
    +
    +
    +  static FT_Int
    +  af_find_lowest_contour( AF_GlyphHints  hints )
    +  {
    +    FT_Int  lowest_contour = 0;
    +    FT_Pos  lowest_min_y   = FT_LONG_MAX;
    +    FT_Pos  lowest_max_y   = FT_LONG_MIN;
    +
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  current_min_y = hints->contour_y_minima[contour];
    +      FT_Pos  current_max_y = hints->contour_y_maxima[contour];
    +
    +
    +      if ( current_min_y < lowest_min_y      ||
    +           ( current_min_y == lowest_min_y &&
    +             current_max_y < lowest_max_y  ) )
    +      {
    +        lowest_min_y   = current_min_y;
    +        lowest_max_y   = current_max_y;
    +        lowest_contour = contour;
    +      }
    +    }
    +
    +    return lowest_contour;
    +  }
    +
    +
    +  static FT_Int
    +  af_find_second_lowest_contour( AF_GlyphHints  hints )
    +  {
    +    FT_Int  lowest_contour;
    +    FT_Pos  lowest_max_y;
    +
    +    FT_Int  second_lowest_contour = 0;
    +    FT_Pos  second_lowest_min_y   = FT_LONG_MAX;
    +
    +    FT_Int  contour;
    +
    +
    +    if ( hints->num_contours < 3 )
    +      return 0;
    +
    +    lowest_contour = af_find_lowest_contour( hints );
    +    lowest_max_y   = hints->contour_y_maxima[lowest_contour];
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  current_min_y;
    +      FT_Pos  current_max_y;
    +
    +
    +      if ( contour == lowest_contour )
    +        continue;
    +
    +      current_min_y = hints->contour_y_minima[contour];
    +      current_max_y = hints->contour_y_maxima[contour];
    +
    +      if ( current_min_y < second_lowest_min_y &&
    +           current_max_y > lowest_max_y        )
    +      {
    +        second_lowest_min_y   = current_min_y;
    +        second_lowest_contour = contour;
    +      }
    +    }
    +
    +    return second_lowest_contour;
    +  }
    +
    +
    +  /* While aligning edges to blue zones, make the auto-hinter */
    +  /* ignore the ones that are higher than `pos`.              */
    +  static void
    +  af_prevent_top_blue_alignment( AF_GlyphHints  hints,
    +                                 FT_Pos         pos )
    +  {
    +    AF_AxisHints  axis = &hints->axis[AF_DIMENSION_VERT];
    +
    +    AF_Edge  edges      = axis->edges;
    +    AF_Edge  edge_limit = FT_OFFSET( edges, axis->num_edges );
    +    AF_Edge  edge;
    +
    +
    +    for ( edge = edges; edge < edge_limit; edge++ )
    +      if ( edge->pos > pos )
    +        edge->flags |= AF_EDGE_NO_BLUE;
    +  }
    +
    +
    +  static void
    +  af_prevent_bottom_blue_alignment( AF_GlyphHints  hints,
    +                                    FT_Pos         pos )
    +  {
    +    AF_AxisHints  axis = &hints->axis[AF_DIMENSION_VERT];
    +
    +    AF_Edge  edges      = axis->edges;
    +    AF_Edge  edge_limit = FT_OFFSET( edges, axis->num_edges );
    +    AF_Edge  edge;
    +
    +
    +    for ( edge = edges; edge < edge_limit; edge++ )
    +      if ( edge->pos < pos )
    +        edge->flags |= AF_EDGE_NO_BLUE;
    +  }
    +
    +
    +  static void
    +  af_latin_get_base_glyph_blues( AF_GlyphHints  hints,
    +                                 FT_Bool        is_capital,
    +                                 AF_LatinBlue*  top,
    +                                 AF_LatinBlue*  bottom )
    +  {
    +    AF_LatinMetrics  metrics = (AF_LatinMetrics)hints->metrics;
    +    AF_LatinAxis     axis    = &metrics->axis[AF_DIMENSION_VERT];
    +
    +    FT_UInt  top_flag;
    +    FT_UInt  bottom_flag;
    +
    +    FT_UInt  i;
    +
    +
    +    top_flag  = is_capital ? AF_LATIN_BLUE_TOP
    +                           : AF_LATIN_BLUE_ADJUSTMENT;
    +    top_flag |= AF_LATIN_BLUE_ACTIVE;
    +
    +    for ( i = 0; i < axis->blue_count; i++ )
    +      if ( ( axis->blues[i].flags & top_flag ) == top_flag )
    +        break;
    +    if ( i < axis->blue_count )
    +      *top = &axis->blues[i];
    +
    +    bottom_flag  = is_capital ? AF_LATIN_BLUE_BOTTOM
    +                              : AF_LATIN_BLUE_BOTTOM_SMALL;
    +    bottom_flag |= AF_LATIN_BLUE_ACTIVE;
    +
    +    for ( i = 0; i < axis->blue_count; i++ )
    +      if ( ( axis->blues[i].flags & bottom_flag ) == bottom_flag )
    +        break;
    +    if ( i < axis->blue_count )
    +      *bottom = &axis->blues[i];
    +  }
    +
    +
    +  /* Make the auto-hinter ignore top blue zones while aligning edges. */
    +  /* This affects everything that is higher than a vertical position  */
    +  /* based on the lowercase or uppercase top and bottom blue zones    */
    +  /* (depending on `is_capital`).                                     */
    +  static void
    +  af_latin_ignore_top( AF_GlyphHints  hints,
    +                       AF_LatinBlue   top_blue,
    +                       AF_LatinBlue   bottom_blue )
    +  {
    +    FT_Pos  base_glyph_height;
    +    FT_Pos  limit;
    +
    +
    +    /* Ignore blue zones that are higher than a heuristic threshold     */
    +    /* (value 7 corresponds to approx. 14%, which should be sufficient  */
    +    /* to exceed the height of uppercase serifs.  We also add a quarter */
    +    /* of a pixel as a safety measure.                                  */
    +    base_glyph_height = top_blue->shoot.cur - bottom_blue->shoot.cur;
    +    limit             = top_blue->shoot.cur + base_glyph_height / 7 + 16;
    +
    +    af_prevent_top_blue_alignment( hints, limit );
    +  }
    +
    +
    +  static void
    +  af_latin_ignore_bottom( AF_GlyphHints  hints,
    +                          AF_LatinBlue   top_blue,
    +                          AF_LatinBlue   bottom_blue )
    +  {
    +    FT_Pos  base_glyph_height;
    +    FT_Pos  limit;
    +
    +
    +    base_glyph_height = top_blue->shoot.cur - bottom_blue->shoot.cur;
    +    limit             = bottom_blue->shoot.cur - base_glyph_height / 7 - 16;
    +
    +    af_prevent_bottom_blue_alignment( hints, limit );
    +  }
    +
    +
    +  static void
    +  af_touch_contour( AF_GlyphHints  hints,
    +                    FT_Int         contour )
    +  {
    +    AF_Point  first_point = hints->contours[contour];
    +    AF_Point  p           = first_point;
    +
    +
    +    do
    +    {
    +      p = p->next;
    +
    +      p->flags |= AF_FLAG_IGNORE;
    +      if ( !( p->flags & AF_FLAG_CONTROL ) )
    +        p->flags |= AF_FLAG_TOUCH_Y;
    +
    +    } while ( p != first_point );
    +  }
    +
    +
    +  static void
    +  af_touch_top_contours( AF_GlyphHints  hints,
    +                         FT_Int         limit_contour )
    +  {
    +    FT_Pos  limit = hints->contour_y_minima[limit_contour];
    +
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  min_y = hints->contour_y_minima[contour];
    +      FT_Pos  max_y = hints->contour_y_maxima[contour];
    +
    +
    +      if ( min_y < max_y  &&
    +           min_y >= limit )
    +        af_touch_contour( hints, contour );
    +    }
    +  }
    +
    +
    +  static void
    +  af_touch_bottom_contours( AF_GlyphHints  hints,
    +                            FT_Int         limit_contour )
    +  {
    +    FT_Pos  limit = hints->contour_y_minima[limit_contour];
    +
    +    FT_Int  contour;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      FT_Pos  min_y = hints->contour_y_minima[contour];
    +      FT_Pos  max_y = hints->contour_y_maxima[contour];
    +
    +
    +      if ( min_y < max_y  &&
    +           max_y <= limit )
    +        af_touch_contour( hints, contour );
    +    }
    +  }
    +
    +
    +  /* Stretch tilde vertically, if necessary, and return the height */
    +  /* difference between the original and the stretched outline.    */
    +  static FT_Pos
    +  af_latin_stretch_top_tilde( AF_GlyphHints  hints,
    +                              FT_Int         tilde_contour )
    +  {
    +    AF_Point  p           = hints->contours[tilde_contour];
    +    AF_Point  first_point = p;
    +
    +    FT_Pos  min_y = hints->contour_y_minima[tilde_contour];
    +    FT_Pos  max_y = hints->contour_y_maxima[tilde_contour];
    +
    +    FT_Pos   min_measurement   = FT_LONG_MAX;
    +    FT_Bool  measurement_taken = FALSE;
    +
    +    FT_Pos  height;
    +    FT_Pos  extremum_threshold;
    +    FT_Pos  target_height;
    +
    +
    +    if ( min_y == max_y )
    +      return 0;
    +
    +    FT_TRACE4(( "af_latin_stretch_top_tilde: min y: %ld, max y: %ld\n",
    +                min_y, max_y ));
    +
    +    height             = SUB_LONG( max_y, min_y );
    +    extremum_threshold = height / 8;    /* Value 8 is heuristic. */
    +
    +    /* Find points that are local vertical round extrema, and which   */
    +    /* do not coincide with the vertical extreme values (i.e., we     */
    +    /* search for the 'other' wiggles in the tilde), then measure the */
    +    /* distance to the vertical extreme values.  Try to find the one  */
    +    /* with the smallest distance.                                    */
    +    /*                                                                */
    +    /* The algorithm only works for tilde shapes that don't deviate   */
    +    /* from the standard shape too much.  In particular, the wiggles  */
    +    /* must be round extrema.                                         */
    +    do
    +    {
    +      p = p->next;
    +
    +      if ( !( p->flags & AF_FLAG_CONTROL )          &&
    +           p->prev->y == p->y && p->next->y == p->y &&
    +           p->y != min_y && p->y != max_y           &&
    +           p->prev->flags & AF_FLAG_CONTROL         &&
    +           p->next->flags & AF_FLAG_CONTROL         )
    +      {
    +        /* This point could be a candidate.  Find the next and previous */
    +        /* on-curve points, and make sure they are both either above or */
    +        /* below the point, then make the measurement.                  */
    +        AF_Point  prev_on = p->prev;
    +        AF_Point  next_on = p->next;
    +
    +        FT_Pos  measurement;
    +
    +
    +        while ( prev_on->flags & AF_FLAG_CONTROL )
    +          prev_on = prev_on->prev;
    +        while ( next_on->flags & AF_FLAG_CONTROL )
    +          next_on = next_on->next;
    +
    +        if ( next_on->y > p->y && prev_on->y > p->y )
    +          measurement = SUB_LONG( p->y, min_y );
    +        else if ( next_on->y < p->y && prev_on->y < p->y )
    +          measurement = SUB_LONG( max_y, p->y );
    +        else
    +          continue;
    +
    +        /* Ignore hits that are too near to a vertical extremum. */
    +        if ( measurement < extremum_threshold )
    +          continue;
    +
    +        if ( !measurement_taken || measurement < min_measurement )
    +        {
    +          measurement_taken = TRUE;
    +          min_measurement   = measurement;
    +        }
    +      }
    +
    +    } while ( p != first_point );
    +
    +    if ( !measurement_taken )
    +      min_measurement = 0;
    +
    +    FT_TRACE4(( "af_latin_stretch_top_tilde: min measurement %ld\n",
    +                min_measurement ));
    +
    +    /* To preserve the stretched shape we prevent that the tilde */
    +    /* gets auto-hinted; we do this for all contours equal or    */
    +    /* above the vertical minimum of `tilde_contour`.            */
    +    af_touch_top_contours( hints, tilde_contour );
    +
    +    /* XXX This is an important element of the algorithm; */
    +    /*     we need a description.                         */
    +    target_height = min_measurement + 64;
    +    if ( height >= target_height )
    +      return 0;
    +
    +    /* Do the scaling. */
    +    p = first_point;
    +    do
    +    {
    +      p    = p->next;
    +      /* We adjust the height of the diacritic only, which means */
    +      /* we are never dealing with (valid) large numbers and can */
    +      /* thus avoid `FT_MulFix`.                                 */
    +      p->y = ADD_LONG( MUL_LONG( SUB_LONG( p->y,
    +                                           min_y ),
    +                                 target_height ) / height,
    +                       min_y );
    +
    +    } while ( p != first_point );
    +
    +    return target_height - height;
    +  }
    +
    +
    +  static FT_Pos
    +  af_latin_stretch_bottom_tilde( AF_GlyphHints  hints,
    +                                 FT_Int         tilde_contour )
    +  {
    +    AF_Point  p           = hints->contours[tilde_contour];
    +    AF_Point  first_point = p;
    +
    +    FT_Pos  min_y = hints->contour_y_minima[tilde_contour];
    +    FT_Pos  max_y = hints->contour_y_maxima[tilde_contour];
    +
    +    FT_Pos   min_measurement   = FT_LONG_MAX;
    +    FT_Bool  measurement_taken = FALSE;
    +
    +    FT_Pos  height;
    +    FT_Pos  extremum_threshold;
    +    FT_Pos  target_height;
    +
    +
    +    if ( min_y == max_y )
    +      return 0;
    +
    +    FT_TRACE4(( "af_latin_stretch_bottom_tilde: min y: %ld, max y: %ld\n",
    +                min_y, max_y ));
    +
    +    height             = SUB_LONG( max_y, min_y );
    +    extremum_threshold = height / 8;
    +
    +    do
    +    {
    +      p = p->next;
    +
    +      if ( !( p->flags & AF_FLAG_CONTROL )          &&
    +           p->prev->y == p->y && p->next->y == p->y &&
    +           p->y != min_y && p->y != max_y           &&
    +           p->prev->flags & AF_FLAG_CONTROL         &&
    +           p->next->flags & AF_FLAG_CONTROL         )
    +      {
    +        AF_Point  prev_on = p->prev;
    +        AF_Point  next_on = p->next;
    +
    +        FT_Pos  measurement;
    +
    +
    +        while ( prev_on->flags & AF_FLAG_CONTROL )
    +          prev_on = prev_on->prev;
    +        while ( next_on->flags & AF_FLAG_CONTROL )
    +          next_on = next_on->next;
    +
    +        if ( next_on->y > p->y && prev_on->y > p->y )
    +          measurement = SUB_LONG( p->y, min_y );
    +        else if ( next_on->y < p->y && prev_on->y < p->y )
    +          measurement = SUB_LONG( max_y, p->y );
    +        else
    +          continue;
    +
    +        if ( measurement < extremum_threshold )
    +          continue;
    +
    +        if ( !measurement_taken || measurement < min_measurement )
    +        {
    +          measurement_taken = TRUE;
    +          min_measurement   = measurement;
    +        }
    +      }
    +
    +    } while ( p != first_point );
    +
    +    if ( !measurement_taken )
    +      min_measurement = 0;
    +
    +    FT_TRACE4(( "af_latin_stretch_bottom_tilde: min measurement %ld\n",
    +                min_measurement ));
    +
    +    af_touch_bottom_contours( hints, tilde_contour );
    +
    +    target_height = min_measurement + 64;
    +    if ( height >= target_height )
    +      return 0;
    +
    +    p = first_point;
    +    do
    +    {
    +      p    = p->next;
    +      p->y = ADD_LONG( MUL_LONG( SUB_LONG( p->y,
    +                                           max_y ),
    +                                 target_height ) / height,
    +                       max_y );
    +
    +    } while ( p != first_point );
    +
    +    return target_height - height;
    +  }
    +
    +
    +  /*
    +    As part of `af_latin_stretch_top_tilde`, normally all points in the
    +    tilde are marked as touched, so the existing grid fitting will leave the
    +    tilde misaligned with the grid.
    +
    +    This function moves the tilde contour down to be grid-fitted.  We assume
    +    that if moving the tilde down would cause it to touch or overlap another
    +    countour, the vertical adjustment step will fix it.
    +
    +    Because the vertical adjustment step comes after all other grid-fitting
    +    steps, the top edge of the contour under the tilde is usually aligned
    +    with a horizontal grid line.  The vertical gap enforced by the vertical
    +    adjustment is exactly one pixel, so if the top edge of the contour below
    +    the tilde is on a grid line, the resulting tilde contour will also be
    +    grid-aligned.
    +
    +    But in cases where the gap is already big enough so that the vertical
    +    adjustment does nothing, this function ensures that even without the
    +    intervention of the vertical adjustment step, the tilde will be
    +    grid-aligned.
    +
    +    Return the vertical alignment amount.
    +  */
    +  static FT_Pos
    +  af_latin_align_top_tilde( AF_GlyphHints  hints,
    +                            FT_Int         tilde_contour )
    +  {
    +    AF_Point  p           = hints->contours[tilde_contour];
    +    AF_Point  first_point = p;
    +
    +    FT_Pos  min_y = p->y;
    +    FT_Pos  max_y = p->y;
    +
    +    FT_Pos  min_y_rounded;
    +    FT_Pos  delta;
    +    FT_Pos  height;
    +
    +
    +    /* Find vertical extrema of the (now stretched) tilde contour. */
    +    do
    +    {
    +      p = p->next;
    +      if ( p->y < min_y )
    +        min_y = p->y;
    +      if ( p->y > max_y )
    +        max_y = p->y;
    +
    +    } while ( p != first_point );
    +
    +    /* Align bottom of the tilde to the grid. */
    +    min_y_rounded = FT_PIX_ROUND_LONG( min_y );
    +    delta         = SUB_LONG( min_y_rounded, min_y );
    +    height        = SUB_LONG( max_y, min_y );
    +
    +    /* If the tilde is less than 3 pixels tall, snap the center of it */
    +    /* to the grid instead of the bottom to improve readability.      */
    +    if ( height < 64 * 3 )
    +      delta += ( FT_PIX_ROUND( height ) - height ) / 2;
    +
    +    af_move_contour_vertically( first_point, delta );
    +
    +    return delta;
    +  }
    +
    +
    +  static FT_Pos
    +  af_latin_align_bottom_tilde( AF_GlyphHints  hints,
    +                               FT_Int         tilde_contour )
    +  {
    +    AF_Point  p           = hints->contours[tilde_contour];
    +    AF_Point  first_point = p;
    +
    +    FT_Pos  min_y = p->y;
    +    FT_Pos  max_y = p->y;
    +
    +    FT_Pos  max_y_rounded;
    +    FT_Pos  delta;
    +    FT_Pos  height;
    +
    +
    +    do
    +    {
    +      p = p->next;
    +      if ( p->y < min_y )
    +        min_y = p->y;
    +      if ( p->y > max_y )
    +        max_y = p->y;
    +
    +    } while ( p != first_point );
    +
    +    max_y_rounded = FT_PIX_ROUND_LONG( max_y );
    +    delta         = SUB_LONG( max_y_rounded, max_y );
    +    height        = SUB_LONG( max_y, min_y );
    +
    +    if ( height < 64 * 3 )
    +      delta -= ( FT_PIX_ROUND( height ) - height ) / 2;
    +
    +    af_move_contour_vertically( first_point, delta );
    +
    +    return delta;
    +  }
    +
    +
    +  /* Return 1 if the given contour overlaps horizontally with the bounding */
    +  /* box of all other contours combined.  This is a helper for function    */
    +  /* `af_glyph_hints_apply_vertical_separation_adjustments`.               */
    +  static FT_Bool
    +  af_check_contour_horizontal_overlap( AF_GlyphHints  hints,
    +                                       FT_Int         contour_index )
    +  {
    +    FT_Pos  contour_max_x = FT_LONG_MIN;
    +    FT_Pos  contour_min_x = FT_LONG_MAX;
    +    FT_Pos  others_max_x  = FT_LONG_MIN;
    +    FT_Pos  others_min_x  = FT_LONG_MAX;
    +
    +    FT_Int  contour;
    +
    +    FT_Bool  horizontal_overlap;
    +
    +
    +    for ( contour = 0; contour < hints->num_contours; contour++ )
    +    {
    +      AF_Point  first_point = hints->contours[contour];
    +      AF_Point  p           = first_point;
    +
    +
    +      /* Ignore dimensionless contours (i.e., contours with only one or */
    +      /* two points).                                                   */
    +      if ( first_point->next->next == first_point )
    +        continue;
    +
    +      do
    +      {
    +        p = p->next;
    +
    +        if ( contour == contour_index )
    +        {
    +          if ( p->x < contour_min_x )
    +            contour_min_x = p->x;
    +          if ( p->x > contour_max_x )
    +            contour_max_x = p->x;
    +        }
    +        else
    +        {
    +          if ( p->x < others_min_x )
    +            others_min_x = p->x;
    +          if ( p->x > others_max_x )
    +            others_max_x = p->x;
    +        }
    +      } while ( p != first_point );
    +    }
    +
    +    horizontal_overlap =
    +      ( others_min_x <= contour_max_x && contour_max_x <= others_max_x ) ||
    +      ( others_min_x <= contour_min_x && contour_min_x <= others_max_x ) ||
    +      ( contour_max_x >= others_max_x && contour_min_x <= others_min_x );
    +
    +    return horizontal_overlap;
    +  }
    +
    +
    +  static void
    +  af_glyph_hints_apply_vertical_separation_adjustments(
    +    AF_GlyphHints  hints,
    +    AF_Dimension   dim,
    +    FT_UInt        glyph_index,
    +    FT_Pos         accent_height_limit,
    +    FT_Hash        reverse_charmap )
    +  {
    +    FT_Bool  adjust_top       = FALSE;
    +    FT_Bool  adjust_below_top = FALSE;
    +
    +    FT_Bool  adjust_bottom       = FALSE;
    +    FT_Bool  adjust_above_bottom = FALSE;
    +
    +    size_t*    val;
    +    FT_UInt32  adj_type = AF_ADJUST_NONE;
    +
    +
    +    FT_TRACE4(( "Entering"
    +                " af_glyph_hints_apply_vertical_separation_adjustments\n" ));
    +
    +    if ( dim != AF_DIMENSION_VERT )
    +      return;
    +
    +    val = ft_hash_num_lookup( (FT_Int)glyph_index, reverse_charmap );
    +    if ( val )
    +    {
    +      FT_UInt  codepoint = *val;
    +
    +
    +      adj_type = af_adjustment_database_lookup( codepoint );
    +
    +      if ( adj_type )
    +      {
    +        adjust_top       = !!( adj_type & AF_ADJUST_UP );
    +        adjust_below_top = !!( adj_type & AF_ADJUST_UP2 );
    +
    +        adjust_bottom       = !!( adj_type & AF_ADJUST_DOWN );
    +        adjust_above_bottom = !!( adj_type & AF_ADJUST_DOWN2 );
    +      }
    +    }
    +
    +    if ( ( ( adjust_top || adjust_bottom ) &&
    +           hints->num_contours >= 2        )             ||
    +         ( ( adjust_below_top || adjust_above_bottom ) &&
    +           hints->num_contours >= 3                    ) )
    +    {
    +      /* Recompute vertical extrema, this time acting on already */
    +      /* auto-hinted outlines.                                   */
    +      af_compute_vertical_extrema( hints );
    +    }
    +
    +    if ( ( adjust_top && hints->num_contours >= 2 )       ||
    +         ( adjust_below_top && hints->num_contours >= 3 ) )
    +    {
    +      FT_Int  high_contour;
    +      FT_Pos  high_min_y;
    +      FT_Pos  high_max_y;
    +      FT_Pos  high_height;
    +
    +      FT_Int  tilde_contour;
    +      FT_Pos  tilde_min_y;
    +      FT_Pos  tilde_max_y;
    +      FT_Pos  tilde_height;
    +
    +      FT_Int   contour;
    +      FT_Bool  horizontal_overlap;
    +
    +      FT_Pos  min_distance         = 64;
    +      FT_Pos  adjustment_amount;
    +      FT_Pos  calculated_amount;
    +      FT_Pos  centering_adjustment = 0;
    +      FT_Pos  pos;
    +
    +      FT_Bool  is_top_tilde       = !!( adj_type & AF_ADJUST_TILDE_TOP );
    +      FT_Bool  is_below_top_tilde = !!( adj_type & AF_ADJUST_TILDE_TOP2 );
    +
    +
    +      FT_TRACE4(( "af_glyph_hints_apply_vertical_separation_adjustments:\n"
    +                  "  Applying vertical adjustment: %s\n",
    +                  adjust_top ? "AF_ADJUST_TOP" : "AF_ADJUST_TOP2" ));
    +
    +      high_contour = adjust_below_top
    +                       ? af_find_second_highest_contour( hints )
    +                       : af_find_highest_contour( hints );
    +
    +      /* Check for a horizontal overlap between the high contour and the */
    +      /* rest.  If there is no overlap, do not adjust.                   */
    +      horizontal_overlap =
    +        af_check_contour_horizontal_overlap( hints, high_contour );
    +      if ( !horizontal_overlap )
    +      {
    +        FT_TRACE4(( "    High contour does not horizontally overlap"
    +                    " with other contours.\n"
    +                    "    Skipping adjustment.\n" ));
    +        return;
    +      }
    +
    +      high_min_y  = hints->contour_y_minima[high_contour];
    +      high_max_y  = hints->contour_y_maxima[high_contour];
    +      high_height = SUB_LONG( high_max_y, high_min_y );
    +
    +      if ( high_height > accent_height_limit )
    +      {
    +        FT_TRACE4(( "    High contour height (%.2f) exceeds accent height"
    +                    " limit (%.2f).\n"
    +                    "    Skipping adjustment.\n",
    +                    (double)high_height / 64,
    +                    (double)accent_height_limit / 64 ));
    +        return;
    +      }
    +
    +      /* If the difference between the vertical minimum of the high   */
    +      /* contour and the vertical maximum of another contour is less  */
    +      /* than a pixel, shift up the high contour to make the distance */
    +      /* one pixel.                                                   */
    +      for ( contour = 0; contour < hints->num_contours; contour++ )
    +      {
    +        FT_Pos  min_y;
    +        FT_Pos  max_y;
    +        FT_Pos  distance;
    +
    +
    +        if ( contour == high_contour )
    +          continue;
    +
    +        min_y = hints->contour_y_minima[contour];
    +        max_y = hints->contour_y_maxima[contour];
    +
    +        /* We also check that the y minimum of the 'other' contour */
    +        /* is below the high contour to avoid potential false hits */
    +        /* with contours enclosed in the high one.                 */
    +        distance = SUB_LONG( high_min_y, max_y );
    +        if ( distance < 64           &&
    +             distance < min_distance &&
    +             min_y < high_min_y      )
    +          min_distance = distance;
    +      }
    +
    +      adjustment_amount = 64 - min_distance;
    +
    +      if ( is_top_tilde || is_below_top_tilde )
    +      {
    +        tilde_contour = adjust_top
    +                          ? high_contour
    +                          : ( is_below_top_tilde
    +                                ? high_contour
    +                                : af_find_highest_contour( hints ) );
    +
    +        tilde_min_y  = hints->contour_y_minima[tilde_contour];
    +        tilde_max_y  = hints->contour_y_maxima[tilde_contour];
    +        tilde_height = SUB_LONG( tilde_max_y, tilde_min_y);
    +
    +        /* The vertical separation adjustment potentially undoes a */
    +        /* tilde center alignment.  If it would grid-align a tilde */
    +        /* less than 3 pixels in height, shift additionally to     */
    +        /* re-center the tilde.                                    */
    +
    +        pos = ADD_LONG( high_min_y, adjustment_amount );
    +        if ( adjust_below_top && is_top_tilde )
    +          pos += high_height;
    +
    +        if ( pos % 64 == 0 && tilde_height < 3 * 64 )
    +        {
    +          centering_adjustment = ( FT_PIX_ROUND( tilde_height ) -
    +                                   tilde_height ) / 2;
    +
    +          FT_TRACE4(( "    Additional tilde centering adjustment: %ld\n",
    +                      centering_adjustment ));
    +        }
    +      }
    +
    +      if ( ( adjust_top && is_top_tilde )             ||
    +           ( adjust_below_top && is_below_top_tilde ) )
    +        calculated_amount = adjustment_amount + centering_adjustment;
    +      else
    +        calculated_amount = adjustment_amount;
    +
    +      /* allow a delta of 2/64px to handle rounding differences */
    +      FT_TRACE4(( "    Calculated adjustment amount: %ld%s\n",
    +                  calculated_amount,
    +                  ( calculated_amount < -2                               ||
    +                    ( adjustment_amount > 66 && calculated_amount > 66 ) )
    +                      ? " (out of range [-2;66], not adjusting)" : "" ));
    +
    +      if ( calculated_amount != 0                                 &&
    +           calculated_amount >= -2                                &&
    +           ( calculated_amount <= 66 || adjustment_amount <= 66 ) )
    +      {
    +        /* Value 8 is heuristic. */
    +        FT_Pos  height_delta = high_height / 8;
    +        FT_Pos  min_y_limit  = SUB_LONG( high_min_y, height_delta );
    +
    +
    +        FT_TRACE4(( "    Pushing high contour %ld units up\n",
    +                    calculated_amount ));
    +
    +        /* While we use only a single contour (the 'high' one) for    */
    +        /* computing `adjustment_amount`, we apply it to all contours */
    +        /* that are (approximately) in the same vertical range or     */
    +        /* higher.  This covers, for example, the inner contour of    */
    +        /* the Czech ring accent or the second acute accent in the    */
    +        /* Hungarian double acute accent.                             */
    +        af_move_contours_up( hints, min_y_limit, adjustment_amount );
    +
    +        if ( adjust_below_top && is_top_tilde )
    +        {
    +          FT_TRACE4(( "    Pushing top tilde %ld units up\n",
    +                      centering_adjustment ));
    +
    +          af_move_contours_up( hints,
    +                               ADD_LONG( min_y_limit, high_height ),
    +                               centering_adjustment );
    +        }
    +      }
    +    }
    +
    +    if ( ( adjust_bottom && hints->num_contours >= 2 )       ||
    +         ( adjust_above_bottom && hints->num_contours >= 3 ) )
    +    {
    +      FT_Int  low_contour;
    +      FT_Pos  low_min_y;
    +      FT_Pos  low_max_y;
    +      FT_Pos  low_height;
    +
    +      FT_Int  tilde_contour;
    +      FT_Pos  tilde_min_y;
    +      FT_Pos  tilde_max_y;
    +      FT_Pos  tilde_height;
    +
    +      FT_Int   contour;
    +      FT_Bool  horizontal_overlap;
    +
    +      FT_Pos  min_distance         = 64;
    +      FT_Pos  adjustment_amount;
    +      FT_Pos  calculated_amount;
    +      FT_Pos  centering_adjustment = 0;
    +      FT_Pos  pos;
    +
    +      FT_Bool  is_bottom_tilde =
    +                 !!( adj_type & AF_ADJUST_TILDE_BOTTOM );
    +      FT_Bool  is_above_bottom_tilde =
    +                 !!( adj_type & AF_ADJUST_TILDE_BOTTOM2 );
    +
    +
    +      FT_TRACE4(( "af_glyph_hints_apply_vertical_separation_adjustments:\n"
    +                  "  Applying vertical adjustment: %s\n",
    +                  adjust_bottom ? "AF_ADJUST_DOWN": "AF_ADJUST_DOWN2" ));
    +
    +      low_contour = adjust_above_bottom
    +                      ? af_find_second_lowest_contour( hints )
    +                      : af_find_lowest_contour( hints );
    +
    +      horizontal_overlap =
    +        af_check_contour_horizontal_overlap( hints, low_contour );
    +      if ( !horizontal_overlap )
    +      {
    +        FT_TRACE4(( "    Low contour does not horizontally overlap"
    +                    " with other contours.\n"
    +                    "    Skipping adjustment.\n" ));
    +        return;
    +      }
    +
    +      low_min_y  = hints->contour_y_minima[low_contour];
    +      low_max_y  = hints->contour_y_maxima[low_contour];
    +      low_height = SUB_LONG( low_max_y, low_min_y );
    +
    +      if ( low_height > accent_height_limit )
    +      {
    +        FT_TRACE4(( "    Low contour height (%.2f) exceeds accent height"
    +                    " limit (%.2f).\n"
    +                    "    Skipping adjustment.\n",
    +                    (double)low_height / 64,
    +                    (double)accent_height_limit / 64 ));
    +        return;
    +      }
    +
    +      for ( contour = 0; contour < hints->num_contours; contour++ )
    +      {
    +        FT_Pos  min_y;
    +        FT_Pos  max_y;
    +        FT_Pos  distance;
    +
    +
    +        if ( contour == low_contour )
    +          continue;
    +
    +        min_y = hints->contour_y_minima[contour];
    +        max_y = hints->contour_y_maxima[contour];
    +
    +        distance = SUB_LONG( min_y, low_max_y );
    +        if ( distance < 64           &&
    +             distance < min_distance &&
    +             max_y > low_max_y       )
    +          min_distance = distance;
    +      }
    +
    +      adjustment_amount = 64 - min_distance;
    +
    +      if ( is_bottom_tilde || is_above_bottom_tilde )
    +      {
    +        tilde_contour = adjust_bottom
    +                          ? low_contour
    +                          : ( is_above_bottom_tilde
    +                                ? low_contour
    +                                : af_find_lowest_contour( hints ) );
    +
    +        tilde_min_y  = hints->contour_y_minima[tilde_contour];
    +        tilde_max_y  = hints->contour_y_maxima[tilde_contour];
    +        tilde_height = SUB_LONG( tilde_max_y, tilde_min_y );
    +
    +        pos = SUB_LONG( low_max_y, adjustment_amount );
    +        if ( adjust_above_bottom && is_bottom_tilde )
    +          pos -= low_height;
    +
    +        if ( pos % 64 == 0 && tilde_height < 3 * 64 )
    +        {
    +          centering_adjustment = ( FT_PIX_ROUND( tilde_height ) -
    +                                   tilde_height ) / 2;
    +
    +          FT_TRACE4(( "    Additional tilde centering adjustment: %ld\n",
    +                      centering_adjustment ));
    +        }
    +      }
    +
    +      if ( ( adjust_bottom && is_bottom_tilde )             ||
    +           ( adjust_above_bottom && is_above_bottom_tilde ) )
    +        calculated_amount = adjustment_amount + centering_adjustment;
    +      else
    +        calculated_amount = adjustment_amount;
    +
    +      FT_TRACE4(( "    Calculated adjustment amount: %ld%s\n",
    +                  calculated_amount,
    +                  ( calculated_amount < -2                               ||
    +                    ( adjustment_amount > 66 && calculated_amount > 66 ) )
    +                      ? " (out of range [-2;66], not adjusting)" : "" ));
    +
    +      if ( calculated_amount != 0                                 &&
    +           calculated_amount >= -2                                &&
    +           ( calculated_amount <= 66 || adjustment_amount <= 66 ) )
    +      {
    +        FT_Pos  height_delta = low_height / 8;
    +        FT_Pos  max_y_limit  = ADD_LONG( low_max_y, height_delta );
    +
    +
    +        FT_TRACE4(( "    Pushing low contour %ld units down\n",
    +                    calculated_amount ));
    +
    +        af_move_contours_down( hints, max_y_limit, adjustment_amount );
    +
    +        if ( adjust_above_bottom && is_bottom_tilde )
    +        {
    +          FT_TRACE4(( "    Pushing bottom tilde %ld units down\n",
    +                      centering_adjustment ));
    +
    +          af_move_contours_down( hints,
    +                                 SUB_LONG( max_y_limit, low_height ),
    +                                 centering_adjustment );
    +        }
    +      }
    +    }
    +
    +#ifdef FT_DEBUG_LEVEL_TRACE
    +    if ( !( ( ( adjust_top || adjust_bottom ) &&
    +              hints->num_contours >= 2        )             ||
    +            ( ( adjust_below_top || adjust_above_bottom ) &&
    +              hints->num_contours >= 3                    ) ) )
    +      FT_TRACE4(( "af_glyph_hints_apply_vertical_separation_adjustments:\n"
    +                  "  No vertical adjustment applied\n" ));
    +#endif
    +
    +    FT_TRACE4(( "Exiting"
    +                " af_glyph_hints_apply_vertical_separation_adjustments\n" ));
    +  }
    +
    +
    +#undef  FT_COMPONENT
    +#define FT_COMPONENT  aflatin
    +
    +
       /* Compute the snapped width of a given stem, ignoring very thin ones. */
       /* There is a lot of voodoo in this function; changing the hard-coded  */
       /* parameters influence the whole hinting process.                     */
    @@ -2998,13 +4220,15 @@
       af_latin_hint_edges( AF_GlyphHints  hints,
                            AF_Dimension   dim )
       {
    -    AF_AxisHints  axis       = &hints->axis[dim];
    -    AF_Edge       edges      = axis->edges;
    -    AF_Edge       edge_limit = FT_OFFSET( edges, axis->num_edges );
    -    FT_PtrDist    n_edges;
    -    AF_Edge       edge;
    -    AF_Edge       anchor     = NULL;
    -    FT_Int        has_serifs = 0;
    +    AF_AxisHints  axis = &hints->axis[dim];
    +
    +    AF_Edge     edges      = axis->edges;
    +    AF_Edge     edge_limit = FT_OFFSET( edges, axis->num_edges );
    +    AF_Edge     edge;
    +    FT_PtrDist  n_edges;
    +
    +    AF_Edge  anchor             = NULL;
    +    FT_Bool  has_non_stem_edges = 0;
     
         AF_StyleClass   style_class  = hints->metrics->style_class;
         AF_ScriptClass  script_class = af_script_classes[style_class->script];
    @@ -3131,7 +4355,7 @@
           edge2 = edge->link;
           if ( !edge2 )
           {
    -        has_serifs++;
    +        has_non_stem_edges = TRUE;
             continue;
           }
     
    @@ -3408,7 +4632,7 @@
           }
         }
     
    -    if ( has_serifs || !anchor )
    +    if ( has_non_stem_edges || !anchor )
         {
           /*
            * now hint the remaining edges (serifs and single) in order
    @@ -3426,9 +4650,75 @@
     
             if ( edge->serif )
             {
    +          AF_Edge  e, top, bottom;
    +          FT_Pos   min_pos, max_pos;
    +
    +
    +          /* Check whether we have a real serif -- if there are  */
    +          /* other edges with overlapping (or enclosed) segments */
    +          /* between the primary and serif edge, we have not.    */
    +          /*                                                     */
    +          /* Such a situation might happen if an accent is very  */
    +          /* near to its base glyph (for example, Vietnamese     */
    +          /* uppercase letters with two accents in `arial.ttf`), */
    +          /* and the segment detection algorithm classifies the  */
    +          /* top of the accent incorrectly as a serif.           */
               delta = edge->serif->opos - edge->opos;
               if ( delta < 0 )
    +          {
                 delta = -delta;
    +
    +            top    = edge;
    +            bottom = edge->serif;
    +          }
    +          else
    +          {
    +            top    = edge->serif;
    +            bottom = edge;
    +          }
    +
    +          if ( delta < 64 + 32 )
    +          {
    +            /* take care of outline orientation while computing extrema */
    +            min_pos = FT_MIN( FT_MIN( FT_MIN( top->first->first->v,
    +                                              top->first->last->v ),
    +                                      FT_MIN( top->last->first->v,
    +                                              top->last->last->v ) ),
    +                              FT_MIN( FT_MIN( bottom->first->first->v,
    +                                              bottom->first->last->v ),
    +                                      FT_MIN( bottom->last->first->v,
    +                                              bottom->last->last->v ) ) );
    +            max_pos = FT_MAX( FT_MAX( FT_MAX( top->first->first->v,
    +                                              top->first->last->v ),
    +                                      FT_MAX( top->last->first->v,
    +                                              top->last->last->v ) ),
    +                              FT_MAX( FT_MAX( bottom->first->first->v,
    +                                              bottom->first->last->v ),
    +                                      FT_MAX( bottom->last->first->v,
    +                                              bottom->last->last->v ) ) );
    +
    +            for ( e = bottom + 1; e < top; e++ )
    +            {
    +              FT_Pos  e_min = FT_MIN( FT_MIN( e->first->first->v,
    +                                              e->first->last->v ),
    +                                      FT_MIN( e->last->first->v,
    +                                              e->last->last->v ) );
    +              FT_Pos  e_max = FT_MAX( FT_MAX( e->first->first->v,
    +                                              e->first->last->v ),
    +                                      FT_MAX( e->last->first->v,
    +                                              e->last->last->v ) );
    +
    +              if ( !( ( e_min < min_pos && e_max < min_pos ) ||
    +                      ( e_min > max_pos && e_max > max_pos ) ) )
    +              {
    +                delta = 1000;  /* not a real serif */
    +                break;
    +              }
    +            }
    +
    +            if ( delta == 1000 )
    +              continue;
    +          }
             }
     
             if ( delta < 64 + 16 )
    @@ -3562,6 +4852,8 @@
     
         AF_LatinAxis  axis;
     
    +    FT_Pos  accent_height_limit = 0;
    +
     
         error = af_glyph_hints_reload( hints, outline );
         if ( error )
    @@ -3581,11 +4873,172 @@
     
         if ( AF_HINTS_DO_VERTICAL( hints ) )
         {
    +      size_t*  val;
    +
    +      FT_Int  top_tilde_contour    = 0;
    +      FT_Int  bottom_tilde_contour = 0;
    +
    +      FT_Int  below_top_tilde_contour    = 0;
    +      FT_Int  above_bottom_tilde_contour = 0;
    +
    +      AF_LatinBlue  capital_top_blue    = NULL;
    +      AF_LatinBlue  capital_bottom_blue = NULL;
    +
    +      AF_LatinBlue  small_top_blue    = NULL;
    +      AF_LatinBlue  small_bottom_blue = NULL;
    +
    +      FT_Bool  have_flags = FALSE;
    +
    +      FT_Bool  is_top_tilde    = FALSE;
    +      FT_Bool  is_bottom_tilde = FALSE;
    +
    +      FT_Bool  is_below_top_tilde    = FALSE;
    +      FT_Bool  is_above_bottom_tilde = FALSE;
    +
    +      FT_Bool  ignore_capital_top    = FALSE;
    +      FT_Bool  ignore_capital_bottom = FALSE;
    +
    +      FT_Bool  ignore_small_top    = FALSE;
    +      FT_Bool  ignore_small_bottom = FALSE;
    +
    +      FT_Bool  do_height_check = TRUE;
    +
    +      FT_Pos  limit;
    +      FT_Pos  y_offset;
    +
    +
    +      val = ft_hash_num_lookup( (FT_Int)glyph_index,
    +                                metrics->root.reverse_charmap );
    +      if ( val )
    +      {
    +        FT_UInt    codepoint = *val;
    +        FT_UInt32  adj_type  = af_adjustment_database_lookup( codepoint );
    +
    +
    +        if ( adj_type )
    +        {
    +          have_flags = !!adj_type;
    +
    +          is_top_tilde    = !!( adj_type & AF_ADJUST_TILDE_TOP );
    +          is_bottom_tilde = !!( adj_type & AF_ADJUST_TILDE_BOTTOM );
    +
    +          is_below_top_tilde    = !!( adj_type & AF_ADJUST_TILDE_TOP2 );
    +          is_above_bottom_tilde = !!( adj_type & AF_ADJUST_TILDE_BOTTOM2 );
    +
    +          ignore_capital_top    = !!( adj_type & AF_IGNORE_CAPITAL_TOP );
    +          ignore_capital_bottom = !!( adj_type & AF_IGNORE_CAPITAL_BOTTOM );
    +
    +          ignore_small_top    = !!( adj_type & AF_IGNORE_SMALL_TOP );
    +          ignore_small_bottom = !!( adj_type & AF_IGNORE_SMALL_BOTTOM );
    +
    +          do_height_check = !( adj_type & AF_ADJUST_NO_HEIGHT_CHECK );
    +        }
    +      }
    +
    +      if ( is_top_tilde || is_bottom_tilde             ||
    +           is_below_top_tilde || is_above_bottom_tilde )
    +        af_compute_vertical_extrema( hints );
    +
    +      /* Process inner tilde glyphs first. */
    +      if ( is_below_top_tilde )
    +      {
    +        below_top_tilde_contour = af_find_second_highest_contour( hints );
    +
    +        y_offset = af_latin_stretch_top_tilde(
    +                     hints, below_top_tilde_contour );
    +        y_offset += af_latin_align_top_tilde(
    +                      hints, below_top_tilde_contour );
    +
    +        limit = hints->contour_y_minima[below_top_tilde_contour];
    +        af_move_contours_up( hints, limit, y_offset );
    +      }
    +      if ( is_above_bottom_tilde )
    +      {
    +        above_bottom_tilde_contour = af_find_second_lowest_contour( hints );
    +
    +        y_offset = af_latin_stretch_bottom_tilde(
    +                     hints, above_bottom_tilde_contour );
    +        y_offset -= af_latin_align_bottom_tilde(
    +                      hints, above_bottom_tilde_contour );
    +
    +        limit = hints->contour_y_maxima[above_bottom_tilde_contour];
    +        af_move_contours_down( hints, limit, y_offset );
    +      }
    +
    +      if ( is_top_tilde )
    +      {
    +        top_tilde_contour = af_find_highest_contour( hints );
    +
    +        (void)af_latin_stretch_top_tilde( hints, top_tilde_contour );
    +        (void)af_latin_align_top_tilde( hints, top_tilde_contour );
    +      }
    +      if ( is_bottom_tilde )
    +      {
    +        bottom_tilde_contour = af_find_lowest_contour( hints );
    +
    +        (void)af_latin_stretch_bottom_tilde( hints, bottom_tilde_contour );
    +        (void)af_latin_align_bottom_tilde( hints, bottom_tilde_contour );
    +      }
    +
           axis  = &metrics->axis[AF_DIMENSION_VERT];
           error = af_latin_hints_detect_features( hints,
                                                   axis->width_count,
                                                   axis->widths,
                                                   AF_DIMENSION_VERT );
    +
    +      if ( have_flags )
    +      {
    +        af_latin_get_base_glyph_blues( hints,
    +                                       TRUE,
    +                                       &capital_top_blue,
    +                                       &capital_bottom_blue );
    +        af_latin_get_base_glyph_blues( hints,
    +                                       FALSE,
    +                                       &small_top_blue,
    +                                       &small_bottom_blue );
    +
    +        if ( do_height_check )
    +        {
    +          /* Set a heuristic limit for the accent height so that    */
    +          /* `af_glyph_hints_apply_vertical_separation_adjustments` */
    +          /* can correctly ignore the case where an accent is       */
    +          /* unexpectedly not the highest (or lowest) contour.      */
    +
    +          /* Either 2/3 of the lowercase blue zone height... */
    +          if ( small_top_blue && small_bottom_blue )
    +            accent_height_limit = 2 * ( small_top_blue->shoot.cur -
    +                                        small_bottom_blue->shoot.cur ) / 3;
    +          /* or 1/2 of the uppercase blue zone height... */
    +          else if ( capital_top_blue && capital_bottom_blue )
    +            accent_height_limit = ( capital_top_blue->shoot.cur -
    +                                    capital_bottom_blue->shoot.cur ) / 2;
    +          /* or half of the standard PostScript ascender value (8/10) */
    +          /* of the EM value, scaled.                                 */
    +          else
    +            accent_height_limit = FT_MulFix( metrics->units_per_em * 4 / 10,
    +                                             metrics->root.scaler.y_scale );
    +        }
    +      }
    +
    +      if ( capital_top_blue && capital_bottom_blue )
    +      {
    +        if ( ignore_capital_top )
    +          af_latin_ignore_top( hints,
    +                               capital_top_blue, capital_bottom_blue );
    +        if ( ignore_capital_bottom )
    +          af_latin_ignore_bottom( hints,
    +                                  capital_top_blue, capital_bottom_blue );
    +      }
    +      if ( small_top_blue && small_bottom_blue )
    +      {
    +        if ( ignore_small_top )
    +          af_latin_ignore_top( hints,
    +                               small_top_blue, small_bottom_blue );
    +        if ( ignore_small_bottom )
    +          af_latin_ignore_bottom( hints,
    +                                  small_top_blue, small_bottom_blue );
    +      }
    +
           if ( error )
             goto Exit;
     
    @@ -3604,6 +5057,12 @@
             af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim );
             af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
             af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
    +        af_glyph_hints_apply_vertical_separation_adjustments(
    +          hints,
    +          (AF_Dimension)dim,
    +          glyph_index,
    +          accent_height_limit,
    +          metrics->root.reverse_charmap );
           }
         }
     
    @@ -3632,7 +5091,7 @@
     
         (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init,        /* style_metrics_init    */
         (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale,       /* style_metrics_scale   */
    -    (AF_WritingSystem_DoneMetricsFunc) NULL,                         /* style_metrics_done    */
    +    (AF_WritingSystem_DoneMetricsFunc) af_latin_metrics_done,        /* style_metrics_done    */
         (AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, /* style_metrics_getstdw */
     
         (AF_WritingSystem_InitHintsFunc)   af_latin_hints_init,          /* style_hints_init      */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
    index 54e50615021..82b4b0d480d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h
    @@ -5,7 +5,7 @@
      *   Auto-fitter hinting routines for latin writing system
      *   (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -61,17 +61,26 @@ FT_BEGIN_HEADER
               ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
     #define AF_LATIN_IS_LONG_BLUE( b ) \
               ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
    +#define AF_LATIN_IS_CAPITAL_BOTTOM_BLUE( b ) \
    +          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM )
    +#define AF_LATIN_IS_SMALL_BOTTOM_BLUE( b ) \
    +          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM )
     
     #define AF_LATIN_MAX_WIDTHS  16
     
     
    -#define AF_LATIN_BLUE_ACTIVE      ( 1U << 0 ) /* zone height is <= 3/4px   */
    -#define AF_LATIN_BLUE_TOP         ( 1U << 1 ) /* we have a top blue zone   */
    -#define AF_LATIN_BLUE_SUB_TOP     ( 1U << 2 ) /* we have a subscript top   */
    -                                              /* blue zone                 */
    -#define AF_LATIN_BLUE_NEUTRAL     ( 1U << 3 ) /* we have neutral blue zone */
    -#define AF_LATIN_BLUE_ADJUSTMENT  ( 1U << 4 ) /* used for scale adjustment */
    -                                              /* optimization              */
    +#define AF_LATIN_BLUE_ACTIVE        ( 1U << 0 ) /* zone height is <= 3/4px */
    +#define AF_LATIN_BLUE_TOP           ( 1U << 1 ) /* we have a top blue zone */
    +#define AF_LATIN_BLUE_SUB_TOP       ( 1U << 2 ) /* we have a subscript     */
    +                                                /* top blue zone           */
    +#define AF_LATIN_BLUE_NEUTRAL       ( 1U << 3 ) /* we have a neutral blue  */
    +                                                /* zone                    */
    +#define AF_LATIN_BLUE_ADJUSTMENT    ( 1U << 4 ) /* used for scale adjustm. */
    +                                                /* optimization            */
    +#define AF_LATIN_BLUE_BOTTOM        ( 1U << 5 ) /* we have a capital       */
    +                                                /* letter bottom blue zone */
    +#define AF_LATIN_BLUE_BOTTOM_SMALL  ( 1U << 6 ) /* we have a small letter  */
    +                                                /* bottom blue zone        */
     
     
       typedef struct  AF_LatinBlueRec_
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
    index af1d59a6896..4e2ac1f1ce3 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter glyph loading routines (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -524,16 +524,18 @@
     
           bbox.xMin = FT_PIX_FLOOR( bbox.xMin );
           bbox.yMin = FT_PIX_FLOOR( bbox.yMin );
    -      bbox.xMax = FT_PIX_CEIL(  bbox.xMax );
    -      bbox.yMax = FT_PIX_CEIL(  bbox.yMax );
    +      bbox.xMax = FT_PIX_CEIL_LONG( bbox.xMax );
    +      bbox.yMax = FT_PIX_CEIL_LONG( bbox.yMax );
     
    -      slot->metrics.width        = bbox.xMax - bbox.xMin;
    -      slot->metrics.height       = bbox.yMax - bbox.yMin;
    +      slot->metrics.width        = SUB_LONG( bbox.xMax, bbox.xMin );
    +      slot->metrics.height       = SUB_LONG( bbox.yMax, bbox.yMin );
           slot->metrics.horiBearingX = bbox.xMin;
           slot->metrics.horiBearingY = bbox.yMax;
     
    -      slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x );
    -      slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
    +      slot->metrics.vertBearingX = FT_PIX_FLOOR( ADD_LONG( bbox.xMin,
    +                                                           vvector.x ) );
    +      slot->metrics.vertBearingY = FT_PIX_FLOOR( ADD_LONG( bbox.yMax,
    +                                                           vvector.y ) );
     
           /* for mono-width fonts (like Andale, Courier, etc.) we need */
           /* to keep the original rounded advance width; ditto for     */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
    index 99f0e15f92b..a04b4df0b3b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter glyph loading routines (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
    index 726f6ca2b78..22d85a889e8 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter module implementation (body).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -146,7 +146,7 @@
     
           if ( !af_style_classes[ss] )
           {
    -        FT_TRACE2(( "af_property_set: Invalid value %d for property `%s'\n",
    +        FT_TRACE2(( "af_property_set: Invalid value %u for property `%s'\n",
                         *fallback_script, property_name ));
             return FT_THROW( Invalid_Argument );
           }
    @@ -412,6 +412,11 @@
         module->darken_params[6]  = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
         module->darken_params[7]  = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
     
    +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ )         && \
    +    defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
    +    ft_hb_funcs_init( module );
    +#endif
    +
         return FT_Err_Ok;
       }
     
    @@ -421,6 +426,11 @@
       {
         FT_UNUSED( ft_module );
     
    +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ )         && \
    +    defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
    +    ft_hb_funcs_done( (AF_Module)ft_module );
    +#endif
    +
     #ifdef FT_DEBUG_AUTOFIT
         if ( af_debug_hints_rec_->memory )
           af_glyph_hints_done( af_debug_hints_rec_ );
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
    index 91a1abfef1f..c62421ef696 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter module implementation (specification).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -22,6 +22,7 @@
     #include 
     #include 
     
    +#include "ft-hb.h"
     
     FT_BEGIN_HEADER
     
    @@ -40,6 +41,11 @@ FT_BEGIN_HEADER
         FT_Bool       no_stem_darkening;
         FT_Int        darken_params[8];
     
    +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ )         && \
    +    defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
    +    ft_hb_funcs_t*  hb_funcs;
    +#endif
    +
       } AF_ModuleRec, *AF_Module;
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
    index 007b4328189..fd54948f3a5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter Unicode script ranges (body).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -73,9 +73,11 @@
       {
         AF_UNIRANGE_REC(  0x0600,  0x06FF ),  /* Arabic                                 */
         AF_UNIRANGE_REC(  0x0750,  0x07FF ),  /* Arabic Supplement                      */
    +    AF_UNIRANGE_REC(  0x0870,  0x089F ),  /* Arabic Extended-B                      */
         AF_UNIRANGE_REC(  0x08A0,  0x08FF ),  /* Arabic Extended-A                      */
         AF_UNIRANGE_REC(  0xFB50,  0xFDFF ),  /* Arabic Presentation Forms-A            */
         AF_UNIRANGE_REC(  0xFE70,  0xFEFF ),  /* Arabic Presentation Forms-B            */
    +    AF_UNIRANGE_REC( 0x10EC0, 0x10EFF ),  /* Arabic Extended-C                      */
         AF_UNIRANGE_REC( 0x1EE00, 0x1EEFF ),  /* Arabic Mathematical Alphabetic Symbols */
         AF_UNIRANGE_REC(       0,       0 )
       };
    @@ -90,8 +92,9 @@
         AF_UNIRANGE_REC(  0x06DF,  0x06E4 ),
         AF_UNIRANGE_REC(  0x06E7,  0x06E8 ),
         AF_UNIRANGE_REC(  0x06EA,  0x06ED ),
    -    AF_UNIRANGE_REC(  0x08D4,  0x08E1 ),
    -    AF_UNIRANGE_REC(  0x08D3,  0x08FF ),
    +    AF_UNIRANGE_REC(  0x0897,  0x089F ),
    +    AF_UNIRANGE_REC(  0x08CA,  0x08E1 ),
    +    AF_UNIRANGE_REC(  0x08E3,  0x08FF ),
         AF_UNIRANGE_REC(  0xFBB2,  0xFBC1 ),
         AF_UNIRANGE_REC(  0xFE70,  0xFE70 ),
         AF_UNIRANGE_REC(  0xFE72,  0xFE72 ),
    @@ -101,6 +104,7 @@
         AF_UNIRANGE_REC(  0xFE7A,  0xFE7A ),
         AF_UNIRANGE_REC(  0xFE7C,  0xFE7C ),
         AF_UNIRANGE_REC(  0xFE7E,  0xFE7E ),
    +    AF_UNIRANGE_REC( 0x10EFD, 0x10EFF ),
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -198,8 +202,9 @@
     
       const AF_Script_UniRangeRec  af_cans_uniranges[] =
       {
    -    AF_UNIRANGE_REC(  0x1400,  0x167F ), /* Unified Canadian Aboriginal Syllabics          */
    -    AF_UNIRANGE_REC(  0x18B0,  0x18FF ), /* Unified Canadian Aboriginal Syllabics Extended */
    +    AF_UNIRANGE_REC(  0x1400,  0x167F ), /* Unified Canadian Aboriginal Syllabics            */
    +    AF_UNIRANGE_REC(  0x18B0,  0x18FF ), /* Unified Canadian Aboriginal Syllabics Extended   */
    +    AF_UNIRANGE_REC( 0x11AB0, 0x11ABF ), /* Unified Canadian Aboriginal Syllabics Extended-A */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -259,6 +264,9 @@
       };
     
     
    +  /* TODO: Split off data for new 'cyrb' (subscript) and 'cyrp'     */
    +  /*       (superscript) groups (mainly from the Extended-D block), */
    +  /*       in analogy to 'latb' and 'latp'?                         */
       const AF_Script_UniRangeRec  af_cyrl_uniranges[] =
       {
         AF_UNIRANGE_REC(  0x0400,  0x04FF ),  /* Cyrillic            */
    @@ -266,6 +274,7 @@
         AF_UNIRANGE_REC(  0x2DE0,  0x2DFF ),  /* Cyrillic Extended-A */
         AF_UNIRANGE_REC(  0xA640,  0xA69F ),  /* Cyrillic Extended-B */
         AF_UNIRANGE_REC(  0x1C80,  0x1C8F ),  /* Cyrillic Extended-C */
    +    AF_UNIRANGE_REC( 0x1E030, 0x1E08F ),  /* Cyrillic Extended-D */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -285,15 +294,16 @@
     
       const AF_Script_UniRangeRec  af_deva_uniranges[] =
       {
    -    AF_UNIRANGE_REC(  0x0900,  0x093B ),  /* Devanagari          */
    +    AF_UNIRANGE_REC(  0x0900,  0x093B ),  /* Devanagari            */
         /* omitting U+093C nukta */
    -    AF_UNIRANGE_REC(  0x093D,  0x0950 ),  /* ... continued       */
    +    AF_UNIRANGE_REC(  0x093D,  0x0950 ),  /* ... continued         */
         /* omitting U+0951 udatta, U+0952 anudatta */
    -    AF_UNIRANGE_REC(  0x0953,  0x0963 ),  /* ... continued       */
    +    AF_UNIRANGE_REC(  0x0953,  0x0963 ),  /* ... continued         */
         /* omitting U+0964 danda, U+0965 double danda */
    -    AF_UNIRANGE_REC(  0x0966,  0x097F ),  /* ... continued       */
    -    AF_UNIRANGE_REC(  0x20B9,  0x20B9 ),  /* (new) Rupee sign    */
    -    AF_UNIRANGE_REC(  0xA8E0,  0xA8FF ),  /* Devanagari Extended */
    +    AF_UNIRANGE_REC(  0x0966,  0x097F ),  /* ... continued         */
    +    AF_UNIRANGE_REC(  0x20B9,  0x20B9 ),  /* (new) Rupee sign      */
    +    AF_UNIRANGE_REC(  0xA8E0,  0xA8FF ),  /* Devanagari Extended   */
    +    AF_UNIRANGE_REC( 0x11B00, 0x11B5F ),  /* Devanagari Extended-A */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -329,6 +339,7 @@
         AF_UNIRANGE_REC(  0x1380,  0x139F ),  /* Ethiopic Supplement */
         AF_UNIRANGE_REC(  0x2D80,  0x2DDF ),  /* Ethiopic Extended   */
         AF_UNIRANGE_REC(  0xAB00,  0xAB2F ),  /* Ethiopic Extended-A */
    +    AF_UNIRANGE_REC( 0x1E7E0, 0x1E7FF ),  /* Ethiopic Extended-B */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -534,7 +545,7 @@
       {
         AF_UNIRANGE_REC(  0x0EB1,  0x0EB1 ),
         AF_UNIRANGE_REC(  0x0EB4,  0x0EBC ),
    -    AF_UNIRANGE_REC(  0x0EC8,  0x0ECD ),
    +    AF_UNIRANGE_REC(  0x0EC8,  0x0ECE ),
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -567,12 +578,15 @@
         AF_UNIRANGE_REC(  0x2C7E,  0x2C7F ),  /* ... continued                          */
         AF_UNIRANGE_REC(  0x2E00,  0x2E7F ),  /* Supplemental Punctuation               */
         AF_UNIRANGE_REC(  0xA720,  0xA76F ),  /* Latin Extended-D                       */
    -    AF_UNIRANGE_REC(  0xA771,  0xA7F7 ),  /* ... continued                          */
    +    AF_UNIRANGE_REC(  0xA771,  0xA7F0 ),  /* ... continued                          */
    +    AF_UNIRANGE_REC(  0xA7F2,  0xA7F7 ),  /* ... continued                          */
         AF_UNIRANGE_REC(  0xA7FA,  0xA7FF ),  /* ... continued                          */
         AF_UNIRANGE_REC(  0xAB30,  0xAB5B ),  /* Latin Extended-E                       */
    -    AF_UNIRANGE_REC(  0xAB60,  0xAB6F ),  /* ... continued                          */
    +    AF_UNIRANGE_REC(  0xAB60,  0xAB68 ),  /* ... continued                          */
    +    AF_UNIRANGE_REC(  0xAB6A,  0xAB6F ),  /* ... continued                          */
         AF_UNIRANGE_REC(  0xFB00,  0xFB06 ),  /* Alphab. Present. Forms (Latin Ligs)    */
         AF_UNIRANGE_REC( 0x1D400, 0x1D7FF ),  /* Mathematical Alphanumeric Symbols      */
    +    AF_UNIRANGE_REC( 0x1DF00, 0x1DFFF ),  /* Latin Extended-G                       */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -588,7 +602,7 @@
         AF_UNIRANGE_REC(  0x02B9,  0x02DF ),
         AF_UNIRANGE_REC(  0x02E5,  0x02FF ),
         AF_UNIRANGE_REC(  0x0300,  0x036F ),
    -    AF_UNIRANGE_REC(  0x1AB0,  0x1ABE ),
    +    AF_UNIRANGE_REC(  0x1AB0,  0x1AEB ),
         AF_UNIRANGE_REC(  0x1DC0,  0x1DFF ),
         AF_UNIRANGE_REC(  0x2017,  0x2017 ),
         AF_UNIRANGE_REC(  0x203E,  0x203E ),
    @@ -625,8 +639,11 @@
         AF_UNIRANGE_REC(  0x2070,  0x207F ),  /* superscript digits and letters      */
         AF_UNIRANGE_REC(  0x2C7D,  0x2C7D ),  /* modifier letter capital v           */
         AF_UNIRANGE_REC(  0xA770,  0xA770 ),  /* modifier letter us                  */
    +    AF_UNIRANGE_REC(  0xA7F1,  0xA7F1 ),  /* modifier letter capital s           */
         AF_UNIRANGE_REC(  0xA7F8,  0xA7F9 ),  /* more modifier letters               */
         AF_UNIRANGE_REC(  0xAB5C,  0xAB5F ),  /* more modifier letters               */
    +    AF_UNIRANGE_REC(  0xAB69,  0xAB69 ),  /* modifier letter small turned w      */
    +    AF_UNIRANGE_REC( 0x10780, 0x107FB ),  /* Latin Extended-F                    */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -638,7 +655,8 @@
     
       const AF_Script_UniRangeRec  af_lisu_uniranges[] =
       {
    -    AF_UNIRANGE_REC(  0xA4D0,  0xA4FF ),    /* Lisu */
    +    AF_UNIRANGE_REC(  0xA4D0,  0xA4FF ),    /* Lisu            */
    +    AF_UNIRANGE_REC( 0x11FB0, 0x11FBF ),    /* Lisu Supplement */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -696,6 +714,7 @@
         AF_UNIRANGE_REC(  0x1000,  0x109F ),    /* Myanmar            */
         AF_UNIRANGE_REC(  0xA9E0,  0xA9FF ),    /* Myanmar Extended-B */
         AF_UNIRANGE_REC(  0xAA60,  0xAA7F ),    /* Myanmar Extended-A */
    +    AF_UNIRANGE_REC( 0x116D0, 0x116FF ),    /* Myanmar Extended-C */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -836,6 +855,7 @@
     
       const AF_Script_UniRangeRec  af_sinh_nonbase_uniranges[] =
       {
    +    AF_UNIRANGE_REC(  0x0D81,  0x0D81 ),
         AF_UNIRANGE_REC(  0x0DCA,  0x0DCA ),
         AF_UNIRANGE_REC(  0x0DD2,  0x0DD6 ),
         AF_UNIRANGE_REC(       0,       0 )
    @@ -859,7 +879,8 @@
     
       const AF_Script_UniRangeRec  af_taml_uniranges[] =
       {
    -    AF_UNIRANGE_REC(  0x0B80,  0x0BFF ),  /* Tamil */
    +    AF_UNIRANGE_REC(  0x0B80,  0x0BFF ),  /* Tamil            */
    +    AF_UNIRANGE_REC( 0x11FC0, 0x11FFF ),  /* Tamil Supplement */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -899,6 +920,7 @@
       {
         AF_UNIRANGE_REC(  0x0C00,  0x0C00 ),
         AF_UNIRANGE_REC(  0x0C04,  0x0C04 ),
    +    AF_UNIRANGE_REC(  0x0C3C,  0x0C3C ),
         AF_UNIRANGE_REC(  0x0C3E,  0x0C40 ),
         AF_UNIRANGE_REC(  0x0C46,  0x0C56 ),
         AF_UNIRANGE_REC(  0x0C62,  0x0C63 ),
    @@ -992,6 +1014,7 @@
         AF_UNIRANGE_REC(  0xA806,  0xA806 ),
         AF_UNIRANGE_REC(  0xA80B,  0xA80B ),
         AF_UNIRANGE_REC(  0xA825,  0xA826 ),
    +    AF_UNIRANGE_REC(  0xA82C,  0xA82C ),
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    @@ -1048,15 +1071,21 @@
         AF_UNIRANGE_REC(  0xFE10,  0xFE1F ),  /* Vertical forms                          */
         AF_UNIRANGE_REC(  0xFE30,  0xFE4F ),  /* CJK Compatibility Forms                 */
         AF_UNIRANGE_REC(  0xFF00,  0xFFEF ),  /* Halfwidth and Fullwidth Forms           */
    +    AF_UNIRANGE_REC( 0x1AFF0, 0x1AFFF ),  /* Kana Extended-B                         */
         AF_UNIRANGE_REC( 0x1B000, 0x1B0FF ),  /* Kana Supplement                         */
         AF_UNIRANGE_REC( 0x1B100, 0x1B12F ),  /* Kana Extended-A                         */
    +    AF_UNIRANGE_REC( 0x1B130, 0x1B16F ),  /* Small Kana Extension                    */
         AF_UNIRANGE_REC( 0x1D300, 0x1D35F ),  /* Tai Xuan Hing Symbols                   */
         AF_UNIRANGE_REC( 0x20000, 0x2A6DF ),  /* CJK Unified Ideographs Extension B      */
         AF_UNIRANGE_REC( 0x2A700, 0x2B73F ),  /* CJK Unified Ideographs Extension C      */
         AF_UNIRANGE_REC( 0x2B740, 0x2B81F ),  /* CJK Unified Ideographs Extension D      */
         AF_UNIRANGE_REC( 0x2B820, 0x2CEAF ),  /* CJK Unified Ideographs Extension E      */
         AF_UNIRANGE_REC( 0x2CEB0, 0x2EBEF ),  /* CJK Unified Ideographs Extension F      */
    +    AF_UNIRANGE_REC( 0x2EBF0, 0x2EE5D ),  /* CJK Unified Ideographs Extension I      */
         AF_UNIRANGE_REC( 0x2F800, 0x2FA1F ),  /* CJK Compatibility Ideographs Supplement */
    +    AF_UNIRANGE_REC( 0x30000, 0x3134A ),  /* CJK Unified Ideographs Extension G      */
    +    AF_UNIRANGE_REC( 0x31350, 0x323AF ),  /* CJK Unified Ideographs Extension H      */
    +    AF_UNIRANGE_REC( 0x323B0, 0x33479 ),  /* CJK Unified Ideographs Extension J      */
         AF_UNIRANGE_REC(       0,       0 )
       };
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
    index 813b3ee78ef..fa00eb75046 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter Unicode script ranges (specification).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h b/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
    index 0a83d771501..5c4cbbcb922 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter scripts (specification only).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
    index df0f46ada89..f3c0744fd9d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c
    @@ -4,7 +4,7 @@
      *
      *   HarfBuzz interface for accessing OpenType features (body).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -22,8 +22,8 @@
     #include "aftypes.h"
     #include "afshaper.h"
     
    -#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
     
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
     
       /**************************************************************************
        *
    @@ -89,17 +89,18 @@
     #define SCRIPT( s, S, d, h, H, ss )  h,
     
     
    -  static const hb_script_t  scripts[] =
    +  FT_LOCAL_ARRAY_DEF( hb_script_t )
    +  af_hb_scripts[] =
       {
     #include "afscript.h"
       };
     
     
    -  FT_Error
    -  af_shaper_get_coverage( AF_FaceGlobals  globals,
    -                          AF_StyleClass   style_class,
    -                          FT_UShort*      gstyles,
    -                          FT_Bool         default_script )
    +  static FT_Error
    +  af_shaper_get_coverage_hb( AF_FaceGlobals  globals,
    +                             AF_StyleClass   style_class,
    +                             FT_UShort*      gstyles,
    +                             FT_Bool         default_script )
       {
         hb_face_t*  face;
     
    @@ -124,10 +125,10 @@
         if ( !globals || !style_class || !gstyles )
           return FT_THROW( Invalid_Argument );
     
    -    face = hb_font_get_face( globals->hb_font );
    +    face = hb( font_get_face )( globals->hb_font );
     
         coverage_tags = coverages[style_class->coverage];
    -    script        = scripts[style_class->script];
    +    script        = af_hb_scripts[style_class->script];
     
         /* Convert a HarfBuzz script tag into the corresponding OpenType */
         /* tag or tags -- some Indic scripts like Devanagari have an old */
    @@ -137,19 +138,19 @@
           hb_tag_t      tags[3];
     
     
    -      hb_ot_tags_from_script_and_language( script,
    -                                           HB_LANGUAGE_INVALID,
    -                                           &tags_count,
    -                                           tags,
    -                                           NULL,
    -                                           NULL );
    +      hb( ot_tags_from_script_and_language )( script,
    +                                              HB_LANGUAGE_INVALID,
    +                                              &tags_count,
    +                                              tags,
    +                                              NULL,
    +                                              NULL );
           script_tags[0] = tags_count > 0 ? tags[0] : HB_TAG_NONE;
           script_tags[1] = tags_count > 1 ? tags[1] : HB_TAG_NONE;
           script_tags[2] = tags_count > 2 ? tags[2] : HB_TAG_NONE;
         }
     
    -    /* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to     */
    -    /* HB_TAG_NONE except for the default script.                        */
    +    /* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to */
    +    /* HB_TAG_NONE except for the default script.                    */
         if ( default_script )
         {
           if ( script_tags[0] == HB_TAG_NONE )
    @@ -170,15 +171,15 @@
             goto Exit;
         }
     
    -    gsub_lookups = hb_set_create();
    -    hb_ot_layout_collect_lookups( face,
    -                                  HB_OT_TAG_GSUB,
    -                                  script_tags,
    -                                  NULL,
    -                                  coverage_tags,
    -                                  gsub_lookups );
    +    gsub_lookups = hb( set_create )();
    +    hb( ot_layout_collect_lookups )( face,
    +                                     HB_OT_TAG_GSUB,
    +                                     script_tags,
    +                                     NULL,
    +                                     coverage_tags,
    +                                     gsub_lookups );
     
    -    if ( hb_set_is_empty( gsub_lookups ) )
    +    if ( hb( set_is_empty )( gsub_lookups ) )
           goto Exit; /* nothing to do */
     
         FT_TRACE4(( "GSUB lookups (style `%s'):\n",
    @@ -189,22 +190,22 @@
         count = 0;
     #endif
     
    -    gsub_glyphs = hb_set_create();
    -    for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); )
    +    gsub_glyphs = hb( set_create )();
    +    for ( idx = HB_SET_VALUE_INVALID; hb( set_next )( gsub_lookups, &idx ); )
         {
     #ifdef FT_DEBUG_LEVEL_TRACE
    -      FT_TRACE4(( " %d", idx ));
    +      FT_TRACE4(( " %u", idx ));
           count++;
     #endif
     
           /* get output coverage of GSUB feature */
    -      hb_ot_layout_lookup_collect_glyphs( face,
    -                                          HB_OT_TAG_GSUB,
    -                                          idx,
    -                                          NULL,
    -                                          NULL,
    -                                          NULL,
    -                                          gsub_glyphs );
    +      hb( ot_layout_lookup_collect_glyphs )( face,
    +                                             HB_OT_TAG_GSUB,
    +                                             idx,
    +                                             NULL,
    +                                             NULL,
    +                                             NULL,
    +                                             gsub_glyphs );
         }
     
     #ifdef FT_DEBUG_LEVEL_TRACE
    @@ -218,34 +219,34 @@
                     af_style_names[style_class->style] ));
         FT_TRACE4(( " " ));
     
    -    gpos_lookups = hb_set_create();
    -    hb_ot_layout_collect_lookups( face,
    -                                  HB_OT_TAG_GPOS,
    -                                  script_tags,
    -                                  NULL,
    -                                  coverage_tags,
    -                                  gpos_lookups );
    +    gpos_lookups = hb( set_create )();
    +    hb( ot_layout_collect_lookups )( face,
    +                                     HB_OT_TAG_GPOS,
    +                                     script_tags,
    +                                     NULL,
    +                                     coverage_tags,
    +                                     gpos_lookups );
     
     #ifdef FT_DEBUG_LEVEL_TRACE
         count = 0;
     #endif
     
    -    gpos_glyphs = hb_set_create();
    -    for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); )
    +    gpos_glyphs = hb( set_create )();
    +    for ( idx = HB_SET_VALUE_INVALID; hb( set_next )( gpos_lookups, &idx ); )
         {
     #ifdef FT_DEBUG_LEVEL_TRACE
    -      FT_TRACE4(( " %d", idx ));
    +      FT_TRACE4(( " %u", idx ));
           count++;
     #endif
     
           /* get input coverage of GPOS feature */
    -      hb_ot_layout_lookup_collect_glyphs( face,
    -                                          HB_OT_TAG_GPOS,
    -                                          idx,
    -                                          NULL,
    -                                          gpos_glyphs,
    -                                          NULL,
    -                                          NULL );
    +      hb( ot_layout_lookup_collect_glyphs )( face,
    +                                             HB_OT_TAG_GPOS,
    +                                             idx,
    +                                             NULL,
    +                                             gpos_glyphs,
    +                                             NULL,
    +                                             NULL );
         }
     
     #ifdef FT_DEBUG_LEVEL_TRACE
    @@ -281,14 +282,14 @@
     
               GET_UTF8_CHAR( ch, p );
     
    -          for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups,
    -                                                         &idx ); )
    +          for ( idx = HB_SET_VALUE_INVALID; hb( set_next )( gsub_lookups,
    +                                                            &idx ); )
               {
                 hb_codepoint_t  gidx = FT_Get_Char_Index( globals->face, ch );
     
     
    -            if ( hb_ot_layout_lookup_would_substitute( face, idx,
    -                                                       &gidx, 1, 1 ) )
    +            if ( hb( ot_layout_lookup_would_substitute )( face, idx,
    +                                                          &gidx, 1, 1 ) )
                 {
                   found = 1;
                   break;
    @@ -352,14 +353,14 @@
          *
          */
         if ( style_class->coverage != AF_COVERAGE_DEFAULT )
    -      hb_set_subtract( gsub_glyphs, gpos_glyphs );
    +      hb( set_subtract )( gsub_glyphs, gpos_glyphs );
     
     #ifdef FT_DEBUG_LEVEL_TRACE
         FT_TRACE4(( "  glyphs without GPOS data (`*' means already assigned)" ));
         count = 0;
     #endif
     
    -    for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_glyphs, &idx ); )
    +    for ( idx = HB_SET_VALUE_INVALID; hb( set_next )( gsub_glyphs, &idx ); )
         {
     #ifdef FT_DEBUG_LEVEL_TRACE
           if ( !( count % 10 ) )
    @@ -368,7 +369,7 @@
             FT_TRACE4(( "   " ));
           }
     
    -      FT_TRACE4(( " %d", idx ));
    +      FT_TRACE4(( " %u", idx ));
           count++;
     #endif
     
    @@ -397,10 +398,10 @@
     #endif
     
       Exit:
    -    hb_set_destroy( gsub_lookups );
    -    hb_set_destroy( gsub_glyphs  );
    -    hb_set_destroy( gpos_lookups );
    -    hb_set_destroy( gpos_glyphs  );
    +    hb( set_destroy )( gsub_lookups );
    +    hb( set_destroy )( gsub_glyphs  );
    +    hb( set_destroy )( gpos_lookups );
    +    hb( set_destroy )( gpos_glyphs  );
     
         return FT_Err_Ok;
       }
    @@ -437,31 +438,33 @@
       };
     
     
    -  void*
    -  af_shaper_buf_create( FT_Face  face )
    +  static void*
    +  af_shaper_buf_create_hb( AF_FaceGlobals  globals )
       {
    -    FT_UNUSED( face );
    +    FT_UNUSED( globals );
     
    -    return (void*)hb_buffer_create();
    +    return (void*)hb( buffer_create )();
       }
     
     
    -  void
    -  af_shaper_buf_destroy( FT_Face  face,
    -                         void*    buf )
    +  static void
    +  af_shaper_buf_destroy_hb( AF_FaceGlobals  globals,
    +                            void*           buf )
       {
    -    FT_UNUSED( face );
    +    FT_UNUSED( globals );
     
    -    hb_buffer_destroy( (hb_buffer_t*)buf );
    +    hb( buffer_destroy )( (hb_buffer_t*)buf );
       }
     
     
    -  const char*
    -  af_shaper_get_cluster( const char*      p,
    -                         AF_StyleMetrics  metrics,
    -                         void*            buf_,
    -                         unsigned int*    count )
    +  static const char*
    +  af_shaper_get_cluster_hb( const char*      p,
    +                            AF_StyleMetrics  metrics,
    +                            void*            buf_,
    +                            unsigned int*    count )
       {
    +    AF_FaceGlobals  globals = metrics->globals;
    +
         AF_StyleClass        style_class;
         const hb_feature_t*  feature;
         FT_Int               upem;
    @@ -472,6 +475,8 @@
         hb_font_t*      font;
         hb_codepoint_t  dummy;
     
    +    FT_UNUSED( globals );
    +
     
         upem        = (FT_Int)metrics->globals->face->units_per_EM;
         style_class = metrics->style_class;
    @@ -480,7 +485,7 @@
         font = metrics->globals->hb_font;
     
         /* we shape at a size of units per EM; this means font units */
    -    hb_font_set_scale( font, upem, upem );
    +    hb( font_set_scale )( font, upem, upem );
     
         while ( *p == ' ' )
           p++;
    @@ -492,15 +497,15 @@
         len = (int)( q - p );
     
         /* feed character(s) to the HarfBuzz buffer */
    -    hb_buffer_clear_contents( buf );
    -    hb_buffer_add_utf8( buf, p, len, 0, len );
    +    hb( buffer_clear_contents )( buf );
    +    hb( buffer_add_utf8 )( buf, p, len, 0, len );
     
         /* we let HarfBuzz guess the script and writing direction */
    -    hb_buffer_guess_segment_properties( buf );
    +    hb( buffer_guess_segment_properties )( buf );
     
         /* shape buffer, which means conversion from character codes to */
         /* glyph indices, possibly applying a feature                   */
    -    hb_shape( font, buf, feature, feature ? 1 : 0 );
    +    hb( shape )( font, buf, feature, feature ? 1 : 0 );
     
         if ( feature )
         {
    @@ -517,13 +522,13 @@
           /* glyph indices; otherwise the affected glyph or glyphs aren't     */
           /* available at all in the feature                                  */
     
    -      hb_buffer_clear_contents( hb_buf );
    -      hb_buffer_add_utf8( hb_buf, p, len, 0, len );
    -      hb_buffer_guess_segment_properties( hb_buf );
    -      hb_shape( font, hb_buf, NULL, 0 );
    +      hb( buffer_clear_contents )( hb_buf );
    +      hb( buffer_add_utf8 )( hb_buf, p, len, 0, len );
    +      hb( buffer_guess_segment_properties )( hb_buf );
    +      hb( shape )( font, hb_buf, NULL, 0 );
     
    -      ginfo    = hb_buffer_get_glyph_infos( buf, &gcount );
    -      hb_ginfo = hb_buffer_get_glyph_infos( hb_buf, &hb_gcount );
    +      ginfo    = hb( buffer_get_glyph_infos )( buf, &gcount );
    +      hb_ginfo = hb( buffer_get_glyph_infos )( hb_buf, &hb_gcount );
     
           if ( gcount == hb_gcount )
           {
    @@ -537,12 +542,12 @@
             if ( i == gcount )
             {
               /* both buffers have identical glyph indices */
    -          hb_buffer_clear_contents( buf );
    +          hb( buffer_clear_contents )( buf );
             }
           }
         }
     
    -    *count = hb_buffer_get_length( buf );
    +    *count = hb( buffer_get_length )( buf );
     
     #ifdef FT_DEBUG_LEVEL_TRACE
         if ( feature && *count > 1 )
    @@ -554,23 +559,25 @@
       }
     
     
    -  FT_ULong
    -  af_shaper_get_elem( AF_StyleMetrics  metrics,
    -                      void*            buf_,
    -                      unsigned int     idx,
    -                      FT_Long*         advance,
    -                      FT_Long*         y_offset )
    +  static FT_ULong
    +  af_shaper_get_elem_hb( AF_StyleMetrics  metrics,
    +                         void*            buf_,
    +                         unsigned int     idx,
    +                         FT_Long*         advance,
    +                         FT_Long*         y_offset )
       {
    +    AF_FaceGlobals  globals = metrics->globals;
    +
         hb_buffer_t*          buf = (hb_buffer_t*)buf_;
         hb_glyph_info_t*      ginfo;
         hb_glyph_position_t*  gpos;
         unsigned int          gcount;
     
    -    FT_UNUSED( metrics );
    +    FT_UNUSED( globals );
     
     
    -    ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
    -    gpos  = hb_buffer_get_glyph_positions( buf, &gcount );
    +    ginfo = hb( buffer_get_glyph_infos )( buf, &gcount );
    +    gpos  = hb( buffer_get_glyph_positions )( buf, &gcount );
     
         if ( idx >= gcount )
           return 0;
    @@ -584,14 +591,14 @@
       }
     
     
    -#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
    +#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */
     
     
    -  FT_Error
    -  af_shaper_get_coverage( AF_FaceGlobals  globals,
    -                          AF_StyleClass   style_class,
    -                          FT_UShort*      gstyles,
    -                          FT_Bool         default_script )
    +  static FT_Error
    +  af_shaper_get_coverage_nohb( AF_FaceGlobals  globals,
    +                               AF_StyleClass   style_class,
    +                               FT_UShort*      gstyles,
    +                               FT_Bool         default_script )
       {
         FT_UNUSED( globals );
         FT_UNUSED( style_class );
    @@ -602,29 +609,29 @@
       }
     
     
    -  void*
    -  af_shaper_buf_create( FT_Face  face )
    +  static void*
    +  af_shaper_buf_create_nohb( AF_FaceGlobals  globals )
       {
    -    FT_UNUSED( face );
    +    FT_UNUSED( globals );
     
         return NULL;
       }
     
     
    -  void
    -  af_shaper_buf_destroy( FT_Face  face,
    -                         void*    buf )
    +  static void
    +  af_shaper_buf_destroy_nohb( AF_FaceGlobals  globals,
    +                              void*    buf )
       {
    -    FT_UNUSED( face );
    +    FT_UNUSED( globals );
         FT_UNUSED( buf );
       }
     
     
    -  const char*
    -  af_shaper_get_cluster( const char*      p,
    -                         AF_StyleMetrics  metrics,
    -                         void*            buf_,
    -                         unsigned int*    count )
    +  static const char*
    +  af_shaper_get_cluster_nohb( const char*      p,
    +                              AF_StyleMetrics  metrics,
    +                              void*            buf_,
    +                              unsigned int*    count )
       {
         FT_Face    face      = metrics->globals->face;
         FT_ULong   ch, dummy = 0;
    @@ -656,12 +663,12 @@
       }
     
     
    -  FT_ULong
    -  af_shaper_get_elem( AF_StyleMetrics  metrics,
    -                      void*            buf_,
    -                      unsigned int     idx,
    -                      FT_Long*         advance,
    -                      FT_Long*         y_offset )
    +  static FT_ULong
    +  af_shaper_get_elem_nohb( AF_StyleMetrics  metrics,
    +                           void*            buf_,
    +                           unsigned int     idx,
    +                           FT_Long*         advance,
    +                           FT_Long*         y_offset )
       {
         FT_Face   face        = metrics->globals->face;
         FT_ULong  glyph_index = *(FT_ULong*)buf_;
    @@ -684,7 +691,90 @@
       }
     
     
    -#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
    +  /********************************************************************/
    +
    +  FT_Error
    +  af_shaper_get_coverage( AF_FaceGlobals  globals,
    +                          AF_StyleClass   style_class,
    +                          FT_UShort*      gstyles,
    +                          FT_Bool         default_script )
    +  {
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    if ( ft_hb_enabled( globals ) )
    +      return af_shaper_get_coverage_hb( globals,
    +                                        style_class,
    +                                        gstyles,
    +                                        default_script );
    +    else
    +#endif
    +      return af_shaper_get_coverage_nohb( globals,
    +                                          style_class,
    +                                          gstyles,
    +                                          default_script );
    +  }
    +
    +
    +  void*
    +  af_shaper_buf_create( AF_FaceGlobals  globals )
    +  {
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    if ( ft_hb_enabled( globals ) )
    +      return af_shaper_buf_create_hb( globals );
    +    else
    +#endif
    +      return af_shaper_buf_create_nohb( globals );
    +  }
    +
    +
    +  void
    +  af_shaper_buf_destroy( AF_FaceGlobals  globals,
    +                         void*           buf )
    +  {
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    if ( ft_hb_enabled( globals ) )
    +      af_shaper_buf_destroy_hb( globals, buf );
    +    else
    +#endif
    +      af_shaper_buf_destroy_nohb( globals, buf );
    +  }
    +
    +
    +  const char*
    +  af_shaper_get_cluster( const char*      p,
    +                         AF_StyleMetrics  metrics,
    +                         void*            buf_,
    +                         unsigned int*    count )
    +  {
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    if ( ft_hb_enabled( metrics->globals ) )
    +      return af_shaper_get_cluster_hb( p, metrics, buf_, count );
    +    else
    +#endif
    +      return af_shaper_get_cluster_nohb( p, metrics, buf_, count );
    +  }
    +
    +
    +  FT_ULong
    +  af_shaper_get_elem( AF_StyleMetrics  metrics,
    +                      void*            buf_,
    +                      unsigned int     idx,
    +                      FT_Long*         advance,
    +                      FT_Long*         y_offset )
    +  {
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    if ( ft_hb_enabled( metrics->globals ) )
    +      return af_shaper_get_elem_hb( metrics,
    +                                    buf_,
    +                                    idx,
    +                                    advance,
    +                                    y_offset );
    +#endif
    +      return af_shaper_get_elem_nohb( metrics,
    +                                      buf_,
    +                                      idx,
    +                                      advance,
    +                                      y_offset );
    +  }
     
     
     /* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
    index 2eb03bb5d98..757368fc9c0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h
    @@ -4,7 +4,7 @@
      *
      *   HarfBuzz interface for accessing OpenType features (specification).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -23,17 +23,14 @@
     #include 
     
     
    +FT_BEGIN_HEADER
    +
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    -
    -#include 
    -#include 
    -#include "ft-hb.h"
    -
    +  FT_LOCAL_ARRAY( hb_script_t )
    +  af_hb_scripts[];
     #endif
     
     
    -FT_BEGIN_HEADER
    -
       FT_Error
       af_shaper_get_coverage( AF_FaceGlobals  globals,
                               AF_StyleClass   style_class,
    @@ -42,11 +39,11 @@ FT_BEGIN_HEADER
     
     
       void*
    -  af_shaper_buf_create( FT_Face  face );
    +  af_shaper_buf_create( AF_FaceGlobals  globals );
     
       void
    -  af_shaper_buf_destroy( FT_Face  face,
    -                         void*    buf );
    +  af_shaper_buf_destroy( AF_FaceGlobals  globals,
    +                         void*           buf );
     
       const char*
       af_shaper_get_cluster( const char*      p,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h b/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
    index 7a33f37a856..206232efe25 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter styles (specification only).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -50,36 +50,36 @@
                      AF_COVERAGE_ ## C )
     
     #undef  META_STYLE_LATIN
    -#define META_STYLE_LATIN( s, S, ds )                     \
    -          STYLE_LATIN( s, S, c2cp, C2CP, ds,             \
    +#define META_STYLE_LATIN( s, S, ds )                    \
    +          STYLE_LATIN( s, S, c2cp, C2CP, ds,            \
                            "petite capitals from capitals", \
    -                       PETITE_CAPITALS_FROM_CAPITALS )   \
    -          STYLE_LATIN( s, S, c2sc, C2SC, ds,             \
    +                       PETITE_CAPITALS_FROM_CAPITALS )  \
    +          STYLE_LATIN( s, S, c2sc, C2SC, ds,            \
                            "small capitals from capitals",  \
    -                       SMALL_CAPITALS_FROM_CAPITALS )    \
    -          STYLE_LATIN( s, S, ordn, ORDN, ds,             \
    -                       "ordinals",                       \
    -                       ORDINALS )                        \
    -          STYLE_LATIN( s, S, pcap, PCAP, ds,             \
    -                       "petite capitals",                \
    -                       PETITE_CAPITALS )                 \
    -          STYLE_LATIN( s, S, sinf, SINF, ds,             \
    -                       "scientific inferiors",           \
    -                       SCIENTIFIC_INFERIORS )            \
    -          STYLE_LATIN( s, S, smcp, SMCP, ds,             \
    -                       "small capitals",                 \
    -                       SMALL_CAPITALS )                  \
    -          STYLE_LATIN( s, S, subs, SUBS, ds,             \
    -                       "subscript",                      \
    -                       SUBSCRIPT )                       \
    -          STYLE_LATIN( s, S, sups, SUPS, ds,             \
    -                       "superscript",                    \
    -                       SUPERSCRIPT )                     \
    -          STYLE_LATIN( s, S, titl, TITL, ds,             \
    -                       "titling",                        \
    -                       TITLING )                         \
    -          STYLE_LATIN( s, S, dflt, DFLT, ds,             \
    -                       "default",                        \
    +                       SMALL_CAPITALS_FROM_CAPITALS )   \
    +          STYLE_LATIN( s, S, ordn, ORDN, ds,            \
    +                       "ordinals",                      \
    +                       ORDINALS )                       \
    +          STYLE_LATIN( s, S, pcap, PCAP, ds,            \
    +                       "petite capitals",               \
    +                       PETITE_CAPITALS )                \
    +          STYLE_LATIN( s, S, sinf, SINF, ds,            \
    +                       "scientific inferiors",          \
    +                       SCIENTIFIC_INFERIORS )           \
    +          STYLE_LATIN( s, S, smcp, SMCP, ds,            \
    +                       "small capitals",                \
    +                       SMALL_CAPITALS )                 \
    +          STYLE_LATIN( s, S, subs, SUBS, ds,            \
    +                       "subscript",                     \
    +                       SUBSCRIPT )                      \
    +          STYLE_LATIN( s, S, sups, SUPS, ds,            \
    +                       "superscript",                   \
    +                       SUPERSCRIPT )                    \
    +          STYLE_LATIN( s, S, titl, TITL, ds,            \
    +                       "titling",                       \
    +                       TITLING )                        \
    +          STYLE_LATIN( s, S, dflt, DFLT, ds,            \
    +                       "default",                       \
                            DEFAULT )
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h b/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
    index 27e4185e9f8..959640a12ec 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter types (specification only).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -35,6 +35,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     #include 
     
    @@ -406,6 +407,7 @@ extern void*  af_debug_hints_;
     
       typedef struct AF_FaceGlobalsRec_*  AF_FaceGlobals;
     
    +
       /* This is the main structure that combines everything.  Autofit modules */
       /* specific to writing systems derive their structures from it, for      */
       /* example `AF_LatinMetrics'.                                            */
    @@ -418,6 +420,8 @@ extern void*  af_debug_hints_;
     
         AF_FaceGlobals  globals;    /* to access properties */
     
    +    FT_Hash  reverse_charmap;
    +
       } AF_StyleMetricsRec;
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h b/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
    index b78745af74e..12fa7a27a2b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afws-decl.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter writing system declarations (specification only).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h b/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
    index c86d609a352..1752697b375 100644
    --- a/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afws-iter.h
    @@ -4,7 +4,7 @@
      *
      *   Auto-fitter writing systems iterator (specification only).
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.c b/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.c
    new file mode 100644
    index 00000000000..3c145d04640
    --- /dev/null
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.c
    @@ -0,0 +1,197 @@
    +/****************************************************************************
    + *
    + * ft-hb.c
    + *
    + *   FreeType-HarfBuzz bridge (body).
    + *
    + * Copyright (C) 2025 by
    + * Behdad Esfahbod.
    + *
    + * This file is part of the FreeType project, and may only be used,
    + * modified, and distributed under the terms of the FreeType project
    + * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    + * this file you indicate that you have read the license and
    + * understand and accept it fully.
    + *
    + */
    +
    +
    +#if !defined( _WIN32 ) && !defined( _GNU_SOURCE )
    +#  define _GNU_SOURCE  1  /* for RTLD_DEFAULT */
    +#endif
    +
    +#include 
    +#include 
    +
    +#include "afglobal.h"
    +
    +#include "ft-hb.h"
    +
    +
    +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ )         && \
    +    defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC )
    +
    +#ifndef FT_LIBHARFBUZZ
    +#  ifdef _WIN32
    +#    define FT_LIBHARFBUZZ "libharfbuzz-0.dll"
    +#  else
    +#    ifdef __APPLE__
    +#      define FT_LIBHARFBUZZ "libharfbuzz.0.dylib"
    +#    else
    +#      define FT_LIBHARFBUZZ "libharfbuzz.so.0"
    +#    endif
    +#  endif
    +#endif
    +
    +#ifdef _WIN32
    +
    +#  include 
    +
    +#else /* !_WIN32 */
    +
    +#  include 
    +
    +  /* The GCC pragma suppresses the warning "ISO C forbids     */
    +  /* assignment between function pointer and 'void *'", which */
    +  /* inevitably gets emitted with `-Wpedantic`; see the man   */
    +  /* page of function `dlsym` for more information.           */
    +#  if defined( __GNUC__ )
    +#    pragma GCC diagnostic push
    +#    ifndef __cplusplus
    +#      pragma GCC diagnostic ignored "-Wpedantic"
    +#    endif
    +#  endif
    +
    +#endif /* !_WIN32 */
    +
    +
    +  FT_LOCAL_DEF( void )
    +  ft_hb_funcs_init( struct AF_ModuleRec_  *af_module )
    +  {
    +    FT_Memory  memory = af_module->root.memory;
    +    FT_Error   error;
    +
    +    ft_hb_funcs_t                *funcs           = NULL;
    +    ft_hb_version_atleast_func_t  version_atleast = NULL;
    +
    +#ifdef _WIN32
    +    HANDLE  lib;
    +#  define DLSYM( lib, name ) \
    +            (ft_ ## name ## _func_t)GetProcAddress( lib, #name )
    +#else
    +    void  *lib;
    +#  define DLSYM( lib, name ) \
    +            (ft_ ## name ## _func_t)dlsym( lib, #name )
    +#endif
    +
    +
    +    af_module->hb_funcs = NULL;
    +
    +    if ( FT_NEW( funcs ) )
    +      return;
    +    FT_ZERO( funcs );
    +
    +#ifdef _WIN32
    +
    +    lib = LoadLibraryA( FT_LIBHARFBUZZ );
    +    if ( !lib )
    +      goto Fail;
    +    version_atleast = DLSYM( lib, hb_version_atleast );
    +
    +#else /* !_WIN32 */
    +
    +#  ifdef RTLD_DEFAULT
    +#    define FT_RTLD_FLAGS RTLD_LAZY | RTLD_GLOBAL
    +    lib             = RTLD_DEFAULT;
    +    version_atleast = DLSYM( lib, hb_version_atleast );
    +#  else
    +#    define FT_RTLD_FLAGS RTLD_LAZY
    +#  endif
    +
    +    if ( !version_atleast )
    +    {
    +      /* Load the HarfBuzz library.
    +       *
    +       * We never close the library, since we opened it with RTLD_GLOBAL.
    +       * This is important for the case where we are using HarfBuzz as a
    +       * shared library, and we want to use the symbols from the library in
    +       * other shared libraries or clients.  HarfBuzz holds onto global
    +       * variables, and closing the library will cause them to be
    +       * invalidated.
    +       */
    +      lib = dlopen( FT_LIBHARFBUZZ, FT_RTLD_FLAGS );
    +      if ( !lib )
    +        goto Fail;
    +      version_atleast = DLSYM( lib, hb_version_atleast );
    +    }
    +
    +#endif /* !_WIN32 */
    +
    +    if ( !version_atleast )
    +      goto Fail;
    +
    +    /* Load all symbols we use. */
    +#define HB_EXTERN( ret, name, args )  \
    +  {                                   \
    +    funcs->name = DLSYM( lib, name ); \
    +    if ( !funcs->name )               \
    +      goto Fail;                      \
    +  }
    +#include "ft-hb-decls.h"
    +#undef HB_EXTERN
    +
    +#undef DLSYM
    +
    +    af_module->hb_funcs = funcs;
    +    return;
    +
    +  Fail:
    +    if ( funcs )
    +      FT_FREE( funcs );
    +  }
    +
    +
    +  FT_LOCAL_DEF( void )
    +  ft_hb_funcs_done( struct AF_ModuleRec_  *af_module )
    +  {
    +    FT_Memory  memory = af_module->root.memory;
    +
    +
    +    if ( af_module->hb_funcs )
    +    {
    +      FT_FREE( af_module->hb_funcs );
    +      af_module->hb_funcs = NULL;
    +    }
    +  }
    +
    +
    +  FT_LOCAL_DEF( FT_Bool )
    +  ft_hb_enabled( struct AF_FaceGlobalsRec_  *globals )
    +  {
    +    return globals->module->hb_funcs != NULL;
    +  }
    +
    +#ifndef _WIN32
    +#  if defined( __GNUC__ )
    +#    pragma GCC diagnostic pop
    +#  endif
    +#endif
    +
    +#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */
    +
    +  FT_LOCAL_DEF( FT_Bool )
    +  ft_hb_enabled( struct AF_FaceGlobalsRec_  *globals )
    +  {
    +    FT_UNUSED( globals );
    +
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +    return TRUE;
    +#else
    +    return FALSE;
    +#endif
    +  }
    +
    +#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */
    +
    +
    +/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.h b/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.h
    new file mode 100644
    index 00000000000..95914deb8d3
    --- /dev/null
    +++ b/src/java.desktop/share/native/libfreetype/src/autofit/ft-hb.h
    @@ -0,0 +1,82 @@
    +/****************************************************************************
    + *
    + * ft-hb.h
    + *
    + *   FreeType-HarfBuzz bridge (specification).
    + *
    + * Copyright (C) 2025 by
    + * Behdad Esfahbod.
    + *
    + * This file is part of the FreeType project, and may only be used,
    + * modified, and distributed under the terms of the FreeType project
    + * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    + * this file you indicate that you have read the license and
    + * understand and accept it fully.
    + *
    + */
    +
    +
    +#ifndef FT_HB_H
    +#define FT_HB_H
    +
    +#include 
    +#include 
    +
    +
    +FT_BEGIN_HEADER
    +
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    +
    +#  include "ft-hb-types.h"
    +
    +#  ifdef FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC
    +
    +#    define HB_EXTERN( ret, name, args ) \
    +              typedef ret (*ft_ ## name ## _func_t) args;
    +#    include "ft-hb-decls.h"
    +#    undef HB_EXTERN
    +
    +  typedef struct ft_hb_funcs_t
    +  {
    +#    define HB_EXTERN( ret, name, args ) \
    +              ft_ ## name ## _func_t  name;
    +#    include "ft-hb-decls.h"
    +#    undef HB_EXTERN
    +  } ft_hb_funcs_t;
    +
    +  struct  AF_ModuleRec_;
    +
    +  FT_LOCAL( void )
    +  ft_hb_funcs_init( struct AF_ModuleRec_  *af_module );
    +
    +  FT_LOCAL( void )
    +  ft_hb_funcs_done( struct AF_ModuleRec_  *af_module );
    +
    +#    define hb( x )  globals->module->hb_funcs->hb_ ## x
    +
    +#  else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */
    +
    +#    define HB_EXTERN( ret, name, args ) \
    +              ret name args;
    +#    include "ft-hb-decls.h"
    +#    undef HB_EXTERN
    +
    +#    define hb( x )  hb_ ## x
    +
    +#  endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */
    +
    +#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */
    +
    +
    +  struct AF_FaceGlobalsRec_;
    +
    +  FT_LOCAL( FT_Bool )
    +  ft_hb_enabled( struct AF_FaceGlobalsRec_  *globals );
    +
    +
    +FT_END_HEADER
    +
    +#endif /* FT_HB_H */
    +
    +
    +/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
    index 717f7d08b35..7b965c62d58 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c
    @@ -4,7 +4,7 @@
      *
      *   Quick computation of advance widths (body).
      *
    - * Copyright (C) 2008-2024 by
    + * Copyright (C) 2008-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -20,6 +20,7 @@
     
     #include 
     #include 
    +#include 
     
     
       static FT_Error
    @@ -47,11 +48,43 @@
         /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c)        */
     
         for ( nn = 0; nn < count; nn++ )
    -      advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
    +      advances[nn] = FT_MulFix( 1024 * advances[nn], scale );
     
         return FT_Err_Ok;
       }
     
    +  /* loading (and hinting) to calculate the advances is slow  */
    +  /* unless TrueType hdmx table is provided as an accelerator */
    +  static FT_Error
    +  ft_load_advances( FT_Face   face,
    +                    FT_UInt   gindex,
    +                    FT_UInt   count,
    +                    FT_Int32  flags,
    +                    FT_Fixed  *padvances )
    +  {
    +    FT_UInt   nn;
    +    FT_Error  error   = FT_Err_Ok;
    +    FT_Pos    factor  = flags & FT_LOAD_NO_SCALE ? 1 : 1024;
    +    FT_Pos*   advance = flags & FT_LOAD_VERTICAL_LAYOUT
    +                          ? &face->glyph->advance.y
    +                          : &face->glyph->advance.x;
    +
    +
    +    flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
    +
    +    for ( nn = 0; nn < count; nn++ )
    +    {
    +      error = FT_Load_Glyph( face, gindex + nn, flags );
    +      if ( error )
    +        break;
    +
    +      /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
    +      padvances[nn] = *advance * factor;
    +    }
    +
    +    return error;
    +  }
    +
     
        /* at the moment, we can perform fast advance retrieval only in */
        /* the following cases:                                         */
    @@ -102,7 +135,10 @@
             return error;
         }
     
    -    return FT_Get_Advances( face, gindex, 1, flags, padvance );
    +    if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
    +      return FT_THROW( Unimplemented_Feature );
    +
    +    return ft_load_advances( face, gindex, 1, flags, padvance );
       }
     
     
    @@ -115,12 +151,9 @@
                        FT_Int32   flags,
                        FT_Fixed  *padvances )
       {
    -    FT_Error  error = FT_Err_Ok;
    -
         FT_Face_GetAdvancesFunc  func;
     
    -    FT_UInt  num, end, nn;
    -    FT_Int   factor;
    +    FT_UInt  num, end;
     
     
         if ( !face )
    @@ -140,6 +173,9 @@
         func = face->driver->clazz->get_advances;
         if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
         {
    +      FT_Error  error;
    +
    +
           error = func( face, start, count, flags, padvances );
           if ( !error )
             return ft_face_scale_advances_( face, padvances, count, flags );
    @@ -148,26 +184,10 @@
             return error;
         }
     
    -    error = FT_Err_Ok;
    -
         if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
           return FT_THROW( Unimplemented_Feature );
     
    -    flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
    -    factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
    -    for ( nn = 0; nn < count; nn++ )
    -    {
    -      error = FT_Load_Glyph( face, start + nn, flags );
    -      if ( error )
    -        break;
    -
    -      /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
    -      padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
    -                      ? face->glyph->advance.y * factor
    -                      : face->glyph->advance.x * factor;
    -    }
    -
    -    return error;
    +    return ft_load_advances( face, start, count, flags, padvances );
       }
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbase.h b/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
    index 1d98b26dd51..66f091165fe 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftbase.h
    @@ -4,7 +4,7 @@
      *
      *   Private functions used in the `base' module (specification).
      *
    - * Copyright (C) 2008-2024 by
    + * Copyright (C) 2008-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -34,7 +34,7 @@ FT_BEGIN_HEADER
     #ifdef FT_CONFIG_OPTION_MAC_FONTS
     
       /* MacOS resource fork cannot exceed 16MB at least for Carbon code; */
    -  /* see https://support.microsoft.com/en-us/kb/130437                */
    +  /* see https://jeffpar.github.io/kbarchive/kb/130/Q130437/          */
     #define FT_MAC_RFORK_MAX_LEN  0x00FFFFFFUL
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c b/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
    index d6aa5d56df8..feccdee5dd7 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType bbox computation (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
    index 4be145679fd..364f881e435 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility functions for bitmaps (body).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -876,13 +876,13 @@
     
     #ifdef FT_DEBUG_LEVEL_TRACE
         FT_TRACE5(( "FT_Bitmap_Blend:\n" ));
    -    FT_TRACE5(( "  source bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
    +    FT_TRACE5(( "  source bitmap: (%ld, %ld) -- (%ld, %ld); %u x %u\n",
           source_llx / 64, source_lly / 64,
           source_urx / 64, source_ury / 64,
           source_->width, source_->rows ));
     
         if ( target->width && target->rows )
    -      FT_TRACE5(( "  target bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
    +      FT_TRACE5(( "  target bitmap: (%ld, %ld) -- (%ld, %ld); %u x %u\n",
             target_llx / 64, target_lly / 64,
             target_urx / 64, target_ury / 64,
             target->width, target->rows ));
    @@ -890,7 +890,7 @@
           FT_TRACE5(( "  target bitmap: empty\n" ));
     
         if ( final_width && final_rows )
    -      FT_TRACE5(( "  final bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
    +      FT_TRACE5(( "  final bitmap: (%ld, %ld) -- (%ld, %ld); %u x %u\n",
             final_llx / 64, final_lly / 64,
             final_urx / 64, final_ury / 64,
             final_width, final_rows ));
    @@ -922,14 +922,7 @@
           target->pitch      = (int)final_width * 4;
           target->num_grays  = 256;
     
    -      if ( FT_LONG_MAX / target->pitch < (int)target->rows )
    -      {
    -        FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
    -                     final_width, final_rows ));
    -        return FT_THROW( Invalid_Argument );
    -      }
    -
    -      if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) )
    +      if ( FT_ALLOC_MULT( target->buffer, target->rows, target->pitch ) )
             return error;
     
           free_target_bitmap_on_error = 1;
    @@ -950,16 +943,9 @@
     
           new_pitch = (int)final_width * 4;
     
    -      if ( FT_LONG_MAX / new_pitch < (int)final_rows )
    -      {
    -        FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
    -                     final_width, final_rows ));
    -        return FT_THROW( Invalid_Argument );
    -      }
    -
           /* TODO: provide an in-buffer solution for large bitmaps */
           /*       to avoid allocation of a new buffer             */
    -      if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) )
    +      if ( FT_ALLOC_MULT( buffer, final_rows, new_pitch ) )
             goto Error;
     
           /* copy data to new buffer */
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c b/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
    index 92de09ed877..7d6e12e2543 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c
    @@ -4,7 +4,7 @@
      *
      *   Arithmetic computations (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -38,24 +38,11 @@
     #include 
     #include 
     
    -
    -#ifdef FT_MULFIX_ASSEMBLER
    -#undef FT_MulFix
    +  /* cancel inlining macro from internal/ftcalc.h */
    +#ifdef FT_MulFix
    +#  undef FT_MulFix
     #endif
     
    -/* we need to emulate a 64-bit data type if a real one isn't available */
    -
    -#ifndef FT_INT64
    -
    -  typedef struct  FT_Int64_
    -  {
    -    FT_UInt32  lo;
    -    FT_UInt32  hi;
    -
    -  } FT_Int64;
    -
    -#endif /* !FT_INT64 */
    -
     
       /**************************************************************************
        *
    @@ -88,7 +75,7 @@
       FT_EXPORT_DEF( FT_Fixed )
       FT_RoundFix( FT_Fixed  a )
       {
    -    return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
    +    return ADD_LONG( a, 0x8000L - ( a < 0 ) ) & ~0xFFFFL;
       }
     
     
    @@ -97,7 +84,7 @@
       FT_EXPORT_DEF( FT_Fixed )
       FT_CeilFix( FT_Fixed  a )
       {
    -    return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
    +    return ADD_LONG( a, 0xFFFFL ) & ~0xFFFFL;
       }
     
     
    @@ -225,18 +212,18 @@
       FT_MulFix( FT_Long  a_,
                  FT_Long  b_ )
       {
    -#ifdef FT_MULFIX_ASSEMBLER
    +#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
     
    -    return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
    +    return FT_MulFix_64( a_, b_ );
     
     #else
     
    -    FT_Int64  ab = (FT_Int64)a_ * (FT_Int64)b_;
    +    FT_Int64  ab = MUL_INT64( a_, b_ );
     
         /* this requires arithmetic right shift of signed numbers */
    -    return (FT_Long)( ( ab + 0x8000L - ( ab < 0 ) ) >> 16 );
    +    return (FT_Long)( ( ab + 0x8000L + ( ab >> 63 ) ) >> 16 );
     
    -#endif /* FT_MULFIX_ASSEMBLER */
    +#endif /* FT_CONFIG_OPTION_INLINE_MULFIX */
       }
     
     
    @@ -975,43 +962,36 @@
     
     #else
     
    -    FT_Int  result;
    +    FT_Int64  z1, z2;
    +    FT_Int    result;
     
     
    -    if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
    -         ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
    +    if ( (FT_ULong)FT_ABS( in_x ) + (FT_ULong)FT_ABS( out_y ) <= 92681UL )
         {
    -      FT_Long  z1 = MUL_LONG( in_x, out_y );
    -      FT_Long  z2 = MUL_LONG( in_y, out_x );
    -
    -
    -      if ( z1 > z2 )
    -        result = +1;
    -      else if ( z1 < z2 )
    -        result = -1;
    -      else
    -        result = 0;
    +      z1.lo = (FT_UInt32)in_x * (FT_UInt32)out_y;
    +      z1.hi = (FT_UInt32)( (FT_Int32)z1.lo >> 31 );  /* sign-expansion */
         }
    -    else /* products might overflow 32 bits */
    -    {
    -      FT_Int64  z1, z2;
    -
    -
    -      /* XXX: this function does not allow 64-bit arguments */
    +    else
           ft_multo64( (FT_UInt32)in_x, (FT_UInt32)out_y, &z1 );
    +
    +    if ( (FT_ULong)FT_ABS( in_y ) + (FT_ULong)FT_ABS( out_x ) <= 92681UL )
    +    {
    +      z2.lo = (FT_UInt32)in_y * (FT_UInt32)out_x;
    +      z2.hi = (FT_UInt32)( (FT_Int32)z2.lo >> 31 );  /* sign-expansion */
    +    }
    +    else
           ft_multo64( (FT_UInt32)in_y, (FT_UInt32)out_x, &z2 );
     
    -      if ( z1.hi > z2.hi )
    -        result = +1;
    -      else if ( z1.hi < z2.hi )
    -        result = -1;
    -      else if ( z1.lo > z2.lo )
    -        result = +1;
    -      else if ( z1.lo < z2.lo )
    -        result = -1;
    -      else
    -        result = 0;
    -    }
    +    if      ( (FT_Int32)z1.hi > (FT_Int32)z2.hi )
    +      result = +1;
    +    else if ( (FT_Int32)z1.hi < (FT_Int32)z2.hi )
    +      result = -1;
    +    else if ( z1.lo > z2.lo )
    +      result = +1;
    +    else if ( z1.lo < z2.lo )
    +      result = -1;
    +    else
    +      result =  0;
     
         /* XXX: only the sign of return value, +1/0/-1 must be used */
         return result;
    @@ -1065,62 +1045,4 @@
       }
     
     
    -  FT_BASE_DEF( FT_Int32 )
    -  FT_MulAddFix( FT_Fixed*  s,
    -                FT_Int32*  f,
    -                FT_UInt    count )
    -  {
    -    FT_UInt   i;
    -    FT_Int64  temp;
    -
    -
    -#ifdef FT_INT64
    -    temp = 0;
    -
    -    for ( i = 0; i < count; ++i )
    -      temp += (FT_Int64)s[i] * f[i];
    -
    -    return (FT_Int32)( ( temp + 0x8000 ) >> 16 );
    -#else
    -    temp.hi = 0;
    -    temp.lo = 0;
    -
    -    for ( i = 0; i < count; ++i )
    -    {
    -      FT_Int64  multResult;
    -
    -      FT_Int     sign  = 1;
    -      FT_UInt32  carry = 0;
    -
    -      FT_UInt32  scalar;
    -      FT_UInt32  factor;
    -
    -
    -      FT_MOVE_SIGN( FT_UInt32, s[i], scalar, sign );
    -      FT_MOVE_SIGN( FT_UInt32, f[i], factor, sign );
    -
    -      ft_multo64( scalar, factor, &multResult );
    -
    -      if ( sign < 0 )
    -      {
    -        /* Emulated `FT_Int64` negation. */
    -        carry = ( multResult.lo == 0 );
    -
    -        multResult.lo = ~multResult.lo + 1;
    -        multResult.hi = ~multResult.hi + carry;
    -      }
    -
    -      FT_Add64( &temp, &multResult, &temp );
    -    }
    -
    -    /* Shift and round value. */
    -    return (FT_Int32)( ( ( temp.hi << 16 ) | ( temp.lo >> 16 ) )
    -                                     + ( 1 & ( temp.lo >> 15 ) ) );
    -
    -
    -#endif /* !FT_INT64 */
    -
    -  }
    -
    -
     /* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcid.c b/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
    index 4f2deb19a05..35cd0fcd2be 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftcid.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for accessing CID font information.
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * Derek Clegg and Michael Toftdal.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c b/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
    index c6bf2a3cd1a..90b02b7d2de 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType's glyph color management (body).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -56,9 +56,7 @@
                          FT_Color*  *apalette )
       {
         FT_Error  error;
    -
    -    TT_Face       ttface;
    -    SFNT_Service  sfnt;
    +    TT_Face   ttface = (TT_Face)face;
     
     
         if ( !face )
    @@ -72,14 +70,17 @@
           return FT_Err_Ok;
         }
     
    -    ttface = (TT_Face)face;
    -    sfnt   = (SFNT_Service)ttface->sfnt;
    +    if ( palette_index != ttface->palette_index )
    +    {
    +      SFNT_Service  sfnt = (SFNT_Service)ttface->sfnt;
     
    -    error = sfnt->set_palette( ttface, palette_index );
    -    if ( error )
    -      return error;
     
    -    ttface->palette_index = palette_index;
    +      error = sfnt->set_palette( ttface, palette_index );
    +      if ( error )
    +        return error;
    +
    +      ttface->palette_index = palette_index;
    +    }
     
         if ( apalette )
           *apalette = ttface->palette;
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c b/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
    index 902a5dc8bbc..7f54e759b16 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c
    @@ -4,7 +4,7 @@
      *
      *   Memory debugger (body).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -139,7 +139,6 @@
       } FT_MemTableRec;
     
     
    -#define FT_MEM_SIZE_MIN  7
     #define FT_MEM_SIZE_MAX  13845163
     
     #define FT_FILENAME( x )  ( (x) ? (x) : "unknown file" )
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c b/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
    index 11307eaace4..c615f29e521 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
    @@ -4,7 +4,7 @@
      *
      *   Debugging and logging component (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -64,7 +64,7 @@
        *    with the actual log message if set to true.
        *
        * 5. The flag `ft_timestamp_flag` prints time along with the actual log
    -   *    message if set to ture.
    +   *    message if set to true.
        *
        * 6. `ft_have_newline_char` is used to differentiate between a log
        *    message with and without a trailing newline character.
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c b/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
    index 77b4089e7e2..7f4f14ffdb0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility file for font formats (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c b/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
    index 1565c3b7e25..3a95752ffaa 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility file to access FSType data (body).
      *
    - * Copyright (C) 2008-2024 by
    + * Copyright (C) 2008-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c b/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
    index c63d30e978c..2202240b57e 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c
    @@ -4,7 +4,7 @@
      *
      *   Access of TrueType's `gasp' table (body).
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c b/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
    index 484d98f1722..47781bc4d5c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph loader (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
    index 1b5849f99af..6138cfeec2c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType convenience functions to handle glyphs (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -62,7 +62,7 @@
                             FT_GlyphSlot  slot )
       {
         FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;
    -    FT_Error        error   = FT_Err_Ok;
    +    FT_Error        error;
         FT_Library      library = FT_GLYPH( glyph )->library;
     
     
    @@ -75,17 +75,8 @@
         glyph->left = slot->bitmap_left;
         glyph->top  = slot->bitmap_top;
     
    -    /* do lazy copying whenever possible */
    -    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
    -    {
    -      glyph->bitmap          = slot->bitmap;
    -      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
    -    }
    -    else
    -    {
    -      FT_Bitmap_Init( &glyph->bitmap );
    -      error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
    -    }
    +    FT_Bitmap_Init( &glyph->bitmap );
    +    error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
     
       Exit:
         return error;
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/fthash.c b/src/java.desktop/share/native/libfreetype/src/base/fthash.c
    index 313bbbb4b27..ab248ace8bd 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/fthash.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/fthash.c
    @@ -41,6 +41,7 @@
     
     #include 
     #include 
    +#include 
     
     
     #define INITIAL_HT_SIZE  241
    @@ -233,7 +234,8 @@
       hash_insert( FT_Hashkey  key,
                    size_t      data,
                    FT_Hash     hash,
    -               FT_Memory   memory )
    +               FT_Memory   memory,
    +               FT_Bool     overwrite )
       {
         FT_Hashnode   nn;
         FT_Hashnode*  bp    = hash_bucket( key, hash );
    @@ -259,7 +261,7 @@
     
           hash->used++;
         }
    -    else
    +    else if ( overwrite )
           nn->data = data;
     
       Exit:
    @@ -278,7 +280,7 @@
     
         hk.str = key;
     
    -    return hash_insert( hk, data, hash, memory );
    +    return hash_insert( hk, data, hash, memory, TRUE );
       }
     
     
    @@ -293,7 +295,37 @@
     
         hk.num = num;
     
    -    return hash_insert( hk, data, hash, memory );
    +    return hash_insert( hk, data, hash, memory, TRUE );
    +  }
    +
    +
    +  FT_Error
    +  ft_hash_str_insert_no_overwrite( const char*  key,
    +                                   size_t       data,
    +                                   FT_Hash      hash,
    +                                   FT_Memory    memory )
    +  {
    +    FT_Hashkey  hk;
    +
    +
    +    hk.str = key;
    +
    +    return hash_insert( hk, data, hash, memory, FALSE );
    +  }
    +
    +
    +  FT_Error
    +  ft_hash_num_insert_no_overwrite( FT_Int     num,
    +                                   size_t     data,
    +                                   FT_Hash    hash,
    +                                   FT_Memory  memory )
    +  {
    +    FT_Hashkey  hk;
    +
    +
    +    hk.num = num;
    +
    +    return hash_insert( hk, data, hash, memory, FALSE );
       }
     
     
    @@ -335,4 +367,68 @@
       }
     
     
    +  FT_Bool
    +  ft_hash_num_iterator( FT_UInt  *idx,
    +                        FT_Int   *key,
    +                        size_t   *value,
    +                        FT_Hash   hash )
    +  {
    +    FT_Hashnode  nn = NULL;
    +
    +
    +    while ( 1 )
    +    {
    +      if ( *idx >= hash->size )
    +        return 0;
    +
    +      nn = hash->table[*idx];
    +      if ( nn )
    +        break;
    +
    +      (*idx)++;
    +    }
    +
    +    if ( key )
    +      *key = nn->key.num;
    +    if ( value )
    +      *value = nn->data;
    +
    +    (*idx)++;
    +
    +    return 1;
    +  }
    +
    +
    +  FT_Bool
    +  ft_hash_str_iterator( FT_UInt      *idx,
    +                        const char*  *key,
    +                        size_t       *value,
    +                        FT_Hash       hash )
    +  {
    +    FT_Hashnode  nn = NULL;
    +
    +
    +    while ( 1 )
    +    {
    +      if ( *idx >= hash->size )
    +        return 0;
    +
    +      nn = hash->table[*idx];
    +      if ( nn )
    +        break;
    +
    +      (*idx)++;
    +    }
    +
    +    if ( key )
    +      *key = nn->key.str;
    +    if ( value )
    +      *value = nn->data;
    +
    +    (*idx)++;
    +
    +    return 1;
    +  }
    +
    +
     /* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftinit.c b/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
    index 9a6c00e13ef..37d7f87bcb9 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftinit.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType initialization layer (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
    index 1e69d4da70f..51c6fd48a1b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType API for color filtering of subpixel bitmap glyphs (body).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -25,265 +25,28 @@
     
     #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
     
    -/* define USE_LEGACY to implement the legacy filter */
    -#define  USE_LEGACY
    -
    -#define FT_SHIFTCLAMP( x )  ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) )
    -
    -
    -  /* add padding according to filter weights */
    +  /* add padding sufficient for a 5-tap filter, */
    +  /* which is 2/3 of a pixel                    */
       FT_BASE_DEF( void )
       ft_lcd_padding( FT_BBox*        cbox,
                       FT_GlyphSlot    slot,
                       FT_Render_Mode  mode )
       {
    -    FT_Byte*                 lcd_weights;
    -    FT_Bitmap_LcdFilterFunc  lcd_filter_func;
    +    FT_UNUSED( slot );
     
    -
    -    /* Per-face LCD filtering takes priority if set up. */
    -    if ( slot->face && slot->face->internal->lcd_filter_func )
    +    if ( mode == FT_RENDER_MODE_LCD )
         {
    -      lcd_weights     = slot->face->internal->lcd_weights;
    -      lcd_filter_func = slot->face->internal->lcd_filter_func;
    +      cbox->xMin -= 43;
    +      cbox->xMax += 43;
         }
    -    else
    +    else if ( mode == FT_RENDER_MODE_LCD_V )
         {
    -      lcd_weights     = slot->library->lcd_weights;
    -      lcd_filter_func = slot->library->lcd_filter_func;
    -    }
    -
    -    if ( lcd_filter_func == ft_lcd_filter_fir )
    -    {
    -      if ( mode == FT_RENDER_MODE_LCD )
    -      {
    -        cbox->xMin -= lcd_weights[0] ? 43 :
    -                      lcd_weights[1] ? 22 : 0;
    -        cbox->xMax += lcd_weights[4] ? 43 :
    -                      lcd_weights[3] ? 22 : 0;
    -      }
    -      else if ( mode == FT_RENDER_MODE_LCD_V )
    -      {
    -        cbox->yMin -= lcd_weights[0] ? 43 :
    -                      lcd_weights[1] ? 22 : 0;
    -        cbox->yMax += lcd_weights[4] ? 43 :
    -                      lcd_weights[3] ? 22 : 0;
    -      }
    +      cbox->yMin -= 43;
    +      cbox->yMax += 43;
         }
       }
     
     
    -  /* FIR filter used by the default and light filters */
    -  FT_BASE_DEF( void )
    -  ft_lcd_filter_fir( FT_Bitmap*           bitmap,
    -                     FT_LcdFiveTapFilter  weights )
    -  {
    -    FT_UInt   width  = (FT_UInt)bitmap->width;
    -    FT_UInt   height = (FT_UInt)bitmap->rows;
    -    FT_Int    pitch  = bitmap->pitch;
    -    FT_Byte*  origin = bitmap->buffer;
    -    FT_Byte   mode   = bitmap->pixel_mode;
    -
    -
    -    /* take care of bitmap flow */
    -    if ( pitch > 0 && height > 0 )
    -      origin += pitch * (FT_Int)( height - 1 );
    -
    -    /* horizontal in-place FIR filter */
    -    if ( mode == FT_PIXEL_MODE_LCD && width >= 2 )
    -    {
    -      FT_Byte*  line = origin;
    -
    -
    -      /* `fir' must be at least 32 bit wide, since the sum of */
    -      /* the values in `weights' can exceed 0xFF              */
    -
    -      for ( ; height > 0; height--, line -= pitch )
    -      {
    -        FT_UInt  fir[5];
    -        FT_UInt  val, xx;
    -
    -
    -        val    = line[0];
    -        fir[2] = weights[2] * val;
    -        fir[3] = weights[3] * val;
    -        fir[4] = weights[4] * val;
    -
    -        val    = line[1];
    -        fir[1] = fir[2] + weights[1] * val;
    -        fir[2] = fir[3] + weights[2] * val;
    -        fir[3] = fir[4] + weights[3] * val;
    -        fir[4] =          weights[4] * val;
    -
    -        for ( xx = 2; xx < width; xx++ )
    -        {
    -          val    = line[xx];
    -          fir[0] = fir[1] + weights[0] * val;
    -          fir[1] = fir[2] + weights[1] * val;
    -          fir[2] = fir[3] + weights[2] * val;
    -          fir[3] = fir[4] + weights[3] * val;
    -          fir[4] =          weights[4] * val;
    -
    -          line[xx - 2] = FT_SHIFTCLAMP( fir[0] );
    -        }
    -
    -        line[xx - 2] = FT_SHIFTCLAMP( fir[1] );
    -        line[xx - 1] = FT_SHIFTCLAMP( fir[2] );
    -      }
    -    }
    -
    -    /* vertical in-place FIR filter */
    -    else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 )
    -    {
    -      FT_Byte*  column = origin;
    -
    -
    -      for ( ; width > 0; width--, column++ )
    -      {
    -        FT_Byte*  col = column;
    -        FT_UInt   fir[5];
    -        FT_UInt   val, yy;
    -
    -
    -        val    = col[0];
    -        fir[2] = weights[2] * val;
    -        fir[3] = weights[3] * val;
    -        fir[4] = weights[4] * val;
    -        col   -= pitch;
    -
    -        val    = col[0];
    -        fir[1] = fir[2] + weights[1] * val;
    -        fir[2] = fir[3] + weights[2] * val;
    -        fir[3] = fir[4] + weights[3] * val;
    -        fir[4] =          weights[4] * val;
    -        col   -= pitch;
    -
    -        for ( yy = 2; yy < height; yy++, col -= pitch )
    -        {
    -          val    = col[0];
    -          fir[0] = fir[1] + weights[0] * val;
    -          fir[1] = fir[2] + weights[1] * val;
    -          fir[2] = fir[3] + weights[2] * val;
    -          fir[3] = fir[4] + weights[3] * val;
    -          fir[4] =          weights[4] * val;
    -
    -          col[pitch * 2]  = FT_SHIFTCLAMP( fir[0] );
    -        }
    -
    -        col[pitch * 2]  = FT_SHIFTCLAMP( fir[1] );
    -        col[pitch]      = FT_SHIFTCLAMP( fir[2] );
    -      }
    -    }
    -  }
    -
    -
    -#ifdef USE_LEGACY
    -
    -  /* intra-pixel filter used by the legacy filter */
    -  static void
    -  _ft_lcd_filter_legacy( FT_Bitmap*      bitmap,
    -                         FT_Byte*        weights )
    -  {
    -    FT_UInt   width  = (FT_UInt)bitmap->width;
    -    FT_UInt   height = (FT_UInt)bitmap->rows;
    -    FT_Int    pitch  = bitmap->pitch;
    -    FT_Byte*  origin = bitmap->buffer;
    -    FT_Byte   mode   = bitmap->pixel_mode;
    -
    -    static const unsigned int  filters[3][3] =
    -    {
    -      { 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 },
    -      { 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 },
    -      { 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
    -    };
    -
    -    FT_UNUSED( weights );
    -
    -
    -    /* take care of bitmap flow */
    -    if ( pitch > 0 && height > 0 )
    -      origin += pitch * (FT_Int)( height - 1 );
    -
    -    /* horizontal in-place intra-pixel filter */
    -    if ( mode == FT_PIXEL_MODE_LCD && width >= 3 )
    -    {
    -      FT_Byte*  line = origin;
    -
    -
    -      for ( ; height > 0; height--, line -= pitch )
    -      {
    -        FT_UInt  xx;
    -
    -
    -        for ( xx = 0; xx < width; xx += 3 )
    -        {
    -          FT_UInt  r, g, b;
    -          FT_UInt  p;
    -
    -
    -          p  = line[xx];
    -          r  = filters[0][0] * p;
    -          g  = filters[0][1] * p;
    -          b  = filters[0][2] * p;
    -
    -          p  = line[xx + 1];
    -          r += filters[1][0] * p;
    -          g += filters[1][1] * p;
    -          b += filters[1][2] * p;
    -
    -          p  = line[xx + 2];
    -          r += filters[2][0] * p;
    -          g += filters[2][1] * p;
    -          b += filters[2][2] * p;
    -
    -          line[xx]     = (FT_Byte)( r / 65536 );
    -          line[xx + 1] = (FT_Byte)( g / 65536 );
    -          line[xx + 2] = (FT_Byte)( b / 65536 );
    -        }
    -      }
    -    }
    -    else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 )
    -    {
    -      FT_Byte*  column = origin;
    -
    -
    -      for ( ; width > 0; width--, column++ )
    -      {
    -        FT_Byte*  col = column - 2 * pitch;
    -
    -
    -        for ( ; height > 0; height -= 3, col -= 3 * pitch )
    -        {
    -          FT_UInt  r, g, b;
    -          FT_UInt  p;
    -
    -
    -          p  = col[0];
    -          r  = filters[0][0] * p;
    -          g  = filters[0][1] * p;
    -          b  = filters[0][2] * p;
    -
    -          p  = col[pitch];
    -          r += filters[1][0] * p;
    -          g += filters[1][1] * p;
    -          b += filters[1][2] * p;
    -
    -          p  = col[pitch * 2];
    -          r += filters[2][0] * p;
    -          g += filters[2][1] * p;
    -          b += filters[2][2] * p;
    -
    -          col[0]         = (FT_Byte)( r / 65536 );
    -          col[pitch]     = (FT_Byte)( g / 65536 );
    -          col[pitch * 2] = (FT_Byte)( b / 65536 );
    -        }
    -      }
    -    }
    -  }
    -
    -#endif /* USE_LEGACY */
    -
    -
       /* documentation in ftlcdfil.h */
     
       FT_EXPORT_DEF( FT_Error )
    @@ -297,7 +60,6 @@
           return FT_THROW( Invalid_Argument );
     
         ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS );
    -    library->lcd_filter_func = ft_lcd_filter_fir;
     
         return FT_Err_Ok;
       }
    @@ -321,32 +83,23 @@
         switch ( filter )
         {
         case FT_LCD_FILTER_NONE:
    -      library->lcd_filter_func = NULL;
    +      ft_memset( library->lcd_weights,
    +                 0,
    +                 FT_LCD_FILTER_FIVE_TAPS );
           break;
     
         case FT_LCD_FILTER_DEFAULT:
           ft_memcpy( library->lcd_weights,
                      default_weights,
                      FT_LCD_FILTER_FIVE_TAPS );
    -      library->lcd_filter_func = ft_lcd_filter_fir;
           break;
     
         case FT_LCD_FILTER_LIGHT:
           ft_memcpy( library->lcd_weights,
                      light_weights,
                      FT_LCD_FILTER_FIVE_TAPS );
    -      library->lcd_filter_func = ft_lcd_filter_fir;
           break;
     
    -#ifdef USE_LEGACY
    -
    -    case FT_LCD_FILTER_LEGACY:
    -    case FT_LCD_FILTER_LEGACY1:
    -      library->lcd_filter_func = _ft_lcd_filter_legacy;
    -      break;
    -
    -#endif
    -
         default:
           return FT_THROW( Invalid_Argument );
         }
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftmac.c b/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
    index e8e35627b50..37d97be1838 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftmac.c
    @@ -8,7 +8,7 @@
      * This file is for Mac OS X only; see builds/mac/ftoldmac.c for
      * classic platforms built by MPW.
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftmm.c b/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
    index cc4ca22fba3..9e67001406c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftmm.c
    @@ -4,7 +4,7 @@
      *
      *   Multiple Master font support (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -292,6 +292,9 @@
         if ( num_coords && !coords )
           return FT_THROW( Invalid_Argument );
     
    +    if ( !num_coords && !FT_IS_VARIATION( face ) )
    +      return FT_Err_Ok;  /* nothing to be done */
    +
         error = ft_face_get_mm_service( face, &service_mm );
         if ( !error )
         {
    @@ -299,15 +302,21 @@
           if ( service_mm->set_var_design )
             error = service_mm->set_var_design( face, num_coords, coords );
     
    -      if ( !error || error == -1 )
    +      if ( !error || error == -1 || error == -2 )
           {
             FT_Bool  is_variation_old = FT_IS_VARIATION( face );
     
     
    -        if ( num_coords )
    -          face->face_flags |= FT_FACE_FLAG_VARIATION;
    -        else
    -          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    +        if ( error != -1 )
    +        {
    +          if ( error == -2 ) /* -2 means is_variable. */
    +          {
    +            face->face_flags |= FT_FACE_FLAG_VARIATION;
    +            error             = FT_Err_Ok;
    +          }
    +          else
    +            face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    +        }
     
             if ( service_mm->construct_ps_name )
             {
    @@ -474,15 +483,21 @@
           if ( service_mm->set_mm_blend )
             error = service_mm->set_mm_blend( face, num_coords, coords );
     
    -      if ( !error || error == -1 )
    +      if ( !error || error == -1 || error == -2 )
           {
             FT_Bool  is_variation_old = FT_IS_VARIATION( face );
     
     
    -        if ( num_coords )
    -          face->face_flags |= FT_FACE_FLAG_VARIATION;
    -        else
    -          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    +        if ( error != -1 )
    +        {
    +          if ( error == -2 ) /* -2 means is_variable. */
    +          {
    +            face->face_flags |= FT_FACE_FLAG_VARIATION;
    +            error             = FT_Err_Ok;
    +          }
    +          else
    +            face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    +        }
     
             if ( service_mm->construct_ps_name )
             {
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
    index 9b97820c379..323dd5efac2 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c
    @@ -4,7 +4,7 @@
      *
      *   The FreeType private base classes (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -524,12 +524,28 @@
         bitmap->rows       = (unsigned int)height;
         bitmap->pitch      = pitch;
     
    -    if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF ||
    -         pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF )
    +    /* Flag the bounding box size unsuitable for rendering. */
    +    /* FT_Renderer modules should check the return value.   */
    +    /* The limit is based on the ppem value when available. */
         {
    -      FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
    -                  pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
    -      return 1;
    +      FT_Face  face = slot->face;
    +      FT_Pos   xlim = 0x8000;
    +      FT_Pos   ylim = 0x8000;
    +
    +
    +      if ( face )
    +      {
    +        xlim = FT_MIN( xlim, 10 * face->size->metrics.x_ppem );
    +        ylim = FT_MIN( ylim, 10 * face->size->metrics.y_ppem );
    +      }
    +
    +      if ( pbox.xMin < -xlim || pbox.xMax >= xlim ||
    +           pbox.yMin < -ylim || pbox.yMax >= ylim )
    +      {
    +        FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
    +                    pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
    +        return 1;
    +      }
         }
     
         return 0;
    @@ -549,8 +565,7 @@
     
     
       FT_BASE_DEF( FT_Error )
    -  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
    -                             FT_ULong      size )
    +  ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot )
       {
         FT_Memory  memory = FT_FACE_MEMORY( slot->face );
         FT_Error   error;
    @@ -561,7 +576,10 @@
         else
           slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
     
    -    FT_MEM_ALLOC( slot->bitmap.buffer, size );
    +    /* dimensions must be preset */
    +    FT_MEM_ALLOC_MULT( slot->bitmap.buffer,
    +                       slot->bitmap.rows,
    +                       slot->bitmap.pitch );
         return error;
       }
     
    @@ -905,7 +923,6 @@
         FT_Library    library;
         FT_Bool       autohint = FALSE;
         FT_Module     hinter;
    -    TT_Face       ttface = (TT_Face)face;
     
     
         if ( !face || !face->size || !face->glyph )
    @@ -983,6 +1000,7 @@
           {
             FT_Render_Mode  mode = FT_LOAD_TARGET_MODE( load_flags );
             FT_Bool         is_light_type1;
    +        TT_Face         ttface = (TT_Face)face;
     
     
             /* only the new Adobe engine (for both CFF and Type 1) is `light'; */
    @@ -994,8 +1012,7 @@
             /* the check for `num_locations' assures that we actually    */
             /* test for instructions in a TTF and not in a CFF-based OTF */
             /*                                                           */
    -        /* since `maxSizeOfInstructions' might be unreliable, we     */
    -        /* check the size of the `fpgm' and `prep' tables, too --    */
    +        /* we check the size of the `fpgm' and `prep' tables, too -- */
             /* the assumption is that there don't exist real TTFs where  */
             /* both `fpgm' and `prep' tables are missing                 */
             if ( ( mode == FT_RENDER_MODE_LIGHT           &&
    @@ -1003,9 +1020,8 @@
                      !is_light_type1                    ) )         ||
                  ( FT_IS_SFNT( face )                             &&
                    ttface->num_locations                          &&
    -               ttface->max_profile.maxSizeOfInstructions == 0 &&
                    ttface->font_program_size == 0                 &&
    -               ttface->cvt_program_size == 0                  ) )
    +               ttface->cvt_program_size <= 7                  ) )
               autohint = TRUE;
           }
         }
    @@ -1172,9 +1188,9 @@
         }
     
     #ifdef FT_DEBUG_LEVEL_TRACE
    -    FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n",
    +    FT_TRACE5(( "FT_Load_Glyph: index %u, flags 0x%x\n",
                     glyph_index, load_flags ));
    -    FT_TRACE5(( "  bitmap %dx%d %s, %s (mode %d)\n",
    +    FT_TRACE5(( "  bitmap %ux%u %s, %s (mode %d)\n",
                     slot->bitmap.width,
                     slot->bitmap.rows,
                     slot->outline.points ?
    @@ -1253,14 +1269,14 @@
         FT_Driver  driver = (FT_Driver)driver_;
     
     
    -    /* finalize client-specific data */
    -    if ( size->generic.finalizer )
    -      size->generic.finalizer( size );
    -
         /* finalize format-specific stuff */
         if ( driver->clazz->done_size )
           driver->clazz->done_size( size );
     
    +    /* finalize client-specific data */
    +    if ( size->generic.finalizer )
    +      size->generic.finalizer( size );
    +
         FT_FREE( size->internal );
         FT_FREE( size );
       }
    @@ -1322,10 +1338,6 @@
                           driver );
         face->size = NULL;
     
    -    /* now discard client data */
    -    if ( face->generic.finalizer )
    -      face->generic.finalizer( face );
    -
         /* discard charmaps */
         destroy_charmaps( face, memory );
     
    @@ -1340,6 +1352,10 @@
     
         face->stream = NULL;
     
    +    /* now discard client data */
    +    if ( face->generic.finalizer )
    +      face->generic.finalizer( face );
    +
         /* get rid of it */
         if ( face->internal )
         {
    @@ -1359,21 +1375,9 @@
       }
     
     
    -  /**************************************************************************
    -   *
    -   * @Function:
    -   *   find_unicode_charmap
    -   *
    -   * @Description:
    -   *   This function finds a Unicode charmap, if there is one.
    -   *   And if there is more than one, it tries to favour the more
    -   *   extensive one, i.e., one that supports UCS-4 against those which
    -   *   are limited to the BMP (said UCS-2 encoding.)
    -   *
    -   *   This function is called from open_face() (just below), and also
    -   *   from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ).
    -   */
    -  static FT_Error
    +  /* documentation is in ftobjs.h */
    +
    +  FT_BASE_DEF( FT_Error )
       find_unicode_charmap( FT_Face  face )
       {
         FT_CharMap*  first;
    @@ -1427,7 +1431,10 @@
             if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT &&
                    cur[0]->encoding_id == TT_MS_ID_UCS_4        )     ||
                  ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
    -               cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32    ) )
    +               cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32    ) ||
    +             ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
    +               cur[0]->encoding_id == TT_APPLE_ID_FULL_UNICODE  &&
    +               FT_Get_CMap_Format( cur[0] ) == 13               ) )
             {
               face->charmap = cur[0];
               return FT_Err_Ok;
    @@ -2125,7 +2132,7 @@
           if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
             goto Exit2;
     
    -      FT_TRACE3(( "    Load POST fragment #%d (%ld byte) to buffer"
    +      FT_TRACE3(( "    Load POST fragment #%d (%lu byte) to buffer"
                       " %p + 0x%08lx\n",
                       i, rlen, (void*)pfb_data, pfb_pos ));
     
    @@ -2398,7 +2405,7 @@
           is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i );
           if ( is_darwin_vfs && vfs_rfork_has_no_font )
           {
    -        FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
    +        FT_TRACE3(( "Skip rule %u: darwin vfs resource fork"
                         " is already checked and"
                         " no font is found\n",
                         i ));
    @@ -2407,7 +2414,7 @@
     
           if ( errors[i] )
           {
    -        FT_TRACE3(( "Error 0x%x has occurred in rule %d\n",
    +        FT_TRACE3(( "Error 0x%x has occurred in rule %u\n",
                         errors[i], i ));
             continue;
           }
    @@ -2415,7 +2422,7 @@
           args2.flags    = FT_OPEN_PATHNAME;
           args2.pathname = file_names[i] ? file_names[i] : args->pathname;
     
    -      FT_TRACE3(( "Try rule %d: %s (offset=%ld) ...",
    +      FT_TRACE3(( "Try rule %u: %s (offset=%ld) ...",
                       i, args2.pathname, offsets[i] ));
     
           error = FT_Stream_New( library, &args2, &stream2 );
    @@ -2812,11 +2819,6 @@
           internal->refcount = 1;
     
           internal->no_stem_darkening = -1;
    -
    -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    -      /* Per-face filtering can only be set up by FT_Face_Properties */
    -      internal->lcd_filter_func = NULL;
    -#endif
         }
     
         if ( aface )
    @@ -4046,18 +4048,8 @@
           }
           else if ( properties->tag == FT_PARAM_TAG_LCD_FILTER_WEIGHTS )
           {
    -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    -        if ( properties->data )
    -        {
    -          ft_memcpy( face->internal->lcd_weights,
    -                     properties->data,
    -                     FT_LCD_FILTER_FIVE_TAPS );
    -          face->internal->lcd_filter_func = ft_lcd_filter_fir;
    -        }
    -#else
             error = FT_THROW( Unimplemented_Feature );
             goto Exit;
    -#endif
           }
           else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED )
           {
    @@ -5044,9 +5036,9 @@
       static void
       Destroy_Module( FT_Module  module )
       {
    -    FT_Memory         memory  = module->memory;
    -    FT_Module_Class*  clazz   = module->clazz;
    -    FT_Library        library = module->library;
    +    const FT_Module_Class*  clazz   = module->clazz;
    +    FT_Library              library = module->library;
    +    FT_Memory               memory  = module->memory;
     
     
         if ( library && library->auto_hinter == module )
    @@ -5125,9 +5117,9 @@
           goto Exit;
     
         /* base initialization */
    +    module->clazz   = clazz;
         module->library = library;
         module->memory  = memory;
    -    module->clazz   = (FT_Module_Class*)clazz;
     
         /* check whether the module is a renderer - this must be performed */
         /* before the normal module initialization                         */
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c b/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
    index ef699b3c7cd..8a15b03eb83 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType outline management (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c b/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
    index 2055757e023..664bc34deea 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c
    @@ -5,7 +5,7 @@
      *   FreeType API for checking patented TrueType bytecode instructions
      *   (body).  Obsolete, retained for backward compatibility.
      *
    - * Copyright (C) 2007-2024 by
    + * Copyright (C) 2007-2025 by
      * David Turner.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c b/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
    index 37a6cee6cc9..0631cd63f62 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c
    @@ -5,7 +5,7 @@
      *   Get and set properties of PostScript drivers (body).
      *   See `ftdriver.h' for available properties.
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c b/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
    index dc9b043d8bb..1e241f4f95b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c
    @@ -4,7 +4,7 @@
      *
      *   Embedded resource forks accessor (body).
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * Masatake YAMATO and Redhat K.K.
      *
      * FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are
    @@ -269,14 +269,8 @@
                * According to Inside Macintosh: More Macintosh Toolbox,
                * "Resource IDs" (1-46), there are some reserved IDs.
                * However, FreeType2 is not a font synthesizer, no need
    -           * to check the acceptable resource ID.
    +           * to check the acceptable resource ID or its attributes.
                */
    -          if ( temp < 0 )
    -          {
    -            error = FT_THROW( Invalid_Table );
    -            goto Exit;
    -          }
    -
               ref[j].offset = temp & 0xFFFFFFL;
     
               FT_TRACE3(( "             [%d]:"
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c b/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
    index f7231fd61cc..34a67a148fc 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c
    @@ -7,7 +7,7 @@
      *
      *   This is _not_ used to retrieve glyph names!
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftstream.c b/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
    index 66722246128..c04a0506def 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftstream.c
    @@ -4,7 +4,7 @@
      *
      *   I/O stream support (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -242,7 +242,7 @@
         FT_ULong  read_bytes;
     
     
    -    FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count ));
    +    FT_TRACE7(( "FT_Stream_EnterFrame: %lu bytes\n", count ));
     
         /* check for nested frame access */
         FT_ASSERT( stream && stream->cursor == 0 );
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c b/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
    index 64f46ce43e7..591f18eaa83 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType path stroker (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -1070,7 +1070,7 @@
             if ( theta == FT_ANGLE_PI2 )
               theta = -rotate;
     
    -        phi    = stroker->angle_in + theta + rotate;
    +        phi = stroker->angle_in + theta + rotate;
     
             FT_Vector_From_Polar( &sigma, stroker->miter_limit, theta );
     
    @@ -1371,7 +1371,7 @@
         arc[1] = *control;
         arc[2] = stroker->center;
     
    -    while ( arc >= bez_stack )
    +    do
         {
           FT_Angle  angle_in, angle_out;
     
    @@ -1524,10 +1524,12 @@
             }
           }
     
    -      arc -= 2;
    -
           stroker->angle_in = angle_out;
    -    }
    +
    +      if ( arc == bez_stack )
    +        break;
    +      arc -= 2;
    +    } while ( 1 );
     
         stroker->center      = *to;
         stroker->line_length = 0;
    @@ -1577,7 +1579,7 @@
         arc[2] = *control1;
         arc[3] = stroker->center;
     
    -    while ( arc >= bez_stack )
    +    do
         {
           FT_Angle  angle_in, angle_mid, angle_out;
     
    @@ -1741,10 +1743,12 @@
             }
           }
     
    -      arc -= 3;
    -
           stroker->angle_in = angle_out;
    -    }
    +
    +      if ( arc == bez_stack )
    +        break;
    +      arc -= 3;
    +    } while ( 1 );
     
         stroker->center      = *to;
         stroker->line_length = 0;
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c b/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
    index ec05bce33a9..08bc1742202 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType synthesizing code for emboldening and slanting (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -141,7 +141,7 @@
           /*
            * XXX: overflow check for 16-bit system, for compatibility
            *      with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
    -       *      unfortunately, this function return no informations
    +       *      unfortunately, this function returns no information
            *      about the cause of error.
            */
           if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c b/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
    index eee3642334f..186119d5581 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c
    @@ -4,7 +4,7 @@
      *
      *   ANSI-specific FreeType low-level system interface (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -280,7 +280,7 @@
         stream->close = ft_ansi_stream_close;
     
         FT_TRACE1(( "FT_Stream_Open:" ));
    -    FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
    +    FT_TRACE1(( " opened `%s' (%lu bytes) successfully\n",
                     filepathname, stream->size ));
     
         return FT_Err_Ok;
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c b/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
    index 4b1aced1cba..29eff639c51 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType trigonometric functions (body).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/fttype1.c b/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
    index cedf7c40505..77978df674d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/fttype1.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility file for PS names support (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
    index b13512f8704..f83c4394893 100644
    --- a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
    +++ b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType utility file for memory and list management (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -424,11 +424,10 @@
         while ( cur )
         {
           FT_ListNode  next = cur->next;
    -      void*        data = cur->data;
     
     
           if ( destroy )
    -        destroy( memory, data, user );
    +        destroy( memory, cur->data, user );
     
           FT_FREE( cur );
           cur = next;
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
    index ea5f8ed2885..cb69abdb90f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c
    @@ -4,7 +4,7 @@
      *
      *   CFF character mapping table (cmap) support (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
    index 1dd8700cd8b..60e16d94875 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h
    @@ -4,7 +4,7 @@
      *
      *   CFF character mapping table (cmap) support (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
    index f6ebdb3810a..44ff44aecbd 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
    @@ -4,7 +4,7 @@
      *
      *   OpenType font driver implementation (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and Dominik Röttsches.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -121,7 +121,20 @@
         kerning->y = 0;
     
         if ( sfnt )
    -      kerning->x = sfnt->get_kerning( cffface, left_glyph, right_glyph );
    +    {
    +      /* Use 'kern' table if available since that can be faster; otherwise */
    +      /* use GPOS kerning pairs if available.                              */
    +      if ( cffface->kern_avail_bits )
    +        kerning->x = sfnt->get_kerning( cffface,
    +                                        left_glyph,
    +                                        right_glyph );
    +#ifdef TT_CONFIG_OPTION_GPOS_KERNING
    +      else if ( cffface->num_gpos_lookups_kerning )
    +        kerning->x = sfnt->get_gpos_kerning( cffface,
    +                                             left_glyph,
    +                                             right_glyph );
    +#endif
    +    }
     
         return FT_Err_Ok;
       }
    @@ -168,25 +181,7 @@
         CFF_Size       cffsize = (CFF_Size)size;
     
     
    -    if ( !cffslot )
    -      return FT_THROW( Invalid_Slot_Handle );
    -
    -    FT_TRACE1(( "cff_glyph_load: glyph index %d\n", glyph_index ));
    -
    -    /* check whether we want a scaled outline or bitmap */
    -    if ( !cffsize )
    -      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
    -
    -    /* reset the size object if necessary */
    -    if ( load_flags & FT_LOAD_NO_SCALE )
    -      size = NULL;
    -
    -    if ( size )
    -    {
    -      /* these two objects must have the same parent */
    -      if ( size->face != slot->face )
    -        return FT_THROW( Invalid_Face_Handle );
    -    }
    +    FT_TRACE1(( "cff_glyph_load: glyph index %u\n", glyph_index ));
     
         /* now load the glyph outline if necessary */
         error = cff_slot_load( cffslot, cffsize, glyph_index, load_flags );
    @@ -205,105 +200,70 @@
                         FT_Int32   flags,
                         FT_Fixed*  advances )
       {
    -    FT_UInt       nn;
    -    FT_Error      error = FT_Err_Ok;
    -    FT_GlyphSlot  slot  = face->glyph;
    +    CFF_Face  cffface = (CFF_Face)face;
    +    FT_Bool   horz;
    +    FT_UInt   nn;
     
     
    -    if ( FT_IS_SFNT( face ) )
    +    if ( !FT_IS_SFNT( face ) )
    +      return FT_THROW( Unimplemented_Feature );
    +
    +    horz = !( flags & FT_LOAD_VERTICAL_LAYOUT );
    +
    +    if ( horz )
         {
           /* OpenType 1.7 mandates that the data from `hmtx' table be used; */
           /* it is no longer necessary that those values are identical to   */
           /* the values in the `CFF' table                                  */
    +      if ( !cffface->horizontal.number_Of_HMetrics )
    +        return FT_THROW( Unimplemented_Feature );
     
    -      CFF_Face  cffface = (CFF_Face)face;
    -      FT_Short  dummy;
    -
    -
    -      if ( flags & FT_LOAD_VERTICAL_LAYOUT )
    -      {
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    -        /* no fast retrieval for blended MM fonts without VVAR table */
    -        if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
    -             !( cffface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    -          return FT_THROW( Unimplemented_Feature );
    +      /* no fast retrieval for blended MM fonts without HVAR table */
    +      if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
    +           !( cffface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    +        return FT_THROW( Unimplemented_Feature );
     #endif
    +    }
    +    else  /* vertical */
    +    {
    +      /* check whether we have data from the `vmtx' table at all; */
    +      /* otherwise we extract the info from the CFF glyphstrings  */
    +      /* (instead of synthesizing a global value using the `OS/2' */
    +      /* table)                                                   */
    +      if ( !cffface->vertical_info )
    +        return FT_THROW( Unimplemented_Feature );
     
    -        /* check whether we have data from the `vmtx' table at all; */
    -        /* otherwise we extract the info from the CFF glyphstrings  */
    -        /* (instead of synthesizing a global value using the `OS/2' */
    -        /* table)                                                   */
    -        if ( !cffface->vertical_info )
    -          goto Missing_Table;
    -
    -        for ( nn = 0; nn < count; nn++ )
    -        {
    -          FT_UShort  ah;
    -
    -
    -          ( (SFNT_Service)cffface->sfnt )->get_metrics( cffface,
    -                                                        1,
    -                                                        start + nn,
    -                                                        &dummy,
    -                                                        &ah );
    -
    -          FT_TRACE5(( "  idx %d: advance height %d font unit%s\n",
    -                      start + nn,
    -                      ah,
    -                      ah == 1 ? "" : "s" ));
    -          advances[nn] = ah;
    -        }
    -      }
    -      else
    -      {
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    -        /* no fast retrieval for blended MM fonts without HVAR table */
    -        if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
    -             !( cffface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
    -          return FT_THROW( Unimplemented_Feature );
    +      /* no fast retrieval for blended MM fonts without VVAR table */
    +      if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
    +           !( cffface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
    +        return FT_THROW( Unimplemented_Feature );
     #endif
    -
    -        /* check whether we have data from the `hmtx' table at all */
    -        if ( !cffface->horizontal.number_Of_HMetrics )
    -          goto Missing_Table;
    -
    -        for ( nn = 0; nn < count; nn++ )
    -        {
    -          FT_UShort  aw;
    -
    -
    -          ( (SFNT_Service)cffface->sfnt )->get_metrics( cffface,
    -                                                        0,
    -                                                        start + nn,
    -                                                        &dummy,
    -                                                        &aw );
    -
    -          FT_TRACE5(( "  idx %d: advance width %d font unit%s\n",
    -                      start + nn,
    -                      aw,
    -                      aw == 1 ? "" : "s" ));
    -          advances[nn] = aw;
    -        }
    -      }
    -
    -      return error;
         }
     
    -  Missing_Table:
    -    flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
    -
    +    /* proceed to fast advances */
         for ( nn = 0; nn < count; nn++ )
         {
    -      error = cff_glyph_load( slot, face->size, start + nn, flags );
    -      if ( error )
    -        break;
    +      FT_UShort  aw;
    +      FT_Short   dummy;
     
    -      advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
    -                     ? slot->linearVertAdvance
    -                     : slot->linearHoriAdvance;
    +
    +      ( (SFNT_Service)cffface->sfnt )->get_metrics( cffface,
    +                                                    !horz,
    +                                                    start + nn,
    +                                                    &dummy,
    +                                                    &aw );
    +
    +      FT_TRACE5(( "  idx %u: advance %s %d font unit%s\n",
    +                  start + nn,
    +                  horz ? "width" : "height",
    +                  aw,
    +                  aw == 1 ? "" : "s" ));
    +      advances[nn] = aw;
         }
     
    -    return error;
    +    return FT_Err_Ok;
       }
     
     
    @@ -496,8 +456,8 @@
                                                              dict->weight );
           font_info->italic_angle        = dict->italic_angle;
           font_info->is_fixed_pitch      = dict->is_fixed_pitch;
    -      font_info->underline_position  = (FT_Short)dict->underline_position;
    -      font_info->underline_thickness = (FT_UShort)dict->underline_thickness;
    +      font_info->underline_position  = dict->underline_position;
    +      font_info->underline_thickness = dict->underline_thickness;
     
           cff->font_info = font_info;
         }
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
    index fd5bc37ecd4..52a1e727a6a 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h
    @@ -4,7 +4,7 @@
      *
      *   High-level OpenType driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h b/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
    index 128adc3b716..7491886c7be 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h
    @@ -4,7 +4,7 @@
      *
      *   CFF error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
    index cbb071abdfe..e8bab3c1e33 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c
    @@ -4,7 +4,7 @@
      *
      *   OpenType Glyph Loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -238,24 +238,12 @@
         else if ( glyph_index >= cff->num_glyphs )
           return FT_THROW( Invalid_Argument );
     
    -    if ( load_flags & FT_LOAD_NO_RECURSE )
    -      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
    -
    -    glyph->x_scale = 0x10000L;
    -    glyph->y_scale = 0x10000L;
    -    if ( size )
    -    {
    -      glyph->x_scale = size->root.metrics.x_scale;
    -      glyph->y_scale = size->root.metrics.y_scale;
    -    }
    -
     #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
     
         /* try to load embedded bitmap if any              */
         /*                                                 */
         /* XXX: The convention should be emphasized in     */
         /*      the documents because it can be confusing. */
    -    if ( size )
         {
           CFF_Face      cff_face = (CFF_Face)size->root.face;
           SFNT_Service  sfnt     = (SFNT_Service)cff_face->sfnt;
    @@ -284,9 +272,6 @@
               FT_Short   dummy;
     
     
    -          glyph->root.outline.n_points   = 0;
    -          glyph->root.outline.n_contours = 0;
    -
               glyph->root.metrics.width  = (FT_Pos)metrics.width  * 64;
               glyph->root.metrics.height = (FT_Pos)metrics.height * 64;
     
    @@ -423,6 +408,25 @@
     
     #endif /* FT_CONFIG_OPTION_SVG */
     
    +    /* top-level code ensures that FT_LOAD_NO_HINTING is set */
    +    /* if FT_LOAD_NO_SCALE is active                         */
    +    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
    +    scaled  = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 );
    +
    +    glyph->hint        = hinting;
    +    glyph->scaled      = scaled;
    +
    +    if ( scaled )
    +    {
    +      glyph->x_scale = size->root.metrics.x_scale;
    +      glyph->y_scale = size->root.metrics.y_scale;
    +    }
    +    else
    +    {
    +      glyph->x_scale = 0x10000L;
    +      glyph->y_scale = 0x10000L;
    +    }
    +
         /* if we have a CID subfont, use its matrix (which has already */
         /* been multiplied with the root matrix)                       */
     
    @@ -457,18 +461,6 @@
           font_offset = cff->top_font.font_dict.font_offset;
         }
     
    -    glyph->root.outline.n_points   = 0;
    -    glyph->root.outline.n_contours = 0;
    -
    -    /* top-level code ensures that FT_LOAD_NO_HINTING is set */
    -    /* if FT_LOAD_NO_SCALE is active                         */
    -    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
    -    scaled  = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 );
    -
    -    glyph->hint        = hinting;
    -    glyph->scaled      = scaled;
    -    glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;  /* by default */
    -
         {
     #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
           PS_Driver  driver = (PS_Driver)FT_FACE_DRIVER( face );
    @@ -602,10 +594,8 @@
         {
           /* Now, set the metrics -- this is rather simple, as   */
           /* the left side bearing is the xMin, and the top side */
    -      /* bearing the yMax.                                   */
    -
    -      /* For composite glyphs, return only left side bearing and */
    -      /* advance width.                                          */
    +      /* bearing the yMax. For composite glyphs, return only */
    +      /* left side bearing and advance width.                */
           if ( load_flags & FT_LOAD_NO_RECURSE )
           {
             FT_Slot_Internal  internal = glyph->root.internal;
    @@ -624,6 +614,12 @@
             FT_Bool            has_vertical_info;
     
     
    +        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
    +
    +        glyph->root.outline.flags = FT_OUTLINE_REVERSE_FILL;
    +        if ( size && size->root.metrics.y_ppem < 24 )
    +          glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    +
             if ( face->horizontal.number_Of_HMetrics )
             {
               FT_Short   horiBearingX = 0;
    @@ -677,14 +673,6 @@
     
             glyph->root.linearVertAdvance = metrics->vertAdvance;
     
    -        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
    -
    -        glyph->root.outline.flags = 0;
    -        if ( size && size->root.metrics.y_ppem < 24 )
    -          glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    -
    -        glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
    -
             /* apply the font matrix, if any */
             if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
                  font_matrix.xy != 0        || font_matrix.yx != 0        )
    @@ -707,7 +695,7 @@
               metrics->vertAdvance += font_offset.y;
             }
     
    -        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
    +        if ( scaled || force_scaling )
             {
               /* scale the outline and the metrics */
               FT_Int       n;
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
    index 346d4b11c31..662bb7cff53 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h
    @@ -4,7 +4,7 @@
      *
      *   OpenType Glyph Loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
    index 979fd45f6ca..39d662eb434 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c
    @@ -4,7 +4,7 @@
      *
      *   OpenType and CFF data/program tables loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -442,7 +442,7 @@
           if ( cur_offset != 0 )
           {
             FT_TRACE0(( "cff_index_get_pointers:"
    -                    " invalid first offset value %ld set to zero\n",
    +                    " invalid first offset value %lu set to zero\n",
                         cur_offset ));
             cur_offset = 0;
           }
    @@ -559,8 +559,8 @@
                idx->data_offset > stream->size - off2 + 1 )
           {
             FT_ERROR(( "cff_index_access_element:"
    -                   " offset to next entry (%ld)"
    -                   " exceeds the end of stream (%ld)\n",
    +                   " offset to next entry (%lu)"
    +                   " exceeds the end of stream (%lu)\n",
                        off2, stream->size - idx->data_offset + 1 ));
             off2 = stream->size - idx->data_offset + 1;
           }
    @@ -982,7 +982,7 @@
                 if ( glyph_sid > 0xFFFFL - nleft )
                 {
                   FT_ERROR(( "cff_charset_load: invalid SID range trimmed"
    -                         " nleft=%d -> %ld\n", nleft, 0xFFFFL - glyph_sid ));
    +                         " nleft=%u -> %ld\n", nleft, 0xFFFFL - glyph_sid ));
                   nleft = ( FT_UInt )( 0xFFFFL - glyph_sid );
                 }
     
    @@ -1315,7 +1315,7 @@
     
         if ( numOperands > count )
         {
    -      FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n",
    +      FT_TRACE4(( " cff_blend_doBlend: Stack underflow %u argument%s\n",
                       count,
                       count == 1 ? "" : "s" ));
     
    @@ -1466,7 +1466,7 @@
           if ( master == 0 )
           {
             blend->BV[master] = FT_FIXED_ONE;
    -        FT_TRACE4(( "   build blend vector len %d\n", len ));
    +        FT_TRACE4(( "   build blend vector len %u\n", len ));
             FT_TRACE4(( "   [ %f ", blend->BV[master] / 65536.0 ));
             continue;
           }
    @@ -2014,8 +2014,8 @@
         /* set defaults */
         FT_ZERO( top );
     
    -    top->underline_position  = -( 100L << 16 );
    -    top->underline_thickness = 50L << 16;
    +    top->underline_position  = -100;
    +    top->underline_thickness = 50;
         top->charstring_type     = 2;
         top->font_matrix.xx      = 0x10000L;
         top->font_matrix.yy      = 0x10000L;
    @@ -2341,7 +2341,7 @@
           if ( face_index > 0 && subfont_index >= font->name_index.count )
           {
             FT_ERROR(( "cff_font_load:"
    -                   " invalid subfont index for pure CFF font (%d)\n",
    +                   " invalid subfont index for pure CFF font (%u)\n",
                        subfont_index ));
             error = FT_THROW( Invalid_Argument );
             goto Exit;
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffload.h b/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
    index 02209245421..fdc132c8f3f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffload.h
    @@ -4,7 +4,7 @@
      *
      *   OpenType & CFF data/program tables loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
    index 7c6713739a1..9e00943a95d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c
    @@ -4,7 +4,7 @@
      *
      *   OpenType objects manager (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -537,8 +537,8 @@
     
           sfnt_format = 1;
     
    -      /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
    -      /* font; in the latter case it doesn't have a `head' table         */
    +      /* the font may be OpenType/CFF, SVG CEF, or sfnt/CFF; a `head' table */
    +      /* implies OpenType/CFF, otherwise just look for an optional cmap     */
           error = face->goto_table( face, TTAG_head, stream, 0 );
           if ( !error )
           {
    @@ -554,7 +554,9 @@
           {
             /* load the `cmap' table explicitly */
             error = sfnt->load_cmap( face, stream );
    -        if ( error )
    +
    +        /* this may fail because CID-keyed fonts don't have a cmap */
    +        if ( FT_ERR_NEQ( error, Table_Missing ) && FT_ERR_NEQ( error, Ok ) )
               goto Exit;
           }
     
    @@ -651,7 +653,7 @@
             {
               s = cff_index_get_sid_string( cff, idx );
               if ( s )
    -            FT_TRACE4(( "  %5d %s\n", idx, s ));
    +            FT_TRACE4(( "  %5u %s\n", idx, s ));
             }
     
             /* In Multiple Master CFFs, two SIDs hold the Normalize Design  */
    @@ -666,7 +668,7 @@
               FT_PtrDist  l;
     
     
    -          FT_TRACE4(( "  %5d ", idx + 390 ));
    +          FT_TRACE4(( "  %5u ", idx + 390 ));
               for ( l = 0; l < s1len; l++ )
                 FT_TRACE4(( "%c", s1[l] ));
               FT_TRACE4(( "\n" ));
    @@ -681,7 +683,7 @@
               FT_PtrDist  l;
     
     
    -          FT_TRACE4(( "  %5d ", cff->num_strings + 390 ));
    +          FT_TRACE4(( "  %5u ", cff->num_strings + 390 ));
               for ( l = 0; l < s1len; l++ )
                 FT_TRACE4(( "%c", s1[l] ));
               FT_TRACE4(( "\n" ));
    @@ -844,10 +846,8 @@
               cffface->height = (FT_Short)( cffface->ascender -
                                             cffface->descender );
     
    -        cffface->underline_position  =
    -          (FT_Short)( dict->underline_position >> 16 );
    -        cffface->underline_thickness =
    -          (FT_Short)( dict->underline_thickness >> 16 );
    +        cffface->underline_position  = (FT_Short)dict->underline_position;
    +        cffface->underline_thickness = (FT_Short)dict->underline_thickness;
     
             /* retrieve font family & style name */
             if ( dict->family_name )
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
    index 91ad83b1cd0..982dcd64dd0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h
    @@ -4,7 +4,7 @@
      *
      *   OpenType objects manager (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
    index 92a69c3b516..864b2490b3b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
    @@ -4,7 +4,7 @@
      *
      *   CFF token stream parser (body)
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -892,7 +892,7 @@
                        dict->cid_supplement ));
           error = FT_Err_Ok;
     
    -      FT_TRACE4(( " %d %d %ld\n",
    +      FT_TRACE4(( " %u %u %ld\n",
                       dict->cid_registry,
                       dict->cid_ordering,
                       dict->cid_supplement ));
    @@ -929,7 +929,7 @@
     
         priv->vsindex = (FT_UInt)cff_parse_num( parser, data++ );
     
    -    FT_TRACE4(( " %d\n", priv->vsindex ));
    +    FT_TRACE4(( " %u\n", priv->vsindex ));
     
         error = FT_Err_Ok;
     
    @@ -979,7 +979,7 @@
           goto Exit;
         }
     
    -    FT_TRACE4(( "   %d value%s blended\n",
    +    FT_TRACE4(( "   %u value%s blended\n",
                     numBlends,
                     numBlends == 1 ? "" : "s" ));
     
    @@ -1014,7 +1014,7 @@
         if ( dict->maxstack < CFF2_DEFAULT_STACK )
           dict->maxstack = CFF2_DEFAULT_STACK;
     
    -    FT_TRACE4(( " %d\n", dict->maxstack ));
    +    FT_TRACE4(( " %u\n", dict->maxstack ));
     
       Exit:
         return error;
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
    index ca6b18af6aa..47cceb1a4a0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h
    @@ -4,7 +4,7 @@
      *
      *   CFF token stream parser (specification)
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
    index da45faa7f4e..a7ee1cb3fe7 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h
    @@ -4,7 +4,7 @@
      *
      *   CFF token definitions (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -30,8 +30,8 @@
       CFF_FIELD_STRING  ( 4,     weight,              "Weight" )
       CFF_FIELD_BOOL    ( 0x101, is_fixed_pitch,      "isFixedPitch" )
       CFF_FIELD_FIXED   ( 0x102, italic_angle,        "ItalicAngle" )
    -  CFF_FIELD_FIXED   ( 0x103, underline_position,  "UnderlinePosition" )
    -  CFF_FIELD_FIXED   ( 0x104, underline_thickness, "UnderlineThickness" )
    +  CFF_FIELD_NUM     ( 0x103, underline_position,  "UnderlinePosition" )
    +  CFF_FIELD_NUM     ( 0x104, underline_thickness, "UnderlineThickness" )
       CFF_FIELD_NUM     ( 0x105, paint_type,          "PaintType" )
       CFF_FIELD_NUM     ( 0x106, charstring_type,     "CharstringType" )
       CFF_FIELD_CALLBACK( 0x107, font_matrix,         "FontMatrix" )
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h b/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
    index c439a8c4a0b..1591979d370 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h
    @@ -4,7 +4,7 @@
      *
      *   CID error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
    index 7b571322d45..249ede5757d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c
    @@ -4,7 +4,7 @@
      *
      *   CID-keyed Type1 Glyph Loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -103,20 +103,20 @@
           if ( ( cid->fd_bytes == 1 && fd_select == 0xFFU   ) ||
                ( cid->fd_bytes == 2 && fd_select == 0xFFFFU ) )
           {
    -        FT_TRACE1(( "cid_load_glyph: fail for glyph index %d:\n",
    +        FT_TRACE1(( "cid_load_glyph: fail for glyph index %u:\n",
                         glyph_index ));
    -        FT_TRACE1(( "                FD number %ld is the maximum\n",
    +        FT_TRACE1(( "                FD number %lu is the maximum\n",
                         fd_select ));
    -        FT_TRACE1(( "                integer fitting into %d byte%s\n",
    +        FT_TRACE1(( "                integer fitting into %u byte%s\n",
                         cid->fd_bytes, cid->fd_bytes == 1 ? "" : "s" ));
           }
           else
           {
    -        FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
    +        FT_TRACE0(( "cid_load_glyph: fail for glyph index %u:\n",
                         glyph_index ));
    -        FT_TRACE0(( "                FD number %ld is larger\n",
    +        FT_TRACE0(( "                FD number %lu is larger\n",
                         fd_select ));
    -        FT_TRACE0(( "                than number of dictionaries (%d)\n",
    +        FT_TRACE0(( "                than number of dictionaries (%u)\n",
                         cid->num_dicts ));
           }
     
    @@ -125,7 +125,7 @@
         }
         else if ( off2 > stream->size )
         {
    -      FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
    +      FT_TRACE0(( "cid_load_glyph: fail for glyph index %u:\n",
                       glyph_index ));
           FT_TRACE0(( "               end of the glyph data\n" ));
           FT_TRACE0(( "               is beyond the data stream\n" ));
    @@ -135,7 +135,7 @@
         }
         else if ( off1 > off2 )
         {
    -      FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
    +      FT_TRACE0(( "cid_load_glyph: fail for glyph index %u:\n",
                       glyph_index ));
           FT_TRACE0(( "                the end position of glyph data\n" ));
           FT_TRACE0(( "                is set before the start position\n" ));
    @@ -252,8 +252,8 @@
           cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0;
           if ( cs_offset > glyph_length )
           {
    -        FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, "
    -                    "offset to the charstring is beyond glyph length\n",
    +        FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%u,"
    +                    " offset to the charstring is beyond glyph length\n",
                         glyph_index ));
             error = FT_THROW( Invalid_Offset );
             goto Exit;
    @@ -452,16 +452,12 @@
         glyph->x_scale = cidsize->metrics.x_scale;
         glyph->y_scale = cidsize->metrics.y_scale;
     
    -    cidglyph->outline.n_points   = 0;
    -    cidglyph->outline.n_contours = 0;
    -
         hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
                            ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
         scaled  = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 );
     
         glyph->hint      = hinting;
         glyph->scaled    = scaled;
    -    cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
     
         error = psaux->t1_decoder_funcs->init( &decoder,
                                                cidglyph->face,
    @@ -501,12 +497,8 @@
     
         /* now set the metrics -- this is rather simple, as    */
         /* the left side bearing is the xMin, and the top side */
    -    /* bearing the yMax                                    */
    -    cidglyph->outline.flags &= FT_OUTLINE_OWNER;
    -    cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
    -
    -    /* for composite glyphs, return only left side bearing and */
    -    /* advance width                                           */
    +    /* bearing the yMax; for composite glyphs, return only */
    +    /* left side bearing and advance width                 */
         if ( load_flags & FT_LOAD_NO_RECURSE )
         {
           FT_Slot_Internal  internal = cidglyph->internal;
    @@ -527,6 +519,13 @@
           FT_Glyph_Metrics*  metrics = &cidglyph->metrics;
     
     
    +      cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
    +
    +      cidglyph->outline.flags &= FT_OUTLINE_OWNER;
    +      cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
    +      if ( cidsize->metrics.y_ppem < 24 )
    +        cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    +
           /* copy the _unscaled_ advance width */
           metrics->horiAdvance =
             FIXED_TO_INT( decoder.builder.advance.x );
    @@ -539,11 +538,6 @@
                                           face->cid.font_bbox.yMin ) >> 16;
           cidglyph->linearVertAdvance = metrics->vertAdvance;
     
    -      cidglyph->format            = FT_GLYPH_FORMAT_OUTLINE;
    -
    -      if ( cidsize->metrics.y_ppem < 24 )
    -        cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    -
           /* apply the font matrix, if any */
           if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
                font_matrix.xy != 0        || font_matrix.yx != 0        )
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
    index 9fdc9db5892..cef96073ded 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h
    @@ -4,7 +4,7 @@
      *
      *   OpenType Glyph Loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidload.c b/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
    index 722f5a34ddf..bb1bf13e221 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidload.c
    @@ -4,7 +4,7 @@
      *
      *   CID-keyed Type1 font loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidload.h b/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
    index 7f030b32df7..659dd0e378c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidload.h
    @@ -4,7 +4,7 @@
      *
      *   CID-keyed Type1 font loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
    index 8d337c41128..634bbf2f135 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c
    @@ -4,7 +4,7 @@
      *
      *   CID objects manager (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
    index d371cbe9954..800268efa2f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h
    @@ -4,7 +4,7 @@
      *
      *   CID objects manager (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
    index 73a3ade893b..4d1ba335960 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c
    @@ -4,7 +4,7 @@
      *
      *   CID-keyed Type1 parser (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
    index 0f5baddcb92..6ae2e542394 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h
    @@ -4,7 +4,7 @@
      *
      *   CID-keyed Type1 parser (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
    index 4be8a5c00d5..a3a587c57bf 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c
    @@ -4,7 +4,7 @@
      *
      *   CID driver interface (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
    index 7ddce431c5b..55d0b8a0d9b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h
    @@ -4,7 +4,7 @@
      *
      *   High-level CID driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
    index 160897d1447..d40ebfab86d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
    +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h
    @@ -4,7 +4,7 @@
      *
      *   CID token definitions (specification only).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -47,7 +47,7 @@
       T1_FIELD_STRING( "FullName",           full_name,           0 )
       T1_FIELD_STRING( "FamilyName",         family_name,         0 )
       T1_FIELD_STRING( "Weight",             weight,              0 )
    -  T1_FIELD_NUM   ( "ItalicAngle",        italic_angle,        0 )
    +  T1_FIELD_FIXED ( "ItalicAngle",        italic_angle,        0 )
       T1_FIELD_BOOL  ( "isFixedPitch",       is_fixed_pitch,      0 )
       T1_FIELD_NUM   ( "UnderlinePosition",  underline_position,  0 )
       T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness, 0 )
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
    index e2f6a8e5adb..b813efde4eb 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c
    @@ -4,7 +4,7 @@
      *
      *   AFM parser (body).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
    index b7766372821..add8597717d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h
    @@ -4,7 +4,7 @@
      *
      *   AFM parser (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
    index 9556e11a586..17bdd23c7d4 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c
    @@ -4,7 +4,7 @@
      *
      *   PostScript CFF (Type 2) decoding routines (body).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -2141,7 +2141,7 @@
                                           decoder->locals_bias );
     
     
    -            FT_TRACE4(( " callsubr (idx %d, entering level %td)\n",
    +            FT_TRACE4(( " callsubr (idx %u, entering level %td)\n",
                             idx,
                             zone - decoder->zones + 1 ));
     
    @@ -2185,7 +2185,7 @@
                                           decoder->globals_bias );
     
     
    -            FT_TRACE4(( " callgsubr (idx %d, entering level %td)\n",
    +            FT_TRACE4(( " callgsubr (idx %u, entering level %td)\n",
                             idx,
                             zone - decoder->zones + 1 ));
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
    index 038f7235c3d..e72ec043baa 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript CFF (Type 2) decoding routines (specification).
      *
    - * Copyright (C) 2017-2024 by
    + * Copyright (C) 2017-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h b/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
    index 18428c40d5a..0d7fe2b6121 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h
    @@ -4,7 +4,7 @@
      *
      *   PS auxiliary module error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
    index 6826f9d8d3e..942804190c5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType auxiliary PostScript module implementation (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
    index 82d7e348af8..4a5ebc1b607 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType auxiliary PostScript module implementation (specification).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -46,9 +46,6 @@ FT_BEGIN_HEADER
       const CFF_Decoder_FuncsRec  cff_decoder_funcs;
     
     
    -  FT_EXPORT_VAR( const FT_Module_Class )  psaux_driver_class;
    -
    -
       FT_DECLARE_MODULE( psaux_module_class )
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
    index 56c0ecd1d7f..4567d3f3c06 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c
    @@ -4,7 +4,7 @@
      *
      *   Some convenience conversions (body).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
    index 91fcd15a1c9..63735af411f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h
    @@ -4,7 +4,7 @@
      *
      *   Some convenience conversions (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c b/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
    index 7572e225e37..7e3475e6f58 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c
    @@ -618,7 +618,7 @@
         /*       Our copy of it does not change that requirement.         */
         cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 );
     
    -    charstring  = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack );
    +    charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack );
     
         /* catch errors so far */
         if ( *error )
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
    index eca465f009e..8159fd6ef15 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c
    @@ -4,7 +4,7 @@
      *
      *   Auxiliary functions for PostScript fonts (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -460,6 +460,9 @@
           case '%':
             skip_comment( &cur, limit );
             break;
    +
    +      default:
    +        break;
           }
         }
     
    @@ -1145,7 +1148,7 @@
                 FT_ERROR(( "ps_parser_load_field:"
                            " expected a name or string\n" ));
                 FT_ERROR(( "                     "
    -                       " but found token of type %d instead\n",
    +                       " but found token of type %u instead\n",
                            token.type ));
                 error = FT_THROW( Invalid_File_Format );
                 goto Exit;
    @@ -1225,7 +1228,7 @@
                 if ( result < 0 || (FT_UInt)result < max_objects )
                 {
                   FT_ERROR(( "ps_parser_load_field:"
    -                         " expected %d integer%s in the %s subarray\n",
    +                         " expected %u integer%s in the %s subarray\n",
                              max_objects, max_objects > 1 ? "s" : "",
                              i == 0 ? "first"
                                     : ( i == 1 ? "second"
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
    index 345fc8a7335..277aa1247c5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h
    @@ -4,7 +4,7 @@
      *
      *   Auxiliary functions for PostScript fonts (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
    index 5681c3bd0fd..66493b68123 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 character map support (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
    index 445e6a2784f..114bfbb0410 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 character map support (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
    index c74baa8038f..c3fb343d4c9 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c
    @@ -4,7 +4,7 @@
      *
      *   PostScript Type 1 decoding routines (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -1633,7 +1633,7 @@
     
             default:
               FT_ERROR(( "t1_decoder_parse_charstrings:"
    -                     " unhandled opcode %d\n", op ));
    +                     " unhandled opcode %u\n", op ));
               goto Syntax_Error;
             }
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
    index 16203b8f734..7b913f55dff 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript Type 1 decoding routines (specification).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
    index 967767b3485..e053dba17b2 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c
    @@ -4,7 +4,7 @@
      *
      *   PostScript hinting algorithm (body).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used
    @@ -35,10 +35,6 @@
     #endif
     
     
    -#define  COMPUTE_INFLEXS  /* compute inflection points to optimize `S' */
    -                          /* and similar glyphs                        */
    -
    -
       /*************************************************************************/
       /*************************************************************************/
       /*****                                                               *****/
    @@ -100,7 +96,7 @@
     
         if ( idx >= table->max_hints )
         {
    -      FT_TRACE0(( "psh_hint_table_record: invalid hint index %d\n", idx ));
    +      FT_TRACE0(( "psh_hint_table_record: invalid hint index %u\n", idx ));
           return;
         }
     
    @@ -920,117 +916,6 @@
     #define  psh_corner_orientation  ft_corner_orientation
     
     
    -#ifdef COMPUTE_INFLEXS
    -
    -  /* compute all inflex points in a given glyph */
    -  static void
    -  psh_glyph_compute_inflections( PSH_Glyph  glyph )
    -  {
    -    FT_UInt  n;
    -
    -
    -    for ( n = 0; n < glyph->num_contours; n++ )
    -    {
    -      PSH_Point  first, start, end, before, after;
    -      FT_Pos     in_x, in_y, out_x, out_y;
    -      FT_Int     orient_prev, orient_cur;
    -      FT_Int     finished = 0;
    -
    -
    -      /* we need at least 4 points to create an inflection point */
    -      if ( glyph->contours[n].count < 4 )
    -        continue;
    -
    -      /* compute first segment in contour */
    -      first = glyph->contours[n].start;
    -
    -      start = end = first;
    -      do
    -      {
    -        end = end->next;
    -        if ( end == first )
    -          goto Skip;
    -
    -        in_x = end->org_u - start->org_u;
    -        in_y = end->org_v - start->org_v;
    -
    -      } while ( in_x == 0 && in_y == 0 );
    -
    -      /* extend the segment start whenever possible */
    -      before = start;
    -      do
    -      {
    -        do
    -        {
    -          start  = before;
    -          before = before->prev;
    -          if ( before == first )
    -            goto Skip;
    -
    -          out_x = start->org_u - before->org_u;
    -          out_y = start->org_v - before->org_v;
    -
    -        } while ( out_x == 0 && out_y == 0 );
    -
    -        orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y );
    -
    -      } while ( orient_prev == 0 );
    -
    -      first = start;
    -      in_x  = out_x;
    -      in_y  = out_y;
    -
    -      /* now, process all segments in the contour */
    -      do
    -      {
    -        /* first, extend current segment's end whenever possible */
    -        after = end;
    -        do
    -        {
    -          do
    -          {
    -            end   = after;
    -            after = after->next;
    -            if ( after == first )
    -              finished = 1;
    -
    -            out_x = after->org_u - end->org_u;
    -            out_y = after->org_v - end->org_v;
    -
    -          } while ( out_x == 0 && out_y == 0 );
    -
    -          orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y );
    -
    -        } while ( orient_cur == 0 );
    -
    -        if ( ( orient_cur ^ orient_prev ) < 0 )
    -        {
    -          do
    -          {
    -            psh_point_set_inflex( start );
    -            start = start->next;
    -          }
    -          while ( start != end );
    -
    -          psh_point_set_inflex( start );
    -        }
    -
    -        start       = end;
    -        end         = after;
    -        orient_prev = orient_cur;
    -        in_x        = out_x;
    -        in_y        = out_y;
    -
    -      } while ( !finished );
    -
    -    Skip:
    -      ;
    -    }
    -  }
    -
    -#endif /* COMPUTE_INFLEXS */
    -
    -
       static void
       psh_glyph_done( PSH_Glyph  glyph )
       {
    @@ -1258,11 +1143,6 @@
         glyph->outline = outline;
         glyph->globals = globals;
     
    -#ifdef COMPUTE_INFLEXS
    -    psh_glyph_load_points( glyph, 0 );
    -    psh_glyph_compute_inflections( glyph );
    -#endif /* COMPUTE_INFLEXS */
    -
         /* now deal with hints tables */
         error = psh_hint_table_init( &glyph->hint_tables [0],
                                      &ps_hints->dimension[0].hints,
    @@ -1285,122 +1165,47 @@
       }
     
     
    -  /* compute all extrema in a glyph for a given dimension */
    +  /* compute all extreme and inflection points */
    +  /* in a glyph for a given dimension          */
       static void
       psh_glyph_compute_extrema( PSH_Glyph  glyph )
       {
         FT_UInt  n;
     
     
    -    /* first of all, compute all local extrema */
         for ( n = 0; n < glyph->num_contours; n++ )
         {
    -      PSH_Point  first = glyph->contours[n].start;
    -      PSH_Point  point, before, after;
    +      PSH_Point  first, point, before, after;
     
     
    -      if ( glyph->contours[n].count == 0 )
    +      /* we need at least 3 points to create an extremum */
    +      if ( glyph->contours[n].count < 3 )
             continue;
     
    -      point  = first;
    -      before = point;
    +      first = glyph->contours[n].start;
    +      point = first->prev;
    +      after = first;
     
           do
           {
    -        before = before->prev;
    -        if ( before == first )
    -          goto Skip;
    -
    -      } while ( before->org_u == point->org_u );
    -
    -      first = point = before->next;
    -
    -      for (;;)
    -      {
    -        after = point;
    -        do
    -        {
    -          after = after->next;
    -          if ( after == first )
    -            goto Next;
    -
    -        } while ( after->org_u == point->org_u );
    -
    -        if ( before->org_u < point->org_u )
    -        {
    -          if ( after->org_u < point->org_u )
    -          {
    -            /* local maximum */
    -            goto Extremum;
    -          }
    -        }
    -        else /* before->org_u > point->org_u */
    -        {
    -          if ( after->org_u > point->org_u )
    -          {
    -            /* local minimum */
    -          Extremum:
    -            do
    -            {
    -              psh_point_set_extremum( point );
    -              point = point->next;
    -
    -            } while ( point != after );
    -          }
    -        }
    -
    -        before = after->prev;
    +        before = point;
             point  = after;
    +        after  = point->next;
     
    -      } /* for  */
    +        if ( ( before->org_u < point->org_u && point->org_u < after->org_u ) ||
    +             ( before->org_u > point->org_u && point->org_u > after->org_u ) )
    +          continue;
     
    -    Next:
    -      ;
    -    }
    +        /* otherwise this is either extremum or inflection point */
    +        psh_point_set_extremum( point );
     
    -    /* for each extremum, determine its direction along the */
    -    /* orthogonal axis                                      */
    -    for ( n = 0; n < glyph->num_points; n++ )
    -    {
    -      PSH_Point  point, before, after;
    +        /* also note its direction */
    +        if ( before->org_v < after->org_v )
    +          psh_point_set_positive( point );
    +        else if ( before->org_v > after->org_v )
    +          psh_point_set_negative( point );
     
    -
    -      point  = &glyph->points[n];
    -      before = point;
    -      after  = point;
    -
    -      if ( psh_point_is_extremum( point ) )
    -      {
    -        do
    -        {
    -          before = before->prev;
    -          if ( before == point )
    -            goto Skip;
    -
    -        } while ( before->org_v == point->org_v );
    -
    -        do
    -        {
    -          after = after->next;
    -          if ( after == point )
    -            goto Skip;
    -
    -        } while ( after->org_v == point->org_v );
    -      }
    -
    -      if ( before->org_v < point->org_v &&
    -           after->org_v  > point->org_v )
    -      {
    -        psh_point_set_positive( point );
    -      }
    -      else if ( before->org_v > point->org_v &&
    -                after->org_v  < point->org_v )
    -      {
    -        psh_point_set_negative( point );
    -      }
    -
    -    Skip:
    -      ;
    +      } while ( after != first );
         }
       }
     
    @@ -1836,8 +1641,7 @@
                  point->dir_in != point->dir_out )
               continue;
     
    -        if ( !psh_point_is_extremum( point ) &&
    -             !psh_point_is_inflex( point )   )
    +        if ( !psh_point_is_extremum( point ) )
               continue;
     
             point->flags &= ~PSH_POINT_SMOOTH;
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
    index fb362f061b6..f4aa8540559 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript hinting algorithm (specification).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
    index 435f45838ff..a772b66f309 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c
    @@ -5,7 +5,7 @@
      *   PostScript hinter global hinting management (body).
      *   Inspired by the new auto-hinter module.
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used
    @@ -376,36 +376,24 @@
         /* not.  We simply need to compare the vertical scale     */
         /* parameter to the raw bluescale value.  Here is why:    */
         /*                                                        */
    -    /*   We need to suppress overshoots for all pointsizes.   */
    -    /*   At 300dpi that satisfies:                            */
    +    /* The specs explain how the bluescale is calculated      */
    +    /* from the desired maximum rounded pointsize at 300 dpi  */
    +    /* and assuming upem of 1000.                             */
         /*                                                        */
    -    /*      pointsize < 240*bluescale + 0.49                  */
    +    /*    bluescale = ( pointsize - 0.49 ) / 240              */
         /*                                                        */
    -    /*   This corresponds to:                                 */
    +    /* For unrounded pointsize in general terms               */
         /*                                                        */
    -    /*      pixelsize < 1000*bluescale + 49/24                */
    +    /*    bluescale = ( pointsize * dpi / 72 ) / upem         */
         /*                                                        */
    -    /*      scale*EM_Size < 1000*bluescale + 49/24            */
    +    /* which is                                               */
         /*                                                        */
    -    /*   However, for normal Type 1 fonts, EM_Size is 1000!   */
    -    /*   We thus only check:                                  */
    +    /*    bluescale = pixelsize / upem                        */
         /*                                                        */
    -    /*      scale < bluescale + 49/24000                      */
    +    /* Therefore, the bluescale value can be used directly    */
    +    /* as a scale limit, now that it is in comparable units   */
         /*                                                        */
    -    /*   which we shorten to                                  */
    -    /*                                                        */
    -    /*      "scale < bluescale"                               */
    -    /*                                                        */
    -    /* Note that `blue_scale' is stored 1000 times its real   */
    -    /* value, and that `scale' converts from font units to    */
    -    /* fractional pixels.                                     */
    -    /*                                                        */
    -
    -    /* 1000 / 64 = 125 / 8 */
    -    if ( scale >= 0x20C49BAL )
    -      blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 );
    -    else
    -      blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 );
    +    blues->no_overshoots = FT_BOOL( scale < blues->blue_scale );
     
         /*                                                        */
         /*  The blue threshold is the font units distance under   */
    @@ -420,8 +408,8 @@
           FT_Int  threshold = blues->blue_shift;
     
     
    -      while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 )
    -        threshold--;
    +      if ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 )
    +        threshold = 32 * 0x10000L / scale;
     
           blues->blue_threshold = threshold;
         }
    @@ -708,7 +696,6 @@
     
           /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
           {
    -        FT_Fixed  max_scale;
             FT_Short  max_height = 1;
     
     
    @@ -725,11 +712,12 @@
                                               priv->family_other_blues,
                                               max_height );
     
    -        /* BlueScale is scaled 1000 times */
    -        max_scale = FT_DivFix( 1000, max_height );
    -        globals->blues.blue_scale = priv->blue_scale < max_scale
    -                                      ? priv->blue_scale
    -                                      : max_scale;
    +        /* restrict BlueScale value that is amplified 1000-fold and */
    +        /* rescale it to be comparable to the metrics scale         */
    +        if ( FT_MulFix( max_height, priv->blue_scale ) < 1000 )
    +          globals->blues.blue_scale = priv->blue_scale * 8 / 125;
    +        else
    +          globals->blues.blue_scale = 64 * 0x10000L / max_height;
           }
     
           globals->blues.blue_shift = priv->blue_shift;
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
    index c5a5c913168..555e99facb2 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript hinter global hinting management.
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
    index 9965d5b16bf..c9f4a94fe98 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType PostScript hinter module implementation (body).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
    index 62ac0a60fdc..de9c398e9fb 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript hinter module interface (specification).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
    index e9641340e53..7076664ddde 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h
    @@ -4,7 +4,7 @@
      *
      *   PS Hinter error codes (specification only).
      *
    - * Copyright (C) 2003-2024 by
    + * Copyright (C) 2003-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
    index 0b2b549fc29..13754313fbb 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c
    @@ -4,7 +4,7 @@
      *
      *   FreeType PostScript hints recorder (body).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -467,7 +467,7 @@
           table->num_masks--;
         }
         else
    -      FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
    +      FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%u,%u)\n",
                       index1, index2 ));
     
       Exit:
    @@ -817,7 +817,7 @@
         /* limit "dimension" to 0..1 */
         if ( dimension > 1 )
         {
    -      FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
    +      FT_TRACE0(( "ps_hints_stem: invalid dimension (%u) used\n",
                       dimension ));
           dimension = ( dimension != 0 );
         }
    @@ -870,7 +870,7 @@
           /* limit "dimension" to 0..1 */
           if ( dimension > 1 )
           {
    -        FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
    +        FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%u) used\n",
                         dimension ));
             dimension = ( dimension != 0 );
           }
    @@ -976,7 +976,7 @@
           if ( bit_count !=  count1 + count2 )
           {
             FT_TRACE0(( "ps_hints_t2mask:"
    -                    " called with invalid bitcount %d (instead of %d)\n",
    +                    " called with invalid bitcount %u (instead of %u)\n",
                        bit_count, count1 + count2 ));
     
             /* simply ignore the operator */
    @@ -1022,7 +1022,7 @@
           if ( bit_count !=  count1 + count2 )
           {
             FT_TRACE0(( "ps_hints_t2counter:"
    -                    " called with invalid bitcount %d (instead of %d)\n",
    +                    " called with invalid bitcount %u (instead of %u)\n",
                        bit_count, count1 + count2 ));
     
             /* simply ignore the operator */
    diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
    index 7e375af7ba8..a79069f98d2 100644
    --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
    +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h
    @@ -4,7 +4,7 @@
      *
      *   Postscript (Type1/Type2) hints recorder (specification).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
    index 35d054d1cfb..c5d71edad88 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
    +++ b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c
    @@ -4,7 +4,7 @@
      *
      *   psnames module implementation (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
    index 770458316b1..482fd0a36d1 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h
    @@ -4,7 +4,7 @@
      *
      *   High-level psnames module interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h b/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
    index e123eb65e39..17987f9cd4f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h
    @@ -4,7 +4,7 @@
      *
      *   PS names module error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h b/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
    index 2a941b04609..65ce6c0b47f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
    +++ b/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h
    @@ -4,7 +4,7 @@
      *
      *   PostScript glyph names.
      *
    - * Copyright (C) 2005-2024 by
    + * Copyright (C) 2005-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h b/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
    index 943f2aa0a50..9d97223e94e 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h
    @@ -5,7 +5,7 @@
      *   Miscellaneous macros for stand-alone rasterizer (specification
      *   only).
      *
    - * Copyright (C) 2005-2024 by
    + * Copyright (C) 2005-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
    index e4b7b937d5a..807d444e7aa 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph rasterizer (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -251,7 +251,11 @@
       /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
       /* for clipping computations.  It simply uses the FT_MulDiv() function   */
       /* defined in `ftcalc.h'.                                                */
    -#define SMulDiv_No_Round  FT_MulDiv_No_Round
    +#ifdef FT_INT64
    +#define SMulDiv( a, b, c )  (Long)( (FT_Int64)(a) * (b) / (c) )
    +#else
    +#define SMulDiv  FT_MulDiv_No_Round
    +#endif
     
       /* The rasterizer is a very general purpose component; please leave */
       /* the following redefinitions there (you never know your target    */
    @@ -653,7 +657,7 @@
           ras.cProfile->height = 0;
         }
     
    -    ras.cProfile->flags  = ras.dropOutControl;
    +    ras.cProfile->flags = ras.dropOutControl;
     
         switch ( aState )
         {
    @@ -967,14 +971,14 @@
           goto Fin;
         }
     
    -    Ix     = SMulDiv_No_Round( e - y1, Dx, Dy );
    +    Ix     = SMulDiv( e - y1, Dx, Dy );
         x1    += Ix;
         *top++ = x1;
     
         if ( --size )
         {
           Ax = Dx * ( e - y1 )    - Dy * Ix;  /* remainder */
    -      Ix = FMulDiv( ras.precision, Dx, Dy );
    +      Ix = SMulDiv( ras.precision, Dx, Dy );
           Rx = Dx * ras.precision - Dy * Ix;  /* remainder */
           Dx = 1;
     
    @@ -1090,8 +1094,8 @@
         PLong  top;
     
     
    -    y1  = arc[degree].y;
    -    y2  = arc[0].y;
    +    y1 = arc[degree].y;
    +    y2 = arc[0].y;
     
         if ( y2 < miny || y1 > maxy )
           return SUCCESS;
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
    index ad9cb1b9fe0..64499bf955b 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph rasterizer (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
    index fd9f174f2e1..3fa008704e5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph rasterizer interface (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
    index cf3e73c0a24..d838a942b04 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h
    @@ -4,7 +4,7 @@
      *
      *   The FreeType glyph rasterizer interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h b/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
    index 326d42e0438..39d82a8051a 100644
    --- a/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h
    @@ -4,7 +4,7 @@
      *
      *   monochrome renderer error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
    index 76181568af9..24fb3455598 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c
    @@ -4,7 +4,7 @@
      *
      *   PNG Bitmap glyph support.
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * Google, Inc.
      * Written by Stuart Gill and Behdad Esfahbod.
      *
    @@ -420,10 +420,7 @@
         if ( populate_map_and_metrics )
         {
           /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
    -      FT_ULong  size = map->rows * (FT_ULong)map->pitch;
    -
    -
    -      error = ft_glyphslot_alloc_bitmap( slot, size );
    +      error = ft_glyphslot_alloc_bitmap( slot );
           if ( error )
             goto DestroyExit;
         }
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
    index 6e7a5c08e71..c59199e60df 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h
    @@ -4,7 +4,7 @@
      *
      *   PNG Bitmap glyph support.
      *
    - * Copyright (C) 2013-2024 by
    + * Copyright (C) 2013-2025 by
      * Google, Inc.
      * Written by Stuart Gill and Behdad Esfahbod.
      *
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
    index 81072207b49..32291e23e36 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c
    @@ -4,7 +4,7 @@
      *
      *   High-level SFNT driver interface (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -895,7 +895,7 @@
             FT_TRACE0(( "sfnt_get_var_ps_name:"
                         " Shortening variation PS name prefix\n" ));
             FT_TRACE0(( "                     "
    -                    " to %d characters\n", len ));
    +                    " to %u characters\n", len ));
           }
     
           face->var_postscript_prefix     = result;
    @@ -1142,12 +1142,7 @@
         FT_Error         error;
     
     
    -    /* XXX: I don't know whether this is correct, since
    -     *      tt_face_find_bdf_prop only returns something correct if we have
    -     *      previously selected a size that is listed in the BDF table.
    -     *      Should we change the BDF table format to include single offsets
    -     *      for `CHARSET_REGISTRY' and `CHARSET_ENCODING'?
    -     */
    +    /* We expect that a bitmap strike has been selected. */
         error = tt_face_find_bdf_prop( face, "CHARSET_REGISTRY", ®istry );
         if ( !error )
         {
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
    index 6f71489fdc1..be4e33166c1 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h
    @@ -4,7 +4,7 @@
      *
      *   High-level SFNT driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
    index d3ca1d9aa8b..2da4ac776b0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h
    @@ -4,7 +4,7 @@
      *
      *   SFNT error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
    index 6ee4e5e939b..6af35787e85 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
    @@ -4,7 +4,7 @@
      *
      *   SFNT object management (base).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -579,6 +579,9 @@
         if ( face_instance_index < 0 && face_index > 0 )
           face_index--;
     
    +    /* Note that `face_index` is also used to enumerate elements */
    +    /* of containers like a Mac Resource; this means we must     */
    +    /* check whether we actually have a TTC.                     */
         if ( face_index >= face->ttc_header.count )
         {
           if ( face_instance_index >= 0 )
    @@ -1127,9 +1130,9 @@
             flags |= FT_FACE_FLAG_VERTICAL;
     
           /* kerning available ? */
    -      if ( TT_FACE_HAS_KERNING( face )
    +      if ( face->kern_avail_bits
     #ifdef TT_CONFIG_OPTION_GPOS_KERNING
    -           || face->gpos_kerning_available
    +           || face->num_gpos_lookups_kerning
     #endif
              )
             flags |= FT_FACE_FLAG_KERNING;
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
    index 90847d95732..8c38b727950 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h
    @@ -4,7 +4,7 @@
      *
      *   SFNT object management (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
    index 14514bf9574..015c7b78b4d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.c
    @@ -4,7 +4,7 @@
      *
      *   WOFF format management (base).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
    index a04735ffe28..df7ace5c209 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff.h
    @@ -4,7 +4,7 @@
      *
      *   WOFFF format management (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
    index 589b3e0c6b7..41c233597b8 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c
    @@ -4,7 +4,7 @@
      *
      *   WOFF2 format management (base).
      *
    - * Copyright (C) 2019-2024 by
    + * Copyright (C) 2019-2025 by
      * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -902,7 +902,7 @@
           substreams[i].offset = pos + offset;
           substreams[i].size   = substream_size;
     
    -      FT_TRACE5(( "  Substream %d: offset = %lu; size = %lu;\n",
    +      FT_TRACE5(( "  Substream %u: offset = %lu; size = %lu;\n",
                       i, substreams[i].offset, substreams[i].size ));
           offset += substream_size;
         }
    @@ -1043,7 +1043,6 @@
             FT_ULong   total_n_points = 0;
             FT_UShort  n_points_contour;
             FT_UInt    j;
    -        FT_ULong   flag_size;
             FT_ULong   triplet_size;
             FT_ULong   triplet_bytes_used;
             FT_Bool    have_overlap  = FALSE;
    @@ -1088,8 +1087,8 @@
             }
             substreams[N_POINTS_STREAM].offset = FT_STREAM_POS();
     
    -        flag_size = total_n_points;
    -        if ( flag_size > substreams[FLAG_STREAM].size )
    +        points_size += total_n_points;
    +        if ( points_size > substreams[FLAG_STREAM].size )
               goto Fail;
     
             flags_buf   = stream->base + substreams[FLAG_STREAM].offset;
    @@ -1106,8 +1105,7 @@
             triplet_bytes_used = 0;
     
             /* Create array to store point information. */
    -        points_size = total_n_points;
    -        if ( FT_QNEW_ARRAY( points, points_size ) )
    +        if ( FT_QNEW_ARRAY( points, total_n_points ) )
               goto Fail;
     
             if ( triplet_decode( flags_buf,
    @@ -1118,7 +1116,7 @@
                                  &triplet_bytes_used ) )
               goto Fail;
     
    -        substreams[FLAG_STREAM].offset  += flag_size;
    +        substreams[FLAG_STREAM].offset  += total_n_points;
             substreams[GLYPH_STREAM].offset += triplet_bytes_used;
     
             if ( FT_STREAM_SEEK( substreams[GLYPH_STREAM].offset ) ||
    @@ -1592,7 +1590,7 @@
           WOFF2_TableRec  table = *( indices[nn] );
     
     
    -      FT_TRACE3(( "Seeking to %ld with table size %ld.\n",
    +      FT_TRACE3(( "Seeking to %lu with table size %lu.\n",
                       table.src_offset, table.src_length ));
           FT_TRACE3(( "Table tag: %c%c%c%c.\n",
                       (FT_Char)( table.Tag >> 24 ),
    @@ -1943,7 +1941,7 @@
           src_offset       += table->TransformLength;
           table->dst_offset = 0;
     
    -      FT_TRACE2(( "  %c%c%c%c  %08d  %08d   %08ld    %08ld    %08ld\n",
    +      FT_TRACE2(( "  %c%c%c%c  %08d  %08d   %08lu    %08lu    %08lu\n",
                       (FT_Char)( table->Tag >> 24 ),
                       (FT_Char)( table->Tag >> 16 ),
                       (FT_Char)( table->Tag >> 8  ),
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
    index f41140648dc..588761d0c8e 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.h
    @@ -4,7 +4,7 @@
      *
      *   WOFFF2 format management (specification).
      *
    - * Copyright (C) 2019-2024 by
    + * Copyright (C) 2019-2025 by
      * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
    index 28f4d1173c0..91b02344224 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType character mapping table (cmap) support (body).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -179,7 +179,7 @@
     
     
         cmap_info->format   = 0;
    -    cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
    +    cmap_info->language = TT_PEEK_USHORT( p );
     
         return FT_Err_Ok;
       }
    @@ -596,7 +596,7 @@
     
     
         cmap_info->format   = 2;
    -    cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
    +    cmap_info->language = TT_PEEK_USHORT( p );
     
         return FT_Err_Ok;
       }
    @@ -1539,7 +1539,7 @@
     
     
         cmap_info->format   = 4;
    -    cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
    +    cmap_info->language = TT_PEEK_USHORT( p );
     
         return FT_Err_Ok;
       }
    @@ -1712,7 +1712,7 @@
     
     
         cmap_info->format   = 6;
    -    cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
    +    cmap_info->language = TT_PEEK_USHORT( p );
     
         return FT_Err_Ok;
       }
    @@ -2009,7 +2009,7 @@
     
     
         cmap_info->format   = 8;
    -    cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
    +    cmap_info->language = TT_PEEK_ULONG( p );
     
         return FT_Err_Ok;
       }
    @@ -2184,7 +2184,7 @@
     
     
         cmap_info->format   = 10;
    -    cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
    +    cmap_info->language = TT_PEEK_ULONG( p );
     
         return FT_Err_Ok;
       }
    @@ -2528,7 +2528,7 @@
     
     
         cmap_info->format   = 12;
    -    cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
    +    cmap_info->language = TT_PEEK_ULONG( p );
     
         return FT_Err_Ok;
       }
    @@ -2844,7 +2844,7 @@
     
     
         cmap_info->format   = 13;
    -    cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
    +    cmap_info->language = TT_PEEK_ULONG( p );
     
         return FT_Err_Ok;
       }
    @@ -3792,7 +3792,7 @@
           return FT_THROW( Invalid_Table );
     
         /* Version 1.8.3 of the OpenType specification contains the following */
    -    /* (https://docs.microsoft.com/en-us/typography/opentype/spec/cmap):  */
    +    /* (https://learn.microsoft.com/typography/opentype/spec/cmap):       */
         /*                                                                    */
         /*   The 'cmap' table version number remains at 0x0000 for fonts that */
         /*   make use of the newer subtable formats.                          */
    @@ -3803,7 +3803,7 @@
         p += 2;
     
         num_cmaps = TT_NEXT_USHORT( p );
    -    FT_TRACE4(( "tt_face_build_cmaps: %d cmaps\n", num_cmaps ));
    +    FT_TRACE4(( "tt_face_build_cmaps: %u cmaps\n", num_cmaps ));
     
         limit = table + face->cmap_size;
         for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
    index e2c5e72bf02..645e9e37e0c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType character mapping table (cmap) support (specification).
      *
    - * Copyright (C) 2002-2024 by
    + * Copyright (C) 2002-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
    index 370898363f3..65807bb7378 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h
    @@ -4,7 +4,7 @@
      *
      *   TT CMAP classes definitions (specification only).
      *
    - * Copyright (C) 2009-2024 by
    + * Copyright (C) 2009-2025 by
      * Oran Agra and Mickey Gabel.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
    index b37658dde9e..7929b7aaf4c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType colored glyph layer support (body).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, Dominik Röttsches, and Werner Lemberg.
      *
      * Originally written by Shao Yu Zhang .
    @@ -51,7 +51,7 @@
     #define COLOR_STOP_SIZE                   6U
     #define VAR_IDX_BASE_SIZE                 4U
     #define LAYER_SIZE                        4U
    -/* https://docs.microsoft.com/en-us/typography/opentype/spec/colr#colr-header */
    +/* https://learn.microsoft.com/typography/opentype/spec/colr#colr-header */
     /* 3 * uint16 + 2 * Offset32 */
     #define COLRV0_HEADER_SIZE               14U
     /* COLRV0_HEADER_SIZE + 5 * Offset32 */
    @@ -1749,7 +1749,6 @@
         FT_UInt  x, y;
         FT_Byte  b, g, r, alpha;
     
    -    FT_ULong  size;
         FT_Byte*  src;
         FT_Byte*  dst;
     
    @@ -1767,13 +1766,9 @@
           dstSlot->bitmap.pitch      = (int)dstSlot->bitmap.width * 4;
           dstSlot->bitmap.num_grays  = 256;
     
    -      size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch;
    -
    -      error = ft_glyphslot_alloc_bitmap( dstSlot, size );
    +      error = ft_glyphslot_alloc_bitmap( dstSlot );
           if ( error )
             return error;
    -
    -      FT_MEM_ZERO( dstSlot->bitmap.buffer, size );
         }
         else
         {
    @@ -1805,8 +1800,7 @@
             FT_Byte*  q;
     
     
    -        size  = rows * pitch;
    -        if ( FT_ALLOC( buf, size ) )
    +        if ( FT_ALLOC_MULT( buf, rows, pitch ) )
               return error;
     
             p = dstSlot->bitmap.buffer;
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
    index 30031464c73..3913acc74d5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType colored glyph layer support (specification).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * Originally written by Shao Yu Zhang .
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
    index 997eb869ffc..6d1208f6af2 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType color palette support (body).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * Originally written by Shao Yu Zhang .
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
    index bb301ae88b6..a0b4c9d927f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType color palette support (specification).
      *
    - * Copyright (C) 2018-2024 by
    + * Copyright (C) 2018-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * Originally written by Shao Yu Zhang .
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
    index f0411366af4..76618b0d3bb 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c
    @@ -2,10 +2,9 @@
      *
      * ttkern.c
      *
    - *   Load the basic TrueType kerning table.  This doesn't handle
    - *   kerning data within the GPOS table at the moment.
    + *   Routines to parse and access the 'kern' table for kerning (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
    index a54e51df12d..e0075dce61d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h
    @@ -2,10 +2,10 @@
      *
      * ttkern.h
      *
    - *   Load the basic TrueType kerning table.  This doesn't handle
    - *   kerning data within the GPOS table at the moment.
    + *   Routines to parse and access the 'kern' table for kerning
    + *   (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -40,8 +40,6 @@ FT_BEGIN_HEADER
                            FT_UInt     left_glyph,
                            FT_UInt     right_glyph );
     
    -#define TT_FACE_HAS_KERNING( face )  ( (face)->kern_avail_bits != 0 )
    -
     
     FT_END_HEADER
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
    index c3a5fae2cb9..0c257ce4d31 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c
    @@ -5,7 +5,7 @@
      *   Load the basic TrueType tables, i.e., tables that can be either in
      *   TTF or OTF fonts (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -535,7 +535,8 @@
        *     The tag of table to load.  Use the value 0 if you want
        *     to access the whole font file, else set this parameter
        *     to a valid TrueType table tag that you can forge with
    -   *     the MAKE_TT_TAG macro.
    +   *     the MAKE_TT_TAG macro.  Use value 1 to access the table
    +   *     directory.
        *
        *   offset ::
        *     The starting offset in the table (or the file if
    @@ -577,7 +578,29 @@
         FT_ULong   size;
     
     
    -    if ( tag != 0 )
    +    if ( tag == 0 )
    +    {
    +      /* The whole font file. */
    +      size = face->root.stream->size;
    +    }
    +    else if ( tag == 1 )
    +    {
    +      /* The currently selected font's table directory.            */
    +      /*                                                           */
    +      /* Note that `face_index` is also used to enumerate elements */
    +      /* of containers like a Mac Resource; this means we must     */
    +      /* check whether we actually have a TTC (with multiple table */
    +      /* directories).                                             */
    +      FT_Long  idx = face->root.face_index & 0xFFFF;
    +
    +
    +      if ( idx >= face->ttc_header.count )
    +        idx = 0;
    +
    +      offset += face->ttc_header.offsets[idx];
    +      size    = 4 + 8 + 16 * face->num_tables;
    +    }
    +    else
         {
           /* look for tag in font directory */
           table = tt_face_lookup_table( face, tag );
    @@ -590,9 +613,6 @@
           offset += table->Offset;
           size    = table->Length;
         }
    -    else
    -      /* tag == 0 -- the user wants to access the font file directly */
    -      size = face->root.stream->size;
     
         if ( length && *length == 0 )
         {
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
    index 2b1d62d9bd9..e3666c901b1 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h
    @@ -5,7 +5,7 @@
      *   Load the basic TrueType tables, i.e., tables that can be either in
      *   TTF or OTF fonts (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
    index 27884118563..541d8447470 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c
    @@ -4,7 +4,7 @@
      *
      *   Load the metrics tables common to TTF and OTF fonts (body).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -306,7 +306,7 @@
         }
     
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    -    if ( var && face->blend )
    +    if ( var && FT_IS_VARIATION( &face->root ) )
         {
           FT_Face  f = FT_FACE( face );
           FT_Int   a = (FT_Int)*aadvance;
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
    index 34b3c0e18f2..1ee84507f15 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h
    @@ -4,7 +4,7 @@
      *
      *   Load the metrics tables common to TTF and OTF fonts (specification).
      *
    - * Copyright (C) 2006-2024 by
    + * Copyright (C) 2006-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
    index 5698a62c8d1..4246b6c8eff 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c
    @@ -5,7 +5,7 @@
      *   PostScript name table processing for TrueType and OpenType fonts
      *   (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
    index 150db6c3981..a11b6696854 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h
    @@ -5,7 +5,7 @@
      *   PostScript name table processing for TrueType and OpenType fonts
      *   (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
    index cb3a8abf182..34e45619817 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType embedded bitmap support (body).
      *
    - * Copyright (C) 2005-2024 by
    + * Copyright (C) 2005-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * Copyright 2013 by Google, Inc.
    @@ -342,7 +342,7 @@
                 FT_TRACE2(( "tt_face_load_strike_metrics:"
                             " sanitizing invalid ascender and descender\n" ));
                 FT_TRACE2(( "                            "
    -                        " values for strike %ld (%dppem, %dppem)\n",
    +                        " values for strike %lu (%dppem, %dppem)\n",
                             strike_index,
                             metrics->x_ppem, metrics->y_ppem ));
     
    @@ -547,7 +547,6 @@
         FT_Error    error = FT_Err_Ok;
         FT_UInt     width, height;
         FT_Bitmap*  map = decoder->bitmap;
    -    FT_ULong    size;
     
     
         if ( !decoder->metrics_loaded )
    @@ -599,17 +598,11 @@
           goto Exit;
         }
     
    -    size = map->rows * (FT_ULong)map->pitch;
    -
    -    /* check that there is no empty image */
    -    if ( size == 0 )
    -      goto Exit;     /* exit successfully! */
    -
         if ( metrics_only )
           goto Exit;     /* only metrics are requested */
     
    -    error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
    -    if ( error )
    +    error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph );
    +    if ( error || !map->buffer )
           goto Exit;
     
         decoder->bitmap_allocated = 1;
    @@ -993,7 +986,7 @@
           goto Fail;
         }
     
    -    FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d component%s\n",
    +    FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %u component%s\n",
                     num_components,
                     num_components == 1 ? "" : "s" ));
     
    @@ -1419,7 +1412,7 @@
         image_start = image_offset + image_start;
     
         FT_TRACE3(( "tt_sbit_decoder_load_image:"
    -                " found sbit (format %d) for glyph index %d\n",
    +                " found sbit (format %u) for glyph index %u\n",
                     image_format, glyph_index ));
     
         return tt_sbit_decoder_load_bitmap( decoder,
    @@ -1438,13 +1431,13 @@
         if ( recurse_count )
         {
           FT_TRACE4(( "tt_sbit_decoder_load_image:"
    -                  " missing subglyph sbit with glyph index %d\n",
    +                  " missing subglyph sbit with glyph index %u\n",
                       glyph_index ));
           return FT_THROW( Invalid_Composite );
         }
     
         FT_TRACE4(( "tt_sbit_decoder_load_image:"
    -                " no sbit found for glyph index %d\n", glyph_index ));
    +                " no sbit found for glyph index %u\n", glyph_index ));
         return FT_THROW( Missing_Bitmap );
       }
     
    @@ -1462,12 +1455,13 @@
         FT_Int    originOffsetX, originOffsetY;
         FT_Tag    graphicType;
         FT_Int    recurse_depth = 0;
    +    FT_Bool   flipped       = FALSE;
     
         FT_Error  error;
         FT_Byte*  p;
     
    -    FT_UNUSED( map );
     #ifndef FT_CONFIG_OPTION_USE_PNG
    +    FT_UNUSED( map );
         FT_UNUSED( metrics_only );
     #endif
     
    @@ -1517,12 +1511,16 @@
     
         switch ( graphicType )
         {
    +    case FT_MAKE_TAG( 'f', 'l', 'i', 'p' ):
    +      flipped = !flipped;
    +      FALL_THROUGH;
    +
         case FT_MAKE_TAG( 'd', 'u', 'p', 'e' ):
    -      if ( recurse_depth < 4 )
    +      if ( recurse_depth++ < 4 )
           {
             glyph_index = FT_GET_USHORT();
             FT_FRAME_EXIT();
    -        recurse_depth++;
    +
             goto retry;
           }
           error = FT_THROW( Invalid_File_Format );
    @@ -1540,6 +1538,38 @@
                                  glyph_end - glyph_start - 8,
                                  TRUE,
                                  metrics_only );
    +      if ( flipped && !metrics_only && !error )
    +      {
    +        FT_UInt32*  curr_pos = (FT_UInt32*)map->buffer;
    +
    +        /* `Load_SBit_Png` always returns a pixmap with 32 bits per pixel */
    +        /* and no extra pitch bytes.                                      */
    +        FT_UInt  width = map->width;
    +        FT_UInt  y;
    +
    +
    +        for ( y = 0; y < map->rows; y++ )
    +        {
    +          FT_UInt32*  left  = curr_pos;
    +          FT_UInt32*  right = curr_pos + width - 1;
    +
    +
    +          while ( left < right )
    +          {
    +            FT_UInt32  value;
    +
    +
    +            value  = *right;
    +            *right = *left;
    +            *left  = value;
    +
    +            left++;
    +            right--;
    +          }
    +
    +          curr_pos += width;
    +        }
    +      }
     #else
           error = FT_THROW( Unimplemented_Feature );
     #endif
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
    index 96f80a58424..7427149d68f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType and OpenType embedded bitmap support (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
    index 532ccfa1737..0f9e3889aab 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.c
    @@ -4,7 +4,7 @@
      *
      *   WOFF2 Font table tags (base).
      *
    - * Copyright (C) 2019-2024 by
    + * Copyright (C) 2019-2025 by
      * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
    index d03b4b41bc9..e223022962e 100644
    --- a/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
    +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/woff2tags.h
    @@ -4,7 +4,7 @@
      *
      *   WOFF2 Font table tags (specification).
      *
    - * Copyright (C) 2019-2024 by
    + * Copyright (C) 2019-2025 by
      * Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
    index b7c0632a6fa..3c387aea0ac 100644
    --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
    +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c
    @@ -4,7 +4,7 @@
      *
      *   A new `perfect' anti-aliasing renderer (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -157,10 +157,6 @@
     
     #define ft_memset   memset
     
    -#define ft_setjmp   setjmp
    -#define ft_longjmp  longjmp
    -#define ft_jmp_buf  jmp_buf
    -
     typedef ptrdiff_t  FT_PtrDist;
     
     
    @@ -170,8 +166,8 @@ typedef ptrdiff_t  FT_PtrDist;
     #define Smooth_Err_Invalid_Argument     -3
     #define Smooth_Err_Raster_Overflow      -4
     
    -#define FT_BEGIN_HEADER
    -#define FT_END_HEADER
    +#define FT_BEGIN_HEADER  /* nothing */
    +#define FT_END_HEADER    /* nothing */
     
     #include "ftimage.h"
     #include "ftgrays.h"
    @@ -495,6 +491,7 @@ typedef ptrdiff_t  FT_PtrDist;
         TCoord  min_ey, max_ey;
         TCoord  count_ey;        /* same as (max_ey - min_ey) */
     
    +    int         error;       /* pool overflow exception                  */
         PCell       cell;        /* current cell                             */
         PCell       cell_free;   /* call allocation next free slot           */
         PCell       cell_null;   /* last cell, used as dumpster and limit    */
    @@ -510,8 +507,6 @@ typedef ptrdiff_t  FT_PtrDist;
         FT_Raster_Span_Func  render_span;
         void*                render_span_data;
     
    -    ft_jmp_buf  jump_buffer;
    -
       } gray_TWorker, *gray_PWorker;
     
     #if defined( _MSC_VER )
    @@ -613,9 +608,14 @@ typedef ptrdiff_t  FT_PtrDist;
           }
     
           /* insert new cell */
    -      cell = ras.cell_free++;
    -      if ( cell >= ras.cell_null )
    -        ft_longjmp( ras.jump_buffer, 1 );
    +      cell = ras.cell_free;
    +      if ( cell == ras.cell_null )
    +      {
    +        ras.error = FT_THROW( Raster_Overflow );
    +        goto Found;
    +      }
    +
    +      ras.cell_free = cell + 1;
     
           cell->x     = ex;
           cell->area  = 0;
    @@ -1353,7 +1353,8 @@ typedef ptrdiff_t  FT_PtrDist;
     
         ras.x = x;
         ras.y = y;
    -    return 0;
    +
    +    return ras.error;
       }
     
     
    @@ -1365,7 +1366,8 @@ typedef ptrdiff_t  FT_PtrDist;
     
     
         gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
    -    return 0;
    +
    +    return ras.error;
       }
     
     
    @@ -1378,7 +1380,8 @@ typedef ptrdiff_t  FT_PtrDist;
     
     
         gray_render_conic( RAS_VAR_ control, to );
    -    return 0;
    +
    +    return ras.error;
       }
     
     
    @@ -1392,7 +1395,8 @@ typedef ptrdiff_t  FT_PtrDist;
     
     
         gray_render_cubic( RAS_VAR_ control1, control2, to );
    -    return 0;
    +
    +    return ras.error;
       }
     
     
    @@ -1700,30 +1704,22 @@ typedef ptrdiff_t  FT_PtrDist;
       gray_convert_glyph_inner( RAS_ARG_
                                 int  continued )
       {
    -    volatile int  error;
    +    int  error;
     
     
    -    if ( ft_setjmp( ras.jump_buffer ) == 0 )
    -    {
    -      if ( continued )
    -        FT_Trace_Disable();
    -      error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
    -      if ( continued )
    -        FT_Trace_Enable();
    +    if ( continued )
    +      FT_Trace_Disable();
    +    error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
    +    if ( continued )
    +      FT_Trace_Enable();
     
    -      FT_TRACE7(( "band [%d..%d]: %td cell%s remaining\n",
    -                  ras.min_ey,
    -                  ras.max_ey,
    -                  ras.cell_null - ras.cell_free,
    -                  ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
    -    }
    -    else
    -    {
    -      error = FT_THROW( Raster_Overflow );
    -
    -      FT_TRACE7(( "band [%d..%d]: to be bisected\n",
    -                  ras.min_ey, ras.max_ey ));
    -    }
    +    FT_TRACE7(( error == Smooth_Err_Raster_Overflow
    +                  ? "band [%d..%d]: to be bisected\n"
    +                  : "band [%d..%d]: %td cell%s remaining\n",
    +                ras.min_ey,
    +                ras.max_ey,
    +                ras.cell_null - ras.cell_free,
    +                ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
     
         return error;
       }
    @@ -1808,7 +1804,7 @@ typedef ptrdiff_t  FT_PtrDist;
               FT_FILL_RULE( coverage, cover, fill );
     
               span[n].coverage = (unsigned char)coverage;
    -          span[n].x        = (short)x;
    +          span[n].x        = (unsigned short)x;
               span[n].len      = (unsigned short)( cell->x - x );
     
               if ( ++n == FT_MAX_GRAY_SPANS )
    @@ -1827,7 +1823,7 @@ typedef ptrdiff_t  FT_PtrDist;
               FT_FILL_RULE( coverage, area, fill );
     
               span[n].coverage = (unsigned char)coverage;
    -          span[n].x        = (short)cell->x;
    +          span[n].x        = (unsigned short)cell->x;
               span[n].len      = 1;
     
               if ( ++n == FT_MAX_GRAY_SPANS )
    @@ -1873,6 +1869,7 @@ typedef ptrdiff_t  FT_PtrDist;
         TCoord*  band;
     
         int  continued = 0;
    +    int  error     = Smooth_Err_Ok;
     
     
         /* Initialize the null cell at the end of the poll. */
    @@ -1907,7 +1904,6 @@ typedef ptrdiff_t  FT_PtrDist;
           do
           {
             TCoord  i;
    -        int     error;
     
     
             ras.min_ex = band[1];
    @@ -1922,6 +1918,7 @@ typedef ptrdiff_t  FT_PtrDist;
     
             ras.cell_free = buffer + n;
             ras.cell      = ras.cell_null;
    +        ras.error     = Smooth_Err_Ok;
     
             error     = gray_convert_glyph_inner( RAS_VAR_ continued );
             continued = 1;
    @@ -1936,7 +1933,7 @@ typedef ptrdiff_t  FT_PtrDist;
               continue;
             }
             else if ( error != Smooth_Err_Raster_Overflow )
    -          return error;
    +          goto Exit;
     
             /* render pool overflow; we will reduce the render band by half */
             i = ( band[0] - band[1] ) >> 1;
    @@ -1945,7 +1942,8 @@ typedef ptrdiff_t  FT_PtrDist;
             if ( i == 0 )
             {
               FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
    -          return FT_THROW( Raster_Overflow );
    +          error = FT_THROW( Raster_Overflow );
    +          goto Exit;
             }
     
             band++;
    @@ -1954,7 +1952,11 @@ typedef ptrdiff_t  FT_PtrDist;
           } while ( band >= bands );
         }
     
    -    return Smooth_Err_Ok;
    +  Exit:
    +    ras.cell   = ras.cell_free = ras.cell_null = NULL;
    +    ras.ycells = NULL;
    +
    +    return error;
       }
     
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
    index 940fbe8c79b..e463e5b3eb8 100644
    --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
    +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h
    @@ -4,7 +4,7 @@
      *
      *   FreeType smooth renderer declaration
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -19,11 +19,6 @@
     #ifndef FTGRAYS_H_
     #define FTGRAYS_H_
     
    -#ifdef __cplusplus
    -  extern "C" {
    -#endif
    -
    -
     #ifdef STANDALONE_
     #include "ftimage.h"
     #else
    @@ -31,6 +26,7 @@
     #include 
     #endif
     
    +FT_BEGIN_HEADER
     
       /**************************************************************************
        *
    @@ -46,10 +42,7 @@
     
       FT_EXPORT_VAR( const FT_Raster_Funcs )  ft_grays_raster;
     
    -
    -#ifdef __cplusplus
    -  }
    -#endif
    +FT_END_HEADER
     
     #endif /* FTGRAYS_H_ */
     
    diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
    index 6d41fb8e0fd..8d5068549fa 100644
    --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h
    @@ -4,7 +4,7 @@
      *
      *   smooth renderer error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
    index f0acc1ea4a6..5a7a852a619 100644
    --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
    +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c
    @@ -4,7 +4,7 @@
      *
      *   Anti-aliasing renderer interface (body).
      *
    - * Copyright (C) 2000-2024 by
    + * Copyright (C) 2000-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -80,6 +80,7 @@
       {
         unsigned char*  origin;  /* pixmap origin at the bottom-left */
         int             pitch;   /* pitch to go down one row */
    +    unsigned char   wght[5]; /* filtering weights */
     
       } TOrigin;
     
    @@ -274,6 +275,32 @@
       }
     
     
    +  /* This function applies a horizontal filter in direct rendering mode */
    +  static void
    +  ft_smooth_lcd_spans( int             y,
    +                       int             count,
    +                       const FT_Span*  spans,
    +                       void*           target_ )   /* TOrigin* */
    +  {
    +    TOrigin*  target = (TOrigin*)target_;
    +
    +    unsigned char*  dst_line = target->origin - y * target->pitch - 2;
    +    unsigned char*  dst;
    +    unsigned short  w;
    +
    +
    +    for ( ; count--; spans++ )
    +      for ( dst = dst_line + spans->x, w = spans->len; w--; dst++ )
    +      {
    +        dst[0] += ( spans->coverage * target->wght[0] + 85 ) >> 8;
    +        dst[1] += ( spans->coverage * target->wght[1] + 85 ) >> 8;
    +        dst[2] += ( spans->coverage * target->wght[2] + 85 ) >> 8;
    +        dst[3] += ( spans->coverage * target->wght[3] + 85 ) >> 8;
    +        dst[4] += ( spans->coverage * target->wght[4] + 85 ) >> 8;
    +      }
    +  }
    +
    +
       static FT_Error
       ft_smooth_raster_lcd( FT_Renderer  render,
                             FT_Outline*  outline,
    @@ -285,11 +312,47 @@
         FT_Vector*  vec;
     
         FT_Raster_Params  params;
    +    TOrigin           target;
     
     
    -    params.target = bitmap;
    -    params.source = outline;
    -    params.flags  = FT_RASTER_FLAG_AA;
    +    if ( render->root.library->lcd_weights[2] )
    +    {
    +      /* Reject outlines that are too wide for 16-bit FT_Span.       */
    +      /* Other limits are applied upstream with the same error code. */
    +      if ( bitmap->width > 0x7FFF )
    +        return FT_THROW( Raster_Overflow );
    +
    +      /* Set up direct rendering for instant filtering. */
    +      params.source     = outline;
    +      params.flags      = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
    +      params.gray_spans = ft_smooth_lcd_spans;
    +      params.user       = ⌖
    +
    +      params.clip_box.xMin = 0;
    +      params.clip_box.yMin = 0;
    +      params.clip_box.xMax = bitmap->width;
    +      params.clip_box.yMax = bitmap->rows;
    +
    +      if ( bitmap->pitch < 0 )
    +        target.origin = bitmap->buffer;
    +      else
    +        target.origin = bitmap->buffer
    +                        + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch;
    +
    +      target.pitch = bitmap->pitch;
    +
    +      target.wght[0] = render->root.library->lcd_weights[0];
    +      target.wght[1] = render->root.library->lcd_weights[1];
    +      target.wght[2] = render->root.library->lcd_weights[2];
    +      target.wght[3] = render->root.library->lcd_weights[3];
    +      target.wght[4] = render->root.library->lcd_weights[4];
    +    }
    +    else
    +    {
    +      params.target = bitmap;
    +      params.source = outline;
    +      params.flags  = FT_RASTER_FLAG_AA;
    +    }
     
         /* implode outline */
         for ( vec = points; vec < points_end; vec++ )
    @@ -306,6 +369,32 @@
       }
     
     
    +  /* This function applies a vertical filter in direct rendering mode */
    +  static void
    +  ft_smooth_lcdv_spans( int             y,
    +                        int             count,
    +                        const FT_Span*  spans,
    +                        void*           target_ )   /* TOrigin* */
    +  {
    +    TOrigin*  target = (TOrigin*)target_;
    +
    +    int             pitch    = target->pitch;
    +    unsigned char*  dst_line = target->origin - ( y + 2 ) * pitch;
    +    unsigned char*  dst;
    +    unsigned short  w;
    +
    +
    +    for ( ; count--; spans++ )
    +      for ( dst = dst_line + spans->x, w = spans->len; w--; dst++ )
    +      {
    +        dst[        0] += ( spans->coverage * target->wght[0] + 85 ) >> 8;
    +        dst[    pitch] += ( spans->coverage * target->wght[1] + 85 ) >> 8;
    +        dst[2 * pitch] += ( spans->coverage * target->wght[2] + 85 ) >> 8;
    +        dst[3 * pitch] += ( spans->coverage * target->wght[3] + 85 ) >> 8;
    +        dst[4 * pitch] += ( spans->coverage * target->wght[4] + 85 ) >> 8;
    +      }
    +  }
    +
       static FT_Error
       ft_smooth_raster_lcdv( FT_Renderer  render,
                              FT_Outline*  outline,
    @@ -317,11 +406,42 @@
         FT_Vector*  vec;
     
         FT_Raster_Params  params;
    +    TOrigin           target;
     
     
    -    params.target = bitmap;
    -    params.source = outline;
    -    params.flags  = FT_RASTER_FLAG_AA;
    +    if ( render->root.library->lcd_weights[2] )
    +    {
    +      /* Set up direct rendering for instant filtering. */
    +      params.source     = outline;
    +      params.flags      = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
    +      params.gray_spans = ft_smooth_lcdv_spans;
    +      params.user       = ⌖
    +
    +      params.clip_box.xMin = 0;
    +      params.clip_box.yMin = 0;
    +      params.clip_box.xMax = bitmap->width;
    +      params.clip_box.yMax = bitmap->rows;
    +
    +      if ( bitmap->pitch < 0 )
    +        target.origin = bitmap->buffer;
    +      else
    +        target.origin = bitmap->buffer
    +                        + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch;
    +
    +      target.pitch = bitmap->pitch;
    +
    +      target.wght[0] = render->root.library->lcd_weights[0];
    +      target.wght[1] = render->root.library->lcd_weights[1];
    +      target.wght[2] = render->root.library->lcd_weights[2];
    +      target.wght[3] = render->root.library->lcd_weights[3];
    +      target.wght[4] = render->root.library->lcd_weights[4];
    +    }
    +    else
    +    {
    +      params.target = bitmap;
    +      params.source = outline;
    +      params.flags  = FT_RASTER_FLAG_AA;
    +    }
     
         /* implode outline */
         for ( vec = points; vec < points_end; vec++ )
    @@ -494,12 +614,6 @@
         else
           y_shift += 64 * (FT_Int)bitmap->rows;
     
    -    if ( origin )
    -    {
    -      x_shift += origin->x;
    -      y_shift += origin->y;
    -    }
    -
         /* translate outline to render it into the bitmap */
         if ( x_shift || y_shift )
           FT_Outline_Translate( outline, x_shift, y_shift );
    @@ -527,33 +641,6 @@
             error = ft_smooth_raster_lcd ( render, outline, bitmap );
           else if ( mode == FT_RENDER_MODE_LCD_V )
             error = ft_smooth_raster_lcdv( render, outline, bitmap );
    -
    -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    -
    -      /* finally apply filtering */
    -      {
    -        FT_Byte*                 lcd_weights;
    -        FT_Bitmap_LcdFilterFunc  lcd_filter_func;
    -
    -
    -        /* Per-face LCD filtering takes priority if set up. */
    -        if ( slot->face && slot->face->internal->lcd_filter_func )
    -        {
    -          lcd_weights     = slot->face->internal->lcd_weights;
    -          lcd_filter_func = slot->face->internal->lcd_filter_func;
    -        }
    -        else
    -        {
    -          lcd_weights     = slot->library->lcd_weights;
    -          lcd_filter_func = slot->library->lcd_filter_func;
    -        }
    -
    -        if ( lcd_filter_func )
    -          lcd_filter_func( bitmap, lcd_weights );
    -      }
    -
    -#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
    -
         }
     
       Exit:
    diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
    index d7b61a9e60e..f76708ae701 100644
    --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
    +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h
    @@ -4,7 +4,7 @@
      *
      *   Anti-aliasing renderer interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
    index 4ab68eb9a12..6369d83d6d5 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType font driver implementation (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -220,12 +220,12 @@
         {
           /* Use 'kern' table if available since that can be faster; otherwise */
           /* use GPOS kerning pairs if available.                              */
    -      if ( ttface->kern_avail_bits != 0 )
    +      if ( ttface->kern_avail_bits )
             kerning->x = sfnt->get_kerning( ttface,
                                             left_glyph,
                                             right_glyph );
     #ifdef TT_CONFIG_OPTION_GPOS_KERNING
    -      else if ( ttface->gpos_kerning_available )
    +      else if ( ttface->num_gpos_lookups_kerning )
             kerning->x = sfnt->get_gpos_kerning( ttface,
                                                  left_glyph,
                                                  right_glyph );
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
    index 3e1cf234fcf..943eaae3482 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h
    @@ -4,7 +4,7 @@
      *
      *   High-level TrueType driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h b/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
    index 7ad937bd04d..631dbf5a80f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
    index b656ccf04e3..4dd68ab1019 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType Glyph Loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -660,7 +660,7 @@
         } while ( subglyph->flags & MORE_COMPONENTS );
     
         gloader->current.num_subglyphs = num_subglyphs;
    -    FT_TRACE5(( "  %d component%s\n",
    +    FT_TRACE5(( "  %u component%s\n",
                     num_subglyphs,
                     num_subglyphs > 1 ? "s" : "" ));
     
    @@ -674,7 +674,7 @@
           for ( i = 0; i < num_subglyphs; i++ )
           {
             if ( num_subglyphs > 1 )
    -          FT_TRACE7(( "    subglyph %d:\n", i ));
    +          FT_TRACE7(( "    subglyph %u:\n", i ));
     
             FT_TRACE7(( "      glyph index: %d\n", subglyph->index ));
     
    @@ -777,15 +777,11 @@
       TT_Hint_Glyph( TT_Loader  loader,
                      FT_Bool    is_composite )
       {
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    TT_Face    face   = loader->face;
    -    TT_Driver  driver = (TT_Driver)FT_FACE_DRIVER( face );
    -#endif
    -
         TT_GlyphZone  zone = &loader->zone;
     
     #ifdef TT_USE_BYTECODE_INTERPRETER
         TT_ExecContext  exec  = loader->exec;
    +    TT_Size         size  = loader->size;
         FT_Long         n_ins = exec->glyphSize;
     #else
         FT_UNUSED( is_composite );
    @@ -797,9 +793,6 @@
         if ( n_ins > 0 )
           FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
     
    -    /* Reset graphics state. */
    -    exec->GS = loader->size->GS;
    -
         /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
         /*      completely refer to the (already) hinted subglyphs.     */
         if ( is_composite )
    @@ -811,8 +804,8 @@
         }
         else
         {
    -      exec->metrics.x_scale = loader->size->metrics->x_scale;
    -      exec->metrics.y_scale = loader->size->metrics->y_scale;
    +      exec->metrics.x_scale = size->metrics->x_scale;
    +      exec->metrics.y_scale = size->metrics->y_scale;
         }
     #endif
     
    @@ -838,7 +831,7 @@
           exec->is_composite = is_composite;
           exec->pts          = *zone;
     
    -      error = TT_Run_Context( exec );
    +      error = TT_Run_Context( exec, size );
           if ( error && exec->pedantic_hinting )
             return error;
     
    @@ -854,8 +847,7 @@
         /* to change bearings or advance widths.                               */
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
    -         exec->backward_compatibility )
    +    if ( exec->backward_compatibility )
           return FT_Err_Ok;
     #endif
     
    @@ -1152,30 +1144,15 @@
             x = FT_MulFix( x, x_scale );
             y = FT_MulFix( y, y_scale );
     
    -        if ( subglyph->flags & ROUND_XY_TO_GRID )
    +        if ( subglyph->flags & ROUND_XY_TO_GRID &&
    +             IS_HINTED( loader->load_flags )    )
             {
    -          TT_Face    face   = loader->face;
    -          TT_Driver  driver = (TT_Driver)FT_FACE_DRIVER( face );
    +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    +          if ( !loader->exec->backward_compatibility )
    +#endif
    +            x = FT_PIX_ROUND( x );
     
    -
    -          if ( IS_HINTED( loader->load_flags ) )
    -          {
    -            /*
    -             * We round the horizontal offset only if there is hinting along
    -             * the x axis; this corresponds to integer advance width values.
    -             *
    -             * Theoretically, a glyph's bytecode can toggle ClearType's
    -             * `backward compatibility' mode, which would allow modification
    -             * of the advance width.  In reality, however, applications
    -             * neither allow nor expect modified advance widths if subpixel
    -             * rendering is active.
    -             *
    -             */
    -            if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 )
    -              x = FT_PIX_ROUND( x );
    -
    -            y = FT_PIX_ROUND( y );
    -          }
    +          y = FT_PIX_ROUND( y );
             }
           }
         }
    @@ -1204,8 +1181,6 @@
       {
         FT_Error     error;
         FT_Outline*  outline = &loader->gloader->base.outline;
    -    FT_Stream    stream = loader->stream;
    -    FT_UShort    n_ins;
         FT_UInt      i;
     
     
    @@ -1224,8 +1199,10 @@
     #ifdef TT_USE_BYTECODE_INTERPRETER
     
         {
    -      TT_ExecContext  exec = loader->exec;
    +      TT_ExecContext  exec   = loader->exec;
           FT_Memory       memory = exec->memory;
    +      FT_Stream       stream = loader->stream;
    +      FT_UShort       n_ins;
     
     
           if ( exec->glyphSize )
    @@ -1378,8 +1355,9 @@
     
           if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
                loader->exec                                             &&
    -           loader->exec->subpixel_hinting_lean                      &&
    -           loader->exec->grayscale_cleartype                        )
    +           loader->exec->mode != FT_RENDER_MODE_MONO                &&
    +           loader->exec->mode != FT_RENDER_MODE_LCD                 &&
    +           loader->exec->mode != FT_RENDER_MODE_LCD_V               )
           {
             loader->pp3.x = loader->advance / 2;
             loader->pp4.x = loader->advance / 2;
    @@ -1444,13 +1422,13 @@
     
     #ifdef FT_DEBUG_LEVEL_TRACE
         if ( recurse_count )
    -      FT_TRACE5(( "  nesting level: %d\n", recurse_count ));
    +      FT_TRACE5(( "  nesting level: %u\n", recurse_count ));
     #endif
     
         /* some fonts have an incorrect value of `maxComponentDepth' */
         if ( recurse_count > face->max_profile.maxComponentDepth )
         {
    -      FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %d\n",
    +      FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %u\n",
                       recurse_count ));
           face->max_profile.maxComponentDepth = (FT_UShort)recurse_count;
         }
    @@ -1566,18 +1544,18 @@
         if ( header_only )
           goto Exit;
     
    +#ifdef FT_CONFIG_OPTION_INCREMENTAL
    +    tt_get_metrics_incremental( loader, glyph_index );
    +#endif
    +    tt_loader_set_pp( loader );
    +
    +    /* shortcut for empty glyphs */
         if ( loader->byte_len == 0 || loader->n_contours == 0 )
         {
    -#ifdef FT_CONFIG_OPTION_INCREMENTAL
    -      tt_get_metrics_incremental( loader, glyph_index );
    -#endif
    -      tt_loader_set_pp( loader );
    -
     
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
     
    -      if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
    -           FT_IS_VARIATION( FT_FACE( face ) )      )
    +      if ( !IS_DEFAULT_INSTANCE( FT_FACE( face ) ) )
           {
             /* a small outline structure with four elements for */
             /* communication with `TT_Vary_Apply_Glyph_Deltas'  */
    @@ -1627,11 +1605,6 @@
           goto Exit;
         }
     
    -#ifdef FT_CONFIG_OPTION_INCREMENTAL
    -    tt_get_metrics_incremental( loader, glyph_index );
    -#endif
    -    tt_loader_set_pp( loader );
    -
     
         /***********************************************************************/
         /***********************************************************************/
    @@ -1735,8 +1708,7 @@
     
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
     
    -      if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
    -           FT_IS_VARIATION( FT_FACE( face ) )      )
    +      if ( !IS_DEFAULT_INSTANCE( FT_FACE( face ) ) )
           {
             FT_UShort    i, limit;
             FT_SubGlyph  subglyph;
    @@ -1953,6 +1925,9 @@
     
     #ifdef FT_CONFIG_OPTION_INCREMENTAL
     
    +    /* restore the original stream */
    +    loader->stream = face->root.stream;
    +
         if ( glyph_data_loaded )
           face->root.internal->incremental_interface->funcs->free_glyph_data(
             face->root.internal->incremental_interface->object,
    @@ -2112,7 +2087,6 @@
       {
         TT_Face             face   = (TT_Face)glyph->face;
         SFNT_Service        sfnt   = (SFNT_Service)face->sfnt;
    -    FT_Stream           stream = face->root.stream;
         FT_Error            error;
         TT_SBit_MetricsRec  sbit_metrics;
     
    @@ -2121,14 +2095,11 @@
                                        size->strike_index,
                                        glyph_index,
                                        (FT_UInt)load_flags,
    -                                   stream,
    +                                   face->root.stream,
                                        &glyph->bitmap,
                                        &sbit_metrics );
         if ( !error )
         {
    -      glyph->outline.n_points   = 0;
    -      glyph->outline.n_contours = 0;
    -
           glyph->metrics.width  = (FT_Pos)sbit_metrics.width  * 64;
           glyph->metrics.height = (FT_Pos)sbit_metrics.height * 64;
     
    @@ -2153,6 +2124,50 @@
             glyph->bitmap_top  = sbit_metrics.horiBearingY;
           }
         }
    +    /* a missing glyph in a bitmap-only font is assumed whitespace */
    +    /* that needs to be constructed using metrics data from `hmtx' */
    +    /* and, optionally, `vmtx' tables                              */
    +    else if ( FT_ERR_EQ( error, Missing_Bitmap ) &&
    +              !FT_IS_SCALABLE( glyph->face )     &&
    +              face->horz_metrics_size            )
    +    {
    +      FT_Fixed  x_scale = size->root.metrics.x_scale;
    +      FT_Fixed  y_scale = size->root.metrics.y_scale;
    +
    +      FT_Short  left_bearing = 0;
    +      FT_Short  top_bearing  = 0;
    +
    +      FT_UShort  advance_width  = 0;
    +      FT_UShort  advance_height = 0;
    +
    +
    +      TT_Get_HMetrics( face, glyph_index,
    +                       &left_bearing,
    +                       &advance_width );
    +      TT_Get_VMetrics( face, glyph_index,
    +                       0,
    +                       &top_bearing,
    +                       &advance_height );
    +
    +      glyph->metrics.width  = 0;
    +      glyph->metrics.height = 0;
    +
    +      glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
    +      glyph->metrics.horiBearingY = 0;
    +      glyph->metrics.horiAdvance  = FT_MulFix( advance_width, x_scale );
    +
    +      glyph->metrics.vertBearingX = 0;
    +      glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
    +      glyph->metrics.vertAdvance  = FT_MulFix( advance_height, y_scale );
    +
    +      glyph->format            = FT_GLYPH_FORMAT_BITMAP;
    +      glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
    +
    +      glyph->bitmap_left = 0;
    +      glyph->bitmap_top  = 0;
    +
    +      error = FT_Err_Ok;
    +    }
     
         return error;
       }
    @@ -2168,15 +2183,6 @@
                       FT_Bool       glyf_table_only )
       {
         TT_Face    face   = (TT_Face)glyph->face;
    -    FT_Stream  stream = face->root.stream;
    -
    -#ifdef TT_USE_BYTECODE_INTERPRETER
    -    FT_Error   error;
    -    FT_Bool    pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    TT_Driver  driver   = (TT_Driver)FT_FACE_DRIVER( glyph->face );
    -#endif
    -#endif
     
     
         FT_ZERO( loader );
    @@ -2186,122 +2192,80 @@
         /* load execution context */
         if ( IS_HINTED( load_flags ) && !glyf_table_only )
         {
    +      FT_Error        error;
           TT_ExecContext  exec;
    -      FT_Bool         grayscale = TRUE;
    +      FT_Render_Mode  mode      = FT_LOAD_TARGET_MODE( load_flags );
    +      FT_Bool         grayscale = FT_BOOL( mode != FT_RENDER_MODE_MONO );
    +      FT_Bool         reexecute = FALSE;
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -      FT_Bool         subpixel_hinting_lean;
    -      FT_Bool         grayscale_cleartype;
    +      TT_Driver       driver    = (TT_Driver)FT_FACE_DRIVER( glyph->face );
     #endif
     
    -      FT_Bool  reexecute = FALSE;
     
    -
    -      if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
    +      if ( size->bytecode_ready > 0 )
    +        return size->bytecode_ready;
    +      if ( size->bytecode_ready < 0 )
           {
    -        error = tt_size_ready_bytecode( size, pedantic );
    +        FT_Bool  pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
    +
    +
    +        error = tt_size_init_bytecode( size, pedantic );
             if ( error )
               return error;
           }
    -      else if ( size->bytecode_ready )
    -        return size->bytecode_ready;
    -      else if ( size->cvt_ready )
    -        return size->cvt_ready;
     
    -      /* query new execution context */
           exec = size->context;
    -      if ( !exec )
    -        return FT_THROW( Could_Not_Find_Context );
    -
    -      grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
    -                             FT_RENDER_MODE_MONO             );
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    +      /* reset backward compatibility; note that */
    +      /* the CVT program always runs without it  */
    +      exec->backward_compatibility = 0;
    +
           if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
           {
    -        subpixel_hinting_lean =
    -          FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
    -                   FT_RENDER_MODE_MONO               );
    -        grayscale_cleartype =
    -          FT_BOOL( subpixel_hinting_lean         &&
    -                   !( ( load_flags         &
    -                        FT_LOAD_TARGET_LCD )   ||
    -                      ( load_flags           &
    -                        FT_LOAD_TARGET_LCD_V ) ) );
    -        exec->vertical_lcd_lean =
    -          FT_BOOL( subpixel_hinting_lean    &&
    -                   ( load_flags           &
    -                     FT_LOAD_TARGET_LCD_V ) );
    -        grayscale = FT_BOOL( grayscale && !subpixel_hinting_lean );
    -      }
    -      else
    -      {
    -        subpixel_hinting_lean   = FALSE;
    -        grayscale_cleartype     = FALSE;
    -        exec->vertical_lcd_lean = FALSE;
    -      }
    -#endif
    +        grayscale = FALSE;
     
    -      error = TT_Load_Context( exec, face, size );
    -      if ( error )
    -        return error;
    -
    -      {
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -        if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
    +        /* any mode change requires a re-execution of the CVT program */
    +        if ( mode != exec->mode )
             {
    -          /* a change from mono to subpixel rendering (and vice versa) */
    -          /* requires a re-execution of the CVT program                */
    -          if ( subpixel_hinting_lean != exec->subpixel_hinting_lean )
    -          {
    -            FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
    -                        " re-executing `prep' table\n" ));
    -
    -            exec->subpixel_hinting_lean = subpixel_hinting_lean;
    -            reexecute                   = TRUE;
    -          }
    -
    -          /* a change from colored to grayscale subpixel rendering (and */
    -          /* vice versa) requires a re-execution of the CVT program     */
    -          if ( grayscale_cleartype != exec->grayscale_cleartype )
    -          {
    -            FT_TRACE4(( "tt_loader_init: grayscale subpixel hinting change,"
    -                        " re-executing `prep' table\n" ));
    -
    -            exec->grayscale_cleartype = grayscale_cleartype;
    -            reexecute                 = TRUE;
    -          }
    -        }
    -#endif
    -
    -        /* a change from mono to grayscale rendering (and vice versa) */
    -        /* requires a re-execution of the CVT program                 */
    -        if ( grayscale != exec->grayscale )
    -        {
    -          FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
    +          FT_TRACE4(( "tt_loader_init: render mode change,"
                           " re-executing `prep' table\n" ));
     
    -          exec->grayscale = grayscale;
    -          reexecute       = TRUE;
    +          exec->mode = mode;
    +          reexecute  = TRUE;
             }
           }
    +#endif
     
    -      if ( reexecute )
    +      /* a change from mono to grayscale rendering (and vice versa) */
    +      /* requires a re-execution of the CVT program                 */
    +      if ( grayscale != exec->grayscale )
           {
    -        error = tt_size_run_prep( size, pedantic );
    -        if ( error )
    -          return error;
    -        error = TT_Load_Context( exec, face, size );
    +        FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
    +                    " re-executing `prep' table\n" ));
    +
    +        exec->grayscale = grayscale;
    +        reexecute       = TRUE;
    +      }
    +
    +      if ( size->cvt_ready > 0 )
    +        return size->cvt_ready;
    +      if ( size->cvt_ready < 0 || reexecute )
    +      {
    +        error = tt_size_run_prep( size );
             if ( error )
               return error;
           }
     
    +      TT_Load_Context( exec, face, size );
    +
           /* check whether the cvt program has disabled hinting */
    -      if ( exec->GS.instruct_control & 1 )
    +      if ( size->GS.instruct_control & 1 )
             load_flags |= FT_LOAD_NO_HINTING;
     
    -      /* load default graphics state -- if needed */
    -      if ( exec->GS.instruct_control & 2 )
    -        exec->GS = tt_default_graphics_state;
    +      /* check whether GS modifications should be reverted */
    +      if ( size->GS.instruct_control & 2 )
    +        size->GS = tt_default_graphics_state;
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
           /*
    @@ -2318,28 +2282,24 @@
            *
            */
           if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
    -           subpixel_hinting_lean                                    &&
    +           mode != FT_RENDER_MODE_MONO                              &&
                !FT_IS_TRICKY( glyph->face )                             )
    -        exec->backward_compatibility = !( exec->GS.instruct_control & 4 );
    -      else
    -        exec->backward_compatibility = FALSE;
    +        exec->backward_compatibility = ( size->GS.instruct_control & 4 ) ^ 4;
    +
     #endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
     
    -      exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
           loader->exec = exec;
    -      loader->instructions = exec->glyphIns;
     
           /* Use the hdmx table if any unless FT_LOAD_COMPUTE_METRICS */
           /* is set or backward compatibility mode of the v38 or v40  */
           /* interpreters is active.  See `ttinterp.h' for details on */
           /* backward compatibility mode.                             */
    -      if ( IS_HINTED( loader->load_flags )                                &&
    -           !( loader->load_flags & FT_LOAD_COMPUTE_METRICS )              &&
    +      if ( IS_HINTED( load_flags )                   &&
    +           !( load_flags & FT_LOAD_COMPUTE_METRICS ) &&
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -           !( driver->interpreter_version == TT_INTERPRETER_VERSION_40  &&
    -              exec->backward_compatibility                              ) &&
    +           !exec->backward_compatibility             &&
     #endif
    -           !face->postscript.isFixedPitch                                 )
    +           !face->postscript.isFixedPitch            )
           {
             loader->widthp = size->widthp;
           }
    @@ -2364,7 +2324,7 @@
         loader->face   = face;
         loader->size   = size;
         loader->glyph  = (FT_GlyphSlot)glyph;
    -    loader->stream = stream;
    +    loader->stream = face->root.stream;
     
         loader->composites.head = NULL;
         loader->composites.tail = NULL;
    @@ -2426,84 +2386,26 @@
         TT_LoaderRec  loader;
     
     
    -    FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
    +    FT_TRACE1(( "TT_Load_Glyph: glyph index %u\n", glyph_index ));
     
     #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
     
         /* try to load embedded bitmap (if any) */
    -    if ( size->strike_index != 0xFFFFFFFFUL      &&
    -         ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
    -         IS_DEFAULT_INSTANCE( glyph->face )      )
    +    if ( size->strike_index != 0xFFFFFFFFUL  &&
    +         !( load_flags & FT_LOAD_NO_BITMAP &&
    +            FT_IS_SCALABLE( glyph->face )  ) &&
    +         IS_DEFAULT_INSTANCE( glyph->face )  )
         {
    -      FT_Fixed  x_scale = size->root.metrics.x_scale;
    -      FT_Fixed  y_scale = size->root.metrics.y_scale;
    -
    -
           error = load_sbit_image( size, glyph, glyph_index, load_flags );
    -      if ( FT_ERR_EQ( error, Missing_Bitmap ) )
    -      {
    -        /* the bitmap strike is incomplete and misses the requested glyph; */
    -        /* if we have a bitmap-only font, return an empty glyph            */
    -        if ( !FT_IS_SCALABLE( glyph->face ) )
    -        {
    -          FT_Short  left_bearing = 0;
    -          FT_Short  top_bearing  = 0;
    -
    -          FT_UShort  advance_width  = 0;
    -          FT_UShort  advance_height = 0;
    -
    -
    -          /* to return an empty glyph, however, we need metrics data   */
    -          /* from the `hmtx' (or `vmtx') table; the assumption is that */
    -          /* empty glyphs are missing intentionally, representing      */
    -          /* whitespace - not having at least horizontal metrics is    */
    -          /* thus considered an error                                  */
    -          if ( !face->horz_metrics_size )
    -            return error;
    -
    -          /* we now construct an empty bitmap glyph */
    -          TT_Get_HMetrics( face, glyph_index,
    -                           &left_bearing,
    -                           &advance_width );
    -          TT_Get_VMetrics( face, glyph_index,
    -                           0,
    -                           &top_bearing,
    -                           &advance_height );
    -
    -          glyph->outline.n_points   = 0;
    -          glyph->outline.n_contours = 0;
    -
    -          glyph->metrics.width  = 0;
    -          glyph->metrics.height = 0;
    -
    -          glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
    -          glyph->metrics.horiBearingY = 0;
    -          glyph->metrics.horiAdvance  = FT_MulFix( advance_width, x_scale );
    -
    -          glyph->metrics.vertBearingX = 0;
    -          glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
    -          glyph->metrics.vertAdvance  = FT_MulFix( advance_height, y_scale );
    -
    -          glyph->format            = FT_GLYPH_FORMAT_BITMAP;
    -          glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
    -
    -          glyph->bitmap_left = 0;
    -          glyph->bitmap_top  = 0;
    -
    -          return FT_Err_Ok;
    -        }
    -      }
    -      else if ( error )
    -      {
    -        /* return error if font is not scalable */
    -        if ( !FT_IS_SCALABLE( glyph->face ) )
    -          return error;
    -      }
    -      else
    +      if ( !error )
           {
             if ( FT_IS_SCALABLE( glyph->face ) ||
                  FT_HAS_SBIX( glyph->face )    )
             {
    +          FT_Fixed  x_scale = size->root.metrics.x_scale;
    +          FT_Fixed  y_scale = size->root.metrics.y_scale;
    +
    +
               /* for the bbox we need the header only */
               (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
               (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
    @@ -2550,8 +2452,10 @@
                                                         y_scale );
             }
     
    -        return FT_Err_Ok;
    +        goto Exit;
           }
    +      else if ( !FT_IS_SCALABLE( glyph->face ) )
    +        goto Exit;
         }
     
         if ( load_flags & FT_LOAD_SBITS_ONLY )
    @@ -2563,7 +2467,7 @@
     #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
     
         /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
    -    if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
    +    if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.ppem )
         {
           error = FT_THROW( Invalid_Size_Handle );
           goto Exit;
    @@ -2614,7 +2518,7 @@
             glyph->metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
             glyph->metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
     
    -        return error;
    +        goto Exit;
           }
     
           FT_TRACE3(( "Failed to load SVG glyph\n" ));
    @@ -2642,10 +2546,6 @@
           goto Done;
         }
     
    -    glyph->format        = FT_GLYPH_FORMAT_OUTLINE;
    -    glyph->num_subglyphs = 0;
    -    glyph->outline.flags = 0;
    -
         /* main loading loop */
         error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
         if ( !error )
    @@ -2657,9 +2557,18 @@
           }
           else
           {
    +        glyph->format         = FT_GLYPH_FORMAT_OUTLINE;
    +
             glyph->outline        = loader.gloader->base.outline;
             glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
     
    +        /* Set the `high precision' bit flag.  This is _critical_ to   */
    +        /* get correct output for monochrome TrueType glyphs at all    */
    +        /* sizes using the bytecode interpreter.                       */
    +        if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
    +             size->metrics->y_ppem < 24         )
    +          glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    +
             /* Translate array so that (0,0) is the glyph's origin.  Note  */
             /* that this behaviour is independent on the value of bit 1 of */
             /* the `flags' field in the `head' table -- at least major     */
    @@ -2708,14 +2617,6 @@
           error = compute_glyph_metrics( &loader, glyph_index );
         }
     
    -    /* Set the `high precision' bit flag.                           */
    -    /* This is _critical_ to get correct output for monochrome      */
    -    /* TrueType glyphs at all sizes using the bytecode interpreter. */
    -    /*                                                              */
    -    if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
    -         size->metrics->y_ppem < 24         )
    -      glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    -
         FT_TRACE1(( "  subglyphs = %u, contours = %hu, points = %hu,"
                     " flags = 0x%.3x\n",
                     loader.gloader->base.num_subglyphs,
    @@ -2727,11 +2628,8 @@
         tt_loader_done( &loader );
     
       Exit:
    -#ifdef FT_DEBUG_LEVEL_TRACE
    -    if ( error )
    -      FT_TRACE1(( "  failed (error code 0x%x)\n",
    -                  error ));
    -#endif
    +    FT_TRACE1(( error ? "  failed (error code 0x%x)\n" : "",
    +                error ));
     
         return error;
       }
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
    index 22ea967f301..39d6ae3664c 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType Glyph Loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
    index 4f0083c96b7..f8842795f14 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType GX Font Variation loader
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -489,8 +489,9 @@
         FT_UShort  axis_count;
         FT_UInt    region_count;
     
    -    FT_UInt  i, j;
    -    FT_Bool  long_words;
    +    FT_UInt   i, j;
    +    FT_Byte*  bytes;
    +    FT_Bool   long_words;
     
         GX_Blend   blend           = ttface->blend;
         FT_ULong*  dataOffsetArray = NULL;
    @@ -526,11 +527,15 @@
         if ( FT_QNEW_ARRAY( dataOffsetArray, data_count ) )
           goto Exit;
     
    +    if ( FT_FRAME_ENTER( data_count * 4 ) )
    +      goto Exit;
    +
    +    bytes = stream->cursor;
    +
         for ( i = 0; i < data_count; i++ )
    -    {
    -      if ( FT_READ_ULONG( dataOffsetArray[i] ) )
    -        goto Exit;
    -    }
    +      dataOffsetArray[i] = FT_NEXT_ULONG( bytes );
    +
    +    FT_FRAME_EXIT();
     
         /* parse array of region records (region list) */
         if ( FT_STREAM_SEEK( offset + region_offset ) )
    @@ -564,13 +569,26 @@
           goto Exit;
         itemStore->regionCount = region_count;
     
    -    for ( i = 0; i < itemStore->regionCount; i++ )
    +    if ( FT_FRAME_ENTER( (FT_Long)region_count * axis_count * 6 ) )
    +    {
    +      FT_TRACE2(( "tt_var_load_item_variation_store:"
    +                  " not enough data for variation regions\n" ));
    +      error = FT_THROW( Invalid_Table );
    +      goto Exit;
    +    }
    +
    +    bytes = stream->cursor;
    +
    +    for ( i = 0; i < region_count; i++ )
         {
           GX_AxisCoords  axisCoords;
     
     
           if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList, axis_count ) )
    +      {
    +        FT_FRAME_EXIT();
             goto Exit;
    +      }
     
           axisCoords = itemStore->varRegionList[i].axisList;
     
    @@ -579,10 +597,9 @@
             FT_Int  start, peak, end;
     
     
    -        if ( FT_READ_SHORT( start ) ||
    -             FT_READ_SHORT( peak )  ||
    -             FT_READ_SHORT( end )   )
    -          goto Exit;
    +        start = FT_NEXT_SHORT( bytes );
    +        peak  = FT_NEXT_SHORT( bytes );
    +        end   = FT_NEXT_SHORT( bytes );
     
             /* immediately tag invalid ranges with special peak = 0 */
             if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
    @@ -594,6 +611,8 @@
           }
         }
     
    +    FT_FRAME_EXIT();
    +
         /* end of region list parse */
     
         /* use dataOffsetArray now to parse varData items */
    @@ -625,7 +644,7 @@
           /* check some data consistency */
           if ( word_delta_count > region_idx_count )
           {
    -        FT_TRACE2(( "bad short count %d or region count %d\n",
    +        FT_TRACE2(( "bad short count %d or region count %u\n",
                         word_delta_count,
                         region_idx_count ));
             error = FT_THROW( Invalid_Table );
    @@ -634,7 +653,7 @@
     
           if ( region_idx_count > itemStore->regionCount )
           {
    -        FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
    +        FT_TRACE2(( "inconsistent regionCount %u in varData[%u]\n",
                         region_idx_count,
                         i ));
             error = FT_THROW( Invalid_Table );
    @@ -648,29 +667,39 @@
           varData->wordDeltaCount = word_delta_count;
           varData->longWords      = long_words;
     
    +      if ( FT_FRAME_ENTER( region_idx_count * 2 ) )
    +      {
    +        FT_TRACE2(( "tt_var_load_item_variation_store:"
    +                    " not enough data for region indices\n" ));
    +        error = FT_THROW( Invalid_Table );
    +        goto Exit;
    +      }
    +
    +      bytes = stream->cursor;
    +
           for ( j = 0; j < varData->regionIdxCount; j++ )
           {
    -        if ( FT_READ_USHORT( varData->regionIndices[j] ) )
    -          goto Exit;
    +        varData->regionIndices[j] = FT_NEXT_USHORT( bytes );
     
             if ( varData->regionIndices[j] >= itemStore->regionCount )
             {
    -          FT_TRACE2(( "bad region index %d\n",
    +          FT_TRACE2(( "bad region index %u\n",
                           varData->regionIndices[j] ));
    +          FT_FRAME_EXIT();
               error = FT_THROW( Invalid_Table );
               goto Exit;
             }
           }
     
    +      FT_FRAME_EXIT();
    +
           per_region_size = word_delta_count + region_idx_count;
           if ( long_words )
             per_region_size *= 2;
     
    -      if ( FT_NEW_ARRAY( varData->deltaSet, per_region_size * item_count ) )
    +      if ( FT_QALLOC_MULT( varData->deltaSet, item_count, per_region_size ) )
             goto Exit;
    -      if ( FT_Stream_Read( stream,
    -                           varData->deltaSet,
    -                           per_region_size * item_count ) )
    +      if ( FT_STREAM_READ( varData->deltaSet, item_count * per_region_size ) )
           {
             FT_TRACE2(( "deltaSet read failed." ));
             error = FT_THROW( Invalid_Table );
    @@ -706,6 +735,7 @@
         FT_UInt   innerIndexMask;
         FT_ULong  i;
         FT_UInt   j;
    +    FT_Byte*  bytes;
     
     
         if ( FT_STREAM_SEEK( offset )    ||
    @@ -757,6 +787,16 @@
         if ( FT_NEW_ARRAY( map->outerIndex, map->mapCount ) )
           goto Exit;
     
    +    if ( FT_FRAME_ENTER( map->mapCount * entrySize ) )
    +    {
    +      FT_TRACE2(( "tt_var_load_delta_set_index_mapping:"
    +                  " invalid number of delta-set index mappings\n" ));
    +      error = FT_THROW( Invalid_Table );
    +      goto Exit;
    +    }
    +
    +    bytes = stream->cursor;
    +
         for ( i = 0; i < map->mapCount; i++ )
         {
           FT_UInt  mapData = 0;
    @@ -769,9 +809,7 @@
             FT_Byte  data;
     
     
    -        if ( FT_READ_BYTE( data ) )
    -          goto Exit;
    -
    +        data    = FT_NEXT_BYTE( bytes );
             mapData = ( mapData << 8 ) | data;
           }
     
    @@ -789,7 +827,7 @@
     
           if ( outerIndex >= itemStore->dataCount )
           {
    -        FT_TRACE2(( "outerIndex[%ld] == %d out of range\n",
    +        FT_TRACE2(( "outerIndex[%lu] == %u out of range\n",
                         i,
                         outerIndex ));
             error = FT_THROW( Invalid_Table );
    @@ -802,7 +840,7 @@
     
           if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
           {
    -        FT_TRACE2(( "innerIndex[%ld] == %d out of range\n",
    +        FT_TRACE2(( "innerIndex[%lu] == %u out of range\n",
                         i,
                         innerIndex ));
             error = FT_THROW( Invalid_Table );
    @@ -812,6 +850,8 @@
           map->innerIndex[i] = innerIndex;
         }
     
    +    FT_FRAME_EXIT();
    +
       Exit:
         return error;
       }
    @@ -965,28 +1005,181 @@
       }
     
     
    +  static FT_Fixed
    +  tt_calculate_scalar( GX_AxisCoords  axis,
    +                       FT_UInt        axisCount,
    +                       FT_Fixed*      normalizedcoords )
    +  {
    +    FT_Fixed  scalar = 0x10000L;
    +    FT_UInt   j;
    +
    +
    +    /* Inner loop steps through axes in this region. */
    +    for ( j = 0; j < axisCount; j++, axis++ )
    +    {
    +      FT_Fixed  ncv = normalizedcoords[j];
    +
    +
    +      /* Compute the scalar contribution of this axis, */
    +      /* with peak of 0 used for invalid axes.         */
    +      if ( axis->peakCoord == ncv ||
    +           axis->peakCoord == 0   )
    +        continue;
    +
    +      /* Ignore this region if coordinates are out of range. */
    +      else if ( ncv <= axis->startCoord ||
    +                ncv >= axis->endCoord   )
    +      {
    +        scalar = 0;
    +        break;
    +      }
    +
    +      /* Cumulative product of all the axis scalars. */
    +      else if ( ncv < axis->peakCoord )
    +        scalar = FT_MulDiv( scalar,
    +                            ncv - axis->startCoord,
    +                            axis->peakCoord - axis->startCoord );
    +      else   /* ncv > axis->peakCoord */
    +        scalar = FT_MulDiv( scalar,
    +                            axis->endCoord - ncv,
    +                            axis->endCoord - axis->peakCoord );
    +
    +    } /* per-axis loop */
    +
    +    return scalar;
    +  }
    +
    +
    +  static FT_Int64
    +  ft_mul_add_delta_scalar( FT_Int64  returnValue,
    +                           FT_Int32  delta,
    +                           FT_Int32  scalar )
    +  {
    +
    +#ifdef FT_INT64
    +
    +    return returnValue + (FT_Int64)delta * scalar;
    +
    +#else /* !FT_INT64 */
    +
    +    if ( (FT_UInt32)( delta + 0x8000 ) <= 0x20000 )
    +    {
    +      /* Fast path: multiplication result fits into 32 bits. */
    +
    +      FT_Int32  lo = delta * scalar;
    +
    +
    +      returnValue.lo += (FT_UInt32)lo;
    +
    +      if ( returnValue.lo < (FT_UInt32)lo )
    +        returnValue.hi += ( lo < 0 ) ? 0 : 1;
    +
    +      if ( lo < 0 )
    +        returnValue.hi -= 1;
    +
    +      return returnValue;
    +    }
    +    else
    +    {
    +      /* Slow path: full 32x32 -> 64-bit signed multiplication. */
    +
    +      FT_Int64 product;
    +
    +      /* Get absolute values. */
    +      FT_UInt32  a = ( delta < 0 ) ? -delta : delta;
    +      FT_UInt32  b = ( scalar < 0 ) ? -scalar : scalar;
    +
    +      /* Prepare unsigned multiplication. */
    +      FT_UInt32  a_lo = a & 0xFFFF;
    +      FT_UInt32  a_hi = a >> 16;
    +
    +      FT_UInt32  b_lo = b & 0xFFFF;
    +      FT_UInt32  b_hi = b >> 16;
    +
    +      /* Partial products. */
    +      FT_UInt32  p0 = a_lo * b_lo;
    +      FT_UInt32  p1 = a_lo * b_hi;
    +      FT_UInt32  p2 = a_hi * b_lo;
    +      FT_UInt32  p3 = a_hi * b_hi;
    +
    +      /* Combine: result = p3 << 32 + (p1 + p2) << 16 + p0 */
    +      FT_UInt32  mid       = p1 + p2;
    +      FT_UInt32  mid_carry = ( mid < p1 );
    +
    +      FT_UInt32  carry;
    +
    +
    +      product.lo = ( mid << 16 ) + ( p0 & 0xFFFF );
    +      carry      = ( product.lo < ( p0 & 0xFFFF ) ) ? 1 : 0;
    +      product.hi = p3 + ( mid >> 16 ) + mid_carry + carry;
    +
    +      /* If result should be negative, negate. */
    +      if ( ( delta < 0 ) ^ ( scalar < 0 ) )
    +      {
    +        product.lo = ~product.lo + 1;
    +        product.hi = ~product.hi + ( product.lo == 0 ? 1 : 0 );
    +      }
    +
    +      /* Add to `returnValue`. */
    +      returnValue.lo += product.lo;
    +      if ( returnValue.lo < product.lo )
    +        returnValue.hi++;
    +      returnValue.hi += product.hi;
    +
    +      return returnValue;
    +    }
    +
    +#endif /* !FT_INT64 */
    +
    +  }
    +
    +
    +  static FT_ItemVarDelta
    +  ft_round_and_shift16( FT_Int64  returnValue )
    +  {
    +
    +#ifdef FT_INT64
    +
    +    return (FT_ItemVarDelta)( returnValue + 0x8000L ) >> 16;
    +
    +#else /* !FT_INT64 */
    +
    +    FT_UInt hi = returnValue.hi;
    +    FT_UInt lo = returnValue.lo;
    +
    +    FT_UInt delta;
    +
    +
    +    /* Add 0x8000 to round. */
    +    lo += 0x8000;
    +    if ( lo < 0x8000 )  /* overflow occurred */
    +      hi += 1;
    +
    +    /* Shift right by 16 bits. */
    +    delta = ( hi << 16 ) | ( lo >> 16 );
    +
    +    return (FT_ItemVarDelta)delta;
    +
    +#endif /* !FT_INT64 */
    +
    +  }
    +
    +
       FT_LOCAL_DEF( FT_ItemVarDelta )
       tt_var_get_item_delta( FT_Face          face,        /* TT_Face */
                              GX_ItemVarStore  itemStore,
                              FT_UInt          outerIndex,
                              FT_UInt          innerIndex )
       {
    -    TT_Face    ttface = (TT_Face)face;
    -    FT_Stream  stream = FT_FACE_STREAM( face );
    -    FT_Memory  memory = stream->memory;
    -    FT_Error   error  = FT_Err_Ok;
    +    TT_Face  ttface = (TT_Face)face;
     
    -    GX_ItemVarData    varData;
    -    FT_ItemVarDelta*  deltaSet = NULL;
    -    FT_ItemVarDelta   deltaSetStack[16];
    +    GX_ItemVarData  varData;
     
    -    FT_Fixed*  scalars = NULL;
    -    FT_Fixed   scalarsStack[16];
    -
    -    FT_UInt          master, j;
    -    FT_ItemVarDelta  returnValue = 0;
    -    FT_UInt          per_region_size;
    -    FT_Byte*         bytes;
    +    FT_UInt   master;
    +    FT_Int64  returnValue = FT_INT64_ZERO;
    +    FT_UInt   shift_base  = 1;
    +    FT_UInt   per_region_size;
    +    FT_Byte*  bytes;
     
     
         if ( !ttface->blend || !ttface->blend->normalizedcoords )
    @@ -1011,113 +1204,63 @@
         if ( varData->regionIdxCount == 0 )
           return 0; /* Avoid "applying zero offset to null pointer". */
     
    -    if ( varData->regionIdxCount < 16 )
    -    {
    -      deltaSet = deltaSetStack;
    -      scalars  = scalarsStack;
    -    }
    -    else
    -    {
    -      if ( FT_QNEW_ARRAY( deltaSet, varData->regionIdxCount ) )
    -        goto Exit;
    -      if ( FT_QNEW_ARRAY( scalars, varData->regionIdxCount ) )
    -        goto Exit;
    -    }
    -
         /* Parse delta set.                                            */
         /*                                                             */
         /* Deltas are (word_delta_count + region_idx_count) bytes each */
         /* if `longWords` isn't set, and twice as much otherwise.      */
         per_region_size = varData->wordDeltaCount + varData->regionIdxCount;
         if ( varData->longWords )
    +    {
    +      shift_base       = 2;
           per_region_size *= 2;
    +    }
     
         bytes = varData->deltaSet + per_region_size * innerIndex;
     
    -    if ( varData->longWords )
    -    {
    -      for ( master = 0; master < varData->wordDeltaCount; master++ )
    -        deltaSet[master] = FT_NEXT_LONG( bytes );
    -      for ( ; master < varData->regionIdxCount; master++ )
    -        deltaSet[master] = FT_NEXT_SHORT( bytes );
    -    }
    -    else
    -    {
    -      for ( master = 0; master < varData->wordDeltaCount; master++ )
    -        deltaSet[master] = FT_NEXT_SHORT( bytes );
    -      for ( ; master < varData->regionIdxCount; master++ )
    -        deltaSet[master] = FT_NEXT_CHAR( bytes );
    -    }
    -
         /* outer loop steps through master designs to be blended */
         for ( master = 0; master < varData->regionIdxCount; master++ )
         {
    -      FT_Fixed  scalar      = 0x10000L;
    -      FT_UInt   regionIndex = varData->regionIndices[master];
    +      FT_UInt  regionIndex = varData->regionIndices[master];
     
           GX_AxisCoords  axis = itemStore->varRegionList[regionIndex].axisList;
     
    +      FT_Fixed  scalar = tt_calculate_scalar(
    +                           axis,
    +                           itemStore->axisCount,
    +                           ttface->blend->normalizedcoords );
     
    -      /* inner loop steps through axes in this region */
    -      for ( j = 0; j < itemStore->axisCount; j++, axis++ )
    +
    +      if ( scalar )
           {
    -        FT_Fixed  ncv = ttface->blend->normalizedcoords[j];
    +        FT_Int  delta;
     
     
    -        /* compute the scalar contribution of this axis */
    -        /* with peak of 0 used for invalid axes         */
    -        if ( axis->peakCoord == ncv ||
    -             axis->peakCoord == 0   )
    -          continue;
    -
    -        /* ignore this region if coords are out of range */
    -        else if ( ncv <= axis->startCoord ||
    -                  ncv >= axis->endCoord   )
    +        if ( varData->longWords )
             {
    -          scalar = 0;
    -          break;
    +          if ( master < varData->wordDeltaCount )
    +            delta = FT_NEXT_LONG( bytes );
    +          else
    +            delta = FT_NEXT_SHORT( bytes );
    +        }
    +        else
    +        {
    +          if ( master < varData->wordDeltaCount )
    +            delta = FT_NEXT_SHORT( bytes );
    +          else
    +            delta = FT_NEXT_CHAR( bytes );
             }
     
    -        /* cumulative product of all the axis scalars */
    -        else if ( ncv < axis->peakCoord )
    -          scalar = FT_MulDiv( scalar,
    -                              ncv - axis->startCoord,
    -                              axis->peakCoord - axis->startCoord );
    -        else   /* ncv > axis->peakCoord */
    -          scalar = FT_MulDiv( scalar,
    -                              axis->endCoord - ncv,
    -                              axis->endCoord - axis->peakCoord );
    -
    -      } /* per-axis loop */
    -
    -      scalars[master] = scalar;
    +        returnValue = ft_mul_add_delta_scalar( returnValue, delta, scalar );
    +      }
    +      else
    +      {
    +        /* Branch-free, yay. */
    +        bytes += shift_base << ( master < varData->wordDeltaCount );
    +      }
     
         } /* per-region loop */
     
    -
    -    /* Compute the scaled delta for this region.
    -     *
    -     * From: https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#item-variation-store-header-and-item-variation-data-subtables:
    -     *
    -     *   `Fixed` is a 32-bit (16.16) type and, in the general case, requires
    -     *   32-bit deltas.  As described above, the `DeltaSet` record can
    -     *   accommodate deltas that are, logically, either 16-bit or 32-bit.
    -     *   When scaled deltas are applied to `Fixed` values, the `Fixed` value
    -     *   is treated like a 32-bit integer.
    -     *
    -     * `FT_MulAddFix` internally uses 64-bit precision; it thus can handle
    -     * deltas ranging from small 8-bit to large 32-bit values that are
    -     * applied to 16.16 `FT_Fixed` / OpenType `Fixed` values.
    -     */
    -    returnValue = FT_MulAddFix( scalars, deltaSet, varData->regionIdxCount );
    -
    -  Exit:
    -    if ( scalars != scalarsStack )
    -      FT_FREE( scalars );
    -    if ( deltaSet != deltaSetStack )
    -      FT_FREE( deltaSet );
    -
    -    return returnValue;
    +    return ft_round_and_shift16( returnValue );
       }
     
     
    @@ -1643,6 +1786,7 @@
         GX_Blend      blend  = face->blend;
         FT_Error      error;
         FT_UInt       i, j;
    +    FT_Byte*      bytes;
         FT_ULong      table_len;
         FT_ULong      gvar_start;
         FT_ULong      offsetToData;
    @@ -1734,6 +1878,8 @@
         if ( FT_FRAME_ENTER( offsets_len ) )
           goto Exit;
     
    +    bytes = stream->cursor;
    +
         /* offsets (one more offset than glyphs, to mark size of last) */
         if ( FT_QNEW_ARRAY( blend->glyphoffsets, gvar_head.glyphCount + 1 ) )
           goto Fail2;
    @@ -1744,16 +1890,24 @@
           FT_ULong  max_offset = 0;
     
     
    +      if ( stream->limit - stream->cursor < gvar_head.glyphCount * 4 )
    +      {
    +        FT_TRACE2(( "ft_var_load_gvar:"
    +                    " glyph variation data offset not enough\n" ));
    +        error = FT_THROW( Invalid_Table );
    +        goto Fail;
    +      }
    +
           for ( i = 0; i <= gvar_head.glyphCount; i++ )
           {
    -        blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG();
    +        blend->glyphoffsets[i] = offsetToData + FT_NEXT_ULONG( bytes );
     
             if ( max_offset <= blend->glyphoffsets[i] )
               max_offset = blend->glyphoffsets[i];
             else
             {
               FT_TRACE2(( "ft_var_load_gvar:"
    -                      " glyph variation data offset %d not monotonic\n",
    +                      " glyph variation data offset %u not monotonic\n",
                           i ));
               blend->glyphoffsets[i] = max_offset;
             }
    @@ -1762,7 +1916,7 @@
             if ( limit < blend->glyphoffsets[i] )
             {
               FT_TRACE2(( "ft_var_load_gvar:"
    -                      " glyph variation data offset %d out of range\n",
    +                      " glyph variation data offset %u out of range\n",
                           i ));
               blend->glyphoffsets[i] = limit;
             }
    @@ -1774,16 +1928,24 @@
           FT_ULong  max_offset = 0;
     
     
    +      if ( stream->limit - stream->cursor < gvar_head.glyphCount * 2 )
    +      {
    +        FT_TRACE2(( "ft_var_load_gvar:"
    +                    " glyph variation data offset not enough\n" ));
    +        error = FT_THROW( Invalid_Table );
    +        goto Fail;
    +      }
    +
           for ( i = 0; i <= gvar_head.glyphCount; i++ )
           {
    -        blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2;
    +        blend->glyphoffsets[i] = offsetToData + FT_NEXT_USHORT( bytes ) * 2;
     
             if ( max_offset <= blend->glyphoffsets[i] )
               max_offset = blend->glyphoffsets[i];
             else
             {
               FT_TRACE2(( "ft_var_load_gvar:"
    -                      " glyph variation data offset %d not monotonic\n",
    +                      " glyph variation data offset %u not monotonic\n",
                           i ));
               blend->glyphoffsets[i] = max_offset;
             }
    @@ -1792,7 +1954,7 @@
             if ( limit < blend->glyphoffsets[i] )
             {
               FT_TRACE2(( "ft_var_load_gvar:"
    -                      " glyph variation data offset %d out of range\n",
    +                      " glyph variation data offset %u out of range\n",
                           i ));
               blend->glyphoffsets[i] = limit;
             }
    @@ -1814,6 +1976,8 @@
             goto Fail;
           }
     
    +      bytes = stream->cursor;
    +
           if ( FT_QNEW_ARRAY( blend->tuplecoords,
                               gvar_head.axisCount * gvar_head.globalCoordCount ) )
             goto Fail2;
    @@ -1824,13 +1988,17 @@
             for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ )
             {
               blend->tuplecoords[i * gvar_head.axisCount + j] =
    -            FT_fdot14ToFixed( FT_GET_SHORT() );
    +            FT_fdot14ToFixed( FT_NEXT_SHORT( bytes ) );
               FT_TRACE5(( "%.5f ",
                 (double)blend->tuplecoords[i * gvar_head.axisCount + j] / 65536 ));
             }
             FT_TRACE5(( "]\n" ));
           }
     
    +      if ( FT_NEW_ARRAY( blend->tuplescalars,
    +                         gvar_head.globalCoordCount ) )
    +        goto Fail2;
    +
           blend->tuplecount = gvar_head.globalCoordCount;
     
           FT_TRACE5(( "\n" ));
    @@ -1896,15 +2064,25 @@
     
         for ( i = 0; i < blend->num_axis; i++ )
         {
    -      FT_Fixed  ncv = blend->normalizedcoords[i];
    +      FT_Fixed  ncv;
     
     
    -      FT_TRACE6(( "    axis %d coordinate %.5f:\n", i, (double)ncv / 65536 ));
    +      if ( tuple_coords[i] == 0 )
    +      {
    +        FT_TRACE6(( "      tuple coordinate is zero, ignore\n" ));
    +        continue;
    +      }
     
    -      /* It's not clear why (for intermediate tuples) we don't need     */
    -      /* to check against start/end -- the documentation says we don't. */
    -      /* Similarly, it's unclear why we don't need to scale along the   */
    -      /* axis.                                                          */
    +      ncv = blend->normalizedcoords[i];
    +
    +      FT_TRACE6(( "    axis %u coordinate %.5f:\n", i, (double)ncv / 65536 ));
    +
    +      if ( ncv == 0 )
    +      {
    +        FT_TRACE6(( "      axis coordinate is zero, stop\n" ));
    +        apply = 0;
    +        break;
    +      }
     
           if ( tuple_coords[i] == ncv )
           {
    @@ -1914,12 +2092,6 @@
             continue;
           }
     
    -      if ( tuple_coords[i] == 0 )
    -      {
    -        FT_TRACE6(( "      tuple coordinate is zero, ignore\n" ));
    -        continue;
    -      }
    -
           if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
           {
             /* not an intermediate tuple */
    @@ -2001,7 +2173,7 @@
         if ( num_coords > mmvar->num_axis )
         {
           FT_TRACE2(( "ft_var_to_normalized:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       mmvar->num_axis, num_coords ));
           num_coords = mmvar->num_axis;
         }
    @@ -2016,7 +2188,7 @@
           FT_Fixed  coord = coords[i];
     
     
    -      FT_TRACE5(( "    %d: %.5f\n", i, (double)coord / 65536 ));
    +      FT_TRACE5(( "    %u: %.5f\n", i, (double)coord / 65536 ));
           if ( coord > a->maximum || coord < a->minimum )
           {
             FT_TRACE1(( "ft_var_to_normalized: design coordinate %.5f\n",
    @@ -2156,7 +2328,7 @@
         if ( num_coords > blend->num_axis )
         {
           FT_TRACE2(( "ft_var_to_design:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       blend->num_axis, num_coords ));
           nc = blend->num_axis;
         }
    @@ -2516,7 +2688,7 @@
                           "    minimum     default     maximum   flags\n" ));
                        /* "  XXXX.XXXXX  XXXX.XXXXX  XXXX.XXXXX  0xXXXX" */
     
    -        FT_TRACE5(( "  %3d  `%s'"
    +        FT_TRACE5(( "  %3u  `%s'"
                         "  %10.5f  %10.5f  %10.5f  0x%04X%s\n",
                         i,
                         a->name,
    @@ -2608,7 +2780,7 @@
     
               (void)FT_STREAM_SEEK( pos );
     
    -          FT_TRACE5(( "  named instance %d (%s%s%s, %s%s%s)\n",
    +          FT_TRACE5(( "  named instance %u (%s%s%s, %s%s%s)\n",
                           i,
                           strname ? "name: `" : "",
                           strname ? strname : "unnamed",
    @@ -2636,7 +2808,7 @@
             FT_UInt  strid = ~0U;
     
     
    -        /* The default instance is missing in array the    */
    +        /* The default instance is missing in the array    */
             /* of named instances; try to synthesize an entry. */
             /* If this fails, `default_named_instance` remains */
             /* at value zero, which doesn't do any harm.       */
    @@ -2766,10 +2938,18 @@
         } manageCvt;
     
     
    -    face->doblend = FALSE;
    -
         if ( !face->blend )
         {
    +      face->doblend = FALSE;
    +      for ( i = 0; i < num_coords; i++ )
    +        if ( coords[i] )
    +        {
    +          face->doblend = TRUE;
    +          break;
    +        }
    +      if ( !face->doblend )
    +        goto Exit;
    +
           if ( FT_SET_ERROR( TT_Get_MM_Var( FT_FACE( face ), NULL ) ) )
             goto Exit;
         }
    @@ -2780,7 +2960,7 @@
         if ( num_coords > mmvar->num_axis )
         {
           FT_TRACE2(( "TT_Set_MM_Blend:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       mmvar->num_axis, num_coords ));
           num_coords = mmvar->num_axis;
         }
    @@ -2882,11 +3062,7 @@
     
           /* return value -1 indicates `no change' */
           if ( !have_diff )
    -      {
    -        face->doblend = TRUE;
    -
             return -1;
    -      }
     
           for ( ; i < mmvar->num_axis; i++ )
           {
    @@ -2915,7 +3091,15 @@
                             blend->normalizedcoords,
                             blend->coords );
     
    -    face->doblend = TRUE;
    +    face->doblend = FALSE;
    +    for ( i = 0; i < blend->num_axis; i++ )
    +    {
    +      if ( blend->normalizedcoords[i] )
    +      {
    +        face->doblend = TRUE;
    +        break;
    +      }
    +    }
     
         if ( face->cvt )
         {
    @@ -2941,6 +3125,9 @@
           }
         }
     
    +    for ( i = 0 ; i < blend->tuplecount ; i++ )
    +      blend->tuplescalars[i] = (FT_Fixed)-0x20000L;
    +
       Exit:
         return error;
       }
    @@ -2980,7 +3167,24 @@
                        FT_UInt    num_coords,
                        FT_Fixed*  coords )
       {
    -    return tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
    +    FT_Error  error;
    +
    +
    +    error = tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
    +    if ( error == FT_Err_Ok )
    +    {
    +      FT_UInt  i;
    +
    +
    +      for ( i = 0; i < num_coords; i++ )
    +        if ( coords[i] )
    +        {
    +          error = -2; /* -2 means is_variable. */
    +          break;
    +        }
    +    }
    +
    +    return error;
       }
     
     
    @@ -3043,7 +3247,7 @@
         if ( num_coords > blend->num_axis )
         {
           FT_TRACE2(( "TT_Get_MM_Blend:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       blend->num_axis, num_coords ));
           nc = blend->num_axis;
         }
    @@ -3125,7 +3329,7 @@
         if ( num_coords > mmvar->num_axis )
         {
           FT_TRACE2(( "TT_Set_Var_Design:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       mmvar->num_axis, num_coords ));
           num_coords = mmvar->num_axis;
         }
    @@ -3201,6 +3405,15 @@
         if ( error )
           goto Exit;
     
    +    for ( i = 0; i < num_coords; i++ )
    +    {
    +      if ( normalized[i] )
    +      {
    +        error = -2; /* -2 means is_variable. */
    +        break;
    +      }
    +    }
    +
       Exit:
         FT_FREE( normalized );
         return error;
    @@ -3237,10 +3450,12 @@
                          FT_UInt    num_coords,
                          FT_Fixed*  coords )
       {
    -    TT_Face   ttface = (TT_Face)face;
    -    FT_Error  error  = FT_Err_Ok;
    -    GX_Blend  blend;
    -    FT_UInt   i, nc;
    +    TT_Face       ttface = (TT_Face)face;
    +    FT_Error      error  = FT_Err_Ok;
    +    GX_Blend      blend;
    +    FT_MM_Var*    mmvar;
    +    FT_Var_Axis*  a;
    +    FT_UInt       i, nc;
     
     
         if ( !ttface->blend )
    @@ -3263,24 +3478,26 @@
         if ( num_coords > blend->num_axis )
         {
           FT_TRACE2(( "TT_Get_Var_Design:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       blend->num_axis, num_coords ));
           nc = blend->num_axis;
         }
     
    +    mmvar = blend->mmvar;
    +    a     = mmvar->axis;
         if ( ttface->doblend )
         {
    -      for ( i = 0; i < nc; i++ )
    +      for ( i = 0; i < nc; i++, a++ )
             coords[i] = blend->coords[i];
         }
         else
         {
    -      for ( i = 0; i < nc; i++ )
    -        coords[i] = 0;
    +      for ( i = 0; i < nc; i++, a++ )
    +        coords[i] = a->def;
         }
     
    -    for ( ; i < num_coords; i++ )
    -      coords[i] = 0;
    +    for ( ; i < num_coords; i++, a++ )
    +      coords[i] = a->def;
     
         return FT_Err_Ok;
       }
    @@ -3373,6 +3590,9 @@
           error = TT_Set_Var_Design( face, 0, NULL );
         }
     
    +    if ( error == -1 || error == -2 )
    +      error = FT_Err_Ok;
    +
       Exit:
         return error;
       }
    @@ -3591,7 +3811,7 @@
           FT_Stream_SeekSet( stream, here );
         }
     
    -    FT_TRACE5(( "cvar: there %s %d tuple%s:\n",
    +    FT_TRACE5(( "cvar: there %s %u tuple%s:\n",
                     ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
                     tupleCount & GX_TC_TUPLE_COUNT_MASK,
                     ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
    @@ -3610,7 +3830,7 @@
           FT_Fixed  apply;
     
     
    -      FT_TRACE6(( "  tuple %d:\n", i ));
    +      FT_TRACE6(( "  tuple %u:\n", i ));
     
           tupleDataSize = FT_GET_USHORT();
           tupleIndex    = FT_GET_USHORT();
    @@ -3676,7 +3896,7 @@
           if ( !points || !deltas )
             ; /* failure, ignore it */
     
    -      else if ( localpoints == ALL_POINTS )
    +      else if ( points == ALL_POINTS )
           {
     #ifdef FT_DEBUG_LEVEL_TRACE
             int  count = 0;
    @@ -3697,7 +3917,7 @@
     #ifdef FT_DEBUG_LEVEL_TRACE
               if ( old_cvt_delta != cvt_deltas[j] )
               {
    -            FT_TRACE7(( "      %d: %f -> %f\n",
    +            FT_TRACE7(( "      %u: %f -> %f\n",
                             j,
                             (double)( FT_fdot6ToFixed( face->cvt[j] ) +
                                         old_cvt_delta ) / 65536,
    @@ -4027,7 +4247,7 @@
                                   FT_Outline*  outline,
                                   FT_Vector*   unrounded )
       {
    -    FT_Error   error;
    +    FT_Error   error       = FT_Err_Ok;
         TT_Face    face        = loader->face;
         FT_Stream  stream      = face->root.stream;
         FT_Memory  memory      = stream->memory;
    @@ -4047,6 +4267,15 @@
         FT_ULong  here;
         FT_UInt   i, j;
     
    +    FT_UInt   peak_coords_size;
    +    FT_UInt   point_deltas_x_size;
    +    FT_UInt   points_org_size;
    +    FT_UInt   points_out_size;
    +    FT_UInt   has_delta_size;
    +    FT_UInt   pool_size;
    +    FT_Byte*  pool = NULL;
    +    FT_Byte*  p;
    +
         FT_Fixed*  peak_coords = NULL;
         FT_Fixed*  tuple_coords;
         FT_Fixed*  im_start_coords;
    @@ -4067,21 +4296,24 @@
         FT_Fixed*  point_deltas_y = NULL;
     
     
    -    if ( !face->doblend || !blend )
    -      return FT_THROW( Invalid_Argument );
    -
         for ( i = 0; i < n_points; i++ )
         {
           unrounded[i].x = INT_TO_F26DOT6( outline->points[i].x );
           unrounded[i].y = INT_TO_F26DOT6( outline->points[i].y );
         }
     
    +    if ( !face->doblend  )
    +      goto Exit;
    +
    +    if ( !blend )
    +      return FT_THROW( Invalid_Argument );
    +
         if ( glyph_index >= blend->gv_glyphcnt      ||
              blend->glyphoffsets[glyph_index] ==
                blend->glyphoffsets[glyph_index + 1] )
         {
           FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
    -                  " no variation data for glyph %d\n", glyph_index ));
    +                  " no variation data for glyph %u\n", glyph_index ));
           return FT_Err_Ok;
         }
     
    @@ -4125,18 +4357,41 @@
           FT_Stream_SeekSet( stream, here );
         }
     
    -    FT_TRACE5(( "gvar: there %s %d tuple%s:\n",
    +    FT_TRACE5(( "gvar: there %s %u tuple%s:\n",
                     ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
                     tupleCount & GX_TC_TUPLE_COUNT_MASK,
                     ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
     
    -    if ( FT_QNEW_ARRAY( peak_coords, 3 * blend->num_axis ) ||
    -         FT_NEW_ARRAY( point_deltas_x, 2 * n_points )      ||
    -         FT_QNEW_ARRAY( points_org, n_points )             ||
    -         FT_QNEW_ARRAY( points_out, n_points )             ||
    -         FT_QNEW_ARRAY( has_delta, n_points )              )
    +    peak_coords_size    = ALIGN_SIZE( 3 * blend->num_axis *
    +                                      sizeof ( *peak_coords ) );
    +    point_deltas_x_size = ALIGN_SIZE( 2 * n_points *
    +                                      sizeof ( *point_deltas_x ) );
    +    points_org_size     = ALIGN_SIZE( n_points * sizeof ( *points_org ) );
    +    points_out_size     = ALIGN_SIZE( n_points * sizeof ( *points_out ) );
    +    has_delta_size      = ALIGN_SIZE( n_points * sizeof ( *has_delta ) );
    +
    +    pool_size = peak_coords_size    +
    +                point_deltas_x_size +
    +                points_org_size     +
    +                points_out_size     +
    +                has_delta_size;
    +
    +    if ( FT_ALLOC( pool, pool_size ) )
           goto Exit;
     
    +    p               = pool;
    +    peak_coords     = (FT_Fixed*)p;
    +    p              += peak_coords_size;
    +    point_deltas_x  = (FT_Fixed*)p;
    +    p              += point_deltas_x_size;
    +    points_org      = (FT_Vector*)p;
    +    p              += points_org_size;
    +    points_out      = (FT_Vector*)p;
    +    p              += points_out_size;
    +    has_delta       = (FT_Bool*)p;
    +
    +    FT_ARRAY_ZERO( point_deltas_x, 2 * n_points );
    +
         im_start_coords = peak_coords + blend->num_axis;
         im_end_coords   = im_start_coords + blend->num_axis;
         point_deltas_y  = point_deltas_x + n_points;
    @@ -4147,27 +4402,70 @@
           points_org[j].y = FT_intToFixed( outline->points[j].y );
         }
     
    -    for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
    +    p = stream->cursor;
    +
    +    tupleCount &= GX_TC_TUPLE_COUNT_MASK;
    +    for ( i = 0; i < tupleCount; i++ )
         {
    -      FT_UInt   tupleDataSize;
    -      FT_UInt   tupleIndex;
    -      FT_Fixed  apply;
    +      FT_UInt    tupleDataSize;
    +      FT_UInt    tupleIndex;
    +      FT_Fixed   apply;
    +      FT_Fixed*  tupleScalars;
     
     
    -      FT_TRACE6(( "  tuple %d:\n", i ));
    +      FT_TRACE6(( "  tuple %u:\n", i ));
     
    -      tupleDataSize = FT_GET_USHORT();
    -      tupleIndex    = FT_GET_USHORT();
    +      tupleScalars = blend->tuplescalars;
    +
    +      /* Enter frame for four bytes. */
    +      if ( 4 > stream->limit - p )
    +      {
    +        FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
    +                    " invalid glyph variation array header\n" ));
    +        error = FT_THROW( Invalid_Table );
    +        goto Exit;
    +      }
    +
    +      tupleDataSize = FT_NEXT_USHORT( p );
    +      tupleIndex    = FT_NEXT_USHORT( p );
    +
    +      if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
    +        tupleScalars = NULL;
     
           if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
           {
    +        if ( 2 * blend->num_axis > (FT_UInt)( stream->limit - p ) )
    +        {
    +          FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
    +                      " invalid glyph variation array header\n" ));
    +          error = FT_THROW( Invalid_Table );
    +          goto Exit;
    +        }
    +
             for ( j = 0; j < blend->num_axis; j++ )
    -          peak_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
    +          peak_coords[j] = FT_fdot14ToFixed( FT_NEXT_SHORT( p ) );
    +
             tuple_coords = peak_coords;
    +        tupleScalars = NULL;
           }
           else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) < blend->tuplecount )
    +      {
    +        FT_Fixed  scalar =
    +                    tupleScalars
    +                      ? tupleScalars[tupleIndex & GX_TI_TUPLE_INDEX_MASK]
    +                      : (FT_Fixed)-0x20000;
    +
    +
    +        if ( scalar != (FT_Fixed)-0x20000 )
    +        {
    +          apply = scalar;
    +          goto apply_found;
    +        }
    +
             tuple_coords = blend->tuplecoords +
    -            ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis;
    +                         ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) *
    +                         blend->num_axis;
    +      }
           else
           {
             FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
    @@ -4179,10 +4477,18 @@
     
           if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
           {
    +        if ( 4 * blend->num_axis > (FT_UInt)( stream->limit - p ) )
    +        {
    +          FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
    +                      " invalid glyph variation array header\n" ));
    +          error = FT_THROW( Invalid_Table );
    +          goto Exit;
    +        }
    +
             for ( j = 0; j < blend->num_axis; j++ )
    -          im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
    +          im_start_coords[j] = FT_fdot14ToFixed( FT_NEXT_SHORT( p ) );
             for ( j = 0; j < blend->num_axis; j++ )
    -          im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
    +          im_end_coords[j] = FT_fdot14ToFixed( FT_NEXT_SHORT( p ) );
           }
     
           apply = ft_var_apply_tuple( blend,
    @@ -4191,6 +4497,11 @@
                                       im_start_coords,
                                       im_end_coords );
     
    +      if ( tupleScalars )
    +        tupleScalars[tupleIndex & GX_TI_TUPLE_INDEX_MASK] = apply;
    +
    +    apply_found:
    +
           if ( apply == 0 )              /* tuple isn't active for our blend */
           {
             offsetToData += tupleDataSize;
    @@ -4247,7 +4558,7 @@
     #ifdef FT_DEBUG_LEVEL_TRACE
               if ( point_delta_x || point_delta_y )
               {
    -            FT_TRACE7(( "      %d: (%f, %f) -> (%f, %f)\n",
    +            FT_TRACE7(( "      %u: (%f, %f) -> (%f, %f)\n",
                             j,
                             (double)( FT_intToFixed( outline->points[j].x ) +
                                         old_point_delta_x ) / 65536,
    @@ -4321,7 +4632,7 @@
     #ifdef FT_DEBUG_LEVEL_TRACE
               if ( point_delta_x || point_delta_y )
               {
    -            FT_TRACE7(( "      %d: (%f, %f) -> (%f, %f)\n",
    +            FT_TRACE7(( "      %u: (%f, %f) -> (%f, %f)\n",
                             j,
                             (double)( FT_intToFixed( outline->points[j].x ) +
                                         old_point_delta_x ) / 65536,
    @@ -4402,11 +4713,7 @@
       Exit:
         if ( sharedpoints != ALL_POINTS )
           FT_FREE( sharedpoints );
    -    FT_FREE( points_org );
    -    FT_FREE( points_out );
    -    FT_FREE( has_delta );
    -    FT_FREE( peak_coords );
    -    FT_FREE( point_deltas_x );
    +    FT_FREE( pool );
     
       FExit:
         FT_FRAME_EXIT();
    @@ -4577,6 +4884,7 @@
             FT_FREE( blend->mvar_table );
           }
     
    +      FT_FREE( blend->tuplescalars );
           FT_FREE( blend->tuplecoords );
           FT_FREE( blend->glyphoffsets );
           FT_FREE( blend );
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
    index 9326011e3a2..568c8027bbf 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType GX Font Variation loader (specification)
      *
    - * Copyright (C) 2004-2024 by
    + * Copyright (C) 2004-2025 by
      * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -255,6 +255,10 @@ FT_BEGIN_HEADER
        *     A two-dimensional array that holds the shared tuple coordinates
        *     in the `gvar' table.
        *
    +   *   tuplescalars ::
    +   *     A one-dimensional array that holds the shared tuple
    +   *     scalars in the `gvar' table for current face coordinates.
    +   *
        *   gv_glyphcnt ::
        *     The number of glyphs handled in the `gvar' table.
        *
    @@ -293,6 +297,7 @@ FT_BEGIN_HEADER
     
         FT_UInt         tuplecount;
         FT_Fixed*       tuplecoords;      /* tuplecoords[tuplecount][num_axis] */
    +    FT_Fixed*       tuplescalars;     /* tuplescalars[tuplecount]          */
     
         FT_UInt         gv_glyphcnt;
         FT_ULong*       glyphoffsets;         /* glyphoffsets[gv_glyphcnt + 1] */
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
    index 951891dbf51..f46cc77fe5f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType bytecode interpreter (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -27,6 +27,8 @@
     #include 
     #include 
     
    +#ifdef TT_USE_BYTECODE_INTERPRETER
    +
     #include "ttinterp.h"
     #include "tterrors.h"
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    @@ -34,9 +36,6 @@
     #endif
     
     
    -#ifdef TT_USE_BYTECODE_INTERPRETER
    -
    -
       /**************************************************************************
        *
        * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    @@ -89,6 +88,32 @@
     #define FAILURE  1
     
     
    +  /* The default value for `scan_control' is documented as FALSE in the */
    +  /* TrueType specification.  This is confusing since it implies a      */
    +  /* Boolean value.  However, this is not the case, thus both the       */
    +  /* default values of our `scan_type' and `scan_control' fields (which */
    +  /* the documentation's `scan_control' variable is split into) are     */
    +  /* zero.                                                              */
    +  /*                                                                    */
    +  /* The rounding compensation should logically belong here but poorly  */
    +  /* described in the OpenType specs.  It was probably important in the */
    +  /* days of dot matrix printers.  The values are referenced by color   */
    +  /* as Gray, Black, and White in order. The Apple specification says   */
    +  /* that the Gray compensation is always zero.  The fourth value is    */
    +  /* not described at all, but Greg says that it is the same as Gray.   */
    +  /* FreeType sets all compensation values to zero.                     */
    +
    +  const TT_GraphicsState  tt_default_graphics_state =
    +  {
    +    0, 0, 0,  1, 1, 1,
    +    { 0x4000, 0 }, { 0x4000, 0 }, { 0x4000, 0 },
    +    1, 1, { 0, 0, 0, 0 },
    +
    +    64, 68, 0, 0, 9, 3,
    +    TRUE, 0, FALSE, 0
    +  };
    +
    +
       /**************************************************************************
        *
        *                       CODERANGE FUNCTIONS
    @@ -96,53 +121,6 @@
        */
     
     
    -  /**************************************************************************
    -   *
    -   * @Function:
    -   *   TT_Goto_CodeRange
    -   *
    -   * @Description:
    -   *   Switches to a new code range (updates the code related elements in
    -   *   `exec', and `IP').
    -   *
    -   * @Input:
    -   *   range ::
    -   *     The new execution code range.
    -   *
    -   *   IP ::
    -   *     The new IP in the new code range.
    -   *
    -   * @InOut:
    -   *   exec ::
    -   *     The target execution context.
    -   */
    -  FT_LOCAL_DEF( void )
    -  TT_Goto_CodeRange( TT_ExecContext  exec,
    -                     FT_Int          range,
    -                     FT_Long         IP )
    -  {
    -    TT_CodeRange*  coderange;
    -
    -
    -    FT_ASSERT( range >= 1 && range <= 3 );
    -
    -    coderange = &exec->codeRangeTable[range - 1];
    -
    -    FT_ASSERT( coderange->base );
    -
    -    /* NOTE: Because the last instruction of a program may be a CALL */
    -    /*       which will return to the first byte *after* the code    */
    -    /*       range, we test for IP <= Size instead of IP < Size.     */
    -    /*                                                               */
    -    FT_ASSERT( IP <= coderange->size );
    -
    -    exec->code     = coderange->base;
    -    exec->codeSize = coderange->size;
    -    exec->IP       = IP;
    -    exec->curRange = range;
    -  }
    -
    -
       /**************************************************************************
        *
        * @Function:
    @@ -168,13 +146,19 @@
       FT_LOCAL_DEF( void )
       TT_Set_CodeRange( TT_ExecContext  exec,
                         FT_Int          range,
    -                    void*           base,
    +                    FT_Byte*        base,
                         FT_Long         length )
       {
         FT_ASSERT( range >= 1 && range <= 3 );
     
    -    exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
    +    exec->codeRangeTable[range - 1].base = base;
         exec->codeRangeTable[range - 1].size = length;
    +
    +    exec->code     = base;
    +    exec->codeSize = length;
    +    exec->IP       = 0;
    +    exec->curRange = range;
    +    exec->iniRange = range;
       }
     
     
    @@ -224,9 +208,6 @@
        *   exec ::
        *     A handle to the target execution context.
        *
    -   *   memory ::
    -   *     A handle to the parent memory object.
    -   *
        * @Note:
        *   Only the glyph loader and debugger should call this function.
        */
    @@ -240,10 +221,6 @@
         exec->maxPoints   = 0;
         exec->maxContours = 0;
     
    -    /* free stack */
    -    FT_FREE( exec->stack );
    -    exec->stackSize = 0;
    -
         /* free glyf cvt working area */
         FT_FREE( exec->glyfCvt );
         exec->glyfCvtSize = 0;
    @@ -295,79 +272,31 @@
        *
        *   Note that not all members of `TT_ExecContext` get initialized.
        */
    -  FT_LOCAL_DEF( FT_Error )
    +  FT_LOCAL_DEF( void )
       TT_Load_Context( TT_ExecContext  exec,
                        TT_Face         face,
                        TT_Size         size )
       {
    -    FT_Int          i;
    -    TT_MaxProfile*  maxp;
    -    FT_Error        error;
    -    FT_Memory       memory = exec->memory;
    +    FT_Memory  memory = exec->memory;
     
     
         exec->face = face;
    -    maxp       = &face->max_profile;
         exec->size = size;
     
    -    if ( size )
    -    {
    -      exec->numFDefs   = size->num_function_defs;
    -      exec->maxFDefs   = size->max_function_defs;
    -      exec->numIDefs   = size->num_instruction_defs;
    -      exec->maxIDefs   = size->max_instruction_defs;
    -      exec->FDefs      = size->function_defs;
    -      exec->IDefs      = size->instruction_defs;
    -      exec->pointSize  = size->point_size;
    -      exec->tt_metrics = size->ttmetrics;
    -      exec->metrics    = *size->metrics;
    -
    -      exec->maxFunc    = size->max_func;
    -      exec->maxIns     = size->max_ins;
    -
    -      for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
    -        exec->codeRangeTable[i] = size->codeRangeTable[i];
    -
    -      /* set graphics state */
    -      exec->GS = size->GS;
    -
    -      exec->cvtSize = size->cvt_size;
    -      exec->cvt     = size->cvt;
    -
    -      exec->storeSize = size->storage_size;
    -      exec->storage   = size->storage;
    -
    -      exec->twilight  = size->twilight;
    -
    -      /* In case of multi-threading it can happen that the old size object */
    -      /* no longer exists, thus we must clear all glyph zone references.   */
    -      FT_ZERO( &exec->zp0 );
    -      exec->zp1 = exec->zp0;
    -      exec->zp2 = exec->zp0;
    -    }
    -
    -    /* XXX: We reserve a little more elements on the stack to deal safely */
    -    /*      with broken fonts like arialbs, courbs, timesbs, etc.         */
    -    if ( FT_QRENEW_ARRAY( exec->stack,
    -                          exec->stackSize,
    -                          maxp->maxStackElements + 32 ) )
    -      return error;
    -    exec->stackSize = maxp->maxStackElements + 32;
    +    /* CVT and storage are not persistent in FreeType */
    +    /* reset them after they might have been modified */
    +    exec->storage = exec->stack   + exec->stackSize;
    +    exec->cvt     = exec->storage + exec->storeSize;
     
         /* free previous glyph code range */
         FT_FREE( exec->glyphIns );
         exec->glyphSize = 0;
     
    -    exec->pts.n_points   = 0;
    -    exec->pts.n_contours = 0;
    +    exec->pointSize  = size->point_size;
    +    exec->tt_metrics = size->ttmetrics;
    +    exec->metrics    = *size->metrics;
     
    -    exec->zp1 = exec->pts;
    -    exec->zp2 = exec->pts;
    -    exec->zp0 = exec->pts;
    -
    -    exec->instruction_trap = FALSE;
    -
    -    return FT_Err_Ok;
    +    exec->twilight   = size->twilight;
       }
     
     
    @@ -394,89 +323,22 @@
       TT_Save_Context( TT_ExecContext  exec,
                        TT_Size         size )
       {
    -    FT_Int  i;
    +    /* UNDOCUMENTED!                                            */
    +    /* Only these GS values can be modified by the CVT program. */
     
    -
    -    /* XXX: Will probably disappear soon with all the code range */
    -    /*      management, which is now rather obsolete.            */
    -    /*                                                           */
    -    size->num_function_defs    = exec->numFDefs;
    -    size->num_instruction_defs = exec->numIDefs;
    -
    -    size->max_func = exec->maxFunc;
    -    size->max_ins  = exec->maxIns;
    -
    -    for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
    -      size->codeRangeTable[i] = exec->codeRangeTable[i];
    +    size->GS.minimum_distance    = exec->GS.minimum_distance;
    +    size->GS.control_value_cutin = exec->GS.control_value_cutin;
    +    size->GS.single_width_cutin  = exec->GS.single_width_cutin;
    +    size->GS.single_width_value  = exec->GS.single_width_value;
    +    size->GS.delta_base          = exec->GS.delta_base;
    +    size->GS.delta_shift         = exec->GS.delta_shift;
    +    size->GS.auto_flip           = exec->GS.auto_flip;
    +    size->GS.instruct_control    = exec->GS.instruct_control;
    +    size->GS.scan_control        = exec->GS.scan_control;
    +    size->GS.scan_type           = exec->GS.scan_type;
       }
     
     
    -  /**************************************************************************
    -   *
    -   * @Function:
    -   *   TT_Run_Context
    -   *
    -   * @Description:
    -   *   Executes one or more instructions in the execution context.
    -   *
    -   * @Input:
    -   *   exec ::
    -   *     A handle to the target execution context.
    -   *
    -   * @Return:
    -   *   TrueType error code.  0 means success.
    -   */
    -  FT_LOCAL_DEF( FT_Error )
    -  TT_Run_Context( TT_ExecContext  exec )
    -  {
    -    TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 );
    -
    -    exec->zp0 = exec->pts;
    -    exec->zp1 = exec->pts;
    -    exec->zp2 = exec->pts;
    -
    -    exec->GS.gep0 = 1;
    -    exec->GS.gep1 = 1;
    -    exec->GS.gep2 = 1;
    -
    -    exec->GS.projVector.x = 0x4000;
    -    exec->GS.projVector.y = 0x0000;
    -
    -    exec->GS.freeVector = exec->GS.projVector;
    -    exec->GS.dualVector = exec->GS.projVector;
    -
    -    exec->GS.round_state = 1;
    -    exec->GS.loop        = 1;
    -
    -    /* some glyphs leave something on the stack. so we clean it */
    -    /* before a new execution.                                  */
    -    exec->top     = 0;
    -    exec->callTop = 0;
    -
    -    return exec->face->interpreter( exec );
    -  }
    -
    -
    -  /* The default value for `scan_control' is documented as FALSE in the */
    -  /* TrueType specification.  This is confusing since it implies a      */
    -  /* Boolean value.  However, this is not the case, thus both the       */
    -  /* default values of our `scan_type' and `scan_control' fields (which */
    -  /* the documentation's `scan_control' variable is split into) are     */
    -  /* zero.                                                              */
    -
    -  const TT_GraphicsState  tt_default_graphics_state =
    -  {
    -    0, 0, 0,
    -    { 0x4000, 0 },
    -    { 0x4000, 0 },
    -    { 0x4000, 0 },
    -
    -    1, 64, 1,
    -    TRUE, 68, 0, 0, 9, 3,
    -    0, FALSE, 0, 1, 1, 1
    -  };
    -
    -
       /* documentation is in ttinterp.h */
     
       FT_EXPORT_DEF( TT_ExecContext )
    @@ -485,7 +347,8 @@
         FT_Memory  memory;
         FT_Error   error;
     
    -    TT_ExecContext  exec = NULL;
    +    TT_ExecContext     exec = NULL;
    +    FT_DebugHook_Func  interp;
     
     
         if ( !driver )
    @@ -497,6 +360,15 @@
         if ( FT_NEW( exec ) )
           goto Fail;
     
    +    /* set `exec->interpreter' according to the debug hook present, */
    +    /* which is used by 'ttdebug'.                                  */
    +    interp = driver->root.root.library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
    +
    +    if ( interp )
    +      exec->interpreter = (TT_Interpreter)interp;
    +    else
    +      exec->interpreter = (TT_Interpreter)TT_RunIns;
    +
         /* create callStack here, other allocations delayed */
         exec->memory   = memory;
         exec->callSize = 32;
    @@ -1160,20 +1032,35 @@
     #undef PACK
     
     
    -#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
    +#ifdef FT_INT64
    +
    +#define TT_MulFix14( a, b )  TT_MulFix14_64( a, b )
    +
    +  static inline FT_F26Dot6
    +  TT_MulFix14_64( FT_F26Dot6  a,
    +                  FT_F2Dot14  b )
    +  {
    +    FT_Int64  ab = MUL_INT64( a, b );
    +
    +
    +    ab = ADD_INT64( ab, 0x2000 + ( ab >> 63 ) );  /* rounding phase */
    +
    +    return (FT_F26Dot6)( ab >> 14 );
    +  }
    +
    +#elif !defined( FT_CONFIG_OPTION_NO_ASSEMBLER )
     
     #if defined( __arm__ )                                 && \
         ( defined( __thumb2__ ) || !defined( __thumb__ ) )
     
     #define TT_MulFix14  TT_MulFix14_arm
     
    -  static FT_Int32
    +  static __inline FT_Int32
       TT_MulFix14_arm( FT_Int32  a,
    -                   FT_Int    b )
    +                   FT_Int32  b )
       {
         FT_Int32  t, t2;
     
    -
     #if defined( __CC_ARM ) || defined( __ARMCC__ )
     
         __asm
    @@ -1199,8 +1086,8 @@
     #endif
           "adds   %1, %1, %0\n\t"           /* %1 += %0 */
           "adc    %2, %2, #0\n\t"           /* %2 += carry */
    -      "mov    %0, %1, lsr #14\n\t"      /* %0  = %1 >> 16 */
    -      "orr    %0, %0, %2, lsl #18\n\t"  /* %0 |= %2 << 16 */
    +      "mov    %0, %1, lsr #14\n\t"      /* %0  = %1 >> 14 */
    +      "orr    %0, %0, %2, lsl #18\n\t"  /* %0 |= %2 << 18 */
           : "=r"(a), "=&r"(t2), "=&r"(t)
           : "r"(a), "r"(b)
           : "cc" );
    @@ -1210,49 +1097,60 @@
         return a;
       }
     
    -#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
    +#elif defined( __i386__ ) || defined( _M_IX86 )
     
    -#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
    +#define TT_MulFix14  TT_MulFix14_i386
     
    +  /* documentation is in freetype.h */
     
    -#if defined( __GNUC__ )                              && \
    -    ( defined( __i386__ ) || defined( __x86_64__ ) )
    -
    -#define TT_MulFix14  TT_MulFix14_long_long
    -
    -  /* Temporarily disable the warning that C90 doesn't support `long long'. */
    -#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
    -#pragma GCC diagnostic push
    -#endif
    -#pragma GCC diagnostic ignored "-Wlong-long"
    -
    -  /* This is declared `noinline' because inlining the function results */
    -  /* in slower code.  The `pure' attribute indicates that the result   */
    -  /* only depends on the parameters.                                   */
    -  static __attribute__(( noinline ))
    -         __attribute__(( pure )) FT_Int32
    -  TT_MulFix14_long_long( FT_Int32  a,
    -                         FT_Int    b )
    +  static __inline FT_Int32
    +  TT_MulFixi14_i386( FT_Int32  a,
    +                     FT_Int32  b )
       {
    +    FT_Int32  result;
     
    -    long long  ret = (long long)a * b;
    +#if defined( __GNUC__ )
     
    -    /* The following line assumes that right shifting of signed values */
    -    /* will actually preserve the sign bit.  The exact behaviour is    */
    -    /* undefined, but this is true on x86 and x86_64.                  */
    -    long long  tmp = ret >> 63;
    +    __asm__ __volatile__ (
    +      "imul  %%edx\n"
    +      "movl  %%edx, %%ecx\n"
    +      "sarl  $31, %%ecx\n"
    +      "addl  $0x2000, %%ecx\n"
    +      "addl  %%ecx, %%eax\n"
    +      "adcl  $0, %%edx\n"
    +      "shrl  $14, %%eax\n"
    +      "shll  $18, %%edx\n"
    +      "addl  %%edx, %%eax\n"
    +      : "=a"(result), "=d"(b)
    +      : "a"(a), "d"(b)
    +      : "%ecx", "cc" );
     
    +#elif defined( _MSC_VER)
     
    -    ret += 0x2000 + tmp;
    +    __asm
    +    {
    +      mov eax, a
    +      mov edx, b
    +      imul edx
    +      mov ecx, edx
    +      sar ecx, 31
    +      add ecx, 2000h
    +      add eax, ecx
    +      adc edx, 0
    +      shr eax, 14
    +      shl edx, 18
    +      add eax, edx
    +      mov result, eax
    +    }
     
    -    return (FT_Int32)( ret >> 14 );
    +#endif
    +
    +    return result;
       }
     
    -#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
    -#pragma GCC diagnostic pop
    -#endif
    +#endif /* __i386__ || _M_IX86 */
     
    -#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
    +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
     
     
     #ifndef TT_MulFix14
    @@ -1262,92 +1160,59 @@
       /* for platforms where sizeof(int) == 2.                   */
       static FT_Int32
       TT_MulFix14( FT_Int32  a,
    -               FT_Int    b )
    +               FT_Int16  b )
       {
    -    FT_Int32   sign;
    -    FT_UInt32  ah, al, mid, lo, hi;
    +    FT_Int32   m, hi;
    +    FT_UInt32  l, lo;
     
     
    -    sign = a ^ b;
    +    /* compute a*b as 64-bit (hi_lo) value */
    +    l = (FT_UInt32)( ( a & 0xFFFFU ) * b );
    +    m = ( a >> 16 ) * b;
     
    -    if ( a < 0 )
    -      a = -a;
    -    if ( b < 0 )
    -      b = -b;
    +    lo = l + ( (FT_UInt32)m << 16 );
    +    hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l );
     
    -    ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
    -    al = (FT_UInt32)( a & 0xFFFFU );
    +    /* divide the result by 2^14 with rounding */
    +    l   = lo + 0x2000U + (FT_UInt32)( hi >> 31 );  /* rounding phase */
    +    hi += ( l < lo );
     
    -    lo    = al * b;
    -    mid   = ah * b;
    -    hi    = mid >> 16;
    -    mid   = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
    -    lo   += mid;
    -    if ( lo < mid )
    -      hi += 1;
    -
    -    mid = ( lo >> 14 ) | ( hi << 18 );
    -
    -    return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
    +    return (FT_F26Dot6)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
       }
     
     #endif  /* !TT_MulFix14 */
     
     
    -#if defined( __GNUC__ )        && \
    -    ( defined( __i386__ )   ||    \
    -      defined( __x86_64__ ) ||    \
    -      defined( __arm__ )    )
    -
    -#define TT_DotFix14  TT_DotFix14_long_long
    -
    -#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
    -#pragma GCC diagnostic push
    -#endif
    -#pragma GCC diagnostic ignored "-Wlong-long"
    -
    -  static __attribute__(( pure )) FT_Int32
    -  TT_DotFix14_long_long( FT_Int32  ax,
    -                         FT_Int32  ay,
    -                         FT_Int    bx,
    -                         FT_Int    by )
    -  {
    -    /* Temporarily disable the warning that C90 doesn't support */
    -    /* `long long'.                                             */
    -
    -    long long  temp1 = (long long)ax * bx;
    -    long long  temp2 = (long long)ay * by;
    -
    -
    -    temp1 += temp2;
    -    temp2  = temp1 >> 63;
    -    temp1 += 0x2000 + temp2;
    -
    -    return (FT_Int32)( temp1 >> 14 );
    -
    -  }
    -
    -#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
    -#pragma GCC diagnostic pop
    -#endif
    -
    -#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
    -
    -
    -#ifndef TT_DotFix14
    +#ifdef FT_INT64
     
       /* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
    -  static FT_Int32
    -  TT_DotFix14( FT_Int32  ax,
    -               FT_Int32  ay,
    -               FT_Int    bx,
    -               FT_Int    by )
    +  static inline FT_F26Dot6
    +  TT_DotFix14( FT_F26Dot6  ax,
    +               FT_F26Dot6  ay,
    +               FT_F2Dot14  bx,
    +               FT_F2Dot14  by )
       {
    -    FT_Int32   m, s, hi1, hi2, hi;
    +    FT_Int64  c = ADD_INT64( MUL_INT64( ax, bx ), MUL_INT64( ay, by ) );
    +
    +
    +    c = ADD_INT64( c, 0x2000 + ( c >> 63 ) );  /* rounding phase */
    +
    +    return (FT_F26Dot6)( c >> 14 );
    +  }
    +
    +#else
    +
    +  static inline FT_F26Dot6
    +  TT_DotFix14( FT_F26Dot6  ax,
    +               FT_F26Dot6  ay,
    +               FT_F2Dot14  bx,
    +               FT_F2Dot14  by )
    +  {
    +    FT_Int32   m, hi1, hi2, hi;
         FT_UInt32  l, lo1, lo2, lo;
     
     
    -    /* compute ax*bx as 64-bit value */
    +    /* compute ax*bx as 64-bit (hi_lo) value */
         l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );
         m = ( ax >> 16 ) * bx;
     
    @@ -1366,18 +1231,13 @@
         hi = hi1 + hi2 + ( lo < lo1 );
     
         /* divide the result by 2^14 with rounding */
    -    s   = hi >> 31;
    -    l   = lo + (FT_UInt32)s;
    -    hi += s + ( l < lo );
    -    lo  = l;
    -
    -    l   = lo + 0x2000U;
    +    l   = lo + 0x2000U + (FT_UInt32)( hi >> 31 );  /* rounding phase */
         hi += ( l < lo );
     
    -    return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
    +    return (FT_F26Dot6)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
       }
     
    -#endif /* TT_DotFix14 */
    +#endif /* !FT_INT64 */
     
     
       /**************************************************************************
    @@ -1531,31 +1391,6 @@
       }
     
     
    -  /**************************************************************************
    -   *
    -   * @Function:
    -   *   GetShortIns
    -   *
    -   * @Description:
    -   *   Returns a short integer taken from the instruction stream at
    -   *   address IP.
    -   *
    -   * @Return:
    -   *   Short read at code[IP].
    -   *
    -   * @Note:
    -   *   This one could become a macro.
    -   */
    -  static FT_Short
    -  GetShortIns( TT_ExecContext  exc )
    -  {
    -    /* Reading a byte stream so there is no endianness (DaveP) */
    -    exc->IP += 2;
    -    return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) +
    -                         exc->code[exc->IP - 1]      );
    -  }
    -
    -
       /**************************************************************************
        *
        * @Function:
    @@ -1609,6 +1444,7 @@
         exc->code     = range->base;
         exc->codeSize = range->size;
         exc->IP       = aIP;
    +    exc->length   = 0;
         exc->curRange = aRange;
     
         return SUCCESS;
    @@ -1671,48 +1507,33 @@
                    FT_UShort       point,
                    FT_F26Dot6      distance )
       {
    -    FT_F26Dot6  v;
    +    FT_Fixed  v;
     
     
    -    v = exc->GS.freeVector.x;
    -
    +    v = exc->moveVector.x;
         if ( v != 0 )
         {
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
           /* Exception to the post-IUP curfew: Allow the x component of */
           /* diagonal moves, but only post-IUP.  DejaVu tries to adjust */
           /* diagonal stems like on `Z' and `z' post-IUP.               */
    -      if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
    -        zone->cur[point].x = ADD_LONG( zone->cur[point].x,
    -                                       FT_MulDiv( distance,
    -                                                  v,
    -                                                  exc->F_dot_P ) );
    -      else
    +      if ( !exc->backward_compatibility )
     #endif
    -
    -      if ( NO_SUBPIXEL_HINTING )
             zone->cur[point].x = ADD_LONG( zone->cur[point].x,
    -                                       FT_MulDiv( distance,
    -                                                  v,
    -                                                  exc->F_dot_P ) );
    +                                       FT_MulFix( distance, v ) );
     
           zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
         }
     
    -    v = exc->GS.freeVector.y;
    -
    +    v = exc->moveVector.y;
         if ( v != 0 )
         {
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -      if ( !( SUBPIXEL_HINTING_MINIMAL    &&
    -              exc->backward_compatibility &&
    -              exc->iupx_called            &&
    -              exc->iupy_called            ) )
    +      /* See `ttinterp.h' for details on backward compatibility mode. */
    +      if ( exc->backward_compatibility != 0x7 )
     #endif
             zone->cur[point].y = ADD_LONG( zone->cur[point].y,
    -                                       FT_MulDiv( distance,
    -                                                  v,
    -                                                  exc->F_dot_P ) );
    +                                       FT_MulFix( distance, v ) );
     
           zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
         }
    @@ -1745,24 +1566,20 @@
                         FT_UShort       point,
                         FT_F26Dot6      distance )
       {
    -    FT_F26Dot6  v;
    +    FT_Fixed  v;
     
     
    -    v = exc->GS.freeVector.x;
    +    v = exc->moveVector.x;
     
         if ( v != 0 )
           zone->org[point].x = ADD_LONG( zone->org[point].x,
    -                                     FT_MulDiv( distance,
    -                                                v,
    -                                                exc->F_dot_P ) );
    +                                     FT_MulFix( distance, v ) );
     
    -    v = exc->GS.freeVector.y;
    +    v = exc->moveVector.y;
     
         if ( v != 0 )
           zone->org[point].y = ADD_LONG( zone->org[point].y,
    -                                     FT_MulDiv( distance,
    -                                                v,
    -                                                exc->F_dot_P ) );
    +                                     FT_MulFix( distance, v ) );
       }
     
     
    @@ -1784,12 +1601,8 @@
                      FT_F26Dot6      distance )
       {
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
    -      zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
    -    else
    +    if ( !exc->backward_compatibility )
     #endif
    -
    -    if ( NO_SUBPIXEL_HINTING )
           zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
     
         zone->tags[point]  |= FT_CURVE_TAG_TOUCH_X;
    @@ -1805,9 +1618,8 @@
         FT_UNUSED( exc );
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    if ( !( SUBPIXEL_HINTING_MINIMAL             &&
    -            exc->backward_compatibility          &&
    -            exc->iupx_called && exc->iupy_called ) )
    +    /* See `ttinterp.h' for details on backward compatibility mode. */
    +    if ( exc->backward_compatibility != 0x7 )
     #endif
           zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance );
     
    @@ -1860,8 +1672,8 @@
        *   distance ::
        *     The distance (not) to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   The compensated distance.
    @@ -1869,10 +1681,10 @@
       static FT_F26Dot6
       Round_None( TT_ExecContext  exc,
                   FT_F26Dot6      distance,
    -              FT_Int          color )
    +              FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -1903,8 +1715,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -1912,10 +1724,10 @@
       static FT_F26Dot6
       Round_To_Grid( TT_ExecContext  exc,
                      FT_F26Dot6      distance,
    -                 FT_Int          color )
    +                 FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -1948,8 +1760,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -1957,10 +1769,10 @@
       static FT_F26Dot6
       Round_To_Half_Grid( TT_ExecContext  exc,
                           FT_F26Dot6      distance,
    -                      FT_Int          color )
    +                      FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -1995,8 +1807,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -2004,10 +1816,10 @@
       static FT_F26Dot6
       Round_Down_To_Grid( TT_ExecContext  exc,
                           FT_F26Dot6      distance,
    -                      FT_Int          color )
    +                      FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -2039,8 +1851,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -2048,10 +1860,10 @@
       static FT_F26Dot6
       Round_Up_To_Grid( TT_ExecContext  exc,
                         FT_F26Dot6      distance,
    -                    FT_Int          color )
    +                    FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -2084,8 +1896,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -2093,10 +1905,10 @@
       static FT_F26Dot6
       Round_To_Double_Grid( TT_ExecContext  exc,
                             FT_F26Dot6      distance,
    -                        FT_Int          color )
    +                        FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
    +    FT_UNUSED( exc );
     
     
         if ( distance >= 0 )
    @@ -2129,8 +1941,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -2144,9 +1956,8 @@
       static FT_F26Dot6
       Round_Super( TT_ExecContext  exc,
                    FT_F26Dot6      distance,
    -               FT_Int          color )
    +               FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
     
     
    @@ -2185,8 +1996,8 @@
        *   distance ::
        *     The distance to round.
        *
    -   *   color ::
    -   *     The engine compensation color.
    +   *   compensation ::
    +   *     The engine compensation.
        *
        * @Return:
        *   Rounded distance.
    @@ -2198,9 +2009,8 @@
       static FT_F26Dot6
       Round_Super_45( TT_ExecContext  exc,
                       FT_F26Dot6      distance,
    -                  FT_Int          color )
    +                  FT_F26Dot6      compensation )
       {
    -    FT_F26Dot6  compensation = exc->tt_metrics.compensations[color];
         FT_F26Dot6  val;
     
     
    @@ -2227,59 +2037,6 @@
       }
     
     
    -  /**************************************************************************
    -   *
    -   * @Function:
    -   *   Compute_Round
    -   *
    -   * @Description:
    -   *   Sets the rounding mode.
    -   *
    -   * @Input:
    -   *   round_mode ::
    -   *     The rounding mode to be used.
    -   */
    -  static void
    -  Compute_Round( TT_ExecContext  exc,
    -                 FT_Byte         round_mode )
    -  {
    -    switch ( round_mode )
    -    {
    -    case TT_Round_Off:
    -      exc->func_round = (TT_Round_Func)Round_None;
    -      break;
    -
    -    case TT_Round_To_Grid:
    -      exc->func_round = (TT_Round_Func)Round_To_Grid;
    -      break;
    -
    -    case TT_Round_Up_To_Grid:
    -      exc->func_round = (TT_Round_Func)Round_Up_To_Grid;
    -      break;
    -
    -    case TT_Round_Down_To_Grid:
    -      exc->func_round = (TT_Round_Func)Round_Down_To_Grid;
    -      break;
    -
    -    case TT_Round_To_Half_Grid:
    -      exc->func_round = (TT_Round_Func)Round_To_Half_Grid;
    -      break;
    -
    -    case TT_Round_To_Double_Grid:
    -      exc->func_round = (TT_Round_Func)Round_To_Double_Grid;
    -      break;
    -
    -    case TT_Round_Super:
    -      exc->func_round = (TT_Round_Func)Round_Super;
    -      break;
    -
    -    case TT_Round_Super_45:
    -      exc->func_round = (TT_Round_Func)Round_Super_45;
    -      break;
    -    }
    -  }
    -
    -
       /**************************************************************************
        *
        * @Function:
    @@ -2481,14 +2238,45 @@
       static void
       Compute_Funcs( TT_ExecContext  exc )
       {
    -    if ( exc->GS.freeVector.x == 0x4000 )
    -      exc->F_dot_P = exc->GS.projVector.x;
    -    else if ( exc->GS.freeVector.y == 0x4000 )
    -      exc->F_dot_P = exc->GS.projVector.y;
    +    FT_Long  F_dot_P =
    +             ( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x +
    +               (FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y +
    +               0x2000L ) >> 14;
    +
    +
    +    if ( F_dot_P >= 0x3FFEL )
    +    {
    +      /* commonly collinear */
    +      exc->moveVector.x = exc->GS.freeVector.x * 4;
    +      exc->moveVector.y = exc->GS.freeVector.y * 4;
    +    }
    +    else if ( -0x400L < F_dot_P && F_dot_P < 0x400L )
    +    {
    +      /* prohibitively orthogonal */
    +      exc->moveVector.x = 0;
    +      exc->moveVector.y = 0;
    +    }
         else
    -      exc->F_dot_P =
    -        ( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x +
    -          (FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y ) >> 14;
    +    {
    +      exc->moveVector.x = exc->GS.freeVector.x * 0x10000L / F_dot_P;
    +      exc->moveVector.y = exc->GS.freeVector.y * 0x10000L / F_dot_P;
    +    }
    +
    +    if ( F_dot_P >= 0x3FFEL && exc->GS.freeVector.x == 0x4000 )
    +    {
    +      exc->func_move      = (TT_Move_Func)Direct_Move_X;
    +      exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
    +    }
    +    else if ( F_dot_P >= 0x3FFEL && exc->GS.freeVector.y == 0x4000 )
    +    {
    +      exc->func_move      = (TT_Move_Func)Direct_Move_Y;
    +      exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
    +    }
    +    else
    +    {
    +      exc->func_move      = (TT_Move_Func)Direct_Move;
    +      exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig;
    +    }
     
         if ( exc->GS.projVector.x == 0x4000 )
           exc->func_project = (TT_Project_Func)Project_x;
    @@ -2504,29 +2292,6 @@
         else
           exc->func_dualproj = (TT_Project_Func)Dual_Project;
     
    -    exc->func_move      = (TT_Move_Func)Direct_Move;
    -    exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig;
    -
    -    if ( exc->F_dot_P == 0x4000L )
    -    {
    -      if ( exc->GS.freeVector.x == 0x4000 )
    -      {
    -        exc->func_move      = (TT_Move_Func)Direct_Move_X;
    -        exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
    -      }
    -      else if ( exc->GS.freeVector.y == 0x4000 )
    -      {
    -        exc->func_move      = (TT_Move_Func)Direct_Move_Y;
    -        exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
    -      }
    -    }
    -
    -    /* at small sizes, F_dot_P can become too small, resulting   */
    -    /* in overflows and `spikes' in a number of glyphs like `w'. */
    -
    -    if ( FT_ABS( exc->F_dot_P ) < 0x400L )
    -      exc->F_dot_P = 0x4000L;
    -
         /* Disable cached aspect ratio */
         exc->tt_metrics.ratio = 0;
       }
    @@ -2799,7 +2564,7 @@
       Ins_ODD( TT_ExecContext  exc,
                FT_Long*        args )
       {
    -    args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 64 );
    +    args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 64 ) == 64 );
       }
     
     
    @@ -2813,7 +2578,7 @@
       Ins_EVEN( TT_ExecContext  exc,
                 FT_Long*        args )
       {
    -    args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 0 );
    +    args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 64 ) == 0 );
       }
     
     
    @@ -3020,7 +2785,7 @@
             FT_MEM_QRENEW_ARRAY( exc->glyfStorage,
                                  exc->glyfStoreSize,
                                  exc->storeSize );
    -        exc->error  = error;
    +        exc->error = error;
             if ( error )
               return;
     
    @@ -3143,7 +2908,8 @@
       Ins_ROUND( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    -    args[0] = exc->func_round( exc, args[0], exc->opcode & 3 );
    +    args[0] = exc->func_round( exc, args[0],
    +                               exc->GS.compensation[exc->opcode & 3] );
       }
     
     
    @@ -3157,7 +2923,8 @@
       Ins_NROUND( TT_ExecContext  exc,
                   FT_Long*        args )
       {
    -    args[0] = Round_None( exc, args[0], exc->opcode & 3 );
    +    args[0] = Round_None( exc, args[0],
    +                          exc->GS.compensation[exc->opcode & 3] );
       }
     
     
    @@ -3211,13 +2978,11 @@
         }
         else
         {
    -      K = exc->stack[exc->args - L];
    +      K = args[-L];
     
    -      FT_ARRAY_MOVE( &exc->stack[exc->args - L    ],
    -                     &exc->stack[exc->args - L + 1],
    -                     ( L - 1 ) );
    +      FT_ARRAY_MOVE( args - L, args - L + 1, L - 1 );
     
    -      exc->stack[exc->args - 1] = K;
    +      args[-1] = K;
         }
       }
     
    @@ -3244,7 +3009,7 @@
           args[0] = 0;
         }
         else
    -      args[0] = exc->stack[exc->args - L];
    +      args[0] = args[-L];
       }
     
     
    @@ -3314,8 +3079,7 @@
             exc->length = 2 - exc->length * exc->code[exc->IP + 1];
           }
     
    -      if ( exc->IP + exc->length <= exc->codeSize )
    -        return SUCCESS;
    +      return SUCCESS;
         }
     
       Fail_Overflow:
    @@ -3363,6 +3127,9 @@
             nIfs--;
             Out = FT_BOOL( nIfs == 0 );
             break;
    +
    +      default:
    +        break;
           }
         } while ( Out == 0 );
       }
    @@ -3396,6 +3163,9 @@
           case 0x59:    /* EIF */
             nIfs--;
             break;
    +
    +      default:
    +        break;
           }
         } while ( nIfs != 0 );
       }
    @@ -3439,7 +3209,7 @@
           return;
         }
     
    -    exc->step_ins = FALSE;
    +    exc->length = 0;
     
         if ( args[0] < 0 )
         {
    @@ -3540,10 +3310,10 @@
           return;
         }
     
    -    rec->range          = exc->curRange;
    -    rec->opc            = (FT_UInt16)n;
    -    rec->start          = exc->IP + 1;
    -    rec->active         = TRUE;
    +    rec->range  = exc->curRange;
    +    rec->opc    = (FT_UInt16)n;
    +    rec->start  = exc->IP + 1;
    +    rec->active = TRUE;
     
         if ( n > exc->maxFunc )
           exc->maxFunc = (FT_UInt16)n;
    @@ -3555,14 +3325,17 @@
         {
           switch ( exc->opcode )
           {
    -      case 0x89:    /* IDEF */
    -      case 0x2C:    /* FDEF */
    +      case 0x89:   /* IDEF */
    +      case 0x2C:   /* FDEF */
             exc->error = FT_THROW( Nested_DEFS );
             return;
     
           case 0x2D:   /* ENDF */
             rec->end = exc->IP;
             return;
    +
    +      default:
    +        break;
           }
         }
       }
    @@ -3592,12 +3365,11 @@
     
         pRec->Cur_Count--;
     
    -    exc->step_ins = FALSE;
    -
         if ( pRec->Cur_Count > 0 )
         {
           exc->callTop++;
    -      exc->IP = pRec->Def->start;
    +      exc->IP     = pRec->Def->start;
    +      exc->length = 0;
         }
         else
           /* Loop through the current function */
    @@ -3685,8 +3457,6 @@
     
         Ins_Goto_CodeRange( exc, def->range, def->start );
     
    -    exc->step_ins = FALSE;
    -
         return;
     
       Fail:
    @@ -3764,8 +3534,6 @@
     
           Ins_Goto_CodeRange( exc, def->range, def->start );
     
    -      exc->step_ins = FALSE;
    -
           exc->loopcall_counter += (FT_ULong)args[0];
           if ( exc->loopcall_counter > exc->loopcall_counter_max )
             exc->error = FT_THROW( Execution_Too_Long );
    @@ -3845,9 +3613,13 @@
           case 0x2C:   /* FDEF */
             exc->error = FT_THROW( Nested_DEFS );
             return;
    +
           case 0x2D:   /* ENDF */
             def->end = exc->IP;
             return;
    +
    +      default:
    +        break;
           }
         }
       }
    @@ -3870,10 +3642,23 @@
       Ins_NPUSHB( TT_ExecContext  exc,
                   FT_Long*        args )
       {
    -    FT_UShort  L, K;
    +    FT_Long  IP = exc->IP;
    +    FT_Int   L, K;
     
     
    -    L = (FT_UShort)exc->code[exc->IP + 1];
    +    if ( ++IP >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
    +
    +    L = exc->code[IP];
    +
    +    if ( IP + L >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
     
         if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
         {
    @@ -3881,10 +3666,11 @@
           return;
         }
     
    -    for ( K = 1; K <= L; K++ )
    -      args[K - 1] = exc->code[exc->IP + K + 1];
    +    for ( K = 0; K < L; K++ )
    +      args[K] = exc->code[++IP];
     
         exc->new_top += L;
    +    exc->IP       = IP;
       }
     
     
    @@ -3898,10 +3684,23 @@
       Ins_NPUSHW( TT_ExecContext  exc,
                   FT_Long*        args )
       {
    -    FT_UShort  L, K;
    +    FT_Long  IP = exc->IP;
    +    FT_Int   L, K;
     
     
    -    L = (FT_UShort)exc->code[exc->IP + 1];
    +    if ( ++IP >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
    +
    +    L = exc->code[IP];
    +
    +    if ( IP + 2 * L >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
     
         if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
         {
    @@ -3909,13 +3708,12 @@
           return;
         }
     
    -    exc->IP += 2;
    +    /* note casting for sign-extension */
    +    for ( K = 0; K < L; K++, IP += 2 )
    +      args[K] = (FT_Short)( exc->code[IP + 1] << 8 ) | exc->code[IP + 2];
     
    -    for ( K = 0; K < L; K++ )
    -      args[K] = GetShortIns( exc );
    -
    -    exc->step_ins = FALSE;
         exc->new_top += L;
    +    exc->IP       = IP;
       }
     
     
    @@ -3929,10 +3727,17 @@
       Ins_PUSHB( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    -    FT_UShort  L, K;
    +    FT_Long  IP = exc->IP;
    +    FT_Int   L, K;
     
     
    -    L = (FT_UShort)( exc->opcode - 0xB0 + 1 );
    +    L = exc->opcode - 0xB0 + 1;
    +
    +    if ( IP + L >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
     
         if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
         {
    @@ -3940,8 +3745,10 @@
           return;
         }
     
    -    for ( K = 1; K <= L; K++ )
    -      args[K - 1] = exc->code[exc->IP + K];
    +    for ( K = 0; K < L; K++ )
    +      args[K] = exc->code[++IP];
    +
    +    exc->IP = IP;
       }
     
     
    @@ -3955,10 +3762,17 @@
       Ins_PUSHW( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    -    FT_UShort  L, K;
    +    FT_Long  IP = exc->IP;
    +    FT_Int   L, K;
     
     
    -    L = (FT_UShort)( exc->opcode - 0xB8 + 1 );
    +    L = exc->opcode - 0xB8 + 1;
    +
    +    if ( IP + 2 * L >= exc->codeSize )
    +    {
    +      exc->error = FT_THROW( Code_Overflow );
    +      return;
    +    }
     
         if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) )
         {
    @@ -3966,12 +3780,11 @@
           return;
         }
     
    -    exc->IP++;
    +    /* note casting for sign-extension */
    +    for ( K = 0; K < L; K++, IP += 2 )
    +      args[K] = (FT_Short)( exc->code[IP + 1] << 8 ) | exc->code[IP + 2];
     
    -    for ( K = 0; K < L; K++ )
    -      args[K] = GetShortIns( exc );
    -
    -    exc->step_ins = FALSE;
    +    exc->IP = IP;
       }
     
     
    @@ -4142,15 +3955,12 @@
       Ins_SPVFS( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    -    FT_Short  S;
         FT_Long   X, Y;
     
     
         /* Only use low 16bits, then sign extend */
    -    S = (FT_Short)args[1];
    -    Y = (FT_Long)S;
    -    S = (FT_Short)args[0];
    -    X = (FT_Long)S;
    +    Y = (FT_Short)args[1];
    +    X = (FT_Short)args[0];
     
         Normalize( X, Y, &exc->GS.projVector );
     
    @@ -4169,15 +3979,12 @@
       Ins_SFVFS( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    -    FT_Short  S;
         FT_Long   X, Y;
     
     
         /* Only use low 16bits, then sign extend */
    -    S = (FT_Short)args[1];
    -    Y = (FT_Long)S;
    -    S = (FT_Short)args[0];
    -    X = S;
    +    Y = (FT_Short)args[1];
    +    X = (FT_Short)args[0];
     
         Normalize( X, Y, &exc->GS.freeVector );
         Compute_Funcs( exc );
    @@ -4915,7 +4722,7 @@
           /* compatibility hacks and lets them program points to the grid like */
           /* it's 1996.  They might sign a waiver for just one glyph, though.  */
           if ( SUBPIXEL_HINTING_MINIMAL )
    -        exc->backward_compatibility = !FT_BOOL( L == 4 );
    +        exc->backward_compatibility = ( L & 4 ) ^ 4;
     #endif
         }
         else if ( exc->pedantic_hinting )
    @@ -4999,32 +4806,31 @@
        * Stack:        uint32... -->
        */
       static void
    -  Ins_FLIPPT( TT_ExecContext  exc )
    +  Ins_FLIPPT( TT_ExecContext  exc,
    +              FT_Long*        args )
       {
    +    FT_Long    loop = exc->GS.loop;
         FT_UShort  point;
     
     
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    /* See `ttinterp.h' for details on backward compatibility mode. */
    -    if ( SUBPIXEL_HINTING_MINIMAL    &&
    -         exc->backward_compatibility &&
    -         exc->iupx_called            &&
    -         exc->iupy_called            )
    -      goto Fail;
    -#endif
    -
    -    if ( exc->top < exc->GS.loop )
    +    if ( exc->new_top < loop )
         {
           if ( exc->pedantic_hinting )
             exc->error = FT_THROW( Too_Few_Arguments );
           goto Fail;
         }
     
    -    while ( exc->GS.loop > 0 )
    -    {
    -      exc->args--;
    +    exc->new_top -= loop;
     
    -      point = (FT_UShort)exc->stack[exc->args];
    +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    +    /* See `ttinterp.h' for details on backward compatibility mode. */
    +    if ( exc->backward_compatibility == 0x7 )
    +      goto Fail;
    +#endif
    +
    +    while ( loop-- )
    +    {
    +      point = (FT_UShort)*(--args);
     
           if ( BOUNDS( point, exc->pts.n_points ) )
           {
    @@ -5036,13 +4842,10 @@
           }
           else
             exc->pts.tags[point] ^= FT_CURVE_TAG_ON;
    -
    -      exc->GS.loop--;
         }
     
       Fail:
         exc->GS.loop = 1;
    -    exc->new_top = exc->args;
       }
     
     
    @@ -5061,10 +4864,7 @@
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
         /* See `ttinterp.h' for details on backward compatibility mode. */
    -    if ( SUBPIXEL_HINTING_MINIMAL    &&
    -         exc->backward_compatibility &&
    -         exc->iupx_called            &&
    -         exc->iupy_called            )
    +    if ( exc->backward_compatibility == 0x7 )
           return;
     #endif
     
    @@ -5099,10 +4899,7 @@
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
         /* See `ttinterp.h' for details on backward compatibility mode. */
    -    if ( SUBPIXEL_HINTING_MINIMAL    &&
    -         exc->backward_compatibility &&
    -         exc->iupx_called            &&
    -         exc->iupy_called            )
    +    if ( exc->backward_compatibility == 0x7 )
           return;
     #endif
     
    @@ -5158,8 +4955,8 @@
     
         d = PROJECT( zp.cur + p, zp.org + p );
     
    -    *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
    -    *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
    +    *x = FT_MulFix( d, exc->moveVector.x );
    +    *y = FT_MulFix( d, exc->moveVector.y );
     
         return SUCCESS;
       }
    @@ -5176,8 +4973,8 @@
         if ( exc->GS.freeVector.x != 0 )
         {
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -      if ( !( SUBPIXEL_HINTING_MINIMAL    &&
    -              exc->backward_compatibility ) )
    +      /* See `ttinterp.h' for details on backward compatibility mode. */
    +      if ( !exc->backward_compatibility )
     #endif
             exc->zp2.cur[point].x = ADD_LONG( exc->zp2.cur[point].x, dx );
     
    @@ -5188,10 +4985,8 @@
         if ( exc->GS.freeVector.y != 0 )
         {
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -      if ( !( SUBPIXEL_HINTING_MINIMAL    &&
    -              exc->backward_compatibility &&
    -              exc->iupx_called            &&
    -              exc->iupy_called            ) )
    +      /* See `ttinterp.h' for details on backward compatibility mode. */
    +      if ( exc->backward_compatibility != 0x7 )
     #endif
             exc->zp2.cur[point].y = ADD_LONG( exc->zp2.cur[point].y, dy );
     
    @@ -5208,8 +5003,10 @@
        * Stack:        uint32... -->
        */
       static void
    -  Ins_SHP( TT_ExecContext  exc )
    +  Ins_SHP( TT_ExecContext  exc,
    +           FT_Long*        args )
       {
    +    FT_Long          loop = exc->GS.loop;
         TT_GlyphZoneRec  zp;
         FT_UShort        refp;
     
    @@ -5217,20 +5014,21 @@
         FT_UShort        point;
     
     
    -    if ( exc->top < exc->GS.loop )
    +    if ( exc->new_top < loop )
         {
           if ( exc->pedantic_hinting )
    -        exc->error = FT_THROW( Invalid_Reference );
    +        exc->error = FT_THROW( Too_Few_Arguments );
           goto Fail;
         }
     
    +    exc->new_top -= loop;
    +
         if ( Compute_Point_Displacement( exc, &dx, &dy, &zp, &refp ) )
           return;
     
    -    while ( exc->GS.loop > 0 )
    +    while ( loop-- )
         {
    -      exc->args--;
    -      point = (FT_UShort)exc->stack[exc->args];
    +      point = (FT_UShort)*(--args);
     
           if ( BOUNDS( point, exc->zp2.n_points ) )
           {
    @@ -5242,13 +5040,10 @@
           }
           else
             Move_Zp2_Point( exc, point, dx, dy, TRUE );
    -
    -      exc->GS.loop--;
         }
     
       Fail:
         exc->GS.loop = 1;
    -    exc->new_top = exc->args;
       }
     
     
    @@ -5364,6 +5159,7 @@
       Ins_SHPIX( TT_ExecContext  exc,
                  FT_Long*        args )
       {
    +    FT_Long     loop = exc->GS.loop;
         FT_F26Dot6  dx, dy;
         FT_UShort   point;
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    @@ -5373,22 +5169,21 @@
     #endif
     
     
    -
    -    if ( exc->top < exc->GS.loop + 1 )
    +    if ( exc->new_top < loop )
         {
           if ( exc->pedantic_hinting )
    -        exc->error = FT_THROW( Invalid_Reference );
    +        exc->error = FT_THROW( Too_Few_Arguments );
           goto Fail;
         }
     
    +    exc->new_top -= loop;
    +
         dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
         dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
     
    -    while ( exc->GS.loop > 0 )
    +    while ( loop-- )
         {
    -      exc->args--;
    -
    -      point = (FT_UShort)exc->stack[exc->args];
    +      point = (FT_UShort)*(--args);
     
           if ( BOUNDS( point, exc->zp2.n_points ) )
           {
    @@ -5400,8 +5195,7 @@
           }
           else
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -      if ( SUBPIXEL_HINTING_MINIMAL    &&
    -           exc->backward_compatibility )
    +      if ( exc->backward_compatibility )
           {
             /* Special case: allow SHPIX to move points in the twilight zone.  */
             /* Otherwise, treat SHPIX the same as DELTAP.  Unbreaks various    */
    @@ -5409,7 +5203,7 @@
             /* that would glitch severely after calling ALIGNRP after a        */
             /* blocked SHPIX.                                                  */
             if ( in_twilight                                                ||
    -             ( !( exc->iupx_called && exc->iupy_called )              &&
    +             ( exc->backward_compatibility != 0x7                     &&
                    ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
                      ( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y )    ) ) )
               Move_Zp2_Point( exc, point, 0, dy, TRUE );
    @@ -5417,13 +5211,10 @@
           else
     #endif
             Move_Zp2_Point( exc, point, dx, dy, TRUE );
    -
    -      exc->GS.loop--;
         }
     
       Fail:
         exc->GS.loop = 1;
    -    exc->new_top = exc->args;
       }
     
     
    @@ -5502,7 +5293,7 @@
         if ( ( exc->opcode & 1 ) != 0 )
         {
           cur_dist = FAST_PROJECT( &exc->zp0.cur[point] );
    -      distance = SUB_LONG( exc->func_round( exc, cur_dist, 3 ), cur_dist );
    +      distance = SUB_LONG( exc->func_round( exc, cur_dist, 0 ), cur_dist );
         }
         else
           distance = 0;
    @@ -5566,7 +5357,7 @@
         if ( exc->GS.gep0 == 0 )   /* If in twilight zone */
         {
           exc->zp0.org[point].x = TT_MulFix14( distance,
    -                                             exc->GS.freeVector.x );
    +                                           exc->GS.freeVector.x );
           exc->zp0.org[point].y = TT_MulFix14( distance,
                                                exc->GS.freeVector.y );
           exc->zp0.cur[point]   = exc->zp0.org[point];
    @@ -5587,7 +5378,7 @@
           if ( delta > control_value_cutin )
             distance = org_dist;
     
    -      distance = exc->func_round( exc, distance, 3 );
    +      distance = exc->func_round( exc, distance, 0 );
         }
     
         exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
    @@ -5609,7 +5400,7 @@
                 FT_Long*        args )
       {
         FT_UShort   point = 0;
    -    FT_F26Dot6  org_dist, distance;
    +    FT_F26Dot6  org_dist, distance, compensation;
     
     
         point = (FT_UShort)args[0];
    @@ -5664,11 +5455,11 @@
         /* single width cut-in test */
     
         /* |org_dist - single_width_value| < single_width_cutin */
    -    if ( exc->GS.single_width_cutin > 0          &&
    -         org_dist < exc->GS.single_width_value +
    -                      exc->GS.single_width_cutin &&
    -         org_dist > exc->GS.single_width_value -
    -                      exc->GS.single_width_cutin )
    +    if ( exc->GS.single_width_cutin > 0                    &&
    +         org_dist < ADD_LONG( exc->GS.single_width_value,
    +                              exc->GS.single_width_cutin ) &&
    +         org_dist > SUB_LONG( exc->GS.single_width_value,
    +                              exc->GS.single_width_cutin ) )
         {
           if ( org_dist >= 0 )
             org_dist = exc->GS.single_width_value;
    @@ -5678,12 +5469,12 @@
     
         /* round flag */
     
    +    compensation = exc->GS.compensation[exc->opcode & 3];
    +
         if ( ( exc->opcode & 4 ) != 0 )
    -    {
    -      distance = exc->func_round( exc, org_dist, exc->opcode & 3 );
    -    }
    +      distance = exc->func_round( exc, org_dist, compensation );
         else
    -      distance = Round_None( exc, org_dist, exc->opcode & 3 );
    +      distance = Round_None( exc, org_dist, compensation );
     
         /* minimum distance flag */
     
    @@ -5735,7 +5526,8 @@
         FT_F26Dot6  cvt_dist,
                     distance,
                     cur_dist,
    -                org_dist;
    +                org_dist,
    +                compensation;
     
         FT_F26Dot6  delta;
     
    @@ -5801,6 +5593,8 @@
     
         /* control value cut-in and round */
     
    +    compensation = exc->GS.compensation[exc->opcode & 3];
    +
         if ( ( exc->opcode & 4 ) != 0 )
         {
           /* XXX: UNDOCUMENTED!  Only perform cut-in test when both points */
    @@ -5831,16 +5625,16 @@
               cvt_dist = org_dist;
           }
     
    -      distance = exc->func_round( exc, cvt_dist, exc->opcode & 3 );
    +      distance = exc->func_round( exc, cvt_dist, compensation );
         }
         else
    -      distance = Round_None( exc, cvt_dist, exc->opcode & 3 );
    +      distance = Round_None( exc, cvt_dist, compensation );
     
         /* minimum distance test */
     
         if ( ( exc->opcode & 8 ) != 0 )
         {
    -      FT_F26Dot6  minimum_distance    = exc->GS.minimum_distance;
    +      FT_F26Dot6  minimum_distance = exc->GS.minimum_distance;
     
     
           if ( org_dist >= 0 )
    @@ -5862,11 +5656,10 @@
     
       Fail:
         exc->GS.rp1 = exc->GS.rp0;
    +    exc->GS.rp2 = point;
     
         if ( ( exc->opcode & 16 ) != 0 )
           exc->GS.rp0 = point;
    -
    -    exc->GS.rp2 = point;
       }
     
     
    @@ -5877,25 +5670,33 @@
        * Stack:        uint32 uint32... -->
        */
       static void
    -  Ins_ALIGNRP( TT_ExecContext  exc )
    +  Ins_ALIGNRP( TT_ExecContext  exc,
    +               FT_Long*        args )
       {
    +    FT_Long     loop = exc->GS.loop;
         FT_UShort   point;
         FT_F26Dot6  distance;
     
     
    -    if ( exc->top < exc->GS.loop                  ||
    -         BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
    +    if ( exc->new_top < loop )
    +    {
    +      if ( exc->pedantic_hinting )
    +        exc->error = FT_THROW( Too_Few_Arguments );
    +      goto Fail;
    +    }
    +
    +    exc->new_top -= loop;
    +
    +    if ( BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
         {
           if ( exc->pedantic_hinting )
             exc->error = FT_THROW( Invalid_Reference );
           goto Fail;
         }
     
    -    while ( exc->GS.loop > 0 )
    +    while ( loop-- )
         {
    -      exc->args--;
    -
    -      point = (FT_UShort)exc->stack[exc->args];
    +      point = (FT_UShort)*(--args);
     
           if ( BOUNDS( point, exc->zp1.n_points ) )
           {
    @@ -5912,13 +5713,10 @@
     
             exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) );
           }
    -
    -      exc->GS.loop--;
         }
     
       Fail:
         exc->GS.loop = 1;
    -    exc->new_top = exc->args;
       }
     
     
    @@ -6060,15 +5858,26 @@
       /* SOMETIMES, DUMBER CODE IS BETTER CODE */
     
       static void
    -  Ins_IP( TT_ExecContext  exc )
    +  Ins_IP( TT_ExecContext  exc,
    +          FT_Long*        args )
       {
    +    FT_Long     loop = exc->GS.loop;
         FT_F26Dot6  old_range, cur_range;
         FT_Vector*  orus_base;
         FT_Vector*  cur_base;
         FT_Int      twilight;
     
     
    -    if ( exc->top < exc->GS.loop )
    +    if ( exc->new_top < loop )
    +    {
    +      if ( exc->pedantic_hinting )
    +        exc->error = FT_THROW( Too_Few_Arguments );
    +      goto Fail;
    +    }
    +
    +    exc->new_top -= loop;
    +
    +    if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) )
         {
           if ( exc->pedantic_hinting )
             exc->error = FT_THROW( Invalid_Reference );
    @@ -6084,13 +5893,6 @@
                      exc->GS.gep1 == 0 ||
                      exc->GS.gep2 == 0 );
     
    -    if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) )
    -    {
    -      if ( exc->pedantic_hinting )
    -        exc->error = FT_THROW( Invalid_Reference );
    -      goto Fail;
    -    }
    -
         if ( twilight )
           orus_base = &exc->zp0.org[exc->GS.rp1];
         else
    @@ -6102,8 +5904,7 @@
         /*      fonts out there (e.g. [aeu]grave in monotype.ttf)   */
         /*      calling IP[] with bad values of rp[12].             */
         /*      Do something sane when this odd thing happens.      */
    -    if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ||
    -         BOUNDS( exc->GS.rp2, exc->zp1.n_points ) )
    +    if ( BOUNDS( exc->GS.rp2, exc->zp1.n_points ) )
         {
           old_range = 0;
           cur_range = 0;
    @@ -6132,9 +5933,9 @@
           cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base );
         }
     
    -    for ( ; exc->GS.loop > 0; exc->GS.loop-- )
    +    while ( loop-- )
         {
    -      FT_UInt     point = (FT_UInt)exc->stack[--exc->args];
    +      FT_UInt     point = (FT_UInt)*(--args);
           FT_F26Dot6  org_dist, cur_dist, new_dist;
     
     
    @@ -6206,7 +6007,6 @@
     
       Fail:
         exc->GS.loop = 1;
    -    exc->new_top = exc->args;
       }
     
     
    @@ -6405,17 +6205,10 @@
         /* See `ttinterp.h' for details on backward compatibility mode.  */
         /* Allow IUP until it has been called on both axes.  Immediately */
         /* return on subsequent ones.                                    */
    -    if ( SUBPIXEL_HINTING_MINIMAL    &&
    -         exc->backward_compatibility )
    -    {
    -      if ( exc->iupx_called && exc->iupy_called )
    -        return;
    -
    -      if ( exc->opcode & 1 )
    -        exc->iupx_called = TRUE;
    -      else
    -        exc->iupy_called = TRUE;
    -    }
    +    if ( exc->backward_compatibility == 0x7 )
    +      return;
    +    else if ( exc->backward_compatibility )
    +      exc->backward_compatibility |= 1 << ( exc->opcode & 1 );
     #endif
     
         /* ignore empty outlines */
    @@ -6507,30 +6300,50 @@
       Ins_DELTAP( TT_ExecContext  exc,
                   FT_Long*        args )
       {
    -    FT_ULong   nump, k;
    +    FT_Long    nump;
         FT_UShort  A;
    -    FT_ULong   C, P;
    -    FT_Long    B;
    +    FT_Long    B, P, F;
     
     
    -    P    = (FT_ULong)exc->func_cur_ppem( exc );
    -    nump = (FT_ULong)args[0];   /* some points theoretically may occur more
    -                                   than once, thus UShort isn't enough */
    +    nump = args[0];  /* signed value for convenience */
     
    -    for ( k = 1; k <= nump; k++ )
    +    if ( nump < 0 || nump > exc->new_top / 2 )
         {
    -      if ( exc->args < 2 )
    -      {
    -        if ( exc->pedantic_hinting )
    -          exc->error = FT_THROW( Too_Few_Arguments );
    -        exc->args = 0;
    -        goto Fail;
    -      }
    +      if ( exc->pedantic_hinting )
    +        exc->error = FT_THROW( Too_Few_Arguments );
     
    -      exc->args -= 2;
    +      nump = exc->new_top / 2;
    +    }
     
    -      A = (FT_UShort)exc->stack[exc->args + 1];
    -      B = exc->stack[exc->args];
    +    exc->new_top -= 2 * nump;
    +
    +    P = exc->func_cur_ppem( exc ) - exc->GS.delta_base;
    +
    +    switch ( exc->opcode )
    +    {
    +    case 0x5D:
    +      break;
    +
    +    case 0x71:
    +      P -= 16;
    +      break;
    +
    +    case 0x72:
    +      P -= 32;
    +      break;
    +    }
    +
    +    /* check applicable range of adjusted ppem */
    +    if ( P & ~0xF )         /* P < 0 || P > 15 */
    +      return;
    +
    +    P <<= 4;
    +    F   = 1L << ( 6 - exc->GS.delta_shift );
    +
    +    while ( nump-- )
    +    {
    +      A = (FT_UShort)*(--args);
    +      B = *(--args);
     
           /* XXX: Because some popular fonts contain some invalid DeltaP */
           /*      instructions, we simply ignore them when the stacked   */
    @@ -6538,41 +6351,28 @@
           /*      error.  As a delta instruction doesn't change a glyph  */
           /*      in great ways, this shouldn't be a problem.            */
     
    -      if ( !BOUNDS( A, exc->zp0.n_points ) )
    +      if ( BOUNDS( A, exc->zp0.n_points ) )
           {
    -        C = ( (FT_ULong)B & 0xF0 ) >> 4;
    -
    -        switch ( exc->opcode )
    +        if ( exc->pedantic_hinting )
             {
    -        case 0x5D:
    -          break;
    -
    -        case 0x71:
    -          C += 16;
    -          break;
    -
    -        case 0x72:
    -          C += 32;
    -          break;
    +          exc->error = FT_THROW( Invalid_Reference );
    +          return;
             }
    -
    -        C += exc->GS.delta_base;
    -
    -        if ( P == C )
    +      }
    +      else
    +      {
    +        if ( ( B & 0xF0 ) == P )
             {
    -          B = ( (FT_ULong)B & 0xF ) - 8;
    +          B = ( B & 0xF ) - 8;
               if ( B >= 0 )
                 B++;
    -          B *= 1L << ( 6 - exc->GS.delta_shift );
    -
    +          B *= F;
     
     #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -          /* See `ttinterp.h' for details on backward compatibility */
    -          /* mode.                                                  */
    -          if ( SUBPIXEL_HINTING_MINIMAL    &&
    -               exc->backward_compatibility )
    +          /* See `ttinterp.h' for details on backward compatibility mode. */
    +          if ( exc->backward_compatibility )
               {
    -            if ( !( exc->iupx_called && exc->iupy_called )              &&
    +            if ( exc->backward_compatibility != 0x7                     &&
                      ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
                        ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y )        ) )
                   exc->func_move( exc, &exc->zp0, A, B );
    @@ -6582,13 +6382,7 @@
                 exc->func_move( exc, &exc->zp0, A, B );
             }
           }
    -      else
    -        if ( exc->pedantic_hinting )
    -          exc->error = FT_THROW( Invalid_Reference );
         }
    -
    -  Fail:
    -    exc->new_top = exc->args;
       }
     
     
    @@ -6602,28 +6396,50 @@
       Ins_DELTAC( TT_ExecContext  exc,
                   FT_Long*        args )
       {
    -    FT_ULong  nump, k;
    -    FT_ULong  A, C, P;
    -    FT_Long   B;
    +    FT_Long   nump;
    +    FT_ULong  A;
    +    FT_Long   B, P, F;
     
     
    -    P    = (FT_ULong)exc->func_cur_ppem( exc );
    -    nump = (FT_ULong)args[0];
    +    nump = args[0];  /* signed value for convenience */
     
    -    for ( k = 1; k <= nump; k++ )
    +    if ( nump < 0 || nump > exc->new_top / 2 )
         {
    -      if ( exc->args < 2 )
    -      {
    -        if ( exc->pedantic_hinting )
    -          exc->error = FT_THROW( Too_Few_Arguments );
    -        exc->args = 0;
    -        goto Fail;
    -      }
    +      if ( exc->pedantic_hinting )
    +        exc->error = FT_THROW( Too_Few_Arguments );
     
    -      exc->args -= 2;
    +      nump = exc->new_top / 2;
    +    }
     
    -      A = (FT_ULong)exc->stack[exc->args + 1];
    -      B = exc->stack[exc->args];
    +    exc->new_top -= 2 * nump;
    +
    +    P = exc->func_cur_ppem( exc ) - exc->GS.delta_base;
    +
    +    switch ( exc->opcode )
    +    {
    +    case 0x73:
    +      break;
    +
    +    case 0x74:
    +      P -= 16;
    +      break;
    +
    +    case 0x75:
    +      P -= 32;
    +      break;
    +    }
    +
    +    /* check applicable range of adjusted ppem */
    +    if ( P & ~0xF )         /* P < 0 || P > 15 */
    +      return;
    +
    +    P <<= 4;
    +    F   = 1L << ( 6 - exc->GS.delta_shift );
    +
    +    while ( nump-- )
    +    {
    +      A = (FT_ULong)*(--args);
    +      B = *(--args);
     
           if ( BOUNDSL( A, exc->cvtSize ) )
           {
    @@ -6635,38 +6451,17 @@
           }
           else
           {
    -        C = ( (FT_ULong)B & 0xF0 ) >> 4;
    -
    -        switch ( exc->opcode )
    +        if ( ( B & 0xF0 ) == P )
             {
    -        case 0x73:
    -          break;
    -
    -        case 0x74:
    -          C += 16;
    -          break;
    -
    -        case 0x75:
    -          C += 32;
    -          break;
    -        }
    -
    -        C += exc->GS.delta_base;
    -
    -        if ( P == C )
    -        {
    -          B = ( (FT_ULong)B & 0xF ) - 8;
    +          B = ( B & 0xF ) - 8;
               if ( B >= 0 )
                 B++;
    -          B *= 1L << ( 6 - exc->GS.delta_shift );
    +          B *= F;
     
               exc->func_move_cvt( exc, A, B );
             }
           }
         }
    -
    -  Fail:
    -    exc->new_top = exc->args;
       }
     
     
    @@ -6736,7 +6531,7 @@
         /* Otherwise, instructions may behave weirdly and rendering results */
         /* may differ between v35 and v40 mode, e.g., in `Times New Roman   */
         /* Bold Italic'. */
    -    if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean )
    +    if ( SUBPIXEL_HINTING_MINIMAL && exc->mode != FT_RENDER_MODE_MONO )
         {
           /*********************************
            * HINTING FOR SUBPIXEL
    @@ -6753,7 +6548,7 @@
            * Selector Bit:  8
            * Return Bit(s): 15
            */
    -      if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean )
    +      if ( ( args[0] & 256 ) != 0 && exc->mode == FT_RENDER_MODE_LCD_V )
             K |= 1 << 15;
     
           /*********************************
    @@ -6774,7 +6569,7 @@
            * The only smoothing method FreeType supports unless someone sets
            * FT_LOAD_TARGET_MONO.
            */
    -      if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean )
    +      if ( ( args[0] & 2048 ) != 0 && exc->mode != FT_RENDER_MODE_MONO )
             K |= 1 << 18;
     
           /*********************************
    @@ -6786,7 +6581,10 @@
            * Grayscale rendering is what FreeType does anyway unless someone
            * sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V)
            */
    -      if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype )
    +      if ( ( args[0] & 4096 ) != 0           &&
    +           exc->mode != FT_RENDER_MODE_MONO  &&
    +           exc->mode != FT_RENDER_MODE_LCD   &&
    +           exc->mode != FT_RENDER_MODE_LCD_V )
             K |= 1 << 19;
         }
     #endif
    @@ -6833,6 +6631,8 @@
           for ( i = 0; i < num_axes; i++ )
             args[i] = 0;
         }
    +
    +    exc->new_top += num_axes;
       }
     
     
    @@ -6883,7 +6683,6 @@
     
             Ins_Goto_CodeRange( exc, def->range, def->start );
     
    -        exc->step_ins = FALSE;
             return;
           }
         }
    @@ -6928,96 +6727,22 @@
       TT_RunIns( void*  exec )
       {
         TT_ExecContext  exc = (TT_ExecContext)exec;
    +    FT_ULong        ins_counter = 0;
     
    -    FT_ULong   ins_counter = 0;  /* executed instructions counter */
    -    FT_ULong   num_twilight_points;
    -    FT_UShort  i;
    -
    -
    -    /* We restrict the number of twilight points to a reasonable,     */
    -    /* heuristic value to avoid slow execution of malformed bytecode. */
    -    num_twilight_points = FT_MAX( 30,
    -                                  2 * ( exc->pts.n_points + exc->cvtSize ) );
    -    if ( exc->twilight.n_points > num_twilight_points )
    -    {
    -      if ( num_twilight_points > 0xFFFFU )
    -        num_twilight_points = 0xFFFFU;
    -
    -      FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" ));
    -      FT_TRACE5(( "           from %d to the more reasonable value %ld\n",
    -                  exc->twilight.n_points,
    -                  num_twilight_points ));
    -      exc->twilight.n_points = (FT_UShort)num_twilight_points;
    -    }
    -
    -    /* Set up loop detectors.  We restrict the number of LOOPCALL loops */
    -    /* and the number of JMPR, JROT, and JROF calls with a negative     */
    -    /* argument to values that depend on various parameters like the    */
    -    /* size of the CVT table or the number of points in the current     */
    -    /* glyph (if applicable).                                           */
    -    /*                                                                  */
    -    /* The idea is that in real-world bytecode you either iterate over  */
    -    /* all CVT entries (in the `prep' table), or over all points (or    */
    -    /* contours, in the `glyf' table) of a glyph, and such iterations   */
    -    /* don't happen very often.                                         */
    -    exc->loopcall_counter = 0;
    -    exc->neg_jump_counter = 0;
    -
    -    /* The maximum values are heuristic. */
    -    if ( exc->pts.n_points )
    -      exc->loopcall_counter_max = FT_MAX( 50,
    -                                          10 * exc->pts.n_points ) +
    -                                  FT_MAX( 50,
    -                                          exc->cvtSize / 10 );
    -    else
    -      exc->loopcall_counter_max = 300 + 22 * exc->cvtSize;
    -
    -    /* as a protection against an unreasonable number of CVT entries  */
    -    /* we assume at most 100 control values per glyph for the counter */
    -    if ( exc->loopcall_counter_max >
    -         100 * (FT_ULong)exc->face->root.num_glyphs )
    -      exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs;
    -
    -    FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
    -                " to %ld\n", exc->loopcall_counter_max ));
    -
    -    exc->neg_jump_counter_max = exc->loopcall_counter_max;
    -    FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps"
    -                " to %ld\n", exc->neg_jump_counter_max ));
    -
    -    /* set PPEM and CVT functions */
    -    exc->tt_metrics.ratio = 0;
    -    if ( exc->metrics.x_ppem != exc->metrics.y_ppem )
    -    {
    -      /* non-square pixels, use the stretched routines */
    -      exc->func_cur_ppem  = Current_Ppem_Stretched;
    -      exc->func_read_cvt  = Read_CVT_Stretched;
    -      exc->func_write_cvt = Write_CVT_Stretched;
    -      exc->func_move_cvt  = Move_CVT_Stretched;
    -    }
    -    else
    -    {
    -      /* square pixels, use normal routines */
    -      exc->func_cur_ppem  = Current_Ppem;
    -      exc->func_read_cvt  = Read_CVT;
    -      exc->func_write_cvt = Write_CVT;
    -      exc->func_move_cvt  = Move_CVT;
    -    }
    -
    -    exc->iniRange    = exc->curRange;
    -
    -    Compute_Funcs( exc );
    -    Compute_Round( exc, (FT_Byte)exc->GS.round_state );
    -
    -    /* These flags cancel execution of some opcodes after IUP is called */
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    -    exc->iupx_called = FALSE;
    -    exc->iupy_called = FALSE;
    -#endif
     
         do
         {
    +      /* increment instruction counter and check if we didn't */
    +      /* run this program for too long (e.g. infinite loops). */
    +      if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
    +      {
    +        exc->error = FT_THROW( Execution_Too_Long );
    +        goto LErrorLabel_;
    +      }
    +
    +      exc->error  = FT_Err_Ok;
           exc->opcode = exc->code[exc->IP];
    +      exc->length = 1;
     
     #ifdef FT_DEBUG_LEVEL_TRACE
           if ( ft_trace_levels[trace_ttinterp] >= 6 )
    @@ -7041,17 +6766,6 @@
           }
     #endif /* FT_DEBUG_LEVEL_TRACE */
     
    -      if ( ( exc->length = opcode_length[exc->opcode] ) < 0 )
    -      {
    -        if ( exc->IP + 1 >= exc->codeSize )
    -          goto LErrorCodeOverflow_;
    -
    -        exc->length = 2 - exc->length * exc->code[exc->IP + 1];
    -      }
    -
    -      if ( exc->IP + exc->length > exc->codeSize )
    -        goto LErrorCodeOverflow_;
    -
           /* First, let's check for empty stack and overflow */
           exc->args = exc->top - ( Pop_Push_Count[exc->opcode] >> 4 );
     
    @@ -7059,6 +6773,9 @@
           /* One can also interpret it as the index of the last argument.    */
           if ( exc->args < 0 )
           {
    +        FT_UShort  i;
    +
    +
             if ( exc->pedantic_hinting )
             {
               exc->error = FT_THROW( Too_Few_Arguments );
    @@ -7071,21 +6788,7 @@
             exc->args = 0;
           }
     
    -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    -      if ( exc->opcode == 0x91 )
    -      {
    -        /* this is very special: GETVARIATION returns */
    -        /* a variable number of arguments             */
    -
    -        /* it is the job of the application to `activate' GX handling, */
    -        /* that is, calling any of the GX API functions on the current */
    -        /* font to select a variation instance                         */
    -        if ( exc->face->blend )
    -          exc->new_top = exc->args + exc->face->blend->num_axis;
    -      }
    -      else
    -#endif
    -        exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
    +      exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
     
           /* `new_top' is the new top of the stack, after the instruction's */
           /* execution.  `top' will be set to `new_top' after the `switch'  */
    @@ -7096,9 +6799,6 @@
             goto LErrorLabel_;
           }
     
    -      exc->step_ins = TRUE;
    -      exc->error    = FT_Err_Ok;
    -
           {
             FT_Long*  args   = exc->stack + exc->args;
             FT_Byte   opcode = exc->opcode;
    @@ -7281,7 +6981,7 @@
     
             case 0x32:  /* SHP */
             case 0x33:  /* SHP */
    -          Ins_SHP( exc );
    +          Ins_SHP( exc, args );
               break;
     
             case 0x34:  /* SHC */
    @@ -7299,7 +6999,7 @@
               break;
     
             case 0x39:  /* IP    */
    -          Ins_IP( exc );
    +          Ins_IP( exc, args );
               break;
     
             case 0x3A:  /* MSIRP */
    @@ -7308,7 +7008,7 @@
               break;
     
             case 0x3C:  /* AlignRP */
    -          Ins_ALIGNRP( exc );
    +          Ins_ALIGNRP( exc, args );
               break;
     
             case 0x3D:  /* RTDG */
    @@ -7544,7 +7244,7 @@
               break;
     
             case 0x80:  /* FLIPPT */
    -          Ins_FLIPPT( exc );
    +          Ins_FLIPPT( exc, args );
               break;
     
             case 0x81:  /* FLIPRGON */
    @@ -7642,13 +7342,13 @@
           {
             switch ( exc->error )
             {
    -          /* looking for redefined instructions */
             case FT_ERR( Invalid_Opcode ):
               {
                 TT_DefRecord*  def   = exc->IDefs;
                 TT_DefRecord*  limit = FT_OFFSET( def, exc->numIDefs );
     
     
    +            /* looking for redefined instructions */
                 for ( ; def < limit; def++ )
                 {
                   if ( def->active && exc->opcode == (FT_Byte)def->opc )
    @@ -7678,37 +7378,15 @@
                   }
                 }
               }
    -
    -          exc->error = FT_THROW( Invalid_Opcode );
    -          goto LErrorLabel_;
    -
    -#if 0
    -          break;   /* Unreachable code warning suppression.             */
    -                   /* Leave to remind in case a later change the editor */
    -                   /* to consider break;                                */
    -#endif
    +          FALL_THROUGH;
     
             default:
               goto LErrorLabel_;
    -
    -#if 0
    -        break;
    -#endif
             }
           }
     
           exc->top = exc->new_top;
    -
    -      if ( exc->step_ins )
    -        exc->IP += exc->length;
    -
    -      /* increment instruction counter and check if we didn't */
    -      /* run this program for too long (e.g. infinite loops). */
    -      if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
    -      {
    -        exc->error = FT_THROW( Execution_Too_Long );
    -        goto LErrorLabel_;
    -      }
    +      exc->IP += exc->length;
     
         LSuiteLabel_:
           if ( exc->IP >= exc->codeSize )
    @@ -7724,15 +7402,12 @@
         } while ( !exc->instruction_trap );
     
       LNo_Error_:
    -    FT_TRACE4(( "  %ld instruction%s executed\n",
    +    FT_TRACE4(( "  %lu instruction%s executed\n",
                     ins_counter,
                     ins_counter == 1 ? "" : "s" ));
     
         return FT_Err_Ok;
     
    -  LErrorCodeOverflow_:
    -    exc->error = FT_THROW( Code_Overflow );
    -
       LErrorLabel_:
         if ( exc->error && !exc->instruction_trap )
           FT_TRACE1(( "  The interpreter returned error 0x%x\n", exc->error ));
    @@ -7740,6 +7415,126 @@
         return exc->error;
       }
     
    +
    +  /**************************************************************************
    +   *
    +   * @Function:
    +   *   TT_Run_Context
    +   *
    +   * @Description:
    +   *   Executes one or more instructions in the execution context.
    +   *
    +   * @Input:
    +   *   exec ::
    +   *     A handle to the target execution context.
    +   *
    +   * @Return:
    +   *   TrueType error code.  0 means success.
    +   */
    +  FT_LOCAL_DEF( FT_Error )
    +  TT_Run_Context( TT_ExecContext  exec,
    +                  TT_Size         size )
    +  {
    +    FT_ULong   num_twilight_points;
    +
    +
    +    exec->zp0 = exec->pts;
    +    exec->zp1 = exec->pts;
    +    exec->zp2 = exec->pts;
    +
    +    /* We restrict the number of twilight points to a reasonable,     */
    +    /* heuristic value to avoid slow execution of malformed bytecode. */
    +    /* The selected value is large enough to support fonts hinted     */
    +    /* with `ttfautohint`, which uses twilight points to store        */
    +    /* vertical coordinates of (auto-hinter) segments.                */
    +    num_twilight_points = FT_MAX( 30,
    +                                  2 * ( exec->pts.n_points + exec->cvtSize ) );
    +    if ( exec->twilight.n_points > num_twilight_points )
    +    {
    +      if ( num_twilight_points > 0xFFFFU )
    +        num_twilight_points = 0xFFFFU;
    +
    +      FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" ));
    +      FT_TRACE5(( "           from %d to the more reasonable value %lu\n",
    +                  exec->twilight.n_points,
    +                  num_twilight_points ));
    +      exec->twilight.n_points = (FT_UShort)num_twilight_points;
    +    }
    +
    +    /* Set up loop detectors.  We restrict the number of LOOPCALL loops */
    +    /* and the number of JMPR, JROT, and JROF calls with a negative     */
    +    /* argument to values that depend on various parameters like the    */
    +    /* size of the CVT table or the number of points in the current     */
    +    /* glyph (if applicable).                                           */
    +    /*                                                                  */
    +    /* The idea is that in real-world bytecode you either iterate over  */
    +    /* all CVT entries (in the `prep' table), or over all points (or    */
    +    /* contours, in the `glyf' table) of a glyph, and such iterations   */
    +    /* don't happen very often.                                         */
    +    exec->loopcall_counter = 0;
    +    exec->neg_jump_counter = 0;
    +
    +    /* The maximum values are heuristic. */
    +    if ( exec->pts.n_points )
    +      exec->loopcall_counter_max = FT_MAX( 50,
    +                                           10 * exec->pts.n_points ) +
    +                                   FT_MAX( 50,
    +                                           exec->cvtSize / 10 );
    +    else
    +      exec->loopcall_counter_max = 300 + 22 * exec->cvtSize;
    +
    +    /* as a protection against an unreasonable number of CVT entries  */
    +    /* we assume at most 100 control values per glyph for the counter */
    +    if ( exec->loopcall_counter_max >
    +         100 * (FT_ULong)exec->face->root.num_glyphs )
    +      exec->loopcall_counter_max = 100 * (FT_ULong)exec->face->root.num_glyphs;
    +
    +    FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
    +                " to %lu\n", exec->loopcall_counter_max ));
    +
    +    exec->neg_jump_counter_max = exec->loopcall_counter_max;
    +    FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps"
    +                " to %lu\n", exec->neg_jump_counter_max ));
    +
    +    /* set PPEM and CVT functions */
    +    if ( exec->metrics.x_ppem != exec->metrics.y_ppem )
    +    {
    +      /* non-square pixels, use the stretched routines */
    +      exec->func_cur_ppem  = Current_Ppem_Stretched;
    +      exec->func_read_cvt  = Read_CVT_Stretched;
    +      exec->func_write_cvt = Write_CVT_Stretched;
    +      exec->func_move_cvt  = Move_CVT_Stretched;
    +    }
    +    else
    +    {
    +      /* square pixels, use normal routines */
    +      exec->func_cur_ppem  = Current_Ppem;
    +      exec->func_read_cvt  = Read_CVT;
    +      exec->func_write_cvt = Write_CVT;
    +      exec->func_move_cvt  = Move_CVT;
    +    }
    +
    +    /* reset graphics state */
    +    exec->GS         = size->GS;
    +    exec->func_round = (TT_Round_Func)Round_To_Grid;
    +    Compute_Funcs( exec );
    +
    +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
    +    /* Reset IUP tracking bits in the backward compatibility mode. */
    +    /* See `ttinterp.h' for details.                               */
    +    exec->backward_compatibility &= ~0x3;
    +#endif
    +
    +    /* some glyphs leave something on the stack, */
    +    /* so we clean it before a new execution.    */
    +    exec->top     = 0;
    +    exec->callTop = 0;
    +
    +    exec->instruction_trap = FALSE;
    +
    +    return exec->interpreter( exec );
    +  }
    +
     #else /* !TT_USE_BYTECODE_INTERPRETER */
     
       /* ANSI C doesn't like empty source files */
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
    index 4f1a9bbc679..5cdc8f59f1a 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType bytecode interpreter (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -39,6 +39,60 @@ FT_BEGIN_HEADER
     #define TT_Round_Super_45        7
     
     
    +  /**************************************************************************
    +   *
    +   * EXECUTION SUBTABLES
    +   *
    +   * These sub-tables relate to instruction execution.
    +   *
    +   */
    +
    +
    +#define TT_MAX_CODE_RANGES  3
    +
    +
    +  /**************************************************************************
    +   *
    +   * There can only be 3 active code ranges at once:
    +   *   - the Font Program
    +   *   - the CVT Program
    +   *   - a glyph's instructions set
    +   */
    +  typedef enum  TT_CodeRange_Tag_
    +  {
    +    tt_coderange_none = 0,
    +    tt_coderange_font,
    +    tt_coderange_cvt,
    +    tt_coderange_glyph
    +
    +  } TT_CodeRange_Tag;
    +
    +
    +  typedef struct  TT_CodeRange_
    +  {
    +    FT_Byte*  base;
    +    FT_Long   size;
    +
    +  } TT_CodeRange;
    +
    +  typedef TT_CodeRange  TT_CodeRangeTable[TT_MAX_CODE_RANGES];
    +
    +
    +  /**************************************************************************
    +   *
    +   * Defines a function/instruction definition record.
    +   */
    +  typedef struct  TT_DefRecord_
    +  {
    +    FT_Int    range;          /* in which code range is it located?     */
    +    FT_Long   start;          /* where does it start?                   */
    +    FT_Long   end;            /* where does it end?                     */
    +    FT_UInt   opc;            /* function #, or instruction code        */
    +    FT_Bool   active;         /* is it active?                          */
    +
    +  } TT_DefRecord, *TT_DefArray;
    +
    +
       /**************************************************************************
        *
        * Function types used by the interpreter, depending on various modes
    @@ -51,7 +105,7 @@ FT_BEGIN_HEADER
       typedef FT_F26Dot6
       (*TT_Round_Func)( TT_ExecContext  exc,
                         FT_F26Dot6      distance,
    -                    FT_Int          color );
    +                    FT_F26Dot6      compensation );
     
       /* Point displacement along the freedom vector routine */
       typedef void
    @@ -111,12 +165,13 @@ FT_BEGIN_HEADER
         TT_Face            face;       /* ! */
         TT_Size            size;       /* ! */
         FT_Memory          memory;
    +    TT_Interpreter     interpreter;
     
         /* instructions state */
     
         FT_Error           error;      /* last execution error */
     
    -    FT_Long            top;        /* @ top of exec. stack */
    +    FT_Long            top;        /* @! top of exec. stack */
     
         FT_Long            stackSize;  /* ! size of exec. stack */
         FT_Long*           stack;      /* ! current exec. stack */
    @@ -142,11 +197,9 @@ FT_BEGIN_HEADER
         FT_Long            IP;        /* current instruction pointer */
         FT_Long            codeSize;  /* size of current range       */
     
    -    FT_Byte            opcode;    /* current opcode              */
    -    FT_Int             length;    /* length of current opcode    */
    +    FT_Byte            opcode;    /* current opcode             */
    +    FT_Int             length;    /* opcode length or increment */
     
    -    FT_Bool            step_ins;  /* true if the interpreter must */
    -                                  /* increment IP after ins. exec */
         FT_ULong           cvtSize;   /* ! */
         FT_Long*           cvt;       /* ! */
         FT_ULong           glyfCvtSize;
    @@ -166,9 +219,9 @@ FT_BEGIN_HEADER
         FT_UInt            maxFunc;   /* ! maximum function index    */
         FT_UInt            maxIns;    /* ! maximum instruction index */
     
    -    FT_Int             callTop,    /* @ top of call stack during execution */
    -                       callSize;   /*   size of call stack                 */
    -    TT_CallStack       callStack;  /*   call stack                         */
    +    FT_Int             callTop,    /* @! top of call stack during execution */
    +                       callSize;   /*    size of call stack                 */
    +    TT_CallStack       callStack;  /*    call stack                         */
     
         FT_UShort          maxPoints;    /* capacity of this context's `pts' */
         FT_Short           maxContours;  /* record, expressed in points and  */
    @@ -189,16 +242,14 @@ FT_BEGIN_HEADER
         FT_Bool            instruction_trap; /* ! If `True', the interpreter   */
                                              /*   exits after each instruction */
     
    -    TT_GraphicsState   default_GS;       /* graphics state resulting from   */
    -                                         /* the prep program                */
         FT_Bool            is_composite;     /* true if the glyph is composite  */
         FT_Bool            pedantic_hinting; /* true if pedantic interpretation */
     
         /* latest interpreter additions */
     
    -    FT_Long            F_dot_P;    /* dot product of freedom and projection */
    -                                   /* vectors                               */
    -    TT_Round_Func      func_round; /* current rounding function             */
    +    TT_Round_Func      func_round;     /* current rounding function   */
    +
    +    FT_Vector          moveVector;     /* "projected" freedom vector  */
     
         TT_Project_Func    func_project,   /* current projection function */
                            func_dualproj,  /* current dual proj. function */
    @@ -327,34 +378,13 @@ FT_BEGIN_HEADER
          *
          */
     
    -    /* Using v40 implies subpixel hinting, unless FT_RENDER_MODE_MONO has been
    -     * requested.  Used to detect interpreter */
    -    /* version switches.  `_lean' to differentiate from the Infinality */
    -    /* `subpixel_hinting', which is managed differently.               */
    -    FT_Bool            subpixel_hinting_lean;
    +    /* Activate backward compatibility (bit 2) and track IUP (bits 0-1). */
    +    /* If this is zero, it means that the interpreter is either in v35   */
    +    /* or in native ClearType mode.                                      */
    +    FT_Int             backward_compatibility;
     
    -    /* Long side of a LCD subpixel is vertical (e.g., screen is rotated). */
    -    /* `_lean' to differentiate from the Infinality `vertical_lcd', which */
    -    /* is managed differently.                                            */
    -    FT_Bool            vertical_lcd_lean;
    +    FT_Render_Mode     mode;  /* target render mode */
     
    -    /* Default to backward compatibility mode in v40 interpreter.  If   */
    -    /* this is false, it implies the interpreter is in v35 or in native */
    -    /* ClearType mode.                                                  */
    -    FT_Bool            backward_compatibility;
    -
    -    /* Useful for detecting and denying post-IUP trickery that is usually */
    -    /* used to fix pixel patterns (`superhinting').                       */
    -    FT_Bool            iupx_called;
    -    FT_Bool            iupy_called;
    -
    -    /* ClearType hinting and grayscale rendering, as used by Universal */
    -    /* Windows Platform apps (Windows 8 and above).  Like the standard */
    -    /* colorful ClearType mode, it utilizes a vastly increased virtual */
    -    /* resolution on the x axis.  Different from bi-level hinting and  */
    -    /* grayscale rendering, the old mode from Win9x days that roughly  */
    -    /* adheres to the physical pixel grid on both axes.                */
    -    FT_Bool            grayscale_cleartype;
     #endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
     
         /* We maintain two counters (in addition to the instruction counter) */
    @@ -371,22 +401,15 @@ FT_BEGIN_HEADER
       extern const TT_GraphicsState  tt_default_graphics_state;
     
     
    -#ifdef TT_USE_BYTECODE_INTERPRETER
    -  FT_LOCAL( void )
    -  TT_Goto_CodeRange( TT_ExecContext  exec,
    -                     FT_Int          range,
    -                     FT_Long         IP );
    -
       FT_LOCAL( void )
       TT_Set_CodeRange( TT_ExecContext  exec,
                         FT_Int          range,
    -                    void*           base,
    +                    FT_Byte*        base,
                         FT_Long         length );
     
       FT_LOCAL( void )
       TT_Clear_CodeRange( TT_ExecContext  exec,
                           FT_Int          range );
    -#endif /* TT_USE_BYTECODE_INTERPRETER */
     
     
       /**************************************************************************
    @@ -413,22 +436,21 @@ FT_BEGIN_HEADER
       TT_New_Context( TT_Driver  driver );
     
     
    -#ifdef TT_USE_BYTECODE_INTERPRETER
       FT_LOCAL( void )
       TT_Done_Context( TT_ExecContext  exec );
     
    -  FT_LOCAL( FT_Error )
    +  FT_LOCAL( void )
       TT_Load_Context( TT_ExecContext  exec,
                        TT_Face         face,
                        TT_Size         size );
     
       FT_LOCAL( void )
       TT_Save_Context( TT_ExecContext  exec,
    -                   TT_Size         ins );
    +                   TT_Size         size );
     
       FT_LOCAL( FT_Error )
    -  TT_Run_Context( TT_ExecContext  exec );
    -#endif /* TT_USE_BYTECODE_INTERPRETER */
    +  TT_Run_Context( TT_ExecContext  exec,
    +                  TT_Size         size );
     
     
       /**************************************************************************
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
    index d0ac3181204..2aedbd842c1 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c
    @@ -4,7 +4,7 @@
      *
      *   Objects manager (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -67,23 +67,13 @@
        *     A pointer to the target glyph zone.
        */
       FT_LOCAL_DEF( void )
    -  tt_glyphzone_done( TT_GlyphZone  zone )
    +  tt_glyphzone_done( FT_Memory     memory,
    +                     TT_GlyphZone  zone )
       {
    -    FT_Memory  memory = zone->memory;
    +    FT_FREE( zone->org );
     
    -
    -    if ( memory )
    -    {
    -      FT_FREE( zone->contours );
    -      FT_FREE( zone->tags );
    -      FT_FREE( zone->cur );
    -      FT_FREE( zone->org );
    -      FT_FREE( zone->orus );
    -
    -      zone->max_points   = zone->n_points   = 0;
    -      zone->max_contours = zone->n_contours = 0;
    -      zone->memory       = NULL;
    -    }
    +    zone->n_points   = 0;
    +    zone->n_contours = 0;
       }
     
     
    @@ -119,23 +109,22 @@
                         TT_GlyphZone  zone )
       {
         FT_Error  error;
    +    FT_Long   size = 3 * maxPoints * sizeof ( FT_Vector ) +
    +                       maxContours * sizeof ( FT_UShort ) +
    +                         maxPoints * sizeof ( FT_Byte );
     
     
    -    FT_ZERO( zone );
    -    zone->memory = memory;
    -
    -    if ( FT_NEW_ARRAY( zone->org,      maxPoints   ) ||
    -         FT_NEW_ARRAY( zone->cur,      maxPoints   ) ||
    -         FT_NEW_ARRAY( zone->orus,     maxPoints   ) ||
    -         FT_NEW_ARRAY( zone->tags,     maxPoints   ) ||
    -         FT_NEW_ARRAY( zone->contours, maxContours ) )
    +    if ( !FT_ALLOC( zone->org, size ) )
         {
    -      tt_glyphzone_done( zone );
    -    }
    -    else
    -    {
    -      zone->max_points   = maxPoints;
    -      zone->max_contours = maxContours;
    +      zone->n_points   = maxPoints;
    +      zone->n_contours = maxContours;
    +
    +      zone->cur      =               zone->org      + maxPoints;
    +      zone->orus     =               zone->cur      + maxPoints;
    +      zone->contours = (FT_UShort*)( zone->orus     + maxPoints );
    +      zone->tags     =   (FT_Byte*)( zone->contours + maxContours );
    +
    +      zone->first_point = 0;
         }
     
         return error;
    @@ -488,8 +477,7 @@
         int        j, k;
     
     
    -    FT_MEM_SET( num_matched_ids, 0,
    -                sizeof ( int ) * TRICK_SFNT_IDS_NUM_FACES );
    +    FT_ARRAY_ZERO( num_matched_ids, TRICK_SFNT_IDS_NUM_FACES );
         has_cvt  = FALSE;
         has_fpgm = FALSE;
         has_prep = FALSE;
    @@ -787,7 +775,7 @@
           FT_UInt  instance_index = (FT_UInt)face_index >> 16;
     
     
    -      if ( FT_HAS_MULTIPLE_MASTERS( ttface ) )
    +      if ( instance_index && FT_HAS_MULTIPLE_MASTERS( ttface ) )
           {
             error = FT_Set_Named_Instance( ttface, instance_index );
             if ( error )
    @@ -885,59 +873,18 @@
        *   size ::
        *     A handle to the size object.
        *
    -   *   pedantic ::
    -   *     Set if bytecode execution should be pedantic.
    -   *
        * @Return:
        *   FreeType error code.  0 means success.
        */
       FT_LOCAL_DEF( FT_Error )
    -  tt_size_run_fpgm( TT_Size  size,
    -                    FT_Bool  pedantic )
    +  tt_size_run_fpgm( TT_Size  size )
       {
         TT_Face         face = (TT_Face)size->root.face;
    -    TT_ExecContext  exec;
    +    TT_ExecContext  exec = size->context;
         FT_Error        error;
     
     
    -    exec = size->context;
    -
    -    error = TT_Load_Context( exec, face, size );
    -    if ( error )
    -      return error;
    -
    -    exec->callTop = 0;
    -    exec->top     = 0;
    -
    -    exec->period    = 64;
    -    exec->phase     = 0;
    -    exec->threshold = 0;
    -
    -    exec->instruction_trap = FALSE;
    -    exec->F_dot_P          = 0x4000L;
    -
    -    exec->pedantic_hinting = pedantic;
    -
    -    {
    -      FT_Size_Metrics*  size_metrics = &exec->metrics;
    -      TT_Size_Metrics*  tt_metrics   = &exec->tt_metrics;
    -
    -
    -      size_metrics->x_ppem   = 0;
    -      size_metrics->y_ppem   = 0;
    -      size_metrics->x_scale  = 0;
    -      size_metrics->y_scale  = 0;
    -
    -      tt_metrics->ppem  = 0;
    -      tt_metrics->scale = 0;
    -      tt_metrics->ratio = 0x10000L;
    -    }
    -
    -    /* allow font program execution */
    -    TT_Set_CodeRange( exec,
    -                      tt_coderange_font,
    -                      face->font_program,
    -                      (FT_Long)face->font_program_size );
    +    TT_Load_Context( exec, face, size );
     
         /* disable CVT and glyph programs coderange */
         TT_Clear_CodeRange( exec, tt_coderange_cvt );
    @@ -945,15 +892,19 @@
     
         if ( face->font_program_size > 0 )
         {
    -      TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
    +      /* allow font program execution */
    +      TT_Set_CodeRange( exec,
    +                        tt_coderange_font,
    +                        face->font_program,
    +                        (FT_Long)face->font_program_size );
    +
    +      exec->pts.n_points   = 0;
    +      exec->pts.n_contours = 0;
     
           FT_TRACE4(( "Executing `fpgm' table.\n" ));
    -      error = face->interpreter( exec );
    -#ifdef FT_DEBUG_LEVEL_TRACE
    -      if ( error )
    -        FT_TRACE4(( "  interpretation failed with error code 0x%x\n",
    -                    error ));
    -#endif
    +      error = TT_Run_Context( exec, size );
    +      FT_TRACE4(( error ? "  failed (error code 0x%x)\n" : "",
    +                  error ));
         }
         else
           error = FT_Err_Ok;
    @@ -979,212 +930,146 @@
        *   size ::
        *     A handle to the size object.
        *
    -   *   pedantic ::
    -   *     Set if bytecode execution should be pedantic.
    -   *
        * @Return:
        *   FreeType error code.  0 means success.
        */
       FT_LOCAL_DEF( FT_Error )
    -  tt_size_run_prep( TT_Size  size,
    -                    FT_Bool  pedantic )
    +  tt_size_run_prep( TT_Size  size )
       {
         TT_Face         face = (TT_Face)size->root.face;
    -    TT_ExecContext  exec;
    +    TT_ExecContext  exec = size->context;
         FT_Error        error;
         FT_UInt         i;
     
     
    +    /* set default GS, twilight points, and storage */
    +    /* before CV program can modify them.           */
    +    size->GS = tt_default_graphics_state;
    +
    +    /* all twilight points are originally zero */
    +    FT_ARRAY_ZERO( size->twilight.org, size->twilight.n_points );
    +    FT_ARRAY_ZERO( size->twilight.cur, size->twilight.n_points );
    +
    +    TT_Load_Context( exec, face, size );
    +
    +    /* clear storage area */
    +    FT_ARRAY_ZERO( exec->storage, exec->storeSize );
    +
         /* Scale the cvt values to the new ppem.            */
         /* By default, we use the y ppem value for scaling. */
         FT_TRACE6(( "CVT values:\n" ));
    -    for ( i = 0; i < size->cvt_size; i++ )
    +    for ( i = 0; i < exec->cvtSize; i++ )
         {
           /* Unscaled CVT values are already stored in 26.6 format.            */
           /* Note that this scaling operation is very sensitive to rounding;   */
           /* the integer division by 64 must be applied to the first argument. */
    -      size->cvt[i] = FT_MulFix( face->cvt[i] / 64, size->ttmetrics.scale );
    -      FT_TRACE6(( "  %3d: %f (%f)\n",
    -                  i, (double)face->cvt[i] / 64, (double)size->cvt[i] / 64 ));
    +      exec->cvt[i] = FT_MulFix( face->cvt[i] / 64, size->ttmetrics.scale );
    +      FT_TRACE6(( "  %3u: %f (%f)\n",
    +                  i, (double)face->cvt[i] / 64, (double)exec->cvt[i] / 64 ));
         }
         FT_TRACE6(( "\n" ));
     
    -    exec = size->context;
    -
    -    error = TT_Load_Context( exec, face, size );
    -    if ( error )
    -      return error;
    -
    -    exec->callTop = 0;
    -    exec->top     = 0;
    -
    -    exec->instruction_trap = FALSE;
    -
    -    exec->pedantic_hinting = pedantic;
    -
    -    TT_Set_CodeRange( exec,
    -                      tt_coderange_cvt,
    -                      face->cvt_program,
    -                      (FT_Long)face->cvt_program_size );
    -
         TT_Clear_CodeRange( exec, tt_coderange_glyph );
     
         if ( face->cvt_program_size > 0 )
         {
    -      TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
    +      /* allow CV program execution */
    +      TT_Set_CodeRange( exec,
    +                        tt_coderange_cvt,
    +                        face->cvt_program,
    +                        (FT_Long)face->cvt_program_size );
    +
    +      exec->pts.n_points   = 0;
    +      exec->pts.n_contours = 0;
     
           FT_TRACE4(( "Executing `prep' table.\n" ));
    -      error = face->interpreter( exec );
    -#ifdef FT_DEBUG_LEVEL_TRACE
    -      if ( error )
    -        FT_TRACE4(( "  interpretation failed with error code 0x%x\n",
    -                    error ));
    -#endif
    +      error = TT_Run_Context( exec, size );
    +      FT_TRACE4(( error ? "  failed (error code 0x%x)\n" : "",
    +                  error ));
         }
         else
           error = FT_Err_Ok;
     
         size->cvt_ready = error;
     
    -    /* UNDOCUMENTED!  The MS rasterizer doesn't allow the following */
    -    /* graphics state variables to be modified by the CVT program.  */
    -
    -    exec->GS.dualVector.x = 0x4000;
    -    exec->GS.dualVector.y = 0;
    -    exec->GS.projVector.x = 0x4000;
    -    exec->GS.projVector.y = 0x0;
    -    exec->GS.freeVector.x = 0x4000;
    -    exec->GS.freeVector.y = 0x0;
    -
    -    exec->GS.rp0 = 0;
    -    exec->GS.rp1 = 0;
    -    exec->GS.rp2 = 0;
    -
    -    exec->GS.gep0 = 1;
    -    exec->GS.gep1 = 1;
    -    exec->GS.gep2 = 1;
    -
    -    exec->GS.loop = 1;
    -
    -    /* save as default graphics state */
    -    size->GS = exec->GS;
    -
    -    TT_Save_Context( exec, size );
    +    if ( !error )
    +      TT_Save_Context( exec, size );
     
         return error;
       }
     
     
       static void
    -  tt_size_done_bytecode( FT_Size  ftsize )
    +  tt_size_done_bytecode( TT_Size  size )
       {
    -    TT_Size    size   = (TT_Size)ftsize;
    -    TT_Face    face   = (TT_Face)ftsize->face;
    -    FT_Memory  memory = face->root.memory;
    +    FT_Memory       memory = size->root.face->memory;
    +    TT_ExecContext  exec   = size->context;
     
    -    if ( size->context )
    +
    +    if ( exec )
         {
    -      TT_Done_Context( size->context );
    +      FT_FREE( exec->stack );
    +      FT_FREE( exec->FDefs );
    +
    +      TT_Done_Context( exec );
           size->context = NULL;
         }
     
    -    FT_FREE( size->cvt );
    -    size->cvt_size = 0;
    -
    -    /* free storage area */
    -    FT_FREE( size->storage );
    -    size->storage_size = 0;
    -
         /* twilight zone */
    -    tt_glyphzone_done( &size->twilight );
    -
    -    FT_FREE( size->function_defs );
    -    FT_FREE( size->instruction_defs );
    -
    -    size->num_function_defs    = 0;
    -    size->max_function_defs    = 0;
    -    size->num_instruction_defs = 0;
    -    size->max_instruction_defs = 0;
    -
    -    size->max_func = 0;
    -    size->max_ins  = 0;
    -
    -    size->bytecode_ready = -1;
    -    size->cvt_ready      = -1;
    +    tt_glyphzone_done( memory, &size->twilight );
       }
     
     
       /* Initialize bytecode-related fields in the size object.       */
       /* We do this only if bytecode interpretation is really needed. */
    -  static FT_Error
    -  tt_size_init_bytecode( FT_Size  ftsize,
    +  FT_LOCAL_DEF( FT_Error )
    +  tt_size_init_bytecode( TT_Size  size,
                              FT_Bool  pedantic )
       {
         FT_Error   error;
    -    TT_Size    size = (TT_Size)ftsize;
    -    TT_Face    face = (TT_Face)ftsize->face;
    -    FT_Memory  memory = face->root.memory;
    +    TT_Face    face = (TT_Face)size->root.face;
    +    FT_Memory  memory = size->root.face->memory;
     
         FT_UShort       n_twilight;
         TT_MaxProfile*  maxp = &face->max_profile;
    +    TT_ExecContext  exec;
     
     
    -    /* clean up bytecode related data */
    -    FT_FREE( size->function_defs );
    -    FT_FREE( size->instruction_defs );
    -    FT_FREE( size->cvt );
    -    FT_FREE( size->storage );
    +    exec = TT_New_Context( (TT_Driver)face->root.driver );
    +    if ( !exec )
    +      return FT_THROW( Could_Not_Find_Context );
     
    -    if ( size->context )
    -      TT_Done_Context( size->context );
    -    tt_glyphzone_done( &size->twilight );
    +    size->context = exec;
     
    -    size->bytecode_ready = -1;
    -    size->cvt_ready      = -1;
    +    exec->pedantic_hinting = pedantic;
     
    -    size->context = TT_New_Context( (TT_Driver)face->root.driver );
    +    exec->maxFDefs = maxp->maxFunctionDefs;
    +    exec->maxIDefs = maxp->maxInstructionDefs;
     
    -    size->max_function_defs    = maxp->maxFunctionDefs;
    -    size->max_instruction_defs = maxp->maxInstructionDefs;
    +    if ( FT_NEW_ARRAY( exec->FDefs, exec->maxFDefs + exec->maxIDefs ) )
    +      goto Fail;
     
    -    size->num_function_defs    = 0;
    -    size->num_instruction_defs = 0;
    +    exec->IDefs = exec->FDefs + exec->maxFDefs;
     
    -    size->max_func = 0;
    -    size->max_ins  = 0;
    +    exec->numFDefs = 0;
    +    exec->numIDefs = 0;
     
    -    size->cvt_size     = face->cvt_size;
    -    size->storage_size = maxp->maxStorage;
    +    exec->maxFunc = 0;
    +    exec->maxIns  = 0;
     
    -    /* Set default metrics */
    -    {
    -      TT_Size_Metrics*  tt_metrics = &size->ttmetrics;
    +    /* XXX: We reserve a little more elements on the stack to deal */
    +    /*      with broken fonts like arialbs, courbs, timesbs, etc.  */
    +    exec->stackSize = maxp->maxStackElements + 32;
    +    exec->storeSize = maxp->maxStorage;
    +    exec->cvtSize   = face->cvt_size;
     
    +    if ( FT_NEW_ARRAY( exec->stack,
    +                       exec->stackSize +
    +                         (FT_Long)( exec->storeSize + exec->cvtSize ) ) )
    +      goto Fail;
     
    -      tt_metrics->rotated   = FALSE;
    -      tt_metrics->stretched = FALSE;
    -
    -      /* Set default engine compensation.  Value 3 is not described */
    -      /* in the OpenType specification (as of Mai 2019), but Greg   */
    -      /* says that MS handles it the same as `gray'.                */
    -      /*                                                            */
    -      /* The Apple specification says that the compensation for     */
    -      /* `gray' is always zero.  FreeType doesn't do any            */
    -      /* compensation at all.                                       */
    -      tt_metrics->compensations[0] = 0;   /* gray  */
    -      tt_metrics->compensations[1] = 0;   /* black */
    -      tt_metrics->compensations[2] = 0;   /* white */
    -      tt_metrics->compensations[3] = 0;   /* zero  */
    -    }
    -
    -    /* allocate function defs, instruction defs, cvt, and storage area */
    -    if ( FT_NEW_ARRAY( size->function_defs,    size->max_function_defs    ) ||
    -         FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
    -         FT_NEW_ARRAY( size->cvt,              size->cvt_size             ) ||
    -         FT_NEW_ARRAY( size->storage,          size->storage_size         ) )
    -      goto Exit;
    -
    -    /* reserve twilight zone */
    +    /* reserve twilight zone and set GS before fpgm is executed, */
    +    /* just in case, even though fpgm should not touch them      */
         n_twilight = maxp->maxTwilightPoints;
     
         /* there are 4 phantom points (do we need this?) */
    @@ -1192,22 +1077,13 @@
     
         error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
         if ( error )
    -      goto Exit;
    +      goto Fail;
     
    -    size->twilight.n_points = n_twilight;
    +    size->GS        = tt_default_graphics_state;
    +    size->cvt_ready = -1;
     
    -    size->GS = tt_default_graphics_state;
    -
    -    /* set `face->interpreter' according to the debug hook present */
    -    {
    -      FT_Library  library = face->root.driver->root.library;
    -
    -
    -      face->interpreter = (TT_Interpreter)
    -                            library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
    -      if ( !face->interpreter )
    -        face->interpreter = (TT_Interpreter)TT_RunIns;
    -    }
    +    size->ttmetrics.rotated   = FALSE;
    +    size->ttmetrics.stretched = FALSE;
     
         /* Fine, now run the font program! */
     
    @@ -1217,59 +1093,11 @@
         /* to be executed just once; calling it again is completely useless   */
         /* and might even lead to extremely slow behaviour if it is malformed */
         /* (containing an infinite loop, for example).                        */
    -    error = tt_size_run_fpgm( size, pedantic );
    +    error = tt_size_run_fpgm( size );
         return error;
     
    -  Exit:
    -    if ( error )
    -      tt_size_done_bytecode( ftsize );
    -
    -    return error;
    -  }
    -
    -
    -  FT_LOCAL_DEF( FT_Error )
    -  tt_size_ready_bytecode( TT_Size  size,
    -                          FT_Bool  pedantic )
    -  {
    -    FT_Error  error = FT_Err_Ok;
    -
    -
    -    if ( size->bytecode_ready < 0 )
    -      error = tt_size_init_bytecode( (FT_Size)size, pedantic );
    -    else
    -      error = size->bytecode_ready;
    -
    -    if ( error )
    -      goto Exit;
    -
    -    /* rescale CVT when needed */
    -    if ( size->cvt_ready < 0 )
    -    {
    -      FT_UShort  i;
    -
    -
    -      /* all twilight points are originally zero */
    -      for ( i = 0; i < size->twilight.n_points; i++ )
    -      {
    -        size->twilight.org[i].x = 0;
    -        size->twilight.org[i].y = 0;
    -        size->twilight.cur[i].x = 0;
    -        size->twilight.cur[i].y = 0;
    -      }
    -
    -      /* clear storage area */
    -      for ( i = 0; i < size->storage_size; i++ )
    -        size->storage[i] = 0;
    -
    -      size->GS = tt_default_graphics_state;
    -
    -      error = tt_size_run_prep( size, pedantic );
    -    }
    -    else
    -      error = size->cvt_ready;
    -
    -  Exit:
    +  Fail:
    +    tt_size_done_bytecode( size );
         return error;
       }
     
    @@ -1300,11 +1128,9 @@
     
     #ifdef TT_USE_BYTECODE_INTERPRETER
         size->bytecode_ready = -1;
    -    size->cvt_ready      = -1;
     #endif
     
    -    size->ttmetrics.valid = FALSE;
    -    size->strike_index    = 0xFFFFFFFFUL;
    +    size->strike_index = 0xFFFFFFFFUL;
     
         return error;
       }
    @@ -1325,14 +1151,11 @@
       FT_LOCAL_DEF( void )
       tt_size_done( FT_Size  ttsize )           /* TT_Size */
       {
    -    TT_Size  size = (TT_Size)ttsize;
    -
    -
     #ifdef TT_USE_BYTECODE_INTERPRETER
    -    tt_size_done_bytecode( ttsize );
    +    tt_size_done_bytecode( (TT_Size)ttsize );
    +#else
    +    FT_UNUSED( ttsize );
     #endif
    -
    -    size->ttmetrics.valid = FALSE;
       }
     
     
    @@ -1353,21 +1176,13 @@
        *     function must take `FT_Size` as a result. The passed `FT_Size` is
        *     expected to point to a `TT_Size`.
        */
    -  FT_LOCAL_DEF( FT_Error )
    +  FT_LOCAL_DEF( void )
       tt_size_reset_height( FT_Size  ft_size )
       {
         TT_Size           size         = (TT_Size)ft_size;
    -    TT_Face           face         = (TT_Face)size->root.face;
    +    TT_Face           face         = (TT_Face)ft_size->face;
         FT_Size_Metrics*  size_metrics = &size->hinted_metrics;
     
    -    size->ttmetrics.valid = FALSE;
    -
    -    /* copy the result from base layer */
    -    *size_metrics = size->root.metrics;
    -
    -    if ( size_metrics->x_ppem < 1 || size_metrics->y_ppem < 1 )
    -      return FT_THROW( Invalid_PPem );
    -
         /* This bit flag, if set, indicates that the ppems must be       */
         /* rounded to integers.  Nearly all TrueType fonts have this bit */
         /* set, as hinting won't work really well otherwise.             */
    @@ -1385,10 +1200,6 @@
                                    FT_MulFix( face->root.height,
                                               size_metrics->y_scale ) );
         }
    -
    -    size->ttmetrics.valid = TRUE;
    -
    -    return FT_Err_Ok;
       }
     
     
    @@ -1408,14 +1219,20 @@
       FT_LOCAL_DEF( FT_Error )
       tt_size_reset( TT_Size  size )
       {
    -    FT_Error          error;
         TT_Face           face         = (TT_Face)size->root.face;
         FT_Size_Metrics*  size_metrics = &size->hinted_metrics;
     
     
    -    error = tt_size_reset_height( (FT_Size)size );
    -    if ( error )
    -      return error;
    +    /* invalidate the size object first */
    +    size->ttmetrics.ppem = 0;
    +
    +    if ( size->root.metrics.x_ppem == 0 || size->root.metrics.y_ppem == 0 )
    +      return FT_THROW( Invalid_PPem );
    +
    +    /* copy the result from base layer */
    +    *size_metrics = size->root.metrics;
    +
    +    tt_size_reset_height( (FT_Size)size );
     
         if ( face->header.Flags & 8 )
         {
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
    index 9c36ca78362..28d6c7d855f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h
    @@ -4,7 +4,7 @@
      *
      *   Objects manager (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -53,6 +53,8 @@ FT_BEGIN_HEADER
       typedef FT_GlyphSlot  TT_GlyphSlot;
     
     
    +#ifdef TT_USE_BYTECODE_INTERPRETER
    +
       /**************************************************************************
        *
        * @Struct:
    @@ -67,21 +69,27 @@ FT_BEGIN_HEADER
         FT_UShort      rp1;
         FT_UShort      rp2;
     
    +    FT_UShort      gep0;
    +    FT_UShort      gep1;
    +    FT_UShort      gep2;
    +
         FT_UnitVector  dualVector;
         FT_UnitVector  projVector;
         FT_UnitVector  freeVector;
     
         FT_Long        loop;
    -    FT_F26Dot6     minimum_distance;
         FT_Int         round_state;
    +    FT_F26Dot6     compensation[4];   /* device-specific compensations  */
     
    -    FT_Bool        auto_flip;
    +    /* default values below can be modified by 'fpgm' and 'prep' */
    +    FT_F26Dot6     minimum_distance;
         FT_F26Dot6     control_value_cutin;
         FT_F26Dot6     single_width_cutin;
         FT_F26Dot6     single_width_value;
         FT_UShort      delta_base;
         FT_UShort      delta_shift;
     
    +    FT_Bool        auto_flip;
         FT_Byte        instruct_control;
         /* According to Greg Hitchcock from Microsoft, the `scan_control'     */
         /* variable as documented in the TrueType specification is a 32-bit   */
    @@ -90,17 +98,12 @@ FT_BEGIN_HEADER
         FT_Bool        scan_control;
         FT_Int         scan_type;
     
    -    FT_UShort      gep0;
    -    FT_UShort      gep1;
    -    FT_UShort      gep2;
    -
       } TT_GraphicsState;
     
     
    -#ifdef TT_USE_BYTECODE_INTERPRETER
    -
       FT_LOCAL( void )
    -  tt_glyphzone_done( TT_GlyphZone  zone );
    +  tt_glyphzone_done( FT_Memory     memory,
    +                     TT_GlyphZone  zone );
     
       FT_LOCAL( FT_Error )
       tt_glyphzone_new( FT_Memory     memory,
    @@ -112,73 +115,6 @@ FT_BEGIN_HEADER
     
     
     
    -  /**************************************************************************
    -   *
    -   * EXECUTION SUBTABLES
    -   *
    -   * These sub-tables relate to instruction execution.
    -   *
    -   */
    -
    -
    -#define TT_MAX_CODE_RANGES  3
    -
    -
    -  /**************************************************************************
    -   *
    -   * There can only be 3 active code ranges at once:
    -   *   - the Font Program
    -   *   - the CVT Program
    -   *   - a glyph's instructions set
    -   */
    -  typedef enum  TT_CodeRange_Tag_
    -  {
    -    tt_coderange_none = 0,
    -    tt_coderange_font,
    -    tt_coderange_cvt,
    -    tt_coderange_glyph
    -
    -  } TT_CodeRange_Tag;
    -
    -
    -  typedef struct  TT_CodeRange_
    -  {
    -    FT_Byte*  base;
    -    FT_Long   size;
    -
    -  } TT_CodeRange;
    -
    -  typedef TT_CodeRange  TT_CodeRangeTable[TT_MAX_CODE_RANGES];
    -
    -
    -  /**************************************************************************
    -   *
    -   * Defines a function/instruction definition record.
    -   */
    -  typedef struct  TT_DefRecord_
    -  {
    -    FT_Int    range;          /* in which code range is it located?     */
    -    FT_Long   start;          /* where does it start?                   */
    -    FT_Long   end;            /* where does it end?                     */
    -    FT_UInt   opc;            /* function #, or instruction code        */
    -    FT_Bool   active;         /* is it active?                          */
    -
    -  } TT_DefRecord, *TT_DefArray;
    -
    -
    -  /**************************************************************************
    -   *
    -   * Subglyph transformation record.
    -   */
    -  typedef struct  TT_Transform_
    -  {
    -    FT_Fixed    xx, xy;     /* transformation matrix coefficients */
    -    FT_Fixed    yx, yy;
    -    FT_F26Dot6  ox, oy;     /* offsets                            */
    -
    -  } TT_Transform;
    -
    -
       /**************************************************************************
        *
        * A note regarding non-squared pixels:
    @@ -251,13 +187,9 @@ FT_BEGIN_HEADER
         FT_Long     x_ratio;
         FT_Long     y_ratio;
     
    -    FT_UShort   ppem;               /* maximum ppem size              */
         FT_Long     ratio;              /* current ratio                  */
         FT_Fixed    scale;
    -
    -    FT_F26Dot6  compensations[4];   /* device-specific compensations  */
    -
    -    FT_Bool     valid;
    +    FT_UShort   ppem;               /* maximum ppem size              */
     
         FT_Bool     rotated;            /* `is the glyph rotated?'-flag   */
         FT_Bool     stretched;          /* `is the glyph stretched?'-flag */
    @@ -288,27 +220,8 @@ FT_BEGIN_HEADER
     
         FT_Long            point_size;    /* for the `MPS' bytecode instruction */
     
    -    FT_UInt            num_function_defs; /* number of function definitions */
    -    FT_UInt            max_function_defs;
    -    TT_DefArray        function_defs;     /* table of function definitions  */
    -
    -    FT_UInt            num_instruction_defs;  /* number of ins. definitions */
    -    FT_UInt            max_instruction_defs;
    -    TT_DefArray        instruction_defs;      /* table of ins. definitions  */
    -
    -    FT_UInt            max_func;
    -    FT_UInt            max_ins;
    -
    -    TT_CodeRangeTable  codeRangeTable;
    -
         TT_GraphicsState   GS;
     
    -    FT_ULong           cvt_size;      /* the scaled control value table */
    -    FT_Long*           cvt;
    -
    -    FT_UShort          storage_size; /* The storage area is now part of */
    -    FT_Long*           storage;      /* the instance                    */
    -
         TT_GlyphZoneRec    twilight;     /* The instance's twilight zone    */
     
         TT_ExecContext     context;
    @@ -375,20 +288,18 @@ FT_BEGIN_HEADER
     #ifdef TT_USE_BYTECODE_INTERPRETER
     
       FT_LOCAL( FT_Error )
    -  tt_size_run_fpgm( TT_Size  size,
    -                    FT_Bool  pedantic );
    +  tt_size_run_fpgm( TT_Size  size );
     
       FT_LOCAL( FT_Error )
    -  tt_size_run_prep( TT_Size  size,
    -                    FT_Bool  pedantic );
    +  tt_size_run_prep( TT_Size  size );
     
       FT_LOCAL( FT_Error )
    -  tt_size_ready_bytecode( TT_Size  size,
    -                          FT_Bool  pedantic );
    +  tt_size_init_bytecode( TT_Size  size,
    +                         FT_Bool  pedantic );
     
     #endif /* TT_USE_BYTECODE_INTERPRETER */
     
    -  FT_LOCAL( FT_Error )
    +  FT_LOCAL( void )
       tt_size_reset_height( FT_Size  size );
     
       FT_LOCAL( FT_Error )
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
    index 9505b5f179f..827454d8574 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c
    @@ -4,7 +4,7 @@
      *
      *   TrueType-specific tables loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -110,7 +110,7 @@
     
         if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
         {
    -      FT_TRACE2(( "glyph count mismatch!  loca: %ld, maxp: %ld\n",
    +      FT_TRACE2(( "glyph count mismatch!  loca: %lu, maxp: %ld\n",
                       face->num_locations - 1, face->root.num_glyphs ));
     
           /* we only handle the case where `maxp' gives a larger value */
    @@ -151,7 +151,7 @@
               face->num_locations = (FT_ULong)face->root.num_glyphs + 1;
               table_len           = new_loca_len;
     
    -          FT_TRACE2(( "adjusting num_locations to %ld\n",
    +          FT_TRACE2(( "adjusting num_locations to %lu\n",
                           face->num_locations ));
             }
             else
    @@ -225,7 +225,7 @@
         if ( pos1 > ttface->glyf_len )
         {
           FT_TRACE1(( "tt_face_get_location:"
    -                  " too large offset (0x%08lx) found for glyph index %d,\n",
    +                  " too large offset (0x%08lx) found for glyph index %u,\n",
                       pos1, gindex ));
           FT_TRACE1(( "                     "
                       " exceeding the end of `glyf' table (0x%08lx)\n",
    @@ -240,17 +240,17 @@
           if ( gindex == ttface->num_locations - 2 )
           {
             FT_TRACE1(( "tt_face_get_location:"
    -                    " too large size (%ld bytes) found for glyph index %d,\n",
    +                    " too large size (%lu bytes) found for glyph index %u,\n",
                         pos2 - pos1, gindex ));
             FT_TRACE1(( "                     "
    -                    " truncating at the end of `glyf' table to %ld bytes\n",
    +                    " truncating at the end of `glyf' table to %lu bytes\n",
                         ttface->glyf_len - pos1 ));
             pos2 = ttface->glyf_len;
           }
           else
           {
             FT_TRACE1(( "tt_face_get_location:"
    -                    " too large offset (0x%08lx) found for glyph index %d,\n",
    +                    " too large offset (0x%08lx) found for glyph index %u,\n",
                         pos2, gindex + 1 ));
             FT_TRACE1(( "                     "
                         " exceeding the end of `glyf' table (0x%08lx)\n",
    @@ -419,7 +419,7 @@
           if ( FT_FRAME_EXTRACT( table_len, face->font_program ) )
             goto Exit;
     
    -      FT_TRACE2(( "loaded, %12ld bytes\n", face->font_program_size ));
    +      FT_TRACE2(( "loaded, %12lu bytes\n", face->font_program_size ));
         }
     
       Exit:
    @@ -482,7 +482,7 @@
           if ( FT_FRAME_EXTRACT( table_len, face->cvt_program ) )
             goto Exit;
     
    -      FT_TRACE2(( "loaded, %12ld bytes\n", face->cvt_program_size ));
    +      FT_TRACE2(( "loaded, %12lu bytes\n", face->cvt_program_size ));
         }
     
       Exit:
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
    index bc32b58020c..bb4d3c9cc55 100644
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h
    @@ -4,7 +4,7 @@
      *
      *   TrueType-specific tables loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c
    deleted file mode 100644
    index d811beef0df..00000000000
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c
    +++ /dev/null
    @@ -1,1013 +0,0 @@
    -/****************************************************************************
    - *
    - * ttsubpix.c
    - *
    - *   TrueType Subpixel Hinting.
    - *
    - * Copyright (C) 2010-2023 by
    - * David Turner, Robert Wilhelm, and Werner Lemberg.
    - *
    - * This file is part of the FreeType project, and may only be used,
    - * modified, and distributed under the terms of the FreeType project
    - * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    - * this file you indicate that you have read the license and
    - * understand and accept it fully.
    - *
    - */
    -
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    -
    -#include "ttsubpix.h"
    -
    -
    -#if defined( TT_USE_BYTECODE_INTERPRETER )            && \
    -    defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY )
    -
    -  /**************************************************************************
    -   *
    -   * These rules affect how the TT Interpreter does hinting, with the
    -   * goal of doing subpixel hinting by (in general) ignoring x moves.
    -   * Some of these rules are fixes that go above and beyond the
    -   * stated techniques in the MS whitepaper on Cleartype, due to
    -   * artifacts in many glyphs.  So, these rules make some glyphs render
    -   * better than they do in the MS rasterizer.
    -   *
    -   * "" string or 0 int/char indicates to apply to all glyphs.
    -   * "-" used as dummy placeholders, but any non-matching string works.
    -   *
    -   * Some of this could arguably be implemented in fontconfig, however:
    -   *
    -   * - Fontconfig can't set things on a glyph-by-glyph basis.
    -   * - The tweaks that happen here are very low-level, from an average
    -   *   user's point of view and are best implemented in the hinter.
    -   *
    -   * The goal is to make the subpixel hinting techniques as generalized
    -   * as possible across all fonts to prevent the need for extra rules such
    -   * as these.
    -   *
    -   * The rule structure is designed so that entirely new rules can easily
    -   * be added when a new compatibility feature is discovered.
    -   *
    -   * The rule structures could also use some enhancement to handle ranges.
    -   *
    -   *     ****************** WORK IN PROGRESS *******************
    -   */
    -
    -  /* These are `classes' of fonts that can be grouped together and used in */
    -  /* rules below.  A blank entry "" is required at the end of these!       */
    -#define FAMILY_CLASS_RULES_SIZE  7
    -
    -  static const SPH_Font_Class  FAMILY_CLASS_Rules
    -                               [FAMILY_CLASS_RULES_SIZE] =
    -  {
    -    { "MS Legacy Fonts",
    -      { "Aharoni",
    -        "Andale Mono",
    -        "Andalus",
    -        "Angsana New",
    -        "AngsanaUPC",
    -        "Arabic Transparent",
    -        "Arial Black",
    -        "Arial Narrow",
    -        "Arial Unicode MS",
    -        "Arial",
    -        "Batang",
    -        "Browallia New",
    -        "BrowalliaUPC",
    -        "Comic Sans MS",
    -        "Cordia New",
    -        "CordiaUPC",
    -        "Courier New",
    -        "DFKai-SB",
    -        "David Transparent",
    -        "David",
    -        "DilleniaUPC",
    -        "Estrangelo Edessa",
    -        "EucrosiaUPC",
    -        "FangSong_GB2312",
    -        "Fixed Miriam Transparent",
    -        "FrankRuehl",
    -        "Franklin Gothic Medium",
    -        "FreesiaUPC",
    -        "Garamond",
    -        "Gautami",
    -        "Georgia",
    -        "Gulim",
    -        "Impact",
    -        "IrisUPC",
    -        "JasmineUPC",
    -        "KaiTi_GB2312",
    -        "KodchiangUPC",
    -        "Latha",
    -        "Levenim MT",
    -        "LilyUPC",
    -        "Lucida Console",
    -        "Lucida Sans Unicode",
    -        "MS Gothic",
    -        "MS Mincho",
    -        "MV Boli",
    -        "Mangal",
    -        "Marlett",
    -        "Microsoft Sans Serif",
    -        "Mingliu",
    -        "Miriam Fixed",
    -        "Miriam Transparent",
    -        "Miriam",
    -        "Narkisim",
    -        "Palatino Linotype",
    -        "Raavi",
    -        "Rod Transparent",
    -        "Rod",
    -        "Shruti",
    -        "SimHei",
    -        "Simplified Arabic Fixed",
    -        "Simplified Arabic",
    -        "Simsun",
    -        "Sylfaen",
    -        "Symbol",
    -        "Tahoma",
    -        "Times New Roman",
    -        "Traditional Arabic",
    -        "Trebuchet MS",
    -        "Tunga",
    -        "Verdana",
    -        "Webdings",
    -        "Wingdings",
    -        "",
    -      },
    -    },
    -    { "Core MS Legacy Fonts",
    -      { "Arial Black",
    -        "Arial Narrow",
    -        "Arial Unicode MS",
    -        "Arial",
    -        "Comic Sans MS",
    -        "Courier New",
    -        "Garamond",
    -        "Georgia",
    -        "Impact",
    -        "Lucida Console",
    -        "Lucida Sans Unicode",
    -        "Microsoft Sans Serif",
    -        "Palatino Linotype",
    -        "Tahoma",
    -        "Times New Roman",
    -        "Trebuchet MS",
    -        "Verdana",
    -        "",
    -      },
    -    },
    -    { "Apple Legacy Fonts",
    -      { "Geneva",
    -        "Times",
    -        "Monaco",
    -        "Century",
    -        "Chalkboard",
    -        "Lobster",
    -        "Century Gothic",
    -        "Optima",
    -        "Lucida Grande",
    -        "Gill Sans",
    -        "Baskerville",
    -        "Helvetica",
    -        "Helvetica Neue",
    -        "",
    -      },
    -    },
    -    { "Legacy Sans Fonts",
    -      { "Andale Mono",
    -        "Arial Unicode MS",
    -        "Arial",
    -        "Century Gothic",
    -        "Comic Sans MS",
    -        "Franklin Gothic Medium",
    -        "Geneva",
    -        "Lucida Console",
    -        "Lucida Grande",
    -        "Lucida Sans Unicode",
    -        "Lucida Sans Typewriter",
    -        "Microsoft Sans Serif",
    -        "Monaco",
    -        "Tahoma",
    -        "Trebuchet MS",
    -        "Verdana",
    -        "",
    -      },
    -    },
    -
    -    { "Misc Legacy Fonts",
    -      { "Dark Courier", "", }, },
    -    { "Verdana Clones",
    -      { "DejaVu Sans",
    -        "Bitstream Vera Sans", "", }, },
    -    { "Verdana and Clones",
    -      { "DejaVu Sans",
    -        "Bitstream Vera Sans",
    -        "Verdana", "", }, },
    -  };
    -
    -
    -  /* Define this to force natural (i.e. not bitmap-compatible) widths.     */
    -  /* The default leans strongly towards natural widths except for a few    */
    -  /* legacy fonts where a selective combination produces nicer results.    */
    -/* #define FORCE_NATURAL_WIDTHS   */
    -
    -
    -  /* Define `classes' of styles that can be grouped together and used in   */
    -  /* rules below.  A blank entry "" is required at the end of these!       */
    -#define STYLE_CLASS_RULES_SIZE  5
    -
    -  static const SPH_Font_Class  STYLE_CLASS_Rules
    -                               [STYLE_CLASS_RULES_SIZE] =
    -  {
    -    { "Regular Class",
    -      { "Regular",
    -        "Book",
    -        "Medium",
    -        "Roman",
    -        "Normal",
    -        "",
    -      },
    -    },
    -    { "Regular/Italic Class",
    -      { "Regular",
    -        "Book",
    -        "Medium",
    -        "Italic",
    -        "Oblique",
    -        "Roman",
    -        "Normal",
    -        "",
    -      },
    -    },
    -    { "Bold/BoldItalic Class",
    -      { "Bold",
    -        "Bold Italic",
    -        "Black",
    -        "",
    -      },
    -    },
    -    { "Bold/Italic/BoldItalic Class",
    -      { "Bold",
    -        "Bold Italic",
    -        "Black",
    -        "Italic",
    -        "Oblique",
    -        "",
    -      },
    -    },
    -    { "Regular/Bold Class",
    -      { "Regular",
    -        "Book",
    -        "Medium",
    -        "Normal",
    -        "Roman",
    -        "Bold",
    -        "Black",
    -        "",
    -      },
    -    },
    -  };
    -
    -
    -  /* Force special legacy fixes for fonts.                                 */
    -#define COMPATIBILITY_MODE_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  COMPATIBILITY_MODE_Rules
    -                              [COMPATIBILITY_MODE_RULES_SIZE] =
    -  {
    -    { "Verdana Clones", 0, "", 0 },
    -  };
    -
    -
    -  /* Don't do subpixel (ignore_x_mode) hinting; do normal hinting.         */
    -#define PIXEL_HINTING_RULES_SIZE  2
    -
    -  static const SPH_TweakRule  PIXEL_HINTING_Rules
    -                              [PIXEL_HINTING_RULES_SIZE] =
    -  {
    -    /* these characters are almost always safe */
    -    { "Courier New", 12, "Italic", 'z' },
    -    { "Courier New", 11, "Italic", 'z' },
    -  };
    -
    -
    -  /* Subpixel hinting ignores SHPIX rules on X.  Force SHPIX for these.    */
    -#define DO_SHPIX_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  DO_SHPIX_Rules
    -                              [DO_SHPIX_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Skip Y moves that start with a point that is not on a Y pixel         */
    -  /* boundary and don't move that point to a Y pixel boundary.             */
    -#define SKIP_NONPIXEL_Y_MOVES_RULES_SIZE  4
    -
    -  static const SPH_TweakRule  SKIP_NONPIXEL_Y_MOVES_Rules
    -                              [SKIP_NONPIXEL_Y_MOVES_RULES_SIZE] =
    -  {
    -    /* fix vwxyz thinness */
    -    { "Consolas", 0, "", 0 },
    -    /* Fix thin middle stems */
    -    { "Core MS Legacy Fonts", 0, "Regular", 0 },
    -    /* Cyrillic small letter I */
    -    { "Legacy Sans Fonts", 0, "", 0 },
    -    /* Fix artifacts with some Regular & Bold */
    -    { "Verdana Clones", 0, "", 0 },
    -  };
    -
    -
    -#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE  1
    -
    -  static const SPH_TweakRule  SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions
    -                              [SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
    -  {
    -    /* Fixes < and > */
    -    { "Courier New", 0, "Regular", 0 },
    -  };
    -
    -
    -  /* Skip Y moves that start with a point that is not on a Y pixel         */
    -  /* boundary and don't move that point to a Y pixel boundary.             */
    -#define SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE  2
    -
    -  static const SPH_TweakRule  SKIP_NONPIXEL_Y_MOVES_DELTAP_Rules
    -                              [SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE] =
    -  {
    -    /* Maintain thickness of diagonal in 'N' */
    -    { "Times New Roman", 0, "Regular/Bold Class", 'N' },
    -    { "Georgia", 0, "Regular/Bold Class", 'N' },
    -  };
    -
    -
    -  /* Skip Y moves that move a point off a Y pixel boundary.                */
    -#define SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  SKIP_OFFPIXEL_Y_MOVES_Rules
    -                              [SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -#define SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE  1
    -
    -  static const SPH_TweakRule  SKIP_OFFPIXEL_Y_MOVES_Rules_Exceptions
    -                              [SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Round moves that don't move a point to a Y pixel boundary.            */
    -#define ROUND_NONPIXEL_Y_MOVES_RULES_SIZE  2
    -
    -  static const SPH_TweakRule  ROUND_NONPIXEL_Y_MOVES_Rules
    -                              [ROUND_NONPIXEL_Y_MOVES_RULES_SIZE] =
    -  {
    -    /* Droid font instructions don't snap Y to pixels */
    -    { "Droid Sans", 0, "Regular/Italic Class", 0 },
    -    { "Droid Sans Mono", 0, "", 0 },
    -  };
    -
    -
    -#define ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE  1
    -
    -  static const SPH_TweakRule  ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions
    -                              [ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Allow a Direct_Move along X freedom vector if matched.                */
    -#define ALLOW_X_DMOVE_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  ALLOW_X_DMOVE_Rules
    -                              [ALLOW_X_DMOVE_RULES_SIZE] =
    -  {
    -    /* Fixes vanishing diagonal in 4 */
    -    { "Verdana", 0, "Regular", '4' },
    -  };
    -
    -
    -  /* Return MS rasterizer version 35 if matched.                           */
    -#define RASTERIZER_35_RULES_SIZE  8
    -
    -  static const SPH_TweakRule  RASTERIZER_35_Rules
    -                              [RASTERIZER_35_RULES_SIZE] =
    -  {
    -    /* This seems to be the only way to make these look good */
    -    { "Times New Roman", 0, "Regular", 'i' },
    -    { "Times New Roman", 0, "Regular", 'j' },
    -    { "Times New Roman", 0, "Regular", 'm' },
    -    { "Times New Roman", 0, "Regular", 'r' },
    -    { "Times New Roman", 0, "Regular", 'a' },
    -    { "Times New Roman", 0, "Regular", 'n' },
    -    { "Times New Roman", 0, "Regular", 'p' },
    -    { "Times", 0, "", 0 },
    -  };
    -
    -
    -  /* Don't round to the subpixel grid.  Round to pixel grid.               */
    -#define NORMAL_ROUND_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  NORMAL_ROUND_Rules
    -                              [NORMAL_ROUND_RULES_SIZE] =
    -  {
    -    /* Fix serif thickness for certain ppems */
    -    /* Can probably be generalized somehow   */
    -    { "Courier New", 0, "", 0 },
    -  };
    -
    -
    -  /* Skip IUP instructions if matched.                                     */
    -#define SKIP_IUP_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  SKIP_IUP_Rules
    -                              [SKIP_IUP_RULES_SIZE] =
    -  {
    -    { "Arial", 13, "Regular", 'a' },
    -  };
    -
    -
    -  /* Skip MIAP Twilight hack if matched.                                   */
    -#define MIAP_HACK_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  MIAP_HACK_Rules
    -                              [MIAP_HACK_RULES_SIZE] =
    -  {
    -    { "Geneva", 12, "", 0 },
    -  };
    -
    -
    -  /* Skip DELTAP instructions if matched.                                  */
    -#define ALWAYS_SKIP_DELTAP_RULES_SIZE  23
    -
    -  static const SPH_TweakRule  ALWAYS_SKIP_DELTAP_Rules
    -                              [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
    -  {
    -    { "Georgia", 0, "Regular", 'k' },
    -    /* fix various problems with e in different versions */
    -    { "Trebuchet MS", 14, "Regular", 'e' },
    -    { "Trebuchet MS", 13, "Regular", 'e' },
    -    { "Trebuchet MS", 15, "Regular", 'e' },
    -    { "Trebuchet MS", 0, "Italic", 'v' },
    -    { "Trebuchet MS", 0, "Italic", 'w' },
    -    { "Trebuchet MS", 0, "Regular", 'Y' },
    -    { "Arial", 11, "Regular", 's' },
    -    /* prevent problems with '3' and others */
    -    { "Verdana", 10, "Regular", 0 },
    -    { "Verdana", 9, "Regular", 0 },
    -    /* Cyrillic small letter short I */
    -    { "Legacy Sans Fonts", 0, "", 0x438 },
    -    { "Legacy Sans Fonts", 0, "", 0x439 },
    -    { "Arial", 10, "Regular", '6' },
    -    { "Arial", 0, "Bold/BoldItalic Class", 'a' },
    -    /* Make horizontal stems consistent with the rest */
    -    { "Arial", 24, "Bold", 'a' },
    -    { "Arial", 25, "Bold", 'a' },
    -    { "Arial", 24, "Bold", 's' },
    -    { "Arial", 25, "Bold", 's' },
    -    { "Arial", 34, "Bold", 's' },
    -    { "Arial", 35, "Bold", 's' },
    -    { "Arial", 36, "Bold", 's' },
    -    { "Arial", 25, "Regular", 's' },
    -    { "Arial", 26, "Regular", 's' },
    -  };
    -
    -
    -  /* Always do DELTAP instructions if matched.                             */
    -#define ALWAYS_DO_DELTAP_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  ALWAYS_DO_DELTAP_Rules
    -                              [ALWAYS_DO_DELTAP_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Don't allow ALIGNRP after IUP.                                        */
    -#define NO_ALIGNRP_AFTER_IUP_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  NO_ALIGNRP_AFTER_IUP_Rules
    -                              [NO_ALIGNRP_AFTER_IUP_RULES_SIZE] =
    -  {
    -    /* Prevent creation of dents in outline */
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Don't allow DELTAP after IUP.                                         */
    -#define NO_DELTAP_AFTER_IUP_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  NO_DELTAP_AFTER_IUP_Rules
    -                              [NO_DELTAP_AFTER_IUP_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* Don't allow CALL after IUP.                                           */
    -#define NO_CALL_AFTER_IUP_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  NO_CALL_AFTER_IUP_Rules
    -                              [NO_CALL_AFTER_IUP_RULES_SIZE] =
    -  {
    -    /* Prevent creation of dents in outline */
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -  /* De-embolden these glyphs slightly.                                    */
    -#define DEEMBOLDEN_RULES_SIZE  9
    -
    -  static const SPH_TweakRule  DEEMBOLDEN_Rules
    -                              [DEEMBOLDEN_RULES_SIZE] =
    -  {
    -    { "Courier New", 0, "Bold", 'A' },
    -    { "Courier New", 0, "Bold", 'W' },
    -    { "Courier New", 0, "Bold", 'w' },
    -    { "Courier New", 0, "Bold", 'M' },
    -    { "Courier New", 0, "Bold", 'X' },
    -    { "Courier New", 0, "Bold", 'K' },
    -    { "Courier New", 0, "Bold", 'x' },
    -    { "Courier New", 0, "Bold", 'z' },
    -    { "Courier New", 0, "Bold", 'v' },
    -  };
    -
    -
    -  /* Embolden these glyphs slightly.                                       */
    -#define EMBOLDEN_RULES_SIZE  2
    -
    -  static const SPH_TweakRule  EMBOLDEN_Rules
    -                              [EMBOLDEN_RULES_SIZE] =
    -  {
    -    { "Courier New", 0, "Regular", 0 },
    -    { "Courier New", 0, "Italic", 0 },
    -  };
    -
    -
    -  /* This is a CVT hack that makes thick horizontal stems on 2, 5, 7       */
    -  /* similar to Windows XP.                                                */
    -#define TIMES_NEW_ROMAN_HACK_RULES_SIZE  12
    -
    -  static const SPH_TweakRule  TIMES_NEW_ROMAN_HACK_Rules
    -                              [TIMES_NEW_ROMAN_HACK_RULES_SIZE] =
    -  {
    -    { "Times New Roman", 16, "Italic", '2' },
    -    { "Times New Roman", 16, "Italic", '5' },
    -    { "Times New Roman", 16, "Italic", '7' },
    -    { "Times New Roman", 16, "Regular", '2' },
    -    { "Times New Roman", 16, "Regular", '5' },
    -    { "Times New Roman", 16, "Regular", '7' },
    -    { "Times New Roman", 17, "Italic", '2' },
    -    { "Times New Roman", 17, "Italic", '5' },
    -    { "Times New Roman", 17, "Italic", '7' },
    -    { "Times New Roman", 17, "Regular", '2' },
    -    { "Times New Roman", 17, "Regular", '5' },
    -    { "Times New Roman", 17, "Regular", '7' },
    -  };
    -
    -
    -  /* This fudges distance on 2 to get rid of the vanishing stem issue.     */
    -  /* A real solution to this is certainly welcome.                         */
    -#define COURIER_NEW_2_HACK_RULES_SIZE  15
    -
    -  static const SPH_TweakRule  COURIER_NEW_2_HACK_Rules
    -                              [COURIER_NEW_2_HACK_RULES_SIZE] =
    -  {
    -    { "Courier New", 10, "Regular", '2' },
    -    { "Courier New", 11, "Regular", '2' },
    -    { "Courier New", 12, "Regular", '2' },
    -    { "Courier New", 13, "Regular", '2' },
    -    { "Courier New", 14, "Regular", '2' },
    -    { "Courier New", 15, "Regular", '2' },
    -    { "Courier New", 16, "Regular", '2' },
    -    { "Courier New", 17, "Regular", '2' },
    -    { "Courier New", 18, "Regular", '2' },
    -    { "Courier New", 19, "Regular", '2' },
    -    { "Courier New", 20, "Regular", '2' },
    -    { "Courier New", 21, "Regular", '2' },
    -    { "Courier New", 22, "Regular", '2' },
    -    { "Courier New", 23, "Regular", '2' },
    -    { "Courier New", 24, "Regular", '2' },
    -  };
    -
    -
    -#ifndef FORCE_NATURAL_WIDTHS
    -
    -  /* Use compatible widths with these glyphs.  Compatible widths is always */
    -  /* on when doing B/W TrueType instructing, but is used selectively here, */
    -  /* typically on glyphs with 3 or more vertical stems.                    */
    -#define COMPATIBLE_WIDTHS_RULES_SIZE  38
    -
    -  static const SPH_TweakRule  COMPATIBLE_WIDTHS_Rules
    -                              [COMPATIBLE_WIDTHS_RULES_SIZE] =
    -  {
    -    { "Arial Unicode MS", 12, "Regular Class", 'm' },
    -    { "Arial Unicode MS", 14, "Regular Class", 'm' },
    -    /* Cyrillic small letter sha */
    -    { "Arial", 10, "Regular Class", 0x448 },
    -    { "Arial", 11, "Regular Class", 'm' },
    -    { "Arial", 12, "Regular Class", 'm' },
    -    /* Cyrillic small letter sha */
    -    { "Arial", 12, "Regular Class", 0x448 },
    -    { "Arial", 13, "Regular Class", 0x448 },
    -    { "Arial", 14, "Regular Class", 'm' },
    -    /* Cyrillic small letter sha */
    -    { "Arial", 14, "Regular Class", 0x448 },
    -    { "Arial", 15, "Regular Class", 0x448 },
    -    { "Arial", 17, "Regular Class", 'm' },
    -    { "DejaVu Sans", 15, "Regular Class", 0 },
    -    { "Microsoft Sans Serif", 11, "Regular Class", 0 },
    -    { "Microsoft Sans Serif", 12, "Regular Class", 0 },
    -    { "Segoe UI", 11, "Regular Class", 0 },
    -    { "Monaco", 0, "Regular Class", 0 },
    -    { "Segoe UI", 12, "Regular Class", 'm' },
    -    { "Segoe UI", 14, "Regular Class", 'm' },
    -    { "Tahoma", 11, "Regular Class", 0 },
    -    { "Times New Roman", 16, "Regular Class", 'c' },
    -    { "Times New Roman", 16, "Regular Class", 'm' },
    -    { "Times New Roman", 16, "Regular Class", 'o' },
    -    { "Times New Roman", 16, "Regular Class", 'w' },
    -    { "Trebuchet MS", 11, "Regular Class", 0 },
    -    { "Trebuchet MS", 12, "Regular Class", 0 },
    -    { "Trebuchet MS", 14, "Regular Class", 0 },
    -    { "Trebuchet MS", 15, "Regular Class", 0 },
    -    { "Ubuntu", 12, "Regular Class", 'm' },
    -    /* Cyrillic small letter sha */
    -    { "Verdana", 10, "Regular Class", 0x448 },
    -    { "Verdana", 11, "Regular Class", 0x448 },
    -    { "Verdana and Clones", 12, "Regular Class", 'i' },
    -    { "Verdana and Clones", 12, "Regular Class", 'j' },
    -    { "Verdana and Clones", 12, "Regular Class", 'l' },
    -    { "Verdana and Clones", 12, "Regular Class", 'm' },
    -    { "Verdana and Clones", 13, "Regular Class", 'i' },
    -    { "Verdana and Clones", 13, "Regular Class", 'j' },
    -    { "Verdana and Clones", 13, "Regular Class", 'l' },
    -    { "Verdana and Clones", 14, "Regular Class", 'm' },
    -  };
    -
    -
    -  /* Scaling slightly in the x-direction prior to hinting results in       */
    -  /* more visually pleasing glyphs in certain cases.                       */
    -  /* This sometimes needs to be coordinated with compatible width rules.   */
    -  /* A value of 1000 corresponds to a scaled value of 1.0.                 */
    -
    -#define X_SCALING_RULES_SIZE  50
    -
    -  static const SPH_ScaleRule  X_SCALING_Rules[X_SCALING_RULES_SIZE] =
    -  {
    -    { "DejaVu Sans", 12, "Regular Class", 'm', 950 },
    -    { "Verdana and Clones", 12, "Regular Class", 'a', 1100 },
    -    { "Verdana and Clones", 13, "Regular Class", 'a', 1050 },
    -    { "Arial", 11, "Regular Class", 'm', 975 },
    -    { "Arial", 12, "Regular Class", 'm', 1050 },
    -    /* Cyrillic small letter el */
    -    { "Arial", 13, "Regular Class", 0x43B, 950 },
    -    { "Arial", 13, "Regular Class", 'o', 950 },
    -    { "Arial", 13, "Regular Class", 'e', 950 },
    -    { "Arial", 14, "Regular Class", 'm', 950 },
    -    /* Cyrillic small letter el */
    -    { "Arial", 15, "Regular Class", 0x43B, 925 },
    -    { "Bitstream Vera Sans", 10, "Regular/Italic Class", 0, 1100 },
    -    { "Bitstream Vera Sans", 12, "Regular/Italic Class", 0, 1050 },
    -    { "Bitstream Vera Sans", 16, "Regular Class", 0, 1050 },
    -    { "Bitstream Vera Sans", 9, "Regular/Italic Class", 0, 1050 },
    -    { "DejaVu Sans", 12, "Regular Class", 'l', 975 },
    -    { "DejaVu Sans", 12, "Regular Class", 'i', 975 },
    -    { "DejaVu Sans", 12, "Regular Class", 'j', 975 },
    -    { "DejaVu Sans", 13, "Regular Class", 'l', 950 },
    -    { "DejaVu Sans", 13, "Regular Class", 'i', 950 },
    -    { "DejaVu Sans", 13, "Regular Class", 'j', 950 },
    -    { "DejaVu Sans", 10, "Regular/Italic Class", 0, 1100 },
    -    { "DejaVu Sans", 12, "Regular/Italic Class", 0, 1050 },
    -    { "Georgia", 10, "", 0, 1050 },
    -    { "Georgia", 11, "", 0, 1100 },
    -    { "Georgia", 12, "", 0, 1025 },
    -    { "Georgia", 13, "", 0, 1050 },
    -    { "Georgia", 16, "", 0, 1050 },
    -    { "Georgia", 17, "", 0, 1030 },
    -    { "Liberation Sans", 12, "Regular Class", 'm', 1100 },
    -    { "Lucida Grande", 11, "Regular Class", 'm', 1100 },
    -    { "Microsoft Sans Serif", 11, "Regular Class", 'm', 950 },
    -    { "Microsoft Sans Serif", 12, "Regular Class", 'm', 1050 },
    -    { "Segoe UI", 12, "Regular Class", 'H', 1050 },
    -    { "Segoe UI", 12, "Regular Class", 'm', 1050 },
    -    { "Segoe UI", 14, "Regular Class", 'm', 1050 },
    -    { "Tahoma", 11, "Regular Class", 'i', 975 },
    -    { "Tahoma", 11, "Regular Class", 'l', 975 },
    -    { "Tahoma", 11, "Regular Class", 'j', 900 },
    -    { "Tahoma", 11, "Regular Class", 'm', 918 },
    -    { "Verdana", 10, "Regular/Italic Class", 0, 1100 },
    -    { "Verdana", 12, "Regular Class", 'm', 975 },
    -    { "Verdana", 12, "Regular/Italic Class", 0, 1050 },
    -    { "Verdana", 13, "Regular/Italic Class", 'i', 950 },
    -    { "Verdana", 13, "Regular/Italic Class", 'j', 950 },
    -    { "Verdana", 13, "Regular/Italic Class", 'l', 950 },
    -    { "Verdana", 16, "Regular Class", 0, 1050 },
    -    { "Verdana", 9, "Regular/Italic Class", 0, 1050 },
    -    { "Times New Roman", 16, "Regular Class", 'm', 918 },
    -    { "Trebuchet MS", 11, "Regular Class", 'm', 800 },
    -    { "Trebuchet MS", 12, "Regular Class", 'm', 800 },
    -  };
    -
    -#else
    -
    -#define COMPATIBLE_WIDTHS_RULES_SIZE  1
    -
    -  static const SPH_TweakRule  COMPATIBLE_WIDTHS_Rules
    -                              [COMPATIBLE_WIDTHS_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0 },
    -  };
    -
    -
    -#define X_SCALING_RULES_SIZE  1
    -
    -  static const SPH_ScaleRule  X_SCALING_Rules
    -                              [X_SCALING_RULES_SIZE] =
    -  {
    -    { "-", 0, "", 0, 1000 },
    -  };
    -
    -#endif /* FORCE_NATURAL_WIDTHS */
    -
    -
    -  static FT_Bool
    -  is_member_of_family_class( const FT_String*  detected_font_name,
    -                             const FT_String*  rule_font_name )
    -  {
    -    FT_UInt  i, j;
    -
    -
    -    /* Does font name match rule family? */
    -    if ( ft_strcmp( detected_font_name, rule_font_name ) == 0 )
    -      return TRUE;
    -
    -    /* Is font name a wildcard ""? */
    -    if ( ft_strcmp( rule_font_name, "" ) == 0 )
    -      return TRUE;
    -
    -    /* Is font name contained in a class list? */
    -    for ( i = 0; i < FAMILY_CLASS_RULES_SIZE; i++ )
    -    {
    -      if ( ft_strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 )
    -      {
    -        for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
    -        {
    -          if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
    -            continue;
    -          if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j],
    -                          detected_font_name ) == 0 )
    -            return TRUE;
    -        }
    -      }
    -    }
    -
    -    return FALSE;
    -  }
    -
    -
    -  static FT_Bool
    -  is_member_of_style_class( const FT_String*  detected_font_style,
    -                            const FT_String*  rule_font_style )
    -  {
    -    FT_UInt  i, j;
    -
    -
    -    /* Does font style match rule style? */
    -    if ( ft_strcmp( detected_font_style, rule_font_style ) == 0 )
    -      return TRUE;
    -
    -    /* Is font style a wildcard ""? */
    -    if ( ft_strcmp( rule_font_style, "" ) == 0 )
    -      return TRUE;
    -
    -    /* Is font style contained in a class list? */
    -    for ( i = 0; i < STYLE_CLASS_RULES_SIZE; i++ )
    -    {
    -      if ( ft_strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 )
    -      {
    -        for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
    -        {
    -          if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
    -            continue;
    -          if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j],
    -                          detected_font_style ) == 0 )
    -            return TRUE;
    -        }
    -      }
    -    }
    -
    -    return FALSE;
    -  }
    -
    -
    -  FT_LOCAL_DEF( FT_Bool )
    -  sph_test_tweak( TT_Face               face,
    -                  const FT_String*      family,
    -                  FT_UInt               ppem,
    -                  const FT_String*      style,
    -                  FT_UInt               glyph_index,
    -                  const SPH_TweakRule*  rule,
    -                  FT_UInt               num_rules )
    -  {
    -    FT_UInt  i;
    -
    -
    -    /* rule checks may be able to be optimized further */
    -    for ( i = 0; i < num_rules; i++ )
    -    {
    -      if ( family                                                   &&
    -           ( is_member_of_family_class ( family, rule[i].family ) ) )
    -        if ( rule[i].ppem == 0    ||
    -             rule[i].ppem == ppem )
    -          if ( style                                             &&
    -               is_member_of_style_class ( style, rule[i].style ) )
    -            if ( rule[i].glyph == 0                                ||
    -                 FT_Get_Char_Index( (FT_Face)face,
    -                                    rule[i].glyph ) == glyph_index )
    -        return TRUE;
    -    }
    -
    -    return FALSE;
    -  }
    -
    -
    -  static FT_UInt
    -  scale_test_tweak( TT_Face               face,
    -                    const FT_String*      family,
    -                    FT_UInt               ppem,
    -                    const FT_String*      style,
    -                    FT_UInt               glyph_index,
    -                    const SPH_ScaleRule*  rule,
    -                    FT_UInt               num_rules )
    -  {
    -    FT_UInt  i;
    -
    -
    -    /* rule checks may be able to be optimized further */
    -    for ( i = 0; i < num_rules; i++ )
    -    {
    -      if ( family                                                   &&
    -           ( is_member_of_family_class ( family, rule[i].family ) ) )
    -        if ( rule[i].ppem == 0    ||
    -             rule[i].ppem == ppem )
    -          if ( style                                            &&
    -               is_member_of_style_class( style, rule[i].style ) )
    -            if ( rule[i].glyph == 0                                ||
    -                 FT_Get_Char_Index( (FT_Face)face,
    -                                    rule[i].glyph ) == glyph_index )
    -        return rule[i].scale;
    -    }
    -
    -    return 1000;
    -  }
    -
    -
    -  FT_LOCAL_DEF( FT_UInt )
    -  sph_test_tweak_x_scaling( TT_Face           face,
    -                            const FT_String*  family,
    -                            FT_UInt           ppem,
    -                            const FT_String*  style,
    -                            FT_UInt           glyph_index )
    -  {
    -    return scale_test_tweak( face, family, ppem, style, glyph_index,
    -                             X_SCALING_Rules, X_SCALING_RULES_SIZE );
    -  }
    -
    -
    -#define TWEAK_RULES( x )                                       \
    -  if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
    -                       x##_Rules, x##_RULES_SIZE ) )           \
    -    loader->exec->sph_tweak_flags |= SPH_TWEAK_##x
    -
    -#define TWEAK_RULES_EXCEPTIONS( x )                                        \
    -  if ( sph_test_tweak( face, family, ppem, style, glyph_index,             \
    -                       x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
    -    loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x
    -
    -
    -  FT_LOCAL_DEF( void )
    -  sph_set_tweaks( TT_Loader  loader,
    -                  FT_UInt    glyph_index )
    -  {
    -    TT_Face     face   = loader->face;
    -    FT_String*  family = face->root.family_name;
    -    FT_UInt     ppem   = loader->size->metrics->x_ppem;
    -    FT_String*  style  = face->root.style_name;
    -
    -
    -    /* don't apply rules if style isn't set */
    -    if ( !face->root.style_name )
    -      return;
    -
    -#ifdef SPH_DEBUG_MORE_VERBOSE
    -    printf( "%s,%d,%s,%c=%d ",
    -            family, ppem, style, glyph_index, glyph_index );
    -#endif
    -
    -    TWEAK_RULES( PIXEL_HINTING );
    -
    -    if ( loader->exec->sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING )
    -    {
    -      loader->exec->ignore_x_mode = FALSE;
    -      return;
    -    }
    -
    -    TWEAK_RULES( ALLOW_X_DMOVE );
    -    TWEAK_RULES( ALWAYS_DO_DELTAP );
    -    TWEAK_RULES( ALWAYS_SKIP_DELTAP );
    -    TWEAK_RULES( DEEMBOLDEN );
    -    TWEAK_RULES( DO_SHPIX );
    -    TWEAK_RULES( EMBOLDEN );
    -    TWEAK_RULES( MIAP_HACK );
    -    TWEAK_RULES( NORMAL_ROUND );
    -    TWEAK_RULES( NO_ALIGNRP_AFTER_IUP );
    -    TWEAK_RULES( NO_CALL_AFTER_IUP );
    -    TWEAK_RULES( NO_DELTAP_AFTER_IUP );
    -    TWEAK_RULES( RASTERIZER_35 );
    -    TWEAK_RULES( SKIP_IUP );
    -
    -    TWEAK_RULES( SKIP_OFFPIXEL_Y_MOVES );
    -    TWEAK_RULES_EXCEPTIONS( SKIP_OFFPIXEL_Y_MOVES );
    -
    -    TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES_DELTAP );
    -
    -    TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES );
    -    TWEAK_RULES_EXCEPTIONS( SKIP_NONPIXEL_Y_MOVES );
    -
    -    TWEAK_RULES( ROUND_NONPIXEL_Y_MOVES );
    -    TWEAK_RULES_EXCEPTIONS( ROUND_NONPIXEL_Y_MOVES );
    -
    -    if ( loader->exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
    -    {
    -      if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 )
    -      {
    -        loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
    -        loader->exec->size->cvt_ready    = -1;
    -
    -        tt_size_ready_bytecode(
    -          loader->exec->size,
    -          FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
    -      }
    -      else
    -        loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
    -    }
    -    else
    -    {
    -      if ( loader->exec->rasterizer_version  !=
    -           SPH_OPTION_SET_RASTERIZER_VERSION )
    -      {
    -        loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
    -        loader->exec->size->cvt_ready    = -1;
    -
    -        tt_size_ready_bytecode(
    -          loader->exec->size,
    -          FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
    -      }
    -      else
    -        loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
    -    }
    -
    -    if ( IS_HINTED( loader->load_flags ) )
    -    {
    -      TWEAK_RULES( TIMES_NEW_ROMAN_HACK );
    -      TWEAK_RULES( COURIER_NEW_2_HACK );
    -    }
    -
    -    if ( sph_test_tweak( face, family, ppem, style, glyph_index,
    -           COMPATIBILITY_MODE_Rules, COMPATIBILITY_MODE_RULES_SIZE ) )
    -      loader->exec->face->sph_compatibility_mode = TRUE;
    -
    -
    -    if ( IS_HINTED( loader->load_flags ) )
    -    {
    -      if ( sph_test_tweak( face, family, ppem, style, glyph_index,
    -             COMPATIBLE_WIDTHS_Rules, COMPATIBLE_WIDTHS_RULES_SIZE ) )
    -        loader->exec->compatible_widths |= TRUE;
    -    }
    -  }
    -
    -#else /* !(TT_USE_BYTECODE_INTERPRETER &&          */
    -      /*   TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */
    -
    -  /* ANSI C doesn't like empty source files */
    -  typedef int  _tt_subpix_dummy;
    -
    -#endif /* !(TT_USE_BYTECODE_INTERPRETER &&          */
    -       /*   TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */
    -
    -
    -/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h
    deleted file mode 100644
    index 62af4c272d1..00000000000
    --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h
    +++ /dev/null
    @@ -1,110 +0,0 @@
    -/****************************************************************************
    - *
    - * ttsubpix.h
    - *
    - *   TrueType Subpixel Hinting.
    - *
    - * Copyright (C) 2010-2023 by
    - * David Turner, Robert Wilhelm, and Werner Lemberg.
    - *
    - * This file is part of the FreeType project, and may only be used,
    - * modified, and distributed under the terms of the FreeType project
    - * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    - * this file you indicate that you have read the license and
    - * understand and accept it fully.
    - *
    - */
    -
    -
    -#ifndef TTSUBPIX_H_
    -#define TTSUBPIX_H_
    -
    -#include "ttobjs.h"
    -#include "ttinterp.h"
    -
    -
    -FT_BEGIN_HEADER
    -
    -
    -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
    -
    -  /**************************************************************************
    -   *
    -   * ID flags to identify special functions at FDEF and runtime.
    -   *
    -   */
    -#define SPH_FDEF_INLINE_DELTA_1       0x0000001
    -#define SPH_FDEF_INLINE_DELTA_2       0x0000002
    -#define SPH_FDEF_DIAGONAL_STROKE      0x0000004
    -#define SPH_FDEF_VACUFORM_ROUND_1     0x0000008
    -#define SPH_FDEF_TTFAUTOHINT_1        0x0000010
    -#define SPH_FDEF_SPACING_1            0x0000020
    -#define SPH_FDEF_SPACING_2            0x0000040
    -#define SPH_FDEF_TYPEMAN_STROKES      0x0000080
    -#define SPH_FDEF_TYPEMAN_DIAGENDCTRL  0x0000100
    -
    -
    -  /**************************************************************************
    -   *
    -   * Tweak flags that are set for each glyph by the below rules.
    -   *
    -   */
    -#define SPH_TWEAK_ALLOW_X_DMOVE                   0x0000001UL
    -#define SPH_TWEAK_ALWAYS_DO_DELTAP                0x0000002UL
    -#define SPH_TWEAK_ALWAYS_SKIP_DELTAP              0x0000004UL
    -#define SPH_TWEAK_COURIER_NEW_2_HACK              0x0000008UL
    -#define SPH_TWEAK_DEEMBOLDEN                      0x0000010UL
    -#define SPH_TWEAK_DO_SHPIX                        0x0000020UL
    -#define SPH_TWEAK_EMBOLDEN                        0x0000040UL
    -#define SPH_TWEAK_MIAP_HACK                       0x0000080UL
    -#define SPH_TWEAK_NORMAL_ROUND                    0x0000100UL
    -#define SPH_TWEAK_NO_ALIGNRP_AFTER_IUP            0x0000200UL
    -#define SPH_TWEAK_NO_CALL_AFTER_IUP               0x0000400UL
    -#define SPH_TWEAK_NO_DELTAP_AFTER_IUP             0x0000800UL
    -#define SPH_TWEAK_PIXEL_HINTING                   0x0001000UL
    -#define SPH_TWEAK_RASTERIZER_35                   0x0002000UL
    -#define SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES          0x0004000UL
    -#define SPH_TWEAK_SKIP_IUP                        0x0008000UL
    -#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES           0x0010000UL
    -#define SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES           0x0020000UL
    -#define SPH_TWEAK_TIMES_NEW_ROMAN_HACK            0x0040000UL
    -#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP    0x0080000UL
    -
    -
    -  FT_LOCAL( FT_Bool )
    -  sph_test_tweak( TT_Face               face,
    -                  const FT_String*      family,
    -                  FT_UInt               ppem,
    -                  const FT_String*      style,
    -                  FT_UInt               glyph_index,
    -                  const SPH_TweakRule*  rule,
    -                  FT_UInt               num_rules );
    -
    -  FT_LOCAL( FT_UInt )
    -  sph_test_tweak_x_scaling( TT_Face           face,
    -                            const FT_String*  family,
    -                            FT_UInt           ppem,
    -                            const FT_String*  style,
    -                            FT_UInt           glyph_index );
    -
    -  FT_LOCAL( void )
    -  sph_set_tweaks( TT_Loader  loader,
    -                  FT_UInt    glyph_index );
    -
    -
    -  /* These macros are defined absent a method for setting them */
    -#define SPH_OPTION_BITMAP_WIDTHS           FALSE
    -#define SPH_OPTION_SET_SUBPIXEL            TRUE
    -#define SPH_OPTION_SET_GRAYSCALE           FALSE
    -#define SPH_OPTION_SET_COMPATIBLE_WIDTHS   FALSE
    -#define SPH_OPTION_SET_RASTERIZER_VERSION  38
    -
    -#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
    -
    -
    -FT_END_HEADER
    -
    -#endif /* TTSUBPIX_H_ */
    -
    -
    -/* END */
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
    index a63cd4dc48a..b1a0d23bed6 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c
    @@ -4,7 +4,7 @@
      *
      *   AFM support for Type 1 fonts (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
    index 7f5cdda191f..92ff627dd0d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h
    @@ -4,7 +4,7 @@
      *
      *   AFM support for Type 1 fonts (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
    index 8ed01914a5a..5ded7714021 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 driver interface (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
    index 5ff52b55b1a..1cc3d24e7dd 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h
    @@ -4,7 +4,7 @@
      *
      *   High-level Type 1 driver interface (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h b/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
    index 8aeb24ae188..46bddbc30fd 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 error codes (specification only).
      *
    - * Copyright (C) 2001-2024 by
    + * Copyright (C) 2001-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
    index c29e682510c..b9bc0b56ce8 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 Glyph Loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -70,8 +70,13 @@
         /* For incremental fonts get the character data using the */
         /* callback function.                                     */
         if ( inc )
    +    {
    +      /* So `free_glyph_data` knows whether to free it. */
    +      char_string->pointer = NULL;
    +
           error = inc->funcs->get_glyph_data( inc->object,
                                               glyph_index, char_string );
    +    }
         else
     
     #endif /* FT_CONFIG_OPTION_INCREMENTAL */
    @@ -155,6 +160,9 @@
           decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance_v );
         }
     
    +    if ( error && inc )
    +      inc->funcs->free_glyph_data( inc->object, char_string );
    +
     #endif /* FT_CONFIG_OPTION_INCREMENTAL */
     
         return error;
    @@ -295,7 +303,7 @@
           {
             advances[nn] = 0;
     
    -        FT_TRACE5(( "  idx %d: advance height 0 font units\n",
    +        FT_TRACE5(( "  idx %u: advance height 0 font units\n",
                         first + nn ));
           }
     
    @@ -333,7 +341,7 @@
           else
             advances[nn] = 0;
     
    -      FT_TRACE5(( "  idx %d: advance width %ld font unit%s\n",
    +      FT_TRACE5(( "  idx %u: advance width %ld font unit%s\n",
                       first + nn,
                       advances[nn],
                       advances[nn] == 1 ? "" : "s" ));
    @@ -380,7 +388,7 @@
           goto Exit;
         }
     
    -    FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
    +    FT_TRACE1(( "T1_Load_Glyph: glyph index %u\n", glyph_index ));
     
         FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
     
    @@ -398,16 +406,12 @@
           glyph->y_scale = 0x10000L;
         }
     
    -    t1glyph->outline.n_points   = 0;
    -    t1glyph->outline.n_contours = 0;
    -
         hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE   ) &&
                            !( load_flags & FT_LOAD_NO_HINTING ) );
         scaled  = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE   ) );
     
         glyph->hint     = hinting;
         glyph->scaled   = scaled;
    -    t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
     
         error = decoder_funcs->init( &decoder,
                                      t1glyph->face,
    @@ -452,16 +456,12 @@
     
         must_finish_decoder = FALSE;
     
    -    /* now, set the metrics -- this is rather simple, as   */
    -    /* the left side bearing is the xMin, and the top side */
    -    /* bearing the yMax                                    */
         if ( !error )
         {
    -      t1glyph->outline.flags &= FT_OUTLINE_OWNER;
    -      t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
    -
    -      /* for composite glyphs, return only left side bearing and */
    -      /* advance width                                           */
    +      /* now, set the metrics -- this is rather simple, as   */
    +      /* the left side bearing is the xMin, and the top side */
    +      /* bearing the yMax; for composite glyphs, return only */
    +      /* left side bearing and advance width                 */
           if ( load_flags & FT_LOAD_NO_RECURSE )
           {
             FT_Slot_Internal  internal = t1glyph->internal;
    @@ -482,6 +482,13 @@
             FT_Glyph_Metrics*  metrics = &t1glyph->metrics;
     
     
    +        t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
    +
    +        t1glyph->outline.flags &= FT_OUTLINE_OWNER;
    +        t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
    +        if ( t1size && t1size->metrics.y_ppem < 24 )
    +          t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    +
             /* copy the _unscaled_ advance width */
             metrics->horiAdvance =
               FIXED_TO_INT( decoder.builder.advance.x );
    @@ -504,11 +511,6 @@
                 FIXED_TO_INT( decoder.builder.advance.y );
             }
     
    -        t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
    -
    -        if ( t1size && t1size->metrics.y_ppem < 24 )
    -          t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
    -
     #if 1
             /* apply the font matrix, if any */
             if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
    index 17a6a5941e3..6bedd132c5f 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 Glyph Loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1load.c b/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
    index ee7fb42a517..0f11445bef0 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1load.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 font loader (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -471,7 +471,7 @@
         nc = num_coords;
         if ( num_coords > blend->num_axis )
         {
    -      FT_TRACE2(( "T1_Get_MM_Blend: only using first %d of %d coordinates\n",
    +      FT_TRACE2(( "T1_Get_MM_Blend: only using first %u of %u coordinates\n",
                       blend->num_axis, num_coords ));
           nc = blend->num_axis;
         }
    @@ -640,7 +640,7 @@
       {
         FT_UNUSED( instance_index );
     
    -    return T1_Set_MM_Blend( face, 0, NULL );
    +    return T1_Set_MM_WeightVector( face, 0, NULL );
       }
     
     
    @@ -691,7 +691,7 @@
         if ( num_coords > blend->num_axis )
         {
           FT_TRACE2(( "T1_Get_Var_Design:"
    -                  " only using first %d of %d coordinates\n",
    +                  " only using first %u of %u coordinates\n",
                       blend->num_axis, num_coords ));
           nc = blend->num_axis;
         }
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1load.h b/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
    index a45efa7cb7b..2cd8241968d 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1load.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 font loader (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
    index b1b27c31fe3..7f25208f875 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 objects manager (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
    index 3809370c1e0..6c71977c154 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 objects manager (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
    index 3717ea7c572..ef643e298f4 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c
    @@ -4,7 +4,7 @@
      *
      *   Type 1 parser (body).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
    index a0a2134d45c..f4ad426e9e1 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 parser (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
    index 5a3d2f1ef08..a526406a411 100644
    --- a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
    +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h
    @@ -4,7 +4,7 @@
      *
      *   Type 1 tokenizer (specification).
      *
    - * Copyright (C) 1996-2024 by
    + * Copyright (C) 1996-2025 by
      * David Turner, Robert Wilhelm, and Werner Lemberg.
      *
      * This file is part of the FreeType project, and may only be used,
    @@ -33,7 +33,7 @@
                        T1_FIELD_DICT_FONTDICT )
     
       /* we use pointers to detect modifications made by synthetic fonts */
    -  T1_FIELD_NUM   ( "ItalicAngle",        italic_angle,
    +  T1_FIELD_FIXED ( "ItalicAngle",        italic_angle,
                        T1_FIELD_DICT_FONTDICT )
       T1_FIELD_BOOL  ( "isFixedPitch",       is_fixed_pitch,
                        T1_FIELD_DICT_FONTDICT )
    diff --git a/src/java.desktop/share/native/libharfbuzz/hb-aat-layout-common.hh b/src/java.desktop/share/native/libharfbuzz/hb-aat-layout-common.hh
    index d2ce32616be..4bb41fd0189 100644
    --- a/src/java.desktop/share/native/libharfbuzz/hb-aat-layout-common.hh
    +++ b/src/java.desktop/share/native/libharfbuzz/hb-aat-layout-common.hh
    @@ -1266,8 +1266,7 @@ struct StateTableDriver
                                       next_state == StateTableT::STATE_START_OF_TEXT &&
                                       start_state_safe_to_break_eot &&
                                       is_not_actionable &&
    -                                  is_not_epsilon_transition &&
    -                                  !last_range;
    +                                  is_not_epsilon_transition;
     
             if (is_null_transition)
             {
    diff --git a/src/java.desktop/share/native/libharfbuzz/hb-ot-layout-common.hh b/src/java.desktop/share/native/libharfbuzz/hb-ot-layout-common.hh
    index dcacc9cb86c..6b62732bf54 100644
    --- a/src/java.desktop/share/native/libharfbuzz/hb-ot-layout-common.hh
    +++ b/src/java.desktop/share/native/libharfbuzz/hb-ot-layout-common.hh
    @@ -2480,7 +2480,7 @@ struct VarRegionAxis
         /* TODO Move these to sanitize(). */
         if (unlikely (start > peak || peak > end))
           return 1.f;
    -    if (unlikely (start < 0 && end > 0 && peak != 0))
    +    if (unlikely (start < 0 && end > 0))
           return 1.f;
     
         if (coord <= start || end <= coord)
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
    index 2e035d12453..26686e59b0b 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2000, 2026, 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
    @@ -286,13 +286,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -325,6 +326,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -357,6 +362,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -389,6 +398,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -536,15 +548,14 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               sp = sl;
               dp = dl;
     
    -          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    -          p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
               if (kw == 7) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -583,6 +594,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -618,6 +635,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -653,6 +676,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -688,6 +715,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = buff[0]; p3 = buff[1];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -723,6 +754,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 2)*/ {
     
    +            p2 = buff[0];
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -756,6 +791,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    @@ -882,17 +919,16 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                 if (kw > MAX_KER) kw = kw/2;
               off += kw;
     
    -          p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    -          p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
    -          sp += (kw - 1)*chan1;
    -
               if (kw == 7) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -927,6 +963,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -961,6 +1005,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -995,6 +1047,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -1029,6 +1087,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = sp[0]; p3 = sp[chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -1063,6 +1127,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 2) {
     
    +            p2 = sp[0];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -1097,6 +1167,10 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 1)*/ {
     
    +            k0 = pk[0];
    +
    +            sp += (kw - 1)*chan1;
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = sp[0];
    @@ -1127,6 +1201,8 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +        pk += kw;
             }
           }
     
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
    index bb264d9dcd2..b2ee9742213 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2000, 2026, 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
    @@ -158,13 +158,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -195,6 +196,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -225,6 +230,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -255,6 +264,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -400,15 +412,14 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               sp = sl;
               dp = dl;
     
    -          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    -          p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
               if (kw == 7) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -444,6 +455,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -479,6 +496,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -514,6 +537,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -549,6 +576,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = buff[0]; p3 = buff[1];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -584,6 +615,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else { /* kw == 2 */
     
    +            p2 = buff[0];
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -617,6 +652,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
    index c144404b0f4..ce7cac00f72 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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
    @@ -287,13 +287,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -326,6 +327,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -358,6 +363,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -390,6 +399,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -537,15 +549,14 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               sp = sl;
               dp = dl;
     
    -          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    -          p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
               if (kw == 7) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -584,6 +595,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -619,6 +636,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -654,6 +677,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -689,6 +716,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = buff[0]; p3 = buff[1];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -724,6 +755,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 2)*/ {
     
    +            p2 = buff[0];
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -757,6 +792,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    @@ -883,17 +920,16 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                 if (kw > MAX_KER) kw = kw/2;
               off += kw;
     
    -          p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    -          p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
    -          sp += (kw - 1)*chan1;
    -
               if (kw == 7) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -928,6 +964,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -962,6 +1006,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -996,6 +1048,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -1030,6 +1088,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = sp[0]; p3 = sp[chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -1064,6 +1128,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 2) {
     
    +            p2 = sp[0];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -1098,6 +1168,10 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 1)*/ {
     
    +            k0 = pk[0];
    +
    +            sp += (kw - 1)*chan1;
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = sp[0];
    @@ -1128,6 +1202,8 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
    index 54e11c64a49..389c1b52c1e 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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
    @@ -150,13 +150,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -184,6 +185,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -211,6 +216,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -238,6 +247,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -322,17 +334,16 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               if (kw > 2*MAX_KER) kw = MAX_KER; else
                 if (kw > MAX_KER) kw = kw/2;
     
    -          p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    -          sp0 += chan3;
    -          p5 = sp0[0]; p6 = sp0[chan1]; p7 = sp0[chan2];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -
               dp = dl;
     
               if (kw == 7) {
    +
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0]; p6 = sp0[chan1]; p7 = sp0[chan2];
                 sp = sp0 += chan3;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -362,7 +373,13 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 6) {
    +
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0]; p6 = sp0[chan1];
                 sp = sp0 += chan2;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -392,7 +409,13 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 5) {
    +
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0];
                 sp = sp0 += chan1;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -423,7 +446,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
                 sp = sp0;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -453,7 +479,11 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 3) {
    +
    +            p2 = sp0[0]; p3 = sp0[chan1];
    +            sp0 += chan3;
                 sp = sp0 -= chan1;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -483,7 +513,11 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else { /* kw == 2 */
    +
    +            p2 = sp0[0];
    +            sp0 += chan3;
                 sp = sp0 -= chan2;
    +            k0 = pk[0]; k1 = pk[1];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
    index e87607ddf12..e6c68de5054 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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
    @@ -150,13 +150,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -184,6 +185,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -211,6 +216,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -238,6 +247,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -322,17 +334,15 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               if (kw > 2*MAX_KER) kw = MAX_KER; else
                 if (kw > MAX_KER) kw = kw/2;
     
    -          p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    -          sp0 += chan3;
    -          p5 = sp0[0]; p6 = sp0[chan1]; p7 = sp0[chan2];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -
               dp = dl;
     
               if (kw == 7) {
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0]; p6 = sp0[chan1]; p7 = sp0[chan2];
                 sp = sp0 += chan3;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -362,7 +372,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 6) {
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0]; p6 = sp0[chan1];
                 sp = sp0 += chan2;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -392,7 +407,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 5) {
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
    +            p5 = sp0[0];
                 sp = sp0 += chan1;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -423,7 +443,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2];
    +            sp0 += chan3;
                 sp = sp0;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -453,7 +476,11 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else if (kw == 3) {
    +
    +            p2 = sp0[0]; p3 = sp0[chan1];
    +            sp0 += chan3;
                 sp = sp0 -= chan1;
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    @@ -483,7 +510,11 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                 }
     
               } else { /* kw == 2 */
    +
    +            p2 = sp0[0];
    +            sp0 += chan3;
                 sp = sp0 -= chan2;
    +            k0 = pk[0]; k1 = pk[1];
     
                 if (pk == k) {
                   for (i = 0; i <= (wid - 2); i += 2) {
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
    index 49412c7d7ef..438531e2c07 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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
    @@ -286,13 +286,14 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
             pk = k + off;
             sp = sl0;
     
    -        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    -
             dp = dl;
             kh = n - off;
     
             if (kh == 4) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
    +
               sp += 3*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -325,6 +326,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 3) {
    +
    +          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +          p2 = sp[0]; p3 = sp[sll];
    +
               sp += 2*sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -357,6 +362,10 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else if (kh == 2) {
    +
    +          k0 = pk[0]; k1 = pk[1];
    +          p2 = sp[0];
    +
               sp += sll;
     
               for (j = 0; j <= (hsize - 2); j += 2) {
    @@ -389,6 +398,9 @@ static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
               }
     
             } else /* if (kh == 1) */ {
    +
    +          k0 = pk[0];
    +
               for (j = 0; j < hsize; j++) {
                 p0 = sp[0];
     
    @@ -536,15 +548,14 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
               sp = sl;
               dp = dl;
     
    -          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    -          p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
               if (kw == 7) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -583,6 +594,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3]; p6 = buff[4];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -618,6 +635,12 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +            p5 = buff[3];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -653,6 +676,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -688,6 +715,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = buff[0]; p3 = buff[1];
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -723,6 +754,10 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 2)*/ {
     
    +            p2 = buff[0];
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -756,6 +791,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    @@ -882,17 +919,16 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                 if (kw > MAX_KER) kw = kw/2;
               off += kw;
     
    -          p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    -          p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    -
    -          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    -          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    -          pk += kw;
    -
    -          sp += (kw - 1)*chan1;
    -
               if (kw == 7) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
    @@ -927,6 +963,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 6) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4]; k5 = pk[5];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
    @@ -961,6 +1005,14 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 5) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +            p5 = sp[chan2 + chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +            k4 = pk[4];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4; p3 = p5;
    @@ -995,6 +1047,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 4) {
     
    +            p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3; p2 = p4;
    @@ -1029,6 +1087,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 3) {
     
    +            p2 = sp[0]; p3 = sp[chan1];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2; p1 = p3;
    @@ -1063,6 +1127,12 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else if (kw == 2) {
     
    +            p2 = sp[0];
    +
    +            sp += (kw - 1)*chan1;
    +
    +            k0 = pk[0]; k1 = pk[1];
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = p2;
    @@ -1097,6 +1167,10 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
     
               } else /*if (kw == 1)*/ {
     
    +            k0 = pk[0];
    +
    +            sp += (kw - 1)*chan1;
    +
                 if (l < (n - 1) || off < m) {
                   for (i = 0; i <= (wid - 2); i += 2) {
                     p0 = sp[0];
    @@ -1127,6 +1201,8 @@ mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
                   }
                 }
               }
    +
    +          pk += kw;
             }
           }
     
    diff --git a/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConvVersion.c b/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConvVersion.c
    index 5f8768fb180..b7e685609c9 100644
    --- a/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConvVersion.c
    +++ b/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConvVersion.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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,7 +51,7 @@ mlib_s32 mlib_ImageConvVersion(mlib_s32 m,
                                    mlib_s32 scale,
                                    mlib_type type)
     {
    -  mlib_d64 dscale = 1.0 / (1 << scale); /* 16 < scale <= 31 */
    +  mlib_d64 dscale = 1.0 / (((mlib_s64)1) << scale); /* 16 < scale <= 31 */
     
       if (type == MLIB_BYTE) {
         if ((m * n * dscale * 32768.0) > MAX_U8)
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/COPYING b/src/java.desktop/share/native/libsplashscreen/giflib/COPYING
    index b9c0b501260..92774a3b036 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/COPYING
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/COPYING
    @@ -1,4 +1,4 @@
    -The GIFLIB distribution is Copyright (c) 1997  Eric S. Raymond
    += MIT LICENSE
     
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c b/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
    index 0b2860b4b50..2fa005ed20d 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c
    @@ -30,9 +30,9 @@ The functions here and in egif_lib.c are partitioned carefully so that
     if you only require one of read and write capability, only one of these
     two modules will be linked.  Preserve this property!
     
    -SPDX-License-Identifier: MIT
    -
     *****************************************************************************/
    +// SPDX-License-Identifier: MIT
    +// SPDX-FileCopyrightText: Copyright (C) Eric S. Raymond 
     
     #include 
     #include 
    @@ -55,11 +55,11 @@ SPDX-License-Identifier: MIT
     
     /* avoid extra function call in case we use fread (TVT) */
     static int InternalRead(GifFileType *gif, GifByteType *buf, int len) {
    -    // fprintf(stderr, "### Read: %d\n", len);
    -    return (((GifFilePrivateType *)gif->Private)->Read
    -                ? ((GifFilePrivateType *)gif->Private)->Read(gif, buf, len)
    -                : fread(buf, 1, len,
    -                        ((GifFilePrivateType *)gif->Private)->File));
    +        // fprintf(stderr, "### Read: %d\n", len);
    +        return (((GifFilePrivateType *)gif->Private)->Read
    +                    ? ((GifFilePrivateType *)gif->Private)->Read(gif, buf, len)
    +                    : fread(buf, 1, len,
    +                            ((GifFilePrivateType *)gif->Private)->File));
     }
     
     static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
    @@ -78,18 +78,18 @@ static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
      info record.
     ******************************************************************************/
     GifFileType *DGifOpenFileName(const char *FileName, int *Error) {
    -    int FileHandle;
    -    GifFileType *GifFile;
    +        int FileHandle;
    +        GifFileType *GifFile;
     
    -    if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_OPEN_FAILED;
    +        if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_OPEN_FAILED;
    +                }
    +                return NULL;
             }
    -        return NULL;
    -    }
     
    -    GifFile = DGifOpenFileHandle(FileHandle, Error);
    -    return GifFile;
    +        GifFile = DGifOpenFileHandle(FileHandle, Error);
    +        return GifFile;
     }
     
     /******************************************************************************
    @@ -98,171 +98,171 @@ GifFileType *DGifOpenFileName(const char *FileName, int *Error) {
      info record.
     ******************************************************************************/
     GifFileType *DGifOpenFileHandle(int FileHandle, int *Error) {
    -    char Buf[GIF_STAMP_LEN + 1];
    -    GifFileType *GifFile;
    -    GifFilePrivateType *Private;
    -    FILE *f;
    +        char Buf[GIF_STAMP_LEN + 1];
    +        GifFileType *GifFile;
    +        GifFilePrivateType *Private;
    +        FILE *f;
     
    -    GifFile = (GifFileType *)malloc(sizeof(GifFileType));
    -    if (GifFile == NULL) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +        GifFile = (GifFileType *)malloc(sizeof(GifFileType));
    +        if (GifFile == NULL) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                }
    +                (void)close(FileHandle);
    +                return NULL;
             }
    -        (void)close(FileHandle);
    -        return NULL;
    -    }
     
    -    /*@i1@*/ memset(GifFile, '\0', sizeof(GifFileType));
    +        /*@i1@*/ memset(GifFile, '\0', sizeof(GifFileType));
     
    -    /* Belt and suspenders, in case the null pointer isn't zero */
    -    GifFile->SavedImages = NULL;
    -    GifFile->SColorMap = NULL;
    +        /* Belt and suspenders, in case the null pointer isn't zero */
    +        GifFile->SavedImages = NULL;
    +        GifFile->SColorMap = NULL;
     
    -    Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
    -    if (Private == NULL) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +        Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
    +        if (Private == NULL) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                }
    +                (void)close(FileHandle);
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        (void)close(FileHandle);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
     
    -    /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
    +        /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
     
     #ifdef _WIN32
    -    _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
    +        _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
     #endif                                  /* _WIN32 */
     
    -    f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
    +        f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
     
    -    /*@-mustfreeonly@*/
    -    GifFile->Private = (void *)Private;
    -    Private->FileHandle = FileHandle;
    -    Private->File = f;
    -    Private->FileState = FILE_STATE_READ;
    -    Private->Read = NULL;     /* don't use alternate input method (TVT) */
    -    GifFile->UserData = NULL; /* TVT */
    -    /*@=mustfreeonly@*/
    +        /*@-mustfreeonly@*/
    +        GifFile->Private = (void *)Private;
    +        Private->FileHandle = FileHandle;
    +        Private->File = f;
    +        Private->FileState = FILE_STATE_READ;
    +        Private->Read = NULL;     /* don't use alternate input method (TVT) */
    +        GifFile->UserData = NULL; /* TVT */
    +        /*@=mustfreeonly@*/
     
    -    /* Let's see if this is a GIF file: */
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
    -        GIF_STAMP_LEN) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_READ_FAILED;
    +        /* Let's see if this is a GIF file: */
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
    +            GIF_STAMP_LEN) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_READ_FAILED;
    +                }
    +                (void)fclose(f);
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        (void)fclose(f);
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
     
    -    /* Check for GIF prefix at start of file */
    -    Buf[GIF_STAMP_LEN] = 0;
    -    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_GIF_FILE;
    +        /* Check for GIF prefix at start of file */
    +        Buf[GIF_STAMP_LEN] = 0;
    +        if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_GIF_FILE;
    +                }
    +                (void)fclose(f);
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        (void)fclose(f);
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
     
    -    if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
    -        (void)fclose(f);
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
    +        if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
    +                (void)fclose(f);
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                return NULL;
    +        }
     
    -    GifFile->Error = 0;
    +        GifFile->Error = 0;
     
    -    /* What version of GIF? */
    -    Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
    +        /* What version of GIF? */
    +        Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
     
    -    return GifFile;
    +        return GifFile;
     }
     
     /******************************************************************************
      GifFileType constructor with user supplied input function (TVT)
     ******************************************************************************/
     GifFileType *DGifOpen(void *userData, InputFunc readFunc, int *Error) {
    -    char Buf[GIF_STAMP_LEN + 1];
    -    GifFileType *GifFile;
    -    GifFilePrivateType *Private;
    +        char Buf[GIF_STAMP_LEN + 1];
    +        GifFileType *GifFile;
    +        GifFilePrivateType *Private;
     
    -    GifFile = (GifFileType *)malloc(sizeof(GifFileType));
    -    if (GifFile == NULL) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +        GifFile = (GifFileType *)malloc(sizeof(GifFileType));
    +        if (GifFile == NULL) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                }
    +                return NULL;
             }
    -        return NULL;
    -    }
     
    -    memset(GifFile, '\0', sizeof(GifFileType));
    +        memset(GifFile, '\0', sizeof(GifFileType));
     
    -    /* Belt and suspenders, in case the null pointer isn't zero */
    -    GifFile->SavedImages = NULL;
    -    GifFile->SColorMap = NULL;
    +        /* Belt and suspenders, in case the null pointer isn't zero */
    +        GifFile->SavedImages = NULL;
    +        GifFile->SColorMap = NULL;
     
    -    Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
    -    if (!Private) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +        Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
    +        if (!Private) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                }
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        free((char *)GifFile);
    -        return NULL;
    -    }
    -    /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
    +        /*@i1@*/ memset(Private, '\0', sizeof(GifFilePrivateType));
     
    -    GifFile->Private = (void *)Private;
    -    Private->FileHandle = 0;
    -    Private->File = NULL;
    -    Private->FileState = FILE_STATE_READ;
    +        GifFile->Private = (void *)Private;
    +        Private->FileHandle = 0;
    +        Private->File = NULL;
    +        Private->FileState = FILE_STATE_READ;
     
    -    Private->Read = readFunc;     /* TVT */
    -    GifFile->UserData = userData; /* TVT */
    +        Private->Read = readFunc;     /* TVT */
    +        GifFile->UserData = userData; /* TVT */
     
    -    /* Lets see if this is a GIF file: */
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
    -        GIF_STAMP_LEN) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_READ_FAILED;
    +        /* Lets see if this is a GIF file: */
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) !=
    +            GIF_STAMP_LEN) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_READ_FAILED;
    +                }
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
     
    -    /* Check for GIF prefix at start of file */
    -    Buf[GIF_STAMP_LEN] = '\0';
    -    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NOT_GIF_FILE;
    +        /* Check for GIF prefix at start of file */
    +        Buf[GIF_STAMP_LEN] = '\0';
    +        if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NOT_GIF_FILE;
    +                }
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                return NULL;
             }
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        return NULL;
    -    }
     
    -    if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
    -        free((char *)Private);
    -        free((char *)GifFile);
    -        if (Error != NULL) {
    -            *Error = D_GIF_ERR_NO_SCRN_DSCR;
    +        if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
    +                free((char *)Private);
    +                free((char *)GifFile);
    +                if (Error != NULL) {
    +                        *Error = D_GIF_ERR_NO_SCRN_DSCR;
    +                }
    +                return NULL;
             }
    -        return NULL;
    -    }
     
    -    GifFile->Error = 0;
    +        GifFile->Error = 0;
     
    -    /* What version of GIF? */
    -    Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
    +        /* What version of GIF? */
    +        Private->gif89 = (Buf[GIF_VERSION_POS + 1] == '9');
     
    -    return GifFile;
    +        return GifFile;
     }
     
     /******************************************************************************
    @@ -270,180 +270,180 @@ GifFileType *DGifOpen(void *userData, InputFunc readFunc, int *Error) {
      this routine is called automatically from DGif file open routines.
     ******************************************************************************/
     int DGifGetScreenDesc(GifFileType *GifFile) {
    -    int BitsPerPixel;
    -    bool SortFlag;
    -    GifByteType Buf[3];
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        int BitsPerPixel;
    +        bool SortFlag;
    +        GifByteType Buf[3];
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -
    -    /* Put the screen descriptor into the file: */
    -    if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR ||
    -        DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR) {
    -        return GIF_ERROR;
    -    }
    -
    -    if (InternalRead(GifFile, Buf, 3) != 3) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        GifFreeMapObject(GifFile->SColorMap);
    -        GifFile->SColorMap = NULL;
    -        return GIF_ERROR;
    -    }
    -    GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
    -    SortFlag = (Buf[0] & 0x08) != 0;
    -    BitsPerPixel = (Buf[0] & 0x07) + 1;
    -    GifFile->SBackGroundColor = Buf[1];
    -    GifFile->AspectByte = Buf[2];
    -    if (Buf[0] & 0x80) { /* Do we have global color map? */
    -        int i;
    -
    -        GifFile->SColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
    -        if (GifFile->SColorMap == NULL) {
    -            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    -            return GIF_ERROR;
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
             }
     
    -        /* Get the global color map: */
    -        GifFile->SColorMap->SortFlag = SortFlag;
    -        for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
    -            /* coverity[check_return] */
    -            if (InternalRead(GifFile, Buf, 3) != 3) {
    +        /* Put the screen descriptor into the file: */
    +        if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR ||
    +            DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR) {
    +                return GIF_ERROR;
    +        }
    +
    +        if (InternalRead(GifFile, Buf, 3) != 3) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
                     GifFreeMapObject(GifFile->SColorMap);
                     GifFile->SColorMap = NULL;
    -                GifFile->Error = D_GIF_ERR_READ_FAILED;
                     return GIF_ERROR;
    -            }
    -            GifFile->SColorMap->Colors[i].Red = Buf[0];
    -            GifFile->SColorMap->Colors[i].Green = Buf[1];
    -            GifFile->SColorMap->Colors[i].Blue = Buf[2];
             }
    -    } else {
    -        GifFile->SColorMap = NULL;
    -    }
    +        GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
    +        SortFlag = (Buf[0] & 0x08) != 0;
    +        BitsPerPixel = (Buf[0] & 0x07) + 1;
    +        GifFile->SBackGroundColor = Buf[1];
    +        GifFile->AspectByte = Buf[2];
    +        if (Buf[0] & 0x80) { /* Do we have global color map? */
    +                int i;
     
    -    /*
    -     * No check here for whether the background color is in range for the
    -     * screen color map.  Possibly there should be.
    -     */
    +                GifFile->SColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
    +                if (GifFile->SColorMap == NULL) {
    +                        GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                        return GIF_ERROR;
    +                }
     
    -    return GIF_OK;
    +                /* Get the global color map: */
    +                GifFile->SColorMap->SortFlag = SortFlag;
    +                for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
    +                        /* coverity[check_return] */
    +                        if (InternalRead(GifFile, Buf, 3) != 3) {
    +                                GifFreeMapObject(GifFile->SColorMap);
    +                                GifFile->SColorMap = NULL;
    +                                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                                return GIF_ERROR;
    +                        }
    +                        GifFile->SColorMap->Colors[i].Red = Buf[0];
    +                        GifFile->SColorMap->Colors[i].Green = Buf[1];
    +                        GifFile->SColorMap->Colors[i].Blue = Buf[2];
    +                }
    +        } else {
    +                GifFile->SColorMap = NULL;
    +        }
    +
    +        /*
    +         * No check here for whether the background color is in range for the
    +         * screen color map.  Possibly there should be.
    +         */
    +
    +        return GIF_OK;
     }
     
     const char *DGifGetGifVersion(GifFileType *GifFile) {
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (Private->gif89) {
    -        return GIF89_STAMP;
    -    } else {
    -        return GIF87_STAMP;
    -    }
    +        if (Private->gif89) {
    +                return GIF89_STAMP;
    +        } else {
    +                return GIF87_STAMP;
    +        }
     }
     
     /******************************************************************************
      This routine should be called before any attempt to read an image.
     ******************************************************************************/
     int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type) {
    -    GifByteType Buf;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType Buf;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
    +        }
     
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, &Buf, 1) != 1) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR;
    -    }
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, &Buf, 1) != 1) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR;
    +        }
     
    -    // fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
    -    switch (Buf) {
    -    case DESCRIPTOR_INTRODUCER:
    -        *Type = IMAGE_DESC_RECORD_TYPE;
    -        break;
    -    case EXTENSION_INTRODUCER:
    -        *Type = EXTENSION_RECORD_TYPE;
    -        break;
    -    case TERMINATOR_INTRODUCER:
    -        *Type = TERMINATE_RECORD_TYPE;
    -        break;
    -    default:
    -        *Type = UNDEFINED_RECORD_TYPE;
    -        GifFile->Error = D_GIF_ERR_WRONG_RECORD;
    -        return GIF_ERROR;
    -    }
    +        // fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
    +        switch (Buf) {
    +        case DESCRIPTOR_INTRODUCER:
    +                *Type = IMAGE_DESC_RECORD_TYPE;
    +                break;
    +        case EXTENSION_INTRODUCER:
    +                *Type = EXTENSION_RECORD_TYPE;
    +                break;
    +        case TERMINATOR_INTRODUCER:
    +                *Type = TERMINATE_RECORD_TYPE;
    +                break;
    +        default:
    +                *Type = UNDEFINED_RECORD_TYPE;
    +                GifFile->Error = D_GIF_ERR_WRONG_RECORD;
    +                return GIF_ERROR;
    +        }
     
    -    return GIF_OK;
    +        return GIF_OK;
     }
     
     int DGifGetImageHeader(GifFileType *GifFile) {
    -    unsigned int BitsPerPixel;
    -    GifByteType Buf[3];
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        unsigned int BitsPerPixel;
    +        GifByteType Buf[3];
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -
    -    if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR ||
    -        DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR ||
    -        DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
    -        DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR) {
    -        return GIF_ERROR;
    -    }
    -    if (InternalRead(GifFile, Buf, 1) != 1) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        GifFreeMapObject(GifFile->Image.ColorMap);
    -        GifFile->Image.ColorMap = NULL;
    -        return GIF_ERROR;
    -    }
    -    BitsPerPixel = (Buf[0] & 0x07) + 1;
    -    GifFile->Image.Interlace = (Buf[0] & 0x40) ? true : false;
    -
    -    /* Setup the colormap */
    -    if (GifFile->Image.ColorMap) {
    -        GifFreeMapObject(GifFile->Image.ColorMap);
    -        GifFile->Image.ColorMap = NULL;
    -    }
    -    /* Does this image have local color map? */
    -    if (Buf[0] & 0x80) {
    -        unsigned int i;
    -
    -        GifFile->Image.ColorMap =
    -            GifMakeMapObject(1 << BitsPerPixel, NULL);
    -        if (GifFile->Image.ColorMap == NULL) {
    -            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    -            return GIF_ERROR;
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
             }
     
    -        /* Get the image local color map: */
    -        for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
    -            /* coverity[check_return] */
    -            if (InternalRead(GifFile, Buf, 3) != 3) {
    -                GifFreeMapObject(GifFile->Image.ColorMap);
    +        if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR ||
    +            DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR ||
    +            DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
    +            DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR) {
    +                return GIF_ERROR;
    +        }
    +        if (InternalRead(GifFile, Buf, 1) != 1) {
                     GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                GifFreeMapObject(GifFile->Image.ColorMap);
                     GifFile->Image.ColorMap = NULL;
                     return GIF_ERROR;
    -            }
    -            GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
    -            GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
    -            GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
             }
    -    }
    +        BitsPerPixel = (Buf[0] & 0x07) + 1;
    +        GifFile->Image.Interlace = (Buf[0] & 0x40) ? true : false;
     
    -    Private->PixelCount =
    -        (long)GifFile->Image.Width * (long)GifFile->Image.Height;
    +        /* Setup the colormap */
    +        if (GifFile->Image.ColorMap) {
    +                GifFreeMapObject(GifFile->Image.ColorMap);
    +                GifFile->Image.ColorMap = NULL;
    +        }
    +        /* Does this image have local color map? */
    +        if (Buf[0] & 0x80) {
    +                unsigned int i;
     
    -    /* Reset decompress algorithm parameters. */
    -    return DGifSetupDecompress(GifFile);
    +                GifFile->Image.ColorMap =
    +                    GifMakeMapObject(1 << BitsPerPixel, NULL);
    +                if (GifFile->Image.ColorMap == NULL) {
    +                        GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                        return GIF_ERROR;
    +                }
    +
    +                /* Get the image local color map: */
    +                for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
    +                        /* coverity[check_return] */
    +                        if (InternalRead(GifFile, Buf, 3) != 3) {
    +                                GifFreeMapObject(GifFile->Image.ColorMap);
    +                                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                                GifFile->Image.ColorMap = NULL;
    +                                return GIF_ERROR;
    +                        }
    +                        GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
    +                        GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
    +                        GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
    +                }
    +        }
    +
    +        Private->PixelCount =
    +            (long)GifFile->Image.Width * (long)GifFile->Image.Height;
    +
    +        /* Reset decompress algorithm parameters. */
    +        return DGifSetupDecompress(GifFile);
     }
     
     /******************************************************************************
    @@ -451,133 +451,135 @@ int DGifGetImageHeader(GifFileType *GifFile) {
      Note it is assumed the Image desc. header has been read.
     ******************************************************************************/
     int DGifGetImageDesc(GifFileType *GifFile) {
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    -    SavedImage *sp;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        SavedImage *sp;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -
    -    if (DGifGetImageHeader(GifFile) == GIF_ERROR) {
    -        return GIF_ERROR;
    -    }
    -
    -    if (GifFile->SavedImages) {
    -        SavedImage *new_saved_images = (SavedImage *)reallocarray(
    -            GifFile->SavedImages, (GifFile->ImageCount + 1),
    -            sizeof(SavedImage));
    -        if (new_saved_images == NULL) {
    -            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    -            return GIF_ERROR;
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
             }
    -        GifFile->SavedImages = new_saved_images;
    -    } else {
    -        if ((GifFile->SavedImages =
    -                 (SavedImage *)malloc(sizeof(SavedImage))) == NULL) {
    -            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    -            return GIF_ERROR;
    +
    +        if (DGifGetImageHeader(GifFile) == GIF_ERROR) {
    +                return GIF_ERROR;
             }
    -    }
     
    -    sp = &GifFile->SavedImages[GifFile->ImageCount];
    -    memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
    -    if (GifFile->Image.ColorMap != NULL) {
    -        sp->ImageDesc.ColorMap =
    -            GifMakeMapObject(GifFile->Image.ColorMap->ColorCount,
    -                             GifFile->Image.ColorMap->Colors);
    -        if (sp->ImageDesc.ColorMap == NULL) {
    -            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    -            return GIF_ERROR;
    +        if (GifFile->SavedImages) {
    +                SavedImage *new_saved_images = (SavedImage *)reallocarray(
    +                    GifFile->SavedImages, (GifFile->ImageCount + 1),
    +                    sizeof(SavedImage));
    +                if (new_saved_images == NULL) {
    +                        GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                        return GIF_ERROR;
    +                }
    +                GifFile->SavedImages = new_saved_images;
    +        } else {
    +                if ((GifFile->SavedImages =
    +                         (SavedImage *)malloc(sizeof(SavedImage))) == NULL) {
    +                        GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                        return GIF_ERROR;
    +                }
             }
    -    }
    -    sp->RasterBits = (unsigned char *)NULL;
    -    sp->ExtensionBlockCount = 0;
    -    sp->ExtensionBlocks = (ExtensionBlock *)NULL;
     
    -    GifFile->ImageCount++;
    +        sp = &GifFile->SavedImages[GifFile->ImageCount];
    +        memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
    +        if (GifFile->Image.ColorMap != NULL) {
    +                sp->ImageDesc.ColorMap =
    +                    GifMakeMapObject(GifFile->Image.ColorMap->ColorCount,
    +                                     GifFile->Image.ColorMap->Colors);
    +                if (sp->ImageDesc.ColorMap == NULL) {
    +                        GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
    +                        return GIF_ERROR;
    +                }
    +        }
    +        sp->RasterBits = (unsigned char *)NULL;
    +        sp->ExtensionBlockCount = 0;
    +        sp->ExtensionBlocks = (ExtensionBlock *)NULL;
     
    -    return GIF_OK;
    +        GifFile->ImageCount++;
    +
    +        return GIF_OK;
     }
     
     /******************************************************************************
      Get one full scanned line (Line) of length LineLen from GIF file.
     ******************************************************************************/
     int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) {
    -    GifByteType *Dummy;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType *Dummy;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -
    -    if (!LineLen) {
    -        LineLen = GifFile->Image.Width;
    -    }
    -
    -    if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
    -        GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
    -        return GIF_ERROR;
    -    }
    -
    -    if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
    -        if (Private->PixelCount == 0) {
    -            /* We probably won't be called any more, so let's clean
    -             * up everything before we return: need to flush out all
    -             * the rest of image until an empty block (size 0)
    -             * detected. We use GetCodeNext.
    -             */
    -            do {
    -                if (DGifGetCodeNext(GifFile, &Dummy) ==
    -                    GIF_ERROR) {
    -                    return GIF_ERROR;
    -                }
    -            } while (Dummy != NULL);
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
    +        }
    +
    +        if (!LineLen) {
    +                LineLen = GifFile->Image.Width;
    +        }
    +
    +        if (LineLen < 0 || Private->PixelCount < (unsigned long)LineLen) {
    +                GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
    +                return GIF_ERROR;
    +        }
    +        Private->PixelCount -= LineLen;
    +
    +        if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
    +                if (Private->PixelCount == 0) {
    +                        /* We probably won't be called any more, so let's clean
    +                         * up everything before we return: need to flush out all
    +                         * the rest of image until an empty block (size 0)
    +                         * detected. We use GetCodeNext.
    +                         */
    +                        do {
    +                                if (DGifGetCodeNext(GifFile, &Dummy) ==
    +                                    GIF_ERROR) {
    +                                        return GIF_ERROR;
    +                                }
    +                        } while (Dummy != NULL);
    +                }
    +                return GIF_OK;
    +        } else {
    +                return GIF_ERROR;
             }
    -        return GIF_OK;
    -    } else {
    -        return GIF_ERROR;
    -    }
     }
     
     /******************************************************************************
      Put one pixel (Pixel) into GIF file.
     ******************************************************************************/
     int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) {
    -    GifByteType *Dummy;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType *Dummy;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -    if (--Private->PixelCount > 0xffff0000UL) {
    -        GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
    -        return GIF_ERROR;
    -    }
    -
    -    if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
    -        if (Private->PixelCount == 0) {
    -            /* We probably won't be called any more, so let's clean
    -             * up everything before we return: need to flush out all
    -             * the rest of image until an empty block (size 0)
    -             * detected. We use GetCodeNext.
    -             */
    -            do {
    -                if (DGifGetCodeNext(GifFile, &Dummy) ==
    -                    GIF_ERROR) {
    -                    return GIF_ERROR;
    -                }
    -            } while (Dummy != NULL);
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
    +        }
    +        if (Private->PixelCount == 0) {
    +                GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
    +                return GIF_ERROR;
    +        }
    +        Private->PixelCount --;
    +
    +        if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
    +                if (Private->PixelCount == 0) {
    +                        /* We probably won't be called any more, so let's clean
    +                         * up everything before we return: need to flush out all
    +                         * the rest of image until an empty block (size 0)
    +                         * detected. We use GetCodeNext.
    +                         */
    +                        do {
    +                                if (DGifGetCodeNext(GifFile, &Dummy) ==
    +                                    GIF_ERROR) {
    +                                        return GIF_ERROR;
    +                                }
    +                        } while (Dummy != NULL);
    +                }
    +                return GIF_OK;
    +        } else {
    +                return GIF_ERROR;
             }
    -        return GIF_OK;
    -    } else {
    -        return GIF_ERROR;
    -    }
     }
     
     /******************************************************************************
    @@ -589,26 +591,26 @@ int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) {
     ******************************************************************************/
     int DGifGetExtension(GifFileType *GifFile, int *ExtCode,
                          GifByteType **Extension) {
    -    GifByteType Buf;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType Buf;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    // fprintf(stderr, "### -> DGifGetExtension:\n");
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    +        // fprintf(stderr, "### -> DGifGetExtension:\n");
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
    +        }
     
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, &Buf, 1) != 1) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR;
    -    }
    -    *ExtCode = Buf;
    -    // fprintf(stderr, "### <- DGifGetExtension: %02x, about to call
    -    // next\n", Buf);
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, &Buf, 1) != 1) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR;
    +        }
    +        *ExtCode = Buf;
    +        // fprintf(stderr, "### <- DGifGetExtension: %02x, about to call
    +        // next\n", Buf);
     
    -    return DGifGetExtensionNext(GifFile, Extension);
    +        return DGifGetExtensionNext(GifFile, Extension);
     }
     
     /******************************************************************************
    @@ -617,31 +619,31 @@ int DGifGetExtension(GifFileType *GifFile, int *ExtCode,
      The Extension should NOT be freed by the user (not dynamically allocated).
     ******************************************************************************/
     int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) {
    -    GifByteType Buf;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType Buf;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    // fprintf(stderr, "### -> DGifGetExtensionNext\n");
    -    if (InternalRead(GifFile, &Buf, 1) != 1) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR;
    -    }
    -    // fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
    -
    -    if (Buf > 0) {
    -        *Extension = Private->Buf; /* Use private unused buffer. */
    -        (*Extension)[0] =
    -            Buf; /* Pascal strings notation (pos. 0 is len.). */
    -                 /* coverity[tainted_data,check_return] */
    -        if (InternalRead(GifFile, &((*Extension)[1]), Buf) != Buf) {
    -            GifFile->Error = D_GIF_ERR_READ_FAILED;
    -            return GIF_ERROR;
    +        // fprintf(stderr, "### -> DGifGetExtensionNext\n");
    +        if (InternalRead(GifFile, &Buf, 1) != 1) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR;
             }
    -    } else {
    -        *Extension = NULL;
    -    }
    -    // fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
    +        // fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
     
    -    return GIF_OK;
    +        if (Buf > 0) {
    +                *Extension = Private->Buf; /* Use private unused buffer. */
    +                (*Extension)[0] =
    +                    Buf; /* Pascal strings notation (pos. 0 is len.). */
    +                         /* coverity[tainted_data,check_return] */
    +                if (InternalRead(GifFile, &((*Extension)[1]), Buf) != Buf) {
    +                        GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                        return GIF_ERROR;
    +                }
    +        } else {
    +                *Extension = NULL;
    +        }
    +        // fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
    +
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -651,21 +653,21 @@ int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) {
     int DGifExtensionToGCB(const size_t GifExtensionLength,
                            const GifByteType *GifExtension,
                            GraphicsControlBlock *GCB) {
    -    if (GifExtensionLength != 4) {
    -        return GIF_ERROR;
    -    }
    +        if (GifExtensionLength != 4) {
    +                return GIF_ERROR;
    +        }
     
    -    GCB->DisposalMode = (GifExtension[0] >> 2) & 0x07;
    -    GCB->UserInputFlag = (GifExtension[0] & 0x02) != 0;
    -    GCB->DelayTime =
    -        UNSIGNED_LITTLE_ENDIAN(GifExtension[1], GifExtension[2]);
    -    if (GifExtension[0] & 0x01) {
    -        GCB->TransparentColor = (int)GifExtension[3];
    -    } else {
    -        GCB->TransparentColor = NO_TRANSPARENT_COLOR;
    -    }
    +        GCB->DisposalMode = (GifExtension[0] >> 2) & 0x07;
    +        GCB->UserInputFlag = (GifExtension[0] & 0x02) != 0;
    +        GCB->DelayTime =
    +            UNSIGNED_LITTLE_ENDIAN(GifExtension[1], GifExtension[2]);
    +        if (GifExtension[0] & 0x01) {
    +                GCB->TransparentColor = (int)GifExtension[3];
    +        } else {
    +                GCB->TransparentColor = NO_TRANSPARENT_COLOR;
    +        }
     
    -    return GIF_OK;
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -674,101 +676,101 @@ int DGifExtensionToGCB(const size_t GifExtensionLength,
     
     int DGifSavedExtensionToGCB(GifFileType *GifFile, int ImageIndex,
                                 GraphicsControlBlock *GCB) {
    -    int i;
    +        int i;
     
    -    if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1) {
    -        return GIF_ERROR;
    -    }
    -
    -    GCB->DisposalMode = DISPOSAL_UNSPECIFIED;
    -    GCB->UserInputFlag = false;
    -    GCB->DelayTime = 0;
    -    GCB->TransparentColor = NO_TRANSPARENT_COLOR;
    -
    -    for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount;
    -         i++) {
    -        ExtensionBlock *ep =
    -            &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
    -        if (ep->Function == GRAPHICS_EXT_FUNC_CODE) {
    -            return DGifExtensionToGCB(ep->ByteCount, ep->Bytes,
    -                                      GCB);
    +        if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1) {
    +                return GIF_ERROR;
             }
    -    }
     
    -    return GIF_ERROR;
    +        GCB->DisposalMode = DISPOSAL_UNSPECIFIED;
    +        GCB->UserInputFlag = false;
    +        GCB->DelayTime = 0;
    +        GCB->TransparentColor = NO_TRANSPARENT_COLOR;
    +
    +        for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount;
    +             i++) {
    +                ExtensionBlock *ep =
    +                    &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
    +                if (ep->Function == GRAPHICS_EXT_FUNC_CODE) {
    +                        return DGifExtensionToGCB(ep->ByteCount, ep->Bytes,
    +                                                  GCB);
    +                }
    +        }
    +
    +        return GIF_ERROR;
     }
     
     /******************************************************************************
      This routine should be called last, to close the GIF file.
     ******************************************************************************/
     int DGifCloseFile(GifFileType *GifFile, int *ErrorCode) {
    -    GifFilePrivateType *Private;
    +        GifFilePrivateType *Private;
     
    -    if (GifFile == NULL || GifFile->Private == NULL) {
    -        return GIF_ERROR;
    -    }
    -
    -    if (GifFile->Image.ColorMap) {
    -        GifFreeMapObject(GifFile->Image.ColorMap);
    -        GifFile->Image.ColorMap = NULL;
    -    }
    -
    -    if (GifFile->SColorMap) {
    -        GifFreeMapObject(GifFile->SColorMap);
    -        GifFile->SColorMap = NULL;
    -    }
    -
    -    if (GifFile->SavedImages) {
    -        GifFreeSavedImages(GifFile);
    -        GifFile->SavedImages = NULL;
    -    }
    -
    -    GifFreeExtensions(&GifFile->ExtensionBlockCount,
    -                      &GifFile->ExtensionBlocks);
    -
    -    Private = (GifFilePrivateType *)GifFile->Private;
    -
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        if (ErrorCode != NULL) {
    -            *ErrorCode = D_GIF_ERR_NOT_READABLE;
    +        if (GifFile == NULL || GifFile->Private == NULL) {
    +                return GIF_ERROR;
             }
    +
    +        if (GifFile->Image.ColorMap) {
    +                GifFreeMapObject(GifFile->Image.ColorMap);
    +                GifFile->Image.ColorMap = NULL;
    +        }
    +
    +        if (GifFile->SColorMap) {
    +                GifFreeMapObject(GifFile->SColorMap);
    +                GifFile->SColorMap = NULL;
    +        }
    +
    +        if (GifFile->SavedImages) {
    +                GifFreeSavedImages(GifFile);
    +                GifFile->SavedImages = NULL;
    +        }
    +
    +        GifFreeExtensions(&GifFile->ExtensionBlockCount,
    +                          &GifFile->ExtensionBlocks);
    +
    +        Private = (GifFilePrivateType *)GifFile->Private;
    +
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                if (ErrorCode != NULL) {
    +                        *ErrorCode = D_GIF_ERR_NOT_READABLE;
    +                }
    +                free((char *)GifFile->Private);
    +                free(GifFile);
    +                return GIF_ERROR;
    +        }
    +
    +        if (Private->File && (fclose(Private->File) != 0)) {
    +                if (ErrorCode != NULL) {
    +                        *ErrorCode = D_GIF_ERR_CLOSE_FAILED;
    +                }
    +                free((char *)GifFile->Private);
    +                free(GifFile);
    +                return GIF_ERROR;
    +        }
    +
             free((char *)GifFile->Private);
             free(GifFile);
    -        return GIF_ERROR;
    -    }
    -
    -    if (Private->File && (fclose(Private->File) != 0)) {
             if (ErrorCode != NULL) {
    -            *ErrorCode = D_GIF_ERR_CLOSE_FAILED;
    +                *ErrorCode = D_GIF_SUCCEEDED;
             }
    -        free((char *)GifFile->Private);
    -        free(GifFile);
    -        return GIF_ERROR;
    -    }
    -
    -    free((char *)GifFile->Private);
    -    free(GifFile);
    -    if (ErrorCode != NULL) {
    -        *ErrorCode = D_GIF_SUCCEEDED;
    -    }
    -    return GIF_OK;
    +        return GIF_OK;
     }
     
     /******************************************************************************
      Get 2 bytes (word) from the given file:
     ******************************************************************************/
     static int DGifGetWord(GifFileType *GifFile, GifWord *Word) {
    -    unsigned char c[2];
    +        unsigned char c[2];
     
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, c, 2) != 2) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR;
    -    }
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, c, 2) != 2) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR;
    +        }
     
    -    *Word = (GifWord)UNSIGNED_LITTLE_ENDIAN(c[0], c[1]);
    -    return GIF_OK;
    +        *Word = (GifWord)UNSIGNED_LITTLE_ENDIAN(c[0], c[1]);
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -779,17 +781,17 @@ static int DGifGetWord(GifFileType *GifFile, GifWord *Word) {
      The block should NOT be freed by the user (not dynamically allocated).
     ******************************************************************************/
     int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock) {
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
    +                return GIF_ERROR;
    +        }
     
    -    *CodeSize = Private->BitsPerPixel;
    +        *CodeSize = Private->BitsPerPixel;
     
    -    return DGifGetCodeNext(GifFile, CodeBlock);
    +        return DGifGetCodeNext(GifFile, CodeBlock);
     }
     
     /******************************************************************************
    @@ -798,78 +800,78 @@ int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock) {
      The block should NOT be freed by the user (not dynamically allocated).
     ******************************************************************************/
     int DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock) {
    -    GifByteType Buf;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType Buf;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    /* coverity[tainted_data_argument] */
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, &Buf, 1) != 1) {
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR;
    -    }
    -
    -    /* coverity[lower_bounds] */
    -    if (Buf > 0) {
    -        *CodeBlock = Private->Buf; /* Use private unused buffer. */
    -        (*CodeBlock)[0] =
    -            Buf; /* Pascal strings notation (pos. 0 is len.). */
    -                 /* coverity[tainted_data] */
    -        if (InternalRead(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
    -            GifFile->Error = D_GIF_ERR_READ_FAILED;
    -            return GIF_ERROR;
    +        /* coverity[tainted_data_argument] */
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, &Buf, 1) != 1) {
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR;
             }
    -    } else {
    -        *CodeBlock = NULL;
    -        Private->Buf[0] = 0; /* Make sure the buffer is empty! */
    -        Private->PixelCount =
    -            0; /* And local info. indicate image read. */
    -    }
     
    -    return GIF_OK;
    +        /* coverity[lower_bounds] */
    +        if (Buf > 0) {
    +                *CodeBlock = Private->Buf; /* Use private unused buffer. */
    +                (*CodeBlock)[0] =
    +                    Buf; /* Pascal strings notation (pos. 0 is len.). */
    +                         /* coverity[tainted_data] */
    +                if (InternalRead(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
    +                        GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                        return GIF_ERROR;
    +                }
    +        } else {
    +                *CodeBlock = NULL;
    +                Private->Buf[0] = 0; /* Make sure the buffer is empty! */
    +                Private->PixelCount =
    +                    0; /* And local info. indicate image read. */
    +        }
    +
    +        return GIF_OK;
     }
     
     /******************************************************************************
      Setup the LZ decompression for this image:
     ******************************************************************************/
     static int DGifSetupDecompress(GifFileType *GifFile) {
    -    int i, BitsPerPixel;
    -    GifByteType CodeSize;
    -    GifPrefixType *Prefix;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        int i, BitsPerPixel;
    +        GifByteType CodeSize;
    +        GifPrefixType *Prefix;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    /* coverity[check_return] */
    -    if (InternalRead(GifFile, &CodeSize, 1) <
    -        1) { /* Read Code size from file. */
    -        GifFile->Error = D_GIF_ERR_READ_FAILED;
    -        return GIF_ERROR; /* Failed to read Code size. */
    -    }
    -    BitsPerPixel = CodeSize;
    +        /* coverity[check_return] */
    +        if (InternalRead(GifFile, &CodeSize, 1) <
    +            1) { /* Read Code size from file. */
    +                GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                return GIF_ERROR; /* Failed to read Code size. */
    +        }
    +        BitsPerPixel = CodeSize;
     
    -    /* this can only happen on a severely malformed GIF */
    -    if (BitsPerPixel > 8) {
    -        GifFile->Error =
    -            D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */
    -        return GIF_ERROR;          /* Failed to read Code size. */
    -    }
    +        /* this can only happen on a severely malformed GIF */
    +        if (BitsPerPixel > 8) {
    +                GifFile->Error =
    +                    D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */
    +                return GIF_ERROR;          /* Failed to read Code size. */
    +        }
     
    -    Private->Buf[0] = 0; /* Input Buffer empty. */
    -    Private->BitsPerPixel = BitsPerPixel;
    -    Private->ClearCode = (1 << BitsPerPixel);
    -    Private->EOFCode = Private->ClearCode + 1;
    -    Private->RunningCode = Private->EOFCode + 1;
    -    Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */
    -    Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */
    -    Private->StackPtr = 0; /* No pixels on the pixel stack. */
    -    Private->LastCode = NO_SUCH_CODE;
    -    Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */
    -    Private->CrntShiftDWord = 0;
    +        Private->Buf[0] = 0; /* Input Buffer empty. */
    +        Private->BitsPerPixel = BitsPerPixel;
    +        Private->ClearCode = (1 << BitsPerPixel);
    +        Private->EOFCode = Private->ClearCode + 1;
    +        Private->RunningCode = Private->EOFCode + 1;
    +        Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */
    +        Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */
    +        Private->StackPtr = 0; /* No pixels on the pixel stack. */
    +        Private->LastCode = NO_SUCH_CODE;
    +        Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */
    +        Private->CrntShiftDWord = 0;
     
    -    Prefix = Private->Prefix;
    -    for (i = 0; i <= LZ_MAX_CODE; i++) {
    -        Prefix[i] = NO_SUCH_CODE;
    -    }
    +        Prefix = Private->Prefix;
    +        for (i = 0; i <= LZ_MAX_CODE; i++) {
    +                Prefix[i] = NO_SUCH_CODE;
    +        }
     
    -    return GIF_OK;
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -880,147 +882,147 @@ static int DGifSetupDecompress(GifFileType *GifFile) {
     ******************************************************************************/
     static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
                                   int LineLen) {
    -    int i = 0;
    -    int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
    -    GifByteType *Stack, *Suffix;
    -    GifPrefixType *Prefix;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        int i = 0;
    +        int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
    +        GifByteType *Stack, *Suffix;
    +        GifPrefixType *Prefix;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    StackPtr = Private->StackPtr;
    -    Prefix = Private->Prefix;
    -    Suffix = Private->Suffix;
    -    Stack = Private->Stack;
    -    EOFCode = Private->EOFCode;
    -    ClearCode = Private->ClearCode;
    -    LastCode = Private->LastCode;
    +        StackPtr = Private->StackPtr;
    +        Prefix = Private->Prefix;
    +        Suffix = Private->Suffix;
    +        Stack = Private->Stack;
    +        EOFCode = Private->EOFCode;
    +        ClearCode = Private->ClearCode;
    +        LastCode = Private->LastCode;
     
    -    if (StackPtr > LZ_MAX_CODE) {
    -        return GIF_ERROR;
    -    }
    -
    -    if (StackPtr != 0) {
    -        /* Let pop the stack off before continueing to read the GIF
    -         * file: */
    -        while (StackPtr != 0 && i < LineLen) {
    -            Line[i++] = Stack[--StackPtr];
    -        }
    -    }
    -
    -    while (i < LineLen) { /* Decode LineLen items. */
    -        if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR) {
    -            return GIF_ERROR;
    +        if (StackPtr > LZ_MAX_CODE) {
    +                return GIF_ERROR;
             }
     
    -        if (CrntCode == EOFCode) {
    -            /* Note however that usually we will not be here as we
    -             * will stop decoding as soon as we got all the pixel,
    -             * or EOF code will not be read at all, and
    -             * DGifGetLine/Pixel clean everything.  */
    -            GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
    -            return GIF_ERROR;
    -        } else if (CrntCode == ClearCode) {
    -            /* We need to start over again: */
    -            for (j = 0; j <= LZ_MAX_CODE; j++) {
    -                Prefix[j] = NO_SUCH_CODE;
    -            }
    -            Private->RunningCode = Private->EOFCode + 1;
    -            Private->RunningBits = Private->BitsPerPixel + 1;
    -            Private->MaxCode1 = 1 << Private->RunningBits;
    -            LastCode = Private->LastCode = NO_SUCH_CODE;
    -        } else {
    -            /* Its regular code - if in pixel range simply add it to
    -             * output stream, otherwise trace to codes linked list
    -             * until the prefix is in pixel range: */
    -            if (CrntCode < ClearCode) {
    -                /* This is simple - its pixel scalar, so add it
    -                 * to output: */
    -                Line[i++] = CrntCode;
    -            } else {
    -                /* Its a code to needed to be traced: trace the
    -                 * linked list until the prefix is a pixel,
    -                 * while pushing the suffix pixels on our stack.
    -                 * If we done, pop the stack in reverse (thats
    -                 * what stack is good for!) order to output.  */
    -                if (Prefix[CrntCode] == NO_SUCH_CODE) {
    -                    CrntPrefix = LastCode;
    -
    -                    /* Only allowed if CrntCode is exactly
    -                     * the running code: In that case
    -                     * CrntCode = XXXCode, CrntCode or the
    -                     * prefix code is last code and the
    -                     * suffix char is exactly the prefix of
    -                     * last code! */
    -                    if (CrntCode ==
    -                        Private->RunningCode - 2) {
    -                        Suffix[Private->RunningCode -
    -                               2] = Stack[StackPtr++] =
    -                            DGifGetPrefixChar(
    -                                Prefix, LastCode,
    -                                ClearCode);
    -                    } else {
    -                        Suffix[Private->RunningCode -
    -                               2] = Stack[StackPtr++] =
    -                            DGifGetPrefixChar(
    -                                Prefix, CrntCode,
    -                                ClearCode);
    -                    }
    -                } else {
    -                    CrntPrefix = CrntCode;
    -                }
    -
    -                /* Now (if image is O.K.) we should not get a
    -                 * NO_SUCH_CODE during the trace. As we might
    -                 * loop forever, in case of defective image, we
    -                 * use StackPtr as loop counter and stop before
    -                 * overflowing Stack[]. */
    -                while (StackPtr < LZ_MAX_CODE &&
    -                       CrntPrefix > ClearCode &&
    -                       CrntPrefix <= LZ_MAX_CODE) {
    -                    Stack[StackPtr++] = Suffix[CrntPrefix];
    -                    CrntPrefix = Prefix[CrntPrefix];
    -                }
    -                if (StackPtr >= LZ_MAX_CODE ||
    -                    CrntPrefix > LZ_MAX_CODE) {
    -                    GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    -                    return GIF_ERROR;
    -                }
    -                /* Push the last character on stack: */
    -                Stack[StackPtr++] = CrntPrefix;
    -
    -                /* Now lets pop all the stack into output: */
    +        if (StackPtr != 0) {
    +                /* Let pop the stack off before continueing to read the GIF
    +                 * file: */
                     while (StackPtr != 0 && i < LineLen) {
    -                    Line[i++] = Stack[--StackPtr];
    +                        Line[i++] = Stack[--StackPtr];
                     }
    -            }
    -            if (LastCode != NO_SUCH_CODE &&
    -                Private->RunningCode - 2 < (LZ_MAX_CODE + 1) &&
    -                Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
    -                Prefix[Private->RunningCode - 2] = LastCode;
    -
    -                if (CrntCode == Private->RunningCode - 2) {
    -                    /* Only allowed if CrntCode is exactly
    -                     * the running code: In that case
    -                     * CrntCode = XXXCode, CrntCode or the
    -                     * prefix code is last code and the
    -                     * suffix char is exactly the prefix of
    -                     * last code! */
    -                    Suffix[Private->RunningCode - 2] =
    -                        DGifGetPrefixChar(Prefix, LastCode,
    -                                          ClearCode);
    -                } else {
    -                    Suffix[Private->RunningCode - 2] =
    -                        DGifGetPrefixChar(Prefix, CrntCode,
    -                                          ClearCode);
    -                }
    -            }
    -            LastCode = CrntCode;
             }
    -    }
     
    -    Private->LastCode = LastCode;
    -    Private->StackPtr = StackPtr;
    +        while (i < LineLen) { /* Decode LineLen items. */
    +                if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR) {
    +                        return GIF_ERROR;
    +                }
     
    -    return GIF_OK;
    +                if (CrntCode == EOFCode) {
    +                        /* Note however that usually we will not be here as we
    +                         * will stop decoding as soon as we got all the pixel,
    +                         * or EOF code will not be read at all, and
    +                         * DGifGetLine/Pixel clean everything.  */
    +                        GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
    +                        return GIF_ERROR;
    +                } else if (CrntCode == ClearCode) {
    +                        /* We need to start over again: */
    +                        for (j = 0; j <= LZ_MAX_CODE; j++) {
    +                                Prefix[j] = NO_SUCH_CODE;
    +                        }
    +                        Private->RunningCode = Private->EOFCode + 1;
    +                        Private->RunningBits = Private->BitsPerPixel + 1;
    +                        Private->MaxCode1 = 1 << Private->RunningBits;
    +                        LastCode = Private->LastCode = NO_SUCH_CODE;
    +                } else {
    +                        /* Its regular code - if in pixel range simply add it to
    +                         * output stream, otherwise trace to codes linked list
    +                         * until the prefix is in pixel range: */
    +                        if (CrntCode < ClearCode) {
    +                                /* This is simple - its pixel scalar, so add it
    +                                 * to output: */
    +                                Line[i++] = CrntCode;
    +                        } else {
    +                                /* Its a code to needed to be traced: trace the
    +                                 * linked list until the prefix is a pixel,
    +                                 * while pushing the suffix pixels on our stack.
    +                                 * If we done, pop the stack in reverse (thats
    +                                 * what stack is good for!) order to output.  */
    +                                if (Prefix[CrntCode] == NO_SUCH_CODE) {
    +                                        CrntPrefix = LastCode;
    +
    +                                        /* Only allowed if CrntCode is exactly
    +                                         * the running code: In that case
    +                                         * CrntCode = XXXCode, CrntCode or the
    +                                         * prefix code is last code and the
    +                                         * suffix char is exactly the prefix of
    +                                         * last code! */
    +                                        if (CrntCode ==
    +                                            Private->RunningCode - 2) {
    +                                                Suffix[Private->RunningCode -
    +                                                       2] = Stack[StackPtr++] =
    +                                                    DGifGetPrefixChar(
    +                                                        Prefix, LastCode,
    +                                                        ClearCode);
    +                                        } else {
    +                                                Suffix[Private->RunningCode -
    +                                                       2] = Stack[StackPtr++] =
    +                                                    DGifGetPrefixChar(
    +                                                        Prefix, CrntCode,
    +                                                        ClearCode);
    +                                        }
    +                                } else {
    +                                        CrntPrefix = CrntCode;
    +                                }
    +
    +                                /* Now (if image is O.K.) we should not get a
    +                                 * NO_SUCH_CODE during the trace. As we might
    +                                 * loop forever, in case of defective image, we
    +                                 * use StackPtr as loop counter and stop before
    +                                 * overflowing Stack[]. */
    +                                while (StackPtr < LZ_MAX_CODE &&
    +                                       CrntPrefix > ClearCode &&
    +                                       CrntPrefix <= LZ_MAX_CODE) {
    +                                        Stack[StackPtr++] = Suffix[CrntPrefix];
    +                                        CrntPrefix = Prefix[CrntPrefix];
    +                                }
    +                                if (StackPtr >= LZ_MAX_CODE ||
    +                                    CrntPrefix > LZ_MAX_CODE) {
    +                                        GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    +                                        return GIF_ERROR;
    +                                }
    +                                /* Push the last character on stack: */
    +                                Stack[StackPtr++] = CrntPrefix;
    +
    +                                /* Now lets pop all the stack into output: */
    +                                while (StackPtr != 0 && i < LineLen) {
    +                                        Line[i++] = Stack[--StackPtr];
    +                                }
    +                        }
    +                        if (LastCode != NO_SUCH_CODE &&
    +                            Private->RunningCode - 2 < (LZ_MAX_CODE + 1) &&
    +                            Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
    +                                Prefix[Private->RunningCode - 2] = LastCode;
    +
    +                                if (CrntCode == Private->RunningCode - 2) {
    +                                        /* Only allowed if CrntCode is exactly
    +                                         * the running code: In that case
    +                                         * CrntCode = XXXCode, CrntCode or the
    +                                         * prefix code is last code and the
    +                                         * suffix char is exactly the prefix of
    +                                         * last code! */
    +                                        Suffix[Private->RunningCode - 2] =
    +                                            DGifGetPrefixChar(Prefix, LastCode,
    +                                                              ClearCode);
    +                                } else {
    +                                        Suffix[Private->RunningCode - 2] =
    +                                            DGifGetPrefixChar(Prefix, CrntCode,
    +                                                              ClearCode);
    +                                }
    +                        }
    +                        LastCode = CrntCode;
    +                }
    +        }
    +
    +        Private->LastCode = LastCode;
    +        Private->StackPtr = StackPtr;
    +
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -1031,15 +1033,15 @@ static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
     ******************************************************************************/
     static int DGifGetPrefixChar(const GifPrefixType *Prefix, int Code,
                                  int ClearCode) {
    -    int i = 0;
    +        int i = 0;
     
    -    while (Code > ClearCode && i++ <= LZ_MAX_CODE) {
    -        if (Code > LZ_MAX_CODE) {
    -            return NO_SUCH_CODE;
    +        while (Code > ClearCode && i++ <= LZ_MAX_CODE) {
    +                if (Code > LZ_MAX_CODE) {
    +                        return NO_SUCH_CODE;
    +                }
    +                Code = Prefix[Code];
             }
    -        Code = Prefix[Code];
    -    }
    -    return Code;
    +        return Code;
     }
     
     /******************************************************************************
    @@ -1047,37 +1049,37 @@ static int DGifGetPrefixChar(const GifPrefixType *Prefix, int Code,
      (12bits), or to -1 if EOF code is returned.
     ******************************************************************************/
     int DGifGetLZCodes(GifFileType *GifFile, int *Code) {
    -    GifByteType *CodeBlock;
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifByteType *CodeBlock;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    if (!IS_READABLE(Private)) {
    -        /* This file was NOT open for reading: */
    -        GifFile->Error = D_GIF_ERR_NOT_READABLE;
    -        return GIF_ERROR;
    -    }
    -
    -    if (DGifDecompressInput(GifFile, Code) == GIF_ERROR) {
    -        return GIF_ERROR;
    -    }
    -
    -    if (*Code == Private->EOFCode) {
    -        /* Skip rest of codes (hopefully only NULL terminating block):
    -         */
    -        do {
    -            if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) {
    +        if (!IS_READABLE(Private)) {
    +                /* This file was NOT open for reading: */
    +                GifFile->Error = D_GIF_ERR_NOT_READABLE;
                     return GIF_ERROR;
    -            }
    -        } while (CodeBlock != NULL);
    +        }
     
    -        *Code = -1;
    -    } else if (*Code == Private->ClearCode) {
    -        /* We need to start over again: */
    -        Private->RunningCode = Private->EOFCode + 1;
    -        Private->RunningBits = Private->BitsPerPixel + 1;
    -        Private->MaxCode1 = 1 << Private->RunningBits;
    -    }
    +        if (DGifDecompressInput(GifFile, Code) == GIF_ERROR) {
    +                return GIF_ERROR;
    +        }
     
    -    return GIF_OK;
    +        if (*Code == Private->EOFCode) {
    +                /* Skip rest of codes (hopefully only NULL terminating block):
    +                 */
    +                do {
    +                        if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) {
    +                                return GIF_ERROR;
    +                        }
    +                } while (CodeBlock != NULL);
    +
    +                *Code = -1;
    +        } else if (*Code == Private->ClearCode) {
    +                /* We need to start over again: */
    +                Private->RunningCode = Private->EOFCode + 1;
    +                Private->RunningBits = Private->BitsPerPixel + 1;
    +                Private->MaxCode1 = 1 << Private->RunningBits;
    +        }
    +
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -1087,47 +1089,47 @@ int DGifGetLZCodes(GifFileType *GifFile, int *Code) {
      Returns GIF_OK if read successfully.
     ******************************************************************************/
     static int DGifDecompressInput(GifFileType *GifFile, int *Code) {
    -    static const unsigned short CodeMasks[] = {
    -        0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f,
    -        0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff};
    +        static const unsigned short CodeMasks[] = {
    +            0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f,
    +            0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff};
     
    -    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
    +        GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
     
    -    GifByteType NextByte;
    +        GifByteType NextByte;
     
    -    /* The image can't contain more than LZ_BITS per code. */
    -    if (Private->RunningBits > LZ_BITS) {
    -        GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    -        return GIF_ERROR;
    -    }
    -
    -    while (Private->CrntShiftState < Private->RunningBits) {
    -        /* Needs to get more bytes from input stream for next code: */
    -        if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) ==
    -            GIF_ERROR) {
    -            return GIF_ERROR;
    +        /* The image can't contain more than LZ_BITS per code. */
    +        if (Private->RunningBits > LZ_BITS) {
    +                GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    +                return GIF_ERROR;
             }
    -        Private->CrntShiftDWord |= ((unsigned long)NextByte)
    -                                   << Private->CrntShiftState;
    -        Private->CrntShiftState += 8;
    -    }
    -    *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
     
    -    Private->CrntShiftDWord >>= Private->RunningBits;
    -    Private->CrntShiftState -= Private->RunningBits;
    +        while (Private->CrntShiftState < Private->RunningBits) {
    +                /* Needs to get more bytes from input stream for next code: */
    +                if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) ==
    +                    GIF_ERROR) {
    +                        return GIF_ERROR;
    +                }
    +                Private->CrntShiftDWord |= ((unsigned long)NextByte)
    +                                           << Private->CrntShiftState;
    +                Private->CrntShiftState += 8;
    +        }
    +        *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
     
    -    /* If code cannot fit into RunningBits bits, must raise its size. Note
    -     * however that codes above 4095 are used for special signaling.
    -     * If we're using LZ_BITS bits already and we're at the max code, just
    -     * keep using the table as it is, don't increment Private->RunningCode.
    -     */
    -    if (Private->RunningCode < LZ_MAX_CODE + 2 &&
    -        ++Private->RunningCode > Private->MaxCode1 &&
    -        Private->RunningBits < LZ_BITS) {
    -        Private->MaxCode1 <<= 1;
    -        Private->RunningBits++;
    -    }
    -    return GIF_OK;
    +        Private->CrntShiftDWord >>= Private->RunningBits;
    +        Private->CrntShiftState -= Private->RunningBits;
    +
    +        /* If code cannot fit into RunningBits bits, must raise its size. Note
    +         * however that codes above 4095 are used for special signaling.
    +         * If we're using LZ_BITS bits already and we're at the max code, just
    +         * keep using the table as it is, don't increment Private->RunningCode.
    +         */
    +        if (Private->RunningCode < LZ_MAX_CODE + 2 &&
    +            ++Private->RunningCode > Private->MaxCode1 &&
    +            Private->RunningBits < LZ_BITS) {
    +                Private->MaxCode1 <<= 1;
    +                Private->RunningBits++;
    +        }
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -1138,34 +1140,34 @@ static int DGifDecompressInput(GifFileType *GifFile, int *Code) {
     ******************************************************************************/
     static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
                                  GifByteType *NextByte) {
    -    if (Buf[0] == 0) {
    -        /* Needs to read the next buffer - this one is empty: */
    -        /* coverity[check_return] */
    -        if (InternalRead(GifFile, Buf, 1) != 1) {
    -            GifFile->Error = D_GIF_ERR_READ_FAILED;
    -            return GIF_ERROR;
    -        }
    -        /* There shouldn't be any empty data blocks here as the LZW spec
    -         * says the LZW termination code should come first.  Therefore
    -         * we shouldn't be inside this routine at that point.
    -         */
             if (Buf[0] == 0) {
    -            GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    -            return GIF_ERROR;
    +                /* Needs to read the next buffer - this one is empty: */
    +                /* coverity[check_return] */
    +                if (InternalRead(GifFile, Buf, 1) != 1) {
    +                        GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                        return GIF_ERROR;
    +                }
    +                /* There shouldn't be any empty data blocks here as the LZW spec
    +                 * says the LZW termination code should come first.  Therefore
    +                 * we shouldn't be inside this routine at that point.
    +                 */
    +                if (Buf[0] == 0) {
    +                        GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
    +                        return GIF_ERROR;
    +                }
    +                if (InternalRead(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
    +                        GifFile->Error = D_GIF_ERR_READ_FAILED;
    +                        return GIF_ERROR;
    +                }
    +                *NextByte = Buf[1];
    +                Buf[1] = 2; /* We use now the second place as last char read! */
    +                Buf[0]--;
    +        } else {
    +                *NextByte = Buf[Buf[1]++];
    +                Buf[0]--;
             }
    -        if (InternalRead(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
    -            GifFile->Error = D_GIF_ERR_READ_FAILED;
    -            return GIF_ERROR;
    -        }
    -        *NextByte = Buf[1];
    -        Buf[1] = 2; /* We use now the second place as last char read! */
    -        Buf[0]--;
    -    } else {
    -        *NextByte = Buf[Buf[1]++];
    -        Buf[0]--;
    -    }
     
    -    return GIF_OK;
    +        return GIF_OK;
     }
     
     /******************************************************************************
    @@ -1175,17 +1177,20 @@ static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
      SavedImages may point to the spoilt image and null pointer buffers.
     *******************************************************************************/
     void DGifDecreaseImageCounter(GifFileType *GifFile) {
    -    GifFile->ImageCount--;
    -    if (GifFile->SavedImages[GifFile->ImageCount].RasterBits != NULL) {
    -        free(GifFile->SavedImages[GifFile->ImageCount].RasterBits);
    -    }
    +        GifFile->ImageCount--;
    +        if (GifFile->SavedImages[GifFile->ImageCount].RasterBits != NULL) {
    +                free(GifFile->SavedImages[GifFile->ImageCount].RasterBits);
    +        }
    +        if (GifFile->SavedImages[GifFile->ImageCount].ImageDesc.ColorMap != NULL) {
    +                GifFreeMapObject(GifFile->SavedImages[GifFile->ImageCount].ImageDesc.ColorMap);
    +        }
     
    -    // Realloc array according to the new image counter.
    -    SavedImage *correct_saved_images = (SavedImage *)reallocarray(
    -        GifFile->SavedImages, GifFile->ImageCount, sizeof(SavedImage));
    -    if (correct_saved_images != NULL) {
    -        GifFile->SavedImages = correct_saved_images;
    -    }
    +        // Realloc array according to the new image counter.
    +        SavedImage *correct_saved_images = (SavedImage *)reallocarray(
    +            GifFile->SavedImages, GifFile->ImageCount, sizeof(SavedImage));
    +        if (correct_saved_images != NULL) {
    +                GifFile->SavedImages = correct_saved_images;
    +        }
     }
     
     /******************************************************************************
    @@ -1194,143 +1199,143 @@ void DGifDecreaseImageCounter(GifFileType *GifFile) {
      first to initialize I/O.  Its inverse is EGifSpew().
     *******************************************************************************/
     int DGifSlurp(GifFileType *GifFile) {
    -    size_t ImageSize;
    -    GifRecordType RecordType;
    -    SavedImage *sp;
    -    GifByteType *ExtData;
    -    int ExtFunction;
    +        size_t ImageSize;
    +        GifRecordType RecordType;
    +        SavedImage *sp;
    +        GifByteType *ExtData;
    +        int ExtFunction;
     
    -    GifFile->ExtensionBlocks = NULL;
    -    GifFile->ExtensionBlockCount = 0;
    +        GifFile->ExtensionBlocks = NULL;
    +        GifFile->ExtensionBlockCount = 0;
     
    -    do {
    -        if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
    -            return (GIF_ERROR);
    -        }
    +        do {
    +                if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
    +                        return (GIF_ERROR);
    +                }
     
    -        switch (RecordType) {
    -        case IMAGE_DESC_RECORD_TYPE:
    -            if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
    -                return (GIF_ERROR);
    -            }
    -
    -            sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
    -            /* Allocate memory for the image */
    -            if (sp->ImageDesc.Width <= 0 ||
    -                sp->ImageDesc.Height <= 0 ||
    -                sp->ImageDesc.Width >
    -                    (INT_MAX / sp->ImageDesc.Height)) {
    -                DGifDecreaseImageCounter(GifFile);
    -                return GIF_ERROR;
    -            }
    -            ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
    -
    -            if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
    -                DGifDecreaseImageCounter(GifFile);
    -                return GIF_ERROR;
    -            }
    -            sp->RasterBits = (unsigned char *)reallocarray(
    -                NULL, ImageSize, sizeof(GifPixelType));
    -
    -            if (sp->RasterBits == NULL) {
    -                DGifDecreaseImageCounter(GifFile);
    -                return GIF_ERROR;
    -            }
    -
    -            if (sp->ImageDesc.Interlace) {
    -                int i, j;
    -                /*
    -                 * The way an interlaced image should be read -
    -                 * offsets and jumps...
    -                 */
    -                static const int InterlacedOffset[] = {0, 4, 2,
    -                                                       1};
    -                static const int InterlacedJumps[] = {8, 8, 4,
    -                                                      2};
    -                /* Need to perform 4 passes on the image */
    -                for (i = 0; i < 4; i++) {
    -                    for (j = InterlacedOffset[i];
    -                         j < sp->ImageDesc.Height;
    -                         j += InterlacedJumps[i]) {
    -                        if (DGifGetLine(
    -                                GifFile,
    -                                sp->RasterBits +
    -                                    j * sp->ImageDesc
    -                                            .Width,
    -                                sp->ImageDesc.Width) ==
    -                            GIF_ERROR) {
    -                            DGifDecreaseImageCounter(
    -                                GifFile);
    -                            return GIF_ERROR;
    +                switch (RecordType) {
    +                case IMAGE_DESC_RECORD_TYPE:
    +                        if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
    +                                return (GIF_ERROR);
                             }
    -                    }
    +
    +                        sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
    +                        /* Allocate memory for the image */
    +                        if (sp->ImageDesc.Width <= 0 ||
    +                            sp->ImageDesc.Height <= 0 ||
    +                            sp->ImageDesc.Width >
    +                                (INT_MAX / sp->ImageDesc.Height)) {
    +                                DGifDecreaseImageCounter(GifFile);
    +                                return GIF_ERROR;
    +                        }
    +                        ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
    +
    +                        if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
    +                                DGifDecreaseImageCounter(GifFile);
    +                                return GIF_ERROR;
    +                        }
    +                        sp->RasterBits = (unsigned char *)reallocarray(
    +                            NULL, ImageSize, sizeof(GifPixelType));
    +
    +                        if (sp->RasterBits == NULL) {
    +                                DGifDecreaseImageCounter(GifFile);
    +                                return GIF_ERROR;
    +                        }
    +
    +                        if (sp->ImageDesc.Interlace) {
    +                                int i, j;
    +                                /*
    +                                 * The way an interlaced image should be read -
    +                                 * offsets and jumps...
    +                                 */
    +                                static const int InterlacedOffset[] = {0, 4, 2,
    +                                                                       1};
    +                                static const int InterlacedJumps[] = {8, 8, 4,
    +                                                                      2};
    +                                /* Need to perform 4 passes on the image */
    +                                for (i = 0; i < 4; i++) {
    +                                        for (j = InterlacedOffset[i];
    +                                             j < sp->ImageDesc.Height;
    +                                             j += InterlacedJumps[i]) {
    +                                                if (DGifGetLine(
    +                                                        GifFile,
    +                                                        sp->RasterBits +
    +                                                            j * sp->ImageDesc
    +                                                                    .Width,
    +                                                        sp->ImageDesc.Width) ==
    +                                                    GIF_ERROR) {
    +                                                        DGifDecreaseImageCounter(
    +                                                            GifFile);
    +                                                        return GIF_ERROR;
    +                                                }
    +                                        }
    +                                }
    +                        } else {
    +                                if (DGifGetLine(GifFile, sp->RasterBits,
    +                                                ImageSize) == GIF_ERROR) {
    +                                        DGifDecreaseImageCounter(GifFile);
    +                                        return GIF_ERROR;
    +                                }
    +                        }
    +
    +                        if (GifFile->ExtensionBlocks) {
    +                                sp->ExtensionBlocks = GifFile->ExtensionBlocks;
    +                                sp->ExtensionBlockCount =
    +                                    GifFile->ExtensionBlockCount;
    +
    +                                GifFile->ExtensionBlocks = NULL;
    +                                GifFile->ExtensionBlockCount = 0;
    +                        }
    +                        break;
    +
    +                case EXTENSION_RECORD_TYPE:
    +                        if (DGifGetExtension(GifFile, &ExtFunction, &ExtData) ==
    +                            GIF_ERROR) {
    +                                return (GIF_ERROR);
    +                        }
    +                        /* Create an extension block with our data */
    +                        if (ExtData != NULL) {
    +                                if (GifAddExtensionBlock(
    +                                        &GifFile->ExtensionBlockCount,
    +                                        &GifFile->ExtensionBlocks, ExtFunction,
    +                                        ExtData[0], &ExtData[1]) == GIF_ERROR) {
    +                                        return (GIF_ERROR);
    +                                }
    +                        }
    +                        for (;;) {
    +                                if (DGifGetExtensionNext(GifFile, &ExtData) ==
    +                                    GIF_ERROR) {
    +                                        return (GIF_ERROR);
    +                                }
    +                                if (ExtData == NULL) {
    +                                        break;
    +                                }
    +                                /* Continue the extension block */
    +                                if (GifAddExtensionBlock(
    +                                        &GifFile->ExtensionBlockCount,
    +                                        &GifFile->ExtensionBlocks,
    +                                        CONTINUE_EXT_FUNC_CODE, ExtData[0],
    +                                        &ExtData[1]) == GIF_ERROR) {
    +                                        return (GIF_ERROR);
    +                                }
    +                        }
    +                        break;
    +
    +                case TERMINATE_RECORD_TYPE:
    +                        break;
    +
    +                default: /* Should be trapped by DGifGetRecordType */
    +                        break;
                     }
    -            } else {
    -                if (DGifGetLine(GifFile, sp->RasterBits,
    -                                ImageSize) == GIF_ERROR) {
    -                    DGifDecreaseImageCounter(GifFile);
    -                    return GIF_ERROR;
    -                }
    -            }
    +        } while (RecordType != TERMINATE_RECORD_TYPE);
     
    -            if (GifFile->ExtensionBlocks) {
    -                sp->ExtensionBlocks = GifFile->ExtensionBlocks;
    -                sp->ExtensionBlockCount =
    -                    GifFile->ExtensionBlockCount;
    -
    -                GifFile->ExtensionBlocks = NULL;
    -                GifFile->ExtensionBlockCount = 0;
    -            }
    -            break;
    -
    -        case EXTENSION_RECORD_TYPE:
    -            if (DGifGetExtension(GifFile, &ExtFunction, &ExtData) ==
    -                GIF_ERROR) {
    +        /* Sanity check for corrupted file */
    +        if (GifFile->ImageCount == 0) {
    +                GifFile->Error = D_GIF_ERR_NO_IMAG_DSCR;
                     return (GIF_ERROR);
    -            }
    -            /* Create an extension block with our data */
    -            if (ExtData != NULL) {
    -                if (GifAddExtensionBlock(
    -                        &GifFile->ExtensionBlockCount,
    -                        &GifFile->ExtensionBlocks, ExtFunction,
    -                        ExtData[0], &ExtData[1]) == GIF_ERROR) {
    -                    return (GIF_ERROR);
    -                }
    -            }
    -            for (;;) {
    -                if (DGifGetExtensionNext(GifFile, &ExtData) ==
    -                    GIF_ERROR) {
    -                    return (GIF_ERROR);
    -                }
    -                if (ExtData == NULL) {
    -                    break;
    -                }
    -                /* Continue the extension block */
    -                if (GifAddExtensionBlock(
    -                        &GifFile->ExtensionBlockCount,
    -                        &GifFile->ExtensionBlocks,
    -                        CONTINUE_EXT_FUNC_CODE, ExtData[0],
    -                        &ExtData[1]) == GIF_ERROR) {
    -                    return (GIF_ERROR);
    -                }
    -            }
    -            break;
    -
    -        case TERMINATE_RECORD_TYPE:
    -            break;
    -
    -        default: /* Should be trapped by DGifGetRecordType */
    -            break;
             }
    -    } while (RecordType != TERMINATE_RECORD_TYPE);
     
    -    /* Sanity check for corrupted file */
    -    if (GifFile->ImageCount == 0) {
    -        GifFile->Error = D_GIF_ERR_NO_IMAG_DSCR;
    -        return (GIF_ERROR);
    -    }
    -
    -    return (GIF_OK);
    +        return (GIF_OK);
     }
     
     /* end */
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c b/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
    index 3b6785f7c63..a3cc03b8865 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_err.c
    @@ -26,9 +26,9 @@
     
     gif_err.c - handle error reporting for the GIF library.
     
    -SPDX-License-Identifier: MIT
    -
     ****************************************************************************/
    +// SPDX-License-Identifier: MIT
    +// SPDX-File-Copyright-Txt: (C) Copyright 1989 Gershon Elber
     
     #include 
     
    @@ -39,83 +39,83 @@ SPDX-License-Identifier: MIT
      Return a string description of  the last GIF error
     *****************************************************************************/
     const char *GifErrorString(int ErrorCode) {
    -    const char *Err;
    +        const char *Err;
     
    -    switch (ErrorCode) {
    -    case E_GIF_ERR_OPEN_FAILED:
    -        Err = "Failed to open given file";
    -        break;
    -    case E_GIF_ERR_WRITE_FAILED:
    -        Err = "Failed to write to given file";
    -        break;
    -    case E_GIF_ERR_HAS_SCRN_DSCR:
    -        Err = "Screen descriptor has already been set";
    -        break;
    -    case E_GIF_ERR_HAS_IMAG_DSCR:
    -        Err = "Image descriptor is still active";
    -        break;
    -    case E_GIF_ERR_NO_COLOR_MAP:
    -        Err = "Neither global nor local color map";
    -        break;
    -    case E_GIF_ERR_DATA_TOO_BIG:
    -        Err = "Number of pixels bigger than width * height";
    -        break;
    -    case E_GIF_ERR_NOT_ENOUGH_MEM:
    -        Err = "Failed to allocate required memory";
    -        break;
    -    case E_GIF_ERR_DISK_IS_FULL:
    -        Err = "Write failed (disk full?)";
    -        break;
    -    case E_GIF_ERR_CLOSE_FAILED:
    -        Err = "Failed to close given file";
    -        break;
    -    case E_GIF_ERR_NOT_WRITEABLE:
    -        Err = "Given file was not opened for write";
    -        break;
    -    case D_GIF_ERR_OPEN_FAILED:
    -        Err = "Failed to open given file";
    -        break;
    -    case D_GIF_ERR_READ_FAILED:
    -        Err = "Failed to read from given file";
    -        break;
    -    case D_GIF_ERR_NOT_GIF_FILE:
    -        Err = "Data is not in GIF format";
    -        break;
    -    case D_GIF_ERR_NO_SCRN_DSCR:
    -        Err = "No screen descriptor detected";
    -        break;
    -    case D_GIF_ERR_NO_IMAG_DSCR:
    -        Err = "No Image Descriptor detected";
    -        break;
    -    case D_GIF_ERR_NO_COLOR_MAP:
    -        Err = "Neither global nor local color map";
    -        break;
    -    case D_GIF_ERR_WRONG_RECORD:
    -        Err = "Wrong record type detected";
    -        break;
    -    case D_GIF_ERR_DATA_TOO_BIG:
    -        Err = "Number of pixels bigger than width * height";
    -        break;
    -    case D_GIF_ERR_NOT_ENOUGH_MEM:
    -        Err = "Failed to allocate required memory";
    -        break;
    -    case D_GIF_ERR_CLOSE_FAILED:
    -        Err = "Failed to close given file";
    -        break;
    -    case D_GIF_ERR_NOT_READABLE:
    -        Err = "Given file was not opened for read";
    -        break;
    -    case D_GIF_ERR_IMAGE_DEFECT:
    -        Err = "Image is defective, decoding aborted";
    -        break;
    -    case D_GIF_ERR_EOF_TOO_SOON:
    -        Err = "Image EOF detected before image complete";
    -        break;
    -    default:
    -        Err = NULL;
    -        break;
    -    }
    -    return Err;
    +        switch (ErrorCode) {
    +        case E_GIF_ERR_OPEN_FAILED:
    +                Err = "Failed to open given file";
    +                break;
    +        case E_GIF_ERR_WRITE_FAILED:
    +                Err = "Failed to write to given file";
    +                break;
    +        case E_GIF_ERR_HAS_SCRN_DSCR:
    +                Err = "Screen descriptor has already been set";
    +                break;
    +        case E_GIF_ERR_HAS_IMAG_DSCR:
    +                Err = "Image descriptor is still active";
    +                break;
    +        case E_GIF_ERR_NO_COLOR_MAP:
    +                Err = "Neither global nor local color map";
    +                break;
    +        case E_GIF_ERR_DATA_TOO_BIG:
    +                Err = "Number of pixels bigger than width * height";
    +                break;
    +        case E_GIF_ERR_NOT_ENOUGH_MEM:
    +                Err = "Failed to allocate required memory";
    +                break;
    +        case E_GIF_ERR_DISK_IS_FULL:
    +                Err = "Write failed (disk full?)";
    +                break;
    +        case E_GIF_ERR_CLOSE_FAILED:
    +                Err = "Failed to close given file";
    +                break;
    +        case E_GIF_ERR_NOT_WRITEABLE:
    +                Err = "Given file was not opened for write";
    +                break;
    +        case D_GIF_ERR_OPEN_FAILED:
    +                Err = "Failed to open given file";
    +                break;
    +        case D_GIF_ERR_READ_FAILED:
    +                Err = "Failed to read from given file";
    +                break;
    +        case D_GIF_ERR_NOT_GIF_FILE:
    +                Err = "Data is not in GIF format";
    +                break;
    +        case D_GIF_ERR_NO_SCRN_DSCR:
    +                Err = "No screen descriptor detected";
    +                break;
    +        case D_GIF_ERR_NO_IMAG_DSCR:
    +                Err = "No Image Descriptor detected";
    +                break;
    +        case D_GIF_ERR_NO_COLOR_MAP:
    +                Err = "Neither global nor local color map";
    +                break;
    +        case D_GIF_ERR_WRONG_RECORD:
    +                Err = "Wrong record type detected";
    +                break;
    +        case D_GIF_ERR_DATA_TOO_BIG:
    +                Err = "Number of pixels bigger than width * height";
    +                break;
    +        case D_GIF_ERR_NOT_ENOUGH_MEM:
    +                Err = "Failed to allocate required memory";
    +                break;
    +        case D_GIF_ERR_CLOSE_FAILED:
    +                Err = "Failed to close given file";
    +                break;
    +        case D_GIF_ERR_NOT_READABLE:
    +                Err = "Given file was not opened for read";
    +                break;
    +        case D_GIF_ERR_IMAGE_DEFECT:
    +                Err = "Image is defective, decoding aborted";
    +                break;
    +        case D_GIF_ERR_EOF_TOO_SOON:
    +                Err = "Image EOF detected before image complete";
    +                break;
    +        default:
    +                Err = NULL;
    +                break;
    +        }
    +        return Err;
     }
     
     /* end */
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
    index bd00af64161..eb3cba3135f 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h
    @@ -26,9 +26,8 @@
     
     gif_hash.h - magfic constants and declarations for GIF LZW
     
    -SPDX-License-Identifier: MIT
    -
     ******************************************************************************/
    +// SPDX-License-Identifier: MIT
     
     #ifndef _GIF_HASH_H_
     #define _GIF_HASH_H_
    @@ -46,7 +45,7 @@ SPDX-License-Identifier: MIT
     
     /* The 32 bits of the long are divided into two parts for the key & code:   */
     /* 1. The code is 12 bits as our compression algorithm is limited to 12bits */
    -/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits.        */
    +/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits.           */
     /* The key is the upper 20 bits.  The code is the lower 12. */
     #define HT_GET_KEY(l) (l >> 12)
     #define HT_GET_CODE(l) (l & 0x0FFF)
    @@ -54,7 +53,7 @@ SPDX-License-Identifier: MIT
     #define HT_PUT_CODE(l) (l & 0x0FFF)
     
     typedef struct GifHashTableType {
    -    uint32_t HTable[HT_SIZE];
    +        uint32_t HTable[HT_SIZE];
     } GifHashTableType;
     
     GifHashTableType *_InitHashTable(void);
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
    index 74a2e969c0d..64b33beefa7 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h
    @@ -37,8 +37,8 @@ SPDX-License-Identifier: MIT
     extern "C" {
     #endif /* __cplusplus */
     
    -#define GIFLIB_MAJOR 5
    -#define GIFLIB_MINOR 2
    +#define GIFLIB_MAJOR 6
    +#define GIFLIB_MINOR 1
     #define GIFLIB_RELEASE 2
     
     #define GIF_ERROR 0
    @@ -60,26 +60,26 @@ typedef unsigned int GifPrefixType;
     typedef int GifWord;
     
     typedef struct GifColorType {
    -    GifByteType Red, Green, Blue;
    +        GifByteType Red, Green, Blue;
     } GifColorType;
     
     typedef struct ColorMapObject {
    -    int ColorCount;
    -    int BitsPerPixel;
    -    bool SortFlag;
    -    GifColorType *Colors; /* on malloc(3) heap */
    +        int ColorCount;
    +        int BitsPerPixel;
    +        bool SortFlag;
    +        GifColorType *Colors; /* on malloc(3) heap */
     } ColorMapObject;
     
     typedef struct GifImageDesc {
    -    GifWord Left, Top, Width, Height; /* Current image dimensions. */
    -    bool Interlace;                   /* Sequential/Interlaced lines. */
    -    ColorMapObject *ColorMap;         /* The local color map */
    +        GifWord Left, Top, Width, Height; /* Current image dimensions. */
    +        bool Interlace;                   /* Sequential/Interlaced lines. */
    +        ColorMapObject *ColorMap;         /* The local color map */
     } GifImageDesc;
     
     typedef struct ExtensionBlock {
    -    int ByteCount;
    -    GifByteType *Bytes;            /* on malloc(3) heap */
    -    int Function;                  /* The block function code */
    +        int ByteCount;
    +        GifByteType *Bytes;            /* on malloc(3) heap */
    +        int Function;                  /* The block function code */
     #define CONTINUE_EXT_FUNC_CODE 0x00    /* continuation subblock */
     #define COMMENT_EXT_FUNC_CODE 0xfe     /* comment */
     #define GRAPHICS_EXT_FUNC_CODE 0xf9    /* graphics control (GIF89) */
    @@ -88,36 +88,36 @@ typedef struct ExtensionBlock {
     } ExtensionBlock;
     
     typedef struct SavedImage {
    -    GifImageDesc ImageDesc;
    -    GifByteType *RasterBits;         /* on malloc(3) heap */
    -    int ExtensionBlockCount;         /* Count of extensions before image */
    -    ExtensionBlock *ExtensionBlocks; /* Extensions before image */
    +        GifImageDesc ImageDesc;
    +        GifByteType *RasterBits;         /* on malloc(3) heap */
    +        int ExtensionBlockCount;         /* Count of extensions before image */
    +        ExtensionBlock *ExtensionBlocks; /* Extensions before image */
     } SavedImage;
     
     typedef struct GifFileType {
    -    GifWord SWidth, SHeight;   /* Size of virtual canvas */
    -    GifWord SColorResolution;  /* How many colors can we generate? */
    -    GifWord SBackGroundColor;  /* Background color for virtual canvas */
    -    GifByteType AspectByte;    /* Used to compute pixel aspect ratio */
    -    ColorMapObject *SColorMap; /* Global colormap, NULL if nonexistent. */
    -    int ImageCount;            /* Number of current image (both APIs) */
    -    GifImageDesc Image;        /* Current image (low-level API) */
    -    SavedImage *SavedImages;   /* Image sequence (high-level API) */
    -    int ExtensionBlockCount;   /* Count extensions past last image */
    -    ExtensionBlock *ExtensionBlocks; /* Extensions past last image */
    -    int Error;                       /* Last error condition reported */
    -    void *UserData;                  /* hook to attach user data (TVT) */
    -    void *Private;                   /* Don't mess with this! */
    +        GifWord SWidth, SHeight;   /* Size of virtual canvas */
    +        GifWord SColorResolution;  /* How many colors can we generate? */
    +        GifWord SBackGroundColor;  /* Background color for virtual canvas */
    +        GifByteType AspectByte;    /* Used to compute pixel aspect ratio */
    +        ColorMapObject *SColorMap; /* Global colormap, NULL if nonexistent. */
    +        int ImageCount;            /* Number of current image (both APIs) */
    +        GifImageDesc Image;        /* Current image (low-level API) */
    +        SavedImage *SavedImages;   /* Image sequence (high-level API) */
    +        int ExtensionBlockCount;   /* Count extensions past last image */
    +        ExtensionBlock *ExtensionBlocks; /* Extensions past last image */
    +        int Error;                       /* Last error condition reported */
    +        void *UserData;                  /* hook to attach user data (TVT) */
    +        void *Private;                   /* Don't mess with this! */
     } GifFileType;
     
     #define GIF_ASPECT_RATIO(n) ((n) + 15.0 / 64.0)
     
     typedef enum {
    -    UNDEFINED_RECORD_TYPE,
    -    SCREEN_DESC_RECORD_TYPE,
    -    IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
    -    EXTENSION_RECORD_TYPE,  /* Begin with '!' */
    -    TERMINATE_RECORD_TYPE   /* Begin with ';' */
    +        UNDEFINED_RECORD_TYPE,
    +        SCREEN_DESC_RECORD_TYPE,
    +        IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
    +        EXTENSION_RECORD_TYPE,  /* Begin with '!' */
    +        TERMINATE_RECORD_TYPE   /* Begin with ';' */
     } GifRecordType;
     
     /* func type to read gif data from arbitrary sources (TVT) */
    @@ -133,14 +133,14 @@ typedef int (*OutputFunc)(GifFileType *, const GifByteType *, int);
     ******************************************************************************/
     
     typedef struct GraphicsControlBlock {
    -    int DisposalMode;
    +        int DisposalMode;
     #define DISPOSAL_UNSPECIFIED 0 /* No disposal specified. */
     #define DISPOSE_DO_NOT 1       /* Leave image in place */
     #define DISPOSE_BACKGROUND 2   /* Set area too background color */
     #define DISPOSE_PREVIOUS 3     /* Restore to previous content */
    -    bool UserInputFlag;    /* User confirmation required before disposal */
    -    int DelayTime;         /* pre-display delay in 0.01sec units */
    -    int TransparentColor;  /* Palette index for transparency, -1 if none */
    +        bool UserInputFlag;    /* User confirmation required before disposal */
    +        int DelayTime;         /* pre-display delay in 0.01sec units */
    +        int TransparentColor;  /* Palette index for transparency, -1 if none */
     #define NO_TRANSPARENT_COLOR -1
     } GraphicsControlBlock;
     
    @@ -153,21 +153,21 @@ GifFileType *EGifOpenFileName(const char *GifFileName,
                                   const bool GifTestExistence, int *Error);
     GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error);
     GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error);
    -int EGifSpew(GifFileType *GifFile);
    +int EGifSpew(GifFileType *GifFile, int *ErrorCode);
     const char *EGifGetGifVersion(GifFileType *GifFile); /* new in 5.x */
     int EGifCloseFile(GifFileType *GifFile, int *ErrorCode);
     
     #define E_GIF_SUCCEEDED 0
    -#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */
    -#define E_GIF_ERR_WRITE_FAILED 2
    -#define E_GIF_ERR_HAS_SCRN_DSCR 3
    -#define E_GIF_ERR_HAS_IMAG_DSCR 4
    -#define E_GIF_ERR_NO_COLOR_MAP 5
    -#define E_GIF_ERR_DATA_TOO_BIG 6
    -#define E_GIF_ERR_NOT_ENOUGH_MEM 7
    -#define E_GIF_ERR_DISK_IS_FULL 8
    -#define E_GIF_ERR_CLOSE_FAILED 9
    -#define E_GIF_ERR_NOT_WRITEABLE 10
    +#define E_GIF_ERR_OPEN_FAILED 201 /* And EGif possible errors. */
    +#define E_GIF_ERR_WRITE_FAILED 202
    +#define E_GIF_ERR_HAS_SCRN_DSCR 203
    +#define E_GIF_ERR_HAS_IMAG_DSCR 204
    +#define E_GIF_ERR_NO_COLOR_MAP 205
    +#define E_GIF_ERR_DATA_TOO_BIG 206
    +#define E_GIF_ERR_NOT_ENOUGH_MEM 207
    +#define E_GIF_ERR_DISK_IS_FULL 208
    +#define E_GIF_ERR_CLOSE_FAILED 209
    +#define E_GIF_ERR_NOT_WRITEABLE 210
     
     /* These are legacy.  You probably do not want to call them directly */
     int EGifPutScreenDesc(GifFileType *GifFile, const int GifWidth,
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
    index f905e0d7b48..079d05898b4 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h
    @@ -60,30 +60,30 @@ SPDX-License-Identifier: MIT
     #define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
     
     typedef struct GifFilePrivateType {
    -    GifWord FileState, FileHandle, /* Where all this data goes to! */
    -        BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
    -        ClearCode,    /* The CLEAR LZ code. */
    -        EOFCode,      /* The EOF LZ code. */
    -        RunningCode,  /* The next code algorithm can generate. */
    -        RunningBits,  /* The number of bits required to represent
    -                         RunningCode. */
    -        MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits.
    -                   */
    -        LastCode, /* The code before the current code. */
    -        CrntCode, /* Current algorithm code. */
    -        StackPtr, /* For character stack (see below). */
    -        CrntShiftState;           /* Number of bits in CrntShiftDWord. */
    -    unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
    -    unsigned long PixelCount;     /* Number of pixels in image. */
    -    FILE *File;                   /* File as stream. */
    -    InputFunc Read;               /* function to read gif input (TVT) */
    -    OutputFunc Write;             /* function to write gif output (MRB) */
    -    GifByteType Buf[256];         /* Compressed input is buffered here. */
    -    GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
    -    GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
    -    GifPrefixType Prefix[LZ_MAX_CODE + 1];
    -    GifHashTableType *HashTable;
    -    bool gif89;
    +        GifWord FileState, FileHandle, /* Where all this data goes to! */
    +            BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
    +            ClearCode,    /* The CLEAR LZ code. */
    +            EOFCode,      /* The EOF LZ code. */
    +            RunningCode,  /* The next code algorithm can generate. */
    +            RunningBits,  /* The number of bits required to represent
    +                             RunningCode. */
    +            MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits.
    +                       */
    +            LastCode, /* The code before the current code. */
    +            CrntCode, /* Current algorithm code. */
    +            StackPtr, /* For character stack (see below). */
    +            CrntShiftState;           /* Number of bits in CrntShiftDWord. */
    +        unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
    +        unsigned long PixelCount;     /* Number of pixels in image. */
    +        FILE *File;                   /* File as stream. */
    +        InputFunc Read;               /* function to read gif input (TVT) */
    +        OutputFunc Write;             /* function to write gif output (MRB) */
    +        GifByteType Buf[256];         /* Compressed input is buffered here. */
    +        GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
    +        GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
    +        GifPrefixType Prefix[LZ_MAX_CODE + 1];
    +        GifHashTableType *HashTable;
    +        bool gif89;
     } GifFilePrivateType;
     
     #ifndef HAVE_REALLOCARRAY
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c b/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
    index 5aef3044558..25e03914496 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c
    @@ -26,9 +26,9 @@
     
      GIF construction tools
     
    -SPDX-License-Identifier: MIT
    -
     ****************************************************************************/
    +// SPDX-License-Identifier: MIT
    +// SPDX-FileCopyrightText: Copyright (C) Eric S. Raymond 
     
     #include 
     #include 
    @@ -45,14 +45,14 @@ SPDX-License-Identifier: MIT
     
     /* return smallest bitfield size n will fit in */
     int GifBitSize(int n) {
    -    register int i;
    +        register int i;
     
    -    for (i = 1; i <= 8; i++) {
    -        if ((1 << i) >= n) {
    -            break;
    +        for (i = 1; i <= 8; i++) {
    +                if ((1 << i) >= n) {
    +                        break;
    +                }
             }
    -    }
    -    return (i);
    +        return (i);
     }
     
     /******************************************************************************
    @@ -64,64 +64,64 @@ int GifBitSize(int n) {
      * ColorMap if that pointer is non-NULL.
      */
     ColorMapObject *GifMakeMapObject(int ColorCount, const GifColorType *ColorMap) {
    -    ColorMapObject *Object;
    +        ColorMapObject *Object;
     
    -    /*** FIXME: Our ColorCount has to be a power of two.  Is it necessary to
    -     * make the user know that or should we automatically round up instead?
    -     */
    -    if (ColorCount != (1 << GifBitSize(ColorCount))) {
    -        return ((ColorMapObject *)NULL);
    -    }
    +        /*** FIXME: Our ColorCount has to be a power of two.  Is it necessary to
    +         * make the user know that or should we automatically round up instead?
    +         */
    +        if (ColorCount != (1 << GifBitSize(ColorCount))) {
    +                return ((ColorMapObject *)NULL);
    +        }
     
    -    Object = (ColorMapObject *)malloc(sizeof(ColorMapObject));
    -    if (Object == (ColorMapObject *)NULL) {
    -        return ((ColorMapObject *)NULL);
    -    }
    +        Object = (ColorMapObject *)malloc(sizeof(ColorMapObject));
    +        if (Object == (ColorMapObject *)NULL) {
    +                return ((ColorMapObject *)NULL);
    +        }
     
    -    Object->Colors =
    -        (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
    -    if (Object->Colors == (GifColorType *)NULL) {
    -        free(Object);
    -        return ((ColorMapObject *)NULL);
    -    }
    +        Object->Colors =
    +            (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
    +        if (Object->Colors == (GifColorType *)NULL) {
    +                free(Object);
    +                return ((ColorMapObject *)NULL);
    +        }
     
    -    Object->ColorCount = ColorCount;
    -    Object->BitsPerPixel = GifBitSize(ColorCount);
    -    Object->SortFlag = false;
    +        Object->ColorCount = ColorCount;
    +        Object->BitsPerPixel = GifBitSize(ColorCount);
    +        Object->SortFlag = false;
     
    -    if (ColorMap != NULL) {
    -        memcpy((char *)Object->Colors, (char *)ColorMap,
    -               ColorCount * sizeof(GifColorType));
    -    }
    +        if (ColorMap != NULL) {
    +                memcpy((char *)Object->Colors, (char *)ColorMap,
    +                       ColorCount * sizeof(GifColorType));
    +        }
     
    -    return (Object);
    +        return (Object);
     }
     
     /*******************************************************************************
      Free a color map object
     *******************************************************************************/
     void GifFreeMapObject(ColorMapObject *Object) {
    -    if (Object != NULL) {
    -        (void)free(Object->Colors);
    -        (void)free(Object);
    -    }
    +        if (Object != NULL) {
    +                (void)free(Object->Colors);
    +                (void)free(Object);
    +        }
     }
     
     #ifdef DEBUG
     void DumpColorMap(ColorMapObject *Object, FILE *fp) {
    -    if (Object != NULL) {
    -        int i, j, Len = Object->ColorCount;
    +        if (Object != NULL) {
    +                int i, j, Len = Object->ColorCount;
     
    -        for (i = 0; i < Len; i += 4) {
    -            for (j = 0; j < 4 && j < Len; j++) {
    -                (void)fprintf(fp, "%3d: %02x %02x %02x   ",
    -                              i + j, Object->Colors[i + j].Red,
    -                              Object->Colors[i + j].Green,
    -                              Object->Colors[i + j].Blue);
    -            }
    -            (void)fprintf(fp, "\n");
    +                for (i = 0; i < Len; i += 4) {
    +                        for (j = 0; j < 4 && j < Len; j++) {
    +                                (void)fprintf(fp, "%3d: %02x %02x %02x   ",
    +                                              i + j, Object->Colors[i + j].Red,
    +                                              Object->Colors[i + j].Green,
    +                                              Object->Colors[i + j].Blue);
    +                        }
    +                        (void)fprintf(fp, "\n");
    +                }
             }
    -    }
     }
     #endif /* DEBUG */
     
    @@ -135,112 +135,112 @@ void DumpColorMap(ColorMapObject *Object, FILE *fp) {
     ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,
                                      const ColorMapObject *ColorIn2,
                                      GifPixelType ColorTransIn2[]) {
    -    int i, j, CrntSlot, RoundUpTo, NewGifBitSize;
    -    ColorMapObject *ColorUnion;
    -
    -    /*
    -     * We don't worry about duplicates within either color map; if
    -     * the caller wants to resolve those, he can perform unions
    -     * with an empty color map.
    -     */
    -
    -    /* Allocate table which will hold the result for sure. */
    -    ColorUnion = GifMakeMapObject(
    -        MAX(ColorIn1->ColorCount, ColorIn2->ColorCount) * 2, NULL);
    -
    -    if (ColorUnion == NULL) {
    -        return (NULL);
    -    }
    -
    -    /*
    -     * Copy ColorIn1 to ColorUnion.
    -     */
    -    for (i = 0; i < ColorIn1->ColorCount; i++) {
    -        ColorUnion->Colors[i] = ColorIn1->Colors[i];
    -    }
    -    CrntSlot = ColorIn1->ColorCount;
    -
    -    /*
    -     * Potentially obnoxious hack:
    -     *
    -     * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end
    -     * of table 1.  This is very useful if your display is limited to
    -     * 16 colors.
    -     */
    -    while (ColorIn1->Colors[CrntSlot - 1].Red == 0 &&
    -           ColorIn1->Colors[CrntSlot - 1].Green == 0 &&
    -           ColorIn1->Colors[CrntSlot - 1].Blue == 0) {
    -        CrntSlot--;
    -    }
    -
    -    /* Copy ColorIn2 to ColorUnion (use old colors if they exist): */
    -    for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) {
    -        /* Let's see if this color already exists: */
    -        for (j = 0; j < ColorIn1->ColorCount; j++) {
    -            if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i],
    -                       sizeof(GifColorType)) == 0) {
    -                break;
    -            }
    -        }
    -
    -        if (j < ColorIn1->ColorCount) {
    -            ColorTransIn2[i] = j; /* color exists in Color1 */
    -        } else {
    -            /* Color is new - copy it to a new slot: */
    -            ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
    -            ColorTransIn2[i] = CrntSlot++;
    -        }
    -    }
    -
    -    if (CrntSlot > 256) {
    -        GifFreeMapObject(ColorUnion);
    -        return ((ColorMapObject *)NULL);
    -    }
    -
    -    NewGifBitSize = GifBitSize(CrntSlot);
    -    RoundUpTo = (1 << NewGifBitSize);
    -
    -    if (RoundUpTo != ColorUnion->ColorCount) {
    -        register GifColorType *Map = ColorUnion->Colors;
    +        int i, j, CrntSlot, RoundUpTo, NewGifBitSize;
    +        ColorMapObject *ColorUnion;
     
             /*
    -         * Zero out slots up to next power of 2.
    -         * We know these slots exist because of the way ColorUnion's
    -         * start dimension was computed.
    +         * We don't worry about duplicates within either color map; if
    +         * the caller wants to resolve those, he can perform unions
    +         * with an empty color map.
              */
    -        for (j = CrntSlot; j < RoundUpTo; j++) {
    -            Map[j].Red = Map[j].Green = Map[j].Blue = 0;
    +
    +        /* Allocate table which will hold the result for sure. */
    +        ColorUnion = GifMakeMapObject(
    +            MAX(ColorIn1->ColorCount, ColorIn2->ColorCount) * 2, NULL);
    +
    +        if (ColorUnion == NULL) {
    +                return (NULL);
             }
     
    -        /* perhaps we can shrink the map? */
    -        if (RoundUpTo < ColorUnion->ColorCount) {
    -            GifColorType *new_map = (GifColorType *)reallocarray(
    -                Map, RoundUpTo, sizeof(GifColorType));
    -            if (new_map == NULL) {
    +        /*
    +         * Copy ColorIn1 to ColorUnion.
    +         */
    +        for (i = 0; i < ColorIn1->ColorCount; i++) {
    +                ColorUnion->Colors[i] = ColorIn1->Colors[i];
    +        }
    +        CrntSlot = ColorIn1->ColorCount;
    +
    +        /*
    +         * Potentially obnoxious hack:
    +         *
    +         * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end
    +         * of table 1.  This is very useful if your display is limited to
    +         * 16 colors.
    +         */
    +        while (ColorIn1->Colors[CrntSlot - 1].Red == 0 &&
    +               ColorIn1->Colors[CrntSlot - 1].Green == 0 &&
    +               ColorIn1->Colors[CrntSlot - 1].Blue == 0) {
    +                CrntSlot--;
    +        }
    +
    +        /* Copy ColorIn2 to ColorUnion (use old colors if they exist): */
    +        for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) {
    +                /* Let's see if this color already exists: */
    +                for (j = 0; j < ColorIn1->ColorCount; j++) {
    +                        if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i],
    +                                   sizeof(GifColorType)) == 0) {
    +                                break;
    +                        }
    +                }
    +
    +                if (j < ColorIn1->ColorCount) {
    +                        ColorTransIn2[i] = j; /* color exists in Color1 */
    +                } else {
    +                        /* Color is new - copy it to a new slot: */
    +                        ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
    +                        ColorTransIn2[i] = CrntSlot++;
    +                }
    +        }
    +
    +        if (CrntSlot > 256) {
                     GifFreeMapObject(ColorUnion);
                     return ((ColorMapObject *)NULL);
    -            }
    -            ColorUnion->Colors = new_map;
             }
    -    }
     
    -    ColorUnion->ColorCount = RoundUpTo;
    -    ColorUnion->BitsPerPixel = NewGifBitSize;
    +        NewGifBitSize = GifBitSize(CrntSlot);
    +        RoundUpTo = (1 << NewGifBitSize);
     
    -    return (ColorUnion);
    +        if (RoundUpTo != ColorUnion->ColorCount) {
    +                register GifColorType *Map = ColorUnion->Colors;
    +
    +                /*
    +                 * Zero out slots up to next power of 2.
    +                 * We know these slots exist because of the way ColorUnion's
    +                 * start dimension was computed.
    +                 */
    +                for (j = CrntSlot; j < RoundUpTo; j++) {
    +                        Map[j].Red = Map[j].Green = Map[j].Blue = 0;
    +                }
    +
    +                /* perhaps we can shrink the map? */
    +                if (RoundUpTo < ColorUnion->ColorCount) {
    +                        GifColorType *new_map = (GifColorType *)reallocarray(
    +                            Map, RoundUpTo, sizeof(GifColorType));
    +                        if (new_map == NULL) {
    +                                GifFreeMapObject(ColorUnion);
    +                                return ((ColorMapObject *)NULL);
    +                        }
    +                        ColorUnion->Colors = new_map;
    +                }
    +        }
    +
    +        ColorUnion->ColorCount = RoundUpTo;
    +        ColorUnion->BitsPerPixel = NewGifBitSize;
    +
    +        return (ColorUnion);
     }
     
     /*******************************************************************************
      Apply a given color translation to the raster bits of an image
     *******************************************************************************/
     void GifApplyTranslation(SavedImage *Image, const GifPixelType Translation[]) {
    -    register int i;
    -    register int RasterSize =
    -        Image->ImageDesc.Height * Image->ImageDesc.Width;
    +        register int i;
    +        register int RasterSize =
    +            Image->ImageDesc.Height * Image->ImageDesc.Width;
     
    -    for (i = 0; i < RasterSize; i++) {
    -        Image->RasterBits[i] = Translation[Image->RasterBits[i]];
    -    }
    +        for (i = 0; i < RasterSize; i++) {
    +                Image->RasterBits[i] = Translation[Image->RasterBits[i]];
    +        }
     }
     
     /******************************************************************************
    @@ -249,56 +249,56 @@ void GifApplyTranslation(SavedImage *Image, const GifPixelType Translation[]) {
     int GifAddExtensionBlock(int *ExtensionBlockCount,
                              ExtensionBlock **ExtensionBlocks, int Function,
                              unsigned int Len, unsigned char ExtData[]) {
    -    ExtensionBlock *ep;
    +        ExtensionBlock *ep;
     
    -    if (*ExtensionBlocks == NULL) {
    -        *ExtensionBlocks =
    -            (ExtensionBlock *)malloc(sizeof(ExtensionBlock));
    -    } else {
    -        ExtensionBlock *ep_new = (ExtensionBlock *)reallocarray(
    -            *ExtensionBlocks, (*ExtensionBlockCount + 1),
    -            sizeof(ExtensionBlock));
    -        if (ep_new == NULL) {
    -            return (GIF_ERROR);
    +        if (*ExtensionBlocks == NULL) {
    +                *ExtensionBlocks =
    +                    (ExtensionBlock *)malloc(sizeof(ExtensionBlock));
    +        } else {
    +                ExtensionBlock *ep_new = (ExtensionBlock *)reallocarray(
    +                    *ExtensionBlocks, (*ExtensionBlockCount + 1),
    +                    sizeof(ExtensionBlock));
    +                if (ep_new == NULL) {
    +                        return (GIF_ERROR);
    +                }
    +                *ExtensionBlocks = ep_new;
             }
    -        *ExtensionBlocks = ep_new;
    -    }
     
    -    if (*ExtensionBlocks == NULL) {
    -        return (GIF_ERROR);
    -    }
    +        if (*ExtensionBlocks == NULL) {
    +                return (GIF_ERROR);
    +        }
     
    -    ep = &(*ExtensionBlocks)[(*ExtensionBlockCount)++];
    +        ep = &(*ExtensionBlocks)[(*ExtensionBlockCount)++];
     
    -    ep->Function = Function;
    -    ep->ByteCount = Len;
    -    ep->Bytes = (GifByteType *)malloc(ep->ByteCount);
    -    if (ep->Bytes == NULL) {
    -        return (GIF_ERROR);
    -    }
    +        ep->Function = Function;
    +        ep->ByteCount = Len;
    +        ep->Bytes = (GifByteType *)malloc(ep->ByteCount);
    +        if (ep->Bytes == NULL) {
    +                return (GIF_ERROR);
    +        }
     
    -    if (ExtData != NULL) {
    -        memcpy(ep->Bytes, ExtData, Len);
    -    }
    +        if (ExtData != NULL) {
    +                memcpy(ep->Bytes, ExtData, Len);
    +        }
     
    -    return (GIF_OK);
    +        return (GIF_OK);
     }
     
     void GifFreeExtensions(int *ExtensionBlockCount,
                            ExtensionBlock **ExtensionBlocks) {
    -    ExtensionBlock *ep;
    +        ExtensionBlock *ep;
     
    -    if (*ExtensionBlocks == NULL) {
    -        return;
    -    }
    +        if (*ExtensionBlocks == NULL) {
    +                return;
    +        }
     
    -    for (ep = *ExtensionBlocks;
    -         ep < (*ExtensionBlocks + *ExtensionBlockCount); ep++) {
    -        (void)free((char *)ep->Bytes);
    -    }
    -    (void)free((char *)*ExtensionBlocks);
    -    *ExtensionBlocks = NULL;
    -    *ExtensionBlockCount = 0;
    +        for (ep = *ExtensionBlocks;
    +             ep < (*ExtensionBlocks + *ExtensionBlockCount); ep++) {
    +                (void)free((char *)ep->Bytes);
    +        }
    +        (void)free((char *)*ExtensionBlocks);
    +        *ExtensionBlocks = NULL;
    +        *ExtensionBlockCount = 0;
     }
     
     /******************************************************************************
    @@ -309,37 +309,37 @@ void GifFreeExtensions(int *ExtensionBlockCount,
      * Frees the last image in the GifFile->SavedImages array
      */
     void FreeLastSavedImage(GifFileType *GifFile) {
    -    SavedImage *sp;
    +        SavedImage *sp;
     
    -    if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
    -        return;
    -    }
    +        if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
    +                return;
    +        }
     
    -    /* Remove one SavedImage from the GifFile */
    -    GifFile->ImageCount--;
    -    sp = &GifFile->SavedImages[GifFile->ImageCount];
    +        /* Remove one SavedImage from the GifFile */
    +        GifFile->ImageCount--;
    +        sp = &GifFile->SavedImages[GifFile->ImageCount];
     
    -    /* Deallocate its Colormap */
    -    if (sp->ImageDesc.ColorMap != NULL) {
    -        GifFreeMapObject(sp->ImageDesc.ColorMap);
    -        sp->ImageDesc.ColorMap = NULL;
    -    }
    +        /* Deallocate its Colormap */
    +        if (sp->ImageDesc.ColorMap != NULL) {
    +                GifFreeMapObject(sp->ImageDesc.ColorMap);
    +                sp->ImageDesc.ColorMap = NULL;
    +        }
     
    -    /* Deallocate the image data */
    -    if (sp->RasterBits != NULL) {
    -        free((char *)sp->RasterBits);
    -    }
    +        /* Deallocate the image data */
    +        if (sp->RasterBits != NULL) {
    +                free((char *)sp->RasterBits);
    +        }
     
    -    /* Deallocate any extensions */
    -    GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
    +        /* Deallocate any extensions */
    +        GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
     
    -    /*** FIXME: We could realloc the GifFile->SavedImages structure but is
    -     * there a point to it? Saves some memory but we'd have to do it every
    -     * time.  If this is used in GifFreeSavedImages then it would be
    -     * inefficient (The whole array is going to be deallocated.)  If we just
    -     * use it when we want to free the last Image it's convenient to do it
    -     * here.
    -     */
    +        /*** FIXME: We could realloc the GifFile->SavedImages structure but is
    +         * there a point to it? Saves some memory but we'd have to do it every
    +         * time.  If this is used in GifFreeSavedImages then it would be
    +         * inefficient (The whole array is going to be deallocated.)  If we just
    +         * use it when we want to free the last Image it's convenient to do it
    +         * here.
    +         */
     }
     
     /*
    @@ -347,103 +347,129 @@ void FreeLastSavedImage(GifFileType *GifFile) {
      */
     SavedImage *GifMakeSavedImage(GifFileType *GifFile,
                                   const SavedImage *CopyFrom) {
    -    // cppcheck-suppress ctunullpointer
    -    if (GifFile->SavedImages == NULL) {
    -        GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
    -    } else {
    -        SavedImage *newSavedImages = (SavedImage *)reallocarray(
    -            GifFile->SavedImages, (GifFile->ImageCount + 1),
    -            sizeof(SavedImage));
    -        if (newSavedImages == NULL) {
    -            return ((SavedImage *)NULL);
    -        }
    -        GifFile->SavedImages = newSavedImages;
    -    }
    -    if (GifFile->SavedImages == NULL) {
    -        return ((SavedImage *)NULL);
    -    } else {
    -        SavedImage *sp = &GifFile->SavedImages[GifFile->ImageCount++];
    -
    -        if (CopyFrom != NULL) {
    -            memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
    -
    -            /*
    -             * Make our own allocated copies of the heap fields in
    -             * the copied record.  This guards against potential
    -             * aliasing problems.
    -             */
    -
    -            /* first, the local color map */
    -            if (CopyFrom->ImageDesc.ColorMap != NULL) {
    -                sp->ImageDesc.ColorMap = GifMakeMapObject(
    -                    CopyFrom->ImageDesc.ColorMap->ColorCount,
    -                    CopyFrom->ImageDesc.ColorMap->Colors);
    -                if (sp->ImageDesc.ColorMap == NULL) {
    -                    FreeLastSavedImage(GifFile);
    -                    return (SavedImage *)(NULL);
    -                }
    -            }
    -
    -            /* next, the raster */
    -            sp->RasterBits = (unsigned char *)reallocarray(
    -                NULL,
    -                (CopyFrom->ImageDesc.Height *
    -                 CopyFrom->ImageDesc.Width),
    -                sizeof(GifPixelType));
    -            if (sp->RasterBits == NULL) {
    -                FreeLastSavedImage(GifFile);
    -                return (SavedImage *)(NULL);
    -            }
    -            memcpy(sp->RasterBits, CopyFrom->RasterBits,
    -                   sizeof(GifPixelType) *
    -                       CopyFrom->ImageDesc.Height *
    -                       CopyFrom->ImageDesc.Width);
    -
    -            /* finally, the extension blocks */
    -            if (CopyFrom->ExtensionBlocks != NULL) {
    -                sp->ExtensionBlocks =
    -                    (ExtensionBlock *)reallocarray(
    -                        NULL, CopyFrom->ExtensionBlockCount,
    -                        sizeof(ExtensionBlock));
    -                if (sp->ExtensionBlocks == NULL) {
    -                    FreeLastSavedImage(GifFile);
    -                    return (SavedImage *)(NULL);
    -                }
    -                memcpy(sp->ExtensionBlocks,
    -                       CopyFrom->ExtensionBlocks,
    -                       sizeof(ExtensionBlock) *
    -                           CopyFrom->ExtensionBlockCount);
    -            }
    +        // cppcheck-suppress ctunullpointer
    +        if (GifFile->SavedImages == NULL) {
    +                GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
             } else {
    -            memset((char *)sp, '\0', sizeof(SavedImage));
    +                SavedImage *newSavedImages = (SavedImage *)reallocarray(
    +                    GifFile->SavedImages, (GifFile->ImageCount + 1),
    +                    sizeof(SavedImage));
    +                if (newSavedImages == NULL) {
    +                        return ((SavedImage *)NULL);
    +                }
    +                GifFile->SavedImages = newSavedImages;
             }
    +        if (GifFile->SavedImages == NULL) {
    +                return ((SavedImage *)NULL);
    +        } else {
    +                SavedImage *sp = &GifFile->SavedImages[GifFile->ImageCount++];
     
    -        return (sp);
    -    }
    +                if (CopyFrom != NULL) {
    +                        memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
    +
    +                        /*
    +                         * Make our own allocated copies of the heap fields in
    +                         * the copied record.  This guards against potential
    +                         * aliasing problems.
    +                         */
    +
    +                        /* Null out aliased pointers before any allocations
    +                         * so that FreeLastSavedImage won't free CopyFrom's
    +                         * data if an allocation fails partway through. */
    +                        sp->ImageDesc.ColorMap = NULL;
    +                        sp->RasterBits = NULL;
    +                        sp->ExtensionBlocks = NULL;
    +                        sp->ExtensionBlockCount = 0;
    +
    +                        /* first, the local color map */
    +                        if (CopyFrom->ImageDesc.ColorMap != NULL) {
    +                                sp->ImageDesc.ColorMap = GifMakeMapObject(
    +                                    CopyFrom->ImageDesc.ColorMap->ColorCount,
    +                                    CopyFrom->ImageDesc.ColorMap->Colors);
    +                                if (sp->ImageDesc.ColorMap == NULL) {
    +                                        FreeLastSavedImage(GifFile);
    +                                        return (SavedImage *)(NULL);
    +                                }
    +                        }
    +
    +                        /* next, the raster */
    +                        sp->RasterBits = (unsigned char *)reallocarray(
    +                            NULL,
    +                            (CopyFrom->ImageDesc.Height *
    +                             CopyFrom->ImageDesc.Width),
    +                            sizeof(GifPixelType));
    +                        if (sp->RasterBits == NULL) {
    +                                FreeLastSavedImage(GifFile);
    +                                return (SavedImage *)(NULL);
    +                        }
    +                        memcpy(sp->RasterBits, CopyFrom->RasterBits,
    +                               sizeof(GifPixelType) *
    +                                   CopyFrom->ImageDesc.Height *
    +                                   CopyFrom->ImageDesc.Width);
    +
    +                        /* finally, the extension blocks */
    +                        if (CopyFrom->ExtensionBlocks != NULL) {
    +                                int k;
    +                                sp->ExtensionBlocks =
    +                                    (ExtensionBlock *)calloc(
    +                                        CopyFrom->ExtensionBlockCount,
    +                                        sizeof(ExtensionBlock));
    +                                if (sp->ExtensionBlocks == NULL) {
    +                                        FreeLastSavedImage(GifFile);
    +                                        return (SavedImage *)(NULL);
    +                                }
    +                                for (k = 0; k < CopyFrom->ExtensionBlockCount;
    +                                     k++) {
    +                                        ExtensionBlock *dst =
    +                                            &sp->ExtensionBlocks[k];
    +                                        ExtensionBlock *src =
    +                                            &CopyFrom->ExtensionBlocks[k];
    +                                        dst->Function = src->Function;
    +                                        dst->ByteCount = src->ByteCount;
    +                                        if (src->ByteCount > 0) {
    +                                                dst->Bytes =
    +                                                    (GifByteType *)malloc(
    +                                                        src->ByteCount);
    +                                                if (dst->Bytes == NULL) {
    +                                                        FreeLastSavedImage(
    +                                                            GifFile);
    +                                                        return (SavedImage *)(NULL);
    +                                                }
    +                                                memcpy(dst->Bytes, src->Bytes,
    +                                                       src->ByteCount);
    +                                        }
    +                                }
    +                        }
    +                } else {
    +                        memset((char *)sp, '\0', sizeof(SavedImage));
    +                }
    +
    +                return (sp);
    +        }
     }
     
     void GifFreeSavedImages(GifFileType *GifFile) {
    -    SavedImage *sp;
    +        SavedImage *sp;
     
    -    if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
    -        return;
    -    }
    -    for (sp = GifFile->SavedImages;
    -         sp < GifFile->SavedImages + GifFile->ImageCount; sp++) {
    -        if (sp->ImageDesc.ColorMap != NULL) {
    -            GifFreeMapObject(sp->ImageDesc.ColorMap);
    -            sp->ImageDesc.ColorMap = NULL;
    +        if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
    +                return;
             }
    +        for (sp = GifFile->SavedImages;
    +             sp < GifFile->SavedImages + GifFile->ImageCount; sp++) {
    +                if (sp->ImageDesc.ColorMap != NULL) {
    +                        GifFreeMapObject(sp->ImageDesc.ColorMap);
    +                        sp->ImageDesc.ColorMap = NULL;
    +                }
     
    -        if (sp->RasterBits != NULL) {
    -            free((char *)sp->RasterBits);
    +                if (sp->RasterBits != NULL) {
    +                        free((char *)sp->RasterBits);
    +                }
    +
    +                GifFreeExtensions(&sp->ExtensionBlockCount,
    +                                  &sp->ExtensionBlocks);
             }
    -
    -        GifFreeExtensions(&sp->ExtensionBlockCount,
    -                          &sp->ExtensionBlocks);
    -    }
    -    free((char *)GifFile->SavedImages);
    -    GifFile->SavedImages = NULL;
    +        free((char *)GifFile->SavedImages);
    +        GifFile->SavedImages = NULL;
     }
     
     /* end */
    diff --git a/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c b/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
    index 7420af674c5..57504fceaa9 100644
    --- a/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
    +++ b/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c
    @@ -22,9 +22,8 @@
      * questions.
      */
     
    -/*    $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $    */
     /*
    - * Copyright (c) 2008 Otto Moerbeek 
    + * SPDX-FileCopyrightText: Copyright (C) 2008 Otto Moerbeek 
      * SPDX-License-Identifier: MIT
      */
     
    @@ -44,55 +43,55 @@
     #define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
     
     void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size) {
    -    if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
    -        nmemb > 0 && SIZE_MAX / nmemb < size) {
    -        errno = ENOMEM;
    -        return NULL;
    -    }
    -    /*
    -     * Head off variations in realloc behavior on different
    -     * platforms (reported by MarkR )
    -     *
    -     * The behaviour of reallocarray is implementation-defined if
    -     * nmemb or size is zero. It can return NULL or non-NULL
    -     * depending on the platform.
    -     * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations
    -     *
    -     * Here are some extracts from realloc man pages on different platforms.
    -     *
    -     * void realloc( void memblock, size_t size );
    -     *
    -     * Windows:
    -     *
    -     * If there is not enough available memory to expand the block
    -     * to the given size, the original block is left unchanged,
    -     * and NULL is returned.  If size is zero, then the block
    -     * pointed to by memblock is freed; the return value is NULL,
    -     * and memblock is left pointing at a freed block.
    -     *
    -     * OpenBSD:
    -     *
    -     * If size or nmemb is equal to 0, a unique pointer to an
    -     * access protected, zero sized object is returned. Access via
    -     * this pointer will generate a SIGSEGV exception.
    -     *
    -     * Linux:
    -     *
    -     * If size was equal to 0, either NULL or a pointer suitable
    -     * to be passed to free() is returned.
    -     *
    -     * OS X:
    -     *
    -     * If size is zero and ptr is not NULL, a new, minimum sized
    -     * object is allocated and the original object is freed.
    -     *
    -     * It looks like images with zero width or height can trigger
    -     * this, and fuzzing behaviour will differ by platform, so
    -     * fuzzing on one platform may not detect zero-size allocation
    -     * problems on other platforms.
    -     */
    -    if (size == 0 || nmemb == 0) {
    -        return NULL;
    -    }
    -    return realloc(optr, size * nmemb);
    +        if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
    +            nmemb > 0 && SIZE_MAX / nmemb < size) {
    +                errno = ENOMEM;
    +                return NULL;
    +        }
    +        /*
    +         * Head off variations in realloc behavior on different
    +         * platforms (reported by MarkR )
    +         *
    +         * The behaviour of reallocarray is implementation-defined if
    +         * nmemb or size is zero. It can return NULL or non-NULL
    +         * depending on the platform.
    +         * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations
    +         *
    +         * Here are some extracts from realloc man pages on different platforms.
    +         *
    +         * void realloc( void memblock, size_t size );
    +         *
    +         * Windows:
    +         *
    +         * If there is not enough available memory to expand the block
    +         * to the given size, the original block is left unchanged,
    +         * and NULL is returned.  If size is zero, then the block
    +         * pointed to by memblock is freed; the return value is NULL,
    +         * and memblock is left pointing at a freed block.
    +         *
    +         * OpenBSD:
    +         *
    +         * If size or nmemb is equal to 0, a unique pointer to an
    +         * access protected, zero sized object is returned. Access via
    +         * this pointer will generate a SIGSEGV exception.
    +         *
    +         * Linux:
    +         *
    +         * If size was equal to 0, either NULL or a pointer suitable
    +         * to be passed to free() is returned.
    +         *
    +         * OS X:
    +         *
    +         * If size is zero and ptr is not NULL, a new, minimum sized
    +         * object is allocated and the original object is freed.
    +         *
    +         * It looks like images with zero width or height can trigger
    +         * this, and fuzzing behaviour will differ by platform, so
    +         * fuzzing on one platform may not detect zero-size allocation
    +         * problems on other platforms.
    +         */
    +        if (size == 0 || nmemb == 0) {
    +                return NULL;
    +        }
    +        return realloc(optr, size * nmemb);
     }
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
    index 3bb1baecd23..af9fcff6eb3 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
    @@ -5988,7 +5988,7 @@ Version 1.6.32rc01 [August 18, 2017]
     
     Version 1.6.32rc02 [August 22, 2017]
       Added contrib/oss-fuzz directory which contains files used by the oss-fuzz
    -    project (https://github.com/google/oss-fuzz/tree/master/projects/libpng).
    +    project .
     
     Version 1.6.32 [August 24, 2017]
       No changes.
    @@ -6323,15 +6323,21 @@ Version 1.6.53 [December 5, 2025]
     
     Version 1.6.54 [January 12, 2026]
       Fixed CVE-2026-22695 (medium severity):
    -    Heap buffer over-read in `png_image_read_direct_scaled.
    +    Heap buffer over-read in `png_image_read_direct_scaled`.
         (Reported and fixed by Petr Simecek.)
       Fixed CVE-2026-22801 (medium severity):
         Integer truncation causing heap buffer over-read in `png_image_write_*`.
       Implemented various improvements in oss-fuzz.
         (Contributed by Philippe Antoine.)
     
    +Version 1.6.55 [February 9, 2026]
    +  Fixed CVE-2026-25646 (high severity):
    +    Heap buffer overflow in `png_set_quantize`.
    +    (Reported and fixed by Joshua Inscoe.)
    +  Resolved an oss-fuzz build issue involving nalloc.
    +    (Contributed by Philippe Antoine.)
     
     Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
     Subscription is required; visit
    -https://lists.sourceforge.net/lists/listinfo/png-mng-implement
    +
     to subscribe.
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/README b/src/java.desktop/share/native/libsplashscreen/libpng/README
    index 63d1376edf7..6e0d1e33137 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/README
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/README
    @@ -1,4 +1,4 @@
    -README for libpng version 1.6.54
    +README for libpng version 1.6.55
     ================================
     
     See the note about version numbers near the top of `png.h`.
    @@ -24,14 +24,14 @@ for more things than just PNG files.  You can use zlib as a drop-in
     replacement for `fread()` and `fwrite()`, if you are so inclined.
     
     zlib should be available at the same place that libpng is, or at
    -https://zlib.net .
    +.
     
     You may also want a copy of the PNG specification.  It is available
     as an RFC, a W3C Recommendation, and an ISO/IEC Standard.  You can find
    -these at http://www.libpng.org/pub/png/pngdocs.html .
    +these at .
     
    -This code is currently being archived at https://libpng.sourceforge.io
    -in the download area, and at http://libpng.download/src .
    +This code is currently being archived at 
    +in the download area, and at .
     
     This release, based in a large way on Glenn's, Guy's and Andreas'
     earlier work, was created and will be supported by myself and the PNG
    @@ -39,12 +39,12 @@ development group.
     
     Send comments, corrections and commendations to `png-mng-implement`
     at `lists.sourceforge.net`.  (Subscription is required; visit
    -https://lists.sourceforge.net/lists/listinfo/png-mng-implement
    +
     to subscribe.)
     
     Send general questions about the PNG specification to `png-mng-misc`
     at `lists.sourceforge.net`.  (Subscription is required; visit
    -https://lists.sourceforge.net/lists/listinfo/png-mng-misc
    +
     to subscribe.)
     
     Historical notes
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.c b/src/java.desktop/share/native/libsplashscreen/libpng/png.c
    index 5636b4a754e..955fda8dd7e 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/png.c
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.c
    @@ -42,7 +42,7 @@
     #include "pngpriv.h"
     
     /* Generate a compiler error if there is an old png.h in the search path. */
    -typedef png_libpng_version_1_6_54 Your_png_h_is_not_version_1_6_54;
    +typedef png_libpng_version_1_6_55 Your_png_h_is_not_version_1_6_55;
     
     /* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
      * corresponding macro definitions.  This causes a compile time failure if
    @@ -849,7 +849,7 @@ png_get_copyright(png_const_structrp png_ptr)
        return PNG_STRING_COPYRIGHT
     #else
        return PNG_STRING_NEWLINE \
    -      "libpng version 1.6.54" PNG_STRING_NEWLINE \
    +      "libpng version 1.6.55" PNG_STRING_NEWLINE \
           "Copyright (c) 2018-2026 Cosmin Truta" PNG_STRING_NEWLINE \
           "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
           PNG_STRING_NEWLINE \
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/png.h b/src/java.desktop/share/native/libsplashscreen/libpng/png.h
    index ab8876a9626..e95c0444399 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/png.h
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/png.h
    @@ -29,7 +29,7 @@
      * However, the following notice accompanied the original version of this
      * file and, per its terms, should not be removed:
      *
    - * libpng version 1.6.54
    + * libpng version 1.6.55
      *
      * Copyright (c) 2018-2026 Cosmin Truta
      * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
    @@ -43,7 +43,7 @@
      *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
      *   libpng versions 0.97, January 1998, through 1.6.35, July 2018:
      *     Glenn Randers-Pehrson
    - *   libpng versions 1.6.36, December 2018, through 1.6.54, January 2026:
    + *   libpng versions 1.6.36, December 2018, through 1.6.55, February 2026:
      *     Cosmin Truta
      *   See also "Contributing Authors", below.
      */
    @@ -267,7 +267,7 @@
      *    ...
      *    1.5.30                  15    10530  15.so.15.30[.0]
      *    ...
    - *    1.6.54                  16    10654  16.so.16.54[.0]
    + *    1.6.55                  16    10655  16.so.16.55[.0]
      *
      *    Henceforth the source version will match the shared-library major and
      *    minor numbers; the shared-library major version number will be used for
    @@ -303,7 +303,7 @@
      */
     
     /* Version information for png.h - this should match the version in png.c */
    -#define PNG_LIBPNG_VER_STRING "1.6.54"
    +#define PNG_LIBPNG_VER_STRING "1.6.55"
     #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
     
     /* The versions of shared library builds should stay in sync, going forward */
    @@ -314,7 +314,7 @@
     /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
     #define PNG_LIBPNG_VER_MAJOR   1
     #define PNG_LIBPNG_VER_MINOR   6
    -#define PNG_LIBPNG_VER_RELEASE 54
    +#define PNG_LIBPNG_VER_RELEASE 55
     
     /* This should be zero for a public release, or non-zero for a
      * development version.
    @@ -345,7 +345,7 @@
      * From version 1.0.1 it is:
      * XXYYZZ, where XX=major, YY=minor, ZZ=release
      */
    -#define PNG_LIBPNG_VER 10654 /* 1.6.54 */
    +#define PNG_LIBPNG_VER 10655 /* 1.6.55 */
     
     /* Library configuration: these options cannot be changed after
      * the library has been built.
    @@ -455,7 +455,7 @@ extern "C" {
     /* This triggers a compiler error in png.c, if png.c and png.h
      * do not agree upon the version number.
      */
    -typedef char *png_libpng_version_1_6_54;
    +typedef char *png_libpng_version_1_6_55;
     
     /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
      *
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
    index 959c604edbc..b957f8b5061 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
    @@ -29,7 +29,7 @@
      * However, the following notice accompanied the original version of this
      * file and, per its terms, should not be removed:
      *
    - * libpng version 1.6.54
    + * libpng version 1.6.55
      *
      * Copyright (c) 2018-2026 Cosmin Truta
      * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
    index b413b510acf..ae1ab462072 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
    @@ -31,7 +31,7 @@
      * However, the following notice accompanied the original version of this
      * file and, per its terms, should not be removed:
      */
    -/* libpng version 1.6.54 */
    +/* libpng version 1.6.55 */
     
     /* Copyright (c) 2018-2026 Cosmin Truta */
     /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
    diff --git a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
    index 7680fe64828..fcce80da1cb 100644
    --- a/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
    +++ b/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
    @@ -29,7 +29,7 @@
      * However, the following notice accompanied the original version of this
      * file and, per its terms, should not be removed:
      *
    - * Copyright (c) 2018-2025 Cosmin Truta
    + * Copyright (c) 2018-2026 Cosmin Truta
      * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
      * Copyright (c) 1996-1997 Andreas Dilger
      * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
    @@ -737,8 +737,8 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
                              break;
     
                          t->next = hash[d];
    -                     t->left = (png_byte)i;
    -                     t->right = (png_byte)j;
    +                     t->left = png_ptr->palette_to_index[i];
    +                     t->right = png_ptr->palette_to_index[j];
                          hash[d] = t;
                       }
                    }
    diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java
    index a7130fa7fe9..560e114982f 100644
    --- a/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java
    +++ b/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -35,7 +35,6 @@ import java.util.Iterator;
     import sun.awt.AWTAccessor;
     import sun.util.logging.PlatformLogger;
     
    -import sun.awt.AppContext;
     import sun.awt.SunToolkit;
     
     import sun.awt.dnd.SunDropTargetContextPeer;
    @@ -55,20 +54,14 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
     
         private static final Unsafe unsafe = XlibWrapper.unsafe;
     
    -    /*
    -     * A key to store a peer instance for an AppContext.
    -     */
    -    private static final Object DTCP_KEY = "DropTargetContextPeer";
    -
         private XDropTargetContextPeer() {}
     
    -    static XDropTargetContextPeer getPeer(AppContext appContext) {
    +    private static XDropTargetContextPeer peer;
    +
    +    static XDropTargetContextPeer getPeer() {
             synchronized (_globalLock) {
    -            XDropTargetContextPeer peer =
    -                (XDropTargetContextPeer)appContext.get(DTCP_KEY);
                 if (peer == null) {
                     peer = new XDropTargetContextPeer();
    -                appContext.put(DTCP_KEY, peer);
                 }
     
                 return peer;
    @@ -261,17 +254,11 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
                                                      int eventID) {
                 Object target = xwindow.getTarget();
     
    -            // The Every component is associated with some AppContext.
                 assert target instanceof Component;
     
                 Component component = (Component)target;
     
    -            AppContext appContext = SunToolkit.targetToAppContext(target);
    -
    -            // Every component is associated with some AppContext.
    -            assert appContext != null;
    -
    -            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer(appContext);
    +            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer();
     
                 peer.postDropTargetEvent(component, x, y, dropAction, actions, formats,
                                          nativeCtxt, eventID,
    diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
    index bc1b3ac9f4b..f5bb47db50c 100644
    --- a/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
    +++ b/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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
    @@ -338,7 +338,7 @@ public final class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusLi
     //             Rectangle my_bounds = getBounds();
     //             setBounds(my_bounds.x, my_bounds.y, bounds.width, bounds.height, SET_BOUNDS);
             }
    -        XToolkit.postEvent(XToolkit.targetToAppContext(target), new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
    +        XToolkit.postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
         }
     
         void focusNext() {
    @@ -735,9 +735,7 @@ public final class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusLi
                 xembedLog.finest("     Drop target=" + target.getDropTarget());
             }
             if (target.getDropTarget() instanceof XEmbedDropTarget) {
    -            AppContext appContext = XToolkit.targetToAppContext(getTarget());
    -            XDropTargetContextPeer peer =
    -                XDropTargetContextPeer.getPeer(appContext);
    +            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer();
                 peer.forwardEventToEmbedded(xembed.handle, ctxt, eventID);
                 return true;
             } else {
    diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XSelection.java b/src/java.desktop/unix/classes/sun/awt/X11/XSelection.java
    index f7a40312fe7..e93b311633d 100644
    --- a/src/java.desktop/unix/classes/sun/awt/X11/XSelection.java
    +++ b/src/java.desktop/unix/classes/sun/awt/X11/XSelection.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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.io.IOException;
     import java.util.Hashtable;
     import java.util.Map;
     
    -import sun.awt.AppContext;
     import sun.awt.SunToolkit;
     import sun.awt.UNIXToolkit;
     
    @@ -91,8 +90,6 @@ final class XSelection {
         private Map formatMap = null;
         /* The formats supported by the current owner was set. */
         private long[] formats = null;
    -    /* The AppContext in which the current owner was set. */
    -    private AppContext appContext = null;
         // The X server time of the last XConvertSelection() call;
         // protected with 'lock' and awtLock.
         private static long lastRequestServerTime;
    @@ -148,7 +145,6 @@ final class XSelection {
             this.contents = contents;
             this.formatMap = formatMap;
             this.formats = formats;
    -        this.appContext = AppContext.getAppContext();
             this.ownershipTime = time;
     
             XToolkit.awtLock();
    @@ -469,7 +465,6 @@ final class XSelection {
             contents = null;
             formatMap = null;
             formats = null;
    -        appContext = null;
             ownershipTime = 0;
         }
     
    @@ -483,7 +478,7 @@ final class XSelection {
             int count = 0;
     
             try {
    -            SunToolkit.insertTargetMapping(this, appContext);
    +            SunToolkit.insertTargetMapping(this);
     
                 byteData = DataTransferer.getInstance().convertData(this,
                                                                     contents,
    diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java
    index 473b638cb74..82423a75d0c 100644
    --- a/src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java
    +++ b/src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 2026, 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,7 +28,6 @@ package sun.awt.X11;
     import java.awt.*;
     import java.awt.peer.SystemTrayPeer;
     import sun.awt.SunToolkit;
    -import sun.awt.AppContext;
     import sun.awt.AWTAccessor;
     import sun.awt.UNIXToolkit;
     import sun.util.logging.PlatformLogger;
    @@ -183,7 +182,7 @@ public final class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListene
                             .firePropertyChange(target, propertyName, oldValue, newValue);
                     }
                 };
    -        invokeOnEachAppContext(runnable);
    +        SunToolkit.invokeLater(runnable);
         }
     
         private void createTrayPeers() {
    @@ -198,7 +197,7 @@ public final class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListene
                         }
                     }
                 };
    -        invokeOnEachAppContext(runnable);
    +        SunToolkit.invokeLater(runnable);
         }
     
         private void removeTrayPeers() {
    @@ -210,13 +209,6 @@ public final class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListene
                         }
                     }
                 };
    -        invokeOnEachAppContext(runnable);
    +        SunToolkit.invokeLater(runnable);
         }
    -
    -    private void invokeOnEachAppContext(Runnable runnable) {
    -        for (AppContext appContext : AppContext.getAppContexts()) {
    -            SunToolkit.invokeLaterOnAppContext(appContext, runnable);
    -        }
    -    }
    -
     }
    diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
    index 78cd4a7e57d..5dcd1b763e1 100644
    --- a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
    +++ b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2002, 2026, 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
    @@ -1770,7 +1770,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
             final int altL = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_L);
             final int altR = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_R);
             final int numLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Num_Lock);
    -        final int modeSwitch = keysymToPrimaryKeycode(XKeySymConstants.XK_Mode_switch);
    +        int modeSwitchTmp = keysymToPrimaryKeycode(XKeySymConstants.XK_Mode_switch);
    +        if (modeSwitchTmp == 0) {
    +            modeSwitchTmp = keysymToPrimaryKeycode(XKeySymConstants.XK_ISO_Level3_Shift);
    +        }
    +        final int modeSwitch = modeSwitchTmp;
             final int shiftLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Shift_Lock);
             final int capsLock  = keysymToPrimaryKeycode(XKeySymConstants.XK_Caps_Lock);
     
    diff --git a/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c b/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c
    index 8f264278d9f..0497dbf69fa 100644
    --- a/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c
    +++ b/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, 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,6 +40,8 @@
     
     #ifndef HEADLESS
     
    +#include 
    +
     extern LockFunc       OGLSD_Lock;
     extern GetRasInfoFunc OGLSD_GetRasInfo;
     extern UnlockFunc     OGLSD_Unlock;
    @@ -50,6 +52,74 @@ extern void
     
     jboolean surfaceCreationFailed = JNI_FALSE;
     
    +/**
    + * Per-Window GLXWindow entry with reference counting.
    + * Stored in an XContext keyed by the X Window XID.
    + */
    +typedef struct {
    +    GLXWindow glxWindow;
    +    int       refCount;
    +} GLXWindowRef;
    +
    +static XContext glxWindowContext;
    +
    +/**
    + * Gets or creates a shared GLXWindow for the given X Window.
    + * All callers are synchronized by the AWT lock.
    + */
    +static GLXWindow acquireGLXWindow(Window window, GLXFBConfig fbconfig)
    +{
    +    if (glxWindowContext == 0) {
    +        glxWindowContext = XUniqueContext();
    +    }
    +
    +    XPointer data;
    +    if (XFindContext(awt_display, window, glxWindowContext, &data) == 0) {
    +        GLXWindowRef *ref = (GLXWindowRef *)data;
    +        ref->refCount++;
    +        return ref->glxWindow;
    +    }
    +
    +    GLXWindow glxWin = j2d_glXCreateWindow(awt_display, fbconfig, window, NULL);
    +    if (glxWin == 0) {
    +        return 0;
    +    }
    +
    +    GLXWindowRef *ref = malloc(sizeof(*ref));
    +    if (ref == NULL) {
    +        j2d_glXDestroyWindow(awt_display, glxWin);
    +        return 0;
    +    }
    +    ref->glxWindow = glxWin;
    +    ref->refCount = 1;
    +    if (XSaveContext(awt_display, window, glxWindowContext, (XPointer)ref) != 0)
    +    {
    +        j2d_glXDestroyWindow(awt_display, glxWin);
    +        free(ref);
    +        return 0;
    +    }
    +    return glxWin;
    +}
    +
    +/**
    + * Decrements the reference count for the GLXWindow associated with the given
    + * X Window. Destroys it when the count reaches zero.
    + * All callers are synchronized by the AWT lock.
    + */
    +static void releaseGLXWindow(Window window)
    +{
    +    XPointer data;
    +    if (XFindContext(awt_display, window, glxWindowContext, &data) != 0) {
    +        return;
    +    }
    +    GLXWindowRef *ref = (GLXWindowRef *)data;
    +    if (--ref->refCount <= 0) {
    +        j2d_glXDestroyWindow(awt_display, ref->glxWindow);
    +        XDeleteContext(awt_display, window, glxWindowContext);
    +        free(ref);
    +    }
    +}
    +
     #endif /* !HEADLESS */
     
     JNIEXPORT void JNICALL
    @@ -74,7 +144,7 @@ Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
         // later the graphicsConfig will be used for deallocation of oglsdo
         oglsdo->graphicsConfig = gc;
     
    -    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
    +    GLXSDOps *glxsdo = (GLXSDOps *)calloc(1, sizeof(GLXSDOps));
     
         if (glxsdo == NULL) {
             JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
    @@ -125,8 +195,13 @@ Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
     void
     OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
     {
    +    GLXSDOps *glxsdo = (GLXSDOps *)oglsdo->privOps;
         J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
    -    // X Window is free'd later by AWT code...
    +    if (glxsdo != NULL && glxsdo->drawable != 0) {
    +        releaseGLXWindow(glxsdo->window);
    +        glxsdo->drawable = 0;
    +        oglsdo->drawableType = OGLSD_UNDEFINED;
    +    }
     }
     
     /**
    @@ -296,6 +371,13 @@ OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
             return JNI_FALSE;
         }
     
    +    glxsdo->drawable = acquireGLXWindow(window,
    +                                        glxsdo->configData->glxInfo->fbconfig);
    +    if (glxsdo->drawable == 0) {
    +        J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: GLXWindow is 0");
    +        return JNI_FALSE;
    +    }
    +
         XGetWindowAttributes(awt_display, window, &attr);
         oglsdo->width = attr.width;
         oglsdo->height = attr.height;
    @@ -304,7 +386,6 @@ OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
         oglsdo->isOpaque = JNI_TRUE;
         oglsdo->xOffset = 0;
         oglsdo->yOffset = 0;
    -    glxsdo->drawable = window;
         glxsdo->xdrawable = window;
     
         J2dTraceLn(J2D_TRACE_VERBOSE, "  created window: w=%d h=%d",
    @@ -333,7 +414,16 @@ OGLSD_SwapBuffers(JNIEnv *env, jlong window)
             return;
         }
     
    -    j2d_glXSwapBuffers(awt_display, (Window)window);
    +    XPointer data;
    +    if (XFindContext(awt_display, (Window)window, glxWindowContext, &data) != 0)
    +    {
    +        J2dRlsTraceLn(J2D_TRACE_ERROR,
    +                      "OGLSD_SwapBuffers: GLXWindow not found");
    +        return;
    +    }
    +
    +    GLXWindowRef *ref = (GLXWindowRef *)data;
    +    j2d_glXSwapBuffers(awt_display, ref->glxWindow);
     }
     
     // needed by Mac OS X port, no-op on other platforms
    diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c b/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
    index 3b7b2880316..1c29e5168ba 100644
    --- a/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
    +++ b/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 2026, 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
    @@ -400,5 +400,5 @@ Java_com_sun_java_swing_plaf_gtk_GTKLookAndFeel_applyThemeIfNeeded(JNIEnv *env,
         const gboolean result = gtk->apply_theme_if_needed();
         gtk->gdk_threads_leave();
     
    -    return result;
    +    return result ? JNI_TRUE : JNI_FALSE;
     }
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java
    index 81766db8116..572e9e8c117 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1998, 2026, 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
    @@ -115,7 +115,7 @@ public final class WindowsBorders {
         }
     
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    public static final class ProgressBarBorder extends AbstractBorder implements UIResource {
    +    public static class ProgressBarBorder extends AbstractBorder implements UIResource {
             protected Color shadow;
             protected Color highlight;
     
    @@ -148,7 +148,7 @@ public final class WindowsBorders {
          * @since 1.4
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    public static final class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
    +    public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
             protected Color shadow;
             protected Color highlight;
     
    @@ -308,7 +308,7 @@ public final class WindowsBorders {
          * @since 1.4
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    public static final class InternalFrameLineBorder extends LineBorder implements
    +    public static class InternalFrameLineBorder extends LineBorder implements
                 UIResource {
             protected Color activeColor;
             protected Color inactiveColor;
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java
    index ee07276aa30..63e99e0804a 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java
    @@ -56,7 +56,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
      *
      * @author Jeff Dinkins
      */
    -public final class WindowsButtonUI extends BasicButtonUI
    +public class WindowsButtonUI extends BasicButtonUI
     {
         protected int dashedRectGapX;
         protected int dashedRectGapY;
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
    index 3a2578b3e0b..47e311486ba 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, 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,7 +42,7 @@ import com.sun.java.swing.plaf.windows.TMSchema.State;
     /**
      * Windows check box menu item.
      */
    -public final class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
    +public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
     
         final WindowsMenuItemUIAccessor accessor =
             new WindowsMenuItemUIAccessor() {
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java
    index 7cb2490fd76..d264393f4d8 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java
    @@ -35,7 +35,7 @@ import javax.swing.plaf.ComponentUI;
      *
      * @author Jeff Dinkins
      */
    -public final class WindowsCheckBoxUI extends WindowsRadioButtonUI
    +public class WindowsCheckBoxUI extends WindowsRadioButtonUI
     {
         // NOTE: WindowsCheckBoxUI inherits from WindowsRadioButtonUI instead
         // of BasicCheckBoxUI because we want to pick up all the
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java
    index 5716a875cd7..802b5f66888 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -31,7 +31,7 @@ package com.sun.java.swing.plaf.windows;
      * @since 1.5
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
    -public final class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
    +public class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
         @Override
         public String getName() {
             return "Windows Classic";
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
    index fdc9b03ae7d..8717fd715ea 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, 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,7 +75,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
      * @author Tom Santos
      * @author Igor Kushnirskiy
      */
    -public final class WindowsComboBoxUI extends BasicComboBoxUI {
    +public class WindowsComboBoxUI extends BasicComboBoxUI {
     
         private static final MouseListener rolloverListener =
             new MouseAdapter() {
    @@ -532,7 +532,7 @@ public final class WindowsComboBoxUI extends BasicComboBoxUI {
         }
     
         @SuppressWarnings("serial") // Same-version serialization only
    -    protected final class WinComboPopUp extends BasicComboPopup {
    +    protected class WinComboPopUp extends BasicComboPopup {
             private Skin listBoxBorder = null;
             private XPStyle xp;
     
    @@ -550,7 +550,7 @@ public final class WindowsComboBoxUI extends BasicComboBoxUI {
                 return new InvocationKeyHandler();
             }
     
    -        protected final class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
    +        protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
                 protected InvocationKeyHandler() {
                     WinComboPopUp.this.super();
                 }
    @@ -570,7 +570,7 @@ public final class WindowsComboBoxUI extends BasicComboBoxUI {
         /**
          * Subclassed to highlight selected item in an editable combo box.
          */
    -    public static final class WindowsComboBoxEditor
    +    public static class WindowsComboBoxEditor
             extends BasicComboBoxEditor.UIResource {
     
             /**
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java
    index 47ecdf5747b..2cebb050396 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, 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
    @@ -36,7 +36,7 @@ import javax.swing.plaf.basic.BasicDesktopIconUI;
     /**
      * Windows icon for a minimized window on the desktop.
      */
    -public final class WindowsDesktopIconUI extends BasicDesktopIconUI {
    +public class WindowsDesktopIconUI extends BasicDesktopIconUI {
         private int width;
     
         public static ComponentUI createUI(JComponent c) {
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java
    index 79d81bad089..ae081a7690c 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -52,7 +52,7 @@ import java.lang.ref.WeakReference;
      * @author Thomas Ball
      */
     @SuppressWarnings("serial") // JDK-implementation class
    -public final class WindowsDesktopManager extends DefaultDesktopManager
    +public class WindowsDesktopManager extends DefaultDesktopManager
             implements java.io.Serializable, javax.swing.plaf.UIResource {
     
         /* The frame which is currently selected/activated.
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java
    index dabbe3fb992..4a3f0ec38b1 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, 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 @@ import javax.swing.plaf.basic.BasicDesktopPaneUI;
      *
      * @author David Kloba
      */
    -public final class WindowsDesktopPaneUI extends BasicDesktopPaneUI
    +public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
     {
         public static ComponentUI createUI(JComponent c) {
             return new WindowsDesktopPaneUI();
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java
    index 44cb0e9634c..ea21b41c619 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -33,7 +33,7 @@ import javax.swing.text.Caret;
     /**
      * Windows rendition of the component.
      */
    -public final class WindowsEditorPaneUI extends BasicEditorPaneUI
    +public class WindowsEditorPaneUI extends BasicEditorPaneUI
     {
     
         /**
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
    index 08c01760be9..86c40ea70d6 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2026, 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
    @@ -101,7 +101,7 @@ import sun.swing.WindowsPlacesBar;
      *
      * @author Jeff Dinkins
      */
    -public final class WindowsFileChooserUI extends BasicFileChooserUI {
    +public class WindowsFileChooserUI extends BasicFileChooserUI {
     
         // The following are private because the implementation of the
         // Windows FileChooser L&F is not complete yet.
    @@ -1122,7 +1122,7 @@ public final class WindowsFileChooserUI extends BasicFileChooserUI {
          * Data model for a type-face selection combo-box.
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    protected final class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
    +    protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
             Vector directories = new Vector();
             int[] depths = null;
             File selectedDirectory = null;
    @@ -1252,7 +1252,7 @@ public final class WindowsFileChooserUI extends BasicFileChooserUI {
          * Render different type sizes and styles.
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    public final class FilterComboBoxRenderer extends DefaultListCellRenderer {
    +    public class FilterComboBoxRenderer extends DefaultListCellRenderer {
             @Override
             public Component getListCellRendererComponent(JList list,
                 Object value, int index, boolean isSelected,
    @@ -1279,7 +1279,7 @@ public final class WindowsFileChooserUI extends BasicFileChooserUI {
          * Data model for a type-face selection combo-box.
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
    -    protected final class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel,
    +    protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel,
                 PropertyChangeListener {
             protected FileFilter[] filters;
             protected FilterComboBoxModel() {
    @@ -1362,7 +1362,7 @@ public final class WindowsFileChooserUI extends BasicFileChooserUI {
         /**
          * Acts when DirectoryComboBox has changed the selected item.
          */
    -    protected final class DirectoryComboBoxAction implements ActionListener {
    +    protected class DirectoryComboBoxAction implements ActionListener {
     
     
     
    @@ -1387,7 +1387,7 @@ public final class WindowsFileChooserUI extends BasicFileChooserUI {
         // ***********************
         // * FileView operations *
         // ***********************
    -    protected final class WindowsFileView extends BasicFileView {
    +    protected class WindowsFileView extends BasicFileView {
             /* FileView type descriptions */
     
             @Override
    diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java
    index ba4bde12122..029e139fe8f 100644
    --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java
    +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2001, 2026, 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
    @@ -418,7 +418,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
             return new WindowsTitlePaneLayout();
         }
     
    -    public final class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
    +    public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
             private Insets captionMargin = null;
             private Insets contentMargin = null;
             private XPStyle xp = XPStyle.getXP();
    @@ -506,7 +506,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
             }
         } // end WindowsTitlePaneLayout
     
    -    public final class WindowsPropertyChangeHandler extends PropertyChangeHandler {
    +    public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
             @Override
             public void propertyChange(PropertyChangeEvent evt) {
                 String prop = evt.getPropertyName();
    @@ -530,7 +530,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
          * 

    * Note: We assume here that icons are square. */ - public static final class ScalableIconUIResource implements Icon, UIResource { + public static class ScalableIconUIResource implements Icon, UIResource { // We can use an arbitrary size here because we scale to it in paintIcon() private static final int SIZE = 16; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java index 9db31ba38f9..6e76ac6a5b4 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +45,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; /** * Windows rendition of the component. */ -public final class WindowsInternalFrameUI extends BasicInternalFrameUI +public class WindowsInternalFrameUI extends BasicInternalFrameUI { XPStyle xp = XPStyle.getXP(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java index 4283f743b97..c910b635491 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java @@ -40,7 +40,7 @@ import sun.swing.SwingUtilities2; /** * Windows rendition of the component. */ -public final class WindowsLabelUI extends BasicLabelUI { +public class WindowsLabelUI extends BasicLabelUI { private static final ComponentUI UI = new WindowsLabelUI(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java index 3d3cf5feee7..ac26dcbf425 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -57,7 +57,7 @@ import sun.swing.MnemonicHandler; /** * Windows rendition of the component. */ -public final class WindowsMenuBarUI extends BasicMenuBarUI +public class WindowsMenuBarUI extends BasicMenuBarUI { /* to be accessed on the EDT only */ private WindowListener windowListener = null; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java index d15bc93a628..d50540588fb 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java @@ -58,7 +58,7 @@ import sun.swing.SwingUtilities2; * * @author Igor Kushnirskiy */ -public final class WindowsMenuItemUI extends BasicMenuItemUI { +public class WindowsMenuItemUI extends BasicMenuItemUI { /** * The instance of {@code PropertyChangeListener}. */ diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java index a7aca0c5ccf..78028db7c00 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -50,9 +50,9 @@ import com.sun.java.swing.plaf.windows.TMSchema.State; /** * Windows rendition of the component. */ -public final class WindowsMenuUI extends BasicMenuUI { - private Integer menuBarHeight; - private boolean hotTrackingOn; +public class WindowsMenuUI extends BasicMenuUI { + protected Integer menuBarHeight; + protected boolean hotTrackingOn; final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { @@ -283,7 +283,7 @@ public final class WindowsMenuUI extends BasicMenuUI { * true when the mouse enters the menu and false when it exits. * @since 1.4 */ - protected final class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler { + protected class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler { @Override public void mouseEntered(MouseEvent evt) { super.mouseEntered(evt); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java index 05c1b177705..3bed1856a55 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,5 +30,5 @@ import javax.swing.plaf.basic.BasicOptionPaneUI; /** * Windows rendition of the component. */ -public final class WindowsOptionPaneUI extends BasicOptionPaneUI { +public class WindowsOptionPaneUI extends BasicOptionPaneUI { } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java index 6adf6e402ec..0c30b291648 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import javax.swing.text.Caret; /** * Windows rendition of the component. */ -public final class WindowsPasswordFieldUI extends BasicPasswordFieldUI { +public class WindowsPasswordFieldUI extends BasicPasswordFieldUI { /** * Creates a UI for a JPasswordField diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java index 576549ae482..f236c6b14fc 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, 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,7 +42,7 @@ import com.sun.java.swing.plaf.windows.XPStyle.Skin; * @author Igor Kushnirskiy */ -public final class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { +public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { public static ComponentUI createUI(JComponent c) { return new WindowsPopupMenuSeparatorUI(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java index 1361286df4a..1c85cfebd94 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -57,7 +57,7 @@ import static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET; * * @author Igor Kushnirskiy */ -public final class WindowsPopupMenuUI extends BasicPopupMenuUI { +public class WindowsPopupMenuUI extends BasicPopupMenuUI { static MnemonicListener mnemonicListener = null; static final Object GUTTER_OFFSET_KEY = diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java index 1d48fbe8042..c7bb3dd0233 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java @@ -53,7 +53,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; * * @author Michael C. Albers */ -public final class WindowsProgressBarUI extends BasicProgressBarUI +public class WindowsProgressBarUI extends BasicProgressBarUI { private Rectangle previousFullBox; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java index 78768c29ab3..2ec78341c2a 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +42,7 @@ import com.sun.java.swing.plaf.windows.TMSchema.State; /** * Windows rendition of the component. */ -public final class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI { +public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI { final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java index 5e08dcf5605..d41fd9421e4 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,7 +70,7 @@ import sun.swing.MnemonicHandler; * @author Mark Davidson * @since 1.4 */ -public final class WindowsRootPaneUI extends BasicRootPaneUI { +public class WindowsRootPaneUI extends BasicRootPaneUI { private static final WindowsRootPaneUI windowsRootPaneUI = new WindowsRootPaneUI(); static final AltProcessor altProcessor = new AltProcessor(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java index 04a9f2e97cf..2755f3543f1 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -55,7 +55,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; /** * Windows rendition of the component. */ -public final class WindowsScrollBarUI extends BasicScrollBarUI { +public class WindowsScrollBarUI extends BasicScrollBarUI { private Grid thumbGrid; private Grid highlightGrid; private Dimension horizontalThumbSize; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java index 48e7a8c02fb..56b8eb1004e 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,5 +30,5 @@ import javax.swing.plaf.basic.BasicScrollPaneUI; /** * Windows rendition of the component. */ -public final class WindowsScrollPaneUI extends BasicScrollPaneUI +public class WindowsScrollPaneUI extends BasicScrollPaneUI {} diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java index 2a2caef60d2..12eaa33872c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,4 +30,4 @@ import javax.swing.plaf.basic.*; /** * Windows Separator. */ -public final class WindowsSeparatorUI extends BasicSeparatorUI { } +public class WindowsSeparatorUI extends BasicSeparatorUI { } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java index 731775a2575..cfc509babf4 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -44,7 +44,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; /** * Windows rendition of the component. */ -public final class WindowsSliderUI extends BasicSliderUI +public class WindowsSliderUI extends BasicSliderUI { private boolean rollover = false; private boolean pressed = false; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java index a8e2a2ddcf1..8934bf9ff21 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import static com.sun.java.swing.plaf.windows.TMSchema.State; import static com.sun.java.swing.plaf.windows.XPStyle.Skin; -public final class WindowsSpinnerUI extends BasicSpinnerUI { +public class WindowsSpinnerUI extends BasicSpinnerUI { public static ComponentUI createUI(JComponent c) { return new WindowsSpinnerUI(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java index a132756bbee..26cd1bd8c2d 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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,7 +39,7 @@ import javax.swing.plaf.basic.BasicSplitPaneUI; * @author Jeff Dinkins */ @SuppressWarnings("serial") // Superclass is not serializable across versions -public final class WindowsSplitPaneDivider extends BasicSplitPaneDivider +public class WindowsSplitPaneDivider extends BasicSplitPaneDivider { /** diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java index 481fa466a5b..b67ab22f48f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import javax.swing.plaf.basic.BasicSplitPaneUI; /** * Windows rendition of the component. */ -public final class WindowsSplitPaneUI extends BasicSplitPaneUI +public class WindowsSplitPaneUI extends BasicSplitPaneUI { public WindowsSplitPaneUI() { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java index 874b5c65c6e..da8e8b9d385 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; /** * Windows rendition of the component. */ -public final class WindowsTabbedPaneUI extends BasicTabbedPaneUI { +public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { /** * Keys to use for forward focus traversal when the JComponent is * managing focus. diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java index de8f18b4ea1..1db0050f162 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -50,7 +50,7 @@ import static com.sun.java.swing.plaf.windows.TMSchema.Part; import static com.sun.java.swing.plaf.windows.TMSchema.State; import static com.sun.java.swing.plaf.windows.XPStyle.Skin; -public final class WindowsTableHeaderUI extends BasicTableHeaderUI { +public class WindowsTableHeaderUI extends BasicTableHeaderUI { private TableCellRenderer originalHeaderRenderer; public static ComponentUI createUI(JComponent h) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java index 78cceff2a0c..7c9abb12e05 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import javax.swing.text.Caret; /** * Windows rendition of the component. */ -public final class WindowsTextAreaUI extends BasicTextAreaUI { +public class WindowsTextAreaUI extends BasicTextAreaUI { /** * Creates the object to use for a caret. By default an * instance of WindowsCaret is created. This method diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java index 5846dcb9f09..9920ed371d8 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -62,7 +62,7 @@ import javax.swing.text.Position; * * @author Timothy Prinzing */ -public final class WindowsTextFieldUI extends BasicTextFieldUI +public class WindowsTextFieldUI extends BasicTextFieldUI { /** * Creates a UI for a JTextField. diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java index 2c645903e51..d1418205385 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import javax.swing.text.Caret; /** * Windows rendition of the component. */ -public final class WindowsTextPaneUI extends BasicTextPaneUI +public class WindowsTextPaneUI extends BasicTextPaneUI { /** * Creates a UI for a JTextPane. diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java index 67eb5c1d6a0..a612b3f392e 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java @@ -43,7 +43,7 @@ import javax.swing.plaf.basic.BasicToggleButtonUI; * * @author Jeff Dinkins */ -public final class WindowsToggleButtonUI extends BasicToggleButtonUI +public class WindowsToggleButtonUI extends BasicToggleButtonUI { protected int dashedRectGapX; protected int dashedRectGapY; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java index 47175b83d30..1707ce5a80c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; * * @author Mark Davidson */ -public final class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI { +public class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI { public static ComponentUI createUI( JComponent c ) { return new WindowsToolBarSeparatorUI(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java index 025c30c5c96..4e2cf42bf5d 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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,7 +45,7 @@ import javax.swing.plaf.basic.BasicToolBarUI; import static com.sun.java.swing.plaf.windows.TMSchema.Part; -public final class WindowsToolBarUI extends BasicToolBarUI { +public class WindowsToolBarUI extends BasicToolBarUI { public static ComponentUI createUI(JComponent c) { return new WindowsToolBarUI(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java index 78384bbd18a..26edfb978bd 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -167,7 +167,7 @@ public class WindowsTreeUI extends BasicTreeUI { * The plus sign button icon */ @SuppressWarnings("serial") // Superclass is not serializable across versions - public static final class CollapsedIcon extends ExpandedIcon { + public static class CollapsedIcon extends ExpandedIcon { public static Icon createCollapsedIcon() { return new CollapsedIcon(); } @@ -185,7 +185,7 @@ public class WindowsTreeUI extends BasicTreeUI { } @SuppressWarnings("serial") // Superclass is not serializable across versions - public final class WindowsTreeCellRenderer extends DefaultTreeCellRenderer { + public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer { /** * Configures the renderer based on the passed in components. diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java index 1b3fb9a85e9..00ad60c8bb3 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -902,7 +902,7 @@ public abstract class WComponentPeer extends WObjectPeer */ void postEvent(AWTEvent event) { preprocessPostEvent(event); - WToolkit.postEvent(WToolkit.targetToAppContext(target), event); + WToolkit.postEvent(event); } void preprocessPostEvent(AWTEvent event) {} diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java index 9a74a1c25f7..0bd44d8ca85 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -238,8 +238,7 @@ public final class WEmbeddedFrame extends EmbeddedFrame { peer.emulateActivation(true); } }; - WToolkit.postEvent(WToolkit.targetToAppContext(this), - new InvocationEvent(this, r)); + WToolkit.postEvent(new InvocationEvent(this, r)); } } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java b/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java index a9237e21ff6..50ad23fabcd 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -602,7 +602,7 @@ final class WInputMethod extends InputMethodAdapter commitedTextLength, TextHitInfo.leading(caretPos), TextHitInfo.leading(visiblePos)); - WToolkit.postEvent(WToolkit.targetToAppContext(source), event); + WToolkit.postEvent(event); } public void inquireCandidatePosition() @@ -641,8 +641,7 @@ final class WInputMethod extends InputMethodAdapter openCandidateWindow(awtFocussedComponentPeer, x, y); } }; - WToolkit.postEvent(WToolkit.targetToAppContext(source), - new InvocationEvent(source, r)); + WToolkit.postEvent(new InvocationEvent(source, r)); } // java.awt.Toolkit#getNativeContainer() is not available diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java index 4abb9fa84ae..2594bd38a7d 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -123,7 +123,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { * Post an event. Queue it for execution by the callback thread. */ void postEvent(AWTEvent event) { - WToolkit.postEvent(WToolkit.targetToAppContext(target), event); + WToolkit.postEvent(event); } native void create(WMenuPeer parent); 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 1da9db3a35b..b238921cb77 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java @@ -1734,7 +1734,9 @@ public final class WPrinterJob extends RasterPrinterJob attributes.add(new PageRanges(from, to)); setPageRange(from, to); } else { - attributes.remove(PageRanges.class); + // Sets default values for PageRange attribute and setPageRange + attributes.add(new PageRanges(1, + Integer.MAX_VALUE)); setPageRange(Pageable.UNKNOWN_NUMBER_OF_PAGES, Pageable.UNKNOWN_NUMBER_OF_PAGES); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java index 0fdc4c6005b..4ed3e6b7e68 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -123,7 +123,6 @@ import javax.swing.text.JTextComponent; import sun.awt.AWTAccessor; import sun.awt.AWTAutoShutdown; -import sun.awt.AppContext; import sun.awt.DisplayChangedListener; import sun.awt.LightweightFrame; import sun.awt.SunToolkit; @@ -777,20 +776,7 @@ public final class WToolkit extends SunToolkit implements Runnable { ((DisplayChangedListener) lge).displayChanged(); } }; - if (AppContext.getAppContext() != null) { - // Common case, standalone application - EventQueue.invokeLater(runnable); - } else { - if (displayChangeExecutor == null) { - // No synchronization, called on the Toolkit thread only - displayChangeExecutor = Executors.newFixedThreadPool(1, r -> { - Thread t = Executors.defaultThreadFactory().newThread(r); - t.setDaemon(true); - return t; - }); - } - displayChangeExecutor.submit(runnable); - } + EventQueue.invokeLater(runnable); } /** @@ -910,17 +896,7 @@ public final class WToolkit extends SunToolkit implements Runnable { } updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); - - if (AppContext.getAppContext() == null) { - // We cannot post the update to any EventQueue. Listeners will - // be called on EDTs by DesktopPropertyChangeSupport - updateProperties(props); - } else { - // Cannot update on Toolkit thread. - // DesktopPropertyChangeSupport will call listeners on Toolkit - // thread if it has AppContext (standalone mode) - EventQueue.invokeLater(() -> updateProperties(props)); - } + EventQueue.invokeLater(() -> updateProperties(props)); } private synchronized void updateProperties(final Map props) { diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java index 7cf92292a32..5c04803669d 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -181,7 +181,7 @@ final class WTrayIconPeer extends WObjectPeer implements TrayIconPeer { } void postEvent(AWTEvent event) { - WToolkit.postEvent(WToolkit.targetToAppContext(target), event); + WToolkit.postEvent(event); } native void create(); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java index f678be9f1ab..f028e0fbec5 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -56,7 +56,6 @@ import java.util.LinkedList; import java.util.List; import sun.awt.AWTAccessor; -import sun.awt.AppContext; import sun.awt.DisplayChangedListener; import sun.awt.SunToolkit; import sun.awt.TimedWindowEvent; @@ -84,26 +83,12 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, private TranslucentWindowPainter painter; /* - * A key used for storing a list of active windows in AppContext. The value - * is a list of windows, sorted by the time of activation: later a window is - * activated, greater its index is in the list. - */ - private static final StringBuffer ACTIVE_WINDOWS_KEY = - new StringBuffer("active_windows_list"); - - /* - * Listener for 'activeWindow' KFM property changes. It is added to each - * AppContext KFM. See ActiveWindowListener inner class below. + * Listener for 'activeWindow' KFM property changes. + * See ActiveWindowListener inner class below. */ private static PropertyChangeListener activeWindowListener = new ActiveWindowListener(); - /* - * The object is a listener for the AppContext.GUI_DISPOSED property. - */ - private static final PropertyChangeListener guiDisposedListener = - new GuiDisposedListener(); - /* * Called (on the Toolkit thread) before the appropriate * WindowStateEvent is posted to the EventQueue. @@ -116,18 +101,17 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, private static native void initIDs(); static { initIDs(); + KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + kfm.addPropertyChangeListener("activeWindow", activeWindowListener); } + static List activeWindows = new LinkedList(); // WComponentPeer overrides @Override @SuppressWarnings("unchecked") protected void disposeImpl() { - AppContext appContext = SunToolkit.targetToAppContext(target); - synchronized (appContext) { - List l = (List)appContext.get(ACTIVE_WINDOWS_KEY); - if (l != null) { - l.remove(this); - } + synchronized (activeWindows) { + activeWindows.remove(this); } // Remove ourself from the Map of DisplayChangeListeners @@ -222,8 +206,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice(); gd.addDisplayChangedListener(this); - initActiveWindowsTracking((Window)target); - updateIconImages(); Shape shape = ((Window)target).getShape(); @@ -530,22 +512,15 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, native void modalEnable(Dialog blocker); /* - * Returns all the ever active windows from the current AppContext. + * Returns all the active windows. * The list is sorted by the time of activation, so the latest * active window is always at the end. */ - @SuppressWarnings("unchecked") public static long[] getActiveWindowHandles(Component target) { - AppContext appContext = SunToolkit.targetToAppContext(target); - if (appContext == null) return null; - synchronized (appContext) { - List l = (List)appContext.get(ACTIVE_WINDOWS_KEY); - if (l == null) { - return null; - } - long[] result = new long[l.size()]; - for (int j = 0; j < l.size(); j++) { - result[j] = l.get(j).getHWnd(); + synchronized (activeWindows) { + long[] result = new long[activeWindows.size()]; + for (int j = 0; j < activeWindows.size(); j++) { + result[j] = activeWindows.get(j).getHWnd(); } return result; } @@ -823,58 +798,11 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, } } - /* - * The method maps the list of the active windows to the window's AppContext, - * then the method registers ActiveWindowListener, GuiDisposedListener listeners; - * it executes the initilialization only once per AppContext. - */ - @SuppressWarnings("unchecked") - private static void initActiveWindowsTracking(Window w) { - AppContext appContext = AppContext.getAppContext(); - synchronized (appContext) { - List l = (List)appContext.get(ACTIVE_WINDOWS_KEY); - if (l == null) { - l = new LinkedList(); - appContext.put(ACTIVE_WINDOWS_KEY, l); - appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener); - - KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - kfm.addPropertyChangeListener("activeWindow", activeWindowListener); - } - } - } - - /* - * The GuiDisposedListener class listens for the AppContext.GUI_DISPOSED property, - * it removes the list of the active windows from the disposed AppContext and - * unregisters ActiveWindowListener listener. - */ - private static final class GuiDisposedListener implements PropertyChangeListener { - @Override - public void propertyChange(PropertyChangeEvent e) { - boolean isDisposed = (Boolean)e.getNewValue(); - if (isDisposed != true) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine(" Assertion (newValue != true) failed for AppContext.GUI_DISPOSED "); - } - } - AppContext appContext = AppContext.getAppContext(); - synchronized (appContext) { - appContext.remove(ACTIVE_WINDOWS_KEY); - appContext.removePropertyChangeListener(AppContext.GUI_DISPOSED, this); - - KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - kfm.removePropertyChangeListener("activeWindow", activeWindowListener); - } - } - } - /* * Static inner class, listens for 'activeWindow' KFM property changes and - * updates the list of active windows per AppContext, so the latest active - * window is always at the end of the list. The list is stored in AppContext. + * updates the list of active windows so the latest active + * window is always at the end of the list. */ - @SuppressWarnings("unchecked") private static final class ActiveWindowListener implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent e) { @@ -882,15 +810,11 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, if (w == null) { return; } - AppContext appContext = SunToolkit.targetToAppContext(w); - synchronized (appContext) { + synchronized (activeWindows) { WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w); // add/move wp to the end of the list - List l = (List)appContext.get(ACTIVE_WINDOWS_KEY); - if (l != null) { - l.remove(wp); - l.add(wp); - } + activeWindows.remove(wp); + activeWindows.add(wp); } } } diff --git a/src/java.instrument/share/native/libinstrument/JavaExceptions.c b/src/java.instrument/share/native/libinstrument/JavaExceptions.c index 0a787ce4150..45c31e329d0 100644 --- a/src/java.instrument/share/native/libinstrument/JavaExceptions.c +++ b/src/java.instrument/share/native/libinstrument/JavaExceptions.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -68,9 +68,20 @@ forceFallback(jthrowable potentialException) { jboolean initializeFallbackError(JNIEnv* jnienv) { jplis_assert(isSafeForJNICalls(jnienv)); - sFallbackInternalError = createInternalError(jnienv, NULL); + jthrowable localRef = createInternalError(jnienv, NULL); + if (localRef == NULL) { + return JNI_FALSE; + } + + jthrowable globalRef = (*jnienv)->NewGlobalRef(jnienv, localRef); + if (globalRef == NULL) { + return JNI_FALSE; + } + + sFallbackInternalError = globalRef; jplis_assert(isSafeForJNICalls(jnienv)); - return (sFallbackInternalError != NULL); + + return JNI_TRUE; } diff --git a/src/java.logging/share/classes/java/util/logging/LogManager.java b/src/java.logging/share/classes/java/util/logging/LogManager.java index 9c9c708a062..102f4bac6e4 100644 --- a/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -736,41 +736,56 @@ public class LogManager { logger.setLevel(level); } - // instantiation of the handler is done in the LogManager.addLogger - // implementation as a handler class may be only visible to LogManager - // subclass for the custom log manager case - processParentHandlers(logger, name, VisitedLoggers.NEVER); + // We need to make sure that loggers created by processParentHandlers + // will not be garbage collected before the child/parent + // pointers are updated. We use an ArrayList to temporarily + // store these loggers, until the parent/child relationship + // have been updated + final List saved = new ArrayList<>(); + try { - // Find the new node and its parent. - LogNode node = getNode(name); - node.loggerRef = ref; - Logger parent = null; - LogNode nodep = node.parent; - while (nodep != null) { - LoggerWeakRef nodeRef = nodep.loggerRef; - if (nodeRef != null) { - parent = nodeRef.get(); - if (parent != null) { - break; + // always return false, to make sure we process all loggers from + // root to child. + Predicate visited = (l) -> saved.add(l) && false; + + // instantiation of the handler is done in the LogManager.addLogger + // implementation as a handler class may be only visible to LogManager + // subclass for the custom log manager case + processParentHandlers(logger, name, visited); + + // Find the new node and its parent. + LogNode node = getNode(name); + node.loggerRef = ref; + Logger parent = null; + LogNode nodep = node.parent; + while (nodep != null) { + LoggerWeakRef nodeRef = nodep.loggerRef; + if (nodeRef != null) { + parent = nodeRef.get(); + if (parent != null) { + break; + } } + nodep = nodep.parent; } - nodep = nodep.parent; - } - if (parent != null) { - logger.setParent(parent); - } - // Walk over the children and tell them we are their new parent. - node.walkAndSetParent(logger); - // new LogNode is ready so tell the LoggerWeakRef about it - ref.setNode(node); + if (parent != null) { + logger.setParent(parent); + } + // Walk over the children and tell them we are their new parent. + node.walkAndSetParent(logger); + // new LogNode is ready so tell the LoggerWeakRef about it + ref.setNode(node); - // Do not publish 'ref' in namedLoggers before the logger tree - // is fully updated - because the named logger will be visible as - // soon as it is published in namedLoggers (findLogger takes - // benefit of the ConcurrentHashMap implementation of namedLoggers - // to avoid synchronizing on retrieval when that is possible). - namedLoggers.put(name, ref); + // Do not publish 'ref' in namedLoggers before the logger tree + // is fully updated - because the named logger will be visible as + // soon as it is published in namedLoggers (findLogger takes + // benefit of the ConcurrentHashMap implementation of namedLoggers + // to avoid synchronizing on retrieval when that is possible). + namedLoggers.put(name, ref); + } finally { + saved.clear(); + } return true; } @@ -1647,11 +1662,6 @@ public class LogManager { public void clear() { if (visited != null) visited.clear(); } - - // An object that considers that no logger has ever been visited. - // This is used when processParentHandlers is called from - // LoggerContext.addLocalLogger - static final VisitedLoggers NEVER = new VisitedLoggers(null); } diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java index 6eebaf4d6eb..dcb739a8697 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -523,7 +523,15 @@ public final class Connection implements Runnable { void abandonRequest(LdapRequest ldr, Control[] reqCtls) { // Remove from queue removeRequest(ldr); - + // an optimistic check to avoid having to construct the BER + // messages for the "abandon request". we repeat + // this check later when holding the lock, before actually + // writing out the "abandon request", and that check actually + // determines whether or not the "abandon request" is actually + // sent + if (!ldr.shouldAbandonRequest()) { + return; + } BerEncoder ber = new BerEncoder(256); int abandonMsgId = getMsgId(); @@ -547,6 +555,9 @@ public final class Connection implements Runnable { lock.lock(); try { + if (!ldr.shouldAbandonRequest()) { + return; + } outStream.write(ber.getBuf(), 0, ber.getDataLen()); outStream.flush(); } finally { @@ -680,7 +691,7 @@ public final class Connection implements Runnable { if (nparent) { LdapRequest ldr = pendingRequests; while (ldr != null) { - ldr.close(); + ldr.connectionClosed(); ldr = ldr.next; } } diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java index 2fdd685376c..a8694ed3c7a 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit; final class LdapRequest { - private static final BerDecoder CLOSED_MARKER = new BerDecoder(new byte[]{}, -1, 0); + private static final BerDecoder CONN_CLOSED_MARKER = new BerDecoder(new byte[]{}, -1, 0); private static final BerDecoder CANCELLED_MARKER = new BerDecoder(new byte[]{}, -1, 0); private static final String CLOSE_MSG = "LDAP connection has been closed"; @@ -44,7 +44,7 @@ final class LdapRequest { private final boolean pauseAfterReceipt; private volatile boolean cancelled; - private volatile boolean closed; + private volatile boolean connectionClosed; private volatile boolean completed; LdapRequest(int msgId, boolean pause, int replyQueueCapacity) { @@ -62,9 +62,22 @@ final class LdapRequest { replies.offer(CANCELLED_MARKER); } - void close() { - closed = true; - replies.offer(CLOSED_MARKER); + /* + * Invoked when the connection on which this (pending) request was made + * is closed. + */ + void connectionClosed() { + connectionClosed = true; + replies.offer(CONN_CLOSED_MARKER); + } + + /** + * {@return true if an "abandon request" may be sent for this request, false otherwise} + */ + boolean shouldAbandonRequest() { + // if the connection to which this request belonged was closed, then + // don't send any further "abandon request" message + return !connectionClosed; } boolean addReplyBer(BerDecoder ber) { @@ -73,7 +86,7 @@ final class LdapRequest { // this is merely a best effort basis check and if we do add the reply // due to a race, that's OK since the replies queue would have necessary // markers for cancelled/closed state and those will be detected by getReplyBer(). - if (cancelled || closed) { + if (cancelled || connectionClosed) { return false; } // if the request is not already completed, check if the reply being added @@ -127,7 +140,7 @@ final class LdapRequest { throw new CommunicationException("Request: " + msgId + " cancelled"); } - if (closed) { + if (connectionClosed) { throw new IOException(CLOSE_MSG); } } @@ -146,7 +159,7 @@ final class LdapRequest { throw new CommunicationException("Request: " + msgId + " cancelled"); } - if (result == CLOSED_MARKER) { + if (result == CONN_CLOSED_MARKER) { throw new IOException(CLOSE_MSG); } return result; diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/SaslOutputStream.java b/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/SaslOutputStream.java index 30d64fc8611..8787df8c498 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/SaslOutputStream.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/SaslOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,9 +35,10 @@ import java.io.OutputStream; class SaslOutputStream extends FilterOutputStream { private static final boolean debug = false; - private byte[] lenBuf = new byte[4]; // buffer for storing length + private final byte[] lenBuf = new byte[4]; // buffer for storing length private int rawSendSize = 65536; - private SaslClient sc; + private final SaslClient sc; + private boolean closed; SaslOutputStream(SaslClient sc, OutputStream out) throws SaslException { super(out); @@ -60,8 +61,9 @@ class SaslOutputStream extends FilterOutputStream { // Override this method to call write(byte[], int, int) counterpart // super.write(int) simply calls out.write(int) - + @Override public void write(int b) throws IOException { + ensureOpen(); byte[] buffer = new byte[1]; buffer[0] = (byte)b; write(buffer, 0, 1); @@ -71,7 +73,9 @@ class SaslOutputStream extends FilterOutputStream { * Override this method to "wrap" the outgoing buffer before * writing it to the underlying output stream. */ + @Override public void write(byte[] buffer, int offset, int total) throws IOException { + ensureOpen(); int count; byte[] wrappedToken; @@ -101,7 +105,12 @@ class SaslOutputStream extends FilterOutputStream { } } + @Override public void close() throws IOException { + if (closed) { + return; + } + closed = true; SaslException save = null; try { sc.dispose(); // Dispose of SaslClient's state @@ -121,8 +130,7 @@ class SaslOutputStream extends FilterOutputStream { * Encodes an integer into 4 bytes in network byte order in the buffer * supplied. */ - private static void intToNetworkByteOrder(int num, byte[] buf, int start, - int count) { + private static void intToNetworkByteOrder(int num, byte[] buf, int start, int count) { if (count > 4) { throw new IllegalArgumentException("Cannot handle more than 4 bytes"); } @@ -132,4 +140,10 @@ class SaslOutputStream extends FilterOutputStream { num >>>= 8; } } + + private void ensureOpen() throws IOException { + if (closed) { + throw new IOException("stream closed"); + } + } } diff --git a/src/java.net.http/share/classes/java/net/http/package-info.java b/src/java.net.http/share/classes/java/net/http/package-info.java index 1b8395c2706..ce954404c81 100644 --- a/src/java.net.http/share/classes/java/net/http/package-info.java +++ b/src/java.net.http/share/classes/java/net/http/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -68,6 +68,8 @@ *

    Unless otherwise stated, {@code null} parameter values will cause methods * of all classes in this package to throw {@code NullPointerException}. * + * @see java.net.http/ + * * @spec https://www.rfc-editor.org/info/rfc9114 * RFC 9114: HTTP/3 * @spec https://www.rfc-editor.org/info/rfc7540 diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java index 72a47eca42c..006c4b30bea 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -473,11 +473,10 @@ class Http1Exchange extends ExchangeImpl { @Override Http1ResponseBodySubscriber createResponseSubscriber(BodyHandler handler, ResponseInfo response) { - BodySubscriber subscriber = handler.apply(response); var cancelTimerOnTermination = cancelTimerOnResponseBodySubscriberTermination( exchange.request().isWebSocket(), response.statusCode()); - return new Http1ResponseBodySubscriber<>(subscriber, cancelTimerOnTermination, this); + return new Http1ResponseBodySubscriber<>(handler.apply(response), cancelTimerOnTermination, this); } @Override diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java index 671874b8fb5..670b8cf3c25 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -384,6 +384,7 @@ class MultiExchange implements Cancelable { private CompletableFuture> handleNoBody(Response r, Exchange exch) { BodySubscriber bs = responseHandler.apply(new ResponseInfoImpl(r.statusCode(), r.headers(), r.version())); + Objects.requireNonNull(bs, "BodyHandler returned a null BodySubscriber"); bs.onSubscribe(new NullSubscription()); bs.onComplete(); CompletionStage cs = ResponseSubscribers.getBodyAsync(executor, bs); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpBodySubscriberWrapper.java b/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpBodySubscriberWrapper.java index f1c1f6f2d2a..86a93f67dcd 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpBodySubscriberWrapper.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpBodySubscriberWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,6 +70,7 @@ public class HttpBodySubscriberWrapper implements TrustedSubscriber { volatile SubscriptionWrapper subscription; volatile Throwable withError; public HttpBodySubscriberWrapper(BodySubscriber userSubscriber) { + Objects.requireNonNull(userSubscriber, "BodySubscriber"); this.userSubscriber = userSubscriber; } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/PeerConnectionId.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/PeerConnectionId.java index 0c6f946d1a2..b822480c2a5 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/PeerConnectionId.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/PeerConnectionId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,8 +72,13 @@ public final class PeerConnectionId extends QuicConnectionId { } private static ByteBuffer cloneBuffer(ByteBuffer src) { + // we make a copy of the bytes and create a new + // ByteBuffer here because we do not want to retain + // the memory that was allocated for the original + // ByteBuffer, which could ba a slice of a larger + // buffer, such as the whole datagram payload. final byte[] idBytes = new byte[src.remaining()]; - src.get(idBytes); + src.get(src.position(), idBytes); return ByteBuffer.wrap(idBytes); } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java index edb94d5929a..41b814a551c 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java @@ -703,7 +703,9 @@ public class QuicConnectionImpl extends QuicConnection implements QuicPacketRece return; } if (debug.on()) { - debug.log("scheduleForDecryption: %d bytes", received); + debug.log("scheduleForDecryption: %s bytes [idbytes: %s(%s,%s)]", + received, datagram.destConnId().getClass().getSimpleName(), + datagram.destConnId().position(), datagram.destConnId().limit()); } endpoint.buffer(received); incoming.add(datagram); @@ -1847,6 +1849,10 @@ public class QuicConnectionImpl extends QuicConnection implements QuicPacketRece header.destinationId().toHexString(), Utils.asHexString(destConnId)); } + assert packetIndex > 1 : + "first long packet CID does not match itself %s(%s,%s)" + .formatted(destConnId.getClass().getSimpleName(), + destConnId.position(), destConnId.limit()); return; } var peekedVersion = header.version(); @@ -1918,6 +1924,10 @@ public class QuicConnectionImpl extends QuicConnection implements QuicPacketRece " wrong connection id (%s vs %s)", packetIndex, Utils.asHexString(cid), Utils.asHexString(destConnId)); } + assert packetIndex > 1 : "first short packet CID does not match itself %s(%s,%s)" + .formatted(destConnId.getClass().getSimpleName(), + destConnId.position(), destConnId.limit()); + return; } @@ -1934,6 +1944,9 @@ public class QuicConnectionImpl extends QuicConnection implements QuicPacketRece if (debug.on()) { debug.log("Failed to process incoming packet", t); } + if (t instanceof AssertionError) { + this.terminator.terminate(TerminationCause.forException(t)); + } } } diff --git a/src/java.net.http/share/classes/module-info.java b/src/java.net.http/share/classes/module-info.java index 48f23953ad0..fdfd1bf7e0d 100644 --- a/src/java.net.http/share/classes/module-info.java +++ b/src/java.net.http/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ */ /** - * Defines the HTTP Client and WebSocket APIs. + * Defines the {@linkplain java.net.http HTTP Client and WebSocket APIs}. *

    * System properties used by the java.net.http API *

    @@ -144,15 +144,21 @@ * The value for HTTP/2 and HTTP/3 can be overridden with the * {@code jdk.httpclient.keepalive.timeout.h2} and {@code jdk.httpclient.keepalive.timeout.h3} * properties respectively. The value specified for HTTP/2 acts as default value for HTTP/3. + * If the provided value is negative, the default value is used. + * A value of 0 is valid and has no special meaning other than the connection is closed + * when it becomes idle. *

  • *
  • {@systemProperty jdk.httpclient.keepalive.timeout.h2} (default: see - * below)
    The number of seconds to keep idle HTTP/2 connections alive. If not set, then the - * {@code jdk.httpclient.keepalive.timeout} setting is used. + * below)
    The number of seconds to keep idle HTTP/2 connections alive. If not set, or negative, + * then the {@code jdk.httpclient.keepalive.timeout} setting is used. + * A value of 0 is valid and has no special meaning other than the connection is closed + * when it becomes idle. *

  • *
  • {@systemProperty jdk.httpclient.keepalive.timeout.h3} (default: see - * below)
    The number of seconds to keep idle HTTP/3 connections alive. If not set, then the - * {@code jdk.httpclient.keepalive.timeout.h2} setting is used. - *

  • + * below)
    The number of seconds to keep idle HTTP/3 connections alive. If not set, + * or negative, then the {@code jdk.httpclient.keepalive.timeout.h2} setting is used. + * A value of 0 is valid and has no special meaning other than the connection is closed + * when it becomes idle. *
  • {@systemProperty jdk.httpclient.maxframesize} (default: 16384 or 16kB)
    * The HTTP/2 client maximum frame size in bytes. The server is not permitted to send a frame * larger than this. diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java index 845203c8735..152883b4930 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java @@ -266,6 +266,13 @@ public interface Tree { */ PRIMITIVE_TYPE(PrimitiveTypeTree.class), + /** + * Used for instances of {@link VarTypeTree}. + * + * @since 27 + */ + VAR_TYPE(VarTypeTree.class), + /** * Used for instances of {@link ReturnTree}. */ diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java index a2a33ccf8eb..f2a067971d1 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java @@ -498,6 +498,15 @@ public interface TreeVisitor { */ R visitPrimitiveType(PrimitiveTypeTree node, P p); + /** + * Visits a {@code VarTypeTree} node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + * @since 27 + */ + R visitVarType(VarTypeTree node, P p); + /** * Visits a {@code TypeParameterTree} node. * @param node the node being visited diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/VarTypeTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/VarTypeTree.java new file mode 100644 index 00000000000..bfe13ebdce1 --- /dev/null +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/VarTypeTree.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.tree; + +import javax.lang.model.type.TypeKind; + +/** + * A tree node for a {@code var} contextual keyword used as a type. + * + * @since 27 + */ +public interface VarTypeTree extends Tree { +} diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java index a1191b2f8e6..11dc41577be 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java @@ -65,10 +65,13 @@ public interface VariableTree extends StatementTree { */ ExpressionTree getNameExpression(); - /** - * Returns the type of the variable being declared. - * @return the type - */ + /// {@return the type of the variable being declared.} + /// + /// @apiNote + /// The type of the variable can be one of the following: + /// - if the variable is declared using {@code var}, then the returned value is a {@link VarTypeTree}, + /// - if the variable is a lambda parameter declared without a type (i.e. relying on type inferrence), then the returned value is {@code null}, + /// - otherwise, the variable is declared with an explicit type, and the returned value is that type. Tree getType(); /** diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java index 45a452bd0dd..44d9bd89917 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java +++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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,23 +195,30 @@ public abstract class DocTrees extends Trees { /** * Returns the language model element referred to by the leaf node of the given - * {@link DocTreePath}, or {@code null} if unknown. + * {@link DocTreePath}, or {@code null} if the leaf node of {@code path} does + * not refer to an element. + * * @param path the path for the tree node - * @return the element + * @return the referenced element, or null + * @see #getType(DocTreePath) */ public abstract Element getElement(DocTreePath path); /** * Returns the language model type referred to by the leaf node of the given - * {@link DocTreePath}, or {@code null} if unknown. This method usually - * returns the same value as {@code getElement(path).asType()} for a - * {@code path} argument for which {@link #getElement(DocTreePath)} returns - * a non-null value, but may return a type that includes additional - * information, such as a parameterized generic type instead of a raw type. + * {@link DocTreePath}, or {@code null} if the leaf node of {@code path} does + * not refer to a type. + * + *

    If {@link #getElement(DocTreePath)} returns a non-null value for a given {@code path} + * argument, this method usally returns the same value as {@code getElement(path).asType()}. + * However, there are cases where the returned type includes additional information, + * such as a parameterized generic type instead of a raw type. In other cases, such as with + * primitive or array types, the returned type may not have a corresponding element returned + * by {@code getElement(DocTreePath)}.

    * * @param path the path for the tree node * @return the referenced type, or null - * + * @see #getElement(DocTreePath) * @since 15 */ public abstract TypeMirror getType(DocTreePath path); diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java index 77305d56b1e..917df861b70 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java +++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java @@ -803,6 +803,21 @@ public class SimpleTreeVisitor implements TreeVisitor { return defaultAction(node, p); } + /** + * {@inheritDoc} + * + * @implSpec This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + * @since 27 + */ + @Override + public R visitVarType(VarTypeTree node, P p) { + return defaultAction(node, p); + } + /** * {@inheritDoc} * diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java index 29e81c206e0..ca8b785d8cb 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java +++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java @@ -939,6 +939,21 @@ public class TreeScanner implements TreeVisitor { return null; } + /** + * {@inheritDoc} + * + * @implSpec This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + * @since 27 + */ + @Override + public R visitVarType(VarTypeTree node, P p) { + return null; + } + /** * {@inheritDoc} * diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java index 6bc5d358b6f..ecd7f5b101a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -354,22 +354,28 @@ public class JavacTrees extends DocTrees { DocTree tree = path.getLeaf(); if (tree instanceof DCReference dcReference) { JCTree qexpr = dcReference.qualifierExpression; - if (qexpr != null) { + + // Forward references with explicit module name to getElement + if (qexpr != null && dcReference.moduleName == null) { + + Env env = getAttrContext(path.getTreePath()); Log.DeferredDiagnosticHandler deferredDiagnosticHandler = log.new DeferredDiagnosticHandler(); + JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile); + try { - Env env = getAttrContext(path.getTreePath()); - JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile); - try { - Type t = attr.attribType(dcReference.qualifierExpression, env); - if (t != null && !t.isErroneous()) { + Type t = attr.attribType(dcReference.qualifierExpression, env); + if (t != null && !t.isErroneous()) { + if (dcReference.memberName != null) { + Symbol sym = resolveMember(t, (Name) dcReference.memberName, dcReference, env); + return sym == null ? null : sym.type; + } else { return t; } - } finally { - log.useSource(prevSource); } } catch (Abort e) { // may be thrown by Check.completionError in case of bad class file return null; } finally { + log.useSource(prevSource); log.popDiagnosticHandler(deferredDiagnosticHandler); } } @@ -426,14 +432,12 @@ public class JavacTrees extends DocTrees { memberName = (Name) ref.memberName; } else { // Check if qualifierExpression is a type or package, using the methods javac provides. - // If no module name is given we check if qualifierExpression identifies a type. - // If that fails or we have a module name, use that to resolve qualifierExpression to - // a package or type. - Type t = ref.moduleName == null ? attr.attribType(ref.qualifierExpression, env) : null; + Type t = attr.attribType(ref.qualifierExpression, env); - if (t == null || t.isErroneous()) { - JCCompilationUnit toplevel = - treeMaker.TopLevel(List.nil()); + if (t == null || t.isErroneous() || + (ref.moduleName != null && !mdlsym.equals(elements.getModuleOf(t.asElement())))) { + + JCCompilationUnit toplevel = treeMaker.TopLevel(List.nil()); toplevel.modle = mdlsym; toplevel.packge = mdlsym.unnamedPackage; Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel); @@ -447,10 +451,6 @@ public class JavacTrees extends DocTrees { if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) { tsym = (TypeSymbol) sym; memberName = (Name) ref.memberName; - if (sym.kind == PCK && memberName != null) { - //cannot refer to a package "member" - return null; - } } else { if (modules.modulesInitialized() && ref.moduleName == null && ref.memberName == null) { // package/type does not exist, check if there is a matching module @@ -470,64 +470,22 @@ public class JavacTrees extends DocTrees { } } } else { - Type e = t; - // If this is an array type convert to element type - while (e instanceof ArrayType arrayType) - e = arrayType.elemtype; - tsym = e.tsym; + tsym = switch (t.getKind()) { + case DECLARED, TYPEVAR, PACKAGE, MODULE -> t.tsym; + default -> null; + }; memberName = (Name) ref.memberName; } } if (memberName == null) { return tsym; - } else if (tsym == null || tsym.getKind() == ElementKind.PACKAGE || tsym.getKind() == ElementKind.MODULE) { - return null; // Non-null member name in non-class context - } - - if (tsym.type.isPrimitive()) { + } else if (tsym == null) { return null; } - final List paramTypes; - if (ref.paramTypes == null) - paramTypes = null; - else { - ListBuffer lb = new ListBuffer<>(); - for (List l = (List) ref.paramTypes; l.nonEmpty(); l = l.tail) { - JCTree tree = l.head; - Type t = attr.attribType(tree, env); - lb.add(t); - } - paramTypes = lb.toList(); - } + return resolveMember(tsym.type, memberName, ref, env); - ClassSymbol sym = (ClassSymbol) types.skipTypeVars(tsym.type, false).tsym; - boolean explicitType = ref.qualifierExpression != null; - Symbol msym = (memberName == sym.name) - ? findConstructor(sym, paramTypes, true) - : findMethod(sym, memberName, paramTypes, true, explicitType); - - if (msym == null) { - msym = (memberName == sym.name) - ? findConstructor(sym, paramTypes, false) - : findMethod(sym, memberName, paramTypes, false, explicitType); - } - - if (paramTypes != null) { - // explicit (possibly empty) arg list given, so cannot be a field - return msym; - } - - VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName, explicitType); - // prefer a field over a method with no parameters - if (vsym != null && - (msym == null || - types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { - return vsym; - } else { - return msym; - } } catch (Abort e) { // may be thrown by Check.completionError in case of bad class file return null; } finally { @@ -536,6 +494,54 @@ public class JavacTrees extends DocTrees { } } + private Symbol resolveMember(Type type, Name memberName, DCReference ref, Env env) { + + if (type.isPrimitive() || type.getKind() == TypeKind.PACKAGE || type.getKind() == TypeKind.MODULE) { + return null; + } + + final List paramTypes; + if (ref.paramTypes == null) + paramTypes = null; + else { + ListBuffer lb = new ListBuffer<>(); + for (List l = (List) ref.paramTypes; l.nonEmpty(); l = l.tail) { + JCTree tree = l.head; + Type t = attr.attribType(tree, env); + lb.add(t); + } + paramTypes = lb.toList(); + } + + // skipTypeVars conversion below is needed if type is itself a type variable + ClassSymbol sym = (ClassSymbol) types.skipTypeVars(type, false).tsym; + boolean explicitType = ref.qualifierExpression != null; + Symbol msym = (memberName == sym.name) + ? findConstructor(sym, paramTypes, true) + : findMethod(sym, memberName, paramTypes, true, explicitType); + + if (msym == null) { + msym = (memberName == sym.name) + ? findConstructor(sym, paramTypes, false) + : findMethod(sym, memberName, paramTypes, false, explicitType); + } + + if (paramTypes != null) { + // explicit (possibly empty) arg list given, so cannot be a field + return msym; + } + + VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName, explicitType); + // prefer a field over a method with no parameters + if (vsym != null && + (msym == null || + types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { + return vsym; + } else { + return msym; + } + } + private Symbol attributeParamIdentifier(TreePath path, DCParam paramTag) { Symbol javadocSymbol = getElement(path); if (javadocSymbol == null) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java index 5b59e47027e..ac1bcc84194 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -156,12 +156,22 @@ public class Flags { @Use({FlagTarget.CLASS}) public static final int IMPLICIT_CLASS = 1<<19; + /** Variable with implicit/inferred type. + */ + @Use(FlagTarget.VARIABLE) + public static final int VAR_VARIABLE = 1<<19; + /** Flag is set for compiler-generated anonymous method symbols * that `own' an initializer block. */ @Use({FlagTarget.METHOD}) public static final int BLOCK = 1<<20; + /** A parameter of a lambda function. + */ + @Use(FlagTarget.VARIABLE) + public static final int LAMBDA_PARAMETER = 1<<20; + /** Flag is set for ClassSymbols that are being compiled from source. */ @Use({FlagTarget.CLASS}) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index 84a823f785f..cf5e5ca83f5 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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 @@ -272,6 +272,7 @@ public enum Source { CASE_NULL(JDK21, Fragments.FeatureCaseNull, DiagKind.NORMAL), PATTERN_SWITCH(JDK21, Fragments.FeaturePatternSwitch, DiagKind.PLURAL), REDUNDANT_STRICTFP(JDK17), + TYPE_ANNOTATIONS_ON_VAR_LAMBDA_PARAMETER(MIN, JDK19), UNCONDITIONAL_PATTERN_IN_INSTANCEOF(JDK21, Fragments.FeatureUnconditionalPatternsInInstanceof, DiagKind.PLURAL), RECORD_PATTERNS(JDK21, Fragments.FeatureDeconstructionPatterns, DiagKind.PLURAL), IMPLICIT_CLASSES(JDK25, Fragments.FeatureImplicitClasses, DiagKind.PLURAL), diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 86319f20c73..8eba79c7480 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -50,6 +50,7 @@ import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind; import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Type.ModuleType; +import com.sun.tools.javac.code.Type.UnionClassType; import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; @@ -61,6 +62,7 @@ import com.sun.tools.javac.tree.JCTree.JCAnnotatedType; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; import com.sun.tools.javac.tree.JCTree.JCBlock; +import com.sun.tools.javac.tree.JCTree.JCCatch; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.tree.JCTree.JCFieldAccess; @@ -70,6 +72,7 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; import com.sun.tools.javac.tree.JCTree.JCNewArray; import com.sun.tools.javac.tree.JCTree.JCNewClass; +import com.sun.tools.javac.tree.JCTree.JCTry; import com.sun.tools.javac.tree.JCTree.JCTypeApply; import com.sun.tools.javac.tree.JCTree.JCTypeIntersection; import com.sun.tools.javac.tree.JCTree.JCTypeParameter; @@ -111,6 +114,7 @@ public class TypeAnnotations { final Symtab syms; final Annotate annotate; final Attr attr; + final Types types; @SuppressWarnings("this-escape") protected TypeAnnotations(Context context) { @@ -120,6 +124,7 @@ public class TypeAnnotations { syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); + types = Types.instance(context); } /** @@ -132,7 +137,24 @@ public class TypeAnnotations { annotate.afterTypes(() -> { JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); try { - new TypeAnnotationPositions(true).scan(tree); + new TypeAnnotationPositions(null, true).scan(tree); + } finally { + log.useSource(oldSource); + } + }); + } + + public void organizeTypeAnnotationsSignaturesForLocalVarType(final Env env, final JCVariableDecl tree) { + annotate.afterTypes(() -> { + JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); + try { + TypeAnnotationPositions pos = new TypeAnnotationPositions(env.tree, true); + if (env.tree instanceof JCLambda) { + pos.push(env.tree); + } else { + pos.push(env.enclMethod); + } + pos.scan(tree); } finally { log.useSource(oldSource); } @@ -155,7 +177,7 @@ public class TypeAnnotations { * top-level blocks, and method bodies, and should be called from Attr. */ public void organizeTypeAnnotationsBodies(JCClassDecl tree) { - new TypeAnnotationPositions(false).scan(tree); + new TypeAnnotationPositions(null, false).scan(tree); } public enum AnnotationType { DECLARATION, TYPE, NONE, BOTH } @@ -265,9 +287,11 @@ public class TypeAnnotations { private class TypeAnnotationPositions extends TreeScanner { + private final JCTree contextTree; private final boolean sigOnly; - TypeAnnotationPositions(boolean sigOnly) { + TypeAnnotationPositions(JCTree contextTree, boolean sigOnly) { + this.contextTree = contextTree; this.sigOnly = sigOnly; } @@ -455,14 +479,15 @@ public class TypeAnnotations { return type.annotatedType(onlyTypeAnnotations); } else if (type.getKind() == TypeKind.UNION) { // There is a TypeKind, but no TypeTag. + UnionClassType ut = (UnionClassType) type; JCTypeUnion tutree = (JCTypeUnion)typetree; JCExpression fst = tutree.alternatives.get(0); Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations, pos); fst.type = res; - // TODO: do we want to set res as first element in uct.alternatives? - // UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type; - // Return the un-annotated union-type. - return type; + ListBuffer alternatives = new ListBuffer<>(); + alternatives.add(res); + alternatives.addAll(ut.alternatives_field.tail); + return new UnionClassType((ClassType) ut.getLub(), alternatives.toList()); } else { Type enclTy = type; Element enclEl = type.asElement(); @@ -1237,7 +1262,17 @@ public class TypeAnnotations { } else if (tree.sym == null) { Assert.error("Visiting tree node before memberEnter"); } else if (tree.sym.getKind() == ElementKind.PARAMETER) { - // Parameters are handled in visitMethodDef or visitLambda. + if (sigOnly) { + if (contextTree instanceof JCCatch c && c.param == tree) { + //exception "parameter": + final TypeAnnotationPosition pos = + TypeAnnotationPosition.exceptionParameter(currentLambda, + tree.pos); + separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + } else { + // (real) parameters are handled in visitMethodDef or visitLambda. + } + } } else if (tree.sym.getKind() == ElementKind.FIELD) { if (sigOnly) { TypeAnnotationPosition pos = @@ -1245,27 +1280,36 @@ public class TypeAnnotations { separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); } } else if (tree.sym.getKind() == ElementKind.LOCAL_VARIABLE) { - final TypeAnnotationPosition pos = - TypeAnnotationPosition.localVariable(currentLambda, - tree.pos); - if (!tree.declaredUsingVar()) { - separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + if (sigOnly && !tree.declaredUsingVar()) { + if (contextTree instanceof JCTry t && t.resources.contains(tree)) { + final TypeAnnotationPosition pos = + TypeAnnotationPosition.resourceVariable(currentLambda, + tree.pos); + separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + } else { + final TypeAnnotationPosition pos = + TypeAnnotationPosition.localVariable(currentLambda, + tree.pos); + if (!tree.declaredUsingVar()) { + separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + } + } } } else if (tree.sym.getKind() == ElementKind.BINDING_VARIABLE) { - final TypeAnnotationPosition pos = - TypeAnnotationPosition.localVariable(currentLambda, - tree.pos); - separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + if (sigOnly) { + final TypeAnnotationPosition pos = + TypeAnnotationPosition.localVariable(currentLambda, + tree.pos); + separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + } } else if (tree.sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { - final TypeAnnotationPosition pos = - TypeAnnotationPosition.exceptionParameter(currentLambda, - tree.pos); - separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + if (sigOnly) { + Assert.error("Should not get variable kind: " + tree.sym.getKind()); + } } else if (tree.sym.getKind() == ElementKind.RESOURCE_VARIABLE) { - final TypeAnnotationPosition pos = - TypeAnnotationPosition.resourceVariable(currentLambda, - tree.pos); - separateAnnotationsKinds(tree, tree.vartype, tree.sym.type, tree.sym, pos); + if (sigOnly) { + Assert.error("Should not get variable kind: " + tree.sym.getKind()); + } } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) { // No type annotations can occur here. } else { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 539b1470a75..f1c6676d087 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -993,10 +993,12 @@ public class Types { @Override public boolean test(Symbol sym) { + List msyms; return sym.kind == MTH && (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT && !overridesObjectMethod(origin, sym) && - (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0; + (msyms = interfaceCandidates(origin.type, (MethodSymbol)sym)).nonEmpty() && + (msyms.head.flags() & DEFAULT) == 0; } } @@ -1436,7 +1438,7 @@ public class Types { return visit(s, t); return s.hasTag(ARRAY) - && containsTypeEquivalent(t.elemtype, elemtype(s)); + && visit(t.elemtype, elemtype(s)); } @Override diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java index f45e8500000..fb5576a82e1 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java @@ -370,7 +370,6 @@ public class Analyzer { */ JCVariableDecl rewriteVarType(JCVariableDecl oldTree) { JCVariableDecl newTree = copier.copy(oldTree); - newTree.vartype = null; return newTree; } @@ -751,7 +750,6 @@ public class Analyzer { if (oldLambda.paramKind == ParameterKind.IMPLICIT) { //reset implicit lambda parameters (whose type might have been set during attr) newLambda.paramKind = ParameterKind.IMPLICIT; - newLambda.params.forEach(p -> p.vartype = null); } return newLambda; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java index f865afe11fb..118d761573b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -861,7 +861,6 @@ public class Annotate { if (!chk.validateAnnotationDeferErrors(annoTree)) log.error(annoTree.pos(), Errors.DuplicateAnnotationInvalidRepeated(origAnnoType)); - c = attributeAnnotation(annoTree, targetContainerType, ctx.env); c.setSynthesized(true); @SuppressWarnings("unchecked") diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index cdd88b22510..444530c7266 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -680,10 +680,7 @@ public class Attr extends JCTree.Visitor { } matchBindings = matchBindingsComputer.finishBindings(tree, matchBindings); - if (tree == breakTree && - resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) { - breakTreeFound(copyEnv(env)); - } + checkBreakTree(tree, env); return result; } catch (CompletionFailure ex) { tree.type = syms.errType; @@ -694,6 +691,13 @@ public class Attr extends JCTree.Visitor { } } + private void checkBreakTree(JCTree tree, Env env) { + if (tree == breakTree && + resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) { + breakTreeFound(copyEnv(env)); + } + } + protected void breakTreeFound(Env env) { throw new BreakAttr(env); } @@ -1259,24 +1263,25 @@ public class Attr extends JCTree.Visitor { // parameters have already been entered env.info.scope.enter(tree.sym); } else { - if (tree.isImplicitlyTyped() && (tree.getModifiers().flags & PARAMETER) == 0) { + if (tree.isImplicitlyTyped() && (tree.getModifiers().flags & PARAMETER) == 0 && tree.type == null) { if (tree.init == null) { //cannot use 'var' without initializer log.error(tree, Errors.CantInferLocalVarType(tree.name, Fragments.LocalMissingInit)); - tree.vartype = make.at(tree.pos()).Erroneous(); + tree.type = syms.errType; } else { Fragment msg = canInferLocalVarType(tree); if (msg != null) { //cannot use 'var' with initializer which require an explicit target //(e.g. lambda, method reference, array initializer). log.error(tree, Errors.CantInferLocalVarType(tree.name, msg)); - tree.vartype = make.at(tree.pos()).Erroneous(); + tree.type = syms.errType; } } } try { annotate.blockAnnotations(); memberEnter.memberEnter(tree, env); + typeAnnotations.organizeTypeAnnotationsSignaturesForLocalVarType(env, tree); } finally { annotate.unblockAnnotations(); } @@ -1319,7 +1324,7 @@ public class Attr extends JCTree.Visitor { } } if (tree.isImplicitlyTyped()) { - setSyntheticVariableType(tree, v.type); + setupImplicitlyTypedVariable(tree, v.type); } } result = tree.type = v.type; @@ -1593,7 +1598,8 @@ public class Attr extends JCTree.Visitor { } if (tree.var.isImplicitlyTyped()) { Type inferredType = chk.checkLocalVarType(tree.var, elemtype, tree.var.name); - setSyntheticVariableType(tree.var, inferredType); + tree.var.type = inferredType; + setupImplicitlyTypedVariable(tree.var, inferredType); } attribStat(tree.var, loopEnv); chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type); @@ -2813,6 +2819,8 @@ public class Attr extends JCTree.Visitor { checkNewInnerClass(tree.pos(), env, clazztype, false); } + checkBreakTree(tree.clazz, localEnv); + // Attribute constructor arguments. ListBuffer argtypesBuf = new ListBuffer<>(); final KindSelector pkind = @@ -3217,8 +3225,10 @@ public class Attr extends JCTree.Visitor { Type argType = arityMismatch ? syms.errType : actuals.head; - if (params.head.isImplicitlyTyped()) { - setSyntheticVariableType(params.head, argType); + if (params.head.type == null && + params.head.isImplicitlyTyped()) { //error recovery + params.head.type = argType; + setupImplicitlyTypedVariable(params.head, argType); } params.head.sym = null; actuals = actuals.isEmpty() ? @@ -3250,10 +3260,8 @@ public class Attr extends JCTree.Visitor { attribTree(that.getBody(), localEnv, bodyResultInfo); } else { JCBlock body = (JCBlock)that.body; - if (body == breakTree && - resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) { - breakTreeFound(copyEnv(localEnv)); - } + + checkBreakTree(body, localEnv); attribStats(body.stats, localEnv); } @@ -3438,7 +3446,7 @@ public class Attr extends JCTree.Visitor { JCLambda lambda = (JCLambda)tree; List argtypes = List.nil(); for (JCVariableDecl param : lambda.params) { - argtypes = param.vartype != null && param.vartype.type != null ? + argtypes = !param.isImplicitlyTyped() && param.vartype.type != null ? argtypes.append(param.vartype.type) : argtypes.append(syms.errType); } @@ -4214,29 +4222,30 @@ public class Attr extends JCTree.Visitor { public void visitBindingPattern(JCBindingPattern tree) { Type type; - if (tree.var.vartype != null) { + if (!tree.var.isImplicitlyTyped()) { type = attribType(tree.var.vartype, env); } else { type = resultInfo.pt; } - tree.type = tree.var.type = type; - BindingSymbol v = new BindingSymbol(tree.var.mods.flags, tree.var.name, type, env.info.scope.owner); + BindingSymbol v = new BindingSymbol(tree.var.mods.flags | tree.var.declKind.additionalSymbolFlags, + tree.var.name, type, env.info.scope.owner); v.pos = tree.pos; tree.var.sym = v; if (chk.checkUnique(tree.var.pos(), v, env.info.scope)) { chk.checkTransparentVar(tree.var.pos(), v, env.info.scope); } - chk.validate(tree.var.vartype, env, true); if (tree.var.isImplicitlyTyped()) { - setSyntheticVariableType(tree.var, type == Type.noType ? syms.errType - : type); + setupImplicitlyTypedVariable(tree.var, type == Type.noType ? syms.errType + : type); } + chk.validate(tree.var.vartype, env, true); annotate.annotateLater(tree.var.mods.annotations, env, v); if (!tree.var.isImplicitlyTyped()) { annotate.queueScanTreeAndTypeAnnotate(tree.var.vartype, env, v); } annotate.flush(); - result = tree.type; + typeAnnotations.organizeTypeAnnotationsSignaturesForLocalVarType(env, tree.var); + result = tree.type = tree.var.type = v.type; if (v.isUnnamedVariable()) { matchBindings = MatchBindingsComputer.EMPTY; } else { @@ -4249,7 +4258,7 @@ public class Attr extends JCTree.Visitor { public void visitRecordPattern(JCRecordPattern tree) { Type site; - if (tree.deconstructor == null) { + if (tree.deconstructor.hasTag(VARTYPE)) { log.error(tree.pos(), Errors.DeconstructionPatternVarNotAllowed); tree.record = syms.errSymbol; site = tree.type = types.createErrorType(tree.record.type); @@ -4265,6 +4274,7 @@ public class Attr extends JCTree.Visitor { } tree.type = tree.deconstructor.type = type; site = types.capture(tree.type); + chk.validate(tree.deconstructor, env, true); } List expectedRecordTypes; @@ -4310,7 +4320,6 @@ public class Attr extends JCTree.Visitor { } finally { localEnv.info.scope.leave(); } - chk.validate(tree.deconstructor, env, true); result = tree.type; matchBindings = new MatchBindings(outBindings.toList(), List.nil()); } @@ -5390,7 +5399,8 @@ public class Attr extends JCTree.Visitor { Type st = types.supertype(c.type); if ((c.flags_field & Flags.COMPOUND) == 0 && - (c.flags_field & Flags.SUPER_OWNER_ATTRIBUTED) == 0) { + (c.flags_field & Flags.SUPER_OWNER_ATTRIBUTED) == 0 && + breakTree == null) { // First, attribute superclass. if (st.hasTag(CLASS)) attribClass((ClassSymbol)st.tsym); @@ -5725,15 +5735,20 @@ public class Attr extends JCTree.Visitor { return types.capture(type); } - private void setSyntheticVariableType(JCVariableDecl tree, Type type) { - if (type.isErroneous()) { - tree.vartype = make.at(tree.pos()).Erroneous(); - } else if (tree.declaredUsingVar()) { - Assert.check(tree.typePos != Position.NOPOS); - tree.vartype = make.at(tree.typePos).Type(type); - } else { - tree.vartype = make.at(tree.pos()).Type(type); + private void setupImplicitlyTypedVariable(JCVariableDecl tree, Type type) { + Assert.check(tree.isImplicitlyTyped()); + + type.complete(); + + if (tree.vartype == null) { + return ; } + + Assert.check(tree.vartype.hasTag(VARTYPE)); + + JCVarType vartype = (JCVarType) tree.vartype; + + vartype.type = type; } public void validateTypeAnnotations(JCTree tree, boolean sigOnly) { @@ -6062,9 +6077,6 @@ public class Attr extends JCTree.Visitor { that.sym = new VarSymbol(0, that.name, that.type, syms.noSymbol); that.sym.adr = 0; } - if (that.vartype == null) { - that.vartype = make.at(Position.NOPOS).Erroneous(); - } super.visitVarDef(that); } @@ -6139,6 +6151,11 @@ public class Attr extends JCTree.Visitor { syms.noSymbol); } } + + @Override + public void visitVarType(JCVarType that) { + initTypeIfNeeded(that); + } } // diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrRecover.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrRecover.java index 716345fa077..092035c84dd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrRecover.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrRecover.java @@ -117,11 +117,6 @@ public class AttrRecover { ? formals.head : ((ArrayType) formals.head).elemtype; if (arg.hasTag(JCTree.Tag.LAMBDA)) { final JCTree.JCLambda lambda = (JCLambda) arg; - if (lambda.paramKind == JCLambda.ParameterKind.IMPLICIT) { - for (JCVariableDecl var : lambda.params) { - var.vartype = null; //reset type - } - } if (types.isFunctionalInterface(formal)) { Type functionalType = types.findDescriptorType(formal); boolean voidCompatible = functionalType.getReturnType().hasTag(TypeTag.VOID); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 94b14f3122f..0af30be4671 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -3544,7 +3544,10 @@ public class Check { if (s.kind == PCK) applicableTargets.add(names.PACKAGE); } else if (target == names.TYPE_USE) { - if (s.kind == VAR && s.owner.kind == MTH && s.type.hasTag(NONE)) { + if (s.kind == VAR && + (s.flags() & Flags.VAR_VARIABLE) != 0 && + (!Feature.TYPE_ANNOTATIONS_ON_VAR_LAMBDA_PARAMETER.allowedInSource(source) || + ((s.flags() & Flags.LAMBDA_PARAMETER) == 0))) { //cannot type annotate implicitly typed locals continue; } else if (s.kind == TYP || s.kind == VAR || @@ -5632,8 +5635,8 @@ public class Check { } case JCVariableDecl variableDecl -> { if (variableDecl.vartype != null && - (variableDecl.sym.flags_field & RECORD) == 0 || - (variableDecl.sym.flags_field & ~(Flags.PARAMETER | RECORD | GENERATED_MEMBER)) != 0) { + ((variableDecl.sym.flags_field & RECORD) == 0 || + (variableDecl.sym.flags_field & ~(Flags.PARAMETER | RECORD | GENERATED_MEMBER)) != 0)) { /* we don't want to warn twice so if this variable is a compiler generated parameter of * a canonical record constructor, we don't want to issue a warning as we will warn the * corresponding compiler generated private record field anyways diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index 69161fd682c..be603ffc9ca 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -3692,11 +3692,12 @@ public class Lower extends TreeTranslator { if (tree.var.type.isPrimitive()) vardefinit = make.TypeCast(types.cvarUpperBound(iteratorTarget), vardefinit); else - vardefinit = make.TypeCast(tree.var.type, vardefinit); + vardefinit = transTypes.coerce(attrEnv, vardefinit, tree.var.type); JCVariableDecl indexDef = (JCVariableDecl)make.VarDef(tree.var.mods, tree.var.name, tree.var.vartype, - vardefinit).setType(tree.var.type); + vardefinit, + tree.var.declKind).setType(tree.var.type); indexDef.sym = tree.var.sym; JCBlock body = make.Block(0, List.of(indexDef, tree.body)); body.bracePos = TreeInfo.endPos(tree.body); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java index d63ba1677d6..cb0e6d4676b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -114,7 +114,7 @@ public class MemberEnter extends JCTree.Visitor { ListBuffer argbuf = new ListBuffer<>(); for (List l = params; l.nonEmpty(); l = l.tail) { memberEnter(l.head, env); - argbuf.append(l.head.vartype.type); + argbuf.append(l.head.sym.type); } // Attribute result type, if one is given. @@ -276,12 +276,16 @@ public class MemberEnter extends JCTree.Visitor { tree.vartype.type = atype.makeVarargs(); } WriteableScope enclScope = enter.enterScope(env); - Type vartype = tree.isImplicitlyTyped() - ? env.info.scope.owner.kind == MTH ? Type.noType : syms.errType - : tree.vartype.type; + Type vartype = switch (tree.declKind) { + case IMPLICIT -> tree.type; + case EXPLICIT -> tree.vartype.type; + case VAR -> tree.type != null ? tree.type + : env.info.scope.owner.kind == MTH ? Type.noType + : syms.errType; + }; Name name = tree.name; VarSymbol v = new VarSymbol(0, name, vartype, enclScope.owner); - v.flags_field = chk.checkFlags(tree.mods.flags, v, tree); + v.flags_field = chk.checkFlags(tree.mods.flags | tree.declKind.additionalSymbolFlags, v, tree); tree.sym = v; if (tree.init != null) { v.flags_field |= HASINIT; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java index 862c02ea5f0..1229939c0bf 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -29,7 +29,6 @@ package com.sun.tools.javac.comp; import com.sun.source.tree.MemberReferenceTree.ReferenceMode; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Attribute.TypeCompound; -import com.sun.tools.javac.code.Source.Feature; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.TypeVar; import com.sun.tools.javac.jvm.Target; @@ -49,8 +48,6 @@ import static com.sun.tools.javac.code.TypeTag.VOID; import static com.sun.tools.javac.comp.CompileStates.CompileState; import com.sun.tools.javac.tree.JCTree.JCBreak; -import javax.lang.model.type.TypeKind; - /** This pass translates Generic Java to conventional Java. * *

    This is NOT part of any supported API. @@ -109,7 +106,9 @@ public class TransTypes extends TreeTranslator { if (!types.isSameType(tree.type, target)) { if (!resolve.isAccessible(env, target.tsym)) resolve.logAccessErrorInternal(env, tree, target); - tree = make.TypeCast(make.Type(target), tree).setType(target); + tree = explicitCastTP != null && types.isSameType(target, explicitCastTP) ? + tree : + make.TypeCast(make.Type(target), tree).setType(target); } make.pos = oldpos; return tree; @@ -440,16 +439,29 @@ public class TransTypes extends TreeTranslator { /** Visitor argument: proto-type. */ private Type pt; + /** we use this type to indicate that "upstream" there is an explicit cast to this type, + * this way we can avoid generating redundant type casts. Redundant casts are not + * innocuous as they can trump user provided ones and affect the offset + * calculation of type annotations applied to the user provided type cast. + */ + private Type explicitCastTP; /** Visitor method: perform a type translation on tree. */ public T translate(T tree, Type pt) { + return translate(tree, pt, pt == explicitCastTP ? explicitCastTP : null); + } + + public T translate(T tree, Type pt, Type castTP) { Type prevPt = this.pt; + Type prevCastPT = this.explicitCastTP; try { this.pt = pt; + this.explicitCastTP = castTP; return translate(tree); } finally { this.pt = prevPt; + this.explicitCastTP = prevCastPT; } } @@ -1037,7 +1049,9 @@ public class TransTypes extends TreeTranslator { tree.clazz = translate(tree.clazz, null); Type originalTarget = tree.type; tree.type = erasure(tree.type); - JCExpression newExpression = translate(tree.expr, tree.type); + JCExpression newExpression = tree.clazz.hasTag(Tag.ANNOTATED_TYPE) ? + translate(tree.expr, tree.type, tree.type) : + translate(tree.expr, tree.type); if (newExpression != tree.expr) { JCTypeCast typeCast = newExpression.hasTag(Tag.TYPECAST) ? (JCTypeCast) newExpression diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java index bbc12f1fe80..4890b749a90 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java @@ -93,6 +93,7 @@ import com.sun.tools.javac.tree.JCTree.JCTypeParameter; import com.sun.tools.javac.tree.JCTree.JCTypeUnion; import com.sun.tools.javac.tree.JCTree.JCUnary; import com.sun.tools.javac.tree.JCTree.JCUses; +import com.sun.tools.javac.tree.JCTree.JCVarType; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.tree.JCTree.JCWhileLoop; import com.sun.tools.javac.tree.JCTree.JCWildcard; @@ -631,6 +632,11 @@ public class TreeDiffer extends TreeScanner { result = tree.typetag == that.typetag; } + @Override + public void visitVarType(JCVarType tree) { + result = true; + } + @Override public void visitTypeIntersection(JCTypeIntersection tree) { JCTypeIntersection that = (JCTypeIntersection) parameter; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index b7bf48b4a12..08ba0442781 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,6 +69,7 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.ByteBuffer.UnderflowException; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.JCDiagnostic.Fragment; +import com.sun.tools.javac.util.Log.DeferredDiagnosticHandler; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.Kind.*; @@ -1366,9 +1367,7 @@ public class ClassReader { else self.fullname = ClassSymbol.formFullName(self.name, self.owner); - if (m != null) { - ((ClassType)sym.type).setEnclosingType(m.type); - } else if ((self.flags_field & STATIC) == 0) { + if ((self.flags_field & STATIC) == 0 && (m == null || (m.flags_field & STATIC) == 0)) { ((ClassType)sym.type).setEnclosingType(c.type); } else { ((ClassType)sym.type).setEnclosingType(Type.noType); @@ -2043,15 +2042,27 @@ public class ClassReader { } Attribute.Compound deproxyCompound(CompoundAnnotationProxy a) { - Type annotationType = resolvePossibleProxyType(a.type); - ListBuffer> buf = new ListBuffer<>(); - for (List> l = a.values; - l.nonEmpty(); - l = l.tail) { - MethodSymbol meth = findAccessMethod(annotationType, l.head.fst); - buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd))); + DeferredDiagnosticHandler deferred = log.new DeferredDiagnosticHandler(); + Type annotationType = syms.objectType; + try { + annotationType = resolvePossibleProxyType(a.type); + ListBuffer> buf = new ListBuffer<>(); + for (List> l = a.values; + l.nonEmpty(); + l = l.tail) { + MethodSymbol meth = findAccessMethod(annotationType, l.head.fst); + buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd))); + } + return new Attribute.Compound(annotationType, buf.toList()); + } finally { + if (!annotationType.tsym.type.hasTag(TypeTag.ERROR)) { + //if the annotation type does not exists + //throw away warnings reported while de-proxying the annotation, + //as the annotation's library is probably missing from the classpath: + deferred.reportDeferredDiagnostics(); + } + log.popDiagnosticHandler(deferred); } - return new Attribute.Compound(annotationType, buf.toList()); } MethodSymbol findAccessMethod(Type container, Name name) { @@ -2146,15 +2157,21 @@ public class ClassReader { failure = ex; } if (enumerator == null) { - if (failure != null) { - log.warning(Warnings.UnknownEnumConstantReason(currentClassFile, - enumTypeSym, - proxy.enumerator, - failure.getDiagnostic())); - } else { - log.warning(Warnings.UnknownEnumConstant(currentClassFile, - enumTypeSym, - proxy.enumerator)); + // The enumerator wasn't found: emit a warning and recover + JavaFileObject prevSource = log.useSource(requestingOwner.classfile); + try { + if (failure != null) { + log.warning(LintWarnings.UnknownEnumConstantReason(currentClassFile, + enumTypeSym, + proxy.enumerator, + failure.getDiagnostic())); + } else { + log.warning(LintWarnings.UnknownEnumConstant(currentClassFile, + enumTypeSym, + proxy.enumerator)); + } + } finally { + log.useSource(prevSource); } result = new Attribute.Enum(enumTypeSym.type, new VarSymbol(0, proxy.enumerator, syms.botType, enumTypeSym)); @@ -2668,6 +2685,7 @@ public class ClassReader { // won't pass the "hasOuterInstance" check above, but those that don't have an // enclosing method (i.e. from initializers) will pass that check. boolean local = forceLocal = + currentOwner.owner.kind != TYP || !currentOwner.owner.members().includes(currentOwner, LookupKind.NON_RECURSIVE); if (!currentOwner.name.isEmpty() && !local) type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()), @@ -3019,7 +3037,9 @@ public class ClassReader { * `typevars'. */ protected void enterTypevars(Symbol sym, Type t) { - if (t.getEnclosingType() != null) { + if (sym.owner.kind == MTH) { + enterTypevars(sym.owner, sym.owner.type); + } else if (t.getEnclosingType() != null) { if (!t.getEnclosingType().hasTag(TypeTag.NONE)) { enterTypevars(sym.owner, t.getEnclosingType()); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java index af7d79d4195..e8ab1b9349c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -181,17 +181,17 @@ public final class SourceLauncher { ProgramDescriptor program = context.getProgramDescriptor(); // 1. Find a main method in the first class and if there is one - invoke it - Class firstClass; + Class mainClass; String firstClassName = program.qualifiedTypeNames().getFirst(); ClassLoader loader = context.newClassLoaderFor(parentLoader, firstClassName); Thread.currentThread().setContextClassLoader(loader); try { - firstClass = Class.forName(firstClassName, false, loader); + mainClass = Class.forName(firstClassName, false, loader); } catch (ClassNotFoundException e) { throw new Fault(Errors.CantFindClass(firstClassName)); } - Method mainMethod = MethodFinder.findMainMethod(firstClass); + Method mainMethod = MethodFinder.findMainMethod(mainClass); if (mainMethod == null) { // 2. If the first class doesn't have a main method, look for a class with a matching name var compilationUnitName = program.fileObject().getFile().getFileName().toString(); @@ -206,22 +206,18 @@ public final class SourceLauncher { .findFirst() .orElseThrow(() -> new Fault(Errors.CantFindClass(expectedName))); - Class actualClass; try { - actualClass = Class.forName(actualName, false, firstClass.getClassLoader()); + mainClass = Class.forName(actualName, false, mainClass.getClassLoader()); } catch (ClassNotFoundException ignore) { throw new Fault(Errors.CantFindClass(actualName)); } - mainMethod = MethodFinder.findMainMethod(actualClass); + mainMethod = MethodFinder.findMainMethod(mainClass); if (mainMethod == null) { throw new Fault(Errors.CantFindMainMethod(actualName)); } } - // selected main method instance points back to its declaring class - Class mainClass = mainMethod.getDeclaringClass(); String mainClassName = mainClass.getName(); - var isStatic = Modifier.isStatic(mainMethod.getModifiers()); Object instance = null; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 94292d9a348..269d2f5de62 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -823,9 +823,9 @@ public class JavaCompiler { c, () -> diagFactory.fragment(Fragments.UserSelectedCompletionFailure), dcfh); } JavaFileObject filename = c.classfile; - JavaFileObject prev = log.useSource(filename); if (tree == null) { + JavaFileObject prev = log.useSource(filename); try { tree = parse(filename, filename.getCharContent(false)); } catch (IOException e) { 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 e78537c10f5..df5da5cb954 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -977,13 +977,11 @@ public class JavacParser implements Parser { pattern = toP(F.at(token.pos).AnyPattern()); } else { - int varTypePos = Position.NOPOS; if (parsedType == null) { boolean var = token.kind == IDENTIFIER && token.name() == names.var; e = unannotatedType(allowVar, TYPE | NOLAMBDA); if (var) { - varTypePos = e.pos; - e = null; + e = replaceTypeWithVar(e); } } else { e = parsedType; @@ -1021,12 +1019,9 @@ public class JavacParser implements Parser { name = names.empty; } JCVariableDecl var = toP(F.at(varPos).VarDef(mods, name, e, null, - varTypePos != Position.NOPOS ? JCVariableDecl.DeclKind.VAR : JCVariableDecl.DeclKind.EXPLICIT, - varTypePos)); - if (e == null) { - if (var.name == names.underscore && !allowVar) { - log.error(DiagnosticFlag.SYNTAX, varPos, Errors.UseOfUnderscoreNotAllowed); - } + e.hasTag(VARTYPE) ? JCVariableDecl.DeclKind.VAR : JCVariableDecl.DeclKind.EXPLICIT)); + if (var.name == names.underscore && !allowVar) { + log.error(DiagnosticFlag.SYNTAX, varPos, Errors.UseOfUnderscoreNotAllowed); } pattern = toP(F.at(pos).BindingPattern(var)); } @@ -2178,8 +2173,7 @@ public class JavacParser implements Parser { && restrictedTypeName(param.vartype, true) != null) { checkSourceLevel(param.pos, Feature.VAR_SYNTAX_IMPLICIT_LAMBDAS); param.declKind = JCVariableDecl.DeclKind.VAR; - param.typePos = TreeInfo.getStartPos(param.vartype); - param.vartype = null; + param.vartype = replaceTypeWithVar(param.vartype); } } } @@ -3792,7 +3786,6 @@ public class JavacParser implements Parser { */ JCVariableDecl variableDeclaratorRest(int pos, JCModifiers mods, JCExpression type, Name name, boolean reqInit, Comment dc, boolean localDecl, boolean compound) { - boolean declaredUsingVar = false; JCExpression init = null; type = bracketsOpt(type); @@ -3818,7 +3811,6 @@ public class JavacParser implements Parser { syntaxError(token.pos, Errors.Expected(EQ)); } - int varTypePos = Position.NOPOS; JCTree elemType = TreeInfo.innermostType(type, true); if (elemType.hasTag(IDENT)) { Name typeName = ((JCIdent) elemType).name; @@ -3829,21 +3821,27 @@ public class JavacParser implements Parser { //error - 'var' and arrays reportSyntaxError(elemType.pos, Errors.RestrictedTypeNotAllowedArray(typeName)); } else { - declaredUsingVar = true; - varTypePos = elemType.pos; + type = replaceTypeWithVar(type); + if (compound) //error - 'var' in compound local var decl reportSyntaxError(elemType.pos, Errors.RestrictedTypeNotAllowedCompound(typeName)); - //implicit type - type = null; } } } JCVariableDecl result = toP(F.at(pos).VarDef(mods, name, type, init, - declaredUsingVar ? JCVariableDecl.DeclKind.VAR : JCVariableDecl.DeclKind.EXPLICIT, varTypePos)); + type.hasTag(VARTYPE) ? JCVariableDecl.DeclKind.VAR : JCVariableDecl.DeclKind.EXPLICIT)); return attach(result, dc); } + JCExpression replaceTypeWithVar(JCExpression type) { + JCVarType varType = F.at(type).VarType(); + + varType.endpos = type.endpos; + + return varType; + } + Name restrictedTypeName(JCExpression e, boolean shouldWarn) { switch (e.getTag()) { case IDENT: @@ -3902,7 +3900,7 @@ public class JavacParser implements Parser { if (allowThisIdent || !lambdaParameter || LAX_IDENTIFIER.test(token.kind) || - mods.flags != Flags.PARAMETER || + (mods.flags & ~(Flags.PARAMETER | Flags.LAMBDA_PARAMETER)) != 0 || mods.annotations.nonEmpty()) { JCExpression pn; if (token.kind == UNDERSCORE && (catchParameter || lambdaParameter)) { @@ -3954,11 +3952,10 @@ public class JavacParser implements Parser { name = names.empty; } - boolean declaredUsingVar = type != null && type.hasTag(IDENT) && ((JCIdent)type).name == names.var; + boolean declaredUsingVar = type != null && type.hasTag(VARTYPE); JCVariableDecl.DeclKind declKind = declaredUsingVar ? JCVariableDecl.DeclKind.VAR : type != null ? JCVariableDecl.DeclKind.EXPLICIT : JCVariableDecl.DeclKind.IMPLICIT; - int typePos = type != null ? type.pos : pos; - return toP(F.at(pos).VarDef(mods, name, type, null, declKind, typePos)); + return toP(F.at(pos).VarDef(mods, name, type, null, declKind)); } /** Resources = Resource { ";" Resources } @@ -4424,12 +4421,13 @@ public class JavacParser implements Parser { JCMethodDecl methDef = (JCMethodDecl) def; if (methDef.name == names.init && methDef.params.isEmpty() && (methDef.mods.flags & Flags.COMPACT_RECORD_CONSTRUCTOR) != 0) { ListBuffer tmpParams = new ListBuffer<>(); + TreeCopier copier = new TreeCopier<>(F); for (JCVariableDecl param : headerFields) { tmpParams.add(F.at(param) // we will get flags plus annotations from the record component .VarDef(F.Modifiers(Flags.PARAMETER | Flags.GENERATED_MEMBER | Flags.MANDATED | param.mods.flags & Flags.VARARGS, - param.mods.annotations), - param.name, param.vartype, null)); + copier.copy(param.mods.annotations)), + param.name, copier.copy(param.vartype), null)); } methDef.params = tmpParams.toList(); } @@ -5405,7 +5403,19 @@ public class JavacParser implements Parser { * LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter */ protected JCVariableDecl formalParameter(boolean lambdaParameter, boolean recordComponent) { - JCModifiers mods = !recordComponent ? optFinal(Flags.PARAMETER) : modifiersOpt(); + JCModifiers mods; + + if (recordComponent) { + mods = modifiersOpt(); + /* it could be that the user added a javadoc with the @deprecated tag, when analyzing this + * javadoc, javac will set the DEPRECATED flag. This is correct in most cases but not for + * record components and thus should be removed in that case. Any javadoc applied to + * record components is ignored + */ + mods.flags &= ~Flags.DEPRECATED; + } else { + mods = optFinal(Flags.PARAMETER | (lambdaParameter ? Flags.LAMBDA_PARAMETER : 0)); + } if (recordComponent && mods.flags != 0) { log.error(mods.pos, Errors.RecordCantDeclareFieldModifiers); } @@ -5436,7 +5446,7 @@ public class JavacParser implements Parser { } protected JCVariableDecl implicitParameter() { - JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER); + JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER | Flags.LAMBDA_PARAMETER); return variableDeclaratorId(mods, null, false, true, false); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 915d7f8a8d8..58a5333ce4c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2521,10 +2521,12 @@ compiler.err.cant.attach.type.annotations=\ {3} # 0: file object, 1: symbol, 2: name +# lint: classfile compiler.warn.unknown.enum.constant=\ unknown enum constant {1}.{2} # 0: file object, 1: symbol, 2: name, 3: message segment +# lint: classfile compiler.warn.unknown.enum.constant.reason=\ unknown enum constant {1}.{2}\n\ reason: {3} diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java index e0a99a6f103..f0a8b6034df 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -277,6 +277,10 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { */ TYPEIDENT, + /** 'var' type. + */ + VARTYPE, + /** Array types, of type TypeArray. */ TYPEARRAY, @@ -1012,9 +1016,16 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public static class JCVariableDecl extends JCStatement implements VariableTree { public enum DeclKind { - EXPLICIT, // "SomeType name" - IMPLICIT, // "name" - VAR, // "var name" + EXPLICIT(0), // "SomeType name" + IMPLICIT(Flags.VAR_VARIABLE), // "name" + VAR(Flags.VAR_VARIABLE), // "var name" + ; + + public final long additionalSymbolFlags; + + private DeclKind(long additionalSymbolFlags) { + this.additionalSymbolFlags = additionalSymbolFlags; + } } /** variable modifiers */ @@ -1031,15 +1042,13 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public VarSymbol sym; /** how the variable's type was declared */ public DeclKind declKind; - /** a source code position to use for "vartype" when null (can happen if declKind != EXPLICIT) */ - public int typePos; protected JCVariableDecl(JCModifiers mods, Name name, JCExpression vartype, JCExpression init, VarSymbol sym) { - this(mods, name, vartype, init, sym, DeclKind.EXPLICIT, Position.NOPOS); + this(mods, name, vartype, init, sym, DeclKind.EXPLICIT); } protected JCVariableDecl(JCModifiers mods, @@ -1047,21 +1056,19 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { JCExpression vartype, JCExpression init, VarSymbol sym, - DeclKind declKind, - int typePos) { + DeclKind declKind) { this.mods = mods; this.name = name; this.vartype = vartype; this.init = init; this.sym = sym; this.declKind = declKind; - this.typePos = typePos; } protected JCVariableDecl(JCModifiers mods, JCExpression nameexpr, JCExpression vartype) { - this(mods, null, vartype, null, null, DeclKind.EXPLICIT, Position.NOPOS); + this(mods, null, vartype, null, null, DeclKind.EXPLICIT); this.nameexpr = nameexpr; if (nameexpr.hasTag(Tag.IDENT)) { this.name = ((JCIdent)nameexpr).name; @@ -1071,8 +1078,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { } } + @DefinedBy(Api.COMPILER_TREE) public boolean isImplicitlyTyped() { - return vartype == null; + return declKind != DeclKind.EXPLICIT; } public boolean declaredUsingVar() { @@ -2040,7 +2048,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { this.params = params; this.body = body; if (params.isEmpty() || - params.head.vartype != null) { + !params.head.isImplicitlyTyped()) { paramKind = ParameterKind.EXPLICIT; } else { paramKind = ParameterKind.IMPLICIT; @@ -2820,6 +2828,24 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { } } + public static class JCVarType extends JCExpression implements VarTypeTree { + public JCVarType() {} + @Override + public void accept(Visitor v) { v.visitVarType(this); } + + @DefinedBy(Api.COMPILER_TREE) + public Kind getKind() { return Kind.VAR_TYPE; } + + @Override @DefinedBy(Api.COMPILER_TREE) + public R accept(TreeVisitor v, D d) { + return v.visitVarType(this, d); + } + @Override + public Tag getTag() { + return VARTYPE; + } + } + /** * An array type, A[] */ @@ -3597,6 +3623,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public void visitIdent(JCIdent that) { visitTree(that); } public void visitLiteral(JCLiteral that) { visitTree(that); } public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); } + public void visitVarType(JCVarType that) { visitTree(that); } public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); } public void visitTypeApply(JCTypeApply that) { visitTree(that); } public void visitTypeUnion(JCTypeUnion that) { visitTree(that); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java index d953663a6d7..c22dfd61637 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java @@ -1529,6 +1529,15 @@ public class Pretty extends JCTree.Visitor { } } + @Override + public void visitVarType(JCVarType that) { + try { + print("var"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + public void visitTypeArray(JCArrayTypeTree tree) { try { printBaseElementType(tree); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java index 9efc6a9d895..95e2976f14e 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java @@ -480,6 +480,12 @@ public class TreeCopier

    implements TreeVisitor { return M.at(t.pos).TypeIdent(t.typetag); } + @DefinedBy(Api.COMPILER_TREE) + public JCTree visitVarType(VarTypeTree node, P p) { + JCVarType t = (JCVarType) node; + return M.at(t.pos).VarType(); + } + @DefinedBy(Api.COMPILER_TREE) public JCTree visitTypeParameter(TypeParameterTree node, P p) { JCTypeParameter t = (JCTypeParameter) node; @@ -551,7 +557,7 @@ public class TreeCopier

    implements TreeVisitor { JCExpression vartype = copy(t.vartype, p); if (t.nameexpr == null) { JCExpression init = copy(t.init, p); - return M.at(t.pos).VarDef(mods, t.name, vartype, init, t.declKind, t.typePos); + return M.at(t.pos).VarDef(mods, t.name, vartype, init, t.declKind); } else { JCExpression nameexpr = copy(t.nameexpr, p); return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java index aa616f3f580..ffb259c6a8b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -621,8 +621,6 @@ public class TreeInfo { return node.mods.pos; } else if (node.vartype != null) { return getStartPos(node.vartype); - } else if (node.typePos != Position.NOPOS) { - return node.typePos; } break; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java index 0e71df99bdc..77391493ad2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -238,8 +238,8 @@ public class TreeMaker implements JCTree.Factory { } public JCVariableDecl VarDef(JCModifiers mods, Name name, JCExpression vartype, JCExpression init, - JCVariableDecl.DeclKind declKind, int typePos) { - JCVariableDecl tree = new JCVariableDecl(mods, name, vartype, init, null, declKind, typePos); + JCVariableDecl.DeclKind declKind) { + JCVariableDecl tree = new JCVariableDecl(mods, name, vartype, init, null, declKind); tree.pos = pos; return tree; } @@ -566,6 +566,12 @@ public class TreeMaker implements JCTree.Factory { return tree; } + public JCVarType VarType() { + JCVarType tree = new JCVarType(); + tree.pos = pos; + return tree; + } + public JCArrayTypeTree TypeArray(JCExpression elemtype) { JCArrayTypeTree tree = new JCArrayTypeTree(elemtype); tree.pos = pos; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java index b9ae35da9df..0d1216217c8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java @@ -361,6 +361,9 @@ public class TreeScanner extends Visitor { public void visitTypeIdent(JCPrimitiveTypeTree tree) { } + public void visitVarType(JCVarType tree) { + } + public void visitTypeArray(JCArrayTypeTree tree) { scan(tree.elemtype); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java index 63778fb42ff..5b06e76bf33 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java @@ -418,6 +418,10 @@ public class TreeTranslator extends JCTree.Visitor { result = tree; } + public void visitVarType(JCVarType tree) { + result = tree; + } + public void visitTypeArray(JCArrayTypeTree tree) { tree.elemtype = translate(tree.elemtype); result = tree; diff --git a/src/jdk.hotspot.agent/doc/clhsdb.html b/src/jdk.hotspot.agent/doc/clhsdb.html index bd436f1dfef..cfe6453b736 100644 --- a/src/jdk.hotspot.agent/doc/clhsdb.html +++ b/src/jdk.hotspot.agent/doc/clhsdb.html @@ -57,7 +57,6 @@ Available commands: pmap show Solaris pmap-like output print expression print given Klass*, Method* or arbitrary address printas type expression print given address as given HotSpot type. eg. print JavaThread <address> - printmdo -a | expression print method data oop printstatics [ type ] print static fields of given HotSpot type (or all types if none specified) pstack [-v] [-l] show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode. -l includes info on owned java.util.concurrent locks. quit quit CLHSDB tool diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/DwarfParser.cpp b/src/jdk.hotspot.agent/linux/native/libsaproc/DwarfParser.cpp index 6c94992e1e2..62dbc84f88c 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/DwarfParser.cpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/DwarfParser.cpp @@ -205,7 +205,7 @@ extern "C" JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_linux_amd64_DwarfParser_getReturnAddressOffsetFromCFA (JNIEnv *env, jobject this_obj) { DwarfParser *parser = reinterpret_cast(get_dwarf_context(env, this_obj)); - return parser->get_ra_cfa_offset(); + return parser->get_offset_from_cfa(RA); } /* @@ -217,5 +217,5 @@ extern "C" JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_linux_amd64_DwarfParser_getBasePointerOffsetFromCFA (JNIEnv *env, jobject this_obj) { DwarfParser *parser = reinterpret_cast(get_dwarf_context(env, this_obj)); - return parser->get_bp_cfa_offset(); + return parser->get_offset_from_cfa(RBP); } diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp b/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp index 2636bdf691a..459e3cc57e9 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp @@ -24,10 +24,32 @@ */ #include +#include #include "dwarf.hpp" #include "libproc_impl.h" +DwarfParser::DwarfParser(lib_info *lib) : _lib(lib), + _buf(NULL), + _encoding(0), + _code_factor(0), + _data_factor(0), + _current_pc(0L) { + init_state(_initial_state); + init_state(_state); +} + +void DwarfParser::init_state(struct DwarfState& st) { + st.cfa_reg = MAX_VALUE; + st.return_address_reg = MAX_VALUE; + st.cfa_offset = 0; + + st.offset_from_cfa.clear(); + for (int reg = 0; reg < MAX_VALUE; reg++) { + st.offset_from_cfa[static_cast(reg)] = INT_MAX; + } +} + /* from read_leb128() in dwarf.c in binutils */ uintptr_t DwarfParser::read_leb(bool sign) { uintptr_t result = 0L; @@ -82,7 +104,7 @@ bool DwarfParser::process_cie(unsigned char *start_of_entry, uint32_t id) { _code_factor = read_leb(false); _data_factor = static_cast(read_leb(true)); - _return_address_reg = static_cast(*_buf++); + enum DWARF_Register initial_ra = static_cast(*_buf++); if (strpbrk(augmentation_string, "LP") != NULL) { // Language personality routine (P) and Language Specific Data Area (LSDA:L) @@ -99,14 +121,12 @@ bool DwarfParser::process_cie(unsigned char *start_of_entry, uint32_t id) { // Clear state _current_pc = 0L; - _cfa_reg = MAX_VALUE; - _return_address_reg = RA; - _cfa_offset = 0; - _ra_cfa_offset = 8; - _bp_cfa_offset = INT_MAX; + init_state(_state); + _state.return_address_reg = initial_ra; parse_dwarf_instructions(0L, static_cast(-1L), end); + _initial_state = _state; _buf = orig_pos; return true; } @@ -114,12 +134,7 @@ bool DwarfParser::process_cie(unsigned char *start_of_entry, uint32_t id) { void DwarfParser::parse_dwarf_instructions(uintptr_t begin, uintptr_t pc, const unsigned char *end) { uintptr_t operand1; _current_pc = begin; - - /* for remember state */ - enum DWARF_Register rem_cfa_reg = MAX_VALUE; - int rem_cfa_offset = 0; - int rem_ra_cfa_offset = 8; - int rem_bp_cfa_offset = INT_MAX; + std::stack remember_state; while ((_buf < end) && (_current_pc < pc)) { unsigned char op = *_buf++; @@ -138,21 +153,17 @@ void DwarfParser::parse_dwarf_instructions(uintptr_t begin, uintptr_t pc, const } break; case 0x0c: // DW_CFA_def_cfa - _cfa_reg = static_cast(read_leb(false)); - _cfa_offset = read_leb(false); + _state.cfa_reg = static_cast(read_leb(false)); + _state.cfa_offset = read_leb(false); break; case 0x80: {// DW_CFA_offset operand1 = read_leb(false); enum DWARF_Register reg = static_cast(opa); - if (reg == RBP) { - _bp_cfa_offset = operand1 * _data_factor; - } else if (reg == RA) { - _ra_cfa_offset = operand1 * _data_factor; - } + _state.offset_from_cfa[reg] = operand1 * _data_factor; break; } case 0xe: // DW_CFA_def_cfa_offset - _cfa_offset = read_leb(false); + _state.cfa_offset = read_leb(false); break; case 0x40: // DW_CFA_advance_loc if (_current_pc != 0L) { @@ -184,28 +195,28 @@ void DwarfParser::parse_dwarf_instructions(uintptr_t begin, uintptr_t pc, const } case 0x07: { // DW_CFA_undefined enum DWARF_Register reg = static_cast(read_leb(false)); - // We are only interested in BP here because CFA and RA should not be undefined. - if (reg == RBP) { - _bp_cfa_offset = INT_MAX; - } + _state.offset_from_cfa[reg] = INT_MAX; break; } - case 0x0d: {// DW_CFA_def_cfa_register - _cfa_reg = static_cast(read_leb(false)); + case 0x0d: // DW_CFA_def_cfa_register + _state.cfa_reg = static_cast(read_leb(false)); break; - } case 0x0a: // DW_CFA_remember_state - rem_cfa_reg = _cfa_reg; - rem_cfa_offset = _cfa_offset; - rem_ra_cfa_offset = _ra_cfa_offset; - rem_bp_cfa_offset = _bp_cfa_offset; + remember_state.push(_state); break; case 0x0b: // DW_CFA_restore_state - _cfa_reg = rem_cfa_reg; - _cfa_offset = rem_cfa_offset; - _ra_cfa_offset = rem_ra_cfa_offset; - _bp_cfa_offset = rem_bp_cfa_offset; + if (remember_state.empty()) { + print_debug("DWARF Error: DW_CFA_restore_state with empty stack.\n"); + return; + } + _state = remember_state.top(); + remember_state.pop(); break; + case 0xc0: {// DW_CFA_restore + enum DWARF_Register reg = static_cast(opa); + _state.offset_from_cfa[reg] = _initial_state.offset_from_cfa[reg]; + break; + } default: print_debug("DWARF: Unknown opcode: 0x%x\n", op); return; diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.hpp b/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.hpp index a2692738ce1..0a38c9a0f2e 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.hpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.hpp @@ -26,6 +26,8 @@ #ifndef _DWARF_HPP_ #define _DWARF_HPP_ +#include + #include "libproc_impl.h" /* @@ -55,6 +57,13 @@ enum DWARF_Register { MAX_VALUE }; +struct DwarfState { + enum DWARF_Register cfa_reg; + enum DWARF_Register return_address_reg; + int cfa_offset; + std::map offset_from_cfa; +}; + /* * DwarfParser finds out CFA (Canonical Frame Address) from DWARF in ELF binary. * Also Return Address (RA) and Base Pointer (BP) are calculated from CFA. @@ -64,16 +73,14 @@ class DwarfParser { const lib_info *_lib; unsigned char *_buf; unsigned char _encoding; - enum DWARF_Register _cfa_reg; - enum DWARF_Register _return_address_reg; unsigned int _code_factor; int _data_factor; uintptr_t _current_pc; - int _cfa_offset; - int _ra_cfa_offset; - int _bp_cfa_offset; + struct DwarfState _initial_state; + struct DwarfState _state; + void init_state(struct DwarfState& st); uintptr_t read_leb(bool sign); uint64_t get_entry_length(); bool process_cie(unsigned char *start_of_entry, uint32_t id); @@ -82,24 +89,12 @@ class DwarfParser { unsigned int get_pc_range(); public: - DwarfParser(lib_info *lib) : _lib(lib), - _buf(NULL), - _encoding(0), - _cfa_reg(MAX_VALUE), - _return_address_reg(RA), - _code_factor(0), - _data_factor(0), - _current_pc(0L), - _cfa_offset(0), - _ra_cfa_offset(8), - _bp_cfa_offset(INT_MAX) {}; - + DwarfParser(lib_info *lib); ~DwarfParser() {} bool process_dwarf(const uintptr_t pc); - enum DWARF_Register get_cfa_register() { return _cfa_reg; } - int get_cfa_offset() { return _cfa_offset; } - int get_ra_cfa_offset() { return _ra_cfa_offset; } - int get_bp_cfa_offset() { return _bp_cfa_offset; } + enum DWARF_Register get_cfa_register() { return _state.cfa_reg; } + int get_cfa_offset() { return _state.cfa_offset; } + int get_offset_from_cfa(enum DWARF_Register reg) { return _state.offset_from_cfa[reg]; } bool is_in(long pc) { return (_lib->exec_start <= pc) && (pc < _lib->exec_end); diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c index e2681be73fe..029aac1f107 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c @@ -182,13 +182,14 @@ static bool fill_addr_info(lib_info* lib) { return false; } + long page_size = sysconf(_SC_PAGE_SIZE); lib->end = (uintptr_t)-1L; lib->exec_start = (uintptr_t)-1L; lib->exec_end = (uintptr_t)-1L; for (ph = phbuf, cnt = 0; cnt < ehdr.e_phnum; cnt++, ph++) { if (ph->p_type == PT_LOAD) { uintptr_t aligned_start = lib->base + align_down(ph->p_vaddr, ph->p_align); - uintptr_t aligned_end = aligned_start + align_up(ph->p_memsz, ph->p_align); + uintptr_t aligned_end = aligned_start + align_up(ph->p_memsz, page_size); if ((lib->end == (uintptr_t)-1L) || (lib->end < aligned_end)) { lib->end = aligned_end; } diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h index 262e99f4a64..62b1b4d0d6b 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.h @@ -96,7 +96,7 @@ struct core_data { int classes_jsa_fd; // file descriptor of class share archive uintptr_t dynamic_addr; // address of dynamic section of a.out uintptr_t vdso_addr; // address of vDSO - off64_t vdso_offset; // offset of vDSO in core + off_t vdso_offset; // offset of vDSO in core size_t vdso_size; // size of vDSO uintptr_t ld_base_addr; // base address of ld.so size_t num_maps; // number of maps. diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c index 6a991b18c10..6298f569aaf 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c @@ -635,8 +635,8 @@ static int handle_vdso(struct ps_prochandle* ph, char* lib_name, size_t lib_name lib_fd = -1; } else { lib_fd = fileno(tmpf); - off64_t ofs = ph->core->vdso_offset; - if (sendfile64(lib_fd, ph->core->core_fd, &ofs, ph->core->vdso_size) == -1) { + off_t ofs = ph->core->vdso_offset; + if (sendfile(lib_fd, ph->core->core_fd, &ofs, ph->core->vdso_size) == -1) { print_debug("can't copy vDSO (%d)\n", errno); fclose(tmpf); lib_fd = -1; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java index 01b9a4a447e..74335f78888 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +60,6 @@ import sun.jvm.hotspot.oops.InstanceKlass; import sun.jvm.hotspot.oops.Klass; import sun.jvm.hotspot.oops.Metadata; import sun.jvm.hotspot.oops.Method; -import sun.jvm.hotspot.oops.MethodData; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.oops.RawHeapVisitor; import sun.jvm.hotspot.oops.Symbol; @@ -860,44 +859,8 @@ public class CommandProcessor { } } }, - new Command("printmdo", "printmdo [ -a | expression ]", false) { - // Print every MDO in the heap or the one referenced by expression. - public void doit(Tokens t) { - if (t.countTokens() != 1) { - usage(); - } else { - String s = t.nextToken(); - if (s.equals("-a")) { - ClassLoaderDataGraph cldg = VM.getVM().getClassLoaderDataGraph(); - cldg.classesDo(new ClassLoaderDataGraph.ClassVisitor() { - public void visit(Klass k) { - if (k instanceof InstanceKlass) { - MethodArray methods = ((InstanceKlass)k).getMethods(); - for (int i = 0; i < methods.length(); i++) { - Method m = methods.at(i); - MethodData mdo = m.getMethodData(); - if (mdo != null) { - out.println("MethodData " + mdo.getAddress() + " for " + - "method " + m.getMethodHolder().getName().asString() + "." + - m.getName().asString() + - m.getSignature().asString() + "@" + m.getAddress()); - mdo.printDataOn(out); - } - } - } - } - } - ); - } else { - Address a = VM.getVM().getDebugger().parseAddress(s); - MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a); - mdo.printDataOn(out); - } - } - } - }, new Command("printall", "printall", false) { - // Print every MDO in the heap or the one referenced by expression. + // Print every Method for every class loaded. public void doit(Tokens t) { if (t.countTokens() != 0) { usage(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java index 44b407edaca..7ce46799495 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/classfile/ClassLoaderData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -44,12 +44,14 @@ public class ClassLoaderData extends VMObject { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ClassLoaderData"); classLoaderFieldOffset = type.getAddressField("_class_loader").getOffset(); + theNullClassLoaderDataField = type.getAddressField("_the_null_class_loader_data"); nextField = type.getAddressField("_next"); klassesField = new MetadataField(type.getAddressField("_klasses"), 0); hasClassMirrorHolderField = new CIntField(type.getCIntegerField("_has_class_mirror_holder"), 0); } private static long classLoaderFieldOffset; + private static AddressField theNullClassLoaderDataField; private static AddressField nextField; private static MetadataField klassesField; private static CIntField hasClassMirrorHolderField; @@ -75,6 +77,10 @@ public class ClassLoaderData extends VMObject { return hasClassMirrorHolderField.getValue(this) != 0; } + public static ClassLoaderData theNullClassLoaderData() { + return instantiateWrapperFor(theNullClassLoaderDataField.getValue()); + } + public ClassLoaderData next() { return instantiateWrapperFor(nextField.getValue(getAddress())); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java index 14d8af58e4d..12b614e7fa8 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java @@ -41,6 +41,7 @@ public class FileMapInfo { private static Address rwRegionEndAddress; private static Address vtablesIndex; private static Address mapped_base_address; + private static long metadataOffsetShift; // HashMap created by mapping the vTable addresses in the rw region with // the corresponding metadata type. @@ -97,12 +98,15 @@ public class FileMapInfo { headerObj = VMObjectFactory.newObject(FileMapHeader.class, header); // char* mapped_base_address = header->_mapped_base_address - // narrowPtr cloned_vtable_narrowPtr = header->_cloned_vtable_offset + // narrowPtr cloned_vtable_narrowPtr = header->_cloned_vtables // size_t cloned_vtable_offset = AOTCompressedPointers::get_byte_offset(cloned_vtable_narrowPtr); // CppVtableInfo** vtablesIndex = mapped_base_address + cloned_vtable_offset; mapped_base_address = get_AddressField(FileMapHeader_type, header, "_mapped_base_address"); long cloned_vtable_narrowPtr = get_CIntegerField(FileMapHeader_type, header, "_cloned_vtables"); - long cloned_vtable_offset = cloned_vtable_narrowPtr; // Currently narrowPtr is the same as offset + // narrowPtr stores scaled offset units (byte_offset >> MetadataOffsetShift). + // Apply the left shift to convert back to byte offset. + metadataOffsetShift = db.lookupIntConstant("AOTCompressedPointers::MetadataOffsetShift").longValue(); + long cloned_vtable_offset = cloned_vtable_narrowPtr << metadataOffsetShift; vtablesIndex = mapped_base_address.addOffsetTo(cloned_vtable_offset); // CDSFileMapRegion* rw_region = &header->_region[rw]; @@ -176,9 +180,9 @@ public class FileMapInfo { // vtablesIndex points to to an array like this: // long info[] = { - // offset of the CppVtableInfo for ConstantPool, - // offset of the CppVtableInfo for InstanceKlass, - // offset of the CppVtableInfo for InstanceClassLoaderKlass, + // narrowPtr of the CppVtableInfo for ConstantPool, + // narrowPtr of the CppVtableInfo for InstanceKlass, + // narrowPtr of the CppVtableInfo for InstanceClassLoaderKlass, // ... // }; // @@ -189,8 +193,8 @@ public class FileMapInfo { // }; // // The loop below computes the following - // CppVtableInfo* t_ConstantPool = mapped_base_address + info[0]; - // CppVtableInfo* t_InstanceKlass = mapped_base_address + info[1]; + // CppVtableInfo* t_ConstantPool = mapped_base_address + (info[0] << metadataOffsetShift); + // CppVtableInfo* t_InstanceKlass = mapped_base_address + (info[1] << metadataOffsetShift); // ... // // If we have the following objects @@ -203,21 +207,21 @@ public class FileMapInfo { // // To get an idea what these address look like, do this: // - // $ java -Xlog:cds+vtables=debug -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=0 --version - // [0.002s][debug][cds,vtables] Copying 14 vtable entries for ConstantPool to 0x800000018 - // [0.002s][debug][cds,vtables] Copying 41 vtable entries for InstanceKlass to 0x800000090 - // [0.002s][debug][cds,vtables] Copying 41 vtable entries for InstanceClassLoaderKlass to 0x8000001e0 - // [0.002s][debug][cds,vtables] Copying 41 vtable entries for InstanceMirrorKlass to 0x800000330 - // [0.002s][debug][cds,vtables] Copying 41 vtable entries for InstanceRefKlass to 0x800000480 - // [0.002s][debug][cds,vtables] Copying 41 vtable entries for InstanceStackChunkKlass to 0x8000005d0 - // [0.002s][debug][cds,vtables] Copying 14 vtable entries for Method to 0x800000720 - // [0.002s][debug][cds,vtables] Copying 42 vtable entries for ObjArrayKlass to 0x800000798 - // [0.002s][debug][cds,vtables] Copying 42 vtable entries for TypeArrayKlass to 0x8000008f0 - // java 23-internal 2024-09-17 + // $ java -Xlog:aot+vtables=debug -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=0 --version + // [0.002s][debug][aot,vtables] Copying 14 vtable entries for ConstantPool to 0x800000018 + // [0.002s][debug][aot,vtables] Copying 41 vtable entries for InstanceKlass to 0x800000090 + // [0.002s][debug][aot,vtables] Copying 41 vtable entries for InstanceClassLoaderKlass to 0x8000001e0 + // [0.002s][debug][aot,vtables] Copying 41 vtable entries for InstanceMirrorKlass to 0x800000330 + // [0.002s][debug][aot,vtables] Copying 41 vtable entries for InstanceRefKlass to 0x800000480 + // [0.002s][debug][aot,vtables] Copying 41 vtable entries for InstanceStackChunkKlass to 0x8000005d0 + // [0.002s][debug][aot,vtables] Copying 14 vtable entries for Method to 0x800000720 + // [0.002s][debug][aot,vtables] Copying 42 vtable entries for ObjArrayKlass to 0x800000798 + // [0.002s][debug][aot,vtables] Copying 42 vtable entries for TypeArrayKlass to 0x8000008f0 // ... for (int i=0; i < metadataTypeArray.length; i++) { - long vtable_offset = vtablesIndex.getJLongAt(i * addressSize); // long offset = _index[i] + long narrowPtr = vtablesIndex.getJLongAt(i * addressSize); + long vtable_offset = narrowPtr << metadataOffsetShift; // CppVtableInfo* t = the address of the CppVtableInfo for the i-th table Address vtableInfoAddress = mapped_base_address.addOffsetTo(vtable_offset); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java index c4eeaf4a367..61067e63707 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,10 +83,8 @@ public class Array extends Oop { } if (VM.getVM().isCompactObjectHeadersEnabled()) { lengthOffsetInBytes = Oop.getHeaderSize(); - } else if (VM.getVM().isCompressedKlassPointersEnabled()) { - lengthOffsetInBytes = typeSize - VM.getVM().getIntSize(); } else { - lengthOffsetInBytes = typeSize; + lengthOffsetInBytes = typeSize - VM.getVM().getIntSize(); } return lengthOffsetInBytes; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayData.java deleted file mode 100644 index 0eaa3faa74a..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArrayData.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// ArrayData -// -// A ArrayData is a base class for accessing profiling data which does -// not have a statically known size. It consists of an array length -// and an array start. -abstract class ArrayData extends ProfileData { - - static final int arrayLenOffSet = 0; - static final int arrayStartOffSet = 1; - - int arrayUintAt(int index) { - int aindex = index + arrayStartOffSet; - return uintAt(aindex); - } - int arrayIntAt(int index) { - int aindex = index + arrayStartOffSet; - return intAt(aindex); - } - - // Code generation support for subclasses. - static int arrayElementOffset(int index) { - return cellOffset(arrayStartOffSet + index); - } - - ArrayData(DataLayout layout) { - super(layout); - } - - static int staticCellCount() { - return -1; - } - - int arrayLen() { - return intAt(arrayLenOffSet); - } - - public int cellCount() { - return arrayLen() + 1; - } - - // Code generation support - static int arrayLenOffset() { - return cellOffset(arrayLenOffSet); - } - static int arrayStartOffset() { - return cellOffset(arrayStartOffSet); - } - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BitData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BitData.java deleted file mode 100644 index fa48a7c9b16..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BitData.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 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. - * - * 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.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// BitData -// -// A BitData holds a flag or two in its header. -public class BitData extends ProfileData { - - // nullSeen: - // saw a null operand (cast/aastore/instanceof) - static final int nullSeenFlag = DataLayout.firstFlag + 0; - static final int bitCellCount = 0; - - public BitData(DataLayout layout) { - super(layout); - } - - static int staticCellCount() { - return bitCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Accessor - - // The nullSeen flag bit is specially known to the interpreter. - // Consulting it allows the compiler to avoid setting up nullCheck traps. - boolean nullSeen() { return flagAt(nullSeenFlag); } - - // Code generation support - // static int nullSeenByteConstant() { - // return flagNumberToByteConstant(nullSeenFlag); - // } - - static int bitDataSize() { - return cellOffset(bitCellCount); - } - - public void printDataOn(PrintStream st) { - printShared(st, "BitData"); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BranchData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BranchData.java deleted file mode 100644 index 5f27437289c..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BranchData.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// BranchData -// -// A BranchData is used to access profiling data for a two-way branch. -// It consists of taken and notTaken counts as well as a data displacement -// for the taken case. -public class BranchData extends JumpData { - - static final int notTakenOffSet = jumpCellCount; - static final int branchCellCount = notTakenOffSet + 1; - - public BranchData(DataLayout layout) { - super(layout); - //assert(layout.tag() == DataLayout.branchDataTag, "wrong type"); - } - - static int staticCellCount() { - return branchCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Direct accessor - int notTaken() { - return uintAt(notTakenOffSet); - } - - // Code generation support - static int notTakenOffset() { - return cellOffset(notTakenOffSet); - } - static int branchDataSize() { - return cellOffset(branchCellCount); - } - - public void printDataOn(PrintStream st) { - printShared(st, "BranchData"); - st.println("taken(" + taken() + ") displacement(" + displacement() + ")"); - tab(st); - st.println("not taken(" + notTaken() + ")"); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeData.java deleted file mode 100644 index a0eb02946b3..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeData.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// CallTypeData -// -// A CallTypeData is used to access profiling information about a non -// virtual call for which we collect type information about arguments -// and return value. -public class CallTypeData extends CounterData implements CallTypeDataInterface { - final TypeStackSlotEntries args; - final ReturnTypeEntry ret; - - int cellCountGlobalOffset() { - return CounterData.staticCellCount() + TypeEntriesAtCall.cellCountLocalOffset(); - } - - int cellCountNoHeader() { - return uintAt(cellCountGlobalOffset()); - } - - public CallTypeData(MethodDataInterface methodData, DataLayout layout) { - super(layout); - args = new TypeStackSlotEntries(methodData, this, CounterData.staticCellCount()+TypeEntriesAtCall.headerCellCount(), numberOfArguments()); - ret = new ReturnTypeEntry(methodData, this, cellCount() - ReturnTypeEntry.staticCellCount()); - } - - static int staticCellCount() { - return -1; - } - - public int cellCount() { - return CounterData.staticCellCount() + - TypeEntriesAtCall.headerCellCount() + - intAt(cellCountGlobalOffset()); - } - - public int numberOfArguments() { - return cellCountNoHeader() / TypeStackSlotEntries.perArgCount(); - } - - public boolean hasArguments() { - return cellCountNoHeader() >= TypeStackSlotEntries.perArgCount(); - } - - public K argumentType(int i) { - return args.type(i); - } - - public boolean hasReturn() { - return (cellCountNoHeader() % TypeStackSlotEntries.perArgCount()) != 0; - } - - public K returnType() { - return ret.type(); - } - - public int argumentTypeIndex(int i) { - return args.typeIndex(i); - } - - public int returnTypeIndex() { - return ret.typeIndex(); - } - - public void printDataOn(PrintStream st) { - super.printDataOn(st); - if (hasArguments()) { - tab(st); - st.print("argument types"); - args.printDataOn(st); - } - if (hasReturn()) { - tab(st); - st.print("return type"); - ret.printDataOn(st); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CounterData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CounterData.java deleted file mode 100644 index f803c71e02b..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CounterData.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// CounterData -// -// A CounterData corresponds to a simple counter. -public class CounterData extends BitData { - - static final int countOff = 0; - static final int counterCellCount = 1; - - public CounterData(DataLayout layout) { - super(layout); - } - - static int staticCellCount() { - return counterCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Direct accessor - int count() { - return uintAt(countOff); - } - - // Code generation support - static int countOffset() { - return cellOffset(countOff); - } - static int counterDataSize() { - return cellOffset(counterCellCount); - } - - public void printDataOn(PrintStream st) { - printShared(st, "CounterData"); - st.println("count(" + count() + ")"); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java deleted file mode 100644 index d627c66839b..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2011, 2021, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -public class DataLayout { - public static final int noTag = 0; - public static final int bitDataTag = 1; - public static final int counterDataTag = 2; - public static final int jumpDataTag= 3; - public static final int receiverTypeDataTag = 4; - public static final int virtualCallDataTag = 5; - public static final int retDataTag = 6; - public static final int branchDataTag = 7; - public static final int multiBranchDataTag = 8; - public static final int argInfoDataTag = 9; - public static final int callTypeDataTag = 10; - public static final int virtualCallTypeDataTag = 11; - public static final int parametersTypeDataTag = 12; - public static final int speculativeTrapDataTag = 13; - - // The trap state breaks down as [recompile:1 | reason:31]. - // This further breakdown is defined in deoptimization.cpp. - // See Deoptimization.trapStateReason for an assert that - // trapBits is big enough to hold reasons < reasonRecordedLimit. - // - // The trapState is collected only if ProfileTraps is true. - public static final int trapBits = 1+31; // 31: enough to distinguish [0..reasonRecordedLimit]. - public static final int trapMask = Bits.rightNBits(trapBits); - public static final int firstFlag = 0; - - private Address data; - - private int offset; - - public DataLayout(MethodData d, int o) { - data = d.getAddress(); - offset = o; - } - - public DataLayout(Address d, int o) { - data = d; - offset = o; - } - - public int dp() { return offset; } - - private int getU11(int at) { - return data.getJByteAt(offset + at) & 0xff; - } - - private int getU22(int at) { - return data.getJShortAt(offset + at) & 0xffff; - } - - long cellAt(int index) { - return data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); - } - - public Address addressAt(int index) { - return data.getAddressAt(offset + cellOffset(index)); - } - - // Every data layout begins with a header. This header - // contains a tag, which is used to indicate the size/layout - // of the data, 8 bits of flags, which can be used in any way, - // 32 bits of trap history (none/one reason/many reasons), - // and a bci, which is used to tie this piece of data to a - // specific bci in the bytecodes. - // union { - // u8 _bits; - // struct { - // u1 _tag; - // u1 _flags; - // u2 _bci; - // u4 _traps; - // } _struct; - // } _header; - - // Some types of data layouts need a length field. - static boolean needsArrayLen(int tag) { - return (tag == multiBranchDataTag); - } - - public static final int counterIncrement = 1; - - // Size computation - static int headerSizeInBytes() { - return MethodData.cellSize * headerSizeInCells(); - } - static int headerSizeInCells() { - return VM.getVM().isLP64() ? 1 : 2; - } - - public static int computeSizeInBytes(int cellCount) { - return headerSizeInBytes() + cellCount * MethodData.cellSize; - } - - // Initialization - // void initialize(int tag, int bci, int cellCount); - - // Accessors - public int tag() { - return getU11(0); - } - - // Return a few bits of trap state. Range is [0..trapMask]. - // The state tells if traps with zero, one, or many reasons have occurred. - // It also tells whether zero or many recompilations have occurred. - // The associated trap histogram in the MDO itself tells whether - // traps are common or not. If a BCI shows that a trap X has - // occurred, and the MDO shows N occurrences of X, we make the - // simplifying assumption that all N occurrences can be blamed - // on that BCI. - int trapState() { - return data.getJIntAt(offset+4); - } - - int flags() { - return getU11(1); - } - - int bci() { - return getU22(2); - } - - boolean flagAt(int flagNumber) { - // assert(flagNumber < flagLimit, "oob"); - return (flags() & (0x1 << flagNumber)) != 0; - } - - // Low-level support for code generation. - static int headerOffset() { - return 0; - } - static int tagOffset() { - return 0; - } - static int flagsOffset() { - return 1; - } - static int bciOffset() { - return 2; - } - public static int cellOffset(int index) { - return (headerSizeInCells() + index) * MethodData.cellSize; - } - // // Return a value which, when or-ed as a byte into _flags, sets the flag. - // static int flagNumberToByteConstant(int flagNumber) { - // assert(0 <= flagNumber && flagNumber < flagLimit, "oob"); - // DataLayout temp; temp.setHeader(0); - // temp.setFlagAt(flagNumber); - // return temp._header._struct._flags; - // } - // // Return a value which, when or-ed as a word into _header, sets the flag. - // static intptrT flagMaskToHeaderMask(int byteConstant) { - // DataLayout temp; temp.setHeader(0); - // temp._header._struct._flags = byteConstant; - // return temp._header._bits; - // } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Instance.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Instance.java index 66efbe3484a..fea4fdaabc2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Instance.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Instance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -57,10 +57,8 @@ public class Instance extends Oop { public static long getHeaderSize() { if (VM.getVM().isCompactObjectHeadersEnabled()) { return Oop.getHeaderSize(); - } else if (VM.getVM().isCompressedKlassPointersEnabled()) { - return typeSize - VM.getVM().getIntSize(); } else { - return typeSize; + return typeSize - VM.getVM().getIntSize(); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/JumpData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/JumpData.java deleted file mode 100644 index 008a6ee7164..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/JumpData.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// JumpData -// -// A JumpData is used to access profiling information for a direct -// branch. It is a counter, used for counting the number of branches, -// plus a data displacement, used for realigning the data pointer to -// the corresponding target bci. -public class JumpData extends ProfileData { - static final int takenOffSet = 0; - static final int displacementOffSet = 1; - static final int jumpCellCount = 2; - - public JumpData(DataLayout layout) { - super(layout); - //assert(layout.tag() == DataLayout.jumpDataTag || - // layout.tag() == DataLayout.branchDataTag, "wrong type"); - } - - static int staticCellCount() { - return jumpCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Direct accessor - int taken() { - return uintAt(takenOffSet); - } - - int displacement() { - return intAt(displacementOffSet); - } - - // Code generation support - static int takenOffset() { - return cellOffset(takenOffSet); - } - - static int displacementOffset() { - return cellOffset(displacementOffSet); - } - - public void printDataOn(PrintStream st) { - printShared(st, "JumpData"); - st.println("taken(" + taken() + ") displacement(" + displacement() + ")"); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java index dfbd67ae805..1ba1f817c5c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -67,7 +67,6 @@ public abstract class Metadata extends VMObject { metadataConstructor.addMapping("TypeArrayKlass", TypeArrayKlass.class); metadataConstructor.addMapping("ObjArrayKlass", ObjArrayKlass.class); metadataConstructor.addMapping("Method", Method.class); - metadataConstructor.addMapping("MethodData", MethodData.class); metadataConstructor.addMapping("ConstMethod", ConstMethod.class); metadataConstructor.addMapping("ConstantPool", ConstantPool.class); metadataConstructor.addMapping("ConstantPoolCache", ConstantPoolCache.class); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java index 75dec8edbd1..d16fa61a6b4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Method.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -56,7 +56,6 @@ public class Method extends Metadata { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { type = db.lookupType("Method"); constMethod = type.getAddressField("_constMethod"); - methodData = type.getAddressField("_method_data"); methodCounters = type.getAddressField("_method_counters"); accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); code = type.getAddressField("_code"); @@ -82,7 +81,6 @@ public class Method extends Metadata { // Fields private static AddressField constMethod; - private static AddressField methodData; private static AddressField methodCounters; private static CIntField accessFlags; private static CIntField vtableIndex; @@ -126,10 +124,6 @@ public class Method extends Metadata { public U1Array getStackMapData() { return getConstMethod().getStackMapData(); } - public MethodData getMethodData() { - Address addr = methodData.getValue(getAddress()); - return VMObjectFactory.newObject(MethodData.class, addr); - } public MethodCounters getMethodCounters() { Address addr = methodCounters.getValue(getAddress()); return VMObjectFactory.newObject(MethodCounters.class, addr); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java index a7c2e2bccb7..fd804085c7b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,92 +35,7 @@ import sun.jvm.hotspot.utilities.Observer; // A MethodData provides interpreter profiling information -public class MethodData extends Metadata implements MethodDataInterface { - static int TypeProfileWidth = 2; - static int BciProfileWidth = 2; - static int CompileThreshold; - - static int Reason_many; // indicates presence of several reasons - static int Reason_none; // indicates absence of a relevant deopt. - static int Reason_LIMIT; - static int Reason_RECORDED_LIMIT; // some are not recorded per bc - - private static String[] trapReasonName; - - static String trapReasonName(int reason) { - if (reason == Reason_many) return "many"; - if (reason < Reason_LIMIT) - return trapReasonName[reason]; - return "reason" + reason; - } - - - static int trapStateReason(int trapState) { - // This assert provides the link between the width of DataLayout.trapBits - // and the encoding of "recorded" reasons. It ensures there are enough - // bits to store all needed reasons in the per-BCI MDO profile. - // assert(dsReasonMask >= reasonRecordedLimit, "enough bits"); - int recompileBit = (trapState & dsRecompileBit); - trapState -= recompileBit; - if (trapState == dsReasonMask) { - return Reason_many; - } else { - // assert((int)reasonNone == 0, "state=0 => Reason_none"); - return trapState; - } - } - - - static final int dsReasonMask = DataLayout.trapMask >> 1; - static final int dsRecompileBit = DataLayout.trapMask - dsReasonMask; - - static boolean trapStateIsRecompiled(int trapState) { - return (trapState & dsRecompileBit) != 0; - } - - static boolean reasonIsRecordedPerBytecode(int reason) { - return reason > Reason_none && reason < Reason_RECORDED_LIMIT; - } - static int trapStateAddReason(int trapState, int reason) { - // assert(reasonIsRecordedPerBytecode((DeoptReason)reason) || reason == reasonMany, "valid reason"); - int recompileBit = (trapState & dsRecompileBit); - trapState -= recompileBit; - if (trapState == dsReasonMask) { - return trapState + recompileBit; // already at state lattice bottom - } else if (trapState == reason) { - return trapState + recompileBit; // the condition is already true - } else if (trapState == 0) { - return reason + recompileBit; // no condition has yet been true - } else { - return dsReasonMask + recompileBit; // fall to state lattice bottom - } - } - static int trapStateSetRecompiled(int trapState, boolean z) { - if (z) return trapState | dsRecompileBit; - else return trapState & ~dsRecompileBit; - } - - static String formatTrapState(int trapState) { - int reason = trapStateReason(trapState); - boolean recompFlag = trapStateIsRecompiled(trapState); - // Re-encode the state from its decoded components. - int decodedState = 0; - if (reasonIsRecordedPerBytecode(reason) || reason == Reason_many) - decodedState = trapStateAddReason(decodedState, reason); - if (recompFlag) - decodedState = trapStateSetRecompiled(decodedState, recompFlag); - // If the state re-encodes properly, format it symbolically. - // Because this routine is used for debugging and diagnostics, - // be robust even if the state is a strange value. - if (decodedState != trapState) { - // Random buggy state that doesn't decode?? - return "#" + trapState; - } else { - return trapReasonName(reason) + (recompFlag ? " recompiled" : ""); - } - } - - +public class MethodData extends Metadata { static { VM.registerVMInitializedObserver(new Observer() { @@ -132,96 +47,17 @@ public class MethodData extends Metadata implements MethodDataInterface parametersTypeData() { - int di = (int)parametersTypeDataDi.getValue(getAddress()); - if (di == -1 || di == -2) { - return null; - } - DataLayout dataLayout = new DataLayout(this, di + (int)data.getOffset()); - return new ParametersTypeData(this, dataLayout); - } - - boolean outOfBounds(int dataIndex) { - return dataIndex >= dataSize(); - } - - ProfileData dataAt(int dataIndex) { - if (outOfBounds(dataIndex)) { - return null; - } - DataLayout dataLayout = new DataLayout(this, dataIndex + (int)data.getOffset()); - - switch (dataLayout.tag()) { - case DataLayout.noTag: - default: - throw new InternalError(dataIndex + " " + dataSize() + " " + dataLayout.tag()); - case DataLayout.bitDataTag: - return new BitData(dataLayout); - case DataLayout.counterDataTag: - return new CounterData(dataLayout); - case DataLayout.jumpDataTag: - return new JumpData(dataLayout); - case DataLayout.receiverTypeDataTag: - return new ReceiverTypeData(this, dataLayout); - case DataLayout.virtualCallDataTag: - return new VirtualCallData(this, dataLayout); - case DataLayout.retDataTag: - return new RetData(dataLayout); - case DataLayout.branchDataTag: - return new BranchData(dataLayout); - case DataLayout.multiBranchDataTag: - return new MultiBranchData(dataLayout); - case DataLayout.callTypeDataTag: - return new CallTypeData(this, dataLayout); - case DataLayout.virtualCallTypeDataTag: - return new VirtualCallTypeData(this, dataLayout); - case DataLayout.parametersTypeDataTag: - return new ParametersTypeData(this, dataLayout); - } - } - - int dpToDi(int dp) { - // this in an offset from the base of the MDO, so convert to offset into _data - return dp - (int)data.getOffset(); - } - - int firstDi() { return 0; } - public ProfileData firstData() { return dataAt(firstDi()); } - public ProfileData nextData(ProfileData current) { - int currentIndex = dpToDi(current.dp()); - int nextIndex = currentIndex + current.sizeInBytes(); - return dataAt(nextIndex); - } - boolean isValid(ProfileData current) { return current != null; } - - DataLayout limitDataPosition() { - return new DataLayout(this, dataSize() + (int)data.getOffset()); - } - - DataLayout extraDataBase() { - return limitDataPosition(); - } - - DataLayout extraDataLimit() { - return new DataLayout(this, sizeInBytes()); - } - - public static int extraNbCells(DataLayout dataLayout) { - int nbCells = 0; - switch(dataLayout.tag()) { - case DataLayout.bitDataTag: - case DataLayout.noTag: - nbCells = BitData.staticCellCount(); - break; - case DataLayout.speculativeTrapDataTag: - nbCells = SpeculativeTrapData.staticCellCount(); - break; - default: - throw new InternalError("unexpected tag " + dataLayout.tag()); - } - return nbCells; - } - - DataLayout nextExtra(DataLayout dataLayout) { - return new DataLayout(this, dataLayout.dp() + DataLayout.computeSizeInBytes(extraNbCells(dataLayout))); - } - - public void printDataOn(PrintStream st) { - if (parametersTypeData() != null) { - parametersTypeData().printDataOn(st); - } - ProfileData data = firstData(); - for ( ; isValid(data); data = nextData(data)) { - st.print(dpToDi(data.dp())); - st.print(" "); - // st->fillTo(6); - data.printDataOn(st); - } - st.println("--- Extra data:"); - DataLayout dp = extraDataBase(); - DataLayout end = extraDataLimit(); - for (;; dp = nextExtra(dp)) { - switch(dp.tag()) { - case DataLayout.noTag: - continue; - case DataLayout.bitDataTag: - data = new BitData(dp); - break; - case DataLayout.speculativeTrapDataTag: - data = new SpeculativeTrapData(this, dp); - break; - case DataLayout.argInfoDataTag: - data = new ArgInfoData(dp); - dp = end; // ArgInfoData is at the end of extra data section. - break; - default: - throw new InternalError("unexpected tag " + dp.tag()); - } - st.print(dpToDi(data.dp())); - st.print(" "); - data.printDataOn(st); - if (dp == end) return; - } - } - - private byte[] fetchDataAt(Address base, long offset, long size) { - byte[] result = new byte[(int)size]; - for (int i = 0; i < size; i++) { - result[i] = base.getJByteAt(offset + i); - } - return result; - } - - public byte[] orig() { - // fetch the orig MethodData data between header and dataSize - return fetchDataAt(getAddress(), 0, sizeofMethodDataOopDesc); - } - - public long[] data() { - // Read the data as an array of intptr_t elements - Address base = getAddress(); - long offset = data.getOffset(); - int elements = dataSize() / cellSize; - long[] result = new long[elements]; - for (int i = 0; i < elements; i++) { - Address value = base.getAddressAt(offset + i * MethodData.cellSize); - if (value != null) { - result[i] = value.minus(null); - } - } - return result; - } - - // Get a measure of how much mileage the method has on it. - int mileageOf(Method method) { - long mileage = 0; - long iic = method.interpreterInvocationCount(); - if (mileage < iic) mileage = iic; - - long ic = method.getInvocationCount(); - long bc = method.getBackedgeCount(); - - long icval = ic >> 3; - if ((ic & 4) != 0) icval += CompileThreshold; - if (mileage < icval) mileage = icval; - long bcval = bc >> 3; - if ((bc & 4) != 0) bcval += CompileThreshold; - if (mileage < bcval) mileage = bcval; - return (int)mileage; - } - - public int currentMileage() { - return 20000; - } - } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MultiBranchData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MultiBranchData.java deleted file mode 100644 index 089de318adf..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MultiBranchData.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2011, 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. - * - * 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.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// MultiBranchData -// -// A MultiBranchData is used to access profiling information for -// a multi-way branch (*switch bytecodes). It consists of a series -// of (count, displacement) pairs, which count the number of times each -// case was taken and specify the data displacement for each branch target. -public class MultiBranchData extends ArrayData { - static final int defaultCountOffSet = 0; - static final int defaultDisaplacementOffSet = 1; - static final int caseArrayStart = 2; - static final int relativeCountOffSet = 0; - static final int relativeDisplacementOffSet = 1; - static final int perCaseCellCount = 2; - - public MultiBranchData(DataLayout layout) { - super(layout); - //assert(layout.tag() == DataLayout.multiBranchDataTag, "wrong type"); - } - - // static int computeCellCount(BytecodeStream stream); - - int numberOfCases() { - int alen = arrayLen() - 2; // get rid of default case here. - //assert(alen % perCaseCellCount == 0, "must be even"); - return (alen / perCaseCellCount); - } - - int defaultCount() { - return arrayUintAt(defaultCountOffSet); - } - int defaultDisplacement() { - return arrayIntAt(defaultDisaplacementOffSet); - } - - int countAt(int index) { - return arrayUintAt(caseArrayStart + - index * perCaseCellCount + - relativeCountOffSet); - } - int displacementAt(int index) { - return arrayIntAt(caseArrayStart + - index * perCaseCellCount + - relativeDisplacementOffSet); - } - - // Code generation support - static int defaultCountOffset() { - return arrayElementOffset(defaultCountOffSet); - } - static int defaultDisplacementOffset() { - return arrayElementOffset(defaultDisaplacementOffSet); - } - static int caseCountOffset(int index) { - return caseArrayOffset() + - (perCaseSize() * index) + - relativeCountOffset(); - } - static int caseArrayOffset() { - return arrayElementOffset(caseArrayStart); - } - static int perCaseSize() { - return (perCaseCellCount) * MethodData.cellSize; - } - static int relativeCountOffset() { - return (relativeCountOffSet) * MethodData.cellSize; - } - static int relativeDisplacementOffset() { - return (relativeDisplacementOffSet) * MethodData.cellSize; - } - - public void printDataOn(PrintStream st) { - printShared(st, "MultiBranchData"); - st.println("default_count(" + defaultCount() + ") displacement(" + defaultDisplacement() + ")"); - int cases = numberOfCases(); - for (int i = 0; i < cases; i++) { - tab(st); - st.println("count(" + countAt(i) + ") displacement(" + displacementAt(i) + ")"); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java index 75ad4ab1d66..951499974fa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,8 +51,7 @@ public class Oop { headerSize = markType.getSize(); } else { headerSize = type.getSize(); - klass = new MetadataField(type.getAddressField("_metadata._klass"), 0); - compressedKlass = new NarrowKlassField(type.getAddressField("_metadata._compressed_klass"), 0); + compressedKlass = new NarrowKlassField(type.getAddressField("_compressed_klass"), 0); } } @@ -75,7 +74,6 @@ public class Oop { public static long getHeaderSize() { return headerSize; } // Header size in bytes. private static CIntField mark; - private static MetadataField klass; private static NarrowKlassField compressedKlass; // Accessors for declared fields @@ -83,12 +81,9 @@ public class Oop { public Klass getKlass() { if (VM.getVM().isCompactObjectHeadersEnabled()) { - assert(VM.getVM().isCompressedKlassPointersEnabled()); return getMark().getKlass(); - } else if (VM.getVM().isCompressedKlassPointersEnabled()) { - return (Klass)compressedKlass.getValue(getHandle()); } else { - return (Klass)klass.getValue(getHandle()); + return (Klass)compressedKlass.getValue(getHandle()); } } @@ -157,11 +152,7 @@ public class Oop { if (doVMFields) { visitor.doCInt(mark, true); if (!VM.getVM().isCompactObjectHeadersEnabled()) { - if (VM.getVM().isCompressedKlassPointersEnabled()) { - visitor.doMetadata(compressedKlass, true); - } else { - visitor.doMetadata(klass, true); - } + visitor.doMetadata(compressedKlass, true); } } } @@ -220,10 +211,8 @@ public class Oop { if (VM.getVM().isCompactObjectHeadersEnabled()) { Mark mark = new Mark(handle); return mark.getKlass(); - } else if (VM.getVM().isCompressedKlassPointersEnabled()) { - return (Klass)Metadata.instantiateWrapperFor(handle.getCompKlassAddressAt(compressedKlass.getOffset())); } else { - return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset())); + return (Klass)Metadata.instantiateWrapperFor(handle.getCompKlassAddressAt(compressedKlass.getOffset())); } } }; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ParametersTypeData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ParametersTypeData.java deleted file mode 100644 index d6ea749576a..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ParametersTypeData.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2014, 2021, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// ParametersTypeData -// -// A ParametersTypeData is used to access profiling information about -// types of parameters to a method -public class ParametersTypeData extends ArrayData { - final TypeStackSlotEntries parameters; - - static int stackSlotLocalOffset(int i) { - return arrayStartOffSet + TypeStackSlotEntries.stackSlotLocalOffset(i); - } - - static int typeLocalOffset(int i) { - return arrayStartOffSet + TypeStackSlotEntries.typeLocalOffset(i); - } - - public ParametersTypeData(MethodDataInterface methodData, DataLayout layout) { - super(layout); - parameters = new TypeStackSlotEntries(methodData, this, 1, numberOfParameters()); - } - - public int numberOfParameters() { - return arrayLen() / TypeStackSlotEntries.perArgCount(); - } - - int stackSlot(int i) { - return parameters.stackSlot(i); - } - - public K type(int i) { - return parameters.type(i); - } - - public static int typeIndex(int i) { - return typeLocalOffset(i); - } - - public void printDataOn(PrintStream st) { - st.print("parameter types"); - parameters.printDataOn(st); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java deleted file mode 100644 index 29a127b6a49..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2011, 2021, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -public abstract class ProfileData { - // This is a pointer to a section of profiling data. - private DataLayout _data; - - public DataLayout data() { return _data; } - - // How many cells are in this? - public abstract int cellCount(); - - - // Return the size of this data. - public int sizeInBytes() { - return DataLayout.computeSizeInBytes(cellCount()); - } - - public int dp() { - return data().dp(); - } - - // Low-level accessors for underlying data - long intptrAt(int index) { - //assert(0 <= index && index < cellCount(), "oob"); - return data().cellAt(index); - } - int intAt(int index) { - return (int)intptrAt(index); - } - int uintAt(int index) { - return (int)intptrAt(index); - } - public Address addressAt(int index) { - return data().addressAt(index); - } - - boolean flagAt(int flagNumber) { - return data().flagAt(flagNumber); - } - - // two convenient imports for use by subclasses: - public static int cellOffset(int index) { - return DataLayout.cellOffset(index); - } - - public ProfileData(DataLayout data) { - _data = data; - } - - // Constructor for invalid ProfileData. - ProfileData() { - _data = null; - } - - int bci() { - return data().bci(); - } - - int trapState() { - return data().trapState(); - } - public abstract void printDataOn(PrintStream st); - - void tab(PrintStream st) { - st.print("\t"); - } - - void printShared(PrintStream st, String name) { - st.print("bci: " + bci()); - // st.fillTo(tabWidthOne); - st.print(" " + name + " "); - tab(st); - int trap = trapState(); - if (trap != 0) { - st.print("trap(" + MethodData.formatTrapState(trap) + ") "); - } - int flags = data().flags(); - if (flags != 0) - st.print("flags(" + flags + ") "); - } - - public String toString() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - try { - printDataOn(ps); - } finally { - ps.close(); - } - return baos.toString(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java deleted file mode 100644 index 758566c5611..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// ReceiverTypeData -// -// A ReceiverTypeData is used to access profiling information about a -// dynamic type check. It consists of a counter which counts the total times -// that the check is reached, and a series of (Klass, count) pairs -// which are used to store a type profile for the receiver of the check. -public class ReceiverTypeData extends CounterData { - static final int nonProfiledCountOffset = counterCellCount; - static final int receiver0Offset; - static final int count0Offset; - static final int receiverTypeRowCellCount; - static { - receiver0Offset = counterCellCount; - count0Offset = receiver0Offset + 1; - receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; - } - final MethodDataInterface methodData; - - public ReceiverTypeData(MethodDataInterface methodData, DataLayout layout) { - super(layout); - this.methodData = methodData; - //assert(layout.tag() == DataLayout.receiverTypeDataTag || - // layout.tag() == DataLayout.virtualCallDataTag, "wrong type"); - } - - boolean isReceivertypedata() { return true; } - - static int staticCellCount() { - int cellCount = counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; - return cellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Direct accessors - public static int rowLimit() { - return MethodData.TypeProfileWidth; - } - public static int receiverCellIndex(int row) { - return receiver0Offset + row * receiverTypeRowCellCount; - } - public static int receiverCountCellIndex(int row) { - return count0Offset + row * receiverTypeRowCellCount; - } - - // Get the receiver at row. The 'unchecked' version is needed by parallel old - // gc; it does not assert the receiver is a klass. During compaction of the - // perm gen, the klass may already have moved, so the isKlass() predicate - // would fail. The 'normal' version should be used whenever possible. - K receiverUnchecked(int row) { - //assert(row < rowLimit(), "oob"); - Address recv = addressAt(receiverCellIndex(row)); - return methodData.getKlassAtAddress(recv); - } - - public K receiver(int row) { - K recv = receiverUnchecked(row); - //assert(recv == NULL || ((oop)recv).isKlass(), "wrong type"); - return recv; - } - - public int receiverCount(int row) { - //assert(row < rowLimit(), "oob"); - return uintAt(receiverCountCellIndex(row)); - } - - // Code generation support - static int receiverOffset(int row) { - return cellOffset(receiverCellIndex(row)); - } - static int receiverCountOffset(int row) { - return cellOffset(receiverCountCellIndex(row)); - } - static int receiverTypeDataSize() { - return cellOffset(staticCellCount()); - } - - void printReceiverDataOn(PrintStream st) { - int row; - int entries = 0; - for (row = 0; row < rowLimit(); row++) { - if (receiver(row) != null) entries++; - } - st.println("count(" + count() + ") entries(" + entries + ")"); - for (row = 0; row < rowLimit(); row++) { - if (receiver(row) != null) { - tab(st); - methodData.printKlassValueOn(receiver(row), st); - st.println("(" + receiverCount(row) + ")"); - } - } - } - public void printDataOn(PrintStream st) { - printShared(st, "ReceiverTypeData"); - printReceiverDataOn(st); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/RetData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/RetData.java deleted file mode 100644 index 5ecd60bcb8e..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/RetData.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 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. - * - * 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.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// RetData -// -// A RetData is used to access profiling information for a ret bytecode. -// It is composed of a count of the number of times that the ret has -// been executed, followed by a series of triples of the form -// (bci, count, di) which count the number of times that some bci was the -// target of the ret and cache a corresponding data displacement. -public class RetData extends CounterData { - - static final int bci0Offset = counterCellCount; - static final int count0Offset = bci0Offset + 1; - static final int displacement0Offset = count0Offset + 1; - static final int retRowCellCount = (displacement0Offset + 1) - bci0Offset; - - public RetData(DataLayout layout) { - super(layout); - //assert(layout.tag() == DataLayout.retDataTag, "wrong type"); - } - - static final int noBci = -1; // value of bci when bci1/2 are not in use. - - static int staticCellCount() { - return counterCellCount + MethodData.BciProfileWidth * retRowCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - static int rowLimit() { - return MethodData.BciProfileWidth; - } - static int bciCellIndex(int row) { - return bci0Offset + row * retRowCellCount; - } - static int bciCountCellIndex(int row) { - return count0Offset + row * retRowCellCount; - } - static int bciDisplacementCellIndex(int row) { - return displacement0Offset + row * retRowCellCount; - } - - // Direct accessors - int bci(int row) { - return intAt(bciCellIndex(row)); - } - int bciCount(int row) { - return uintAt(bciCountCellIndex(row)); - } - int bciDisplacement(int row) { - return intAt(bciDisplacementCellIndex(row)); - } - - // Code generation support - static int bciOffset(int row) { - return cellOffset(bciCellIndex(row)); - } - static int bciCountOffset(int row) { - return cellOffset(bciCountCellIndex(row)); - } - static int bciDisplacementOffset(int row) { - return cellOffset(bciDisplacementCellIndex(row)); - } - - public void printDataOn(PrintStream st) { - printShared(st, "RetData"); - int row; - int entries = 0; - for (row = 0; row < rowLimit(); row++) { - if (bci(row) != noBci) entries++; - } - st.println("count(" + count() + ") entries(" + entries + ")"); - for (row = 0; row < rowLimit(); row++) { - if (bci(row) != noBci) { - tab(st); - st.println(" bci(" + bci(row) + ": count(" + bciCount(row) + ") displacement(" + bciDisplacement(row) + "))"); - } - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/SpeculativeTrapData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/SpeculativeTrapData.java deleted file mode 100644 index 76e531d1dea..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/SpeculativeTrapData.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014, 2021, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// SpeculativeTrapData -// -// A SpeculativeTrapData is used to record traps due to type -// speculation. It records the root of the compilation. -public class SpeculativeTrapData extends ProfileData { - static final int speculativeTrapMethod = 0; - static final int speculativeTrapCellCount = 1; - final MethodDataInterface methodData; - - public SpeculativeTrapData(MethodDataInterface methodData, DataLayout layout) { - super(layout); - this.methodData = methodData; - } - - static int staticCellCount() { - return speculativeTrapCellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - public M method() { - return methodData.getMethodAtAddress(addressAt(speculativeTrapMethod)); - } - - public static int methodIndex() { - return speculativeTrapMethod; - } - - public void printDataOn(PrintStream st) { - printShared(st, "SpeculativeTrapData"); - tab(st); - methodData.printMethodValueOn(method(), st); - st.println(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java deleted file mode 100644 index 16ba553a838..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014, 2021, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// Entries in a ProfileData object to record types: it can either be -// none (no profile), unknown (conflicting profile data) or a klass if -// a single one is seen. Whether a null reference was seen is also -// recorded. No counter is associated with the type and a single type -// is tracked (unlike VirtualCallData). -public abstract class TypeEntries { - static final int nullSeen = 1; - static final int typeMask = ~nullSeen; - static final int typeUnknown = 2; - static final int statusBits = nullSeen | typeUnknown; - static final int typeKlassMask = ~statusBits; - - final ProfileData pd; - final int baseOff; - final MethodDataInterface methodData; - - boolean wasNullSeen(int index) { - long v = pd.intptrAt(index); - return (v & nullSeen) != 0; - } - - boolean isTypeUnknown(int index) { - long v = pd.intptrAt(index); - return (v & typeUnknown) != 0; - } - - boolean isTypeNone(int index) { - long v = pd.intptrAt(index); - return (v & typeMask) == 0; - } - - K validKlass(int index) { - if (!isTypeNone(index) && - !isTypeUnknown(index)) { - return methodData.getKlassAtAddress(pd.addressAt(index).andWithMask(typeKlassMask)); - } else { - return null; - } - } - - void printKlass(PrintStream st, int index) { - if (isTypeNone(index)) { - st.print("none"); - } else if (isTypeUnknown(index)) { - st.print("unknown"); - } else { - methodData.printKlassValueOn(validKlass(index), st); - } - if (wasNullSeen(index)) { - st.print(" (null seen)"); - } - } - - TypeEntries(MethodDataInterface methodData, ProfileData pd, int baseOff) { - this.pd = pd; - this.baseOff = baseOff; - this.methodData = methodData; - } - - long intptrAt(int index) { - return pd.intptrAt(index); - } - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeStackSlotEntries.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeStackSlotEntries.java deleted file mode 100644 index 9efff34a4c3..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeStackSlotEntries.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// Type entries used for arguments passed at a call and parameters on -// method entry. 2 cells per entry: one for the type encoded as in -// TypeEntries and one initialized with the stack slot where the -// profiled object is to be found so that the interpreter can locate -// it quickly. -public class TypeStackSlotEntries extends TypeEntries { - static final int stackSlotEntry = 0; - static final int typeEntry = 1; - static final int perArgCellCount = 2; - - int stackSlotOffset(int i) { - return baseOff + stackSlotLocalOffset(i); - } - - final int numberOfEntries; - - int typeOffsetInCells(int i) { - return baseOff + typeLocalOffset(i); - } - - TypeStackSlotEntries(MethodDataInterface methodData, ProfileData pd, int baseOff, int nbEntries) { - super(methodData, pd, baseOff); - numberOfEntries = nbEntries; - } - - static int stackSlotLocalOffset(int i) { - return i * perArgCellCount + stackSlotEntry; - } - - static int typeLocalOffset(int i) { - return i * perArgCellCount + typeEntry; - } - - int stackSlot(int i) { - return pd.uintAt(stackSlotOffset(i)); - } - - K type(int i) { - return validKlass(typeOffsetInCells(i)); - } - - static int perArgCount() { - return perArgCellCount; - } - - int typeIndex(int i) { - return typeOffsetInCells(i); - } - - void printDataOn(PrintStream st) { - for (int i = 0; i < numberOfEntries; i++) { - pd.tab(st); - st.print(i + ": stack(" + stackSlot(i)+ ") "); - printKlass(st, typeOffsetInCells(i)); - st.println(); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java deleted file mode 100644 index 2d303d8606d..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// VirtualCallData -// -// A VirtualCallData is used to access profiling information about a -// call. For now, it has nothing more than a ReceiverTypeData. -public class VirtualCallData extends ReceiverTypeData { - public VirtualCallData(MethodDataInterface methodData, DataLayout layout) { - super(methodData, layout); - //assert(layout.tag() == DataLayout.virtualCallDataTag, "wrong type"); - } - - static int staticCellCount() { - // At this point we could add more profile state, e.g., for arguments. - // But for now it's the same size as the base record type. - int cellCount = ReceiverTypeData.staticCellCount(); - return cellCount; - } - - public int cellCount() { - return staticCellCount(); - } - - // Direct accessors - static int virtualCallDataSize() { - return cellOffset(staticCellCount()); - } - - public void printDataOn(PrintStream st) { - printShared(st, "VirtualCallData"); - printReceiverDataOn(st); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java deleted file mode 100644 index 483d0d54ee2..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2014, 2020, 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 sun.jvm.hotspot.oops; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; - -// VirtualCallTypeData -// -// A VirtualCallTypeData is used to access profiling information about -// a virtual call for which we collect type information about -// arguments and return value. -public class VirtualCallTypeData extends VirtualCallData implements CallTypeDataInterface { - final TypeStackSlotEntries args; - final ReturnTypeEntry ret; - - int cellCountGlobalOffset() { - return VirtualCallData.staticCellCount() + TypeEntriesAtCall.cellCountLocalOffset(); - } - - int cellCountNoHeader() { - return uintAt(cellCountGlobalOffset()); - } - - public VirtualCallTypeData(MethodDataInterface methodData, DataLayout layout) { - super(methodData, layout); - args = new TypeStackSlotEntries(methodData, this, VirtualCallData.staticCellCount()+TypeEntriesAtCall.headerCellCount(), numberOfArguments()); - ret = new ReturnTypeEntry(methodData, this, cellCount() - ReturnTypeEntry.staticCellCount()); - } - - static int staticCellCount() { - return -1; - } - - public int cellCount() { - return VirtualCallData.staticCellCount() + - TypeEntriesAtCall.headerCellCount() + - intAt(cellCountGlobalOffset()); - } - - public int numberOfArguments() { - return cellCountNoHeader() / TypeStackSlotEntries.perArgCount(); - } - - public boolean hasArguments() { - return cellCountNoHeader() >= TypeStackSlotEntries.perArgCount(); - } - - public K argumentType(int i) { - return args.type(i); - } - - public boolean hasReturn() { - return (cellCountNoHeader() % TypeStackSlotEntries.perArgCount()) != 0; - } - - public K returnType() { - return ret.type(); - } - - public int argumentTypeIndex(int i) { - return args.typeIndex(i); - } - - public int returnTypeIndex() { - return ret.typeIndex(); - } - - public void printDataOn(PrintStream st) { - super.printDataOn(st); - if (hasArguments()) { - tab(st); - st.print("argument types"); - args.printDataOn(st); - } - if (hasReturn()) { - tab(st); - st.print("return type"); - ret.printDataOn(st); - } - } -}; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuation.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuation.java new file mode 100644 index 00000000000..72ba053f451 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuation.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. + * 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 sun.jvm.hotspot.runtime; + +import sun.jvm.hotspot.debugger.Address; + + +public class Continuation { + + public static boolean isReturnBarrierEntry(Address senderPC) { + if (!Continuations.enabled()) { + return false; + } + return VM.getVM().getStubRoutines().contReturnBarrier().equals(senderPC); + } + + public static boolean isSPInContinuation(ContinuationEntry entry, Address sp) { + return entry.getEntrySP().greaterThan(sp); + } + + public static ContinuationEntry getContinuationEntryForSP(JavaThread thread, Address sp) { + ContinuationEntry entry = thread.getContEntry(); + while (entry != null && !isSPInContinuation(entry, sp)) { + entry = entry.getParent(); + } + return entry; + } + + public static Frame continuationBottomSender(JavaThread thread, Frame callee, Address senderSP) { + ContinuationEntry ce = getContinuationEntryForSP(thread, callee.getSP()); + Frame entry = ce.toFrame(); + if (callee.isInterpretedFrame()) { + entry.setSP(senderSP); // sp != unextended_sp + } + return entry; + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ContinuationEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ContinuationEntry.java index 73152bdee84..7d8a2ba5993 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ContinuationEntry.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ContinuationEntry.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2025, NTT DATA. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,12 +26,17 @@ package sun.jvm.hotspot.runtime; import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.runtime.aarch64.*; +import sun.jvm.hotspot.runtime.amd64.*; +import sun.jvm.hotspot.runtime.ppc64.*; +import sun.jvm.hotspot.runtime.riscv64.*; import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.*; -public class ContinuationEntry extends VMObject { +public abstract class ContinuationEntry extends VMObject { private static long size; + private static AddressField parentField; private static Address returnPC; static { @@ -41,13 +46,28 @@ public class ContinuationEntry extends VMObject { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ContinuationEntry"); size = type.getSize(); + parentField = type.getAddressField("_parent"); returnPC = type.getAddressField("_return_pc").getValue(); } + public static ContinuationEntry create(Address addr) { + return switch (VM.getVM().getDebugger().getCPU()) { + case "amd64" -> VMObjectFactory.newObject(AMD64ContinuationEntry.class, addr); + case "aarch64" -> VMObjectFactory.newObject(AARCH64ContinuationEntry.class, addr); + case "riscv64" -> VMObjectFactory.newObject(RISCV64ContinuationEntry.class, addr); + case "ppc64" -> VMObjectFactory.newObject(PPC64ContinuationEntry.class, addr); + default -> throw new UnsupportedPlatformException("Continuation is not yet implemented."); + }; + } + public ContinuationEntry(Address addr) { super(addr); } + public ContinuationEntry getParent() { + return create(parentField.getValue(addr)); + } + public Address getEntryPC() { return returnPC; } @@ -60,4 +80,6 @@ public class ContinuationEntry extends VMObject { return this.getAddress().addOffsetTo(size); } + public abstract Frame toFrame(); + } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeDataInterface.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuations.java similarity index 75% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeDataInterface.java rename to src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuations.java index 0a8bf4721e4..884f8764ba5 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CallTypeDataInterface.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Continuations.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. * 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,15 +22,12 @@ * questions. * */ +package sun.jvm.hotspot.runtime; -package sun.jvm.hotspot.oops; +public class Continuations { + + public static boolean enabled() { + return VM.getVM().getCommandLineFlag("VMContinuations").getBool(); + } -public interface CallTypeDataInterface { - int numberOfArguments(); - boolean hasArguments(); - K argumentType(int i); - boolean hasReturn(); - K returnType(); - int argumentTypeIndex(int i); - int returnTypeIndex(); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Frame.java index ee9e0ecdafd..978fb39ad1c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -138,6 +138,7 @@ public abstract class Frame implements Cloneable { } public abstract Address getSP(); + public abstract void setSP(Address newSP); public abstract Address getID(); public abstract Address getFP(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java index 826b5cecfd5..c18bcf8cd37 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -343,7 +343,7 @@ public class JavaThread extends Thread { } public ContinuationEntry getContEntry() { - return VMObjectFactory.newObject(ContinuationEntry.class, contEntryField.getValue(addr)); + return ContinuationEntry.create(contEntryField.getValue(addr)); } /** Gets the Java-side thread object for this JavaThread */ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java index 38a3103ac50..85d8c8cd3b6 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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,6 +34,7 @@ import sun.jvm.hotspot.utilities.Observer; public class StubRoutines { private static AddressField callStubReturnAddressField; + private static AddressField contReturnBarrierField; static { VM.registerVMInitializedObserver(new Observer() { @@ -46,6 +47,7 @@ public class StubRoutines { private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("StubRoutines"); callStubReturnAddressField = type.getAddressField("_call_stub_return_address"); + contReturnBarrierField = type.getAddressField("_cont_returnBarrier"); } public StubRoutines() { @@ -59,4 +61,9 @@ public class StubRoutines { return (addr.equals(returnPC)); } } + + public Address contReturnBarrier() { + return contReturnBarrierField.getValue(); + } + } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java index 22bc02a06d9..d2e05c6f84d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java @@ -39,7 +39,7 @@ public class Thread extends VMObject { private static AddressField currentWaitingMonitorField; private static AddressField osThreadField; - private static JLongField allocatedBytesField; + private static CIntegerField allocatedBytesField; static { VM.registerVMInitializedObserver(new Observer() { @@ -60,7 +60,7 @@ public class Thread extends VMObject { tlabFieldOffset = typeThread.getField("_tlab").getOffset(); currentPendingMonitorField = typeJavaThread.getAddressField("_current_pending_monitor"); currentWaitingMonitorField = typeJavaThread.getAddressField("_current_waiting_monitor"); - allocatedBytesField = typeThread.getJLongField("_allocated_bytes"); + allocatedBytesField = typeThread.getCIntegerField("_allocated_bytes"); } public Thread(Address addr) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java index 11f03a6003e..683e4b67935 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java @@ -76,10 +76,9 @@ public class ThreadLocalAllocBuffer extends VMObject { private long endReserve() { long labAlignmentReserve = VM.getVM().getLabAlignmentReserve(); - long reserveForAllocationPrefetch = VM.getVM().getReserveForAllocationPrefetch(); long heapWordSize = VM.getVM().getHeapWordSize(); - return Math.max(labAlignmentReserve, reserveForAllocationPrefetch) * heapWordSize; + return labAlignmentReserve * heapWordSize; } /** Support for iteration over heap -- not sure how this will diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java index dc27a4fc59e..2ec96121934 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, 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 @@ -123,7 +123,6 @@ public class VM { private int invocationEntryBCI; private ReversePtrs revPtrs; private VMRegImpl vmregImpl; - private int reserveForAllocationPrefetch; private int labAlignmentReserve; // System.getProperties from debuggee VM @@ -145,7 +144,6 @@ public class VM { private static CIntegerType boolType; private Boolean sharingEnabled; private Boolean compressedOopsEnabled; - private Boolean compressedKlassPointersEnabled; private Boolean compactObjectHeadersEnabled; // command line flags supplied to VM - see struct JVMFlag in jvmFlag.hpp @@ -447,8 +445,6 @@ public class VM { boolType = (CIntegerType) db.lookupType("bool"); Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer"); - CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch"); - reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); Type collectedHeap = db.lookupType("CollectedHeap"); CIntegerField labAlignmentReserveField = collectedHeap.getCIntegerField("_lab_alignment_reserve"); @@ -518,11 +514,7 @@ public class VM { heapOopSize = (int)getOopSize(); } - if (isCompressedKlassPointersEnabled()) { - klassPtrSize = (int)getIntSize(); - } else { - klassPtrSize = (int)getOopSize(); // same as an oop - } + klassPtrSize = (int)getIntSize(); } /** This could be used by a reflective runtime system */ @@ -915,10 +907,6 @@ public class VM { return vmInternalInfo; } - public int getReserveForAllocationPrefetch() { - return reserveForAllocationPrefetch; - } - public int getLabAlignmentReserve() { return labAlignmentReserve; } @@ -945,15 +933,6 @@ public class VM { return compressedOopsEnabled.booleanValue(); } - public boolean isCompressedKlassPointersEnabled() { - if (compressedKlassPointersEnabled == null) { - Flag flag = getCommandLineFlag("UseCompressedClassPointers"); - compressedKlassPointersEnabled = (flag == null) ? Boolean.FALSE: - (flag.getBool()? Boolean.TRUE: Boolean.FALSE); - } - return compressedKlassPointersEnabled.booleanValue(); - } - public boolean isCompactObjectHeadersEnabled() { if (compactObjectHeadersEnabled == null) { Flag flag = getCommandLineFlag("UseCompactObjectHeaders"); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArgInfoData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64ContinuationEntry.java similarity index 58% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArgInfoData.java rename to src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64ContinuationEntry.java index 992d86a02ec..b373167a37c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ArgInfoData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64ContinuationEntry.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. * 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,36 +22,22 @@ * questions. * */ +package sun.jvm.hotspot.runtime.aarch64; -package sun.jvm.hotspot.oops; +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.ContinuationEntry; +import sun.jvm.hotspot.runtime.Frame; -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -public class ArgInfoData extends ArrayData { +public class AARCH64ContinuationEntry extends ContinuationEntry { - public ArgInfoData(DataLayout layout) { - super(layout); - } - - int numberOfArgs() { - return arrayLen(); - } - - int argModified(int arg) { - return arrayUintAt(arg); - } - - public void printDataOn(PrintStream st) { - printShared(st, "ArgInfoData"); - int nargs = numberOfArgs(); - for (int i = 0; i < nargs; i++) { - st.print(" 0x" + Integer.toHexString(argModified(i))); + public AARCH64ContinuationEntry(Address addr) { + super(addr); } - st.println(); - } + + @Override + public Frame toFrame() { + return new AARCH64Frame(getEntrySP(), getEntrySP(), getEntryFP(), getEntryPC()); + } + } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java index 7233d508cbc..5e73150c6cf 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -206,6 +206,11 @@ public class AARCH64Frame extends Frame { public Address getSP() { return raw_sp; } public Address getID() { return raw_sp; } + @Override + public void setSP(Address newSP) { + raw_sp = newSP; + } + // FIXME: not implemented yet public boolean isSignalHandlerFrameDbg() { return false; } public int getSignalNumberDbg() { return 0; } @@ -360,16 +365,6 @@ public class AARCH64Frame extends Frame { map.setLocation(fp, savedFPAddr); } - private Frame senderForContinuationStub(AARCH64RegisterMap map, CodeBlob cb) { - var contEntry = map.getThread().getContEntry(); - - Address senderSP = contEntry.getEntrySP(); - Address senderPC = contEntry.getEntryPC(); - Address senderFP = contEntry.getEntryFP(); - - return new AARCH64Frame(senderSP, senderFP, senderPC); - } - private Frame senderForCompiledFrame(AARCH64RegisterMap map, CodeBlob cb) { if (DEBUG) { System.out.println("senderForCompiledFrame"); @@ -416,6 +411,22 @@ public class AARCH64Frame extends Frame { updateMapWithSavedLink(map, savedFPAddr); } + if (Continuation.isReturnBarrierEntry(senderPC)) { + // We assume WalkContinuation is "WalkContinuation::skip". + // It is same with c'tor arguments of RegisterMap in frame::next_frame(). + // + // HotSpot code in cpu/aarch64/frame_aarch64.inline.hpp: + // + // if (Continuation::is_return_barrier_entry(sender_pc)) { + // if (map->walk_cont()) { // about to walk into an h-stack + // return Continuation::top_frame(*this, map); + // } else { + // return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp); + // } + // } + return Continuation.continuationBottomSender(map.getThread(), this, senderSP); + } + return new AARCH64Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64ContinuationEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64ContinuationEntry.java new file mode 100644 index 00000000000..3cbebfce2f4 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64ContinuationEntry.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. + * 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 sun.jvm.hotspot.runtime.amd64; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.ContinuationEntry; +import sun.jvm.hotspot.runtime.Frame; + + +public class AMD64ContinuationEntry extends ContinuationEntry { + + public AMD64ContinuationEntry(Address addr) { + super(addr); + } + + @Override + public Frame toFrame() { + return new AMD64Frame(getEntrySP(), getEntrySP(), getEntryFP(), getEntryPC()); + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java index fa9d50160e1..2b78157e2b2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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 @@ -206,6 +206,11 @@ public class AMD64Frame extends Frame { public Address getSP() { return raw_sp; } public Address getID() { return raw_sp; } + @Override + public void setSP(Address newSP) { + raw_sp = newSP; + } + // FIXME: not implemented yet (should be done for Solaris) public boolean isSignalHandlerFrameDbg() { return false; } public int getSignalNumberDbg() { return 0; } @@ -258,6 +263,23 @@ public class AMD64Frame extends Frame { // update it accordingly map.setIncludeArgumentOops(false); + // HotSpot has following code in frame::sender_raw() at frame_x86.inline.hpp, however + // in_cont() should be false. + // + // if (map->in_cont()) { // already in an h-stack + // return map->stack_chunk()->sender(*this, map); + // } + // + // in_cont() returns true if _chunk() is not null. + // + // frame::next_frame() creates RegisterMap instance with 4 arguments. + // It sets RegisterMap::WalkContinuation::skip to final argument (walk_cont), + // therefore _chunk will not be initialized by the following code in c'tor of RegisterMap. + // + // if (walk_cont == WalkContinuation::include && thread != nullptr && thread->last_continuation() != nullptr) { + // _chunk = stackChunkHandle(Thread::current()->handle_area()->allocate_null_handle(), true /* dummy */); + // } + if (isEntryFrame()) return senderForEntryFrame(map); if (isInterpretedFrame()) return senderForInterpreterFrame(map); @@ -360,16 +382,6 @@ public class AMD64Frame extends Frame { map.setLocation(rbp, savedFPAddr); } - private Frame senderForContinuationStub(AMD64RegisterMap map, CodeBlob cb) { - var contEntry = map.getThread().getContEntry(); - - Address senderSP = contEntry.getEntrySP(); - Address senderPC = contEntry.getEntryPC(); - Address senderFP = contEntry.getEntryFP(); - - return new AMD64Frame(senderSP, senderFP, senderPC); - } - private Frame senderForCompiledFrame(AMD64RegisterMap map, CodeBlob cb) { if (DEBUG) { System.out.println("senderForCompiledFrame"); @@ -408,6 +420,22 @@ public class AMD64Frame extends Frame { updateMapWithSavedLink(map, savedFPAddr); } + if (Continuation.isReturnBarrierEntry(senderPC)) { + // We assume WalkContinuation is "WalkContinuation::skip". + // It is same with c'tor arguments of RegisterMap in frame::next_frame(). + // + // HotSpot code in cpu/x86/frame_x86.inline.hpp: + // + // if (Continuation::is_return_barrier_entry(sender_pc)) { + // if (map->walk_cont()) { // about to walk into an h-stack + // return Continuation::top_frame(*this, map); + // } else { + // return Continuation::continuation_bottom_sender(map->thread(), *this, sender_sp); + // } + // } + return Continuation.continuationBottomSender(map.getThread(), this, senderSP); + } + return new AMD64Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64ContinuationEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64ContinuationEntry.java new file mode 100644 index 00000000000..fac71cc9953 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64ContinuationEntry.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. + * 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 sun.jvm.hotspot.runtime.ppc64; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.ContinuationEntry; +import sun.jvm.hotspot.runtime.Frame; + + +public class PPC64ContinuationEntry extends ContinuationEntry { + + public PPC64ContinuationEntry(Address addr) { + super(addr); + } + + @Override + public Frame toFrame() { + return new PPC64Frame(getEntrySP(), getEntrySP(), getEntryFP(), getEntryPC()); + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java index cae034c9613..a663d016011 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -198,6 +198,11 @@ public class PPC64Frame extends Frame { public Address getSP() { return raw_sp; } public Address getID() { return raw_sp; } + @Override + public void setSP(Address newSP) { + raw_sp = newSP; + } + // FIXME: not implemented yet (should be done for Solaris/PPC64) public boolean isSignalHandlerFrameDbg() { return false; } public int getSignalNumberDbg() { return 0; } @@ -260,9 +265,7 @@ public class PPC64Frame extends Frame { if (cb != null) { if (cb.isUpcallStub()) { return senderForUpcallStub(map, (UpcallStub)cb); - } else if (cb.isContinuationStub()) { - return senderForContinuationStub(map, cb); - } else { + } else if (cb.getFrameSize() > 0) { return senderForCompiledFrame(map, cb); } } @@ -337,16 +340,6 @@ public class PPC64Frame extends Frame { return new PPC64Frame(sp, unextendedSP, getLink(), getSenderPC()); } - private Frame senderForContinuationStub(PPC64RegisterMap map, CodeBlob cb) { - var contEntry = map.getThread().getContEntry(); - - Address sp = contEntry.getEntrySP(); - Address pc = contEntry.getEntryPC(); - Address fp = contEntry.getEntryFP(); - - return new PPC64Frame(sp, fp, pc); - } - private Frame senderForCompiledFrame(PPC64RegisterMap map, CodeBlob cb) { if (DEBUG) { System.out.println("senderForCompiledFrame"); @@ -379,6 +372,22 @@ public class PPC64Frame extends Frame { } } + if (Continuation.isReturnBarrierEntry(senderPC)) { + // We assume WalkContinuation is "WalkContinuation::skip". + // It is same with c'tor arguments of RegisterMap in frame::next_frame(). + // + // HotSpot code in cpu/ppc/frame_ppc.inline.hpp: + // + // if (Continuation::is_return_barrier_entry(sender_pc)) { + // if (map->walk_cont()) { // about to walk into an h-stack + // return Continuation::top_frame(*this, map); + // } else { + // return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp); + // } + // } + return Continuation.continuationBottomSender(map.getThread(), this, senderSP); + } + return new PPC64Frame(senderSP, getLink(), senderPC); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64ContinuationEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64ContinuationEntry.java new file mode 100644 index 00000000000..ec04498a6c0 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64ContinuationEntry.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA. + * 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 sun.jvm.hotspot.runtime.riscv64; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.ContinuationEntry; +import sun.jvm.hotspot.runtime.Frame; + + +public class RISCV64ContinuationEntry extends ContinuationEntry { + + public RISCV64ContinuationEntry(Address addr) { + super(addr); + } + + @Override + public Frame toFrame() { + return new RISCV64Frame(getEntrySP(), getEntrySP(), getEntryFP(), getEntryPC()); + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java index 44c8f4c679c..a35c0735979 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. * Copyright (c) 2021, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -201,6 +201,11 @@ public class RISCV64Frame extends Frame { public Address getSP() { return raw_sp; } public Address getID() { return raw_sp; } + @Override + public void setSP(Address newSP) { + raw_sp = newSP; + } + // FIXME: not implemented yet public boolean isSignalHandlerFrameDbg() { return false; } public int getSignalNumberDbg() { return 0; } @@ -264,9 +269,7 @@ public class RISCV64Frame extends Frame { if (cb != null) { if (cb.isUpcallStub()) { return senderForUpcallStub(map, (UpcallStub)cb); - } else if (cb.isContinuationStub()) { - return senderForContinuationStub(map, cb); - } else { + } else if (cb.getFrameSize() > 0) { return senderForCompiledFrame(map, cb); } } @@ -354,16 +357,6 @@ public class RISCV64Frame extends Frame { map.setLocation(fp, savedFPAddr); } - private Frame senderForContinuationStub(RISCV64RegisterMap map, CodeBlob cb) { - var contEntry = map.getThread().getContEntry(); - - Address senderSP = contEntry.getEntrySP(); - Address senderPC = contEntry.getEntryPC(); - Address senderFP = contEntry.getEntryFP(); - - return new RISCV64Frame(senderSP, senderFP, senderPC); - } - private Frame senderForCompiledFrame(RISCV64RegisterMap map, CodeBlob cb) { if (DEBUG) { System.out.println("senderForCompiledFrame"); @@ -406,6 +399,22 @@ public class RISCV64Frame extends Frame { updateMapWithSavedLink(map, savedFPAddr); } + if (Continuation.isReturnBarrierEntry(senderPC)) { + // We assume WalkContinuation is "WalkContinuation::skip". + // It is same with c'tor arguments of RegisterMap in frame::next_frame(). + // + // HotSpot code in cpu/riscv/frame_riscv.inline.hpp: + // + // if (Continuation::is_return_barrier_entry(sender_pc)) { + // if (map->walk_cont()) { // about to walk into an h-stack + // return Continuation::top_frame(*this, map); + // } else { + // return Continuation::continuation_bottom_sender(map->thread(), *this, l_sender_sp); + // } + // } + return Continuation.continuationBottomSender(map.getThread(), this, senderSP); + } + return new RISCV64Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java index 51f40fad12b..80ea272ea2c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, 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 @@ -121,6 +121,9 @@ public abstract class AbstractHeapGraphWriter implements HeapGraphWriter { // write JNI global handles writeGlobalJNIHandles(); + // write classes in null class loader data + writeStickyClasses(); + } catch (RuntimeException re) { handleRuntimeException(re); } @@ -168,6 +171,9 @@ public abstract class AbstractHeapGraphWriter implements HeapGraphWriter { } } + protected void writeStickyClasses() throws IOException { + } + protected void writeGlobalJNIHandle(Address handleAddr) throws IOException { } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java index ce048bf2d86..2745e1f0783 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @@ -967,6 +967,22 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter { } } + @Override + protected void writeStickyClasses() throws IOException { + ClassLoaderData.theNullClassLoaderData().classesDo(k -> { + if (k instanceof InstanceKlass) { + try { + int size = 1 + (int)VM.getVM().getAddressSize(); + writeHeapRecordPrologue(size); + out.writeByte((byte)HPROF_GC_ROOT_STICKY_CLASS); + writeClassID(k); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + }); + } + protected void writeObjectArray(ObjArray array) throws IOException { int headerSize = getArrayHeaderSize(true); final int length = calculateArrayMaxLength(array.getLength(), @@ -1304,6 +1320,10 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter { writeObjectID(address); } + private void writeClassID(Klass k) throws IOException { + writeObjectID(k.getJavaMirror()); + } + private void writeSymbolID(Symbol sym) throws IOException { assert names.contains(sym); long address = (sym != null) ? getAddressValue(sym.getAddress()) : getAddressValue(null); diff --git a/src/jdk.hotspot.agent/share/man/jhsdb.md b/src/jdk.hotspot.agent/share/man/jhsdb.md index 4c6be775ece..f329a2fea6f 100644 --- a/src/jdk.hotspot.agent/share/man/jhsdb.md +++ b/src/jdk.hotspot.agent/share/man/jhsdb.md @@ -119,20 +119,20 @@ The `jhsdb` tool can be launched in any one of the following modes: ## Options for the debugd Mode -`--serverid` *server-id* +[`--serverid`]{#debugd-option--serverid} *server-id* : An optional unique ID for this debug server. This is required if multiple debug servers are run on the same machine. -`--rmiport` *port* +[`--rmiport`]{#debugd-option--rmiport} *port* : Sets the port number to which the RMI connector is bound. If not specified a random available port is used. -`--registryport` *port* +[`--registryport`]{#debugd-option--registryport} *port* : Sets the RMI registry port. This option overrides the system property 'sun.jvm.hotspot.rmi.port'. If not specified, the system property is used. If the system property is not set, the default port 1099 is used. -`--hostname` *hostname* +[`--hostname`]{#debugd-option--hostname} *hostname* : Sets the hostname the RMI connector is bound. The value could be a hostname or an IPv4/IPv6 address. This option overrides the system property 'java.rmi.server.hostname'. If not specified, the system property is used. @@ -140,10 +140,10 @@ The `jhsdb` tool can be launched in any one of the following modes: ## Options for the jinfo Mode -`--flags` +[`--flags`]{#jinfo-option--flags} : Prints the VM flags. -`--sysprops` +[`--sysprops`]{#jinfo-option--sysprops} : Prints the Java system properties. no option @@ -154,33 +154,33 @@ no option no option : Prints the same information as Solaris `pmap`. -`--heap` +[`--heap`]{#jmap-option--heap} : Prints the `java` heap summary. -`--binaryheap` +[`--binaryheap`]{#jmap-option--binaryheap} : Dumps the `java` heap in `hprof` binary format. -`--dumpfile` *name* +[`--dumpfile`]{#jmap-option--dumpfile} *name* : The name of the dumpfile. -`--histo` +[`--histo`]{#jmap-option--histo} : Prints the histogram of `java` object heap. -`--clstats` +[`--clstats`]{#jmap-option--clstats} : Prints the class loader statistics. -`--finalizerinfo` +[`--finalizerinfo`]{#jmap-option--finalizerinfo} : Prints the information on objects awaiting finalization. ## Options for the jstack Mode -`--locks` +[`--locks`]{#jstack-option--locks} : Prints the `java.util.concurrent` locks information. -`--mixed` +[`--mixed`]{#jstack-option--mixed} : Attempts to print both `java` and native frames if the platform allows it. ## Options for the jsnap Mode -`--all` +[`--all`]{#jsnap-option--all} : Prints all performance counters. diff --git a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java index a0271fed146..fb10ecb0755 100644 --- a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java +++ b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,7 +75,7 @@ import java.util.concurrent.Executor; * *

    The following table shows some request URIs and which, if any context they would * match with: - * + *
    description
    * * * @@ -278,10 +278,20 @@ public abstract class HttpServer { *

    The class overview describes how incoming request URIs are * mapped to HttpContext instances. * - * @apiNote The path should generally, but is not required to, end with '/'. - * If the path does not end with '/', eg such as with {@code "/foo"} then - * this would match requests with a path of {@code "/foobar"} or - * {@code "/foo/bar"}. + * @apiNote + * The path should generally, but is not required to, end with {@code /}. + * If the path does not end with {@code /}, e.g., such as with {@code /foo}, + * then some implementations may use string prefix matching where + * this context path matches request paths {@code /foo}, + * {@code /foo/bar}, or {@code /foobar}. Others may use path prefix + * matching where {@code /foo} matches request paths {@code /foo} and + * {@code /foo/bar}, but not {@code /foobar}. + * + * @implNote + * By default, the JDK built-in implementation uses path prefix matching. + * String prefix matching can be enabled using the + * {@link jdk.httpserver/##sun.net.httpserver.pathMatcher sun.net.httpserver.pathMatcher} + * system property. * * @param path the root URI path to associate the context with * @param handler the handler to invoke for incoming requests @@ -289,6 +299,8 @@ public abstract class HttpServer { * already exists for this path * @throws NullPointerException if either path, or handler are {@code null} * @return an instance of {@code HttpContext} + * + * @see jdk.httpserver/##sun.net.httpserver.pathMatcher sun.net.httpserver.pathMatcher */ public abstract HttpContext createContext(String path, HttpHandler handler); @@ -308,16 +320,28 @@ public abstract class HttpServer { *

    The class overview describes how incoming request URIs are * mapped to {@code HttpContext} instances. * - * @apiNote The path should generally, but is not required to, end with '/'. - * If the path does not end with '/', eg such as with {@code "/foo"} then - * this would match requests with a path of {@code "/foobar"} or - * {@code "/foo/bar"}. + * @apiNote + * The path should generally, but is not required to, end with {@code /}. + * If the path does not end with {@code /}, e.g., such as with {@code /foo}, + * then some implementations may use string prefix matching where + * this context path matches request paths {@code /foo}, + * {@code /foo/bar}, or {@code /foobar}. Others may use path prefix + * matching where {@code /foo} matches request paths + * {@code /foo} and {@code /foo/bar}, but not {@code /foobar}. + * + * @implNote + * By default, the JDK built-in implementation uses path prefix matching. + * String prefix matching can be enabled using the + * {@link jdk.httpserver/##sun.net.httpserver.pathMatcher sun.net.httpserver.pathMatcher} + * system property. * * @param path the root URI path to associate the context with * @throws IllegalArgumentException if path is invalid, or if a context * already exists for this path * @throws NullPointerException if path is {@code null} * @return an instance of {@code HttpContext} + * + * @see jdk.httpserver/##sun.net.httpserver.pathMatcher sun.net.httpserver.pathMatcher */ public abstract HttpContext createContext(String path); diff --git a/src/jdk.httpserver/share/classes/module-info.java b/src/jdk.httpserver/share/classes/module-info.java index ac147582b14..0a0e77c628f 100644 --- a/src/jdk.httpserver/share/classes/module-info.java +++ b/src/jdk.httpserver/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -101,7 +101,35 @@ import com.sun.net.httpserver.*; *

  • {@systemProperty sun.net.httpserver.nodelay} (default: false)
    * Boolean value, which if true, sets the {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} * socket option on all incoming connections. - *

  • + * + *
  • + *

    {@systemProperty sun.net.httpserver.pathMatcher} (default: + * {@code pathPrefix})
    + * + * The path matching scheme used to route requests to context handlers. + * The property can be configured with one of the following values:

    + * + *
    + *
    + *
    {@code pathPrefix} (default)
    + *
    The request path must begin with the context path and all matching path + * segments must be identical. For instance, the context path {@code /foo} + * would match request paths {@code /foo}, {@code /foo/}, and {@code /foo/bar}, + * but not {@code /foobar}.
    + *
    {@code stringPrefix}
    + *
    The request path string must begin with the context path string. For + * instance, the context path {@code /foo} would match request paths + * {@code /foo}, {@code /foo/}, {@code /foo/bar}, and {@code /foobar}. + *
    + *
    + *
    + * + *

    In case of a blank or invalid value, the default will be used.

    + * + *

    This property and the ability to restore the string prefix matching + * behavior may be removed in a future release.

    + *
  • + * * * @apiNote The API and SPI in this module are designed and implemented to support a minimal * HTTP server and simple HTTP semantics primarily. diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ChunkedOutputStream.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ChunkedOutputStream.java index fd1a940c0a5..0af59f1d1a7 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ChunkedOutputStream.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ChunkedOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -154,9 +154,7 @@ class ChunkedOutputStream extends FilterOutputStream } finally { closed = true; } - - Event e = new Event.WriteFinished(t); - t.getHttpContext().getServerImpl().addEvent(e); + t.postExchangeFinished(true); } public void flush() throws IOException { diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java index 96b55575928..14a07b3a677 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,13 +26,22 @@ package sun.net.httpserver; import java.util.*; +import java.util.function.BiPredicate; class ContextList { + private static final System.Logger LOGGER = System.getLogger(ContextList.class.getName()); + private final LinkedList list = new LinkedList<>(); public synchronized void add(HttpContextImpl ctx) { + assert ctx != null; + // `findContext(String protocol, String path, ContextPathMatcher matcher)` + // expects the protocol to be lower-cased using ROOT locale, hence: + assert ctx.getProtocol().equals(ctx.getProtocol().toLowerCase(Locale.ROOT)); assert ctx.getPath() != null; + // `ContextPathMatcher` expects context paths to be non-empty: + assert !ctx.getPath().isEmpty(); if (contains(ctx)) { throw new IllegalArgumentException("cannot add context to list"); } @@ -40,21 +49,25 @@ class ContextList { } boolean contains(HttpContextImpl ctx) { - return findContext(ctx.getProtocol(), ctx.getPath(), true) != null; + return findContext(ctx.getProtocol(), ctx.getPath(), ContextPathMatcher.EXACT) != null; } public synchronized int size() { return list.size(); } - /* initially contexts are located only by protocol:path. - * Context with longest prefix matches (currently case-sensitive) + /** + * {@return the context with the longest case-sensitive prefix match} + * + * @param protocol the request protocol + * @param path the request path */ - synchronized HttpContextImpl findContext(String protocol, String path) { - return findContext(protocol, path, false); + HttpContextImpl findContext(String protocol, String path) { + var matcher = ContextPathMatcher.ofConfiguredPrefixPathMatcher(); + return findContext(protocol, path, matcher); } - synchronized HttpContextImpl findContext(String protocol, String path, boolean exact) { + private synchronized HttpContextImpl findContext(String protocol, String path, ContextPathMatcher matcher) { protocol = protocol.toLowerCase(Locale.ROOT); String longest = ""; HttpContextImpl lc = null; @@ -63,9 +76,7 @@ class ContextList { continue; } String cpath = ctx.getPath(); - if (exact && !cpath.equals(path)) { - continue; - } else if (!exact && !path.startsWith(cpath)) { + if (!matcher.test(cpath, path)) { continue; } if (cpath.length() > longest.length()) { @@ -76,10 +87,167 @@ class ContextList { return lc; } + private enum ContextPathMatcher implements BiPredicate { + + /** + * Tests if both the request path and the context path are identical. + */ + EXACT(String::equals), + + /** + * Tests string prefix matches where the request path string + * starts with the context path string. + * + *

    Examples

    + * + *
    description
    Request URI
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Context pathRequest path
    /foo/foo//foo/bar/foobar
    /YYYY
    /fooYYYY
    /foo/NYYN
    + */ + STRING_PREFIX((contextPath, requestPath) -> requestPath.startsWith(contextPath)), + + /** + * Tests path prefix matches where path segments must have an + * exact match. + * + *

    Examples

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Context pathRequest path
    /foo/foo//foo/bar/foobar
    /YYYY
    /fooYYYN
    /foo/NYYN
    + */ + PATH_PREFIX((contextPath, requestPath) -> { + + // Does the request path prefix match? + if (!requestPath.startsWith(contextPath)) { + return false; + } + + // Is it an exact match? + int contextPathLength = contextPath.length(); + if (requestPath.length() == contextPathLength) { + return true; + } + + // Is it a path-prefix match? + assert contextPathLength > 0; + return + // Case 1: The request path starts with the context + // path, but the context path has an extra path + // separator suffix. For instance, the context path is + // `/foo/` and the request path is `/foo/bar`. + contextPath.charAt(contextPathLength - 1) == '/' || + // Case 2: The request path starts with the + // context path, but the request path has an + // extra path separator suffix. For instance, + // context path is `/foo` and the request path + // is `/foo/` or `/foo/bar`. + requestPath.charAt(contextPathLength) == '/'; + + }); + + private final BiPredicate predicate; + + ContextPathMatcher(BiPredicate predicate) { + this.predicate = predicate; + } + + @Override + public boolean test(String contextPath, String requestPath) { + return predicate.test(contextPath, requestPath); + } + + private static ContextPathMatcher ofConfiguredPrefixPathMatcher() { + var propertyName = "sun.net.httpserver.pathMatcher"; + var propertyValueDefault = "pathPrefix"; + var propertyValue = System.getProperty(propertyName, propertyValueDefault); + return switch (propertyValue) { + case "pathPrefix" -> ContextPathMatcher.PATH_PREFIX; + case "stringPrefix" -> ContextPathMatcher.STRING_PREFIX; + default -> { + LOGGER.log( + System.Logger.Level.WARNING, + "System property \"{}\" contains an invalid value: \"{}\". Falling back to the default: \"{}\"", + propertyName, propertyValue, propertyValueDefault); + yield ContextPathMatcher.PATH_PREFIX; + } + }; + } + + } + public synchronized void remove(String protocol, String path) throws IllegalArgumentException { - HttpContextImpl ctx = findContext(protocol, path, true); + HttpContextImpl ctx = findContext(protocol, path, ContextPathMatcher.EXACT); if (ctx == null) { throw new IllegalArgumentException("cannot remove element from list"); } diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/Event.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/Event.java index 18c2535492b..41ce83596b7 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/Event.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/Event.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,13 +47,15 @@ abstract sealed class Event { } /** - * Event indicating that writing is finished for a given exchange. + * Event indicating that the exchange is finished, + * without having necessarily read the complete + * request or sent the complete response. + * Typically, this event is posted when invoking + * the filter chain throws an exception. */ - static final class WriteFinished extends Event { - WriteFinished(ExchangeImpl t) { + static final class ExchangeFinished extends Event { + ExchangeFinished(ExchangeImpl t) { super(Objects.requireNonNull(t)); - assert !t.writefinished; - t.writefinished = true; } } } diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java index ad6805938a2..57296842db2 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,10 +32,10 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.lang.System.Logger; import java.lang.System.Logger.Level; -import java.text.*; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; import com.sun.net.httpserver.*; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; @@ -46,7 +46,7 @@ class ExchangeImpl { Headers reqHdrs, rspHdrs; Request req; String method; - boolean writefinished; + private boolean writefinished; URI uri; HttpConnection connection; long reqContentLen; @@ -87,6 +87,19 @@ class ExchangeImpl { HttpPrincipal principal; ServerImpl server; + // Used to control that ServerImpl::endExchange is called + // exactly once for this exchange. ServerImpl::endExchange decrements + // the refcount that was incremented by calling ServerImpl::startExchange + // in this ExchangeImpl constructor. + private final AtomicBoolean ended = new AtomicBoolean(); + + // Used to ensure that the Event.ExchangeFinished is posted only + // once for this exchange. The Event.ExchangeFinished is what will + // eventually cause the ServerImpl::finishedLatch to be triggered, + // once the number of active exchanges reaches 0 and ServerImpl::stop + // has been requested. + private final AtomicBoolean finished = new AtomicBoolean(); + ExchangeImpl( String m, URI u, Request req, long len, HttpConnection connection ) throws IOException { @@ -107,6 +120,55 @@ class ExchangeImpl { server.startExchange(); } + /** + * When true, writefinished indicates that all bytes expected + * by the client have been written to the response body + * outputstream, and that the response body outputstream has + * been closed. When all bytes have also been pulled from + * the request body input stream, this makes it possible to + * reuse the connection for the next request. + */ + synchronized boolean writefinished() { + return writefinished; + } + + /** + * Calls ServerImpl::endExchange if not already called for this + * exchange. ServerImpl::endExchange must be called exactly once + * per exchange, and this method ensures that it is not called + * more than once for this exchange. + * @return the new (or current) value of the exchange count. + */ + int endExchange() { + // only call server.endExchange(); once per exchange + if (ended.compareAndSet(false, true)) { + return server.endExchange(); + } + return server.getExchangeCount(); + } + + /** + * Posts the ExchangeFinished event if not already posted. + * If `writefinished` is true, marks the exchange as {@link + * #writefinished()} so that the connection can be reused. + * @param writefinished whether all bytes expected by the + * client have been writen out to the + * response body output stream. + */ + void postExchangeFinished(boolean writefinished) { + // only post ExchangeFinished once per exchange + if (finished.compareAndSet(false, true)) { + if (writefinished) { + synchronized (this) { + assert this.writefinished == false; + this.writefinished = true; + } + } + Event e = new Event.ExchangeFinished(this); + getHttpContext().getServerImpl().addEvent(e); + } + } + public Headers getRequestHeaders() { return reqHdrs; } @@ -140,7 +202,7 @@ class ExchangeImpl { /* close the underlying connection if, * a) the streams not set up yet, no response can be sent, or * b) if the wrapper output stream is not set up, or - * c) if the close of the input/outpu stream fails + * c) if the close of the input/output stream fails */ try { if (uis_orig == null || uos == null) { @@ -157,6 +219,8 @@ class ExchangeImpl { uos.close(); } catch (IOException e) { connection.close(); + } finally { + postExchangeFinished(false); } } diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/FixedLengthOutputStream.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/FixedLengthOutputStream.java index 95de03d27fa..e9dbd93bb12 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/FixedLengthOutputStream.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/FixedLengthOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,8 +94,7 @@ class FixedLengthOutputStream extends FilterOutputStream is.close(); } catch (IOException e) {} } - Event e = new Event.WriteFinished(t); - t.getHttpContext().getServerImpl().addEvent(e); + t.postExchangeFinished(true); } // flush is a pass-through diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java index e8c8d336e03..94fe78b9c64 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -419,7 +419,8 @@ class ServerImpl { // Stopping marking the state as finished if stop is requested, // termination is in progress and exchange count is 0 if (r instanceof Event.StopRequested) { - logger.log(Level.TRACE, "Handling Stop Requested Event"); + logger.log(Level.TRACE, "Handling {0} event", + r.getClass().getSimpleName()); // checking if terminating is set to true final boolean terminatingCopy = terminating; @@ -437,10 +438,11 @@ class ServerImpl { HttpConnection c = t.getConnection(); try { - if (r instanceof Event.WriteFinished) { + if (r instanceof Event.ExchangeFinished) { - logger.log(Level.TRACE, "Write Finished"); - int exchanges = endExchange(); + logger.log(Level.TRACE, "Handling {0} event", + r.getClass().getSimpleName()); + int exchanges = t.endExchange(); if (terminating && exchanges == 0 && reqConnections.isEmpty()) { finishedLatch.countDown(); } @@ -842,68 +844,77 @@ class ServerImpl { tx = new ExchangeImpl( method, uri, req, clen, connection ); - String chdr = headers.getFirst("Connection"); - Headers rheaders = tx.getResponseHeaders(); + try { - if (chdr != null && chdr.equalsIgnoreCase("close")) { - tx.close = true; - } - if (version.equalsIgnoreCase("http/1.0")) { - tx.http10 = true; - if (chdr == null) { + String chdr = headers.getFirst("Connection"); + Headers rheaders = tx.getResponseHeaders(); + + if (chdr != null && chdr.equalsIgnoreCase("close")) { tx.close = true; - rheaders.set("Connection", "close"); - } else if (chdr.equalsIgnoreCase("keep-alive")) { - rheaders.set("Connection", "keep-alive"); - int idleSeconds = (int) (ServerConfig.getIdleIntervalMillis() / 1000); - String val = "timeout=" + idleSeconds; - rheaders.set("Keep-Alive", val); } - } + if (version.equalsIgnoreCase("http/1.0")) { + tx.http10 = true; + if (chdr == null) { + tx.close = true; + rheaders.set("Connection", "close"); + } else if (chdr.equalsIgnoreCase("keep-alive")) { + rheaders.set("Connection", "keep-alive"); + int idleSeconds = (int) (ServerConfig.getIdleIntervalMillis() / 1000); + String val = "timeout=" + idleSeconds; + rheaders.set("Keep-Alive", val); + } + } - if (newconnection) { - connection.setParameters( - rawin, rawout, chan, engine, sslStreams, - sslContext, protocol, ctx, rawin - ); - } - /* check if client sent an Expect 100 Continue. - * In that case, need to send an interim response. - * In future API may be modified to allow app to - * be involved in this process. - */ - String exp = headers.getFirst("Expect"); - if (exp != null && exp.equalsIgnoreCase("100-continue")) { - logReply(100, requestLine, null); - sendReply( - Code.HTTP_CONTINUE, false, null - ); - } - /* uf is the list of filters seen/set by the user. - * sf is the list of filters established internally - * and which are not visible to the user. uc and sc - * are the corresponding Filter.Chains. - * They are linked together by a LinkHandler - * so that they can both be invoked in one call. - */ - final List sf = ctx.getSystemFilters(); - final List uf = ctx.getFilters(); + if (newconnection) { + connection.setParameters( + rawin, rawout, chan, engine, sslStreams, + sslContext, protocol, ctx, rawin + ); + } + /* check if client sent an Expect 100 Continue. + * In that case, need to send an interim response. + * In future API may be modified to allow app to + * be involved in this process. + */ + String exp = headers.getFirst("Expect"); + if (exp != null && exp.equalsIgnoreCase("100-continue")) { + logReply(100, requestLine, null); + sendReply( + Code.HTTP_CONTINUE, false, null + ); + } + /* uf is the list of filters seen/set by the user. + * sf is the list of filters established internally + * and which are not visible to the user. uc and sc + * are the corresponding Filter.Chains. + * They are linked together by a LinkHandler + * so that they can both be invoked in one call. + */ + final List sf = ctx.getSystemFilters(); + final List uf = ctx.getFilters(); - final Filter.Chain sc = new Filter.Chain(sf, ctx.getHandler()); - final Filter.Chain uc = new Filter.Chain(uf, new LinkHandler(sc)); + final Filter.Chain sc = new Filter.Chain(sf, ctx.getHandler()); + final Filter.Chain uc = new Filter.Chain(uf, new LinkHandler(sc)); - /* set up the two stream references */ - tx.getRequestBody(); - tx.getResponseBody(); - if (https) { - uc.doFilter(new HttpsExchangeImpl(tx)); - } else { - uc.doFilter(new HttpExchangeImpl(tx)); + /* set up the two stream references */ + tx.getRequestBody(); + tx.getResponseBody(); + if (https) { + uc.doFilter(new HttpsExchangeImpl(tx)); + } else { + uc.doFilter(new HttpExchangeImpl(tx)); + } + } catch (Throwable t) { + // release the exchange. + logger.log(Level.TRACE, "ServerImpl.Exchange", t); + if (!tx.writefinished()) { + closeConnection(connection); + } + tx.postExchangeFinished(false); } - } catch (Exception e) { logger.log(Level.TRACE, "ServerImpl.Exchange", e); - if (tx == null || !tx.writefinished) { + if (tx == null || !tx.writefinished()) { closeConnection(connection); } } catch (Throwable t) { diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/UndefLengthOutputStream.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/UndefLengthOutputStream.java index ecda32ecc31..9e1f949321a 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/UndefLengthOutputStream.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/UndefLengthOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, 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,8 +75,7 @@ class UndefLengthOutputStream extends FilterOutputStream is.close(); } catch (IOException e) {} } - Event e = new Event.WriteFinished(t); - t.getHttpContext().getServerImpl().addEvent(e); + t.postExchangeFinished(true); } // flush is a pass-through diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java index 5b762edfd3b..9ac90c08c27 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java @@ -24,17 +24,19 @@ */ package jdk.incubator.vector; -import java.util.Objects; - -import jdk.internal.vm.annotation.ForceInline; - import jdk.internal.misc.Unsafe; - +import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; import static jdk.incubator.vector.VectorOperators.*; -abstract class AbstractMask extends VectorMask { +abstract sealed class AbstractMask extends VectorMask + permits ByteVector64.ByteMask64, ByteVector128.ByteMask128, ByteVector256.ByteMask256, ByteVector512.ByteMask512, ByteVectorMax.ByteMaskMax, + DoubleVector64.DoubleMask64, DoubleVector128.DoubleMask128, DoubleVector256.DoubleMask256, DoubleVector512.DoubleMask512, DoubleVectorMax.DoubleMaskMax, + FloatVector64.FloatMask64, FloatVector128.FloatMask128, FloatVector256.FloatMask256, FloatVector512.FloatMask512, FloatVectorMax.FloatMaskMax, + IntVector64.IntMask64, IntVector128.IntMask128, IntVector256.IntMask256, IntVector512.IntMask512, IntVectorMax.IntMaskMax, + LongVector64.LongMask64, LongVector128.LongMask128, LongVector256.LongMask256, LongVector512.LongMask512, LongVectorMax.LongMaskMax, + ShortVector64.ShortMask64, ShortVector128.ShortMask128, ShortVector256.ShortMask256, ShortVector512.ShortMask512, ShortVectorMax.ShortMaskMax { AbstractMask(boolean[] bits) { super(bits); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java index 075400a0d4a..bea495f74fc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java @@ -25,10 +25,17 @@ package jdk.incubator.vector; import java.util.function.IntUnaryOperator; + import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -abstract class AbstractShuffle extends VectorShuffle { +abstract sealed class AbstractShuffle extends VectorShuffle + permits ByteVector64.ByteShuffle64, ByteVector128.ByteShuffle128, ByteVector256.ByteShuffle256, ByteVector512.ByteShuffle512, ByteVectorMax.ByteShuffleMax, + DoubleVector64.DoubleShuffle64, DoubleVector128.DoubleShuffle128, DoubleVector256.DoubleShuffle256, DoubleVector512.DoubleShuffle512, DoubleVectorMax.DoubleShuffleMax, + FloatVector64.FloatShuffle64, FloatVector128.FloatShuffle128, FloatVector256.FloatShuffle256, FloatVector512.FloatShuffle512, FloatVectorMax.FloatShuffleMax, + IntVector64.IntShuffle64, IntVector128.IntShuffle128, IntVector256.IntShuffle256, IntVector512.IntShuffle512, IntVectorMax.IntShuffleMax, + LongVector64.LongShuffle64, LongVector128.LongShuffle128, LongVector256.LongShuffle256, LongVector512.LongShuffle512, LongVectorMax.LongShuffleMax, + ShortVector64.ShortShuffle64, ShortVector128.ShortShuffle128, ShortVector256.ShortShuffle256, ShortVector512.ShortShuffle512, ShortVectorMax.ShortShuffleMax { static final IntUnaryOperator IDENTITY = i -> i; // Internal representation allows for a maximum index of E.MAX_VALUE - 1 diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java index 0f9edbe450c..3fd2be34346 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java @@ -24,39 +24,31 @@ */ package jdk.incubator.vector; -import java.lang.foreign.MemorySegment; -import jdk.internal.vm.annotation.ForceInline; -import jdk.internal.vm.annotation.Stable; import java.lang.reflect.Array; -import java.nio.ByteOrder; import java.util.Arrays; import java.util.function.Function; import java.util.function.IntUnaryOperator; -abstract class AbstractSpecies extends jdk.internal.vm.vector.VectorSupport.VectorSpecies - implements VectorSpecies { - @Stable +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.annotation.Stable; +import jdk.internal.vm.annotation.TrustFinalFields; + +@TrustFinalFields +abstract sealed class AbstractSpecies extends jdk.internal.vm.vector.VectorSupport.VectorSpecies + implements VectorSpecies + permits ByteVector.ByteSpecies, DoubleVector.DoubleSpecies, FloatVector.FloatSpecies, + IntVector.IntSpecies, LongVector.LongSpecies, ShortVector.ShortSpecies { final VectorShape vectorShape; - @Stable final LaneType laneType; - @Stable final int laneCount; - @Stable final int laneCountLog2P1; - @Stable final Class> vectorType; - @Stable final Class> maskType; - @Stable final Class> shuffleType; - @Stable final Function> vectorFactory; - @Stable final VectorShape indexShape; - @Stable final int maxScale, minScale; - @Stable final int vectorBitSize, vectorByteSize; AbstractSpecies(VectorShape vectorShape, @@ -150,6 +142,14 @@ abstract class AbstractSpecies extends jdk.internal.vm.vector.VectorSupport.V int laneTypeOrdinal() { return laneType.ordinal(); } + + @ForceInline + @SuppressWarnings("unchecked") + //NOT FINAL: SPECIALIZED + Class carrierType() { + return (Class) laneType.carrierType; + } + // FIXME: appeal to general method (see https://bugs.openjdk.org/browse/JDK-6176992) // replace usages of this method and remove @ForceInline @@ -326,7 +326,7 @@ abstract class AbstractSpecies extends jdk.internal.vm.vector.VectorSupport.V return makeDummyVector(); } private AbstractVector makeDummyVector() { - Object za = Array.newInstance(elementType(), laneCount); + Object za = Array.newInstance(carrierType(), laneCount); return dummyVector = vectorFactory.apply(za); // This is the only use of vectorFactory. // All other factory requests are routed @@ -421,8 +421,7 @@ abstract class AbstractSpecies extends jdk.internal.vm.vector.VectorSupport.V Object iotaArray() { // Create an iota array. It's OK if this is really slow, // because it happens only once per species. - Object ia = Array.newInstance(laneType.elementType, - laneCount); + Object ia = Array.newInstance(carrierType(), laneCount); assert(ia.getClass() == laneType.arrayType); checkValue(laneCount-1); // worst case for (int i = 0; i < laneCount; i++) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java index 80260c2bd30..ea8112cc2ae 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java @@ -25,22 +25,17 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; +import java.nio.ByteOrder; +import java.util.function.IntUnaryOperator; -import jdk.internal.foreign.AbstractMemorySegmentImpl; -import jdk.internal.foreign.Utils; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import java.lang.foreign.ValueLayout; -import java.lang.reflect.Array; -import java.nio.ByteOrder; -import java.util.Objects; -import java.util.function.IntUnaryOperator; - import static jdk.incubator.vector.VectorOperators.*; @SuppressWarnings("cast") -abstract class AbstractVector extends Vector { +abstract sealed class AbstractVector extends Vector + permits ByteVector, DoubleVector, FloatVector, IntVector, LongVector, ShortVector { /** * The order of vector bytes when stored in natural, * array elements of the same lane type. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index 36609807774..7231ada3273 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code byte} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class ByteVector extends AbstractVector { +public abstract sealed class ByteVector extends AbstractVector + permits ByteVector64, ByteVector128, ByteVector256, ByteVector512, ByteVectorMax { ByteVector(byte[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class ByteVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -4474,13 +4475,13 @@ public abstract class ByteVector extends AbstractVector { @Override @ForceInline public final ByteVector zero() { - if ((Class) vectorType() == ByteMaxVector.class) - return ByteMaxVector.ZERO; + if ((Class) vectorType() == ByteVectorMax.class) + return ByteVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Byte64Vector.ZERO; - case 128: return Byte128Vector.ZERO; - case 256: return Byte256Vector.ZERO; - case 512: return Byte512Vector.ZERO; + case 64: return ByteVector64.ZERO; + case 128: return ByteVector128.ZERO; + case 256: return ByteVector256.ZERO; + case 512: return ByteVector512.ZERO; } throw new AssertionError(); } @@ -4488,13 +4489,13 @@ public abstract class ByteVector extends AbstractVector { @Override @ForceInline public final ByteVector iota() { - if ((Class) vectorType() == ByteMaxVector.class) - return ByteMaxVector.IOTA; + if ((Class) vectorType() == ByteVectorMax.class) + return ByteVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Byte64Vector.IOTA; - case 128: return Byte128Vector.IOTA; - case 256: return Byte256Vector.IOTA; - case 512: return Byte512Vector.IOTA; + case 64: return ByteVector64.IOTA; + case 128: return ByteVector128.IOTA; + case 256: return ByteVector256.IOTA; + case 512: return ByteVector512.IOTA; } throw new AssertionError(); } @@ -4503,13 +4504,13 @@ public abstract class ByteVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == ByteMaxVector.class) - return ByteMaxVector.ByteMaxMask.maskAll(bit); + if ((Class) vectorType() == ByteVectorMax.class) + return ByteVectorMax.ByteMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Byte64Vector.Byte64Mask.maskAll(bit); - case 128: return Byte128Vector.Byte128Mask.maskAll(bit); - case 256: return Byte256Vector.Byte256Mask.maskAll(bit); - case 512: return Byte512Vector.Byte512Mask.maskAll(bit); + case 64: return ByteVector64.ByteMask64.maskAll(bit); + case 128: return ByteVector128.ByteMask128.maskAll(bit); + case 256: return ByteVector256.ByteMask256.maskAll(bit); + case 512: return ByteVector512.ByteMask512.maskAll(bit); } throw new AssertionError(); } @@ -4537,42 +4538,42 @@ public abstract class ByteVector extends AbstractVector { /** Species representing {@link ByteVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new ByteSpecies(VectorShape.S_64_BIT, - Byte64Vector.class, - Byte64Vector.Byte64Mask.class, - Byte64Vector.Byte64Shuffle.class, - Byte64Vector::new); + ByteVector64.class, + ByteVector64.ByteMask64.class, + ByteVector64.ByteShuffle64.class, + ByteVector64::new); /** Species representing {@link ByteVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new ByteSpecies(VectorShape.S_128_BIT, - Byte128Vector.class, - Byte128Vector.Byte128Mask.class, - Byte128Vector.Byte128Shuffle.class, - Byte128Vector::new); + ByteVector128.class, + ByteVector128.ByteMask128.class, + ByteVector128.ByteShuffle128.class, + ByteVector128::new); /** Species representing {@link ByteVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new ByteSpecies(VectorShape.S_256_BIT, - Byte256Vector.class, - Byte256Vector.Byte256Mask.class, - Byte256Vector.Byte256Shuffle.class, - Byte256Vector::new); + ByteVector256.class, + ByteVector256.ByteMask256.class, + ByteVector256.ByteShuffle256.class, + ByteVector256::new); /** Species representing {@link ByteVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new ByteSpecies(VectorShape.S_512_BIT, - Byte512Vector.class, - Byte512Vector.Byte512Mask.class, - Byte512Vector.Byte512Shuffle.class, - Byte512Vector::new); + ByteVector512.class, + ByteVector512.ByteMask512.class, + ByteVector512.ByteShuffle512.class, + ByteVector512::new); /** Species representing {@link ByteVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new ByteSpecies(VectorShape.S_Max_BIT, - ByteMaxVector.class, - ByteMaxVector.ByteMaxMask.class, - ByteMaxVector.ByteMaxShuffle.class, - ByteMaxVector::new); + ByteVectorMax.class, + ByteVectorMax.ByteMaskMax.class, + ByteVectorMax.ByteShuffleMax.class, + ByteVectorMax::new); /** * Preferred species for {@link ByteVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector128.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector128.java index 0b710938ede..36ea8d081a8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector128.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Byte128Vector extends ByteVector { +@ValueBased +final class ByteVector128 extends ByteVector { static final ByteSpecies VSPECIES = (ByteSpecies) ByteVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Byte128Vector.class; + static final Class VCLASS = ByteVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + static final Class ETYPE = byte.class; // used by the JVM - Byte128Vector(byte[] v) { + ByteVector128(byte[] v) { super(v); } - // For compatibility as Byte128Vector::new, + // For compatibility as ByteVector128::new, // stored into species.vectorFactory. - Byte128Vector(Object v) { + ByteVector128(Object v) { this((byte[]) v); } - static final Byte128Vector ZERO = new Byte128Vector(new byte[VLENGTH]); - static final Byte128Vector IOTA = new Byte128Vector(VSPECIES.iotaArray()); + static final ByteVector128 ZERO = new ByteVector128(new byte[VLENGTH]); + static final ByteVector128 IOTA = new ByteVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Byte128Vector extends ByteVector { @Override public final Class elementType() { return byte.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Byte.SIZE; } @@ -130,51 +135,51 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline - public final Byte128Vector broadcast(byte e) { - return (Byte128Vector) super.broadcastTemplate(e); // specialize + public final ByteVector128 broadcast(byte e) { + return (ByteVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Byte128Vector broadcast(long e) { - return (Byte128Vector) super.broadcastTemplate(e); // specialize + public final ByteVector128 broadcast(long e) { + return (ByteVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Byte128Mask maskFromArray(boolean[] bits) { - return new Byte128Mask(bits); + ByteMask128 maskFromArray(boolean[] bits) { + return new ByteMask128(bits); } @Override @ForceInline - Byte128Shuffle iotaShuffle() { return Byte128Shuffle.IOTA; } + ByteShuffle128 iotaShuffle() { return ByteShuffle128.IOTA; } @Override @ForceInline - Byte128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Byte128Shuffle) iotaShuffleTemplate((byte) start, (byte) step, wrap); + ByteShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (ByteShuffle128) iotaShuffleTemplate((byte) start, (byte) step, wrap); } @Override @ForceInline - Byte128Shuffle shuffleFromArray(int[] indices, int i) { return new Byte128Shuffle(indices, i); } + ByteShuffle128 shuffleFromArray(int[] indices, int i) { return new ByteShuffle128(indices, i); } @Override @ForceInline - Byte128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte128Shuffle(fn); } + ByteShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new ByteShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Byte128Vector vectorFactory(byte[] vec) { - return new Byte128Vector(vec); + ByteVector128 vectorFactory(byte[] vec) { + return new ByteVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Byte128Vector extends ByteVector { @ForceInline final @Override - Byte128Vector uOp(FUnOp f) { - return (Byte128Vector) super.uOpTemplate(f); // specialize + ByteVector128 uOp(FUnOp f) { + return (ByteVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Byte128Vector uOp(VectorMask m, FUnOp f) { - return (Byte128Vector) - super.uOpTemplate((Byte128Mask)m, f); // specialize + ByteVector128 uOp(VectorMask m, FUnOp f) { + return (ByteVector128) + super.uOpTemplate((ByteMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Byte128Vector bOp(Vector v, FBinOp f) { - return (Byte128Vector) super.bOpTemplate((Byte128Vector)v, f); // specialize + ByteVector128 bOp(Vector v, FBinOp f) { + return (ByteVector128) super.bOpTemplate((ByteVector128)v, f); // specialize } @ForceInline final @Override - Byte128Vector bOp(Vector v, + ByteVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Byte128Vector) - super.bOpTemplate((Byte128Vector)v, (Byte128Mask)m, + return (ByteVector128) + super.bOpTemplate((ByteVector128)v, (ByteMask128)m, f); // specialize } @@ -219,19 +224,19 @@ final class Byte128Vector extends ByteVector { @ForceInline final @Override - Byte128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Byte128Vector) - super.tOpTemplate((Byte128Vector)v1, (Byte128Vector)v2, + ByteVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (ByteVector128) + super.tOpTemplate((ByteVector128)v1, (ByteVector128)v2, f); // specialize } @ForceInline final @Override - Byte128Vector tOp(Vector v1, Vector v2, + ByteVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Byte128Vector) - super.tOpTemplate((Byte128Vector)v1, (Byte128Vector)v2, - (Byte128Mask)m, f); // specialize + return (ByteVector128) + super.tOpTemplate((ByteVector128)v1, (ByteVector128)v2, + (ByteMask128)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline - public Byte128Vector lanewise(Unary op) { - return (Byte128Vector) super.lanewiseTemplate(op); // specialize + public ByteVector128 lanewise(Unary op) { + return (ByteVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Byte128Vector lanewise(Unary op, VectorMask m) { - return (Byte128Vector) super.lanewiseTemplate(op, Byte128Mask.class, (Byte128Mask) m); // specialize + public ByteVector128 lanewise(Unary op, VectorMask m) { + return (ByteVector128) super.lanewiseTemplate(op, ByteMask128.class, (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector lanewise(Binary op, Vector v) { - return (Byte128Vector) super.lanewiseTemplate(op, v); // specialize + public ByteVector128 lanewise(Binary op, Vector v) { + return (ByteVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Byte128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Byte128Vector) super.lanewiseTemplate(op, Byte128Mask.class, v, (Byte128Mask) m); // specialize + public ByteVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (ByteVector128) super.lanewiseTemplate(op, ByteMask128.class, v, (ByteMask128) m); // specialize } /*package-private*/ @Override - @ForceInline Byte128Vector + @ForceInline ByteVector128 lanewiseShift(VectorOperators.Binary op, int e) { - return (Byte128Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ByteVector128) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Byte128Vector + @ForceInline ByteVector128 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Byte128Vector) super.lanewiseShiftTemplate(op, Byte128Mask.class, e, (Byte128Mask) m); // specialize + return (ByteVector128) super.lanewiseShiftTemplate(op, ByteMask128.class, e, (ByteMask128) m); // specialize } /*package-private*/ @Override @ForceInline public final - Byte128Vector + ByteVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Byte128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ByteVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Byte128Vector + ByteVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Byte128Vector) super.lanewiseTemplate(op, Byte128Mask.class, v1, v2, (Byte128Mask) m); // specialize + return (ByteVector128) super.lanewiseTemplate(op, ByteMask128.class, v1, v2, (ByteMask128) m); // specialize } @Override @ForceInline public final - Byte128Vector addIndex(int scale) { - return (Byte128Vector) super.addIndexTemplate(scale); // specialize + ByteVector128 addIndex(int scale) { + return (ByteVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Byte128Vector extends ByteVector { @ForceInline public final byte reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Byte128Mask.class, (Byte128Mask) m); // specialized + return super.reduceLanesTemplate(op, ByteMask128.class, (ByteMask128) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Byte128Vector extends ByteVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Byte128Mask.class, (Byte128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ByteMask128.class, (ByteMask128) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline - public final Byte128Shuffle toShuffle() { - return (Byte128Shuffle) toShuffle(vspecies(), false); + public final ByteShuffle128 toShuffle() { + return (ByteShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Byte128Mask test(Test op) { - return super.testTemplate(Byte128Mask.class, op); // specialize + public final ByteMask128 test(Test op) { + return super.testTemplate(ByteMask128.class, op); // specialize } @Override @ForceInline - public final Byte128Mask test(Test op, VectorMask m) { - return super.testTemplate(Byte128Mask.class, op, (Byte128Mask) m); // specialize + public final ByteMask128 test(Test op, VectorMask m) { + return super.testTemplate(ByteMask128.class, op, (ByteMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Byte128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Byte128Mask.class, op, v); // specialize + public final ByteMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(ByteMask128.class, op, v); // specialize } @Override @ForceInline - public final Byte128Mask compare(Comparison op, byte s) { - return super.compareTemplate(Byte128Mask.class, op, s); // specialize + public final ByteMask128 compare(Comparison op, byte s) { + return super.compareTemplate(ByteMask128.class, op, s); // specialize } @Override @ForceInline - public final Byte128Mask compare(Comparison op, long s) { - return super.compareTemplate(Byte128Mask.class, op, s); // specialize + public final ByteMask128 compare(Comparison op, long s) { + return super.compareTemplate(ByteMask128.class, op, s); // specialize } @Override @ForceInline - public final Byte128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Byte128Mask.class, op, v, (Byte128Mask) m); + public final ByteMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ByteMask128.class, op, v, (ByteMask128) m); } @Override @ForceInline - public Byte128Vector blend(Vector v, VectorMask m) { - return (Byte128Vector) - super.blendTemplate(Byte128Mask.class, - (Byte128Vector) v, - (Byte128Mask) m); // specialize + public ByteVector128 blend(Vector v, VectorMask m) { + return (ByteVector128) + super.blendTemplate(ByteMask128.class, + (ByteVector128) v, + (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector slice(int origin, Vector v) { - return (Byte128Vector) super.sliceTemplate(origin, v); // specialize + public ByteVector128 slice(int origin, Vector v) { + return (ByteVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Byte128Vector slice(int origin) { - return (Byte128Vector) super.sliceTemplate(origin); // specialize + public ByteVector128 slice(int origin) { + return (ByteVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Byte128Vector unslice(int origin, Vector w, int part) { - return (Byte128Vector) super.unsliceTemplate(origin, w, part); // specialize + public ByteVector128 unslice(int origin, Vector w, int part) { + return (ByteVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Byte128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Byte128Vector) - super.unsliceTemplate(Byte128Mask.class, + public ByteVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (ByteVector128) + super.unsliceTemplate(ByteMask128.class, origin, w, part, - (Byte128Mask) m); // specialize + (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector unslice(int origin) { - return (Byte128Vector) super.unsliceTemplate(origin); // specialize + public ByteVector128 unslice(int origin) { + return (ByteVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Byte128Vector rearrange(VectorShuffle s) { - return (Byte128Vector) - super.rearrangeTemplate(Byte128Shuffle.class, - (Byte128Shuffle) s); // specialize + public ByteVector128 rearrange(VectorShuffle s) { + return (ByteVector128) + super.rearrangeTemplate(ByteShuffle128.class, + (ByteShuffle128) s); // specialize } @Override @ForceInline - public Byte128Vector rearrange(VectorShuffle shuffle, + public ByteVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Byte128Vector) - super.rearrangeTemplate(Byte128Shuffle.class, - Byte128Mask.class, - (Byte128Shuffle) shuffle, - (Byte128Mask) m); // specialize + return (ByteVector128) + super.rearrangeTemplate(ByteShuffle128.class, + ByteMask128.class, + (ByteShuffle128) shuffle, + (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector rearrange(VectorShuffle s, + public ByteVector128 rearrange(VectorShuffle s, Vector v) { - return (Byte128Vector) - super.rearrangeTemplate(Byte128Shuffle.class, - (Byte128Shuffle) s, - (Byte128Vector) v); // specialize + return (ByteVector128) + super.rearrangeTemplate(ByteShuffle128.class, + (ByteShuffle128) s, + (ByteVector128) v); // specialize } @Override @ForceInline - public Byte128Vector compress(VectorMask m) { - return (Byte128Vector) - super.compressTemplate(Byte128Mask.class, - (Byte128Mask) m); // specialize + public ByteVector128 compress(VectorMask m) { + return (ByteVector128) + super.compressTemplate(ByteMask128.class, + (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector expand(VectorMask m) { - return (Byte128Vector) - super.expandTemplate(Byte128Mask.class, - (Byte128Mask) m); // specialize + public ByteVector128 expand(VectorMask m) { + return (ByteVector128) + super.expandTemplate(ByteMask128.class, + (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector selectFrom(Vector v) { - return (Byte128Vector) - super.selectFromTemplate((Byte128Vector) v); // specialize + public ByteVector128 selectFrom(Vector v) { + return (ByteVector128) + super.selectFromTemplate((ByteVector128) v); // specialize } @Override @ForceInline - public Byte128Vector selectFrom(Vector v, + public ByteVector128 selectFrom(Vector v, VectorMask m) { - return (Byte128Vector) - super.selectFromTemplate((Byte128Vector) v, - Byte128Mask.class, (Byte128Mask) m); // specialize + return (ByteVector128) + super.selectFromTemplate((ByteVector128) v, + ByteMask128.class, (ByteMask128) m); // specialize } @Override @ForceInline - public Byte128Vector selectFrom(Vector v1, + public ByteVector128 selectFrom(Vector v1, Vector v2) { - return (Byte128Vector) - super.selectFromTemplate((Byte128Vector) v1, (Byte128Vector) v2); // specialize + return (ByteVector128) + super.selectFromTemplate((ByteVector128) v1, (ByteVector128) v2); // specialize } @ForceInline @@ -558,7 +563,7 @@ final class Byte128Vector extends ByteVector { @ForceInline @Override - public Byte128Vector withLane(int i, byte e) { + public ByteVector128 withLane(int i, byte e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -581,7 +586,7 @@ final class Byte128Vector extends ByteVector { } @ForceInline - public Byte128Vector withLaneHelper(int i, byte e) { + public ByteVector128 withLaneHelper(int i, byte e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -593,20 +598,21 @@ final class Byte128Vector extends ByteVector { } // Mask - - static final class Byte128Mask extends AbstractMask { + @ValueBased + static final class ByteMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte128Mask(boolean[] bits) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteMask128(boolean[] bits) { this(bits, 0); } - Byte128Mask(boolean[] bits, int offset) { + ByteMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Byte128Mask(boolean val) { + ByteMask128(boolean val) { super(prepare(val)); } @@ -639,31 +645,31 @@ final class Byte128Vector extends ByteVector { } @Override - Byte128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Byte128Mask(res); + return new ByteMask128(res); } @Override - Byte128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Byte128Mask)m).getBits(); + boolean[] mbits = ((ByteMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Byte128Mask(res); + return new ByteMask128(res); } @ForceInline @Override public final - Byte128Vector toVector() { - return (Byte128Vector) super.toVectorTemplate(); // specialize + ByteVector128 toVector() { + return (ByteVector128) super.toVectorTemplate(); // specialize } /** @@ -696,25 +702,25 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline /*package-private*/ - Byte128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Byte128Mask) VectorSupport.indexPartiallyInUpperRange( - Byte128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Byte128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ByteMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMask128) VectorSupport.indexPartiallyInUpperRange( + ByteMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ByteMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Byte128Mask not() { + public ByteMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Byte128Mask compress() { - return (Byte128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte128Vector.class, Byte128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ByteMask128 compress() { + return (ByteMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ByteVector128.class, ByteMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -723,30 +729,30 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline - public Byte128Mask and(VectorMask mask) { + public ByteMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask128 m = (ByteMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Byte128Mask or(VectorMask mask) { + public ByteMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask128 m = (ByteMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Byte128Mask xor(VectorMask mask) { + public ByteMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask128 m = (ByteMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -756,21 +762,21 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -780,7 +786,7 @@ final class Byte128Vector extends ByteVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -790,7 +796,7 @@ final class Byte128Vector extends ByteVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ByteMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -799,48 +805,49 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte128Mask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ByteMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ByteMask128)m).getBits())); } @ForceInline /*package-private*/ - static Byte128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ByteMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ByteMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Byte128Mask TRUE_MASK = new Byte128Mask(true); - private static final Byte128Mask FALSE_MASK = new Byte128Mask(false); + private static final ByteMask128 TRUE_MASK = new ByteMask128(true); + private static final ByteMask128 FALSE_MASK = new ByteMask128(false); } // Shuffle - - static final class Byte128Shuffle extends AbstractShuffle { + @ValueBased + static final class ByteShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte128Shuffle(byte[] indices) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteShuffle128(byte[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Byte128Shuffle(int[] indices, int i) { + ByteShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Byte128Shuffle(IntUnaryOperator fn) { + ByteShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -860,23 +867,23 @@ final class Byte128Vector extends ByteVector { assert(VLENGTH < Byte.MAX_VALUE); assert(Byte.MIN_VALUE <= -VLENGTH); } - static final Byte128Shuffle IOTA = new Byte128Shuffle(IDENTITY); + static final ByteShuffle128 IOTA = new ByteShuffle128(IDENTITY); @Override @ForceInline - public Byte128Vector toVector() { + public ByteVector128 toVector() { return toBitsVector(); } @Override @ForceInline - Byte128Vector toBitsVector() { - return (Byte128Vector) super.toBitsVectorTemplate(); + ByteVector128 toBitsVector() { + return (ByteVector128) super.toBitsVectorTemplate(); } @Override - Byte128Vector toBitsVector0() { - return ((Byte128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ByteVector128 toBitsVector0() { + return ((ByteVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -925,30 +932,30 @@ final class Byte128Vector extends ByteVector { @Override @ForceInline - public final Byte128Mask laneIsValid() { - return (Byte128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ByteMask128 laneIsValid() { + return (ByteMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Byte128Shuffle rearrange(VectorShuffle shuffle) { - Byte128Shuffle concreteShuffle = (Byte128Shuffle) shuffle; - return (Byte128Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ByteShuffle128 rearrange(VectorShuffle shuffle) { + ByteShuffle128 concreteShuffle = (ByteShuffle128) shuffle; + return (ByteShuffle128) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Byte128Shuffle wrapIndexes() { - Byte128Vector v = toBitsVector(); + public final ByteShuffle128 wrapIndexes() { + ByteVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Byte128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ByteVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Byte128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ByteVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Byte128Shuffle) v.toShuffle(vspecies(), false); + return (ByteShuffle128) v.toShuffle(VSPECIES, false); } private static byte[] prepare(int[] indices, int offset) { @@ -999,14 +1006,14 @@ final class Byte128Vector extends ByteVector { @Override final ByteVector fromArray0(byte[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Byte128Mask.class, a, offset, (Byte128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ByteMask128.class, a, offset, (ByteMask128) m, offsetInRange); // specialize } @ForceInline @Override final ByteVector fromArray0(byte[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Byte128Mask.class, a, offset, indexMap, mapOffset, (Byte128Mask) m); + return super.fromArray0Template(ByteMask128.class, a, offset, indexMap, mapOffset, (ByteMask128) m); } @@ -1021,7 +1028,7 @@ final class Byte128Vector extends ByteVector { @Override final ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromBooleanArray0Template(Byte128Mask.class, a, offset, (Byte128Mask) m, offsetInRange); // specialize + return super.fromBooleanArray0Template(ByteMask128.class, a, offset, (ByteMask128) m, offsetInRange); // specialize } @ForceInline @@ -1035,7 +1042,7 @@ final class Byte128Vector extends ByteVector { @Override final ByteVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Byte128Mask.class, ms, offset, (Byte128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ByteMask128.class, ms, offset, (ByteMask128) m, offsetInRange); // specialize } @ForceInline @@ -1049,7 +1056,7 @@ final class Byte128Vector extends ByteVector { @Override final void intoArray0(byte[] a, int offset, VectorMask m) { - super.intoArray0Template(Byte128Mask.class, a, offset, (Byte128Mask) m); + super.intoArray0Template(ByteMask128.class, a, offset, (ByteMask128) m); } @@ -1057,14 +1064,14 @@ final class Byte128Vector extends ByteVector { @Override final void intoBooleanArray0(boolean[] a, int offset, VectorMask m) { - super.intoBooleanArray0Template(Byte128Mask.class, a, offset, (Byte128Mask) m); + super.intoBooleanArray0Template(ByteMask128.class, a, offset, (ByteMask128) m); } @ForceInline @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Byte128Mask.class, ms, offset, (Byte128Mask) m); + super.intoMemorySegment0Template(ByteMask128.class, ms, offset, (ByteMask128) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector256.java similarity index 67% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector256.java index 6b0e57f8b8f..a11268ea40d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector256.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Byte256Vector extends ByteVector { +@ValueBased +final class ByteVector256 extends ByteVector { static final ByteSpecies VSPECIES = (ByteSpecies) ByteVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Byte256Vector.class; + static final Class VCLASS = ByteVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + static final Class ETYPE = byte.class; // used by the JVM - Byte256Vector(byte[] v) { + ByteVector256(byte[] v) { super(v); } - // For compatibility as Byte256Vector::new, + // For compatibility as ByteVector256::new, // stored into species.vectorFactory. - Byte256Vector(Object v) { + ByteVector256(Object v) { this((byte[]) v); } - static final Byte256Vector ZERO = new Byte256Vector(new byte[VLENGTH]); - static final Byte256Vector IOTA = new Byte256Vector(VSPECIES.iotaArray()); + static final ByteVector256 ZERO = new ByteVector256(new byte[VLENGTH]); + static final ByteVector256 IOTA = new ByteVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Byte256Vector extends ByteVector { @Override public final Class elementType() { return byte.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Byte.SIZE; } @@ -130,51 +135,51 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline - public final Byte256Vector broadcast(byte e) { - return (Byte256Vector) super.broadcastTemplate(e); // specialize + public final ByteVector256 broadcast(byte e) { + return (ByteVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Byte256Vector broadcast(long e) { - return (Byte256Vector) super.broadcastTemplate(e); // specialize + public final ByteVector256 broadcast(long e) { + return (ByteVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Byte256Mask maskFromArray(boolean[] bits) { - return new Byte256Mask(bits); + ByteMask256 maskFromArray(boolean[] bits) { + return new ByteMask256(bits); } @Override @ForceInline - Byte256Shuffle iotaShuffle() { return Byte256Shuffle.IOTA; } + ByteShuffle256 iotaShuffle() { return ByteShuffle256.IOTA; } @Override @ForceInline - Byte256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Byte256Shuffle) iotaShuffleTemplate((byte) start, (byte) step, wrap); + ByteShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (ByteShuffle256) iotaShuffleTemplate((byte) start, (byte) step, wrap); } @Override @ForceInline - Byte256Shuffle shuffleFromArray(int[] indices, int i) { return new Byte256Shuffle(indices, i); } + ByteShuffle256 shuffleFromArray(int[] indices, int i) { return new ByteShuffle256(indices, i); } @Override @ForceInline - Byte256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte256Shuffle(fn); } + ByteShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new ByteShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Byte256Vector vectorFactory(byte[] vec) { - return new Byte256Vector(vec); + ByteVector256 vectorFactory(byte[] vec) { + return new ByteVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Byte256Vector extends ByteVector { @ForceInline final @Override - Byte256Vector uOp(FUnOp f) { - return (Byte256Vector) super.uOpTemplate(f); // specialize + ByteVector256 uOp(FUnOp f) { + return (ByteVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Byte256Vector uOp(VectorMask m, FUnOp f) { - return (Byte256Vector) - super.uOpTemplate((Byte256Mask)m, f); // specialize + ByteVector256 uOp(VectorMask m, FUnOp f) { + return (ByteVector256) + super.uOpTemplate((ByteMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Byte256Vector bOp(Vector v, FBinOp f) { - return (Byte256Vector) super.bOpTemplate((Byte256Vector)v, f); // specialize + ByteVector256 bOp(Vector v, FBinOp f) { + return (ByteVector256) super.bOpTemplate((ByteVector256)v, f); // specialize } @ForceInline final @Override - Byte256Vector bOp(Vector v, + ByteVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Byte256Vector) - super.bOpTemplate((Byte256Vector)v, (Byte256Mask)m, + return (ByteVector256) + super.bOpTemplate((ByteVector256)v, (ByteMask256)m, f); // specialize } @@ -219,19 +224,19 @@ final class Byte256Vector extends ByteVector { @ForceInline final @Override - Byte256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Byte256Vector) - super.tOpTemplate((Byte256Vector)v1, (Byte256Vector)v2, + ByteVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (ByteVector256) + super.tOpTemplate((ByteVector256)v1, (ByteVector256)v2, f); // specialize } @ForceInline final @Override - Byte256Vector tOp(Vector v1, Vector v2, + ByteVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Byte256Vector) - super.tOpTemplate((Byte256Vector)v1, (Byte256Vector)v2, - (Byte256Mask)m, f); // specialize + return (ByteVector256) + super.tOpTemplate((ByteVector256)v1, (ByteVector256)v2, + (ByteMask256)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline - public Byte256Vector lanewise(Unary op) { - return (Byte256Vector) super.lanewiseTemplate(op); // specialize + public ByteVector256 lanewise(Unary op) { + return (ByteVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Byte256Vector lanewise(Unary op, VectorMask m) { - return (Byte256Vector) super.lanewiseTemplate(op, Byte256Mask.class, (Byte256Mask) m); // specialize + public ByteVector256 lanewise(Unary op, VectorMask m) { + return (ByteVector256) super.lanewiseTemplate(op, ByteMask256.class, (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector lanewise(Binary op, Vector v) { - return (Byte256Vector) super.lanewiseTemplate(op, v); // specialize + public ByteVector256 lanewise(Binary op, Vector v) { + return (ByteVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Byte256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Byte256Vector) super.lanewiseTemplate(op, Byte256Mask.class, v, (Byte256Mask) m); // specialize + public ByteVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (ByteVector256) super.lanewiseTemplate(op, ByteMask256.class, v, (ByteMask256) m); // specialize } /*package-private*/ @Override - @ForceInline Byte256Vector + @ForceInline ByteVector256 lanewiseShift(VectorOperators.Binary op, int e) { - return (Byte256Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ByteVector256) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Byte256Vector + @ForceInline ByteVector256 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Byte256Vector) super.lanewiseShiftTemplate(op, Byte256Mask.class, e, (Byte256Mask) m); // specialize + return (ByteVector256) super.lanewiseShiftTemplate(op, ByteMask256.class, e, (ByteMask256) m); // specialize } /*package-private*/ @Override @ForceInline public final - Byte256Vector + ByteVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Byte256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ByteVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Byte256Vector + ByteVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Byte256Vector) super.lanewiseTemplate(op, Byte256Mask.class, v1, v2, (Byte256Mask) m); // specialize + return (ByteVector256) super.lanewiseTemplate(op, ByteMask256.class, v1, v2, (ByteMask256) m); // specialize } @Override @ForceInline public final - Byte256Vector addIndex(int scale) { - return (Byte256Vector) super.addIndexTemplate(scale); // specialize + ByteVector256 addIndex(int scale) { + return (ByteVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Byte256Vector extends ByteVector { @ForceInline public final byte reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Byte256Mask.class, (Byte256Mask) m); // specialized + return super.reduceLanesTemplate(op, ByteMask256.class, (ByteMask256) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Byte256Vector extends ByteVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Byte256Mask.class, (Byte256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ByteMask256.class, (ByteMask256) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline - public final Byte256Shuffle toShuffle() { - return (Byte256Shuffle) toShuffle(vspecies(), false); + public final ByteShuffle256 toShuffle() { + return (ByteShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Byte256Mask test(Test op) { - return super.testTemplate(Byte256Mask.class, op); // specialize + public final ByteMask256 test(Test op) { + return super.testTemplate(ByteMask256.class, op); // specialize } @Override @ForceInline - public final Byte256Mask test(Test op, VectorMask m) { - return super.testTemplate(Byte256Mask.class, op, (Byte256Mask) m); // specialize + public final ByteMask256 test(Test op, VectorMask m) { + return super.testTemplate(ByteMask256.class, op, (ByteMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Byte256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Byte256Mask.class, op, v); // specialize + public final ByteMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(ByteMask256.class, op, v); // specialize } @Override @ForceInline - public final Byte256Mask compare(Comparison op, byte s) { - return super.compareTemplate(Byte256Mask.class, op, s); // specialize + public final ByteMask256 compare(Comparison op, byte s) { + return super.compareTemplate(ByteMask256.class, op, s); // specialize } @Override @ForceInline - public final Byte256Mask compare(Comparison op, long s) { - return super.compareTemplate(Byte256Mask.class, op, s); // specialize + public final ByteMask256 compare(Comparison op, long s) { + return super.compareTemplate(ByteMask256.class, op, s); // specialize } @Override @ForceInline - public final Byte256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Byte256Mask.class, op, v, (Byte256Mask) m); + public final ByteMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ByteMask256.class, op, v, (ByteMask256) m); } @Override @ForceInline - public Byte256Vector blend(Vector v, VectorMask m) { - return (Byte256Vector) - super.blendTemplate(Byte256Mask.class, - (Byte256Vector) v, - (Byte256Mask) m); // specialize + public ByteVector256 blend(Vector v, VectorMask m) { + return (ByteVector256) + super.blendTemplate(ByteMask256.class, + (ByteVector256) v, + (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector slice(int origin, Vector v) { - return (Byte256Vector) super.sliceTemplate(origin, v); // specialize + public ByteVector256 slice(int origin, Vector v) { + return (ByteVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Byte256Vector slice(int origin) { - return (Byte256Vector) super.sliceTemplate(origin); // specialize + public ByteVector256 slice(int origin) { + return (ByteVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Byte256Vector unslice(int origin, Vector w, int part) { - return (Byte256Vector) super.unsliceTemplate(origin, w, part); // specialize + public ByteVector256 unslice(int origin, Vector w, int part) { + return (ByteVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Byte256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Byte256Vector) - super.unsliceTemplate(Byte256Mask.class, + public ByteVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (ByteVector256) + super.unsliceTemplate(ByteMask256.class, origin, w, part, - (Byte256Mask) m); // specialize + (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector unslice(int origin) { - return (Byte256Vector) super.unsliceTemplate(origin); // specialize + public ByteVector256 unslice(int origin) { + return (ByteVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Byte256Vector rearrange(VectorShuffle s) { - return (Byte256Vector) - super.rearrangeTemplate(Byte256Shuffle.class, - (Byte256Shuffle) s); // specialize + public ByteVector256 rearrange(VectorShuffle s) { + return (ByteVector256) + super.rearrangeTemplate(ByteShuffle256.class, + (ByteShuffle256) s); // specialize } @Override @ForceInline - public Byte256Vector rearrange(VectorShuffle shuffle, + public ByteVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Byte256Vector) - super.rearrangeTemplate(Byte256Shuffle.class, - Byte256Mask.class, - (Byte256Shuffle) shuffle, - (Byte256Mask) m); // specialize + return (ByteVector256) + super.rearrangeTemplate(ByteShuffle256.class, + ByteMask256.class, + (ByteShuffle256) shuffle, + (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector rearrange(VectorShuffle s, + public ByteVector256 rearrange(VectorShuffle s, Vector v) { - return (Byte256Vector) - super.rearrangeTemplate(Byte256Shuffle.class, - (Byte256Shuffle) s, - (Byte256Vector) v); // specialize + return (ByteVector256) + super.rearrangeTemplate(ByteShuffle256.class, + (ByteShuffle256) s, + (ByteVector256) v); // specialize } @Override @ForceInline - public Byte256Vector compress(VectorMask m) { - return (Byte256Vector) - super.compressTemplate(Byte256Mask.class, - (Byte256Mask) m); // specialize + public ByteVector256 compress(VectorMask m) { + return (ByteVector256) + super.compressTemplate(ByteMask256.class, + (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector expand(VectorMask m) { - return (Byte256Vector) - super.expandTemplate(Byte256Mask.class, - (Byte256Mask) m); // specialize + public ByteVector256 expand(VectorMask m) { + return (ByteVector256) + super.expandTemplate(ByteMask256.class, + (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector selectFrom(Vector v) { - return (Byte256Vector) - super.selectFromTemplate((Byte256Vector) v); // specialize + public ByteVector256 selectFrom(Vector v) { + return (ByteVector256) + super.selectFromTemplate((ByteVector256) v); // specialize } @Override @ForceInline - public Byte256Vector selectFrom(Vector v, + public ByteVector256 selectFrom(Vector v, VectorMask m) { - return (Byte256Vector) - super.selectFromTemplate((Byte256Vector) v, - Byte256Mask.class, (Byte256Mask) m); // specialize + return (ByteVector256) + super.selectFromTemplate((ByteVector256) v, + ByteMask256.class, (ByteMask256) m); // specialize } @Override @ForceInline - public Byte256Vector selectFrom(Vector v1, + public ByteVector256 selectFrom(Vector v1, Vector v2) { - return (Byte256Vector) - super.selectFromTemplate((Byte256Vector) v1, (Byte256Vector) v2); // specialize + return (ByteVector256) + super.selectFromTemplate((ByteVector256) v1, (ByteVector256) v2); // specialize } @ForceInline @@ -574,7 +579,7 @@ final class Byte256Vector extends ByteVector { @ForceInline @Override - public Byte256Vector withLane(int i, byte e) { + public ByteVector256 withLane(int i, byte e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -613,7 +618,7 @@ final class Byte256Vector extends ByteVector { } @ForceInline - public Byte256Vector withLaneHelper(int i, byte e) { + public ByteVector256 withLaneHelper(int i, byte e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -625,20 +630,21 @@ final class Byte256Vector extends ByteVector { } // Mask - - static final class Byte256Mask extends AbstractMask { + @ValueBased + static final class ByteMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte256Mask(boolean[] bits) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteMask256(boolean[] bits) { this(bits, 0); } - Byte256Mask(boolean[] bits, int offset) { + ByteMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Byte256Mask(boolean val) { + ByteMask256(boolean val) { super(prepare(val)); } @@ -671,31 +677,31 @@ final class Byte256Vector extends ByteVector { } @Override - Byte256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Byte256Mask(res); + return new ByteMask256(res); } @Override - Byte256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Byte256Mask)m).getBits(); + boolean[] mbits = ((ByteMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Byte256Mask(res); + return new ByteMask256(res); } @ForceInline @Override public final - Byte256Vector toVector() { - return (Byte256Vector) super.toVectorTemplate(); // specialize + ByteVector256 toVector() { + return (ByteVector256) super.toVectorTemplate(); // specialize } /** @@ -728,25 +734,25 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline /*package-private*/ - Byte256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Byte256Mask) VectorSupport.indexPartiallyInUpperRange( - Byte256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Byte256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ByteMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMask256) VectorSupport.indexPartiallyInUpperRange( + ByteMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ByteMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Byte256Mask not() { + public ByteMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Byte256Mask compress() { - return (Byte256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte256Vector.class, Byte256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ByteMask256 compress() { + return (ByteMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ByteVector256.class, ByteMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -755,30 +761,30 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline - public Byte256Mask and(VectorMask mask) { + public ByteMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask256 m = (ByteMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Byte256Mask or(VectorMask mask) { + public ByteMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask256 m = (ByteMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Byte256Mask xor(VectorMask mask) { + public ByteMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask256 m = (ByteMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -788,21 +794,21 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -812,7 +818,7 @@ final class Byte256Vector extends ByteVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -822,7 +828,7 @@ final class Byte256Vector extends ByteVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ByteMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -831,48 +837,49 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte256Mask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ByteMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ByteMask256)m).getBits())); } @ForceInline /*package-private*/ - static Byte256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ByteMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ByteMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Byte256Mask TRUE_MASK = new Byte256Mask(true); - private static final Byte256Mask FALSE_MASK = new Byte256Mask(false); + private static final ByteMask256 TRUE_MASK = new ByteMask256(true); + private static final ByteMask256 FALSE_MASK = new ByteMask256(false); } // Shuffle - - static final class Byte256Shuffle extends AbstractShuffle { + @ValueBased + static final class ByteShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte256Shuffle(byte[] indices) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteShuffle256(byte[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Byte256Shuffle(int[] indices, int i) { + ByteShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Byte256Shuffle(IntUnaryOperator fn) { + ByteShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -892,23 +899,23 @@ final class Byte256Vector extends ByteVector { assert(VLENGTH < Byte.MAX_VALUE); assert(Byte.MIN_VALUE <= -VLENGTH); } - static final Byte256Shuffle IOTA = new Byte256Shuffle(IDENTITY); + static final ByteShuffle256 IOTA = new ByteShuffle256(IDENTITY); @Override @ForceInline - public Byte256Vector toVector() { + public ByteVector256 toVector() { return toBitsVector(); } @Override @ForceInline - Byte256Vector toBitsVector() { - return (Byte256Vector) super.toBitsVectorTemplate(); + ByteVector256 toBitsVector() { + return (ByteVector256) super.toBitsVectorTemplate(); } @Override - Byte256Vector toBitsVector0() { - return ((Byte256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ByteVector256 toBitsVector0() { + return ((ByteVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -957,30 +964,30 @@ final class Byte256Vector extends ByteVector { @Override @ForceInline - public final Byte256Mask laneIsValid() { - return (Byte256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ByteMask256 laneIsValid() { + return (ByteMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Byte256Shuffle rearrange(VectorShuffle shuffle) { - Byte256Shuffle concreteShuffle = (Byte256Shuffle) shuffle; - return (Byte256Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ByteShuffle256 rearrange(VectorShuffle shuffle) { + ByteShuffle256 concreteShuffle = (ByteShuffle256) shuffle; + return (ByteShuffle256) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Byte256Shuffle wrapIndexes() { - Byte256Vector v = toBitsVector(); + public final ByteShuffle256 wrapIndexes() { + ByteVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Byte256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ByteVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Byte256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ByteVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Byte256Shuffle) v.toShuffle(vspecies(), false); + return (ByteShuffle256) v.toShuffle(VSPECIES, false); } private static byte[] prepare(int[] indices, int offset) { @@ -1031,14 +1038,14 @@ final class Byte256Vector extends ByteVector { @Override final ByteVector fromArray0(byte[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Byte256Mask.class, a, offset, (Byte256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ByteMask256.class, a, offset, (ByteMask256) m, offsetInRange); // specialize } @ForceInline @Override final ByteVector fromArray0(byte[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Byte256Mask.class, a, offset, indexMap, mapOffset, (Byte256Mask) m); + return super.fromArray0Template(ByteMask256.class, a, offset, indexMap, mapOffset, (ByteMask256) m); } @@ -1053,7 +1060,7 @@ final class Byte256Vector extends ByteVector { @Override final ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromBooleanArray0Template(Byte256Mask.class, a, offset, (Byte256Mask) m, offsetInRange); // specialize + return super.fromBooleanArray0Template(ByteMask256.class, a, offset, (ByteMask256) m, offsetInRange); // specialize } @ForceInline @@ -1067,7 +1074,7 @@ final class Byte256Vector extends ByteVector { @Override final ByteVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Byte256Mask.class, ms, offset, (Byte256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ByteMask256.class, ms, offset, (ByteMask256) m, offsetInRange); // specialize } @ForceInline @@ -1081,7 +1088,7 @@ final class Byte256Vector extends ByteVector { @Override final void intoArray0(byte[] a, int offset, VectorMask m) { - super.intoArray0Template(Byte256Mask.class, a, offset, (Byte256Mask) m); + super.intoArray0Template(ByteMask256.class, a, offset, (ByteMask256) m); } @@ -1089,14 +1096,14 @@ final class Byte256Vector extends ByteVector { @Override final void intoBooleanArray0(boolean[] a, int offset, VectorMask m) { - super.intoBooleanArray0Template(Byte256Mask.class, a, offset, (Byte256Mask) m); + super.intoBooleanArray0Template(ByteMask256.class, a, offset, (ByteMask256) m); } @ForceInline @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Byte256Mask.class, ms, offset, (Byte256Mask) m); + super.intoMemorySegment0Template(ByteMask256.class, ms, offset, (ByteMask256) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector512.java similarity index 69% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector512.java index b1df6949e3a..707254e034e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector512.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Byte512Vector extends ByteVector { +@ValueBased +final class ByteVector512 extends ByteVector { static final ByteSpecies VSPECIES = (ByteSpecies) ByteVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Byte512Vector.class; + static final Class VCLASS = ByteVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + static final Class ETYPE = byte.class; // used by the JVM - Byte512Vector(byte[] v) { + ByteVector512(byte[] v) { super(v); } - // For compatibility as Byte512Vector::new, + // For compatibility as ByteVector512::new, // stored into species.vectorFactory. - Byte512Vector(Object v) { + ByteVector512(Object v) { this((byte[]) v); } - static final Byte512Vector ZERO = new Byte512Vector(new byte[VLENGTH]); - static final Byte512Vector IOTA = new Byte512Vector(VSPECIES.iotaArray()); + static final ByteVector512 ZERO = new ByteVector512(new byte[VLENGTH]); + static final ByteVector512 IOTA = new ByteVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Byte512Vector extends ByteVector { @Override public final Class elementType() { return byte.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Byte.SIZE; } @@ -130,51 +135,51 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline - public final Byte512Vector broadcast(byte e) { - return (Byte512Vector) super.broadcastTemplate(e); // specialize + public final ByteVector512 broadcast(byte e) { + return (ByteVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Byte512Vector broadcast(long e) { - return (Byte512Vector) super.broadcastTemplate(e); // specialize + public final ByteVector512 broadcast(long e) { + return (ByteVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Byte512Mask maskFromArray(boolean[] bits) { - return new Byte512Mask(bits); + ByteMask512 maskFromArray(boolean[] bits) { + return new ByteMask512(bits); } @Override @ForceInline - Byte512Shuffle iotaShuffle() { return Byte512Shuffle.IOTA; } + ByteShuffle512 iotaShuffle() { return ByteShuffle512.IOTA; } @Override @ForceInline - Byte512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Byte512Shuffle) iotaShuffleTemplate((byte) start, (byte) step, wrap); + ByteShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (ByteShuffle512) iotaShuffleTemplate((byte) start, (byte) step, wrap); } @Override @ForceInline - Byte512Shuffle shuffleFromArray(int[] indices, int i) { return new Byte512Shuffle(indices, i); } + ByteShuffle512 shuffleFromArray(int[] indices, int i) { return new ByteShuffle512(indices, i); } @Override @ForceInline - Byte512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte512Shuffle(fn); } + ByteShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new ByteShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Byte512Vector vectorFactory(byte[] vec) { - return new Byte512Vector(vec); + ByteVector512 vectorFactory(byte[] vec) { + return new ByteVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Byte512Vector extends ByteVector { @ForceInline final @Override - Byte512Vector uOp(FUnOp f) { - return (Byte512Vector) super.uOpTemplate(f); // specialize + ByteVector512 uOp(FUnOp f) { + return (ByteVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Byte512Vector uOp(VectorMask m, FUnOp f) { - return (Byte512Vector) - super.uOpTemplate((Byte512Mask)m, f); // specialize + ByteVector512 uOp(VectorMask m, FUnOp f) { + return (ByteVector512) + super.uOpTemplate((ByteMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Byte512Vector bOp(Vector v, FBinOp f) { - return (Byte512Vector) super.bOpTemplate((Byte512Vector)v, f); // specialize + ByteVector512 bOp(Vector v, FBinOp f) { + return (ByteVector512) super.bOpTemplate((ByteVector512)v, f); // specialize } @ForceInline final @Override - Byte512Vector bOp(Vector v, + ByteVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Byte512Vector) - super.bOpTemplate((Byte512Vector)v, (Byte512Mask)m, + return (ByteVector512) + super.bOpTemplate((ByteVector512)v, (ByteMask512)m, f); // specialize } @@ -219,19 +224,19 @@ final class Byte512Vector extends ByteVector { @ForceInline final @Override - Byte512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Byte512Vector) - super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2, + ByteVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (ByteVector512) + super.tOpTemplate((ByteVector512)v1, (ByteVector512)v2, f); // specialize } @ForceInline final @Override - Byte512Vector tOp(Vector v1, Vector v2, + ByteVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Byte512Vector) - super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2, - (Byte512Mask)m, f); // specialize + return (ByteVector512) + super.tOpTemplate((ByteVector512)v1, (ByteVector512)v2, + (ByteMask512)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline - public Byte512Vector lanewise(Unary op) { - return (Byte512Vector) super.lanewiseTemplate(op); // specialize + public ByteVector512 lanewise(Unary op) { + return (ByteVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Byte512Vector lanewise(Unary op, VectorMask m) { - return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, (Byte512Mask) m); // specialize + public ByteVector512 lanewise(Unary op, VectorMask m) { + return (ByteVector512) super.lanewiseTemplate(op, ByteMask512.class, (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector lanewise(Binary op, Vector v) { - return (Byte512Vector) super.lanewiseTemplate(op, v); // specialize + public ByteVector512 lanewise(Binary op, Vector v) { + return (ByteVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Byte512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v, (Byte512Mask) m); // specialize + public ByteVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (ByteVector512) super.lanewiseTemplate(op, ByteMask512.class, v, (ByteMask512) m); // specialize } /*package-private*/ @Override - @ForceInline Byte512Vector + @ForceInline ByteVector512 lanewiseShift(VectorOperators.Binary op, int e) { - return (Byte512Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ByteVector512) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Byte512Vector + @ForceInline ByteVector512 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Byte512Vector) super.lanewiseShiftTemplate(op, Byte512Mask.class, e, (Byte512Mask) m); // specialize + return (ByteVector512) super.lanewiseShiftTemplate(op, ByteMask512.class, e, (ByteMask512) m); // specialize } /*package-private*/ @Override @ForceInline public final - Byte512Vector + ByteVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Byte512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ByteVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Byte512Vector + ByteVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v1, v2, (Byte512Mask) m); // specialize + return (ByteVector512) super.lanewiseTemplate(op, ByteMask512.class, v1, v2, (ByteMask512) m); // specialize } @Override @ForceInline public final - Byte512Vector addIndex(int scale) { - return (Byte512Vector) super.addIndexTemplate(scale); // specialize + ByteVector512 addIndex(int scale) { + return (ByteVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Byte512Vector extends ByteVector { @ForceInline public final byte reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m); // specialized + return super.reduceLanesTemplate(op, ByteMask512.class, (ByteMask512) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Byte512Vector extends ByteVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ByteMask512.class, (ByteMask512) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline - public final Byte512Shuffle toShuffle() { - return (Byte512Shuffle) toShuffle(vspecies(), false); + public final ByteShuffle512 toShuffle() { + return (ByteShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Byte512Mask test(Test op) { - return super.testTemplate(Byte512Mask.class, op); // specialize + public final ByteMask512 test(Test op) { + return super.testTemplate(ByteMask512.class, op); // specialize } @Override @ForceInline - public final Byte512Mask test(Test op, VectorMask m) { - return super.testTemplate(Byte512Mask.class, op, (Byte512Mask) m); // specialize + public final ByteMask512 test(Test op, VectorMask m) { + return super.testTemplate(ByteMask512.class, op, (ByteMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Byte512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Byte512Mask.class, op, v); // specialize + public final ByteMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(ByteMask512.class, op, v); // specialize } @Override @ForceInline - public final Byte512Mask compare(Comparison op, byte s) { - return super.compareTemplate(Byte512Mask.class, op, s); // specialize + public final ByteMask512 compare(Comparison op, byte s) { + return super.compareTemplate(ByteMask512.class, op, s); // specialize } @Override @ForceInline - public final Byte512Mask compare(Comparison op, long s) { - return super.compareTemplate(Byte512Mask.class, op, s); // specialize + public final ByteMask512 compare(Comparison op, long s) { + return super.compareTemplate(ByteMask512.class, op, s); // specialize } @Override @ForceInline - public final Byte512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Byte512Mask.class, op, v, (Byte512Mask) m); + public final ByteMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ByteMask512.class, op, v, (ByteMask512) m); } @Override @ForceInline - public Byte512Vector blend(Vector v, VectorMask m) { - return (Byte512Vector) - super.blendTemplate(Byte512Mask.class, - (Byte512Vector) v, - (Byte512Mask) m); // specialize + public ByteVector512 blend(Vector v, VectorMask m) { + return (ByteVector512) + super.blendTemplate(ByteMask512.class, + (ByteVector512) v, + (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector slice(int origin, Vector v) { - return (Byte512Vector) super.sliceTemplate(origin, v); // specialize + public ByteVector512 slice(int origin, Vector v) { + return (ByteVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Byte512Vector slice(int origin) { - return (Byte512Vector) super.sliceTemplate(origin); // specialize + public ByteVector512 slice(int origin) { + return (ByteVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Byte512Vector unslice(int origin, Vector w, int part) { - return (Byte512Vector) super.unsliceTemplate(origin, w, part); // specialize + public ByteVector512 unslice(int origin, Vector w, int part) { + return (ByteVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Byte512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Byte512Vector) - super.unsliceTemplate(Byte512Mask.class, + public ByteVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (ByteVector512) + super.unsliceTemplate(ByteMask512.class, origin, w, part, - (Byte512Mask) m); // specialize + (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector unslice(int origin) { - return (Byte512Vector) super.unsliceTemplate(origin); // specialize + public ByteVector512 unslice(int origin) { + return (ByteVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Byte512Vector rearrange(VectorShuffle s) { - return (Byte512Vector) - super.rearrangeTemplate(Byte512Shuffle.class, - (Byte512Shuffle) s); // specialize + public ByteVector512 rearrange(VectorShuffle s) { + return (ByteVector512) + super.rearrangeTemplate(ByteShuffle512.class, + (ByteShuffle512) s); // specialize } @Override @ForceInline - public Byte512Vector rearrange(VectorShuffle shuffle, + public ByteVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Byte512Vector) - super.rearrangeTemplate(Byte512Shuffle.class, - Byte512Mask.class, - (Byte512Shuffle) shuffle, - (Byte512Mask) m); // specialize + return (ByteVector512) + super.rearrangeTemplate(ByteShuffle512.class, + ByteMask512.class, + (ByteShuffle512) shuffle, + (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector rearrange(VectorShuffle s, + public ByteVector512 rearrange(VectorShuffle s, Vector v) { - return (Byte512Vector) - super.rearrangeTemplate(Byte512Shuffle.class, - (Byte512Shuffle) s, - (Byte512Vector) v); // specialize + return (ByteVector512) + super.rearrangeTemplate(ByteShuffle512.class, + (ByteShuffle512) s, + (ByteVector512) v); // specialize } @Override @ForceInline - public Byte512Vector compress(VectorMask m) { - return (Byte512Vector) - super.compressTemplate(Byte512Mask.class, - (Byte512Mask) m); // specialize + public ByteVector512 compress(VectorMask m) { + return (ByteVector512) + super.compressTemplate(ByteMask512.class, + (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector expand(VectorMask m) { - return (Byte512Vector) - super.expandTemplate(Byte512Mask.class, - (Byte512Mask) m); // specialize + public ByteVector512 expand(VectorMask m) { + return (ByteVector512) + super.expandTemplate(ByteMask512.class, + (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector selectFrom(Vector v) { - return (Byte512Vector) - super.selectFromTemplate((Byte512Vector) v); // specialize + public ByteVector512 selectFrom(Vector v) { + return (ByteVector512) + super.selectFromTemplate((ByteVector512) v); // specialize } @Override @ForceInline - public Byte512Vector selectFrom(Vector v, + public ByteVector512 selectFrom(Vector v, VectorMask m) { - return (Byte512Vector) - super.selectFromTemplate((Byte512Vector) v, - Byte512Mask.class, (Byte512Mask) m); // specialize + return (ByteVector512) + super.selectFromTemplate((ByteVector512) v, + ByteMask512.class, (ByteMask512) m); // specialize } @Override @ForceInline - public Byte512Vector selectFrom(Vector v1, + public ByteVector512 selectFrom(Vector v1, Vector v2) { - return (Byte512Vector) - super.selectFromTemplate((Byte512Vector) v1, (Byte512Vector) v2); // specialize + return (ByteVector512) + super.selectFromTemplate((ByteVector512) v1, (ByteVector512) v2); // specialize } @ForceInline @@ -606,7 +611,7 @@ final class Byte512Vector extends ByteVector { @ForceInline @Override - public Byte512Vector withLane(int i, byte e) { + public ByteVector512 withLane(int i, byte e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -677,7 +682,7 @@ final class Byte512Vector extends ByteVector { } @ForceInline - public Byte512Vector withLaneHelper(int i, byte e) { + public ByteVector512 withLaneHelper(int i, byte e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -689,20 +694,21 @@ final class Byte512Vector extends ByteVector { } // Mask - - static final class Byte512Mask extends AbstractMask { + @ValueBased + static final class ByteMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte512Mask(boolean[] bits) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteMask512(boolean[] bits) { this(bits, 0); } - Byte512Mask(boolean[] bits, int offset) { + ByteMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Byte512Mask(boolean val) { + ByteMask512(boolean val) { super(prepare(val)); } @@ -735,31 +741,31 @@ final class Byte512Vector extends ByteVector { } @Override - Byte512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Byte512Mask(res); + return new ByteMask512(res); } @Override - Byte512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Byte512Mask)m).getBits(); + boolean[] mbits = ((ByteMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Byte512Mask(res); + return new ByteMask512(res); } @ForceInline @Override public final - Byte512Vector toVector() { - return (Byte512Vector) super.toVectorTemplate(); // specialize + ByteVector512 toVector() { + return (ByteVector512) super.toVectorTemplate(); // specialize } /** @@ -792,25 +798,25 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline /*package-private*/ - Byte512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Byte512Mask) VectorSupport.indexPartiallyInUpperRange( - Byte512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Byte512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ByteMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMask512) VectorSupport.indexPartiallyInUpperRange( + ByteMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ByteMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Byte512Mask not() { + public ByteMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Byte512Mask compress() { - return (Byte512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte512Vector.class, Byte512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ByteMask512 compress() { + return (ByteMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ByteVector512.class, ByteMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -819,30 +825,30 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline - public Byte512Mask and(VectorMask mask) { + public ByteMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask512 m = (ByteMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Byte512Mask or(VectorMask mask) { + public ByteMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask512 m = (ByteMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Byte512Mask xor(VectorMask mask) { + public ByteMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask512 m = (ByteMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -852,21 +858,21 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -876,7 +882,7 @@ final class Byte512Vector extends ByteVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -886,7 +892,7 @@ final class Byte512Vector extends ByteVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ByteMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -895,48 +901,49 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ByteMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ByteMask512)m).getBits())); } @ForceInline /*package-private*/ - static Byte512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ByteMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ByteMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Byte512Mask TRUE_MASK = new Byte512Mask(true); - private static final Byte512Mask FALSE_MASK = new Byte512Mask(false); + private static final ByteMask512 TRUE_MASK = new ByteMask512(true); + private static final ByteMask512 FALSE_MASK = new ByteMask512(false); } // Shuffle - - static final class Byte512Shuffle extends AbstractShuffle { + @ValueBased + static final class ByteShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte512Shuffle(byte[] indices) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteShuffle512(byte[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Byte512Shuffle(int[] indices, int i) { + ByteShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Byte512Shuffle(IntUnaryOperator fn) { + ByteShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -956,23 +963,23 @@ final class Byte512Vector extends ByteVector { assert(VLENGTH < Byte.MAX_VALUE); assert(Byte.MIN_VALUE <= -VLENGTH); } - static final Byte512Shuffle IOTA = new Byte512Shuffle(IDENTITY); + static final ByteShuffle512 IOTA = new ByteShuffle512(IDENTITY); @Override @ForceInline - public Byte512Vector toVector() { + public ByteVector512 toVector() { return toBitsVector(); } @Override @ForceInline - Byte512Vector toBitsVector() { - return (Byte512Vector) super.toBitsVectorTemplate(); + ByteVector512 toBitsVector() { + return (ByteVector512) super.toBitsVectorTemplate(); } @Override - Byte512Vector toBitsVector0() { - return ((Byte512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ByteVector512 toBitsVector0() { + return ((ByteVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -1021,30 +1028,30 @@ final class Byte512Vector extends ByteVector { @Override @ForceInline - public final Byte512Mask laneIsValid() { - return (Byte512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ByteMask512 laneIsValid() { + return (ByteMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Byte512Shuffle rearrange(VectorShuffle shuffle) { - Byte512Shuffle concreteShuffle = (Byte512Shuffle) shuffle; - return (Byte512Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ByteShuffle512 rearrange(VectorShuffle shuffle) { + ByteShuffle512 concreteShuffle = (ByteShuffle512) shuffle; + return (ByteShuffle512) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Byte512Shuffle wrapIndexes() { - Byte512Vector v = toBitsVector(); + public final ByteShuffle512 wrapIndexes() { + ByteVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Byte512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ByteVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Byte512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ByteVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Byte512Shuffle) v.toShuffle(vspecies(), false); + return (ByteShuffle512) v.toShuffle(VSPECIES, false); } private static byte[] prepare(int[] indices, int offset) { @@ -1095,14 +1102,14 @@ final class Byte512Vector extends ByteVector { @Override final ByteVector fromArray0(byte[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ByteMask512.class, a, offset, (ByteMask512) m, offsetInRange); // specialize } @ForceInline @Override final ByteVector fromArray0(byte[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Byte512Mask.class, a, offset, indexMap, mapOffset, (Byte512Mask) m); + return super.fromArray0Template(ByteMask512.class, a, offset, indexMap, mapOffset, (ByteMask512) m); } @@ -1117,7 +1124,7 @@ final class Byte512Vector extends ByteVector { @Override final ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m, offsetInRange); // specialize + return super.fromBooleanArray0Template(ByteMask512.class, a, offset, (ByteMask512) m, offsetInRange); // specialize } @ForceInline @@ -1131,7 +1138,7 @@ final class Byte512Vector extends ByteVector { @Override final ByteVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Byte512Mask.class, ms, offset, (Byte512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ByteMask512.class, ms, offset, (ByteMask512) m, offsetInRange); // specialize } @ForceInline @@ -1145,7 +1152,7 @@ final class Byte512Vector extends ByteVector { @Override final void intoArray0(byte[] a, int offset, VectorMask m) { - super.intoArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m); + super.intoArray0Template(ByteMask512.class, a, offset, (ByteMask512) m); } @@ -1153,14 +1160,14 @@ final class Byte512Vector extends ByteVector { @Override final void intoBooleanArray0(boolean[] a, int offset, VectorMask m) { - super.intoBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m); + super.intoBooleanArray0Template(ByteMask512.class, a, offset, (ByteMask512) m); } @ForceInline @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Byte512Mask.class, ms, offset, (Byte512Mask) m); + super.intoMemorySegment0Template(ByteMask512.class, ms, offset, (ByteMask512) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector64.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector64.java index dfd16e1812a..d304edfc0c7 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector64.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Byte64Vector extends ByteVector { +@ValueBased +final class ByteVector64 extends ByteVector { static final ByteSpecies VSPECIES = (ByteSpecies) ByteVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Byte64Vector.class; + static final Class VCLASS = ByteVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + static final Class ETYPE = byte.class; // used by the JVM - Byte64Vector(byte[] v) { + ByteVector64(byte[] v) { super(v); } - // For compatibility as Byte64Vector::new, + // For compatibility as ByteVector64::new, // stored into species.vectorFactory. - Byte64Vector(Object v) { + ByteVector64(Object v) { this((byte[]) v); } - static final Byte64Vector ZERO = new Byte64Vector(new byte[VLENGTH]); - static final Byte64Vector IOTA = new Byte64Vector(VSPECIES.iotaArray()); + static final ByteVector64 ZERO = new ByteVector64(new byte[VLENGTH]); + static final ByteVector64 IOTA = new ByteVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Byte64Vector extends ByteVector { @Override public final Class elementType() { return byte.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Byte.SIZE; } @@ -130,51 +135,51 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline - public final Byte64Vector broadcast(byte e) { - return (Byte64Vector) super.broadcastTemplate(e); // specialize + public final ByteVector64 broadcast(byte e) { + return (ByteVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Byte64Vector broadcast(long e) { - return (Byte64Vector) super.broadcastTemplate(e); // specialize + public final ByteVector64 broadcast(long e) { + return (ByteVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Byte64Mask maskFromArray(boolean[] bits) { - return new Byte64Mask(bits); + ByteMask64 maskFromArray(boolean[] bits) { + return new ByteMask64(bits); } @Override @ForceInline - Byte64Shuffle iotaShuffle() { return Byte64Shuffle.IOTA; } + ByteShuffle64 iotaShuffle() { return ByteShuffle64.IOTA; } @Override @ForceInline - Byte64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Byte64Shuffle) iotaShuffleTemplate((byte) start, (byte) step, wrap); + ByteShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (ByteShuffle64) iotaShuffleTemplate((byte) start, (byte) step, wrap); } @Override @ForceInline - Byte64Shuffle shuffleFromArray(int[] indices, int i) { return new Byte64Shuffle(indices, i); } + ByteShuffle64 shuffleFromArray(int[] indices, int i) { return new ByteShuffle64(indices, i); } @Override @ForceInline - Byte64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte64Shuffle(fn); } + ByteShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new ByteShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Byte64Vector vectorFactory(byte[] vec) { - return new Byte64Vector(vec); + ByteVector64 vectorFactory(byte[] vec) { + return new ByteVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Byte64Vector extends ByteVector { @ForceInline final @Override - Byte64Vector uOp(FUnOp f) { - return (Byte64Vector) super.uOpTemplate(f); // specialize + ByteVector64 uOp(FUnOp f) { + return (ByteVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Byte64Vector uOp(VectorMask m, FUnOp f) { - return (Byte64Vector) - super.uOpTemplate((Byte64Mask)m, f); // specialize + ByteVector64 uOp(VectorMask m, FUnOp f) { + return (ByteVector64) + super.uOpTemplate((ByteMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Byte64Vector bOp(Vector v, FBinOp f) { - return (Byte64Vector) super.bOpTemplate((Byte64Vector)v, f); // specialize + ByteVector64 bOp(Vector v, FBinOp f) { + return (ByteVector64) super.bOpTemplate((ByteVector64)v, f); // specialize } @ForceInline final @Override - Byte64Vector bOp(Vector v, + ByteVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Byte64Vector) - super.bOpTemplate((Byte64Vector)v, (Byte64Mask)m, + return (ByteVector64) + super.bOpTemplate((ByteVector64)v, (ByteMask64)m, f); // specialize } @@ -219,19 +224,19 @@ final class Byte64Vector extends ByteVector { @ForceInline final @Override - Byte64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Byte64Vector) - super.tOpTemplate((Byte64Vector)v1, (Byte64Vector)v2, + ByteVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (ByteVector64) + super.tOpTemplate((ByteVector64)v1, (ByteVector64)v2, f); // specialize } @ForceInline final @Override - Byte64Vector tOp(Vector v1, Vector v2, + ByteVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Byte64Vector) - super.tOpTemplate((Byte64Vector)v1, (Byte64Vector)v2, - (Byte64Mask)m, f); // specialize + return (ByteVector64) + super.tOpTemplate((ByteVector64)v1, (ByteVector64)v2, + (ByteMask64)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline - public Byte64Vector lanewise(Unary op) { - return (Byte64Vector) super.lanewiseTemplate(op); // specialize + public ByteVector64 lanewise(Unary op) { + return (ByteVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Byte64Vector lanewise(Unary op, VectorMask m) { - return (Byte64Vector) super.lanewiseTemplate(op, Byte64Mask.class, (Byte64Mask) m); // specialize + public ByteVector64 lanewise(Unary op, VectorMask m) { + return (ByteVector64) super.lanewiseTemplate(op, ByteMask64.class, (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector lanewise(Binary op, Vector v) { - return (Byte64Vector) super.lanewiseTemplate(op, v); // specialize + public ByteVector64 lanewise(Binary op, Vector v) { + return (ByteVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Byte64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Byte64Vector) super.lanewiseTemplate(op, Byte64Mask.class, v, (Byte64Mask) m); // specialize + public ByteVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (ByteVector64) super.lanewiseTemplate(op, ByteMask64.class, v, (ByteMask64) m); // specialize } /*package-private*/ @Override - @ForceInline Byte64Vector + @ForceInline ByteVector64 lanewiseShift(VectorOperators.Binary op, int e) { - return (Byte64Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ByteVector64) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Byte64Vector + @ForceInline ByteVector64 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Byte64Vector) super.lanewiseShiftTemplate(op, Byte64Mask.class, e, (Byte64Mask) m); // specialize + return (ByteVector64) super.lanewiseShiftTemplate(op, ByteMask64.class, e, (ByteMask64) m); // specialize } /*package-private*/ @Override @ForceInline public final - Byte64Vector + ByteVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Byte64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ByteVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Byte64Vector + ByteVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Byte64Vector) super.lanewiseTemplate(op, Byte64Mask.class, v1, v2, (Byte64Mask) m); // specialize + return (ByteVector64) super.lanewiseTemplate(op, ByteMask64.class, v1, v2, (ByteMask64) m); // specialize } @Override @ForceInline public final - Byte64Vector addIndex(int scale) { - return (Byte64Vector) super.addIndexTemplate(scale); // specialize + ByteVector64 addIndex(int scale) { + return (ByteVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Byte64Vector extends ByteVector { @ForceInline public final byte reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Byte64Mask.class, (Byte64Mask) m); // specialized + return super.reduceLanesTemplate(op, ByteMask64.class, (ByteMask64) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Byte64Vector extends ByteVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Byte64Mask.class, (Byte64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ByteMask64.class, (ByteMask64) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline - public final Byte64Shuffle toShuffle() { - return (Byte64Shuffle) toShuffle(vspecies(), false); + public final ByteShuffle64 toShuffle() { + return (ByteShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Byte64Mask test(Test op) { - return super.testTemplate(Byte64Mask.class, op); // specialize + public final ByteMask64 test(Test op) { + return super.testTemplate(ByteMask64.class, op); // specialize } @Override @ForceInline - public final Byte64Mask test(Test op, VectorMask m) { - return super.testTemplate(Byte64Mask.class, op, (Byte64Mask) m); // specialize + public final ByteMask64 test(Test op, VectorMask m) { + return super.testTemplate(ByteMask64.class, op, (ByteMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Byte64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Byte64Mask.class, op, v); // specialize + public final ByteMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(ByteMask64.class, op, v); // specialize } @Override @ForceInline - public final Byte64Mask compare(Comparison op, byte s) { - return super.compareTemplate(Byte64Mask.class, op, s); // specialize + public final ByteMask64 compare(Comparison op, byte s) { + return super.compareTemplate(ByteMask64.class, op, s); // specialize } @Override @ForceInline - public final Byte64Mask compare(Comparison op, long s) { - return super.compareTemplate(Byte64Mask.class, op, s); // specialize + public final ByteMask64 compare(Comparison op, long s) { + return super.compareTemplate(ByteMask64.class, op, s); // specialize } @Override @ForceInline - public final Byte64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Byte64Mask.class, op, v, (Byte64Mask) m); + public final ByteMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ByteMask64.class, op, v, (ByteMask64) m); } @Override @ForceInline - public Byte64Vector blend(Vector v, VectorMask m) { - return (Byte64Vector) - super.blendTemplate(Byte64Mask.class, - (Byte64Vector) v, - (Byte64Mask) m); // specialize + public ByteVector64 blend(Vector v, VectorMask m) { + return (ByteVector64) + super.blendTemplate(ByteMask64.class, + (ByteVector64) v, + (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector slice(int origin, Vector v) { - return (Byte64Vector) super.sliceTemplate(origin, v); // specialize + public ByteVector64 slice(int origin, Vector v) { + return (ByteVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Byte64Vector slice(int origin) { - return (Byte64Vector) super.sliceTemplate(origin); // specialize + public ByteVector64 slice(int origin) { + return (ByteVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Byte64Vector unslice(int origin, Vector w, int part) { - return (Byte64Vector) super.unsliceTemplate(origin, w, part); // specialize + public ByteVector64 unslice(int origin, Vector w, int part) { + return (ByteVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Byte64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Byte64Vector) - super.unsliceTemplate(Byte64Mask.class, + public ByteVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (ByteVector64) + super.unsliceTemplate(ByteMask64.class, origin, w, part, - (Byte64Mask) m); // specialize + (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector unslice(int origin) { - return (Byte64Vector) super.unsliceTemplate(origin); // specialize + public ByteVector64 unslice(int origin) { + return (ByteVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Byte64Vector rearrange(VectorShuffle s) { - return (Byte64Vector) - super.rearrangeTemplate(Byte64Shuffle.class, - (Byte64Shuffle) s); // specialize + public ByteVector64 rearrange(VectorShuffle s) { + return (ByteVector64) + super.rearrangeTemplate(ByteShuffle64.class, + (ByteShuffle64) s); // specialize } @Override @ForceInline - public Byte64Vector rearrange(VectorShuffle shuffle, + public ByteVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Byte64Vector) - super.rearrangeTemplate(Byte64Shuffle.class, - Byte64Mask.class, - (Byte64Shuffle) shuffle, - (Byte64Mask) m); // specialize + return (ByteVector64) + super.rearrangeTemplate(ByteShuffle64.class, + ByteMask64.class, + (ByteShuffle64) shuffle, + (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector rearrange(VectorShuffle s, + public ByteVector64 rearrange(VectorShuffle s, Vector v) { - return (Byte64Vector) - super.rearrangeTemplate(Byte64Shuffle.class, - (Byte64Shuffle) s, - (Byte64Vector) v); // specialize + return (ByteVector64) + super.rearrangeTemplate(ByteShuffle64.class, + (ByteShuffle64) s, + (ByteVector64) v); // specialize } @Override @ForceInline - public Byte64Vector compress(VectorMask m) { - return (Byte64Vector) - super.compressTemplate(Byte64Mask.class, - (Byte64Mask) m); // specialize + public ByteVector64 compress(VectorMask m) { + return (ByteVector64) + super.compressTemplate(ByteMask64.class, + (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector expand(VectorMask m) { - return (Byte64Vector) - super.expandTemplate(Byte64Mask.class, - (Byte64Mask) m); // specialize + public ByteVector64 expand(VectorMask m) { + return (ByteVector64) + super.expandTemplate(ByteMask64.class, + (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector selectFrom(Vector v) { - return (Byte64Vector) - super.selectFromTemplate((Byte64Vector) v); // specialize + public ByteVector64 selectFrom(Vector v) { + return (ByteVector64) + super.selectFromTemplate((ByteVector64) v); // specialize } @Override @ForceInline - public Byte64Vector selectFrom(Vector v, + public ByteVector64 selectFrom(Vector v, VectorMask m) { - return (Byte64Vector) - super.selectFromTemplate((Byte64Vector) v, - Byte64Mask.class, (Byte64Mask) m); // specialize + return (ByteVector64) + super.selectFromTemplate((ByteVector64) v, + ByteMask64.class, (ByteMask64) m); // specialize } @Override @ForceInline - public Byte64Vector selectFrom(Vector v1, + public ByteVector64 selectFrom(Vector v1, Vector v2) { - return (Byte64Vector) - super.selectFromTemplate((Byte64Vector) v1, (Byte64Vector) v2); // specialize + return (ByteVector64) + super.selectFromTemplate((ByteVector64) v1, (ByteVector64) v2); // specialize } @ForceInline @@ -550,7 +555,7 @@ final class Byte64Vector extends ByteVector { @ForceInline @Override - public Byte64Vector withLane(int i, byte e) { + public ByteVector64 withLane(int i, byte e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -565,7 +570,7 @@ final class Byte64Vector extends ByteVector { } @ForceInline - public Byte64Vector withLaneHelper(int i, byte e) { + public ByteVector64 withLaneHelper(int i, byte e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -577,20 +582,21 @@ final class Byte64Vector extends ByteVector { } // Mask - - static final class Byte64Mask extends AbstractMask { + @ValueBased + static final class ByteMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte64Mask(boolean[] bits) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteMask64(boolean[] bits) { this(bits, 0); } - Byte64Mask(boolean[] bits, int offset) { + ByteMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Byte64Mask(boolean val) { + ByteMask64(boolean val) { super(prepare(val)); } @@ -623,31 +629,31 @@ final class Byte64Vector extends ByteVector { } @Override - Byte64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Byte64Mask(res); + return new ByteMask64(res); } @Override - Byte64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Byte64Mask)m).getBits(); + boolean[] mbits = ((ByteMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Byte64Mask(res); + return new ByteMask64(res); } @ForceInline @Override public final - Byte64Vector toVector() { - return (Byte64Vector) super.toVectorTemplate(); // specialize + ByteVector64 toVector() { + return (ByteVector64) super.toVectorTemplate(); // specialize } /** @@ -680,25 +686,25 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline /*package-private*/ - Byte64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Byte64Mask) VectorSupport.indexPartiallyInUpperRange( - Byte64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Byte64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ByteMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMask64) VectorSupport.indexPartiallyInUpperRange( + ByteMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ByteMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Byte64Mask not() { + public ByteMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Byte64Mask compress() { - return (Byte64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte64Vector.class, Byte64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ByteMask64 compress() { + return (ByteMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ByteVector64.class, ByteMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -707,30 +713,30 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline - public Byte64Mask and(VectorMask mask) { + public ByteMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask64 m = (ByteMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Byte64Mask or(VectorMask mask) { + public ByteMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask64 m = (ByteMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Byte64Mask xor(VectorMask mask) { + public ByteMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMask64 m = (ByteMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -740,21 +746,21 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -764,7 +770,7 @@ final class Byte64Vector extends ByteVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -774,7 +780,7 @@ final class Byte64Vector extends ByteVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ByteMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -783,48 +789,49 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte64Mask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ByteMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ByteMask64)m).getBits())); } @ForceInline /*package-private*/ - static Byte64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ByteMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ByteMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Byte64Mask TRUE_MASK = new Byte64Mask(true); - private static final Byte64Mask FALSE_MASK = new Byte64Mask(false); + private static final ByteMask64 TRUE_MASK = new ByteMask64(true); + private static final ByteMask64 FALSE_MASK = new ByteMask64(false); } // Shuffle - - static final class Byte64Shuffle extends AbstractShuffle { + @ValueBased + static final class ByteShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - Byte64Shuffle(byte[] indices) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteShuffle64(byte[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Byte64Shuffle(int[] indices, int i) { + ByteShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Byte64Shuffle(IntUnaryOperator fn) { + ByteShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -844,23 +851,23 @@ final class Byte64Vector extends ByteVector { assert(VLENGTH < Byte.MAX_VALUE); assert(Byte.MIN_VALUE <= -VLENGTH); } - static final Byte64Shuffle IOTA = new Byte64Shuffle(IDENTITY); + static final ByteShuffle64 IOTA = new ByteShuffle64(IDENTITY); @Override @ForceInline - public Byte64Vector toVector() { + public ByteVector64 toVector() { return toBitsVector(); } @Override @ForceInline - Byte64Vector toBitsVector() { - return (Byte64Vector) super.toBitsVectorTemplate(); + ByteVector64 toBitsVector() { + return (ByteVector64) super.toBitsVectorTemplate(); } @Override - Byte64Vector toBitsVector0() { - return ((Byte64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ByteVector64 toBitsVector0() { + return ((ByteVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -909,30 +916,30 @@ final class Byte64Vector extends ByteVector { @Override @ForceInline - public final Byte64Mask laneIsValid() { - return (Byte64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ByteMask64 laneIsValid() { + return (ByteMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Byte64Shuffle rearrange(VectorShuffle shuffle) { - Byte64Shuffle concreteShuffle = (Byte64Shuffle) shuffle; - return (Byte64Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ByteShuffle64 rearrange(VectorShuffle shuffle) { + ByteShuffle64 concreteShuffle = (ByteShuffle64) shuffle; + return (ByteShuffle64) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Byte64Shuffle wrapIndexes() { - Byte64Vector v = toBitsVector(); + public final ByteShuffle64 wrapIndexes() { + ByteVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Byte64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ByteVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Byte64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ByteVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Byte64Shuffle) v.toShuffle(vspecies(), false); + return (ByteShuffle64) v.toShuffle(VSPECIES, false); } private static byte[] prepare(int[] indices, int offset) { @@ -983,14 +990,14 @@ final class Byte64Vector extends ByteVector { @Override final ByteVector fromArray0(byte[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Byte64Mask.class, a, offset, (Byte64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ByteMask64.class, a, offset, (ByteMask64) m, offsetInRange); // specialize } @ForceInline @Override final ByteVector fromArray0(byte[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Byte64Mask.class, a, offset, indexMap, mapOffset, (Byte64Mask) m); + return super.fromArray0Template(ByteMask64.class, a, offset, indexMap, mapOffset, (ByteMask64) m); } @@ -1005,7 +1012,7 @@ final class Byte64Vector extends ByteVector { @Override final ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromBooleanArray0Template(Byte64Mask.class, a, offset, (Byte64Mask) m, offsetInRange); // specialize + return super.fromBooleanArray0Template(ByteMask64.class, a, offset, (ByteMask64) m, offsetInRange); // specialize } @ForceInline @@ -1019,7 +1026,7 @@ final class Byte64Vector extends ByteVector { @Override final ByteVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Byte64Mask.class, ms, offset, (Byte64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ByteMask64.class, ms, offset, (ByteMask64) m, offsetInRange); // specialize } @ForceInline @@ -1033,7 +1040,7 @@ final class Byte64Vector extends ByteVector { @Override final void intoArray0(byte[] a, int offset, VectorMask m) { - super.intoArray0Template(Byte64Mask.class, a, offset, (Byte64Mask) m); + super.intoArray0Template(ByteMask64.class, a, offset, (ByteMask64) m); } @@ -1041,14 +1048,14 @@ final class Byte64Vector extends ByteVector { @Override final void intoBooleanArray0(boolean[] a, int offset, VectorMask m) { - super.intoBooleanArray0Template(Byte64Mask.class, a, offset, (Byte64Mask) m); + super.intoBooleanArray0Template(ByteMask64.class, a, offset, (ByteMask64) m); } @ForceInline @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Byte64Mask.class, ms, offset, (Byte64Mask) m); + super.intoMemorySegment0Template(ByteMask64.class, ms, offset, (ByteMask64) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVectorMax.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVectorMax.java index 8c3cc68cece..0084995346b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVectorMax.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class ByteMaxVector extends ByteVector { +@ValueBased +final class ByteVectorMax extends ByteVector { static final ByteSpecies VSPECIES = (ByteSpecies) ByteVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = ByteMaxVector.class; + static final Class VCLASS = ByteVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + static final Class ETYPE = byte.class; // used by the JVM - ByteMaxVector(byte[] v) { + ByteVectorMax(byte[] v) { super(v); } - // For compatibility as ByteMaxVector::new, + // For compatibility as ByteVectorMax::new, // stored into species.vectorFactory. - ByteMaxVector(Object v) { + ByteVectorMax(Object v) { this((byte[]) v); } - static final ByteMaxVector ZERO = new ByteMaxVector(new byte[VLENGTH]); - static final ByteMaxVector IOTA = new ByteMaxVector(VSPECIES.iotaArray()); + static final ByteVectorMax ZERO = new ByteVectorMax(new byte[VLENGTH]); + static final ByteVectorMax IOTA = new ByteVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class ByteMaxVector extends ByteVector { @Override public final Class elementType() { return byte.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Byte.SIZE; } @@ -130,51 +135,51 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline - public final ByteMaxVector broadcast(byte e) { - return (ByteMaxVector) super.broadcastTemplate(e); // specialize + public final ByteVectorMax broadcast(byte e) { + return (ByteVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final ByteMaxVector broadcast(long e) { - return (ByteMaxVector) super.broadcastTemplate(e); // specialize + public final ByteVectorMax broadcast(long e) { + return (ByteVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - ByteMaxMask maskFromArray(boolean[] bits) { - return new ByteMaxMask(bits); + ByteMaskMax maskFromArray(boolean[] bits) { + return new ByteMaskMax(bits); } @Override @ForceInline - ByteMaxShuffle iotaShuffle() { return ByteMaxShuffle.IOTA; } + ByteShuffleMax iotaShuffle() { return ByteShuffleMax.IOTA; } @Override @ForceInline - ByteMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (ByteMaxShuffle) iotaShuffleTemplate((byte) start, (byte) step, wrap); + ByteShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (ByteShuffleMax) iotaShuffleTemplate((byte) start, (byte) step, wrap); } @Override @ForceInline - ByteMaxShuffle shuffleFromArray(int[] indices, int i) { return new ByteMaxShuffle(indices, i); } + ByteShuffleMax shuffleFromArray(int[] indices, int i) { return new ByteShuffleMax(indices, i); } @Override @ForceInline - ByteMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new ByteMaxShuffle(fn); } + ByteShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new ByteShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - ByteMaxVector vectorFactory(byte[] vec) { - return new ByteMaxVector(vec); + ByteVectorMax vectorFactory(byte[] vec) { + return new ByteVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class ByteMaxVector extends ByteVector { @ForceInline final @Override - ByteMaxVector uOp(FUnOp f) { - return (ByteMaxVector) super.uOpTemplate(f); // specialize + ByteVectorMax uOp(FUnOp f) { + return (ByteVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - ByteMaxVector uOp(VectorMask m, FUnOp f) { - return (ByteMaxVector) - super.uOpTemplate((ByteMaxMask)m, f); // specialize + ByteVectorMax uOp(VectorMask m, FUnOp f) { + return (ByteVectorMax) + super.uOpTemplate((ByteMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - ByteMaxVector bOp(Vector v, FBinOp f) { - return (ByteMaxVector) super.bOpTemplate((ByteMaxVector)v, f); // specialize + ByteVectorMax bOp(Vector v, FBinOp f) { + return (ByteVectorMax) super.bOpTemplate((ByteVectorMax)v, f); // specialize } @ForceInline final @Override - ByteMaxVector bOp(Vector v, + ByteVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (ByteMaxVector) - super.bOpTemplate((ByteMaxVector)v, (ByteMaxMask)m, + return (ByteVectorMax) + super.bOpTemplate((ByteVectorMax)v, (ByteMaskMax)m, f); // specialize } @@ -219,19 +224,19 @@ final class ByteMaxVector extends ByteVector { @ForceInline final @Override - ByteMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (ByteMaxVector) - super.tOpTemplate((ByteMaxVector)v1, (ByteMaxVector)v2, + ByteVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (ByteVectorMax) + super.tOpTemplate((ByteVectorMax)v1, (ByteVectorMax)v2, f); // specialize } @ForceInline final @Override - ByteMaxVector tOp(Vector v1, Vector v2, + ByteVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (ByteMaxVector) - super.tOpTemplate((ByteMaxVector)v1, (ByteMaxVector)v2, - (ByteMaxMask)m, f); // specialize + return (ByteVectorMax) + super.tOpTemplate((ByteVectorMax)v1, (ByteVectorMax)v2, + (ByteMaskMax)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline - public ByteMaxVector lanewise(Unary op) { - return (ByteMaxVector) super.lanewiseTemplate(op); // specialize + public ByteVectorMax lanewise(Unary op) { + return (ByteVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public ByteMaxVector lanewise(Unary op, VectorMask m) { - return (ByteMaxVector) super.lanewiseTemplate(op, ByteMaxMask.class, (ByteMaxMask) m); // specialize + public ByteVectorMax lanewise(Unary op, VectorMask m) { + return (ByteVectorMax) super.lanewiseTemplate(op, ByteMaskMax.class, (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector lanewise(Binary op, Vector v) { - return (ByteMaxVector) super.lanewiseTemplate(op, v); // specialize + public ByteVectorMax lanewise(Binary op, Vector v) { + return (ByteVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public ByteMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (ByteMaxVector) super.lanewiseTemplate(op, ByteMaxMask.class, v, (ByteMaxMask) m); // specialize + public ByteVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (ByteVectorMax) super.lanewiseTemplate(op, ByteMaskMax.class, v, (ByteMaskMax) m); // specialize } /*package-private*/ @Override - @ForceInline ByteMaxVector + @ForceInline ByteVectorMax lanewiseShift(VectorOperators.Binary op, int e) { - return (ByteMaxVector) super.lanewiseShiftTemplate(op, e); // specialize + return (ByteVectorMax) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline ByteMaxVector + @ForceInline ByteVectorMax lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (ByteMaxVector) super.lanewiseShiftTemplate(op, ByteMaxMask.class, e, (ByteMaxMask) m); // specialize + return (ByteVectorMax) super.lanewiseShiftTemplate(op, ByteMaskMax.class, e, (ByteMaskMax) m); // specialize } /*package-private*/ @Override @ForceInline public final - ByteMaxVector + ByteVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (ByteMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ByteVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - ByteMaxVector + ByteVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (ByteMaxVector) super.lanewiseTemplate(op, ByteMaxMask.class, v1, v2, (ByteMaxMask) m); // specialize + return (ByteVectorMax) super.lanewiseTemplate(op, ByteMaskMax.class, v1, v2, (ByteMaskMax) m); // specialize } @Override @ForceInline public final - ByteMaxVector addIndex(int scale) { - return (ByteMaxVector) super.addIndexTemplate(scale); // specialize + ByteVectorMax addIndex(int scale) { + return (ByteVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class ByteMaxVector extends ByteVector { @ForceInline public final byte reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, ByteMaxMask.class, (ByteMaxMask) m); // specialized + return super.reduceLanesTemplate(op, ByteMaskMax.class, (ByteMaskMax) m); // specialized } @Override @@ -354,7 +359,7 @@ final class ByteMaxVector extends ByteVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, ByteMaxMask.class, (ByteMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, ByteMaskMax.class, (ByteMaskMax) m); // specialized } @Override @@ -365,160 +370,160 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline - public final ByteMaxShuffle toShuffle() { - return (ByteMaxShuffle) toShuffle(vspecies(), false); + public final ByteShuffleMax toShuffle() { + return (ByteShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final ByteMaxMask test(Test op) { - return super.testTemplate(ByteMaxMask.class, op); // specialize + public final ByteMaskMax test(Test op) { + return super.testTemplate(ByteMaskMax.class, op); // specialize } @Override @ForceInline - public final ByteMaxMask test(Test op, VectorMask m) { - return super.testTemplate(ByteMaxMask.class, op, (ByteMaxMask) m); // specialize + public final ByteMaskMax test(Test op, VectorMask m) { + return super.testTemplate(ByteMaskMax.class, op, (ByteMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final ByteMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(ByteMaxMask.class, op, v); // specialize + public final ByteMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(ByteMaskMax.class, op, v); // specialize } @Override @ForceInline - public final ByteMaxMask compare(Comparison op, byte s) { - return super.compareTemplate(ByteMaxMask.class, op, s); // specialize + public final ByteMaskMax compare(Comparison op, byte s) { + return super.compareTemplate(ByteMaskMax.class, op, s); // specialize } @Override @ForceInline - public final ByteMaxMask compare(Comparison op, long s) { - return super.compareTemplate(ByteMaxMask.class, op, s); // specialize + public final ByteMaskMax compare(Comparison op, long s) { + return super.compareTemplate(ByteMaskMax.class, op, s); // specialize } @Override @ForceInline - public final ByteMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(ByteMaxMask.class, op, v, (ByteMaxMask) m); + public final ByteMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ByteMaskMax.class, op, v, (ByteMaskMax) m); } @Override @ForceInline - public ByteMaxVector blend(Vector v, VectorMask m) { - return (ByteMaxVector) - super.blendTemplate(ByteMaxMask.class, - (ByteMaxVector) v, - (ByteMaxMask) m); // specialize + public ByteVectorMax blend(Vector v, VectorMask m) { + return (ByteVectorMax) + super.blendTemplate(ByteMaskMax.class, + (ByteVectorMax) v, + (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector slice(int origin, Vector v) { - return (ByteMaxVector) super.sliceTemplate(origin, v); // specialize + public ByteVectorMax slice(int origin, Vector v) { + return (ByteVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public ByteMaxVector slice(int origin) { - return (ByteMaxVector) super.sliceTemplate(origin); // specialize + public ByteVectorMax slice(int origin) { + return (ByteVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public ByteMaxVector unslice(int origin, Vector w, int part) { - return (ByteMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public ByteVectorMax unslice(int origin, Vector w, int part) { + return (ByteVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public ByteMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (ByteMaxVector) - super.unsliceTemplate(ByteMaxMask.class, + public ByteVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (ByteVectorMax) + super.unsliceTemplate(ByteMaskMax.class, origin, w, part, - (ByteMaxMask) m); // specialize + (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector unslice(int origin) { - return (ByteMaxVector) super.unsliceTemplate(origin); // specialize + public ByteVectorMax unslice(int origin) { + return (ByteVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public ByteMaxVector rearrange(VectorShuffle s) { - return (ByteMaxVector) - super.rearrangeTemplate(ByteMaxShuffle.class, - (ByteMaxShuffle) s); // specialize + public ByteVectorMax rearrange(VectorShuffle s) { + return (ByteVectorMax) + super.rearrangeTemplate(ByteShuffleMax.class, + (ByteShuffleMax) s); // specialize } @Override @ForceInline - public ByteMaxVector rearrange(VectorShuffle shuffle, + public ByteVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (ByteMaxVector) - super.rearrangeTemplate(ByteMaxShuffle.class, - ByteMaxMask.class, - (ByteMaxShuffle) shuffle, - (ByteMaxMask) m); // specialize + return (ByteVectorMax) + super.rearrangeTemplate(ByteShuffleMax.class, + ByteMaskMax.class, + (ByteShuffleMax) shuffle, + (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector rearrange(VectorShuffle s, + public ByteVectorMax rearrange(VectorShuffle s, Vector v) { - return (ByteMaxVector) - super.rearrangeTemplate(ByteMaxShuffle.class, - (ByteMaxShuffle) s, - (ByteMaxVector) v); // specialize + return (ByteVectorMax) + super.rearrangeTemplate(ByteShuffleMax.class, + (ByteShuffleMax) s, + (ByteVectorMax) v); // specialize } @Override @ForceInline - public ByteMaxVector compress(VectorMask m) { - return (ByteMaxVector) - super.compressTemplate(ByteMaxMask.class, - (ByteMaxMask) m); // specialize + public ByteVectorMax compress(VectorMask m) { + return (ByteVectorMax) + super.compressTemplate(ByteMaskMax.class, + (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector expand(VectorMask m) { - return (ByteMaxVector) - super.expandTemplate(ByteMaxMask.class, - (ByteMaxMask) m); // specialize + public ByteVectorMax expand(VectorMask m) { + return (ByteVectorMax) + super.expandTemplate(ByteMaskMax.class, + (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector selectFrom(Vector v) { - return (ByteMaxVector) - super.selectFromTemplate((ByteMaxVector) v); // specialize + public ByteVectorMax selectFrom(Vector v) { + return (ByteVectorMax) + super.selectFromTemplate((ByteVectorMax) v); // specialize } @Override @ForceInline - public ByteMaxVector selectFrom(Vector v, + public ByteVectorMax selectFrom(Vector v, VectorMask m) { - return (ByteMaxVector) - super.selectFromTemplate((ByteMaxVector) v, - ByteMaxMask.class, (ByteMaxMask) m); // specialize + return (ByteVectorMax) + super.selectFromTemplate((ByteVectorMax) v, + ByteMaskMax.class, (ByteMaskMax) m); // specialize } @Override @ForceInline - public ByteMaxVector selectFrom(Vector v1, + public ByteVectorMax selectFrom(Vector v1, Vector v2) { - return (ByteMaxVector) - super.selectFromTemplate((ByteMaxVector) v1, (ByteMaxVector) v2); // specialize + return (ByteVectorMax) + super.selectFromTemplate((ByteVectorMax) v1, (ByteVectorMax) v2); // specialize } @ForceInline @@ -543,7 +548,7 @@ final class ByteMaxVector extends ByteVector { @ForceInline @Override - public ByteMaxVector withLane(int i, byte e) { + public ByteVectorMax withLane(int i, byte e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -551,7 +556,7 @@ final class ByteMaxVector extends ByteVector { } @ForceInline - public ByteMaxVector withLaneHelper(int i, byte e) { + public ByteVectorMax withLaneHelper(int i, byte e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -563,20 +568,21 @@ final class ByteMaxVector extends ByteVector { } // Mask - - static final class ByteMaxMask extends AbstractMask { + @ValueBased + static final class ByteMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - ByteMaxMask(boolean[] bits) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteMaskMax(boolean[] bits) { this(bits, 0); } - ByteMaxMask(boolean[] bits, int offset) { + ByteMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - ByteMaxMask(boolean val) { + ByteMaskMax(boolean val) { super(prepare(val)); } @@ -609,31 +615,31 @@ final class ByteMaxVector extends ByteVector { } @Override - ByteMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new ByteMaxMask(res); + return new ByteMaskMax(res); } @Override - ByteMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ByteMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((ByteMaxMask)m).getBits(); + boolean[] mbits = ((ByteMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new ByteMaxMask(res); + return new ByteMaskMax(res); } @ForceInline @Override public final - ByteMaxVector toVector() { - return (ByteMaxVector) super.toVectorTemplate(); // specialize + ByteVectorMax toVector() { + return (ByteVectorMax) super.toVectorTemplate(); // specialize } /** @@ -666,25 +672,25 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline /*package-private*/ - ByteMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (ByteMaxMask) VectorSupport.indexPartiallyInUpperRange( - ByteMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (ByteMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + ByteMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMaskMax) VectorSupport.indexPartiallyInUpperRange( + ByteMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ByteMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public ByteMaxMask not() { + public ByteMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public ByteMaxMask compress() { - return (ByteMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - ByteMaxVector.class, ByteMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ByteMaskMax compress() { + return (ByteMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ByteVectorMax.class, ByteMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -693,30 +699,30 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline - public ByteMaxMask and(VectorMask mask) { + public ByteMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMaskMax m = (ByteMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public ByteMaxMask or(VectorMask mask) { + public ByteMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMaskMax m = (ByteMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public ByteMaxMask xor(VectorMask mask) { + public ByteMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ByteMaskMax m = (ByteMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -726,21 +732,21 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -750,7 +756,7 @@ final class ByteMaxVector extends ByteVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -760,7 +766,7 @@ final class ByteMaxVector extends ByteVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(ByteMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ByteMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -769,48 +775,49 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((ByteMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ByteMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((ByteMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ByteMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static ByteMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(ByteMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ByteMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ByteMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final ByteMaxMask TRUE_MASK = new ByteMaxMask(true); - private static final ByteMaxMask FALSE_MASK = new ByteMaxMask(false); + private static final ByteMaskMax TRUE_MASK = new ByteMaskMax(true); + private static final ByteMaskMax FALSE_MASK = new ByteMaskMax(false); } // Shuffle - - static final class ByteMaxShuffle extends AbstractShuffle { + @ValueBased + static final class ByteShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM - ByteMaxShuffle(byte[] indices) { + static final Class CTYPE = byte.class; // used by the JVM + + ByteShuffleMax(byte[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - ByteMaxShuffle(int[] indices, int i) { + ByteShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - ByteMaxShuffle(IntUnaryOperator fn) { + ByteShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -830,23 +837,23 @@ final class ByteMaxVector extends ByteVector { assert(VLENGTH < Byte.MAX_VALUE); assert(Byte.MIN_VALUE <= -VLENGTH); } - static final ByteMaxShuffle IOTA = new ByteMaxShuffle(IDENTITY); + static final ByteShuffleMax IOTA = new ByteShuffleMax(IDENTITY); @Override @ForceInline - public ByteMaxVector toVector() { + public ByteVectorMax toVector() { return toBitsVector(); } @Override @ForceInline - ByteMaxVector toBitsVector() { - return (ByteMaxVector) super.toBitsVectorTemplate(); + ByteVectorMax toBitsVector() { + return (ByteVectorMax) super.toBitsVectorTemplate(); } @Override - ByteMaxVector toBitsVector0() { - return ((ByteMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ByteVectorMax toBitsVector0() { + return ((ByteVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -895,30 +902,30 @@ final class ByteMaxVector extends ByteVector { @Override @ForceInline - public final ByteMaxMask laneIsValid() { - return (ByteMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ByteMaskMax laneIsValid() { + return (ByteMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final ByteMaxShuffle rearrange(VectorShuffle shuffle) { - ByteMaxShuffle concreteShuffle = (ByteMaxShuffle) shuffle; - return (ByteMaxShuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ByteShuffleMax rearrange(VectorShuffle shuffle) { + ByteShuffleMax concreteShuffle = (ByteShuffleMax) shuffle; + return (ByteShuffleMax) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final ByteMaxShuffle wrapIndexes() { - ByteMaxVector v = toBitsVector(); + public final ByteShuffleMax wrapIndexes() { + ByteVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (ByteMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ByteVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (ByteMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ByteVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (ByteMaxShuffle) v.toShuffle(vspecies(), false); + return (ByteShuffleMax) v.toShuffle(VSPECIES, false); } private static byte[] prepare(int[] indices, int offset) { @@ -969,14 +976,14 @@ final class ByteMaxVector extends ByteVector { @Override final ByteVector fromArray0(byte[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(ByteMaxMask.class, a, offset, (ByteMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(ByteMaskMax.class, a, offset, (ByteMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final ByteVector fromArray0(byte[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(ByteMaxMask.class, a, offset, indexMap, mapOffset, (ByteMaxMask) m); + return super.fromArray0Template(ByteMaskMax.class, a, offset, indexMap, mapOffset, (ByteMaskMax) m); } @@ -991,7 +998,7 @@ final class ByteMaxVector extends ByteVector { @Override final ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromBooleanArray0Template(ByteMaxMask.class, a, offset, (ByteMaxMask) m, offsetInRange); // specialize + return super.fromBooleanArray0Template(ByteMaskMax.class, a, offset, (ByteMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -1005,7 +1012,7 @@ final class ByteMaxVector extends ByteVector { @Override final ByteVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(ByteMaxMask.class, ms, offset, (ByteMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ByteMaskMax.class, ms, offset, (ByteMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -1019,7 +1026,7 @@ final class ByteMaxVector extends ByteVector { @Override final void intoArray0(byte[] a, int offset, VectorMask m) { - super.intoArray0Template(ByteMaxMask.class, a, offset, (ByteMaxMask) m); + super.intoArray0Template(ByteMaskMax.class, a, offset, (ByteMaskMax) m); } @@ -1027,14 +1034,14 @@ final class ByteMaxVector extends ByteVector { @Override final void intoBooleanArray0(boolean[] a, int offset, VectorMask m) { - super.intoBooleanArray0Template(ByteMaxMask.class, a, offset, (ByteMaxMask) m); + super.intoBooleanArray0Template(ByteMaskMax.class, a, offset, (ByteMaskMax) m); } @ForceInline @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(ByteMaxMask.class, ms, offset, (ByteMaxMask) m); + super.intoMemorySegment0Template(ByteMaskMax.class, ms, offset, (ByteMaskMax) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/CPUFeatures.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/CPUFeatures.java index c0d8ef03ada..0ad7ba1651d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/CPUFeatures.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/CPUFeatures.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -36,7 +36,7 @@ import static jdk.internal.vm.vector.Utils.debug; /** * Enumerates CPU ISA extensions supported by the JVM on the current hardware. */ -/*package-private*/ class CPUFeatures { +/*package-private*/ final class CPUFeatures { private static final Set features = getCPUFeatures(); private static Set getCPUFeatures() { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index 70be5f829f0..6f9b5e53ead 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code double} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class DoubleVector extends AbstractVector { +public abstract sealed class DoubleVector extends AbstractVector + permits DoubleVector64, DoubleVector128, DoubleVector256, DoubleVector512, DoubleVectorMax { DoubleVector(double[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class DoubleVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -724,7 +725,7 @@ public abstract class DoubleVector extends AbstractVector { @ForceInline final DoubleVector unaryMathOp(VectorOperators.Unary op) { - return VectorMathLibrary.unaryMathOp(op, opCode(op), species(), DoubleVector::unaryOperations, + return VectorMathLibrary.unaryMathOp(op, opCode(op), vspecies(), DoubleVector::unaryOperations, this); } @@ -851,7 +852,7 @@ public abstract class DoubleVector extends AbstractVector { @ForceInline final DoubleVector binaryMathOp(VectorOperators.Binary op, DoubleVector that) { - return VectorMathLibrary.binaryMathOp(op, opCode(op), species(), DoubleVector::binaryOperations, + return VectorMathLibrary.binaryMathOp(op, opCode(op), vspecies(), DoubleVector::binaryOperations, this, that); } @@ -2921,7 +2922,7 @@ public abstract class DoubleVector extends AbstractVector { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For DoubleMaxVector, if vector length is non-power-of-two or + // For DoubleVectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of Double species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of Double // vector is 32. When converting Double species to int species, @@ -2929,7 +2930,7 @@ public abstract class DoubleVector extends AbstractVector { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3212,14 +3213,14 @@ public abstract class DoubleVector extends AbstractVector { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For DoubleMaxVector, if vector length is 2048 bits, indexShape + // For DoubleVectorMax, if vector length is 2048 bits, indexShape // of Double species is S_MAX_BIT. and the lane count of Double // vector is 32. When converting Double species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3406,7 +3407,7 @@ public abstract class DoubleVector extends AbstractVector { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For DoubleMaxVector, if vector length is non-power-of-two or + // For DoubleVectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of Double species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of Double // vector is 32. When converting Double species to int species, @@ -3414,7 +3415,7 @@ public abstract class DoubleVector extends AbstractVector { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3522,14 +3523,14 @@ public abstract class DoubleVector extends AbstractVector { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For DoubleMaxVector, if vector length is 2048 bits, indexShape + // For DoubleVectorMax, if vector length is 2048 bits, indexShape // of Double species is S_MAX_BIT. and the lane count of Double // vector is 32. When converting Double species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3976,13 +3977,13 @@ public abstract class DoubleVector extends AbstractVector { @Override @ForceInline public final DoubleVector zero() { - if ((Class) vectorType() == DoubleMaxVector.class) - return DoubleMaxVector.ZERO; + if ((Class) vectorType() == DoubleVectorMax.class) + return DoubleVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Double64Vector.ZERO; - case 128: return Double128Vector.ZERO; - case 256: return Double256Vector.ZERO; - case 512: return Double512Vector.ZERO; + case 64: return DoubleVector64.ZERO; + case 128: return DoubleVector128.ZERO; + case 256: return DoubleVector256.ZERO; + case 512: return DoubleVector512.ZERO; } throw new AssertionError(); } @@ -3990,13 +3991,13 @@ public abstract class DoubleVector extends AbstractVector { @Override @ForceInline public final DoubleVector iota() { - if ((Class) vectorType() == DoubleMaxVector.class) - return DoubleMaxVector.IOTA; + if ((Class) vectorType() == DoubleVectorMax.class) + return DoubleVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Double64Vector.IOTA; - case 128: return Double128Vector.IOTA; - case 256: return Double256Vector.IOTA; - case 512: return Double512Vector.IOTA; + case 64: return DoubleVector64.IOTA; + case 128: return DoubleVector128.IOTA; + case 256: return DoubleVector256.IOTA; + case 512: return DoubleVector512.IOTA; } throw new AssertionError(); } @@ -4005,13 +4006,13 @@ public abstract class DoubleVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == DoubleMaxVector.class) - return DoubleMaxVector.DoubleMaxMask.maskAll(bit); + if ((Class) vectorType() == DoubleVectorMax.class) + return DoubleVectorMax.DoubleMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Double64Vector.Double64Mask.maskAll(bit); - case 128: return Double128Vector.Double128Mask.maskAll(bit); - case 256: return Double256Vector.Double256Mask.maskAll(bit); - case 512: return Double512Vector.Double512Mask.maskAll(bit); + case 64: return DoubleVector64.DoubleMask64.maskAll(bit); + case 128: return DoubleVector128.DoubleMask128.maskAll(bit); + case 256: return DoubleVector256.DoubleMask256.maskAll(bit); + case 512: return DoubleVector512.DoubleMask512.maskAll(bit); } throw new AssertionError(); } @@ -4039,42 +4040,42 @@ public abstract class DoubleVector extends AbstractVector { /** Species representing {@link DoubleVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new DoubleSpecies(VectorShape.S_64_BIT, - Double64Vector.class, - Double64Vector.Double64Mask.class, - Double64Vector.Double64Shuffle.class, - Double64Vector::new); + DoubleVector64.class, + DoubleVector64.DoubleMask64.class, + DoubleVector64.DoubleShuffle64.class, + DoubleVector64::new); /** Species representing {@link DoubleVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new DoubleSpecies(VectorShape.S_128_BIT, - Double128Vector.class, - Double128Vector.Double128Mask.class, - Double128Vector.Double128Shuffle.class, - Double128Vector::new); + DoubleVector128.class, + DoubleVector128.DoubleMask128.class, + DoubleVector128.DoubleShuffle128.class, + DoubleVector128::new); /** Species representing {@link DoubleVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new DoubleSpecies(VectorShape.S_256_BIT, - Double256Vector.class, - Double256Vector.Double256Mask.class, - Double256Vector.Double256Shuffle.class, - Double256Vector::new); + DoubleVector256.class, + DoubleVector256.DoubleMask256.class, + DoubleVector256.DoubleShuffle256.class, + DoubleVector256::new); /** Species representing {@link DoubleVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new DoubleSpecies(VectorShape.S_512_BIT, - Double512Vector.class, - Double512Vector.Double512Mask.class, - Double512Vector.Double512Shuffle.class, - Double512Vector::new); + DoubleVector512.class, + DoubleVector512.DoubleMask512.class, + DoubleVector512.DoubleShuffle512.class, + DoubleVector512::new); /** Species representing {@link DoubleVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new DoubleSpecies(VectorShape.S_Max_BIT, - DoubleMaxVector.class, - DoubleMaxVector.DoubleMaxMask.class, - DoubleMaxVector.DoubleMaxShuffle.class, - DoubleMaxVector::new); + DoubleVectorMax.class, + DoubleVectorMax.DoubleMaskMax.class, + DoubleVectorMax.DoubleShuffleMax.class, + DoubleVectorMax::new); /** * Preferred species for {@link DoubleVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector128.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector128.java index f00efcf5163..8d3ec21ec9b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector128.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Double128Vector extends DoubleVector { +@ValueBased +final class DoubleVector128 extends DoubleVector { static final DoubleSpecies VSPECIES = (DoubleSpecies) DoubleVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Double128Vector.class; + static final Class VCLASS = DoubleVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + static final Class ETYPE = double.class; // used by the JVM - Double128Vector(double[] v) { + DoubleVector128(double[] v) { super(v); } - // For compatibility as Double128Vector::new, + // For compatibility as DoubleVector128::new, // stored into species.vectorFactory. - Double128Vector(Object v) { + DoubleVector128(Object v) { this((double[]) v); } - static final Double128Vector ZERO = new Double128Vector(new double[VLENGTH]); - static final Double128Vector IOTA = new Double128Vector(VSPECIES.iotaArray()); + static final DoubleVector128 ZERO = new DoubleVector128(new double[VLENGTH]); + static final DoubleVector128 IOTA = new DoubleVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Double128Vector extends DoubleVector { @Override public final Class elementType() { return double.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Double.SIZE; } @@ -130,51 +136,51 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline - public final Double128Vector broadcast(double e) { - return (Double128Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector128 broadcast(double e) { + return (DoubleVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Double128Vector broadcast(long e) { - return (Double128Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector128 broadcast(long e) { + return (DoubleVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Double128Mask maskFromArray(boolean[] bits) { - return new Double128Mask(bits); + DoubleMask128 maskFromArray(boolean[] bits) { + return new DoubleMask128(bits); } @Override @ForceInline - Double128Shuffle iotaShuffle() { return Double128Shuffle.IOTA; } + DoubleShuffle128 iotaShuffle() { return DoubleShuffle128.IOTA; } @Override @ForceInline - Double128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Double128Shuffle) iotaShuffleTemplate(start, step, wrap); + DoubleShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (DoubleShuffle128) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Double128Shuffle shuffleFromArray(int[] indices, int i) { return new Double128Shuffle(indices, i); } + DoubleShuffle128 shuffleFromArray(int[] indices, int i) { return new DoubleShuffle128(indices, i); } @Override @ForceInline - Double128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Double128Shuffle(fn); } + DoubleShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new DoubleShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Double128Vector vectorFactory(double[] vec) { - return new Double128Vector(vec); + DoubleVector128 vectorFactory(double[] vec) { + return new DoubleVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +193,31 @@ final class Double128Vector extends DoubleVector { @ForceInline final @Override - Double128Vector uOp(FUnOp f) { - return (Double128Vector) super.uOpTemplate(f); // specialize + DoubleVector128 uOp(FUnOp f) { + return (DoubleVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Double128Vector uOp(VectorMask m, FUnOp f) { - return (Double128Vector) - super.uOpTemplate((Double128Mask)m, f); // specialize + DoubleVector128 uOp(VectorMask m, FUnOp f) { + return (DoubleVector128) + super.uOpTemplate((DoubleMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Double128Vector bOp(Vector v, FBinOp f) { - return (Double128Vector) super.bOpTemplate((Double128Vector)v, f); // specialize + DoubleVector128 bOp(Vector v, FBinOp f) { + return (DoubleVector128) super.bOpTemplate((DoubleVector128)v, f); // specialize } @ForceInline final @Override - Double128Vector bOp(Vector v, + DoubleVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Double128Vector) - super.bOpTemplate((Double128Vector)v, (Double128Mask)m, + return (DoubleVector128) + super.bOpTemplate((DoubleVector128)v, (DoubleMask128)m, f); // specialize } @@ -219,19 +225,19 @@ final class Double128Vector extends DoubleVector { @ForceInline final @Override - Double128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Double128Vector) - super.tOpTemplate((Double128Vector)v1, (Double128Vector)v2, + DoubleVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (DoubleVector128) + super.tOpTemplate((DoubleVector128)v1, (DoubleVector128)v2, f); // specialize } @ForceInline final @Override - Double128Vector tOp(Vector v1, Vector v2, + DoubleVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Double128Vector) - super.tOpTemplate((Double128Vector)v1, (Double128Vector)v2, - (Double128Mask)m, f); // specialize + return (DoubleVector128) + super.tOpTemplate((DoubleVector128)v1, (DoubleVector128)v2, + (DoubleMask128)m, f); // specialize } @ForceInline @@ -269,26 +275,26 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline - public Double128Vector lanewise(Unary op) { - return (Double128Vector) super.lanewiseTemplate(op); // specialize + public DoubleVector128 lanewise(Unary op) { + return (DoubleVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Double128Vector lanewise(Unary op, VectorMask m) { - return (Double128Vector) super.lanewiseTemplate(op, Double128Mask.class, (Double128Mask) m); // specialize + public DoubleVector128 lanewise(Unary op, VectorMask m) { + return (DoubleVector128) super.lanewiseTemplate(op, DoubleMask128.class, (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector lanewise(Binary op, Vector v) { - return (Double128Vector) super.lanewiseTemplate(op, v); // specialize + public DoubleVector128 lanewise(Binary op, Vector v) { + return (DoubleVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Double128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Double128Vector) super.lanewiseTemplate(op, Double128Mask.class, v, (Double128Mask) m); // specialize + public DoubleVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (DoubleVector128) super.lanewiseTemplate(op, DoubleMask128.class, v, (DoubleMask128) m); // specialize } @@ -296,24 +302,24 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline public final - Double128Vector + DoubleVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Double128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (DoubleVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Double128Vector + DoubleVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Double128Vector) super.lanewiseTemplate(op, Double128Mask.class, v1, v2, (Double128Mask) m); // specialize + return (DoubleVector128) super.lanewiseTemplate(op, DoubleMask128.class, v1, v2, (DoubleMask128) m); // specialize } @Override @ForceInline public final - Double128Vector addIndex(int scale) { - return (Double128Vector) super.addIndexTemplate(scale); // specialize + DoubleVector128 addIndex(int scale) { + return (DoubleVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +334,7 @@ final class Double128Vector extends DoubleVector { @ForceInline public final double reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Double128Mask.class, (Double128Mask) m); // specialized + return super.reduceLanesTemplate(op, DoubleMask128.class, (DoubleMask128) m); // specialized } @Override @@ -341,7 +347,7 @@ final class Double128Vector extends DoubleVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Double128Mask.class, (Double128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, DoubleMask128.class, (DoubleMask128) m); // specialized } @Override @@ -352,160 +358,160 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline - public final Double128Shuffle toShuffle() { - return (Double128Shuffle) toShuffle(vspecies(), false); + public final DoubleShuffle128 toShuffle() { + return (DoubleShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Double128Mask test(Test op) { - return super.testTemplate(Double128Mask.class, op); // specialize + public final DoubleMask128 test(Test op) { + return super.testTemplate(DoubleMask128.class, op); // specialize } @Override @ForceInline - public final Double128Mask test(Test op, VectorMask m) { - return super.testTemplate(Double128Mask.class, op, (Double128Mask) m); // specialize + public final DoubleMask128 test(Test op, VectorMask m) { + return super.testTemplate(DoubleMask128.class, op, (DoubleMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Double128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Double128Mask.class, op, v); // specialize + public final DoubleMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(DoubleMask128.class, op, v); // specialize } @Override @ForceInline - public final Double128Mask compare(Comparison op, double s) { - return super.compareTemplate(Double128Mask.class, op, s); // specialize + public final DoubleMask128 compare(Comparison op, double s) { + return super.compareTemplate(DoubleMask128.class, op, s); // specialize } @Override @ForceInline - public final Double128Mask compare(Comparison op, long s) { - return super.compareTemplate(Double128Mask.class, op, s); // specialize + public final DoubleMask128 compare(Comparison op, long s) { + return super.compareTemplate(DoubleMask128.class, op, s); // specialize } @Override @ForceInline - public final Double128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Double128Mask.class, op, v, (Double128Mask) m); + public final DoubleMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(DoubleMask128.class, op, v, (DoubleMask128) m); } @Override @ForceInline - public Double128Vector blend(Vector v, VectorMask m) { - return (Double128Vector) - super.blendTemplate(Double128Mask.class, - (Double128Vector) v, - (Double128Mask) m); // specialize + public DoubleVector128 blend(Vector v, VectorMask m) { + return (DoubleVector128) + super.blendTemplate(DoubleMask128.class, + (DoubleVector128) v, + (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector slice(int origin, Vector v) { - return (Double128Vector) super.sliceTemplate(origin, v); // specialize + public DoubleVector128 slice(int origin, Vector v) { + return (DoubleVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Double128Vector slice(int origin) { - return (Double128Vector) super.sliceTemplate(origin); // specialize + public DoubleVector128 slice(int origin) { + return (DoubleVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Double128Vector unslice(int origin, Vector w, int part) { - return (Double128Vector) super.unsliceTemplate(origin, w, part); // specialize + public DoubleVector128 unslice(int origin, Vector w, int part) { + return (DoubleVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Double128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Double128Vector) - super.unsliceTemplate(Double128Mask.class, + public DoubleVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (DoubleVector128) + super.unsliceTemplate(DoubleMask128.class, origin, w, part, - (Double128Mask) m); // specialize + (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector unslice(int origin) { - return (Double128Vector) super.unsliceTemplate(origin); // specialize + public DoubleVector128 unslice(int origin) { + return (DoubleVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Double128Vector rearrange(VectorShuffle s) { - return (Double128Vector) - super.rearrangeTemplate(Double128Shuffle.class, - (Double128Shuffle) s); // specialize + public DoubleVector128 rearrange(VectorShuffle s) { + return (DoubleVector128) + super.rearrangeTemplate(DoubleShuffle128.class, + (DoubleShuffle128) s); // specialize } @Override @ForceInline - public Double128Vector rearrange(VectorShuffle shuffle, + public DoubleVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Double128Vector) - super.rearrangeTemplate(Double128Shuffle.class, - Double128Mask.class, - (Double128Shuffle) shuffle, - (Double128Mask) m); // specialize + return (DoubleVector128) + super.rearrangeTemplate(DoubleShuffle128.class, + DoubleMask128.class, + (DoubleShuffle128) shuffle, + (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector rearrange(VectorShuffle s, + public DoubleVector128 rearrange(VectorShuffle s, Vector v) { - return (Double128Vector) - super.rearrangeTemplate(Double128Shuffle.class, - (Double128Shuffle) s, - (Double128Vector) v); // specialize + return (DoubleVector128) + super.rearrangeTemplate(DoubleShuffle128.class, + (DoubleShuffle128) s, + (DoubleVector128) v); // specialize } @Override @ForceInline - public Double128Vector compress(VectorMask m) { - return (Double128Vector) - super.compressTemplate(Double128Mask.class, - (Double128Mask) m); // specialize + public DoubleVector128 compress(VectorMask m) { + return (DoubleVector128) + super.compressTemplate(DoubleMask128.class, + (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector expand(VectorMask m) { - return (Double128Vector) - super.expandTemplate(Double128Mask.class, - (Double128Mask) m); // specialize + public DoubleVector128 expand(VectorMask m) { + return (DoubleVector128) + super.expandTemplate(DoubleMask128.class, + (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector selectFrom(Vector v) { - return (Double128Vector) - super.selectFromTemplate((Double128Vector) v); // specialize + public DoubleVector128 selectFrom(Vector v) { + return (DoubleVector128) + super.selectFromTemplate((DoubleVector128) v); // specialize } @Override @ForceInline - public Double128Vector selectFrom(Vector v, + public DoubleVector128 selectFrom(Vector v, VectorMask m) { - return (Double128Vector) - super.selectFromTemplate((Double128Vector) v, - Double128Mask.class, (Double128Mask) m); // specialize + return (DoubleVector128) + super.selectFromTemplate((DoubleVector128) v, + DoubleMask128.class, (DoubleMask128) m); // specialize } @Override @ForceInline - public Double128Vector selectFrom(Vector v1, + public DoubleVector128 selectFrom(Vector v1, Vector v2) { - return (Double128Vector) - super.selectFromTemplate((Double128Vector) v1, (Double128Vector) v2); // specialize + return (DoubleVector128) + super.selectFromTemplate((DoubleVector128) v1, (DoubleVector128) v2); // specialize } @ForceInline @@ -533,7 +539,7 @@ final class Double128Vector extends DoubleVector { @ForceInline @Override - public Double128Vector withLane(int i, double e) { + public DoubleVector128 withLane(int i, double e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -542,7 +548,7 @@ final class Double128Vector extends DoubleVector { } @ForceInline - public Double128Vector withLaneHelper(int i, double e) { + public DoubleVector128 withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), @@ -554,20 +560,21 @@ final class Double128Vector extends DoubleVector { } // Mask - - static final class Double128Mask extends AbstractMask { + @ValueBased + static final class DoubleMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM - Double128Mask(boolean[] bits) { + static final Class CTYPE = double.class; // used by the JVM + + DoubleMask128(boolean[] bits) { this(bits, 0); } - Double128Mask(boolean[] bits, int offset) { + DoubleMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Double128Mask(boolean val) { + DoubleMask128(boolean val) { super(prepare(val)); } @@ -600,31 +607,31 @@ final class Double128Vector extends DoubleVector { } @Override - Double128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Double128Mask(res); + return new DoubleMask128(res); } @Override - Double128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Double128Mask)m).getBits(); + boolean[] mbits = ((DoubleMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Double128Mask(res); + return new DoubleMask128(res); } @ForceInline @Override public final - Double128Vector toVector() { - return (Double128Vector) super.toVectorTemplate(); // specialize + DoubleVector128 toVector() { + return (DoubleVector128) super.toVectorTemplate(); // specialize } /** @@ -657,25 +664,25 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline /*package-private*/ - Double128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Double128Mask) VectorSupport.indexPartiallyInUpperRange( - Double128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Double128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + DoubleMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMask128) VectorSupport.indexPartiallyInUpperRange( + DoubleMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (DoubleMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Double128Mask not() { + public DoubleMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Double128Mask compress() { - return (Double128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double128Vector.class, Double128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public DoubleMask128 compress() { + return (DoubleMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + DoubleVector128.class, DoubleMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -684,30 +691,30 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline - public Double128Mask and(VectorMask mask) { + public DoubleMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask128 m = (DoubleMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Double128Mask or(VectorMask mask) { + public DoubleMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask128 m = (DoubleMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Double128Mask xor(VectorMask mask) { + public DoubleMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask128 m = (DoubleMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -717,21 +724,21 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -741,7 +748,7 @@ final class Double128Vector extends DoubleVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -751,7 +758,7 @@ final class Double128Vector extends DoubleVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(DoubleMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -760,48 +767,49 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double128Mask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((DoubleMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((DoubleMask128)m).getBits())); } @ForceInline /*package-private*/ - static Double128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static DoubleMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(DoubleMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Double128Mask TRUE_MASK = new Double128Mask(true); - private static final Double128Mask FALSE_MASK = new Double128Mask(false); + private static final DoubleMask128 TRUE_MASK = new DoubleMask128(true); + private static final DoubleMask128 FALSE_MASK = new DoubleMask128(false); } // Shuffle - - static final class Double128Shuffle extends AbstractShuffle { + @ValueBased + static final class DoubleShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Double128Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + DoubleShuffle128(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Double128Shuffle(int[] indices, int i) { + DoubleShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Double128Shuffle(IntUnaryOperator fn) { + DoubleShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -821,23 +829,23 @@ final class Double128Vector extends DoubleVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Double128Shuffle IOTA = new Double128Shuffle(IDENTITY); + static final DoubleShuffle128 IOTA = new DoubleShuffle128(IDENTITY); @Override @ForceInline - public Double128Vector toVector() { - return (Double128Vector) toBitsVector().castShape(vspecies(), 0); + public DoubleVector128 toVector() { + return (DoubleVector128) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Long128Vector toBitsVector() { - return (Long128Vector) super.toBitsVectorTemplate(); + LongVector128 toBitsVector() { + return (LongVector128) super.toBitsVectorTemplate(); } @Override - Long128Vector toBitsVector0() { - return ((Long128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector128 toBitsVector0() { + return ((LongVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -909,30 +917,30 @@ final class Double128Vector extends DoubleVector { @Override @ForceInline - public final Double128Mask laneIsValid() { - return (Double128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final DoubleMask128 laneIsValid() { + return (DoubleMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Double128Shuffle rearrange(VectorShuffle shuffle) { - Double128Shuffle concreteShuffle = (Double128Shuffle) shuffle; - return (Double128Shuffle) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_128)) - .toShuffle(vspecies(), false); + public final DoubleShuffle128 rearrange(VectorShuffle shuffle) { + DoubleShuffle128 concreteShuffle = (DoubleShuffle128) shuffle; + return (DoubleShuffle128) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_128)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Double128Shuffle wrapIndexes() { - Long128Vector v = toBitsVector(); + public final DoubleShuffle128 wrapIndexes() { + LongVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Double128Shuffle) v.toShuffle(vspecies(), false); + return (DoubleShuffle128) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -983,14 +991,14 @@ final class Double128Vector extends DoubleVector { @Override final DoubleVector fromArray0(double[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Double128Mask.class, a, offset, (Double128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(DoubleMask128.class, a, offset, (DoubleMask128) m, offsetInRange); // specialize } @ForceInline @Override final DoubleVector fromArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Double128Mask.class, a, offset, indexMap, mapOffset, (Double128Mask) m); + return super.fromArray0Template(DoubleMask128.class, a, offset, indexMap, mapOffset, (DoubleMask128) m); } @@ -1006,7 +1014,7 @@ final class Double128Vector extends DoubleVector { @Override final DoubleVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Double128Mask.class, ms, offset, (Double128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(DoubleMask128.class, ms, offset, (DoubleMask128) m, offsetInRange); // specialize } @ForceInline @@ -1020,14 +1028,14 @@ final class Double128Vector extends DoubleVector { @Override final void intoArray0(double[] a, int offset, VectorMask m) { - super.intoArray0Template(Double128Mask.class, a, offset, (Double128Mask) m); + super.intoArray0Template(DoubleMask128.class, a, offset, (DoubleMask128) m); } @ForceInline @Override final void intoArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Double128Mask.class, a, offset, indexMap, mapOffset, (Double128Mask) m); + super.intoArray0Template(DoubleMask128.class, a, offset, indexMap, mapOffset, (DoubleMask128) m); } @@ -1035,7 +1043,7 @@ final class Double128Vector extends DoubleVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Double128Mask.class, ms, offset, (Double128Mask) m); + super.intoMemorySegment0Template(DoubleMask128.class, ms, offset, (DoubleMask128) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector256.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector256.java index 0f145bf06e2..c6bb4b7e3d3 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector256.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Double256Vector extends DoubleVector { +@ValueBased +final class DoubleVector256 extends DoubleVector { static final DoubleSpecies VSPECIES = (DoubleSpecies) DoubleVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Double256Vector.class; + static final Class VCLASS = DoubleVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + static final Class ETYPE = double.class; // used by the JVM - Double256Vector(double[] v) { + DoubleVector256(double[] v) { super(v); } - // For compatibility as Double256Vector::new, + // For compatibility as DoubleVector256::new, // stored into species.vectorFactory. - Double256Vector(Object v) { + DoubleVector256(Object v) { this((double[]) v); } - static final Double256Vector ZERO = new Double256Vector(new double[VLENGTH]); - static final Double256Vector IOTA = new Double256Vector(VSPECIES.iotaArray()); + static final DoubleVector256 ZERO = new DoubleVector256(new double[VLENGTH]); + static final DoubleVector256 IOTA = new DoubleVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Double256Vector extends DoubleVector { @Override public final Class elementType() { return double.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Double.SIZE; } @@ -130,51 +136,51 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline - public final Double256Vector broadcast(double e) { - return (Double256Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector256 broadcast(double e) { + return (DoubleVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Double256Vector broadcast(long e) { - return (Double256Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector256 broadcast(long e) { + return (DoubleVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Double256Mask maskFromArray(boolean[] bits) { - return new Double256Mask(bits); + DoubleMask256 maskFromArray(boolean[] bits) { + return new DoubleMask256(bits); } @Override @ForceInline - Double256Shuffle iotaShuffle() { return Double256Shuffle.IOTA; } + DoubleShuffle256 iotaShuffle() { return DoubleShuffle256.IOTA; } @Override @ForceInline - Double256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Double256Shuffle) iotaShuffleTemplate(start, step, wrap); + DoubleShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (DoubleShuffle256) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Double256Shuffle shuffleFromArray(int[] indices, int i) { return new Double256Shuffle(indices, i); } + DoubleShuffle256 shuffleFromArray(int[] indices, int i) { return new DoubleShuffle256(indices, i); } @Override @ForceInline - Double256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Double256Shuffle(fn); } + DoubleShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new DoubleShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Double256Vector vectorFactory(double[] vec) { - return new Double256Vector(vec); + DoubleVector256 vectorFactory(double[] vec) { + return new DoubleVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +193,31 @@ final class Double256Vector extends DoubleVector { @ForceInline final @Override - Double256Vector uOp(FUnOp f) { - return (Double256Vector) super.uOpTemplate(f); // specialize + DoubleVector256 uOp(FUnOp f) { + return (DoubleVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Double256Vector uOp(VectorMask m, FUnOp f) { - return (Double256Vector) - super.uOpTemplate((Double256Mask)m, f); // specialize + DoubleVector256 uOp(VectorMask m, FUnOp f) { + return (DoubleVector256) + super.uOpTemplate((DoubleMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Double256Vector bOp(Vector v, FBinOp f) { - return (Double256Vector) super.bOpTemplate((Double256Vector)v, f); // specialize + DoubleVector256 bOp(Vector v, FBinOp f) { + return (DoubleVector256) super.bOpTemplate((DoubleVector256)v, f); // specialize } @ForceInline final @Override - Double256Vector bOp(Vector v, + DoubleVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Double256Vector) - super.bOpTemplate((Double256Vector)v, (Double256Mask)m, + return (DoubleVector256) + super.bOpTemplate((DoubleVector256)v, (DoubleMask256)m, f); // specialize } @@ -219,19 +225,19 @@ final class Double256Vector extends DoubleVector { @ForceInline final @Override - Double256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Double256Vector) - super.tOpTemplate((Double256Vector)v1, (Double256Vector)v2, + DoubleVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (DoubleVector256) + super.tOpTemplate((DoubleVector256)v1, (DoubleVector256)v2, f); // specialize } @ForceInline final @Override - Double256Vector tOp(Vector v1, Vector v2, + DoubleVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Double256Vector) - super.tOpTemplate((Double256Vector)v1, (Double256Vector)v2, - (Double256Mask)m, f); // specialize + return (DoubleVector256) + super.tOpTemplate((DoubleVector256)v1, (DoubleVector256)v2, + (DoubleMask256)m, f); // specialize } @ForceInline @@ -269,26 +275,26 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline - public Double256Vector lanewise(Unary op) { - return (Double256Vector) super.lanewiseTemplate(op); // specialize + public DoubleVector256 lanewise(Unary op) { + return (DoubleVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Double256Vector lanewise(Unary op, VectorMask m) { - return (Double256Vector) super.lanewiseTemplate(op, Double256Mask.class, (Double256Mask) m); // specialize + public DoubleVector256 lanewise(Unary op, VectorMask m) { + return (DoubleVector256) super.lanewiseTemplate(op, DoubleMask256.class, (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector lanewise(Binary op, Vector v) { - return (Double256Vector) super.lanewiseTemplate(op, v); // specialize + public DoubleVector256 lanewise(Binary op, Vector v) { + return (DoubleVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Double256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Double256Vector) super.lanewiseTemplate(op, Double256Mask.class, v, (Double256Mask) m); // specialize + public DoubleVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (DoubleVector256) super.lanewiseTemplate(op, DoubleMask256.class, v, (DoubleMask256) m); // specialize } @@ -296,24 +302,24 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline public final - Double256Vector + DoubleVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Double256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (DoubleVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Double256Vector + DoubleVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Double256Vector) super.lanewiseTemplate(op, Double256Mask.class, v1, v2, (Double256Mask) m); // specialize + return (DoubleVector256) super.lanewiseTemplate(op, DoubleMask256.class, v1, v2, (DoubleMask256) m); // specialize } @Override @ForceInline public final - Double256Vector addIndex(int scale) { - return (Double256Vector) super.addIndexTemplate(scale); // specialize + DoubleVector256 addIndex(int scale) { + return (DoubleVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +334,7 @@ final class Double256Vector extends DoubleVector { @ForceInline public final double reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Double256Mask.class, (Double256Mask) m); // specialized + return super.reduceLanesTemplate(op, DoubleMask256.class, (DoubleMask256) m); // specialized } @Override @@ -341,7 +347,7 @@ final class Double256Vector extends DoubleVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Double256Mask.class, (Double256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, DoubleMask256.class, (DoubleMask256) m); // specialized } @Override @@ -352,160 +358,160 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline - public final Double256Shuffle toShuffle() { - return (Double256Shuffle) toShuffle(vspecies(), false); + public final DoubleShuffle256 toShuffle() { + return (DoubleShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Double256Mask test(Test op) { - return super.testTemplate(Double256Mask.class, op); // specialize + public final DoubleMask256 test(Test op) { + return super.testTemplate(DoubleMask256.class, op); // specialize } @Override @ForceInline - public final Double256Mask test(Test op, VectorMask m) { - return super.testTemplate(Double256Mask.class, op, (Double256Mask) m); // specialize + public final DoubleMask256 test(Test op, VectorMask m) { + return super.testTemplate(DoubleMask256.class, op, (DoubleMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Double256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Double256Mask.class, op, v); // specialize + public final DoubleMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(DoubleMask256.class, op, v); // specialize } @Override @ForceInline - public final Double256Mask compare(Comparison op, double s) { - return super.compareTemplate(Double256Mask.class, op, s); // specialize + public final DoubleMask256 compare(Comparison op, double s) { + return super.compareTemplate(DoubleMask256.class, op, s); // specialize } @Override @ForceInline - public final Double256Mask compare(Comparison op, long s) { - return super.compareTemplate(Double256Mask.class, op, s); // specialize + public final DoubleMask256 compare(Comparison op, long s) { + return super.compareTemplate(DoubleMask256.class, op, s); // specialize } @Override @ForceInline - public final Double256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Double256Mask.class, op, v, (Double256Mask) m); + public final DoubleMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(DoubleMask256.class, op, v, (DoubleMask256) m); } @Override @ForceInline - public Double256Vector blend(Vector v, VectorMask m) { - return (Double256Vector) - super.blendTemplate(Double256Mask.class, - (Double256Vector) v, - (Double256Mask) m); // specialize + public DoubleVector256 blend(Vector v, VectorMask m) { + return (DoubleVector256) + super.blendTemplate(DoubleMask256.class, + (DoubleVector256) v, + (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector slice(int origin, Vector v) { - return (Double256Vector) super.sliceTemplate(origin, v); // specialize + public DoubleVector256 slice(int origin, Vector v) { + return (DoubleVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Double256Vector slice(int origin) { - return (Double256Vector) super.sliceTemplate(origin); // specialize + public DoubleVector256 slice(int origin) { + return (DoubleVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Double256Vector unslice(int origin, Vector w, int part) { - return (Double256Vector) super.unsliceTemplate(origin, w, part); // specialize + public DoubleVector256 unslice(int origin, Vector w, int part) { + return (DoubleVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Double256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Double256Vector) - super.unsliceTemplate(Double256Mask.class, + public DoubleVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (DoubleVector256) + super.unsliceTemplate(DoubleMask256.class, origin, w, part, - (Double256Mask) m); // specialize + (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector unslice(int origin) { - return (Double256Vector) super.unsliceTemplate(origin); // specialize + public DoubleVector256 unslice(int origin) { + return (DoubleVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Double256Vector rearrange(VectorShuffle s) { - return (Double256Vector) - super.rearrangeTemplate(Double256Shuffle.class, - (Double256Shuffle) s); // specialize + public DoubleVector256 rearrange(VectorShuffle s) { + return (DoubleVector256) + super.rearrangeTemplate(DoubleShuffle256.class, + (DoubleShuffle256) s); // specialize } @Override @ForceInline - public Double256Vector rearrange(VectorShuffle shuffle, + public DoubleVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Double256Vector) - super.rearrangeTemplate(Double256Shuffle.class, - Double256Mask.class, - (Double256Shuffle) shuffle, - (Double256Mask) m); // specialize + return (DoubleVector256) + super.rearrangeTemplate(DoubleShuffle256.class, + DoubleMask256.class, + (DoubleShuffle256) shuffle, + (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector rearrange(VectorShuffle s, + public DoubleVector256 rearrange(VectorShuffle s, Vector v) { - return (Double256Vector) - super.rearrangeTemplate(Double256Shuffle.class, - (Double256Shuffle) s, - (Double256Vector) v); // specialize + return (DoubleVector256) + super.rearrangeTemplate(DoubleShuffle256.class, + (DoubleShuffle256) s, + (DoubleVector256) v); // specialize } @Override @ForceInline - public Double256Vector compress(VectorMask m) { - return (Double256Vector) - super.compressTemplate(Double256Mask.class, - (Double256Mask) m); // specialize + public DoubleVector256 compress(VectorMask m) { + return (DoubleVector256) + super.compressTemplate(DoubleMask256.class, + (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector expand(VectorMask m) { - return (Double256Vector) - super.expandTemplate(Double256Mask.class, - (Double256Mask) m); // specialize + public DoubleVector256 expand(VectorMask m) { + return (DoubleVector256) + super.expandTemplate(DoubleMask256.class, + (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector selectFrom(Vector v) { - return (Double256Vector) - super.selectFromTemplate((Double256Vector) v); // specialize + public DoubleVector256 selectFrom(Vector v) { + return (DoubleVector256) + super.selectFromTemplate((DoubleVector256) v); // specialize } @Override @ForceInline - public Double256Vector selectFrom(Vector v, + public DoubleVector256 selectFrom(Vector v, VectorMask m) { - return (Double256Vector) - super.selectFromTemplate((Double256Vector) v, - Double256Mask.class, (Double256Mask) m); // specialize + return (DoubleVector256) + super.selectFromTemplate((DoubleVector256) v, + DoubleMask256.class, (DoubleMask256) m); // specialize } @Override @ForceInline - public Double256Vector selectFrom(Vector v1, + public DoubleVector256 selectFrom(Vector v1, Vector v2) { - return (Double256Vector) - super.selectFromTemplate((Double256Vector) v1, (Double256Vector) v2); // specialize + return (DoubleVector256) + super.selectFromTemplate((DoubleVector256) v1, (DoubleVector256) v2); // specialize } @ForceInline @@ -535,7 +541,7 @@ final class Double256Vector extends DoubleVector { @ForceInline @Override - public Double256Vector withLane(int i, double e) { + public DoubleVector256 withLane(int i, double e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -546,7 +552,7 @@ final class Double256Vector extends DoubleVector { } @ForceInline - public Double256Vector withLaneHelper(int i, double e) { + public DoubleVector256 withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), @@ -558,20 +564,21 @@ final class Double256Vector extends DoubleVector { } // Mask - - static final class Double256Mask extends AbstractMask { + @ValueBased + static final class DoubleMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM - Double256Mask(boolean[] bits) { + static final Class CTYPE = double.class; // used by the JVM + + DoubleMask256(boolean[] bits) { this(bits, 0); } - Double256Mask(boolean[] bits, int offset) { + DoubleMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Double256Mask(boolean val) { + DoubleMask256(boolean val) { super(prepare(val)); } @@ -604,31 +611,31 @@ final class Double256Vector extends DoubleVector { } @Override - Double256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Double256Mask(res); + return new DoubleMask256(res); } @Override - Double256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Double256Mask)m).getBits(); + boolean[] mbits = ((DoubleMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Double256Mask(res); + return new DoubleMask256(res); } @ForceInline @Override public final - Double256Vector toVector() { - return (Double256Vector) super.toVectorTemplate(); // specialize + DoubleVector256 toVector() { + return (DoubleVector256) super.toVectorTemplate(); // specialize } /** @@ -661,25 +668,25 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline /*package-private*/ - Double256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Double256Mask) VectorSupport.indexPartiallyInUpperRange( - Double256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Double256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + DoubleMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMask256) VectorSupport.indexPartiallyInUpperRange( + DoubleMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (DoubleMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Double256Mask not() { + public DoubleMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Double256Mask compress() { - return (Double256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double256Vector.class, Double256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public DoubleMask256 compress() { + return (DoubleMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + DoubleVector256.class, DoubleMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -688,30 +695,30 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline - public Double256Mask and(VectorMask mask) { + public DoubleMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask256 m = (DoubleMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Double256Mask or(VectorMask mask) { + public DoubleMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask256 m = (DoubleMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Double256Mask xor(VectorMask mask) { + public DoubleMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask256 m = (DoubleMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -721,21 +728,21 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -745,7 +752,7 @@ final class Double256Vector extends DoubleVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -755,7 +762,7 @@ final class Double256Vector extends DoubleVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(DoubleMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -764,48 +771,49 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double256Mask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((DoubleMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((DoubleMask256)m).getBits())); } @ForceInline /*package-private*/ - static Double256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static DoubleMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(DoubleMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Double256Mask TRUE_MASK = new Double256Mask(true); - private static final Double256Mask FALSE_MASK = new Double256Mask(false); + private static final DoubleMask256 TRUE_MASK = new DoubleMask256(true); + private static final DoubleMask256 FALSE_MASK = new DoubleMask256(false); } // Shuffle - - static final class Double256Shuffle extends AbstractShuffle { + @ValueBased + static final class DoubleShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Double256Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + DoubleShuffle256(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Double256Shuffle(int[] indices, int i) { + DoubleShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Double256Shuffle(IntUnaryOperator fn) { + DoubleShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -825,23 +833,23 @@ final class Double256Vector extends DoubleVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Double256Shuffle IOTA = new Double256Shuffle(IDENTITY); + static final DoubleShuffle256 IOTA = new DoubleShuffle256(IDENTITY); @Override @ForceInline - public Double256Vector toVector() { - return (Double256Vector) toBitsVector().castShape(vspecies(), 0); + public DoubleVector256 toVector() { + return (DoubleVector256) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Long256Vector toBitsVector() { - return (Long256Vector) super.toBitsVectorTemplate(); + LongVector256 toBitsVector() { + return (LongVector256) super.toBitsVectorTemplate(); } @Override - Long256Vector toBitsVector0() { - return ((Long256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector256 toBitsVector0() { + return ((LongVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -913,30 +921,30 @@ final class Double256Vector extends DoubleVector { @Override @ForceInline - public final Double256Mask laneIsValid() { - return (Double256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final DoubleMask256 laneIsValid() { + return (DoubleMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Double256Shuffle rearrange(VectorShuffle shuffle) { - Double256Shuffle concreteShuffle = (Double256Shuffle) shuffle; - return (Double256Shuffle) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_256)) - .toShuffle(vspecies(), false); + public final DoubleShuffle256 rearrange(VectorShuffle shuffle) { + DoubleShuffle256 concreteShuffle = (DoubleShuffle256) shuffle; + return (DoubleShuffle256) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_256)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Double256Shuffle wrapIndexes() { - Long256Vector v = toBitsVector(); + public final DoubleShuffle256 wrapIndexes() { + LongVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Double256Shuffle) v.toShuffle(vspecies(), false); + return (DoubleShuffle256) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -987,14 +995,14 @@ final class Double256Vector extends DoubleVector { @Override final DoubleVector fromArray0(double[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Double256Mask.class, a, offset, (Double256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(DoubleMask256.class, a, offset, (DoubleMask256) m, offsetInRange); // specialize } @ForceInline @Override final DoubleVector fromArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Double256Mask.class, a, offset, indexMap, mapOffset, (Double256Mask) m); + return super.fromArray0Template(DoubleMask256.class, a, offset, indexMap, mapOffset, (DoubleMask256) m); } @@ -1010,7 +1018,7 @@ final class Double256Vector extends DoubleVector { @Override final DoubleVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Double256Mask.class, ms, offset, (Double256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(DoubleMask256.class, ms, offset, (DoubleMask256) m, offsetInRange); // specialize } @ForceInline @@ -1024,14 +1032,14 @@ final class Double256Vector extends DoubleVector { @Override final void intoArray0(double[] a, int offset, VectorMask m) { - super.intoArray0Template(Double256Mask.class, a, offset, (Double256Mask) m); + super.intoArray0Template(DoubleMask256.class, a, offset, (DoubleMask256) m); } @ForceInline @Override final void intoArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Double256Mask.class, a, offset, indexMap, mapOffset, (Double256Mask) m); + super.intoArray0Template(DoubleMask256.class, a, offset, indexMap, mapOffset, (DoubleMask256) m); } @@ -1039,7 +1047,7 @@ final class Double256Vector extends DoubleVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Double256Mask.class, ms, offset, (Double256Mask) m); + super.intoMemorySegment0Template(DoubleMask256.class, ms, offset, (DoubleMask256) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector512.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector512.java index 581a3ac7329..fb1441efc63 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector512.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Double512Vector extends DoubleVector { +@ValueBased +final class DoubleVector512 extends DoubleVector { static final DoubleSpecies VSPECIES = (DoubleSpecies) DoubleVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Double512Vector.class; + static final Class VCLASS = DoubleVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + static final Class ETYPE = double.class; // used by the JVM - Double512Vector(double[] v) { + DoubleVector512(double[] v) { super(v); } - // For compatibility as Double512Vector::new, + // For compatibility as DoubleVector512::new, // stored into species.vectorFactory. - Double512Vector(Object v) { + DoubleVector512(Object v) { this((double[]) v); } - static final Double512Vector ZERO = new Double512Vector(new double[VLENGTH]); - static final Double512Vector IOTA = new Double512Vector(VSPECIES.iotaArray()); + static final DoubleVector512 ZERO = new DoubleVector512(new double[VLENGTH]); + static final DoubleVector512 IOTA = new DoubleVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Double512Vector extends DoubleVector { @Override public final Class elementType() { return double.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Double.SIZE; } @@ -130,51 +136,51 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline - public final Double512Vector broadcast(double e) { - return (Double512Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector512 broadcast(double e) { + return (DoubleVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Double512Vector broadcast(long e) { - return (Double512Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector512 broadcast(long e) { + return (DoubleVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Double512Mask maskFromArray(boolean[] bits) { - return new Double512Mask(bits); + DoubleMask512 maskFromArray(boolean[] bits) { + return new DoubleMask512(bits); } @Override @ForceInline - Double512Shuffle iotaShuffle() { return Double512Shuffle.IOTA; } + DoubleShuffle512 iotaShuffle() { return DoubleShuffle512.IOTA; } @Override @ForceInline - Double512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Double512Shuffle) iotaShuffleTemplate(start, step, wrap); + DoubleShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (DoubleShuffle512) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Double512Shuffle shuffleFromArray(int[] indices, int i) { return new Double512Shuffle(indices, i); } + DoubleShuffle512 shuffleFromArray(int[] indices, int i) { return new DoubleShuffle512(indices, i); } @Override @ForceInline - Double512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Double512Shuffle(fn); } + DoubleShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new DoubleShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Double512Vector vectorFactory(double[] vec) { - return new Double512Vector(vec); + DoubleVector512 vectorFactory(double[] vec) { + return new DoubleVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +193,31 @@ final class Double512Vector extends DoubleVector { @ForceInline final @Override - Double512Vector uOp(FUnOp f) { - return (Double512Vector) super.uOpTemplate(f); // specialize + DoubleVector512 uOp(FUnOp f) { + return (DoubleVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Double512Vector uOp(VectorMask m, FUnOp f) { - return (Double512Vector) - super.uOpTemplate((Double512Mask)m, f); // specialize + DoubleVector512 uOp(VectorMask m, FUnOp f) { + return (DoubleVector512) + super.uOpTemplate((DoubleMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Double512Vector bOp(Vector v, FBinOp f) { - return (Double512Vector) super.bOpTemplate((Double512Vector)v, f); // specialize + DoubleVector512 bOp(Vector v, FBinOp f) { + return (DoubleVector512) super.bOpTemplate((DoubleVector512)v, f); // specialize } @ForceInline final @Override - Double512Vector bOp(Vector v, + DoubleVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Double512Vector) - super.bOpTemplate((Double512Vector)v, (Double512Mask)m, + return (DoubleVector512) + super.bOpTemplate((DoubleVector512)v, (DoubleMask512)m, f); // specialize } @@ -219,19 +225,19 @@ final class Double512Vector extends DoubleVector { @ForceInline final @Override - Double512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Double512Vector) - super.tOpTemplate((Double512Vector)v1, (Double512Vector)v2, + DoubleVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (DoubleVector512) + super.tOpTemplate((DoubleVector512)v1, (DoubleVector512)v2, f); // specialize } @ForceInline final @Override - Double512Vector tOp(Vector v1, Vector v2, + DoubleVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Double512Vector) - super.tOpTemplate((Double512Vector)v1, (Double512Vector)v2, - (Double512Mask)m, f); // specialize + return (DoubleVector512) + super.tOpTemplate((DoubleVector512)v1, (DoubleVector512)v2, + (DoubleMask512)m, f); // specialize } @ForceInline @@ -269,26 +275,26 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline - public Double512Vector lanewise(Unary op) { - return (Double512Vector) super.lanewiseTemplate(op); // specialize + public DoubleVector512 lanewise(Unary op) { + return (DoubleVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Double512Vector lanewise(Unary op, VectorMask m) { - return (Double512Vector) super.lanewiseTemplate(op, Double512Mask.class, (Double512Mask) m); // specialize + public DoubleVector512 lanewise(Unary op, VectorMask m) { + return (DoubleVector512) super.lanewiseTemplate(op, DoubleMask512.class, (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector lanewise(Binary op, Vector v) { - return (Double512Vector) super.lanewiseTemplate(op, v); // specialize + public DoubleVector512 lanewise(Binary op, Vector v) { + return (DoubleVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Double512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Double512Vector) super.lanewiseTemplate(op, Double512Mask.class, v, (Double512Mask) m); // specialize + public DoubleVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (DoubleVector512) super.lanewiseTemplate(op, DoubleMask512.class, v, (DoubleMask512) m); // specialize } @@ -296,24 +302,24 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline public final - Double512Vector + DoubleVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Double512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (DoubleVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Double512Vector + DoubleVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Double512Vector) super.lanewiseTemplate(op, Double512Mask.class, v1, v2, (Double512Mask) m); // specialize + return (DoubleVector512) super.lanewiseTemplate(op, DoubleMask512.class, v1, v2, (DoubleMask512) m); // specialize } @Override @ForceInline public final - Double512Vector addIndex(int scale) { - return (Double512Vector) super.addIndexTemplate(scale); // specialize + DoubleVector512 addIndex(int scale) { + return (DoubleVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +334,7 @@ final class Double512Vector extends DoubleVector { @ForceInline public final double reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Double512Mask.class, (Double512Mask) m); // specialized + return super.reduceLanesTemplate(op, DoubleMask512.class, (DoubleMask512) m); // specialized } @Override @@ -341,7 +347,7 @@ final class Double512Vector extends DoubleVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Double512Mask.class, (Double512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, DoubleMask512.class, (DoubleMask512) m); // specialized } @Override @@ -352,160 +358,160 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline - public final Double512Shuffle toShuffle() { - return (Double512Shuffle) toShuffle(vspecies(), false); + public final DoubleShuffle512 toShuffle() { + return (DoubleShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Double512Mask test(Test op) { - return super.testTemplate(Double512Mask.class, op); // specialize + public final DoubleMask512 test(Test op) { + return super.testTemplate(DoubleMask512.class, op); // specialize } @Override @ForceInline - public final Double512Mask test(Test op, VectorMask m) { - return super.testTemplate(Double512Mask.class, op, (Double512Mask) m); // specialize + public final DoubleMask512 test(Test op, VectorMask m) { + return super.testTemplate(DoubleMask512.class, op, (DoubleMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Double512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Double512Mask.class, op, v); // specialize + public final DoubleMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(DoubleMask512.class, op, v); // specialize } @Override @ForceInline - public final Double512Mask compare(Comparison op, double s) { - return super.compareTemplate(Double512Mask.class, op, s); // specialize + public final DoubleMask512 compare(Comparison op, double s) { + return super.compareTemplate(DoubleMask512.class, op, s); // specialize } @Override @ForceInline - public final Double512Mask compare(Comparison op, long s) { - return super.compareTemplate(Double512Mask.class, op, s); // specialize + public final DoubleMask512 compare(Comparison op, long s) { + return super.compareTemplate(DoubleMask512.class, op, s); // specialize } @Override @ForceInline - public final Double512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Double512Mask.class, op, v, (Double512Mask) m); + public final DoubleMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(DoubleMask512.class, op, v, (DoubleMask512) m); } @Override @ForceInline - public Double512Vector blend(Vector v, VectorMask m) { - return (Double512Vector) - super.blendTemplate(Double512Mask.class, - (Double512Vector) v, - (Double512Mask) m); // specialize + public DoubleVector512 blend(Vector v, VectorMask m) { + return (DoubleVector512) + super.blendTemplate(DoubleMask512.class, + (DoubleVector512) v, + (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector slice(int origin, Vector v) { - return (Double512Vector) super.sliceTemplate(origin, v); // specialize + public DoubleVector512 slice(int origin, Vector v) { + return (DoubleVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Double512Vector slice(int origin) { - return (Double512Vector) super.sliceTemplate(origin); // specialize + public DoubleVector512 slice(int origin) { + return (DoubleVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Double512Vector unslice(int origin, Vector w, int part) { - return (Double512Vector) super.unsliceTemplate(origin, w, part); // specialize + public DoubleVector512 unslice(int origin, Vector w, int part) { + return (DoubleVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Double512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Double512Vector) - super.unsliceTemplate(Double512Mask.class, + public DoubleVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (DoubleVector512) + super.unsliceTemplate(DoubleMask512.class, origin, w, part, - (Double512Mask) m); // specialize + (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector unslice(int origin) { - return (Double512Vector) super.unsliceTemplate(origin); // specialize + public DoubleVector512 unslice(int origin) { + return (DoubleVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Double512Vector rearrange(VectorShuffle s) { - return (Double512Vector) - super.rearrangeTemplate(Double512Shuffle.class, - (Double512Shuffle) s); // specialize + public DoubleVector512 rearrange(VectorShuffle s) { + return (DoubleVector512) + super.rearrangeTemplate(DoubleShuffle512.class, + (DoubleShuffle512) s); // specialize } @Override @ForceInline - public Double512Vector rearrange(VectorShuffle shuffle, + public DoubleVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Double512Vector) - super.rearrangeTemplate(Double512Shuffle.class, - Double512Mask.class, - (Double512Shuffle) shuffle, - (Double512Mask) m); // specialize + return (DoubleVector512) + super.rearrangeTemplate(DoubleShuffle512.class, + DoubleMask512.class, + (DoubleShuffle512) shuffle, + (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector rearrange(VectorShuffle s, + public DoubleVector512 rearrange(VectorShuffle s, Vector v) { - return (Double512Vector) - super.rearrangeTemplate(Double512Shuffle.class, - (Double512Shuffle) s, - (Double512Vector) v); // specialize + return (DoubleVector512) + super.rearrangeTemplate(DoubleShuffle512.class, + (DoubleShuffle512) s, + (DoubleVector512) v); // specialize } @Override @ForceInline - public Double512Vector compress(VectorMask m) { - return (Double512Vector) - super.compressTemplate(Double512Mask.class, - (Double512Mask) m); // specialize + public DoubleVector512 compress(VectorMask m) { + return (DoubleVector512) + super.compressTemplate(DoubleMask512.class, + (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector expand(VectorMask m) { - return (Double512Vector) - super.expandTemplate(Double512Mask.class, - (Double512Mask) m); // specialize + public DoubleVector512 expand(VectorMask m) { + return (DoubleVector512) + super.expandTemplate(DoubleMask512.class, + (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector selectFrom(Vector v) { - return (Double512Vector) - super.selectFromTemplate((Double512Vector) v); // specialize + public DoubleVector512 selectFrom(Vector v) { + return (DoubleVector512) + super.selectFromTemplate((DoubleVector512) v); // specialize } @Override @ForceInline - public Double512Vector selectFrom(Vector v, + public DoubleVector512 selectFrom(Vector v, VectorMask m) { - return (Double512Vector) - super.selectFromTemplate((Double512Vector) v, - Double512Mask.class, (Double512Mask) m); // specialize + return (DoubleVector512) + super.selectFromTemplate((DoubleVector512) v, + DoubleMask512.class, (DoubleMask512) m); // specialize } @Override @ForceInline - public Double512Vector selectFrom(Vector v1, + public DoubleVector512 selectFrom(Vector v1, Vector v2) { - return (Double512Vector) - super.selectFromTemplate((Double512Vector) v1, (Double512Vector) v2); // specialize + return (DoubleVector512) + super.selectFromTemplate((DoubleVector512) v1, (DoubleVector512) v2); // specialize } @ForceInline @@ -539,7 +545,7 @@ final class Double512Vector extends DoubleVector { @ForceInline @Override - public Double512Vector withLane(int i, double e) { + public DoubleVector512 withLane(int i, double e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -554,7 +560,7 @@ final class Double512Vector extends DoubleVector { } @ForceInline - public Double512Vector withLaneHelper(int i, double e) { + public DoubleVector512 withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), @@ -566,20 +572,21 @@ final class Double512Vector extends DoubleVector { } // Mask - - static final class Double512Mask extends AbstractMask { + @ValueBased + static final class DoubleMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM - Double512Mask(boolean[] bits) { + static final Class CTYPE = double.class; // used by the JVM + + DoubleMask512(boolean[] bits) { this(bits, 0); } - Double512Mask(boolean[] bits, int offset) { + DoubleMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Double512Mask(boolean val) { + DoubleMask512(boolean val) { super(prepare(val)); } @@ -612,31 +619,31 @@ final class Double512Vector extends DoubleVector { } @Override - Double512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Double512Mask(res); + return new DoubleMask512(res); } @Override - Double512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Double512Mask)m).getBits(); + boolean[] mbits = ((DoubleMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Double512Mask(res); + return new DoubleMask512(res); } @ForceInline @Override public final - Double512Vector toVector() { - return (Double512Vector) super.toVectorTemplate(); // specialize + DoubleVector512 toVector() { + return (DoubleVector512) super.toVectorTemplate(); // specialize } /** @@ -669,25 +676,25 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline /*package-private*/ - Double512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Double512Mask) VectorSupport.indexPartiallyInUpperRange( - Double512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Double512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + DoubleMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMask512) VectorSupport.indexPartiallyInUpperRange( + DoubleMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (DoubleMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Double512Mask not() { + public DoubleMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Double512Mask compress() { - return (Double512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double512Vector.class, Double512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public DoubleMask512 compress() { + return (DoubleMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + DoubleVector512.class, DoubleMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -696,30 +703,30 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline - public Double512Mask and(VectorMask mask) { + public DoubleMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask512 m = (DoubleMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Double512Mask or(VectorMask mask) { + public DoubleMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask512 m = (DoubleMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Double512Mask xor(VectorMask mask) { + public DoubleMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask512 m = (DoubleMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -729,21 +736,21 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -753,7 +760,7 @@ final class Double512Vector extends DoubleVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -763,7 +770,7 @@ final class Double512Vector extends DoubleVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(DoubleMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -772,48 +779,49 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double512Mask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((DoubleMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((DoubleMask512)m).getBits())); } @ForceInline /*package-private*/ - static Double512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static DoubleMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(DoubleMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Double512Mask TRUE_MASK = new Double512Mask(true); - private static final Double512Mask FALSE_MASK = new Double512Mask(false); + private static final DoubleMask512 TRUE_MASK = new DoubleMask512(true); + private static final DoubleMask512 FALSE_MASK = new DoubleMask512(false); } // Shuffle - - static final class Double512Shuffle extends AbstractShuffle { + @ValueBased + static final class DoubleShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Double512Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + DoubleShuffle512(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Double512Shuffle(int[] indices, int i) { + DoubleShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Double512Shuffle(IntUnaryOperator fn) { + DoubleShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -833,23 +841,23 @@ final class Double512Vector extends DoubleVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Double512Shuffle IOTA = new Double512Shuffle(IDENTITY); + static final DoubleShuffle512 IOTA = new DoubleShuffle512(IDENTITY); @Override @ForceInline - public Double512Vector toVector() { - return (Double512Vector) toBitsVector().castShape(vspecies(), 0); + public DoubleVector512 toVector() { + return (DoubleVector512) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Long512Vector toBitsVector() { - return (Long512Vector) super.toBitsVectorTemplate(); + LongVector512 toBitsVector() { + return (LongVector512) super.toBitsVectorTemplate(); } @Override - Long512Vector toBitsVector0() { - return ((Long512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector512 toBitsVector0() { + return ((LongVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -921,30 +929,30 @@ final class Double512Vector extends DoubleVector { @Override @ForceInline - public final Double512Mask laneIsValid() { - return (Double512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final DoubleMask512 laneIsValid() { + return (DoubleMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Double512Shuffle rearrange(VectorShuffle shuffle) { - Double512Shuffle concreteShuffle = (Double512Shuffle) shuffle; - return (Double512Shuffle) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_512)) - .toShuffle(vspecies(), false); + public final DoubleShuffle512 rearrange(VectorShuffle shuffle) { + DoubleShuffle512 concreteShuffle = (DoubleShuffle512) shuffle; + return (DoubleShuffle512) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_512)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Double512Shuffle wrapIndexes() { - Long512Vector v = toBitsVector(); + public final DoubleShuffle512 wrapIndexes() { + LongVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Double512Shuffle) v.toShuffle(vspecies(), false); + return (DoubleShuffle512) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -995,14 +1003,14 @@ final class Double512Vector extends DoubleVector { @Override final DoubleVector fromArray0(double[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Double512Mask.class, a, offset, (Double512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(DoubleMask512.class, a, offset, (DoubleMask512) m, offsetInRange); // specialize } @ForceInline @Override final DoubleVector fromArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Double512Mask.class, a, offset, indexMap, mapOffset, (Double512Mask) m); + return super.fromArray0Template(DoubleMask512.class, a, offset, indexMap, mapOffset, (DoubleMask512) m); } @@ -1018,7 +1026,7 @@ final class Double512Vector extends DoubleVector { @Override final DoubleVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Double512Mask.class, ms, offset, (Double512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(DoubleMask512.class, ms, offset, (DoubleMask512) m, offsetInRange); // specialize } @ForceInline @@ -1032,14 +1040,14 @@ final class Double512Vector extends DoubleVector { @Override final void intoArray0(double[] a, int offset, VectorMask m) { - super.intoArray0Template(Double512Mask.class, a, offset, (Double512Mask) m); + super.intoArray0Template(DoubleMask512.class, a, offset, (DoubleMask512) m); } @ForceInline @Override final void intoArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Double512Mask.class, a, offset, indexMap, mapOffset, (Double512Mask) m); + super.intoArray0Template(DoubleMask512.class, a, offset, indexMap, mapOffset, (DoubleMask512) m); } @@ -1047,7 +1055,7 @@ final class Double512Vector extends DoubleVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Double512Mask.class, ms, offset, (Double512Mask) m); + super.intoMemorySegment0Template(DoubleMask512.class, ms, offset, (DoubleMask512) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector64.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector64.java index 9535f112ada..5583cff80e1 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector64.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Double64Vector extends DoubleVector { +@ValueBased +final class DoubleVector64 extends DoubleVector { static final DoubleSpecies VSPECIES = (DoubleSpecies) DoubleVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Double64Vector.class; + static final Class VCLASS = DoubleVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + static final Class ETYPE = double.class; // used by the JVM - Double64Vector(double[] v) { + DoubleVector64(double[] v) { super(v); } - // For compatibility as Double64Vector::new, + // For compatibility as DoubleVector64::new, // stored into species.vectorFactory. - Double64Vector(Object v) { + DoubleVector64(Object v) { this((double[]) v); } - static final Double64Vector ZERO = new Double64Vector(new double[VLENGTH]); - static final Double64Vector IOTA = new Double64Vector(VSPECIES.iotaArray()); + static final DoubleVector64 ZERO = new DoubleVector64(new double[VLENGTH]); + static final DoubleVector64 IOTA = new DoubleVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Double64Vector extends DoubleVector { @Override public final Class elementType() { return double.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Double.SIZE; } @@ -130,51 +136,51 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline - public final Double64Vector broadcast(double e) { - return (Double64Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector64 broadcast(double e) { + return (DoubleVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Double64Vector broadcast(long e) { - return (Double64Vector) super.broadcastTemplate(e); // specialize + public final DoubleVector64 broadcast(long e) { + return (DoubleVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Double64Mask maskFromArray(boolean[] bits) { - return new Double64Mask(bits); + DoubleMask64 maskFromArray(boolean[] bits) { + return new DoubleMask64(bits); } @Override @ForceInline - Double64Shuffle iotaShuffle() { return Double64Shuffle.IOTA; } + DoubleShuffle64 iotaShuffle() { return DoubleShuffle64.IOTA; } @Override @ForceInline - Double64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Double64Shuffle) iotaShuffleTemplate(start, step, wrap); + DoubleShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (DoubleShuffle64) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Double64Shuffle shuffleFromArray(int[] indices, int i) { return new Double64Shuffle(indices, i); } + DoubleShuffle64 shuffleFromArray(int[] indices, int i) { return new DoubleShuffle64(indices, i); } @Override @ForceInline - Double64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Double64Shuffle(fn); } + DoubleShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new DoubleShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Double64Vector vectorFactory(double[] vec) { - return new Double64Vector(vec); + DoubleVector64 vectorFactory(double[] vec) { + return new DoubleVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +193,31 @@ final class Double64Vector extends DoubleVector { @ForceInline final @Override - Double64Vector uOp(FUnOp f) { - return (Double64Vector) super.uOpTemplate(f); // specialize + DoubleVector64 uOp(FUnOp f) { + return (DoubleVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Double64Vector uOp(VectorMask m, FUnOp f) { - return (Double64Vector) - super.uOpTemplate((Double64Mask)m, f); // specialize + DoubleVector64 uOp(VectorMask m, FUnOp f) { + return (DoubleVector64) + super.uOpTemplate((DoubleMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Double64Vector bOp(Vector v, FBinOp f) { - return (Double64Vector) super.bOpTemplate((Double64Vector)v, f); // specialize + DoubleVector64 bOp(Vector v, FBinOp f) { + return (DoubleVector64) super.bOpTemplate((DoubleVector64)v, f); // specialize } @ForceInline final @Override - Double64Vector bOp(Vector v, + DoubleVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Double64Vector) - super.bOpTemplate((Double64Vector)v, (Double64Mask)m, + return (DoubleVector64) + super.bOpTemplate((DoubleVector64)v, (DoubleMask64)m, f); // specialize } @@ -219,19 +225,19 @@ final class Double64Vector extends DoubleVector { @ForceInline final @Override - Double64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Double64Vector) - super.tOpTemplate((Double64Vector)v1, (Double64Vector)v2, + DoubleVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (DoubleVector64) + super.tOpTemplate((DoubleVector64)v1, (DoubleVector64)v2, f); // specialize } @ForceInline final @Override - Double64Vector tOp(Vector v1, Vector v2, + DoubleVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Double64Vector) - super.tOpTemplate((Double64Vector)v1, (Double64Vector)v2, - (Double64Mask)m, f); // specialize + return (DoubleVector64) + super.tOpTemplate((DoubleVector64)v1, (DoubleVector64)v2, + (DoubleMask64)m, f); // specialize } @ForceInline @@ -269,26 +275,26 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline - public Double64Vector lanewise(Unary op) { - return (Double64Vector) super.lanewiseTemplate(op); // specialize + public DoubleVector64 lanewise(Unary op) { + return (DoubleVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Double64Vector lanewise(Unary op, VectorMask m) { - return (Double64Vector) super.lanewiseTemplate(op, Double64Mask.class, (Double64Mask) m); // specialize + public DoubleVector64 lanewise(Unary op, VectorMask m) { + return (DoubleVector64) super.lanewiseTemplate(op, DoubleMask64.class, (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector lanewise(Binary op, Vector v) { - return (Double64Vector) super.lanewiseTemplate(op, v); // specialize + public DoubleVector64 lanewise(Binary op, Vector v) { + return (DoubleVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Double64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Double64Vector) super.lanewiseTemplate(op, Double64Mask.class, v, (Double64Mask) m); // specialize + public DoubleVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (DoubleVector64) super.lanewiseTemplate(op, DoubleMask64.class, v, (DoubleMask64) m); // specialize } @@ -296,24 +302,24 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline public final - Double64Vector + DoubleVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Double64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (DoubleVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Double64Vector + DoubleVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Double64Vector) super.lanewiseTemplate(op, Double64Mask.class, v1, v2, (Double64Mask) m); // specialize + return (DoubleVector64) super.lanewiseTemplate(op, DoubleMask64.class, v1, v2, (DoubleMask64) m); // specialize } @Override @ForceInline public final - Double64Vector addIndex(int scale) { - return (Double64Vector) super.addIndexTemplate(scale); // specialize + DoubleVector64 addIndex(int scale) { + return (DoubleVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +334,7 @@ final class Double64Vector extends DoubleVector { @ForceInline public final double reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Double64Mask.class, (Double64Mask) m); // specialized + return super.reduceLanesTemplate(op, DoubleMask64.class, (DoubleMask64) m); // specialized } @Override @@ -341,7 +347,7 @@ final class Double64Vector extends DoubleVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Double64Mask.class, (Double64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, DoubleMask64.class, (DoubleMask64) m); // specialized } @Override @@ -352,160 +358,160 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline - public final Double64Shuffle toShuffle() { - return (Double64Shuffle) toShuffle(vspecies(), false); + public final DoubleShuffle64 toShuffle() { + return (DoubleShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Double64Mask test(Test op) { - return super.testTemplate(Double64Mask.class, op); // specialize + public final DoubleMask64 test(Test op) { + return super.testTemplate(DoubleMask64.class, op); // specialize } @Override @ForceInline - public final Double64Mask test(Test op, VectorMask m) { - return super.testTemplate(Double64Mask.class, op, (Double64Mask) m); // specialize + public final DoubleMask64 test(Test op, VectorMask m) { + return super.testTemplate(DoubleMask64.class, op, (DoubleMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Double64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Double64Mask.class, op, v); // specialize + public final DoubleMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(DoubleMask64.class, op, v); // specialize } @Override @ForceInline - public final Double64Mask compare(Comparison op, double s) { - return super.compareTemplate(Double64Mask.class, op, s); // specialize + public final DoubleMask64 compare(Comparison op, double s) { + return super.compareTemplate(DoubleMask64.class, op, s); // specialize } @Override @ForceInline - public final Double64Mask compare(Comparison op, long s) { - return super.compareTemplate(Double64Mask.class, op, s); // specialize + public final DoubleMask64 compare(Comparison op, long s) { + return super.compareTemplate(DoubleMask64.class, op, s); // specialize } @Override @ForceInline - public final Double64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Double64Mask.class, op, v, (Double64Mask) m); + public final DoubleMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(DoubleMask64.class, op, v, (DoubleMask64) m); } @Override @ForceInline - public Double64Vector blend(Vector v, VectorMask m) { - return (Double64Vector) - super.blendTemplate(Double64Mask.class, - (Double64Vector) v, - (Double64Mask) m); // specialize + public DoubleVector64 blend(Vector v, VectorMask m) { + return (DoubleVector64) + super.blendTemplate(DoubleMask64.class, + (DoubleVector64) v, + (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector slice(int origin, Vector v) { - return (Double64Vector) super.sliceTemplate(origin, v); // specialize + public DoubleVector64 slice(int origin, Vector v) { + return (DoubleVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Double64Vector slice(int origin) { - return (Double64Vector) super.sliceTemplate(origin); // specialize + public DoubleVector64 slice(int origin) { + return (DoubleVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Double64Vector unslice(int origin, Vector w, int part) { - return (Double64Vector) super.unsliceTemplate(origin, w, part); // specialize + public DoubleVector64 unslice(int origin, Vector w, int part) { + return (DoubleVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Double64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Double64Vector) - super.unsliceTemplate(Double64Mask.class, + public DoubleVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (DoubleVector64) + super.unsliceTemplate(DoubleMask64.class, origin, w, part, - (Double64Mask) m); // specialize + (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector unslice(int origin) { - return (Double64Vector) super.unsliceTemplate(origin); // specialize + public DoubleVector64 unslice(int origin) { + return (DoubleVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Double64Vector rearrange(VectorShuffle s) { - return (Double64Vector) - super.rearrangeTemplate(Double64Shuffle.class, - (Double64Shuffle) s); // specialize + public DoubleVector64 rearrange(VectorShuffle s) { + return (DoubleVector64) + super.rearrangeTemplate(DoubleShuffle64.class, + (DoubleShuffle64) s); // specialize } @Override @ForceInline - public Double64Vector rearrange(VectorShuffle shuffle, + public DoubleVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Double64Vector) - super.rearrangeTemplate(Double64Shuffle.class, - Double64Mask.class, - (Double64Shuffle) shuffle, - (Double64Mask) m); // specialize + return (DoubleVector64) + super.rearrangeTemplate(DoubleShuffle64.class, + DoubleMask64.class, + (DoubleShuffle64) shuffle, + (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector rearrange(VectorShuffle s, + public DoubleVector64 rearrange(VectorShuffle s, Vector v) { - return (Double64Vector) - super.rearrangeTemplate(Double64Shuffle.class, - (Double64Shuffle) s, - (Double64Vector) v); // specialize + return (DoubleVector64) + super.rearrangeTemplate(DoubleShuffle64.class, + (DoubleShuffle64) s, + (DoubleVector64) v); // specialize } @Override @ForceInline - public Double64Vector compress(VectorMask m) { - return (Double64Vector) - super.compressTemplate(Double64Mask.class, - (Double64Mask) m); // specialize + public DoubleVector64 compress(VectorMask m) { + return (DoubleVector64) + super.compressTemplate(DoubleMask64.class, + (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector expand(VectorMask m) { - return (Double64Vector) - super.expandTemplate(Double64Mask.class, - (Double64Mask) m); // specialize + public DoubleVector64 expand(VectorMask m) { + return (DoubleVector64) + super.expandTemplate(DoubleMask64.class, + (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector selectFrom(Vector v) { - return (Double64Vector) - super.selectFromTemplate((Double64Vector) v); // specialize + public DoubleVector64 selectFrom(Vector v) { + return (DoubleVector64) + super.selectFromTemplate((DoubleVector64) v); // specialize } @Override @ForceInline - public Double64Vector selectFrom(Vector v, + public DoubleVector64 selectFrom(Vector v, VectorMask m) { - return (Double64Vector) - super.selectFromTemplate((Double64Vector) v, - Double64Mask.class, (Double64Mask) m); // specialize + return (DoubleVector64) + super.selectFromTemplate((DoubleVector64) v, + DoubleMask64.class, (DoubleMask64) m); // specialize } @Override @ForceInline - public Double64Vector selectFrom(Vector v1, + public DoubleVector64 selectFrom(Vector v1, Vector v2) { - return (Double64Vector) - super.selectFromTemplate((Double64Vector) v1, (Double64Vector) v2); // specialize + return (DoubleVector64) + super.selectFromTemplate((DoubleVector64) v1, (DoubleVector64) v2); // specialize } @ForceInline @@ -532,7 +538,7 @@ final class Double64Vector extends DoubleVector { @ForceInline @Override - public Double64Vector withLane(int i, double e) { + public DoubleVector64 withLane(int i, double e) { switch(i) { case 0: return withLaneHelper(0, e); default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); @@ -540,7 +546,7 @@ final class Double64Vector extends DoubleVector { } @ForceInline - public Double64Vector withLaneHelper(int i, double e) { + public DoubleVector64 withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), @@ -552,20 +558,21 @@ final class Double64Vector extends DoubleVector { } // Mask - - static final class Double64Mask extends AbstractMask { + @ValueBased + static final class DoubleMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM - Double64Mask(boolean[] bits) { + static final Class CTYPE = double.class; // used by the JVM + + DoubleMask64(boolean[] bits) { this(bits, 0); } - Double64Mask(boolean[] bits, int offset) { + DoubleMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Double64Mask(boolean val) { + DoubleMask64(boolean val) { super(prepare(val)); } @@ -598,31 +605,31 @@ final class Double64Vector extends DoubleVector { } @Override - Double64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Double64Mask(res); + return new DoubleMask64(res); } @Override - Double64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Double64Mask)m).getBits(); + boolean[] mbits = ((DoubleMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Double64Mask(res); + return new DoubleMask64(res); } @ForceInline @Override public final - Double64Vector toVector() { - return (Double64Vector) super.toVectorTemplate(); // specialize + DoubleVector64 toVector() { + return (DoubleVector64) super.toVectorTemplate(); // specialize } /** @@ -655,25 +662,25 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline /*package-private*/ - Double64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Double64Mask) VectorSupport.indexPartiallyInUpperRange( - Double64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Double64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + DoubleMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMask64) VectorSupport.indexPartiallyInUpperRange( + DoubleMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (DoubleMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Double64Mask not() { + public DoubleMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Double64Mask compress() { - return (Double64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double64Vector.class, Double64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public DoubleMask64 compress() { + return (DoubleMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + DoubleVector64.class, DoubleMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -682,30 +689,30 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline - public Double64Mask and(VectorMask mask) { + public DoubleMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask64 m = (DoubleMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Double64Mask or(VectorMask mask) { + public DoubleMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask64 m = (DoubleMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Double64Mask xor(VectorMask mask) { + public DoubleMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMask64 m = (DoubleMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -715,21 +722,21 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -739,7 +746,7 @@ final class Double64Vector extends DoubleVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -749,7 +756,7 @@ final class Double64Vector extends DoubleVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(DoubleMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -758,48 +765,49 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double64Mask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((DoubleMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((DoubleMask64)m).getBits())); } @ForceInline /*package-private*/ - static Double64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static DoubleMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(DoubleMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Double64Mask TRUE_MASK = new Double64Mask(true); - private static final Double64Mask FALSE_MASK = new Double64Mask(false); + private static final DoubleMask64 TRUE_MASK = new DoubleMask64(true); + private static final DoubleMask64 FALSE_MASK = new DoubleMask64(false); } // Shuffle - - static final class Double64Shuffle extends AbstractShuffle { + @ValueBased + static final class DoubleShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Double64Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + DoubleShuffle64(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Double64Shuffle(int[] indices, int i) { + DoubleShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Double64Shuffle(IntUnaryOperator fn) { + DoubleShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -819,23 +827,23 @@ final class Double64Vector extends DoubleVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Double64Shuffle IOTA = new Double64Shuffle(IDENTITY); + static final DoubleShuffle64 IOTA = new DoubleShuffle64(IDENTITY); @Override @ForceInline - public Double64Vector toVector() { - return (Double64Vector) toBitsVector().castShape(vspecies(), 0); + public DoubleVector64 toVector() { + return (DoubleVector64) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Long64Vector toBitsVector() { - return (Long64Vector) super.toBitsVectorTemplate(); + LongVector64 toBitsVector() { + return (LongVector64) super.toBitsVectorTemplate(); } @Override - Long64Vector toBitsVector0() { - return ((Long64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector64 toBitsVector0() { + return ((LongVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -907,30 +915,30 @@ final class Double64Vector extends DoubleVector { @Override @ForceInline - public final Double64Mask laneIsValid() { - return (Double64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final DoubleMask64 laneIsValid() { + return (DoubleMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Double64Shuffle rearrange(VectorShuffle shuffle) { - Double64Shuffle concreteShuffle = (Double64Shuffle) shuffle; - return (Double64Shuffle) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_64)) - .toShuffle(vspecies(), false); + public final DoubleShuffle64 rearrange(VectorShuffle shuffle) { + DoubleShuffle64 concreteShuffle = (DoubleShuffle64) shuffle; + return (DoubleShuffle64) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_64)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Double64Shuffle wrapIndexes() { - Long64Vector v = toBitsVector(); + public final DoubleShuffle64 wrapIndexes() { + LongVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Double64Shuffle) v.toShuffle(vspecies(), false); + return (DoubleShuffle64) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -981,14 +989,14 @@ final class Double64Vector extends DoubleVector { @Override final DoubleVector fromArray0(double[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Double64Mask.class, a, offset, (Double64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(DoubleMask64.class, a, offset, (DoubleMask64) m, offsetInRange); // specialize } @ForceInline @Override final DoubleVector fromArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Double64Mask.class, a, offset, indexMap, mapOffset, (Double64Mask) m); + return super.fromArray0Template(DoubleMask64.class, a, offset, indexMap, mapOffset, (DoubleMask64) m); } @@ -1004,7 +1012,7 @@ final class Double64Vector extends DoubleVector { @Override final DoubleVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Double64Mask.class, ms, offset, (Double64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(DoubleMask64.class, ms, offset, (DoubleMask64) m, offsetInRange); // specialize } @ForceInline @@ -1018,14 +1026,14 @@ final class Double64Vector extends DoubleVector { @Override final void intoArray0(double[] a, int offset, VectorMask m) { - super.intoArray0Template(Double64Mask.class, a, offset, (Double64Mask) m); + super.intoArray0Template(DoubleMask64.class, a, offset, (DoubleMask64) m); } @ForceInline @Override final void intoArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Double64Mask.class, a, offset, indexMap, mapOffset, (Double64Mask) m); + super.intoArray0Template(DoubleMask64.class, a, offset, indexMap, mapOffset, (DoubleMask64) m); } @@ -1033,7 +1041,7 @@ final class Double64Vector extends DoubleVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Double64Mask.class, ms, offset, (Double64Mask) m); + super.intoMemorySegment0Template(DoubleMask64.class, ms, offset, (DoubleMask64) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVectorMax.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVectorMax.java index 8daa77dfc49..41272a5a5e5 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVectorMax.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class DoubleMaxVector extends DoubleVector { +@ValueBased +final class DoubleVectorMax extends DoubleVector { static final DoubleSpecies VSPECIES = (DoubleSpecies) DoubleVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = DoubleMaxVector.class; + static final Class VCLASS = DoubleVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + static final Class ETYPE = double.class; // used by the JVM - DoubleMaxVector(double[] v) { + DoubleVectorMax(double[] v) { super(v); } - // For compatibility as DoubleMaxVector::new, + // For compatibility as DoubleVectorMax::new, // stored into species.vectorFactory. - DoubleMaxVector(Object v) { + DoubleVectorMax(Object v) { this((double[]) v); } - static final DoubleMaxVector ZERO = new DoubleMaxVector(new double[VLENGTH]); - static final DoubleMaxVector IOTA = new DoubleMaxVector(VSPECIES.iotaArray()); + static final DoubleVectorMax ZERO = new DoubleVectorMax(new double[VLENGTH]); + static final DoubleVectorMax IOTA = new DoubleVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class DoubleMaxVector extends DoubleVector { @Override public final Class elementType() { return double.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Double.SIZE; } @@ -130,51 +136,51 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline - public final DoubleMaxVector broadcast(double e) { - return (DoubleMaxVector) super.broadcastTemplate(e); // specialize + public final DoubleVectorMax broadcast(double e) { + return (DoubleVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final DoubleMaxVector broadcast(long e) { - return (DoubleMaxVector) super.broadcastTemplate(e); // specialize + public final DoubleVectorMax broadcast(long e) { + return (DoubleVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - DoubleMaxMask maskFromArray(boolean[] bits) { - return new DoubleMaxMask(bits); + DoubleMaskMax maskFromArray(boolean[] bits) { + return new DoubleMaskMax(bits); } @Override @ForceInline - DoubleMaxShuffle iotaShuffle() { return DoubleMaxShuffle.IOTA; } + DoubleShuffleMax iotaShuffle() { return DoubleShuffleMax.IOTA; } @Override @ForceInline - DoubleMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (DoubleMaxShuffle) iotaShuffleTemplate(start, step, wrap); + DoubleShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (DoubleShuffleMax) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - DoubleMaxShuffle shuffleFromArray(int[] indices, int i) { return new DoubleMaxShuffle(indices, i); } + DoubleShuffleMax shuffleFromArray(int[] indices, int i) { return new DoubleShuffleMax(indices, i); } @Override @ForceInline - DoubleMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new DoubleMaxShuffle(fn); } + DoubleShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new DoubleShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - DoubleMaxVector vectorFactory(double[] vec) { - return new DoubleMaxVector(vec); + DoubleVectorMax vectorFactory(double[] vec) { + return new DoubleVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +193,31 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline final @Override - DoubleMaxVector uOp(FUnOp f) { - return (DoubleMaxVector) super.uOpTemplate(f); // specialize + DoubleVectorMax uOp(FUnOp f) { + return (DoubleVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - DoubleMaxVector uOp(VectorMask m, FUnOp f) { - return (DoubleMaxVector) - super.uOpTemplate((DoubleMaxMask)m, f); // specialize + DoubleVectorMax uOp(VectorMask m, FUnOp f) { + return (DoubleVectorMax) + super.uOpTemplate((DoubleMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - DoubleMaxVector bOp(Vector v, FBinOp f) { - return (DoubleMaxVector) super.bOpTemplate((DoubleMaxVector)v, f); // specialize + DoubleVectorMax bOp(Vector v, FBinOp f) { + return (DoubleVectorMax) super.bOpTemplate((DoubleVectorMax)v, f); // specialize } @ForceInline final @Override - DoubleMaxVector bOp(Vector v, + DoubleVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (DoubleMaxVector) - super.bOpTemplate((DoubleMaxVector)v, (DoubleMaxMask)m, + return (DoubleVectorMax) + super.bOpTemplate((DoubleVectorMax)v, (DoubleMaskMax)m, f); // specialize } @@ -219,19 +225,19 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline final @Override - DoubleMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (DoubleMaxVector) - super.tOpTemplate((DoubleMaxVector)v1, (DoubleMaxVector)v2, + DoubleVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (DoubleVectorMax) + super.tOpTemplate((DoubleVectorMax)v1, (DoubleVectorMax)v2, f); // specialize } @ForceInline final @Override - DoubleMaxVector tOp(Vector v1, Vector v2, + DoubleVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (DoubleMaxVector) - super.tOpTemplate((DoubleMaxVector)v1, (DoubleMaxVector)v2, - (DoubleMaxMask)m, f); // specialize + return (DoubleVectorMax) + super.tOpTemplate((DoubleVectorMax)v1, (DoubleVectorMax)v2, + (DoubleMaskMax)m, f); // specialize } @ForceInline @@ -269,26 +275,26 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline - public DoubleMaxVector lanewise(Unary op) { - return (DoubleMaxVector) super.lanewiseTemplate(op); // specialize + public DoubleVectorMax lanewise(Unary op) { + return (DoubleVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public DoubleMaxVector lanewise(Unary op, VectorMask m) { - return (DoubleMaxVector) super.lanewiseTemplate(op, DoubleMaxMask.class, (DoubleMaxMask) m); // specialize + public DoubleVectorMax lanewise(Unary op, VectorMask m) { + return (DoubleVectorMax) super.lanewiseTemplate(op, DoubleMaskMax.class, (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector lanewise(Binary op, Vector v) { - return (DoubleMaxVector) super.lanewiseTemplate(op, v); // specialize + public DoubleVectorMax lanewise(Binary op, Vector v) { + return (DoubleVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public DoubleMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (DoubleMaxVector) super.lanewiseTemplate(op, DoubleMaxMask.class, v, (DoubleMaxMask) m); // specialize + public DoubleVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (DoubleVectorMax) super.lanewiseTemplate(op, DoubleMaskMax.class, v, (DoubleMaskMax) m); // specialize } @@ -296,24 +302,24 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline public final - DoubleMaxVector + DoubleVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (DoubleMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (DoubleVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - DoubleMaxVector + DoubleVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (DoubleMaxVector) super.lanewiseTemplate(op, DoubleMaxMask.class, v1, v2, (DoubleMaxMask) m); // specialize + return (DoubleVectorMax) super.lanewiseTemplate(op, DoubleMaskMax.class, v1, v2, (DoubleMaskMax) m); // specialize } @Override @ForceInline public final - DoubleMaxVector addIndex(int scale) { - return (DoubleMaxVector) super.addIndexTemplate(scale); // specialize + DoubleVectorMax addIndex(int scale) { + return (DoubleVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +334,7 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline public final double reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, DoubleMaxMask.class, (DoubleMaxMask) m); // specialized + return super.reduceLanesTemplate(op, DoubleMaskMax.class, (DoubleMaskMax) m); // specialized } @Override @@ -341,7 +347,7 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, DoubleMaxMask.class, (DoubleMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, DoubleMaskMax.class, (DoubleMaskMax) m); // specialized } @Override @@ -352,160 +358,160 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline - public final DoubleMaxShuffle toShuffle() { - return (DoubleMaxShuffle) toShuffle(vspecies(), false); + public final DoubleShuffleMax toShuffle() { + return (DoubleShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final DoubleMaxMask test(Test op) { - return super.testTemplate(DoubleMaxMask.class, op); // specialize + public final DoubleMaskMax test(Test op) { + return super.testTemplate(DoubleMaskMax.class, op); // specialize } @Override @ForceInline - public final DoubleMaxMask test(Test op, VectorMask m) { - return super.testTemplate(DoubleMaxMask.class, op, (DoubleMaxMask) m); // specialize + public final DoubleMaskMax test(Test op, VectorMask m) { + return super.testTemplate(DoubleMaskMax.class, op, (DoubleMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final DoubleMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(DoubleMaxMask.class, op, v); // specialize + public final DoubleMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(DoubleMaskMax.class, op, v); // specialize } @Override @ForceInline - public final DoubleMaxMask compare(Comparison op, double s) { - return super.compareTemplate(DoubleMaxMask.class, op, s); // specialize + public final DoubleMaskMax compare(Comparison op, double s) { + return super.compareTemplate(DoubleMaskMax.class, op, s); // specialize } @Override @ForceInline - public final DoubleMaxMask compare(Comparison op, long s) { - return super.compareTemplate(DoubleMaxMask.class, op, s); // specialize + public final DoubleMaskMax compare(Comparison op, long s) { + return super.compareTemplate(DoubleMaskMax.class, op, s); // specialize } @Override @ForceInline - public final DoubleMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(DoubleMaxMask.class, op, v, (DoubleMaxMask) m); + public final DoubleMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(DoubleMaskMax.class, op, v, (DoubleMaskMax) m); } @Override @ForceInline - public DoubleMaxVector blend(Vector v, VectorMask m) { - return (DoubleMaxVector) - super.blendTemplate(DoubleMaxMask.class, - (DoubleMaxVector) v, - (DoubleMaxMask) m); // specialize + public DoubleVectorMax blend(Vector v, VectorMask m) { + return (DoubleVectorMax) + super.blendTemplate(DoubleMaskMax.class, + (DoubleVectorMax) v, + (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector slice(int origin, Vector v) { - return (DoubleMaxVector) super.sliceTemplate(origin, v); // specialize + public DoubleVectorMax slice(int origin, Vector v) { + return (DoubleVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public DoubleMaxVector slice(int origin) { - return (DoubleMaxVector) super.sliceTemplate(origin); // specialize + public DoubleVectorMax slice(int origin) { + return (DoubleVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public DoubleMaxVector unslice(int origin, Vector w, int part) { - return (DoubleMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public DoubleVectorMax unslice(int origin, Vector w, int part) { + return (DoubleVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public DoubleMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (DoubleMaxVector) - super.unsliceTemplate(DoubleMaxMask.class, + public DoubleVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (DoubleVectorMax) + super.unsliceTemplate(DoubleMaskMax.class, origin, w, part, - (DoubleMaxMask) m); // specialize + (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector unslice(int origin) { - return (DoubleMaxVector) super.unsliceTemplate(origin); // specialize + public DoubleVectorMax unslice(int origin) { + return (DoubleVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public DoubleMaxVector rearrange(VectorShuffle s) { - return (DoubleMaxVector) - super.rearrangeTemplate(DoubleMaxShuffle.class, - (DoubleMaxShuffle) s); // specialize + public DoubleVectorMax rearrange(VectorShuffle s) { + return (DoubleVectorMax) + super.rearrangeTemplate(DoubleShuffleMax.class, + (DoubleShuffleMax) s); // specialize } @Override @ForceInline - public DoubleMaxVector rearrange(VectorShuffle shuffle, + public DoubleVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (DoubleMaxVector) - super.rearrangeTemplate(DoubleMaxShuffle.class, - DoubleMaxMask.class, - (DoubleMaxShuffle) shuffle, - (DoubleMaxMask) m); // specialize + return (DoubleVectorMax) + super.rearrangeTemplate(DoubleShuffleMax.class, + DoubleMaskMax.class, + (DoubleShuffleMax) shuffle, + (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector rearrange(VectorShuffle s, + public DoubleVectorMax rearrange(VectorShuffle s, Vector v) { - return (DoubleMaxVector) - super.rearrangeTemplate(DoubleMaxShuffle.class, - (DoubleMaxShuffle) s, - (DoubleMaxVector) v); // specialize + return (DoubleVectorMax) + super.rearrangeTemplate(DoubleShuffleMax.class, + (DoubleShuffleMax) s, + (DoubleVectorMax) v); // specialize } @Override @ForceInline - public DoubleMaxVector compress(VectorMask m) { - return (DoubleMaxVector) - super.compressTemplate(DoubleMaxMask.class, - (DoubleMaxMask) m); // specialize + public DoubleVectorMax compress(VectorMask m) { + return (DoubleVectorMax) + super.compressTemplate(DoubleMaskMax.class, + (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector expand(VectorMask m) { - return (DoubleMaxVector) - super.expandTemplate(DoubleMaxMask.class, - (DoubleMaxMask) m); // specialize + public DoubleVectorMax expand(VectorMask m) { + return (DoubleVectorMax) + super.expandTemplate(DoubleMaskMax.class, + (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector selectFrom(Vector v) { - return (DoubleMaxVector) - super.selectFromTemplate((DoubleMaxVector) v); // specialize + public DoubleVectorMax selectFrom(Vector v) { + return (DoubleVectorMax) + super.selectFromTemplate((DoubleVectorMax) v); // specialize } @Override @ForceInline - public DoubleMaxVector selectFrom(Vector v, + public DoubleVectorMax selectFrom(Vector v, VectorMask m) { - return (DoubleMaxVector) - super.selectFromTemplate((DoubleMaxVector) v, - DoubleMaxMask.class, (DoubleMaxMask) m); // specialize + return (DoubleVectorMax) + super.selectFromTemplate((DoubleVectorMax) v, + DoubleMaskMax.class, (DoubleMaskMax) m); // specialize } @Override @ForceInline - public DoubleMaxVector selectFrom(Vector v1, + public DoubleVectorMax selectFrom(Vector v1, Vector v2) { - return (DoubleMaxVector) - super.selectFromTemplate((DoubleMaxVector) v1, (DoubleMaxVector) v2); // specialize + return (DoubleVectorMax) + super.selectFromTemplate((DoubleVectorMax) v1, (DoubleVectorMax) v2); // specialize } @ForceInline @@ -531,7 +537,7 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline @Override - public DoubleMaxVector withLane(int i, double e) { + public DoubleVectorMax withLane(int i, double e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -539,7 +545,7 @@ final class DoubleMaxVector extends DoubleVector { } @ForceInline - public DoubleMaxVector withLaneHelper(int i, double e) { + public DoubleVectorMax withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), @@ -551,20 +557,21 @@ final class DoubleMaxVector extends DoubleVector { } // Mask - - static final class DoubleMaxMask extends AbstractMask { + @ValueBased + static final class DoubleMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM - DoubleMaxMask(boolean[] bits) { + static final Class CTYPE = double.class; // used by the JVM + + DoubleMaskMax(boolean[] bits) { this(bits, 0); } - DoubleMaxMask(boolean[] bits, int offset) { + DoubleMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - DoubleMaxMask(boolean val) { + DoubleMaskMax(boolean val) { super(prepare(val)); } @@ -597,31 +604,31 @@ final class DoubleMaxVector extends DoubleVector { } @Override - DoubleMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new DoubleMaxMask(res); + return new DoubleMaskMax(res); } @Override - DoubleMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + DoubleMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((DoubleMaxMask)m).getBits(); + boolean[] mbits = ((DoubleMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new DoubleMaxMask(res); + return new DoubleMaskMax(res); } @ForceInline @Override public final - DoubleMaxVector toVector() { - return (DoubleMaxVector) super.toVectorTemplate(); // specialize + DoubleVectorMax toVector() { + return (DoubleVectorMax) super.toVectorTemplate(); // specialize } /** @@ -654,25 +661,25 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline /*package-private*/ - DoubleMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (DoubleMaxMask) VectorSupport.indexPartiallyInUpperRange( - DoubleMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (DoubleMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + DoubleMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMaskMax) VectorSupport.indexPartiallyInUpperRange( + DoubleMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (DoubleMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public DoubleMaxMask not() { + public DoubleMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public DoubleMaxMask compress() { - return (DoubleMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - DoubleMaxVector.class, DoubleMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public DoubleMaskMax compress() { + return (DoubleMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + DoubleVectorMax.class, DoubleMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -681,30 +688,30 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline - public DoubleMaxMask and(VectorMask mask) { + public DoubleMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMaskMax m = (DoubleMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public DoubleMaxMask or(VectorMask mask) { + public DoubleMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMaskMax m = (DoubleMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public DoubleMaxMask xor(VectorMask mask) { + public DoubleMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + DoubleMaskMax m = (DoubleMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -714,21 +721,21 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -738,7 +745,7 @@ final class DoubleMaxVector extends DoubleVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -748,7 +755,7 @@ final class DoubleMaxVector extends DoubleVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(DoubleMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(DoubleMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -757,48 +764,49 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((DoubleMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((DoubleMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((DoubleMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((DoubleMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static DoubleMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(DoubleMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static DoubleMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(DoubleMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final DoubleMaxMask TRUE_MASK = new DoubleMaxMask(true); - private static final DoubleMaxMask FALSE_MASK = new DoubleMaxMask(false); + private static final DoubleMaskMax TRUE_MASK = new DoubleMaskMax(true); + private static final DoubleMaskMax FALSE_MASK = new DoubleMaskMax(false); } // Shuffle - - static final class DoubleMaxShuffle extends AbstractShuffle { + @ValueBased + static final class DoubleShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - DoubleMaxShuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + DoubleShuffleMax(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - DoubleMaxShuffle(int[] indices, int i) { + DoubleShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - DoubleMaxShuffle(IntUnaryOperator fn) { + DoubleShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -818,23 +826,23 @@ final class DoubleMaxVector extends DoubleVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final DoubleMaxShuffle IOTA = new DoubleMaxShuffle(IDENTITY); + static final DoubleShuffleMax IOTA = new DoubleShuffleMax(IDENTITY); @Override @ForceInline - public DoubleMaxVector toVector() { - return (DoubleMaxVector) toBitsVector().castShape(vspecies(), 0); + public DoubleVectorMax toVector() { + return (DoubleVectorMax) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - LongMaxVector toBitsVector() { - return (LongMaxVector) super.toBitsVectorTemplate(); + LongVectorMax toBitsVector() { + return (LongVectorMax) super.toBitsVectorTemplate(); } @Override - LongMaxVector toBitsVector0() { - return ((LongMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVectorMax toBitsVector0() { + return ((LongVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -906,30 +914,30 @@ final class DoubleMaxVector extends DoubleVector { @Override @ForceInline - public final DoubleMaxMask laneIsValid() { - return (DoubleMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final DoubleMaskMax laneIsValid() { + return (DoubleMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final DoubleMaxShuffle rearrange(VectorShuffle shuffle) { - DoubleMaxShuffle concreteShuffle = (DoubleMaxShuffle) shuffle; - return (DoubleMaxShuffle) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_MAX)) - .toShuffle(vspecies(), false); + public final DoubleShuffleMax rearrange(VectorShuffle shuffle) { + DoubleShuffleMax concreteShuffle = (DoubleShuffleMax) shuffle; + return (DoubleShuffleMax) toBitsVector().rearrange(concreteShuffle.cast(LongVector.SPECIES_MAX)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final DoubleMaxShuffle wrapIndexes() { - LongMaxVector v = toBitsVector(); + public final DoubleShuffleMax wrapIndexes() { + LongVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (LongMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (LongMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (DoubleMaxShuffle) v.toShuffle(vspecies(), false); + return (DoubleShuffleMax) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -980,14 +988,14 @@ final class DoubleMaxVector extends DoubleVector { @Override final DoubleVector fromArray0(double[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(DoubleMaxMask.class, a, offset, (DoubleMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(DoubleMaskMax.class, a, offset, (DoubleMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final DoubleVector fromArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(DoubleMaxMask.class, a, offset, indexMap, mapOffset, (DoubleMaxMask) m); + return super.fromArray0Template(DoubleMaskMax.class, a, offset, indexMap, mapOffset, (DoubleMaskMax) m); } @@ -1003,7 +1011,7 @@ final class DoubleMaxVector extends DoubleVector { @Override final DoubleVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(DoubleMaxMask.class, ms, offset, (DoubleMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(DoubleMaskMax.class, ms, offset, (DoubleMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -1017,14 +1025,14 @@ final class DoubleMaxVector extends DoubleVector { @Override final void intoArray0(double[] a, int offset, VectorMask m) { - super.intoArray0Template(DoubleMaxMask.class, a, offset, (DoubleMaxMask) m); + super.intoArray0Template(DoubleMaskMax.class, a, offset, (DoubleMaskMax) m); } @ForceInline @Override final void intoArray0(double[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(DoubleMaxMask.class, a, offset, indexMap, mapOffset, (DoubleMaxMask) m); + super.intoArray0Template(DoubleMaskMax.class, a, offset, indexMap, mapOffset, (DoubleMaskMax) m); } @@ -1032,7 +1040,7 @@ final class DoubleMaxVector extends DoubleVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(DoubleMaxMask.class, ms, offset, (DoubleMaxMask) m); + super.intoMemorySegment0Template(DoubleMaskMax.class, ms, offset, (DoubleMaskMax) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16Consts.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16Consts.java index 48c4d2199b1..b70b11b0a49 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16Consts.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16Consts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ import static jdk.incubator.vector.Float16.SIZE; * {@code Float16} type. */ -class Float16Consts { +final class Float16Consts { /** * Don't let anyone instantiate this class. */ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index ee9cb9119fd..cdf2532e4d9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code float} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class FloatVector extends AbstractVector { +public abstract sealed class FloatVector extends AbstractVector + permits FloatVector64, FloatVector128, FloatVector256, FloatVector512, FloatVectorMax { FloatVector(float[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class FloatVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -724,7 +725,7 @@ public abstract class FloatVector extends AbstractVector { @ForceInline final FloatVector unaryMathOp(VectorOperators.Unary op) { - return VectorMathLibrary.unaryMathOp(op, opCode(op), species(), FloatVector::unaryOperations, + return VectorMathLibrary.unaryMathOp(op, opCode(op), vspecies(), FloatVector::unaryOperations, this); } @@ -851,7 +852,7 @@ public abstract class FloatVector extends AbstractVector { @ForceInline final FloatVector binaryMathOp(VectorOperators.Binary op, FloatVector that) { - return VectorMathLibrary.binaryMathOp(op, opCode(op), species(), FloatVector::binaryOperations, + return VectorMathLibrary.binaryMathOp(op, opCode(op), vspecies(), FloatVector::binaryOperations, this, that); } @@ -3926,13 +3927,13 @@ public abstract class FloatVector extends AbstractVector { @Override @ForceInline public final FloatVector zero() { - if ((Class) vectorType() == FloatMaxVector.class) - return FloatMaxVector.ZERO; + if ((Class) vectorType() == FloatVectorMax.class) + return FloatVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Float64Vector.ZERO; - case 128: return Float128Vector.ZERO; - case 256: return Float256Vector.ZERO; - case 512: return Float512Vector.ZERO; + case 64: return FloatVector64.ZERO; + case 128: return FloatVector128.ZERO; + case 256: return FloatVector256.ZERO; + case 512: return FloatVector512.ZERO; } throw new AssertionError(); } @@ -3940,13 +3941,13 @@ public abstract class FloatVector extends AbstractVector { @Override @ForceInline public final FloatVector iota() { - if ((Class) vectorType() == FloatMaxVector.class) - return FloatMaxVector.IOTA; + if ((Class) vectorType() == FloatVectorMax.class) + return FloatVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Float64Vector.IOTA; - case 128: return Float128Vector.IOTA; - case 256: return Float256Vector.IOTA; - case 512: return Float512Vector.IOTA; + case 64: return FloatVector64.IOTA; + case 128: return FloatVector128.IOTA; + case 256: return FloatVector256.IOTA; + case 512: return FloatVector512.IOTA; } throw new AssertionError(); } @@ -3955,13 +3956,13 @@ public abstract class FloatVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == FloatMaxVector.class) - return FloatMaxVector.FloatMaxMask.maskAll(bit); + if ((Class) vectorType() == FloatVectorMax.class) + return FloatVectorMax.FloatMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Float64Vector.Float64Mask.maskAll(bit); - case 128: return Float128Vector.Float128Mask.maskAll(bit); - case 256: return Float256Vector.Float256Mask.maskAll(bit); - case 512: return Float512Vector.Float512Mask.maskAll(bit); + case 64: return FloatVector64.FloatMask64.maskAll(bit); + case 128: return FloatVector128.FloatMask128.maskAll(bit); + case 256: return FloatVector256.FloatMask256.maskAll(bit); + case 512: return FloatVector512.FloatMask512.maskAll(bit); } throw new AssertionError(); } @@ -3989,42 +3990,42 @@ public abstract class FloatVector extends AbstractVector { /** Species representing {@link FloatVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new FloatSpecies(VectorShape.S_64_BIT, - Float64Vector.class, - Float64Vector.Float64Mask.class, - Float64Vector.Float64Shuffle.class, - Float64Vector::new); + FloatVector64.class, + FloatVector64.FloatMask64.class, + FloatVector64.FloatShuffle64.class, + FloatVector64::new); /** Species representing {@link FloatVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new FloatSpecies(VectorShape.S_128_BIT, - Float128Vector.class, - Float128Vector.Float128Mask.class, - Float128Vector.Float128Shuffle.class, - Float128Vector::new); + FloatVector128.class, + FloatVector128.FloatMask128.class, + FloatVector128.FloatShuffle128.class, + FloatVector128::new); /** Species representing {@link FloatVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new FloatSpecies(VectorShape.S_256_BIT, - Float256Vector.class, - Float256Vector.Float256Mask.class, - Float256Vector.Float256Shuffle.class, - Float256Vector::new); + FloatVector256.class, + FloatVector256.FloatMask256.class, + FloatVector256.FloatShuffle256.class, + FloatVector256::new); /** Species representing {@link FloatVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new FloatSpecies(VectorShape.S_512_BIT, - Float512Vector.class, - Float512Vector.Float512Mask.class, - Float512Vector.Float512Shuffle.class, - Float512Vector::new); + FloatVector512.class, + FloatVector512.FloatMask512.class, + FloatVector512.FloatShuffle512.class, + FloatVector512::new); /** Species representing {@link FloatVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new FloatSpecies(VectorShape.S_Max_BIT, - FloatMaxVector.class, - FloatMaxVector.FloatMaxMask.class, - FloatMaxVector.FloatMaxShuffle.class, - FloatMaxVector::new); + FloatVectorMax.class, + FloatVectorMax.FloatMaskMax.class, + FloatVectorMax.FloatShuffleMax.class, + FloatVectorMax::new); /** * Preferred species for {@link FloatVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector128.java similarity index 62% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector128.java index 62c7d535fc7..24888e966da 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector128.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Float128Vector extends FloatVector { +@ValueBased +final class FloatVector128 extends FloatVector { static final FloatSpecies VSPECIES = (FloatSpecies) FloatVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Float128Vector.class; + static final Class VCLASS = FloatVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + static final Class ETYPE = float.class; // used by the JVM - Float128Vector(float[] v) { + FloatVector128(float[] v) { super(v); } - // For compatibility as Float128Vector::new, + // For compatibility as FloatVector128::new, // stored into species.vectorFactory. - Float128Vector(Object v) { + FloatVector128(Object v) { this((float[]) v); } - static final Float128Vector ZERO = new Float128Vector(new float[VLENGTH]); - static final Float128Vector IOTA = new Float128Vector(VSPECIES.iotaArray()); + static final FloatVector128 ZERO = new FloatVector128(new float[VLENGTH]); + static final FloatVector128 IOTA = new FloatVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Float128Vector extends FloatVector { @Override public final Class elementType() { return float.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Float.SIZE; } @@ -130,51 +135,51 @@ final class Float128Vector extends FloatVector { @Override @ForceInline - public final Float128Vector broadcast(float e) { - return (Float128Vector) super.broadcastTemplate(e); // specialize + public final FloatVector128 broadcast(float e) { + return (FloatVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Float128Vector broadcast(long e) { - return (Float128Vector) super.broadcastTemplate(e); // specialize + public final FloatVector128 broadcast(long e) { + return (FloatVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Float128Mask maskFromArray(boolean[] bits) { - return new Float128Mask(bits); + FloatMask128 maskFromArray(boolean[] bits) { + return new FloatMask128(bits); } @Override @ForceInline - Float128Shuffle iotaShuffle() { return Float128Shuffle.IOTA; } + FloatShuffle128 iotaShuffle() { return FloatShuffle128.IOTA; } @Override @ForceInline - Float128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Float128Shuffle) iotaShuffleTemplate(start, step, wrap); + FloatShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (FloatShuffle128) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Float128Shuffle shuffleFromArray(int[] indices, int i) { return new Float128Shuffle(indices, i); } + FloatShuffle128 shuffleFromArray(int[] indices, int i) { return new FloatShuffle128(indices, i); } @Override @ForceInline - Float128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Float128Shuffle(fn); } + FloatShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new FloatShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Float128Vector vectorFactory(float[] vec) { - return new Float128Vector(vec); + FloatVector128 vectorFactory(float[] vec) { + return new FloatVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Float128Vector extends FloatVector { @ForceInline final @Override - Float128Vector uOp(FUnOp f) { - return (Float128Vector) super.uOpTemplate(f); // specialize + FloatVector128 uOp(FUnOp f) { + return (FloatVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Float128Vector uOp(VectorMask m, FUnOp f) { - return (Float128Vector) - super.uOpTemplate((Float128Mask)m, f); // specialize + FloatVector128 uOp(VectorMask m, FUnOp f) { + return (FloatVector128) + super.uOpTemplate((FloatMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Float128Vector bOp(Vector v, FBinOp f) { - return (Float128Vector) super.bOpTemplate((Float128Vector)v, f); // specialize + FloatVector128 bOp(Vector v, FBinOp f) { + return (FloatVector128) super.bOpTemplate((FloatVector128)v, f); // specialize } @ForceInline final @Override - Float128Vector bOp(Vector v, + FloatVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Float128Vector) - super.bOpTemplate((Float128Vector)v, (Float128Mask)m, + return (FloatVector128) + super.bOpTemplate((FloatVector128)v, (FloatMask128)m, f); // specialize } @@ -219,19 +224,19 @@ final class Float128Vector extends FloatVector { @ForceInline final @Override - Float128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Float128Vector) - super.tOpTemplate((Float128Vector)v1, (Float128Vector)v2, + FloatVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (FloatVector128) + super.tOpTemplate((FloatVector128)v1, (FloatVector128)v2, f); // specialize } @ForceInline final @Override - Float128Vector tOp(Vector v1, Vector v2, + FloatVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Float128Vector) - super.tOpTemplate((Float128Vector)v1, (Float128Vector)v2, - (Float128Mask)m, f); // specialize + return (FloatVector128) + super.tOpTemplate((FloatVector128)v1, (FloatVector128)v2, + (FloatMask128)m, f); // specialize } @ForceInline @@ -269,26 +274,26 @@ final class Float128Vector extends FloatVector { @Override @ForceInline - public Float128Vector lanewise(Unary op) { - return (Float128Vector) super.lanewiseTemplate(op); // specialize + public FloatVector128 lanewise(Unary op) { + return (FloatVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Float128Vector lanewise(Unary op, VectorMask m) { - return (Float128Vector) super.lanewiseTemplate(op, Float128Mask.class, (Float128Mask) m); // specialize + public FloatVector128 lanewise(Unary op, VectorMask m) { + return (FloatVector128) super.lanewiseTemplate(op, FloatMask128.class, (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector lanewise(Binary op, Vector v) { - return (Float128Vector) super.lanewiseTemplate(op, v); // specialize + public FloatVector128 lanewise(Binary op, Vector v) { + return (FloatVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Float128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Float128Vector) super.lanewiseTemplate(op, Float128Mask.class, v, (Float128Mask) m); // specialize + public FloatVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (FloatVector128) super.lanewiseTemplate(op, FloatMask128.class, v, (FloatMask128) m); // specialize } @@ -296,24 +301,24 @@ final class Float128Vector extends FloatVector { @Override @ForceInline public final - Float128Vector + FloatVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Float128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (FloatVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Float128Vector + FloatVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Float128Vector) super.lanewiseTemplate(op, Float128Mask.class, v1, v2, (Float128Mask) m); // specialize + return (FloatVector128) super.lanewiseTemplate(op, FloatMask128.class, v1, v2, (FloatMask128) m); // specialize } @Override @ForceInline public final - Float128Vector addIndex(int scale) { - return (Float128Vector) super.addIndexTemplate(scale); // specialize + FloatVector128 addIndex(int scale) { + return (FloatVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +333,7 @@ final class Float128Vector extends FloatVector { @ForceInline public final float reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Float128Mask.class, (Float128Mask) m); // specialized + return super.reduceLanesTemplate(op, FloatMask128.class, (FloatMask128) m); // specialized } @Override @@ -341,7 +346,7 @@ final class Float128Vector extends FloatVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Float128Mask.class, (Float128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, FloatMask128.class, (FloatMask128) m); // specialized } @Override @@ -352,160 +357,160 @@ final class Float128Vector extends FloatVector { @Override @ForceInline - public final Float128Shuffle toShuffle() { - return (Float128Shuffle) toShuffle(vspecies(), false); + public final FloatShuffle128 toShuffle() { + return (FloatShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Float128Mask test(Test op) { - return super.testTemplate(Float128Mask.class, op); // specialize + public final FloatMask128 test(Test op) { + return super.testTemplate(FloatMask128.class, op); // specialize } @Override @ForceInline - public final Float128Mask test(Test op, VectorMask m) { - return super.testTemplate(Float128Mask.class, op, (Float128Mask) m); // specialize + public final FloatMask128 test(Test op, VectorMask m) { + return super.testTemplate(FloatMask128.class, op, (FloatMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Float128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Float128Mask.class, op, v); // specialize + public final FloatMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(FloatMask128.class, op, v); // specialize } @Override @ForceInline - public final Float128Mask compare(Comparison op, float s) { - return super.compareTemplate(Float128Mask.class, op, s); // specialize + public final FloatMask128 compare(Comparison op, float s) { + return super.compareTemplate(FloatMask128.class, op, s); // specialize } @Override @ForceInline - public final Float128Mask compare(Comparison op, long s) { - return super.compareTemplate(Float128Mask.class, op, s); // specialize + public final FloatMask128 compare(Comparison op, long s) { + return super.compareTemplate(FloatMask128.class, op, s); // specialize } @Override @ForceInline - public final Float128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Float128Mask.class, op, v, (Float128Mask) m); + public final FloatMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(FloatMask128.class, op, v, (FloatMask128) m); } @Override @ForceInline - public Float128Vector blend(Vector v, VectorMask m) { - return (Float128Vector) - super.blendTemplate(Float128Mask.class, - (Float128Vector) v, - (Float128Mask) m); // specialize + public FloatVector128 blend(Vector v, VectorMask m) { + return (FloatVector128) + super.blendTemplate(FloatMask128.class, + (FloatVector128) v, + (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector slice(int origin, Vector v) { - return (Float128Vector) super.sliceTemplate(origin, v); // specialize + public FloatVector128 slice(int origin, Vector v) { + return (FloatVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Float128Vector slice(int origin) { - return (Float128Vector) super.sliceTemplate(origin); // specialize + public FloatVector128 slice(int origin) { + return (FloatVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Float128Vector unslice(int origin, Vector w, int part) { - return (Float128Vector) super.unsliceTemplate(origin, w, part); // specialize + public FloatVector128 unslice(int origin, Vector w, int part) { + return (FloatVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Float128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Float128Vector) - super.unsliceTemplate(Float128Mask.class, + public FloatVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (FloatVector128) + super.unsliceTemplate(FloatMask128.class, origin, w, part, - (Float128Mask) m); // specialize + (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector unslice(int origin) { - return (Float128Vector) super.unsliceTemplate(origin); // specialize + public FloatVector128 unslice(int origin) { + return (FloatVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Float128Vector rearrange(VectorShuffle s) { - return (Float128Vector) - super.rearrangeTemplate(Float128Shuffle.class, - (Float128Shuffle) s); // specialize + public FloatVector128 rearrange(VectorShuffle s) { + return (FloatVector128) + super.rearrangeTemplate(FloatShuffle128.class, + (FloatShuffle128) s); // specialize } @Override @ForceInline - public Float128Vector rearrange(VectorShuffle shuffle, + public FloatVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Float128Vector) - super.rearrangeTemplate(Float128Shuffle.class, - Float128Mask.class, - (Float128Shuffle) shuffle, - (Float128Mask) m); // specialize + return (FloatVector128) + super.rearrangeTemplate(FloatShuffle128.class, + FloatMask128.class, + (FloatShuffle128) shuffle, + (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector rearrange(VectorShuffle s, + public FloatVector128 rearrange(VectorShuffle s, Vector v) { - return (Float128Vector) - super.rearrangeTemplate(Float128Shuffle.class, - (Float128Shuffle) s, - (Float128Vector) v); // specialize + return (FloatVector128) + super.rearrangeTemplate(FloatShuffle128.class, + (FloatShuffle128) s, + (FloatVector128) v); // specialize } @Override @ForceInline - public Float128Vector compress(VectorMask m) { - return (Float128Vector) - super.compressTemplate(Float128Mask.class, - (Float128Mask) m); // specialize + public FloatVector128 compress(VectorMask m) { + return (FloatVector128) + super.compressTemplate(FloatMask128.class, + (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector expand(VectorMask m) { - return (Float128Vector) - super.expandTemplate(Float128Mask.class, - (Float128Mask) m); // specialize + public FloatVector128 expand(VectorMask m) { + return (FloatVector128) + super.expandTemplate(FloatMask128.class, + (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector selectFrom(Vector v) { - return (Float128Vector) - super.selectFromTemplate((Float128Vector) v); // specialize + public FloatVector128 selectFrom(Vector v) { + return (FloatVector128) + super.selectFromTemplate((FloatVector128) v); // specialize } @Override @ForceInline - public Float128Vector selectFrom(Vector v, + public FloatVector128 selectFrom(Vector v, VectorMask m) { - return (Float128Vector) - super.selectFromTemplate((Float128Vector) v, - Float128Mask.class, (Float128Mask) m); // specialize + return (FloatVector128) + super.selectFromTemplate((FloatVector128) v, + FloatMask128.class, (FloatMask128) m); // specialize } @Override @ForceInline - public Float128Vector selectFrom(Vector v1, + public FloatVector128 selectFrom(Vector v1, Vector v2) { - return (Float128Vector) - super.selectFromTemplate((Float128Vector) v1, (Float128Vector) v2); // specialize + return (FloatVector128) + super.selectFromTemplate((FloatVector128) v1, (FloatVector128) v2); // specialize } @ForceInline @@ -535,7 +540,7 @@ final class Float128Vector extends FloatVector { @ForceInline @Override - public Float128Vector withLane(int i, float e) { + public FloatVector128 withLane(int i, float e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -546,7 +551,7 @@ final class Float128Vector extends FloatVector { } @ForceInline - public Float128Vector withLaneHelper(int i, float e) { + public FloatVector128 withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), @@ -558,20 +563,21 @@ final class Float128Vector extends FloatVector { } // Mask - - static final class Float128Mask extends AbstractMask { + @ValueBased + static final class FloatMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM - Float128Mask(boolean[] bits) { + static final Class CTYPE = float.class; // used by the JVM + + FloatMask128(boolean[] bits) { this(bits, 0); } - Float128Mask(boolean[] bits, int offset) { + FloatMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Float128Mask(boolean val) { + FloatMask128(boolean val) { super(prepare(val)); } @@ -604,31 +610,31 @@ final class Float128Vector extends FloatVector { } @Override - Float128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Float128Mask(res); + return new FloatMask128(res); } @Override - Float128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Float128Mask)m).getBits(); + boolean[] mbits = ((FloatMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Float128Mask(res); + return new FloatMask128(res); } @ForceInline @Override public final - Float128Vector toVector() { - return (Float128Vector) super.toVectorTemplate(); // specialize + FloatVector128 toVector() { + return (FloatVector128) super.toVectorTemplate(); // specialize } /** @@ -661,25 +667,25 @@ final class Float128Vector extends FloatVector { @Override @ForceInline /*package-private*/ - Float128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Float128Mask) VectorSupport.indexPartiallyInUpperRange( - Float128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Float128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + FloatMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMask128) VectorSupport.indexPartiallyInUpperRange( + FloatMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (FloatMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Float128Mask not() { + public FloatMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Float128Mask compress() { - return (Float128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float128Vector.class, Float128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public FloatMask128 compress() { + return (FloatMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + FloatVector128.class, FloatMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -688,30 +694,30 @@ final class Float128Vector extends FloatVector { @Override @ForceInline - public Float128Mask and(VectorMask mask) { + public FloatMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask128 m = (FloatMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Float128Mask or(VectorMask mask) { + public FloatMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask128 m = (FloatMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Float128Mask xor(VectorMask mask) { + public FloatMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask128 m = (FloatMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -721,21 +727,21 @@ final class Float128Vector extends FloatVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -745,7 +751,7 @@ final class Float128Vector extends FloatVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -755,7 +761,7 @@ final class Float128Vector extends FloatVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(FloatMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -764,48 +770,49 @@ final class Float128Vector extends FloatVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float128Mask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((FloatMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((FloatMask128)m).getBits())); } @ForceInline /*package-private*/ - static Float128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static FloatMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(FloatMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Float128Mask TRUE_MASK = new Float128Mask(true); - private static final Float128Mask FALSE_MASK = new Float128Mask(false); + private static final FloatMask128 TRUE_MASK = new FloatMask128(true); + private static final FloatMask128 FALSE_MASK = new FloatMask128(false); } // Shuffle - - static final class Float128Shuffle extends AbstractShuffle { + @ValueBased + static final class FloatShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Float128Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + FloatShuffle128(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Float128Shuffle(int[] indices, int i) { + FloatShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Float128Shuffle(IntUnaryOperator fn) { + FloatShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -825,23 +832,23 @@ final class Float128Vector extends FloatVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Float128Shuffle IOTA = new Float128Shuffle(IDENTITY); + static final FloatShuffle128 IOTA = new FloatShuffle128(IDENTITY); @Override @ForceInline - public Float128Vector toVector() { - return (Float128Vector) toBitsVector().castShape(vspecies(), 0); + public FloatVector128 toVector() { + return (FloatVector128) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Int128Vector toBitsVector() { - return (Int128Vector) super.toBitsVectorTemplate(); + IntVector128 toBitsVector() { + return (IntVector128) super.toBitsVectorTemplate(); } @Override - Int128Vector toBitsVector0() { - return ((Int128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector128 toBitsVector0() { + return ((IntVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -864,30 +871,30 @@ final class Float128Vector extends FloatVector { @Override @ForceInline - public final Float128Mask laneIsValid() { - return (Float128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final FloatMask128 laneIsValid() { + return (FloatMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Float128Shuffle rearrange(VectorShuffle shuffle) { - Float128Shuffle concreteShuffle = (Float128Shuffle) shuffle; - return (Float128Shuffle) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_128)) - .toShuffle(vspecies(), false); + public final FloatShuffle128 rearrange(VectorShuffle shuffle) { + FloatShuffle128 concreteShuffle = (FloatShuffle128) shuffle; + return (FloatShuffle128) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_128)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Float128Shuffle wrapIndexes() { - Int128Vector v = toBitsVector(); + public final FloatShuffle128 wrapIndexes() { + IntVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Float128Shuffle) v.toShuffle(vspecies(), false); + return (FloatShuffle128) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -938,14 +945,14 @@ final class Float128Vector extends FloatVector { @Override final FloatVector fromArray0(float[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Float128Mask.class, a, offset, (Float128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(FloatMask128.class, a, offset, (FloatMask128) m, offsetInRange); // specialize } @ForceInline @Override final FloatVector fromArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Float128Mask.class, a, offset, indexMap, mapOffset, (Float128Mask) m); + return super.fromArray0Template(FloatMask128.class, a, offset, indexMap, mapOffset, (FloatMask128) m); } @@ -961,7 +968,7 @@ final class Float128Vector extends FloatVector { @Override final FloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Float128Mask.class, ms, offset, (Float128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(FloatMask128.class, ms, offset, (FloatMask128) m, offsetInRange); // specialize } @ForceInline @@ -975,14 +982,14 @@ final class Float128Vector extends FloatVector { @Override final void intoArray0(float[] a, int offset, VectorMask m) { - super.intoArray0Template(Float128Mask.class, a, offset, (Float128Mask) m); + super.intoArray0Template(FloatMask128.class, a, offset, (FloatMask128) m); } @ForceInline @Override final void intoArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Float128Mask.class, a, offset, indexMap, mapOffset, (Float128Mask) m); + super.intoArray0Template(FloatMask128.class, a, offset, indexMap, mapOffset, (FloatMask128) m); } @@ -990,7 +997,7 @@ final class Float128Vector extends FloatVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Float128Mask.class, ms, offset, (Float128Mask) m); + super.intoMemorySegment0Template(FloatMask128.class, ms, offset, (FloatMask128) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector256.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector256.java index f41194500f9..ecbd80046f4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector256.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Float256Vector extends FloatVector { +@ValueBased +final class FloatVector256 extends FloatVector { static final FloatSpecies VSPECIES = (FloatSpecies) FloatVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Float256Vector.class; + static final Class VCLASS = FloatVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + static final Class ETYPE = float.class; // used by the JVM - Float256Vector(float[] v) { + FloatVector256(float[] v) { super(v); } - // For compatibility as Float256Vector::new, + // For compatibility as FloatVector256::new, // stored into species.vectorFactory. - Float256Vector(Object v) { + FloatVector256(Object v) { this((float[]) v); } - static final Float256Vector ZERO = new Float256Vector(new float[VLENGTH]); - static final Float256Vector IOTA = new Float256Vector(VSPECIES.iotaArray()); + static final FloatVector256 ZERO = new FloatVector256(new float[VLENGTH]); + static final FloatVector256 IOTA = new FloatVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Float256Vector extends FloatVector { @Override public final Class elementType() { return float.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Float.SIZE; } @@ -130,51 +135,51 @@ final class Float256Vector extends FloatVector { @Override @ForceInline - public final Float256Vector broadcast(float e) { - return (Float256Vector) super.broadcastTemplate(e); // specialize + public final FloatVector256 broadcast(float e) { + return (FloatVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Float256Vector broadcast(long e) { - return (Float256Vector) super.broadcastTemplate(e); // specialize + public final FloatVector256 broadcast(long e) { + return (FloatVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Float256Mask maskFromArray(boolean[] bits) { - return new Float256Mask(bits); + FloatMask256 maskFromArray(boolean[] bits) { + return new FloatMask256(bits); } @Override @ForceInline - Float256Shuffle iotaShuffle() { return Float256Shuffle.IOTA; } + FloatShuffle256 iotaShuffle() { return FloatShuffle256.IOTA; } @Override @ForceInline - Float256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Float256Shuffle) iotaShuffleTemplate(start, step, wrap); + FloatShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (FloatShuffle256) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Float256Shuffle shuffleFromArray(int[] indices, int i) { return new Float256Shuffle(indices, i); } + FloatShuffle256 shuffleFromArray(int[] indices, int i) { return new FloatShuffle256(indices, i); } @Override @ForceInline - Float256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Float256Shuffle(fn); } + FloatShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new FloatShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Float256Vector vectorFactory(float[] vec) { - return new Float256Vector(vec); + FloatVector256 vectorFactory(float[] vec) { + return new FloatVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Float256Vector extends FloatVector { @ForceInline final @Override - Float256Vector uOp(FUnOp f) { - return (Float256Vector) super.uOpTemplate(f); // specialize + FloatVector256 uOp(FUnOp f) { + return (FloatVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Float256Vector uOp(VectorMask m, FUnOp f) { - return (Float256Vector) - super.uOpTemplate((Float256Mask)m, f); // specialize + FloatVector256 uOp(VectorMask m, FUnOp f) { + return (FloatVector256) + super.uOpTemplate((FloatMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Float256Vector bOp(Vector v, FBinOp f) { - return (Float256Vector) super.bOpTemplate((Float256Vector)v, f); // specialize + FloatVector256 bOp(Vector v, FBinOp f) { + return (FloatVector256) super.bOpTemplate((FloatVector256)v, f); // specialize } @ForceInline final @Override - Float256Vector bOp(Vector v, + FloatVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Float256Vector) - super.bOpTemplate((Float256Vector)v, (Float256Mask)m, + return (FloatVector256) + super.bOpTemplate((FloatVector256)v, (FloatMask256)m, f); // specialize } @@ -219,19 +224,19 @@ final class Float256Vector extends FloatVector { @ForceInline final @Override - Float256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Float256Vector) - super.tOpTemplate((Float256Vector)v1, (Float256Vector)v2, + FloatVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (FloatVector256) + super.tOpTemplate((FloatVector256)v1, (FloatVector256)v2, f); // specialize } @ForceInline final @Override - Float256Vector tOp(Vector v1, Vector v2, + FloatVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Float256Vector) - super.tOpTemplate((Float256Vector)v1, (Float256Vector)v2, - (Float256Mask)m, f); // specialize + return (FloatVector256) + super.tOpTemplate((FloatVector256)v1, (FloatVector256)v2, + (FloatMask256)m, f); // specialize } @ForceInline @@ -269,26 +274,26 @@ final class Float256Vector extends FloatVector { @Override @ForceInline - public Float256Vector lanewise(Unary op) { - return (Float256Vector) super.lanewiseTemplate(op); // specialize + public FloatVector256 lanewise(Unary op) { + return (FloatVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Float256Vector lanewise(Unary op, VectorMask m) { - return (Float256Vector) super.lanewiseTemplate(op, Float256Mask.class, (Float256Mask) m); // specialize + public FloatVector256 lanewise(Unary op, VectorMask m) { + return (FloatVector256) super.lanewiseTemplate(op, FloatMask256.class, (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector lanewise(Binary op, Vector v) { - return (Float256Vector) super.lanewiseTemplate(op, v); // specialize + public FloatVector256 lanewise(Binary op, Vector v) { + return (FloatVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Float256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Float256Vector) super.lanewiseTemplate(op, Float256Mask.class, v, (Float256Mask) m); // specialize + public FloatVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (FloatVector256) super.lanewiseTemplate(op, FloatMask256.class, v, (FloatMask256) m); // specialize } @@ -296,24 +301,24 @@ final class Float256Vector extends FloatVector { @Override @ForceInline public final - Float256Vector + FloatVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Float256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (FloatVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Float256Vector + FloatVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Float256Vector) super.lanewiseTemplate(op, Float256Mask.class, v1, v2, (Float256Mask) m); // specialize + return (FloatVector256) super.lanewiseTemplate(op, FloatMask256.class, v1, v2, (FloatMask256) m); // specialize } @Override @ForceInline public final - Float256Vector addIndex(int scale) { - return (Float256Vector) super.addIndexTemplate(scale); // specialize + FloatVector256 addIndex(int scale) { + return (FloatVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +333,7 @@ final class Float256Vector extends FloatVector { @ForceInline public final float reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Float256Mask.class, (Float256Mask) m); // specialized + return super.reduceLanesTemplate(op, FloatMask256.class, (FloatMask256) m); // specialized } @Override @@ -341,7 +346,7 @@ final class Float256Vector extends FloatVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Float256Mask.class, (Float256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, FloatMask256.class, (FloatMask256) m); // specialized } @Override @@ -352,160 +357,160 @@ final class Float256Vector extends FloatVector { @Override @ForceInline - public final Float256Shuffle toShuffle() { - return (Float256Shuffle) toShuffle(vspecies(), false); + public final FloatShuffle256 toShuffle() { + return (FloatShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Float256Mask test(Test op) { - return super.testTemplate(Float256Mask.class, op); // specialize + public final FloatMask256 test(Test op) { + return super.testTemplate(FloatMask256.class, op); // specialize } @Override @ForceInline - public final Float256Mask test(Test op, VectorMask m) { - return super.testTemplate(Float256Mask.class, op, (Float256Mask) m); // specialize + public final FloatMask256 test(Test op, VectorMask m) { + return super.testTemplate(FloatMask256.class, op, (FloatMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Float256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Float256Mask.class, op, v); // specialize + public final FloatMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(FloatMask256.class, op, v); // specialize } @Override @ForceInline - public final Float256Mask compare(Comparison op, float s) { - return super.compareTemplate(Float256Mask.class, op, s); // specialize + public final FloatMask256 compare(Comparison op, float s) { + return super.compareTemplate(FloatMask256.class, op, s); // specialize } @Override @ForceInline - public final Float256Mask compare(Comparison op, long s) { - return super.compareTemplate(Float256Mask.class, op, s); // specialize + public final FloatMask256 compare(Comparison op, long s) { + return super.compareTemplate(FloatMask256.class, op, s); // specialize } @Override @ForceInline - public final Float256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Float256Mask.class, op, v, (Float256Mask) m); + public final FloatMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(FloatMask256.class, op, v, (FloatMask256) m); } @Override @ForceInline - public Float256Vector blend(Vector v, VectorMask m) { - return (Float256Vector) - super.blendTemplate(Float256Mask.class, - (Float256Vector) v, - (Float256Mask) m); // specialize + public FloatVector256 blend(Vector v, VectorMask m) { + return (FloatVector256) + super.blendTemplate(FloatMask256.class, + (FloatVector256) v, + (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector slice(int origin, Vector v) { - return (Float256Vector) super.sliceTemplate(origin, v); // specialize + public FloatVector256 slice(int origin, Vector v) { + return (FloatVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Float256Vector slice(int origin) { - return (Float256Vector) super.sliceTemplate(origin); // specialize + public FloatVector256 slice(int origin) { + return (FloatVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Float256Vector unslice(int origin, Vector w, int part) { - return (Float256Vector) super.unsliceTemplate(origin, w, part); // specialize + public FloatVector256 unslice(int origin, Vector w, int part) { + return (FloatVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Float256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Float256Vector) - super.unsliceTemplate(Float256Mask.class, + public FloatVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (FloatVector256) + super.unsliceTemplate(FloatMask256.class, origin, w, part, - (Float256Mask) m); // specialize + (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector unslice(int origin) { - return (Float256Vector) super.unsliceTemplate(origin); // specialize + public FloatVector256 unslice(int origin) { + return (FloatVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Float256Vector rearrange(VectorShuffle s) { - return (Float256Vector) - super.rearrangeTemplate(Float256Shuffle.class, - (Float256Shuffle) s); // specialize + public FloatVector256 rearrange(VectorShuffle s) { + return (FloatVector256) + super.rearrangeTemplate(FloatShuffle256.class, + (FloatShuffle256) s); // specialize } @Override @ForceInline - public Float256Vector rearrange(VectorShuffle shuffle, + public FloatVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Float256Vector) - super.rearrangeTemplate(Float256Shuffle.class, - Float256Mask.class, - (Float256Shuffle) shuffle, - (Float256Mask) m); // specialize + return (FloatVector256) + super.rearrangeTemplate(FloatShuffle256.class, + FloatMask256.class, + (FloatShuffle256) shuffle, + (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector rearrange(VectorShuffle s, + public FloatVector256 rearrange(VectorShuffle s, Vector v) { - return (Float256Vector) - super.rearrangeTemplate(Float256Shuffle.class, - (Float256Shuffle) s, - (Float256Vector) v); // specialize + return (FloatVector256) + super.rearrangeTemplate(FloatShuffle256.class, + (FloatShuffle256) s, + (FloatVector256) v); // specialize } @Override @ForceInline - public Float256Vector compress(VectorMask m) { - return (Float256Vector) - super.compressTemplate(Float256Mask.class, - (Float256Mask) m); // specialize + public FloatVector256 compress(VectorMask m) { + return (FloatVector256) + super.compressTemplate(FloatMask256.class, + (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector expand(VectorMask m) { - return (Float256Vector) - super.expandTemplate(Float256Mask.class, - (Float256Mask) m); // specialize + public FloatVector256 expand(VectorMask m) { + return (FloatVector256) + super.expandTemplate(FloatMask256.class, + (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector selectFrom(Vector v) { - return (Float256Vector) - super.selectFromTemplate((Float256Vector) v); // specialize + public FloatVector256 selectFrom(Vector v) { + return (FloatVector256) + super.selectFromTemplate((FloatVector256) v); // specialize } @Override @ForceInline - public Float256Vector selectFrom(Vector v, + public FloatVector256 selectFrom(Vector v, VectorMask m) { - return (Float256Vector) - super.selectFromTemplate((Float256Vector) v, - Float256Mask.class, (Float256Mask) m); // specialize + return (FloatVector256) + super.selectFromTemplate((FloatVector256) v, + FloatMask256.class, (FloatMask256) m); // specialize } @Override @ForceInline - public Float256Vector selectFrom(Vector v1, + public FloatVector256 selectFrom(Vector v1, Vector v2) { - return (Float256Vector) - super.selectFromTemplate((Float256Vector) v1, (Float256Vector) v2); // specialize + return (FloatVector256) + super.selectFromTemplate((FloatVector256) v1, (FloatVector256) v2); // specialize } @ForceInline @@ -539,7 +544,7 @@ final class Float256Vector extends FloatVector { @ForceInline @Override - public Float256Vector withLane(int i, float e) { + public FloatVector256 withLane(int i, float e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -554,7 +559,7 @@ final class Float256Vector extends FloatVector { } @ForceInline - public Float256Vector withLaneHelper(int i, float e) { + public FloatVector256 withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), @@ -566,20 +571,21 @@ final class Float256Vector extends FloatVector { } // Mask - - static final class Float256Mask extends AbstractMask { + @ValueBased + static final class FloatMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM - Float256Mask(boolean[] bits) { + static final Class CTYPE = float.class; // used by the JVM + + FloatMask256(boolean[] bits) { this(bits, 0); } - Float256Mask(boolean[] bits, int offset) { + FloatMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Float256Mask(boolean val) { + FloatMask256(boolean val) { super(prepare(val)); } @@ -612,31 +618,31 @@ final class Float256Vector extends FloatVector { } @Override - Float256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Float256Mask(res); + return new FloatMask256(res); } @Override - Float256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Float256Mask)m).getBits(); + boolean[] mbits = ((FloatMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Float256Mask(res); + return new FloatMask256(res); } @ForceInline @Override public final - Float256Vector toVector() { - return (Float256Vector) super.toVectorTemplate(); // specialize + FloatVector256 toVector() { + return (FloatVector256) super.toVectorTemplate(); // specialize } /** @@ -669,25 +675,25 @@ final class Float256Vector extends FloatVector { @Override @ForceInline /*package-private*/ - Float256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Float256Mask) VectorSupport.indexPartiallyInUpperRange( - Float256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Float256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + FloatMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMask256) VectorSupport.indexPartiallyInUpperRange( + FloatMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (FloatMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Float256Mask not() { + public FloatMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Float256Mask compress() { - return (Float256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float256Vector.class, Float256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public FloatMask256 compress() { + return (FloatMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + FloatVector256.class, FloatMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -696,30 +702,30 @@ final class Float256Vector extends FloatVector { @Override @ForceInline - public Float256Mask and(VectorMask mask) { + public FloatMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask256 m = (FloatMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Float256Mask or(VectorMask mask) { + public FloatMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask256 m = (FloatMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Float256Mask xor(VectorMask mask) { + public FloatMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask256 m = (FloatMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -729,21 +735,21 @@ final class Float256Vector extends FloatVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -753,7 +759,7 @@ final class Float256Vector extends FloatVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -763,7 +769,7 @@ final class Float256Vector extends FloatVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(FloatMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -772,48 +778,49 @@ final class Float256Vector extends FloatVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float256Mask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((FloatMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((FloatMask256)m).getBits())); } @ForceInline /*package-private*/ - static Float256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static FloatMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(FloatMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Float256Mask TRUE_MASK = new Float256Mask(true); - private static final Float256Mask FALSE_MASK = new Float256Mask(false); + private static final FloatMask256 TRUE_MASK = new FloatMask256(true); + private static final FloatMask256 FALSE_MASK = new FloatMask256(false); } // Shuffle - - static final class Float256Shuffle extends AbstractShuffle { + @ValueBased + static final class FloatShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Float256Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + FloatShuffle256(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Float256Shuffle(int[] indices, int i) { + FloatShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Float256Shuffle(IntUnaryOperator fn) { + FloatShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -833,23 +840,23 @@ final class Float256Vector extends FloatVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Float256Shuffle IOTA = new Float256Shuffle(IDENTITY); + static final FloatShuffle256 IOTA = new FloatShuffle256(IDENTITY); @Override @ForceInline - public Float256Vector toVector() { - return (Float256Vector) toBitsVector().castShape(vspecies(), 0); + public FloatVector256 toVector() { + return (FloatVector256) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Int256Vector toBitsVector() { - return (Int256Vector) super.toBitsVectorTemplate(); + IntVector256 toBitsVector() { + return (IntVector256) super.toBitsVectorTemplate(); } @Override - Int256Vector toBitsVector0() { - return ((Int256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector256 toBitsVector0() { + return ((IntVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -872,30 +879,30 @@ final class Float256Vector extends FloatVector { @Override @ForceInline - public final Float256Mask laneIsValid() { - return (Float256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final FloatMask256 laneIsValid() { + return (FloatMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Float256Shuffle rearrange(VectorShuffle shuffle) { - Float256Shuffle concreteShuffle = (Float256Shuffle) shuffle; - return (Float256Shuffle) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_256)) - .toShuffle(vspecies(), false); + public final FloatShuffle256 rearrange(VectorShuffle shuffle) { + FloatShuffle256 concreteShuffle = (FloatShuffle256) shuffle; + return (FloatShuffle256) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_256)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Float256Shuffle wrapIndexes() { - Int256Vector v = toBitsVector(); + public final FloatShuffle256 wrapIndexes() { + IntVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Float256Shuffle) v.toShuffle(vspecies(), false); + return (FloatShuffle256) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -946,14 +953,14 @@ final class Float256Vector extends FloatVector { @Override final FloatVector fromArray0(float[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Float256Mask.class, a, offset, (Float256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(FloatMask256.class, a, offset, (FloatMask256) m, offsetInRange); // specialize } @ForceInline @Override final FloatVector fromArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Float256Mask.class, a, offset, indexMap, mapOffset, (Float256Mask) m); + return super.fromArray0Template(FloatMask256.class, a, offset, indexMap, mapOffset, (FloatMask256) m); } @@ -969,7 +976,7 @@ final class Float256Vector extends FloatVector { @Override final FloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Float256Mask.class, ms, offset, (Float256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(FloatMask256.class, ms, offset, (FloatMask256) m, offsetInRange); // specialize } @ForceInline @@ -983,14 +990,14 @@ final class Float256Vector extends FloatVector { @Override final void intoArray0(float[] a, int offset, VectorMask m) { - super.intoArray0Template(Float256Mask.class, a, offset, (Float256Mask) m); + super.intoArray0Template(FloatMask256.class, a, offset, (FloatMask256) m); } @ForceInline @Override final void intoArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Float256Mask.class, a, offset, indexMap, mapOffset, (Float256Mask) m); + super.intoArray0Template(FloatMask256.class, a, offset, indexMap, mapOffset, (FloatMask256) m); } @@ -998,7 +1005,7 @@ final class Float256Vector extends FloatVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Float256Mask.class, ms, offset, (Float256Mask) m); + super.intoMemorySegment0Template(FloatMask256.class, ms, offset, (FloatMask256) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector512.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector512.java index c2fced0fdae..b5a934dd90c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector512.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Float512Vector extends FloatVector { +@ValueBased +final class FloatVector512 extends FloatVector { static final FloatSpecies VSPECIES = (FloatSpecies) FloatVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Float512Vector.class; + static final Class VCLASS = FloatVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + static final Class ETYPE = float.class; // used by the JVM - Float512Vector(float[] v) { + FloatVector512(float[] v) { super(v); } - // For compatibility as Float512Vector::new, + // For compatibility as FloatVector512::new, // stored into species.vectorFactory. - Float512Vector(Object v) { + FloatVector512(Object v) { this((float[]) v); } - static final Float512Vector ZERO = new Float512Vector(new float[VLENGTH]); - static final Float512Vector IOTA = new Float512Vector(VSPECIES.iotaArray()); + static final FloatVector512 ZERO = new FloatVector512(new float[VLENGTH]); + static final FloatVector512 IOTA = new FloatVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Float512Vector extends FloatVector { @Override public final Class elementType() { return float.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Float.SIZE; } @@ -130,51 +135,51 @@ final class Float512Vector extends FloatVector { @Override @ForceInline - public final Float512Vector broadcast(float e) { - return (Float512Vector) super.broadcastTemplate(e); // specialize + public final FloatVector512 broadcast(float e) { + return (FloatVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Float512Vector broadcast(long e) { - return (Float512Vector) super.broadcastTemplate(e); // specialize + public final FloatVector512 broadcast(long e) { + return (FloatVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Float512Mask maskFromArray(boolean[] bits) { - return new Float512Mask(bits); + FloatMask512 maskFromArray(boolean[] bits) { + return new FloatMask512(bits); } @Override @ForceInline - Float512Shuffle iotaShuffle() { return Float512Shuffle.IOTA; } + FloatShuffle512 iotaShuffle() { return FloatShuffle512.IOTA; } @Override @ForceInline - Float512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Float512Shuffle) iotaShuffleTemplate(start, step, wrap); + FloatShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (FloatShuffle512) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Float512Shuffle shuffleFromArray(int[] indices, int i) { return new Float512Shuffle(indices, i); } + FloatShuffle512 shuffleFromArray(int[] indices, int i) { return new FloatShuffle512(indices, i); } @Override @ForceInline - Float512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Float512Shuffle(fn); } + FloatShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new FloatShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Float512Vector vectorFactory(float[] vec) { - return new Float512Vector(vec); + FloatVector512 vectorFactory(float[] vec) { + return new FloatVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Float512Vector extends FloatVector { @ForceInline final @Override - Float512Vector uOp(FUnOp f) { - return (Float512Vector) super.uOpTemplate(f); // specialize + FloatVector512 uOp(FUnOp f) { + return (FloatVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Float512Vector uOp(VectorMask m, FUnOp f) { - return (Float512Vector) - super.uOpTemplate((Float512Mask)m, f); // specialize + FloatVector512 uOp(VectorMask m, FUnOp f) { + return (FloatVector512) + super.uOpTemplate((FloatMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Float512Vector bOp(Vector v, FBinOp f) { - return (Float512Vector) super.bOpTemplate((Float512Vector)v, f); // specialize + FloatVector512 bOp(Vector v, FBinOp f) { + return (FloatVector512) super.bOpTemplate((FloatVector512)v, f); // specialize } @ForceInline final @Override - Float512Vector bOp(Vector v, + FloatVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Float512Vector) - super.bOpTemplate((Float512Vector)v, (Float512Mask)m, + return (FloatVector512) + super.bOpTemplate((FloatVector512)v, (FloatMask512)m, f); // specialize } @@ -219,19 +224,19 @@ final class Float512Vector extends FloatVector { @ForceInline final @Override - Float512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Float512Vector) - super.tOpTemplate((Float512Vector)v1, (Float512Vector)v2, + FloatVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (FloatVector512) + super.tOpTemplate((FloatVector512)v1, (FloatVector512)v2, f); // specialize } @ForceInline final @Override - Float512Vector tOp(Vector v1, Vector v2, + FloatVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Float512Vector) - super.tOpTemplate((Float512Vector)v1, (Float512Vector)v2, - (Float512Mask)m, f); // specialize + return (FloatVector512) + super.tOpTemplate((FloatVector512)v1, (FloatVector512)v2, + (FloatMask512)m, f); // specialize } @ForceInline @@ -269,26 +274,26 @@ final class Float512Vector extends FloatVector { @Override @ForceInline - public Float512Vector lanewise(Unary op) { - return (Float512Vector) super.lanewiseTemplate(op); // specialize + public FloatVector512 lanewise(Unary op) { + return (FloatVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Float512Vector lanewise(Unary op, VectorMask m) { - return (Float512Vector) super.lanewiseTemplate(op, Float512Mask.class, (Float512Mask) m); // specialize + public FloatVector512 lanewise(Unary op, VectorMask m) { + return (FloatVector512) super.lanewiseTemplate(op, FloatMask512.class, (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector lanewise(Binary op, Vector v) { - return (Float512Vector) super.lanewiseTemplate(op, v); // specialize + public FloatVector512 lanewise(Binary op, Vector v) { + return (FloatVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Float512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Float512Vector) super.lanewiseTemplate(op, Float512Mask.class, v, (Float512Mask) m); // specialize + public FloatVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (FloatVector512) super.lanewiseTemplate(op, FloatMask512.class, v, (FloatMask512) m); // specialize } @@ -296,24 +301,24 @@ final class Float512Vector extends FloatVector { @Override @ForceInline public final - Float512Vector + FloatVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Float512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (FloatVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Float512Vector + FloatVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Float512Vector) super.lanewiseTemplate(op, Float512Mask.class, v1, v2, (Float512Mask) m); // specialize + return (FloatVector512) super.lanewiseTemplate(op, FloatMask512.class, v1, v2, (FloatMask512) m); // specialize } @Override @ForceInline public final - Float512Vector addIndex(int scale) { - return (Float512Vector) super.addIndexTemplate(scale); // specialize + FloatVector512 addIndex(int scale) { + return (FloatVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +333,7 @@ final class Float512Vector extends FloatVector { @ForceInline public final float reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Float512Mask.class, (Float512Mask) m); // specialized + return super.reduceLanesTemplate(op, FloatMask512.class, (FloatMask512) m); // specialized } @Override @@ -341,7 +346,7 @@ final class Float512Vector extends FloatVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Float512Mask.class, (Float512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, FloatMask512.class, (FloatMask512) m); // specialized } @Override @@ -352,160 +357,160 @@ final class Float512Vector extends FloatVector { @Override @ForceInline - public final Float512Shuffle toShuffle() { - return (Float512Shuffle) toShuffle(vspecies(), false); + public final FloatShuffle512 toShuffle() { + return (FloatShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Float512Mask test(Test op) { - return super.testTemplate(Float512Mask.class, op); // specialize + public final FloatMask512 test(Test op) { + return super.testTemplate(FloatMask512.class, op); // specialize } @Override @ForceInline - public final Float512Mask test(Test op, VectorMask m) { - return super.testTemplate(Float512Mask.class, op, (Float512Mask) m); // specialize + public final FloatMask512 test(Test op, VectorMask m) { + return super.testTemplate(FloatMask512.class, op, (FloatMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Float512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Float512Mask.class, op, v); // specialize + public final FloatMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(FloatMask512.class, op, v); // specialize } @Override @ForceInline - public final Float512Mask compare(Comparison op, float s) { - return super.compareTemplate(Float512Mask.class, op, s); // specialize + public final FloatMask512 compare(Comparison op, float s) { + return super.compareTemplate(FloatMask512.class, op, s); // specialize } @Override @ForceInline - public final Float512Mask compare(Comparison op, long s) { - return super.compareTemplate(Float512Mask.class, op, s); // specialize + public final FloatMask512 compare(Comparison op, long s) { + return super.compareTemplate(FloatMask512.class, op, s); // specialize } @Override @ForceInline - public final Float512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Float512Mask.class, op, v, (Float512Mask) m); + public final FloatMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(FloatMask512.class, op, v, (FloatMask512) m); } @Override @ForceInline - public Float512Vector blend(Vector v, VectorMask m) { - return (Float512Vector) - super.blendTemplate(Float512Mask.class, - (Float512Vector) v, - (Float512Mask) m); // specialize + public FloatVector512 blend(Vector v, VectorMask m) { + return (FloatVector512) + super.blendTemplate(FloatMask512.class, + (FloatVector512) v, + (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector slice(int origin, Vector v) { - return (Float512Vector) super.sliceTemplate(origin, v); // specialize + public FloatVector512 slice(int origin, Vector v) { + return (FloatVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Float512Vector slice(int origin) { - return (Float512Vector) super.sliceTemplate(origin); // specialize + public FloatVector512 slice(int origin) { + return (FloatVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Float512Vector unslice(int origin, Vector w, int part) { - return (Float512Vector) super.unsliceTemplate(origin, w, part); // specialize + public FloatVector512 unslice(int origin, Vector w, int part) { + return (FloatVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Float512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Float512Vector) - super.unsliceTemplate(Float512Mask.class, + public FloatVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (FloatVector512) + super.unsliceTemplate(FloatMask512.class, origin, w, part, - (Float512Mask) m); // specialize + (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector unslice(int origin) { - return (Float512Vector) super.unsliceTemplate(origin); // specialize + public FloatVector512 unslice(int origin) { + return (FloatVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Float512Vector rearrange(VectorShuffle s) { - return (Float512Vector) - super.rearrangeTemplate(Float512Shuffle.class, - (Float512Shuffle) s); // specialize + public FloatVector512 rearrange(VectorShuffle s) { + return (FloatVector512) + super.rearrangeTemplate(FloatShuffle512.class, + (FloatShuffle512) s); // specialize } @Override @ForceInline - public Float512Vector rearrange(VectorShuffle shuffle, + public FloatVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Float512Vector) - super.rearrangeTemplate(Float512Shuffle.class, - Float512Mask.class, - (Float512Shuffle) shuffle, - (Float512Mask) m); // specialize + return (FloatVector512) + super.rearrangeTemplate(FloatShuffle512.class, + FloatMask512.class, + (FloatShuffle512) shuffle, + (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector rearrange(VectorShuffle s, + public FloatVector512 rearrange(VectorShuffle s, Vector v) { - return (Float512Vector) - super.rearrangeTemplate(Float512Shuffle.class, - (Float512Shuffle) s, - (Float512Vector) v); // specialize + return (FloatVector512) + super.rearrangeTemplate(FloatShuffle512.class, + (FloatShuffle512) s, + (FloatVector512) v); // specialize } @Override @ForceInline - public Float512Vector compress(VectorMask m) { - return (Float512Vector) - super.compressTemplate(Float512Mask.class, - (Float512Mask) m); // specialize + public FloatVector512 compress(VectorMask m) { + return (FloatVector512) + super.compressTemplate(FloatMask512.class, + (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector expand(VectorMask m) { - return (Float512Vector) - super.expandTemplate(Float512Mask.class, - (Float512Mask) m); // specialize + public FloatVector512 expand(VectorMask m) { + return (FloatVector512) + super.expandTemplate(FloatMask512.class, + (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector selectFrom(Vector v) { - return (Float512Vector) - super.selectFromTemplate((Float512Vector) v); // specialize + public FloatVector512 selectFrom(Vector v) { + return (FloatVector512) + super.selectFromTemplate((FloatVector512) v); // specialize } @Override @ForceInline - public Float512Vector selectFrom(Vector v, + public FloatVector512 selectFrom(Vector v, VectorMask m) { - return (Float512Vector) - super.selectFromTemplate((Float512Vector) v, - Float512Mask.class, (Float512Mask) m); // specialize + return (FloatVector512) + super.selectFromTemplate((FloatVector512) v, + FloatMask512.class, (FloatMask512) m); // specialize } @Override @ForceInline - public Float512Vector selectFrom(Vector v1, + public FloatVector512 selectFrom(Vector v1, Vector v2) { - return (Float512Vector) - super.selectFromTemplate((Float512Vector) v1, (Float512Vector) v2); // specialize + return (FloatVector512) + super.selectFromTemplate((FloatVector512) v1, (FloatVector512) v2); // specialize } @ForceInline @@ -547,7 +552,7 @@ final class Float512Vector extends FloatVector { @ForceInline @Override - public Float512Vector withLane(int i, float e) { + public FloatVector512 withLane(int i, float e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -570,7 +575,7 @@ final class Float512Vector extends FloatVector { } @ForceInline - public Float512Vector withLaneHelper(int i, float e) { + public FloatVector512 withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), @@ -582,20 +587,21 @@ final class Float512Vector extends FloatVector { } // Mask - - static final class Float512Mask extends AbstractMask { + @ValueBased + static final class FloatMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM - Float512Mask(boolean[] bits) { + static final Class CTYPE = float.class; // used by the JVM + + FloatMask512(boolean[] bits) { this(bits, 0); } - Float512Mask(boolean[] bits, int offset) { + FloatMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Float512Mask(boolean val) { + FloatMask512(boolean val) { super(prepare(val)); } @@ -628,31 +634,31 @@ final class Float512Vector extends FloatVector { } @Override - Float512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Float512Mask(res); + return new FloatMask512(res); } @Override - Float512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Float512Mask)m).getBits(); + boolean[] mbits = ((FloatMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Float512Mask(res); + return new FloatMask512(res); } @ForceInline @Override public final - Float512Vector toVector() { - return (Float512Vector) super.toVectorTemplate(); // specialize + FloatVector512 toVector() { + return (FloatVector512) super.toVectorTemplate(); // specialize } /** @@ -685,25 +691,25 @@ final class Float512Vector extends FloatVector { @Override @ForceInline /*package-private*/ - Float512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Float512Mask) VectorSupport.indexPartiallyInUpperRange( - Float512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Float512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + FloatMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMask512) VectorSupport.indexPartiallyInUpperRange( + FloatMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (FloatMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Float512Mask not() { + public FloatMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Float512Mask compress() { - return (Float512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float512Vector.class, Float512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public FloatMask512 compress() { + return (FloatMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + FloatVector512.class, FloatMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -712,30 +718,30 @@ final class Float512Vector extends FloatVector { @Override @ForceInline - public Float512Mask and(VectorMask mask) { + public FloatMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask512 m = (FloatMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Float512Mask or(VectorMask mask) { + public FloatMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask512 m = (FloatMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Float512Mask xor(VectorMask mask) { + public FloatMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask512 m = (FloatMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -745,21 +751,21 @@ final class Float512Vector extends FloatVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -769,7 +775,7 @@ final class Float512Vector extends FloatVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -779,7 +785,7 @@ final class Float512Vector extends FloatVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(FloatMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -788,48 +794,49 @@ final class Float512Vector extends FloatVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float512Mask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((FloatMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((FloatMask512)m).getBits())); } @ForceInline /*package-private*/ - static Float512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static FloatMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(FloatMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Float512Mask TRUE_MASK = new Float512Mask(true); - private static final Float512Mask FALSE_MASK = new Float512Mask(false); + private static final FloatMask512 TRUE_MASK = new FloatMask512(true); + private static final FloatMask512 FALSE_MASK = new FloatMask512(false); } // Shuffle - - static final class Float512Shuffle extends AbstractShuffle { + @ValueBased + static final class FloatShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Float512Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + FloatShuffle512(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Float512Shuffle(int[] indices, int i) { + FloatShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Float512Shuffle(IntUnaryOperator fn) { + FloatShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -849,23 +856,23 @@ final class Float512Vector extends FloatVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Float512Shuffle IOTA = new Float512Shuffle(IDENTITY); + static final FloatShuffle512 IOTA = new FloatShuffle512(IDENTITY); @Override @ForceInline - public Float512Vector toVector() { - return (Float512Vector) toBitsVector().castShape(vspecies(), 0); + public FloatVector512 toVector() { + return (FloatVector512) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Int512Vector toBitsVector() { - return (Int512Vector) super.toBitsVectorTemplate(); + IntVector512 toBitsVector() { + return (IntVector512) super.toBitsVectorTemplate(); } @Override - Int512Vector toBitsVector0() { - return ((Int512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector512 toBitsVector0() { + return ((IntVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -888,30 +895,30 @@ final class Float512Vector extends FloatVector { @Override @ForceInline - public final Float512Mask laneIsValid() { - return (Float512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final FloatMask512 laneIsValid() { + return (FloatMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Float512Shuffle rearrange(VectorShuffle shuffle) { - Float512Shuffle concreteShuffle = (Float512Shuffle) shuffle; - return (Float512Shuffle) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_512)) - .toShuffle(vspecies(), false); + public final FloatShuffle512 rearrange(VectorShuffle shuffle) { + FloatShuffle512 concreteShuffle = (FloatShuffle512) shuffle; + return (FloatShuffle512) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_512)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Float512Shuffle wrapIndexes() { - Int512Vector v = toBitsVector(); + public final FloatShuffle512 wrapIndexes() { + IntVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Float512Shuffle) v.toShuffle(vspecies(), false); + return (FloatShuffle512) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -962,14 +969,14 @@ final class Float512Vector extends FloatVector { @Override final FloatVector fromArray0(float[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Float512Mask.class, a, offset, (Float512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(FloatMask512.class, a, offset, (FloatMask512) m, offsetInRange); // specialize } @ForceInline @Override final FloatVector fromArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Float512Mask.class, a, offset, indexMap, mapOffset, (Float512Mask) m); + return super.fromArray0Template(FloatMask512.class, a, offset, indexMap, mapOffset, (FloatMask512) m); } @@ -985,7 +992,7 @@ final class Float512Vector extends FloatVector { @Override final FloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Float512Mask.class, ms, offset, (Float512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(FloatMask512.class, ms, offset, (FloatMask512) m, offsetInRange); // specialize } @ForceInline @@ -999,14 +1006,14 @@ final class Float512Vector extends FloatVector { @Override final void intoArray0(float[] a, int offset, VectorMask m) { - super.intoArray0Template(Float512Mask.class, a, offset, (Float512Mask) m); + super.intoArray0Template(FloatMask512.class, a, offset, (FloatMask512) m); } @ForceInline @Override final void intoArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Float512Mask.class, a, offset, indexMap, mapOffset, (Float512Mask) m); + super.intoArray0Template(FloatMask512.class, a, offset, indexMap, mapOffset, (FloatMask512) m); } @@ -1014,7 +1021,7 @@ final class Float512Vector extends FloatVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Float512Mask.class, ms, offset, (Float512Mask) m); + super.intoMemorySegment0Template(FloatMask512.class, ms, offset, (FloatMask512) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector64.java similarity index 62% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector64.java index 67676c828d6..4d3118739ea 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector64.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Float64Vector extends FloatVector { +@ValueBased +final class FloatVector64 extends FloatVector { static final FloatSpecies VSPECIES = (FloatSpecies) FloatVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Float64Vector.class; + static final Class VCLASS = FloatVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + static final Class ETYPE = float.class; // used by the JVM - Float64Vector(float[] v) { + FloatVector64(float[] v) { super(v); } - // For compatibility as Float64Vector::new, + // For compatibility as FloatVector64::new, // stored into species.vectorFactory. - Float64Vector(Object v) { + FloatVector64(Object v) { this((float[]) v); } - static final Float64Vector ZERO = new Float64Vector(new float[VLENGTH]); - static final Float64Vector IOTA = new Float64Vector(VSPECIES.iotaArray()); + static final FloatVector64 ZERO = new FloatVector64(new float[VLENGTH]); + static final FloatVector64 IOTA = new FloatVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Float64Vector extends FloatVector { @Override public final Class elementType() { return float.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Float.SIZE; } @@ -130,51 +135,51 @@ final class Float64Vector extends FloatVector { @Override @ForceInline - public final Float64Vector broadcast(float e) { - return (Float64Vector) super.broadcastTemplate(e); // specialize + public final FloatVector64 broadcast(float e) { + return (FloatVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Float64Vector broadcast(long e) { - return (Float64Vector) super.broadcastTemplate(e); // specialize + public final FloatVector64 broadcast(long e) { + return (FloatVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Float64Mask maskFromArray(boolean[] bits) { - return new Float64Mask(bits); + FloatMask64 maskFromArray(boolean[] bits) { + return new FloatMask64(bits); } @Override @ForceInline - Float64Shuffle iotaShuffle() { return Float64Shuffle.IOTA; } + FloatShuffle64 iotaShuffle() { return FloatShuffle64.IOTA; } @Override @ForceInline - Float64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Float64Shuffle) iotaShuffleTemplate(start, step, wrap); + FloatShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (FloatShuffle64) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Float64Shuffle shuffleFromArray(int[] indices, int i) { return new Float64Shuffle(indices, i); } + FloatShuffle64 shuffleFromArray(int[] indices, int i) { return new FloatShuffle64(indices, i); } @Override @ForceInline - Float64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Float64Shuffle(fn); } + FloatShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new FloatShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Float64Vector vectorFactory(float[] vec) { - return new Float64Vector(vec); + FloatVector64 vectorFactory(float[] vec) { + return new FloatVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Float64Vector extends FloatVector { @ForceInline final @Override - Float64Vector uOp(FUnOp f) { - return (Float64Vector) super.uOpTemplate(f); // specialize + FloatVector64 uOp(FUnOp f) { + return (FloatVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Float64Vector uOp(VectorMask m, FUnOp f) { - return (Float64Vector) - super.uOpTemplate((Float64Mask)m, f); // specialize + FloatVector64 uOp(VectorMask m, FUnOp f) { + return (FloatVector64) + super.uOpTemplate((FloatMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Float64Vector bOp(Vector v, FBinOp f) { - return (Float64Vector) super.bOpTemplate((Float64Vector)v, f); // specialize + FloatVector64 bOp(Vector v, FBinOp f) { + return (FloatVector64) super.bOpTemplate((FloatVector64)v, f); // specialize } @ForceInline final @Override - Float64Vector bOp(Vector v, + FloatVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Float64Vector) - super.bOpTemplate((Float64Vector)v, (Float64Mask)m, + return (FloatVector64) + super.bOpTemplate((FloatVector64)v, (FloatMask64)m, f); // specialize } @@ -219,19 +224,19 @@ final class Float64Vector extends FloatVector { @ForceInline final @Override - Float64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Float64Vector) - super.tOpTemplate((Float64Vector)v1, (Float64Vector)v2, + FloatVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (FloatVector64) + super.tOpTemplate((FloatVector64)v1, (FloatVector64)v2, f); // specialize } @ForceInline final @Override - Float64Vector tOp(Vector v1, Vector v2, + FloatVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Float64Vector) - super.tOpTemplate((Float64Vector)v1, (Float64Vector)v2, - (Float64Mask)m, f); // specialize + return (FloatVector64) + super.tOpTemplate((FloatVector64)v1, (FloatVector64)v2, + (FloatMask64)m, f); // specialize } @ForceInline @@ -269,26 +274,26 @@ final class Float64Vector extends FloatVector { @Override @ForceInline - public Float64Vector lanewise(Unary op) { - return (Float64Vector) super.lanewiseTemplate(op); // specialize + public FloatVector64 lanewise(Unary op) { + return (FloatVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Float64Vector lanewise(Unary op, VectorMask m) { - return (Float64Vector) super.lanewiseTemplate(op, Float64Mask.class, (Float64Mask) m); // specialize + public FloatVector64 lanewise(Unary op, VectorMask m) { + return (FloatVector64) super.lanewiseTemplate(op, FloatMask64.class, (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector lanewise(Binary op, Vector v) { - return (Float64Vector) super.lanewiseTemplate(op, v); // specialize + public FloatVector64 lanewise(Binary op, Vector v) { + return (FloatVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Float64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Float64Vector) super.lanewiseTemplate(op, Float64Mask.class, v, (Float64Mask) m); // specialize + public FloatVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (FloatVector64) super.lanewiseTemplate(op, FloatMask64.class, v, (FloatMask64) m); // specialize } @@ -296,24 +301,24 @@ final class Float64Vector extends FloatVector { @Override @ForceInline public final - Float64Vector + FloatVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Float64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (FloatVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Float64Vector + FloatVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Float64Vector) super.lanewiseTemplate(op, Float64Mask.class, v1, v2, (Float64Mask) m); // specialize + return (FloatVector64) super.lanewiseTemplate(op, FloatMask64.class, v1, v2, (FloatMask64) m); // specialize } @Override @ForceInline public final - Float64Vector addIndex(int scale) { - return (Float64Vector) super.addIndexTemplate(scale); // specialize + FloatVector64 addIndex(int scale) { + return (FloatVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +333,7 @@ final class Float64Vector extends FloatVector { @ForceInline public final float reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Float64Mask.class, (Float64Mask) m); // specialized + return super.reduceLanesTemplate(op, FloatMask64.class, (FloatMask64) m); // specialized } @Override @@ -341,7 +346,7 @@ final class Float64Vector extends FloatVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Float64Mask.class, (Float64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, FloatMask64.class, (FloatMask64) m); // specialized } @Override @@ -352,160 +357,160 @@ final class Float64Vector extends FloatVector { @Override @ForceInline - public final Float64Shuffle toShuffle() { - return (Float64Shuffle) toShuffle(vspecies(), false); + public final FloatShuffle64 toShuffle() { + return (FloatShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Float64Mask test(Test op) { - return super.testTemplate(Float64Mask.class, op); // specialize + public final FloatMask64 test(Test op) { + return super.testTemplate(FloatMask64.class, op); // specialize } @Override @ForceInline - public final Float64Mask test(Test op, VectorMask m) { - return super.testTemplate(Float64Mask.class, op, (Float64Mask) m); // specialize + public final FloatMask64 test(Test op, VectorMask m) { + return super.testTemplate(FloatMask64.class, op, (FloatMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Float64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Float64Mask.class, op, v); // specialize + public final FloatMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(FloatMask64.class, op, v); // specialize } @Override @ForceInline - public final Float64Mask compare(Comparison op, float s) { - return super.compareTemplate(Float64Mask.class, op, s); // specialize + public final FloatMask64 compare(Comparison op, float s) { + return super.compareTemplate(FloatMask64.class, op, s); // specialize } @Override @ForceInline - public final Float64Mask compare(Comparison op, long s) { - return super.compareTemplate(Float64Mask.class, op, s); // specialize + public final FloatMask64 compare(Comparison op, long s) { + return super.compareTemplate(FloatMask64.class, op, s); // specialize } @Override @ForceInline - public final Float64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Float64Mask.class, op, v, (Float64Mask) m); + public final FloatMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(FloatMask64.class, op, v, (FloatMask64) m); } @Override @ForceInline - public Float64Vector blend(Vector v, VectorMask m) { - return (Float64Vector) - super.blendTemplate(Float64Mask.class, - (Float64Vector) v, - (Float64Mask) m); // specialize + public FloatVector64 blend(Vector v, VectorMask m) { + return (FloatVector64) + super.blendTemplate(FloatMask64.class, + (FloatVector64) v, + (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector slice(int origin, Vector v) { - return (Float64Vector) super.sliceTemplate(origin, v); // specialize + public FloatVector64 slice(int origin, Vector v) { + return (FloatVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Float64Vector slice(int origin) { - return (Float64Vector) super.sliceTemplate(origin); // specialize + public FloatVector64 slice(int origin) { + return (FloatVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Float64Vector unslice(int origin, Vector w, int part) { - return (Float64Vector) super.unsliceTemplate(origin, w, part); // specialize + public FloatVector64 unslice(int origin, Vector w, int part) { + return (FloatVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Float64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Float64Vector) - super.unsliceTemplate(Float64Mask.class, + public FloatVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (FloatVector64) + super.unsliceTemplate(FloatMask64.class, origin, w, part, - (Float64Mask) m); // specialize + (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector unslice(int origin) { - return (Float64Vector) super.unsliceTemplate(origin); // specialize + public FloatVector64 unslice(int origin) { + return (FloatVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Float64Vector rearrange(VectorShuffle s) { - return (Float64Vector) - super.rearrangeTemplate(Float64Shuffle.class, - (Float64Shuffle) s); // specialize + public FloatVector64 rearrange(VectorShuffle s) { + return (FloatVector64) + super.rearrangeTemplate(FloatShuffle64.class, + (FloatShuffle64) s); // specialize } @Override @ForceInline - public Float64Vector rearrange(VectorShuffle shuffle, + public FloatVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Float64Vector) - super.rearrangeTemplate(Float64Shuffle.class, - Float64Mask.class, - (Float64Shuffle) shuffle, - (Float64Mask) m); // specialize + return (FloatVector64) + super.rearrangeTemplate(FloatShuffle64.class, + FloatMask64.class, + (FloatShuffle64) shuffle, + (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector rearrange(VectorShuffle s, + public FloatVector64 rearrange(VectorShuffle s, Vector v) { - return (Float64Vector) - super.rearrangeTemplate(Float64Shuffle.class, - (Float64Shuffle) s, - (Float64Vector) v); // specialize + return (FloatVector64) + super.rearrangeTemplate(FloatShuffle64.class, + (FloatShuffle64) s, + (FloatVector64) v); // specialize } @Override @ForceInline - public Float64Vector compress(VectorMask m) { - return (Float64Vector) - super.compressTemplate(Float64Mask.class, - (Float64Mask) m); // specialize + public FloatVector64 compress(VectorMask m) { + return (FloatVector64) + super.compressTemplate(FloatMask64.class, + (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector expand(VectorMask m) { - return (Float64Vector) - super.expandTemplate(Float64Mask.class, - (Float64Mask) m); // specialize + public FloatVector64 expand(VectorMask m) { + return (FloatVector64) + super.expandTemplate(FloatMask64.class, + (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector selectFrom(Vector v) { - return (Float64Vector) - super.selectFromTemplate((Float64Vector) v); // specialize + public FloatVector64 selectFrom(Vector v) { + return (FloatVector64) + super.selectFromTemplate((FloatVector64) v); // specialize } @Override @ForceInline - public Float64Vector selectFrom(Vector v, + public FloatVector64 selectFrom(Vector v, VectorMask m) { - return (Float64Vector) - super.selectFromTemplate((Float64Vector) v, - Float64Mask.class, (Float64Mask) m); // specialize + return (FloatVector64) + super.selectFromTemplate((FloatVector64) v, + FloatMask64.class, (FloatMask64) m); // specialize } @Override @ForceInline - public Float64Vector selectFrom(Vector v1, + public FloatVector64 selectFrom(Vector v1, Vector v2) { - return (Float64Vector) - super.selectFromTemplate((Float64Vector) v1, (Float64Vector) v2); // specialize + return (FloatVector64) + super.selectFromTemplate((FloatVector64) v1, (FloatVector64) v2); // specialize } @ForceInline @@ -533,7 +538,7 @@ final class Float64Vector extends FloatVector { @ForceInline @Override - public Float64Vector withLane(int i, float e) { + public FloatVector64 withLane(int i, float e) { switch(i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -542,7 +547,7 @@ final class Float64Vector extends FloatVector { } @ForceInline - public Float64Vector withLaneHelper(int i, float e) { + public FloatVector64 withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), @@ -554,20 +559,21 @@ final class Float64Vector extends FloatVector { } // Mask - - static final class Float64Mask extends AbstractMask { + @ValueBased + static final class FloatMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM - Float64Mask(boolean[] bits) { + static final Class CTYPE = float.class; // used by the JVM + + FloatMask64(boolean[] bits) { this(bits, 0); } - Float64Mask(boolean[] bits, int offset) { + FloatMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Float64Mask(boolean val) { + FloatMask64(boolean val) { super(prepare(val)); } @@ -600,31 +606,31 @@ final class Float64Vector extends FloatVector { } @Override - Float64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Float64Mask(res); + return new FloatMask64(res); } @Override - Float64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Float64Mask)m).getBits(); + boolean[] mbits = ((FloatMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Float64Mask(res); + return new FloatMask64(res); } @ForceInline @Override public final - Float64Vector toVector() { - return (Float64Vector) super.toVectorTemplate(); // specialize + FloatVector64 toVector() { + return (FloatVector64) super.toVectorTemplate(); // specialize } /** @@ -657,25 +663,25 @@ final class Float64Vector extends FloatVector { @Override @ForceInline /*package-private*/ - Float64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Float64Mask) VectorSupport.indexPartiallyInUpperRange( - Float64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Float64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + FloatMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMask64) VectorSupport.indexPartiallyInUpperRange( + FloatMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (FloatMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Float64Mask not() { + public FloatMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Float64Mask compress() { - return (Float64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float64Vector.class, Float64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public FloatMask64 compress() { + return (FloatMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + FloatVector64.class, FloatMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -684,30 +690,30 @@ final class Float64Vector extends FloatVector { @Override @ForceInline - public Float64Mask and(VectorMask mask) { + public FloatMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask64 m = (FloatMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Float64Mask or(VectorMask mask) { + public FloatMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask64 m = (FloatMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Float64Mask xor(VectorMask mask) { + public FloatMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMask64 m = (FloatMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -717,21 +723,21 @@ final class Float64Vector extends FloatVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -741,7 +747,7 @@ final class Float64Vector extends FloatVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -751,7 +757,7 @@ final class Float64Vector extends FloatVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(FloatMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -760,48 +766,49 @@ final class Float64Vector extends FloatVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float64Mask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((FloatMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((FloatMask64)m).getBits())); } @ForceInline /*package-private*/ - static Float64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static FloatMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(FloatMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Float64Mask TRUE_MASK = new Float64Mask(true); - private static final Float64Mask FALSE_MASK = new Float64Mask(false); + private static final FloatMask64 TRUE_MASK = new FloatMask64(true); + private static final FloatMask64 FALSE_MASK = new FloatMask64(false); } // Shuffle - - static final class Float64Shuffle extends AbstractShuffle { + @ValueBased + static final class FloatShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Float64Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + FloatShuffle64(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Float64Shuffle(int[] indices, int i) { + FloatShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Float64Shuffle(IntUnaryOperator fn) { + FloatShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -821,23 +828,23 @@ final class Float64Vector extends FloatVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Float64Shuffle IOTA = new Float64Shuffle(IDENTITY); + static final FloatShuffle64 IOTA = new FloatShuffle64(IDENTITY); @Override @ForceInline - public Float64Vector toVector() { - return (Float64Vector) toBitsVector().castShape(vspecies(), 0); + public FloatVector64 toVector() { + return (FloatVector64) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - Int64Vector toBitsVector() { - return (Int64Vector) super.toBitsVectorTemplate(); + IntVector64 toBitsVector() { + return (IntVector64) super.toBitsVectorTemplate(); } @Override - Int64Vector toBitsVector0() { - return ((Int64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector64 toBitsVector0() { + return ((IntVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -860,30 +867,30 @@ final class Float64Vector extends FloatVector { @Override @ForceInline - public final Float64Mask laneIsValid() { - return (Float64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final FloatMask64 laneIsValid() { + return (FloatMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Float64Shuffle rearrange(VectorShuffle shuffle) { - Float64Shuffle concreteShuffle = (Float64Shuffle) shuffle; - return (Float64Shuffle) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_64)) - .toShuffle(vspecies(), false); + public final FloatShuffle64 rearrange(VectorShuffle shuffle) { + FloatShuffle64 concreteShuffle = (FloatShuffle64) shuffle; + return (FloatShuffle64) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_64)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Float64Shuffle wrapIndexes() { - Int64Vector v = toBitsVector(); + public final FloatShuffle64 wrapIndexes() { + IntVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Float64Shuffle) v.toShuffle(vspecies(), false); + return (FloatShuffle64) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -934,14 +941,14 @@ final class Float64Vector extends FloatVector { @Override final FloatVector fromArray0(float[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Float64Mask.class, a, offset, (Float64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(FloatMask64.class, a, offset, (FloatMask64) m, offsetInRange); // specialize } @ForceInline @Override final FloatVector fromArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Float64Mask.class, a, offset, indexMap, mapOffset, (Float64Mask) m); + return super.fromArray0Template(FloatMask64.class, a, offset, indexMap, mapOffset, (FloatMask64) m); } @@ -957,7 +964,7 @@ final class Float64Vector extends FloatVector { @Override final FloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Float64Mask.class, ms, offset, (Float64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(FloatMask64.class, ms, offset, (FloatMask64) m, offsetInRange); // specialize } @ForceInline @@ -971,14 +978,14 @@ final class Float64Vector extends FloatVector { @Override final void intoArray0(float[] a, int offset, VectorMask m) { - super.intoArray0Template(Float64Mask.class, a, offset, (Float64Mask) m); + super.intoArray0Template(FloatMask64.class, a, offset, (FloatMask64) m); } @ForceInline @Override final void intoArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Float64Mask.class, a, offset, indexMap, mapOffset, (Float64Mask) m); + super.intoArray0Template(FloatMask64.class, a, offset, indexMap, mapOffset, (FloatMask64) m); } @@ -986,7 +993,7 @@ final class Float64Vector extends FloatVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Float64Mask.class, ms, offset, (Float64Mask) m); + super.intoMemorySegment0Template(FloatMask64.class, ms, offset, (FloatMask64) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVectorMax.java similarity index 62% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVectorMax.java index 35e4c83ebde..f115a1c79b8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVectorMax.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class FloatMaxVector extends FloatVector { +@ValueBased +final class FloatVectorMax extends FloatVector { static final FloatSpecies VSPECIES = (FloatSpecies) FloatVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = FloatMaxVector.class; + static final Class VCLASS = FloatVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + static final Class ETYPE = float.class; // used by the JVM - FloatMaxVector(float[] v) { + FloatVectorMax(float[] v) { super(v); } - // For compatibility as FloatMaxVector::new, + // For compatibility as FloatVectorMax::new, // stored into species.vectorFactory. - FloatMaxVector(Object v) { + FloatVectorMax(Object v) { this((float[]) v); } - static final FloatMaxVector ZERO = new FloatMaxVector(new float[VLENGTH]); - static final FloatMaxVector IOTA = new FloatMaxVector(VSPECIES.iotaArray()); + static final FloatVectorMax ZERO = new FloatVectorMax(new float[VLENGTH]); + static final FloatVectorMax IOTA = new FloatVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class FloatMaxVector extends FloatVector { @Override public final Class elementType() { return float.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Float.SIZE; } @@ -130,51 +135,51 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline - public final FloatMaxVector broadcast(float e) { - return (FloatMaxVector) super.broadcastTemplate(e); // specialize + public final FloatVectorMax broadcast(float e) { + return (FloatVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final FloatMaxVector broadcast(long e) { - return (FloatMaxVector) super.broadcastTemplate(e); // specialize + public final FloatVectorMax broadcast(long e) { + return (FloatVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - FloatMaxMask maskFromArray(boolean[] bits) { - return new FloatMaxMask(bits); + FloatMaskMax maskFromArray(boolean[] bits) { + return new FloatMaskMax(bits); } @Override @ForceInline - FloatMaxShuffle iotaShuffle() { return FloatMaxShuffle.IOTA; } + FloatShuffleMax iotaShuffle() { return FloatShuffleMax.IOTA; } @Override @ForceInline - FloatMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (FloatMaxShuffle) iotaShuffleTemplate(start, step, wrap); + FloatShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (FloatShuffleMax) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - FloatMaxShuffle shuffleFromArray(int[] indices, int i) { return new FloatMaxShuffle(indices, i); } + FloatShuffleMax shuffleFromArray(int[] indices, int i) { return new FloatShuffleMax(indices, i); } @Override @ForceInline - FloatMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new FloatMaxShuffle(fn); } + FloatShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new FloatShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - FloatMaxVector vectorFactory(float[] vec) { - return new FloatMaxVector(vec); + FloatVectorMax vectorFactory(float[] vec) { + return new FloatVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class FloatMaxVector extends FloatVector { @ForceInline final @Override - FloatMaxVector uOp(FUnOp f) { - return (FloatMaxVector) super.uOpTemplate(f); // specialize + FloatVectorMax uOp(FUnOp f) { + return (FloatVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - FloatMaxVector uOp(VectorMask m, FUnOp f) { - return (FloatMaxVector) - super.uOpTemplate((FloatMaxMask)m, f); // specialize + FloatVectorMax uOp(VectorMask m, FUnOp f) { + return (FloatVectorMax) + super.uOpTemplate((FloatMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - FloatMaxVector bOp(Vector v, FBinOp f) { - return (FloatMaxVector) super.bOpTemplate((FloatMaxVector)v, f); // specialize + FloatVectorMax bOp(Vector v, FBinOp f) { + return (FloatVectorMax) super.bOpTemplate((FloatVectorMax)v, f); // specialize } @ForceInline final @Override - FloatMaxVector bOp(Vector v, + FloatVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (FloatMaxVector) - super.bOpTemplate((FloatMaxVector)v, (FloatMaxMask)m, + return (FloatVectorMax) + super.bOpTemplate((FloatVectorMax)v, (FloatMaskMax)m, f); // specialize } @@ -219,19 +224,19 @@ final class FloatMaxVector extends FloatVector { @ForceInline final @Override - FloatMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (FloatMaxVector) - super.tOpTemplate((FloatMaxVector)v1, (FloatMaxVector)v2, + FloatVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (FloatVectorMax) + super.tOpTemplate((FloatVectorMax)v1, (FloatVectorMax)v2, f); // specialize } @ForceInline final @Override - FloatMaxVector tOp(Vector v1, Vector v2, + FloatVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (FloatMaxVector) - super.tOpTemplate((FloatMaxVector)v1, (FloatMaxVector)v2, - (FloatMaxMask)m, f); // specialize + return (FloatVectorMax) + super.tOpTemplate((FloatVectorMax)v1, (FloatVectorMax)v2, + (FloatMaskMax)m, f); // specialize } @ForceInline @@ -269,26 +274,26 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline - public FloatMaxVector lanewise(Unary op) { - return (FloatMaxVector) super.lanewiseTemplate(op); // specialize + public FloatVectorMax lanewise(Unary op) { + return (FloatVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public FloatMaxVector lanewise(Unary op, VectorMask m) { - return (FloatMaxVector) super.lanewiseTemplate(op, FloatMaxMask.class, (FloatMaxMask) m); // specialize + public FloatVectorMax lanewise(Unary op, VectorMask m) { + return (FloatVectorMax) super.lanewiseTemplate(op, FloatMaskMax.class, (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector lanewise(Binary op, Vector v) { - return (FloatMaxVector) super.lanewiseTemplate(op, v); // specialize + public FloatVectorMax lanewise(Binary op, Vector v) { + return (FloatVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public FloatMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (FloatMaxVector) super.lanewiseTemplate(op, FloatMaxMask.class, v, (FloatMaxMask) m); // specialize + public FloatVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (FloatVectorMax) super.lanewiseTemplate(op, FloatMaskMax.class, v, (FloatMaskMax) m); // specialize } @@ -296,24 +301,24 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline public final - FloatMaxVector + FloatVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (FloatMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (FloatVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - FloatMaxVector + FloatVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (FloatMaxVector) super.lanewiseTemplate(op, FloatMaxMask.class, v1, v2, (FloatMaxMask) m); // specialize + return (FloatVectorMax) super.lanewiseTemplate(op, FloatMaskMax.class, v1, v2, (FloatMaskMax) m); // specialize } @Override @ForceInline public final - FloatMaxVector addIndex(int scale) { - return (FloatMaxVector) super.addIndexTemplate(scale); // specialize + FloatVectorMax addIndex(int scale) { + return (FloatVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -328,7 +333,7 @@ final class FloatMaxVector extends FloatVector { @ForceInline public final float reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, FloatMaxMask.class, (FloatMaxMask) m); // specialized + return super.reduceLanesTemplate(op, FloatMaskMax.class, (FloatMaskMax) m); // specialized } @Override @@ -341,7 +346,7 @@ final class FloatMaxVector extends FloatVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, FloatMaxMask.class, (FloatMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, FloatMaskMax.class, (FloatMaskMax) m); // specialized } @Override @@ -352,160 +357,160 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline - public final FloatMaxShuffle toShuffle() { - return (FloatMaxShuffle) toShuffle(vspecies(), false); + public final FloatShuffleMax toShuffle() { + return (FloatShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final FloatMaxMask test(Test op) { - return super.testTemplate(FloatMaxMask.class, op); // specialize + public final FloatMaskMax test(Test op) { + return super.testTemplate(FloatMaskMax.class, op); // specialize } @Override @ForceInline - public final FloatMaxMask test(Test op, VectorMask m) { - return super.testTemplate(FloatMaxMask.class, op, (FloatMaxMask) m); // specialize + public final FloatMaskMax test(Test op, VectorMask m) { + return super.testTemplate(FloatMaskMax.class, op, (FloatMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final FloatMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(FloatMaxMask.class, op, v); // specialize + public final FloatMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(FloatMaskMax.class, op, v); // specialize } @Override @ForceInline - public final FloatMaxMask compare(Comparison op, float s) { - return super.compareTemplate(FloatMaxMask.class, op, s); // specialize + public final FloatMaskMax compare(Comparison op, float s) { + return super.compareTemplate(FloatMaskMax.class, op, s); // specialize } @Override @ForceInline - public final FloatMaxMask compare(Comparison op, long s) { - return super.compareTemplate(FloatMaxMask.class, op, s); // specialize + public final FloatMaskMax compare(Comparison op, long s) { + return super.compareTemplate(FloatMaskMax.class, op, s); // specialize } @Override @ForceInline - public final FloatMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(FloatMaxMask.class, op, v, (FloatMaxMask) m); + public final FloatMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(FloatMaskMax.class, op, v, (FloatMaskMax) m); } @Override @ForceInline - public FloatMaxVector blend(Vector v, VectorMask m) { - return (FloatMaxVector) - super.blendTemplate(FloatMaxMask.class, - (FloatMaxVector) v, - (FloatMaxMask) m); // specialize + public FloatVectorMax blend(Vector v, VectorMask m) { + return (FloatVectorMax) + super.blendTemplate(FloatMaskMax.class, + (FloatVectorMax) v, + (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector slice(int origin, Vector v) { - return (FloatMaxVector) super.sliceTemplate(origin, v); // specialize + public FloatVectorMax slice(int origin, Vector v) { + return (FloatVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public FloatMaxVector slice(int origin) { - return (FloatMaxVector) super.sliceTemplate(origin); // specialize + public FloatVectorMax slice(int origin) { + return (FloatVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public FloatMaxVector unslice(int origin, Vector w, int part) { - return (FloatMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public FloatVectorMax unslice(int origin, Vector w, int part) { + return (FloatVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public FloatMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (FloatMaxVector) - super.unsliceTemplate(FloatMaxMask.class, + public FloatVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (FloatVectorMax) + super.unsliceTemplate(FloatMaskMax.class, origin, w, part, - (FloatMaxMask) m); // specialize + (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector unslice(int origin) { - return (FloatMaxVector) super.unsliceTemplate(origin); // specialize + public FloatVectorMax unslice(int origin) { + return (FloatVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public FloatMaxVector rearrange(VectorShuffle s) { - return (FloatMaxVector) - super.rearrangeTemplate(FloatMaxShuffle.class, - (FloatMaxShuffle) s); // specialize + public FloatVectorMax rearrange(VectorShuffle s) { + return (FloatVectorMax) + super.rearrangeTemplate(FloatShuffleMax.class, + (FloatShuffleMax) s); // specialize } @Override @ForceInline - public FloatMaxVector rearrange(VectorShuffle shuffle, + public FloatVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (FloatMaxVector) - super.rearrangeTemplate(FloatMaxShuffle.class, - FloatMaxMask.class, - (FloatMaxShuffle) shuffle, - (FloatMaxMask) m); // specialize + return (FloatVectorMax) + super.rearrangeTemplate(FloatShuffleMax.class, + FloatMaskMax.class, + (FloatShuffleMax) shuffle, + (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector rearrange(VectorShuffle s, + public FloatVectorMax rearrange(VectorShuffle s, Vector v) { - return (FloatMaxVector) - super.rearrangeTemplate(FloatMaxShuffle.class, - (FloatMaxShuffle) s, - (FloatMaxVector) v); // specialize + return (FloatVectorMax) + super.rearrangeTemplate(FloatShuffleMax.class, + (FloatShuffleMax) s, + (FloatVectorMax) v); // specialize } @Override @ForceInline - public FloatMaxVector compress(VectorMask m) { - return (FloatMaxVector) - super.compressTemplate(FloatMaxMask.class, - (FloatMaxMask) m); // specialize + public FloatVectorMax compress(VectorMask m) { + return (FloatVectorMax) + super.compressTemplate(FloatMaskMax.class, + (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector expand(VectorMask m) { - return (FloatMaxVector) - super.expandTemplate(FloatMaxMask.class, - (FloatMaxMask) m); // specialize + public FloatVectorMax expand(VectorMask m) { + return (FloatVectorMax) + super.expandTemplate(FloatMaskMax.class, + (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector selectFrom(Vector v) { - return (FloatMaxVector) - super.selectFromTemplate((FloatMaxVector) v); // specialize + public FloatVectorMax selectFrom(Vector v) { + return (FloatVectorMax) + super.selectFromTemplate((FloatVectorMax) v); // specialize } @Override @ForceInline - public FloatMaxVector selectFrom(Vector v, + public FloatVectorMax selectFrom(Vector v, VectorMask m) { - return (FloatMaxVector) - super.selectFromTemplate((FloatMaxVector) v, - FloatMaxMask.class, (FloatMaxMask) m); // specialize + return (FloatVectorMax) + super.selectFromTemplate((FloatVectorMax) v, + FloatMaskMax.class, (FloatMaskMax) m); // specialize } @Override @ForceInline - public FloatMaxVector selectFrom(Vector v1, + public FloatVectorMax selectFrom(Vector v1, Vector v2) { - return (FloatMaxVector) - super.selectFromTemplate((FloatMaxVector) v1, (FloatMaxVector) v2); // specialize + return (FloatVectorMax) + super.selectFromTemplate((FloatVectorMax) v1, (FloatVectorMax) v2); // specialize } @ForceInline @@ -531,7 +536,7 @@ final class FloatMaxVector extends FloatVector { @ForceInline @Override - public FloatMaxVector withLane(int i, float e) { + public FloatVectorMax withLane(int i, float e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -539,7 +544,7 @@ final class FloatMaxVector extends FloatVector { } @ForceInline - public FloatMaxVector withLaneHelper(int i, float e) { + public FloatVectorMax withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), @@ -551,20 +556,21 @@ final class FloatMaxVector extends FloatVector { } // Mask - - static final class FloatMaxMask extends AbstractMask { + @ValueBased + static final class FloatMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM - FloatMaxMask(boolean[] bits) { + static final Class CTYPE = float.class; // used by the JVM + + FloatMaskMax(boolean[] bits) { this(bits, 0); } - FloatMaxMask(boolean[] bits, int offset) { + FloatMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - FloatMaxMask(boolean val) { + FloatMaskMax(boolean val) { super(prepare(val)); } @@ -597,31 +603,31 @@ final class FloatMaxVector extends FloatVector { } @Override - FloatMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new FloatMaxMask(res); + return new FloatMaskMax(res); } @Override - FloatMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + FloatMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((FloatMaxMask)m).getBits(); + boolean[] mbits = ((FloatMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new FloatMaxMask(res); + return new FloatMaskMax(res); } @ForceInline @Override public final - FloatMaxVector toVector() { - return (FloatMaxVector) super.toVectorTemplate(); // specialize + FloatVectorMax toVector() { + return (FloatVectorMax) super.toVectorTemplate(); // specialize } /** @@ -654,25 +660,25 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline /*package-private*/ - FloatMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (FloatMaxMask) VectorSupport.indexPartiallyInUpperRange( - FloatMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (FloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + FloatMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMaskMax) VectorSupport.indexPartiallyInUpperRange( + FloatMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (FloatMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public FloatMaxMask not() { + public FloatMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public FloatMaxMask compress() { - return (FloatMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - FloatMaxVector.class, FloatMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public FloatMaskMax compress() { + return (FloatMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + FloatVectorMax.class, FloatMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -681,30 +687,30 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline - public FloatMaxMask and(VectorMask mask) { + public FloatMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMaskMax m = (FloatMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public FloatMaxMask or(VectorMask mask) { + public FloatMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMaskMax m = (FloatMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public FloatMaxMask xor(VectorMask mask) { + public FloatMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + FloatMaskMax m = (FloatMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -714,21 +720,21 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -738,7 +744,7 @@ final class FloatMaxVector extends FloatVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -748,7 +754,7 @@ final class FloatMaxVector extends FloatVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(FloatMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(FloatMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -757,48 +763,49 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((FloatMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((FloatMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static FloatMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(FloatMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static FloatMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(FloatMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final FloatMaxMask TRUE_MASK = new FloatMaxMask(true); - private static final FloatMaxMask FALSE_MASK = new FloatMaxMask(false); + private static final FloatMaskMax TRUE_MASK = new FloatMaskMax(true); + private static final FloatMaskMax FALSE_MASK = new FloatMaskMax(false); } // Shuffle - - static final class FloatMaxShuffle extends AbstractShuffle { + @ValueBased + static final class FloatShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - FloatMaxShuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + FloatShuffleMax(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - FloatMaxShuffle(int[] indices, int i) { + FloatShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - FloatMaxShuffle(IntUnaryOperator fn) { + FloatShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -818,23 +825,23 @@ final class FloatMaxVector extends FloatVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final FloatMaxShuffle IOTA = new FloatMaxShuffle(IDENTITY); + static final FloatShuffleMax IOTA = new FloatShuffleMax(IDENTITY); @Override @ForceInline - public FloatMaxVector toVector() { - return (FloatMaxVector) toBitsVector().castShape(vspecies(), 0); + public FloatVectorMax toVector() { + return (FloatVectorMax) toBitsVector().castShape(VSPECIES, 0); } @Override @ForceInline - IntMaxVector toBitsVector() { - return (IntMaxVector) super.toBitsVectorTemplate(); + IntVectorMax toBitsVector() { + return (IntVectorMax) super.toBitsVectorTemplate(); } @Override - IntMaxVector toBitsVector0() { - return ((IntMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVectorMax toBitsVector0() { + return ((IntVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -857,30 +864,30 @@ final class FloatMaxVector extends FloatVector { @Override @ForceInline - public final FloatMaxMask laneIsValid() { - return (FloatMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final FloatMaskMax laneIsValid() { + return (FloatMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final FloatMaxShuffle rearrange(VectorShuffle shuffle) { - FloatMaxShuffle concreteShuffle = (FloatMaxShuffle) shuffle; - return (FloatMaxShuffle) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_MAX)) - .toShuffle(vspecies(), false); + public final FloatShuffleMax rearrange(VectorShuffle shuffle) { + FloatShuffleMax concreteShuffle = (FloatShuffleMax) shuffle; + return (FloatShuffleMax) toBitsVector().rearrange(concreteShuffle.cast(IntVector.SPECIES_MAX)) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final FloatMaxShuffle wrapIndexes() { - IntMaxVector v = toBitsVector(); + public final FloatShuffleMax wrapIndexes() { + IntVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (IntMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (IntMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (FloatMaxShuffle) v.toShuffle(vspecies(), false); + return (FloatShuffleMax) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -931,14 +938,14 @@ final class FloatMaxVector extends FloatVector { @Override final FloatVector fromArray0(float[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(FloatMaxMask.class, a, offset, (FloatMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(FloatMaskMax.class, a, offset, (FloatMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final FloatVector fromArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(FloatMaxMask.class, a, offset, indexMap, mapOffset, (FloatMaxMask) m); + return super.fromArray0Template(FloatMaskMax.class, a, offset, indexMap, mapOffset, (FloatMaskMax) m); } @@ -954,7 +961,7 @@ final class FloatMaxVector extends FloatVector { @Override final FloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(FloatMaxMask.class, ms, offset, (FloatMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(FloatMaskMax.class, ms, offset, (FloatMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -968,14 +975,14 @@ final class FloatMaxVector extends FloatVector { @Override final void intoArray0(float[] a, int offset, VectorMask m) { - super.intoArray0Template(FloatMaxMask.class, a, offset, (FloatMaxMask) m); + super.intoArray0Template(FloatMaskMax.class, a, offset, (FloatMaskMax) m); } @ForceInline @Override final void intoArray0(float[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(FloatMaxMask.class, a, offset, indexMap, mapOffset, (FloatMaxMask) m); + super.intoArray0Template(FloatMaskMax.class, a, offset, indexMap, mapOffset, (FloatMaskMax) m); } @@ -983,7 +990,7 @@ final class FloatMaxVector extends FloatVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(FloatMaxMask.class, ms, offset, (FloatMaxMask) m); + super.intoMemorySegment0Template(FloatMaskMax.class, ms, offset, (FloatMaskMax) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index 412ac8e59b2..37b7e3eeae4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code int} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class IntVector extends AbstractVector { +public abstract sealed class IntVector extends AbstractVector + permits IntVector64, IntVector128, IntVector256, IntVector512, IntVectorMax { IntVector(int[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class IntVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -4084,13 +4085,13 @@ public abstract class IntVector extends AbstractVector { @Override @ForceInline public final IntVector zero() { - if ((Class) vectorType() == IntMaxVector.class) - return IntMaxVector.ZERO; + if ((Class) vectorType() == IntVectorMax.class) + return IntVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Int64Vector.ZERO; - case 128: return Int128Vector.ZERO; - case 256: return Int256Vector.ZERO; - case 512: return Int512Vector.ZERO; + case 64: return IntVector64.ZERO; + case 128: return IntVector128.ZERO; + case 256: return IntVector256.ZERO; + case 512: return IntVector512.ZERO; } throw new AssertionError(); } @@ -4098,13 +4099,13 @@ public abstract class IntVector extends AbstractVector { @Override @ForceInline public final IntVector iota() { - if ((Class) vectorType() == IntMaxVector.class) - return IntMaxVector.IOTA; + if ((Class) vectorType() == IntVectorMax.class) + return IntVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Int64Vector.IOTA; - case 128: return Int128Vector.IOTA; - case 256: return Int256Vector.IOTA; - case 512: return Int512Vector.IOTA; + case 64: return IntVector64.IOTA; + case 128: return IntVector128.IOTA; + case 256: return IntVector256.IOTA; + case 512: return IntVector512.IOTA; } throw new AssertionError(); } @@ -4113,13 +4114,13 @@ public abstract class IntVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == IntMaxVector.class) - return IntMaxVector.IntMaxMask.maskAll(bit); + if ((Class) vectorType() == IntVectorMax.class) + return IntVectorMax.IntMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Int64Vector.Int64Mask.maskAll(bit); - case 128: return Int128Vector.Int128Mask.maskAll(bit); - case 256: return Int256Vector.Int256Mask.maskAll(bit); - case 512: return Int512Vector.Int512Mask.maskAll(bit); + case 64: return IntVector64.IntMask64.maskAll(bit); + case 128: return IntVector128.IntMask128.maskAll(bit); + case 256: return IntVector256.IntMask256.maskAll(bit); + case 512: return IntVector512.IntMask512.maskAll(bit); } throw new AssertionError(); } @@ -4147,42 +4148,42 @@ public abstract class IntVector extends AbstractVector { /** Species representing {@link IntVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new IntSpecies(VectorShape.S_64_BIT, - Int64Vector.class, - Int64Vector.Int64Mask.class, - Int64Vector.Int64Shuffle.class, - Int64Vector::new); + IntVector64.class, + IntVector64.IntMask64.class, + IntVector64.IntShuffle64.class, + IntVector64::new); /** Species representing {@link IntVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new IntSpecies(VectorShape.S_128_BIT, - Int128Vector.class, - Int128Vector.Int128Mask.class, - Int128Vector.Int128Shuffle.class, - Int128Vector::new); + IntVector128.class, + IntVector128.IntMask128.class, + IntVector128.IntShuffle128.class, + IntVector128::new); /** Species representing {@link IntVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new IntSpecies(VectorShape.S_256_BIT, - Int256Vector.class, - Int256Vector.Int256Mask.class, - Int256Vector.Int256Shuffle.class, - Int256Vector::new); + IntVector256.class, + IntVector256.IntMask256.class, + IntVector256.IntShuffle256.class, + IntVector256::new); /** Species representing {@link IntVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new IntSpecies(VectorShape.S_512_BIT, - Int512Vector.class, - Int512Vector.Int512Mask.class, - Int512Vector.Int512Shuffle.class, - Int512Vector::new); + IntVector512.class, + IntVector512.IntMask512.class, + IntVector512.IntShuffle512.class, + IntVector512::new); /** Species representing {@link IntVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new IntSpecies(VectorShape.S_Max_BIT, - IntMaxVector.class, - IntMaxVector.IntMaxMask.class, - IntMaxVector.IntMaxShuffle.class, - IntMaxVector::new); + IntVectorMax.class, + IntVectorMax.IntMaskMax.class, + IntVectorMax.IntShuffleMax.class, + IntVectorMax::new); /** * Preferred species for {@link IntVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector128.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector128.java index 17e93dbd06a..f64328e2a1e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector128.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Int128Vector extends IntVector { +@ValueBased +final class IntVector128 extends IntVector { static final IntSpecies VSPECIES = (IntSpecies) IntVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Int128Vector.class; + static final Class VCLASS = IntVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + static final Class ETYPE = int.class; // used by the JVM - Int128Vector(int[] v) { + IntVector128(int[] v) { super(v); } - // For compatibility as Int128Vector::new, + // For compatibility as IntVector128::new, // stored into species.vectorFactory. - Int128Vector(Object v) { + IntVector128(Object v) { this((int[]) v); } - static final Int128Vector ZERO = new Int128Vector(new int[VLENGTH]); - static final Int128Vector IOTA = new Int128Vector(VSPECIES.iotaArray()); + static final IntVector128 ZERO = new IntVector128(new int[VLENGTH]); + static final IntVector128 IOTA = new IntVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Int128Vector extends IntVector { @Override public final Class elementType() { return int.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Integer.SIZE; } @@ -130,51 +135,51 @@ final class Int128Vector extends IntVector { @Override @ForceInline - public final Int128Vector broadcast(int e) { - return (Int128Vector) super.broadcastTemplate(e); // specialize + public final IntVector128 broadcast(int e) { + return (IntVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Int128Vector broadcast(long e) { - return (Int128Vector) super.broadcastTemplate(e); // specialize + public final IntVector128 broadcast(long e) { + return (IntVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Int128Mask maskFromArray(boolean[] bits) { - return new Int128Mask(bits); + IntMask128 maskFromArray(boolean[] bits) { + return new IntMask128(bits); } @Override @ForceInline - Int128Shuffle iotaShuffle() { return Int128Shuffle.IOTA; } + IntShuffle128 iotaShuffle() { return IntShuffle128.IOTA; } @Override @ForceInline - Int128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Int128Shuffle) iotaShuffleTemplate(start, step, wrap); + IntShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (IntShuffle128) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Int128Shuffle shuffleFromArray(int[] indices, int i) { return new Int128Shuffle(indices, i); } + IntShuffle128 shuffleFromArray(int[] indices, int i) { return new IntShuffle128(indices, i); } @Override @ForceInline - Int128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Int128Shuffle(fn); } + IntShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new IntShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Int128Vector vectorFactory(int[] vec) { - return new Int128Vector(vec); + IntVector128 vectorFactory(int[] vec) { + return new IntVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Int128Vector extends IntVector { @ForceInline final @Override - Int128Vector uOp(FUnOp f) { - return (Int128Vector) super.uOpTemplate(f); // specialize + IntVector128 uOp(FUnOp f) { + return (IntVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Int128Vector uOp(VectorMask m, FUnOp f) { - return (Int128Vector) - super.uOpTemplate((Int128Mask)m, f); // specialize + IntVector128 uOp(VectorMask m, FUnOp f) { + return (IntVector128) + super.uOpTemplate((IntMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Int128Vector bOp(Vector v, FBinOp f) { - return (Int128Vector) super.bOpTemplate((Int128Vector)v, f); // specialize + IntVector128 bOp(Vector v, FBinOp f) { + return (IntVector128) super.bOpTemplate((IntVector128)v, f); // specialize } @ForceInline final @Override - Int128Vector bOp(Vector v, + IntVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Int128Vector) - super.bOpTemplate((Int128Vector)v, (Int128Mask)m, + return (IntVector128) + super.bOpTemplate((IntVector128)v, (IntMask128)m, f); // specialize } @@ -219,19 +224,19 @@ final class Int128Vector extends IntVector { @ForceInline final @Override - Int128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Int128Vector) - super.tOpTemplate((Int128Vector)v1, (Int128Vector)v2, + IntVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (IntVector128) + super.tOpTemplate((IntVector128)v1, (IntVector128)v2, f); // specialize } @ForceInline final @Override - Int128Vector tOp(Vector v1, Vector v2, + IntVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Int128Vector) - super.tOpTemplate((Int128Vector)v1, (Int128Vector)v2, - (Int128Mask)m, f); // specialize + return (IntVector128) + super.tOpTemplate((IntVector128)v1, (IntVector128)v2, + (IntMask128)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Int128Vector extends IntVector { @Override @ForceInline - public Int128Vector lanewise(Unary op) { - return (Int128Vector) super.lanewiseTemplate(op); // specialize + public IntVector128 lanewise(Unary op) { + return (IntVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Int128Vector lanewise(Unary op, VectorMask m) { - return (Int128Vector) super.lanewiseTemplate(op, Int128Mask.class, (Int128Mask) m); // specialize + public IntVector128 lanewise(Unary op, VectorMask m) { + return (IntVector128) super.lanewiseTemplate(op, IntMask128.class, (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector lanewise(Binary op, Vector v) { - return (Int128Vector) super.lanewiseTemplate(op, v); // specialize + public IntVector128 lanewise(Binary op, Vector v) { + return (IntVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Int128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Int128Vector) super.lanewiseTemplate(op, Int128Mask.class, v, (Int128Mask) m); // specialize + public IntVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (IntVector128) super.lanewiseTemplate(op, IntMask128.class, v, (IntMask128) m); // specialize } /*package-private*/ @Override - @ForceInline Int128Vector + @ForceInline IntVector128 lanewiseShift(VectorOperators.Binary op, int e) { - return (Int128Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (IntVector128) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Int128Vector + @ForceInline IntVector128 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Int128Vector) super.lanewiseShiftTemplate(op, Int128Mask.class, e, (Int128Mask) m); // specialize + return (IntVector128) super.lanewiseShiftTemplate(op, IntMask128.class, e, (IntMask128) m); // specialize } /*package-private*/ @Override @ForceInline public final - Int128Vector + IntVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Int128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (IntVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Int128Vector + IntVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Int128Vector) super.lanewiseTemplate(op, Int128Mask.class, v1, v2, (Int128Mask) m); // specialize + return (IntVector128) super.lanewiseTemplate(op, IntMask128.class, v1, v2, (IntMask128) m); // specialize } @Override @ForceInline public final - Int128Vector addIndex(int scale) { - return (Int128Vector) super.addIndexTemplate(scale); // specialize + IntVector128 addIndex(int scale) { + return (IntVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Int128Vector extends IntVector { @ForceInline public final int reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Int128Mask.class, (Int128Mask) m); // specialized + return super.reduceLanesTemplate(op, IntMask128.class, (IntMask128) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Int128Vector extends IntVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Int128Mask.class, (Int128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, IntMask128.class, (IntMask128) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Int128Vector extends IntVector { @Override @ForceInline - public final Int128Shuffle toShuffle() { - return (Int128Shuffle) toShuffle(vspecies(), false); + public final IntShuffle128 toShuffle() { + return (IntShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Int128Mask test(Test op) { - return super.testTemplate(Int128Mask.class, op); // specialize + public final IntMask128 test(Test op) { + return super.testTemplate(IntMask128.class, op); // specialize } @Override @ForceInline - public final Int128Mask test(Test op, VectorMask m) { - return super.testTemplate(Int128Mask.class, op, (Int128Mask) m); // specialize + public final IntMask128 test(Test op, VectorMask m) { + return super.testTemplate(IntMask128.class, op, (IntMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Int128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Int128Mask.class, op, v); // specialize + public final IntMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(IntMask128.class, op, v); // specialize } @Override @ForceInline - public final Int128Mask compare(Comparison op, int s) { - return super.compareTemplate(Int128Mask.class, op, s); // specialize + public final IntMask128 compare(Comparison op, int s) { + return super.compareTemplate(IntMask128.class, op, s); // specialize } @Override @ForceInline - public final Int128Mask compare(Comparison op, long s) { - return super.compareTemplate(Int128Mask.class, op, s); // specialize + public final IntMask128 compare(Comparison op, long s) { + return super.compareTemplate(IntMask128.class, op, s); // specialize } @Override @ForceInline - public final Int128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Int128Mask.class, op, v, (Int128Mask) m); + public final IntMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(IntMask128.class, op, v, (IntMask128) m); } @Override @ForceInline - public Int128Vector blend(Vector v, VectorMask m) { - return (Int128Vector) - super.blendTemplate(Int128Mask.class, - (Int128Vector) v, - (Int128Mask) m); // specialize + public IntVector128 blend(Vector v, VectorMask m) { + return (IntVector128) + super.blendTemplate(IntMask128.class, + (IntVector128) v, + (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector slice(int origin, Vector v) { - return (Int128Vector) super.sliceTemplate(origin, v); // specialize + public IntVector128 slice(int origin, Vector v) { + return (IntVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Int128Vector slice(int origin) { - return (Int128Vector) super.sliceTemplate(origin); // specialize + public IntVector128 slice(int origin) { + return (IntVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Int128Vector unslice(int origin, Vector w, int part) { - return (Int128Vector) super.unsliceTemplate(origin, w, part); // specialize + public IntVector128 unslice(int origin, Vector w, int part) { + return (IntVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Int128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Int128Vector) - super.unsliceTemplate(Int128Mask.class, + public IntVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (IntVector128) + super.unsliceTemplate(IntMask128.class, origin, w, part, - (Int128Mask) m); // specialize + (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector unslice(int origin) { - return (Int128Vector) super.unsliceTemplate(origin); // specialize + public IntVector128 unslice(int origin) { + return (IntVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Int128Vector rearrange(VectorShuffle s) { - return (Int128Vector) - super.rearrangeTemplate(Int128Shuffle.class, - (Int128Shuffle) s); // specialize + public IntVector128 rearrange(VectorShuffle s) { + return (IntVector128) + super.rearrangeTemplate(IntShuffle128.class, + (IntShuffle128) s); // specialize } @Override @ForceInline - public Int128Vector rearrange(VectorShuffle shuffle, + public IntVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Int128Vector) - super.rearrangeTemplate(Int128Shuffle.class, - Int128Mask.class, - (Int128Shuffle) shuffle, - (Int128Mask) m); // specialize + return (IntVector128) + super.rearrangeTemplate(IntShuffle128.class, + IntMask128.class, + (IntShuffle128) shuffle, + (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector rearrange(VectorShuffle s, + public IntVector128 rearrange(VectorShuffle s, Vector v) { - return (Int128Vector) - super.rearrangeTemplate(Int128Shuffle.class, - (Int128Shuffle) s, - (Int128Vector) v); // specialize + return (IntVector128) + super.rearrangeTemplate(IntShuffle128.class, + (IntShuffle128) s, + (IntVector128) v); // specialize } @Override @ForceInline - public Int128Vector compress(VectorMask m) { - return (Int128Vector) - super.compressTemplate(Int128Mask.class, - (Int128Mask) m); // specialize + public IntVector128 compress(VectorMask m) { + return (IntVector128) + super.compressTemplate(IntMask128.class, + (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector expand(VectorMask m) { - return (Int128Vector) - super.expandTemplate(Int128Mask.class, - (Int128Mask) m); // specialize + public IntVector128 expand(VectorMask m) { + return (IntVector128) + super.expandTemplate(IntMask128.class, + (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector selectFrom(Vector v) { - return (Int128Vector) - super.selectFromTemplate((Int128Vector) v); // specialize + public IntVector128 selectFrom(Vector v) { + return (IntVector128) + super.selectFromTemplate((IntVector128) v); // specialize } @Override @ForceInline - public Int128Vector selectFrom(Vector v, + public IntVector128 selectFrom(Vector v, VectorMask m) { - return (Int128Vector) - super.selectFromTemplate((Int128Vector) v, - Int128Mask.class, (Int128Mask) m); // specialize + return (IntVector128) + super.selectFromTemplate((IntVector128) v, + IntMask128.class, (IntMask128) m); // specialize } @Override @ForceInline - public Int128Vector selectFrom(Vector v1, + public IntVector128 selectFrom(Vector v1, Vector v2) { - return (Int128Vector) - super.selectFromTemplate((Int128Vector) v1, (Int128Vector) v2); // specialize + return (IntVector128) + super.selectFromTemplate((IntVector128) v1, (IntVector128) v2); // specialize } @ForceInline @@ -546,7 +551,7 @@ final class Int128Vector extends IntVector { @ForceInline @Override - public Int128Vector withLane(int i, int e) { + public IntVector128 withLane(int i, int e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -557,7 +562,7 @@ final class Int128Vector extends IntVector { } @ForceInline - public Int128Vector withLaneHelper(int i, int e) { + public IntVector128 withLaneHelper(int i, int e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -569,20 +574,21 @@ final class Int128Vector extends IntVector { } // Mask - - static final class Int128Mask extends AbstractMask { + @ValueBased + static final class IntMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int128Mask(boolean[] bits) { + static final Class CTYPE = int.class; // used by the JVM + + IntMask128(boolean[] bits) { this(bits, 0); } - Int128Mask(boolean[] bits, int offset) { + IntMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Int128Mask(boolean val) { + IntMask128(boolean val) { super(prepare(val)); } @@ -615,31 +621,31 @@ final class Int128Vector extends IntVector { } @Override - Int128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Int128Mask(res); + return new IntMask128(res); } @Override - Int128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Int128Mask)m).getBits(); + boolean[] mbits = ((IntMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Int128Mask(res); + return new IntMask128(res); } @ForceInline @Override public final - Int128Vector toVector() { - return (Int128Vector) super.toVectorTemplate(); // specialize + IntVector128 toVector() { + return (IntVector128) super.toVectorTemplate(); // specialize } /** @@ -672,25 +678,25 @@ final class Int128Vector extends IntVector { @Override @ForceInline /*package-private*/ - Int128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Int128Mask) VectorSupport.indexPartiallyInUpperRange( - Int128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Int128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + IntMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (IntMask128) VectorSupport.indexPartiallyInUpperRange( + IntMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (IntMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Int128Mask not() { + public IntMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Int128Mask compress() { - return (Int128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int128Vector.class, Int128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public IntMask128 compress() { + return (IntMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + IntVector128.class, IntMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -699,30 +705,30 @@ final class Int128Vector extends IntVector { @Override @ForceInline - public Int128Mask and(VectorMask mask) { + public IntMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask128 m = (IntMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Int128Mask or(VectorMask mask) { + public IntMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask128 m = (IntMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Int128Mask xor(VectorMask mask) { + public IntMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask128 m = (IntMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -732,21 +738,21 @@ final class Int128Vector extends IntVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -756,7 +762,7 @@ final class Int128Vector extends IntVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -766,7 +772,7 @@ final class Int128Vector extends IntVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(IntMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -775,48 +781,49 @@ final class Int128Vector extends IntVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int128Mask)m).getBits())); + return VectorSupport.test(BT_ne, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((IntMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((IntMask128)m).getBits())); } @ForceInline /*package-private*/ - static Int128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static IntMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(IntMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Int128Mask TRUE_MASK = new Int128Mask(true); - private static final Int128Mask FALSE_MASK = new Int128Mask(false); + private static final IntMask128 TRUE_MASK = new IntMask128(true); + private static final IntMask128 FALSE_MASK = new IntMask128(false); } // Shuffle - - static final class Int128Shuffle extends AbstractShuffle { + @ValueBased + static final class IntShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int128Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + IntShuffle128(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Int128Shuffle(int[] indices, int i) { + IntShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Int128Shuffle(IntUnaryOperator fn) { + IntShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -836,23 +843,23 @@ final class Int128Vector extends IntVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Int128Shuffle IOTA = new Int128Shuffle(IDENTITY); + static final IntShuffle128 IOTA = new IntShuffle128(IDENTITY); @Override @ForceInline - public Int128Vector toVector() { + public IntVector128 toVector() { return toBitsVector(); } @Override @ForceInline - Int128Vector toBitsVector() { - return (Int128Vector) super.toBitsVectorTemplate(); + IntVector128 toBitsVector() { + return (IntVector128) super.toBitsVectorTemplate(); } @Override - Int128Vector toBitsVector0() { - return ((Int128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector128 toBitsVector0() { + return ((IntVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -875,30 +882,30 @@ final class Int128Vector extends IntVector { @Override @ForceInline - public final Int128Mask laneIsValid() { - return (Int128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final IntMask128 laneIsValid() { + return (IntMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Int128Shuffle rearrange(VectorShuffle shuffle) { - Int128Shuffle concreteShuffle = (Int128Shuffle) shuffle; - return (Int128Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final IntShuffle128 rearrange(VectorShuffle shuffle) { + IntShuffle128 concreteShuffle = (IntShuffle128) shuffle; + return (IntShuffle128) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Int128Shuffle wrapIndexes() { - Int128Vector v = toBitsVector(); + public final IntShuffle128 wrapIndexes() { + IntVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Int128Shuffle) v.toShuffle(vspecies(), false); + return (IntShuffle128) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -949,14 +956,14 @@ final class Int128Vector extends IntVector { @Override final IntVector fromArray0(int[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Int128Mask.class, a, offset, (Int128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(IntMask128.class, a, offset, (IntMask128) m, offsetInRange); // specialize } @ForceInline @Override final IntVector fromArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Int128Mask.class, a, offset, indexMap, mapOffset, (Int128Mask) m); + return super.fromArray0Template(IntMask128.class, a, offset, indexMap, mapOffset, (IntMask128) m); } @@ -972,7 +979,7 @@ final class Int128Vector extends IntVector { @Override final IntVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Int128Mask.class, ms, offset, (Int128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(IntMask128.class, ms, offset, (IntMask128) m, offsetInRange); // specialize } @ForceInline @@ -986,14 +993,14 @@ final class Int128Vector extends IntVector { @Override final void intoArray0(int[] a, int offset, VectorMask m) { - super.intoArray0Template(Int128Mask.class, a, offset, (Int128Mask) m); + super.intoArray0Template(IntMask128.class, a, offset, (IntMask128) m); } @ForceInline @Override final void intoArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Int128Mask.class, a, offset, indexMap, mapOffset, (Int128Mask) m); + super.intoArray0Template(IntMask128.class, a, offset, indexMap, mapOffset, (IntMask128) m); } @@ -1001,7 +1008,7 @@ final class Int128Vector extends IntVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Int128Mask.class, ms, offset, (Int128Mask) m); + super.intoMemorySegment0Template(IntMask128.class, ms, offset, (IntMask128) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector256.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector256.java index f9700fbfd71..58a1667d2ac 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector256.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Int256Vector extends IntVector { +@ValueBased +final class IntVector256 extends IntVector { static final IntSpecies VSPECIES = (IntSpecies) IntVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Int256Vector.class; + static final Class VCLASS = IntVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + static final Class ETYPE = int.class; // used by the JVM - Int256Vector(int[] v) { + IntVector256(int[] v) { super(v); } - // For compatibility as Int256Vector::new, + // For compatibility as IntVector256::new, // stored into species.vectorFactory. - Int256Vector(Object v) { + IntVector256(Object v) { this((int[]) v); } - static final Int256Vector ZERO = new Int256Vector(new int[VLENGTH]); - static final Int256Vector IOTA = new Int256Vector(VSPECIES.iotaArray()); + static final IntVector256 ZERO = new IntVector256(new int[VLENGTH]); + static final IntVector256 IOTA = new IntVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Int256Vector extends IntVector { @Override public final Class elementType() { return int.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Integer.SIZE; } @@ -130,51 +135,51 @@ final class Int256Vector extends IntVector { @Override @ForceInline - public final Int256Vector broadcast(int e) { - return (Int256Vector) super.broadcastTemplate(e); // specialize + public final IntVector256 broadcast(int e) { + return (IntVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Int256Vector broadcast(long e) { - return (Int256Vector) super.broadcastTemplate(e); // specialize + public final IntVector256 broadcast(long e) { + return (IntVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Int256Mask maskFromArray(boolean[] bits) { - return new Int256Mask(bits); + IntMask256 maskFromArray(boolean[] bits) { + return new IntMask256(bits); } @Override @ForceInline - Int256Shuffle iotaShuffle() { return Int256Shuffle.IOTA; } + IntShuffle256 iotaShuffle() { return IntShuffle256.IOTA; } @Override @ForceInline - Int256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Int256Shuffle) iotaShuffleTemplate(start, step, wrap); + IntShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (IntShuffle256) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Int256Shuffle shuffleFromArray(int[] indices, int i) { return new Int256Shuffle(indices, i); } + IntShuffle256 shuffleFromArray(int[] indices, int i) { return new IntShuffle256(indices, i); } @Override @ForceInline - Int256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Int256Shuffle(fn); } + IntShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new IntShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Int256Vector vectorFactory(int[] vec) { - return new Int256Vector(vec); + IntVector256 vectorFactory(int[] vec) { + return new IntVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Int256Vector extends IntVector { @ForceInline final @Override - Int256Vector uOp(FUnOp f) { - return (Int256Vector) super.uOpTemplate(f); // specialize + IntVector256 uOp(FUnOp f) { + return (IntVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Int256Vector uOp(VectorMask m, FUnOp f) { - return (Int256Vector) - super.uOpTemplate((Int256Mask)m, f); // specialize + IntVector256 uOp(VectorMask m, FUnOp f) { + return (IntVector256) + super.uOpTemplate((IntMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Int256Vector bOp(Vector v, FBinOp f) { - return (Int256Vector) super.bOpTemplate((Int256Vector)v, f); // specialize + IntVector256 bOp(Vector v, FBinOp f) { + return (IntVector256) super.bOpTemplate((IntVector256)v, f); // specialize } @ForceInline final @Override - Int256Vector bOp(Vector v, + IntVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Int256Vector) - super.bOpTemplate((Int256Vector)v, (Int256Mask)m, + return (IntVector256) + super.bOpTemplate((IntVector256)v, (IntMask256)m, f); // specialize } @@ -219,19 +224,19 @@ final class Int256Vector extends IntVector { @ForceInline final @Override - Int256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Int256Vector) - super.tOpTemplate((Int256Vector)v1, (Int256Vector)v2, + IntVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (IntVector256) + super.tOpTemplate((IntVector256)v1, (IntVector256)v2, f); // specialize } @ForceInline final @Override - Int256Vector tOp(Vector v1, Vector v2, + IntVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Int256Vector) - super.tOpTemplate((Int256Vector)v1, (Int256Vector)v2, - (Int256Mask)m, f); // specialize + return (IntVector256) + super.tOpTemplate((IntVector256)v1, (IntVector256)v2, + (IntMask256)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Int256Vector extends IntVector { @Override @ForceInline - public Int256Vector lanewise(Unary op) { - return (Int256Vector) super.lanewiseTemplate(op); // specialize + public IntVector256 lanewise(Unary op) { + return (IntVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Int256Vector lanewise(Unary op, VectorMask m) { - return (Int256Vector) super.lanewiseTemplate(op, Int256Mask.class, (Int256Mask) m); // specialize + public IntVector256 lanewise(Unary op, VectorMask m) { + return (IntVector256) super.lanewiseTemplate(op, IntMask256.class, (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector lanewise(Binary op, Vector v) { - return (Int256Vector) super.lanewiseTemplate(op, v); // specialize + public IntVector256 lanewise(Binary op, Vector v) { + return (IntVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Int256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Int256Vector) super.lanewiseTemplate(op, Int256Mask.class, v, (Int256Mask) m); // specialize + public IntVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (IntVector256) super.lanewiseTemplate(op, IntMask256.class, v, (IntMask256) m); // specialize } /*package-private*/ @Override - @ForceInline Int256Vector + @ForceInline IntVector256 lanewiseShift(VectorOperators.Binary op, int e) { - return (Int256Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (IntVector256) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Int256Vector + @ForceInline IntVector256 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Int256Vector) super.lanewiseShiftTemplate(op, Int256Mask.class, e, (Int256Mask) m); // specialize + return (IntVector256) super.lanewiseShiftTemplate(op, IntMask256.class, e, (IntMask256) m); // specialize } /*package-private*/ @Override @ForceInline public final - Int256Vector + IntVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Int256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (IntVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Int256Vector + IntVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Int256Vector) super.lanewiseTemplate(op, Int256Mask.class, v1, v2, (Int256Mask) m); // specialize + return (IntVector256) super.lanewiseTemplate(op, IntMask256.class, v1, v2, (IntMask256) m); // specialize } @Override @ForceInline public final - Int256Vector addIndex(int scale) { - return (Int256Vector) super.addIndexTemplate(scale); // specialize + IntVector256 addIndex(int scale) { + return (IntVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Int256Vector extends IntVector { @ForceInline public final int reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Int256Mask.class, (Int256Mask) m); // specialized + return super.reduceLanesTemplate(op, IntMask256.class, (IntMask256) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Int256Vector extends IntVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Int256Mask.class, (Int256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, IntMask256.class, (IntMask256) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Int256Vector extends IntVector { @Override @ForceInline - public final Int256Shuffle toShuffle() { - return (Int256Shuffle) toShuffle(vspecies(), false); + public final IntShuffle256 toShuffle() { + return (IntShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Int256Mask test(Test op) { - return super.testTemplate(Int256Mask.class, op); // specialize + public final IntMask256 test(Test op) { + return super.testTemplate(IntMask256.class, op); // specialize } @Override @ForceInline - public final Int256Mask test(Test op, VectorMask m) { - return super.testTemplate(Int256Mask.class, op, (Int256Mask) m); // specialize + public final IntMask256 test(Test op, VectorMask m) { + return super.testTemplate(IntMask256.class, op, (IntMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Int256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Int256Mask.class, op, v); // specialize + public final IntMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(IntMask256.class, op, v); // specialize } @Override @ForceInline - public final Int256Mask compare(Comparison op, int s) { - return super.compareTemplate(Int256Mask.class, op, s); // specialize + public final IntMask256 compare(Comparison op, int s) { + return super.compareTemplate(IntMask256.class, op, s); // specialize } @Override @ForceInline - public final Int256Mask compare(Comparison op, long s) { - return super.compareTemplate(Int256Mask.class, op, s); // specialize + public final IntMask256 compare(Comparison op, long s) { + return super.compareTemplate(IntMask256.class, op, s); // specialize } @Override @ForceInline - public final Int256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Int256Mask.class, op, v, (Int256Mask) m); + public final IntMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(IntMask256.class, op, v, (IntMask256) m); } @Override @ForceInline - public Int256Vector blend(Vector v, VectorMask m) { - return (Int256Vector) - super.blendTemplate(Int256Mask.class, - (Int256Vector) v, - (Int256Mask) m); // specialize + public IntVector256 blend(Vector v, VectorMask m) { + return (IntVector256) + super.blendTemplate(IntMask256.class, + (IntVector256) v, + (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector slice(int origin, Vector v) { - return (Int256Vector) super.sliceTemplate(origin, v); // specialize + public IntVector256 slice(int origin, Vector v) { + return (IntVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Int256Vector slice(int origin) { - return (Int256Vector) super.sliceTemplate(origin); // specialize + public IntVector256 slice(int origin) { + return (IntVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Int256Vector unslice(int origin, Vector w, int part) { - return (Int256Vector) super.unsliceTemplate(origin, w, part); // specialize + public IntVector256 unslice(int origin, Vector w, int part) { + return (IntVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Int256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Int256Vector) - super.unsliceTemplate(Int256Mask.class, + public IntVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (IntVector256) + super.unsliceTemplate(IntMask256.class, origin, w, part, - (Int256Mask) m); // specialize + (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector unslice(int origin) { - return (Int256Vector) super.unsliceTemplate(origin); // specialize + public IntVector256 unslice(int origin) { + return (IntVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Int256Vector rearrange(VectorShuffle s) { - return (Int256Vector) - super.rearrangeTemplate(Int256Shuffle.class, - (Int256Shuffle) s); // specialize + public IntVector256 rearrange(VectorShuffle s) { + return (IntVector256) + super.rearrangeTemplate(IntShuffle256.class, + (IntShuffle256) s); // specialize } @Override @ForceInline - public Int256Vector rearrange(VectorShuffle shuffle, + public IntVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Int256Vector) - super.rearrangeTemplate(Int256Shuffle.class, - Int256Mask.class, - (Int256Shuffle) shuffle, - (Int256Mask) m); // specialize + return (IntVector256) + super.rearrangeTemplate(IntShuffle256.class, + IntMask256.class, + (IntShuffle256) shuffle, + (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector rearrange(VectorShuffle s, + public IntVector256 rearrange(VectorShuffle s, Vector v) { - return (Int256Vector) - super.rearrangeTemplate(Int256Shuffle.class, - (Int256Shuffle) s, - (Int256Vector) v); // specialize + return (IntVector256) + super.rearrangeTemplate(IntShuffle256.class, + (IntShuffle256) s, + (IntVector256) v); // specialize } @Override @ForceInline - public Int256Vector compress(VectorMask m) { - return (Int256Vector) - super.compressTemplate(Int256Mask.class, - (Int256Mask) m); // specialize + public IntVector256 compress(VectorMask m) { + return (IntVector256) + super.compressTemplate(IntMask256.class, + (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector expand(VectorMask m) { - return (Int256Vector) - super.expandTemplate(Int256Mask.class, - (Int256Mask) m); // specialize + public IntVector256 expand(VectorMask m) { + return (IntVector256) + super.expandTemplate(IntMask256.class, + (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector selectFrom(Vector v) { - return (Int256Vector) - super.selectFromTemplate((Int256Vector) v); // specialize + public IntVector256 selectFrom(Vector v) { + return (IntVector256) + super.selectFromTemplate((IntVector256) v); // specialize } @Override @ForceInline - public Int256Vector selectFrom(Vector v, + public IntVector256 selectFrom(Vector v, VectorMask m) { - return (Int256Vector) - super.selectFromTemplate((Int256Vector) v, - Int256Mask.class, (Int256Mask) m); // specialize + return (IntVector256) + super.selectFromTemplate((IntVector256) v, + IntMask256.class, (IntMask256) m); // specialize } @Override @ForceInline - public Int256Vector selectFrom(Vector v1, + public IntVector256 selectFrom(Vector v1, Vector v2) { - return (Int256Vector) - super.selectFromTemplate((Int256Vector) v1, (Int256Vector) v2); // specialize + return (IntVector256) + super.selectFromTemplate((IntVector256) v1, (IntVector256) v2); // specialize } @ForceInline @@ -550,7 +555,7 @@ final class Int256Vector extends IntVector { @ForceInline @Override - public Int256Vector withLane(int i, int e) { + public IntVector256 withLane(int i, int e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -565,7 +570,7 @@ final class Int256Vector extends IntVector { } @ForceInline - public Int256Vector withLaneHelper(int i, int e) { + public IntVector256 withLaneHelper(int i, int e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -577,20 +582,21 @@ final class Int256Vector extends IntVector { } // Mask - - static final class Int256Mask extends AbstractMask { + @ValueBased + static final class IntMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int256Mask(boolean[] bits) { + static final Class CTYPE = int.class; // used by the JVM + + IntMask256(boolean[] bits) { this(bits, 0); } - Int256Mask(boolean[] bits, int offset) { + IntMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Int256Mask(boolean val) { + IntMask256(boolean val) { super(prepare(val)); } @@ -623,31 +629,31 @@ final class Int256Vector extends IntVector { } @Override - Int256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Int256Mask(res); + return new IntMask256(res); } @Override - Int256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Int256Mask)m).getBits(); + boolean[] mbits = ((IntMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Int256Mask(res); + return new IntMask256(res); } @ForceInline @Override public final - Int256Vector toVector() { - return (Int256Vector) super.toVectorTemplate(); // specialize + IntVector256 toVector() { + return (IntVector256) super.toVectorTemplate(); // specialize } /** @@ -680,25 +686,25 @@ final class Int256Vector extends IntVector { @Override @ForceInline /*package-private*/ - Int256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Int256Mask) VectorSupport.indexPartiallyInUpperRange( - Int256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Int256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + IntMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (IntMask256) VectorSupport.indexPartiallyInUpperRange( + IntMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (IntMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Int256Mask not() { + public IntMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Int256Mask compress() { - return (Int256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int256Vector.class, Int256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public IntMask256 compress() { + return (IntMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + IntVector256.class, IntMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -707,30 +713,30 @@ final class Int256Vector extends IntVector { @Override @ForceInline - public Int256Mask and(VectorMask mask) { + public IntMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask256 m = (IntMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Int256Mask or(VectorMask mask) { + public IntMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask256 m = (IntMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Int256Mask xor(VectorMask mask) { + public IntMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask256 m = (IntMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -740,21 +746,21 @@ final class Int256Vector extends IntVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -764,7 +770,7 @@ final class Int256Vector extends IntVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -774,7 +780,7 @@ final class Int256Vector extends IntVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(IntMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -783,48 +789,49 @@ final class Int256Vector extends IntVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int256Mask)m).getBits())); + return VectorSupport.test(BT_ne, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((IntMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((IntMask256)m).getBits())); } @ForceInline /*package-private*/ - static Int256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static IntMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(IntMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Int256Mask TRUE_MASK = new Int256Mask(true); - private static final Int256Mask FALSE_MASK = new Int256Mask(false); + private static final IntMask256 TRUE_MASK = new IntMask256(true); + private static final IntMask256 FALSE_MASK = new IntMask256(false); } // Shuffle - - static final class Int256Shuffle extends AbstractShuffle { + @ValueBased + static final class IntShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int256Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + IntShuffle256(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Int256Shuffle(int[] indices, int i) { + IntShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Int256Shuffle(IntUnaryOperator fn) { + IntShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -844,23 +851,23 @@ final class Int256Vector extends IntVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Int256Shuffle IOTA = new Int256Shuffle(IDENTITY); + static final IntShuffle256 IOTA = new IntShuffle256(IDENTITY); @Override @ForceInline - public Int256Vector toVector() { + public IntVector256 toVector() { return toBitsVector(); } @Override @ForceInline - Int256Vector toBitsVector() { - return (Int256Vector) super.toBitsVectorTemplate(); + IntVector256 toBitsVector() { + return (IntVector256) super.toBitsVectorTemplate(); } @Override - Int256Vector toBitsVector0() { - return ((Int256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector256 toBitsVector0() { + return ((IntVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -883,30 +890,30 @@ final class Int256Vector extends IntVector { @Override @ForceInline - public final Int256Mask laneIsValid() { - return (Int256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final IntMask256 laneIsValid() { + return (IntMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Int256Shuffle rearrange(VectorShuffle shuffle) { - Int256Shuffle concreteShuffle = (Int256Shuffle) shuffle; - return (Int256Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final IntShuffle256 rearrange(VectorShuffle shuffle) { + IntShuffle256 concreteShuffle = (IntShuffle256) shuffle; + return (IntShuffle256) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Int256Shuffle wrapIndexes() { - Int256Vector v = toBitsVector(); + public final IntShuffle256 wrapIndexes() { + IntVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Int256Shuffle) v.toShuffle(vspecies(), false); + return (IntShuffle256) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -957,14 +964,14 @@ final class Int256Vector extends IntVector { @Override final IntVector fromArray0(int[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Int256Mask.class, a, offset, (Int256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(IntMask256.class, a, offset, (IntMask256) m, offsetInRange); // specialize } @ForceInline @Override final IntVector fromArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Int256Mask.class, a, offset, indexMap, mapOffset, (Int256Mask) m); + return super.fromArray0Template(IntMask256.class, a, offset, indexMap, mapOffset, (IntMask256) m); } @@ -980,7 +987,7 @@ final class Int256Vector extends IntVector { @Override final IntVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Int256Mask.class, ms, offset, (Int256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(IntMask256.class, ms, offset, (IntMask256) m, offsetInRange); // specialize } @ForceInline @@ -994,14 +1001,14 @@ final class Int256Vector extends IntVector { @Override final void intoArray0(int[] a, int offset, VectorMask m) { - super.intoArray0Template(Int256Mask.class, a, offset, (Int256Mask) m); + super.intoArray0Template(IntMask256.class, a, offset, (IntMask256) m); } @ForceInline @Override final void intoArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Int256Mask.class, a, offset, indexMap, mapOffset, (Int256Mask) m); + super.intoArray0Template(IntMask256.class, a, offset, indexMap, mapOffset, (IntMask256) m); } @@ -1009,7 +1016,7 @@ final class Int256Vector extends IntVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Int256Mask.class, ms, offset, (Int256Mask) m); + super.intoMemorySegment0Template(IntMask256.class, ms, offset, (IntMask256) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector512.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector512.java index 2e2ee7eac05..ac48e589a05 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector512.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Int512Vector extends IntVector { +@ValueBased +final class IntVector512 extends IntVector { static final IntSpecies VSPECIES = (IntSpecies) IntVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Int512Vector.class; + static final Class VCLASS = IntVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + static final Class ETYPE = int.class; // used by the JVM - Int512Vector(int[] v) { + IntVector512(int[] v) { super(v); } - // For compatibility as Int512Vector::new, + // For compatibility as IntVector512::new, // stored into species.vectorFactory. - Int512Vector(Object v) { + IntVector512(Object v) { this((int[]) v); } - static final Int512Vector ZERO = new Int512Vector(new int[VLENGTH]); - static final Int512Vector IOTA = new Int512Vector(VSPECIES.iotaArray()); + static final IntVector512 ZERO = new IntVector512(new int[VLENGTH]); + static final IntVector512 IOTA = new IntVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Int512Vector extends IntVector { @Override public final Class elementType() { return int.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Integer.SIZE; } @@ -130,51 +135,51 @@ final class Int512Vector extends IntVector { @Override @ForceInline - public final Int512Vector broadcast(int e) { - return (Int512Vector) super.broadcastTemplate(e); // specialize + public final IntVector512 broadcast(int e) { + return (IntVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Int512Vector broadcast(long e) { - return (Int512Vector) super.broadcastTemplate(e); // specialize + public final IntVector512 broadcast(long e) { + return (IntVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Int512Mask maskFromArray(boolean[] bits) { - return new Int512Mask(bits); + IntMask512 maskFromArray(boolean[] bits) { + return new IntMask512(bits); } @Override @ForceInline - Int512Shuffle iotaShuffle() { return Int512Shuffle.IOTA; } + IntShuffle512 iotaShuffle() { return IntShuffle512.IOTA; } @Override @ForceInline - Int512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Int512Shuffle) iotaShuffleTemplate(start, step, wrap); + IntShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (IntShuffle512) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Int512Shuffle shuffleFromArray(int[] indices, int i) { return new Int512Shuffle(indices, i); } + IntShuffle512 shuffleFromArray(int[] indices, int i) { return new IntShuffle512(indices, i); } @Override @ForceInline - Int512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Int512Shuffle(fn); } + IntShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new IntShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Int512Vector vectorFactory(int[] vec) { - return new Int512Vector(vec); + IntVector512 vectorFactory(int[] vec) { + return new IntVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Int512Vector extends IntVector { @ForceInline final @Override - Int512Vector uOp(FUnOp f) { - return (Int512Vector) super.uOpTemplate(f); // specialize + IntVector512 uOp(FUnOp f) { + return (IntVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Int512Vector uOp(VectorMask m, FUnOp f) { - return (Int512Vector) - super.uOpTemplate((Int512Mask)m, f); // specialize + IntVector512 uOp(VectorMask m, FUnOp f) { + return (IntVector512) + super.uOpTemplate((IntMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Int512Vector bOp(Vector v, FBinOp f) { - return (Int512Vector) super.bOpTemplate((Int512Vector)v, f); // specialize + IntVector512 bOp(Vector v, FBinOp f) { + return (IntVector512) super.bOpTemplate((IntVector512)v, f); // specialize } @ForceInline final @Override - Int512Vector bOp(Vector v, + IntVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Int512Vector) - super.bOpTemplate((Int512Vector)v, (Int512Mask)m, + return (IntVector512) + super.bOpTemplate((IntVector512)v, (IntMask512)m, f); // specialize } @@ -219,19 +224,19 @@ final class Int512Vector extends IntVector { @ForceInline final @Override - Int512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Int512Vector) - super.tOpTemplate((Int512Vector)v1, (Int512Vector)v2, + IntVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (IntVector512) + super.tOpTemplate((IntVector512)v1, (IntVector512)v2, f); // specialize } @ForceInline final @Override - Int512Vector tOp(Vector v1, Vector v2, + IntVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Int512Vector) - super.tOpTemplate((Int512Vector)v1, (Int512Vector)v2, - (Int512Mask)m, f); // specialize + return (IntVector512) + super.tOpTemplate((IntVector512)v1, (IntVector512)v2, + (IntMask512)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Int512Vector extends IntVector { @Override @ForceInline - public Int512Vector lanewise(Unary op) { - return (Int512Vector) super.lanewiseTemplate(op); // specialize + public IntVector512 lanewise(Unary op) { + return (IntVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Int512Vector lanewise(Unary op, VectorMask m) { - return (Int512Vector) super.lanewiseTemplate(op, Int512Mask.class, (Int512Mask) m); // specialize + public IntVector512 lanewise(Unary op, VectorMask m) { + return (IntVector512) super.lanewiseTemplate(op, IntMask512.class, (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector lanewise(Binary op, Vector v) { - return (Int512Vector) super.lanewiseTemplate(op, v); // specialize + public IntVector512 lanewise(Binary op, Vector v) { + return (IntVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Int512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Int512Vector) super.lanewiseTemplate(op, Int512Mask.class, v, (Int512Mask) m); // specialize + public IntVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (IntVector512) super.lanewiseTemplate(op, IntMask512.class, v, (IntMask512) m); // specialize } /*package-private*/ @Override - @ForceInline Int512Vector + @ForceInline IntVector512 lanewiseShift(VectorOperators.Binary op, int e) { - return (Int512Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (IntVector512) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Int512Vector + @ForceInline IntVector512 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Int512Vector) super.lanewiseShiftTemplate(op, Int512Mask.class, e, (Int512Mask) m); // specialize + return (IntVector512) super.lanewiseShiftTemplate(op, IntMask512.class, e, (IntMask512) m); // specialize } /*package-private*/ @Override @ForceInline public final - Int512Vector + IntVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Int512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (IntVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Int512Vector + IntVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Int512Vector) super.lanewiseTemplate(op, Int512Mask.class, v1, v2, (Int512Mask) m); // specialize + return (IntVector512) super.lanewiseTemplate(op, IntMask512.class, v1, v2, (IntMask512) m); // specialize } @Override @ForceInline public final - Int512Vector addIndex(int scale) { - return (Int512Vector) super.addIndexTemplate(scale); // specialize + IntVector512 addIndex(int scale) { + return (IntVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Int512Vector extends IntVector { @ForceInline public final int reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Int512Mask.class, (Int512Mask) m); // specialized + return super.reduceLanesTemplate(op, IntMask512.class, (IntMask512) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Int512Vector extends IntVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Int512Mask.class, (Int512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, IntMask512.class, (IntMask512) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Int512Vector extends IntVector { @Override @ForceInline - public final Int512Shuffle toShuffle() { - return (Int512Shuffle) toShuffle(vspecies(), false); + public final IntShuffle512 toShuffle() { + return (IntShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Int512Mask test(Test op) { - return super.testTemplate(Int512Mask.class, op); // specialize + public final IntMask512 test(Test op) { + return super.testTemplate(IntMask512.class, op); // specialize } @Override @ForceInline - public final Int512Mask test(Test op, VectorMask m) { - return super.testTemplate(Int512Mask.class, op, (Int512Mask) m); // specialize + public final IntMask512 test(Test op, VectorMask m) { + return super.testTemplate(IntMask512.class, op, (IntMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Int512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Int512Mask.class, op, v); // specialize + public final IntMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(IntMask512.class, op, v); // specialize } @Override @ForceInline - public final Int512Mask compare(Comparison op, int s) { - return super.compareTemplate(Int512Mask.class, op, s); // specialize + public final IntMask512 compare(Comparison op, int s) { + return super.compareTemplate(IntMask512.class, op, s); // specialize } @Override @ForceInline - public final Int512Mask compare(Comparison op, long s) { - return super.compareTemplate(Int512Mask.class, op, s); // specialize + public final IntMask512 compare(Comparison op, long s) { + return super.compareTemplate(IntMask512.class, op, s); // specialize } @Override @ForceInline - public final Int512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Int512Mask.class, op, v, (Int512Mask) m); + public final IntMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(IntMask512.class, op, v, (IntMask512) m); } @Override @ForceInline - public Int512Vector blend(Vector v, VectorMask m) { - return (Int512Vector) - super.blendTemplate(Int512Mask.class, - (Int512Vector) v, - (Int512Mask) m); // specialize + public IntVector512 blend(Vector v, VectorMask m) { + return (IntVector512) + super.blendTemplate(IntMask512.class, + (IntVector512) v, + (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector slice(int origin, Vector v) { - return (Int512Vector) super.sliceTemplate(origin, v); // specialize + public IntVector512 slice(int origin, Vector v) { + return (IntVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Int512Vector slice(int origin) { - return (Int512Vector) super.sliceTemplate(origin); // specialize + public IntVector512 slice(int origin) { + return (IntVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Int512Vector unslice(int origin, Vector w, int part) { - return (Int512Vector) super.unsliceTemplate(origin, w, part); // specialize + public IntVector512 unslice(int origin, Vector w, int part) { + return (IntVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Int512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Int512Vector) - super.unsliceTemplate(Int512Mask.class, + public IntVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (IntVector512) + super.unsliceTemplate(IntMask512.class, origin, w, part, - (Int512Mask) m); // specialize + (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector unslice(int origin) { - return (Int512Vector) super.unsliceTemplate(origin); // specialize + public IntVector512 unslice(int origin) { + return (IntVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Int512Vector rearrange(VectorShuffle s) { - return (Int512Vector) - super.rearrangeTemplate(Int512Shuffle.class, - (Int512Shuffle) s); // specialize + public IntVector512 rearrange(VectorShuffle s) { + return (IntVector512) + super.rearrangeTemplate(IntShuffle512.class, + (IntShuffle512) s); // specialize } @Override @ForceInline - public Int512Vector rearrange(VectorShuffle shuffle, + public IntVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Int512Vector) - super.rearrangeTemplate(Int512Shuffle.class, - Int512Mask.class, - (Int512Shuffle) shuffle, - (Int512Mask) m); // specialize + return (IntVector512) + super.rearrangeTemplate(IntShuffle512.class, + IntMask512.class, + (IntShuffle512) shuffle, + (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector rearrange(VectorShuffle s, + public IntVector512 rearrange(VectorShuffle s, Vector v) { - return (Int512Vector) - super.rearrangeTemplate(Int512Shuffle.class, - (Int512Shuffle) s, - (Int512Vector) v); // specialize + return (IntVector512) + super.rearrangeTemplate(IntShuffle512.class, + (IntShuffle512) s, + (IntVector512) v); // specialize } @Override @ForceInline - public Int512Vector compress(VectorMask m) { - return (Int512Vector) - super.compressTemplate(Int512Mask.class, - (Int512Mask) m); // specialize + public IntVector512 compress(VectorMask m) { + return (IntVector512) + super.compressTemplate(IntMask512.class, + (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector expand(VectorMask m) { - return (Int512Vector) - super.expandTemplate(Int512Mask.class, - (Int512Mask) m); // specialize + public IntVector512 expand(VectorMask m) { + return (IntVector512) + super.expandTemplate(IntMask512.class, + (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector selectFrom(Vector v) { - return (Int512Vector) - super.selectFromTemplate((Int512Vector) v); // specialize + public IntVector512 selectFrom(Vector v) { + return (IntVector512) + super.selectFromTemplate((IntVector512) v); // specialize } @Override @ForceInline - public Int512Vector selectFrom(Vector v, + public IntVector512 selectFrom(Vector v, VectorMask m) { - return (Int512Vector) - super.selectFromTemplate((Int512Vector) v, - Int512Mask.class, (Int512Mask) m); // specialize + return (IntVector512) + super.selectFromTemplate((IntVector512) v, + IntMask512.class, (IntMask512) m); // specialize } @Override @ForceInline - public Int512Vector selectFrom(Vector v1, + public IntVector512 selectFrom(Vector v1, Vector v2) { - return (Int512Vector) - super.selectFromTemplate((Int512Vector) v1, (Int512Vector) v2); // specialize + return (IntVector512) + super.selectFromTemplate((IntVector512) v1, (IntVector512) v2); // specialize } @ForceInline @@ -558,7 +563,7 @@ final class Int512Vector extends IntVector { @ForceInline @Override - public Int512Vector withLane(int i, int e) { + public IntVector512 withLane(int i, int e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -581,7 +586,7 @@ final class Int512Vector extends IntVector { } @ForceInline - public Int512Vector withLaneHelper(int i, int e) { + public IntVector512 withLaneHelper(int i, int e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -593,20 +598,21 @@ final class Int512Vector extends IntVector { } // Mask - - static final class Int512Mask extends AbstractMask { + @ValueBased + static final class IntMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int512Mask(boolean[] bits) { + static final Class CTYPE = int.class; // used by the JVM + + IntMask512(boolean[] bits) { this(bits, 0); } - Int512Mask(boolean[] bits, int offset) { + IntMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Int512Mask(boolean val) { + IntMask512(boolean val) { super(prepare(val)); } @@ -639,31 +645,31 @@ final class Int512Vector extends IntVector { } @Override - Int512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Int512Mask(res); + return new IntMask512(res); } @Override - Int512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Int512Mask)m).getBits(); + boolean[] mbits = ((IntMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Int512Mask(res); + return new IntMask512(res); } @ForceInline @Override public final - Int512Vector toVector() { - return (Int512Vector) super.toVectorTemplate(); // specialize + IntVector512 toVector() { + return (IntVector512) super.toVectorTemplate(); // specialize } /** @@ -696,25 +702,25 @@ final class Int512Vector extends IntVector { @Override @ForceInline /*package-private*/ - Int512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Int512Mask) VectorSupport.indexPartiallyInUpperRange( - Int512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Int512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + IntMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (IntMask512) VectorSupport.indexPartiallyInUpperRange( + IntMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (IntMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Int512Mask not() { + public IntMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Int512Mask compress() { - return (Int512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int512Vector.class, Int512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public IntMask512 compress() { + return (IntMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + IntVector512.class, IntMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -723,30 +729,30 @@ final class Int512Vector extends IntVector { @Override @ForceInline - public Int512Mask and(VectorMask mask) { + public IntMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask512 m = (IntMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Int512Mask or(VectorMask mask) { + public IntMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask512 m = (IntMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Int512Mask xor(VectorMask mask) { + public IntMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask512 m = (IntMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -756,21 +762,21 @@ final class Int512Vector extends IntVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -780,7 +786,7 @@ final class Int512Vector extends IntVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -790,7 +796,7 @@ final class Int512Vector extends IntVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(IntMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -799,48 +805,49 @@ final class Int512Vector extends IntVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int512Mask)m).getBits())); + return VectorSupport.test(BT_ne, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((IntMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((IntMask512)m).getBits())); } @ForceInline /*package-private*/ - static Int512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static IntMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(IntMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Int512Mask TRUE_MASK = new Int512Mask(true); - private static final Int512Mask FALSE_MASK = new Int512Mask(false); + private static final IntMask512 TRUE_MASK = new IntMask512(true); + private static final IntMask512 FALSE_MASK = new IntMask512(false); } // Shuffle - - static final class Int512Shuffle extends AbstractShuffle { + @ValueBased + static final class IntShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int512Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + IntShuffle512(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Int512Shuffle(int[] indices, int i) { + IntShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Int512Shuffle(IntUnaryOperator fn) { + IntShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -860,23 +867,23 @@ final class Int512Vector extends IntVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Int512Shuffle IOTA = new Int512Shuffle(IDENTITY); + static final IntShuffle512 IOTA = new IntShuffle512(IDENTITY); @Override @ForceInline - public Int512Vector toVector() { + public IntVector512 toVector() { return toBitsVector(); } @Override @ForceInline - Int512Vector toBitsVector() { - return (Int512Vector) super.toBitsVectorTemplate(); + IntVector512 toBitsVector() { + return (IntVector512) super.toBitsVectorTemplate(); } @Override - Int512Vector toBitsVector0() { - return ((Int512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector512 toBitsVector0() { + return ((IntVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -899,30 +906,30 @@ final class Int512Vector extends IntVector { @Override @ForceInline - public final Int512Mask laneIsValid() { - return (Int512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final IntMask512 laneIsValid() { + return (IntMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Int512Shuffle rearrange(VectorShuffle shuffle) { - Int512Shuffle concreteShuffle = (Int512Shuffle) shuffle; - return (Int512Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final IntShuffle512 rearrange(VectorShuffle shuffle) { + IntShuffle512 concreteShuffle = (IntShuffle512) shuffle; + return (IntShuffle512) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Int512Shuffle wrapIndexes() { - Int512Vector v = toBitsVector(); + public final IntShuffle512 wrapIndexes() { + IntVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Int512Shuffle) v.toShuffle(vspecies(), false); + return (IntShuffle512) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -973,14 +980,14 @@ final class Int512Vector extends IntVector { @Override final IntVector fromArray0(int[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Int512Mask.class, a, offset, (Int512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(IntMask512.class, a, offset, (IntMask512) m, offsetInRange); // specialize } @ForceInline @Override final IntVector fromArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Int512Mask.class, a, offset, indexMap, mapOffset, (Int512Mask) m); + return super.fromArray0Template(IntMask512.class, a, offset, indexMap, mapOffset, (IntMask512) m); } @@ -996,7 +1003,7 @@ final class Int512Vector extends IntVector { @Override final IntVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Int512Mask.class, ms, offset, (Int512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(IntMask512.class, ms, offset, (IntMask512) m, offsetInRange); // specialize } @ForceInline @@ -1010,14 +1017,14 @@ final class Int512Vector extends IntVector { @Override final void intoArray0(int[] a, int offset, VectorMask m) { - super.intoArray0Template(Int512Mask.class, a, offset, (Int512Mask) m); + super.intoArray0Template(IntMask512.class, a, offset, (IntMask512) m); } @ForceInline @Override final void intoArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Int512Mask.class, a, offset, indexMap, mapOffset, (Int512Mask) m); + super.intoArray0Template(IntMask512.class, a, offset, indexMap, mapOffset, (IntMask512) m); } @@ -1025,7 +1032,7 @@ final class Int512Vector extends IntVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Int512Mask.class, ms, offset, (Int512Mask) m); + super.intoMemorySegment0Template(IntMask512.class, ms, offset, (IntMask512) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector64.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector64.java index 8338799c61a..25329aa81aa 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector64.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Int64Vector extends IntVector { +@ValueBased +final class IntVector64 extends IntVector { static final IntSpecies VSPECIES = (IntSpecies) IntVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Int64Vector.class; + static final Class VCLASS = IntVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + static final Class ETYPE = int.class; // used by the JVM - Int64Vector(int[] v) { + IntVector64(int[] v) { super(v); } - // For compatibility as Int64Vector::new, + // For compatibility as IntVector64::new, // stored into species.vectorFactory. - Int64Vector(Object v) { + IntVector64(Object v) { this((int[]) v); } - static final Int64Vector ZERO = new Int64Vector(new int[VLENGTH]); - static final Int64Vector IOTA = new Int64Vector(VSPECIES.iotaArray()); + static final IntVector64 ZERO = new IntVector64(new int[VLENGTH]); + static final IntVector64 IOTA = new IntVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Int64Vector extends IntVector { @Override public final Class elementType() { return int.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Integer.SIZE; } @@ -130,51 +135,51 @@ final class Int64Vector extends IntVector { @Override @ForceInline - public final Int64Vector broadcast(int e) { - return (Int64Vector) super.broadcastTemplate(e); // specialize + public final IntVector64 broadcast(int e) { + return (IntVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Int64Vector broadcast(long e) { - return (Int64Vector) super.broadcastTemplate(e); // specialize + public final IntVector64 broadcast(long e) { + return (IntVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Int64Mask maskFromArray(boolean[] bits) { - return new Int64Mask(bits); + IntMask64 maskFromArray(boolean[] bits) { + return new IntMask64(bits); } @Override @ForceInline - Int64Shuffle iotaShuffle() { return Int64Shuffle.IOTA; } + IntShuffle64 iotaShuffle() { return IntShuffle64.IOTA; } @Override @ForceInline - Int64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Int64Shuffle) iotaShuffleTemplate(start, step, wrap); + IntShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (IntShuffle64) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Int64Shuffle shuffleFromArray(int[] indices, int i) { return new Int64Shuffle(indices, i); } + IntShuffle64 shuffleFromArray(int[] indices, int i) { return new IntShuffle64(indices, i); } @Override @ForceInline - Int64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Int64Shuffle(fn); } + IntShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new IntShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Int64Vector vectorFactory(int[] vec) { - return new Int64Vector(vec); + IntVector64 vectorFactory(int[] vec) { + return new IntVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Int64Vector extends IntVector { @ForceInline final @Override - Int64Vector uOp(FUnOp f) { - return (Int64Vector) super.uOpTemplate(f); // specialize + IntVector64 uOp(FUnOp f) { + return (IntVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Int64Vector uOp(VectorMask m, FUnOp f) { - return (Int64Vector) - super.uOpTemplate((Int64Mask)m, f); // specialize + IntVector64 uOp(VectorMask m, FUnOp f) { + return (IntVector64) + super.uOpTemplate((IntMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Int64Vector bOp(Vector v, FBinOp f) { - return (Int64Vector) super.bOpTemplate((Int64Vector)v, f); // specialize + IntVector64 bOp(Vector v, FBinOp f) { + return (IntVector64) super.bOpTemplate((IntVector64)v, f); // specialize } @ForceInline final @Override - Int64Vector bOp(Vector v, + IntVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Int64Vector) - super.bOpTemplate((Int64Vector)v, (Int64Mask)m, + return (IntVector64) + super.bOpTemplate((IntVector64)v, (IntMask64)m, f); // specialize } @@ -219,19 +224,19 @@ final class Int64Vector extends IntVector { @ForceInline final @Override - Int64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Int64Vector) - super.tOpTemplate((Int64Vector)v1, (Int64Vector)v2, + IntVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (IntVector64) + super.tOpTemplate((IntVector64)v1, (IntVector64)v2, f); // specialize } @ForceInline final @Override - Int64Vector tOp(Vector v1, Vector v2, + IntVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Int64Vector) - super.tOpTemplate((Int64Vector)v1, (Int64Vector)v2, - (Int64Mask)m, f); // specialize + return (IntVector64) + super.tOpTemplate((IntVector64)v1, (IntVector64)v2, + (IntMask64)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Int64Vector extends IntVector { @Override @ForceInline - public Int64Vector lanewise(Unary op) { - return (Int64Vector) super.lanewiseTemplate(op); // specialize + public IntVector64 lanewise(Unary op) { + return (IntVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Int64Vector lanewise(Unary op, VectorMask m) { - return (Int64Vector) super.lanewiseTemplate(op, Int64Mask.class, (Int64Mask) m); // specialize + public IntVector64 lanewise(Unary op, VectorMask m) { + return (IntVector64) super.lanewiseTemplate(op, IntMask64.class, (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector lanewise(Binary op, Vector v) { - return (Int64Vector) super.lanewiseTemplate(op, v); // specialize + public IntVector64 lanewise(Binary op, Vector v) { + return (IntVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Int64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Int64Vector) super.lanewiseTemplate(op, Int64Mask.class, v, (Int64Mask) m); // specialize + public IntVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (IntVector64) super.lanewiseTemplate(op, IntMask64.class, v, (IntMask64) m); // specialize } /*package-private*/ @Override - @ForceInline Int64Vector + @ForceInline IntVector64 lanewiseShift(VectorOperators.Binary op, int e) { - return (Int64Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (IntVector64) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Int64Vector + @ForceInline IntVector64 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Int64Vector) super.lanewiseShiftTemplate(op, Int64Mask.class, e, (Int64Mask) m); // specialize + return (IntVector64) super.lanewiseShiftTemplate(op, IntMask64.class, e, (IntMask64) m); // specialize } /*package-private*/ @Override @ForceInline public final - Int64Vector + IntVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Int64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (IntVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Int64Vector + IntVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Int64Vector) super.lanewiseTemplate(op, Int64Mask.class, v1, v2, (Int64Mask) m); // specialize + return (IntVector64) super.lanewiseTemplate(op, IntMask64.class, v1, v2, (IntMask64) m); // specialize } @Override @ForceInline public final - Int64Vector addIndex(int scale) { - return (Int64Vector) super.addIndexTemplate(scale); // specialize + IntVector64 addIndex(int scale) { + return (IntVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Int64Vector extends IntVector { @ForceInline public final int reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Int64Mask.class, (Int64Mask) m); // specialized + return super.reduceLanesTemplate(op, IntMask64.class, (IntMask64) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Int64Vector extends IntVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Int64Mask.class, (Int64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, IntMask64.class, (IntMask64) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Int64Vector extends IntVector { @Override @ForceInline - public final Int64Shuffle toShuffle() { - return (Int64Shuffle) toShuffle(vspecies(), false); + public final IntShuffle64 toShuffle() { + return (IntShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Int64Mask test(Test op) { - return super.testTemplate(Int64Mask.class, op); // specialize + public final IntMask64 test(Test op) { + return super.testTemplate(IntMask64.class, op); // specialize } @Override @ForceInline - public final Int64Mask test(Test op, VectorMask m) { - return super.testTemplate(Int64Mask.class, op, (Int64Mask) m); // specialize + public final IntMask64 test(Test op, VectorMask m) { + return super.testTemplate(IntMask64.class, op, (IntMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Int64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Int64Mask.class, op, v); // specialize + public final IntMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(IntMask64.class, op, v); // specialize } @Override @ForceInline - public final Int64Mask compare(Comparison op, int s) { - return super.compareTemplate(Int64Mask.class, op, s); // specialize + public final IntMask64 compare(Comparison op, int s) { + return super.compareTemplate(IntMask64.class, op, s); // specialize } @Override @ForceInline - public final Int64Mask compare(Comparison op, long s) { - return super.compareTemplate(Int64Mask.class, op, s); // specialize + public final IntMask64 compare(Comparison op, long s) { + return super.compareTemplate(IntMask64.class, op, s); // specialize } @Override @ForceInline - public final Int64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Int64Mask.class, op, v, (Int64Mask) m); + public final IntMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(IntMask64.class, op, v, (IntMask64) m); } @Override @ForceInline - public Int64Vector blend(Vector v, VectorMask m) { - return (Int64Vector) - super.blendTemplate(Int64Mask.class, - (Int64Vector) v, - (Int64Mask) m); // specialize + public IntVector64 blend(Vector v, VectorMask m) { + return (IntVector64) + super.blendTemplate(IntMask64.class, + (IntVector64) v, + (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector slice(int origin, Vector v) { - return (Int64Vector) super.sliceTemplate(origin, v); // specialize + public IntVector64 slice(int origin, Vector v) { + return (IntVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Int64Vector slice(int origin) { - return (Int64Vector) super.sliceTemplate(origin); // specialize + public IntVector64 slice(int origin) { + return (IntVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Int64Vector unslice(int origin, Vector w, int part) { - return (Int64Vector) super.unsliceTemplate(origin, w, part); // specialize + public IntVector64 unslice(int origin, Vector w, int part) { + return (IntVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Int64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Int64Vector) - super.unsliceTemplate(Int64Mask.class, + public IntVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (IntVector64) + super.unsliceTemplate(IntMask64.class, origin, w, part, - (Int64Mask) m); // specialize + (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector unslice(int origin) { - return (Int64Vector) super.unsliceTemplate(origin); // specialize + public IntVector64 unslice(int origin) { + return (IntVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Int64Vector rearrange(VectorShuffle s) { - return (Int64Vector) - super.rearrangeTemplate(Int64Shuffle.class, - (Int64Shuffle) s); // specialize + public IntVector64 rearrange(VectorShuffle s) { + return (IntVector64) + super.rearrangeTemplate(IntShuffle64.class, + (IntShuffle64) s); // specialize } @Override @ForceInline - public Int64Vector rearrange(VectorShuffle shuffle, + public IntVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Int64Vector) - super.rearrangeTemplate(Int64Shuffle.class, - Int64Mask.class, - (Int64Shuffle) shuffle, - (Int64Mask) m); // specialize + return (IntVector64) + super.rearrangeTemplate(IntShuffle64.class, + IntMask64.class, + (IntShuffle64) shuffle, + (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector rearrange(VectorShuffle s, + public IntVector64 rearrange(VectorShuffle s, Vector v) { - return (Int64Vector) - super.rearrangeTemplate(Int64Shuffle.class, - (Int64Shuffle) s, - (Int64Vector) v); // specialize + return (IntVector64) + super.rearrangeTemplate(IntShuffle64.class, + (IntShuffle64) s, + (IntVector64) v); // specialize } @Override @ForceInline - public Int64Vector compress(VectorMask m) { - return (Int64Vector) - super.compressTemplate(Int64Mask.class, - (Int64Mask) m); // specialize + public IntVector64 compress(VectorMask m) { + return (IntVector64) + super.compressTemplate(IntMask64.class, + (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector expand(VectorMask m) { - return (Int64Vector) - super.expandTemplate(Int64Mask.class, - (Int64Mask) m); // specialize + public IntVector64 expand(VectorMask m) { + return (IntVector64) + super.expandTemplate(IntMask64.class, + (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector selectFrom(Vector v) { - return (Int64Vector) - super.selectFromTemplate((Int64Vector) v); // specialize + public IntVector64 selectFrom(Vector v) { + return (IntVector64) + super.selectFromTemplate((IntVector64) v); // specialize } @Override @ForceInline - public Int64Vector selectFrom(Vector v, + public IntVector64 selectFrom(Vector v, VectorMask m) { - return (Int64Vector) - super.selectFromTemplate((Int64Vector) v, - Int64Mask.class, (Int64Mask) m); // specialize + return (IntVector64) + super.selectFromTemplate((IntVector64) v, + IntMask64.class, (IntMask64) m); // specialize } @Override @ForceInline - public Int64Vector selectFrom(Vector v1, + public IntVector64 selectFrom(Vector v1, Vector v2) { - return (Int64Vector) - super.selectFromTemplate((Int64Vector) v1, (Int64Vector) v2); // specialize + return (IntVector64) + super.selectFromTemplate((IntVector64) v1, (IntVector64) v2); // specialize } @ForceInline @@ -544,7 +549,7 @@ final class Int64Vector extends IntVector { @ForceInline @Override - public Int64Vector withLane(int i, int e) { + public IntVector64 withLane(int i, int e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -553,7 +558,7 @@ final class Int64Vector extends IntVector { } @ForceInline - public Int64Vector withLaneHelper(int i, int e) { + public IntVector64 withLaneHelper(int i, int e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -565,20 +570,21 @@ final class Int64Vector extends IntVector { } // Mask - - static final class Int64Mask extends AbstractMask { + @ValueBased + static final class IntMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int64Mask(boolean[] bits) { + static final Class CTYPE = int.class; // used by the JVM + + IntMask64(boolean[] bits) { this(bits, 0); } - Int64Mask(boolean[] bits, int offset) { + IntMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Int64Mask(boolean val) { + IntMask64(boolean val) { super(prepare(val)); } @@ -611,31 +617,31 @@ final class Int64Vector extends IntVector { } @Override - Int64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Int64Mask(res); + return new IntMask64(res); } @Override - Int64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Int64Mask)m).getBits(); + boolean[] mbits = ((IntMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Int64Mask(res); + return new IntMask64(res); } @ForceInline @Override public final - Int64Vector toVector() { - return (Int64Vector) super.toVectorTemplate(); // specialize + IntVector64 toVector() { + return (IntVector64) super.toVectorTemplate(); // specialize } /** @@ -668,25 +674,25 @@ final class Int64Vector extends IntVector { @Override @ForceInline /*package-private*/ - Int64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Int64Mask) VectorSupport.indexPartiallyInUpperRange( - Int64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Int64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + IntMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (IntMask64) VectorSupport.indexPartiallyInUpperRange( + IntMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (IntMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Int64Mask not() { + public IntMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Int64Mask compress() { - return (Int64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int64Vector.class, Int64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public IntMask64 compress() { + return (IntMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + IntVector64.class, IntMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -695,30 +701,30 @@ final class Int64Vector extends IntVector { @Override @ForceInline - public Int64Mask and(VectorMask mask) { + public IntMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask64 m = (IntMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Int64Mask or(VectorMask mask) { + public IntMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask64 m = (IntMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Int64Mask xor(VectorMask mask) { + public IntMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMask64 m = (IntMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -728,21 +734,21 @@ final class Int64Vector extends IntVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -752,7 +758,7 @@ final class Int64Vector extends IntVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -762,7 +768,7 @@ final class Int64Vector extends IntVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(IntMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -771,48 +777,49 @@ final class Int64Vector extends IntVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int64Mask)m).getBits())); + return VectorSupport.test(BT_ne, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((IntMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((IntMask64)m).getBits())); } @ForceInline /*package-private*/ - static Int64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static IntMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(IntMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Int64Mask TRUE_MASK = new Int64Mask(true); - private static final Int64Mask FALSE_MASK = new Int64Mask(false); + private static final IntMask64 TRUE_MASK = new IntMask64(true); + private static final IntMask64 FALSE_MASK = new IntMask64(false); } // Shuffle - - static final class Int64Shuffle extends AbstractShuffle { + @ValueBased + static final class IntShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - Int64Shuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + IntShuffle64(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Int64Shuffle(int[] indices, int i) { + IntShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Int64Shuffle(IntUnaryOperator fn) { + IntShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -832,23 +839,23 @@ final class Int64Vector extends IntVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final Int64Shuffle IOTA = new Int64Shuffle(IDENTITY); + static final IntShuffle64 IOTA = new IntShuffle64(IDENTITY); @Override @ForceInline - public Int64Vector toVector() { + public IntVector64 toVector() { return toBitsVector(); } @Override @ForceInline - Int64Vector toBitsVector() { - return (Int64Vector) super.toBitsVectorTemplate(); + IntVector64 toBitsVector() { + return (IntVector64) super.toBitsVectorTemplate(); } @Override - Int64Vector toBitsVector0() { - return ((Int64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVector64 toBitsVector0() { + return ((IntVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -871,30 +878,30 @@ final class Int64Vector extends IntVector { @Override @ForceInline - public final Int64Mask laneIsValid() { - return (Int64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final IntMask64 laneIsValid() { + return (IntMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Int64Shuffle rearrange(VectorShuffle shuffle) { - Int64Shuffle concreteShuffle = (Int64Shuffle) shuffle; - return (Int64Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final IntShuffle64 rearrange(VectorShuffle shuffle) { + IntShuffle64 concreteShuffle = (IntShuffle64) shuffle; + return (IntShuffle64) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Int64Shuffle wrapIndexes() { - Int64Vector v = toBitsVector(); + public final IntShuffle64 wrapIndexes() { + IntVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Int64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Int64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Int64Shuffle) v.toShuffle(vspecies(), false); + return (IntShuffle64) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -945,14 +952,14 @@ final class Int64Vector extends IntVector { @Override final IntVector fromArray0(int[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Int64Mask.class, a, offset, (Int64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(IntMask64.class, a, offset, (IntMask64) m, offsetInRange); // specialize } @ForceInline @Override final IntVector fromArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Int64Mask.class, a, offset, indexMap, mapOffset, (Int64Mask) m); + return super.fromArray0Template(IntMask64.class, a, offset, indexMap, mapOffset, (IntMask64) m); } @@ -968,7 +975,7 @@ final class Int64Vector extends IntVector { @Override final IntVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Int64Mask.class, ms, offset, (Int64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(IntMask64.class, ms, offset, (IntMask64) m, offsetInRange); // specialize } @ForceInline @@ -982,14 +989,14 @@ final class Int64Vector extends IntVector { @Override final void intoArray0(int[] a, int offset, VectorMask m) { - super.intoArray0Template(Int64Mask.class, a, offset, (Int64Mask) m); + super.intoArray0Template(IntMask64.class, a, offset, (IntMask64) m); } @ForceInline @Override final void intoArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Int64Mask.class, a, offset, indexMap, mapOffset, (Int64Mask) m); + super.intoArray0Template(IntMask64.class, a, offset, indexMap, mapOffset, (IntMask64) m); } @@ -997,7 +1004,7 @@ final class Int64Vector extends IntVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Int64Mask.class, ms, offset, (Int64Mask) m); + super.intoMemorySegment0Template(IntMask64.class, ms, offset, (IntMask64) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVectorMax.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVectorMax.java index 177890e765c..348fda59381 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVectorMax.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class IntMaxVector extends IntVector { +@ValueBased +final class IntVectorMax extends IntVector { static final IntSpecies VSPECIES = (IntSpecies) IntVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = IntMaxVector.class; + static final Class VCLASS = IntVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + static final Class ETYPE = int.class; // used by the JVM - IntMaxVector(int[] v) { + IntVectorMax(int[] v) { super(v); } - // For compatibility as IntMaxVector::new, + // For compatibility as IntVectorMax::new, // stored into species.vectorFactory. - IntMaxVector(Object v) { + IntVectorMax(Object v) { this((int[]) v); } - static final IntMaxVector ZERO = new IntMaxVector(new int[VLENGTH]); - static final IntMaxVector IOTA = new IntMaxVector(VSPECIES.iotaArray()); + static final IntVectorMax ZERO = new IntVectorMax(new int[VLENGTH]); + static final IntVectorMax IOTA = new IntVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class IntMaxVector extends IntVector { @Override public final Class elementType() { return int.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Integer.SIZE; } @@ -130,51 +135,51 @@ final class IntMaxVector extends IntVector { @Override @ForceInline - public final IntMaxVector broadcast(int e) { - return (IntMaxVector) super.broadcastTemplate(e); // specialize + public final IntVectorMax broadcast(int e) { + return (IntVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final IntMaxVector broadcast(long e) { - return (IntMaxVector) super.broadcastTemplate(e); // specialize + public final IntVectorMax broadcast(long e) { + return (IntVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - IntMaxMask maskFromArray(boolean[] bits) { - return new IntMaxMask(bits); + IntMaskMax maskFromArray(boolean[] bits) { + return new IntMaskMax(bits); } @Override @ForceInline - IntMaxShuffle iotaShuffle() { return IntMaxShuffle.IOTA; } + IntShuffleMax iotaShuffle() { return IntShuffleMax.IOTA; } @Override @ForceInline - IntMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (IntMaxShuffle) iotaShuffleTemplate(start, step, wrap); + IntShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (IntShuffleMax) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - IntMaxShuffle shuffleFromArray(int[] indices, int i) { return new IntMaxShuffle(indices, i); } + IntShuffleMax shuffleFromArray(int[] indices, int i) { return new IntShuffleMax(indices, i); } @Override @ForceInline - IntMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new IntMaxShuffle(fn); } + IntShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new IntShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - IntMaxVector vectorFactory(int[] vec) { - return new IntMaxVector(vec); + IntVectorMax vectorFactory(int[] vec) { + return new IntVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class IntMaxVector extends IntVector { @ForceInline final @Override - IntMaxVector uOp(FUnOp f) { - return (IntMaxVector) super.uOpTemplate(f); // specialize + IntVectorMax uOp(FUnOp f) { + return (IntVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - IntMaxVector uOp(VectorMask m, FUnOp f) { - return (IntMaxVector) - super.uOpTemplate((IntMaxMask)m, f); // specialize + IntVectorMax uOp(VectorMask m, FUnOp f) { + return (IntVectorMax) + super.uOpTemplate((IntMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - IntMaxVector bOp(Vector v, FBinOp f) { - return (IntMaxVector) super.bOpTemplate((IntMaxVector)v, f); // specialize + IntVectorMax bOp(Vector v, FBinOp f) { + return (IntVectorMax) super.bOpTemplate((IntVectorMax)v, f); // specialize } @ForceInline final @Override - IntMaxVector bOp(Vector v, + IntVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (IntMaxVector) - super.bOpTemplate((IntMaxVector)v, (IntMaxMask)m, + return (IntVectorMax) + super.bOpTemplate((IntVectorMax)v, (IntMaskMax)m, f); // specialize } @@ -219,19 +224,19 @@ final class IntMaxVector extends IntVector { @ForceInline final @Override - IntMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (IntMaxVector) - super.tOpTemplate((IntMaxVector)v1, (IntMaxVector)v2, + IntVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (IntVectorMax) + super.tOpTemplate((IntVectorMax)v1, (IntVectorMax)v2, f); // specialize } @ForceInline final @Override - IntMaxVector tOp(Vector v1, Vector v2, + IntVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (IntMaxVector) - super.tOpTemplate((IntMaxVector)v1, (IntMaxVector)v2, - (IntMaxMask)m, f); // specialize + return (IntVectorMax) + super.tOpTemplate((IntVectorMax)v1, (IntVectorMax)v2, + (IntMaskMax)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class IntMaxVector extends IntVector { @Override @ForceInline - public IntMaxVector lanewise(Unary op) { - return (IntMaxVector) super.lanewiseTemplate(op); // specialize + public IntVectorMax lanewise(Unary op) { + return (IntVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public IntMaxVector lanewise(Unary op, VectorMask m) { - return (IntMaxVector) super.lanewiseTemplate(op, IntMaxMask.class, (IntMaxMask) m); // specialize + public IntVectorMax lanewise(Unary op, VectorMask m) { + return (IntVectorMax) super.lanewiseTemplate(op, IntMaskMax.class, (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector lanewise(Binary op, Vector v) { - return (IntMaxVector) super.lanewiseTemplate(op, v); // specialize + public IntVectorMax lanewise(Binary op, Vector v) { + return (IntVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public IntMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (IntMaxVector) super.lanewiseTemplate(op, IntMaxMask.class, v, (IntMaxMask) m); // specialize + public IntVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (IntVectorMax) super.lanewiseTemplate(op, IntMaskMax.class, v, (IntMaskMax) m); // specialize } /*package-private*/ @Override - @ForceInline IntMaxVector + @ForceInline IntVectorMax lanewiseShift(VectorOperators.Binary op, int e) { - return (IntMaxVector) super.lanewiseShiftTemplate(op, e); // specialize + return (IntVectorMax) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline IntMaxVector + @ForceInline IntVectorMax lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (IntMaxVector) super.lanewiseShiftTemplate(op, IntMaxMask.class, e, (IntMaxMask) m); // specialize + return (IntVectorMax) super.lanewiseShiftTemplate(op, IntMaskMax.class, e, (IntMaskMax) m); // specialize } /*package-private*/ @Override @ForceInline public final - IntMaxVector + IntVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (IntMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (IntVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - IntMaxVector + IntVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (IntMaxVector) super.lanewiseTemplate(op, IntMaxMask.class, v1, v2, (IntMaxMask) m); // specialize + return (IntVectorMax) super.lanewiseTemplate(op, IntMaskMax.class, v1, v2, (IntMaskMax) m); // specialize } @Override @ForceInline public final - IntMaxVector addIndex(int scale) { - return (IntMaxVector) super.addIndexTemplate(scale); // specialize + IntVectorMax addIndex(int scale) { + return (IntVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class IntMaxVector extends IntVector { @ForceInline public final int reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, IntMaxMask.class, (IntMaxMask) m); // specialized + return super.reduceLanesTemplate(op, IntMaskMax.class, (IntMaskMax) m); // specialized } @Override @@ -354,7 +359,7 @@ final class IntMaxVector extends IntVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, IntMaxMask.class, (IntMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, IntMaskMax.class, (IntMaskMax) m); // specialized } @Override @@ -365,160 +370,160 @@ final class IntMaxVector extends IntVector { @Override @ForceInline - public final IntMaxShuffle toShuffle() { - return (IntMaxShuffle) toShuffle(vspecies(), false); + public final IntShuffleMax toShuffle() { + return (IntShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final IntMaxMask test(Test op) { - return super.testTemplate(IntMaxMask.class, op); // specialize + public final IntMaskMax test(Test op) { + return super.testTemplate(IntMaskMax.class, op); // specialize } @Override @ForceInline - public final IntMaxMask test(Test op, VectorMask m) { - return super.testTemplate(IntMaxMask.class, op, (IntMaxMask) m); // specialize + public final IntMaskMax test(Test op, VectorMask m) { + return super.testTemplate(IntMaskMax.class, op, (IntMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final IntMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(IntMaxMask.class, op, v); // specialize + public final IntMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(IntMaskMax.class, op, v); // specialize } @Override @ForceInline - public final IntMaxMask compare(Comparison op, int s) { - return super.compareTemplate(IntMaxMask.class, op, s); // specialize + public final IntMaskMax compare(Comparison op, int s) { + return super.compareTemplate(IntMaskMax.class, op, s); // specialize } @Override @ForceInline - public final IntMaxMask compare(Comparison op, long s) { - return super.compareTemplate(IntMaxMask.class, op, s); // specialize + public final IntMaskMax compare(Comparison op, long s) { + return super.compareTemplate(IntMaskMax.class, op, s); // specialize } @Override @ForceInline - public final IntMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(IntMaxMask.class, op, v, (IntMaxMask) m); + public final IntMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(IntMaskMax.class, op, v, (IntMaskMax) m); } @Override @ForceInline - public IntMaxVector blend(Vector v, VectorMask m) { - return (IntMaxVector) - super.blendTemplate(IntMaxMask.class, - (IntMaxVector) v, - (IntMaxMask) m); // specialize + public IntVectorMax blend(Vector v, VectorMask m) { + return (IntVectorMax) + super.blendTemplate(IntMaskMax.class, + (IntVectorMax) v, + (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector slice(int origin, Vector v) { - return (IntMaxVector) super.sliceTemplate(origin, v); // specialize + public IntVectorMax slice(int origin, Vector v) { + return (IntVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public IntMaxVector slice(int origin) { - return (IntMaxVector) super.sliceTemplate(origin); // specialize + public IntVectorMax slice(int origin) { + return (IntVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public IntMaxVector unslice(int origin, Vector w, int part) { - return (IntMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public IntVectorMax unslice(int origin, Vector w, int part) { + return (IntVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public IntMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (IntMaxVector) - super.unsliceTemplate(IntMaxMask.class, + public IntVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (IntVectorMax) + super.unsliceTemplate(IntMaskMax.class, origin, w, part, - (IntMaxMask) m); // specialize + (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector unslice(int origin) { - return (IntMaxVector) super.unsliceTemplate(origin); // specialize + public IntVectorMax unslice(int origin) { + return (IntVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public IntMaxVector rearrange(VectorShuffle s) { - return (IntMaxVector) - super.rearrangeTemplate(IntMaxShuffle.class, - (IntMaxShuffle) s); // specialize + public IntVectorMax rearrange(VectorShuffle s) { + return (IntVectorMax) + super.rearrangeTemplate(IntShuffleMax.class, + (IntShuffleMax) s); // specialize } @Override @ForceInline - public IntMaxVector rearrange(VectorShuffle shuffle, + public IntVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (IntMaxVector) - super.rearrangeTemplate(IntMaxShuffle.class, - IntMaxMask.class, - (IntMaxShuffle) shuffle, - (IntMaxMask) m); // specialize + return (IntVectorMax) + super.rearrangeTemplate(IntShuffleMax.class, + IntMaskMax.class, + (IntShuffleMax) shuffle, + (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector rearrange(VectorShuffle s, + public IntVectorMax rearrange(VectorShuffle s, Vector v) { - return (IntMaxVector) - super.rearrangeTemplate(IntMaxShuffle.class, - (IntMaxShuffle) s, - (IntMaxVector) v); // specialize + return (IntVectorMax) + super.rearrangeTemplate(IntShuffleMax.class, + (IntShuffleMax) s, + (IntVectorMax) v); // specialize } @Override @ForceInline - public IntMaxVector compress(VectorMask m) { - return (IntMaxVector) - super.compressTemplate(IntMaxMask.class, - (IntMaxMask) m); // specialize + public IntVectorMax compress(VectorMask m) { + return (IntVectorMax) + super.compressTemplate(IntMaskMax.class, + (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector expand(VectorMask m) { - return (IntMaxVector) - super.expandTemplate(IntMaxMask.class, - (IntMaxMask) m); // specialize + public IntVectorMax expand(VectorMask m) { + return (IntVectorMax) + super.expandTemplate(IntMaskMax.class, + (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector selectFrom(Vector v) { - return (IntMaxVector) - super.selectFromTemplate((IntMaxVector) v); // specialize + public IntVectorMax selectFrom(Vector v) { + return (IntVectorMax) + super.selectFromTemplate((IntVectorMax) v); // specialize } @Override @ForceInline - public IntMaxVector selectFrom(Vector v, + public IntVectorMax selectFrom(Vector v, VectorMask m) { - return (IntMaxVector) - super.selectFromTemplate((IntMaxVector) v, - IntMaxMask.class, (IntMaxMask) m); // specialize + return (IntVectorMax) + super.selectFromTemplate((IntVectorMax) v, + IntMaskMax.class, (IntMaskMax) m); // specialize } @Override @ForceInline - public IntMaxVector selectFrom(Vector v1, + public IntVectorMax selectFrom(Vector v1, Vector v2) { - return (IntMaxVector) - super.selectFromTemplate((IntMaxVector) v1, (IntMaxVector) v2); // specialize + return (IntVectorMax) + super.selectFromTemplate((IntVectorMax) v1, (IntVectorMax) v2); // specialize } @ForceInline @@ -543,7 +548,7 @@ final class IntMaxVector extends IntVector { @ForceInline @Override - public IntMaxVector withLane(int i, int e) { + public IntVectorMax withLane(int i, int e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -551,7 +556,7 @@ final class IntMaxVector extends IntVector { } @ForceInline - public IntMaxVector withLaneHelper(int i, int e) { + public IntVectorMax withLaneHelper(int i, int e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -563,20 +568,21 @@ final class IntMaxVector extends IntVector { } // Mask - - static final class IntMaxMask extends AbstractMask { + @ValueBased + static final class IntMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - IntMaxMask(boolean[] bits) { + static final Class CTYPE = int.class; // used by the JVM + + IntMaskMax(boolean[] bits) { this(bits, 0); } - IntMaxMask(boolean[] bits, int offset) { + IntMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - IntMaxMask(boolean val) { + IntMaskMax(boolean val) { super(prepare(val)); } @@ -609,31 +615,31 @@ final class IntMaxVector extends IntVector { } @Override - IntMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new IntMaxMask(res); + return new IntMaskMax(res); } @Override - IntMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + IntMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((IntMaxMask)m).getBits(); + boolean[] mbits = ((IntMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new IntMaxMask(res); + return new IntMaskMax(res); } @ForceInline @Override public final - IntMaxVector toVector() { - return (IntMaxVector) super.toVectorTemplate(); // specialize + IntVectorMax toVector() { + return (IntVectorMax) super.toVectorTemplate(); // specialize } /** @@ -666,25 +672,25 @@ final class IntMaxVector extends IntVector { @Override @ForceInline /*package-private*/ - IntMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (IntMaxMask) VectorSupport.indexPartiallyInUpperRange( - IntMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (IntMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + IntMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (IntMaskMax) VectorSupport.indexPartiallyInUpperRange( + IntMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (IntMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public IntMaxMask not() { + public IntMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public IntMaxMask compress() { - return (IntMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - IntMaxVector.class, IntMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public IntMaskMax compress() { + return (IntMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + IntVectorMax.class, IntMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -693,30 +699,30 @@ final class IntMaxVector extends IntVector { @Override @ForceInline - public IntMaxMask and(VectorMask mask) { + public IntMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, IntMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMaskMax m = (IntMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public IntMaxMask or(VectorMask mask) { + public IntMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, IntMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMaskMax m = (IntMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public IntMaxMask xor(VectorMask mask) { + public IntMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + IntMaskMax m = (IntMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -726,21 +732,21 @@ final class IntMaxVector extends IntVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -750,7 +756,7 @@ final class IntMaxVector extends IntVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -760,7 +766,7 @@ final class IntMaxVector extends IntVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(IntMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(IntMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -769,28 +775,28 @@ final class IntMaxVector extends IntVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((IntMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((IntMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((IntMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((IntMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static IntMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(IntMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static IntMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(IntMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final IntMaxMask TRUE_MASK = new IntMaxMask(true); - private static final IntMaxMask FALSE_MASK = new IntMaxMask(false); + private static final IntMaskMax TRUE_MASK = new IntMaskMax(true); + private static final IntMaskMax FALSE_MASK = new IntMaskMax(false); static boolean[] maskLowerHalf() { @@ -802,26 +808,27 @@ final class IntMaxVector extends IntVector { return a; } - static final IntMaxMask LOWER_HALF_TRUE_MASK = new IntMaxMask(maskLowerHalf()); + static final IntMaskMax LOWER_HALF_TRUE_MASK = new IntMaskMax(maskLowerHalf()); } // Shuffle - - static final class IntMaxShuffle extends AbstractShuffle { + @ValueBased + static final class IntShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM - IntMaxShuffle(int[] indices) { + static final Class CTYPE = int.class; // used by the JVM + + IntShuffleMax(int[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - IntMaxShuffle(int[] indices, int i) { + IntShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - IntMaxShuffle(IntUnaryOperator fn) { + IntShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -841,23 +848,23 @@ final class IntMaxVector extends IntVector { assert(VLENGTH < Integer.MAX_VALUE); assert(Integer.MIN_VALUE <= -VLENGTH); } - static final IntMaxShuffle IOTA = new IntMaxShuffle(IDENTITY); + static final IntShuffleMax IOTA = new IntShuffleMax(IDENTITY); @Override @ForceInline - public IntMaxVector toVector() { + public IntVectorMax toVector() { return toBitsVector(); } @Override @ForceInline - IntMaxVector toBitsVector() { - return (IntMaxVector) super.toBitsVectorTemplate(); + IntVectorMax toBitsVector() { + return (IntVectorMax) super.toBitsVectorTemplate(); } @Override - IntMaxVector toBitsVector0() { - return ((IntMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + IntVectorMax toBitsVector0() { + return ((IntVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -880,30 +887,30 @@ final class IntMaxVector extends IntVector { @Override @ForceInline - public final IntMaxMask laneIsValid() { - return (IntMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final IntMaskMax laneIsValid() { + return (IntMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final IntMaxShuffle rearrange(VectorShuffle shuffle) { - IntMaxShuffle concreteShuffle = (IntMaxShuffle) shuffle; - return (IntMaxShuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final IntShuffleMax rearrange(VectorShuffle shuffle) { + IntShuffleMax concreteShuffle = (IntShuffleMax) shuffle; + return (IntShuffleMax) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final IntMaxShuffle wrapIndexes() { - IntMaxVector v = toBitsVector(); + public final IntShuffleMax wrapIndexes() { + IntVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (IntMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (IntVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (IntMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (IntVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (IntMaxShuffle) v.toShuffle(vspecies(), false); + return (IntShuffleMax) v.toShuffle(VSPECIES, false); } private static int[] prepare(int[] indices, int offset) { @@ -954,14 +961,14 @@ final class IntMaxVector extends IntVector { @Override final IntVector fromArray0(int[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(IntMaxMask.class, a, offset, (IntMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(IntMaskMax.class, a, offset, (IntMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final IntVector fromArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(IntMaxMask.class, a, offset, indexMap, mapOffset, (IntMaxMask) m); + return super.fromArray0Template(IntMaskMax.class, a, offset, indexMap, mapOffset, (IntMaskMax) m); } @@ -977,7 +984,7 @@ final class IntMaxVector extends IntVector { @Override final IntVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(IntMaxMask.class, ms, offset, (IntMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(IntMaskMax.class, ms, offset, (IntMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -991,14 +998,14 @@ final class IntMaxVector extends IntVector { @Override final void intoArray0(int[] a, int offset, VectorMask m) { - super.intoArray0Template(IntMaxMask.class, a, offset, (IntMaxMask) m); + super.intoArray0Template(IntMaskMax.class, a, offset, (IntMaskMax) m); } @ForceInline @Override final void intoArray0(int[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(IntMaxMask.class, a, offset, indexMap, mapOffset, (IntMaxMask) m); + super.intoArray0Template(IntMaskMax.class, a, offset, indexMap, mapOffset, (IntMaskMax) m); } @@ -1006,7 +1013,7 @@ final class IntMaxVector extends IntVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(IntMaxMask.class, ms, offset, (IntMaxMask) m); + super.intoMemorySegment0Template(IntMaskMax.class, ms, offset, (IntMaskMax) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java index 59844eabb57..c18bbce1f34 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java @@ -35,19 +35,20 @@ import static jdk.incubator.vector.VectorIntrinsics.*; * It caches all sorts of goodies that we can't put on java.lang.Class. */ enum LaneType { - FLOAT(float.class, Float.class, float[].class, 'F', 24, Float.SIZE), - DOUBLE(double.class, Double.class, double[].class, 'F', 53, Double.SIZE), - BYTE(byte.class, Byte.class, byte[].class, 'I', -1, Byte.SIZE), - SHORT(short.class, Short.class, short[].class, 'I', -1, Short.SIZE), - INT(int.class, Integer.class, int[].class, 'I', -1, Integer.SIZE), - LONG(long.class, Long.class, long[].class, 'I', -1, Long.SIZE); + FLOAT(float.class, Float.class, float[].class, 'F', 24, Float.SIZE, float.class), + DOUBLE(double.class, Double.class, double[].class, 'F', 53, Double.SIZE, double.class), + BYTE(byte.class, Byte.class, byte[].class, 'I', -1, Byte.SIZE, byte.class), + SHORT(short.class, Short.class, short[].class, 'I', -1, Short.SIZE, short.class), + INT(int.class, Integer.class, int[].class, 'I', -1, Integer.SIZE, int.class), + LONG(long.class, Long.class, long[].class, 'I', -1, Long.SIZE, long.class); LaneType(Class elementType, Class genericElementType, Class arrayType, char elementKind, int elementPrecision, - int elementSize) { + int elementSize, + Class carrierType) { if (elementPrecision <= 0) elementPrecision += elementSize; this.elementType = elementType; @@ -66,6 +67,9 @@ enum LaneType { // report that condition also. this.typeChar = genericElementType.getSimpleName().charAt(0); assert("FDBSIL".indexOf(typeChar) == ordinal()) : this; + this.carrierType = carrierType; + assert(carrierType.isPrimitive()); + } final Class elementType; @@ -78,6 +82,7 @@ enum LaneType { final int switchKey; // 1+ordinal(), which is non-zero final String printName; final char typeChar; // one of "BSILFD" + final Class carrierType; private @Stable LaneType asIntegral; private @Stable LaneType asFloating; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 5657bbec0a6..36300cf892b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code long} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class LongVector extends AbstractVector { +public abstract sealed class LongVector extends AbstractVector + permits LongVector64, LongVector128, LongVector256, LongVector512, LongVectorMax { LongVector(long[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class LongVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -2964,7 +2965,7 @@ public abstract class LongVector extends AbstractVector { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For LongMaxVector, if vector length is non-power-of-two or + // For LongVectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of Long species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of Long // vector is 32. When converting Long species to int species, @@ -2972,7 +2973,7 @@ public abstract class LongVector extends AbstractVector { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3255,14 +3256,14 @@ public abstract class LongVector extends AbstractVector { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For LongMaxVector, if vector length is 2048 bits, indexShape + // For LongVectorMax, if vector length is 2048 bits, indexShape // of Long species is S_MAX_BIT. and the lane count of Long // vector is 32. When converting Long species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3449,7 +3450,7 @@ public abstract class LongVector extends AbstractVector { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For LongMaxVector, if vector length is non-power-of-two or + // For LongVectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of Long species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of Long // vector is 32. When converting Long species to int species, @@ -3457,7 +3458,7 @@ public abstract class LongVector extends AbstractVector { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -3565,14 +3566,14 @@ public abstract class LongVector extends AbstractVector { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For LongMaxVector, if vector length is 2048 bits, indexShape + // For LongVectorMax, if vector length is 2048 bits, indexShape // of Long species is S_MAX_BIT. and the lane count of Long // vector is 32. When converting Long species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -4010,13 +4011,13 @@ public abstract class LongVector extends AbstractVector { @Override @ForceInline public final LongVector zero() { - if ((Class) vectorType() == LongMaxVector.class) - return LongMaxVector.ZERO; + if ((Class) vectorType() == LongVectorMax.class) + return LongVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Long64Vector.ZERO; - case 128: return Long128Vector.ZERO; - case 256: return Long256Vector.ZERO; - case 512: return Long512Vector.ZERO; + case 64: return LongVector64.ZERO; + case 128: return LongVector128.ZERO; + case 256: return LongVector256.ZERO; + case 512: return LongVector512.ZERO; } throw new AssertionError(); } @@ -4024,13 +4025,13 @@ public abstract class LongVector extends AbstractVector { @Override @ForceInline public final LongVector iota() { - if ((Class) vectorType() == LongMaxVector.class) - return LongMaxVector.IOTA; + if ((Class) vectorType() == LongVectorMax.class) + return LongVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Long64Vector.IOTA; - case 128: return Long128Vector.IOTA; - case 256: return Long256Vector.IOTA; - case 512: return Long512Vector.IOTA; + case 64: return LongVector64.IOTA; + case 128: return LongVector128.IOTA; + case 256: return LongVector256.IOTA; + case 512: return LongVector512.IOTA; } throw new AssertionError(); } @@ -4039,13 +4040,13 @@ public abstract class LongVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == LongMaxVector.class) - return LongMaxVector.LongMaxMask.maskAll(bit); + if ((Class) vectorType() == LongVectorMax.class) + return LongVectorMax.LongMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Long64Vector.Long64Mask.maskAll(bit); - case 128: return Long128Vector.Long128Mask.maskAll(bit); - case 256: return Long256Vector.Long256Mask.maskAll(bit); - case 512: return Long512Vector.Long512Mask.maskAll(bit); + case 64: return LongVector64.LongMask64.maskAll(bit); + case 128: return LongVector128.LongMask128.maskAll(bit); + case 256: return LongVector256.LongMask256.maskAll(bit); + case 512: return LongVector512.LongMask512.maskAll(bit); } throw new AssertionError(); } @@ -4073,42 +4074,42 @@ public abstract class LongVector extends AbstractVector { /** Species representing {@link LongVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new LongSpecies(VectorShape.S_64_BIT, - Long64Vector.class, - Long64Vector.Long64Mask.class, - Long64Vector.Long64Shuffle.class, - Long64Vector::new); + LongVector64.class, + LongVector64.LongMask64.class, + LongVector64.LongShuffle64.class, + LongVector64::new); /** Species representing {@link LongVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new LongSpecies(VectorShape.S_128_BIT, - Long128Vector.class, - Long128Vector.Long128Mask.class, - Long128Vector.Long128Shuffle.class, - Long128Vector::new); + LongVector128.class, + LongVector128.LongMask128.class, + LongVector128.LongShuffle128.class, + LongVector128::new); /** Species representing {@link LongVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new LongSpecies(VectorShape.S_256_BIT, - Long256Vector.class, - Long256Vector.Long256Mask.class, - Long256Vector.Long256Shuffle.class, - Long256Vector::new); + LongVector256.class, + LongVector256.LongMask256.class, + LongVector256.LongShuffle256.class, + LongVector256::new); /** Species representing {@link LongVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new LongSpecies(VectorShape.S_512_BIT, - Long512Vector.class, - Long512Vector.Long512Mask.class, - Long512Vector.Long512Shuffle.class, - Long512Vector::new); + LongVector512.class, + LongVector512.LongMask512.class, + LongVector512.LongShuffle512.class, + LongVector512::new); /** Species representing {@link LongVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new LongSpecies(VectorShape.S_Max_BIT, - LongMaxVector.class, - LongMaxVector.LongMaxMask.class, - LongMaxVector.LongMaxShuffle.class, - LongMaxVector::new); + LongVectorMax.class, + LongVectorMax.LongMaskMax.class, + LongVectorMax.LongShuffleMax.class, + LongVectorMax::new); /** * Preferred species for {@link LongVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector128.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector128.java index 01d721f64fc..7ce60b2efe0 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector128.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Long128Vector extends LongVector { +@ValueBased +final class LongVector128 extends LongVector { static final LongSpecies VSPECIES = (LongSpecies) LongVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Long128Vector.class; + static final Class VCLASS = LongVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + static final Class ETYPE = long.class; // used by the JVM - Long128Vector(long[] v) { + LongVector128(long[] v) { super(v); } - // For compatibility as Long128Vector::new, + // For compatibility as LongVector128::new, // stored into species.vectorFactory. - Long128Vector(Object v) { + LongVector128(Object v) { this((long[]) v); } - static final Long128Vector ZERO = new Long128Vector(new long[VLENGTH]); - static final Long128Vector IOTA = new Long128Vector(VSPECIES.iotaArray()); + static final LongVector128 ZERO = new LongVector128(new long[VLENGTH]); + static final LongVector128 IOTA = new LongVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Long128Vector extends LongVector { @Override public final Class elementType() { return long.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Long.SIZE; } @@ -130,46 +136,46 @@ final class Long128Vector extends LongVector { @Override @ForceInline - public final Long128Vector broadcast(long e) { - return (Long128Vector) super.broadcastTemplate(e); // specialize + public final LongVector128 broadcast(long e) { + return (LongVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Long128Mask maskFromArray(boolean[] bits) { - return new Long128Mask(bits); + LongMask128 maskFromArray(boolean[] bits) { + return new LongMask128(bits); } @Override @ForceInline - Long128Shuffle iotaShuffle() { return Long128Shuffle.IOTA; } + LongShuffle128 iotaShuffle() { return LongShuffle128.IOTA; } @Override @ForceInline - Long128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Long128Shuffle) iotaShuffleTemplate(start, step, wrap); + LongShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (LongShuffle128) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Long128Shuffle shuffleFromArray(int[] indices, int i) { return new Long128Shuffle(indices, i); } + LongShuffle128 shuffleFromArray(int[] indices, int i) { return new LongShuffle128(indices, i); } @Override @ForceInline - Long128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long128Shuffle(fn); } + LongShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new LongShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Long128Vector vectorFactory(long[] vec) { - return new Long128Vector(vec); + LongVector128 vectorFactory(long[] vec) { + return new LongVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -182,31 +188,31 @@ final class Long128Vector extends LongVector { @ForceInline final @Override - Long128Vector uOp(FUnOp f) { - return (Long128Vector) super.uOpTemplate(f); // specialize + LongVector128 uOp(FUnOp f) { + return (LongVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Long128Vector uOp(VectorMask m, FUnOp f) { - return (Long128Vector) - super.uOpTemplate((Long128Mask)m, f); // specialize + LongVector128 uOp(VectorMask m, FUnOp f) { + return (LongVector128) + super.uOpTemplate((LongMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Long128Vector bOp(Vector v, FBinOp f) { - return (Long128Vector) super.bOpTemplate((Long128Vector)v, f); // specialize + LongVector128 bOp(Vector v, FBinOp f) { + return (LongVector128) super.bOpTemplate((LongVector128)v, f); // specialize } @ForceInline final @Override - Long128Vector bOp(Vector v, + LongVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Long128Vector) - super.bOpTemplate((Long128Vector)v, (Long128Mask)m, + return (LongVector128) + super.bOpTemplate((LongVector128)v, (LongMask128)m, f); // specialize } @@ -214,19 +220,19 @@ final class Long128Vector extends LongVector { @ForceInline final @Override - Long128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Long128Vector) - super.tOpTemplate((Long128Vector)v1, (Long128Vector)v2, + LongVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (LongVector128) + super.tOpTemplate((LongVector128)v1, (LongVector128)v2, f); // specialize } @ForceInline final @Override - Long128Vector tOp(Vector v1, Vector v2, + LongVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Long128Vector) - super.tOpTemplate((Long128Vector)v1, (Long128Vector)v2, - (Long128Mask)m, f); // specialize + return (LongVector128) + super.tOpTemplate((LongVector128)v1, (LongVector128)v2, + (LongMask128)m, f); // specialize } @ForceInline @@ -264,64 +270,64 @@ final class Long128Vector extends LongVector { @Override @ForceInline - public Long128Vector lanewise(Unary op) { - return (Long128Vector) super.lanewiseTemplate(op); // specialize + public LongVector128 lanewise(Unary op) { + return (LongVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Long128Vector lanewise(Unary op, VectorMask m) { - return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, (Long128Mask) m); // specialize + public LongVector128 lanewise(Unary op, VectorMask m) { + return (LongVector128) super.lanewiseTemplate(op, LongMask128.class, (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector lanewise(Binary op, Vector v) { - return (Long128Vector) super.lanewiseTemplate(op, v); // specialize + public LongVector128 lanewise(Binary op, Vector v) { + return (LongVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Long128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, v, (Long128Mask) m); // specialize + public LongVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (LongVector128) super.lanewiseTemplate(op, LongMask128.class, v, (LongMask128) m); // specialize } /*package-private*/ @Override - @ForceInline Long128Vector + @ForceInline LongVector128 lanewiseShift(VectorOperators.Binary op, int e) { - return (Long128Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (LongVector128) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Long128Vector + @ForceInline LongVector128 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Long128Vector) super.lanewiseShiftTemplate(op, Long128Mask.class, e, (Long128Mask) m); // specialize + return (LongVector128) super.lanewiseShiftTemplate(op, LongMask128.class, e, (LongMask128) m); // specialize } /*package-private*/ @Override @ForceInline public final - Long128Vector + LongVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Long128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (LongVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Long128Vector + LongVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, v1, v2, (Long128Mask) m); // specialize + return (LongVector128) super.lanewiseTemplate(op, LongMask128.class, v1, v2, (LongMask128) m); // specialize } @Override @ForceInline public final - Long128Vector addIndex(int scale) { - return (Long128Vector) super.addIndexTemplate(scale); // specialize + LongVector128 addIndex(int scale) { + return (LongVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -336,7 +342,7 @@ final class Long128Vector extends LongVector { @ForceInline public final long reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Long128Mask.class, (Long128Mask) m); // specialized + return super.reduceLanesTemplate(op, LongMask128.class, (LongMask128) m); // specialized } @Override @@ -349,7 +355,7 @@ final class Long128Vector extends LongVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Long128Mask.class, (Long128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, LongMask128.class, (LongMask128) m); // specialized } @Override @@ -360,155 +366,155 @@ final class Long128Vector extends LongVector { @Override @ForceInline - public final Long128Shuffle toShuffle() { - return (Long128Shuffle) toShuffle(vspecies(), false); + public final LongShuffle128 toShuffle() { + return (LongShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Long128Mask test(Test op) { - return super.testTemplate(Long128Mask.class, op); // specialize + public final LongMask128 test(Test op) { + return super.testTemplate(LongMask128.class, op); // specialize } @Override @ForceInline - public final Long128Mask test(Test op, VectorMask m) { - return super.testTemplate(Long128Mask.class, op, (Long128Mask) m); // specialize + public final LongMask128 test(Test op, VectorMask m) { + return super.testTemplate(LongMask128.class, op, (LongMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Long128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Long128Mask.class, op, v); // specialize + public final LongMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(LongMask128.class, op, v); // specialize } @Override @ForceInline - public final Long128Mask compare(Comparison op, long s) { - return super.compareTemplate(Long128Mask.class, op, s); // specialize + public final LongMask128 compare(Comparison op, long s) { + return super.compareTemplate(LongMask128.class, op, s); // specialize } @Override @ForceInline - public final Long128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Long128Mask.class, op, v, (Long128Mask) m); + public final LongMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(LongMask128.class, op, v, (LongMask128) m); } @Override @ForceInline - public Long128Vector blend(Vector v, VectorMask m) { - return (Long128Vector) - super.blendTemplate(Long128Mask.class, - (Long128Vector) v, - (Long128Mask) m); // specialize + public LongVector128 blend(Vector v, VectorMask m) { + return (LongVector128) + super.blendTemplate(LongMask128.class, + (LongVector128) v, + (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector slice(int origin, Vector v) { - return (Long128Vector) super.sliceTemplate(origin, v); // specialize + public LongVector128 slice(int origin, Vector v) { + return (LongVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Long128Vector slice(int origin) { - return (Long128Vector) super.sliceTemplate(origin); // specialize + public LongVector128 slice(int origin) { + return (LongVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Long128Vector unslice(int origin, Vector w, int part) { - return (Long128Vector) super.unsliceTemplate(origin, w, part); // specialize + public LongVector128 unslice(int origin, Vector w, int part) { + return (LongVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Long128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Long128Vector) - super.unsliceTemplate(Long128Mask.class, + public LongVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (LongVector128) + super.unsliceTemplate(LongMask128.class, origin, w, part, - (Long128Mask) m); // specialize + (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector unslice(int origin) { - return (Long128Vector) super.unsliceTemplate(origin); // specialize + public LongVector128 unslice(int origin) { + return (LongVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Long128Vector rearrange(VectorShuffle s) { - return (Long128Vector) - super.rearrangeTemplate(Long128Shuffle.class, - (Long128Shuffle) s); // specialize + public LongVector128 rearrange(VectorShuffle s) { + return (LongVector128) + super.rearrangeTemplate(LongShuffle128.class, + (LongShuffle128) s); // specialize } @Override @ForceInline - public Long128Vector rearrange(VectorShuffle shuffle, + public LongVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Long128Vector) - super.rearrangeTemplate(Long128Shuffle.class, - Long128Mask.class, - (Long128Shuffle) shuffle, - (Long128Mask) m); // specialize + return (LongVector128) + super.rearrangeTemplate(LongShuffle128.class, + LongMask128.class, + (LongShuffle128) shuffle, + (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector rearrange(VectorShuffle s, + public LongVector128 rearrange(VectorShuffle s, Vector v) { - return (Long128Vector) - super.rearrangeTemplate(Long128Shuffle.class, - (Long128Shuffle) s, - (Long128Vector) v); // specialize + return (LongVector128) + super.rearrangeTemplate(LongShuffle128.class, + (LongShuffle128) s, + (LongVector128) v); // specialize } @Override @ForceInline - public Long128Vector compress(VectorMask m) { - return (Long128Vector) - super.compressTemplate(Long128Mask.class, - (Long128Mask) m); // specialize + public LongVector128 compress(VectorMask m) { + return (LongVector128) + super.compressTemplate(LongMask128.class, + (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector expand(VectorMask m) { - return (Long128Vector) - super.expandTemplate(Long128Mask.class, - (Long128Mask) m); // specialize + public LongVector128 expand(VectorMask m) { + return (LongVector128) + super.expandTemplate(LongMask128.class, + (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector selectFrom(Vector v) { - return (Long128Vector) - super.selectFromTemplate((Long128Vector) v); // specialize + public LongVector128 selectFrom(Vector v) { + return (LongVector128) + super.selectFromTemplate((LongVector128) v); // specialize } @Override @ForceInline - public Long128Vector selectFrom(Vector v, + public LongVector128 selectFrom(Vector v, VectorMask m) { - return (Long128Vector) - super.selectFromTemplate((Long128Vector) v, - Long128Mask.class, (Long128Mask) m); // specialize + return (LongVector128) + super.selectFromTemplate((LongVector128) v, + LongMask128.class, (LongMask128) m); // specialize } @Override @ForceInline - public Long128Vector selectFrom(Vector v1, + public LongVector128 selectFrom(Vector v1, Vector v2) { - return (Long128Vector) - super.selectFromTemplate((Long128Vector) v1, (Long128Vector) v2); // specialize + return (LongVector128) + super.selectFromTemplate((LongVector128) v1, (LongVector128) v2); // specialize } @ForceInline @@ -534,7 +540,7 @@ final class Long128Vector extends LongVector { @ForceInline @Override - public Long128Vector withLane(int i, long e) { + public LongVector128 withLane(int i, long e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -543,7 +549,7 @@ final class Long128Vector extends LongVector { } @ForceInline - public Long128Vector withLaneHelper(int i, long e) { + public LongVector128 withLaneHelper(int i, long e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -555,20 +561,21 @@ final class Long128Vector extends LongVector { } // Mask - - static final class Long128Mask extends AbstractMask { + @ValueBased + static final class LongMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long128Mask(boolean[] bits) { + static final Class CTYPE = long.class; // used by the JVM + + LongMask128(boolean[] bits) { this(bits, 0); } - Long128Mask(boolean[] bits, int offset) { + LongMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Long128Mask(boolean val) { + LongMask128(boolean val) { super(prepare(val)); } @@ -601,31 +608,31 @@ final class Long128Vector extends LongVector { } @Override - Long128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Long128Mask(res); + return new LongMask128(res); } @Override - Long128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Long128Mask)m).getBits(); + boolean[] mbits = ((LongMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Long128Mask(res); + return new LongMask128(res); } @ForceInline @Override public final - Long128Vector toVector() { - return (Long128Vector) super.toVectorTemplate(); // specialize + LongVector128 toVector() { + return (LongVector128) super.toVectorTemplate(); // specialize } /** @@ -658,25 +665,25 @@ final class Long128Vector extends LongVector { @Override @ForceInline /*package-private*/ - Long128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Long128Mask) VectorSupport.indexPartiallyInUpperRange( - Long128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Long128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + LongMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (LongMask128) VectorSupport.indexPartiallyInUpperRange( + LongMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (LongMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Long128Mask not() { + public LongMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Long128Mask compress() { - return (Long128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long128Vector.class, Long128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public LongMask128 compress() { + return (LongMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + LongVector128.class, LongMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -685,30 +692,30 @@ final class Long128Vector extends LongVector { @Override @ForceInline - public Long128Mask and(VectorMask mask) { + public LongMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask128 m = (LongMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Long128Mask or(VectorMask mask) { + public LongMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask128 m = (LongMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Long128Mask xor(VectorMask mask) { + public LongMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask128 m = (LongMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -718,21 +725,21 @@ final class Long128Vector extends LongVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -742,7 +749,7 @@ final class Long128Vector extends LongVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -752,7 +759,7 @@ final class Long128Vector extends LongVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(LongMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -761,48 +768,49 @@ final class Long128Vector extends LongVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long128Mask)m).getBits())); + return VectorSupport.test(BT_ne, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((LongMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((LongMask128)m).getBits())); } @ForceInline /*package-private*/ - static Long128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static LongMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(LongMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Long128Mask TRUE_MASK = new Long128Mask(true); - private static final Long128Mask FALSE_MASK = new Long128Mask(false); + private static final LongMask128 TRUE_MASK = new LongMask128(true); + private static final LongMask128 FALSE_MASK = new LongMask128(false); } // Shuffle - - static final class Long128Shuffle extends AbstractShuffle { + @ValueBased + static final class LongShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long128Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + LongShuffle128(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Long128Shuffle(int[] indices, int i) { + LongShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Long128Shuffle(IntUnaryOperator fn) { + LongShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -822,23 +830,23 @@ final class Long128Vector extends LongVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Long128Shuffle IOTA = new Long128Shuffle(IDENTITY); + static final LongShuffle128 IOTA = new LongShuffle128(IDENTITY); @Override @ForceInline - public Long128Vector toVector() { + public LongVector128 toVector() { return toBitsVector(); } @Override @ForceInline - Long128Vector toBitsVector() { - return (Long128Vector) super.toBitsVectorTemplate(); + LongVector128 toBitsVector() { + return (LongVector128) super.toBitsVectorTemplate(); } @Override - Long128Vector toBitsVector0() { - return ((Long128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector128 toBitsVector0() { + return ((LongVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -910,30 +918,30 @@ final class Long128Vector extends LongVector { @Override @ForceInline - public final Long128Mask laneIsValid() { - return (Long128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final LongMask128 laneIsValid() { + return (LongMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Long128Shuffle rearrange(VectorShuffle shuffle) { - Long128Shuffle concreteShuffle = (Long128Shuffle) shuffle; - return (Long128Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final LongShuffle128 rearrange(VectorShuffle shuffle) { + LongShuffle128 concreteShuffle = (LongShuffle128) shuffle; + return (LongShuffle128) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Long128Shuffle wrapIndexes() { - Long128Vector v = toBitsVector(); + public final LongShuffle128 wrapIndexes() { + LongVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Long128Shuffle) v.toShuffle(vspecies(), false); + return (LongShuffle128) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -984,14 +992,14 @@ final class Long128Vector extends LongVector { @Override final LongVector fromArray0(long[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Long128Mask.class, a, offset, (Long128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(LongMask128.class, a, offset, (LongMask128) m, offsetInRange); // specialize } @ForceInline @Override final LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Long128Mask.class, a, offset, indexMap, mapOffset, (Long128Mask) m); + return super.fromArray0Template(LongMask128.class, a, offset, indexMap, mapOffset, (LongMask128) m); } @@ -1007,7 +1015,7 @@ final class Long128Vector extends LongVector { @Override final LongVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Long128Mask.class, ms, offset, (Long128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(LongMask128.class, ms, offset, (LongMask128) m, offsetInRange); // specialize } @ForceInline @@ -1021,14 +1029,14 @@ final class Long128Vector extends LongVector { @Override final void intoArray0(long[] a, int offset, VectorMask m) { - super.intoArray0Template(Long128Mask.class, a, offset, (Long128Mask) m); + super.intoArray0Template(LongMask128.class, a, offset, (LongMask128) m); } @ForceInline @Override final void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Long128Mask.class, a, offset, indexMap, mapOffset, (Long128Mask) m); + super.intoArray0Template(LongMask128.class, a, offset, indexMap, mapOffset, (LongMask128) m); } @@ -1036,7 +1044,7 @@ final class Long128Vector extends LongVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Long128Mask.class, ms, offset, (Long128Mask) m); + super.intoMemorySegment0Template(LongMask128.class, ms, offset, (LongMask128) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector256.java similarity index 66% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector256.java index b3e7022771c..110a54c547f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector256.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Long256Vector extends LongVector { +@ValueBased +final class LongVector256 extends LongVector { static final LongSpecies VSPECIES = (LongSpecies) LongVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Long256Vector.class; + static final Class VCLASS = LongVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + static final Class ETYPE = long.class; // used by the JVM - Long256Vector(long[] v) { + LongVector256(long[] v) { super(v); } - // For compatibility as Long256Vector::new, + // For compatibility as LongVector256::new, // stored into species.vectorFactory. - Long256Vector(Object v) { + LongVector256(Object v) { this((long[]) v); } - static final Long256Vector ZERO = new Long256Vector(new long[VLENGTH]); - static final Long256Vector IOTA = new Long256Vector(VSPECIES.iotaArray()); + static final LongVector256 ZERO = new LongVector256(new long[VLENGTH]); + static final LongVector256 IOTA = new LongVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Long256Vector extends LongVector { @Override public final Class elementType() { return long.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Long.SIZE; } @@ -130,46 +136,46 @@ final class Long256Vector extends LongVector { @Override @ForceInline - public final Long256Vector broadcast(long e) { - return (Long256Vector) super.broadcastTemplate(e); // specialize + public final LongVector256 broadcast(long e) { + return (LongVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Long256Mask maskFromArray(boolean[] bits) { - return new Long256Mask(bits); + LongMask256 maskFromArray(boolean[] bits) { + return new LongMask256(bits); } @Override @ForceInline - Long256Shuffle iotaShuffle() { return Long256Shuffle.IOTA; } + LongShuffle256 iotaShuffle() { return LongShuffle256.IOTA; } @Override @ForceInline - Long256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Long256Shuffle) iotaShuffleTemplate(start, step, wrap); + LongShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (LongShuffle256) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Long256Shuffle shuffleFromArray(int[] indices, int i) { return new Long256Shuffle(indices, i); } + LongShuffle256 shuffleFromArray(int[] indices, int i) { return new LongShuffle256(indices, i); } @Override @ForceInline - Long256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long256Shuffle(fn); } + LongShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new LongShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Long256Vector vectorFactory(long[] vec) { - return new Long256Vector(vec); + LongVector256 vectorFactory(long[] vec) { + return new LongVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -182,31 +188,31 @@ final class Long256Vector extends LongVector { @ForceInline final @Override - Long256Vector uOp(FUnOp f) { - return (Long256Vector) super.uOpTemplate(f); // specialize + LongVector256 uOp(FUnOp f) { + return (LongVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Long256Vector uOp(VectorMask m, FUnOp f) { - return (Long256Vector) - super.uOpTemplate((Long256Mask)m, f); // specialize + LongVector256 uOp(VectorMask m, FUnOp f) { + return (LongVector256) + super.uOpTemplate((LongMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Long256Vector bOp(Vector v, FBinOp f) { - return (Long256Vector) super.bOpTemplate((Long256Vector)v, f); // specialize + LongVector256 bOp(Vector v, FBinOp f) { + return (LongVector256) super.bOpTemplate((LongVector256)v, f); // specialize } @ForceInline final @Override - Long256Vector bOp(Vector v, + LongVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Long256Vector) - super.bOpTemplate((Long256Vector)v, (Long256Mask)m, + return (LongVector256) + super.bOpTemplate((LongVector256)v, (LongMask256)m, f); // specialize } @@ -214,19 +220,19 @@ final class Long256Vector extends LongVector { @ForceInline final @Override - Long256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Long256Vector) - super.tOpTemplate((Long256Vector)v1, (Long256Vector)v2, + LongVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (LongVector256) + super.tOpTemplate((LongVector256)v1, (LongVector256)v2, f); // specialize } @ForceInline final @Override - Long256Vector tOp(Vector v1, Vector v2, + LongVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Long256Vector) - super.tOpTemplate((Long256Vector)v1, (Long256Vector)v2, - (Long256Mask)m, f); // specialize + return (LongVector256) + super.tOpTemplate((LongVector256)v1, (LongVector256)v2, + (LongMask256)m, f); // specialize } @ForceInline @@ -264,64 +270,64 @@ final class Long256Vector extends LongVector { @Override @ForceInline - public Long256Vector lanewise(Unary op) { - return (Long256Vector) super.lanewiseTemplate(op); // specialize + public LongVector256 lanewise(Unary op) { + return (LongVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Long256Vector lanewise(Unary op, VectorMask m) { - return (Long256Vector) super.lanewiseTemplate(op, Long256Mask.class, (Long256Mask) m); // specialize + public LongVector256 lanewise(Unary op, VectorMask m) { + return (LongVector256) super.lanewiseTemplate(op, LongMask256.class, (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector lanewise(Binary op, Vector v) { - return (Long256Vector) super.lanewiseTemplate(op, v); // specialize + public LongVector256 lanewise(Binary op, Vector v) { + return (LongVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Long256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Long256Vector) super.lanewiseTemplate(op, Long256Mask.class, v, (Long256Mask) m); // specialize + public LongVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (LongVector256) super.lanewiseTemplate(op, LongMask256.class, v, (LongMask256) m); // specialize } /*package-private*/ @Override - @ForceInline Long256Vector + @ForceInline LongVector256 lanewiseShift(VectorOperators.Binary op, int e) { - return (Long256Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (LongVector256) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Long256Vector + @ForceInline LongVector256 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Long256Vector) super.lanewiseShiftTemplate(op, Long256Mask.class, e, (Long256Mask) m); // specialize + return (LongVector256) super.lanewiseShiftTemplate(op, LongMask256.class, e, (LongMask256) m); // specialize } /*package-private*/ @Override @ForceInline public final - Long256Vector + LongVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Long256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (LongVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Long256Vector + LongVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Long256Vector) super.lanewiseTemplate(op, Long256Mask.class, v1, v2, (Long256Mask) m); // specialize + return (LongVector256) super.lanewiseTemplate(op, LongMask256.class, v1, v2, (LongMask256) m); // specialize } @Override @ForceInline public final - Long256Vector addIndex(int scale) { - return (Long256Vector) super.addIndexTemplate(scale); // specialize + LongVector256 addIndex(int scale) { + return (LongVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -336,7 +342,7 @@ final class Long256Vector extends LongVector { @ForceInline public final long reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Long256Mask.class, (Long256Mask) m); // specialized + return super.reduceLanesTemplate(op, LongMask256.class, (LongMask256) m); // specialized } @Override @@ -349,7 +355,7 @@ final class Long256Vector extends LongVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Long256Mask.class, (Long256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, LongMask256.class, (LongMask256) m); // specialized } @Override @@ -360,155 +366,155 @@ final class Long256Vector extends LongVector { @Override @ForceInline - public final Long256Shuffle toShuffle() { - return (Long256Shuffle) toShuffle(vspecies(), false); + public final LongShuffle256 toShuffle() { + return (LongShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Long256Mask test(Test op) { - return super.testTemplate(Long256Mask.class, op); // specialize + public final LongMask256 test(Test op) { + return super.testTemplate(LongMask256.class, op); // specialize } @Override @ForceInline - public final Long256Mask test(Test op, VectorMask m) { - return super.testTemplate(Long256Mask.class, op, (Long256Mask) m); // specialize + public final LongMask256 test(Test op, VectorMask m) { + return super.testTemplate(LongMask256.class, op, (LongMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Long256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Long256Mask.class, op, v); // specialize + public final LongMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(LongMask256.class, op, v); // specialize } @Override @ForceInline - public final Long256Mask compare(Comparison op, long s) { - return super.compareTemplate(Long256Mask.class, op, s); // specialize + public final LongMask256 compare(Comparison op, long s) { + return super.compareTemplate(LongMask256.class, op, s); // specialize } @Override @ForceInline - public final Long256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Long256Mask.class, op, v, (Long256Mask) m); + public final LongMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(LongMask256.class, op, v, (LongMask256) m); } @Override @ForceInline - public Long256Vector blend(Vector v, VectorMask m) { - return (Long256Vector) - super.blendTemplate(Long256Mask.class, - (Long256Vector) v, - (Long256Mask) m); // specialize + public LongVector256 blend(Vector v, VectorMask m) { + return (LongVector256) + super.blendTemplate(LongMask256.class, + (LongVector256) v, + (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector slice(int origin, Vector v) { - return (Long256Vector) super.sliceTemplate(origin, v); // specialize + public LongVector256 slice(int origin, Vector v) { + return (LongVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Long256Vector slice(int origin) { - return (Long256Vector) super.sliceTemplate(origin); // specialize + public LongVector256 slice(int origin) { + return (LongVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Long256Vector unslice(int origin, Vector w, int part) { - return (Long256Vector) super.unsliceTemplate(origin, w, part); // specialize + public LongVector256 unslice(int origin, Vector w, int part) { + return (LongVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Long256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Long256Vector) - super.unsliceTemplate(Long256Mask.class, + public LongVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (LongVector256) + super.unsliceTemplate(LongMask256.class, origin, w, part, - (Long256Mask) m); // specialize + (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector unslice(int origin) { - return (Long256Vector) super.unsliceTemplate(origin); // specialize + public LongVector256 unslice(int origin) { + return (LongVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Long256Vector rearrange(VectorShuffle s) { - return (Long256Vector) - super.rearrangeTemplate(Long256Shuffle.class, - (Long256Shuffle) s); // specialize + public LongVector256 rearrange(VectorShuffle s) { + return (LongVector256) + super.rearrangeTemplate(LongShuffle256.class, + (LongShuffle256) s); // specialize } @Override @ForceInline - public Long256Vector rearrange(VectorShuffle shuffle, + public LongVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Long256Vector) - super.rearrangeTemplate(Long256Shuffle.class, - Long256Mask.class, - (Long256Shuffle) shuffle, - (Long256Mask) m); // specialize + return (LongVector256) + super.rearrangeTemplate(LongShuffle256.class, + LongMask256.class, + (LongShuffle256) shuffle, + (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector rearrange(VectorShuffle s, + public LongVector256 rearrange(VectorShuffle s, Vector v) { - return (Long256Vector) - super.rearrangeTemplate(Long256Shuffle.class, - (Long256Shuffle) s, - (Long256Vector) v); // specialize + return (LongVector256) + super.rearrangeTemplate(LongShuffle256.class, + (LongShuffle256) s, + (LongVector256) v); // specialize } @Override @ForceInline - public Long256Vector compress(VectorMask m) { - return (Long256Vector) - super.compressTemplate(Long256Mask.class, - (Long256Mask) m); // specialize + public LongVector256 compress(VectorMask m) { + return (LongVector256) + super.compressTemplate(LongMask256.class, + (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector expand(VectorMask m) { - return (Long256Vector) - super.expandTemplate(Long256Mask.class, - (Long256Mask) m); // specialize + public LongVector256 expand(VectorMask m) { + return (LongVector256) + super.expandTemplate(LongMask256.class, + (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector selectFrom(Vector v) { - return (Long256Vector) - super.selectFromTemplate((Long256Vector) v); // specialize + public LongVector256 selectFrom(Vector v) { + return (LongVector256) + super.selectFromTemplate((LongVector256) v); // specialize } @Override @ForceInline - public Long256Vector selectFrom(Vector v, + public LongVector256 selectFrom(Vector v, VectorMask m) { - return (Long256Vector) - super.selectFromTemplate((Long256Vector) v, - Long256Mask.class, (Long256Mask) m); // specialize + return (LongVector256) + super.selectFromTemplate((LongVector256) v, + LongMask256.class, (LongMask256) m); // specialize } @Override @ForceInline - public Long256Vector selectFrom(Vector v1, + public LongVector256 selectFrom(Vector v1, Vector v2) { - return (Long256Vector) - super.selectFromTemplate((Long256Vector) v1, (Long256Vector) v2); // specialize + return (LongVector256) + super.selectFromTemplate((LongVector256) v1, (LongVector256) v2); // specialize } @ForceInline @@ -536,7 +542,7 @@ final class Long256Vector extends LongVector { @ForceInline @Override - public Long256Vector withLane(int i, long e) { + public LongVector256 withLane(int i, long e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -547,7 +553,7 @@ final class Long256Vector extends LongVector { } @ForceInline - public Long256Vector withLaneHelper(int i, long e) { + public LongVector256 withLaneHelper(int i, long e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -559,20 +565,21 @@ final class Long256Vector extends LongVector { } // Mask - - static final class Long256Mask extends AbstractMask { + @ValueBased + static final class LongMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long256Mask(boolean[] bits) { + static final Class CTYPE = long.class; // used by the JVM + + LongMask256(boolean[] bits) { this(bits, 0); } - Long256Mask(boolean[] bits, int offset) { + LongMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Long256Mask(boolean val) { + LongMask256(boolean val) { super(prepare(val)); } @@ -605,31 +612,31 @@ final class Long256Vector extends LongVector { } @Override - Long256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Long256Mask(res); + return new LongMask256(res); } @Override - Long256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Long256Mask)m).getBits(); + boolean[] mbits = ((LongMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Long256Mask(res); + return new LongMask256(res); } @ForceInline @Override public final - Long256Vector toVector() { - return (Long256Vector) super.toVectorTemplate(); // specialize + LongVector256 toVector() { + return (LongVector256) super.toVectorTemplate(); // specialize } /** @@ -662,25 +669,25 @@ final class Long256Vector extends LongVector { @Override @ForceInline /*package-private*/ - Long256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Long256Mask) VectorSupport.indexPartiallyInUpperRange( - Long256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Long256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + LongMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (LongMask256) VectorSupport.indexPartiallyInUpperRange( + LongMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (LongMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Long256Mask not() { + public LongMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Long256Mask compress() { - return (Long256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long256Vector.class, Long256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public LongMask256 compress() { + return (LongMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + LongVector256.class, LongMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -689,30 +696,30 @@ final class Long256Vector extends LongVector { @Override @ForceInline - public Long256Mask and(VectorMask mask) { + public LongMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask256 m = (LongMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Long256Mask or(VectorMask mask) { + public LongMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask256 m = (LongMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Long256Mask xor(VectorMask mask) { + public LongMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask256 m = (LongMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -722,21 +729,21 @@ final class Long256Vector extends LongVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -746,7 +753,7 @@ final class Long256Vector extends LongVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -756,7 +763,7 @@ final class Long256Vector extends LongVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(LongMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -765,48 +772,49 @@ final class Long256Vector extends LongVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long256Mask)m).getBits())); + return VectorSupport.test(BT_ne, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((LongMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((LongMask256)m).getBits())); } @ForceInline /*package-private*/ - static Long256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static LongMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(LongMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Long256Mask TRUE_MASK = new Long256Mask(true); - private static final Long256Mask FALSE_MASK = new Long256Mask(false); + private static final LongMask256 TRUE_MASK = new LongMask256(true); + private static final LongMask256 FALSE_MASK = new LongMask256(false); } // Shuffle - - static final class Long256Shuffle extends AbstractShuffle { + @ValueBased + static final class LongShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long256Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + LongShuffle256(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Long256Shuffle(int[] indices, int i) { + LongShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Long256Shuffle(IntUnaryOperator fn) { + LongShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -826,23 +834,23 @@ final class Long256Vector extends LongVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Long256Shuffle IOTA = new Long256Shuffle(IDENTITY); + static final LongShuffle256 IOTA = new LongShuffle256(IDENTITY); @Override @ForceInline - public Long256Vector toVector() { + public LongVector256 toVector() { return toBitsVector(); } @Override @ForceInline - Long256Vector toBitsVector() { - return (Long256Vector) super.toBitsVectorTemplate(); + LongVector256 toBitsVector() { + return (LongVector256) super.toBitsVectorTemplate(); } @Override - Long256Vector toBitsVector0() { - return ((Long256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector256 toBitsVector0() { + return ((LongVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -914,30 +922,30 @@ final class Long256Vector extends LongVector { @Override @ForceInline - public final Long256Mask laneIsValid() { - return (Long256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final LongMask256 laneIsValid() { + return (LongMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Long256Shuffle rearrange(VectorShuffle shuffle) { - Long256Shuffle concreteShuffle = (Long256Shuffle) shuffle; - return (Long256Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final LongShuffle256 rearrange(VectorShuffle shuffle) { + LongShuffle256 concreteShuffle = (LongShuffle256) shuffle; + return (LongShuffle256) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Long256Shuffle wrapIndexes() { - Long256Vector v = toBitsVector(); + public final LongShuffle256 wrapIndexes() { + LongVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Long256Shuffle) v.toShuffle(vspecies(), false); + return (LongShuffle256) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -988,14 +996,14 @@ final class Long256Vector extends LongVector { @Override final LongVector fromArray0(long[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Long256Mask.class, a, offset, (Long256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(LongMask256.class, a, offset, (LongMask256) m, offsetInRange); // specialize } @ForceInline @Override final LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Long256Mask.class, a, offset, indexMap, mapOffset, (Long256Mask) m); + return super.fromArray0Template(LongMask256.class, a, offset, indexMap, mapOffset, (LongMask256) m); } @@ -1011,7 +1019,7 @@ final class Long256Vector extends LongVector { @Override final LongVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Long256Mask.class, ms, offset, (Long256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(LongMask256.class, ms, offset, (LongMask256) m, offsetInRange); // specialize } @ForceInline @@ -1025,14 +1033,14 @@ final class Long256Vector extends LongVector { @Override final void intoArray0(long[] a, int offset, VectorMask m) { - super.intoArray0Template(Long256Mask.class, a, offset, (Long256Mask) m); + super.intoArray0Template(LongMask256.class, a, offset, (LongMask256) m); } @ForceInline @Override final void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Long256Mask.class, a, offset, indexMap, mapOffset, (Long256Mask) m); + super.intoArray0Template(LongMask256.class, a, offset, indexMap, mapOffset, (LongMask256) m); } @@ -1040,7 +1048,7 @@ final class Long256Vector extends LongVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Long256Mask.class, ms, offset, (Long256Mask) m); + super.intoMemorySegment0Template(LongMask256.class, ms, offset, (LongMask256) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector512.java similarity index 66% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector512.java index 169664bc242..3502f209c3b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector512.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Long512Vector extends LongVector { +@ValueBased +final class LongVector512 extends LongVector { static final LongSpecies VSPECIES = (LongSpecies) LongVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Long512Vector.class; + static final Class VCLASS = LongVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + static final Class ETYPE = long.class; // used by the JVM - Long512Vector(long[] v) { + LongVector512(long[] v) { super(v); } - // For compatibility as Long512Vector::new, + // For compatibility as LongVector512::new, // stored into species.vectorFactory. - Long512Vector(Object v) { + LongVector512(Object v) { this((long[]) v); } - static final Long512Vector ZERO = new Long512Vector(new long[VLENGTH]); - static final Long512Vector IOTA = new Long512Vector(VSPECIES.iotaArray()); + static final LongVector512 ZERO = new LongVector512(new long[VLENGTH]); + static final LongVector512 IOTA = new LongVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Long512Vector extends LongVector { @Override public final Class elementType() { return long.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Long.SIZE; } @@ -130,46 +136,46 @@ final class Long512Vector extends LongVector { @Override @ForceInline - public final Long512Vector broadcast(long e) { - return (Long512Vector) super.broadcastTemplate(e); // specialize + public final LongVector512 broadcast(long e) { + return (LongVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Long512Mask maskFromArray(boolean[] bits) { - return new Long512Mask(bits); + LongMask512 maskFromArray(boolean[] bits) { + return new LongMask512(bits); } @Override @ForceInline - Long512Shuffle iotaShuffle() { return Long512Shuffle.IOTA; } + LongShuffle512 iotaShuffle() { return LongShuffle512.IOTA; } @Override @ForceInline - Long512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Long512Shuffle) iotaShuffleTemplate(start, step, wrap); + LongShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (LongShuffle512) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Long512Shuffle shuffleFromArray(int[] indices, int i) { return new Long512Shuffle(indices, i); } + LongShuffle512 shuffleFromArray(int[] indices, int i) { return new LongShuffle512(indices, i); } @Override @ForceInline - Long512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long512Shuffle(fn); } + LongShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new LongShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Long512Vector vectorFactory(long[] vec) { - return new Long512Vector(vec); + LongVector512 vectorFactory(long[] vec) { + return new LongVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -182,31 +188,31 @@ final class Long512Vector extends LongVector { @ForceInline final @Override - Long512Vector uOp(FUnOp f) { - return (Long512Vector) super.uOpTemplate(f); // specialize + LongVector512 uOp(FUnOp f) { + return (LongVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Long512Vector uOp(VectorMask m, FUnOp f) { - return (Long512Vector) - super.uOpTemplate((Long512Mask)m, f); // specialize + LongVector512 uOp(VectorMask m, FUnOp f) { + return (LongVector512) + super.uOpTemplate((LongMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Long512Vector bOp(Vector v, FBinOp f) { - return (Long512Vector) super.bOpTemplate((Long512Vector)v, f); // specialize + LongVector512 bOp(Vector v, FBinOp f) { + return (LongVector512) super.bOpTemplate((LongVector512)v, f); // specialize } @ForceInline final @Override - Long512Vector bOp(Vector v, + LongVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Long512Vector) - super.bOpTemplate((Long512Vector)v, (Long512Mask)m, + return (LongVector512) + super.bOpTemplate((LongVector512)v, (LongMask512)m, f); // specialize } @@ -214,19 +220,19 @@ final class Long512Vector extends LongVector { @ForceInline final @Override - Long512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Long512Vector) - super.tOpTemplate((Long512Vector)v1, (Long512Vector)v2, + LongVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (LongVector512) + super.tOpTemplate((LongVector512)v1, (LongVector512)v2, f); // specialize } @ForceInline final @Override - Long512Vector tOp(Vector v1, Vector v2, + LongVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Long512Vector) - super.tOpTemplate((Long512Vector)v1, (Long512Vector)v2, - (Long512Mask)m, f); // specialize + return (LongVector512) + super.tOpTemplate((LongVector512)v1, (LongVector512)v2, + (LongMask512)m, f); // specialize } @ForceInline @@ -264,64 +270,64 @@ final class Long512Vector extends LongVector { @Override @ForceInline - public Long512Vector lanewise(Unary op) { - return (Long512Vector) super.lanewiseTemplate(op); // specialize + public LongVector512 lanewise(Unary op) { + return (LongVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Long512Vector lanewise(Unary op, VectorMask m) { - return (Long512Vector) super.lanewiseTemplate(op, Long512Mask.class, (Long512Mask) m); // specialize + public LongVector512 lanewise(Unary op, VectorMask m) { + return (LongVector512) super.lanewiseTemplate(op, LongMask512.class, (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector lanewise(Binary op, Vector v) { - return (Long512Vector) super.lanewiseTemplate(op, v); // specialize + public LongVector512 lanewise(Binary op, Vector v) { + return (LongVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Long512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Long512Vector) super.lanewiseTemplate(op, Long512Mask.class, v, (Long512Mask) m); // specialize + public LongVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (LongVector512) super.lanewiseTemplate(op, LongMask512.class, v, (LongMask512) m); // specialize } /*package-private*/ @Override - @ForceInline Long512Vector + @ForceInline LongVector512 lanewiseShift(VectorOperators.Binary op, int e) { - return (Long512Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (LongVector512) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Long512Vector + @ForceInline LongVector512 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Long512Vector) super.lanewiseShiftTemplate(op, Long512Mask.class, e, (Long512Mask) m); // specialize + return (LongVector512) super.lanewiseShiftTemplate(op, LongMask512.class, e, (LongMask512) m); // specialize } /*package-private*/ @Override @ForceInline public final - Long512Vector + LongVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Long512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (LongVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Long512Vector + LongVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Long512Vector) super.lanewiseTemplate(op, Long512Mask.class, v1, v2, (Long512Mask) m); // specialize + return (LongVector512) super.lanewiseTemplate(op, LongMask512.class, v1, v2, (LongMask512) m); // specialize } @Override @ForceInline public final - Long512Vector addIndex(int scale) { - return (Long512Vector) super.addIndexTemplate(scale); // specialize + LongVector512 addIndex(int scale) { + return (LongVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -336,7 +342,7 @@ final class Long512Vector extends LongVector { @ForceInline public final long reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Long512Mask.class, (Long512Mask) m); // specialized + return super.reduceLanesTemplate(op, LongMask512.class, (LongMask512) m); // specialized } @Override @@ -349,7 +355,7 @@ final class Long512Vector extends LongVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Long512Mask.class, (Long512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, LongMask512.class, (LongMask512) m); // specialized } @Override @@ -360,155 +366,155 @@ final class Long512Vector extends LongVector { @Override @ForceInline - public final Long512Shuffle toShuffle() { - return (Long512Shuffle) toShuffle(vspecies(), false); + public final LongShuffle512 toShuffle() { + return (LongShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Long512Mask test(Test op) { - return super.testTemplate(Long512Mask.class, op); // specialize + public final LongMask512 test(Test op) { + return super.testTemplate(LongMask512.class, op); // specialize } @Override @ForceInline - public final Long512Mask test(Test op, VectorMask m) { - return super.testTemplate(Long512Mask.class, op, (Long512Mask) m); // specialize + public final LongMask512 test(Test op, VectorMask m) { + return super.testTemplate(LongMask512.class, op, (LongMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Long512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Long512Mask.class, op, v); // specialize + public final LongMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(LongMask512.class, op, v); // specialize } @Override @ForceInline - public final Long512Mask compare(Comparison op, long s) { - return super.compareTemplate(Long512Mask.class, op, s); // specialize + public final LongMask512 compare(Comparison op, long s) { + return super.compareTemplate(LongMask512.class, op, s); // specialize } @Override @ForceInline - public final Long512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Long512Mask.class, op, v, (Long512Mask) m); + public final LongMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(LongMask512.class, op, v, (LongMask512) m); } @Override @ForceInline - public Long512Vector blend(Vector v, VectorMask m) { - return (Long512Vector) - super.blendTemplate(Long512Mask.class, - (Long512Vector) v, - (Long512Mask) m); // specialize + public LongVector512 blend(Vector v, VectorMask m) { + return (LongVector512) + super.blendTemplate(LongMask512.class, + (LongVector512) v, + (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector slice(int origin, Vector v) { - return (Long512Vector) super.sliceTemplate(origin, v); // specialize + public LongVector512 slice(int origin, Vector v) { + return (LongVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Long512Vector slice(int origin) { - return (Long512Vector) super.sliceTemplate(origin); // specialize + public LongVector512 slice(int origin) { + return (LongVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Long512Vector unslice(int origin, Vector w, int part) { - return (Long512Vector) super.unsliceTemplate(origin, w, part); // specialize + public LongVector512 unslice(int origin, Vector w, int part) { + return (LongVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Long512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Long512Vector) - super.unsliceTemplate(Long512Mask.class, + public LongVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (LongVector512) + super.unsliceTemplate(LongMask512.class, origin, w, part, - (Long512Mask) m); // specialize + (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector unslice(int origin) { - return (Long512Vector) super.unsliceTemplate(origin); // specialize + public LongVector512 unslice(int origin) { + return (LongVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Long512Vector rearrange(VectorShuffle s) { - return (Long512Vector) - super.rearrangeTemplate(Long512Shuffle.class, - (Long512Shuffle) s); // specialize + public LongVector512 rearrange(VectorShuffle s) { + return (LongVector512) + super.rearrangeTemplate(LongShuffle512.class, + (LongShuffle512) s); // specialize } @Override @ForceInline - public Long512Vector rearrange(VectorShuffle shuffle, + public LongVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Long512Vector) - super.rearrangeTemplate(Long512Shuffle.class, - Long512Mask.class, - (Long512Shuffle) shuffle, - (Long512Mask) m); // specialize + return (LongVector512) + super.rearrangeTemplate(LongShuffle512.class, + LongMask512.class, + (LongShuffle512) shuffle, + (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector rearrange(VectorShuffle s, + public LongVector512 rearrange(VectorShuffle s, Vector v) { - return (Long512Vector) - super.rearrangeTemplate(Long512Shuffle.class, - (Long512Shuffle) s, - (Long512Vector) v); // specialize + return (LongVector512) + super.rearrangeTemplate(LongShuffle512.class, + (LongShuffle512) s, + (LongVector512) v); // specialize } @Override @ForceInline - public Long512Vector compress(VectorMask m) { - return (Long512Vector) - super.compressTemplate(Long512Mask.class, - (Long512Mask) m); // specialize + public LongVector512 compress(VectorMask m) { + return (LongVector512) + super.compressTemplate(LongMask512.class, + (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector expand(VectorMask m) { - return (Long512Vector) - super.expandTemplate(Long512Mask.class, - (Long512Mask) m); // specialize + public LongVector512 expand(VectorMask m) { + return (LongVector512) + super.expandTemplate(LongMask512.class, + (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector selectFrom(Vector v) { - return (Long512Vector) - super.selectFromTemplate((Long512Vector) v); // specialize + public LongVector512 selectFrom(Vector v) { + return (LongVector512) + super.selectFromTemplate((LongVector512) v); // specialize } @Override @ForceInline - public Long512Vector selectFrom(Vector v, + public LongVector512 selectFrom(Vector v, VectorMask m) { - return (Long512Vector) - super.selectFromTemplate((Long512Vector) v, - Long512Mask.class, (Long512Mask) m); // specialize + return (LongVector512) + super.selectFromTemplate((LongVector512) v, + LongMask512.class, (LongMask512) m); // specialize } @Override @ForceInline - public Long512Vector selectFrom(Vector v1, + public LongVector512 selectFrom(Vector v1, Vector v2) { - return (Long512Vector) - super.selectFromTemplate((Long512Vector) v1, (Long512Vector) v2); // specialize + return (LongVector512) + super.selectFromTemplate((LongVector512) v1, (LongVector512) v2); // specialize } @ForceInline @@ -540,7 +546,7 @@ final class Long512Vector extends LongVector { @ForceInline @Override - public Long512Vector withLane(int i, long e) { + public LongVector512 withLane(int i, long e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -555,7 +561,7 @@ final class Long512Vector extends LongVector { } @ForceInline - public Long512Vector withLaneHelper(int i, long e) { + public LongVector512 withLaneHelper(int i, long e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -567,20 +573,21 @@ final class Long512Vector extends LongVector { } // Mask - - static final class Long512Mask extends AbstractMask { + @ValueBased + static final class LongMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long512Mask(boolean[] bits) { + static final Class CTYPE = long.class; // used by the JVM + + LongMask512(boolean[] bits) { this(bits, 0); } - Long512Mask(boolean[] bits, int offset) { + LongMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Long512Mask(boolean val) { + LongMask512(boolean val) { super(prepare(val)); } @@ -613,31 +620,31 @@ final class Long512Vector extends LongVector { } @Override - Long512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Long512Mask(res); + return new LongMask512(res); } @Override - Long512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Long512Mask)m).getBits(); + boolean[] mbits = ((LongMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Long512Mask(res); + return new LongMask512(res); } @ForceInline @Override public final - Long512Vector toVector() { - return (Long512Vector) super.toVectorTemplate(); // specialize + LongVector512 toVector() { + return (LongVector512) super.toVectorTemplate(); // specialize } /** @@ -670,25 +677,25 @@ final class Long512Vector extends LongVector { @Override @ForceInline /*package-private*/ - Long512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Long512Mask) VectorSupport.indexPartiallyInUpperRange( - Long512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Long512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + LongMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (LongMask512) VectorSupport.indexPartiallyInUpperRange( + LongMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (LongMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Long512Mask not() { + public LongMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Long512Mask compress() { - return (Long512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long512Vector.class, Long512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public LongMask512 compress() { + return (LongMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + LongVector512.class, LongMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -697,30 +704,30 @@ final class Long512Vector extends LongVector { @Override @ForceInline - public Long512Mask and(VectorMask mask) { + public LongMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask512 m = (LongMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Long512Mask or(VectorMask mask) { + public LongMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask512 m = (LongMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Long512Mask xor(VectorMask mask) { + public LongMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask512 m = (LongMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -730,21 +737,21 @@ final class Long512Vector extends LongVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -754,7 +761,7 @@ final class Long512Vector extends LongVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -764,7 +771,7 @@ final class Long512Vector extends LongVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(LongMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -773,48 +780,49 @@ final class Long512Vector extends LongVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long512Mask)m).getBits())); + return VectorSupport.test(BT_ne, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((LongMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((LongMask512)m).getBits())); } @ForceInline /*package-private*/ - static Long512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static LongMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(LongMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Long512Mask TRUE_MASK = new Long512Mask(true); - private static final Long512Mask FALSE_MASK = new Long512Mask(false); + private static final LongMask512 TRUE_MASK = new LongMask512(true); + private static final LongMask512 FALSE_MASK = new LongMask512(false); } // Shuffle - - static final class Long512Shuffle extends AbstractShuffle { + @ValueBased + static final class LongShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long512Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + LongShuffle512(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Long512Shuffle(int[] indices, int i) { + LongShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Long512Shuffle(IntUnaryOperator fn) { + LongShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -834,23 +842,23 @@ final class Long512Vector extends LongVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Long512Shuffle IOTA = new Long512Shuffle(IDENTITY); + static final LongShuffle512 IOTA = new LongShuffle512(IDENTITY); @Override @ForceInline - public Long512Vector toVector() { + public LongVector512 toVector() { return toBitsVector(); } @Override @ForceInline - Long512Vector toBitsVector() { - return (Long512Vector) super.toBitsVectorTemplate(); + LongVector512 toBitsVector() { + return (LongVector512) super.toBitsVectorTemplate(); } @Override - Long512Vector toBitsVector0() { - return ((Long512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector512 toBitsVector0() { + return ((LongVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -922,30 +930,30 @@ final class Long512Vector extends LongVector { @Override @ForceInline - public final Long512Mask laneIsValid() { - return (Long512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final LongMask512 laneIsValid() { + return (LongMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Long512Shuffle rearrange(VectorShuffle shuffle) { - Long512Shuffle concreteShuffle = (Long512Shuffle) shuffle; - return (Long512Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final LongShuffle512 rearrange(VectorShuffle shuffle) { + LongShuffle512 concreteShuffle = (LongShuffle512) shuffle; + return (LongShuffle512) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Long512Shuffle wrapIndexes() { - Long512Vector v = toBitsVector(); + public final LongShuffle512 wrapIndexes() { + LongVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Long512Shuffle) v.toShuffle(vspecies(), false); + return (LongShuffle512) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -996,14 +1004,14 @@ final class Long512Vector extends LongVector { @Override final LongVector fromArray0(long[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Long512Mask.class, a, offset, (Long512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(LongMask512.class, a, offset, (LongMask512) m, offsetInRange); // specialize } @ForceInline @Override final LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Long512Mask.class, a, offset, indexMap, mapOffset, (Long512Mask) m); + return super.fromArray0Template(LongMask512.class, a, offset, indexMap, mapOffset, (LongMask512) m); } @@ -1019,7 +1027,7 @@ final class Long512Vector extends LongVector { @Override final LongVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Long512Mask.class, ms, offset, (Long512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(LongMask512.class, ms, offset, (LongMask512) m, offsetInRange); // specialize } @ForceInline @@ -1033,14 +1041,14 @@ final class Long512Vector extends LongVector { @Override final void intoArray0(long[] a, int offset, VectorMask m) { - super.intoArray0Template(Long512Mask.class, a, offset, (Long512Mask) m); + super.intoArray0Template(LongMask512.class, a, offset, (LongMask512) m); } @ForceInline @Override final void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Long512Mask.class, a, offset, indexMap, mapOffset, (Long512Mask) m); + super.intoArray0Template(LongMask512.class, a, offset, indexMap, mapOffset, (LongMask512) m); } @@ -1048,7 +1056,7 @@ final class Long512Vector extends LongVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Long512Mask.class, ms, offset, (Long512Mask) m); + super.intoMemorySegment0Template(LongMask512.class, ms, offset, (LongMask512) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector64.java similarity index 66% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector64.java index 66c84fde56f..2a2fe4329a8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector64.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Long64Vector extends LongVector { +@ValueBased +final class LongVector64 extends LongVector { static final LongSpecies VSPECIES = (LongSpecies) LongVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Long64Vector.class; + static final Class VCLASS = LongVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + static final Class ETYPE = long.class; // used by the JVM - Long64Vector(long[] v) { + LongVector64(long[] v) { super(v); } - // For compatibility as Long64Vector::new, + // For compatibility as LongVector64::new, // stored into species.vectorFactory. - Long64Vector(Object v) { + LongVector64(Object v) { this((long[]) v); } - static final Long64Vector ZERO = new Long64Vector(new long[VLENGTH]); - static final Long64Vector IOTA = new Long64Vector(VSPECIES.iotaArray()); + static final LongVector64 ZERO = new LongVector64(new long[VLENGTH]); + static final LongVector64 IOTA = new LongVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class Long64Vector extends LongVector { @Override public final Class elementType() { return long.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Long.SIZE; } @@ -130,46 +136,46 @@ final class Long64Vector extends LongVector { @Override @ForceInline - public final Long64Vector broadcast(long e) { - return (Long64Vector) super.broadcastTemplate(e); // specialize + public final LongVector64 broadcast(long e) { + return (LongVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Long64Mask maskFromArray(boolean[] bits) { - return new Long64Mask(bits); + LongMask64 maskFromArray(boolean[] bits) { + return new LongMask64(bits); } @Override @ForceInline - Long64Shuffle iotaShuffle() { return Long64Shuffle.IOTA; } + LongShuffle64 iotaShuffle() { return LongShuffle64.IOTA; } @Override @ForceInline - Long64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Long64Shuffle) iotaShuffleTemplate(start, step, wrap); + LongShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (LongShuffle64) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - Long64Shuffle shuffleFromArray(int[] indices, int i) { return new Long64Shuffle(indices, i); } + LongShuffle64 shuffleFromArray(int[] indices, int i) { return new LongShuffle64(indices, i); } @Override @ForceInline - Long64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long64Shuffle(fn); } + LongShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new LongShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Long64Vector vectorFactory(long[] vec) { - return new Long64Vector(vec); + LongVector64 vectorFactory(long[] vec) { + return new LongVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -182,31 +188,31 @@ final class Long64Vector extends LongVector { @ForceInline final @Override - Long64Vector uOp(FUnOp f) { - return (Long64Vector) super.uOpTemplate(f); // specialize + LongVector64 uOp(FUnOp f) { + return (LongVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Long64Vector uOp(VectorMask m, FUnOp f) { - return (Long64Vector) - super.uOpTemplate((Long64Mask)m, f); // specialize + LongVector64 uOp(VectorMask m, FUnOp f) { + return (LongVector64) + super.uOpTemplate((LongMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Long64Vector bOp(Vector v, FBinOp f) { - return (Long64Vector) super.bOpTemplate((Long64Vector)v, f); // specialize + LongVector64 bOp(Vector v, FBinOp f) { + return (LongVector64) super.bOpTemplate((LongVector64)v, f); // specialize } @ForceInline final @Override - Long64Vector bOp(Vector v, + LongVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Long64Vector) - super.bOpTemplate((Long64Vector)v, (Long64Mask)m, + return (LongVector64) + super.bOpTemplate((LongVector64)v, (LongMask64)m, f); // specialize } @@ -214,19 +220,19 @@ final class Long64Vector extends LongVector { @ForceInline final @Override - Long64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Long64Vector) - super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2, + LongVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (LongVector64) + super.tOpTemplate((LongVector64)v1, (LongVector64)v2, f); // specialize } @ForceInline final @Override - Long64Vector tOp(Vector v1, Vector v2, + LongVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Long64Vector) - super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2, - (Long64Mask)m, f); // specialize + return (LongVector64) + super.tOpTemplate((LongVector64)v1, (LongVector64)v2, + (LongMask64)m, f); // specialize } @ForceInline @@ -264,64 +270,64 @@ final class Long64Vector extends LongVector { @Override @ForceInline - public Long64Vector lanewise(Unary op) { - return (Long64Vector) super.lanewiseTemplate(op); // specialize + public LongVector64 lanewise(Unary op) { + return (LongVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Long64Vector lanewise(Unary op, VectorMask m) { - return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, (Long64Mask) m); // specialize + public LongVector64 lanewise(Unary op, VectorMask m) { + return (LongVector64) super.lanewiseTemplate(op, LongMask64.class, (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector lanewise(Binary op, Vector v) { - return (Long64Vector) super.lanewiseTemplate(op, v); // specialize + public LongVector64 lanewise(Binary op, Vector v) { + return (LongVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Long64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, v, (Long64Mask) m); // specialize + public LongVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (LongVector64) super.lanewiseTemplate(op, LongMask64.class, v, (LongMask64) m); // specialize } /*package-private*/ @Override - @ForceInline Long64Vector + @ForceInline LongVector64 lanewiseShift(VectorOperators.Binary op, int e) { - return (Long64Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (LongVector64) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Long64Vector + @ForceInline LongVector64 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Long64Vector) super.lanewiseShiftTemplate(op, Long64Mask.class, e, (Long64Mask) m); // specialize + return (LongVector64) super.lanewiseShiftTemplate(op, LongMask64.class, e, (LongMask64) m); // specialize } /*package-private*/ @Override @ForceInline public final - Long64Vector + LongVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Long64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (LongVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Long64Vector + LongVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, v1, v2, (Long64Mask) m); // specialize + return (LongVector64) super.lanewiseTemplate(op, LongMask64.class, v1, v2, (LongMask64) m); // specialize } @Override @ForceInline public final - Long64Vector addIndex(int scale) { - return (Long64Vector) super.addIndexTemplate(scale); // specialize + LongVector64 addIndex(int scale) { + return (LongVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -336,7 +342,7 @@ final class Long64Vector extends LongVector { @ForceInline public final long reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Long64Mask.class, (Long64Mask) m); // specialized + return super.reduceLanesTemplate(op, LongMask64.class, (LongMask64) m); // specialized } @Override @@ -349,7 +355,7 @@ final class Long64Vector extends LongVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Long64Mask.class, (Long64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, LongMask64.class, (LongMask64) m); // specialized } @Override @@ -360,155 +366,155 @@ final class Long64Vector extends LongVector { @Override @ForceInline - public final Long64Shuffle toShuffle() { - return (Long64Shuffle) toShuffle(vspecies(), false); + public final LongShuffle64 toShuffle() { + return (LongShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Long64Mask test(Test op) { - return super.testTemplate(Long64Mask.class, op); // specialize + public final LongMask64 test(Test op) { + return super.testTemplate(LongMask64.class, op); // specialize } @Override @ForceInline - public final Long64Mask test(Test op, VectorMask m) { - return super.testTemplate(Long64Mask.class, op, (Long64Mask) m); // specialize + public final LongMask64 test(Test op, VectorMask m) { + return super.testTemplate(LongMask64.class, op, (LongMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Long64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Long64Mask.class, op, v); // specialize + public final LongMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(LongMask64.class, op, v); // specialize } @Override @ForceInline - public final Long64Mask compare(Comparison op, long s) { - return super.compareTemplate(Long64Mask.class, op, s); // specialize + public final LongMask64 compare(Comparison op, long s) { + return super.compareTemplate(LongMask64.class, op, s); // specialize } @Override @ForceInline - public final Long64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Long64Mask.class, op, v, (Long64Mask) m); + public final LongMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(LongMask64.class, op, v, (LongMask64) m); } @Override @ForceInline - public Long64Vector blend(Vector v, VectorMask m) { - return (Long64Vector) - super.blendTemplate(Long64Mask.class, - (Long64Vector) v, - (Long64Mask) m); // specialize + public LongVector64 blend(Vector v, VectorMask m) { + return (LongVector64) + super.blendTemplate(LongMask64.class, + (LongVector64) v, + (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector slice(int origin, Vector v) { - return (Long64Vector) super.sliceTemplate(origin, v); // specialize + public LongVector64 slice(int origin, Vector v) { + return (LongVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Long64Vector slice(int origin) { - return (Long64Vector) super.sliceTemplate(origin); // specialize + public LongVector64 slice(int origin) { + return (LongVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Long64Vector unslice(int origin, Vector w, int part) { - return (Long64Vector) super.unsliceTemplate(origin, w, part); // specialize + public LongVector64 unslice(int origin, Vector w, int part) { + return (LongVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Long64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Long64Vector) - super.unsliceTemplate(Long64Mask.class, + public LongVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (LongVector64) + super.unsliceTemplate(LongMask64.class, origin, w, part, - (Long64Mask) m); // specialize + (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector unslice(int origin) { - return (Long64Vector) super.unsliceTemplate(origin); // specialize + public LongVector64 unslice(int origin) { + return (LongVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Long64Vector rearrange(VectorShuffle s) { - return (Long64Vector) - super.rearrangeTemplate(Long64Shuffle.class, - (Long64Shuffle) s); // specialize + public LongVector64 rearrange(VectorShuffle s) { + return (LongVector64) + super.rearrangeTemplate(LongShuffle64.class, + (LongShuffle64) s); // specialize } @Override @ForceInline - public Long64Vector rearrange(VectorShuffle shuffle, + public LongVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Long64Vector) - super.rearrangeTemplate(Long64Shuffle.class, - Long64Mask.class, - (Long64Shuffle) shuffle, - (Long64Mask) m); // specialize + return (LongVector64) + super.rearrangeTemplate(LongShuffle64.class, + LongMask64.class, + (LongShuffle64) shuffle, + (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector rearrange(VectorShuffle s, + public LongVector64 rearrange(VectorShuffle s, Vector v) { - return (Long64Vector) - super.rearrangeTemplate(Long64Shuffle.class, - (Long64Shuffle) s, - (Long64Vector) v); // specialize + return (LongVector64) + super.rearrangeTemplate(LongShuffle64.class, + (LongShuffle64) s, + (LongVector64) v); // specialize } @Override @ForceInline - public Long64Vector compress(VectorMask m) { - return (Long64Vector) - super.compressTemplate(Long64Mask.class, - (Long64Mask) m); // specialize + public LongVector64 compress(VectorMask m) { + return (LongVector64) + super.compressTemplate(LongMask64.class, + (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector expand(VectorMask m) { - return (Long64Vector) - super.expandTemplate(Long64Mask.class, - (Long64Mask) m); // specialize + public LongVector64 expand(VectorMask m) { + return (LongVector64) + super.expandTemplate(LongMask64.class, + (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector selectFrom(Vector v) { - return (Long64Vector) - super.selectFromTemplate((Long64Vector) v); // specialize + public LongVector64 selectFrom(Vector v) { + return (LongVector64) + super.selectFromTemplate((LongVector64) v); // specialize } @Override @ForceInline - public Long64Vector selectFrom(Vector v, + public LongVector64 selectFrom(Vector v, VectorMask m) { - return (Long64Vector) - super.selectFromTemplate((Long64Vector) v, - Long64Mask.class, (Long64Mask) m); // specialize + return (LongVector64) + super.selectFromTemplate((LongVector64) v, + LongMask64.class, (LongMask64) m); // specialize } @Override @ForceInline - public Long64Vector selectFrom(Vector v1, + public LongVector64 selectFrom(Vector v1, Vector v2) { - return (Long64Vector) - super.selectFromTemplate((Long64Vector) v1, (Long64Vector) v2); // specialize + return (LongVector64) + super.selectFromTemplate((LongVector64) v1, (LongVector64) v2); // specialize } @ForceInline @@ -533,7 +539,7 @@ final class Long64Vector extends LongVector { @ForceInline @Override - public Long64Vector withLane(int i, long e) { + public LongVector64 withLane(int i, long e) { switch (i) { case 0: return withLaneHelper(0, e); default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); @@ -541,7 +547,7 @@ final class Long64Vector extends LongVector { } @ForceInline - public Long64Vector withLaneHelper(int i, long e) { + public LongVector64 withLaneHelper(int i, long e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -553,20 +559,21 @@ final class Long64Vector extends LongVector { } // Mask - - static final class Long64Mask extends AbstractMask { + @ValueBased + static final class LongMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long64Mask(boolean[] bits) { + static final Class CTYPE = long.class; // used by the JVM + + LongMask64(boolean[] bits) { this(bits, 0); } - Long64Mask(boolean[] bits, int offset) { + LongMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Long64Mask(boolean val) { + LongMask64(boolean val) { super(prepare(val)); } @@ -599,31 +606,31 @@ final class Long64Vector extends LongVector { } @Override - Long64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Long64Mask(res); + return new LongMask64(res); } @Override - Long64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Long64Mask)m).getBits(); + boolean[] mbits = ((LongMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Long64Mask(res); + return new LongMask64(res); } @ForceInline @Override public final - Long64Vector toVector() { - return (Long64Vector) super.toVectorTemplate(); // specialize + LongVector64 toVector() { + return (LongVector64) super.toVectorTemplate(); // specialize } /** @@ -656,25 +663,25 @@ final class Long64Vector extends LongVector { @Override @ForceInline /*package-private*/ - Long64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Long64Mask) VectorSupport.indexPartiallyInUpperRange( - Long64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Long64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + LongMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (LongMask64) VectorSupport.indexPartiallyInUpperRange( + LongMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (LongMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Long64Mask not() { + public LongMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Long64Mask compress() { - return (Long64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long64Vector.class, Long64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public LongMask64 compress() { + return (LongMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + LongVector64.class, LongMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -683,30 +690,30 @@ final class Long64Vector extends LongVector { @Override @ForceInline - public Long64Mask and(VectorMask mask) { + public LongMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask64 m = (LongMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Long64Mask or(VectorMask mask) { + public LongMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask64 m = (LongMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Long64Mask xor(VectorMask mask) { + public LongMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMask64 m = (LongMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -716,21 +723,21 @@ final class Long64Vector extends LongVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -740,7 +747,7 @@ final class Long64Vector extends LongVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -750,7 +757,7 @@ final class Long64Vector extends LongVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(LongMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -759,48 +766,49 @@ final class Long64Vector extends LongVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long64Mask)m).getBits())); + return VectorSupport.test(BT_ne, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((LongMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((LongMask64)m).getBits())); } @ForceInline /*package-private*/ - static Long64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static LongMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(LongMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Long64Mask TRUE_MASK = new Long64Mask(true); - private static final Long64Mask FALSE_MASK = new Long64Mask(false); + private static final LongMask64 TRUE_MASK = new LongMask64(true); + private static final LongMask64 FALSE_MASK = new LongMask64(false); } // Shuffle - - static final class Long64Shuffle extends AbstractShuffle { + @ValueBased + static final class LongShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - Long64Shuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + LongShuffle64(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Long64Shuffle(int[] indices, int i) { + LongShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Long64Shuffle(IntUnaryOperator fn) { + LongShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -820,23 +828,23 @@ final class Long64Vector extends LongVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final Long64Shuffle IOTA = new Long64Shuffle(IDENTITY); + static final LongShuffle64 IOTA = new LongShuffle64(IDENTITY); @Override @ForceInline - public Long64Vector toVector() { + public LongVector64 toVector() { return toBitsVector(); } @Override @ForceInline - Long64Vector toBitsVector() { - return (Long64Vector) super.toBitsVectorTemplate(); + LongVector64 toBitsVector() { + return (LongVector64) super.toBitsVectorTemplate(); } @Override - Long64Vector toBitsVector0() { - return ((Long64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVector64 toBitsVector0() { + return ((LongVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -908,30 +916,30 @@ final class Long64Vector extends LongVector { @Override @ForceInline - public final Long64Mask laneIsValid() { - return (Long64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final LongMask64 laneIsValid() { + return (LongMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Long64Shuffle rearrange(VectorShuffle shuffle) { - Long64Shuffle concreteShuffle = (Long64Shuffle) shuffle; - return (Long64Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final LongShuffle64 rearrange(VectorShuffle shuffle) { + LongShuffle64 concreteShuffle = (LongShuffle64) shuffle; + return (LongShuffle64) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Long64Shuffle wrapIndexes() { - Long64Vector v = toBitsVector(); + public final LongShuffle64 wrapIndexes() { + LongVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Long64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Long64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Long64Shuffle) v.toShuffle(vspecies(), false); + return (LongShuffle64) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -982,14 +990,14 @@ final class Long64Vector extends LongVector { @Override final LongVector fromArray0(long[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Long64Mask.class, a, offset, (Long64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(LongMask64.class, a, offset, (LongMask64) m, offsetInRange); // specialize } @ForceInline @Override final LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Long64Mask.class, a, offset, indexMap, mapOffset, (Long64Mask) m); + return super.fromArray0Template(LongMask64.class, a, offset, indexMap, mapOffset, (LongMask64) m); } @@ -1005,7 +1013,7 @@ final class Long64Vector extends LongVector { @Override final LongVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Long64Mask.class, ms, offset, (Long64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(LongMask64.class, ms, offset, (LongMask64) m, offsetInRange); // specialize } @ForceInline @@ -1019,14 +1027,14 @@ final class Long64Vector extends LongVector { @Override final void intoArray0(long[] a, int offset, VectorMask m) { - super.intoArray0Template(Long64Mask.class, a, offset, (Long64Mask) m); + super.intoArray0Template(LongMask64.class, a, offset, (LongMask64) m); } @ForceInline @Override final void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(Long64Mask.class, a, offset, indexMap, mapOffset, (Long64Mask) m); + super.intoArray0Template(LongMask64.class, a, offset, indexMap, mapOffset, (LongMask64) m); } @@ -1034,7 +1042,7 @@ final class Long64Vector extends LongVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Long64Mask.class, ms, offset, (Long64Mask) m); + super.intoMemorySegment0Template(LongMask64.class, ms, offset, (LongMask64) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVectorMax.java similarity index 65% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVectorMax.java index c95db0c4482..157c58e20e8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVectorMax.java @@ -31,43 +31,46 @@ import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class LongMaxVector extends LongVector { +@ValueBased +final class LongVectorMax extends LongVector { static final LongSpecies VSPECIES = (LongSpecies) LongVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = LongMaxVector.class; + static final Class VCLASS = LongVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + static final Class ETYPE = long.class; // used by the JVM - LongMaxVector(long[] v) { + LongVectorMax(long[] v) { super(v); } - // For compatibility as LongMaxVector::new, + // For compatibility as LongVectorMax::new, // stored into species.vectorFactory. - LongMaxVector(Object v) { + LongVectorMax(Object v) { this((long[]) v); } - static final LongMaxVector ZERO = new LongMaxVector(new long[VLENGTH]); - static final LongMaxVector IOTA = new LongMaxVector(VSPECIES.iotaArray()); + static final LongVectorMax ZERO = new LongVectorMax(new long[VLENGTH]); + static final LongVectorMax IOTA = new LongVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +95,9 @@ final class LongMaxVector extends LongVector { @Override public final Class elementType() { return long.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Long.SIZE; } @@ -130,46 +136,46 @@ final class LongMaxVector extends LongVector { @Override @ForceInline - public final LongMaxVector broadcast(long e) { - return (LongMaxVector) super.broadcastTemplate(e); // specialize + public final LongVectorMax broadcast(long e) { + return (LongVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - LongMaxMask maskFromArray(boolean[] bits) { - return new LongMaxMask(bits); + LongMaskMax maskFromArray(boolean[] bits) { + return new LongMaskMax(bits); } @Override @ForceInline - LongMaxShuffle iotaShuffle() { return LongMaxShuffle.IOTA; } + LongShuffleMax iotaShuffle() { return LongShuffleMax.IOTA; } @Override @ForceInline - LongMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (LongMaxShuffle) iotaShuffleTemplate(start, step, wrap); + LongShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (LongShuffleMax) iotaShuffleTemplate(start, step, wrap); } @Override @ForceInline - LongMaxShuffle shuffleFromArray(int[] indices, int i) { return new LongMaxShuffle(indices, i); } + LongShuffleMax shuffleFromArray(int[] indices, int i) { return new LongShuffleMax(indices, i); } @Override @ForceInline - LongMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new LongMaxShuffle(fn); } + LongShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new LongShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - LongMaxVector vectorFactory(long[] vec) { - return new LongMaxVector(vec); + LongVectorMax vectorFactory(long[] vec) { + return new LongVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -182,31 +188,31 @@ final class LongMaxVector extends LongVector { @ForceInline final @Override - LongMaxVector uOp(FUnOp f) { - return (LongMaxVector) super.uOpTemplate(f); // specialize + LongVectorMax uOp(FUnOp f) { + return (LongVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - LongMaxVector uOp(VectorMask m, FUnOp f) { - return (LongMaxVector) - super.uOpTemplate((LongMaxMask)m, f); // specialize + LongVectorMax uOp(VectorMask m, FUnOp f) { + return (LongVectorMax) + super.uOpTemplate((LongMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - LongMaxVector bOp(Vector v, FBinOp f) { - return (LongMaxVector) super.bOpTemplate((LongMaxVector)v, f); // specialize + LongVectorMax bOp(Vector v, FBinOp f) { + return (LongVectorMax) super.bOpTemplate((LongVectorMax)v, f); // specialize } @ForceInline final @Override - LongMaxVector bOp(Vector v, + LongVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (LongMaxVector) - super.bOpTemplate((LongMaxVector)v, (LongMaxMask)m, + return (LongVectorMax) + super.bOpTemplate((LongVectorMax)v, (LongMaskMax)m, f); // specialize } @@ -214,19 +220,19 @@ final class LongMaxVector extends LongVector { @ForceInline final @Override - LongMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (LongMaxVector) - super.tOpTemplate((LongMaxVector)v1, (LongMaxVector)v2, + LongVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (LongVectorMax) + super.tOpTemplate((LongVectorMax)v1, (LongVectorMax)v2, f); // specialize } @ForceInline final @Override - LongMaxVector tOp(Vector v1, Vector v2, + LongVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (LongMaxVector) - super.tOpTemplate((LongMaxVector)v1, (LongMaxVector)v2, - (LongMaxMask)m, f); // specialize + return (LongVectorMax) + super.tOpTemplate((LongVectorMax)v1, (LongVectorMax)v2, + (LongMaskMax)m, f); // specialize } @ForceInline @@ -264,64 +270,64 @@ final class LongMaxVector extends LongVector { @Override @ForceInline - public LongMaxVector lanewise(Unary op) { - return (LongMaxVector) super.lanewiseTemplate(op); // specialize + public LongVectorMax lanewise(Unary op) { + return (LongVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public LongMaxVector lanewise(Unary op, VectorMask m) { - return (LongMaxVector) super.lanewiseTemplate(op, LongMaxMask.class, (LongMaxMask) m); // specialize + public LongVectorMax lanewise(Unary op, VectorMask m) { + return (LongVectorMax) super.lanewiseTemplate(op, LongMaskMax.class, (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector lanewise(Binary op, Vector v) { - return (LongMaxVector) super.lanewiseTemplate(op, v); // specialize + public LongVectorMax lanewise(Binary op, Vector v) { + return (LongVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public LongMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (LongMaxVector) super.lanewiseTemplate(op, LongMaxMask.class, v, (LongMaxMask) m); // specialize + public LongVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (LongVectorMax) super.lanewiseTemplate(op, LongMaskMax.class, v, (LongMaskMax) m); // specialize } /*package-private*/ @Override - @ForceInline LongMaxVector + @ForceInline LongVectorMax lanewiseShift(VectorOperators.Binary op, int e) { - return (LongMaxVector) super.lanewiseShiftTemplate(op, e); // specialize + return (LongVectorMax) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline LongMaxVector + @ForceInline LongVectorMax lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (LongMaxVector) super.lanewiseShiftTemplate(op, LongMaxMask.class, e, (LongMaxMask) m); // specialize + return (LongVectorMax) super.lanewiseShiftTemplate(op, LongMaskMax.class, e, (LongMaskMax) m); // specialize } /*package-private*/ @Override @ForceInline public final - LongMaxVector + LongVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (LongMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (LongVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - LongMaxVector + LongVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (LongMaxVector) super.lanewiseTemplate(op, LongMaxMask.class, v1, v2, (LongMaxMask) m); // specialize + return (LongVectorMax) super.lanewiseTemplate(op, LongMaskMax.class, v1, v2, (LongMaskMax) m); // specialize } @Override @ForceInline public final - LongMaxVector addIndex(int scale) { - return (LongMaxVector) super.addIndexTemplate(scale); // specialize + LongVectorMax addIndex(int scale) { + return (LongVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -336,7 +342,7 @@ final class LongMaxVector extends LongVector { @ForceInline public final long reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, LongMaxMask.class, (LongMaxMask) m); // specialized + return super.reduceLanesTemplate(op, LongMaskMax.class, (LongMaskMax) m); // specialized } @Override @@ -349,7 +355,7 @@ final class LongMaxVector extends LongVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, LongMaxMask.class, (LongMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, LongMaskMax.class, (LongMaskMax) m); // specialized } @Override @@ -360,155 +366,155 @@ final class LongMaxVector extends LongVector { @Override @ForceInline - public final LongMaxShuffle toShuffle() { - return (LongMaxShuffle) toShuffle(vspecies(), false); + public final LongShuffleMax toShuffle() { + return (LongShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final LongMaxMask test(Test op) { - return super.testTemplate(LongMaxMask.class, op); // specialize + public final LongMaskMax test(Test op) { + return super.testTemplate(LongMaskMax.class, op); // specialize } @Override @ForceInline - public final LongMaxMask test(Test op, VectorMask m) { - return super.testTemplate(LongMaxMask.class, op, (LongMaxMask) m); // specialize + public final LongMaskMax test(Test op, VectorMask m) { + return super.testTemplate(LongMaskMax.class, op, (LongMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final LongMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(LongMaxMask.class, op, v); // specialize + public final LongMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(LongMaskMax.class, op, v); // specialize } @Override @ForceInline - public final LongMaxMask compare(Comparison op, long s) { - return super.compareTemplate(LongMaxMask.class, op, s); // specialize + public final LongMaskMax compare(Comparison op, long s) { + return super.compareTemplate(LongMaskMax.class, op, s); // specialize } @Override @ForceInline - public final LongMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(LongMaxMask.class, op, v, (LongMaxMask) m); + public final LongMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(LongMaskMax.class, op, v, (LongMaskMax) m); } @Override @ForceInline - public LongMaxVector blend(Vector v, VectorMask m) { - return (LongMaxVector) - super.blendTemplate(LongMaxMask.class, - (LongMaxVector) v, - (LongMaxMask) m); // specialize + public LongVectorMax blend(Vector v, VectorMask m) { + return (LongVectorMax) + super.blendTemplate(LongMaskMax.class, + (LongVectorMax) v, + (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector slice(int origin, Vector v) { - return (LongMaxVector) super.sliceTemplate(origin, v); // specialize + public LongVectorMax slice(int origin, Vector v) { + return (LongVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public LongMaxVector slice(int origin) { - return (LongMaxVector) super.sliceTemplate(origin); // specialize + public LongVectorMax slice(int origin) { + return (LongVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public LongMaxVector unslice(int origin, Vector w, int part) { - return (LongMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public LongVectorMax unslice(int origin, Vector w, int part) { + return (LongVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public LongMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (LongMaxVector) - super.unsliceTemplate(LongMaxMask.class, + public LongVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (LongVectorMax) + super.unsliceTemplate(LongMaskMax.class, origin, w, part, - (LongMaxMask) m); // specialize + (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector unslice(int origin) { - return (LongMaxVector) super.unsliceTemplate(origin); // specialize + public LongVectorMax unslice(int origin) { + return (LongVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public LongMaxVector rearrange(VectorShuffle s) { - return (LongMaxVector) - super.rearrangeTemplate(LongMaxShuffle.class, - (LongMaxShuffle) s); // specialize + public LongVectorMax rearrange(VectorShuffle s) { + return (LongVectorMax) + super.rearrangeTemplate(LongShuffleMax.class, + (LongShuffleMax) s); // specialize } @Override @ForceInline - public LongMaxVector rearrange(VectorShuffle shuffle, + public LongVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (LongMaxVector) - super.rearrangeTemplate(LongMaxShuffle.class, - LongMaxMask.class, - (LongMaxShuffle) shuffle, - (LongMaxMask) m); // specialize + return (LongVectorMax) + super.rearrangeTemplate(LongShuffleMax.class, + LongMaskMax.class, + (LongShuffleMax) shuffle, + (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector rearrange(VectorShuffle s, + public LongVectorMax rearrange(VectorShuffle s, Vector v) { - return (LongMaxVector) - super.rearrangeTemplate(LongMaxShuffle.class, - (LongMaxShuffle) s, - (LongMaxVector) v); // specialize + return (LongVectorMax) + super.rearrangeTemplate(LongShuffleMax.class, + (LongShuffleMax) s, + (LongVectorMax) v); // specialize } @Override @ForceInline - public LongMaxVector compress(VectorMask m) { - return (LongMaxVector) - super.compressTemplate(LongMaxMask.class, - (LongMaxMask) m); // specialize + public LongVectorMax compress(VectorMask m) { + return (LongVectorMax) + super.compressTemplate(LongMaskMax.class, + (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector expand(VectorMask m) { - return (LongMaxVector) - super.expandTemplate(LongMaxMask.class, - (LongMaxMask) m); // specialize + public LongVectorMax expand(VectorMask m) { + return (LongVectorMax) + super.expandTemplate(LongMaskMax.class, + (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector selectFrom(Vector v) { - return (LongMaxVector) - super.selectFromTemplate((LongMaxVector) v); // specialize + public LongVectorMax selectFrom(Vector v) { + return (LongVectorMax) + super.selectFromTemplate((LongVectorMax) v); // specialize } @Override @ForceInline - public LongMaxVector selectFrom(Vector v, + public LongVectorMax selectFrom(Vector v, VectorMask m) { - return (LongMaxVector) - super.selectFromTemplate((LongMaxVector) v, - LongMaxMask.class, (LongMaxMask) m); // specialize + return (LongVectorMax) + super.selectFromTemplate((LongVectorMax) v, + LongMaskMax.class, (LongMaskMax) m); // specialize } @Override @ForceInline - public LongMaxVector selectFrom(Vector v1, + public LongVectorMax selectFrom(Vector v1, Vector v2) { - return (LongMaxVector) - super.selectFromTemplate((LongMaxVector) v1, (LongMaxVector) v2); // specialize + return (LongVectorMax) + super.selectFromTemplate((LongVectorMax) v1, (LongVectorMax) v2); // specialize } @ForceInline @@ -533,7 +539,7 @@ final class LongMaxVector extends LongVector { @ForceInline @Override - public LongMaxVector withLane(int i, long e) { + public LongVectorMax withLane(int i, long e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -541,7 +547,7 @@ final class LongMaxVector extends LongVector { } @ForceInline - public LongMaxVector withLaneHelper(int i, long e) { + public LongVectorMax withLaneHelper(int i, long e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -553,20 +559,21 @@ final class LongMaxVector extends LongVector { } // Mask - - static final class LongMaxMask extends AbstractMask { + @ValueBased + static final class LongMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - LongMaxMask(boolean[] bits) { + static final Class CTYPE = long.class; // used by the JVM + + LongMaskMax(boolean[] bits) { this(bits, 0); } - LongMaxMask(boolean[] bits, int offset) { + LongMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - LongMaxMask(boolean val) { + LongMaskMax(boolean val) { super(prepare(val)); } @@ -599,31 +606,31 @@ final class LongMaxVector extends LongVector { } @Override - LongMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new LongMaxMask(res); + return new LongMaskMax(res); } @Override - LongMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + LongMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((LongMaxMask)m).getBits(); + boolean[] mbits = ((LongMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new LongMaxMask(res); + return new LongMaskMax(res); } @ForceInline @Override public final - LongMaxVector toVector() { - return (LongMaxVector) super.toVectorTemplate(); // specialize + LongVectorMax toVector() { + return (LongVectorMax) super.toVectorTemplate(); // specialize } /** @@ -656,25 +663,25 @@ final class LongMaxVector extends LongVector { @Override @ForceInline /*package-private*/ - LongMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (LongMaxMask) VectorSupport.indexPartiallyInUpperRange( - LongMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (LongMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + LongMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (LongMaskMax) VectorSupport.indexPartiallyInUpperRange( + LongMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (LongMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public LongMaxMask not() { + public LongMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public LongMaxMask compress() { - return (LongMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - LongMaxVector.class, LongMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public LongMaskMax compress() { + return (LongMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + LongVectorMax.class, LongMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -683,30 +690,30 @@ final class LongMaxVector extends LongVector { @Override @ForceInline - public LongMaxMask and(VectorMask mask) { + public LongMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, LongMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMaskMax m = (LongMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public LongMaxMask or(VectorMask mask) { + public LongMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, LongMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMaskMax m = (LongMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public LongMaxMask xor(VectorMask mask) { + public LongMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + LongMaskMax m = (LongMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -716,21 +723,21 @@ final class LongMaxVector extends LongVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -740,7 +747,7 @@ final class LongMaxVector extends LongVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -750,7 +757,7 @@ final class LongMaxVector extends LongVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(LongMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(LongMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -759,48 +766,49 @@ final class LongMaxVector extends LongVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((LongMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((LongMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((LongMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((LongMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static LongMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(LongMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static LongMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(LongMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final LongMaxMask TRUE_MASK = new LongMaxMask(true); - private static final LongMaxMask FALSE_MASK = new LongMaxMask(false); + private static final LongMaskMax TRUE_MASK = new LongMaskMax(true); + private static final LongMaskMax FALSE_MASK = new LongMaskMax(false); } // Shuffle - - static final class LongMaxShuffle extends AbstractShuffle { + @ValueBased + static final class LongShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM - LongMaxShuffle(long[] indices) { + static final Class CTYPE = long.class; // used by the JVM + + LongShuffleMax(long[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - LongMaxShuffle(int[] indices, int i) { + LongShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - LongMaxShuffle(IntUnaryOperator fn) { + LongShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -820,23 +828,23 @@ final class LongMaxVector extends LongVector { assert(VLENGTH < Long.MAX_VALUE); assert(Long.MIN_VALUE <= -VLENGTH); } - static final LongMaxShuffle IOTA = new LongMaxShuffle(IDENTITY); + static final LongShuffleMax IOTA = new LongShuffleMax(IDENTITY); @Override @ForceInline - public LongMaxVector toVector() { + public LongVectorMax toVector() { return toBitsVector(); } @Override @ForceInline - LongMaxVector toBitsVector() { - return (LongMaxVector) super.toBitsVectorTemplate(); + LongVectorMax toBitsVector() { + return (LongVectorMax) super.toBitsVectorTemplate(); } @Override - LongMaxVector toBitsVector0() { - return ((LongMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + LongVectorMax toBitsVector0() { + return ((LongVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -908,30 +916,30 @@ final class LongMaxVector extends LongVector { @Override @ForceInline - public final LongMaxMask laneIsValid() { - return (LongMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final LongMaskMax laneIsValid() { + return (LongMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final LongMaxShuffle rearrange(VectorShuffle shuffle) { - LongMaxShuffle concreteShuffle = (LongMaxShuffle) shuffle; - return (LongMaxShuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final LongShuffleMax rearrange(VectorShuffle shuffle) { + LongShuffleMax concreteShuffle = (LongShuffleMax) shuffle; + return (LongShuffleMax) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final LongMaxShuffle wrapIndexes() { - LongMaxVector v = toBitsVector(); + public final LongShuffleMax wrapIndexes() { + LongVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (LongMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (LongVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (LongMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (LongVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (LongMaxShuffle) v.toShuffle(vspecies(), false); + return (LongShuffleMax) v.toShuffle(VSPECIES, false); } private static long[] prepare(int[] indices, int offset) { @@ -982,14 +990,14 @@ final class LongMaxVector extends LongVector { @Override final LongVector fromArray0(long[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(LongMaxMask.class, a, offset, (LongMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(LongMaskMax.class, a, offset, (LongMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(LongMaxMask.class, a, offset, indexMap, mapOffset, (LongMaxMask) m); + return super.fromArray0Template(LongMaskMax.class, a, offset, indexMap, mapOffset, (LongMaskMax) m); } @@ -1005,7 +1013,7 @@ final class LongMaxVector extends LongVector { @Override final LongVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(LongMaxMask.class, ms, offset, (LongMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(LongMaskMax.class, ms, offset, (LongMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -1019,14 +1027,14 @@ final class LongMaxVector extends LongVector { @Override final void intoArray0(long[] a, int offset, VectorMask m) { - super.intoArray0Template(LongMaxMask.class, a, offset, (LongMaxMask) m); + super.intoArray0Template(LongMaskMax.class, a, offset, (LongMaskMax) m); } @ForceInline @Override final void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - super.intoArray0Template(LongMaxMask.class, a, offset, indexMap, mapOffset, (LongMaxMask) m); + super.intoArray0Template(LongMaskMax.class, a, offset, indexMap, mapOffset, (LongMaskMax) m); } @@ -1034,7 +1042,7 @@ final class LongMaxVector extends LongVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(LongMaxMask.class, ms, offset, (LongMaxMask) m); + super.intoMemorySegment0Template(LongMaskMax.class, ms, offset, (LongMaskMax) m); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index 03b7bb030b9..21bc80a12bc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code short} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class ShortVector extends AbstractVector { +public abstract sealed class ShortVector extends AbstractVector + permits ShortVector64, ShortVector128, ShortVector256, ShortVector512, ShortVectorMax { ShortVector(short[] vec) { super(vec); @@ -84,8 +85,8 @@ public abstract class ShortVector extends AbstractVector { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -4455,13 +4456,13 @@ public abstract class ShortVector extends AbstractVector { @Override @ForceInline public final ShortVector zero() { - if ((Class) vectorType() == ShortMaxVector.class) - return ShortMaxVector.ZERO; + if ((Class) vectorType() == ShortVectorMax.class) + return ShortVectorMax.ZERO; switch (vectorBitSize()) { - case 64: return Short64Vector.ZERO; - case 128: return Short128Vector.ZERO; - case 256: return Short256Vector.ZERO; - case 512: return Short512Vector.ZERO; + case 64: return ShortVector64.ZERO; + case 128: return ShortVector128.ZERO; + case 256: return ShortVector256.ZERO; + case 512: return ShortVector512.ZERO; } throw new AssertionError(); } @@ -4469,13 +4470,13 @@ public abstract class ShortVector extends AbstractVector { @Override @ForceInline public final ShortVector iota() { - if ((Class) vectorType() == ShortMaxVector.class) - return ShortMaxVector.IOTA; + if ((Class) vectorType() == ShortVectorMax.class) + return ShortVectorMax.IOTA; switch (vectorBitSize()) { - case 64: return Short64Vector.IOTA; - case 128: return Short128Vector.IOTA; - case 256: return Short256Vector.IOTA; - case 512: return Short512Vector.IOTA; + case 64: return ShortVector64.IOTA; + case 128: return ShortVector128.IOTA; + case 256: return ShortVector256.IOTA; + case 512: return ShortVector512.IOTA; } throw new AssertionError(); } @@ -4484,13 +4485,13 @@ public abstract class ShortVector extends AbstractVector { @Override @ForceInline public final VectorMask maskAll(boolean bit) { - if ((Class) vectorType() == ShortMaxVector.class) - return ShortMaxVector.ShortMaxMask.maskAll(bit); + if ((Class) vectorType() == ShortVectorMax.class) + return ShortVectorMax.ShortMaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return Short64Vector.Short64Mask.maskAll(bit); - case 128: return Short128Vector.Short128Mask.maskAll(bit); - case 256: return Short256Vector.Short256Mask.maskAll(bit); - case 512: return Short512Vector.Short512Mask.maskAll(bit); + case 64: return ShortVector64.ShortMask64.maskAll(bit); + case 128: return ShortVector128.ShortMask128.maskAll(bit); + case 256: return ShortVector256.ShortMask256.maskAll(bit); + case 512: return ShortVector512.ShortMask512.maskAll(bit); } throw new AssertionError(); } @@ -4518,42 +4519,42 @@ public abstract class ShortVector extends AbstractVector { /** Species representing {@link ShortVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies SPECIES_64 = new ShortSpecies(VectorShape.S_64_BIT, - Short64Vector.class, - Short64Vector.Short64Mask.class, - Short64Vector.Short64Shuffle.class, - Short64Vector::new); + ShortVector64.class, + ShortVector64.ShortMask64.class, + ShortVector64.ShortShuffle64.class, + ShortVector64::new); /** Species representing {@link ShortVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies SPECIES_128 = new ShortSpecies(VectorShape.S_128_BIT, - Short128Vector.class, - Short128Vector.Short128Mask.class, - Short128Vector.Short128Shuffle.class, - Short128Vector::new); + ShortVector128.class, + ShortVector128.ShortMask128.class, + ShortVector128.ShortShuffle128.class, + ShortVector128::new); /** Species representing {@link ShortVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies SPECIES_256 = new ShortSpecies(VectorShape.S_256_BIT, - Short256Vector.class, - Short256Vector.Short256Mask.class, - Short256Vector.Short256Shuffle.class, - Short256Vector::new); + ShortVector256.class, + ShortVector256.ShortMask256.class, + ShortVector256.ShortShuffle256.class, + ShortVector256::new); /** Species representing {@link ShortVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies SPECIES_512 = new ShortSpecies(VectorShape.S_512_BIT, - Short512Vector.class, - Short512Vector.Short512Mask.class, - Short512Vector.Short512Shuffle.class, - Short512Vector::new); + ShortVector512.class, + ShortVector512.ShortMask512.class, + ShortVector512.ShortShuffle512.class, + ShortVector512::new); /** Species representing {@link ShortVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies SPECIES_MAX = new ShortSpecies(VectorShape.S_Max_BIT, - ShortMaxVector.class, - ShortMaxVector.ShortMaxMask.class, - ShortMaxVector.ShortMaxShuffle.class, - ShortMaxVector::new); + ShortVectorMax.class, + ShortVectorMax.ShortMaskMax.class, + ShortVectorMax.ShortShuffleMax.class, + ShortVectorMax::new); /** * Preferred species for {@link ShortVector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector128.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector128.java index cc35a1ea069..22bbfce0928 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector128.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Short128Vector extends ShortVector { +@ValueBased +final class ShortVector128 extends ShortVector { static final ShortSpecies VSPECIES = (ShortSpecies) ShortVector.SPECIES_128; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Short128Vector.class; + static final Class VCLASS = ShortVector128.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + static final Class ETYPE = short.class; // used by the JVM - Short128Vector(short[] v) { + ShortVector128(short[] v) { super(v); } - // For compatibility as Short128Vector::new, + // For compatibility as ShortVector128::new, // stored into species.vectorFactory. - Short128Vector(Object v) { + ShortVector128(Object v) { this((short[]) v); } - static final Short128Vector ZERO = new Short128Vector(new short[VLENGTH]); - static final Short128Vector IOTA = new Short128Vector(VSPECIES.iotaArray()); + static final ShortVector128 ZERO = new ShortVector128(new short[VLENGTH]); + static final ShortVector128 IOTA = new ShortVector128(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Short128Vector extends ShortVector { @Override public final Class elementType() { return short.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Short.SIZE; } @@ -130,51 +135,51 @@ final class Short128Vector extends ShortVector { @Override @ForceInline - public final Short128Vector broadcast(short e) { - return (Short128Vector) super.broadcastTemplate(e); // specialize + public final ShortVector128 broadcast(short e) { + return (ShortVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Short128Vector broadcast(long e) { - return (Short128Vector) super.broadcastTemplate(e); // specialize + public final ShortVector128 broadcast(long e) { + return (ShortVector128) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Short128Mask maskFromArray(boolean[] bits) { - return new Short128Mask(bits); + ShortMask128 maskFromArray(boolean[] bits) { + return new ShortMask128(bits); } @Override @ForceInline - Short128Shuffle iotaShuffle() { return Short128Shuffle.IOTA; } + ShortShuffle128 iotaShuffle() { return ShortShuffle128.IOTA; } @Override @ForceInline - Short128Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Short128Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + ShortShuffle128 iotaShuffle(int start, int step, boolean wrap) { + return (ShortShuffle128) iotaShuffleTemplate((short) start, (short) step, wrap); } @Override @ForceInline - Short128Shuffle shuffleFromArray(int[] indices, int i) { return new Short128Shuffle(indices, i); } + ShortShuffle128 shuffleFromArray(int[] indices, int i) { return new ShortShuffle128(indices, i); } @Override @ForceInline - Short128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Short128Shuffle(fn); } + ShortShuffle128 shuffleFromOp(IntUnaryOperator fn) { return new ShortShuffle128(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Short128Vector vectorFactory(short[] vec) { - return new Short128Vector(vec); + ShortVector128 vectorFactory(short[] vec) { + return new ShortVector128(vec); } @ForceInline final @Override - Byte128Vector asByteVectorRaw() { - return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector128 asByteVectorRaw() { + return (ByteVector128) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Short128Vector extends ShortVector { @ForceInline final @Override - Short128Vector uOp(FUnOp f) { - return (Short128Vector) super.uOpTemplate(f); // specialize + ShortVector128 uOp(FUnOp f) { + return (ShortVector128) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Short128Vector uOp(VectorMask m, FUnOp f) { - return (Short128Vector) - super.uOpTemplate((Short128Mask)m, f); // specialize + ShortVector128 uOp(VectorMask m, FUnOp f) { + return (ShortVector128) + super.uOpTemplate((ShortMask128)m, f); // specialize } // Binary operator @ForceInline final @Override - Short128Vector bOp(Vector v, FBinOp f) { - return (Short128Vector) super.bOpTemplate((Short128Vector)v, f); // specialize + ShortVector128 bOp(Vector v, FBinOp f) { + return (ShortVector128) super.bOpTemplate((ShortVector128)v, f); // specialize } @ForceInline final @Override - Short128Vector bOp(Vector v, + ShortVector128 bOp(Vector v, VectorMask m, FBinOp f) { - return (Short128Vector) - super.bOpTemplate((Short128Vector)v, (Short128Mask)m, + return (ShortVector128) + super.bOpTemplate((ShortVector128)v, (ShortMask128)m, f); // specialize } @@ -219,19 +224,19 @@ final class Short128Vector extends ShortVector { @ForceInline final @Override - Short128Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Short128Vector) - super.tOpTemplate((Short128Vector)v1, (Short128Vector)v2, + ShortVector128 tOp(Vector v1, Vector v2, FTriOp f) { + return (ShortVector128) + super.tOpTemplate((ShortVector128)v1, (ShortVector128)v2, f); // specialize } @ForceInline final @Override - Short128Vector tOp(Vector v1, Vector v2, + ShortVector128 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Short128Vector) - super.tOpTemplate((Short128Vector)v1, (Short128Vector)v2, - (Short128Mask)m, f); // specialize + return (ShortVector128) + super.tOpTemplate((ShortVector128)v1, (ShortVector128)v2, + (ShortMask128)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Short128Vector extends ShortVector { @Override @ForceInline - public Short128Vector lanewise(Unary op) { - return (Short128Vector) super.lanewiseTemplate(op); // specialize + public ShortVector128 lanewise(Unary op) { + return (ShortVector128) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Short128Vector lanewise(Unary op, VectorMask m) { - return (Short128Vector) super.lanewiseTemplate(op, Short128Mask.class, (Short128Mask) m); // specialize + public ShortVector128 lanewise(Unary op, VectorMask m) { + return (ShortVector128) super.lanewiseTemplate(op, ShortMask128.class, (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector lanewise(Binary op, Vector v) { - return (Short128Vector) super.lanewiseTemplate(op, v); // specialize + public ShortVector128 lanewise(Binary op, Vector v) { + return (ShortVector128) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Short128Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Short128Vector) super.lanewiseTemplate(op, Short128Mask.class, v, (Short128Mask) m); // specialize + public ShortVector128 lanewise(Binary op, Vector v, VectorMask m) { + return (ShortVector128) super.lanewiseTemplate(op, ShortMask128.class, v, (ShortMask128) m); // specialize } /*package-private*/ @Override - @ForceInline Short128Vector + @ForceInline ShortVector128 lanewiseShift(VectorOperators.Binary op, int e) { - return (Short128Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ShortVector128) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Short128Vector + @ForceInline ShortVector128 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Short128Vector) super.lanewiseShiftTemplate(op, Short128Mask.class, e, (Short128Mask) m); // specialize + return (ShortVector128) super.lanewiseShiftTemplate(op, ShortMask128.class, e, (ShortMask128) m); // specialize } /*package-private*/ @Override @ForceInline public final - Short128Vector + ShortVector128 lanewise(Ternary op, Vector v1, Vector v2) { - return (Short128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ShortVector128) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Short128Vector + ShortVector128 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Short128Vector) super.lanewiseTemplate(op, Short128Mask.class, v1, v2, (Short128Mask) m); // specialize + return (ShortVector128) super.lanewiseTemplate(op, ShortMask128.class, v1, v2, (ShortMask128) m); // specialize } @Override @ForceInline public final - Short128Vector addIndex(int scale) { - return (Short128Vector) super.addIndexTemplate(scale); // specialize + ShortVector128 addIndex(int scale) { + return (ShortVector128) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Short128Vector extends ShortVector { @ForceInline public final short reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Short128Mask.class, (Short128Mask) m); // specialized + return super.reduceLanesTemplate(op, ShortMask128.class, (ShortMask128) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Short128Vector extends ShortVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Short128Mask.class, (Short128Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ShortMask128.class, (ShortMask128) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Short128Vector extends ShortVector { @Override @ForceInline - public final Short128Shuffle toShuffle() { - return (Short128Shuffle) toShuffle(vspecies(), false); + public final ShortShuffle128 toShuffle() { + return (ShortShuffle128) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Short128Mask test(Test op) { - return super.testTemplate(Short128Mask.class, op); // specialize + public final ShortMask128 test(Test op) { + return super.testTemplate(ShortMask128.class, op); // specialize } @Override @ForceInline - public final Short128Mask test(Test op, VectorMask m) { - return super.testTemplate(Short128Mask.class, op, (Short128Mask) m); // specialize + public final ShortMask128 test(Test op, VectorMask m) { + return super.testTemplate(ShortMask128.class, op, (ShortMask128) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Short128Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Short128Mask.class, op, v); // specialize + public final ShortMask128 compare(Comparison op, Vector v) { + return super.compareTemplate(ShortMask128.class, op, v); // specialize } @Override @ForceInline - public final Short128Mask compare(Comparison op, short s) { - return super.compareTemplate(Short128Mask.class, op, s); // specialize + public final ShortMask128 compare(Comparison op, short s) { + return super.compareTemplate(ShortMask128.class, op, s); // specialize } @Override @ForceInline - public final Short128Mask compare(Comparison op, long s) { - return super.compareTemplate(Short128Mask.class, op, s); // specialize + public final ShortMask128 compare(Comparison op, long s) { + return super.compareTemplate(ShortMask128.class, op, s); // specialize } @Override @ForceInline - public final Short128Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Short128Mask.class, op, v, (Short128Mask) m); + public final ShortMask128 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ShortMask128.class, op, v, (ShortMask128) m); } @Override @ForceInline - public Short128Vector blend(Vector v, VectorMask m) { - return (Short128Vector) - super.blendTemplate(Short128Mask.class, - (Short128Vector) v, - (Short128Mask) m); // specialize + public ShortVector128 blend(Vector v, VectorMask m) { + return (ShortVector128) + super.blendTemplate(ShortMask128.class, + (ShortVector128) v, + (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector slice(int origin, Vector v) { - return (Short128Vector) super.sliceTemplate(origin, v); // specialize + public ShortVector128 slice(int origin, Vector v) { + return (ShortVector128) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Short128Vector slice(int origin) { - return (Short128Vector) super.sliceTemplate(origin); // specialize + public ShortVector128 slice(int origin) { + return (ShortVector128) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Short128Vector unslice(int origin, Vector w, int part) { - return (Short128Vector) super.unsliceTemplate(origin, w, part); // specialize + public ShortVector128 unslice(int origin, Vector w, int part) { + return (ShortVector128) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Short128Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Short128Vector) - super.unsliceTemplate(Short128Mask.class, + public ShortVector128 unslice(int origin, Vector w, int part, VectorMask m) { + return (ShortVector128) + super.unsliceTemplate(ShortMask128.class, origin, w, part, - (Short128Mask) m); // specialize + (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector unslice(int origin) { - return (Short128Vector) super.unsliceTemplate(origin); // specialize + public ShortVector128 unslice(int origin) { + return (ShortVector128) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Short128Vector rearrange(VectorShuffle s) { - return (Short128Vector) - super.rearrangeTemplate(Short128Shuffle.class, - (Short128Shuffle) s); // specialize + public ShortVector128 rearrange(VectorShuffle s) { + return (ShortVector128) + super.rearrangeTemplate(ShortShuffle128.class, + (ShortShuffle128) s); // specialize } @Override @ForceInline - public Short128Vector rearrange(VectorShuffle shuffle, + public ShortVector128 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Short128Vector) - super.rearrangeTemplate(Short128Shuffle.class, - Short128Mask.class, - (Short128Shuffle) shuffle, - (Short128Mask) m); // specialize + return (ShortVector128) + super.rearrangeTemplate(ShortShuffle128.class, + ShortMask128.class, + (ShortShuffle128) shuffle, + (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector rearrange(VectorShuffle s, + public ShortVector128 rearrange(VectorShuffle s, Vector v) { - return (Short128Vector) - super.rearrangeTemplate(Short128Shuffle.class, - (Short128Shuffle) s, - (Short128Vector) v); // specialize + return (ShortVector128) + super.rearrangeTemplate(ShortShuffle128.class, + (ShortShuffle128) s, + (ShortVector128) v); // specialize } @Override @ForceInline - public Short128Vector compress(VectorMask m) { - return (Short128Vector) - super.compressTemplate(Short128Mask.class, - (Short128Mask) m); // specialize + public ShortVector128 compress(VectorMask m) { + return (ShortVector128) + super.compressTemplate(ShortMask128.class, + (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector expand(VectorMask m) { - return (Short128Vector) - super.expandTemplate(Short128Mask.class, - (Short128Mask) m); // specialize + public ShortVector128 expand(VectorMask m) { + return (ShortVector128) + super.expandTemplate(ShortMask128.class, + (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector selectFrom(Vector v) { - return (Short128Vector) - super.selectFromTemplate((Short128Vector) v); // specialize + public ShortVector128 selectFrom(Vector v) { + return (ShortVector128) + super.selectFromTemplate((ShortVector128) v); // specialize } @Override @ForceInline - public Short128Vector selectFrom(Vector v, + public ShortVector128 selectFrom(Vector v, VectorMask m) { - return (Short128Vector) - super.selectFromTemplate((Short128Vector) v, - Short128Mask.class, (Short128Mask) m); // specialize + return (ShortVector128) + super.selectFromTemplate((ShortVector128) v, + ShortMask128.class, (ShortMask128) m); // specialize } @Override @ForceInline - public Short128Vector selectFrom(Vector v1, + public ShortVector128 selectFrom(Vector v1, Vector v2) { - return (Short128Vector) - super.selectFromTemplate((Short128Vector) v1, (Short128Vector) v2); // specialize + return (ShortVector128) + super.selectFromTemplate((ShortVector128) v1, (ShortVector128) v2); // specialize } @ForceInline @@ -550,7 +555,7 @@ final class Short128Vector extends ShortVector { @ForceInline @Override - public Short128Vector withLane(int i, short e) { + public ShortVector128 withLane(int i, short e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -565,7 +570,7 @@ final class Short128Vector extends ShortVector { } @ForceInline - public Short128Vector withLaneHelper(int i, short e) { + public ShortVector128 withLaneHelper(int i, short e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -577,20 +582,21 @@ final class Short128Vector extends ShortVector { } // Mask - - static final class Short128Mask extends AbstractMask { + @ValueBased + static final class ShortMask128 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short128Mask(boolean[] bits) { + static final Class CTYPE = short.class; // used by the JVM + + ShortMask128(boolean[] bits) { this(bits, 0); } - Short128Mask(boolean[] bits, int offset) { + ShortMask128(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Short128Mask(boolean val) { + ShortMask128(boolean val) { super(prepare(val)); } @@ -623,31 +629,31 @@ final class Short128Vector extends ShortVector { } @Override - Short128Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask128 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Short128Mask(res); + return new ShortMask128(res); } @Override - Short128Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask128 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Short128Mask)m).getBits(); + boolean[] mbits = ((ShortMask128)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Short128Mask(res); + return new ShortMask128(res); } @ForceInline @Override public final - Short128Vector toVector() { - return (Short128Vector) super.toVectorTemplate(); // specialize + ShortVector128 toVector() { + return (ShortVector128) super.toVectorTemplate(); // specialize } /** @@ -680,25 +686,25 @@ final class Short128Vector extends ShortVector { @Override @ForceInline /*package-private*/ - Short128Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Short128Mask) VectorSupport.indexPartiallyInUpperRange( - Short128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Short128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ShortMask128 indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMask128) VectorSupport.indexPartiallyInUpperRange( + ShortMask128.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ShortMask128) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Short128Mask not() { + public ShortMask128 not() { return xor(maskAll(true)); } @Override @ForceInline - public Short128Mask compress() { - return (Short128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short128Vector.class, Short128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ShortMask128 compress() { + return (ShortMask128)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ShortVector128.class, ShortMask128.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -707,30 +713,30 @@ final class Short128Vector extends ShortVector { @Override @ForceInline - public Short128Mask and(VectorMask mask) { + public ShortMask128 and(VectorMask mask) { Objects.requireNonNull(mask); - Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask128 m = (ShortMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Short128Mask or(VectorMask mask) { + public ShortMask128 or(VectorMask mask) { Objects.requireNonNull(mask); - Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask128 m = (ShortMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Short128Mask xor(VectorMask mask) { + public ShortMask128 xor(VectorMask mask) { Objects.requireNonNull(mask); - Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short128Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask128 m = (ShortMask128)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMask128.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -740,21 +746,21 @@ final class Short128Vector extends ShortVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -764,7 +770,7 @@ final class Short128Vector extends ShortVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -774,7 +780,7 @@ final class Short128Vector extends ShortVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short128Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ShortMask128.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -783,48 +789,49 @@ final class Short128Vector extends ShortVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short128Mask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ShortMask128)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ShortMask128)m).getBits())); } @ForceInline /*package-private*/ - static Short128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short128Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ShortMask128 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ShortMask128.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Short128Mask TRUE_MASK = new Short128Mask(true); - private static final Short128Mask FALSE_MASK = new Short128Mask(false); + private static final ShortMask128 TRUE_MASK = new ShortMask128(true); + private static final ShortMask128 FALSE_MASK = new ShortMask128(false); } // Shuffle - - static final class Short128Shuffle extends AbstractShuffle { + @ValueBased + static final class ShortShuffle128 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short128Shuffle(short[] indices) { + static final Class CTYPE = short.class; // used by the JVM + + ShortShuffle128(short[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Short128Shuffle(int[] indices, int i) { + ShortShuffle128(int[] indices, int i) { this(prepare(indices, i)); } - Short128Shuffle(IntUnaryOperator fn) { + ShortShuffle128(IntUnaryOperator fn) { this(prepare(fn)); } @@ -844,23 +851,23 @@ final class Short128Vector extends ShortVector { assert(VLENGTH < Short.MAX_VALUE); assert(Short.MIN_VALUE <= -VLENGTH); } - static final Short128Shuffle IOTA = new Short128Shuffle(IDENTITY); + static final ShortShuffle128 IOTA = new ShortShuffle128(IDENTITY); @Override @ForceInline - public Short128Vector toVector() { + public ShortVector128 toVector() { return toBitsVector(); } @Override @ForceInline - Short128Vector toBitsVector() { - return (Short128Vector) super.toBitsVectorTemplate(); + ShortVector128 toBitsVector() { + return (ShortVector128) super.toBitsVectorTemplate(); } @Override - Short128Vector toBitsVector0() { - return ((Short128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ShortVector128 toBitsVector0() { + return ((ShortVector128) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -897,30 +904,30 @@ final class Short128Vector extends ShortVector { @Override @ForceInline - public final Short128Mask laneIsValid() { - return (Short128Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ShortMask128 laneIsValid() { + return (ShortMask128) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Short128Shuffle rearrange(VectorShuffle shuffle) { - Short128Shuffle concreteShuffle = (Short128Shuffle) shuffle; - return (Short128Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ShortShuffle128 rearrange(VectorShuffle shuffle) { + ShortShuffle128 concreteShuffle = (ShortShuffle128) shuffle; + return (ShortShuffle128) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Short128Shuffle wrapIndexes() { - Short128Vector v = toBitsVector(); + public final ShortShuffle128 wrapIndexes() { + ShortVector128 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Short128Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ShortVector128) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Short128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ShortVector128) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Short128Shuffle) v.toShuffle(vspecies(), false); + return (ShortShuffle128) v.toShuffle(VSPECIES, false); } private static short[] prepare(int[] indices, int offset) { @@ -971,14 +978,14 @@ final class Short128Vector extends ShortVector { @Override final ShortVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Short128Mask.class, a, offset, (Short128Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ShortMask128.class, a, offset, (ShortMask128) m, offsetInRange); // specialize } @ForceInline @Override final ShortVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Short128Mask.class, a, offset, indexMap, mapOffset, (Short128Mask) m); + return super.fromArray0Template(ShortMask128.class, a, offset, indexMap, mapOffset, (ShortMask128) m); } @ForceInline @@ -992,7 +999,7 @@ final class Short128Vector extends ShortVector { @Override final ShortVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromCharArray0Template(Short128Mask.class, a, offset, (Short128Mask) m, offsetInRange); // specialize + return super.fromCharArray0Template(ShortMask128.class, a, offset, (ShortMask128) m, offsetInRange); // specialize } @@ -1007,7 +1014,7 @@ final class Short128Vector extends ShortVector { @Override final ShortVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Short128Mask.class, ms, offset, (Short128Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ShortMask128.class, ms, offset, (ShortMask128) m, offsetInRange); // specialize } @ForceInline @@ -1021,7 +1028,7 @@ final class Short128Vector extends ShortVector { @Override final void intoArray0(short[] a, int offset, VectorMask m) { - super.intoArray0Template(Short128Mask.class, a, offset, (Short128Mask) m); + super.intoArray0Template(ShortMask128.class, a, offset, (ShortMask128) m); } @@ -1030,14 +1037,14 @@ final class Short128Vector extends ShortVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Short128Mask.class, ms, offset, (Short128Mask) m); + super.intoMemorySegment0Template(ShortMask128.class, ms, offset, (ShortMask128) m); } @ForceInline @Override final void intoCharArray0(char[] a, int offset, VectorMask m) { - super.intoCharArray0Template(Short128Mask.class, a, offset, (Short128Mask) m); + super.intoCharArray0Template(ShortMask128.class, a, offset, (ShortMask128) m); } // End of specialized low-level memory operations. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector256.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector256.java index a3841eb63dc..6011695bf54 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector256.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Short256Vector extends ShortVector { +@ValueBased +final class ShortVector256 extends ShortVector { static final ShortSpecies VSPECIES = (ShortSpecies) ShortVector.SPECIES_256; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Short256Vector.class; + static final Class VCLASS = ShortVector256.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + static final Class ETYPE = short.class; // used by the JVM - Short256Vector(short[] v) { + ShortVector256(short[] v) { super(v); } - // For compatibility as Short256Vector::new, + // For compatibility as ShortVector256::new, // stored into species.vectorFactory. - Short256Vector(Object v) { + ShortVector256(Object v) { this((short[]) v); } - static final Short256Vector ZERO = new Short256Vector(new short[VLENGTH]); - static final Short256Vector IOTA = new Short256Vector(VSPECIES.iotaArray()); + static final ShortVector256 ZERO = new ShortVector256(new short[VLENGTH]); + static final ShortVector256 IOTA = new ShortVector256(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Short256Vector extends ShortVector { @Override public final Class elementType() { return short.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Short.SIZE; } @@ -130,51 +135,51 @@ final class Short256Vector extends ShortVector { @Override @ForceInline - public final Short256Vector broadcast(short e) { - return (Short256Vector) super.broadcastTemplate(e); // specialize + public final ShortVector256 broadcast(short e) { + return (ShortVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Short256Vector broadcast(long e) { - return (Short256Vector) super.broadcastTemplate(e); // specialize + public final ShortVector256 broadcast(long e) { + return (ShortVector256) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Short256Mask maskFromArray(boolean[] bits) { - return new Short256Mask(bits); + ShortMask256 maskFromArray(boolean[] bits) { + return new ShortMask256(bits); } @Override @ForceInline - Short256Shuffle iotaShuffle() { return Short256Shuffle.IOTA; } + ShortShuffle256 iotaShuffle() { return ShortShuffle256.IOTA; } @Override @ForceInline - Short256Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Short256Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + ShortShuffle256 iotaShuffle(int start, int step, boolean wrap) { + return (ShortShuffle256) iotaShuffleTemplate((short) start, (short) step, wrap); } @Override @ForceInline - Short256Shuffle shuffleFromArray(int[] indices, int i) { return new Short256Shuffle(indices, i); } + ShortShuffle256 shuffleFromArray(int[] indices, int i) { return new ShortShuffle256(indices, i); } @Override @ForceInline - Short256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Short256Shuffle(fn); } + ShortShuffle256 shuffleFromOp(IntUnaryOperator fn) { return new ShortShuffle256(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Short256Vector vectorFactory(short[] vec) { - return new Short256Vector(vec); + ShortVector256 vectorFactory(short[] vec) { + return new ShortVector256(vec); } @ForceInline final @Override - Byte256Vector asByteVectorRaw() { - return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector256 asByteVectorRaw() { + return (ByteVector256) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Short256Vector extends ShortVector { @ForceInline final @Override - Short256Vector uOp(FUnOp f) { - return (Short256Vector) super.uOpTemplate(f); // specialize + ShortVector256 uOp(FUnOp f) { + return (ShortVector256) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Short256Vector uOp(VectorMask m, FUnOp f) { - return (Short256Vector) - super.uOpTemplate((Short256Mask)m, f); // specialize + ShortVector256 uOp(VectorMask m, FUnOp f) { + return (ShortVector256) + super.uOpTemplate((ShortMask256)m, f); // specialize } // Binary operator @ForceInline final @Override - Short256Vector bOp(Vector v, FBinOp f) { - return (Short256Vector) super.bOpTemplate((Short256Vector)v, f); // specialize + ShortVector256 bOp(Vector v, FBinOp f) { + return (ShortVector256) super.bOpTemplate((ShortVector256)v, f); // specialize } @ForceInline final @Override - Short256Vector bOp(Vector v, + ShortVector256 bOp(Vector v, VectorMask m, FBinOp f) { - return (Short256Vector) - super.bOpTemplate((Short256Vector)v, (Short256Mask)m, + return (ShortVector256) + super.bOpTemplate((ShortVector256)v, (ShortMask256)m, f); // specialize } @@ -219,19 +224,19 @@ final class Short256Vector extends ShortVector { @ForceInline final @Override - Short256Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Short256Vector) - super.tOpTemplate((Short256Vector)v1, (Short256Vector)v2, + ShortVector256 tOp(Vector v1, Vector v2, FTriOp f) { + return (ShortVector256) + super.tOpTemplate((ShortVector256)v1, (ShortVector256)v2, f); // specialize } @ForceInline final @Override - Short256Vector tOp(Vector v1, Vector v2, + ShortVector256 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Short256Vector) - super.tOpTemplate((Short256Vector)v1, (Short256Vector)v2, - (Short256Mask)m, f); // specialize + return (ShortVector256) + super.tOpTemplate((ShortVector256)v1, (ShortVector256)v2, + (ShortMask256)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Short256Vector extends ShortVector { @Override @ForceInline - public Short256Vector lanewise(Unary op) { - return (Short256Vector) super.lanewiseTemplate(op); // specialize + public ShortVector256 lanewise(Unary op) { + return (ShortVector256) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Short256Vector lanewise(Unary op, VectorMask m) { - return (Short256Vector) super.lanewiseTemplate(op, Short256Mask.class, (Short256Mask) m); // specialize + public ShortVector256 lanewise(Unary op, VectorMask m) { + return (ShortVector256) super.lanewiseTemplate(op, ShortMask256.class, (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector lanewise(Binary op, Vector v) { - return (Short256Vector) super.lanewiseTemplate(op, v); // specialize + public ShortVector256 lanewise(Binary op, Vector v) { + return (ShortVector256) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Short256Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Short256Vector) super.lanewiseTemplate(op, Short256Mask.class, v, (Short256Mask) m); // specialize + public ShortVector256 lanewise(Binary op, Vector v, VectorMask m) { + return (ShortVector256) super.lanewiseTemplate(op, ShortMask256.class, v, (ShortMask256) m); // specialize } /*package-private*/ @Override - @ForceInline Short256Vector + @ForceInline ShortVector256 lanewiseShift(VectorOperators.Binary op, int e) { - return (Short256Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ShortVector256) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Short256Vector + @ForceInline ShortVector256 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Short256Vector) super.lanewiseShiftTemplate(op, Short256Mask.class, e, (Short256Mask) m); // specialize + return (ShortVector256) super.lanewiseShiftTemplate(op, ShortMask256.class, e, (ShortMask256) m); // specialize } /*package-private*/ @Override @ForceInline public final - Short256Vector + ShortVector256 lanewise(Ternary op, Vector v1, Vector v2) { - return (Short256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ShortVector256) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Short256Vector + ShortVector256 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Short256Vector) super.lanewiseTemplate(op, Short256Mask.class, v1, v2, (Short256Mask) m); // specialize + return (ShortVector256) super.lanewiseTemplate(op, ShortMask256.class, v1, v2, (ShortMask256) m); // specialize } @Override @ForceInline public final - Short256Vector addIndex(int scale) { - return (Short256Vector) super.addIndexTemplate(scale); // specialize + ShortVector256 addIndex(int scale) { + return (ShortVector256) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Short256Vector extends ShortVector { @ForceInline public final short reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Short256Mask.class, (Short256Mask) m); // specialized + return super.reduceLanesTemplate(op, ShortMask256.class, (ShortMask256) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Short256Vector extends ShortVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Short256Mask.class, (Short256Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ShortMask256.class, (ShortMask256) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Short256Vector extends ShortVector { @Override @ForceInline - public final Short256Shuffle toShuffle() { - return (Short256Shuffle) toShuffle(vspecies(), false); + public final ShortShuffle256 toShuffle() { + return (ShortShuffle256) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Short256Mask test(Test op) { - return super.testTemplate(Short256Mask.class, op); // specialize + public final ShortMask256 test(Test op) { + return super.testTemplate(ShortMask256.class, op); // specialize } @Override @ForceInline - public final Short256Mask test(Test op, VectorMask m) { - return super.testTemplate(Short256Mask.class, op, (Short256Mask) m); // specialize + public final ShortMask256 test(Test op, VectorMask m) { + return super.testTemplate(ShortMask256.class, op, (ShortMask256) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Short256Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Short256Mask.class, op, v); // specialize + public final ShortMask256 compare(Comparison op, Vector v) { + return super.compareTemplate(ShortMask256.class, op, v); // specialize } @Override @ForceInline - public final Short256Mask compare(Comparison op, short s) { - return super.compareTemplate(Short256Mask.class, op, s); // specialize + public final ShortMask256 compare(Comparison op, short s) { + return super.compareTemplate(ShortMask256.class, op, s); // specialize } @Override @ForceInline - public final Short256Mask compare(Comparison op, long s) { - return super.compareTemplate(Short256Mask.class, op, s); // specialize + public final ShortMask256 compare(Comparison op, long s) { + return super.compareTemplate(ShortMask256.class, op, s); // specialize } @Override @ForceInline - public final Short256Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Short256Mask.class, op, v, (Short256Mask) m); + public final ShortMask256 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ShortMask256.class, op, v, (ShortMask256) m); } @Override @ForceInline - public Short256Vector blend(Vector v, VectorMask m) { - return (Short256Vector) - super.blendTemplate(Short256Mask.class, - (Short256Vector) v, - (Short256Mask) m); // specialize + public ShortVector256 blend(Vector v, VectorMask m) { + return (ShortVector256) + super.blendTemplate(ShortMask256.class, + (ShortVector256) v, + (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector slice(int origin, Vector v) { - return (Short256Vector) super.sliceTemplate(origin, v); // specialize + public ShortVector256 slice(int origin, Vector v) { + return (ShortVector256) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Short256Vector slice(int origin) { - return (Short256Vector) super.sliceTemplate(origin); // specialize + public ShortVector256 slice(int origin) { + return (ShortVector256) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Short256Vector unslice(int origin, Vector w, int part) { - return (Short256Vector) super.unsliceTemplate(origin, w, part); // specialize + public ShortVector256 unslice(int origin, Vector w, int part) { + return (ShortVector256) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Short256Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Short256Vector) - super.unsliceTemplate(Short256Mask.class, + public ShortVector256 unslice(int origin, Vector w, int part, VectorMask m) { + return (ShortVector256) + super.unsliceTemplate(ShortMask256.class, origin, w, part, - (Short256Mask) m); // specialize + (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector unslice(int origin) { - return (Short256Vector) super.unsliceTemplate(origin); // specialize + public ShortVector256 unslice(int origin) { + return (ShortVector256) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Short256Vector rearrange(VectorShuffle s) { - return (Short256Vector) - super.rearrangeTemplate(Short256Shuffle.class, - (Short256Shuffle) s); // specialize + public ShortVector256 rearrange(VectorShuffle s) { + return (ShortVector256) + super.rearrangeTemplate(ShortShuffle256.class, + (ShortShuffle256) s); // specialize } @Override @ForceInline - public Short256Vector rearrange(VectorShuffle shuffle, + public ShortVector256 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Short256Vector) - super.rearrangeTemplate(Short256Shuffle.class, - Short256Mask.class, - (Short256Shuffle) shuffle, - (Short256Mask) m); // specialize + return (ShortVector256) + super.rearrangeTemplate(ShortShuffle256.class, + ShortMask256.class, + (ShortShuffle256) shuffle, + (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector rearrange(VectorShuffle s, + public ShortVector256 rearrange(VectorShuffle s, Vector v) { - return (Short256Vector) - super.rearrangeTemplate(Short256Shuffle.class, - (Short256Shuffle) s, - (Short256Vector) v); // specialize + return (ShortVector256) + super.rearrangeTemplate(ShortShuffle256.class, + (ShortShuffle256) s, + (ShortVector256) v); // specialize } @Override @ForceInline - public Short256Vector compress(VectorMask m) { - return (Short256Vector) - super.compressTemplate(Short256Mask.class, - (Short256Mask) m); // specialize + public ShortVector256 compress(VectorMask m) { + return (ShortVector256) + super.compressTemplate(ShortMask256.class, + (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector expand(VectorMask m) { - return (Short256Vector) - super.expandTemplate(Short256Mask.class, - (Short256Mask) m); // specialize + public ShortVector256 expand(VectorMask m) { + return (ShortVector256) + super.expandTemplate(ShortMask256.class, + (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector selectFrom(Vector v) { - return (Short256Vector) - super.selectFromTemplate((Short256Vector) v); // specialize + public ShortVector256 selectFrom(Vector v) { + return (ShortVector256) + super.selectFromTemplate((ShortVector256) v); // specialize } @Override @ForceInline - public Short256Vector selectFrom(Vector v, + public ShortVector256 selectFrom(Vector v, VectorMask m) { - return (Short256Vector) - super.selectFromTemplate((Short256Vector) v, - Short256Mask.class, (Short256Mask) m); // specialize + return (ShortVector256) + super.selectFromTemplate((ShortVector256) v, + ShortMask256.class, (ShortMask256) m); // specialize } @Override @ForceInline - public Short256Vector selectFrom(Vector v1, + public ShortVector256 selectFrom(Vector v1, Vector v2) { - return (Short256Vector) - super.selectFromTemplate((Short256Vector) v1, (Short256Vector) v2); // specialize + return (ShortVector256) + super.selectFromTemplate((ShortVector256) v1, (ShortVector256) v2); // specialize } @ForceInline @@ -558,7 +563,7 @@ final class Short256Vector extends ShortVector { @ForceInline @Override - public Short256Vector withLane(int i, short e) { + public ShortVector256 withLane(int i, short e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -581,7 +586,7 @@ final class Short256Vector extends ShortVector { } @ForceInline - public Short256Vector withLaneHelper(int i, short e) { + public ShortVector256 withLaneHelper(int i, short e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -593,20 +598,21 @@ final class Short256Vector extends ShortVector { } // Mask - - static final class Short256Mask extends AbstractMask { + @ValueBased + static final class ShortMask256 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short256Mask(boolean[] bits) { + static final Class CTYPE = short.class; // used by the JVM + + ShortMask256(boolean[] bits) { this(bits, 0); } - Short256Mask(boolean[] bits, int offset) { + ShortMask256(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Short256Mask(boolean val) { + ShortMask256(boolean val) { super(prepare(val)); } @@ -639,31 +645,31 @@ final class Short256Vector extends ShortVector { } @Override - Short256Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask256 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Short256Mask(res); + return new ShortMask256(res); } @Override - Short256Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask256 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Short256Mask)m).getBits(); + boolean[] mbits = ((ShortMask256)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Short256Mask(res); + return new ShortMask256(res); } @ForceInline @Override public final - Short256Vector toVector() { - return (Short256Vector) super.toVectorTemplate(); // specialize + ShortVector256 toVector() { + return (ShortVector256) super.toVectorTemplate(); // specialize } /** @@ -696,25 +702,25 @@ final class Short256Vector extends ShortVector { @Override @ForceInline /*package-private*/ - Short256Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Short256Mask) VectorSupport.indexPartiallyInUpperRange( - Short256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Short256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ShortMask256 indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMask256) VectorSupport.indexPartiallyInUpperRange( + ShortMask256.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ShortMask256) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Short256Mask not() { + public ShortMask256 not() { return xor(maskAll(true)); } @Override @ForceInline - public Short256Mask compress() { - return (Short256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short256Vector.class, Short256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ShortMask256 compress() { + return (ShortMask256)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ShortVector256.class, ShortMask256.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -723,30 +729,30 @@ final class Short256Vector extends ShortVector { @Override @ForceInline - public Short256Mask and(VectorMask mask) { + public ShortMask256 and(VectorMask mask) { Objects.requireNonNull(mask); - Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask256 m = (ShortMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Short256Mask or(VectorMask mask) { + public ShortMask256 or(VectorMask mask) { Objects.requireNonNull(mask); - Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask256 m = (ShortMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Short256Mask xor(VectorMask mask) { + public ShortMask256 xor(VectorMask mask) { Objects.requireNonNull(mask); - Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short256Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask256 m = (ShortMask256)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMask256.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -756,21 +762,21 @@ final class Short256Vector extends ShortVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -780,7 +786,7 @@ final class Short256Vector extends ShortVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -790,7 +796,7 @@ final class Short256Vector extends ShortVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short256Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ShortMask256.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -799,48 +805,49 @@ final class Short256Vector extends ShortVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short256Mask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ShortMask256)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ShortMask256)m).getBits())); } @ForceInline /*package-private*/ - static Short256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short256Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ShortMask256 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ShortMask256.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Short256Mask TRUE_MASK = new Short256Mask(true); - private static final Short256Mask FALSE_MASK = new Short256Mask(false); + private static final ShortMask256 TRUE_MASK = new ShortMask256(true); + private static final ShortMask256 FALSE_MASK = new ShortMask256(false); } // Shuffle - - static final class Short256Shuffle extends AbstractShuffle { + @ValueBased + static final class ShortShuffle256 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short256Shuffle(short[] indices) { + static final Class CTYPE = short.class; // used by the JVM + + ShortShuffle256(short[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Short256Shuffle(int[] indices, int i) { + ShortShuffle256(int[] indices, int i) { this(prepare(indices, i)); } - Short256Shuffle(IntUnaryOperator fn) { + ShortShuffle256(IntUnaryOperator fn) { this(prepare(fn)); } @@ -860,23 +867,23 @@ final class Short256Vector extends ShortVector { assert(VLENGTH < Short.MAX_VALUE); assert(Short.MIN_VALUE <= -VLENGTH); } - static final Short256Shuffle IOTA = new Short256Shuffle(IDENTITY); + static final ShortShuffle256 IOTA = new ShortShuffle256(IDENTITY); @Override @ForceInline - public Short256Vector toVector() { + public ShortVector256 toVector() { return toBitsVector(); } @Override @ForceInline - Short256Vector toBitsVector() { - return (Short256Vector) super.toBitsVectorTemplate(); + ShortVector256 toBitsVector() { + return (ShortVector256) super.toBitsVectorTemplate(); } @Override - Short256Vector toBitsVector0() { - return ((Short256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ShortVector256 toBitsVector0() { + return ((ShortVector256) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -913,30 +920,30 @@ final class Short256Vector extends ShortVector { @Override @ForceInline - public final Short256Mask laneIsValid() { - return (Short256Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ShortMask256 laneIsValid() { + return (ShortMask256) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Short256Shuffle rearrange(VectorShuffle shuffle) { - Short256Shuffle concreteShuffle = (Short256Shuffle) shuffle; - return (Short256Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ShortShuffle256 rearrange(VectorShuffle shuffle) { + ShortShuffle256 concreteShuffle = (ShortShuffle256) shuffle; + return (ShortShuffle256) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Short256Shuffle wrapIndexes() { - Short256Vector v = toBitsVector(); + public final ShortShuffle256 wrapIndexes() { + ShortVector256 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Short256Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ShortVector256) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Short256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ShortVector256) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Short256Shuffle) v.toShuffle(vspecies(), false); + return (ShortShuffle256) v.toShuffle(VSPECIES, false); } private static short[] prepare(int[] indices, int offset) { @@ -987,14 +994,14 @@ final class Short256Vector extends ShortVector { @Override final ShortVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Short256Mask.class, a, offset, (Short256Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ShortMask256.class, a, offset, (ShortMask256) m, offsetInRange); // specialize } @ForceInline @Override final ShortVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Short256Mask.class, a, offset, indexMap, mapOffset, (Short256Mask) m); + return super.fromArray0Template(ShortMask256.class, a, offset, indexMap, mapOffset, (ShortMask256) m); } @ForceInline @@ -1008,7 +1015,7 @@ final class Short256Vector extends ShortVector { @Override final ShortVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromCharArray0Template(Short256Mask.class, a, offset, (Short256Mask) m, offsetInRange); // specialize + return super.fromCharArray0Template(ShortMask256.class, a, offset, (ShortMask256) m, offsetInRange); // specialize } @@ -1023,7 +1030,7 @@ final class Short256Vector extends ShortVector { @Override final ShortVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Short256Mask.class, ms, offset, (Short256Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ShortMask256.class, ms, offset, (ShortMask256) m, offsetInRange); // specialize } @ForceInline @@ -1037,7 +1044,7 @@ final class Short256Vector extends ShortVector { @Override final void intoArray0(short[] a, int offset, VectorMask m) { - super.intoArray0Template(Short256Mask.class, a, offset, (Short256Mask) m); + super.intoArray0Template(ShortMask256.class, a, offset, (ShortMask256) m); } @@ -1046,14 +1053,14 @@ final class Short256Vector extends ShortVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Short256Mask.class, ms, offset, (Short256Mask) m); + super.intoMemorySegment0Template(ShortMask256.class, ms, offset, (ShortMask256) m); } @ForceInline @Override final void intoCharArray0(char[] a, int offset, VectorMask m) { - super.intoCharArray0Template(Short256Mask.class, a, offset, (Short256Mask) m); + super.intoCharArray0Template(ShortMask256.class, a, offset, (ShortMask256) m); } // End of specialized low-level memory operations. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector512.java similarity index 66% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector512.java index 3da20257a8d..e6101d2e6be 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector512.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Short512Vector extends ShortVector { +@ValueBased +final class ShortVector512 extends ShortVector { static final ShortSpecies VSPECIES = (ShortSpecies) ShortVector.SPECIES_512; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Short512Vector.class; + static final Class VCLASS = ShortVector512.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + static final Class ETYPE = short.class; // used by the JVM - Short512Vector(short[] v) { + ShortVector512(short[] v) { super(v); } - // For compatibility as Short512Vector::new, + // For compatibility as ShortVector512::new, // stored into species.vectorFactory. - Short512Vector(Object v) { + ShortVector512(Object v) { this((short[]) v); } - static final Short512Vector ZERO = new Short512Vector(new short[VLENGTH]); - static final Short512Vector IOTA = new Short512Vector(VSPECIES.iotaArray()); + static final ShortVector512 ZERO = new ShortVector512(new short[VLENGTH]); + static final ShortVector512 IOTA = new ShortVector512(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Short512Vector extends ShortVector { @Override public final Class elementType() { return short.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Short.SIZE; } @@ -130,51 +135,51 @@ final class Short512Vector extends ShortVector { @Override @ForceInline - public final Short512Vector broadcast(short e) { - return (Short512Vector) super.broadcastTemplate(e); // specialize + public final ShortVector512 broadcast(short e) { + return (ShortVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Short512Vector broadcast(long e) { - return (Short512Vector) super.broadcastTemplate(e); // specialize + public final ShortVector512 broadcast(long e) { + return (ShortVector512) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Short512Mask maskFromArray(boolean[] bits) { - return new Short512Mask(bits); + ShortMask512 maskFromArray(boolean[] bits) { + return new ShortMask512(bits); } @Override @ForceInline - Short512Shuffle iotaShuffle() { return Short512Shuffle.IOTA; } + ShortShuffle512 iotaShuffle() { return ShortShuffle512.IOTA; } @Override @ForceInline - Short512Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Short512Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + ShortShuffle512 iotaShuffle(int start, int step, boolean wrap) { + return (ShortShuffle512) iotaShuffleTemplate((short) start, (short) step, wrap); } @Override @ForceInline - Short512Shuffle shuffleFromArray(int[] indices, int i) { return new Short512Shuffle(indices, i); } + ShortShuffle512 shuffleFromArray(int[] indices, int i) { return new ShortShuffle512(indices, i); } @Override @ForceInline - Short512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Short512Shuffle(fn); } + ShortShuffle512 shuffleFromOp(IntUnaryOperator fn) { return new ShortShuffle512(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Short512Vector vectorFactory(short[] vec) { - return new Short512Vector(vec); + ShortVector512 vectorFactory(short[] vec) { + return new ShortVector512(vec); } @ForceInline final @Override - Byte512Vector asByteVectorRaw() { - return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector512 asByteVectorRaw() { + return (ByteVector512) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Short512Vector extends ShortVector { @ForceInline final @Override - Short512Vector uOp(FUnOp f) { - return (Short512Vector) super.uOpTemplate(f); // specialize + ShortVector512 uOp(FUnOp f) { + return (ShortVector512) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Short512Vector uOp(VectorMask m, FUnOp f) { - return (Short512Vector) - super.uOpTemplate((Short512Mask)m, f); // specialize + ShortVector512 uOp(VectorMask m, FUnOp f) { + return (ShortVector512) + super.uOpTemplate((ShortMask512)m, f); // specialize } // Binary operator @ForceInline final @Override - Short512Vector bOp(Vector v, FBinOp f) { - return (Short512Vector) super.bOpTemplate((Short512Vector)v, f); // specialize + ShortVector512 bOp(Vector v, FBinOp f) { + return (ShortVector512) super.bOpTemplate((ShortVector512)v, f); // specialize } @ForceInline final @Override - Short512Vector bOp(Vector v, + ShortVector512 bOp(Vector v, VectorMask m, FBinOp f) { - return (Short512Vector) - super.bOpTemplate((Short512Vector)v, (Short512Mask)m, + return (ShortVector512) + super.bOpTemplate((ShortVector512)v, (ShortMask512)m, f); // specialize } @@ -219,19 +224,19 @@ final class Short512Vector extends ShortVector { @ForceInline final @Override - Short512Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Short512Vector) - super.tOpTemplate((Short512Vector)v1, (Short512Vector)v2, + ShortVector512 tOp(Vector v1, Vector v2, FTriOp f) { + return (ShortVector512) + super.tOpTemplate((ShortVector512)v1, (ShortVector512)v2, f); // specialize } @ForceInline final @Override - Short512Vector tOp(Vector v1, Vector v2, + ShortVector512 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Short512Vector) - super.tOpTemplate((Short512Vector)v1, (Short512Vector)v2, - (Short512Mask)m, f); // specialize + return (ShortVector512) + super.tOpTemplate((ShortVector512)v1, (ShortVector512)v2, + (ShortMask512)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Short512Vector extends ShortVector { @Override @ForceInline - public Short512Vector lanewise(Unary op) { - return (Short512Vector) super.lanewiseTemplate(op); // specialize + public ShortVector512 lanewise(Unary op) { + return (ShortVector512) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Short512Vector lanewise(Unary op, VectorMask m) { - return (Short512Vector) super.lanewiseTemplate(op, Short512Mask.class, (Short512Mask) m); // specialize + public ShortVector512 lanewise(Unary op, VectorMask m) { + return (ShortVector512) super.lanewiseTemplate(op, ShortMask512.class, (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector lanewise(Binary op, Vector v) { - return (Short512Vector) super.lanewiseTemplate(op, v); // specialize + public ShortVector512 lanewise(Binary op, Vector v) { + return (ShortVector512) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Short512Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Short512Vector) super.lanewiseTemplate(op, Short512Mask.class, v, (Short512Mask) m); // specialize + public ShortVector512 lanewise(Binary op, Vector v, VectorMask m) { + return (ShortVector512) super.lanewiseTemplate(op, ShortMask512.class, v, (ShortMask512) m); // specialize } /*package-private*/ @Override - @ForceInline Short512Vector + @ForceInline ShortVector512 lanewiseShift(VectorOperators.Binary op, int e) { - return (Short512Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ShortVector512) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Short512Vector + @ForceInline ShortVector512 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Short512Vector) super.lanewiseShiftTemplate(op, Short512Mask.class, e, (Short512Mask) m); // specialize + return (ShortVector512) super.lanewiseShiftTemplate(op, ShortMask512.class, e, (ShortMask512) m); // specialize } /*package-private*/ @Override @ForceInline public final - Short512Vector + ShortVector512 lanewise(Ternary op, Vector v1, Vector v2) { - return (Short512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ShortVector512) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Short512Vector + ShortVector512 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Short512Vector) super.lanewiseTemplate(op, Short512Mask.class, v1, v2, (Short512Mask) m); // specialize + return (ShortVector512) super.lanewiseTemplate(op, ShortMask512.class, v1, v2, (ShortMask512) m); // specialize } @Override @ForceInline public final - Short512Vector addIndex(int scale) { - return (Short512Vector) super.addIndexTemplate(scale); // specialize + ShortVector512 addIndex(int scale) { + return (ShortVector512) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Short512Vector extends ShortVector { @ForceInline public final short reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Short512Mask.class, (Short512Mask) m); // specialized + return super.reduceLanesTemplate(op, ShortMask512.class, (ShortMask512) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Short512Vector extends ShortVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Short512Mask.class, (Short512Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ShortMask512.class, (ShortMask512) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Short512Vector extends ShortVector { @Override @ForceInline - public final Short512Shuffle toShuffle() { - return (Short512Shuffle) toShuffle(vspecies(), false); + public final ShortShuffle512 toShuffle() { + return (ShortShuffle512) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Short512Mask test(Test op) { - return super.testTemplate(Short512Mask.class, op); // specialize + public final ShortMask512 test(Test op) { + return super.testTemplate(ShortMask512.class, op); // specialize } @Override @ForceInline - public final Short512Mask test(Test op, VectorMask m) { - return super.testTemplate(Short512Mask.class, op, (Short512Mask) m); // specialize + public final ShortMask512 test(Test op, VectorMask m) { + return super.testTemplate(ShortMask512.class, op, (ShortMask512) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Short512Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Short512Mask.class, op, v); // specialize + public final ShortMask512 compare(Comparison op, Vector v) { + return super.compareTemplate(ShortMask512.class, op, v); // specialize } @Override @ForceInline - public final Short512Mask compare(Comparison op, short s) { - return super.compareTemplate(Short512Mask.class, op, s); // specialize + public final ShortMask512 compare(Comparison op, short s) { + return super.compareTemplate(ShortMask512.class, op, s); // specialize } @Override @ForceInline - public final Short512Mask compare(Comparison op, long s) { - return super.compareTemplate(Short512Mask.class, op, s); // specialize + public final ShortMask512 compare(Comparison op, long s) { + return super.compareTemplate(ShortMask512.class, op, s); // specialize } @Override @ForceInline - public final Short512Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Short512Mask.class, op, v, (Short512Mask) m); + public final ShortMask512 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ShortMask512.class, op, v, (ShortMask512) m); } @Override @ForceInline - public Short512Vector blend(Vector v, VectorMask m) { - return (Short512Vector) - super.blendTemplate(Short512Mask.class, - (Short512Vector) v, - (Short512Mask) m); // specialize + public ShortVector512 blend(Vector v, VectorMask m) { + return (ShortVector512) + super.blendTemplate(ShortMask512.class, + (ShortVector512) v, + (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector slice(int origin, Vector v) { - return (Short512Vector) super.sliceTemplate(origin, v); // specialize + public ShortVector512 slice(int origin, Vector v) { + return (ShortVector512) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Short512Vector slice(int origin) { - return (Short512Vector) super.sliceTemplate(origin); // specialize + public ShortVector512 slice(int origin) { + return (ShortVector512) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Short512Vector unslice(int origin, Vector w, int part) { - return (Short512Vector) super.unsliceTemplate(origin, w, part); // specialize + public ShortVector512 unslice(int origin, Vector w, int part) { + return (ShortVector512) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Short512Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Short512Vector) - super.unsliceTemplate(Short512Mask.class, + public ShortVector512 unslice(int origin, Vector w, int part, VectorMask m) { + return (ShortVector512) + super.unsliceTemplate(ShortMask512.class, origin, w, part, - (Short512Mask) m); // specialize + (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector unslice(int origin) { - return (Short512Vector) super.unsliceTemplate(origin); // specialize + public ShortVector512 unslice(int origin) { + return (ShortVector512) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Short512Vector rearrange(VectorShuffle s) { - return (Short512Vector) - super.rearrangeTemplate(Short512Shuffle.class, - (Short512Shuffle) s); // specialize + public ShortVector512 rearrange(VectorShuffle s) { + return (ShortVector512) + super.rearrangeTemplate(ShortShuffle512.class, + (ShortShuffle512) s); // specialize } @Override @ForceInline - public Short512Vector rearrange(VectorShuffle shuffle, + public ShortVector512 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Short512Vector) - super.rearrangeTemplate(Short512Shuffle.class, - Short512Mask.class, - (Short512Shuffle) shuffle, - (Short512Mask) m); // specialize + return (ShortVector512) + super.rearrangeTemplate(ShortShuffle512.class, + ShortMask512.class, + (ShortShuffle512) shuffle, + (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector rearrange(VectorShuffle s, + public ShortVector512 rearrange(VectorShuffle s, Vector v) { - return (Short512Vector) - super.rearrangeTemplate(Short512Shuffle.class, - (Short512Shuffle) s, - (Short512Vector) v); // specialize + return (ShortVector512) + super.rearrangeTemplate(ShortShuffle512.class, + (ShortShuffle512) s, + (ShortVector512) v); // specialize } @Override @ForceInline - public Short512Vector compress(VectorMask m) { - return (Short512Vector) - super.compressTemplate(Short512Mask.class, - (Short512Mask) m); // specialize + public ShortVector512 compress(VectorMask m) { + return (ShortVector512) + super.compressTemplate(ShortMask512.class, + (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector expand(VectorMask m) { - return (Short512Vector) - super.expandTemplate(Short512Mask.class, - (Short512Mask) m); // specialize + public ShortVector512 expand(VectorMask m) { + return (ShortVector512) + super.expandTemplate(ShortMask512.class, + (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector selectFrom(Vector v) { - return (Short512Vector) - super.selectFromTemplate((Short512Vector) v); // specialize + public ShortVector512 selectFrom(Vector v) { + return (ShortVector512) + super.selectFromTemplate((ShortVector512) v); // specialize } @Override @ForceInline - public Short512Vector selectFrom(Vector v, + public ShortVector512 selectFrom(Vector v, VectorMask m) { - return (Short512Vector) - super.selectFromTemplate((Short512Vector) v, - Short512Mask.class, (Short512Mask) m); // specialize + return (ShortVector512) + super.selectFromTemplate((ShortVector512) v, + ShortMask512.class, (ShortMask512) m); // specialize } @Override @ForceInline - public Short512Vector selectFrom(Vector v1, + public ShortVector512 selectFrom(Vector v1, Vector v2) { - return (Short512Vector) - super.selectFromTemplate((Short512Vector) v1, (Short512Vector) v2); // specialize + return (ShortVector512) + super.selectFromTemplate((ShortVector512) v1, (ShortVector512) v2); // specialize } @ForceInline @@ -574,7 +579,7 @@ final class Short512Vector extends ShortVector { @ForceInline @Override - public Short512Vector withLane(int i, short e) { + public ShortVector512 withLane(int i, short e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -613,7 +618,7 @@ final class Short512Vector extends ShortVector { } @ForceInline - public Short512Vector withLaneHelper(int i, short e) { + public ShortVector512 withLaneHelper(int i, short e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -625,20 +630,21 @@ final class Short512Vector extends ShortVector { } // Mask - - static final class Short512Mask extends AbstractMask { + @ValueBased + static final class ShortMask512 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short512Mask(boolean[] bits) { + static final Class CTYPE = short.class; // used by the JVM + + ShortMask512(boolean[] bits) { this(bits, 0); } - Short512Mask(boolean[] bits, int offset) { + ShortMask512(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Short512Mask(boolean val) { + ShortMask512(boolean val) { super(prepare(val)); } @@ -671,31 +677,31 @@ final class Short512Vector extends ShortVector { } @Override - Short512Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask512 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Short512Mask(res); + return new ShortMask512(res); } @Override - Short512Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask512 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Short512Mask)m).getBits(); + boolean[] mbits = ((ShortMask512)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Short512Mask(res); + return new ShortMask512(res); } @ForceInline @Override public final - Short512Vector toVector() { - return (Short512Vector) super.toVectorTemplate(); // specialize + ShortVector512 toVector() { + return (ShortVector512) super.toVectorTemplate(); // specialize } /** @@ -728,25 +734,25 @@ final class Short512Vector extends ShortVector { @Override @ForceInline /*package-private*/ - Short512Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Short512Mask) VectorSupport.indexPartiallyInUpperRange( - Short512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Short512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ShortMask512 indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMask512) VectorSupport.indexPartiallyInUpperRange( + ShortMask512.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ShortMask512) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Short512Mask not() { + public ShortMask512 not() { return xor(maskAll(true)); } @Override @ForceInline - public Short512Mask compress() { - return (Short512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short512Vector.class, Short512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ShortMask512 compress() { + return (ShortMask512)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ShortVector512.class, ShortMask512.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -755,30 +761,30 @@ final class Short512Vector extends ShortVector { @Override @ForceInline - public Short512Mask and(VectorMask mask) { + public ShortMask512 and(VectorMask mask) { Objects.requireNonNull(mask); - Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask512 m = (ShortMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Short512Mask or(VectorMask mask) { + public ShortMask512 or(VectorMask mask) { Objects.requireNonNull(mask); - Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask512 m = (ShortMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Short512Mask xor(VectorMask mask) { + public ShortMask512 xor(VectorMask mask) { Objects.requireNonNull(mask); - Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short512Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask512 m = (ShortMask512)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMask512.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -788,21 +794,21 @@ final class Short512Vector extends ShortVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -812,7 +818,7 @@ final class Short512Vector extends ShortVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -822,7 +828,7 @@ final class Short512Vector extends ShortVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short512Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ShortMask512.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -831,48 +837,49 @@ final class Short512Vector extends ShortVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short512Mask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ShortMask512)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ShortMask512)m).getBits())); } @ForceInline /*package-private*/ - static Short512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short512Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ShortMask512 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ShortMask512.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Short512Mask TRUE_MASK = new Short512Mask(true); - private static final Short512Mask FALSE_MASK = new Short512Mask(false); + private static final ShortMask512 TRUE_MASK = new ShortMask512(true); + private static final ShortMask512 FALSE_MASK = new ShortMask512(false); } // Shuffle - - static final class Short512Shuffle extends AbstractShuffle { + @ValueBased + static final class ShortShuffle512 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short512Shuffle(short[] indices) { + static final Class CTYPE = short.class; // used by the JVM + + ShortShuffle512(short[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Short512Shuffle(int[] indices, int i) { + ShortShuffle512(int[] indices, int i) { this(prepare(indices, i)); } - Short512Shuffle(IntUnaryOperator fn) { + ShortShuffle512(IntUnaryOperator fn) { this(prepare(fn)); } @@ -892,23 +899,23 @@ final class Short512Vector extends ShortVector { assert(VLENGTH < Short.MAX_VALUE); assert(Short.MIN_VALUE <= -VLENGTH); } - static final Short512Shuffle IOTA = new Short512Shuffle(IDENTITY); + static final ShortShuffle512 IOTA = new ShortShuffle512(IDENTITY); @Override @ForceInline - public Short512Vector toVector() { + public ShortVector512 toVector() { return toBitsVector(); } @Override @ForceInline - Short512Vector toBitsVector() { - return (Short512Vector) super.toBitsVectorTemplate(); + ShortVector512 toBitsVector() { + return (ShortVector512) super.toBitsVectorTemplate(); } @Override - Short512Vector toBitsVector0() { - return ((Short512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ShortVector512 toBitsVector0() { + return ((ShortVector512) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -945,30 +952,30 @@ final class Short512Vector extends ShortVector { @Override @ForceInline - public final Short512Mask laneIsValid() { - return (Short512Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ShortMask512 laneIsValid() { + return (ShortMask512) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Short512Shuffle rearrange(VectorShuffle shuffle) { - Short512Shuffle concreteShuffle = (Short512Shuffle) shuffle; - return (Short512Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ShortShuffle512 rearrange(VectorShuffle shuffle) { + ShortShuffle512 concreteShuffle = (ShortShuffle512) shuffle; + return (ShortShuffle512) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Short512Shuffle wrapIndexes() { - Short512Vector v = toBitsVector(); + public final ShortShuffle512 wrapIndexes() { + ShortVector512 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Short512Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ShortVector512) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Short512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ShortVector512) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Short512Shuffle) v.toShuffle(vspecies(), false); + return (ShortShuffle512) v.toShuffle(VSPECIES, false); } private static short[] prepare(int[] indices, int offset) { @@ -1019,14 +1026,14 @@ final class Short512Vector extends ShortVector { @Override final ShortVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Short512Mask.class, a, offset, (Short512Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ShortMask512.class, a, offset, (ShortMask512) m, offsetInRange); // specialize } @ForceInline @Override final ShortVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Short512Mask.class, a, offset, indexMap, mapOffset, (Short512Mask) m); + return super.fromArray0Template(ShortMask512.class, a, offset, indexMap, mapOffset, (ShortMask512) m); } @ForceInline @@ -1040,7 +1047,7 @@ final class Short512Vector extends ShortVector { @Override final ShortVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromCharArray0Template(Short512Mask.class, a, offset, (Short512Mask) m, offsetInRange); // specialize + return super.fromCharArray0Template(ShortMask512.class, a, offset, (ShortMask512) m, offsetInRange); // specialize } @@ -1055,7 +1062,7 @@ final class Short512Vector extends ShortVector { @Override final ShortVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Short512Mask.class, ms, offset, (Short512Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ShortMask512.class, ms, offset, (ShortMask512) m, offsetInRange); // specialize } @ForceInline @@ -1069,7 +1076,7 @@ final class Short512Vector extends ShortVector { @Override final void intoArray0(short[] a, int offset, VectorMask m) { - super.intoArray0Template(Short512Mask.class, a, offset, (Short512Mask) m); + super.intoArray0Template(ShortMask512.class, a, offset, (ShortMask512) m); } @@ -1078,14 +1085,14 @@ final class Short512Vector extends ShortVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Short512Mask.class, ms, offset, (Short512Mask) m); + super.intoMemorySegment0Template(ShortMask512.class, ms, offset, (ShortMask512) m); } @ForceInline @Override final void intoCharArray0(char[] a, int offset, VectorMask m) { - super.intoCharArray0Template(Short512Mask.class, a, offset, (Short512Mask) m); + super.intoCharArray0Template(ShortMask512.class, a, offset, (ShortMask512) m); } // End of specialized low-level memory operations. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector64.java similarity index 64% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector64.java index 8b3246996f3..31af959b4a8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector64.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class Short64Vector extends ShortVector { +@ValueBased +final class ShortVector64 extends ShortVector { static final ShortSpecies VSPECIES = (ShortSpecies) ShortVector.SPECIES_64; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = Short64Vector.class; + static final Class VCLASS = ShortVector64.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + static final Class ETYPE = short.class; // used by the JVM - Short64Vector(short[] v) { + ShortVector64(short[] v) { super(v); } - // For compatibility as Short64Vector::new, + // For compatibility as ShortVector64::new, // stored into species.vectorFactory. - Short64Vector(Object v) { + ShortVector64(Object v) { this((short[]) v); } - static final Short64Vector ZERO = new Short64Vector(new short[VLENGTH]); - static final Short64Vector IOTA = new Short64Vector(VSPECIES.iotaArray()); + static final ShortVector64 ZERO = new ShortVector64(new short[VLENGTH]); + static final ShortVector64 IOTA = new ShortVector64(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class Short64Vector extends ShortVector { @Override public final Class elementType() { return short.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Short.SIZE; } @@ -130,51 +135,51 @@ final class Short64Vector extends ShortVector { @Override @ForceInline - public final Short64Vector broadcast(short e) { - return (Short64Vector) super.broadcastTemplate(e); // specialize + public final ShortVector64 broadcast(short e) { + return (ShortVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final Short64Vector broadcast(long e) { - return (Short64Vector) super.broadcastTemplate(e); // specialize + public final ShortVector64 broadcast(long e) { + return (ShortVector64) super.broadcastTemplate(e); // specialize } @Override @ForceInline - Short64Mask maskFromArray(boolean[] bits) { - return new Short64Mask(bits); + ShortMask64 maskFromArray(boolean[] bits) { + return new ShortMask64(bits); } @Override @ForceInline - Short64Shuffle iotaShuffle() { return Short64Shuffle.IOTA; } + ShortShuffle64 iotaShuffle() { return ShortShuffle64.IOTA; } @Override @ForceInline - Short64Shuffle iotaShuffle(int start, int step, boolean wrap) { - return (Short64Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + ShortShuffle64 iotaShuffle(int start, int step, boolean wrap) { + return (ShortShuffle64) iotaShuffleTemplate((short) start, (short) step, wrap); } @Override @ForceInline - Short64Shuffle shuffleFromArray(int[] indices, int i) { return new Short64Shuffle(indices, i); } + ShortShuffle64 shuffleFromArray(int[] indices, int i) { return new ShortShuffle64(indices, i); } @Override @ForceInline - Short64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Short64Shuffle(fn); } + ShortShuffle64 shuffleFromOp(IntUnaryOperator fn) { return new ShortShuffle64(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - Short64Vector vectorFactory(short[] vec) { - return new Short64Vector(vec); + ShortVector64 vectorFactory(short[] vec) { + return new ShortVector64(vec); } @ForceInline final @Override - Byte64Vector asByteVectorRaw() { - return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector64 asByteVectorRaw() { + return (ByteVector64) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class Short64Vector extends ShortVector { @ForceInline final @Override - Short64Vector uOp(FUnOp f) { - return (Short64Vector) super.uOpTemplate(f); // specialize + ShortVector64 uOp(FUnOp f) { + return (ShortVector64) super.uOpTemplate(f); // specialize } @ForceInline final @Override - Short64Vector uOp(VectorMask m, FUnOp f) { - return (Short64Vector) - super.uOpTemplate((Short64Mask)m, f); // specialize + ShortVector64 uOp(VectorMask m, FUnOp f) { + return (ShortVector64) + super.uOpTemplate((ShortMask64)m, f); // specialize } // Binary operator @ForceInline final @Override - Short64Vector bOp(Vector v, FBinOp f) { - return (Short64Vector) super.bOpTemplate((Short64Vector)v, f); // specialize + ShortVector64 bOp(Vector v, FBinOp f) { + return (ShortVector64) super.bOpTemplate((ShortVector64)v, f); // specialize } @ForceInline final @Override - Short64Vector bOp(Vector v, + ShortVector64 bOp(Vector v, VectorMask m, FBinOp f) { - return (Short64Vector) - super.bOpTemplate((Short64Vector)v, (Short64Mask)m, + return (ShortVector64) + super.bOpTemplate((ShortVector64)v, (ShortMask64)m, f); // specialize } @@ -219,19 +224,19 @@ final class Short64Vector extends ShortVector { @ForceInline final @Override - Short64Vector tOp(Vector v1, Vector v2, FTriOp f) { - return (Short64Vector) - super.tOpTemplate((Short64Vector)v1, (Short64Vector)v2, + ShortVector64 tOp(Vector v1, Vector v2, FTriOp f) { + return (ShortVector64) + super.tOpTemplate((ShortVector64)v1, (ShortVector64)v2, f); // specialize } @ForceInline final @Override - Short64Vector tOp(Vector v1, Vector v2, + ShortVector64 tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (Short64Vector) - super.tOpTemplate((Short64Vector)v1, (Short64Vector)v2, - (Short64Mask)m, f); // specialize + return (ShortVector64) + super.tOpTemplate((ShortVector64)v1, (ShortVector64)v2, + (ShortMask64)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class Short64Vector extends ShortVector { @Override @ForceInline - public Short64Vector lanewise(Unary op) { - return (Short64Vector) super.lanewiseTemplate(op); // specialize + public ShortVector64 lanewise(Unary op) { + return (ShortVector64) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public Short64Vector lanewise(Unary op, VectorMask m) { - return (Short64Vector) super.lanewiseTemplate(op, Short64Mask.class, (Short64Mask) m); // specialize + public ShortVector64 lanewise(Unary op, VectorMask m) { + return (ShortVector64) super.lanewiseTemplate(op, ShortMask64.class, (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector lanewise(Binary op, Vector v) { - return (Short64Vector) super.lanewiseTemplate(op, v); // specialize + public ShortVector64 lanewise(Binary op, Vector v) { + return (ShortVector64) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public Short64Vector lanewise(Binary op, Vector v, VectorMask m) { - return (Short64Vector) super.lanewiseTemplate(op, Short64Mask.class, v, (Short64Mask) m); // specialize + public ShortVector64 lanewise(Binary op, Vector v, VectorMask m) { + return (ShortVector64) super.lanewiseTemplate(op, ShortMask64.class, v, (ShortMask64) m); // specialize } /*package-private*/ @Override - @ForceInline Short64Vector + @ForceInline ShortVector64 lanewiseShift(VectorOperators.Binary op, int e) { - return (Short64Vector) super.lanewiseShiftTemplate(op, e); // specialize + return (ShortVector64) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline Short64Vector + @ForceInline ShortVector64 lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (Short64Vector) super.lanewiseShiftTemplate(op, Short64Mask.class, e, (Short64Mask) m); // specialize + return (ShortVector64) super.lanewiseShiftTemplate(op, ShortMask64.class, e, (ShortMask64) m); // specialize } /*package-private*/ @Override @ForceInline public final - Short64Vector + ShortVector64 lanewise(Ternary op, Vector v1, Vector v2) { - return (Short64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ShortVector64) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - Short64Vector + ShortVector64 lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (Short64Vector) super.lanewiseTemplate(op, Short64Mask.class, v1, v2, (Short64Mask) m); // specialize + return (ShortVector64) super.lanewiseTemplate(op, ShortMask64.class, v1, v2, (ShortMask64) m); // specialize } @Override @ForceInline public final - Short64Vector addIndex(int scale) { - return (Short64Vector) super.addIndexTemplate(scale); // specialize + ShortVector64 addIndex(int scale) { + return (ShortVector64) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class Short64Vector extends ShortVector { @ForceInline public final short reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, Short64Mask.class, (Short64Mask) m); // specialized + return super.reduceLanesTemplate(op, ShortMask64.class, (ShortMask64) m); // specialized } @Override @@ -354,7 +359,7 @@ final class Short64Vector extends ShortVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, Short64Mask.class, (Short64Mask) m); // specialized + return (long) super.reduceLanesTemplate(op, ShortMask64.class, (ShortMask64) m); // specialized } @Override @@ -365,160 +370,160 @@ final class Short64Vector extends ShortVector { @Override @ForceInline - public final Short64Shuffle toShuffle() { - return (Short64Shuffle) toShuffle(vspecies(), false); + public final ShortShuffle64 toShuffle() { + return (ShortShuffle64) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final Short64Mask test(Test op) { - return super.testTemplate(Short64Mask.class, op); // specialize + public final ShortMask64 test(Test op) { + return super.testTemplate(ShortMask64.class, op); // specialize } @Override @ForceInline - public final Short64Mask test(Test op, VectorMask m) { - return super.testTemplate(Short64Mask.class, op, (Short64Mask) m); // specialize + public final ShortMask64 test(Test op, VectorMask m) { + return super.testTemplate(ShortMask64.class, op, (ShortMask64) m); // specialize } // Specialized comparisons @Override @ForceInline - public final Short64Mask compare(Comparison op, Vector v) { - return super.compareTemplate(Short64Mask.class, op, v); // specialize + public final ShortMask64 compare(Comparison op, Vector v) { + return super.compareTemplate(ShortMask64.class, op, v); // specialize } @Override @ForceInline - public final Short64Mask compare(Comparison op, short s) { - return super.compareTemplate(Short64Mask.class, op, s); // specialize + public final ShortMask64 compare(Comparison op, short s) { + return super.compareTemplate(ShortMask64.class, op, s); // specialize } @Override @ForceInline - public final Short64Mask compare(Comparison op, long s) { - return super.compareTemplate(Short64Mask.class, op, s); // specialize + public final ShortMask64 compare(Comparison op, long s) { + return super.compareTemplate(ShortMask64.class, op, s); // specialize } @Override @ForceInline - public final Short64Mask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(Short64Mask.class, op, v, (Short64Mask) m); + public final ShortMask64 compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ShortMask64.class, op, v, (ShortMask64) m); } @Override @ForceInline - public Short64Vector blend(Vector v, VectorMask m) { - return (Short64Vector) - super.blendTemplate(Short64Mask.class, - (Short64Vector) v, - (Short64Mask) m); // specialize + public ShortVector64 blend(Vector v, VectorMask m) { + return (ShortVector64) + super.blendTemplate(ShortMask64.class, + (ShortVector64) v, + (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector slice(int origin, Vector v) { - return (Short64Vector) super.sliceTemplate(origin, v); // specialize + public ShortVector64 slice(int origin, Vector v) { + return (ShortVector64) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public Short64Vector slice(int origin) { - return (Short64Vector) super.sliceTemplate(origin); // specialize + public ShortVector64 slice(int origin) { + return (ShortVector64) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public Short64Vector unslice(int origin, Vector w, int part) { - return (Short64Vector) super.unsliceTemplate(origin, w, part); // specialize + public ShortVector64 unslice(int origin, Vector w, int part) { + return (ShortVector64) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public Short64Vector unslice(int origin, Vector w, int part, VectorMask m) { - return (Short64Vector) - super.unsliceTemplate(Short64Mask.class, + public ShortVector64 unslice(int origin, Vector w, int part, VectorMask m) { + return (ShortVector64) + super.unsliceTemplate(ShortMask64.class, origin, w, part, - (Short64Mask) m); // specialize + (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector unslice(int origin) { - return (Short64Vector) super.unsliceTemplate(origin); // specialize + public ShortVector64 unslice(int origin) { + return (ShortVector64) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public Short64Vector rearrange(VectorShuffle s) { - return (Short64Vector) - super.rearrangeTemplate(Short64Shuffle.class, - (Short64Shuffle) s); // specialize + public ShortVector64 rearrange(VectorShuffle s) { + return (ShortVector64) + super.rearrangeTemplate(ShortShuffle64.class, + (ShortShuffle64) s); // specialize } @Override @ForceInline - public Short64Vector rearrange(VectorShuffle shuffle, + public ShortVector64 rearrange(VectorShuffle shuffle, VectorMask m) { - return (Short64Vector) - super.rearrangeTemplate(Short64Shuffle.class, - Short64Mask.class, - (Short64Shuffle) shuffle, - (Short64Mask) m); // specialize + return (ShortVector64) + super.rearrangeTemplate(ShortShuffle64.class, + ShortMask64.class, + (ShortShuffle64) shuffle, + (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector rearrange(VectorShuffle s, + public ShortVector64 rearrange(VectorShuffle s, Vector v) { - return (Short64Vector) - super.rearrangeTemplate(Short64Shuffle.class, - (Short64Shuffle) s, - (Short64Vector) v); // specialize + return (ShortVector64) + super.rearrangeTemplate(ShortShuffle64.class, + (ShortShuffle64) s, + (ShortVector64) v); // specialize } @Override @ForceInline - public Short64Vector compress(VectorMask m) { - return (Short64Vector) - super.compressTemplate(Short64Mask.class, - (Short64Mask) m); // specialize + public ShortVector64 compress(VectorMask m) { + return (ShortVector64) + super.compressTemplate(ShortMask64.class, + (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector expand(VectorMask m) { - return (Short64Vector) - super.expandTemplate(Short64Mask.class, - (Short64Mask) m); // specialize + public ShortVector64 expand(VectorMask m) { + return (ShortVector64) + super.expandTemplate(ShortMask64.class, + (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector selectFrom(Vector v) { - return (Short64Vector) - super.selectFromTemplate((Short64Vector) v); // specialize + public ShortVector64 selectFrom(Vector v) { + return (ShortVector64) + super.selectFromTemplate((ShortVector64) v); // specialize } @Override @ForceInline - public Short64Vector selectFrom(Vector v, + public ShortVector64 selectFrom(Vector v, VectorMask m) { - return (Short64Vector) - super.selectFromTemplate((Short64Vector) v, - Short64Mask.class, (Short64Mask) m); // specialize + return (ShortVector64) + super.selectFromTemplate((ShortVector64) v, + ShortMask64.class, (ShortMask64) m); // specialize } @Override @ForceInline - public Short64Vector selectFrom(Vector v1, + public ShortVector64 selectFrom(Vector v1, Vector v2) { - return (Short64Vector) - super.selectFromTemplate((Short64Vector) v1, (Short64Vector) v2); // specialize + return (ShortVector64) + super.selectFromTemplate((ShortVector64) v1, (ShortVector64) v2); // specialize } @ForceInline @@ -546,7 +551,7 @@ final class Short64Vector extends ShortVector { @ForceInline @Override - public Short64Vector withLane(int i, short e) { + public ShortVector64 withLane(int i, short e) { switch (i) { case 0: return withLaneHelper(0, e); case 1: return withLaneHelper(1, e); @@ -557,7 +562,7 @@ final class Short64Vector extends ShortVector { } @ForceInline - public Short64Vector withLaneHelper(int i, short e) { + public ShortVector64 withLaneHelper(int i, short e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -569,20 +574,21 @@ final class Short64Vector extends ShortVector { } // Mask - - static final class Short64Mask extends AbstractMask { + @ValueBased + static final class ShortMask64 extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short64Mask(boolean[] bits) { + static final Class CTYPE = short.class; // used by the JVM + + ShortMask64(boolean[] bits) { this(bits, 0); } - Short64Mask(boolean[] bits, int offset) { + ShortMask64(boolean[] bits, int offset) { super(prepare(bits, offset)); } - Short64Mask(boolean val) { + ShortMask64(boolean val) { super(prepare(val)); } @@ -615,31 +621,31 @@ final class Short64Vector extends ShortVector { } @Override - Short64Mask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask64 uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new Short64Mask(res); + return new ShortMask64(res); } @Override - Short64Mask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMask64 bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((Short64Mask)m).getBits(); + boolean[] mbits = ((ShortMask64)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new Short64Mask(res); + return new ShortMask64(res); } @ForceInline @Override public final - Short64Vector toVector() { - return (Short64Vector) super.toVectorTemplate(); // specialize + ShortVector64 toVector() { + return (ShortVector64) super.toVectorTemplate(); // specialize } /** @@ -672,25 +678,25 @@ final class Short64Vector extends ShortVector { @Override @ForceInline /*package-private*/ - Short64Mask indexPartiallyInUpperRange(long offset, long limit) { - return (Short64Mask) VectorSupport.indexPartiallyInUpperRange( - Short64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (Short64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + ShortMask64 indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMask64) VectorSupport.indexPartiallyInUpperRange( + ShortMask64.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ShortMask64) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public Short64Mask not() { + public ShortMask64 not() { return xor(maskAll(true)); } @Override @ForceInline - public Short64Mask compress() { - return (Short64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short64Vector.class, Short64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ShortMask64 compress() { + return (ShortMask64)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ShortVector64.class, ShortMask64.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -699,30 +705,30 @@ final class Short64Vector extends ShortVector { @Override @ForceInline - public Short64Mask and(VectorMask mask) { + public ShortMask64 and(VectorMask mask) { Objects.requireNonNull(mask); - Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask64 m = (ShortMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public Short64Mask or(VectorMask mask) { + public ShortMask64 or(VectorMask mask) { Objects.requireNonNull(mask); - Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask64 m = (ShortMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public Short64Mask xor(VectorMask mask) { + public ShortMask64 xor(VectorMask mask) { Objects.requireNonNull(mask); - Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short64Mask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMask64 m = (ShortMask64)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMask64.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -732,21 +738,21 @@ final class Short64Vector extends ShortVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -756,7 +762,7 @@ final class Short64Vector extends ShortVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -766,7 +772,7 @@ final class Short64Vector extends ShortVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short64Mask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ShortMask64.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -775,48 +781,49 @@ final class Short64Vector extends ShortVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short64Mask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ShortMask64)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ShortMask64)m).getBits())); } @ForceInline /*package-private*/ - static Short64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short64Mask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ShortMask64 maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ShortMask64.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final Short64Mask TRUE_MASK = new Short64Mask(true); - private static final Short64Mask FALSE_MASK = new Short64Mask(false); + private static final ShortMask64 TRUE_MASK = new ShortMask64(true); + private static final ShortMask64 FALSE_MASK = new ShortMask64(false); } // Shuffle - - static final class Short64Shuffle extends AbstractShuffle { + @ValueBased + static final class ShortShuffle64 extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - Short64Shuffle(short[] indices) { + static final Class CTYPE = short.class; // used by the JVM + + ShortShuffle64(short[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - Short64Shuffle(int[] indices, int i) { + ShortShuffle64(int[] indices, int i) { this(prepare(indices, i)); } - Short64Shuffle(IntUnaryOperator fn) { + ShortShuffle64(IntUnaryOperator fn) { this(prepare(fn)); } @@ -836,23 +843,23 @@ final class Short64Vector extends ShortVector { assert(VLENGTH < Short.MAX_VALUE); assert(Short.MIN_VALUE <= -VLENGTH); } - static final Short64Shuffle IOTA = new Short64Shuffle(IDENTITY); + static final ShortShuffle64 IOTA = new ShortShuffle64(IDENTITY); @Override @ForceInline - public Short64Vector toVector() { + public ShortVector64 toVector() { return toBitsVector(); } @Override @ForceInline - Short64Vector toBitsVector() { - return (Short64Vector) super.toBitsVectorTemplate(); + ShortVector64 toBitsVector() { + return (ShortVector64) super.toBitsVectorTemplate(); } @Override - Short64Vector toBitsVector0() { - return ((Short64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ShortVector64 toBitsVector0() { + return ((ShortVector64) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -889,30 +896,30 @@ final class Short64Vector extends ShortVector { @Override @ForceInline - public final Short64Mask laneIsValid() { - return (Short64Mask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ShortMask64 laneIsValid() { + return (ShortMask64) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final Short64Shuffle rearrange(VectorShuffle shuffle) { - Short64Shuffle concreteShuffle = (Short64Shuffle) shuffle; - return (Short64Shuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ShortShuffle64 rearrange(VectorShuffle shuffle) { + ShortShuffle64 concreteShuffle = (ShortShuffle64) shuffle; + return (ShortShuffle64) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final Short64Shuffle wrapIndexes() { - Short64Vector v = toBitsVector(); + public final ShortShuffle64 wrapIndexes() { + ShortVector64 v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (Short64Vector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ShortVector64) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (Short64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ShortVector64) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (Short64Shuffle) v.toShuffle(vspecies(), false); + return (ShortShuffle64) v.toShuffle(VSPECIES, false); } private static short[] prepare(int[] indices, int offset) { @@ -963,14 +970,14 @@ final class Short64Vector extends ShortVector { @Override final ShortVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(Short64Mask.class, a, offset, (Short64Mask) m, offsetInRange); // specialize + return super.fromArray0Template(ShortMask64.class, a, offset, (ShortMask64) m, offsetInRange); // specialize } @ForceInline @Override final ShortVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(Short64Mask.class, a, offset, indexMap, mapOffset, (Short64Mask) m); + return super.fromArray0Template(ShortMask64.class, a, offset, indexMap, mapOffset, (ShortMask64) m); } @ForceInline @@ -984,7 +991,7 @@ final class Short64Vector extends ShortVector { @Override final ShortVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromCharArray0Template(Short64Mask.class, a, offset, (Short64Mask) m, offsetInRange); // specialize + return super.fromCharArray0Template(ShortMask64.class, a, offset, (ShortMask64) m, offsetInRange); // specialize } @@ -999,7 +1006,7 @@ final class Short64Vector extends ShortVector { @Override final ShortVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(Short64Mask.class, ms, offset, (Short64Mask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ShortMask64.class, ms, offset, (ShortMask64) m, offsetInRange); // specialize } @ForceInline @@ -1013,7 +1020,7 @@ final class Short64Vector extends ShortVector { @Override final void intoArray0(short[] a, int offset, VectorMask m) { - super.intoArray0Template(Short64Mask.class, a, offset, (Short64Mask) m); + super.intoArray0Template(ShortMask64.class, a, offset, (ShortMask64) m); } @@ -1022,14 +1029,14 @@ final class Short64Vector extends ShortVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(Short64Mask.class, ms, offset, (Short64Mask) m); + super.intoMemorySegment0Template(ShortMask64.class, ms, offset, (ShortMask64) m); } @ForceInline @Override final void intoCharArray0(char[] a, int offset, VectorMask m) { - super.intoCharArray0Template(Short64Mask.class, a, offset, (Short64Mask) m); + super.intoCharArray0Template(ShortMask64.class, a, offset, (ShortMask64) m); } // End of specialized low-level memory operations. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVectorMax.java similarity index 63% rename from src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java rename to src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVectorMax.java index bf9b13c6606..fe0359c4711 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVectorMax.java @@ -25,49 +25,51 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; -import java.lang.foreign.ValueLayout; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; // -- This file was mechanically generated: Do not edit! -- // @SuppressWarnings("cast") // warning: redundant cast -final class ShortMaxVector extends ShortVector { +@ValueBased +final class ShortVectorMax extends ShortVector { static final ShortSpecies VSPECIES = (ShortSpecies) ShortVector.SPECIES_MAX; static final VectorShape VSHAPE = VSPECIES.vectorShape(); - static final Class VCLASS = ShortMaxVector.class; + static final Class VCLASS = ShortVectorMax.class; static final int VSIZE = VSPECIES.vectorBitSize(); static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + static final Class ETYPE = short.class; // used by the JVM - ShortMaxVector(short[] v) { + ShortVectorMax(short[] v) { super(v); } - // For compatibility as ShortMaxVector::new, + // For compatibility as ShortVectorMax::new, // stored into species.vectorFactory. - ShortMaxVector(Object v) { + ShortVectorMax(Object v) { this((short[]) v); } - static final ShortMaxVector ZERO = new ShortMaxVector(new short[VLENGTH]); - static final ShortMaxVector IOTA = new ShortMaxVector(VSPECIES.iotaArray()); + static final ShortVectorMax ZERO = new ShortVectorMax(new short[VLENGTH]); + static final ShortVectorMax IOTA = new ShortVectorMax(VSPECIES.iotaArray()); static { // Warm up a few species caches. @@ -92,6 +94,9 @@ final class ShortMaxVector extends ShortVector { @Override public final Class elementType() { return short.class; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return Short.SIZE; } @@ -130,51 +135,51 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline - public final ShortMaxVector broadcast(short e) { - return (ShortMaxVector) super.broadcastTemplate(e); // specialize + public final ShortVectorMax broadcast(short e) { + return (ShortVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - public final ShortMaxVector broadcast(long e) { - return (ShortMaxVector) super.broadcastTemplate(e); // specialize + public final ShortVectorMax broadcast(long e) { + return (ShortVectorMax) super.broadcastTemplate(e); // specialize } @Override @ForceInline - ShortMaxMask maskFromArray(boolean[] bits) { - return new ShortMaxMask(bits); + ShortMaskMax maskFromArray(boolean[] bits) { + return new ShortMaskMax(bits); } @Override @ForceInline - ShortMaxShuffle iotaShuffle() { return ShortMaxShuffle.IOTA; } + ShortShuffleMax iotaShuffle() { return ShortShuffleMax.IOTA; } @Override @ForceInline - ShortMaxShuffle iotaShuffle(int start, int step, boolean wrap) { - return (ShortMaxShuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + ShortShuffleMax iotaShuffle(int start, int step, boolean wrap) { + return (ShortShuffleMax) iotaShuffleTemplate((short) start, (short) step, wrap); } @Override @ForceInline - ShortMaxShuffle shuffleFromArray(int[] indices, int i) { return new ShortMaxShuffle(indices, i); } + ShortShuffleMax shuffleFromArray(int[] indices, int i) { return new ShortShuffleMax(indices, i); } @Override @ForceInline - ShortMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new ShortMaxShuffle(fn); } + ShortShuffleMax shuffleFromOp(IntUnaryOperator fn) { return new ShortShuffleMax(fn); } // Make a vector of the same species but the given elements: @ForceInline final @Override - ShortMaxVector vectorFactory(short[] vec) { - return new ShortMaxVector(vec); + ShortVectorMax vectorFactory(short[] vec) { + return new ShortVectorMax(vec); } @ForceInline final @Override - ByteMaxVector asByteVectorRaw() { - return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + ByteVectorMax asByteVectorRaw() { + return (ByteVectorMax) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -187,31 +192,31 @@ final class ShortMaxVector extends ShortVector { @ForceInline final @Override - ShortMaxVector uOp(FUnOp f) { - return (ShortMaxVector) super.uOpTemplate(f); // specialize + ShortVectorMax uOp(FUnOp f) { + return (ShortVectorMax) super.uOpTemplate(f); // specialize } @ForceInline final @Override - ShortMaxVector uOp(VectorMask m, FUnOp f) { - return (ShortMaxVector) - super.uOpTemplate((ShortMaxMask)m, f); // specialize + ShortVectorMax uOp(VectorMask m, FUnOp f) { + return (ShortVectorMax) + super.uOpTemplate((ShortMaskMax)m, f); // specialize } // Binary operator @ForceInline final @Override - ShortMaxVector bOp(Vector v, FBinOp f) { - return (ShortMaxVector) super.bOpTemplate((ShortMaxVector)v, f); // specialize + ShortVectorMax bOp(Vector v, FBinOp f) { + return (ShortVectorMax) super.bOpTemplate((ShortVectorMax)v, f); // specialize } @ForceInline final @Override - ShortMaxVector bOp(Vector v, + ShortVectorMax bOp(Vector v, VectorMask m, FBinOp f) { - return (ShortMaxVector) - super.bOpTemplate((ShortMaxVector)v, (ShortMaxMask)m, + return (ShortVectorMax) + super.bOpTemplate((ShortVectorMax)v, (ShortMaskMax)m, f); // specialize } @@ -219,19 +224,19 @@ final class ShortMaxVector extends ShortVector { @ForceInline final @Override - ShortMaxVector tOp(Vector v1, Vector v2, FTriOp f) { - return (ShortMaxVector) - super.tOpTemplate((ShortMaxVector)v1, (ShortMaxVector)v2, + ShortVectorMax tOp(Vector v1, Vector v2, FTriOp f) { + return (ShortVectorMax) + super.tOpTemplate((ShortVectorMax)v1, (ShortVectorMax)v2, f); // specialize } @ForceInline final @Override - ShortMaxVector tOp(Vector v1, Vector v2, + ShortVectorMax tOp(Vector v1, Vector v2, VectorMask m, FTriOp f) { - return (ShortMaxVector) - super.tOpTemplate((ShortMaxVector)v1, (ShortMaxVector)v2, - (ShortMaxMask)m, f); // specialize + return (ShortVectorMax) + super.tOpTemplate((ShortVectorMax)v1, (ShortVectorMax)v2, + (ShortMaskMax)m, f); // specialize } @ForceInline @@ -269,64 +274,64 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline - public ShortMaxVector lanewise(Unary op) { - return (ShortMaxVector) super.lanewiseTemplate(op); // specialize + public ShortVectorMax lanewise(Unary op) { + return (ShortVectorMax) super.lanewiseTemplate(op); // specialize } @Override @ForceInline - public ShortMaxVector lanewise(Unary op, VectorMask m) { - return (ShortMaxVector) super.lanewiseTemplate(op, ShortMaxMask.class, (ShortMaxMask) m); // specialize + public ShortVectorMax lanewise(Unary op, VectorMask m) { + return (ShortVectorMax) super.lanewiseTemplate(op, ShortMaskMax.class, (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector lanewise(Binary op, Vector v) { - return (ShortMaxVector) super.lanewiseTemplate(op, v); // specialize + public ShortVectorMax lanewise(Binary op, Vector v) { + return (ShortVectorMax) super.lanewiseTemplate(op, v); // specialize } @Override @ForceInline - public ShortMaxVector lanewise(Binary op, Vector v, VectorMask m) { - return (ShortMaxVector) super.lanewiseTemplate(op, ShortMaxMask.class, v, (ShortMaxMask) m); // specialize + public ShortVectorMax lanewise(Binary op, Vector v, VectorMask m) { + return (ShortVectorMax) super.lanewiseTemplate(op, ShortMaskMax.class, v, (ShortMaskMax) m); // specialize } /*package-private*/ @Override - @ForceInline ShortMaxVector + @ForceInline ShortVectorMax lanewiseShift(VectorOperators.Binary op, int e) { - return (ShortMaxVector) super.lanewiseShiftTemplate(op, e); // specialize + return (ShortVectorMax) super.lanewiseShiftTemplate(op, e); // specialize } /*package-private*/ @Override - @ForceInline ShortMaxVector + @ForceInline ShortVectorMax lanewiseShift(VectorOperators.Binary op, int e, VectorMask m) { - return (ShortMaxVector) super.lanewiseShiftTemplate(op, ShortMaxMask.class, e, (ShortMaxMask) m); // specialize + return (ShortVectorMax) super.lanewiseShiftTemplate(op, ShortMaskMax.class, e, (ShortMaskMax) m); // specialize } /*package-private*/ @Override @ForceInline public final - ShortMaxVector + ShortVectorMax lanewise(Ternary op, Vector v1, Vector v2) { - return (ShortMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + return (ShortVectorMax) super.lanewiseTemplate(op, v1, v2); // specialize } @Override @ForceInline public final - ShortMaxVector + ShortVectorMax lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { - return (ShortMaxVector) super.lanewiseTemplate(op, ShortMaxMask.class, v1, v2, (ShortMaxMask) m); // specialize + return (ShortVectorMax) super.lanewiseTemplate(op, ShortMaskMax.class, v1, v2, (ShortMaskMax) m); // specialize } @Override @ForceInline public final - ShortMaxVector addIndex(int scale) { - return (ShortMaxVector) super.addIndexTemplate(scale); // specialize + ShortVectorMax addIndex(int scale) { + return (ShortVectorMax) super.addIndexTemplate(scale); // specialize } // Type specific horizontal reductions @@ -341,7 +346,7 @@ final class ShortMaxVector extends ShortVector { @ForceInline public final short reduceLanes(VectorOperators.Associative op, VectorMask m) { - return super.reduceLanesTemplate(op, ShortMaxMask.class, (ShortMaxMask) m); // specialized + return super.reduceLanesTemplate(op, ShortMaskMax.class, (ShortMaskMax) m); // specialized } @Override @@ -354,7 +359,7 @@ final class ShortMaxVector extends ShortVector { @ForceInline public final long reduceLanesToLong(VectorOperators.Associative op, VectorMask m) { - return (long) super.reduceLanesTemplate(op, ShortMaxMask.class, (ShortMaxMask) m); // specialized + return (long) super.reduceLanesTemplate(op, ShortMaskMax.class, (ShortMaskMax) m); // specialized } @Override @@ -365,160 +370,160 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline - public final ShortMaxShuffle toShuffle() { - return (ShortMaxShuffle) toShuffle(vspecies(), false); + public final ShortShuffleMax toShuffle() { + return (ShortShuffleMax) toShuffle(VSPECIES, false); } // Specialized unary testing @Override @ForceInline - public final ShortMaxMask test(Test op) { - return super.testTemplate(ShortMaxMask.class, op); // specialize + public final ShortMaskMax test(Test op) { + return super.testTemplate(ShortMaskMax.class, op); // specialize } @Override @ForceInline - public final ShortMaxMask test(Test op, VectorMask m) { - return super.testTemplate(ShortMaxMask.class, op, (ShortMaxMask) m); // specialize + public final ShortMaskMax test(Test op, VectorMask m) { + return super.testTemplate(ShortMaskMax.class, op, (ShortMaskMax) m); // specialize } // Specialized comparisons @Override @ForceInline - public final ShortMaxMask compare(Comparison op, Vector v) { - return super.compareTemplate(ShortMaxMask.class, op, v); // specialize + public final ShortMaskMax compare(Comparison op, Vector v) { + return super.compareTemplate(ShortMaskMax.class, op, v); // specialize } @Override @ForceInline - public final ShortMaxMask compare(Comparison op, short s) { - return super.compareTemplate(ShortMaxMask.class, op, s); // specialize + public final ShortMaskMax compare(Comparison op, short s) { + return super.compareTemplate(ShortMaskMax.class, op, s); // specialize } @Override @ForceInline - public final ShortMaxMask compare(Comparison op, long s) { - return super.compareTemplate(ShortMaxMask.class, op, s); // specialize + public final ShortMaskMax compare(Comparison op, long s) { + return super.compareTemplate(ShortMaskMax.class, op, s); // specialize } @Override @ForceInline - public final ShortMaxMask compare(Comparison op, Vector v, VectorMask m) { - return super.compareTemplate(ShortMaxMask.class, op, v, (ShortMaxMask) m); + public final ShortMaskMax compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(ShortMaskMax.class, op, v, (ShortMaskMax) m); } @Override @ForceInline - public ShortMaxVector blend(Vector v, VectorMask m) { - return (ShortMaxVector) - super.blendTemplate(ShortMaxMask.class, - (ShortMaxVector) v, - (ShortMaxMask) m); // specialize + public ShortVectorMax blend(Vector v, VectorMask m) { + return (ShortVectorMax) + super.blendTemplate(ShortMaskMax.class, + (ShortVectorMax) v, + (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector slice(int origin, Vector v) { - return (ShortMaxVector) super.sliceTemplate(origin, v); // specialize + public ShortVectorMax slice(int origin, Vector v) { + return (ShortVectorMax) super.sliceTemplate(origin, v); // specialize } @Override @ForceInline - public ShortMaxVector slice(int origin) { - return (ShortMaxVector) super.sliceTemplate(origin); // specialize + public ShortVectorMax slice(int origin) { + return (ShortVectorMax) super.sliceTemplate(origin); // specialize } @Override @ForceInline - public ShortMaxVector unslice(int origin, Vector w, int part) { - return (ShortMaxVector) super.unsliceTemplate(origin, w, part); // specialize + public ShortVectorMax unslice(int origin, Vector w, int part) { + return (ShortVectorMax) super.unsliceTemplate(origin, w, part); // specialize } @Override @ForceInline - public ShortMaxVector unslice(int origin, Vector w, int part, VectorMask m) { - return (ShortMaxVector) - super.unsliceTemplate(ShortMaxMask.class, + public ShortVectorMax unslice(int origin, Vector w, int part, VectorMask m) { + return (ShortVectorMax) + super.unsliceTemplate(ShortMaskMax.class, origin, w, part, - (ShortMaxMask) m); // specialize + (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector unslice(int origin) { - return (ShortMaxVector) super.unsliceTemplate(origin); // specialize + public ShortVectorMax unslice(int origin) { + return (ShortVectorMax) super.unsliceTemplate(origin); // specialize } @Override @ForceInline - public ShortMaxVector rearrange(VectorShuffle s) { - return (ShortMaxVector) - super.rearrangeTemplate(ShortMaxShuffle.class, - (ShortMaxShuffle) s); // specialize + public ShortVectorMax rearrange(VectorShuffle s) { + return (ShortVectorMax) + super.rearrangeTemplate(ShortShuffleMax.class, + (ShortShuffleMax) s); // specialize } @Override @ForceInline - public ShortMaxVector rearrange(VectorShuffle shuffle, + public ShortVectorMax rearrange(VectorShuffle shuffle, VectorMask m) { - return (ShortMaxVector) - super.rearrangeTemplate(ShortMaxShuffle.class, - ShortMaxMask.class, - (ShortMaxShuffle) shuffle, - (ShortMaxMask) m); // specialize + return (ShortVectorMax) + super.rearrangeTemplate(ShortShuffleMax.class, + ShortMaskMax.class, + (ShortShuffleMax) shuffle, + (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector rearrange(VectorShuffle s, + public ShortVectorMax rearrange(VectorShuffle s, Vector v) { - return (ShortMaxVector) - super.rearrangeTemplate(ShortMaxShuffle.class, - (ShortMaxShuffle) s, - (ShortMaxVector) v); // specialize + return (ShortVectorMax) + super.rearrangeTemplate(ShortShuffleMax.class, + (ShortShuffleMax) s, + (ShortVectorMax) v); // specialize } @Override @ForceInline - public ShortMaxVector compress(VectorMask m) { - return (ShortMaxVector) - super.compressTemplate(ShortMaxMask.class, - (ShortMaxMask) m); // specialize + public ShortVectorMax compress(VectorMask m) { + return (ShortVectorMax) + super.compressTemplate(ShortMaskMax.class, + (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector expand(VectorMask m) { - return (ShortMaxVector) - super.expandTemplate(ShortMaxMask.class, - (ShortMaxMask) m); // specialize + public ShortVectorMax expand(VectorMask m) { + return (ShortVectorMax) + super.expandTemplate(ShortMaskMax.class, + (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector selectFrom(Vector v) { - return (ShortMaxVector) - super.selectFromTemplate((ShortMaxVector) v); // specialize + public ShortVectorMax selectFrom(Vector v) { + return (ShortVectorMax) + super.selectFromTemplate((ShortVectorMax) v); // specialize } @Override @ForceInline - public ShortMaxVector selectFrom(Vector v, + public ShortVectorMax selectFrom(Vector v, VectorMask m) { - return (ShortMaxVector) - super.selectFromTemplate((ShortMaxVector) v, - ShortMaxMask.class, (ShortMaxMask) m); // specialize + return (ShortVectorMax) + super.selectFromTemplate((ShortVectorMax) v, + ShortMaskMax.class, (ShortMaskMax) m); // specialize } @Override @ForceInline - public ShortMaxVector selectFrom(Vector v1, + public ShortVectorMax selectFrom(Vector v1, Vector v2) { - return (ShortMaxVector) - super.selectFromTemplate((ShortMaxVector) v1, (ShortMaxVector) v2); // specialize + return (ShortVectorMax) + super.selectFromTemplate((ShortVectorMax) v1, (ShortVectorMax) v2); // specialize } @ForceInline @@ -543,7 +548,7 @@ final class ShortMaxVector extends ShortVector { @ForceInline @Override - public ShortMaxVector withLane(int i, short e) { + public ShortVectorMax withLane(int i, short e) { if (i < 0 || i >= VLENGTH) { throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); } @@ -551,7 +556,7 @@ final class ShortMaxVector extends ShortVector { } @ForceInline - public ShortMaxVector withLaneHelper(int i, short e) { + public ShortVectorMax withLaneHelper(int i, short e) { return VectorSupport.insert( VCLASS, LANE_TYPE_ORDINAL, VLENGTH, this, i, (long)e, @@ -563,20 +568,21 @@ final class ShortMaxVector extends ShortVector { } // Mask - - static final class ShortMaxMask extends AbstractMask { + @ValueBased + static final class ShortMaskMax extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - ShortMaxMask(boolean[] bits) { + static final Class CTYPE = short.class; // used by the JVM + + ShortMaskMax(boolean[] bits) { this(bits, 0); } - ShortMaxMask(boolean[] bits, int offset) { + ShortMaskMax(boolean[] bits, int offset) { super(prepare(bits, offset)); } - ShortMaxMask(boolean val) { + ShortMaskMax(boolean val) { super(prepare(val)); } @@ -609,31 +615,31 @@ final class ShortMaxVector extends ShortVector { } @Override - ShortMaxMask uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMaskMax uOp(MUnOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); } - return new ShortMaxMask(res); + return new ShortMaskMax(res); } @Override - ShortMaxMask bOp(VectorMask m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + ShortMaskMax bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); - boolean[] mbits = ((ShortMaxMask)m).getBits(); + boolean[] mbits = ((ShortMaskMax)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i], mbits[i]); } - return new ShortMaxMask(res); + return new ShortMaskMax(res); } @ForceInline @Override public final - ShortMaxVector toVector() { - return (ShortMaxVector) super.toVectorTemplate(); // specialize + ShortVectorMax toVector() { + return (ShortVectorMax) super.toVectorTemplate(); // specialize } /** @@ -666,25 +672,25 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline /*package-private*/ - ShortMaxMask indexPartiallyInUpperRange(long offset, long limit) { - return (ShortMaxMask) VectorSupport.indexPartiallyInUpperRange( - ShortMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, - (o, l) -> (ShortMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + ShortMaskMax indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMaskMax) VectorSupport.indexPartiallyInUpperRange( + ShortMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, offset, limit, + (o, l) -> (ShortMaskMax) TRUE_MASK.indexPartiallyInRange(o, l)); } // Unary operations @Override @ForceInline - public ShortMaxMask not() { + public ShortMaskMax not() { return xor(maskAll(true)); } @Override @ForceInline - public ShortMaxMask compress() { - return (ShortMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - ShortMaxVector.class, ShortMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, + public ShortMaskMax compress() { + return (ShortMaskMax)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + ShortVectorMax.class, ShortMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, null, this, (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); } @@ -693,30 +699,30 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline - public ShortMaxMask and(VectorMask mask) { + public ShortMaskMax and(VectorMask mask) { Objects.requireNonNull(mask); - ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMaskMax m = (ShortMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @Override @ForceInline - public ShortMaxMask or(VectorMask mask) { + public ShortMaskMax or(VectorMask mask) { Objects.requireNonNull(mask); - ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMaskMax m = (ShortMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @Override @ForceInline - public ShortMaxMask xor(VectorMask mask) { + public ShortMaskMax xor(VectorMask mask) { Objects.requireNonNull(mask); - ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMaxMask.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, + ShortMaskMax m = (ShortMaskMax)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMaskMax.class, null, LANEBITS_TYPE_ORDINAL, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -726,21 +732,21 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> lastTrueHelper(m.getBits())); } @@ -750,7 +756,7 @@ final class ShortMaxVector extends ShortVector { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -760,7 +766,7 @@ final class ShortMaxVector extends ShortVector { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(ShortMaxMask.class, LANE_TYPE_ORDINAL, VLENGTH, + return VectorSupport.extract(ShortMaskMax.class, LANE_TYPE_ORDINAL, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -769,48 +775,49 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((ShortMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper(((ShortMaskMax)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((ShortMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper(((ShortMaskMax)m).getBits())); } @ForceInline /*package-private*/ - static ShortMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(ShortMaxMask.class, LANEBITS_TYPE_ORDINAL, VLENGTH, + static ShortMaskMax maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(ShortMaskMax.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } - private static final ShortMaxMask TRUE_MASK = new ShortMaxMask(true); - private static final ShortMaxMask FALSE_MASK = new ShortMaxMask(false); + private static final ShortMaskMax TRUE_MASK = new ShortMaskMax(true); + private static final ShortMaskMax FALSE_MASK = new ShortMaskMax(false); } // Shuffle - - static final class ShortMaxShuffle extends AbstractShuffle { + @ValueBased + static final class ShortShuffleMax extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM - ShortMaxShuffle(short[] indices) { + static final Class CTYPE = short.class; // used by the JVM + + ShortShuffleMax(short[] indices) { super(indices); assert(VLENGTH == indices.length); assert(indicesInRange(indices)); } - ShortMaxShuffle(int[] indices, int i) { + ShortShuffleMax(int[] indices, int i) { this(prepare(indices, i)); } - ShortMaxShuffle(IntUnaryOperator fn) { + ShortShuffleMax(IntUnaryOperator fn) { this(prepare(fn)); } @@ -830,23 +837,23 @@ final class ShortMaxVector extends ShortVector { assert(VLENGTH < Short.MAX_VALUE); assert(Short.MIN_VALUE <= -VLENGTH); } - static final ShortMaxShuffle IOTA = new ShortMaxShuffle(IDENTITY); + static final ShortShuffleMax IOTA = new ShortShuffleMax(IDENTITY); @Override @ForceInline - public ShortMaxVector toVector() { + public ShortVectorMax toVector() { return toBitsVector(); } @Override @ForceInline - ShortMaxVector toBitsVector() { - return (ShortMaxVector) super.toBitsVectorTemplate(); + ShortVectorMax toBitsVector() { + return (ShortVectorMax) super.toBitsVectorTemplate(); } @Override - ShortMaxVector toBitsVector0() { - return ((ShortMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + ShortVectorMax toBitsVector0() { + return ((ShortVectorMax) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -883,30 +890,30 @@ final class ShortMaxVector extends ShortVector { @Override @ForceInline - public final ShortMaxMask laneIsValid() { - return (ShortMaxMask) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + public final ShortMaskMax laneIsValid() { + return (ShortMaskMax) toBitsVector().compare(VectorOperators.GE, 0) + .cast(VSPECIES); } @ForceInline @Override - public final ShortMaxShuffle rearrange(VectorShuffle shuffle) { - ShortMaxShuffle concreteShuffle = (ShortMaxShuffle) shuffle; - return (ShortMaxShuffle) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + public final ShortShuffleMax rearrange(VectorShuffle shuffle) { + ShortShuffleMax concreteShuffle = (ShortShuffleMax) shuffle; + return (ShortShuffleMax) toBitsVector().rearrange(concreteShuffle) + .toShuffle(VSPECIES, false); } @ForceInline @Override - public final ShortMaxShuffle wrapIndexes() { - ShortMaxVector v = toBitsVector(); + public final ShortShuffleMax wrapIndexes() { + ShortVectorMax v = toBitsVector(); if ((length() & (length() - 1)) == 0) { - v = (ShortMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + v = (ShortVectorMax) v.lanewise(VectorOperators.AND, length() - 1); } else { - v = (ShortMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v = (ShortVectorMax) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return (ShortMaxShuffle) v.toShuffle(vspecies(), false); + return (ShortShuffleMax) v.toShuffle(VSPECIES, false); } private static short[] prepare(int[] indices, int offset) { @@ -957,14 +964,14 @@ final class ShortMaxVector extends ShortVector { @Override final ShortVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromArray0Template(ShortMaxMask.class, a, offset, (ShortMaxMask) m, offsetInRange); // specialize + return super.fromArray0Template(ShortMaskMax.class, a, offset, (ShortMaskMax) m, offsetInRange); // specialize } @ForceInline @Override final ShortVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { - return super.fromArray0Template(ShortMaxMask.class, a, offset, indexMap, mapOffset, (ShortMaxMask) m); + return super.fromArray0Template(ShortMaskMax.class, a, offset, indexMap, mapOffset, (ShortMaskMax) m); } @ForceInline @@ -978,7 +985,7 @@ final class ShortMaxVector extends ShortVector { @Override final ShortVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { - return super.fromCharArray0Template(ShortMaxMask.class, a, offset, (ShortMaxMask) m, offsetInRange); // specialize + return super.fromCharArray0Template(ShortMaskMax.class, a, offset, (ShortMaskMax) m, offsetInRange); // specialize } @@ -993,7 +1000,7 @@ final class ShortMaxVector extends ShortVector { @Override final ShortVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { - return super.fromMemorySegment0Template(ShortMaxMask.class, ms, offset, (ShortMaxMask) m, offsetInRange); // specialize + return super.fromMemorySegment0Template(ShortMaskMax.class, ms, offset, (ShortMaskMax) m, offsetInRange); // specialize } @ForceInline @@ -1007,7 +1014,7 @@ final class ShortMaxVector extends ShortVector { @Override final void intoArray0(short[] a, int offset, VectorMask m) { - super.intoArray0Template(ShortMaxMask.class, a, offset, (ShortMaxMask) m); + super.intoArray0Template(ShortMaskMax.class, a, offset, (ShortMaskMax) m); } @@ -1016,14 +1023,14 @@ final class ShortMaxVector extends ShortVector { @Override final void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { - super.intoMemorySegment0Template(ShortMaxMask.class, ms, offset, (ShortMaxMask) m); + super.intoMemorySegment0Template(ShortMaskMax.class, ms, offset, (ShortMaskMax) m); } @ForceInline @Override final void intoCharArray0(char[] a, int offset, VectorMask m) { - super.intoCharArray0Template(ShortMaxMask.class, a, offset, (ShortMaxMask) m); + super.intoCharArray0Template(ShortMaskMax.class, a, offset, (ShortMaskMax) m); } // End of specialized low-level memory operations. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Util.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Util.java index 8562d4b5d7a..133195fa54d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Util.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ */ package jdk.incubator.vector; -/*package-private*/ class Util { +/*package-private*/ final class Util { public static void requires(boolean cond, String message) { if (!cond) { throw new InternalError(message); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java index 68b4a35067c..85b3bbca269 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -1170,9 +1170,10 @@ import java.util.Arrays; * @param the boxed version of {@code ETYPE}, * the element type of a vector * + * @sealedGraph */ @SuppressWarnings("exports") -public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vector { +public abstract sealed class Vector extends jdk.internal.vm.vector.VectorSupport.Vector permits AbstractVector { // This type is sealed within its package. // Users cannot roll their own vector types. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java index 266a843083a..f0115371d48 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +28,7 @@ import jdk.internal.vm.annotation.ForceInline; import java.util.Objects; -/*non-public*/ class VectorIntrinsics { +/*non-public*/ final class VectorIntrinsics { static final int VECTOR_ACCESS_OOB_CHECK = Integer.getInteger("jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK", 2); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java index 13ee9e27e0d..607b194946b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java @@ -131,7 +131,7 @@ import java.util.Objects; * the element type of a vector */ @SuppressWarnings("exports") -public abstract class VectorMask extends jdk.internal.vm.vector.VectorSupport.VectorMask { +public abstract sealed class VectorMask extends jdk.internal.vm.vector.VectorSupport.VectorMask permits AbstractMask { VectorMask(boolean[] bits) { super(bits); } /** diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java index ecd03ab9124..823cebd85a9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +42,7 @@ import static jdk.internal.vm.vector.Utils.debug; * A wrapper for native vector math libraries bundled with the JDK (SVML and SLEEF). * Binds vector operations to native implementations provided by the libraries. */ -/*package-private*/ class VectorMathLibrary { +/*package-private*/ final class VectorMathLibrary { private static final SymbolLookup LOOKUP = SymbolLookup.loaderLookup(); interface Library { @@ -139,8 +139,8 @@ import static jdk.internal.vm.vector.Utils.debug; public String symbolName(Operator op, VectorSpecies vspecies) { String suffix = suffix(vspecies); String elemType = (vspecies.elementType() == float.class ? "f" : ""); - boolean isFloat64Vector = (vspecies.elementType() == float.class) && (vspecies.length() == 2); // Float64Vector or FloatMaxVector - int vlen = (isFloat64Vector ? 4 : vspecies.length()); // reuse 128-bit variant for 64-bit float vectors + boolean isFloatVector64 = (vspecies.elementType() == float.class) && (vspecies.length() == 2); // FloatVector64 or FloatVectorMax + int vlen = (isFloatVector64 ? 4 : vspecies.length()); // reuse 128-bit variant for 64-bit float vectors return String.format("__jsvml_%s%s%d_ha_%s", op.operatorName(), elemType, vlen, suffix); } @@ -211,8 +211,8 @@ import static jdk.internal.vm.vector.Utils.debug; @Override public String symbolName(Operator op, VectorSpecies vspecies) { - boolean isFloat64Vector = (vspecies.elementType() == float.class) && (vspecies.length() == 2); // Float64Vector or FloatMaxVector - int vlen = (isFloat64Vector ? 4 : vspecies.length()); // reuse 128-bit variant for 64-bit float vectors + boolean isFloatVector64 = (vspecies.elementType() == float.class) && (vspecies.length() == 2); // FloatVector64 or FloatVectorMax + int vlen = (isFloatVector64 ? 4 : vspecies.length()); // reuse 128-bit variant for 64-bit float vectors boolean isShapeAgnostic = isRISCV64() || (isAARCH64() && vspecies.vectorBitSize() > 128); return String.format("%s%s%s_%s%s", op.operatorName(), (vspecies.elementType() == float.class ? "f" : "d"), @@ -283,7 +283,7 @@ import static jdk.internal.vm.vector.Utils.debug; @ForceInline /*package-private*/ static > - V unaryMathOp(Unary op, int opc, VectorSpecies vspecies, + V unaryMathOp(Unary op, int opc, AbstractSpecies vspecies, IntFunction> implSupplier, V v) { var entry = lookup(op, opc, vspecies, implSupplier); @@ -293,7 +293,7 @@ import static jdk.internal.vm.vector.Utils.debug; @SuppressWarnings({"unchecked"}) Class vt = (Class)vspecies.vectorType(); return VectorSupport.libraryUnaryOp( - entry.entry.address(), vt, vspecies.elementType(), vspecies.length(), entry.name, + entry.entry.address(), vt, vspecies.laneTypeOrdinal(), vspecies.length(), entry.name, v, entry.impl); } else { @@ -304,7 +304,7 @@ import static jdk.internal.vm.vector.Utils.debug; @ForceInline /*package-private*/ static > - V binaryMathOp(Binary op, int opc, VectorSpecies vspecies, + V binaryMathOp(Binary op, int opc, AbstractSpecies vspecies, IntFunction> implSupplier, V v1, V v2) { var entry = lookup(op, opc, vspecies, implSupplier); @@ -314,7 +314,7 @@ import static jdk.internal.vm.vector.Utils.debug; @SuppressWarnings({"unchecked"}) Class vt = (Class)vspecies.vectorType(); return VectorSupport.libraryBinaryOp( - entry.entry.address(), vt, vspecies.elementType(), vspecies.length(), entry.name, + entry.entry.address(), vt, vspecies.laneTypeOrdinal(), vspecies.length(), entry.name, v1, v2, entry.impl); } else { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java index 84009c55ac9..2f2d33ab130 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java @@ -24,13 +24,12 @@ */ package jdk.incubator.vector; -import java.util.function.IntFunction; -import java.util.HashMap; import java.util.ArrayList; +import java.util.HashMap; +import java.util.function.IntFunction; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Stable; - import jdk.internal.vm.vector.VectorSupport; import static jdk.internal.vm.vector.Utils.isNonCapturingLambda; @@ -115,7 +114,7 @@ import static jdk.internal.vm.vector.Utils.isNonCapturingLambda; * operations on individual lane values. * */ -public abstract class VectorOperators { +public final class VectorOperators { private VectorOperators() { } /** @@ -131,12 +130,9 @@ public abstract class VectorOperators { * @see VectorOperators.Test Test * @see VectorOperators.Conversion Conversion * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. + * @sealedGraph */ - public interface Operator { + public sealed interface Operator { /** * Returns the symbolic name of this operator, * as a constant in {@link VectorOperators}. @@ -235,13 +231,8 @@ public abstract class VectorOperators { * usable in expressions like {@code w = v0.}{@link * Vector#lanewise(VectorOperators.Unary) * lanewise}{@code (NEG)}. - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Unary extends Operator { + public sealed interface Unary extends Operator { } /** @@ -252,12 +243,9 @@ public abstract class VectorOperators { * Vector#lanewise(VectorOperators.Binary,Vector) * lanewise}{@code (ADD, v1)}. * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. + * @sealedGraph */ - public interface Binary extends Operator { + public sealed interface Binary extends Operator { } /** @@ -267,13 +255,8 @@ public abstract class VectorOperators { * usable in expressions like {@code w = v0.}{@link * Vector#lanewise(VectorOperators.Ternary,Vector,Vector) * lanewise}{@code (FMA, v1, v2)}. - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Ternary extends Operator { + public sealed interface Ternary extends Operator { } /** @@ -283,13 +266,8 @@ public abstract class VectorOperators { * usable in expressions like {@code e = v0.}{@link * IntVector#reduceLanes(VectorOperators.Associative) * reduceLanes}{@code (ADD)}. - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Associative extends Binary { + public sealed interface Associative extends Binary { } /** @@ -299,13 +277,8 @@ public abstract class VectorOperators { * usable in expressions like {@code m = v0.}{@link * FloatVector#test(VectorOperators.Test) * test}{@code (IS_FINITE)}. - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Test extends Operator { + public sealed interface Test extends Operator { } /** @@ -315,13 +288,8 @@ public abstract class VectorOperators { * usable in expressions like {@code m = v0.}{@link * Vector#compare(VectorOperators.Comparison,Vector) * compare}{@code (LT, v1)}. - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Comparison extends Operator { + public sealed interface Comparison extends Operator { } /** @@ -336,13 +304,8 @@ public abstract class VectorOperators { * domain type (the input lane type) * @param the boxed element type for the conversion * range type (the output lane type) - * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. */ - public interface Conversion extends Operator { + public sealed interface Conversion extends Operator { /** * The domain of this conversion, a primitive type. * @return the domain of this conversion @@ -831,7 +794,7 @@ public abstract class VectorOperators { kind, dom, ran); } - private abstract static class OperatorImpl implements Operator { + private abstract static sealed class OperatorImpl implements Operator { private final String symName; private final String opName; private final int opInfo; @@ -956,35 +919,35 @@ public abstract class VectorOperators { } } - private static class UnaryImpl extends OperatorImpl implements Unary { + private static final class UnaryImpl extends OperatorImpl implements Unary { private UnaryImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); assert((opInfo & VO_ARITY_MASK) == VO_UNARY); } } - private static class BinaryImpl extends OperatorImpl implements Binary { + private static sealed class BinaryImpl extends OperatorImpl implements Binary permits AssociativeImpl { private BinaryImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); assert((opInfo & VO_ARITY_MASK) == VO_BINARY); } } - private static class TernaryImpl extends OperatorImpl implements Ternary { + private static final class TernaryImpl extends OperatorImpl implements Ternary { private TernaryImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); assert((opInfo & VO_ARITY_MASK) == VO_TERNARY); } } - private static class AssociativeImpl extends BinaryImpl implements Associative { + private static final class AssociativeImpl extends BinaryImpl implements Associative { private AssociativeImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); } } /*package-private*/ - static + static final class ConversionImpl extends OperatorImpl implements Conversion { private ConversionImpl(String symName, String opName, int opInfo, @@ -1260,7 +1223,7 @@ public abstract class VectorOperators { } } - private static class TestImpl extends OperatorImpl implements Test { + private static final class TestImpl extends OperatorImpl implements Test { private TestImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); assert((opInfo & VO_ARITY_MASK) == VO_UNARY); @@ -1272,7 +1235,7 @@ public abstract class VectorOperators { } } - private static class ComparisonImpl extends OperatorImpl implements Comparison { + private static final class ComparisonImpl extends OperatorImpl implements Comparison { private ComparisonImpl(String symName, String opName, int opInfo) { super(symName, opName, opInfo); assert((opInfo & VO_ARITY_MASK) == VO_BINARY); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java index f6e36450ce0..84b58ef789a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -250,8 +250,8 @@ public enum VectorShape { private static VectorShape computePreferredShape() { int prefBitSize = Integer.MAX_VALUE; for (LaneType type : LaneType.values()) { - Class etype = type.elementType; - prefBitSize = Math.min(prefBitSize, getMaxVectorBitSize(etype)); + Class ctype = type.carrierType; + prefBitSize = Math.min(prefBitSize, getMaxVectorBitSize(ctype)); } // If these assertions fail, we must reconsider our API portability assumptions. assert(prefBitSize >= Double.SIZE && prefBitSize < Integer.MAX_VALUE / Long.SIZE); @@ -264,16 +264,16 @@ public enum VectorShape { /** * Returns the maximum vector bit size for a given element type. * - * @param etype the element type. + * @param ctype the carrier type. * @return the maximum vector bit. */ /*package-private*/ - static int getMaxVectorBitSize(Class etype) { + static int getMaxVectorBitSize(Class ctype) { // VectorSupport.getMaxLaneCount may return -1 if C2 is not enabled, // or a value smaller than the S_64_BIT.vectorBitSize / elementSizeInBits if MaxVectorSize < 16 // If so default to S_64_BIT - int maxLaneCount = VectorSupport.getMaxLaneCount(etype); - int elementSizeInBits = LaneType.of(etype).elementSize; + int maxLaneCount = VectorSupport.getMaxLaneCount(ctype); + int elementSizeInBits = LaneType.of(ctype).elementSize; return Math.max(maxLaneCount * elementSizeInBits, S_64_BIT.vectorBitSize); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShuffle.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShuffle.java index 9cde9d2315c..5da38a25e16 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShuffle.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShuffle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -136,7 +136,7 @@ import java.util.function.IntUnaryOperator; * the element type of a vector */ @SuppressWarnings("exports") -public abstract class VectorShuffle extends jdk.internal.vm.vector.VectorSupport.VectorShuffle { +public abstract sealed class VectorShuffle extends jdk.internal.vm.vector.VectorSupport.VectorShuffle permits AbstractShuffle { VectorShuffle(Object indices) { super(indices); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorSpecies.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorSpecies.java index e80bbf231ea..4c3ef3f471d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorSpecies.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorSpecies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,11 +36,6 @@ import java.util.function.IntUnaryOperator; * of element type ({@code ETYPE}) * and {@link VectorShape shape}. * - * @apiNote - * User code should not implement this interface. A future release of - * this type may restrict implementations to be members of the same - * package. - * * @implNote * The string representation of an instance of this interface will * be of the form "Species[ETYPE, VLENGTH, SHAPE]", where {@code @@ -57,7 +52,7 @@ import java.util.function.IntUnaryOperator; * @param the boxed version of {@code ETYPE}, * the element type of a vector */ -public interface VectorSpecies { +public sealed interface VectorSpecies permits AbstractSpecies { /** * Returns the primitive element type of vectors of this * species. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index 48d6ed762be..b3c5bfac302 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -49,7 +49,8 @@ import static jdk.incubator.vector.VectorOperators.*; * {@code $type$} values. */ @SuppressWarnings("cast") // warning: redundant cast -public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { +public abstract sealed class $abstractvectortype$ extends AbstractVector<$Boxtype$> + permits $Type$Vector64, $Type$Vector128, $Type$Vector256, $Type$Vector512, $Type$VectorMax { $abstractvectortype$($type$[] vec) { super(vec); @@ -88,8 +89,8 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // The various shape-specific subclasses // also specialize them by wrapping // them in a call like this: - // return (Byte128Vector) - // super.bOp((Byte128Vector) o); + // return (ByteVector128) + // super.bOp((ByteVector128) o); // The purpose of that is to forcibly inline // the generic definition from this file // into a sharply-typed and size-specific @@ -772,7 +773,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @ForceInline final $abstractvectortype$ unaryMathOp(VectorOperators.Unary op) { - return VectorMathLibrary.unaryMathOp(op, opCode(op), species(), $abstractvectortype$::unaryOperations, + return VectorMathLibrary.unaryMathOp(op, opCode(op), vspecies(), $abstractvectortype$::unaryOperations, this); } #end[FP] @@ -983,7 +984,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @ForceInline final $abstractvectortype$ binaryMathOp(VectorOperators.Binary op, $abstractvectortype$ that) { - return VectorMathLibrary.binaryMathOp(op, opCode(op), species(), $abstractvectortype$::binaryOperations, + return VectorMathLibrary.binaryMathOp(op, opCode(op), vspecies(), $abstractvectortype$::binaryOperations, this, that); } #end[FP] @@ -3829,7 +3830,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For $Type$MaxVector, if vector length is non-power-of-two or + // For $Type$VectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of $Type$ species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of $Type$ // vector is 32. When converting $Type$ species to int species, @@ -3837,7 +3838,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -4455,14 +4456,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For $Type$MaxVector, if vector length is 2048 bits, indexShape + // For $Type$VectorMax, if vector length is 2048 bits, indexShape // of $Type$ species is S_MAX_BIT. and the lane count of $Type$ // vector is 32. When converting $Type$ species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -5061,7 +5062,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // Index vector: vix[0:n] = k -> offset + indexMap[mapOffset + k] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For $Type$MaxVector, if vector length is non-power-of-two or + // For $Type$VectorMax, if vector length is non-power-of-two or // 2048 bits, indexShape of $Type$ species is S_MAX_BIT. // Assume that vector length is 2048, then the lane count of $Type$ // vector is 32. When converting $Type$ species to int species, @@ -5069,7 +5070,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -5252,14 +5253,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // Index vector: vix[0:n] = i -> offset + indexMap[mo + i] IntVector vix; if (isp.laneCount() != vsp.laneCount()) { - // For $Type$MaxVector, if vector length is 2048 bits, indexShape + // For $Type$VectorMax, if vector length is 2048 bits, indexShape // of $Type$ species is S_MAX_BIT. and the lane count of $Type$ // vector is 32. When converting $Type$ species to int species, // indexShape is still S_MAX_BIT, but the lane count of int vector // is 64. So when loading index vector (IntVector), only lower half // of index data is needed. vix = IntVector - .fromArray(isp, indexMap, mapOffset, IntMaxVector.IntMaxMask.LOWER_HALF_TRUE_MASK) + .fromArray(isp, indexMap, mapOffset, IntVectorMax.IntMaskMax.LOWER_HALF_TRUE_MASK) .add(offset); } else { vix = IntVector @@ -5813,13 +5814,13 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @Override @ForceInline public final $abstractvectortype$ zero() { - if ((Class) vectorType() == $Type$MaxVector.class) - return $Type$MaxVector.ZERO; + if ((Class) vectorType() == $Type$VectorMax.class) + return $Type$VectorMax.ZERO; switch (vectorBitSize()) { - case 64: return $Type$64Vector.ZERO; - case 128: return $Type$128Vector.ZERO; - case 256: return $Type$256Vector.ZERO; - case 512: return $Type$512Vector.ZERO; + case 64: return $Type$Vector64.ZERO; + case 128: return $Type$Vector128.ZERO; + case 256: return $Type$Vector256.ZERO; + case 512: return $Type$Vector512.ZERO; } throw new AssertionError(); } @@ -5827,13 +5828,13 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @Override @ForceInline public final $abstractvectortype$ iota() { - if ((Class) vectorType() == $Type$MaxVector.class) - return $Type$MaxVector.IOTA; + if ((Class) vectorType() == $Type$VectorMax.class) + return $Type$VectorMax.IOTA; switch (vectorBitSize()) { - case 64: return $Type$64Vector.IOTA; - case 128: return $Type$128Vector.IOTA; - case 256: return $Type$256Vector.IOTA; - case 512: return $Type$512Vector.IOTA; + case 64: return $Type$Vector64.IOTA; + case 128: return $Type$Vector128.IOTA; + case 256: return $Type$Vector256.IOTA; + case 512: return $Type$Vector512.IOTA; } throw new AssertionError(); } @@ -5842,13 +5843,13 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @Override @ForceInline public final VectorMask<$Boxtype$> maskAll(boolean bit) { - if ((Class) vectorType() == $Type$MaxVector.class) - return $Type$MaxVector.$Type$MaxMask.maskAll(bit); + if ((Class) vectorType() == $Type$VectorMax.class) + return $Type$VectorMax.$Type$MaskMax.maskAll(bit); switch (vectorBitSize()) { - case 64: return $Type$64Vector.$Type$64Mask.maskAll(bit); - case 128: return $Type$128Vector.$Type$128Mask.maskAll(bit); - case 256: return $Type$256Vector.$Type$256Mask.maskAll(bit); - case 512: return $Type$512Vector.$Type$512Mask.maskAll(bit); + case 64: return $Type$Vector64.$Type$Mask64.maskAll(bit); + case 128: return $Type$Vector128.$Type$Mask128.maskAll(bit); + case 256: return $Type$Vector256.$Type$Mask256.maskAll(bit); + case 512: return $Type$Vector512.$Type$Mask512.maskAll(bit); } throw new AssertionError(); } @@ -5876,42 +5877,42 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ public static final VectorSpecies<$Boxtype$> SPECIES_64 = new $Type$Species(VectorShape.S_64_BIT, - $Type$64Vector.class, - $Type$64Vector.$Type$64Mask.class, - $Type$64Vector.$Type$64Shuffle.class, - $Type$64Vector::new); + $Type$Vector64.class, + $Type$Vector64.$Type$Mask64.class, + $Type$Vector64.$Type$Shuffle64.class, + $Type$Vector64::new); /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ public static final VectorSpecies<$Boxtype$> SPECIES_128 = new $Type$Species(VectorShape.S_128_BIT, - $Type$128Vector.class, - $Type$128Vector.$Type$128Mask.class, - $Type$128Vector.$Type$128Shuffle.class, - $Type$128Vector::new); + $Type$Vector128.class, + $Type$Vector128.$Type$Mask128.class, + $Type$Vector128.$Type$Shuffle128.class, + $Type$Vector128::new); /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ public static final VectorSpecies<$Boxtype$> SPECIES_256 = new $Type$Species(VectorShape.S_256_BIT, - $Type$256Vector.class, - $Type$256Vector.$Type$256Mask.class, - $Type$256Vector.$Type$256Shuffle.class, - $Type$256Vector::new); + $Type$Vector256.class, + $Type$Vector256.$Type$Mask256.class, + $Type$Vector256.$Type$Shuffle256.class, + $Type$Vector256::new); /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ public static final VectorSpecies<$Boxtype$> SPECIES_512 = new $Type$Species(VectorShape.S_512_BIT, - $Type$512Vector.class, - $Type$512Vector.$Type$512Mask.class, - $Type$512Vector.$Type$512Shuffle.class, - $Type$512Vector::new); + $Type$Vector512.class, + $Type$Vector512.$Type$Mask512.class, + $Type$Vector512.$Type$Shuffle512.class, + $Type$Vector512::new); /** Species representing {@link $Type$Vector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ public static final VectorSpecies<$Boxtype$> SPECIES_MAX = new $Type$Species(VectorShape.S_Max_BIT, - $Type$MaxVector.class, - $Type$MaxVector.$Type$MaxMask.class, - $Type$MaxVector.$Type$MaxShuffle.class, - $Type$MaxVector::new); + $Type$VectorMax.class, + $Type$VectorMax.$Type$MaskMax.class, + $Type$VectorMax.$Type$ShuffleMax.class, + $Type$VectorMax::new); /** * Preferred species for {@link $Type$Vector}s. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index 61ac02d84f6..d66d22cab19 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -25,22 +25,25 @@ package jdk.incubator.vector; import java.lang.foreign.MemorySegment; +#if[longOrDouble] import java.lang.foreign.ValueLayout; +#end[longOrDouble] import java.nio.ByteOrder; import java.util.Arrays; import java.util.Objects; import java.util.function.IntUnaryOperator; +import jdk.internal.ValueBased; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; -import static jdk.internal.vm.vector.VectorSupport.*; - import static jdk.incubator.vector.VectorOperators.*; +import static jdk.internal.vm.vector.VectorSupport.*; #warn This file is preprocessed before being compiled @SuppressWarnings("cast") // warning: redundant cast +@ValueBased final class $vectortype$ extends $abstractvectortype$ { static final $Type$Species VSPECIES = ($Type$Species) $Type$Vector.SPECIES_$BITS$; @@ -54,6 +57,8 @@ final class $vectortype$ extends $abstractvectortype$ { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class<$Carriertype$> CTYPE = $carriertype$.class; // carrier type used by the JVM + static final Class<$Boxtype$> ETYPE = $type$.class; // used by the JVM $vectortype$($type$[] v) { @@ -92,6 +97,9 @@ final class $vectortype$ extends $abstractvectortype$ { @Override public final Class<$Boxtype$> elementType() { return $type$.class; } + @ForceInline + final Class<$Carriertype$> carrierType() { return CTYPE; } + @ForceInline @Override public final int elementSize() { return $Boxtype$.SIZE; } @@ -183,8 +191,8 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline final @Override - Byte$bits$Vector asByteVectorRaw() { - return (Byte$bits$Vector) super.asByteVectorRawTemplate(); // specialize + ByteVector$bits$ asByteVectorRaw() { + return (ByteVector$bits$) super.asByteVectorRawTemplate(); // specialize } @ForceInline @@ -382,7 +390,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public final $shuffletype$ toShuffle() { - return ($shuffletype$) toShuffle(vspecies(), false); + return ($shuffletype$) toShuffle(VSPECIES, false); } // Specialized unary testing @@ -850,10 +858,11 @@ final class $vectortype$ extends $abstractvectortype$ { #end[FP] // Mask - + @ValueBased static final class $masktype$ extends AbstractMask<$Boxtype$> { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class<$Boxtype$> ETYPE = $type$.class; // used by the JVM + + static final Class<$Carriertype$> CTYPE = $carriertype$.class; // used by the JVM $masktype$(boolean[] bits) { this(bits, 0); @@ -897,7 +906,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override $masktype$ uOp(MUnOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, bits[i]); @@ -907,7 +916,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override $masktype$ bOp(VectorMask<$Boxtype$> m, MBinOp f) { - boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] res = new boolean[VSPECIES.laneCount()]; boolean[] bits = getBits(); boolean[] mbits = (($masktype$)m).getBits(); for (int i = 0; i < res.length; i++) { @@ -1057,16 +1066,16 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public boolean anyTrue() { return VectorSupport.test(BT_ne, $masktype$.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper((($masktype$)m).getBits())); + this, VSPECIES.maskAll(true), + (m, _) -> anyTrueHelper((($masktype$)m).getBits())); } @Override @ForceInline public boolean allTrue() { return VectorSupport.test(BT_overflow, $masktype$.class, LANEBITS_TYPE_ORDINAL, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper((($masktype$)m).getBits())); + this, VSPECIES.maskAll(true), + (m, _) -> allTrueHelper((($masktype$)m).getBits())); } @ForceInline @@ -1074,7 +1083,7 @@ final class $vectortype$ extends $abstractvectortype$ { static $masktype$ maskAll(boolean bit) { return VectorSupport.fromBitsCoerced($masktype$.class, LANEBITS_TYPE_ORDINAL, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, - (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + (v, _) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } private static final $masktype$ TRUE_MASK = new $masktype$(true); private static final $masktype$ FALSE_MASK = new $masktype$(false); @@ -1092,15 +1101,16 @@ final class $vectortype$ extends $abstractvectortype$ { #end[intAndMax] #if[intAndMax] - static final IntMaxMask LOWER_HALF_TRUE_MASK = new IntMaxMask(maskLowerHalf()); + static final IntMaskMax LOWER_HALF_TRUE_MASK = new IntMaskMax(maskLowerHalf()); #end[intAndMax] } // Shuffle - + @ValueBased static final class $shuffletype$ extends AbstractShuffle<$Boxtype$> { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class<$Boxbitstype$> ETYPE = $bitstype$.class; // used by the JVM + + static final Class<$Boxbitstype$> CTYPE = $bitstype$.class; // used by the JVM $shuffletype$($bitstype$[] indices) { super(indices); @@ -1138,7 +1148,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public $vectortype$ toVector() { - return ($vectortype$) toBitsVector().castShape(vspecies(), 0); + return ($vectortype$) toBitsVector().castShape(VSPECIES, 0); } #else[FP] @Override @@ -1156,7 +1166,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override $bitsvectortype$ toBitsVector0() { - return (($bitsvectortype$) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + return (($bitsvectortype$) VSPECIES.asIntegral().dummyVector()).vectorFactory(indices()); } @Override @@ -1292,7 +1302,7 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public final $masktype$ laneIsValid() { return ($masktype$) toBitsVector().compare(VectorOperators.GE, 0) - .cast(vspecies()); + .cast(VSPECIES); } @ForceInline @@ -1301,10 +1311,10 @@ final class $vectortype$ extends $abstractvectortype$ { $shuffletype$ concreteShuffle = ($shuffletype$) shuffle; #if[FP] return ($shuffletype$) toBitsVector().rearrange(concreteShuffle.cast($Bitstype$Vector.SPECIES_$BITS$)) - .toShuffle(vspecies(), false); + .toShuffle(VSPECIES, false); #else[FP] return ($shuffletype$) toBitsVector().rearrange(concreteShuffle) - .toShuffle(vspecies(), false); + .toShuffle(VSPECIES, false); #end[FP] } @@ -1318,7 +1328,7 @@ final class $vectortype$ extends $abstractvectortype$ { v = ($bitsvectortype$) v.blend(v.lanewise(VectorOperators.ADD, length()), v.compare(VectorOperators.LT, 0)); } - return ($shuffletype$) v.toShuffle(vspecies(), false); + return ($shuffletype$) v.toShuffle(VSPECIES, false); } private static $bitstype$[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh index a9f1648eaa7..a8a7ea83625 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh @@ -72,6 +72,8 @@ do fptype=$type Fptype=$Type Boxfptype=$Boxtype + carriertype=$type + Carriertype=$Type case $type in byte) @@ -90,6 +92,7 @@ do ;; int) Boxtype=Integer + Carriertype=Integer Wideboxtype=Integer Boxbitstype=Integer fptype=float @@ -135,9 +138,10 @@ do args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" args="$args -DsizeInBytes=$sizeInBytes" + args="$args -Dcarriertype=$carriertype -DCarriertype=$Carriertype" abstractvectortype=${typeprefix}${Type}Vector - abstractbitsvectortype=${typeprefix}${Bitstype}Vector + abstractbitsvectortype=${typeprefix}Vector${Bitstype} abstractfpvectortype=${typeprefix}${Fptype}Vector args="$args -Dabstractvectortype=$abstractvectortype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" case $abstractvectortype in @@ -158,11 +162,11 @@ do old_args="$args" for bits in 64 128 256 512 Max do - vectortype=${typeprefix}${Type}${bits}Vector - masktype=${typeprefix}${Type}${bits}Mask - shuffletype=${typeprefix}${Type}${bits}Shuffle - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector + vectortype=${typeprefix}${Type}Vector${bits} + masktype=${typeprefix}${Type}Mask${bits} + shuffletype=${typeprefix}${Type}Shuffle${bits} + bitsvectortype=${typeprefix}${Bitstype}Vector${bits} + fpvectortype=${typeprefix}${Fptype}Vector${bits} vectorindexbits=$((bits * 4 / sizeInBytes)) numLanes=$((bits / (sizeInBytes * 8))) @@ -185,7 +189,7 @@ do if [[ "${bits}" == "Max" ]]; then vectorindextype="vix.getClass()" else - vectorindextype="Int${vectorindexbits}Vector.class" + vectorindextype="IntVector${vectorindexbits}.class" fi; BITS=$bits @@ -199,7 +203,7 @@ do Shape=S_${bits}_BIT args="$old_args" args="$args -K$lanes -K$bits" - if [[ "${vectortype}" == "IntMaxVector" ]]; then + if [[ "${vectortype}" == "IntVectorMax" ]]; then args="$args -KintAndMax" fi bitargs="$args -Dbits=$bits -DBITS=$BITS -Dvectortype=$vectortype -Dmasktype=$masktype -Dshuffletype=$shuffletype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dvectorindextype=$vectorindextype -Dshape=$shape -DShape=$Shape" diff --git a/src/jdk.jartool/share/man/jar.md b/src/jdk.jartool/share/man/jar.md index d944afcfb7f..658fa0cb4fa 100644 --- a/src/jdk.jartool/share/man/jar.md +++ b/src/jdk.jartool/share/man/jar.md @@ -1,5 +1,5 @@ --- -# Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2026, 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 @@ -84,29 +84,29 @@ appropriate operation arguments described in this section. You can mix an operation argument with other one-letter options. Generally the operation argument is the first argument specified on the command line. -`-c` or `--create` +[`-c`]{#option--create} or `--create` : Creates the archive. -`-i` *FILE* or `--generate-index=`*FILE* +[`-i`]{#option--generate-index} *FILE* or `--generate-index=`*FILE* : Generates index information for the specified JAR file. This option is deprecated and may be removed in a future release. -`-t` or `--list` +[`-t`]{#option--list} or `--list` : Lists the table of contents for the archive. -`-u` or `--update` +[`-u`]{#option--update} or `--update` : Updates an existing JAR file. -`-x` or `--extract` +[`-x`]{#option--extract} or `--extract` : Extracts the named (or all) files from the archive. If a file with the same name appears more than once in the archive, each copy will be extracted, with later copies overwriting (replacing) earlier copies unless -k is specified. -`-d` or `--describe-module` +[`-d`]{#option--describe-module} or `--describe-module` : Prints the module descriptor or automatic module name. -`--validate` +[`--validate`]{#option--validate} : Validate the contents of the JAR file. See `Integrity of a JAR File` section below for more details. @@ -115,7 +115,7 @@ argument is the first argument specified on the command line. You can use the following options to customize the actions of any operation mode included in the `jar` command. -`-C` *DIR* +[`-C`]{#option-C} *DIR* : When used with the create operation mode, changes the specified directory and includes the *files* specified at the end of the command line. @@ -126,10 +126,10 @@ mode included in the `jar` command. where the JAR file will be extracted. Unlike with the create operation mode, this option can be specified only once with the extract operation mode. -`-f` *FILE* or `--file=`*FILE* +[`-f`]{#option--file} *FILE* or `--file=`*FILE* : Specifies the archive file name. -`--release` *VERSION* +[`--release`]{#option--release} *VERSION* : Creates a multirelease JAR file. Places all files specified after the option into a versioned directory of the JAR file named `META-INF/versions/`*VERSION*`/`, where *VERSION* must be must be a @@ -149,26 +149,26 @@ mode included in the `jar` command. You can use the following options to customize the actions of the create and the update main operation modes: -`-e` *CLASSNAME* or `--main-class=`*CLASSNAME* +[`-e`]{#option--main-class} *CLASSNAME* or `--main-class=`*CLASSNAME* : Specifies the application entry point for standalone applications bundled into a modular or executable modular JAR file. -`-m` *FILE* or `--manifest=`*FILE* +[`-m`]{#option--manifest} *FILE* or `--manifest=`*FILE* : Includes the manifest information from the given manifest file. -`-M` or `--no-manifest` +[`-M`]{#option--no-manifest} or `--no-manifest` : Doesn't create a manifest file for the entries. -`--module-version=`*VERSION* +[`--module-version=`]{#option--module-version}*VERSION* : Specifies the module version, when creating or updating a modular JAR file, or updating a non-modular JAR file. -`--hash-modules=`*PATTERN* +[`--hash-modules=`]{#option--hash-modules}*PATTERN* : Computes and records the hashes of modules matched by the given pattern and that depend upon directly or indirectly on a modular JAR file being created or a non-modular JAR file being updated. -`-p` or `--module-path` +[`-p`]{#option--module-path} or `--module-path` : Specifies the location of module dependence for generating the hash. `@`*file* @@ -181,20 +181,20 @@ You can use the following options to customize the actions of the create (`-c` or `--create`) the update (`-u` or `--update` ) and the generate-index (`-i` or `--generate-index=`*FILE*) main operation modes: -`-0` or `--no-compress` +[`-0`]{#option--no-compress} or `--no-compress` : Stores without using ZIP compression. -`--date=`*TIMESTAMP* +[`--date=`]{#option--date}*TIMESTAMP* : The timestamp in ISO-8601 extended offset date-time with optional time-zone format, to use for the timestamp of the entries, e.g. "2022-02-12T12:30:00-05:00". ## Operation Modifiers Valid Only in Extract Mode -`--dir` *DIR* +[`--dir`]{#option--dir} *DIR* : Directory into which the JAR file will be extracted. -`-k` or `--keep-old-files` +[`-k`]{#option--keep-old-files} or `--keep-old-files` : Do not overwrite existing files. If a Jar file entry with the same name exists in the target directory, the existing file will not be overwritten. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ExternalSpecsWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ExternalSpecsWriter.java index 0115de5558f..b8767dd9913 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ExternalSpecsWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ExternalSpecsWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -57,7 +57,11 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.IndexItem; import jdk.javadoc.internal.html.Content; import jdk.javadoc.internal.html.ContentBuilder; +import jdk.javadoc.internal.html.HtmlAttr; +import jdk.javadoc.internal.html.HtmlId; +import jdk.javadoc.internal.html.HtmlTag; import jdk.javadoc.internal.html.HtmlTree; +import jdk.javadoc.internal.html.Script; import jdk.javadoc.internal.html.Text; import static java.util.stream.Collectors.groupingBy; @@ -108,6 +112,24 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, contents.getContent("doclet.External_Specifications")))) .addMainContent(mainContent) + .addMainContent(new Script(""" + let select = document.getElementById('specs-by-domain'); + select.addEventListener("change", selectHost); + addEventListener("pageshow", selectHost); + function selectHost() { + const selectedClass = select.value ? "external-specs-tab" + select.value : "external-specs"; + let tabPanel = document.getElementById("external-specs.tabpanel"); + let count = 0; + tabPanel.querySelectorAll("div.external-specs").forEach(function(elem) { + elem.style.display = elem.classList.contains(selectedClass) ? "" : "none"; + if (elem.style.display === "") { + let isEvenRow = count++ % 4 < 2; + toggleStyle(elem.classList, isEvenRow, evenRowColor, oddRowColor); + } + }); + } + selectHost(); + """).asContent()) .setFooter(getFooter())); printHtmlDocument(null, "external specifications", body); @@ -180,7 +202,7 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { boolean noHost = false; for (var searchIndexItems : searchIndexMap.values()) { try { - URI uri = getSpecURI(searchIndexItems.get(0)); + URI uri = getSpecURI(searchIndexItems.getFirst()); String host = uri.getHost(); if (host != null) { hostNamesSet.add(host); @@ -191,14 +213,19 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { // ignore } } - var hostNamesList = new ArrayList<>(hostNamesSet); var table = new Table(HtmlStyles.summaryTable) .setCaption(contents.externalSpecifications) .setHeader(new TableHeader(contents.specificationLabel, contents.referencedIn)) .setColumnStyles(HtmlStyles.colFirst, HtmlStyles.colLast) - .setId(HtmlIds.EXTERNAL_SPECS); + .setId(HtmlIds.EXTERNAL_SPECS) + .setDefaultTab(contents.externalSpecifications) + .setRenderTabs(false); + + var hostNamesList = new ArrayList<>(hostNamesSet); + Content selector = Text.EMPTY; if ((hostNamesList.size() + (noHost ? 1 : 0)) > 1) { + selector = createHostSelect(hostNamesList, noHost); for (var host : hostNamesList) { table.addTab(Text.of(host), u -> host.equals(u.getHost())); } @@ -207,10 +234,9 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { u -> u.getHost() == null); } } - table.setDefaultTab(Text.of(resources.getText("doclet.External_Specifications.All_Specifications"))); for (List searchIndexItems : searchIndexMap.values()) { - IndexItem ii = searchIndexItems.get(0); + IndexItem ii = searchIndexItems.getFirst(); Content specName = createSpecLink(ii); Content referencesList = HtmlTree.UL(HtmlStyles.refList, searchIndexItems, item -> HtmlTree.LI(createLink(item))); @@ -227,6 +253,7 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { table.addRow(specName, references); } } + content.add(selector); content.add(table); } @@ -235,6 +262,29 @@ public class ExternalSpecsWriter extends HtmlDocletWriter { .collect(groupingBy(IndexItem::getLabel, () -> new TreeMap<>(getTitleComparator()), toList())); } + private Content createHostSelect(List hosts, boolean hasLocal) { + var index = 1; + var id = HtmlId.of("specs-by-domain"); + var specsByHost = resources.getText("doclet.External_Specifications.by-host"); + var select = HtmlTree.of(HtmlTag.SELECT) + .setId(id) + .add(HtmlTree.of(HtmlTag.OPTION) + .put(HtmlAttr.VALUE, "") + .add(Text.of(resources.getText("doclet.External_Specifications.all-hosts")))); + + for (var host : hosts) { + select.add(HtmlTree.of(HtmlTag.OPTION) + .put(HtmlAttr.VALUE, Integer.toString(index++)) + .add(Text.of(host))); + } + if (hasLocal) { + select.add(HtmlTree.of(HtmlTag.OPTION) + .put(HtmlAttr.VALUE, Integer.toString(index)) + .add(Text.of("Local"))); + } + return new ContentBuilder(HtmlTree.LABEL(id.name(), Text.of(specsByHost)), Text.of(" "), select); + } + Comparator getTitleComparator() { Collator collator = Collator.getInstance(); return (s1, s2) -> { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties index 4366295477b..1aba5c9862b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2026, 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 @@ -180,7 +180,8 @@ doclet.Inheritance_Tree=Inheritance Tree doclet.DefinedIn=Defined In doclet.ReferencedIn=Referenced In doclet.External_Specifications=External Specifications -doclet.External_Specifications.All_Specifications=All Specifications +doclet.External_Specifications.by-host=Show specifications by host name: +doclet.External_Specifications.all-hosts=All host names doclet.External_Specifications.no-host=Local doclet.Specification=Specification doclet.Summary_Page=Summary Page diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css index 6198df5c2f3..5bd14f7cf33 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ @@ -1228,7 +1228,7 @@ input::placeholder { input:focus::placeholder { color: transparent; } -select#search-modules { +select { margin: 0 10px 10px 2px; font-size: var(--nav-font-size); padding: 3px 5px; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java index 30aa86aea71..3d300b77073 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -136,10 +136,7 @@ public class CommentHelper { return null; } DocTrees doctrees = configuration.docEnv.getDocTrees(); - // Workaround for JDK-8284193 - // DocTrees.getElement(DocTreePath) returns javac-internal Symbols - var e = doctrees.getElement(docTreePath); - return e == null || e.getKind() == ElementKind.CLASS && e.asType().getKind() != TypeKind.DECLARED ? null : e; + return doctrees.getElement(docTreePath); } public TypeMirror getType(ReferenceTree rtree) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java index b5399d0fef9..90b371a8a15 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -1006,11 +1006,11 @@ public class Checker extends DocTreePathScanner { public Void visitReference(ReferenceTree tree, Void ignore) { // Exclude same-file anchor links from reference checks if (!tree.getSignature().startsWith("##")) { - Element e = env.trees.getElement(getCurrentPath()); - if (e == null) { - reportBadReference(tree); - } else if ((inLink || inSee) - && e.getKind() == ElementKind.CLASS && e.asType().getKind() != TypeKind.DECLARED) { + if (inLink || inSee) { + if (env.trees.getElement(getCurrentPath()) == null) { + reportBadReference(tree); + } + } else if (env.trees.getType(getCurrentPath()) == null) { reportBadReference(tree); } } diff --git a/src/jdk.jcmd/share/man/jcmd.md b/src/jdk.jcmd/share/man/jcmd.md index af3886a915c..23dfa67d864 100644 --- a/src/jdk.jcmd/share/man/jcmd.md +++ b/src/jdk.jcmd/share/man/jcmd.md @@ -134,6 +134,16 @@ The following commands are available: - `-all`: (Optional) Show help for all commands (BOOLEAN, false) . +`AOT.end_recording` +: Ends an in-progress AOT training and records the results to the file(s) specified by `-XX:AOTConfiguration` and/or `-XX:AOTCacheOutput`. + + Impact: Low + + **Note:** + + The JVM must be started in AOT training mode using command-line arguments such as `-XX:AOTMode=record` or `-XX:AOTCacheOutput=`. + The results of the AOT training can be an AOT configuration file, an AOT cache file, or both. + `Compiler.CodeHeap_Analytics` \[*function*\] \[*granularity*\] : Print CodeHeap analytics diff --git a/src/jdk.jcmd/share/man/jmap.md b/src/jdk.jcmd/share/man/jmap.md index b0352ad9194..dd0be1b24ef 100644 --- a/src/jdk.jcmd/share/man/jmap.md +++ b/src/jdk.jcmd/share/man/jmap.md @@ -62,20 +62,20 @@ was produced. ## Options for the jmap Command -`-clstats` *pid* +[`-clstats`]{#option-clstats} *pid* : Connects to a running process and prints class loader statistics of Java heap. -`-finalizerinfo` *pid* +[`-finalizerinfo`]{#option-finalizerinfo} *pid* : Connects to a running process and prints information on objects awaiting finalization. -`-histo`\[`:live`\] *pid* +[`-histo`]{#option-histo}\[`:live`\] *pid* : Connects to a running process and prints a histogram of the Java object heap. If the `live` suboption is specified, it then counts only live objects. -`-dump:`*dump\_options* *pid* +[`-dump:`]{#option-dump_}*dump\_options* *pid* : Connects to a running process and dumps the Java heap. The *dump\_options* include: diff --git a/src/jdk.jcmd/share/man/jstat.md b/src/jdk.jcmd/share/man/jstat.md index 324d0a48cb2..624b675de76 100644 --- a/src/jdk.jcmd/share/man/jstat.md +++ b/src/jdk.jcmd/share/man/jstat.md @@ -125,7 +125,7 @@ Don't write scripts to parse the `jstat` command's output because the format might change in future releases. If you write scripts that parse the `jstat` command output, then expect to modify them for future releases of this tool. -`-statOption` +[`-statOption`]{#option-statOption} : Determines the statistics information that the `jstat` command displays. The following lists the available options. Use the `-options` general option to display the list of options for a particular platform @@ -161,7 +161,7 @@ command output, then expect to modify them for future releases of this tool. `printcompilation`: Displays Java HotSpot VM compilation method statistics. -`-J`*javaOption* +[`-J`]{#option-J}*javaOption* : Passes *javaOption* to the Java application launcher. For example, `-J-Xms48m` sets the startup memory to 48 MB. For a complete list of options, see [java](java.html). @@ -171,7 +171,7 @@ command output, then expect to modify them for future releases of this tool. The following information summarizes the columns that the `jstat` command outputs for each *statOption*. -`-class` *option* +[`-class`]{#option-class} *option* : Class loader statistics. `Loaded`: Number of classes loaded. @@ -184,7 +184,7 @@ outputs for each *statOption*. `Time`: Time spent performing class loading and unloading operations. -`-compiler` *option* +[`-compiler`]{#option-compiler} *option* : Java HotSpot VM Just-in-Time compiler statistics. `Compiled`: Number of compilation tasks performed. @@ -199,7 +199,7 @@ outputs for each *statOption*. `FailedMethod`: Class name and method of the last failed compilation. -`-gc` *option* +[`-gc`]{#option-gc} *option* : Garbage collected heap statistics. `S0C`: Current survivor space 0 capacity (KB). @@ -236,7 +236,7 @@ outputs for each *statOption*. `GCT`: Total garbage collection time. -`-gccapacity` *option* +[`-gccapacity`]{#option-gccapacity} *option* : Memory pool generation and space capacities. `NGCMN`: Minimum new generation capacity (KB). @@ -275,7 +275,7 @@ outputs for each *statOption*. `FGC`: Number of full GC events. -`-gccause` *option* +[`-gccause`]{#option-gccause} *option* : This option displays the same summary of garbage collection statistics as the `-gcutil` option, but includes the causes of the last garbage collection event and (when applicable), the current garbage collection @@ -286,7 +286,7 @@ outputs for each *statOption*. `GCC`: Cause of current garbage collection -`-gcnew` *option* +[`-gcnew`]{#option-gcnew} *option* : New generation statistics. `S0C`: Current survivor space 0 capacity (KB). @@ -311,7 +311,7 @@ outputs for each *statOption*. `YGCT`: Young generation garbage collection time. -`-gcnewcapacity` *option* +[`-gcnewcapacity`]{#option-gcnewcapacity} *option* : New generation space size statistics. `NGCMN`: Minimum new generation capacity (KB). @@ -336,7 +336,7 @@ outputs for each *statOption*. `FGC`: Number of full GC events. -`-gcold` *option* +[`-gcold`]{#option-gcold} *option* : Old generation size statistics. `MC`: Metaspace Committed Size (KB). @@ -359,7 +359,7 @@ outputs for each *statOption*. `GCT`: Total garbage collection time. -`-gcoldcapacity` *option* +[`-gcoldcapacity`]{#option-gcoldcapacity} *option* : Old generation statistics. `OGCMN`: Minimum old generation capacity (KB). @@ -378,7 +378,7 @@ outputs for each *statOption*. `GCT`: Total garbage collection time. -`-gcmetacapacity` *option* +[`-gcmetacapacity`]{#option-gcmetacapacity} *option* : Metaspace size statistics. `MCMN`: Minimum metaspace capacity (KB). @@ -399,7 +399,7 @@ outputs for each *statOption*. `GCT`: Total garbage collection time. -`-gcutil` *option* +[`-gcutil`]{#option-gcutil} *option* : Summary of garbage collection statistics. `S0`: Survivor space 0 utilization as a percentage of the space's current @@ -427,7 +427,7 @@ outputs for each *statOption*. `GCT`: Total garbage collection time. -`-printcompilation` *option* +[`-printcompilation`]{#option-printcompilation} *option* : Java HotSpot VM compiler method statistics. `Compiled`: Number of compilation tasks performed by the most recently diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/LValue.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/LValue.java index 3855d1bd51c..43b2c420147 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/LValue.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/LValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -73,11 +73,11 @@ abstract class LValue { setValue0(value); } catch (InvalidTypeException exc) { throw new ParseException( - "Attempt to set value of incorrect type" + + "Attempt to set value of incorrect type: " + exc); } catch (ClassNotLoadedException exc) { throw new ParseException( - "Attempt to set value before " + exc.className() + " was loaded" + + "Attempt to set value before " + exc.className() + " was loaded: " + exc); } } diff --git a/src/jdk.jdi/share/man/jdb.md b/src/jdk.jdi/share/man/jdb.md index 75d2d9a150c..8aabb202c80 100644 --- a/src/jdk.jdi/share/man/jdb.md +++ b/src/jdk.jdi/share/man/jdb.md @@ -145,50 +145,50 @@ The following options are accepted by the `jdb` command: `-help` : Displays a help message. -`-sourcepath` *dir1*`:`*dir2*`:`... +[`-sourcepath`]{#option-sourcepath} *dir1*`:`*dir2*`:`... : Uses the specified path to search for source files in the specified path. If this option is not specified, then use the default path of dot (`.`). -`-attach` *address* +[`-attach`]{#option-attach} *address* : Attaches the debugger to a running JVM with the default connection mechanism. -`-listen` *address* +[`-listen`]{#option-listen} *address* : Waits for a running JVM to connect to the specified address with a standard connector. -`-listenany` +[`-listenany`]{#option-listenany} : Waits for a running JVM to connect at any available address using a standard connector. -`-launch` +[`-launch`]{#option-launch} : Starts the debugged application immediately upon startup of the `jdb` command. The `-launch` option removes the need for the `run` command. The debugged application is launched and then stopped just before the initial application class is loaded. At that point, you can set any necessary breakpoints and use the `cont` command to continue execution. -`-listconnectors` +[`-listconnectors`]{#option-listconnectors} : Lists the connectors available in this JVM. -`-connect` *connector-name*`:`*name1*`=`*value1*.... +[`-connect`]{#option-connect} *connector-name*`:`*name1*`=`*value1*.... : Connects to the target JVM with the named connector and listed argument values. -`-dbgtrace` \[*flags*\] +[`-dbgtrace`]{#option-dbgtrace} \[*flags*\] : Prints information for debugging the `jdb` command. -`-tclient` +[`-tclient`]{#option-tclient} : Runs the application in the Java HotSpot VM client. -`-trackallthreads` +[`-trackallthreads`]{#option-trackallthreads} : Track all threads as they are created, including virtual threads. See [Working With Virtual Threads](#working-with-virtual-threads) below. -`-tserver` +[`-tserver`]{#option-tserver} : Runs the application in the Java HotSpot VM server. -`-J`*option* +[`-J`]{#option-J}*option* : Passes *option* to the JDB JVM, where option is one of the options described on the reference page for the Java application launcher. For example, `-J-Xms48m` sets the startup memory to 48 MB. See *Overview of Java diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.c b/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.c index cf330d74d29..d4f4003a43d 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -171,18 +171,16 @@ initState(JNIEnv *env, jthread thread, StepRequest *step) * Initial values that may be changed below */ step->fromLine = -1; - step->fromNative = JNI_FALSE; + step->notifyFramePopFailed = JNI_FALSE; step->frameExited = JNI_FALSE; step->fromStackDepth = getFrameCount(thread); if (step->fromStackDepth <= 0) { /* - * If there are no stack frames, treat the step as though - * from a native frame. This is most likely to occur at the - * beginning of a debug session, right after the VM_INIT event, - * so we need to do something intelligent. + * If there are no stack frames, there is nothing more to do here. If we are + * doing a step INTO, initEvents() will enable stepping. Otherwise it is + * not enabled because there is nothing to step OVER or OUT of. */ - step->fromNative = JNI_TRUE; return JVMTI_ERROR_NONE; } @@ -196,7 +194,13 @@ initState(JNIEnv *env, jthread thread, StepRequest *step) error = JVMTI_FUNC_PTR(gdata->jvmti,NotifyFramePop) (gdata->jvmti, thread, 0); if (error == JVMTI_ERROR_OPAQUE_FRAME) { - step->fromNative = JNI_TRUE; + // OPAQUE_FRAME doesn't always mean native method. It's rare that it doesn't, and + // means that there is something about the frame's state that prevents setting up + // a NotifyFramePop. One example is a frame that is in the process of returning, + // which can happen if we start single stepping after getting a MethodExit event. + // In either any case, we need to be aware that there will be no FramePop event + // when this frame exits. + step->notifyFramePopFailed = JNI_TRUE; error = JVMTI_ERROR_NONE; /* continue without error */ } else if (error == JVMTI_ERROR_DUPLICATE) { @@ -761,31 +765,28 @@ initEvents(jthread thread, StepRequest *step) } } + /* - * Initially enable stepping: - * 1) For step into, always - * 2) For step over, unless right after the VM_INIT. - * Enable stepping for STEP_MIN or STEP_LINE with or without line numbers. - * If the class is redefined then non EMCP methods may not have line - * number info. So enable line stepping for non line number so that it - * behaves like STEP_MIN/STEP_OVER. - * 3) For step out, only if stepping from native, except right after VM_INIT - * - * (right after VM_INIT, a step->over or out is identical to running - * forever) + * Enable step events if necessary. Note that right after VM_INIT, a + * step OVER or OUT is identical to running forever, so we only enable + * step events if fromStackDepth > 0. */ switch (step->depth) { case JDWP_STEP_DEPTH(INTO): enableStepping(thread); break; case JDWP_STEP_DEPTH(OVER): - if (step->fromStackDepth > 0 && !step->fromNative ) { + // We need to always enable for OVER (except right after VM_INIT). + // If we are in a native method, that is the only way to find out + // that we have returned to a java method. + if (step->fromStackDepth > 0) { enableStepping(thread); } break; case JDWP_STEP_DEPTH(OUT): - if (step->fromNative && - (step->fromStackDepth > 0)) { + // We rely on the FramePop event to tell us when we exit the current frame. + // If NotifyFramePop failed, then we need to enable stepping. + if (step->notifyFramePopFailed && (step->fromStackDepth > 0)) { enableStepping(thread); } break; diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.h b/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.h index 63f97fb6231..566b8b00ea0 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.h +++ b/src/jdk.jdwp.agent/share/native/libjdwp/stepControl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ typedef struct { /* State */ jboolean pending; jboolean frameExited; /* for depth == STEP_OVER or STEP_OUT */ - jboolean fromNative; + jboolean notifyFramePopFailed; jint fromStackDepth; /* for all but STEP_INTO STEP_INSTRUCTION */ jint fromLine; /* for granularity == STEP_LINE */ jmethodID method; /* Where line table came from. */ diff --git a/src/jdk.jfr/share/classes/jdk/jfr/EventSettings.java b/src/jdk.jfr/share/classes/jdk/jfr/EventSettings.java index 6ed20f124d9..c9f24d9f903 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/EventSettings.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/EventSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -150,6 +150,11 @@ public abstract class EventSettings { return FlightRecorder.getFlightRecorder().getInternal(); } + @Override + public Recording newRecording(RecordingState state) { + return new Recording(state, Map.of()); + } + @Override public EventSettings newEventSettings(EventSettingsModifier esm) { return new EventSettings.DelegatedEventSettings(esm); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java index 089a5ed37d8..8a3181307d2 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +import jdk.jfr.RecordingState; import jdk.jfr.internal.PlatformRecorder; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.Type; @@ -100,11 +101,16 @@ public final class Recording implements Closeable { * @since 11 */ public Recording(Map settings) { + this(RecordingState.NEW, settings); + } + + // package private + Recording(RecordingState state, Map settings) { Objects.requireNonNull(settings, "settings"); Map sanitized = Utils.sanitizeNullFreeStringMap(settings); PlatformRecorder r = FlightRecorder.getFlightRecorder().getInternal(); synchronized (r) { - this.internal = r.newRecording(sanitized); + this.internal = r.newRecording(state, sanitized); this.internal.setRecording(this); if (internal.getRecording() != this) { throw new InternalError("Internal recording not properly setup"); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index cf46c05b804..260f2fed54d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,8 +82,8 @@ public final class PlatformRecorder { Runtime.getRuntime().addShutdownHook(shutdownHook); } - public synchronized PlatformRecording newRecording(Map settings) { - return newRecording(settings, ++recordingCounter); + public synchronized PlatformRecording newRecording(RecordingState state, Map settings) { + return newRecording(state, settings, ++recordingCounter); } // To be used internally when doing dumps. @@ -92,15 +92,17 @@ public final class PlatformRecorder { if(!Thread.holdsLock(this)) { throw new InternalError("Caller must have recorder lock"); } - return newRecording(new HashMap<>(), 0); + return newRecording(RecordingState.NEW, new HashMap<>(), 0); } - private synchronized PlatformRecording newRecording(Map settings, long id) { + private synchronized PlatformRecording newRecording(RecordingState state, Map settings, long id) { PlatformRecording recording = new PlatformRecording(this, id); if (!settings.isEmpty()) { recording.setSettings(settings); } - recordings.add(recording); + if (state != RecordingState.CLOSED) { + recordings.add(recording); + } return recording; } @@ -545,8 +547,10 @@ public final class PlatformRecorder { } synchronized Recording newCopy(PlatformRecording r, boolean stop) { - Recording newRec = new Recording(); - PlatformRecording copy = PrivateAccess.getInstance().getPlatformRecording(newRec); + PrivateAccess pr = PrivateAccess.getInstance(); + boolean closed = r.getState() == RecordingState.CLOSED; + Recording newRec = closed ? pr.newRecording(RecordingState.CLOSED) : new Recording(); + PlatformRecording copy = pr.getPlatformRecording(newRec); copy.setSettings(r.getSettings()); copy.setMaxAge(r.getMaxAge()); copy.setMaxSize(r.getMaxSize()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java index fe5d5aea327..2297bf7bdde 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PrivateAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jdk.jfr.Configuration; import jdk.jfr.EventSettings; import jdk.jfr.EventType; import jdk.jfr.Recording; +import jdk.jfr.RecordingState; import jdk.jfr.SettingDescriptor; import jdk.jfr.ValueDescriptor; import jdk.jfr.internal.management.EventSettingsModifier; @@ -96,6 +97,8 @@ public abstract class PrivateAccess { public abstract PlatformRecorder getPlatformRecorder(); + public abstract Recording newRecording(RecordingState state); + public abstract EventSettings newEventSettings(EventSettingsModifier esm); public abstract boolean isVisible(EventType t); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Field.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Field.java index b7fc4381670..f9c2ab351bf 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Field.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Field.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -118,6 +118,9 @@ final class Field { // An integral type (byte, short, int, long) boolean integralType; + // An integral type that should be treated like a symbol, e.g. PID. + boolean identifier; + // A java.time.Duration boolean timespan; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java index 64791b1976a..8d0b3371c7d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -274,6 +274,7 @@ final class FieldBuilder { case "int", "long", "short", "byte": field.integralType = true; field.alignLeft = false; + field.identifier = fieldName.equals("id") || fieldName.endsWith("Id") || field.label.endsWith("Identifier"); break; case "float", "double": field.fractionalType = true; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldFormatter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldFormatter.java index 989e2231eb1..ec032ce9f34 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldFormatter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -165,7 +165,7 @@ public class FieldFormatter { return object + " Hz"; } } - if (object instanceof Number number) { + if (object instanceof Number number && !field.identifier) { return ValueFormatter.formatNumber(number); } return object.toString(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/TimedMethod.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/TimedMethod.java index bd4f2262444..2651f5b473a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/TimedMethod.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tracing/TimedMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -46,10 +46,10 @@ record TimedMethod(AtomicLong invocations, AtomicLong time, AtomicLong minimum, while (true) { long max = maximum.get(); if (duration <= max) { - return; + break; } if (maximum.weakCompareAndSetVolatile(max, duration)) { - return; + break; } } } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java index df2aca02d68..3f324ba1364 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java @@ -435,7 +435,10 @@ class JImageTask { } } } catch (IOException ioe) { - throw TASK_HELPER.newBadArgs("err.invalid.jimage", file, ioe.getMessage()); + boolean isVersionMismatch = ioe instanceof BasicImageReader.ImageVersionMismatchException; + // Both messages take the file name and underlying message. + String msgKey = isVersionMismatch ? "err.wrong.version" : "err.invalid.jimage"; + throw TASK_HELPER.newBadArgs(msgKey, file, ioe.getMessage()); } } } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties index ac13505a0d9..3038dfcc5ec 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties @@ -89,15 +89,20 @@ main.opt.footer=\ \ glob:\n\ \ regex: - - err.not.a.task=task must be one of : {0} err.missing.arg=no value given for {0} err.ambiguous.arg=value for option {0} starts with \"--\" should use {0}= format err.not.a.dir=not a directory: {0} err.not.a.jimage=not a jimage file: {0} -err.invalid.jimage=Unable to open {0}: {1} err.no.jimage=no jimage provided err.option.unsupported={0} not supported: {1} err.unknown.option=unknown option: {0} err.cannot.create.dir=cannot create directory {0} + +# General failure to open a jimage file. +# {0} = path of jimage file, {1} = underlying error message +err.invalid.jimage=Unable to open {0}: {1} +# More specific alternative for cases of version mismatch +err.wrong.version=Unable to open {0}: mismatched file and tool version\n\ +Use ''/bin/jimage'' for the JDK associated with the jimage file:\n\ +{1} diff --git a/src/jdk.jlink/share/man/jlink.md b/src/jdk.jlink/share/man/jlink.md index 5c77202434c..b95424fdde9 100644 --- a/src/jdk.jlink/share/man/jlink.md +++ b/src/jdk.jlink/share/man/jlink.md @@ -57,14 +57,14 @@ Developers are responsible for updating their custom runtime images. ## jlink Options -`--add-modules` *mod*\[`,`*mod*...\] +[`--add-modules`]{#option--add-modules} *mod*\[`,`*mod*...\] : Adds the named modules, *mod*, to the default set of root modules. The default set of root modules is empty. -`--bind-services` +[`--bind-services`]{#option--bind-services} : Link service provider modules and their dependencies. -`-c zip-{0-9}` or `--compress=zip-{0-9}` +[`-c zip-{0-9}`]{#option--compress} or `--compress=zip-{0-9}` : Enable compression of resources. The accepted values are: zip-{0-9}, where zip-0 provides no compression, and zip-9 provides the best compression. Default is zip-6. @@ -75,37 +75,37 @@ Developers are responsible for updating their custom runtime images. - `1`: Constant string sharing - `2`: ZIP. Use zip-6 instead. -`--disable-plugin` *pluginname* +[`--disable-plugin`]{#option--disable-plugin} *pluginname* : Disables the specified plug-in. See [jlink Plug-ins] for the list of supported plug-ins. -`--endian` {`little`\|`big`} +[`--endian`]{#option--endian} {`little`\|`big`} : Specifies the byte order of the generated image. The default value is the format of your system's architecture. `-h` or `--help` : Prints the help message. -`--ignore-signing-information` +[`--ignore-signing-information`]{#option--ignore-signing-information} : Suppresses a fatal error when signed modular JARs are linked in the runtime image. The signature-related files of the signed modular JARs aren't copied to the runtime image. -`--launcher` *command*`=`*module* or `--launcher` *command*`=`*module*`/`*main* +[`--launcher`]{#option--launcher} *command*`=`*module* or `--launcher` *command*`=`*module*`/`*main* : Specifies the launcher command name for the module or the command name for the module and main class (the module and the main class names are separated by a slash (`/`)). -`--limit-modules` *mod*\[`,`*mod*...\] +[`--limit-modules`]{#option--limit-modules} *mod*\[`,`*mod*...\] : Limits the universe of observable modules to those in the transitive closure of the named modules, `mod`, plus the main module, if any, plus any further modules specified in the `--add-modules` option. -`--list-plugins` +[`--list-plugins`]{#option--list-plugins} : Lists available plug-ins, which you can access through command-line options; see [jlink Plug-ins]. -`-p` or `--module-path` *modulepath* +[`-p`]{#option-module-path} or `--module-path` *modulepath* : Specifies the module path. If this option is not specified, then the default module path is @@ -114,19 +114,19 @@ Developers are responsible for updating their custom runtime images. `java.base` module cannot be resolved from it, then the `jlink` command appends `$JAVA_HOME/jmods` to the module path. -`--no-header-files` +[`--no-header-files`]{#option--no-header-files} : Excludes header files. -`--no-man-pages` +[`--no-man-pages`]{#option--no-man-pages} : Excludes man pages. -`--output` *path* +[`--output`]{#option--output} *path* : Specifies the location of the generated runtime image. -`--save-opts` *filename* +[`--save-opts`]{#option--save-opts} *filename* : Saves `jlink` options in the specified file. -`--suggest-providers` \[*name*`,` ...\] +[`--suggest-providers`]{#option--suggest-providers} \[*name*`,` ...\] : Suggest providers that implement the given service types from the module path. diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LibProvidersLookup.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LibProvidersLookup.java index 6faacbca528..2dccc91cf8f 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LibProvidersLookup.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LibProvidersLookup.java @@ -44,7 +44,7 @@ import java.util.stream.Stream; */ public final class LibProvidersLookup { static boolean supported() { - return (new ToolValidator(TOOL_LDD).validate() == null); + return (new ToolValidator(TOOL_LDD).setCommandLine("--version").validate() == null); } LibProvidersLookup setPackageLookup(PackageLookup v) { diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java index d2169ede461..724aeabb4b3 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java @@ -30,8 +30,10 @@ import static jdk.jpackage.internal.LinuxPackagingPipeline.APPLICATION_LAYOUT; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_APP_IMAGE; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_DEB; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_RPM; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Stream; @@ -40,6 +42,7 @@ import jdk.jpackage.internal.cli.StandardBundlingOperation; import jdk.jpackage.internal.model.BundlingOperationDescriptor; import jdk.jpackage.internal.model.LinuxPackage; import jdk.jpackage.internal.model.PackageType; +import jdk.jpackage.internal.model.StandardPackageType; import jdk.jpackage.internal.util.Result; public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { @@ -54,11 +57,15 @@ public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { }); Supplier> debSysEnv = () -> { - return LinuxDebSystemEnvironment.create(sysEnv.get()); + return LinuxDebSystemEnvironment.create(sysEnv.get().flatMap(v -> { + return adjustPackageArch(v, StandardPackageType.LINUX_DEB); + })); }; Supplier> rpmSysEnv = () -> { - return LinuxRpmSystemEnvironment.create(sysEnv.get()); + return LinuxRpmSystemEnvironment.create(sysEnv.get().flatMap(v -> { + return adjustPackageArch(v, StandardPackageType.LINUX_RPM); + })); }; builder.defaultOperation(() -> { @@ -106,6 +113,20 @@ public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { return new BuildEnvFromOptions().predefinedAppImageLayout(APPLICATION_LAYOUT); } + private static Result adjustPackageArch(LinuxSystemEnvironment sysEnv, StandardPackageType type) { + Objects.requireNonNull(sysEnv); + Objects.requireNonNull(type); + if (sysEnv.nativePackageType().equals(type)) { + return Result.of(() -> { + return sysEnv; + }); + } else { + return LinuxPackageArch.create(type).map(arch -> { + return new LinuxSystemEnvironment.Stub(sysEnv.soLookupAvailable(), sysEnv.nativePackageType(), arch); + }); + } + } + private static final Map DESCRIPTORS = Stream.of( CREATE_LINUX_DEB, CREATE_LINUX_RPM diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java index 7c1f06f54a3..d46ec8865c8 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java @@ -104,7 +104,7 @@ final class LinuxDebPackager extends LinuxPackager { List cmdline = new ArrayList<>(List.of( sysEnv.dpkgdeb().toString(), "-f", outputPackageFile().toString())); - properties.forEach(property -> cmdline.add(property.name)); + properties.forEach(property -> cmdline.add(property.name())); Map actualValues = Executor.of(cmdline) .saveOutput(true) @@ -116,7 +116,7 @@ final class LinuxDebPackager extends LinuxPackager { components -> components[1])); for (var property : properties) { - Optional.ofNullable(property.verifyValue(actualValues.get(property.name))).ifPresent(errors::add); + Optional.ofNullable(property.verifyValue(actualValues.get(property.name()))).ifPresent(errors::add); } return errors; diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebSystemEnvironmentMixin.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebSystemEnvironmentMixin.java index 2cf3e9e36e8..4c6fd75bed8 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebSystemEnvironmentMixin.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebSystemEnvironmentMixin.java @@ -40,6 +40,9 @@ interface LinuxDebSystemEnvironmentMixin { static Result create() { final var errors = Stream.of(Internal.TOOL_DPKG_DEB, Internal.TOOL_DPKG, Internal.TOOL_FAKEROOT) .map(ToolValidator::new) + .map(v -> { + return v.setCommandLine("--version"); + }) .map(ToolValidator::validate) .filter(Objects::nonNull) .toList(); diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromOptions.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromOptions.java index 0791c79c662..1f954036431 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromOptions.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromOptions.java @@ -27,6 +27,7 @@ package jdk.jpackage.internal; import static jdk.jpackage.internal.FromOptions.buildApplicationBuilder; import static jdk.jpackage.internal.FromOptions.createPackageBuilder; import static jdk.jpackage.internal.LinuxPackagingPipeline.APPLICATION_LAYOUT; +import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_RPM; import static jdk.jpackage.internal.cli.StandardOption.LINUX_APP_CATEGORY; import static jdk.jpackage.internal.cli.StandardOption.LINUX_DEB_MAINTAINER_EMAIL; import static jdk.jpackage.internal.cli.StandardOption.LINUX_MENU_GROUP; @@ -39,6 +40,7 @@ import static jdk.jpackage.internal.model.StandardPackageType.LINUX_DEB; import static jdk.jpackage.internal.model.StandardPackageType.LINUX_RPM; import jdk.jpackage.internal.cli.Options; +import jdk.jpackage.internal.model.DottedVersion; import jdk.jpackage.internal.model.Launcher; import jdk.jpackage.internal.model.LinuxApplication; import jdk.jpackage.internal.model.LinuxDebPackage; @@ -67,6 +69,10 @@ final class LinuxFromOptions { appBuilder.launchers().map(LinuxPackagingPipeline::normalizeShortcuts).ifPresent(appBuilder::launchers); + if (OptionUtils.bundlingOperation(options) == CREATE_LINUX_RPM) { + appBuilder.derivedVersionNormalizer(LinuxFromOptions::normalizeRpmVersion); + } + return LinuxApplication.create(appBuilder.create()); } @@ -118,4 +124,15 @@ final class LinuxFromOptions { return pkgBuilder; } + private static String normalizeRpmVersion(String version) { + // RPM does not support "-" symbol in version. In some case + // we might have "-" from "release" file version. + // Normalize version if it has "-" symbols. All other supported version + // formats by "release" file should be supported by RPM. + if (version.contains("-")) { + return DottedVersion.lazy(version).toComponentsString(); + } + + return version; + } } diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java index e22b9c24fdd..8c3e8125e9b 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java @@ -112,12 +112,12 @@ final class LinuxRpmPackager extends LinuxPackager { "APPLICATION_VERSION", specFileName), new PackageProperty("Release", pkg.release().orElseThrow(), "APPLICATION_RELEASE", specFileName), - new PackageProperty("Arch", pkg.arch(), null, specFileName)); + new PackageProperty("Arch", pkg.arch(), specFileName)); var actualValues = Executor.of( sysEnv.rpm().toString(), "-qp", - "--queryformat", properties.stream().map(e -> String.format("%%{%s}", e.name)).collect(joining("\\n")), + "--queryformat", properties.stream().map(e -> String.format("%%{%s}", e.name())).collect(joining("\\n")), outputPackageFile().toString() ).saveOutput(true).executeExpectSuccess().getOutput(); diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmSystemEnvironmentMixin.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmSystemEnvironmentMixin.java index 4cbd3ce4a9c..8de28b79430 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmSystemEnvironmentMixin.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmSystemEnvironmentMixin.java @@ -44,7 +44,9 @@ interface LinuxRpmSystemEnvironmentMixin { final var errors = Stream.of( Internal.createRpmbuildToolValidator(), new ToolValidator(Internal.TOOL_RPM) - ).map(ToolValidator::validate).filter(Objects::nonNull).toList(); + ).map(v -> { + return v.setCommandLine("--version"); + }).map(ToolValidator::validate).filter(Objects::nonNull).toList(); if (errors.isEmpty()) { return Result.ofValue(new Stub(Internal.TOOL_RPM, Internal.TOOL_RPMBUILD)); diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java index 6b06190f891..e19e45cb5d4 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,52 +25,61 @@ package jdk.jpackage.internal; -import java.text.MessageFormat; +import java.util.Objects; +import java.util.Optional; import jdk.jpackage.internal.model.ConfigException; -final class PackageProperty { - /** - * Constructor - * - * @param name property name - * @param expectedValue expected property value - * @param substString substitution string to be placed in resource file to - * be replaced with the expected property value by jpackage at package build - * time - * @param customResource name of custom resource from resource directory in - * which this package property can be set - */ - PackageProperty(String name, String expectedValue, String substString, - String customResource) { - this.name = name; - this.expectedValue = expectedValue; - this.substString = substString; - this.customResource = customResource; +/** + * Linux package property. + * + * @param name the property name (e.g.: "Architecture", "Version") + * @param expectedValue the expected value of the property + * @param subtrituteString the substitute string in the jpackage resource if + * applicable (e.g.: "APPLICATION_PACKAGE", + * "APPLICATION_VERSION") + * @param resourceName the name of the custom resource file from the + * resource directory in which this package property can + * be set + */ +record PackageProperty(String name, String expectedValue, Optional subtrituteString, String customResource) { + + PackageProperty { + Objects.requireNonNull(name); + Objects.requireNonNull(expectedValue); + Objects.requireNonNull(subtrituteString); + Objects.requireNonNull(customResource); + } + + PackageProperty(String name, String expectedValue, String subtrituteString, String resourceName) { + this(name, expectedValue, Optional.of(subtrituteString), resourceName); + } + + PackageProperty(String name, String expectedValue, String resourceName) { + this(name, expectedValue, Optional.empty(), resourceName); + } + + private String formatErrorMessage(String actualValue) { + Objects.requireNonNull(actualValue); + return I18N.format("error.unexpected-package-property", + name, expectedValue, actualValue, customResource); + } + + private String formatAdvice(String actualValue) { + Objects.requireNonNull(actualValue); + return subtrituteString.map(ss -> { + return I18N.format("error.unexpected-package-property.advice", ss, actualValue, name, customResource); + }).orElseGet(() -> { + return I18N.format("error.unexpected-default-package-property.advice", name, customResource); + }); } ConfigException verifyValue(String actualValue) { + Objects.requireNonNull(actualValue); + if (expectedValue.equals(actualValue)) { return null; } - final String advice; - if (substString != null) { - advice = MessageFormat.format(I18N.getString( - "error.unexpected-package-property.advice"), substString, - actualValue, name, customResource); - } else { - advice = MessageFormat.format(I18N.getString( - "error.unexpected-default-package-property.advice"), name, - customResource); - } - - return new ConfigException(MessageFormat.format(I18N.getString( - "error.unexpected-package-property"), name, - expectedValue, actualValue, customResource, substString), advice); + return new ConfigException(formatErrorMessage(actualValue), formatAdvice(actualValue)); } - - final String name; - private final String expectedValue; - private final String substString; - private final String customResource; } diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties index 3aa0e0e92a0..1ab45d26a4c 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties @@ -58,6 +58,6 @@ message.rpm-ldd-not-available.advice=Install "glibc-common" RPM package to get l warning.foreign-app-image=Warning: app-image dir not generated by jpackage. message.not-default-bundler-no-dependencies-lookup={0} is not the default package type. Package dependencies will not be generated. -error.unexpected-package-property=Expected value of "{0}" property is [{1}]. Actual value in output package is [{2}]. Looks like custom "{3}" file from resource directory contained hard coded value of "{0}" property +error.unexpected-package-property=Expected value of "{0}" property is [{1}]. Actual value in output package is [{2}]. Looks like the value of "{0}" property is hardcoded in "{3}" file in the resource directory error.unexpected-package-property.advice=Use [{0}] pattern string instead of hard coded value [{1}] of {2} property in custom "{3}" file -error.unexpected-default-package-property.advice=Don't explicitly set value of {0} property in custom "{1}" file +error.unexpected-default-package-property.advice=Don''t explicitly set value of "{0}" property in custom "{1}" file diff --git a/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c b/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c index 7fb8d9f53e9..7db42bc2dbd 100644 --- a/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c +++ b/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -133,6 +133,43 @@ cleanup: } +static ssize_t readFully(const int fd, void* buf, const size_t len) { + size_t nRead = 0; + ssize_t n; + + while (nRead < len) { + n = read(fd, (char*)buf + nRead, len - nRead); + if (n == -1) { + if (errno == EINTR) { + continue; + } + return -1; + } + if (n == 0) { + break; + } + nRead += (size_t)n; + } + return (ssize_t)nRead; +} + +static ssize_t writeFully(const int fd, const void* buf, const size_t len) { + size_t nWritten = 0; + ssize_t n; + + while (nWritten < len) { + n = write(fd, (const char*)buf + nWritten, len - nWritten); + if (n == -1) { + if (errno == EINTR) { + continue; + } + return -1; + } + nWritten += (size_t)n; + } + return (ssize_t)nWritten; +} + static void closePipeEnd(int* pipefd, int idx) { if (pipefd[idx] >= 0) { close(pipefd[idx]); @@ -190,21 +227,24 @@ int main(int argc, char *argv[]) { jvmLauncherData = initJvmlLauncherData(&jvmLauncherDataBufferSize); if (jvmLauncherData) { /* Buffer size */ - if (write(pipefd[1], &jvmLauncherDataBufferSize, - sizeof(jvmLauncherDataBufferSize)) == -1) { + if (writeFully(pipefd[1], &jvmLauncherDataBufferSize, + sizeof(jvmLauncherDataBufferSize)) != + sizeof(jvmLauncherDataBufferSize)) { JP_LOG_ERRNO; goto cleanup; } if (jvmLauncherDataBufferSize) { /* Buffer address */ - if (write(pipefd[1], &jvmLauncherData, - sizeof(jvmLauncherData)) == -1) { + if (writeFully(pipefd[1], &jvmLauncherData, + sizeof(jvmLauncherData)) != + sizeof(jvmLauncherData)) { JP_LOG_ERRNO; goto cleanup; } /* Buffer data */ - if (write(pipefd[1], jvmLauncherData, - jvmLauncherDataBufferSize) == -1) { + if (writeFully(pipefd[1], jvmLauncherData, + jvmLauncherDataBufferSize) != + jvmLauncherDataBufferSize) { JP_LOG_ERRNO; goto cleanup; } @@ -218,8 +258,9 @@ int main(int argc, char *argv[]) { /* Close unused write end */ closePipeEnd(pipefd, 1); - if (read(pipefd[0], &jvmLauncherDataBufferSize, - sizeof(jvmLauncherDataBufferSize)) == -1) { + if (readFully(pipefd[0], &jvmLauncherDataBufferSize, + sizeof(jvmLauncherDataBufferSize)) != + sizeof(jvmLauncherDataBufferSize)) { JP_LOG_ERRNO; goto cleanup; } @@ -229,7 +270,8 @@ int main(int argc, char *argv[]) { goto cleanup; } - if (read(pipefd[0], &baseAddress, sizeof(baseAddress)) == -1) { + if (readFully(pipefd[0], &baseAddress, sizeof(baseAddress)) != + sizeof(baseAddress)) { JP_LOG_ERRNO; goto cleanup; } @@ -240,8 +282,8 @@ int main(int argc, char *argv[]) { goto cleanup; } - if (read(pipefd[0], jvmLauncherData, - jvmLauncherDataBufferSize) == -1) { + if (readFully(pipefd[0], jvmLauncherData, jvmLauncherDataBufferSize) != + jvmLauncherDataBufferSize) { JP_LOG_ERRNO; goto cleanup; } diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/ActiveKeychainList.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/ActiveKeychainList.java new file mode 100644 index 00000000000..ab41fc0a60e --- /dev/null +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/ActiveKeychainList.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2025, 2026, 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.jpackage.internal; + +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import jdk.internal.util.OSVersion; + +final class ActiveKeychainList implements Closeable { + + static Optional createForPlatform(List keychains) throws IOException { + if (!keychains.isEmpty() && Globals.instance().findBooleanProperty(ActiveKeychainList.class).orElseGet(ActiveKeychainList::isRequired)) { + return Optional.of(new ActiveKeychainList(keychains)); + } else { + return Optional.empty(); + } + } + + static Optional createForPlatform(Keychain... keychains) throws IOException { + return createForPlatform(List.of(keychains)); + } + + @SuppressWarnings("try") + static void withKeychains(Consumer> keychainConsumer, List keychains) throws IOException { + var keychainList = createForPlatform(keychains); + if (keychainList.isEmpty()) { + keychainConsumer.accept(keychains); + } else { + try (var kl = keychainList.get()) { + keychainConsumer.accept(keychains); + } + } + } + + static void withKeychain(Consumer keychainConsumer, Keychain keychain) throws IOException { + + Objects.requireNonNull(keychainConsumer); + withKeychains(keychains -> { + keychainConsumer.accept(keychains.getFirst()); + }, List.of(keychain)); + } + + ActiveKeychainList(List requestedKeychains, List currentKeychains, boolean force) throws IOException { + this.requestedKeychains = List.copyOf(requestedKeychains); + this.oldKeychains = List.copyOf(currentKeychains); + + final List cmdline = new ArrayList<>(LIST_KEYCHAINS_CMD_PREFIX); + addKeychains(cmdline, oldKeychains); + + if (force) { + this.currentKeychains = requestedKeychains; + restoreKeychainsCmd = List.copyOf(cmdline); + cmdline.subList(LIST_KEYCHAINS_CMD_PREFIX.size(), cmdline.size()).clear(); + addKeychains(cmdline, requestedKeychains); + } else { + final var currentKeychainPaths = oldKeychains.stream().map(Keychain::path).toList(); + + final var missingKeychains = requestedKeychains.stream().filter(k -> { + return !currentKeychainPaths.contains(k.path()); + }).toList(); + + if (missingKeychains.isEmpty()) { + this.currentKeychains = oldKeychains; + restoreKeychainsCmd = List.of(); + } else { + this.currentKeychains = Stream.of(oldKeychains, missingKeychains) + .flatMap(List::stream).collect(Collectors.toUnmodifiableList()); + restoreKeychainsCmd = List.copyOf(cmdline); + addKeychains(cmdline, missingKeychains); + } + } + + Executor.of(cmdline).executeExpectSuccess(); + } + + ActiveKeychainList(List keychains) throws IOException { + this(keychains, Keychain.listKeychains(), false); + } + + List requestedKeychains() { + return requestedKeychains; + } + + List currentKeychains() { + return currentKeychains; + } + + List restoreKeychains() { + return oldKeychains; + } + + @Override + public void close() throws IOException { + if (!restoreKeychainsCmd.isEmpty()) { + Executor.of(restoreKeychainsCmd).executeExpectSuccess(); + } + } + + private static void addKeychains(List cmdline, List keychains) { + cmdline.addAll(keychains.stream().map(Keychain::asCliArg).toList()); + } + + private static boolean isRequired() { + // Required for OS X 10.12+ + return 0 <= OSVersion.current().compareTo(new OSVersion(10, 12)); + } + + private final List requestedKeychains; + private final List currentKeychains; + private final List oldKeychains; + private final List restoreKeychainsCmd; + + private final static List LIST_KEYCHAINS_CMD_PREFIX = List.of("/usr/bin/security", "list-keychains", "-s"); +} diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/AppImageInfoPListFile.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/AppImageInfoPListFile.java deleted file mode 100644 index 602e147a970..00000000000 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/AppImageInfoPListFile.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2025, 2026, 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.jpackage.internal; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import jdk.jpackage.internal.model.DottedVersion; -import jdk.jpackage.internal.util.PListReader; -import org.xml.sax.SAXException; - -/** - * Mandatory elements of Info.plist file of app image. - */ -record AppImageInfoPListFile(String bundleIdentifier, String bundleName, String copyright, - DottedVersion shortVersion, DottedVersion bundleVersion, String category) { - - static final class InvalidPlistFileException extends Exception { - InvalidPlistFileException(Throwable cause) { - super(cause); - } - - private static final long serialVersionUID = 1L; - } - - static AppImageInfoPListFile loadFromInfoPList(Path infoPListFile) - throws IOException, InvalidPlistFileException, SAXException { - - final var plistReader = new PListReader(Files.readAllBytes(infoPListFile)); - - try { - return new AppImageInfoPListFile( - plistReader.queryValue("CFBundleIdentifier"), - plistReader.queryValue("CFBundleName"), - plistReader.queryValue("NSHumanReadableCopyright"), - DottedVersion.greedy(plistReader.queryValue("CFBundleShortVersionString")), - DottedVersion.greedy(plistReader.queryValue("CFBundleVersion")), - plistReader.queryValue("LSApplicationCategoryType")); - } catch (Exception ex) { - throw new InvalidPlistFileException(ex); - } - } -} diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacApplicationBuilder.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacApplicationBuilder.java index a73a6152f6d..d6b816ca75e 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacApplicationBuilder.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacApplicationBuilder.java @@ -24,6 +24,8 @@ */ package jdk.jpackage.internal; +import static jdk.jpackage.internal.cli.StandardValidator.IS_VALID_MAC_BUNDLE_IDENTIFIER; + import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; @@ -32,23 +34,29 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import jdk.jpackage.internal.util.RootedPath; import java.util.stream.Stream; import jdk.jpackage.internal.model.AppImageLayout; import jdk.jpackage.internal.model.AppImageSigningConfig; import jdk.jpackage.internal.model.Application; +import jdk.jpackage.internal.model.ApplicationLaunchers; +import jdk.jpackage.internal.model.ConfigException; +import jdk.jpackage.internal.model.ExternalApplication; +import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.Launcher; import jdk.jpackage.internal.model.MacApplication; import jdk.jpackage.internal.model.MacApplicationMixin; +import jdk.jpackage.internal.util.PListReader; +import jdk.jpackage.internal.util.Result; +import jdk.jpackage.internal.util.RootedPath; final class MacApplicationBuilder { - MacApplicationBuilder(Application app) { - this.app = Objects.requireNonNull(app); + MacApplicationBuilder(ApplicationBuilder appBuilder) { + this.superBuilder = Objects.requireNonNull(appBuilder); } private MacApplicationBuilder(MacApplicationBuilder other) { - this(other.app); + this(other.superBuilder.copy()); icon = other.icon; bundleName = other.bundleName; bundleIdentifier = other.bundleIdentifier; @@ -93,18 +101,28 @@ final class MacApplicationBuilder { return this; } + Optional externalApplication() { + return superBuilder.externalApplication(); + } + + Optional launchers() { + return superBuilder.launchers(); + } + MacApplication create() { if (externalInfoPlistFile != null) { return createCopyForExternalInfoPlistFile().create(); } + var app = superBuilder.create(); + validateAppVersion(app); validateAppContentDirs(app); final var mixin = new MacApplicationMixin.Stub( validatedIcon(), - validatedBundleName(), - validatedBundleIdentifier(), + validatedBundleName(app), + validatedBundleIdentifier(app), validatedCategory(), appStore, createSigningConfig()); @@ -123,20 +141,6 @@ final class MacApplicationBuilder { return MacApplication.create(ApplicationBuilder.overrideAppImageLayout(app, appImageLayout), mixin); } - static boolean isValidBundleIdentifier(String id) { - for (int i = 0; i < id.length(); i++) { - char a = id.charAt(i); - // We check for ASCII codes first which we accept. If check fails, - // check if it is acceptable extended ASCII or unicode character. - if ((a >= 'A' && a <= 'Z') || (a >= 'a' && a <= 'z') - || (a >= '0' && a <= '9') || (a == '-' || a == '.')) { - continue; - } - return false; - } - return true; - } - private static void validateAppVersion(Application app) { try { CFBundleVersion.of(app.version()); @@ -160,41 +164,58 @@ final class MacApplicationBuilder { } private MacApplicationBuilder createCopyForExternalInfoPlistFile() { - try { - final var plistFile = AppImageInfoPListFile.loadFromInfoPList(externalInfoPlistFile); + final var builder = new MacApplicationBuilder(this); - final var builder = new MacApplicationBuilder(this); + builder.externalInfoPlistFile(null); - builder.externalInfoPlistFile(null); + Result plistResult = Result.of(() -> { + return new PListReader(Files.readAllBytes(externalInfoPlistFile)); + }, Exception.class); + plistResult.value().ifPresent(plist -> { if (builder.bundleName == null) { - builder.bundleName(plistFile.bundleName()); + plist.findValue("CFBundleName").ifPresent(builder::bundleName); } if (builder.bundleIdentifier == null) { - builder.bundleIdentifier(plistFile.bundleIdentifier()); + plist.findValue("CFBundleIdentifier").ifPresent(builder::bundleIdentifier); } if (builder.category == null) { - builder.category(plistFile.category()); + plist.findValue("LSApplicationCategoryType").ifPresent(builder::category); } - return builder; - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } catch (Exception ex) { - throw I18N.buildConfigException("message.app-image-requires-identifier") - .advice("message.app-image-requires-identifier.advice") - .cause(ex) - .create(); - } + if (builder.superBuilder.version().isEmpty()) { + plist.findValue("CFBundleVersion").ifPresent(builder.superBuilder::version); + } + }); + + plistResult.firstError().filter(_ -> { + // If we are building a runtime and the Info.plist file of the predefined + // runtime bundle is malformed or unavailable, ignore it. + return !superBuilder.isRuntime(); + }).ifPresent(ex -> { + // We are building an application from the predefined app image and + // the Info.plist file in the predefined app image bundle is malformed or unavailable. Bail out. + switch (ex) { + case IOException ioex -> { + throw new UncheckedIOException(ioex); + } + default -> { + throw new JPackageException( + I18N.format("error.invalid-app-image-plist-file", externalInfoPlistFile), ex); + } + } + }); + + return builder; } private Optional createSigningConfig() { return Optional.ofNullable(signingBuilder).map(AppImageSigningConfigBuilder::create); } - private String validatedBundleName() { + private String validatedBundleName(Application app) { final var value = Optional.ofNullable(bundleName).orElseGet(() -> { final var appName = app.name(); // Commented out for backward compatibility @@ -213,9 +234,9 @@ final class MacApplicationBuilder { return value; } - private String validatedBundleIdentifier() { - final var value = Optional.ofNullable(bundleIdentifier).orElseGet(() -> { - return app.mainLauncher() + private String validatedBundleIdentifier(Application app) { + return Optional.ofNullable(bundleIdentifier).orElseGet(() -> { + var derivedValue = app.mainLauncher() .flatMap(Launcher::startupInfo) .map(li -> { final var packageName = li.packageName(); @@ -226,15 +247,23 @@ final class MacApplicationBuilder { } }) .orElseGet(app::name); + + if (!IS_VALID_MAC_BUNDLE_IDENTIFIER.test(derivedValue)) { + // Derived bundle identifier is invalid. Try to adjust it by dropping all invalid characters. + derivedValue = derivedValue.codePoints() + .mapToObj(Character::toString) + .filter(IS_VALID_MAC_BUNDLE_IDENTIFIER) + .collect(Collectors.joining("")); + if (!IS_VALID_MAC_BUNDLE_IDENTIFIER.test(derivedValue)) { + throw new ConfigException( + I18N.format("error.invalid-derived-bundle-identifier"), + I18N.format("error.invalid-derived-bundle-identifier.advice")); + } + } + + Log.verbose(I18N.format("message.derived-bundle-identifier", derivedValue)); + return derivedValue; }); - - if (!isValidBundleIdentifier(value)) { - throw I18N.buildConfigException("message.invalid-identifier", value) - .advice("message.invalid-identifier.advice") - .create(); - } - - return value; } private String validatedCategory() { @@ -256,7 +285,7 @@ final class MacApplicationBuilder { private Path externalInfoPlistFile; private AppImageSigningConfigBuilder signingBuilder; - private final Application app; + private final ApplicationBuilder superBuilder; private static final Defaults DEFAULTS = new Defaults("utilities"); diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBundlingEnvironment.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBundlingEnvironment.java index 224ea20f249..1e60d8490f0 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBundlingEnvironment.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBundlingEnvironment.java @@ -31,6 +31,7 @@ import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_MAC_APP import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_MAC_DMG; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_MAC_PKG; import static jdk.jpackage.internal.cli.StandardBundlingOperation.SIGN_MAC_APP_IMAGE; +import static jdk.jpackage.internal.cli.StandardOption.EXIT_AFTER_CONFIGURATION_PHASE; import java.util.Optional; import jdk.jpackage.internal.cli.Options; @@ -74,6 +75,10 @@ public class MacBundlingEnvironment extends DefaultBundlingEnvironment { final var pkg = createSignAppImagePackage(app, env); + if (EXIT_AFTER_CONFIGURATION_PHASE.getFrom(options)) { + return; + } + buildPipeline(pkg).create().execute(env, pkg, env.appImageDir()); } diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgSystemEnvironment.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgSystemEnvironment.java index 12d105b99b5..11cf94ca66d 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgSystemEnvironment.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgSystemEnvironment.java @@ -31,6 +31,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.internal.util.OperatingSystem; import jdk.jpackage.internal.util.Result; record MacDmgSystemEnvironment(Path hdiutil, Path osascript, Optional setFileUtility) implements SystemEnvironment { @@ -39,12 +40,22 @@ record MacDmgSystemEnvironment(Path hdiutil, Path osascript, Optional setF } static Result create() { - final var errors = Stream.of(HDIUTIL, OSASCRIPT) - .map(ToolValidator::new) - .map(ToolValidator::checkExistsOnly) - .map(ToolValidator::validate) - .filter(Objects::nonNull) - .toList(); + + List errors; + + if (OperatingSystem.isMacOS()) { + errors = Stream.of(HDIUTIL, OSASCRIPT) + .map(ToolValidator::new) + .map(ToolValidator::checkExistsOnly) + .map(ToolValidator::validate) + .filter(Objects::nonNull) + .toList(); + } else { + // The code runs on an OS other than macOS. Presume this is mock testing. + // Don't validate the tools; checking that their executables exist will fail in this environment. + errors = List.of(); + } + if (errors.isEmpty()) { return Result.ofValue(new MacDmgSystemEnvironment(HDIUTIL, OSASCRIPT, findSetFileUtility())); } else { diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacFromOptions.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacFromOptions.java index 0598e6bc2a9..2c247ed3989 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacFromOptions.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacFromOptions.java @@ -27,9 +27,8 @@ package jdk.jpackage.internal; import static jdk.jpackage.internal.FromOptions.buildApplicationBuilder; import static jdk.jpackage.internal.FromOptions.createPackageBuilder; import static jdk.jpackage.internal.MacPackagingPipeline.APPLICATION_LAYOUT; -import static jdk.jpackage.internal.MacRuntimeValidator.validateRuntimeHasJliLib; -import static jdk.jpackage.internal.MacRuntimeValidator.validateRuntimeHasNoBinDir; -import static jdk.jpackage.internal.cli.StandardBundlingOperation.SIGN_MAC_APP_IMAGE; +import static jdk.jpackage.internal.OptionUtils.isBundlingOperation; +import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_MAC_PKG; import static jdk.jpackage.internal.cli.StandardOption.APPCLASS; import static jdk.jpackage.internal.cli.StandardOption.ICON; import static jdk.jpackage.internal.cli.StandardOption.MAC_APP_CATEGORY; @@ -63,6 +62,7 @@ import jdk.jpackage.internal.cli.OptionValue; import jdk.jpackage.internal.cli.Options; import jdk.jpackage.internal.cli.StandardFaOption; import jdk.jpackage.internal.model.ApplicationLaunchers; +import jdk.jpackage.internal.model.DottedVersion; import jdk.jpackage.internal.model.ExternalApplication; import jdk.jpackage.internal.model.FileAssociation; import jdk.jpackage.internal.model.Launcher; @@ -120,23 +120,39 @@ final class MacFromOptions { final Optional pkgSigningIdentityBuilder; - if (sign && (MAC_INSTALLER_SIGN_IDENTITY.containsIn(options) || MAC_SIGNING_KEY_NAME.containsIn(options))) { + if (!sign) { + pkgSigningIdentityBuilder = Optional.empty(); + } else if (hasAppImageSignIdentity(options) && !hasPkgInstallerSignIdentity(options)) { + // They explicitly request to sign the app image, + // but don't specify signing identity for signing the PKG package. + // They want signed app image inside of unsigned PKG. + pkgSigningIdentityBuilder = Optional.empty(); + } else { final var signingIdentityBuilder = createSigningIdentityBuilder(options); - MAC_INSTALLER_SIGN_IDENTITY.ifPresentIn(options, signingIdentityBuilder::signingIdentity); - MAC_SIGNING_KEY_NAME.findIn(options).ifPresent(userName -> { - final StandardCertificateSelector domain; - if (appStore) { - domain = StandardCertificateSelector.APP_STORE_PKG_INSTALLER; - } else { - domain = StandardCertificateSelector.PKG_INSTALLER; - } - signingIdentityBuilder.certificateSelector(StandardCertificateSelector.create(userName, domain)); - }); + MAC_INSTALLER_SIGN_IDENTITY.findIn(options).ifPresentOrElse( + signingIdentityBuilder::signingIdentity, + () -> { + MAC_SIGNING_KEY_NAME.findIn(options).or(() -> { + if (MAC_APP_IMAGE_SIGN_IDENTITY.findIn(options).isPresent()) { + return Optional.empty(); + } else { + return Optional.of(""); + } + }).ifPresent(userName -> { + final StandardCertificateSelector domain; + if (appStore) { + domain = StandardCertificateSelector.APP_STORE_PKG_INSTALLER; + } else { + domain = StandardCertificateSelector.PKG_INSTALLER; + } + + signingIdentityBuilder.certificateSelector(StandardCertificateSelector.create(userName, domain)); + }); + } + ); pkgSigningIdentityBuilder = Optional.of(signingIdentityBuilder); - } else { - pkgSigningIdentityBuilder = Optional.empty(); } ApplicationWithDetails app = null; @@ -180,17 +196,19 @@ final class MacFromOptions { } } - private static ApplicationWithDetails createMacApplicationInternal(Options options) { + private static ApplicationBuilder createApplicationBuilder(Options options) { final var predefinedRuntimeLayout = PREDEFINED_RUNTIME_IMAGE.findIn(options) .map(MacPackage::guessRuntimeLayout); - predefinedRuntimeLayout.ifPresent(layout -> { - validateRuntimeHasJliLib(layout); - if (MAC_APP_STORE.containsIn(options)) { - validateRuntimeHasNoBinDir(layout); - } - }); + predefinedRuntimeLayout.ifPresent(MacRuntimeValidator::validateRuntimeHasJliLib); + + if (MAC_APP_STORE.containsIn(options)) { + PREDEFINED_APP_IMAGE.findIn(options) + .map(APPLICATION_LAYOUT::resolveAt) + .ifPresent(MacRuntimeValidator::validateRuntimeHasNoBinDir); + predefinedRuntimeLayout.ifPresent(MacRuntimeValidator::validateRuntimeHasNoBinDir); + } final var launcherFromOptions = new LauncherFromOptions().faMapper(MacFromOptions::createMacFa); @@ -216,54 +234,88 @@ final class MacFromOptions { superAppBuilder.launchers(new ApplicationLaunchers(MacLauncher.create(mainLauncher), launchers.additionalLaunchers())); } - final var app = superAppBuilder.create(); + superAppBuilder.derivedVersionNormalizer(MacFromOptions::normalizeVersion); - final var appBuilder = new MacApplicationBuilder(app); + return superAppBuilder; + } - PREDEFINED_APP_IMAGE.findIn(options) - .map(MacBundle::new) - .map(MacBundle::infoPlistFile) - .ifPresent(appBuilder::externalInfoPlistFile); + private static ApplicationWithDetails createMacApplicationInternal(Options options) { + + final var appBuilder = new MacApplicationBuilder(createApplicationBuilder(options)); + + if (OptionUtils.isRuntimeInstaller(options)) { + // Predefined runtime image, if specified, can be a macOS bundle or regular directory. + // Notify application builder with the path to the plist file in the predefined runtime image only if the file exists. + // If it doesn't, jpackage should keep going. + PREDEFINED_RUNTIME_IMAGE.findIn(options) + .flatMap(MacBundle::fromPath) + .map(MacBundle::infoPlistFile) + .ifPresent(appBuilder::externalInfoPlistFile); + } else { + // Predefined app image, if specified, should always be a valid macOS bundle. + // Notify application builder with the path to the plist file in the predefined app image without checking if the file exists. + // If it doesn't, the builder should throw and jpackage should exit with error. + PREDEFINED_APP_IMAGE.findIn(options) + .map(MacBundle::new) + .map(MacBundle::infoPlistFile) + .ifPresent(appBuilder::externalInfoPlistFile); + } ICON.ifPresentIn(options, appBuilder::icon); MAC_BUNDLE_NAME.ifPresentIn(options, appBuilder::bundleName); MAC_BUNDLE_IDENTIFIER.ifPresentIn(options, appBuilder::bundleIdentifier); MAC_APP_CATEGORY.ifPresentIn(options, appBuilder::category); - final boolean sign; + final boolean sign = MAC_SIGN.getFrom(options); final boolean appStore; - if (PREDEFINED_APP_IMAGE.containsIn(options) && OptionUtils.bundlingOperation(options) != SIGN_MAC_APP_IMAGE) { - final var appImageFileOptions = superAppBuilder.externalApplication().orElseThrow().extra(); - sign = MAC_SIGN.getFrom(appImageFileOptions); + if (MAC_APP_STORE.containsIn(options)) { + appStore = MAC_APP_STORE.getFrom(options); + } else if (PREDEFINED_APP_IMAGE.containsIn(options)) { + final var appImageFileOptions = appBuilder.externalApplication().orElseThrow().extra(); appStore = MAC_APP_STORE.getFrom(appImageFileOptions); } else { - sign = MAC_SIGN.getFrom(options); - appStore = MAC_APP_STORE.getFrom(options); + appStore = false; } appBuilder.appStore(appStore); - if (sign && (MAC_APP_IMAGE_SIGN_IDENTITY.containsIn(options) || MAC_SIGNING_KEY_NAME.containsIn(options))) { - final var signingIdentityBuilder = createSigningIdentityBuilder(options); - MAC_APP_IMAGE_SIGN_IDENTITY.ifPresentIn(options, signingIdentityBuilder::signingIdentity); - MAC_SIGNING_KEY_NAME.findIn(options).ifPresent(userName -> { - final StandardCertificateSelector domain; - if (appStore) { - domain = StandardCertificateSelector.APP_STORE_APP_IMAGE; - } else { - domain = StandardCertificateSelector.APP_IMAGE; - } + final var signOnlyPkgInstaller = sign && ( + isBundlingOperation(options, CREATE_MAC_PKG) + && !hasAppImageSignIdentity(options) + && hasPkgInstallerSignIdentity(options)); - signingIdentityBuilder.certificateSelector(StandardCertificateSelector.create(userName, domain)); - }); + if (sign && !signOnlyPkgInstaller) { + final var signingIdentityBuilder = createSigningIdentityBuilder(options); + + MAC_APP_IMAGE_SIGN_IDENTITY.findIn(options).ifPresentOrElse( + signingIdentityBuilder::signingIdentity, + () -> { + MAC_SIGNING_KEY_NAME.findIn(options).or(() -> { + if (MAC_INSTALLER_SIGN_IDENTITY.containsIn(options)) { + return Optional.empty(); + } else { + return Optional.of(""); + } + }).ifPresent(userName -> { + final StandardCertificateSelector domain; + if (appStore) { + domain = StandardCertificateSelector.APP_STORE_APP_IMAGE; + } else { + domain = StandardCertificateSelector.APP_IMAGE; + } + + signingIdentityBuilder.certificateSelector(StandardCertificateSelector.create(userName, domain)); + }); + } + ); final var signingBuilder = new AppImageSigningConfigBuilder(signingIdentityBuilder); if (appStore) { signingBuilder.entitlementsResourceName("sandbox.plist"); } - app.mainLauncher().flatMap(Launcher::startupInfo).ifPresentOrElse( + appBuilder.launchers().map(ApplicationLaunchers::mainLauncher).flatMap(Launcher::startupInfo).ifPresentOrElse( signingBuilder::signingIdentifierPrefix, () -> { // Runtime installer does not have the main launcher, use @@ -278,7 +330,7 @@ final class MacFromOptions { appBuilder.signingBuilder(signingBuilder); } - return new ApplicationWithDetails(appBuilder.create(), superAppBuilder.externalApplication()); + return new ApplicationWithDetails(appBuilder.create(), appBuilder.externalApplication()); } private static MacPackageBuilder createMacPackageBuilder(Options options, ApplicationWithDetails app, PackageType type) { @@ -331,4 +383,19 @@ final class MacFromOptions { return builder.create(fa); } + + private static boolean hasAppImageSignIdentity(Options options) { + return options.contains(MAC_SIGNING_KEY_NAME) || options.contains(MAC_APP_IMAGE_SIGN_IDENTITY); + } + + private static boolean hasPkgInstallerSignIdentity(Options options) { + return options.contains(MAC_SIGNING_KEY_NAME) || options.contains(MAC_INSTALLER_SIGN_IDENTITY); + } + + private static String normalizeVersion(String version) { + // macOS requires 1, 2 or 3 components version string. + // When reading from release file it can be 1 or 3 or maybe more. + // We will always normalize to 3 components if needed. + return DottedVersion.lazy(version).trim(3).toComponentsString(); + } } diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackageBuilder.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackageBuilder.java index e19f234d0d6..1049496146f 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackageBuilder.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +65,7 @@ final class MacPackageBuilder { } private static void validatePredefinedAppImage(MacPackage pkg) { - if (pkg.predefinedAppImageSigned().orElse(false)) { + if (pkg.predefinedAppImageSigned().orElse(false) && !pkg.isRuntimeInstaller()) { pkg.predefinedAppImage().ifPresent(predefinedAppImage -> { var thePackageFile = PackageFile.getPathInAppImage(APPLICATION_LAYOUT); if (!Files.exists(predefinedAppImage.resolve(thePackageFile))) { diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackagingPipeline.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackagingPipeline.java index 4e63f6db178..d75b7d0b9cd 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackagingPipeline.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPackagingPipeline.java @@ -500,7 +500,7 @@ final class MacPackagingPipeline { }; app.signingConfig().flatMap(AppImageSigningConfig::keychain).map(Keychain::new).ifPresentOrElse(keychain -> { - toBiConsumer(TempKeychain::withKeychain).accept(unused -> signAction.run(), keychain); + toBiConsumer(ActiveKeychainList::withKeychain).accept(unused -> signAction.run(), keychain); }, signAction); } diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgPackager.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgPackager.java index fc5c85c699c..369ab201611 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgPackager.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgPackager.java @@ -51,7 +51,6 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import jdk.internal.util.Architecture; -import jdk.internal.util.OSVersion; import jdk.jpackage.internal.PackagingPipeline.PackageTaskID; import jdk.jpackage.internal.PackagingPipeline.TaskID; import jdk.jpackage.internal.model.MacPkgPackage; @@ -509,11 +508,6 @@ record MacPkgPackager(BuildEnv env, MacPkgPackage pkg, Optional servic // maybe sign if (pkg.sign()) { - if (OSVersion.current().compareTo(new OSVersion(10, 12)) >= 0) { - // we need this for OS X 10.12+ - Log.verbose(I18N.getString("message.signing.pkg")); - } - final var pkgSigningConfig = pkg.signingConfig().orElseThrow(); commandLine.add("--sign"); diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacRuntimeValidator.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacRuntimeValidator.java index cfab12cbcba..340078849c7 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacRuntimeValidator.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacRuntimeValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,10 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.function.Predicate; +import jdk.jpackage.internal.model.AppImageLayout; +import jdk.jpackage.internal.model.ApplicationLayout; +import jdk.jpackage.internal.model.ConfigException; +import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.RuntimeLayout; final class MacRuntimeValidator { @@ -45,17 +49,29 @@ final class MacRuntimeValidator { throw new UncheckedIOException(ex); } - throw I18N.buildConfigException("error.invalid-runtime-image-missing-file", + throw new JPackageException(I18N.format("error.invalid-runtime-image-missing-file", runtimeLayout.rootDirectory(), - runtimeLayout.unresolve().runtimeDirectory().resolve("lib/**").resolve(jliName)).create(); + runtimeLayout.unresolve().runtimeDirectory().resolve("lib/**").resolve(jliName))); } - static void validateRuntimeHasNoBinDir(RuntimeLayout runtimeLayout) { - if (Files.isDirectory(runtimeLayout.runtimeDirectory().resolve("bin"))) { - throw I18N.buildConfigException() - .message("error.invalid-runtime-image-bin-dir", runtimeLayout.rootDirectory()) - .advice("error.invalid-runtime-image-bin-dir.advice", "--mac-app-store") - .create(); + static void validateRuntimeHasNoBinDir(AppImageLayout appImageLayout) { + if (Files.isDirectory(appImageLayout.runtimeDirectory().resolve("bin"))) { + switch (appImageLayout) { + case RuntimeLayout runtimeLayout -> { + throw new ConfigException( + I18N.format("error.invalid-runtime-image-bin-dir", runtimeLayout.rootDirectory()), + I18N.format("error.invalid-runtime-image-bin-dir.advice", "--mac-app-store")); + } + case ApplicationLayout appLayout -> { + throw new JPackageException(I18N.format("error.invalid-app-image-runtime-image-bin-dir", + appLayout.rootDirectory().relativize(appLayout.runtimeDirectory()), + appLayout.rootDirectory())); + } + default -> { + throw new IllegalArgumentException(); + } + } + } } } diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/TempKeychain.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/TempKeychain.java deleted file mode 100644 index 2f616aafba1..00000000000 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/TempKeychain.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2025, 2026, 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.jpackage.internal; - -import java.io.Closeable; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.Consumer; -import jdk.internal.util.OSVersion; - -final class TempKeychain implements Closeable { - - static void withKeychains(Consumer> keychainConsumer, List keychains) { - - keychains.forEach(Objects::requireNonNull); - if (keychains.isEmpty() || OSVersion.current().compareTo(new OSVersion(10, 12)) < 0) { - keychainConsumer.accept(keychains); - } else { - // we need this for OS X 10.12+ - try (var tempKeychain = new TempKeychain(keychains)) { - keychainConsumer.accept(tempKeychain.keychains); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - } - } - - static void withKeychain(Consumer keychainConsumer, Keychain keychain) { - - Objects.requireNonNull(keychainConsumer); - withKeychains(keychains -> { - keychainConsumer.accept(keychains.getFirst()); - }, List.of(keychain)); - } - - TempKeychain(List keychains) throws IOException { - this.keychains = Objects.requireNonNull(keychains); - - final var currentKeychains = Keychain.listKeychains(); - - final var currentKeychainPaths = currentKeychains.stream().map(Keychain::path).toList(); - - final var missingKeychains = keychains.stream().filter(k -> { - return !currentKeychainPaths.contains(k.path()); - }).toList(); - - if (missingKeychains.isEmpty()) { - restoreKeychainsCmd = List.of(); - } else { - List args = new ArrayList<>(); - args.add("/usr/bin/security"); - args.add("list-keychains"); - args.add("-s"); - args.addAll(currentKeychains.stream().map(Keychain::asCliArg).toList()); - - restoreKeychainsCmd = List.copyOf(args); - - args.addAll(missingKeychains.stream().map(Keychain::asCliArg).toList()); - - Executor.of(args).executeExpectSuccess(); - } - } - - List keychains() { - return keychains; - } - - @Override - public void close() throws IOException { - if (!restoreKeychainsCmd.isEmpty()) { - Executor.of(restoreKeychainsCmd).executeExpectSuccess(); - } - } - - private final List keychains; - private final List restoreKeychainsCmd; -} diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties index e43cadc5782..2ed1f740805 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties @@ -29,8 +29,13 @@ error.cert.not.found=No certificate found matching [{0}] using keychain [{1}] error.multiple.certs.found=Multiple certificates matching name [{0}] found in keychain [{1}] error.app-image.mac-sign.required=--mac-sign option is required with predefined application image and with type [app-image] error.invalid-runtime-image-missing-file=Runtime image "{0}" is missing "{1}" file +error.invalid-app-image-runtime-image-bin-dir=Runtime directory {0} in the predefined application image [{1}] should not contain "bin" folder error.invalid-runtime-image-bin-dir=Runtime image "{0}" should not contain "bin" folder error.invalid-runtime-image-bin-dir.advice=Use --strip-native-commands jlink option when generating runtime image used with {0} option +error.invalid-app-image-plist-file=Invalid "{0}" file in the predefined application image +error.invalid-derived-bundle-identifier=Can't derive a valid bundle identifier from the input data +error.invalid-derived-bundle-identifier.advice=Specify bundle identifier with --mac-package-identifier option + resource.app-info-plist=Application Info.plist resource.app-runtime-info-plist=Embedded Java Runtime Info.plist resource.runtime-info-plist=Java Runtime Info.plist @@ -54,12 +59,10 @@ message.icon-not-icns= The specified icon "{0}" is not an ICNS file and will not message.version-string-too-many-components='app-version' may have between 1 and 3 numbers: 1, 1.2, 1.2.3. message.version-string-first-number-not-zero=The first number in an app-version cannot be zero or negative. message.keychain.error=Unable to get keychain list. -message.invalid-identifier=Invalid mac bundle identifier [{0}]. -message.invalid-identifier.advice=specify identifier with "--mac-package-identifier". +message.derived-bundle-identifier=Derived bundle identifier: {0} message.preparing-dmg-setup=Preparing dmg setup: {0}. message.preparing-scripts=Preparing package scripts. message.preparing-distribution-dist=Preparing distribution.dist: {0}. -message.signing.pkg=Warning: For signing PKG, you might need to set "Always Trust" for your certificate using "Keychain Access" tool. message.setfile.dmg=Setting custom icon on DMG file skipped because 'SetFile' utility was not found. Installing Xcode with Command Line Tools should resolve this issue. message.codesign.failed.reason.app.content="codesign" failed and additional application content was supplied via the "--app-content" parameter. Probably the additional content broke the integrity of the application bundle and caused the failure. Ensure content supplied via the "--app-content" parameter does not break the integrity of the application bundle, or add it in the post-processing step. message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem. diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java index 75ead9d08ad..7edc6cd3c11 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java @@ -134,19 +134,6 @@ final class AppImageFile { return appLayout.appDirectory().resolve(FILENAME); } - /** - * Loads application image info from the specified application layout. - *

    - * It is an equivalent to calling - * {@link #load(ApplicationLayout, OperatingSystem)} method with - * {@code OperatingSystem.current()} for the second parameter. - * - * @param appLayout the application layout - */ - static ExternalApplication load(ApplicationLayout appLayout) { - return load(appLayout, OperatingSystem.current()); - } - /** * Loads application image info from the specified application layout and OS. * diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationBuilder.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationBuilder.java index 9d5407524a8..0cca59f7c19 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationBuilder.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationBuilder.java @@ -36,19 +36,46 @@ import java.util.Optional; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.UnaryOperator; import jdk.jpackage.internal.model.AppImageLayout; import jdk.jpackage.internal.model.Application; import jdk.jpackage.internal.model.ApplicationLaunchers; import jdk.jpackage.internal.model.ExternalApplication; import jdk.jpackage.internal.model.Launcher; import jdk.jpackage.internal.model.LauncherIcon; +import jdk.jpackage.internal.model.LauncherModularStartupInfo; import jdk.jpackage.internal.model.LauncherStartupInfo; import jdk.jpackage.internal.model.ResourceDirLauncherIcon; import jdk.jpackage.internal.model.RuntimeBuilder; +import jdk.jpackage.internal.model.RuntimeLayout; import jdk.jpackage.internal.util.RootedPath; +import jdk.jpackage.internal.util.RuntimeReleaseFile; final class ApplicationBuilder { + ApplicationBuilder() { + } + + ApplicationBuilder(ApplicationBuilder other) { + name = other.name; + description = other.description; + version = other.version; + vendor = other.vendor; + copyright = other.copyright; + appDirSources = other.appDirSources; + externalApp = other.externalApp; + contentDirSources = other.contentDirSources; + appImageLayout = other.appImageLayout; + runtimeBuilder = other.runtimeBuilder; + launchers = other.launchers; + runtimeReleaseFile = other.runtimeReleaseFile; + derivedVersionNormalizer = other.derivedVersionNormalizer; + } + + ApplicationBuilder copy() { + return new ApplicationBuilder(this); + } + Application create() { Objects.requireNonNull(appImageLayout); @@ -64,7 +91,7 @@ final class ApplicationBuilder { return new Application.Stub( effectiveName, Optional.ofNullable(description).orElse(effectiveName), - Optional.ofNullable(version).orElseGet(DEFAULTS::version), + validatedVersion(), Optional.ofNullable(vendor).orElseGet(DEFAULTS::vendor), Optional.ofNullable(copyright).orElseGet(DEFAULTS::copyright), Optional.ofNullable(appDirSources).orElseGet(List::of), @@ -103,6 +130,11 @@ final class ApplicationBuilder { return this; } + boolean isRuntime() { + return Optional.ofNullable(appImageLayout) + .orElseThrow(IllegalStateException::new) instanceof RuntimeLayout; + } + ApplicationBuilder name(String v) { name = v; return this; @@ -118,6 +150,15 @@ final class ApplicationBuilder { return this; } + Optional version() { + return Optional.ofNullable(version); + } + + ApplicationBuilder runtimeReleaseFile(Path v) { + runtimeReleaseFile = v; + return this; + } + ApplicationBuilder vendor(String v) { vendor = v; return this; @@ -138,6 +179,54 @@ final class ApplicationBuilder { return this; } + ApplicationBuilder derivedVersionNormalizer(UnaryOperator v) { + derivedVersionNormalizer = v; + return this; + } + + private String validatedVersion() { + return Optional.ofNullable(version).or(() -> { + // Application version has not been specified explicitly. Derive it. + var derivedVersion = derivedVersion(); + if (derivedVersionNormalizer != null) { + derivedVersion = derivedVersion.map(v -> { + var mappedVersion = derivedVersionNormalizer.apply(v); + if (!mappedVersion.equals(v)) { + Log.verbose(I18N.format("message.version-normalized", mappedVersion, v)); + } + return mappedVersion; + }); + } + return derivedVersion; + }).orElseGet(DEFAULTS::version); + } + + private Optional derivedVersion() { + if (appImageLayout instanceof RuntimeLayout && runtimeReleaseFile != null) { + try { + var releaseVersion = new RuntimeReleaseFile(runtimeReleaseFile).getJavaVersion().toString(); + Log.verbose(I18N.format("message.release-version", releaseVersion)); + return Optional.of(releaseVersion); + } catch (Exception ex) { + Log.verbose(ex); + return Optional.empty(); + } + } else if (launchers != null) { + return launchers.mainLauncher().startupInfo() + .filter(LauncherModularStartupInfo.class::isInstance) + .map(LauncherModularStartupInfo.class::cast) + .flatMap(modularStartupInfo -> { + var moduleVersion = modularStartupInfo.moduleVersion(); + moduleVersion.ifPresent(v -> { + Log.verbose(I18N.format("message.module-version", v, modularStartupInfo.moduleName())); + }); + return moduleVersion; + }); + } else { + return Optional.empty(); + } + } + static ApplicationLaunchers normalizeIcons( ApplicationLaunchers appLaunchers, Optional resourceDir, BiFunction launcherOverrideCtor) { @@ -302,6 +391,8 @@ final class ApplicationBuilder { private AppImageLayout appImageLayout; private RuntimeBuilder runtimeBuilder; private ApplicationLaunchers launchers; + private Path runtimeReleaseFile; + private UnaryOperator derivedVersionNormalizer; private static final Defaults DEFAULTS = new Defaults( "1.0", diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DefaultBundlingEnvironment.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DefaultBundlingEnvironment.java index 331bde29d27..ae4b1005318 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DefaultBundlingEnvironment.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DefaultBundlingEnvironment.java @@ -25,6 +25,8 @@ package jdk.jpackage.internal; import static java.util.stream.Collectors.toMap; +import static jdk.jpackage.internal.cli.StandardOption.EXIT_AFTER_CONFIGURATION_PHASE; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import java.io.IOException; import java.io.UncheckedIOException; @@ -36,7 +38,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -50,6 +51,7 @@ import jdk.jpackage.internal.model.Application; import jdk.jpackage.internal.model.BundlingOperationDescriptor; import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.Package; +import jdk.jpackage.internal.util.MemoizingSupplier; import jdk.jpackage.internal.util.PathUtils; import jdk.jpackage.internal.util.Result; @@ -66,7 +68,7 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { return runOnce(e.getValue()); })); - this.defaultOperationSupplier = Objects.requireNonNull(defaultOperationSupplier).map(DefaultBundlingEnvironment::runOnce); + this.defaultOperationSupplier = Objects.requireNonNull(defaultOperationSupplier).map(MemoizingSupplier::runOnce); } @@ -110,10 +112,6 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { return new Builder(); } - static Supplier runOnce(Supplier supplier) { - return new CachingSupplier<>(supplier); - } - static Supplier>> createBundlerSupplier( Supplier> sysEnvResultSupplier, BiConsumer bundler) { Objects.requireNonNull(sysEnvResultSupplier); @@ -132,6 +130,10 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { Objects.requireNonNull(app); Objects.requireNonNull(pipelineBuilder); + if (EXIT_AFTER_CONFIGURATION_PHASE.getFrom(options)) { + return; + } + final var outputDir = PathUtils.normalizedAbsolutePath(OptionUtils.outputDir(options).resolve(app.appImageDirName())); Log.verbose(I18N.getString("message.create-app-image")); @@ -173,6 +175,10 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { Objects.requireNonNull(createPipelineBuilder); Objects.requireNonNull(pipelineBuilderMutatorFactory); + if (EXIT_AFTER_CONFIGURATION_PHASE.getFrom(options)) { + return; + } + var pipelineBuilder = Objects.requireNonNull(createPipelineBuilder.apply(pkg)); // Delete an old output package file (if any) before creating a new one. @@ -198,11 +204,11 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { public void createBundle(BundlingOperationDescriptor op, Options cmdline) { final var bundler = getBundlerSupplier(op).get().orElseThrow(); Optional permanentWorkDirectory = Optional.empty(); - try (var tempDir = new TempDirectory(cmdline)) { + try (var tempDir = new TempDirectory(cmdline, Globals.instance().objectFactory())) { if (!tempDir.deleteOnClose()) { permanentWorkDirectory = Optional.of(tempDir.path()); } - bundler.accept(tempDir.options()); + bundler.accept(tempDir.map(cmdline)); } catch (IOException ex) { throw new UncheckedIOException(ex); } finally { @@ -223,25 +229,6 @@ class DefaultBundlingEnvironment implements CliBundlingEnvironment { }); } - - private static final class CachingSupplier implements Supplier { - - CachingSupplier(Supplier getter) { - this.getter = Objects.requireNonNull(getter); - } - - @Override - public T get() { - return cachedValue.updateAndGet(v -> { - return Optional.ofNullable(v).orElseGet(getter); - }); - } - - private final Supplier getter; - private final AtomicReference cachedValue = new AtomicReference<>(); - } - - private final Map>>> bundlers; private final Optional>> defaultOperationSupplier; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Executor.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Executor.java index 53c587ab37c..f9ccec7e3bb 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Executor.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Executor.java @@ -49,7 +49,7 @@ import jdk.jpackage.internal.util.CommandOutputControl.Result; import jdk.jpackage.internal.util.RetryExecutor; import jdk.jpackage.internal.util.function.ExceptionBox; -final class Executor { +public final class Executor { static Executor of(String... cmdline) { return of(List.of(cmdline)); @@ -78,118 +78,118 @@ final class Executor { mapper = other.mapper; } - Executor saveOutput(boolean v) { + public Executor saveOutput(boolean v) { commandOutputControl.saveOutput(v); return this; } - Executor saveOutput() { + public Executor saveOutput() { return saveOutput(true); } - Executor saveFirstLineOfOutput() { + public Executor saveFirstLineOfOutput() { commandOutputControl.saveFirstLineOfOutput(); return this; } - Executor charset(Charset v) { + public Executor charset(Charset v) { commandOutputControl.charset(v); return this; } - Executor storeOutputInFiles(boolean v) { + public Executor storeOutputInFiles(boolean v) { commandOutputControl.storeOutputInFiles(v); return this; } - Executor storeOutputInFiles() { + public Executor storeOutputInFiles() { return storeOutputInFiles(true); } - Executor binaryOutput(boolean v) { + public Executor binaryOutput(boolean v) { commandOutputControl.binaryOutput(v); return this; } - Executor binaryOutput() { + public Executor binaryOutput() { return binaryOutput(true); } - Executor discardStdout(boolean v) { + public Executor discardStdout(boolean v) { commandOutputControl.discardStdout(v); return this; } - Executor discardStdout() { + public Executor discardStdout() { return discardStdout(true); } - Executor discardStderr(boolean v) { + public Executor discardStderr(boolean v) { commandOutputControl.discardStderr(v); return this; } - Executor discardStderr() { + public Executor discardStderr() { return discardStderr(true); } - Executor timeout(long v, TimeUnit unit) { + public Executor timeout(long v, TimeUnit unit) { return timeout(Duration.of(v, unit.toChronoUnit())); } - Executor timeout(Duration v) { + public Executor timeout(Duration v) { timeout = v; return this; } - Executor toolProvider(ToolProvider v) { + public Executor toolProvider(ToolProvider v) { toolProvider = Objects.requireNonNull(v); processBuilder = null; return this; } - Optional toolProvider() { + public Optional toolProvider() { return Optional.ofNullable(toolProvider); } - Executor processBuilder(ProcessBuilder v) { + public Executor processBuilder(ProcessBuilder v) { processBuilder = Objects.requireNonNull(v); toolProvider = null; return this; } - Optional processBuilder() { + public Optional processBuilder() { return Optional.ofNullable(processBuilder); } - Executor args(List v) { + public Executor args(List v) { args.addAll(v); return this; } - Executor args(String... args) { + public Executor args(String... args) { return args(List.of(args)); } - List args() { + public List args() { return args; } - Executor setQuiet(boolean v) { + public Executor setQuiet(boolean v) { quietCommand = v; return this; } - Executor mapper(UnaryOperator v) { + public Executor mapper(UnaryOperator v) { mapper = v; return this; } - Optional> mapper() { + public Optional> mapper() { return Optional.ofNullable(mapper); } - Executor copy() { + public Executor copy() { return new Executor(this); } @@ -261,7 +261,7 @@ final class Executor { }); } - List commandLine() { + public List commandLine() { if (processBuilder != null) { return Stream.of(processBuilder.command(), args).flatMap(Collection::stream).toList(); } else if (toolProvider != null) { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ExecutorFactory.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ExecutorFactory.java index ce703358b82..82d81d1052e 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ExecutorFactory.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ExecutorFactory.java @@ -25,9 +25,9 @@ package jdk.jpackage.internal; @FunctionalInterface -interface ExecutorFactory { +public interface ExecutorFactory { Executor executor(); - static final ExecutorFactory DEFAULT = Executor::new; + public static final ExecutorFactory DEFAULT = Executor::new; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromOptions.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromOptions.java index cccd05792d6..4b4e6f9dbac 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromOptions.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromOptions.java @@ -49,6 +49,7 @@ import java.nio.file.Path; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.BiFunction; @@ -58,10 +59,10 @@ import jdk.jpackage.internal.model.Application; import jdk.jpackage.internal.model.ApplicationLaunchers; import jdk.jpackage.internal.model.ApplicationLayout; import jdk.jpackage.internal.model.Launcher; -import jdk.jpackage.internal.model.LauncherModularStartupInfo; import jdk.jpackage.internal.model.PackageType; import jdk.jpackage.internal.model.RuntimeLayout; import jdk.jpackage.internal.util.RootedPath; +import jdk.jpackage.internal.util.RuntimeReleaseFile; final class FromOptions { @@ -149,6 +150,13 @@ final class FromOptions { ApplicationLayout appLayout, RuntimeLayout runtimeLayout, Optional predefinedRuntimeLayout) { + Objects.requireNonNull(options); + Objects.requireNonNull(launcherCtor); + Objects.requireNonNull(launcherOverrideCtor); + Objects.requireNonNull(appLayout); + Objects.requireNonNull(runtimeLayout); + Objects.requireNonNull(predefinedRuntimeLayout); + final var appBuilder = new ApplicationBuilder(); final var isRuntimeInstaller = isRuntimeInstaller(options); @@ -185,7 +193,15 @@ final class FromOptions { } else { appBuilder.appImageLayout(appLayout); - final var launchers = createLaunchers(options, launcherCtor); + // Adjust the value of the PREDEFINED_RUNTIME_IMAGE option to make it reference + // a directory with the standard Java runtime structure. + final var launcherOptions = predefinedRuntimeDirectory.filter(v -> { + return !predefinedRuntimeImage.get().equals(v); + }).map(v -> { + return Options.of(Map.of(PREDEFINED_RUNTIME_IMAGE, v)).copyWithParent(options); + }).orElse(options); + + final var launchers = createLaunchers(launcherOptions, launcherCtor); if (PREDEFINED_APP_IMAGE.containsIn(options)) { appBuilder.launchers(launchers); @@ -196,19 +212,6 @@ final class FromOptions { runtimeBuilderBuilder.modulePath(ensureBaseModuleInModulePath(MODULE_PATH.findIn(options).orElseGet(List::of))); - if (!APP_VERSION.containsIn(options)) { - // Version is not specified explicitly. Try to get it from the app's module. - launchers.mainLauncher().startupInfo().ifPresent(startupInfo -> { - if (startupInfo instanceof LauncherModularStartupInfo modularStartupInfo) { - modularStartupInfo.moduleVersion().ifPresent(moduleVersion -> { - appBuilder.version(moduleVersion); - Log.verbose(I18N.format("message.module-version", - moduleVersion, modularStartupInfo.moduleName())); - }); - } - }); - } - predefinedRuntimeDirectory.ifPresentOrElse(runtimeBuilderBuilder::forRuntime, () -> { final var startupInfos = launchers.asList().stream() .map(Launcher::startupInfo) @@ -223,6 +226,8 @@ final class FromOptions { } } + predefinedRuntimeDirectory.map(RuntimeReleaseFile::releaseFilePathInRuntime).ifPresent(appBuilder::runtimeReleaseFile); + return appBuilder; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Globals.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Globals.java index 91ae37870a5..0128d050c25 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Globals.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Globals.java @@ -25,6 +25,9 @@ package jdk.jpackage.internal; import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Supplier; @@ -33,20 +36,35 @@ public final class Globals { private Globals() { } - Globals objectFactory(ObjectFactory v) { + public Globals objectFactory(ObjectFactory v) { checkMutable(); objectFactory = Optional.ofNullable(v).orElse(ObjectFactory.DEFAULT); return this; } - ObjectFactory objectFactory() { + public ObjectFactory objectFactory() { return objectFactory; } - Globals executorFactory(ExecutorFactory v) { + public Globals executorFactory(ExecutorFactory v) { return objectFactory(ObjectFactory.build(objectFactory).executorFactory(v).create()); } + @SuppressWarnings("unchecked") + public Optional findProperty(Object key) { + return Optional.ofNullable((T)properties.get(Objects.requireNonNull(key))); + } + + public Optional findBooleanProperty(Object key) { + return findProperty(key); + } + + public Globals setProperty(Object key, T value) { + checkMutable(); + properties.compute(Objects.requireNonNull(key), (_, _) -> value); + return this; + } + Log.Logger logger() { return logger; } @@ -79,6 +97,7 @@ public final class Globals { private ObjectFactory objectFactory = ObjectFactory.DEFAULT; private final Log.Logger logger = new Log.Logger(); + private final Map properties = new HashMap<>(); private static final ScopedValue INSTANCE = ScopedValue.newInstance(); private static final Globals DEFAULT = new Globals(); diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ModuleInfo.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ModuleInfo.java index 590321d5e86..9555423db62 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ModuleInfo.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ModuleInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,13 @@ */ package jdk.jpackage.internal; -import java.io.IOException; -import java.io.Reader; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleReference; import java.net.URI; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.Properties; -import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.RuntimeReleaseFile; record ModuleInfo(String name, Optional version, Optional mainClass, Optional location) { @@ -57,40 +52,16 @@ record ModuleInfo(String name, Optional version, Optional mainCl // We can't extract info about version and main class of a module // linked in external runtime without running ModuleFinder in that // runtime. But this is too much work as the runtime might have been - // coocked without native launchers. So just make sure the module - // is linked in the runtime by simply analysing the data + // cooked without native launchers. So just make sure the module + // is linked in the runtime by simply analyzing the data // of `release` file. - final Path releaseFile; - if (!OperatingSystem.isMacOS()) { - releaseFile = cookedRuntime.resolve("release"); - } else { - // On Mac `cookedRuntime` can be runtime root or runtime home. - Path runtimeHome = cookedRuntime.resolve("Contents/Home"); - if (!Files.isDirectory(runtimeHome)) { - runtimeHome = cookedRuntime; - } - releaseFile = runtimeHome.resolve("release"); - } - - try (Reader reader = Files.newBufferedReader(releaseFile)) { - Properties props = new Properties(); - props.load(reader); - String moduleList = props.getProperty("MODULES"); - if (moduleList == null) { + try { + var cookedRuntimeModules = RuntimeReleaseFile.loadFromRuntime(cookedRuntime).getModules(); + if (!cookedRuntimeModules.contains(moduleName)) { return Optional.empty(); } - - if ((moduleList.startsWith("\"") && moduleList.endsWith("\"")) - || (moduleList.startsWith("\'") && moduleList.endsWith( - "\'"))) { - moduleList = moduleList.substring(1, moduleList.length() - 1); - } - - if (!List.of(moduleList.split("\\s+")).contains(moduleName)) { - return Optional.empty(); - } - } catch (IOException|IllegalArgumentException ex) { + } catch (Exception ex) { Log.verbose(ex); return Optional.empty(); } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ObjectFactory.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ObjectFactory.java index f1a83eb9eab..b6a95ae539b 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ObjectFactory.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ObjectFactory.java @@ -28,38 +28,38 @@ import java.util.Objects; import java.util.Optional; import jdk.jpackage.internal.util.CompositeProxy; -interface ObjectFactory extends ExecutorFactory, RetryExecutorFactory { +public interface ObjectFactory extends ExecutorFactory, RetryExecutorFactory { - static ObjectFactory.Builder build() { + public static ObjectFactory.Builder build() { return new Builder(); } - static ObjectFactory.Builder build(ObjectFactory from) { + public static ObjectFactory.Builder build(ObjectFactory from) { return build().initFrom(from); } - static final class Builder { + public static final class Builder { private Builder() { } - ObjectFactory create() { + public ObjectFactory create() { return CompositeProxy.build().invokeTunnel(CompositeProxyTunnel.INSTANCE).create( ObjectFactory.class, Optional.ofNullable(executorFactory).orElse(ExecutorFactory.DEFAULT), Optional.ofNullable(retryExecutorFactory).orElse(RetryExecutorFactory.DEFAULT)); } - Builder initFrom(ObjectFactory of) { + public Builder initFrom(ObjectFactory of) { Objects.requireNonNull(of); return executorFactory(of).retryExecutorFactory(of); } - Builder executorFactory(ExecutorFactory v) { + public Builder executorFactory(ExecutorFactory v) { executorFactory = v; return this; } - Builder retryExecutorFactory(RetryExecutorFactory v) { + public Builder retryExecutorFactory(RetryExecutorFactory v) { retryExecutorFactory = v; return this; } @@ -68,5 +68,5 @@ interface ObjectFactory extends ExecutorFactory, RetryExecutorFactory { private RetryExecutorFactory retryExecutorFactory; } - static final ObjectFactory DEFAULT = build().create(); + public static final ObjectFactory DEFAULT = build().create(); } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionUtils.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionUtils.java index 97e1274f078..b39e67a9eb7 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionUtils.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +32,7 @@ import static jdk.jpackage.internal.cli.StandardOption.PREDEFINED_APP_IMAGE; import static jdk.jpackage.internal.cli.StandardOption.PREDEFINED_RUNTIME_IMAGE; import java.nio.file.Path; +import java.util.Objects; import jdk.jpackage.internal.cli.Options; import jdk.jpackage.internal.cli.StandardBundlingOperation; @@ -51,4 +52,8 @@ final class OptionUtils { static StandardBundlingOperation bundlingOperation(Options options) { return StandardBundlingOperation.valueOf(BUNDLING_OPERATION_DESCRIPTOR.getFrom(options)).orElseThrow(); } + + static boolean isBundlingOperation(Options options, StandardBundlingOperation op) { + return bundlingOperation(options).equals(Objects.requireNonNull(op)); + } } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionsTransformer.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionsTransformer.java index a01be089a49..f7b535b06f6 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionsTransformer.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/OptionsTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -46,7 +46,10 @@ record OptionsTransformer(Options mainOptions, Optional ext } OptionsTransformer(Options mainOptions, ApplicationLayout appLayout) { - this(mainOptions, PREDEFINED_APP_IMAGE.findIn(mainOptions).map(appLayout::resolveAt).map(AppImageFile::load)); + this(mainOptions, PREDEFINED_APP_IMAGE.findIn(mainOptions).map(appLayout::resolveAt).map(resolvedLayout -> { + var os = OptionUtils.bundlingOperation(mainOptions).os(); + return AppImageFile.load(resolvedLayout, os); + })); } Options appOptions() { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/PackageBuilder.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/PackageBuilder.java index f537a1ea0a2..8b61ef19fa2 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/PackageBuilder.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/PackageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -207,7 +207,7 @@ final class PackageBuilder { }); } - private static Path mapInstallDir(Path installDir, PackageType pkgType) { + private static Path mapInstallDir(Path installDir, PackageType type) { var ex = buildConfigException("error.invalid-install-dir", installDir).create(); if (installDir.getNameCount() == 0) { @@ -223,15 +223,17 @@ final class PackageBuilder { throw ex; } - switch (pkgType) { - case StandardPackageType.WIN_EXE, StandardPackageType.WIN_MSI -> { - if (installDir.isAbsolute()) { - throw ex; + if (type instanceof StandardPackageType stdType) { + switch (stdType) { + case WIN_EXE, WIN_MSI -> { + if (installDir.isAbsolute()) { + throw ex; + } } - } - default -> { - if (!installDir.isAbsolute()) { - throw ex; + default -> { + if (!installDir.isAbsolute()) { + throw ex; + } } } } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutorFactory.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutorFactory.java index 3efb522abd4..f18ce61fc04 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutorFactory.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutorFactory.java @@ -27,9 +27,9 @@ package jdk.jpackage.internal; import jdk.jpackage.internal.util.RetryExecutor; @FunctionalInterface -interface RetryExecutorFactory { +public interface RetryExecutorFactory { RetryExecutor retryExecutor(Class exceptionType); - static final RetryExecutorFactory DEFAULT = RetryExecutor::new; + public static final RetryExecutorFactory DEFAULT = RetryExecutor::new; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/TempDirectory.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/TempDirectory.java index 50d1701bf0d..345a42c5051 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/TempDirectory.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/TempDirectory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,29 +26,46 @@ package jdk.jpackage.internal; import java.io.Closeable; import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.TimeUnit; import jdk.jpackage.internal.cli.Options; import jdk.jpackage.internal.cli.StandardOption; import jdk.jpackage.internal.util.FileUtils; +import jdk.jpackage.internal.util.Slot; final class TempDirectory implements Closeable { - TempDirectory(Options options) throws IOException { - final var tempDir = StandardOption.TEMP_ROOT.findIn(options); - if (tempDir.isPresent()) { - this.path = tempDir.orElseThrow(); - this.options = options; - } else { - this.path = Files.createTempDirectory("jdk.jpackage"); - this.options = options.copyWithDefaultValue(StandardOption.TEMP_ROOT, path); - } - - deleteOnClose = tempDir.isEmpty(); + TempDirectory(Options options, RetryExecutorFactory retryExecutorFactory) throws IOException { + this(StandardOption.TEMP_ROOT.findIn(options), retryExecutorFactory); } - Options options() { - return options; + TempDirectory(Optional tempDir, RetryExecutorFactory retryExecutorFactory) throws IOException { + this(tempDir.isEmpty() ? Files.createTempDirectory("jdk.jpackage") : tempDir.get(), + tempDir.isEmpty(), + retryExecutorFactory); + } + + TempDirectory(Path tempDir, boolean deleteOnClose, RetryExecutorFactory retryExecutorFactory) throws IOException { + this.path = Objects.requireNonNull(tempDir); + this.deleteOnClose = deleteOnClose; + this.retryExecutorFactory = Objects.requireNonNull(retryExecutorFactory); + } + + Options map(Options options) { + if (deleteOnClose) { + return options.copyWithDefaultValue(StandardOption.TEMP_ROOT, path); + } else { + return options; + } } Path path() { @@ -62,11 +79,107 @@ final class TempDirectory implements Closeable { @Override public void close() throws IOException { if (deleteOnClose) { - FileUtils.deleteRecursive(path); + retryExecutorFactory.retryExecutor(IOException.class) + .setMaxAttemptsCount(5) + .setAttemptTimeout(2, TimeUnit.SECONDS) + .setExecutable(context -> { + try { + FileUtils.deleteRecursive(path); + } catch (IOException ex) { + if (!context.isLastAttempt()) { + throw ex; + } else { + // Collect the list of leftover files. Collect at most the first 100 files. + var remainingFiles = DirectoryListing.listFilesAndEmptyDirectories( + path, MAX_REPORTED_UNDELETED_FILE_COUNT).paths(); + + if (remainingFiles.equals(List.of(path))) { + Log.info(I18N.format("warning.tempdir.cleanup-failed", path)); + } else { + remainingFiles.forEach(file -> { + Log.info(I18N.format("warning.tempdir.cleanup-file-failed", file)); + }); + } + + Log.verbose(ex); + } + } + return null; + }).execute(); + } + } + + record DirectoryListing(List paths, boolean complete) { + DirectoryListing { + Objects.requireNonNull(paths); + } + + static DirectoryListing listFilesAndEmptyDirectories(Path path, int limit) { + Objects.requireNonNull(path); + if (limit < 0) { + throw new IllegalArgumentException(); + } else if (limit == 0) { + return new DirectoryListing(List.of(), !Files.exists(path)); + } + + var paths = new ArrayList(); + var stopped = Slot.createEmpty(); + + stopped.set(false); + + try { + Files.walkFileTree(path, new FileVisitor<>() { + + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { + try (var walk = Files.walk(dir)) { + if (walk.skip(1).findAny().isEmpty()) { + // This is an empty directory, add it to the list. + return addPath(dir, FileVisitResult.SKIP_SUBTREE); + } + } catch (IOException ex) { + Log.verbose(ex); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + return addPath(file, FileVisitResult.CONTINUE); + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + return addPath(file, FileVisitResult.CONTINUE); + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { + return FileVisitResult.CONTINUE; + } + + private FileVisitResult addPath(Path v, FileVisitResult result) { + if (paths.size() < limit) { + paths.add(v); + return result; + } else { + stopped.set(true); + } + return FileVisitResult.TERMINATE; + } + + }); + } catch (IOException ex) { + Log.verbose(ex); + } + + return new DirectoryListing(Collections.unmodifiableList(paths), !stopped.get()); } } private final Path path; - private final Options options; private final boolean deleteOnClose; + private final RetryExecutorFactory retryExecutorFactory; + + private final static int MAX_REPORTED_UNDELETED_FILE_COUNT = 100; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ToolValidator.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ToolValidator.java index 9440aff3a53..13a9e05e934 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ToolValidator.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ToolValidator.java @@ -33,7 +33,6 @@ import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Stream; -import jdk.internal.util.OperatingSystem; import jdk.jpackage.internal.model.ConfigException; import jdk.jpackage.internal.model.DottedVersion; @@ -46,9 +45,6 @@ final class ToolValidator { ToolValidator(Path toolPath) { this.toolPath = Objects.requireNonNull(toolPath); - if (OperatingSystem.isLinux()) { - setCommandLine("--version"); - } } ToolValidator setCommandLine(String... args) { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/Main.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/Main.java index d40895a7da6..5789203c3e9 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/Main.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/Main.java @@ -64,14 +64,15 @@ import jdk.jpackage.internal.util.function.ExceptionBox; */ public final class Main { - public record Provider(Supplier bundlingEnvSupplier) implements ToolProvider { + public record Provider(Supplier bundlingEnvSupplier, OperatingSystem os) implements ToolProvider { public Provider { Objects.requireNonNull(bundlingEnvSupplier); + Objects.requireNonNull(os); } public Provider() { - this(DefaultBundlingEnvironmentLoader.INSTANCE); + this(DefaultBundlingEnvironmentLoader.INSTANCE, OperatingSystem.current()); } @Override @@ -81,7 +82,7 @@ public final class Main { @Override public int run(PrintWriter out, PrintWriter err, String... args) { - return Main.run(bundlingEnvSupplier, out, err, args); + return Main.run(os, bundlingEnvSupplier, out, err, args); } @Override @@ -107,25 +108,29 @@ public final class Main { public static void main(String... args) { var out = toPrintWriter(System.out); var err = toPrintWriter(System.err); - System.exit(run(out, err, args)); + System.exit(run(OperatingSystem.current(), DefaultBundlingEnvironmentLoader.INSTANCE, out, err, args)); } - static int run(PrintWriter out, PrintWriter err, String... args) { - return run(DefaultBundlingEnvironmentLoader.INSTANCE, out, err, args); - } - - static int run(Supplier bundlingEnvSupplier, PrintWriter out, PrintWriter err, String... args) { - return Globals.main(() -> { - return runWithGlobals(bundlingEnvSupplier, out, err, args); - }); - } - - private static int runWithGlobals( + static int run( + OperatingSystem os, Supplier bundlingEnvSupplier, PrintWriter out, PrintWriter err, String... args) { + return Globals.main(() -> { + return runWithGlobals(os, bundlingEnvSupplier, out, err, args); + }); + } + + private static int runWithGlobals( + OperatingSystem os, + Supplier bundlingEnvSupplier, + PrintWriter out, + PrintWriter err, + String... args) { + + Objects.requireNonNull(os); Objects.requireNonNull(bundlingEnvSupplier); Objects.requireNonNull(args); for (String arg : args) { @@ -162,7 +167,7 @@ public final class Main { final var bundlingEnv = bundlingEnvSupplier.get(); - final var parseResult = Utils.buildParser(OperatingSystem.current(), bundlingEnv).create().apply(mappedArgs.get()); + final var parseResult = Utils.buildParser(os, bundlingEnv).create().apply(mappedArgs.get()); return runner.run(() -> { final var parsedOptionsBuilder = parseResult.orElseThrow(); @@ -189,7 +194,7 @@ public final class Main { Globals.instance().loggerVerbose(); } - final var optionsProcessor = new OptionsProcessor(parsedOptionsBuilder, bundlingEnv); + final var optionsProcessor = new OptionsProcessor(parsedOptionsBuilder, os, bundlingEnv); final var validationResult = optionsProcessor.validate(); diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsAnalyzer.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsAnalyzer.java index 6c32a3d1569..fb1dd20df92 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsAnalyzer.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsAnalyzer.java @@ -63,8 +63,8 @@ import jdk.jpackage.internal.model.BundleType; */ final class OptionsAnalyzer { - OptionsAnalyzer(Options cmdline, BundlingEnvironment bundlingEnv) { - this(cmdline, getBundlingOperation(cmdline, OperatingSystem.current(), bundlingEnv), false); + OptionsAnalyzer(Options cmdline, OperatingSystem os, BundlingEnvironment bundlingEnv) { + this(cmdline, getBundlingOperation(cmdline, os, bundlingEnv), false); } OptionsAnalyzer(Options cmdline, StandardBundlingOperation bundlingOperation) { @@ -291,17 +291,17 @@ final class OptionsAnalyzer { return bundlingOperations.getFirst(); } else { // Multiple standard bundling operations produce the `bundleType` bundle type. - // Filter those that belong to the current OS + // Filter those that belong to the specified OS. bundlingOperations = bundlingOperations.stream().filter(op -> { - return op.os().equals(OperatingSystem.current()); + return op.os().equals(os); }).toList(); if (bundlingOperations.isEmpty()) { // jpackage internal error: none of the standard bundling operations produce - // bundles of the `bundleType` on the current OS. + // bundles of the `bundleType` on the specified OS. throw new AssertionError(String.format( "None of the standard bundling operations produce bundles of type [%s] on %s", - bundleType, OperatingSystem.current())); + bundleType, os)); } else if (bundlingOperations.size() == 1) { return bundlingOperations.getFirst(); } else if (StandardBundlingOperation.MACOS_APP_IMAGE.containsAll(bundlingOperations)) { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsProcessor.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsProcessor.java index 3c0eab77f8a..387c36ea416 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsProcessor.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/OptionsProcessor.java @@ -62,8 +62,9 @@ import jdk.jpackage.internal.util.Result; */ final class OptionsProcessor { - OptionsProcessor(OptionsBuilder optionsBuilder, CliBundlingEnvironment bundlingEnv) { + OptionsProcessor(OptionsBuilder optionsBuilder, OperatingSystem os, CliBundlingEnvironment bundlingEnv) { this.optionsBuilder = Objects.requireNonNull(optionsBuilder); + this.os = Objects.requireNonNull(os); this.bundlingEnv = Objects.requireNonNull(bundlingEnv); } @@ -88,7 +89,7 @@ final class OptionsProcessor { final var untypedOptions = optionsBuilder.create(); // Create command line structure analyzer. - final var analyzerResult = Result.of(() -> new OptionsAnalyzer(untypedOptions, bundlingEnv)); + final var analyzerResult = Result.of(() -> new OptionsAnalyzer(untypedOptions, os, bundlingEnv)); if (analyzerResult.hasErrors()) { // Failed to derive the bundling operation from the command line. allErrors.addAll(analyzerResult.mapErrors().errors()); @@ -419,6 +420,7 @@ final class OptionsProcessor { private final JOptSimpleOptionsBuilder.OptionsBuilder optionsBuilder; + private final OperatingSystem os; private final CliBundlingEnvironment bundlingEnv; private static final OptionValue> ADD_LAUNCHER_INTERNAL = diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardOption.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardOption.java index 4450a6168e2..f193cff0dc0 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardOption.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardOption.java @@ -58,9 +58,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.cli.OptionValueExceptionFactory.StandardArgumentsMapper; import jdk.jpackage.internal.model.AppImageBundleType; import jdk.jpackage.internal.model.BundleType; import jdk.jpackage.internal.model.BundlingOperationDescriptor; +import jdk.jpackage.internal.model.ConfigException; import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.LauncherShortcut; import jdk.jpackage.internal.model.LauncherShortcutStartupDirectory; @@ -109,7 +111,7 @@ public final class StandardOption { public static final OptionValue VERBOSE = auxilaryOption("verbose").create(); - public static final OptionValue TYPE = option("type", BundleType.class).addAliases("t") + static final OptionValue TYPE = option("type", BundleType.class).addAliases("t") .scope(StandardBundlingOperation.values()).inScope(NOT_BUILDING_APP_IMAGE) .converterExceptionFactory(ERROR_WITH_VALUE).converterExceptionFormatString("ERR_InvalidInstallerType") .converter(str -> { @@ -342,7 +344,7 @@ public final class StandardOption { public static final OptionValue MAC_SIGN = booleanOption("mac-sign").scope(MAC_SIGNING).addAliases("s").create(); - public static final OptionValue MAC_APP_STORE = booleanOption("mac-app-store").create(); + public static final OptionValue MAC_APP_STORE = booleanOption("mac-app-store").scope(MAC_SIGNING).create(); public static final OptionValue MAC_APP_CATEGORY = stringOption("mac-app-category").create(); @@ -352,6 +354,11 @@ public final class StandardOption { public static final OptionValue MAC_BUNDLE_IDENTIFIER = stringOption("mac-package-identifier") .valuePattern("package identifier") + .validator(StandardValidator.IS_VALID_MAC_BUNDLE_IDENTIFIER) + .validatorExceptionFactory(OptionValueExceptionFactory.build((message, cause) -> { + return new ConfigException(message, I18N.format("error.parameter-not-mac-bundle-identifier.advice"), cause); + }).formatArgumentsTransformer(StandardArgumentsMapper.VALUE_AND_NAME).create()) + .validatorExceptionFormatString("error.parameter-not-mac-bundle-identifier") .create(); public static final OptionValue MAC_BUNDLE_SIGNING_PREFIX = stringOption("mac-package-signing-prefix").scope(MAC_SIGNING).create(); @@ -400,6 +407,8 @@ public final class StandardOption { public static final OptionValue WIN_INSTALLDIR_CHOOSER = booleanOption("win-dir-chooser").scope(nativeBundling()).create(); + public static final OptionValue WIN_WITH_UI = booleanOption("win-with-ui").scope(nativeBundling()).create(); + public static final OptionValue WIN_UPGRADE_UUID = uuidOption("win-upgrade-uuid").scope(nativeBundling()).create(); public static final OptionValue WIN_CONSOLE_HINT = booleanOption("win-console") @@ -434,6 +443,12 @@ public final class StandardOption { public static final OptionValue BUNDLING_OPERATION_DESCRIPTOR = OptionValue.create(); + /** + * Debug option telling bundler to exit after the configuration phase is over, + * without running the packaging phase. + */ + public static final OptionValue EXIT_AFTER_CONFIGURATION_PHASE = OptionValue.build().defaultValue(false).create(); + /** * Returns options configuring a launcher. * diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardValidator.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardValidator.java index cfa97439592..ee9f39ee9cd 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardValidator.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/StandardValidator.java @@ -36,11 +36,12 @@ import java.nio.file.Path; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.regex.Pattern; import jdk.jpackage.internal.cli.Validator.ValidatingConsumerException; import jdk.jpackage.internal.util.FileUtils; import jdk.jpackage.internal.util.MacBundle; -final public class StandardValidator { +public final class StandardValidator { private StandardValidator() { } @@ -143,6 +144,9 @@ final public class StandardValidator { return MacBundle.fromPath(path).isPresent(); }; + // https://developer.apple.com/documentation/BundleResources/Information-Property-List/CFBundleIdentifier + public static final Predicate IS_VALID_MAC_BUNDLE_IDENTIFIER = Pattern.compile("[\\p{Alnum}-\\.]+").asMatchPredicate(); + public static final class DirectoryListingIOException extends RuntimeException { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java index b49cbb025e9..8071f182801 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,12 +37,11 @@ import java.util.stream.Stream; public final class DottedVersion { private DottedVersion(String version, boolean greedy) { - this.value = version; if (version.isEmpty()) { if (greedy) { throw new IllegalArgumentException(I18N.getString("error.version-string-empty")); } else { - this.components = new BigInteger[0]; + this.components = new Component[0]; this.suffix = ""; } } else { @@ -53,12 +52,12 @@ public final class DottedVersion { if (!greedy) { return null; } else { - ds.throwException(); + throw ds.createException(); } } try { - return new BigInteger(digits); + return new Component(digits); } catch (NumberFormatException ex) { if (!greedy) { return null; @@ -68,17 +67,25 @@ public final class DottedVersion { digits)); } } - }).takeWhile(Objects::nonNull).toArray(BigInteger[]::new); + }).takeWhile(Objects::nonNull).toArray(Component[]::new); suffix = ds.getUnprocessedString(); if (!suffix.isEmpty() && greedy) { - ds.throwException(); + throw ds.createException(); } } } + private DottedVersion(Component[] components, String suffix) { + this.components = components; + this.suffix = suffix; + } + private static class DigitsSupplier { DigitsSupplier(String input) { + if (input.isEmpty()) { + throw new IllegalArgumentException(); + } this.input = input; } @@ -95,7 +102,7 @@ public final class DottedVersion { } else { var curStopAtDot = (chr == '.'); if (!curStopAtDot) { - if (lastDotPos >= 0) { + if (sb.isEmpty() && lastDotPos >= 0) { cursor = lastDotPos; } else { cursor--; @@ -112,11 +119,7 @@ public final class DottedVersion { } if (sb.isEmpty()) { - if (lastDotPos >= 0) { - cursor = lastDotPos; - } else { - cursor--; - } + cursor = lastDotPos; } stoped = true; @@ -127,7 +130,7 @@ public final class DottedVersion { return input.substring(cursor); } - void throwException() { + IllegalArgumentException createException() { final String tail; if (lastDotPos >= 0) { tail = input.substring(lastDotPos + 1); @@ -143,7 +146,7 @@ public final class DottedVersion { errMessage = MessageFormat.format(I18N.getString( "error.version-string-invalid-component"), input, tail); } - throw new IllegalArgumentException(errMessage); + return new IllegalArgumentException(errMessage); } private int cursor; @@ -211,9 +214,31 @@ public final class DottedVersion { return Arrays.deepEquals(this.components, other.components); } + public DottedVersion trim(int limit) { + if (limit < 0) { + throw new IllegalArgumentException(); + } else if (limit >= components.length) { + return this; + } else { + return new DottedVersion(Arrays.copyOf(components, limit), suffix); + } + } + + public DottedVersion pad(int limit) { + if (limit < 0) { + throw new IllegalArgumentException(); + } else if (limit <= components.length) { + return this; + } else { + var newComponents = Arrays.copyOf(components, limit); + Arrays.fill(newComponents, components.length, newComponents.length, Component.ZERO); + return new DottedVersion(newComponents, suffix); + } + } + @Override public String toString() { - return value; + return Stream.of(components).map(Component::toString).collect(Collectors.joining(".")) + suffix; } public String getUnprocessedSuffix() { @@ -221,14 +246,35 @@ public final class DottedVersion { } public String toComponentsString() { - return Stream.of(components).map(BigInteger::toString).collect(Collectors.joining(".")); + return Stream.of(components).map(Component::parsedValue).map(BigInteger::toString).collect(Collectors.joining(".")); + } + + public int getComponentsCount() { + return components.length; } public BigInteger[] getComponents() { - return components; + return Stream.of(components).map(Component::parsedValue).toArray(BigInteger[]::new); } - private final BigInteger[] components; - private final String value; + private record Component(BigInteger parsedValue, String strValue) { + Component { + Objects.requireNonNull(parsedValue); + Objects.requireNonNull(strValue); + } + + Component(String strValue) { + this(new BigInteger(strValue), strValue); + } + + @Override + public String toString() { + return strValue; + } + + static final Component ZERO = new Component(BigInteger.ZERO, "0"); + } + + private final Component[] components; private final String suffix; } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties index 466f58ee68e..7f570e71330 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2026, 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 @@ -405,20 +405,24 @@ help.option.win-help-url=\ \ URL where user can obtain further information or technical support help.option.win-menu=\ -\ Request to add a Start menu shortcut for this application +\ Adds a Start menu shortcut for this application, or requests\n\ +\ to do so if --win-shortcut-prompt is specified help.option.win-menu-group=\ \ Start Menu group this application is placed in help.option.win-per-user-install=\ -\ Request to perform an install on a per-user basis +\ Installs the application on a per-user basis.\n\ +\ Without this option installs per-machine help.option.win-shortcut=\ -\ Request to add desktop shortcut for this application +\ Adds a desktop shortcut for this application, or requests\n\ +\ to do so if --win-shortcut-prompt is specified help.option.win-shortcut-prompt=\ -\ Adds a dialog to enable the user to choose if shortcuts\n\ -\ will be created by installer. +\ Adds a dialog if at least one of --win-menu or --win-shortcut\n\ +\ are specified to enable the user to choose if these shortcuts\n\ +\ will be created by the installer help.option.win-update-url=\ \ URL of available application update information @@ -426,3 +430,5 @@ help.option.win-update-url=\ help.option.win-upgrade-uuid=\ \ UUID associated with upgrades for this package +help.option.win-with-ui=\ +\ Enforces the installer to have UI diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties index 6e5de3d9729..9dfd13d60bb 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties @@ -52,6 +52,8 @@ message.app-image-created=Succeeded in building output application image directo message.debug-working-directory=Kept working directory for debug: {0} message.module-version=Using version "{0}" from module "{1}" as application version +message.release-version=Using version "{0}" from "release" file of the predefined runtime as a package version +message.version-normalized=Using version "{0}" normalized to platform supported format from "{1}" message.error-header=Error: {0} message.advice-header=Advice to fix: {0} @@ -86,6 +88,8 @@ error.parameter-not-empty-directory=The value "{0}" provided for parameter {1} i error.parameter-not-url=The value "{0}" provided for parameter {1} is not a valid URL error.parameter-not-launcher-shortcut-dir=The value "{0}" provided for parameter {1} is not a valid shortcut startup directory error.parameter-not-mac-bundle=The value "{0}" provided for parameter {1} is not a valid macOS bundle +error.parameter-not-mac-bundle-identifier=The value "{0}" provided for parameter {1} is not a valid macOS bundle identifier. +error.parameter-not-mac-bundle-identifier.advice=Bundle identifier must be a non-empty string containing only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.) error.path-parameter-ioexception=I/O error accessing path value "{0}" of parameter {1} error.parameter-add-launcher-malformed=The value "{0}" provided for parameter {1} does not match the pattern = error.parameter-add-launcher-not-file=The value of path to a property file "{0}" provided for additional launcher "{1}" is not a valid file path @@ -109,6 +113,9 @@ error.tool-not-found.advice=Please install "{0}" error.tool-old-version=Can not find "{0}" {1} or newer error.tool-old-version.advice=Please install "{0}" {1} or newer +warning.tempdir.cleanup-failed=Warning: Failed to clean-up temporary directory {0} +warning.tempdir.cleanup-file-failed=Warning: Failed to delete "{0}" file in the temporary directory + error.output-bundle-cannot-be-overwritten=Output package file "{0}" exists and can not be removed. error.blocked.option=jlink option [{0}] is not permitted in --jlink-options diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/MemoizingSupplier.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/MemoizingSupplier.java new file mode 100644 index 00000000000..2974c498867 --- /dev/null +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/MemoizingSupplier.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.util; + +import jdk.jpackage.internal.util.function.ExceptionBox; +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.function.Supplier; + +public final class MemoizingSupplier implements Supplier { + + public MemoizingSupplier(Supplier supplier) { + this.future = new FutureTask<>(Objects.requireNonNull(supplier)::get); + } + + @Override + public T get() { + try { + future.run(); + return future.get(); + } catch (InterruptedException ex) { + throw ExceptionBox.toUnchecked(ex); + } catch (ExecutionException ex) { + throw ExceptionBox.toUnchecked(ExceptionBox.unbox(ex.getCause())); + } + } + + public static Supplier runOnce(Supplier supplier) { + return new MemoizingSupplier<>(supplier); + } + + private final FutureTask future; +} diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/RuntimeReleaseFile.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/RuntimeReleaseFile.java new file mode 100644 index 00000000000..e055417f391 --- /dev/null +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/RuntimeReleaseFile.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.util; + +import java.io.IOException; +import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.Properties; + +public final class RuntimeReleaseFile { + + public RuntimeReleaseFile(Path releaseFilePath) throws IOException { + // The implementation is based on the behavior of + // jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin, which + // uses java.util.Properties to read/write the "release" file. + try (Reader reader = Files.newBufferedReader(releaseFilePath)) { + props = new Properties(); + props.load(reader); + } + } + + /** + * Returns path to the "runtime" file in the specified runtime directory. + * + * @param runtimeDir the path to a directory with the standard Java runtime + * structure + */ + public static Path releaseFilePathInRuntime(Path runtimeDir) { + return runtimeDir.resolve("release"); + } + + /** + * Creates the instance form the "runtime" file in the specified runtime + * directory. + *

    + * Uses {@link #releaseFilePathInRuntime(Path)} to get the path to the "runtime" + * file in the specified runtime directory. + * + * @param runtimeDir the path to a directory with the standard Java runtime + * structure + */ + public static RuntimeReleaseFile loadFromRuntime(Path runtimeDir) throws IOException { + return new RuntimeReleaseFile(releaseFilePathInRuntime(runtimeDir)); + } + + /** + * Returns verbatim value of the property with the specified name or an empty + * {@code Optional} if there is no property with the specified name. + *

    + * Property values in the "release" file are enclosed in double quotes. + * This method returns the value with the double quotes. + * + * @param propertyName the property name + */ + public Optional findRawProperty(String propertyName) { + return Optional.ofNullable(props.getProperty(propertyName)); + } + + /** + * Returns unquoted value of the property with the specified name or an empty + * {@code Optional} if there is no property with the specified name. + *

    + * Property values in the "release" file are enclosed in double quotes. This + * method returns the value without the double quotes. + * + * @param propertyName the property name + */ + public Optional findProperty(String propertyName) { + return findRawProperty(propertyName).map(v -> { + if (v.charAt(0) == '"' && v.charAt(v.length() - 1) == '"') { + return v.substring(1, v.length() - 1); + } else { + return v; + } + }); + } + + /** + * Returns the value of the "JAVA_VERSION" property. + *

    + * Will throw {@code NoSuchElementException} if there is no such property. Will + * use {@link Runtime.Version#parse(String)} method to parse version string. Any + * exception that it may yield will be passed to the caller verbatim. + * + * @throws NoSuchElementException if there is no such property + */ + public Runtime.Version getJavaVersion() { + return findProperty("JAVA_VERSION").map(Runtime.Version::parse).orElseThrow(NoSuchElementException::new); + } + + /** + * Returns the value of the "MODULES" property. + * + * @throws NoSuchElementException if there is no such property + */ + public List getModules() { + return findProperty("MODULES").map(v -> { + return List.of(v.split("\\s+")); + }).orElseThrow(NoSuchElementException::new); + } + + private final Properties props; +} diff --git a/src/jdk.jpackage/share/man/jpackage.md b/src/jdk.jpackage/share/man/jpackage.md index f78bec9808c..156b05307b7 100644 --- a/src/jdk.jpackage/share/man/jpackage.md +++ b/src/jdk.jpackage/share/man/jpackage.md @@ -1,5 +1,5 @@ --- -# Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -410,7 +410,8 @@ The `jpackage` tool will take as input a Java application and a Java run-time im `--win-menu` -: Request to add a Start Menu shortcut for this application +: Adds a Start menu shortcut for this application, or requests to do so + if --win-shortcut-prompt is specified `--win-menu-group` *menu-group-name* @@ -418,15 +419,17 @@ The `jpackage` tool will take as input a Java application and a Java run-time im `--win-per-user-install` -: Request to perform an install on a per-user basis +: Installs the application on a per-user basis. Without this option installs per-machine `--win-shortcut` -: Request to create a desktop shortcut for this application +: Adds a desktop shortcut for this application, or requests to do so + if --win-shortcut-prompt is specified `--win-shortcut-prompt` -: Adds a dialog to enable the user to choose if shortcuts will be created by installer +: Adds a dialog if at least one of --win-menu or --win-shortcut are specified + to enable the user to choose if these shortcuts will be created by the installer `--win-update-url` *url* @@ -436,6 +439,10 @@ The `jpackage` tool will take as input a Java application and a Java run-time im : UUID associated with upgrades for this package +`--win-with-ui` + +: Enforces the installer to have UI + #### Linux platform options (available only when running on Linux): `--linux-package-name` *name* diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/ExecutableRebrander.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/ExecutableRebrander.java index 05b87e6f449..ec2a96d4c7d 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/ExecutableRebrander.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/ExecutableRebrander.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,9 +40,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Properties; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Stream; import jdk.jpackage.internal.model.DottedVersion; +import jdk.jpackage.internal.model.JPackageException; import jdk.jpackage.internal.model.WinApplication; import jdk.jpackage.internal.model.WinExePackage; import jdk.jpackage.internal.model.WinLauncher; @@ -74,11 +76,11 @@ final class ExecutableRebrander { this.props = new HashMap<>(); - validateValueAndPut(this.props, Map.entry("COMPANY_NAME", props.vendor), "vendor"); - validateValueAndPut(this.props, Map.entry("FILE_DESCRIPTION",props.description), "description"); - validateValueAndPut(this.props, Map.entry("FILE_VERSION", props.version.toString()), "version"); - validateValueAndPut(this.props, Map.entry("LEGAL_COPYRIGHT", props.copyright), "copyright"); - validateValueAndPut(this.props, Map.entry("PRODUCT_NAME", props.name), "name"); + this.props.put("COMPANY_NAME", validateSingleLine(props.vendor)); + this.props.put("FILE_DESCRIPTION", validateSingleLine(props.description)); + this.props.put("FILE_VERSION", validateSingleLine(props.version.toString())); + this.props.put("LEGAL_COPYRIGHT", validateSingleLine(props.copyright)); + this.props.put("PRODUCT_NAME", validateSingleLine(props.name)); this.props.put("FIXEDFILEINFO_FILE_VERSION", toFixedFileVersion(props.version)); this.props.put("INTERNAL_NAME", props.executableName); @@ -90,7 +92,7 @@ final class ExecutableRebrander { UpdateResourceAction versionSwapper = resourceLock -> { if (versionSwap(resourceLock, propsArray) != 0) { - throw I18N.buildException().message("error.version-swap", target).create(RuntimeException::new); + throw new JPackageException(I18N.format("error.version-swap", target)); } }; @@ -100,7 +102,7 @@ final class ExecutableRebrander { .map(absIcon -> { return resourceLock -> { if (iconSwap(resourceLock, absIcon.toString()) != 0) { - throw I18N.buildException().message("error.icon-swap", absIcon).create(RuntimeException::new); + throw new JPackageException(I18N.format("error.icon-swap", absIcon)); } }; }); @@ -118,43 +120,58 @@ final class ExecutableRebrander { private static void rebrandExecutable(BuildEnv env, final Path target, List actions) throws IOException { + + Objects.requireNonNull(env); + Objects.requireNonNull(target); Objects.requireNonNull(actions); actions.forEach(Objects::requireNonNull); - String tempDirectory = env.buildRoot().toAbsolutePath().toString(); - if (WindowsDefender.isThereAPotentialWindowsDefenderIssue(tempDirectory)) { - Log.verbose(I18N.format("message.potential.windows.defender.issue", tempDirectory)); - } - - var shortTargetPath = ShortPathUtils.toShortPath(target); - long resourceLock = lockResource(shortTargetPath.orElse(target).toString()); - if (resourceLock == 0) { - throw I18N.buildException().message("error.lock-resource", shortTargetPath.orElse(target)).create(RuntimeException::new); - } - - final boolean resourceUnlockedSuccess; try { - for (var action : actions) { - action.editResource(resourceLock); - } - } finally { - if (resourceLock == 0) { - resourceUnlockedSuccess = true; - } else { - resourceUnlockedSuccess = unlockResource(resourceLock); - if (shortTargetPath.isPresent()) { - // Windows will rename the executable in the unlock operation. - // Should restore executable's name. - var tmpPath = target.getParent().resolve( - target.getFileName().toString() + ".restore"); - Files.move(shortTargetPath.get(), tmpPath); - Files.move(tmpPath, target); - } - } - } + Globals.instance().objectFactory().retryExecutor(RuntimeException.class).setExecutable(() -> { - if (!resourceUnlockedSuccess) { - throw I18N.buildException().message("error.unlock-resource", target).create(RuntimeException::new); + var shortTargetPath = ShortPathUtils.toShortPath(target); + long resourceLock = lockResource(shortTargetPath.orElse(target).toString()); + if (resourceLock == 0) { + throw new JPackageException(I18N.format("error.lock-resource", shortTargetPath.orElse(target))); + } + + final boolean resourceUnlockedSuccess; + try { + for (var action : actions) { + try { + action.editResource(resourceLock); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + } finally { + if (resourceLock == 0) { + resourceUnlockedSuccess = true; + } else { + resourceUnlockedSuccess = unlockResource(resourceLock); + if (shortTargetPath.isPresent()) { + // Windows will rename the executable in the unlock operation. + // Should restore executable's name. + var tmpPath = target.getParent().resolve( + target.getFileName().toString() + ".restore"); + try { + Files.move(shortTargetPath.get(), tmpPath); + Files.move(tmpPath, target); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + } + } + + if (!resourceUnlockedSuccess) { + throw new JPackageException(I18N.format("error.unlock-resource", shortTargetPath.orElse(target))); + } + + return null; + }).setMaxAttemptsCount(5).setAttemptTimeout(3, TimeUnit.SECONDS).execute(); + } catch (UncheckedIOException ex) { + throw ex.getCause(); } } @@ -197,14 +214,13 @@ final class ExecutableRebrander { } } - private static void validateValueAndPut(Map target, - Map.Entry e, String label) { - if (e.getValue().contains("\r") || e.getValue().contains("\n")) { - Log.error("Configuration parameter " + label - + " contains multiple lines of text, ignore it"); - e = Map.entry(e.getKey(), ""); + private static String validateSingleLine(String v) { + Objects.requireNonNull(v); + if (v.contains("\r") || v.contains("\n")) { + throw new IllegalArgumentException("Configuration parameter contains multiple lines of text"); + } else { + return v; } - target.put(e.getKey(), e.getValue()); } @FunctionalInterface @@ -212,19 +228,35 @@ final class ExecutableRebrander { public void editResource(long resourceLock) throws IOException; } - private static record ExecutableProperties(String vendor, String description, + private record ExecutableProperties(String vendor, String description, DottedVersion version, String copyright, String name, String executableName) { - static ExecutableProperties create(WinApplication app, - WinLauncher launcher) { - return new ExecutableProperties(app.vendor(), launcher.description(), - app.winVersion(), app.copyright(), launcher.name(), + + ExecutableProperties { + Objects.requireNonNull(vendor); + Objects.requireNonNull(description); + Objects.requireNonNull(version); + Objects.requireNonNull(copyright); + Objects.requireNonNull(name); + Objects.requireNonNull(executableName); + } + + static ExecutableProperties create(WinApplication app, WinLauncher launcher) { + return new ExecutableProperties( + app.vendor(), + launcher.description(), + app.winVersion(), + app.copyright(), + launcher.name(), launcher.executableNameWithSuffix()); } static ExecutableProperties create(WinExePackage pkg) { - return new ExecutableProperties(pkg.app().vendor(), - pkg.description(), DottedVersion.lazy(pkg.version()), - pkg.app().copyright(), pkg.packageName(), + return new ExecutableProperties( + pkg.app().vendor(), + pkg.description(), + DottedVersion.lazy(pkg.version()), + pkg.app().copyright(), + pkg.packageName(), pkg.packageFileNameWithSuffix()); } } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/MsiMutator.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/MsiMutator.java new file mode 100644 index 00000000000..592cc55c0df --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/MsiMutator.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021, 2026, 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.jpackage.internal; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; +import jdk.jpackage.internal.resources.ResourceLocator; + +/** + * WSH script altering cooked .msi file. + */ +record MsiMutator(String scriptResourceName) { + + MsiMutator { + Objects.requireNonNull(scriptResourceName); + if (Path.of(scriptResourceName).getNameCount() != 1) { + throw new IllegalArgumentException(); + } + } + + void addToConfigRoot(Path configRoot) throws IOException { + var scriptFile = configRoot.resolve(pathInConfigRoot()); + try (var in = ResourceLocator.class.getResourceAsStream(scriptResourceName)) { + Files.createDirectories(scriptFile.getParent()); + Files.copy(in, scriptFile); + } + } + + Path pathInConfigRoot() { + return Path.of(scriptResourceName); + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinBundlingEnvironment.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinBundlingEnvironment.java index de52a222d7d..e10bfb95abf 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinBundlingEnvironment.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinBundlingEnvironment.java @@ -29,6 +29,7 @@ import static jdk.jpackage.internal.WinPackagingPipeline.APPLICATION_LAYOUT; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_WIN_APP_IMAGE; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_WIN_EXE; import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_WIN_MSI; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import jdk.jpackage.internal.cli.Options; diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinFromOptions.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinFromOptions.java index 6009e2f6724..59701777396 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinFromOptions.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinFromOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,9 +39,11 @@ import static jdk.jpackage.internal.cli.StandardOption.WIN_SHORTCUT_HINT; import static jdk.jpackage.internal.cli.StandardOption.WIN_SHORTCUT_PROMPT; import static jdk.jpackage.internal.cli.StandardOption.WIN_UPDATE_URL; import static jdk.jpackage.internal.cli.StandardOption.WIN_UPGRADE_UUID; +import static jdk.jpackage.internal.cli.StandardOption.WIN_WITH_UI; import static jdk.jpackage.internal.model.StandardPackageType.WIN_MSI; import jdk.jpackage.internal.cli.Options; +import jdk.jpackage.internal.model.DottedVersion; import jdk.jpackage.internal.model.Launcher; import jdk.jpackage.internal.model.WinApplication; import jdk.jpackage.internal.model.WinExePackage; @@ -73,6 +75,8 @@ final class WinFromOptions { appBuilder.launchers().map(WinPackagingPipeline::normalizeShortcuts).ifPresent(appBuilder::launchers); + appBuilder.derivedVersionNormalizer(WinFromOptions::normalizeVersion); + return WinApplication.create(appBuilder.create()); } @@ -90,6 +94,7 @@ final class WinFromOptions { WIN_UPDATE_URL.ifPresentIn(options, pkgBuilder::updateURL); WIN_INSTALLDIR_CHOOSER.ifPresentIn(options, pkgBuilder::withInstallDirChooser); WIN_SHORTCUT_PROMPT.ifPresentIn(options, pkgBuilder::withShortcutPrompt); + WIN_WITH_UI.ifPresentIn(options, pkgBuilder::withUi); if (app.isService()) { RESOURCE_DIR.ifPresentIn(options, resourceDir -> { @@ -112,4 +117,11 @@ final class WinFromOptions { return pkgBuilder.create(); } + + private static String normalizeVersion(String version) { + // Windows requires between 2 and 4 components version string. + // When reading from release file it can be 1 or 3 or maybe more. + // One component will be normalized to 2 and more then 4 will be trim to 4. + return DottedVersion.lazy(version).trim(4).pad(2).toComponentsString(); + } } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackageBuilder.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackageBuilder.java index 7695cf04ac1..c2564028ecb 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackageBuilder.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +65,7 @@ final class WinMsiPackageBuilder { MsiVersion.of(pkg.version()), withInstallDirChooser, withShortcutPrompt, + withUi, Optional.ofNullable(helpURL), Optional.ofNullable(updateURL), Optional.ofNullable(startMenuGroupName).orElseGet(DEFAULTS::startMenuGroupName), @@ -92,6 +93,11 @@ final class WinMsiPackageBuilder { return this; } + WinMsiPackageBuilder withUi(boolean v) { + withUi = v; + return this; + } + WinMsiPackageBuilder helpURL(String v) { helpURL = v; return this; @@ -131,6 +137,7 @@ final class WinMsiPackageBuilder { private boolean withInstallDirChooser; private boolean withShortcutPrompt; + private boolean withUi; private String helpURL; private String updateURL; private String startMenuGroupName; diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackager.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackager.java index c72b14a76d5..3eb7b10b846 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackager.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiPackager.java @@ -36,7 +36,6 @@ import java.nio.file.Path; import java.nio.file.PathMatcher; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -151,9 +150,6 @@ final class WinMsiPackager implements Consumer { wixFragments.forEach(wixFragment -> wixFragment.setWixVersion(wixToolset.getVersion(), wixToolset.getType())); - - wixFragments.stream().map(WixFragmentBuilder::getLoggableWixFeatures).flatMap( - List::stream).distinct().toList().forEach(Log::verbose); } WinMsiPackager(BuildEnv env, WinMsiPackage pkg, Path outputDir, WinSystemEnvironment sysEnv) { @@ -318,50 +314,50 @@ final class WinMsiPackager implements Consumer { wixPipeline.buildMsi(msiOut.toAbsolutePath()); } - private Map createWixVars() throws IOException { - Map data = new HashMap<>(); + private WixVariables createWixVars() throws IOException { + var wixVars = new WixVariables(); - data.put("JpProductCode", pkg.productCode().toString()); - data.put("JpProductUpgradeCode", pkg.upgradeCode().toString()); + wixVars.put("JpProductCode", pkg.productCode().toString()); + wixVars.put("JpProductUpgradeCode", pkg.upgradeCode().toString()); Log.verbose(I18N.format("message.product-code", pkg.productCode())); Log.verbose(I18N.format("message.upgrade-code", pkg.upgradeCode())); - data.put("JpAllowUpgrades", "yes"); + wixVars.define("JpAllowUpgrades"); if (!pkg.isRuntimeInstaller()) { - data.put("JpAllowDowngrades", "yes"); + wixVars.define("JpAllowDowngrades"); } - data.put("JpAppName", pkg.packageName()); - data.put("JpAppDescription", pkg.description()); - data.put("JpAppVendor", pkg.app().vendor()); - data.put("JpAppVersion", pkg.version()); + wixVars.put("JpAppName", pkg.packageName()); + wixVars.put("JpAppDescription", pkg.description()); + wixVars.put("JpAppVendor", pkg.app().vendor()); + wixVars.put("JpAppVersion", pkg.version()); if (Files.exists(installerIcon)) { - data.put("JpIcon", installerIcon.toString()); + wixVars.put("JpIcon", installerIcon.toString()); } pkg.helpURL().ifPresent(value -> { - data.put("JpHelpURL", value); + wixVars.put("JpHelpURL", value); }); pkg.updateURL().ifPresent(value -> { - data.put("JpUpdateURL", value); + wixVars.put("JpUpdateURL", value); }); pkg.aboutURL().ifPresent(value -> { - data.put("JpAboutURL", value); + wixVars.put("JpAboutURL", value); }); - data.put("JpAppSizeKb", Long.toString(AppImageLayout.toPathGroup( + wixVars.put("JpAppSizeKb", Long.toString(AppImageLayout.toPathGroup( env.appImageLayout()).sizeInBytes() >> 10)); - data.put("JpConfigDir", env.configDir().toAbsolutePath().toString()); + wixVars.put("JpConfigDir", env.configDir().toAbsolutePath().toString()); if (pkg.isSystemWideInstall()) { - data.put("JpIsSystemWide", "yes"); + wixVars.define("JpIsSystemWide"); } - return data; + return wixVars; } private static List getWxlFilesFromDir(Path dir) { diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsDefender.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsDefender.java deleted file mode 100644 index 075d87bcbca..00000000000 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsDefender.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2012, 2023, 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.jpackage.internal; - -import java.util.List; -import jdk.internal.util.OperatingSystem; -import jdk.internal.util.OSVersion; - -final class WindowsDefender { - - private WindowsDefender() {} - - static final boolean isThereAPotentialWindowsDefenderIssue(String dir) { - boolean result = false; - - if (OperatingSystem.isWindows() && - OSVersion.current().major() == 10) { - - // If DisableRealtimeMonitoring is not enabled then there - // may be a problem. - if (!WindowsRegistry.readDisableRealtimeMonitoring() && - !isDirectoryInExclusionPath(dir)) { - result = true; - } - } - - return result; - } - - private static boolean isDirectoryInExclusionPath(String dir) { - boolean result = false; - // If the user temp directory is not found in the exclusion - // list then there may be a problem. - List paths = WindowsRegistry.readExclusionsPaths(); - for (String s : paths) { - if (WindowsRegistry.comparePaths(s, dir)) { - result = true; - break; - } - } - - return result; - } - - static final String getUserTempDirectory() { - String tempDirectory = System.getProperty("java.io.tmpdir"); - return tempDirectory; - } -} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsRegistry.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsRegistry.java deleted file mode 100644 index 7eb7b922667..00000000000 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsRegistry.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 - * 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.jpackage.internal; - -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("restricted") -final class WindowsRegistry { - - // Currently we only support HKEY_LOCAL_MACHINE. Native implementation will - // require support for additinal HKEY if needed. - private static final int HKEY_LOCAL_MACHINE = 1; - - static { - System.loadLibrary("jpackage"); - } - - private WindowsRegistry() {} - - /** - * Reads the registry value for DisableRealtimeMonitoring. - * @return true if DisableRealtimeMonitoring is set to 0x1, - * false otherwise. - */ - static final boolean readDisableRealtimeMonitoring() { - final String subKey = "Software\\Microsoft\\" - + "Windows Defender\\Real-Time Protection"; - final String value = "DisableRealtimeMonitoring"; - int result = readDwordValue(HKEY_LOCAL_MACHINE, subKey, value, 0); - return (result == 1); - } - - static final List readExclusionsPaths() { - List result = new ArrayList<>(); - final String subKey = "Software\\Microsoft\\" - + "Windows Defender\\Exclusions\\Paths"; - long lKey = openRegistryKey(HKEY_LOCAL_MACHINE, subKey); - if (lKey == 0) { - return result; - } - - String valueName; - int index = 0; - do { - valueName = enumRegistryValue(lKey, index); - if (valueName != null) { - result.add(valueName); - index++; - } - } while (valueName != null); - - closeRegistryKey(lKey); - - return result; - } - - /** - * Reads DWORD registry value. - * - * @param key one of HKEY predefine value - * @param subKey registry sub key - * @param value value to read - * @param defaultValue default value in case if subKey or value not found - * or any other errors occurred - * @return value's data only if it was read successfully, otherwise - * defaultValue - */ - private static native int readDwordValue(int key, String subKey, - String value, int defaultValue); - - /** - * Open registry key. - * - * @param key one of HKEY predefine value - * @param subKey registry sub key - * @return native handle to open key - */ - private static native long openRegistryKey(int key, String subKey); - - /** - * Enumerates the values for registry key. - * - * @param lKey native handle to open key returned by openRegistryKey - * @param index index of value starting from 0. Increment until this - * function returns NULL which means no more values. - * @return returns value or NULL if error or no more data - */ - private static native String enumRegistryValue(long lKey, int index); - - /** - * Close registry key. - * - * @param lKey native handle to open key returned by openRegistryKey - */ - private static native void closeRegistryKey(long lKey); - - /** - * Compares two Windows paths regardless case and if paths - * are short or long. - * - * @param path1 path to compare - * @param path2 path to compare - * @return true if paths point to same location - */ - public static native boolean comparePaths(String path1, String path2); -} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java index 0dff5c26ae2..ac7af873739 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import static jdk.jpackage.internal.util.CollectionUtils.toCollection; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -142,16 +141,6 @@ final class WixAppImageFragmentBuilder extends WixFragmentBuilder { super.addFilesToConfigRoot(); } - @Override - List getLoggableWixFeatures() { - if (isWithWix36Features()) { - return List.of(MessageFormat.format(I18N.getString("message.use-wix36-features"), - getWixVersion())); - } else { - return List.of(); - } - } - @Override protected Collection getFragmentWriters() { return List.of( diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixFragmentBuilder.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixFragmentBuilder.java index 4d180a94871..c842c366f63 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixFragmentBuilder.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixFragmentBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,19 +30,17 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.nio.file.Path; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.stream.XMLStreamWriter; -import jdk.jpackage.internal.util.XmlConsumer; import jdk.internal.util.Architecture; import jdk.jpackage.internal.WixSourceConverter.ResourceGroup; import jdk.jpackage.internal.WixToolset.WixToolsetType; import jdk.jpackage.internal.model.DottedVersion; import jdk.jpackage.internal.model.WinMsiPackage; +import jdk.jpackage.internal.util.XmlConsumer; import jdk.jpackage.internal.util.XmlUtils; /** @@ -66,20 +64,14 @@ abstract class WixFragmentBuilder { } void initFromParams(BuildEnv env, WinMsiPackage pkg) { - wixVariables = null; + wixVariables = new WixVariables(); additionalResources = null; configRoot = env.configDir(); fragmentResource = env.createResource(defaultResourceName).setPublicName(outputFileName); } - List getLoggableWixFeatures() { - return List.of(); - } - void configureWixPipeline(WixPipeline.Builder wixPipeline) { - wixPipeline.addSource(configRoot.resolve(outputFileName), - Optional.ofNullable(wixVariables).map(WixVariables::getValues).orElse( - null)); + wixPipeline.addSource(configRoot.resolve(outputFileName), wixVariables); } void addFilesToConfigRoot() throws IOException { @@ -152,14 +144,11 @@ abstract class WixFragmentBuilder { protected abstract Collection getFragmentWriters(); protected final void defineWixVariable(String variableName) { - setWixVariable(variableName, "yes"); + wixVariables.define(variableName); } protected final void setWixVariable(String variableName, String variableValue) { - if (wixVariables == null) { - wixVariables = new WixVariables(); - } - wixVariables.setWixVariable(variableName, variableValue); + wixVariables.put(variableName, variableValue); } protected final void addResource(OverridableResource resource, String saveAsName) { diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixPipeline.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixPipeline.java index 40160192862..a09db389ca5 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixPipeline.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixPipeline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,18 @@ */ package jdk.jpackage.internal; +import static jdk.jpackage.internal.ShortPathUtils.adjustPath; + import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.Set; -import java.util.function.Function; +import java.util.function.Consumer; import java.util.function.UnaryOperator; -import java.util.stream.Collectors; import java.util.stream.Stream; -import static jdk.jpackage.internal.ShortPathUtils.adjustPath; import jdk.jpackage.internal.util.PathUtils; /** @@ -61,18 +57,20 @@ final class WixPipeline { final var absWorkDir = workDir.normalize().toAbsolutePath(); - final UnaryOperator normalizePath = path -> { - return path.normalize().toAbsolutePath(); - }; + final var absObjWorkDir = PathUtils.normalizedAbsolutePath(wixObjDir); - final var absObjWorkDir = normalizePath.apply(wixObjDir); - - var relSources = sources.stream().map(source -> { - return source.overridePath(normalizePath.apply(source.path)); + final var absSources = sources.stream().map(source -> { + return source.copyWithPath(PathUtils.normalizedAbsolutePath(source.path)); }).toList(); - return new WixPipeline(toolset, adjustPath(absWorkDir), absObjWorkDir, - wixVariables, mapLightOptions(normalizePath), relSources); + return new WixPipeline( + toolset, + adjustPath(absWorkDir), + absObjWorkDir, + wixVariables.createdImmutableCopy(), + mapLightOptions(PathUtils::normalizedAbsolutePath), + absSources, + msiMutators); } Builder setWixObjDir(Path v) { @@ -85,17 +83,30 @@ final class WixPipeline { return this; } - Builder setWixVariables(Map v) { - wixVariables.clear(); + Builder putWixVariables(WixVariables v) { wixVariables.putAll(v); return this; } - Builder addSource(Path source, Map wixVariables) { - sources.add(new WixSource(source, wixVariables)); + Builder putWixVariables(Map v) { + wixVariables.putAll(v); return this; } + Builder addSource(Path source, WixVariables wixVariables) { + sources.add(new WixSource(source, wixVariables.createdImmutableCopy())); + return this; + } + + Builder addMsiMutator(MsiMutator msiMutator, List args) { + msiMutators.add(new MsiMutatorWithArgs(msiMutator, args)); + return this; + } + + Builder addSource(Path source) { + return addSource(source, WixVariables.EMPTY); + } + Builder addLightOptions(String ... v) { lightOptions.addAll(List.of(v)); return this; @@ -119,87 +130,59 @@ final class WixPipeline { private Path workDir; private Path wixObjDir; - private final Map wixVariables = new HashMap<>(); + private final WixVariables wixVariables = new WixVariables(); private final List lightOptions = new ArrayList<>(); private final List sources = new ArrayList<>(); + private final List msiMutators = new ArrayList<>(); } static Builder build() { return new Builder(); } - private WixPipeline(WixToolset toolset, Path workDir, Path wixObjDir, - Map wixVariables, List lightOptions, - List sources) { - this.toolset = toolset; - this.workDir = workDir; - this.wixObjDir = wixObjDir; - this.wixVariables = wixVariables; - this.lightOptions = lightOptions; - this.sources = sources; + private WixPipeline( + WixToolset toolset, + Path workDir, + Path wixObjDir, + WixVariables wixVariables, + List lightOptions, + List sources, + List msiMutators) { + + this.toolset = Objects.requireNonNull(toolset); + this.workDir = Objects.requireNonNull(workDir); + this.wixObjDir = Objects.requireNonNull(wixObjDir); + this.wixVariables = Objects.requireNonNull(wixVariables); + this.lightOptions = Objects.requireNonNull(lightOptions); + this.sources = Objects.requireNonNull(sources); + this.msiMutators = Objects.requireNonNull(msiMutators); } void buildMsi(Path msi) throws IOException { - Objects.requireNonNull(workDir); // Use short path to the output msi to workaround // WiX limitations of handling long paths. var transientMsi = wixObjDir.resolve("a.msi"); + var configRoot = workDir.resolve(transientMsi).getParent(); + + for (var msiMutator : msiMutators) { + msiMutator.addToConfigRoot(configRoot); + } + switch (toolset.getType()) { case Wix3 -> buildMsiWix3(transientMsi); case Wix4 -> buildMsiWix4(transientMsi); - default -> throw new IllegalArgumentException(); + } + + for (var msiMutator : msiMutators) { + msiMutator.execute(configRoot, workDir.resolve(transientMsi)); } IOUtils.copyFile(workDir.resolve(transientMsi), msi); } - private void addWixVariblesToCommandLine( - Map otherWixVariables, List cmdline) { - Stream.of(wixVariables, Optional.ofNullable(otherWixVariables). - orElseGet(Collections::emptyMap)).filter(Objects::nonNull). - reduce((a, b) -> { - a.putAll(b); - return a; - }).ifPresent(wixVars -> { - var entryStream = wixVars.entrySet().stream(); - - Stream stream; - switch (toolset.getType()) { - case Wix3 -> { - stream = entryStream.map(wixVar -> { - return String.format("-d%s=%s", wixVar.getKey(), wixVar. - getValue()); - }); - } - case Wix4 -> { - stream = entryStream.map(wixVar -> { - return Stream.of("-d", String.format("%s=%s", wixVar. - getKey(), wixVar.getValue())); - }).flatMap(Function.identity()); - } - default -> { - throw new IllegalArgumentException(); - } - } - - stream.reduce(cmdline, (ctnr, wixVar) -> { - ctnr.add(wixVar); - return ctnr; - }, (x, y) -> { - x.addAll(y); - return x; - }); - }); - } - private void buildMsiWix4(Path msi) throws IOException { - var mergedSrcWixVars = sources.stream().map(wixSource -> { - return Optional.ofNullable(wixSource.variables).orElseGet( - Collections::emptyMap).entrySet().stream(); - }).flatMap(Function.identity()).collect(Collectors.toMap( - Map.Entry::getKey, Map.Entry::getValue)); List cmdline = new ArrayList<>(List.of( toolset.getToolPath(WixTool.Wix4).toString(), @@ -213,7 +196,7 @@ final class WixPipeline { cmdline.addAll(lightOptions); - addWixVariblesToCommandLine(mergedSrcWixVars, cmdline); + addWixVariablesToCommandLine(sources.stream(), cmdline::addAll); cmdline.addAll(sources.stream().map(wixSource -> { return wixSource.path.toString(); @@ -241,7 +224,6 @@ final class WixPipeline { lightCmdline.addAll(lightOptions); wixObjs.stream().map(Path::toString).forEach(lightCmdline::add); - Files.createDirectories(msi.getParent()); execute(lightCmdline); } @@ -262,7 +244,7 @@ final class WixPipeline { cmdline.add("-fips"); } - addWixVariblesToCommandLine(wixSource.variables, cmdline); + addWixVariablesToCommandLine(Stream.of(wixSource), cmdline::addAll); execute(cmdline); @@ -273,16 +255,47 @@ final class WixPipeline { Executor.of(new ProcessBuilder(cmdline).directory(workDir.toFile())).executeExpectSuccess(); } - private record WixSource(Path path, Map variables) { - WixSource overridePath(Path path) { + private void addWixVariablesToCommandLine(Stream wixSources, Consumer> sink) { + sink.accept(wixSources.map(WixSource::variables).reduce(wixVariables, (a, b) -> { + return new WixVariables().putAll(a).putAll(b); + }).toWixCommandLine(toolset.getType())); + } + + private record WixSource(Path path, WixVariables variables) { + WixSource { + Objects.requireNonNull(path); + Objects.requireNonNull(variables); + } + + WixSource copyWithPath(Path path) { return new WixSource(path, variables); } } + private record MsiMutatorWithArgs(MsiMutator mutator, List args) { + MsiMutatorWithArgs { + Objects.requireNonNull(mutator); + Objects.requireNonNull(args); + } + + void addToConfigRoot(Path configRoot) throws IOException { + mutator.addToConfigRoot(configRoot); + } + + void execute(Path configRoot, Path transientMsi) throws IOException { + Executor.of("cscript", "//Nologo") + .args(PathUtils.normalizedAbsolutePathString(configRoot.resolve(mutator.pathInConfigRoot()))) + .args(PathUtils.normalizedAbsolutePathString(transientMsi)) + .args(args) + .executeExpectSuccess(); + } + } + private final WixToolset toolset; - private final Map wixVariables; + private final WixVariables wixVariables; private final List lightOptions; private final Path wixObjDir; private final Path workDir; private final List sources; + private final List msiMutators; } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixUiFragmentBuilder.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixUiFragmentBuilder.java index 4a2a0756dbd..4748dcfb827 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixUiFragmentBuilder.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixUiFragmentBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,25 +24,32 @@ */ package jdk.jpackage.internal; -import jdk.jpackage.internal.model.WinMsiPackage; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.function.Function; -import java.util.function.Supplier; +import java.util.stream.Stream; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import jdk.jpackage.internal.WixAppImageFragmentBuilder.ShortcutsFolder; import jdk.jpackage.internal.WixToolset.WixToolsetType; +import jdk.jpackage.internal.model.WinMsiPackage; import jdk.jpackage.internal.resources.ResourceLocator; import jdk.jpackage.internal.util.XmlConsumer; +import jdk.jpackage.internal.wixui.Dialog; +import jdk.jpackage.internal.wixui.DialogPair; +import jdk.jpackage.internal.wixui.Publish; +import jdk.jpackage.internal.wixui.ShowActionSuppresser; +import jdk.jpackage.internal.wixui.UIConfig; +import jdk.jpackage.internal.wixui.UISpec; /** * Creates UI WiX fragment. @@ -53,63 +60,83 @@ final class WixUiFragmentBuilder extends WixFragmentBuilder { void initFromParams(BuildEnv env, WinMsiPackage pkg) { super.initFromParams(env, pkg); - withLicenseDlg = pkg.licenseFile().isPresent(); - if (withLicenseDlg) { + final var shortcutFolders = ShortcutsFolder.getForPackage(pkg); + + uiConfig = UIConfig.build() + .withLicenseDlg(pkg.licenseFile().isPresent()) + .withInstallDirChooserDlg(pkg.withInstallDirChooser()) + .withShortcutPromptDlg(!shortcutFolders.isEmpty() && pkg.withShortcutPrompt()) + .create(); + + if (!uiConfig.equals(UIConfig.build().create()) || pkg.withUI()) { + uiSpec = Optional.of(UISpec.create(uiConfig)); + } else { + uiSpec = Optional.empty(); + } + + if (uiConfig.isWithLicenseDlg()) { Path licenseFileName = pkg.licenseFile().orElseThrow().getFileName(); Path destFile = getConfigRoot().resolve(licenseFileName); setWixVariable("JpLicenseRtf", destFile.toAbsolutePath().toString()); } - withInstallDirChooserDlg = pkg.withInstallDirChooser(); - - final var shortcutFolders = ShortcutsFolder.getForPackage(pkg); - - withShortcutPromptDlg = !shortcutFolders.isEmpty() && pkg.withShortcutPrompt(); - customDialogs = new ArrayList<>(); - if (withShortcutPromptDlg) { - CustomDialog dialog = new CustomDialog(env::createResource, I18N.getString( - "resource.shortcutpromptdlg-wix-file"), + if (uiConfig.isWithShortcutPromptDlg()) { + CustomDialog dialog = new CustomDialog( + env::createResource, + I18N.getString("resource.shortcutpromptdlg-wix-file"), "ShortcutPromptDlg.wxs"); for (var shortcutFolder : shortcutFolders) { - dialog.wixVariables.defineWixVariable( + dialog.wixVariables.define( shortcutFolder.getWixVariableName()); } customDialogs.add(dialog); } - if (withInstallDirChooserDlg) { - CustomDialog dialog = new CustomDialog(env::createResource, I18N.getString( - "resource.installdirnotemptydlg-wix-file"), + if (uiConfig.isWithInstallDirChooserDlg()) { + CustomDialog dialog = new CustomDialog( + env::createResource, + I18N.getString("resource.installdirnotemptydlg-wix-file"), "InstallDirNotEmptyDlg.wxs"); - List

    dialogIds = getUI().dialogIdsSupplier.apply(this); - dialog.wixVariables.setWixVariable("JpAfterInstallDirDlg", - dialogIds.get(dialogIds.indexOf(Dialog.InstallDirDlg) + 1).id); customDialogs.add(dialog); } + } @Override void configureWixPipeline(WixPipeline.Builder wixPipeline) { super.configureWixPipeline(wixPipeline); - if (withShortcutPromptDlg || withInstallDirChooserDlg || withLicenseDlg) { - final String extName; - switch (getWixType()) { - case Wix3 -> extName = "WixUIExtension"; - case Wix4 -> extName = "WixToolset.UI.wixext"; - default -> throw new IllegalArgumentException(); - } - wixPipeline.addLightOptions("-ext", extName); - } - // Only needed if we using CA dll, so Wix can find it if (withCustomActionsDll) { wixPipeline.addLightOptions("-b", getConfigRoot().toAbsolutePath().toString()); } + if (uiSpec.isEmpty()) { + return; + } + + var extName = switch (getWixType()) { + case Wix3 -> "WixUIExtension"; + case Wix4 -> "WixToolset.UI.wixext"; + }; + wixPipeline.addLightOptions("-ext", extName); + wixPipeline.putWixVariables(uiSpec.get().wixVariables()); + + if (!uiSpec.get().hideDialogs().isEmpty() && getWixType() == WixToolsetType.Wix3) { + // Older WiX doesn't support multiple overrides of a "ShowAction" element. + // Have to run a script to alter the msi. + var removeActions = uiSpec.get().hideDialogs().stream() + .map(ShowActionSuppresser::dialog) + .sorted(Dialog.DEFAULT_COMPARATOR) + .map(Dialog::id); + wixPipeline.addMsiMutator( + new MsiMutator("msi-disable-actions.js"), + Stream.concat(Stream.of("InstallUISequence"), removeActions).toList()); + } + for (var customDialog : customDialogs) { customDialog.addToWixPipeline(wixPipeline); } @@ -132,26 +159,24 @@ final class WixUiFragmentBuilder extends WixFragmentBuilder { return List.of(this::addUI); } - private void addUI(XMLStreamWriter xml) throws XMLStreamException, - IOException { + private void addUI(XMLStreamWriter xml) throws XMLStreamException, IOException { - if (withInstallDirChooserDlg) { + if (uiConfig.isWithInstallDirChooserDlg()) { xml.writeStartElement("Property"); xml.writeAttribute("Id", "WIXUI_INSTALLDIR"); xml.writeAttribute("Value", "INSTALLDIR"); xml.writeEndElement(); // Property } - if (withLicenseDlg) { + if (uiConfig.isWithLicenseDlg()) { xml.writeStartElement("WixVariable"); xml.writeAttribute("Id", "WixUILicenseRtf"); xml.writeAttribute("Value", "$(var.JpLicenseRtf)"); xml.writeEndElement(); // WixVariable } - var ui = getUI(); - if (ui != null) { - ui.write(getWixType(), this, xml); + if (uiSpec.isPresent()) { + writeNonEmptyUIElement(xml); } else { xml.writeStartElement("UI"); xml.writeAttribute("Id", "JpUI"); @@ -159,371 +184,140 @@ final class WixUiFragmentBuilder extends WixFragmentBuilder { } } - private UI getUI() { - if (withInstallDirChooserDlg || withShortcutPromptDlg) { - // WixUI_InstallDir for shortcut prompt dialog too because in - // WixUI_Minimal UI sequence WelcomeEulaDlg dialog doesn't have "Next" - // button, but has "Install" button. So inserting shortcut prompt dialog - // after welcome dialog in WixUI_Minimal UI sequence would be confusing - return UI.InstallDir; - } else if (withLicenseDlg) { - return UI.Minimal; - } else { - return null; - } - } + void writeNonEmptyUIElement(XMLStreamWriter xml) throws XMLStreamException, IOException { - private enum UI { - InstallDir("WixUI_InstallDir", - WixUiFragmentBuilder::dialogSequenceForWixUI_InstallDir, - Dialog::createPairsForWixUI_InstallDir), - Minimal("WixUI_Minimal", null, null); + switch (getWixType()) { + case Wix3 -> {} + case Wix4 -> { + // https://wixtoolset.org/docs/fourthree/faqs/#converting-custom-wixui-dialog-sets + xml.writeProcessingInstruction("foreach WIXUIARCH in X86;X64;A64"); + writeWix4UIRef(xml, uiSpec.get().wixUI().id(), "JpUIInternal_$(WIXUIARCH)"); + xml.writeProcessingInstruction("endforeach"); - UI(String wixUIRef, - Function> dialogIdsSupplier, - Supplier>> dialogPairsSupplier) { - this.wixUIRef = wixUIRef; - this.dialogIdsSupplier = dialogIdsSupplier; - this.dialogPairsSupplier = dialogPairsSupplier; - } - - void write(WixToolsetType wixType, WixUiFragmentBuilder outer, XMLStreamWriter xml) throws XMLStreamException, IOException { - switch (wixType) { - case Wix3 -> {} - case Wix4 -> { - // https://wixtoolset.org/docs/fourthree/faqs/#converting-custom-wixui-dialog-sets - xml.writeProcessingInstruction("foreach WIXUIARCH in X86;X64;A64"); - writeWix4UIRef(xml, wixUIRef, "JpUIInternal_$(WIXUIARCH)"); - xml.writeProcessingInstruction("endforeach"); - - writeWix4UIRef(xml, "JpUIInternal", "JpUI"); - } - default -> { - throw new IllegalArgumentException(); - } - } - - xml.writeStartElement("UI"); - switch (wixType) { - case Wix3 -> { - xml.writeAttribute("Id", "JpUI"); - xml.writeStartElement("UIRef"); - xml.writeAttribute("Id", wixUIRef); - xml.writeEndElement(); // UIRef - } - case Wix4 -> { - xml.writeAttribute("Id", "JpUIInternal"); - } - default -> { - throw new IllegalArgumentException(); - } - } - writeContents(wixType, outer, xml); - xml.writeEndElement(); // UI - } - - private void writeContents(WixToolsetType wixType, WixUiFragmentBuilder outer, - XMLStreamWriter xml) throws XMLStreamException, IOException { - if (dialogIdsSupplier != null) { - List dialogIds = dialogIdsSupplier.apply(outer); - Map> dialogPairs = dialogPairsSupplier.get(); - - if (dialogIds.contains(Dialog.InstallDirDlg)) { - xml.writeStartElement("DialogRef"); - xml.writeAttribute("Id", "InstallDirNotEmptyDlg"); - xml.writeEndElement(); // DialogRef - } - - var it = dialogIds.iterator(); - Dialog firstId = it.next(); - while (it.hasNext()) { - Dialog secondId = it.next(); - DialogPair pair = new DialogPair(firstId, secondId); - for (var curPair : List.of(pair, pair.flip())) { - for (var publish : dialogPairs.get(curPair)) { - writePublishDialogPair(wixType, xml, publish, curPair); - } - } - firstId = secondId; - } + writeWix4UIRef(xml, "JpUIInternal", "JpUI"); } } - private static void writeWix4UIRef(XMLStreamWriter xml, String uiRef, String id) throws XMLStreamException, IOException { - // https://wixtoolset.org/docs/fourthree/faqs/#referencing-the-standard-wixui-dialog-sets - xml.writeStartElement("UI"); - xml.writeAttribute("Id", id); - xml.writeStartElement("ui:WixUI"); - xml.writeAttribute("Id", uiRef); - xml.writeNamespace("ui", "http://wixtoolset.org/schemas/v4/wxs/ui"); - xml.writeEndElement(); // UIRef - xml.writeEndElement(); // UI - } - - private final String wixUIRef; - private final Function> dialogIdsSupplier; - private final Supplier>> dialogPairsSupplier; - } - - private List dialogSequenceForWixUI_InstallDir() { - List dialogIds = new ArrayList<>( - List.of(Dialog.WixUI_WelcomeDlg)); - if (withLicenseDlg) { - dialogIds.add(Dialog.WixUI_LicenseAgreementDlg); - } - - if (withInstallDirChooserDlg) { - dialogIds.add(Dialog.InstallDirDlg); - } - - if (withShortcutPromptDlg) { - dialogIds.add(Dialog.ShortcutPromptDlg); - } - - dialogIds.add(Dialog.WixUI_VerifyReadyDlg); - - return dialogIds; - } - - private enum Dialog { - WixUI_WelcomeDlg, - WixUI_LicenseAgreementDlg, - InstallDirDlg, - ShortcutPromptDlg, - WixUI_VerifyReadyDlg; - - Dialog() { - if (name().startsWith("WixUI_")) { - id = name().substring("WixUI_".length()); - } else { - id = name(); + xml.writeStartElement("UI"); + switch (getWixType()) { + case Wix3 -> { + xml.writeAttribute("Id", "JpUI"); + xml.writeStartElement("UIRef"); + xml.writeAttribute("Id", uiSpec.get().wixUI().id()); + xml.writeEndElement(); // UIRef + } + case Wix4 -> { + xml.writeAttribute("Id", "JpUIInternal"); } } - - static Map> createPair(Dialog firstId, - Dialog secondId, List nextBuilders, - List prevBuilders) { - var pair = new DialogPair(firstId, secondId); - return Map.of(pair, nextBuilders.stream().map(b -> { - return buildPublish(b.create()).next().create(); - }).toList(), pair.flip(), - prevBuilders.stream().map(b -> { - return buildPublish(b.create()).back().create(); - }).toList()); - } - - static Map> createPair(Dialog firstId, - Dialog secondId, List builders) { - return createPair(firstId, secondId, builders, builders); - } - - static Map> createPairsForWixUI_InstallDir() { - Map> map = new HashMap<>(); - - // Order is a "weight" of action. If there are multiple - // "NewDialog" action for the same dialog Id, MSI would pick the one - // with higher order value. In WixUI_InstallDir dialog sequence the - // highest order value is 4. InstallDirNotEmptyDlg adds NewDialog - // action with order 5. Setting order to 6 for all - // actions configured in this function would make them executed - // instead of corresponding default actions defined in - // WixUI_InstallDir dialog sequence. - var order = 6; - - // Based on WixUI_InstallDir.wxs - var backFromVerifyReadyDlg = List.of(buildPublish().condition( - "NOT Installed").order(order)); - var uncondinal = List.of(buildPublish().condition("1")); - var ifNotIstalled = List.of( - buildPublish().condition("NOT Installed").order(order)); - var ifLicenseAccepted = List.of(buildPublish().condition( - "LicenseAccepted = \"1\"").order(order)); - - // Empty condition list for the default dialog sequence - map.putAll(createPair(WixUI_WelcomeDlg, WixUI_LicenseAgreementDlg, - List.of())); - map.putAll( - createPair(WixUI_WelcomeDlg, InstallDirDlg, ifNotIstalled)); - map.putAll(createPair(WixUI_WelcomeDlg, ShortcutPromptDlg, - ifNotIstalled)); - - map.putAll(createPair(WixUI_LicenseAgreementDlg, InstallDirDlg, - List.of())); - map.putAll(createPair(WixUI_LicenseAgreementDlg, ShortcutPromptDlg, - ifLicenseAccepted, uncondinal)); - map.putAll(createPair(WixUI_LicenseAgreementDlg, - WixUI_VerifyReadyDlg, ifLicenseAccepted, - backFromVerifyReadyDlg)); - - map.putAll(createPair(InstallDirDlg, ShortcutPromptDlg, List.of(), - uncondinal)); - map.putAll(createPair(InstallDirDlg, WixUI_VerifyReadyDlg, List.of())); - - map.putAll(createPair(ShortcutPromptDlg, WixUI_VerifyReadyDlg, - uncondinal, backFromVerifyReadyDlg)); - - return map; - } - - private final String id; + writeUIElementContents(xml); + xml.writeEndElement(); // UI } - private static final class DialogPair { + private void writeUIElementContents(XMLStreamWriter xml) throws XMLStreamException, IOException { - DialogPair(Dialog first, Dialog second) { - this(first.id, second.id); + if (uiConfig.isWithInstallDirChooserDlg()) { + xml.writeStartElement("DialogRef"); + xml.writeAttribute("Id", "InstallDirNotEmptyDlg"); + xml.writeEndElement(); // DialogRef } - DialogPair(String firstId, String secondId) { - this.firstId = firstId; - this.secondId = secondId; + for (var e : uiSpec.get().customDialogSequence().entrySet().stream() + .sorted(Comparator.comparing(Map.Entry::getKey, DialogPair.DEFAULT_COMPARATOR)) + .toList()) { + writePublishDialogPair(getWixType(), xml, e.getValue(), e.getKey()); } - DialogPair flip() { - return new DialogPair(secondId, firstId); - } - - @Override - public int hashCode() { - int hash = 3; - hash = 97 * hash + Objects.hashCode(this.firstId); - hash = 97 * hash + Objects.hashCode(this.secondId); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final DialogPair other = (DialogPair) obj; - if (!Objects.equals(this.firstId, other.firstId)) { - return false; - } - if (!Objects.equals(this.secondId, other.secondId)) { - return false; - } - return true; - } - - private final String firstId; - private final String secondId; + hideDialogs(getWixType(), xml, uiSpec.get().hideDialogs()); } - private static final class Publish { - - Publish(String control, String condition, int order) { - this.control = control; - this.condition = condition; - this.order = order; - } - - private final String control; - private final String condition; - private final int order; + private static void writeWix4UIRef(XMLStreamWriter xml, String uiRef, String id) throws XMLStreamException, IOException { + // https://wixtoolset.org/docs/fourthree/faqs/#referencing-the-standard-wixui-dialog-sets + xml.writeStartElement("UI"); + xml.writeAttribute("Id", Objects.requireNonNull(id)); + xml.writeStartElement("ui:WixUI"); + xml.writeAttribute("Id", Objects.requireNonNull(uiRef)); + xml.writeNamespace("ui", "http://wixtoolset.org/schemas/v4/wxs/ui"); + xml.writeEndElement(); // UIRef + xml.writeEndElement(); // UI } - private static final class PublishBuilder { + private static void writePublishDialogPair( + WixToolsetType wixType, + XMLStreamWriter xml, + Publish publish, + DialogPair dialogPair) throws IOException, XMLStreamException { - PublishBuilder() { - order(0); - next(); - condition("1"); - } - - PublishBuilder(Publish publish) { - order(publish.order); - control(publish.control); - condition(publish.condition); - } - - public PublishBuilder control(String v) { - control = v; - return this; - } - - public PublishBuilder next() { - return control("Next"); - } - - public PublishBuilder back() { - return control("Back"); - } - - public PublishBuilder condition(String v) { - condition = v; - return this; - } - - public PublishBuilder order(int v) { - order = v; - return this; - } - - Publish create() { - return new Publish(control, condition, order); - } - - private String control; - private String condition; - private int order; - } - - private static PublishBuilder buildPublish() { - return new PublishBuilder(); - } - - private static PublishBuilder buildPublish(Publish publish) { - return new PublishBuilder(publish); - } - - private static void writePublishDialogPair(WixToolsetType wixType, XMLStreamWriter xml, - Publish publish, DialogPair dialogPair) throws IOException, XMLStreamException { xml.writeStartElement("Publish"); - xml.writeAttribute("Dialog", dialogPair.firstId); - xml.writeAttribute("Control", publish.control); + xml.writeAttribute("Dialog", dialogPair.first().id()); + xml.writeAttribute("Control", publish.control().id()); xml.writeAttribute("Event", "NewDialog"); - xml.writeAttribute("Value", dialogPair.secondId); - if (publish.order != 0) { - xml.writeAttribute("Order", String.valueOf(publish.order)); + xml.writeAttribute("Value", dialogPair.second().id()); + if (publish.order() != 0) { + xml.writeAttribute("Order", String.valueOf(publish.order())); } + switch (wixType) { - case Wix3 -> xml.writeCharacters(publish.condition); - case Wix4 -> xml.writeAttribute("Condition", publish.condition); - default -> throw new IllegalArgumentException(); + case Wix3 -> { + xml.writeCharacters(publish.condition()); + } + case Wix4 -> { + xml.writeAttribute("Condition", publish.condition()); + } } + + xml.writeEndElement(); + } + + private static void hideDialogs( + WixToolsetType wixType, + XMLStreamWriter xml, + Collection hideDialogs) throws IOException, XMLStreamException { + + if (!hideDialogs.isEmpty()) { + if (wixType == WixToolsetType.Wix4) { + xml.writeStartElement("InstallUISequence"); + for (var showAction : hideDialogs.stream().sorted(ShowActionSuppresser.DEFAULT_COMPARATOR).toList()) { + writeWix4ShowAction(wixType, xml, showAction); + } + xml.writeEndElement(); + } + } + } + + private static void writeWix4ShowAction( + WixToolsetType wixType, + XMLStreamWriter xml, + ShowActionSuppresser hideDialog) throws IOException, XMLStreamException { + + xml.writeStartElement("Show"); + xml.writeAttribute("Dialog", String.format("override %s", hideDialog.dialog().id())); + xml.writeAttribute(switch (hideDialog.order()) { + case AFTER -> "After"; + }, hideDialog.anchor().id()); + xml.writeAttribute("Condition", "0"); xml.writeEndElement(); } private final class CustomDialog { - CustomDialog(Function createResource, String category, - String wxsFileName) { + CustomDialog(Function createResource, String category, String wxsFileName) { this.wxsFileName = wxsFileName; this.wixVariables = new WixVariables(); - addResource(createResource.apply(wxsFileName).setCategory(category).setPublicName( - wxsFileName), wxsFileName); + addResource(createResource.apply(wxsFileName).setCategory(category).setPublicName(wxsFileName), wxsFileName); } void addToWixPipeline(WixPipeline.Builder wixPipeline) { - wixPipeline.addSource(getConfigRoot().toAbsolutePath().resolve( - wxsFileName), wixVariables.getValues()); + wixPipeline.addSource(getConfigRoot().toAbsolutePath().resolve(wxsFileName), wixVariables); } private final WixVariables wixVariables; private final String wxsFileName; } - private boolean withInstallDirChooserDlg; - private boolean withShortcutPromptDlg; - private boolean withLicenseDlg; + private UIConfig uiConfig; + private Optional uiSpec; private boolean withCustomActionsDll = true; private List customDialogs; } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixVariables.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixVariables.java index 36ed1d99738..88a25810182 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixVariables.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixVariables.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,103 @@ */ package jdk.jpackage.internal; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Stream; +import jdk.jpackage.internal.WixToolset.WixToolsetType; final class WixVariables { - void defineWixVariable(String variableName) { - setWixVariable(variableName, "yes"); + WixVariables() { + this.values = new HashMap<>(); } - void setWixVariable(String variableName, String variableValue) { - values.put(variableName, variableValue); + private WixVariables(Map values) { + this.values = values; + this.isImmutable = true; } - Map getValues() { - return values; + WixVariables define(String variableName) { + return put(variableName, "yes"); } - private final Map values = new HashMap<>(); + WixVariables put(String variableName, String variableValue) { + Objects.requireNonNull(variableName); + Objects.requireNonNull(variableValue); + validateMutable(); + values.compute(variableName, (k, v) -> { + if (!allowOverrides && v != null) { + throw overridingDisabled(); + } + return variableValue; + }); + return this; + } + + WixVariables putAll(Map values) { + Objects.requireNonNull(values); + validateMutable(); + if (!allowOverrides && !Collections.disjoint(this.values.keySet(), values.keySet())) { + throw overridingDisabled(); + } else { + values.entrySet().forEach(e -> { + put(e.getKey(), e.getValue()); + }); + } + return this; + } + + WixVariables putAll(WixVariables other) { + return putAll(other.values); + } + + WixVariables allowOverrides(boolean v) { + validateMutable(); + allowOverrides = v; + return this; + } + + WixVariables createdImmutableCopy() { + if (isImmutable) { + return this; + } else { + return new WixVariables(Map.copyOf(values)); + } + } + + List toWixCommandLine(WixToolsetType wixType) { + var orderedWixVars = values.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)); + return (switch (Objects.requireNonNull(wixType)) { + case Wix3 -> { + yield orderedWixVars.map(wixVar -> { + return String.format("-d%s=%s", wixVar.getKey(), wixVar.getValue()); + }); + } + case Wix4 -> { + yield orderedWixVars.flatMap(wixVar -> { + return Stream.of("-d", String.format("%s=%s", wixVar.getKey(), wixVar.getValue())); + }); + } + }).toList(); + } + + private void validateMutable() { + if (isImmutable) { + throw new IllegalStateException("WiX variables container is immutable"); + } + } + + private static IllegalStateException overridingDisabled() { + return new IllegalStateException("Overriding variables is unsupported"); + } + + private final Map values; + private boolean allowOverrides; + private boolean isImmutable; + + static final WixVariables EMPTY = new WixVariables().createdImmutableCopy(); } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/model/WinMsiPackageMixin.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/model/WinMsiPackageMixin.java index 94d7c30fe57..ec004da2cee 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/model/WinMsiPackageMixin.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/model/WinMsiPackageMixin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -36,6 +36,8 @@ public interface WinMsiPackageMixin { boolean withShortcutPrompt(); + boolean withUI(); + Optional helpURL(); Optional updateURL(); @@ -50,8 +52,16 @@ public interface WinMsiPackageMixin { Optional serviceInstaller(); - record Stub(DottedVersion msiVersion, boolean withInstallDirChooser, boolean withShortcutPrompt, - Optional helpURL, Optional updateURL, String startMenuGroupName, - boolean isSystemWideInstall, UUID upgradeCode, UUID productCode, + record Stub( + DottedVersion msiVersion, + boolean withInstallDirChooser, + boolean withShortcutPrompt, + boolean withUI, + Optional helpURL, + Optional updateURL, + String startMenuGroupName, + boolean isSystemWideInstall, + UUID upgradeCode, + UUID productCode, Optional serviceInstaller) implements WinMsiPackageMixin {} } diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties index 38d0bd02bbb..0f3dcab8260 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties @@ -55,10 +55,8 @@ error.missing-service-installer='service-installer.exe' service installer not fo error.missing-service-installer.advice=Add 'service-installer.exe' service installer to the resource directory message.icon-not-ico=The specified icon "{0}" is not an ICO file and will not be used. The default icon will be used in it's place. -message.potential.windows.defender.issue=Warning: Windows Defender may prevent jpackage from functioning. If there is an issue, it can be addressed by either disabling realtime monitoring, or adding an exclusion for the directory "{0}". message.tool-version=Detected [{0}] version [{1}]. message.wrong-tool-version=Detected [{0}] version {1} but version {2} is required. -message.use-wix36-features=WiX {0} detected. Enabling advanced cleanup action. message.product-code=MSI ProductCode: {0}. message.upgrade-code=MSI UpgradeCode: {0}. message.preparing-msi-config=Preparing MSI config: {0}. diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/msi-disable-actions.js b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/msi-disable-actions.js new file mode 100644 index 00000000000..2f0f3a5d019 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/msi-disable-actions.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2026, 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. + */ + + +function modifyMsi(msiPath, callback) { + var installer = new ActiveXObject('WindowsInstaller.Installer') + var database = installer.OpenDatabase(msiPath, 1 /* msiOpenDatabaseModeTransact */) + + callback(installer, database) + + database.Commit() +} + + +function disableActions(installer, db, sequence, actionIDs) { + var tables = {} + + var view = db.OpenView("SELECT `Action`, `Condition`, `Sequence` FROM " + sequence) + view.Execute() + + try { + while (true) { + var record = view.Fetch() + if (!record) { + break + } + + var action = record.StringData(1) + + if (actionIDs.hasOwnProperty(action)) { + WScript.Echo("Set condition of [" + action + "] action in [" + sequence + "] sequence to [0]") + var newRecord = installer.CreateRecord(3) + for (var i = 1; i !== newRecord.FieldCount + 1; i++) { + newRecord.StringData(i) = record.StringData(i) + } + newRecord.StringData(2) = "0" // Set condition value to `0` + view.Modify(3 /* msiViewModifyAssign */, newRecord) // Replace existing record + } + } + } finally { + view.Close() + } +} + + +(function () { + var msi = WScript.arguments(0) + var sequence = WScript.arguments(1) + var actionIDs = {} + for (var i = 0; i !== WScript.arguments.Count(); i++) { + actionIDs[WScript.arguments(i)] = true + } + + modifyMsi(msi, function (installer, db) { + disableActions(installer, db, sequence, actionIDs) + }) +})() diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Control.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Control.java new file mode 100644 index 00000000000..d41fc435126 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Control.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import java.util.Comparator; + +/** + * WiX Dialog's control. + */ +public sealed interface Control permits StandardControl { + String id(); + + public static final Comparator DEFAULT_COMPARATOR = Comparator.comparing(Control::id); +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/CustomDialog.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/CustomDialog.java new file mode 100644 index 00000000000..7325685469c --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/CustomDialog.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +/** + * Custom jpackage dialogs. + */ +public enum CustomDialog implements Dialog { + ShortcutPromptDlg, + ; + + @Override + public String id() { + return name(); + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Dialog.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Dialog.java new file mode 100644 index 00000000000..a43648042a9 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Dialog.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import java.util.Comparator; + +/** + * WiX Dialog. + */ +public sealed interface Dialog permits WixDialog, CustomDialog { + String id(); + + public static final Comparator DEFAULT_COMPARATOR = Comparator.comparing(Dialog::id); +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/DialogPair.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/DialogPair.java new file mode 100644 index 00000000000..7f0f3bb6090 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/DialogPair.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import static java.util.Comparator.comparing; + +import java.util.Comparator; +import java.util.Objects; + +public record DialogPair(Dialog first, Dialog second) { + + public DialogPair { + Objects.requireNonNull(first); + Objects.requireNonNull(second); + if (first.equals(second) || first.id().equals(second.id())) { + throw new IllegalArgumentException("Dialogs must be different"); + } + } + + DialogPair flip() { + return new DialogPair(second, first); + } + + public static final Comparator DEFAULT_COMPARATOR = + comparing(DialogPair::first, Dialog.DEFAULT_COMPARATOR) + .thenComparing(comparing(DialogPair::second, Dialog.DEFAULT_COMPARATOR)); +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Publish.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Publish.java new file mode 100644 index 00000000000..7741ad823bb --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/Publish.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import java.util.Objects; + +public record Publish(Control control, String condition, int order) { + + public Publish { + Objects.requireNonNull(control); + Objects.requireNonNull(condition); + if (order < 0) { + throw new IllegalArgumentException("Negative order"); + } + } + + Builder toBuilder() { + return new Builder(this); + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + private Builder() { + order(0); + next(); + condition("1"); + } + + private Builder(Publish publish) { + order(publish.order); + control(publish.control); + condition(publish.condition); + } + + Publish create() { + return new Publish(control, condition, order); + } + + Builder control(Control v) { + control = v; + return this; + } + + Builder next() { + return control(StandardControl.NEXT); + } + + Builder back() { + return control(StandardControl.BACK); + } + + Builder condition(String v) { + condition = v; + return this; + } + + Builder order(int v) { + order = v; + return this; + } + + private int order; + private Control control; + private String condition; + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/ShowActionSuppresser.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/ShowActionSuppresser.java new file mode 100644 index 00000000000..f89b15987ee --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/ShowActionSuppresser.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import static java.util.Comparator.comparing; + +import java.util.Comparator; +import java.util.Objects; + +public record ShowActionSuppresser(Dialog dialog, Dialog anchor, Order order) { + + public enum Order { + AFTER, + ; + } + + public ShowActionSuppresser { + Objects.requireNonNull(order); + validate(dialog); + validate(anchor); + } + + static Builder suppressShowAction(WixDialog dialog) { + return new Builder(dialog); + } + + static final class Builder { + + private Builder(WixDialog dialog) { + this.dialog = Objects.requireNonNull(dialog); + } + + ShowActionSuppresser after(WixDialog anchor) { + return new ShowActionSuppresser(dialog, anchor, Order.AFTER); + } + + private final WixDialog dialog; + } + + private static void validate(Dialog v) { + if (!(Objects.requireNonNull(v) instanceof WixDialog)) { + throw new IllegalArgumentException(); + } + } + + public static final Comparator DEFAULT_COMPARATOR = + comparing(ShowActionSuppresser::dialog, Dialog.DEFAULT_COMPARATOR) + .thenComparing(comparing(ShowActionSuppresser::anchor, Dialog.DEFAULT_COMPARATOR)) + .thenComparing(comparing(ShowActionSuppresser::order)); +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/StandardControl.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/StandardControl.java new file mode 100644 index 00000000000..43c5c5a7e9e --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/StandardControl.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import java.util.Objects; + +/** + * Dialog controls referenced in adjustments of the standard WiX UI. + */ +enum StandardControl implements Control { + NEXT("Next"), + BACK("Back"), + ; + + StandardControl(String id) { + this.id = Objects.requireNonNull(id); + } + + @Override + public String id() { + return id; + } + + private final String id; +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UIConfig.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UIConfig.java new file mode 100644 index 00000000000..c695694788f --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UIConfig.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +/** + * UI config. + */ +public record UIConfig( + boolean isWithInstallDirChooserDlg, + boolean isWithShortcutPromptDlg, + boolean isWithLicenseDlg) { + + public static Builder build() { + return new Builder(); + } + + public static final class Builder { + + private Builder() { + } + + public UIConfig create() { + return new UIConfig(isWithInstallDirChooserDlg, isWithShortcutPromptDlg, isWithLicenseDlg); + } + + public Builder withInstallDirChooserDlg(boolean v) { + isWithInstallDirChooserDlg = v; + return this; + } + + public Builder withInstallDirChooserDlg() { + return withInstallDirChooserDlg(true); + } + + public Builder withShortcutPromptDlg(boolean v) { + isWithShortcutPromptDlg = v; + return this; + } + + public Builder withShortcutPromptDlg() { + return withShortcutPromptDlg(true); + } + + public Builder withLicenseDlg(boolean v) { + isWithLicenseDlg = v; + return this; + } + + public Builder withLicenseDlg() { + return withLicenseDlg(true); + } + + private boolean isWithInstallDirChooserDlg; + private boolean isWithShortcutPromptDlg; + private boolean isWithLicenseDlg; + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UISpec.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UISpec.java new file mode 100644 index 00000000000..38cf3775c2b --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/UISpec.java @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import static jdk.jpackage.internal.wixui.CustomDialog.ShortcutPromptDlg; +import static jdk.jpackage.internal.wixui.ShowActionSuppresser.suppressShowAction; +import static jdk.jpackage.internal.wixui.WixDialog.InstallDirDlg; +import static jdk.jpackage.internal.wixui.WixDialog.LicenseAgreementDlg; +import static jdk.jpackage.internal.wixui.WixDialog.ProgressDlg; +import static jdk.jpackage.internal.wixui.WixDialog.VerifyReadyDlg; +import static jdk.jpackage.internal.wixui.WixDialog.WelcomeDlg; +import static jdk.jpackage.internal.wixui.WixDialog.WelcomeEulaDlg; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +/** + * UI spec. + *

    + * UI is based on one of the standard WiX UIs with optional alterations. + */ +public record UISpec( + WixUI wixUI, + Map wixVariables, + Map customDialogSequence, + Collection hideDialogs) { + + public UISpec { + Objects.requireNonNull(wixUI); + Objects.requireNonNull(wixVariables); + Objects.requireNonNull(customDialogSequence); + Objects.requireNonNull(hideDialogs); + } + + static Builder build(WixUI wixUI) { + return new Builder().wixUI(wixUI); + } + + static final class Builder { + + private Builder() { + } + + UISpec create() { + return new UISpec( + wixUI, + Optional.ofNullable(wixVariables).map(Collections::unmodifiableMap).orElseGet(Map::of), + Optional.ofNullable(customDialogSequence).map(Collections::unmodifiableMap).orElseGet(Map::of), + Optional.ofNullable(hideDialogs).map(List::copyOf).orElseGet(List::of)); + } + + Builder wixUI(WixUI v) { + wixUI = v; + return this; + } + + Builder setWixVariable(String name, String value) { + wixVariables.put(Objects.requireNonNull(name), Objects.requireNonNull(value)); + return this; + } + + Builder customDialogSequence(Map v) { + customDialogSequence = v; + return this; + } + + Builder hideDialogs(Collection v) { + hideDialogs = v; + return this; + } + + Builder hideDialogs(ShowActionSuppresser... v) { + return hideDialogs(List.of(v)); + } + + private WixUI wixUI; + private final Map wixVariables = new HashMap<>(); + private Map customDialogSequence; + private Collection hideDialogs; + } + + public static UISpec create(UIConfig cfg) { + Objects.requireNonNull(cfg); + return Optional.ofNullable(DEFAULT_SPECS.get(cfg)).map(Supplier::get).orElseGet(() -> { + return createCustom(cfg); + }); + } + + private static UISpec createCustom(UIConfig cfg) { + Objects.requireNonNull(cfg); + + var dialogs = installDirUiDialogs(cfg); + var dialogPairs = toDialogPairs(dialogs); + + var customDialogSequence = overrideInstallDirDialogSequence().stream().filter(e -> { + return dialogPairs.contains(e.getKey()); + }).collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); + + var uiSpec = build(WixUI.INSTALL_DIR).customDialogSequence(customDialogSequence); + + var it = dialogs.iterator(); + do { + if (it.next().equals(InstallDirDlg)) { + uiSpec.setWixVariable("JpAfterInstallDirDlg", it.next().id()); + } + } while (it.hasNext()); + + return uiSpec.create(); + } + + private static void createPairs( + BiConsumer sink, + Dialog first, + Dialog second, + Publish publishNext, + Publish publishPrev) { + + createPairNext(sink, first, second, publishNext); + createPairBack(sink, second, first, publishPrev); + } + + private static void createPairs( + BiConsumer sink, + Dialog first, + Dialog second, + Publish publish) { + createPairs(sink, first, second, publish, publish); + } + + private static void createPairNext( + BiConsumer sink, + Dialog first, + Dialog second, + Publish publish) { + + var pair = new DialogPair(first, second); + + sink.accept(pair, publish.toBuilder().next().create()); + } + + private static void createPairBack( + BiConsumer sink, + Dialog first, + Dialog second, + Publish publish) { + + var pair = new DialogPair(first, second); + + sink.accept(pair, publish.toBuilder().back().create()); + } + + private static Collection toDialogPairs(List

    dialogs) { + if (dialogs.size() < 2) { + throw new IllegalArgumentException(); + } + + var pairs = new ArrayList(); + var it = dialogs.listIterator(); + var prev = it.next(); + do { + var next = it.next(); + var pair = new DialogPair(prev, next); + pairs.add(pair); + pairs.add(pair.flip()); + prev = next; + } while (it.hasNext()); + + return pairs; + } + + private static List installDirUiDialogs(UIConfig cfg) { + var dialogs = new ArrayList(); + + dialogs.add(WelcomeDlg); + + if (cfg.isWithLicenseDlg()) { + dialogs.add(LicenseAgreementDlg); + } + + if (cfg.isWithInstallDirChooserDlg()) { + dialogs.add(InstallDirDlg); + } + + if (cfg.isWithShortcutPromptDlg()) { + dialogs.add(ShortcutPromptDlg); + } + + dialogs.add(VerifyReadyDlg); + + return dialogs; + } + + private static Collection> overrideInstallDirDialogSequence() { + + List> entries = new ArrayList<>(); + + BiConsumer acc = (pair, publish) -> { + entries.add(Map.entry(pair, publish)); + }; + + // Order is a "weight" of action. If there are multiple + // "NewDialog" action for the same dialog Id, MSI would pick the one + // with higher order value. In WixUI_InstallDir dialog sequence the + // highest order value is 4. InstallDirNotEmptyDlg adds NewDialog + // action with order 5. Setting order to 6 for all + // actions configured in this function would make them executed + // instead of corresponding default actions defined in + // WixUI_InstallDir dialog sequence. + var order = 6; + + // Based on WixUI_InstallDir.wxs + var backFromVerifyReadyDlg = Publish.build().condition(CONDITION_NOT_INSTALLED).order(order).create(); + var uncondinal = Publish.build().condition(CONDITION_ALWAYS).create(); + var ifNotIstalled = Publish.build().condition(CONDITION_NOT_INSTALLED).order(order).create(); + var ifLicenseAccepted = Publish.build().condition("LicenseAccepted = \"1\"").order(order).create(); + + // Define all alternative transitions: + // - Skip standard license dialog + // - Insert shortcut prompt dialog after the standard install dir dialog + // - Replace the standard install dir dialog with the shortcut prompt dialog + + createPairs(acc, WelcomeDlg, InstallDirDlg, ifNotIstalled); + createPairs(acc, WelcomeDlg, VerifyReadyDlg, ifNotIstalled); + createPairs(acc, WelcomeDlg, ShortcutPromptDlg, ifNotIstalled); + + createPairs(acc, LicenseAgreementDlg, ShortcutPromptDlg, ifLicenseAccepted, uncondinal); + createPairs(acc, LicenseAgreementDlg, VerifyReadyDlg, ifLicenseAccepted, backFromVerifyReadyDlg); + + createPairs(acc, InstallDirDlg, ShortcutPromptDlg, uncondinal); + + createPairs(acc, ShortcutPromptDlg, VerifyReadyDlg, uncondinal, backFromVerifyReadyDlg); + + return entries; + } + + private static final Map> DEFAULT_SPECS; + + private static final String CONDITION_ALWAYS = "1"; + private static final String CONDITION_NOT_INSTALLED = "NOT Installed"; + + static { + + var specs = new HashMap>(); + + // Verbatim WiX "Minimal" dialog set. + specs.put(UIConfig.build() + .withLicenseDlg() + .create(), () -> { + return build(WixUI.MINIMAL).create(); + }); + + // Standard WiX "Minimal" dialog set without the license dialog. + // The license dialog is removed by overriding the default "Show" + // action with the condition that always evaluates to "FALSE". + specs.put(UIConfig.build() + .create(), () -> { + return build(WixUI.MINIMAL).hideDialogs(suppressShowAction(WelcomeEulaDlg).after(ProgressDlg)).create(); + }); + + DEFAULT_SPECS = Collections.unmodifiableMap(specs); + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixDialog.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixDialog.java new file mode 100644 index 00000000000..95c415dcaa0 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixDialog.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +/** + * Standard WiX dialogs. + */ +enum WixDialog implements Dialog { + InstallDirDlg, + LicenseAgreementDlg, + ProgressDlg, + VerifyReadyDlg, + WelcomeDlg, + WelcomeEulaDlg, + ; + + @Override + public String id() { + return name(); + } +} diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixUI.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixUI.java new file mode 100644 index 00000000000..1b87a7fee2d --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/wixui/WixUI.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2026, 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.jpackage.internal.wixui; + +import java.util.Objects; + +/** + * Standard WiX UI. + */ +public enum WixUI { + MINIMAL("WixUI_Minimal"), + INSTALL_DIR("WixUI_InstallDir"), + ; + + WixUI(String id) { + this.id = Objects.requireNonNull(id); + } + + public String id() { + return id; + } + + private final String id; +} diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java index 57d427c1774..eba81b4be07 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +49,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -181,6 +182,7 @@ class ConsoleIOContext extends IOContext { setupReader.accept(reader); reader.setOpt(Option.DISABLE_EVENT_EXPANSION); + reader.setVariable(LineReader.WORDCHARS, "_$"); reader.setParser((line, cursor, context) -> { if (!ConsoleIOContext.this.allowIncompleteInputs && !repl.isComplete(line)) { @@ -201,6 +203,7 @@ class ConsoleIOContext extends IOContext { .filter(key -> key.startsWith(HISTORY_LINE_PREFIX)) .sorted() .map(key -> repl.prefs.get(key)) + .filter(Objects::nonNull) .forEach(loadHistory::add); for (ListIterator it = loadHistory.listIterator(); it.hasNext(); ) { diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java index bc6f6d30236..70f3b70fd66 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java @@ -337,7 +337,7 @@ class Eval { Set anonymousClasses = Collections.emptySet(); StringBuilder sbBrackets = new StringBuilder(); Tree baseType = vt.getType(); - if (baseType != null) { + if (vt.getType() != null && vt.getType().getKind() != Tree.Kind.VAR_TYPE) { tds.scan(baseType); // Not dependent on initializer fullTypeName = displayType = typeName = EvalPretty.prettyExpr((JCTree) vt.getType(), false); while (baseType instanceof ArrayTypeTree) { diff --git a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 1cf0c85702f..35faab231af 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -816,7 +816,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { SourcePositions sp = trees.getSourcePositions(); List tokens = new ArrayList<>(); Context ctx = new Context(); - ctx.put(DiagnosticListener.class, (DiagnosticListener) d -> {}); + ctx.put(DiagnosticListener.class, (DiagnosticListener) d -> {}); Scanner scanner = ScannerFactory.instance(ctx).newScanner(wrappedCode, false); Log.instance(ctx).useSource(cut.getSourceFile()); scanner.nextToken(); @@ -932,7 +932,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { @Override public Void visitVariable(VariableTree node, Void p) { int pos = ((JCTree) node).pos; - if (sp.getEndPosition(cut, node.getType()) == (-1)) { + if (node.getType() != null && node.getType().getKind() == Kind.VAR_TYPE) { Token varCandidate = findTokensBefore(pos, TokenKind.IDENTIFIER); if (varCandidate != null && "var".equals(varCandidate.name().toString())) { addKeyword.accept(varCandidate); diff --git a/src/jdk.management/share/classes/com/sun/management/doc-files/threadDump.schema.json b/src/jdk.management/share/classes/com/sun/management/doc-files/threadDump.schema.json index bf52bb3915d..1da3e3941ef 100644 --- a/src/jdk.management/share/classes/com/sun/management/doc-files/threadDump.schema.json +++ b/src/jdk.management/share/classes/com/sun/management/doc-files/threadDump.schema.json @@ -81,7 +81,7 @@ "owner": { "type": "string", "description": "The thread identifier of the owner when the parkBlocker is an AbstractOwnableSynchronizer." - } + }, "required": [ "object" ] diff --git a/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java index 589744641e4..aaed4d3e048 100644 --- a/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java +++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,6 @@ import java.awt.Toolkit; import java.awt.Window; import java.awt.AWTEvent; import sun.awt.SunToolkit; -import sun.awt.AppContext; import sun.awt.UngrabEvent; /** @@ -47,10 +46,7 @@ public class SwingInterOpUtils { public SwingInterOpUtils() {} public static void postEvent(Object target, java.awt.AWTEvent e) { - AppContext context = SunToolkit.targetToAppContext(target); - if (context != null) { - SunToolkit.postEvent(context, e); - } + SunToolkit.postEvent(e); } public static void grab(Toolkit toolkit, Window window) { diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index ab471694890..3223ff9dccd 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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 @@ -105,6 +105,9 @@ class ZipFileSystem extends FileSystem { private static final String COMPRESSION_METHOD_DEFLATED = "DEFLATED"; // Value specified for compressionMethod property to not compress Zip entries private static final String COMPRESSION_METHOD_STORED = "STORED"; + // CEN size is limited to the maximum array size in the JDK + // See ArraysSupport.SOFT_MAX_ARRAY_LENGTH; + private static final int MAX_CEN_SIZE = Integer.MAX_VALUE - 8; private final ZipFileSystemProvider provider; private final Path zfpath; @@ -1233,7 +1236,7 @@ class ZipFileSystem extends FileSystem { private volatile boolean isOpen = true; private final SeekableByteChannel ch; // channel to the zipfile - final byte[] cen; // CEN & ENDHDR + final byte[] cen; // CEN private END end; private long locpos; // position of first LOC header (usually 0) @@ -1353,7 +1356,7 @@ class ZipFileSystem extends FileSystem { // to use the end64 values end.cenlen = cenlen64; end.cenoff = cenoff64; - end.centot = (int)centot64; // assume total < 2g + end.centot = centot64; end.endpos = end64pos; return end; } @@ -1575,25 +1578,36 @@ class ZipFileSystem extends FileSystem { buildNodeTree(); return null; // only END header present } - if (end.cenlen > end.endpos) - throw new ZipException("invalid END header (bad central directory size)"); + // Validate END header + if (end.cenlen > end.endpos) { + zerror("invalid END header (bad central directory size)"); + } long cenpos = end.endpos - end.cenlen; // position of CEN table - // Get position of first local file (LOC) header, taking into - // account that there may be a stub prefixed to the zip file. + // account that there may be a stub prefixed to the ZIP file. locpos = cenpos - end.cenoff; - if (locpos < 0) - throw new ZipException("invalid END header (bad central directory offset)"); + if (locpos < 0) { + zerror("invalid END header (bad central directory offset)"); + } + if (end.cenlen > MAX_CEN_SIZE) { + zerror("invalid END header (central directory size too large)"); + } + if (end.centot < 0 || end.centot > end.cenlen / CENHDR) { + zerror("invalid END header (total entries count too large)"); + } + // Validation ensures these are <= Integer.MAX_VALUE + int cenlen = Math.toIntExact(end.cenlen); + int centot = Math.toIntExact(end.centot); - // read in the CEN and END - byte[] cen = new byte[(int)(end.cenlen + ENDHDR)]; - if (readNBytesAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) { - throw new ZipException("read CEN tables failed"); + // read in the CEN + byte[] cen = new byte[cenlen]; + if (readNBytesAt(cen, 0, cen.length, cenpos) != cenlen) { + zerror("read CEN tables failed"); } // Iterate through the entries in the central directory - inodes = LinkedHashMap.newLinkedHashMap(end.centot + 1); + inodes = LinkedHashMap.newLinkedHashMap(centot + 1); int pos = 0; - int limit = cen.length - ENDHDR; + int limit = cen.length; while (pos < limit) { if (!cenSigAt(cen, pos)) throw new ZipException("invalid CEN header (bad signature)"); @@ -1641,7 +1655,7 @@ class ZipFileSystem extends FileSystem { // skip ext and comment pos += (CENHDR + nlen + elen + clen); } - if (pos + ENDHDR != cen.length) { + if (pos != cen.length) { throw new ZipException("invalid CEN header (bad header size)"); } buildNodeTree(); @@ -1671,7 +1685,7 @@ class ZipFileSystem extends FileSystem { } // CEN Offset where this Extra field ends int extraEndOffset = startingOffset + extraFieldLen; - if (extraEndOffset > cen.length - ENDHDR) { + if (extraEndOffset > cen.length) { zerror("Invalid CEN header (extra data field size too long)"); } int currentOffset = startingOffset; @@ -2666,7 +2680,7 @@ class ZipFileSystem extends FileSystem { // int disknum; // int sdisknum; // int endsub; - int centot; // 4 bytes + long centot; // 4 bytes long cenlen; // 4 bytes long cenoff; // 4 bytes // int comlen; // comment length @@ -2689,7 +2703,7 @@ class ZipFileSystem extends FileSystem { xoff = ZIP64_MINVAL; hasZip64 = true; } - int count = centot; + int count = Math.toIntExact(centot); if (count >= ZIP64_MINVAL32) { count = ZIP64_MINVAL32; hasZip64 = true; diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java index 66af78e53d2..adfa975c1c3 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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 @@ -55,6 +55,8 @@ import static java.nio.file.StandardOpenOption.WRITE; */ final class ZipPath implements Path { + private static final byte[] EMPTY_PATH = new byte[0]; + private final ZipFileSystem zfs; private final byte[] path; private volatile int[] offsets; @@ -93,8 +95,15 @@ final class ZipPath implements Path { @Override public ZipPath getFileName() { int off = path.length; - if (off == 0 || off == 1 && path[0] == '/') + if (off == 0) { + // empty path, which is defined as consisting solely of + // one name element that is empty + return new ZipPath(getFileSystem(), EMPTY_PATH, true); + } + if (off == 1 && path[0] == '/') { + // root path, which is defined as having 0 name elements return null; + } while (--off >= 0 && path[off] != '/') {} if (off < 0) return this; diff --git a/test/docs/TEST.ROOT b/test/docs/TEST.ROOT index 9a7e66b631c..11cba9c1c88 100644 --- a/test/docs/TEST.ROOT +++ b/test/docs/TEST.ROOT @@ -40,11 +40,6 @@ groups=TEST.groups # Minimum jtreg version requiredVersion=8.2.1+1 -# Use new module options -useNewOptions=true - -# Use --patch-module instead of -Xmodule: -useNewPatchModule=true # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/test/hotspot/gtest/aarch64/test_spin_pause.cpp b/test/hotspot/gtest/aarch64/test_spin_pause.cpp index e220362eae9..98d05e030c2 100644 --- a/test/hotspot/gtest/aarch64/test_spin_pause.cpp +++ b/test/hotspot/gtest/aarch64/test_spin_pause.cpp @@ -21,7 +21,9 @@ * questions. */ -#if defined(AARCH64) && !defined(ZERO) +// Skip Windows to prevent GTestWrapper.java from failing because +// SpinPause is not implemented on Windows (and therefore returns 0) +#if defined(AARCH64) && !defined(ZERO) && !defined(_WINDOWS) #include "utilities/spinYield.hpp" #include "unittest.hpp" diff --git a/test/hotspot/gtest/cds/test_scaledOffsets.cpp b/test/hotspot/gtest/cds/test_scaledOffsets.cpp new file mode 100644 index 00000000000..93b1b211276 --- /dev/null +++ b/test/hotspot/gtest/cds/test_scaledOffsets.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2026 salesforce.com, inc. 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. + * + */ + +#include "cds/aotCompressedPointers.hpp" +#include "unittest.hpp" +#include "utilities/globalDefinitions.hpp" + +#include + +TEST_VM(ScaledOffsetsTest, constants) { +#ifdef _LP64 + ASSERT_EQ((size_t)3, AOTCompressedPointers::MetadataOffsetShift); + ASSERT_TRUE(is_aligned(AOTCompressedPointers::MaxMetadataOffsetBytes, (size_t)1 << AOTCompressedPointers::MetadataOffsetShift)); + ASSERT_EQ((size_t)(3584ULL * M), AOTCompressedPointers::MaxMetadataOffsetBytes); +#else + ASSERT_EQ((size_t)0, AOTCompressedPointers::MetadataOffsetShift); + ASSERT_EQ((size_t)0x7FFFFFFF, AOTCompressedPointers::MaxMetadataOffsetBytes); +#endif +} + +TEST_VM(ScaledOffsetsTest, encode_decode_roundtrip) { + // Test that encoding and decoding via get_byte_offset produces correct results + const size_t unit = (size_t)1 << AOTCompressedPointers::MetadataOffsetShift; + + // Test that get_byte_offset correctly applies the shift + // Note: We can't directly test encode_byte_offset as it's private, but we can verify + // the shift value is applied correctly in get_byte_offset + AOTCompressedPointers::narrowPtr np1 = static_cast(1); + ASSERT_EQ(unit, AOTCompressedPointers::get_byte_offset(np1)); + + AOTCompressedPointers::narrowPtr np2 = static_cast(2); + ASSERT_EQ(2 * unit, AOTCompressedPointers::get_byte_offset(np2)); + + AOTCompressedPointers::narrowPtr np1024 = static_cast(1024); + ASSERT_EQ(1024 * unit, AOTCompressedPointers::get_byte_offset(np1024)); + +#ifdef _LP64 + const uint64_t max_units = (uint64_t)UINT32_MAX; + AOTCompressedPointers::narrowPtr np_max = static_cast(UINT32_MAX); + const uint64_t max_bytes = max_units << AOTCompressedPointers::MetadataOffsetShift; + ASSERT_EQ(max_bytes, AOTCompressedPointers::get_byte_offset(np_max)); + ASSERT_GE(max_bytes, AOTCompressedPointers::MaxMetadataOffsetBytes - unit); +#endif +} + +TEST_VM(ScaledOffsetsTest, null_handling) { + // Test that null() returns 0 + ASSERT_EQ(static_cast(0), AOTCompressedPointers::null()); + ASSERT_EQ((size_t)0, AOTCompressedPointers::get_byte_offset(AOTCompressedPointers::null())); +} diff --git a/test/hotspot/gtest/gc/shenandoah/test_shenandoahGlobalHeuristic.cpp b/test/hotspot/gtest/gc/shenandoah/test_shenandoahGlobalHeuristic.cpp new file mode 100644 index 00000000000..7b3e4227b5c --- /dev/null +++ b/test/hotspot/gtest/gc/shenandoah/test_shenandoahGlobalHeuristic.cpp @@ -0,0 +1,332 @@ +/* + * Copyright Amazon.com Inc. 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. + */ + +#include "unittest.hpp" +#include "gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp" + +// Region size of 256K is the minimum Shenandoah region size. +static const size_t REGION_SIZE = 256 * 1024; + +// Waste factors matching the default JVM flag values. +static const double OLD_EVAC_WASTE = ShenandoahOldEvacWaste; +static const double PROMO_EVAC_WASTE = ShenandoahPromoEvacWaste; +static const double YOUNG_EVAC_WASTE = ShenandoahEvacWaste; + +// Default thresholds as percentages of region size. +static const size_t GARBAGE_THRESHOLD = REGION_SIZE * 25 / 100; +static const size_t IGNORE_THRESHOLD = REGION_SIZE * 5 / 100; + +static ShenandoahGlobalCSetBudget make_budget(size_t shared_reserves, + size_t min_garbage = 0, + size_t young_evac_reserve = 0, + size_t old_evac_reserve = 0, + size_t promo_reserve = 0) { + return ShenandoahGlobalCSetBudget(REGION_SIZE, shared_reserves, + GARBAGE_THRESHOLD, IGNORE_THRESHOLD, min_garbage, + young_evac_reserve, YOUNG_EVAC_WASTE, + old_evac_reserve, OLD_EVAC_WASTE, + promo_reserve, PROMO_EVAC_WASTE); +} + +// ---- Threshold tests ---- + +// A region whose garbage is 1 byte below the 25% garbage threshold should be +// skipped, even when there is plenty of shared reserve available. +TEST(ShenandoahGlobalCSet, skip_below_garbage_threshold) { + auto budget = make_budget(10 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD - 1, REGION_SIZE - (GARBAGE_THRESHOLD - 1), 0, false, false + }; + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); +} + +// When the cumulative garbage collected so far is below min_garbage, regions +// with garbage above the ignore threshold (5%) but below the garbage threshold +// (25%) are added anyway ("add_regardless" path). This young non-tenurable +// region should be accepted as a young evacuation. +TEST(ShenandoahGlobalCSet, add_regardless_when_below_min_garbage) { + auto budget = make_budget(10 * REGION_SIZE, /*min_garbage=*/REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + IGNORE_THRESHOLD + 1, 1000, 0, false, false + }; + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_YOUNG_EVAC); +} + +// A region whose garbage is exactly at the ignore threshold (not above it) +// should be skipped even when min_garbage has not been met, because the +// add_regardless condition requires garbage strictly above the ignore threshold. +TEST(ShenandoahGlobalCSet, skip_at_ignore_threshold) { + auto budget = make_budget(10 * REGION_SIZE, /*min_garbage=*/REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + IGNORE_THRESHOLD, 1000, 0, false, false + }; + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); +} + +// ---- Old region evacuation ---- + +// An old region at the garbage threshold with 50K live and 10K free, backed by +// ample shared reserves. Should be accepted as old evacuation. The old_evac +// budget consumes 50K * 1.4 = 70K for evacuation, and the promo budget absorbs +// the 10K of free bytes that are lost when this region enters the collection set. +TEST(ShenandoahGlobalCSet, old_region_accepted) { + auto budget = make_budget(5 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 50000, 10000, true, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_OLD_EVAC); + EXPECT_EQ(budget.old_evac.region_count(), (size_t)1); + EXPECT_EQ(budget.old_evac.live_bytes(), (size_t)50000); + EXPECT_EQ(budget.old_evac.consumed(), (size_t)(50000 * OLD_EVAC_WASTE)); + EXPECT_EQ(budget.promo.consumed(), (size_t)10000); + EXPECT_EQ(budget.cur_garbage(), GARBAGE_THRESHOLD); +} + +// An old region with zero shared reserves and no per-category reserves. Both +// the old_evac and promo reservations will fail, so the region is skipped. +// Verify that all budget state remains at zero (clean rollback). +TEST(ShenandoahGlobalCSet, old_region_rejected_no_budget) { + auto budget = make_budget(0); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 50000, 10000, true, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); + EXPECT_EQ(budget.old_evac.region_count(), (size_t)0); + EXPECT_EQ(budget.committed_from_shared(), (size_t)0); + EXPECT_EQ(budget.old_evac.consumed(), (size_t)0); + EXPECT_EQ(budget.promo.consumed(), (size_t)0); +} + +// An old region with no per-category reserves but sufficient shared reserves. +// The old_evac budget must expand from the shared pool to accommodate the +// evacuation. Since old_evac starts at zero, all of its reserve comes from +// shared, so committed_from_shared should equal old_evac.reserve(). +TEST(ShenandoahGlobalCSet, old_region_expands_shared) { + auto budget = make_budget(5 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 50000, 0, true, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_OLD_EVAC); + EXPECT_GT(budget.committed_from_shared(), (size_t)0); + EXPECT_EQ(budget.committed_from_shared(), budget.old_evac.reserve()); + EXPECT_GE(budget.old_evac.reserve(), budget.old_evac.consumed()); +} + +// An old region with enough old_evac reserve for the live data but zero promo +// reserve, and a full region's worth of free bytes. The free bytes represent +// promotion capacity that is lost when this region enters the cset, so the +// promo budget must expand from shared reserves to absorb that loss. +TEST(ShenandoahGlobalCSet, old_region_free_bytes_consume_promo_reserve) { + size_t live_data = 10000; + size_t evac_needed = (size_t)(live_data * OLD_EVAC_WASTE); + auto budget = make_budget(5 * REGION_SIZE, 0, 0, evac_needed, 0); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, live_data, REGION_SIZE, true, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_OLD_EVAC); + EXPECT_GT(budget.committed_from_shared(), (size_t)0); + EXPECT_GE(budget.promo.reserve(), (size_t)REGION_SIZE); + EXPECT_EQ(budget.promo.consumed(), (size_t)REGION_SIZE); +} + +// ---- Promotion ---- + +// A young tenurable region at the garbage threshold with 40K live data and +// ample shared reserves. Should be accepted as a promotion. The promo budget +// consumes 40K * 1.2 = 48K. +TEST(ShenandoahGlobalCSet, tenurable_region_promoted) { + auto budget = make_budget(5 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 40000, 0, false, true + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_PROMO); + EXPECT_EQ(budget.promo.region_count(), (size_t)1); + EXPECT_EQ(budget.promo.live_bytes(), (size_t)40000); + EXPECT_EQ(budget.promo.consumed(), (size_t)(40000 * PROMO_EVAC_WASTE)); +} + +// A young tenurable region with zero reserves. The promo reservation fails, +// so the region is skipped. +TEST(ShenandoahGlobalCSet, tenurable_region_rejected) { + auto budget = make_budget(0); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 40000, 0, false, true + }; + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); +} + +// ---- Young evacuation ---- + +// A young non-tenurable region at the garbage threshold with 30K live data. +// Should be accepted as a young evacuation. The young_evac budget consumes +// 30K * 1.2 = 36K. +TEST(ShenandoahGlobalCSet, young_region_evacuated) { + auto budget = make_budget(5 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 30000, 0, false, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_YOUNG_EVAC); + EXPECT_EQ(budget.young_evac.region_count(), (size_t)1); + EXPECT_EQ(budget.young_evac.consumed(), (size_t)(30000 * YOUNG_EVAC_WASTE)); +} + +// A young non-tenurable region with zero reserves. The young_evac reservation +// fails, so the region is skipped. +TEST(ShenandoahGlobalCSet, young_region_rejected) { + auto budget = make_budget(0); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 30000, 0, false, false + }; + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); +} + +// ---- Multi-region and budget interaction tests ---- + +// Evaluate two identical young regions against a budget with only 1 region's +// worth of shared reserves. Each region has 150K live data, so anticipated +// consumption is 150K * 1.2 = 180K per region. The first region expands the +// young_evac reserve by one region (256K) from shared, consuming 180K of it. +// The second region needs another 180K, but only 76K remains in the reserve +// and the shared pool is exhausted, so it must be skipped. +TEST(ShenandoahGlobalCSet, shared_exhausted_across_regions) { + auto budget = make_budget(1 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 150000, 0, false, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_YOUNG_EVAC); + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::SKIP); + EXPECT_EQ(budget.young_evac.region_count(), (size_t)1); +} + +// An old region where the old_evac reserve is pre-sized to exactly cover the +// evacuation need, and the promo reserve covers the free bytes loss. No shared +// reserves should be drawn because the per-category reserves are sufficient. +TEST(ShenandoahGlobalCSet, existing_reserve_used_before_shared) { + size_t live_data = 50000; + size_t evac_needed = (size_t)(live_data * OLD_EVAC_WASTE); + auto budget = make_budget(5 * REGION_SIZE, 0, 0, evac_needed, REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, live_data, 1000, true, false + }; + + EXPECT_EQ(budget.try_add_region(region), ShenandoahGlobalRegionDisposition::ADD_OLD_EVAC); + EXPECT_EQ(budget.committed_from_shared(), (size_t)0); +} + +// Evaluate two identical young regions and verify that cur_garbage accumulates +// the garbage from each accepted region. +TEST(ShenandoahGlobalCSet, garbage_accumulates) { + auto budget = make_budget(10 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 10000, 0, false, false + }; + + budget.try_add_region(region); + EXPECT_EQ(budget.cur_garbage(), GARBAGE_THRESHOLD); + budget.try_add_region(region); + EXPECT_EQ(budget.cur_garbage(), 2 * GARBAGE_THRESHOLD); +} + +// When no regions are evaluated, finish() should donate the entire shared +// reserve pool to the promo budget. +TEST(ShenandoahGlobalCSet, finish_donates_remaining_to_promo) { + auto budget = make_budget(5 * REGION_SIZE); + size_t promo_before = budget.promo.reserve(); + budget.finish(); + EXPECT_EQ(budget.promo.reserve(), promo_before + 5 * REGION_SIZE); +} + +// After evaluating one region that draws from the shared pool, finish() should +// donate only the remaining (unconsumed) shared reserves to promo. +TEST(ShenandoahGlobalCSet, finish_donates_remainder_after_use) { + auto budget = make_budget(5 * REGION_SIZE); + ShenandoahGlobalRegionAttributes region = { + GARBAGE_THRESHOLD, 10000, 0, false, false + }; + budget.try_add_region(region); + size_t shared_used = budget.committed_from_shared(); + size_t promo_before = budget.promo.reserve(); + budget.finish(); + EXPECT_EQ(budget.promo.reserve(), promo_before + (5 * REGION_SIZE - shared_used)); +} + +// ---- ShenandoahEvacuationBudget unit tests ---- + +// A reservation that fits entirely within the existing reserve should succeed +// without drawing from the shared pool. +TEST(ShenandoahEvacuationBudget, try_reserve_fits_without_expansion) { + ShenandoahSharedEvacReserve shared(5 * REGION_SIZE); + ShenandoahEvacuationBudget evac_budget(REGION_SIZE, 1.0, REGION_SIZE, &shared); + EXPECT_TRUE(evac_budget.try_reserve(REGION_SIZE)); + EXPECT_EQ(shared.committed, (size_t)0); + EXPECT_EQ(evac_budget.reserve(), (size_t)REGION_SIZE); +} + +// A reservation of REGION_SIZE+1 bytes starting from a zero reserve requires +// two region-sized expansions from the shared pool (one region isn't enough). +TEST(ShenandoahEvacuationBudget, try_reserve_expands_from_shared) { + ShenandoahSharedEvacReserve shared(5 * REGION_SIZE); + ShenandoahEvacuationBudget evac_budget(0, 1.0, REGION_SIZE, &shared); + EXPECT_TRUE(evac_budget.try_reserve(REGION_SIZE + 1)); + EXPECT_EQ(shared.committed, 2 * REGION_SIZE); + EXPECT_EQ(evac_budget.reserve(), 2 * REGION_SIZE); +} + +// A reservation with an empty shared pool should fail, leaving both the +// budget's reserve and the shared pool's committed count unchanged. +TEST(ShenandoahEvacuationBudget, try_reserve_fails_no_shared) { + ShenandoahSharedEvacReserve shared(0); + ShenandoahEvacuationBudget evac_budget(0, 1.0, REGION_SIZE, &shared); + EXPECT_FALSE(evac_budget.try_reserve(REGION_SIZE)); + EXPECT_EQ(shared.committed, (size_t)0); + EXPECT_EQ(evac_budget.reserve(), (size_t)0); +} + +// A reservation of 3 regions against a shared pool of only 2 regions should +// fail. On failure, neither the budget's reserve nor the shared pool's +// committed count should be modified. +TEST(ShenandoahEvacuationBudget, try_reserve_fails_insufficient_shared) { + ShenandoahSharedEvacReserve shared(2 * REGION_SIZE); + ShenandoahEvacuationBudget evac_budget(0, 1.0, REGION_SIZE, &shared); + EXPECT_FALSE(evac_budget.try_reserve(3 * REGION_SIZE)); + EXPECT_EQ(shared.committed, (size_t)0); + EXPECT_EQ(evac_budget.reserve(), (size_t)0); +} + +// Committing a consumption of 1200 bytes with 1000 live bytes should update +// all three tracking fields: consumed, live_bytes, and region_count. +TEST(ShenandoahEvacuationBudget, commit_updates_fields) { + ShenandoahSharedEvacReserve shared(5 * REGION_SIZE); + ShenandoahEvacuationBudget evac_budget(REGION_SIZE, 1.2, REGION_SIZE, &shared); + evac_budget.commit(1200, 1000); + EXPECT_EQ(evac_budget.consumed(), (size_t)1200); + EXPECT_EQ(evac_budget.live_bytes(), (size_t)1000); + EXPECT_EQ(evac_budget.region_count(), (size_t)1); +} diff --git a/test/hotspot/gtest/gc/shenandoah/test_shenandoahMarkBitMap.cpp b/test/hotspot/gtest/gc/shenandoah/test_shenandoahMarkBitMap.cpp index 3dbb7c62122..18cf3b3333f 100644 --- a/test/hotspot/gtest/gc/shenandoah/test_shenandoahMarkBitMap.cpp +++ b/test/hotspot/gtest/gc/shenandoah/test_shenandoahMarkBitMap.cpp @@ -165,8 +165,8 @@ public: static bool run_test() { ShenandoahHeap* heap = ShenandoahHeap::heap(); - size_t heap_size = heap->max_capacity(); - size_t heap_size_words = heap_size / HeapWordSize; + size_t test_heap_size = MIN2(32 * M, heap->max_capacity()); + size_t heap_size_words = test_heap_size / HeapWordSize; HeapWord* my_heap_memory = heap->base(); HeapWord* end_of_my_heap = my_heap_memory + heap_size_words; MemRegion heap_descriptor(my_heap_memory, heap_size_words); @@ -175,7 +175,7 @@ public: _assertion_failures = 0; size_t bitmap_page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); - size_t bitmap_size_orig = ShenandoahMarkBitMap::compute_size(heap_size); + size_t bitmap_size_orig = ShenandoahMarkBitMap::compute_size(test_heap_size); size_t bitmap_size = align_up(bitmap_size_orig, bitmap_page_size); size_t bitmap_word_size = (bitmap_size + HeapWordSize - 1) / HeapWordSize; diff --git a/test/hotspot/gtest/gc/shenandoah/test_shenandoahOldGeneration.cpp b/test/hotspot/gtest/gc/shenandoah/test_shenandoahOldGeneration.cpp index 4167e33b706..4633d8588d3 100644 --- a/test/hotspot/gtest/gc/shenandoah/test_shenandoahOldGeneration.cpp +++ b/test/hotspot/gtest/gc/shenandoah/test_shenandoahOldGeneration.cpp @@ -26,6 +26,7 @@ #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" +#include "gc/shenandoah/shenandoahPLAB.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" #define SKIP_IF_NOT_SHENANDOAH() \ @@ -58,10 +59,15 @@ protected: old->set_evacuation_reserve(512 * HeapWordSize); Thread* thread = Thread::current(); - ShenandoahThreadLocalData::reset_plab_promoted(thread); - ShenandoahThreadLocalData::disable_plab_promotions(thread); - ShenandoahThreadLocalData::set_plab_actual_size(thread, INITIAL_PLAB_SIZE); - ShenandoahThreadLocalData::add_to_plab_promoted(thread, INITIAL_PLAB_PROMOTED); + ShenandoahPLAB* shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + if (shenandoah_plab == nullptr) { + ShenandoahThreadLocalData::initialize_gclab(thread); + shenandoah_plab = ShenandoahThreadLocalData::shenandoah_plab(thread); + } + shenandoah_plab->reset_promoted(); + shenandoah_plab->disable_promotions(); + shenandoah_plab->set_actual_size(INITIAL_PLAB_SIZE); + shenandoah_plab->add_to_promoted(INITIAL_PLAB_PROMOTED); } void TearDown() override { @@ -72,15 +78,15 @@ protected: } static bool promotions_enabled() { - return ShenandoahThreadLocalData::allow_plab_promotions(Thread::current()); + return ShenandoahThreadLocalData::shenandoah_plab(Thread::current())->allows_promotion(); } static size_t plab_size() { - return ShenandoahThreadLocalData::get_plab_actual_size(Thread::current()); + return ShenandoahThreadLocalData::shenandoah_plab(Thread::current())->get_actual_size(); } static size_t plab_promoted() { - return ShenandoahThreadLocalData::get_plab_promoted(Thread::current()); + return ShenandoahThreadLocalData::shenandoah_plab(Thread::current())->get_promoted(); } }; diff --git a/test/hotspot/gtest/logging/test_logOutputList.cpp b/test/hotspot/gtest/logging/test_logOutputList.cpp index 64becbd7ef7..df3bb2c3227 100644 --- a/test/hotspot/gtest/logging/test_logOutputList.cpp +++ b/test/hotspot/gtest/logging/test_logOutputList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,16 @@ static LogOutput* dummy_output(size_t id) { return reinterpret_cast(id + 1); } +static LogStdoutOutput* dummy_stdout() { + static LogStdoutOutput dummy_stdout; + return &dummy_stdout; +} + +static LogStderrOutput* dummy_stderr() { + static LogStderrOutput dummy_stderr; + return &dummy_stderr; +} + // Randomly update and verify some outputs some number of times TEST(LogOutputList, set_output_level_update) { const size_t TestOutputCount = 10; @@ -174,7 +184,7 @@ TEST(LogOutputList, is_level_single_output) { for (size_t i = LogLevel::First; i < LogLevel::Count; i++) { LogLevelType level = static_cast(i); LogOutputList list; - list.set_output_level(LogConfiguration::StdoutLog, level); + list.set_output_level(dummy_stdout(), level); for (size_t j = LogLevel::First; j < LogLevel::Count; j++) { LogLevelType other = static_cast(j); // Verify that levels finer than the current level for stdout are reported as disabled, @@ -202,8 +212,8 @@ TEST(LogOutputList, is_level_empty) { // Test is_level() on lists with two outputs on different levels TEST(LogOutputList, is_level_multiple_outputs) { for (size_t i = LogLevel::First; i < LogLevel::Count - 1; i++) { - LogOutput* dummy1 = LogConfiguration::StdoutLog; - LogOutput* dummy2 = LogConfiguration::StderrLog; + LogOutput* dummy1 = dummy_stdout(); + LogOutput* dummy2 = dummy_stderr(); LogLevelType first = static_cast(i); LogLevelType second = static_cast(i + 1); LogOutputList list; @@ -227,19 +237,19 @@ TEST(LogOutputList, level_for) { LogOutputList list; // Ask the empty list about stdout, stderr - EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StdoutLog)); - EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StderrLog)); + EXPECT_EQ(LogLevel::Off, list.level_for(dummy_stdout())); + EXPECT_EQ(LogLevel::Off, list.level_for(dummy_stderr())); // Ask for level in a list with two outputs on different levels - list.set_output_level(LogConfiguration::StdoutLog, LogLevel::Info); - list.set_output_level(LogConfiguration::StderrLog, LogLevel::Trace); - EXPECT_EQ(LogLevel::Info, list.level_for(LogConfiguration::StdoutLog)); - EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); + list.set_output_level(dummy_stdout(), LogLevel::Info); + list.set_output_level(dummy_stderr(), LogLevel::Trace); + EXPECT_EQ(LogLevel::Info, list.level_for(dummy_stdout())); + EXPECT_EQ(LogLevel::Trace, list.level_for(dummy_stderr())); // Remove and ask again - list.set_output_level(LogConfiguration::StdoutLog, LogLevel::Off); - EXPECT_EQ(LogLevel::Off, list.level_for(LogConfiguration::StdoutLog)); - EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); + list.set_output_level(dummy_stdout(), LogLevel::Off); + EXPECT_EQ(LogLevel::Off, list.level_for(dummy_stdout())); + EXPECT_EQ(LogLevel::Trace, list.level_for(dummy_stderr())); // Ask about an unknown output LogOutput* dummy = dummy_output(4711); @@ -252,5 +262,5 @@ TEST(LogOutputList, level_for) { } // Make sure the stderr level is still the same - EXPECT_EQ(LogLevel::Trace, list.level_for(LogConfiguration::StderrLog)); + EXPECT_EQ(LogLevel::Trace, list.level_for(dummy_stderr())); } diff --git a/test/hotspot/gtest/logging/test_logTagSet.cpp b/test/hotspot/gtest/logging/test_logTagSet.cpp index 4c00644d25b..b53272eafdb 100644 --- a/test/hotspot/gtest/logging/test_logTagSet.cpp +++ b/test/hotspot/gtest/logging/test_logTagSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,9 @@ #include "utilities/ostream.hpp" #include "unittest.hpp" -// Test the default level for each tagset -TEST_VM(LogTagSet, defaults) { +// Test the default level for each tagset, runs in other VM to ensure no other +// test have changed a LogTagSet. +TEST_OTHER_VM(LogTagSet, defaults) { for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { char buf[256]; ts->label(buf, sizeof(buf)); diff --git a/test/hotspot/gtest/memory/test_virtualspace.cpp b/test/hotspot/gtest/memory/test_virtualspace.cpp index 70f442c5802..eaabc46edaf 100644 --- a/test/hotspot/gtest/memory/test_virtualspace.cpp +++ b/test/hotspot/gtest/memory/test_virtualspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -354,11 +354,7 @@ class TestReservedSpace : AllStatic { } static void release_memory_for_test(ReservedSpace rs) { - if (rs.special()) { - os::release_memory_special(rs.base(), rs.size()); - } else { - os::release_memory(rs.base(), rs.size()); - } + os::release_memory(rs.base(), rs.size()); } static void test_reserved_space1(size_t size, size_t alignment) { diff --git a/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp b/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp index a35888c62e2..c1b4abfb355 100644 --- a/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp +++ b/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -65,8 +65,8 @@ public: // Test VirtualSpaceList::contains const VirtualSpaceList* const vslist = - (mdType == Metaspace::ClassType && Metaspace::using_class_space()) ? - VirtualSpaceList::vslist_class() : VirtualSpaceList::vslist_nonclass(); + (mdType == Metaspace::ClassType && INCLUDE_CLASS_SPACE) ? + VirtualSpaceList::vslist_class() : VirtualSpaceList::vslist_nonclass(); ASSERT_TRUE(vslist->contains((MetaWord*)p)); diff --git a/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp b/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp index 49ab816c4a0..68deb283784 100644 --- a/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp +++ b/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,15 +37,15 @@ TEST_VM(metaspace, MetaspaceUtils_reserved) { EXPECT_LE(reserved_metadata, reserved); } +#if INCLUDE_CLASS_SPACE TEST_VM(metaspace, MetaspaceUtils_reserved_compressed_class_pointers) { - if (UseCompressedClassPointers && CompressedKlassPointers::needs_class_space()) { - size_t reserved = MetaspaceUtils::reserved_bytes(); - EXPECT_GT(reserved, 0UL); - size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType); - EXPECT_GT(reserved_class, 0UL); - EXPECT_LE(reserved_class, reserved); - } + size_t reserved = MetaspaceUtils::reserved_bytes(); + EXPECT_GT(reserved, 0UL); + size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType); + EXPECT_GT(reserved_class, 0UL); + EXPECT_LE(reserved_class, reserved); } +#endif // INCLUDE_CLASS_SPACE TEST_VM(metaspace, MetaspaceUtils_committed) { size_t committed = MetaspaceUtils::committed_bytes(); @@ -59,30 +59,15 @@ TEST_VM(metaspace, MetaspaceUtils_committed) { EXPECT_LE(committed_metadata, committed); } +#if INCLUDE_CLASS_SPACE TEST_VM(metaspace, MetaspaceUtils_committed_compressed_class_pointers) { - if (UseCompressedClassPointers && CompressedKlassPointers::needs_class_space()) { - size_t committed = MetaspaceUtils::committed_bytes(); - EXPECT_GT(committed, 0UL); - size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType); - EXPECT_GT(committed_class, 0UL); - EXPECT_LE(committed_class, committed); - } -} - -TEST_VM(metaspace, MetaspaceUtils_non_compressed_class_pointers) { - if (UseCompressedClassPointers) { - return; - } - + size_t committed = MetaspaceUtils::committed_bytes(); + EXPECT_GT(committed, 0UL); size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType); - EXPECT_EQ(committed_class, 0UL); - - size_t used_class = MetaspaceUtils::used_bytes(Metaspace::ClassType); - EXPECT_EQ(used_class, 0UL); - - size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType); - EXPECT_EQ(reserved_class, 0UL); + EXPECT_GT(committed_class, 0UL); + EXPECT_LE(committed_class, committed); } +#endif // INCLUDE_CLASS_SPACE static void check_metaspace_stats_are_consistent(const MetaspaceStats& stats) { EXPECT_LE(stats.committed(), stats.reserved()); @@ -102,13 +87,13 @@ TEST_VM(MetaspaceUtils, MetaspaceUtils_get_statistics) { check_metaspace_stats_are_not_null(combined_stats.non_class_space_stats()); check_metaspace_stats_are_consistent(combined_stats.non_class_space_stats()); - if (CompressedKlassPointers::needs_class_space() && UseCompressedClassPointers) { - check_metaspace_stats_are_not_null(combined_stats.class_space_stats()); - check_metaspace_stats_are_consistent(combined_stats.class_space_stats()); - } else { - // if we don't have a class space, combined stats should equal non-class stats - EXPECT_EQ(combined_stats.non_class_space_stats().reserved(), combined_stats.reserved()); - EXPECT_EQ(combined_stats.non_class_space_stats().committed(), combined_stats.committed()); - EXPECT_EQ(combined_stats.non_class_space_stats().used(), combined_stats.used()); - } +#if INCLUDE_CLASS_SPACE + check_metaspace_stats_are_not_null(combined_stats.class_space_stats()); + check_metaspace_stats_are_consistent(combined_stats.class_space_stats()); +#else + // if we don't have a class space, combined stats should equal non-class stats + EXPECT_EQ(combined_stats.non_class_space_stats().reserved(), combined_stats.reserved()); + EXPECT_EQ(combined_stats.non_class_space_stats().committed(), combined_stats.committed()); + EXPECT_EQ(combined_stats.non_class_space_stats().used(), combined_stats.used()); +#endif // INCLUDE_CLASS_SPACE } diff --git a/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp b/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp index c65808d3f4d..e3b03440141 100644 --- a/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022 SAP SE. All rights reserved. - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ "fake message ignore this - " expected_assertion_message); \ } \ } - /////// #if !INCLUDE_ASAN @@ -86,31 +85,6 @@ DEFINE_TEST(test_overwrite_back_long_unaligned_distance, "footer canary broken") /////// -static void test_double_free() { - address p = (address) os::malloc(1, mtTest); - os::free(p); - // Now a double free. Note that this is susceptible to concurrency issues should - // a concurrent thread have done a malloc and gotten the same address after the - // first free. To decrease chance of this happening, we repeat the double free - // several times. - for (int i = 0; i < 100; i ++) { - os::free(p); - } -} - -// What assertion message we will see depends on whether the VM wipes the memory-to-be-freed -// on the first free(), and whether the libc uses the freed memory to store bookkeeping information. -// If the death marker in the header is still intact after the first free, we will recognize this as -// double free; if it got wiped, we should at least see a broken header canary. -// The message would be either -// - "header canary broken" or -// - "header canary dead (double free?)". -// However, since gtest regex expressions do not support unions (a|b), I search for a reasonable -// subset here. -DEFINE_TEST(test_double_free, "header canary") - -/////// - static void test_invalid_block_address() { // very low, like the result of an overflow or of accessing a null this pointer os::free((void*)0x100); diff --git a/test/hotspot/gtest/nmt/test_nmt_summarydiff.cpp b/test/hotspot/gtest/nmt/test_nmt_summarydiff.cpp new file mode 100644 index 00000000000..fcdbe57bfe1 --- /dev/null +++ b/test/hotspot/gtest/nmt/test_nmt_summarydiff.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2026, 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. + * + */ + +#include "nmt/memTag.hpp" +#include "nmt/vmatree.hpp" +#include "unittest.hpp" + + +// The SummaryDiff is seldom used with a large number of tags +// so test that separately. +TEST(NMTSummaryDiffTest, WorksForLargeTagCount) { + VMATree::SummaryDiff d; + for (int i = 0; i < std::numeric_limits>::max(); i++) { + VMATree::SingleDiff& sd = d.tag(i); + sd.reserve = i; + } + for (int i = 0; i < std::numeric_limits>::max(); i++) { + VMATree::SingleDiff& sd = d.tag(i); + EXPECT_EQ(i, sd.reserve); + } +} diff --git a/test/hotspot/gtest/nmt/test_regions_tree.cpp b/test/hotspot/gtest/nmt/test_regions_tree.cpp index 7465c84aa72..5d50a797a80 100644 --- a/test/hotspot/gtest/nmt/test_regions_tree.cpp +++ b/test/hotspot/gtest/nmt/test_regions_tree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -44,30 +44,30 @@ TEST_VM_F(NMTRegionsTreeTest, ReserveCommitTwice) { { VMATree::SummaryDiff diff; rt.reserve_mapping(0, 100, rd, diff); - EXPECT_EQ(100, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); + EXPECT_EQ(100, diff.tag(mtTest).reserve); } { VMATree::SummaryDiff diff, not_used; rt.commit_region(nullptr, 50, ncs, not_used); rt.reserve_mapping(0, 100, rd, diff); - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(-50, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(-50, diff.tag(mtTest).commit); } { VMATree::SummaryDiff diff; rt.reserve_mapping(0, 100, rd2, diff); - EXPECT_EQ(-100, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(100, diff.tag[NMTUtil::tag_to_index(mtGC)].reserve); + EXPECT_EQ(-100, diff.tag(mtTest).reserve); + EXPECT_EQ(100, diff.tag(mtGC).reserve); } { VMATree::SummaryDiff diff1, diff2; rt.commit_region(nullptr, 50, ncs, diff1); - EXPECT_EQ(0, diff1.tag[NMTUtil::tag_to_index(mtGC)].reserve); - EXPECT_EQ(50, diff1.tag[NMTUtil::tag_to_index(mtGC)].commit); + EXPECT_EQ(0, diff1.tag(mtGC).reserve); + EXPECT_EQ(50, diff1.tag(mtGC).commit); rt.commit_region(nullptr, 50, ncs, diff2); - EXPECT_EQ(0, diff2.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(0, diff2.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff2.tag(mtTest).reserve); + EXPECT_EQ(0, diff2.tag(mtTest).commit); } } @@ -79,20 +79,20 @@ TEST_VM_F(NMTRegionsTreeTest, CommitUncommitRegion) { { VMATree::SummaryDiff diff; rt.commit_region(nullptr, 50, ncs, diff); - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(50, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(50, diff.tag(mtTest).commit); } { VMATree::SummaryDiff diff; rt.commit_region((address)60, 10, ncs, diff); - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(10, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(10, diff.tag(mtTest).commit); } { VMATree::SummaryDiff diff; rt.uncommit_region(nullptr, 50, diff); - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(-50, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(-50, diff.tag(mtTest).commit); } } @@ -104,15 +104,15 @@ TEST_VM_F(NMTRegionsTreeTest, FindReservedRegion) { rt.reserve_mapping(1200, 50, rd, not_used); rt.reserve_mapping(1300, 50, rd, not_used); rt.reserve_mapping(1400, 50, rd, not_used); - ReservedMemoryRegion rmr; - rmr = rt.find_reserved_region((address)1205); - EXPECT_EQ(rmr.base(), (address)1200); - rmr = rt.find_reserved_region((address)1305); - EXPECT_EQ(rmr.base(), (address)1300); - rmr = rt.find_reserved_region((address)1405); - EXPECT_EQ(rmr.base(), (address)1400); - rmr = rt.find_reserved_region((address)1005); - EXPECT_EQ(rmr.base(), (address)1000); + VirtualMemoryRegion rgn; + rgn = rt.find_reserved_region((address)1205); + EXPECT_EQ(rgn.base(), (address)1200); + rgn = rt.find_reserved_region((address)1305); + EXPECT_EQ(rgn.base(), (address)1300); + rgn = rt.find_reserved_region((address)1405); + EXPECT_EQ(rgn.base(), (address)1400); + rgn = rt.find_reserved_region((address)1005); + EXPECT_EQ(rgn.base(), (address)1000); } TEST_VM_F(NMTRegionsTreeTest, VisitReservedRegions) { @@ -124,7 +124,7 @@ TEST_VM_F(NMTRegionsTreeTest, VisitReservedRegions) { rt.reserve_mapping(1300, 50, rd, not_used); rt.reserve_mapping(1400, 50, rd, not_used); - rt.visit_reserved_regions([&](const ReservedMemoryRegion& rgn) { + rt.visit_reserved_regions([&](const VirtualMemoryRegion& rgn) { EXPECT_EQ(((size_t)rgn.base()) % 100, 0UL); EXPECT_EQ(rgn.size(), 50UL); return true; @@ -144,9 +144,9 @@ TEST_VM_F(NMTRegionsTreeTest, VisitCommittedRegions) { rt.commit_region((address)1020, 5UL, ncs, not_used); rt.commit_region((address)1030, 5UL, ncs, not_used); rt.commit_region((address)1040, 5UL, ncs, not_used); - ReservedMemoryRegion rmr((address)1000, 50); + VirtualMemoryRegion rgn((address)1000, 50); size_t count = 0; - rt.visit_committed_regions(rmr, [&](CommittedMemoryRegion& crgn) { + rt.visit_committed_regions(rgn, [&](VirtualMemoryRegion& crgn) { count++; EXPECT_EQ((((size_t)crgn.base()) % 100) / 10, count); EXPECT_EQ(crgn.size(), 5UL); diff --git a/test/hotspot/gtest/nmt/test_vmatree.cpp b/test/hotspot/gtest/nmt/test_vmatree.cpp index eed2e5af0be..67cdc080cd6 100644 --- a/test/hotspot/gtest/nmt/test_vmatree.cpp +++ b/test/hotspot/gtest/nmt/test_vmatree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -221,13 +221,13 @@ public: EXPECT_EQ(n1.val().out.committed_stack(), upd.new_st.committed_stack()) << failed_case; if (from == to) { - EXPECT_EQ(diff.tag[from].reserve, upd.reserve[0] + upd.reserve[1]) << failed_case; - EXPECT_EQ(diff.tag[from].commit, upd.commit[0] + upd.commit[1]) << failed_case; + EXPECT_EQ(diff.tag(from).reserve, upd.reserve[0] + upd.reserve[1]) << failed_case; + EXPECT_EQ(diff.tag(from).commit, upd.commit[0] + upd.commit[1]) << failed_case; } else { - EXPECT_EQ(diff.tag[from].reserve, upd.reserve[0]) << failed_case; - EXPECT_EQ(diff.tag[from].commit, upd.commit[0]) << failed_case; - EXPECT_EQ(diff.tag[to].reserve, upd.reserve[1]) << failed_case; - EXPECT_EQ(diff.tag[to].commit, upd.commit[1]) << failed_case; + EXPECT_EQ(diff.tag(from).reserve, upd.reserve[0]) << failed_case; + EXPECT_EQ(diff.tag(from).commit, upd.commit[0]) << failed_case; + EXPECT_EQ(diff.tag(to).reserve, upd.reserve[1]) << failed_case; + EXPECT_EQ(diff.tag(to).commit, upd.commit[1]) << failed_case; } } @@ -235,6 +235,7 @@ public: void create_tree(Tree& tree, ExpectedTree& et, int line_no) { using SIndex = NativeCallStackStorage::StackIndex; const SIndex ES = NativeCallStackStorage::invalid; // Empty Stack + VMATree::SummaryDiff not_used; VMATree::IntervalChange st; for (int i = 0; i < N; i++) { st.in.set_type(et.states[i]); @@ -537,8 +538,8 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { tree.reserve_mapping(0, 600, rd, not_used); - tree.set_tag(0, 500, mtGC); - tree.set_tag(500, 100, mtClassShared); + tree.set_tag(0, 500, mtGC, not_used); + tree.set_tag(500, 100, mtClassShared, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -569,8 +570,8 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { tree.commit_mapping(550, 10, rd, not_used); tree.commit_mapping(565, 10, rd, not_used); // OK, set tag - tree.set_tag(0, 500, mtGC); - tree.set_tag(500, 100, mtClassShared); + tree.set_tag(0, 500, mtGC, not_used); + tree.set_tag(500, 100, mtClassShared, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -584,7 +585,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { Tree::RegionData compiler(si, mtCompiler); tree.reserve_mapping(0, 100, gc, not_used); tree.reserve_mapping(100, 100, compiler, not_used); - tree.set_tag(0, 200, mtGC); + tree.set_tag(0, 200, mtGC, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -601,7 +602,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { Tree::RegionData compiler(si2, mtCompiler); tree.reserve_mapping(0, 100, gc, not_used); tree.reserve_mapping(100, 100, compiler, not_used); - tree.set_tag(0, 200, mtGC); + tree.set_tag(0, 200, mtGC, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -615,7 +616,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { VMATree::SummaryDiff not_used; Tree::RegionData compiler(si, mtCompiler); tree.reserve_mapping(0, 200, compiler, not_used); - tree.set_tag(100, 50, mtGC); + tree.set_tag(100, 50, mtGC, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -631,7 +632,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { Tree::RegionData compiler(si, mtCompiler); tree.reserve_mapping(0, 100, gc, not_used); tree.reserve_mapping(100, 100, compiler, not_used); - tree.set_tag(75, 50, mtClass); + tree.set_tag(75, 50, mtClass, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -647,7 +648,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { Tree::RegionData class_shared(si, mtClassShared); tree.reserve_mapping(0, 50, class_shared, not_used); tree.reserve_mapping(75, 25, class_shared, not_used); - tree.set_tag(0, 80, mtGC); + tree.set_tag(0, 80, mtGC, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -659,7 +660,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { VMATree::SummaryDiff not_used; Tree::RegionData class_shared(si, mtClassShared); tree.reserve_mapping(10, 10, class_shared, not_used); - tree.set_tag(0, 100, mtCompiler); + tree.set_tag(0, 100, mtCompiler, not_used); expect_equivalent_form(expected, tree, __LINE__); } @@ -677,7 +678,7 @@ TEST_VM_F(NMTVMATreeTest, SetTag) { tree.reserve_mapping(0, 100, class_shared, not_used); tree.release_mapping(1, 49, not_used); tree.release_mapping(75, 24, not_used); - tree.set_tag(0, 100, mtGC); + tree.set_tag(0, 100, mtGC, not_used); expect_equivalent_form(expected, tree, __LINE__); } } @@ -696,7 +697,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag(mtTest); EXPECT_EQ(100, diff.reserve); tree.reserve_mapping(50, 25, rd_NMT_cs0, all_diff); // 1 2 3 4 5 6 7 8 9 10 11 @@ -707,8 +708,8 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // B - Native Memory Tracking (reserved) // C - Test (reserved) // . - free - diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; - VMATree::SingleDiff diff2 = all_diff.tag[NMTUtil::tag_to_index(mtNMT)]; + diff = all_diff.tag(mtTest); + VMATree::SingleDiff diff2 = all_diff.tag(mtNMT); EXPECT_EQ(-25, diff.reserve); EXPECT_EQ(25, diff2.reserve); } @@ -723,14 +724,14 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag(mtTest); EXPECT_EQ(100, diff.reserve); tree.release_mapping(0, 100, all_diff); // 1 2 3 4 5 6 7 8 9 10 11 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // .............................................................................................................. // Legend: - diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + diff = all_diff.tag(mtTest); EXPECT_EQ(-100, diff.reserve); } { // Convert some of a released mapping to a committed one @@ -744,7 +745,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag(mtTest); EXPECT_EQ(diff.reserve, 100); tree.commit_mapping(0, 100, rd_Test_cs0, all_diff); // 1 2 3 4 5 6 7 8 9 10 11 @@ -753,7 +754,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // a - Test (committed) // . - free - diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + diff = all_diff.tag(mtTest); EXPECT_EQ(0, diff.reserve); EXPECT_EQ(100, diff.commit); } @@ -768,7 +769,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag(mtTest); EXPECT_EQ(diff.reserve, 10); tree.reserve_mapping(10, 10, rd_Test_cs0, all_diff); // 1 2 3 @@ -777,7 +778,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + diff = all_diff.tag(mtTest); EXPECT_EQ(10, diff.reserve); } { // Adjacent reserved mappings with different tags @@ -792,7 +793,7 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // A - Test (reserved) // . - free - VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag(mtTest); EXPECT_EQ(diff.reserve, 10); tree.reserve_mapping(10, 10, rd_NMT_cs0, all_diff); // 1 2 3 @@ -802,9 +803,9 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // A - Test (reserved) // B - Native Memory Tracking (reserved) // . - free - diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + diff = all_diff.tag(mtTest); EXPECT_EQ(0, diff.reserve); - diff = all_diff.tag[NMTUtil::tag_to_index(mtNMT)]; + diff = all_diff.tag(mtNMT); EXPECT_EQ(10, diff.reserve); } @@ -834,8 +835,8 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { // Legend: // a - Test (committed) // . - free - EXPECT_EQ(16, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); - EXPECT_EQ(16, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); + EXPECT_EQ(16, diff.tag(mtTest).commit); + EXPECT_EQ(16, diff.tag(mtTest).reserve); } } @@ -845,16 +846,16 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccountingReserveAsUncommit) { VMATree::SummaryDiff diff1, diff2, diff3; tree.reserve_mapping(1200, 100, rd, diff1); tree.commit_mapping(1210, 50, rd, diff2); - EXPECT_EQ(100, diff1.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(50, diff2.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(100, diff1.tag(mtTest).reserve); + EXPECT_EQ(50, diff2.tag(mtTest).commit); tree.reserve_mapping(1220, 20, rd, diff3); - EXPECT_EQ(-20, diff3.tag[NMTUtil::tag_to_index(mtTest)].commit); - EXPECT_EQ(0, diff3.tag[NMTUtil::tag_to_index(mtTest)].reserve); + EXPECT_EQ(-20, diff3.tag(mtTest).commit); + EXPECT_EQ(0, diff3.tag(mtTest).reserve); } // Exceedingly simple tracker for page-granular allocations // Use it for testing consistency with VMATree. - struct SimpleVMATracker : public CHeapObj { +struct SimpleVMATracker : public CHeapObj { const size_t page_size = 4096; enum Kind { Reserved, Committed, Free }; struct Info { @@ -881,10 +882,9 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccountingReserveAsUncommit) { } } - VMATree::SummaryDiff do_it(Kind kind, size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { + void do_it(Kind kind, size_t start, size_t size, NativeCallStack stack, MemTag mem_tag, VMATree::SummaryDiff& diff) { assert(is_aligned(size, page_size) && is_aligned(start, page_size), "page alignment"); - VMATree::SummaryDiff diff; const size_t page_count = size / page_size; const size_t start_idx = start / page_size; const size_t end_idx = start_idx + page_count; @@ -896,34 +896,33 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccountingReserveAsUncommit) { // Register diff if (old_info.kind == Reserved) { - diff.tag[(int)old_info.mem_tag].reserve -= page_size; + diff.tag(old_info.mem_tag).reserve -= page_size; } else if (old_info.kind == Committed) { - diff.tag[(int)old_info.mem_tag].reserve -= page_size; - diff.tag[(int)old_info.mem_tag].commit -= page_size; + diff.tag(old_info.mem_tag).reserve -= page_size; + diff.tag(old_info.mem_tag).commit -= page_size; } if (kind == Reserved) { - diff.tag[(int)new_info.mem_tag].reserve += page_size; + diff.tag(new_info.mem_tag).reserve += page_size; } else if (kind == Committed) { - diff.tag[(int)new_info.mem_tag].reserve += page_size; - diff.tag[(int)new_info.mem_tag].commit += page_size; + diff.tag(new_info.mem_tag).reserve += page_size; + diff.tag(new_info.mem_tag).commit += page_size; } // Overwrite old one with new pages[i] = new_info; } - return diff; } - VMATree::SummaryDiff reserve(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { - return do_it(Reserved, start, size, stack, mem_tag); + void reserve(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag, VMATree::SummaryDiff& diff) { + return do_it(Reserved, start, size, stack, mem_tag, diff); } - VMATree::SummaryDiff commit(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { - return do_it(Committed, start, size, stack, mem_tag); + void commit(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag, VMATree::SummaryDiff& diff) { + return do_it(Committed, start, size, stack, mem_tag, diff); } - VMATree::SummaryDiff release(size_t start, size_t size) { - return do_it(Free, start, size, NativeCallStack(), mtNone); + void release(size_t start, size_t size, VMATree::SummaryDiff& diff) { + return do_it(Free, start, size, NativeCallStack(), mtNone, diff); } }; @@ -979,19 +978,19 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { VMATree::SummaryDiff tree_diff; VMATree::SummaryDiff simple_diff; if (kind == SimpleVMATracker::Reserved) { - simple_diff = tr->reserve(start, size, stack, mem_tag); + tr->reserve(start, size, stack, mem_tag, simple_diff); tree.reserve_mapping(start, size, data, tree_diff); } else if (kind == SimpleVMATracker::Committed) { - simple_diff = tr->commit(start, size, stack, mem_tag); + tr->commit(start, size, stack, mem_tag, simple_diff); tree.commit_mapping(start, size, data, tree_diff); } else { - simple_diff = tr->release(start, size); + tr->release(start, size, simple_diff); tree.release_mapping(start, size, tree_diff); } for (int j = 0; j < mt_number_of_tags; j++) { - VMATree::SingleDiff td = tree_diff.tag[j]; - VMATree::SingleDiff sd = simple_diff.tag[j]; + VMATree::SingleDiff td = tree_diff.tag(j); + VMATree::SingleDiff sd = simple_diff.tag(j); ASSERT_EQ(td.reserve, sd.reserve); ASSERT_EQ(td.commit, sd.commit); } @@ -1067,22 +1066,22 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccountingWhenUseTagInplace) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // CCCCCCCCCCCCCCCCCCCCCCCCCrrrrrrrrrrrrrrrrrrrrrrrrr - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(25, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(25, diff.tag(mtTest).commit); tree.commit_mapping(30, 5, rd_None_cs1, diff, true); // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // CCCCCCCCCCCCCCCCCCCCCCCCCrrrrrCCCCCrrrrrrrrrrrrrrr - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(5, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(5, diff.tag(mtTest).commit); tree.uncommit_mapping(0, 25, rd_None_cs1, diff); // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrCCCCCrrrrrrrrrrrrrrr - EXPECT_EQ(0, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); - EXPECT_EQ(-25, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(0, diff.tag(mtTest).reserve); + EXPECT_EQ(-25, diff.tag(mtTest).commit); } // How the memory regions are visualized: @@ -1328,8 +1327,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows0To3) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCCCCCCC.......................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 10); ExpectedTree<6> et = {{ 5, 10, 12, 14, 16, 25 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl }, @@ -1356,8 +1355,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows0To3) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCC............................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 5); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 5); ExpectedTree<6> et = {{ 5, 10, 12, 14, 16, 20 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl }, @@ -1402,8 +1401,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows4to7) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrr..........CCCCCCCCCCCCCCCCCCCC........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 20); ExpectedTree<4> et = {{ 0, 10, 20, 40 }, {mtNone, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , Rl , C , Rl }, @@ -1430,8 +1429,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows4to7) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....rrrrrCCCCCCCCCC............................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 10); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20 - 15); + EXPECT_EQ(diff.tag(mtTest).commit, 10); + EXPECT_EQ(diff.tag(mtTest).reserve, 20 - 15); ExpectedTree<4> et = {{ 5, 10, 15, 20 }, {mtNone, mtTest, mtTest, mtTest, mtNone}, {Rl , Rs , C , C , Rl }, @@ -1458,8 +1457,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows4to7) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrr..CCCCCCCCCCCCCCCCCCCC........................ - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 10); ExpectedTree<8> et = {{ 0, 5, 7, 10, 12, 14, 16, 27 }, {mtNone, mtTest, mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , Rs , Rl , C , C , C , C , C , Rl }, @@ -1486,8 +1485,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows4to7) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrr..CCCCCCCCCCCCC............................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 13); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 3); + EXPECT_EQ(diff.tag(mtTest).commit, 13); + EXPECT_EQ(diff.tag(mtTest).reserve, 3); ExpectedTree<8> et = {{ 0, 5, 7, 10, 12, 14, 16, 20 }, {mtNone, mtTest, mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , Rs , Rl , C , C , C , C , C , Rl }, @@ -1539,8 +1538,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows8to11) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrrCCCCCCCCCCCCCCCCCCCC..................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 20); ExpectedTree<3> et = {{ 0, 10, 30 }, {mtNone, mtTest, mtTest, mtNone}, {Rl , Rs , C , Rl }, @@ -1567,8 +1566,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows8to11) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // CCCCCCCCCCCCCCCCCCCC............................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 10); ExpectedTree<3> et = {{ 0, 10, 20 }, {mtNone, mtTest, mtTest, mtNone}, {Rl , C , C , Rl }, @@ -1595,8 +1594,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows8to11) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCCCCCCC.......................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 25 - 20); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 25 - 20); ExpectedTree<6> et = {{ 5, 10, 12, 14, 16, 25 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl }, @@ -1623,8 +1622,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows8to11) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCC............................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 0); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 0); ExpectedTree<6> et = {{ 5, 10, 12, 14, 16, 20 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl }, @@ -1670,8 +1669,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows12to15) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCCCCCCC.....rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 20); ExpectedTree<4> et = {{ 5, 25, 30, 40 }, {mtNone, mtTest, mtNone, mtTest, mtNone}, {Rl , C , Rl , Rs , Rl }, @@ -1698,8 +1697,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows12to15) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCCCCCCCrrrrr..................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 30 - 25); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, 30 - 25); ExpectedTree<4> et = {{ 5, 10, 25, 30 }, {mtNone, mtTest, mtTest, mtTest, mtNone}, {Rl , C , C , Rs , Rl }, @@ -1726,8 +1725,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows12to15) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCCCCCCC.....rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, (10 - 5) + ( 25 - 20)); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, (10 - 5) + ( 25 - 20)); ExpectedTree<8> et = {{ 5, 10, 12, 14, 16, 25, 30, 40 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl , Rs , Rl }, @@ -1754,8 +1753,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows12to15) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // .....CCCCCCCCCCCCCCC..........rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10 - 5); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 10 - 5); ExpectedTree<8> et = {{ 5, 10, 12, 14, 16, 20, 30, 40 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , C , C , C , C , C , Rl , Rs , Rl }, @@ -1800,8 +1799,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows16to19) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrr.....CCCCCCCCCC.....rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 10); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10); + EXPECT_EQ(diff.tag(mtTest).commit, 10); + EXPECT_EQ(diff.tag(mtTest).reserve, 10); ExpectedTree<6> et = {{ 0, 10, 15, 25, 30, 40 }, {mtNone, mtTest, mtNone, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , Rl , C , Rl , Rs , Rl }, @@ -1828,8 +1827,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows16to19) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrr.....CCCCCCCCCCrrrrr..................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 10); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20 - 15); + EXPECT_EQ(diff.tag(mtTest).commit, 10); + EXPECT_EQ(diff.tag(mtTest).reserve, 20 - 15); ExpectedTree<6> et = {{ 0, 10, 15, 20, 25, 30 }, {mtNone, mtTest, mtNone, mtTest, mtTest, mtTest, mtNone}, {Rl , Rs , Rl , C , C , Rs , Rl }, @@ -1856,8 +1855,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows16to19) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrr..CCCCCCCCCCCCCCCCCCCC...rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, (10 - 7) + (27 - 20)); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, (10 - 7) + (27 - 20)); ExpectedTree<10> et = {{ 0, 5, 7, 12, 14, 16, 20, 27, 30, 40 }, {mtNone, mtTest, mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , Rl , C , C , C , C , C , Rl , Rs , Rl }, @@ -1884,8 +1883,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows16to19) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrr..CCCCCCCCCCCCC..........rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 13); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10 - 7); + EXPECT_EQ(diff.tag(mtTest).commit, 13); + EXPECT_EQ(diff.tag(mtTest).reserve, 10 - 7); ExpectedTree<10> et = {{ 0, 5, 7, 10, 12, 14, 16, 20, 30, 40 }, {mtNone, mtTest, mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , Rl , C , C , C , C , C , Rl , Rs , Rl }, @@ -1931,8 +1930,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows20to23) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrrCCCCCCCCCCCCCCC.....rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 15); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 15); ExpectedTree<5> et = {{ 0, 10, 25, 30, 40 }, {mtNone, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , C , Rl , Rs , Rl }, @@ -1959,8 +1958,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows20to23) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrrrrrrCCCCCCCCCCCCCCCrrrrr..................... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 20 - 10); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 20 - 10); ExpectedTree<5> et = {{ 0, 10, 20, 25, 30 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtNone}, {Rl , Rs , C , C , Rs , Rl }, @@ -1987,8 +1986,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows20to23) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrCCCCCCCCCCCCCCCCCCCC.....rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 20); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, (10 - 5) + (25 - 20)); + EXPECT_EQ(diff.tag(mtTest).commit, 20); + EXPECT_EQ(diff.tag(mtTest).reserve, (10 - 5) + (25 - 20)); ExpectedTree<9> et = {{ 0, 5, 12, 14, 16, 20, 25, 30, 40 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , C , C , C , C , C , Rl , Rs , Rl }, @@ -2015,8 +2014,8 @@ TEST_VM_F(NMTVMATreeTest, OverlapTableRows20to23) { // 1 2 3 4 5 // 012345678901234567890123456789012345678901234567890 // rrrrrCCCCCCCCCCCCCCC..........rrrrrrrrrr........... - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].commit, 15); - EXPECT_EQ(diff.tag[NMTUtil::tag_to_index(mtTest)].reserve, 10 - 5); + EXPECT_EQ(diff.tag(mtTest).commit, 15); + EXPECT_EQ(diff.tag(mtTest).reserve, 10 - 5); ExpectedTree<9> et = {{ 0, 5, 10, 12, 14, 16, 20, 30, 40 }, {mtNone, mtTest, mtTest, mtTest, mtTest, mtTest, mtTest, mtNone, mtTest, mtNone}, {Rl , Rs , C , C , C , C , C , Rl , Rs , Rl }, @@ -2070,4 +2069,4 @@ TEST_VM_F(NMTVMATreeTest, UpdateRegionTest) { for (auto ci : call_info) { call_update_region(ci); } -} \ No newline at end of file +} diff --git a/test/hotspot/gtest/oops/test_arrayOop.cpp b/test/hotspot/gtest/oops/test_arrayOop.cpp index 33163de427c..bb5f54b3f58 100644 --- a/test/hotspot/gtest/oops/test_arrayOop.cpp +++ b/test/hotspot/gtest/oops/test_arrayOop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, 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 @@ -97,7 +97,7 @@ TEST_VM(arrayOopDesc, base_offset) { EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 16); } - } else if (UseCompressedClassPointers) { + } else { EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BOOLEAN), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BYTE), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_SHORT), 16); @@ -108,22 +108,6 @@ TEST_VM(arrayOopDesc, base_offset) { EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_DOUBLE), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 16); EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 16); - } else { - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BOOLEAN), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BYTE), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_SHORT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_CHAR), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_INT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_FLOAT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_LONG), 24); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_DOUBLE), 24); - if (UseCompressedOops) { - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 20); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 20); - } else { - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_OBJECT), 24); - EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_ARRAY), 24); - } } #else EXPECT_EQ(arrayOopDesc::base_offset_in_bytes(T_BOOLEAN), 12); diff --git a/test/hotspot/gtest/oops/test_compressedKlass.cpp b/test/hotspot/gtest/oops/test_compressedKlass.cpp index dcdb335adb5..5a7323edc03 100644 --- a/test/hotspot/gtest/oops/test_compressedKlass.cpp +++ b/test/hotspot/gtest/oops/test_compressedKlass.cpp @@ -29,9 +29,6 @@ #include "unittest.hpp" TEST_VM(CompressedKlass, basics) { - if (!UseCompressedClassPointers) { - return; - } ASSERT_LE(CompressedKlassPointers::base(), CompressedKlassPointers::klass_range_start()); ASSERT_LT(CompressedKlassPointers::klass_range_start(), CompressedKlassPointers::klass_range_end()); ASSERT_LE(CompressedKlassPointers::klass_range_end(), CompressedKlassPointers::encoding_range_end()); @@ -54,22 +51,7 @@ TEST_VM(CompressedKlass, basics) { #endif // _LP64 } -TEST_VM(CompressedKlass, ccp_off) { - if (UseCompressedClassPointers) { - return; - } - ASSERT_EQ(CompressedKlassPointers::klass_range_start(), (address)nullptr); - ASSERT_EQ(CompressedKlassPointers::klass_range_end(), (address)nullptr); - // We should be able to call CompressedKlassPointers::is_encodable, and it should - // always return false - ASSERT_FALSE(CompressedKlassPointers::is_encodable((address)0x12345)); -} - - TEST_VM(CompressedKlass, test_too_low_address) { - if (!UseCompressedClassPointers) { - return; - } address really_low = (address) 32; ASSERT_FALSE(CompressedKlassPointers::is_encodable(really_low)); address low = CompressedKlassPointers::klass_range_start() - 1; @@ -77,9 +59,6 @@ TEST_VM(CompressedKlass, test_too_low_address) { } TEST_VM(CompressedKlass, test_too_high_address) { - if (!UseCompressedClassPointers) { - return; - } address really_high = (address) UINTPTR_MAX; ASSERT_FALSE(CompressedKlassPointers::is_encodable(really_high)); address high = CompressedKlassPointers::klass_range_end(); @@ -87,9 +66,6 @@ TEST_VM(CompressedKlass, test_too_high_address) { } TEST_VM(CompressedKlass, test_unaligned_address) { - if (!UseCompressedClassPointers) { - return; - } const size_t alignment = CompressedKlassPointers::klass_alignment_in_bytes(); address addr = CompressedKlassPointers::klass_range_start() + alignment - 1; ASSERT_FALSE(CompressedKlassPointers::is_encodable(addr)); @@ -103,9 +79,6 @@ TEST_VM(CompressedKlass, test_unaligned_address) { } TEST_VM(CompressedKlass, test_good_address) { - if (!UseCompressedClassPointers) { - return; - } const size_t alignment = CompressedKlassPointers::klass_alignment_in_bytes(); address addr = CompressedKlassPointers::klass_range_start(); ASSERT_TRUE(CompressedKlassPointers::is_encodable(addr)); @@ -114,9 +87,6 @@ TEST_VM(CompressedKlass, test_good_address) { } TEST_VM(CompressedKlass, test_is_valid_narrow_klass) { - if (!UseCompressedClassPointers) { - return; - } ASSERT_FALSE(CompressedKlassPointers::is_valid_narrow_klass_id(0)); narrowKlass nk_jlC = CompressedKlassPointers::encode((Klass*)vmClasses::Class_klass()); ASSERT_TRUE(CompressedKlassPointers::is_valid_narrow_klass_id(nk_jlC)); diff --git a/test/hotspot/gtest/oops/test_objArrayOop.cpp b/test/hotspot/gtest/oops/test_objArrayOop.cpp index 22c9b2efc11..f6a53a3031f 100644 --- a/test/hotspot/gtest/oops/test_objArrayOop.cpp +++ b/test/hotspot/gtest/oops/test_objArrayOop.cpp @@ -27,35 +27,29 @@ TEST_VM(objArrayOop, osize) { static const struct { - int objal; bool ccp; bool coops; bool coh; int result; + int objal; bool coops; bool coh; int result; } x[] = { -// ObjAligInB, UseCCP, UseCoops, UseCOH, object size in heap words +// ObjAligInB, UseCoops, UseCOH, object size in heap words #ifdef _LP64 - { 8, false, false, false, 4 }, // 20 byte header, 8 byte oops - { 8, false, true, false, 3 }, // 20 byte header, 4 byte oops - { 8, true, false, false, 3 }, // 16 byte header, 8 byte oops - { 8, true, true, false, 3 }, // 16 byte header, 4 byte oops - { 8, true, false, true, 3 }, // 12 byte header, 8 byte oops - { 8, true, true, true, 2 }, // 12 byte header, 4 byte oops - { 16, false, false, false, 4 }, // 20 byte header, 8 byte oops, 16-byte align - { 16, false, true, false, 4 }, // 20 byte header, 4 byte oops, 16-byte align - { 16, true, false, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align - { 16, true, true, false, 4 }, // 16 byte header, 4 byte oops, 16-byte align - { 16, true, false, true, 4 }, // 12 byte header, 8 byte oops, 16-byte align - { 16, true, true, true, 2 }, // 12 byte header, 4 byte oops, 16-byte align - { 256, false, false, false, 32 }, // 20 byte header, 8 byte oops, 256-byte align - { 256, false, true, false, 32 }, // 20 byte header, 4 byte oops, 256-byte align - { 256, true, false, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align - { 256, true, true, false, 32 }, // 16 byte header, 4 byte oops, 256-byte align - { 256, true, false, true, 32 }, // 12 byte header, 8 byte oops, 256-byte align - { 256, true, true, true, 32 }, // 12 byte header, 4 byte oops, 256-byte align + { 8, false, false, 3 }, // 16 byte header, 8 byte oops + { 8, true, false, 3 }, // 16 byte header, 4 byte oops + { 8, false, true, 3 }, // 12 byte header, 8 byte oops + { 8, true, true, 2 }, // 12 byte header, 4 byte oops + { 16, false, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align + { 16, true, false, 4 }, // 16 byte header, 4 byte oops, 16-byte align + { 16, false, true, 4 }, // 12 byte header, 8 byte oops, 16-byte align + { 16, true, true, 2 }, // 12 byte header, 4 byte oops, 16-byte align + { 256, false, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align + { 256, true, false, 32 }, // 16 byte header, 4 byte oops, 256-byte align + { 256, false, true, 32 }, // 12 byte header, 8 byte oops, 256-byte align + { 256, true, true, 32 }, // 12 byte header, 4 byte oops, 256-byte align #else - { 8, false, false, false, 4 }, // 12 byte header, 4 byte oops, wordsize 4 + { 8, false, false, 4 }, // 12 byte header, 4 byte oops, wordsize 4 #endif - { -1, false, false, false, -1 } + { -1, false, false, -1 } }; for (int i = 0; x[i].result != -1; i++) { - if (x[i].objal == (int)ObjectAlignmentInBytes && x[i].ccp == UseCompressedClassPointers && x[i].coops == UseCompressedOops && + if (x[i].objal == (int)ObjectAlignmentInBytes && x[i].coops == UseCompressedOops && x[i].coh == UseCompactObjectHeaders) { EXPECT_EQ(objArrayOopDesc::object_size(1), (size_t)x[i].result); } diff --git a/test/hotspot/gtest/opto/test_rangeinference.cpp b/test/hotspot/gtest/opto/test_rangeinference.cpp index fd49050d022..641edaba4da 100644 --- a/test/hotspot/gtest/opto/test_rangeinference.cpp +++ b/test/hotspot/gtest/opto/test_rangeinference.cpp @@ -370,6 +370,32 @@ static void test_binary_instance_correctness_exhaustive(Operation op, Inference } } +template > +static void populate_sample_values(U* samples, const size_t sample_count, const InputType &input) { + constexpr size_t max_tries = 100; + constexpr size_t start_random_idx = 4; + + assert(sample_count >= 4, "need at least 4 slots for boundary values"); + samples[0] = U(input._lo); + samples[1] = U(input._hi); + samples[2] = input._ulo; + samples[3] = input._uhi; + + // Initialize remaining slots to a known-contained value in case the random + // fill below doesn't find enough values. + for (size_t i = start_random_idx; i < sample_count; i++) { + samples[i] = input._ulo; + } + + for (size_t tries = 0, idx = start_random_idx; tries < max_tries && idx < sample_count; tries++) { + U n = uniform_random(); + if (input.contains(n)) { + samples[idx] = n; + idx++; + } + } +} + // Check the correctness, that is, if v1 is an element of input1, v2 is an element of input2, then // op(v1, v2) must be an element of infer(input1, input2). This version does the check randomly on // a number of elements in input1 and input2. @@ -379,22 +405,11 @@ static void test_binary_instance_correctness_samples(Operation op, Inference inf auto result = infer(input1, input2); constexpr size_t sample_count = 6; - U input1_samples[sample_count] {U(input1._lo), U(input1._hi), input1._ulo, input1._uhi, input1._ulo, input1._ulo}; - U input2_samples[sample_count] {U(input2._lo), U(input2._hi), input2._ulo, input2._uhi, input2._ulo, input2._ulo}; + U input1_samples[sample_count]; + populate_sample_values(input1_samples, sample_count, input1); - auto random_sample = [](U* samples, const InputType& input) { - constexpr size_t max_tries = 100; - constexpr size_t start_random_idx = 4; - for (size_t tries = 0, idx = start_random_idx; tries < max_tries && idx < sample_count; tries++) { - U n = uniform_random(); - if (input.contains(n)) { - samples[idx] = n; - idx++; - } - } - }; - random_sample(input1_samples, input1); - random_sample(input2_samples, input2); + U input2_samples[sample_count]; + populate_sample_values(input2_samples, sample_count, input2); for (size_t i = 0; i < sample_count; i++) { for (size_t j = 0; j < sample_count; j++) { @@ -428,6 +443,22 @@ static void test_binary_instance_monotonicity_exhaustive(Inference infer, const } } +template +static InputType compute_random_superset(const InputType& input) { + using S = std::remove_const_t; + using U = std::remove_const_t; + + S lo = MIN2(input->_lo, S(uniform_random())); + S hi = MAX2(input->_hi, S(uniform_random())); + U ulo = MIN2(input->_ulo, uniform_random()); + U uhi = MAX2(input->_uhi, uniform_random()); + U zeros = input->_bits._zeros & uniform_random(); + U ones = input->_bits._ones & uniform_random(); + InputType super = InputType::make(TypeIntPrototype{{lo, hi}, {ulo, uhi}, {zeros, ones}}, 0); + assert(super.contains(input), "impossible"); + return super; +} + // Check the monotonicity, that is, if input1 is a subset of super1, input2 is a subset of super2, // then infer(input1, input2) must be a subset of infer(super1, super2). This version does the // check randomly on a number of supersets of input1 and input2. @@ -443,20 +474,8 @@ static void test_binary_instance_monotonicity_samples(Inference infer, const Inp ASSERT_TRUE(infer(input1, universe).contains(result)); ASSERT_TRUE(infer(universe, universe).contains(result)); - auto random_superset = [](const InputType& input) { - S lo = MIN2(input->_lo, S(uniform_random())); - S hi = MAX2(input->_hi, S(uniform_random())); - U ulo = MIN2(input->_ulo, uniform_random()); - U uhi = MAX2(input->_uhi, uniform_random()); - U zeros = input->_bits._zeros & uniform_random(); - U ones = input->_bits._ones & uniform_random(); - InputType super = InputType::make(TypeIntPrototype{{lo, hi}, {ulo, uhi}, {zeros, ones}}, 0); - assert(super.contains(input), "impossible"); - return super; - }; - - InputType super1 = random_superset(input1); - InputType super2 = random_superset(input2); + InputType super1 = compute_random_superset(input1); + InputType super2 = compute_random_superset(input2); ASSERT_TRUE(infer(super1, input2).contains(result)); ASSERT_TRUE(infer(input1, super2).contains(result)); ASSERT_TRUE(infer(super1, super2).contains(result)); @@ -480,16 +499,11 @@ static void test_binary_exhaustive(Operation op, Inference infer) { } } -// Verify the correctness and monotonicity of an inference function by randomly sampling instances -// of InputType -template -static void test_binary_random(Operation op, Inference infer) { +template +static void populate_sample_types(InputType* samples, const size_t sample_count) { using S = std::remove_const_t; using U = std::remove_const_t; - constexpr size_t sample_count = 100; - InputType samples[sample_count]; - // Fill with {0} for (size_t i = 0; i < sample_count; i++) { samples[i] = InputType::make(TypeIntPrototype{{S(0), S(0)}, {U(0), U(0)}, {U(0), U(0)}}, 0); @@ -549,6 +563,18 @@ static void test_binary_random(Operation op, Inference infer) { canonicalized_t._data._bits}; idx++; } +} + +// Verify the correctness and monotonicity of an inference function by randomly sampling instances +// of InputType +template +static void test_binary_random(Operation op, Inference infer) { + using S = std::remove_const_t; + using U = std::remove_const_t; + + constexpr size_t sample_count = 100; + InputType samples[sample_count]; + populate_sample_types(samples, sample_count); for (size_t i = 0; i < sample_count; i++) { for (size_t j = 0; j < sample_count; j++) { @@ -570,6 +596,107 @@ static void test_binary() { test_binary_random>(Operation(), Inference>()); } +template +static U lshift_op(U v, int shift) { + return v << shift; +} + +// Test correctness: for all values v in input, (v << shift) must be in the result +template +static void test_lshift_correctness(const InputType& input, int shift) { + using U = std::remove_const_t_ulo)>; + auto result = RangeInference::infer_lshift(input, shift); + for (juint v = 0; v <= juint(std::numeric_limits::max()); v++) { + if (input.contains(U(v))) { + U r = lshift_op(U(v), shift); + ASSERT_TRUE(result.contains(r)); + } + } +} + +// Test correctness for jint/jlong types by sampling values from the input range. +template +static void test_lshift_correctness_samples(const InputType& input, int shift) { + using U = std::remove_const_t_ulo)>; + auto result = RangeInference::infer_lshift(input, shift); + + constexpr size_t sample_count = 6; + U samples[sample_count]; + populate_sample_values(samples, sample_count, input); + + for (size_t i = 0; i < sample_count; i++) { + ASSERT_TRUE(input.contains(samples[i])); + + U r = lshift_op(samples[i], shift); + ASSERT_TRUE(result.contains(r)); + } +} + +// Test monotonicity: if input is a subset of super, then result is a subset of +// infer_lshift(super, shift) +template +static void test_lshift_monotonicity(const InputType& input, int shift) { + auto result = RangeInference::infer_lshift(input, shift); + for (const InputType& super : all_instances()) { + if (super.contains(input)) { + ASSERT_TRUE(RangeInference::infer_lshift(super, shift).contains(result)); + } + } +} + +// Test monotonicity for jint/jlong types by constructing random supersets. +template +static void test_lshift_monotonicity_samples(const InputType& input, int shift) { + using S = std::remove_const_t_lo)>; + using U = std::remove_const_t_ulo)>; + auto result = RangeInference::infer_lshift(input, shift); + + // The universe is a superset of all other sets + InputType universe = InputType{std::numeric_limits::min(), std::numeric_limits::max(), U(0), U(-1), {U(0), U(0)}}; + ASSERT_TRUE(RangeInference::infer_lshift(universe, shift).contains(result)); + + InputType super = compute_random_superset(input); + ASSERT_TRUE(RangeInference::infer_lshift(super, shift).contains(result)); +} + +template +static void test_lshift_for_type() { + using U = std::remove_const_t; + constexpr int type_bits = HotSpotNumerics::type_width(); + for (const InputType& input : all_instances()) { + for (int shift = 0; shift < type_bits; shift++) { + test_lshift_correctness(input, shift); + test_lshift_monotonicity(input, shift); + } + } +} + +// Sample-based test for jint/jlong types +template +static void test_lshift_random() { + using S = std::remove_const_t; + using U = std::remove_const_t; + + constexpr size_t sample_count = 100; + InputType samples[sample_count]; + populate_sample_types(samples, sample_count); + + for (size_t i = 0; i < sample_count; i++) { + for (int shift = 0; shift < HotSpotNumerics::type_width(); shift++) { + test_lshift_correctness_samples(samples[i], shift); + test_lshift_monotonicity_samples(samples[i], shift); + } + } +} + +static void test_lshift() { + test_lshift_for_type, uintn_t<1>>>(); + test_lshift_for_type, uintn_t<2>>>(); + test_lshift_for_type, uintn_t<3>>>(); + test_lshift_random>(); + test_lshift_random>(); +} + template class OpAnd { public: @@ -622,4 +749,5 @@ TEST(opto, range_inference) { test_binary(); test_binary(); test_binary(); + test_lshift(); } diff --git a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp index 7a4f7bcb99e..69d04ae8883 100644 --- a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp +++ b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp @@ -479,7 +479,7 @@ TEST(cgroupTest, set_cgroupv1_subsystem_path_adjusted) { ccc->set_subsystem_path((char*)cpu.cgroup_path); EXPECT_TRUE(ccc->needs_hierarchy_adjustment()); - CgroupUtil::adjust_controller(ccc); + CgroupUtil::adjust_controller(ccc, 1); ASSERT_STREQ(cpu.expected_path, ccc->subsystem_path()); EXPECT_FALSE(ccc->needs_hierarchy_adjustment()); @@ -489,7 +489,7 @@ TEST(cgroupTest, set_cgroupv1_subsystem_path_adjusted) { cmc->set_subsystem_path((char*)memory.cgroup_path); EXPECT_TRUE(cmc->needs_hierarchy_adjustment()); - CgroupUtil::adjust_controller(cmc); + CgroupUtil::adjust_controller(cmc, (physical_memory_size_type)1024); ASSERT_STREQ(memory.expected_path, cmc->subsystem_path()); EXPECT_FALSE(cmc->needs_hierarchy_adjustment()); } @@ -512,7 +512,7 @@ TEST(cgroupTest, set_cgroupv2_subsystem_path_adjusted) { true /* read-only mount */)); EXPECT_TRUE(ccc->needs_hierarchy_adjustment()); - CgroupUtil::adjust_controller(ccc); + CgroupUtil::adjust_controller(ccc, 1); ASSERT_STREQ(cpu.expected_path, ccc->subsystem_path()); EXPECT_FALSE(ccc->needs_hierarchy_adjustment()); @@ -521,7 +521,7 @@ TEST(cgroupTest, set_cgroupv2_subsystem_path_adjusted) { true /* read-only mount */)); EXPECT_TRUE(cmc->needs_hierarchy_adjustment()); - CgroupUtil::adjust_controller(cmc); + CgroupUtil::adjust_controller(cmc, (physical_memory_size_type)1024); ASSERT_STREQ(memory.expected_path, cmc->subsystem_path()); EXPECT_FALSE(cmc->needs_hierarchy_adjustment()); } diff --git a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp index 5b78a66a3ae..8cf62fb9ea5 100644 --- a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp +++ b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,15 +45,14 @@ public: VirtualMemoryTracker::Instance::snapshot_thread_stacks(); } - ReservedMemoryRegion rmr_found; + VirtualMemoryRegion rgn_found; { MemTracker::NmtVirtualMemoryLocker vml; - rmr_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region(stack_end); + rgn_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region(stack_end); } - ASSERT_TRUE(rmr_found.is_valid()); - ASSERT_EQ(rmr_found.base(), stack_end); - + ASSERT_TRUE(rgn_found.is_valid()); + ASSERT_EQ(rgn_found.base(), stack_end); int i = 0; address i_addr = (address)&i; @@ -64,12 +63,12 @@ public: bool found_stack_top = false; { MemTracker::NmtVirtualMemoryLocker vml; - VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr_found, [&](const CommittedMemoryRegion& cmr) { - if (cmr.base() + cmr.size() == stack_top) { - EXPECT_TRUE(cmr.size() <= stack_size); + VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rgn_found, [&](const VirtualMemoryRegion& rgn) { + if (rgn.base() + rgn.size() == stack_top) { + EXPECT_TRUE(rgn.size() <= stack_size); found_stack_top = true; } - if (i_addr < stack_top && i_addr >= cmr.base()) { + if (i_addr < stack_top && i_addr >= rgn.base()) { found_i_addr = true; } i++; @@ -115,25 +114,25 @@ public: } // trigger the test - ReservedMemoryRegion rmr_found; + VirtualMemoryRegion rgn_found; { MemTracker::NmtVirtualMemoryLocker nvml; VirtualMemoryTracker::Instance::snapshot_thread_stacks(); - rmr_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region((address)base); + rgn_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region((address)base); } - ASSERT_TRUE(rmr_found.is_valid()); - ASSERT_EQ(rmr_found.base(), (address)base); + ASSERT_TRUE(rgn_found.is_valid()); + ASSERT_EQ(rgn_found.base(), (address)base); bool precise_tracking_supported = false; { MemTracker::NmtVirtualMemoryLocker nvml; - VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr_found, [&](const CommittedMemoryRegion& cmr){ - if (cmr.size() == size) { + VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rgn_found, [&](const VirtualMemoryRegion& rgn){ + if (rgn.size() == size) { return false; } else { precise_tracking_supported = true; - check_covered_pages(cmr.base(), cmr.size(), (address)base, touch_pages, page_num); + check_covered_pages(rgn.base(), rgn.size(), (address)base, touch_pages, page_num); } return true; }); @@ -151,9 +150,9 @@ public: { MemTracker::NmtVirtualMemoryLocker nvml; VirtualMemoryTracker::Instance::remove_released_region((address)base, size); - rmr_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region((address)base); + rgn_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region((address)base); } - ASSERT_TRUE(!rmr_found.is_valid()); + ASSERT_TRUE(!rgn_found.is_valid()); } static void test_committed_region() { diff --git a/test/hotspot/gtest/runtime/test_globals.cpp b/test/hotspot/gtest/runtime/test_globals.cpp index 84a62732056..e88f930ff73 100644 --- a/test/hotspot/gtest/runtime/test_globals.cpp +++ b/test/hotspot/gtest/runtime/test_globals.cpp @@ -42,7 +42,7 @@ } while (0) TEST_VM(FlagGuard, bool_flag) { - TEST_FLAG(AlwaysActAsServerClassMachine, bool, true); + TEST_FLAG(PrintCompilation, bool, true); } TEST_VM(FlagGuard, int_flag) { @@ -58,7 +58,7 @@ TEST_VM(FlagGuard, size_t_flag) { } TEST_VM(FlagGuard, uint64_t_flag) { - TEST_FLAG(MaxRAM, uint64_t, 1337); + TEST_FLAG(ErrorLogTimeout, uint64_t, 1337); } TEST_VM(FlagGuard, double_flag) { diff --git a/test/hotspot/gtest/runtime/test_os.cpp b/test/hotspot/gtest/runtime/test_os.cpp index 7f90a21884b..094f16a4262 100644 --- a/test/hotspot/gtest/runtime/test_os.cpp +++ b/test/hotspot/gtest/runtime/test_os.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -506,6 +506,7 @@ static inline bool can_reserve_executable_memory(void) { #define PRINT_MAPPINGS(s) { tty->print_cr("%s", s); os::print_memory_mappings((char*)p, total_range_len, tty); tty->cr(); } //#define PRINT_MAPPINGS +#ifndef _AIX // Release a range allocated with reserve_multiple carefully, to not trip mapping // asserts on Windows in os::release_memory() static void carefully_release_multiple(address start, int num_stripes, size_t stripe_len) { @@ -515,7 +516,6 @@ static void carefully_release_multiple(address start, int num_stripes, size_t st } } -#ifndef _AIX // JDK-8257041 // Reserve an area consisting of multiple mappings // (from multiple calls to os::reserve_memory) static address reserve_multiple(int num_stripes, size_t stripe_len) { diff --git a/test/hotspot/gtest/runtime/test_os_linux.cpp b/test/hotspot/gtest/runtime/test_os_linux.cpp index 337365592dc..9c624267c18 100644 --- a/test/hotspot/gtest/runtime/test_os_linux.cpp +++ b/test/hotspot/gtest/runtime/test_os_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -59,7 +59,7 @@ namespace { HugeTlbfsMemory(char* const ptr, size_t size) : _ptr(ptr), _size(size) { } ~HugeTlbfsMemory() { if (_ptr != nullptr) { - os::release_memory_special(_ptr, _size); + os::release_memory(_ptr, _size); } } }; @@ -227,7 +227,7 @@ class TestReserveMemorySpecial : AllStatic { char* addr = os::reserve_memory_special(size, alignment, page_size, nullptr, false); if (addr != nullptr) { small_page_write(addr, size); - os::release_memory_special(addr, size); + os::release_memory(addr, size); } } @@ -285,7 +285,7 @@ class TestReserveMemorySpecial : AllStatic { if (p != nullptr) { EXPECT_TRUE(is_aligned(p, alignment)); small_page_write(p, size); - os::release_memory_special(p, size); + os::release_memory(p, size); } } } @@ -300,7 +300,7 @@ class TestReserveMemorySpecial : AllStatic { if (p != nullptr) { EXPECT_EQ(p, req_addr); small_page_write(p, size); - os::release_memory_special(p, size); + os::release_memory(p, size); } } } diff --git a/test/hotspot/gtest/runtime/test_os_windows.cpp b/test/hotspot/gtest/runtime/test_os_windows.cpp index 2d9a7e00b39..13574dcbdb3 100644 --- a/test/hotspot/gtest/runtime/test_os_windows.cpp +++ b/test/hotspot/gtest/runtime/test_os_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +39,7 @@ namespace { MemoryReleaser(char* ptr, size_t size) : _ptr(ptr), _size(size) { } ~MemoryReleaser() { if (_ptr != nullptr) { - os::release_memory_special(_ptr, _size); + os::release_memory(_ptr, _size); } } }; diff --git a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp index 4242302997a..a7e4b273788 100644 --- a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp +++ b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -50,41 +50,41 @@ namespace { }; } -#define check(vmt, rmr, regions) check_inner((vmt), (rmr), (regions), ARRAY_SIZE(regions), __FILE__, __LINE__) +#define check(vmt, rgn, regions) check_inner((vmt), (rgn), (regions), ARRAY_SIZE(regions), __FILE__, __LINE__) -#define check_empty(vmt, rmr) \ +#define check_empty(vmt, rgn) \ do { \ - check_inner((vmt), (rmr), nullptr, 0, __FILE__, __LINE__); \ + check_inner((vmt), (rgn), nullptr, 0, __FILE__, __LINE__); \ } while (false) -static void diagnostic_print(VirtualMemoryTracker& vmt, const ReservedMemoryRegion& rmr) { - LOG("In reserved region " PTR_FORMAT ", size %X:", p2i(rmr.base()), rmr.size()); - vmt.tree()->visit_committed_regions(rmr, [&](CommittedMemoryRegion& region) { - LOG(" committed region: " PTR_FORMAT ", size %X", p2i(region.base()), region.size()); +static void diagnostic_print(VirtualMemoryTracker& vmt, const VirtualMemoryRegion& rgn) { + LOG("In reserved region " PTR_FORMAT ", size %X:", p2i(rgn.base()), rgn.size()); + vmt.tree()->visit_committed_regions(rgn, [&](VirtualMemoryRegion& crgn) { + LOG(" committed region: " PTR_FORMAT ", size %X", p2i(crgn.base()), crgn.size()); return true; }); } -static void check_inner(VirtualMemoryTracker& vmt, const ReservedMemoryRegion& rmr, R* regions, size_t regions_size, const char* file, int line) { +static void check_inner(VirtualMemoryTracker& vmt, const VirtualMemoryRegion& rgn, R* regions, size_t regions_size, const char* file, int line) { size_t i = 0; size_t size = 0; // Helpful log - diagnostic_print(vmt, rmr); + diagnostic_print(vmt, rgn); #define WHERE " from " << file << ":" << line - vmt.tree()->visit_committed_regions(rmr, [&](CommittedMemoryRegion& region) { + vmt.tree()->visit_committed_regions(rgn, [&](VirtualMemoryRegion& crgn) { EXPECT_LT(i, regions_size) << WHERE; - EXPECT_EQ(region.base(), regions[i]._addr) << WHERE; - EXPECT_EQ(region.size(), regions[i]._size) << WHERE; - size += region.size(); + EXPECT_EQ(crgn.base(), regions[i]._addr) << WHERE; + EXPECT_EQ(crgn.size(), regions[i]._size) << WHERE; + size += crgn.size(); i++; return true; }); EXPECT_EQ(i, regions_size) << WHERE; - EXPECT_EQ(size, vmt.committed_size(&rmr)) << WHERE; + EXPECT_EQ(size, vmt.committed_size(&rgn)) << WHERE; } class VirtualMemoryTrackerTest { @@ -104,11 +104,11 @@ public: NativeCallStack stack(&frame1, 1); NativeCallStack stack2(&frame2, 1); - // Fetch the added RMR for the space - ReservedMemoryRegion rmr = rtree->find_reserved_region(addr); + // Fetch the added region for the space + VirtualMemoryRegion rgn = rtree->find_reserved_region(addr); - ASSERT_EQ(rmr.size(), size); - ASSERT_EQ(rmr.base(), addr); + ASSERT_EQ(rgn.size(), size); + ASSERT_EQ(rgn.base(), addr); // Commit Size Granularity const size_t cs = 0x1000; @@ -118,24 +118,24 @@ public: { // Commit one region rtree->commit_region(addr + cs, cs, stack, diff); R r[] = { {addr + cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent - lower address rtree->commit_region(addr, cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent - higher address rtree->commit_region(addr + 2 * cs, cs, stack, diff); R r[] = { {addr, 3 * cs} }; - check(vmt,rmr, r); + check(vmt, rgn, r); } // Cleanup rtree->uncommit_region(addr, 3 * cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 0u); + ASSERT_EQ(vmt.committed_size(&rgn), 0u); // Commit adjacent regions with different stacks @@ -143,14 +143,14 @@ public: { // Commit one region rtree->commit_region(addr + cs, cs, stack, diff); R r[] = { {addr + cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent - lower address rtree->commit_region(addr, cs, stack2, diff); R r[] = { {addr, cs}, {addr + cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent - higher address @@ -158,12 +158,12 @@ public: R r[] = { {addr, cs}, {addr + cs, cs}, {addr + 2 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // Cleanup rtree->uncommit_region(addr, 3 * cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 0u); + ASSERT_EQ(vmt.committed_size(&rgn), 0u); } static void test_add_committed_region_adjacent_overlapping() { @@ -180,11 +180,11 @@ public: NativeCallStack stack(&frame1, 1); NativeCallStack stack2(&frame2, 1); - // Fetch the added RMR for the space - ReservedMemoryRegion rmr = rtree->find_reserved_region(addr); + // Fetch the added region for the space + VirtualMemoryRegion rgn = rtree->find_reserved_region(addr); - ASSERT_EQ(rmr.size(), size); - ASSERT_EQ(rmr.base(), addr); + ASSERT_EQ(rgn.size(), size); + ASSERT_EQ(rgn.base(), addr); // Commit Size Granularity const size_t cs = 0x1000; @@ -196,28 +196,28 @@ public: rtree->commit_region(addr + 3 * cs, 2 * cs, stack, diff); R r[] = { {addr, 2 * cs}, {addr + 3 * cs, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent and overlapping rtree->commit_region(addr + 2 * cs, 2 * cs, stack, diff); R r[] = { {addr, 5 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // revert to two non-adjacent regions rtree->uncommit_region(addr + 2 * cs, cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 4 * cs); + ASSERT_EQ(vmt.committed_size(&rgn), 4 * cs); { // Commit overlapping and adjacent rtree->commit_region(addr + cs, 2 * cs, stack, diff); R r[] = { {addr, 5 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // Cleanup rtree->uncommit_region(addr, 5 * cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 0u); + ASSERT_EQ(vmt.committed_size(&rgn), 0u); // Commit adjacent and overlapping regions with different stacks @@ -227,7 +227,7 @@ public: rtree->commit_region(addr + 3 * cs, 2 * cs, stack, diff); R r[] = { {addr, 2 * cs}, {addr + 3 * cs, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit adjacent and overlapping @@ -235,20 +235,20 @@ public: R r[] = { {addr, 2 * cs}, {addr + 2 * cs, 2 * cs}, {addr + 4 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // revert to two non-adjacent regions rtree->commit_region(addr, 5 * cs, stack, diff); rtree->uncommit_region(addr + 2 * cs, cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 4 * cs); + ASSERT_EQ(vmt.committed_size(&rgn), 4 * cs); { // Commit overlapping and adjacent rtree->commit_region(addr + cs, 2 * cs, stack2, diff); R r[] = { {addr, cs}, {addr + cs, 2 * cs}, {addr + 3 * cs, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } rtree->tree().remove_all(); @@ -269,12 +269,12 @@ public: NativeCallStack stack(&frame1, 1); NativeCallStack stack2(&frame2, 1); - // Fetch the added RMR for the space - ReservedMemoryRegion rmr = rtree->find_reserved_region(addr); + // Fetch the added region for the space + VirtualMemoryRegion rgn = rtree->find_reserved_region(addr); - ASSERT_EQ(rmr.size(), size); - ASSERT_EQ(rmr.base(), addr); + ASSERT_EQ(rgn.size(), size); + ASSERT_EQ(rgn.base(), addr); // Commit Size Granularity const size_t cs = 0x1000; @@ -284,54 +284,54 @@ public: { // Commit one region rtree->commit_region(addr, cs, stack, diff); R r[] = { {addr, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit the same region rtree->commit_region(addr, cs, stack, diff); R r[] = { {addr, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit a succeeding region rtree->commit_region(addr + cs, cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit over two regions rtree->commit_region(addr, 2 * cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } {// Commit first part of a region rtree->commit_region(addr, cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit second part of a region rtree->commit_region(addr + cs, cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit a third part rtree->commit_region(addr + 2 * cs, cs, stack, diff); R r[] = { {addr, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit in the middle of a region rtree->commit_region(addr + 1 * cs, cs, stack, diff); R r[] = { {addr, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // Cleanup rtree->uncommit_region(addr, 3 * cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 0u); + ASSERT_EQ(vmt.committed_size(&rgn), 0u); // With preceding region @@ -342,71 +342,71 @@ public: { R r[] = { {addr, cs}, {addr + 2 * cs, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } rtree->commit_region(addr + 3 * cs, cs, stack, diff); { R r[] = { {addr, cs}, {addr + 2 * cs, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } rtree->commit_region(addr + 4 * cs, cs, stack, diff); { R r[] = { {addr, cs}, {addr + 2 * cs, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // Cleanup rtree->uncommit_region(addr, 5 * cs, diff); - ASSERT_EQ(vmt.committed_size(&rmr), 0u); + ASSERT_EQ(vmt.committed_size(&rgn), 0u); // With different stacks { // Commit one region rtree->commit_region(addr, cs, stack, diff); R r[] = { {addr, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit the same region rtree->commit_region(addr, cs, stack2, diff); R r[] = { {addr, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit a succeeding region rtree->commit_region(addr + cs, cs, stack, diff); R r[] = { {addr, cs}, {addr + cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit over two regions rtree->commit_region(addr, 2 * cs, stack, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } {// Commit first part of a region rtree->commit_region(addr, cs, stack2, diff); R r[] = { {addr, cs}, {addr + cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit second part of a region rtree->commit_region(addr + cs, cs, stack2, diff); R r[] = { {addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit a third part rtree->commit_region(addr + 2 * cs, cs, stack2, diff); R r[] = { {addr, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } { // Commit in the middle of a region @@ -414,7 +414,7 @@ public: R r[] = { {addr, cs}, {addr + cs, cs}, {addr + 2 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } rtree->tree().remove_all(); @@ -445,11 +445,11 @@ public: NativeCallStack stack(&frame1, 1); NativeCallStack stack2(&frame2, 1); - // Fetch the added RMR for the space - ReservedMemoryRegion rmr = rtree->find_reserved_region(addr); + // Fetch the added region for the space + VirtualMemoryRegion rgn = rtree->find_reserved_region(addr); - ASSERT_EQ(rmr.size(), size); - ASSERT_EQ(rmr.base(), addr); + ASSERT_EQ(rgn.size(), size); + ASSERT_EQ(rgn.base(), addr); // Commit Size Granularity const size_t cs = 0x1000; @@ -457,11 +457,11 @@ public: { // Commit regions rtree->commit_region(addr, 3 * cs, stack, diff); R r[] = { {addr, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); // Remove only existing rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { @@ -473,7 +473,7 @@ public: rtree->uncommit_region(addr, cs, diff); R r[] = { {addr + 2 * cs, cs}, {addr + 4 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // add back @@ -483,7 +483,7 @@ public: rtree->uncommit_region(addr + 2 * cs, cs, diff); R r[] = { {addr + 0 * cs, cs}, {addr + 4 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } // add back @@ -493,17 +493,17 @@ public: rtree->uncommit_region(addr + 4 * cs, cs, diff); R r[] = { {addr + 0 * cs, cs}, {addr + 2 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); } rtree->uncommit_region(addr, 5 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove larger region rtree->commit_region(addr + 1 * cs, cs, stack, diff); rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove smaller region - in the middle @@ -511,50 +511,50 @@ public: rtree->uncommit_region(addr + 1 * cs, cs, diff); R r[] = { { addr + 0 * cs, cs}, { addr + 2 * cs, cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove smaller region - at the beginning rtree->commit_region(addr, 3 * cs, stack, diff); rtree->uncommit_region(addr + 0 * cs, cs, diff); R r[] = { { addr + 1 * cs, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove smaller region - at the end rtree->commit_region(addr, 3 * cs, stack, diff); rtree->uncommit_region(addr + 2 * cs, cs, diff); R r[] = { { addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove smaller, overlapping region - at the beginning rtree->commit_region(addr + 1 * cs, 4 * cs, stack, diff); rtree->uncommit_region(addr, 2 * cs, diff); R r[] = { { addr + 2 * cs, 3 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); rtree->uncommit_region(addr + 1 * cs, 4 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } { // Remove smaller, overlapping region - at the end rtree->commit_region(addr, 3 * cs, stack, diff); rtree->uncommit_region(addr + 2 * cs, 2 * cs, diff); R r[] = { { addr, 2 * cs} }; - check(vmt, rmr, r); + check(vmt, rgn, r); rtree->uncommit_region(addr, 3 * cs, diff); - check_empty(vmt, rmr); + check_empty(vmt, rgn); } rtree->tree().remove_all(); diff --git a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp index 77055e92256..8094e93b944 100644 --- a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp +++ b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp @@ -888,7 +888,6 @@ public: virtual ~RunnerGSInserterThread(){} void premain() { - volatile bool timeout = false; _start = START; _range = RANGE; CHTTestThread* tt[GSTEST_THREAD_COUNT]; diff --git a/test/hotspot/gtest/utilities/test_globalDefinitions.cpp b/test/hotspot/gtest/utilities/test_globalDefinitions.cpp index f24d74ea529..b8b65ae8ca8 100644 --- a/test/hotspot/gtest/utilities/test_globalDefinitions.cpp +++ b/test/hotspot/gtest/utilities/test_globalDefinitions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,6 @@ */ #include "cppstdlib/type_traits.hpp" -#include "memory/resourceArea.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" @@ -220,10 +219,9 @@ TEST(globalDefinitions, array_size) { #define check_format(format, value, expected) \ do { \ - ResourceMark rm; \ stringStream out; \ out.print((format), (value)); \ - const char* result = out.as_string(); \ + const char* result = out.base(); \ EXPECT_STREQ((result), (expected)) << "Failed with" \ << " format '" << (format) << "'" \ << " value '" << (value); \ @@ -321,3 +319,38 @@ TEST(globalDefinitions, jlong_from) { val = jlong_from(0xABCD, 0xEFEF); EXPECT_EQ(val, CONST64(0x0000ABCD0000EFEF)); } + +struct NoCopy { + int x; + NONCOPYABLE(NoCopy); +}; + +TEST(globalDefinitions, sizeof_auto) { + char x = 5; + char& y = x; + char* z = &x; + EXPECT_EQ(sizeof_auto(x), sizeof(x)); + EXPECT_EQ(sizeof_auto(y), sizeof(y)); + EXPECT_EQ(sizeof_auto(z), sizeof(z)); + + NoCopy nc{0}; + sizeof_auto(nc); + + static_assert(sizeof_auto(char[1LL]) == 1); + static_assert(sizeof_auto(char[std::numeric_limits::max() + 1LL]) == std::numeric_limits::max() + 1LL); + static_assert(sizeof_auto(char[std::numeric_limits::max() + 1LL]) == std::numeric_limits::max() + 1LL); +#if defined(_LP64) && !defined(_WINDOWS) + // char array sometimes limited to 2 gig length on 32 bit platforms (signed), disabled for Windows because of compiler error C2148. + static_assert(sizeof_auto(char[std::numeric_limits::max() + 1LL]) == std::numeric_limits::max() + 1LL); +#endif + + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max()])) == sizeof(uint8_t)); + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max() + 1LL])) == sizeof(uint16_t)); + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max()])) == sizeof(uint16_t)); + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max() + 1LL])) == sizeof(uint32_t)); +#if defined(_LP64) && !defined(_WINDOWS) + // char array sometimes limited to 2 gig length on 32 bit platforms (signed), disabled for Windows because of compiler error C2148. + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max()])) == sizeof(uint32_t)); + static_assert(sizeof(sizeof_auto(char[std::numeric_limits::max() + 1LL])) == sizeof(uint64_t)); +#endif +} diff --git a/test/hotspot/gtest/utilities/test_integerCast.cpp b/test/hotspot/gtest/utilities/test_integerCast.cpp new file mode 100644 index 00000000000..87d35384c2c --- /dev/null +++ b/test/hotspot/gtest/utilities/test_integerCast.cpp @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2026, 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. + */ + +#include "cppstdlib/limits.hpp" +#include "cppstdlib/type_traits.hpp" +#include "utilities/integerCast.hpp" +#include "utilities/globalDefinitions.hpp" + +#include "unittest.hpp" + +// Enable gcc warnings to verify we don't get any of these. +// Eventually we plan to have these globally enabled, but not there yet. +#ifdef __GNUC__ +#pragma GCC diagnostic warning "-Wconversion" +#pragma GCC diagnostic warning "-Wsign-conversion" +#endif + +// Tautology tests for signed -> signed types. +static_assert(is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); +static_assert(is_always_integer_convertible()); +static_assert(is_always_integer_convertible()); + +// Tautology tests for unsigned -> unsigned types. +static_assert(is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); +static_assert(is_always_integer_convertible()); +static_assert(is_always_integer_convertible()); + +// Tautology tests for signed -> unsigned types. +static_assert(!is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); + +// Tautology tests for unsigned -> signed types. +static_assert(!is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); +static_assert(is_always_integer_convertible()); +static_assert(!is_always_integer_convertible()); + +template +struct TestIntegerCastValues { + static TestIntegerCastValues values; + + T minus_one = static_cast(-1); + T zero = static_cast(0); + T one = static_cast(1); + T min = std::numeric_limits::min(); + T max = std::numeric_limits::max(); +}; + +template +TestIntegerCastValues TestIntegerCastValues::values{}; + +template +struct TestIntegerCastPairedValues { + static TestIntegerCastPairedValues values; + + From min = static_cast(std::numeric_limits::min()); + From max = static_cast(std::numeric_limits::max()); +}; + +template +TestIntegerCastPairedValues +TestIntegerCastPairedValues::values{}; + +////////////////////////////////////////////////////////////////////////////// +// Integer casts between integral types of different sizes. +// Test narrowing to verify checking. +// Test widening to verify no compiler warnings for tautological comparisons. + +template +struct TestIntegerCastIntegerValues { + static TestIntegerCastIntegerValues values; + + TestIntegerCastValues to; + TestIntegerCastValues from; + TestIntegerCastPairedValues to_as_from; +}; + +template +TestIntegerCastIntegerValues +TestIntegerCastIntegerValues::values{}; + +template +static void good_integer_conversion(From from) { + ASSERT_TRUE(is_integer_convertible(from)); + EXPECT_EQ(static_cast(from), integer_cast(from)); +} + +template +static void bad_integer_conversion(From from) { + EXPECT_FALSE(is_integer_convertible(from)); +} + +// signed -> signed is tautological unless From is wider than To. + +TEST(TestIntegerCast, wide_signed_to_narrow_signed_integers) { + using To = int32_t; + using From = int64_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + good_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + bad_integer_conversion(values.from.min); + bad_integer_conversion(values.from.max); + good_integer_conversion(values.to_as_from.min); + good_integer_conversion(values.to_as_from.max); + bad_integer_conversion(values.to_as_from.min - 1); + bad_integer_conversion(values.to_as_from.max + 1); +} + +// unsigned -> unsigned is tautological unless From is wider than To. + +TEST(TestIntegerCast, wide_unsigned_to_narrow_unsigned_integers) { + using To = uint32_t; + using From = uint64_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + bad_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + good_integer_conversion(values.from.min); + bad_integer_conversion(values.from.max); + good_integer_conversion(values.to_as_from.min); + good_integer_conversion(values.to_as_from.min); + bad_integer_conversion(values.to_as_from.min - 1); + bad_integer_conversion(values.to_as_from.max + 1); +} + +TEST(TestIntegerCast, unsigned_to_signed_same_size_integers) { + using To = int32_t; + using From = uint32_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + good_integer_conversion(values.from.min); + bad_integer_conversion(values.from.max); + bad_integer_conversion(values.to_as_from.min); + good_integer_conversion(values.to_as_from.max); + bad_integer_conversion(values.to_as_from.max + 1); +} + +// Narrow unsigned to wide signed is tautological. + +TEST(TestIntegerCast, wide_unsigned_to_narrow_signed_integers) { + using To = int32_t; + using From = uint64_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + bad_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + good_integer_conversion(values.from.min); + bad_integer_conversion(values.from.max); + bad_integer_conversion(values.to_as_from.min); + good_integer_conversion(values.to_as_from.max); + bad_integer_conversion(values.to_as_from.min - 1); + bad_integer_conversion(values.to_as_from.max + 1); +} + +TEST(TestIntegerCast, signed_to_unsigned_same_size_integers) { + using To = uint32_t; + using From = int32_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + bad_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + bad_integer_conversion(values.from.min); + good_integer_conversion(values.from.max); + good_integer_conversion(values.to_as_from.min); + bad_integer_conversion(values.to_as_from.max); +} + +TEST(TestIntegerCast, narrow_signed_to_wide_unsigned_integers) { + using To = uint64_t; + using From = int32_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + bad_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + bad_integer_conversion(values.from.min); + good_integer_conversion(values.from.max); + good_integer_conversion(values.to_as_from.min); + bad_integer_conversion(values.to_as_from.max); +} + +TEST(TestIntegerCast, wide_signed_to_narrow_unsigned_integers) { + using To = uint32_t; + using From = int64_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + bad_integer_conversion(values.from.minus_one); + good_integer_conversion(values.from.zero); + good_integer_conversion(values.from.one); + bad_integer_conversion(values.from.min); + bad_integer_conversion(values.from.max); + good_integer_conversion(values.to_as_from.min); + good_integer_conversion(values.to_as_from.max); +} + +TEST(TestIntegerCast, permit_tautology) { + using From = uint32_t; + using To = int64_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + static_assert(is_always_integer_convertible()); + EXPECT_EQ(static_cast(values.from.min), + (integer_cast(values.from.min))); + EXPECT_EQ(static_cast(values.from.min), + (integer_cast_permit_tautology(values.from.min))); + EXPECT_EQ(static_cast(values.from.max), + (integer_cast(values.from.max))); + EXPECT_EQ(static_cast(values.from.max), + integer_cast_permit_tautology(values.from.max)); +} + +TEST(TestIntegerCast, check_constexpr) { + using From = int64_t; + using To = int32_t; + constexpr From value = std::numeric_limits::max(); + constexpr To converted = integer_cast(value); + EXPECT_EQ(static_cast(value), converted); +} + +#ifdef ASSERT + +TEST_VM_ASSERT(TestIntegerCast, cast_failure_signed_range) { + using From = int64_t; + using To = int32_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + From value = values.from.max; + To expected = static_cast(value); // Narrowing conversion. + EXPECT_FALSE(is_integer_convertible(value)); + // Should assert. If it doesn't, then shuld be equal, so fail. + EXPECT_NE(static_cast(value), integer_cast(value)); +} + +TEST_VM_ASSERT(TestIntegerCast, cast_failure_unsigned_range) { + using From = uint64_t; + using To = uint32_t; + using Values = TestIntegerCastIntegerValues; + const Values& values = Values::values; + + From value = values.from.max; + To expected = static_cast(value); // Narrowing conversion. + EXPECT_FALSE(is_integer_convertible(value)); + // Should assert. If it doesn't, then should be equal, so fail. + EXPECT_NE(static_cast(value), integer_cast(value)); +} + +#endif // ASSERT diff --git a/test/hotspot/gtest/utilities/test_istream.cpp b/test/hotspot/gtest/utilities/test_istream.cpp index c07450822af..643d8cf8fcf 100644 --- a/test/hotspot/gtest/utilities/test_istream.cpp +++ b/test/hotspot/gtest/utilities/test_istream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -305,16 +305,13 @@ static void istream_test_driver(const bool VERBOSE, } TEST_VM(istream, basic) { - const bool VERBOSE = false; - istream_test_driver(VERBOSE, false, false, false); -} - -TEST_VM(istream, coverage) { - const bool VERBOSE = false; + const bool VERBOSE_TEST = false; + const bool VERBOSE_COVERAGE = false; + istream_test_driver(VERBOSE_TEST, false, false, false); #ifdef ASSERT istream_coverage_mode(0, cases, total, zeroes); if (cases == 0) return; - if (VERBOSE || zeroes != 0) + if (VERBOSE_COVERAGE || zeroes != 0) istream_coverage_mode(-1, cases, total, zeroes); EXPECT_EQ(zeroes, 0) << "zeroes: " << zeroes << "/" << cases; #endif //ASSERT diff --git a/test/hotspot/gtest/utilities/test_rbtree.cpp b/test/hotspot/gtest/utilities/test_rbtree.cpp index a351e2141e8..7eca5f54831 100644 --- a/test/hotspot/gtest/utilities/test_rbtree.cpp +++ b/test/hotspot/gtest/utilities/test_rbtree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -115,6 +115,16 @@ struct ArrayAllocator { using IntrusiveTreeInt = IntrusiveRBTree; using IntrusiveCursor = IntrusiveTreeInt::Cursor; + struct DestructionTracker { + static int destructed_count; + int value; + + DestructionTracker(int value) : value(value) {} + ~DestructionTracker() { destructed_count++; } + + static void reset() { destructed_count = 0; } + }; + public: void inserting_duplicates_results_in_one_value() { constexpr int up_to = 10; @@ -607,6 +617,55 @@ public: } } + void test_remove_destructs() { + using Tree = RBTreeCHeap; + using Node = RBNode; + using Cursor = Tree::Cursor; + + Tree tree; + + // Test the 3 ways of removing a single node + tree.upsert(0, DestructionTracker(0)); + tree.upsert(1, DestructionTracker(1)); + tree.upsert(2, DestructionTracker(2)); + + DestructionTracker::reset(); + + tree.remove(0); + + Node* n = tree.find_node(1); + tree.remove(n); + + Cursor remove_cursor = tree.cursor(2); + tree.remove_at_cursor(remove_cursor); + + EXPECT_EQ(3, DestructionTracker::destructed_count); + + // Test clearing the tree + constexpr int num_nodes = 10; + for (int n = 0; n < num_nodes; n++) { + tree.upsert(n, DestructionTracker(n)); + } + + DestructionTracker::reset(); + + tree.remove_all(); + EXPECT_EQ(num_nodes, DestructionTracker::destructed_count); + + // Test replacing a node + tree.upsert(0, DestructionTracker(0)); + Cursor replace_cursor = tree.cursor(0); + Node* new_node = tree.allocate_node(1, DestructionTracker(1)); + + DestructionTracker::reset(); + + tree.replace_at_cursor(new_node, replace_cursor); + EXPECT_EQ(1, DestructionTracker::destructed_count); + + tree.remove_at_cursor(replace_cursor); + EXPECT_EQ(2, DestructionTracker::destructed_count); + } + void test_cursor() { constexpr int num_nodes = 10; RBTreeInt tree; @@ -971,6 +1030,11 @@ TEST_VM_F(RBTreeTest, NodeHints) { this->test_node_hints(); } +int RBTreeTest::DestructionTracker::destructed_count = 0; +TEST_VM_F(RBTreeTest, RemoveDestructs) { + this->test_remove_destructs(); +} + TEST_VM_F(RBTreeTest, CursorFind) { this->test_cursor(); } @@ -1252,3 +1316,17 @@ TEST_VM_F(RBTreeTest, AllocatorMayReturnNull) { EXPECT_EQ(false, success); // The test didn't exit the VM, so it was succesful. } + +TEST_VM_F(RBTreeTest, ArenaAllocator) { + Arena arena(mtTest); + RBTreeArena rbtree(&arena); + bool success = rbtree.upsert(5, 5); + ASSERT_EQ(true, success); +} + +TEST_VM_F(RBTreeTest, ResourceAreaAllocator) { + ResourceArea area(mtTest); + RBTreeResourceArea rbtree(&area); + bool success = rbtree.upsert(5, 5); + ASSERT_EQ(true, success); +} diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 3e52b7169df..8514ffce11c 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -27,82 +27,6 @@ # ############################################################################# -# Quiet the majority of SA tests -# We run serviceability/sa/TestUniverse.java as a sanity check for minimal functionality - -resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8307393 generic-all -serviceability/sa/CDSJMapClstats.java 8307393 generic-all -serviceability/sa/ClhsdbAttach.java 8307393 generic-all -serviceability/sa/ClhsdbAttachDifferentJVMs.java 8307393 generic-all -serviceability/sa/ClhsdbCDSCore.java 8307393 generic-all -serviceability/sa/ClhsdbCDSJstackPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbClasses.java 8307393 generic-all -serviceability/sa/ClhsdbDumpclass.java 8307393 generic-all -serviceability/sa/ClhsdbDumpheap.java 8307393 generic-all -serviceability/sa/ClhsdbField.java 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFlags.java 8307393 generic-all -serviceability/sa/ClhsdbHistory.java 8307393 generic-all -serviceability/sa/ClhsdbInspect.java 8307393 generic-all -serviceability/sa/ClhsdbJdis.java 8307393 generic-all -serviceability/sa/ClhsdbJhisto.java 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id0 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id1 8307393 generic-all -serviceability/sa/ClhsdbJstackWithConcurrentLock.java 8307393 generic-all -serviceability/sa/ClhsdbJstackXcompStress.java 8307393 generic-all -serviceability/sa/ClhsdbLongConstant.java 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#core 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#process 8307393 generic-all -serviceability/sa/ClhsdbPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbPrintAs.java 8307393 generic-all -serviceability/sa/ClhsdbPrintStatics.java 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#core 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#process 8307393 generic-all -serviceability/sa/ClhsdbScanOops.java#parallel 8307393 generic-all -serviceability/sa/ClhsdbScanOops.java#serial 8307393 generic-all -serviceability/sa/ClhsdbSource.java 8307393 generic-all -serviceability/sa/ClhsdbSymbol.java 8307393 generic-all -serviceability/sa/ClhsdbThread.java 8307393 generic-all -serviceability/sa/ClhsdbThreadContext.java 8307393 generic-all -serviceability/sa/ClhsdbVmStructsDump.java 8307393 generic-all -serviceability/sa/ClhsdbWhere.java 8307393 generic-all -serviceability/sa/DeadlockDetectionTest.java 8307393 generic-all -serviceability/sa/JhsdbThreadInfoTest.java 8307393 generic-all -serviceability/sa/TestClassDump.java 8307393 generic-all -serviceability/sa/TestClhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestCpoolForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestDefaultMethods.java 8307393 generic-all -serviceability/sa/TestG1HeapRegion.java 8307393 generic-all -serviceability/sa/TestHeapDumpForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSize.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSizeForInterface.java 8307393 generic-all -serviceability/sa/TestIntConstant.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLineNumbers.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackMixed.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackPrintVMLocks.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackUpcall.java 8307393 generic-all -serviceability/sa/TestJmapCore.java 8307393 generic-all -serviceability/sa/TestJmapCoreMetaspace.java 8307393 generic-all -serviceability/sa/TestObjectAlignment.java 8307393 generic-all -serviceability/sa/TestObjectMonitorIterate.java 8307393 generic-all -serviceability/sa/TestPrintMdo.java 8307393 generic-all -serviceability/sa/TestRevPtrsForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestSysProps.java 8307393 generic-all -serviceability/sa/TestType.java 8307393 generic-all -serviceability/sa/UniqueVtableTest.java 8307393 generic-all -serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java 8307393 generic-all -serviceability/sa/ClhsdbTestAllocationMerge.java 8307393 generic-all -serviceability/sa/sadebugd/DebugdConnectTest.java 8307393 generic-all -serviceability/sa/sadebugd/DisableRegistryTest.java 8307393 generic-all -serviceability/sa/sadebugd/PmapOnDebugdTest.java 8307393 generic-all -serviceability/sa/sadebugd/RunCommandOnServerTest.java 8307393 generic-all -serviceability/sa/sadebugd/SADebugDTest.java 8307393 generic-all vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 3e4814180f6..3b871d9f4b6 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -59,6 +59,10 @@ compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-all compiler/vectorapi/reshape/TestVectorReinterpret.java 8320897,8348519 aix-ppc64,linux-ppc64le,linux-s390x compiler/vectorapi/VectorRebracket128Test.java 8330538 generic-all +compiler/vectorization/TestVectorAlgorithms.java#noSuperWord 8376803 aix-ppc64,linux-s390x +compiler/vectorization/TestVectorAlgorithms.java#vanilla 8376803 aix-ppc64,linux-s390x +compiler/vectorization/TestVectorAlgorithms.java#noOptimizeFill 8376803 aix-ppc64,linux-s390x + compiler/jvmci/TestUncaughtErrorInCompileMethod.java 8309073 generic-all compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 8331704 linux-riscv64 compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java 8331704 linux-riscv64 @@ -74,10 +78,11 @@ compiler/floatingpoint/TestSubnormalDouble.java 8317810 generic-i586 compiler/codecache/CodeCacheFullCountTest.java 8332954 generic-all compiler/interpreter/Test6833129.java 8335266 generic-i586 +compiler/intrinsics/TestReturnOopSetForJFRWriteCheckpoint.java 8286300 linux-s390x compiler/c2/aarch64/TestStaticCallStub.java 8359963 linux-aarch64,macosx-aarch64 -compiler/longcountedloops/TestLoopNestTooManyTraps.java 8376591 generic-all +compiler/unsafe/AlignmentGapAccess.java 8373487 generic-all ############################################################################# @@ -92,9 +97,6 @@ gc/TestAllocHumongousFragment.java#g1 8298781 generic-all gc/TestAllocHumongousFragment.java#static 8298781 generic-all gc/shenandoah/oom/TestAllocOutOfMemory.java#large 8344312 linux-ppc64le gc/shenandoah/TestEvilSyncBug.java#generational 8345501 generic-all -gc/shenandoah/TestRetainObjects.java#no-tlab 8361099 generic-all -gc/shenandoah/TestSieveObjects.java#no-tlab 8361099 generic-all -gc/shenandoah/TestSieveObjects.java#no-tlab-genshen 8361099 generic-all ############################################################################# @@ -112,11 +114,11 @@ runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le runtime/NMT/VirtualAllocCommitMerge.java 8309698 linux-s390x +applications/ctw/modules/jdk_jfr.java 8286300 linux-s390x applications/jcstress/copy.java 8229852 linux-all -containers/docker/TestJcmd.java 8278102 linux-all containers/docker/TestJFREvents.java 8327723 linux-x64 -containers/docker/TestJcmdWithSideCar.java 8341518 linux-x64 +containers/docker/TestJcmdWithSideCar.java 8341518 linux-all ############################################################################# @@ -195,4 +197,3 @@ vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find006/Test # in either implementation or test code. ############################################################################# - diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index d1c72b9768c..892529b966f 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -69,7 +69,6 @@ requires.properties= \ vm.gc.Z \ vm.jvmci \ vm.jvmci.enabled \ - vm.emulatedClient \ vm.cpu.features \ vm.pageSize \ vm.debug \ @@ -113,8 +112,3 @@ requiredVersion=8.2.1+1 # does not need ../../../ notation to reach them external.lib.roots = ../../../ -# Use new module options -useNewOptions=true - -# Use --patch-module instead of -Xmodule: -useNewPatchModule=true diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 32cff812975..6e9421e5c09 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -458,6 +458,7 @@ hotspot_appcds_dynamic = \ -runtime/cds/appcds/TestEpsilonGCWithCDS.java \ -runtime/cds/appcds/TestParallelGCWithCDS.java \ -runtime/cds/appcds/TestSerialGCWithCDS.java \ + -runtime/cds/appcds/TestZGCWithAOTHeap.java \ -runtime/cds/appcds/TestZGCWithCDS.java \ -runtime/cds/appcds/UnusedCPDuringDump.java \ -runtime/cds/appcds/VerifierTest_1B.java diff --git a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java index cf8000b7a21..10be61e98ec 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java @@ -52,7 +52,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU { private static final String UNLOCK_DIAGNOSTIC = "-XX:+UnlockDiagnosticVMOptions"; public static void main(String[] args) throws Throwable { - if (!IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE.getAsBoolean()) { + if (!IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE.getAsBoolean()) { throw new SkippedException("Skipping... SHA3 intrinsics are not available on this platform."); } @@ -111,7 +111,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU { private static void testWarningWhenEnablingWithUseSHADisabled() throws Throwable { // A warning should be printed when trying to enable UseSHA3Intrinsics with -UseSHA CommandLineOptionTest.verifySameJVMStartup( - new String[] { WARNING_MESSAGE }, // Warning should appear + new String[] { "warning" }, // Warning should appear null, // No unexpected output "JVM should start successfully", String.format("A warning should be printed when trying to enable %s while %s is disabled", diff --git a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java index 1e0df1874b6..ebada79c877 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java +++ b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java @@ -51,7 +51,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU { private static final String UNLOCK_DIAGNOSTIC = "-XX:+UnlockDiagnosticVMOptions"; public static void main(String[] args) throws Throwable { - if (IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE.getAsBoolean()) { + if (IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE.getAsBoolean()) { throw new SkippedException("Skipping... SHA3 intrinsics are available on this platform."); } diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java index 839ff6cf36e..9e920a08b0f 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java @@ -25,7 +25,7 @@ * @test * @bug 8072016 * @summary Infinite deoptimization/recompilation cycles in case of arraycopy with tightly coupled allocation - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management @@ -87,8 +87,8 @@ public class TestArrayCopyNoInitDeopt { } static public void main(String[] args) throws Exception { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } // Only execute if C2 is available if (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2.java b/test/hotspot/jtreg/compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2.java index 7f5a891ce9e..c7554dcffdb 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2.java @@ -27,7 +27,7 @@ * @summary C2: Access to [].clone from interfaces fails. * @library /test/lib / * - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xcomp -Xbatch -Xbootclasspath/a:. -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestObjectArrayClone.java b/test/hotspot/jtreg/compiler/arraycopy/TestObjectArrayClone.java index b7e5b135c64..595205055ee 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestObjectArrayClone.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestObjectArrayClone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,10 +34,6 @@ * @run main/othervm -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone* * -XX:CompileCommand=compileonly,jdk.internal.reflect.GeneratedMethodAccessor*::invoke * compiler.arraycopy.TestObjectArrayClone - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedClassPointers -Xmx128m - * -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone* - * -XX:CompileCommand=compileonly,jdk.internal.reflect.GeneratedMethodAccessor*::invoke - * compiler.arraycopy.TestObjectArrayClone * @run main/othervm -Xbatch -XX:-UseTypeProfile * -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone* * -XX:CompileCommand=compileonly,jdk.internal.reflect.GeneratedMethodAccessor*::invoke diff --git a/test/hotspot/jtreg/compiler/c1/TestArrayCopyToFromObject.java b/test/hotspot/jtreg/compiler/c1/TestArrayCopyToFromObject.java index 98c8c24dd3a..176226806a6 100644 --- a/test/hotspot/jtreg/compiler/c1/TestArrayCopyToFromObject.java +++ b/test/hotspot/jtreg/compiler/c1/TestArrayCopyToFromObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 @@ * @test * @bug 8160591 * @summary C1-generated code for System.arraycopy() does not throw an ArrayStoreException if 'dst' is no a "proper" array (i.e., it is java.lang.Object) - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:-UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject::test TestArrayCopyToFromObject - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:+UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject::test TestArrayCopyToFromObject + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:CompileOnly=TestArrayCopyToFromObject::test TestArrayCopyToFromObject */ public class TestArrayCopyToFromObject { diff --git a/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyle.java b/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyle.java new file mode 100644 index 00000000000..53763302f90 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyle.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2026 IBM Corporation. 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 8379180 + * @summary test AllocatePrefetchStyle + * + * @run main/othervm -Xbatch -XX:AllocatePrefetchStyle=2 compiler.c2.TestAllocatePrefetchStyle + * @run main/othervm -Xbatch -XX:AllocatePrefetchStyle=3 compiler.c2.TestAllocatePrefetchStyle + */ +package compiler.c2; + +public class TestAllocatePrefetchStyle { + public static void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + test(); + } + } + + private static int[] test() { + return new int[10]; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyleLargeFlags.java b/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyleLargeFlags.java new file mode 100644 index 00000000000..b455107d5f6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestAllocatePrefetchStyleLargeFlags.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2026, 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 + * @summary Stress allocation prefetch with large legal AllocatePrefetch* values + * @requires vm.compiler2.enabled + * + * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+UseTLAB + * -XX:AllocatePrefetchStyle=1 + * -XX:AllocatePrefetchDistance=512 + * -XX:AllocatePrefetchStepSize=512 + * -XX:AllocatePrefetchLines=64 + * -XX:AllocateInstancePrefetchLines=64 + * compiler.c2.TestAllocatePrefetchStyleLargeFlags + * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+UseTLAB + * -XX:AllocatePrefetchStyle=2 + * -XX:AllocatePrefetchDistance=512 + * -XX:AllocatePrefetchStepSize=512 + * -XX:AllocatePrefetchLines=64 + * -XX:AllocateInstancePrefetchLines=64 + * compiler.c2.TestAllocatePrefetchStyleLargeFlags + * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+UseTLAB + * -XX:AllocatePrefetchStyle=3 + * -XX:AllocatePrefetchDistance=512 + * -XX:AllocatePrefetchStepSize=512 + * -XX:AllocatePrefetchLines=64 + * -XX:AllocateInstancePrefetchLines=64 + * compiler.c2.TestAllocatePrefetchStyleLargeFlags + */ + +package compiler.c2; + +public class TestAllocatePrefetchStyleLargeFlags { + private static volatile Object sink; + + private static final class Payload { + private final int value; + + private Payload(int value) { + this.value = value; + } + } + + private static Object allocateInstance(int value) { + return new Payload(value); + } + + private static Object allocateArray(int value) { + return new int[value & 31]; + } + + public static void main(String[] args) { + for (int i = 0; i < 50_000; i++) { + sink = allocateInstance(i); + sink = allocateArray(i); + } + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestDependsOnTestSqrtHFAssertion.java b/test/hotspot/jtreg/compiler/c2/TestDependsOnTestSqrtHFAssertion.java new file mode 100644 index 00000000000..5ad9a927097 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestDependsOnTestSqrtHFAssertion.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2026, 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 8378897 + * @summary assertion failure due to missing depends_only_on_test_impl definition in SqrtHFNode + * @library /test/lib / + * @modules jdk.incubator.vector + * @requires vm.debug & vm.compiler2.enabled + * @run main/othervm --add-modules=jdk.incubator.vector compiler.c2.TestDependsOnTestSqrtHFAssertion + */ + +package compiler.c2; + +import jdk.incubator.vector.*; + +public class TestDependsOnTestSqrtHFAssertion { + public static int x1 = 10; + + public static int x2 = 20; + + public static int y = 30; + + public static int micro(int x1, int x2, int y, int ctr) { + int res = 0; + for (int i = 0; i < ctr; i++) { + if (y != 0) { + if (x1 > 0) { + if (x2 > 0) { + if (y != 0) { + res += (int)Float16.float16ToRawShortBits(Float16.sqrt(Float16.shortBitsToFloat16((short)(x1/y)))); + res += (int)Float16.float16ToRawShortBits(Float16.sqrt(Float16.shortBitsToFloat16((short)(x2/y)))); + } + } + } + } + } + return res; + } + + public static void main(String [] args) { + int res = 0; + for (int i = 0 ; i < 100000; i++) { + res += micro(x1, x2, y, i); + } + IO.println("PASS" + res); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java b/test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java index a7e90353f90..6b93f00cdb1 100644 --- a/test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java +++ b/test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, Arm Limited. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +31,7 @@ import java.util.Random; /* * @test - * @bug 8294816 + * @bug 8294816 8342095 * @key randomness * @summary Test Math.min/max vectorization miscompilation for integer subwords * @library /test/lib / @@ -58,11 +59,11 @@ public class TestMinMaxSubword { } } - // Ensure vector max/min instructions are not generated for integer subword types - // as Java APIs for Math.min/max do not support integer subword types and superword - // should not generate vectorized Min/Max nodes for them. + // Ensure that casts to/from subword types are emitted, as java APIs for Math.min/max do not support integer subword + // types and superword should generate int versions and then cast between them. + @Test - @IR(failOn = {IRNode.MIN_VI, IRNode.MIN_VF, IRNode.MIN_VD}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public static void testMinShort() { for (int i = 0; i < LENGTH; i++) { sb[i] = (short) Math.min(sa[i], val); @@ -78,7 +79,7 @@ public class TestMinMaxSubword { } @Test - @IR(failOn = {IRNode.MAX_VI, IRNode.MAX_VF, IRNode.MAX_VD}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public static void testMaxShort() { for (int i = 0; i < LENGTH; i++) { sb[i] = (short) Math.max(sa[i], val); @@ -93,7 +94,7 @@ public class TestMinMaxSubword { } @Test - @IR(failOn = {IRNode.MIN_VI, IRNode.MIN_VF, IRNode.MIN_VD}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", ">0" }) public static void testMinByte() { for (int i = 0; i < LENGTH; i++) { bb[i] = (byte) Math.min(ba[i], val); @@ -109,7 +110,7 @@ public class TestMinMaxSubword { } @Test - @IR(failOn = {IRNode.MAX_VI, IRNode.MAX_VF, IRNode.MAX_VD}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", ">0" }) public static void testMaxByte() { for (int i = 0; i < LENGTH; i++) { bb[i] = (byte) Math.max(ba[i], val); diff --git a/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndHeapDump.java b/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndHeapDump.java index 9319da0e0b9..f65643f8d87 100644 --- a/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndHeapDump.java +++ b/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndHeapDump.java @@ -26,7 +26,7 @@ * @bug 8319784 * @summary Check that the JVM is able to dump the heap even when there are ReduceAllocationMerge in the scope. * @library /test/lib / - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @run main/othervm compiler.c2.TestReduceAllocationAndHeapDump */ diff --git a/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndLoadKlass.java b/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndLoadKlass.java deleted file mode 100644 index a8997535aae..00000000000 --- a/test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndLoadKlass.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024, 2025, 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 8330795 - * @summary Check that Reduce Allocation Merges doesn't crash when CompressedClassPointers - * is disabled and there is an access to Klass "field" through the phi. - * @requires vm.bits == 64 & vm.flagless & vm.compiler2.enabled & vm.opt.final.EliminateAllocations - * @run main/othervm -XX:CompileCommand=dontinline,*TestReduceAllocationAndLoadKlass*::test - * -XX:CompileCommand=compileonly,*TestReduceAllocationAndLoadKlass*::test - * -XX:CompileCommand=compileonly,*Shape*::*init* - * -XX:CompileCommand=compileonly,*Point*::*init* - * -XX:CompileCommand=exclude,*TestReduceAllocationAndLoadKlass*::dummy - * -XX:-TieredCompilation - * -XX:-UseCompressedClassPointers - * -Xbatch - * -Xcomp - * compiler.c2.TestReduceAllocationAndLoadKlass - */ - -package compiler.c2; - -public class TestReduceAllocationAndLoadKlass { - public static void main(String[] args) { - Point p = new Point(); - Line q = new Line(); - - test(true); - test(false); - } - - static Class test(boolean cond) { - Object p = cond ? dummy() : new Line(); - return p.getClass(); - } - - static Point dummy() { return new Point(); } - - static class Shape { } - static class Point extends Shape { } - static class Line extends Shape { } -} diff --git a/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java b/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java new file mode 100644 index 00000000000..adbfa537aed --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java @@ -0,0 +1,99 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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 8366138 + * @summary C2: jump_switch_ranges could cause stack overflow when compiling + * huge switch statement with zero-count profiling data. + * @library /test/lib / + * @run main/othervm ${test.main.class} + * @run main/othervm -Xbatch -XX:CompileOnly=Test::test -XX:-DontCompileHugeMethods -XX:CompilerThreadStackSize=512 ${test.main.class} + * @run main/othervm -Xbatch -XX:CompileOnly=Test::test -XX:+DontCompileHugeMethods -XX:CompilerThreadStackSize=512 ${test.main.class} + */ + +package compiler.c2; + +import java.util.stream.Stream; + +import compiler.lib.compile_framework.CompileFramework; +import compiler.lib.template_framework.Template; +import static compiler.lib.template_framework.Template.scope; + +public class TestSwitchStackOverflow { + // Template method exceeds HugeMethodLimit, hence -XX:-DontCompileHugeMethods. + // 5000 cases + CompilerThreadStackSize=512 reliably overflows without the fix. + static final int NUM_CASES = 5000; + + // Generate a class with a large tableswitch method and a main that + // triggers recompilation with zero-count profiling data: + // Phase 1: warm up with default-only path -> C2 compiles + // Phase 2: hit a case -> triggers unstable_if deopt + // Phase 3: recompile with all counts zero (except the default case) + static String generate() { + var caseTemplate = Template.make("i", (Integer i) -> scope( + """ + case #i: + return #i; + """ + )); + var test = Template.make(() -> scope( + """ + public class Test { + static int test(int x) { + switch (x) { + """, + Stream.iterate(0, i -> i + 1) + .limit(NUM_CASES) + .map(i -> caseTemplate.asToken(i)) + .toList(), + """ + default: return -1; + } + } + + public static void main(String[] args) { + for (int i = 0; i < 10_000; i++) { + test(-1); + } + test(42); + for (int i = 0; i < 10_000; i++) { + test(-1); + } + System.out.println("Done"); + } + } + """ + )); + + return test.render(); + } + + public static void main(String[] args) { + CompileFramework comp = new CompileFramework(); + comp.addJavaSourceCode("Test", generate()); + comp.compile(); + comp.invoke("Test", "main", new Object[] { new String[0] }); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/gvn/CmpUNodeValueTests.java b/test/hotspot/jtreg/compiler/c2/gvn/CmpUNodeValueTests.java index cbcbda3422f..2df74e52971 100644 --- a/test/hotspot/jtreg/compiler/c2/gvn/CmpUNodeValueTests.java +++ b/test/hotspot/jtreg/compiler/c2/gvn/CmpUNodeValueTests.java @@ -99,7 +99,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, counts = {IRNode.CMP_U, "1"}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, counts = {IRNode.CMP_U, "1"}) int testIntControl(boolean b1, boolean b2) { int v1 = b1 ? 1 : -1; int v2 = b2 ? 1 : 0; @@ -107,7 +107,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntLT(int x) { int v1 = x & Integer.MAX_VALUE; // Unset the highest bit, make v1 non-negative int v2 = Integer.MIN_VALUE; @@ -115,7 +115,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntLE(boolean b1, boolean b2) { int v1 = b1 ? 2 : 0; int v2 = b2 ? -1 : 2; @@ -123,7 +123,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntGT(boolean b1, boolean b2) { int v1 = b1 ? Integer.MIN_VALUE : Integer.MAX_VALUE; int v2 = b2 ? 0 : 2; @@ -131,7 +131,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntGE(int x, int y) { int v1 = x | Integer.MIN_VALUE; // Set the highest bit, make v1 negative int v2 = y & Integer.MAX_VALUE; // Unset the highest bit, make v2 non-negative @@ -139,13 +139,13 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntEQ() { return Integer.compareUnsigned(oneInline(), 1) == 0 ? 0 : one(); } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_U, IRNode.CALL}) int testIntNE(boolean b1, boolean b2) { int v1 = b1 ? 1 : -1; int v2 = b2 ? 0 : 2; @@ -153,7 +153,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, counts = {IRNode.CMP_UL, "1"}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, counts = {IRNode.CMP_UL, "1"}) int testLongControl(boolean b1, boolean b2) { long v1 = b1 ? 1 : -1; long v2 = b2 ? 1 : 0; @@ -162,7 +162,7 @@ public class CmpUNodeValueTests { @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongLT(int x, boolean b2) { long v1 = Integer.toUnsignedLong(x); long v2 = Integer.MIN_VALUE; @@ -170,7 +170,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongLE(boolean b1, boolean b2) { long v1 = b1 ? 2 : 0; long v2 = b2 ? -1 : 2; @@ -178,7 +178,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongGT(boolean b1, boolean b2) { long v1 = b1 ? Long.MIN_VALUE : Long.MAX_VALUE; long v2 = b2 ? 0 : 2; @@ -186,7 +186,7 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongGE(int x, int y) { long v1 = x | Long.MIN_VALUE; // Set the highest bit, make v1 negative long v2 = y & Long.MAX_VALUE; // Unset the highest bit, make v2 non-negative @@ -194,13 +194,13 @@ public class CmpUNodeValueTests { } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongEQ() { return Long.compareUnsigned(oneInline(), 1L) == 0 ? 0 : one(); } @Test - @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) + @IR(applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, failOn = {IRNode.CMP_UL, IRNode.CALL}) int testLongNE(boolean b1, boolean b2) { long v1 = b1 ? 1 : -1; long v2 = b2 ? 0 : 2; diff --git a/test/hotspot/jtreg/compiler/c2/gvn/MissedRShiftLShiftIdentity.java b/test/hotspot/jtreg/compiler/c2/gvn/MissedRShiftLShiftIdentity.java new file mode 100644 index 00000000000..9f8eaab514f --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/gvn/MissedRShiftLShiftIdentity.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.gvn; + +/* + * @test + * @bug 8374798 + * @summary RShift(LShift(x, C), C) Identity missed when shift counts are different + * constant nodes for the same effective count (e.g. -1 vs 31) due to + * mask_and_replace_shift_amount normalizing them at different times. + * + * @run main ${test.main.class} + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:+StressIGVN -XX:+StressCCP -XX:VerifyIterativeGVN=1000 -Xbatch -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,${test.main.class}::test* ${test.main.class} + */ + +public class MissedRShiftLShiftIdentity { + public static int iFld = 0; + + public static void test() { + int[] iArr = new int[10]; + int i2 = -1, i3 = 0; + + for (int i11 : iArr) { + iFld = i11; + for (int i1 = 0; i1 < 10; i1++) { + iFld <<= i3; + iFld >>= i2; // RShift + i3 = i2; + } + int i16 = 0; + do { + for (int f3 = 1; f3 < 1; f3 += 3) { + i2 = -1; + } + } while (++i16 < 5); + } + } + + public static void main(String[] args) { + test(); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java new file mode 100644 index 00000000000..a953ea3bcca --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.gvn; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; +import java.util.Random; + +/* + * @test + * @bug 8378413 8379544 + * @key randomness + * @summary Verify that URShift{I,L}Node::Ideal optimizes ((x << C) + y) >>> C + * regardless of Add input order, i.e. it is commutative w.r.t. the addition. + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class MissedURShiftIAddILShiftIdeal { + + private static final Random RANDOM = Utils.getRandomInstance(); + + public static void main(String[] args) { + var framework = new TestFramework(); + framework.addScenarios(new Scenario(0)); + if (Platform.isDebugBuild()) { + framework.addScenarios(new Scenario(1, "-XX:+IgnoreUnrecognizedVMOptions", "-XX:VerifyIterativeGVN=1110")); + } + framework.start(); + } + + @Run(test = {"testI", "testICommuted", "testIComputedY", "testIComputedX", + "testL", "testLCommuted", "testLComputedY", "testLComputedX"}) + public void runMethod() { + int xi = RANDOM.nextInt(); + int yi = RANDOM.nextInt(); + int ai = RANDOM.nextInt(); + int bi = RANDOM.nextInt(); + long xl = RANDOM.nextLong(); + long yl = RANDOM.nextLong(); + long al = RANDOM.nextLong(); + long bl = RANDOM.nextLong(); + + assertResultI(xi, yi, ai, bi); + assertResultL(xl, yl, al, bl); + } + + @DontCompile + public void assertResultI(int x, int y, int a, int b) { + Asserts.assertEQ(((x << 3) + y) >>> 3, testI(x, y)); + Asserts.assertEQ((y + (x << 5)) >>> 5, testICommuted(x, y)); + Asserts.assertEQ(((x << 7) + (a ^ b)) >>> 7, testIComputedY(x, a, b)); + Asserts.assertEQ((((a ^ b) << 19) + y) >>> 19, testIComputedX(a, b, y)); + } + + @DontCompile + public void assertResultL(long x, long y, long a, long b) { + Asserts.assertEQ(((x << 9) + y) >>> 9, testL(x, y)); + Asserts.assertEQ((y + (x << 11)) >>> 11, testLCommuted(x, y)); + Asserts.assertEQ(((x << 13) + (a ^ b)) >>> 13, testLComputedY(x, a, b)); + Asserts.assertEQ((((a ^ b) << 19) + y) >>> 19, testLComputedX(a, b, y)); + } + + @Test + // ((x << 3) + y) >>> 3 => (x + (y >>> 3)) & mask + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testI(int x, int y) { + return ((x << 3) + y) >>> 3; + } + + @Test + // (y + (x << 5)) >>> 5 => (x + (y >>> 5)) & mask (commuted Add) + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testICommuted(int x, int y) { + return (y + (x << 5)) >>> 5; + } + + @Test + // ((x << 7) + (a ^ b)) >>> 7 => (x + ((a ^ b) >>> 7)) & mask + // Computed y (a ^ b) has higher _idx than LShift, so LShift stays in Add's in(1). + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testIComputedY(int x, int a, int b) { + return ((x << 7) + (a ^ b)) >>> 7; + } + + @Test + // ((x << 9) + y) >>> 9 => (x + (y >>> 9)) & mask + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testL(long x, long y) { + return ((x << 9) + y) >>> 9; + } + + @Test + // (y + (x << 11)) >>> 11 => (x + (y >>> 11)) & mask (commuted Add) + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testLCommuted(long x, long y) { + return (y + (x << 11)) >>> 11; + } + + @Test + // ((x << 13) + (a ^ b)) >>> 13 => (x + ((a ^ b) >>> 13)) & mask + // Computed y (a ^ b) has higher _idx than LShift, so LShift stays in Add's in(1). + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testLComputedY(long x, long a, long b) { + return ((x << 13) + (a ^ b)) >>> 13; + } + + @Test + // (((a ^ b) << v) + y) >>> 19 => ((a ^ b) + (y >>> 19)) & mask + // v is only known to be 19 after loop optimization, so LShiftI's shift count + // changes mid-IGVN. URShiftI must be notified through AddI (Case 2). + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testIComputedX(int a, int b, int y) { + int u = 19; + int v = 0; + do { + u--; + v++; + } while (u > 0); + return (((a ^ b) << v) + y) >>> 19; + } + + @Test + // (((a ^ b) << v) + y) >>> 19 => ((a ^ b) + (y >>> 19)) & mask + // v is only known to be 19 after loop optimization, so LShiftL's shift count + // changes mid-IGVN. URShiftL must be notified through AddL (Case 2). + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testLComputedX(long a, long b, long y) { + int u = 19; + int v = 0; + do { + u--; + v++; + } while (u > 0); + return (((a ^ b) << v) + y) >>> 19; + } + +} diff --git a/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftLShiftIdeal.java b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftLShiftIdeal.java new file mode 100644 index 00000000000..774b218b1ca --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftLShiftIdeal.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.gvn; + +/* + * @test + * @bug 8374798 8377389 + * @summary URShift(LShift(x, C), C) Ideal optimization missed due to missing IGVN notification: + * when LShift inputs change, its URShift users were not re-queued for the + * (X << C) >>> C -> X & mask optimization. + * + * @run main ${test.main.class} + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:+StressIGVN -XX:+StressCCP -XX:VerifyIterativeGVN=0100 -Xbatch -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,${test.main.class}::test* ${test.main.class} + */ + +public class MissedURShiftLShiftIdeal { + public static int iFld = 0; + + public static void test() { + int[] iArr = new int[10]; + int i2 = -1, i3 = 0; + + for (int i11 : iArr) { + iFld = i11; + for (int i1 = 0; i1 < 10; i1++) { + iFld <<= i3; + iFld >>>= i2; // URShift + i3 = i2; + } + int i16 = 0; + do { + for (int f3 = 1; f3 < 1; f3 += 3) { + i2 = -1; + } + } while (++i16 < 5); + } + } + + public static void main(String[] args) { + test(); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/gvn/TestFindStore.java b/test/hotspot/jtreg/compiler/c2/gvn/TestFindStore.java new file mode 100644 index 00000000000..aac3e0cf980 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/gvn/TestFindStore.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.gvn; + +import compiler.lib.ir_framework.*; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.Asserts; + +/* + * @test + * @bug 8376220 + * @summary Tests that memory accesses can be elided when the compiler can see the value at the + * accessed memory location by walking the memory graph. + * @modules java.base/jdk.internal.misc + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class TestFindStore { + private static final Unsafe U = Unsafe.getUnsafe(); + + static class P { + int v; + int u; + } + + static final long V_OFFSET = U.objectFieldOffset(P.class, "v"); + static final long U_OFFSET = U.objectFieldOffset(P.class, "u"); + + static class C1 extends P {} + static class C2 extends P {} + + public static void main(String[] args) { + TestFramework.runWithFlags("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + } + + @Run(test = {"testLoad", "testStore", "testLoadDependent1", "testLoadDependent2", "testLoadArray", + "testLoadArrayOverlap", "testLoadIndependentAliasClasses", "testLoadMismatched", + "testLoadArrayCopy", "testLoadArrayCopyUnknownLength"}) + public void run() { + C1 c1 = new C1(); + C2 c2 = new C2(); + int[] a1 = new int[1000]; + int[] a2 = new int[1000]; + + Asserts.assertEQ(0, testLoad(c1, c2, 0, 1)); + Asserts.assertEQ(0, testStore(c2, 0).v); + Asserts.assertEQ(0, testLoadDependent1(c1, c1, 0, 1)); + Asserts.assertEQ(1, testLoadDependent1(c2, c1, 0, 1)); + Asserts.assertEQ(1, testLoadDependent2(c1, c1, 0, 1)); + Asserts.assertEQ(0, testLoadDependent2(c2, c1, 0, 1)); + + Asserts.assertEQ(0, testLoadArray(a1, a2, 0, 1)); + Asserts.assertEQ(0, testLoadArrayOverlap(a1, a2, 2, 0, 1)); + Asserts.assertEQ(0, testLoadArrayOverlap(a1, a1, 0, 0, 1)); + Asserts.assertEQ(1, testLoadArrayOverlap(a1, a1, 2, 0, 1)); + Asserts.assertEQ(0, testLoadIndependentAliasClasses(c1, 0, 1)); + Asserts.assertNE(0, testLoadMismatched(c1, 0, -1)); + Asserts.assertEQ(1, testLoadArrayCopy(a1, a2, 1)); + + a1[2] = 0; + Asserts.assertEQ(1, testLoadArrayCopyUnknownLength(a1, a2, 100, 1)); + a1[2] = 0; + Asserts.assertEQ(0, testLoadArrayCopyUnknownLength(a1, a2, 2, 1)); + } + + @Test + @IR(failOn = IRNode.LOAD) + static int testLoad(C1 c1, C2 c2, int v1, int v2) { + // c1 and c2 are provably independent + c1.v = v1; + c2.v = v2; + return c1.v; + } + + @Test + @IR(counts = {IRNode.STORE, "1"}, phase = CompilePhase.BEFORE_MACRO_EXPANSION) + static C1 testStore(C2 c2, int v2) { + C1 c1 = new C1(); + c2.v = v2; + c1.v = 0; + return c1; + } + + @Test + @IR(counts = {IRNode.LOAD, "1"}) + static int testLoadDependent1(P p, C1 c1, int v, int v1) { + // It cannot be proved that p and c1 are independent + c1.v = v1; + p.v = v; + return c1.v; + } + + @Test + @IR(counts = {IRNode.LOAD, "1"}) + static int testLoadDependent2(P p, C1 c1, int v, int v1) { + // It cannot be proved that p and c1 are independent + p.v = v; + c1.v = v1; + return p.v; + } + + @Test + @IR(failOn = IRNode.LOAD) + static int testLoadArray(int[] a1, int[] a2, int v1, int v2) { + // a1[2] and a2[1] are provably independent + a1[2] = v1; + a2[1] = v2; + return a1[2]; + } + + @Test + @IR(counts = {IRNode.LOAD, "1"}) + static int testLoadArrayOverlap(int[] a1, int[] a2, int idx, int v1, int v2) { + // Cannot prove that a1[2] and a2[idx] are independent + a1[2] = v1; + a2[idx] = v2; + return a1[2]; + } + + @Test + @IR(failOn = IRNode.LOAD) + static int testLoadIndependentAliasClasses(P p, int v, int u) { + p.v = v; + p.u = u; + return p.v; + } + + @Test + @IR(counts = {IRNode.LOAD, "1"}) + static int testLoadMismatched(P p, int v1, int v2) { + p.v = v1; + U.putIntUnaligned(p, (V_OFFSET + U_OFFSET) / 2, v2); + return p.v; + } + + @Test + @IR(failOn = IRNode.LOAD, applyIf = {"ArrayCopyLoadStoreMaxElem", "<100"}) + static int testLoadArrayCopy(int[] a1, int[] a2, int v) { + a2[2] = v; + // Should be large so the compiler does not just transform it into a couple of loads and stores + System.arraycopy(a2, 0, a1, 0, 100); + return a1[2]; + } + + @Test + @IR(counts = {IRNode.LOAD, "1"}) + static int testLoadArrayCopyUnknownLength(int[] a1, int[] a2, int len, int v) { + a2[2] = v; + // Cannot determine if this overwrites a1[2] + System.arraycopy(a2, 0, a1, 0, len); + return a1[2]; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/igvn/TestIdealReturnReplaceShiftAmount.java b/test/hotspot/jtreg/compiler/c2/igvn/TestIdealReturnReplaceShiftAmount.java new file mode 100644 index 00000000000..589da988606 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/igvn/TestIdealReturnReplaceShiftAmount.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.igvn; + +/* + * @test + * @bug 8373251 + * @summary In Ideal of shift nodes, we call mask_and_replace_shift_amount to reduce the + * shift amount. We need to make sure that Ideal returns something if this is + * the only modification taking place. Use -XX:VerifyIterativeGVN=100000 to + * verify the return value of Ideal if the hash has changed. + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -Xcomp -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,${test.main.class}::test* + * -XX:VerifyIterativeGVN=100000 + * ${test.main.class} + * @run main ${test.main.class} + * + */ + +public class TestIdealReturnReplaceShiftAmount { + static long lFld; + static int iFld; + + static void testLShiftI() { + // we need the loop so that the shift amount replacement happens + // during IGVN and not directly at parsing + for (int i = 0; i < 5; i++) { + iFld <<= (i + 32); + } + } + + static void testLShiftL() { + for (int i = 0; i < 5; i++) { + lFld <<= (i + 64); + } + } + + static void testRShiftI() { + for (int i = 0; i < 5; i++) { + iFld >>= (i + 32); + } + } + + static void testRShiftL() { + for (int i = 0; i < 5; i++) { + lFld >>= (i + 64); + } + } + + static void testURShiftI() { + for (int i = 0; i < 5; i++) { + iFld >>>= (i + 32); + } + } + + static void testURShiftL() { + for (int i = 0; i < 5; i++) { + lFld >>>= (i + 64); + } + } + + public static void main(String[] args) { + testLShiftI(); + testLShiftL(); + testRShiftI(); + testRShiftL(); + testURShiftI(); + testURShiftL(); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/igvn/TestMissingAddSubElimination.java b/test/hotspot/jtreg/compiler/c2/igvn/TestMissingAddSubElimination.java new file mode 100644 index 00000000000..1679e131505 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/igvn/TestMissingAddSubElimination.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.igvn; + +import compiler.lib.ir_framework.*; +import java.util.Random; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + +/* + * @test + * @bug 8373731 + * @summary C2 IGVN should eliminate a + (b - c) after c = a * i folds to a, + * i.e. a + (b - a) -> b + * @library /test/lib / + * @run driver ${test.main.class} + */ + +public class TestMissingAddSubElimination { + private static final Random R = Utils.getRandomInstance(); + + public static void main(String[] args) { + TestFramework.runWithFlags("-XX:+IgnoreUnrecognizedVMOptions", + "-XX:VerifyIterativeGVN=1000", + "-XX:CompileCommand=compileonly,compiler.c2.igvn.TestMissingAddSubElimination::*"); + } + + @Run(test = {"testAddI1", "testAddI2", "testAddL1", "testAddL2"}) + public void runTestAdd(){ + int x = R.nextInt(); + int y = R.nextInt(); + Asserts.assertEQ(testAddI1(x, y), y); + Asserts.assertEQ(testAddI2(x, y), x); + + long xl = R.nextLong(); + long yl = R.nextLong(); + Asserts.assertEQ(testAddL1(xl, yl), yl); + Asserts.assertEQ(testAddL2(xl, yl), xl); + } + + // int: x + (y - x) -> y + @Test + @IR(counts = { + IRNode.ADD_I, "0", + IRNode.SUB_I, "0", + IRNode.MUL_I, "0" + }) + int testAddI1(int x, int y) { + int i; + for (i = -10; i < 1; i++) { } + int c = x * i; + return x + (y - c); + } + + // int: (x - y) + y -> x + @Test + @IR(counts = { + IRNode.ADD_I, "0", + IRNode.SUB_I, "0", + IRNode.MUL_I, "0" + }) + int testAddI2(int x, int y) { + int i; + for (i = -10; i < 1; i++) { } + int c = y * i; + return (x - c) + y; + } + + // long: x + (y - x) -> y + @Test + @IR(counts = { + IRNode.ADD_L, "0", + IRNode.SUB_L, "0", + IRNode.MUL_L, "0" + }) + long testAddL1(long x, long y) { + int i; + for (i = -10; i < 1; i++) { } + long c = x * i; + return x + (y - c); + } + + // long: (x - y) + y -> x + @Test + @IR(counts = { + IRNode.ADD_L, "0", + IRNode.SUB_L, "0", + IRNode.MUL_L, "0" + }) + long testAddL2(long x, long y) { + int i; + for (i = -10; i < 1; i++) { } + long c = y * i; + return (x - c) + y; + } +} \ No newline at end of file diff --git a/test/hotspot/jtreg/compiler/c2/igvn/TestMissingOptReplaceShiftAmount.java b/test/hotspot/jtreg/compiler/c2/igvn/TestMissingOptReplaceShiftAmount.java new file mode 100644 index 00000000000..a2d6505c311 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/igvn/TestMissingOptReplaceShiftAmount.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.igvn; + +/* + * @test + * @bug 8373251 + * @summary In Ideal of shift nodes, we call mask_and_replace_shift_amount to reduce the + * shift amount. We need to make sure that the updates are propagated if this is + * the only modification taking place. Use -XX:VerifyIterativeGVN=1110 to + * catch missing optimizations. + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -Xcomp -XX:-TieredCompilation + * -XX:+StressIGVN -XX:StressSeed=342568167 + * -XX:CompileCommand=compileonly,${test.main.class}::test* + * -XX:VerifyIterativeGVN=1110 + * ${test.main.class} + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -Xcomp -XX:-TieredCompilation + * -XX:+StressIGVN + * -XX:CompileCommand=compileonly,${test.main.class}::test* + * -XX:VerifyIterativeGVN=1110 + * ${test.main.class} + * @run main ${test.main.class} + */ + +public class TestMissingOptReplaceShiftAmount { + static long lFld; + static boolean flag; + + static void test() { + int x = 67; + for (int i = 0; i < 20; i++) { + if (flag) { + x = 0; + } + lFld <<= x; + lFld >>>= x; + } + } + + public static void main(String[] args) { + test(); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/igvn/TestURShiftAddNotification.java b/test/hotspot/jtreg/compiler/c2/igvn/TestURShiftAddNotification.java new file mode 100644 index 00000000000..8ca192ea38b --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/igvn/TestURShiftAddNotification.java @@ -0,0 +1,89 @@ +/* + * Copyright Amazon.com Inc. 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 compiler.c2.igvn; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; +import java.util.Random; + +/* + * @test + * @bug 8379460 + * @key randomness + * @summary When AddI/AddL inputs change during IGVN, URShift users must be re-added + * to the IGVN worklist so they can re-check the ((X << z) + Y) >>> z optimization. + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class TestURShiftAddNotification { + + private static final Random RANDOM = Utils.getRandomInstance(); + + public static void main(String[] args) { + var framework = new TestFramework(); + framework.addScenarios(new Scenario(0)); + if (Platform.isDebugBuild()) { + framework.addScenarios(new Scenario(1, "-XX:VerifyIterativeGVN=1110")); + } + framework.start(); + } + + // The trick: a loop whose exit value is only known after loop optimization. + // During initial GVN, i is a Phi, so (x << C) * i stays as MulI — URShift + // can't see the LShiftI input through the MulI. After loop opts resolve + // i = 1, MulI identity-folds to LShiftI (same type, no cascade), and + // without the fix URShift is never re-notified about the new LShiftI input. + + @Run(test = {"testI", "testL"}) + public void runTests() { + int xi = RANDOM.nextInt(); + int yi = RANDOM.nextInt(); + long xl = RANDOM.nextLong(); + long yl = RANDOM.nextLong(); + + Asserts.assertEQ(((xi << 3) + yi) >>> 3, testI(xi, yi)); + Asserts.assertEQ(((xl << 9) + yl) >>> 9, testL(xl, yl)); + } + + @Test + @IR(failOn = {IRNode.LSHIFT_I, IRNode.MUL_I}, + counts = {IRNode.URSHIFT_I, "1", IRNode.AND_I, "1"}) + static int testI(int x, int y) { + int i; + for (i = -10; i < 1; i++) { } + int c = (x << 3) * i; + return (c + y) >>> 3; + } + + @Test + @IR(failOn = {IRNode.LSHIFT_L, IRNode.MUL_L}, + counts = {IRNode.URSHIFT_L, "1", IRNode.AND_L, "1"}) + static long testL(long x, long y) { + int i; + for (i = -10; i < 1; i++) { } + long c = (x << 9) * i; + return (c + y) >>> 9; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ConvD2FIdealizationStress.java b/test/hotspot/jtreg/compiler/c2/irTests/ConvD2FIdealizationStress.java new file mode 100644 index 00000000000..ac0df25ff86 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/ConvD2FIdealizationStress.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.irTests; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import java.util.Random; +import jdk.test.lib.Utils; + +/* + * @test + * @bug 8375633 + * @key randomness + * @summary Test that ConvD2F::Ideal optimization is not missed with incremental inlining. + * AlwaysIncrementalInline is not required but deterministically defers even + * small methods, making this test reliable. + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class ConvD2FIdealizationStress { + + private static final Random RANDOM = Utils.getRandomInstance(); + + public static void main(String[] args) { + TestFramework.runWithFlags("-XX:-TieredCompilation", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+AlwaysIncrementalInline", + "-XX:VerifyIterativeGVN=1110"); + } + + // Deferred by AlwaysIncrementalInline; ConvF2D appears only after inlining. + static double toDouble(float x) { + return (double) x; + } + + // ConvD2F(SqrtD(ConvF2D(x))) => SqrtF(x) + // Math.sqrt (intrinsic) is expanded at parse time; toDouble is deferred. + @Test + @IR(counts = {IRNode.SQRT_F, ">=1"}, + failOn = {IRNode.CONV_D2F, IRNode.SQRT_D, IRNode.CONV_F2D}) + public static float testSqrtConversion(float x) { + return (float) Math.sqrt(toDouble(x)); + } + + @Run(test = "testSqrtConversion") + public void runSqrtConversion() { + float input = RANDOM.nextFloat(); + checkSqrtConversion(input, testSqrtConversion(input)); + } + + @DontCompile + public void checkSqrtConversion(float input, float result) { + Asserts.assertEQ((float) Math.sqrt(input), result); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ConvF2HFIdealizationStress.java b/test/hotspot/jtreg/compiler/c2/irTests/ConvF2HFIdealizationStress.java new file mode 100644 index 00000000000..941077362d5 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/ConvF2HFIdealizationStress.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2026, 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 compiler.c2.irTests; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import java.util.Random; +import jdk.test.lib.Utils; + +/* + * @test + * @bug 8375633 + * @key randomness + * @summary Test that ConvF2HF::Ideal optimization is not missed with incremental inlining. + * AlwaysIncrementalInline is not required but deterministically defers even + * small methods, making this test reliable. + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class ConvF2HFIdealizationStress { + + private static final Random RANDOM = Utils.getRandomInstance(); + + private short srcBits; + private short twoBits; + private short actualBits; + + public static void main(String[] args) { + TestFramework.runWithFlags("-XX:-TieredCompilation", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+AlwaysIncrementalInline", + "-XX:VerifyIterativeGVN=1110"); + } + + public ConvF2HFIdealizationStress() { + srcBits = Float.floatToFloat16(RANDOM.nextFloat()); + twoBits = Float.floatToFloat16(2.0f); + } + + // Deferred by AlwaysIncrementalInline; ConvHF2F appears only after inlining. + static float toFloat(short hf) { + return Float.float16ToFloat(hf); + } + + // ConvF2HF(MulF(ConvHF2F(a), ConvHF2F(b))) => MulHF(a, b) + // Float.floatToFloat16 (intrinsic) is expanded at parse time; toFloat is deferred. + @Test + @IR(counts = {IRNode.MUL_HF, "1"}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zfh", "true"}, + failOn = {IRNode.CONV_F2HF}) + @IR(counts = {IRNode.MUL_HF, "1"}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}, + failOn = {IRNode.CONV_F2HF}) + public void testMultiply() { + actualBits = Float.floatToFloat16(toFloat(srcBits) * toFloat(twoBits)); + } + + @Check(test = "testMultiply") + public void checkMultiply() { + float twice = Float.float16ToFloat(srcBits) * Float.float16ToFloat(twoBits); + short expected = Float.floatToFloat16(twice); + Asserts.assertEQ(expected, actualBits); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ModDNodeTests.java b/test/hotspot/jtreg/compiler/c2/irTests/ModDNodeTests.java index 6b20b782923..ac427ea3831 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/ModDNodeTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/ModDNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +29,7 @@ import compiler.lib.ir_framework.*; /* * @test - * @bug 8345766 + * @bug 8345766 8378742 * @key randomness * @summary Test that Ideal transformations of ModDNode are being performed as expected. * @library /test/lib / @@ -37,6 +37,7 @@ import compiler.lib.ir_framework.*; */ public class ModDNodeTests { public static final double q = Utils.getRandomInstance().nextDouble() * 100.0d; + public static volatile int volatileField; public static void main(String[] args) { TestFramework.run(); @@ -48,6 +49,7 @@ public class ModDNodeTests { "unusedResultAfterLoopOpt1", "unusedResultAfterLoopOpt2", "unusedResultAfterLoopOpt3", + "constantFoldInCCP" }) public void runMethod() { Asserts.assertEQ(constant(), q % 72.0d % 30.0d); @@ -61,6 +63,7 @@ public class ModDNodeTests { Asserts.assertEQ(unusedResultAfterLoopOpt1(1.1d, 2.2d), 0.d); Asserts.assertEQ(unusedResultAfterLoopOpt2(1.1d, 2.2d), 0.d); Asserts.assertEQ(unusedResultAfterLoopOpt3(1.1d, 2.2d), 0.d); + Asserts.assertEQ(constantFoldInCCP(), 4.0d); } // Note: we used to check for ConD nodes in the IR. But that is a bit brittle: @@ -72,7 +75,7 @@ public class ModDNodeTests { @Test @IR(counts = {IRNode.MOD_D, "2"}, phase = CompilePhase.AFTER_PARSING) - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double constant() { // All constants available during parsing @@ -84,7 +87,7 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "1"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double alsoConstant() { // Make sure value is only available after second loop opts round @@ -102,7 +105,7 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "2"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double nanLeftConstant() { // Make sure value is only available after second loop opts round @@ -120,7 +123,7 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "2"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double nanRightConstant() { // Make sure value is only available after second loop opts round @@ -156,7 +159,7 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "0"}, phase = CompilePhase.ITER_GVN1) // IGVN removes unused nodes - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public void unusedResult(double x, double y) { double unused = x % y; @@ -165,9 +168,9 @@ public class ModDNodeTests { @Test @IR(counts = {IRNode.MOD_D, "1"}, phase = CompilePhase.AFTER_PARSING) - @IR(counts = {IRNode.MOD_D, "0"}, + @IR(failOn = {IRNode.MOD_D}, phase = CompilePhase.ITER_GVN1) // IGVN removes unused nodes - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public void repeatedlyUnused(double x, double y) { double unused = 1.d; @@ -185,9 +188,9 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "1"}, phase = CompilePhase.ITER_GVN2) - @IR(counts = {IRNode.MOD_D, "0"}, + @IR(failOn = {IRNode.MOD_D}, phase = CompilePhase.BEFORE_MACRO_EXPANSION) - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double unusedResultAfterLoopOpt1(double x, double y) { double unused = x % y; @@ -210,9 +213,9 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "1"}, phase = CompilePhase.AFTER_CLOOPS) - @IR(counts = {IRNode.MOD_D, "0"}, + @IR(failOn = {IRNode.MOD_D}, phase = CompilePhase.PHASEIDEALLOOP1) - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double unusedResultAfterLoopOpt2(double x, double y) { int a = 77; @@ -235,9 +238,9 @@ public class ModDNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_D, "2"}, phase = CompilePhase.AFTER_CLOOPS) // drop the useless one - @IR(counts = {IRNode.MOD_D, "0"}, + @IR(failOn = {IRNode.MOD_D}, phase = CompilePhase.PHASEIDEALLOOP1) // drop the rest - @IR(counts = {".*CallLeaf.*drem.*", "0"}, + @IR(failOn = {".*CallLeaf.*drem.*"}, phase = CompilePhase.BEFORE_MATCHING) public double unusedResultAfterLoopOpt3(double x, double y) { double unused = x % y; @@ -252,4 +255,25 @@ public class ModDNodeTests { int other = (b - 77) * (int)(x % y % 1.d); return (double)other; } + + @Test + @IR(failOn = {IRNode.CMP_D}, + phase = CompilePhase.CCP1) + @IR(failOn = {IRNode.MOD_D}, + phase = CompilePhase.BEFORE_MACRO_EXPANSION) + public double constantFoldInCCP(){ + int i; + for (i = 2; i < 4; i *= 2) { + } + int j; + for (j = 2; j < 4; j *= 2) { + } + volatileField = 42; + double v1 = (double) i / 2; + double v2 = j; + double v = v1 % v2; + for (; v < v2; v *= 2) { + } + return v; + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ModFNodeTests.java b/test/hotspot/jtreg/compiler/c2/irTests/ModFNodeTests.java index 2f69578c2f0..f703df3d04e 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/ModFNodeTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/ModFNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +29,7 @@ import compiler.lib.ir_framework.*; /* * @test - * @bug 8345766 + * @bug 8345766 8378742 * @key randomness * @summary Test that Ideal transformations of ModFNode are being performed as expected. * @library /test/lib / @@ -37,6 +37,7 @@ import compiler.lib.ir_framework.*; */ public class ModFNodeTests { public static final float q = Utils.getRandomInstance().nextFloat() * 100.0f; + public static volatile int volatileField; public static void main(String[] args) { TestFramework.run(); @@ -48,6 +49,7 @@ public class ModFNodeTests { "unusedResultAfterLoopOpt1", "unusedResultAfterLoopOpt2", "unusedResultAfterLoopOpt3", + "constantFoldInCCP" }) public void runMethod() { Asserts.assertEQ(constant(), q % 72.0f % 30.0f); @@ -61,6 +63,7 @@ public class ModFNodeTests { Asserts.assertEQ(unusedResultAfterLoopOpt1(1.1f, 2.2f), 0.f); Asserts.assertEQ(unusedResultAfterLoopOpt2(1.1f, 2.2f), 0.f); Asserts.assertEQ(unusedResultAfterLoopOpt3(1.1f, 2.2f), 0.f); + Asserts.assertEQ(constantFoldInCCP(), 4.0f); } // Note: we used to check for ConF nodes in the IR. But that is a bit brittle: @@ -72,7 +75,7 @@ public class ModFNodeTests { @Test @IR(counts = {IRNode.MOD_F, "2"}, phase = CompilePhase.AFTER_PARSING) - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float constant() { // All constants available during parsing @@ -84,7 +87,7 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "1"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float alsoConstant() { // Make sure value is only available after second loop opts round @@ -102,7 +105,7 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "2"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float nanLeftConstant() { // Make sure value is only available after second loop opts round @@ -120,7 +123,7 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "2"}, phase = CompilePhase.PHASEIDEALLOOP1) // Only constant fold after some loop opts - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float nanRightConstant() { // Make sure value is only available after second loop opts round @@ -154,9 +157,9 @@ public class ModFNodeTests { @Test @IR(counts = {IRNode.MOD_F, "1"}, phase = CompilePhase.AFTER_PARSING) - @IR(counts = {IRNode.MOD_F, "0"}, + @IR(failOn = {IRNode.MOD_F}, phase = CompilePhase.ITER_GVN1) // IGVN removes unused nodes - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public void unusedResult(float x, float y) { float unused = x % y; @@ -165,9 +168,9 @@ public class ModFNodeTests { @Test @IR(counts = {IRNode.MOD_F, "1"}, phase = CompilePhase.AFTER_PARSING) - @IR(counts = {IRNode.MOD_F, "0"}, + @IR(failOn = {IRNode.MOD_F}, phase = CompilePhase.ITER_GVN1) // IGVN removes unused nodes - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public void repeatedlyUnused(float x, float y) { float unused = 1.f; @@ -185,9 +188,9 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "1"}, phase = CompilePhase.ITER_GVN2) - @IR(counts = {IRNode.MOD_F, "0"}, + @IR(failOn = {IRNode.MOD_F}, phase = CompilePhase.BEFORE_MACRO_EXPANSION) - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float unusedResultAfterLoopOpt1(float x, float y) { float unused = x % y; @@ -210,9 +213,9 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "1"}, phase = CompilePhase.AFTER_CLOOPS) - @IR(counts = {IRNode.MOD_F, "0"}, + @IR(failOn = {IRNode.MOD_F}, phase = CompilePhase.PHASEIDEALLOOP1) - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float unusedResultAfterLoopOpt2(float x, float y) { int a = 77; @@ -235,9 +238,9 @@ public class ModFNodeTests { phase = CompilePhase.AFTER_PARSING) @IR(counts = {IRNode.MOD_F, "2"}, phase = CompilePhase.AFTER_CLOOPS) // drop the useless one - @IR(counts = {IRNode.MOD_F, "0"}, + @IR(failOn = {IRNode.MOD_F}, phase = CompilePhase.PHASEIDEALLOOP1) // drop the rest - @IR(counts = {".*CallLeaf.*frem.*", "0"}, + @IR(failOn = {".*CallLeaf.*frem.*"}, phase = CompilePhase.BEFORE_MATCHING) public float unusedResultAfterLoopOpt3(float x, float y) { float unused = x % y; @@ -252,4 +255,25 @@ public class ModFNodeTests { int other = (b - 77) * (int)(x % y % 1.f); return (float)other; } + + @Test + @IR(failOn = {IRNode.CMP_F}, + phase = CompilePhase.CCP1) + @IR(failOn = {IRNode.MOD_F}, + phase = CompilePhase.BEFORE_MACRO_EXPANSION) + public float constantFoldInCCP(){ + int i; + for (i = 2; i < 4; i *= 2) { + } + int j; + for (j = 2; j < 4; j *= 2) { + } + volatileField = 42; + float v1 = (float) i / 2; + float v2 = j; + float v = v1 % v2; + for (; v < v2; v *= 2) { + } + return v; + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestPushAddThruCast.java b/test/hotspot/jtreg/compiler/c2/irTests/TestPushAddThruCast.java index 3aee78e9d6a..81a88791b07 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestPushAddThruCast.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestPushAddThruCast.java @@ -86,7 +86,7 @@ public class TestPushAddThruCast { // Test commoning of Casts after loop opts when they are at the same control @Test @IR(phase = CompilePhase.ITER_GVN1, counts = { IRNode.CAST_II, "4" }) - @IR(phase = CompilePhase.OPTIMIZE_FINISHED, counts = { IRNode.CAST_II, "2" }) + @IR(phase = CompilePhase.OPTIMIZE_FINISHED, counts = { IRNode.CAST_II, "3" }) public static int test3() { int j = Objects.checkIndex(i - 3, length); j += Objects.checkIndex(i, length); diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestShiftAndMask.java b/test/hotspot/jtreg/compiler/c2/irTests/TestShiftAndMask.java index 1413ee0cafa..8f798a1b7eb 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestShiftAndMask.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestShiftAndMask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Red Hat, Inc. All rights reserved. + * Copyright (c) 2021, 2026, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,14 @@ package compiler.c2.irTests; import compiler.lib.ir_framework.*; -import jdk.test.lib.Utils; -import java.util.Random; +import static compiler.lib.generators.Generators.G; +import jdk.test.lib.Asserts; + import java.util.Objects; /* * @test - * @bug 8277850 8278949 8285793 8346664 + * @bug 8277850 8278949 8285793 8346664 8380475 * @key randomness * @summary C2: optimize mask checks in counted loops * @library /test/lib / @@ -38,33 +39,31 @@ import java.util.Objects; */ public class TestShiftAndMask { - private static final Random RANDOM = Utils.getRandomInstance(); - public static void main(String[] args) { TestFramework.run(); } // any X << INT_MASK_WIDTH is zero under any INT_MASK - static final int INT_MASK_WIDTH = 1 + RANDOM.nextInt(30); + static final int INT_MASK_WIDTH = G.ints().restricted(1, 30).next(); static final int INT_MAX_MASK = (1 << INT_MASK_WIDTH) - 1; - static final int INT_MASK = 1 + RANDOM.nextInt(INT_MAX_MASK); - static final int INT_MASK2 = 1 + RANDOM.nextInt(INT_MAX_MASK); - static final int INT_ZERO_CONST = RANDOM.nextInt() << INT_MASK_WIDTH; + static final int INT_MASK = G.ints().restricted(1, INT_MAX_MASK).next(); + static final int INT_MASK2 = G.ints().restricted(1, INT_MAX_MASK).next(); + static final int INT_ZERO_CONST = G.ints().next() << INT_MASK_WIDTH; - static final int INT_RANDOM_CONST = RANDOM.nextInt(); - static final int INT_RANDOM_SHIFT = RANDOM.nextInt(); - static final int INT_RANDOM_MASK = RANDOM.nextInt(); + static final int INT_RANDOM_CONST = G.ints().next(); + static final int INT_RANDOM_SHIFT = G.ints().next(); + static final int INT_RANDOM_MASK = G.ints().next(); // any X << LONG_MASK_WIDTH is zero under any LONG_MASK - static final int LONG_MASK_WIDTH = 1 + RANDOM.nextInt(62); + static final int LONG_MASK_WIDTH = G.ints().restricted(1, 62).next(); static final long LONG_MAX_MASK = (1L << LONG_MASK_WIDTH) - 1; - static final long LONG_MASK = 1 + RANDOM.nextLong(LONG_MAX_MASK); - static final long LONG_MASK2 = 1 + RANDOM.nextLong(LONG_MAX_MASK); - static final long LONG_ZERO_CONST = RANDOM.nextLong() << LONG_MASK_WIDTH; + static final long LONG_MASK = G.longs().restricted(1L, LONG_MAX_MASK).next(); + static final long LONG_MASK2 = G.longs().restricted(1L, LONG_MAX_MASK).next(); + static final long LONG_ZERO_CONST = G.longs().next() << LONG_MASK_WIDTH; - static final long LONG_RANDOM_CONST = RANDOM.nextLong(); - static final long LONG_RANDOM_SHIFT = RANDOM.nextLong(); - static final long LONG_RANDOM_MASK = RANDOM.nextLong(); + static final long LONG_RANDOM_CONST = G.longs().next(); + static final long LONG_RANDOM_SHIFT = G.longs().next(); + static final long LONG_RANDOM_MASK = G.longs().next(); @Test public static int intSumAndMask(int i, int j) { @@ -73,12 +72,9 @@ public class TestShiftAndMask { @Run(test = { "intSumAndMask" }) public static void checkIntSumAndMask() { - int j = RANDOM.nextInt(); - int i = RANDOM.nextInt(); - int res = intSumAndMask(i, j); - if (res != ((j + i << INT_RANDOM_SHIFT + INT_RANDOM_CONST) & INT_RANDOM_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int j = G.ints().next(); + int i = G.ints().next(); + Asserts.assertEquals(intSumAndMask(i, j), (j + i << INT_RANDOM_SHIFT + INT_RANDOM_CONST) & INT_RANDOM_MASK); } @Test @@ -90,9 +86,7 @@ public class TestShiftAndMask { @Check(test = "shiftMaskInt") public static void checkShiftMaskInt(int res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0); } @Test @@ -102,12 +96,9 @@ public class TestShiftAndMask { @Run(test = { "longSumAndMask" }) public static void checkLongSumAndMask() { - long j = RANDOM.nextLong(); - long i = RANDOM.nextLong(); - long res = longSumAndMask(i, j); - if (res != ((j + i << LONG_RANDOM_SHIFT + LONG_RANDOM_CONST) & LONG_RANDOM_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + long j = G.longs().next(); + long i = G.longs().next(); + Asserts.assertEquals(longSumAndMask(i, j), (j + i << LONG_RANDOM_SHIFT + LONG_RANDOM_CONST) & LONG_RANDOM_MASK); } @Test @@ -120,9 +111,7 @@ public class TestShiftAndMask { @Check(test = "shiftMaskLong") public static void checkShiftMaskLong(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } static volatile int barrier; @@ -143,9 +132,7 @@ public class TestShiftAndMask { @Check(test = "shiftNonConstMaskInt") public static void checkShiftNonConstMaskInt(int res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0); } @Test @@ -164,9 +151,7 @@ public class TestShiftAndMask { @Check(test = "shiftNonConstMaskLong") public static void checkShiftNonConstMaskLong(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } @Test @@ -178,12 +163,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskInt") public static void addShiftMaskInt_runner() { - int i = RANDOM.nextInt(); - int j = RANDOM.nextInt(); - int res = addShiftMaskInt(i, j); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.ints().next(); + int j = G.ints().next(); + Asserts.assertEquals(addShiftMaskInt(i, j), j & INT_MASK); } @Test @@ -195,12 +177,9 @@ public class TestShiftAndMask { @Run(test = "addShiftPlusConstMaskInt") public static void addShiftPlusConstMaskInt_runner() { - int i = RANDOM.nextInt(); - int j = RANDOM.nextInt(); - int res = addShiftPlusConstMaskInt(i, j); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.ints().next(); + int j = G.ints().next(); + Asserts.assertEquals(addShiftPlusConstMaskInt(i, j), j & INT_MASK); } @Test @@ -233,16 +212,10 @@ public class TestShiftAndMask { @Run(test = "addSshiftNonConstMaskInt") public static void addSshiftNonConstMaskInt_runner() { - int i = RANDOM.nextInt(); - int j = RANDOM.nextInt(); - int res = addSshiftNonConstMaskInt(i, j, true); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } - res = addSshiftNonConstMaskInt(i, j, false); - if (res != (j & INT_MASK2)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.ints().next(); + int j = G.ints().next(); + Asserts.assertEquals(addSshiftNonConstMaskInt(i, j, true), j & INT_MASK); + Asserts.assertEquals(addSshiftNonConstMaskInt(i, j, false), j & INT_MASK2); } @Test @@ -261,15 +234,9 @@ public class TestShiftAndMask { @Run(test = "addConstNonConstMaskInt") public static void addConstNonConstMaskInt_runner() { - int j = RANDOM.nextInt(); - int res = addConstNonConstMaskInt(j, true); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } - res = addConstNonConstMaskInt(j, false); - if (res != (j & INT_MASK2)) { - throw new RuntimeException("incorrect result: " + res); - } + int j = G.ints().next(); + Asserts.assertEquals(addConstNonConstMaskInt(j, true), j & INT_MASK); + Asserts.assertEquals(addConstNonConstMaskInt(j, false), j & INT_MASK2); } @Test @@ -281,12 +248,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskLong") public static void addShiftMaskLong_runner() { - long i = RANDOM.nextLong(); - long j = RANDOM.nextLong(); - long res = addShiftMaskLong(i, j); - if (res != (j & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.longs().next(); + long j = G.longs().next(); + Asserts.assertEquals(addShiftMaskLong(i, j), j & LONG_MASK); } @Test @@ -298,12 +262,9 @@ public class TestShiftAndMask { @Run(test = "addShiftPlusConstMaskLong") public static void addShiftPlusConstMaskLong_runner() { - long i = RANDOM.nextLong(); - long j = RANDOM.nextLong(); - long res = addShiftPlusConstMaskLong(i, j); - if (res != (j & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.longs().next(); + long j = G.longs().next(); + Asserts.assertEquals(addShiftPlusConstMaskLong(i, j), j & LONG_MASK); } @Test @@ -322,16 +283,10 @@ public class TestShiftAndMask { @Run(test = "addSshiftNonConstMaskLong") public static void addSshiftNonConstMaskLong_runner() { - long i = RANDOM.nextLong(); - long j = RANDOM.nextLong(); - long res = addSshiftNonConstMaskLong(i, j, true); - if (res != (j & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } - res = addSshiftNonConstMaskLong(i, j, false); - if (res != (j & LONG_MASK2)) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.longs().next(); + long j = G.longs().next(); + Asserts.assertEquals(addSshiftNonConstMaskLong(i, j, true), j & LONG_MASK); + Asserts.assertEquals(addSshiftNonConstMaskLong(i, j, false), j & LONG_MASK2); } @Test @@ -350,15 +305,9 @@ public class TestShiftAndMask { @Run(test = "addConstNonConstMaskLong") public static void addConstNonConstMaskLong_runner() { - long j = RANDOM.nextLong(); - long res = addConstNonConstMaskLong(j, true); - if (res != (j & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } - res = addConstNonConstMaskLong(j, false); - if (res != (j & LONG_MASK2)) { - throw new RuntimeException("incorrect result: " + res); - } + long j = G.longs().next(); + Asserts.assertEquals(addConstNonConstMaskLong(j, true), j & LONG_MASK); + Asserts.assertEquals(addConstNonConstMaskLong(j, false), j & LONG_MASK2); } @Test @@ -370,9 +319,7 @@ public class TestShiftAndMask { @Check(test = "addShiftMaskInt2") public static void checkAddShiftMaskInt2(int res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0); } @Test @@ -384,9 +331,7 @@ public class TestShiftAndMask { @Check(test = "addShiftMaskLong2") public static void checkAddShiftMaskLong2(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } // Try to get add inputs swapped compared to other tests @@ -401,12 +346,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskInt3") public static void addShiftMaskInt3_runner() { - int i = RANDOM.nextInt(); - int j = RANDOM.nextInt(); - int res = addShiftMaskInt3(i, j); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.ints().next(); + int j = G.ints().next(); + Asserts.assertEquals(addShiftMaskInt3(i, j), j & INT_MASK); } @Test @@ -420,12 +362,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskLong3") public static void addShiftMaskLong3_runner() { - long i = RANDOM.nextLong(); - float j = RANDOM.nextFloat(); - long res = addShiftMaskLong3(i, j); - if (res != (((long) j) & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.longs().next(); + float j = G.floats().next(); + Asserts.assertEquals(addShiftMaskLong3(i, j), ((long) j) & LONG_MASK); } @Test @@ -437,9 +376,7 @@ public class TestShiftAndMask { @Check(test = "shiftConvMask") public static void checkShiftConvMask(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } @Test @@ -458,9 +395,7 @@ public class TestShiftAndMask { @Check(test = "shiftNotConstConvMask") public static void checkShiftNotConstConvMask(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } @Test @@ -472,12 +407,9 @@ public class TestShiftAndMask { @Run(test = "addShiftConvMask") public static void addShiftConvMask_runner() { - int i = RANDOM.nextInt(); - long j = RANDOM.nextLong(); - long res = addShiftConvMask(i, j); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.ints().next(); + long j = G.longs().next(); + Asserts.assertEquals(addShiftConvMask(i, j), j & INT_MASK); } @Test @@ -489,9 +421,7 @@ public class TestShiftAndMask { @Check(test = "addShiftConvMask2") public static void checkAddShiftConvMask2(long res) { - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + Asserts.assertEquals(res, 0L); } @Test @@ -502,11 +432,8 @@ public class TestShiftAndMask { @Run(test = "shiftMaskIntCheckIndex") public static void shiftMaskIntCheckIndex_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - int res = shiftMaskIntCheckIndex(i, (i << INT_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(shiftMaskIntCheckIndex(i, (i << INT_MASK_WIDTH) + 1), 0); } @Test @@ -517,11 +444,8 @@ public class TestShiftAndMask { @Run(test = "shiftMaskLongCheckIndex") public static void shiftMaskLongCheckIndex_runner() { - long i = RANDOM.nextLong((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH); - long res = shiftMaskLongCheckIndex(i, (i << LONG_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.uniformLongs(0L, ((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(shiftMaskLongCheckIndex(i, (i << LONG_MASK_WIDTH) + 1), 0L); } @Test @@ -533,12 +457,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskIntCheckIndex") public static void addShiftMaskIntCheckIndex_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - int j = RANDOM.nextInt(); - int res = addShiftMaskIntCheckIndex(i, j, (i << INT_MASK_WIDTH) + 1); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + int j = G.ints().next(); + Asserts.assertEquals(addShiftMaskIntCheckIndex(i, j, (i << INT_MASK_WIDTH) + 1), j & INT_MASK); } @Test @@ -550,12 +471,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskLongCheckIndex") public static void addShiftMaskLongCheckIndex_runner() { - long i = RANDOM.nextLong((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH); - long j = RANDOM.nextLong(); - long res = addShiftMaskLongCheckIndex(i, j, (i << LONG_MASK_WIDTH) + 1); - if (res != (j & LONG_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.uniformLongs(0L, ((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH) - 1).next(); + long j = G.longs().next(); + Asserts.assertEquals(addShiftMaskLongCheckIndex(i, j, (i << LONG_MASK_WIDTH) + 1), j & LONG_MASK); } @Test @@ -567,12 +485,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskIntCheckIndex2") public static void addShiftMaskIntCheckIndex2_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - int j = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - int res = addShiftMaskIntCheckIndex2(i, j, (Integer.max(i, j) << INT_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + int j = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(addShiftMaskIntCheckIndex2(i, j, (Integer.max(i, j) << INT_MASK_WIDTH) + 1), 0); } @Test @@ -583,12 +498,9 @@ public class TestShiftAndMask { @Run(test = "addShiftMaskLongCheckIndex2") public static void addShiftMaskLongCheckIndex2_runner() { - long i = RANDOM.nextLong((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH); - long j = RANDOM.nextLong((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH); - long res = addShiftMaskLongCheckIndex2(i, j, (Long.max(i, j) << LONG_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + long i = G.uniformLongs(0L, ((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH) - 1).next(); + long j = G.uniformLongs(0L, ((Long.MAX_VALUE - 1) >> LONG_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(addShiftMaskLongCheckIndex2(i, j, (Long.max(i, j) << LONG_MASK_WIDTH) + 1), 0L); } @Test @@ -599,11 +511,8 @@ public class TestShiftAndMask { @Run(test = "shiftConvMaskCheckIndex") public static void shiftConvMaskCheckIndex_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - long res = shiftConvMaskCheckIndex(i, (i << INT_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(shiftConvMaskCheckIndex(i, (i << INT_MASK_WIDTH) + 1), 0L); } @Test @@ -615,12 +524,9 @@ public class TestShiftAndMask { @Run(test = "addShiftConvMaskCheckIndex") public static void addShiftConvMaskCheckIndex_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - long j = RANDOM.nextLong(); - long res = addShiftConvMaskCheckIndex(i, j, (i << INT_MASK_WIDTH) + 1); - if (res != (j & INT_MASK)) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + long j = G.longs().next(); + Asserts.assertEquals(addShiftConvMaskCheckIndex(i, j, (i << INT_MASK_WIDTH) + 1), j & INT_MASK); } @Test @@ -631,11 +537,147 @@ public class TestShiftAndMask { @Run(test = "addShiftConvMaskCheckIndex2") public static void addShiftConvMaskCheckIndex2_runner() { - int i = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - int j = RANDOM.nextInt((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH); - long res = addShiftConvMaskCheckIndex2(i, j, (Integer.max(i, j) << INT_MASK_WIDTH) + 1); - if (res != 0) { - throw new RuntimeException("incorrect result: " + res); - } + int i = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + int j = G.uniformInts(0, ((Integer.MAX_VALUE - 1) >> INT_MASK_WIDTH) - 1).next(); + Asserts.assertEquals(addShiftConvMaskCheckIndex2(i, j, (Integer.max(i, j) << INT_MASK_WIDTH) + 1), 0L); + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.LSHIFT_I, "1"}) + public int shiftLeftWithLowMaskInt(int x) { + return (x << INT_MASK_WIDTH) & (-1 << INT_MASK_WIDTH); // transformed to: return x << INT_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.LSHIFT_L, "1"}) + public long shiftLeftWithLowMaskLong(long x) { + return (x << LONG_MASK_WIDTH) & (-1 << LONG_MASK_WIDTH); // transformed to: return x << LONG_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.LSHIFT_I, "1"}) + public int shiftLeftWithLowMaskSmallInt(int x) { + return (x << INT_MASK_WIDTH) & (-1 << (INT_MASK_WIDTH - 1)); // transformed to: return x << INT_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.LSHIFT_L, "1"}) + public long shiftLeftWithLowMaskSmallLong(long x) { + return (x << LONG_MASK_WIDTH) & (-1 << (LONG_MASK_WIDTH - 1)); // transformed to: return x << LONG_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.LSHIFT_I, "1"}) + public static int shiftLeftWithLowMaskIntReversed(int x) { + return (-1 << INT_MASK_WIDTH) & (x << INT_MASK_WIDTH); // transformed to: return x << INT_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.LSHIFT_L, "1"}) + public static long shiftLeftWithLowMaskLongReversed(long x) { + return (-1 << LONG_MASK_WIDTH) & (x << LONG_MASK_WIDTH); // transformed to: return x << LONG_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.LSHIFT_I, "1"}) + public static int shiftLeftWithLowMaskSmallIntReversed(int x) { + return (-1 << (INT_MASK_WIDTH - 1)) & (x << INT_MASK_WIDTH); // transformed to: return x << INT_MASK_WIDTH; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.LSHIFT_L, "1"}) + public static long shiftLeftWithLowMaskSmallLongReversed(long x) { + return (-1 << (LONG_MASK_WIDTH - 1)) & (x << LONG_MASK_WIDTH); // transformed to: return x << LONG_MASK_WIDTH; + } + + @Test + @IR(counts = {IRNode.AND_I, "1"}) + public int andMaskNonNegativeInt(int x) { + return (x & 0x7FFF) & 0xFFFF; // transformed to: return x & 0x7FFF; + } + + @Test + @IR(counts = {IRNode.AND_L, "1"}) + public long andMaskNonNegativeLong(long x) { + return (x & 0x7FFFL) & 0xFFFFL; // transformed to: return x & 0x7FFFL; + } + + @Test + @IR(counts = {IRNode.AND_I, "1"}) + public int andMaskNonNegativeIntReversed(int x) { + return 0xFFFF & (x & 0x7FFF); // transformed to: return x & 0x7FFF; + } + + @Test + @IR(counts = {IRNode.AND_L, "1"}) + public long andMaskNonNegativeLongReversed(long x) { + return 0xFFFFL & (x & 0x7FFFL); // transformed to: return x & 0x7FFFL; + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.URSHIFT_I, "1"}) + public int andAfterURShiftInt(int x) { + return (x >>> 8) & 0x00FFFFFF; // transformed to return x >>> 8; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.URSHIFT_L, "1"}) + public long andAfterURShiftLong(long x) { + return (x >>> 16) & 0x0000FFFFFFFFFFFFL; // transformed to return x >>> 16; + } + + @Test + @IR(failOn = {IRNode.AND_I}) + @IR(counts = {IRNode.URSHIFT_I, "1"}) + public int andAfterURShiftIntReversed(int x) { + return 0x00FFFFFF & (x >>> 8); // transformed to return x >>> 8; + } + + @Test + @IR(failOn = {IRNode.AND_L}) + @IR(counts = {IRNode.URSHIFT_L, "1"}) + public long andAfterURShiftLongReversed(long x) { + return 0x0000FFFFFFFFFFFFL & (x >>> 16); // transformed to return x >>> 16; + } + + @Run(test = {"shiftLeftWithLowMaskInt", "shiftLeftWithLowMaskLong", + "shiftLeftWithLowMaskSmallInt", "shiftLeftWithLowMaskSmallLong", + "shiftLeftWithLowMaskIntReversed", "shiftLeftWithLowMaskLongReversed", + "shiftLeftWithLowMaskSmallIntReversed", "shiftLeftWithLowMaskSmallLongReversed", + "andMaskNonNegativeInt", "andMaskNonNegativeLong", + "andMaskNonNegativeIntReversed", "andMaskNonNegativeLongReversed", + "andAfterURShiftInt", "andAfterURShiftLong", + "andAfterURShiftIntReversed", "andAfterURShiftLongReversed", + }) + public void verifyShiftAndMaskTransforms() { + int xi = G.ints().next(); + long xl = G.longs().next(); + + Asserts.assertEquals(shiftLeftWithLowMaskInt(xi), (xi << INT_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskLong(xl), (xl << LONG_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskSmallInt(xi), (xi << INT_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskSmallLong(xl), (xl << LONG_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskIntReversed(xi), (xi << INT_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskLongReversed(xl), (xl << LONG_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskSmallIntReversed(xi), (xi << INT_MASK_WIDTH)); + Asserts.assertEquals(shiftLeftWithLowMaskSmallLongReversed(xl), (xl << LONG_MASK_WIDTH)); + Asserts.assertEquals(andMaskNonNegativeInt(xi), (xi & 0x7FFF)); + Asserts.assertEquals(andMaskNonNegativeLong(xl), (xl & 0x7FFFL)); + Asserts.assertEquals(andMaskNonNegativeIntReversed(xi), (xi & 0x7FFF)); + Asserts.assertEquals(andMaskNonNegativeLongReversed(xl), (xl & 0x7FFFL)); + Asserts.assertEquals(andAfterURShiftInt(xi), (xi >>> 8)); + Asserts.assertEquals(andAfterURShiftLong(xl), (xl >>> 16)); + Asserts.assertEquals(andAfterURShiftIntReversed(xi), (xi >>> 8)); + Asserts.assertEquals(andAfterURShiftLongReversed(xl), (xl >>> 16)); } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/igvn/TestCombineAddPWithConstantOffsets.java b/test/hotspot/jtreg/compiler/c2/irTests/igvn/TestCombineAddPWithConstantOffsets.java index 69963316fa9..cb7a63f5fe6 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/igvn/TestCombineAddPWithConstantOffsets.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/igvn/TestCombineAddPWithConstantOffsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +27,7 @@ import compiler.lib.ir_framework.*; /* * @test * @bug 8343067 - * @requires os.simpleArch == "x64" | os.simpleArch == "aarch64" + * @requires os.simpleArch == "x64" | os.simpleArch == "aarch64" | os.simpleArch == "riscv64" * @requires vm.compiler2.enabled * @summary Test that chains of AddP nodes with constant offsets are idealized * when their offset input changes. @@ -43,6 +43,7 @@ public class TestCombineAddPWithConstantOffsets { @Test @IR(applyIfPlatform = {"x64", "true"}, failOn = {IRNode.ADD_P_OF, ".*"}) @IR(applyIfPlatform = {"aarch64", "true"}, failOn = {IRNode.ADD_P_OF, "reg_imm"}) + @IR(applyIfPlatform = {"riscv64", "true"}, failOn = {IRNode.ADD_P_OF, "reg_imm"}) static void testCombineAddPWithConstantOffsets(int[] arr) { for (long i = 6; i < 14; i++) { arr[(int)i] = 1; diff --git a/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java index 24065bd97b9..2c84ad2676e 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -46,26 +46,13 @@ public class AllocationMergesTests { "-XX:+TraceReduceAllocationMerges", "-XX:+DeoptimizeALot", "-XX:+UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:CompileCommand=inline,*::charAt*", "-XX:CompileCommand=inline,*PicturePositions::*", "-XX:CompileCommand=inline,*Point::*", "-XX:CompileCommand=inline,*Nested::*", "-XX:CompileCommand=exclude,*::dummy*"); - Scenario scenario1 = new Scenario(1, "-XX:+UnlockDiagnosticVMOptions", - "-XX:+ReduceAllocationMerges", - "-XX:+TraceReduceAllocationMerges", - "-XX:+DeoptimizeALot", - "-XX:+UseCompressedOops", - "-XX:-UseCompressedClassPointers", - "-XX:CompileCommand=inline,*::charAt*", - "-XX:CompileCommand=inline,*PicturePositions::*", - "-XX:CompileCommand=inline,*Point::*", - "-XX:CompileCommand=inline,*Nested::*", - "-XX:CompileCommand=exclude,*::dummy*"); - - Scenario scenario2 = new Scenario(2, "-XX:+UnlockDiagnosticVMOptions", + Scenario scenario1 = new Scenario(2, "-XX:+UnlockDiagnosticVMOptions", "-XX:+ReduceAllocationMerges", "-XX:+TraceReduceAllocationMerges", "-XX:+DeoptimizeALot", @@ -76,12 +63,11 @@ public class AllocationMergesTests { "-XX:CompileCommand=inline,*Nested::*", "-XX:CompileCommand=exclude,*::dummy*"); - Scenario scenario3 = new Scenario(3, "-XX:+UnlockDiagnosticVMOptions", + Scenario scenario2 = new Scenario(3, "-XX:+UnlockDiagnosticVMOptions", "-XX:+ReduceAllocationMerges", "-XX:+TraceReduceAllocationMerges", "-XX:+DeoptimizeALot", "-XX:+UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:-OptimizePtrCompare", "-XX:+VerifyReduceAllocationMerges", "-XX:CompileCommand=inline,*::charAt*", @@ -90,7 +76,7 @@ public class AllocationMergesTests { "-XX:CompileCommand=inline,*Nested::*", "-XX:CompileCommand=exclude,*::dummy*"); - framework.addScenarios(scenario0, scenario1, scenario2, scenario3).start(); + framework.addScenarios(scenario0, scenario1, scenario2).start(); } // ------------------ No Scalar Replacement Should Happen in The Tests Below ------------------- // diff --git a/test/hotspot/jtreg/compiler/codecache/stress/OverloadCompileQueueTest.java b/test/hotspot/jtreg/compiler/codecache/stress/OverloadCompileQueueTest.java index 548a746c3af..7122a81c1e7 100644 --- a/test/hotspot/jtreg/compiler/codecache/stress/OverloadCompileQueueTest.java +++ b/test/hotspot/jtreg/compiler/codecache/stress/OverloadCompileQueueTest.java @@ -112,9 +112,9 @@ public class OverloadCompileQueueTest implements Runnable { AVAILABLE_LEVELS = IntStream .rangeClosed(LEVEL_SIMPLE, TIERED_STOP_AT_LEVEL) .toArray(); - } else if (Platform.isServer() && !Platform.isEmulatedClient()) { + } else if (Platform.isServer()) { AVAILABLE_LEVELS = new int[] { LEVEL_FULL_OPTIMIZATION }; - } else if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { + } else if (Platform.isClient() || Platform.isMinimal()) { AVAILABLE_LEVELS = new int[] { LEVEL_SIMPLE }; } else { throw new Error("TESTBUG: unknown VM: " + Platform.vmName); diff --git a/test/hotspot/jtreg/compiler/codegen/TestCheckCastPPRawOopSchedulingAtSafepoint.java b/test/hotspot/jtreg/compiler/codegen/TestCheckCastPPRawOopSchedulingAtSafepoint.java new file mode 100644 index 00000000000..00ba4be76f8 --- /dev/null +++ b/test/hotspot/jtreg/compiler/codegen/TestCheckCastPPRawOopSchedulingAtSafepoint.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2026, 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 8372649 8376189 + * @summary CheckCastPP with RawPtr input can be scheduled below a safepoint during C2 + * post-regalloc block-local scheduling, causing a live raw oop at the safepoint + * instead of a corresponding oop in the OopMap. + * @library /test/lib + * @modules jdk.incubator.vector + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:TrackedInitializationLimit=0 + * -XX:CompileCommand=compileonly,${test.main.class}::test8372649 + * -XX:+OptoScheduling ${test.main.class} 8372649 + * @run main/othervm --add-modules=jdk.incubator.vector + * -XX:+OptoScheduling ${test.main.class} 8376189 + */ + +package compiler.codegen; + +import jdk.incubator.vector.*; +import jdk.test.lib.Asserts; + +public class TestCheckCastPPRawOopSchedulingAtSafepoint { + private static final VectorSpecies SPECIES_I = IntVector.SPECIES_64; + + static public void main(String[] args) { + String mode = args[0]; + if ("8372649".equals(mode)) { + run8372649(); + } else if ("8376189".equals(mode)) { + run8376189(); + } + } + + // JDK-8372649 + static void run8372649(){ + for (int j = 6; 116 > j; ++j) { + test8372649(); + } + Asserts.assertEQ(Test.c, 43560L); + } + + static class Test { + static int a = 256; + float[] b = new float[256]; + static long c; + } + + static void test8372649() { + float[][] g = new float[Test.a][Test.a]; + for (int d = 7; d < 16; d++) { + long e = 1; + do { + g[d][(int) e] = d; + synchronized (new Test()) {} + } while (++e < 5); + } + for (int i = 0; i < Test.a; ++i) { + for (int j = 0; j < Test.a ; ++j) { + Test.c += g[i][j]; + } + } + } + + // JDK-8376189 + static void run8376189(){ + int[] a = new int[10_000]; + int r = 0; + for (int i = 0; i < 10_000; i++) { + r = test8376189(a); + } + Asserts.assertEQ(r, 0); + } + + public static int test8376189(int[] a) { + var mins = IntVector.broadcast(SPECIES_I, a[0]); + for (int i = 0; i < SPECIES_I.loopBound(a.length); i += SPECIES_I.length()) { + mins = IntVector.fromArray(SPECIES_I, a, 0); + } + return mins.reduceLanes(VectorOperators.MIN); + } +} \ No newline at end of file diff --git a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java index 59c8b2efa11..421307e85ca 100644 --- a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java +++ b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java @@ -76,7 +76,7 @@ public class TestAESIntrinsicsOnSupportedConfig extends AESIntrinsicsBase { prepareArguments(prepareBooleanFlag(AESIntrinsicsBase .USE_AES, true))); final String errorMessage = "Case testUseAES failed"; - if (Platform.isServer() && !Platform.isEmulatedClient() && isTieredLevelGreaterThan(3)) { + if (Platform.isServer() && isTieredLevelGreaterThan(3)) { verifyOutput(new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC}, null, errorMessage, outputAnalyzer); diff --git a/test/hotspot/jtreg/compiler/gallery/ParticleLife.java b/test/hotspot/jtreg/compiler/gallery/ParticleLife.java new file mode 100644 index 00000000000..b6c393d328b --- /dev/null +++ b/test/hotspot/jtreg/compiler/gallery/ParticleLife.java @@ -0,0 +1,812 @@ +/* + * Copyright (c) 2026, 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 compiler.gallery; + +import java.util.Random; + +import jdk.incubator.vector.*; + +import javax.swing.*; + +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Color; +import java.awt.Font; +import java.awt.Dimension; +import java.awt.BorderLayout; +import java.awt.RenderingHints; +import java.awt.geom.Ellipse2D; + +/** + * This is a visual demo of the Vector API, presenting an N-Body simulation, + * where every body (particle) interacts with every other body. + * + * This is a stand-alone test that you can run directly with: + * java --add-modules=jdk.incubator.vector ParticleLife.java + * + * On x86, you can also play with the UseAVX flag: + * java --add-modules=jdk.incubator.vector -XX:UseAVX=2 ParticleLife.java + * + * There is a JTREG test that automatically runs this demo, + * see {@link TestParticleLife}. + * + * The motivation for this demo is to present a realistic computation, + * such as a physics simulation, but which is currently not auto + * vectorized. It is thus a good candidate for the use of the Vector API. + * This demo is based on the work of Tom Mohr and others before him: + * https://particle-life.com/ + * https://www.youtube.com/@tom-mohr + * + * If you are interested in understanding the components, then look at these: + * - State.update: one step in the simulation. This consists of two parts: + * - updateForce*: This computes the forces between all the particles, which affects the velocities. + * We have multiple implementations (scalar and Vector API). + * This is the most expensive part of the simulation. + * - updatePositions: The velocities are added to the position. + */ +public class ParticleLife { + public static final Random RANDOM = new Random(123); + + // Increasing this number will make the demo slower. + public static int NUMBER_OF_PARTICLES = 2560; + public static int NUMBER_OF_GROUPS = 50; + + public static float ZOOM = 1500f; + + public static float SCALE1 = 0.02f; + public static float SCALE2 = 0.04f; + public static float SCALE3 = 1f; + public static float FORCE_PARTICLE = 0.0001f; + public static float FORCE_ORIGIN = 0.05f; + + // Dampening factor, applied to the velocity. + // 0: no velocity carried to next update, particles have no momentum + // 1: no dampening, can lead to increase in energy in the system over time. + public static float DAMPENING = 0.3f; + + // Time step size of each update. Larger makes the simulation faster. + // But if it is too large, this can lead to numerical instability. + public static float DT = 1f; + + enum Implementation { + Scalar, VectorAPI_Inner_Gather, VectorAPI_Inner_Rearranged, VectorAPI_Outer + } + + public static Implementation IMPLEMENTATION = Implementation.Scalar; + + enum PoleGen { + Default, Random, Rainbow, Sparse + } + + public static PoleGen POLE_GEN = PoleGen.Default; + + private static final VectorSpecies SPECIES_F = FloatVector.SPECIES_PREFERRED; + + public static State STATE = new State(); + + static void main() { + System.out.println("Welcome to the Particle Life Demo!"); + + // Set up a panel we can draw on, and put it in a window. + JFrame frame = new JFrame("Particle Life Demo (VectorAPI)"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(1400, 1000); + frame.setResizable(false); + frame.setLayout(new BorderLayout()); + + ParticlePanel panel = new ParticlePanel(); + panel.setPreferredSize(new Dimension(1000, 0)); + + JPanel controlPanel = new JPanel(); + controlPanel.setLayout(null); + controlPanel.setPreferredSize(new Dimension(400, 0)); + + int y = 10; + // ---------------------------- Reset Button ------------------------- + JButton button = new JButton("Reset"); + button.setBounds(10, y, 120, 30); + button.setToolTipText("Reset state, with new numbers of particles and groups, and new poles."); + controlPanel.add(button); + + button.addActionListener(_ -> { STATE = new State(); }); + y += 40; + + // ---------------------------- Computation Selector ------------------------- + { + JLabel label = new JLabel("Implementation"); + label.setBounds(10, y, 150, 30); + controlPanel.add(label); + + String[] options = {"Scalar", "VectorAPI Inner Gather", "VectorAPI Inner Rearranged", "VectorAPI Outer"}; + JComboBox comboBox = new JComboBox<>(options); + comboBox.setBounds(160, y, 210, 30); + comboBox.setToolTipText("Choose the implementation of the force computation. Using the VectorAPI should be faster."); + controlPanel.add(comboBox); + + comboBox.addActionListener(_ -> { + String selected = (String) comboBox.getSelectedItem(); + switch (selected) { + case "Scalar" -> IMPLEMENTATION = Implementation.Scalar; + case "VectorAPI Inner Gather" -> IMPLEMENTATION = Implementation.VectorAPI_Inner_Gather; + case "VectorAPI Inner Rearranged" -> IMPLEMENTATION = Implementation.VectorAPI_Inner_Rearranged; + case "VectorAPI Outer" -> IMPLEMENTATION = Implementation.VectorAPI_Outer; + } + }); + } + y += 40; + + // ---------------------------- Zoom Slider ------------------------- + JLabel zoomLabel = new JLabel("Zoom"); + zoomLabel.setBounds(10, y, 80, 30); + controlPanel.add(zoomLabel); + + JSlider zoomSlider = new JSlider(JSlider.HORIZONTAL, 10, 2500, (int)ZOOM); + zoomSlider.setBounds(160, y, 200, 30); + zoomSlider.setMajorTickSpacing(100); + zoomSlider.setPaintTicks(false); + zoomSlider.setPaintLabels(false); + controlPanel.add(zoomSlider); + + zoomSlider.addChangeListener(_ -> { + ZOOM = zoomSlider.getValue(); + }); + zoomSlider.setValue((int)ZOOM); + y += 40; + + // ---------------------------- :Particles Slider ------------------------- + JLabel particlesLabel = new JLabel("Particles"); + particlesLabel.setBounds(10, y, 150, 30); + controlPanel.add(particlesLabel); + + JSlider particlesSlider = new JSlider(JSlider.HORIZONTAL, 64, 10000, 64); + particlesSlider.setBounds(160, y, 200, 30); + particlesSlider.setMajorTickSpacing(100); + particlesSlider.setPaintTicks(false); + particlesSlider.setPaintLabels(false); + particlesSlider.setToolTipText("More particles make the simulation slower. Only applied on Reset."); + controlPanel.add(particlesSlider); + + particlesSlider.addChangeListener(_ -> { + NUMBER_OF_PARTICLES = particlesSlider.getValue() / 64 * 64; + particlesLabel.setText("Particles = " + NUMBER_OF_PARTICLES); + }); + particlesSlider.setValue(NUMBER_OF_PARTICLES); + y += 40; + + // ---------------------------- Groups Slider ------------------------- + JLabel groupsLabel = new JLabel("Groups"); + groupsLabel.setBounds(10, y, 150, 30); + controlPanel.add(groupsLabel); + + JSlider groupsSlider = new JSlider(JSlider.HORIZONTAL, 1, 100, 1); + groupsSlider.setBounds(160, y, 200, 30); + groupsSlider.setMajorTickSpacing(100); + groupsSlider.setPaintTicks(false); + groupsSlider.setPaintLabels(false); + groupsSlider.setToolTipText("More groups lead to more complex behavior. Only applied on Reset."); + controlPanel.add(groupsSlider); + + groupsSlider.addChangeListener(_ -> { + NUMBER_OF_GROUPS = groupsSlider.getValue(); + groupsLabel.setText("Groups = " + NUMBER_OF_GROUPS); + }); + groupsSlider.setValue(NUMBER_OF_GROUPS); + y += 40; + + // ---------------------------- Pole Gen Selector ------------------------- + { + JLabel label = new JLabel("Poles"); + label.setBounds(10, y, 150, 30); + controlPanel.add(label); + + String[] options = {"Default", "Random", "Rainbow", "Sparse"}; + JComboBox comboBox = new JComboBox<>(options); + comboBox.setBounds(160, y, 210, 30); + comboBox.setToolTipText("Poles define attraction/repulsion between groups. Only applied on Reset."); + controlPanel.add(comboBox); + + comboBox.addActionListener(_ -> { + String selected = (String) comboBox.getSelectedItem(); + switch (selected) { + case "Default" -> POLE_GEN = PoleGen.Default; + case "Random" -> POLE_GEN = PoleGen.Random; + case "Rainbow" -> POLE_GEN = PoleGen.Rainbow; + case "Sparse" -> POLE_GEN = PoleGen.Sparse; + } + }); + } + y += 40; + + // ---------------------------- Scale1 Slider ------------------------- + JLabel scale1Label = new JLabel("scale1"); + scale1Label.setBounds(10, y, 150, 30); + controlPanel.add(scale1Label); + + JSlider scale1Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + scale1Slider.setBounds(160, y, 200, 30); + scale1Slider.setMajorTickSpacing(100); + scale1Slider.setPaintTicks(false); + scale1Slider.setPaintLabels(false); + scale1Slider.setToolTipText("Defines (inner) radius: repulsion between all particles."); + controlPanel.add(scale1Slider); + + scale1Slider.addChangeListener(_ -> { + SCALE1 = scale1Slider.getValue() * 0.002f + 0.001f; + scale1Label.setText("scale1 = " + String.format("%.4f", SCALE1)); + }); + scale1Slider.setValue(10); + y += 40; + + // ---------------------------- Scale2 Slider ------------------------- + JLabel scale2Label = new JLabel("scale2"); + scale2Label.setBounds(10, y, 150, 30); + controlPanel.add(scale2Label); + + JSlider scale2Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + scale2Slider.setBounds(160, y, 200, 30); + scale2Slider.setMajorTickSpacing(100); + scale2Slider.setPaintTicks(false); + scale2Slider.setPaintLabels(false); + scale2Slider.setToolTipText("Defines (outer) radius: attraction/repulsion depending on poles/groups."); + controlPanel.add(scale2Slider); + + scale2Slider.addChangeListener(_ -> { + SCALE2 = scale2Slider.getValue() * 0.002f + 0.001f; + scale2Label.setText("scale2 = " + String.format("%.4f", SCALE2)); + }); + scale2Slider.setValue(20); + y += 40; + + // ---------------------------- Scale3 Slider ------------------------- + JLabel scale3Label = new JLabel("scale3"); + scale3Label.setBounds(10, y, 150, 30); + controlPanel.add(scale3Label); + + JSlider scale3Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + scale3Slider.setBounds(160, y, 200, 30); + scale3Slider.setMajorTickSpacing(101); + scale3Slider.setPaintTicks(false); + scale3Slider.setPaintLabels(false); + scale3Slider.setToolTipText("Poles factor: adjust attraction/repulsion strenght."); + controlPanel.add(scale3Slider); + + scale3Slider.addChangeListener(_ -> { + SCALE3 = scale3Slider.getValue() * 0.02f; + scale3Label.setText("scale3 = " + String.format("%.4f", SCALE3)); + }); + scale3Slider.setValue(50); + y += 40; + + // ---------------------------- FORCE_PARTICLE Slider ------------------------- + JLabel forceParticlesLabel = new JLabel("fParticles"); + forceParticlesLabel.setBounds(10, y, 150, 30); + controlPanel.add(forceParticlesLabel); + + JSlider forceParticlesSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + forceParticlesSlider.setBounds(160, y, 200, 30); + forceParticlesSlider.setMajorTickSpacing(100); + forceParticlesSlider.setPaintTicks(false); + forceParticlesSlider.setPaintLabels(false); + forceParticlesSlider.setToolTipText("Particles force factor: adjust force strength between particles."); + controlPanel.add(forceParticlesSlider); + + forceParticlesSlider.addChangeListener(_ -> { + FORCE_PARTICLE = forceParticlesSlider.getValue() * 0.00001f; + forceParticlesLabel.setText("fParticles = " + String.format("%.5f", FORCE_PARTICLE)); + }); + forceParticlesSlider.setValue(10); + y += 40; + + // ---------------------------- FORCE_ORIGIN Slider ------------------------- + JLabel forceOriginLabel = new JLabel("fOrigin"); + forceOriginLabel.setBounds(10, y, 150, 30); + controlPanel.add(forceOriginLabel); + + JSlider forceOriginSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + forceOriginSlider.setBounds(160, y, 200, 30); + forceOriginSlider.setMajorTickSpacing(100); + forceOriginSlider.setPaintTicks(false); + forceOriginSlider.setPaintLabels(false); + forceOriginSlider.setToolTipText("Origin force factor: adjust force attracting all particles to the center/origin."); + controlPanel.add(forceOriginSlider); + + forceOriginSlider.addChangeListener(_ -> { + FORCE_ORIGIN = forceOriginSlider.getValue() * 0.0005f; + forceOriginLabel.setText("fOrigin = " + String.format("%.5f", FORCE_ORIGIN)); + }); + forceOriginSlider.setValue(50); + y += 40; + + // ---------------------------- DAMPENING Slider ------------------------- + JLabel dampeningLabel = new JLabel("dampening"); + dampeningLabel.setBounds(10, y, 150, 30); + controlPanel.add(dampeningLabel); + + JSlider dampeningSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + dampeningSlider.setBounds(160, y, 200, 30); + dampeningSlider.setMajorTickSpacing(100); + dampeningSlider.setPaintTicks(false); + dampeningSlider.setPaintLabels(false); + dampeningSlider.setToolTipText("Dampening removes energy from the system over time. 1 = no dampening."); + controlPanel.add(dampeningSlider); + + dampeningSlider.addChangeListener(_ -> { + DAMPENING = dampeningSlider.getValue() * 0.01f; + dampeningLabel.setText("dampening = " + String.format("%.5f", DAMPENING)); + }); + dampeningSlider.setValue(30); + y += 40; + + // ---------------------------- DT Slider ------------------------- + JLabel dtLabel = new JLabel("dt"); + dtLabel.setBounds(10, y, 150, 30); + controlPanel.add(dtLabel); + + JSlider dtSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); + dtSlider.setBounds(160, y, 200, 30); + dtSlider.setMajorTickSpacing(100); + dtSlider.setPaintTicks(false); + dtSlider.setPaintLabels(false); + dtSlider.setToolTipText("Time delta between simulation steps. Small values lead to slow simulation, large values can lead to simulation instability."); + controlPanel.add(dtSlider); + + dtSlider.addChangeListener(_ -> { + DT = dtSlider.getValue() * 0.04f + 0.001f; + dtLabel.setText("dt = " + String.format("%.3f", DT)); + }); + dtSlider.setValue(25); + y += 40; + + // ---------------------------- Force Panel ------------------------- + ForcePanel forcePanel = new ForcePanel(); + forcePanel.setBounds(10, y, 350, 350); + forcePanel.setToolTipText("Displays the attraction/repulsion between the groups. Only updated on Reset."); + controlPanel.add(forcePanel); + y += 360; + + frame.add(panel, BorderLayout.WEST); + frame.add(controlPanel, BorderLayout.CENTER); + frame.setVisible(true); + + System.out.println("Running Demo..."); + try { + // Tight loop where we redraw the panel as fast as possible. + while (true) { + Thread.sleep(1); + STATE.update(); + panel.repaint(); + forcePanel.repaint(); + } + } catch (InterruptedException e) { + System.out.println("Interrputed, terminating demo."); + } finally { + System.out.println("Shut down demo."); + frame.setVisible(false); + frame.dispose(); + } + } + + /** + * State of the simulation. + */ + public static class State { + public long lastTime; + public float fps; + + // "struct of arrays" approach allows adjacent vector loads. + public float[] x; + public float[] y; + public float[] vx; + public float[] vy; + public int[] group; // group index of the particle + + public Color[] colors; // color of the group + + // Matrix of the poles: defines attraction/repulsion between groups i and j + public float[][] poles; + public float[][] polesT; // transpose of poles + public float[] polesScratch; + + public State() { + int n = NUMBER_OF_PARTICLES; + int g = NUMBER_OF_GROUPS; + x = new float[n]; + y = new float[n]; + vx = new float[n]; + vy = new float[n]; + group = new int[n]; + + for (int i = 0; i < n; i++) { + x[i] = 0.2f * (RANDOM.nextFloat() - 0.5f); + y[i] = 0.2f * (RANDOM.nextFloat() - 0.5f); + group[i] = RANDOM.nextInt(g); + } + + colors = new Color[g]; + for (int i = 0; i < g; i++) { + float h = i / (float)g; + colors[i] = Color.getHSBColor(h, 1f, 1f); + } + + poles = new float[g][g]; + polesT = new float[g][g]; + polesScratch = new float[n]; + for (int i = 0; i < g; i++) { + for (int j = 0; j < g; j++) { + poles[i][j] = poleGen(i, j, g); + polesT[j][i] = poles[i][j]; + } + } + + // Set up the FPS tracker + lastTime = System.nanoTime(); + } + + public static float poleGen(int i, int j, int g) { + int offset = (i - j + g) % g; + return switch (POLE_GEN) { + case PoleGen.Default -> (i == j) ? -1f : RANDOM.nextFloat() * 2f - 1f; + case PoleGen.Random -> RANDOM.nextFloat() * 2f - 1f; + case PoleGen.Rainbow -> (i == j) ? -1f : ((offset == 1) ? -0.5f : 0f); + case PoleGen.Sparse -> (i == j) ? -1f : (RANDOM.nextInt(g) <= 2 ? -0.5f : 0.3f); + }; + } + + public void update() { + long nowTime = System.nanoTime(); + float newFPS = 1e9f / (nowTime - lastTime); + fps = 0.9f * fps + 0.1f * newFPS; + lastTime = nowTime; + + switch (IMPLEMENTATION) { + case Implementation.Scalar -> updateForcesScalar(); + case Implementation.VectorAPI_Inner_Gather -> updateForcesVectorAPI_Inner_Gather(); + case Implementation.VectorAPI_Inner_Rearranged -> updateForcesVectorAPI_Inner_Rearranged(); + case Implementation.VectorAPI_Outer -> updateForcesVectorAPI_Outer(); + default -> throw new RuntimeException("not implemented"); + } + + updatePositions(); + } + + public void updateForcesScalar() { + for (int i = 0; i < x.length; i++) { + float pix = x[i]; + float piy = y[i]; + float pivx = vx[i]; + float pivy = vy[i]; + for (int j = 0; j < x.length; j++) { + float pjx = x[j]; + float pjy = y[j]; + + float dx = pix - pjx; + float dy = piy - pjy; + float d = (float)Math.sqrt(dx * dx + dy * dy); + + // Ignoring d=0 avoids division by zero. + // This would happen for i==j which we want to exclude anyway, + // of if two particles have identical position. + if (d > 0f) { + float pole = poles[group[i]][group[j]]; + // If the distance is very large, the force is zero. + float f = 0; + if (d < SCALE1) { + // Small distance: repell all particles + f = (SCALE1 - d) / SCALE1; + } else if (d < SCALE1 + SCALE2) { + // Medium distance: attract/repell according to pole + f = (d - SCALE1) / SCALE2 * pole * SCALE3; + } else if (d < SCALE1 + 2f * SCALE2) { + // Medium distance: attract/repell according to pole + f = ((SCALE1 + 2f * SCALE2) - d) / SCALE2 * pole * SCALE3; + } + // The force is adjustable by the user via FORCE_PARTICLE. + // Additionally we need to respect the DT factor of the simulation + // time step. Finally, we need to normalize dx and dy by dividing + // by d. + f *= FORCE_PARTICLE * DT / d; + pivx += dx * f; + pivy += dy * f; + } + } + vx[i] = pivx; + vy[i] = pivy; + } + } + + // Inner loop vectorization, the inner loop is vectorized. + public void updateForcesVectorAPI_Inner_Gather() { + // We don't want to deal with tail loops, so we just assert that the number of + // particles is a multiple of the vector length. + if (x.length % SPECIES_F.length() != 0) { + throw new RuntimeException("Number of particles is not a multiple of the vector length."); + } + + for (int i = 0; i < x.length; i++) { + float pix = x[i]; + float piy = y[i]; + + // We consider the force of multiple (j) particles on particle i. + var fx = FloatVector.zero(SPECIES_F); + var fy = FloatVector.zero(SPECIES_F); + + for (int j = 0; j < x.length; j += SPECIES_F.length()) { + var pjx = FloatVector.fromArray(SPECIES_F, x, j); + var pjy = FloatVector.fromArray(SPECIES_F, y, j); + + var dx = pjx.sub(pix).neg(); + var dy = pjy.sub(piy).neg(); + var d2 = ( dx.mul(dx) ).add( dy.mul(dy) ); + var d = d2.lanewise(VectorOperators.SQRT); + + // We directly gather the poles from the matrix. + var pole = FloatVector.fromArray(SPECIES_F, poles[group[i]], 0, group, j); + + // We need to compute all 3 piece-wise liner parts. + var poleDivScale2 = pole.mul(SCALE3 / SCALE2); + var f1 = d.sub(SCALE1).neg().mul(1f / SCALE1); + var f2 = d.sub(SCALE1).mul(poleDivScale2); + var f3 = d.sub(SCALE1 + SCALE2 * 2f).neg().mul(poleDivScale2); + + // And we need to perform all checks, for the boundaries of the piece-wise parts. + var f0Mask = d.compare(VectorOperators.GT, 0); + var f1Mask = d.compare(VectorOperators.LT, SCALE1); + var f2Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2); + var f3Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2 * 2f); + var f03Mask = f0Mask.and(f3Mask); + + // Then, we put together the 3 middle parts. + var f12 = f2.blend(f1, f1Mask); + var f123 = f3.blend(f12, f2Mask); + + f123 = f123.mul(FORCE_PARTICLE * DT).div(d); + + // And we only apply the middle (non-zero) parts if the mask is enabled. + fx = fx.add(dx.mul(f123), f03Mask); + fy = fy.add(dy.mul(f123), f03Mask); + } + // We need to add the force of all the (j) particles onto i's velocity. + vx[i] += fx.reduceLanes(VectorOperators.ADD); + vy[i] += fy.reduceLanes(VectorOperators.ADD); + } + } + + // Inner loop vectorization, the inner loop is vectorized. But instead of gathering the poles + // in the inner loop, we rearrange it in the outer loop, so the inner loop has a linear access. + public void updateForcesVectorAPI_Inner_Rearranged() { + // We don't want to deal with tail loops, so we just assert that the number of + // particles is a multiple of the vector length. + if (x.length % SPECIES_F.length() != 0) { + throw new RuntimeException("Number of particles is not a multiple of the vector length."); + } + + for (int i = 0; i < x.length; i++) { + // Rearrange data to avoid rearrange in the loop. + // We could also use the VectorAPI for this loop, but it is not even necessary for speedups. + float[] polesgi = poles[group[i]]; + for (int j = 0; j < x.length; j++) { + polesScratch[j] = polesgi[group[j]]; + } + + float pix = x[i]; + float piy = y[i]; + + // We consider the force of multiple (j) particles on particle i. + var fx = FloatVector.zero(SPECIES_F); + var fy = FloatVector.zero(SPECIES_F); + + for (int j = 0; j < x.length; j += SPECIES_F.length()) { + var pjx = FloatVector.fromArray(SPECIES_F, x, j); + var pjy = FloatVector.fromArray(SPECIES_F, y, j); + + var dx = pjx.sub(pix).neg(); + var dy = pjy.sub(piy).neg(); + var d2 = ( dx.mul(dx) ).add( dy.mul(dy) ); + var d = d2.lanewise(VectorOperators.SQRT); + + // We can now access the poles from scratch in a linear access, avoiding the + // repeated gather in each inner loop. This helps especially if gather is + // not supported on a platform. But it also improves the access pattern on + // platforms where gather would be supported, but linear access is faster. + var pole = FloatVector.fromArray(SPECIES_F, polesScratch, j); + + // We need to compute all 3 piece-wise liner parts. + var poleDivScale2 = pole.mul(SCALE3 / SCALE2); + var f1 = d.sub(SCALE1).neg().mul(1f / SCALE1); + var f2 = d.sub(SCALE1).mul(poleDivScale2); + var f3 = d.sub(SCALE1 + SCALE2 * 2f).neg().mul(poleDivScale2); + + // And we need to perform all checks, for the boundaries of the piece-wise parts. + var f0Mask = d.compare(VectorOperators.GT, 0); + var f1Mask = d.compare(VectorOperators.LT, SCALE1); + var f2Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2); + var f3Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2 * 2f); + var f03Mask = f0Mask.and(f3Mask); + + // Then, we put together the 3 middle parts. + var f12 = f2.blend(f1, f1Mask); + var f123 = f3.blend(f12, f2Mask); + + f123 = f123.mul(FORCE_PARTICLE * DT).div(d); + + // And we only apply the middle (non-zero) parts if the mask is enabled. + fx = fx.add(dx.mul(f123), f03Mask); + fy = fy.add(dy.mul(f123), f03Mask); + } + // We need to add the force of all the (j) particles onto i's velocity. + vx[i] += fx.reduceLanes(VectorOperators.ADD); + vy[i] += fy.reduceLanes(VectorOperators.ADD); + } + } + + // Instead of vectorizing the inner loop, we can also vectorize the outer loop. + public void updateForcesVectorAPI_Outer() { + // We don't want to deal with tail loops, so we just assert that the number of + // particles is a multiple of the vector length. + if (x.length % SPECIES_F.length() != 0) { + throw new RuntimeException("Number of particles is not a multiple of the vector length."); + } + + for (int i = 0; i < x.length; i += SPECIES_F.length()) { + var pix = FloatVector.fromArray(SPECIES_F, x, i); + var piy = FloatVector.fromArray(SPECIES_F, y, i); + var pivx = FloatVector.fromArray(SPECIES_F, vx, i); + var pivy = FloatVector.fromArray(SPECIES_F, vy, i); + + // Let's consider the force of the j particle on all of the i particles in the vector. + for (int j = 0; j < x.length; j++) { + float pjx = x[j]; + float pjy = y[j]; + + var dx = pix.sub(pjx); + var dy = piy.sub(pjy); + var d2 = ( dx.mul(dx) ).add( dy.mul(dy) ); + var d = d2.lanewise(VectorOperators.SQRT); + + // We need to access transpose of poles, because we need to access adjacent i's + var pole = FloatVector.fromArray(SPECIES_F, polesT[group[j]], 0, group, i); + + var poleDivScale2 = pole.mul(SCALE3 / SCALE2); + var f1 = d.sub(SCALE1).neg().mul(1f / SCALE1); + var f2 = d.sub(SCALE1).mul(poleDivScale2); + var f3 = d.sub(SCALE1 + SCALE2 * 2f).neg().mul(poleDivScale2); + + var f0Mask = d.compare(VectorOperators.GT, 0); + var f1Mask = d.compare(VectorOperators.LT, SCALE1); + var f2Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2); + var f3Mask = d.compare(VectorOperators.LT, SCALE1 + SCALE2 * 2f); + var f03Mask = f0Mask.and(f3Mask); + + var f12 = f2.blend(f1, f1Mask); + var f123 = f3.blend(f12, f2Mask); + + f123 = f123.mul(FORCE_PARTICLE * DT).div(d); + pivx = pivx.add(dx.mul(f123), f03Mask); + pivy = pivy.add(dy.mul(f123), f03Mask); + } + pivx.intoArray(vx, i); + pivy.intoArray(vy, i); + } + } + + // The loop is so simple that it can be auto vectorized + public void updatePositions() { + float effectiveDampening = (float)Math.pow(DAMPENING, DT); + for (int i = 0; i < x.length; i++) { + float px = x[i]; + float py = y[i]; + float pvx = vx[i]; + float pvy = vy[i]; + + // Force that pulls to origin, based on distance. + float d = (float)Math.sqrt(px * px + py * py); + pvx -= px * d * FORCE_ORIGIN * DT; + pvy -= py * d * FORCE_ORIGIN * DT; + + // Update position and put drag on speed + px += pvx * DT; + py += pvy * DT; + pvx *= effectiveDampening; + pvy *= effectiveDampening; + + x[i] = px; + y[i] = py; + vx[i] = pvx; + vy[i] = pvy; + } + } + } + + /** + * This panel displays the simulation. + **/ + public static class ParticlePanel extends JPanel { + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + + // Rendering settings for smoother circles + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + + g2d.setColor(new Color(0, 0, 0)); + g2d.fillRect(0, 0, 1000, 1000); + + // Draw position of points + for (int i = 0; i < STATE.x.length; i++) { + g2d.setColor(STATE.colors[STATE.group[i]]); + int xx = (int)(STATE.x[i] * ZOOM + 500f); + int yy = (int)(STATE.y[i] * ZOOM + 500f); + //g2d.fillRect(xx - 3, yy - 3, 6, 6); + g2d.fill(new Ellipse2D.Double(xx - 3, yy - 3, 6, 6)); + } + + g2d.setColor(new Color(0, 0, 0)); + g2d.fillRect(0, 0, 150, 35); + g2d.setColor(new Color(255, 255, 255)); + g2d.setFont(new Font("Consolas", Font.PLAIN, 30)); + g2d.drawString("FPS: " + (int)Math.floor(STATE.fps), 0, 30); + + g2d.setColor(new Color(255, 255, 255)); + int r1 = (int)(ZOOM * SCALE1); + int r2 = (int)(ZOOM * (SCALE1 + SCALE2 * 2f)); + g2d.drawOval(900 - r1, 100 - r1, 2 * r1, 2 * r1); + g2d.drawOval(900 - r2, 100 - r2, 2 * r2, 2 * r2); + } + } + + /** + * This panel displays the pole matrix. + **/ + public static class ForcePanel extends JPanel { + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + + g2d.setColor(new Color(0, 0, 0)); + g2d.fillRect(0, 0, 350, 350); + + int nGroups = STATE.poles.length; + int scale = (int)(300f / nGroups); + for (int i = 0; i < nGroups; i++) { + g2d.setColor(STATE.colors[i]); + g2d.fillRect(scale * (i + 1), 0, scale, scale); + g2d.fillRect(0, scale * (i + 1), scale, scale); + + for (int j = 0; j < nGroups; j++) { + float p = STATE.poles[i][j]; + float cr = Math.max(0, p); + float cg = Math.max(0, -p); + g2d.setColor(new Color(cr, cg, 0)); + g2d.fillRect(scale * (i + 1), scale * (j + 1), scale, scale); + } + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/gallery/TestParticleLife.java b/test/hotspot/jtreg/compiler/gallery/TestParticleLife.java new file mode 100644 index 00000000000..bb1eea927c7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/gallery/TestParticleLife.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2026, 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 id=ir + * @bug 8378166 + * @summary Visual example of the Vector API: NBody / Particle Life simulation. + * @library /test/lib / + * @modules jdk.incubator.vector + * @run driver ${test.main.class} ir + */ + +/* + * @test id=visual + * @key headful + * @library /test/lib / + * @modules jdk.incubator.vector + * @run main ${test.main.class} visual + */ + +package compiler.gallery; + +import jdk.test.lib.Utils; + +import compiler.lib.ir_framework.*; + +/** + * This test is the JTREG version for automatic verification of the stand-alone + * {@link ParticleLife}. If you just want to run the demo and play with it, + * go look at the documentation in {@link ParticleLife}. + * Here, we launch both a visual version that just runs for a few seconds, to see + * that there are no crashes, but we don't do any specific verification. + * We also have an IR test, that ensures that we get vectorization. + */ +public class TestParticleLife { + public static void main(String[] args) throws InterruptedException { + String mode = args[0]; + System.out.println("Running JTREG test in mode: " + mode); + + switch (mode) { + case "ir" -> runIR(); + case "visual" -> runVisual(); + default -> throw new RuntimeException("Unknown mode: " + mode); + } + } + + private static void runIR() { + System.out.println("Testing with IR rules..."); + TestFramework.runWithFlags("-XX:CompileCommand=inline,compiler.gallery.ParticleLife$State::update*", + "--add-modules=jdk.incubator.vector"); + } + + private static void runVisual() throws InterruptedException { + System.out.println("Testing with 2d Graphics (visual)..."); + + // We will not do anything special here, just launch the application, + // tell it to run for 10 second, interrupt it and let it shut down. + Thread thread = new Thread() { + public void run() { + ParticleLife.main(); + } + }; + thread.setDaemon(true); + thread.start(); + Thread.sleep(Utils.adjustTimeout(10000)); // let demo run for 10 seconds + thread.interrupt(); + Thread.sleep(Utils.adjustTimeout(1000)); // allow demo 1 second for shutdown + } + + // ---------------------- For the IR testing part only -------------------------------- + ParticleLife.State state = new ParticleLife.State(); + + @Test + @Warmup(75) + @IR(counts = {IRNode.REPLICATE_F, "> 0", + IRNode.LOAD_VECTOR_F, "> 0", + IRNode.SUB_VF, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.ADD_VF, "> 0", + IRNode.SQRT_VF, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIf = {"AlignVector", "false"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}) + private void testIR_updatePositions() { + // This call should inline given the CompileCommand above. + // We expect auto vectorization of the relatively simple loop. + state.updatePositions(); + } + + @Test + @Warmup(2) + @IR(counts = {IRNode.REPLICATE_F, "= 0", + IRNode.LOAD_VECTOR_F, "= 0", + IRNode.REPLICATE_I, "= 0", + IRNode.LOAD_VECTOR_I, "= 0", + IRNode.ADD_VI, "= 0", + IRNode.LOAD_VECTOR_GATHER, "= 0", + IRNode.SUB_VF, "= 0", + IRNode.MUL_VF, "= 0", + IRNode.ADD_VF, "= 0", + IRNode.NEG_VF, "= 0", + IRNode.SQRT_VF, "= 0", + IRNode.DIV_VF, "= 0", + IRNode.VECTOR_MASK_CMP, "= 0", + IRNode.VECTOR_MASK_CAST, "= 0", + IRNode.AND_V_MASK, "= 0", + IRNode.VECTOR_BLEND_F, "= 0", + IRNode.STORE_VECTOR, "= 0", + IRNode.ADD_REDUCTION_VF, "= 0"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + private void testIR_updateForcesScalar() { + // This call should inline given the CompileCommand above. + // We expect no vectorization, though it may in principle be possible + // to auto vectorize one day. + state.updateForcesScalar(); + } + + @Test + @Warmup(2) + @IR(counts = {IRNode.REPLICATE_F, "> 0", + IRNode.LOAD_VECTOR_F, "> 0", + IRNode.REPLICATE_I, "> 0", + IRNode.LOAD_VECTOR_I, "> 0", + IRNode.ADD_VI, "> 0", + IRNode.LOAD_VECTOR_GATHER, "> 0", + IRNode.SUB_VF, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.ADD_VF, "> 0", + IRNode.NEG_VF, "> 0", + IRNode.SQRT_VF, "> 0", + IRNode.DIV_VF, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_MASK_CAST, "> 0", + IRNode.VECTOR_BLEND_F, "> 0", + IRNode.ADD_REDUCTION_VF, "> 0"}, // instead we reduce the vector to a scalar + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeature = {"avx2", "true"}) + private void testIR_updateForcesVectorAPI_Inner_Gather() { + // This call should inline given the CompileCommand above. + // We expect the VectorAPI calls to intrinsify. + state.updateForcesVectorAPI_Inner_Gather(); + } + + @Test + @Warmup(2) + @IR(counts = {IRNode.REPLICATE_F, "> 0", + IRNode.LOAD_VECTOR_F, "> 0", + IRNode.REPLICATE_I, "= 0", // No gather operation + IRNode.LOAD_VECTOR_I, "= 0", // No gather operation + IRNode.ADD_VI, "= 0", // No gather operation + IRNode.LOAD_VECTOR_GATHER, "= 0", // No gather operation + IRNode.SUB_VF, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.ADD_VF, "> 0", + IRNode.NEG_VF, "> 0", + IRNode.SQRT_VF, "> 0", + IRNode.DIV_VF, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_MASK_CAST, "> 0", + IRNode.VECTOR_BLEND_F, "> 0", + IRNode.ADD_REDUCTION_VF, "> 0"}, // instead we reduce the vector to a scalar + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + private void testIR_updateForcesVectorAPI_Inner_Rearranged() { + // This call should inline given the CompileCommand above. + // We expect the VectorAPI calls to intrinsify. + state.updateForcesVectorAPI_Inner_Rearranged(); + } + + + @Test + @Warmup(2) + @IR(counts = {IRNode.REPLICATE_F, "> 0", + IRNode.LOAD_VECTOR_F, "> 0", + IRNode.REPLICATE_I, "> 0", + IRNode.LOAD_VECTOR_I, "> 0", + IRNode.ADD_VI, "> 0", + IRNode.LOAD_VECTOR_GATHER, "> 0", + IRNode.SUB_VF, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.ADD_VF, "> 0", + IRNode.NEG_VF, "> 0", + IRNode.SQRT_VF, "> 0", + IRNode.DIV_VF, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_MASK_CAST, "> 0", + IRNode.VECTOR_BLEND_F, "> 0", + IRNode.STORE_VECTOR, "> 0", // store back a vector + IRNode.ADD_REDUCTION_VF, "= 0"}, // and no reduction operation + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeature = {"avx2", "true"}) + private void testIR_updateForcesVectorAPI_Outer() { + // This call should inline given the CompileCommand above. + // We expect the VectorAPI calls to intrinsify. + state.updateForcesVectorAPI_Outer(); + } +} diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java index ff20f750935..38aaee62045 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -251,7 +251,8 @@ class TestZGCCorrectBarrierElision { class TestZGCEffectiveBarrierElision { @Test - @IR(counts = { IRNode.Z_LOAD_P_WITH_BARRIER_FLAG, Common.ELIDED, "1" }, phase = CompilePhase.FINAL_CODE) + // C2 does not emit a field load during parsing, so it also does not emit any barriers. + @IR(failOn = { IRNode.Z_LOAD_P_WITH_BARRIER_FLAG, Common.ELIDED }, phase = CompilePhase.FINAL_CODE) static void testAllocateThenLoad() { Outer o1 = new Outer(); Common.blackhole(o1); diff --git a/test/hotspot/jtreg/compiler/igvn/ExpressionFuzzer.java b/test/hotspot/jtreg/compiler/igvn/ExpressionFuzzer.java index 875ef57c865..33be24a0367 100644 --- a/test/hotspot/jtreg/compiler/igvn/ExpressionFuzzer.java +++ b/test/hotspot/jtreg/compiler/igvn/ExpressionFuzzer.java @@ -52,6 +52,7 @@ import static compiler.lib.template_framework.Template.let; import static compiler.lib.template_framework.Template.$; import compiler.lib.template_framework.library.CodeGenerationDataNameType; import compiler.lib.template_framework.library.Expression; +import compiler.lib.template_framework.library.Expression.Nesting; import compiler.lib.template_framework.library.Operations; import compiler.lib.template_framework.library.PrimitiveType; import compiler.lib.template_framework.library.TestFrameworkClass; @@ -335,7 +336,7 @@ public class ExpressionFuzzer { for (int i = 0; i < 10; i++) { // The depth determines roughly how many operations are going to be used in the expression. int depth = RANDOM.nextInt(1, 20); - Expression expression = Expression.nestRandomly(type, Operations.PRIMITIVE_OPERATIONS, depth); + Expression expression = Expression.nestRandomly(type, Operations.PRIMITIVE_OPERATIONS, depth, Nesting.EXACT); tests.add(testTemplate.asToken(expression)); } } @@ -350,7 +351,7 @@ public class ExpressionFuzzer { for (int i = 0; i < 2; i++) { // The depth determines roughly how many operations are going to be used in the expression. int depth = RANDOM.nextInt(1, 20); - Expression expression = Expression.nestRandomly(type, Operations.SCALAR_NUMERIC_OPERATIONS, depth); + Expression expression = Expression.nestRandomly(type, Operations.SCALAR_NUMERIC_OPERATIONS, depth, Nesting.EXACT); tests.add(testTemplate.asToken(expression)); } } diff --git a/test/hotspot/jtreg/compiler/igvn/TestMinMaxIdentity.java b/test/hotspot/jtreg/compiler/igvn/TestMinMaxIdentity.java index b4c62fb49a9..f91b153817b 100644 --- a/test/hotspot/jtreg/compiler/igvn/TestMinMaxIdentity.java +++ b/test/hotspot/jtreg/compiler/igvn/TestMinMaxIdentity.java @@ -163,7 +163,7 @@ public class TestMinMaxIdentity { """ @IR(counts = {IRNode.#op, "= 1"}, phase = CompilePhase.BEFORE_MACRO_EXPANSION, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "darn", "true"}) @IR(counts = {IRNode.#op, "= 1"}, phase = CompilePhase.BEFORE_MACRO_EXPANSION, applyIfPlatform = {"riscv64", "true"}) diff --git a/test/hotspot/jtreg/compiler/inlining/InlineBimorphicVirtualCallAfterMorphismChanged.java b/test/hotspot/jtreg/compiler/inlining/InlineBimorphicVirtualCallAfterMorphismChanged.java index 6f1dadd6b80..bebb3802eb9 100644 --- a/test/hotspot/jtreg/compiler/inlining/InlineBimorphicVirtualCallAfterMorphismChanged.java +++ b/test/hotspot/jtreg/compiler/inlining/InlineBimorphicVirtualCallAfterMorphismChanged.java @@ -29,7 +29,7 @@ * @modules java.base/jdk.internal.misc * @library /test/lib * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * * @run driver compiler.inlining.InlineBimorphicVirtualCallAfterMorphismChanged */ diff --git a/test/hotspot/jtreg/compiler/integerArithmetic/TestHoistDivision.java b/test/hotspot/jtreg/compiler/integerArithmetic/TestHoistDivision.java new file mode 100644 index 00000000000..26fce864c12 --- /dev/null +++ b/test/hotspot/jtreg/compiler/integerArithmetic/TestHoistDivision.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2026, 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 compiler.integerArithmetic; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; + +/* + * @test + * @bug 8347365 + * @summary Tests that divisions are hoisted when their zero checks are elided. + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class TestHoistDivision { + public static void main(String[] args) { + TestFramework.run(); + } + + @DontInline + private static void dontInline() {} + + @Run(test = {"testCommon", "testHoistOutOfLoop"}) + public void run() { + Asserts.assertEQ(2, testCommon(1, 1)); + Asserts.assertEQ(0, testHoistOutOfLoop(1, 1, true, 1, 4, 2)); + Asserts.assertEQ(0, testHoistOutOfLoop(1, 1, false, 1, 4, 2)); + } + + @Test + @IR(counts = {IRNode.DIV_I, "1", IRNode.DIV_BY_ZERO_TRAP, "1"}) + public int testCommon(int x, int y) { + // The 2 divisions should be commoned + int result = x / y; + dontInline(); + return result + x / y; + } + + @Test + @IR(failOn = IRNode.DIV_BY_ZERO_TRAP, counts = {IRNode.DIV_I, "1", IRNode.TRAP, "1"}) + public int testHoistOutOfLoop(int x, int y, boolean b, int start, int limit, int step) { + // The divisions should be hoisted out of the loop, allowing them to be commoned + int result = 0; + for (int i = start; i < limit; i *= step) { + if (b) { + dontInline(); + result += x / y; + } else { + result -= x / y; + } + b = !b; + } + return result; + } +} diff --git a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java index abf0aa7b885..310fce78f9b 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java @@ -142,7 +142,7 @@ public class IntrinsicAvailableTest extends CompilerWhiteBoxTest { public void test() throws Exception { Executable intrinsicMethod = testCase.getExecutable(); - if (Platform.isServer() && !Platform.isEmulatedClient() && (TIERED_STOP_AT_LEVEL == COMP_LEVEL_FULL_OPTIMIZATION)) { + if (Platform.isServer() && (TIERED_STOP_AT_LEVEL == COMP_LEVEL_FULL_OPTIMIZATION)) { if (TIERED_COMPILATION) { checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java index a98bef68c9a..7eb1c855f4b 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java @@ -217,8 +217,7 @@ public class IntrinsicDisabledTest { } public static void main(String args[]) { - if (Platform.isServer() && !Platform.isEmulatedClient() && - (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) { + if (Platform.isServer() && (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) { if (TIERED_COMPILATION) { test(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/bigInteger/MontgomeryMultiplyTest.java b/test/hotspot/jtreg/compiler/intrinsics/bigInteger/MontgomeryMultiplyTest.java index e145a0088c0..0ca419f7dcd 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bigInteger/MontgomeryMultiplyTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bigInteger/MontgomeryMultiplyTest.java @@ -26,7 +26,7 @@ * @test * @bug 8130150 8131779 8139907 * @summary Verify that the Montgomery multiply and square intrinsic works and correctly checks their arguments. - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @modules java.base/jdk.internal.misc:open * @modules java.base/java.math:open * @library /test/lib / @@ -313,8 +313,8 @@ public class MontgomeryMultiplyTest { } public static void main(String args[]) { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } if (wb.isIntrinsicAvailable(getExecutable(true), CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) && wb.isIntrinsicAvailable(getExecutable(false), CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) { diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java index 4145b0f5641..30ce3b36af6 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java index c17e5345d21..1a3e7e1314d 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java index 881ed37906e..71d9e52a539 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java index 1ea8125b1cd..425f70f1052 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java index 38753762f39..3632d9617b8 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java index 9a279083059..8f6958d212f 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java index 4ea2b3ab841..bd8c26724a1 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java index 421e24d07ab..68f82a99bd3 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java index 0e8c8fe9514..8c6120388a1 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java @@ -83,7 +83,7 @@ public class BmiIntrinsicBase extends CompilerWhiteBoxTest { System.out.println(testCase.name()); - if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX || Platform.isEmulatedClient()) { + if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX) { System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED"); return; } diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java index 4cf94a0eb8b..872fefd883c 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java @@ -23,7 +23,7 @@ /* * @test - * @requires vm.simpleArch == "x64" & vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.simpleArch == "x64" & vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java index c905fca34a2..34f1eb4f3a3 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java index cf49937936f..30cadaf200e 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java index 8a8ce4508fa..bc6c1276450 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java index 926f071074e..b5db7b861c3 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java index 1828e0ba837..31449eefb33 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java @@ -26,7 +26,7 @@ * @bug 8054492 * @summary Casting can result in redundant null checks in generated code * @requires vm.hasJFR - * @requires vm.flavor == "server" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & !vm.graal.enabled * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -93,8 +93,8 @@ public class CastNullCheckDroppingsTest { int[] asink; public static void main(String[] args) throws Exception { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } // Make sure background compilation is disabled if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { diff --git a/test/hotspot/jtreg/compiler/intrinsics/math/PowDNodeTests.java b/test/hotspot/jtreg/compiler/intrinsics/math/PowDNodeTests.java new file mode 100644 index 00000000000..e28cc5ab346 --- /dev/null +++ b/test/hotspot/jtreg/compiler/intrinsics/math/PowDNodeTests.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2026, IBM 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 compiler.intrinsics.math; + +import jdk.test.lib.Asserts; + +import compiler.lib.ir_framework.*; +import compiler.lib.generators.*; +import static compiler.lib.generators.Generators.*; + +import java.util.Random; + +/* + * @test + * @bug 8378713 + * @key randomness + * @summary Math.pow(base, exp) should constant propagate + * @library /test/lib / + * @run driver ${test.main.class} + */ +public class PowDNodeTests { + public static final Generator UNIFORMS = G.uniformDoubles(); // [0, 1) + + public static final double B = UNIFORMS.next() * 1000.0d; + public static final double E = UNIFORMS.next() * 1000.0d + 3.0d; // e >= 3 to avoid strength reduction code + + public static void main(String[] args) { + TestFramework.run(); + + testCorrectness(); + } + + // Test 1: pow(2.0, 10.0) -> 1024.0 + @Test + @IR(failOn = {IRNode.POW_D}) + public static double constantLiteralFolding() { + return Math.pow(2.0, 10.0); // should fold to 1024.0 + } + + // Test 2: pow(final B, final E) -> B^E + @Test + @IR(failOn = {IRNode.POW_D}) + public static double constantStaticFolding() { + return Math.pow(B, E); // should fold to B^E + } + + // Test 3: pow(b, 0.0) -> 1.0 + @Test + @IR(failOn = {IRNode.POW_D}) + @Arguments(values = {Argument.RANDOM_EACH}) + public static double expZero(double b) { + return Math.pow(b, 0.0); + } + + // Test 4: pow(b, 1.0) -> b (identity) + @Test + @IR(failOn = {IRNode.POW_D}) + @Arguments(values = {Argument.RANDOM_EACH}) + public static double expOne(double b) { + return Math.pow(b, 1.0); + } + + // Test 5: pow(b, NaN) -> NaN + @Test + @IR(failOn = {IRNode.POW_D}) + @Arguments(values = {Argument.RANDOM_EACH}) + public static double expNaN(double b) { + return Math.pow(b, Double.NaN); + } + + // Test 6: pow(b, 2.0) -> b * b + // More tests in TestPow2Opt.java + @Test + @IR(failOn = {IRNode.POW_D}) + @IR(counts = {IRNode.MUL_D, "1"}) + @Arguments(values = {Argument.RANDOM_EACH}) + public static double expTwo(double b) { + return Math.pow(b, 2.0); + } + + // Test 7: pow(b, 0.5) -> b <= 0.0 ? pow(b, 0.5) : sqrt(b) + // More tests in TestPow0Dot5Opt.java + @Test + @IR(counts = {IRNode.IF, "1"}) + @IR(counts = {IRNode.SQRT_D, "1"}) + @IR(counts = {".*CallLeaf.*pow.*", "1"}, phase = CompilePhase.BEFORE_MATCHING) + @Arguments(values = {Argument.RANDOM_EACH}) + public static double expDot5(double b) { + return Math.pow(b, 0.5); // expand to: if (b > 0) { sqrt(b) } else { call(b) } + } + + // Test 8: non-constant exponent stays as call + @Test + @IR(counts = {IRNode.POW_D, "1"}) + @Arguments(values = {Argument.RANDOM_EACH, Argument.RANDOM_EACH}) + public static double nonConstant(double b, double e) { + return Math.pow(b, e); + } + + // Test 9: late constant discovery on base (after loop opts) + @Test + @IR(counts = {IRNode.POW_D, "1"}, phase = CompilePhase.AFTER_PARSING) + @IR(failOn = {IRNode.POW_D}) + public static double lateBaseConstant() { + double base = 0; + for (int i = 0; i < 4; i++) { + if ((i % 2) == 0) { + base = B; + } + } + // After loop opts, base == B (constant), so pow(B, E) folds + return Math.pow(base, E); + } + + // Test 10: late constant discovery on exp (after loop opts) + @Test + @IR(counts = {IRNode.POW_D, "1"}, phase = CompilePhase.AFTER_PARSING) + @IR(failOn = {IRNode.POW_D}) + public static double lateExpConstant() { + double exp = 0; + for (int i = 0; i < 4; i++) { + if ((i % 2) == 0) { + exp = E; + } + } + // After loop opts, exp == E (constant), so pow(B, E) folds + return Math.pow(B, exp); + } + + // Test 11: late constant discoveries on both base and exp (after loop opts) + @Test + @IR(counts = {IRNode.POW_D, "1"}, phase = CompilePhase.AFTER_PARSING) + @IR(failOn = {IRNode.POW_D}) + public static double lateBothConstant() { + double base = 0, exp = 0; + for (int i = 0; i < 4; i++) { + if ((i % 2) == 0) { + base = B; + exp = E; + } + } + // After loop opts, base = B, exp == E, so pow(B, E) folds + return Math.pow(base, exp); + } + + private static void assertEQWithinOneUlp(double expected, double observed) { + if (Double.isNaN(expected) && Double.isNaN(observed)) return; + + // Math.pow() requires result must be within 1 ulp of the respective magnitude + double ulp = Math.max(Math.ulp(expected), Math.ulp(observed)); + if (Math.abs(expected - observed) > ulp) { + throw new AssertionError(String.format( + "expect = %x, observed = %x, ulp = %x", + Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(observed), Double.doubleToRawLongBits(ulp) + )); + } + } + + private static void testCorrectness() { + // No need to warm up for intrinsics + Asserts.assertEQ(1024.0d, constantLiteralFolding()); + + double BE = StrictMath.pow(B, E); + assertEQWithinOneUlp(BE, constantStaticFolding()); + assertEQWithinOneUlp(BE, lateBaseConstant()); + assertEQWithinOneUlp(BE, lateExpConstant()); + assertEQWithinOneUlp(BE, lateBothConstant()); + + Generator anyBits = G.anyBitsDouble(); + Generator largeDoubles = G.uniformDoubles(Long.MAX_VALUE, Double.MAX_VALUE); + Generator doubles = G.doubles(); + double[] values = { + Double.MIN_VALUE, Double.MIN_NORMAL, -42.0d, -1.0d, -0.0d, +0.0d, 0.5d, 1.0d, 2.0d, 123d, Double.MAX_VALUE, + Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN, + UNIFORMS.next(), UNIFORMS.next(), + largeDoubles.next(), -largeDoubles.next(), // some sufficiently large magnitudes + anyBits.next(), anyBits.next(), // any bits with potentially more NaN representation + doubles.next(), doubles.next() // a healthy sprinkle of whatever else is possible + }; + + for (double b : values) { + // Strength reduced, so we know the bits matches exactly + Asserts.assertEQ(1.0d, expZero(b)); + Asserts.assertEQ(b, expOne(b)); + Asserts.assertEQ(b * b, expTwo(b)); + + assertEQWithinOneUlp(Double.NaN, expNaN(b)); + + // Runtime calls, so make sure the result is within 1 ulp + assertEQWithinOneUlp(StrictMath.pow(b, 0.5d), expDot5(b)); + + for (double e : values) { + assertEQWithinOneUlp(StrictMath.pow(b, e), nonConstant(b, e)); + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java b/test/hotspot/jtreg/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java index f9b2e156f0c..10ae924c794 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java +++ b/test/hotspot/jtreg/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java @@ -50,7 +50,7 @@ public abstract class IntrinsicBase extends CompilerWhiteBoxTest { int expectedIntrinsicCount = 0; - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { if (TIERED_COMPILATION) { int max_level = TIERED_STOP_AT_LEVEL; expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0; diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java index 22b3bba854c..b8a3896294b 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java @@ -122,7 +122,7 @@ public class DigestOptionsBase extends CommandLineOptionTest { case DigestOptionsBase.USE_SHA512_INTRINSICS_OPTION: return IntrinsicPredicates.isSHA512IntrinsicAvailable(); case DigestOptionsBase.USE_SHA3_INTRINSICS_OPTION: - return IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE; + return IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE; default: throw new Error("Unexpected option " + optionName); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java index d3c0a4a8da7..c47591d75da 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java @@ -28,10 +28,7 @@ * @summary Verify UseSHA3Intrinsics option processing on supported CPU. * @library /test/lib / * @requires vm.flagless - * @requires os.arch == "aarch64" & os.family == "mac" - * @comment sha3 is only implemented on AArch64 for now. - * UseSHA3Intrinsics is only auto-enabled on Apple silicon, because it - * may introduce performance regression on others. See JDK-8297092. + * @requires (os.arch == "aarch64" | os.arch == "amd64" | os.arch == "x86_64") * * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java index 4b3914e75fd..f1c7069c317 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java @@ -80,7 +80,8 @@ public class GenericTestCaseForSupportedCPU extends // Verify that if -XX:-UseSHA is passed to the JVM, it is not possible // to enable the tested option and a warning is printed. CommandLineOptionTest.verifySameJVMStartup( - new String[] { DigestOptionsBase.getWarningForUnsupportedCPU(optionName) }, + new String[] { "warning: " }, // Accept any warning message, e.g. "requires that UseSHA is enabled" + // or the common "not available on this CPU" message. null, shouldPassMessage, String.format("Enabling option '%s' should not be possible and should result in a warning if %s was passed to JVM", diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java index 85f6f280ccb..b2a0720e6e8 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java @@ -71,7 +71,8 @@ public class GenericTestCaseForUnsupportedCPU extends // a warning will occur in VM output if UseSHA is disabled. if (!optionName.equals(DigestOptionsBase.USE_SHA_OPTION)) { CommandLineOptionTest.verifySameJVMStartup( - new String[] { DigestOptionsBase.getWarningForUnsupportedCPU(optionName) }, + new String[] { "warning: " }, // Accept any warning message, e.g. "requires that UseSHA is enabled" + // or the common "not available on this CPU" message. null, shouldPassMessage, shouldPassMessage, diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestOpaqueConstantBoolNodes.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestOpaqueConstantBoolNodes.java index b8db97f7ecb..c32eba5aa77 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestOpaqueConstantBoolNodes.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestOpaqueConstantBoolNodes.java @@ -26,6 +26,7 @@ * @bug 8374582 * @summary Tests the creation and removal of opaque nodes at range checks points in string intrinsics. * @requires vm.flagless + * @requires os.arch != "riscv64" | vm.cpu.features ~= ".*rvv.*" * @library /test/lib / * @run driver ${test.main.class} */ diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java index a7d2cfe7fa7..ec99bba19d2 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,12 +89,16 @@ public class TestStringIntrinsicRangeChecks { for (int srcOff = 0; srcOff < SIZE; ++srcOff) { for (int dstOff = 0; dstOff < SIZE; ++dstOff) { for (int len = 0; len < SIZE; ++len) { + int srcEnd = srcOff + len; + int dstEnd = dstOff + len; // Check for potential overlows in source or destination array boolean srcOverflow = (srcOff + len) > SIZE; boolean srcOverflowB = (2*srcOff + 2*len) > SIZE; boolean dstOverflow = (dstOff + len) > SIZE; boolean dstOverflowB = (2*dstOff + 2*len) > SIZE; - boolean getCharsOver = (srcOff < len) && ((2*(len-1) >= SIZE) || ((dstOff + len - srcOff) > SIZE)); + boolean getCharsOver = srcOff > srcEnd || (2*srcEnd) > SIZE || // src + (2*len) > SIZE || // len + dstOff > dstEnd || dstEnd > SIZE; // dst // Check if an exception is thrown and bail out if result is inconsistent with above // assumptions (for example, an exception was not thrown although an overflow happened). check(compressByte, srcOverflowB || dstOverflow, byteArray, srcOff, SIZE, dstOff, len); @@ -102,7 +106,7 @@ public class TestStringIntrinsicRangeChecks { check(inflateByte, srcOverflow || dstOverflowB, byteArray, srcOff, SIZE, dstOff, len); check(inflateChar, srcOverflow || dstOverflow, byteArray, srcOff, SIZE, dstOff, len); check(toBytes, srcOverflow, charArray, srcOff, len); - check(getChars, getCharsOver, byteArray, srcOff, len, SIZE, dstOff); + check(getChars, getCharsOver, byteArray, srcOff, srcEnd, SIZE, dstOff); } } } diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index e0302e7b5aa..1e2e2d50232 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -159,7 +159,6 @@ public class GetResolvedJavaTypeTest { /* a compressed parameter for tested method is set to false because unsafe.getKlassPointer always returns uncompressed pointer */ private static final boolean COMPRESSED = false; - // = WB.getBooleanVMFlag("UseCompressedClassPointers"); private static long getPtrToKlass() { Field field; diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java index adbad3e0b4d..b0c7d11edfe 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -119,7 +119,6 @@ public class DataPatchTest extends CodeInstallationTest { @Test public void testInlineNarrowMetadata() { - Assume.assumeTrue(config.useCompressedClassPointers); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); @@ -144,7 +143,6 @@ public class DataPatchTest extends CodeInstallationTest { @Test public void testNarrowMetadataInDataSection() { - Assume.assumeTrue(config.useCompressedClassPointers); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java index a26872b96ae..4b0065d0e70 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -36,7 +36,6 @@ public class TestHotSpotVMConfig extends HotSpotVMConfigAccess { } public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - public final boolean useCompressedClassPointers = getFlag("UseCompressedClassPointers", Boolean.class); public final long narrowOopBase = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_base", Long.class, "address"); public final int narrowOopShift = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_shift", Integer.class, "int"); diff --git a/test/hotspot/jtreg/compiler/lib/compile_framework/CompileFramework.java b/test/hotspot/jtreg/compiler/lib/compile_framework/CompileFramework.java index d9a98582aec..3612f5ab3d3 100644 --- a/test/hotspot/jtreg/compiler/lib/compile_framework/CompileFramework.java +++ b/test/hotspot/jtreg/compiler/lib/compile_framework/CompileFramework.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,8 @@ import java.lang.reflect.Method; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import jtreg.SkippedException; /** * This is the entry-point for the Compile Framework. Its purpose it to allow @@ -132,10 +134,31 @@ public class CompileFramework { } catch (IllegalAccessException e) { throw new CompileFrameworkException("Illegal access:", e); } catch (InvocationTargetException e) { + // Rethrow jtreg.SkippedException so the tests are properly skipped. + // If we wrapped the SkippedException instead, it would get buried + // in the exception causes and cause a failed test instead. + findJtregSkippedExceptionInCauses(e).ifPresent(ex -> { throw ex; }); throw new CompileFrameworkException("Invocation target:", e); } } + private static Optional findJtregSkippedExceptionInCauses(Throwable ex) { + while (ex != null) { + // jtreg.SkippedException can be from a different classloader, comparing by name + if (ex.getClass().getName().equals(SkippedException.class.getName())) { + return Optional.of((RuntimeException) ex); + } + + if (ex.getCause() == ex) { + break; + } + + ex = ex.getCause(); + } + + return Optional.empty(); + } + private Method findMethod(String className, String methodName) { Class c = getClass(className); Method[] methods = c.getDeclaredMethods(); diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index f488e930710..8885d1283df 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -24,7 +24,7 @@ package compiler.lib.ir_framework; import compiler.lib.ir_framework.driver.irmatching.mapping.*; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.CheckedTestFrameworkException; import compiler.lib.ir_framework.shared.TestFormat; import compiler.lib.ir_framework.shared.TestFormatException; @@ -117,13 +117,14 @@ public class IRNode { public static final String VECTOR_SIZE_32 = VECTOR_SIZE + "32"; public static final String VECTOR_SIZE_64 = VECTOR_SIZE + "64"; - private static final String TYPE_BYTE = "B"; - private static final String TYPE_CHAR = "C"; - private static final String TYPE_SHORT = "S"; - private static final String TYPE_INT = "I"; - private static final String TYPE_LONG = "J"; - private static final String TYPE_FLOAT = "F"; - private static final String TYPE_DOUBLE = "D"; + private static final String TYPE_BYTE = "B"; + private static final String TYPE_CHAR = "C"; + private static final String TYPE_SHORT = "S"; + private static final String TYPE_INT = "I"; + private static final String TYPE_LONG = "J"; + private static final String TYPE_FLOAT = "F"; + private static final String TYPE_DOUBLE = "D"; + private static final String TYPE_BOOLEAN = "Z"; /** * IR placeholder string to regex-for-compile-phase map. @@ -640,6 +641,11 @@ public class IRNode { beforeMatchingNameRegex(CONV, "Conv"); } + public static final String CONV_D2F = PREFIX + "CONV_D2F" + POSTFIX; + static { + beforeMatchingNameRegex(CONV_D2F, "ConvD2F"); + } + public static final String CONV_D2I = PREFIX + "CONV_D2I" + POSTFIX; static { beforeMatchingNameRegex(CONV_D2I, "ConvD2I"); @@ -650,6 +656,11 @@ public class IRNode { beforeMatchingNameRegex(CONV_D2L, "ConvD2L"); } + public static final String CONV_F2D = PREFIX + "CONV_F2D" + POSTFIX; + static { + beforeMatchingNameRegex(CONV_F2D, "ConvF2D"); + } + public static final String CONV_F2HF = PREFIX + "CONV_F2HF" + POSTFIX; static { beforeMatchingNameRegex(CONV_F2HF, "ConvF2HF"); @@ -1100,6 +1111,11 @@ public class IRNode { vectorNode(LOAD_VECTOR_D, "LoadVector", TYPE_DOUBLE); } + public static final String LOAD_VECTOR_Z = VECTOR_PREFIX + "LOAD_VECTOR_Z" + POSTFIX; + static { + vectorNode(LOAD_VECTOR_Z, "LoadVector", TYPE_BOOLEAN); + } + public static final String LOAD_VECTOR_GATHER = PREFIX + "LOAD_VECTOR_GATHER" + POSTFIX; static { beforeMatchingNameRegex(LOAD_VECTOR_GATHER, "LoadVectorGather"); @@ -1478,6 +1494,12 @@ public class IRNode { beforeMatchingNameRegex(VECTOR_MASK_FIRST_TRUE, "VectorMaskFirstTrue"); } + // Can only be used if libjsvml or libsleef is available + public static final String CALL_LEAF_VECTOR = PREFIX + "CALL_LEAF_VECTOR" + POSTFIX; + static { + beforeMatchingNameRegex(CALL_LEAF_VECTOR, "CallLeafVector"); + } + // Can only be used if avx512_vnni is available. public static final String MUL_ADD_VS2VI_VNNI = PREFIX + "MUL_ADD_VS2VI_VNNI" + POSTFIX; static { @@ -1995,6 +2017,11 @@ public class IRNode { beforeMatchingNameRegex(SQRT_HF, "SqrtHF"); } + public static final String SQRT_D = PREFIX + "SQRT_D" + POSTFIX; + static { + beforeMatchingNameRegex(SQRT_D, "SqrtD"); + } + public static final String SQRT_F = PREFIX + "SQRT_F" + POSTFIX; static { beforeMatchingNameRegex(SQRT_F, "SqrtF"); @@ -3107,6 +3134,12 @@ public class IRNode { macroNodes(MOD_D, regex); } + public static final String POW_D = PREFIX + "POW_D" + POSTFIX; + static { + String regex = START + "PowD" + MID + END; + macroNodes(POW_D, regex); + } + public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX; static { fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole"); @@ -3491,11 +3524,11 @@ public class IRNode { */ public static int getTypeSizeInBytes(String typeString) { return switch (typeString) { - case TYPE_BYTE -> 1; - case TYPE_CHAR, TYPE_SHORT -> 2; - case TYPE_INT, TYPE_FLOAT -> 4; - case TYPE_LONG, TYPE_DOUBLE -> 8; - default -> 0; + case TYPE_BYTE, TYPE_BOOLEAN -> 1; + case TYPE_CHAR, TYPE_SHORT -> 2; + case TYPE_INT, TYPE_FLOAT -> 4; + case TYPE_LONG, TYPE_DOUBLE -> 8; + default -> 0; }; } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java index 137efd18136..debb025f449 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java @@ -881,8 +881,7 @@ public class TestFramework { if (shouldVerifyIR) { try { TestClassParser testClassParser = new TestClassParser(testClass, allowNotCompilable); - Matchable testClassMatchable = testClassParser.parse(testVMProcess.getHotspotPidFileName(), - testVMProcess.getApplicableIRRules()); + Matchable testClassMatchable = testClassParser.parse(testVMProcess.testVmData()); IRMatcher matcher = new IRMatcher(testClassMatchable); matcher.match(); } catch (IRViolationException e) { diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java index 931d687b0bc..00a9b93d124 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java @@ -24,6 +24,7 @@ package compiler.lib.ir_framework.driver; import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.driver.network.TestVMData; import compiler.lib.ir_framework.shared.TestFrameworkException; import compiler.lib.ir_framework.shared.TestFrameworkSocket; import compiler.lib.ir_framework.shared.NoTestsRunException; @@ -58,10 +59,9 @@ public class TestVMProcess { private static String lastTestVMOutput = ""; private final ArrayList cmds; - private String hotspotPidFileName; private String commandLine; private OutputAnalyzer oa; - private String applicableIRRules; + private final TestVMData testVmData; public TestVMProcess(List additionalFlags, Class testClass, Set> helperClasses, int defaultWarmup, boolean allowNotCompilable, boolean testClassesOnBootClassPath) { @@ -72,20 +72,18 @@ public class TestVMProcess { allowNotCompilable, testClassesOnBootClassPath); start(); } - processSocketOutput(socket); checkTestVMExitCode(); + String hotspotPidFileName = String.format("hotspot_pid%d.log", oa.pid()); + testVmData = socket.testVmData(hotspotPidFileName, allowNotCompilable); + testVmData.printJavaMessages(); } public String getCommandLine() { return commandLine; } - public String getApplicableIRRules() { - return applicableIRRules; - } - - public String getHotspotPidFileName() { - return hotspotPidFileName; + public TestVMData testVmData() { + return testVmData; } public static String getLastTestVMOutput() { @@ -172,55 +170,9 @@ public class TestVMProcess { process.command().add(1, "-DReproduce=true"); // Add after "/path/to/bin/java" in order to rerun the Test VM directly commandLine = "Command Line:" + System.lineSeparator() + String.join(" ", process.command()) + System.lineSeparator(); - hotspotPidFileName = String.format("hotspot_pid%d.log", oa.pid()); lastTestVMOutput = oa.getOutput(); } - /** - * Process the socket output: All prefixed lines are dumped to the standard output while the remaining lines - * represent the Applicable IR Rules used for IR matching later. - */ - private void processSocketOutput(TestFrameworkSocket socket) { - String output = socket.getOutput(); - if (socket.hasStdOut()) { - StringBuilder testListBuilder = new StringBuilder(); - StringBuilder messagesBuilder = new StringBuilder(); - StringBuilder nonStdOutBuilder = new StringBuilder(); - Scanner scanner = new Scanner(output); - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - if (line.startsWith(TestFrameworkSocket.STDOUT_PREFIX)) { - // Exclude [STDOUT] from message. - line = line.substring(TestFrameworkSocket.STDOUT_PREFIX.length()); - if (line.startsWith(TestFrameworkSocket.TESTLIST_TAG)) { - // Exclude [TESTLIST] from message for better formatting. - line = "> " + line.substring(TestFrameworkSocket.TESTLIST_TAG.length() + 1); - testListBuilder.append(line).append(System.lineSeparator()); - } else { - messagesBuilder.append(line).append(System.lineSeparator()); - } - } else { - nonStdOutBuilder.append(line).append(System.lineSeparator()); - } - } - System.out.println(); - if (!testListBuilder.isEmpty()) { - System.out.println("Run flag defined test list"); - System.out.println("--------------------------"); - System.out.println(testListBuilder); - System.out.println(); - } - if (!messagesBuilder.isEmpty()) { - System.out.println("Messages from Test VM"); - System.out.println("---------------------"); - System.out.println(messagesBuilder); - } - applicableIRRules = nonStdOutBuilder.toString(); - } else { - applicableIRRules = output; - } - } - private void checkTestVMExitCode() { final int exitCode = oa.getExitValue(); if (EXCLUDE_RANDOM || REPORT_STDOUT || (VERBOSE && exitCode == 0)) { diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java index 893312c5196..137766b0011 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java @@ -31,8 +31,8 @@ import compiler.lib.ir_framework.driver.irmatching.MatchResult; import compiler.lib.ir_framework.driver.irmatching.Matchable; import compiler.lib.ir_framework.driver.irmatching.MatchableMatcher; import compiler.lib.ir_framework.driver.irmatching.irrule.IRRule; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; import compiler.lib.ir_framework.driver.network.testvm.java.IRRuleIds; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.TestFormat; import compiler.lib.ir_framework.shared.TestFormatException; @@ -98,7 +98,7 @@ public class IRMethod implements IRMethodMatchable { List match = matcher.match(); long endTime = System.nanoTime(); long duration = (endTime - startTime); - System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1000000) + " ms"); + System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1_000_000) + " ms"); return new IRMethodMatchResult(method, match); } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/IRRule.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/IRRule.java index 749942eabd6..5c48394851b 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/IRRule.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/IRRule.java @@ -31,7 +31,7 @@ import compiler.lib.ir_framework.driver.irmatching.Matchable; import compiler.lib.ir_framework.driver.irmatching.MatchableMatcher; import compiler.lib.ir_framework.driver.irmatching.irrule.phase.CompilePhaseIRRule; import compiler.lib.ir_framework.driver.irmatching.irrule.phase.CompilePhaseIRRuleBuilder; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; /** * This class represents a generic {@link IR @IR} rule of an IR method. It contains a list of compile phase specific diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java index b86ae47e186..d8be8add2a2 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,10 @@ package compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.parsin import compiler.lib.ir_framework.CompilePhase; import compiler.lib.ir_framework.IRNode; +import compiler.lib.ir_framework.driver.SuccessOnlyConstraintException; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.Comparison; import compiler.lib.ir_framework.shared.TestFormat; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; -import compiler.lib.ir_framework.driver.SuccessOnlyConstraintException; import java.util.regex.Matcher; diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawConstraint.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawConstraint.java index 1c2fba218db..174136c7c28 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawConstraint.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawConstraint.java @@ -27,12 +27,12 @@ import compiler.lib.ir_framework.CompilePhase; import compiler.lib.ir_framework.IR; import compiler.lib.ir_framework.IRNode; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.Constraint; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; /** * Interface to represent a single raw constraint as found in the {@link IR @IR} annotation (i.e. {@link IRNode} * placeholder strings are not replaced by regexes, yet). A raw constraint can be parsed into a {@link Constraint} by - * calling {@link #parse(CompilePhase, String)}. This replaces the IR node placeholder strings by actual regexes and + * calling {@link #parse(CompilePhase, String, VMInfo)}. This replaces the IR node placeholder strings by actual regexes and * merges composite nodes together. * * @see Constraint diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawCountsConstraint.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawCountsConstraint.java index 9934a830a06..a616f1a0455 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawCountsConstraint.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawCountsConstraint.java @@ -26,12 +26,11 @@ package compiler.lib.ir_framework.driver.irmatching.irrule.constraint.raw; import compiler.lib.ir_framework.CompilePhase; import compiler.lib.ir_framework.IR; -import compiler.lib.ir_framework.IRNode; import compiler.lib.ir_framework.TestFramework; import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.parsing.RawIRNode; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.Constraint; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; import compiler.lib.ir_framework.driver.SuccessOnlyConstraintException; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.Comparison; import compiler.lib.ir_framework.shared.TestFormat; import compiler.lib.ir_framework.shared.TestFormatException; diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawFailOnConstraint.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawFailOnConstraint.java index 4bd334f1f08..6bd3f8f3448 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawFailOnConstraint.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/constraint/raw/RawFailOnConstraint.java @@ -29,7 +29,7 @@ import compiler.lib.ir_framework.TestFramework; import compiler.lib.ir_framework.driver.SuccessOnlyConstraintException; import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.parsing.RawIRNode; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.Constraint; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.Comparison; /** diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/CompilePhaseIRRuleBuilder.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/CompilePhaseIRRuleBuilder.java index 5d327135c22..4d46a53c46b 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/CompilePhaseIRRuleBuilder.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/CompilePhaseIRRuleBuilder.java @@ -34,7 +34,7 @@ import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.parsing import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.parsing.RawFailOn; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.Constraint; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.raw.RawConstraint; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.TestFormat; import java.util.*; diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/DefaultPhaseRawConstraintParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/DefaultPhaseRawConstraintParser.java index 1f837883978..5f8f597a4fe 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/DefaultPhaseRawConstraintParser.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/phase/DefaultPhaseRawConstraintParser.java @@ -31,7 +31,7 @@ import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.Counts; import compiler.lib.ir_framework.driver.irmatching.irrule.checkattribute.FailOn; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.Constraint; import compiler.lib.ir_framework.driver.irmatching.irrule.constraint.raw.RawConstraint; -import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.TestFrameworkException; import java.util.ArrayList; @@ -71,7 +71,7 @@ class DefaultPhaseRawConstraintParser { for (RawConstraint rawConstraint : rawConstraints) { CompilePhase compilePhase = rawConstraint.defaultCompilePhase(); List checkAttribute = - matchableForCompilePhase.computeIfAbsent(compilePhase, k -> new ArrayList<>()); + matchableForCompilePhase.computeIfAbsent(compilePhase, _ -> new ArrayList<>()); checkAttribute.add(rawConstraint.parse(compilePhase, compilation.output(compilePhase), vmInfo)); } return replaceConstraintsWithCheckAttribute(matchableForCompilePhase, checkAttributeType); @@ -113,7 +113,7 @@ class DefaultPhaseRawConstraintParser { private static void addCheckAttribute(Map failOnForCompilePhase, Map> result) { failOnForCompilePhase.forEach((compilePhase, matchable) -> { - List list = result.computeIfAbsent(compilePhase, k -> new ArrayList<>()); + List list = result.computeIfAbsent(compilePhase, _ -> new ArrayList<>()); list.add(matchable); }); } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/ApplicableIRRulesParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/ApplicableIRRulesParser.java index be44c3f3d91..67a04df2b58 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/ApplicableIRRulesParser.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/ApplicableIRRulesParser.java @@ -25,19 +25,13 @@ package compiler.lib.ir_framework.driver.irmatching.parser; import compiler.lib.ir_framework.IR; import compiler.lib.ir_framework.TestFramework; -import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.HotSpotPidFileParser; +import compiler.lib.ir_framework.driver.network.testvm.java.ApplicableIRRules; import compiler.lib.ir_framework.driver.network.testvm.java.IRRuleIds; import compiler.lib.ir_framework.shared.TestFormat; -import compiler.lib.ir_framework.shared.TestFrameworkException; -import compiler.lib.ir_framework.test.ApplicableIRRulesPrinter; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Class to parse the Applicable IR Rules emitted by the Test VM and creating {@link TestMethod} objects for each entry. @@ -45,11 +39,6 @@ import java.util.regex.Pattern; * @see TestMethod */ public class ApplicableIRRulesParser { - - private static final boolean PRINT_APPLICABLE_IR_RULES = Boolean.parseBoolean(System.getProperty("PrintApplicableIRRules", "false")); - private static final Pattern APPLICABLE_IR_RULES_PATTERN = - Pattern.compile("(?<=" + ApplicableIRRulesPrinter.START + "\r?\n).*\\R([\\s\\S]*)(?=" + ApplicableIRRulesPrinter.END + ")"); - private final Map testMethods; private final Class testClass; @@ -62,81 +51,19 @@ public class ApplicableIRRulesParser { * Parse the Applicable IR rules passed as parameter and return a "test name" -> TestMethod map that contains an * entry for each method that needs to be IR matched on. */ - public TestMethods parse(String applicableIRRules) { - if (TestFramework.VERBOSE || PRINT_APPLICABLE_IR_RULES) { - System.out.println("Read Applicable IR Rules from Test VM:"); - System.out.println(applicableIRRules); - } - createTestMethodMap(applicableIRRules, testClass); + public TestMethods parse(ApplicableIRRules applicableIRRules) { + createTestMethodMap(applicableIRRules); // We could have found format errors in @IR annotations. Report them now with an exception. TestFormat.throwIfAnyFailures(); return new TestMethods(testMethods); } - /** - * Sets up a map testname -> TestMethod map. The TestMethod object will later be filled with the ideal and opto - * assembly output in {@link HotSpotPidFileParser}. - */ - private void createTestMethodMap(String applicableIRRules, Class testClass) { - Map irRulesMap = parseApplicableIRRules(applicableIRRules); - createTestMethodsWithApplicableIRRules(testClass, irRulesMap); - } - - /** - * Read the Applicable IR Rules emitted by the Test VM to decide if an @IR rule must be checked for a method. - */ - private Map parseApplicableIRRules(String applicableIRRules) { - Map irRulesMap = new HashMap<>(); - String[] applicableIRRulesLines = getApplicableIRRulesLines(applicableIRRules); - for (String s : applicableIRRulesLines) { - String line = s.trim(); - String[] splitLine = line.split(","); - if (splitLine.length < 2) { - throw new TestFrameworkException("Invalid Applicable IR Rules format. No comma found: " + splitLine[0]); - } - String testName = splitLine[0]; - IRRuleIds irRuleIds = parseIrRulesIds(splitLine); - irRulesMap.put(testName, irRuleIds); - } - return irRulesMap; - } - - /** - * Parse the Applicable IR Rules lines without header, explanation line and footer and return them in an array. - */ - private String[] getApplicableIRRulesLines(String applicableIRRules) { - Matcher matcher = APPLICABLE_IR_RULES_PATTERN.matcher(applicableIRRules); - TestFramework.check(matcher.find(), "Did not find Applicable IR Rules in:" + - System.lineSeparator() + applicableIRRules); - String lines = matcher.group(1).trim(); - if (lines.isEmpty()) { - // Nothing to IR match. - return new String[0]; - } - return lines.split("\\R"); - } - - /** - * Parse rule indexes from a single line of the Applicable IR Rules in the format: - */ - private IRRuleIds parseIrRulesIds(String[] splitLine) { - List irRuleIds = new ArrayList<>(); - for (int i = 1; i < splitLine.length; i++) { - try { - irRuleIds.add(Integer.parseInt(splitLine[i])); - } catch (NumberFormatException e) { - throw new TestFrameworkException("Invalid Applicable IR Rules format. No number found: " + splitLine[i]); - } - } - return new IRRuleIds(irRuleIds); - } - - private void createTestMethodsWithApplicableIRRules(Class testClass, Map irRulesMap) { + private void createTestMethodMap(ApplicableIRRules applicableIRRules) { for (Method m : testClass.getDeclaredMethods()) { IR[] irAnnos = m.getAnnotationsByType(IR.class); if (irAnnos.length > 0) { // Validation of legal @IR attributes and placement of the annotation was already done in Test VM. - IRRuleIds irRuleIds = irRulesMap.get(m.getName()); + IRRuleIds irRuleIds = applicableIRRules.ruleIds(m.getName()); validateIRRuleIds(m, irAnnos, irRuleIds); if (hasAnyApplicableIRRules(irRuleIds)) { testMethods.put(m.getName(), new TestMethod(m, irAnnos, irRuleIds)); @@ -146,10 +73,7 @@ public class ApplicableIRRulesParser { } private void validateIRRuleIds(Method m, IR[] irAnnos, IRRuleIds irRuleIds) { - TestFramework.check(irRuleIds != null, "Should find method name in validIrRulesMap for " + m); - TestFramework.check(!irRuleIds.isEmpty(), "Did not find any rule indices for " + m); - TestFramework.check((irRuleIds.first() >= 1 || irRuleIds.first() == ApplicableIRRulesPrinter.NO_RULE_APPLIED) - && irRuleIds.last() <= irAnnos.length, + TestFramework.check((irRuleIds.isEmpty() || (irRuleIds.first() >= 1 && irRuleIds.last() <= irAnnos.length)), "Invalid IR rule index found in validIrRulesMap for " + m); } @@ -157,6 +81,6 @@ public class ApplicableIRRulesParser { * Does the list of IR rules contain any applicable IR rules for the given conditions? */ private boolean hasAnyApplicableIRRules(IRRuleIds irRuleIds) { - return irRuleIds.first() != ApplicableIRRulesPrinter.NO_RULE_APPLIED; + return !irRuleIds.isEmpty(); } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/IRMethodBuilder.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/IRMethodBuilder.java index 46a237576e6..5ce93df434c 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/IRMethodBuilder.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/IRMethodBuilder.java @@ -32,6 +32,7 @@ import compiler.lib.ir_framework.driver.irmatching.irmethod.NotCompilableIRMetho import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.HotSpotPidFileParser; import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.LoggedMethod; import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.LoggedMethods; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import java.util.Map; import java.util.SortedSet; diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/TestClassParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/TestClassParser.java index 2329b41afbe..30a766ddd4e 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/TestClassParser.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/TestClassParser.java @@ -23,6 +23,7 @@ package compiler.lib.ir_framework.driver.irmatching.parser; +import compiler.lib.ir_framework.TestFramework; import compiler.lib.ir_framework.driver.irmatching.Matchable; import compiler.lib.ir_framework.driver.irmatching.NonIRTestClass; import compiler.lib.ir_framework.driver.irmatching.TestClass; @@ -30,6 +31,9 @@ import compiler.lib.ir_framework.driver.irmatching.irmethod.IRMethod; import compiler.lib.ir_framework.driver.irmatching.irmethod.IRMethodMatchable; import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.HotSpotPidFileParser; import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.LoggedMethods; +import compiler.lib.ir_framework.driver.network.TestVMData; +import compiler.lib.ir_framework.driver.network.testvm.java.ApplicableIRRules; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; import compiler.lib.ir_framework.shared.TestFormat; import java.util.SortedSet; @@ -53,20 +57,21 @@ public class TestClassParser { * Parse the Applicable IR Rules and hotspot_pid* file to create a collection of {@link IRMethod} objects. * Return a default/empty TestClass object if there are no applicable @IR rules in any method of the test class. */ - public Matchable parse(String hotspotPidFileName, String applicableIRRules) { - ApplicableIRRulesParser applicableIRRulesParser = new ApplicableIRRulesParser(testClass); - TestMethods testMethods = applicableIRRulesParser.parse(applicableIRRules); - VMInfo vmInfo = VMInfoParser.parseVMInfo(applicableIRRules); - if (testMethods.hasTestMethods()) { - HotSpotPidFileParser hotSpotPidFileParser = new HotSpotPidFileParser(testClass.getName(), testMethods); - LoggedMethods loggedMethods = hotSpotPidFileParser.parse(hotspotPidFileName); - return createTestClass(testMethods, loggedMethods, vmInfo); + public Matchable parse(TestVMData testVmData) { + ApplicableIRRules applicableIrRules = testVmData.applicableIRRules(); + if (applicableIrRules.hasNoMethods()) { + return new NonIRTestClass(); } - return new NonIRTestClass(); + ApplicableIRRulesParser applicableIRRulesParser = new ApplicableIRRulesParser(testClass); + TestMethods testMethods = applicableIRRulesParser.parse(testVmData.applicableIRRules()); + TestFramework.check(testMethods.hasTestMethods(), "must have at least one"); + HotSpotPidFileParser hotSpotPidFileParser = new HotSpotPidFileParser(testClass.getName(), testMethods); + LoggedMethods loggedMethods = hotSpotPidFileParser.parse(testVmData.hotspotPidFileName()); + return createTestClass(testMethods, loggedMethods, testVmData.vmInfo()); } /** - * Create test class with IR methods for all test methods identified by {@link ApplicableIRRulesParser} by combining them + * Create test class with IR methods for all test methods found in {@link ApplicableIRRules} by combining them * with the parsed compilation output from {@link HotSpotPidFileParser}. */ private Matchable createTestClass(TestMethods testMethods, LoggedMethods loggedMethods, VMInfo vmInfo) { diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfoParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfoParser.java deleted file mode 100644 index 2b17303f1a7..00000000000 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfoParser.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023, 2026, 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 compiler.lib.ir_framework.driver.irmatching.parser; - -import compiler.lib.ir_framework.TestFramework; -import compiler.lib.ir_framework.shared.TestFrameworkException; -import compiler.lib.ir_framework.test.VMInfoPrinter; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Class to parse the VMInfo emitted by the Test VM and creating {@link VMInfo} objects for each entry. - * - * @see VMInfo - */ -public class VMInfoParser { - - private static final Pattern VM_INFO_PATTERN = - Pattern.compile("(?<=" + VMInfoPrinter.START_VM_INFO + "\r?\n).*\\R([\\s\\S]*)(?=" + VMInfoPrinter.END_VM_INFO + ")"); - - /** - * Extract VMInfo from the applicableIRRules. - */ - public static VMInfo parseVMInfo(String applicableIRRules) { - Map map = new HashMap<>(); - String[] lines = getVMInfoLines(applicableIRRules); - for (String s : lines) { - String line = s.trim(); - String[] splitLine = line.split(":", 2); - if (splitLine.length != 2) { - throw new TestFrameworkException("Invalid VMInfo key:value encoding. Found: " + splitLine[0]); - } - String key = splitLine[0]; - String value = splitLine[1]; - map.put(key, value); - } - return new VMInfo(map); - } - - /** - * Extract the VMInfo from the applicableIRRules string, strip away the header and return the individual key-value lines. - */ - private static String[] getVMInfoLines(String applicableIRRules) { - Matcher matcher = VM_INFO_PATTERN.matcher(applicableIRRules); - TestFramework.check(matcher.find(), "Did not find VMInfo in:" + System.lineSeparator() + applicableIRRules); - String lines = matcher.group(1).trim(); - if (lines.isEmpty()) { - // Nothing to IR match. - return new String[0]; - } - return lines.split("\\R"); - } -} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/TestVMData.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/TestVMData.java new file mode 100644 index 00000000000..59632ef1a48 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/TestVMData.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network; + +import compiler.lib.ir_framework.driver.irmatching.IRMatcher; +import compiler.lib.ir_framework.driver.network.testvm.java.ApplicableIRRules; +import compiler.lib.ir_framework.driver.network.testvm.java.JavaMessages; +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; +import compiler.lib.ir_framework.shared.TestFrameworkSocket; + +/** + * This class collects all the parsed data received over the {@link TestFrameworkSocket}. This data is required later + * in the {@link IRMatcher}. + */ +public class TestVMData { + private final JavaMessages javaMessages; + private final boolean allowNotCompilable; + private final String hotspotPidFileName; + + public TestVMData(JavaMessages javaMessages, String hotspotPidFileName, boolean allowNotCompilable) { + this.javaMessages = javaMessages; + this.hotspotPidFileName = hotspotPidFileName; + this.allowNotCompilable = allowNotCompilable; + } + + public ApplicableIRRules applicableIRRules() { + return javaMessages.applicableIRRules(); + } + + public VMInfo vmInfo() { + return javaMessages.vmInfo(); + } + + public String hotspotPidFileName() { + return hotspotPidFileName; + } + + public boolean allowNotCompilable() { + return allowNotCompilable; + } + + public void printJavaMessages() { + javaMessages.print(); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/TestVmMessageReader.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/TestVmMessageReader.java new file mode 100644 index 00000000000..a203fd367f7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/TestVmMessageReader.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm; + +import compiler.lib.ir_framework.driver.network.testvm.java.JavaMessageParser; +import compiler.lib.ir_framework.driver.network.testvm.java.JavaMessages; +import compiler.lib.ir_framework.shared.TestFrameworkException; +import compiler.lib.ir_framework.shared.TestFrameworkSocket; + +import java.io.BufferedReader; +import java.net.Socket; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +/** + * Dedicated reader for Test VM messages received by the {@link TestFrameworkSocket}. The reader is used as a task + * wrapped in a {@link Future}. The received messages are parsed with the {@link JavaMessageParser}. Once the Test VM + * is terminated, client connection is closed and the parsed messages can be fetched with {@link Future#get()} which + * calls {@link #call()}. + */ +public class TestVmMessageReader implements Callable { + private final Socket socket; + private final BufferedReader reader; + private final JavaMessageParser messageParser; + + public TestVmMessageReader(Socket socket, BufferedReader reader) { + this.socket = socket; + this.reader = reader; + this.messageParser = new JavaMessageParser(); + } + + @Override + public JavaMessages call() { + try (socket; reader) { + String line; + while ((line = reader.readLine()) != null) { + messageParser.parseLine(line); + } + return messageParser.output(); + } catch (Exception e) { + throw new TestFrameworkException("Error while reading Test VM socket messages", e); + } + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ApplicableIRRules.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ApplicableIRRules.java new file mode 100644 index 00000000000..eb41472057e --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ApplicableIRRules.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +import compiler.lib.ir_framework.IR; +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.driver.irmatching.IRMatcher; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Class to hold the Applicable IR Rules sent by the Test VM. It specifies which {@link IR @IR} rules the + * {@link IRMatcher} need to check. This can be different depending on the used VM flags or the machine the test is run + * on itself. + */ +public class ApplicableIRRules implements JavaMessage { + private static final boolean PRINT_APPLICABLE_IR_RULES = + Boolean.parseBoolean(System.getProperty("PrintApplicableIRRules", "false")) + || TestFramework.VERBOSE; + + private final Map methods; + + public ApplicableIRRules() { + this.methods = new LinkedHashMap<>(); + } + + public void add(String method, IRRuleIds irRuleIds) { + methods.put(method, irRuleIds); + } + + public IRRuleIds ruleIds(String methodName) { + return methods.computeIfAbsent(methodName, _ -> IRRuleIds.createEmpty()); + } + + public boolean hasNoMethods() { + return methods.isEmpty(); + } + + @Override + public void print() { + if (!PRINT_APPLICABLE_IR_RULES) { + return; + } + + System.out.println(); + System.out.println("Applicable IR Rules"); + System.out.println("-------------------"); + if (methods.isEmpty()) { + System.out.println(""); + return; + } + for (var entry : methods.entrySet()) { + String method = entry.getKey(); + String ruleIds = entry.getValue().stream().map(String::valueOf).collect(Collectors.joining(", ")); + System.out.println("- " + method + ": " + ruleIds); + } + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ExecutedTests.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ExecutedTests.java new file mode 100644 index 00000000000..f17d7eb5d74 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/ExecutedTests.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +import compiler.lib.ir_framework.test.network.MessageTag; + +import java.util.List; + +/** + * Class to collect all Java Messages sent with tag {@link MessageTag#TEST_LIST}. These are only generated when the + * user runs with {@code -DTest=myTest} and represent the executed tests. + */ +class ExecutedTests implements JavaMessage { + private final List tests; + + public ExecutedTests(List tests) { + this.tests = tests; + } + + @Override + public void print() { + if (tests.isEmpty()) { + return; + } + + System.out.println(); + System.out.println("Executed Subset of Tests"); + System.out.println("------------------------"); + for (String test : tests) { + System.out.println("- " + test); + } + System.out.println(); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/IRRuleIds.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/IRRuleIds.java index b8ea1765b4f..f5bc084fbce 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/IRRuleIds.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/IRRuleIds.java @@ -49,6 +49,10 @@ public class IRRuleIds implements Iterable { return ruleIds.getLast(); } + public static IRRuleIds createEmpty() { + return new IRRuleIds(new ArrayList<>()); + } + public boolean isEmpty() { return ruleIds.isEmpty(); } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessage.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessage.java new file mode 100644 index 00000000000..7eef84dbbbc --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessage.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +import compiler.lib.ir_framework.shared.TestFrameworkSocket; +import compiler.lib.ir_framework.test.network.MessageTag; + +/** + * Interface for a message sent from Java code to the Driver VM via the {@link TestFrameworkSocket}. We differentiate + * between different messages depending on the leading {@link MessageTag} of a received message. + */ +public interface JavaMessage { + void print(); +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessageParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessageParser.java new file mode 100644 index 00000000000..d419a06c8de --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessageParser.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.driver.network.testvm.java.multiline.ApplicableIRRulesStrategy; +import compiler.lib.ir_framework.driver.network.testvm.java.multiline.MultiLineParser; +import compiler.lib.ir_framework.driver.network.testvm.java.multiline.VMInfoStrategy; +import compiler.lib.ir_framework.shared.TestFrameworkException; +import compiler.lib.ir_framework.test.network.MessageTag; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static compiler.lib.ir_framework.test.network.MessageTag.*; + +/** + * Dedicated parser for {@link JavaMessages} received from the Test VM. Depending on the parsed {@link MessageTag}, the + * message is parsed differently. + */ +public class JavaMessageParser { + private static final Pattern TAG_PATTERN = Pattern.compile("^(\\[[^]]+])\\s*(.*)$"); + + private final List stdoutMessages; + private final List executedTests; + private final Map methodTimes; + private final MultiLineParser vmInfoParser; + private final MultiLineParser applicableIRRulesParser; + + private MultiLineParser currentMultiLineParser; + + public JavaMessageParser() { + this.stdoutMessages = new ArrayList<>(); + this.methodTimes = new HashMap<>(); + this.executedTests = new ArrayList<>(); + this.vmInfoParser = new MultiLineParser<>(new VMInfoStrategy()); + this.applicableIRRulesParser = new MultiLineParser<>(new ApplicableIRRulesStrategy()); + this.currentMultiLineParser = null; + } + + public void parseLine(String line) { + line = line.trim(); + Matcher tagLineMatcher = TAG_PATTERN.matcher(line); + if (tagLineMatcher.matches()) { + // New tag + assertNoActiveParser(); + parseTagLine(tagLineMatcher); + return; + } + + assertActiveParser(); + if (line.equals(END_MARKER)) { + // End tag + parseEndTag(); + return; + } + + currentMultiLineParser.parseLine(line); + } + + private void assertNoActiveParser() { + TestFramework.check(currentMultiLineParser == null, "Unexpected new tag while parsing block"); + } + + private void parseTagLine(Matcher tagLineMatcher) { + String tag = tagLineMatcher.group(1); + String message = tagLineMatcher.group(2); + switch (tag) { + case STDOUT -> stdoutMessages.add(message); + case TEST_LIST -> executedTests.add(message); + case PRINT_TIMES -> parsePrintTimes(message); + case VM_INFO -> currentMultiLineParser = vmInfoParser; + case APPLICABLE_IR_RULES -> currentMultiLineParser = applicableIRRulesParser; + default -> throw new TestFrameworkException("unknown tag"); + } + } + + private void parsePrintTimes(String message) { + String[] split = message.split(","); + TestFramework.check(split.length == 2, "unexpected format"); + String methodName = split[0]; + try { + long duration = Long.parseLong(split[1]); + methodTimes.put(methodName, duration); + } catch (NumberFormatException e) { + throw new TestFrameworkException("invalid duration", e); + } + } + + private void assertActiveParser() { + TestFramework.check(currentMultiLineParser != null, "Received non-tag line outside of any tag block"); + } + + private void parseEndTag() { + currentMultiLineParser.markFinished(); + currentMultiLineParser = null; + } + + public JavaMessages output() { + return new JavaMessages(new StdoutMessages(stdoutMessages), + new ExecutedTests(executedTests), + new MethodTimes(methodTimes), + applicableIRRulesParser.output(), + vmInfoParser.output()); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessages.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessages.java new file mode 100644 index 00000000000..e817610f441 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/JavaMessages.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +/** + * Class to collect all Java messages sent from the Test VM to the Driver VM. + */ +public class JavaMessages { + private final StdoutMessages stdoutMessages; + private final ExecutedTests executedTests; + private final MethodTimes methodTimes; + private final ApplicableIRRules applicableIrRules; + private final VMInfo vmInfo; + + JavaMessages(StdoutMessages stdoutMessages, ExecutedTests executedTests, MethodTimes methodTimes, + ApplicableIRRules applicableIrRules, VMInfo vmInfo) { + this.stdoutMessages = stdoutMessages; + this.executedTests = executedTests; + this.methodTimes = methodTimes; + this.applicableIrRules = applicableIrRules; + this.vmInfo = vmInfo; + } + + public VMInfo vmInfo() { + return vmInfo; + } + + public ApplicableIRRules applicableIRRules() { + return applicableIrRules; + } + + public void print() { + stdoutMessages.print(); + methodTimes.print(); + executedTests.print(); + vmInfo.print(); + applicableIrRules.print(); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/MethodTimes.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/MethodTimes.java new file mode 100644 index 00000000000..1b4cad52270 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/MethodTimes.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java; + +import compiler.lib.ir_framework.test.network.MessageTag; + +import java.util.List; +import java.util.Map; + + +/** + * Class to collect all Java Messages sent with tag {@link MessageTag#PRINT_TIMES}. These are only generated when the + * user runs with {@code -DPrintTimes=true} and represent the execution times for methods. + */ +class MethodTimes implements JavaMessage { + private final Map methodTimes; + + public MethodTimes(Map methodTimes) { + this.methodTimes = methodTimes; + } + + @Override + public void print() { + if (methodTimes.isEmpty()) { + return; + } + + System.out.println(); + System.out.println("Test Execution Times"); + System.out.println("--------------------"); + + int maxWidthNames = maxMethodNameWidth(); + int maxDurationsWidth = maxDurationsWidth(); + List> sortedMethodTimes = sortByDurationAsc(); + + for (Map.Entry entry : sortedMethodTimes) { + System.out.printf("- %-" + (maxWidthNames + 3) + "s %" + maxDurationsWidth + "d ns%n", + entry.getKey() + ":", entry.getValue()); + } + + System.out.println(); + } + + private int maxMethodNameWidth() { + return methodTimes.keySet().stream() + .mapToInt(String::length) + .max() + .orElseThrow(); + } + + private int maxDurationsWidth() { + return methodTimes.values().stream() + .mapToInt(v -> Long.toString(v).length()) + .max() + .orElseThrow(); + } + + private List> sortByDurationAsc() { + return methodTimes.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .toList(); + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReturnTypeEntry.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/StdoutMessages.java similarity index 51% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReturnTypeEntry.java rename to test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/StdoutMessages.java index 667e4cd4a94..11b23ad4237 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReturnTypeEntry.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/StdoutMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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,42 +19,36 @@ * 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.jvm.hotspot.oops; +package compiler.lib.ir_framework.driver.network.testvm.java; -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +import compiler.lib.ir_framework.test.network.MessageTag; -// Type entry used for return from a call. A single cell to record the -// type. -public class ReturnTypeEntry extends TypeEntries { - static final int cellCount = 1; +import java.util.List; - ReturnTypeEntry(MethodDataInterface methodData, ProfileData pd, int baseOff) { - super(methodData, pd, baseOff); - } - K type() { - return validKlass(baseOff); - } +/** + * Class to collect all Java Messages sent with tag {@link MessageTag#STDOUT}. These messages are generated at various + * places in the Test VM and are unconditionally shown in the Driver VM output. + */ +class StdoutMessages implements JavaMessage { + private final List messages; - static int staticCellCount() { - return cellCount; - } + public StdoutMessages(List messages) { + this.messages = messages; + } - int typeIndex() { - return baseOff; - } - - void printDataOn(PrintStream st) { - pd.tab(st); - printKlass(st, baseOff); - st.println(); - } + @Override + public void print() { + if (messages.isEmpty()) { + return; + } + System.out.println(); + System.out.println("Test VM Messages"); + System.out.println("----------------"); + for (String message : messages) { + System.out.println("- " + message); + } + } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfo.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/VMInfo.java similarity index 74% rename from test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfo.java rename to test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/VMInfo.java index 89b6d610496..a948dbc22ef 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/parser/VMInfo.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/VMInfo.java @@ -21,7 +21,7 @@ * questions. */ -package compiler.lib.ir_framework.driver.irmatching.parser; +package compiler.lib.ir_framework.driver.network.testvm.java; import compiler.lib.ir_framework.TestFramework; import compiler.lib.ir_framework.shared.TestFrameworkException; @@ -32,31 +32,27 @@ import java.util.regex.Pattern; /** * This class stores the key value mapping from the VMInfo. - * - * @see ApplicableIRRulesParser */ -public class VMInfo { +public class VMInfo implements JavaMessage { + private static final Pattern CPU_SKYLAKE_PATTERN = + Pattern.compile("family 6 model 85 stepping (\\d+) "); + /** * Stores the key-value mapping. */ private final Map keyValueMap; - private static final Pattern CPU_SKYLAKE_PATTERN = - Pattern.compile("family 6 model 85 stepping (\\d+) "); - - public VMInfo(Map map) { - this.keyValueMap = map; - - TestFramework.check(isKey("cpuFeatures"), "VMInfo does not contain cpuFeatures"); - TestFramework.check(isKey("MaxVectorSize"), "VMInfo does not contain MaxVectorSize"); - TestFramework.check(isKey("MaxVectorSizeIsDefault"), "VMInfo does not contain MaxVectorSizeIsDefault"); - TestFramework.check(isKey("LoopMaxUnroll"), "VMInfo does not contain LoopMaxUnroll"); - TestFramework.check(isKey("UseAVX"), "VMInfo does not contain UseAVX"); - TestFramework.check(isKey("UseAVXIsDefault"), "VMInfo does not contain UseAVXIsDefault"); + public VMInfo(Map keyValueMap) { + this.keyValueMap = keyValueMap; } - public String getStringValue(String key) { - TestFramework.check(isKey(key), "VMInfo does not contain \"" + key + "\""); + public boolean hasCPUFeature(String feature) { + String features = getStringValue("cpuFeatures") + ","; + return features.contains(" " + feature + ","); + } + + private String getStringValue(String key) { + TestFramework.check(keyValueMap.containsKey(key), "VMInfo does not contain \"" + key + "\""); return keyValueMap.get(key); } @@ -68,28 +64,6 @@ public class VMInfo { } } - public boolean hasCPUFeature(String feature) { - String features = getStringValue("cpuFeatures") + ","; - return features.contains(" " + feature + ","); - } - - public boolean isCascadeLake() { - Matcher matcher = CPU_SKYLAKE_PATTERN.matcher(getStringValue("cpuFeatures")); - if (!matcher.find()) { - return false; // skylake pattern not found - } - String stepping = matcher.group(1).trim(); - return Long.parseLong(stepping) >= 5; // this makes it Cascade Lake - } - - public boolean isDefaultCascadeLake() { - // See VM_Version::is_default_intel_cascade_lake - return isCascadeLake() && - getLongValue("MaxVectorSizeIsDefault") == 1 && - getLongValue("UseAVXIsDefault") == 1 && - getLongValue("UseAVX") > 2; - } - /** * Some platforms do not behave as expected, and one cannot trust that the vectors * make use of the full MaxVectorSize. For Cascade Lake, we only use 32 bytes for @@ -101,7 +75,36 @@ public class VMInfo { return !isDefaultCascadeLake(); } - public boolean isKey(String key) { - return keyValueMap.containsKey(key); + private boolean isDefaultCascadeLake() { + // See VM_Version::is_default_intel_cascade_lake + return isCascadeLake() && + getLongValue("MaxVectorSizeIsDefault") == 1 && + getLongValue("UseAVXIsDefault") == 1 && + getLongValue("UseAVX") > 2; + } + + private boolean isCascadeLake() { + Matcher matcher = CPU_SKYLAKE_PATTERN.matcher(getStringValue("cpuFeatures")); + if (!matcher.find()) { + return false; // skylake pattern not found + } + String stepping = matcher.group(1).trim(); + return Long.parseLong(stepping) >= 5; // this makes it Cascade Lake + } + + @Override + public void print() { + if (!TestFramework.VERBOSE) { + return; + } + + System.out.println(); + System.out.println("VM Info"); + System.out.println("--------"); + for (var entry : keyValueMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + System.out.println("- Key: " + key + ", Value: " + value); + } } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/ApplicableIRRulesStrategy.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/ApplicableIRRulesStrategy.java new file mode 100644 index 00000000000..3728e489ba7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/ApplicableIRRulesStrategy.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java.multiline; + +import compiler.lib.ir_framework.driver.network.testvm.java.ApplicableIRRules; +import compiler.lib.ir_framework.driver.network.testvm.java.IRRuleIds; +import compiler.lib.ir_framework.shared.TestFrameworkException; +import compiler.lib.ir_framework.test.ApplicableIRRulesPrinter; + +import java.util.ArrayList; +import java.util.List; + +/** + * Dedicated strategy to parse the multi-line Applicable IR Rules message into a new {@link ApplicableIRRules} object. + */ +public class ApplicableIRRulesStrategy implements MultiLineParsingStrategy { + private final ApplicableIRRules applicableIrRules; + + public ApplicableIRRulesStrategy() { + this.applicableIrRules = new ApplicableIRRules(); + } + + @Override + public void parseLine(String line) { + if (line.equals(ApplicableIRRulesPrinter.NO_RULES)) { + return; + } + + String[] splitLine = line.split(","); + if (splitLine.length < 2) { + throw new TestFrameworkException("Invalid Applicable IR Rules format. No comma found: " + splitLine[0]); + } + String testName = splitLine[0]; + IRRuleIds irRulesIds = parseIrRulesIds(splitLine); + applicableIrRules.add(testName, irRulesIds); + } + + /** + * Parse rule indexes from a single line of the Applicable IR Rules in the format: + */ + private IRRuleIds parseIrRulesIds(String[] splitLine) { + List irRuleIds = new ArrayList<>(); + for (int i = 1; i < splitLine.length; i++) { + try { + irRuleIds.add(Integer.parseInt(splitLine[i])); + } catch (NumberFormatException e) { + throw new TestFrameworkException("Invalid Applicable IR Rules format. No number found: " + splitLine[i]); + } + } + return new IRRuleIds(irRuleIds); + } + + @Override + public ApplicableIRRules output() { + return applicableIrRules; + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParser.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParser.java new file mode 100644 index 00000000000..fbc24eed736 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParser.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java.multiline; + +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.driver.network.testvm.java.JavaMessage; +import compiler.lib.ir_framework.test.network.MessageTag; + +/** + * Generic multi-line parser that takes a {@link MultiLineParsingStrategy} to decide how to parse a single line of + * a multi line {@link JavaMessage}. Once parsing is done, the strategy is queried for the final parsed output. + */ +public class MultiLineParser { + private enum ParserState { + NOTHING_PARSED, PARSING, FINISHED_PARSING + } + + private ParserState parserState; + private final MultiLineParsingStrategy multiLineParsingStrategy; + + public MultiLineParser(MultiLineParsingStrategy multiLineParsingStrategy) { + this.multiLineParsingStrategy = multiLineParsingStrategy; + this.parserState = ParserState.NOTHING_PARSED; + } + + public void parseLine(String line) { + TestFramework.check(parserState != ParserState.FINISHED_PARSING, + "cannot parse another block"); + parserState = ParserState.PARSING; + multiLineParsingStrategy.parseLine(line); + } + + /** + * Once the {@link MessageTag#END_MARKER} was seen, this method is called to mark the end of this multi-line message. + */ + public void markFinished() { + TestFramework.check(parserState == ParserState.PARSING, + "nothing parsed, cannot have empty block"); + parserState = ParserState.FINISHED_PARSING; + } + + public Output output() { + TestFramework.check(parserState != ParserState.PARSING, "either nothing parsed or finished"); + return multiLineParsingStrategy.output(); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParsingStrategy.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParsingStrategy.java new file mode 100644 index 00000000000..0283c520465 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/MultiLineParsingStrategy.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java.multiline; + +/** + * Interface to define a strategy to parse a line in a {@link MultiLineParser}. + */ +public interface MultiLineParsingStrategy { + void parseLine(String line); + Output output(); +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/VMInfoStrategy.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/VMInfoStrategy.java new file mode 100644 index 00000000000..7d3072394c0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/network/testvm/java/multiline/VMInfoStrategy.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.driver.network.testvm.java.multiline; + +import compiler.lib.ir_framework.driver.network.testvm.java.VMInfo; +import compiler.lib.ir_framework.shared.TestFrameworkException; + +import java.util.HashMap; +import java.util.Map; + +/** + * Dedicated strategy to parse the multi-line VM info message into a new {@link VMInfo} object. + */ +public class VMInfoStrategy implements MultiLineParsingStrategy { + private final Map keyValueMap; + + public VMInfoStrategy() { + this.keyValueMap = new HashMap<>(); + } + + @Override + public void parseLine(String line) { + String[] splitLine = line.split(":", 2); + if (splitLine.length != 2) { + throw new TestFrameworkException("Invalid VmInfo key:value encoding. Found: " + splitLine[0]); + } + String key = splitLine[0]; + String value = splitLine[1]; + keyValueMap.put(key, value); + } + + @Override + public VMInfo output() { + return new VMInfo(keyValueMap); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java index f10540ebc5b..77d560952f1 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java @@ -24,40 +24,27 @@ package compiler.lib.ir_framework.shared; import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.driver.network.*; +import compiler.lib.ir_framework.driver.network.testvm.TestVmMessageReader; +import compiler.lib.ir_framework.driver.network.testvm.java.JavaMessages; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; +import java.net.*; +import java.util.concurrent.*; /** - * Dedicated socket to send data from the flag and Test VM back to the Driver VM. + * Dedicated Driver VM socket to receive data from the Test VM. Could either be received from Java and C2 code. */ public class TestFrameworkSocket implements AutoCloseable { - public static final String STDOUT_PREFIX = "[STDOUT]"; - public static final String TESTLIST_TAG = "[TESTLIST]"; - public static final String DEFAULT_REGEX_TAG = "[DEFAULT_REGEX]"; - public static final String PRINT_TIMES_TAG = "[PRINT_TIMES]"; - public static final String NOT_COMPILABLE_TAG = "[NOT_COMPILABLE]"; - - // Static fields used for Test VM only. private static final String SERVER_PORT_PROPERTY = "ir.framework.server.port"; - private static final int SERVER_PORT = Integer.getInteger(SERVER_PORT_PROPERTY, -1); - private static final boolean REPRODUCE = Boolean.getBoolean("Reproduce"); - private static Socket clientSocket = null; - private static PrintWriter clientWriter = null; - - private final String serverPortPropertyFlag; - private FutureTask socketTask; + private final int serverSocketPort; private final ServerSocket serverSocket; - private boolean receivedStdOut = false; + private boolean running; + private final ExecutorService executor; + private Future javaFuture; public TestFrameworkSocket() { try { @@ -66,140 +53,80 @@ public class TestFrameworkSocket implements AutoCloseable { } catch (IOException e) { throw new TestFrameworkException("Failed to create TestFramework server socket", e); } - int port = serverSocket.getLocalPort(); + serverSocketPort = serverSocket.getLocalPort(); + executor = Executors.newCachedThreadPool(); if (TestFramework.VERBOSE) { - System.out.println("TestFramework server socket uses port " + port); + System.out.println("TestFramework server socket uses port " + serverSocketPort); } - serverPortPropertyFlag = "-D" + SERVER_PORT_PROPERTY + "=" + port; start(); } public String getPortPropertyFlag() { - return serverPortPropertyFlag; + return "-D" + SERVER_PORT_PROPERTY + "=" + serverSocketPort; } private void start() { - socketTask = initSocketTask(); - Thread socketThread = new Thread(socketTask); - socketThread.start(); + running = true; + executor.submit(this::acceptLoop); } /** - * Waits for a client (created by flag or Test VM) to connect. Return the messages received from the client. + * Main loop to wait for new client connections and handling them upon connection request. */ - private FutureTask initSocketTask() { - return new FutureTask<>(() -> { - try (Socket clientSocket = serverSocket.accept(); - BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())) - ) { - StringBuilder builder = new StringBuilder(); - String next; - while ((next = in.readLine()) != null) { - builder.append(next).append(System.lineSeparator()); - if (next.startsWith(STDOUT_PREFIX)) { - receivedStdOut = true; - } - } - return builder.toString(); - } catch (IOException e) { + private void acceptLoop() { + while (running) { + try { + acceptNewClientConnection(); + } catch (TestFrameworkException e) { + running = false; + throw e; + } catch (Exception e) { + running = false; throw new TestFrameworkException("Server socket error", e); } - }); + } + } + + /** + * Accept new client connection and then submit a task accordingly to manage incoming message on that connection/socket. + */ + private void acceptNewClientConnection() throws IOException { + Socket client = serverSocket.accept(); + BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream())); + submitTask(client, reader); + } + + /** + * Submit dedicated tasks which are wrapped into {@link Future} objects. The tasks will read all messages sent + * over that connection. + */ + private void submitTask(Socket client, BufferedReader reader) { + javaFuture = executor.submit(new TestVmMessageReader(client, reader)); } @Override public void close() { try { + running = false; serverSocket.close(); } catch (IOException e) { throw new TestFrameworkException("Could not close socket", e); } + executor.shutdown(); } - /** - * Only called by Test VM to write to server socket. - */ - public static void write(String msg, String tag) { - write(msg, tag, false); + public TestVMData testVmData(String hotspotPidFileName, boolean allowNotCompilable) { + JavaMessages javaMessages = testVmMessages(); + return new TestVMData(javaMessages, hotspotPidFileName, allowNotCompilable); } - /** - * Only called by Test VM to write to server socket. - *

    - * The Test VM is spawned by the main jtreg VM. The stdout of the Test VM is hidden - * unless the Verbose or ReportStdout flag is used. TestFrameworkSocket is used by the parent jtreg - * VM and the Test VM to communicate. By sending the prints through the TestFrameworkSocket with the - * parameter stdout set to true, the parent VM will print the received messages to its stdout, making it - * visible to the user. - */ - public static void write(String msg, String tag, boolean stdout) { - if (REPRODUCE) { - System.out.println("Debugging Test VM: Skip writing due to -DReproduce"); - return; - } - TestFramework.check(SERVER_PORT != -1, "Server port was not set correctly for flag and/or Test VM " - + "or method not called from flag or Test VM"); + private JavaMessages testVmMessages() { try { - // Keep the client socket open until the Test VM terminates (calls closeClientSocket before exiting main()). - if (clientSocket == null) { - clientSocket = new Socket(InetAddress.getLoopbackAddress(), SERVER_PORT); - clientWriter = new PrintWriter(clientSocket.getOutputStream(), true); - } - if (stdout) { - msg = STDOUT_PREFIX + tag + " " + msg; - } - clientWriter.println(msg); - } catch (Exception e) { - // When the Test VM is directly run, we should ignore all messages that would normally be sent to the - // Driver VM. - String failMsg = System.lineSeparator() + System.lineSeparator() + """ - ########################################################### - Did you directly run the Test VM (TestVM class) - to reproduce a bug? - => Append the flag -DReproduce=true and try again! - ########################################################### - """; - throw new TestRunException(failMsg, e); - } - if (TestFramework.VERBOSE) { - System.out.println("Written " + tag + " to socket:"); - System.out.println(msg); - } - } - - /** - * Closes (and flushes) the printer to the socket and the socket itself. Is called as last thing before exiting - * the main() method of the flag and the Test VM. - */ - public static void closeClientSocket() { - if (clientSocket != null) { - try { - clientWriter.close(); - clientSocket.close(); - } catch (IOException e) { - throw new RuntimeException("Could not close TestVM socket", e); - } - } - } - - /** - * Get the socket output of the Flag VM. - */ - public String getOutput() { - try { - return socketTask.get(); + return javaFuture.get(); } catch (ExecutionException e) { - // Thrown when socket task was not finished, yet (i.e. no client sent data) but socket was already closed. - return ""; + throw new TestFrameworkException("No test VM messages were received", e); } catch (Exception e) { - throw new TestFrameworkException("Could not read from socket task", e); + throw new TestFrameworkException("Error while fetching Test VM Future", e); } } - - /** - * Return whether Test VM sent messages to be put on stdout (starting with {@link ::STDOUT_PREFIX}). - */ - public boolean hasStdOut() { - return receivedStdOut; - } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java index 4d227900e2e..152dcab273a 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/AbstractTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,13 @@ package compiler.lib.ir_framework.test; import compiler.lib.ir_framework.*; import compiler.lib.ir_framework.shared.TestRun; import compiler.lib.ir_framework.shared.TestRunException; +import compiler.lib.ir_framework.test.network.TestVmSocket; import jdk.test.whitebox.WhiteBox; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import compiler.lib.ir_framework.shared.TestFrameworkSocket; - /** * Abstract super class for base, checked and custom run tests. */ @@ -118,7 +117,7 @@ abstract class AbstractTest { tryCompileMethod(test); } catch (MethodNotCompilableException e) { final Method testMethod = test.getTestMethod(); - TestFrameworkSocket.write("Method not compilable: " + testMethod, TestFrameworkSocket.NOT_COMPILABLE_TAG, true); + TestVmSocket.send("Method not compilable: " + testMethod); TestRun.check(test.isAllowNotCompilable(), "Method " + testMethod + " not compilable (anymore) at level " + test.getCompLevel() + ". Most likely, this is not expected, but if it is, you can use 'allowNotCompilable'."); diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/ApplicableIRRulesPrinter.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/ApplicableIRRulesPrinter.java index 7a868c172dd..a4797a29dc7 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/ApplicableIRRulesPrinter.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/ApplicableIRRulesPrinter.java @@ -27,6 +27,8 @@ import compiler.lib.ir_framework.IR; import compiler.lib.ir_framework.IRNode; import compiler.lib.ir_framework.TestFramework; import compiler.lib.ir_framework.shared.*; +import compiler.lib.ir_framework.test.network.MessageTag; +import compiler.lib.ir_framework.test.network.TestVmSocket; import jdk.test.lib.Platform; import jdk.test.whitebox.WhiteBox; @@ -45,9 +47,7 @@ import java.util.function.Function; * termination of the Test VM. IR rule indices start at 1. */ public class ApplicableIRRulesPrinter { - public static final String START = "##### ApplicableIRRules - used by TestFramework #####"; - public static final String END = "----- END -----"; - public static final int NO_RULE_APPLIED = -1; + public static final String NO_RULES = ""; private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); private static final List> LONG_GETTERS = Arrays.asList( @@ -126,14 +126,12 @@ public class ApplicableIRRulesPrinter { "zfh", "zvbb", "zvfh", - "zvkn" + "zvkn", + // PPC64 + "darn", + "brw" )); - public ApplicableIRRulesPrinter() { - output.append(START).append(System.lineSeparator()); - output.append(",{comma separated applied @IR rule ids}").append(System.lineSeparator()); - } - /** * Emits ",{ids}" where {ids} is either: * - indices of all @IR rules that should be applied, separated by a comma @@ -157,23 +155,20 @@ public class ApplicableIRRulesPrinter { i++; } } - if (irAnnos.length != 0) { - output.append(m.getName()); - if (validRules.isEmpty()) { - output.append("," + NO_RULE_APPLIED); - } else { - for (i = 0; i < validRules.size(); i++) { - output.append(",").append(validRules.get(i)); - } - } - output.append(System.lineSeparator()); + + if (irAnnos.length == 0 || validRules.isEmpty()) { + return; } + output.append(m.getName()); + for (i = 0; i < validRules.size(); i++) { + output.append(",").append(validRules.get(i)); + } + output.append(System.lineSeparator()); } private void printDisableReason(String method, String reason, String[] apply, int ruleIndex, int ruleMax) { - TestFrameworkSocket.write("Disabling IR matching for rule " + ruleIndex + " of " + ruleMax + " in " + - method + ": " + reason + ": " + String.join(", ", apply), - "[ApplicableIRRules]", true); + TestVmSocket.send("Disabling IR matching for rule " + ruleIndex + " of " + ruleMax + " in " + method + ": " + + reason + ": " + String.join(", ", apply)); } private boolean shouldApplyIrRule(IR irAnno, String m, int ruleIndex, int ruleMax) { @@ -286,7 +281,7 @@ public class ApplicableIRRulesPrinter { IRNode.checkIRNodeSupported(s); } } catch (CheckedTestFrameworkException e) { - TestFrameworkSocket.write("Skip Rule " + ruleIndex + ": " + e.getMessage(), TestFrameworkSocket.DEFAULT_REGEX_TAG, true); + TestVmSocket.send("Skip Rule " + ruleIndex + ": " + e.getMessage()); return true; } return false; @@ -523,9 +518,10 @@ public class ApplicableIRRulesPrinter { } public void emit() { - output.append(END); - TestFrameworkSocket.write(output.toString(), "ApplicableIRRules"); + if (output.isEmpty()) { + output.append(NO_RULES).append(System.lineSeparator()); + } + output.append(MessageTag.END_MARKER); + TestVmSocket.sendMultiLine(MessageTag.APPLICABLE_IR_RULES, output.toString()); } } - - diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java index 14551141cd7..ac52bcaaa98 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java @@ -26,6 +26,8 @@ package compiler.lib.ir_framework.test; import compiler.lib.ir_framework.*; import compiler.lib.ir_framework.Compiler; import compiler.lib.ir_framework.shared.*; +import compiler.lib.ir_framework.test.network.MessageTag; +import compiler.lib.ir_framework.test.network.TestVmSocket; import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.whitebox.WhiteBox; @@ -38,8 +40,6 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import static compiler.lib.ir_framework.shared.TestFrameworkSocket.PRINT_TIMES_TAG; - /** * This class' main method is called from {@link TestFramework} and represents the so-called "Test VM". The class is * the heart of the framework and is responsible for executing all the specified tests in the test class. It uses the @@ -159,6 +159,7 @@ public class TestVM { */ public static void main(String[] args) { try { + TestVmSocket.connect(); String testClassName = args[0]; System.out.println("TestVM main() called - about to run tests in class " + testClassName); Class testClass = getClassObject(testClassName, "test"); @@ -167,7 +168,7 @@ public class TestVM { framework.addHelperClasses(args); framework.start(); } finally { - TestFrameworkSocket.closeClientSocket(); + TestVmSocket.close(); } } @@ -593,8 +594,8 @@ public class TestVM { "Cannot overload @Test methods, but method " + m + " has " + overloads.size() + " overload" + (overloads.size() == 1 ? "" : "s") + ":" + overloads.stream().map(String::valueOf).collect(Collectors.joining("\n - ", "\n - ", "")) ); - TestFormat.check(!testMethodMap.containsKey(m.getName()), - "Cannot overload two @Test methods: " + m + ", " + testMethodMap.get(m.getName())); + TestFramework.check(!testMethodMap.containsKey(m.getName()), + "Cannot overload two @Test methods: " + m + ", " + testMethodMap.get(m.getName())); TestFormat.check(testAnno != null, m + " must be a method with a @Test annotation"); Check checkAnno = getAnnotation(m, Check.class); @@ -835,7 +836,6 @@ public class TestVM { * Once all framework tests are collected, they are run in this method. */ private void runTests() { - TreeMap durations = PRINT_TIMES ? new TreeMap<>() : null; long startTime = System.nanoTime(); List testList; boolean testFilterPresent = testFilterPresent(); @@ -864,7 +864,7 @@ public class TestVM { System.out.println("Run " + test.toString()); } if (testFilterPresent) { - TestFrameworkSocket.write("Run " + test.toString(), TestFrameworkSocket.TESTLIST_TAG, true); + TestVmSocket.sendWithTag(MessageTag.TEST_LIST, "Run " + test.toString()); } try { test.run(); @@ -879,10 +879,11 @@ public class TestVM { if (PRINT_TIMES) { long endTime = System.nanoTime(); long duration = (endTime - startTime); - durations.put(duration, test.getName()); if (VERBOSE) { - System.out.println("Done " + test.getName() + ": " + duration + " ns = " + (duration / 1000000) + " ms"); + System.out.println("Done " + test.getName() + ": " + duration + " ns = " + (duration / 1_000_000) + " ms"); } + // Will be correctly formatted later. + TestVmSocket.sendWithTag(MessageTag.PRINT_TIMES, test.getName() + "," + duration); } if (GC_AFTER) { System.out.println("doing GC"); @@ -890,15 +891,6 @@ public class TestVM { } } - // Print execution times - if (PRINT_TIMES) { - TestFrameworkSocket.write("Test execution times:", PRINT_TIMES_TAG, true); - for (Map.Entry entry : durations.entrySet()) { - TestFrameworkSocket.write(String.format("%-25s%15d ns%n", entry.getValue() + ":", entry.getKey()), - PRINT_TIMES_TAG, true); - } - } - if (failures > 0) { // Finally, report all occurred exceptions in a nice format. String msg = System.lineSeparator() + System.lineSeparator() + "Test Failures (" + failures + ")" diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/VMInfoPrinter.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/VMInfoPrinter.java index 470569122dd..8fc61ee9bad 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/VMInfoPrinter.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/VMInfoPrinter.java @@ -23,22 +23,18 @@ package compiler.lib.ir_framework.test; -import compiler.lib.ir_framework.shared.TestFrameworkSocket; +import compiler.lib.ir_framework.test.network.MessageTag; +import compiler.lib.ir_framework.test.network.TestVmSocket; import jdk.test.whitebox.WhiteBox; /** * Prints some Test VM info to the socket. */ public class VMInfoPrinter { - public static final String START_VM_INFO = "##### IRMatchingVMInfo - used by TestFramework #####"; - public static final String END_VM_INFO = "----- END VMInfo -----"; - private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); public static void emit() { StringBuilder vmInfo = new StringBuilder(); - vmInfo.append(START_VM_INFO).append(System.lineSeparator()); - vmInfo.append(":").append(System.lineSeparator()); // CPU feature independent info String cpuFeatures = WHITE_BOX.getCPUFeatures(); @@ -64,7 +60,7 @@ public class VMInfoPrinter { .append(useAVXIsDefault ? 1 : 0) .append(System.lineSeparator()); - vmInfo.append(END_VM_INFO); - TestFrameworkSocket.write(vmInfo.toString(), "VMInfo"); + vmInfo.append(MessageTag.END_MARKER); + TestVmSocket.sendMultiLine(MessageTag.VM_INFO, vmInfo.toString()); } } diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/MessageTag.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/MessageTag.java new file mode 100644 index 00000000000..66b89dc122d --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/MessageTag.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.test.network; + +public class MessageTag { + public static final String STDOUT = "[STDOUT]"; + public static final String TEST_LIST = "[TEST_LIST]"; + public static final String PRINT_TIMES = "[PRINT_TIMES]"; + public static final String VM_INFO = "[VM_INFO]"; + public static final String APPLICABLE_IR_RULES = "[APPLICABLE_IR_RULES]"; + public static final String END_MARKER = "#END#"; +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/TestVmSocket.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/TestVmSocket.java new file mode 100644 index 00000000000..37e59b9dcae --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/network/TestVmSocket.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2026, 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 compiler.lib.ir_framework.test.network; + +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.shared.TestRunException; +import compiler.lib.ir_framework.test.TestVM; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.InetAddress; +import java.net.Socket; + +public class TestVmSocket { + private static final boolean REPRODUCE = Boolean.getBoolean("Reproduce"); + private static final String SERVER_PORT_PROPERTY = "ir.framework.server.port"; + private static final int SERVER_PORT = Integer.getInteger(SERVER_PORT_PROPERTY, -1); + + private static Socket socket = null; + private static PrintWriter writer = null; + + /** + * Send a message to the Driver VM which is unconditionally shown in the Driver VM output. + */ + public static void send(String message) { + sendWithTag(MessageTag.STDOUT, message); + } + + /** + * Send a message with multiple lines to the Driver VM with a {@link MessageTag}. Not all messages are shown by + * default in the Driver VM output and require setting some property flags first like {@code -DPrintTimes=true}. + */ + public static void sendMultiLine(String tag, String message) { + if (REPRODUCE) { + // Debugging Test VM: Skip writing due to -DReproduce; + return; + } + + TestFramework.check(socket != null, "must be connected"); + writer.println(tag + System.lineSeparator() + message); + } + + /** + * Send a message to the Driver VM with a {@link MessageTag}. Not all messages are shown by default in the + * Driver VM output and require setting some property flags first like {@code -DPrintTimes=true}. + */ + public static void sendWithTag(String tag, String message) { + if (REPRODUCE) { + // Debugging Test VM: Skip writing due to -DReproduce; + return; + } + + TestFramework.check(socket != null, "must be connected"); + writer.println(tag + " " + message); + } + + public static void connect() { + if (REPRODUCE) { + // Debugging Test VM: Skip writing due to -DReproduce; + return; + } + + TestFramework.check(SERVER_PORT != -1, "Server port was not set correctly for flag and/or test VM " + + "or method not called from flag or test VM"); + + try { + // Keep the client socket open until the test VM terminates (calls closeClientSocket before exiting main()). + socket = new Socket(InetAddress.getLoopbackAddress(), SERVER_PORT); + writer = new PrintWriter(socket.getOutputStream(), true); + } catch (Exception e) { + // When the test VM is directly run, we should ignore all messages that would normally be sent to the + // driver VM. + String failMsg = System.lineSeparator() + System.lineSeparator() + """ + ########################################################### + Did you directly run the test VM (TestVM class) + to reproduce a bug? + => Append the flag -DReproduce=true and try again! + ########################################################### + """; + throw new TestRunException(failMsg, e); + } + + } + + /** + * Closes (and flushes) the printer to the socket and the socket itself. Is called as last thing before exiting + * the main() method of the flag and the test VM. + */ + public static void close() { + if (socket != null) { + writer.close(); + try { + socket.close(); + } catch (IOException e) { + throw new RuntimeException("Could not close TestVM socket", e); + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/lib/template_framework/Renderer.java b/test/hotspot/jtreg/compiler/lib/template_framework/Renderer.java index 61ab9ab343c..cb83a5ea40c 100644 --- a/test/hotspot/jtreg/compiler/lib/template_framework/Renderer.java +++ b/test/hotspot/jtreg/compiler/lib/template_framework/Renderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -413,8 +413,39 @@ final class Renderer { } } + /** + * Finds the index where the next replacement pattern after {@code start} begins while skipping + * over "$$" and "##". + * + * @param s string to search for replacements + * @param start index from which to start searching + * @return the index of the beginning of the next replacement pattern or the length of {@code s} + */ + private int findNextReplacement(final String s, final int start) { + int next = start; + for (int potentialStart = start; potentialStart < s.length() && s.charAt(next) == s.charAt(potentialStart); potentialStart = next + 1) { + // If this is not the first iteration, we have found a doubled up "$" or "#" and need to skip + // over the second instance. + if (potentialStart != start) { + potentialStart += 1; + } + // Find the next "$" or "#", after the potential start. + int dollar = s.indexOf("$", potentialStart); + int hashtag = s.indexOf("#", potentialStart); + // If the character was not found, we want to have the rest of the + // String s, so instead of "-1" take the end/length of the String. + dollar = (dollar == -1) ? s.length() : dollar; + hashtag = (hashtag == -1) ? s.length() : hashtag; + // Take the first one. + next = Math.min(dollar, hashtag); + } + + return next; + } + /** * We split a {@link String} by "#" and "$", and then look at each part. + * However, we escape "##" to "#" and "$$" to "$". * Example: * * s: "abcdefghijklmnop #name abcdefgh${var_name} 12345#{name2}_con $field_name something" @@ -428,16 +459,19 @@ final class Renderer { int start = 0; boolean startIsAfterDollar = false; do { - // Find the next "$" or "#", after start. - int dollar = s.indexOf("$", start); - int hashtag = s.indexOf("#", start); - // If the character was not found, we want to have the rest of the - // String s, so instead of "-1" take the end/length of the String. - dollar = (dollar == -1) ? s.length() : dollar; - hashtag = (hashtag == -1) ? s.length() : hashtag; - // Take the first one. - int next = Math.min(dollar, hashtag); + int next = findNextReplacement(s, start); + + // Detect most zero sized replacement patterns, i.e. "$#" or "#$", for better error reporting. + if (next < s.length() - 2 && ((s.charAt(next) == '$' && s.charAt(next + 1) == '#') || + (s.charAt(next) == '#' && s.charAt(next + 1) == '$'))) { + String pattern = s.substring(next, next + 2); + throw new RendererException("Found zero sized replacement pattern '" + pattern + "'."); + } + String part = s.substring(start, next); + // Escape doubled up replacement characters. + part = part.replace("##", "#"); + part = part.replace("$$", "$"); if (count == 0) { // First part has no "#" or "$" before it. @@ -452,8 +486,8 @@ final class Renderer { // terminate now. return; } - start = next + 1; // skip over the "#" or "$" - startIsAfterDollar = next == dollar; // remember which character we just split with + start = next + 1; + startIsAfterDollar = s.charAt(next) == '$'; // remember which character we just split with count++; } while (true); } diff --git a/test/hotspot/jtreg/compiler/lib/template_framework/Template.java b/test/hotspot/jtreg/compiler/lib/template_framework/Template.java index f245cda0501..3cd3a9097ff 100644 --- a/test/hotspot/jtreg/compiler/lib/template_framework/Template.java +++ b/test/hotspot/jtreg/compiler/lib/template_framework/Template.java @@ -160,7 +160,8 @@ import compiler.lib.ir_framework.TestFramework; * arguments into the strings. But since string templates are not (yet) available, the Templates provide * hashtag replacements in the {@link String}s: the Template argument names are captured, and * the argument values automatically replace any {@code "#name"} in the {@link String}s. See the different overloads - * of {@link #make} for examples. Additional hashtag replacements can be defined with {@link #let}. + * of {@link #make} for examples. Additional hashtag replacements can be defined with {@link #let}. If a "#" is needed + * in the code, hashtag replacmement can be escaped by writing two hashtags, i.e. "##" will render as "#". * We have decided to keep hashtag replacements constrained to the scope of one Template. They * do not escape to outer or inner Template uses. If one needs to pass values to inner Templates, * this can be done with Template arguments. Keeping hashtag replacements local to Templates @@ -172,7 +173,8 @@ import compiler.lib.ir_framework.TestFramework; * For this, Templates provide dollar replacements, which automatically rename any * {@code "$name"} in the {@link String} with a {@code "name_ID"}, where the {@code "ID"} is unique for every use of * a Template. The dollar replacement can also be captured with {@link #$}, and passed to nested - * Templates, which allows sharing of these identifier names between Templates. + * Templates, which allows sharing of these identifier names between Templates. Similar to hashtag replacements, + * dollars can be escaped by doubling up, i.e. "$$" renders as "$". * *

    * The dollar and hashtag names must have at least one character. The first character must be a letter diff --git a/test/hotspot/jtreg/compiler/lib/template_framework/library/Expression.java b/test/hotspot/jtreg/compiler/lib/template_framework/library/Expression.java index 43ab16af415..37ad4debde6 100644 --- a/test/hotspot/jtreg/compiler/lib/template_framework/library/Expression.java +++ b/test/hotspot/jtreg/compiler/lib/template_framework/library/Expression.java @@ -382,6 +382,23 @@ public class Expression { return sb.toString(); } + /** + * {@link Nesting} defines the different ways of selecting {@link Expression}s + * to nest based on their types. + */ + public enum Nesting { + /** + * Only nest {@Expression}s where the argument and return types match exactly + * based on the implementation of {@link CodeGenerateionDataNameType#isSubtypeOf}. + */ + EXACT, + /** + * Only nest {@Expression}s where the return type is a subtype of the argument + * type based on the implemetation of {@link CodeGenerateionDataNameType#isSubtypeOf}. + */ + SUBTYPE + } + /** * Create a nested {@link Expression} with a specified {@code returnType} from a * set of {@code expressions}. @@ -391,11 +408,13 @@ public class Expression { * the nested {@link Expression}. * @param maxNumberOfUsedExpressions the maximal number of {@link Expression}s from the * {@code expressions} are nested. + * @param nesting control the {@link Nesting} of the sampled {@link Expression}s. * @return a new randomly nested {@link Expression}. */ public static Expression nestRandomly(CodeGenerationDataNameType returnType, List expressions, - int maxNumberOfUsedExpressions) { + int maxNumberOfUsedExpressions, + Nesting nesting) { List filtered = expressions.stream().filter(e -> e.returnType.isSubtypeOf(returnType)).toList(); if (filtered.isEmpty()) { @@ -406,7 +425,7 @@ public class Expression { Expression expression = filtered.get(r); for (int i = 1; i < maxNumberOfUsedExpressions; i++) { - expression = expression.nestRandomly(expressions); + expression = expression.nestRandomly(expressions, nesting); } return expression; } @@ -416,12 +435,16 @@ public class Expression { * {@code this} {@link Expression}, ensuring compatibility of argument and return type. * * @param nestingExpressions list of expressions we sample from for the inner {@link Expression}. + * @param nesting control the {@link Nesting} of the sampled {@link Expression}s. * @return a new nested {@link Expression}. */ - public Expression nestRandomly(List nestingExpressions) { + public Expression nestRandomly(List nestingExpressions, Nesting nesting) { int argumentIndex = RANDOM.nextInt(this.argumentTypes.size()); CodeGenerationDataNameType argumentType = this.argumentTypes.get(argumentIndex); - List filtered = nestingExpressions.stream().filter(e -> e.returnType.isSubtypeOf(argumentType)).toList(); + List filtered = nestingExpressions.stream() + .filter(e -> e.returnType.isSubtypeOf(argumentType) && + (nesting == Nesting.EXACT ? argumentType.isSubtypeOf(e.returnType) : true)) + .toList(); if (filtered.isEmpty()) { // Found no expression that has a matching returnType. diff --git a/test/hotspot/jtreg/compiler/lib/template_framework/library/Operations.java b/test/hotspot/jtreg/compiler/lib/template_framework/library/Operations.java index 1fe05cc2b6c..2ea251cc5e5 100644 --- a/test/hotspot/jtreg/compiler/lib/template_framework/library/Operations.java +++ b/test/hotspot/jtreg/compiler/lib/template_framework/library/Operations.java @@ -129,8 +129,17 @@ public final class Operations { ops.add(Expression.make(type, "(", type, " + ", type, ")")); ops.add(Expression.make(type, "(", type, " - ", type, ")")); ops.add(Expression.make(type, "(", type, " * ", type, ")")); - ops.add(Expression.make(type, "(", type, " / ", type, ")")); - ops.add(Expression.make(type, "(", type, " % ", type, ")")); + // Because of subtyping, we can sample an expression like `(float)((int)(3) / (int)(0))`. Floating point + // division and modulo do not throw an ArithmeticException on division by zero, integer division and modulo + // do. In the expression above, the division has an integer on both sides, so it is executed as an integer + // division and throws an ArithmeticException even though we would expect the float division not to do so. + // To prevent this issue, we provide two versions of floating point division operations: one that casts + // its operands and one that expects that an ArithmeticException might be thrown when we get unlucky when + // sampling subtypes. + ops.add(Expression.make(type, "((" + type.name() + ")(", type, ") / (" + type.name() +")(", type, "))")); + ops.add(Expression.make(type, "((" + type.name() + ")(", type, ") % (" + type.name() +")(", type, "))")); + ops.add(Expression.make(type, "(", type, " / ", type, ")", WITH_ARITHMETIC_EXCEPTION)); + ops.add(Expression.make(type, "(", type, " % ", type, ")", WITH_ARITHMETIC_EXCEPTION)); // Relational / Comparison Operators ops.add(Expression.make(BOOLEANS, "(", type, " == ", type, ")")); diff --git a/test/hotspot/jtreg/compiler/lib/template_framework/library/PrimitiveType.java b/test/hotspot/jtreg/compiler/lib/template_framework/library/PrimitiveType.java index b789da45d44..b20dbb28d22 100644 --- a/test/hotspot/jtreg/compiler/lib/template_framework/library/PrimitiveType.java +++ b/test/hotspot/jtreg/compiler/lib/template_framework/library/PrimitiveType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -71,7 +71,25 @@ public final class PrimitiveType implements CodeGenerationDataNameType { @Override public boolean isSubtypeOf(DataName.Type other) { - return (other instanceof PrimitiveType pt) && pt.kind == kind; + // Implement other >: this according to JLS §4.10.1. + if (other instanceof PrimitiveType superType) { + if (superType.kind == Kind.BOOLEAN || kind == Kind.BOOLEAN) { + // Boolean does not have a supertype and only itself as a subtype. + return superType.kind == this.kind; + } + if (superType.kind == Kind.CHAR || kind == Kind.CHAR) { + // Char does not have a subtype, but it is itself a subtype of any primitive type with + // a larger byte size. The following is correct for the subtype relation to floats, + // since chars are 16 bits wide and floats 32 bits or more. + return superType.kind == this.kind || (superType.byteSize() > this.byteSize() && this.kind != Kind.BYTE); + } + // Due to float >: long, all integers are subtypes of floating point types. + return (superType.isFloating() && !this.isFloating()) || + // Generally, narrower types are subtypes of wider types. + (superType.isFloating() == this.isFloating() && superType.byteSize() >= this.byteSize()); + } + + return false; } @Override @@ -141,6 +159,35 @@ public final class PrimitiveType implements CodeGenerationDataNameType { }; } + /** + * Provides the field descriptor for primitive types as per JVMS§4.3.2. + * + * @return the field descriptor of the type. + */ + public String fieldDesc() { + return switch (kind) { + case LONG -> "J"; + case BOOLEAN -> "Z"; + default -> boxedTypeName().substring(0, 1); + }; + } + + /** + * Provides the abbreviation of the type as it would be used for node classes in the + * IR-Framework. Note the the abbreviations for boolean and char are used inconsistently. + * This method maps boolean to "UB", even though it might sometimes be mapped under "B" since + * it is loaded as a byte, and char to "C", even though it might sometimes be mapped to "US" + * for "unsigned short". + * + * @return the abbreviation of the type. + */ + public String abbrev() { + return switch (kind) { + case BOOLEAN -> "UB"; + default -> boxedTypeName().substring(0, 1); + }; + } + /** * Indicates if the type is a floating point type. * diff --git a/test/hotspot/jtreg/compiler/longcountedloops/TestLoopNestTooManyTraps.java b/test/hotspot/jtreg/compiler/longcountedloops/TestLoopNestTooManyTraps.java index 502afc56548..c2008a2cccb 100644 --- a/test/hotspot/jtreg/compiler/longcountedloops/TestLoopNestTooManyTraps.java +++ b/test/hotspot/jtreg/compiler/longcountedloops/TestLoopNestTooManyTraps.java @@ -25,6 +25,7 @@ * @test * @bug 8350330 * @summary C2: PhaseIdealLoop::add_parse_predicate() should mirror GraphKit::add_parse_predicate() + * @requires vm.flagless * @library /test/lib / * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/loopopts/TestBoxingInfiniteLoopBrokenIf.java b/test/hotspot/jtreg/compiler/loopopts/TestBoxingInfiniteLoopBrokenIf.java new file mode 100644 index 00000000000..18b4816445b --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestBoxingInfiniteLoopBrokenIf.java @@ -0,0 +1,88 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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 8378005 + * @summary Verify that an infinite loop with boxing does not crash when the containing If is broken + * @library /test/lib / + * @run driver ${test.main.class} + */ + +package compiler.loopopts; +import compiler.lib.ir_framework.*; +import jdk.test.lib.Utils; + +public class TestBoxingInfiniteLoopBrokenIf { + static boolean flag; + static volatile boolean testReturned; + + public static void main(String[] args) { + TestFramework framework = new TestFramework(); + framework.addScenarios( + new Scenario(0), + new Scenario(1, "-XX:PerMethodTrapLimit=0", "-XX:CompileCommand=dontinline,*::valueOf", "-XX:CompileCommand=dontinline,*::throwWrongPath"), + new Scenario(2, "-XX:PerMethodTrapLimit=0", "-XX:CompileCommand=dontinline,*::valueOf", "-XX:CompileCommand=dontinline,*::throwWrongPath", + "-XX:+IgnoreUnrecognizedVMOptions", "-XX:StressLongCountedLoop=1") + ); + framework.start(); + } + + @Test + static void test() { + new Integer(0); // Enable EA + Loop opts + + if (flag) { // Always false + throwWrongPath(); // Not inlined to simplify graph + } else { + // Infinite loop: j is always 0, Integer.valueOf(0) < 1 is always true. + for (int j = 0; Integer.valueOf(j) < 1;) { + j = 0; + } + } + } + + @Run(test = "test") + @Warmup(0) + static void runTest(RunInfo info) { + testReturned = false; + Thread thread = new Thread(() -> { + test(); + testReturned = true; + }); + thread.setDaemon(true); + thread.start(); + try { + Thread.sleep(Utils.adjustTimeout(500)); + } catch (InterruptedException e) { + } + if (testReturned) { + throw new RuntimeException("test() should not return: infinite loop was incorrectly optimized away"); + } + } + + static void throwWrongPath() { + throw new RuntimeException("Wrong path"); + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestCountedLoopSafepointBackedge.java b/test/hotspot/jtreg/compiler/loopopts/TestCountedLoopSafepointBackedge.java index e277f15035a..31c32f2cd2a 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestCountedLoopSafepointBackedge.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestCountedLoopSafepointBackedge.java @@ -24,7 +24,7 @@ /** * @test * @bug 8161147 - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Safepoint on backedge breaks UseCountedLoopSafepoints * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+UseCountedLoopSafepoints TestCountedLoopSafepointBackedge * diff --git a/test/hotspot/jtreg/compiler/loopopts/TestLoopPeeling.java b/test/hotspot/jtreg/compiler/loopopts/TestLoopPeeling.java index a32f3cb851a..aab6e4f2aaa 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestLoopPeeling.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestLoopPeeling.java @@ -23,12 +23,27 @@ /* * @test - * @bug 8078262 8177095 - * @summary Tests correct dominator information after loop peeling. + * @bug 8078262 8177095 8371685 + * @summary Tests correct dominator information after loop peeling and + * tests that LoopPeeling flag correctly disables loop peeling. * * @run main/othervm -Xcomp * -XX:CompileCommand=compileonly,compiler.loopopts.TestLoopPeeling::test* * compiler.loopopts.TestLoopPeeling + * @run main/othervm -Xcomp + * -XX:+UnlockDiagnosticVMOptions -XX:LoopPeeling=0 + * -XX:CompileCommand=compileonly,compiler.loopopts.TestLoopPeeling::test* + * compiler.loopopts.TestLoopPeeling + * @run main/othervm -Xbatch + * -XX:+UnlockDiagnosticVMOptions -XX:LoopPeeling=0 + * compiler.loopopts.TestLoopPeeling + * @run main/othervm -Xcomp + * -XX:+UnlockDiagnosticVMOptions -XX:LoopPeeling=2 + * -XX:CompileCommand=compileonly,compiler.loopopts.TestLoopPeeling::test* + * compiler.loopopts.TestLoopPeeling + * @run main/othervm -Xbatch + * -XX:+UnlockDiagnosticVMOptions -XX:LoopPeeling=2 + * compiler.loopopts.TestLoopPeeling */ package compiler.loopopts; @@ -44,6 +59,8 @@ public class TestLoopPeeling { test.testArrayAccess2(0); test.testArrayAccess3(0, false); test.testArrayAllocation(0, 1); + test.testEmptyLoop(100); + test.testMaxUnrollOddTrip(); } catch (Exception e) { // Ignore exceptions } @@ -142,5 +159,19 @@ public class TestLoopPeeling { } return null; } -} + public void testEmptyLoop(int limit) { + for (int i = 0; i < limit; i++) { + // Empty body - candidate for empty loop removal + } + } + + public int testMaxUnrollOddTrip() { + int sum = 0; + // Trip count of 5 (odd) - maximal unroll needs to peel one iteration + for (int i = 0; i < 5; i++) { + sum += array[i]; + } + return sum; + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestLoopPeelingDisabled.java b/test/hotspot/jtreg/compiler/loopopts/TestLoopPeelingDisabled.java new file mode 100644 index 00000000000..e7bbe24d1de --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestLoopPeelingDisabled.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2026, 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 compiler.loopopts; + +import compiler.lib.ir_framework.*; +import compiler.lib.ir_framework.driver.irmatching.IRViolationException; +import jdk.test.lib.Asserts; + +/* + * @test + * @bug 8371685 + * @requires vm.flagless & vm.debug + * @summary Verifies that the LoopPeeling flag correctly disables loop peeling + * by checking whether the "After Loop Peeling" compile phase is + * emitted. When loop peeling is disabled, no peeling should occur and + * the phase must be absent from the compilation output. + * @library /test/lib / + * @run driver compiler.loopopts.TestLoopPeelingDisabled + */ +public class TestLoopPeelingDisabled { + static int[] array = new int[100]; + + public static void main(String[] args) { + // First, run the test with loop peeling enabled, which is the default. + // The IR framework should catch if the number of counted loops does not + // match the annotations. + TestFramework.run(); + + // Then, run the same test with loop peeling disabled, which should + // elide the {BEFORE,AFTER}_LOOP_PEELING compilation phases, causing the + // test to throw an IRViolationException. We then check whether the + // exception message matches our expectation (that the loop peeling + // phase was not found). + try { + TestFramework.runWithFlags("-XX:+UnlockDiagnosticVMOptions", + "-XX:LoopPeeling=0"); + Asserts.fail("Expected IRViolationException"); + } catch (IRViolationException e) { + String info = e.getExceptionInfo(); + if (!info.contains("NO compilation output found for this phase")) { + Asserts.fail("Unexpected IR violation: " + info); + } + System.out.println("Loop peeling correctly disabled"); + } + + // Finally, run the same test with loop peeling disabled only when + // splitting iterations. Since the function being tested does not hit + // this case, we expect that the loop will be peeled, which is ensured + // by the IR annotations. + TestFramework.runWithFlags("-XX:+UnlockDiagnosticVMOptions", + "-XX:LoopPeeling=2"); + } + + @Test + @IR(counts = {IRNode.COUNTED_LOOP, "1"}, phase = CompilePhase.BEFORE_LOOP_PEELING) + @IR(counts = {IRNode.COUNTED_LOOP, "2"}, phase = CompilePhase.AFTER_LOOP_PEELING) + public static int test() { + int sum = 0; + + // Use an odd trip count so that `do_maximally_unroll()` tries to peel + // the odd iteration. + for (int i = 0; i < 5; i++) { + sum += array[i]; + } + + return sum; + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopInfiniteLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopInfiniteLoop.java new file mode 100644 index 00000000000..81996018a2b --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopInfiniteLoop.java @@ -0,0 +1,75 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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 8378005 + * @summary assert in proj_out when StressLongCountedLoop converts infinite loop to long counted loop nest + * @run main ${test.main.class} + * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:StressLongCountedLoop=1 + * -XX:CompileCommand=compileonly,${test.main.class}::test ${test.main.class} + */ + +package compiler.loopopts; + +public class TestStressLongCountedLoopInfiniteLoop { + static int RANGE; + + public static void main(String[] args) { + int[] a = new int[RANGE]; + for (int i = 0; i < 10000; i++) { + try { + test(a, 0); + } catch (ArrayIndexOutOfBoundsException e) { + } + } + } + + static void test(int[] a, int invar) { + // new Integer(0) works too, using MyInteger to avoid deprecation warnings. + a[new MyInteger(0).v()] = 0; + + Object o; + for (int i = 0; i < 1; i++) { + o = 1; + } + + // Infinite loop: j is always 0, 0 < 1 is always true. + for (int j = 0; Integer.valueOf(j) < 1;) { + j = 0; + } + } + + static class MyInteger { + int v; + + MyInteger(int v) { + this.v = v; + } + + int v() { + return Integer.valueOf(v); + } + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopLimitChecks.java b/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopLimitChecks.java new file mode 100644 index 00000000000..fd0143acdb6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestStressLongCountedLoopLimitChecks.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2026 IBM 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 compiler.loopopts; + +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.io.IOException; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * @test + * @bug 8353290 + * @summary test loop limit checks are inserted when stressing int counted loops to long counted loops + * @library /test/lib + * @requires vm.debug == true + * @run driver compiler.loopopts.TestStressLongCountedLoopLimitChecks + */ +public class TestStressLongCountedLoopLimitChecks { + public static void main(String[] args) throws Exception { + test(BasicLauncher.class, 1, "-XX:StressLongCountedLoop=0"); + test(BasicLauncher.class, 1, "-XX:StressLongCountedLoop=2000000"); + + test(LargeStrideLauncher.class, 2, "-XX:StressLongCountedLoop=0"); + test(LargeStrideLauncher.class, 2, "-XX:StressLongCountedLoop=2000000"); + } + + private static void test(Class launcher, int limitChecks, String... flags) throws IOException { + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + Stream.concat(Arrays.stream(flags), Stream.of( + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+TraceLoopLimitCheck", + "-XX:CompileOnly=" + launcher.getName() + "::test*", + "-Xcomp", + launcher.getName() + )).toList() + ); + + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + analyzer.shouldHaveExitValue(0); + + analyzer.outputTo(System.out); + analyzer.errorTo(System.err); + + Asserts.assertEQ( + limitChecks, + (int) analyzer.asLines().stream().filter( + l -> l.trim().matches("Counted Loop Limit Check generated:") + ).count(), + "wrong numbers of loop limit checks" + ); + } + + public static class BasicLauncher { + static int x, y, z; + + public static void main(String[] args) throws Exception { + test(); + } + + static void test() { + int i = x; // Any int + do { + x += y; + i++; // Could overflow and thus we need a Loop Limit Check Predicate "i < z" + } while (i < z); + } + } + + public static class LargeStrideLauncher { + static final int STRIDE = 100_000; + + public static void main(String[] args) throws Exception { + Asserts.assertEQ(10_000_000L / STRIDE, test(0, 10_000_000), "loop not stopped"); + Asserts.assertEQ(-1L, test(0, Integer.MAX_VALUE), "loop stopped prematurely"); + } + + static long ONE = 1; // Just so the compiler doesn't try to IV replace the whole thing + + public static long test(int init, int limit) { + final int stride = 100_000; + + long iterations = 0; + for (int i = init; i < limit; i += 100000) { + iterations += ONE; + + if (iterations > (limit / stride) + 1) { // No it's not stopping, as we should expect. + return -1; + } + } + return iterations; // Possibly stopping prematurely. + } + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java b/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java index 2a9cedfc87e..378c8e6da75 100644 --- a/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java +++ b/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java @@ -28,7 +28,7 @@ * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop * @library /test/lib / * @requires vm.compMode != "Xint" & vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) & vm.debug == true - * @requires !vm.emulatedClient & !vm.graal.enabled + * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox @@ -37,7 +37,6 @@ package compiler.loopopts; -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import java.util.List; diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestCompatibleUseDefTypeSize.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestCompatibleUseDefTypeSize.java index 0e17489e1c8..e6edda9085a 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/TestCompatibleUseDefTypeSize.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestCompatibleUseDefTypeSize.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 IBM Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,17 +25,19 @@ package compiler.loopopts.superword; import compiler.lib.ir_framework.*; +import compiler.lib.verify.Verify; import jdk.test.lib.Utils; import jdk.test.whitebox.WhiteBox; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; import java.lang.reflect.Array; import java.util.Map; import java.util.HashMap; import java.util.Random; -import java.nio.ByteOrder; /* * @test - * @bug 8325155 + * @bug 8325155 8342095 * @key randomness * @summary Test some cases that vectorize after the removal of the alignment boundaries code. * Now, we instead check if use-def connections have compatible type size. @@ -61,6 +64,8 @@ public class TestCompatibleUseDefTypeSize { float[] bF; double[] aD; double[] bD; + MemorySegment aMSF; + MemorySegment aMSD; // List of tests Map tests = new HashMap(); @@ -92,6 +97,8 @@ public class TestCompatibleUseDefTypeSize { bF = generateF(); aD = generateD(); bD = generateD(); + aMSF = generateMemorySegmentF(); + aMSD = generateMemorySegmentD(); // Add all tests to list tests.put("test0", () -> { return test0(aB.clone(), bC.clone()); }); @@ -106,6 +113,26 @@ public class TestCompatibleUseDefTypeSize { tests.put("test9", () -> { return test9(aL.clone(), bD.clone()); }); tests.put("test10", () -> { return test10(aL.clone(), bD.clone()); }); tests.put("test11", () -> { return test11(aC.clone()); }); + tests.put("testByteToInt", () -> { return testByteToInt(aB.clone(), bI.clone()); }); + tests.put("testByteToShort", () -> { return testByteToShort(aB.clone(), bS.clone()); }); + tests.put("testByteToChar", () -> { return testByteToChar(aB.clone(), bC.clone()); }); + tests.put("testByteToLong", () -> { return testByteToLong(aB.clone(), bL.clone()); }); + tests.put("testShortToByte", () -> { return testShortToByte(aS.clone(), bB.clone()); }); + tests.put("testShortToChar", () -> { return testShortToChar(aS.clone(), bC.clone()); }); + tests.put("testShortToInt", () -> { return testShortToInt(aS.clone(), bI.clone()); }); + tests.put("testShortToLong", () -> { return testShortToLong(aS.clone(), bL.clone()); }); + tests.put("testIntToShort", () -> { return testIntToShort(aI.clone(), bS.clone()); }); + tests.put("testIntToChar", () -> { return testIntToChar(aI.clone(), bC.clone()); }); + tests.put("testIntToByte", () -> { return testIntToByte(aI.clone(), bB.clone()); }); + tests.put("testIntToLong", () -> { return testIntToLong(aI.clone(), bL.clone()); }); + tests.put("testLongToByte", () -> { return testLongToByte(aL.clone(), bB.clone()); }); + tests.put("testLongToShort", () -> { return testLongToShort(aL.clone(), bS.clone()); }); + tests.put("testLongToChar", () -> { return testLongToChar(aL.clone(), bC.clone()); }); + tests.put("testLongToInt", () -> { return testLongToInt(aL.clone(), bI.clone()); }); + tests.put("testFloatToIntMemorySegment", () -> { return testFloatToIntMemorySegment(copyF(aMSF), bF.clone()); }); + tests.put("testDoubleToLongMemorySegment", () -> { return testDoubleToLongMemorySegment(copyD(aMSD), bD.clone()); }); + tests.put("testIntToFloatMemorySegment", () -> { return testIntToFloatMemorySegment(copyF(aMSF), bF.clone()); }); + tests.put("testLongToDoubleMemorySegment", () -> { return testLongToDoubleMemorySegment(copyD(aMSD), bD.clone()); }); // Compute gold value for all test methods before compilation for (Map.Entry entry : tests.entrySet()) { @@ -128,7 +155,27 @@ public class TestCompatibleUseDefTypeSize { "test8", "test9", "test10", - "test11"}) + "test11", + "testByteToInt", + "testByteToShort", + "testByteToChar", + "testByteToLong", + "testShortToByte", + "testShortToChar", + "testShortToInt", + "testShortToLong", + "testIntToShort", + "testIntToChar", + "testIntToByte", + "testIntToLong", + "testLongToByte", + "testLongToShort", + "testLongToChar", + "testLongToInt", + "testFloatToIntMemorySegment", + "testDoubleToLongMemorySegment", + "testIntToFloatMemorySegment", + "testLongToDoubleMemorySegment"}) public void runTests() { for (Map.Entry entry : tests.entrySet()) { String name = entry.getKey(); @@ -138,7 +185,7 @@ public class TestCompatibleUseDefTypeSize { // Compute new result Object[] result = test.run(); // Compare gold and new result - verify(name, gold, result); + Verify.checkEQ(gold, result); } } @@ -198,119 +245,32 @@ public class TestCompatibleUseDefTypeSize { return a; } - static void verify(String name, Object[] gold, Object[] result) { - if (gold.length != result.length) { - throw new RuntimeException("verify " + name + ": not the same number of outputs: gold.length = " + - gold.length + ", result.length = " + result.length); - } - for (int i = 0; i < gold.length; i++) { - Object g = gold[i]; - Object r = result[i]; - if (g.getClass() != r.getClass() || !g.getClass().isArray() || !r.getClass().isArray()) { - throw new RuntimeException("verify " + name + ": must both be array of same type:" + - " gold[" + i + "].getClass() = " + g.getClass().getSimpleName() + - " result[" + i + "].getClass() = " + r.getClass().getSimpleName()); - } - if (g == r) { - throw new RuntimeException("verify " + name + ": should be two separate arrays (with identical content):" + - " gold[" + i + "] == result[" + i + "]"); - } - if (Array.getLength(g) != Array.getLength(r)) { - throw new RuntimeException("verify " + name + ": arrays must have same length:" + - " gold[" + i + "].length = " + Array.getLength(g) + - " result[" + i + "].length = " + Array.getLength(r)); - } - Class c = g.getClass().getComponentType(); - if (c == byte.class) { - verifyB(name, i, (byte[])g, (byte[])r); - } else if (c == short.class) { - verifyS(name, i, (short[])g, (short[])r); - } else if (c == char.class) { - verifyC(name, i, (char[])g, (char[])r); - } else if (c == int.class) { - verifyI(name, i, (int[])g, (int[])r); - } else if (c == long.class) { - verifyL(name, i, (long[])g, (long[])r); - } else if (c == float.class) { - verifyF(name, i, (float[])g, (float[])r); - } else if (c == double.class) { - verifyD(name, i, (double[])g, (double[])r); - } else { - throw new RuntimeException("verify " + name + ": array type not supported for verify:" + - " gold[" + i + "].getClass() = " + g.getClass().getSimpleName() + - " result[" + i + "].getClass() = " + r.getClass().getSimpleName()); - } + static MemorySegment generateMemorySegmentF() { + MemorySegment a = MemorySegment.ofArray(new float[RANGE]); + for (int i = 0; i < (int) a.byteSize(); i += 8) { + a.set(ValueLayout.JAVA_LONG_UNALIGNED, i, RANDOM.nextLong()); } + return a; } - static void verifyB(String name, int i, byte[] g, byte[] r) { - for (int j = 0; j < g.length; j++) { - if (g[j] != r[j]) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } + MemorySegment copyF(MemorySegment src) { + MemorySegment dst = generateMemorySegmentF(); + MemorySegment.copy(src, 0, dst, 0, src.byteSize()); + return dst; } - static void verifyS(String name, int i, short[] g, short[] r) { - for (int j = 0; j < g.length; j++) { - if (g[j] != r[j]) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } + static MemorySegment generateMemorySegmentD() { + MemorySegment a = MemorySegment.ofArray(new double[RANGE]); + for (int i = 0; i < (int) a.byteSize(); i += 8) { + a.set(ValueLayout.JAVA_LONG_UNALIGNED, i, RANDOM.nextLong()); } + return a; } - static void verifyC(String name, int i, char[] g, char[] r) { - for (int j = 0; j < g.length; j++) { - if (g[j] != r[j]) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } - } - - static void verifyI(String name, int i, int[] g, int[] r) { - for (int j = 0; j < g.length; j++) { - if (g[j] != r[j]) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } - } - - static void verifyL(String name, int i, long[] g, long[] r) { - for (int j = 0; j < g.length; j++) { - if (g[j] != r[j]) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } - } - - static void verifyF(String name, int i, float[] g, float[] r) { - for (int j = 0; j < g.length; j++) { - if (Float.floatToIntBits(g[j]) != Float.floatToIntBits(r[j])) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } - } - - static void verifyD(String name, int i, double[] g, double[] r) { - for (int j = 0; j < g.length; j++) { - if (Double.doubleToLongBits(g[j]) != Double.doubleToLongBits(r[j])) { - throw new RuntimeException("verify " + name + ": arrays must have same content:" + - " gold[" + i + "][" + j + "] = " + g[j] + - " result[" + i + "][" + j + "] = " + r[j]); - } - } + MemorySegment copyD(MemorySegment src) { + MemorySegment dst = generateMemorySegmentD(); + MemorySegment.copy(src, 0, dst, 0, src.byteSize()); + return dst; } @Test @@ -328,12 +288,12 @@ public class TestCompatibleUseDefTypeSize { } @Test - @IR(counts = {IRNode.STORE_VECTOR, "= 0"}, + @IR(counts = {IRNode.STORE_VECTOR, "> 0"}, applyIfPlatform = {"64-bit", "true"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + applyIf = {"AlignVector", "false"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}) // "inflate" method: 1 byte -> 2 byte. // Java scalar code has no explicit conversion. - // Vector code would need a conversion. We may add this in the future. static Object[] test1(byte[] src, char[] dst) { for (int i = 0; i < src.length; i++) { dst[i] = (char)(src[i]); @@ -478,4 +438,261 @@ public class TestCompatibleUseDefTypeSize { } return new Object[]{ a, new char[] { m } }; } + + // Narrowing + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) + public Object[] testIntToShort(int[] ints, short[] res) { + for (int i = 0; i < ints.length; i++) { + res[i] = (short) ints[i]; + } + + return new Object[] { ints, res }; + } + + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_char)", ">0" }) + public Object[] testIntToChar(int[] ints, char[] res) { + for (int i = 0; i < ints.length; i++) { + res[i] = (char) ints[i]; + } + + return new Object[] { ints, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", ">0" }) + public Object[] testIntToByte(int[] ints, byte[] res) { + for (int i = 0; i < ints.length; i++) { + res[i] = (byte) ints[i]; + } + + return new Object[] { ints, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_S2B, IRNode.VECTOR_SIZE + "min(max_short, max_byte)", ">0" }) + public Object[] testShortToByte(short[] shorts, byte[] res) { + for (int i = 0; i < shorts.length; i++) { + res[i] = (byte) shorts[i]; + } + + return new Object[] { shorts, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx2", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_L2B, IRNode.VECTOR_SIZE + "min(max_long, max_byte)", ">0" }) + public Object[] testLongToByte(long[] longs, byte[] res) { + for (int i = 0; i < longs.length; i++) { + res[i] = (byte) longs[i]; + } + + return new Object[] { longs, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_L2S, IRNode.VECTOR_SIZE + "min(max_long, max_short)", ">0" }) + public Object[] testLongToShort(long[] longs, short[] res) { + for (int i = 0; i < longs.length; i++) { + res[i] = (short) longs[i]; + } + + return new Object[] { longs, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_L2S, IRNode.VECTOR_SIZE + "min(max_long, max_char)", ">0" }) + public Object[] testLongToChar(long[] longs, char[] res) { + for (int i = 0; i < longs.length; i++) { + res[i] = (char) longs[i]; + } + + return new Object[] { longs, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_L2I, IRNode.VECTOR_SIZE + "min(max_long, max_int)", ">0" }) + public Object[] testLongToInt(long[] longs, int[] res) { + for (int i = 0; i < longs.length; i++) { + res[i] = (int) longs[i]; + } + + return new Object[] { longs, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.STORE_VECTOR, ">0" }) + public Object[] testShortToChar(short[] shorts, char[] res) { + for (int i = 0; i < shorts.length; i++) { + res[i] = (char) shorts[i]; + } + + return new Object[] { shorts, res }; + } + + // Widening + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_S2I, IRNode.VECTOR_SIZE + "min(max_short, max_int)", ">0" }) + public Object[] testShortToInt(short[] shorts, int[] res) { + for (int i = 0; i < shorts.length; i++) { + res[i] = shorts[i]; + } + + return new Object[] { shorts, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2I, IRNode.VECTOR_SIZE + "min(max_byte, max_int)", ">0" }) + public Object[] testByteToInt(byte[] bytes, int[] res) { + for (int i = 0; i < bytes.length; i++) { + res[i] = bytes[i]; + } + + return new Object[] { bytes, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2S, IRNode.VECTOR_SIZE + "min(max_byte, max_short)", ">0" }) + public Object[] testByteToShort(byte[] bytes, short[] res) { + for (int i = 0; i < bytes.length; i++) { + res[i] = bytes[i]; + } + + return new Object[] { bytes, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2S, IRNode.VECTOR_SIZE + "min(max_byte, max_char)", ">0" }) + public Object[] testByteToChar(byte[] bytes, char[] res) { + for (int i = 0; i < bytes.length; i++) { + res[i] = (char) bytes[i]; + } + + return new Object[] { bytes, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx2", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2L, IRNode.VECTOR_SIZE + "min(max_byte, max_long)", ">0" }) + public Object[] testByteToLong(byte[] bytes, long[] res) { + for (int i = 0; i < bytes.length; i++) { + res[i] = bytes[i]; + } + + return new Object[] { bytes, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_S2L, IRNode.VECTOR_SIZE + "min(max_short, max_long)", ">0" }) + public Object[] testShortToLong(short[] shorts, long[] res) { + for (int i = 0; i < shorts.length; i++) { + res[i] = shorts[i]; + } + + return new Object[] { shorts, res }; + } + + @Test + @IR(applyIfCPUFeatureOr = { "avx", "true", "asimd", "true", "rvv", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2L, IRNode.VECTOR_SIZE + "min(max_int, max_long)", ">0" }) + public Object[] testIntToLong(int[] ints, long[] res) { + for (int i = 0; i < ints.length; i++) { + res[i] = ints[i]; + } + + return new Object[] { ints, res }; + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", "> 0", + IRNode.STORE_VECTOR, "> 0", + IRNode.VECTOR_REINTERPRET, "> 0"}, + applyIf = {"AlignVector", "false"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + static Object[] testFloatToIntMemorySegment(MemorySegment a, float[] b) { + for (int i = 0; i < RANGE; i++) { + a.set(ValueLayout.JAVA_FLOAT_UNALIGNED, 4L * i, b[i]); + } + + return new Object[]{ a, b }; + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", "> 0", + IRNode.STORE_VECTOR, "> 0", + IRNode.VECTOR_REINTERPRET, "> 0"}, + applyIf = {"AlignVector", "false"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + static Object[] testDoubleToLongMemorySegment(MemorySegment a, double[] b) { + for (int i = 0; i < RANGE; i++) { + a.set(ValueLayout.JAVA_DOUBLE_UNALIGNED, 8L * i, b[i]); + } + + return new Object[]{ a, b }; + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", + IRNode.STORE_VECTOR, "> 0", + IRNode.VECTOR_REINTERPRET, "> 0"}, + applyIf = {"AlignVector", "false"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + static Object[] testIntToFloatMemorySegment(MemorySegment a, float[] b) { + for (int i = 0; i < RANGE; i++) { + b[i] = a.get(ValueLayout.JAVA_FLOAT_UNALIGNED, 4L * i); + } + + return new Object[]{ a, b }; + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", + IRNode.STORE_VECTOR, "> 0", + IRNode.VECTOR_REINTERPRET, "> 0"}, + applyIf = {"AlignVector", "false"}, + applyIfPlatform = {"64-bit", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + static Object[] testLongToDoubleMemorySegment(MemorySegment a, double[] b) { + for (int i = 0; i < RANGE; i++) { + b[i] = a.get(ValueLayout.JAVA_DOUBLE_UNALIGNED, 8L * i); + } + + return new Object[]{ a, b }; + } } diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestReductions.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestReductions.java index 1cd5cfa1e75..5c085e6a3a3 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/TestReductions.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestReductions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +23,7 @@ /* * @test id=no-vectorization - * @bug 8340093 + * @bug 8340093 8342095 * @summary Test vectorization of reduction loops. * @library /test/lib / * @run driver compiler.loopopts.superword.TestReductions P0 @@ -31,7 +31,7 @@ /* * @test id=vanilla - * @bug 8340093 + * @bug 8340093 8342095 * @summary Test vectorization of reduction loops. * @library /test/lib / * @run driver compiler.loopopts.superword.TestReductions P1 @@ -39,7 +39,7 @@ /* * @test id=force-vectorization - * @bug 8340093 + * @bug 8340093 8342095 * @summary Test vectorization of reduction loops. * @library /test/lib / * @run driver compiler.loopopts.superword.TestReductions P2 @@ -455,7 +455,13 @@ public class TestReductions { // ---------byte***Simple ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteAndSimple() { byte acc = (byte)0xFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -466,7 +472,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteOrSimple() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -477,7 +489,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteXorSimple() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -510,7 +528,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMinSimple() { byte acc = Byte.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -521,7 +545,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMaxSimple() { byte acc = Byte.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -533,7 +563,13 @@ public class TestReductions { // ---------byte***DotProduct ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteAndDotProduct() { byte acc = (byte)0xFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -544,7 +580,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteOrDotProduct() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -555,7 +597,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteXorDotProduct() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -588,7 +636,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMinDotProduct() { byte acc = Byte.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -599,7 +653,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMaxDotProduct() { byte acc = Byte.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -611,7 +671,13 @@ public class TestReductions { // ---------byte***Big ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteAndBig() { byte acc = (byte)0xFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -622,7 +688,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteOrBig() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -633,7 +705,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteXorBig() { byte acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -666,7 +744,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMinBig() { byte acc = Byte.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -677,7 +761,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_B) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_B, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static byte byteMaxBig() { byte acc = Byte.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -923,7 +1013,13 @@ public class TestReductions { // ---------short***Simple ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortAndSimple() { short acc = (short)0xFFFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -934,7 +1030,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortOrSimple() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -945,7 +1047,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortXorSimple() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -978,7 +1086,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMinSimple() { short acc = Short.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -989,7 +1103,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMaxSimple() { short acc = Short.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1001,7 +1121,13 @@ public class TestReductions { // ---------short***DotProduct ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortAndDotProduct() { short acc = (short)0xFFFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1012,7 +1138,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortOrDotProduct() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1023,7 +1155,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortXorDotProduct() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1056,7 +1194,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMinDotProduct() { short acc = Short.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1067,7 +1211,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMaxDotProduct() { short acc = Short.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1079,7 +1229,13 @@ public class TestReductions { // ---------short***Big ------------------------------------------------------------ @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.AND_REDUCTION_V, "> 0", + IRNode.AND_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortAndBig() { short acc = (short)0xFFFF; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1090,7 +1246,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.OR_REDUCTION_V, "> 0", + IRNode.OR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortOrBig() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1101,7 +1263,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.XOR_REDUCTION_V, "> 0", + IRNode.XOR_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortXorBig() { short acc = 0; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1134,7 +1302,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MIN_REDUCTION_V, "> 0", + IRNode.MIN_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMinBig() { short acc = Short.MAX_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1145,7 +1319,13 @@ public class TestReductions { } @Test - @IR(failOn = IRNode.LOAD_VECTOR_S) // does not vectorize for now, might in the future. + @IR(counts = {IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.MAX_REDUCTION_V, "> 0", + IRNode.MAX_VI, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) + @IR(failOn = IRNode.LOAD_VECTOR_S, + applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) private static short shortMaxBig() { short acc = Short.MIN_VALUE; // neutral element for (int i = 0; i < SIZE; i++) { @@ -1160,7 +1340,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.AND_REDUCTION_V, "> 0", IRNode.AND_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1177,7 +1357,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.OR_REDUCTION_V, "> 0", IRNode.OR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1194,7 +1374,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.XOR_REDUCTION_V, "> 0", IRNode.XOR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1211,7 +1391,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1228,7 +1408,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MUL_REDUCTION_VI, "> 0", IRNode.MUL_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1245,7 +1425,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1262,7 +1442,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1280,7 +1460,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.AND_REDUCTION_V, "> 0", IRNode.AND_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1297,7 +1477,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.OR_REDUCTION_V, "> 0", IRNode.OR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1314,7 +1494,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.XOR_REDUCTION_V, "> 0", IRNode.XOR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1331,7 +1511,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1348,7 +1528,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MUL_REDUCTION_VI, "> 0", IRNode.MUL_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1365,7 +1545,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1382,7 +1562,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1400,7 +1580,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.AND_REDUCTION_V, "> 0", IRNode.AND_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1417,7 +1597,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.OR_REDUCTION_V, "> 0", IRNode.OR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1434,7 +1614,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.XOR_REDUCTION_V, "> 0", IRNode.XOR_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1451,7 +1631,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1468,7 +1648,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MUL_REDUCTION_VI, "> 0", IRNode.MUL_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1485,7 +1665,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1502,7 +1682,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_I, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1520,7 +1700,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.AND_REDUCTION_V, "> 0", IRNode.AND_VL, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1537,7 +1717,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.OR_REDUCTION_V, "> 0", IRNode.OR_VL, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1554,7 +1734,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.XOR_REDUCTION_V, "> 0", IRNode.XOR_VL, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1571,7 +1751,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.ADD_REDUCTION_VL, "> 0", IRNode.ADD_VL, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -1619,7 +1799,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VL, "> 0"}, - applyIfCPUFeatureOr = {"avx512", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx512", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIfCPUFeatureAnd = {"avx512", "false", "avx2", "true"}) @@ -1639,7 +1819,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VL, "> 0"}, - applyIfCPUFeatureOr = {"avx512", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx512", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_L, applyIfCPUFeatureAnd = {"avx512", "false", "avx2", "true"}) @@ -2027,7 +2207,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2044,7 +2224,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2104,7 +2284,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2121,7 +2301,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2181,7 +2361,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2198,7 +2378,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VF, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_F, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2264,7 +2444,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2281,7 +2461,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2341,7 +2521,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2358,7 +2538,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2418,7 +2598,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.MIN_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) @@ -2435,7 +2615,7 @@ public class TestReductions { @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.MAX_REDUCTION_V, "> 0", IRNode.MAX_VD, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}, applyIf = {"AutoVectorizationOverrideProfitability", "> 0"}) @IR(failOn = IRNode.LOAD_VECTOR_D, applyIf = {"AutoVectorizationOverrideProfitability", "= 0"}) diff --git a/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java b/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java index 19eb98af3ba..0693d6b3df0 100644 --- a/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java +++ b/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java @@ -157,7 +157,7 @@ public class Helper { } public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - StringUTF16.inflate(src, srcOff, dst, dstOff, len); + StringLatin1.inflate(src, srcOff, dst, dstOff, len); } public static int indexOf(byte[] src, int srcCount, diff --git a/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java b/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java index 895589ea03f..9d64a08b691 100644 --- a/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java +++ b/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java @@ -27,7 +27,7 @@ * @summary Parameters type profiling is not performed from aarch64 interpreter * * @requires os.arch != "arm" - * @requires vm.flavor == "server" & vm.compMode == "Xmixed" & !vm.emulatedClient & !vm.graal.enabled + * @requires vm.flavor == "server" & vm.compMode == "Xmixed" & !vm.graal.enabled * * @comment the test can't be run w/ TieredStopAtLevel < 4 * @requires vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4 @@ -94,8 +94,8 @@ public class TestTypeProfiling { } static public void main(String[] args) throws Exception { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } // Only execute if C2 is available if (TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { diff --git a/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java b/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java index d74a10ae02c..c48609647c1 100644 --- a/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java +++ b/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java @@ -447,8 +447,7 @@ public class TestExplicitRangeChecks { success = false; } // Only perform these additional checks if C2 is available - if (Platform.isServer() && !Platform.isEmulatedClient() && - TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { + if (Platform.isServer() && TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { if (deoptimize && WHITE_BOX.isMethodCompiled(m)) { System.out.println(name + " not deoptimized on invalid access"); success = false; diff --git a/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java b/test/hotspot/jtreg/compiler/splitif/TestTraceSplitIf.java similarity index 55% rename from test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java rename to test/hotspot/jtreg/compiler/splitif/TestTraceSplitIf.java index b152fc8c936..32f3a213215 100644 --- a/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java +++ b/test/hotspot/jtreg/compiler/splitif/TestTraceSplitIf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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,33 +21,38 @@ * questions. */ -package gc.arguments; - -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; - /* * @test - * @bug 8015107 - * @summary Tests that VM prints a warning when -XX:CompressedClassSpaceSize - * is used together with -XX:-UseCompressedClassPointers + * @bug 8351847 + * @summary Sanity test for -XX:+TraceSplitIf to ensure it doesn't crash and produces output. * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc - * java.management - * @requires vm.opt.CompressedClassSpaceSize == null & vm.opt.UseCompressedClassPointers == null - * @run driver gc.arguments.TestCompressedClassFlags + * @requires vm.compiler2.enabled & vm.debug + * @run driver ${test.main.class} */ -public class TestCompressedClassFlags { + +package compiler.splitif; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestTraceSplitIf { public static void main(String[] args) throws Exception { - if (Platform.is64bit()) { - OutputAnalyzer output = GCArguments.executeTestJava( - "-XX:CompressedClassSpaceSize=1g", - "-XX:-UseCompressedClassPointers", - "-version"); - output.shouldContain("warning"); - output.shouldNotContain("error"); - output.shouldHaveExitValue(0); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:+TraceSplitIf", + "-Xcomp", + HelloWorld.class.getName() + ); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + output.shouldContain("Merging Identical Ifs"); + output.shouldContain("Split-If"); + } + + public static class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World!"); } } } diff --git a/test/hotspot/jtreg/compiler/stable/TestStableArrayMembars.java b/test/hotspot/jtreg/compiler/stable/TestStableArrayMembars.java new file mode 100644 index 00000000000..9d7babddfb9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/stable/TestStableArrayMembars.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2026, 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 8377541 + * @summary Test that membars are eliminated when loading from a stable array. + * @library /test/lib / + * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.vm.annotation + * @run driver ${test.main.class} + */ + +package compiler.stable; + +import java.util.Objects; + +import jdk.internal.misc.Unsafe; +import jdk.internal.vm.annotation.Stable; + +import compiler.lib.ir_framework.*; + +public class TestStableArrayMembars { + + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + + public static void main(String[] args) { + TestFramework tf = new TestFramework(); + tf.addTestClassesToBootClassPath(); + tf.addFlags( "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + tf.start(); + } + + static final class LazyIntArray { + @Stable + private final Integer[] arr; + + LazyIntArray() { + this.arr = new Integer[10]; + } + + @ForceInline + Integer get(int idx) { + Integer i = contentsAcquire(offsetFor(idx)); + return i == null ? slowPath(arr, idx) : i; + } + + @ForceInline + private Integer contentsAcquire(long offset) { + return (Integer) UNSAFE.getReferenceAcquire(arr, offset); + } + + @ForceInline + private static long offsetFor(long index) { + return Unsafe.ARRAY_OBJECT_BASE_OFFSET + Unsafe.ARRAY_OBJECT_INDEX_SCALE * index; + } + + static Integer slowPath(final Integer[] array, final int index) { + final long offset = offsetFor(index); + final Integer t = array[index]; + if (t == null) { + final Integer newValue = Integer.valueOf(42); + Objects.requireNonNull(newValue); + set(array, index, newValue); + + return newValue; + } + return t; + } + + static void set(Integer[] array, int index, Integer newValue) { + if (array[index] == null) { + UNSAFE.putReferenceRelease(array, Unsafe.ARRAY_OBJECT_BASE_OFFSET + Unsafe.ARRAY_OBJECT_INDEX_SCALE * (long) index, newValue); + } + } + } + + static final LazyIntArray la = new LazyIntArray(); + + @Test + @IR(failOn = { IRNode.LOAD, IRNode.MEMBAR }) + static Integer test() { + return la.get(0); + } +} diff --git a/test/hotspot/jtreg/compiler/testlibrary/CompilerUtils.java b/test/hotspot/jtreg/compiler/testlibrary/CompilerUtils.java index 93be1971ca3..a8d953c5a30 100644 --- a/test/hotspot/jtreg/compiler/testlibrary/CompilerUtils.java +++ b/test/hotspot/jtreg/compiler/testlibrary/CompilerUtils.java @@ -53,10 +53,10 @@ public class CompilerUtils { "TieredStopAtLevel has value out of int capacity"); return IntStream.rangeClosed(1, maxLevel).toArray(); } else { - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { return new int[]{4}; } - if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { + if (Platform.isClient() || Platform.isMinimal()) { return new int[]{1}; } } diff --git a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java index 0c53c36af1d..52925fcf993 100644 --- a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java +++ b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java @@ -56,7 +56,7 @@ public class IntrinsicPredicates { "TieredStopAtLevel"); boolean maxLevelIsReachable = (tieredMaxLevel == IntrinsicPredicates.TIERED_MAX_LEVEL); - return Platform.isServer() && !Platform.isEmulatedClient() && (!isTiered || maxLevelIsReachable); + return Platform.isServer() && (!isTiered || maxLevelIsReachable); }; public static final BooleanSupplier MD5_INSTRUCTION_AVAILABLE @@ -109,6 +109,12 @@ public class IntrinsicPredicates { new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] {"avx512f", "avx512bw"}, null), new CPUSpecificPredicate("x86_64", new String[] {"avx512f", "avx512bw"}, null))); + public static final BooleanSupplier SHA3_INTRINSIC_AVAILABLE + // AArch64 has both SHA3-based and GPR-based implementations of the SHA3 intrinsic. No need for the SHA3 capability. + = new OrPredicate(new CPUSpecificPredicate("aarch64.*", null, null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] {"avx512f", "avx512bw"}, null), + new CPUSpecificPredicate("x86_64", new String[] {"avx512f", "avx512bw"}, null))); + public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, new OrPredicate(IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE, diff --git a/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java b/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java index d23b13a65e4..fd55187a7ef 100644 --- a/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java +++ b/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java @@ -47,10 +47,10 @@ public class NonTieredLevelsTest extends CompLevelsTest { private static final int AVAILABLE_COMP_LEVEL; private static final IntPredicate IS_AVAILABLE_COMPLEVEL; static { - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { AVAILABLE_COMP_LEVEL = COMP_LEVEL_FULL_OPTIMIZATION; IS_AVAILABLE_COMPLEVEL = x -> x == COMP_LEVEL_FULL_OPTIMIZATION; - } else if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { + } else if (Platform.isClient() || Platform.isMinimal()) { AVAILABLE_COMP_LEVEL = COMP_LEVEL_SIMPLE; IS_AVAILABLE_COMPLEVEL = x -> x == COMP_LEVEL_SIMPLE; } else { diff --git a/test/hotspot/jtreg/compiler/types/TestCheckCastPPBecomesTOP.java b/test/hotspot/jtreg/compiler/types/TestCheckCastPPBecomesTOP.java index 5c57e479307..38ab9121b47 100644 --- a/test/hotspot/jtreg/compiler/types/TestCheckCastPPBecomesTOP.java +++ b/test/hotspot/jtreg/compiler/types/TestCheckCastPPBecomesTOP.java @@ -30,9 +30,6 @@ * @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation * -XX:CompileOnly=TestCheckCastPPBecomesTOP::test1 -XX:LoopMaxUnroll=0 * -XX:CompileCommand=dontinline,TestCheckCastPPBecomesTOP::notInlined -XX:+UseParallelGC TestCheckCastPPBecomesTOP - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation - * -XX:CompileOnly=TestCheckCastPPBecomesTOP::test1 -XX:LoopMaxUnroll=0 - * -XX:CompileCommand=dontinline,TestCheckCastPPBecomesTOP::notInlined -XX:+UseParallelGC -XX:-UseCompressedClassPointers TestCheckCastPPBecomesTOP * */ diff --git a/test/hotspot/jtreg/compiler/types/correctness/CorrectnessTest.java b/test/hotspot/jtreg/compiler/types/correctness/CorrectnessTest.java index 895f8674ed5..08cbdb29aea 100644 --- a/test/hotspot/jtreg/compiler/types/correctness/CorrectnessTest.java +++ b/test/hotspot/jtreg/compiler/types/correctness/CorrectnessTest.java @@ -25,7 +25,7 @@ * @test CorrectnessTest * @bug 8038418 * @summary Tests correctness of type usage with type profiling and speculations - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management @@ -87,8 +87,8 @@ public class CorrectnessTest { private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); public static void main(String[] args) { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } Asserts.assertGTE(args.length, 1); ProfilingType profilingType = ProfilingType.valueOf(args[0]); diff --git a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java index 6f2354cf895..338c818fd3a 100644 --- a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java +++ b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java @@ -25,7 +25,7 @@ * @test CorrectnessTest * @key randomness * @bug 8038418 - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestPrintDiagnosticsWithoutProfileTraps.java b/test/hotspot/jtreg/compiler/uncommontrap/TestPrintDiagnosticsWithoutProfileTraps.java new file mode 100644 index 00000000000..51b30219aca --- /dev/null +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestPrintDiagnosticsWithoutProfileTraps.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2026, 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 8374807 + * @summary Regression test for -XX:+TraceDeoptimization -XX:-ProfileTraps + * -XX:-TieredCompilation -Xcomp crash + * @modules java.base/jdk.internal.misc + * @requires vm.debug + * @run main/othervm -XX:+TraceDeoptimization -XX:-ProfileTraps + * -XX:-TieredCompilation -Xcomp -Xbatch + * -XX:CompileCommand=compileonly,compiler.uncommontrap.TestPrintDiagnosticsWithoutProfileTraps::test + * compiler.uncommontrap.TestPrintDiagnosticsWithoutProfileTraps + */ + +package compiler.uncommontrap; + +import jdk.internal.misc.Unsafe; + +public class TestPrintDiagnosticsWithoutProfileTraps { + static final Unsafe UNSAFE=Unsafe.getUnsafe(); + static volatile long sink; + + static class TestSubClass { + int f; + } + + static void test(){ + // Trigger a deopt/uncommon-trap path while resolving the field offset. + sink = UNSAFE.objectFieldOffset(TestSubClass.class,"f"); + } + + public static void main(String[] args) { + test(); + System.out.println("passed"); + } +} \ No newline at end of file diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java index 04293370eb5..d539b56d850 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java @@ -210,7 +210,7 @@ public class TestUnstableIfTrap { boolean isMethodCompiledAtMaxTier = WB.getMethodCompilationLevel(m) == MAX_TIER; - return Platform.isServer() && !Platform.isEmulatedClient() && isMethodCompiled + return Platform.isServer() && isMethodCompiled && (!isTiered || isMethodCompiledAtMaxTier); } diff --git a/test/hotspot/jtreg/compiler/unsafe/OpaqueAccesses.java b/test/hotspot/jtreg/compiler/unsafe/OpaqueAccesses.java index 9a31cbbb057..00c3ce5fb7f 100644 --- a/test/hotspot/jtreg/compiler/unsafe/OpaqueAccesses.java +++ b/test/hotspot/jtreg/compiler/unsafe/OpaqueAccesses.java @@ -247,28 +247,14 @@ public class OpaqueAccesses { "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:-TieredCompilation", "-Xbatch", - "-XX:+UseCompressedOops", "-XX:+UseCompressedClassPointers", + "-XX:+UseCompressedOops", "-XX:CompileCommand=dontinline,compiler.unsafe.OpaqueAccesses::test*" ); TestFramework.runWithFlags( "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:-TieredCompilation", "-Xbatch", - "-XX:+UseCompressedOops", "-XX:-UseCompressedClassPointers", - "-XX:CompileCommand=dontinline,compiler.unsafe.OpaqueAccesses::test*" - ); - TestFramework.runWithFlags( - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+UnlockDiagnosticVMOptions", - "-XX:-TieredCompilation", "-Xbatch", - "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", - "-XX:CompileCommand=dontinline,compiler.unsafe.OpaqueAccesses::test*" - ); - TestFramework.runWithFlags( - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+UnlockDiagnosticVMOptions", - "-XX:-TieredCompilation", "-Xbatch", - "-XX:-UseCompressedOops", "-XX:-UseCompressedClassPointers", + "-XX:-UseCompressedOops", "-XX:CompileCommand=dontinline,compiler.unsafe.OpaqueAccesses::test*" ); } diff --git a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetConstantField.java b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetConstantField.java index 8b20cbf8ecd..bab22bb0cd0 100644 --- a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetConstantField.java +++ b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetConstantField.java @@ -27,7 +27,7 @@ * @library /test/lib * @library /testlibrary/asm * - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * * @modules java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc @@ -97,8 +97,8 @@ public class UnsafeGetConstantField { static final Unsafe U = Unsafe.getUnsafe(); public static void main(String[] args) { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } testUnsafeGetAddress(); testUnsafeGetField(); diff --git a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java index 9d3578bd6a1..a124c58055a 100644 --- a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java @@ -26,7 +26,7 @@ * @summary tests on constant folding of unsafe get operations from stable arrays * @library /test/lib * @build jdk.test.whitebox.WhiteBox - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * * @modules java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc @@ -343,8 +343,8 @@ public class UnsafeGetStableArrayElement { } public static void main(String[] args) throws Exception { - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } testUnsafeAccess(); System.out.println("TEST PASSED"); diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorLibraryUnaryOpAndBinaryOp.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLibraryUnaryOpAndBinaryOp.java new file mode 100644 index 00000000000..f7837e1abfa --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLibraryUnaryOpAndBinaryOp.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, NTT DATA + * 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 compiler.vectorapi; + +import compiler.lib.ir_framework.*; +import jdk.incubator.vector.*; + +/** + * @test + * @bug 8378312 + * @library /test/lib / + * @summary VectorAPI: libraryUnaryOp and libraryBinaryOp should be intrinsified. + * @modules jdk.incubator.vector + * + * @run driver compiler.vectorapi.TestVectorLibraryUnaryOpAndBinaryOp + */ + +public class TestVectorLibraryUnaryOpAndBinaryOp { + + @Test + @IR(counts = { IRNode.CALL_LEAF_VECTOR, "= 1" }, applyIfCPUFeatureOr = { "asimd", "true", "avx", "true" }) + public static void testUnary() { + var vec = FloatVector.broadcast(FloatVector.SPECIES_128, 3.14f); + vec.lanewise(VectorOperators.COS); + } + + @Test + @IR(counts = { IRNode.CALL_LEAF_VECTOR, "= 1" }, applyIfCPUFeatureOr = { "asimd", "true", "avx", "true" }) + public static void testBinary() { + var vec = FloatVector.broadcast(FloatVector.SPECIES_128, 2.0f); + vec.lanewise(VectorOperators.HYPOT, 1.0f); + } + + public static void main(String[] args) { + TestFramework testFramework = new TestFramework(); + testFramework.addFlags("--add-modules=jdk.incubator.vector") + .start(); + } + +} diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorLoadStoreOptimization.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLoadStoreOptimization.java index c603f450d0c..71507bde7c0 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestVectorLoadStoreOptimization.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLoadStoreOptimization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * Copyright (c) 2025, 2026, NVIDIA CORPORATION & 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,7 +29,7 @@ import jdk.incubator.vector.*; import jdk.test.lib.Asserts; /** - * @test 8371603 + * @test 8371603 8378239 * @key randomness * @library /test/lib / * @summary Test the missing optimization issues for vector load/store caused by JDK-8286941 @@ -96,6 +96,14 @@ public class TestVectorLoadStoreOptimization { } } + // Test that store a value that is just loaded from the same memory location is elided + @Test + @IR(failOn = IRNode.STORE_VECTOR, + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true", "rvv", "true"}) + public static void testStoreVector2() { + IntVector.fromArray(SPECIES, a, 0).intoArray(a, 0); + } + public static void main(String[] args) { TestFramework testFramework = new TestFramework(); testFramework.setDefaultWarmup(10000) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorLongToMaskNodeIdealization.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLongToMaskNodeIdealization.java new file mode 100644 index 00000000000..706e21554bb --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorLongToMaskNodeIdealization.java @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2026, 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 compiler.vectorapi; + +import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.Random; + +import jdk.test.lib.Utils; + +import compiler.lib.ir_framework.*; +import compiler.lib.verify.Verify; +import jdk.incubator.vector.*; +import compiler.lib.compile_framework.CompileFramework; + +import compiler.lib.template_framework.Template; +import compiler.lib.template_framework.TemplateToken; +import compiler.lib.template_framework.library.TestFrameworkClass; +import compiler.lib.template_framework.library.PrimitiveType; +import compiler.lib.template_framework.library.CodeGenerationDataNameType; +import static compiler.lib.template_framework.Template.scope; +import static compiler.lib.template_framework.Template.let; + +/* + * @test + * @bug 8277997 8378968 + * @key randomness + * @summary Testing some optimizations in VectorLongToMaskNode::Ideal + * For now: VectorMask.fromLong(.., mask.toLong()) + * @modules jdk.incubator.vector + * @library /test/lib / + * @compile ../../compiler/lib/ir_framework/TestFramework.java + * @compile ../../compiler/lib/generators/Generators.java + * @compile ../../compiler/lib/verify/Verify.java + * @run driver ${test.main.class} + */ +public class TestVectorLongToMaskNodeIdealization { + private static final Random RANDOM = Utils.getRandomInstance(); + + static final long[] ONES_L = new long[64]; + static { Arrays.fill(ONES_L, 1); } + + static final boolean[] TRUES = new boolean[64]; + static { Arrays.fill(TRUES, true); } + + public static void main(String[] args) { + // Run some tests directly first. + TestFramework testFramework = new TestFramework(); + testFramework.setDefaultWarmup(10000) + .addFlags("--add-modules=jdk.incubator.vector") + .start(); + + // Then also generate some random examples. + CompileFramework comp = new CompileFramework(); + comp.addJavaSourceCode("compiler.vectorapi.templated.Templated", generate(comp)); + comp.compile("--add-modules=jdk.incubator.vector"); + comp.invoke("compiler.vectorapi.templated.Templated", "main", new Object[] {new String[] { + "--add-modules=jdk.incubator.vector", + "--add-opens", "jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED", + "--add-opens", "java.base/java.lang=ALL-UNNAMED" + }}); + } + + // ------------------------------------------------------------------------------------- + @Test + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_LOAD_MASK, "> 0", // Not yet optimized away + IRNode.VECTOR_STORE_MASK, "> 0", // Not yet optimized away + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Not yet optimized away + IRNode.VECTOR_BLEND_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureAnd = {"avx2", "true", "avx512", "false"}) + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_LOAD_MASK, "= 0", // Optimized away + IRNode.VECTOR_STORE_MASK, "= 0", // Optimized away + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Cast I->J + IRNode.VECTOR_BLEND_I, "= 0", // Not needed + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeature = {"avx512", "true"}) + // This is the original reproducer for JDK-8378968, which failed on AVX2 with a wrong result. + public static Object test1() { + // There was a bug here with AVX2: + var ones = LongVector.broadcast(LongVector.SPECIES_256, 1); + var trues_L256 = ones.compare(VectorOperators.NE, 0); + // VectorMaskCmp #vectory -> (L-mask=0x0..0/0xF..F) + + var trues_I128 = VectorMask.fromLong(IntVector.SPECIES_128, trues_L256.toLong()); + // VectorStoreMask(L-mask to 0/1) + // VectorMaskToLong + // AndL(truncate) + // VectorLongToMask -> 0/1 + // + // VectorLongToMaskNode::Ideal transforms this into: + // VectorMaskCmp #vectory -> (L-mask=0x0..0/0xF..F) + // VectorMaskCastNode -> (L-mask=0x0..0/0xF..F to 0/1) + // But VectorMaskCastNode is not made for such mask conversion to boolean mask, + // and so it wrongly produces a 0x00/0xFF byte mask, instead of bytes 0x00/01. + // See: vector_mask_cast + // + // The correct transformation would have been to: + // VectorMaskCmp #vectory -> (L-mask=0x0..0/0xF..F) + // VectorStoreMask(L-mask to 0/1, i.e. 0x00/0x01 bytes) + + var zeros = IntVector.zero(IntVector.SPECIES_128); + var m1s = zeros.lanewise(VectorOperators.NOT, trues_I128); + // The rest of the code is: + // VectorLoadMask (0/1 to I-mask=0x0..0/0xF..F) + // It expects x=0x00/0x01 bytes, and does a subtraction 0-x to get values 0x00/0xFF + // that are then widened to int-length. + // But if it instead gets 0x00/0xFF, the subtraction produces 0x00/0x01 values, which + // are widened to int 0x0..0/0..01 values. + // See: load_vector_mask + // Blend, which expects I-mask (0x0..0/0xF..F) + // It looks at the 7th (uppermost) bit of every byte to determine which byte is taken. + // If it instead gets the 0x0..0/0x0..01 mask, it interprets both as "false". + + int[] out = new int[64]; + m1s.intoArray(out, 0); + return out; + } + + static final Object GOLD_TEST1 = test1(); + + @Check(test = "test1") + public static void check_test1(Object out) { + Verify.checkEQ(GOLD_TEST1, out); + } + // ------------------------------------------------------------------------------------- + @Test + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_LOAD_MASK, "> 0", // Not yet optimized away + IRNode.VECTOR_STORE_MASK, "> 0", // Not yet optimized away + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Not yet optimized away: Cast Z->Z, see JDK-8379866 + IRNode.VECTOR_BLEND_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureAnd = {"avx2", "true", "avx512", "false"}) + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_LOAD_MASK, "= 0", // Optimized away + IRNode.VECTOR_STORE_MASK, "= 0", // Optimized away + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Cast I->J + IRNode.VECTOR_BLEND_I, "= 0", // Not needed + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeature = {"avx512", "true"}) + // The original reproducer test1 could eventually constant-fold the comparison + // with zero and trues. So let's make sure we load the data from a mutable array. + public static Object test1b() { + // load instead of broadcast: + var ones = LongVector.fromArray(LongVector.SPECIES_256, ONES_L, 0); + var trues_L256 = ones.compare(VectorOperators.NE, 0); + + var trues_I128 = VectorMask.fromLong(IntVector.SPECIES_128, trues_L256.toLong()); + + var zeros = IntVector.zero(IntVector.SPECIES_128); + var m1s = zeros.lanewise(VectorOperators.NOT, trues_I128); + + int[] out = new int[64]; + m1s.intoArray(out, 0); + return out; + } + + static final Object GOLD_TEST1B = test1b(); + + @Check(test = "test1b") + public static void check_test1b(Object out) { + Verify.checkEQ(GOLD_TEST1B, out); + } + // ------------------------------------------------------------------------------------- + @Test + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "= 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.LOAD_VECTOR_Z, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "= 0", + IRNode.VECTOR_LOAD_MASK, "> 0", + IRNode.VECTOR_STORE_MASK, "= 0", + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Not yet optimized Z->Z, see JDK-8379866 + IRNode.VECTOR_BLEND_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureAnd = {"avx2", "true", "avx512", "false"}) + @IR(counts = {IRNode.REPLICATE_L, IRNode.VECTOR_SIZE_4, "= 0", + IRNode.REPLICATE_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.LOAD_VECTOR_Z, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "= 0", + IRNode.VECTOR_LOAD_MASK, "> 0", + IRNode.VECTOR_STORE_MASK, "= 0", + IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0", // Optimized away + IRNode.VECTOR_MASK_CAST, "> 0", // Cast I->J + IRNode.VECTOR_BLEND_I, "= 0", // Not needed + IRNode.XOR_VI, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeature = {"avx512", "true"}) + // And now let's try a case where we load the mask from boolean array, so we don't + // have the VectorStoreMask before the VectorMaskToLong. + public static Object test1c() { + // Load true mask from array directly. + var trues_L256 = VectorMask.fromArray(LongVector.SPECIES_256, TRUES, 0); + + var trues_I128 = VectorMask.fromLong(IntVector.SPECIES_128, trues_L256.toLong()); + + var zeros = IntVector.zero(IntVector.SPECIES_128); + var m1s = zeros.lanewise(VectorOperators.NOT, trues_I128); + + int[] out = new int[64]; + m1s.intoArray(out, 0); + return out; + } + + static final Object GOLD_TEST1C = test1c(); + + @Check(test = "test1c") + public static void check_test1c(Object out) { + Verify.checkEQ(GOLD_TEST1C, out); + } + // ------------------------------------------------------------------------------------- + + // TODO: we can refactor this away once JDK-8369699 is integrated. + record VectorType(PrimitiveType elementType, int length) { + String typeName() { + return switch(elementType.name()) { + case "byte" -> "ByteVector"; + case "short" -> "ShortVector"; + case "int" -> "IntVector"; + case "long" -> "LongVector"; + case "float" -> "FloatVector"; + case "double" -> "DoubleVector"; + default -> throw new UnsupportedOperationException("Not supported: " + elementType.name()); + }; + } + + String speciesName() { + return typeName() + ".SPECIES_" + bitSize(); + } + + int bitSize() { + return elementType.byteSize() * length() * 8; + } + } + + public static final List VECTOR_TYPES = List.of( + new VectorType(CodeGenerationDataNameType.bytes(), 8), + new VectorType(CodeGenerationDataNameType.bytes(), 16), + new VectorType(CodeGenerationDataNameType.bytes(), 32), + new VectorType(CodeGenerationDataNameType.bytes(), 64), + new VectorType(CodeGenerationDataNameType.shorts(), 4), + new VectorType(CodeGenerationDataNameType.shorts(), 8), + new VectorType(CodeGenerationDataNameType.shorts(), 16), + new VectorType(CodeGenerationDataNameType.shorts(), 32), + new VectorType(CodeGenerationDataNameType.ints(), 2), + new VectorType(CodeGenerationDataNameType.ints(), 4), + new VectorType(CodeGenerationDataNameType.ints(), 8), + new VectorType(CodeGenerationDataNameType.ints(), 16), + new VectorType(CodeGenerationDataNameType.longs(), 1), + new VectorType(CodeGenerationDataNameType.longs(), 2), + new VectorType(CodeGenerationDataNameType.longs(), 4), + new VectorType(CodeGenerationDataNameType.longs(), 8), + new VectorType(CodeGenerationDataNameType.floats(), 2), + new VectorType(CodeGenerationDataNameType.floats(), 4), + new VectorType(CodeGenerationDataNameType.floats(), 8), + new VectorType(CodeGenerationDataNameType.floats(), 16), + new VectorType(CodeGenerationDataNameType.doubles(), 1), + new VectorType(CodeGenerationDataNameType.doubles(), 2), + new VectorType(CodeGenerationDataNameType.doubles(), 4), + new VectorType(CodeGenerationDataNameType.doubles(), 8) + ); + + private static String generate(CompileFramework comp) { + // Create a list to collect all tests. + List tests = new ArrayList<>(); + + var testTemplate = Template.make("t1", "t2", (VectorType t1, VectorType t2) -> scope( + let("e1", t1.elementType()), + let("e2", t2.elementType()), + let("V1", t1.typeName()), + let("V2", t2.typeName()), + let("S1", t1.speciesName()), + let("S2", t2.speciesName()), + """ + // ------------ $test ------------- + @Test + @Warmup(10_000) + """, + // Now let's generate some IR rules. + // General Idea: if the lengths match, we can optimize. If the don't match, it is + // a truncation/zero extension, and we don't optimize. + // + // TODO: length=64 leads the AndL mask to be all-ones, and fold away immediately. + // We could eventually extend the optimization to handle that. See JDK-8379398. + // + // AVX512: expect vectorization in length range [4..64] + // TODO: 2-element masks are currently not properly intrinsified, see JDK-8378589. + (t1.length() >= 4 && t2.length() >= 4) + ?( (t1.length() == t2.length && t1.length() != 64) + ? """ + @IR(counts = {IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0"}, // Optimized away + applyIfCPUFeature = {"avx512", "true"}) + """ + : """ + @IR(counts = {IRNode.VECTOR_LONG_TO_MASK, "> 0", // Cannot optimize + IRNode.VECTOR_MASK_TO_LONG, "> 0"}, // Cannot optimize + applyIfCPUFeature = {"avx512", "true"}) + """) + :( """ + // AVX512: at least one vector length not in range [4..64] -> no IR rule. + """), + // AVX2: expect vectorization if: length >= 4 and bitSize <= 256 + // TODO: 2-element masks are currently not properly intrinsified, see JDK-8378589. + (t1.bitSize() <= 256 && t2.bitSize() <= 256 && t1.length() >= 4 && t2.length() >= 4) + ?( (t1.length() == t2.length) + ? """ + @IR(counts = {IRNode.VECTOR_LONG_TO_MASK, "= 0", // Optimized away + IRNode.VECTOR_MASK_TO_LONG, "= 0"}, // Optimized away + applyIfCPUFeatureAnd = {"avx2", "true", "avx512", "false"}) + """ + : """ + @IR(counts = {IRNode.VECTOR_LONG_TO_MASK, "> 0", // Cannot optimize + IRNode.VECTOR_MASK_TO_LONG, "> 0"}, // Cannot optimize + applyIfCPUFeatureAnd = {"avx2", "true", "avx512", "false"}) + """) + :( """ + // AVX2: at least one vector length not: length >= 4 and bitSize <= 256 -> no IR rule. + """), + """ + public static Object $test() { + var inputs = #V1.fromArray(#S1, $INPUT, 0); + var mask1 = inputs.compare(VectorOperators.GT, 0); + + var mask2 = VectorMask.fromLong(#S2, mask1.toLong()); + + var zeros = #V2.zero(#S2); + var m1s = #V2.broadcast(#S2, -1); + var res = zeros.blend(m1s, mask2); + + #e2[] out = new #e2[64]; + res.intoArray(out, 0); + return out; + } + + public static #e1[] $INPUT = new #e1[64]; + """, + "static { for (int i = 0; i < $INPUT.length; i++) { $INPUT[i] = ", t1.elementType().callLibraryRNG(), "; } }", + """ + public static Object $GOLD = $test(); + + @Check(test = "$test") + public static void $check(Object val) { + Verify.checkEQ($GOLD, val); + } + """ + )); + + tests.add(PrimitiveType.generateLibraryRNG()); + + // It would take a bit long to cover all 20*20=400 combinations, but we can sample some: + for (int i = 0; i < 20; i++) { + VectorType t1 = VECTOR_TYPES.get(RANDOM.nextInt(VECTOR_TYPES.size())); + VectorType t2 = VECTOR_TYPES.get(RANDOM.nextInt(VECTOR_TYPES.size())); + tests.add(testTemplate.asToken(t1, t2)); + } + + // Create the test class, which runs all testTemplateTokens. + return TestFrameworkClass.render( + // package and class name. + "compiler.vectorapi.templated", "Templated", + // List of imports. + Set.of("compiler.lib.verify.*", + "java.util.Random", + "jdk.test.lib.Utils", + "compiler.lib.generators.*", + "jdk.incubator.vector.*"), + // classpath, so the Test VM has access to the compiled class files. + comp.getEscapedClassPathOfCompiledClasses(), + // The list of tests. + tests); + } +} diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java new file mode 100644 index 00000000000..f9807754539 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2026, 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 8375688 + * @key randomness + * @library /test/lib / + * @summary VectorMaskToLong constant folding through VectorStoreMask must work under StressIncrementalInlining + * @modules jdk.incubator.vector + * + * @run driver ${test.main.class} + */ + +package compiler.vectorapi; + +import compiler.lib.ir_framework.*; +import jdk.incubator.vector.*; +import jdk.test.lib.Asserts; + +/** + * Tests that VectorMaskToLongNode::Ideal_MaskAll folds constant masks even + * when StressIncrementalInlining randomizes the IGVN worklist order. + * + * Each test method does {@code VectorMask.fromLong(SPECIES, constant).toLong()} + * and asserts that VectorMaskToLong is folded away entirely (count = 0). + * + * Ideal_MaskAll looks through VectorStoreMask to inspect its input. Without the worklist + * propagation fix in PhaseIterGVN::add_users_of_use_to_worklist (JDK-8375688), VectorMaskToLong + * is not re-visited after VectorStoreMask's input becomes a recognized constant, + * leaving the fold opportunity missed. + * + * IR rules cover three hardware paths: + * - AVX-512/SVE/RVV: masks fold through MaskAll (correctness check only, VectorStoreMask + * is not involved on these platforms) + * - AVX2 without AVX-512: masks go through VectorStoreMask, directly exercising the worklist fix + * - ASIMD without SVE: same VectorStoreMask path, on AArch64 + * + * {@code @Check} methods verify correctness on all platforms, including those where no IR rule applies. + * Float/Double species are excluded because VectorMaskToLong fails to fold their masks + * due to an intervening VectorMaskCast (JDK-8377588). + */ +public class TestVectorMaskToLongStress { + static final VectorSpecies B_SPECIES = ByteVector.SPECIES_MAX; + static final VectorSpecies S_SPECIES = ShortVector.SPECIES_MAX; + static final VectorSpecies I_SPECIES = IntVector.SPECIES_MAX; + static final VectorSpecies L_SPECIES = LongVector.SPECIES_MAX; + + // --- All-ones mask: fromLong(-1).toLong() should fold to a constant --- + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesByte() { + return VectorMask.fromLong(B_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesShort() { + return VectorMask.fromLong(S_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesInt() { + return VectorMask.fromLong(I_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesLong() { + return VectorMask.fromLong(L_SPECIES, -1L).toLong(); + } + + // --- All-zeros mask: fromLong(0).toLong() should fold to a constant --- + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllZerosByte() { + return VectorMask.fromLong(B_SPECIES, 0L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllZerosInt() { + return VectorMask.fromLong(I_SPECIES, 0L).toLong(); + } + + // --- Verification --- + + @Check(test = "testAllOnesByte") + public static void checkAllOnesByte(long result) { + Asserts.assertEquals(-1L >>> (64 - B_SPECIES.length()), result); + } + + @Check(test = "testAllOnesShort") + public static void checkAllOnesShort(long result) { + Asserts.assertEquals(-1L >>> (64 - S_SPECIES.length()), result); + } + + @Check(test = "testAllOnesInt") + public static void checkAllOnesInt(long result) { + Asserts.assertEquals(-1L >>> (64 - I_SPECIES.length()), result); + } + + @Check(test = "testAllOnesLong") + public static void checkAllOnesLong(long result) { + Asserts.assertEquals(-1L >>> (64 - L_SPECIES.length()), result); + } + + @Check(test = "testAllZerosByte") + public static void checkAllZerosByte(long result) { + Asserts.assertEquals(0L, result); + } + + @Check(test = "testAllZerosInt") + public static void checkAllZerosInt(long result) { + Asserts.assertEquals(0L, result); + } + + public static void main(String[] args) { + TestFramework testFramework = new TestFramework(); + testFramework.addFlags("--add-modules=jdk.incubator.vector", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+StressIncrementalInlining", + "-XX:CompileCommand=compileonly,compiler.vectorapi.TestVectorMaskToLongStress::*", + "-XX:VerifyIterativeGVN=1110") + .start(); + } +} diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastIdentityTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastIdentityTest.java index be9d8e6390c..e4f166f510a 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastIdentityTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastIdentityTest.java @@ -50,7 +50,7 @@ public class VectorMaskCastIdentityTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 2" }, applyIfCPUFeatureOr = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 2" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static int testTwoCastToDifferentType() { // The types before and after the two casts are not the same, so the cast cannot be eliminated. VectorMask mFloat64 = VectorMask.fromArray(FloatVector.SPECIES_64, mr, 0); @@ -84,7 +84,7 @@ public class VectorMaskCastIdentityTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static int testTwoCastToSameType() { // The types before and after the two casts are the same, so the cast will be eliminated. VectorMask mInt128 = VectorMask.fromArray(IntVector.SPECIES_128, mr, 0); @@ -101,7 +101,7 @@ public class VectorMaskCastIdentityTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 1" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "= 1" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static int testOneCastToDifferentType() { // The types before and after the only cast are different, the cast will not be eliminated. VectorMask mFloat128 = VectorMask.fromArray(FloatVector.SPECIES_128, mr, 0).not(); diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastTest.java index 25594d5caf9..1f346cffd2f 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorMaskCastTest.java @@ -74,7 +74,7 @@ public class VectorMaskCastTest { // Byte @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testByte64ToShort128(VectorMask v) { return v.cast(ShortVector.SPECIES_128); } @@ -201,7 +201,7 @@ public class VectorMaskCastTest { // Short @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testShort64ToInt128(VectorMask v) { return v.cast(IntVector.SPECIES_128); } @@ -215,7 +215,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testShort64ToFloat128(VectorMask v) { return v.cast(FloatVector.SPECIES_128); } @@ -257,7 +257,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testShort128ToByte64(VectorMask v) { return v.cast(ByteVector.SPECIES_64); } @@ -384,7 +384,7 @@ public class VectorMaskCastTest { // Int @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testInt64ToLong128(VectorMask v) { return v.cast(LongVector.SPECIES_128); } @@ -398,7 +398,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testInt64ToDouble128(VectorMask v) { return v.cast(DoubleVector.SPECIES_128); } @@ -412,7 +412,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testInt128ToShort64(VectorMask v) { return v.cast(ShortVector.SPECIES_64); } @@ -539,7 +539,7 @@ public class VectorMaskCastTest { // Float @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testFloat64ToLong128(VectorMask v) { return v.cast(LongVector.SPECIES_128); } @@ -553,7 +553,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testFloat64ToDouble128(VectorMask v) { return v.cast(DoubleVector.SPECIES_128); } @@ -567,7 +567,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public static VectorMask testFloat128ToShort64(VectorMask v) { return v.cast(ShortVector.SPECIES_64); } @@ -694,7 +694,7 @@ public class VectorMaskCastTest { // Long @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testLong128ToInt64(VectorMask v) { return v.cast(IntVector.SPECIES_64); } @@ -708,7 +708,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testLong128ToFloat64(VectorMask v) { return v.cast(FloatVector.SPECIES_64); } @@ -821,7 +821,7 @@ public class VectorMaskCastTest { // Double @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testDouble128ToInt64(VectorMask v) { return v.cast(IntVector.SPECIES_64); } @@ -835,7 +835,7 @@ public class VectorMaskCastTest { } @Test - @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeature = {"asimd", "true"}) + @IR(counts = { IRNode.VECTOR_MASK_CAST, "> 0" }, applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) public static VectorMask testDouble128ToFloat64(VectorMask v) { return v.cast(FloatVector.SPECIES_64); } diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java index 1c8cc34170e..4c753d91afd 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,7 +141,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMin() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0).reduceLanes(VectorOperators.UMIN); verifyByte(B_SPECIES, got, BYTE_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -148,7 +149,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMax() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0).reduceLanes(VectorOperators.UMAX); verifyByte(B_SPECIES, got, BYTE_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -156,7 +157,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMinMasked() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0) .reduceLanes(VectorOperators.UMIN, @@ -166,7 +167,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMaxMasked() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0) .reduceLanes(VectorOperators.UMAX, @@ -178,7 +179,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMin() { short got = ShortVector.fromArray(S_SPECIES, sa, 0).reduceLanes(VectorOperators.UMIN); verifyShort(S_SPECIES, got, SHORT_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -186,7 +187,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMax() { short got = ShortVector.fromArray(S_SPECIES, sa, 0).reduceLanes(VectorOperators.UMAX); verifyShort(S_SPECIES, got, SHORT_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -194,7 +195,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMinMasked() { short got = ShortVector.fromArray(S_SPECIES, sa, 0) .reduceLanes(VectorOperators.UMIN, @@ -204,7 +205,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMaxMasked() { short got = ShortVector.fromArray(S_SPECIES, sa, 0) .reduceLanes(VectorOperators.UMAX, @@ -216,7 +217,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMin() { int got = IntVector.fromArray(I_SPECIES, ia, 0).reduceLanes(VectorOperators.UMIN); verifyInt(I_SPECIES, got, INT_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -224,7 +225,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMax() { int got = IntVector.fromArray(I_SPECIES, ia, 0).reduceLanes(VectorOperators.UMAX); verifyInt(I_SPECIES, got, INT_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -232,7 +233,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMinMasked() { int got = IntVector.fromArray(I_SPECIES, ia, 0) .reduceLanes(VectorOperators.UMIN, @@ -242,7 +243,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMaxMasked() { int got = IntVector.fromArray(I_SPECIES, ia, 0) .reduceLanes(VectorOperators.UMAX, @@ -254,7 +255,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMin() { long got = LongVector.fromArray(L_SPECIES, la, 0).reduceLanes(VectorOperators.UMIN); verifyLong(L_SPECIES, got, LONG_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -262,7 +263,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMax() { long got = LongVector.fromArray(L_SPECIES, la, 0).reduceLanes(VectorOperators.UMAX); verifyLong(L_SPECIES, got, LONG_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -270,7 +271,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMinMasked() { long got = LongVector.fromArray(L_SPECIES, la, 0) .reduceLanes(VectorOperators.UMIN, @@ -280,7 +281,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMaxMasked() { long got = LongVector.fromArray(L_SPECIES, la, 0) .reduceLanes(VectorOperators.UMAX, diff --git a/test/hotspot/jtreg/compiler/vectorization/TestRotateByteAndShortVector.java b/test/hotspot/jtreg/compiler/vectorization/TestRotateByteAndShortVector.java index e130fc0ba6c..79cde2f0d26 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestRotateByteAndShortVector.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestRotateByteAndShortVector.java @@ -1,6 +1,7 @@ /* * Copyright (c) 2022, 2025 Loongson Technology Co. Ltd. All rights reserved. * Copyright (c) 2025, Rivos Inc. All rights reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +25,7 @@ /** * @test - * @bug 8286847 8353600 + * @bug 8286847 8353600 8342095 * @key randomness * @summary Test vectorization of rotate byte and short * @library /test/lib / @@ -116,11 +117,10 @@ public class TestRotateByteAndShortVector { } } - // NOTE: currently, there is no platform supporting RotateLeftV/RotateRightV intrinsic. - // If there is some implementation, it could probably in a wrong way which is different - // from what java language spec expects. @Test - @IR(failOn = { IRNode.ROTATE_LEFT_V }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.ROTATE_LEFT_V, "> 0" }, + applyIfCPUFeature = {"avx512f", "true"}) @IR(failOn = { IRNode.ROTATE_RIGHT_V }) static void testRotateLeftByte(byte[] test, byte[] arr, int shift) { for (int i = 0; i < ARRLEN; i++) { @@ -130,7 +130,9 @@ public class TestRotateByteAndShortVector { @Test @IR(failOn = { IRNode.ROTATE_LEFT_V }) - @IR(failOn = { IRNode.ROTATE_RIGHT_V }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.ROTATE_RIGHT_V, "> 0" }, + applyIfCPUFeature = {"avx512f", "true"}) static void testRotateRightByte(byte[] test, byte[] arr, int shift) { for (int i = 0; i < ARRLEN; i++) { test[i] = (byte) ((arr[i] >>> shift) | (arr[i] << -shift)); @@ -138,7 +140,9 @@ public class TestRotateByteAndShortVector { } @Test - @IR(failOn = { IRNode.ROTATE_LEFT_V }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.ROTATE_LEFT_V, "> 0" }, + applyIfCPUFeature = {"avx512f", "true"}) @IR(failOn = { IRNode.ROTATE_RIGHT_V }) static void testRotateLeftShort(short[] test, short[] arr, int shift) { for (int i = 0; i < ARRLEN; i++) { @@ -148,7 +152,9 @@ public class TestRotateByteAndShortVector { @Test @IR(failOn = { IRNode.ROTATE_LEFT_V }) - @IR(failOn = { IRNode.ROTATE_RIGHT_V }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0", + IRNode.ROTATE_RIGHT_V, "> 0" }, + applyIfCPUFeature = {"avx512f", "true"}) static void testRotateRightShort(short[] test, short[] arr, int shift) { for (int i = 0; i < ARRLEN; i++) { test[i] = (short) ((arr[i] >>> shift) | (arr[i] << -shift)); diff --git a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java index 53c1b89a203..2f6296e41d2 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.g * 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,7 +29,7 @@ import compiler.lib.generators.*; /* * @test - * @bug 8350177 8362171 8369881 + * @bug 8350177 8362171 8369881 8342095 * @summary Ensure that truncation of subword vectors produces correct results * @library /test/lib / * @run driver compiler.vectorization.TestSubwordTruncation @@ -73,7 +73,8 @@ public class TestSubwordTruncation { // Shorts @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupShortArray") public Object[] testShortLeadingZeros(short[] in) { short[] res = new short[SIZE]; @@ -98,7 +99,8 @@ public class TestSubwordTruncation { } @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupShortArray") public Object[] testShortTrailingZeros(short[] in) { short[] res = new short[SIZE]; @@ -123,7 +125,8 @@ public class TestSubwordTruncation { } @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupShortArray") public Object[] testShortReverse(short[] in) { short[] res = new short[SIZE]; @@ -148,7 +151,8 @@ public class TestSubwordTruncation { } @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupShortArray") public Object[] testShortBitCount(short[] in) { short[] res = new short[SIZE]; @@ -277,7 +281,8 @@ public class TestSubwordTruncation { // Bytes @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupByteArray") public Object[] testByteLeadingZeros(byte[] in) { byte[] res = new byte[SIZE]; @@ -302,7 +307,8 @@ public class TestSubwordTruncation { } @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupByteArray") public Object[] testByteTrailingZeros(byte[] in) { byte[] res = new byte[SIZE]; @@ -327,7 +333,8 @@ public class TestSubwordTruncation { } @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupByteArray") public Object[] testByteReverse(byte[] in) { byte[] res = new byte[SIZE]; @@ -403,7 +410,8 @@ public class TestSubwordTruncation { @Test - @IR(counts = { IRNode.STORE_VECTOR, "=0" }) + @IR(counts = { IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0" }, + applyIfCPUFeatureOr = { "avx2", "true", "asimd", "true", "zvbb", "true" }) @Arguments(setup = "setupByteArray") public Object[] testByteBitCount(byte[] in) { byte[] res = new byte[SIZE]; diff --git a/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java b/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java index e02563c2fc2..2667ac59471 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java @@ -79,6 +79,12 @@ public class TestVectorAlgorithms { VectorAlgorithmsImpl.Data d; + // We should test with a wide range of probabilities, to ensure correctness, + // and also to ensure we get all branches compiled, so IR matching compiles + // also for branches that require a very extreme probability. + private static final float[] BRANCH_PROBABILITIES = new float[] {0f, 0.1f, 0.3f, 0.5f, 0.7f, 0.9f, 1f}; + private static int branch_probabilities_idx = 0; + public static void main(String[] args) { TestFramework framework = new TestFramework(); framework.addFlags("--add-modules=jdk.incubator.vector", @@ -133,16 +139,19 @@ public class TestVectorAlgorithms { testGroups.get("findMinIndexI").put("findMinIndexI_VectorAPI", i -> { return findMinIndexI_VectorAPI(d.aI); }); testGroups.put("findI", new HashMap()); - testGroups.get("findI").put("findI_loop", i -> { return findI_loop(d.aI, d.eI[i]); }); - testGroups.get("findI").put("findI_VectorAPI", i -> { return findI_VectorAPI(d.aI, d.eI[i]); }); + testGroups.get("findI").put("findI_loop", i -> { return findI_loop(d.aI, d.eI_findI[i]); }); + testGroups.get("findI").put("findI_VectorAPI", i -> { return findI_VectorAPI(d.aI, d.eI_findI[i]); }); testGroups.put("reverseI", new HashMap()); testGroups.get("reverseI").put("reverseI_loop", i -> { return reverseI_loop(d.aI, d.rI1); }); testGroups.get("reverseI").put("reverseI_VectorAPI", i -> { return reverseI_VectorAPI(d.aI, d.rI2); }); testGroups.put("filterI", new HashMap()); - testGroups.get("filterI").put("filterI_loop", i -> { return filterI_loop(d.aI, d.rI1, d.eI[i]); }); - testGroups.get("filterI").put("filterI_VectorAPI", i -> { return filterI_VectorAPI(d.aI, d.rI2, d.eI[i]); }); + testGroups.get("filterI").put("filterI_loop", i -> { return filterI_loop(d.aI_filterI, d.rI1, d.eI_filterI); }); + testGroups.get("filterI").put("filterI_VectorAPI_v1", i -> { return filterI_VectorAPI_v1(d.aI_filterI, d.rI2, d.eI_filterI); }); + testGroups.get("filterI").put("filterI_VectorAPI_v2_l2", i -> { return filterI_VectorAPI_v2_l2(d.aI_filterI, d.rI3, d.eI_filterI); }); + testGroups.get("filterI").put("filterI_VectorAPI_v2_l4", i -> { return filterI_VectorAPI_v2_l4(d.aI_filterI, d.rI4, d.eI_filterI); }); + testGroups.get("filterI").put("filterI_VectorAPI_v2_l8", i -> { return filterI_VectorAPI_v2_l8(d.aI_filterI, d.rI5, d.eI_filterI); }); testGroups.put("reduceAddIFieldsX4", new HashMap()); testGroups.get("reduceAddIFieldsX4").put("reduceAddIFieldsX4_loop", i -> { return reduceAddIFieldsX4_loop(d.oopsX4, d.memX4); }); @@ -152,6 +161,17 @@ public class TestVectorAlgorithms { testGroups.get("lowerCaseB").put("lowerCaseB_loop", i -> { return lowerCaseB_loop(d.strB, d.rB1); }); testGroups.get("lowerCaseB").put("lowerCaseB_VectorAPI_v1", i -> { return lowerCaseB_VectorAPI_v1(d.strB, d.rB2); }); testGroups.get("lowerCaseB").put("lowerCaseB_VectorAPI_v2", i -> { return lowerCaseB_VectorAPI_v2(d.strB, d.rB3); }); + + testGroups.put("conditionalSumB", new HashMap()); + testGroups.get("conditionalSumB").put("conditionalSumB_loop", i -> { return conditionalSumB_loop(d.strB); }); + testGroups.get("conditionalSumB").put("conditionalSumB_VectorAPI_v1", i -> { return conditionalSumB_VectorAPI_v1(d.strB); }); + testGroups.get("conditionalSumB").put("conditionalSumB_VectorAPI_v2", i -> { return conditionalSumB_VectorAPI_v2(d.strB); }); + + + testGroups.put("pieceWise2FunctionF", new HashMap()); + testGroups.get("pieceWise2FunctionF").put("pieceWise2FunctionF_loop", _ -> { return pieceWise2FunctionF_loop(d.xF, d.rF1); }); + testGroups.get("pieceWise2FunctionF").put("pieceWise2FunctionF_VectorAPI_v1", _ -> { return pieceWise2FunctionF_VectorAPI_v1(d.xF, d.rF2); }); + testGroups.get("pieceWise2FunctionF").put("pieceWise2FunctionF_VectorAPI_v2", _ -> { return pieceWise2FunctionF_VectorAPI_v2(d.xF, d.rF3); }); } @Warmup(100) @@ -186,12 +206,21 @@ public class TestVectorAlgorithms { "reverseI_loop", "reverseI_VectorAPI", "filterI_loop", - "filterI_VectorAPI", + "filterI_VectorAPI_v1", + "filterI_VectorAPI_v2_l2", + "filterI_VectorAPI_v2_l4", + "filterI_VectorAPI_v2_l8", "reduceAddIFieldsX4_loop", "reduceAddIFieldsX4_VectorAPI", "lowerCaseB_loop", "lowerCaseB_VectorAPI_v1", - "lowerCaseB_VectorAPI_v2"}) + "lowerCaseB_VectorAPI_v2", + "conditionalSumB_loop", + "conditionalSumB_VectorAPI_v1", + "conditionalSumB_VectorAPI_v2", + "pieceWise2FunctionF_loop", + "pieceWise2FunctionF_VectorAPI_v1", + "pieceWise2FunctionF_VectorAPI_v2"}) public void runTests(RunInfo info) { // Repeat many times, so that we also have multiple iterations for post-warmup to potentially recompile int iters = info.isWarmUp() ? 1 : 20; @@ -200,7 +229,9 @@ public class TestVectorAlgorithms { int size = 100_000 + RANDOM.nextInt(10_000); int seed = RANDOM.nextInt(); int numXObjects = 10_000; - d = new VectorAlgorithmsImpl.Data(size, seed, numXObjects); + branch_probabilities_idx = (branch_probabilities_idx + 1) % BRANCH_PROBABILITIES.length; + float branchProbability = BRANCH_PROBABILITIES[branch_probabilities_idx]; + d = new VectorAlgorithmsImpl.Data(size, seed, numXObjects, branchProbability); // Run all tests for (Map.Entry> group_entry : testGroups.entrySet()) { @@ -231,11 +262,11 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.REPLICATE_I, "= 1", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIfAnd = {"UseSuperWord", "true", "OptimizeFill", "false"}) @IR(counts = {".*CallLeafNoFP.*jint_fill.*", "= 1"}, phase = CompilePhase.BEFORE_MATCHING, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"OptimizeFill", "true"}) // By default, the fill intrinsic "jint_fill" is used, but we can disable // the detection of the fill loop, and then we auto vectorize. @@ -246,7 +277,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.REPLICATE_I, "= 1", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object fillI_VectorAPI(int[] r) { return VectorAlgorithmsImpl.fillI_VectorAPI(r); } @@ -261,7 +292,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.POPULATE_INDEX, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"avx2", "true", "sve", "true"}, + applyIfCPUFeatureOr = {"avx2", "true", "sve", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) // Note: the Vector API example below can also vectorize for AVX, // because it does not use a PopulateIndex. @@ -272,8 +303,10 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.ADD_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}) - // Note: also works with NEON/asimd, but only with TieredCompilation. + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, + applyIf = {"TieredCompilation", "true"}) + // IR check only works with TieredCompilation. Needs to make it + // work with -XX:-TieredCompilation in future (see JDK-8378640). public Object iotaI_VectorAPI(int[] r) { return VectorAlgorithmsImpl.iotaI_VectorAPI(r); } @@ -281,7 +314,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) public Object copyI_loop(int[] a, int[] r) { return VectorAlgorithmsImpl.copyI_loop(a, r); @@ -290,7 +323,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object copyI_VectorAPI(int[] a, int[] r) { return VectorAlgorithmsImpl.copyI_VectorAPI(a, r); } @@ -298,7 +331,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {".*CallLeafNoFP.*jint_disjoint_arraycopy.*", "= 1"}, phase = CompilePhase.BEFORE_MATCHING, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object copyI_System_arraycopy(int[] a, int[] r) { return VectorAlgorithmsImpl.copyI_System_arraycopy(a, r); } @@ -307,7 +340,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MUL_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) public Object mapI_loop(int[] a, int[] r) { return VectorAlgorithmsImpl.mapI_loop(a, r); @@ -317,7 +350,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.MUL_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object mapI_VectorAPI(int[] a, int[] r) { return VectorAlgorithmsImpl.mapI_VectorAPI(a, r); } @@ -326,7 +359,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) public int reduceAddI_loop(int[] a) { return VectorAlgorithmsImpl.reduceAddI_loop(a); @@ -340,7 +373,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, // reduceLanes inside loop - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public int reduceAddI_VectorAPI_naive(int[] a) { return VectorAlgorithmsImpl.reduceAddI_VectorAPI_naive(a); } @@ -360,7 +393,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_REDUCTION_V, "> 0", IRNode.MUL_VF, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) public float dotProductF_VectorAPI_naive(float[] a, float[] b) { return VectorAlgorithmsImpl.dotProductF_VectorAPI_naive(a, b); @@ -370,7 +403,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_REDUCTION_V, "> 0", IRNode.MUL_VF, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"UseSuperWord", "true"}) public float dotProductF_VectorAPI_reduction_after_loop(float[] a, float[] b) { return VectorAlgorithmsImpl.dotProductF_VectorAPI_reduction_after_loop(a, b); @@ -392,7 +425,8 @@ public class TestVectorAlgorithms { IRNode.MUL_VI, IRNode.VECTOR_SIZE_8, "> 0", IRNode.ADD_VI, IRNode.VECTOR_SIZE_8, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) + applyIfCPUFeatureOr = {"avx2", "true", "sve", "true", "rvv", "true"}, + applyIf = {"MaxVectorSize", ">=32"}) public int hashCodeB_VectorAPI_v1(byte[] a) { return VectorAlgorithmsImpl.hashCodeB_VectorAPI_v1(a); } @@ -402,7 +436,7 @@ public class TestVectorAlgorithms { IRNode.MUL_VI, "> 0", IRNode.ADD_VI, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) public int hashCodeB_VectorAPI_v2(byte[] a) { return VectorAlgorithmsImpl.hashCodeB_VectorAPI_v2(a); } @@ -411,7 +445,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_REDUCTION_VI, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public int reduceAddI_VectorAPI_reduction_after_loop(int[] a) { return VectorAlgorithmsImpl.reduceAddI_VectorAPI_reduction_after_loop(a); } @@ -435,7 +469,7 @@ public class TestVectorAlgorithms { IRNode.AND_VI, "> 0", IRNode.ADD_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}, applyIf = {"MaxVectorSize", ">=64"}) public Object scanAddI_VectorAPI_permute_add(int[] a, int[] r) { return VectorAlgorithmsImpl.scanAddI_VectorAPI_permute_add(a, r); @@ -454,7 +488,7 @@ public class TestVectorAlgorithms { IRNode.VECTOR_BLEND_I, "> 0", IRNode.MIN_REDUCTION_V, "> 0", IRNode.ADD_VI, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}) public int findMinIndexI_VectorAPI(int[] a) { return VectorAlgorithmsImpl.findMinIndexI_VectorAPI(a); } @@ -470,7 +504,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.VECTOR_MASK_CMP, "> 0", IRNode.VECTOR_TEST, "> 0"}, - applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}) public int findI_VectorAPI(int[] a, int e) { return VectorAlgorithmsImpl.findI_VectorAPI(a, e); } @@ -488,7 +522,7 @@ public class TestVectorAlgorithms { IRNode.REARRANGE_VI, "> 0", IRNode.AND_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object reverseI_VectorAPI(int[] a, int[] r) { return VectorAlgorithmsImpl.reverseI_VectorAPI(a, r); } @@ -506,9 +540,46 @@ public class TestVectorAlgorithms { IRNode.VECTOR_TEST, "> 0", IRNode.COMPRESS_VI, "> 0", IRNode.STORE_VECTOR_MASKED, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) - public Object filterI_VectorAPI(int[] a, int[] r, int threshold) { - return VectorAlgorithmsImpl.filterI_VectorAPI(a, r, threshold); + applyIfCPUFeatureOr = {"avx2", "true", "sve", "true", "rvv", "true"}) + public Object filterI_VectorAPI_v1(int[] a, int[] r, int threshold) { + return VectorAlgorithmsImpl.filterI_VectorAPI_v1(a, r, threshold); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE_2, "> 0", + IRNode.VECTOR_MASK_CMP, "= 0", // not implemented + IRNode.VECTOR_TEST, "= 0", // not implemented + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeature = {"sse4.1", "true"}) + // x86 seems to have a limitation with 2-element VectorStoreMask, this blocks intrinsification + @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE_2, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_TEST, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureOr = {"asimd", "true", "rvv", "true"}) + public Object filterI_VectorAPI_v2_l2(int[] a, int[] r, int threshold) { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l2(a, r, threshold); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE_4, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_TEST, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureOr = {"avx", "true", "asimd", "true", "rvv", "true"}) + public Object filterI_VectorAPI_v2_l4(int[] a, int[] r, int threshold) { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l4(a, r, threshold); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE_8, "> 0", + IRNode.VECTOR_MASK_CMP, "> 0", + IRNode.VECTOR_TEST, "> 0", + IRNode.STORE_VECTOR, "> 0"}, + applyIfCPUFeatureOr = {"avx2", "true"}) + // Note: need 8int = 256bit vector. NEON only has 128bit. + public Object filterI_VectorAPI_v2_l8(int[] a, int[] r, int threshold) { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l8(a, r, threshold); } @Test @@ -526,7 +597,10 @@ public class TestVectorAlgorithms { IRNode.OR_V_MASK, "> 0", IRNode.ADD_VI, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeatureOr = {"avx512", "true", "sve", "true"}) + applyIfCPUFeatureOr = {"avx512", "true", "sve", "true", "rvv", "true"}, + applyIf = {"TieredCompilation", "true"}) + // IR check only works with TieredCompilation. Needs to make it + // work with -XX:-TieredCompilation in future (see JDK-8378640). public int reduceAddIFieldsX4_VectorAPI(int[] oops, int[] mem) { return VectorAlgorithmsImpl.reduceAddIFieldsX4_VectorAPI(oops, mem); } @@ -541,7 +615,7 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.LOAD_VECTOR_B, "> 0", IRNode.ADD_VB, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object lowerCaseB_VectorAPI_v1(byte[] a, byte[] r) { return VectorAlgorithmsImpl.lowerCaseB_VectorAPI_v1(a, r); } @@ -549,8 +623,57 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.LOAD_VECTOR_B, "> 0", IRNode.ADD_VB, "> 0"}, - applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}) + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) public Object lowerCaseB_VectorAPI_v2(byte[] a, byte[] r) { return VectorAlgorithmsImpl.lowerCaseB_VectorAPI_v2(a, r); } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_B, "= 0"}) + // Currently does not vectorize, but might in the future. + public Object conditionalSumB_loop(byte[] a) { + return VectorAlgorithmsImpl.conditionalSumB_loop(a); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0", + IRNode.ADD_VI, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", "> 0"}, + applyIfCPUFeature = {"avx2", "true"}) + // Note: we need at least a 256bit int vector. NEON only has 128bit. + public Object conditionalSumB_VectorAPI_v1(byte[] a) { + return VectorAlgorithmsImpl.conditionalSumB_VectorAPI_v1(a); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_B, "> 0", + IRNode.ADD_VI, "> 0"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true", "rvv", "true"}) + public Object conditionalSumB_VectorAPI_v2(byte[] a) { + return VectorAlgorithmsImpl.conditionalSumB_VectorAPI_v2(a); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_F, "= 0"}) + // Currently does not vectorize, but might in the future. + public Object pieceWise2FunctionF_loop(float[] a, float[] r) { + return VectorAlgorithmsImpl.pieceWise2FunctionF_loop(a, r); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.SQRT_VF, "> 0"}, + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) + public Object pieceWise2FunctionF_VectorAPI_v1(float[] a, float[] r) { + return VectorAlgorithmsImpl.pieceWise2FunctionF_VectorAPI_v1(a, r); + } + + @Test + @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", + IRNode.MUL_VF, "> 0", + IRNode.SQRT_VF, "> 0"}, + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true", "rvv", "true"}) + public Object pieceWise2FunctionF_VectorAPI_v2(float[] a, float[] r) { + return VectorAlgorithmsImpl.pieceWise2FunctionF_VectorAPI_v2(a, r); + } } diff --git a/test/hotspot/jtreg/compiler/vectorization/VectorAlgorithmsImpl.java b/test/hotspot/jtreg/compiler/vectorization/VectorAlgorithmsImpl.java index 2dfac704069..8276d90509f 100644 --- a/test/hotspot/jtreg/compiler/vectorization/VectorAlgorithmsImpl.java +++ b/test/hotspot/jtreg/compiler/vectorization/VectorAlgorithmsImpl.java @@ -36,6 +36,8 @@ public class VectorAlgorithmsImpl { private static final VectorSpecies SPECIES_I = IntVector.SPECIES_PREFERRED; private static final VectorSpecies SPECIES_I512 = IntVector.SPECIES_512; private static final VectorSpecies SPECIES_I256 = IntVector.SPECIES_256; + private static final VectorSpecies SPECIES_I128 = IntVector.SPECIES_128; + private static final VectorSpecies SPECIES_I64 = IntVector.SPECIES_64; private static final VectorSpecies SPECIES_B = ByteVector.SPECIES_PREFERRED; private static final VectorSpecies SPECIES_B64 = ByteVector.SPECIES_64; private static final VectorSpecies SPECIES_F = FloatVector.SPECIES_PREFERRED; @@ -58,15 +60,31 @@ public class VectorAlgorithmsImpl { public int[] rI2; public int[] rI3; public int[] rI4; - public int[] eI; + public int[] rI5; + + // Search element for "findI" + public int[] eI_findI; // The test has to use the same index into eI for all implementations. But in the // benchmark, we'd like to use random indices, so we use the index to advance through // the array. - public int eI_idx = 0; + public int eI_findI_idx = 0; + + // Data and threshold eI value for "filterI". + // We create the data in a range, and then pick a threshold scaled to that range, + // so that the branch in the filter is branchProbability. + public int[] aI_filterI; + public int eI_filterI; public float[] aF; public float[] bF; + // Input for piece-wise functions. + // Uniform [0..1[ with probability p and Uniform [1..2[ with probability (1-p) + public float[] xF; + public float[] rF1; + public float[] rF2; + public float[] rF3; + public byte[] aB; public byte[] strB; public byte[] rB1; @@ -76,7 +94,7 @@ public class VectorAlgorithmsImpl { public int[] oopsX4; public int[] memX4; - public Data(int size, int seed, int numX4Objects) { + public Data(int size, int seed, int numX4Objects, float branchProbability) { Random random = new Random(seed); // int: one input array and multiple output arrays so different implementations can @@ -86,14 +104,20 @@ public class VectorAlgorithmsImpl { rI2 = new int[size]; rI3 = new int[size]; rI4 = new int[size]; + rI5 = new int[size]; Arrays.setAll(aI, i -> random.nextInt()); // Populate with some random values from aI, and some totally random values. - eI = new int[0x10000]; - for (int i = 0; i < eI.length; i++) { - eI[i] = (random.nextInt(10) == 0) ? random.nextInt() : aI[random.nextInt(size)]; + eI_findI = new int[0x10000]; + for (int i = 0; i < eI_findI.length; i++) { + eI_findI[i] = (random.nextInt(10) == 0) ? random.nextInt() : aI[random.nextInt(size)]; } + int filterI_range = 1000_000; + aI_filterI = new int[size]; + Arrays.setAll(aI_filterI, i -> random.nextInt(filterI_range)); + eI_filterI = (int)(filterI_range * (1.0f - branchProbability)); + // X4 oop setup. // oopsX4 holds "addresses" (i.e. indices), that point to the 16-byte objects in memX4. oopsX4 = new int[size]; @@ -117,14 +141,30 @@ public class VectorAlgorithmsImpl { bF[i] = random.nextInt(32) - 16; } + xF = new float[size]; + rF1 = new float[size]; + rF2 = new float[size]; + rF3 = new float[size]; + for (int i = 0; i < size; i++) { + xF[i] = (random.nextFloat() < branchProbability) + ? 0f + random.nextFloat() + : 1f + random.nextFloat(); + } + // byte: just random data. aB = new byte[size]; - strB = new byte[size]; rB1 = new byte[size]; rB2 = new byte[size]; rB3 = new byte[size]; random.nextBytes(aB); - random.nextBytes(strB); // TODO: special data! + + // byte string: for lowerCase benchmark. + strB = new byte[size]; + for (int i = 0; i < size; i++) { + strB[i] = (random.nextFloat() < branchProbability) + ? (byte)(random.nextInt(16) + 'A') + : (byte)(random.nextInt(16) + 'a'); + } } } @@ -651,13 +691,12 @@ public class VectorAlgorithmsImpl { return r; } - public static Object filterI_VectorAPI(int[] a, int[] r, int threshold) { - var thresholds = IntVector.broadcast(SPECIES_I, threshold); + public static Object filterI_VectorAPI_v1(int[] a, int[] r, int threshold) { int j = 0; int i = 0; for (; i < SPECIES_I.loopBound(a.length); i += SPECIES_I.length()) { IntVector v = IntVector.fromArray(SPECIES_I, a, i); - var mask = v.compare(VectorOperators.GE, thresholds); + var mask = v.compare(VectorOperators.GE, threshold); v = v.compress(mask); int trueCount = mask.trueCount(); var prefixMask = mask.compress(); @@ -676,6 +715,98 @@ public class VectorAlgorithmsImpl { return r; } + // Idea: on platforms that do not support the "v1" solution with "compress" and + // masked stores, we struggle to deal with the loop-carried dependency of j. + // But we can still use dynamic uniformity to enable some vectorized performance. + public static Object filterI_VectorAPI_v2_l2(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I64.loopBound(a.length); i += SPECIES_I64.length()) { + IntVector v = IntVector.fromArray(SPECIES_I64, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 2; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + + public static Object filterI_VectorAPI_v2_l4(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I128.loopBound(a.length); i += SPECIES_I128.length()) { + IntVector v = IntVector.fromArray(SPECIES_I128, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 4; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + if (mask.laneIsSet(2)) { r[j++] = v.lane(2); } + if (mask.laneIsSet(3)) { r[j++] = v.lane(3); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + + public static Object filterI_VectorAPI_v2_l8(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I256.loopBound(a.length); i += SPECIES_I256.length()) { + IntVector v = IntVector.fromArray(SPECIES_I256, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 8; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + if (mask.laneIsSet(2)) { r[j++] = v.lane(2); } + if (mask.laneIsSet(3)) { r[j++] = v.lane(3); } + if (mask.laneIsSet(4)) { r[j++] = v.lane(4); } + if (mask.laneIsSet(5)) { r[j++] = v.lane(5); } + if (mask.laneIsSet(6)) { r[j++] = v.lane(6); } + if (mask.laneIsSet(7)) { r[j++] = v.lane(7); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + // X4: ints simulate 4-byte oops. // oops: if non-zero (= non-null), every entry simulates a 4-byte oop, pointing into mem. // mem: an int array that simulates the memory. @@ -771,4 +902,176 @@ public class VectorAlgorithmsImpl { } return r; } + + public static int conditionalSumB_loop(byte[] a) { + int sum = 0; + for (int i = 0; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + + public static int conditionalSumB_VectorAPI_v1(byte[] a) { + return ConditionalSumB_VectorAPI_V1.compute(a); + } + + private static class ConditionalSumB_VectorAPI_V1 { + // Pick I species to be a full vector, and the B vector a quarter its bit length. + // However, we have to get at least 64bits for the B vector, so at least 256bits + // for the int vector - a sad restriction by the currently very narrow range of + // supported shapes. + private static final int BITS_I = Math.max(256, IntVector.SPECIES_PREFERRED.vectorBitSize()); + private static final int BITS_B = BITS_I / 4; + private static final VectorShape SHAPE_I = VectorShape.forBitSize(BITS_I); + private static final VectorShape SHAPE_B = VectorShape.forBitSize(BITS_B); + private static final VectorSpecies SPECIES_I = SHAPE_I.withLanes(int.class); + private static final VectorSpecies SPECIES_B = SHAPE_B.withLanes(byte.class); + + public static int compute(byte[] a) { + var zeroB = ByteVector.zero(SPECIES_B); + var accI = IntVector.zero(SPECIES_I); + int i; + for (i = 0; i < SPECIES_B.loopBound(a.length); i += SPECIES_B.length()) { + var vB = ByteVector.fromArray(SPECIES_B, a, i); + var maskA = vB.compare(VectorOperators.GE, (byte)'A'); + var maskZ = vB.compare(VectorOperators.LE, (byte)'Z'); + var mask = maskA.and(maskZ); + vB = zeroB.blend(vB, mask); + var vI = vB.castShape(SPECIES_I, 0); + accI = accI.add(vI); + } + int sum = accI.reduceLanes(VectorOperators.ADD); + for (; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + } + + public static int conditionalSumB_VectorAPI_v2(byte[] a) { + return ConditionalSumB_VectorAPI_V2.compute(a); + } + + private static class ConditionalSumB_VectorAPI_V2 { + // Pick B species to be a full vector, and use 4 I vectors of the same bit size. + private static final VectorSpecies SPECIES_B = ByteVector.SPECIES_PREFERRED; + private static final VectorSpecies SPECIES_I = SPECIES_B.vectorShape().withLanes(int.class); + + public static int compute(byte[] a) { + var zeroB = ByteVector.zero(SPECIES_B); + var accI = IntVector.zero(SPECIES_I); + int i; + for (i = 0; i < SPECIES_B.loopBound(a.length); i += SPECIES_B.length()) { + var vB = ByteVector.fromArray(SPECIES_B, a, i); + var maskA = vB.compare(VectorOperators.GE, (byte)'A'); + var maskZ = vB.compare(VectorOperators.LE, (byte)'Z'); + var mask = maskA.and(maskZ); + vB = zeroB.blend(vB, mask); + // When casting byte->int, we get 4x the bits, and split them into 4 parts. + var vI0 = vB.castShape(SPECIES_I, 0); + var vI1 = vB.castShape(SPECIES_I, 1); + var vI2 = vB.castShape(SPECIES_I, 2); + var vI3 = vB.castShape(SPECIES_I, 3); + accI = accI.add(vI0.add(vI1).add(vI2).add(vI3)); + } + int sum = accI.reduceLanes(VectorOperators.ADD); + for (; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + } + + public static float[] pieceWise2FunctionF_loop(float[] a, float[] r) { + for (int i = 0; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } + + public static float[] pieceWise2FunctionF_VectorAPI_v1(float[] a, float[] r) { + int i; + for (i = 0; i < SPECIES_F.loopBound(a.length); i += SPECIES_F.length()) { + var ai = FloatVector.fromArray(SPECIES_F, a, i); + var mask = ai.compare(VectorOperators.LT, 1f); + var a2 = ai.lanewise(VectorOperators.MUL, ai); + var a4 = a2.lanewise(VectorOperators.MUL, a2); + var a8 = a4.lanewise(VectorOperators.MUL, a4); + var s2 = ai.lanewise(VectorOperators.SQRT); + var s4 = s2.lanewise(VectorOperators.SQRT); + var s8 = s4.lanewise(VectorOperators.SQRT); + var v = s8.blend(a8, mask); + v.intoArray(r, i); + } + for (; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } + + public static float[] pieceWise2FunctionF_VectorAPI_v2(float[] a, float[] r) { + int i; + for (i = 0; i < SPECIES_F.loopBound(a.length); i += SPECIES_F.length()) { + var ai = FloatVector.fromArray(SPECIES_F, a, i); + var mask = ai.compare(VectorOperators.LT, 1f); + var a2 = ai.lanewise(VectorOperators.MUL, ai); + var a4 = a2.lanewise(VectorOperators.MUL, a2); + var a8 = a4.lanewise(VectorOperators.MUL, a4); + var v = a8; + // SQRT is expensive, so only call if it necessary + if (!mask.allTrue()) { + var s2 = ai.lanewise(VectorOperators.SQRT); + var s4 = s2.lanewise(VectorOperators.SQRT); + var s8 = s4.lanewise(VectorOperators.SQRT); + v = s8.blend(a8, mask); + } + v.intoArray(r, i); + } + for (; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } } diff --git a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java index 1f0c8e668b7..a0434411da7 100644 --- a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java +++ b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java @@ -247,9 +247,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner { } @Test - // Note that right shift operations on subword expressions cannot be - // vectorized since precise type info about signedness is missing. - @IR(failOn = {IRNode.STORE_VECTOR}) + @IR(applyIfCPUFeature = {"avx", "true"}, + counts = {IRNode.RSHIFT_VI, ">0"}) public short[] subwordExpressionRightShift() { short[] res = new short[SIZE]; for (int i = 0; i < SIZE; i++) { diff --git a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java index d3119a00c37..f9c5f6199f1 100644 --- a/test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java +++ b/test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, 2023, Arm Limited. All rights reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test + * @bug 8183390 8340010 8342095 * @summary Vectorization test on array type conversions * @library /test/lib / * @@ -108,10 +109,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { // ---------------- Integer Extension ---------------- @Test - @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. - // Assert the vectorization failure so that we are reminded to update - // the test when this limitation is addressed in the future. + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_S2I, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public int[] signExtension() { int[] res = new int[SIZE]; for (int i = 0; i < SIZE; i++) { @@ -122,7 +122,7 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { @Test @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. + // Subword vector casts with char do not work currently, see JDK-8349562. // Assert the vectorization failure so that we are reminded to update // the test when this limitation is addressed in the future. public int[] zeroExtension() { @@ -134,10 +134,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { } @Test - @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. - // Assert the vectorization failure so that we are reminded to update - // the test when this limitation is addressed in the future. + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2I, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", ">0" }) public int[] signExtensionFromByte() { int[] res = new int[SIZE]; for (int i = 0; i < SIZE; i++) { @@ -146,12 +145,23 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { return res; } + @Test + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_B2S, IRNode.VECTOR_SIZE + "min(max_short, max_byte)", ">0" }) + public short[] signExtensionFromByteToShort() { + short[] res = new short[SIZE]; + for (int i = 0; i < SIZE; i++) { + res[i] = bytes[i]; + } + return res; + } + // ---------------- Integer Narrow ---------------- @Test - @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. - // Assert the vectorization failure so that we are reminded to update - // the test when this limitation is addressed in the future. + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public short[] narrowToSigned() { short[] res = new short[SIZE]; for (int i = 0; i < SIZE; i++) { @@ -161,10 +171,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { } @Test - @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. - // Assert the vectorization failure so that we are reminded to update - // the test when this limitation is addressed in the future. + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_char)", ">0" }) public char[] narrowToUnsigned() { char[] res = new char[SIZE]; for (int i = 0; i < SIZE; i++) { @@ -174,11 +183,10 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { } @Test - @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. - // Assert the vectorization failure so that we are reminded to update - // the test when this limitation is addressed in the future. - public byte[] NarrowToByte() { + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_I2B, IRNode.VECTOR_SIZE + "min(max_int, max_byte)", ">0" }) + public byte[] narrowToByte() { byte[] res = new byte[SIZE]; for (int i = 0; i < SIZE; i++) { res[i] = (byte) ints[i]; @@ -186,6 +194,18 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { return res; } + @Test + @IR(applyIfCPUFeature = { "avx", "true" }, + applyIfOr = {"AlignVector", "false", "UseCompactObjectHeaders", "false"}, + counts = { IRNode.VECTOR_CAST_S2B, IRNode.VECTOR_SIZE + "min(max_short, max_byte)", ">0" }) + public byte[] narrowShortToByte() { + byte[] res = new byte[SIZE]; + for (int i = 0; i < SIZE; i++) { + res[i] = (byte) shorts[i]; + } + return res; + } + // ---------------- Convert I/L to F/D ---------------- @Test @IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true", "rvv", "true"}, @@ -268,7 +288,7 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { @Test @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. + // Subword vector casts with char do not work currently, see JDK-8349562. // Assert the vectorization failure so that we are reminded to update // the test when this limitation is addressed in the future. public float[] convertCharToFloat() { @@ -281,7 +301,7 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner { @Test @IR(failOn = {IRNode.STORE_VECTOR}) - // Subword vector casts do not work currently, see JDK-8342095. + // Subword vector casts with char do not work currently, see JDK-8349562. // Assert the vectorization failure so that we are reminded to update // the test when this limitation is addressed in the future. public double[] convertCharToDouble() { diff --git a/test/hotspot/jtreg/compiler/vectorization/runner/BasicShortOpTest.java b/test/hotspot/jtreg/compiler/vectorization/runner/BasicShortOpTest.java index 63739584558..b957a00278a 100644 --- a/test/hotspot/jtreg/compiler/vectorization/runner/BasicShortOpTest.java +++ b/test/hotspot/jtreg/compiler/vectorization/runner/BasicShortOpTest.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, 2023, Arm Limited. All rights reserved. + * Copyright (c) 2026, 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,6 +24,7 @@ /* * @test + * @bug 8183390 8342095 * @summary Vectorization test on basic short operations * @library /test/lib / * @@ -210,10 +212,10 @@ public class BasicShortOpTest extends VectorizationTestRunner { return res; } + // Min/Max vectorization requires a cast from subword to int and back to subword, to avoid losing the higher order bits. + @Test - // Note that min operations on subword types cannot be vectorized - // because higher bits will be lost. - @IR(failOn = {IRNode.STORE_VECTOR}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public short[] vectorMin() { short[] res = new short[SIZE]; for (int i = 0; i < SIZE; i++) { @@ -223,9 +225,7 @@ public class BasicShortOpTest extends VectorizationTestRunner { } @Test - // Note that max operations on subword types cannot be vectorized - // because higher bits will be lost. - @IR(failOn = {IRNode.STORE_VECTOR}) + @IR(applyIfCPUFeature = { "avx", "true" }, counts = { IRNode.VECTOR_CAST_I2S, IRNode.VECTOR_SIZE + "min(max_int, max_short)", ">0" }) public short[] vectorMax() { short[] res = new short[SIZE]; for (int i = 0; i < SIZE; i++) { diff --git a/test/hotspot/jtreg/compiler/whitebox/DeoptimizeRelocatedNMethod.java b/test/hotspot/jtreg/compiler/whitebox/DeoptimizeRelocatedNMethod.java index c7cf355259b..672e24ad874 100644 --- a/test/hotspot/jtreg/compiler/whitebox/DeoptimizeRelocatedNMethod.java +++ b/test/hotspot/jtreg/compiler/whitebox/DeoptimizeRelocatedNMethod.java @@ -29,7 +29,6 @@ * @modules java.base/jdk.internal.misc java.management * @requires vm.opt.DeoptimizeALot != true * @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) - * @requires !vm.emulatedClient * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch -XX:+SegmentedCodeCache diff --git a/test/hotspot/jtreg/compiler/whitebox/IsMethodCompilableTest.java b/test/hotspot/jtreg/compiler/whitebox/IsMethodCompilableTest.java index 19f577067e7..fff6517fc34 100644 --- a/test/hotspot/jtreg/compiler/whitebox/IsMethodCompilableTest.java +++ b/test/hotspot/jtreg/compiler/whitebox/IsMethodCompilableTest.java @@ -31,7 +31,6 @@ * * @requires vm.opt.DeoptimizeALot != true * @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) - * @requires !vm.emulatedClient * * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox @@ -84,8 +83,8 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest { protected void test() throws Exception { // Only c2 compilations can be disabled through PerMethodRecompilationCutoff - if (!Platform.isServer() || Platform.isEmulatedClient()) { - throw new Error("TESTBUG: Not server mode"); + if (!Platform.isServer()) { + throw new Error("TESTBUG: Not server VM"); } if (skipXcompOSR()) { diff --git a/test/hotspot/jtreg/containers/docker/TestJcmd.java b/test/hotspot/jtreg/containers/docker/TestJcmd.java index fcd5c665f2b..4f6fda20c86 100644 --- a/test/hotspot/jtreg/containers/docker/TestJcmd.java +++ b/test/hotspot/jtreg/containers/docker/TestJcmd.java @@ -170,14 +170,10 @@ public class TestJcmd { opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/:z") .addJavaOpts("-cp", "/test-classes/") .addDockerOpts("--cap-add=SYS_PTRACE") + .addDockerOpts("--pull=never") .addDockerOpts("--name", CONTAINER_NAME) .addClassOptions("" + TIME_TO_RUN_CONTAINER_PROCESS); - if (IS_PODMAN && !ROOT_UID.equals(getId("-u"))) { - // map the current userid to the one in the target namespace - opts.addDockerOpts("--userns=keep-id"); - } - // avoid large Xmx opts.appendTestJavaOptions = false; @@ -186,7 +182,7 @@ public class TestJcmd { return ProcessTools.startProcess("main-container-process", pb, line -> line.contains(EventGeneratorLoop.MAIN_METHOD_STARTED), - 5, TimeUnit.SECONDS); + 15, TimeUnit.SECONDS); } diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java b/test/hotspot/jtreg/gc/arguments/TestMaxRAMPercentage.java similarity index 73% rename from test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java rename to test/hotspot/jtreg/gc/arguments/TestMaxRAMPercentage.java index e7b2f371ed6..0cf34a0d239 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxRAMPercentage.java @@ -24,10 +24,9 @@ package gc.arguments; /* - * @test TestMaxRAMFlags + * @test TestMaxRAMPercentage * @bug 8222252 - * @summary Verify correct MaxHeapSize and UseCompressedOops when MaxRAM and MaxRAMPercentage - * are specified. + * @summary Verify correct MaxHeapSize and UseCompressedOops when MaxRAMPercentage is specified * @library /test/lib * @library / * @requires vm.bits == "64" @@ -35,8 +34,11 @@ package gc.arguments; * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver gc.arguments.TestMaxRAMFlags - * @author bob.vandette@oracle.com + * @run main/othervm + * -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * gc.arguments.TestMaxRAMPercentage */ import java.util.regex.Matcher; @@ -45,14 +47,17 @@ import java.util.regex.Pattern; import java.util.ArrayList; import java.util.Arrays; +import jdk.test.whitebox.WhiteBox; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; -public class TestMaxRAMFlags { +public class TestMaxRAMPercentage { - private static void checkMaxRAMSize(long maxram, int maxrampercent, boolean forcecoop, long expectheap, boolean expectcoop) throws Exception { + private static final WhiteBox wb = WhiteBox.getWhiteBox(); + + private static void checkMaxRAMSize(double maxrampercent, boolean forcecoop, long expectheap, boolean expectcoop) throws Exception { ArrayList args = new ArrayList(); - args.add("-XX:MaxRAM=" + maxram); args.add("-XX:MaxRAMPercentage=" + maxrampercent); if (forcecoop) { args.add("-XX:+UseCompressedOops"); @@ -107,21 +112,32 @@ public class TestMaxRAMFlags { } public static void main(String args[]) throws Exception { - // Tests - // 1. Verify that MaxRAMPercentage overrides UseCompressedOops Ergo - // 2. Verify that UseCompressedOops forces compressed oops limit even - // when other flags are specified. - - long oneG = 1L * 1024L * 1024L * 1024L; - // Hotspot startup logic reduces MaxHeapForCompressedOops by HeapBaseMinAddress // in order to get zero based compressed oops offsets. long heapbaseminaddr = getHeapBaseMinAddress(); long maxcoopheap = TestUseCompressedOopsErgoTools.getMaxHeapForCompressedOops(new String [0]) - heapbaseminaddr; - // Args: MaxRAM , MaxRAMPercentage, forcecoop, expect heap, expect coop - checkMaxRAMSize(maxcoopheap - oneG, 100, false, maxcoopheap - oneG, true); - checkMaxRAMSize(maxcoopheap + oneG, 100, false, maxcoopheap + oneG, false); - checkMaxRAMSize(maxcoopheap + oneG, 100, true, maxcoopheap, true); + // The headroom is used to get/not get compressed oops from the maxcoopheap size + long M = 1L * 1024L * 1024L; + long headroom = 64 * M; + + long requiredHostMemory = maxcoopheap + headroom; + + // Get host memory + long hostMemory = wb.hostPhysicalMemory(); + + System.out.println("hostMemory: " + hostMemory + ", requiredHostMemory: " + requiredHostMemory); + + if (hostMemory < requiredHostMemory) { + throw new SkippedException("Not enough RAM on machine to run. Test skipped!"); + } + + double MaxRAMPercentage = ((double)maxcoopheap / hostMemory) * 100.0; + double headroomPercentage = ((double)headroom / hostMemory) * 100.0; + + // Args: MaxRAMPercentage, forcecoop, expectheap, expectcoop + checkMaxRAMSize(MaxRAMPercentage - headroomPercentage, false, maxcoopheap - (long)headroom, true); + checkMaxRAMSize(MaxRAMPercentage + headroomPercentage, false, maxcoopheap + (long)headroom, false); + checkMaxRAMSize(MaxRAMPercentage, true, maxcoopheap, true); } } diff --git a/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java b/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java deleted file mode 100644 index f885ef7e462..00000000000 --- a/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015, 2025, 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 gc.arguments; - -/* - * @test TestNewSizeThreadIncrease - * @bug 8144527 - * @summary Tests argument processing for NewSizeThreadIncrease - * @library /test/lib - * @library / - * @requires vm.gc.Serial - * @requires test.thread.factory == null - * @modules java.base/jdk.internal.misc - * java.management - * @run driver gc.arguments.TestNewSizeThreadIncrease - */ - - -import jdk.test.lib.Platform; -import jdk.test.lib.process.OutputAnalyzer; - -// Range of NewSizeThreadIncrease is 0 ~ max_uintx. -// Total of 5 threads will be created (1 GCTest thread and 4 TestThread). -public class TestNewSizeThreadIncrease { - static final String VALID_VALUE = "2097152"; // 2MB - - // This value will make an overflow of 'thread count * NewSizeThreadIncrease' at DefNewGeneration::compute_new_size(). - // = (max_uintx / 5) + 1, = (18446744073709551615 / 5) + 1 - static String INVALID_VALUE_1 = "3689348814741910324"; - - // This string is contained when compute_new_size() expands or shrinks. - static final String LOG_NEWSIZE_CHANGED = "New generation size "; - - public static void main(String[] args) throws Exception { - if (Platform.is32bit()) { - // (max_uintx / 5) + 1, 4294967295/5 + 1 - INVALID_VALUE_1 = "858993460"; - } - - // New size will be applied as NewSizeThreadIncrease is small enough to expand. - runNewSizeThreadIncreaseTest(VALID_VALUE, true); - - // New size will be ignored as 'thread count * NewSizeThreadIncrease' overflows. - runNewSizeThreadIncreaseTest(INVALID_VALUE_1, false); - } - - static void runNewSizeThreadIncreaseTest(String expectedValue, boolean isNewsizeChanged) throws Exception { - OutputAnalyzer output = GCArguments.executeLimitedTestJava("-XX:+UseSerialGC", - "-Xms96M", - "-Xmx128M", - "-XX:NewRatio=2", - "-Xlog:gc+heap+ergo=debug", - "-XX:NewSizeThreadIncrease="+expectedValue, - GCTest.class.getName()); - - output.shouldHaveExitValue(0); - - if (isNewsizeChanged) { - output.shouldContain(LOG_NEWSIZE_CHANGED); - } else { - output.shouldNotContain(LOG_NEWSIZE_CHANGED); - } - } - - static class GCTest { - - static final int MAX_THREADS_COUNT = 4; - static TestThread threads[] = new TestThread[MAX_THREADS_COUNT]; - - public static void main(String[] args) { - - System.out.println("Creating garbage"); - - for (int i=0; i result = new ArrayList(); - result.addAll(Arrays.asList(args)); - result.add("-XX:+PrintFlagsFinal"); - result.add("-version"); - OutputAnalyzer output = GCArguments.executeTestJava(result); - - output.shouldHaveExitValue(0); - - final String expectedPattern = expectedTrue ? parallelRefProcEnabledPattern : parallelRefProcDisabledPattern; - - String value = output.firstMatch(expectedPattern); - if (value == null) { - throw new RuntimeException( - Arrays.toString(args) + " didn't set ParallelRefProcEnabled to " + expectedTrue + " as expected"); - } - } -} diff --git a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java b/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java deleted file mode 100644 index a5e144bcd15..00000000000 --- a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015, 2025, 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 gc.arguments; - -/* - * @test TestSelectDefaultGC - * @summary Test selection of GC when no GC option is specified - * @bug 8068582 - * @library /test/lib - * @library / - * @requires vm.gc.Serial & vm.gc.G1 - * @modules java.base/jdk.internal.misc - * java.management - * @run driver gc.arguments.TestSelectDefaultGC - */ - -import jdk.test.lib.process.OutputAnalyzer; - -public class TestSelectDefaultGC { - public static void assertVMOption(OutputAnalyzer output, String option, boolean value) { - output.shouldMatch(" " + option + " .*=.* " + value + " "); - } - - public static void testDefaultGC(boolean actAsServer) throws Exception { - // Start VM without specifying GC - OutputAnalyzer output = GCArguments.executeTestJava( - "-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine", - "-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine", - "-XX:+PrintFlagsFinal", - "-version"); - output.shouldHaveExitValue(0); - - final boolean isServer = actAsServer; - - // Verify GC selection - // G1 is default for server class machines - assertVMOption(output, "UseG1GC", isServer); - // Serial is default for non-server class machines - assertVMOption(output, "UseSerialGC", !isServer); - } - - public static void main(String[] args) throws Exception { - // Test server class machine - testDefaultGC(false); - - // Test non-server class machine - testDefaultGC(true); - } -} diff --git a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java index c9cf7291aaa..10c85c30c33 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java @@ -26,8 +26,7 @@ package gc.arguments; /* * @test TestUseCompressedOopsFlagsWithUlimit * @bug 8280761 - * @summary Verify correct UseCompressedOops when MaxRAM and MaxRAMPercentage - * are specified with ulimit -v. + * @summary Verify that ergonomic setting of UseCompressedOops adheres to ulimit -v * @library /test/lib * @library / * @requires vm.bits == "64" @@ -50,10 +49,9 @@ import jdk.test.lib.process.ProcessTools; public class TestUseCompressedOopsFlagsWithUlimit { - private static void checkFlag(long ulimit, long maxram, int maxrampercent, boolean expectcoop) throws Exception { + private static void checkFlag(long ulimit, int maxrampercent, boolean expectcoop) throws Exception { ArrayList args = new ArrayList(); - args.add("-XX:MaxRAM=" + maxram); args.add("-XX:MaxRAMPercentage=" + maxrampercent); args.add("-XX:+PrintFlagsFinal"); @@ -74,7 +72,7 @@ public class TestUseCompressedOopsFlagsWithUlimit { boolean actualcoop = getFlagBoolValue("UseCompressedOops", stdout); if (actualcoop != expectcoop) { throw new RuntimeException("UseCompressedOops set to " + actualcoop + - ", expected " + expectcoop + " when running with the following flags: " + Arrays.asList(args).toString()); + ", expected " + expectcoop + " when running with the following flags: " + Arrays.asList(args).toString() + ", and ulimit: " + ulimit); } } @@ -91,10 +89,13 @@ public class TestUseCompressedOopsFlagsWithUlimit { // Verify that UseCompressedOops Ergo follows ulimit -v setting. long oneG = 1L * 1024L * 1024L * 1024L; + long ulimit = 10 * oneG; - // Args: ulimit, max_ram, max_ram_percent, expected_coop - // Setting MaxRAMPercentage explicitly to make the test more resilient. - checkFlag(10 * oneG, 32 * oneG, 100, true); - checkFlag(10 * oneG, 128 * oneG, 100, true); + // Regardless of how much memory that is available on the machine, we should + // always get compressed oops if we have set a ulimit below the COOPS limit. + // We set MaxRAMPercentage explicitly to make the test more resilient. + + // Args: ulimit, maxrampercent, expectedcoop + checkFlag(ulimit, 100, true); } } diff --git a/test/hotspot/jtreg/gc/epsilon/TestInitAllocs.java b/test/hotspot/jtreg/gc/epsilon/TestInitAllocs.java index 353daaef8b6..cdfd29bad61 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestInitAllocs.java +++ b/test/hotspot/jtreg/gc/epsilon/TestInitAllocs.java @@ -23,54 +23,84 @@ package gc.epsilon; -/** - * @test TestInitAllocs +import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/* @test id=default * @requires vm.gc.Epsilon - * @summary Test that allocation path taken in early JVM phases works - * - * @run main/othervm -Xmx256m - * -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC - * gc.epsilon.TestInitAllocs - * - * @run main/othervm -Xmx256m - * -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC - * -XX:+UseTLAB - * -XX:+UseCompressedOops - * -XX:EpsilonMinHeapExpand=1024 - * -XX:EpsilonUpdateCountersStep=1 - * -XX:EpsilonPrintHeapSteps=1000000 - * gc.epsilon.TestInitAllocs - * - * @run main/othervm -Xmx256m - * -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC - * -XX:+UseTLAB - * -XX:-UseCompressedOops - * -XX:EpsilonMinHeapExpand=1024 - * -XX:EpsilonUpdateCountersStep=1 - * -XX:EpsilonPrintHeapSteps=1000000 - * gc.epsilon.TestInitAllocs - * - * @run main/othervm -Xmx256m - * -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC - * -XX:-UseTLAB - * -XX:+UseCompressedOops - * -XX:EpsilonMinHeapExpand=1024 - * -XX:EpsilonUpdateCountersStep=1 - * -XX:EpsilonPrintHeapSteps=1000000 - * gc.epsilon.TestInitAllocs - * - * @run main/othervm -Xmx256m - * -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC - * -XX:-UseTLAB - * -XX:-UseCompressedOops - * -XX:EpsilonMinHeapExpand=1024 - * -XX:EpsilonUpdateCountersStep=1 - * -XX:EpsilonPrintHeapSteps=1000000 - * gc.epsilon.TestInitAllocs + * @summary Stress test that allocation path taken in early JVM phases works + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs + */ + +/* @test id=nocoops + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:-UseCompressedOops + */ + +/* @test id=notlabs + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:-UseTLAB + */ + +/* @test id=notlabs-nocoops + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:-UseCompressedOops -XX:-UseTLAB + */ + +/* @test id=coh + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:+UseCompactObjectHeaders + */ + +/* @test id=coh-nocoops + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:+UseCompactObjectHeaders -XX:-UseCompressedOops + */ + +/* @test id=coh-notlabs + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:+UseCompactObjectHeaders -XX:-UseTLAB + */ + +/* @test id=coh-notlabs-nocoops + * @requires vm.gc.Epsilon + * @library /test/lib + * @run driver gc.epsilon.TestInitAllocs -XX:+UseCompactObjectHeaders -XX:-UseCompressedOops -XX:-UseTLAB */ public class TestInitAllocs { - public static void main(String[] args) throws Exception { - System.out.println("Hello World"); + static final Integer TRIES = Integer.getInteger("tries", 500); + + public static void main(String... args) throws Exception { + List testArgs = new ArrayList<>(); + testArgs.add("-Xmx256m"); + testArgs.add("-XX:+UnlockExperimentalVMOptions"); + testArgs.add("-XX:+UseEpsilonGC"); + testArgs.add("-XX:EpsilonMinHeapExpand=1024"); + testArgs.add("-XX:EpsilonUpdateCountersStep=1"); + testArgs.add("-XX:EpsilonPrintHeapSteps=1000000"); + testArgs.addAll(Arrays.asList(args)); + testArgs.add(TestInitAllocs.Main.class.getName()); + for (int t = 0; t < TRIES; t++) { + OutputAnalyzer oa = ProcessTools.executeLimitedTestJava(testArgs); + oa.shouldHaveExitValue(0); + } + } + + static class Main { + public static void main(String... args) { + // Do nothing + } } } diff --git a/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java b/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java index cf3445bd656..b0cf8f582b2 100644 --- a/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java +++ b/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java @@ -70,14 +70,6 @@ public class TestDynamicNumberOfGCThreads { // Base test with gc and +UseDynamicNumberOfGCThreads: OutputAnalyzer output = ProcessTools.executeLimitedTestJava(baseArgs); verifyDynamicNumberOfGCThreads(output); - - // Turn on parallel reference processing - String[] parRefProcArg = {"-XX:+ParallelRefProcEnabled", "-XX:-ShowMessageBoxOnError"}; - String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length]; - System.arraycopy(parRefProcArg, 0, parRefArgs, 0, parRefProcArg.length); - System.arraycopy(baseArgs, 0, parRefArgs, parRefProcArg.length, baseArgs.length); - output = ProcessTools.executeLimitedTestJava(parRefArgs); - verifyDynamicNumberOfGCThreads(output); } static class GCTest { diff --git a/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java b/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java index 69a3e7b8742..52aa1bc26e5 100644 --- a/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java +++ b/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java @@ -55,7 +55,7 @@ public class TestInitialGCThreadLogging { if (GC.Shenandoah.isSupported()) { noneGCSupported = false; - testInitialGCThreadLogging("UseShenandoahGC", "Shenandoah GC Thread"); + testInitialGCThreadLogging("UseShenandoahGC", "ShenWorker"); } if (noneGCSupported) { diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java index fd1924b9644..5637e578e8f 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java @@ -84,26 +84,19 @@ public class TestEagerReclaimHumongousRegions { * @param phase The phase during concurrent mark to reach before triggering a young garbage collection. * @return Returns the stdout of the VM. */ - private static String runHelperVM(ObjectType type, ReferencePolicy refPolicy, AllocationTiming timing, String phase) throws Exception { + private static String runHelperVM(List args, ObjectType type, ReferencePolicy refPolicy, AllocationTiming timing, String phase) throws Exception { boolean useTypeArray = (type == ObjectType.TYPE_ARRAY); boolean keepReference = (refPolicy == ReferencePolicy.KEEP); boolean allocateAfter = (timing == AllocationTiming.AFTER_MARK_START); - OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-XX:+UseG1GC", - "-Xmx20M", - "-Xms20m", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+VerifyAfterGC", - "-Xbootclasspath/a:.", - "-Xlog:gc=debug,gc+humongous=debug", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - TestEagerReclaimHumongousRegionsClearMarkBitsRunner.class.getName(), - String.valueOf(useTypeArray), - String.valueOf(keepReference), - String.valueOf(allocateAfter), - phase); + args.add(TestEagerReclaimHumongousRegionsClearMarkBitsRunner.class.getName()); + args.add(String.valueOf(useTypeArray)); + args.add(String.valueOf(keepReference)); + args.add(String.valueOf(allocateAfter)); + args.add(phase); + + OutputAnalyzer output = ProcessTools.executeLimitedTestJava(args); String log = output.getStdout(); System.out.println(log); @@ -111,19 +104,25 @@ public class TestEagerReclaimHumongousRegions { return log; } + private static List testArgs() throws Exception { + return List.of("-XX:+UseG1GC", + "-Xmx20M", + "-Xms20m", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+VerifyAfterGC", + "-Xbootclasspath/a:.", + "-Xlog:gc=debug,gc+humongous=debug", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI"); + } + private static String boolToInt(boolean value) { return value ? "1" : "0"; } - private static void runTest(ObjectType type, - ReferencePolicy refPolicy, - AllocationTiming timing, - String phase, - ExpectedState expected) throws Exception { - String log = runHelperVM(type, refPolicy, timing, phase); - + private static void verifyLog(String log, AllocationTiming timing, ExpectedState expected) { // Find the log output indicating that the humongous object has been reclaimed, and marked and verify for the expected results. -// [0.351s][debug][gc,humongous] GC(3) Humongous region 2 (object size 4194320 @ 0x00000000fee00000) remset 0 code roots 0 marked 1 pinned count 0 reclaim candidate 1 type array 1 + // [0.351s][debug][gc,humongous] GC(3) Humongous region 2 (object size 4194320 @ 0x00000000fee00000) remset 0 code roots 0 marked 1 pinned count 0 reclaim candidate 1 type array 1 // Now check the result of the reclaim attempt. We are interested in the last such message (as mentioned above, we might get two). String patternString = "gc,humongous.* marked (\\d) pin.*candidate (\\d)"; @@ -152,6 +151,23 @@ public class TestEagerReclaimHumongousRegions { Asserts.assertTrue(expected.reclaimed == reclaimed, "Wrong log output reclaiming humongous region"); } + private static void runTest(ObjectType type, + ReferencePolicy refPolicy, + AllocationTiming timing, + String phase, + ExpectedState expected) throws Exception { + List vmArgs = testArgs(); + + ArrayList args = new ArrayList(vmArgs); + String log = runHelperVM(args, type, refPolicy, timing, phase); + verifyLog(log, timing, expected); + + ArrayList jfrArgs = new ArrayList(vmArgs); + jfrArgs.addLast("-XX:StartFlightRecording=settings=profile"); + String jfrLog = runHelperVM(jfrArgs, type, refPolicy, timing, phase); + verifyLog(jfrLog, timing, expected); + } + public static void main(String[] args) throws Exception { System.out.println("Tests checking eager reclaim for when the object is allocated before mark start."); runTest(ObjectType.TYPE_ARRAY, ReferencePolicy.DROP, AllocationTiming.BEFORE_MARK_START, WB.BEFORE_MARKING_COMPLETED, ExpectedState.MARKED_CANDIDATE_RECLAIMED); diff --git a/test/hotspot/jtreg/gc/g1/TestRegionAlignment.java b/test/hotspot/jtreg/gc/g1/TestRegionAlignment.java index 2bc25079068..3555fad56a8 100644 --- a/test/hotspot/jtreg/gc/g1/TestRegionAlignment.java +++ b/test/hotspot/jtreg/gc/g1/TestRegionAlignment.java @@ -28,12 +28,12 @@ package gc.g1; * @bug 8013791 * @requires vm.gc.G1 * @summary Make sure that G1 ergonomics pick a heap size that is aligned with the region size - * @run main/othervm -XX:+UseG1GC -XX:G1HeapRegionSize=32m -XX:MaxRAM=555m gc.g1.TestRegionAlignment - * - * When G1 ergonomically picks a maximum heap size it must be aligned to the region size. - * This test tries to get the VM to pick a small and unaligned heap size (by using MaxRAM=555) and a - * large region size (by using -XX:G1HeapRegionSize=32m). This will fail without the fix for 8013791. + * @comment When G1 ergonomically picks a maximum heap size it must be aligned to the region size. + * This test tries to get the VM to pick a small and unaligned heap size (by using MaxRAM=555) and a + * large region size (by using -XX:G1HeapRegionSize=32m). This will fail without the fix for 8013791. + * @run main/othervm -XX:+UseG1GC -XX:G1HeapRegionSize=32m -Xmx140m gc.g1.TestRegionAlignment */ + public class TestRegionAlignment { public static void main(String[] args) { } } diff --git a/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java b/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java index 1156a2166c1..bba3c850213 100644 --- a/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java +++ b/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -53,7 +53,7 @@ public class TestSharedArchiveWithPreTouch { List dump_args = new ArrayList(BaseOptions); if (Platform.is64bit()) { - dump_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" })); + dump_args.addFirst("-XX:+UseCompressedOops" ); } dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump", "-Xlog:cds" })); @@ -66,7 +66,7 @@ public class TestSharedArchiveWithPreTouch { List load_args = new ArrayList(BaseOptions); if (Platform.is64bit()) { - load_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" })); + load_args.addFirst("-XX:+UseCompressedOops" ); } load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-version" })); diff --git a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java index b1ddecd7290..b3a30d8f2f4 100644 --- a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java +++ b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java @@ -44,8 +44,8 @@ import java.lang.ref.WeakReference; * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * * @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions - * -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xms200m -Xmx200m -Xlog:gc - * -XX:InitiatingHeapOccupancyPercent=100 -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectCollected.gc.log + * -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xms200m -Xmx200m -Xlog:gc,gc+humongous=debug + * -XX:InitiatingHeapOccupancyPercent=100 -XX:G1HeapRegionSize=1M -Xlog:gc,gc+humongous=debug:file=TestObjectCollected.gc.log * gc.g1.humongousObjects.TestObjectCollected */ @@ -103,12 +103,22 @@ public class TestObjectCollected { public Reference create() { return new WeakReference<>(new byte[ALLOCATION_SIZE], referenceQueqe); } + + @Override + public boolean expectCleared() { + return true; + } }, SOFT { @Override public Reference create() { return new SoftReference<>(new byte[ALLOCATION_SIZE], referenceQueqe); } + + @Override + public boolean expectCleared() { + return false; + } }; private static final ReferenceQueue referenceQueqe = new ReferenceQueue<>(); @@ -120,6 +130,11 @@ public class TestObjectCollected { * @return weak/soft reference on byte array of ALLOCATION_SIZE */ public abstract Reference create(); + + /** + * For WeakReferences we expect the referent to always be cleared after GC. + */ + public abstract boolean expectCleared(); } @@ -162,8 +177,13 @@ public class TestObjectCollected { isRegionFree = WHITE_BOX.g1BelongsToFreeRegion(adr); boolean isObjCollected = isRegionFree || !isRegionHumongous; - - Asserts.assertEquals(isRefNulled, isObjCollected, + if (ref.expectCleared()) { + Asserts.assertEquals(isRefNulled, true, + "Reference.get() did not return null for a reference where it is expected"); + Asserts.assertEquals(isObjCollected, true, + "The humonogus object was not collected as expected"); + } else { + Asserts.assertEquals(isRefNulled, isObjCollected, String.format("There is an inconsistensy between reference and white box " + "method behavior - one considers object referenced with " + "%s type collected and another doesn't!\n" @@ -172,7 +192,7 @@ public class TestObjectCollected { reference.getClass().getSimpleName(), (isRefNulled ? "" : "not "), (isObjCollected ? "" : " not"))); - + } System.out.println("Passed"); } diff --git a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java index 6f2c7c005df..2028e8751d7 100644 --- a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java +++ b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -119,7 +119,6 @@ public class TestIHOPStatic { System.out.println(" MaxHeapSize : " + heapSize); System.out.println(" Expect for concurrent cycle initiation message : " + expectInitiationMessage); List options = new ArrayList<>(); - Collections.addAll(options, Utils.getTestJavaOpts()); Collections.addAll(options, "-XX:InitiatingHeapOccupancyPercent=" + ihop, "-Dmemory.fill=" + (heapSize * 1024 * 1024 * pctToFill / 100), diff --git a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java index 6f64e6e9b5e..390159e7cd2 100644 --- a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java +++ b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java @@ -57,8 +57,7 @@ public class TestPrintReferences { static final String gcLogTimeRegex = ".* GC\\([0-9]+\\) "; public static void main(String[] args) throws Exception { - testPhases(true); - testPhases(false); + testPhases(); testRefs(); } @@ -93,16 +92,15 @@ public class TestPrintReferences { refRegex("PhantomReference")); } - public static void testPhases(boolean parallelRefProcEnabled) throws Exception { + public static void testPhases() throws Exception { OutputAnalyzer output = ProcessTools.executeLimitedTestJava("-Xlog:gc+phases+ref=debug", "-XX:+UseG1GC", "-Xmx32M", - "-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled", "-XX:-UseDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=2", GCTest.class.getName()); - checkLogFormat(output, parallelRefProcEnabled); + checkLogFormat(output); checkLogValue(output); output.shouldHaveExitValue(0); @@ -113,37 +111,31 @@ public class TestPrintReferences { return indent(6) + phaseName + ": " + timeRegex + "\n"; } - private static String subphaseRegex(String subphaseName, boolean parallelRefProcEnabled) { + private static String subphaseRegex(String subphaseName) { final String timeRegex = "\\s+" + doubleRegex; - if (parallelRefProcEnabled) { - final String timeInParRegex = timeRegex +",\\s"; - return gcLogTimeRegex + indent(8) + subphaseName + - " \\(ms\\):\\s+(Min:" + timeInParRegex + "Avg:" + timeInParRegex + "Max:" + timeInParRegex + "Diff:" + timeInParRegex + "Sum:" + timeInParRegex + - "Workers: [0-9]+|skipped)" + "\n"; - } else { - return gcLogTimeRegex + indent(8) + subphaseName + ":(" + timeRegex + "ms|\\s+skipped)\n"; - } + final String timeInParRegex = timeRegex +",\\s"; + return gcLogTimeRegex + indent(8) + subphaseName + + " \\(ms\\):\\s+(Min:" + timeInParRegex + "Avg:" + timeInParRegex + "Max:" + timeInParRegex + "Diff:" + timeInParRegex + "Sum:" + timeInParRegex + + "Workers: [0-9]+|skipped)" + "\n"; } // Find the first Reference Processing log and check its format. - private static void checkLogFormat(OutputAnalyzer output, boolean parallelRefProcEnabled) { + private static void checkLogFormat(OutputAnalyzer output) { String timeRegex = doubleRegex + "ms"; /* Total Reference processing time */ String totalRegex = gcLogTimeRegex + indent(4) + referenceProcessing + ": " + timeRegex + "\n"; - String balanceRegex = parallelRefProcEnabled ? "(" + gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n)??" : ""; - - final boolean p = parallelRefProcEnabled; + String balanceRegex = "(" + gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n)??"; String phase2Regex = gcLogTimeRegex + phaseRegex(phaseNotifySoftWeakReferences) + balanceRegex + - subphaseRegex("SoftRef", p) + - subphaseRegex("WeakRef", p) + - subphaseRegex("FinalRef", p) + - subphaseRegex("Total", p); - String phase3Regex = gcLogTimeRegex + phaseRegex(phaseNotifyKeepAliveFinalizer) + balanceRegex + subphaseRegex("FinalRef", p); - String phase4Regex = gcLogTimeRegex + phaseRegex(phaseNotifyPhantomReferences) + balanceRegex + subphaseRegex("PhantomRef", p); + subphaseRegex("SoftRef") + + subphaseRegex("WeakRef") + + subphaseRegex("FinalRef") + + subphaseRegex("Total"); + String phase3Regex = gcLogTimeRegex + phaseRegex(phaseNotifyKeepAliveFinalizer) + balanceRegex + subphaseRegex("FinalRef"); + String phase4Regex = gcLogTimeRegex + phaseRegex(phaseNotifyPhantomReferences) + balanceRegex + subphaseRegex("PhantomRef"); output.shouldMatch(totalRegex + phase2Regex + diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java index 71cf2003ddd..2f4ce3df8b2 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,10 +37,9 @@ import static jdk.test.lib.Asserts.*; * @library / * @modules java.base/jdk.internal.misc * java.management - * @run main/othervm -XX:-UseCompressedOops gc.metaspace.TestMetaspaceMemoryPool - * @run main/othervm -XX:-UseCompressedOops -XX:MaxMetaspaceSize=60m gc.metaspace.TestMetaspaceMemoryPool - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers gc.metaspace.TestMetaspaceMemoryPool - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:CompressedClassSpaceSize=60m gc.metaspace.TestMetaspaceMemoryPool + * @run main/othervm gc.metaspace.TestMetaspaceMemoryPool + * @run main/othervm -XX:MaxMetaspaceSize=60m gc.metaspace.TestMetaspaceMemoryPool + * @run main/othervm -XX:CompressedClassSpaceSize=60m gc.metaspace.TestMetaspaceMemoryPool */ public class TestMetaspaceMemoryPool { @@ -51,10 +50,8 @@ public class TestMetaspaceMemoryPool { verifyMemoryPool(getMemoryPool("Metaspace"), isMetaspaceMaxDefined); if (Platform.is64bit()) { - if (InputArguments.contains("-XX:+UseCompressedOops")) { - MemoryPoolMXBean cksPool = getMemoryPool("Compressed Class Space"); - verifyMemoryPool(cksPool, true); - } + MemoryPoolMXBean cksPool = getMemoryPool("Compressed Class Space"); + verifyMemoryPool(cksPool, true); } } diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java index b0f779109e1..5ead40c9068 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,8 +48,7 @@ import gc.testlibrary.PerfCounters; * java.compiler * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC gc.metaspace.TestMetaspacePerfCounters - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC gc.metaspace.TestMetaspacePerfCounters + * @run main/othervm -XX:+UseCompressedOops -XX:+UsePerfData -XX:+UseSerialGC gc.metaspace.TestMetaspacePerfCounters */ /* @test id=Parallel-64 @@ -63,8 +62,7 @@ import gc.testlibrary.PerfCounters; * java.compiler * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC gc.metaspace.TestMetaspacePerfCounters - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC gc.metaspace.TestMetaspacePerfCounters + * @run main/othervm -XX:+UseCompressedOops -XX:+UsePerfData -XX:+UseParallelGC gc.metaspace.TestMetaspacePerfCounters */ /* @test id=G1-64 @@ -78,8 +76,7 @@ import gc.testlibrary.PerfCounters; * java.compiler * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC gc.metaspace.TestMetaspacePerfCounters - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC gc.metaspace.TestMetaspacePerfCounters + * @run main/othervm -XX:+UseCompressedOops -XX:+UsePerfData -XX:+UseG1GC gc.metaspace.TestMetaspacePerfCounters */ /* @test id=Shenandoah-64 @@ -93,8 +90,7 @@ import gc.testlibrary.PerfCounters; * java.compiler * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseShenandoahGC gc.metaspace.TestMetaspacePerfCounters - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseShenandoahGC gc.metaspace.TestMetaspacePerfCounters + * @run main/othervm -XX:+UseCompressedOops -XX:+UsePerfData -XX:+UseShenandoahGC gc.metaspace.TestMetaspacePerfCounters */ /* @test id=Epsilon-64 @@ -108,8 +104,7 @@ import gc.testlibrary.PerfCounters; * java.compiler * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseEpsilonGC gc.metaspace.TestMetaspacePerfCounters - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseEpsilonGC gc.metaspace.TestMetaspacePerfCounters + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:+UsePerfData -XX:+UseEpsilonGC gc.metaspace.TestMetaspacePerfCounters */ /* @test id=Serial-32 @@ -227,14 +222,8 @@ public class TestMetaspacePerfCounters { String ccs = "sun.gc.compressedclassspace"; checkPerfCounters(metaspace); - - if (isUsingCompressedClassPointers()) { - checkPerfCounters(ccs); - checkUsedIncreasesWhenLoadingClass(ccs); - } else { - checkEmptyPerfCounters(ccs); - checkUsedIncreasesWhenLoadingClass(metaspace); - } + checkPerfCounters(ccs); + checkUsedIncreasesWhenLoadingClass(ccs); } private static void checkPerfCounters(String ns) throws Exception { @@ -262,13 +251,6 @@ public class TestMetaspacePerfCounters { assertGTE(snap1.maxCapacity, snap1.capacity); } - private static void checkEmptyPerfCounters(String ns) throws Exception { - for (PerfCounter counter : countersInNamespace(ns)) { - String msg = "Expected " + counter.getName() + " to equal 0"; - assertEQ(counter.longValue(), 0L, msg); - } - } - private static void checkUsedIncreasesWhenLoadingClass(String ns) throws Exception { // Need to ensure that used is up to date and that all unreachable // classes are unloaded before doing this check. @@ -296,7 +278,4 @@ public class TestMetaspacePerfCounters { return ByteCodeLoader.load(name, byteCode); } - private static boolean isUsingCompressedClassPointers() { - return Platform.is64bit() && InputArguments.contains("-XX:+UseCompressedClassPointers"); - } } diff --git a/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java b/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java index fb32c439940..6d5cdf181b9 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java +++ b/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,8 +40,7 @@ import gc.testlibrary.PerfCounters; * @modules java.base/jdk.internal.misc * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -Xlog:class+load,class+unload=trace -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint gc.metaspace.TestPerfCountersAndMemoryPools - * @run main/othervm -Xlog:class+load,class+unload=trace -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint gc.metaspace.TestPerfCountersAndMemoryPools + * @run main/othervm -Xlog:class+load,class+unload=trace -XX:+UseCompressedOops -XX:+UseSerialGC -XX:+UsePerfData -Xint gc.metaspace.TestPerfCountersAndMemoryPools */ /* @test TestPerfCountersAndMemoryPools @@ -60,7 +59,7 @@ public class TestPerfCountersAndMemoryPools { public static void main(String[] args) throws Exception { checkMemoryUsage("Metaspace", "sun.gc.metaspace"); - if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) { + if (Platform.is64bit()) { checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace"); } } diff --git a/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java b/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java index 4237b8ce1dd..db698782e8f 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java +++ b/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Twitter, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,24 +35,21 @@ import java.util.List; * @requires vm.gc.Serial * @summary Tests that the metaspace size transition logging is done correctly. * @library /test/lib - * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseSerialGC - * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseSerialGC + * @run driver gc.metaspace.TestSizeTransitions -XX:+UseSerialGC */ /* @test TestSizeTransitionsParallel * @requires vm.gc.Parallel * @summary Tests that the metaspace size transition logging is done correctly. * @library /test/lib - * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseParallelGC - * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseParallelGC + * @run driver gc.metaspace.TestSizeTransitions -XX:+UseParallelGC */ /* @test TestSizeTransitionsG1 * @requires vm.gc.G1 * @summary Tests that the metaspace size transition logging is done correctly. * @library /test/lib - * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseG1GC - * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseG1GC + * @run driver gc.metaspace.TestSizeTransitions -XX:+UseG1GC */ public class TestSizeTransitions { @@ -76,13 +73,13 @@ public class TestSizeTransitions { private static final String SIZE_TRANSITION_REGEX = "\\d+K\\(\\d+K\\)->\\d+K\\(\\d+K\\)"; // matches -coops metaspace size transitions - private static final String NO_COMPRESSED_KLASS_POINTERS_REGEX = + private static final String WITHOUT_CLASS_SPACE_REGEX = String.format("^%s.* Metaspace: %s$", LOG_TAGS_REGEX, SIZE_TRANSITION_REGEX); // matches +coops metaspace size transitions - private static final String COMPRESSED_KLASS_POINTERS_REGEX = + private static final String WITH_CLASS_SPACE_REGEX = String.format("^%s.* Metaspace: %s NonClass: %s Class: %s$", LOG_TAGS_REGEX, SIZE_TRANSITION_REGEX, @@ -90,26 +87,11 @@ public class TestSizeTransitions { SIZE_TRANSITION_REGEX); public static void main(String... args) throws Exception { - // args: - if (args.length != 2) { - throw new RuntimeException("wrong number of args: " + args.length); + if (args.length == 0) { + throw new RuntimeException("expected jvm args: " + args.length); } - final boolean hasCompressedKlassPointers = Platform.is64bit(); - final boolean useCompressedKlassPointers = Boolean.parseBoolean(args[0]); - final String gcArg = args[1]; - - if (!hasCompressedKlassPointers && useCompressedKlassPointers) { - // No need to run this configuration. - System.out.println("Skipping test."); - return; - } - - List jvmArgs = new ArrayList<>(); - if (hasCompressedKlassPointers) { - jvmArgs.add(useCompressedKlassPointers ? "-XX:+UseCompressedClassPointers" : "-XX:-UseCompressedClassPointers"); - } - jvmArgs.add(gcArg); + List jvmArgs = new ArrayList<>(List.of(args)); jvmArgs.add("-Xmx256m"); jvmArgs.add("-Xlog:gc,gc+metaspace=info"); jvmArgs.add(TestSizeTransitions.Run.class.getName()); @@ -123,12 +105,14 @@ public class TestSizeTransitions { System.out.println(output.getStdout()); output.shouldHaveExitValue(0); - if (useCompressedKlassPointers) { - output.stdoutShouldMatch(COMPRESSED_KLASS_POINTERS_REGEX); - output.stdoutShouldNotMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX); + // 32-bit uses narrow Pointers but no class space + final boolean hasClassSpace = Platform.is64bit(); + if (hasClassSpace) { + output.stdoutShouldMatch(WITH_CLASS_SPACE_REGEX); + output.stdoutShouldNotMatch(WITHOUT_CLASS_SPACE_REGEX); } else { - output.stdoutShouldMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX); - output.stdoutShouldNotMatch(COMPRESSED_KLASS_POINTERS_REGEX); + output.stdoutShouldMatch(WITHOUT_CLASS_SPACE_REGEX); + output.stdoutShouldNotMatch(WITH_CLASS_SPACE_REGEX); } } } diff --git a/test/hotspot/jtreg/gc/shenandoah/compiler/TestLinkToNativeRBP.java b/test/hotspot/jtreg/gc/shenandoah/compiler/TestLinkToNativeRBP.java index 96440ba15ae..ff853d174b1 100644 --- a/test/hotspot/jtreg/gc/shenandoah/compiler/TestLinkToNativeRBP.java +++ b/test/hotspot/jtreg/gc/shenandoah/compiler/TestLinkToNativeRBP.java @@ -27,10 +27,11 @@ * @summary guarantee(loc != NULL) failed: missing saved register with native invoke * * @requires vm.flavor == "server" - * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "ppc64" | os.arch == "ppc64le" + * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | + os.arch == "aarch64" | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "riscv64" * @requires vm.gc.Shenandoah * - * @run main/othervm --enable-native-access=ALL-UNNAMED -XX:+UnlockDiagnosticVMOptions + * @run main/native/othervm --enable-native-access=ALL-UNNAMED -XX:+UnlockDiagnosticVMOptions * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive TestLinkToNativeRBP * */ diff --git a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java index a66b9161c7e..7af81fabe13 100644 --- a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java +++ b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java @@ -27,6 +27,7 @@ * @summary Test that growth of old-gen triggers old-gen marking * @key intermittent * @requires vm.gc.Shenandoah + * @requires vm.flagless * @library /test/lib * @run driver TestOldGrowthTriggers */ @@ -34,7 +35,6 @@ import java.util.*; import java.math.BigInteger; -import jdk.test.lib.Asserts; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; diff --git a/test/hotspot/jtreg/gc/shenandoah/mxbeans/TestCycleEndMessage.java b/test/hotspot/jtreg/gc/shenandoah/mxbeans/TestCycleEndMessage.java new file mode 100644 index 00000000000..e7a4cfc9605 --- /dev/null +++ b/test/hotspot/jtreg/gc/shenandoah/mxbeans/TestCycleEndMessage.java @@ -0,0 +1,83 @@ +/* + * Copyright Amazon.com Inc. 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 + * @summary Check that GC cycle end message contains generation name + * @library /test/lib / + * @requires vm.gc.Shenandoah + * + * @run main/othervm -Xmx128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational + * TestCycleEndMessage + */ + +import java.lang.management.GarbageCollectorMXBean; +import java.lang.management.ManagementFactory; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.management.Notification; +import javax.management.NotificationEmitter; +import javax.management.NotificationListener; +import javax.management.openmbean.CompositeData; + +import com.sun.management.GarbageCollectionNotificationInfo; + +public class TestCycleEndMessage { + + public static void main(String[] args) throws Exception { + final AtomicBoolean foundGenerationInCycle = new AtomicBoolean(false); + + NotificationListener listener = new NotificationListener() { + @Override + public void handleNotification(Notification n, Object o) { + if (n.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { + GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) n.getUserData()); + + String name = info.getGcName(); + String action = info.getGcAction(); + + System.out.println("Received: " + name + " / " + action); + + if (name.equals("Shenandoah Cycles") && + (action.contains("Global") || action.contains("Young") || action.contains("Old"))) { + foundGenerationInCycle.set(true); + } + } + } + }; + + for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { + ((NotificationEmitter) bean).addNotificationListener(listener, null, null); + } + + System.gc(); + Thread.sleep(2000); + + if (!foundGenerationInCycle.get()) { + throw new IllegalStateException("Expected to find generation name (Global/Young/Old) in Shenandoah Cycles action message"); + } + + System.out.println("Test passed: Found generation name in cycle end message"); + } +} diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithAllocateHeapAt.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithAllocateHeapAt.java index 778d398d9d2..cf837c1c3dd 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithAllocateHeapAt.java @@ -31,7 +31,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.G1 - * @requires vm.flavor == "server" & !vm.emulatedClient & os.family != "aix" + * @requires vm.flavor == "server" & os.family != "aix" * @summary Stress Java heap allocation with AllocateHeapAt flag using GC basher. * @run main/othervm/timeout=500 -Xlog:gc*=info -Xmx256m -server -XX:+UseG1GC -XX:AllocateHeapAt=. gc.stress.gcbasher.TestGCBasherWithAllocateHeapAt 120000 */ diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithG1.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithG1.java index 4f11ab361fb..a9095d73d9d 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithG1.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithG1.java @@ -31,7 +31,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.G1 - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the G1 GC by trying to make old objects more likely to be garbage than young objects. * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx256m -XX:+UseG1GC gc.stress.gcbasher.TestGCBasherWithG1 120000 */ diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithParallel.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithParallel.java index ee5ab654462..1bb71531abd 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithParallel.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithParallel.java @@ -31,7 +31,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Parallel - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Parallel GC by trying to make old objects more likely to be garbage than young objects. * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx256m -XX:+UseParallelGC -XX:-UseGCOverheadLimit gc.stress.gcbasher.TestGCBasherWithParallel 120000 */ diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithSerial.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithSerial.java index 25650b6b9d5..ff6ad786302 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithSerial.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithSerial.java @@ -31,7 +31,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Serial - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Serial GC by trying to make old objects more likely to be garbage than young objects. * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx256m -XX:+UseSerialGC gc.stress.gcbasher.TestGCBasherWithSerial 120000 */ diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithShenandoah.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithShenandoah.java index 0d1a4af9a2a..3bf0e59dce3 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithShenandoah.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithShenandoah.java @@ -32,7 +32,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Shenandoah GC by trying to make old objects more likely to be garbage than young objects. * * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -51,7 +51,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Shenandoah GC by trying to make old objects more likely to be garbage than young objects. * * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -74,7 +74,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Shenandoah GC by trying to make old objects more likely to be garbage than young objects. * * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -92,7 +92,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -105,7 +105,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -126,7 +126,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -152,7 +152,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -172,7 +172,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -185,7 +185,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress the Shenandoah GC by trying to make old objects more likely to be garbage than young objects. * * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions @@ -203,7 +203,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Shenandoah - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress Shenandoah GC with nmethod barrier forced deoptimization enabled. * * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java index d4a95fd9791..2007580f065 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java @@ -31,7 +31,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Z - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @summary Stress ZGC * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx384m -XX:+UseZGC gc.stress.gcbasher.TestGCBasherWithZ 120000 */ @@ -41,7 +41,7 @@ import java.io.IOException; * @key stress * @library / * @requires vm.gc.Z - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false + * @requires vm.flavor == "server" & vm.opt.ClassUnloading != false * @summary Stress ZGC with nmethod barrier forced deoptimization enabled. * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx384m -XX:+UseZGC * -XX:+UnlockDiagnosticVMOptions -XX:+DeoptimizeNMethodBarriersALot -XX:-Inline diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java index 3dbedd61d12..e4185dd0f12 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java @@ -129,7 +129,8 @@ class TestStringDeduplicationTools { GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) n.getUserData()); // Shenandoah and Z GC also report GC pauses, skip them if (info.getGcName().startsWith("Shenandoah")) { - if ("end of GC cycle".equals(info.getGcAction())) { + String action = info.getGcAction(); + if (action != null && action.contains("GC cycle")) { gcCount++; } } else if (info.getGcName().startsWith("ZGC")) { diff --git a/test/hotspot/jtreg/gtest/ArrayTests.java b/test/hotspot/jtreg/gtest/ArrayTests.java index b1afa4795d2..d3a8498d5eb 100644 --- a/test/hotspot/jtreg/gtest/ArrayTests.java +++ b/test/hotspot/jtreg/gtest/ArrayTests.java @@ -26,31 +26,18 @@ * This tests object array sizes by running gtests with different settings. */ -/* @test id=with-coops-with-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers +/* @test id=with-coops + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:+UseCompressedClassPointers -XX:+UseCompressedOops + * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:+UseCompressedOops */ -/* @test id=with-coops-no-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers + +/* @test id=no-coops + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:-UseCompressedClassPointers -XX:+UseCompressedOops - */ -/* @test id=no-coops-with-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:+UseCompressedClassPointers -XX:-UseCompressedOops - */ -/* @test id=no-coops-no-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:-UseCompressedClassPointers -XX:-UseCompressedOops + * @run main/native GTestWrapper --gtest_filter=arrayOop -XX:-UseCompressedOops */ diff --git a/test/hotspot/jtreg/gtest/CompressedKlassGtest.java b/test/hotspot/jtreg/gtest/CompressedKlassGtest.java index ba801724558..24f1dff5a30 100644 --- a/test/hotspot/jtreg/gtest/CompressedKlassGtest.java +++ b/test/hotspot/jtreg/gtest/CompressedKlassGtest.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2024, Red Hat, Inc. All rights reserved. - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,14 +39,6 @@ * @run main/native GTestWrapper --gtest_filter=CompressedKlass* -XX:-UseCompactObjectHeaders -Xlog:metaspace* -Xmx6g -Xms128m -Xshare:off -XX:CompressedClassSpaceSize=128m */ -/* @test id=ccp_off - * @library /test/lib - * @requires vm.bits == "64" - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=CompressedKlass* -XX:-UseCompressedClassPointers -Xlog:metaspace* -Xmx6g -Xms128m - */ - /* @test id=use-zero-based-encoding-coh * @library /test/lib * @requires vm.bits == "64" diff --git a/test/hotspot/jtreg/gtest/MetaspaceGtests.java b/test/hotspot/jtreg/gtest/MetaspaceGtests.java index 38fef145125..26faa2c7c2d 100644 --- a/test/hotspot/jtreg/gtest/MetaspaceGtests.java +++ b/test/hotspot/jtreg/gtest/MetaspaceGtests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -40,15 +40,6 @@ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=1 */ -/* @test id=no-ccs - * @summary Run metaspace-related gtests with compressed class pointers off - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @requires vm.bits == 64 - * @requires vm.flagless - * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:-UseCompressedClassPointers - */ /* @test id=UseCompactObjectHeaders * @summary Run metaspace-related gtests with tiny classpointers diff --git a/test/hotspot/jtreg/gtest/ObjArrayTests.java b/test/hotspot/jtreg/gtest/ObjArrayTests.java index baae1840417..ede85948335 100644 --- a/test/hotspot/jtreg/gtest/ObjArrayTests.java +++ b/test/hotspot/jtreg/gtest/ObjArrayTests.java @@ -26,60 +26,34 @@ * This tests object array sizes by running gtests with different settings. */ -/* @test id=with-coops-with-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers +/* @test id=with-coops + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedClassPointers -XX:+UseCompressedOops - */ -/* @test id=with-coops-no-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedClassPointers -XX:+UseCompressedOops - */ -/* @test id=no-coops-with-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedClassPointers -XX:-UseCompressedOops - */ -/* @test id=no-coops-no-ccp - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedClassPointers -XX:-UseCompressedOops + * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedOops */ -/* @test id=with-coops-with-ccp-large-align - * @summary Run object array size tests with compressed oops and compressed class pointers +/* @test id=no-coops + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:ObjAlignmentInBytes=256 + * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedOops */ -/* @test id=with-coops-no-ccp-large-align - * @summary Run object array size tests with compressed oops and compressed class pointers + +/* @test id=with-coops-large-align + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedClassPointers -XX:+UseCompressedOops -XX:ObjAlignmentInBytes=256 + * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedOops -XX:ObjAlignmentInBytes=256 */ -/* @test id=no-coops-with-ccp-large-align - * @summary Run object array size tests with compressed oops and compressed class pointers + +/* @test id=no-coops-large-align + * @summary Run object array size tests with compressed oops * @library /test/lib * @modules java.base/jdk.internal.misc * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:+UseCompressedClassPointers -XX:-UseCompressedOops -XX:ObjAlignmentInBytes=256 - */ -/* @test id=no-coops-no-ccp-large-align - * @summary Run object array size tests with compressed oops and compressed class pointers - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.xml - * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedClassPointers -XX:-UseCompressedOops -XX:ObjAlignmentInBytes=256 + * @run main/native GTestWrapper --gtest_filter=objArrayOop -XX:-UseCompressedOops -XX:ObjAlignmentInBytes=256 */ diff --git a/test/hotspot/jtreg/gtest/TestSpinPauseAArch64.java b/test/hotspot/jtreg/gtest/TestSpinPauseAArch64.java index 475c86d889f..6adf00af250 100644 --- a/test/hotspot/jtreg/gtest/TestSpinPauseAArch64.java +++ b/test/hotspot/jtreg/gtest/TestSpinPauseAArch64.java @@ -28,6 +28,7 @@ * @library /test/lib * @requires vm.flagless * @requires os.arch=="aarch64" + * @requires os.family != "windows" * @run main/native GTestWrapper --gtest_filter=SpinPause* * @run main/native GTestWrapper --gtest_filter=SpinPause* -XX:+UnlockDiagnosticVMOptions -XX:OnSpinWaitInst=none * @run main/native GTestWrapper --gtest_filter=SpinPause* -XX:+UnlockDiagnosticVMOptions -XX:OnSpinWaitInst=nop @@ -41,6 +42,6 @@ * @summary Run SpinPause gtest using SB instruction for SpinPause * @library /test/lib * @requires vm.flagless - * @requires (os.arch=="aarch64" & vm.cpu.features ~= ".*sb.*") + * @requires (os.arch=="aarch64" & vm.cpu.features ~= ".*sb.*" & os.family != "windows") * @run main/native GTestWrapper --gtest_filter=SpinPause* -XX:+UnlockDiagnosticVMOptions -XX:OnSpinWaitInst=sb */ diff --git a/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java b/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java index 553b8fbac35..cf32880c182 100644 --- a/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java +++ b/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,9 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @bug 8171084 - * @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.bits == "64" & os.maxMemory > 8g * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.utilities diff --git a/test/hotspot/jtreg/runtime/7167069/PrintAsFlag.java b/test/hotspot/jtreg/runtime/7167069/PrintAsFlag.java index 9948ef1738f..cd03af20b34 100644 --- a/test/hotspot/jtreg/runtime/7167069/PrintAsFlag.java +++ b/test/hotspot/jtreg/runtime/7167069/PrintAsFlag.java @@ -27,7 +27,7 @@ * * @test PrintAsFlag * @summary verify that Flag::print_as_flag() works correctly. This is used by "jinfo -flag" and -XX:+PrintCommandLineFlags. - * @run main/othervm -XX:+PrintCommandLineFlags -XX:-ShowMessageBoxOnError -XX:ParallelGCThreads=4 -XX:MaxRAM=1G -XX:ErrorFile="file" PrintAsFlag + * @run main/othervm -XX:+PrintCommandLineFlags -XX:-ShowMessageBoxOnError -XX:ParallelGCThreads=4 -XX:ErrorLogTimeout=12345 -XX:ErrorFile="file" PrintAsFlag */ public class PrintAsFlag { diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java deleted file mode 100644 index 51b0469ce46..00000000000 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013, 2023, 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 - * @requires vm.cds - * @requires vm.bits == 64 - * @requires vm.flagless - * @bug 8003424 - * @summary Testing UseCompressedClassPointers with CDS - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @run driver CDSCompressedKPtrs - */ - -import jdk.test.lib.Platform; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jtreg.SkippedException; - -public class CDSCompressedKPtrs { - public static void main(String[] args) throws Exception { - ProcessBuilder pb; - pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", - "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:dump", "-Xlog:cds"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - try { - output.shouldContain("Loading classes to share"); - output.shouldHaveExitValue(0); - - pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", - "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:on", "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("sharing"); - output.shouldHaveExitValue(0); - - } catch (RuntimeException e) { - output.shouldContain("Unable to use shared archive"); - output.shouldHaveExitValue(1); - throw new SkippedException("CDS was turned off"); - } - } -} diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 0ac19c4a487..eb0fd5f8be5 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -237,7 +237,6 @@ public class TestOptionsWithRanges { excludeTestMaxRange("G1ConcRefinementThreads"); excludeTestMaxRange("InitialHeapSize"); excludeTestMaxRange("MaxHeapSize"); - excludeTestMaxRange("MaxRAM"); excludeTestMaxRange("NewSize"); excludeTestMaxRange("ParallelGCThreads"); excludeTestMaxRange("TLABSize"); diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java index ef74dc41846..617bf910108 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java @@ -218,9 +218,6 @@ public class JVMOptionsUtils { option.addPrepend("-XX:+VerifyBeforeGC"); option.addPrepend("-XX:+VerifyAfterGC"); break; - case "NewSizeThreadIncrease": - option.addPrepend("-XX:+UseSerialGC"); - break; case "SharedBaseAddress": case "SharedSymbolTableBucketSize": option.addPrepend("-XX:+UnlockDiagnosticVMOptions"); diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java index e4b6f2a0548..fe1f8cb92fc 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,6 @@ import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jtreg.SkippedException; public class CompressedClassPointers { @@ -218,7 +217,6 @@ public class CompressedClassPointers { public static void smallHeapTestNoCoop() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedBaseAddress=8g", "-Xmx128m", @@ -236,7 +234,6 @@ public class CompressedClassPointers { public static void smallHeapTestWith1GNoCoop() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-XX:CompressedClassSpaceSize=1g", "-Xmx128m", @@ -258,7 +255,6 @@ public class CompressedClassPointers { public static void largeHeapTestNoCoop() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", "-Xmx30g", @@ -280,7 +276,6 @@ public class CompressedClassPointers { public static void largePagesTestNoCoop() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-Xmx128m", "-XX:+UseLargePages", @@ -291,23 +286,10 @@ public class CompressedClassPointers { output.shouldHaveExitValue(0); } - public static void heapBaseMinAddressTestNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", - "-XX:HeapBaseMinAddress=1m", - "-Xlog:gc+heap+coops=debug", - "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("HeapBaseMinAddress must be at least"); - output.shouldHaveExitValue(0); - } - public static void sharingTestNoCoop() throws Exception { // Test small heaps ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CompressedClassPointers.jsa", "-Xmx128m", @@ -325,7 +307,6 @@ public class CompressedClassPointers { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CompressedClassPointers.jsa", "-Xmx128m", @@ -356,7 +337,6 @@ public class CompressedClassPointers { smallHeapTestWith1GNoCoop(); largeHeapTestNoCoop(); largePagesTestNoCoop(); - heapBaseMinAddressTestNoCoop(); sharingTestNoCoop(); } } diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java index 7bbb9edb7b4..0898e6b96eb 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -107,13 +107,6 @@ public class CompressedClassSpaceSize { output = new OutputAnalyzer(pb.start()); output.shouldContain("outside the allowed range") .shouldHaveExitValue(1); - - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:-UseCompressedClassPointers", - "-XX:CompressedClassSpaceSize=" + minAllowedClassSpaceSize, - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") - .shouldHaveExitValue(0); } break; case "valid_small": { diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java index 403654d1cc8..32bb432308b 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,8 +23,7 @@ /* * @test - * @bug 8000968 - * @summary NPG: UseCompressedClassPointers asserts with ObjectAlignmentInBytes=32 + * @summary Test Compressed Oops with different object alignments * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -51,7 +50,6 @@ public class CompressedKlassPointerAndOops { OutputAnalyzer output; pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", "-XX:ObjectAlignmentInBytes=" + alignment, "-version"); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java index ba36d5810d8..7608c5f5619 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java @@ -169,6 +169,10 @@ public class MachCodeFramesInErrorFile { Matcher matcher = Pattern.compile("\\[MachCode\\]\\s*\\[Verified Entry Point\\]\\s* # \\{method\\} \\{[^}]*\\} '([^']+)' '([^']+)' in '([^']+)'", Pattern.DOTALL).matcher(hsErr); List machCodeHeaders = matcher.results().map(mr -> String.format("'%s' '%s' in '%s'", mr.group(1), mr.group(2), mr.group(3))).collect(Collectors.toList()); int minExpectedMachCodeSections = Math.max(1, compiledJavaFrames); + if ((hsErr.contains("stop reattempt (retry printing native stack (no source info))") || hsErr.contains("reason: Step time limit reached"))) { + // In this case, the vm only prints the crashing frame. + minExpectedMachCodeSections = 1; + } if (machCodeHeaders.size() < minExpectedMachCodeSections) { Asserts.fail(machCodeHeaders.size() + " < " + minExpectedMachCodeSections); } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java b/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java index a964a61003a..1e29afe5ff8 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java @@ -33,7 +33,7 @@ import java.util.List; * @test StackWalkNativeToJava * @bug 8316309 * @summary Check that walking the stack works fine when going from C++ frame to Java frame. - * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" + * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch=="riscv64" * @requires os.family != "windows" * @requires vm.flagless * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java index 00b5becdbfa..6fe00498797 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,13 +108,19 @@ public class TestDwarf { if (Platform.isX64() || Platform.isX86()) { // Not all platforms raise SIGFPE but x86_32 and x86_64 do. runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDivByZero"), - new DwarfConstraint(0, "Java_TestDwarf_crashNativeDivByZero", "libTestDwarf.c", 59)); + new DwarfConstraint(0, "Java_TestDwarf_crashNativeDivByZero", "libTestDwarf.c", 62)); runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeMultipleMethods"), - new DwarfConstraint(0, "foo", "libTestDwarf.c", 42), - new DwarfConstraint(1, "Java_TestDwarf_crashNativeMultipleMethods", "libTestDwarf.c", 70)); + new DwarfConstraint(0, "foo", "libTestDwarf.c", 45), + new DwarfConstraint(1, "Java_TestDwarf_crashNativeMultipleMethods", "libTestDwarf.c", 73)); + } + // Null pointer dereferences exhibit different behaviour depending on if GCC or Clang is used. + // When using GCC, the VM will crash gracefully and generate a hs_err which can be parsed. + // On the contrary, with Clang the process exits immediately without hs_err. + // Since runAndCheck needs an hs_err file, we have to skip this subtest. + if (!isUsingClang()) { + runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"), + new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 49)); } - runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"), - new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 46)); } // A full pattern could check for lines like: @@ -240,6 +246,7 @@ public class TestDwarf { private static native void crashNativeDivByZero(); private static native void crashNativeDereferenceNull(); private static native void crashNativeMultipleMethods(int x); + private static native boolean isUsingClang(); } class UnsupportedDwarfVersionException extends RuntimeException { } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java index 1e168221726..8f41121fbc1 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java @@ -56,7 +56,7 @@ public class TestVMConfigInHsErrFile { public static void main(String[] args) throws Exception { switch (args[0]) { case "coh-on" -> testCompactObjectHeaders(); - case "coh-off" -> testCompressedClassPointers(); + case "coh-off" -> testNotCompactObjectHeaders(); } } @@ -79,20 +79,16 @@ public class TestVMConfigInHsErrFile { Pattern[] expectedPatterns = new Pattern[] { Pattern.compile("# Java VM: .*compact obj headers.*") }; - Pattern[] notExpectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compressed class ptrs.*") - }; - HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); + HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, null, true, true); } - private static void testCompressedClassPointers() throws Exception { + private static void testNotCompactObjectHeaders() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", "-XX:-UseCompactObjectHeaders", - "-XX:+UseCompressedClassPointers", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=14", @@ -104,14 +100,11 @@ public class TestVMConfigInHsErrFile { // extract hs-err file File f = HsErrFileUtils.openHsErrFileFromOutput(output); - Pattern[] expectedPatterns = new Pattern[] { - Pattern.compile("# Java VM: .*compressed class ptrs.*") - }; Pattern[] notExpectedPatterns = new Pattern[] { Pattern.compile("# Java VM: .*compact obj headers.*") }; - HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true); + HsErrFileUtils.checkHsErrFileContent(f, null, notExpectedPatterns, true, true); } } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarf.c b/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarf.c index 616a6f07d12..19993d17de3 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarf.c +++ b/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +28,10 @@ int zero = 0; int result = 0; int limit = 20; -// Just big enough by doing some random things such that it is not inlined. +// Explicitly don't inline. foo needs complexity so GCC/Clang don't optimize it away. +#if !defined(_MSC_VER) +__attribute__((noinline)) +#endif void foo(int x) { printf("foo3:"); printf(" %d\n", x); @@ -76,3 +79,12 @@ JNIEXPORT void JNICALL Java_TestDwarf_crashNativeMultipleMethods(JNIEnv* env, jc } } +// Need to tell if Clang was used to build libTestDwarf. +JNIEXPORT jboolean JNICALL Java_TestDwarf_isUsingClang(JNIEnv* env, jobject obj) { +#if defined(__clang__) + return JNI_TRUE; +#else + return JNI_FALSE; +#endif +} + diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarfHelper.h b/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarfHelper.h index 1da05c1c3d3..9f9ef33add2 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarfHelper.h +++ b/test/hotspot/jtreg/runtime/ErrorHandling/libTestDwarfHelper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,6 +41,9 @@ void unused4() { void unused5() { } +#if !defined(_MSC_VER) +__attribute__((noinline)) +#endif EXPORT void dereference_null() { int* x = (int*)0; *x = 34; // Crash diff --git a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java index 73f5a1c6137..00b09fec6ed 100644 --- a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java +++ b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,47 +22,29 @@ */ /* - * @test id=with-coops-with-ccp + * @test id=with-coops * @library /test/lib / * @requires vm.bits == "64" * @modules java.base/jdk.internal.misc * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:-UseCompactObjectHeaders BaseOffsets + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseCompressedOops -XX:-UseCompactObjectHeaders BaseOffsets */ + /* - * @test id=no-coops-with-ccp + * @test id=no-coops * @library /test/lib / * @requires vm.bits == "64" * @modules java.base/jdk.internal.misc * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCompressedOops -XX:+UseCompressedClassPointers -XX:-UseCompactObjectHeaders BaseOffsets + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCompressedOops -XX:-UseCompactObjectHeaders BaseOffsets */ + /* - * @test id=with-coops-no-ccp - * @library /test/lib / - * @requires vm.bits == "64" - * @modules java.base/jdk.internal.misc - * java.management - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseCompressedOops -XX:-UseCompressedClassPointers -XX:-UseCompactObjectHeaders BaseOffsets - */ -/* - * @test id=no-coops-no-ccp - * @library /test/lib / - * @requires vm.bits == "64" - * @modules java.base/jdk.internal.misc - * java.management - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:-UseCompactObjectHeaders BaseOffsets - */ -/* - * @test id=with-coop--with-coh + * @test id=with-coop-with-coh * @library /test/lib / * @requires vm.bits == "64" * @modules java.base/jdk.internal.misc @@ -71,6 +53,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseCompressedOops -XX:+UseCompactObjectHeaders BaseOffsets */ + /* * @test id=no-coops-with-coh * @library /test/lib / @@ -81,6 +64,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCompressedOops -XX:+UseCompactObjectHeaders BaseOffsets */ + /* * @test id=32bit * @library /test/lib / @@ -117,14 +101,10 @@ public class BaseOffsets { INT_OFFSET = 8; INT_ARRAY_OFFSET = 12; LONG_ARRAY_OFFSET = 16; - } else if (WB.getBooleanVMFlag("UseCompressedClassPointers")) { + } else { INT_OFFSET = 12; INT_ARRAY_OFFSET = 16; LONG_ARRAY_OFFSET = 16; - } else { - INT_OFFSET = 16; - INT_ARRAY_OFFSET = 20; - LONG_ARRAY_OFFSET = 24; } } diff --git a/test/hotspot/jtreg/runtime/FieldLayout/FieldDensityTest.java b/test/hotspot/jtreg/runtime/FieldLayout/FieldDensityTest.java index 5f4fb7a79c4..019b428ae84 100644 --- a/test/hotspot/jtreg/runtime/FieldLayout/FieldDensityTest.java +++ b/test/hotspot/jtreg/runtime/FieldLayout/FieldDensityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,7 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run main/othervm -XX:+UseCompressedOops -XX:+UseCompressedClassPointers FieldDensityTest - * @run main/othervm -XX:+UseCompressedOops -XX:-UseCompressedClassPointers FieldDensityTest + * @run main/othervm -XX:+UseCompressedOops FieldDensityTest */ import java.lang.reflect.Field; diff --git a/test/hotspot/jtreg/runtime/FieldLayout/TestOopMapSizeMinimal.java b/test/hotspot/jtreg/runtime/FieldLayout/TestOopMapSizeMinimal.java index 861f1aa3d1b..263bd750ca3 100644 --- a/test/hotspot/jtreg/runtime/FieldLayout/TestOopMapSizeMinimal.java +++ b/test/hotspot/jtreg/runtime/FieldLayout/TestOopMapSizeMinimal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,47 +30,27 @@ import java.util.ArrayList; import java.util.List; /* - * @test id=no_coops_no_ccptr_no_coh + * @test id=no_coops_no_coh * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseCompressedOops -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal */ /* - * @test id=coops_no_ccptr_no_coh + * @test id=coops_no_coh * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:-UseCompressedClassPointers -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal */ /* - * @test id=no_coops_ccptr_no_coh - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseCompressedOops -XX:+UseCompressedClassPointers -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal - */ - -/* - * @test id=coops_ccptr_no_coh - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:-UseCompactObjectHeaders TestOopMapSizeMinimal - */ - -/* - * @test id=no_coops_ccptr_coh + * @test id=no_coops_coh * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -79,6 +59,16 @@ import java.util.List; * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseCompressedOops -XX:+UseCompactObjectHeaders TestOopMapSizeMinimal */ +/* + * @test id=coops_coh + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:+UseCompactObjectHeaders TestOopMapSizeMinimal + */ + public class TestOopMapSizeMinimal { public static int OOP_SIZE_IN_BYTES = -1; @@ -99,10 +89,8 @@ public class TestOopMapSizeMinimal { if (is_64_bit) { if (WB.getBooleanVMFlag("UseCompactObjectHeaders")) { HEADER_SIZE_IN_BYTES = 8; - } else if (WB.getBooleanVMFlag("UseCompressedClassPointers")) { - HEADER_SIZE_IN_BYTES = 12; } else { - HEADER_SIZE_IN_BYTES = 16; + HEADER_SIZE_IN_BYTES = 12; } } else { HEADER_SIZE_IN_BYTES = 8; @@ -188,10 +176,9 @@ public class TestOopMapSizeMinimal { // DERIVED4 o4 oopmap entry 2 (reversed order) // i4 - // There are two combinations that have gaps: - // -UseCompressedOops + +COH, and -UseCompressedOops + -UseCompressedClassPointers. - // In both cases there is a gap following i1, and i2 will therefore nestle into that gap. - // Otherwise the same logic applies. + // There is one combination that has gaps: + // -UseCompressedOops + +COH: A gap will be following i1, and i2 will therefore nestle into that gap. + // Otherwise, the same logic applies. if (OOP_SIZE_IN_BYTES == 4 || // oop size == int size (OOP_SIZE_IN_BYTES == 8 && HEADER_SIZE_IN_BYTES == 12) diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java index b2ff8ed9bde..a42a6ee3a52 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +39,6 @@ public class MaxMetaspaceSizeTest { "-Xshare:off", "-Xmx1g", "-XX:MaxMetaspaceSize=4K", - "-XX:+UseCompressedClassPointers", "-XX:CompressedClassSpaceSize=1g", "--version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java index 7ff19326324..f526405900d 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java +++ b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, SAP and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -22,62 +22,27 @@ * questions. */ +import jdk.test.lib.Platform; import jdk.test.lib.dcmd.PidJcmdExecutor; import jdk.test.lib.process.OutputAnalyzer; -/* - * @test id=test-64bit-ccs - * @summary Test the VM.metaspace command - * @requires vm.bits == "64" - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers PrintMetaspaceDcmd - */ +import java.io.IOException; /* - * @test id=test-64bit-noccs + * @test * @summary Test the VM.metaspace command - * @requires vm.bits == "64" * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run main/othervm -Dwithout-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:-UseCompressedOops -XX:-UseCompressedClassPointers PrintMetaspaceDcmd - */ - - /* - * @test id=test-nospecified - * @summary Test the VM.metaspace command - * @requires vm.bits == "64" - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @run main/othervm -Dno-specified-flag -Xmx100M -XX:-UseCompressedOops -XX:-UseCompressedClassPointers PrintMetaspaceDcmd - */ - -/* - * @test test-32bit - * @summary Test the VM.metaspace command - * @requires vm.bits == "32" - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @run main/othervm -Dwithout-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M PrintMetaspaceDcmd + * @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M PrintMetaspaceDcmd */ public class PrintMetaspaceDcmd { - private static void doTheNoSpecifiedPropTest() throws Exception { - ProcessBuilder pb = new ProcessBuilder(); - OutputAnalyzer output; + public static void main(String [] args) throws IOException { - pb.command(new PidJcmdExecutor().getCommandLine("VM.metaspace", "basic")); - output = new OutputAnalyzer(pb.start()); - output.shouldHaveExitValue(0); - output.shouldMatch("MaxMetaspaceSize: unlimited"); - } + final boolean usesCompressedClassSpace = Platform.is64bit(); - private static void doTheCCSPropTest(boolean usesCompressedClassSpace) throws Exception { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; @@ -172,15 +137,4 @@ public class PrintMetaspaceDcmd { output.shouldMatch("MaxMetaspaceSize:.*210763776 bytes"); } - public static void main(String args[]) throws Exception { - if (System.getProperty("no-specified-flag") != null) { - doTheNoSpecifiedPropTest(); - } else if (System.getProperty("with-compressed-class-space") != null) { - doTheCCSPropTest(true); - } else if (System.getProperty("without-compressed-class-space") != null) { - doTheCCSPropTest(false); - } else { - throw new IllegalArgumentException("Unrecognized running mode"); - } - } } diff --git a/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTestCompiler.java b/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTestCompiler.java index ac9e41b3236..2dc6b7e56a5 100644 --- a/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTestCompiler.java +++ b/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTestCompiler.java @@ -25,7 +25,7 @@ * @test ReservedStackTestCompiler * @summary Run ReservedStackTest with dedicated compilers C1 and C2. * - * @requires vm.flavor == "server" & !vm.emulatedClient + * @requires vm.flavor == "server" * @requires vm.opt.DeoptimizeALot != true * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/Unsafe/AllocateMemory.java b/test/hotspot/jtreg/runtime/Unsafe/AllocateMemory.java index 7d8d33b1225..b18bcb8cc13 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/AllocateMemory.java +++ b/test/hotspot/jtreg/runtime/Unsafe/AllocateMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ public class AllocateMemory { // allocateMemory() should throw an OutOfMemoryError when the underlying malloc fails, // since we start with -XX:MallocLimit try { - address = unsafe.allocateMemory(100 * 1024 * 1024); + address = unsafe.allocateMemory(101 * 1024 * 1024); throw new RuntimeException("Did not get expected OutOfMemoryError"); } catch (OutOfMemoryError e) { // Expected diff --git a/test/hotspot/jtreg/runtime/Unsafe/Reallocate.java b/test/hotspot/jtreg/runtime/Unsafe/Reallocate.java index c15b931449d..dc0ce86fa1f 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/Reallocate.java +++ b/test/hotspot/jtreg/runtime/Unsafe/Reallocate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -62,7 +62,7 @@ public class Reallocate { // Make sure we can throw an OOME when we fail to reallocate due to OOM try { - unsafe.reallocateMemory(address, 100 * 1024 * 1024); + unsafe.reallocateMemory(address, 101 * 1024 * 1024); } catch (OutOfMemoryError e) { // Expected return; diff --git a/test/hotspot/jtreg/runtime/cds/DeterministicClasslist.java b/test/hotspot/jtreg/runtime/cds/DeterministicClasslist.java new file mode 100644 index 00000000000..00f12a500a4 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/DeterministicClasslist.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2026, 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 8378371 + * @summary The same JDK build should always generate the same classlist file (no randomness). + * @requires vm.cds & vm.flagless + * @library /test/lib ./appcds/ + * @run driver DeterministicClasslist + */ + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.compiler.InMemoryJavaCompiler; +import jdk.test.lib.helpers.ClassFileInstaller; + + +public class DeterministicClasslist { + + public static void compareClasslists(String base, String test) throws Exception { + File baseClasslistFile = new File(base); + File testClasslistFile = new File(test); + + BufferedReader baseReader = new BufferedReader(new FileReader(baseClasslistFile)); + BufferedReader testReader = new BufferedReader(new FileReader(testClasslistFile)); + + String baseLine, testLine; + while ((baseLine = baseReader.readLine()) != null) { + testLine = testReader.readLine(); + // Skip constant pool entries + if (baseLine.contains("@cp")) { + continue; + } + if (!baseLine.equals(testLine)) { + System.out.println(baseLine + " vs " + testLine); + throw new RuntimeException("Classlists differ"); + } + } + } + + static Path findFile(String path) { + Path root = Paths.get(System.getProperty("test.root", ".")); + // Move back to java root directory + root = root.getParent().getParent().getParent(); + + Path file = root.resolve(path); + if (Files.exists(file)) { + return file; + } + + return null; + } + + public static void main (String[] args) throws Exception { + String[] classlist = { "build/tools/classlist/HelloClasslist", "build/tools/classlist/HelloClasslist$1A", "build/tools/classlist/HelloClasslist$1B" }; + String appClass = classlist[0]; + String appJar; + String classDir = System.getProperty("test.classes"); + String baseClasslist = "base.classlist"; + String testClasslist = "test.classlist"; + + Path testPath = findFile("make/jdk/src/classes/build/tools/classlist/HelloClasslist.java"); + if (testPath == null) { + throw new RuntimeException("Could not find HelloClasslist"); + } + + String source = Files.readString(testPath); + Map compiledClasses = InMemoryJavaCompiler.compile(Map.of(appClass, source)); + + for (Entry e : compiledClasses.entrySet()) { + ClassFileInstaller.writeClassToDisk(e.getKey(), e.getValue(), classDir); + } + + JarBuilder.build("classlist", classlist); + appJar = TestCommon.getTestJar("classlist.jar"); + + CDSTestUtils.dumpClassList(baseClasslist, "-cp", appJar, "-Xint", appClass); + CDSTestUtils.dumpClassList(testClasslist, "-cp", appJar, "-Xint", appClass); + + compareClasslists(baseClasslist, testClasslist); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/DumpSymbolAndStringTable.java b/test/hotspot/jtreg/runtime/cds/DumpSymbolAndStringTable.java index 735d5a3070b..f606f242cf6 100644 --- a/test/hotspot/jtreg/runtime/cds/DumpSymbolAndStringTable.java +++ b/test/hotspot/jtreg/runtime/cds/DumpSymbolAndStringTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,70 +24,26 @@ /* * @test * @bug 8059510 8213445 - * @summary Test jcmd VM.symboltable, VM.stringtable and VM.systemdictionary options + * @summary Test jcmd VM.symboltable and VM.stringtable * @library /test/lib - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI DumpSymbolAndStringTable + * @run main/othervm DumpSymbolAndStringTable */ import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.dcmd.PidJcmdExecutor; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.whitebox.WhiteBox; public class DumpSymbolAndStringTable { - public static void main(String[] args) throws Exception { - WhiteBox wb = WhiteBox.getWhiteBox(); - boolean sharingEnabled = wb.isSharingEnabled(); + public static final String s = "MY_INTERNED_STRING"; + public static void main(String[] args) throws Exception { ProcessBuilder pb = new ProcessBuilder(); + pb.command(new PidJcmdExecutor().getCommandLine("VM.symboltable", "-verbose")); OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-symboltable"); - final String sharedSymbolsHeader = "Shared symbols:\n"; - try { - output.shouldContain("24 2: DumpSymbolAndStringTable\n"); - if (sharingEnabled) { - output.shouldContain(sharedSymbolsHeader); - output.shouldContain("17 65535: java.lang.runtime\n"); - } - } catch (RuntimeException e) { - output.shouldContain("Unknown diagnostic command"); - } + output.shouldContain("18 1: MY_INTERNED_STRING\n"); // This symbol should have been interned pb.command(new PidJcmdExecutor().getCommandLine("VM.stringtable", "-verbose")); output = CDSTestUtils.executeAndLog(pb, "jcmd-stringtable"); - final String sharedStringsHeader = "Shared strings:\n"; - try { - output.shouldContain("24: DumpSymbolAndStringTable\n"); - if (sharingEnabled && wb.canWriteJavaHeapArchive()) { - output.shouldContain(sharedStringsHeader); - if (!wb.isSharedInternedString("MILLI_OF_SECOND")) { - throw new RuntimeException("'MILLI_OF_SECOND' should be a shared string"); - } - } - } catch (RuntimeException e) { - output.shouldContain("Unknown diagnostic command"); - } - - pb.command(new PidJcmdExecutor().getCommandLine("VM.systemdictionary")); - output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary"); - try { - output.shouldContain("System Dictionary for 'app' class loader statistics:"); - output.shouldContain("Number of buckets"); - output.shouldContain("Number of entries"); - output.shouldContain("Maximum bucket size"); - } catch (RuntimeException e) { - output.shouldContain("Unknown diagnostic command"); - } - - pb.command(new PidJcmdExecutor().getCommandLine("VM.systemdictionary", "-verbose")); - output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary"); - try { - output.shouldContain("Dictionary for loader data: 0x"); - output.shouldContain("^java.lang.String"); - } catch (RuntimeException e) { - output.shouldContain("Unknown diagnostic command"); - } + output.shouldContain("18: MY_INTERNED_STRING\n"); // This string should have been interned } } diff --git a/test/hotspot/jtreg/runtime/cds/MetaspaceAllocGaps.java b/test/hotspot/jtreg/runtime/cds/MetaspaceAllocGaps.java new file mode 100644 index 00000000000..65459263e36 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/MetaspaceAllocGaps.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2026, 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 + * @requires vm.cds + * @requires vm.flagless + * @requires vm.bits == 64 + * @bug 8376822 + * @summary Allocation gaps in the RW region caused by -XX:+UseCompactObjectHeaders should be reused + * @library /test/lib + * @build MetaspaceAllocGaps + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar hello.jar Hello + * @run driver MetaspaceAllocGaps + */ + +import jdk.test.lib.cds.SimpleCDSAppTester; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.process.OutputAnalyzer; + +public class MetaspaceAllocGaps { + public static void main(String[] args) throws Exception { + String appJar = ClassFileInstaller.getJarPath("hello.jar"); + for (int i = 0; i < 2; i++) { + String compressedOops = "-XX:" + (i == 0 ? "-" : "+") + "UseCompressedOops"; + SimpleCDSAppTester.of("MetaspaceAllocGaps" + i) + .addVmArgs("-Xlog:aot=debug,aot+alloc=trace", + "-XX:+UseCompactObjectHeaders") + .classpath(appJar) + .appCommandLine("Hello") + .setTrainingChecker((OutputAnalyzer out) -> { + // Typically all gaps should be filled. If not, we probably have a regression in C++ class ArchiveUtils. + // + // [0.422s][debug][aot ] Detailed metadata info (excluding heap region): + // [...] + // [0.422s][debug][aot ] Gap : 0 0 0.0 | 0 0 0.0 | 0 0 0.0 <<< look for this pattern + out.shouldMatch("Allocated [1-9][0-9]+ objects of [1-9][0-9]+ bytes in gaps .remain = 0 bytes") + .shouldMatch("debug.* Gap .*0[.]0.*0[.]0.*0[.]0") + .shouldNotMatch("Unexpected .* gaps .* for Klass alignment"); + }) + .setProductionChecker((OutputAnalyzer out) -> { + out.shouldContain("HelloWorld"); + }) + .runAOTWorkflow(); + } + } +} + +class Hello { + public static void main(String[] args) { + System.out.println("HelloWorld"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/SharedStrings.java b/test/hotspot/jtreg/runtime/cds/SharedStrings.java deleted file mode 100644 index db0bc3264b2..00000000000 --- a/test/hotspot/jtreg/runtime/cds/SharedStrings.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015, 2025, 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 - * @summary Check to make sure that shared strings in the bootstrap CDS archive - * are actually shared - * @requires vm.cds.write.mapped.java.heap - * @requires vm.flagless - * @library /test/lib - * @build SharedStringsWb jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox - * @run driver SharedStrings - */ - -import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.helpers.ClassFileInstaller; - -public class SharedStrings { - public static void main(String[] args) throws Exception { - // Note: This is a basic sanity test for Shared Strings feature. - // This also serves as a reference on how to use this feature, - // hence the command lines are spelled out instead of using the - // test utils methods. - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./SharedStrings.jsa", - "-Xlog:cds,aot+hashtables", - // Needed for bootclasspath match, for CDS to work with WhiteBox API - "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), - "-Xshare:dump"); - - OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump"); - CDSTestUtils.checkDump(out, "Shared string table stats"); - - - pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./SharedStrings.jsa", - // needed for access to white box test API - "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), - "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-Xshare:on", "-showversion", "SharedStringsWb"); - - out = CDSTestUtils.executeAndLog(pb, "exec"); - CDSTestUtils.checkExec(out); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java b/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java index 4e40ae3645e..8241b0f9a2e 100644 --- a/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java +++ b/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,8 +61,8 @@ public class TestCDSVMCrash { CDSTestUtils.executeAndLog(pb, "cds_vm_crash"); throw new Error("Expected VM to crash"); } catch(RuntimeException e) { - if (!e.getMessage().equals("Hotspot crashed")) { - throw new Error("Expected message: Hotspot crashed"); + if (!e.getMessage().contains("A fatal error has been detected")) { + throw new Error("Expected message: A fatal error has been detected"); } } System.out.println("PASSED"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java index 6ab9b18c1e9..da994edeb27 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -55,7 +55,6 @@ public class CommandLineFlagCombo { private static final String[] testTable = { "-XX:+UseG1GC", "-XX:+UseSerialGC", "-XX:+UseParallelGC", "-XX:+UseLargePages", // may only take effect on machines with large-pages - "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", "-XX:ObjectAlignmentInBytes=16", "-XX:ObjectAlignmentInBytes=32", @@ -123,7 +122,6 @@ public class CommandLineFlagCombo { if (Platform.is32bit()) { if (testEntry.equals("-XX:+UseCompressedOops") || - testEntry.equals("-XX:+UseCompressedClassPointers") || testEntry.contains("ObjectAlignmentInBytes") ) { System.out.println("Test case not applicable on 32-bit platforms"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagComboNegative.java b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagComboNegative.java index 89fe868349b..d5aafb2bcf6 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagComboNegative.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagComboNegative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -66,9 +66,9 @@ public class CommandLineFlagComboNegative { "An error has occurred while processing the shared archive file", 1) ); } testTable.add( new TestVector("-XX:+UseCompressedOops", "-XX:-UseCompressedOops", - "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.", 1) ); - testTable.add( new TestVector("-XX:+UseCompressedClassPointers", "-XX:-UseCompressedClassPointers", - "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.", 1) ); + "The saved state of UseCompressedOops (1) is different from runtime (0), CDS will be disabled.", 1) ); + testTable.add( new TestVector("-XX:-UseCompressedOops", "-XX:+UseCompressedOops", + "The saved state of UseCompressedOops (0) is different from runtime (1), CDS will be disabled.", 1) ); } private void runTests() throws Exception diff --git a/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java b/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java deleted file mode 100644 index 8538155375c..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022, Tencent. 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 8286066 - * @summary VM crash caused by unloaded FillerObject_klass - * @library /test/lib - * @requires vm.cds - * @requires vm.flagless - * @run driver FillerObjectLoadTest - */ - -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; - -public class FillerObjectLoadTest { - public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseCompressedClassPointers", - "-XX:+UnlockExperimentalVMOptions", "-XX:+UseEpsilonGC", "-Xshare:dump", - "-XX:SharedArchiveFile=" + TestCommon.getNewArchiveName()); - OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); - analyzer.shouldHaveExitValue(0); - - pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseCompressedClassPointers", - "-XX:TLABSize=2048", "-Xshare:dump", - "-XX:SharedArchiveFile=" + TestCommon.getNewArchiveName()); - analyzer = new OutputAnalyzer(pb.start()); - analyzer.shouldHaveExitValue(0); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java index 4f3681d30df..f0700b14b55 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -46,12 +46,10 @@ public class TestCombinedCompressedFlags { static class ConfArg { public boolean useCompressedOops; // UseCompressedOops - public boolean useCompressedClassPointers; // UseCompressedClassPointers public String msg; public int code; - public ConfArg(boolean useCompressedOops, boolean useCompressedClassPointers, String msg, int code) { + public ConfArg(boolean useCompressedOops, String msg, int code) { this.useCompressedOops = useCompressedOops; - this.useCompressedClassPointers = useCompressedClassPointers; this.msg = msg; this.code = code; } @@ -65,67 +63,13 @@ public class TestCombinedCompressedFlags { initExecArgs(); } private void initExecArgs() { - /* The combinations have four cases. - * UseCompressedOops UseCompressedClassPointers Result - * 1. - * dump: on on - * test: on on Pass - * on off Fail - * off on Fail - * off off Fail - * 2. - * dump: on off - * test: on off Pass - * on on Fail - * off on Pass - * off off Fail - * 3. - * dump: off on - * test: off on Pass - * on on Fail - * on off Fail - * 4. - * dump: off off - * test: off off Pass - * on on Fail - * on off Fail - **/ + // We fail this test if the UseCompressedOops setting used at dumptime differs from runtime, + // succeed if it is identical execArgs = new ArrayList(); - if (dumpArg.useCompressedOops && dumpArg.useCompressedClassPointers) { - execArgs - .add(new ConfArg(true, true, HELLO_STRING, PASS)); - execArgs - .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(false, true, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(false, false, EXEC_ABNORMAL_MSG, FAIL)); - - } else if(dumpArg.useCompressedOops && !dumpArg.useCompressedClassPointers) { - execArgs - .add(new ConfArg(true, false, HELLO_STRING, PASS)); - execArgs - .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(false, true, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(false, false, EXEC_ABNORMAL_MSG, FAIL)); - - } else if (!dumpArg.useCompressedOops && dumpArg.useCompressedClassPointers) { - execArgs - .add(new ConfArg(false, true, HELLO_STRING, PASS)); - execArgs - .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL)); - } else if (!dumpArg.useCompressedOops && !dumpArg.useCompressedClassPointers) { - execArgs - .add(new ConfArg(false, false, HELLO_STRING, PASS)); - execArgs - .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL)); - execArgs - .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL)); - } + execArgs + .add(new ConfArg(dumpArg.useCompressedOops, HELLO_STRING, PASS)); + execArgs + .add(new ConfArg(!dumpArg.useCompressedOops, EXEC_ABNORMAL_MSG, FAIL)); } } @@ -134,23 +78,14 @@ public class TestCombinedCompressedFlags { else return "-XX:-UseCompressedOops"; } - public static String getCompressedClassPointersArg(boolean on) { - if (on) return "-XX:+UseCompressedClassPointers"; - else return "-XX:-UseCompressedClassPointers"; - } - public static List runList; public static void configureRunArgs() { runList = new ArrayList(); runList - .add(new RunArg(new ConfArg(true, true, null, PASS))); + .add(new RunArg(new ConfArg(true, null, PASS))); runList - .add(new RunArg(new ConfArg(true, false, null, PASS))); - runList - .add(new RunArg(new ConfArg(false, true, null, PASS))); - runList - .add(new RunArg(new ConfArg(false, false, null, PASS))); + .add(new RunArg(new ConfArg(false, null, PASS))); } public static void main(String[] args) throws Exception { @@ -162,7 +97,6 @@ public class TestCombinedCompressedFlags { .dump(helloJar, new String[] {"Hello"}, getCompressedOopsArg(t.dumpArg.useCompressedOops), - getCompressedClassPointersArg(t.dumpArg.useCompressedClassPointers), "-Xlog:cds", "-XX:NativeMemoryTracking=detail"); out.shouldContain("Dumping shared data to file:"); @@ -175,7 +109,6 @@ public class TestCombinedCompressedFlags { "-Xlog:cds", "-XX:NativeMemoryTracking=detail", getCompressedOopsArg(c.useCompressedOops), - getCompressedClassPointersArg(c.useCompressedClassPointers), "Hello"); out.shouldContain(c.msg); out.shouldHaveExitValue(c.code); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithAOTHeap.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithAOTHeap.java index 567c8da73cb..719a4ee83f7 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithAOTHeap.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithAOTHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +65,7 @@ public class TestZGCWithAOTHeap { String dumpGC = dumpWithZ ? Z : G1; String execGC = execWithZ ? Z : G1; String generalErrMsg = "Cannot use CDS heap data."; - String coopsErrMsg = generalErrMsg + " Selected GC not compatible -XX:-UseCompressedOops"; + String coopsErrMsg = "CDS heap data cannot be used by the selected GC. Please choose a different GC or rebuild AOT cache with -XX:+AOTStreamableObjects"; String coops = "-XX:-UseCompressedOops"; String coh = shouldUseCOH ? "-XX:+UseCompactObjectHeaders" : "-XX:-UseCompactObjectHeaders"; String stream = shouldStream ? "-XX:+AOTStreamableObjects" : "-XX:-AOTStreamableObjects"; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java index 7c0b5896a98..bff2bcc727d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* - * @test + * @test id=COH * @bug 8232069 * @requires vm.cds * @requires vm.bits == 64 @@ -31,7 +31,30 @@ * @requires vm.gc == null * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile test-classes/Hello.java - * @run driver TestZGCWithCDS + * @comment Only run if COH is unset or enabled. + * @requires vm.opt.UseCompactObjectHeaders != "false" + * @comment Driver sets compressed oops/class pointers, jtreg overrides will cause problems. + Only run the test if the flags are not set via the command line. + * @requires vm.opt.UseCompressedOops == null + * @run driver TestZGCWithCDS true + */ + +/* + * @test id=NO-COH + * @bug 8232069 + * @requires vm.cds + * @requires vm.bits == 64 + * @requires vm.gc.Z + * @requires vm.gc.Serial + * @requires vm.gc == null + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @compile test-classes/Hello.java + * @comment Only run if COH is unset or disabled. + * @requires vm.opt.UseCompactObjectHeaders != "true" + * @comment Driver sets compressed oops/class pointers, jtreg overrides will cause problems. + Only run the test if the flags are not set via the command line. + * @requires vm.opt.UseCompressedOops == null + * @run driver TestZGCWithCDS false */ import jdk.test.lib.Platform; @@ -40,9 +63,10 @@ import jdk.test.lib.process.OutputAnalyzer; public class TestZGCWithCDS { public final static String HELLO = "Hello World"; public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive."; - public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; + public final static String ERR_MSG = "The saved state of UseCompressedOops (0) is different from runtime (1), CDS will be disabled."; public static void main(String... args) throws Exception { - String compactHeaders = "-XX:+UseCompactObjectHeaders"; + boolean compactHeadersOn = Boolean.valueOf(args[0]); + String compactHeaders = "-XX:" + (compactHeadersOn ? "+" : "-") + "UseCompactObjectHeaders"; String helloJar = JarBuilder.build("hello", "Hello"); System.out.println("0. Dump with ZGC"); OutputAnalyzer out = TestCommon @@ -54,7 +78,7 @@ public class TestZGCWithCDS { out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); - System.out.println("1. Run with same args of dump"); + System.out.println("Run with same args of dump"); out = TestCommon .exec(helloJar, "-XX:+UseZGC", @@ -64,12 +88,11 @@ public class TestZGCWithCDS { out.shouldContain(HELLO); out.shouldHaveExitValue(0); - System.out.println("2. Run with +UseCompressedOops +UseCompressedClassPointers"); + System.out.println("Run with ZGC, +UseCompressedOops"); out = TestCommon .exec(helloJar, "-XX:-UseZGC", "-XX:+UseCompressedOops", // in case turned off by vmoptions - "-XX:+UseCompressedClassPointers", // by jtreg compactHeaders, "-Xlog:cds", "Hello"); @@ -77,37 +100,22 @@ public class TestZGCWithCDS { out.shouldContain(ERR_MSG); out.shouldHaveExitValue(1); - System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers"); + System.out.println("Run with SerialGC, -UseCompressedOops"); out = TestCommon .exec(helloJar, "-XX:+UseSerialGC", "-XX:-UseCompressedOops", - "-XX:-UseCompressedClassPointers", - compactHeaders, - "-Xlog:cds", - "Hello"); - out.shouldContain(UNABLE_TO_USE_ARCHIVE); - out.shouldContain(ERR_MSG); - out.shouldHaveExitValue(1); - - System.out.println("4. Run with -UseCompressedOops +UseCompressedClassPointers"); - out = TestCommon - .exec(helloJar, - "-XX:+UseSerialGC", - "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", compactHeaders, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); out.shouldHaveExitValue(0); - System.out.println("5. Run with +UseCompressedOops -UseCompressedClassPointers"); + System.out.println("Run with SerialGC, +UseCompressedOops"); out = TestCommon .exec(helloJar, "-XX:+UseSerialGC", "-XX:+UseCompressedOops", - "-XX:-UseCompressedClassPointers", compactHeaders, "-Xlog:cds", "Hello"); @@ -115,39 +123,5 @@ public class TestZGCWithCDS { out.shouldContain(ERR_MSG); out.shouldHaveExitValue(1); - System.out.println("6. Run with +UseCompressedOops +UseCompressedClassPointers"); - out = TestCommon - .exec(helloJar, - "-XX:+UseSerialGC", - "-XX:+UseCompressedOops", - "-XX:+UseCompressedClassPointers", - compactHeaders, - "-Xlog:cds", - "Hello"); - out.shouldContain(UNABLE_TO_USE_ARCHIVE); - out.shouldContain(ERR_MSG); - out.shouldHaveExitValue(1); - - System.out.println("7. Dump with -UseCompressedOops -UseCompressedClassPointers"); - out = TestCommon - .dump(helloJar, - new String[] {"Hello"}, - "-XX:+UseSerialGC", - "-XX:-UseCompressedOops", - "-XX:+UseCompressedClassPointers", - compactHeaders, - "-Xlog:cds"); - out.shouldContain("Dumping shared data to file:"); - out.shouldHaveExitValue(0); - - System.out.println("8. Run with ZGC"); - out = TestCommon - .exec(helloJar, - "-XX:+UseZGC", - compactHeaders, - "-Xlog:cds", - "Hello"); - out.shouldContain(HELLO); - out.shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java index 9461957ef2c..1a8313a3058 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,10 +76,12 @@ public class AOTCacheSupportForCustomLoaders { } class AppWithCustomLoaders { + static MyLoader loader; // keep alive so its classes can be cached. + public static void main(String args[]) throws Exception { File custJar = new File("cust.jar"); URL[] urls = new URL[] {custJar.toURI().toURL()}; - MyLoader loader = new MyLoader(urls, AppWithCustomLoaders.class.getClassLoader()); + loader = new MyLoader(urls, AppWithCustomLoaders.class.getClassLoader()); test1(loader); test2(loader); @@ -107,6 +109,7 @@ class AppWithCustomLoaders { } // Test 3: custom loader defines a class from the exact location as a class defined in the boot layer. + static Class test3_c1_keepalive; static void test3(String modulePath) throws Exception { Class c0 = Class.forName("com.test.Foo"); System.out.println(c0); @@ -130,6 +133,9 @@ class AppWithCustomLoaders { System.out.println(c1.getModule().getName()); System.out.println(c1.getClassLoader()); + // Keep c1 alive so it can be cached. + test3_c1_keepalive = c1; + if (!c1.getModule().getName().equals("com.test")) { throw new RuntimeException("Unexpected module: " + c1.getModule()); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ChangedJarFile.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ChangedJarFile.java new file mode 100644 index 00000000000..e86defdf816 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ChangedJarFile.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2026, 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 + * @summary AOT cache should be rejected if JAR file(s) in the classpath have changed + * @bug 8377932 + * @requires vm.cds.supports.aot.class.linking + * @library /test/lib + * @build ChangedJarFile + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar MyTestApp OtherClass + * @run driver ChangedJarFile AOT + */ + +import jdk.jfr.Event; +import jdk.test.lib.cds.CDSAppTester; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.process.OutputAnalyzer; + +public class ChangedJarFile { + static final String appJar = ClassFileInstaller.getJarPath("app.jar"); + static final String mainClass = MyTestApp.class.getName(); + + public static void main(String[] args) throws Exception { + // Train and run with unchanged JAR file (which has OtherClass.class) + Tester tester = new Tester(); + tester.run(args); + + // Run again with changed JAR file (which doesn't have OtherClass.class anymore) + ClassFileInstaller.writeJar(appJar, "MyTestApp"); + + // First disable AOT cache to verify test login + tester.productionRun(new String[] {"-XX:AOTMode=off"}, + new String[] {"jarHasChanged"}); + + // Now see if the AOT cache will be automatically disabled + OutputAnalyzer out = + tester.productionRun(new String[] {"-XX:AOTMode=auto", "-Xlog:aot"}, + new String[] {"jarHasChanged"}); + out.shouldMatch("This file is not the one used while building the " + + "AOT cache: '.*app.jar',.* size has changed"); + } + + static class Tester extends CDSAppTester { + public Tester() { + super(mainClass); + } + + @Override + public String classpath(RunMode runMode) { + return appJar; + } + + @Override + public String[] appCommandLine(RunMode runMode) { + return new String[] { mainClass }; + } + + @Override + public void checkExecution(OutputAnalyzer out, RunMode runMode) { + + } + } + + +} + +class MyTestApp { + public static void main(String args[]) { + boolean jarHasChanged = (args.length != 0); + + System.out.println("JAR has changed = " + (jarHasChanged)); + Class c = null; + try { + c = Class.forName("OtherClass"); + System.out.println("Other class = " + c); + } catch (Throwable t) { + if (!jarHasChanged) { + throw new RuntimeException("OtherClass should have been loaded because JAR has not been changed yet", t); + } + } + + if (jarHasChanged && c != null) { + throw new RuntimeException("OtherClass should not be in JAR file"); + } + } +} + +class OtherClass {} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/EarlyClassInit.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/EarlyClassInit.java new file mode 100644 index 00000000000..f78c3f83861 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/EarlyClassInit.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2026, 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 + * @summary Early init of classes in the AOT cache + * @bug 8378731 + * @requires vm.cds.supports.aot.class.linking + * @library /test/lib + * @build EarlyClassInit + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar EarlyClassInitApp + * @run driver EarlyClassInit + */ + +import jdk.test.lib.cds.SimpleCDSAppTester; +import jdk.test.lib.process.OutputAnalyzer; + +public class EarlyClassInit { + public static void main(String... args) throws Exception { + SimpleCDSAppTester.of("EarlyClassInit") + .addVmArgs("-Xlog:aot+init=debug") + .classpath("app.jar") + .appCommandLine("EarlyClassInitApp") + .setProductionChecker((OutputAnalyzer out) -> { + out.shouldContain("java.lang.Object (aot-inited, early)") + .shouldContain("No early init java.lang.ClassLoader: needs runtimeSetup()") + .shouldContain("No early init java.security.SecureClassLoader: super type java.lang.ClassLoader not initialized") + .shouldContain("Calling java.lang.ClassLoader::runtimeSetup()") + .shouldContain("java.security.SecureClassLoader (aot-inited)"); + out.shouldContain("HelloWorld"); + }) + .runAOTWorkflow(); + } +} + +class EarlyClassInitApp { + public static void main(String[] args) { + System.out.println("HelloWorld"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ExcludedClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ExcludedClasses.java index 9a9524eb2f1..728428afef2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ExcludedClasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/ExcludedClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,6 +32,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar * TestApp * TestApp$Foo + * TestApp$Foo$A * TestApp$Foo$Bar * TestApp$Foo$ShouldBeExcluded * TestApp$Foo$ShouldBeExcludedChild @@ -43,6 +44,8 @@ */ import java.io.File; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -165,6 +168,8 @@ class TestApp { long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < 1000) { lambdaHotSpot(); + lambdaHotSpot2(); + invokeHandleHotSpot(); s.hotSpot2(); b.hotSpot3(); Taz.hotSpot4(); @@ -207,12 +212,52 @@ class TestApp { } } + interface A { + Object get(); + } + + // Lambdas that refer to excluded classes should not be AOT-resolved + static void lambdaHotSpot2() { + long start = System.currentTimeMillis(); + A a = ShouldBeExcluded::new; + while (System.currentTimeMillis() - start < 20) { + Object obj = (ShouldBeExcluded)a.get(); + } + } + + static void invokeHandleHotSpot() { + try { + invokeHandleHotSpotImpl(); + } catch (Throwable t) { + throw new RuntimeException("Unexpected", t); + } + } + + static void invokeHandleHotSpotImpl() throws Throwable { + MethodHandle constructorHandle = + MethodHandles.lookup().unreflectConstructor(ShouldBeExcluded.class.getConstructor()); + long start = System.currentTimeMillis(); + while (System.currentTimeMillis() - start < 20) { + // The JVM rewrites this to: + // invokehandle + // + // The AOT cache must not contain a java.lang.invoke.MethodType that refers to the + // ShouldBeExcluded class. + ShouldBeExcluded o = (ShouldBeExcluded)constructorHandle.invoke(); + if (o.getClass() != ShouldBeExcluded.class) { + throw new RuntimeException("Unexpected object: " + o); + } + } + } + static void doit(Runnable r) { r.run(); } // All subclasses of jdk.jfr.Event are excluded from the CDS archive. static class ShouldBeExcluded extends jdk.jfr.Event { + public ShouldBeExcluded() {} + int f = (int)(System.currentTimeMillis()) + 123; int m() { return f + 456; @@ -275,4 +320,3 @@ class TestApp { } } } - diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/OldClassSupport2.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/OldClassSupport2.java index 16a4d258e4f..b0db450e352 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/OldClassSupport2.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/OldClassSupport2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -53,11 +53,6 @@ public class OldClassSupport2 { // This will disable AOT class linking. Tester tester2 = new Tester("-Djdk.module.showModuleResolution=true"); tester2.run(new String[] {"AOT", "--two-step-training"} ); - - // Heap archiving is disable with -XX:-UseCompressedClassPointers. - // This will disable AOT class linking. - Tester tester3 = new Tester("-XX:-UseCompressedClassPointers"); - tester3.run(new String[] {"AOT", "--two-step-training"} ); } static class Tester extends CDSAppTester { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/RedefineCriticalClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/RedefineCriticalClasses.java new file mode 100644 index 00000000000..c4753ee3878 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/RedefineCriticalClasses.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2026, 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 + * @summary AOT training run should fail if critical classes have been redefined by JVMTI + * @bug 8380409 + * @requires vm.cds.supports.aot.class.linking + * @library /test/lib + * @run driver RedefineClassHelper + * @build RedefineCriticalClasses + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar RedefineCriticalClassesApp + * @run driver RedefineCriticalClasses + */ + +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.process.ProcessTools; + +public class RedefineCriticalClasses { + public static void main(String... args) throws Exception { + ArrayList processArgs = new ArrayList<>(); + + // redefineagent.jar is created by "@run driver RedefineClassHelper" + processArgs.add("-javaagent:redefineagent.jar"); + + processArgs.add("-XX:AOTMode=record"); + processArgs.add("-XX:AOTConfiguration=app.aotconfig"); + processArgs.add("-Xlog:aot,cds"); + processArgs.add("-cp"); + processArgs.add("app.jar"); + processArgs.add("RedefineCriticalClassesApp"); + + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(processArgs); + CDSTestUtils.executeAndLog(pb, "train") + .shouldContain("Redefined: class java.lang.Class") + .shouldContain("Skipping java/lang/Class: Has been redefined") + .shouldContain("Critical class java.lang.Class has been excluded. AOT configuration file cannot be written") + .shouldHaveExitValue(1); + } +} + +class RedefineCriticalClassesApp { + public static void main(String[] args) throws Exception { + // Use RedefineClassHelper (loaded from redefineagent.jar into the boot class loader) + // to redefine java/lang/Class, using the exact same bytecodes as from the JDK. + // The JVM will mark it as having been redefined by JVMTI and will exclude it from the + // AOT configuration file. + + URL url = new URL("jrt:/java.base/java/lang/Class.class"); + try (InputStream in = url.openConnection().getInputStream()) { + byte[] b = in.readAllBytes(); + System.out.println("Length = " + b.length); + RedefineClassHelper.redefineClass(Class.class, b); + System.out.println("Redefined: " + Class.class); + } + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/TransformCriticalClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/TransformCriticalClasses.java new file mode 100644 index 00000000000..9f25d58e01f --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/TransformCriticalClasses.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2026, 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 + * @summary AOT training run should fail if critical classes have been transformed by JVMTI + * with ClassFileLoadHook + * @bug 8380409 + * @requires vm.cds.supports.aot.class.linking + * @library /test/lib + * @build TransformCriticalClasses + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar TransformCriticalClassesApp + * @run main/othervm/native TransformCriticalClasses + */ + +import java.util.ArrayList; +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.process.ProcessTools; + +public class TransformCriticalClasses { + public static void main(String... args) throws Exception { + ArrayList processArgs = new ArrayList<>(); + + // Tell the native agent SimpleClassFileLoadHook to do an dummy transformation + // of java/lang/Class. This class will be defined using the exact same bytecodes + // as from the JDK, but the JVM will mark it as having been transformed by JVMTI + // and will exclude it from the AOT configuration file. + processArgs.add("-agentlib:SimpleClassFileLoadHook=-early,java/lang/Class,xxxxxx,xxxxxx"); + + processArgs.add("-XX:AOTMode=record"); + processArgs.add("-XX:AOTConfiguration=app.aotconfig"); + processArgs.add("-Xlog:aot,cds"); + processArgs.add("-cp"); + processArgs.add("app.jar"); + processArgs.add("TransformCriticalClassesApp"); + + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(processArgs); + CDSTestUtils.executeAndLog(pb, "train") + .shouldContain("Skipping java/lang/Class: From ClassFileLoadHook") + .shouldContain("Critical class java.lang.Class has been excluded. AOT configuration file cannot be written") + .shouldHaveExitValue(1); + } +} + +class TransformCriticalClassesApp { + public static void main(String[] args) { + System.out.println("HelloWorld"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddOpens.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddOpens.java index d3626d30c7e..f7e15f8fae0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddOpens.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddOpens.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -157,7 +157,7 @@ public class AddOpens { out.shouldContain(expectedOutput[0]); out.shouldContain(expectedOutput[1]); } else if (runMode == RunMode.ASSEMBLY) { - out.shouldContain("full module graph: enabled"); + out.shouldMatch("(full module graph: enabled)|(Full module graph = enabled)"); } } } @@ -200,7 +200,7 @@ public class AddOpens { out.shouldContain(expectedOutput[0]); out.shouldContain(expectedOutput[1]); } else if (runMode == RunMode.ASSEMBLY) { - out.shouldContain("full module graph: enabled"); + out.shouldMatch("(full module graph: enabled)|(Full module graph = enabled)"); } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddReads.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddReads.java index 5c9364aa079..95fc9f0f700 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddReads.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AddReads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +65,6 @@ public class AddReads { "[class,load] com.norequires.Main source: shared objects file"; private static final String sharedClassB = "[class,load] org.astro.World source: shared objects file"; - private static final String fmgEnabled = "full module graph: enabled"; - private static final String fmgDisabled = "full module graph: disabled"; private static final String cannotAccess = "class com.norequires.Main (in module com.norequires) cannot access class org.astro.World (in module org.astro)"; @@ -166,8 +164,8 @@ public class AddReads { out.shouldContain("full module graph: disabled"); out.shouldContain("Mismatched values for property jdk.module.addreads: runtime com.norequires=ALL-UNNAMED dump time com.norequires=org.astro"); } else if (runMode == RunMode.ASSEMBLY) { - out.shouldContain("full module graph: enabled"); - } else { + out.shouldMatch("(full module graph: enabled)|(Full module graph = enabled)"); + } else { out.shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCPUFeatureIncompatibilityTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCPUFeatureIncompatibilityTest.java new file mode 100644 index 00000000000..e9e610330ad --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCPUFeatureIncompatibilityTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2026, 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 + * @summary CPU feature compatibility test for AOT Code Cache + * @requires vm.cds.supports.aot.code.caching + * @requires vm.compMode != "Xcomp" & vm.compMode != "Xint" + * @requires os.simpleArch == "x64" | os.simpleArch == "aarch64" + * @comment The test verifies AOT checks during VM startup and not code generation. + * No need to run it with -Xcomp. + * @library /test/lib /test/setup_aot + * @build AOTCodeCPUFeatureIncompatibilityTest JavacBenchApp + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar + * JavacBenchApp + * JavacBenchApp$ClassFile + * JavacBenchApp$FileManager + * JavacBenchApp$SourceFile + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AOTCodeCPUFeatureIncompatibilityTest + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Platform; +import jdk.test.lib.cds.CDSAppTester; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +import jdk.test.whitebox.WhiteBox; +import jdk.test.whitebox.cpuinfo.CPUInfo; + +public class AOTCodeCPUFeatureIncompatibilityTest { + public static void main(String... args) throws Exception { + List cpuFeatures = CPUInfo.getFeatures(); + if (Platform.isX64()) { + // Minimum value of UseSSE required by JVM is 2. So the production run has to be executed with UseSSE=2. + // To simulate the case of incmpatible SSE feature, we can run this test only on system with higher SSE level (sse3 or above). + if (isSSE3Supported(cpuFeatures)) { + testIncompatibleFeature("-XX:UseSSE=2", "sse3"); + } + if (isAVXSupported(cpuFeatures)) { + testIncompatibleFeature("-XX:UseAVX=0", "avx"); + } + } + } + + // vmOption = command line option to disable CPU feature + // featureName = name of the CPU feature used by the JVM in the log messages + public static void testIncompatibleFeature(String vmOption, String featureName) throws Exception { + new CDSAppTester("AOTCodeCPUFeatureIncompatibilityTest") { + @Override + public String[] vmArgs(RunMode runMode) { + if (runMode == RunMode.PRODUCTION) { + return new String[] {vmOption, "-Xlog:aot+codecache*=debug"}; + } else { + return new String[] {"-Xlog:aot+codecache*=debug"}; + } + } + @Override + public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception { + if (runMode == RunMode.ASSEMBLY || runMode == RunMode.PRODUCTION) { + out.shouldMatch("CPU features recorded in AOTCodeCache:.*" + featureName + ".*"); + } + + if (runMode == RunMode.PRODUCTION) { + out.shouldMatch("AOT Code Cache disabled: required cpu features are missing:.*" + featureName + ".*"); + out.shouldContain("Unable to use AOT Code Cache"); + } + } + @Override + public String classpath(RunMode runMode) { + return "app.jar"; + } + @Override + public String[] appCommandLine(RunMode runMode) { + return new String[] { + "JavacBenchApp", "10" + }; + } + }.runAOTWorkflow("--two-step-training"); + } + + // Only used on x86-64 platform + static boolean isSSE3Supported(List cpuFeatures) { + return cpuFeatures.contains("sse3"); + } + + // Only used on x86-64 platform + static boolean isAVXSupported(List cpuFeatures) { + return cpuFeatures.contains("avx"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java index aeeac7ee0a4..fbf84a2a42d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -84,7 +84,7 @@ public class DifferentHeapSizes { } else { result .assertAbnormalExit("Unable to use shared archive.", - "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."); + "The saved state of UseCompressedOops (1) is different from runtime (0), CDS will be disabled."); } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsApp.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsApp.java deleted file mode 100644 index 9e4558002cc..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsApp.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018, 2023, 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.io.File; -import java.net.URL; -import jdk.test.whitebox.WhiteBox; - -// -// - Test static final String field with initial value in cached mirror should be also archived. -// - GC should not crash when reference fields in cached mirror are updated at runtime -// - Reference fields are updated to point to runtime created objects -// - Reference fields are nullified -// -public class MirrorWithReferenceFieldsApp { - - // Static String field with initial value - static final String archived_field = "abc"; - - // Static object field - static Object non_archived_field_1; - - // Instance field - Integer non_archived_field_2; - - public MirrorWithReferenceFieldsApp() { - non_archived_field_1 = new Object(); - non_archived_field_2 = Integer.valueOf(1); - } - - public static void main(String args[]) throws Exception { - WhiteBox wb = WhiteBox.getWhiteBox(); - - if (!wb.areOpenArchiveHeapObjectsMapped()) { - System.out.println("Archived open_archive_heap objects are not mapped."); - System.out.println("This may happen during normal operation. Test Skipped."); - return; - } - - MirrorWithReferenceFieldsApp m = new MirrorWithReferenceFieldsApp(); - m.test(wb); - } - - public void test(WhiteBox wb) { - Class c = MirrorWithReferenceFieldsApp.class; - if (wb.isSharedClass(c)) { - if (wb.isSharedInternedString(archived_field)) { - System.out.println("archived_field is archived as excepted"); - } else { - throw new RuntimeException( - "FAILED. archived_field is not archived."); - } - - // GC should not crash - System.gc(); - System.gc(); - System.gc(); - - non_archived_field_1 = null; - non_archived_field_2 = null; - - System.gc(); - System.gc(); - System.gc(); - - System.out.println("Done."); - } - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java deleted file mode 100644 index 4c670ccba9b..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018, 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. - * - * 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 - * @summary Test archived mirror with reference fields - * @requires vm.cds.write.archived.java.heap - * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds - * @build jdk.test.whitebox.WhiteBox - * @compile MirrorWithReferenceFieldsApp.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar MirrorWithReferenceFieldsApp - * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar WhiteBox.jar jdk.test.whitebox.WhiteBox - * @run driver MirrorWithReferenceFieldsTest - */ - -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.helpers.ClassFileInstaller; -import jdk.test.whitebox.WhiteBox; - -public class MirrorWithReferenceFieldsTest { - public static void main(String[] args) throws Exception { - String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); - String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; - String appJar = ClassFileInstaller.getJarPath("app.jar"); - - String classlist[] = new String[] { - "MirrorWithReferenceFieldsApp", - }; - - TestCommon.testDump(appJar, classlist, use_whitebox_jar); - OutputAnalyzer output = TestCommon.exec(appJar, use_whitebox_jar, - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:+VerifyAfterGC", - "MirrorWithReferenceFieldsApp"); - try { - TestCommon.checkExec(output, "Done"); - } catch (Exception e) { - output.shouldContain("Archived open_archive_heap objects are not mapped"); - } - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassApp.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassApp.java index e247a8158f7..0bac9f4e77d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassApp.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -55,11 +55,6 @@ public class RedefineClassApp { static Instrumentation instrumentation; public static void main(String args[]) throws Throwable { - if (!wb.areSharedStringsMapped()) { - System.out.println("Shared strings are ignored."); - return; - } - File bootJar = new File(args[0]); File appJar = new File(args[1]); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/CDSStreamTestDriver.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/CDSStreamTestDriver.java index 88af964d836..8d66ff3336f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/CDSStreamTestDriver.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/CDSStreamTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public class CDSStreamTestDriver extends DynamicArchiveTestBase { } catch (SkippedException s) { if (GC.Z.isSelected() && s.toString().equals(skippedException)) { System.out.println("Got " + s.toString() + " as expected."); - System.out.println("Because the test was run with ZGC with UseCompressedOops and UseCompressedClassPointers disabled,"); + System.out.println("Because the test was run with ZGC with UseCompressedOops disabled,"); System.out.println("but the base archive was created with the options enabled"); } else { throw new RuntimeException("Archive mapping should always succeed after JDK-8231610 (did the machine run out of memory?)"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java index 108002246db..8ee3b405604 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -306,9 +306,8 @@ class DynamicArchiveTestBase { * the JDK was built via cross-compilation on a different platform; * - the VM under test was started with a different options than the ones * when the default CDS archive was built. E.g. the VM was started with - * -XX:+UseZGC which implicitly disabled the UseCompressedOoops and the - * UseCompressedClassPointers options. Those "compressed" options were - * enabled when the default CDS archive was built. + * -XX:+UseZGC which implicitly disables the UseCompressedOops option. + * UseCompressedOops was enabled when the default CDS archive was built. */ public static boolean isUseSharedSpacesDisabled() { return !WB.isSharingEnabled(); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java index 10e17f2072f..cf9ffb2403a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 class AddmodsOption { final String allModulePath = "ALL-MODULE-PATH"; final String loggingOption = "-Xlog:aot=debug,aot+module=debug,aot+heap=info,cds=debug,module=trace"; final String versionPattern = "java.[0-9][0-9].*"; - final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector"; String archiveName = TestCommon.getNewArchiveName("addmods-option"); TestCommon.setCurrentArchiveName(archiveName); @@ -81,16 +80,14 @@ public class AddmodsOption { "-version"); oa.shouldHaveExitValue(0) .shouldContain("Mismatched values for property jdk.module.addmods") - .shouldContain("runtime jdk.incubator.vector dump time jdk.jconsole") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("runtime jdk.incubator.vector dump time jdk.jconsole"); // no module specified during runtime oa = TestCommon.execCommon( loggingOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("jdk.httpserver specified during dump time but not during runtime") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("jdk.httpserver specified during dump time but not during runtime"); // dump an archive without the --add-modules option archiveName = TestCommon.getNewArchiveName("no-addmods-option"); @@ -111,8 +108,7 @@ public class AddmodsOption { oa.shouldHaveExitValue(0) .shouldContain("jdk.jconsole specified during runtime but not during dump time") // version of the jdk.httpserver module, e.g. java 22-ea - .shouldMatch(versionPattern) - .shouldContain(subgraphCannotBeUsed); + .shouldMatch(versionPattern); // dump an archive with an incubator module, -add-modules jdk.incubator.vector archiveName = TestCommon.getNewArchiveName("incubator-module"); @@ -137,7 +133,6 @@ public class AddmodsOption { // module is not restored from archive .shouldContain("define_module(): creation of module: jdk.incubator.vector") .shouldContain("WARNING: Using incubator modules: jdk.incubator.vector") - .shouldContain("subgraph jdk.internal.module.ArchivedBootLayer is not recorde") .shouldHaveExitValue(0); if (Compiler.isJVMCIEnabled()) { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java index 636169ef3cb..6f1864f90bd 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 @@ public class AddopensOption { final String addOpensTimeFormat = "java.base/java.time.format=ALL-UNNAMED"; final String loggingOption = "-Xlog:aot=debug,aot+module=debug,aot+heap=info,cds=debug,module=trace"; final String versionPattern = "java.[0-9][0-9].*"; - final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector"; String archiveName = TestCommon.getNewArchiveName("addopens-option"); TestCommon.setCurrentArchiveName(archiveName); @@ -76,16 +75,14 @@ public class AddopensOption { "-version"); oa.shouldHaveExitValue(0) .shouldContain("Mismatched values for property jdk.module.addopens") - .shouldContain("runtime java.base/java.nio=ALL-UNNAMED dump time java.base/java.time.format=ALL-UNNAMED") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("runtime java.base/java.nio=ALL-UNNAMED dump time java.base/java.time.format=ALL-UNNAMED"); // no module specified during runtime oa = TestCommon.execCommon( loggingOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("jdk.httpserver specified during dump time but not during runtime") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("jdk.httpserver specified during dump time but not during runtime"); // dump an archive without the --add-opens option archiveName = TestCommon.getNewArchiveName("no-addopens-option"); @@ -106,8 +103,7 @@ public class AddopensOption { oa.shouldHaveExitValue(0) .shouldContain("java.base/java.time.format=ALL-UNNAMED specified during runtime but not during dump time") // version of the jdk.httpserver module, e.g. java 22-ea - .shouldMatch(versionPattern) - .shouldContain(subgraphCannotBeUsed); + .shouldMatch(versionPattern); // dump an archive with -add-opens java.base/java.nio=ALL-UNNAMED archiveName = TestCommon.getNewArchiveName("addopens-java-nio"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java index 3001b8dd2ca..6339538bbb2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +42,6 @@ public class ModuleOption { // e.g. JDK 22: "java 22" // JDK 22.0.1: "java 22.0.1" final String versionPattern = "java.[0-9][0-9].*"; - final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; String archiveName = TestCommon.getNewArchiveName("module-option"); TestCommon.setCurrentArchiveName(archiveName); @@ -70,16 +69,14 @@ public class ModuleOption { "-m", "jdk.compiler/com.sun.tools.javac.Main", "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Mismatched values for property jdk.module.main: runtime jdk.compiler dump time jdk.httpserver") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("Mismatched values for property jdk.module.main: runtime jdk.compiler dump time jdk.httpserver"); // no module specified during runtime oa = TestCommon.execCommon( loggingOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during dump time but not during runtime") - .shouldContain(subgraphCannotBeUsed); + .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during dump time but not during runtime"); // dump an archive without the module option archiveName = TestCommon.getNewArchiveName("no-module-option"); @@ -98,8 +95,7 @@ public class ModuleOption { oa.shouldHaveExitValue(0) .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during runtime but not during dump time") // version of the jdk.httpserver module, e.g. java 22-ea - .shouldMatch(versionPattern) - .shouldContain(subgraphCannotBeUsed); + .shouldMatch(versionPattern); // dump an archive with an incubator module, -m jdk.incubator.vector archiveName = TestCommon.getNewArchiveName("incubator-module"); @@ -122,7 +118,6 @@ public class ModuleOption { // module is not restored from archive .shouldContain("define_module(): creation of module: jdk.incubator.vector") .shouldContain("WARNING: Using incubator modules: jdk.incubator.vector") - .shouldContain("subgraph jdk.internal.module.ArchivedBootLayer is not recorde") .shouldContain("module jdk.incubator.vector does not have a ModuleMainClass attribute, use -m /") .shouldHaveExitValue(1); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java index 4586b94b519..1089e849a90 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java @@ -64,6 +64,7 @@ public class AOTLinkedVarHandles { OutputAnalyzer dumpOut = CDSTestUtils.createArchiveAndCheck(opts); dumpOut.shouldMatch(s + "java/lang/invoke/VarHandle.compareAndExchangeAcquire:\\(\\[DIDI\\)D =>"); dumpOut.shouldMatch(s + "java/lang/invoke/VarHandle.get:\\(\\[DI\\)D => "); + dumpOut.shouldNotContain("rejected .* CP entry.*"); CDSOptions runOpts = (new CDSOptions()) .setUseVersion(false) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringGC.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringGC.java deleted file mode 100644 index 0f8dbf7e753..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringGC.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2015, 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. - * - * 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.whitebox.WhiteBox; - -public class HelloStringGC { - public static String[] array01 = new String[1000]; - public static String[] array02 = new String[1000]; - - public static void main(String args[]) throws RuntimeException { - String testString1 = "shared_test_string_unique_14325"; - String testString2 = "test123"; - - WhiteBox wb = WhiteBox.getWhiteBox(); - if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(testString1)) { - throw new RuntimeException("testString1 is not shared"); - } - - for (int i=0; i<5; i++) { - allocSomeStrings(testString1, testString2); - array01 = null; - array02 = null; - System.gc(); - sleep(300); - array01 = new String[1000]; - array02 = new String[1000]; - } - - wb.fullGC(); - - System.out.println("HelloStringGC: PASS"); - } - - private static void allocSomeStrings(String s1, String s2) { - for (int i = 0; i < 1000; i ++) { - array01[i] = new String(s1); - array02[i] = new String(s2); - } - } - - private static void sleep(int ms) { - try { - Thread.sleep(ms); - } catch (InterruptedException e) { - } - } - -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringPlus.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringPlus.java deleted file mode 100644 index da111ced43a..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/HelloStringPlus.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2015, 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. - * - * 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. - * - */ - -// A test class to be launched in AppCDS mode, has basic+ -// coverage of string operations - -import jdk.test.whitebox.WhiteBox; - -public class HelloStringPlus { - public static void main(String args[]) { - // Let's reference the string that is in archive - String testString1 = "shared_test_string_unique_14325"; - System.out.println("Hello String: " + testString1); - - WhiteBox wb = WhiteBox.getWhiteBox(); - if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(testString1)) { - throw new RuntimeException("testString1 is not shared"); - } - - // Check other basic string operations - // Interning and equality - String[] testArray = new String[] {"shared_", "test_", "string_", "intern_", "12345"}; - String toBeInterned = ""; - - StringBuilder sb = new StringBuilder(); - for (String s : testArray) { - sb.append(s); - } - toBeInterned = sb.toString(); - - System.out.println("About to intern a string: " + toBeInterned); - toBeInterned.intern(); - - // check equality - if (testString1.equals(toBeInterned)) - throw new RuntimeException("Equality test 1 failed"); - - if (!testString1.equals("shared_test_string" + '_' + "unique_14325")) - throw new RuntimeException("Equality test 2 failed"); - - // Chech the hash code functionality; no special assertions, just make sure - // no crashe or exception occurs - System.out.println("testString1.hashCode() = " + testString1.hashCode()); - - // Check intern() method for "" string - String empty = ""; - String empty_interned = empty.intern(); - if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(empty)) { - throw new RuntimeException("Empty string should be shared"); - } - if (empty_interned != empty) { - throw new RuntimeException("Different string is returned from intern() for empty string"); - } - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java index ddbfe2ed862..f2ec33cdefe 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,9 @@ public class IncompatibleOptions { static final String COMPACT_STRING_MISMATCH = "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting"; static final String COMPRESSED_OOPS_NOT_CONSISTENT = - "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; + "The saved state of UseCompressedOops \\(%d\\) is different from runtime \\(%d\\), CDS will be disabled."; + static final String COMPRESSED_OOPS_NOT_CONSISTENT_10 = COMPRESSED_OOPS_NOT_CONSISTENT.formatted(1, 0); + static final String COMPRESSED_OOPS_NOT_CONSISTENT_01 = COMPRESSED_OOPS_NOT_CONSISTENT.formatted(0, 1); static String appJar; static String[] vmOptionsPrefix = {}; @@ -117,7 +119,7 @@ public class IncompatibleOptions { // Explicitly archive with compressed oops, run without. testDump(3, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); - testExec(3, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COMPRESSED_OOPS_NOT_CONSISTENT, true); + testExec(3, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COMPRESSED_OOPS_NOT_CONSISTENT_10, true); // NOTE: No warning is displayed, by design // Still run, to ensure no crash or exception @@ -130,14 +132,14 @@ public class IncompatibleOptions { testExec(4, "-XX:+UseSerialGC", "", "", false); if (GC.Z.isSupported()) { - testExec(4, "-XX:+UseZGC", "", COMPRESSED_OOPS_NOT_CONSISTENT, true); + testExec(4, "-XX:+UseZGC", "", COMPRESSED_OOPS_NOT_CONSISTENT_10, true); } // Explicitly archive with object streaming and COOPs with one GC, run with other GCs. testDump(4, "-XX:-UseCompressedOops", "-XX:+AOTStreamableObjects", null, false); - testExec(4, "-XX:+UseG1GC", "", COMPRESSED_OOPS_NOT_CONSISTENT, true); - testExec(4, "-XX:+UseParallelGC", "", COMPRESSED_OOPS_NOT_CONSISTENT, true); - testExec(4, "-XX:+UseSerialGC", "", COMPRESSED_OOPS_NOT_CONSISTENT, true); + testExec(4, "-XX:+UseG1GC", "", COMPRESSED_OOPS_NOT_CONSISTENT_01, true); + testExec(4, "-XX:+UseParallelGC", "", COMPRESSED_OOPS_NOT_CONSISTENT_01, true); + testExec(4, "-XX:+UseSerialGC", "", COMPRESSED_OOPS_NOT_CONSISTENT_01, true); testExec(4, "-XX:+UseParallelGC", "-XX:-UseCompressedOops", "", false); testExec(4, "-XX:+UseSerialGC", "-XX:-UseCompressedOops", "", false); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java deleted file mode 100644 index 89136ebdc4d..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015, 2025, 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 - * @summary Test shared strings together with string intern operation - * @requires vm.gc == null - * @requires vm.cds.write.mapped.java.heap - * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib - * @compile InternStringTest.java - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver InternSharedString - */ - -// This test requires the vm.cds.write.mapped.java.heap specifically as it has expectations -// about using the mechanism for dumping the entire string table, which the streaming solution -// does not do. - -public class InternSharedString { - public static void main(String[] args) throws Exception { - SharedStringsUtils.run(args, InternSharedString::test); - } - - public static void test(String[] args) throws Exception { - SharedStringsUtils.buildJarAndWhiteBox("InternStringTest"); - - SharedStringsUtils.dumpWithWhiteBox(TestCommon.list("InternStringTest"), - "ExtraSharedInput.txt", "-Xlog:cds,aot+hashtables"); - - String[] extraMatches = new String[] { - InternStringTest.passed_output1, - InternStringTest.passed_output2, - InternStringTest.passed_output3 }; - - SharedStringsUtils.runWithArchiveAndWhiteBox(extraMatches, "InternStringTest"); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternStringTest.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternStringTest.java deleted file mode 100644 index bea24c87888..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternStringTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2015, 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. - * - * 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.whitebox.WhiteBox; - -public class InternStringTest { - public static String passed_output1 = "Found shared string."; - public static String passed_output2 = "Shared strings are equal."; - public static String passed_output3 = "Found shared string containing latin1 supplement chars."; - public static String passed_output4 = "Found shared string containing non-western chars."; - public static final String latin1Sup = "XXXX \u00a3 YYYY"; // \u00a3 = The pound sign - public static final String nonWestern = "XXXX \u5678 YYYY"; // \u5678 = Unicode Han Character 'ton (metric or English)' - - public static void main(String[] args) throws Exception { - WhiteBox wb = WhiteBox.getWhiteBox(); - - // All string literals are shared. - String shared1 = "LiveOak"; - String interned1 = shared1.intern(); - if (wb.areSharedStringsMapped()) { - if (wb.isSharedInternedString(interned1)) { - System.out.println(passed_output1); - } else { - throw new RuntimeException("Failed: String is not shared."); - } - } - - // Test 2: shared_string1.intern() == shared_string2.intern() - String shared2 = "LiveOak"; - String interned2 = shared2.intern(); - if (interned1 == interned2) { - System.out.println(passed_output2); - } else { - throw new RuntimeException("Not equal!"); - } - - // Test 3: interned strings with a char in latin1 supplement block [\u0080-\u00ff] - { - String a = "X" + latin1Sup.substring(1); - String b = a.intern(); - - if (wb.areSharedStringsMapped()) { - if (wb.isSharedInternedString(b)) { - System.out.println(passed_output3); - } else { - throw new RuntimeException("Failed: expected shared string with latin1-supplement chars."); - } - } - } - - // Test 5: interned strings with non-western characters - { - String a = "X" + nonWestern.substring(1); - String b = a.intern(); - if (wb.areSharedStringsMapped()) { - if (wb.isSharedInternedString(b)) { - System.out.println(passed_output4); - } else { - throw new RuntimeException("Failed: expected shared string with non-western chars."); - } - } - } - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java deleted file mode 100644 index 6145ea7719b..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015, 2025, 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 - * @summary Basic plus test for shared strings - * @requires vm.cds.write.mapped.java.heap - * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib - * @build HelloStringPlus jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver SharedStringsBasicPlus - */ - -// This test requires the vm.cds.write.mapped.java.heap specifically as it has expectations -// about using the mechanism for dumping the entire string table, which the streaming solution -// does not do. - -public class SharedStringsBasicPlus { - public static void main(String[] args) throws Exception { - SharedStringsUtils.run(args, SharedStringsBasicPlus::test); - } - - public static void test(String[] args) throws Exception { - SharedStringsUtils.buildJarAndWhiteBox("HelloStringPlus"); - - SharedStringsUtils.dumpWithWhiteBox( TestCommon.list("HelloStringPlus"), - "SharedStringsBasic.txt", "-Xlog:cds,aot+hashtables"); - - SharedStringsUtils.runWithArchiveAndWhiteBox("HelloStringPlus"); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java index e15cfafa3cb..15686d76ab3 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ public class SharedStringsUtils { // SharedStringsUtils.run() is for running the main test body multiple times, each with a different // set of extra VM options that are passed to the child processes. // - // See ./ExerciseGC.java for an example. + // See ./LargePages.java for an example. public static void run(String args[], Test t) throws Exception { int numSetOfChildVMOptions = vmOptionCombos.length; for (int i=0; i< numSetOfChildVMOptions; i++) { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java deleted file mode 100644 index 20dbad30441..00000000000 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, 2025, 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 - * @summary White box test for shared strings - * @requires vm.cds.write.mapped.java.heap - * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds - * @build jdk.test.whitebox.WhiteBox SharedStringsWb - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver SharedStringsWbTest - */ - -// This test requires the vm.cds.write.mapped.java.heap specifically as it has expectations -// about using the mechanism for dumping the entire string table, which the streaming solution -// does not do. - -import java.io.*; -import jdk.test.whitebox.WhiteBox; - -public class SharedStringsWbTest { - public static void main(String[] args) throws Exception { - SharedStringsUtils.run(args, SharedStringsWbTest::test); - } - - public static void test(String[] args) throws Exception { - SharedStringsUtils.buildJarAndWhiteBox("SharedStringsWb"); - - SharedStringsUtils.dumpWithWhiteBox(TestCommon.list("SharedStringsWb"), - "SharedStringsBasic.txt", "-Xlog:cds,aot+hashtables"); - - SharedStringsUtils.runWithArchiveAndWhiteBox("SharedStringsWb"); - } -} diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java index 408ab0582b1..99b2714a08f 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -190,7 +190,6 @@ public class ReplaceCriticalClasses { if (checkSubgraph) { if (expectShared) { if (!out.getOutput().contains("Unable to map at required address in java heap")) { - out.shouldContain(subgraphInit); // If the subgraph is successfully initialized, the specified shared class must not be rewritten. out.shouldNotContain("Rewriting done."); } diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java b/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java index a7063ecd2dc..508dcf197e3 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java @@ -25,7 +25,7 @@ /** * @test * @summary Check that the verbose message of the AME is printed correctly. - * @requires !(os.arch=="arm") & vm.flavor == "server" & !vm.emulatedClient & vm.compMode=="Xmixed" & !vm.graal.enabled & vm.opt.UseJVMCICompiler != true & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) + * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & !vm.graal.enabled & vm.opt.UseJVMCICompiler != true & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) * @requires vm.opt.DeoptimizeALot != true * @library /test/lib / * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java b/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java index 77738191f19..5891ff60c42 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java @@ -26,7 +26,7 @@ * @test * @summary Check that the verbose message of ICCE is printed correctly. * The test forces errors in vtable stubs and interpreter. - * @requires !(os.arch=="arm") & vm.flavor == "server" & !vm.emulatedClient & vm.compMode=="Xmixed" & (!vm.graal.enabled | vm.opt.TieredCompilation == true) & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) + * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & (!vm.graal.enabled | vm.opt.TieredCompilation == true) & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) * @library /test/lib / * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/interpreter/CoherentBytecodeTraceTest.java b/test/hotspot/jtreg/runtime/interpreter/CoherentBytecodeTraceTest.java new file mode 100644 index 00000000000..e0fb8cf98ec --- /dev/null +++ b/test/hotspot/jtreg/runtime/interpreter/CoherentBytecodeTraceTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2026, 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 8370044 + * @library / /test/lib + * @summary Ensures that individual bytecodes are not broken apart. + * @requires vm.debug == true & vm.flagless + * @run driver CoherentBytecodeTraceTest + */ + +import module java.base; + +import jdk.test.lib.Utils; +import jdk.test.lib.process.*; + +public class CoherentBytecodeTraceTest { + private static final int NUM_THREADS = 3; + private static final String THE_METHOD = ""; + + public static void main(String[] args) + throws InterruptedException, IOException { + if (args.length == 1 && "worker".equals(args[0])) { + schedule(); + return; + } + // Create a VM process and trace its bytecodes. + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + "-XX:+TraceBytecodes", + // Make sure that work() is not compiled. If there is no compiler, + // the flag is still accepted. + "-XX:CompileCommand=exclude,CoherentBytecodeTraceTest.work", + CoherentBytecodeTraceTest.class.getName(), "worker" + ); + OutputAnalyzer oa = new OutputAnalyzer(pb.start()).shouldHaveExitValue(0); + analyze(oa.stdoutAsLines()); + } + + private static void schedule() throws InterruptedException { + Thread[] threads = + IntStream.range(0, NUM_THREADS) + .mapToObj(i -> { + Thread thread = new Thread( + CoherentBytecodeTraceTest::work + ); + thread.start(); + return thread; + }) + .toArray(Thread[]::new); + for (Thread thread : threads) { + thread.join(); + } + } + + // The analysis works by finding the invokeinterface bytecode when calling + // Strategy.foo. The trace should look something like the following: + // invokeinterface 116 + // The strategy is to find CoherentBytecodeTraceTest$Strategy.foo's index + // and then ensure the constant pool ref and opcode before are correct. + // This requires going through the file line-by-line. + private static void analyze(List lines) { + IO.println("Analyzing " + lines.size() + " lines"); + boolean foundAtLeastOne = false; + // Reverse regex for: 'invokeinterface \d+ '. This is needed to look + // back from the interface name to ensure that the thing that + // preceeds it is an invokeinterface with a constant pool reference. + // Use 'XXXX' to denote where we want to put \d+ or else it will get + // reversed and lose its semantics. + String searchRegex = reverseString("invokeinterface XXXX ") + .replace("XXXX", "\\d+"); + Pattern reverseFirstPart = Pattern.compile(searchRegex); + for (String line : lines) { + int fooCallIndex = line.indexOf(THE_METHOD); + if (fooCallIndex == -1) { + continue; + } + String untilFooCall = line.substring(0, fooCallIndex); + String beginningReverse = reverseString(untilFooCall); + // Use a Scanner to do a match for "invokeinterface XXXX " + // immediately before the constant pool reference. + Scanner scanner = new Scanner(beginningReverse); + // Scanner#hasNext would use the next token given by whitespace, + // but whitespace is part of the pattern. Use horizon instead, if + // this is null, then there is no match. + if (scanner.findWithinHorizon(reverseFirstPart, 0) == null) { + IO.println("Using regex: " + reverseFirstPart); + IO.println("Regex rejected: " + beginningReverse); + throw new RuntimeException( + "torn bytecode trace: " + line + ); + } + foundAtLeastOne = true; + } + // If there are no invokeinterface calls then something went wrong + // and the test probably needs to be updated. + if (!foundAtLeastOne) { + throw new RuntimeException( + "sanity failure: no invokeinterface found for " + THE_METHOD + ); + } + } + + // Performs some random work. + // The goal is to have this emit some bytecodes that contain other bytes. + public static void work() { + int x = 10; + int y = 30; + int sum = 123; + for (int i = 0; i < 10_000; i++) { + if (i == x) { + int modulo = y % i; + sum ^= modulo; + } else { + Strategy[] arr = new Strategy[] { new Outer(new Object()) }; + arr[0].foo(i); + x = y - sum; + } + } + } + + private static String reverseString(String input) { + return new StringBuilder(input).reverse().toString(); + } + + private record Outer(Object inner) implements Strategy { + @Override + public void foo(int i) { + if (i % 1000 == 0) { + IO.println("foo" + i); + } + } + } + + public interface Strategy { + void foo(int i); + } +} diff --git a/test/hotspot/jtreg/runtime/logging/GenerateOopMapTest.java b/test/hotspot/jtreg/runtime/logging/GenerateOopMapTest.java new file mode 100644 index 00000000000..6e114ff6b1d --- /dev/null +++ b/test/hotspot/jtreg/runtime/logging/GenerateOopMapTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2026, 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 GenerateOopMap + * @bug 8379015 + * @requires vm.flagless + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @run driver GenerateOopMapTest + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.Platform; + +public class GenerateOopMapTest { + + static String infoPattern = "[generateoopmap]"; + static String debugPattern = "[generateoopmap] Basicblock#0 begins at:"; + static String tracePattern = "[trace][generateoopmap] 5 vars = 'r' stack = 'v' monitors = '' \tifne"; + static String traceDetailPattern = "[generateoopmap] 0 vars = ( r |slot0) invokestatic()V"; + + static void test() throws Exception { + // Don't print much with info level. + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:generateoopmap=info", + "GenerateOopMapTest", "test"); + OutputAnalyzer o = new OutputAnalyzer(pb.start()); + o.shouldNotContain(infoPattern).shouldHaveExitValue(0); + + // Prints bytecodes and BasicBlock information in debug. + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:generateoopmap=debug", + "GenerateOopMapTest", "test"); + o = new OutputAnalyzer(pb.start()); + o.shouldContain(debugPattern).shouldHaveExitValue(0); + + // Prints ref/val for each bytecode in trace. + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:generateoopmap=trace", + "GenerateOopMapTest", "test"); + o = new OutputAnalyzer(pb.start()); + o.shouldContain(tracePattern).shouldHaveExitValue(0); + + // Prints extra stuff with detailed. Not sure how useful this is but keep it for now. + if (Platform.isDebugBuild()) { + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:generateoopmap=trace", + "-XX:+Verbose", + "GenerateOopMapTest", "test"); + o = new OutputAnalyzer(pb.start()); + o.shouldContain(traceDetailPattern).shouldHaveExitValue(0); + } + }; + + public static void main(String... args) throws Exception { + System.gc(); + if (args.length == 0) { + test(); + } + } +} diff --git a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java index 18201d99127..51d6742b832 100644 --- a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java +++ b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -38,6 +38,9 @@ import jtreg.SkippedException; import java.util.ArrayList; import java.io.File; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; public class AvailableProcessors { @@ -73,13 +76,17 @@ public class AvailableProcessors { "AvailableProcessors"); int[] expected = new int[] { 1, available/2, available-1, available }; + int cpuId = getFirstAllowedCpu(); + if (cpuId == -1) { + throw new SkippedException("Could not determine allowed CPU cores"); + } for (int i : expected) { System.out.println("Testing for " + i + " processors ..."); - int max = i - 1; + int max = i - 1 + cpuId; ArrayList cmdline = new ArrayList<>(master.command()); // prepend taskset command - cmdline.add(0, "0-" + max); + cmdline.add(0, cpuId + "-" + max); cmdline.add(0, "-c"); cmdline.add(0, taskset); // append expected processor count @@ -104,4 +111,40 @@ public class AvailableProcessors { else System.out.println(SUCCESS_STRING + available); } + + /** + * Retrieves the first available CPU core ID allowed for the current process on Linux. + * + * @return The first CPU ID in Cpus_allowed_list, or -1 if unavailable. + */ + static int getFirstAllowedCpu() { + final String statusFile = "/proc/self/status"; + final String targetKey = "Cpus_allowed_list:"; + + try (BufferedReader br = new BufferedReader(new FileReader(statusFile))) { + String line; + while ((line = br.readLine()) != null) { + // Look for the line starting with "Cpus_allowed_list:" + if (line.startsWith(targetKey)) { + // Extract the value part, e.g., "0-15,32-47" or "80,82,84" + String listValue = line.substring(targetKey.length()).trim(); + if (listValue.isEmpty()) return -1; + + // Get the first segment before any comma (e.g., "0-15" from "0-15,32") + String firstSegment = listValue.split(",")[0]; + + // If it is a range (e.g., "80-159"), take the start number + if (firstSegment.contains("-")) { + return Integer.parseInt(firstSegment.split("-")[0]); + } else { + // If it is a single ID (e.g., "1"), parse it directly + return Integer.parseInt(firstSegment); + } + } + } + } catch (IOException | NumberFormatException | ArrayIndexOutOfBoundsException e) { + throw new RuntimeException("Failed to read or parse " + statusFile, e); + } + return -1; + } } diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java index 7c0dfb2f3bb..6c5896df058 100644 --- a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,6 +26,7 @@ * @test id=Default * @summary Test JVM large page setup (default options) * @library /test/lib + * @requires vm.flagless * @requires os.family == "linux" * @modules java.base/jdk.internal.misc * java.management @@ -36,6 +37,7 @@ * @test id=LP_enabled * @summary Test JVM large page setup (+LP) * @library /test/lib + * @requires vm.flagless * @requires os.family == "linux" * @modules java.base/jdk.internal.misc * java.management @@ -46,6 +48,7 @@ * @test id=THP_enabled * @summary Test JVM large page setup (+THP) * @library /test/lib + * @requires vm.flagless * @requires os.family == "linux" * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/os/TestWXHealing.java b/test/hotspot/jtreg/runtime/os/TestWXHealing.java index 46875848a89..1ed2caf2433 100644 --- a/test/hotspot/jtreg/runtime/os/TestWXHealing.java +++ b/test/hotspot/jtreg/runtime/os/TestWXHealing.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2025 IBM Corporation. All rights reserved. + * Copyright (c) 2026, 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,31 +23,72 @@ */ /* - * @test + * @test id=TraceWXHealing + * @summary Run shell with -XX:+StressWXHealing and -XX:+TraceWXHealing. This tests most of + * the triggers for WX mode. * @requires os.family == "mac" * @requires os.arch == "aarch64" - * @summary Run shell with -XX:+StressWXHealing. This tests most of - * the triggers for WX mode. + * @requires vm.debug == true * @library /test/lib * @compile WXHealing.java - * @run main TestWXHealing + * @build jtreg.SkippedException + * @run main TestWXHealing traceWXHealing */ +/* + * @test id=No-TraceWXHealing + * @summary Run shell with -XX:+StressWXHealing. This tests most of + * the triggers for WX mode. + * @requires os.family == "mac" + * @requires os.arch == "aarch64" + * @library /test/lib + * @compile WXHealing.java + * @build jtreg.SkippedException + * @run main TestWXHealing + */ import java.util.regex.*; import jdk.test.lib.process.*; +import jtreg.SkippedException; -import static java.nio.charset.StandardCharsets.*; +import static java.nio.charset.StandardCharsets.UTF_8; public class TestWXHealing { public static void main(String[] args) throws Throwable { - String[] opts = {"-XX:+UnlockDiagnosticVMOptions", - "-XX:+TraceWXHealing", "-XX:+StressWXHealing", "WXHealing"}; + String[] opts; + boolean traceWXHealing = args.length > 0 && args[0].equals("traceWXHealing"); + // pass -XX:+TraceWXHealing only when instructed to do so + if (traceWXHealing) { + opts = new String[]{ + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+TraceWXHealing", + "-XX:+StressWXHealing", + "WXHealing" + }; + } else { + opts = new String[]{ + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+StressWXHealing", + "WXHealing" + }; + } var process = ProcessTools.createTestJavaProcessBuilder(opts).start(); - String output = new String(process.getInputStream().readAllBytes(), UTF_8); - System.out.println(output); + OutputAnalyzer oa = new OutputAnalyzer(process, UTF_8); + oa.shouldHaveExitValue(0); + String output = oa.getStdout(); + System.out.println("output from WXHealing application: " + output); + if (output.isEmpty()) { + throw new RuntimeException("no output generated by WXHealing application"); + } + if (!traceWXHealing) { + // if -XX:+TraceWXHealing wasn't enabled, then this test merely + // verifies that the java application launched with -XX:+StressWXHealing + // exited normally. + return; + } + // verify the output generated by -XX:+TraceWXHealing if (output.contains("MAP_JIT write protection does not work on this system")) { - System.out.println("Test was not run because MAP_JIT write protection does not work on this system"); + throw new SkippedException("Test was not run because MAP_JIT write protection does not work on this system"); } else { var pattern = Pattern.compile("Healing WXMode WXArmedForWrite at 0x[0-9a-f]* to WXWrite "); var matches = pattern.matcher(output).results().count(); diff --git a/test/hotspot/jtreg/runtime/os/WXHealing.java b/test/hotspot/jtreg/runtime/os/WXHealing.java index ba790db2c59..eb5c5ad7b4b 100644 --- a/test/hotspot/jtreg/runtime/os/WXHealing.java +++ b/test/hotspot/jtreg/runtime/os/WXHealing.java @@ -22,6 +22,8 @@ */ import java.io.*; +import java.util.HashMap; + import jdk.jshell.tool.*; public class WXHealing { @@ -31,6 +33,8 @@ public class WXHealing { public static void main(String[] args) throws Throwable { JavaShellToolBuilder .builder() + // we don't need system level history/storage for this test + .persistence(new HashMap<>()) .in(new ByteArrayInputStream (""" void main() { diff --git a/test/hotspot/jtreg/runtime/verifier/MethodEndsWithLookupSwitch.jasm b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithLookupSwitch.jasm new file mode 100644 index 00000000000..c6043674da9 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithLookupSwitch.jasm @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2026, 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. + */ + +super public class MethodEndsWithLookupSwitch version 51:0 { + +/* + * See if verifier allows a method to end with a switch instruction. + */ +private Method "foo":"()V" + stack 1 locals 1 +{ + goto L1; +L3: + stack_frame_type same; + return; +L1: + stack_frame_type same; + iconst_0; + lookupswitch { + default: L3 + }; +} + +public Method "":"()V" + stack 2 locals 1 +{ + aload_0; + dup; + invokespecial Method java/lang/Object."":"()V"; + invokespecial Method "foo":"()V"; + return; +} + +} // end Class MethodEndsWithLookupSwitch diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWb.java b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithSwitch.java similarity index 65% rename from test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWb.java rename to test/hotspot/jtreg/runtime/verifier/MethodEndsWithSwitch.java index 755d64bf51b..9fca02eb5f0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWb.java +++ b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithSwitch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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,24 +19,24 @@ * 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.whitebox.WhiteBox; +/* + * @test + * @summary Verify that method can end with a switch instruction. + * @compile MethodEndsWithLookupSwitch.jasm MethodEndsWithTableSwitch.jasm + * @run main/othervm MethodEndsWithSwitch + */ + +public class MethodEndsWithSwitch { + + static void test(String testName) throws Exception { + System.out.println("Testing: " + testName); + Class c = Class.forName(testName); + } -public class SharedStringsWb { public static void main(String[] args) throws Exception { - WhiteBox wb = WhiteBox.getWhiteBox(); - String s = "shared_test_string_unique_14325"; - s = s.intern(); - if (wb.areSharedStringsMapped()) { - if (wb.isSharedInternedString(s)) { - System.out.println("Found shared string."); - } else { - throw new RuntimeException("String is not shared."); - } - } + test("MethodEndsWithLookupSwitch"); + test("MethodEndsWithTableSwitch"); } } - - diff --git a/test/hotspot/jtreg/runtime/verifier/MethodEndsWithTableSwitch.jasm b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithTableSwitch.jasm new file mode 100644 index 00000000000..97505f48643 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/MethodEndsWithTableSwitch.jasm @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2026, 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. + */ + +super public class MethodEndsWithTableSwitch version 51:0 { + +/* + * See if verifier allows a method to end with a switch instruction. + */ +private Method "foo":"()V" + stack 1 locals 1 +{ + goto L1; +L3: + stack_frame_type same; + return; +L1: + stack_frame_type same; + iconst_0; + tableswitch { + 0: L3; + 1: L3; + 2: L3; + default: L3 + }; +} + +public Method "":"()V" + stack 2 locals 1 +{ + aload_0; + dup; + invokespecial Method java/lang/Object."":"()V"; + invokespecial Method "foo":"()V"; + return; +} + +} // end Class MethodEndsWithTableSwitch diff --git a/test/hotspot/jtreg/runtime/verifier/UninitThisAcmp.jasm b/test/hotspot/jtreg/runtime/verifier/UninitThisAcmp.jasm new file mode 100644 index 00000000000..c1729a78653 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitThisAcmp.jasm @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitThisAcmp version 69:0 +{ + public Method "":"()V" + stack 2 locals 2 + { + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object."":"()V"; + astore_1; + aload_0; + aload_1; + if_acmpne L14; + nop; + L14: stack_frame_type append; + locals_map class java/lang/Object; + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitThisAcmp diff --git a/test/hotspot/jtreg/runtime/verifier/UninitThisAcmpOld.jasm b/test/hotspot/jtreg/runtime/verifier/UninitThisAcmpOld.jasm new file mode 100644 index 00000000000..3bcc1e09b67 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitThisAcmpOld.jasm @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitThisAcmpOld version 49:0 +{ + public Method "":"()V" + stack 2 locals 2 + { + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object."":"()V"; + astore_1; + aload_0; + aload_1; + if_acmpne L14; + nop; + L14: aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitThisAcmpOld diff --git a/test/hotspot/jtreg/runtime/verifier/UninitThisIfNull.jasm b/test/hotspot/jtreg/runtime/verifier/UninitThisIfNull.jasm new file mode 100644 index 00000000000..57a82a9f1e4 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitThisIfNull.jasm @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitThisIfNull version 69:0 +{ + public Method "":"()V" + stack 2 locals 2 + { + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object."":"()V"; + astore_1; + aload_0; + ifnonnull L14; + nop; + L14: stack_frame_type append; + locals_map class java/lang/Object; + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitThisIfNull diff --git a/test/hotspot/jtreg/runtime/verifier/UninitThisIfNullOld.jasm b/test/hotspot/jtreg/runtime/verifier/UninitThisIfNullOld.jasm new file mode 100644 index 00000000000..fbe96c2eef0 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitThisIfNullOld.jasm @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitThisIfNullOld version 49:0 +{ + public Method "":"()V" + stack 2 locals 2 + { + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object."":"()V"; + astore_1; + aload_0; + ifnonnull L14; + nop; + L14: aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitThisIfNullOld diff --git a/test/hotspot/jtreg/runtime/verifier/UninitializedAcmp.jasm b/test/hotspot/jtreg/runtime/verifier/UninitializedAcmp.jasm new file mode 100644 index 00000000000..b8ce17cb16b --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitializedAcmp.jasm @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitializedAcmp version 69:0 +{ + Method "":"()V" + stack 5 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + aload_0; + L1: new class java/lang/Object; + dup; + dup; + dup; + if_acmpne L18; + nop; + L18: stack_frame_type full; + locals_map class UninitializedAcmp; + stack_map class UninitializedAcmp, at L1, at L1; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitializedAcmp diff --git a/test/hotspot/jtreg/runtime/verifier/UninitializedAcmpOld.jasm b/test/hotspot/jtreg/runtime/verifier/UninitializedAcmpOld.jasm new file mode 100644 index 00000000000..d16cc5c6779 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitializedAcmpOld.jasm @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitializedAcmpOld version 49:0 +{ + Method "":"()V" + stack 5 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + aload_0; + L1: new class java/lang/Object; + dup; + dup; + dup; + if_acmpne L18; + nop; + L18: invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitializedAcmpOld diff --git a/test/hotspot/jtreg/runtime/verifier/UninitializedIfNull.jasm b/test/hotspot/jtreg/runtime/verifier/UninitializedIfNull.jasm new file mode 100644 index 00000000000..4e7251f073d --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitializedIfNull.jasm @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitializedIfNull version 69:0 +{ + Method "":"()V" + stack 3 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + L1: new class java/lang/Object; + dup; + dup; + ifnonnull L18; + nop; + L18: stack_frame_type full; + locals_map class UninitializedIfNull; + stack_map at L1, at L1; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitializedIfNull diff --git a/test/hotspot/jtreg/runtime/verifier/UninitializedIfNullOld.jasm b/test/hotspot/jtreg/runtime/verifier/UninitializedIfNullOld.jasm new file mode 100644 index 00000000000..5bffba887a8 --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitializedIfNullOld.jasm @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025, 2026, 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. + */ + +class UninitializedIfNullOld version 49:0 +{ + Method "":"()V" + stack 3 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + L1: new class java/lang/Object; + dup; + dup; + ifnonnull L18; + nop; + L18: invokespecial Method java/lang/Object."":"()V"; + return; + } +} // end Class UninitializedIfNullOld diff --git a/test/hotspot/jtreg/runtime/verifier/UninitializedThisVerificationTest.java b/test/hotspot/jtreg/runtime/verifier/UninitializedThisVerificationTest.java new file mode 100644 index 00000000000..075e9f2058e --- /dev/null +++ b/test/hotspot/jtreg/runtime/verifier/UninitializedThisVerificationTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025, 2026, 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 8366743 + * @summary Test spec rules for uninitialized + * @compile UninitThisAcmp.jasm UninitThisIfNull.jasm + * UninitializedIfNull.jasm UninitializedAcmp.jasm + * UninitThisAcmpOld.jasm UninitThisIfNullOld.jasm + * UninitializedAcmpOld.jasm UninitializedIfNullOld.jasm + * @run main/othervm -Xlog:verification UninitializedThisVerificationTest + */ + +public class UninitializedThisVerificationTest { + + public static void main(String[] args) throws Exception { + String[] testNames = { "UninitThisAcmp", "UninitThisIfNull", + "UninitializedAcmp", "UninitializedIfNull", + "UninitThisAcmpOld", "UninitThisIfNullOld", + "UninitializedAcmpOld", "UninitializedIfNullOld" }; + int fails = 0; + for (String test : testNames) { + System.out.println("Testing " + test); + try { + Class c = Class.forName(test); + System.out.println("Failed"); + fails++; + } catch (java.lang.VerifyError e) { + System.out.println("Passed"); + } + } + + if (fails > 0) { + throw new RuntimeException("Failed: Expected VerifyError in " + fails + " tests"); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/compiler/CompilerDirectivesDCMDTest.java b/test/hotspot/jtreg/serviceability/dcmd/compiler/CompilerDirectivesDCMDTest.java index 5e4f73cedd5..690726317b0 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/compiler/CompilerDirectivesDCMDTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/compiler/CompilerDirectivesDCMDTest.java @@ -49,7 +49,7 @@ public class CompilerDirectivesDCMDTest { public void run(CommandExecutor executor) { - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { filename = System.getProperty("test.src", ".") + File.separator + "control2.txt"; } else { filename = System.getProperty("test.src", ".") + File.separator + "control1.txt"; diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderStatsTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderStatsTest.java index a89f2508852..aaf54e03f9e 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderStatsTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderStatsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,17 +32,6 @@ * @run testng/othervm --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ClassLoaderStatsTest */ -/* - * @test - * @summary Test of diagnostic command VM.classloader_stats (-UseCCP) - * @library /test/lib - * @requires vm.bits != "32" - * @modules java.base/jdk.internal.misc - * java.compiler - * java.management - * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run testng/othervm -XX:-UseCompressedClassPointers --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ClassLoaderStatsTest - */ import org.testng.annotations.Test; import org.testng.Assert; @@ -110,7 +99,7 @@ public class ClassLoaderStatsTest { // Minimum expected sizes: initial capacity is governed by the chunk size of the first chunk, which // depends on the arena growth policy. Since this is a normal class loader, we expect as initial chunk - // size at least 4k (if UseCompressedClassPointers is off). + // size at least 4k. // Minimum used size is difficult to guess but should be at least 1k. // Maximum expected sizes: We just assume a reasonable maximum. We only loaded one class, so // we should not see values > 64k. diff --git a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java index 5b4a1c7e663..65a89b152b6 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/NMethodRelocation/NMethodRelocationTest.java @@ -28,7 +28,6 @@ * @requires vm.jvmti & * vm.gc != "Epsilon" & * vm.flavor == "server" & - * !vm.emulatedClient & * (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) & * vm.compMode == "Xmixed" * @library /test/lib /test/hotspot/jtreg diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineVerifyError.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineVerifyError.java index fa6bf0b98d4..340207071e0 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineVerifyError.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineVerifyError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +23,7 @@ /* * @test - * @bug 6402717 8330606 + * @bug 6402717 8330606 8376295 * @summary Redefine VerifyError to get a VerifyError should not throw SOE * @requires vm.jvmti * @library /test/lib @@ -33,10 +33,18 @@ * java.instrument * jdk.jartool/sun.tools.jar * @run main RedefineClassHelper + * * @run main/othervm/timeout=180 * -javaagent:redefineagent.jar * -Xlog:class+init,exceptions * RedefineVerifyError + * + * @run main/othervm/timeout=180 + * -javaagent:redefineagent.jar + * -Xlog:class+init,exceptions + * -XX:+UnlockDiagnosticVMOptions + * -XX:-BytecodeVerificationRemote + * RedefineVerifyError */ import org.objectweb.asm.AnnotationVisitor; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java index b596a5c7ee2..359d4a0b5be 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java @@ -111,7 +111,7 @@ public class SelfSuspendDisablerTest { t3.start(); while(!isSuspended(t3)) { - sleep(100); + sleep(1); } testJvmtiThreadState(t3, SUSPENDED); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume3/SuspendResume3.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume3/SuspendResume3.java new file mode 100644 index 00000000000..ae49ce29ed3 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume3/SuspendResume3.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2026, 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 8373944 + * @summary Suspend thread while it's trying to acquire a monitor when unmounted vthreads are in the queue + * @requires vm.continuations + * @requires vm.jvmti + * @library /test/lib /test/hotspot/jtreg/testlibrary + * @run main/othervm/native SuspendResume3 + */ + +import java.time.Instant; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Phaser; + +import java.lang.management.LockInfo; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; + +import jvmti.JVMTIUtils; + +public class SuspendResume3 { + int iterations; + int dummyCounter; + Object lock = new Object(); + Phaser allSync = new Phaser(3); + + SuspendResume3 (int iterations) { + this.iterations = iterations; + } + + void worker1(Phaser sync1, Phaser sync2) { + for (int i = 0; i < iterations; i++) { + synchronized (lock) { + sync1.arriveAndAwaitAdvance(); + sync2.arriveAndAwaitAdvance(); + } + allSync.arriveAndAwaitAdvance(); + } + }; + + void worker2(Phaser sync1, Phaser sync2) { + for (int i = 0; i < iterations; i++) { + sync1.arriveAndAwaitAdvance(); + synchronized (lock) { + sync2.arriveAndAwaitAdvance(); + } + allSync.arriveAndAwaitAdvance(); + } + }; + + void vthreadWorker(CountDownLatch started) { + started.countDown(); + synchronized (lock) { + dummyCounter++; + } + } + + private void runTest() throws Exception { + final Phaser w1Sync1 = new Phaser(2); + final Phaser w1Sync2 = new Phaser(2); + Thread worker1 = Thread.ofPlatform().start(() -> worker1(w1Sync1, w1Sync2)); + + final Phaser w2Sync1 = new Phaser(2); + final Phaser w2Sync2 = new Phaser(2); + Thread worker2 = Thread.ofPlatform().start(() -> worker2(w2Sync1, w2Sync2)); + + for (int i = 0; i < iterations; i++) { + // Wait until worker1 acquires monitor + w1Sync1.arriveAndAwaitAdvance(); + // Let worker2 block on monitor + w2Sync1.arriveAndAwaitAdvance(); + // Wait until worker2 blocks trying to acquire lock. We can't just check + // for a BLOCKED state because method arriveAndAwaitAdvance might involve + // extra class loading/initialization where worker2 could be seen as BLOCKED + // and thus be suspended below. If the main thread then tries to access those + // same classes before resuming worker2 the test would deadlock. + awaitBlockedOnLock(worker2); + + // Suspend worker2 + JVMTIUtils.suspendThread(worker2); + + // Add umounted vthread to _entry_list + var started = new CountDownLatch(1); + Thread vthread = Thread.ofVirtual().start(() -> vthreadWorker(started)); + started.await(); + await(vthread, Thread.State.BLOCKED); + + // Now let worker1 release the monitor picking worker2 + // as successor. Since worker2 is suspended, it will wake + // up, acquire the monitor and release it, unparking the + // unmounted thread as next successor. + w1Sync2.arriveAndAwaitAdvance(); + + // Force safepoint + System.gc(); + + // Let vthread terminate + vthread.join(); + + // Resume worker2 + JVMTIUtils.resumeThread(worker2); + w2Sync2.arriveAndAwaitAdvance(); + + if ((i % 10) == 0) { + System.out.println(Instant.now() + " => " + i + " of " + iterations); + } + allSync.arriveAndAwaitAdvance(); + } + + worker1.join(); + worker2.join(); + } + + public static void main(String[] args) throws Exception { + int iterations = (args.length > 0) ? Integer.parseInt(args[0]) : 100; + + SuspendResume3 obj = new SuspendResume3(iterations); + obj.runTest(); + } + + /** + * Waits for the given thread to reach a given state. + */ + private void await(Thread thread, Thread.State expectedState) throws InterruptedException { + Thread.State state = thread.getState(); + while (state != expectedState) { + assertTrue(state != Thread.State.TERMINATED, "Thread has terminated"); + Thread.sleep(10); + state = thread.getState(); + } + } + + /** + * Waits for the given thread to block trying to acquire lock's monitor. + */ + private void awaitBlockedOnLock(Thread thread) throws InterruptedException { + while (true) { + ThreadInfo threadInfo = ManagementFactory.getThreadMXBean().getThreadInfo(thread.threadId()); + assertTrue(threadInfo != null, "getThreadInfo() failed"); + LockInfo lockInfo = threadInfo.getLockInfo(); + if (lockInfo != null && lockInfo.getIdentityHashCode() == System.identityHashCode(lock)) { + break; + } + Thread.sleep(10); + } + } + + private static void assertTrue(boolean condition, String msg) { + if (!condition) { + throw new RuntimeException(msg); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java index 4fd202a18da..8a9f148b3be 100644 --- a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java +++ b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,9 @@ * @test * @bug 8204308 * @summary Test the jhsdb jmap -clstats command with CDS enabled - * @requires vm.hasSA & vm.cds + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @library /test/lib * @run driver/timeout=2400 CDSJMapClstats */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java index 57cd535a430..6493a803e90 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8191658 * @summary Test clhsdb attach, detach, reattach commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbAttach diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java index 09f90355e67..f6833d5379a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8314679 * @summary Test clhsdb attach, detach, and then attach to different JVM * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbAttachDifferentJVMs diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 53370fc09d6..ab5b73bf720 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,10 @@ /** * @test * @bug 8174994 8200613 - * @summary Test the clhsdb commands 'printmdo', 'printall', 'jstack' on a CDS enabled corefile. - * @requires vm.cds + * @summary Test the clhsdb commands 'printall', 'jstack' on a CDS enabled corefile. * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @requires vm.flavor == "server" * @library /test/lib * @modules java.base/jdk.internal.misc @@ -124,24 +125,10 @@ public class ClhsdbCDSCore { throw new SkippedException("The CDS archive is not mapped"); } - List testJavaOpts = Arrays.asList(Utils.getTestJavaOpts()); - - if (testJavaOpts.contains("-XX:TieredStopAtLevel=1")) { - // No MDOs are allocated in -XX:TieredStopAtLevel=1 - // The reason is methods being compiled aren't hot enough - // Let's not call printmdo in such scenario - cmds = List.of("printall", "jstack -v"); - } else { - cmds = List.of("printmdo -a", "printall", "jstack -v"); - } + cmds = List.of("printall", "jstack -v"); Map> expStrMap = new HashMap<>(); Map> unExpStrMap = new HashMap<>(); - expStrMap.put("printmdo -a", List.of( - "CounterData", - "BranchData")); - unExpStrMap.put("printmdo -a", List.of( - "No suitable match for type of address")); expStrMap.put("printall", List.of( "aload_0", "_nofast_aload_0", diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java index 4d01f9a26c8..c1e632782e2 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,9 @@ * @test * @bug 8174994 * @summary Test the clhsdb commands 'jstack', 'printall', 'where' with CDS enabled - * @requires vm.hasSA & vm.cds + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @library /test/lib * @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java index 3193f03bbc7..c4d11d29ec1 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8242142 * @summary Test clhsdb class and classes commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbClasses diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java index e45318e201d..49a3eb5615c 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 jtreg.SkippedException; * @bug 8240990 * @summary Test clhsdb dumpclass command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver ClhsdbDumpclass diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java index 722c641f5b9..92ec1c5d160 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java @@ -43,6 +43,7 @@ import jtreg.SkippedException; * @bug 8240989 * @summary Test clhsdb dumpheap command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compMode != "Xcomp" * @comment Running this test with -Xcomp is slow and therefore tends to cause @@ -81,10 +82,23 @@ public class ClhsdbDumpheap { fail("HPROF_GC_ROOT_JAVA_FRAME not found"); } + private static void verifyStickyClasses(String file) throws IOException { + try (var snapshot = HprofReader.readFile(file, false, 0)) { + for (var root = snapshot.getRoots(); root.hasMoreElements();) { + if (root.nextElement().getType() == Root.SYSTEM_CLASS) { + // expected + return; + } + } + } + fail("HPROF_GC_ROOT_STICKY_CLASS not found"); + } + private static void verifyDumpFile(File dump) throws Exception { assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath()); printStackTraces(dump.getAbsolutePath()); verifyLocalRefs(dump.getAbsolutePath()); + verifyStickyClasses(dump.getAbsolutePath()); } private static class SubTest { diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java index 7dc676f1f3a..1df35dccce3 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 +32,7 @@ import jtreg.SkippedException; * @bug 8191538 * @summary Test clhsdb 'field' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbField diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java index 7ced4c9515b..1997e497af8 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,9 @@ import jtreg.SkippedException; * @test id=xcomp-process * @bug 8193124 * @summary Test the clhsdb 'findpc' command with Xcomp on live process - * @requires vm.compMode != "Xcomp" * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.compMode != "Xcomp" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compiler1.enabled * @requires vm.opt.DeoptimizeALot != true @@ -48,8 +49,9 @@ import jtreg.SkippedException; * @test id=xcomp-core * @bug 8193124 * @summary Test the clhsdb 'findpc' command with Xcomp on core file - * @requires vm.compMode != "Xcomp" * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.compMode != "Xcomp" * @requires vm.compiler1.enabled * @requires vm.opt.DeoptimizeALot != true * @library /test/lib @@ -61,6 +63,7 @@ import jtreg.SkippedException; * @bug 8193124 * @summary Test the clhsdb 'findpc' command w/o Xcomp on live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compiler1.enabled * @library /test/lib @@ -72,6 +75,7 @@ import jtreg.SkippedException; * @bug 8193124 * @summary Test the clhsdb 'findpc' command w/o Xcomp on core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires vm.compiler1.enabled * @library /test/lib * @run main/othervm/timeout=1920 ClhsdbFindPC false true diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java index a19f3e1ca16..1c8cf7191dd 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8217845 * @summary Test clhsdb flags command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver ClhsdbFlags diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java index e8416cbadd8..5dabb898936 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8217845 * @summary Test clhsdb command line history support * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbHistory diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java index 553706e502d..c0c062223d4 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java @@ -26,6 +26,7 @@ * @bug 8192985 * @summary Test the clhsdb 'inspect' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbInspect diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java index 756e45f68aa..6c0ff0e3dbe 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8193124 * @summary Test the clhsdb 'jdis' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJdis diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java index ef30a97a026..a582b01e832 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import jtreg.SkippedException; * @bug 8191658 * @summary Test clhsdb jhisto command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJhisto diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java index 411664f195d..f066950cfc3 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb Jstack command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbJstack true @@ -44,6 +45,7 @@ import jtreg.SkippedException; * @requires vm.compMode != "Xcomp" * @summary Test clhsdb Jstack command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbJstack false diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java index 64080b252c5..e3d586c9d8a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8324066 * @summary Test the clhsdb 'jstack -l' command for printing concurrent lock information * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJstackWithConcurrentLock diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java index 4b02c01119d..a24b401dc47 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8196969 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.opt.DeoptimizeALot != true * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java index fceb2097e46..7fd3eb23d02 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8190198 * @summary Test clhsdb longConstant command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbLongConstant diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java index 5c0aa9457ae..885694f7abb 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pmap command on a live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPmap false @@ -45,6 +46,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pmap command on a core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/othervm/timeout=480 ClhsdbPmap true */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java index ac5ddf774e1..a62142c2c5c 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +32,7 @@ import jtreg.SkippedException; * @bug 8175384 * @summary Test clhsdb 'printall' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=2400 -Xmx2g ClhsdbPrintAll diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java index 03ce8cd3048..c7e7e979b6d 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8192985 * @summary Test the clhsdb 'printas' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPrintAs diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java index c6f83c06845..e68e3ca4c47 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb printstatics command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPrintStatics diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java index 15d88400917..51738be3554 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pstack command on a live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPstack false @@ -45,6 +46,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pstack command on a core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/othervm/timeout=480 ClhsdbPstack true */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java index 3b2aefec664..89c033f333a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,8 @@ * @test id=parallel * @bug 8192985 * @summary Test the clhsdb 'scanoops' command - * @requires vm.gc.Parallel * @requires vm.hasSA + * @requires vm.gc.Parallel * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=1200 ClhsdbScanOops UseParallelGC @@ -36,8 +36,8 @@ * @test id=serial * @bug 8192985 * @summary Test the clhsdb 'scanoops' command - * @requires vm.gc.Serial * @requires vm.hasSA + * @requires vm.gc.Serial * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=1200 ClhsdbScanOops UseSerialGC diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java index c66e44aa213..8ec946e3ea1 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8192823 * @summary Test clhsdb source command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbSource diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java index fe26427d6ce..ca05ba1d33e 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.util.Map; * @bug 8261095 * @summary Test the clhsdb 'symbol' command on live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbSymbol diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java index d076e648d90..05054f31c51 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import jtreg.SkippedException; * @bug 8318682 * @summary Test clhsdb that decoding of AllocationMerge objects in debug info works correctly * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbTestAllocationMerge diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java index f72b51585f5..e9a0b611134 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8193352 * @summary Test clhsdb 'thread' and 'threads' commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbThread diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java index 5c3092a139d..c452575b782 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @test * @summary Test clhsdb where command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbThreadContext diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java index 21db0e867a4..b00138e0c39 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 +32,7 @@ import jtreg.SkippedException; * @bug 8191538 * @summary Test clhsdb 'vmstructsdump' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbVmStructsDump diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java index 4536d568212..971f30fd94f 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb where command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbWhere diff --git a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java index cf9c4dfc5a1..ada0003fba5 100644 --- a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java +++ b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +25,7 @@ * @test * @summary Test deadlock detection * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java index 75942f7113a..a13106b1401 100644 --- a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java +++ b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import jdk.test.lib.Utils; /** * @test * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver JhsdbThreadInfoTest diff --git a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java index c163d45e0ba..c415332291e 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java +++ b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jtreg.SkippedException; * @bug 8184982 * @summary Test ClassDump tool * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestClassDump diff --git a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java index a0a1051beca..8524b4cd489 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java +++ b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @test * @bug 8185796 8335743 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestClhsdbJstackLock diff --git a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java index b1f2148954c..2d6c208164a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -46,6 +46,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java b/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java index eb59f6f9487..3d808da683d 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -38,6 +38,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8318682 * @summary Test decoding debug info for all nmethods in the code cache * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @modules jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java index 3bbb6fcdf35..c8efec888ca 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java index 418dc5ec5a0..8ed476a0a1f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.hprof.HprofParser; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java index 3dbfbecda73..d1ed4729d39 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -46,6 +46,7 @@ import java.util.*; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java index a462ee30fb2..fd192212bc4 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +42,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java index 2b41394b7a5..23e64452652 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java +++ b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 +34,7 @@ import jtreg.SkippedException; * @summary Test the 'intConstant' command of jhsdb clhsdb. * @bug 8190307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestIntConstant diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java index 15b9aa9ccae..936532527d4 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.SA.SATestUtils; * @test * @bug 8214226 8243500 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.arch=="amd64" | os.arch=="x86_64" * @requires os.family=="windows" | os.family == "linux" | os.family == "mac" * @requires vm.flagless diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java index ac536523815..c9c85b3d25f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jdk.test.lib.Utils; * @test * @bug 8185796 8335743 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackLock diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java index e90418b1030..e3808aa6706 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java @@ -37,7 +37,9 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @key randomness * @bug 8208091 8374469 8377710 - * @requires (os.family == "linux" | os.family == "windows") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires (os.family == "linux" | os.family == "windows") * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackMixed diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java index 84a62eb65e5..99232ed9813 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java @@ -38,7 +38,9 @@ import jtreg.SkippedException; /** * @test * @bug 8374482 8376264 8376284 8377395 - * @requires (os.family == "linux") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib * @run driver TestJhsdbJstackMixedCore diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java index 84da46e272f..de512b93121 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java @@ -38,7 +38,9 @@ import jdk.test.lib.util.CoreUtils; /** * @test * @bug 8376269 - * @requires (os.family == "linux") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib * @run driver TestJhsdbJstackMixedWithVDSOCallCore diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java index a26fc4532df..1ebf6c21a70 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, NTT DATA * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib @@ -46,6 +47,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp-preserve-frame-pointer * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib @@ -56,6 +58,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp-disable-tiered-compilation * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java index b7b3c956441..f6580d71e05 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jtreg.SkippedException; * @test * @summary Test verifies that jstack --mixed prints information about VM locks * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java index 1873672d2ce..e91910c3411 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8339307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackUpcall diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java index 39b6e1ed609..55751c330b5 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, NTT DATA * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,6 +37,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8369505 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run driver TestJhsdbJstackWithVirtualThread */ diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 77258bd45b7..024b5e03c98 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +25,7 @@ * @test TestJmapCore * @summary Test verifies that jhsdb jmap could generate heap dump from core when heap is full * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires !vm.asan * @library /test/lib * @run driver/timeout=480 TestJmapCore run heap diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java index ec3c66476a6..372cd0246ac 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +25,7 @@ * @test TestJmapCoreMetaspace * @summary Test verifies that jhsdb jmap could generate heap dump from core when metaspace is full * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires !vm.asan * @library /test/lib * @run driver/timeout=480 TestJmapCore run metaspace diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java index 62fe2f5d7aa..081dbe1206c 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -38,7 +38,9 @@ import jdk.test.lib.Utils; /** * @test * @library /test/lib - * @requires vm.hasSA & vm.bits == "64" + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.bits == "64" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.runtime diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java index 86a00285ee4..0448cc0788a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,6 +38,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8259008 * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.oops diff --git a/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java b/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java deleted file mode 100644 index 7292d797740..00000000000 --- a/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017, 2025, 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.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import jdk.test.lib.apps.LingeredApp; -import jdk.test.lib.Utils; -import jtreg.SkippedException; - -/** - * @test - * @library /test/lib - * @requires vm.hasSA - * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) - * @requires vm.flavor == "server" & !vm.emulatedClient & !(vm.opt.TieredStopAtLevel == 1) - * @run main/othervm TestPrintMdo - */ - -public class TestPrintMdo { - - public static void main (String... args) throws Exception { - System.out.println("Starting TestPrintMdo test"); - LingeredApp app = null; - try { - ClhsdbLauncher test = new ClhsdbLauncher(); - app = LingeredApp.startApp("-XX:+ProfileInterpreter", "-XX:CompileThreshold=100"); - System.out.println ("Started LingeredApp with pid " + app.getPid()); - List cmds = List.of("printmdo -a"); - - Map> expStrMap = new HashMap<>(); - Map> unExpStrMap = new HashMap<>(); - expStrMap.put("printmdo -a", List.of( - "VirtualCallData", - "CounterData", - "bci", - "MethodData", - "java/lang/Object")); - unExpStrMap.put("printmdo -a", List.of( - "missing reason for ")); - test.run(app.getPid(), cmds, expStrMap, unExpStrMap); - } catch (SkippedException se) { - throw se; - } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); - } finally { - LingeredApp.stopApp(app); - } - - System.out.println("Test PASSED"); - } -} diff --git a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java index 315c931d49e..8c5ce3ae3cd 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 +41,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.utilities diff --git a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java b/test/hotspot/jtreg/serviceability/sa/TestSysProps.java index a591d009ecf..a2617f7f268 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java +++ b/test/hotspot/jtreg/serviceability/sa/TestSysProps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8242165 8242162 * @summary Test "jhsdb jinfo --sysprops", "jinfo -sysprops", and clhsdb "sysprops" commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestSysProps diff --git a/test/hotspot/jtreg/serviceability/sa/TestType.java b/test/hotspot/jtreg/serviceability/sa/TestType.java index c3326032b90..e5b90a3c2a9 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestType.java +++ b/test/hotspot/jtreg/serviceability/sa/TestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 +34,7 @@ import jtreg.SkippedException; * @summary Test the 'type' command of jhsdb clhsdb. * @bug 8190307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestType diff --git a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java index 774fcee50ed..7792ec1a003 100644 --- a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java +++ b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.debugger diff --git a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index a41ab71f4fa..6a7c519fedf 100644 --- a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,6 +42,7 @@ import jdk.test.lib.SA.SATestUtils; * @test * @bug 6313383 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @summary Regression test for hprof export issue due to large heaps (>2G) * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java index 57962e72c5c..ab211b70691 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8262520 * @summary Test clhsdb connect, detach, reattach commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java index 109afa21841..2e07dfa63f0 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,6 +35,7 @@ import jtreg.SkippedException; * @test * @bug 8263342 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java index 285f57f8115..7576aa54bf0 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8209790 * @summary Checks ability for connecting to debug server (jstack, jmap, jinfo, jsnap) * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java index ae0774988a8..312e99c172c 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8263636 8263635 * @summary Test to use already started RMI registry * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java index b1665634fb0..c27989e20ca 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,6 +34,7 @@ import jtreg.SkippedException; * @test * @bug 8263670 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires (os.family != "windows") & (os.family != "mac") * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java index 9e725561341..5905d558c55 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,6 +37,7 @@ import jtreg.SkippedException; * @bug 8265505 * @summary Test clhsdb command which should be run on debugd server * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java index 69f4c9eb454..166e45cc3b7 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,6 +27,7 @@ * @summary Checks that the jshdb debugd utility successfully starts * and tries to attach to a running process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java b/test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java new file mode 100644 index 00000000000..b5db455cc20 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2026, 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 java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; + +import java.util.ArrayList; +import java.util.List; + +/* + * @test + * @bug 8323792 + * @summary Make sure that jmm_GetThreadInfo() call does not crash JVM + * @library /test/lib + * @modules java.management + * @run main/othervm ThreadInfoTest + * + * @comment Exercise getThreadInfo(ids, 0). Depth parameter of zero means + * no VM operation, which could crash with Threads starting and ending. + */ + +public class ThreadInfoTest { + private static com.sun.management.ThreadMXBean mbean = + (com.sun.management.ThreadMXBean)ManagementFactory.getThreadMXBean(); + + private static final int NUM_THREADS = 2; + static long[] ids = new long[NUM_THREADS]; + static ThreadInfo[] infos = new ThreadInfo[NUM_THREADS]; + static volatile int count = 0; + static int ITERATIONS = 4; + + public static void main(String[] argv) throws Exception { + boolean replacing = false; + + startThreads(ids, NUM_THREADS); + new MyGetThreadInfoThread(ids).start(); + new MyReplacerThread(ids).start(); + for (int i = 0; i < ITERATIONS; i++) { + do { + count = countInfo(infos); + System.out.println("Iteration " + i + ": ThreadInfos found (Threads alive): " + count); + goSleep(100); + } while (count > 0); + } + } + + private static Thread newThread(int i) { + Thread thread = new MyThread(i); + thread.setDaemon(true); + return thread; + } + + private static void startThreads(long[] ids, int count) { + System.out.println("Starting " + count + " Threads..."); + Thread[] threads = new Thread[count]; + for (int i = 0; i < count; i++) { + threads[i] = newThread(i); + threads[i].start(); + ids[i] = threads[i].getId(); + } + System.out.println(ids); + } + + // Count ThreadInfo from array, return how many are non-null. + private static int countInfo(ThreadInfo[] info) { + int count = 0; + if (info != null) { + int i = 0; + for (ThreadInfo ti: info) { + if (ti != null) { + count++; + } + i++; + } + } + return count; + } + + private static int replaceThreads(long[] ids, ThreadInfo[] info) { + int replaced = 0; + if (info != null) { + for (int i = 0; i < info.length; i++) { + ThreadInfo ti = info[i]; + if (ti == null) { + Thread thread = newThread(i); + thread.start(); + ids[i] = thread.getId(); + replaced++; + } + } + } + return replaced; + } + + private static void goSleep(long ms) { + try { + Thread.sleep(ms); + } catch (InterruptedException e) { + System.out.println("Unexpected exception is thrown: " + e); + } + } + + // A Thread which replaces Threads in the shared array of threads. + static class MyReplacerThread extends Thread { + long[] ids; + + public MyReplacerThread(long[] ids) { + this.ids = ids; + this.setDaemon(true); + } + + public void run() { + boolean replacing = false; + while (true) { + if (replacing) { + replaceThreads(ids, infos); + } + if (count < 10) { + replacing = true; + } + if (count > 20) { + replacing = false; + } + goSleep(1); + } + } + } + + // A Thread which lives for a short while. + static class MyThread extends Thread { + long endTimeMs; + + public MyThread(long n) { + super("MyThread-" + n); + endTimeMs = (n * n * 10) + System.currentTimeMillis(); + } + + public void run() { + try { + long sleep = Math.max(1, endTimeMs - System.currentTimeMillis()); + goSleep(sleep); + } catch (Exception e) { + System.out.println(Thread.currentThread().getName() + ": " + e); + } + } + } + + // A Thread to continually call getThreadInfo on a shared array of thread ids. + static class MyGetThreadInfoThread extends Thread { + long[] ids; + + public MyGetThreadInfoThread(long[] ids) { + this.ids = ids; + this.setDaemon(true); + } + + public void run() { + while (true) { + infos = mbean.getThreadInfo(ids, 0); + goSleep(10); + } + } + } +} diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java index 11694f72837..d9facb13078 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -319,6 +319,7 @@ public class CtwRunner { "-XX:+StressGCM", "-XX:+StressIGVN", "-XX:+StressCCP", + "-XX:+StressLoopPeeling", "-XX:+StressMacroExpansion", "-XX:+StressMacroElimination", "-XX:+StressIncrementalInlining", diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java index ec24d4f186d..20234677929 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java @@ -86,12 +86,10 @@ public class Utils { INITIAL_COMP_LEVEL = 1; } else { String vmName = System.getProperty("java.vm.name"); - String vmInfo = System.getProperty("java.vm.info"); - boolean isEmulatedClient = (vmInfo != null) && vmInfo.contains("emulated-client"); - if (Utils.endsWithIgnoreCase(vmName, " Server VM") && !isEmulatedClient) { + if (Utils.endsWithIgnoreCase(vmName, " Server VM")) { INITIAL_COMP_LEVEL = 4; } else if (Utils.endsWithIgnoreCase(vmName, " Client VM") - || Utils.endsWithIgnoreCase(vmName, " Minimal VM") || isEmulatedClient) { + || Utils.endsWithIgnoreCase(vmName, " Minimal VM")) { INITIAL_COMP_LEVEL = 1; } else { throw new RuntimeException("Unknown VM: " + vmName); diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java index b6881fede75..e4111238b59 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java @@ -165,25 +165,6 @@ public class TestIRMatching { BadFailOnConstraint.create(RunTests.class, "bad1", 2, "Load") ); - runCheck(new String[] {"-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseCompressedClassPointers"}, - BadFailOnConstraint.create(Loads.class, "load", 1, 1, "Load"), - BadFailOnConstraint.create(Loads.class, "load", 1, 3, "LoadI"), - BadCountsConstraint.create(Loads.class, "load", 1, 1, 0), - BadCountsConstraint.create(Loads.class, "load", 1, 2, 1,"Load"), - GoodRuleConstraint.create(Loads.class, "load", 2), - GoodFailOnConstraint.create(Loads.class, "load", 3), - BadCountsConstraint.create(Loads.class, "load", 3, 2, 2,"Store"), - BadFailOnConstraint.create(Loads.class, "load", 4, 2, "Store"), - BadFailOnConstraint.create(Loads.class, "load", 5, "Load"), - BadFailOnConstraint.create(Loads.class, "load", 6, "Load"), - BadFailOnConstraint.create(Loads.class, "load", 7, "Load"), - GoodRuleConstraint.create(Loads.class, "load", 8), - GoodRuleConstraint.create(Loads.class, "load", 9), - GoodRuleConstraint.create(Loads.class, "load", 10), - BadFailOnConstraint.create(Loads.class, "loadKlass", 1), - BadCountsConstraint.create(Loads.class, "loadKlass", 2, 2,"Field") - ); - // Loops runCheck(BadFailOnConstraint.create(Loops.class, "loop", 1, "Loop"), GoodRuleConstraint.create(Loops.class, "loop", 2), @@ -329,7 +310,7 @@ public class TestIRMatching { System.out.flush(); String output = baos.toString(); findIrIds(output, "testMatchAllIf50", 1, 22); - findIrIds(output, "testMatchNoneIf50", -1, -1); + assertNoIds(output, "testMatchNoneIf50"); runWithArguments(FlagComparisons.class, "-XX:TLABRefillWasteFraction=49"); System.out.flush(); @@ -431,12 +412,14 @@ public class TestIRMatching { private static void findIrIds(String output, String method, int... numbers) { StringBuilder builder = new StringBuilder(); - builder.append(method); + builder.append(method).append(": "); for (int i = 0; i < numbers.length; i+=2) { int start = numbers[i]; int endIncluded = numbers[i + 1]; for (int j = start; j <= endIncluded; j++) { - builder.append(","); + if (j != numbers[0]) { + builder.append(", "); + } builder.append(j); } } @@ -445,6 +428,13 @@ public class TestIRMatching { System.lineSeparator())); } } + + private static void assertNoIds(String output, String methodName) { + String applicableIRRules = output.split("Applicable IR Rules")[1]; + if (applicableIRRules.contains(methodName)) { + addException(new RuntimeException("Should not find ids for \"" + methodName + "\"" + System.lineSeparator())); + } + } } class AndOr1 { diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java index 70e4c463c55..8bec7c03bfe 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java @@ -69,8 +69,7 @@ public class TestPhaseIRMatching { List testVMFlags = flagVMProcess.getTestVMFlags(); TestVMProcess testVMProcess = new TestVMProcess(testVMFlags, testClass, null, -1, false, false); TestClassParser testClassParser = new TestClassParser(testClass, false); - Matchable testClassMatchable = testClassParser.parse(testVMProcess.getHotspotPidFileName(), - testVMProcess.getApplicableIRRules()); + Matchable testClassMatchable = testClassParser.parse(testVMProcess.testVmData()); MatchResult result = testClassMatchable.match(); List expectedFails = new ExpectedFailsBuilder().build(testClass); List foundFailures = new FailureBuilder().build(result); diff --git a/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestPrimitiveTypes.java b/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestPrimitiveTypes.java index b1f5f74e682..facaefaa8f3 100644 --- a/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestPrimitiveTypes.java +++ b/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestPrimitiveTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ import static compiler.lib.template_framework.Template.let; import static compiler.lib.template_framework.Template.$; import static compiler.lib.template_framework.Template.addDataName; import static compiler.lib.template_framework.DataName.Mutability.MUTABLE; +import static compiler.lib.template_framework.DataName.Mutability.MUTABLE_OR_IMMUTABLE; import compiler.lib.template_framework.library.Hooks; import compiler.lib.template_framework.library.CodeGenerationDataNameType; @@ -129,7 +130,8 @@ public class TestPrimitiveTypes { } // Finally, test the type by creating some DataNames (variables), and sampling - // from them. There should be no cross-over between the types. + // from them. Sampling exactly should not lead to any conversion and sampling + // subtypes should only lead to widening conversions. // IMPORTANT: since we are adding the DataName via an inserted Template, we // must chose a "transparentScope", so that the DataName escapes. If we // instead chose "scope", the test would fail, because it later @@ -150,6 +152,14 @@ public class TestPrimitiveTypes { """ )); + var assignmentTemplate = Template.make("lhsType", (PrimitiveType lhsType) -> scope( + dataNames(MUTABLE).exactOf(lhsType).sampleAndLetAs("lhs"), + dataNames(MUTABLE_OR_IMMUTABLE).subtypeOf(lhsType).sampleAndLetAs("rhs"), + """ + #lhs = #rhs; + """ + )); + var namesTemplate = Template.make(() -> scope( """ public static void test_names() { @@ -161,10 +171,16 @@ public class TestPrimitiveTypes { ).toList() ), """ - // Now sample: + // Sample exactly: """, Collections.nCopies(10, CodeGenerationDataNameType.PRIMITIVE_TYPES.stream().map(sampleTemplate::asToken).toList() + ), + """ + // Sample subtypes: + """, + Collections.nCopies(10, + CodeGenerationDataNameType.PRIMITIVE_TYPES.stream().map(assignmentTemplate::asToken).toList() ) )), """ @@ -174,6 +190,46 @@ public class TestPrimitiveTypes { tests.put("test_names", namesTemplate.asToken()); + var abbrevDefTemplate = Template.make("type", (PrimitiveType type) -> scope( + let("CON1", type.con()), + let("CON2", type.con()), + let("abbrev", type.abbrev()), + let("fieldDesc", type.fieldDesc()), + """ + static #type varAbbrev#abbrev = #CON1; + static #type varFieldDesc#fieldDesc = #CON2; + """ + )); + var swapTemplate = Template.make("type", (PrimitiveType type) -> scope( + let("abbrev", type.abbrev()), + let("fieldDesc", type.fieldDesc()), + """ + #type tmp#abbrev = varAbbrev#abbrev; + varAbbrev#abbrev = varFieldDesc#fieldDesc; + varFieldDesc#fieldDesc = tmp#abbrev; + """ + )); + var abbrevTemplate = Template.make(() -> scope( + """ + public static void test_abbrev() { + """, + Hooks.CLASS_HOOK.insert(scope( + // Create fields that would collide if the abbrev() or fieldDesc() methods produced colliding + // strings for different types + CodeGenerationDataNameType.PRIMITIVE_TYPES.stream().map(type -> + abbrevDefTemplate.asToken(type) + ).toList() + )), + CodeGenerationDataNameType.PRIMITIVE_TYPES.stream().map(type -> + swapTemplate.asToken(type) + ).toList(), + """ + } + """ + )); + + tests.put("test_abbrev", abbrevTemplate.asToken()); + // Test runtime random value generation with LibraryRNG // Runtime random number generation of a given primitive type can be very helpful // when writing tests that require random inputs. @@ -231,6 +287,9 @@ public class TestPrimitiveTypes { import compiler.lib.generators.*; public class InnerTest { + """, + Hooks.CLASS_HOOK.anchor(scope( + """ public static void main() { """, // Call all test methods from main. @@ -241,7 +300,8 @@ public class TestPrimitiveTypes { } """, // Now add all the test methods. - tests.values().stream().toList(), + tests.values().stream().toList() + )), """ } """ diff --git a/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestTutorial.java b/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestTutorial.java index ed542180bad..7de32d1bc10 100644 --- a/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestTutorial.java +++ b/test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestTutorial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -226,6 +226,8 @@ public class TestTutorial { // we automatically rename the names that have a $ prepended with // var_1, var_2, etc. """ + // You can escape a hashtag by doubling it up. e.g. ## will render as a + // single hashtag. The same goes for $$. int $var = #con; System.out.println("T1: #x, #con, " + $var); """ diff --git a/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestExpression.java b/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestExpression.java index b34538c39c1..609b0936079 100644 --- a/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestExpression.java +++ b/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestExpression.java @@ -41,6 +41,7 @@ import compiler.lib.template_framework.TemplateToken; import static compiler.lib.template_framework.Template.scope; import compiler.lib.template_framework.library.CodeGenerationDataNameType; import compiler.lib.template_framework.library.Expression; +import compiler.lib.template_framework.library.Expression.Nesting; /** * This tests the use of the {@link Expression} from the template library. This is @@ -174,44 +175,74 @@ public class TestExpression { Expression e4 = Expression.make(myTypeA1, "<", myTypeA, ">"); Expression e5 = Expression.make(myTypeA, "[", myTypeB, "]"); - Expression e1e2 = e1.nestRandomly(List.of(e2)); - Expression e1ex = e1.nestRandomly(List.of(e3, e2, e3)); - Expression e1e4 = e1.nestRandomly(List.of(e3, e4, e3)); - Expression e1ey = e1.nestRandomly(List.of(e3, e3)); + Expression e1e2 = e1.nestRandomly(List.of(e2), Nesting.SUBTYPE); + Expression e1e2Exact = e1.nestRandomly(List.of(e2), Nesting.EXACT); + Expression e1ex = e1.nestRandomly(List.of(e3, e2, e3), Nesting.SUBTYPE); + Expression e1exExact = e1.nestRandomly(List.of(e3, e2, e3), Nesting.EXACT); + Expression e1e4 = e1.nestRandomly(List.of(e3, e4, e3), Nesting.SUBTYPE); + Expression e1e4Exact = e1.nestRandomly(List.of(e3, e4, e3), Nesting.EXACT); + Expression e1ey = e1.nestRandomly(List.of(e3, e3), Nesting.SUBTYPE); + Expression e1eyExact = e1.nestRandomly(List.of(e3, e3), Nesting.EXACT); // 5-deep nesting of e1 - Expression deep1 = Expression.nestRandomly(myTypeA, List.of(e1, e3), 5); + Expression deep1 = Expression.nestRandomly(myTypeA, List.of(e1, e3), 5, Nesting.SUBTYPE); + Expression deep1Exact = Expression.nestRandomly(myTypeA, List.of(e1, e3), 5, Nesting.EXACT); // Alternating pattern - Expression deep2 = Expression.nestRandomly(myTypeA, List.of(e5, e3), 5); + Expression deep2 = Expression.nestRandomly(myTypeA, List.of(e5, e3), 5, Nesting.SUBTYPE); + Expression deep2Exact = Expression.nestRandomly(myTypeA, List.of(e5, e3), 5, Nesting.SUBTYPE); var template = Template.make(() -> scope( "xx", e1e2.toString(), "yy\n", + "xx", e1e2Exact.toString(), "yy\n", "xx", e1ex.toString(), "yy\n", + "xx", e1exExact.toString(), "yy\n", "xx", e1e4.toString(), "yy\n", + "xx", e1e4Exact.toString(), "yy\n", "xx", e1ey.toString(), "yy\n", + "xx", e1eyExact.toString(), "yy\n", "xx", deep1.toString(), "yy\n", + "xx", deep1Exact.toString(), "yy\n", "xx", deep2.toString(), "yy\n", + "xx", deep2Exact.toString(), "yy\n", "xx", e1e2.asToken(List.of("a")), "yy\n", + "xx", e1e2Exact.asToken(List.of("a")), "yy\n", "xx", e1ex.asToken(List.of("a")), "yy\n", + "xx", e1exExact.asToken(List.of("a")), "yy\n", "xx", e1e4.asToken(List.of("a")), "yy\n", + "xx", e1e4Exact.asToken(List.of("a")), "yy\n", "xx", e1ey.asToken(List.of("a")), "yy\n", + "xx", e1eyExact.asToken(List.of("a")), "yy\n", "xx", deep1.asToken(List.of("a")), "yy\n", - "xx", deep2.asToken(List.of("a")), "yy\n" + "xx", deep1Exact.asToken(List.of("a")), "yy\n", + "xx", deep2.asToken(List.of("a")), "yy\n", + "xx", deep2Exact.asToken(List.of("a")), "yy\n" )); String expected = """ xxExpression["[(", MyTypeA, ")]"]yy xxExpression["[(", MyTypeA, ")]"]yy + xxExpression["[(", MyTypeA, ")]"]yy + xxExpression["[(", MyTypeA, ")]"]yy xxExpression["[<", MyTypeA, ">]"]yy xxExpression["[", MyTypeA, "]"]yy + xxExpression["[", MyTypeA, "]"]yy + xxExpression["[", MyTypeA, "]"]yy + xxExpression["[[[[[", MyTypeA, "]]]]]"]yy xxExpression["[[[[[", MyTypeA, "]]]]]"]yy xxExpression["[{[{[", MyTypeB, "]}]}]"]yy + xxExpression["[{[{[", MyTypeB, "]}]}]"]yy + xx[(a)]yy + xx[(a)]yy xx[(a)]yy xx[(a)]yy xx[]yy xx[a]yy + xx[a]yy + xx[a]yy xx[[[[[a]]]]]yy + xx[[[[[a]]]]]yy + xx[{[{[a]}]}]yy xx[{[{[a]}]}]yy """; String code = template.render(); diff --git a/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestTemplate.java b/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestTemplate.java index 9be74d232a7..f56a9d5b231 100644 --- a/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestTemplate.java +++ b/test/hotspot/jtreg/testlibrary_tests/template_framework/tests/TestTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8344942 + * @bug 8344942 8364393 * @summary Test some basic Template instantiations. We do not necessarily generate correct * java code, we just test that the code generation deterministically creates the * expected String. @@ -138,6 +138,7 @@ public class TestTemplate { testHookWithNestedTemplates(); testHookRecursion(); testDollar(); + testEscaping(); testLet1(); testLet2(); testDollarAndHashtagBrackets(); @@ -182,7 +183,6 @@ public class TestTemplate { expectRendererException(() -> testFailingDollarName5(), "Is not a valid '$' replacement pattern: '$' in '$'."); expectRendererException(() -> testFailingDollarName6(), "Is not a valid '$' replacement pattern: '$' in 'asdf$'."); expectRendererException(() -> testFailingDollarName7(), "Is not a valid '$' replacement pattern: '$1' in 'asdf$1'."); - expectRendererException(() -> testFailingDollarName8(), "Is not a valid '$' replacement pattern: '$' in 'abc$$abc'."); expectRendererException(() -> testFailingLetName1(), "A hashtag replacement should not be null."); expectRendererException(() -> testFailingHashtagName1(), "Is not a valid hashtag replacement name: ''."); expectRendererException(() -> testFailingHashtagName2(), "Is not a valid hashtag replacement name: 'abc#abc'."); @@ -191,11 +191,12 @@ public class TestTemplate { expectRendererException(() -> testFailingHashtagName5(), "Is not a valid '#' replacement pattern: '#' in '#'."); expectRendererException(() -> testFailingHashtagName6(), "Is not a valid '#' replacement pattern: '#' in 'asdf#'."); expectRendererException(() -> testFailingHashtagName7(), "Is not a valid '#' replacement pattern: '#1' in 'asdf#1'."); - expectRendererException(() -> testFailingHashtagName8(), "Is not a valid '#' replacement pattern: '#' in 'abc##abc'."); expectRendererException(() -> testFailingDollarHashtagName1(), "Is not a valid '#' replacement pattern: '#' in '#$'."); expectRendererException(() -> testFailingDollarHashtagName2(), "Is not a valid '$' replacement pattern: '$' in '$#'."); - expectRendererException(() -> testFailingDollarHashtagName3(), "Is not a valid '#' replacement pattern: '#' in '#$name'."); - expectRendererException(() -> testFailingDollarHashtagName4(), "Is not a valid '$' replacement pattern: '$' in '$#name'."); + expectRendererException(() -> testFailingDollarHashtagName3(), "Found zero sized replacement pattern '#$'."); + expectRendererException(() -> testFailingDollarHashtagName4(), "Found zero sized replacement pattern '$#'."); + expectRendererException(() -> testFailingDollarHashtagName5(), "Found zero sized replacement pattern '#$'."); + expectRendererException(() -> testFailingDollarHashtagName6(), "Found zero sized replacement pattern '$#'."); expectRendererException(() -> testFailingHook(), "Hook 'Hook1' was referenced but not found!"); expectRendererException(() -> testFailingSample1a(), "No Name found for DataName.FilterdSet(MUTABLE, subtypeOf(int), supertypeOf(int))"); expectRendererException(() -> testFailingSample1b(), "No Name found for StructuralName.FilteredSet( subtypeOf(StructuralA) supertypeOf(StructuralA))"); @@ -822,6 +823,60 @@ public class TestTemplate { checkEQ(code, expected); } + public static void testEscaping() { + var template1 = Template.make(() -> scope( + let("one", 1), + let("two", 2), + let("three", 3), + """ + abc##def + abc$$def + abc####def + abc$$$$def + ##abc + $$abc + abc## + abc$$ + ## + $$ + ###### + $$$$$$ + abc###one + abc$$$dollar + #one ###two #####three + ###{one}## + $dollar $$$dollar $$$$$dollar + $$${dollar}$$ + ##$dollar $$#one $$##$$## + """ + )); + + String code = template1.render(); + String expected = + """ + abc#def + abc$def + abc##def + abc$$def + #abc + $abc + abc# + abc$ + # + $ + ### + $$$ + abc#1 + abc$dollar_1 + 1 #2 ##3 + #1# + dollar_1 $dollar_1 $$dollar_1 + $dollar_1$ + #dollar_1 $1 $#$# + """; + checkEQ(code, expected); + } + public static void testLet1() { var hook1 = new Hook("Hook1"); @@ -3382,13 +3437,6 @@ public class TestTemplate { String code = template1.render(); } - public static void testFailingDollarName8() { - var template1 = Template.make(() -> scope( - "abc$$abc" // empty dollar name - )); - String code = template1.render(); - } - public static void testFailingLetName1() { var template1 = Template.make(() -> scope( let(null, $("abc")) // Null input for hashtag name @@ -3447,13 +3495,6 @@ public class TestTemplate { String code = template1.render(); } - public static void testFailingHashtagName8() { - var template1 = Template.make(() -> scope( - "abc##abc" // empty hashtag name - )); - String code = template1.render(); - } - public static void testFailingDollarHashtagName1() { var template1 = Template.make(() -> scope( "#$" // empty hashtag name @@ -3470,14 +3511,28 @@ public class TestTemplate { public static void testFailingDollarHashtagName3() { var template1 = Template.make(() -> scope( - "#$name" // empty hashtag name + "#$name" // Zero sized replacement )); String code = template1.render(); } public static void testFailingDollarHashtagName4() { var template1 = Template.make(() -> scope( - "$#name" // empty dollar name + "$#name" // Zero sized replacement + )); + String code = template1.render(); + } + + public static void testFailingDollarHashtagName5() { + var template1 = Template.make(() -> scope( + "asdf#$abc" // Zero sized replacement + )); + String code = template1.render(); + } + + public static void testFailingDollarHashtagName6() { + var template1 = Template.make(() -> scope( + "asdf$#abc" // Zero sized replacement )); String code = template1.render(); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001.java index 09fdb1ae3f7..cf840e56c07 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,6 @@ package nsk.jvmti.CompiledMethodUnload; import java.io.*; -import java.math.*; -import java.util.*; import nsk.share.*; import nsk.share.jvmti.*; @@ -93,8 +91,11 @@ public class compmethunload001 { hotCls = null; c = null; - boolean clsUnloaded = clsUnLoader.unloadClass(); - clsUnLoader = null; + // BackgroundCompilation is on by default so wait for compiler threads + // to drop references to the to-be-unloaded class. + if (!clsUnLoader.unloadClassAndWait(10_000)) { + throw new Failure("Class should have been unloaded"); + } } private int runThis(String argv[], PrintStream out) throws Exception { @@ -114,7 +115,7 @@ public class compmethunload001 { num = unloaded(); iter++; if (iter > MAX_ITERATIONS) { - throw new Failure("PRODUCT BUG: class was not unloaded in " + MAX_ITERATIONS); + throw new Failure("PRODUCT BUG: no classunloading callback in " + MAX_ITERATIONS); } } System.out.println("Number of unloaded events " + num + " number of iterations " + iter); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/ClassUnloader.java b/test/hotspot/jtreg/vmTestbase/nsk/share/ClassUnloader.java index 5c7d2b8d640..8f473bf60c5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/ClassUnloader.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ClassUnloader.java @@ -33,6 +33,7 @@ import java.util.*; import nsk.share.gc.gp.*; import nsk.share.test.ExecutionController; import nsk.share.test.Stresser; +import jdk.test.lib.Utils; import jdk.test.whitebox.WhiteBox; /** @@ -231,45 +232,49 @@ public class ClassUnloader { * Forces GC to unload previously loaded classes by cleaning all references * to class loader with its loaded classes. * - * @return true if classes unloading has been detected + * @return true if the class has been unloaded or false otherwise * - * @throws Failure if exception other than OutOfMemoryError - * is thrown while triggering full GC - * * @see WhiteBox.getWhiteBox().fullGC() */ - - public static final int MAX_UNLOAD_ATTEMPS = 10; - public boolean unloadClass() { - // free references to class and class loader to be able for collecting by GC classObjects.removeAllElements(); customClassLoader = null; // force class unloading by triggering full GC WhiteBox.getWhiteBox().fullGC(); - int count = 0; - while (count++ < MAX_UNLOAD_ATTEMPS && !isClassLoaderReclaimed()) { - System.out.println("ClassUnloader: waiting for class loader reclaiming... " + count); - WhiteBox.getWhiteBox().fullGC(); - try { - // small delay to give more changes to process objects - // inside VM like jvmti deferred queue - Thread.sleep(100); - } catch (InterruptedException e) { - } - } - // force GC to unload marked class loader and its classes if (isClassLoaderReclaimed()) { System.out.println("ClassUnloader: class loader has been reclaimed."); return true; + } else { + System.out.println("ClassUnloader: class loader is still reachable."); + return false; } + } - // class loader has not been reclaimed - System.out.println("ClassUnloader: class loader is still reachable."); - return false; + /** + * Forces GC to unload previously loaded classes by cleaning all references + * to class loader with its loaded classes and wait for class loader to be reclaimed. + * + * @param timeout max time to wait for class loader to be reclaimed in milliseconds + * @return true if the class has been unloaded + or false otherwise + */ + public boolean unloadClassAndWait(long timeout) { + timeout = Utils.adjustTimeout(timeout); + boolean wasUnloaded; + final long waitTime = 100; + do { + try { + Thread.sleep(waitTime); + } catch (InterruptedException e) { + // ignore + } + timeout -= waitTime; + wasUnloaded = unloadClass(); + } while (!wasUnloaded && timeout > 0); + return wasUnloaded; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java index 74516fd5a69..ec4dcd87d67 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2026, 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,18 @@ public class AbstractDebuggeeTest { ClassUnloader classUnloader = loadedClasses.get(className); if (classUnloader != null) { - boolean wasUnloaded = classUnloader.unloadClass(); + boolean wasUnloaded; + if (expectedUnloadingResult) { + // We expect unloading to succeed. Retry multiple times because + // the debug agent creates global references (NewGlobalRef) + // when handling ClassPrepare events. These global references + // are released only by the agent thread, whose scheduling can + // be delayed, causing class unloading to occur later than + // expected. + wasUnloaded = classUnloader.unloadClassAndWait(10_000); + } else { + wasUnloaded = classUnloader.unloadClass(); + } if (wasUnloaded) loadedClasses.remove(className); diff --git a/test/jaxp/TEST.ROOT b/test/jaxp/TEST.ROOT index aff3b769830..ddf29839e20 100644 --- a/test/jaxp/TEST.ROOT +++ b/test/jaxp/TEST.ROOT @@ -29,8 +29,3 @@ requiredVersion=8.2.1+1 # does not need ../../ notation to reach them external.lib.roots = ../../ -# Use new module options -useNewOptions=true - -# Use --patch-module instead of -Xmodule: -useNewPatchModule=true diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java index 0447270d99a..612011f8eb6 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,18 +23,20 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.CatalogReferCircularityTest + * @run junit/othervm catalog.CatalogReferCircularityTest * @summary Via nextCatalog entry, the catalog reference chain may be * a (partial) closed circuit. For instance, a catalog may use itself * as an additional catalog specified in its own nextCatalog entry. @@ -42,22 +44,19 @@ import org.testng.annotations.Test; */ public class CatalogReferCircularityTest { - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) + @ParameterizedTest + @ValueSource(strings={ + // This catalog defines itself as next catalog. + "catalogReferCircle-itself.xml", + + // This catalog defines catalogReferCircle-right.xml as its next + // catalog. And catalogReferCircle-right.xml also defines + // catalogReferCircle-left.xml as its next catalog, too. + "catalogReferCircle-left.xml" }) public void testReferCircularity(String catalogFile) { - catalogResolver(catalogFile).resolveEntity(null, - "http://remote/dtd/ghost/docGhost.dtd"); - } - - @DataProvider(name = "catalogName") - public Object[][] catalogName() { - return new Object[][] { - // This catalog defines itself as next catalog. - { "catalogReferCircle-itself.xml" }, - - // This catalog defines catalogReferCircle-right.xml as its next - // catalog. And catalogReferCircle-right.xml also defines - // catalogReferCircle-left.xml as its next catalog, too. - { "catalogReferCircle-left.xml" } }; + CatalogResolver resolver = catalogResolver(catalogFile); + assertThrows( + CatalogException.class, + () -> resolver.resolveEntity(null, "http://remote/dtd/ghost/docGhost.dtd")); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java index d76b56d7510..f17aa04ac76 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java @@ -23,42 +23,30 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DefaultFeaturesTest + * @run junit/othervm catalog.DefaultFeaturesTest * @summary This case tests if the default feature values are expected. */ public class DefaultFeaturesTest { - - private CatalogFeatures defaultFeature; - - @BeforeClass - public void init() { - defaultFeature = CatalogFeatures.defaults(); - } - - @Test(dataProvider="feature-value") + @ParameterizedTest + @MethodSource("defaultFeaturesData") public void testDefaultFeatures(Feature feature, String expected) { - String featureValue = defaultFeature.get(feature); - if (expected != null) { - Assert.assertEquals(featureValue, expected); - } else { - Assert.assertNull(featureValue); - } + CatalogFeatures defaultFeature = CatalogFeatures.defaults(); + assertEquals(expected, defaultFeature.get(feature)); } - @DataProvider(name = "feature-value") - public Object[][] data() { + public static Object[][] defaultFeaturesData() { return new Object[][] { { Feature.FILES, null }, { Feature.PREFER, CatalogTestUtils.PREFER_PUBLIC }, diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index 2d5771557ad..36335cb586d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -23,42 +23,43 @@ package catalog; -import static catalog.CatalogTestUtils.DEFER_FALSE; -import static catalog.CatalogTestUtils.DEFER_TRUE; -import static catalog.CatalogTestUtils.getCatalogPath; -import static javax.xml.catalog.CatalogFeatures.Feature.DEFER; - -import java.lang.reflect.Method; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.Catalog; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; +import java.lang.reflect.Method; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.DEFER_FALSE; +import static catalog.CatalogTestUtils.DEFER_TRUE; +import static catalog.CatalogTestUtils.getCatalogPath; +import static javax.xml.catalog.CatalogFeatures.Feature.DEFER; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 8077931 8176405 * @library /javax/xml/jaxp/libs * @modules java.xml/javax.xml.catalog:open - * @run testng/othervm catalog.DeferFeatureTest + * @run junit/othervm catalog.DeferFeatureTest * @summary This case tests whether the catalogs specified in delegateSystem, * delegatePublic, delegateURI and nextCatalog entries are used lazily * in resolution via defer feature. */ public class DeferFeatureTest { - @Test(dataProvider = "catalog-countOfLoadedCatalogFile") + @ParameterizedTest + @MethodSource("deferData") public void testDeferFeature(Catalog catalog, int catalogCount) throws Exception { - Assert.assertEquals(loadedCatalogCount(catalog), catalogCount); + assertEquals(catalogCount, loadedCatalogCount(catalog)); } - @Test(dataProvider = "testDeferFeatureByResolve") + @ParameterizedTest + @MethodSource("deferByResolveData") public void testDeferFeatureByResolve(Catalog catalog, int catalogCount) throws Exception { CatalogResolver cr = createResolver(catalog); @@ -67,41 +68,39 @@ public class DeferFeatureTest { cr.resolveEntity("-//REMOTE//DTD ALICE DOCALICE", "http://remote/dtd/alice/"); } catch (CatalogException ce) {} - Assert.assertEquals(loadedCatalogCount(catalog), catalogCount); + assertEquals(catalogCount, loadedCatalogCount(catalog)); } - @DataProvider(name = "catalog-countOfLoadedCatalogFile") - public Object[][] data() { - return new Object[][]{ - // By default, alternative catalogs are not loaded. - {createCatalog(CatalogFeatures.defaults()), 1}, - // Alternative catalogs are not loaded when DEFER is set to true. - {createCatalog(createDeferFeature(DEFER_TRUE)), 1}, - // The 3 alternative catalogs are pre-loaded along with the parent - //when DEFER is set to false. - {createCatalog(createDeferFeature(DEFER_FALSE)), 4}}; + public static Object[][] deferData() { + return new Object[][] { + // By default, alternative catalogs are not loaded. + { createCatalog(CatalogFeatures.defaults()), 1 }, + // Alternative catalogs are not loaded when DEFER is set to true. + { createCatalog(createDeferFeature(DEFER_TRUE)), 1 }, + // The 3 alternative catalogs are pre-loaded along with the parent + //when DEFER is set to false. + { createCatalog(createDeferFeature(DEFER_FALSE)), 4 } }; } - @DataProvider(name = "testDeferFeatureByResolve") - public Object[][] getData() { - return new Object[][]{ - {createCatalog(createDeferFeature(DEFER_TRUE)), 4} + public static Object[][] deferByResolveData() { + return new Object[][] { + { createCatalog(createDeferFeature(DEFER_TRUE)), 4 } }; } - private CatalogFeatures createDeferFeature(String defer) { + private static CatalogFeatures createDeferFeature(String defer) { return CatalogFeatures.builder().with(DEFER, defer).build(); } - private Catalog createCatalog(CatalogFeatures feature) { + private static Catalog createCatalog(CatalogFeatures feature) { return CatalogManager.catalog(feature, getCatalogPath("deferFeature.xml")); } - private CatalogResolver createResolver(Catalog catalog) { + private static CatalogResolver createResolver(Catalog catalog) { return CatalogManager.catalogResolver(catalog); } - private int loadedCatalogCount(Catalog catalog) throws Exception { + private static int loadedCatalogCount(Catalog catalog) throws Exception { Method method = catalog.getClass().getDeclaredMethod("loadedCatalogCount"); method.setAccessible(true); return (int) method.invoke(catalog); diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java index 43c6bf42f44..579140825c2 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkPubIdResolution; -import static catalog.ResolutionChecker.expectExceptionOnPubId; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static catalog.ResolutionChecker.expectExceptionOnPubId; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegatePublicTest + * @run junit/othervm catalog.DelegatePublicTest * @summary Get matched URIs from DelegatePublic entries. */ public class DelegatePublicTest { - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String publicId, String matchedUri) { checkPubIdResolution(createResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified public id is defined in // a delegate catalog file of the current catalog file. @@ -71,15 +71,15 @@ public class DelegatePublicTest { "http://local/base/dtd/carl/docCarlPub.dtd" } }; } - @Test(dataProvider = "publicId-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String publicId, Class expectedExceptionClass) { expectExceptionOnPubId(createResolver(), publicId, expectedExceptionClass); } - @DataProvider(name = "publicId-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegatePublic entry of the specified public id // defines a non-existing delegate catalog file. That should @@ -93,7 +93,7 @@ public class DelegatePublicTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("delegatePublic.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java index 554d23776f9..27da1105b2c 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkSysIdResolution; -import static catalog.ResolutionChecker.expectExceptionOnSysId; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static catalog.ResolutionChecker.expectExceptionOnSysId; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegateSystemTest + * @run junit/othervm catalog.DelegateSystemTest * @summary Get matched URIs from delegateSystem entries. */ public class DelegateSystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in // a delegate catalog file of the current catalog file. @@ -71,15 +71,15 @@ public class DelegateSystemTest { "http://local/base/dtd/carl/docCarlDS.dtd"} }; } - @Test(dataProvider = "systemId-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String systemId, Class expectedExceptionClass) { expectExceptionOnSysId(createResolver(), systemId, expectedExceptionClass); } - @DataProvider(name = "systemId-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegateSystem entry of the specified system id // defines a non-existing delegate catalog file. That should @@ -93,7 +93,7 @@ public class DelegateSystemTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("delegateSystem.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java index 2a92149a730..0175a99f938 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java @@ -23,32 +23,32 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkUriResolution; import static catalog.ResolutionChecker.expectExceptionOnUri; -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegateUriTest + * @run junit/othervm catalog.DelegateUriTest * @summary Get matched URIs from delegateURI entries. */ public class DelegateUriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] data() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a delegate catalog file of the current catalog file. @@ -71,14 +71,14 @@ public class DelegateUriTest { "http://local/base/dtd/carl/docCarlDU.dtd"} }; } - @Test(dataProvider = "uri-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String uri, Class expectedExceptionClass) { expectExceptionOnUri(createResolver(), uri, expectedExceptionClass); } - @DataProvider(name = "uri-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegateURI entry of the specified URI reference // defines a non-existing delegate catalog file. That should @@ -92,7 +92,7 @@ public class DelegateUriTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("delegateUri.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java index 7516be7d560..37910c2b1f5 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.GroupTest + * @run junit/othervm catalog.GroupTest * @summary Get matched URIs from system, public and uri entries respectively, * and some of the entries are enclosed by group entries. */ @@ -46,13 +46,13 @@ public class GroupTest { private static final String CATALOG_GROUP = "group.xml"; - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataMatchSysId") public void testMatchOnSysId(String uri, String matchedUri) { checkSysIdResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnSysId() { + public static Object[][] dataMatchSysId() { return new Object[][] { // The matched URI of the specified system id is enclosed by a // group entry. @@ -72,13 +72,13 @@ public class GroupTest { "http://local/base/dtd/docCarlSys1.dtd" } }; } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatchPubId") public void testMatchOnPubId(String uri, String matchedUri) { checkPubIdResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnMatchPubId() { return new Object[][] { // The matched URI of the specified public id is enclosed by a // group entry. @@ -98,13 +98,13 @@ public class GroupTest { "http://local/base/dtd/docCarlPub1.dtd" } }; } - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatchUri") public void testMatchOnUri(String uri, String matchedUri) { checkUriResolution(catalogUriResolver(CATALOG_GROUP), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnUri() { + public static Object[][] dataOnMatchUri() { return new Object[][] { // The matched URI of the specified URI reference is enclosed by // a group entry. @@ -124,7 +124,7 @@ public class GroupTest { "http://local/base/dtd/docAliceURI.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_GROUP); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java index 6a5248b8f9f..481c2fa1f83 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java @@ -23,6 +23,12 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_PUBLIC; import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; @@ -30,18 +36,13 @@ import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.LoadCatalogTest + * @run junit/othervm catalog.LoadCatalogTest * @summary When catalog resolver loads catalog files, the current catalog file * and the catalog files specified by the nextCatalog entries may not * accessible. This case tests how does the resolver handle this issue. @@ -55,14 +56,14 @@ public class LoadCatalogTest { private static final String ID_ALICE_URI = "http://remote/dtd/uri/alice/docAlice.dtd"; private static final String ID_DUMMY = "http://remote/dtd/doc.dtd"; - @Test(dataProvider = "entityResolver") + @ParameterizedTest + @MethodSource("entityResolver") public void testMatchOnEntityResolver(CatalogResolver resolver) { checkSysIdResolution(resolver, ID_ALICE, "http://local/dtd/docAliceSys.dtd"); } - @DataProvider(name = "entityResolver") - public Object[][] entityResolver() { + public static Object[][] entityResolver() { return new Object[][] { // This EntityResolver loads multiple catalog files one by one. // All of the files are available. @@ -75,14 +76,14 @@ public class LoadCatalogTest { CATALOG_SYSTEM) } }; } - @Test(dataProvider = "uriResolver") + @ParameterizedTest + @MethodSource("uriResolver") public void testMatchOnUriResolver(CatalogResolver resolver) { checkUriResolution(resolver, ID_ALICE_URI, "http://local/dtd/docAliceURI.dtd"); } - @DataProvider(name = "uriResolver") - public Object[][] uriResolver() { + public static Object[][] uriResolver() { return new Object[][] { // This URIResolver loads multiple catalog files one by one. // All of the files are available. @@ -95,20 +96,21 @@ public class LoadCatalogTest { CATALOG_URI) } }; } - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) - public void testExceptionOnEntityResolver(String[] catalogName) { - catalogResolver(catalogName).resolveEntity(null, ID_DUMMY); + @ParameterizedTest + @MethodSource("catalogName") + public void testException(String[] catalogName) { + CatalogResolver resolver = catalogResolver(catalogName); + assertThrows(CatalogException.class, () -> resolver.resolveEntity(null, ID_DUMMY)); } - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) + @ParameterizedTest + @MethodSource("catalogName") public void testExceptionOnUriResolver(String[] catalogName) { - catalogUriResolver(catalogName).resolve(ID_DUMMY, null); + CatalogResolver resolver = catalogUriResolver(catalogName); + assertThrows(CatalogException.class, () -> resolver.resolve(ID_DUMMY, null)); } - @DataProvider(name = "catalogName") - public Object[][] catalogName() { + public static Object[][] catalogName() { return new Object[][] { // This catalog file set includes null catalog files. { (String[]) null }, diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java index d7e0711636d..ff56b86a500 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.NextCatalogTest + * @run junit/othervm catalog.NextCatalogTest * @summary Get matched URIs from system, public and uri entries respectively, * but some of the entries are defined in none-current catalog files. */ @@ -49,13 +49,13 @@ public class NextCatalogTest { private static final String CATALOG_NEXTCATALOGRIGHT = "nextCatalog-right.xml"; - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysId") public void testNextCatalogOnSysId(String sytemId, String matchedUri) { checkSysIdResolution(createEntityResolver(), sytemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnSysId() { + public static Object[][] dataOnSysId() { return new Object[][] { // This matched URI of the specified system id is defined in a // next catalog file. @@ -81,13 +81,13 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftSys.dtd" } }; } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnPubId") public void testNextCatalogOnPubId(String publicId, String matchedUri) { checkPubIdResolution(createEntityResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnPubId() { return new Object[][] { // This matched URI of the specified public id is defined in a // next catalog file. @@ -113,13 +113,13 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftPub.dtd" } }; } - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnUri") public void testNextCatalogOnUri(String uri, String matchedUri) { checkUriResolution(createUriResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnUri() { + public static Object[][] dataOnUri() { return new Object[][] { // This matched URI of the specified URI reference is defined in // a next catalog file. @@ -145,12 +145,12 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftURI.dtd" } }; } - private CatalogResolver createEntityResolver() { + private static CatalogResolver createEntityResolver() { return catalogResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } - private CatalogResolver createUriResolver() { + private static CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java index 74fc25e90c1..0a112fd7426 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.NormalizationTest + * @run junit/othervm catalog.NormalizationTest * @summary Before matching identifiers and URI references, it has to normalize * the passed identifiers and URI references. And then the catalog * resolver uses the normalized stuff to search the counterparts in @@ -48,23 +48,25 @@ public class NormalizationTest { private static final String CATALOG_NORMALIZATION = "normalization.xml"; - @Test(dataProvider = "systemId_uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysIdAndUri") public void testNormalizationOnSysId(String sytemId, String matchedUri) { checkSysIdResolution(createEntityResolver(), sytemId, matchedUri); } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnPubId") public void testNormalizationOnPubId(String publicId, String matchedUri) { checkPubIdResolution(createEntityResolver(), publicId, matchedUri); } - @Test(dataProvider = "systemId_uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysIdAndUri") public void testNormalizationOnUri(String uri, String matchedUri) { checkUriResolution(createUriResolver(), uri, matchedUri); } - @DataProvider(name = "systemId_uri-matchedUri") - public Object[][] dataOnSysIdAndUri() { + public static Object[][] dataOnSysIdAndUri() { return new Object[][] { // The specified system id/URI reference contains spaces. And // the counterparts in system/uri entries also contain spaces. @@ -85,8 +87,7 @@ public class NormalizationTest { "http://local/base/dtd/docBobSys.dtd" } }; } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnPubId() { return new Object[][] { // The specified public id contains spaces. And the counterparts // in public entry also contains spaces. @@ -103,11 +104,11 @@ public class NormalizationTest { "http://local/base/dtd/docBobPub.dtd" } }; } - private CatalogResolver createEntityResolver() { + private static CatalogResolver createEntityResolver() { return catalogResolver(CATALOG_NORMALIZATION); } - private CatalogResolver createUriResolver() { + private static CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NORMALIZATION); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java index 85cb2505244..4f9cfcd1f82 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java @@ -23,38 +23,38 @@ package catalog; -import static catalog.CatalogTestUtils.PREFER_PUBLIC; -import static catalog.CatalogTestUtils.PREFER_SYSTEM; -import static catalog.CatalogTestUtils.catalogResolver; -import static javax.xml.catalog.CatalogFeatures.Feature.PREFER; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.PREFER_PUBLIC; +import static catalog.CatalogTestUtils.PREFER_SYSTEM; +import static catalog.CatalogTestUtils.catalogResolver; +import static javax.xml.catalog.CatalogFeatures.Feature.PREFER; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PreferFeatureTest + * @run junit/othervm catalog.PreferFeatureTest * @summary This case tests how does the feature affect the catalog resolution, * and tests the priority between this feature and attribute prefer * in catalog file. */ public class PreferFeatureTest { - @Test(dataProvider = "prefer-publicId-systemId", - expectedExceptions = CatalogException.class) - public void testPreferFeature(String prefer, String systemId, - String publicId) { - createResolver(prefer).resolveEntity(systemId, publicId); + @ParameterizedTest + @MethodSource("data") + public void testPreferFeature(String prefer, String systemId, String publicId) { + CatalogResolver resolver = createResolver(prefer); + assertThrows(CatalogException.class, () -> resolver.resolveEntity(systemId, publicId)); } - @DataProvider(name = "prefer-publicId-systemId") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The feature prefer is system. There's a match for the // specified public id, and no match for the specified system id. @@ -72,7 +72,7 @@ public class PreferFeatureTest { "http://remote/dtd/bob/docBobDummy.dtd"} }; } - private CatalogResolver createResolver(String prefer) { + private static CatalogResolver createResolver(String prefer) { return catalogResolver( CatalogFeatures.builder().with(PREFER, prefer).build(), "preferFeature.xml"); diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java index 6bcbd140466..c358ff85c62 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java @@ -23,19 +23,19 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkExtIdResolution; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkExtIdResolution; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PreferTest + * @run junit/othervm catalog.PreferTest * @summary Get matched URIs from system and public family entries, which * specify the prefer attribute. It tests how does the prefer attribute * affect the resolution procedure. The test rule is based on OASIS @@ -43,14 +43,14 @@ import org.testng.annotations.Test; */ public class PreferTest { - @Test(dataProvider = "publicId-systemId-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testPrefer(String publicId, String systemId, String expected) { checkExtIdResolution(createResolver(), publicId, systemId, expected); } - @DataProvider(name = "publicId-systemId-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The prefer attribute is public. Both of the specified public // id and system id have matches in the catalog file. But @@ -85,7 +85,7 @@ public class PreferTest { "http://local/base/dtd/docBobSys.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("prefer.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java index 42dc6bbe215..44a0d46537f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java @@ -23,20 +23,21 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.api.Test; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PublicFamilyTest + * @run junit/othervm catalog.PublicFamilyTest * @summary Get matched URIs from public and delegatePublic entries. * It tests the resolution priorities among the public family entries. * The test rule is based on OASIS Standard V1.1 section 7.1.2. @@ -58,12 +59,12 @@ public class PublicFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) - public void testNoMatched() { - checkNoMatch(createResolver()); + @Test + public void testNoMatch() { + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("publicFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java index d44dca87732..fe137eac6e9 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java @@ -23,33 +23,35 @@ package catalog; -import static catalog.CatalogTestUtils.CATALOG_PUBLIC; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.CATALOG_PUBLIC; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PublicTest + * @run junit/othervm catalog.PublicTest * @summary Get matched URIs from public entries. */ public class PublicTest { - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testPublic(String publicId, String matchedUri) { checkPubIdResolution(createResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The matched URI of the specified public id is defined in a // public entry. The match is an absolute path. @@ -80,12 +82,12 @@ public class PublicTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_PUBLIC); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java index 0626e83bed9..a642f751a7f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java @@ -23,6 +23,13 @@ package catalog; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogFeatures.Feature; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.RESOLVE_CONTINUE; @@ -33,19 +40,13 @@ import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; import static javax.xml.catalog.CatalogFeatures.builder; - -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogFeatures; -import javax.xml.catalog.CatalogFeatures.Feature; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.ResolveFeatureTest + * @run junit/othervm catalog.ResolveFeatureTest * @summary This case tests how does resolve feature affect the catalog * resolution. */ @@ -55,20 +56,24 @@ public class ResolveFeatureTest { * For strict external identifier resolution, if no match is found, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testStrictResolutionOnEntityResolver() { - createEntityResolver(RESOLVE_STRICT).resolveEntity(null, - "http://remote/dtd/alice/docAliceDummy.dtd"); + CatalogResolver resolver = createEntityResolver(RESOLVE_STRICT); + assertThrows( + CatalogException.class, + () -> resolver.resolveEntity(null, "http://remote/dtd/alice/docAliceDummy.dtd")); } /* * For strict URI reference resolution, if no match is found, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testStrictResolutionOnUriResolver() { - createUriResolver(RESOLVE_STRICT).resolve( - "http://remote/dtd/alice/docAliceDummy.dtd", null); + CatalogResolver resolver = createUriResolver(RESOLVE_STRICT); + assertThrows( + CatalogException.class, + () -> resolver.resolve("http://remote/dtd/alice/docAliceDummy.dtd", null)); } /* @@ -115,15 +120,15 @@ public class ResolveFeatureTest { "http://remote/dtd/carl/docCarlDummy.dtd", null); } - private CatalogResolver createEntityResolver(String resolve) { + private static CatalogResolver createEntityResolver(String resolve) { return catalogResolver(createFeature(resolve), CATALOG_SYSTEM); } - private CatalogResolver createUriResolver(String resolve) { + private static CatalogResolver createUriResolver(String resolve) { return catalogUriResolver(createFeature(resolve), CATALOG_URI); } - private CatalogFeatures createFeature(String resolve) { + private static CatalogFeatures createFeature(String resolve) { return builder().with(Feature.RESOLVE, resolve).build(); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java index 647fccd49fb..6c6cc752b98 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java @@ -23,32 +23,34 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.RewriteSystemTest + * @run junit/othervm catalog.RewriteSystemTest * @summary Get matched URIs from rewriteSystem entries. */ public class RewriteSystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // rewriteSystem entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class RewriteSystemTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("rewriteSystem.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java index d7b98b96f11..1498f866c11 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java @@ -23,32 +23,34 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.RewriteUriTest + * @run junit/othervm catalog.RewriteUriTest * @summary Get matched URIs from rewriteURI entries. */ public class RewriteUriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a rewriteURI entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class RewriteUriTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("rewriteUri.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java index 61c59d4049c..d1795f6a45d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java @@ -23,7 +23,10 @@ package catalog; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogResolver; import static catalog.CatalogTestUtils.FEATURE_FILES; import static catalog.CatalogTestUtils.catalogResolver; @@ -31,19 +34,14 @@ import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.CatalogTestUtils.getCatalogPath; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import static javax.xml.catalog.CatalogFeatures.builder; import static javax.xml.catalog.CatalogFeatures.Feature.FILES; - -import javax.xml.catalog.CatalogFeatures; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.Test; +import static javax.xml.catalog.CatalogFeatures.builder; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SpecifyCatalogTest + * @run junit/othervm catalog.SpecifyCatalogTest * @summary This case tests how to specify the catalog files. */ public class SpecifyCatalogTest { @@ -77,7 +75,7 @@ public class SpecifyCatalogTest { */ @Test public void specifyCatalogViaSysProps() { - setSystemProperty(FEATURE_FILES, + System.setProperty(FEATURE_FILES, getCatalogPath("specifyCatalog-sysProps.xml").toASCIIString()); checkResolutionOnEntityResolver(catalogResolver((String[]) null), @@ -93,13 +91,13 @@ public class SpecifyCatalogTest { "http://local/base/dtd/docAPIURI.dtd"); } - private void checkResolutionOnEntityResolver(CatalogResolver resolver, - String matchedUri) { + private static void checkResolutionOnEntityResolver(CatalogResolver resolver, + String matchedUri) { checkSysIdResolution(resolver, ID_SYS, matchedUri); } - private void checkResolutionOnUriResolver(CatalogResolver resolver, - String matchedUri) { + private static void checkResolutionOnUriResolver(CatalogResolver resolver, + String matchedUri) { checkUriResolution(resolver, ID_URI, matchedUri); } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java index ec614332207..927aa65db66 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java @@ -23,21 +23,23 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemFamilyTest + * @run junit/othervm catalog.SystemFamilyTest * @summary Get matched URIs from system, rewriteSystem, systemSuffix and * delegateSystem entries. It tests the resolution priorities among * the system family entries. The test rule is based on OASIS @@ -45,13 +47,13 @@ import org.testng.annotations.Test; */ public class SystemFamilyTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // system entry. @@ -72,12 +74,12 @@ public class SystemFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("systemFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java index 2a40b581654..6890cc2a4c8 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java @@ -23,32 +23,34 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemSuffixTest + * @run junit/othervm catalog.SystemSuffixTest * @summary Get matched URIs from systemSuffix entries. */ public class SystemSuffixTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // systemIdSuffix entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class SystemSuffixTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("systemSuffix.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java index 73c11340b29..53909c4bd5a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java @@ -23,33 +23,35 @@ package catalog; -import static catalog.CatalogTestUtils.CATALOG_SYSTEM; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.CATALOG_SYSTEM; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemTest + * @run junit/othervm catalog.SystemTest * @summary Get matched URIs from system entries. */ public class SystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // system entry. The match is an absolute path. @@ -80,12 +82,12 @@ public class SystemTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_SYSTEM); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java index 44c9afcfa13..36b8d98ee1f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java @@ -23,21 +23,23 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriFamilyTest + * @run junit/othervm catalog.UriFamilyTest * @summary Get matched URIs from uri, rewriteURI, uriSuffix and delegateURI * entries. It tests the resolution priorities among the uri family * entries. The test rule is based on OASIS Standard V1.1 section @@ -45,13 +47,13 @@ import org.testng.annotations.Test; */ public class UriFamilyTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkUriResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. @@ -72,12 +74,12 @@ public class UriFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("uriFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java index 8feadb03fa2..2bbe63a374a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java @@ -23,32 +23,34 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriSuffixTest + * @run junit/othervm catalog.UriSuffixTest * @summary Get matched URIs from rewriteURI entries. */ public class UriSuffixTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uriSuffix entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class UriSuffixTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("uriSuffix.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java index cf76eada5e7..651b2753713 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java @@ -23,35 +23,37 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.RESOLVE_CONTINUE; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogFeatures; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriTest + * @run junit/othervm catalog.UriTest * @summary Get matched URIs from uri entries. */ public class UriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. The match is an absolute path. @@ -92,12 +94,12 @@ public class UriTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver(CATALOG_URI); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java index f3b99074e98..765e315bd6e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkPubIdResolution; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UrnUnwrappingTest + * @run junit/othervm catalog.UrnUnwrappingTest * @summary If the passed public identifier is started with "urn:publicid:", * it has to be regarded as URN and normalized. And then the catalog * resolver uses the normalized stuff to do matching. */ public class UrnUnwrappingTest { - @Test(dataProvider = "urn-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testUnwrapping(String urn, String matchedUri) { checkPubIdResolution(createResolver(), urn, matchedUri); } - @DataProvider(name = "urn-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The specified public id is URN format. { "urn:publicid:-:REMOTE:DTD+ALICE+DOCALICE+XML:EN", @@ -60,7 +60,7 @@ public class UrnUnwrappingTest { "http://local/base/dtd/docBobPub.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("urnUnwrapping.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java index 04676557ea4..c8316c085a2 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java @@ -23,22 +23,23 @@ package catalog; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogException; + import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.ValidateCatalogTest + * @run junit/othervm catalog.ValidateCatalogTest * @summary A legal catalog file must be well-formed XML, the root element * must be catalog, and the naming space of the root element must be * urn:oasis:names:tc:entity:xmlns:xml:catalog. @@ -52,36 +53,36 @@ public class ValidateCatalogTest { * EntityResolver tries to load catalog with wrong root, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void validateWrongRootCatalogOnEntityResolver() { - catalogResolver(CATALOG_WRONGROOT); + assertThrows(CatalogException.class, () -> catalogResolver(CATALOG_WRONGROOT)); } /* * URIResolver tries to load catalog with wrong root, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void validateWrongRootCatalogOnUriResolver() { - catalogUriResolver(CATALOG_WRONGROOT); + assertThrows(CatalogException.class, () -> catalogUriResolver(CATALOG_WRONGROOT)); } /* * EntityResolver tries to load malformed catalog, * it should throw RuntimeException. */ - @Test(expectedExceptions = RuntimeException.class) + @Test public void validateMalformedCatalogOnEntityResolver() { - catalogResolver(CATALOG_MALFORMED); + assertThrows(RuntimeException.class, () -> catalogResolver(CATALOG_MALFORMED)); } /* * UriResolver tries to load malformed catalog, * it should throw RuntimeException. */ - @Test(expectedExceptions = RuntimeException.class) + @Test public void validateMalformedCatalogOnUriResolver() { - catalogUriResolver(CATALOG_MALFORMED); + assertThrows(RuntimeException.class, () -> catalogUriResolver(CATALOG_MALFORMED)); } /* diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java index cb8f5c56048..83839033b62 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,52 +23,50 @@ package javax.xml.datatype.ptests; -import static javax.xml.datatype.DatatypeConstants.DAYS; -import static javax.xml.datatype.DatatypeConstants.HOURS; -import static javax.xml.datatype.DatatypeConstants.MINUTES; -import static javax.xml.datatype.DatatypeConstants.MONTHS; -import static javax.xml.datatype.DatatypeConstants.SECONDS; -import static javax.xml.datatype.DatatypeConstants.YEARS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Calendar; -import java.util.function.Function; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; import javax.xml.namespace.QName; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.function.Function; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static javax.xml.datatype.DatatypeConstants.DAYS; +import static javax.xml.datatype.DatatypeConstants.HOURS; +import static javax.xml.datatype.DatatypeConstants.MINUTES; +import static javax.xml.datatype.DatatypeConstants.MONTHS; +import static javax.xml.datatype.DatatypeConstants.SECONDS; +import static javax.xml.datatype.DatatypeConstants.YEARS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.datatype.ptests.DurationTest + * @run junit/othervm javax.xml.datatype.ptests.DurationTest * @summary Class containing the test cases for Duration. */ public class DurationTest { - private DatatypeFactory datatypeFactory; + private static DatatypeFactory datatypeFactory = null; - /* - * Setup. - */ - @BeforeClass - public void setup() throws DatatypeConfigurationException { + @BeforeAll + public static void setup() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @DataProvider(name = "legal-number-duration") - public Object[][] getLegalNumberDuration() { + public static Object[][] getLegalNumberDuration() { return new Object[][] { // is positive, year, month, day, hour, minute, second { true, 1, 1, 1, 1, 1, 1 }, @@ -82,13 +80,13 @@ public class DurationTest { * Test for constructor Duration(boolean isPositive,int years,int months, * int days,int hours,int minutes,int seconds). */ - @Test(dataProvider = "legal-number-duration") + @ParameterizedTest + @MethodSource("getLegalNumberDuration") public void checkNumberDurationPos(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds) { datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); } - @DataProvider(name = "illegal-number-duration") - public Object[][] getIllegalNumberDuration() { + public static Object[][] getIllegalNumberDuration() { return new Object[][] { // is positive, year, month, day, hour, minute, second { true, 1, 1, -1, 1, 1, 1 }, @@ -103,13 +101,15 @@ public class DurationTest { * int days,int hours,int minutes,int seconds), if any of the fields is * negative should throw IllegalArgumentException. */ - @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegal-number-duration") + @ParameterizedTest + @MethodSource("getIllegalNumberDuration") public void checkDurationNumberNeg(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds) { - datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); + assertThrows( + IllegalArgumentException.class, + () -> datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds)); } - @DataProvider(name = "legal-bigint-duration") - public Object[][] getLegalBigIntegerDuration() { + public static Object[][] getLegalBigIntegerDuration() { return new Object[][] { // is positive, year, month, day, hour, minute, second { true, zero, zero, zero, zero, zero, new BigDecimal(zero) }, @@ -125,14 +125,14 @@ public class DurationTest { * years,BigInteger months, BigInteger days,BigInteger hours,BigInteger * minutes,BigDecimal seconds). */ - @Test(dataProvider = "legal-bigint-duration") + @ParameterizedTest + @MethodSource("getLegalBigIntegerDuration") public void checkBigIntegerDurationPos(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds) { datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); } - @DataProvider(name = "illegal-bigint-duration") - public Object[][] getIllegalBigIntegerDuration() { + public static Object[][] getIllegalBigIntegerDuration() { return new Object[][] { // is positive, year, month, day, hour, minute, second { true, null, null, null, null, null, null }, @@ -146,79 +146,66 @@ public class DurationTest { * minutes,BigDecimal seconds), if all the fields are null should throw * IllegalArgumentException. */ - @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegal-bigint-duration") - public void checkBigIntegerDurationNeg(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, - BigDecimal seconds) { - datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); - } - - @DataProvider(name = "legal-millisec-duration") - public Object[][] getLegalMilliSecondDuration() { - return new Object[][] { { 1000000 }, { 0 }, { Long.MAX_VALUE }, { Long.MIN_VALUE } - - }; + @ParameterizedTest + @MethodSource("getIllegalBigIntegerDuration") + public void checkBigIntegerDurationNeg( + boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds) { + assertThrows(IllegalArgumentException.class, () -> datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds)); } /* * Test for constructor Duration(long durationInMilliSeconds) */ - @Test(dataProvider = "legal-millisec-duration") + @ParameterizedTest + @ValueSource(longs={ 1000000, 0, Long.MAX_VALUE, Long.MIN_VALUE }) public void checkMilliSecondDuration(long millisec) { datatypeFactory.newDuration(millisec); } - @DataProvider(name = "legal-lexical-duration") - public Object[][] getLegalLexicalDuration() { - return new Object[][] { { "P1Y1M1DT1H1M1S" }, { "-P1Y1M1DT1H1M1S" } }; - } - /* * Test for constructor Duration(java.lang.String lexicalRepresentation) */ - @Test(dataProvider = "legal-lexical-duration") + @ParameterizedTest + @ValueSource(strings={ "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M1S" }) public void checkLexicalDurationPos(String lexRepresentation) { datatypeFactory.newDuration(lexRepresentation); } - @DataProvider(name = "illegal-lexical-duration") - public Object[][] getIllegalLexicalDuration() { - return new Object[][] { - { null }, - { "P1Y1M1DT1H1M1S " }, - { " P1Y1M1DT1H1M1S" }, - { "X1Y1M1DT1H1M1S" }, - { "" }, - { "P1Y2MT" } // The designator 'T' shall be absent if all of the time items are absent in "PnYnMnDTnHnMnS" - }; + /* + * Test for constructor Duration(java.lang.String lexicalRepresentation), + * null should throw NullPointerException + */ + @Test + public void checkLexicalDurationNull() { + assertThrows(NullPointerException.class, () -> datatypeFactory.newDuration(null)); } /* * Test for constructor Duration(java.lang.String lexicalRepresentation), - * null should throw NullPointerException, invalid lex should throw - * IllegalArgumentException + * invalid lex should throw IllegalArgumentException */ - @Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }, dataProvider = "illegal-lexical-duration") + @ParameterizedTest + @ValueSource(strings={ "P1Y1M1DT1H1M1S ", " P1Y1M1DT1H1M1S", "X1Y1M1DT1H1M1S", "", "P1Y2MT" }) public void checkLexicalDurationNeg(String lexRepresentation) { - datatypeFactory.newDuration(lexRepresentation); + assertThrows(IllegalArgumentException.class, () -> datatypeFactory.newDuration(lexRepresentation)); } - @DataProvider(name = "equal-duration") - public Object[][] getEqualDurations() { + public static Object[][] getEqualDurations() { return new Object[][] { { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" } }; } /* * Test for compare() both durations valid and equal. */ - @Test(dataProvider = "equal-duration") + @ParameterizedTest + @MethodSource("getEqualDurations") public void checkDurationEqual(String lexRepresentation1, String lexRepresentation2) { Duration duration1 = datatypeFactory.newDuration(lexRepresentation1); Duration duration2 = datatypeFactory.newDuration(lexRepresentation2); - assertTrue(duration1.equals(duration2)); + assertEquals(duration1, duration2); } - @DataProvider(name = "greater-duration") - public Object[][] getGreaterDuration() { + public static Object[][] getGreaterDuration() { return new Object[][] { { "P1Y1M1DT1H1M2S", "P1Y1M1DT1H1M1S" }, { "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M2S" }, @@ -229,15 +216,15 @@ public class DurationTest { /* * Test for compare() both durations valid and lhs > rhs. */ - @Test(dataProvider = "greater-duration") + @ParameterizedTest + @MethodSource("getGreaterDuration") public void checkDurationCompare(String lexRepresentation1, String lexRepresentation2) { Duration duration1 = datatypeFactory.newDuration(lexRepresentation1); Duration duration2 = datatypeFactory.newDuration(lexRepresentation2); - assertTrue(duration1.compare(duration2) == DatatypeConstants.GREATER); + assertEquals(DatatypeConstants.GREATER, duration1.compare(duration2)); } - @DataProvider(name = "not-equal-duration") - public Object[][] getNotEqualDurations() { + public static Object[][] getNotEqualDurations() { return new Object[][] { { "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M1S" }, { "P2Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" } }; @@ -246,15 +233,15 @@ public class DurationTest { /* * Test for equals() both durations valid and lhs not equals rhs. */ - @Test(dataProvider = "not-equal-duration") + @ParameterizedTest + @MethodSource("getNotEqualDurations") public void checkDurationNotEqual(String lexRepresentation1, String lexRepresentation2) { Duration duration1 = datatypeFactory.newDuration(lexRepresentation1); Duration duration2 = datatypeFactory.newDuration(lexRepresentation2); - Assert.assertNotEquals(duration1, duration2); + assertNotEquals(duration1, duration2); } - @DataProvider(name = "duration-sign") - public Object[][] getDurationAndSign() { + public static Object[][] getDurationAndSign() { return new Object[][] { { "P0Y0M0DT0H0M0S", 0 }, { "P1Y0M0DT0H0M0S", 1 }, @@ -264,10 +251,11 @@ public class DurationTest { /* * Test for Duration.getSign(). */ - @Test(dataProvider = "duration-sign") - public void checkDurationSign(String lexRepresentation, int sign) { + @ParameterizedTest + @MethodSource("getDurationAndSign") + public void checkDurationSign(String lexRepresentation, int expectedSign) { Duration duration = datatypeFactory.newDuration(lexRepresentation); - assertEquals(duration.getSign(), sign); + assertEquals(expectedSign, duration.getSign()); } /* @@ -278,10 +266,9 @@ public class DurationTest { Duration durationPos = datatypeFactory.newDuration("P1Y0M0DT0H0M0S"); Duration durationNeg = datatypeFactory.newDuration("-P1Y0M0DT0H0M0S"); - assertEquals(durationPos.negate(), durationNeg); - assertEquals(durationNeg.negate(), durationPos); - assertEquals(durationPos.negate().negate(), durationPos); - + assertEquals(durationNeg, durationPos.negate()); + assertEquals(durationPos, durationNeg.negate()); + assertEquals(durationPos, durationPos.negate().negate()); } /* @@ -342,24 +329,22 @@ public class DurationTest { /* * Test Duration.isSet(Field) throws NPE if the field parameter is null. */ - @Test(expectedExceptions = NullPointerException.class) public void checkDurationIsSetNeg() { Duration duration = datatypeFactory.newDuration(true, 0, 0, 0, 0, 0, 0); - duration.isSet(null); + assertThrows(NullPointerException.class, () -> duration.isSet(null)); } /* * Test for -getField(DatatypeConstants.Field) DatatypeConstants.Field is * null - throws NPE. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void checkDurationGetFieldNeg() { - Duration duration67 = datatypeFactory.newDuration("P1Y1M1DT1H1M1S"); - duration67.getField(null); + Duration duration = datatypeFactory.newDuration("P1Y1M1DT1H1M1S"); + assertThrows(NullPointerException.class, () -> duration.getField(null)); } - @DataProvider(name = "duration-fields") - public Object[][] getDurationAndFields() { + public static Object[][] getDurationAndFields() { return new Object[][] { { "P1Y1M1DT1H1M1S", one, one, one, one, one, new BigDecimal(one) }, { "PT1M", null, null, null, null, one, null }, @@ -369,21 +354,21 @@ public class DurationTest { /* * Test for Duration.getField(DatatypeConstants.Field). */ - @Test(dataProvider = "duration-fields") + @ParameterizedTest + @MethodSource("getDurationAndFields") public void checkDurationGetField(String lexRepresentation, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds) { Duration duration = datatypeFactory.newDuration(lexRepresentation); - assertEquals(duration.getField(YEARS), years); - assertEquals(duration.getField(MONTHS), months); - assertEquals(duration.getField(DAYS), days); - assertEquals(duration.getField(HOURS), hours); - assertEquals(duration.getField(MINUTES), minutes); - assertEquals(duration.getField(SECONDS), seconds); + assertEquals(years, duration.getField(YEARS)); + assertEquals(months, duration.getField(MONTHS)); + assertEquals(days, duration.getField(DAYS)); + assertEquals(hours, duration.getField(HOURS)); + assertEquals(minutes, duration.getField(MINUTES)); + assertEquals(seconds, duration.getField(SECONDS)); } - @DataProvider(name = "number-string") - public Object[][] getNumberAndString() { + public static Object[][] getNumberAndString() { return new Object[][] { // is positive, year, month, day, hour, minute, second, lexical { true, 1, 1, 1, 1, 1, 1, "P1Y1M1DT1H1M1S" }, @@ -396,22 +381,22 @@ public class DurationTest { /* * Test for - toString(). */ - @Test(dataProvider = "number-string") + @ParameterizedTest + @MethodSource("getNumberAndString") public void checkDurationToString(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds, String lexical) { - Duration duration = datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); - assertEquals(duration.toString(), lexical); + Duration duration = datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); + assertEquals(lexical, duration.toString()); - assertEquals(datatypeFactory.newDuration(duration.toString()), duration); + assertEquals(duration, datatypeFactory.newDuration(duration.toString())); } - @DataProvider(name = "duration-field") - public Object[][] getDurationAndField() { - Function getyears = duration -> duration.getYears(); - Function getmonths = duration -> duration.getMonths(); - Function getdays = duration -> duration.getDays(); - Function gethours = duration -> duration.getHours(); - Function getminutes = duration -> duration.getMinutes(); - Function getseconds = duration -> duration.getSeconds(); + public static Object[][] getDurationAndField() { + Function getyears = Duration::getYears; + Function getmonths = Duration::getMonths; + Function getdays = Duration::getDays; + Function gethours = Duration::getHours; + Function getminutes = Duration::getMinutes; + Function getseconds = Duration::getSeconds; return new Object[][] { { "P1Y1M1DT1H1M1S", getyears, 1 }, { "P1M1DT1H1M1S", getyears, 0 }, @@ -431,10 +416,11 @@ public class DurationTest { /* * Test for Duration.getYears(), getMonths(), etc. */ - @Test(dataProvider = "duration-field") - public void checkDurationGetOneField(String lexRepresentation, Function getter, int value) { + @ParameterizedTest + @MethodSource("getDurationAndField") + public void checkDurationGetOneField(String lexRepresentation, Function getter, int expectedValue) { Duration duration = datatypeFactory.newDuration(lexRepresentation); - assertEquals(getter.apply(duration).intValue(), value); + assertEquals(expectedValue, getter.apply(duration).intValue()); } /* @@ -443,7 +429,7 @@ public class DurationTest { @Test public void checkDurationGetSecondsField() { Duration duration85 = datatypeFactory.newDuration("P1Y1M1DT1H1M100000000S"); - assertEquals((duration85.getField(SECONDS)).intValue(), 100000000); + assertEquals(100000000, (duration85.getField(SECONDS)).intValue()); } /* @@ -452,9 +438,9 @@ public class DurationTest { */ @Test public void checkDurationGetTimeInMillis() { - Duration duration86 = datatypeFactory.newDuration("PT1M1S"); - Calendar calendar86 = Calendar.getInstance(); - assertEquals(duration86.getTimeInMillis(calendar86), 61000); + Duration duration = datatypeFactory.newDuration("PT1M1S"); + Calendar calendar = Calendar.getInstance(); + assertEquals(61000, duration.getTimeInMillis(calendar)); } /* @@ -462,15 +448,13 @@ public class DurationTest { * between startInstant and startInstant plus this Duration throws NPE if * startInstant parameter is null. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void checkDurationGetTimeInMillisNeg() { - Duration duration87 = datatypeFactory.newDuration("PT1M1S"); - Calendar calendar87 = null; - duration87.getTimeInMillis(calendar87); + Duration duration = datatypeFactory.newDuration("PT1M1S"); + assertThrows(NullPointerException.class, () -> duration.getTimeInMillis((Calendar) null)); } - @DataProvider(name = "duration-for-hash") - public Object[][] getDurationsForHash() { + public static Object[][] getDurationsForHash() { return new Object[][] { { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" }, { "P1D", "PT24H" }, @@ -483,17 +467,17 @@ public class DurationTest { * Test for Duration.hashcode(). hashcode() should return same value for * some equal durations. */ - @Test(dataProvider = "duration-for-hash") + @ParameterizedTest + @MethodSource("getDurationsForHash") public void checkDurationHashCode(String lexRepresentation1, String lexRepresentation2) { Duration duration1 = datatypeFactory.newDuration(lexRepresentation1); Duration duration2 = datatypeFactory.newDuration(lexRepresentation2); int hash1 = duration1.hashCode(); int hash2 = duration2.hashCode(); - assertTrue(hash1 == hash2, " generated hash1 : " + hash1 + " generated hash2 : " + hash2); + assertEquals(hash1, hash2, " generated hash1 : " + hash1 + " generated hash2 : " + hash2); } - @DataProvider(name = "duration-for-add") - public Object[][] getDurationsForAdd() { + public static Object[][] getDurationsForAdd() { return new Object[][] { // initVal, addVal, resultVal { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S", "P2Y2M2DT2H2M2S" }, @@ -504,7 +488,8 @@ public class DurationTest { /* * Test for add(Duration rhs). */ - @Test(dataProvider = "duration-for-add") + @ParameterizedTest + @MethodSource("getDurationsForAdd") public void checkDurationAdd(String initVal, String addVal, String result) { Duration durationInit = datatypeFactory.newDuration(initVal); Duration durationAdd = datatypeFactory.newDuration(addVal); @@ -513,25 +498,32 @@ public class DurationTest { assertEquals(durationInit.add(durationAdd), durationResult); } - @DataProvider(name = "duration-for-addneg") - public Object[][] getDurationsForAddNeg() { + public static Object[][] getDurationsForAddNeg() { return new Object[][] { // initVal, addVal - { "P1Y1M1DT1H1M1S", null }, { "P1Y", "-P1D" }, { "-P1Y", "P1D" }, }; } /* - * Test for add(Duration rhs) 'rhs' is null , should throw NPE. "1 year" + - * "-1 day" or "-1 year" + "1 day" should throw IllegalStateException + * Test for add(Duration rhs). + * "1 year" + "-1 day" or "-1 year" + "1 day" should throw IllegalStateException */ - @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }, dataProvider = "duration-for-addneg") + @ParameterizedTest + @MethodSource("getDurationsForAddNeg") public void checkDurationAddNeg(String initVal, String addVal) { Duration durationInit = datatypeFactory.newDuration(initVal); Duration durationAdd = addVal == null ? null : datatypeFactory.newDuration(addVal); + assertThrows(IllegalStateException.class, () -> durationInit.add(durationAdd)); + } - durationInit.add(durationAdd); + /* + * Test for add(Duration rhs) 'rhs' is null , should throw NPE. + */ + @Test + public void checkDurationAddNull() { + Duration durationInit = datatypeFactory.newDuration("P1Y1M1DT1H1M1S"); + assertThrows(NullPointerException.class, () -> durationInit.add(null)); } /* @@ -540,15 +532,14 @@ public class DurationTest { * Bug # 4972785 UnsupportedOperationException is expected * */ - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test public void checkDurationCompareLarge() { String duration1Lex = "P100000000000000000000D"; String duration2Lex = "PT2400000000000000000000H"; Duration duration1 = datatypeFactory.newDuration(duration1Lex); Duration duration2 = datatypeFactory.newDuration(duration2Lex); - duration1.compare(duration2); - + assertThrows(UnsupportedOperationException.class, () -> duration1.compare(duration2)); } /* @@ -562,25 +553,24 @@ public class DurationTest { // DURATION Duration duration = datatypeFactory.newDuration("P1Y1M1DT1H1M1S"); QName duration_xmlSchemaType = duration.getXMLSchemaType(); - assertEquals(duration_xmlSchemaType, DatatypeConstants.DURATION, "Expected DatatypeConstants.DURATION, returned " + duration_xmlSchemaType.toString()); + assertEquals(DatatypeConstants.DURATION, duration_xmlSchemaType, "Expected DatatypeConstants.DURATION, returned " + duration_xmlSchemaType.toString()); // DURATION_DAYTIME Duration duration_dayTime = datatypeFactory.newDuration("P1DT1H1M1S"); QName duration_dayTime_xmlSchemaType = duration_dayTime.getXMLSchemaType(); - assertEquals(duration_dayTime_xmlSchemaType, DatatypeConstants.DURATION_DAYTIME, "Expected DatatypeConstants.DURATION_DAYTIME, returned " + assertEquals(DatatypeConstants.DURATION_DAYTIME, duration_dayTime_xmlSchemaType, "Expected DatatypeConstants.DURATION_DAYTIME, returned " + duration_dayTime_xmlSchemaType.toString()); // DURATION_YEARMONTH Duration duration_yearMonth = datatypeFactory.newDuration("P1Y1M"); QName duration_yearMonth_xmlSchemaType = duration_yearMonth.getXMLSchemaType(); - assertEquals(duration_yearMonth_xmlSchemaType, DatatypeConstants.DURATION_YEARMONTH, "Expected DatatypeConstants.DURATION_YEARMONTH, returned " + assertEquals(DatatypeConstants.DURATION_YEARMONTH, duration_yearMonth_xmlSchemaType, "Expected DatatypeConstants.DURATION_YEARMONTH, returned " + duration_yearMonth_xmlSchemaType.toString()); } - private final int undef = DatatypeConstants.FIELD_UNDEFINED; - private final BigInteger zero = BigInteger.ZERO; - private final BigInteger one = BigInteger.ONE; - + private final static int undef = DatatypeConstants.FIELD_UNDEFINED; + private final static BigInteger zero = BigInteger.ZERO; + private final static BigInteger one = BigInteger.ONE; } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java index 7b75562bd87..642dfad6810 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,25 +23,27 @@ package javax.xml.datatype.ptests; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.datatype.ptests.FactoryNewInstanceTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.datatype.ptests.FactoryNewInstanceTest * @summary Tests for DatatypeFactory.newInstance(factoryClassName , classLoader) */ public class FactoryNewInstanceTest { @@ -50,9 +52,11 @@ public class FactoryNewInstanceTest { "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"; private static final String DATATYPE_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { - return new Object[][] { { DATATYPE_FACTORY_CLASSNAME, null }, { DATATYPE_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + public static Object[][] getValidateParameters() { + return new Object[][] { + { DATATYPE_FACTORY_CLASSNAME, null }, + { DATATYPE_FACTORY_CLASSNAME, FactoryNewInstanceTest.class.getClassLoader() }, + }; } /** @@ -66,8 +70,8 @@ public class FactoryNewInstanceTest { DatatypeFactory dtf2 = DatatypeFactory.newInstance(); assertNotSame(dtf1, dtf2, "same instance returned:"); assertSame(dtf1.getClass(), dtf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(dtf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, dtf1.getClass().getName()); } /* @@ -76,7 +80,8 @@ public class FactoryNewInstanceTest { * implementation of javax.xml.datatype.DatatypeFactory , should return * newInstance of DatatypeFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException { DatatypeFactory dtf = DatatypeFactory.newInstance(DATATYPE_FACTORY_CLASSNAME, null); Duration duration = dtf.newDuration(true, 1, 1, 1, 1, 1, 1); @@ -89,9 +94,11 @@ public class FactoryNewInstanceTest { * java.lang.ClassLoader classLoader) factoryClassName is null , should * throw DatatypeConfigurationException */ - @Test(expectedExceptions = DatatypeConfigurationException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException { - DatatypeFactory.newInstance(factoryClassName, classLoader); + assertThrows( + DatatypeConfigurationException.class, + () -> DatatypeFactory.newInstance(factoryClassName, classLoader)); } - } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java index d9df1a2cddd..8365f2f3ad5 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,56 +23,54 @@ package javax.xml.datatype.ptests; -import static java.util.Calendar.HOUR; -import static java.util.Calendar.MINUTE; -import static java.util.Calendar.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.GregorianCalendar; -import java.util.Locale; -import java.util.TimeZone; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static java.util.Calendar.HOUR; +import static java.util.Calendar.MINUTE; +import static java.util.Calendar.YEAR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 5049592 5041845 5048932 5064587 5040542 5049531 5049528 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.datatype.ptests.XMLGregorianCalendarTest + * @run junit/othervm javax.xml.datatype.ptests.XMLGregorianCalendarTest * @summary Class containing the test cases for XMLGregorianCalendar */ public class XMLGregorianCalendarTest { private DatatypeFactory datatypeFactory; - @BeforeClass + @BeforeEach public void setup() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @DataProvider(name = "valid-milliseconds") - public Object[][] getValidMilliSeconds() { - return new Object[][] { { 0 }, { 1 }, { 2 }, { 16 }, { 1000 } }; - } - /* * Test DatatypeFactory.newXMLGregorianCalendar(..) with milliseconds > 1. * * Bug # 5049592 - * */ - @Test(dataProvider = "valid-milliseconds") - public void checkNewCalendar(int ms) { + @ParameterizedTest + @ValueSource(ints={ 0, 1, 2, 16, 1000 }) + public void checkNewCalendar(int expectedMillis) { // valid milliseconds XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(2004, // year 6, // month @@ -80,12 +78,12 @@ public class XMLGregorianCalendarTest { 19, // hour 20, // minute 59, // second - ms, // milliseconds + expectedMillis, // milliseconds 840 // timezone ); // expected success - assertEquals(calendar.getMillisecond(), ms); + assertEquals(expectedMillis, calendar.getMillisecond()); } /* @@ -93,23 +91,19 @@ public class XMLGregorianCalendarTest { * * Bug # 5049592 */ - @Test(dataProvider = "valid-milliseconds") - public void checkNewTime(int ms) { + @ParameterizedTest + @ValueSource(ints={ 0, 1, 2, 16, 1000 }) + public void checkNewTime(int expectedMillis) { // valid milliseconds XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendarTime(19, // hour 20, // minute 59, // second - ms, // milliseconds + expectedMillis, // milliseconds 840 // timezone ); // expected success - assertEquals(calendar2.getMillisecond(), ms); - } - - @DataProvider(name = "invalid-milliseconds") - public Object[][] getInvalidMilliSeconds() { - return new Object[][] { { -1 }, { 1001 } }; + assertEquals(expectedMillis, calendar2.getMillisecond()); } /* @@ -119,18 +113,21 @@ public class XMLGregorianCalendarTest { * 1001. * */ - @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds") - public void checkNewCalendarNeg(int milliseconds) { + @ParameterizedTest + @ValueSource(ints={ -1, 1001 }) + public void checkNewCalendarNeg(int invalidMilliseconds) { // invalid milliseconds - datatypeFactory.newXMLGregorianCalendar(2004, // year - 6, // month - 2, // day - 19, // hour - 20, // minute - 59, // second - milliseconds, // milliseconds - 840 // timezone - ); + assertThrows( + IllegalArgumentException.class, + () -> datatypeFactory.newXMLGregorianCalendar(2004, // year + 6, // month + 2, // day + 19, // hour + 20, // minute + 59, // second + invalidMilliseconds, // milliseconds + 840 // timezone + )); } /* @@ -140,19 +137,21 @@ public class XMLGregorianCalendarTest { * 1001. * */ - @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds") - public void checkNewTimeNeg(int milliseconds) { + @ParameterizedTest + @ValueSource(ints={ -1, 1001 }) + public void checkNewTimeNeg(int invalidMilliseconds) { // invalid milliseconds - datatypeFactory.newXMLGregorianCalendarTime(19, // hour - 20, // minute - 59, // second - milliseconds, // milliseconds - 840 // timezone - ); + assertThrows( + IllegalArgumentException.class, + () -> datatypeFactory.newXMLGregorianCalendarTime(19, // hour + 20, // minute + 59, // second + invalidMilliseconds, // milliseconds + 840 // timezone + )); } - @DataProvider(name = "data-for-add") - public Object[][] getDataForAdd() { + public static Object[][] getDataForAdd() { return new Object[][] { //calendar1, calendar2, duration { "1999-12-31T00:00:00Z", "2000-01-01T00:00:00Z", "P1D" }, @@ -173,7 +172,8 @@ public class XMLGregorianCalendarTest { * Test XMLGregorianCalendar.add(Duration). * */ - @Test(dataProvider = "data-for-add") + @ParameterizedTest + @MethodSource("getDataForAdd") public void checkAddDays(String cal1, String cal2, String dur) { XMLGregorianCalendar calendar1 = datatypeFactory.newXMLGregorianCalendar(cal1); @@ -184,70 +184,51 @@ public class XMLGregorianCalendarTest { XMLGregorianCalendar calendar1Clone = (XMLGregorianCalendar)calendar1.clone(); calendar1Clone.add(duration); - assertEquals(calendar1Clone, calendar2); + assertEquals(calendar2, calendar1Clone); calendar2.add(duration.negate()); - assertEquals(calendar2, calendar1); + assertEquals(calendar1, calendar2); } - @DataProvider(name = "gMonth") - public Object[][] getGMonth() { - return new Object[][] { - { "2000-02" }, - { "2000-03" }, - { "2018-02" }}; - } /* * Test XMLGregorianCalendar#isValid(). for gMonth * * Bug # 5041845 - * */ - @Test(dataProvider = "gMonth") + @ParameterizedTest + @ValueSource(strings={ "2000-02", "2000-03", "2018-02" }) public void checkIsValid(String month) { - XMLGregorianCalendar gMonth = datatypeFactory.newXMLGregorianCalendar(month); gMonth.setYear(null); - Assert.assertTrue(gMonth.isValid(), gMonth.toString() + " should isValid"); - - } - - @DataProvider(name = "lexical01") - public Object[][] getLexicalRepresentForNormalize01() { - return new Object[][] { { "2000-01-16T12:00:00Z" }, { "2000-01-16T12:00:00" } }; + assertTrue(gMonth.isValid(), gMonth + " should isValid"); } /* * Test XMLGregorianCalendar#normalize(...). * * Bug # 5048932 XMLGregorianCalendar.normalize works - * */ - @Test(dataProvider = "lexical01") + @ParameterizedTest + @ValueSource(strings={ "2000-01-16T12:00:00Z", "2000-01-16T12:00:00" }) public void checkNormalize01(String lexical) { XMLGregorianCalendar lhs = datatypeFactory.newXMLGregorianCalendar(lexical); lhs.normalize(); } - @DataProvider(name = "lexical02") - public Object[][] getLexicalRepresentForNormalize02() { - return new Object[][] { { "2000-01-16T00:00:00.01Z" }, { "2000-01-16T00:00:00.01" }, { "13:20:00" } }; - } - /* * Test XMLGregorianCalendar#normalize(...). * * Bug # 5064587 XMLGregorianCalendar.normalize shall not change timezone - * */ - @Test(dataProvider = "lexical02") + @ParameterizedTest + @ValueSource(strings={ "2000-01-16T00:00:00.01Z", "2000-01-16T00:00:00.01", "13:20:00" }) public void checkNormalize02(String lexical) { XMLGregorianCalendar orig = datatypeFactory.newXMLGregorianCalendar(lexical); XMLGregorianCalendar normalized = datatypeFactory.newXMLGregorianCalendar(lexical).normalize(); - assertEquals(normalized.getTimezone(), orig.getTimezone()); - assertEquals(normalized.getMillisecond(), orig.getMillisecond()); + assertEquals(orig.getTimezone(), normalized.getTimezone()); + assertEquals(orig.getMillisecond(), normalized.getMillisecond()); } /* @@ -291,8 +272,6 @@ public class XMLGregorianCalendarTest { int hour = calendar.get(HOUR); assertTrue((year == 2003 && hour == 2 && minute == 3), " expecting year == 2003, hour == 2, minute == 3" + ", result is year == " + year + ", hour == " + hour + ", minute == " + minute); - - } /* @@ -311,8 +290,7 @@ public class XMLGregorianCalendarTest { calendar.toGregorianCalendar(TimeZone.getDefault(), Locale.getDefault(), null); } - @DataProvider(name = "calendar") - public Object[][] getXMLGregorianCalendarData() { + public static Object[][] getXMLGregorianCalendarData() { return new Object[][] { // year, month, day, hour, minute, second { 1970, 1, 1, 0, 0, 0 }, // DATETIME @@ -332,10 +310,12 @@ public class XMLGregorianCalendarTest { * Bug # 5049528 * */ - @Test(dataProvider = "calendar") + @ParameterizedTest + @MethodSource("getXMLGregorianCalendarData") public void checkToStringPos(final int year, final int month, final int day, final int hour, final int minute, final int second) { XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(year, month, day, hour, minute, second, undef, undef); - calendar.toString(); + assertNotNull(calendar.toString()); + assertFalse(calendar.toString().isEmpty()); } /* @@ -345,13 +325,13 @@ public class XMLGregorianCalendarTest { * if all parameters are undef * */ - @Test(expectedExceptions = IllegalStateException.class) + @Test public void checkToStringNeg() { XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(undef, undef, undef, undef, undef, undef, undef, undef); // expected to fail - calendar.toString(); + assertThrows(IllegalStateException.class, calendar::toString); } - private final int undef = DatatypeConstants.FIELD_UNDEFINED; + private static final int undef = DatatypeConstants.FIELD_UNDEFINED; } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java index 8bf88ff09fc..6cf6e925a36 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,22 +23,21 @@ package javax.xml.parsers.ptests; -import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR; -import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; - -import java.io.File; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; +import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR; +import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; /** * This tests DocumentBuilderFactory for namespace processing and no-namespace @@ -47,7 +46,7 @@ import org.w3c.dom.Document; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.DBFNamespaceTest + * @run junit/othervm javax.xml.parsers.ptests.DBFNamespaceTest */ public class DBFNamespaceTest { @@ -56,15 +55,14 @@ public class DBFNamespaceTest { * @return a two-dimensional array contains factory, output file name and * golden validate file name. */ - @DataProvider(name = "input-provider") - public Object[][] getInput() { + public static Object[][] getInput() { DocumentBuilderFactory dbf1 = DocumentBuilderFactory.newInstance(); - String outputfile1 = USER_DIR + "dbfnstest01.out"; + String outputfile1 = "dbfnstest01.out"; String goldfile1 = GOLDEN_DIR + "dbfnstest01GF.out"; DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance(); dbf2.setNamespaceAware(true); - String outputfile2 = USER_DIR + "dbfnstest02.out"; + String outputfile2 = "dbfnstest02.out"; String goldfile2 = GOLDEN_DIR + "dbfnstest02GF.out"; return new Object[][] { { dbf1, outputfile1, goldfile1 }, { dbf2, outputfile2, goldfile2 } }; } @@ -77,12 +75,15 @@ public class DBFNamespaceTest { * @param goldfile golden validate file name. * @throws Exception If any errors occur. */ - @Test(dataProvider = "input-provider") + @ParameterizedTest + @MethodSource("getInput") public void testNamespaceTest(DocumentBuilderFactory dbf, String outputfile, String goldfile) throws Exception { Document doc = dbf.newDocumentBuilder().parse(new File(XML_DIR, "namespace1.xml")); dummyTransform(doc, outputfile); - assertTrue(compareWithGold(goldfile, outputfile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldfile)), + Files.readAllLines(Path.of(outputfile))); } /** @@ -90,8 +91,6 @@ public class DBFNamespaceTest { * invoke the callbacks through a ContentHandler. If namespace processing is * not chosen, namespaceURI in callbacks should be an empty string otherwise * it should be namespaceURI. - * - * @throws Exception If any errors occur. */ private void dummyTransform(Document document, String fileName) throws Exception { diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java index f21af74330d..044a1ed5de2 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,26 +23,16 @@ package javax.xml.parsers.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR; -import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertNotSame; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -54,17 +44,28 @@ import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; +import java.io.BufferedReader; +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.nio.file.Files; +import java.nio.file.Path; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR; +import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @bug 8080907 8169778 @@ -73,7 +74,8 @@ import org.xml.sax.helpers.DefaultHandler; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.DocumentBuilderFactoryTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.parsers.ptests.DocumentBuilderFactoryTest */ public class DocumentBuilderFactoryTest { @@ -93,9 +95,11 @@ public class DocumentBuilderFactoryTest { * * @return a data provider contains DocumentBuilderFactory instantiation parameters. */ - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { - return new Object[][] { { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, { DOCUMENT_BUILDER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + public static Object[][] getValidateParameters() { + return new Object[][] { + { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, + { DOCUMENT_BUILDER_FACTORY_CLASSNAME, DocumentBuilderFactoryTest.class.getClassLoader() }, + }; } /** @@ -109,8 +113,8 @@ public class DocumentBuilderFactoryTest { DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance(); assertNotSame(dbf1, dbf2, "same instance returned:"); assertSame(dbf1.getClass(), dbf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(dbf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, dbf1.getClass().getName()); } /** @@ -119,12 +123,9 @@ public class DocumentBuilderFactoryTest { * points to correct implementation of * javax.xml.parsers.DocumentBuilderFactory , should return newInstance of * DocumentBuilderFactory - * - * @param factoryClassName - * @param classLoader - * @throws ParserConfigurationException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(factoryClassName, classLoader); DocumentBuilder builder = dbf.newDocumentBuilder(); @@ -135,13 +136,13 @@ public class DocumentBuilderFactoryTest { * test for DocumentBuilderFactory.newInstance(java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is * null , should throw FactoryConfigurationError - * - * @param factoryClassName - * @param classLoader */ - @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { - DocumentBuilderFactory.newInstance(factoryClassName, classLoader); + assertThrows( + FactoryConfigurationError.class, + () -> DocumentBuilderFactory.newInstance(factoryClassName, classLoader)); } /** @@ -162,11 +163,11 @@ public class DocumentBuilderFactoryTest { assertFalse(eh.isErrorOccured()); } - @DataProvider(name = "schema-source") - public Object[][] getSchemaSource() throws FileNotFoundException { + public static Object[][] getSchemaSource() throws FileNotFoundException { return new Object[][] { { new FileInputStream(new File(XML_DIR, "test.xsd")) }, - { new InputSource(filenameToURL(XML_DIR + "test.xsd")) } }; + { new InputSource(Path.of(XML_DIR).resolve("test.xsd").toUri().toASCIIString()) }, + }; } /** @@ -174,7 +175,8 @@ public class DocumentBuilderFactoryTest { * this case the schema source property is set. * @throws Exception If any errors occur. */ - @Test(dataProvider = "schema-source") + @ParameterizedTest + @MethodSource("getSchemaSource") public void testCheckSchemaSupport2(Object schemaSource) throws Exception { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -201,7 +203,8 @@ public class DocumentBuilderFactoryTest { * this case the schema source property is set. * @throws Exception If any errors occur. */ - @Test(dataProvider = "schema-source") + @ParameterizedTest + @MethodSource("getSchemaSource") public void testCheckSchemaSupport3(Object schemaSource) throws Exception { try { SAXParserFactory spf = SAXParserFactory.newInstance(); @@ -236,7 +239,7 @@ public class DocumentBuilderFactoryTest { Document doc = docBuilder.parse(new File(XML_DIR, "DocumentBuilderFactory01.xml")); Element e = (Element) doc.getElementsByTagName("html").item(0); NodeList nl = e.getChildNodes(); - assertEquals(nl.getLength(), 1); + assertEquals(1, nl.getLength()); } /** @@ -312,7 +315,7 @@ public class DocumentBuilderFactoryTest { Element e = (Element) doc.getElementsByTagName("title").item(0); NodeList nl = e.getChildNodes(); assertTrue(dbf.isExpandEntityReferences()); - assertEquals(nl.item(0).getNodeValue().trim().charAt(0), 'W'); + assertEquals('W', nl.item(0).getNodeValue().trim().charAt(0)); } } @@ -331,7 +334,7 @@ public class DocumentBuilderFactoryTest { MyErrorHandler eh = MyErrorHandler.newInstance(); db.setErrorHandler(eh); Document doc = db.parse(new File(XML_DIR, "DocumentBuilderFactory04.xml")); - assertTrue(doc instanceof Document); + assertInstanceOf(Document.class, doc); assertFalse(eh.isErrorOccured()); } @@ -350,7 +353,7 @@ public class DocumentBuilderFactoryTest { Element e = (Element) doc.getElementsByTagName("title").item(0); NodeList nl = e.getChildNodes(); assertTrue(dbf.isExpandEntityReferences()); - assertEquals(nl.item(0).getNodeValue().trim().charAt(0), 'W'); + assertEquals('W', nl.item(0).getNodeValue().trim().charAt(0)); } } @@ -458,12 +461,12 @@ public class DocumentBuilderFactoryTest { * throw Sax Exception. * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class) + @Test public void testCheckDocumentBuilderFactory14() throws Exception { // Accesing default working directory. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); - docBuilder.parse(""); + assertThrows(SAXException.class, () -> docBuilder.parse("")); } /** @@ -472,12 +475,12 @@ public class DocumentBuilderFactoryTest { * @throws Exception If any errors occur. * */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testCheckDocumentBuilderFactory15() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); String uri = null; - docBuilder.parse(uri); + assertThrows(IllegalArgumentException.class, () -> docBuilder.parse(uri)); } /** @@ -496,7 +499,7 @@ public class DocumentBuilderFactoryTest { Document doc = docBuilder.parse(fis); Element e = (Element) doc.getElementsByTagName("body").item(0); NodeList nl = e.getChildNodes(); - assertEquals(nl.getLength(), 0); + assertEquals(0, nl.getLength()); } } @@ -531,7 +534,7 @@ public class DocumentBuilderFactoryTest { @Test public void testCheckElementContentWhitespace() throws Exception { String goldFile = GOLDEN_DIR + "dbfactory02GF.out"; - String outputFile = USER_DIR + "dbfactory02.out"; + String outputFile = "dbfactory02.out"; MyErrorHandler eh = MyErrorHandler.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); @@ -549,6 +552,8 @@ public class DocumentBuilderFactoryTest { saxResult.setHandler(handler); transformer.transform(domSource, saxResult); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java index 4e9006f9f5b..8d265336bbd 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,23 +23,20 @@ package javax.xml.parsers.ptests; -import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FilePermission; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileInputStream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; +import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * This checks for the methods of DocumentBuilder @@ -47,7 +44,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.DocumentBuilderImpl01 + * @run junit/othervm javax.xml.parsers.ptests.DocumentBuilderImpl01 */ public class DocumentBuilderImpl01 implements EntityResolver { /** @@ -57,8 +54,7 @@ public class DocumentBuilderImpl01 implements EntityResolver { * @throws ParserConfigurationException if a DocumentBuilder cannot be * created which satisfies the configuration requested. */ - @DataProvider(name = "builder-provider") - public Object[][] getBuilder() throws ParserConfigurationException { + public static Object[][] getBuilder() throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); return new Object[][] { { docBuilder } }; @@ -69,7 +65,8 @@ public class DocumentBuilderImpl01 implements EntityResolver { * to return false because not setting the validation. * @param docBuilder document builder instance. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl01(DocumentBuilder docBuilder) { assertFalse(docBuilder.isValidating()); } @@ -78,7 +75,8 @@ public class DocumentBuilderImpl01 implements EntityResolver { * Test the default functionality of isNamespaceAware method. * @param docBuilder document builder instance. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl02(DocumentBuilder docBuilder) { assertFalse(docBuilder.isNamespaceAware()); } @@ -88,7 +86,8 @@ public class DocumentBuilderImpl01 implements EntityResolver { * @param docBuilder document builder instance. * @throws Exception If any errors occur. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl04(DocumentBuilder docBuilder) throws Exception { try (FileInputStream fis = new FileInputStream(new File(XML_DIR, @@ -103,7 +102,8 @@ public class DocumentBuilderImpl01 implements EntityResolver { * @param docBuilder document builder instance. * @throws Exception If any errors occur. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl05(DocumentBuilder docBuilder) throws Exception { assertNotNull(docBuilder.parse(new File(XML_DIR, @@ -115,13 +115,14 @@ public class DocumentBuilderImpl01 implements EntityResolver { * @param docBuilder document builder instance. * @throws Exception If any errors occur. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl06(DocumentBuilder docBuilder) throws Exception { try (FileInputStream fis = new FileInputStream(new File(XML_DIR, "DocumentBuilderImpl02.xml"))) { assertNotNull(docBuilder.parse(fis, new File(XML_DIR).toURI() - .toASCIIString() + FILE_SEP)); + .toASCIIString() + '/')); } } @@ -129,7 +130,8 @@ public class DocumentBuilderImpl01 implements EntityResolver { * Test the setEntityResolver. * @param docBuilder document builder instance. */ - @Test(dataProvider = "builder-provider") + @ParameterizedTest + @MethodSource("getBuilder") public void testCheckDocumentBuilderImpl07(DocumentBuilder docBuilder) { docBuilder.setEntityResolver(this); assertNotNull(resolveEntity("publicId", "http://www.myhost.com/today")); diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java index 3bcc49d58b2..fe4288fc2b1 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,17 @@ package javax.xml.parsers.ptests; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.SAXParserFactory; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for SAXParserFactory/DocumentBuilderFactory @@ -41,45 +42,46 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.FactoryConfErrorTest + * @run junit/othervm javax.xml.parsers.ptests.FactoryConfErrorTest */ +@Execution(ExecutionMode.SAME_THREAD) public class FactoryConfErrorTest { /** * Set properties DocumentBuilderFactory and SAXParserFactory to invalid * value before any test run. */ - @BeforeTest - public void setup() { - setSystemProperty("javax.xml.parsers.DocumentBuilderFactory", "xx"); - setSystemProperty("javax.xml.parsers.SAXParserFactory", "xx"); + @BeforeAll + public static void setup() { + System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "xx"); + System.setProperty("javax.xml.parsers.SAXParserFactory", "xx"); } /** * Restore properties DocumentBuilderFactory and SAXParserFactory to default * value after all tests run. */ - @AfterTest - public void cleanup() { - clearSystemProperty("javax.xml.parsers.DocumentBuilderFactory"); - clearSystemProperty("javax.xml.parsers.SAXParserFactory"); + @AfterAll + public static void cleanup() { + System.clearProperty("javax.xml.parsers.DocumentBuilderFactory"); + System.clearProperty("javax.xml.parsers.SAXParserFactory"); } /** * To test exception thrown if javax.xml.parsers.SAXParserFactory property * is invalid. */ - @Test(expectedExceptions = FactoryConfigurationError.class) + @Test public void testNewInstance01() { - SAXParserFactory.newInstance(); + assertThrows(FactoryConfigurationError.class, SAXParserFactory::newInstance); } /** * To test exception thrown if javax.xml.parsers.DocumentBuilderFactory is * invalid. */ - @Test(expectedExceptions = FactoryConfigurationError.class) + @Test public void testNewInstance02() { - DocumentBuilderFactory.newInstance(); + assertThrows(FactoryConfigurationError.class, DocumentBuilderFactory::newInstance); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java index 2b47bd6a3da..22fca5ec207 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,32 +23,35 @@ package javax.xml.parsers.ptests; -import static org.testng.Assert.assertNotNull; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.xml.sax.SAXException; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.SAXFactoryNewInstanceTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.parsers.ptests.SAXFactoryNewInstanceTest * @summary Tests for SAXParserFactory.newInstance(factoryClassName , classLoader) */ public class SAXFactoryNewInstanceTest { private static final String SAXPARSER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"; - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { - return new Object[][] { { SAXPARSER_FACTORY_CLASSNAME, null }, { SAXPARSER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + public static Object[][] getValidateParameters() { + return new Object[][] { + { SAXPARSER_FACTORY_CLASSNAME, null }, + { SAXPARSER_FACTORY_CLASSNAME, SAXFactoryNewInstanceTest.class.getClassLoader() }, + }; } /* @@ -57,7 +60,8 @@ public class SAXFactoryNewInstanceTest { * implementation of javax.xml.parsers.SAXParserFactory , should return * newInstance of SAXParserFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(factoryClassName, classLoader); SAXParser sp = spf.newSAXParser(); @@ -69,9 +73,12 @@ public class SAXFactoryNewInstanceTest { * java.lang.ClassLoader classLoader) factoryClassName is null , should * throw FactoryConfigurationError */ - @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { - SAXParserFactory.newInstance(factoryClassName, classLoader); + assertThrows( + FactoryConfigurationError.class, + () -> SAXParserFactory.newInstance(factoryClassName, classLoader)); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java index 77134c58ac1..0f21dffcea7 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,15 +22,16 @@ */ package javax.xml.parsers.ptests; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; import javax.xml.parsers.SAXParserFactory; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Class containing the test cases for SAXParserFactory API. @@ -39,7 +40,7 @@ import org.testng.annotations.Test; * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.SAXParserFactTest + * @run junit/othervm javax.xml.parsers.ptests.SAXParserFactTest */ public class SAXParserFactTest { @@ -55,16 +56,15 @@ public class SAXParserFactTest { /** * Test if newDefaultInstance() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { SAXParserFactory spf1 = SAXParserFactory.newDefaultInstance(); SAXParserFactory spf2 = SAXParserFactory.newInstance(); assertNotSame(spf1, spf2, "same instance returned:"); assertSame(spf1.getClass(), spf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(spf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, spf1.getClass().getName()); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java index f828dbeea18..38f2e98e286 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,37 +23,45 @@ package javax.xml.parsers.ptests; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.PropertyPermission; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.xml.sax.HandlerBase; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Class contains the test cases for SAXParser API */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.SAXParserTest + * @run junit/othervm javax.xml.parsers.ptests.SAXParserTest */ public class SAXParserTest { + private static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler(); + + @SuppressWarnings("deprecation") + private static final HandlerBase HANDLER_BASE = new HandlerBase(); + /** * Provide SAXParser. * * @return a data provider contains a SAXParser instance. * @throws Exception If any errors occur. */ - @DataProvider(name = "parser-provider") - public Object[][] getParser() throws Exception { + public static Object[][] getParser() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser saxparser = spf.newSAXParser(); return new Object[][] { { saxparser } }; @@ -62,423 +70,332 @@ public class SAXParserTest { /** * Test case with FileInputStream null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse01(SAXParser saxparser) throws Exception { - FileInputStream instream = null; - saxparser.parse(instream, new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse01(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((InputStream) null, HANDLER_BASE)); } /** * Test with by setting URI as null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse02(SAXParser saxparser) throws Exception { - String uri = null; - saxparser.parse(uri, new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse02(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((String) null, HANDLER_BASE)); } /** * Test with non-existence URI, parsing should fail and throw IOException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = { SAXException.class }, - dataProvider = "parser-provider") - public void testParse03(SAXParser saxparser) throws Exception { - saxparser.parse("", new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse03(SAXParser saxparser) { + assertThrows(SAXException.class, () -> saxparser.parse("", HANDLER_BASE)); } /** * Test with File null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse04(SAXParser saxparser) throws Exception { - File file = null; - saxparser.parse(file, new HandlerBase()); + public void testParse04(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((File) null, HANDLER_BASE)); } /** * Test with empty string as File, parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider") - public void testParse05(SAXParser saxparser) throws Exception { - saxparser.parse(new File(""), new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse05(SAXParser saxparser) { + File file = new File(""); + assertThrows(SAXException.class, () -> saxparser.parse(file, HANDLER_BASE)); } /** * Test with input source null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse06(SAXParser saxparser) throws Exception { - InputSource is = null; - saxparser.parse(is, new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse06(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((InputSource) null, HANDLER_BASE)); } /** * Test with FileInputStream null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse07(SAXParser saxparser) throws Exception { - FileInputStream instream = null; - saxparser.parse(instream, new DefaultHandler()); + public void testParse07(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((InputStream) null, DEFAULT_HANDLER)); } /** * Test with URI null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse08(SAXParser saxparser) throws Exception { - String uri = null; - saxparser.parse(uri, new DefaultHandler()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse08(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((String) null, DEFAULT_HANDLER)); } /** * Test with non-existence URI, parsing should fail and throw SAXException * or IOException. - * - * @param saxparser - * a SAXParser instance. - * @throws Exception - * If any errors occur. */ - @Test(expectedExceptions = { SAXException.class, IOException.class }, dataProvider = "parser-provider") - public void testParse09(SAXParser saxparser) throws Exception { - saxparser.parse("no-such-file", new DefaultHandler()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse09(SAXParser saxparser) { + assertThrows(IOException.class, () -> saxparser.parse("no-such-file", DEFAULT_HANDLER)); } /** * Test with empty string as File, parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider") - public void testParse10(SAXParser saxparser) throws Exception { + @ParameterizedTest + @MethodSource("getParser") + public void testParse10(SAXParser saxparser) { File file = new File(""); - saxparser.parse(file, new DefaultHandler()); + assertThrows(SAXException.class, () -> saxparser.parse(file, DEFAULT_HANDLER)); } /** * Test with File null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse11(SAXParser saxparser) throws Exception { - saxparser.parse((File) null, new DefaultHandler()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse11(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((File) null, DEFAULT_HANDLER)); } /** * Test with input source null, parsing should fail and throw * IllegalArgumentException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class, - dataProvider = "parser-provider") - public void testParse12(SAXParser saxparser) throws Exception { - InputSource is = null; - saxparser.parse(is, new DefaultHandler()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse12(SAXParser saxparser) { + assertThrows(IllegalArgumentException.class, () -> saxparser.parse((InputSource) null, DEFAULT_HANDLER)); } /** * Test with an error in XML file, parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") public void testParse13(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream(new File( XML_DIR, "invalid.xml"))) { - saxparser.parse(instream, new HandlerBase()); + assertThrows(SAXException.class, () -> saxparser.parse(instream, HANDLER_BASE)); } } /** * Test with a valid in XML file, parser should parse the XML document. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse14(SAXParser saxparser) throws Exception { - saxparser.parse(new File(XML_DIR, "parsertest.xml"), - new HandlerBase()); + saxparser.parse(new File(XML_DIR, "parsertest.xml"), HANDLER_BASE); } /** * Test with valid input stream, parser should parse the XML document * successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse15(SAXParser saxparser) throws Exception { - try (FileInputStream instream = new FileInputStream(new File(XML_DIR, - "correct.xml"))) { - saxparser.parse(instream, new HandlerBase()); + try (FileInputStream instream = new FileInputStream(new File(XML_DIR, "correct.xml"))) { + saxparser.parse(instream, HANDLER_BASE); } } /** * Test with valid input source, parser should parse the XML document * successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse16(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream( new File(XML_DIR, "parsertest.xml"))) { - saxparser.parse(instream, new HandlerBase(), + saxparser.parse(instream, HANDLER_BASE, new File(XML_DIR).toURI().toASCIIString()); } } /** * Test with proper URI, parser should parse successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse17(SAXParser saxparser) throws Exception { File file = new File(XML_DIR, "correct.xml"); - saxparser.parse(file.toURI().toASCIIString(), new HandlerBase()); + saxparser.parse(file.toURI().toASCIIString(), HANDLER_BASE); } /** * Test with XML file that has errors parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") - public void testParse18(SAXParser saxparser) throws Exception { - saxparser.parse(new File(XML_DIR, "valid.xml"), new HandlerBase()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse18(SAXParser saxparser) { + File file = new File(XML_DIR, "valid.xml"); + assertThrows(SAXException.class, () -> saxparser.parse(file, HANDLER_BASE)); } /** * Test with XML file that has no errors Parser should successfully * parse the XML document. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse19(SAXParser saxparser) throws Exception { - saxparser.parse(new File(XML_DIR, "correct.xml"), new HandlerBase()); + saxparser.parse(new File(XML_DIR, "correct.xml"), HANDLER_BASE); } /** * Test with input source attached an invalid XML, parsing should fail * and throw SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse20(SAXParser saxparser) throws Exception { try(FileInputStream instream = new FileInputStream(new File(XML_DIR, "invalid.xml"))) { - saxparser.parse(new InputSource(instream), new HandlerBase()); + InputSource is = new InputSource(instream); + assertThrows(SAXException.class, () -> saxparser.parse(is, HANDLER_BASE)); } } /** * Test with input source attached an valid XML, parser should * successfully parse the XML document. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse21(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream(new File(XML_DIR, "correct.xml"))) { - saxparser.parse(new InputSource(instream), new HandlerBase()); + saxparser.parse(new InputSource(instream), HANDLER_BASE); } } /** * Test with an error in xml file, parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse22(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream( new File(XML_DIR, "invalid.xml"))) { - saxparser.parse(instream, new DefaultHandler()); + assertThrows(SAXException.class, () -> saxparser.parse(instream, DEFAULT_HANDLER)); } } /** * Test with valid input stream, parser should parse the XML document * successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse23(SAXParser saxparser) throws Exception { - DefaultHandler handler = new DefaultHandler(); - saxparser.parse(new File(XML_DIR, "parsertest.xml"), handler); + saxparser.parse(new File(XML_DIR, "parsertest.xml"), DEFAULT_HANDLER); } /** * Test with valid input stream, parser should parse the XML document * successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse24(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream(new File(XML_DIR, "correct.xml"))) { - DefaultHandler handler = new DefaultHandler(); - saxparser.parse(instream, handler); + saxparser.parse(instream, DEFAULT_HANDLER); } } /** * Test with valid input source, parser should parse the XML document * successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse25(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream( new File(XML_DIR, "parsertest.xml"))) { - saxparser.parse(instream, new DefaultHandler(), - new File(XML_DIR).toURI().toASCIIString()); + saxparser.parse(instream, DEFAULT_HANDLER, + new File(XML_DIR).toURI().toASCIIString()); } } /** * Test with proper URI, parser should parse successfully. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse26(SAXParser saxparser) throws Exception { File file = new File(XML_DIR, "correct.xml"); - saxparser.parse(file.toURI().toASCIIString(), new DefaultHandler()); + saxparser.parse(file.toURI().toASCIIString(), DEFAULT_HANDLER); } /** * Test with XML file that has errors, parsing should fail and throw * SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") - public void testParse27(SAXParser saxparser) throws Exception { - saxparser.parse(new File(XML_DIR, "valid.xml"), new DefaultHandler()); + @ParameterizedTest + @MethodSource("getParser") + public void testParse27(SAXParser saxparser) { + File file = new File(XML_DIR, "valid.xml"); + assertThrows(SAXException.class, () -> saxparser.parse(file, DEFAULT_HANDLER)); } /** * Test with XML file that has no errors, parser should successfully * parse the XML document. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse28(SAXParser saxparser) throws Exception { - saxparser.parse(new File(XML_DIR, "correct.xml"), new DefaultHandler()); + saxparser.parse(new File(XML_DIR, "correct.xml"), DEFAULT_HANDLER); } /** * Test with an invalid XML file, parser should throw SAXException. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class, - dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse29(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream( new File(XML_DIR, "invalid.xml"))) { - saxparser.parse(new InputSource(instream), new DefaultHandler()); + InputSource is = new InputSource(instream); + assertThrows(SAXException.class, () -> saxparser.parse(is, DEFAULT_HANDLER)); } } /** * Test case to parse an XML file that not use namespaces. - * - * @param saxparser a SAXParser instance. - * @throws Exception If any errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParse30(SAXParser saxparser) throws Exception { try (FileInputStream instream = new FileInputStream( new File(XML_DIR, "correct.xml"))) { - saxparser.parse(new InputSource(instream), new DefaultHandler()); + saxparser.parse(new InputSource(instream), DEFAULT_HANDLER); } } /** * Test case to parse an XML file that uses namespaces. - * - * @throws Exception If any errors occur. */ @Test public void testParse31() throws Exception { @@ -486,7 +403,7 @@ public class SAXParserTest { new File(XML_DIR, "ns4.xml"))) { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - spf.newSAXParser().parse(instream, new HandlerBase()); + spf.newSAXParser().parse(instream, HANDLER_BASE); } } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java index db02034e22c..2597bd975a5 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,28 +23,31 @@ package javax.xml.parsers.ptests; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.ext.DeclHandler; import org.xml.sax.ext.LexicalHandler; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Class contains the test cases for SAXParser API */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.SAXParserTest02 + * @run junit/othervm javax.xml.parsers.ptests.SAXParserTest02 */ public class SAXParserTest02 { private static final String DOM_NODE = "http://xml.org/sax/properties/dom-node"; @@ -58,8 +61,7 @@ public class SAXParserTest02 { * @return a data provider contains a SAXParser instance. * @throws Exception If any errors occur. */ - @DataProvider(name = "parser-provider") - public Object[][] getParser() throws Exception { + public static Object[][] getParser() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser saxparser = spf.newSAXParser(); return new Object[][] { { saxparser } }; @@ -70,7 +72,8 @@ public class SAXParserTest02 { * * @param saxparser a SAXParser instance. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testValidate01(SAXParser saxparser) { assertFalse(saxparser.isValidating()); } @@ -78,8 +81,6 @@ public class SAXParserTest02 { /** * Test to test the functionality of setValidating and isValidating * methods. - * - * @throws Exception If any errors occur. */ @Test public void testValidate02() throws Exception { @@ -95,7 +96,8 @@ public class SAXParserTest02 { * * @param saxparser a SAXParser instance. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testNamespace01(SAXParser saxparser) { assertFalse(saxparser.isNamespaceAware()); } @@ -119,7 +121,8 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testParser01(SAXParser saxparser) throws SAXException { assertNotNull(saxparser.getParser()); } @@ -131,7 +134,8 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testXmlReader01(SAXParser saxparser) throws SAXException { assertNotNull(saxparser.getXMLReader()); } @@ -142,10 +146,10 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(expectedExceptions = SAXNotSupportedException.class, - dataProvider = "parser-provider") - public void testProperty01(SAXParser saxparser) throws SAXException { - saxparser.getProperty(XML_STRING); + @ParameterizedTest + @MethodSource("getParser") + public void testProperty01(SAXParser saxparser) { + assertThrows(SAXNotSupportedException.class, () -> saxparser.getProperty(XML_STRING)); } /** @@ -154,10 +158,10 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(expectedExceptions = SAXNotSupportedException.class, - dataProvider = "parser-provider") - public void testProperty02(SAXParser saxparser) throws SAXException { - saxparser.getProperty(DOM_NODE); + @ParameterizedTest + @MethodSource("getParser") + public void testProperty02(SAXParser saxparser) { + assertThrows(SAXNotSupportedException.class, () -> saxparser.getProperty(DOM_NODE)); } /** @@ -166,7 +170,8 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testProperty03(SAXParser saxparser) throws SAXException { assertNull(saxparser.getProperty(LEXICAL_HANDLER)); } @@ -177,7 +182,8 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testProperty04(SAXParser saxparser) throws SAXException { assertNull(saxparser.getProperty(DECL_HANDLER)); } @@ -188,11 +194,12 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testProperty05(SAXParser saxparser) throws SAXException { MyLexicalHandler myLexicalHandler = new MyLexicalHandler(); saxparser.setProperty(LEXICAL_HANDLER, myLexicalHandler); - assertTrue(saxparser.getProperty(LEXICAL_HANDLER) instanceof LexicalHandler); + assertInstanceOf(LexicalHandler.class, saxparser.getProperty(LEXICAL_HANDLER)); } /** @@ -201,11 +208,12 @@ public class SAXParserTest02 { * @param saxparser a SAXParser instance. * @throws SAXException If any parse errors occur. */ - @Test(dataProvider = "parser-provider") + @ParameterizedTest + @MethodSource("getParser") public void testProperty06(SAXParser saxparser) throws SAXException { MyDeclHandler myDeclHandler = new MyDeclHandler(); saxparser.setProperty(DECL_HANDLER, myDeclHandler); - assertTrue(saxparser.getProperty(DECL_HANDLER) instanceof DeclHandler); + assertInstanceOf(DeclHandler.class, saxparser.getProperty(DECL_HANDLER)); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java index 47d202da7b8..61a270b67d5 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,19 +23,18 @@ package javax.xml.parsers.ptests; -import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.xml.sax.SAXException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.File; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Class contains the test cases for SAXParser API @@ -43,7 +42,7 @@ import org.xml.sax.SAXException; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.parsers.ptests.SAXParserTest03 + * @run junit/othervm javax.xml.parsers.ptests.SAXParserTest03 */ public class SAXParserTest03 { @@ -52,8 +51,7 @@ public class SAXParserTest03 { * * @return a dimensional contains. */ - @DataProvider(name = "input-provider") - public Object[][] getFactory() { + public static Object[][] getFactory() { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setValidating(true); return new Object[][] { { spf, MyErrorHandler.newInstance() } }; @@ -67,7 +65,8 @@ public class SAXParserTest03 { * @param handler an error handler for capturing events. * @throws Exception If any errors occur. */ - @Test(dataProvider = "input-provider") + @ParameterizedTest + @MethodSource("getFactory") public void testParseValidate01(SAXParserFactory spf, MyErrorHandler handler) throws Exception { spf.newSAXParser().parse(new File(XML_DIR, "parsertest.xml"), handler); @@ -82,7 +81,8 @@ public class SAXParserTest03 { * @param handler an error handler for capturing events. * @throws Exception If any errors occur. */ - @Test(dataProvider = "input-provider") + @ParameterizedTest + @MethodSource("getFactory") public void testParseValidate02(SAXParserFactory spf, MyErrorHandler handler) throws Exception { spf.setNamespaceAware(true); @@ -99,17 +99,13 @@ public class SAXParserTest03 { * @param handler an error handler for capturing events. * @throws Exception If any errors occur. */ - @Test(dataProvider = "input-provider") + @ParameterizedTest + @MethodSource("getFactory") public void testParseValidate03(SAXParserFactory spf, MyErrorHandler handler) throws Exception { - try { - spf.setNamespaceAware(true); - SAXParser saxparser = spf.newSAXParser(); - saxparser.parse(new File(XML_DIR, "invalidns.xml"), handler); - fail("Expecting SAXException here"); - } catch (SAXException e) { - assertTrue(handler.isErrorOccured()); - } + spf.setNamespaceAware(true); + SAXParser saxparser = spf.newSAXParser(); + assertThrows(SAXException.class, () -> saxparser.parse(new File(XML_DIR, "invalidns.xml"), handler)); + assertTrue(handler.isErrorOccured()); } - } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java index b846524e0bf..36bf2d01c36 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,26 +23,25 @@ package javax.xml.stream.ptests; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.stream.XMLEventFactory; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest * @summary Tests for XMLEventFactory.newFactory(factoryId , classLoader) */ public class XMLEventFactoryNewInstanceTest { @@ -52,26 +51,25 @@ public class XMLEventFactoryNewInstanceTest { private static final String XMLEVENT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; private static final String XMLEVENT_FACTORY_ID = "javax.xml.stream.XMLEventFactory"; - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { + public static Object[][] getValidateParameters() { return new Object[][] { - { XMLEVENT_FACTORY_ID, null }, - { XMLEVENT_FACTORY_ID, this.getClass().getClassLoader() } }; + { XMLEVENT_FACTORY_ID, null }, + { XMLEVENT_FACTORY_ID, XMLEventFactoryNewInstanceTest.class.getClassLoader() }, + }; } /** * Test if newDefaultFactory() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { XMLEventFactory ef1 = XMLEventFactory.newDefaultFactory(); XMLEventFactory ef2 = XMLEventFactory.newFactory(); assertNotSame(ef1, ef2, "same instance returned:"); assertSame(ef1.getClass(), ef2.getClass(), - "unexpected class mismatch for newDefaultFactory():"); - assertEquals(ef1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(DEFAULT_IMPL_CLASS, ef1.getClass().getName()); } /* @@ -80,14 +78,15 @@ public class XMLEventFactoryNewInstanceTest { * implementation of javax.xml.stream.XMLEventFactory , should return * newInstance of XMLEventFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { - setSystemProperty(XMLEVENT_FACTORY_ID, XMLEVENT_FACTORY_CLASSNAME); + System.setProperty(XMLEVENT_FACTORY_ID, XMLEVENT_FACTORY_CLASSNAME); try { XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader); assertNotNull(xef); } finally { - clearSystemProperty(XMLEVENT_FACTORY_ID); + System.clearProperty(XMLEVENT_FACTORY_ID); } } @@ -96,9 +95,10 @@ public class XMLEventFactoryNewInstanceTest { * java.lang.ClassLoader classLoader) factoryClassName is null , should * throw NullPointerException */ - @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { - XMLEventFactory.newFactory(null, null); + assertThrows(NullPointerException.class, () -> XMLEventFactory.newFactory(factoryId, classLoader)); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java index ac6b009410c..fe1ef8d746e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,26 +23,25 @@ package javax.xml.stream.ptests; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.stream.XMLInputFactory; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest * @summary Tests for XMLInputFactory.newFactory(factoryId , classLoader) */ public class XMLInputFactoryNewInstanceTest { @@ -52,26 +51,25 @@ public class XMLInputFactoryNewInstanceTest { private static final String XMLINPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; private static final String XMLINPUT_FACTORY_ID = "javax.xml.stream.XMLInputFactory"; - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { + public static Object[][] getValidateParameters() { return new Object[][] { - { XMLINPUT_FACTORY_ID, null }, - { XMLINPUT_FACTORY_ID, this.getClass().getClassLoader() } }; + { XMLINPUT_FACTORY_ID, null }, + { XMLINPUT_FACTORY_ID, XMLInputFactoryNewInstanceTest.class.getClassLoader() }, + }; } /** * Test if newDefaultFactory() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { XMLInputFactory if1 = XMLInputFactory.newDefaultFactory(); XMLInputFactory if2 = XMLInputFactory.newFactory(); assertNotSame(if1, if2, "same instance returned:"); assertSame(if1.getClass(), if2.getClass(), - "unexpected class mismatch for newDefaultFactory():"); - assertEquals(if1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(DEFAULT_IMPL_CLASS, if1.getClass().getName()); } /* @@ -80,14 +78,15 @@ public class XMLInputFactoryNewInstanceTest { * implementation of javax.xml.stream.XMLInputFactory , should return * newInstance of XMLInputFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { - setSystemProperty(XMLINPUT_FACTORY_ID, XMLINPUT_FACTORY_CLASSNAME); + System.setProperty(XMLINPUT_FACTORY_ID, XMLINPUT_FACTORY_CLASSNAME); try { XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader); assertNotNull(xif); } finally { - clearSystemProperty(XMLINPUT_FACTORY_ID); + System.clearProperty(XMLINPUT_FACTORY_ID); } } @@ -96,9 +95,10 @@ public class XMLInputFactoryNewInstanceTest { * java.lang.ClassLoader classLoader) factoryClassName is null , should * throw NullPointerException */ - @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { - XMLInputFactory.newFactory(factoryId, classLoader); + assertThrows(NullPointerException.class, () -> XMLInputFactory.newFactory(factoryId, classLoader)); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java index fa406024834..b531759f0f7 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,26 +23,25 @@ package javax.xml.stream.ptests; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.stream.XMLOutputFactory; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest * @summary Tests for XMLOutputFactory.newFactory(factoryId , classLoader) */ public class XMLOutputFactoryNewInstanceTest { @@ -52,26 +51,25 @@ public class XMLOutputFactoryNewInstanceTest { private static final String XMLOUTPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; private static final String XMLOUTPUT_FACTORY_ID = "javax.xml.stream.XMLOutputFactory"; - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { + public static Object[][] getValidateParameters() { return new Object[][] { - { XMLOUTPUT_FACTORY_ID, null }, - { XMLOUTPUT_FACTORY_ID, this.getClass().getClassLoader() } }; + { XMLOUTPUT_FACTORY_ID, null }, + { XMLOUTPUT_FACTORY_ID, XMLOutputFactoryNewInstanceTest.class.getClassLoader() }, + }; } /** * Test if newDefaultFactory() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { XMLOutputFactory of1 = XMLOutputFactory.newDefaultFactory(); XMLOutputFactory of2 = XMLOutputFactory.newFactory(); assertNotSame(of1, of2, "same instance returned:"); assertSame(of1.getClass(), of2.getClass(), - "unexpected class mismatch for newDefaultFactory():"); - assertEquals(of1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(DEFAULT_IMPL_CLASS, of1.getClass().getName()); } /* @@ -80,14 +78,15 @@ public class XMLOutputFactoryNewInstanceTest { * implementation of javax.xml.stream.XMLOutputFactory , should return * newInstance of XMLOutputFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { - setSystemProperty(XMLOUTPUT_FACTORY_ID, XMLOUTPUT_FACTORY_CLASSNAME); + System.setProperty(XMLOUTPUT_FACTORY_ID, XMLOUTPUT_FACTORY_CLASSNAME); try { XMLOutputFactory xif = XMLOutputFactory.newFactory(factoryId, classLoader); assertNotNull(xif); } finally { - clearSystemProperty(XMLOUTPUT_FACTORY_ID); + System.clearProperty(XMLOUTPUT_FACTORY_ID); } } @@ -96,9 +95,10 @@ public class XMLOutputFactoryNewInstanceTest { * java.lang.ClassLoader classLoader) factoryClassName is null , should * throw NullPointerException */ - @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { - XMLOutputFactory.newFactory(factoryId, classLoader); + assertThrows(NullPointerException.class, () -> XMLOutputFactory.newFactory(factoryId, classLoader)); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java index cbe4cc59209..5023d675093 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,10 +23,8 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; - -import java.io.ByteArrayOutputStream; -import java.io.File; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -35,15 +33,16 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.ByteArrayOutputStream; +import java.io.File; -import org.testng.annotations.Test; -import org.w3c.dom.Document; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; /* * @test * @bug 6384418 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.Bug6384418Test + * @run junit/othervm javax.xml.transform.ptests.Bug6384418Test * @summary verify the transforming won't throw any exception */ public class Bug6384418Test { diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java index b26537d22bf..9229c3feb10 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +23,7 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; - -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -48,6 +32,21 @@ import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TransformerHandler; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; + /** * DOM parse on test file to be compared with golden output file. No Exception * is expected. @@ -55,7 +54,7 @@ import org.xml.sax.helpers.XMLReaderFactory; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.DOMResultTest + * @run junit/othervm javax.xml.transform.ptests.DOMResultTest */ public class DOMResultTest { /** @@ -64,8 +63,8 @@ public class DOMResultTest { */ @Test public void testcase01() throws Exception { - String resultFile = USER_DIR + "domresult01.out"; - String goldFile = GOLDEN_DIR + "domresult01GF.out"; + String resultFile = "domresult01.out"; + String goldFile = GOLDEN_DIR + "domresult01GF.out"; String xsltFile = XML_DIR + "cities.xsl"; String xmlFile = XML_DIR + "cities.xml"; @@ -86,7 +85,9 @@ public class DOMResultTest { try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { writeNodes(node, writer); } - assertTrue(compareWithGold(goldFile, resultFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(resultFile))); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java index c591c18fb45..bc067cbcf33 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,19 +23,18 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; - -import java.io.File; +import org.junit.jupiter.api.Test; import javax.xml.transform.ErrorListener; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; +import java.io.File; -import org.testng.annotations.Test; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for ErrorListener interface @@ -43,7 +42,7 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.ErrorListenerTest + * @run junit/othervm javax.xml.transform.ptests.ErrorListenerTest */ public class ErrorListenerTest implements ErrorListener { /** @@ -63,15 +62,13 @@ public class ErrorListenerTest implements ErrorListener { @Test public void errorListener01() { ErrorListenerTest listener = new ErrorListenerTest(); - try { - TransformerFactory tfactory = TransformerFactory.newInstance(); - tfactory.setErrorListener (listener); - tfactory.newTransformer(new StreamSource( - new File(XML_DIR + "invalid.xsl"))); - fail("Expect TransformerConfigurationException here"); - } catch (TransformerConfigurationException ex) { - assertEquals(listener.status, ListenerStatus.FATAL); - } + TransformerFactory tfactory = TransformerFactory.newInstance(); + tfactory.setErrorListener(listener); + StreamSource source = new StreamSource(new File(XML_DIR + "invalid.xsl")); + assertThrows( + TransformerConfigurationException.class, + () -> tfactory.newTransformer(source)); + assertEquals(ListenerStatus.FATAL, listener.status); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java index 3e50e8bb79e..851ed676f3a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,22 +23,21 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; +import org.junit.jupiter.api.Test; +import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; -import org.testng.annotations.Test; -import org.xml.sax.InputSource; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** @@ -47,7 +46,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.SAXSourceTest + * @run junit/othervm javax.xml.transform.ptests.SAXSourceTest */ public class SAXSourceTest { /** @@ -57,8 +56,6 @@ public class SAXSourceTest { /** * Test obtaining a SAX InputSource object from a Source object. - * - * @throws IOException reading file error. */ @Test public void source2inputsource01() throws IOException { @@ -72,8 +69,6 @@ public class SAXSourceTest { * This test case tries to get InputSource from DOMSource using * sourceToInputSource method. It is not possible and hence null is * expected. This is a negative test case, - * - * @throws Exception If any errors occur. */ @Test public void source2inputsource02() throws Exception { @@ -87,8 +82,6 @@ public class SAXSourceTest { * This test case tries to get InputSource from SAXSource using * sourceToInputSource method. This will also check if the systemId * remained the same. This is a positive test case. - * - * @throws IOException reading file error. */ @Test public void source2inputsource03() throws IOException { @@ -97,8 +90,7 @@ public class SAXSourceTest { SAXSource saxSource = new SAXSource(new InputSource(fis)); saxSource.setSystemId(SYSTEM_ID); - assertEquals(SAXSource.sourceToInputSource(saxSource).getSystemId(), - SYSTEM_ID); + assertEquals(SYSTEM_ID, SAXSource.sourceToInputSource(saxSource).getSystemId()); } } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java index 0e1eabfa8fe..9c12cb9f119 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,15 +23,14 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLFilter; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -45,14 +44,17 @@ import javax.xml.transform.sax.TemplatesHandler; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; -import org.xml.sax.XMLFilter; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; +import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test newTransformerhandler() method which takes StreamSource as argument can @@ -61,7 +63,7 @@ import org.xml.sax.helpers.XMLReaderFactory; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.SAXTFactoryTest + * @run junit/othervm javax.xml.transform.ptests.SAXTFactoryTest */ public class SAXTFactoryTest { /** @@ -84,16 +86,14 @@ public class SAXTFactoryTest { * argument can be set to XMLReader. SAXSource has input XML file as its * input source. XMLReader has a transformer handler which write out the * result to output file. Test verifies output file is same as golden file. - * - * @throws Exception If any errors occur. */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "saxtf001.out"; + String outputFile = "saxtf001.out"; String goldFile = GOLDEN_DIR + "saxtf001GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory) TransformerFactory.newInstance(); TransformerHandler handler = saxTFactory.newTransformerHandler(new StreamSource(XSLT_FILE)); @@ -102,7 +102,7 @@ public class SAXTFactoryTest { reader.setContentHandler(handler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** @@ -110,17 +110,15 @@ public class SAXTFactoryTest { * argument can be set to XMLReader. SAXSource has input XML file as its * input source. XMLReader has a content handler which write out the result * to output file. Test verifies output file is same as golden file. - * - * @throws Exception If any errors occur. */ @Test public void testcase02() throws Exception { - String outputFile = USER_DIR + "saxtf002.out"; + String outputFile = "saxtf002.out"; String goldFile = GOLDEN_DIR + "saxtf002GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile); - FileInputStream fis = new FileInputStream(XSLT_FILE)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + FileInputStream fis = new FileInputStream(XSLT_FILE)) { + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory) TransformerFactory.newInstance(); SAXSource ss = new SAXSource(); @@ -132,18 +130,16 @@ public class SAXTFactoryTest { reader.setContentHandler(handler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test for newTransformerhandler(Source). DcoumentBuilderFactory is * namespace awareness, DocumentBuilder parse xslt file as DOMSource. - * - * @throws Exception If any errors occur. */ @Test public void testcase03() throws Exception { - String outputFile = USER_DIR + "saxtf003.out"; + String outputFile = "saxtf003.out"; String goldFile = GOLDEN_DIR + "saxtf003GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { @@ -151,10 +147,9 @@ public class SAXTFactoryTest { dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Document document = docBuilder.parse(new File(XSLT_FILE)); - Node node = (Node)document; - DOMSource domSource= new DOMSource(node); + DOMSource domSource = new DOMSource(document); - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); TransformerHandler handler = @@ -164,15 +159,13 @@ public class SAXTFactoryTest { reader.setContentHandler(handler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Negative test for newTransformerHandler when relative URI is in XML file. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = TransformerConfigurationException.class) + @Test public void transformerHandlerTest04() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); @@ -180,31 +173,28 @@ public class SAXTFactoryTest { Document document = docBuilder.parse(new File(XSLT_INCL_FILE)); DOMSource domSource= new DOMSource(document); SAXTransformerFactory saxTFactory - = (SAXTransformerFactory)TransformerFactory.newInstance(); - saxTFactory.newTransformerHandler(domSource); + = (SAXTransformerFactory) TransformerFactory.newInstance(); + assertThrows(TransformerConfigurationException.class, () -> saxTFactory.newTransformerHandler(domSource)); } /** * Unit test for XMLReader parsing when relative URI is used in xsl file and * SystemId was set. - * - * @throws Exception If any errors occur. */ @Test public void testcase05() throws Exception { - String outputFile = USER_DIR + "saxtf005.out"; + String outputFile = "saxtf005.out"; String goldFile = GOLDEN_DIR + "saxtf005GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Document document = docBuilder.parse(new File(XSLT_INCL_FILE)); - Node node = (Node)document; - DOMSource domSource= new DOMSource(node); + DOMSource domSource = new DOMSource(document); domSource.setSystemId("file:///" + XML_DIR); @@ -216,28 +206,26 @@ public class SAXTFactoryTest { reader.setContentHandler(handler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test newTransformerHandler with a DOMSource. - * - * @throws Exception If any errors occur. */ @Test public void testcase06() throws Exception { - String outputFile = USER_DIR + "saxtf006.out"; + String outputFile = "saxtf006.out"; String goldFile = GOLDEN_DIR + "saxtf006GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); - Node node = (Node)docBuilder.parse(new File(XSLT_INCL_FILE)); + Node node = docBuilder.parse(new File(XSLT_INCL_FILE)); DOMSource domSource = new DOMSource(node, "file:///" + XML_DIR); TransformerHandler handler = @@ -248,20 +236,19 @@ public class SAXTFactoryTest { reader.setContentHandler(handler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Test newTransformerHandler with a Template Handler. - * - * @throws Exception If any errors occur. */ + @Test public void testcase08() throws Exception { - String outputFile = USER_DIR + "saxtf008.out"; + String outputFile = "saxtf008.out"; String goldFile = GOLDEN_DIR + "saxtf008GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); @@ -277,22 +264,20 @@ public class SAXTFactoryTest { reader.setContentHandler(tfhandler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Test newTransformerHandler with a Template Handler along with a relative * URI in the style-sheet file. - * - * @throws Exception If any errors occur. */ @Test public void testcase09() throws Exception { - String outputFile = USER_DIR + "saxtf009.out"; + String outputFile = "saxtf009.out"; String goldFile = GOLDEN_DIR + "saxtf009GF.out"; try (FileOutputStream fos = new FileOutputStream(outputFile)) { - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); @@ -307,21 +292,19 @@ public class SAXTFactoryTest { reader.setContentHandler(tfhandler); reader.parse(XML_FILE); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test for contentHandler setter/getter along reader as handler's * parent. - * - * @throws Exception If any errors occur. */ @Test public void testcase10() throws Exception { - String outputFile = USER_DIR + "saxtf010.out"; + String outputFile = "saxtf010.out"; String goldFile = GOLDEN_DIR + "saxtf010GF.out"; // The transformer will use a SAX parser as it's reader. - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); XMLFilter filter = @@ -333,26 +316,23 @@ public class SAXTFactoryTest { // the content handler for the parser object (it's "parent"), and // will then call the parse method on the parser. filter.parse(new InputSource(XML_FILE)); - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test for contentHandler setter/getter with parent. - * - * @throws Exception If any errors occur. */ @Test public void testcase11() throws Exception { - String outputFile = USER_DIR + "saxtf011.out"; + String outputFile = "saxtf011.out"; String goldFile = GOLDEN_DIR + "saxtf011GF.out"; // The transformer will use a SAX parser as it's reader. - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Document document = docBuilder.parse(new File(XSLT_FILE)); - Node node = (Node)document; - DOMSource domSource= new DOMSource(node); + DOMSource domSource = new DOMSource(document); SAXTransformerFactory saxTFactory = (SAXTransformerFactory)TransformerFactory.newInstance(); @@ -365,20 +345,18 @@ public class SAXTFactoryTest { // the content handler for the parser object (it's "parent"), and // will then call the parse method on the parser. filter.parse(new InputSource(XML_FILE)); - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test for contentHandler setter/getter. - * - * @throws Exception If any errors occur. */ @Test public void testcase12() throws Exception { - String outputFile = USER_DIR + "saxtf012.out"; + String outputFile = "saxtf012.out"; String goldFile = GOLDEN_DIR + "saxtf012GF.out"; // The transformer will use a SAX parser as it's reader. - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); InputSource is = new InputSource(new FileInputStream(XSLT_FILE)); SAXSource saxSource = new SAXSource(); @@ -394,27 +372,26 @@ public class SAXTFactoryTest { // the content handler for the parser object (it's "parent"), and // will then call the parse method on the parser. filter.parse(new InputSource(XML_FILE)); - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); } /** * Unit test for TemplatesHandler setter/getter. - * - * @throws Exception If any errors occur. */ @Test public void testcase13() throws Exception { - String outputFile = USER_DIR + "saxtf013.out"; + String outputFile = "saxtf013.out"; String goldFile = GOLDEN_DIR + "saxtf013GF.out"; try(FileInputStream fis = new FileInputStream(XML_FILE)) { // The transformer will use a SAX parser as it's reader. - XMLReader reader = XMLReaderFactory.createXMLReader(); + XMLReader reader = getXmlReader(); SAXTransformerFactory saxTFactory = (SAXTransformerFactory) TransformerFactory.newInstance(); TemplatesHandler thandler = saxTFactory.newTemplatesHandler(); - // I have put this as it was complaining about systemid - thandler.setSystemId("file:///" + USER_DIR); + // Set the root directory as the ID so the handler can resolve relative paths. + String rootDirUri = Path.of(".").toAbsolutePath().toUri().toASCIIString(); + thandler.setSystemId(rootDirUri); reader.setContentHandler(thandler); reader.parse(XSLT_FILE); @@ -425,6 +402,17 @@ public class SAXTFactoryTest { filter.setContentHandler(new MyContentHandler(outputFile)); filter.parse(new InputSource(fis)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertFileLines(goldFile, outputFile); + } + + @SuppressWarnings("deprecation") + private static XMLReader getXmlReader() throws SAXException { + return XMLReaderFactory.createXMLReader(); + } + + private static void assertFileLines(String goldenFile, String actualFile) throws IOException { + assertLinesMatch( + Files.readAllLines(Path.of(goldenFile)), + Files.readAllLines(Path.of(actualFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java index 6002e371523..abd15888493 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,15 +22,9 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.failUnexpected; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.Properties; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -41,10 +35,14 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Properties; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.fail; /** * Test a StreamResult using a file name that contains URL characters that need @@ -53,7 +51,7 @@ import org.xml.sax.SAXException; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.StreamResultTest + * @run junit/othervm javax.xml.transform.ptests.StreamResultTest */ public class StreamResultTest { /** @@ -90,15 +88,15 @@ public class StreamResultTest { DOMSource domSource = new DOMSource(document); StreamSource streamSource = new StreamSource(new FileInputStream(xmlFile)); - File streamResultFile = new File(USER_DIR + file); + File streamResultFile = new File(file); StreamResult streamResult = new StreamResult(streamResultFile); Transformer transformer = TransformerFactory.newInstance().newTransformer(domSource); transformer.setOutputProperties(transformProperties); transformer.transform(streamSource, streamResult); } catch (SAXException | IOException | ParserConfigurationException - | TransformerException ex) { - failUnexpected(ex); + | TransformerException ex) { + fail(ex); } }); } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java index f647d4c0bf1..01dcf3e6b97 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,12 +22,10 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.io.File; -import java.io.FileInputStream; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -37,11 +35,12 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Class containing the test cases for SAXParserFactory API @@ -49,7 +48,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TfClearParamTest + * @run junit/othervm javax.xml.transform.ptests.TfClearParamTest */ public class TfClearParamTest { /** @@ -82,7 +81,7 @@ public class TfClearParamTest { public void clear01() throws TransformerConfigurationException { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setParameter(LONG_PARAM_NAME, PARAM_VALUE); - assertEquals(transformer.getParameter(LONG_PARAM_NAME).toString(), PARAM_VALUE); + assertEquals(PARAM_VALUE, transformer.getParameter(LONG_PARAM_NAME).toString()); } /** @@ -124,9 +123,9 @@ public class TfClearParamTest { public void clear04() throws TransformerConfigurationException { Transformer transformer = TransformerFactory.newInstance().newTransformer(); - int intObject = 5; - transformer.setParameter(SHORT_PARAM_NAME, intObject); - assertEquals(transformer.getParameter(SHORT_PARAM_NAME), intObject); + int expectedIntValue = 5; + transformer.setParameter(SHORT_PARAM_NAME, expectedIntValue); + assertEquals(expectedIntValue, transformer.getParameter(SHORT_PARAM_NAME)); } /** @@ -141,7 +140,7 @@ public class TfClearParamTest { newTransformer(new StreamSource(new File(XSL_FILE))); transformer.setParameter(LONG_PARAM_NAME, PARAM_VALUE); - assertEquals(transformer.getParameter(LONG_PARAM_NAME), PARAM_VALUE); + assertEquals(PARAM_VALUE, transformer.getParameter(LONG_PARAM_NAME)); } /** @@ -172,7 +171,7 @@ public class TfClearParamTest { Transformer transformer = TransformerFactory.newInstance().newTransformer(saxSource); transformer.setParameter(LONG_PARAM_NAME, PARAM_VALUE); - assertEquals(transformer.getParameter(LONG_PARAM_NAME), PARAM_VALUE); + assertEquals(PARAM_VALUE, transformer.getParameter(LONG_PARAM_NAME)); } } @@ -212,7 +211,7 @@ public class TfClearParamTest { Transformer transformer = tfactory.newTransformer(domSource); transformer.setParameter(LONG_PARAM_NAME, PARAM_VALUE); - assertEquals(transformer.getParameter(LONG_PARAM_NAME), PARAM_VALUE); + assertEquals(PARAM_VALUE, transformer.getParameter(LONG_PARAM_NAME)); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java index 8666306669d..1d9600b330b 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,18 +23,19 @@ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; - -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.function.Supplier; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -56,30 +57,33 @@ import javax.xml.transform.stax.StAXResult; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.function.Supplier; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformTest + * @run junit/othervm javax.xml.transform.ptests.TransformTest * @summary Tests for variable combination of Transformer.transform(Source, Result) */ -@Test(singleThreaded = true) +@TestInstance(Lifecycle.PER_CLASS) +@Execution(ExecutionMode.SAME_THREAD) public class TransformTest { /* * Initialize the share objects. */ - @BeforeClass + @BeforeAll public void setup() throws Exception { ifac = XMLInputFactory.newInstance(); ofac = XMLOutputFactory.newInstance(); @@ -95,7 +99,6 @@ public class TransformTest { xmlDoc = db.parse(xmlInputStream()); } - @DataProvider(name = "input-provider") public Object[][] prepareTestCombination() throws Exception { Supplier staxStreamSource = () -> new StAXSource(getXMLStreamReader()); @@ -160,7 +163,8 @@ public class TransformTest { /* * run Transformer.transform(Source, Result) */ - @Test(dataProvider = "input-provider") + @ParameterizedTest + @MethodSource("prepareTestCombination") public void testTransform(Supplier src, Supplier res, Transformer transformer) throws Throwable { try { transformer.transform(src.get(), res.get()); @@ -257,7 +261,7 @@ public class TransformTest { public void setDocumentLocator(Locator locator) { } - public void startDocument() throws SAXException { + public void startDocument() { String str = "startDocument"; try { bWriter.write(str, 0, str.length()); @@ -267,7 +271,7 @@ public class TransformTest { } } - public void endDocument() throws SAXException { + public void endDocument() { String str = "endDocument"; try { bWriter.write(str, 0, str.length()); @@ -279,7 +283,7 @@ public class TransformTest { } } - public void startPrefixMapping(String prefix, String uri) throws SAXException { + public void startPrefixMapping(String prefix, String uri) { String str = "startPrefixMapping: " + prefix + ", " + uri; try { bWriter.write(str, 0, str.length()); @@ -289,7 +293,7 @@ public class TransformTest { } } - public void endPrefixMapping(String prefix) throws SAXException { + public void endPrefixMapping(String prefix) { String str = "endPrefixMapping: " + prefix; try { bWriter.write(str, 0, str.length()); @@ -299,7 +303,7 @@ public class TransformTest { } } - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) { StringBuilder str = new StringBuilder("startElement: ").append(namespaceURI).append(", ").append(namespaceURI).append(", ").append(qName).append(" : "); int n = atts.getLength(); for (int i = 0; i < n; i++) { @@ -314,7 +318,7 @@ public class TransformTest { } } - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { + public void endElement(String namespaceURI, String localName, String qName) { String str = "endElement: " + namespaceURI + ", " + namespaceURI + ", " + qName; try { bWriter.write(str, 0, str.length()); @@ -325,7 +329,7 @@ public class TransformTest { } - public void characters(char ch[], int start, int length) throws SAXException { + public void characters(char ch[], int start, int length) { String str = new String(ch, start, length); try { bWriter.write(str, 0, str.length()); @@ -335,7 +339,7 @@ public class TransformTest { } } - public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { + public void ignorableWhitespace(char ch[], int start, int length) { String str = "ignorableWhitespace"; try { bWriter.write(str, 0, str.length()); @@ -345,7 +349,7 @@ public class TransformTest { } } - public void processingInstruction(String target, String data) throws SAXException { + public void processingInstruction(String target, String data) { String str = "processingInstruction: " + target + ", " + target; try { bWriter.write(str, 0, str.length()); @@ -355,7 +359,7 @@ public class TransformTest { } } - public void skippedEntity(String name) throws SAXException { + public void skippedEntity(String name) { String str = "skippedEntity: " + name; try { bWriter.write(str, 0, str.length()); diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java index 8907b7afd55..25b715864dd 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,21 +22,21 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; - -import java.io.File; +import org.junit.jupiter.api.Test; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; -import org.testng.annotations.Test; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Basic test for TransformerException specification. @@ -44,31 +44,28 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformerExcpTest + * @run junit/othervm javax.xml.transform.ptests.TransformerExcpTest */ public class TransformerExcpTest { /** * Transform an unformatted style-sheet file. TransformerException is thrown. */ @Test - public void tfexception() { - try { - // invalid.xsl has well-formedness error. Therefore transform throws - // TransformerException - StreamSource streamSource - = new StreamSource(new File(XML_DIR + "invalid.xsl")); - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = tFactory.newTransformer(streamSource); - transformer.transform( - new StreamSource(new File(XML_DIR + "cities.xml")), - new SAXResult()); - fail("TransformerException is not thrown as expected"); - } catch (TransformerException e) { - assertNotNull(e.getCause()); - assertNotNull(e.getException()); - assertNull(e.getLocationAsString()); - assertEquals(e.getMessageAndLocation(),e.getMessage()); - } + public void tfexception() throws TransformerConfigurationException { + // invalid.xsl has well-formedness error. Therefore transform throws + // TransformerException + StreamSource streamSource + = new StreamSource(new File(XML_DIR + "invalid.xsl")); + TransformerFactory tFactory = TransformerFactory.newInstance(); + + TransformerException e = assertThrows( + TransformerException.class, + () -> tFactory.newTransformer(streamSource)); + + assertNotNull(e.getCause()); + assertNotNull(e.getException()); + assertNull(e.getLocationAsString()); + assertEquals(e.getMessageAndLocation(), e.getMessage()); } @@ -77,20 +74,20 @@ public class TransformerExcpTest { * TransformerException(Throwable), initCause should throw * IllegalStateException */ - @Test(expectedExceptions = IllegalStateException.class) + @Test public void tfexception06() { TransformerException te = new TransformerException(new Throwable()); - te.initCause(null); + assertThrows(IllegalStateException.class, () -> te.initCause(null)); } /** * Spec says, "if the throwable was created with TransformerException(String, * Throwable), initCause should throw IllegalStateException */ - @Test(expectedExceptions = IllegalStateException.class) + @Test public void tfexception07() { TransformerException te = new TransformerException("MyMessage", new Throwable()); - te.initCause(null); + assertThrows(IllegalStateException.class, () -> te.initCause(null)); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java index 8223319aa0a..b53fe298005 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,18 +22,11 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; - -import java.io.FileInputStream; -import java.io.FileOutputStream; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -44,12 +37,19 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Path; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; +import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for TransformerFactory API's @@ -59,7 +59,8 @@ import org.w3c.dom.Document; * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformerFactoryTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.transform.ptests.TransformerFactoryTest */ public class TransformerFactoryTest { /** @@ -78,24 +79,25 @@ public class TransformerFactoryTest { * * @return a data provider contains TransformerFactory instantiation parameters. */ - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { - return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + public static Object[][] getValidateParameters() { + return new Object[][] { + { TRANSFORMER_FACTORY_CLASSNAME, null }, + { TRANSFORMER_FACTORY_CLASSNAME, TransformerFactoryTest.class.getClassLoader() }, + }; } /** * Test if newDefaultInstance() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { TransformerFactory tf1 = TransformerFactory.newDefaultInstance(); TransformerFactory tf2 = TransformerFactory.newInstance(); assertNotSame(tf1, tf2, "same instance returned:"); assertSame(tf1.getClass(), tf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(tf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, tf1.getClass().getName()); } /** @@ -104,12 +106,9 @@ public class TransformerFactoryTest { * points to correct implementation of * javax.xml.transform.TransformerFactory , should return newInstance of * TransformerFactory - * - * @param factoryClassName - * @param classLoader - * @throws TransformerConfigurationException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws TransformerConfigurationException { TransformerFactory tf = TransformerFactory.newInstance(factoryClassName, classLoader); Transformer transformer = tf.newTransformer(); @@ -120,13 +119,13 @@ public class TransformerFactoryTest { * Test for TransformerFactory.newInstance(java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is * null , should throw TransformerFactoryConfigurationError - * - * @param factoryClassName - * @param classLoader */ - @Test(expectedExceptions = TransformerFactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { - TransformerFactory.newInstance(factoryClassName, classLoader); + assertThrows( + TransformerFactoryConfigurationError.class, + () -> TransformerFactory.newInstance(factoryClassName, classLoader)); } /** @@ -134,12 +133,10 @@ public class TransformerFactoryTest { * of TransformerFactory. * The style sheet returned is then copied to an tfactory01.out * It will then be verified to see if it matches the golden files. - * - * @throws Exception If any errors occur. */ @Test public void tfactory01() throws Exception { - String outputFile = USER_DIR + "tfactory01.out"; + String outputFile = "tfactory01.out"; String goldFile = GOLDEN_DIR + "tfactory01GF.out"; String xmlFile = XML_DIR + "TransformerFactoryTest.xml"; String xmlURI = "file:///" + XML_DIR; @@ -160,6 +157,8 @@ public class TransformerFactoryTest { Transformer t = tFactory.newTransformer(); t.transform(s, streamResult); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java index f940f268ff4..6a779cc05e0 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,14 +22,9 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Properties; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -41,10 +36,14 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.util.Properties; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Basic test cases for Transformer API @@ -52,7 +51,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformerTest + * @run junit/othervm javax.xml.transform.ptests.TransformerTest */ public class TransformerTest { /** @@ -90,8 +89,6 @@ public class TransformerTest { /** * This tests if newTransformer(DOMSource) method returns Transformer. - * - * @throws Exception If any errors occur. */ @Test public void transformer03() throws Exception { @@ -109,8 +106,6 @@ public class TransformerTest { /** * This tests set/get ErrorListener methods of Transformer. - * - * @throws Exception If any errors occur. */ @Test public void transformer04() throws Exception { @@ -124,13 +119,11 @@ public class TransformerTest { .newTransformer(domSource); transformer.setErrorListener(new MyErrorListener()); assertNotNull(transformer.getErrorListener()); - assertTrue(transformer.getErrorListener() instanceof MyErrorListener); + assertInstanceOf(MyErrorListener.class, transformer.getErrorListener()); } /** * This tests getOutputProperties() method of Transformer. - * - * @throws Exception If any errors occur. */ @Test public void transformer05() throws Exception { @@ -144,18 +137,16 @@ public class TransformerTest { newTransformer(domSource); Properties prop = transformer.getOutputProperties(); - assertEquals(prop.getProperty("indent"), "yes"); - assertEquals(prop.getProperty("method"), "xml"); - assertEquals(prop.getProperty("encoding"), "UTF-8"); - assertEquals(prop.getProperty("standalone"), "no"); - assertEquals(prop.getProperty("version"), "1.0"); - assertEquals(prop.getProperty("omit-xml-declaration"), "no"); + assertEquals("yes", prop.getProperty("indent")); + assertEquals("xml", prop.getProperty("method")); + assertEquals("UTF-8", prop.getProperty("encoding")); + assertEquals("no", prop.getProperty("standalone")); + assertEquals("1.0", prop.getProperty("version")); + assertEquals("no", prop.getProperty("omit-xml-declaration")); } /** * This tests getOutputProperty() method of Transformer. - * - * @throws Exception If any errors occur. */ @Test public void transformer06() throws Exception { @@ -168,7 +159,7 @@ public class TransformerTest { DOMSource domSource = new DOMSource(document); Transformer transformer = tfactory.newTransformer(domSource); - assertEquals(transformer.getOutputProperty("method"), "xml"); + assertEquals("xml", transformer.getOutputProperty("method")); } } @@ -199,8 +190,7 @@ class MyErrorListener implements ErrorListener { * @param e exception of a fatal error. */ @Override - public void fatalError (TransformerException e) throws - TransformerException { + public void fatalError(TransformerException e) { System.out.println(" In fatal"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java index a9391b02866..0b7a9a85f09 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,15 +22,7 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -38,8 +30,15 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.Test; +import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; /** @@ -49,17 +48,15 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformerTest02 + * @run junit/othervm javax.xml.transform.ptests.TransformerTest02 */ public class TransformerTest02 { /** * Unit test for transform(StreamSource, StreamResult). - * - * @throws Exception If any errors occur. */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "transformer02.out"; + String outputFile = "transformer02.out"; String goldFile = GOLDEN_DIR + "transformer02GF.out"; String xsltFile = XML_DIR + "cities.xsl"; String xmlFile = XML_DIR + "cities.xml"; @@ -79,6 +76,8 @@ public class TransformerTest02 { transformer.setOutputProperty("indent", "no"); transformer.transform(streamSource, streamResult); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java index 4cdd2e606f1..18e5033b0f0 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,16 +22,7 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.Properties; +import org.junit.jupiter.api.Test; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -39,8 +30,16 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Properties; -import org.testng.annotations.Test; +import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; /** * Here Properties Object is populated with required properties.A transformer @@ -51,17 +50,15 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.TransformerTest03 + * @run junit/othervm javax.xml.transform.ptests.TransformerTest03 */ public class TransformerTest03 { /** * Test for Transformer.setOutputProperties method. - * - * @throws Exception If any errors occur. */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "transformer03.out"; + String outputFile = "transformer03.out"; String goldFile = GOLDEN_DIR + "transformer03GF.out"; String xsltFile = XML_DIR + "cities.xsl"; String xmlFile = XML_DIR + "cities.xml"; @@ -88,6 +85,8 @@ public class TransformerTest03 { transformer.setOutputProperties(properties); transformer.transform(new StreamSource(fis), new StreamResult(fos)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java index 0d642b67129..3db6bec77ae 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,12 +22,9 @@ */ package javax.xml.transform.ptests; -import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.File; -import java.io.FileInputStream; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -39,10 +36,12 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import java.io.File; +import java.io.FileInputStream; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; +import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * URIResolver should be invoked when transform happens. @@ -50,9 +49,9 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.URIResolverTest + * @run junit/othervm javax.xml.transform.ptests.URIResolverTest */ -public class URIResolverTest implements URIResolver { +public class URIResolverTest { /** * System ID constant. */ @@ -73,60 +72,29 @@ public class URIResolverTest implements URIResolver { */ private final static String XSL_TEMP_FILE = "temp/cities.xsl"; - /** - * expected HREF. - */ - private final String validateHref; - - /** - * expected Base URI. - */ - private final String validateBase; - - /** - * Default constructor for testng invocation. - */ - public URIResolverTest(){ - validateHref = null; - validateBase = null; - } - - /** - * Constructor for setting expected Href and expected Base URI. - * @param validateHref expected Href - * @param validateBase expected Base URI - */ - public URIResolverTest(String validateHref, String validateBase){ - this.validateHref = validateHref; - this.validateBase = validateBase; - } - - /** - * Called by the processor when it encounters an xsl:include, xsl:import, - * or document() function. - * @param href An href attribute, which may be relative or absolute. - * @param base The base URI against which the first argument will be made - * absolute if the absolute URI is required. - * @return null always. - */ - @Override - public Source resolve(String href, String base) { - assertEquals(href, validateHref); - assertEquals(base, validateBase); - return null; + record TestResolver(String expectedHref, String expectedBase) implements URIResolver { + /** + * Called by the processor when it encounters an xsl:include, xsl:import, + * or document() function. + */ + @Override + public Source resolve(String href, String base) { + assertEquals(expectedHref, href); + assertEquals(expectedBase, base); + // Return null if the href cannot be resolved. + return null; + } } /** * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:include in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver01() throws Exception { + public void resolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) { TransformerFactory tfactory = TransformerFactory.newInstance(); - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver); StreamSource streamSource = new StreamSource(fis); @@ -138,13 +106,11 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:include in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver02() throws Exception { + public void resolver02() throws Exception { TransformerFactory tfactory = TransformerFactory.newInstance(); - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); tfactory.setURIResolver(resolver); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -159,13 +125,11 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:include in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver03() throws Exception { - try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){ - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + public void resolver03() throws Exception { + try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) { + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); InputSource is = new InputSource(fis); @@ -178,13 +142,11 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when a transformer is * created using StreamSource. style-sheet file has xsl:import in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver04() throws Exception { + public void resolver04() throws Exception { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) { - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); StreamSource streamSource = new StreamSource(fis); @@ -196,12 +158,10 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when a transformer is * created using DOMSource. style-sheet file has xsl:import in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver05() throws Exception { - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + public void resolver05() throws Exception { + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -215,13 +175,11 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when a transformer is * created using SAXSource. style-sheet file has xsl:import in it. - * - * @throws Exception If any errors occur. */ @Test - public static void resolver06() throws Exception { - try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){ - URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); + public void resolver06() throws Exception { + try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) { + TestResolver resolver = new TestResolver(XSL_TEMP_FILE, SYSTEM_ID); TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setURIResolver(resolver); InputSource is = new InputSource(fis); @@ -234,13 +192,11 @@ public class URIResolverTest implements URIResolver { /** * This is to test the URIResolver.resolve() method when there is an error * in the file. - * - * @throws Exception If any errors occur. */ @Test - public static void docResolver01() throws Exception { + public void docResolver01() throws Exception { try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) { - URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID); + TestResolver resolver = new TestResolver("temp/colors.xml", SYSTEM_ID); StreamSource streamSource = new StreamSource(fis); streamSource.setSystemId(SYSTEM_ID); diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java index 41a528ce1d2..31fa2960250 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,14 +22,13 @@ */ package javax.xml.transform.ptests.othervm; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; - -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Test; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Negative test for set invalid TransformerFactory property. @@ -37,17 +36,21 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.transform.ptests.othervm.TFCErrorTest + * @run junit/othervm javax.xml.transform.ptests.othervm.TFCErrorTest */ public class TFCErrorTest { - @Test(expectedExceptions = ClassNotFoundException.class) - public void tfce01() throws Exception { - try{ - setSystemProperty("javax.xml.transform.TransformerFactory","xx"); - TransformerFactory.newInstance(); - fail("Expect TransformerFactoryConfigurationError here"); - } catch (TransformerFactoryConfigurationError expected) { - throw expected.getException(); + private static final String TRANSFORMER_FACTORY = "javax.xml.transform.TransformerFactory"; + + @Test + public void tfce01() { + System.setProperty(TRANSFORMER_FACTORY, "xx"); + try { + TransformerFactoryConfigurationError e = assertThrows( + TransformerFactoryConfigurationError.class, + TransformerFactory::newInstance); + assertInstanceOf(ClassNotFoundException.class, e.getException()); + } finally { + System.clearProperty(TRANSFORMER_FACTORY); } } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/out/saxtf008GF.out b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/out/saxtf008GF.out index 1fc9136a82b..4e646319c6e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/out/saxtf008GF.out +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/out/saxtf008GF.out @@ -1,17 +1,17 @@ - -Paris -Nice -Lyon - - -Roma -Milano -Firenze -Napoli - - -Madrid -Barcelona - + + Paris + Nice + Lyon + + + Roma + Milano + Firenze + Napoli + + + Madrid + Barcelona + diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java index d9721883870..dc5acdfe1a3 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,23 +22,22 @@ */ package javax.xml.validation.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertEquals; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.SAXParseException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -52,31 +51,38 @@ import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.SAXParseException; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 8080907 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.validation.ptests.SchemaFactoryTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.validation.ptests.SchemaFactoryTest * @summary Class containing the test cases for SchemaFactory */ -@Test(singleThreaded = true) +@Execution(ExecutionMode.SAME_THREAD) +@TestInstance(Lifecycle.PER_CLASS) public class SchemaFactoryTest { - @BeforeClass + @BeforeAll public void setup() throws SAXException, IOException, ParserConfigurationException { sf = newSchemaFactory(); assertNotNull(sf); @@ -96,7 +102,6 @@ public class SchemaFactoryTest { } - @DataProvider(name = "parameters") public Object[][] getValidateParameters() { return new Object[][] { { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null }, { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; @@ -105,16 +110,15 @@ public class SchemaFactoryTest { /** * Test if newDefaultInstance() method returns an instance * of the expected factory. - * @throws Exception If any errors occur. */ @Test - public void testDefaultInstance() throws Exception { + public void testDefaultInstance() { SchemaFactory sf1 = SchemaFactory.newDefaultInstance(); SchemaFactory sf2 = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); assertNotSame(sf1, sf2, "same instance returned:"); assertSame(sf1.getClass(), sf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(sf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, sf1.getClass().getName()); assertTrue(sf1.isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI), "isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI):"); assertFalse(sf1.isSchemaLanguageSupported(UNRECOGNIZED_NAME), @@ -128,9 +132,10 @@ public class SchemaFactoryTest { * javax.xml.validation.SchemaFactory , should return newInstance of * SchemaFactory */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) throws SAXException { - SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null); + SchemaFactory sf = SchemaFactory.newInstance(schemaLanguage, factoryClassName, classLoader); Schema schema = sf.newSchema(); assertNotNull(schema); } @@ -140,10 +145,12 @@ public class SchemaFactoryTest { * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) * factoryClassName is null , should throw IllegalArgumentException */ - @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") public void testNewInstanceWithNullFactoryClassName(String factoryClassName, ClassLoader classLoader) { - - SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, factoryClassName, classLoader); + assertThrows( + IllegalArgumentException.class, + () -> SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, factoryClassName, classLoader)); } /* @@ -151,9 +158,11 @@ public class SchemaFactoryTest { * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) * schemaLanguage is null , should throw NPE */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNewInstanceWithNullSchemaLanguage() { - SchemaFactory.newInstance(null, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + assertThrows( + NullPointerException.class, + () -> SchemaFactory.newInstance(null, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader())); } /* @@ -161,15 +170,17 @@ public class SchemaFactoryTest { * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) * schemaLanguage is empty , should throw IllegalArgumentException */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testNewInstanceWithEmptySchemaLanguage() { - SchemaFactory.newInstance("", SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + assertThrows( + IllegalArgumentException.class, + () -> SchemaFactory.newInstance("", SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader())); } - @Test(expectedExceptions = SAXParseException.class) - public void testNewSchemaDefault() throws SAXException, IOException { - validate(sf.newSchema()); + @Test + public void testNewSchemaDefault() { + assertThrows(SAXParseException.class, () -> validate(sf.newSchema())); } @Test @@ -177,12 +188,11 @@ public class SchemaFactoryTest { validate(sf.newSchema(new File(XML_DIR + "test.xsd"))); } - @Test(expectedExceptions = NullPointerException.class) - public void testNewSchemaWithNullFile() throws SAXException { - sf.newSchema((File) null); + @Test + public void testNewSchemaWithNullFile() { + assertThrows(NullPointerException.class, () -> sf.newSchema((File) null)); } - @DataProvider(name = "valid-source") public Object[][] getValidSource() throws XMLStreamException { return new Object[][] { { streamSource(xsd1) }, @@ -193,43 +203,42 @@ public class SchemaFactoryTest { } - @Test(dataProvider = "valid-source") + @ParameterizedTest + @MethodSource("getValidSource") public void testNewSchemaWithValidSource(Source schema) throws SAXException, IOException { validate(sf.newSchema(schema)); } - @DataProvider(name = "invalid-source") - public Object[][] getInvalidSource() { + public static Object[][] getInvalidSource() { return new Object[][] { { nullStreamSource() }, { nullSaxSource() } }; } - @Test(dataProvider = "invalid-source", expectedExceptions = SAXParseException.class) - public void testNewSchemaWithInvalidSource(Source schema) throws SAXException { - sf.newSchema(schema); + @ParameterizedTest + @MethodSource("getInvalidSource") + public void testNewSchemaWithInvalidSource(Source schema) { + assertThrows(SAXParseException.class, () -> sf.newSchema(schema)); } - @Test(expectedExceptions = NullPointerException.class) - public void testNewSchemaWithNullSource() throws SAXException { - sf.newSchema((Source)null); + @Test + public void testNewSchemaWithNullSource() { + assertThrows(NullPointerException.class, () -> sf.newSchema((Source) null)); } - @DataProvider(name = "valid-sources") public Object[][] getValidSources() { return new Object[][] { { streamSource(xsd1), streamSource(xsd2) }, { saxSource(xsd1), saxSource(xsd2) }, { domSource(xsdDoc1), domSource(xsdDoc2) } }; - } - @Test(dataProvider = "valid-sources") + @ParameterizedTest + @MethodSource("getValidSources") public void testNewSchemaWithValidSourceArray(Source schema1, Source schema2) throws SAXException, IOException { validate(sf.newSchema(new Source[] { schema1, schema2 })); } - @DataProvider(name = "invalid-sources") public Object[][] getInvalidSources() { return new Object[][] { { streamSource(xsd1), nullStreamSource() }, @@ -238,12 +247,12 @@ public class SchemaFactoryTest { { nullSaxSource(), nullSaxSource() } }; } - @Test(dataProvider = "invalid-sources", expectedExceptions = SAXParseException.class) - public void testNewSchemaWithInvalidSourceArray(Source schema1, Source schema2) throws SAXException { - sf.newSchema(new Source[] { schema1, schema2 }); + @ParameterizedTest + @MethodSource("getInvalidSources") + public void testNewSchemaWithInvalidSourceArray(Source schema1, Source schema2) { + assertThrows(SAXParseException.class, () -> sf.newSchema(new Source[] { schema1, schema2 })); } - @DataProvider(name = "null-sources") public Object[][] getNullSources() { return new Object[][] { { new Source[] { domSource(xsdDoc1), null } }, @@ -252,14 +261,15 @@ public class SchemaFactoryTest { } - @Test(dataProvider = "null-sources", expectedExceptions = NullPointerException.class) - public void testNewSchemaWithNullSourceArray(Source[] schemas) throws SAXException { - sf.newSchema(schemas); + @ParameterizedTest + @MethodSource("getNullSources") + public void testNewSchemaWithNullSourceArray(Source[] schemas) { + assertThrows(NullPointerException.class, () -> sf.newSchema(schemas)); } - @Test(expectedExceptions = NullPointerException.class) - public void testNewSchemaWithNullUrl() throws SAXException { - sf.newSchema((URL) null); + @Test + public void testNewSchemaWithNullUrl() { + assertThrows(NullPointerException.class, () -> sf.newSchema((URL) null)); } @@ -270,70 +280,66 @@ public class SchemaFactoryTest { ErrorHandler handler = new MyErrorHandler(); sf.setErrorHandler(handler); - assertSame(sf.getErrorHandler(), handler); + assertSame(handler, sf.getErrorHandler()); sf.setErrorHandler(null); assertNull(sf.getErrorHandler()); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetUnrecognizedProperty() { SchemaFactory sf = newSchemaFactory(); - sf.getProperty(UNRECOGNIZED_NAME); - + assertThrows(SAXNotRecognizedException.class, () -> sf.getProperty(UNRECOGNIZED_NAME)); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetUnrecognizedProperty() { SchemaFactory sf = newSchemaFactory(); - sf.setProperty(UNRECOGNIZED_NAME, "test"); + assertThrows(SAXNotRecognizedException.class, () -> sf.setProperty(UNRECOGNIZED_NAME, "test")); } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullProperty() { SchemaFactory sf = newSchemaFactory(); assertNotNull(sf); - sf.getProperty(null); - + assertThrows(NullPointerException.class, () -> sf.getProperty(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullProperty() { SchemaFactory sf = newSchemaFactory(); assertNotNull(sf); - sf.setProperty(null, "test"); + assertThrows(NullPointerException.class, () -> sf.setProperty(null, "test")); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetUnrecognizedFeature() { SchemaFactory sf = newSchemaFactory(); - sf.getFeature(UNRECOGNIZED_NAME); + assertThrows(SAXNotRecognizedException.class, () -> sf.getFeature(UNRECOGNIZED_NAME)); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testSetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetUnrecognizedFeature() { SchemaFactory sf = newSchemaFactory(); - sf.setFeature(UNRECOGNIZED_NAME, true); + assertThrows(SAXNotRecognizedException.class, () -> sf.setFeature(UNRECOGNIZED_NAME, true)); } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullFeature() { SchemaFactory sf = newSchemaFactory(); assertNotNull(sf); - sf.getFeature(null); - + assertThrows(NullPointerException.class, () -> sf.getFeature(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullFeature() { SchemaFactory sf = newSchemaFactory(); assertNotNull(sf); - sf.setFeature(null, true); + assertThrows(NullPointerException.class, () -> sf.setFeature(null, true)); } - @DataProvider(name = "source-feature") - public Object[][] getSourceFeature() { + public static Object[][] getSourceFeature() { return new Object[][] { { StreamSource.FEATURE }, { SAXSource.FEATURE }, @@ -346,7 +352,8 @@ public class SchemaFactoryTest { * Return true for each of the JAXP Source features to indicate that this * SchemaFactory supports all of the built-in JAXP Source types. */ - @Test(dataProvider = "source-feature") + @ParameterizedTest + @MethodSource("getSourceFeature") public void testSourceFeatureGet(String sourceFeature) throws Exception { assertTrue(newSchemaFactory().getFeature(sourceFeature)); } @@ -355,46 +362,52 @@ public class SchemaFactoryTest { * JAXP Source features are read-only because this SchemaFactory always * supports all JAXP Source types. */ - @Test(dataProvider = "source-feature", expectedExceptions = SAXNotSupportedException.class) - public void testSourceFeatureSet(String sourceFeature) throws Exception { - newSchemaFactory().setFeature(sourceFeature, false); + @ParameterizedTest + @MethodSource("getSourceFeature") + public void testSourceFeatureSet(String sourceFeature) { + assertThrows( + SAXNotSupportedException.class, + () -> newSchemaFactory().setFeature(sourceFeature, false)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testInvalidSchemaLanguage() { final String INVALID_SCHEMA_LANGUAGE = "http://relaxng.org/ns/structure/1.0"; - SchemaFactory.newInstance(INVALID_SCHEMA_LANGUAGE); + assertThrows( + IllegalArgumentException.class, + () -> SchemaFactory.newInstance(INVALID_SCHEMA_LANGUAGE)); } - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNullSchemaLanguage() { - SchemaFactory.newInstance(null); + assertThrows(NullPointerException.class, () -> SchemaFactory.newInstance(null)); } private void validate(Schema schema) throws SAXException, IOException { schema.newValidator().validate(new StreamSource(new ByteArrayInputStream(xml))); } - private InputStream newInputStream(byte[] xsd) { + + private static InputStream newInputStream(byte[] xsd) { return new ByteArrayInputStream(xsd); } - private Source streamSource(byte[] xsd) { + private static Source streamSource(byte[] xsd) { return new StreamSource(newInputStream(xsd)); } - private Source nullStreamSource() { + private static Source nullStreamSource() { return new StreamSource((InputStream) null); } - private Source saxSource(byte[] xsd) { + private static Source saxSource(byte[] xsd) { return new SAXSource(new InputSource(newInputStream(xsd))); } - private Source nullSaxSource() { + private static Source nullSaxSource() { return new SAXSource(new InputSource((InputStream) null)); } - private Source domSource(Document xsdDoc) { + private static Source domSource(Document xsdDoc) { return new DOMSource(xsdDoc); } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java index b8c7a2d54e7..d4802728b5b 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,15 +22,12 @@ */ package javax.xml.validation.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; +import org.junit.jupiter.api.Test; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; @@ -38,18 +35,20 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.TypeInfoProvider; import javax.xml.validation.ValidatorHandler; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; -import org.testng.annotations.Test; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.validation.ptests.TypeInfoProviderTest + * @run junit/othervm javax.xml.validation.ptests.TypeInfoProviderTest * @summary test ValidatorHandler.getTypeInfoProvider() */ public class TypeInfoProviderTest { @@ -65,7 +64,8 @@ public class TypeInfoProviderTest { MyDefaultHandler myDefaultHandler = new MyDefaultHandler(); validatorHandler.setContentHandler(myDefaultHandler); - InputSource is = new InputSource(filenameToURL(XML_DIR + "shiporder11.xml")); + String xmlPathUri = Path.of(XML_DIR).resolve("shiporder11.xml").toUri().toASCIIString(); + InputSource is = new InputSource(xmlPathUri); SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(true); @@ -77,13 +77,13 @@ public class TypeInfoProviderTest { private class MyDefaultHandler extends DefaultHandler { - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) { TypeInfoProvider typeInfoProvider = validatorHandler.getTypeInfoProvider(); int index = atts.getIndex("orderid"); if (index != -1) { System.out.println(" Index " + index); System.out.println(" ElementType " + typeInfoProvider.getElementTypeInfo().getTypeName()); - assertEquals(typeInfoProvider.getAttributeTypeInfo(index).getTypeName(), "string"); + assertEquals("string", typeInfoProvider.getAttributeTypeInfo(index).getTypeName()); assertTrue(typeInfoProvider.isSpecified(index)); assertFalse(typeInfoProvider.isIdAttribute(index)); } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java index 2bbed60ba37..b6c66070417 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,37 +22,39 @@ */ package javax.xml.validation.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.io.File; - -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.ValidatorHandler; - -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.xml.sax.ContentHandler; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.helpers.DefaultHandler; +import org.junit.jupiter.api.BeforeAll; + +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.ValidatorHandler; +import java.io.File; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.validation.ptests.ValidatorHandlerTest + * @run junit/othervm javax.xml.validation.ptests.ValidatorHandlerTest * @summary Class containing the test cases for ValidatorHandler API */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ValidatorHandlerTest { - @BeforeClass + @BeforeAll public void setup() throws SAXException { schema = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(new File(XML_DIR + "test.xsd")); @@ -66,60 +68,57 @@ public class ValidatorHandlerTest { ErrorHandler handler = new MyErrorHandler(); validatorHandler.setErrorHandler(handler); - assertSame(validatorHandler.getErrorHandler(), handler); - + assertSame(handler, validatorHandler.getErrorHandler()); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetUnrecognizedProperty() { ValidatorHandler validatorHandler = getValidatorHandler(); - validatorHandler.getProperty(FEATURE_NAME); - + assertThrows(SAXNotRecognizedException.class, () -> validatorHandler.getProperty(FEATURE_NAME)); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetUnrecognizedProperty() { ValidatorHandler validatorHandler = getValidatorHandler(); - validatorHandler.setProperty(FEATURE_NAME, "test"); + assertThrows(SAXNotRecognizedException.class, () -> validatorHandler.setProperty(FEATURE_NAME, "test")); } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullProperty() { ValidatorHandler validatorHandler = getValidatorHandler(); assertNotNull(validatorHandler); - validatorHandler.getProperty(null); + assertThrows(NullPointerException.class, () -> validatorHandler.getProperty(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullProperty() { ValidatorHandler validatorHandler = getValidatorHandler(); assertNotNull(validatorHandler); - validatorHandler.setProperty(null, "test"); + assertThrows(NullPointerException.class, () -> validatorHandler.setProperty(null, "test")); } + @Test public void testFeature() throws SAXNotRecognizedException, SAXNotSupportedException { ValidatorHandler validatorHandler = getValidatorHandler(); assertFalse(validatorHandler.getFeature(FEATURE_NAME), "The feature should be false by default."); validatorHandler.setFeature(FEATURE_NAME, true); assertTrue(validatorHandler.getFeature(FEATURE_NAME), "The feature should be false by default."); - } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullFeature() { ValidatorHandler validatorHandler = getValidatorHandler(); assertNotNull(validatorHandler); - validatorHandler.getFeature(null); - + assertThrows(NullPointerException.class, () -> validatorHandler.getFeature(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullFeature() { ValidatorHandler validatorHandler = getValidatorHandler(); assertNotNull(validatorHandler); - validatorHandler.setFeature(null, true); + assertThrows(NullPointerException.class, () -> validatorHandler.setFeature(null, true)); } @Test @@ -129,11 +128,10 @@ public class ValidatorHandlerTest { ContentHandler handler = new DefaultHandler(); validatorHandler.setContentHandler(handler); - assertSame(validatorHandler.getContentHandler(), handler); + assertSame(handler, validatorHandler.getContentHandler()); validatorHandler.setContentHandler(null); assertNull(validatorHandler.getContentHandler()); - } private ValidatorHandler getValidatorHandler() { diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java index 6dbd38a7fa1..f2cbeb1ebeb 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,15 +22,18 @@ */ package javax.xml.validation.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; - -import java.io.File; -import java.io.IOException; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -44,33 +47,33 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.helpers.DefaultHandler; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.validation.ptests.ValidatorTest + * @run junit/othervm javax.xml.validation.ptests.ValidatorTest * @summary Class containing the test cases for Validator API */ +@TestInstance(Lifecycle.PER_CLASS) public class ValidatorTest { - @BeforeClass + @BeforeAll public void setup() throws SAXException, IOException, ParserConfigurationException { schema = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(new File(XML_DIR + "test.xsd")); assertNotNull(schema); - xmlFileUri = filenameToURL(XML_DIR + "test.xml"); + xmlFileUri = Paths.get(XML_DIR).resolve("test.xml").toUri().toASCIIString(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); @@ -84,11 +87,11 @@ public class ValidatorTest { validator.validate(getStreamSource()); } - @Test(expectedExceptions = NullPointerException.class) - public void testValidateNullSource() throws SAXException, IOException { + @Test + public void testValidateNullSource() { Validator validator = getValidator(); assertNotNull(validator); - validator.validate(null); + assertThrows(NullPointerException.class, () -> validator.validate(null)); } @Test @@ -98,11 +101,10 @@ public class ValidatorTest { ErrorHandler mh = new MyErrorHandler(); validator.setErrorHandler(mh); - assertSame(validator.getErrorHandler(), mh); + assertSame(mh, validator.getErrorHandler()); } - @DataProvider(name = "source-result") public Object[][] getSourceAndResult() { return new Object[][] { { getStreamSource(), null }, @@ -112,66 +114,65 @@ public class ValidatorTest { { getDOMSource(), null } }; } - @Test(dataProvider = "source-result") + @ParameterizedTest + @MethodSource("getSourceAndResult") public void testValidateWithResult(Source source, Result result) throws SAXException, IOException { Validator validator = getValidator(); validator.validate(source, result); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetUnrecognizedProperty() { Validator validator = getValidator(); - validator.getProperty(UNRECOGNIZED_NAME); + assertThrows(SAXNotRecognizedException.class, () -> validator.getProperty(UNRECOGNIZED_NAME)); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetUnrecognizedProperty() { Validator validator = getValidator(); - validator.setProperty(UNRECOGNIZED_NAME, "test"); + assertThrows(SAXNotRecognizedException.class, () -> validator.setProperty(UNRECOGNIZED_NAME, "test")); } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullProperty() { Validator validator = getValidator(); assertNotNull(validator); - validator.getProperty(null); - + assertThrows(NullPointerException.class, () -> validator.getProperty(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullProperty() { Validator validator = getValidator(); assertNotNull(validator); - validator.setProperty(null, "test"); + assertThrows(NullPointerException.class, () -> validator.setProperty(null, "test")); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetUnrecognizedFeature() { Validator validator = getValidator(); - validator.getFeature(UNRECOGNIZED_NAME); + assertThrows(SAXNotRecognizedException.class, () -> validator.getFeature(UNRECOGNIZED_NAME)); } - @Test(expectedExceptions = SAXNotRecognizedException.class) - public void testSetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetUnrecognizedFeature() { Validator validator = getValidator(); - validator.setFeature(UNRECOGNIZED_NAME, true); + assertThrows(SAXNotRecognizedException.class, () -> validator.setFeature(UNRECOGNIZED_NAME, true)); } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testGetNullFeature() { Validator validator = getValidator(); assertNotNull(validator); - validator.getFeature(null); - + assertThrows(NullPointerException.class, () -> validator.getFeature(null)); } - @Test(expectedExceptions = NullPointerException.class) - public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { + @Test + public void testSetNullFeature() { Validator validator = getValidator(); assertNotNull(validator); - validator.setFeature(null, true); + assertThrows(NullPointerException.class, () -> validator.setFeature(null, true)); } private Validator getValidator() { @@ -204,5 +205,4 @@ public class ValidatorTest { private String xmlFileUri; private Schema schema; private Document xmlDoc; - } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java index 5daf8adcfa6..81a9fdfa099 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,34 +23,32 @@ package javax.xml.xpath.ptests; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.Node; import javax.xml.namespace.QName; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathEvaluationResult; import javax.xml.xpath.XPathNodes; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /* * @test * @bug 8183266 * @summary verifies the specification of the XPathEvaluationResult API * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.xpath.ptests.XPathEvaluationResultTest + * @run junit/othervm javax.xml.xpath.ptests.XPathEvaluationResultTest */ public class XPathEvaluationResultTest { /* * Test getQNameType returns QName type for supported types and Number subtypes */ - @Test(dataProvider = "supportedTypes") + @ParameterizedTest + @MethodSource("getSupportedTypes") public void testQNameTypeSupportedTypes(QName expectedQName, Class type) { QName qName = XPathEvaluationResult.XPathResultType.getQNameType(type); assertNotNull(qName); @@ -60,53 +58,16 @@ public class XPathEvaluationResultTest { /* * Test getQNameType returns null when type is not supported */ - @Test(dataProvider = "unsupportedTypes") - public void testQNameTypeUnsupportedTypes(Class type) { - QName qName = XPathEvaluationResult.XPathResultType.getQNameType(type); - assertNull(qName); - } - - /* - * Test getQNameType is null safe - */ - @Test - public void testQNameTypeNullType() { - QName qName = XPathEvaluationResult.XPathResultType.getQNameType(null); - assertNull(qName); - } - - /* - * DataProvider: Class types supported - */ - @DataProvider(name = "supportedTypes") - public Object[][] getSupportedTypes() { - return new Object[][]{ - {XPathConstants.STRING, String.class}, - {XPathConstants.BOOLEAN, Boolean.class}, - {XPathConstants.NODESET, XPathNodes.class}, - {XPathConstants.NODE, Node.class}, - {XPathConstants.NUMBER, Long.class}, - {XPathConstants.NUMBER, Integer.class}, - {XPathConstants.NUMBER, Double.class}, - {XPathConstants.NUMBER, Number.class} - }; - } - - /* - * DataProvider: Class types not supported - */ - @DataProvider(name = "unsupportedTypes") - public Object[][] getUnsupportedTypes() { - return new Object[][]{ - new Object[]{AtomicInteger.class}, - new Object[]{AtomicLong.class}, - new Object[]{BigDecimal.class}, - new Object[]{BigInteger.class}, - new Object[]{Byte.class}, - new Object[]{Float.class}, - new Object[]{Short.class}, - new Object[]{Character.class}, - new Object[]{StringBuilder.class}, + public static Object[][] getSupportedTypes() { + return new Object[][] { + { XPathConstants.STRING, String.class }, + { XPathConstants.BOOLEAN, Boolean.class }, + { XPathConstants.NODESET, XPathNodes.class }, + { XPathConstants.NODE, Node.class }, + { XPathConstants.NUMBER, Long.class }, + { XPathConstants.NUMBER, Integer.class }, + { XPathConstants.NUMBER, Double.class }, + { XPathConstants.NUMBER, Number.class } }; } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java index c63b161aae9..bdd21937504 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,32 +23,33 @@ package javax.xml.xpath.ptests; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + import static javax.xml.xpath.XPathConstants.BOOLEAN; import static javax.xml.xpath.XPathConstants.NODE; import static javax.xml.xpath.XPathConstants.NODESET; import static javax.xml.xpath.XPathConstants.NUMBER; import static javax.xml.xpath.XPathConstants.STRING; import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import javax.xml.XMLConstants; -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for XPathExpression API. @@ -56,7 +57,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.xpath.ptests.XPathExpressionTest + * @run junit/othervm javax.xml.xpath.ptests.XPathExpressionTest */ public class XPathExpressionTest { /** @@ -77,7 +78,7 @@ public class XPathExpressionTest { /** * XML File Path. */ - private static final Path XML_PATH = Paths.get(XML_DIR + "widgets.xml"); + private static final Path XML_PATH = XML_DIR.resolve("widgets.xml"); /** * An expression name which locate at "/widgets/widget[@name='a']/@quantity" @@ -93,7 +94,7 @@ public class XPathExpressionTest { * Create Document object and XPath object for every time * @throws Exception If any errors occur. */ - @BeforeTest + @BeforeEach public void setup() throws Exception { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile()); xpath = XPathFactory.newInstance().newXPath(); @@ -102,303 +103,190 @@ public class XPathExpressionTest { /** * Test for evaluate(java.lang.Object item,QName returnType)throws * XPathExpressionException. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression01() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(document, STRING), "6"); + assertEquals("6", xpath.compile(EXPRESSION_NAME_A). + evaluate(document, STRING)); } /** * evaluate(java.lang.Object item,QName returnType) throws NPE if input * source is null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression02() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(null, STRING); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(NullPointerException.class, () -> expr.evaluate(null, STRING)); } /** * evaluate(java.lang.Object item,QName returnType) throws NPE if returnType * is null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression03() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(document, null); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(NullPointerException.class, () -> expr.evaluate(document, null)); } /** * Test for method evaluate(java.lang.Object item,QName returnType).If a * request is made to evaluate the expression in the absence of a context * item, simple expressions, such as "1+1", can be evaluated. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression04() throws XPathExpressionException { - assertEquals(xpath.compile("1+1").evaluate(document, STRING), "2"); + assertEquals("2", xpath.compile("1+1").evaluate(document, STRING)); } /** * evaluate(java.lang.Object item,QName returnType) throws IAE If returnType * is not one of the types defined in XPathConstants. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testCheckXPathExpression05() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(document, TEST_QNAME); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(IllegalArgumentException.class, () -> expr.evaluate(document, TEST_QNAME)); } /** * evaluate(java.lang.Object item,QName returnType) return correct boolean * value if returnType is Boolean. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression06() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(document, BOOLEAN), true); + assertEquals(true, xpath.compile(EXPRESSION_NAME_A). + evaluate(document, BOOLEAN)); } /** * evaluate(java.lang.Object item,QName returnType) return correct boolean * value if returnType is Boolean. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression07() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_B). - evaluate(document, BOOLEAN), false); + assertEquals(false, xpath.compile(EXPRESSION_NAME_B). + evaluate(document, BOOLEAN)); } /** * evaluate(java.lang.Object item,QName returnType) return correct number * value when return type is Double. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression08() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(document, NUMBER), 6d); + assertEquals(6d, xpath.compile(EXPRESSION_NAME_A). + evaluate(document, NUMBER)); } /** * evaluate(java.lang.Object item,QName returnType) evaluate an attribute * value which returnType is Node. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression09() throws XPathExpressionException { Attr attr = (Attr) xpath.compile(EXPRESSION_NAME_A). evaluate(document, NODE); - assertEquals(attr.getValue(), "6"); + assertEquals("6", attr.getValue()); } /** * evaluate(java.lang.Object item,QName returnType) evaluate an attribute * value which returnType is NodeList. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression10() throws XPathExpressionException { NodeList nodeList = (NodeList) xpath.compile(EXPRESSION_NAME_A). evaluate(document, NODESET); Attr attr = (Attr) nodeList.item(0); - assertEquals(attr.getValue(), "6"); + assertEquals("6", attr.getValue()); } /** * Test for evaluate(java.lang.Object item) when returnType is left off of * the XPath.evaluate method, all expressions are evaluated to a String * value. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression11() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_A).evaluate(document), "6"); - } - - /** - * evaluate(java.lang.Object item) throws NPE if expression is null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. - */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPathExpression12() throws XPathExpressionException { - xpath.compile(null).evaluate(document); + assertEquals("6", xpath.compile(EXPRESSION_NAME_A).evaluate(document)); } /** * evaluate(java.lang.Object item) when a request is made to evaluate the * expression in the absence of a context item, simple expressions, such as * "1+1", can be evaluated. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ @Test public void testCheckXPathExpression13() throws XPathExpressionException { - assertEquals(xpath.compile("1+1").evaluate(document), "2"); + assertEquals("2", xpath.compile("1+1").evaluate(document)); } /** * evaluate(java.lang.Object item) throws NPE if document is null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression14() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(null); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(NullPointerException.class, () -> expr.evaluate(null)); } /** * valuate(InputSource source) return a string value if return type is * String. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression15() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is)), "6"); + assertEquals("6", xpath.compile(EXPRESSION_NAME_A). + evaluate(new InputSource(is))); } } /** * evaluate(InputSource source) throws NPE if input source is null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression16() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(null); - } - - /** - * evaluate(InputSource source) throws NPE if expression is null. - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPathExpression17() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(null).evaluate(new InputSource(is)); - } - } - - /** - * evaluate(InputSource source) throws XPathExpressionException if - * returnType is String junk characters. - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPathExpression18() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile("-*&").evaluate(new InputSource(is)); - } - } - - /** - * evaluate(InputSource source) throws XPathExpressionException if - * expression is a blank string " ". - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPathExpression19() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(" ").evaluate(new InputSource(is)); - } + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(NullPointerException.class, () -> expr.evaluate(null)); } /** * Test for evaluate(InputSource source,QName returnType) returns a string * value if returnType is String. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression20() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is), STRING), "6"); + assertEquals("6", xpath.compile(EXPRESSION_NAME_A). + evaluate(new InputSource(is), STRING)); } } /** * evaluate(InputSource source,QName returnType) throws NPE if source is * null. - * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression21() throws XPathExpressionException { - xpath.compile(EXPRESSION_NAME_A).evaluate(null, STRING); - } - - /** - * evaluate(InputSource source,QName returnType) throws NPE if expression is - * null. - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPathExpression22() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(null).evaluate(new InputSource(is), STRING); - } + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + assertThrows(NullPointerException.class, () -> expr.evaluate(null, STRING)); } /** * evaluate(InputSource source,QName returnType) throws NPE if returnType is * null. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPathExpression23() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), null); - } - } - - /** - * evaluate(InputSource source,QName returnType) throws - * XPathExpressionException if expression is junk characters. - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPathExpression24() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile("-*&").evaluate(new InputSource(is), STRING); - } - } - - /** - * evaluate(InputSource source,QName returnType) throws - * XPathExpressionException if expression is blank " ". - * - * @throws Exception If any errors occur. - */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPathExpression25() throws Exception { - try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(" ").evaluate(new InputSource(is), STRING); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + InputSource source = new InputSource(is); + assertThrows( + NullPointerException.class, + () -> expr.evaluate(source, null)); } } @@ -406,85 +294,75 @@ public class XPathExpressionTest { * evaluate(InputSource source,QName returnType) throws * IllegalArgumentException if returnType is not one of the types defined * in XPathConstants. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testCheckXPathExpression26() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), TEST_QNAME); + XPathExpression expr = xpath.compile(EXPRESSION_NAME_A); + InputSource source = new InputSource(is); + assertThrows(IllegalArgumentException.class, () -> expr.evaluate(source, TEST_QNAME)); } } /** * evaluate(InputSource source,QName returnType) return a correct boolean * value if returnType is Boolean. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression27() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is), BOOLEAN), true); + assertEquals(true, xpath.compile(EXPRESSION_NAME_A). + evaluate(new InputSource(is), BOOLEAN)); } } /** * evaluate(InputSource source,QName returnType) return a correct boolean * value if returnType is Boolean. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression28() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.compile(EXPRESSION_NAME_B). - evaluate(new InputSource(is), BOOLEAN), false); + assertEquals(false, xpath.compile(EXPRESSION_NAME_B). + evaluate(new InputSource(is), BOOLEAN)); } } /** * evaluate(InputSource source,QName returnType) return a correct number * value if returnType is Number. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression29() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is), NUMBER), 6d); + assertEquals(6d, xpath.compile(EXPRESSION_NAME_A). + evaluate(new InputSource(is), NUMBER)); } } /** * Test for evaluate(InputSource source,QName returnType) returns a node if * returnType is Node. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression30() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { Attr attr = (Attr) xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is), NODE); - assertEquals(attr.getValue(), "6"); + evaluate(new InputSource(is), NODE); + assertEquals("6", attr.getValue()); } } /** * Test for evaluate(InputSource source,QName returnType) return a node list * if returnType is NodeList. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPathExpression31() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { NodeList nodeList = (NodeList) xpath.compile(EXPRESSION_NAME_A). - evaluate(new InputSource(is), NODESET); - assertEquals(((Attr) nodeList.item(0)).getValue(), "6"); + evaluate(new InputSource(is), NODESET); + assertEquals("6", ((Attr) nodeList.item(0)).getValue()); } } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java index 561c6923eda..3c276f24908 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +23,24 @@ package javax.xml.xpath.ptests; -import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; -import static javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; +import jaxp.library.JAXPDataProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; -import jaxp.library.JAXPDataProvider; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; +import static javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Class containing the test cases for XPathFactory API. @@ -48,7 +49,8 @@ import org.testng.annotations.Test; * @test * @bug 8169778 * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.xpath.ptests.XPathFactoryTest + * @build jaxp.library.JAXPDataProvider + * @run junit/othervm javax.xml.xpath.ptests.XPathFactoryTest */ public class XPathFactoryTest { /** @@ -78,9 +80,11 @@ public class XPathFactoryTest { * * @return a data provider contains XPathFactory instantiation parameters. */ - @DataProvider(name = "parameters") - public Object[][] getValidateParameters() { - return new Object[][] { { VALID_URL, XPATH_FACTORY_CLASSNAME, null }, { VALID_URL, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + public static Object[][] getValidateParameters() { + return new Object[][] { + { VALID_URL, XPATH_FACTORY_CLASSNAME, null }, + { VALID_URL, XPATH_FACTORY_CLASSNAME, XPathFactoryTest.class.getClassLoader() }, + }; } /** @@ -94,8 +98,8 @@ public class XPathFactoryTest { XPathFactory xpf2 = XPathFactory.newInstance(DEFAULT_OBJECT_MODEL_URI); assertNotSame(xpf1, xpf2, "same instance returned:"); assertSame(xpf1.getClass(), xpf2.getClass(), - "unexpected class mismatch for newDefaultInstance():"); - assertEquals(xpf1.getClass().getName(), DEFAULT_IMPL_CLASS); + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(DEFAULT_IMPL_CLASS, xpf1.getClass().getName()); assertTrue(xpf1.isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI), "isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI):"); assertFalse(xpf1.isObjectModelSupported(INVALID_URL), @@ -107,13 +111,9 @@ public class XPathFactoryTest { * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName * points to correct implementation of javax.xml.xpath.XPathFactory , should * return newInstance of XPathFactory - * - * @param uri - * @param factoryClassName - * @param classLoader - * @throws XPathFactoryConfigurationException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("getValidateParameters") public void testNewInstance(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException { XPathFactory xpf = XPathFactory.newInstance(uri, factoryClassName, classLoader); XPath xpath = xpf.newXPath(); @@ -123,39 +123,34 @@ public class XPathFactoryTest { /** * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) - * - * @param factoryClassName - * @param classLoader - * @throws XPathFactoryConfigurationException - * is expected when factoryClassName is null */ - @Test(expectedExceptions = XPathFactoryConfigurationException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) - public void testNewInstanceWithNullFactoryClassName(String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException { - XPathFactory.newInstance(VALID_URL, factoryClassName, classLoader); + @ParameterizedTest + @MethodSource("jaxp.library.JAXPDataProvider#newInstanceNeg") + public void testNewInstanceWithNullFactoryClassName(String factoryClassName, ClassLoader classLoader) { + assertThrows( + XPathFactoryConfigurationException.class, + () -> XPathFactory.newInstance(VALID_URL, factoryClassName, classLoader)); } /** * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) uri is null , should * throw NPE - * - * @throws XPathFactoryConfigurationException */ - @Test(expectedExceptions = NullPointerException.class) - public void testNewInstanceWithNullUri() throws XPathFactoryConfigurationException { - XPathFactory.newInstance(null, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + @Test + public void testNewInstanceWithNullUri() { + assertThrows( + NullPointerException.class, + () -> XPathFactory.newInstance(null, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader())); } /** * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) - * - * @throws IllegalArgumentException - * is expected when uri is empty */ - @Test(expectedExceptions = IllegalArgumentException.class) - public void testNewInstanceWithEmptyUri() throws XPathFactoryConfigurationException { - XPathFactory.newInstance("", XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader()); + @Test + public void testNewInstanceWithEmptyUri() { + assertThrows(IllegalArgumentException.class, () -> XPathFactory.newInstance("", XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader())); } /** @@ -169,24 +164,20 @@ public class XPathFactoryTest { /** * XPathFactory.newInstance(String uri) throws NPE if uri is null. * - * @throws XPathFactoryConfigurationException If the specified object model - * is unavailable, or if there is a configuration error. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPathFactory02() throws XPathFactoryConfigurationException { - XPathFactory.newInstance(null); + @Test + public void testCheckXPathFactory02() { + assertThrows(NullPointerException.class, () -> XPathFactory.newInstance(null)); } /** * XPathFactory.newInstance(String uri) throws XPFCE if uri is just a blank * string. * - * @throws XPathFactoryConfigurationException If the specified object model - * is unavailable, or if there is a configuration error. */ - @Test(expectedExceptions = XPathFactoryConfigurationException.class) - public void testCheckXPathFactory03() throws XPathFactoryConfigurationException { - XPathFactory.newInstance(" "); + @Test + public void testCheckXPathFactory03() { + assertThrows(XPathFactoryConfigurationException.class, () -> XPathFactory.newInstance(" ")); } /** @@ -205,12 +196,10 @@ public class XPathFactoryTest { * Test for constructor - XPathFactory.newInstance(String uri) with invalid * url - "http://java.sun.com/jaxp/xpath/dom1". * - * @throws XPathFactoryConfigurationException If the specified object model - * is unavailable, or if there is a configuration error. */ - @Test(expectedExceptions = XPathFactoryConfigurationException.class) - public void testCheckXPathFactory05() throws XPathFactoryConfigurationException { - XPathFactory.newInstance(INVALID_URL); + @Test + public void testCheckXPathFactory05() { + assertThrows(XPathFactoryConfigurationException.class, () -> XPathFactory.newInstance(INVALID_URL)); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java index 07d439e5aa8..f74540d8f68 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,14 +23,15 @@ package javax.xml.xpath.ptests; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for XPathFunctionResolver. @@ -38,7 +39,7 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.xpath.ptests.XPathFunctionResolverTest + * @run junit/othervm javax.xml.xpath.ptests.XPathFunctionResolverTest */ public class XPathFunctionResolverTest { /** @@ -50,7 +51,7 @@ public class XPathFunctionResolverTest { * Create XPath object before every test. Make sure function resolver has * been set for XPath object. */ - @BeforeTest + @BeforeEach public void setup() { xpath = XPathFactory.newInstance().newXPath(); if (xpath.getXPathFunctionResolver() == null) { @@ -65,17 +66,16 @@ public class XPathFunctionResolverTest { */ @Test public void testCheckXPathFunctionResolver01() throws XPathExpressionException { - assertEquals(xpath.evaluate("round(1.7)", (Object)null), "2"); + assertEquals("2", xpath.evaluate("round(1.7)", (Object) null)); } /** * Test for resolveFunction(QName functionName,int arity); evaluate throws * NPE if functionName is null. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPathFunctionResolver02() throws XPathExpressionException { - assertEquals(xpath.evaluate(null, "5"), "2"); + @Test + public void testCheckXPathFunctionResolver02() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(null, "5")); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java index e2eb0d6a03a..7bbfaae6b76 100644 --- a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,21 +23,12 @@ package javax.xml.xpath.ptests; -import static javax.xml.xpath.XPathConstants.BOOLEAN; -import static javax.xml.xpath.XPathConstants.NODE; -import static javax.xml.xpath.XPathConstants.NODESET; -import static javax.xml.xpath.XPathConstants.NUMBER; -import static javax.xml.xpath.XPathConstants.STRING; -import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; - -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Iterator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; @@ -46,13 +37,21 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Iterator; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; +import static javax.xml.xpath.XPathConstants.BOOLEAN; +import static javax.xml.xpath.XPathConstants.NODE; +import static javax.xml.xpath.XPathConstants.NODESET; +import static javax.xml.xpath.XPathConstants.NUMBER; +import static javax.xml.xpath.XPathConstants.STRING; +import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Class containing the test cases for XPath API. @@ -60,7 +59,7 @@ import org.xml.sax.InputSource; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm javax.xml.xpath.ptests.XPathTest + * @run junit/othervm javax.xml.xpath.ptests.XPathTest */ public class XPathTest { /** @@ -81,7 +80,7 @@ public class XPathTest { /** * XML File Path. */ - private static final Path XML_PATH = Paths.get(XML_DIR + "widgets.xml"); + private static final Path XML_PATH = XML_DIR.resolve("widgets.xml"); /** * An expression name which locate at "/widgets/widget[@name='a']/@quantity" @@ -97,7 +96,7 @@ public class XPathTest { * Create Document object and XPath object for every time * @throws Exception If any errors occur. */ - @BeforeTest + @BeforeEach public void setup() throws Exception { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile()); xpath = XPathFactory.newInstance().newXPath(); @@ -111,7 +110,7 @@ public class XPathTest { */ @Test public void testCheckXPath01() throws XPathExpressionException { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, document, STRING), "6"); + assertEquals("6", xpath.evaluate(EXPRESSION_NAME_A, document, STRING)); } @@ -123,7 +122,7 @@ public class XPathTest { */ @Test public void testCheckXPath02() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_A).evaluate(document, STRING), "6"); + assertEquals("6", xpath.compile(EXPRESSION_NAME_A).evaluate(document, STRING)); } /** @@ -135,40 +134,37 @@ public class XPathTest { */ @Test public void testCheckXPath03() throws XPathExpressionException { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, document), "6"); + assertEquals("6", xpath.evaluate(EXPRESSION_NAME_A, document)); } /** * Test for XPath.compile(java.lang.String expression). If expression is * null, should throw NPE. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath04() throws XPathExpressionException { - xpath.compile(null); + @Test + public void testCheckXPath04() { + assertThrows(NullPointerException.class, () -> xpath.compile(null)); } /** * Test for XPath.compile(java.lang.String expression). If expression cannot * be compiled junk characters, should throw XPathExpressionException. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPath05() throws XPathExpressionException { - xpath.compile("-*&"); + @Test + public void testCheckXPath05() { + assertThrows(XPathExpressionException.class, () -> xpath.compile("-*&")); } /** * Test for XPath.compile(java.lang.String expression). If expression is * blank, should throw XPathExpressionException * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPath06() throws XPathExpressionException { - xpath.compile(" "); + @Test + public void testCheckXPath06() { + assertThrows(XPathExpressionException.class, () -> xpath.compile(" ")); } /** @@ -179,7 +175,7 @@ public class XPathTest { */ @Test public void testCheckXPath07() throws XPathExpressionException { - assertEquals(xpath.compile(EXPRESSION_NAME_B).evaluate(document, STRING), ""); + assertEquals("", xpath.compile(EXPRESSION_NAME_B).evaluate(document, STRING)); } @@ -187,33 +183,30 @@ public class XPathTest { * Test for XPath.evaluate(java.lang.String expression, java.lang.Object * item, QName returnType). If String expression is null, should throw NPE. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath08() throws XPathExpressionException { - xpath.evaluate(null, document, STRING); + @Test + public void testCheckXPath08() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(null, document, STRING)); } /** * Test for XPath.evaluate(java.lang.String expression, java.lang.Object * item, QName returnType). If item is null, should throw NPE. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath09() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, null, STRING); + @Test + public void testCheckXPath09() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, null, STRING)); } /** * Test for XPath.evaluate(java.lang.String expression, java.lang.Object * item, QName returnType). If returnType is null, should throw NPE. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath10() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, document, null); + @Test + public void testCheckXPath10() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, document, null)); } /** @@ -226,7 +219,7 @@ public class XPathTest { */ @Test public void testCheckXPath11() throws XPathExpressionException { - assertEquals(xpath.evaluate("1+1", document, STRING), "2"); + assertEquals("2", xpath.evaluate("1+1", document, STRING)); } /** @@ -234,11 +227,10 @@ public class XPathTest { * returnType) throws XPathExpressionException if expression is a empty * string "". * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = XPathExpressionException.class) - public void testCheckXPath12() throws XPathExpressionException { - xpath.evaluate("", document, STRING); + @Test + public void testCheckXPath12() { + assertThrows(XPathExpressionException.class, () -> xpath.evaluate("", document, STRING)); } /** @@ -246,11 +238,10 @@ public class XPathTest { * returnType) throws IllegalArgumentException if returnType is not one of * the types defined in XPathConstants. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = IllegalArgumentException.class) - public void testCheckXPath13() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, document, TEST_QNAME); + @Test + public void testCheckXPath13() { + assertThrows(IllegalArgumentException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, document, TEST_QNAME)); } /** @@ -261,7 +252,7 @@ public class XPathTest { */ @Test public void testCheckXPath14() throws XPathExpressionException { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, document, BOOLEAN), true); + assertEquals(true, xpath.evaluate(EXPRESSION_NAME_A, document, BOOLEAN)); } /** @@ -273,7 +264,7 @@ public class XPathTest { */ @Test public void testCheckXPath15() throws XPathExpressionException { - assertEquals(xpath.evaluate(EXPRESSION_NAME_B, document, BOOLEAN), false); + assertEquals(false, xpath.evaluate(EXPRESSION_NAME_B, document, BOOLEAN)); } /** @@ -284,7 +275,7 @@ public class XPathTest { */ @Test public void testCheckXPath16() throws XPathExpressionException { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, document, NUMBER), 6d); + assertEquals(6d, xpath.evaluate(EXPRESSION_NAME_A, document, NUMBER)); } @@ -296,7 +287,7 @@ public class XPathTest { */ @Test public void testCheckXPath17() throws XPathExpressionException { - assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A, document, NODE)).getValue(), "6"); + assertEquals("6", ((Attr) xpath.evaluate(EXPRESSION_NAME_A, document, NODE)).getValue()); } /** @@ -308,19 +299,18 @@ public class XPathTest { */ @Test public void testCheckXPath18() throws XPathExpressionException { - NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A, document, NODESET); - assertEquals(((Attr) nodeList.item(0)).getValue(), "6"); + NodeList nodeList = (NodeList) xpath.evaluate(EXPRESSION_NAME_A, document, NODESET); + assertEquals("6", ((Attr) nodeList.item(0)).getValue()); } /** * Test for XPath.evaluate(java.lang.String expression, java.lang.Object * item). If expression is null, should throw NPE. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath19() throws XPathExpressionException { - xpath.evaluate(null, document); + @Test + public void testCheckXPath19() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(null, document)); } /** @@ -332,30 +322,27 @@ public class XPathTest { */ @Test public void testCheckXPath20() throws XPathExpressionException { - assertEquals(xpath.evaluate("1+1", document), "2"); + assertEquals("2", xpath.evaluate("1+1", document)); } /** * XPath.evaluate(java.lang.String expression, java.lang.Object item) throws * NPE if InputSource is null. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath21() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, null); + @Test + public void testCheckXPath21() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, null)); } /** * XPath.evaluate(java.lang.String expression, InputSource source) return * correct value by looking for Node. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath22() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is)), "6"); + assertEquals("6", xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is))); } } @@ -363,23 +350,20 @@ public class XPathTest { * XPath.evaluate(java.lang.String expression, InputSource source) throws * NPE if InputSource is null. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath23() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, null); + @Test + public void testCheckXPath23() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, null)); } /** * XPath.evaluate(java.lang.String expression, InputSource source) throws * NPE if String expression is null. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath24() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(null, new InputSource(is)); + assertThrows(NullPointerException.class, () -> xpath.evaluate(null, new InputSource(is))); } } @@ -387,39 +371,33 @@ public class XPathTest { * Test for XPath.evaluate(java.lang.String expression, InputSource source). * If expression is junk characters, expression cannot be evaluated, should * throw XPathExpressionException. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = XPathExpressionException.class) + @Test public void testCheckXPath25() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate("-*&", new InputSource(is)); + assertThrows(XPathExpressionException.class, () -> xpath.evaluate("-*&", new InputSource(is))); } } /** * XPath.evaluate(java.lang.String expression, InputSource source) throws * XPathExpressionException if expression is blank " ". - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = XPathExpressionException.class) + @Test public void testCheckXPath26() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(" ", new InputSource(is)); + assertThrows(XPathExpressionException.class, () -> xpath.evaluate(" ", new InputSource(is))); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, QName * returnType) returns correct string value which return type is String. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath27() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), STRING), "6"); + assertEquals("6", xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), STRING)); } } @@ -427,62 +405,53 @@ public class XPathTest { * XPath.evaluate(java.lang.String expression, InputSource source, QName * returnType) throws NPE if source is null. * - * @throws XPathExpressionException If the expression cannot be evaluated. */ - @Test(expectedExceptions = NullPointerException.class) - public void testCheckXPath28() throws XPathExpressionException { - xpath.evaluate(EXPRESSION_NAME_A, null, STRING); + @Test + public void testCheckXPath28() { + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, null, STRING)); } /** * XPath.evaluate(java.lang.String expression, InputSource source, QName * returnType) throws NPE if expression is null. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath29() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(null, new InputSource(is), STRING); + assertThrows(NullPointerException.class, () -> xpath.evaluate(null, new InputSource(is), STRING)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) throws NPE if returnType is null. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath30() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), null); + assertThrows(NullPointerException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), null)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, QName * returnType) throws XPathExpressionException if expression is junk characters. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = XPathExpressionException.class) + @Test public void testCheckXPath31() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate("-*&", new InputSource(is), STRING); + assertThrows(XPathExpressionException.class, () -> xpath.evaluate("-*&", new InputSource(is), STRING)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, QName * returnType) throws XPathExpressionException if expression is blank " ". - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = XPathExpressionException.class) + @Test public void testCheckXPath32() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(" ", new InputSource(is), STRING); + assertThrows(XPathExpressionException.class, () -> xpath.evaluate(" ", new InputSource(is), STRING)); } } @@ -490,84 +459,72 @@ public class XPathTest { * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) throws IllegalArgumentException if returnType is not * one of the types defined in XPathConstants. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testCheckXPath33() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), TEST_QNAME); + assertThrows(IllegalArgumentException.class, () -> xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), TEST_QNAME)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) return correct boolean value if return type is Boolean. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath34() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), - BOOLEAN), true); + assertEquals(true, xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), + BOOLEAN)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) return correct boolean value if return type is Boolean. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath35() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), - BOOLEAN), false); + assertEquals(false, xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), + BOOLEAN)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) return correct number value if return type is Number. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath36() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), - NUMBER), 6d); + assertEquals(6d, xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), + NUMBER)); } } /** * XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) return correct string value if return type is Node. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath37() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A, - new InputSource(is), NODE)).getValue(), "6"); + assertEquals("6", ((Attr) xpath.evaluate(EXPRESSION_NAME_A, + new InputSource(is), NODE)).getValue()); } } /** * Test for XPath.evaluate(java.lang.String expression, InputSource source, * QName returnType) which return type is NodeList. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath38() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A, - new InputSource(is), NODESET); - assertEquals(((Attr) nodeList.item(0)).getValue(), "6"); + NodeList nodeList = (NodeList) xpath.evaluate(EXPRESSION_NAME_A, + new InputSource(is), NODESET); + assertEquals("6", ((Attr) nodeList.item(0)).getValue()); } } @@ -575,57 +532,49 @@ public class XPathTest { * Test for XPath.evaluate(java.lang.String expression, InputSource iSource, * QName returnType). If return type is Boolean, should return false as * expression is not successful in evaluating to any result. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath52() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), - BOOLEAN), false); + assertEquals(false, xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), + BOOLEAN)); } } /** * XPath.evaluate(java.lang.String expression, InputSource iSource, QName * returnType) returns correct number value which return type is Number. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath53() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), - NUMBER), 6d); + assertEquals(6d, xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), + NUMBER)); } } /** * XPath.evaluate(java.lang.String expression, InputSource iSource, QName * returnType) returns a node value if returnType is Node. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath54() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A, - new InputSource(is), NODE)).getValue(), "6"); + assertEquals("6", ((Attr) xpath.evaluate(EXPRESSION_NAME_A, + new InputSource(is), NODE)).getValue()); } } /** * XPath.evaluate(java.lang.String expression, InputSource iSource, QName * returnType) returns a node list if returnType is NodeList. - * - * @throws Exception If any errors occur. */ @Test public void testCheckXPath55() throws Exception { try (InputStream is = Files.newInputStream(XML_PATH)) { - NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A, - new InputSource(is), NODESET); - assertEquals(((Attr) nodeList.item(0)).getValue(), "6"); + NodeList nodeList = (NodeList) xpath.evaluate(EXPRESSION_NAME_A, + new InputSource(is), NODESET); + assertEquals("6", ((Attr) nodeList.item(0)).getValue()); } } @@ -647,18 +596,18 @@ public class XPathTest { */ @Test public void testCheckXPath57() { - MyNamespaceContext myNamespaceContext = new MyNamespaceContext(); - xpath.setNamespaceContext(myNamespaceContext); - assertEquals(xpath.getNamespaceContext(), myNamespaceContext); + MyNamespaceContext expectedNamespaceContext = new MyNamespaceContext(); + xpath.setNamespaceContext(expectedNamespaceContext); + assertEquals(expectedNamespaceContext, xpath.getNamespaceContext()); } /** * Test for XPath.setNamespaceContext(NamespaceContext nsContext) Establish * a namespace context. NullPointerException is thrown if nsContext is null. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath58() { - xpath.setNamespaceContext(null); + assertThrows(NullPointerException.class, () -> xpath.setNamespaceContext(null)); } /** @@ -685,9 +634,9 @@ public class XPathTest { * Test for XPath.setXPathFunctionResolver(XPathFunctionResolver resolver). * set resolver as null, should throw NPE. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath61() { - xpath.setXPathFunctionResolver(null); + assertThrows(NullPointerException.class, () -> xpath.setXPathFunctionResolver(null)); } /** @@ -714,9 +663,9 @@ public class XPathTest { * Test for XPath.setXPathVariableResolver(XPathVariableResolver resolver). * Set resolver as null, should throw NPE. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testCheckXPath64() { - xpath.setXPathVariableResolver(null); + assertThrows(NullPointerException.class, () -> xpath.setXPathVariableResolver(null)); } /** diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java index c1b3381cb98..b46829de8e1 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java @@ -22,27 +22,26 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; -import static org.w3c.dom.DOMException.INDEX_SIZE_ERR; -import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; - -import java.io.IOException; - -import javax.xml.parsers.ParserConfigurationException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.CharacterData; import org.w3c.dom.DOMException; import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import static org.w3c.dom.DOMException.INDEX_SIZE_ERR; +import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; + /* * @summary common test for the CharacterData Interface */ public abstract class AbstractCharacterDataTest { - @DataProvider(name = "data-for-length") - public Object[][] getDataForTestLength() { + public static Object[][] getDataForTestLength() { return new Object[][] { { "", 0 }, { "test", 4 } }; @@ -52,11 +51,11 @@ public abstract class AbstractCharacterDataTest { * Verify getLength method works as the spec, for an empty string, should * return zero */ - @Test(dataProvider = "data-for-length") + @ParameterizedTest + @MethodSource("getDataForTestLength") public void testGetLength(String text, int length) throws Exception { CharacterData cd = createCharacterData(text); - assertEquals(cd.getLength(), length); - + assertEquals(length, cd.getLength()); } /* @@ -66,12 +65,11 @@ public abstract class AbstractCharacterDataTest { public void testAppendData() throws Exception { CharacterData cd = createCharacterData("DOM"); cd.appendData("2"); - assertEquals(cd.getData(), "DOM2"); + assertEquals("DOM2", cd.getData()); } - @DataProvider(name = "data-for-delete") - public Object[][] getDataForTestDelete() { + public static Object[][] getDataForTestDelete() { return new Object[][] { { "DOM", 2, 1, "DO" }, { "DOM", 0, 2, "M" }, @@ -81,15 +79,15 @@ public abstract class AbstractCharacterDataTest { /* * Verify deleteData method works as the spec. */ - @Test(dataProvider = "data-for-delete") + @ParameterizedTest + @MethodSource("getDataForTestDelete") public void testDeleteData(String text, int offset, int count, String result) throws Exception { CharacterData cd = createCharacterData(text); cd.deleteData(offset, count); assertEquals(cd.getData(), result); } - @DataProvider(name = "data-for-replace") - public Object[][] getDataForTestReplace() { + public static Object[][] getDataForTestReplace() { return new Object[][] { { "DOM", 0, 3, "SAX", "SAX" }, { "DOM", 1, 1, "AA", "DAAM" }, @@ -100,15 +98,15 @@ public abstract class AbstractCharacterDataTest { /* * Verify replaceData method works as the spec. */ - @Test(dataProvider = "data-for-replace") + @ParameterizedTest + @MethodSource("getDataForTestReplace") public void testReplaceData(String text, int offset, int count, String arg, String result) throws Exception { CharacterData cd = createCharacterData(text); cd.replaceData(offset, count, arg); assertEquals(cd.getData(), result); } - @DataProvider(name = "data-for-replace-neg") - public Object[][] getDataForTestReplaceNeg() { + public static Object[][] getDataForTestReplaceNeg() { return new Object[][] { { "DOM", -1, 3, "SAX" }, //offset if neg { "DOM", 0, -1, "SAX" }, //count is neg @@ -119,19 +117,19 @@ public abstract class AbstractCharacterDataTest { * Test for replaceData method: verifies that DOMException with * INDEX_SIZE_ERR is thrown if offset or count is out of the bound. */ - @Test(dataProvider = "data-for-replace-neg") + @ParameterizedTest + @MethodSource("getDataForTestReplaceNeg") public void testReplaceDataNeg(String text, int offset, int count, String arg) throws Exception { CharacterData cd = createCharacterData(text); try { cd.replaceData(offset, count, arg); fail(DOMEXCEPTION_EXPECTED); } catch (DOMException e) { - assertEquals(e.code, INDEX_SIZE_ERR); + assertEquals(INDEX_SIZE_ERR, e.code); } } - @DataProvider(name = "data-for-insert") - public Object[][] getDataForTestInsert() { + public static Object[][] getDataForTestInsert() { return new Object[][] { { "DOM", 0, "SAX", "SAXDOM" }, { "DOM", 3, "SAX", "DOMSAX" } }; @@ -140,15 +138,15 @@ public abstract class AbstractCharacterDataTest { /* * Verify insertData method works as the spec. */ - @Test(dataProvider = "data-for-insert") + @ParameterizedTest + @MethodSource("getDataForTestInsert") public void testInsertData(String text, int offset, String arg, String result) throws Exception { CharacterData cd = createCharacterData(text); cd.insertData(offset, arg); assertEquals(cd.getData(), result); } - @DataProvider(name = "data-for-insert-neg") - public Object[][] getDataForTestInsertNeg() { + public static Object[][] getDataForTestInsertNeg() { return new Object[][] { { "DOM", -1 }, //offset is neg { "DOM", 4 } };//offset is greater than length @@ -158,14 +156,15 @@ public abstract class AbstractCharacterDataTest { * Test for insertData method: verifies that DOMException with * INDEX_SIZE_ERR is thrown if offset is out of the bound. */ - @Test(dataProvider = "data-for-insert-neg") + @ParameterizedTest + @MethodSource("getDataForTestInsertNeg") public void testInsertDataNeg(String text, int offset) throws Exception { CharacterData cd = createCharacterData(text); try { cd.insertData(offset, "TEST"); fail(DOMEXCEPTION_EXPECTED); } catch (DOMException e) { - assertEquals(e.code, INDEX_SIZE_ERR); + assertEquals(INDEX_SIZE_ERR, e.code); } } @@ -176,11 +175,10 @@ public abstract class AbstractCharacterDataTest { public void testSetData() throws Exception { CharacterData cd = createCharacterData("DOM"); cd.setData("SAX"); - assertEquals(cd.getData(), "SAX"); + assertEquals("SAX", cd.getData()); } - @DataProvider(name = "data-for-substring") - public Object[][] getDataForTestSubstring() { + public static Object[][] getDataForTestSubstring() { return new Object[][] { { "DOM Level 2", 0, 3, "DOM" }, { "DOM", 0, 3, "DOM" }, @@ -190,15 +188,14 @@ public abstract class AbstractCharacterDataTest { /* * Verify substringData method works as the spec. */ - @Test(dataProvider = "data-for-substring") + @ParameterizedTest + @MethodSource("getDataForTestSubstring") public void testSubstringData(String text, int offset, int count, String result) throws Exception { CharacterData cd = createCharacterData(text); - String retStr = cd.substringData(offset, count); - assertEquals(retStr, result); + assertEquals(result, cd.substringData(offset, count)); } - @DataProvider(name = "data-for-substring-neg") - public Object[][] getDataForTestSubstringNeg() { + public static Object[][] getDataForTestSubstringNeg() { return new Object[][] { { "DOM Level 2", -1, 3 }, //offset is neg { "DOM", 0, -1 }, //count is neg @@ -209,14 +206,15 @@ public abstract class AbstractCharacterDataTest { * Test for substringData method: verifies that DOMException with * INDEX_SIZE_ERR is thrown if offset or count is out of the bound. */ - @Test(dataProvider = "data-for-substring-neg") + @ParameterizedTest + @MethodSource("getDataForTestSubstringNeg") public void testSubstringDataNeg(String text, int offset, int count) throws Exception { CharacterData cd = createCharacterData(text); try { cd.substringData(offset, count); fail(DOMEXCEPTION_EXPECTED); } catch (DOMException e) { - assertEquals(e.code, INDEX_SIZE_ERR); + assertEquals(INDEX_SIZE_ERR, e.code); } } @@ -225,5 +223,4 @@ public abstract class AbstractCharacterDataTest { * Return a concrete CharacterData instance. */ abstract protected CharacterData createCharacterData(String text) throws IOException, SAXException, ParserConfigurationException; - } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java index bd7dfb10eab..08ba9b81055 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +23,23 @@ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.AttrTest + * @run junit/othervm org.w3c.dom.ptests.AttrTest * @summary Test for the Attr Interface */ public class AttrTest { @@ -51,12 +51,12 @@ public class AttrTest { Document document = createDOM("Attr01.xml"); //test a new created Attr Attr attr = document.createAttribute("newAttribute"); - assertEquals(attr.getName(), "newAttribute"); + assertEquals("newAttribute", attr.getName()); //test a Attr loaded from xml file Element elemNode = (Element) document.getElementsByTagName("book").item(1); Attr attr2 = (Attr) elemNode.getAttributes().item(0); - assertEquals(attr2.getName(), "category1"); + assertEquals("category1", attr2.getName()); } /* @@ -71,7 +71,7 @@ public class AttrTest { NamedNodeMap nnMap = elemNode.getAttributes(); for (int i = 0; i < nnMap.getLength(); i++) { Attr attr = (Attr) nnMap.item(i); - assertEquals(attr.getOwnerElement().getNodeName(), "book"); + assertEquals("book", attr.getOwnerElement().getNodeName()); } //test an Attr without owner node @@ -143,8 +143,7 @@ public class AttrTest { Document document = createDOM("Attr01.xml"); Attr attr = document.createAttribute("newAttribute"); attr.setValue("newVal"); - assertEquals(attr.getValue(), "newVal"); - + assertEquals("newVal", attr.getValue()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java index c3cff46c714..2f0664a8139 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,25 +22,24 @@ */ package org.w3c.dom.ptests; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import java.io.IOException; - -import javax.xml.parsers.ParserConfigurationException; - import org.w3c.dom.CharacterData; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; + +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs /javax/xml/jaxp/functional - * @run testng/othervm org.w3c.dom.ptests.CommentTest + * @run junit/othervm org.w3c.dom.ptests.CommentTest * @summary Test for Comment implementation returned by Document.createComment(String) */ public class CommentTest extends AbstractCharacterDataTest { @Override - protected CharacterData createCharacterData(String text) throws IOException, SAXException, ParserConfigurationException { + protected CharacterData createCharacterData(String text) throws ParserConfigurationException { Document document = createNewDocument(); return document.createComment(text); } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java index 3ebf28afaa7..b7b5c2669ea 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,34 +22,35 @@ */ package org.w3c.dom.ptests; -import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; -import static javax.xml.XMLConstants.XML_NS_URI; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; -import static org.w3c.dom.DOMException.NAMESPACE_ERR; -import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; +import static javax.xml.XMLConstants.XML_NS_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; +import static org.w3c.dom.DOMException.NAMESPACE_ERR; +import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.DocumentTest + * @run junit/othervm org.w3c.dom.ptests.DocumentTest * @summary Test createAttributeNS, getElementsByTagNameNS and createElementNS method of Document */ public class DocumentTest { - @DataProvider(name = "invalid-nsuri") - public Object[][] getInvalidNamespaceURI() { + public static Object[][] getInvalidNamespaceURI() { return new Object[][] { { " ", "xml:novel" }, //blank { "hello", "xml:novel" }, //unqualified @@ -61,14 +62,14 @@ public class DocumentTest { * Test for createAttributeNS method: verifies that DOMException is thrown * if reserved prefixes are used with an arbitrary namespace name. */ - @Test(dataProvider = "invalid-nsuri", expectedExceptions = DOMException.class) + @ParameterizedTest + @MethodSource("getInvalidNamespaceURI") public void testCreateAttributeNSNeg(String namespaceURI, String name) throws Exception { Document document = createDOMWithNS("DocumentTest01.xml"); - document.createAttributeNS(namespaceURI, name); + assertThrows(DOMException.class, () -> document.createAttributeNS(namespaceURI, name)); } - @DataProvider(name = "valid-nsuri") - public Object[][] getValidNamespaceURI() { + public static Object[][] getValidNamespaceURI() { return new Object[][] { { XML_NS_URI, "xml:novel" }, { XMLNS_ATTRIBUTE_NS_URI, "xmlns:novel" }, @@ -79,16 +80,16 @@ public class DocumentTest { /* * Verify the Attr from createAttributeNS. */ - @Test(dataProvider = "valid-nsuri") + @ParameterizedTest + @MethodSource("getValidNamespaceURI") public void testCreateAttributeNS(String namespaceURI, String name) throws Exception { Document document = createDOMWithNS("DocumentTest01.xml"); Attr attr = document.createAttributeNS(namespaceURI, name); - assertEquals(attr.getNamespaceURI(), namespaceURI); - assertEquals(attr.getName(), name); + assertEquals(namespaceURI, attr.getNamespaceURI()); + assertEquals(name, attr.getName()); } - @DataProvider(name = "elementName") - public Object[][] getElementName() { + public static Object[][] getElementName() { return new Object[][] { { "author", 1 }, { "b:author", 0 } }; @@ -97,25 +98,27 @@ public class DocumentTest { /* * Verify the NodeList from getElementsByTagNameNS. */ - @Test(dataProvider = "elementName") - public void testGetElementsByTagNameNS(String localName, int number) throws Exception { + @ParameterizedTest + @MethodSource("getElementName") + public void testGetElementsByTagNameNS(String localName, int expectedLength) throws Exception { Document document = createDOMWithNS("DocumentTest01.xml"); NodeList nodeList = document.getElementsByTagNameNS("urn:BooksAreUs.org:BookInfo", localName); - assertEquals(nodeList.getLength(), number); + assertEquals(expectedLength, nodeList.getLength()); } /* * Test for createElementNS method: verifies that DOMException is thrown * if reserved prefixes are used with an arbitrary namespace name. */ - @Test(dataProvider = "invalid-nsuri") + @ParameterizedTest + @MethodSource("getInvalidNamespaceURI") public void testCreateElementNSNeg(String namespaceURI, String name) throws Exception { Document document = createDOMWithNS("DocumentTest01.xml"); try { document.createElementNS(namespaceURI, name); fail(DOMEXCEPTION_EXPECTED); } catch (DOMException e) { - assertEquals(e.code, NAMESPACE_ERR); + assertEquals(NAMESPACE_ERR, e.code); } } @@ -129,9 +132,9 @@ public class DocumentTest { final String localName = "novel"; Document document = createDOMWithNS("DocumentTest01.xml"); Element element = document.createElementNS(nsURI, name); - assertEquals(element.getNamespaceURI(), nsURI); - assertEquals(element.getNodeName(), name); - assertEquals(element.getLocalName(), localName); + assertEquals(nsURI, element.getNamespaceURI()); + assertEquals(name, element.getNodeName()); + assertEquals(localName, element.getLocalName()); } /* @@ -166,9 +169,9 @@ public class DocumentTest { /* * Test createElement with unqualified xml name. */ - @Test(expectedExceptions = DOMException.class) + @Test public void testCreateElementNeg() throws Exception { Document doc = createNewDocument(); - doc.createElement("!nc$%^*(!"); + assertThrows(DOMException.class, () -> doc.createElement("!nc$%^*(!")); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java index b5265b825b0..448e358c97a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,18 +23,18 @@ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; - -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.DocumentType; import org.w3c.dom.NamedNodeMap; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.DocumentTypeTest + * @run junit/othervm org.w3c.dom.ptests.DocumentTypeTest * @summary Test DocumentType */ public class DocumentTypeTest { @@ -48,10 +48,10 @@ public class DocumentTypeTest { NamedNodeMap namedNodeMap = documentType.getEntities(); // should return both external and internal. Parameter entities are not // contained. Duplicates are discarded. - assertEquals(namedNodeMap.getLength(), 3); - assertEquals(namedNodeMap.item(0).getNodeName(), "author"); - assertEquals(namedNodeMap.item(1).getNodeName(), "test"); - assertEquals(namedNodeMap.item(2).getNodeName(), "writer"); + assertEquals(3, namedNodeMap.getLength()); + assertEquals("author", namedNodeMap.item(0).getNodeName()); + assertEquals("test", namedNodeMap.item(1).getNodeName()); + assertEquals("writer", namedNodeMap.item(2).getNodeName()); } /* @@ -61,12 +61,11 @@ public class DocumentTypeTest { public void testGetNotations() throws Exception { DocumentType documentType = createDOM("DocumentType03.xml").getDoctype(); NamedNodeMap nm = documentType.getNotations(); - assertEquals(nm.getLength(), 2); // should return 2 because the notation - // name is repeated and - // it considers only the first - // occurence - assertEquals(nm.item(0).getNodeName(), "gs"); - assertEquals(nm.item(1).getNodeName(), "name"); + // should return 2 because the notation name is repeated, + // and it considers only the first occurrence + assertEquals(2, nm.getLength()); + assertEquals("gs", nm.item(0).getNodeName()); + assertEquals("name", nm.item(1).getNodeName()); } /* @@ -75,7 +74,7 @@ public class DocumentTypeTest { @Test public void testGetName() throws Exception { DocumentType documentType = createDOM("DocumentType03.xml").getDoctype(); - assertEquals(documentType.getName(), "note"); + assertEquals("note", documentType.getName()); } /* @@ -84,8 +83,8 @@ public class DocumentTypeTest { @Test public void testGetSystemId() throws Exception { DocumentType documentType = createDOM("DocumentType05.xml").getDoctype(); - assertEquals(documentType.getSystemId(), "DocumentBuilderImpl02.dtd"); - Assert.assertNull(documentType.getPublicId()); + assertEquals("DocumentBuilderImpl02.dtd", documentType.getSystemId()); + assertNull(documentType.getPublicId()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java index 8e8191aa2a3..251279ced4f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,21 +22,22 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import javax.xml.parsers.ParserConfigurationException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; +import javax.xml.parsers.ParserConfigurationException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.DomImplementationTest + * @run junit/othervm org.w3c.dom.ptests.DomImplementationTest * @summary Test DomImplementation API */ public class DomImplementationTest { @@ -50,8 +51,8 @@ public class DomImplementationTest { final String name = "document:localName"; DOMImplementation domImpl = getDOMImplementation(); Document document = domImpl.createDocument(nsURI, name, null); - assertEquals(document.getDocumentElement().getNamespaceURI(), nsURI); - assertEquals(document.getDocumentElement().getNodeName(), name); + assertEquals(nsURI, document.getDocumentElement().getNamespaceURI()); + assertEquals(name, document.getDocumentElement().getNodeName()); } /* @@ -85,8 +86,7 @@ public class DomImplementationTest { verifyDocumentType(document.getDoctype(), name, publicId, systemId); } - @DataProvider(name = "feature-supported") - public Object[][] getFeatureSupportedList() throws ParserConfigurationException { + public static Object[][] getFeatureSupportedList() throws ParserConfigurationException { DOMImplementation impl = getDOMImplementation(); return new Object[][] { { impl, "XML", "2.0", true }, @@ -109,20 +109,21 @@ public class DomImplementationTest { /* * Verify DOMImplementation for feature supporting. */ - @Test(dataProvider = "feature-supported") + @ParameterizedTest + @MethodSource("getFeatureSupportedList") public void testHasFeature(DOMImplementation impl, String feature, String version, boolean isSupported) { - assertEquals(impl.hasFeature(feature,version), isSupported); + assertEquals(isSupported, impl.hasFeature(feature, version)); } - private DOMImplementation getDOMImplementation() throws ParserConfigurationException { + private static DOMImplementation getDOMImplementation() throws ParserConfigurationException { return createNewDocument().getImplementation(); } - private void verifyDocumentType(DocumentType documentType, String name, String publicId, String systemId) { - assertEquals(documentType.getPublicId(), publicId); - assertEquals(documentType.getSystemId(), systemId); - assertEquals(documentType.getName(), name); + private static void verifyDocumentType(DocumentType documentType, String name, String publicId, String systemId) { + assertEquals(publicId, documentType.getPublicId()); + assertEquals(systemId, documentType.getSystemId()); + assertEquals(name, documentType.getName()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java index b538f7d1738..b861e086b3e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +22,9 @@ */ package org.w3c.dom.ptests; -import static javax.xml.XMLConstants.XML_NS_URI; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import static org.w3c.dom.DOMException.INUSE_ATTRIBUTE_ERR; -import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilderFactory; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.Document; @@ -47,10 +33,25 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; + +import static javax.xml.XMLConstants.XML_NS_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.w3c.dom.DOMException.INUSE_ATTRIBUTE_ERR; +import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.ElementTest + * @run junit/othervm org.w3c.dom.ptests.ElementTest * @summary Test for the methods of Element Interface */ public class ElementTest { @@ -59,7 +60,7 @@ public class ElementTest { Document document = createDOMWithNS("ElementSample01.xml"); Element elemNode = (Element) document.getElementsByTagName("book").item(0); String s = elemNode.getAttributeNS("urn:BooksAreUs.org:BookInfo", "category"); - assertEquals(s, "research"); + assertEquals("research", s); } @Test @@ -67,7 +68,7 @@ public class ElementTest { Document document = createDOMWithNS("ElementSample01.xml"); Element elemNode = (Element) document.getElementsByTagName("book").item(0); Attr attr = elemNode.getAttributeNodeNS("urn:BooksAreUs.org:BookInfo", "category"); - assertEquals(attr.getValue(), "research"); + assertEquals("research", attr.getValue()); } @@ -80,11 +81,11 @@ public class ElementTest { Document document = createDOMWithNS("ElementSample01.xml"); Element elemNode = (Element) document.getElementsByTagName("book").item(1); Attr attr = elemNode.getAttributeNode("category1"); - assertEquals(attr.getValue(), "research"); + assertEquals("research", attr.getValue()); - assertEquals(elemNode.getTagName(), "book"); + assertEquals("book", elemNode.getTagName()); elemNode.removeAttributeNode(attr); - assertEquals(elemNode.getAttribute("category1"), ""); + assertEquals("", elemNode.getAttribute("category1")); } /* @@ -112,8 +113,8 @@ public class ElementTest { elemNode.normalize(); Node firstChild = elemNode.getFirstChild(); Node lastChild = elemNode.getLastChild(); - assertEquals(firstChild.getNodeValue(), "fjfjf"); - assertEquals(lastChild.getNodeValue(), "fjfjf"); + assertEquals("fjfjf", firstChild.getNodeValue()); + assertEquals("fjfjf", lastChild.getNodeValue()); } /* @@ -129,32 +130,32 @@ public class ElementTest { myAttr.setValue(attrValue); assertNull(elemNode.setAttributeNode(myAttr)); - assertEquals(elemNode.getAttribute(attrName), attrValue); + assertEquals(attrValue, elemNode.getAttribute(attrName)); } - @DataProvider(name = "attribute") - public Object[][] getAttributeData() { + public static Object[][] getAttributeData() { return new Object[][] { { "thisisname", "thisisitsvalue" }, { "style", "font-Family" } }; } - @Test(dataProvider = "attribute") + @ParameterizedTest + @MethodSource("getAttributeData") public void testSetAttribute(String name, String value) throws Exception { Document document = createDOM("ElementSample02.xml"); Element elemNode = document.createElement("pricetag2"); elemNode.setAttribute(name, value); - assertEquals(elemNode.getAttribute(name), value); + assertEquals(value, elemNode.getAttribute(name)); } /* * Negative test for setAttribute, null is not a valid name. */ - @Test(expectedExceptions = DOMException.class) + @Test public void testSetAttributeNeg() throws Exception { Document document = createDOM("ElementSample02.xml"); Element elemNode = document.createElement("pricetag2"); - elemNode.setAttribute(null, null); + assertThrows(DOMException.class, () -> elemNode.setAttribute(null, null)); } /* @@ -182,7 +183,7 @@ public class ElementTest { element3.setAttributeNode(attr); fail(DOMEXCEPTION_EXPECTED); } catch (DOMException doe) { - assertEquals(doe.code, INUSE_ATTRIBUTE_ERR); + assertEquals(INUSE_ATTRIBUTE_ERR, doe.code); } } @@ -201,8 +202,7 @@ public class ElementTest { assertNull(nl.item(0)); } - @DataProvider(name = "nsattribute") - public Object[][] getNSAttributeData() { + public static Object[][] getNSAttributeData() { return new Object[][] { { "h:html", "html", "attrValue" }, { "b:style", "style", "attrValue" } }; @@ -211,14 +211,15 @@ public class ElementTest { /* * setAttributeNodeNS and verify it with getAttributeNS. */ - @Test(dataProvider = "nsattribute") + @ParameterizedTest + @MethodSource("getNSAttributeData") public void testSetAttributeNodeNS(String qualifiedName, String localName, String value) throws Exception { Document document = createDOM("ElementSample03.xml"); Element elemNode = document.createElement("pricetag2"); Attr myAttr = document.createAttributeNS(XML_NS_URI, qualifiedName); myAttr.setValue(value); assertNull(elemNode.setAttributeNodeNS(myAttr)); - assertEquals(elemNode.getAttributeNS(XML_NS_URI, localName), value); + assertEquals(value, elemNode.getAttributeNS(XML_NS_URI, localName)); } @Test @@ -233,22 +234,23 @@ public class ElementTest { @Test public void testToString() throws Exception { final String xml = - "" - + "" - + "" - + " \n" - + " " - + " " - + ""; + """ + \ + \ + \ + + \ + \ + """; Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))); Element root = doc.getDocumentElement(); - assertEquals(root.toString(), "[datacenterlist: null]"); + assertEquals("[datacenterlist: null]", root.toString()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java index 65fe0e046ab..447100f45c9 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +22,22 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.XML_DIR; - -import java.io.File; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.XML_DIR; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.EntityChildTest + * @run junit/othervm org.w3c.dom.ptests.EntityChildTest * @summary Test DOM Parser: parsing an xml file that contains external entities. */ public class EntityChildTest { @@ -54,7 +53,7 @@ public class EntityChildTest { Element root = document.getDocumentElement(); NodeList n = root.getElementsByTagName("table"); NodeList nl = n.item(0).getChildNodes(); - assertEquals(n.getLength(), 1); - assertEquals(nl.getLength(), 3); + assertEquals(1, n.getLength()); + assertEquals(3, nl.getLength()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java index 86cd3aa7bbb..5cf6bc2387c 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,21 +22,21 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.NamedNodeMapTest + * @run junit/othervm org.w3c.dom.ptests.NamedNodeMapTest * @summary Test for the methods of NamedNodeMap Interface */ public class NamedNodeMapTest { @@ -61,9 +61,9 @@ public class NamedNodeMapTest { // setting to a new Value attr.setValue("newValue"); Node replacedAttr = namedNodeMap.setNamedItemNS(attr); // return the replaced attr - assertEquals(replacedAttr.getNodeValue(), "font-family"); + assertEquals("font-family", replacedAttr.getNodeValue()); Node updatedAttr = namedNodeMap.getNamedItemNS(nsURI, "style"); - assertEquals(updatedAttr.getNodeValue(), "newValue"); + assertEquals("newValue", updatedAttr.getNodeValue()); // creating a non existing attribute node @@ -75,7 +75,7 @@ public class NamedNodeMapTest { // checking if the node could be accessed // using the getNamedItemNS method Node newAttr = namedNodeMap.getNamedItemNS(nsURI, "newNode"); - assertEquals(newAttr.getNodeValue(), "newValue"); + assertEquals("newValue", newAttr.getNodeValue()); } /* @@ -89,7 +89,7 @@ public class NamedNodeMapTest { Node n = nodeList.item(7); NamedNodeMap namedNodeMap = n.getAttributes(); Node node = namedNodeMap.getNamedItemNS("urn:BooksAreUs.org:BookInfo", "aaa"); - assertEquals(node.getNodeValue(), "value"); + assertEquals("value", node.getNodeValue()); } @@ -107,14 +107,14 @@ public class NamedNodeMapTest { NamedNodeMap namedNodeMap = n.getAttributes(); Attr attr = document.createAttribute("name"); Node replacedAttr = namedNodeMap.setNamedItem(attr); - assertEquals(replacedAttr.getNodeValue(), "attributeValue"); + assertEquals("attributeValue", replacedAttr.getNodeValue()); Node updatedAttrNode = namedNodeMap.getNamedItem("name"); - assertEquals(updatedAttrNode.getNodeValue(), ""); + assertEquals("", updatedAttrNode.getNodeValue()); Attr newAttr = document.createAttribute("nonExistingName"); assertNull(namedNodeMap.setNamedItem(newAttr)); Node newAttrNode = namedNodeMap.getNamedItem("nonExistingName"); - assertEquals(newAttrNode.getNodeValue(), ""); + assertEquals("", newAttrNode.getNodeValue()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java index 740c28279f6..e04b24bd9ae 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,31 +22,31 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.NodeListTest + * @run junit/othervm org.w3c.dom.ptests.NodeListTest * @summary Verifies a bug found in jaxp1.0.1 and 1.1FCS. After going out of * bound, the last element of a NodeList returns null. The bug has been fixed * in jaxp 1.1.1 build. */ public class NodeListTest { - @DataProvider(name = "xml") - public Object[][] getTestData() { + public static Object[][] getTestData() { return new Object[][] { { "nodelist.xml", "document" }, { "Node01.xml", "body" } }; } - @Test(dataProvider = "xml") + @ParameterizedTest + @MethodSource("getTestData") public void lastItemTest(String xmlFileName, String nodeName) throws Exception { Document document = createDOM(xmlFileName); @@ -56,8 +56,7 @@ public class NodeListTest { Element elem1 = (Element) nl.item(n - 1); nl.item(n); Element elem3 = (Element) nl.item(n - 1); - assertEquals(elem3, elem1); - + assertEquals(elem1, elem3); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java index 8df0808f9d4..828503d0e0b 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,29 +22,10 @@ */ package org.w3c.dom.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; -import static org.w3c.dom.ptests.DOMTestUtil.GOLDEN_DIR; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import java.io.File; -import java.util.PropertyPermission; - -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; @@ -52,15 +33,35 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.w3c.dom.ptests.DOMTestUtil.GOLDEN_DIR; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.NodeTest + * @run junit/othervm org.w3c.dom.ptests.NodeTest * @summary Test Node interface */ public class NodeTest { - @DataProvider(name = "feature-supported") - public Object[][] getFeatureSupportedList() throws Exception { + public static Object[][] getFeatureSupportedList() throws Exception { Document document = createDOMWithNS("Node01.xml"); Node node = document.getElementsByTagName("body").item(0); return new Object[][] { @@ -81,9 +82,10 @@ public class NodeTest { /* * Verify Node for feature supporting. */ - @Test(dataProvider = "feature-supported") + @ParameterizedTest + @MethodSource("getFeatureSupportedList") public void testHasFeature(Node node, String feature, String version, boolean supported) { - assertEquals(node.isSupported(feature, version), supported); + assertEquals(supported, node.isSupported(feature, version)); } /* @@ -98,7 +100,7 @@ public class NodeTest { Node node = document.getElementsByTagName("title").item(0); node.appendChild(document.createTextNode("test")); root.normalize(); - assertEquals(node.getChildNodes().item(0).getNodeValue(), "Typographytest"); + assertEquals("Typographytest", node.getChildNodes().item(0).getNodeValue()); } /* @@ -154,10 +156,10 @@ public class NodeTest { Element element = (Element) document.getElementsByTagName("sender").item(0); parentElement.insertBefore(createTestDocumentFragment(document), element); - String outputfile = USER_DIR + "InsertBefore.out"; + String outputfile = "InsertBefore.out"; String goldfile = GOLDEN_DIR + "InsertBeforeGF.out"; outputXml(document, outputfile); - assertTrue(compareWithGold(goldfile, outputfile)); + assertLinesMatch(goldfile, outputfile); } @@ -172,10 +174,10 @@ public class NodeTest { Element element = (Element) document.getElementsByTagName("sender").item(0); parentElement.replaceChild(createTestDocumentFragment(document), element); - String outputfile = USER_DIR + "ReplaceChild3.out"; + String outputfile = "ReplaceChild3.out"; String goldfile = GOLDEN_DIR + "ReplaceChild3GF.out"; outputXml(document, outputfile); - assertTrue(compareWithGold(goldfile, outputfile)); + assertLinesMatch(goldfile, outputfile); } /* @@ -183,14 +185,16 @@ public class NodeTest { * with a node which was created from a different document than the one * which is trying to use this method. It should throw a DOMException. */ - @Test(expectedExceptions = DOMException.class) + @Test public void testReplaceChildNeg() throws Exception { Document document = createDOM("Node04.xml"); Document doc2 = createNewDocument(); Element parentElement = (Element) document.getElementsByTagName("to").item(0); Element element = (Element) document.getElementsByTagName("sender").item(0); - parentElement.replaceChild(createTestDocumentFragment(doc2), element); + assertThrows( + DOMException.class, () -> + parentElement.replaceChild(createTestDocumentFragment(doc2), element)); } private DocumentFragment createTestDocumentFragment(Document document) { @@ -207,4 +211,10 @@ public class NodeTest { StreamResult streamResult = new StreamResult(new File(outputFileName)); transformer.transform(domSource, streamResult); } + + private static void assertLinesMatch(String goldenFile, String actual) throws IOException { + Assertions.assertLinesMatch( + Files.readAllLines(Path.of(goldenFile)), + Files.readAllLines(Path.of(actual))); + } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java index 301df8e51c3..60630deb477 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +22,22 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createDOM; - -import java.io.IOException; - -import javax.xml.parsers.ParserConfigurationException; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Notation; import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.createDOM; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.NotationTest + * @run junit/othervm org.w3c.dom.ptests.NotationTest * @summary Test for Notation interface */ public class NotationTest { @@ -47,7 +46,7 @@ public class NotationTest { */ @Test public void testGetSystemId() throws Exception { - assertEquals(findNotation("gs").getSystemId(), "http://who.knows.where/"); + assertEquals("http://who.knows.where/", findNotation("gs").getSystemId()); } /* @@ -55,7 +54,7 @@ public class NotationTest { */ @Test public void testGetPublicId() throws Exception { - assertEquals(findNotation("pubname").getPublicId(), "pubId"); + assertEquals("pubId", findNotation("pubname").getPublicId()); } //find notation in Notation01.xml diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java index ea6a9072002..0dbff540c97 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,17 +22,17 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.ProcessingInstruction; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.PITest + * @run junit/othervm org.w3c.dom.ptests.PITest * @summary Test for the methods of Processing Instruction */ public class PITest { @@ -43,11 +43,11 @@ public class PITest { public void test() throws Exception { Document document = createDOMWithNS("PITest01.xml"); ProcessingInstruction pi = document.createProcessingInstruction("PI", "processing"); - assertEquals(pi.getData(), "processing"); - assertEquals(pi.getTarget(), "PI"); + assertEquals("processing", pi.getData()); + assertEquals("PI", pi.getTarget()); pi.setData("newProcessing"); - assertEquals(pi.getData(), "newProcessing"); + assertEquals("newProcessing", pi.getData()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java index e763eda5c35..507801d1a2d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,15 +22,7 @@ */ package org.w3c.dom.ptests; -import static org.testng.Assert.assertEquals; -import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; -import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; - -import java.io.IOException; - -import javax.xml.parsers.ParserConfigurationException; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.CharacterData; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -38,10 +30,17 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; +import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; + /* * @test * @library /javax/xml/jaxp/libs /javax/xml/jaxp/functional - * @run testng/othervm org.w3c.dom.ptests.TextTest + * @run junit/othervm org.w3c.dom.ptests.TextTest * @summary Test for Text implementation returned by Document.createTextNode(String) */ public class TextTest extends AbstractCharacterDataTest { @@ -60,8 +59,7 @@ public class TextTest extends AbstractCharacterDataTest { textNode.splitText(0); int increased = node.getChildNodes().getLength() - rawChildNum; - assertEquals(increased, 1); - + assertEquals(1, increased); } @Override diff --git a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java index 1013d5f4baf..d101b45d5f1 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,24 +22,23 @@ */ package org.w3c.dom.ptests; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static org.testng.Assert.assertEquals; - -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.TypeInfo; import org.xml.sax.InputSource; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.w3c.dom.ptests.TypeInfoTest + * @run junit/othervm org.w3c.dom.ptests.TypeInfoTest * @summary Test getTypeName and getTypeNamespace methods of TypeInfo interface */ public class TypeInfoTest { @@ -48,11 +47,14 @@ public class TypeInfoTest { */ @Test public void test() throws Exception { - TypeInfo typeInfo = getTypeOfRoot(SCHEMA_INSTANCE, "\n" + "\n"); - - assertEquals(typeInfo.getTypeName(), "Test"); - assertEquals(typeInfo.getTypeNamespace(), "testNS"); + TypeInfo typeInfo = getTypeOfRoot(SCHEMA_INSTANCE, + """ + + + """); + assertEquals("Test", typeInfo.getTypeName()); + assertEquals("testNS", typeInfo.getTypeNamespace()); } private TypeInfo getTypeOfRoot(String schemaText, String docText) throws Exception { @@ -87,53 +89,55 @@ public class TypeInfoTest { * Schema instance */ private static final String SCHEMA_INSTANCE = - "\n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + "\n"; + """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """; } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java index b43012a6197..2af17996158 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,19 +22,20 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.helpers.AttributesImpl; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Class containing the test cases for AttributesImpl API. */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.AttrImplTest + * @run junit/othervm org.xml.sax.ptests.AttrImplTest */ public class AttrImplTest { private static final String CAR_URI = "http://www.cars.com/xml"; @@ -66,8 +67,8 @@ public class AttrImplTest { attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); - assertEquals(attr.getIndex(CAR_QNAME), 0); - assertEquals(attr.getIndex(JEEP_QNAME), 1); + assertEquals(0, attr.getIndex(CAR_QNAME)); + assertEquals(1, attr.getIndex(JEEP_QNAME)); } /** @@ -79,7 +80,7 @@ public class AttrImplTest { attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); - assertEquals(attr.getIndex(JEEP_URI, JEEP_LOCALNAME), 1); + assertEquals(1, attr.getIndex(JEEP_URI, JEEP_LOCALNAME)); } /** @@ -88,7 +89,7 @@ public class AttrImplTest { @Test public void testcase03() { AttributesImpl attr = new AttributesImpl(); - assertEquals(attr.getIndex(JEEP_URI, "whl"), -1); + assertEquals(-1, attr.getIndex(JEEP_URI, "whl")); } /** @@ -100,8 +101,8 @@ public class AttrImplTest { attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); - assertEquals(attr.getType(1), JEEP_TYPE); - assertEquals(attr.getType(JEEP_QNAME), JEEP_TYPE); + assertEquals(JEEP_TYPE, attr.getType(1)); + assertEquals(JEEP_TYPE, attr.getType(JEEP_QNAME)); } /** @@ -113,9 +114,9 @@ public class AttrImplTest { attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); - assertEquals(attr.getValue(1), JEEP_VALUE); - assertEquals(attr.getValue(attr.getQName(1)), JEEP_VALUE); - assertEquals(attr.getValue(attr.getURI(1), attr.getLocalName(1)), JEEP_VALUE); + assertEquals(JEEP_VALUE, attr.getValue(1)); + assertEquals(JEEP_VALUE, attr.getValue(attr.getQName(1))); + assertEquals(JEEP_VALUE, attr.getValue(attr.getURI(1), attr.getLocalName(1))); } /** @@ -129,11 +130,11 @@ public class AttrImplTest { attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); attr.setAttribute(1, "www.megginson.com", "author", "meg", "s", "SAX2"); - assertEquals(attr.getLocalName(1), "author"); - assertEquals(attr.getQName(1), "meg"); - assertEquals(attr.getType(1), "s"); - assertEquals(attr.getType("meg"), "s"); - assertEquals(attr.getURI(1), "www.megginson.com"); + assertEquals("author", attr.getLocalName(1)); + assertEquals("meg", attr.getQName(1)); + assertEquals("s", attr.getType(1)); + assertEquals("s", attr.getType("meg")); + assertEquals("www.megginson.com", attr.getURI(1)); } /** @@ -152,11 +153,11 @@ public class AttrImplTest { attr.setValue(1, "SAX01"); attr.setURI(1, "www.megginson.com/sax/sax01"); - assertEquals(attr.getLocalName(1), "speclead"); - assertEquals(attr.getQName(1), "megi"); - assertEquals(attr.getType(1), "sax"); - assertEquals(attr.getType("megi"), "sax"); - assertEquals(attr.getURI(1), "www.megginson.com/sax/sax01"); + assertEquals("speclead", attr.getLocalName(1)); + assertEquals("megi", attr.getQName(1)); + assertEquals("sax", attr.getType(1)); + assertEquals("sax", attr.getType("megi")); + assertEquals("www.megginson.com/sax/sax01", attr.getURI(1)); } /** @@ -165,11 +166,11 @@ public class AttrImplTest { @Test public void testcase08() { AttributesImpl attr = new AttributesImpl(); - assertEquals(attr.getLength(), 0); + assertEquals(0, attr.getLength()); attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); - assertEquals(attr.getLength(), 2); + assertEquals(2, attr.getLength()); } /** @@ -189,13 +190,13 @@ public class AttrImplTest { * Javadoc says java.lang.ArrayIndexOutOfBoundsException is thrown When the * supplied index does not point to an attribute in the list. */ - @Test(expectedExceptions = ArrayIndexOutOfBoundsException.class) + @Test public void testcase10() { AttributesImpl attr = new AttributesImpl(); attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE); attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE, JEEP_VALUE); attr.removeAttribute(1); - attr.removeAttribute(1); + assertThrows(ArrayIndexOutOfBoundsException.class, () -> attr.removeAttribute(1)); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java index 5e7db17c746..687ea92c9c9 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,18 +22,17 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.File; +import org.junit.jupiter.api.Test; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; /** * This tests the Attributes interface. Here the startElement() callback of @@ -45,7 +44,7 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.AttributesNSTest + * @run junit/othervm org.xml.sax.ptests.AttributesNSTest */ public class AttributesNSTest { /** @@ -55,7 +54,7 @@ public class AttributesNSTest { */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "AttributesNS.out"; + String outputFile = "AttributesNS.out"; String goldFile = GOLDEN_DIR + "AttributesNSGF.out"; String xmlFile = XML_DIR + "namespace1.xml"; SAXParserFactory spf = SAXParserFactory.newInstance(); @@ -68,6 +67,8 @@ public class AttributesNSTest { MyAttrCHandler myAttrCHandler = new MyAttrCHandler(outputFile); saxParser.parse(new File(xmlFile), myAttrCHandler); myAttrCHandler.flushAndClose(); - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java index 6ebdf070060..e37d0b93e5d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,18 +22,17 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.File; +import org.junit.jupiter.api.Test; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; /** * This tests the Attributes interface. Here the startElement() callback of @@ -46,7 +45,7 @@ import org.testng.annotations.Test; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.AttributesTest + * @run junit/othervm org.xml.sax.ptests.AttributesTest */ public class AttributesTest { /** @@ -57,7 +56,7 @@ public class AttributesTest { */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "Attributes.out"; + String outputFile = "Attributes.out"; String goldFile = GOLDEN_DIR + "AttributesGF.out"; String xmlFile = XML_DIR + "family.xml"; @@ -70,6 +69,8 @@ public class AttributesTest { MyAttrCHandler myAttrCHandler = new MyAttrCHandler(outputFile); saxParser.parse(new File(xmlFile), myAttrCHandler); myAttrCHandler.flushAndClose(); - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java index b450caba7aa..0c06cd27b7e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,20 +22,7 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; @@ -43,6 +30,18 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParserFactory; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Class registers a content event handler to XMLReader. Content event handler * transverses XML and print all visited node when XMLreader parses XML. Test @@ -51,7 +50,7 @@ import org.xml.sax.helpers.XMLFilterImpl; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.ContentHandlerTest + * @run junit/othervm org.xml.sax.ptests.ContentHandlerTest */ public class ContentHandlerTest { /** @@ -61,7 +60,7 @@ public class ContentHandlerTest { */ @Test public void testcase01() throws Exception { - String outputFile = USER_DIR + "Content.out"; + String outputFile = "Content.out"; String goldFile = GOLDEN_DIR + "ContentGF.out"; String xmlFile = XML_DIR + "namespace1.xml"; @@ -73,7 +72,9 @@ public class ContentHandlerTest { xmlReader.setContentHandler(cHandler); xmlReader.parse(new InputSource(instream)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } @@ -112,7 +113,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write characters tag along with content of characters when meet * characters event. - * @throws IOException error happen when writing file. */ @Override public void characters(char[] ch, int start, int length) throws SAXException { @@ -123,7 +123,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write endDocument tag then flush the content and close the file when meet * endDocument event. - * @throws IOException error happen when writing file or closing file. */ @Override public void endDocument() throws SAXException { @@ -139,7 +138,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write endElement tag with namespaceURI, localName, qName to the file when * meet endElement event. - * @throws IOException error happen when writing file. */ @Override public void endElement(String namespaceURI,String localName,String qName) throws SAXException{ @@ -150,7 +148,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write endPrefixMapping tag along with prefix to the file when meet * endPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void endPrefixMapping(String prefix) throws SAXException { @@ -160,7 +157,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write ignorableWhitespace tag along with white spaces when meet * ignorableWhitespace event. - * @throws IOException error happen when writing file. */ @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { @@ -172,7 +168,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write processingInstruction tag along with target name and target data * when meet processingInstruction event. - * @throws IOException error happen when writing file. */ @Override public void processingInstruction(String target, String data) throws SAXException { @@ -196,7 +191,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write skippedEntity tag along with entity name when meet skippedEntity * event. - * @throws IOException error happen when writing file. */ @Override public void skippedEntity(String name) throws SAXException { @@ -205,7 +199,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write startDocument tag when meet startDocument event. - * @throws IOException error happen when writing file. */ @Override public void startDocument() throws SAXException { @@ -215,7 +208,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write startElement tag along with namespaceURI, localName, qName, number * of attributes and line number when meet startElement event. - * @throws IOException error happen when writing file. */ @Override public void startElement(String namespaceURI, String localName, @@ -229,7 +221,6 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { /** * Write startPrefixMapping tag along with prefix and uri when meet * startPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java index f65a290cb2c..548cb6b4e43 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,27 +22,26 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * XMLReader parse XML with default handler that transverses XML and * print all visited node. Test verifies output is same as the golden file. @@ -50,7 +49,7 @@ import org.xml.sax.helpers.DefaultHandler; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.DefaultHandlerTest + * @run junit/othervm org.xml.sax.ptests.DefaultHandlerTest */ public class DefaultHandlerTest { /** @@ -60,7 +59,7 @@ public class DefaultHandlerTest { */ @Test public void testDefaultHandler() throws Exception { - String outputFile = USER_DIR + "DefaultHandler.out"; + String outputFile = "DefaultHandler.out"; String goldFile = GOLDEN_DIR + "DefaultHandlerGF.out"; String xmlFile = XML_DIR + "namespace1.xml"; @@ -75,9 +74,9 @@ public class DefaultHandlerTest { if (File.separatorChar == '\\') newAbsolutePath = Absolutepath.replace('\\', '/'); saxparser.parse("file:///" + newAbsolutePath, handler); - - assertTrue(compareWithGold(goldFile, outputFile)); - + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } @@ -108,7 +107,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write characters tag along with content of characters when meet * characters event. - * @throws IOException error happen when writing file. */ @Override public void characters(char[] ch, int start, int length) throws SAXException { @@ -118,7 +116,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write endDocument tag then flush the content and close the file when meet * endDocument event. - * @throws IOException error happen when writing file or closing file. */ @Override public void endDocument() throws SAXException { @@ -134,7 +131,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write endElement tag with namespaceURI, localName, qName to the file when * meet endElement event. - * @throws IOException error happen when writing file. */ @Override public void endElement(String namespaceURI,String localName,String qName) throws SAXException{ @@ -145,7 +141,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write endPrefixMapping tag along with prefix to the file when meet * endPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void endPrefixMapping(String prefix) throws SAXException { @@ -155,7 +150,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write error tag along with exception to the file when meet recoverable * error event. - * @throws IOException error happen when writing file. */ @Override public void error(SAXParseException e) throws SAXException { @@ -165,7 +159,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write fatalError tag along with exception to the file when meet * unrecoverable error event. - * @throws IOException error happen when writing file. */ @Override public void fatalError(SAXParseException e) throws SAXException { @@ -174,7 +167,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write warning tag along with exception to the file when meet warning event. - * @throws IOException error happen when writing file. */ @Override public void warning(SAXParseException e) throws SAXException { @@ -184,7 +176,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write ignorableWhitespace tag along with white spaces when meet * ignorableWhitespace event. - * @throws IOException error happen when writing file. */ @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { @@ -196,7 +187,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write processingInstruction tag along with target name and target data * when meet processingInstruction event. - * @throws IOException error happen when writing file. */ @Override public void processingInstruction(String target, String data) throws SAXException { @@ -216,7 +206,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write skippedEntity tag along with entity name when meet skippedEntity * event. - * @throws IOException error happen when writing file. */ @Override public void skippedEntity(String name) throws SAXException { @@ -225,7 +214,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write startDocument tag when meet startDocument event. - * @throws IOException error happen when writing file. */ @Override public void startDocument() throws SAXException { @@ -235,7 +223,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write startElement tag along with namespaceURI, localName, qName, number * of attributes and line number when meet startElement event. - * @throws IOException error happen when writing file. */ @Override public void startElement(String namespaceURI, String localName, @@ -248,7 +235,6 @@ class MyDefaultHandler extends DefaultHandler { /** * Write startPrefixMapping tag along with prefix and uri when meet * startPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java index 507e9d28384..578ca881e48 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,28 +22,27 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * ErrorHandler unit test. Set a ErrorHandle to XMLReader. Capture fatal error * events in ErrorHandler. @@ -51,34 +50,31 @@ import org.xml.sax.helpers.XMLFilterImpl; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.EHFatalTest + * @run junit/othervm org.xml.sax.ptests.EHFatalTest */ public class EHFatalTest { /** * Error Handler to capture all error events to output file. Verifies the * output file is same as golden file. - * - * @throws Exception If any errors occur. */ @Test public void testEHFatal() throws Exception { - String outputFile = USER_DIR + "EHFatal.out"; + String outputFile = "EHFatal.out"; String goldFile = GOLDEN_DIR + "EHFatalGF.out"; String xmlFile = XML_DIR + "invalid.xml"; - try(MyErrorHandler eHandler = new MyErrorHandler(outputFile); - FileInputStream instream = new FileInputStream(xmlFile)) { - SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); - XMLReader xmlReader = saxParser.getXMLReader(); + SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); + XMLReader xmlReader = saxParser.getXMLReader(); + try (MyErrorHandler eHandler = new MyErrorHandler(outputFile); + FileInputStream instream = new FileInputStream(xmlFile)) { xmlReader.setErrorHandler(eHandler); InputSource is = new InputSource(instream); - xmlReader.parse(is); - fail("Parse should throw SAXException"); - } catch (SAXException expected) { - // This is expected. + assertThrows(SAXException.class, () -> xmlReader.parse(is)); } // Need close the output file before we compare it with golden file. - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } @@ -109,7 +105,6 @@ class MyErrorHandler extends XMLFilterImpl implements AutoCloseable { /** * Write fatalError tag along with exception to the file when meet * unrecoverable error event. - * @throws IOException error happen when writing file. */ @Override public void fatalError(SAXParseException e) throws SAXException { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java index 4ee4bf510a8..988bc3c92c9 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,13 +22,14 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; +import org.junit.jupiter.api.Test; +import org.xml.sax.helpers.NamespaceSupport; import java.util.Enumeration; -import org.testng.annotations.Test; -import org.xml.sax.helpers.NamespaceSupport; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Unit test cases for NamespaceSupport API @@ -36,7 +37,7 @@ import org.xml.sax.helpers.NamespaceSupport; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.NSSupportTest + * @run junit/othervm org.xml.sax.ptests.NSSupportTest */ public class NSSupportTest { /** @@ -70,14 +71,14 @@ public class NSSupportTest { support.declarePrefix(EMPTY_PREFIX, W3_URI); support.declarePrefix(DC_PREFIX, PURL_URI); - Enumeration e = support.getDeclaredPrefixes(); + Enumeration e = support.getDeclaredPrefixes(); int i = 0; - while(e.hasMoreElements()) { - prefixes[i++] = e.nextElement().toString(); + while (e.hasMoreElements()) { + prefixes[i++] = e.nextElement(); } support.popContext(); - assertEquals(prefixes, new String[]{EMPTY_PREFIX, DC_PREFIX}); + assertArrayEquals(new String[] { EMPTY_PREFIX, DC_PREFIX }, prefixes); } /** @@ -92,7 +93,7 @@ public class NSSupportTest { support.declarePrefix(DC_PREFIX, PURL_URI); parts = support.processName("dc:title", parts, false); support.popContext(); - assertEquals(parts, new String[]{PURL_URI, "title", "dc:title"}); + assertArrayEquals(new String[] { PURL_URI, "title", "dc:title" }, parts); } /** @@ -106,7 +107,7 @@ public class NSSupportTest { support.declarePrefix(EMPTY_PREFIX, W3_URI); parts = support.processName("a", parts, false); support.popContext(); - assertEquals(parts, new String[]{W3_URI, "a", "a"}); + assertArrayEquals(new String[] { W3_URI, "a", "a" }, parts); } @@ -121,8 +122,8 @@ public class NSSupportTest { support.declarePrefix(EMPTY_PREFIX, W3_URI); support.declarePrefix(DC_PREFIX, PURL_URI); - assertEquals(support.getURI(EMPTY_PREFIX), W3_URI); - assertEquals(support.getURI(DC_PREFIX), PURL_URI); + assertEquals(W3_URI, support.getURI(EMPTY_PREFIX)); + assertEquals(PURL_URI, support.getURI(DC_PREFIX)); support.popContext(); assertNull(support.getURI(EMPTY_PREFIX)); assertNull(support.getURI(DC_PREFIX)); diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java index 81da8f25b88..eda3dc89fed 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,14 +22,14 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import org.xml.sax.XMLReader; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.testng.annotations.Test; -import org.xml.sax.XMLReader; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Class containing the test cases for Namespace Table defined at @@ -38,7 +38,7 @@ import org.xml.sax.XMLReader; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.NSTableTest + * @run junit/othervm org.xml.sax.ptests.NSTableTest */ public class NSTableTest { private static final String NAMESPACES = diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java index b4a59180bac..4aaefefaa31 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,16 +22,7 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.FileInputStream; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -41,6 +32,15 @@ import org.xml.sax.helpers.ParserAdapter; import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLReaderAdapter; +import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Unit test cases for ParserAdapter API. By default the only features recognized @@ -49,7 +49,7 @@ import org.xml.sax.helpers.XMLReaderAdapter; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.ParserAdapterTest + * @run junit/othervm org.xml.sax.ptests.ParserAdapterTest */ public class ParserAdapterTest { /** @@ -177,9 +177,9 @@ public class ParserAdapterTest { * * @exception Exception If any errors occur. */ - @Test(expectedExceptions = SAXNotRecognizedException.class) + @Test public void getFeature03() throws Exception { - parserAdapter.getFeature("no-meaning-feature"); + assertThrows(SAXNotRecognizedException.class, () -> parserAdapter.getFeature("no-meaning-feature")); } /** @@ -228,31 +228,25 @@ public class ParserAdapterTest { /** * NPE expected when parsing a null object by ParserAdapter. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void parse01() throws Exception { - parserAdapter.parse((InputSource)null); + assertThrows(NullPointerException.class, () -> parserAdapter.parse((InputSource) null)); } /** * SAXException expected when parsing a wrong-formatter XML with ParserAdapter. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class) + @Test public void parse02() throws Exception { try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { InputSource is = new InputSource(fis); - parserAdapter.parse(is); + assertThrows(SAXException.class, () -> parserAdapter.parse(is)); } } /** * Parse a well-formatter XML with ParserAdapter. - * - * @throws Exception If any errors occur. */ @Test public void parse03() throws Exception { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java index a7463edb53c..483e8b87c1d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,13 +22,14 @@ */ package org.xml.sax.ptests; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; +import org.junit.jupiter.api.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileWriter; @@ -36,16 +37,13 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLFilterImpl; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; /** * Entity resolver should be invoked in XML parse. This test verifies parsing @@ -54,24 +52,22 @@ import org.xml.sax.helpers.XMLFilterImpl; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.ResolverTest + * @run junit/othervm org.xml.sax.ptests.ResolverTest */ -@Test public class ResolverTest { /** * Unit test for entityResolver setter. - * - * @throws Exception If any errors occur. */ + @Test public void testResolver() throws Exception { - String outputFile = USER_DIR + "EntityResolver.out"; + String outputFile = "EntityResolver.out"; String goldFile = GOLDEN_DIR + "EntityResolverGF.out"; String xmlFile = XML_DIR + "publish.xml"; Files.copy(Paths.get(XML_DIR + "publishers.dtd"), - Paths.get(USER_DIR + "publishers.dtd"), REPLACE_EXISTING); + Paths.get("publishers.dtd"), REPLACE_EXISTING); Files.copy(Paths.get(XML_DIR + "familytree.dtd"), - Paths.get(USER_DIR + "familytree.dtd"), REPLACE_EXISTING); + Paths.get("familytree.dtd"), REPLACE_EXISTING); try(FileInputStream instream = new FileInputStream(xmlFile); MyEntityResolver eResolver = new MyEntityResolver(outputFile)) { @@ -81,7 +77,9 @@ public class ResolverTest { InputSource is = new InputSource(instream); xmlReader.parse(is); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java index 4090b6b0733..377cd02ac7d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,20 +22,7 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; @@ -44,6 +31,18 @@ import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParserFactory; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Set parent of XMLFilter to XMLReader. Parsing on XML file will invoke XMLFilter * to write to output file. Test verifies output is same as the golden file. @@ -51,17 +50,15 @@ import org.xml.sax.helpers.XMLFilterImpl; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLFilterCBTest + * @run junit/othervm org.xml.sax.ptests.XMLFilterCBTest */ -@Test public class XMLFilterCBTest { /** * Test XMLFilter working with XML reader. - * - * @throws Exception If any errors occur. */ + @Test public void testXMLFilterCB() throws Exception { - String outputFile = USER_DIR + "XMLFilter.out"; + String outputFile = "XMLFilter.out"; String goldFile = GOLDEN_DIR + "XMLFilterGF.out"; String xmlFile = XML_DIR + "namespace1.xml"; @@ -74,7 +71,9 @@ public class XMLFilterCBTest { myXmlFilter.parse(new InputSource(fis)); } // Need close the output file before we compare it with golden file. - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldFile)), + Files.readAllLines(Path.of(outputFile))); } } @@ -103,7 +102,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write characters tag along with content of characters when meet * characters event. - * @throws IOException error happen when writing file. */ @Override public void characters(char[] ch, int start, int length) throws SAXException { @@ -114,7 +112,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write endDocument tag then flush the content and close the file when meet * endDocument event. - * @throws IOException error happen when writing file or closing file. */ @Override public void endDocument() throws SAXException { @@ -130,7 +127,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write endElement tag with namespaceURI, localName, qName to the file when * meet endElement event. - * @throws IOException error happen when writing file. */ @Override public void endElement(String namespaceURI,String localName,String qName) @@ -142,7 +138,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write endPrefixMapping tag along with prefix to the file when meet * endPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void endPrefixMapping(String prefix) throws SAXException { @@ -152,7 +147,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write error tag along with exception to the file when meet recoverable * error event. - * @throws IOException error happen when writing file. */ @Override public void error(SAXParseException e) throws SAXException { @@ -162,7 +156,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write fatalError tag along with exception to the file when meet * unrecoverable error event. - * @throws IOException error happen when writing file. */ @Override public void fatalError(SAXParseException e) throws SAXException { @@ -171,7 +164,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write warning tag along with exception to the file when meet warning event. - * @throws IOException error happen when writing file. */ @Override public void warning(SAXParseException e) throws SAXException { @@ -181,7 +173,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write ignorableWhitespace tag along with white spaces when meet * ignorableWhitespace event. - * @throws IOException error happen when writing file. */ @Override public void ignorableWhitespace(char[] ch, int start, int length) @@ -194,7 +185,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write processingInstruction tag along with target name and target data * when meet processingInstruction event. - * @throws IOException error happen when writing file. */ @Override public void processingInstruction(String target, String data) @@ -218,7 +208,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write skippedEntity tag along with entity name when meet skippedEntity * event. - * @throws IOException error happen when writing file. */ @Override public void skippedEntity(String name) throws SAXException { @@ -227,7 +216,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write startDocument tag when meet startDocument event. - * @throws IOException error happen when writing file. */ @Override public void startDocument() throws SAXException { @@ -237,7 +225,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write startElement tag along with namespaceURI, localName, qName, number * of attributes and line number when meet startElement event. - * @throws IOException error happen when writing file. */ @Override public void startElement(String namespaceURI, String localName, @@ -250,7 +237,6 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { /** * Write startPrefixMapping tag along with prefix and uri when meet * startPrefixMapping event. - * @throws IOException error happen when writing file. */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java index 7ba882a9d1d..ee62b896b33 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,28 +22,28 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.FileInputStream; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Unit test for XMLFilter. */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLFilterTest + * @run junit/othervm org.xml.sax.ptests.XMLFilterTest */ public class XMLFilterTest { /** @@ -132,8 +132,6 @@ public class XMLFilterTest { /** * By default true is expected get namespaces feature. - * - * @throws Exception If any errors occur. */ @Test public void getFeature01() throws Exception { @@ -148,8 +146,6 @@ public class XMLFilterTest { /** * By default false is expected get namespaces-prefix feature. - * - * @throws Exception If any errors occur. */ @Test public void getFeature02() throws Exception { @@ -163,19 +159,15 @@ public class XMLFilterTest { /** * SAXNotRecognizedException is expected when get a feature by an invalid * feature name. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXNotRecognizedException.class) + @Test public void getFeature03() throws Exception { - new XMLFilterImpl().getFeature("no-meaning-feature"); + assertThrows(SAXNotRecognizedException.class, () -> new XMLFilterImpl().getFeature("no-meaning-feature")); } /** * Set namespaces feature to a value to XMLFilter. it's expected same when * obtain it again. - * - * @throws Exception If any errors occur. */ @Test public void setFeature01() throws Exception { @@ -193,8 +185,6 @@ public class XMLFilterTest { /** * Set namespaces-prefix feature to a value to XMLFilter. it's expected same * when obtain it again. - * - * @throws Exception If any errors occur. */ @Test public void setFeature02() throws Exception { @@ -211,35 +201,31 @@ public class XMLFilterTest { /** * NullPointerException is expected when parse a null InputSource. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void parse01() throws Exception { - new XMLFilterImpl().parse((InputSource)null); + assertThrows(NullPointerException.class, () -> new XMLFilterImpl().parse((InputSource) null)); } /** * SAXException is expected when parsing a invalid formatted XML file. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void parse02() throws Exception { - try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { - new XMLFilterImpl().parse(new InputSource(fis)); + try (FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { + InputSource input = new InputSource(fis); + assertThrows(NullPointerException.class, () -> new XMLFilterImpl().parse(input)); } } /** * No exception when parse a normal XML file. - * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void parse03() throws Exception { - try(FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) { - new XMLFilterImpl().parse(new InputSource(fis)); + try (FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) { + InputSource input = new InputSource(fis); + assertThrows(NullPointerException.class, () -> new XMLFilterImpl().parse(input)); } } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java index 40462fcf076..65dbaba9971 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,28 +22,27 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.FileInputStream; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.HandlerBase; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderAdapter; +import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Class containing the test cases for XMLReaderAdapter API */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLReaderAdapterTest + * @run junit/othervm org.xml.sax.ptests.XMLReaderAdapterTest */ public class XMLReaderAdapterTest { /** @@ -64,21 +63,17 @@ public class XMLReaderAdapterTest { /** * To test the constructor that uses XMLReader. - * - * @throws Exception If any errors occur. */ @Test public void constructor02() throws Exception { XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); - assertNotNull(new XMLReaderAdapter(xmlReader)); + new XMLReaderAdapter(xmlReader); } /** * To test the parse method. The specification says that this method * will throw an exception if the embedded XMLReader does not support * the http://xml.org/sax/features/namespace-prefixes property. - * - * @throws Exception If any errors occur. */ @Test public void nsfeature01() throws Exception { @@ -93,8 +88,6 @@ public class XMLReaderAdapterTest { * To test the parse method. The specification says that this method * will throw an exception if the embedded XMLReader does not support * the http://xml.org/sax/features/namespace-prefixes property. - * - * @throws Exception If any errors occur. */ @Test public void parse01() throws Exception { diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java index a109a27bce4..c8272d186ea 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,21 +22,21 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; - -import static org.testng.Assert.assertNotNull; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.xml.sax.helpers.XMLReaderFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Unit test for XMLReaderFactory.createXMLReader API. */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLReaderFactoryTest + * @run junit/othervm org.xml.sax.ptests.XMLReaderFactoryTest */ public class XMLReaderFactoryTest { /** @@ -56,20 +56,25 @@ public class XMLReaderFactoryTest { */ @Test public void createReader02() throws SAXException { - setSystemProperty("org.xml.sax.driver", - "com.sun.org.apache.xerces.internal.parsers.SAXParser"); - assertNotNull(XMLReaderFactory. - createXMLReader("com.sun.org.apache.xerces.internal.parsers.SAXParser")); + System.setProperty("org.xml.sax.driver", + "com.sun.org.apache.xerces.internal.parsers.SAXParser"); + try { + assertNotNull(XMLReaderFactory.createXMLReader( + "com.sun.org.apache.xerces.internal.parsers.SAXParser")); + } finally { + System.clearProperty("org.xml.sax.driver"); + } } /** * SAXException expected when create XMLReader with an invalid driver name. * @throws org.xml.sax.SAXException expected Exception */ - @Test(expectedExceptions = SAXException.class, - expectedExceptionsMessageRegExp = - "SAX2 driver class org.apache.crimson.parser.ABCD not found") - public void createReader03() throws SAXException{ - XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD"); + @Test + public void createReader03() throws SAXException { + SAXException e = assertThrows( + SAXException.class, + () -> XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD")); + assertEquals("SAX2 driver class org.apache.crimson.parser.ABCD not found", e.getMessage()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java index 9874866c7ec..2e7d0bc548f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,20 +22,20 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.FileInputStream; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; -import org.testng.annotations.Test; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; +import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; /** This class contains the testcases to test XMLReader with regard to * Namespace Table defined at @@ -44,9 +44,8 @@ import org.xml.sax.XMLReader; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLReaderNSTableTest + * @run junit/othervm org.xml.sax.ptests.XMLReaderNSTableTest */ -@Test public class XMLReaderNSTableTest { /** * XML file that used to be parsed. @@ -62,11 +61,10 @@ public class XMLReaderNSTableTest { * namespace processing is enabled. namespace-prefix is also is enabled. * So it is a True-True combination. * The test is to test XMLReader with these conditions. - * - * @throws Exception If any errors occur. */ + @Test public void testWithTrueTrue() throws Exception { - String outputFile = USER_DIR + "XRNSTableTT.out"; + String outputFile = "XRNSTableTT.out"; String goldFile = GOLDEN_DIR + "NSTableTTGF.out"; SAXParserFactory spf = SAXParserFactory.newInstance(); @@ -79,18 +77,17 @@ public class XMLReaderNSTableTest { xmlReader.setContentHandler(handler); xmlReader.parse(new InputSource(fis)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch(goldFile, outputFile); } /** * Namespace processing is enabled. Hence namespace-prefix is * expected to be automatically off. So it is a True-False combination. * The test is to test XMLReader with these conditions. - * - * @throws Exception If any errors occur. */ + @Test public void testWithTrueFalse() throws Exception { - String outputFile = USER_DIR + "XRNSTableTF.out"; + String outputFile = "XRNSTableTF.out"; String goldFile = GOLDEN_DIR + "NSTableTFGF.out"; SAXParserFactory spf = SAXParserFactory.newInstance(); @@ -103,18 +100,17 @@ public class XMLReaderNSTableTest { xmlReader.setContentHandler(handler); xmlReader.parse(new InputSource(fis)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch(goldFile, outputFile); } /** * namespace processing is not enabled. Hence namespace-prefix is * expected to be automaically on. So it is a False-True combination. * The test is to test XMLReader with these conditions. - * - * @throws Exception If any errors occur. */ - public void testWithFalseTrue()throws Exception { - String outputFile = USER_DIR + "XRNSTableFT.out"; + @Test + public void testWithFalseTrue() throws Exception { + String outputFile = "XRNSTableFT.out"; String goldFile = GOLDEN_DIR + "NSTableFTGF.out"; SAXParserFactory spf = SAXParserFactory.newInstance(); @@ -125,6 +121,12 @@ public class XMLReaderNSTableTest { xmlReader.setContentHandler(handler); xmlReader.parse(new InputSource(fis)); } - assertTrue(compareWithGold(goldFile, outputFile)); + assertLinesMatch(goldFile, outputFile); + } + + private static void assertLinesMatch(String goldenFile, String actual) throws IOException { + Assertions.assertLinesMatch( + Files.readAllLines(Path.of(goldenFile)), + Files.readAllLines(Path.of(actual))); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java index 497df48f7e4..f726e19922c 100644 --- a/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,18 +22,7 @@ */ package org.xml.sax.ptests; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.xml.sax.ptests.SAXTestConst.XML_DIR; - -import java.io.FileInputStream; - -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; @@ -43,13 +32,24 @@ import org.xml.sax.ext.DeclHandler; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.XMLFilterImpl; +import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.xml.sax.ptests.SAXTestConst.XML_DIR; + /** * Class containing the test cases for SAXParser API */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm org.xml.sax.ptests.XMLReaderTest + * @run junit/othervm org.xml.sax.ptests.XMLReaderTest */ public class XMLReaderTest { @@ -309,11 +309,11 @@ public class XMLReaderTest { * * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXNotRecognizedException.class) + @Test public void featureNE01() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - spf.newSAXParser().getXMLReader().getFeature("no-meaning-feature"); + assertThrows(SAXNotRecognizedException.class, () -> spf.newSAXParser().getXMLReader().getFeature("no-meaning-feature")); } /** @@ -328,7 +328,7 @@ public class XMLReaderTest { XMLReader xmlReader = spf.newSAXParser().getXMLReader(); XMLFilterImpl xmlFilter = new XMLFilterImpl(); xmlReader.setEntityResolver(xmlFilter); - assertEquals(xmlReader.getEntityResolver(), xmlFilter); + assertEquals(xmlFilter, xmlReader.getEntityResolver()); } /** @@ -355,7 +355,7 @@ public class XMLReaderTest { XMLReader xmlReader = spf.newSAXParser().getXMLReader(); XMLFilterImpl xmlFilter = new XMLFilterImpl(); xmlReader.setDTDHandler(xmlFilter); - assertEquals(xmlReader.getDTDHandler(), xmlFilter); + assertEquals(xmlFilter, xmlReader.getDTDHandler()); } /** @@ -382,7 +382,7 @@ public class XMLReaderTest { XMLReader xmlReader = spf.newSAXParser().getXMLReader(); XMLFilterImpl xmlFilter = new XMLFilterImpl(); xmlReader.setContentHandler(xmlFilter); - assertEquals(xmlReader.getContentHandler(), xmlFilter); + assertEquals(xmlFilter, xmlReader.getContentHandler()); } /** @@ -429,11 +429,11 @@ public class XMLReaderTest { * * @throws Exception If any errors occur. */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void parse01() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - spf.newSAXParser().getXMLReader().parse((InputSource) null); + assertThrows(NullPointerException.class, () -> spf.newSAXParser().getXMLReader().parse((InputSource) null)); } /** @@ -441,12 +441,12 @@ public class XMLReaderTest { * * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXException.class) + @Test public void parse02() throws Exception { try (FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - spf.newSAXParser().getXMLReader().parse(new InputSource(fis)); + assertThrows(SAXException.class, () -> spf.newSAXParser().getXMLReader().parse(new InputSource(fis))); } } @@ -470,11 +470,11 @@ public class XMLReaderTest { * * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXNotSupportedException.class) + @Test public void xrProperty01() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); XMLReader xmlReader = spf.newSAXParser().getXMLReader(); - xmlReader.getProperty(XML_STRING); + assertThrows(SAXNotSupportedException.class, () -> xmlReader.getProperty(XML_STRING)); } /** @@ -483,11 +483,11 @@ public class XMLReaderTest { * * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXNotSupportedException.class) + @Test public void xrProperty02() throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); XMLReader xmlReader = spf.newSAXParser().getXMLReader(); - assertNull(xmlReader.getProperty(DOM_NODE)); + assertThrows(SAXNotSupportedException.class, () -> xmlReader.getProperty(DOM_NODE)); } /** @@ -623,7 +623,7 @@ class MyDeclHandler implements DeclHandler { * @param eName The name of the associated element. * @param aName The name of the attribute. * @param type A string representing the attribute type. - * @param mode A string representing the attribute defaulting mode + * @param valueDefault A string representing the attribute defaulting mode * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies. * @param value A string representing the attribute's default value, or null * if there is none. diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/AstroTest.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/AstroTest.java index a42fcd9d3d7..ae7b88c5d34 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/AstroTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/AstroTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,26 +23,25 @@ package test.astro; -import static java.lang.String.valueOf; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareWithGold; -import static org.testng.Assert.assertTrue; -import static test.astro.AstroConstants.ASTROCAT; -import static test.astro.AstroConstants.GOLDEN_DIR; - -import java.nio.file.Files; -import java.nio.file.Paths; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.transform.sax.TransformerHandler; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static java.lang.String.valueOf; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static test.astro.AstroConstants.ASTROCAT; +import static test.astro.AstroConstants.GOLDEN_DIR; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.AstroTest + * @run junit/othervm test.astro.AstroTest * @summary run astro application, test xslt * * There are vast amounts of textual astronomical data, typically user is @@ -67,10 +66,11 @@ import org.testng.annotations.Test; * AstroProcessor to test different JAXP classes and features. * */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AstroTest { private FiltersAndGolden[] data; - @BeforeClass + @BeforeAll public void setup() throws Exception { data = new FiltersAndGolden[4]; data[0] = new FiltersAndGolden(getGoldenFileName(1), astro -> astro.getRAFilter(0.106, 0.108)); @@ -82,8 +82,7 @@ public class AstroTest { /* * Provide permutations of InputSourceFactory and FilterFactory for test. */ - @DataProvider(name = "factories") - public Object[][] getQueryFactories() { + public static Object[][] getQueryFactories() { return new Object[][] { { StreamFilterFactoryImpl.class, InputSourceFactoryImpl.class }, { SAXFilterFactoryImpl.class, InputSourceFactoryImpl.class }, @@ -92,7 +91,8 @@ public class AstroTest { { StreamFilterFactoryImpl.class, DOML3InputSourceFactoryImpl.class } }; } - @Test(dataProvider = "factories") + @ParameterizedTest + @MethodSource("getQueryFactories") public void test(Class fFactClass, Class isFactClass) throws Exception { System.out.println(fFactClass.getName() +" : " + isFactClass.getName()); AstroProcessor astro = new AstroProcessor(fFactClass, ASTROCAT, isFactClass); @@ -108,10 +108,12 @@ public class AstroTest { for (int i = 0; i < filterCreators.length; i++) filters[i] = filterCreators[i].createFilter(astro); - String outputfile = Files.createTempFile(Paths.get(USER_DIR), "query" + processNum + ".out.", null).toString(); + String outputfile = Files.createTempFile(Paths.get("."), "query" + processNum + ".out.", null).toString(); System.out.println("output file: " + outputfile); astro.process(outputfile, filters); - assertTrue(compareWithGold(goldenFileName, outputfile)); + assertLinesMatch( + Files.readAllLines(Path.of(goldenFileName)), + Files.readAllLines(Path.of(outputfile))); } private String getGoldenFileName(int num) { @@ -124,8 +126,8 @@ public class AstroTest { } private static class FiltersAndGolden { - private FilterCreator[] filters; - private String goldenFileName; + private final FilterCreator[] filters; + private final String goldenFileName; FiltersAndGolden(String goldenFileName, FilterCreator... filters) { this.filters = filters; diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java index d337ee1bbad..4082e0603d6 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,26 +22,7 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS; -import static test.astro.AstroConstants.ASTROCAT; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.ls.DOMImplementationLS; @@ -50,10 +31,27 @@ import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSParser; import org.w3c.dom.ls.LSSerializer; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS; +import static test.astro.AstroConstants.ASTROCAT; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.DocumentLSTest + * @run junit/othervm test.astro.DocumentLSTest * @summary org.w3c.dom.ls tests */ public class DocumentLSTest { @@ -84,11 +82,11 @@ public class DocumentLSTest { assertTrue(src.getCertifiedText()); src.setCertifiedText(origCertified); // set back to orig - src.setSystemId(filenameToURL(ASTROCAT)); + src.setSystemId(Path.of(ASTROCAT).toUri().toASCIIString()); Document doc = domParser.parse(src); Element result = doc.getDocumentElement(); - assertEquals(result.getTagName(), "stardb"); + assertEquals("stardb", result.getTagName()); } } @@ -106,12 +104,12 @@ public class DocumentLSTest { domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE); LSInput src = impl.createLSInput(); src.setStringData(xml); - assertEquals(src.getStringData(), xml); + assertEquals(xml, src.getStringData()); Document doc = domParser.parse(src); String result = domSerializer.writeToString(doc); - assertEquals(result, "runDocumentLS_Q6"); + assertEquals("runDocumentLS_Q6", result); } /* @@ -128,7 +126,7 @@ public class DocumentLSTest { impl = (DOMImplementationLS) db.getDOMImplementation(); LSSerializer domSerializer = impl.createLSSerializer(); MyDOMOutput mydomoutput = new MyDOMOutput(); - try (OutputStream os = new FileOutputStream(USER_DIR + "test.out")) { + try (OutputStream os = new FileOutputStream("test.out")) { mydomoutput.setByteStream(os); mydomoutput.setEncoding("UTF-8"); assertTrue(domSerializer.write(doc, mydomoutput)); diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java index 75b7880a1ca..7e5000a440e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,18 +22,18 @@ */ package test.astro; -import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX; -import static javax.xml.XMLConstants.NULL_NS_URI; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; import javax.xml.namespace.QName; -import org.testng.annotations.Test; +import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX; +import static javax.xml.XMLConstants.NULL_NS_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.NamespaceContextTest + * @run junit/othervm test.astro.NamespaceContextTest * @summary javax.xml.namespace.QName tests */ public class NamespaceContextTest { @@ -47,9 +47,9 @@ public class NamespaceContextTest { @Test public void testQNameConstructor() { QName qname = new QName(NS_URI, LOCAL_PART, PREFIX); - assertEquals(qname.getNamespaceURI(), NS_URI); - assertEquals(qname.getLocalPart(), LOCAL_PART); - assertEquals(qname.getPrefix(), PREFIX); + assertEquals(NS_URI, qname.getNamespaceURI()); + assertEquals(LOCAL_PART, qname.getLocalPart()); + assertEquals(PREFIX, qname.getPrefix()); } /* @@ -59,9 +59,9 @@ public class NamespaceContextTest { @Test public void testDefaultFields() { QName qname = new QName(LOCAL_PART); // just the local part specified - assertEquals(qname.getNamespaceURI(), NULL_NS_URI); - assertEquals(qname.getLocalPart(), LOCAL_PART); - assertEquals(qname.getPrefix(), DEFAULT_NS_PREFIX); + assertEquals(NULL_NS_URI, qname.getNamespaceURI()); + assertEquals(LOCAL_PART, qname.getLocalPart()); + assertEquals(DEFAULT_NS_PREFIX, qname.getPrefix()); } /* @@ -71,9 +71,9 @@ public class NamespaceContextTest { @Test public void testDefaultPrefix() { QName qname = new QName(NS_URI, LOCAL_PART); // no pref - assertEquals(qname.getNamespaceURI(), NS_URI); - assertEquals(qname.getLocalPart(), LOCAL_PART); - assertEquals(qname.getPrefix(), DEFAULT_NS_PREFIX); + assertEquals(NS_URI, qname.getNamespaceURI()); + assertEquals(LOCAL_PART, qname.getLocalPart()); + assertEquals(DEFAULT_NS_PREFIX, qname.getPrefix()); } /* @@ -83,6 +83,6 @@ public class NamespaceContextTest { @Test public void testQNameString() { QName qname = new QName(NS_URI, LOCAL_PART, PREFIX); - assertEquals(QName.valueOf(qname.toString()), qname); + assertEquals(qname, QName.valueOf(qname.toString())); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/SAX201Test.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/SAX201Test.java index 6cdbd93ce82..3384d04161a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/SAX201Test.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/SAX201Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,15 +22,15 @@ */ package test.astro; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.XMLReader; +import javax.xml.parsers.SAXParserFactory; + /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.SAX201Test + * @run junit/othervm test.astro.SAX201Test * @summary verify SAX 2.0.1 allows to use null in setters */ public class SAX201Test { diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java index 782831e60b8..d2e5740f1f8 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,25 +22,25 @@ */ package test.astro; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static test.astro.AstroConstants.ASTROCAT; -import static test.astro.AstroConstants.JAXP_SCHEMA_LANGUAGE; -import static test.astro.AstroConstants.JAXP_SCHEMA_SOURCE; - -import java.io.File; +import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.File; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static test.astro.AstroConstants.ASTROCAT; +import static test.astro.AstroConstants.JAXP_SCHEMA_LANGUAGE; +import static test.astro.AstroConstants.JAXP_SCHEMA_SOURCE; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.SchemaValidationTest + * @run junit/othervm test.astro.SchemaValidationTest * @summary test parser sets schema related properties to do validation */ public class SchemaValidationTest { @@ -59,11 +59,10 @@ public class SchemaValidationTest { * Test SAXException shall be thrown if schemaSource is set but * schemaLanguage is not set. */ - @Test(expectedExceptions = SAXException.class) + @Test public void testSchemaValidationNeg() throws Exception { SAXParser sp = getValidatingParser(); - sp.setProperty(JAXP_SCHEMA_SOURCE, "catalog.xsd"); - sp.parse(new File(ASTROCAT), new DefaultHandler()); + assertThrows(SAXException.class, () -> sp.setProperty(JAXP_SCHEMA_SOURCE, "catalog.xsd")); } private SAXParser getValidatingParser() throws ParserConfigurationException, SAXException { diff --git a/test/jaxp/javax/xml/jaxp/functional/test/astro/XPathAPITest.java b/test/jaxp/javax/xml/jaxp/functional/test/astro/XPathAPITest.java index 04bab01fa75..b305a060459 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/astro/XPathAPITest.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/astro/XPathAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,18 +22,17 @@ */ package test.astro; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; -import static javax.xml.xpath.XPathConstants.NODESET; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertEquals; -import static test.astro.AstroConstants.ASTROCAT; -import static test.astro.AstroConstants.JAXP_SCHEMA_LANGUAGE; -import static test.astro.AstroConstants.JAXP_SCHEMA_SOURCE; - -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.Iterator; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; @@ -44,21 +43,26 @@ import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathVariableResolver; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Iterator; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; +import static javax.xml.xpath.XPathConstants.NODESET; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static test.astro.AstroConstants.ASTROCAT; +import static test.astro.AstroConstants.JAXP_SCHEMA_LANGUAGE; +import static test.astro.AstroConstants.JAXP_SCHEMA_SOURCE; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.astro.XPathAPITest + * @run junit/othervm test.astro.XPathAPITest * @summary test XPath API */ -@Test(singleThreaded = true) +@Execution(ExecutionMode.SAME_THREAD) +@TestInstance(Lifecycle.PER_CLASS) public class XPathAPITest { private static final String STARDB_STAR_3_CONSTELLATION = "//astro:stardb/astro:star[3]/astro:constellation"; private static final String STARDB_STAR = "//astro:stardb/astro:star"; @@ -66,7 +70,7 @@ public class XPathAPITest { private XPathFactory xpf; private NamespaceContext nsContext; - @BeforeClass + @BeforeAll public void setup() throws Exception { DocumentBuilderFactory df = DocumentBuilderFactory.newInstance(); df.setNamespaceAware(true); @@ -81,45 +85,49 @@ public class XPathAPITest { nsContext = new MyNamespaceContext(); } - @DataProvider(name = "nodelist-evaluator") - public Object[][] getNodeListEvaluator() throws MalformedURLException { - return new Object[][] { { (XPathEvaluator) expression -> getXPath().evaluate(expression, doc.getDocumentElement(), NODESET) }, - { (XPathEvaluator) expression -> getXPath().evaluate(expression, createXMLInputSource(), NODESET) }, - { (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(doc.getDocumentElement(), NODESET) }, - { (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(createXMLInputSource(), NODESET) } }; + public Object[] getNodeListEvaluator() { + return new Object[] { + (XPathEvaluator) expression -> getXPath().evaluate(expression, doc.getDocumentElement(), NODESET), + (XPathEvaluator) expression -> getXPath().evaluate(expression, createXMLInputSource(), NODESET), + (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(doc.getDocumentElement(), NODESET), + (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(createXMLInputSource(), NODESET), + }; } /* * Test xpath expression evaluations method that returns type indicated by * QName */ - @Test(dataProvider = "nodelist-evaluator") + @ParameterizedTest + @MethodSource("getNodeListEvaluator") public void testEvaluateNodeList(XPathEvaluator evaluator) throws Exception { NodeList o = (NodeList) evaluator.evaluate(STARDB_STAR); - assertEquals(o.getLength(), 10); + assertEquals(10, o.getLength()); } - @DataProvider(name = "string-evaluator") - public Object[][] getStringEvaluator() throws MalformedURLException { - return new Object[][] { { (XPathEvaluator) expression -> getXPath().evaluate(expression, doc.getDocumentElement()) }, - { (XPathEvaluator) expression -> getXPath().evaluate(expression, createXMLInputSource()) }, - { (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(doc.getDocumentElement()) }, - { (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(createXMLInputSource()) } }; + public Object[] getStringEvaluator() { + return new Object[] { + (XPathEvaluator) expression -> getXPath().evaluate(expression, doc.getDocumentElement()), + (XPathEvaluator) expression -> getXPath().evaluate(expression, createXMLInputSource()), + (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(doc.getDocumentElement()), + (XPathEvaluator) expression -> getXPathExpression(expression).evaluate(createXMLInputSource()), + }; } /* * Test xpath expression evaluations method that returns String */ - @Test(dataProvider = "string-evaluator") + @ParameterizedTest + @MethodSource("getStringEvaluator") public void testEvaluateString(XPathEvaluator evaluator) throws Exception { - assertEquals(evaluator.evaluate(STARDB_STAR_3_CONSTELLATION), "Psc"); + assertEquals("Psc", evaluator.evaluate(STARDB_STAR_3_CONSTELLATION)); } @Test public void testXPathVariableResolver() throws Exception { XPath xpath = getXPath(); xpath.setXPathVariableResolver(new MyXPathVariableResolver()); - assertEquals(xpath.evaluate("//astro:stardb/astro:star[astro:hr=$id]/astro:constellation", doc.getDocumentElement()), "Peg"); + assertEquals("Peg", xpath.evaluate("//astro:stardb/astro:star[astro:hr=$id]/astro:constellation", doc.getDocumentElement())); } @@ -142,15 +150,15 @@ public class XPathAPITest { return "http://www.astro.com/astro".equals(nsURI) ? "astro" : ""; } - public Iterator getPrefixes(String nsURI) { - ArrayList list = new ArrayList(); + public Iterator getPrefixes(String nsURI) { + ArrayList list = new ArrayList<>(); list.add("astro"); return list.iterator(); } } @FunctionalInterface - private interface XPathEvaluator { + public interface XPathEvaluator { Object evaluate(String expression) throws XPathExpressionException; } @@ -165,6 +173,6 @@ public class XPathAPITest { } private InputSource createXMLInputSource() { - return new InputSource(filenameToURL(ASTROCAT)); + return new InputSource(Path.of(ASTROCAT).toUri().toASCIIString()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java b/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java index b2a66629e39..a3cc438f394 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,22 +22,18 @@ */ package test.auctionportal; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static jaxp.library.JAXPTestUtilities.bomStream; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE; -import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE; -import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS; -import static test.auctionportal.HiBidConstants.XML_DIR; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.math.BigInteger; -import java.nio.file.Paths; -import java.util.GregorianCalendar; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.w3c.dom.Attr; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.w3c.dom.TypeInfo; +import org.w3c.dom.bootstrap.DOMImplementationRegistry; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSSerializer; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; @@ -51,17 +47,28 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.GregorianCalendar; -import org.testng.annotations.Test; -import org.w3c.dom.Attr; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.w3c.dom.TypeInfo; -import org.w3c.dom.bootstrap.DOMImplementationRegistry; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSSerializer; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE; +import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE; +import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS; +import static test.auctionportal.HiBidConstants.XML_DIR; /** * This is the user controller class for the Auction portal HiBid.com. @@ -69,14 +76,13 @@ import org.w3c.dom.ls.LSSerializer; /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.auctionportal.AuctionController + * @run junit/othervm test.auctionportal.AuctionController */ public class AuctionController { /** * Check for DOMErrorHandler handling DOMError. Before fix of bug 4890927 * DOMConfiguration.setParameter("well-formed",true) throws an exception. * - * @throws Exception If any errors occur. */ @Test public void testCreateNewItem2Sell() throws Exception { @@ -99,7 +105,6 @@ public class AuctionController { * Check for DOMErrorHandler handling DOMError. Before fix of bug 4896132 * test throws DOM Level 1 node error. * - * @throws Exception If any errors occur. */ @Test public void testCreateNewItem2SellRetry() throws Exception { @@ -131,7 +136,6 @@ public class AuctionController { * Check if setting the attribute to be of type ID works. This will affect * the Attr.isID method according to the spec. * - * @throws Exception If any errors occur. */ @Test public void testCreateID() throws Exception { @@ -152,7 +156,6 @@ public class AuctionController { /** * Check the user data on the node. * - * @throws Exception If any errors occur. */ @Test public void testCheckingUserData() throws Exception { @@ -164,45 +167,44 @@ public class AuctionController { DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Document document = docBuilder.parse(xmlFile); - Element account = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Account").item(0); - assertEquals(account.getNodeName(), "acc:Account"); + Element account = (Element) document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Account").item(0); + assertEquals("acc:Account", account.getNodeName()); Element firstName = (Element) document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "FirstName").item(0); - assertEquals(firstName.getNodeName(), "FirstName"); + assertEquals("FirstName", firstName.getNodeName()); Document doc1 = docBuilder.newDocument(); Element someName = doc1.createElement("newelem"); someName.setUserData("mykey", "dd", - (operation, key, data, src, dst) -> { - System.err.println("In UserDataHandler" + key); - System.out.println("In UserDataHandler"); - }); - Element impAccount = (Element)document.importNode(someName, true); - assertEquals(impAccount.getNodeName(), "newelem"); + (operation, key, data, src, dst) -> { + System.err.println("In UserDataHandler" + key); + System.out.println("In UserDataHandler"); + }); + Element impAccount = (Element) document.importNode(someName, true); + assertEquals("newelem", impAccount.getNodeName()); document.normalizeDocument(); String data = (someName.getUserData("mykey")).toString(); - assertEquals(data, "dd"); + assertEquals("dd", data); } /** * Check the UTF-16 XMLEncoding xml file. * - * @throws Exception If any errors occur. - * @see movies.xml + * @see movies-utf16.xml */ - @Test - public void testCheckingEncoding() throws Exception { - // Note since movies.xml is UTF-16 encoding. We're not using stanard XML - // file suffix. - String xmlFile = XML_DIR + "movies.xml.data"; + @ParameterizedTest + @EnumSource(value=ByteOrder.class) + public void testCheckingEncoding(ByteOrder byteOrder) throws Exception { + String xmlFile = XML_DIR + "movies-utf16.xml"; - try (InputStream source = bomStream("UTF-16", xmlFile)) { + // File is stored as UTF-8, but declares itself as UTF-16 for testing. + try (InputStream source = utf16Stream(xmlFile, byteOrder)) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document document = dbf.newDocumentBuilder().parse(source); - assertEquals(document.getXmlEncoding(), "UTF-16"); - assertEquals(document.getXmlStandalone(), true); + assertEquals("UTF-16", document.getXmlEncoding()); + assertTrue(document.getXmlStandalone()); } } @@ -210,7 +212,6 @@ public class AuctionController { * Check validation API features. A schema which is including in Bug 4909119 * used to be testing for the functionalities. * - * @throws Exception If any errors occur. * @see userDetails.xsd */ @Test @@ -244,7 +245,6 @@ public class AuctionController { /** * Check grammar caching with imported schemas. * - * @throws Exception If any errors occur. * @see coins.xsd * @see coinsImportMe.xsd */ @@ -279,7 +279,6 @@ public class AuctionController { * parsing using the SAXParser. SCHEMA_SOURCE attribute is using for this * test. * - * @throws Exception If any errors occur. * @see coins.xsd * @see coinsImportMe.xsd */ @@ -304,7 +303,6 @@ public class AuctionController { /** * Check usage of javax.xml.datatype.Duration class. * - * @throws Exception If any errors occur. */ @Test public void testGetItemDuration() throws Exception { @@ -326,18 +324,17 @@ public class AuctionController { Duration sellDuration = DatatypeFactory.newInstance().newDuration(childList.item(0).getNodeValue()); assertFalse(sellDuration.isShorterThan(duration)); assertFalse(sellDuration.isLongerThan(duration)); - assertEquals(sellDuration.getField(DatatypeConstants.DAYS), BigInteger.valueOf(365)); - assertEquals(sellDuration.normalizeWith(new GregorianCalendar(1999, 2, 22)), duration); + assertEquals(BigInteger.valueOf(365), sellDuration.getField(DatatypeConstants.DAYS)); + assertEquals(duration, sellDuration.normalizeWith(new GregorianCalendar(1999, 2, 22))); Duration myDuration = sellDuration.add(duration); - assertEquals(myDuration.normalizeWith(new GregorianCalendar(2003, 2, 22)), - DatatypeFactory.newInstance().newDuration("P730D")); + assertEquals(DatatypeFactory.newInstance().newDuration("P730D"), + myDuration.normalizeWith(new GregorianCalendar(2003, 2, 22))); } /** * Check usage of TypeInfo interface introduced in DOM L3. * - * @throws Exception If any errors occur. */ @Test public void testGetTypeInfo() throws Exception { @@ -354,12 +351,36 @@ public class AuctionController { Document document = docBuilder.parse(xmlFile); Element userId = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "UserID").item(0); TypeInfo typeInfo = userId.getSchemaTypeInfo(); - assertTrue(typeInfo.getTypeName().equals("nonNegativeInteger")); - assertTrue(typeInfo.getTypeNamespace().equals(W3C_XML_SCHEMA_NS_URI)); + assertEquals("nonNegativeInteger", typeInfo.getTypeName()); + assertEquals(W3C_XML_SCHEMA_NS_URI, typeInfo.getTypeNamespace()); Element role = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Role").item(0); TypeInfo roletypeInfo = role.getSchemaTypeInfo(); - assertTrue(roletypeInfo.getTypeName().equals("BuyOrSell")); - assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS)); + assertEquals("BuyOrSell", roletypeInfo.getTypeName()); + assertEquals(PORTAL_ACCOUNT_NS, roletypeInfo.getTypeNamespace()); + } + + /** Convert file contents to a given character set with BOM marker. */ + public static InputStream utf16Stream(String file, ByteOrder byteOrder) + throws IOException { + Charset charset; + byte[] head; + switch (byteOrder) { + case BIG_ENDIAN: + charset = StandardCharsets.UTF_16BE; + head = new byte[] { (byte) 0xFE, (byte) 0xFF }; + break; + case LITTLE_ENDIAN: + charset = StandardCharsets.UTF_16LE; + head = new byte[] { (byte) 0xFF, (byte) 0xFE }; + break; + default: + throw new AssertionError("Unsupported byte order: " + byteOrder); + } + byte[] content = Files.readString(Paths.get(file)).getBytes(charset); + ByteBuffer bb = ByteBuffer.allocate(head.length + content.length); + bb.put(head); + bb.put(content); + return new ByteArrayInputStream(bb.array()); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java b/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java index 854cb7d1ad4..dca34a73d82 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,14 +22,31 @@ */ package test.auctionportal; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Paths; import static javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static test.auctionportal.HiBidConstants.GOLDEN_DIR; import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE; import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE; @@ -37,30 +54,13 @@ import static test.auctionportal.HiBidConstants.SP_ENTITY_EXPANSION_LIMIT; import static test.auctionportal.HiBidConstants.SP_MAX_OCCUR_LIMIT; import static test.auctionportal.HiBidConstants.XML_DIR; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXParseException; - /** * This is a test class for the Auction portal HiBid.com. */ /* * @test * @library /javax/xml/jaxp/libs - * @run testng/othervm test.auctionportal.AuctionItemRepository + * @run junit/othervm test.auctionportal.AuctionItemRepository */ public class AuctionItemRepository { /** @@ -79,7 +79,6 @@ public class AuctionItemRepository { * not. Previous system property was changed to jdk.xml.entityExpansionLimit * see http://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html. * - * @throws Exception If any errors occur. */ @Test public void testEntityExpansionSAXPos() throws Exception { @@ -88,7 +87,7 @@ public class AuctionItemRepository { // implementation limits. factory.setFeature(FEATURE_SECURE_PROCESSING, true); // Set entityExpansionLimit as 2 should expect fatalError - setSystemProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(128000)); + System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(128000)); SAXParser parser = factory.newSAXParser(); MyErrorHandler fatalHandler = new MyErrorHandler(); @@ -101,27 +100,25 @@ public class AuctionItemRepository { * not. Previous system property was changed to jdk.xml.entityExpansionLimit * see http://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html. * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXParseException.class) + @Test public void testEntityExpansionSAXNeg() throws Exception { SAXParserFactory factory = SAXParserFactory.newInstance(); // Secure processing will limit XML processing to conform to // implementation limits. factory.setFeature(FEATURE_SECURE_PROCESSING, true); // Set entityExpansionLimit as 2 should expect SAXParseException. - setSystemProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2)); + System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2)); SAXParser parser = factory.newSAXParser(); MyErrorHandler fatalHandler = new MyErrorHandler(); - parser.parse(new File(ENTITY_XML), fatalHandler); + assertThrows(SAXParseException.class, () -> parser.parse(new File(ENTITY_XML), fatalHandler)); } /** * Testing set MaxOccursLimit to 10000 in the secure processing enabled for * SAXParserFactory. * - * @throws Exception If any errors occur. */ @Test public void testMaxOccurLimitPos() throws Exception { @@ -130,7 +127,7 @@ public class AuctionItemRepository { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(true); factory.setFeature(FEATURE_SECURE_PROCESSING, true); - setSystemProperty(SP_MAX_OCCUR_LIMIT, String.valueOf(10000)); + System.setProperty(SP_MAX_OCCUR_LIMIT, String.valueOf(10000)); SAXParser parser = factory.newSAXParser(); parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI); parser.setProperty(JAXP_SCHEMA_SOURCE, new File(schema_file)); @@ -145,13 +142,12 @@ public class AuctionItemRepository { * Use a DocumentBuilder to create a DOM object and see if Secure Processing * feature affects the entity expansion. * - * @throws Exception If any errors occur. */ @Test public void testEntityExpansionDOMPos() throws Exception { DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setFeature(FEATURE_SECURE_PROCESSING, true); - setSystemProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(10000)); + System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(10000)); DocumentBuilder dBuilder = dfactory.newDocumentBuilder(); MyErrorHandler eh = new MyErrorHandler(); dBuilder.setErrorHandler(eh); @@ -164,27 +160,25 @@ public class AuctionItemRepository { * Processing feature and entityExpansionLimit value affects output. * Negative test that when entityExpansionLimit is too small. * - * @throws Exception If any errors occur. */ - @Test(expectedExceptions = SAXParseException.class) + @Test public void testEntityExpansionDOMNeg() throws Exception { DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setFeature(FEATURE_SECURE_PROCESSING, true); - setSystemProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2)); + System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2)); DocumentBuilder dBuilder = dfactory.newDocumentBuilder(); MyErrorHandler eh = new MyErrorHandler(); dBuilder.setErrorHandler(eh); - dBuilder.parse(ENTITY_XML); + assertThrows(SAXParseException.class, () -> dBuilder.parse(ENTITY_XML)); } /** * Test xi:include with a SAXParserFactory. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeSAXPos() throws Exception { - String resultFile = USER_DIR + "doc_xinclude.out"; + String resultFile = "doc_xinclude.out"; String goldFile = GOLDEN_DIR + "doc_xincludeGold.xml"; String xmlFile = XML_DIR + "doc_xinclude.xml"; @@ -203,11 +197,10 @@ public class AuctionItemRepository { * Test the simple case of including a document using xi:include using a * DocumentBuilder. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeDOMPos() throws Exception { - String resultFile = USER_DIR + "doc_xincludeDOM.out"; + String resultFile = "doc_xincludeDOM.out"; String goldFile = GOLDEN_DIR + "doc_xincludeGold.xml"; String xmlFile = XML_DIR + "doc_xinclude.xml"; try (FileOutputStream fos = new FileOutputStream(resultFile)) { @@ -226,11 +219,10 @@ public class AuctionItemRepository { * Test the simple case of including a document using xi:include within a * xi:fallback using a DocumentBuilder. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeFallbackDOMPos() throws Exception { - String resultFile = USER_DIR + "doc_fallbackDOM.out"; + String resultFile = "doc_fallbackDOM.out"; String goldFile = GOLDEN_DIR + "doc_fallbackGold.xml"; String xmlFile = XML_DIR + "doc_fallback.xml"; try (FileOutputStream fos = new FileOutputStream(resultFile)) { @@ -250,11 +242,10 @@ public class AuctionItemRepository { * Test for xi:fallback where the fall back text is parsed as text. This * test uses a nested xi:include for the fallback test. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeFallbackTextPos() throws Exception { - String resultFile = USER_DIR + "doc_fallback_text.out"; + String resultFile = "doc_fallback_text.out"; String goldFile = GOLDEN_DIR + "doc_fallback_textGold.xml"; String xmlFile = XML_DIR + "doc_fallback_text.xml"; try (FileOutputStream fos = new FileOutputStream(resultFile)) { @@ -273,11 +264,10 @@ public class AuctionItemRepository { /** * Test the XPointer element() framework with XInclude. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXpointerElementPos() throws Exception { - String resultFile = USER_DIR + "doc_xpointer_element.out"; + String resultFile = "doc_xpointer_element.out"; String goldFile = GOLDEN_DIR + "doc_xpointerGold.xml"; String xmlFile = XML_DIR + "doc_xpointer_element.xml"; try (FileOutputStream fos = new FileOutputStream(resultFile)) { @@ -297,11 +287,10 @@ public class AuctionItemRepository { /** * Test the XPointer framework with a SAX object. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXPointerPos() throws Exception { - String resultFile = USER_DIR + "doc_xpointer.out"; + String resultFile = "doc_xpointer.out"; String goldFile = GOLDEN_DIR + "doc_xpointerGold.xml"; String xmlFile = XML_DIR + "doc_xpointer.xml"; @@ -320,11 +309,10 @@ public class AuctionItemRepository { * Test if xi:include may reference the doc containing the include if the * parse type is text. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeLoopPos() throws Exception { - String resultFile = USER_DIR + "doc_xinc_loops.out"; + String resultFile = "doc_xinc_loops.out"; String goldFile = GOLDEN_DIR + "doc_xinc_loopGold.xml"; String xmlFile = XML_DIR + "doc_xinc_loops.xml"; @@ -347,11 +335,10 @@ public class AuctionItemRepository { * Test if two non nested xi:include elements can include the same document * with an xi:include statement. * - * @throws Exception If any errors occur. */ - @Test(groups = {"readWriteLocalFiles"}) + @Test public void testXIncludeNestedPos() throws Exception { - String resultFile = USER_DIR + "schedule.out"; + String resultFile = "schedule.out"; String goldFile = GOLDEN_DIR + "scheduleGold.xml"; String xmlFile = XML_DIR + "schedule.xml"; @@ -367,4 +354,20 @@ public class AuctionItemRepository { } assertTrue(compareDocumentWithGold(goldFile, resultFile)); } + + public static boolean compareDocumentWithGold(String goldfile, String resultFile) + throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setCoalescing(true); + factory.setIgnoringElementContentWhitespace(true); + factory.setIgnoringComments(true); + DocumentBuilder db = factory.newDocumentBuilder(); + + Document goldD = db.parse(Paths.get(goldfile).toFile()); + goldD.normalizeDocument(); + Document resultD = db.parse(Paths.get(resultFile).toFile()); + resultD.normalizeDocument(); + return goldD.isEqualNode(resultD); + } } diff --git a/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/content/movies.xml.data b/test/jaxp/javax/xml/jaxp/functional/test/auctionportal/content/movies-utf16.xml similarity index 100% rename from test/jaxp/javax/xml/jaxp/functional/test/auctionportal/content/movies.xml.data rename to test/jaxp/javax/xml/jaxp/functional/test/auctionportal/content/movies-utf16.xml diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java index a8bac488b8e..a9bb95e20a8 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,19 +23,18 @@ package test.gaptest; -import java.io.StringReader; +import org.junit.jupiter.api.Test; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; - -import org.testng.annotations.Test; +import java.io.StringReader; /* * @test * @bug 4511326 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4511326 + * @run junit/othervm test.gaptest.Bug4511326 * @summary In forwards-compatible mode the attribute isn't ignored */ public class Bug4511326 { diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java index d27186bcf6d..2e7b05eaaac 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,24 +23,23 @@ package test.gaptest; -import static javax.xml.transform.OutputKeys.ENCODING; -import static javax.xml.transform.OutputKeys.INDENT; -import static org.testng.Assert.assertEquals; - -import java.io.StringReader; +import org.junit.jupiter.api.Test; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; +import java.io.StringReader; -import org.testng.annotations.Test; +import static javax.xml.transform.OutputKeys.ENCODING; +import static javax.xml.transform.OutputKeys.INDENT; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 4512806 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4512806 + * @run junit/othervm test.gaptest.Bug4512806 * @summary test transformer.setOutputProperties(null) */ public class Bug4512806 { @@ -57,13 +56,13 @@ public class Bug4512806 { transformer.setOutputProperty(INDENT, "no"); transformer.setOutputProperty(ENCODING, "UTF-16"); - assertEquals(printPropertyValue(INDENT), "indent=no"); - assertEquals(printPropertyValue(ENCODING), "encoding=UTF-16"); + assertEquals("indent=no", printPropertyValue(INDENT)); + assertEquals("encoding=UTF-16", printPropertyValue(ENCODING)); transformer.setOutputProperties(null); - assertEquals(printPropertyValue(INDENT), "indent=yes"); - assertEquals(printPropertyValue(ENCODING), "encoding=UTF-8"); + assertEquals("indent=yes", printPropertyValue(INDENT)); + assertEquals("encoding=UTF-8", printPropertyValue(ENCODING)); } diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java index 5fc68a28a6b..8466c9cff79 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,6 +23,8 @@ package test.gaptest; +import org.junit.jupiter.api.Test; + import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; @@ -31,13 +33,11 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.testng.annotations.Test; - /* * @test * @bug 4515047 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4515047 + * @run junit/othervm test.gaptest.Bug4515047 * @summary test transform an empty dom source */ public class Bug4515047 { diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java index 014765f89d8..303db79f68b 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,14 +23,15 @@ package test.gaptest; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; - -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.XMLFilterImpl; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; @@ -41,32 +42,31 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.XMLFilterImpl; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 4515660 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4515660 + * @run junit/othervm test.gaptest.Bug4515660 * @summary verify property org.xml.sax.driver is used by SAXTransformerFactory */ -@Test(singleThreaded = true) +@Execution(ExecutionMode.SAME_THREAD) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class Bug4515660 { - @BeforeClass + @BeforeAll public void setSaxDrier() { - setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName()); + System.setProperty("org.xml.sax.driver", ReaderStub.class.getName()); } - @AfterClass + @AfterAll public void clearSaxDrier() { - clearSystemProperty("org.xml.sax.driver"); + System.clearProperty("org.xml.sax.driver"); } @Test @@ -88,9 +88,13 @@ public class Bug4515660 { @Test public void testSAXTransformerFactory() throws TransformerConfigurationException { - final String xsl = "\n" + "\n" - + " Hello World!\n" + "\n"; - + final String xsl = + """ + + + Hello World! + + """; ReaderStub.used = false; TransformerFactory transFactory = TransformerFactory.newInstance(); diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java index b8fe9e06814..edf2ef2d1c1 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,28 +22,27 @@ */ package test.gaptest; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static test.gaptest.GapTestConst.XML_DIR; - -import java.io.IOException; - -import javax.xml.XMLConstants; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; +import javax.xml.XMLConstants; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.IOException; +import java.nio.file.Path; + +import static test.gaptest.GapTestConst.XML_DIR; + /* * @test * @bug 4848653 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4848653 + * @run junit/othervm test.gaptest.Bug4848653 * @summary Verify JAXP schemaLanguage property is ignored if setValidating(false) */ public class Bug4848653 { @@ -56,7 +55,8 @@ public class Bug4848653 { parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI); String filename = XML_DIR + "Bug4848653.xml"; - InputSource is = new InputSource(filenameToURL(filename)); + String uri = Path.of(filename).toUri().toASCIIString(); + InputSource is = new InputSource(uri); XMLReader xmlReader = parser.getXMLReader(); xmlReader.setErrorHandler(new MyErrorHandler()); xmlReader.parse(is); diff --git a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java index 6ebcae5940d..7667d6ad140 100644 --- a/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java +++ b/test/jaxp/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,43 +22,43 @@ */ package test.gaptest; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static org.testng.Assert.assertEquals; -import static test.gaptest.GapTestConst.GOLDEN_DIR; -import static test.gaptest.GapTestConst.XML_DIR; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; +import org.junit.jupiter.api.Test; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; -import org.testng.annotations.Test; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static test.gaptest.GapTestConst.GOLDEN_DIR; +import static test.gaptest.GapTestConst.XML_DIR; /* * @test * @bug 4858685 4894410 * @library /javax/xml/jaxp/libs - * @run testng/othervm test.gaptest.Bug4858685 + * @run junit/othervm test.gaptest.Bug4858685 * @summary test transforming text node */ public class Bug4858685 { @Test public void test() throws TransformerException, IOException { - String uri = XML_DIR + "certificate.xml"; + String filename = XML_DIR + "certificate.xml"; TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); // use URI as a StreamSource - StreamSource streamSource = new StreamSource(filenameToURL(uri)); + String uri = Path.of(filename).toUri().toASCIIString(); + StreamSource streamSource = new StreamSource(uri); DOMResult domResult = new DOMResult(); @@ -66,12 +66,8 @@ public class Bug4858685 { transformer.transform(streamSource, domResult); // dump DOM in a human readable form - String gotString = DOMDump.dumpDom(domResult.getNode()); - String goldenString = new String(Files.readAllBytes(Paths.get(GOLDEN_DIR + "Bug4858685.txt"))); - - assertEquals(gotString, goldenString); - + assertEquals(goldenString, DOMDump.dumpDom(domResult.getNode())); } /** diff --git a/test/jaxp/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java b/test/jaxp/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java index 3c871d703bf..c6e6e2a6745 100644 --- a/test/jaxp/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java +++ b/test/jaxp/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +23,19 @@ package catalog; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogResolver; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import static catalog.CatalogTestUtils.DEFER_FALSE; import static catalog.CatalogTestUtils.FEATURE_DEFER; import static catalog.CatalogTestUtils.FEATURE_FILES; @@ -36,27 +49,14 @@ import static catalog.CatalogTestUtils.createPropsContent; import static catalog.CatalogTestUtils.deleteJAXPProps; import static catalog.CatalogTestUtils.generateJAXPProps; import static catalog.CatalogTestUtils.getCatalogPath; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.catalog.CatalogResolver; - -import org.testng.Assert; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /* * @test * @library /javax/xml/jaxp/libs /javax/xml/jaxp/isolatedjdk * @run shell/timeout=600 ../IsolatedJDK.sh JAXP_PROPS - * @run testng catalog.PropertiesTest + * @run junit catalog.PropertiesTest * @run shell/timeout=600 ../IsolatedJDK.sh JAXP_PROPS remove * @summary This test case tests if the properties FILES, DEFER, PREFER, * RESOLVE in jaxp.properties and system properties are used. @@ -75,11 +75,11 @@ public class PropertiesTest { public void test() throws Exception { // get required properties and do some assertions String javaclasspath = System.getProperty("java.class.path"); - Assert.assertNotNull(javaclasspath, "Test class path is null"); + assertNotNull(javaclasspath, "Test class path is null"); String testclasspath = System.getProperty("test.class.path"); - Assert.assertNotNull(testclasspath, "Test class path is null"); + assertNotNull(testclasspath, "Test class path is null"); String testsourcepath = System.getProperty("test.src"); - Assert.assertNotNull(testsourcepath, "Test source path is null"); + assertNotNull(testsourcepath, "Test source path is null"); // start the child process List testCall = new ArrayList<>(6); @@ -123,7 +123,7 @@ public class PropertiesTest { // trace exit value and assert 0 int exitValue = test.exitValue(); System.out.println("Process Exit code: " + exitValue); - Assert.assertEquals(exitValue, 0, "PropertiesTest returned nonzero exit code."); + assertEquals(0, exitValue, "PropertiesTest returned nonzero exit code."); } public static void main(String[] args) throws Exception { diff --git a/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java b/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java index 6253e26d6e4..a6ab94b9d7e 100644 --- a/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java +++ b/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java @@ -30,12 +30,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import jaxp.library.JAXPTestUtilities; /* * Utilities for testing XML Catalog API. @@ -69,6 +67,9 @@ final class CatalogTestUtils { private static final String JAXP_PROPS = "jaxp.properties"; private static final String JAXP_PROPS_BAK = JAXP_PROPS + ".bak"; + private static final Path CATALOG_DIR = + Path.of(System.getProperty("test.src")).resolve("catalogFiles").normalize().toAbsolutePath(); + private CatalogTestUtils() { } /* ********** create resolver ********** */ @@ -109,19 +110,12 @@ final class CatalogTestUtils { // Gets the paths of the specified catalogs. private static URI[] getCatalogPaths(String... catalogNames) { - return catalogNames == null - ? null - : Stream.of(catalogNames).map( - catalogName -> getCatalogPath(catalogName)).collect( - Collectors.toList()).toArray(new URI[0]); + return Stream.of(catalogNames).map(CatalogTestUtils::getCatalogPath).toList().toArray(new URI[0]); } // Gets the paths of the specified catalogs. static URI getCatalogPath(String catalogName) { - return catalogName == null - ? null - : Paths.get(JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles") - + catalogName).toUri(); + return CATALOG_DIR.resolve(catalogName).toUri(); } /* ********** jaxp.properties ********** */ diff --git a/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java b/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java index 81013a5a7bd..1e06a353c24 100644 --- a/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java +++ b/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java @@ -25,12 +25,13 @@ package catalog; import javax.xml.catalog.CatalogResolver; -import org.testng.Assert; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * Utilities for checking catalog resolution. */ -class ResolutionChecker { +final class ResolutionChecker { /* ********** Checks normal resolution ********** */ @@ -38,8 +39,8 @@ class ResolutionChecker { * Checks the resolution result for specified external identifier. */ static void checkExtIdResolution(CatalogResolver resolver, - String publicId, String systemId, String matchedUri) { - Assert.assertEquals( + String publicId, String systemId, String matchedUri) { + assertEquals( resolver.resolveEntity(publicId, getNotSpecified(systemId)).getSystemId(), matchedUri); } @@ -65,8 +66,8 @@ class ResolutionChecker { * with the specified base location. */ static void checkUriResolution(CatalogResolver resolver, - String href, String base, String matchedUri) { - Assert.assertEquals(resolver.resolve(href, base).getSystemId(), + String href, String base, String matchedUri) { + assertEquals(resolver.resolve(href, base).getSystemId(), matchedUri); } @@ -106,9 +107,9 @@ class ResolutionChecker { static void expectExceptionOnExtId( CatalogResolver resolver, String publicId, String systemId, Class expectedExceptionClass) { - expectThrows(expectedExceptionClass, () -> { - resolver.resolveEntity(publicId, getNotSpecified(systemId)); - }); + assertThrows( + expectedExceptionClass, + () -> resolver.resolveEntity(publicId, getNotSpecified(systemId))); } /* @@ -140,9 +141,7 @@ class ResolutionChecker { static void expectExceptionOnUri( CatalogResolver resolver, String href, String base, Class expectedExceptionClass) { - expectThrows(expectedExceptionClass, () -> { - resolver.resolve(href, base); - }); + assertThrows(expectedExceptionClass, () -> resolver.resolve(href, base)); } /* @@ -155,31 +154,6 @@ class ResolutionChecker { expectExceptionOnUri(resolver, href, null, expectedExceptionClass); } - // The TestNG distribution in current JTREG build doesn't support - // method Assert.expectThrows(). - private static T expectThrows(Class throwableClass, - ThrowingRunnable runnable) { - try { - runnable.run(); - } catch (Throwable t) { - if (throwableClass.isInstance(t)) { - return throwableClass.cast(t); - } else { - String mismatchMessage = String.format( - "Expected %s to be thrown, but %s was thrown", - throwableClass.getSimpleName(), - t.getClass().getSimpleName()); - - throw new AssertionError(mismatchMessage, t); - } - } - - String message = String.format( - "Expected %s to be thrown, but nothing was thrown", - throwableClass.getSimpleName()); - throw new AssertionError(message); - } - /* * SystemId can never be null in XML. For publicId tests, if systemId is null, * it will be considered as not-specified instead. A non-existent systemId @@ -191,8 +165,4 @@ class ResolutionChecker { } return systemId; } - - private interface ThrowingRunnable { - void run() throws Throwable; - } } diff --git a/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/MyCHandler.java b/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/MyCHandler.java index c43390d43b9..9a32b0a1ac1 100644 --- a/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/MyCHandler.java +++ b/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/MyCHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,22 +22,23 @@ */ package javax.xml.parsers.ptests; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import static jaxp.library.JAXPTestUtilities.ERROR_MSG_HEADER; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.LocatorImpl; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + /** * Customized DefaultHandler which writes output document when methods are * called by Transformer. Test may use output document to compare with golden * file for verification. */ class MyCHandler extends DefaultHandler implements AutoCloseable { + private static final String ERROR_MSG_HEADER = "Unexcepted exception thrown:"; private final BufferedWriter bWriter; private final Locator locator = new LocatorImpl(); diff --git a/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/ParserTestConst.java b/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/ParserTestConst.java index ac50221fec8..dc5ea806c9d 100644 --- a/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/ParserTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/javax/xml/parsers/ptests/ParserTestConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,25 +22,28 @@ */ package javax.xml.parsers.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; - +import java.io.File; +import java.nio.file.Path; /** * Utility interface which includes final variables of XML, golden file * directories. */ public class ParserTestConst { + private static final Path SRC_ROOT = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(ParserTestConst.class, - ".." + FILE_SEP + "xmlfiles"); - + public static final String XML_DIR = forwardSlashDir(SRC_ROOT.resolveSibling("xmlfiles")); /** * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(ParserTestConst.class, - ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); + public static final String GOLDEN_DIR = XML_DIR + "out/"; } diff --git a/test/jaxp/javax/xml/jaxp/libs/javax/xml/transform/ptests/TransformerTestConst.java b/test/jaxp/javax/xml/jaxp/libs/javax/xml/transform/ptests/TransformerTestConst.java index 5f119360432..23c2a73a3b2 100644 --- a/test/jaxp/javax/xml/jaxp/libs/javax/xml/transform/ptests/TransformerTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/javax/xml/transform/ptests/TransformerTestConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +22,27 @@ */ package javax.xml.transform.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.io.File; +import java.nio.file.Path; /** * This is the Base test class provide basic support for JAXP functional test */ public class TransformerTestConst { + private static final Path SRC_ROOT = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(TransformerTestConst.class, - ".." + FILE_SEP + "xmlfiles"); - + public static final String XML_DIR = forwardSlashDir(SRC_ROOT.resolveSibling("xmlfiles")); /** * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(TransformerTestConst.class, - ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); + public static final String GOLDEN_DIR = XML_DIR + "out/"; } diff --git a/test/jaxp/javax/xml/jaxp/libs/javax/xml/validation/ptests/ValidationTestConst.java b/test/jaxp/javax/xml/jaxp/libs/javax/xml/validation/ptests/ValidationTestConst.java index 50f4c86d0e5..f8c6aba18d3 100644 --- a/test/jaxp/javax/xml/jaxp/libs/javax/xml/validation/ptests/ValidationTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/javax/xml/validation/ptests/ValidationTestConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,22 +22,22 @@ */ package javax.xml.validation.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.io.File; +import java.nio.file.Path; /** * This class defines the path constant */ public class ValidationTestConst { + private static final Path SRC_ROOT = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(ValidationTestConst.class, - ".." + FILE_SEP + "xmlfiles"); - - /** - * Golden validation files directory. - */ - public static final String GOLDEN_DIR = getPathByClassName(ValidationTestConst.class, - ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); + public static final String XML_DIR = forwardSlashDir(SRC_ROOT.resolveSibling("xmlfiles")); } diff --git a/test/jaxp/javax/xml/jaxp/libs/javax/xml/xpath/ptests/XPathTestConst.java b/test/jaxp/javax/xml/jaxp/libs/javax/xml/xpath/ptests/XPathTestConst.java index 605dada1656..cfbb4a869df 100644 --- a/test/jaxp/javax/xml/jaxp/libs/javax/xml/xpath/ptests/XPathTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/javax/xml/xpath/ptests/XPathTestConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,16 +22,16 @@ */ package javax.xml.xpath.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.nio.file.Path; /** * This is the Base test class provide basic support for XPath functional test */ public class XPathTestConst { + private static final Path SRC_ROOT = Path.of(System.getProperty("test.src")).toAbsolutePath(); + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(XPathTestConst.class, - ".." + FILE_SEP + "xmlfiles"); + public static final Path XML_DIR = SRC_ROOT.resolveSibling("xmlfiles"); } diff --git a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPDataProvider.java b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPDataProvider.java index d09c3d78b0b..9f925334895 100644 --- a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPDataProvider.java +++ b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,14 @@ package jaxp.library; -import org.testng.annotations.DataProvider; - /** * Provide invalid parameters for negative testing Factory.newInstance. */ public class JAXPDataProvider { - - @DataProvider(name = "new-instance-neg") - public static Object[][] getNewInstanceNeg() { - return new Object[][] { { null, null }, { null, JAXPDataProvider.class.getClassLoader() } }; + public static Object[][] newInstanceNeg() { + return new Object[][] { + { null, null }, + { null, JAXPDataProvider.class.getClassLoader() }, + }; } - } diff --git a/test/jaxp/javax/xml/jaxp/libs/org/w3c/dom/ptests/DOMTestUtil.java b/test/jaxp/javax/xml/jaxp/libs/org/w3c/dom/ptests/DOMTestUtil.java index 6b32aa36e74..c4239606135 100644 --- a/test/jaxp/javax/xml/jaxp/libs/org/w3c/dom/ptests/DOMTestUtil.java +++ b/test/jaxp/javax/xml/jaxp/libs/org/w3c/dom/ptests/DOMTestUtil.java @@ -22,11 +22,9 @@ */ package org.w3c.dom.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; - import java.io.File; import java.io.IOException; +import java.nio.file.Path; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -39,15 +37,22 @@ import org.xml.sax.SAXException; * This class defines the path constant and common method */ public class DOMTestUtil { + private static final Path TEST_SRC = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /* * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(DOMTestUtil.class, ".." + FILE_SEP + "xmlfiles"); + public static final String XML_DIR = forwardSlashDir(TEST_SRC.resolveSibling("xmlfiles")); /* * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(DOMTestUtil.class, ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); + public static final String GOLDEN_DIR = XML_DIR + "out/"; /* * Error Message for DOMException being expected. diff --git a/test/jaxp/javax/xml/jaxp/libs/org/xml/sax/ptests/SAXTestConst.java b/test/jaxp/javax/xml/jaxp/libs/org/xml/sax/ptests/SAXTestConst.java index 6798d7879dc..ea35a484cdf 100644 --- a/test/jaxp/javax/xml/jaxp/libs/org/xml/sax/ptests/SAXTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/org/xml/sax/ptests/SAXTestConst.java @@ -22,8 +22,8 @@ */ package org.xml.sax.ptests; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.io.File; +import java.nio.file.Path; /** * This is the Base test class provide basic support for JAXP SAX functional @@ -31,16 +31,20 @@ import static jaxp.library.JAXPTestUtilities.getPathByClassName; * has their own TestBase class. */ public class SAXTestConst { + private static final Path TEST_SRC = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(SAXTestConst.class, - ".." + FILE_SEP + "xmlfiles"); - + public static final String XML_DIR = forwardSlashDir(TEST_SRC.resolveSibling("xmlfiles")); /** * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(SAXTestConst.class, - ".." + FILE_SEP + "xmlfiles" + FILE_SEP + "out"); + public static final String GOLDEN_DIR = XML_DIR + "out/"; } diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/AstroConstants.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/AstroConstants.java index b3f2cb6e5c6..9645832c896 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/AstroConstants.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/AstroConstants.java @@ -23,10 +23,14 @@ package test.astro; +import java.nio.file.Path; + import static java.io.File.separator; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; public class AstroConstants { + private static final Path XML_FILES = + Path.of(System.getProperty("test.src")).resolve("xmlfiles").toAbsolutePath(); + // Query parameters : public static final double RA_MIN = 0.0; // hours @@ -36,7 +40,7 @@ public class AstroConstants { // Stylesheet source paths: - public static final String XSLPATH = getPathByClassName(AstroConstants.class, "xmlfiles" + separator + "xsl"); + public static final String XSLPATH = XML_FILES.resolve("xsl").toString() + separator; public static final String RAXSL = XSLPATH + "ra.xsl"; public static final String DECXSL = XSLPATH + "dec.xsl"; public static final String RADECXSL = XSLPATH + "radec.xsl"; @@ -51,10 +55,9 @@ public class AstroConstants { // Catalog references - public static final String ASTROCAT = getPathByClassName(AstroConstants.class, "xmlfiles") + "catalog.xml"; + public static final String ASTROCAT = XML_FILES.resolve("catalog.xml").toString(); - - public static final String GOLDEN_DIR = getPathByClassName(AstroConstants.class, "xmlfiles" + separator + "gold"); + public static final String GOLDEN_DIR = XML_FILES.resolve("gold").toString() + separator; public static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; public static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; } diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/DOMFilterFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/DOMFilterFactoryImpl.java index e232fb61fcc..32c34673846 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/DOMFilterFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/DOMFilterFactoryImpl.java @@ -22,12 +22,12 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; import static test.astro.AstroConstants.DECXSL; import static test.astro.AstroConstants.RAXSL; import static test.astro.AstroConstants.STYPEXSL; import java.io.IOException; +import java.nio.file.Path; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -75,6 +75,7 @@ public class DOMFilterFactoryImpl extends SourceFilterFactory { private Document getStylesheetDOM(String xslfilename) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); - return dbf.newDocumentBuilder().parse(filenameToURL(xslfilename)); + String xslUri = Path.of(xslfilename).toUri().toASCIIString(); + return dbf.newDocumentBuilder().parse(xslUri); } } diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java index 2f4170b21ce..6fde37c79ab 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java @@ -22,22 +22,6 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static jaxp.library.JAXPTestUtilities.USER_DIR; -import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS; -import static org.w3c.dom.traversal.NodeFilter.SHOW_ELEMENT; - -import java.io.ByteArrayInputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.file.Files; -import java.nio.file.Paths; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.w3c.dom.DOMConfiguration; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -50,6 +34,20 @@ import org.w3c.dom.ls.LSSerializer; import org.w3c.dom.ls.LSSerializerFilter; import org.xml.sax.InputSource; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS; +import static org.w3c.dom.traversal.NodeFilter.SHOW_ELEMENT; + /* * A specialized implementation of an Input Source factory that utilizes * DOM Level 3 implementations to build a Document (DOM) from the @@ -72,7 +70,7 @@ public class DOML3InputSourceFactoryImpl implements InputSourceFactory { Document doc = null; LSInput src = impl.createLSInput(); // register the input file with the input source... - String systemId = filenameToURL(filename); + String systemId = Path.of(filename).toUri().toASCIIString(); src.setSystemId(systemId); try (Reader reader = new FileReader(filename)) { src.setCharacterStream(reader); @@ -82,7 +80,7 @@ public class DOML3InputSourceFactoryImpl implements InputSourceFactory { // Use DOM L3 LSSerializer (previously called a DOMWriter) // to serialize the xml doc DOM to a file stream. - String tmpCatalog = Files.createTempFile(Paths.get(USER_DIR), "catalog.xml", null).toString(); + String tmpCatalog = Files.createTempFile(Paths.get("."), "catalog.xml", null).toString(); LSSerializer domserializer = impl.createLSSerializer(); domserializer.setFilter(new MyDOMWriterFilter()); diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/InputSourceFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/InputSourceFactoryImpl.java index a2c5b8319c8..d5ccdbf70e6 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/InputSourceFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/InputSourceFactoryImpl.java @@ -22,10 +22,10 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; - import org.xml.sax.InputSource; +import java.nio.file.Path; + /* * Default implementation of a input source factory. This is the most * straight forward way to create a sax input source and set it's @@ -38,7 +38,8 @@ public class InputSourceFactoryImpl implements InputSourceFactory { public InputSource newInputSource(String filename) { InputSource catSrc = new InputSource(filename); - catSrc.setSystemId(filenameToURL(filename)); + String uri = Path.of(filename).toUri().toASCIIString(); + catSrc.setSystemId(uri); return catSrc; } } diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/SAXFilterFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/SAXFilterFactoryImpl.java index 4ef5d3cc259..403c0a70460 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/SAXFilterFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/SAXFilterFactoryImpl.java @@ -22,22 +22,22 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; -import static test.astro.AstroConstants.DECENTXSL; -import static test.astro.AstroConstants.DECXSL; -import static test.astro.AstroConstants.RAENTXSL; -import static test.astro.AstroConstants.STYPEXSL; -import static test.astro.AstroConstants.TOPTEMPLXSL; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Source; import javax.xml.transform.sax.SAXSource; +import java.nio.file.Path; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; +import static test.astro.AstroConstants.DECENTXSL; +import static test.astro.AstroConstants.DECXSL; +import static test.astro.AstroConstants.RAENTXSL; +import static test.astro.AstroConstants.STYPEXSL; +import static test.astro.AstroConstants.TOPTEMPLXSL; /* * Implementation of the filter factory interface that utilizes SAX @@ -51,7 +51,7 @@ import org.xml.sax.XMLReader; * */ public class SAXFilterFactoryImpl extends SourceFilterFactory { - private EntityResolver entityResolver; + private final EntityResolver entityResolver; public SAXFilterFactoryImpl() { super(); @@ -60,7 +60,8 @@ public class SAXFilterFactoryImpl extends SourceFilterFactory { @Override protected Source getSource(String xslFileName) throws SAXException, ParserConfigurationException { - SAXSource saxsource = new SAXSource(new InputSource(filenameToURL(xslFileName))); + String xslUri = Path.of(xslFileName).toUri().toASCIIString(); + SAXSource saxsource = new SAXSource(new InputSource(xslUri)); saxsource.setXMLReader(getXMLReader()); return saxsource; } @@ -97,7 +98,8 @@ public class SAXFilterFactoryImpl extends SourceFilterFactory { public InputSource resolveEntity(String publicid, String sysId) { if (sysId.equals("http://astro.com/stylesheets/toptemplate")) { InputSource retval = new InputSource(TOPTEMPLXSL); - retval.setSystemId(filenameToURL(TOPTEMPLXSL)); + String xslUri = Path.of(TOPTEMPLXSL).toUri().toASCIIString(); + retval.setSystemId(xslUri); return retval; } else { return null; // use default behavior diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/StreamFilterFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/StreamFilterFactoryImpl.java index 0978161312e..38e864f6897 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/StreamFilterFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/StreamFilterFactoryImpl.java @@ -22,7 +22,6 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; import static test.astro.AstroConstants.DECXSL; import static test.astro.AstroConstants.RADECXSL; import static test.astro.AstroConstants.RAXSL; @@ -30,11 +29,13 @@ import static test.astro.AstroConstants.STYPEXSL; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; +import java.nio.file.Path; public class StreamFilterFactoryImpl extends SourceFilterFactory { @Override protected Source getSource(String xslFileName) { - return new StreamSource(filenameToURL(xslFileName)); + String xslUri = Path.of(xslFileName).toUri().toASCIIString(); + return new StreamSource(xslUri); } @Override diff --git a/test/jaxp/javax/xml/jaxp/libs/test/astro/TemplatesFilterFactoryImpl.java b/test/jaxp/javax/xml/jaxp/libs/test/astro/TemplatesFilterFactoryImpl.java index 09a71b1a534..6047d0c5ae8 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/astro/TemplatesFilterFactoryImpl.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/astro/TemplatesFilterFactoryImpl.java @@ -22,13 +22,13 @@ */ package test.astro; -import static jaxp.library.JAXPTestUtilities.filenameToURL; import static test.astro.AstroConstants.DECXSL; import static test.astro.AstroConstants.RAURIXSL; import static test.astro.AstroConstants.STYPEXSL; import static test.astro.AstroConstants.TOPTEMPLINCXSL; import java.io.IOException; +import java.nio.file.Path; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; @@ -94,7 +94,8 @@ public class TemplatesFilterFactoryImpl extends AbstractFilterFactory { // create the stylesheet input source InputSource xslSrc = new InputSource(xslFileName); - xslSrc.setSystemId(filenameToURL(xslFileName)); + String xslUri = Path.of(xslFileName).toUri().toASCIIString(); + xslSrc.setSystemId(xslUri); // hook up the templates handler as the xsl content handler xmlreader.setContentHandler(templatesHandler); // call parse on the xsl input source @@ -113,7 +114,8 @@ public class TemplatesFilterFactoryImpl extends AbstractFilterFactory { public Source resolve(String href, String base) throws TransformerException { if ("http://astro.com/stylesheets/topleveltemplate".equals(href)) { StreamSource ss = new StreamSource(TOPTEMPLINCXSL); - ss.setSystemId(filenameToURL(TOPTEMPLINCXSL)); + String xslUri = Path.of(TOPTEMPLINCXSL).toUri().toASCIIString(); + ss.setSystemId(xslUri); return ss; } else { return null; diff --git a/test/jaxp/javax/xml/jaxp/libs/test/auctionportal/HiBidConstants.java b/test/jaxp/javax/xml/jaxp/libs/test/auctionportal/HiBidConstants.java index 5c812c52b04..7852540a308 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/auctionportal/HiBidConstants.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/auctionportal/HiBidConstants.java @@ -22,21 +22,29 @@ */ package test.auctionportal; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.io.File; +import java.nio.file.Path; /** * This is the Base test class provide basic support for Auction portal test. */ public class HiBidConstants { + private static final Path TEST_SRC = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(HiBidConstants.class, "content"); + public static final String XML_DIR = forwardSlashDir(TEST_SRC.resolve("content")); /** * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(HiBidConstants.class, "golden"); + public static final String GOLDEN_DIR = forwardSlashDir(TEST_SRC.resolve("golden")); /** * Name space for account operation. diff --git a/test/jaxp/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java b/test/jaxp/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java index 237d0ac6ed2..648a6c2be10 100644 --- a/test/jaxp/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java +++ b/test/jaxp/javax/xml/jaxp/libs/test/gaptest/GapTestConst.java @@ -22,20 +22,27 @@ */ package test.gaptest; -import static jaxp.library.JAXPTestUtilities.FILE_SEP; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; +import java.io.File; +import java.nio.file.Path; /** * This class defines the path constant */ public class GapTestConst { + private static final Path TEST_SRC = Path.of(System.getProperty("test.src")).toAbsolutePath(); + + private static String forwardSlashDir(Path p) { + // Convention in these tests is to include trailing '/' in directory strings. + return p.toString().replace(File.separatorChar, '/') + '/'; + } + /** * XML source file directory. */ - public static final String XML_DIR = getPathByClassName(GapTestConst.class, "xmlfiles"); + public static final String XML_DIR = forwardSlashDir(TEST_SRC.resolve("xmlfiles")); /** * Golden validation files directory. */ - public static final String GOLDEN_DIR = getPathByClassName(GapTestConst.class, "xmlfiles" + FILE_SEP + "out"); + public static final String GOLDEN_DIR = XML_DIR + "out/"; } diff --git a/test/jdk/ProblemList-zgc.txt b/test/jdk/ProblemList-zgc.txt index 065a52f9a83..a669f3e3abf 100644 --- a/test/jdk/ProblemList-zgc.txt +++ b/test/jdk/ProblemList-zgc.txt @@ -27,16 +27,6 @@ # ############################################################################# -# Quiet all SA tests - -sun/tools/jhsdb/HeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/BasicLauncherTest.java 8307393 generic-all -sun/tools/jhsdb/JStackStressTest.java 8307393 generic-all -sun/tools/jhsdb/JShellHeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/SAGetoptTest.java 8307393 generic-all -sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8307393 generic-all -sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8307393 generic-all - com/sun/jdi/ThreadMemoryLeakTest.java 8307402 generic-all ############################################################################# diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 94015ebc680..f1bd91d86aa 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -222,7 +222,9 @@ sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all,macosx-all +sun/java2d/OpenGL/MultiWindowFillTest.java 8378506 macosx-all sun/java2d/OpenGL/OpaqueDest.java#id1 8367574 macosx-all +sun/java2d/OpenGL/ScaleParamsOOB.java#id0 8377908 linux-all sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java 8144029 macosx-all,linux-all sun/java2d/SunGraphics2D/DrawImageBilinear.java 8297175 linux-all sun/java2d/SunGraphics2D/PolyVertTest.java 6986565 generic-all @@ -568,6 +570,8 @@ java/nio/channels/DatagramChannel/Unref.java 8233437 generic- java/nio/channels/DatagramChannel/BasicMulticastTests.java 8144003 macosx-all java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java 8144003 macosx-all java/nio/channels/DatagramChannel/Promiscuous.java 8144003 macosx-all +java/nio/channels/SocketChannel/CloseDuringConnect.java 8375658 macosx-26.0,macosx-26.1,macosx-26.2,macosx-26.3 +java/nio/channels/SocketChannel/OpenLeak.java 8375658 macosx-26.0,macosx-26.1,macosx-26.2,macosx-26.3 ############################################################################ @@ -709,6 +713,24 @@ jdk/incubator/vector/LoadJsvmlTest.java 8305390 windows- # jdk_jfr +jdk/jfr/api/consumer/TestRecordingFileWrite.java 8286300 linux-s390x +jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java 8286300 linux-s390x +jdk/jfr/api/consumer/streaming/TestFilledChunks.java 8286300 linux-s390x +jdk/jfr/api/consumer/streaming/TestRemovedChunks.java 8286300 linux-s390x +jdk/jfr/api/recording/misc/TestGetStreamWithFailure.java 8286300 linux-s390x +jdk/jfr/api/settings/TestSettingControl.java 8286300 linux-s390x +jdk/jfr/event/runtime/TestBackToBackSensitive.java 8286300 linux-s390x +jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java 8286300 linux-s390x +jdk/jfr/event/tracing/TestMultipleThreads.java 8286300 linux-s390x +jdk/jfr/event/tracing/TestTracedString.java 8286300 linux-s390x +jdk/jfr/javaagent/TestLoadedAgent.java 8286300 linux-s390x +jdk/jfr/javaagent/TestPremainAgent.java 8286300 linux-s390x +jdk/jfr/jmx/streaming/TestClose.java 8286300 linux-s390x +jdk/jfr/jmx/streaming/TestMaxSize.java 8286300 linux-s390x +jdk/jfr/jvm/TestChunkIntegrity.java 8286300 linux-s390x +jdk/jfr/jvm/TestJFRIntrinsic.java 8286300 linux-s390x +jdk/jfr/tool/TestDisassemble.java 8286300 linux-s390x +jdk/jfr/tool/TestScrub.java 8286300 linux-s390x jdk/jfr/event/compiler/TestCodeSweeper.java 8338127 generic-all jdk/jfr/event/oldobject/TestShenandoah.java 8342951 generic-all jdk/jfr/event/runtime/TestResidentSetSizeEvent.java 8309846 aix-ppc64 @@ -754,7 +776,6 @@ java/awt/FileDialog/DefaultFocusOwner/DefaultFocusOwner.java 7187728 macosx-all, java/awt/FileDialog/DoubleActionESC.java 8356981 linux-all java/awt/print/PageFormat/Orient.java 8016055 macosx-all java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java 8024986 macosx-all,linux-all -java/awt/TextComponent/CorrectTextComponentSelectionTest.java 8237220 macosx-all java/awt/TextComponent/SelectionAndCaretColor.java 7017622 linux-all java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter.java 8254841 macosx-all java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java 8258103 linux-all diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index cc571deab20..0e339d29cea 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -129,8 +129,3 @@ requiredVersion=8.2.1+1 # does not need ../../ notation to reach them external.lib.roots = ../../ -# Use new module options -useNewOptions=true - -# Use --patch-module instead of -Xmodule: -useNewPatchModule=true diff --git a/test/jdk/TEST.groups b/test/jdk/TEST.groups index ccf745700d1..2bff07b8a55 100644 --- a/test/jdk/TEST.groups +++ b/test/jdk/TEST.groups @@ -558,6 +558,7 @@ jdk_jfr_sanity = \ jdk/jfr/event/gc/collection/TestGCWithFasttime.java \ jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java \ jdk/jfr/event/metadata/TestDefaultConfigurations.java \ + jdk/jfr/event/oldobject/TestDFSWithSmallStack.java \ jdk/jfr/startupargs/TestDumpOnExit.java \ jdk/jfr/api/consumer/recordingstream/TestBasics.java diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java index a79f48196d1..09fd0c440a9 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,20 +24,21 @@ /* * @test * @bug 5008156 8248268 - * @run testng NISTWrapKAT + * @run junit NISTWrapKAT * @summary Verify that the AES-Key-Wrap and AES-Key-Wrap-Pad ciphers * work as expected using NIST test vectors. * @author Valerie Peng */ import java.security.Key; import java.security.AlgorithmParameters; -import javax.crypto.*; -import javax.crypto.spec.*; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; import java.util.Arrays; import java.math.BigInteger; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.Assert; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class NISTWrapKAT { @@ -101,8 +102,7 @@ public class NISTWrapKAT { } } - @DataProvider - public Object[][] testData() { + static Object[][] testData() { return new Object[][] { { "AESWrap", KEK, 16, DATA, 16, KW_AES128_128 }, { "AESWrap", KEK, 24, DATA, 16, KW_AES192_128 }, @@ -249,7 +249,8 @@ public class NISTWrapKAT { }; } - @Test(dataProvider = "testData") + @ParameterizedTest + @MethodSource("testData") public void testKeyWrap(String algo, String key, int keyLen, String data, int dataLen, String expected) throws Exception { System.out.println("Testing " + algo + " Cipher with wrapping " + @@ -311,7 +312,8 @@ public class NISTWrapKAT { } } - @Test(dataProvider = "testData") + @ParameterizedTest + @MethodSource("testData") public void testEnc(String algo, String key, int keyLen, String data, int dataLen, String expected) throws Exception { System.out.println("Testing " + algo + " Cipher with enc " + diff --git a/test/jdk/com/sun/crypto/provider/KeyFactory/PBEKeyDestroyTest.java b/test/jdk/com/sun/crypto/provider/KeyFactory/PBEKeyDestroyTest.java index da266c147fb..41a86ccec64 100644 --- a/test/jdk/com/sun/crypto/provider/KeyFactory/PBEKeyDestroyTest.java +++ b/test/jdk/com/sun/crypto/provider/KeyFactory/PBEKeyDestroyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,13 +26,17 @@ * @bug 8312306 * @summary Check the destroy()/isDestroyed() of the PBEKey impl from SunJCE * @library /test/lib - * @run testng/othervm PBEKeyDestroyTest + * @run junit/othervm PBEKeyDestroyTest */ -import javax.crypto.*; -import javax.crypto.spec.*; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; import java.nio.charset.StandardCharsets; -import org.testng.Assert; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class PBEKeyDestroyTest { @@ -48,22 +52,22 @@ public class PBEKeyDestroyTest { SecretKey key2 = skf.generateSecret(keySpec); // should be equal - Assert.assertFalse(key1.isDestroyed()); - Assert.assertFalse(key2.isDestroyed()); - Assert.assertTrue(key1.equals(key2)); - Assert.assertTrue(key2.equals(key1)); + assertFalse(key1.isDestroyed()); + assertFalse(key2.isDestroyed()); + assertEquals(key1, key2); + assertEquals(key2, key1); // destroy key1 key1.destroy(); - Assert.assertTrue(key1.isDestroyed()); - Assert.assertFalse(key1.equals(key2)); - Assert.assertFalse(key2.equals(key1)); + assertTrue(key1.isDestroyed()); + assertNotEquals(key1, key2); + assertNotEquals(key2, key1); // also destroy key2 key2.destroy(); - Assert.assertTrue(key2.isDestroyed()); - Assert.assertFalse(key1.equals(key2)); - Assert.assertFalse(key2.equals(key1)); + assertTrue(key2.isDestroyed()); + assertNotEquals(key1, key2); + assertNotEquals(key2, key1); // call destroy again to make sure no unexpected exceptions key2.destroy(); diff --git a/test/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index cb51e91021b..3a936f288cc 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -84,6 +84,15 @@ * @comment Regression test for using the wrong thread when logging during re-locking from deoptimization. * * @comment DiagnoseSyncOnValueBasedClasses=2 will cause logging when locking on \@ValueBased objects. + * @run driver EATests + * -XX:+UnlockDiagnosticVMOptions + * -Xms256m -Xmx256m + * -Xbootclasspath/a:. + * -XX:CompileCommand=dontinline,*::dontinline_* + * -XX:+WhiteBoxAPI + * -Xbatch + * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks + * -XX:DiagnoseSyncOnValueBasedClasses=2 * * @comment Re-lock may inflate monitors when re-locking, which cause monitorinflation trace logging. * @run driver EATests diff --git a/test/jdk/com/sun/jdi/JdbMethodExitTest.java b/test/jdk/com/sun/jdi/JdbMethodExitTest.java index 77e12b5f4a6..da76ddb4ab6 100644 --- a/test/jdk/com/sun/jdi/JdbMethodExitTest.java +++ b/test/jdk/com/sun/jdi/JdbMethodExitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, 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 @@ -239,6 +239,7 @@ public class JdbMethodExitTest extends JdbTest { // trace exit of methods with all the return values // (but just check a couple of them) jdb.command(JdbCommand.traceMethodExits(true, threadId)); + execCommand(JdbCommand.trace()); execCommand(JdbCommand.cont()) .shouldContain("instance of JdbMethodExitTestTarg") .shouldContain("return value = 8"); @@ -252,7 +253,7 @@ public class JdbMethodExitTest extends JdbTest { .shouldContain("Method entered:"); execCommand(JdbCommand.cont()) .shouldContain("Method exited: return value = \"traceMethods\""); - jdb.command(JdbCommand.stepUp()); + jdb.command(JdbCommand.next()); List reply = new LinkedList<>(); diff --git a/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java b/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java index 80931ca7440..76acac11506 100644 --- a/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java +++ b/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,11 @@ import javax.management.remote.JMXConnectionNotification; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; +import jdk.test.lib.Utils; public class Client { - public static final int COUNTER_TIMEOUT_SECONDS = 60; + public static final int COUNTER_TIMEOUT_SECONDS = 30; public static void run(String url) throws Exception { final int notifEmittedCnt = 10; @@ -87,7 +88,7 @@ public class Client { System.out.println(); try { System.out.println("waiting for " + notifEmittedCnt + " notifications to arrive"); - if (!counter.await(COUNTER_TIMEOUT_SECONDS, TimeUnit.SECONDS)) { + if (!counter.await(Utils.adjustTimeout(COUNTER_TIMEOUT_SECONDS), TimeUnit.SECONDS)) { throw new Error("Client: Counter await expired"); } if (duplNotification.get()) { diff --git a/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.java b/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.java index 0e5e5e30d4e..5fac14d76e3 100644 --- a/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.java +++ b/test/jdk/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,9 @@ import java.util.Arrays; * @author Jaroslav Bachorik * @bug 6937053 8005472 * + * @library /test/lib + * @build jdk.test.lib.Utils + * * @modules java.management * jdk.compiler * @run clean TestSerializationMismatch diff --git a/test/jdk/com/sun/jndi/dns/ConfigTests/PortUnreachable.java b/test/jdk/com/sun/jndi/dns/ConfigTests/PortUnreachable.java index 0a92e52c270..eb917c2f25a 100644 --- a/test/jdk/com/sun/jndi/dns/ConfigTests/PortUnreachable.java +++ b/test/jdk/com/sun/jndi/dns/ConfigTests/PortUnreachable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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 @@ -36,7 +36,7 @@ import javax.naming.directory.InitialDirContext; * @requires os.family != "aix" * @library ../lib/ * @modules java.base/sun.security.util - * @run main/othervm -Djdk.net.usePlainDatagramSocketImpl=false PortUnreachable + * @run main PortUnreachable */ public class PortUnreachable extends DNSTestBase { diff --git a/test/jdk/com/sun/jndi/ldap/LdapPoolTimeoutTest.java b/test/jdk/com/sun/jndi/ldap/LdapPoolTimeoutTest.java index b139f12da25..7d65298faa6 100644 --- a/test/jdk/com/sun/jndi/ldap/LdapPoolTimeoutTest.java +++ b/test/jdk/com/sun/jndi/ldap/LdapPoolTimeoutTest.java @@ -27,10 +27,10 @@ * @summary Multi-threaded client timeout tests for ldap pool * @library /test/lib * lib/ - * @run testng/othervm/timeout=480 LdapPoolTimeoutTest + * @run junit/othervm/timeout=480 LdapPoolTimeoutTest */ -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import javax.naming.Context; import javax.naming.NamingException; diff --git a/test/jdk/com/sun/jndi/ldap/LdapTimeoutTest.java b/test/jdk/com/sun/jndi/ldap/LdapTimeoutTest.java index 39bf24b9dbf..a4b032d0974 100644 --- a/test/jdk/com/sun/jndi/ldap/LdapTimeoutTest.java +++ b/test/jdk/com/sun/jndi/ldap/LdapTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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,14 +25,17 @@ * @test * @library /test/lib * lib/ - * @run testng/othervm LdapTimeoutTest + * @run junit/othervm LdapTimeoutTest * @bug 7094377 8000487 6176036 7056489 8151678 * @summary Timeout tests for ldap */ -import org.testng.Assert; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import javax.naming.Context; import javax.naming.NamingException; @@ -60,8 +63,6 @@ import static java.lang.String.format; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; import static jdk.test.lib.Utils.adjustTimeout; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; public class LdapTimeoutTest { @@ -90,7 +91,7 @@ public class LdapTimeoutTest { assert (2 * CONNECT_MILLIS + READ_MILLIS + TOLERANCE < INFINITY_MILLIS); } - @BeforeTest + @BeforeEach public void beforeTest() { startAuxiliaryDiagnosticOutput(); } @@ -98,11 +99,6 @@ public class LdapTimeoutTest { /* * These are timeout tests and they are run in parallel to reduce the total * amount of run time. - * - * Currently it doesn't seem possible to instruct JTREG to run TestNG test - * methods in parallel. That said, this JTREG test is still - * a "TestNG-flavored" test for the sake of having org.testng.Assert - * capability. */ @Test public void test() throws Exception { @@ -190,11 +186,11 @@ public class LdapTimeoutTest { env.put(Context.PROVIDER_URL, urlTo(server)); server.start(); server.starting().join(); - Assert.ThrowingRunnable completion = + Executable completion = () -> assertCompletion(CONNECT_MILLIS, 2 * CONNECT_MILLIS + TOLERANCE, () -> new InitialDirContext(env)); - NamingException e = expectThrows(NamingException.class, completion); + NamingException e = assertThrows(NamingException.class, completion); String msg = e.getMessage(); assertTrue(msg != null && msg.contains("timeout") && msg.contains(String.valueOf(CONNECT_MILLIS)), @@ -214,11 +210,11 @@ public class LdapTimeoutTest { InitialDirContext ctx = new InitialDirContext(env); SearchControls scl = new SearchControls(); scl.setSearchScope(SearchControls.SUBTREE_SCOPE); - Assert.ThrowingRunnable completion = + Executable completion = () -> assertCompletion(READ_MILLIS, READ_MILLIS + TOLERANCE, () -> ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl)); - NamingException e = expectThrows(NamingException.class, completion); + NamingException e = assertThrows(NamingException.class, completion); String msg = e.getMessage(); assertTrue(msg != null && msg.contains("timeout") && msg.contains(String.valueOf(READ_MILLIS)), @@ -235,11 +231,11 @@ public class LdapTimeoutTest { env.put(Context.PROVIDER_URL, urlTo(server)); server.start(); server.starting().join(); - Assert.ThrowingRunnable completion = + Executable completion = () -> assertCompletion(CONNECT_MILLIS, 2 * CONNECT_MILLIS + TOLERANCE, () -> new InitialDirContext(env)); - NamingException e = expectThrows(NamingException.class, completion); + NamingException e = assertThrows(NamingException.class, completion); String msg = e.getMessage(); assertTrue(msg != null && msg.contains("timeout") && msg.contains(String.valueOf(CONNECT_MILLIS)), @@ -261,11 +257,11 @@ public class LdapTimeoutTest { env.put(Context.PROVIDER_URL, urlTo(server)); server.start(); server.starting().join(); - Assert.ThrowingRunnable completion = + Executable completion = () -> assertCompletion(CONNECT_MILLIS, 2 * CONNECT_MILLIS + TOLERANCE, () -> new InitialDirContext(env)); - NamingException e = expectThrows(NamingException.class, completion); + NamingException e = assertThrows(NamingException.class, completion); String msg = e.getMessage(); assertTrue(msg != null && msg.contains("timeout") && msg.contains(String.valueOf(CONNECT_MILLIS)), diff --git a/test/jdk/com/sun/jndi/ldap/NamingExceptionMessageTest.java b/test/jdk/com/sun/jndi/ldap/NamingExceptionMessageTest.java index c165593ad5e..1250548b60a 100644 --- a/test/jdk/com/sun/jndi/ldap/NamingExceptionMessageTest.java +++ b/test/jdk/com/sun/jndi/ldap/NamingExceptionMessageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +27,7 @@ * @summary Test that CommunicationException is thrown when connection is timed out or closed/cancelled, * and it's text matches the failure reason. * @library /test/lib lib - * @run testng NamingExceptionMessageTest + * @run junit NamingExceptionMessageTest */ import javax.naming.CommunicationException; @@ -45,8 +45,11 @@ import java.util.Hashtable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.testng.annotations.Test; -import org.testng.Assert; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import jdk.test.lib.net.URIBuilder; public class NamingExceptionMessageTest { @@ -58,9 +61,9 @@ public class NamingExceptionMessageTest { ldapServer.awaitStartup(); var env = ldapServer.getInitialLdapCtxEnvironment(TIMEOUT_VALUE); var communicationException = - Assert.expectThrows(CommunicationException.class, () -> new InitialDirContext(env)); + assertThrows(CommunicationException.class, () -> new InitialDirContext(env)); System.out.println("Got CommunicationException:" + communicationException); - Assert.assertEquals(communicationException.getMessage(), EXPECTED_TIMEOUT_MESSAGE); + assertEquals(EXPECTED_TIMEOUT_MESSAGE, communicationException.getMessage()); } } @@ -70,7 +73,7 @@ public class NamingExceptionMessageTest { ldapServer.start(); ldapServer.awaitStartup(); var env = ldapServer.getInitialLdapCtxEnvironment(0); - var namingException = Assert.expectThrows(NamingException.class, () -> new InitialDirContext(env)); + var namingException = assertThrows(NamingException.class, () -> new InitialDirContext(env)); if (namingException instanceof ServiceUnavailableException) { // If naming exception is ServiceUnavailableException it could mean // that the connection was closed on test server-side before LDAP client starts @@ -78,11 +81,11 @@ public class NamingExceptionMessageTest { System.out.println("Got ServiceUnavailableException: Test PASSED"); } else { // If exception is not ServiceUnavailableException, CommunicationException is expected - Assert.assertTrue(namingException instanceof CommunicationException); + assertInstanceOf(CommunicationException.class, namingException); var communicationException = (CommunicationException) namingException; System.out.println("Got CommunicationException:" + communicationException); // Check exception message - Assert.assertEquals(communicationException.getMessage(), EXPECTED_CLOSURE_MESSAGE); + assertEquals(EXPECTED_CLOSURE_MESSAGE, communicationException.getMessage()); } } } diff --git a/test/jdk/com/sun/jndi/ldap/SaslOutputStreamCloseTest.java b/test/jdk/com/sun/jndi/ldap/SaslOutputStreamCloseTest.java new file mode 100644 index 00000000000..5558a4ab196 --- /dev/null +++ b/test/jdk/com/sun/jndi/ldap/SaslOutputStreamCloseTest.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2026, 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.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Constructor; + +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslException; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; + +/* + * @test + * @bug 8377486 + * @summary Verify that SaslOutputStream.write() methods throw an IOException, if invoked + * when the stream is closed + * @modules java.security.sasl/com.sun.security.sasl + * java.naming/com.sun.jndi.ldap.sasl:+open + * @run junit ${test.main.class} + */ +class SaslOutputStreamCloseTest { + + /* + * Verifies that SaslOutputStream.write(...) throws IOException if the SaslOutputStream + * is closed. + */ + @Test + void testWriteThrowsIOExceptionOnClose() throws Exception { + try (final OutputStream os = createSaslOutputStream(new ByteArrayOutputStream())) { + os.write(new byte[]{0x42, 0x42}); + os.close(); + try { + os.write(new byte[]{0x42}, 0, 1); + fail("OutputStream.write(...) on closed " + os + " did not throw IOException"); + } catch (IOException ioe) { + // verify it was thrown for right reason + if (!"stream closed".equals(ioe.getMessage())) { + throw ioe; // propagate original exception + } + // expected + System.err.println("received expected IOException: " + ioe); + } + } + } + + // reflectively construct an instance of + // (package private) com.sun.jndi.ldap.sasl.SaslOutputStream class + private static OutputStream createSaslOutputStream(final OutputStream underlying) throws Exception { + final Constructor constructor = Class.forName("com.sun.jndi.ldap.sasl.SaslOutputStream") + .getDeclaredConstructor(new Class[]{SaslClient.class, OutputStream.class}); + constructor.setAccessible(true); + return (OutputStream) constructor.newInstance(new DummySaslClient(), underlying); + } + + + private static final class DummySaslClient implements SaslClient { + private boolean closed; + + @Override + public String getMechanismName() { + return "DUMMY"; + } + + @Override + public boolean hasInitialResponse() { + return false; + } + + @Override + public byte[] evaluateChallenge(byte[] challenge) throws SaslException { + return new byte[0]; + } + + @Override + public boolean isComplete() { + return true; + } + + @Override + public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException { + if (closed) { + // intentionally throw something other than a IOException + throw new IllegalStateException(this + " is closed"); + } + return incoming; + } + + @Override + public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException { + if (closed) { + // intentionally throw something other than a IOException + throw new IllegalStateException(this + " is closed"); + } + return outgoing; + } + + @Override + public Object getNegotiatedProperty(String propName) { + return null; + } + + @Override + public void dispose() { + this.closed = true; + } + } +} diff --git a/test/jdk/com/sun/jndi/ldap/SkipAbandonRequestOnClosedConn.java b/test/jdk/com/sun/jndi/ldap/SkipAbandonRequestOnClosedConn.java new file mode 100644 index 00000000000..cb2eef49bd2 --- /dev/null +++ b/test/jdk/com/sun/jndi/ldap/SkipAbandonRequestOnClosedConn.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2026, 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.io.FilterInputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.Socket; +import java.util.Arrays; +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import com.sun.jndi.ldap.Connection; +import com.sun.jndi.ldap.LdapClient; +import com.sun.jndi.ldap.LdapCtx; +import jdk.test.lib.net.URIBuilder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +/* + * @test + * @bug 8362268 + * @summary Verify that unexpected exceptions aren't propagated to LdapCtx callers + * when the LdapCtx's (internal) connection is closed due to an exception + * when reading/writing over the connection's stream + * @modules java.naming/com.sun.jndi.ldap:+open + * @library /test/lib lib/ + * @build jdk.test.lib.net.URIBuilder + * BaseLdapServer LdapMessage + * @run junit/othervm ${test.main.class} + */ +class SkipAbandonRequestOnClosedConn { + + private static final String LOOKUP_NAME = "ou=People,o=FooBar"; + + private static final class Server extends BaseLdapServer { + + private Server() throws IOException { + super(); + } + + // handles and responds to the incoming LDAP request + @Override + protected void handleRequest(final Socket socket, + final LdapMessage request, + final OutputStream out) throws IOException { + switch (request.getOperation()) { + case SEARCH_REQUEST: { + System.err.println("responding to SEARCH_REQUEST with id: " + + request.getMessageID() + " on socket " + socket); + // write out some bytes as a response. it doesn't matter what those + // bytes are - in this test they aren't expected to reach + // the application code. + final byte[] irrelevantResponse = new byte[]{0x42, 0x42, 0x42}; + System.err.println("Response: " + Arrays.toString(irrelevantResponse)); + out.write(irrelevantResponse); + out.flush(); + break; + } + default: { + throw new IOException("unexpected operation type: " + request.getOperation() + + ", request: " + request); + } + } + } + } + + private static Server server; + + @BeforeAll + static void beforeAll() throws Exception { + server = new Server(); + server.start(); + System.err.println("server started at " + server.getInetAddress() + + ":" + server.getPort()); + } + + @AfterAll + static void afterAll() throws Exception { + if (server != null) { + System.err.println("stopping server " + server.getInetAddress() + + ":" + server.getPort()); + server.close(); + } + } + + + /* + * Creates a com.sun.jndi.ldap.LdapCtx and configures its internal com.sun.jndi.ldap.Connection + * instance with an InputStream that throws an IOException in its read() methods. The test + * then initiates a Context.lookup() so that a LDAP request is internally issued and a LDAP + * response is waited for. Due to the configured InputStream throwing an exception from its + * read(), the com.sun.jndi.ldap.Connection will get closed (internally) when reading the + * response and the main thread which was waiting for the LDAP response is woken up and notices + * the connection closure. This test verifies that a NamingException gets thrown from the + * lookup() in this scenario. + */ + @Test + void testNamingException() throws Exception { + final Hashtable envProps = new Hashtable<>(); + envProps.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + final String providerUrl = URIBuilder.newBuilder() + .scheme("ldap") + .host(server.getInetAddress().getHostAddress()) + .port(server.getPort()) + .build().toString(); + envProps.put(Context.PROVIDER_URL, providerUrl); + // explicitly set LDAP version to 3 to prevent LDAP BIND requests + // during LdapCtx instantiation + envProps.put("java.naming.ldap.version", "3"); + // create a (custom) InitialContext which allows us to access the + // LdapCtx's internal connection instance + try (final CustomContext ctx = new CustomContext(envProps)) { + // replace the InputStream and OutputStream of the LdapCtx's + // internal connection, to allow us to raise exception from + // the InputStream and OutputStream as necessary + ctx.replaceStreams(); + + System.err.println("issuing ldap request against " + providerUrl + + " using context " + ctx); + // trigger the LDAP SEARCH request through the lookup call. we are not + // interested in the returned value and are merely interested in the + // Context.lookup(...) failing with a NamingException + assertLookupThrowsNamingException(ctx); + } + } + + // assert that Context.lookup(...) raises a NamingException + private static void assertLookupThrowsNamingException(final Context ctx) { + try { + final Object result = ctx.lookup(LOOKUP_NAME); + fail("Context.lookup() was expected to throw NamingException" + + " but returned result " + result); + } catch (NamingException ne) { + // verify the NamingException is for the right reason + if (!ne.toString().contains("LDAP connection has been closed")) { + // unexpected exception, propagate it + fail("NamingException is missing \"LDAP connection has been closed\" message", ne); + } + // expected + System.err.println("got expected exception: " + ne); + } + } + + private static final class CustomContext extends InitialContext implements AutoCloseable { + + private CustomContext(final Hashtable environment) throws NamingException { + super(environment); + } + + private LdapCtx getLdapCtx() throws NamingException { + final Context ctx = getDefaultInitCtx(); + if (ctx instanceof LdapCtx ldapCtx) { + return ldapCtx; + } + throw new IllegalStateException("Not a LdapCtx: " + ctx.getClass().getName()); + } + + // using reflection, return the com.sun.jndi.ldap.Connection instance + // from within the com.sun.jndi.ldap.LdapCtx + private Connection getConnection() throws Exception { + final LdapCtx ldapCtx = getLdapCtx(); + final Field clientField = ldapCtx.getClass().getDeclaredField("clnt"); + clientField.setAccessible(true); + final LdapClient ldapClient = (LdapClient) clientField.get(ldapCtx); + final Field connField = ldapClient.getClass().getDeclaredField("conn"); + connField.setAccessible(true); + return (Connection) connField.get(ldapClient); + } + + private void replaceStreams() throws Exception { + final Connection conn = getConnection(); + assertNotNull(conn, "com.sun.jndi.ldap.Connection instance is null"); + final InputStream originalInputStream = conn.inStream; + final OutputStream originalOutputStream = conn.outStream; + // replace the connection's streams with our test specific streams + conn.replaceStreams(new In(originalInputStream), new Out(originalOutputStream)); + System.err.println("replaced streams on connection: " + conn); + } + } + + // an OutputStream which intentionally throws a NullPointerException + // from its write(...) methods if the OutputStream has been closed + private static final class Out extends FilterOutputStream { + private volatile boolean closed; + + private Out(final OutputStream underlying) { + super(underlying); + } + + @Override + public void write(final int b) throws IOException { + if (closed) { + throw new NullPointerException("OutputStream is closed - intentional" + + " NullPointerException instead of IOException"); + } + super.write(b); + } + + @Override + public void write(final byte[] b, final int off, final int len) throws IOException { + if (closed) { + throw new NullPointerException("OutputStream is closed - intentional" + + " NullPointerException instead of IOException"); + } + super.write(b, off, len); + } + + @Override + public void close() throws IOException { + System.err.println("closing output stream " + this); + closed = true; + super.close(); + } + } + + // an InputStream which intentionally throws an exception + // from its read(...) methods. + private static final class In extends FilterInputStream { + + private In(InputStream underlying) { + super(underlying); + } + + @Override + public int read() throws IOException { + final int v = super.read(); + System.err.println("read " + v + " from " + in + + ", will now intentionally throw an exception"); + throw new IOException("intentional IOException from " + In.class.getName() + ".read()"); + } + + @Override + public int read(final byte[] b, final int off, final int len) throws IOException { + final int v = super.read(b, off, len); + System.err.println("read " + v + " byte(s) from " + in + + ", will now intentionally throw an exception"); + throw new IOException("intentional IOException from " + In.class.getName() + + ".read(byte[], int, int)"); + } + } +} diff --git a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java index 77020491c29..3878513d3f2 100644 --- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java +++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,6 +49,7 @@ import java.nio.file.FileAlreadyExistsException; import java.nio.file.Path; import java.time.ZonedDateTime; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -238,6 +239,7 @@ class DumpThreads { void testBlockedThread(ThreadFactory factory, boolean pinned) throws Exception { var lock = new Object(); + String lockAsString = Objects.toIdentityString(lock); var started = new CountDownLatch(1); Thread thread = factory.newThread(() -> { @@ -258,9 +260,7 @@ class DumpThreads { thread.start(); started.await(); await(thread, Thread.State.BLOCKED); - long tid = thread.threadId(); - String lockAsString = Objects.toIdentityString(lock); // thread dump in plain text should include thread List lines = dumpThreadsToPlainText(); @@ -308,6 +308,7 @@ class DumpThreads { void testWaitingThread(ThreadFactory factory, boolean pinned) throws Exception { var lock = new Object(); + String lockAsString = Objects.toIdentityString(lock); var started = new CountDownLatch(1); Thread thread = factory.newThread(() -> { @@ -331,9 +332,7 @@ class DumpThreads { thread.start(); started.await(); await(thread, Thread.State.WAITING); - long tid = thread.threadId(); - String lockAsString = Objects.toIdentityString(lock); // thread dump in plain text should include thread List lines = dumpThreadsToPlainText(); @@ -417,7 +416,6 @@ class DumpThreads { thread.start(); started.await(); await(thread, Thread.State.WAITING); - long tid = thread.threadId(); // thread dump in plain text should include thread @@ -460,7 +458,7 @@ class DumpThreads { } /** - * Test thread dump with a thread owning a monitor. + * Test thread dump with a thread owning monitors. */ @ParameterizedTest @MethodSource("threadFactories") @@ -475,19 +473,26 @@ class DumpThreads { } void testThreadOwnsMonitor(ThreadFactory factory, boolean pinned) throws Exception { - var lock = new Object(); - var started = new CountDownLatch(1); + var lock1 = new Object(); + var lock2 = new Object(); + var lock3 = new Object(); + String lock1AsString = Objects.toIdentityString(lock1); + String lock2AsString = Objects.toIdentityString(lock2); + String lock3AsString = Objects.toIdentityString(lock3); + var started = new CountDownLatch(1); Thread thread = factory.newThread(() -> { - synchronized (lock) { - if (pinned) { - VThreadPinner.runPinned(() -> { + synchronized (lock1) { + synchronized (lock2) { + if (pinned) { + VThreadPinner.runPinned(() -> { + started.countDown(); + lockAndRun(lock3, LockSupport::park); + }); + } else { started.countDown(); - LockSupport.park(); - }); - } else { - started.countDown(); - LockSupport.park(); + lockAndRun(lock3, LockSupport::park); + } } } }); @@ -497,16 +502,16 @@ class DumpThreads { thread.start(); started.await(); await(thread, Thread.State.WAITING); - long tid = thread.threadId(); - String lockAsString = Objects.toIdentityString(lock); // thread dump in plain text should include thread List lines = dumpThreadsToPlainText(); ThreadFields fields = findThread(tid, lines); assertNotNull(fields, "thread not found"); assertEquals("WAITING", fields.state()); - assertTrue(contains(lines, "- locked <" + lockAsString)); + assertTrue(contains(lines, "- locked <" + lock1AsString)); + assertTrue(contains(lines, "- locked <" + lock2AsString)); + assertTrue(contains(lines, "- locked <" + lock3AsString)); // thread dump in JSON format should include thread in root container ThreadDump threadDump = dumpThreadsToJson(); @@ -516,18 +521,47 @@ class DumpThreads { assertNotNull(ti, "thread not found"); assertEquals(ti.isVirtual(), thread.isVirtual()); - // the lock should be in the ownedMonitors array - Set ownedMonitors = ti.ownedMonitors().values() + // depth -> list of locks + Map> ownedMonitors = ti.ownedMonitors(); + + // lock -> list of depths + Map> monitorDepths = ownedMonitors.entrySet() .stream() - .flatMap(List::stream) - .collect(Collectors.toSet()); - assertTrue(ownedMonitors.contains(lockAsString), lockAsString + " not found"); + .flatMap(e -> e.getValue() + .stream() + .map(monitor -> Map.entry(monitor, e.getKey()))) + .collect(Collectors.groupingBy( + Map.Entry::getKey, + Collectors.mapping(Map.Entry::getValue, Collectors.toList()) + )); + + // each lock should be owned + List lock1Depths = monitorDepths.getOrDefault(lock1AsString, List.of()); + List lock2Depths = monitorDepths.getOrDefault(lock2AsString, List.of()); + List lock3Depths = monitorDepths.getOrDefault(lock3AsString, List.of()); + assertEquals(1, lock1Depths.size()); + assertEquals(1, lock2Depths.size()); + assertEquals(1, lock3Depths.size()); + + // lock1 and lock2 owned at the same depth, lock3 is the innermost + int depth1 = lock1Depths.get(0); + int depth2 = lock2Depths.get(0); + int depth3 = lock3Depths.get(0); + assertEquals(depth1, depth2); + assertTrue(depth3 < depth1); + } finally { LockSupport.unpark(thread); thread.join(); } } + private void lockAndRun(Object lock, Runnable action) { + synchronized (lock) { + action.run(); + } + } + /** * Test mounted virtual thread. */ diff --git a/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java b/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java new file mode 100644 index 00000000000..6b260636585 --- /dev/null +++ b/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2026, 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 com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.http.HttpClient; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.net.http.HttpClient.Builder.NO_PROXY; + +import org.junit.jupiter.api.AfterAll; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/* + * @test id=default + * @bug 8272758 + * @summary Verifies path prefix matching using defaults + * @build EchoHandler + * @run junit ${test.main.class} + */ + +/* + * @test id=withProperty + * @bug 8272758 + * @summary Verifies path prefix matching by providing a system property + * @build EchoHandler + * @run junit/othervm + * -Dsun.net.httpserver.pathMatcher=pathPrefix + * ${test.main.class} + */ + +/* + * @test id=withInvalidProperty + * @bug 8272758 + * @summary Verifies path prefix matching by providing a system property + * containing an invalid value, and observing it fall back to the + * default + * @build EchoHandler + * @run junit/othervm + * -Dsun.net.httpserver.pathMatcher=noSuchMatcher + * ${test.main.class} + */ + +public class ContextPathMatcherPathPrefixTest { + + protected static final HttpClient CLIENT = + HttpClient.newBuilder().proxy(NO_PROXY).build(); + + @AfterAll + static void stopClient() { + CLIENT.shutdownNow(); + } + + @Test + void testContextPathOfEmptyString() { + var iae = assertThrows(IllegalArgumentException.class, () -> new Infra("")); + assertEquals("Illegal value for path or protocol", iae.getMessage()); + } + + @Test + void testContextPathAtRoot() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths + try (var infra = new Infra("/")) { + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "GET /foobar"); + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + infra.expect(200, "DOH /foobar"); + // 404 + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); + } + } + + @Test + void testContextPathAtSubDir() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths + try (var infra = new Infra("/foo")) { + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + // 404 + infra.expect(404, "GET /foobar"); // Differs from string prefix matching! + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /foobar"); // Differs from string prefix matching! + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); + } + } + + @Test + void testContextPathAtSubDirWithTrailingSlash() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths + try (var infra = new Infra("/foo/")) { + // 200 + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + // 404 + infra.expect(404, "GET /foo"); + infra.expect(404, "GET /foobar"); + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /foo"); + infra.expect(404, "DOH /foobar"); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); + } + } + + protected static final class Infra implements AutoCloseable { + + /** Charset used for network and file I/O. */ + private static final Charset CHARSET = StandardCharsets.US_ASCII; + + /** Socket address the server will bind to. */ + private static final InetSocketAddress LO_SA_0 = + new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + + private static final HttpHandler HANDLER = new EchoHandler(); + + private final HttpServer server; + + private final String contextPath; + + protected Infra(String contextPath) throws IOException { + this.server = HttpServer.create(LO_SA_0, 10); + server.createContext(contextPath, HANDLER); + server.start(); + this.contextPath = contextPath; + } + + protected void expect(int statusCode, String requestLinePrefix) { + try { + expect0(statusCode, requestLinePrefix); + } catch (Throwable exception) { + var extendedMessage = exception.getMessage() + " " + Map.of( + "contextPath", contextPath, + "requestLinePrefix", requestLinePrefix); + var extendedException = new RuntimeException(extendedMessage); + extendedException.setStackTrace(exception.getStackTrace()); + throw extendedException; + } + } + + private void expect0(int statusCode, String requestLinePrefix) throws IOException { + + // Connect to the server + try (Socket socket = new Socket()) { + socket.connect(server.getAddress()); + + // Obtain the I/O streams + try (OutputStream outputStream = socket.getOutputStream(); + InputStream inputStream = socket.getInputStream(); + BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream, CHARSET))) { + + // Write the request + byte[] requestBytes = String + // `Connection: close` is required for `BufferedReader::readLine` to work. + .format("%s HTTP/1.1\r\nConnection: close\r\n\r\n", requestLinePrefix) + .getBytes(CHARSET); + outputStream.write(requestBytes); + outputStream.flush(); + + // Read the response status code + String statusLine = inputReader.readLine(); + assertNotNull(statusLine, "Unexpected EOF while reading status line"); + Matcher statusLineMatcher = Pattern.compile("^HTTP/1\\.1 (\\d+) .+$").matcher(statusLine); + assertTrue(statusLineMatcher.matches(), "Couldn't match status line: \"" + statusLine + "\""); + assertEquals(statusCode, Integer.parseInt(statusLineMatcher.group(1))); + + } + + } + + } + + @Override + public void close() { + server.stop(0); + } + + } + +} diff --git a/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java b/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java new file mode 100644 index 00000000000..4faa1463e1b --- /dev/null +++ b/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026, 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 org.junit.jupiter.api.Test; + +/* + * @test + * @bug 8272758 + * @summary Verifies string prefix matching configured using a system property + * @build ContextPathMatcherPathPrefixTest + * EchoHandler + * @run junit/othervm + * -Dsun.net.httpserver.pathMatcher=stringPrefix + * ${test.main.class} + */ + +class ContextPathMatcherStringPrefixTest extends ContextPathMatcherPathPrefixTest { + + @Test + @Override + void testContextPathAtSubDir() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths + try (var infra = new Infra("/foo")) { + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "GET /foobar"); // Differs from path prefix matching! + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + infra.expect(200, "DOH /foobar"); // Differs from path prefix matching! + // 404 + infra.expect(404, "GET /"); + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /"); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); + } + } + +} diff --git a/test/jdk/com/sun/net/httpserver/FailAndStopTest.java b/test/jdk/com/sun/net/httpserver/FailAndStopTest.java new file mode 100644 index 00000000000..005d78add18 --- /dev/null +++ b/test/jdk/com/sun/net/httpserver/FailAndStopTest.java @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2026, 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 8377302 + * @summary HttpServer.stop() blocks indefinitely if handler throws + * @modules jdk.httpserver java.logging + * @library /test/lib + * @run main/othervm ${test.main.class} + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Optional; +import java.util.function.BiPredicate; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsServer; +import jdk.test.lib.net.SimpleSSLContext; +import jdk.test.lib.net.URIBuilder; +import jdk.test.lib.Utils; +import static com.sun.net.httpserver.HttpExchange.RSPBODY_CHUNKED; + +public class FailAndStopTest implements HttpHandler { + // Keep that logger in a static field to make sure it doesn't + // get GC'ed and recreated before the HttpServer is initialized. + private static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); + private static final String BODY = "OK"; + + static enum TestCases { + FAILNOW("failNow", TestCases::shouldAlwaysFail), + ASSERTNOW("assertNow", TestCases::shouldAlwaysFail), + RESPANDFAIL("failAfterResponseStatus", TestCases::shouldFailExceptForHead), + RESPANDASSERT("assertAfterResponseStatus", TestCases::shouldFailExceptForHead), + CLOSEAFTERRESP("closeExchangeAfterResponseStatus", TestCases::shouldFailExceptForHead), + BODYANDFAIL("failAfterBody", TestCases::shouldFailExceptForHeadOrHttps), + BODYANDASSERT("assertAfterBody", TestCases::shouldFailExceptForHeadOrHttps), + CLOSEBEFOREOS("closeExchangeBeforeOS", TestCases::shouldNeverFail), + CLOSEANDRETURN("closeAndReturn", TestCases::shouldNeverFail), + CLOSEANDFAIL("closeAndFail", TestCases::shouldNeverFail), + CLOSEANDASSERT("closeAndAssert", TestCases::shouldNeverFail); + + private final String query; + private BiPredicate shouldFail; + TestCases(String query, BiPredicate shouldFail) { + this.query = query; + this.shouldFail = shouldFail; + } + boolean shouldFail(String scheme, String method) { + // in case of HEAD method the client should not + // fail if we throw after sending response headers + return shouldFail.test(scheme, method); + } + private static boolean shouldAlwaysFail(String scheme, String method) { + return true; + } + private static boolean shouldNeverFail(String scheme, String method) { + return false; + } + private static boolean shouldFailExceptForHead(String scheme, String method) { + return !"HEAD".equals(method); + } + private static boolean shouldFailExceptForHeadOrHttps(String scheme, String method) { + // When using https, the buffered response bytes may be sent + // when the connection is closed, in which case the full body + // will be correctly received, and the client connection + // will not fail. With plain http, the bytes are not sent and + // the client fails with premature end of file. + return !"HEAD".equals(method) && !"https".equalsIgnoreCase(scheme); + } + + } + + @Override + public void handle(HttpExchange ex) throws IOException { + String query = ex.getRequestURI().getRawQuery(); + TestCases step = TestCases.FAILNOW; + if (query == null || query.equals(step.query)) { + System.out.println("Server: " + step); + throw new NullPointerException("Got you!"); + } + step = TestCases.ASSERTNOW; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new AssertionError("Got you!"); + } + byte[] body = BODY.getBytes(StandardCharsets.UTF_8); + ex.sendResponseHeaders(200, body.length); + step = TestCases.RESPANDFAIL; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new NullPointerException("Got you!"); + } + step = TestCases.RESPANDASSERT; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new AssertionError("Got you!"); + } + step = TestCases.CLOSEAFTERRESP; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + ex.close(); + return; + } + if (!"HEAD".equals(ex.getRequestMethod())) { + ex.getResponseBody().write(body); + } + step = TestCases.BODYANDFAIL; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new NullPointerException("Got you!"); + } + step = TestCases.BODYANDASSERT; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new AssertionError("Got you!"); + } + step = TestCases.CLOSEBEFOREOS; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + ex.close(); + return; + } + System.out.println("Server: closing response body"); + ex.getResponseBody().close(); + step = TestCases.CLOSEANDRETURN; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + ex.close(); + return; + } + step = TestCases.CLOSEANDFAIL; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new NullPointerException("Got you!"); + } + step = TestCases.CLOSEANDASSERT; + if (query.equals(step.query)) { + System.out.println("Server: " + step); + throw new AssertionError("Got you!"); + } + } + + private static void enableHttpServerLogging() { + // set HttpServer's logger to ALL + LOGGER.setLevel(Level.ALL); + // get the root logger, get its first handler (by default + // it's a ConsoleHandler), and set its level to ALL (by + // default its level is INFO). + Logger.getLogger("").getHandlers()[0].setLevel(Level.ALL); + } + + + public static void main(String[] args) throws Exception { + + enableHttpServerLogging(); + + // test with GET + for (var test : TestCases.values()) { + test(test, Optional.empty(), "http"); + test(test, Optional.empty(), "https"); + } + // test with HEAD + for (var test : TestCases.values()) { + test(test, Optional.of("HEAD"), "http"); + test(test, Optional.of("HEAD"), "https"); + } + } + + private static SSLContext initSSLContext(boolean secure) { + SSLContext context = secure ? SimpleSSLContext.findSSLContext() : null; + if (secure) { + SSLContext.setDefault(context); + } + return context; + } + + private static HttpServer createHttpServer(SSLContext context) throws IOException { + var address = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + if (context != null) { + var server = HttpsServer.create(address, 0); + server.setHttpsConfigurator(new HttpsConfigurator(context)); + return server; + } else { + return HttpServer.create(address, 0); + } + } + + private static HttpURLConnection createConnection(URL url, boolean secure) + throws IOException { + HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY); + if (secure) { + ((HttpsURLConnection)urlc).setHostnameVerifier(new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }); + } + return urlc; + } + + private static void test(TestCases test, Optional method, String scheme) + throws Exception { + boolean secure = "https".equalsIgnoreCase(scheme); + SSLContext context = initSSLContext(secure); + HttpServer server = createHttpServer(context); + + System.out.println("Test: " + method.orElse("GET") + " " + test.query); + System.out.println("Server listening at: " + server.getAddress()); + try { + server.createContext("/FailAndStopTest/", new FailAndStopTest()); + server.start(); + + URL url = URIBuilder.newBuilder() + .scheme(scheme) + .loopback() + .port(server.getAddress().getPort()) + .path("/FailAndStopTest/") + .query(test.query) + .toURLUnchecked(); + System.out.println("Connecting to: " + url); + HttpURLConnection urlc = createConnection(url, secure); + if (method.isPresent()) urlc.setRequestMethod(method.get()); + try { + System.out.println("Client: Response code received: " + urlc.getResponseCode()); + InputStream is = urlc.getInputStream(); + String body = new String(is.readAllBytes(), StandardCharsets.UTF_8); + is.close(); + System.out.printf("Client: read body: \"%s\"%n", body); + if (test.shouldFail(scheme, urlc.getRequestMethod())) { + throw new AssertionError(test.query + ": test did not fail"); + } + if (!method.orElse("GET").equals("HEAD")) { + if (!BODY.equals(body)) { + throw new AssertionError( + String.format("\"%s\" != \"%s\"", body, BODY)); + } + } else if (!body.isEmpty()) { + throw new AssertionError("Body is not empty: " + body); + } + } catch (IOException so) { + if (test.shouldFail(scheme, urlc.getRequestMethod())) { + // expected + System.out.println(test.query + ": Got expected exception: " + so); + } else if (!test.shouldFail("http", urlc.getRequestMethod())) { + // When using https, the buffered response bytes may be sent + // when the connection is closed, in which case the full body + // will be correctly received, and the client connection + // will not fail. With plain http, the bytes are not sent and + // the client fails with premature end of file. + // So only fail here if the test should not fail with plain + // http - we want to accept possible exception for https... + throw new AssertionError( + String.format("%s: test failed with %s", test.query, so), so); + } else { + System.out.printf("%s: WARNING: unexpected exception: %s%n", test.query, so); + // should only happen in those two cases: + assert secure && !"HEAD".equals(method) && + (test == TestCases.BODYANDFAIL || test == TestCases.BODYANDASSERT); + } + } + } finally { + // if not fixed will cause the test to fail in jtreg timeout + server.stop((int)Utils.adjustTimeout(5000)); + System.out.println("Server stopped as expected"); + } + } +} diff --git a/test/jdk/com/sun/net/httpserver/TaskRejectedTest.java b/test/jdk/com/sun/net/httpserver/TaskRejectedTest.java index 6b6d53fd3a3..109d28627dc 100644 --- a/test/jdk/com/sun/net/httpserver/TaskRejectedTest.java +++ b/test/jdk/com/sun/net/httpserver/TaskRejectedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,11 +21,6 @@ * questions. */ -/** - * @test - * @bug 8169358 - * @summary HttpServer does not close client connection when RejectedExecutionException occurs. - */ import com.sun.net.httpserver.HttpServer; @@ -46,6 +41,14 @@ import java.util.logging.Level; import java.util.logging.Logger; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; +/* + * @test + * @bug 8169358 + * @summary HttpServer does not close client connection when RejectedExecutionException occurs. + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + */ public class TaskRejectedTest { private static final int BACKLOG = 0; @@ -54,6 +57,15 @@ public class TaskRejectedTest { private static final int TIMEOUT = 10000; // 10 sec + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + + private static void setupLogging() { + final Handler consoleHandler = new ConsoleHandler(); + consoleHandler.setLevel(Level.FINEST); + logger.setLevel(Level.FINEST); + logger.addHandler(consoleHandler); + } + private static void runClient(InetSocketAddress listenAddr) throws MalformedURLException, IOException { URL url = new URL("http", listenAddr.getHostString(), @@ -75,13 +87,7 @@ public class TaskRejectedTest { } public static void main(String[] args) throws Exception { - Logger logger = Logger.getLogger( - HttpServer.class.getPackage().getName()); - Handler consoleHandler = new ConsoleHandler(); - consoleHandler.setLevel(Level.FINEST); - logger.setLevel(Level.FINEST); - logger.addHandler(consoleHandler); - + setupLogging(); // merely for debugging Executor executor = Executors.newSingleThreadExecutor(r -> { throw new RejectedExecutionException("test"); }); diff --git a/test/jdk/com/sun/net/httpserver/Test13.java b/test/jdk/com/sun/net/httpserver/Test13.java index 0401dbce5a8..503b9e4430c 100644 --- a/test/jdk/com/sun/net/httpserver/Test13.java +++ b/test/jdk/com/sun/net/httpserver/Test13.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,19 +21,6 @@ * questions. */ -/* - * @test - * @bug 6270015 - * @library /test/lib - * @build jdk.test.lib.Asserts - * jdk.test.lib.Utils - * jdk.test.lib.net.SimpleSSLContext - * jdk.test.lib.net.URIBuilder - * @run main/othervm Test13 - * @run main/othervm -Djava.net.preferIPv6Addresses=true Test13 - * @summary Light weight HTTP server - */ - import com.sun.net.httpserver.*; import java.nio.file.Files; @@ -54,6 +41,20 @@ import static jdk.test.lib.Utils.createTempFileOfSize; * - same as Test12, but with 64 threads */ +/* + * @test + * @bug 6270015 + * @summary Light weight HTTP server + * @library /test/lib + * @build jdk.test.lib.Asserts + * jdk.test.lib.Utils + * jdk.test.lib.net.SimpleSSLContext + * jdk.test.lib.net.URIBuilder + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ public class Test13 extends Test { private static final String TEMP_FILE_PREFIX = @@ -61,20 +62,25 @@ public class Test13 extends Test { private static final SSLContext ctx = SimpleSSLContext.findSSLContext(); + private static final Logger logger = Logger.getLogger ("com.sun.net.httpserver"); + final static int NUM = 32; // was 32 static boolean fail = false; + private static void setupLogging() { + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.ALL); + logger.setLevel(Level.ALL); + logger.addHandler(handler); + } + public static void main (String[] args) throws Exception { HttpServer s1 = null; HttpsServer s2 = null; ExecutorService executor=null; Path filePath = createTempFileOfSize(TEMP_FILE_PREFIX, null, 23); - Logger l = Logger.getLogger ("com.sun.net.httpserver"); - Handler ha = new ConsoleHandler(); - ha.setLevel(Level.ALL); - l.setLevel(Level.ALL); - l.addHandler(ha); + setupLogging(); // merely for debugging InetAddress loopback = InetAddress.getLoopbackAddress(); try { System.out.print ("Test13: "); diff --git a/test/jdk/com/sun/net/httpserver/Test7a.java b/test/jdk/com/sun/net/httpserver/Test7a.java index 8bda4ae8348..832238b2b47 100644 --- a/test/jdk/com/sun/net/httpserver/Test7a.java +++ b/test/jdk/com/sun/net/httpserver/Test7a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,16 +21,6 @@ * questions. */ -/** - * @test - * @bug 6270015 - * @library /test/lib - * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder - * @run main/othervm Test7a - * @run main/othervm -Djava.net.preferIPv6Addresses=true Test7a - * @summary Light weight HTTP server - */ - import com.sun.net.httpserver.*; import java.util.concurrent.*; @@ -44,15 +34,18 @@ import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; /** * Test POST large file via chunked encoding (large chunks) */ - +/* + * @test + * @bug 6270015 + * @summary Light weight HTTP server + * @library /test/lib + * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ public class Test7a extends Test { public static void main (String[] args) throws Exception { - //Logger log = Logger.getLogger ("com.sun.net.httpserver"); - //log.setLevel (Level.FINE); - //ConsoleHandler h = new ConsoleHandler(); - //h.setLevel (Level.ALL); - //log.addHandler (h); Handler handler = new Handler(); InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); diff --git a/test/jdk/com/sun/net/httpserver/Test8a.java b/test/jdk/com/sun/net/httpserver/Test8a.java index 67f9c93172a..9d1525352cf 100644 --- a/test/jdk/com/sun/net/httpserver/Test8a.java +++ b/test/jdk/com/sun/net/httpserver/Test8a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,15 +21,6 @@ * questions. */ -/** - * @test - * @bug 6270015 - * @library /test/lib - * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder - * @run main/othervm Test8a - * @run main/othervm -Djava.net.preferIPv6Addresses=true Test8a - * @summary Light weight HTTP server - */ import com.sun.net.httpserver.*; @@ -43,15 +34,18 @@ import jdk.test.lib.net.URIBuilder; /** * Test POST large file via fixed len encoding */ - +/* + * @test + * @bug 6270015 + * @summary Light weight HTTP server + * @library /test/lib + * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ public class Test8a extends Test { public static void main (String[] args) throws Exception { - //Logger log = Logger.getLogger ("com.sun.net.httpserver"); - //ConsoleHandler h = new ConsoleHandler(); - //h.setLevel (Level.INFO); - //log.addHandler (h); - //log.setLevel (Level.INFO); HttpsServer server = null; ExecutorService executor = null; try { diff --git a/test/jdk/com/sun/net/httpserver/TestLogging.java b/test/jdk/com/sun/net/httpserver/TestLogging.java index 8f4fbddcd42..3f201f90dd2 100644 --- a/test/jdk/com/sun/net/httpserver/TestLogging.java +++ b/test/jdk/com/sun/net/httpserver/TestLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2026, 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,16 +21,6 @@ * questions. */ -/* - * @test - * @bug 6422914 - * @library /test/lib - * @build jdk.test.lib.Utils - * jdk.test.lib.net.URIBuilder - * @summary change httpserver exception printouts - * @run main TestLogging - * @run main/othervm -Djava.net.preferIPv6Addresses=true TestLogging - */ import com.sun.net.httpserver.*; @@ -45,27 +35,44 @@ import jdk.test.lib.net.URIBuilder; import static jdk.test.lib.Utils.createTempFileOfSize; +/* + * @test + * @bug 6422914 + * @summary change httpserver exception printouts + * @library /test/lib + * @build jdk.test.lib.Utils + * jdk.test.lib.net.URIBuilder + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ public class TestLogging extends Test { private static final String TEMP_FILE_PREFIX = HttpServer.class.getPackageName() + '-' + TestLogging.class.getSimpleName() + '-'; + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + + private static void setupLogging() { + logger.setLevel(Level.ALL); + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.ALL); + logger.addHandler(handler); + } + public static void main (String[] args) throws Exception { HttpServer s1 = null; ExecutorService executor=null; Path filePath = createTempFileOfSize(TEMP_FILE_PREFIX, null, 0xBEEF); try { System.out.print ("Test9: "); + setupLogging(); String root = filePath.getParent().toString(); InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); - Logger logger = Logger.getLogger ("com.sun.net.httpserver"); - logger.setLevel (Level.ALL); - Handler h1 = new ConsoleHandler (); - h1.setLevel (Level.ALL); - logger.addHandler (h1); s1 = HttpServer.create (addr, 0); - logger.info (root); + logger.info(root); HttpHandler h = new FileServerHandler (root); HttpContext c1 = s1.createContext ("/", h); executor = Executors.newCachedThreadPool(); diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6886436.java b/test/jdk/com/sun/net/httpserver/bugs/B6886436.java index 5081a81c4c1..c52bbcbdfce 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6886436.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6886436.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,15 +21,6 @@ * questions. */ -/** - * @test - * @bug 6886436 - * @summary HttpServer should not send a body with 204 response. - * @library /test/lib - * @run main B6886436 - * @run main/othervm -Djava.net.preferIPv6Addresses=true B6886436 - */ - import com.sun.net.httpserver.*; import java.util.*; @@ -40,14 +31,29 @@ import java.net.*; import jdk.test.lib.net.URIBuilder; import static com.sun.net.httpserver.HttpExchange.RSPBODY_CHUNKED; +/* + * @test + * @bug 6886436 + * @summary HttpServer should not send a body with 204 response. + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ public class B6886436 { + private static final Logger logger = Logger.getLogger ("com.sun.net.httpserver"); + + private static void setupLogging() { + final ConsoleHandler c = new ConsoleHandler(); + c.setLevel(Level.WARNING); + logger.addHandler(c); + logger.setLevel(Level.WARNING); + } + public static void main (String[] args) throws Exception { - Logger logger = Logger.getLogger ("com.sun.net.httpserver"); - ConsoleHandler c = new ConsoleHandler(); - c.setLevel (Level.WARNING); - logger.addHandler (c); - logger.setLevel (Level.WARNING); + setupLogging(); // merely for debugging Handler handler = new Handler(); InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress (loopback, 0); diff --git a/test/jdk/com/sun/net/httpserver/bugs/B8211420.java b/test/jdk/com/sun/net/httpserver/bugs/B8211420.java index 297aed43bec..d7257ddc755 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B8211420.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B8211420.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,15 +21,6 @@ * questions. */ -/** - * @test - * @bug 8211420 - * @library /test/lib - * @run main/othervm B8211420 - * @run main/othervm -Djava.net.preferIPv6Addresses=true B8211420 - * @summary - */ - import com.sun.net.httpserver.*; import java.util.*; @@ -41,14 +32,29 @@ import java.net.*; import jdk.test.lib.net.URIBuilder; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; +/* + * @test + * @bug 8211420 + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + * @summary + */ public class B8211420 { - public static void main(String[] args) throws Exception { - Logger logger = Logger.getLogger("com.sun.net.httpserver"); - ConsoleHandler c = new ConsoleHandler(); + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + + private static void setupLogging() { + final ConsoleHandler c = new ConsoleHandler(); c.setLevel(Level.WARNING); logger.addHandler(c); logger.setLevel(Level.WARNING); + } + + public static void main(String[] args) throws Exception { + setupLogging(); // merely for debugging Handler handler = new Handler(); InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); diff --git a/test/jdk/com/sun/net/httpserver/bugs/ExceptionKeepAlive.java b/test/jdk/com/sun/net/httpserver/bugs/ExceptionKeepAlive.java index 865e3b7509d..eba6aa67a8f 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/ExceptionKeepAlive.java +++ b/test/jdk/com/sun/net/httpserver/bugs/ExceptionKeepAlive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,15 +21,6 @@ * questions. */ -/** - * @test - * @bug 8219083 - * @summary Exceptions thrown from HttpHandler.handle should not close connection - * if response is completed - * @library /test/lib - * @run junit ExceptionKeepAlive - */ - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; @@ -42,20 +33,35 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; +import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; -import java.util.logging.StreamHandler; import static org.junit.jupiter.api.Assertions.*; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; -public class ExceptionKeepAlive -{ +/* + * @test + * @bug 8219083 + * @summary Exceptions thrown from HttpHandler.handle should not close connection + * if response is completed + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run junit/othervm ${test.main.class} + */ +public class ExceptionKeepAlive { public static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); + private static void setupLogging() { + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.FINEST); + LOGGER.setLevel(Level.FINEST); + LOGGER.addHandler(handler); + } + @Test void test() throws IOException, InterruptedException { HttpServer httpServer = startHttpServer(); @@ -89,11 +95,7 @@ public class ExceptionKeepAlive * Http Server */ HttpServer startHttpServer() throws IOException { - Handler outHandler = new StreamHandler(System.out, - new SimpleFormatter()); - outHandler.setLevel(Level.FINEST); - LOGGER.setLevel(Level.FINEST); - LOGGER.addHandler(outHandler); + setupLogging(); // merely for debugging InetAddress loopback = InetAddress.getLoopbackAddress(); HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0); httpServer.createContext("/", new MyHandler()); diff --git a/test/jdk/com/sun/net/httpserver/bugs/FixedLengthInputStream.java b/test/jdk/com/sun/net/httpserver/bugs/FixedLengthInputStream.java index c2195b3568f..c4287f50c9a 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/FixedLengthInputStream.java +++ b/test/jdk/com/sun/net/httpserver/bugs/FixedLengthInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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,25 +21,14 @@ * questions. */ -/** - * @test - * @bug 6756771 6755625 - * @summary com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig - * @library /test/lib - * @run main FixedLengthInputStream - * @run main/othervm -Djava.net.preferIPv6Addresses=true FixedLengthInputStream - */ - import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; -import java.io.PrintStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.HttpURLConnection; import java.net.Proxy; import java.net.URL; -import java.net.Socket; import java.util.logging.*; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; @@ -47,10 +36,21 @@ import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.URIBuilder; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; -public class FixedLengthInputStream -{ +/* + * @test + * @bug 6756771 6755625 + * @summary com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + * @run main/othervm -Djava.net.preferIPv6Addresses=true ${test.main.class} + */ +public class FixedLengthInputStream { static final long POST_SIZE = 4L * 1024L * 1024L * 1024L; // 4Gig + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + void test(String[] args) throws IOException { HttpServer httpServer = startHttpServer(); int port = httpServer.getAddress().getPort(); @@ -89,18 +89,19 @@ public class FixedLengthInputStream } } + private static void setupLogging() { + final ConsoleHandler handler = new ConsoleHandler(); + handler.setLevel(Level.FINEST); + logger.setLevel(Level.FINEST); + logger.addHandler(handler); + } + /** * Http Server */ HttpServer startHttpServer() throws IOException { if (debug) { - Logger logger = - Logger.getLogger("com.sun.net.httpserver"); - Handler outHandler = new StreamHandler(System.out, - new SimpleFormatter()); - outHandler.setLevel(Level.FINEST); - logger.setLevel(Level.FINEST); - logger.addHandler(outHandler); + setupLogging(); // merely for debugging } InetAddress loopback = InetAddress.getLoopbackAddress(); HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0); diff --git a/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java b/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java index 372e941904e..215a189c7bf 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java +++ b/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,15 +21,6 @@ * questions. */ -/** - * @test - * @bug 8218554 - * @summary test that the handler can request a connection close. - * @library /test/lib - * @build jdk.test.lib.net.SimpleSSLContext - * @run main/othervm HandlerConnectionClose - */ - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; @@ -49,22 +40,30 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Locale; +import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; -import java.util.logging.StreamHandler; import jdk.test.lib.net.SimpleSSLContext; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; -public class HandlerConnectionClose -{ +/* + * @test + * @bug 8218554 + * @summary test that the handler can request a connection close. + * @library /test/lib + * @build jdk.test.lib.net.SimpleSSLContext + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + */ +public class HandlerConnectionClose { static final int ONEK = 1024; static final long POST_SIZE = ONEK * 1L; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - Logger logger; + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); void test(String[] args) throws Exception { @@ -341,17 +340,20 @@ public class HandlerConnectionClose } } + private static void setupLogging() { + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.FINEST); + logger.setLevel(Level.FINEST); + logger.addHandler(handler); + + } + /** * Http Server */ HttpServer startHttpServer(String protocol) throws IOException { if (debug) { - logger = Logger.getLogger("com.sun.net.httpserver"); - Handler outHandler = new StreamHandler(System.out, - new SimpleFormatter()); - outHandler.setLevel(Level.FINEST); - logger.setLevel(Level.FINEST); - logger.addHandler(outHandler); + setupLogging(); // merely for debugging } InetSocketAddress serverAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); diff --git a/test/jdk/com/sun/net/httpserver/bugs/HeadKeepAlive.java b/test/jdk/com/sun/net/httpserver/bugs/HeadKeepAlive.java index 4d987ada173..c575fdfc810 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/HeadKeepAlive.java +++ b/test/jdk/com/sun/net/httpserver/bugs/HeadKeepAlive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,14 +21,6 @@ * questions. */ -/** - * @test - * @bug 8304963 - * @summary Connection should be reusable after HEAD request - * @library /test/lib - * @run junit HeadKeepAlive - */ - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; @@ -41,19 +33,33 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; +import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; -import java.util.logging.StreamHandler; import static org.junit.jupiter.api.Assertions.*; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; -public class HeadKeepAlive -{ +/* + * @test + * @bug 8304963 + * @summary Connection should be reusable after HEAD request + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run junit/othervm ${test.main.class} + */ +public class HeadKeepAlive { - public static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); + private static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); + + private static void setupLogging() { + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.FINEST); + LOGGER.setLevel(Level.FINEST); + LOGGER.addHandler(handler); + } @Test void test() throws IOException, InterruptedException { @@ -90,11 +96,7 @@ public class HeadKeepAlive * Http Server */ HttpServer startHttpServer() throws IOException { - Handler outHandler = new StreamHandler(System.out, - new SimpleFormatter()); - outHandler.setLevel(Level.FINEST); - LOGGER.setLevel(Level.FINEST); - LOGGER.addHandler(outHandler); + setupLogging(); // merely for debugging InetAddress loopback = InetAddress.getLoopbackAddress(); HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0); httpServer.createContext("/", new MyHandler()); diff --git a/test/jdk/com/sun/net/httpserver/bugs/TruncatedRequestBody.java b/test/jdk/com/sun/net/httpserver/bugs/TruncatedRequestBody.java index 824428755a4..95a3d1787df 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/TruncatedRequestBody.java +++ b/test/jdk/com/sun/net/httpserver/bugs/TruncatedRequestBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,11 +21,6 @@ * questions. */ -/** - * @test - * @bug 8190793 - * @summary Httpserver does not detect truncated request body - */ import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; @@ -46,12 +41,23 @@ import java.util.logging.Level; import java.util.logging.Logger; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; +/* + * @test + * @bug 8190793 + * @summary Httpserver does not detect truncated request body + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run main/othervm ${test.main.class} + */ /* * Send two POST requests to the server which are both trucated * and socket closed. Server needs to detect this and throw an IOException * in getRequestBody().read(). Two variants for fixed length and chunked. */ public class TruncatedRequestBody { + + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + static volatile boolean error = false; static CountDownLatch latch = new CountDownLatch(2); @@ -81,16 +87,18 @@ public class TruncatedRequestBody { } + private static void setupLogging() { + final ConsoleHandler h = new ConsoleHandler(); + h.setLevel(Level.ALL); + logger.setLevel(Level.ALL); + logger.addHandler(h); + } + /** * @param args the command line arguments */ public static void main(String[] args) throws IOException, InterruptedException { - Logger logger = Logger.getLogger("com.sun.net.httpserver"); - ConsoleHandler h = new ConsoleHandler(); - h.setLevel(Level.ALL); - logger.setLevel(Level.ALL); - logger.addHandler(h); - + setupLogging(); // merely for debugging InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); HttpServer server = HttpServer.create(addr, 10); diff --git a/test/jdk/com/sun/net/httpserver/bugs/ZeroLengthOutputStream.java b/test/jdk/com/sun/net/httpserver/bugs/ZeroLengthOutputStream.java index 33bbe0479db..0715800ead7 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/ZeroLengthOutputStream.java +++ b/test/jdk/com/sun/net/httpserver/bugs/ZeroLengthOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,14 +21,6 @@ * questions. */ -/** - * @test - * @bug 8219083 - * @summary HttpExchange.getResponseBody write and close should not throw - * even when response length is zero - * @library /test/lib - * @run junit ZeroLengthOutputStream - */ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; @@ -44,19 +36,27 @@ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; import java.util.concurrent.CountDownLatch; +import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; -import java.util.logging.StreamHandler; import static org.junit.jupiter.api.Assertions.*; import static com.sun.net.httpserver.HttpExchange.RSPBODY_EMPTY; -public class ZeroLengthOutputStream -{ +/* + * @test + * @bug 8219083 + * @summary HttpExchange.getResponseBody write and close should not throw + * even when response length is zero + * @library /test/lib + * @comment We use othervm because this test configures logging handlers + * for the system wide "com.sun.net.httpserver" logger + * @run junit/othervm ${test.main.class} + */ +public class ZeroLengthOutputStream { - public static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); + private static final Logger LOGGER = Logger.getLogger("com.sun.net.httpserver"); public volatile boolean closed; public CountDownLatch cdl = new CountDownLatch(1); @@ -80,15 +80,18 @@ public class ZeroLengthOutputStream } } + private static void setupLogging() { + final Handler handler = new ConsoleHandler(); + handler.setLevel(Level.FINEST); + LOGGER.setLevel(Level.FINEST); + LOGGER.addHandler(handler); + } + /** * Http Server */ HttpServer startHttpServer() throws IOException { - Handler outHandler = new StreamHandler(System.out, - new SimpleFormatter()); - outHandler.setLevel(Level.FINEST); - LOGGER.setLevel(Level.FINEST); - LOGGER.addHandler(outHandler); + setupLogging(); // merely for debugging InetAddress loopback = InetAddress.getLoopbackAddress(); HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0); httpServer.createContext("/flis/", new MyHandler()); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java index ff5ca00846c..a1eb2233b02 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java index 5d62b88f23e..bf5872b06d3 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java index 320e556f800..67a946c15d0 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 6863110 + * @requires (os.family == "linux") * @library /test/lib * @summary Newly connected/accepted SctpChannel should fire OP_READ if registered with a Selector * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java index 79b9453a595..699ef3d0971 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java index 48eb413a9ca..896c339dcc0 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java index 48d89c34ca4..1c52f83b972 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,6 +23,7 @@ /* @test * @bug 8034181 + * @requires (os.family == "linux") * @library /test/lib * @summary SIGBUS in SctpChannelImpl receive * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java index 35a28f4eb38..a04205a9463 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java index 0891851fe86..75f0fa9a724 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java index 857efbb63f5..2e6192a0d0e 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java index 9beb8c74c3e..199cbfc0fc1 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java index fdafec80745..f6fffe700c5 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java index 8fb551dd8f4..6f1b05e9db9 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java index a64d4d58270..85db90279c0 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,6 +23,7 @@ /* @test * @bug 8067846 + * @requires (os.family == "linux") * @library /test/lib * @summary Test for send failed notification */ diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java index 3a681884b9a..5d782fcd4e7 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java index c68bfd28945..84c010aaaf0 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java index abf35bf779d..3c358e0a86d 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,6 +23,7 @@ /* @test * @bug 4927640 + * @requires (os.family == "linux") * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar diff --git a/test/jdk/java/awt/Clipboard/FlavorChangeNotificationTest/SystemClipboardTest.java b/test/jdk/java/awt/Clipboard/FlavorChangeNotificationTest/SystemClipboardTest.java deleted file mode 100644 index ff19005b8aa..00000000000 --- a/test/jdk/java/awt/Clipboard/FlavorChangeNotificationTest/SystemClipboardTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2003, 2023, 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 4259272 - @summary tests that notifications on changes to the set of DataFlavors - available on the system clipboard are delivered properly - @key headful - @modules java.desktop/sun.awt - @build Common - @run main SystemClipboardTest -*/ - -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; - -import sun.awt.SunToolkit; - -public class SystemClipboardTest { - - private final Clipboard clipboard = - Toolkit.getDefaultToolkit().getSystemClipboard(); - - private final FlavorListenerImpl listener1 = new FlavorListenerImpl(); - - private final FlavorListenerImpl listener2 = new FlavorListenerImpl(); - - private boolean isListener2Added; - - - public static void main(String[] args) { - new SystemClipboardTest().start(); - } - - public void start() { - Util.setClipboardContents(clipboard, - new StringSelection("text3"), null); - - clipboard.addFlavorListener(listener1); - - final ThreadGroup threadGroup = new ThreadGroup("Test thread group"); - final Object lock = new Object(); - final Runnable runnable = new Runnable() { - public void run() { - SunToolkit.createNewAppContext(); - clipboard.addFlavorListener(listener2); - synchronized (lock) { - isListener2Added = true; - lock.notifyAll(); - } - } - }; - final Thread thread = new Thread(threadGroup, runnable, "Test thread"); - synchronized (lock) { - thread.start(); - while (!isListener2Added) { - try { - lock.wait(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - } - - Util.setClipboardContents(clipboard, - new TransferableUnion(new StringSelection("text2"), - new ImageSelection(Util.createImage())), - null); - Util.sleep(3000); - - clipboard.removeFlavorListener(listener1); - // must not remove listener2 from this AppContext - - Util.setClipboardContents(clipboard, - new StringSelection("text3"), null); - Util.sleep(3000); - - System.err.println("listener1: " + listener1 - + "\nlistener2: " + listener2); - - if (!(listener1.notified1 - && listener2.notified1 - && !listener1.notified2 - && listener2.notified2)) { - throw new RuntimeException("notifications about flavor " + - "changes delivered incorrectly!"); - } - } -} \ No newline at end of file diff --git a/test/jdk/java/awt/ColorClass/ColorARGBConstructorTest.java b/test/jdk/java/awt/ColorClass/ColorARGBConstructorTest.java new file mode 100644 index 00000000000..3464e2057b9 --- /dev/null +++ b/test/jdk/java/awt/ColorClass/ColorARGBConstructorTest.java @@ -0,0 +1,66 @@ +/* + * Copyright Amazon.com Inc. 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.awt.Color; + +/** + * @test + * @bug 6434110 + * @summary Verify Color(int, boolean) constructor uses ARGB bit layout + */ +public final class ColorARGBConstructorTest { + + public static void main(String[] args) { + for (int argb : new int[]{0x00000000, 0x01020304, 0xC0903020, + 0x40302010, 0xD08040C0, 0x80000000, + 0x7FFFFFFF, 0xFFFFFFFF, 0xFF000000, + 0x00FF0000, 0x0000FF00, 0x000000FF}) + { + verify(argb, true); + verify(argb, false); + } + } + + private static void verify(int argb, boolean hasAlpha) { + var c = new Color(argb, hasAlpha); + int expRGB = hasAlpha ? argb : (0xFF000000 | argb); + int expA = hasAlpha ? (argb >>> 24) : 0xFF; + int expR = (argb >> 16) & 0xFF; + int expG = (argb >> 8) & 0xFF; + int expB = argb & 0xFF; + check("RGB", expRGB, c.getRGB(), argb, hasAlpha); + check("Alpha", expA, c.getAlpha(), argb, hasAlpha); + check("Red", expR, c.getRed(), argb, hasAlpha); + check("Green", expG, c.getGreen(), argb, hasAlpha); + check("Blue", expB, c.getBlue(), argb, hasAlpha); + } + + private static void check(String comp, int exp, int got, int argb, + boolean hasAlpha) + { + if (exp != got) { + throw new RuntimeException("0x%08X(%b) %s: 0x%08X != 0x%08X" + .formatted(argb, hasAlpha, comp, exp, got)); + } + } +} diff --git a/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java b/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java deleted file mode 100644 index 1201e5c835c..00000000000 --- a/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2014, 2025, 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.awt.Dialog; -import java.awt.Frame; -import java.io.*; -import javax.swing.*; -import sun.awt.SunToolkit; -import java.util.concurrent.atomic.AtomicReference; - -/** - * @test - * @key headful - * @bug 8043705 - * @summary Can't exit color chooser dialog when running in non-default AppContext - * @modules java.desktop/sun.awt - * @run main CloseDialogTest - */ - -public class CloseDialogTest { - - private static volatile Frame frame; - private static volatile Dialog dialog; - private static volatile InputStream testErrorStream; - private static final PrintStream systemErrStream = System.err; - private static final AtomicReference caughtException - = new AtomicReference<>(); - - public static void main(String[] args) throws Exception { - - // redirect System err - PipedOutputStream errorOutputStream = new PipedOutputStream(); - testErrorStream = new PipedInputStream(errorOutputStream); - System.setErr(new PrintStream(errorOutputStream)); - - ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG"); - try { - new Thread(swingTG, () -> { - SunToolkit.createNewAppContext(); - SwingUtilities.invokeLater(() -> { - frame = new Frame(); - frame.setSize(300, 300); - frame.setVisible(true); - - dialog = new Dialog(frame); - dialog.setSize(200, 200); - dialog.setModal(true); - dialog.setVisible(true); - }); - }).start(); - - Thread.sleep(400); - - Thread disposeThread = new Thread(swingTG, () -> - SwingUtilities.invokeLater(() -> { - try { - while (dialog == null || !dialog.isVisible()) { - Thread.sleep(100); - } - dialog.setVisible(false); - dialog.dispose(); - frame.dispose(); - } catch (Exception e) { - caughtException.set(e); - } - })); - disposeThread.start(); - disposeThread.join(); - Thread.sleep(500); - - // read System err - final char[] buffer = new char[2048]; - System.err.print("END"); - System.setErr(systemErrStream); - try (Reader in = new InputStreamReader(testErrorStream, "UTF-8")) { - int size = in.read(buffer, 0, buffer.length); - String errorString = new String(buffer, 0, size); - if (!errorString.startsWith("END")) { - System.err.println(errorString. - substring(0, errorString.length() - 4)); - throw new RuntimeException("Error output is not empty!"); - } - } - } finally { - if (caughtException.get() != null) { - throw new RuntimeException("Failed. Caught exception!", - caughtException.get()); - } - } - } - - private static ThreadGroup getRootThreadGroup() { - ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); - while (threadGroup.getParent() != null) { - threadGroup = threadGroup.getParent(); - } - return threadGroup; - } -} diff --git a/test/jdk/java/awt/Focus/NullActiveWindowOnFocusLost/NullActiveWindowOnFocusLost.java b/test/jdk/java/awt/Focus/NullActiveWindowOnFocusLost/NullActiveWindowOnFocusLost.java deleted file mode 100644 index 0924413bec4..00000000000 --- a/test/jdk/java/awt/Focus/NullActiveWindowOnFocusLost/NullActiveWindowOnFocusLost.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018, 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. - * - * 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.awt.Button; -import java.awt.Frame; -import java.util.concurrent.TimeUnit; - -import sun.awt.SunToolkit; - -/** - * @test - * @key headful - * @bug 8211435 - * @modules java.desktop/sun.awt - */ -public final class NullActiveWindowOnFocusLost { - - private static volatile long endtime; - private static Throwable failed; - - public static void main(final String[] args) throws Exception { - // Will run the test no more than 30 seconds - endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); - Thread.setDefaultUncaughtExceptionHandler((t, e) -> failed = e); - - final Thread[] threads = new Thread[20]; - for (int i = 0; i < threads.length; i++) { - threads[i] = testThread(i); - } - for (final Thread thread : threads) { - thread.start(); - } - for (final Thread thread : threads) { - thread.join(); - } - if (failed != null) { - failed.printStackTrace(); - throw new RuntimeException(failed); - } - } - - private static Thread testThread(int index) { - return new Thread(new ThreadGroup("TG " + index), () -> { - SunToolkit.createNewAppContext(); - while (!isComplete()) { - final Frame frame = new Frame(); - frame.setSize(300, 300); - frame.add(new Button("Button")); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - try { - Thread.sleep(index); // increase probability of the failure - } catch (InterruptedException ignored) { - } - frame.dispose(); - } - }); - } - - private static boolean isComplete() { - return endtime - System.nanoTime() < 0 || failed != null; - } -} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java b/test/jdk/java/awt/PrintJob/TestPrintNoException.java similarity index 52% rename from test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java rename to test/jdk/java/awt/PrintJob/TestPrintNoException.java index 7cad887a5d9..b54ac8de56b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java +++ b/test/jdk/java/awt/PrintJob/TestPrintNoException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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,29 +19,43 @@ * 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.awt.Frame; +import java.awt.JobAttributes; +import java.awt.PrintJob; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; + /* * @test - * @summary Exercise GC with shared strings - * @requires vm.cds.write.mapped.java.heap - * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib - * @build HelloStringGC jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver ExerciseGC + * @bug 8378417 + * @key headful printer + * @summary Verifies No Exception is thrown when Printing "All" pages + * @run main TestPrintNoException */ -public class ExerciseGC { + +public class TestPrintNoException { + public static void main(String[] args) throws Exception { - SharedStringsUtils.run(args, ExerciseGC::test); - } - public static void test(String[] args) throws Exception { - SharedStringsUtils.buildJarAndWhiteBox("HelloStringGC"); + Robot robot = new Robot(); + Thread t = new Thread (() -> { + robot.delay(5000); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + }); - SharedStringsUtils.dumpWithWhiteBox(TestCommon.list("HelloStringGC"), - "SharedStringsBasic.txt", "-Xlog:cds,aot+hashtables"); - - SharedStringsUtils.runWithArchiveAndWhiteBox("HelloStringGC", - "-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyBeforeGC"); + Frame testFrame = new Frame("print"); + try { + t.start(); + PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(testFrame, null, null); + if (pj != null) { + pj.end(); + } + } finally { + testFrame.dispose(); + } } } diff --git a/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java b/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java index 1f2de081cce..c0a9c90feba 100644 --- a/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java +++ b/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,30 +22,25 @@ */ import java.awt.Color; -import java.awt.Dialog; import java.awt.Frame; import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; -import java.awt.Panel; import java.awt.Rectangle; import java.awt.Robot; import java.awt.SplashScreen; import java.awt.TextField; -import java.awt.Window; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.io.File; +import java.io.IOException; + import javax.imageio.ImageIO; -import sun.java2d.SunGraphics2D; - -/** +/* * @test * @key headful * @bug 8043869 8075244 8078082 8145173 8151787 8212213 * @summary Tests the HiDPI splash screen support for windows and MAC - * @modules java.desktop/sun.java2d * @run main MultiResolutionSplashTest GENERATE_IMAGES * @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_SPLASH 0 * @run main/othervm -splash:splash2 MultiResolutionSplashTest TEST_SPLASH 1 @@ -56,47 +51,54 @@ public class MultiResolutionSplashTest { private static final int IMAGE_WIDTH = 300; private static final int IMAGE_HEIGHT = 200; - private static boolean isMac; - static { - isMac = System.getProperty("os.name").contains("OS X"); - } + private static final boolean isMac = System.getProperty("os.name") + .contains("OS X"); + private static final ImageInfo[] tests = { - new ImageInfo("splash1.png", "splash1@2x.png", Color.BLUE, Color.GREEN), - new ImageInfo("splash2", "splash2@2x", Color.WHITE, Color.BLACK), - new ImageInfo("splash3.", "splash3@2x.", Color.YELLOW, Color.RED) + new ImageInfo("splash1", ".png", Color.BLUE, Color.GREEN), + new ImageInfo("splash2", "", Color.WHITE, Color.BLACK), + new ImageInfo("splash3", ".", Color.YELLOW, Color.RED) }; public static void main(String[] args) throws Exception { - - String test = args[0]; - switch (test) { + switch (args[0]) { case "GENERATE_IMAGES": generateImages(); break; case "TEST_SPLASH": - int index = Integer.parseInt(args[1]); - testSplash(tests[index]); + testSplash(tests[Integer.parseInt(args[1])]); break; case "TEST_FOCUS": testFocus(); break; default: - throw new RuntimeException("Unknown test: " + test); + throw new RuntimeException("Unknown test: " + args[0]); } } static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); - if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } - Graphics2D g = splashScreen.createGraphics(); - Rectangle splashBounds = splashScreen.getBounds(); - int screenX = (int) splashBounds.getCenterX(); - int screenY = (int) splashBounds.getCenterY(); + final Rectangle splashBounds = splashScreen.getBounds(); + final double scaleFactor = getScreenScaleFactor(); + + final Robot robot = new Robot(); + // Allow time for the splash screen to show + robot.delay(100); + + BufferedImage splashCapture = robot.createScreenCapture(splashBounds); + String captureFileName = "splashscreen-%1.2f-%s.png" + .formatted(scaleFactor, test.name1x); + saveImageNoError(splashCapture, new File(captureFileName)); + + // Close the splash screen; this gives time for it to be fully removed + splashScreen.close(); + robot.waitForIdle(); + if (splashBounds.width != IMAGE_WIDTH) { throw new RuntimeException( "SplashScreen#getBounds has wrong width"); @@ -106,19 +108,19 @@ public class MultiResolutionSplashTest { "SplashScreen#getBounds has wrong height"); } - Robot robot = new Robot(); - Color splashScreenColor = robot.getPixelColor(screenX, screenY); - float scaleFactor = getScaleFactor(); + Color splashScreenColor = + new Color(splashCapture.getRGB(splashBounds.width / 2, + splashBounds.height / 2)); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( - "Image with wrong resolution is used for splash screen!"); + "Image with wrong resolution is used for splash screen! " + + "Refer to " + captureFileName); } } static void testFocus() throws Exception { - Robot robot = new Robot(); robot.setAutoWaitForIdle(true); robot.setAutoDelay(50); @@ -157,94 +159,85 @@ public class MultiResolutionSplashTest { return Math.abs(n - m) <= 50; } - static float getScaleFactor() { - - final Dialog dialog = new Dialog((Window) null); - dialog.setSize(100, 100); - dialog.setModal(true); - final float[] scaleFactors = new float[1]; - Panel panel = new Panel() { - - @Override - public void paint(Graphics g) { - float scaleFactor = 1; - if (g instanceof SunGraphics2D) { - scaleFactor = getScreenScaleFactor(); - } - scaleFactors[0] = scaleFactor; - dialog.setVisible(false); - } - }; - - dialog.add(panel); - dialog.setVisible(true); - dialog.dispose(); - - return scaleFactors[0]; - } - static void generateImages() throws Exception { for (ImageInfo test : tests) { - generateImage(test.name1x, test.color1x, 1); - generateImage(test.name2x, test.color2x, getScreenScaleFactor()); + generateImage(test.name1x, test.color1x, 1.0); + + // Ensure the second image uses scale greater than 1.0 + double scale = getAdjustedScaleFactor(); + generateImage(test.name2x, test.color2x, scale); } } - static void generateImage(String name, Color color, float scale) throws Exception { + static void generateImage(final String name, + final Color color, + final double scale) throws Exception { File file = new File(name); if (file.exists()) { return; } - BufferedImage image = new BufferedImage((int) (scale * IMAGE_WIDTH), - (int) (scale * IMAGE_HEIGHT), BufferedImage.TYPE_INT_RGB); + + final int width = (int) (scale * IMAGE_WIDTH); + final int height = (int) (scale * IMAGE_HEIGHT); + BufferedImage image = new BufferedImage(width, + height, + BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(color); - g.fillRect(0, 0, (int) (scale * IMAGE_WIDTH), (int) (scale * IMAGE_HEIGHT)); + g.fillRect(0, 0, width, height); + + saveImage(image, file); + } + + private static void saveImage(BufferedImage image, + File file) throws IOException { ImageIO.write(image, "png", file); } - static float getScreenScaleFactor() { - return (float) GraphicsEnvironment. - getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(). - getDefaultTransform().getScaleX(); + private static void saveImageNoError(BufferedImage image, + File file) { + try { + saveImage(image, file); + } catch (IOException ignored) { + } + } + + static double getScreenScaleFactor() { + return GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .getDefaultConfiguration() + .getDefaultTransform() + .getScaleX(); + } + + // Ensure the second image uses scale greater than 1.0 + static double getAdjustedScaleFactor() { + double scale = getScreenScaleFactor(); + return scale < 1.25 ? 2.0 : scale; } static class ImageInfo { - final String name1x; final String name2x; final Color color1x; final Color color2x; - public ImageInfo(String name1x, String name2x, Color color1x, Color color2x) { - this.name1x = name1x; - if (!isMac) { - float scale = getScreenScaleFactor(); - StringBuffer buff = new StringBuffer(); - if (scale - (int) scale > 0) { - buff.append("@").append((int) (scale * 100)).append("pct"); - } else { - buff.append("@").append((int) scale).append("x"); - } - StringBuffer buffer = new StringBuffer(); - String[] splitStr = name1x.split("\\."); - if (splitStr.length == 2) { - this.name2x = buffer.append(splitStr[0]).append(buff) - .append(".").append(splitStr[1]).toString(); - } else { - if (name1x.indexOf(".") > 0) { - this.name2x = buffer.append(splitStr[0]).append(buff).append(".").toString(); - } else { - this.name2x = buffer.append(splitStr[0]).append(buff).toString(); - } - } - } else { - this.name2x = name2x; - } + public ImageInfo(String baseName, String ext, + Color color1x, Color color2x) { + this.name1x = baseName + ext; + this.name2x = createName2x(baseName, ext); this.color1x = color1x; this.color2x = color2x; } + + private static String createName2x(String baseName, String ext) { + double scale = getAdjustedScaleFactor(); + if (!isMac && (((int) (scale * 100)) % 100 != 0)) { + return baseName + "@" + ((int) (scale * 100)) + "pct" + ext; + } else { + return baseName + "@" + ((int) scale) + "x" + ext; + } + } } } - diff --git a/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java b/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java index 9d3e6d85637..b2352dc04ff 100644 --- a/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java +++ b/test/jdk/java/awt/TextComponent/CorrectTextComponentSelectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,9 +23,9 @@ /* * @test + * @key headful * @bug 5100806 * @summary TextArea.select(0,0) does not de-select the selected text properly - * @key headful * @run main CorrectTextComponentSelectionTest */ @@ -38,7 +38,6 @@ import java.awt.Robot; import java.awt.TextArea; import java.awt.TextComponent; import java.awt.TextField; -import java.lang.reflect.InvocationTargetException; public class CorrectTextComponentSelectionTest { static TextField tf = new TextField("TextField"); @@ -46,14 +45,11 @@ public class CorrectTextComponentSelectionTest { static Robot r; static Frame frame; static volatile Color color_center; - static volatile Point loc; public static void main(String[] args) throws Exception { try { r = new Robot(); - EventQueue.invokeAndWait(() -> { - initialize(); - }); + EventQueue.invokeAndWait(() -> initialize()); r.waitForIdle(); r.delay(1000); @@ -75,24 +71,13 @@ public class CorrectTextComponentSelectionTest { // We should place to the text components the long strings in order to // cover the components by the selection completely - String sf = ""; - for (int i = 0; i < 50; i++) { - sf = sf + " "; - } - tf.setText(sf); + tf.setText(" ".repeat(50)); // We check the color of the text component in order to find out the // bug reproducible situation tf.setForeground(Color.WHITE); tf.setBackground(Color.WHITE); - String sa = ""; - for (int i = 0; i < 50; i++) { - for (int j = 0; j < 50; j++) { - sa = sa + " "; - } - sa = sa + "\n"; - } - ta.setText(sa); + ta.setText((" ".repeat(50) + "\n").repeat(50)); ta.setForeground(Color.WHITE); ta.setBackground(Color.WHITE); @@ -111,26 +96,24 @@ public class CorrectTextComponentSelectionTest { r.waitForIdle(); r.delay(100); + EventQueue.invokeAndWait(() -> { tc.requestFocus(); tc.selectAll(); tc.select(0, 0); }); - r.waitForIdle(); - r.delay(100); - EventQueue.invokeAndWait(() -> { - loc = tc.getLocationOnScreen(); - }); r.waitForIdle(); r.delay(100); EventQueue.invokeAndWait(() -> { - color_center = r.getPixelColor(loc.x + tc.getWidth() / 2, loc.y + tc.getHeight() / 2); + Point p = tc.getLocationOnScreen(); + p.translate(tc.getWidth() / 2, tc.getHeight() / 2); + color_center = r.getPixelColor(p.x, p.y); }); - System.out.println("Color of the text component (CENTER) =" + color_center); - System.out.println("White color=" + Color.WHITE); + System.out.println("Color of the text component (CENTER) = " + color_center); + System.out.println("White color = " + Color.WHITE); if (color_center.getRGB() != Color.WHITE.getRGB()) { throw new RuntimeException("Test Failed"); diff --git a/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java b/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java deleted file mode 100644 index 0f13265ac58..00000000000 --- a/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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.awt.EventQueue; -import java.awt.GraphicsEnvironment; -import java.awt.Toolkit; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; - -import javax.swing.JButton; -import javax.swing.JFrame; - -import sun.awt.DisplayChangedListener; -import sun.awt.SunToolkit; - -/** - * @test - * @key headful - * @bug 8207070 - * @modules java.desktop/sun.java2d - * java.desktop/sun.awt - * java.desktop/sun.awt.windows:open - */ -public final class DisplayChangesException { - - private static boolean fail; - private static CountDownLatch go = new CountDownLatch(1); - - static final class TestThread extends Thread { - - private JFrame frame; - - private TestThread(ThreadGroup tg, String threadName) { - super(tg, threadName); - } - - public void run() { - try { - test(); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - private void test() throws Exception { - SunToolkit.createNewAppContext(); - EventQueue.invokeAndWait(() -> { - frame = new JFrame(); - final JButton b = new JButton(); - b.addPropertyChangeListener(evt -> { - if (!SunToolkit.isDispatchThreadForAppContext(b)) { - System.err.println("Wrong thread:" + currentThread()); - fail = true; - } - }); - frame.add(b); - frame.setSize(100, 100); - frame.setLocationRelativeTo(null); - frame.pack(); - }); - go.await(); - EventQueue.invokeAndWait(() -> { - frame.dispose(); - }); - } - } - - public static void main(final String[] args) throws Exception { - ThreadGroup tg0 = new ThreadGroup("ThreadGroup0"); - ThreadGroup tg1 = new ThreadGroup("ThreadGroup1"); - - TestThread t0 = new TestThread(tg0, "TestThread 0"); - TestThread t1 = new TestThread(tg1, "TestThread 1"); - - t0.start(); - t1.start(); - Thread.sleep(1500); // Cannot use Robot.waitForIdle - testToolkit(); - Thread.sleep(1500); - testGE(); - Thread.sleep(1500); - go.countDown(); - - if (fail) { - throw new RuntimeException(); - } - } - - private static void testGE() { - Object ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - if (!(ge instanceof DisplayChangedListener)) { - return; - } - ((DisplayChangedListener) ge).displayChanged(); - } - - private static void testToolkit() { - final Class toolkit; - try { - toolkit = Class.forName("sun.awt.windows.WToolkit"); - } catch (final ClassNotFoundException ignored) { - return; - } - try { - final Method displayChanged = toolkit.getMethod("displayChanged"); - displayChanged.invoke(Toolkit.getDefaultToolkit()); - } catch (final Exception e) { - e.printStackTrace(); - fail = true; - } - } -} - diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/badAction b/test/jdk/java/awt/dnd/BadSerializationTest/badAction index c02632cabfd..4556c2e5b1f 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/badAction and b/test/jdk/java/awt/dnd/BadSerializationTest/badAction differ diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/good b/test/jdk/java/awt/dnd/BadSerializationTest/good index 523df353a1a..f5dd0e2cb5b 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/good and b/test/jdk/java/awt/dnd/BadSerializationTest/good differ diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/noEvents b/test/jdk/java/awt/dnd/BadSerializationTest/noEvents index a45ba168c71..fdf1125889f 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/noEvents and b/test/jdk/java/awt/dnd/BadSerializationTest/noEvents differ diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/nullComponent b/test/jdk/java/awt/dnd/BadSerializationTest/nullComponent index 63aee01cc2c..d5dfcada90c 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/nullComponent and b/test/jdk/java/awt/dnd/BadSerializationTest/nullComponent differ diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/nullDragSource b/test/jdk/java/awt/dnd/BadSerializationTest/nullDragSource index a483f7106a8..efdfeb3ed20 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/nullDragSource and b/test/jdk/java/awt/dnd/BadSerializationTest/nullDragSource differ diff --git a/test/jdk/java/awt/dnd/BadSerializationTest/nullOrigin b/test/jdk/java/awt/dnd/BadSerializationTest/nullOrigin index 5af1996e74b..17d9fd3a1a9 100644 Binary files a/test/jdk/java/awt/dnd/BadSerializationTest/nullOrigin and b/test/jdk/java/awt/dnd/BadSerializationTest/nullOrigin differ diff --git a/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java index c8730b28964..615e2cdd6af 100644 --- a/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java +++ b/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8041928 8158616 + * @bug 8041928 8158616 8376050 * @requires (os.family != "mac") * @summary Confirm that the Alt-Gr Modifier bit is set correctly. * @library /java/awt/regtesthelpers diff --git a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java b/test/jdk/java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java deleted file mode 100644 index 9af56ba044b..00000000000 --- a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2018, 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. - * - * 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 8204142 - * @key headful - * @summary Deadlock when queueing SequencedEvent of different AppContexts - * @author Laurent Bourges - * @modules java.desktop/sun.awt - * @run main/othervm/timeout=30 MultipleContextsFunctionalTest - */ - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicReference; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.SwingUtilities; -import javax.swing.Timer; - -public final class MultipleContextsFunctionalTest { - - private static final long serialVersionUID = 1L; - - private static final int NUM_WINDOW = 2; - private static final int INTERVAL = 50; - private static final int MAX_TIME = 10000; // 10s - private static final int TOLERANCE = 10000;// 10s - private static final int CHECK_LAPSE = 100; - private static final int MAX_COUNT = MAX_TIME / INTERVAL; - private static final int EXPECTED = MAX_COUNT * NUM_WINDOW; - private static final List WINDOWS = new CopyOnWriteArrayList<>(); - - public static void main(String[] args) { - for (int i = 0; i < NUM_WINDOW; i++) { - createWin(i); - } - - int total = 0; - int waitingTime = MAX_TIME + TOLERANCE; - while (waitingTime > 0 && total != EXPECTED) { - try { - Thread.sleep(CHECK_LAPSE); - } catch (InterruptedException e) { - e.printStackTrace(); - } - waitingTime -= CHECK_LAPSE; - - total = 0; - for (TestWindow window : WINDOWS) { - total += window.getCounter(); - } - } - - // Failure if AWT hanging: assert - System.out.println("Total [" + total + "] - Expected [" + EXPECTED + "]"); - if (total == EXPECTED) { - System.out.println("Test PASSED"); - return; - } - System.out.println("Test FAILED"); - Runtime.getRuntime().halt(-1); - } - - private static void createWin(int tgNum) { - new Thread(new ThreadGroup("TG " + tgNum), - new Runnable() { - @Override - public void run() { - sun.awt.SunToolkit.createNewAppContext(); - - final AtomicReference ref = - new AtomicReference(); - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - final TestWindow window = new TestWindow(tgNum); - window.setVisible(true); - ref.set(window); - WINDOWS.add(window); - } - }); - - // Wait for window to show - TestWindow window = ref.get(); - while (window == null) { - try { - Thread.sleep(100); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - window = ref.get(); - } - window.enableTimer(true); - } - }).start(); - } - - private static final class TestWindow extends JFrame implements ActionListener { - - private final JButton btn; - private volatile int counter = 0; - private final Timer t; - - TestWindow(final int num) { - super("Test Window [" + num + "]"); - setMinimumSize(new Dimension(300, 200)); - setLocation(100 + 400 * (num - 1), 100); - - setLayout(new BorderLayout()); - JLabel textBlock = new JLabel("Lorem ipsum dolor sit amet..."); - add(textBlock); - - btn = new JButton("TEST"); - add(btn, BorderLayout.SOUTH); - - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - pack(); - - t = new Timer(INTERVAL, this); - t.setRepeats(false); - } - - @Override - public void actionPerformed(ActionEvent e) { - this.toFront(); - btn.setText("TEST " + (++counter)); - this.toBack(); - if (counter < MAX_COUNT) { - enableTimer(true); - } else { - dispose(); - } - } - - void enableTimer(boolean enable) { - if (enable) { - t.start(); - } else { - t.stop(); - } - } - - int getCounter() { - return counter; - } - } -} diff --git a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java b/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java deleted file mode 100644 index 8c7062f4abf..00000000000 --- a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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.awt.AWTEvent; -import java.awt.event.InvocationEvent; -import java.lang.reflect.Constructor; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicReference; - -import sun.awt.AppContext; -import sun.awt.SunToolkit; - -/** - * @test - * @bug 8204142 - * @author Sergey Bylokhov - * @key headful - * @modules java.desktop/java.awt:open java.desktop/sun.awt - * @run main/othervm/timeout=30 MultipleContextsUnitTest - */ -public final class MultipleContextsUnitTest { - - private static final int COUNT = 20; - private static final AppContext[] apps = new AppContext[COUNT]; - private static final CountDownLatch go = new CountDownLatch(1); - private static final CountDownLatch end = new CountDownLatch(COUNT); - - private static volatile int createSENumber = 0; - private static volatile int dispatchSENumber = 0; - - public static void main(final String[] args) throws Exception { - for (int i = 0; i < COUNT; i++) { - Thread t = testThread(i); - t.start(); - t.join(); - } - - for (AppContext app : apps) { - SunToolkit.postEvent(app, new InvocationEvent(new Object(), () -> { - try { - go.await(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - })); - } - - // eventOne - created first, but posted last - AWTEvent eventOne = getSequencedEvent(); - { - // eventTwo and eventThree - posted in the reverse order - AppContext app = apps[1]; - AWTEvent eventTwo = getSequencedEvent(); - AWTEvent eventThree = getSequencedEvent(); - SunToolkit.postEvent(app, eventThree); - SunToolkit.postEvent(app, eventTwo); - SunToolkit.postEvent(app, new InvocationEvent(new Object(), () -> { - System.err.println(AppContext.getAppContext()); - end.countDown(); - })); - } - - for (int i = 2; i < apps.length; i++) { - // eventTwo and eventThree - posted in the correct order - AppContext app = apps[i]; - - AWTEvent eventTwo = getSequencedEvent(); - SunToolkit.postEvent(app, eventTwo); - - AtomicReference called1 = new AtomicReference(false); - AtomicReference called2 = new AtomicReference(false); - int num1 = createSENumber; - SunToolkit.postEvent(app, new InvocationEvent(new Object(), () -> { - if (dispatchSENumber < num1) { - throw new RuntimeException("Dispatched too early"); - } - called1.set(true); - if (called2.get()) { - throw new RuntimeException("Second event is called before first"); - } - })); - AWTEvent eventThree = getSequencedEvent(); - SunToolkit.postEvent(app, eventThree); - int num2 = createSENumber; - SunToolkit.postEvent(app, new InvocationEvent(new Object(), () -> { - if (dispatchSENumber < num2) { - throw new RuntimeException("Dispatched too early"); - } - called2.set(true); - if (!called1.get()) { - throw new RuntimeException("First event is not called before second"); - } - System.err.println(AppContext.getAppContext()); - end.countDown(); - })); - } - - - - // eventOne should flush all EDT - SunToolkit.postEvent(apps[0], eventOne); - SunToolkit.postEvent(apps[0], new InvocationEvent(new Object(), () -> { - System.err.println(AppContext.getAppContext()); - end.countDown(); - })); - - go.countDown(); - - System.err.println("Start to wait"); - end.await(); - System.err.println("End to wait"); - } - - private static Thread testThread(int index) { - final ThreadGroup group = new ThreadGroup("TG " + index); - return new Thread(group, () -> { - apps[index] = SunToolkit.createNewAppContext(); - }); - } - - private static AWTEvent getSequencedEvent() - { - int num = createSENumber++; - - InvocationEvent wrapMe = new InvocationEvent(new Object(), () -> { - if (num != dispatchSENumber++) { - System.err.println("num: " + num); - System.err.println("dispatchSENumber: " + dispatchSENumber); - throw new RuntimeException("Wrong order"); - } - }); - - try { - /* - * SequencedEvent is a package private class, which cannot be instantiated - * by importing. So use reflection to create an instance. - */ - Class seqClass = (Class) Class.forName("java.awt.SequencedEvent"); - Constructor - seqConst = seqClass.getConstructor(AWTEvent.class); - seqConst.setAccessible(true); - return seqConst.newInstance(wrapMe); - } catch (Throwable err) { - throw new RuntimeException("Unable to instantiate SequencedEvent",err); - } - } -} diff --git a/test/jdk/java/awt/font/GlyphVector/GlyphMetricsRotatedFontTest.java b/test/jdk/java/awt/font/GlyphVector/GlyphMetricsRotatedFontTest.java new file mode 100644 index 00000000000..eb00fd4f34d --- /dev/null +++ b/test/jdk/java/awt/font/GlyphVector/GlyphMetricsRotatedFontTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2026, 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 8148334 8377937 + * @summary Checks behavior of GlyphVector.getGlyphMetrics(int) with rotated fonts. + */ + +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphMetrics; +import java.awt.font.GlyphVector; +import java.awt.geom.AffineTransform; + +public class GlyphMetricsRotatedFontTest { + + public static void main(String[] args) { + + String text = "The quick brown \r\n fox JUMPS over \t the lazy dog."; + FontRenderContext frc = new FontRenderContext(null, true, true); + + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + String[] names = ge.getAvailableFontFamilyNames(); + + for (String name : names) { + + Font normal = new Font(name, Font.PLAIN, 60); + if (normal.canDisplayUpTo("AZaz09") != -1) { + continue; + } + + double theta = 0.5; // about 30 degrees + AffineTransform tx = AffineTransform.getRotateInstance(theta); + Font rotated = normal.deriveFont(tx); + + GlyphVector gv1 = normal.createGlyphVector(frc, text); + GlyphVector gv2 = rotated.createGlyphVector(frc, text); + + for (int i = 0; i < gv1.getNumGlyphs(); i++) { + GlyphMetrics gm1 = gv1.getGlyphMetrics(i); + GlyphMetrics gm2 = gv2.getGlyphMetrics(i); + assertEqual(0, gm1.getAdvanceY(), 0, name + " normal y", i); + double expectedX = Math.cos(theta) * gm1.getAdvanceX(); + double expectedY = Math.sin(theta) * gm1.getAdvanceX(); + assertEqual(expectedX, gm2.getAdvanceX(), 1, name + " rotated x", i); + assertEqual(expectedY, gm2.getAdvanceY(), 1, name + " rotated y", i); + } + } + } + + private static void assertEqual(double d1, double d2, double variance, + String scenario, int index) { + if (Math.abs(d1 - d2) > variance) { + String msg = String.format("%s for index %d: %f != %f", scenario, index, d1, d2); + throw new RuntimeException(msg); + } + } +} diff --git a/test/jdk/java/awt/font/TextLayout/FormatCharAdvanceTest.java b/test/jdk/java/awt/font/TextLayout/FormatCharAdvanceTest.java index 63cd890f1db..4a3f759c559 100644 --- a/test/jdk/java/awt/font/TextLayout/FormatCharAdvanceTest.java +++ b/test/jdk/java/awt/font/TextLayout/FormatCharAdvanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -67,9 +67,13 @@ public class FormatCharAdvanceTest { * font.em = 2048 * font.ascent = 1638 * font.descent = 410 - * font.familyname = 'Test' - * font.fontname = 'Test' - * font.fullname = 'Test' + * font.familyname = 'TTFTest' + * font.fontname = 'TTFTest' + * font.fullname = 'TTFTest' + * #Use below values for Type 1 font + * #font.familyname = 'Type1Test' + * #font.fontname = 'Type1Test' + * #font.fullname = 'Type1Test' * font.copyright = '' * font.autoWidth(0, 0, 2048) * @@ -107,29 +111,30 @@ public class FormatCharAdvanceTest { * * ttf = 'test.ttf' # TrueType * t64 = 'test.ttf.txt' # TrueType Base64 - * pfb = 'test.pfb' # PostScript Type1 - * p64 = 'test.pfb.txt' # PostScript Type1 Base64 + * #Use commented lines to generate Type1 font + * #pfb = 'test.pfb' # PostScript Type1 + * #p64 = 'test.pfb.txt' # PostScript Type1 Base64 * * font.generate(ttf) - * font.generate(pfb) + * #font.generate(pfb) * * with open(ttf, 'rb') as f1: * encoded = base64.b64encode(f1.read()) * with open(t64, 'wb') as f2: * f2.write(encoded) * - * with open(pfb, 'rb') as f3: - * encoded = base64.b64encode(f3.read()) - * with open(p64, 'wb') as f4: - * f4.write(encoded) + * #with open(pfb, 'rb') as f3: + * #encoded = base64.b64encode(f3.read()) + * #with open(p64, 'wb') as f4: + * #f4.write(encoded) *

*/ - private static final String TTF_BYTES = "AAEAAAANAIAAAwBQRkZUTarBS1AAABbcAAAAHE9TLzKD7vqWAAABWAAAAGBjbWFw11zF/AAAAvwAAANSY3Z0IABEBREAAAZQAAAABGdhc3D//wADAAAW1AAAAAhnbHlmgVJ3qAAAB4gAAAnMaGVhZCqFqboAAADcAAAANmhoZWEIcgJiAAABFAAAACRobXR4L1UevAAAAbgAAAFEbG9jYb8EwZoAAAZUAAABNG1heHAA4ABCAAABOAAAACBuYW1lJWcF2wAAEVQAAAGJcG9zdBSfZd0AABLgAAAD8QABAAAAAQAAzMHptF8PPPUACwgAAAAAAORfr7QAAAAA5F+vtABEAAACZAVVAAAACAACAAAAAAAAAAEAAAVVAAAAuAJYAAAAAAJkAAEAAAAAAAAAAAAAAAAAAAAJAAEAAACZAAgAAgAIAAIAAgAAAAEAAQAAAEAALgABAAEABAJXAZAABQAABTMFmQAAAR4FMwWZAAAD1wBmAhIAAAIABQMAAAAAAACAACADAgAAABECAKgAAAAAUGZFZACAAAn//wZm/mYAuAVVAAAAAAABAAAAAADIAMgAAAAgAAEC7ABEAAAAAAJYAGQCWABkAlgAZAJYAGQCWABkAjkAAAJYAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAAAAFAAAAAwAAACwAAAAEAAAA7AABAAAAAAJMAAMAAQAAACwAAwAKAAAA7AAEAMAAAAAoACAABAAIAA0AIAA5AFoAegCFAK0GBQYcBt0HDwiRCOIYDiAPIC8gb/7///v//wAAAAkAIAAwAEEAYQCFAK0GAAYcBt0HDwiQCOIYDiALICggYP7///n//wAA/+f/2P/R/8v/wf+a+kj6Mvly+UH3wfdx6EbgSuAy4AIBcwAAAAEAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAMABAAFAAYAAgBzAHQAdQAMAAAAAAFgAAAAAAAAABwAAAAJAAAADAAAAAMAAAANAAAADQAAAAIAAAAgAAAAIAAAAAcAAAAwAAAAOQAAAAgAAABBAAAAWgAAABIAAABhAAAAegAAACwAAACFAAAAhQAAAEYAAACtAAAArQAAAEcAAAYAAAAGBQAAAEgAAAYcAAAGHAAAAE4AAAbdAAAG3QAAAE8AAAcPAAAHDwAAAFAAAAiQAAAIkQAAAFEAAAjiAAAI4gAAAFMAABgOAAAYDgAAAFQAACALAAAgDwAAAFUAACAoAAAgLwAAAFoAACBgAAAgbwAAAGIAAP7/AAD+/wAAAHIAAP/5AAD/+wAAAHMAARC9AAEQvQAAAHYAARDNAAEQzQAAAHcAATQwAAE0PwAAAHgAAbygAAG8owAAAIgAAdFzAAHRegAAAIwADgABAA4AAQAAAJQADgAgAA4AIQAAAJUADgB+AA4AfwAAAJcAAAEGAAABAAAAAAAAAAEDBAUGAgAAAAAAAAAAAAAAAAAAAAEAAAcAAAAAAAAAAAAAAAAAAAAICQoLDA0ODxARAAAAAAAAABITFBUWFxgZGhscHR4fICEiIyQlJicoKSorAAAAAAAALC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAURAAAALAAsADQAPABEAEwAVABUAFwAZABsAHQAfACEAIwAlACcAKQArAC0ALwAxADMANQA3ADkAOwA9AD8AQQBDAEUARwBJAEsATQBPAFEAUwBVAFcAWQBbAF0AYYBjgGWAZ4BpgGuAbYBvgHGAc4B1gHeAeYB7gH2Af4CBgIOAhYCHgImAi4CNgI+AkYCTgJWAl4CZgJuAnYCfgKGAo4ClgKeAqYCrgK2Ar4CxgLOAtYC3gLmAu4C9gL+AwYDDgMWAx4DJgMuAzYDPgNGA04DVgNeA2YDbgN2A34DhgOOA5YDngOmA64DtgO+A8YDzgPWA94D5gPuA/YD/gQGBA4EFgQeBCYELgQ2BD4ERgROBFYEXgRmBG4EdgR+BIYEjgSWBJ4EpgSuBLYEvgTGBM4E1gTeBOYAAgBEAAACZAVVAAMABwAusQEALzyyBwQA7TKxBgXcPLIDAgDtMgCxAwAvPLIFBADtMrIHBgH8PLIBAgDtMjMRIRElIREhRAIg/iQBmP5oBVX6q0QEzQAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAAAAgBkAGQB9ADIAAMABwAANzUhFSE1IRVkAZD+cAGQZGRkZGT//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAAAAAAOAK4AAQAAAAAAAAAAAAIAAQAAAAAAAQAEAA0AAQAAAAAAAgAHACIAAQAAAAAAAwAgAGwAAQAAAAAABAAEAJcAAQAAAAAABQAPALwAAQAAAAAABgAEANYAAwABBAkAAAAAAAAAAwABBAkAAQAIAAMAAwABBAkAAgAOABIAAwABBAkAAwBAACoAAwABBAkABAAIAI0AAwABBAkABQAeAJwAAwABBAkABgAIAMwAAAAAVABlAHMAdAAAVGVzdAAAUgBlAGcAdQBsAGEAcgAAUmVndWxhcgAARgBvAG4AdABGAG8AcgBnAGUAIAAyAC4AMAAgADoAIABUAGUAcwB0ACAAOgAgADMAMAAtADUALQAyADAAMgA1AABGb250Rm9yZ2UgMi4wIDogVGVzdCA6IDMwLTUtMjAyNQAAVABlAHMAdAAAVGVzdAAAVgBlAHIAcwBpAG8AbgAgADAAMAAxAC4AMAAwADAAAFZlcnNpb24gMDAxLjAwMAAAVABlAHMAdAAAVGVzdAAAAAAAAgAAAAAAAP9nAGYAAAAAAAAAAAAAAAAAAAAAAAAAAACZAAAAAQECAQMBBAEFAQYAAwATABQAFQAWABcAGAAZABoAGwAcACQAJQAmACcAKAApACoAKwAsAC0ALgAvADAAMQAyADMANAA1ADYANwA4ADkAOgA7ADwAPQBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0BBwEIAQkBCgELAQwBDQEOAQ8BEAERARIBEwEUARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEBIgEjASQBJQEmAScBKAEpASoBKwEsAS0BLgEvATABMQEyATMBNAE1ATYBNwE4ATkBOgE7ATwBPQE+AT8BQAFBAUIBQwFEAUUBRgFHAUgBSQFKAUsBTAFNAU4BTwFQAVEBUgFTAVQBVQFWAVcBWAFZB3VuaTAwMEQHdW5pMDAwOQd1bmkwMDBBB3VuaTAwMEIHdW5pMDAwQwd1bmkwMDg1B3VuaTAwQUQHdW5pMDYwMAd1bmkwNjAxB3VuaTA2MDIHdW5pMDYwMwd1bmkwNjA0B3VuaTA2MDUHdW5pMDYxQwd1bmkwNkREB3VuaTA3MEYHdW5pMDg5MAd1bmkwODkxB3VuaTA4RTIHdW5pMTgwRQd1bmkyMDBCB3VuaTIwMEMHdW5pMjAwRAd1bmkyMDBFB3VuaTIwMEYHdW5pMjAyOAd1bmkyMDI5B3VuaTIwMkEHdW5pMjAyQgd1bmkyMDJDB3VuaTIwMkQHdW5pMjAyRQd1bmkyMDJGB3VuaTIwNjAHdW5pMjA2MQd1bmkyMDYyB3VuaTIwNjMHdW5pMjA2NAd1bmkyMDY1B3VuaTIwNjYHdW5pMjA2Nwd1bmkyMDY4B3VuaTIwNjkHdW5pMjA2QQd1bmkyMDZCB3VuaTIwNkMHdW5pMjA2RAd1bmkyMDZFB3VuaTIwNkYHdW5pRkVGRgd1bmlGRkY5B3VuaUZGRkEHdW5pRkZGQgZ1MTEwQkQGdTExMENEBnUxMzQzMAZ1MTM0MzEGdTEzNDMyBnUxMzQzMwZ1MTM0MzQGdTEzNDM1BnUxMzQzNgZ1MTM0MzcGdTEzNDM4BnUxMzQzOQZ1MTM0M0EGdTEzNDNCBnUxMzQzQwZ1MTM0M0QGdTEzNDNFBnUxMzQzRgZ1MUJDQTAGdTFCQ0ExBnUxQkNBMgZ1MUJDQTMGdTFEMTczBnUxRDE3NAZ1MUQxNzUGdTFEMTc2BnUxRDE3NwZ1MUQxNzgGdTFEMTc5BnUxRDE3QQZ1RTAwMDEGdUUwMDIwBnVFMDAyMQZ1RTAwN0UGdUUwMDdGAAAAAAAAAf//AAIAAAABAAAAAOIB6+cAAAAA5F+vtAAAAADkX6+0"; + private static final String TTF_BYTES = "AAEAAAANAIAAAwBQRkZUTbCUBjwAABcAAAAAHE9TLzKD7vqWAAABWAAAAGBjbWFw11zF/AAAAvwAAANSY3Z0IABEBREAAAZQAAAABGdhc3D//wADAAAW+AAAAAhnbHlmgVJ3qAAAB4gAAAnMaGVhZC1MmToAAADcAAAANmhoZWEIcgJiAAABFAAAACRobXR4L1UevAAAAbgAAAFEbG9jYb8EwZoAAAZUAAABNG1heHAA4ABCAAABOAAAACBuYW1lLzI4NgAAEVQAAAGtcG9zdBSfZd0AABMEAAAD8QABAAAAAQAAp/gvll8PPPUACwgAAAAAAOXDJ3QAAAAA5cMndABEAAACZAVVAAAACAACAAAAAAAAAAEAAAVVAAAAuAJYAAAAAAJkAAEAAAAAAAAAAAAAAAAAAAAJAAEAAACZAAgAAgAIAAIAAgAAAAEAAQAAAEAALgABAAEABAJXAZAABQAABTMFmQAAAR4FMwWZAAAD1wBmAhIAAAIABQMAAAAAAACAACADAgAAABECAKgAAAAAUGZFZACAAAn//wZm/mYAuAVVAAAAAAABAAAAAADIAMgAAAAgAAEC7ABEAAAAAAJYAGQCWABkAlgAZAJYAGQCWABkAjkAAAJYAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAZABkAGQAAAAFAAAAAwAAACwAAAAEAAAA7AABAAAAAAJMAAMAAQAAACwAAwAKAAAA7AAEAMAAAAAoACAABAAIAA0AIAA5AFoAegCFAK0GBQYcBt0HDwiRCOIYDiAPIC8gb/7///v//wAAAAkAIAAwAEEAYQCFAK0GAAYcBt0HDwiQCOIYDiALICggYP7///n//wAA/+f/2P/R/8v/wf+a+kj6Mvly+UH3wfdx6EbgSuAy4AIBcwAAAAEAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAMABAAFAAYAAgBzAHQAdQAMAAAAAAFgAAAAAAAAABwAAAAJAAAADAAAAAMAAAANAAAADQAAAAIAAAAgAAAAIAAAAAcAAAAwAAAAOQAAAAgAAABBAAAAWgAAABIAAABhAAAAegAAACwAAACFAAAAhQAAAEYAAACtAAAArQAAAEcAAAYAAAAGBQAAAEgAAAYcAAAGHAAAAE4AAAbdAAAG3QAAAE8AAAcPAAAHDwAAAFAAAAiQAAAIkQAAAFEAAAjiAAAI4gAAAFMAABgOAAAYDgAAAFQAACALAAAgDwAAAFUAACAoAAAgLwAAAFoAACBgAAAgbwAAAGIAAP7/AAD+/wAAAHIAAP/5AAD/+wAAAHMAARC9AAEQvQAAAHYAARDNAAEQzQAAAHcAATQwAAE0PwAAAHgAAbygAAG8owAAAIgAAdFzAAHRegAAAIwADgABAA4AAQAAAJQADgAgAA4AIQAAAJUADgB+AA4AfwAAAJcAAAEGAAABAAAAAAAAAAEDBAUGAgAAAAAAAAAAAAAAAAAAAAEAAAcAAAAAAAAAAAAAAAAAAAAICQoLDA0ODxARAAAAAAAAABITFBUWFxgZGhscHR4fICEiIyQlJicoKSorAAAAAAAALC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAURAAAALAAsADQAPABEAEwAVABUAFwAZABsAHQAfACEAIwAlACcAKQArAC0ALwAxADMANQA3ADkAOwA9AD8AQQBDAEUARwBJAEsATQBPAFEAUwBVAFcAWQBbAF0AYYBjgGWAZ4BpgGuAbYBvgHGAc4B1gHeAeYB7gH2Af4CBgIOAhYCHgImAi4CNgI+AkYCTgJWAl4CZgJuAnYCfgKGAo4ClgKeAqYCrgK2Ar4CxgLOAtYC3gLmAu4C9gL+AwYDDgMWAx4DJgMuAzYDPgNGA04DVgNeA2YDbgN2A34DhgOOA5YDngOmA64DtgO+A8YDzgPWA94D5gPuA/YD/gQGBA4EFgQeBCYELgQ2BD4ERgROBFYEXgRmBG4EdgR+BIYEjgSWBJ4EpgSuBLYEvgTGBM4E1gTeBOYAAgBEAAACZAVVAAMABwAusQEALzyyBwQA7TKxBgXcPLIDAgDtMgCxAwAvPLIFBADtMrIHBgH8PLIBAgDtMjMRIRElIREhRAIg/iQBmP5oBVX6q0QEzQAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAAAAgBkAGQB9ADIAAMABwAANzUhFSE1IRVkAZD+cAGQZGRkZGT//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAD//wBkAGQB9ADIEgYALAAA//8AZABkAfQAyBIGACwAAP//AGQAZAH0AMgSBgAsAAAAAAAOAK4AAQAAAAAAAAAAAAIAAQAAAAAAAQAHABMAAQAAAAAAAgAHACsAAQAAAAAAAwAjAHsAAQAAAAAABAAHAK8AAQAAAAAABQAPANcAAQAAAAAABgAHAPcAAwABBAkAAAAAAAAAAwABBAkAAQAOAAMAAwABBAkAAgAOABsAAwABBAkAAwBGADMAAwABBAkABAAOAJ8AAwABBAkABQAeALcAAwABBAkABgAOAOcAAAAAVABUAEYAVABlAHMAdAAAVFRGVGVzdAAAUgBlAGcAdQBsAGEAcgAAUmVndWxhcgAARgBvAG4AdABGAG8AcgBnAGUAIAAyAC4AMAAgADoAIABUAFQARgBUAGUAcwB0ACAAOgAgADIANAAtADIALQAyADAAMgA2AABGb250Rm9yZ2UgMi4wIDogVFRGVGVzdCA6IDI0LTItMjAyNgAAVABUAEYAVABlAHMAdAAAVFRGVGVzdAAAVgBlAHIAcwBpAG8AbgAgADAAMAAxAC4AMAAwADAAAFZlcnNpb24gMDAxLjAwMAAAVABUAEYAVABlAHMAdAAAVFRGVGVzdAAAAAAAAgAAAAAAAP9nAGYAAAAAAAAAAAAAAAAAAAAAAAAAAACZAAAAAQECAQMBBAEFAQYAAwATABQAFQAWABcAGAAZABoAGwAcACQAJQAmACcAKAApACoAKwAsAC0ALgAvADAAMQAyADMANAA1ADYANwA4ADkAOgA7ADwAPQBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0BBwEIAQkBCgELAQwBDQEOAQ8BEAERARIBEwEUARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEBIgEjASQBJQEmAScBKAEpASoBKwEsAS0BLgEvATABMQEyATMBNAE1ATYBNwE4ATkBOgE7ATwBPQE+AT8BQAFBAUIBQwFEAUUBRgFHAUgBSQFKAUsBTAFNAU4BTwFQAVEBUgFTAVQBVQFWAVcBWAFZB3VuaTAwMEQHdW5pMDAwOQd1bmkwMDBBB3VuaTAwMEIHdW5pMDAwQwd1bmkwMDg1B3VuaTAwQUQHdW5pMDYwMAd1bmkwNjAxB3VuaTA2MDIHdW5pMDYwMwd1bmkwNjA0B3VuaTA2MDUHdW5pMDYxQwd1bmkwNkREB3VuaTA3MEYHdW5pMDg5MAd1bmkwODkxB3VuaTA4RTIHdW5pMTgwRQd1bmkyMDBCB3VuaTIwMEMHdW5pMjAwRAd1bmkyMDBFB3VuaTIwMEYHdW5pMjAyOAd1bmkyMDI5B3VuaTIwMkEHdW5pMjAyQgd1bmkyMDJDB3VuaTIwMkQHdW5pMjAyRQd1bmkyMDJGB3VuaTIwNjAHdW5pMjA2MQd1bmkyMDYyB3VuaTIwNjMHdW5pMjA2NAd1bmkyMDY1B3VuaTIwNjYHdW5pMjA2Nwd1bmkyMDY4B3VuaTIwNjkHdW5pMjA2QQd1bmkyMDZCB3VuaTIwNkMHdW5pMjA2RAd1bmkyMDZFB3VuaTIwNkYHdW5pRkVGRgd1bmlGRkY5B3VuaUZGRkEHdW5pRkZGQgZ1MTEwQkQGdTExMENEBnUxMzQzMAZ1MTM0MzEGdTEzNDMyBnUxMzQzMwZ1MTM0MzQGdTEzNDM1BnUxMzQzNgZ1MTM0MzcGdTEzNDM4BnUxMzQzOQZ1MTM0M0EGdTEzNDNCBnUxMzQzQwZ1MTM0M0QGdTEzNDNFBnUxMzQzRgZ1MUJDQTAGdTFCQ0ExBnUxQkNBMgZ1MUJDQTMGdTFEMTczBnUxRDE3NAZ1MUQxNzUGdTFEMTc2BnUxRDE3NwZ1MUQxNzgGdTFEMTc5BnUxRDE3QQZ1RTAwMDEGdUUwMDIwBnVFMDAyMQZ1RTAwN0UGdUUwMDdGAAAAAAAAAf//AAIAAAABAAAAAOUNt1MAAAAA5cMndAAAAADlwyd0"; /** - * Same font as above, but in PostScript Type1 (PFB) format. + * Same font as above, but in PostScript Type1 (PFB) format with different font name. */ - private static final String TYPE1_BYTES = "gAFSBwAAJSFQUy1BZG9iZUZvbnQtMS4wOiBUZXN0IDAwMS4wMDAKJSVUaXRsZTogVGVzdAolVmVyc2lvbjogMDAxLjAwMAolJUNyZWF0aW9uRGF0ZTogRnJpIE1heSAzMCAyMDo1NTo0OCAyMDI1CiUlQ3JlYXRvcjogRGFuaWVsIEdyZWRsZXIKJSAyMDI1LTUtMzA6IENyZWF0ZWQgd2l0aCBGb250Rm9yZ2UgKGh0dHA6Ly9mb250Zm9yZ2Uub3JnKQolIEdlbmVyYXRlZCBieSBGb250Rm9yZ2UgMjAyMzAxMDEgKGh0dHA6Ly9mb250Zm9yZ2Uuc2YubmV0LykKJSVFbmRDb21tZW50cwoKMTAgZGljdCBiZWdpbgovRm9udFR5cGUgMSBkZWYKL0ZvbnRNYXRyaXggWzAuMDAwNDg4MjgxIDAgMCAwLjAwMDQ4ODI4MSAwIDAgXXJlYWRvbmx5IGRlZgovRm9udE5hbWUgL1Rlc3QgZGVmCi9Gb250QkJveCB7MTAwIDEwMCA1MDAgMjAwIH1yZWFkb25seSBkZWYKL1BhaW50VHlwZSAwIGRlZgovRm9udEluZm8gMTAgZGljdCBkdXAgYmVnaW4KIC92ZXJzaW9uICgwMDEuMDAwKSByZWFkb25seSBkZWYKIC9Ob3RpY2UgKCkgcmVhZG9ubHkgZGVmCiAvRnVsbE5hbWUgKFRlc3QpIHJlYWRvbmx5IGRlZgogL0ZhbWlseU5hbWUgKFRlc3QpIHJlYWRvbmx5IGRlZgogL1dlaWdodCAoUmVndWxhcikgcmVhZG9ubHkgZGVmCiAvRlNUeXBlIDAgZGVmCiAvSXRhbGljQW5nbGUgMCBkZWYKIC9pc0ZpeGVkUGl0Y2ggZmFsc2UgZGVmCiAvVW5kZXJsaW5lUG9zaXRpb24gLTIwNC44IGRlZgogL1VuZGVybGluZVRoaWNrbmVzcyAxMDIuNCBkZWYKZW5kIHJlYWRvbmx5IGRlZgovRW5jb2RpbmcgMjU2IGFycmF5CiAwIDEgMjU1IHsgMSBpbmRleCBleGNoIC8ubm90ZGVmIHB1dH0gZm9yCmR1cCA5L3VuaTAwMDkgcHV0CmR1cCAxMC91bmkwMDBBIHB1dApkdXAgMTEvdW5pMDAwQiBwdXQKZHVwIDEyL3VuaTAwMEMgcHV0CmR1cCAxMy91bmkwMDBEIHB1dApkdXAgMzIvc3BhY2UgcHV0CmR1cCA0OC96ZXJvIHB1dApkdXAgNDkvb25lIHB1dApkdXAgNTAvdHdvIHB1dApkdXAgNTEvdGhyZWUgcHV0CmR1cCA1Mi9mb3VyIHB1dApkdXAgNTMvZml2ZSBwdXQKZHVwIDU0L3NpeCBwdXQKZHVwIDU1L3NldmVuIHB1dApkdXAgNTYvZWlnaHQgcHV0CmR1cCA1Ny9uaW5lIHB1dApkdXAgNjUvQSBwdXQKZHVwIDY2L0IgcHV0CmR1cCA2Ny9DIHB1dApkdXAgNjgvRCBwdXQKZHVwIDY5L0UgcHV0CmR1cCA3MC9GIHB1dApkdXAgNzEvRyBwdXQKZHVwIDcyL0ggcHV0CmR1cCA3My9JIHB1dApkdXAgNzQvSiBwdXQKZHVwIDc1L0sgcHV0CmR1cCA3Ni9MIHB1dApkdXAgNzcvTSBwdXQKZHVwIDc4L04gcHV0CmR1cCA3OS9PIHB1dApkdXAgODAvUCBwdXQKZHVwIDgxL1EgcHV0CmR1cCA4Mi9SIHB1dApkdXAgODMvUyBwdXQKZHVwIDg0L1QgcHV0CmR1cCA4NS9VIHB1dApkdXAgODYvViBwdXQKZHVwIDg3L1cgcHV0CmR1cCA4OC9YIHB1dApkdXAgODkvWSBwdXQKZHVwIDkwL1ogcHV0CmR1cCA5Ny9hIHB1dApkdXAgOTgvYiBwdXQKZHVwIDk5L2MgcHV0CmR1cCAxMDAvZCBwdXQKZHVwIDEwMS9lIHB1dApkdXAgMTAyL2YgcHV0CmR1cCAxMDMvZyBwdXQKZHVwIDEwNC9oIHB1dApkdXAgMTA1L2kgcHV0CmR1cCAxMDYvaiBwdXQKZHVwIDEwNy9rIHB1dApkdXAgMTA4L2wgcHV0CmR1cCAxMDkvbSBwdXQKZHVwIDExMC9uIHB1dApkdXAgMTExL28gcHV0CmR1cCAxMTIvcCBwdXQKZHVwIDExMy9xIHB1dApkdXAgMTE0L3IgcHV0CmR1cCAxMTUvcyBwdXQKZHVwIDExNi90IHB1dApkdXAgMTE3L3UgcHV0CmR1cCAxMTgvdiBwdXQKZHVwIDExOS93IHB1dApkdXAgMTIwL3ggcHV0CmR1cCAxMjEveSBwdXQKZHVwIDEyMi96IHB1dApkdXAgMTMzL3VuaTAwODUgcHV0CmR1cCAxNzMvdW5pMDBBRCBwdXQKcmVhZG9ubHkgZGVmCmN1cnJlbnRkaWN0IGVuZApjdXJyZW50ZmlsZSBlZXhlYwqAAo0WAAB0P4QT82NsqFqf/vtQtLsnMCpcwKtuL5Wb8g0yDDc8ISjQoM5wcrH2cqCqOMPA7OsEtEyxdKHDFhLXH/ogyQlUJWN4Ny95WwvylB9DfwWfQa4FmMAFFf7xhzM1V/Ms4yqe59S6tl2lND+ScH4s/PPozkRuWtrDn8N+zmS2izVs4NcQ9FsefyzXaKvKFDYINmh2GhAJRkFi0FTB9r8sRqMZs8ZkUodjFsE6kmRW02YpWP1WdA1YVnNuYQT4E+0xkVZ3eTTuscVEWua/buWeWxlwi0KH20ubr5iCkavAb953/MMe4XMKlPvGzsx0Slmp9qOOLD0ko2287peB1DvLavHCG/r2rr8MhqsKVoSyFr36sVd9hMSQrwFxpRjVEjtt5HDGcbHwy3ylp8b1oopSl5AQmeoW/oGT0rPr+358A+Qd2/wpQgStXDcDExQWDrdOL7J5Fr7VBDu8NNORXc7c5uKb2iVQq5AOF+Yfa5bH4reIFcWrAItBML9L9b8sOf1QKzGymFzgcDW3EEx07Y07ys95zSLkYtY5lkjm07GFSyM9cuWhRctY6RTcjTAFNdbxOUBXbIGf4Q8nhdXXi3IKhYdqdgKEsWphwKEdQeP7QYqW4bPSB881DjF/e7r6PIkua8MXGI3G1I0C53TIFnHXai5dtVJ4cZhdaTzgoD9K6zYMNsb8Tof6THYx+cRUzPbJmb+VbprjDk96+92jF+P0EwubV0GQMLEdCyPDV1u/vIHPePqSJt2/YjgkXEugRbyqzFwfZJdeAmkzcqs1CU9EiqrwgqbEfdmWWwv9BDxgkWD4omPKAKX1A6asv/UVfH8lebHSbrKddpR8XU/C2I/t7UhI19oTFqIvUL061MrZPiHZaFE9bnvJw+P91hF+MoPs69ddhD4Kj6z6MJYNGlvAZMuUM/RdAUwE3HHhwGiCN3Hqi4V+byVeB95B/8YLQK1CiW/pgfU7TqZ1d5nWGoAXAcAu6UYGvZZ0ChX3AEPlIFJ4x4hXfBo0I/k/TEHus/u5dNm/+ixyBcr/rX/e2yPIBfJkBJDG8x/y7JaxOFAD1NMQ4zWjbzP1uPpiGzRKfCXYLF6YXLfGDKJ1w3IENGwIMXBgqOx6O2v2xkYhcAUkrZ2Nw3xpRrnj2RqGCGwz00AHrl9AU7CNaM8BkSe6d86xT8teVYuOk926Xj4/+Kx6rfu526Ylz91kxebopcMvql6ysRVzzSGsW2ec9ZPJo1Q/WKb+tCvBm8OdUnRi+DldIajpytyl08TmlS+IRUcHZbxoIjxb7ZCvF8hd03yDhs9bsUSO6h7jbhegenLIiQPX7RtsGAg3logZLD0NUjcAm2tKBieMHhMxAD89lVmuMkNj5r6EaixXvkvhgqzhjPExdu30Knife5IEnlCvIlMCh1EXQsY9KRkzeTRTKfnZTJ/idze+cX0nCEGcFrvCCjZRfNuaLRHx73o2KlDHmoYBm1mFEEvfUReQxS987AiVfSF7cs8IrLEqV9qe2mCAv7ATbVUFbnvYxTBYvHL9sc4892rLrjSu/yP5RZmmIMOpTH8CStLw1zGAcXH3W3ZfPjQkEA4jzvo1U5Oi9EkBKqlgqjj2pFLWepwuNG/L3Iyr36frW6NFtqCxyVQYcNwOTnmQjY0LXPAKxyz2l+xyo/gcDY8nqtWms5aqINgemqM0pG2wBt3GawARbEVkkKllyB/WJbRw0GGHktmj73ixkTulD6nHZ+vMd+aS8iKXPa2ASEOPpxp515DZxg+VYZIrM0h4mDdRff4To/8NKs7Kx4IZx2qzlhIKS2zHpLwuY/U2Wt80e9nqMCFEtnS8sKpcy1rrE9FzXsFUNtYE6LdIat4ygQxoq24Y6D3bfDpl3E8wMvECaVCJX8lfBhQcGGU6+Jba1qfQ7jonjQM0zfoOwHrApk/dkPkSdjQy7UM+dZNMtgZf2N46UuWC2YCtcqCN1X+o5SpojTgXNmTjUy3KOy6L4GNYOxutsDhWiah6rJ+FGVL9D51MJvT3l02T1+LpNt8ZeZQSkZpx7NdFFTFA4/SE8zycfBLNm71Q9pjQKa30TnCY9ZkMEH9rnArLV0w2Gi6LoJoWpT7GoAB2Cdvi3x9wGDdt60K6oABWiD5mpAv4KfrJMBn5dRDJVyRPARXxwBUROAc3BxY8St3WuWKqDqqef0t0rlqAXGynPrcAjqFMXc/GBWORQ7W/dTvbu/eZb+apjKEX7szjaY4cSRsNge4gTyCEsfhLrdBkncM7up9jj206tIaqZQILxHAnrVwYplJ5D2EvSSLYvxFEVHSrI19aNJEvDK64tzXCV+P4yOCOuXpBmc15PDlrMQEauqrD+xneCO+CrCbudHXOJsbmvQq56+ovLp5SNBfdEPQpqo5tBgQaNHcEjg/iVt++uLxT3vAEFW5d7WXPMYdy+XqoMmdRDOzey0Mdx5BZ92rNM/LthQa6F54nvzkypM64HdxCYlri8cO3k0G6bp2eWdseP0P4zMc5QikuXc/Dr4NztBYe2yJLbLLesWSB8nOWcl+gd0GMX5PY4P5mn5WJDNStLWPdD9NapzMsyx6lZwR9Tfv/XSmay9LEo9YaaxysWfllDIasUCdvhZVi7LJvPu/0GbuHLOz9mP6prkF8h8KmjBYMlMktouA23G74M+Pkdfbj9KAM8zOYCgQFZUaXx3iZ4m3uBtDPeKjUcdFZSnHdW11eSv5aCz2fMbExV/qnPOSMbkR5rvpR71WwVZP6j3tNWr8jlPQ8d60k8jXPy7d8wjw9obnDEpvKzKreEzjfA0wCovNt7FLH9oxWmO5TF8JMg/U7+ToEv0fPAW475dXTXdue98/k/c+3+LCJNbHzBBx14CzpteKXKqGNA3jwgJUhfDsTISiN4gF222zIi1deY9BspjPl7jergbwh+ZPdfk2BLaPTDeNUycKdeiFoJEd8gKLvjMrnPa9IX4HwR9gJSjsQ0UWhnYuaXdk12zk8sVkGJAJLrphh5tHcd4LwG2rWcVXwM/2zw1YXQR+jffC1uxUEPVaq1fSf9RB6iEb8LgIollE+gDEybc+Dw3Q/gxVe5/Nu0vHHur6B+4YEcxvz3O5cYKUQTxDgG4mXJhqZ6z7etSWINChQyP6PUFFbsUIDXjfuHZ9oF4ce1NNOnn/RIwm/u/+AduDTtqloUooZjqak4VbvmBEZcW75liKm0MggeilL0nl5arItzTwE8OudJDBkJ/xnf1yZIgeFKSODIz5aQrIiSMJX3BGRxHEEQrm1xtwCfjtMPpFhFtG+o5fjMlCnowJ6+/HrG3FdZKn4/gv7qCxF2/3NW2J4OWuXbjEsUlSHu57DFvhrVl/q8jv81OfXhZKutYQWjaDWwOQHR+ym6wvMyQ9YfiiJpBXa+Ig9uGAbERyApc8wsCLcy0d8Msxx9PAfhrDa+Gf2yhYGA57t8iGxEcoI0A4B8zKVqYXKf4AdsrVzE9cUpfRN/HH8OGWyv9mKMTJyGJQql/OH5hYHnvJVKZXIz6l3nL/7gnpYaGtASiV1q+JwO7WSk1pfwT9SE4sFl7uS7f3pu4BwPhcz/wyN82f144yav11mrGqypOMaMDR27/L0sW1c3hWBBa8BMU/EuwF7ldclS9nxmFHOc35RLruyQ26cp1niukcpK42wg3ozqGQLoQRIoin0AWnUwnOmkdBEkILqFCiWgERDZuCB7G3pZJW/32HPgD3byO0lH8JF6OiINsUmM+75Y3qdvuepTHxXwpDa9Isero3x/f+UWGGUO12s+Ou2yQKtLsQaBNSTaGEBVCAtpJ58TgZ+KfVyhgRQdINr7GuGq9iRPQBY00anspxvsrhfffggqOariHO8h0jdEZPJarJJAufQbYgKiACtJ8iG6jlIs3GfWRI0jRYDw+kHPc2/A6fS5XGF360aX1I6iy5J1pZpN+6stJq5MQ8QRHopTJWQ0DW1Pq46BglmHH9av/X4tvLFFyyC4X6OB2jDb9+XwwcuJ2t/352IcJC06IsWKDsr6E6vF3hC3GUBUy9I7JbqlAh7zlYK52MITQzGINZD2p8+TJjmDycEr/UM/JHqBzbJniUzxg8vo2/FjpZggU8NuBsTZ5P/YZSgRsZcVKkhkGYAn+euvrQIiZ2LMwOygD0gW/zy7v+Z1aHfxKig7kkOR1ZuVCFE8FWx1unCnFHtkjFIx9JY4cYHboveIlF2IzNhfnKJncBt7DuZORqfAT3gQDZlIFNx06tSnTe1v5l7u7VSKMXRhc3bbeCqfvO/NSOqfLz1QYlj2b0C5sm0AcUe1RpC7rOu6muPLeJ38DOIhJHzs+wpqBZTHJr9zdnjZl+OyXaAAbgCsxamEQW91iGdRmVHqyT+0+XQxssYOF795eGYpsXy9Bik6Z4apt/AcuZQFu3XthVXvjyVCi0Rj3gXjOkFdT1YaiRe6yPRdBB2GorcxCzQQvjZXTuh5P4a7MD/6W0mJYoh0BzQHYC0O/T9v3d8GepAbQTytL7MWIWk9C2qZ0pPciuIfXNmGRWBUkCCts1BAsW39l4giNBCwDQ6CauWkz8iWaxx2krBQpKl0WyBBSd/SIJUFM4psvYNaGNk+xR18s0OrPqvxQvc3NNgVwpAljSM/wt3IzIcIsJHF/u0T60hXgEv4H0f44/SzROL0iGUZIfRZK6sJRGBQH2ZVrFCJ6ageJX7WTBLVwKAtxgIUK2dXAemsYgGm/CIe3JCmwL/YmEh8I8W4LrWzXq4vNF6/Sq1hQ2r4dndAO+HEZ8nYpPr+9pUCUgSvnN7aVWZpc/xJaj5L4U6W28hVZ2mb+UUKDpq0bSxKdkVr2SC/7Q/8WimMNDYCaExzXQ+RzZyv/4227pn/k3y1avulXGz3ujy+lqdciVVWHmPYyJPhqeoyDEkM6g46KL9kg912jsB1SGP7Yc2l7XENW59mh5RE+fNiW8wWjxW0Oa+xSe2+RTOgRA+Ojq2L8+g9sL7jKw7BPAPjnYTo8gMat4DurAKbJrtaRLZMzXkFyE7heHr9NsLJl/d1JLRwNoGDpnvLjyPNBUjW/2CTEEIyI6yq3oOJivAwe1yiJib7IUTkh5MCBSnEssvxOYJRUaR/ILAHMJpAoEV/VOCfBlh/I55gVYZWa+Y/5/AMs5Po1w9/18Q6V4ichv80Qr+Up7+2s8sV6zM7m78WMmQp3IR6uTJasqI2Vnr99KAY31BJVpBelRq2xjIruSHx/BAr2kSHA+Kuk1I9+Y1dEaSbfUpjcly0WDUh9x1VTkrUu1u6XN/i/SkFeO1k8o2o7s0rVXNI+VipXQt69H+yVDea7AYuvy9Rp2kKuq7o7mgcFCVq1Vbeyv++vDSKdYmKbyQ2N7ubU6u41Td59YNfRldl56ec0bl7hgyMUb/7/ifjdRXOVl1sTTMUiETnT+44vuAiiUeOHRgKmRlLgHp9iMnPPZVF3DqExLV1IPraZO/olA9QIc4bM2g6SPebITaH94rZn80oQzWzBAFUzK/B2vY39XGdPSTAZTFn1yAYcRHIhqWZs9+FtJvBN9f9lUxPFHUs3vyKBC8sFph/yee7KNIKyTinMNAs1+jcnVS4LPqR4L4cn3ancasZ6wBgexKIjjwf8KPkgUcMwZqk+KwDeJbmyGblqsRzSuhrwPq0U+n4n1ktcqI11Y4D/u93UrU04LgZwWPEZPrgjGUgciPrRa3BIJb6oT1s5VSfgiupwHaFYgF5sJ3VD0ZcT1zwdet8tPprxRq00SIZMZKZeVSIWD0ai82pPxH4PYLUGwUbW3ocaYouILRf9sF9DP1gaVfd4SDRUuKUtZRiG6lpSopmFO24N1vWq90caknzY91uUWX2v4+C/JHDd47e4h/g1Lf13euI6csefzsnQDTDsyrh5zSJDo26B81kY5RyKv+AnsvTnTl8uroRsh1KqeIUywpWImmlnnWT8rpNg822BjraGaWc9NHFzkUSmOmD/iJRdfRjno1JaeDVk8KBniY0vnMqdBG1BWRMsnUAhWxHJ4Jn5fXCltO2C5OV+x+jYocNhWw4Mgu3CVZp9erAEPsDEUsY4qaMitjRq6yJPn3nwkQRpFHGbXv187fPU/z8+BQ5/W4Qfg/qEmJKcp1T5VcrwLAlZQTomKAt/7xNlJIxlx9bCMVXnvk3Y8hB7kCTaSQmvjC8IXCHbJyMCFQV7qAKdmaihyV7zmpqWcDqfELQChm2KxmQJ1dPYJ1+jR+aYm3an5bPEoCdbsZauFF8qXHIhx8JKvRGgxPrTGHi8N5FcfuNsCA3xOkoSGX9Sxg6h5KEtoeFdkwf5BKqhJj5pcsBewAHkWng86BzAqt7R+a9TnyvLMWvmpI/0fkpRkbg731aWOnWOvbpz6f+nXSxGgrvs/B6xSgFPDo6Ty3ivL+CGitfK6XwdHA07TV/eK5vd5oyNe/Ay5wMdXiypEUWukN+jiuGmrVMkke/0DmXmtqqY3T45iLrqfgwRhXsT9kEdzcWVqM4OkAEqEzpjI0NHG74cslhQvDPbX/ZRp57/bcOuarHpCDakvzajblF2NXf0Wp0dO0NltExHFoY8myAlBu/SMn3VN6GF5faMq370MevoNi4eNRD8XiGUYh+QzVphqtLIeqyyt6W4MzTjwSLgAB0kITRYcG0KVi89iUgZMQdwIOfMUBmS/q1GpBtTFKqI2TwC3dz9oBnNzwi3Ru9yyNuX1mw1p0Sd8UNY0yVbdb7UrLrd0ldVrx2FWNVCEedkn0npe9xstIJvgMuRLA0DNN7vex3hfvGvV7qCuQi5ssNVYUkoyEjlFR3xCThuVCgwzK77JmvWMpeB0eR0O3SH9KK/1qaAkXK/bhyazFdT+WHrexsFYZuO5I1MiQWJzNDQ9r3act5mt0senky0dQ+Sb233mB+RX2AWxOf9SUcRtkKjiTvfSdcKHmLx7ns2F8MQdwFoKz7j4a7sPsuruL+BMHWuDj/VTfnVmG6nlzIjs92LVWKnZ010UOv156HJYQvhlSV+WzPv8EC/2A2LhBx0g1ZJ3vYQIu2G1AuhcZurtEOfbhcIsS6cq9P2YoRYTYTHeiXHNzKot/25uSAFs85GQhWyMz+2L3HBiszTmSdwtf0ZzHgGEBc90JD6yNfjwqF4FJ7AcuLYw5euNz/VEON3z2C021shibn6LGd4RjflA8XmBGSakJ0nkpplflYaQ9Awcv2eKYR4ebAVjhyErm4zHikUC5Vgtz/0UbghbNcX0RIEESW2GaGtFNYIYNPHJNtj4QMYLK7BrUOnzITF+Kx/FZG6oIeySnU+TJoZIkJBIqGLOYSkw+QuEbCbf1BM5nERddA8z+IFxYz7Goxg4XMpc3+L/Hx29UZzkNSY55Y2Swii1qxBWgBaRGpzI66cKfr6mHES+cbb9vNAdFPuBgJttyT/t3Jf+W5yRYt8M4VyIlEiUjAGqL3bqakDP5IwywMSpYeS1PmqWBsbUcV9bAavsLMnnEHvUue8GboIr+EeBMCk6XPBKFahrRZBTQq802IGDYOi++VjG7805Tleu2pX6H/IY/LDQVLnqVhxDaVonTvQqMffVvSwXp7EFNvR/XKxh+IJxO/W3tQeAi8Jn77E3itRU+tQEl8QQ65psW7FBQXujG6YYWK9XbPUPI/AkdVmaAuQQt7RPni0MhxB0Q8k6BqzhwbpyLMPa/XCkHdJLrO2xGupnrwYvt0OcF7Ia/hN9+HAekLtq8l+HcNGIY/JA2RPYOYGSEgAEVAgAACjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMApjbGVhcnRvbWFyawqAAw=="; + private static final String TYPE1_BYTES = "gAFfBwAAJSFQUy1BZG9iZUZvbnQtMS4wOiBUeXBlMVRlc3QgMDAxLjAwMAolJVRpdGxlOiBUeXBlMVRlc3QKJVZlcnNpb246IDAwMS4wMDAKJSVDcmVhdGlvbkRhdGU6IFR1ZSBGZWIgMjQgMTU6MzQ6MDUgMjAyNgolJUNyZWF0b3I6IEpheWF0aGlydGggUmFvIEQgVgolIDIwMjYtMi0yNDogQ3JlYXRlZCB3aXRoIEZvbnRGb3JnZSAoaHR0cDovL2ZvbnRmb3JnZS5vcmcpCiUgR2VuZXJhdGVkIGJ5IEZvbnRGb3JnZSAyMDI1MTAwOSAoaHR0cDovL2ZvbnRmb3JnZS5zZi5uZXQvKQolJUVuZENvbW1lbnRzCgoxMCBkaWN0IGJlZ2luCi9Gb250VHlwZSAxIGRlZgovRm9udE1hdHJpeCBbMC4wMDA0ODgyODEgMCAwIDAuMDAwNDg4MjgxIDAgMCBdcmVhZG9ubHkgZGVmCi9Gb250TmFtZSAvVHlwZTFUZXN0IGRlZgovRm9udEJCb3ggezEwMCAxMDAgNTAwIDIwMCB9cmVhZG9ubHkgZGVmCi9QYWludFR5cGUgMCBkZWYKL0ZvbnRJbmZvIDkgZGljdCBkdXAgYmVnaW4KIC92ZXJzaW9uICgwMDEuMDAwKSByZWFkb25seSBkZWYKIC9Ob3RpY2UgKCkgcmVhZG9ubHkgZGVmCiAvRnVsbE5hbWUgKFR5cGUxVGVzdCkgcmVhZG9ubHkgZGVmCiAvRmFtaWx5TmFtZSAoVHlwZTFUZXN0KSByZWFkb25seSBkZWYKIC9XZWlnaHQgKFJlZ3VsYXIpIHJlYWRvbmx5IGRlZgogL0l0YWxpY0FuZ2xlIDAgZGVmCiAvaXNGaXhlZFBpdGNoIGZhbHNlIGRlZgogL1VuZGVybGluZVBvc2l0aW9uIC0yMDQuOCBkZWYKIC9VbmRlcmxpbmVUaGlja25lc3MgMTAyLjQgZGVmCmVuZCByZWFkb25seSBkZWYKL0VuY29kaW5nIDI1NiBhcnJheQogMCAxIDI1NSB7IDEgaW5kZXggZXhjaCAvLm5vdGRlZiBwdXR9IGZvcgpkdXAgOS91bmkwMDA5IHB1dApkdXAgMTAvdW5pMDAwQSBwdXQKZHVwIDExL3VuaTAwMEIgcHV0CmR1cCAxMi91bmkwMDBDIHB1dApkdXAgMTMvdW5pMDAwRCBwdXQKZHVwIDMyL3NwYWNlIHB1dApkdXAgNDgvemVybyBwdXQKZHVwIDQ5L29uZSBwdXQKZHVwIDUwL3R3byBwdXQKZHVwIDUxL3RocmVlIHB1dApkdXAgNTIvZm91ciBwdXQKZHVwIDUzL2ZpdmUgcHV0CmR1cCA1NC9zaXggcHV0CmR1cCA1NS9zZXZlbiBwdXQKZHVwIDU2L2VpZ2h0IHB1dApkdXAgNTcvbmluZSBwdXQKZHVwIDY1L0EgcHV0CmR1cCA2Ni9CIHB1dApkdXAgNjcvQyBwdXQKZHVwIDY4L0QgcHV0CmR1cCA2OS9FIHB1dApkdXAgNzAvRiBwdXQKZHVwIDcxL0cgcHV0CmR1cCA3Mi9IIHB1dApkdXAgNzMvSSBwdXQKZHVwIDc0L0ogcHV0CmR1cCA3NS9LIHB1dApkdXAgNzYvTCBwdXQKZHVwIDc3L00gcHV0CmR1cCA3OC9OIHB1dApkdXAgNzkvTyBwdXQKZHVwIDgwL1AgcHV0CmR1cCA4MS9RIHB1dApkdXAgODIvUiBwdXQKZHVwIDgzL1MgcHV0CmR1cCA4NC9UIHB1dApkdXAgODUvVSBwdXQKZHVwIDg2L1YgcHV0CmR1cCA4Ny9XIHB1dApkdXAgODgvWCBwdXQKZHVwIDg5L1kgcHV0CmR1cCA5MC9aIHB1dApkdXAgOTcvYSBwdXQKZHVwIDk4L2IgcHV0CmR1cCA5OS9jIHB1dApkdXAgMTAwL2QgcHV0CmR1cCAxMDEvZSBwdXQKZHVwIDEwMi9mIHB1dApkdXAgMTAzL2cgcHV0CmR1cCAxMDQvaCBwdXQKZHVwIDEwNS9pIHB1dApkdXAgMTA2L2ogcHV0CmR1cCAxMDcvayBwdXQKZHVwIDEwOC9sIHB1dApkdXAgMTA5L20gcHV0CmR1cCAxMTAvbiBwdXQKZHVwIDExMS9vIHB1dApkdXAgMTEyL3AgcHV0CmR1cCAxMTMvcSBwdXQKZHVwIDExNC9yIHB1dApkdXAgMTE1L3MgcHV0CmR1cCAxMTYvdCBwdXQKZHVwIDExNy91IHB1dApkdXAgMTE4L3YgcHV0CmR1cCAxMTkvdyBwdXQKZHVwIDEyMC94IHB1dApkdXAgMTIxL3kgcHV0CmR1cCAxMjIveiBwdXQKZHVwIDEzMy91bmkwMDg1IHB1dApkdXAgMTczL3VuaTAwQUQgcHV0CnJlYWRvbmx5IGRlZgpjdXJyZW50ZGljdCBlbmQKY3VycmVudGZpbGUgZWV4ZWMKgAKNFgAAdD+EE/NjbKhan/77ULS7JzAqXMCrbi+Vm/INMgw3PCEo0KDOcHKx9nKgqjjDwOzrBLRMsXShwxYS1x/6IMkJVCVjeDcveVsL8pQfQ38Fn0GuBZjABRX+8YczNVfzLOMqnufUurZdpTQ/knB+LPzz6M5Eblraw5/Dfs5ktos1bODXEPRbHn8s12iryhQ2CDZodhoQCUZBYtBUwfa/LEajGbPGZFKHYxbBOpJkVtNmKVj9VnQNWFZzbmEE+BPtMZFWd3k07rHFRFrmv27lnlsZcItCh9tLm6+YgpGrwG/ed/zDHuFzCpT7xs7MdEpZqfajjiw9JKNtvO6XgdQ7y2rxwhv69q6/DIarClaEsha9+rFXfYTEkK8BcaUY1RI7beRwxnGx8Mt8pafG9aKKUpeQEJnqFv6Bk9Kz6/t+fAPkHdv8KUIErVw3AxMUFg63Ti+yeRa+1QQ7vDTTkV3O3Obim9olUKuQDhfmH2uWx+K3iBXFqwCLQTC/S/W/LDn9UCsxsphc4HA1txBMdO2NO8rPec0i5GLWOZZI5tOxhUsjPXLloUXLWOkU3I0wBTXW8TlAV2yBn+EPJ4XV14tyCoWHanYChLFqYcChHUHj+0GKluGz0gfPNQ4xf3u6+jyJLmvDFxiNxtSNAud0yBZx12ouXbVSeHGYXWk84KA/Sus2DDbG/E6H+kx2MfnEVMz2yZm/lW6a4w5Pevvdoxfj9BMLm1dBkDCxHQsjw1dbv7yBz3j6kibdv2I4JFxLoEW8qsxcH2SXXgJpM3KrNQlPRIqq8IKmxH3ZllsL/QQ8YJFg+KJjygCl9QOmrL/1FXx/JXmx0m6ynXaUfF1PwtiP7e1ISNfaExaiL1C9OtTK2T4h2WhRPW57ycPj/dYRfjKD7OvXXYQ+Co+s+jCWDRpbwGTLlDP0XQFMBNxx4cBogjdx6ouFfm8lXgfeQf/GC0CtQolv6YH1O06mdXeZ1hqAFwHALulGBr2WdAoV9wBD5SBSeMeIV3waNCP5P0xB7rP7uXTZv/oscgXK/61/3tsjyAXyZASQxvMf8uyWsThQA9TTEOM1o28z9bj6Yhs0Snwl2CxemFy3xgyidcNyBDRsCDFwYKjsejtr9sZGIXAFJK2djcN8aUa549kahghsM9NAB65fQFOwjWjPAZEnunfOsU/LXlWLjpPdul4+P/iseq37udumJc/dZMXm6KXDL6pesrEVc80hrFtnnPWTyaNUP1im/rQrwZvDnVJ0Yvg5XSGo6crcpdPE5pUviEVHB2W8aCI8W+2QrxfIXdN8g4bPW7FEjuoe424XoHpyyIkD1+0MyVNgCVywIoFjugUfAu5NKoFo+7+WyIvtrHlgEuMjEK70a2RhFp7wVuod4VD0EHJ+MWXUglKomSB7mA07KQiQDck++iAwwPmxKLmUdUItfeOcEji8RBoUkcTu9YuNij22HrsBxawVzE8Yz/ZRKqlbHpuuRHao7z2gIobOg8wHb/+lMC1o4vjwayYLSNfFyvf6XivjCkz2KUQlrLX+8WyTVA6JDHsI1xfhI+kr3NTJ2fZBKweobTge72fpGuiVEjV82l52w9UZBH9P70XJUqd1lYIstqLN+mDdVSJ1axsp9sDufLMEFWX9xUlCOyAdOefz02cniXnJcxIVdH8q01OLa5jxMlJ+CBeXO0D4j+r7qY8ZCTyeRT9eEpAykqEajhOoZPjhjtMlw5jgyZJ9COaM30bC3coKF93YSmRQaIkE9b1kw5dGlFvpGGYL4bAzo0SNSkIO00So24z3TISF9aJ1ssBn2072KoV99O/5QN5cWKdDvaSFkMJp0YFRHXNNHe1Zo0kV5Shq0uEygfikR1XDyuLuiycQSHWnFxVr2xSaMnA5CfKwfQu8hQ5ljap6spe1+Qh6Am4TkDa/CaO1QlQ03mRUcyyxFwGZJljNAkI7mVgG6DUlxxVSK8wJMH7otzpS0L2LYTHTG6LV0iXQBjNB4wuH5LqyqTgsiA8x7UASJFYY0RJGrD9moFp/ON0t+NPT6Rfw3Semq239oYpxMQr/mHkHfExaIA0AX31DjfMqWzj4bypd8B9zZFvOogC2EHPobmhYhjzFcbMdVXwnAENC0EVbEMdLzDQFeSFRpDwF6MJ5CyqFS4wD7PsyF/aVlPwi0rLnr6+xygmhFhtpsOi/zVT8qT0BCWBG4+9UZIh6MfLm+JWkLNQcEGmhTglxzIhntDTZkBO9MkYhs2vOM9pAWS9Pjcba8OR6+aiVMOZVReGm7FH3BixWPTHOeqMGpZYH09MRTScHecT7G/TgiZIcUReqM7OdmyExBR2IJ0tLuaEuHxyn7SC5Gdlcf9mL9Kz15sZFzTkZMjJAtCOTPMaHq/0eQIr/Ln1YMDd6O+ApErFrIGDQd4hBA2H8tIZMIuSct/KMzwj83QiB+wvvF/ec6vJCSEjU7FPayLiPt9ELxOKC0p3+k4wfc4PCX0VLozKllmEQ2+m7gkcI+mvWXGkjziNZtg7HsgEZbRTjH2H8LuaonHwNzpASWjt8e6deQzOglya7sRNKamea3s1oGPx1ZAZmGs5EZGtW0wT7h7WbQkM0Pv0Xcmb2d+0MWyOpvThTQOqog9wOrBZp8WQwFMbimf5h3nqrmgeRcmQL5YGrA0lLaShxIB9fiC8RBJ2ndEs8vW4MJU3u95ZJmQUwTDewI2WhsgV4CG9t74y790nLu/OWuRtm83j6FLEvtmgs0fMoE0WAtqrbzB2BLblT4GN7VXbZSE7K8B+zPTlx2Lw1mH4AwW0RK/6Hl6P8Y2KMsVSnLDDhKXxXSpaQQiiMV6lGAT4JLO9dh4cSAl0KVseZ62jLfcpN3T5UpiNAXr/OMqe0Vki/TLdwUCbfNL606j7Ki8v84s/ob3kaoYzKE5HDhgxKRYkd5NXmT321GSDdGW5OG4J5kwcF7KgJ7lY4HwLAkumbF4oMWMDz3FYRK5BxlYA65pSMxhCYKV5XMg2cPDPpLj8S55CI0Nq8WX8vnIY8JhSA2nbnTwzrSU30sN6BpXPILan6UBbNn91PgLOawA9Qnqebuq3BwqHOYAFecMIf3W/70HZ+iFc87AiEPK7kmn2Fm4az69PV3jVBZlIKAYGUHQvTm3+KYnNEGKSoOLB0bUGhklOy3vnbCuZt7Z2i0OpM2d7J9SqaCF1qrmIItsPKwGI6E1XyOhs1pVMwbWUzwHh4EU/wvU0bmcMinR9PWfvyusq4wUeP/rSQoRd7TfFNHZaCg9HJkgDdtjcTjpPBv/SPMNahf6KdknrkRunKE1+XxvdjKxo+7DXcijK8kPwDB5ZAv//BxZ6NEkippShPuCXnlP6huGWMNaM4Ascw+BU3R5P6SHODlrafn48qAqemBBnoUfmCw2mu+su+agNtVYx5MEacrmpyZGaQizFF/IAygncdllch8YCF6upwv0J8ehKxqIrdB5EpS8NwVmSl9HnL4Xkob5/T/PzCK5wCZYkECwKZEF1atSrcoKBeIHzn7FsCGLNDU7WPEseSYZvRNOUmunflZDysYSLBf7XMKkeaLijeB1qrD4P4fone9c9g1KrdZO597AT3DFfL/fTuKfvzLFS2dFJW3JxBhtIAEbVyd7hhE1ik1QulOOh7ZyPiuu60urRcrGU+fQVbXtdCVCZ+NMn/gvFbipQ+4w4Ry8xfBpyWQrIFTyzQ/hyBgecQnA7iJhrSiV56aCErXrHDhNCXvApKd9+rUB6w8Ltrp2ag/AIn3jA414KjLwvcvh2ztTYW9kGsA9c/TQYKYXrgbaWoSd7Z357cmY9I4UOEVad3Fxk8QZ2zWFdvydAyOrGU+7lo6fvirobuADWo1P6/4BSh7ZdzHxs5s3RvDAYrWwoO/WpmMdWzF5RvAXKXXcYhme5QBalZw270QjmB3VOvaZLQgkBFYV/USdi2Pl5yJRxmeRLHxW+9U3gi/vUxowUiFPaJ4hjgzuogct3zF0oJ3ZrSamVut85DZC88fY5RdC/GR53FR+nt51wzu+PPjh2UtQgZTdTD4tfmZ8MGc2BaHiQ+yhEPpXWi2sfkFwkVlOMnHrJOFwKil0Uy8OoHHiDlSQNX22YinDSmcY8silpqltMmVnibm4mQodIocSfNY+DMA6v5oiFFsXUCEiS5P8975OihDJIokTGt4E/z7VQag2vChKPSEMaK6NIhQjGn1qAVq26MDnXkLe1ScmDDVhdBH7F9OiPdGEoGz0R/EHqAiPC6LaGByJwvKm87QgQ0bP/CIWKAGOmV9b9GV18G8nN4+T1xu4bcatp+0RzLNXxPXBMvFYBDvhBv0JqM1Bzkff5VHc8Cly7qfWJ9GPfghDC1cdFtXf/qNzdrCNvEeT5BloKFZ6s7vkDEfGPLqgMxt5T3ywQPJhdh0J5m7HurwNA+BwBycoPts7h33elU2NlSNe7iRbTViFFLirJdYGSlZaelccnNqAJEWC55V5gxbZiA+nym/7KRlEeUpFmLtFBBPKHOsbhK5uNWw2w2cCCJuwlC8FcLoqsGaykaQimUJNrg4r5lDLwcdIPslHivyRywMP4f/rr509DL/ZsvrEZHXpC1UHiuUnpoYp5uD8Sd5t7TCG1pKC5Wqw6QnE3j5Ra0Zd3WaY9MJkTtmj5zAmPvBWtda/uhdM++vqUD5pm2FkmZjpcxdQ+Dw2ebN3eOKQsDcRrNc07d8qWC2XkqAxyolN21qFg4FBcM68Szc1/50XwOK8QyEBhG24XJbMDfwTGOtzKCExUaTje30HoD3Nzzee39rTe8t3aQJ56VVEdDPBsxqjrYHdbEPJFqwRSExlngpbIWjOiEyWu5YbcX0cQgk/TSlnRGV16o9pg2qBbcvWm5gpPZ0Kj3QrxPpmJIUqq6tYoc2zt2LZUbrTnopjvISz8+fm1jIQJt2vpRgnwLwC9uAsf3vBEoZvnxGQKVsG+1B6uVnlK4hKB0retrDEbdcGGpiACMc8IuXH+vQztfpFYR8aCY79MpHm+oHiIUWsBiosbWoYNOZv1D3T28W+A3xBrKABzqhwvymGnMrec/JzNPObaj4szJYJegxC7SyWuNbA8Je5xNon8SKM9KvtSh6MWDOhOMk4eTOyiuwUpUYRiMpazBdMe0msnhuE2qlRvQC08QaDEUZMN+EWEX63wnjN6CfXw5qIdlAHoG9ZypCQy7G3mYVqYLfywMdFBKE7JY+u31XsYp7UNuRkKAN6VGQux6Qym64jGLBO5M5gvzIHmUluXR+y9D6SzcOtocea4Y9/YXggV1MWSmW2dq7hvV58ZYbix1wWwuv10uG8OIUwiaMet6vVag6bIK1RG+7yPB3caz9gCcqoXnU4zlHNYqu6Zcg3226k91SSDWcvy5fHoKSZOtSwkIEb0m+dJURp7QFJ1AeuWoy6oxD6xAM995YBRyLCX3N9gHGiJZ33BbKq85oGrzQN8SeXs6j8+FrglsRqcjvdk7vgZCLRl7qcWsmkFXCzikZsHPn2stZMJm7bVfILwdMTF4A42iV9wy1idF4qXYzAZHLdEP9BDpdGMKRiICY8avlTv0nYMW1qgBz4cXrdmSrBTPV4Ts5/3yDP44/foH/rju3wLoWprGkQMU1cNj66iCCuKnhExh/bRb40wLE1N6H86Le9WYBUbJEJA5Knx3ELAboZ2xK+e8zK2jPZdcv1AGGfPE7V6G7/7YCOepiP4cv+RTru77QaND/sf+eX1N+pb8WDxgTMPQ5/AJeibBWmEO7zw+L8CBY+rAphiofoUzY9U32dBwf82tdPDwvqrtik+HqZfG74h6We9fRJrfUjR3J/5g7P8IpcJAI7XQ6N7IvujSTMCtDtOd5Pf4mzuvFj/y3A5cLXuFT8wvqtm+BaIMLCe0lgWg4h6vtXEeKGmMsCVnZP16QiuaftHgo71UaXH18Z/rafUcV1TirxHs9ddST6hNPZ31IMPVt6L2Z8p3ucsMRPjlqY4SpYjQClVEiUc6R2FPbGstgmH/OU+uDx7oNhRgFV91/h3p/9klZ1PXOHWzTtPN91bKkITWttjft16yhKkY9Qi2vXG/f8BdyNenjFoUHATcsr4n9UtjNFBIptLX7UQFf4KkNnbyeKV1Cqdl3L+NEz8/gXBeAXJgEEHNRBjz9sQLiyj82rL4wgonrKDtxvVRCBVOc3g2BYdnqsKpe7be5GFrhxyYIufRfj64AVfn9tExQC4y7NoQcMUCXHcDXSQaO4DI5kh4hWftJhYRQciNx7okOXWgQakxRz0BLMquW2zr16Eh+a1wMV+RRRbnOQUrdSuOptLp0HeXxDPBmd23mb+o9EaBZopKJcsZ5uVRnRPG5MpSDZBX/dD+ZcFhNxAkwftTJGxbHU2FvDZxZMau4ORlvRpe0jQqK0KAPjVhxygj+efvJhwqE7SjMk92H8tSlUcJNKTPRWlbzC+nXIfQmrUKWHB9WkJYPkygDNksMh29qtDKBoTrPFKd8TjtqAmPPYOARdnuOZ5GBLvk29+HuyIxm1reGzc0gAVPFM4+a5KuvdXP5RDQsfOYhrjfhryXiSjnafEa4Vr8bQV4tCrvM1wB6GwJNUMUIOLnZMKC1Wpa42CVKIjTsED1U11qk0c/z2pdQSW8bkze+S96EspK6YwFRpG+l2w57H45pXKCM/OtEoUFAsNYp0aUI03VLX0vayOPXwZjxfm0Sbxw8GlVveOcDjxP9PubGwJWB3zThbP3mWiciTTtQYHzJ12nStPUWrHe09we4wUPO5jzfTMVhXA/IGP6+xomVdm6BR6Iffn12RP9G+HUeWBB/vSHCL6FMcBSGEKo8kX9sVT43WPthgSJGxH+5cxSVsRZSpa3WEwJI7W6R30TpkUmhLMOROdMF9Oh6+G+73HC6kdt27xFupu9ZkFRCBxpa/QAQxLUKMekm90PTVMdiWBALcRG/5a+GbCJsEwasen3e8NWD8CDFqPPeDNQEhkDNzaWbvtiNttHV9ESmFC5Ty642U6taS7g3yI/aeMBjh6zebr+UmXv17XeNyO6N6KJBOstv8Ry1f/TmkuuQm3fXu3n99fkb5gLZUHIvUuQ+Q3vTnWrPkCt2Ezbp125iAKvlRyhk1pXLvrr/EA1OhtaGnLqEeq5XqBpwh6StXPQXk9qfZT9wNzhylhcM929FxVeGolbk+68k//XdoJhQg4nxUqYBavhqCEpNTvL+tCJP/DOX4MSAH+3VYuzPQGp03X4exr4V3CKf9vCE6BUiBvHjDic5quOPsKCg8oYqU98UUr7f8aF1IwzW5woFt5CcScIS7mxk93T9ZB3WasKAPuMgV97OniMMOLqV1q6x5g1kHT67a7lQG3t1rPIFzDu/YvRh0ro/ldnLOAG7kgcZgBxG+GUlSMJMFzA51cKCE6zulbDK0U4lGyF+0fQzK5J7JGySCNyspkbL2KoioJJPWZ9kEggqZlKQk9ps0HQbBLNKkad1ZVIyuJHrQTddcr6SB8TnUI+FEH9/dyBpfXAx3XCL9xWWSqzEsQ9h24a+oRnfkm9lEQDrR9YpPyFavVP2QhljRuQJ6TXwqrrBe0LbEL7kn3st3w98B99u4MtdP/mbeSDjk5/8iYKLsilg30/mllHfbIv8kue12+JmZJo01gCc+Dehm0rlMPMxeqqrCKlXj5n5FerqqPfkNs/rKfXFFlgu5cl/cBKqP17G4xLPLOLA7wHfabHXZB0vQDeE9SpIAZPmzR9VjXx/quSDUV8p4ABFQIAAAowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKY2xlYXJ0b21hcmsKgAM="; public static void main(String[] args) throws Exception { diff --git a/test/jdk/java/awt/im/8041990/bug8041990.java b/test/jdk/java/awt/im/8041990/bug8041990.java deleted file mode 100644 index c5ddbac42ba..00000000000 --- a/test/jdk/java/awt/im/8041990/bug8041990.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2014, 2025, 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 - * @key headful - * @bug 8041990 - * @summary Language specific keys does not work in non-default AppContexts of top-level windows - * @author Petr Pchelko - * @modules java.desktop/sun.awt - */ - -import sun.awt.SunToolkit; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.InputMethodEvent; -import java.awt.font.TextHitInfo; -import java.text.AttributedString; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicReference; - -public class bug8041990 { - private static JFrame frame; - private static JComponent component; - - public static void main(String[] args) throws Exception { - ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group"); - ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG"); - try { - Thread stubThread = new Thread(stubTG, SunToolkit::createNewAppContext); - stubThread.start(); - stubThread.join(); - - CountDownLatch startSwingLatch = new CountDownLatch(1); - new Thread(swingTG, () -> { - SunToolkit.createNewAppContext(); - SwingUtilities.invokeLater(() -> { - frame = new JFrame(); - component = new JLabel("Test Text"); - frame.add(component); - frame.setBounds(100, 100, 100, 100); - frame.setVisible(true); - startSwingLatch.countDown(); - }); - }).start(); - startSwingLatch.await(); - - AtomicReference caughtException = new AtomicReference<>(); - Thread checkThread = new Thread(getRootThreadGroup(), () -> { - try { - // If the bug is present this will throw exception - new InputMethodEvent(component, - InputMethodEvent.CARET_POSITION_CHANGED, - TextHitInfo.leading(0), - TextHitInfo.trailing(0)); - } catch (Exception e) { - caughtException.set(e); - } - }); - checkThread.start(); - checkThread.join(); - - if (caughtException.get() != null) { - throw new RuntimeException("Failed. Caught exception!", caughtException.get()); - } - } finally { - new Thread(swingTG, () -> SwingUtilities.invokeLater(() -> { - if (frame != null) { - frame.dispose(); - } - })).start(); - } - } - - private static ThreadGroup getRootThreadGroup() { - ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); - ThreadGroup parentTG = currentTG.getParent(); - while (parentTG != null) { - currentTG = parentTG; - parentTG = currentTG.getParent(); - } - return currentTG; - } -} diff --git a/test/jdk/java/awt/image/XBMDecoder/XBMDecoderTest.java b/test/jdk/java/awt/image/XBMDecoder/XBMDecoderTest.java index 9694043d1bb..9d2a23bd29b 100644 --- a/test/jdk/java/awt/image/XBMDecoder/XBMDecoderTest.java +++ b/test/jdk/java/awt/image/XBMDecoder/XBMDecoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8361748 + * @bug 8361748 8377924 * @summary Tests XBM image size limits and if XBMImageDecoder.produceImage() * throws appropriate error when parsing invalid XBM image data. * @run main XBMDecoderTest @@ -63,7 +63,9 @@ public class XBMDecoderTest { boolean isErrEmpty = errContent.toString().isEmpty(); if (!isErrEmpty) { - System.out.println("Expected ImageFormatException occurred."); + if (!validCase) { + System.out.println("Expected ImageFormatException occurred."); + } System.out.print(errContent); } if (validCase && !isErrEmpty) { @@ -91,9 +93,7 @@ public class XBMDecoderTest { g.drawImage(img, 0, 0, null); g.dispose(); int[] pixels = bi.getRGB(0, 0, w, h, null, 0, w); - if (Arrays.stream(pixels).allMatch(i -> i == 0)) { - return false; - } - return true; + return !Arrays.stream(pixels) + .allMatch(i -> i == 0); } } diff --git a/test/jdk/java/awt/image/XBMDecoder/XBMDecoderWidthHeight.java b/test/jdk/java/awt/image/XBMDecoder/XBMDecoderWidthHeight.java new file mode 100644 index 00000000000..7a9328b1554 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/XBMDecoderWidthHeight.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2026, 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.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Objects; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +import javax.swing.ImageIcon; + +/* + * @test + * @bug 8377924 + * @summary Verifies XBM decoder parses width and height in backward-compatible + * way: `-h` corresponds to width; `-ht` corresponds to height + * @run main XBMDecoderWidthHeight + */ +public final class XBMDecoderWidthHeight { + private static final PrintStream originalErr = System.err; + + private static final String dir = System.getProperty("test.src", "."); + + private static final int WIDTH = 8; + private static final int HEIGHT = 1; + + private static final Pattern glob = + Pattern.compile("valid_WH.?-.*\\.xbm"); + + private static boolean matchesGlob(final Path file) { + return glob.matcher(file.getFileName() + .toString()) + .matches(); + } + + public static void main(String[] args) throws Exception { + final List errors; + + try (Stream files = Files.list(Paths.get(dir))) { + errors = files.filter(XBMDecoderWidthHeight::matchesGlob) + .map(XBMDecoderWidthHeight::testFileWrapper) + .filter(Objects::nonNull) + .toList(); + } + + if (!errors.isEmpty()) { + errors.stream() + .map(Throwable::getMessage) + .forEach(System.err::println); + throw new RuntimeException("Errors found: " + errors.size() + ". " + + errors.get(0).getMessage()); + } + } + + private static Throwable testFileWrapper(final Path file) { + try { + testFile(file); + } catch (Throwable t) { + return t; + } + return null; + } + + private static void testFile(final Path file) throws IOException, Error { + try (ByteArrayOutputStream errContent = new ByteArrayOutputStream()) { + System.setErr(new PrintStream(errContent)); + + ImageIcon icon = new ImageIcon(Files.readAllBytes(file)); + + if (errContent.size() != 0) { + throw new Error(file.getFileName() + " " + + errContent.toString().split("\\n")[0]); + } + + if (icon.getIconWidth() != WIDTH || icon.getIconHeight() != HEIGHT) { + throw new Error(file.getFileName() + + " Unexpected size: " + + formatSize(icon.getIconWidth(), + icon.getIconHeight()) + + " vs " + formatSize(WIDTH, HEIGHT)); + } + } finally { + System.setErr(originalErr); + } + } + + private static String formatSize(int width, int height) { + return width + " x " + height; + } +} diff --git a/test/jdk/java/awt/image/XBMDecoder/invalid_WH1-no-height.xbm b/test/jdk/java/awt/image/XBMDecoder/invalid_WH1-no-height.xbm new file mode 100644 index 00000000000..09fcfe0d576 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/invalid_WH1-no-height.xbm @@ -0,0 +1,3 @@ +#define width 8 +#define width 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/invalid_WH2-no-width.xbm b/test/jdk/java/awt/image/XBMDecoder/invalid_WH2-no-width.xbm new file mode 100644 index 00000000000..fa2e6d9546b --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/invalid_WH2-no-width.xbm @@ -0,0 +1,3 @@ +#define height 8 +#define height 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/invalid_WH3-no-width-height.xbm b/test/jdk/java/awt/image/XBMDecoder/invalid_WH3-no-width-height.xbm new file mode 100644 index 00000000000..cf22314b055 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/invalid_WH3-no-width-height.xbm @@ -0,0 +1,3 @@ +#define test1 8 +#define test2 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH1-th-ht.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH1-th-ht.xbm new file mode 100644 index 00000000000..c287afe79b3 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH1-th-ht.xbm @@ -0,0 +1,3 @@ +#define th 8 +#define ht 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH2-h-ht.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH2-h-ht.xbm new file mode 100644 index 00000000000..58605910d70 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH2-h-ht.xbm @@ -0,0 +1,3 @@ +#define h 8 +#define ht 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH3-ht-th.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH3-ht-th.xbm new file mode 100644 index 00000000000..7d8bc74d1ec --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH3-ht-th.xbm @@ -0,0 +1,3 @@ +#define ht 1 +#define th 8 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH4-ht-h.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH4-ht-h.xbm new file mode 100644 index 00000000000..94afe2c39b9 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH4-ht-h.xbm @@ -0,0 +1,3 @@ +#define ht 1 +#define h 8 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH5-w-h.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH5-w-h.xbm new file mode 100644 index 00000000000..cf423b737a1 --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH5-w-h.xbm @@ -0,0 +1,3 @@ +#define width 8 +#define height 1 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/image/XBMDecoder/valid_WH6-h-w.xbm b/test/jdk/java/awt/image/XBMDecoder/valid_WH6-h-w.xbm new file mode 100644 index 00000000000..d9641b9009f --- /dev/null +++ b/test/jdk/java/awt/image/XBMDecoder/valid_WH6-h-w.xbm @@ -0,0 +1,3 @@ +#define height 1 +#define width 8 +k[] = {0xAB}; diff --git a/test/jdk/java/awt/print/PrinterJob/ExceptionFromPrintableIsIgnoredTest.java b/test/jdk/java/awt/print/PrinterJob/ExceptionFromPrintableIsIgnoredTest.java index a62ae536e1b..4c2ff370cb8 100644 --- a/test/jdk/java/awt/print/PrinterJob/ExceptionFromPrintableIsIgnoredTest.java +++ b/test/jdk/java/awt/print/PrinterJob/ExceptionFromPrintableIsIgnoredTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,15 +21,16 @@ * questions. */ -/* @test - @bug 8262731 - @key headful printer - @summary Verify that "PrinterJob.print" throws the expected exception, - if "Printable.print" throws an exception. - @run main ExceptionFromPrintableIsIgnoredTest MAIN PE - @run main ExceptionFromPrintableIsIgnoredTest MAIN RE - @run main ExceptionFromPrintableIsIgnoredTest EDT PE - @run main ExceptionFromPrintableIsIgnoredTest EDT RE +/* + * @test + * @bug 8262731 8268675 + * @key printer + * @summary Verify that "PrinterJob.print" throws the expected exception, + * if "Printable.print" throws an exception. + * @run main ExceptionFromPrintableIsIgnoredTest MAIN PE + * @run main ExceptionFromPrintableIsIgnoredTest MAIN RE + * @run main ExceptionFromPrintableIsIgnoredTest EDT PE + * @run main ExceptionFromPrintableIsIgnoredTest EDT RE */ import java.awt.Graphics; @@ -64,14 +65,6 @@ public class ExceptionFromPrintableIsIgnoredTest { "Test started. threadType='%s', exceptionType='%s'", threadType, exceptionType)); - String osName = System.getProperty("os.name"); - boolean isOSX = osName.toLowerCase().startsWith("mac"); - if ((exceptionType == TestExceptionType.RE) && !isOSX) { - System.out.println( - "Currently this test scenario can be verified only on macOS."); - return; - } - printError = null; if (threadType == TestThreadType.MAIN) { diff --git a/test/jdk/java/awt/print/PrinterJob/PageRanges.java b/test/jdk/java/awt/print/PrinterJob/PageRanges.java index 691357d5a3c..3a84725910c 100644 --- a/test/jdk/java/awt/print/PrinterJob/PageRanges.java +++ b/test/jdk/java/awt/print/PrinterJob/PageRanges.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6575331 8297191 8373239 + * @bug 6575331 8297191 8373239 8378417 * @key printer * @summary The specified pages should be printed. * @library /java/awt/regtesthelpers diff --git a/test/jdk/java/awt/print/PrinterJob/PageRangesAuto.java b/test/jdk/java/awt/print/PrinterJob/PageRangesAuto.java new file mode 100644 index 00000000000..8d50ef9c2c2 --- /dev/null +++ b/test/jdk/java/awt/print/PrinterJob/PageRangesAuto.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2007, 2026, 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.awt.Font; +import java.awt.Graphics; +import java.awt.print.PageFormat; +import java.awt.print.Pageable; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.List; +import java.util.stream.IntStream; + +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Destination; +import javax.print.attribute.standard.PageRanges; + +/* + * @test + * @bug 6575331 8297191 + * @key printer + * @summary Automatically verifies all the pages in a range are printed + * @run main PageRangesAuto + */ +public class PageRangesAuto implements Pageable, Printable { + + private static final Font font = new Font(Font.SERIF, Font.PLAIN, 50); + + private static final int MAX_PAGE = 10; + + private static final int[][] ranges = { + {1, 1}, + {1, MAX_PAGE}, + {2, 3}, + {3, 6}, + {4, 7}, + {7, 7}, + {9, MAX_PAGE}, + {MAX_PAGE, MAX_PAGE}, + }; + + private enum Type { + PRINTABLE, + PAGEABLE + } + + private final BitSet printedPages = new BitSet(); + + /** + * Configures a printer job and prints it. + * @param type the type of the interface tested + * ({@code Printable} or {@code Pageable}) + * @param pageRange the range of pages to print; + * if {@code null}, print all pages + * @return a bit set of printed page numbers + */ + private static BitSet printJob(final Type type, + final PageRanges pageRange) + throws PrinterException { + final PageRangesAuto test = new PageRangesAuto(); + + final PrinterJob job = PrinterJob.getPrinterJob(); + final String baseName = type.name().toLowerCase(); + + switch (type) { + case PRINTABLE -> job.setPrintable(test); + case PAGEABLE -> job.setPageable(test); + } + + String fileName = pageRange == null + ? baseName + "-all.pdf" + : String.format("%s-%d-%d.pdf", + baseName, + pageRange.getMembers()[0][0], + pageRange.getMembers()[0][1]); + + PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); + set.add(new Destination(new File(fileName) + .toURI())); + if (pageRange != null) { + set.add(pageRange); + } + + job.print(set); + + return test.printedPages; + } + + public static void main(String[] args) throws Exception { + final List errors = new ArrayList<>(); + + for (Type type : Type.values()) { + BitSet pages; // Printed pages + + // Print all pages + System.out.println(type + " - all pages"); + pages = printJob(type, null); + if (!IntStream.range(0, MAX_PAGE) + .allMatch(pages::get)) { + errors.add(new Error("Not all pages printed in " + type + ": " + + pages)); + } + + // Print page range + for (int[] range : ranges) { + System.out.println(type + " - " + Arrays.toString(range)); + pages = printJob(type, new PageRanges(range[0], range[1])); + if (!IntStream.range(range[0] - 1, range[1]) + .allMatch(pages::get)) { + errors.add(new Error("Not all pages printed in " + type + + " within the range " + + Arrays.toString(range) + + ": " + pages)); + } + } + } + + if (!errors.isEmpty()) { + errors.forEach(System.err::println); + throw new RuntimeException("Errors detected: " + errors.size() + + ". - " + errors.getFirst()); + } + } + + @Override + public int print(Graphics g, PageFormat format, int pageIndex) + throws PrinterException { + printedPages.set(pageIndex); + + final int pageNo = pageIndex + 1; + System.out.println(" test.printPage " + pageNo); + if (pageIndex >= MAX_PAGE) { + return NO_SUCH_PAGE; + } + + g.setFont(font); + g.drawString("Page: " + pageNo, + 100, 150); + + return PAGE_EXISTS; + } + + @Override + public int getNumberOfPages() { + System.out.println(" test.getNumberOfPages = " + MAX_PAGE); + return MAX_PAGE; + } + + @Override + public PageFormat getPageFormat(int pageIndex) + throws IndexOutOfBoundsException { + checkPageIndex(pageIndex); + return new PageFormat(); + } + + @Override + public Printable getPrintable(int pageIndex) + throws IndexOutOfBoundsException { + checkPageIndex(pageIndex); + System.out.println(" test.getPrintable(" + (pageIndex + 1) + ")"); + return this; + } + + private static void checkPageIndex(int pageIndex) + throws IndexOutOfBoundsException { + if (pageIndex < 0) { + throw new IndexOutOfBoundsException("pageIndex < 0"); + } + + if (pageIndex >= MAX_PAGE) { + throw new IndexOutOfBoundsException("pageIndex >= " + MAX_PAGE); + } + } +} diff --git a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java index 2c69c5691b8..8ef5483bd82 100644 --- a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java +++ b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -73,7 +73,7 @@ public class TestCaptureCallState extends NativeTestHelper { } private record SaveValuesCase(String nativeTarget, FunctionDescriptor nativeDesc, String threadLocalName, - Consumer resultCheck, boolean critical) {} + Consumer resultCheck, boolean expectTestValue, boolean critical) {} @Test(dataProvider = "cases") public void testSavedThreadLocal(SaveValuesCase testCase) throws Throwable { @@ -90,14 +90,21 @@ public class TestCaptureCallState extends NativeTestHelper { try (Arena arena = Arena.ofConfined()) { MemorySegment saveSeg = arena.allocate(capturedStateLayout); + // The existing value and the value that it should be overwritten with + int prevValue = 24; int testValue = 42; + errnoHandle.set(saveSeg, 0L, prevValue); boolean needsAllocator = testCase.nativeDesc().returnLayout().map(StructLayout.class::isInstance).orElse(false); Object result = needsAllocator ? handle.invoke(arena, saveSeg, testValue) : handle.invoke(saveSeg, testValue); testCase.resultCheck().accept(result); int savedErrno = (int) errnoHandle.get(saveSeg, 0L); - assertEquals(savedErrno, testValue); + if (testCase.expectTestValue()) { + assertEquals(savedErrno, testValue); + } else { + assertEquals(savedErrno, prevValue); + } } } @@ -127,37 +134,45 @@ public class TestCaptureCallState extends NativeTestHelper { for (boolean critical : new boolean[]{ true, false }) { cases.add(new SaveValuesCase("set_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), - "errno", o -> {}, critical)); + "errno", o -> {}, true, critical)); + cases.add(new SaveValuesCase("noset_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), + "errno", o -> {}, false, critical)); cases.add(new SaveValuesCase("set_errno_I", FunctionDescriptor.of(JAVA_INT, JAVA_INT), - "errno", o -> assertEquals((int) o, 42), critical)); + "errno", o -> assertEquals((int) o, 42), true, critical)); cases.add(new SaveValuesCase("set_errno_D", FunctionDescriptor.of(JAVA_DOUBLE, JAVA_INT), - "errno", o -> assertEquals((double) o, 42.0), critical)); + "errno", o -> assertEquals((double) o, 42.0), true, critical)); - cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L), critical)); + cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L), true, critical)); cases.add(structCase("SLL", Map.of(JAVA_LONG.withName("x"), 42L, - JAVA_LONG.withName("y"), 42L), critical)); + JAVA_LONG.withName("y"), 42L), true, 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)); + JAVA_LONG.withName("z"), 42L), true, critical)); + cases.add(structCase("SLLL", Map.of(JAVA_LONG.withName("x"), 42L, + JAVA_LONG.withName("y"), 42L, + JAVA_LONG.withName("z"), 42L), false, critical)); + cases.add(structCase("SD", Map.of(JAVA_DOUBLE.withName("x"), 42D), true, critical)); cases.add(structCase("SDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, - JAVA_DOUBLE.withName("y"), 42D), critical)); + JAVA_DOUBLE.withName("y"), 42D), true, critical)); cases.add(structCase("SDDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, JAVA_DOUBLE.withName("y"), 42D, - JAVA_DOUBLE.withName("z"), 42D), critical)); + JAVA_DOUBLE.withName("z"), 42D), true, critical)); if (IS_WINDOWS) { cases.add(new SaveValuesCase("SetLastError", FunctionDescriptor.ofVoid(JAVA_INT), - "GetLastError", o -> {}, critical)); + "GetLastError", o -> {}, true, critical)); cases.add(new SaveValuesCase("WSASetLastError", FunctionDescriptor.ofVoid(JAVA_INT), - "WSAGetLastError", o -> {}, critical)); + "WSAGetLastError", o -> {}, true, critical)); } } return cases.stream().map(tc -> new Object[] {tc}).toArray(Object[][]::new); } - static SaveValuesCase structCase(String name, Map fields, boolean critical) { + static SaveValuesCase structCase(String name, + Map fields, + boolean expectTestValue, + boolean critical) { StructLayout layout = MemoryLayout.structLayout(fields.keySet().toArray(MemoryLayout[]::new)); Consumer check = o -> {}; @@ -167,9 +182,9 @@ public class TestCaptureCallState extends NativeTestHelper { Object value = field.getValue(); check = check.andThen(o -> assertEquals(fieldHandle.get(o, 0L), value)); } - - return new SaveValuesCase("set_errno_" + name, FunctionDescriptor.of(layout, JAVA_INT), - "errno", check, critical); + String prefix = expectTestValue ? "set_errno_" : "noset_errno_"; + return new SaveValuesCase(prefix + name, FunctionDescriptor.of(layout, JAVA_INT), + "errno", check, expectTestValue, critical); } @DataProvider diff --git a/test/jdk/java/foreign/capturecallstate/libCaptureCallState.c b/test/jdk/java/foreign/capturecallstate/libCaptureCallState.c index d76c9d7beda..fe0d144cb5b 100644 --- a/test/jdk/java/foreign/capturecallstate/libCaptureCallState.c +++ b/test/jdk/java/foreign/capturecallstate/libCaptureCallState.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,6 +29,10 @@ EXPORT void set_errno_V(int value) { errno = value; } +EXPORT int noset_errno_V(int value) { + return 42; +} + EXPORT int set_errno_I(int value) { errno = value; return 42; @@ -78,6 +82,14 @@ EXPORT struct SLLL set_errno_SLLL(int value) { return s; } +EXPORT struct SLLL noset_errno_SLLL(int value) { + struct SLLL s; + s.x = 42; + s.y = 42; + s.z = 42; + return s; +} + struct SD { double x; }; diff --git a/test/jdk/java/io/BufferedInputStream/TransferTo.java b/test/jdk/java/io/BufferedInputStream/TransferTo.java index a0d7b0ee9bd..fe42c0a8b2e 100644 --- a/test/jdk/java/io/BufferedInputStream/TransferTo.java +++ b/test/jdk/java/io/BufferedInputStream/TransferTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -46,22 +46,22 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; -import org.testng.annotations.Test; - import jdk.test.lib.RandomFactory; import static java.lang.String.format; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=180 -Xmx1280m TransferTo + * @run junit/othervm/timeout=180 -Xmx1280m TransferTo * @bug 8279283 8294541 * @summary Tests whether java.io.BufferedInputStream.transferTo conforms to the * InputStream.transferTo specification @@ -183,7 +183,7 @@ public class TransferTo { int count = inBytes.length - posIn; int expected = count - bufferBytes; - assertEquals(reported, expected, + assertEquals(expected, reported, format("transferred %d bytes but should report %d", reported, expected)); byte[] outBytes = recorder.get().get(); @@ -198,7 +198,7 @@ public class TransferTo { reported = in.transferTo(out); expected = count - bufferBytes; - assertEquals(reported, expected, + assertEquals(expected, reported, format("replayed %d bytes but should report %d", reported, expected)); outBytes = recorder.get().get(); diff --git a/test/jdk/java/io/BufferedReader/Lines.java b/test/jdk/java/io/BufferedReader/Lines.java index 2e35f75887d..3b4edb80e70 100644 --- a/test/jdk/java/io/BufferedReader/Lines.java +++ b/test/jdk/java/io/BufferedReader/Lines.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8003258 8029434 - * @run testng Lines + * @run junit Lines */ import java.io.BufferedReader; @@ -41,10 +41,15 @@ import java.util.NoSuchElementException; import java.util.Spliterator; import java.util.stream.Stream; import java.util.concurrent.atomic.AtomicInteger; -import org.testng.annotations.Test; -import static org.testng.Assert.*; -@Test(groups = "unit") +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +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; + public class Lines { private static final Map cases = new HashMap<>(); @@ -155,75 +160,81 @@ public class Lines { private static void verify(Map.Entry e) { final String data = e.getKey(); final int total_lines = e.getValue(); - try (BufferedReader br = new BufferedReader( - new StringReader(data))) { - assertEquals(br.lines() - .mapToInt(l -> 1).reduce(0, (x, y) -> x + y), - total_lines, - data + " should produce " + total_lines + " lines."); - } catch (IOException ioe) { - fail("Should not have any exception."); - } + assertDoesNotThrow + (() -> { + try (BufferedReader br = + new BufferedReader(new StringReader(data))) { + assertEquals(total_lines, + br.lines().mapToInt(l -> 1).reduce(0, (x, y) -> x + y), + data + " should produce " + total_lines + " lines."); + } + }); } + @Test public void testLinesBasic() { // Basic test cases cases.entrySet().stream().forEach(Lines::verify); // Similar test, also verify MockLineReader is correct - for (int i = 0; i < 10; i++) { - try (BufferedReader br = new BufferedReader(new MockLineReader(i))) { - assertEquals(br.lines() - .peek(l -> assertTrue(l.matches("^Line \\d+$"))) - .mapToInt(l -> 1).reduce(0, (x, y) -> x + y), - i, - "MockLineReader(" + i + ") should produce " + i + " lines."); - } catch (IOException ioe) { - fail("Unexpected IOException."); - } - } + assertDoesNotThrow + (() -> { + for (int i = 0; i < 10; i++) { + try (BufferedReader br = + new BufferedReader(new MockLineReader(i))) { + assertEquals(i, + br.lines() + .peek(l -> assertTrue(l.matches("^Line \\d+$"))) + .mapToInt(l -> 1).reduce(0, (x, y) -> x + y), + "MockLineReader(" + i + ") should produce " + i + " lines."); + } + } + }); } + @Test public void testUncheckedIOException() throws IOException { MockLineReader r = new MockLineReader(10, 3); ArrayList ar = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(r)) { - br.lines().limit(3L).forEach(ar::add); - assertEquals(ar.size(), 3, "Should be able to read 3 lines."); - } catch (UncheckedIOException uioe) { - fail("Unexpected UncheckedIOException"); - } + assertDoesNotThrow + (() -> { + try (BufferedReader br = new BufferedReader(r)) { + br.lines().limit(3L).forEach(ar::add); + assertEquals(3, ar.size(), "Should be able to read 3 lines."); + } + }); r.reset(); - try (BufferedReader br = new BufferedReader(r)) { - br.lines().forEach(ar::add); - fail("Should had thrown UncheckedIOException."); - } catch (UncheckedIOException uioe) { - assertEquals(r.getLineNumber(), 4, "should fail to read 4th line"); - assertEquals(ar.size(), 6, "3 + 3 lines read"); - } + assertThrows(UncheckedIOException.class, + () -> { + try (BufferedReader br = new BufferedReader(r)) { + br.lines().forEach(ar::add); + } + }); + assertEquals(4, r.getLineNumber(), "should fail to read 4th line"); + assertEquals(6, ar.size(), "3 + 3 lines read"); for (int i = 0; i < ar.size(); i++) { - assertEquals(ar.get(i), "Line " + (i % 3 + 1)); + assertEquals("Line " + (i % 3 + 1), ar.get(i)); } } + @Test public void testIterator() throws IOException { MockLineReader r = new MockLineReader(6); BufferedReader br = new BufferedReader(r); String line = br.readLine(); - assertEquals(r.getLineNumber(), 1, "Read one line"); + assertEquals(1, r.getLineNumber(), "Read one line"); Stream s = br.lines(); Iterator it = s.iterator(); // Ensure iterate with only next works for (int i = 0; i < 5; i++) { String str = it.next(); - assertEquals(str, "Line " + (i + 2), "Addtional five lines"); + assertEquals("Line " + (i + 2), str, "Addtional five lines"); } // NoSuchElementException - try { - it.next(); - fail("Should have run out of lines."); - } catch (NoSuchElementException nsse) {} + assertThrows(NoSuchElementException.class, () -> it.next(), + "Should have run out of lines."); } + @Test public void testPartialReadAndLineNo() throws IOException { MockLineReader r = new MockLineReader(5); LineNumberReader lr = new LineNumberReader(r); @@ -231,23 +242,24 @@ public class Lines { lr.read(buf, 0, 5); assertEquals(0, lr.getLineNumber(), "LineNumberReader start with line 0"); assertEquals(1, r.getLineNumber(), "MockLineReader start with line 1"); - assertEquals(new String(buf), "Line "); + assertEquals("Line ", new String(buf)); String l1 = lr.readLine(); - assertEquals(l1, "1", "Remaining of the first line"); + assertEquals("1", l1, "Remaining of the first line"); assertEquals(1, lr.getLineNumber(), "Line 1 is read"); assertEquals(1, r.getLineNumber(), "MockLineReader not yet go next line"); lr.read(buf, 0, 4); assertEquals(1, lr.getLineNumber(), "In the middle of line 2"); - assertEquals(new String(buf, 0, 4), "Line"); + assertEquals("Line", new String(buf, 0, 4)); ArrayList ar = lr.lines() .peek(l -> assertEquals(lr.getLineNumber(), r.getLineNumber())) .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); - assertEquals(ar.get(0), " 2", "Remaining in the second line"); + assertEquals(" 2", ar.get(0), "Remaining in the second line"); for (int i = 1; i < ar.size(); i++) { - assertEquals(ar.get(i), "Line " + (i + 2), "Rest are full lines"); + assertEquals("Line " + (i + 2), ar.get(i), "Rest are full lines"); } } + @Test public void testInterlacedRead() throws IOException { MockLineReader r = new MockLineReader(10); BufferedReader br = new BufferedReader(r); @@ -256,26 +268,24 @@ public class Lines { Iterator it = s.iterator(); br.read(buf); - assertEquals(new String(buf), "Line "); - assertEquals(it.next(), "1"); - try { - s.iterator().next(); - fail("Should failed on second attempt to get iterator from s"); - } catch (IllegalStateException ise) {} + assertEquals("Line ", new String(buf)); + assertEquals("1", it.next()); + assertThrows(IllegalStateException.class, () -> s.iterator().next(), + "Should fail on second call to Iterator next method"); br.read(buf, 0, 2); - assertEquals(new String(buf, 0, 2), "Li"); + assertEquals("Li", new String(buf, 0, 2)); // Get stream again should continue from where left // Only read remaining of the line br.lines().limit(1L).forEach(line -> assertEquals(line, "ne 2")); br.read(buf, 0, 2); - assertEquals(new String(buf, 0, 2), "Li"); + assertEquals("Li", new String(buf, 0, 2)); br.read(buf, 0, 2); - assertEquals(new String(buf, 0, 2), "ne"); - assertEquals(it.next(), " 3"); + assertEquals("ne", new String(buf, 0, 2)); + assertEquals(" 3", it.next()); // Line 4 br.readLine(); // interator pick - assertEquals(it.next(), "Line 5"); + assertEquals("Line 5", it.next()); // Another stream instantiated by lines() AtomicInteger line_no = new AtomicInteger(6); br.lines().forEach(l -> assertEquals(l, "Line " + line_no.getAndIncrement())); @@ -283,14 +293,16 @@ public class Lines { assertFalse(it.hasNext()); } + @Test public void testCharacteristics() { - try (BufferedReader br = new BufferedReader( - new StringReader(""))) { - Spliterator instance = br.lines().spliterator(); - assertTrue(instance.hasCharacteristics(Spliterator.NONNULL)); - assertTrue(instance.hasCharacteristics(Spliterator.ORDERED)); - } catch (IOException ioe) { - fail("Should not have any exception."); - } + assertDoesNotThrow + (() -> { + try (BufferedReader br = + new BufferedReader(new StringReader(""))) { + Spliterator instance = br.lines().spliterator(); + assertTrue(instance.hasCharacteristics(Spliterator.NONNULL)); + assertTrue(instance.hasCharacteristics(Spliterator.ORDERED)); + } + }); } } diff --git a/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java b/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java index 1a9d8d4c20b..40bef97294a 100644 --- a/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java +++ b/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,29 +25,31 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @bug 8183743 * @summary Test to verify the new overload method with Charset functions the same * as the existing method that takes a charset name. - * @run testng EncodingTest + * @run junit EncodingTest */ public class EncodingTest { /* - * DataProvider for the toString method test. Provides the following fields: + * MethodSource for the toString method test. Provides the following fields: * byte array, charset name string, charset object */ - @DataProvider(name = "parameters") - public Object[][] getParameters() throws IOException { + public static Stream parameters() throws IOException { byte[] data = getData(); - return new Object[][]{ - {data, StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, - {data, StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, - }; + return Stream.of + (Arguments.of(data, StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8), + Arguments.of(data, StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1)); } /** @@ -58,20 +60,21 @@ public class EncodingTest { * @param charset the charset * @throws Exception if the test fails */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("parameters") public void test(byte[] data, String csn, Charset charset) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(data); String str1 = baos.toString(csn); String str2 = baos.toString(charset); - Assert.assertEquals(str1, str2); + assertEquals(str2, str1); } /* * Returns an array containing a character that's invalid for UTF-8 * but valid for ISO-8859-1 */ - byte[] getData() throws IOException { + static byte[] getData() throws IOException { String str1 = "A string that contains "; String str2 = " , an invalid character for UTF-8."; diff --git a/test/jdk/java/io/ByteArrayOutputStream/Write.java b/test/jdk/java/io/ByteArrayOutputStream/Write.java index 72c399916e0..99d8a206635 100644 --- a/test/jdk/java/io/ByteArrayOutputStream/Write.java +++ b/test/jdk/java/io/ByteArrayOutputStream/Write.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 4017158 8180410 * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng Write + * @run junit Write * @summary Check for correct implementation of ByteArrayInputStream.write * @key randomness */ @@ -35,49 +35,40 @@ import java.io.ByteArrayOutputStream; import java.util.Arrays; import java.util.Random; import jdk.test.lib.RandomFactory; -import org.testng.annotations.Test; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class Write { private static void doBoundsTest(byte[] b, int off, int len, ByteArrayOutputStream baos) throws Exception { if (b != null) { - System.out.println("ByteArrayOutStream.write: b.length = " + + System.err.println("ByteArrayOutStream.write: b.length = " + b.length + " off = " + off + " len = " + len); } else{ - System.out.println("ByteArrayOutStream.write: b is null off = " + + System.err.println("ByteArrayOutStream.write: b is null off = " + off + " len = " + len); } - try { - baos.write(b, off, len); - } catch (IndexOutOfBoundsException e) { - System.out.println("IndexOutOfBoundsException is thrown: OKAY"); - } catch (NullPointerException e) { - System.out.println("NullPointerException is thrown: OKAY"); - } catch (Throwable e){ - throw new RuntimeException("Unexpected Exception is thrown", e); - } + Class expectedException = (b == null) + ? NullPointerException.class : IndexOutOfBoundsException.class; + assertThrows(expectedException, () -> baos.write(b, off, len)); if (b != null) { - System.out.println("ByteArrayOutStream.writeBytes: b.length = " + + System.err.println("ByteArrayOutStream.writeBytes: b.length = " + b.length); } else{ - System.out.println("ByteArrayOutStream.writeBytes: b is null"); - } - - try { - baos.writeBytes(b); - } catch (NullPointerException e) { - System.out.println("NullPointerException is thrown: OKAY"); - } catch (Throwable e){ - throw new RuntimeException("Unexpected Exception is thrown", e); + System.err.println("ByteArrayOutStream.writeBytes: b is null"); + assertThrows(NullPointerException.class, () -> baos.writeBytes(b)); } } @Test - public static void boundsTest() throws Exception { + public void boundsTest() throws Exception { byte array1[] = {1 , 2 , 3 , 4 , 5}; // Simple array //Create new ByteArrayOutputStream object @@ -91,7 +82,7 @@ public class Write { } @Test - public static void writeTest() throws Exception { + public void writeTest() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Random rnd = RandomFactory.getRandom(); final int size = 17 + rnd.nextInt(128); @@ -104,39 +95,36 @@ public class Write { int off2 = rnd.nextInt(size / 2) + 1; int len2 = Math.min(rnd.nextInt(size / 2) + 1, size - off2); - System.out.format("size: %d, off1: %d, len1: %d, off2: %d, len2: %d%n", + System.err.format("size: %d, off1: %d, len1: %d, off2: %d, len2: %d%n", size, off1, len1, off2, len2); baos.write(b, off1, len1); byte[] b1 = baos.toByteArray(); - assertEquals(b1.length, len1, "Array length test 1 failed."); - assertEquals(b1, Arrays.copyOfRange(b, off1, off1 + len1), + assertEquals(len1, b1.length, "Array length test 1 failed."); + assertArrayEquals(Arrays.copyOfRange(b, off1, off1 + len1), b1, "Array equality test 1 failed."); baos.write(b, off2, len2); byte[] b2 = baos.toByteArray(); - assertEquals(b2.length, len1 + len2, "Array length test 2 failed."); - assertEquals(Arrays.copyOfRange(b2, 0, len1), - Arrays.copyOfRange(b, off1, off1 + len1), + assertEquals(len1 + len2, b2.length, "Array length test 2 failed."); + assertArrayEquals(Arrays.copyOfRange(b, off1, off1 + len1), + Arrays.copyOfRange(b2, 0, len1), "Array equality test 2A failed."); - assertEquals(Arrays.copyOfRange(b2, len1, len1 + len2), - Arrays.copyOfRange(b, off2, off2 + len2), + assertArrayEquals(Arrays.copyOfRange(b, off2, off2 + len2), + Arrays.copyOfRange(b2, len1, len1 + len2), "Array equality test 2B failed."); baos.writeBytes(b); byte[] b3 = baos.toByteArray(); int len3 = len1 + len2 + b.length; - if (b3.length != len1 + len2 + b.length) { - throw new RuntimeException("Array length test 3 failed."); - } - assertEquals(b3.length, len3, "Array length test 3 failed."); - assertEquals(Arrays.copyOfRange(b3, 0, len1), - Arrays.copyOfRange(b, off1, off1 + len1), + assertEquals(len3, b3.length, "Array length test 3 failed."); + assertArrayEquals(Arrays.copyOfRange(b, off1, off1 + len1), + Arrays.copyOfRange(b3, 0, len1), "Array equality test 3A failed."); - assertEquals(Arrays.copyOfRange(b3, len1, len1 + len2), - Arrays.copyOfRange(b, off2, off2 + len2), + assertArrayEquals(Arrays.copyOfRange(b, off2, off2 + len2), + Arrays.copyOfRange(b3, len1, len1 + len2), "Array equality test 3B failed."); - assertEquals(Arrays.copyOfRange(b3, len1 + len2, len3), b, + assertArrayEquals(b, Arrays.copyOfRange(b3, len1 + len2, len3), "Array equality test 3C failed."); } } diff --git a/test/jdk/java/io/CharArrayReader/ReadCharBuffer.java b/test/jdk/java/io/CharArrayReader/ReadCharBuffer.java index 545ba8ba029..87571a399ac 100644 --- a/test/jdk/java/io/CharArrayReader/ReadCharBuffer.java +++ b/test/jdk/java/io/CharArrayReader/ReadCharBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,13 +25,9 @@ * @test * @bug 4926314 * @summary Test for CharArrayReader#read(CharBuffer). - * @run testng ReadCharBuffer + * @run junit ReadCharBuffer */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - - import java.io.CharArrayReader; import java.io.IOException; import java.io.Reader; @@ -39,43 +35,46 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.util.Arrays; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ReadCharBuffer { private static final int BUFFER_SIZE = 7; - @DataProvider(name = "buffers") - public Object[][] createBuffers() { + public static CharBuffer[] buffers() { // test both on-heap and off-heap buffers as they may use different code paths - return new Object[][]{ - new Object[]{CharBuffer.allocate(BUFFER_SIZE)}, - new Object[]{ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer()} + return new CharBuffer[] { + CharBuffer.allocate(BUFFER_SIZE), + ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer() }; } - @Test(dataProvider = "buffers") + @ParameterizedTest + @MethodSource("buffers") public void read(CharBuffer buffer) throws IOException { fillBuffer(buffer); try (Reader reader = new CharArrayReader("ABCD".toCharArray())) { buffer.limit(3); buffer.position(1); - assertEquals(reader.read(buffer), 2); - assertEquals(buffer.position(), 3); - assertEquals(buffer.limit(), 3); + assertEquals(2, reader.read(buffer)); + assertEquals(3, buffer.position()); + assertEquals(3, buffer.limit()); buffer.limit(7); buffer.position(4); - assertEquals(reader.read(buffer), 2); - assertEquals(buffer.position(), 6); - assertEquals(buffer.limit(), 7); + assertEquals(2, reader.read(buffer)); + assertEquals(6, buffer.position()); + assertEquals(7, buffer.limit()); - assertEquals(reader.read(buffer), -1); + assertEquals(-1, reader.read(buffer)); } buffer.clear(); - assertEquals(buffer.toString(), "xABxCDx"); + assertEquals("xABxCDx", buffer.toString()); } private void fillBuffer(CharBuffer buffer) { diff --git a/test/jdk/java/io/DataOutputStream/WriteUTF.java b/test/jdk/java/io/DataOutputStream/WriteUTF.java index d5557ec85ed..ed8b7397971 100644 --- a/test/jdk/java/io/DataOutputStream/WriteUTF.java +++ b/test/jdk/java/io/DataOutputStream/WriteUTF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,7 +25,7 @@ * @bug 4260284 8219196 8223254 * @summary Test if DataOutputStream will overcount written field. * @requires (sun.arch.data.model == "64" & os.maxMemory >= 4g) - * @run testng/othervm -Xmx4g WriteUTF + * @run junit/othervm -Xmx4g WriteUTF */ import java.io.ByteArrayOutputStream; @@ -33,11 +33,13 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.UTFDataFormatException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class WriteUTF { @Test - public static void overcountWrittenField() throws IOException { + public void overcountWrittenField() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeUTF("Hello, World!"); // 15 @@ -54,16 +56,16 @@ public class WriteUTF { dos.writeUTF(s); } - @Test(expectedExceptions = UTFDataFormatException.class) + @Test public void utfDataFormatException() throws IOException { - writeUTF(1 << 16); + assertThrows(UTFDataFormatException.class, () -> writeUTF(1 << 16)); } // Without 8219196 fix, throws ArrayIndexOutOfBoundsException instead of // expected UTFDataFormatException. Requires 4GB of heap (-Xmx4g) to run // without throwing an OutOfMemoryError. - @Test(expectedExceptions = UTFDataFormatException.class) + @Test public void arrayIndexOutOfBoundsException() throws IOException { - writeUTF(Integer.MAX_VALUE / 3 + 1); + assertThrows(UTFDataFormatException.class, () -> writeUTF(Integer.MAX_VALUE / 3 + 1)); } } diff --git a/test/jdk/java/io/File/EmptyPath.java b/test/jdk/java/io/File/EmptyPath.java index 374a69c7959..67331380531 100644 --- a/test/jdk/java/io/File/EmptyPath.java +++ b/test/jdk/java/io/File/EmptyPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -285,17 +285,6 @@ public class EmptyPath { assertEquals(nioSet, ioSet); } - @Test - public void listRoots() { - Set expected = Arrays.stream(f.getAbsoluteFile().listRoots()) - .map(File::toString) - .collect(Collectors.toSet()); - Set actual = Arrays.stream(f.listRoots()) - .map(File::toString) - .collect(Collectors.toSet()); - assertEquals(expected, actual); - } - @Test public void mkdir() { assertFalse(f.mkdir()); diff --git a/test/jdk/java/io/File/LastModifiedTest.java b/test/jdk/java/io/File/LastModifiedTest.java index 52c7d390401..4eaf5fa34c2 100644 --- a/test/jdk/java/io/File/LastModifiedTest.java +++ b/test/jdk/java/io/File/LastModifiedTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -21,20 +22,19 @@ * questions. */ -import org.testng.annotations.Test; - import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.time.Instant; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @library .. - * @run testng LastModifiedTest + * @run junit LastModifiedTest * @summary Test to validate that java.nio.Files returns the same value * as java.io.File */ @@ -51,7 +51,7 @@ public class LastModifiedTest { long ioTimestamp = tempFile.lastModified(); long nioTimestamp = Files.getLastModifiedTime(tempFile.toPath()).toMillis(); - assertEquals(ioTimestamp, nioTimestamp); + assertEquals(nioTimestamp, ioTimestamp); } finally { tempFile.delete(); } diff --git a/test/jdk/java/io/FileDescriptor/Sharing.java b/test/jdk/java/io/FileDescriptor/Sharing.java index 24f4fb70b02..e4ceb2d6906 100644 --- a/test/jdk/java/io/FileDescriptor/Sharing.java +++ b/test/jdk/java/io/FileDescriptor/Sharing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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,7 +28,14 @@ * @run main/othervm Sharing */ -import java.io.*; +import java.io.File; +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.io.Writer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.util.concurrent.CountDownLatch; @@ -71,7 +78,7 @@ public class Sharing { // encourage gc System.gc(); // read from fis2 - when fis1 is gc'ed and finalizer is run, read will fail - System.out.print("."); + System.err.print("."); ret = fis2.read(); } } @@ -93,7 +100,7 @@ public class Sharing { * read from fis3 - when raf is gc'ed and finalizer is run, * fd should still be valid. */ - System.out.print("."); + System.err.print("."); ret = fis3.read(); } } finally { @@ -290,7 +297,7 @@ public class Sharing { FileInputStream fis = new FileInputStream(raf.getFD()); fis.close(); if (raf.getFD().valid()) { - throw new RuntimeException("FD should not be valid."); + throw new RuntimeException("FD should not be valid."); } // Test the suppressed exception handling - FileInputStream @@ -308,7 +315,7 @@ public class Sharing { ioe.printStackTrace(); if (ioe.getSuppressed().length != 2) { throw new RuntimeException("[FIS]Incorrect number of suppressed " + - "exceptions received : " + ioe.getSuppressed().length); + "exceptions received : " + ioe.getSuppressed().length); } } if (raf.getFD().valid()) { @@ -332,7 +339,7 @@ public class Sharing { ioe.printStackTrace(); if (ioe.getSuppressed().length != 2) { throw new RuntimeException("[FOS]Incorrect number of suppressed " + - "exceptions received : " + ioe.getSuppressed().length); + "exceptions received : " + ioe.getSuppressed().length); } } if (raf.getFD().valid()) { @@ -347,10 +354,8 @@ public class Sharing { * FileOutputStreams referencing the same native file descriptor. */ private static class OpenClose extends Thread { - private FileDescriptor fd = null; - private CountDownLatch done; - FileInputStream[] fisArray = new FileInputStream[numFiles]; - FileOutputStream[] fosArray = new FileOutputStream[numFiles]; + private final FileDescriptor fd; + private final CountDownLatch done; OpenClose(FileDescriptor filedescriptor, CountDownLatch done) { this.fd = filedescriptor; @@ -358,29 +363,32 @@ public class Sharing { } public void run() { - try { - for(int i=0;i parameters() throws IOException { File file1 = new File(USER_DIR, "FileReaderTest1.txt"); File file2 = new File(USER_DIR, "FileReaderTest2.txt"); - return new Object[][]{ - {ConstructorType.STRING, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.FILE, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.STRING, file1, file2, StandardCharsets.ISO_8859_1}, - {ConstructorType.FILE, file1, file2, StandardCharsets.ISO_8859_1}, - }; + return Stream.of + (Arguments.of(ConstructorType.STRING, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.FILE, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.STRING, file1, file2, StandardCharsets.ISO_8859_1), + Arguments.of(ConstructorType.FILE, file1, file2, StandardCharsets.ISO_8859_1)); } /** @@ -75,7 +77,8 @@ public class ConstructorTest { * @param charset the charset * @throws IOException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("parameters") void test(ConstructorType type, File file1, File file2, Charset charset) throws Exception { prepareFile(file1, TEST_STRING, charset); @@ -86,7 +89,7 @@ public class ConstructorTest { InputStreamReader isr = new InputStreamReader(is, charset);) { String result1 = readAll(fr, BUFFER_SIZE); String result2 = readAll(isr, BUFFER_SIZE); - Assert.assertEquals(result1, result2); + assertEquals(result2, result1); } } diff --git a/test/jdk/java/io/FileWriter/ConstructorTest.java b/test/jdk/java/io/FileWriter/ConstructorTest.java index 691b52504f9..64a43395f51 100644 --- a/test/jdk/java/io/FileWriter/ConstructorTest.java +++ b/test/jdk/java/io/FileWriter/ConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,15 +31,21 @@ import java.io.OutputStreamWriter; import java.io.Reader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @bug 8183554 * @summary Test to verify the new Constructors that take a Charset. - * @run testng ConstructorTest + * @run junit ConstructorTest */ public class ConstructorTest { static String USER_DIR = System.getProperty("user.dir", "."); @@ -54,21 +60,19 @@ public class ConstructorTest { static final String TEST_STRING = "abc \u0100 \u0101 \u0555 \u07FD \u07FF"; static final int BUFFER_SIZE = 8192; - @DataProvider(name = "parameters") - public Object[][] getParameters() throws IOException { + public static Stream parameters() throws IOException { File file1 = new File(USER_DIR, "FileWriterTest1.txt"); File file2 = new File(USER_DIR, "FileWriterTest2.txt"); - return new Object[][]{ - {ConstructorType.STRING, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.FILE, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.STRING_APPEND, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.FILE_APPEND, file1, file2, StandardCharsets.UTF_8}, - {ConstructorType.STRING, file1, file2, StandardCharsets.ISO_8859_1}, - {ConstructorType.FILE, file1, file2, StandardCharsets.ISO_8859_1}, - {ConstructorType.STRING_APPEND, file1, file2, StandardCharsets.ISO_8859_1}, - {ConstructorType.FILE_APPEND, file1, file2, StandardCharsets.ISO_8859_1}, - }; + return Stream.of + (Arguments.of(ConstructorType.STRING, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.FILE, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.STRING_APPEND, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.FILE_APPEND, file1, file2, StandardCharsets.UTF_8), + Arguments.of(ConstructorType.STRING, file1, file2, StandardCharsets.ISO_8859_1), + Arguments.of(ConstructorType.FILE, file1, file2, StandardCharsets.ISO_8859_1), + Arguments.of(ConstructorType.STRING_APPEND, file1, file2, StandardCharsets.ISO_8859_1), + Arguments.of(ConstructorType.FILE_APPEND, file1, file2, StandardCharsets.ISO_8859_1)); } /** @@ -82,7 +86,8 @@ public class ConstructorTest { * @param charset the charset * @throws IOException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("parameters") void test(ConstructorType type, File file1, File file2, Charset charset) throws Exception { writeWithFileWriter(type, file1, TEST_STRING, charset); @@ -94,7 +99,7 @@ public class ConstructorTest { ) { String result1 = readAll(r1, BUFFER_SIZE); String result2 = readAll(r2, BUFFER_SIZE); - Assert.assertEquals(result1, result2); + assertEquals(result1, result2); } } diff --git a/test/jdk/java/io/InputStream/NullInputStream.java b/test/jdk/java/io/InputStream/NullInputStream.java index 74317822404..d911edab380 100644 --- a/test/jdk/java/io/InputStream/NullInputStream.java +++ b/test/jdk/java/io/InputStream/NullInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,232 +21,148 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import java.io.ByteArrayOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 4358774 6516099 8139206 - * @run testng NullInputStream + * @run junit NullInputStream * @summary Check for expected behavior of InputStream.nullInputStream(). */ public class NullInputStream { private static InputStream openStream; private static InputStream closedStream; - @BeforeClass + @BeforeAll public static void setup() { openStream = InputStream.nullInputStream(); closedStream = InputStream.nullInputStream(); - try { - closedStream.close(); - } catch (IOException e) { - fail("Unexpected IOException"); - } + assertDoesNotThrow(() -> closedStream.close()); } - @AfterClass + @AfterAll public static void closeStream() { - try { - openStream.close(); - } catch (IOException e) { - fail("Unexpected IOException"); - } + assertDoesNotThrow(() -> openStream.close()); } @Test - public static void testOpen() { + public void testOpen() { assertNotNull(openStream, "InputStream.nullInputStream() returned null"); } @Test - public static void testAvailable() { - try { - assertEquals(0, openStream.available(), "available() != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testAvailable() throws IOException { + assertEquals(0, openStream.available()); } @Test - public static void testRead() { - try { - assertEquals(-1, openStream.read(), "read() != -1"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testRead() throws IOException { + assertEquals(-1, openStream.read()); } @Test - public static void testReadBII() { - try { - assertEquals(-1, openStream.read(new byte[1], 0, 1), - "read(byte[],int,int) != -1"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testReadBII() throws IOException { + assertEquals(-1, openStream.read(new byte[1], 0, 1)); } @Test - public static void testReadAllBytes() { - try { - assertEquals(0, openStream.readAllBytes().length, - "readAllBytes().length != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testReadAllBytes() throws IOException { + assertEquals(0, openStream.readAllBytes().length); } @Test - public static void testReadNBytes() { - try { - assertEquals(0, openStream.readNBytes(new byte[1], 0, 1), - "readNBytes(byte[],int,int) != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testReadNBytes() throws IOException { + assertEquals(0, openStream.readNBytes(new byte[1], 0, 1)); } @Test - public static void testReadNBytesWithLength() { - try { - assertEquals(0, openStream.readNBytes(-1).length, - "readNBytes(-1) != 0"); - fail("Expected IllegalArgumentException not thrown"); - } catch (IllegalArgumentException iae) { - } catch (IOException ioe) { - fail("Unexpected IOException"); - } - try { - assertEquals(0, openStream.readNBytes(0).length, - "readNBytes(0, false) != 0"); - assertEquals(0, openStream.readNBytes(1).length, - "readNBytes(1, false) != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testReadNBytesWithLength() throws IOException { + assertThrows(IllegalArgumentException.class, + () -> openStream.readNBytes(-1)); + assertEquals(0, openStream.readNBytes(0).length); + assertEquals(0, openStream.readNBytes(1).length); } @Test - public static void testSkip() { - try { - assertEquals(0, openStream.skip(1), "skip() != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testSkip() throws IOException { + assertEquals(0L, openStream.skip(1)); } @Test - public static void testSkipNBytes() { - try { - openStream.skipNBytes(-1); - openStream.skipNBytes(0); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } - } - - @Test(expectedExceptions = EOFException.class) - public static void testSkipNBytesEOF() throws IOException { - openStream.skipNBytes(1); + public void testSkipNBytes() { + assertDoesNotThrow(() -> { + openStream.skipNBytes(-1); + openStream.skipNBytes(0); + }); } @Test - public static void testTransferTo() { - try { - assertEquals(0, openStream.transferTo(new ByteArrayOutputStream(7)), - "transferTo() != 0"); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } + public void testSkipNBytesEOF() throws IOException { + assertThrows(EOFException.class, () -> openStream.skipNBytes(1)); } @Test - public static void testAvailableClosed() { - try { - closedStream.available(); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testTransferTo() throws IOException { + assertEquals(0L, openStream.transferTo(new ByteArrayOutputStream(7))); } @Test - public static void testReadClosed() { - try { - closedStream.read(); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testAvailableClosed() { + assertThrows(IOException.class, () -> closedStream.available()); } @Test - public static void testReadBIIClosed() { - try { - closedStream.read(new byte[1], 0, 1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testReadClosed() { + assertThrows(IOException.class, () -> closedStream.read()); } @Test - public static void testReadAllBytesClosed() { - try { - closedStream.readAllBytes(); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testReadBIIClosed() { + assertThrows(IOException.class, + () -> closedStream.read(new byte[1], 0, 1)); } @Test - public static void testReadNBytesClosed() { - try { - closedStream.readNBytes(new byte[1], 0, 1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testReadAllBytesClosed() { + assertThrows(IOException.class, () -> closedStream.readAllBytes()); } @Test - public static void testReadNBytesWithLengthClosed() { - try { - closedStream.readNBytes(1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testReadNBytesClosed() { + assertThrows(IOException.class, () -> + closedStream.readNBytes(new byte[1], 0, 1)); } @Test - public static void testSkipClosed() { - try { - closedStream.skip(1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testReadNBytesWithLengthClosed() { + assertThrows(IOException.class, () -> closedStream.readNBytes(1)); } @Test - public static void testSkipNBytesClosed() { - try { - closedStream.skipNBytes(1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testSkipClosed() { + assertThrows(IOException.class, () -> closedStream.skip(1)); } @Test - public static void testTransferToClosed() { - try { - closedStream.transferTo(new ByteArrayOutputStream(7)); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testSkipNBytesClosed() { + assertThrows(IOException.class, () -> closedStream.skipNBytes(1)); + } + + @Test + public void testTransferToClosed() { + assertThrows(IOException.class, + () -> closedStream.transferTo(new ByteArrayOutputStream(7))); } } diff --git a/test/jdk/java/io/InputStreamReader/ReadCharBuffer.java b/test/jdk/java/io/InputStreamReader/ReadCharBuffer.java index 8a4094c512a..6df3feb756f 100644 --- a/test/jdk/java/io/InputStreamReader/ReadCharBuffer.java +++ b/test/jdk/java/io/InputStreamReader/ReadCharBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,13 +25,9 @@ * @test * @bug 4926314 8287003 * @summary Test for InputStreamReader#read(CharBuffer). - * @run testng ReadCharBuffer + * @run junit ReadCharBuffer */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; @@ -40,22 +36,25 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CodingErrorAction; import java.util.Arrays; +import java.util.stream.Stream; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ReadCharBuffer { private static final int BUFFER_SIZE = 24; - @DataProvider(name = "buffers") - public Object[][] createBuffers() { + public static Stream buffers() { // test both on-heap and off-heap buffers as they make use different code paths - return new Object[][]{ - new Object[]{CharBuffer.allocate(BUFFER_SIZE)}, - new Object[]{ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer()} - }; + return Stream.of(CharBuffer.allocate(BUFFER_SIZE), + ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer()); } private void fillBuffer(CharBuffer buffer) { @@ -65,7 +64,8 @@ public class ReadCharBuffer { buffer.clear(); } - @Test(dataProvider = "buffers") + @ParameterizedTest + @MethodSource("buffers") public void read(CharBuffer buffer) throws IOException { fillBuffer(buffer); diff --git a/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java b/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java index 95759df5522..f456d176e98 100644 --- a/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java +++ b/test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java @@ -23,7 +23,7 @@ /* @test * @bug 8292043 - * @run testng StatefulDecoderNearEOF + * @run junit StatefulDecoderNearEOF * @summary Check MalformedInputException is thrown with stateful decoders * with malformed input before EOF */ @@ -36,29 +36,30 @@ import java.nio.charset.CodingErrorAction; import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; import java.util.stream.IntStream; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -@Test public class StatefulDecoderNearEOF { - @DataProvider - public Object[][] inputs() { - return new Object[][] { + public static Stream inputs() { + return Stream.of( // BOM, followed by High surrogate (in UTF-16LE). // First read() should throw an exception. - {new byte[] {(byte)0xff, (byte)0xfe, 0, (byte)0xd8}, 0}, + Arguments.of(new byte[] {(byte)0xff, (byte)0xfe, 0, (byte)0xd8}, 0), // BOM, followed by 'A', 'B', 'C', then by High surrogate (in UTF-16LE). // Fourth read() should throw an exception. - {new byte[] {(byte)0xff, (byte)0xfe, (byte)0x41, 0, (byte)0x42, 0, (byte)0x43, 0, 0, (byte)0xd8}, 3}, - }; + Arguments.of(new byte[] {(byte)0xff, (byte)0xfe, (byte)0x41, 0, (byte)0x42, 0, (byte)0x43, 0, 0, (byte)0xd8}, 3)); } - @Test (dataProvider = "inputs") + @ParameterizedTest + @MethodSource("inputs") public void testStatefulDecoderNearEOF(byte[] ba, int numSucessReads) throws IOException { try (var r = new InputStreamReader( new ByteArrayInputStream(ba), diff --git a/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java b/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java index d735e78f684..187bef037c5 100644 --- a/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java +++ b/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 8218280 * @summary Make sure marking a line feed within a CRLF sequence works correctly - * @run testng MarkSplitCRLF + * @run junit MarkSplitCRLF */ import java.io.IOException; @@ -32,13 +32,13 @@ import java.io.LineNumberReader; import java.io.Reader; import java.io.StringReader; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MarkSplitCRLF { @Test - public static void testSpecifiedBufferSize() throws IOException { + public void testSpecifiedBufferSize() throws IOException { final String string = "foo\r\nbar"; try (Reader reader = new LineNumberReader(new StringReader(string), 5)) { @@ -56,7 +56,7 @@ public class MarkSplitCRLF { } @Test - public static void testCRNotFollowedByLF() throws IOException { + public void testCRNotFollowedByLF() throws IOException { final String string = "foo\rbar"; try (Reader reader = new LineNumberReader(new StringReader(string), 5)) { @@ -74,7 +74,7 @@ public class MarkSplitCRLF { } @Test - public static void testDefaultBufferSize() throws IOException { + public void testDefaultBufferSize() throws IOException { StringBuilder sb = new StringBuilder(8195); for (int i = 0; i < 8190; i++) { char c = (char)i; diff --git a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java index 4004cbcf859..b1765b04060 100644 --- a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java +++ b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,10 @@ import java.lang.ref.WeakReference; import java.io.ObjectStreamClass; import java.io.Serializable; import java.util.ArrayList; -import org.testng.annotations.Test; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test id=G1 @@ -36,7 +37,7 @@ import static org.testng.Assert.assertTrue; * @bug 8277072 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (G1 GC) - * @run testng/othervm -Xmx64m -XX:+UseG1GC ObjectStreamClassCaching + * @run junit/othervm -Xmx64m -XX:+UseG1GC ObjectStreamClassCaching */ /* @@ -45,7 +46,7 @@ import static org.testng.Assert.assertTrue; * @bug 8277072 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (Parallel GC) - * @run testng/othervm -Xmx64m -XX:+UseParallelGC ObjectStreamClassCaching + * @run junit/othervm -Xmx64m -XX:+UseParallelGC ObjectStreamClassCaching */ /* @@ -54,7 +55,7 @@ import static org.testng.Assert.assertTrue; * @bug 8277072 8327180 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (ZGC) - * @run testng/othervm -Xmx64m -XX:+UseZGC ObjectStreamClassCaching + * @run junit/othervm -Xmx64m -XX:+UseZGC ObjectStreamClassCaching */ /* @@ -63,7 +64,7 @@ import static org.testng.Assert.assertTrue; * @bug 8277072 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (Shenandoah GC) - * @run testng/othervm -Xmx64m -XX:+UseShenandoahGC ObjectStreamClassCaching + * @run junit/othervm -Xmx64m -XX:+UseShenandoahGC ObjectStreamClassCaching */ /* @@ -72,7 +73,7 @@ import static org.testng.Assert.assertTrue; * @bug 8277072 8327180 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC) - * @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching + * @run junit/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching */ public class ObjectStreamClassCaching { diff --git a/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java b/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java index 1816aa45fe7..e7b944f6574 100644 --- a/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java +++ b/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,18 +29,20 @@ import java.io.ObjectStreamClass; import java.io.ObjectStreamField; import java.io.Serializable; import java.util.Arrays; -import org.testng.annotations.Test; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; import jdk.test.lib.util.ForceGC; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /* @test * @bug 8277072 * @library /test/lib/ * @build jdk.test.lib.util.ForceGC * @summary ObjectStreamClass caches keep ClassLoaders alive - * @run testng TestOSCClassLoaderLeak + * @run junit TestOSCClassLoaderLeak */ public class TestOSCClassLoaderLeak { diff --git a/test/jdk/java/io/OutputStream/NullOutputStream.java b/test/jdk/java/io/OutputStream/NullOutputStream.java index e0041e424d8..d0f76596db3 100644 --- a/test/jdk/java/io/OutputStream/NullOutputStream.java +++ b/test/jdk/java/io/OutputStream/NullOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,85 +21,64 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import java.io.IOException; import java.io.OutputStream; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 4358774 - * @run testng NullOutputStream + * @run junit NullOutputStream * @summary Check for expected behavior of OutputStream.nullOutputStream(). */ public class NullOutputStream { private static OutputStream openStream; private static OutputStream closedStream; - @BeforeClass + @BeforeAll public static void setup() { openStream = OutputStream.nullOutputStream(); closedStream = OutputStream.nullOutputStream(); - try { - closedStream.close(); - } catch (IOException e) { - fail("Unexpected IOException"); - } + assertDoesNotThrow(() -> closedStream.close()); } - @AfterClass + @AfterAll public static void closeStream() { - try { - openStream.close(); - } catch (IOException e) { - fail("Unexpected IOException"); - } + assertDoesNotThrow(() -> openStream.close()); } @Test - public static void testOpen() { + public void testOpen() { assertNotNull(openStream, "OutputStream.nullOutputStream() returned null"); } @Test - public static void testWrite() { - try { - openStream.write(62832); - } catch (IOException e) { - fail("Unexpected IOException"); - } + public void testWrite() throws IOException { + openStream.write(62832); } @Test - public static void testWriteBII() { - try { - openStream.write(new byte[] {(byte)6}, 0, 1); - } catch (Exception e) { - fail("Unexpected IOException"); - } + public void testWriteBII() { + assertDoesNotThrow(() -> openStream.write(new byte[] {(byte)6}, 0, 1)); } @Test - public static void testWriteClosed() { - try { - closedStream.write(62832); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testWriteClosed() { + assertThrows(IOException.class, () -> closedStream.write(62832)); } @Test - public static void testWriteBIIClosed() { - try { - closedStream.write(new byte[] {(byte)6}, 0, 1); - fail("Expected IOException not thrown"); - } catch (IOException e) { - } + public void testWriteBIIClosed() { + assertThrows(IOException.class, + () -> closedStream.write(new byte[] {(byte)6}, 0, 1)); } } diff --git a/test/jdk/java/io/PrintStream/EncodingTest.java b/test/jdk/java/io/PrintStream/EncodingTest.java index d767b5801d3..a0fe27b81cb 100644 --- a/test/jdk/java/io/PrintStream/EncodingTest.java +++ b/test/jdk/java/io/PrintStream/EncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,16 +29,20 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @bug 8183743 * @summary Test to verify the new overload method with Charset functions the same * as the existing method that takes a charset name. - * @run testng EncodingTest + * @run junit EncodingTest */ public class EncodingTest { static String USER_DIR = System.getProperty("user.dir", "."); @@ -50,22 +54,20 @@ public class EncodingTest { } /* - * DataProvider fields: + * MethodSource fields: * Type of the constructor, a file to be written with a charset name, * a file to be written with a charset, charset name, charset. */ - @DataProvider(name = "parameters") - public Object[][] getParameters() throws IOException { + public static Stream parameters() throws IOException { String csn = StandardCharsets.UTF_8.name(); Charset charset = StandardCharsets.UTF_8; File file1 = new File(USER_DIR, "PSCharsetTest1.txt"); File file2 = new File(USER_DIR, "PSCharsetTest2.txt"); - return new Object[][]{ - {ConstructorType.STRING, file1, file2, csn, charset}, - {ConstructorType.FILE, file1, file2, csn, charset}, - {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} - }; + return Stream.of + (Arguments.of(ConstructorType.STRING, file1, file2, csn, charset), + Arguments.of(ConstructorType.FILE, file1, file2, csn, charset), + Arguments.of(ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset)); } /** @@ -78,14 +80,15 @@ public class EncodingTest { * @param charset the charset * @throws IOException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("parameters") public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) throws Exception { createFile(getPrintStream(type, file1.getPath(), csn, null)); createFile(getPrintStream(type, file2.getPath(), null, charset)); - Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), - Files.readAllLines(Paths.get(file2.getPath()), charset)); + assertEquals(Files.readAllLines(Paths.get(file2.getPath()), charset), + Files.readAllLines(Paths.get(file1.getPath()), charset)); } public void createFile(PrintStream out) throws IOException { diff --git a/test/jdk/java/io/PrintStream/InheritEncodingTest.java b/test/jdk/java/io/PrintStream/InheritEncodingTest.java index e31404114a0..094a1d4e0be 100644 --- a/test/jdk/java/io/PrintStream/InheritEncodingTest.java +++ b/test/jdk/java/io/PrintStream/InheritEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,10 +21,6 @@ * questions. */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; @@ -33,31 +29,35 @@ import java.io.PrintWriter; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @test * @bug 8276970 * @summary Test to verify the charset in PrintStream is inherited * in the OutputStreamWriter/PrintWriter - * @run testng InheritEncodingTest + * @run junit InheritEncodingTest */ -@Test public class InheritEncodingTest { private static final String testString = "\u00e9\u3042"; // "éあ" - @DataProvider - public Object[][] encodings() { - return new Object[][]{ - {StandardCharsets.ISO_8859_1}, - {StandardCharsets.US_ASCII}, - {StandardCharsets.UTF_8}, - {StandardCharsets.UTF_16}, - {StandardCharsets.UTF_16BE}, - {StandardCharsets.UTF_16LE}, + public static Charset[] encodings() { + return new Charset[]{ + StandardCharsets.ISO_8859_1, + StandardCharsets.US_ASCII, + StandardCharsets.UTF_8, + StandardCharsets.UTF_16, + StandardCharsets.UTF_16BE, + StandardCharsets.UTF_16LE }; } - @Test (dataProvider = "encodings") + @ParameterizedTest + @MethodSource("encodings") public void testOutputStreamWriter(Charset stdCharset) throws IOException { var ba = new ByteArrayOutputStream(); var ps = new PrintStream(ba, true, stdCharset); @@ -65,16 +65,17 @@ public class InheritEncodingTest { // tests OutputStreamWriter's encoding explicitly var osw = new OutputStreamWriter(ps); - assertEquals(Charset.forName(osw.getEncoding()), stdCharset); + assertEquals(stdCharset, Charset.forName(osw.getEncoding())); // tests roundtrip result osw.write(testString); osw.flush(); var result = ba.toString(stdCharset); - assertEquals(result, expected); + assertEquals(expected, result); } - @Test (dataProvider = "encodings") + @ParameterizedTest + @MethodSource("encodings") public void testPrintWriter(Charset stdCharset) throws IOException { var ba = new ByteArrayOutputStream(); var ps = new PrintStream(ba, true, stdCharset); @@ -85,10 +86,11 @@ public class InheritEncodingTest { pw.write(testString); pw.flush(); var result = ba.toString(stdCharset); - assertEquals(result, expected); + assertEquals(expected, result); } - @Test (dataProvider = "encodings") + @ParameterizedTest + @MethodSource("encodings") public void testPrintStream(Charset stdCharset) throws IOException { var ba = new ByteArrayOutputStream(); var ps = new PrintStream(ba, true, stdCharset); @@ -96,12 +98,12 @@ public class InheritEncodingTest { // tests PrintStream's charset explicitly var psWrapper = new PrintStream(ps); - assertEquals(psWrapper.charset(), stdCharset); + assertEquals(stdCharset, psWrapper.charset()); // tests roundtrip result psWrapper.print(testString); psWrapper.flush(); var result = ba.toString(stdCharset); - assertEquals(result, expected); + assertEquals(expected, result); } } diff --git a/test/jdk/java/io/PrintWriter/EncodingTest.java b/test/jdk/java/io/PrintWriter/EncodingTest.java index f02944d9900..ef6e8b0094b 100644 --- a/test/jdk/java/io/PrintWriter/EncodingTest.java +++ b/test/jdk/java/io/PrintWriter/EncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,16 +29,20 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @bug 8183743 * @summary Test to verify the new overload method with Charset functions the same * as the existing method that takes a charset name. - * @run testng EncodingTest + * @run junit EncodingTest */ public class EncodingTest { static String USER_DIR = System.getProperty("user.dir", "."); @@ -54,18 +58,16 @@ public class EncodingTest { * Type of the constructor, a file to be written with a charset name, * a file to be written with a charset, charset name, charset. */ - @DataProvider(name = "parameters") - public Object[][] getParameters() throws IOException { + public static Stream parameters() throws IOException { String csn = StandardCharsets.UTF_8.name(); Charset charset = StandardCharsets.UTF_8; File file1 = new File(USER_DIR, "PWCharsetTest1.txt"); File file2 = new File(USER_DIR, "PWCharsetTest2.txt"); - return new Object[][]{ - {ConstructorType.STRING, file1, file2, csn, charset}, - {ConstructorType.FILE, file1, file2, csn, charset}, - {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} - }; + return Stream.of + (Arguments.of(ConstructorType.STRING, file1, file2, csn, charset), + Arguments.of(ConstructorType.FILE, file1, file2, csn, charset), + Arguments.of(ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset)); } /** @@ -79,14 +81,15 @@ public class EncodingTest { * @param charset the charset * @throws IOException */ - @Test(dataProvider = "parameters") + @ParameterizedTest + @MethodSource("parameters") public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) throws Exception { createFile(getWriter(type, file1.getPath(), csn, null)); createFile(getWriter(type, file2.getPath(), null, charset)); - Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), - Files.readAllLines(Paths.get(file2.getPath()), charset)); + assertEquals(Files.readAllLines(Paths.get(file2.getPath()), charset), + Files.readAllLines(Paths.get(file1.getPath()), charset)); } void createFile(PrintWriter out) throws IOException { diff --git a/test/jdk/java/io/PushbackInputStream/TransferTo.java b/test/jdk/java/io/PushbackInputStream/TransferTo.java index 0a27d88bc70..5d601748003 100644 --- a/test/jdk/java/io/PushbackInputStream/TransferTo.java +++ b/test/jdk/java/io/PushbackInputStream/TransferTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,21 +32,21 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; -import org.testng.annotations.Test; +import static java.lang.String.format; import jdk.test.lib.RandomFactory; -import static java.lang.String.format; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=180 TransferTo + * @run junit/othervm/timeout=180 TransferTo * @bug 8296431 * @summary Tests whether java.io.PushbackInputStream.transferTo conforms to the * InputStream.transferTo specification @@ -162,7 +162,7 @@ public class TransferTo { long reported = in.transferTo(out); int count = inBytes.length - posIn; - assertEquals(reported, count, + assertEquals(count, reported, format("reported %d bytes but should report %d", reported, count)); byte[] outBytes = recorder.get().get(); diff --git a/test/jdk/java/io/Reader/NullReader.java b/test/jdk/java/io/Reader/NullReader.java index 9c16f33df1c..b80c1a9f67a 100644 --- a/test/jdk/java/io/Reader/NullReader.java +++ b/test/jdk/java/io/Reader/NullReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,118 +27,125 @@ import java.io.StringWriter; import java.nio.CharBuffer; import java.nio.ReadOnlyBufferException; -import org.testng.annotations.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8196298 8204930 - * @run testng NullReader + * @run junit NullReader * @summary Check for expected behavior of Reader.nullReader(). */ public class NullReader { private static Reader openReader; private static Reader closedReader; - @BeforeClass + @BeforeAll public static void setup() throws IOException { openReader = Reader.nullReader(); closedReader = Reader.nullReader(); closedReader.close(); } - @AfterClass + @AfterAll public static void closeStream() throws IOException { openReader.close(); } @Test - public static void testOpen() { + public void testOpen() { assertNotNull(openReader, "Reader.nullReader() returned null"); } @Test - public static void testRead() throws IOException { + public void testRead() throws IOException { assertEquals(-1, openReader.read(), "read() != -1"); } @Test - public static void testReadBII() throws IOException { + public void testReadBII() throws IOException { assertEquals(-1, openReader.read(new char[1], 0, 1), "read(char[],int,int) != -1"); } @Test - public static void testReadBIILenZero() throws IOException { + public void testReadBIILenZero() throws IOException { assertEquals(0, openReader.read(new char[1], 0, 0), "read(char[],int,int) != 0"); } @Test - public static void testReadCharBuffer() throws IOException { + public void testReadCharBuffer() throws IOException { CharBuffer charBuffer = CharBuffer.allocate(1); assertEquals(-1, openReader.read(charBuffer), "read(CharBuffer) != -1"); } @Test - public static void testReadCharBufferZeroRemaining() throws IOException { + public void testReadCharBufferZeroRemaining() throws IOException { CharBuffer charBuffer = CharBuffer.allocate(0); assertEquals(0, openReader.read(charBuffer), "read(CharBuffer) != 0"); } @Test - public static void testReady() throws IOException { + public void testReady() throws IOException { assertFalse(openReader.ready()); } @Test - public static void testSkip() throws IOException { + public void testSkip() throws IOException { assertEquals(0, openReader.skip(1), "skip() != 0"); } @Test - public static void testTransferTo() throws IOException { + public void testTransferTo() throws IOException { assertEquals(0, openReader.transferTo(new StringWriter(7)), "transferTo() != 0"); } - @Test(expectedExceptions = IOException.class) - public static void testReadClosed() throws IOException { - closedReader.read(); + @Test + public void testReadClosed() throws IOException { + assertThrows(IOException.class, () -> closedReader.read()); } - @Test(expectedExceptions = IOException.class) - public static void testReadBIIClosed() throws IOException { - closedReader.read(new char[1], 0, 1); + @Test + public void testReadBIIClosed() throws IOException { + assertThrows(IOException.class, + () -> closedReader.read(new char[1], 0, 1)); } - @Test(expectedExceptions = IOException.class) - public static void testReadCharBufferClosed() throws IOException { + @Test + public void testReadCharBufferClosed() throws IOException { CharBuffer charBuffer = CharBuffer.allocate(0); - closedReader.read(charBuffer); + assertThrows(IOException.class, () -> closedReader.read(charBuffer)); } - @Test(expectedExceptions = IOException.class) - public static void testReadCharBufferZeroRemainingClosed() throws IOException { + @Test + public void testReadCharBufferZeroRemainingClosed() throws IOException { CharBuffer charBuffer = CharBuffer.allocate(0); - closedReader.read(charBuffer); + assertThrows(IOException.class, () -> closedReader.read(charBuffer)); } - @Test(expectedExceptions = IOException.class) - public static void testReadyClosed() throws IOException { - closedReader.ready(); + @Test + public void testReadyClosed() throws IOException { + assertThrows(IOException.class, () -> closedReader.ready()); } - @Test(expectedExceptions = IOException.class) - public static void testSkipClosed() throws IOException { - closedReader.skip(1); + @Test + public void testSkipClosed() throws IOException { + assertThrows(IOException.class, () -> closedReader.skip(1)); } - @Test(expectedExceptions = IOException.class) - public static void testTransferToClosed() throws IOException { - closedReader.transferTo(new StringWriter(7)); + @Test + public void testTransferToClosed() throws IOException { + assertThrows(IOException.class, + () -> closedReader.transferTo(new StringWriter(7))); } } diff --git a/test/jdk/java/io/Reader/Of.java b/test/jdk/java/io/Reader/Of.java index 491c0499e6b..7d3e039b920 100644 --- a/test/jdk/java/io/Reader/Of.java +++ b/test/jdk/java/io/Reader/Of.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,18 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.ReadOnlyBufferException; -import org.testng.annotations.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 8341566 * @summary Check for expected behavior of Reader.of(). - * @run testng Of + * @run junit Of */ public class Of { final static String CONTENT = "Some Reader Test"; @@ -45,7 +48,6 @@ public class Of { /* * Readers to be tested. */ - @DataProvider public static Reader[] readers() { return new Reader[] { new StringReader(CONTENT), @@ -81,135 +83,152 @@ public class Of { }; } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testRead(Reader reader) throws IOException { String s = ""; for (int c; (c = reader.read()) != -1; s += (char) c); - assertEquals(s, CONTENT, "read() returned wrong value"); + assertEquals(CONTENT, s, "read() returned wrong value"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadBII(Reader reader) throws IOException { char[] c = new char[16]; - assertEquals(reader.read(c, 8, 8), 8, + assertEquals(8, reader.read(c, 8, 8), "read(char[],int,int) does not respect given start or end"); - assertEquals(reader.read(c, 0, 16), 8, + assertEquals(8, reader.read(c, 0, 16), "read(char[],int,int) does not respect end of stream"); - assertEquals(new String(c), - CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + assertEquals(CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + new String(c), "read(char[],int,int) provides wrong content"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadBIILenZero(Reader reader) throws IOException { - assertEquals(reader.read(new char[1], 0, 0), 0, + assertEquals(0, reader.read(new char[1], 0, 0), "read(char[],int,int) != 0"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadDirectCharBuffer(Reader reader) throws IOException { CharBuffer charBuffer = ByteBuffer.allocateDirect(32).asCharBuffer(); charBuffer.position(8); - assertEquals(reader.read(charBuffer), 8, + assertEquals(8, reader.read(charBuffer), "read(CharBuffer) does not respect position or limit"); charBuffer.rewind(); - assertEquals(reader.read(charBuffer), 8, + assertEquals(8, reader.read(charBuffer), "read(CharBuffer) does not respect end of stream"); charBuffer.rewind(); - assertEquals(charBuffer.toString(), - // last part first proofs that copy loops correctly stopped - CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + // last part first proves that copy loops correctly stopped + assertEquals(CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + charBuffer.toString(), "read(CharBuffer) provides wrong content"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadNonDirectCharBuffer(Reader reader) throws IOException { CharBuffer charBuffer = CharBuffer.allocate(16); charBuffer.position(8); - assertEquals(reader.read(charBuffer), 8, + assertEquals(8, reader.read(charBuffer), "read(CharBuffer) does not respect position or limit"); charBuffer.rewind(); - assertEquals(reader.read(charBuffer), 8, + assertEquals(8, reader.read(charBuffer), "read(CharBuffer) does not respect end of stream"); charBuffer.rewind(); - assertEquals(charBuffer.toString(), - CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + assertEquals(CONTENT.substring(8, 16) + CONTENT.substring(0, 8), + charBuffer.toString(), "read(CharBuffer) provides wrong content"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadCharBufferZeroRemaining(Reader reader) throws IOException { CharBuffer charBuffer = CharBuffer.allocate(0); - assertEquals(reader.read(charBuffer), 0, "read(CharBuffer) != 0"); + assertEquals(0, reader.read(charBuffer), "read(CharBuffer) != 0"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReady(Reader reader) throws IOException { assertTrue(reader.ready()); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testSkip(Reader reader) throws IOException { - assertEquals(reader.skip(8), 8, "skip() does not respect limit"); - assertEquals(reader.skip(9), 8, "skip() does not respect end of stream"); - assertEquals(reader.skip(1), 0, "skip() does not respect empty stream"); + assertEquals(8, reader.skip(8), "skip() does not respect limit"); + assertEquals(8, reader.skip(9), "skip() does not respect end of stream"); + assertEquals(0, reader.skip(1), "skip() does not respect empty stream"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testTransferTo(Reader reader) throws IOException { StringWriter sw = new StringWriter(16); - assertEquals(reader.transferTo(sw), 16, "transferTo() != 16"); - assertEquals(reader.transferTo(sw), 0, + assertEquals(16, reader.transferTo(sw), "transferTo() != 16"); + assertEquals(0, reader.transferTo(sw), "transferTo() does not respect empty stream"); - assertEquals(sw.toString(), CONTENT, + assertEquals(CONTENT, sw.toString(), "transferTo() provides wrong content"); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadClosed(Reader reader) throws IOException { reader.close(); assertThrows(IOException.class, () -> {reader.read();}); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadBIIClosed(Reader reader) throws IOException { reader.close(); assertThrows(IOException.class, () -> reader.read(new char[1], 0, 1)); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadCharBufferClosed(Reader reader) throws IOException { CharBuffer charBuffer = CharBuffer.allocate(1); reader.close(); assertThrows(IOException.class, () -> reader.read(charBuffer)); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadCharBufferZeroRemainingClosed(Reader reader) throws IOException { CharBuffer charBuffer = CharBuffer.allocate(0); reader.close(); assertThrows(IOException.class, () -> reader.read(charBuffer)); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testReadyClosed(Reader reader) throws IOException { reader.close(); assertThrows(IOException.class, () -> reader.ready()); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testSkipClosed(Reader reader) throws IOException { reader.close(); assertThrows(IOException.class, () -> reader.skip(1)); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testTransferToClosed(Reader reader) throws IOException { reader.close(); assertThrows(IOException.class, () -> reader.transferTo(new StringWriter(1))); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void testCloseClosed(Reader reader) throws IOException { reader.close(); reader.close(); diff --git a/test/jdk/java/io/Reader/ReadCharBuffer.java b/test/jdk/java/io/Reader/ReadCharBuffer.java index c57860601fb..dc858999287 100644 --- a/test/jdk/java/io/Reader/ReadCharBuffer.java +++ b/test/jdk/java/io/Reader/ReadCharBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,40 +25,38 @@ * @test * @bug 4926314 8266014 * @summary Test for Reader#read(CharBuffer). - * @run testng ReadCharBuffer + * @run junit ReadCharBuffer */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - - -import java.io.IOException; import java.io.BufferedReader; import java.io.CharArrayReader; +import java.io.IOException; import java.io.Reader; import java.io.UncheckedIOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.util.Arrays; import java.util.Objects; +import java.util.stream.Stream; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; -@Test(groups = "unit") public class ReadCharBuffer { private static final int BUFFER_SIZE = 8 + 8192 + 2; - @DataProvider(name = "buffers") - public Object[][] createBuffers() { + public static Stream buffers() { // test both on-heap and off-heap buffers as they make use different code paths - return new Object[][]{ - new Object[]{CharBuffer.allocate(BUFFER_SIZE)}, - new Object[]{ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer()} - }; + return Stream.of(CharBuffer.allocate(BUFFER_SIZE), + ByteBuffer.allocateDirect(BUFFER_SIZE * 2).asCharBuffer()); } - @Test(dataProvider = "buffers") + @ParameterizedTest + @MethodSource("buffers") public void read(CharBuffer buffer) throws IOException { fillBuffer(buffer); @@ -74,21 +72,21 @@ public class ReadCharBuffer { int limit = 1 + 6; buffer.limit(limit); buffer.position(1); - assertEquals(reader.read(buffer), 6); - assertEquals(buffer.position(), limit); - assertEquals(buffer.limit(), limit); + assertEquals(6, reader.read(buffer)); + assertEquals(limit, buffer.position()); + assertEquals(limit, buffer.limit()); // read the full temporary buffer // and then accurately reduce the next #read call limit = 8 + 8192 + 1; buffer.limit(8 + 8192 + 1); buffer.position(8); - assertEquals(reader.read(buffer), 8192 + 1); - assertEquals(buffer.position(), limit); - assertEquals(buffer.limit(), limit); + assertEquals(8192 + 1, reader.read(buffer)); + assertEquals(limit, buffer.position()); + assertEquals(limit, buffer.limit()); - assertEquals(reader.read(), 'H'); - assertEquals(reader.read(), -1); + assertEquals('H', reader.read()); + assertEquals(-1, reader.read()); } buffer.clear(); @@ -98,20 +96,15 @@ public class ReadCharBuffer { expected.append('y'); } expected.append("Gx"); - assertEquals(buffer.toString(), expected.toString()); + assertEquals(expected.toString(), buffer.toString()); } @Test - public void readZeroLength() { + public void readZeroLength() throws IOException { char[] buf = new char[] {1, 2, 3}; BufferedReader r = new BufferedReader(new CharArrayReader(buf)); - int n = -1; - try { - n = r.read(CharBuffer.allocate(0)); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - assertEquals(n, 0); + int n = r.read(CharBuffer.allocate(0)); + assertEquals(0, n); } private void fillBuffer(CharBuffer buffer) { diff --git a/test/jdk/java/io/Reader/ReadIntoZeroLengthArray.java b/test/jdk/java/io/Reader/ReadIntoZeroLengthArray.java index 480cd32c981..e69a24d38f4 100644 --- a/test/jdk/java/io/Reader/ReadIntoZeroLengthArray.java +++ b/test/jdk/java/io/Reader/ReadIntoZeroLengthArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,55 +29,57 @@ import java.io.LineNumberReader; import java.io.PushbackReader; import java.io.Reader; import java.io.StringReader; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 8248383 * @summary Ensure that zero is returned for read into zero length array - * @run testng ReadIntoZeroLengthArray + * @run junit ReadIntoZeroLengthArray */ public class ReadIntoZeroLengthArray { - private File file; + private static File file; - private char[] cbuf0; - private char[] cbuf1; + private static char[] cbuf0; + private static char[] cbuf1; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { file = File.createTempFile("foo", "bar", new File(".")); + cbuf0 = new char[0]; cbuf1 = new char[1]; } - @AfterTest - public void teardown() throws IOException { + @AfterAll + public static void teardown() throws IOException { file.delete(); } - @DataProvider(name = "readers") - public Object[][] getReaders() throws IOException { - Reader fileReader = new FileReader(file); - return new Object[][] { - {new LineNumberReader(fileReader)}, - {new CharArrayReader(new char[] {27})}, - {new PushbackReader(fileReader)}, - {fileReader}, - {new StringReader(new String(new byte[] {(byte)42}))} - }; + public static Stream readers() throws IOException { + return Stream.of(new LineNumberReader(new FileReader(file)), + new CharArrayReader(new char[] {27}), + new PushbackReader(new FileReader(file)), + new FileReader(file), + new StringReader(new String(new byte[] {(byte)42}))); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") void test0(Reader r) throws IOException { - Assert.assertEquals(r.read(cbuf0), 0); + assertEquals(0, r.read(cbuf0)); } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") void test1(Reader r) throws IOException { - Assert.assertEquals(r.read(cbuf1, 0, 0), 0); + assertEquals(0, r.read(cbuf1, 0, 0)); } } diff --git a/test/jdk/java/io/Reader/Skip.java b/test/jdk/java/io/Reader/Skip.java index 9e311686507..80d260d4276 100644 --- a/test/jdk/java/io/Reader/Skip.java +++ b/test/jdk/java/io/Reader/Skip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 4134311 8247918 * @summary Test if skip works correctly - * @run testng Skip + * @run junit Skip */ import java.io.CharArrayReader; @@ -36,10 +36,16 @@ import java.io.PushbackReader; import java.io.RandomAccessFile; import java.io.Reader; import java.io.StringReader; +import java.util.stream.Stream; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; public class Skip { private static String FILENAME = @@ -52,52 +58,52 @@ public class Skip { long nchars = 8200; long actual = fr.skip(nchars); - Assert.assertFalse(actual > nchars, + assertFalse(actual > nchars, "Should skip " + nchars + ", but skipped " +actual+" chars"); } } - @DataProvider(name = "readers") - public Object[][] getReaders() throws IOException { - return new Object[][] { - {new LineNumberReader(new FileReader(file))}, - {new CharArrayReader(new char[] {27})}, - {new PushbackReader(new FileReader(file))}, - {new FileReader(file)}, - {new StringReader(new String(new byte[] {(byte)42}))} + public static Reader[] readers() throws IOException { + return new Reader[] { + new LineNumberReader(new FileReader(file)), + new CharArrayReader(new char[] {27}), + new PushbackReader(new FileReader(file)), + new FileReader(file), + new StringReader(new String(new byte[] {(byte)42})) }; } - @Test(dataProvider = "readers") + @ParameterizedTest + @MethodSource("readers") public void eof(Reader r) throws IOException { r.skip(Long.MAX_VALUE); - Assert.assertEquals(r.skip(1), 0); - Assert.assertEquals(r.read(), -1); + assertEquals(0, r.skip(1)); + assertEquals(-1, r.read()); } - @DataProvider(name = "skipIAE") - public Object[][] getSkipIAEs() throws IOException { - return new Object[][] { - {new LineNumberReader(new FileReader(file))}, - {new PushbackReader(new FileReader(file))}, - {new FileReader(file)} + public static Reader[] skipIAE() throws IOException { + return new Reader[] { + new LineNumberReader(new FileReader(file)), + new PushbackReader(new FileReader(file)), + new FileReader(file) }; } - @Test(dataProvider = "skipIAE", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("skipIAE") public void testThrowsIAE(Reader r) throws IOException { - r.skip(-1); + assertThrows(IllegalArgumentException.class, () -> r.skip(-1)); } - @DataProvider(name = "skipNoIAE") - public Object[][] getSkipNoIAEs() throws IOException { - return new Object[][] { - {new CharArrayReader(new char[] {27})}, - {new StringReader(new String(new byte[] {(byte)42}))} + public static Reader[] skipNoIAE() throws IOException { + return new Reader[] { + new CharArrayReader(new char[] {27}), + new StringReader(new String(new byte[] {(byte)42})) }; } - @Test(dataProvider = "skipNoIAE") + @ParameterizedTest + @MethodSource("skipNoIAE") public void testNoIAE(Reader r) throws IOException { r.skip(-1); } diff --git a/test/jdk/java/io/SequenceInputStream/TransferTo.java b/test/jdk/java/io/SequenceInputStream/TransferTo.java index 4c8ff71a4f3..8ea9a77672e 100644 --- a/test/jdk/java/io/SequenceInputStream/TransferTo.java +++ b/test/jdk/java/io/SequenceInputStream/TransferTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,22 +33,22 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; -import org.testng.annotations.Test; +import static java.lang.String.format; import jdk.test.lib.RandomFactory; -import static java.lang.String.format; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=180 TransferTo + * @run junit/othervm/timeout=180 TransferTo * @bug 8297298 * @summary Tests whether java.io.SequenceInputStream.transferTo conforms to the * InputStream.transferTo specification @@ -141,8 +141,8 @@ public class TransferTo { SequenceInputStream sis = new SequenceInputStream(is1, is2); OutputStream nos = OutputStream.nullOutputStream(); sis.transferTo(nos); - assertEquals(is1.available(), 0); - assertEquals(is2.available(), 0); + assertEquals(0, is1.available()); + assertEquals(0, is2.available()); } /* @@ -200,7 +200,7 @@ public class TransferTo { long reported = in.transferTo(out); int count = inBytes.length - posIn; - assertEquals(reported, count, + assertEquals(count, reported, format("reported %d bytes but should report %d", reported, count)); byte[] outBytes = recorder.get().get(); diff --git a/test/jdk/java/io/Writer/NullWriter.java b/test/jdk/java/io/Writer/NullWriter.java index d632947f129..e37c8bd54dd 100644 --- a/test/jdk/java/io/Writer/NullWriter.java +++ b/test/jdk/java/io/Writer/NullWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,144 +21,146 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import java.io.IOException; import java.io.Writer; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8196298 - * @run testng NullWriter + * @run junit NullWriter * @summary Check for expected behavior of Writer.nullWriter(). */ public class NullWriter { private static Writer openWriter; private static Writer closedWriter; - @BeforeClass + @BeforeAll public static void setup() throws IOException { openWriter = Writer.nullWriter(); closedWriter = Writer.nullWriter(); closedWriter.close(); } - @AfterClass + @AfterAll public static void closeStream() throws IOException { openWriter.close(); } @Test - public static void testOpen() { + public void testOpen() { assertNotNull(openWriter, "Writer.nullWriter() returned null"); } @Test - public static void testAppendChar() throws IOException { + public void testAppendChar() throws IOException { assertSame(openWriter, openWriter.append('x')); } @Test - public static void testAppendCharSequence() throws IOException { + public void testAppendCharSequence() throws IOException { CharSequence cs = "abc"; assertSame(openWriter, openWriter.append(cs)); } @Test - public static void testAppendCharSequenceNull() throws IOException { + public void testAppendCharSequenceNull() throws IOException { assertSame(openWriter, openWriter.append(null)); } @Test - public static void testAppendCharSequenceII() throws IOException { + public void testAppendCharSequenceII() throws IOException { CharSequence cs = "abc"; assertSame(openWriter, openWriter.append(cs, 0, 1)); } @Test - public static void testAppendCharSequenceIINull() throws IOException { + public void testAppendCharSequenceIINull() throws IOException { assertSame(openWriter, openWriter.append(null, 2, 1)); } @Test - public static void testFlush() throws IOException { + public void testFlush() throws IOException { openWriter.flush(); } @Test - public static void testWrite() throws IOException { + public void testWrite() throws IOException { openWriter.write(62832); } @Test - public static void testWriteString() throws IOException { + public void testWriteString() throws IOException { openWriter.write(""); } @Test - public static void testWriteStringII() throws IOException { + public void testWriteStringII() throws IOException { openWriter.write("", 0, 0); } @Test - public static void testWriteBII() throws IOException, Exception { + public void testWriteBII() throws IOException, Exception { openWriter.write(new char[]{(char) 6}, 0, 1); } - @Test(expectedExceptions = IOException.class) - public static void testAppendCharClosed() throws IOException { - closedWriter.append('x'); + @Test + public void testAppendCharClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.append('x')); } - @Test(expectedExceptions = IOException.class) - public static void testAppendCharSequenceClosed() throws IOException { + @Test + public void testAppendCharSequenceClosed() throws IOException { CharSequence cs = "abc"; - closedWriter.append(cs); + assertThrows(IOException.class, () -> closedWriter.append(cs)); } - @Test(expectedExceptions = IOException.class) - public static void testAppendCharSequenceNullClosed() throws IOException { - closedWriter.append(null); + @Test + public void testAppendCharSequenceNullClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.append(null)); } - @Test(expectedExceptions = IOException.class) - public static void testAppendCharSequenceIIClosed() throws IOException { + @Test + public void testAppendCharSequenceIIClosed() throws IOException { CharSequence cs = "abc"; - closedWriter.append(cs, 0, 1); + assertThrows(IOException.class, () -> closedWriter.append(cs, 0, 1)); } - @Test(expectedExceptions = IOException.class) - public static void testAppendCharSequenceIINullClosed() throws IOException { - closedWriter.append(null, 2, 1); + @Test + public void testAppendCharSequenceIINullClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.append(null, 2, 1)); } - @Test(expectedExceptions = IOException.class) - public static void testFlushClosed() throws IOException { - closedWriter.flush(); + @Test + public void testFlushClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.flush()); } - @Test(expectedExceptions = IOException.class) - public static void testWriteClosed() throws IOException { - closedWriter.write(62832); + @Test + public void testWriteClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.write(62832)); } - @Test(expectedExceptions = IOException.class) - public static void testWriteStringClosed() throws IOException { - closedWriter.write(""); + @Test + public void testWriteStringClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.write("")); } - @Test(expectedExceptions = IOException.class) - public static void testWriteStringIIClosed() throws IOException { - closedWriter.write("", 0, 0); + @Test + public void testWriteStringIIClosed() throws IOException { + assertThrows(IOException.class, () -> closedWriter.write("", 0, 0)); } - @Test(expectedExceptions = IOException.class) - public static void testWriteBIIClosed() throws IOException { - closedWriter.write(new char[]{(char) 6}, 0, 1); + @Test + public void testWriteBIIClosed() throws IOException { + assertThrows(IOException.class, + () -> closedWriter.write(new char[]{(char) 6}, 0, 1)); } } diff --git a/test/jdk/java/lang/Character/Latin1CaseConversion.java b/test/jdk/java/lang/Character/Latin1CaseConversion.java index a176bd4b002..436193c5f16 100644 --- a/test/jdk/java/lang/Character/Latin1CaseConversion.java +++ b/test/jdk/java/lang/Character/Latin1CaseConversion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,17 +21,16 @@ * questions. */ -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @test * @bug 8302877 * @summary Provides exhaustive verification of Character.toUpperCase and Character.toLowerCase * for all code points in the latin1 range 0-255. - * @run testng Latin1CaseConversion + * @run junit Latin1CaseConversion */ public class Latin1CaseConversion { @@ -44,41 +43,41 @@ public class Latin1CaseConversion { if (c < 0x41) { // Before A assertUnchanged(upper, lower, c); } else if (c <= 0x5A) { // A-Z - assertEquals(upper, c); - assertEquals(lower, c + 32); + assertEquals(c, upper); + assertEquals(c + 32, lower); } else if (c < 0x61) { // Between Z and a assertUnchanged(upper, lower, c); } else if (c <= 0x7A) { // a-z - assertEquals(upper, c - 32); - assertEquals(lower, c); + assertEquals(c - 32, upper); + assertEquals(c, lower); } else if (c < 0xB5) { // Between z and Micro Sign assertUnchanged(upper, lower, c); } else if (c == 0xB5) { // Special case for Micro Sign - assertEquals(upper, 0x39C); - assertEquals(lower, c); + assertEquals(0x39C, upper); + assertEquals(c, lower); } else if (c < 0xC0) { // Between my and A-grave assertUnchanged(upper, lower, c); } else if (c < 0xD7) { // A-grave - O with Diaeresis - assertEquals(upper, c); - assertEquals(lower, c + 32); + assertEquals(c, upper); + assertEquals(c + 32, lower); } else if (c == 0xD7) { // Multiplication assertUnchanged(upper, lower, c); } else if (c <= 0xDE) { // O with slash - Thorn - assertEquals(upper, c); - assertEquals(lower, c + 32); + assertEquals(c, upper); + assertEquals(c + 32, lower); } else if (c == 0xDF) { // Sharp s assertUnchanged(upper, lower, c); } else if (c < 0xF7) { // a-grave - divsion - assertEquals(upper, c - 32); - assertEquals(lower, c); + assertEquals(c - 32, upper); + assertEquals(c, lower); } else if (c == 0xF7) { // Division assertUnchanged(upper, lower, c); } else if (c < 0xFF) { // o with slash - thorn - assertEquals(upper, c - 32); - assertEquals(lower, c); + assertEquals(c - 32, upper); + assertEquals(c, lower); } else if (c == 0XFF) { // Special case for y with Diaeresis - assertEquals(upper, 0x178); - assertEquals(lower, c); + assertEquals(0x178, upper); + assertEquals(c, lower); } else { fail("Uncovered code point: " + Integer.toHexString(c)); } @@ -86,7 +85,7 @@ public class Latin1CaseConversion { } private static void assertUnchanged(int upper, int lower, int c) { - assertEquals(upper, c); - assertEquals(lower, c); + assertEquals(c, upper); + assertEquals(c, lower); } } diff --git a/test/jdk/java/lang/Character/UnicodeBlock/NumberEntities.java b/test/jdk/java/lang/Character/UnicodeBlock/NumberEntities.java index 30382c3cfe3..86b9fe6ea69 100644 --- a/test/jdk/java/lang/Character/UnicodeBlock/NumberEntities.java +++ b/test/jdk/java/lang/Character/UnicodeBlock/NumberEntities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,17 +28,17 @@ * of Character.UnicodeBlock constants. Also checks the size of * Character.UnicodeScript's "aliases" map. * @modules java.base/java.lang:open - * @run testng NumberEntities + * @run junit NumberEntities */ -import static org.testng.Assert.assertEquals; -import org.testng.annotations.Test; - import java.lang.reflect.Field; import java.util.Map; -@Test +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class NumberEntities { + @Test public void test_UnicodeBlock_NumberEntities() throws Throwable { // The number of entries in Character.UnicodeBlock.map. // See src/java.base/share/classes/java/lang/Character.java @@ -46,13 +46,14 @@ public class NumberEntities { Field m = Character.UnicodeBlock.class.getDeclaredField("map"); n.setAccessible(true); m.setAccessible(true); - assertEquals(((Map)m.get(null)).size(), n.getInt(null)); + assertEquals(n.getInt(null), ((Map)m.get(null)).size()); } + @Test public void test_UnicodeScript_aliases() throws Throwable { // The number of entries in Character.UnicodeScript.aliases. // See src/java.base/share/classes/java/lang/Character.java Field aliases = Character.UnicodeScript.class.getDeclaredField("aliases"); aliases.setAccessible(true); - assertEquals(((Map)aliases.get(null)).size(), Character.UnicodeScript.UNKNOWN.ordinal() + 1); + assertEquals(Character.UnicodeScript.UNKNOWN.ordinal() + 1, ((Map)aliases.get(null)).size()); } } diff --git a/test/jdk/java/lang/Math/HyperbolicTests.java b/test/jdk/java/lang/Math/HyperbolicTests.java index 6f4fad94f6b..f45f0d25a48 100644 --- a/test/jdk/java/lang/Math/HyperbolicTests.java +++ b/test/jdk/java/lang/Math/HyperbolicTests.java @@ -27,7 +27,7 @@ * @build Tests * @build HyperbolicTests * @run main HyperbolicTests - * @summary Tests for {Math, StrictMath}.{sinh, cosh, tanh, asinh} + * @summary Tests for {Math, StrictMath}.{sinh, cosh, tanh, asinh, acosh, atanh} */ import static java.lang.Double.longBitsToDouble; @@ -44,6 +44,8 @@ public class HyperbolicTests { failures += testCosh(); failures += testTanh(); failures += testAsinh(); + failures += testAcosh(); + failures += testAtanh(); if (failures > 0) { System.err.println("Testing the hyperbolic functions incurred " @@ -1732,4 +1734,755 @@ public class HyperbolicTests { failures += Tests.testUlpDiffWithAbsBound("StrictMath.asinh", -input, StrictMath::asinh, -expected, ulps, Double.NEGATIVE_INFINITY); return failures; } + + /** + * Test accuracy of {Math, StrictMath}.acosh. The specified + * accuracy is 2.5 ulps. + * + * The defintion of acosh(x) is + * + * acosh(cosh(x)) = x + * + * Can be also written as + * + * acosh(x) = ln(x + sqrt(x * x - 1)) + * + * The series expansion of acosh(x) = + * + * ln(2 * x) - (x^-2 / 4 + 3 * x^-4 / 32 + 15 * x^-6 / 288 ...) + * + * Therefore, + * + * 1. acosh(1) = 0. + * + * 2. The domain is x >= 1. + * + * 3. The function is neither odd nor even. + * + */ + static int testAcosh() { + int failures = 0; + /* + * Array elements below generated using a quad acosh + * implementation. Rounded to a double, the quad result + * *should* be correctly rounded, unless we are quite unlucky. + * Assuming the quad value is a correctly rounded double, the + * allowed error is 3.0 ulps instead of 2.5 since the quad + * value rounded to double can have its own 1/2 ulp error. + */ + double [][] testCases = { + // x acosh(x) + {1.0000, +0.00000000000000000000000000000000000e+00 }, + {1.0625, +3.51737390043260579770744786121122844e-01 }, + {1.1250, +4.94932923094526905889563099576718556e-01 }, + {1.1875, +6.03186598686334413155297365190676416e-01 }, + {1.2500, +6.93147180559945309417232121458176575e-01 }, + {1.3125, +7.71307459173256653700937951825817144e-01 }, + {1.3750, +8.41019322011445738489485196126304665e-01 }, + {1.4375, +9.04286762705515769042139988689583282e-01 }, + {1.5000, +9.62423650119206894995517826848736845e-01 }, + {1.5625, +1.01634809667840380541358127166594224e+00 }, + {1.6250, +1.06673243190143557362309154628644597e+00 }, + {1.6875, +1.11408700135293645158376433073169476e+00 }, + {1.7500, +1.15881036042994681173087299087873020e+00 }, + {1.8125, +1.20122101997969472087682270695675759e+00 }, + {1.8750, +1.24157842330772117651284669611837885e+00 }, + {1.9375, +1.28009731675807455651225000558265526e+00 }, + {2.0000, +1.31695789692481670862504634730796848e+00 }, + {2.0625, +1.35231316261931093541047819670045078e+00 }, + {2.1250, +1.38629436111989061883446424291635315e+00 }, + {2.1875, +1.41901510140371506613255066437684651e+00 }, + {2.2500, +1.45057451382258020872826178236677635e+00 }, + {2.3125, +1.48105971405608381331792780208719133e+00 }, + {2.3750, +1.51054775047320739150161777699985299e+00 }, + {2.4375, +1.53910716184424377297903295285722198e+00 }, + {2.5000, +1.56679923697241107866405686258048358e+00 }, + {2.5625, +1.59367904336440765353731339657532894e+00 }, + {2.6250, +1.61979627485649999465013597110633349e+00 }, + {2.6875, +1.64519595581279452177517379518794699e+00 }, + {2.7500, +1.66991903058776998677838891147712239e+00 }, + {2.8125, +1.69400286038199600062127876942753998e+00 }, + {2.8750, +1.71748164473336519458386901818676709e+00 }, + {2.9375, +1.74038678120611400701568860843885133e+00 }, + {3.0000, +1.76274717403908605046521864995958460e+00 }, + {3.0625, +1.78458950036205246630242932084698860e+00 }, + {3.1250, +1.80593844091928647006641838950547765e+00 }, + {3.1875, +1.82681688093354809536648865402886324e+00 }, + {3.2500, +1.84724608571383784130004129627716938e+00 }, + {3.3125, +1.86724585479221893347421970944127165e+00 }, + {3.3750, +1.88683465772058517690549455261749833e+00 }, + {3.4375, +1.90602975413127236084850555002346490e+00 }, + {3.5000, +1.92484730023841378999103565369747369e+00 }, + {3.5625, +1.94330244360892107348697778473632964e+00 }, + {3.6250, +1.96140940774674480423275041043129955e+00 }, + {3.6875, +1.97918156779907568924375778194574535e+00 }, + {3.7500, +1.99663151849857170393899871209510294e+00 }, + {3.8125, +2.01377113529382496280930762219993708e+00 }, + {3.8750, +2.03061162948500957172739654092925159e+00 }, + {3.9375, +2.04716359806812267677620352283230977e+00 }, + {4.0000, +2.06343706889556054672728117262013178e+00 }, + {4.0625, +2.07944154167983592825169636437452953e+00 }, + {4.1250, +2.09518602529851747179664246793750599e+00 }, + {4.1875, +2.11067907179990670152964344211957784e+00 }, + {4.2500, +2.12592880745889053593506179143141713e+00 }, + {4.3125, +2.14094296118944770996055814756135545e+00 }, + {4.3750, +2.15572889058331846311473049052403906e+00 }, + {4.4375, +2.17029360581243752070499251797833202e+00 }, + {4.5000, +2.18464379160510872667627813307212784e+00 }, + {4.5625, +2.19878582748192321247116242073983256e+00 }, + {4.6250, +2.21272580641655511554559532685274022e+00 }, + {4.6875, +2.22646955206835990390469193746457694e+00 }, + {4.7500, +2.24002263471777221819301091423172581e+00 }, + {4.8125, +2.25339038602153389445857144762743321e+00 }, + {4.8750, +2.26657791269250866199452039018610592e+00 }, + {4.9375, +2.27959010919802897270925407255393153e+00 }, + {5.0000, +2.29243166956117768780078731134801529e+00 }, + {5.0625, +2.30510709834096668441430402487399027e+00 }, + {5.1250, +2.31762072085989362346174598175746039e+00 }, + {5.1875, +2.32997669274071514661824152082627607e+00 }, + {5.2500, +2.34217900880836474718960439585388779e+00 }, + {5.3125, +2.35423151140767607019354831300009086e+00 }, + {5.3750, +2.36613789818286932753788120137389157e+00 }, + {5.4375, +2.37790172936055222645518871553565388e+00 }, + {5.5000, +2.38952643457421860822386165703818122e+00 }, + {5.5625, +2.40101531926484683717268315699636478e+00 }, + {5.6250, +2.41237157068916138816151585667001780e+00 }, + {5.6875, +2.42359826356438621752612199535640197e+00 }, + {5.7500, +2.43469836537585339202679859270163341e+00 }, + {5.8125, +2.44567474137160531324234100032920604e+00 }, + {5.8750, +2.45653015926611756205299063862500772e+00 }, + {5.9375, +2.46726729367344889723552955806057589e+00 }, + {6.0000, +2.47788873028847500481395074507450545e+00 }, + {6.0625, +2.48839696983336532007430913631752335e+00 }, + {6.1250, +2.49879443178510181484789673802222733e+00 }, + {6.1875, +2.50908345789860105234876846349648239e+00 }, + {6.2500, +2.51926631553887363826303725428234388e+00 }, + {6.3125, +2.52934520083462740598919885177286592e+00 }, + {6.3750, +2.53932224166478245066792464622248188e+00 }, + {6.4375, +2.54919950048850872717547586051387259e+00 }, + {6.5000, +2.55897897702861255144554182625683448e+00 }, + {6.5625, +2.56866261081738002442374329274624674e+00 }, + {6.6250, +2.57825228361332690085894009323471199e+00 }, + {6.6875, +2.58774982169670016849316580209717247e+00 }, + {6.7500, +2.59715699805102158059159611581476354e+00 }, + {6.8125, +2.60647553443745310075195298905494613e+00 }, + {6.8750, +2.61570710336829463210497297146055746e+00 }, + {6.9375, +2.62485332998549187571842397668306463e+00 }, + {7.0000, +2.63391579384963341725009269461593696e+00 }, + {7.0625, +2.64289603064454821939888620389440586e+00 }, + {7.1250, +2.65179553380227492960508448932353394e+00 }, + {7.1875, +2.66061575605286038291043830648413625e+00 }, + {7.2500, +2.66935811090315420323249076787858338e+00 }, + {7.3125, +2.67802397404849750222123152071366765e+00 }, + {7.3750, +2.68661468472095454727243455865687717e+00 }, + {7.4375, +2.69513154697750528856415868272675449e+00 }, + {7.5000, +2.70357583093140231733394963705451385e+00 }, + {7.5625, +2.71194877392969682611305770501597479e+00 }, + {7.6250, +2.72025158167975322903284501674667068e+00 }, + {7.6875, +2.72848542932740015820479864569947040e+00 }, + {7.7500, +2.73665146248920556040148045776356816e+00 }, + {7.8125, +2.74475079824121464549309272530654441e+00 }, + {7.8750, +2.75278452606635063332660947345292156e+00 }, + {7.9375, +2.76075370876254883072567909046267813e+00 }, + {8.0000, +2.76865938331357383273200140938374547e+00 }, + {8.0625, +2.77650256172435692961336760207948251e+00 }, + {8.1250, +2.78428423182258551535630273235901386e+00 }, + {8.1875, +2.79200535802817788553087801705861609e+00 }, + {8.2500, +2.79966688209218477865004528925200022e+00 }, + {8.3125, +2.80726972380657289240925980113428074e+00 }, + {8.3750, +2.81481478168626496869015857854363587e+00 }, + {8.4375, +2.82230293362473549711106510083524230e+00 }, + {8.5000, +2.82973503752439027536610108611637391e+00 }, + {8.5625, +2.83711193190289165307916749543060640e+00 }, + {8.6250, +2.84443443647652896774770544175385075e+00 }, + {8.6875, +2.85170335272167517356988163822694873e+00 }, + {8.7500, +2.85891946441531570520913194770155741e+00 }, + {8.8125, +2.86608353815558396737111566993889866e+00 }, + {8.8750, +2.87319632386318927416511462539646535e+00 }, + {8.9375, +2.88025855526457737300290165271813925e+00 }, + {9.0000, +2.88727095035762068498655348054621044e+00 }, + {9.0625, +2.89423421186059490016531823326821096e+00 }, + {9.1250, +2.90114902764516041745652356473355270e+00 }, + {9.1875, +2.90801607115403116308966232802812480e+00 }, + {9.2500, +2.91483600180397941677005500735563642e+00 }, + {9.3125, +2.92160946537479329008903038647778851e+00 }, + {9.3750, +2.92833709438477331505751565470704144e+00 }, + {9.4375, +2.93501950845332609861824133070706912e+00 }, + {9.5000, +2.94165731465118607612817277397561825e+00 }, + {9.5625, +2.94825110783877095494122437627939968e+00 }, + {9.6250, +2.95480147099315238696389016790268450e+00 }, + {9.6875, +2.96130897552410066125326263536732120e+00 }, + {9.7500, +2.96777418157964068500790378422486329e+00 }, + {9.8125, +2.97419763834153614964672155497739057e+00 }, + {9.8750, +2.98057988431109948901325801645778406e+00 }, + {9.9375, +2.98692144758570696460723739938555692e+00 }, + {10.0000, +2.99322284612638089791266771377418276e+00 }, + }; + + + for (double [] testCase : testCases) { + failures += testAcoshCaseWithUlpDiff(testCase[0], + testCase[1], + 3.0); + } + + + + for (double nan : Tests.NaNs) { + failures += testAcoshCaseWithUlpDiff(nan, NaNd, 0); + } + + + + double [][] specialTestCases = { + {0.0, NaNd}, + {-0.0, NaNd}, + {1.0, 0.0}, + {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY}, + {Double.NEGATIVE_INFINITY, NaNd} + }; + + + + for (double [] specialTestCase : specialTestCases) { + failures += testAcoshCaseWithUlpDiff(specialTestCase[0], + specialTestCase[1], + 0.0); + } + + + failures += testAcoshAdditionalTests(); + + return failures; + } + + /** + * Test accuracy of {Math, StrictMath}.acosh using quad precision + * acosh implementation as the reference. There are additional tests. + * The specified accuracy is 2.5 ulps. + * + */ + static int testAcoshAdditionalTests() { + int failures = 0; + /* + * Array elements below are generated using a quad precision acosh + * implementation (libquadmath). Rounded to a double, the quad result + * *should* be correctly rounded, unless we are quite unlucky. + * Assuming the quad value is a correctly rounded double, the + * allowed error is 3.0 ulps instead of 2.5 since the quad + * value rounded to double can have its own 1/2 ulp error. + */ + double[][] testCases = { + // x acosh(x) + {+1.40222409861373051853661308996379375e+01 , +3.33251799248457675610296187717275023e+00 }, + {+4.64063630702987595100239559542387724e+01 , +4.53046765794427717250009108708063951e+00 }, + {+2.26769594350354175560369185404852033e+01 , +3.81401008174403012773998497198756862e+00 }, + {+6.82076069573278687130368780344724655e+01 , +4.91564953670154039555101045371992145e+00 }, + {+9.35345967264471340740783489309251308e+01 , +5.23144999004817476451595194893686997e+00 }, + {+5.24222208302520016331982333213090897e+01 , +4.65238675892723943927493345614044802e+00 }, + {+4.42263893601989721560130419675260782e+00 , +2.16685013650055071552269762531726701e+00 }, + {+5.34403191209646664106003299821168184e+01 , +4.67162513077968730816736013866320559e+00 }, + {+1.76212042009831870714720025716815144e+00 , +1.16720688415256589829633745537084420e+00 }, + {+7.61738148899418732185040425974875689e+00 , +2.71924321506064362327407359954437453e+00 }, + {+6.89904985284954790358824538998305798e+01 , +4.92706344460967378866907640972706781e+00 }, + {+9.31132130019995969405499636195600033e+01 , +5.22693444138174309022758439394131022e+00 }, + {+5.31659489982307036370912101119756699e+01 , +4.66647685890886539018247877652269347e+00 }, + {+6.57379772558717405672723543830215931e+01 , +4.87876612392399046931262815776348806e+00 }, + {+7.04178688554184901704502408392727375e+01 , +4.94754380999195554008986754487841587e+00 }, + {+7.64576059598647788106973166577517986e+01 , +5.02984082858162069509313975886000718e+00 }, + {+5.69898682524488275902285749907605350e+00 , +2.42564775130097776080234839595030019e+00 }, + {+3.34951883898407629658322548493742943e+01 , +4.20432607363489310218001177932001376e+00 }, + {+7.58846381271260241874188068322837353e+01 , +5.02231803118503396528914607189891829e+00 }, + {+3.71685284182660993224089907016605139e+01 , +4.30842856158112686719805147741579474e+00 }, + {+9.82724783457824031529526109807193279e+01 , +5.28086530470046881951663865035216936e+00 }, + {+7.55822276853527057483006501570343971e+01 , +5.01832458735915146090685859231899627e+00 }, + {+8.19590239920287544350685493554919958e+00 , +2.79303880830104526461764198808709567e+00 }, + {+8.85860057527683011358021758496761322e+01 , +5.17708921820009272972577332594088089e+00 }, + {+4.42047291460483080527410493232309818e+01 , +4.48185099473614683233384262644114551e+00 }, + {+4.82954447467224099455052055418491364e+01 , +4.57037722443775069839008053496876858e+00 }, + {+2.82157771675713533454654680099338293e+01 , +4.03271430903366741210592839999395032e+00 }, + {+1.74842128192706276479384541744366288e+01 , +3.55362672330870909254873232512209322e+00 }, + {+8.98679723864892281426364206708967686e+01 , +5.19145784395917044408731940940225234e+00 }, + {+6.99586842581785273154082460678182542e+00 , +2.63331927275597158625520354348567456e+00 }, + {+5.09477665985264778214514080900698900e+01 , +4.62385177612510228171242777653641979e+00 }, + {+3.25842611674598501281252538319677114e+01 , +4.17674101901473628570827854743466486e+00 }, + {+4.99036918354616290116609889082610607e+01 , +4.60314176379122016396592518510391469e+00 }, + {+9.98255656348235120844947232399135828e+00 , +2.99146816849131388203109739268493125e+00 }, + {+8.30115844701927940718633180949836969e+00 , +2.80589439276611715849813780991570715e+00 }, + {+3.90300726488373044276158907450735569e+01 , +4.35731547033614744103231173076054669e+00 }, + {+9.14679267650316347726402455009520054e+01 , +5.20910568139874158502888666687786843e+00 }, + {+4.69801366698952662659394263755530119e+01 , +4.54275878054294975578025810303600533e+00 }, + {+5.95831438716205052941177200409583747e+00 , +2.47081727711668636777886134527797777e+00 }, + {+7.72502501531925105382470064796507359e+01 , +5.04015543904862200893429166398240913e+00 }, + {+1.34111721821950098387787875253707170e+01 , +3.28784240452352224920507313116967307e+00 }, + {+6.91570748043642566926791914738714695e+01 , +4.92947526860125472538045310739830979e+00 }, + {+6.33247983942767831422315794043242931e+01 , +4.84136184327272941501425426966065239e+00 }, + {+7.28157878674183933753738529048860073e+01 , +4.98103282444372675567185179132668151e+00 }, + {+8.89686491926590150569609249942004681e+01 , +5.18139964655774166552638928730792362e+00 }, + {+3.13258612573789463340290240012109280e+01 , +4.13733631620326521460511053592093813e+00 }, + {+5.18140965157089325998640561010688543e+01 , +4.64071629304849263117175976059711265e+00 }, + {+8.47521744710507647369013284333050251e+01 , +5.13284377741645310577993893073249440e+00 }, + {+8.43095533174532931752764852717518806e+01 , +5.12760719138905245783659501854598879e+00 }, + {+4.21240669274286076984026294667273760e+01 , +4.43362549935510675489581351410263443e+00 }, + {+4.73238194816935475728314486332237720e+01 , +4.55004928385543400029944037596031391e+00 }, + {+1.86544426645817758014800347154960036e+01 , +3.61851232034069491499592508470176552e+00 }, + {+5.75938262601410571051019360311329365e+01 , +4.74648718281138202967444216845950983e+00 }, + {+4.27232167589609090896374254953116179e+00 , +2.13131771884641485793724599940809626e+00 }, + {+5.03495317868001706074210233055055141e+01 , +4.61203786952239923442865869830624998e+00 }, + {+7.50809724725515792442820384167134762e+01 , +5.01166999309632169153897035236491293e+00 }, + {+8.91830106756043647919796057976782322e+01 , +5.18380630497515107426424373476548239e+00 }, + {+8.43619216604083419497328577563166618e+01 , +5.12822818585720472109565051928260461e+00 }, + {+2.20623999405381177041363116586580873e+01 , +3.78650797260310183157107999251647380e+00 }, + {+1.39122989185065399908580729970708489e+01 , +3.32462629189603078991830801184905350e+00 }, + {+2.81842266001629120353300095302984118e+01 , +4.03159479043564760795745665884328416e+00 }, + {+4.20150330398823186328627343755215406e+01 , +4.43103301227168439924256715079001048e+00 }, + {+7.12721396815986594219793914817273617e+01 , +4.95960346484961706088932387548050013e+00 }, + {+2.47511696812483386054282163968309760e+01 , +3.90161159523447275422094662483857801e+00 }, + {+3.24364140945400691862232633866369724e+01 , +4.17219116407069688318499622366971673e+00 }, + {+6.55538099356552947938325814902782440e+01 , +4.87596033055444598453664902130389245e+00 }, + {+6.84532751547124860280746361240744591e+01 , +4.91924522217897758728929410442650248e+00 }, + {+3.93848083647737539081390423234552145e+01 , +4.36636613965538581613443666385597861e+00 }, + {+1.56057673113820580823585260077379644e+01 , +3.43975961616459237301460093608428409e+00 }, + {+8.47119903068781923138885758817195892e+01 , +5.13236949468185791854133268753960238e+00 }, + {+9.55854738436600683826327440328896046e+01 , +5.25314067817929358802774910100252994e+00 }, + {+1.56670046394655830823694486753083766e+01 , +3.44368399001615451248068997740627574e+00 }, + {+4.14679026870443507846175634767860174e+01 , +4.41792146385299219920359657474436019e+00 }, + {+5.69249693750823269056127173826098442e+01 , +4.73480409586514749627990327668077645e+00 }, + {+4.93629403713561600852699484676122665e+01 , +4.59224451473128480136302652897840027e+00 }, + {+9.61484189551490686653778539039194584e+01 , +5.25901316478560252169572160735164898e+00 }, + {+2.07759627057374345326934417244046926e+01 , +3.72636417050318935004571518016144611e+00 }, + {+6.32976464844313539970244164578616619e+01 , +4.84093292566853424246928339764776273e+00 }, + {+6.54741204020067897317858296446502209e+01 , +4.87474381391982909784974793043917201e+00 }, + {+8.05042266117176978923453134484589100e+01 , +5.08141829115959617683933639313475601e+00 }, + {+4.81667484910552587962229154072701931e+01 , +4.56770832383321482034955903243661906e+00 }, + {+2.11217831158012465664342016680166125e+01 , +3.74289121691996804899454065396184575e+00 }, + {+9.02656763961261532358548720367252827e+01 , +5.19587377817524068279272963615894387e+00 }, + {+1.50600821596306779781571094645187259e+01 , +3.40409076820438745807924396441229869e+00 }, + {+4.16209905361957765990155166946351528e+01 , +4.42160745328229554045710868854157175e+00 }, + {+8.86791887429291563194055925123393536e+01 , +5.17814062516654447520446624771754712e+00 }, + {+1.70576566142218695176779874600470066e+01 , +3.52888602841986989717710320391598297e+00 }, + {+3.71685638271143758970538328867405653e+01 , +4.30842951458236820308439636796433560e+00 }, + {+1.43758274343816250251393284997902811e+01 , +3.35748343469042965382754422758946510e+00 }, + {+4.60754211385189549332608294207602739e+01 , +4.52330904257767828148397295029679237e+00 }, + {+4.57777167466274974572115752380341291e+01 , +4.51682530040123678433942314310447564e+00 }, + {+9.32357656650976593937230063602328300e+01 , +5.22824982009254837221678766114741857e+00 }, + {+2.23095900244694895775410259375348687e+01 , +3.79766114099573434402313460678612040e+00 }, + {+9.09832666680431856320865335874259472e+01 , +5.20379258533493176911574496349341434e+00 }, + {+8.62251237613208019183730357326567173e+01 , +5.15007514723643448859452771190406728e+00 }, + {+5.10896316393437928127241320908069611e+01 , +4.62663296015956482467254446322296917e+00 }, + {+8.19385868289117524909670464694499969e+01 , +5.09907996803279765921917143342322948e+00 }, + {+4.67622529628467802353952720295637846e+01 , +4.53810915071314717336273606975590283e+00 }, + {+6.36411313235143367705859418492764235e+01 , +4.84634542963631730817381276671897779e+00 }, + {+8.26450413110590460519233602099120617e+01 , +5.10766540264697663339669119714720544e+00 }, + }; + + for (double[] testCase : testCases) { + failures += testAcoshCaseWithUlpDiff(testCase[0], + testCase[1], + 3.0); + } + + return failures; + } + + public static int testAcoshCaseWithTolerance(double input, + double expected, + double tolerance) { + int failures = 0; + failures += Tests.testTolerance("Math.acosh", input, Math::acosh, expected, tolerance); + failures += Tests.testTolerance("StrictMath.acosh", input, StrictMath::acosh, expected, tolerance); + return failures; + } + + public static int testAcoshCaseWithUlpDiff(double input, + double expected, + double ulps) { + int failures = 0; + failures += Tests.testUlpDiffWithAbsBound("Math.acosh", input, Math::acosh, expected, ulps, Double.POSITIVE_INFINITY); + failures += Tests.testUlpDiffWithAbsBound("StrictMath.acosh", input, StrictMath::acosh, expected, ulps, Double.POSITIVE_INFINITY); + return failures; + } + + /** + * Test accuracy of {Math, StrictMath}.atanh. The specified + * accuracy is 2.5 ulps. + * + * The defintion of atanh(x) is + * + * atanh(tanh(x)) = x + * + * Can be also written as + * + * 0.5 * log1p(2 * x / (1-x0)) + * + * Taylor expansion: + * + * x + x^3 / 3 + x^5 / 5 + ... + * + * Therefore, + * + * 1. For small values of x, tanh(x) ~= x. + * + * Additionally, atanh is an odd function; atanh(-x) = -atanh(x). + * + */ + static int testAtanh() { + int failures = 0; + /* + * Array elements below generated using a quad atanh + * implementation. Rounded to a double, the quad result + * *should* be correctly rounded, unless we are quite unlucky. + * Assuming the quad value is a correctly rounded double, the + * allowed error is 3.0 ulps instead of 2.5 since the quad + * value rounded to double can have its own 1/2 ulp error. + */ + double [][] testCases = { + // x atanh(x) + {+0.00000000000000000000000000000000000e+00 , +0.00000000000000000000000000000000000e+00 }, + {+2.00000000000000004163336342344337027e-02 , +2.00026673068495811335374182828113576e-02 }, + {+4.00000000000000008326672684688674053e-02 , +4.00213538367682137458906520059156020e-02 }, + {+5.99999999999999977795539507496869192e-02 , +6.00721559210316214332906986486015264e-02 }, + {+8.00000000000000016653345369377348106e-02 , +8.01713250375896933655527689248809233e-02 }, + {+1.00000000000000005551115123125782702e-01 , +1.00335347731075586242913545116385118e-01 }, + {+1.20000000000000009436895709313830594e-01 , +1.20581028408444044805093075807633198e-01 }, + {+1.40000000000000013322676295501878485e-01 , +1.40925576070493877554736186975308236e-01 }, + {+1.60000000000000003330669073875469621e-01 , +1.61386696131525518759511362898215609e-01 }, + {+1.79999999999999993338661852249060757e-01 , +1.81982688600705816490251036770517457e-01 }, + {+1.99999999999999983346654630622651894e-01 , +2.02732554054082173641771797964103718e-01 }, + {+2.19999999999999973354647408996243030e-01 , +2.23656109021832382650747515743625830e-01 }, + {+2.39999999999999963362640187369834166e-01 , +2.44774112659352854083413297101694196e-01 }, + {+2.59999999999999953370632965743425302e-01 , +2.66108406873654071753827618842061943e-01 }, + {+2.79999999999999971134201359745929949e-01 , +2.87682072451780896117822911968144088e-01 }, + {+2.99999999999999988897769753748434596e-01 , +3.09519604203111703273814331202206426e-01 }, + {+3.20000000000000006661338147750939243e-01 , +3.31647108705132085025104001081840030e-01 }, + {+3.40000000000000024424906541753443889e-01 , +3.54092528962242939723929765493171945e-01 }, + {+3.60000000000000042188474935755948536e-01 , +3.76885901188190124469133896689497444e-01 }, + {+3.80000000000000059952043329758453183e-01 , +4.00059650056056638206593741845596981e-01 }, + {+4.00000000000000077715611723760957830e-01 , +4.23648930193601899373639138690042112e-01 }, + {+4.20000000000000095479180117763462476e-01 , +4.47692023527420813002158901561072580e-01 }, + {+4.40000000000000113242748511765967123e-01 , +4.72230804420425833981180600242988051e-01 }, + {+4.60000000000000131006316905768471770e-01 , +4.97311287572031193620508878977899997e-01 }, + {+4.80000000000000148769885299770976417e-01 , +5.22984277591344047465367134186014130e-01 }, + {+5.00000000000000111022302462515654042e-01 , +5.49306144334054993727359235148812474e-01 }, + {+5.20000000000000128785870856518158689e-01 , +5.76339754969192906113997153691857594e-01 }, + {+5.40000000000000146549439250520663336e-01 , +6.04155602962267286054127265014583953e-01 }, + {+5.60000000000000164313007644523167983e-01 , +6.32833186665638181077146946128475799e-01 }, + {+5.80000000000000182076576038525672629e-01 , +6.62462707371799523213172030295196960e-01 }, + {+6.00000000000000199840144432528177276e-01 , +6.93147180559945621667457797283512021e-01 }, + {+6.20000000000000217603712826530681923e-01 , +7.25005087752999506268291290927001216e-01 }, + {+6.40000000000000235367281220533186570e-01 , +7.58173744684044609195455590065769225e-01 }, + {+6.60000000000000253130849614535691217e-01 , +7.92813631870191370108450047457113058e-01 }, + {+6.80000000000000270894418008538195863e-01 , +8.29114038301766692728933700083100051e-01 }, + {+7.00000000000000288657986402540700510e-01 , +8.67300527694053760423196460163172710e-01 }, + {+7.20000000000000306421554796543205157e-01 , +9.07644983319125195441126107009775370e-01 }, + {+7.40000000000000324185123190545709804e-01 , +9.50479380596524207852088721432242171e-01 }, + {+7.60000000000000341948691584548214450e-01 , +9.96215082345103890579587353760865510e-01 }, + {+7.80000000000000359712259978550719097e-01 , +1.04537054846688556569856922586455819e+00 }, + {+8.00000000000000377475828372553223744e-01 , +1.09861228866811073993921293846013796e+00 }, + {+8.20000000000000395239396766555728391e-01 , +1.15681746459031653565363995495937725e+00 }, + {+8.40000000000000413002965160558233038e-01 , +1.22117351768460359355809310163905228e+00 }, + {+8.60000000000000430766533554560737684e-01 , +1.29334467204897297035888921761818841e+00 }, + {+8.80000000000000448530101948563242331e-01 , +1.37576765652097643587819823310934128e+00 }, + {+9.00000000000000466293670342565746978e-01 , +1.47221948958322268418172604524275263e+00 }, + {+9.20000000000000484057238736568251625e-01 , +1.58902691517397596123778549185721945e+00 }, + {+9.40000000000000501820807130570756271e-01 , +1.73804934491764087653605718356588900e+00 }, + {+9.60000000000000519584375524573260918e-01 , +1.94591014905531993245708137324632564e+00 }, + {+9.80000000000000537347943918575765565e-01 , +2.29755992506730853281874022244325249e+00 }, + }; + + for(double [] testCase : testCases) { + failures += testAtanhCaseWithUlpDiff(testCase[0], + testCase[1], + 3.0); + } + + for(double nan : Tests.NaNs) { + failures += testAtanhCaseWithUlpDiff(nan, NaNd, 0); + } + + double [][] specialTestCases = { + {0.0, 0.0}, + {-0.0, -0.0}, + {1.0, Double.POSITIVE_INFINITY}, + {-1.0, Double.NEGATIVE_INFINITY}, + {2.0, NaNd}, + {-2.0, NaNd}, + }; + + for(double [] specialTestCase : specialTestCases) { + failures += testAtanhCaseWithUlpDiff(specialTestCase[0], + specialTestCase[1], + 0.0); + } + + // For powers of 2 less than 2^(-27), the second and + // subsequent terms of the Taylor series expansion will get + // rounded away since |n-n^3| > 53, the binary precision of a + // double significand. + + for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) { + double d = Math.scalb(2.0, i); + + // Result and expected are the same. + failures += testAtanhCaseWithUlpDiff(d, d, 2.5); + } + + failures += testAtanhAdditionalTests(); + + return failures; + } + + /** + * Test accuracy of {Math, StrictMath}.atanh using quad precision + * tanh implementation as the reference. There are additional tests. + * The specified accuracy is 2.5 ulps. + * + */ + static int testAtanhAdditionalTests() { + int failures = 0; + /* + * Array elements below are generated using a quad precision tanh + * implementation (libquadmath). Rounded to a double, the quad result + * *should* be correctly rounded, unless we are quite unlucky. + * Assuming the quad value is a correctly rounded double, the + * allowed error is 3.0 ulps instead of 2.5 since the quad + * value rounded to double can have its own 1/2 ulp error. + */ + double[][] testCases = { + // x atanh(x) + {+9.39017107929201566562937841808889061e-01 , +1.72967155564501022599234830162276798e+00 }, + {+4.56590977869321346105380143853835762e-01 , +4.92995868916526654745557405930485720e-01 }, + {-6.57855028101722583144805867050308734e-01 , -7.89022676186288902931611202476188124e-01 }, + {+4.62405425240985490376033339998684824e-01 , +5.00366606474614321339885208418466006e-01 }, + {-9.83365261789753697385663144814316183e-01 , -2.39052856803141716223262787771779768e+00 }, + {-6.27582201138608741786129030515439808e-01 , -7.37417270574716377975381198846020522e-01 }, + {-9.83196938676588638728048863413278013e-01 , -2.38545217282555498582477166161511345e+00 }, + {+7.36681396907350904967870519612915814e-01 , +9.43183305171108845024940622694003154e-01 }, + {-7.68733978209885648880117514636367559e-01 , -1.01722532284268312448347897782273734e+00 }, + {-8.99650279001481090190850409271661192e-01 , -1.47038189478731874369381319202006168e+00 }, + {+6.23383381659472490810003364458680153e-02 , +6.24192773197774301522605242534216118e-02 }, + {-8.14139384718910008587045012973248959e-01 , -1.13918472673420532816505691112579313e+00 }, + {-4.89518635342238050967011986358556896e-01 , -5.35427075187260852558782518094419668e-01 }, + {-6.08295892536873550326959048106800765e-01 , -7.06211859359034873213744847874549993e-01 }, + {+9.36079053287340978606323460553539917e-01 , +1.70538649403259128938060088254525967e+00 }, + {+8.31593360663532843446432707423809916e-01 , +1.19328001443669418326658153597705593e+00 }, + {+6.56422583223821076714443734090309590e-01 , +7.86501511439435312578862353672697253e-01 }, + {-3.45789522181036979020518629113212228e-01 , -3.60653496973375779632391162421477716e-01 }, + {+5.32079052777165939502879155043046921e-01 , +5.93040792269778100045583612458499490e-01 }, + {-3.36182931512335247958844774984754622e-01 , -3.49782828626977949006925091676664461e-01 }, + {+6.13630231412017335124176042882027104e-01 , +7.14723430606319696079463920489037224e-01 }, + {+7.39217182016670415478643008100334555e-01 , +9.48751224833067617682882507817093541e-01 }, + {-7.64409441646018983362864673836156726e-03 , -7.64424330871250337925427639013540391e-03 }, + {-9.74816033382744917545892349153291434e-01 , -2.18101148933100542106171185218910695e+00 }, + {+5.52687515297161868765840608830330893e-01 , +6.22242584006598996817110126253907160e-01 }, + {+9.93416759200363430615254856093088165e-01 , +2.85653913150680081054657418761203993e+00 }, + {+9.07659865436335255850508474395610392e-01 , +1.51407684709244159021847264731507603e+00 }, + {+6.60272764758356833780794659105595201e-01 , +7.93297068812459385386864151954890303e-01 }, + {+9.63130814953695568725322573300218210e-01 , +1.98745986190671136058731587311090272e+00 }, + {-5.70877067883640121337407435930799693e-01 , -6.48822975697686437517619163352737241e-01 }, + {-8.11543971448019485492864077968988568e-01 , -1.13153503707350652581786706338031953e+00 }, + {+6.25363929368137561048968109389534220e-01 , +7.33765974893577300297563917687072047e-01 }, + {-2.98846490310910706256208868580870330e-01 , -3.08252492314447063039336121789383998e-01 }, + {-5.97049745291272859759601487894542515e-01 , -6.88550090030688204308547683807415861e-01 }, + {+8.32383827085564576009346637874841690e-01 , +1.19584817769769645815260824209818595e+00 }, + {-6.63715390745103883674005373904947191e-01 , -7.99425357382537999237287552090479860e-01 }, + {-3.94238412786191538828006741823628545e-01 , -4.16808558150307726736043589182851417e-01 }, + {-9.76759747274416945117536670295521617e-01 , -2.22166424268955747060822814557733573e+00 }, + {+8.57442746954987455865193624049425125e-01 , +1.28360612935435243492898897724236702e+00 }, + {-4.24565955117479187919116156990639865e-01 , -4.53248918353154620159372526887584647e-01 }, + {+3.42862260746481295470289296645205468e-01 , +3.57332492545316699435359810051341636e-01 }, + {+9.34459049867542246303742103918921202e-01 , +1.69245393271799745831802454769856267e+00 }, + {+7.64520478549035598092586951679550111e-01 , +1.00700514849153029184678063244721996e+00 }, + {-9.63864704576277597780631367641035467e-01 , -1.99769974929677935746994673118167405e+00 }, + {-1.63366842704400605512660149543080479e-01 , -1.64843919557971079920329622870569601e-01 }, + {+9.94878693411232140064726081618573517e-01 , +2.98246446127683966842287869896800818e+00 }, + {+7.97196021651951247655176757689332590e-01 , +1.09087153746565597453258159715989760e+00 }, + {+8.42371664350162419054868223611265421e-01 , +1.22928450632196951329839160548759750e+00 }, + {+6.96520087724423975217291626904625446e-01 , +8.60509501716176099565750762116593117e-01 }, + {+2.01836732473232416396058397367596626e-01 , +2.04646551779576522368238234135183581e-01 }, + {+5.05939365449320055390103334502782673e-01 , +5.57256946951148119219566387597645954e-01 }, + {-6.01430574320412913991162895399611443e-01 , -6.95385458565007214254554832195678104e-01 }, + {-4.47649318961238940062230540206655860e-01 , -4.81756612137591759595253632500957881e-01 }, + {+3.37215361458020113083478008775273338e-01 , +3.50947266793232870614512911957588554e-01 }, + {+5.14125575037364890285118690371746197e-01 , +5.68321583728012649428480801619053327e-01 }, + {-2.15214858343344861424384362180717289e-01 , -2.18633101430445893274568498462426012e-01 }, + {-9.20630621904034773805847180483397096e-01 , -1.59314811621779716899638118653946385e+00 }, + {+9.19047868224296293782060729427030310e-01 , +1.58286321290197920098639225270320808e+00 }, + {-2.90913484009795997309311132994480431e-01 , -2.99563914714840125917110413508169726e-01 }, + {+3.17993101000002553746526245959103107e-03 , +3.17994172851141737533171613593260162e-03 }, + {-7.16021961571153608971940229821484536e-01 , -8.99433586194582637259073931486986768e-01 }, + {+9.92926371376932737078391255636233836e-01 , +2.82049289268529672262432232518141968e+00 }, + {-7.42199723778889541847547661745920777e-01 , -9.55359320438959545982214260560204172e-01 }, + {+4.01228574786033020949105321051320061e-01 , +4.25112376436892578257996500834612471e-01 }, + {-4.41626489426403034954660142830107361e-01 , -4.74249574732580717257665801841627296e-01 }, + {-7.21334187852223251979921769816428423e-01 , -9.10420850885118135075313207007968241e-01 }, + {+2.82138790772897052328005429444601759e-01 , +2.90004322151609047453793285881602424e-01 }, + {+9.42986643599090679224161704041762277e-01 , +1.76434800601646585550841462860153977e+00 }, + {-5.29497382099672897481923428131267428e-01 , -5.89446464446382266025999977702386855e-01 }, + {+8.90579204675862490248050562513526529e-01 , +1.42471878072594370872155352848645131e+00 }, + {+7.91047774827229877026013582508312538e-01 , +1.07422521925289214702426279427778303e+00 }, + {+4.75836513423619322793456376530230045e-01 , +5.17588301409701923326927500834908347e-01 }, + {+9.32576831661000027473562568047782406e-01 , +1.67781041728427657120484424620161805e+00 }, + {+4.49528137196881449888508086587535217e-01 , +4.84108758524071045231641283604748208e-01 }, + {-6.26946229789648867836149292998015881e-01 , -7.36368746336877301544734566556181860e-01 }, + {+9.58777722962137812778848910966189578e-01 , +1.93054856596755898497650787204101231e+00 }, + {-9.52075725696122754371231167169753462e-01 , -1.85351320681716370080636444991087747e+00 }, + {+9.66628065084665144546249848644947633e-01 , +2.03818021917486263862909093415522483e+00 }, + {-9.90577960901121823411585864960215986e-01 , -2.67656438907628996596144534201915287e+00 }, + {-4.29129153811968588883019037893973291e-01 , -4.58828779570547333956754968138122237e-01 }, + {+9.21075240738198020018501210870454088e-01 , +1.59607267263080478465215862819487820e+00 }, + {-3.36155477527195101217216688382904977e-01 , -3.49751876782073295503516199927519371e-01 }, + {-4.48919523178084922676589485490694642e-01 , -4.83346273396370947315596684554195125e-01 }, + {-7.74714213440744980943009068141691387e-01 , -1.03201246185914269057125935805127686e+00 }, + {-9.33695607057150489538344118045642972e-01 , -1.68646605985566878841417421790327581e+00 }, + {-9.70495709947644780157816057908348739e-01 , -2.10075237060881671900628221642575807e+00 }, + {-9.36541591900329706277261720970273018e-01 , -1.70913713792726775520494333833202263e+00 }, + {+7.37812568478896091406227242259774357e-02 , +7.39155762025176670781318988781666040e-02 }, + {-5.04698425671640915624038825626485050e-01 , -5.55590478683141718256493322563558866e-01 }, + {+8.86920594265426132096763467416167259e-01 , +1.40730559326330763357753153399607213e+00 }, + {-5.34965721339583311078058613929897547e-01 , -5.97076103988724933820435448973192479e-01 }, + {-5.04547440425485049786402669269591570e-01 , -5.55387910636784813509136387661093775e-01 }, + {+6.29048733546408000982808061962714419e-01 , +7.39840413838973059800583747029269377e-01 }, + {-9.78682200705922600292296920088119805e-01 , -2.26532198777189725437096465346095003e+00 }, + {+2.38919916302204882185833412222564220e-03 , +2.38920370910435739436106539813089152e-03 }, + {+9.39119411473845255855508185049984604e-01 , +1.73053742845170764254605902984133442e+00 }, + {-6.12092729070447649775132958893664181e-01 , -7.12261063519474464072359286081706738e-01 }, + {-4.28286500855559193468025114270858467e-01 , -4.57796381674494452786278030205231882e-01 }, + {-3.27343597141078301859806742868386209e-01 , -3.39850137417994572135528032299471827e-01 }, + {+8.67784128381645536443045330088352785e-01 , +1.32403603565363914121499259355873480e+00 }, + {+7.52660015475228982850808279181364924e-01 , +9.79063037984556159433073554464697266e-01 }, + {+7.94013223397652012636172003112733364e-01 , +1.08219921900739052536746217766952318e+00 }, + {+7.09905313419819106179886603058548644e-01 , +8.86992950278189161084285873777251874e-01 }, + {-1.98448575704946783559989853529259562e-01 , -2.01117007840272246446085014680650093e-01 }, + {-5.42433878231522781376838793221395463e-01 , -6.07597742754044712584754611484481699e-01 }, + {-7.54416871023775081894768845813814551e-01 , -9.83128156322049799142775913826928208e-01 }, + {+3.79392548957375952412007791281212121e-01 , +3.99349870596906125894068556877626311e-01 }, + {-7.19279634651493138264299886941444129e-01 , -9.06150816136239309657351447814954486e-01 }, + {-7.23976590297829680764607473975047469e-01 , -9.15951596268038628402616624621418121e-01 }, + {+9.31431733675747830503155455517116934e-01 , +1.66909350005993386837360519102696526e+00 }, + {+5.37270796945802042721140878711594269e-01 , +6.00310952521635654514167563653463826e-01 }, + {+5.05516649275373541883027428411878645e-01 , +5.56688962620397076749424137775916558e-01 }, + {+6.47849417517198489235852321144193411e-01 , +7.71583729081504579676124881689567952e-01 }, + {-5.41124640015404612114480187301523983e-01 , -6.05744544146300297202878069447139070e-01 }, + {+8.08308086737189235293499223189428449e-01 , +1.12212873178291911884370700806026369e+00 }, + {-3.98280706273062445887944704736582935e-01 , -4.21603823445725768059979840445297322e-01 }, + {+8.21296094676341903451088910514954478e-01 , +1.16078669527372101102128788451037300e+00 }, + {+8.31294185704192667429879293194971979e-01 , +1.19231087346512905437819601187290515e+00 }, + {+7.75279686135698531401772015669848770e-01 , +1.03342833983253459558199442655538342e+00 }, + {+8.63016425798844855066249692754354328e-01 , +1.30504558255929258800082186193362940e+00 }, + {-4.01121200686206158536606380948796868e-01 , -4.24984406726507784951210586374028211e-01 }, + {-7.26296876814658931564849808637518436e-01 , -9.20844916340064967501644052845522852e-01 }, + {-6.51251452570346556214531119621824473e-01 , -7.77468783732375082858572957021836038e-01 }, + {-3.38884333978433982537126212264411151e-01 , -3.52831574304372263524860719607206882e-01 }, + {+1.72392299987310537723317338532069698e-01 , +1.74131195612490806064041759672764899e-01 }, + {-5.51462898378643817665079041034914553e-01 , -6.20481084171861782978180187043219425e-01 }, + {-9.64904165725041895740332620334811509e-01 , -2.01255815534358709601688745544440155e+00 }, + {+4.86038064330916674826710277557140216e-01 , +5.30859816325958819695652448239234798e-01 }, + {-1.71510111227157313606994648580439389e-01 , -1.73222128192418256096782313598032358e-01 }, + {-6.40878189659797481425584919634275138e-01 , -7.59662611746376207791374637040653373e-01 }, + {-9.21153045478257270772814990777987987e-01 , -1.59658607015886876829589111732687615e+00 }, + {+9.25949497320595948934851548983715475e-01 , +1.62921352070439068555146795332724838e+00 }, + {+6.67107753751613463677472282142844051e-02 , +6.68100020655284551850585715148980622e-02 }, + {-7.11704678755497255338013928849250078e-01 , -8.90629832677982628857274943637335499e-01 }, + {+2.35257760530820814182106914813630283e-01 , +2.39748052543229836539708777609029562e-01 }, + {-5.99809116170998191108765240642242134e-01 , -6.92848977932719794607448570102282265e-01 }, + {+2.36856137326988402946881251409649849e-02 , +2.36900444994942435090279187572837691e-02 }, + {+4.79753735068501274696473046788014472e-01 , +5.22664335906700767137176554743504717e-01 }, + {-6.67813223642592657114391840877942741e-02 , -6.68808647504004031806529934863158282e-02 }, + {+4.94668485437996574560770568496081978e-01 , +5.42222516993971658066335656775147071e-01 }, + {+9.22379519394591618208778527332469821e-01 , +1.60474385650308389567794994129179836e+00 }, + {+8.66971245297548764874306925776181743e-01 , +1.32075371812223257408713093011711133e+00 }, + {-4.12983669850965462444492004578933120e-01 , -4.39203093212737172928023065922190938e-01 }, + {-5.47462091173417153555647018947638571e-01 , -6.14749985698478964136871989998405650e-01 }, + {+1.94666780724803700763914093840867281e-02 , +1.94691376077079831895420594672983760e-02 }, + {+7.50017550413333511372115935955662280e-01 , +9.72995190965114870405588062706564568e-01 }, + {+4.63499306097077345967250039393547922e-01 , +5.01758888267043269595832923648429311e-01 }, + {-8.37886773978241183868931329925544560e-01 , -1.21403834050977292529923613488719174e+00 }, + {-8.44836969187467534680990866036154330e-01 , -1.23783490656982630833439816713451784e+00 }, + {-6.25239150214307315422956889960914850e-02 , -6.26055803188625957299760516982282628e-02 }, + {+9.22830248275150921699605532921850681e-01 , +1.60777295202485947753242989620181993e+00 }, + {-4.00102773592881266750964641687460244e-01 , -4.23771285697601852943736383483221011e-01 }, + {-2.14797176230649089490043479599989951e-01 , -2.18195175029126913051736730604906575e-01 }, + {+8.02345358196084879054410521348472685e-01 , +1.10516139904369984294917445650114715e+00 }, + {-4.71866662797370439719202295236755162e-01 , -5.12468964220618253719339326228366982e-01 }, + {-5.92911187960187158196845302882138640e-01 , -6.82143591940237868513886526048905163e-01 }, + {-8.76501962797874289989863427763339132e-01 , -1.36046970086086594286889855837180352e+00 }, + {-7.98090332703508265055347692396026105e-01 , -1.09333002432404366596746493295830794e+00 }, + {-9.95891457501823618159164652752224356e-01 , -3.09288886654198972890077598351970075e+00 }, + {+8.90238675794242206862350030860397965e-01 , +1.42307507755399321220435398978827125e+00 }, + {+2.65017376806080395823528306209482253e-01 , +2.71497140326271882216423312414093371e-01 }, + {-8.86140475954999118357591214589774609e-01 , -1.40366125031104099709908824399414822e+00 }, + {-2.77209688130732434530045793508179486e-01 , -2.84656945620440202957754725962273832e-01 }, + {-5.61942305274404585446745841181837022e-01 , -6.35667384226952551579962809234573845e-01 }, + {+5.85899688875965107826004896196536720e-01 , +6.71399455223037749672225055315941521e-01 }, + {+2.89700970360319720597885861934628338e-01 , +2.98239807343473574150289333944139019e-01 }, + {+6.75650398573335864149669305334100500e-01 , +8.21067357862862215855289466859201333e-01 }, + {+8.44595640831392491243434506031917408e-01 , +1.23699243938765398083225288313951255e+00 }, + {+7.51976945151026199276600436860462651e-01 , +9.77489203652249672733902415356008597e-01 }, + {+5.84881385823573185511747851705877110e-01 , +6.69850275691608515819691751205471169e-01 }, + {+1.23322570031297651382828917121514678e-01 , +1.23953519549355101274007946363965461e-01 }, + {-2.47363663564394764549092542438302189e-01 , -2.52602687864803306420298300961589174e-01 }, + {-8.72948142869468535209875881264451891e-01 , -1.34533684420626699711543794108336721e+00 }, + {+8.66853617575293000641067919787019491e-01 , +1.32028029629708106765994282266545478e+00 }, + {+9.65229404828656933901243064610753208e-02 , +9.68243850830075059690451893341587506e-02 }, + {-5.83777226707343555034412929671816528e-01 , -6.68173646565246900863367519530400319e-01 }, + {+9.94603681374665704595372517360374331e-01 , +2.95624183430168683072844226874046298e+00 }, + {+7.54573357889273710341626610897947103e-01 , +9.83491456493016558037612443042858735e-01 }, + {-8.72065566686865079049084670259617269e-01 , -1.34163989421242748094845640631675400e+00 }, + {-1.57050652646726351946426802896894515e-01 , -1.58361317756145752747805962366582739e-01 }, + {+9.07524513496185902816648649604758248e-01 , +1.51330900778040915728163457702896072e+00 }, + {+8.88013640284071148478517443436430767e-01 , +1.41245174788920614220523066982061669e+00 }, + {+5.25920210223992712350593592418590561e-01 , +5.84488641604906625861481645606402185e-01 }, + {-8.55361269493308373768059027497656643e-01 , -1.27579779541753266418749325433063584e+00 }, + {+7.52458416629113502338555008464027196e-01 , +9.78598154541206783526807546834975210e-01 }, + {+2.11594554867804984787937883083941415e-01 , +2.14840051580673426585151516223475322e-01 }, + {-8.77614995063785929829691667691804469e-01 , -1.36529288845779405074788706705067271e+00 }, + {-8.13140811836136734314095519948750734e-01 , -1.13623027343457311746522665305747518e+00 }, + {-9.09625945665704094267312029842287302e-03 , -9.09651034981903612229998860206266111e-03 }, + {+7.11723260837115345722736492461990565e-01 , +8.90667489144918362129731310184000150e-01 }, + {-8.83729688568336113618784111167769879e-01 , -1.39254560811946769303745792066561506e+00 }, + {+2.81119771587539202251093684026272967e-01 , +2.88897516488748428420498810336047168e-01 }, + {+8.67969571335847511761585337808355689e-01 , +1.32478745650884654793737485679177607e+00 }, + {+3.71711284421433640901000217127148062e-01 , +3.90407276521447439801268385319531263e-01 }, + {-5.53264526894389874200896883849054575e-01 , -6.23073752400105167233817313285610373e-01 }, + {-7.50972436681106358946635737083852291e-01 , -9.75181502145488477599896301261990367e-01 }, + {+6.22632428081477007353328190220054239e-01 , +7.29292680370939598849165484001382202e-01 }, + {-5.93039523143406244187758602492976934e-01 , -6.82341523923040079633725976448706286e-01 }, + {-6.21804927349977942796499519317876548e-01 , -7.27942416494347815893737620840227454e-01 }, + {-5.91667199221579398482617762056179345e-01 , -6.80227384371192279205589233595913495e-01 }, + }; + + for (double[] testCase : testCases) { + failures += testAtanhCaseWithUlpDiff(testCase[0], + testCase[1], + 3.0); + } + + return failures; + } + + public static int testAtanhCaseWithTolerance(double input, + double expected, + double tolerance) { + int failures = 0; + failures += Tests.testTolerance("Math.atanh", input, Math::atanh, expected, tolerance); + failures += Tests.testTolerance("Math.atanh", -input, Math::atanh, -expected, tolerance); + + failures += Tests.testTolerance("StrictMath.atanh", input, StrictMath::atanh, expected, tolerance); + failures += Tests.testTolerance("StrictMath.atanh", -input, StrictMath::atanh, -expected, tolerance); + return failures; + } + + public static int testAtanhCaseWithUlpDiff(double input, + double expected, + double ulps) { + int failures = 0; + + failures += Tests.testUlpDiffWithAbsBound("Math.atanh", input, Math::atanh, expected, ulps, Double.POSITIVE_INFINITY); + failures += Tests.testUlpDiffWithAbsBound("Math.atanh", -input, Math::atanh, -expected, ulps, Double.POSITIVE_INFINITY); + + failures += Tests.testUlpDiffWithAbsBound("StrictMath.atanh", input, StrictMath::atanh, expected, ulps, Double.POSITIVE_INFINITY); + failures += Tests.testUlpDiffWithAbsBound("StrictMath.atanh", -input, StrictMath::atanh, -expected, ulps, Double.POSITIVE_INFINITY); + return failures; + } } diff --git a/test/jdk/java/lang/Math/HypotTests.java b/test/jdk/java/lang/Math/HypotTests.java index e09799e34a4..eee40ea6469 100644 --- a/test/jdk/java/lang/Math/HypotTests.java +++ b/test/jdk/java/lang/Math/HypotTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,6 +25,7 @@ * @test * @library /test/lib * @build jdk.test.lib.RandomFactory + * @build Tests * @run main HypotTests * @bug 4851638 4939441 8078672 8240632 * @summary Tests for {Math, StrictMath}.hypot (use -Dseed=X to set PRNG seed) diff --git a/test/jdk/java/lang/Math/IeeeRecommendedTests.java b/test/jdk/java/lang/Math/IeeeRecommendedTests.java index 8570508ff44..3dfb70ab9af 100644 --- a/test/jdk/java/lang/Math/IeeeRecommendedTests.java +++ b/test/jdk/java/lang/Math/IeeeRecommendedTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,6 +25,7 @@ * @test * @library /test/lib * @build jdk.test.lib.RandomFactory + * @build Tests * @run main IeeeRecommendedTests * @bug 4860891 4826732 4780454 4939441 4826652 8078672 * @summary Tests for IEEE 754[R] recommended functions and similar methods (use -Dseed=X to set PRNG seed) diff --git a/test/jdk/java/lang/Math/IeeeRemainderTests.java b/test/jdk/java/lang/Math/IeeeRemainderTests.java index 596310d8e42..8716be870c9 100644 --- a/test/jdk/java/lang/Math/IeeeRemainderTests.java +++ b/test/jdk/java/lang/Math/IeeeRemainderTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ /* * @test * @bug 8304028 + * @build Tests + * @run main IeeeRemainderTests * @summary Tests for {Math, StrictMath}.IEEEremainder */ diff --git a/test/jdk/java/lang/ProcessBuilder/Basic.java b/test/jdk/java/lang/ProcessBuilder/Basic.java index 7034174f85c..70d6101c1a5 100644 --- a/test/jdk/java/lang/ProcessBuilder/Basic.java +++ b/test/jdk/java/lang/ProcessBuilder/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,33 +22,42 @@ */ /* - * @test + * @test id=POSIX_SPAWN * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 * 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464 * 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517 - * 8352533 8368192 + * 8352533 8368192 8377907 * @key intermittent * @summary Basic tests for Process and Environment Variable code * @modules java.base/java.lang:open * java.base/java.io:open - * @requires !vm.musl * @requires vm.flagless * @library /test/lib - * @run main/othervm/native/timeout=360 Basic - * @run main/othervm/native/timeout=360 -Djdk.lang.Process.launchMechanism=fork Basic + * @run main/othervm/native/timeout=360 -Djdk.lang.Process.launchMechanism=posix_spawn Basic * @author Martin Buchholz */ /* - * @test + * @test id=FORK + * @key intermittent + * @summary Basic tests for Process and Environment Variable code + * @modules java.base/java.lang:open + * java.base/java.io:open + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/native/timeout=360 -Djdk.lang.Process.launchMechanism=fork Basic + */ + +/* + * @test id=VFORK * @modules java.base/java.lang:open * java.base/java.io:open * java.base/jdk.internal.misc - * @requires (os.family == "linux" & !vm.musl) + * @requires (os.family == "linux") * @library /test/lib - * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=posix_spawn Basic + * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=vfork Basic */ import java.lang.ProcessBuilder.Redirect; @@ -1230,6 +1239,20 @@ public class Basic { equal(r.out(), "standard output"); equal(r.err(), "standard error"); } + + //---------------------------------------------------------------- + // Default: should go to pipes (use a fresh ProcessBuilder) + //---------------------------------------------------------------- + { + ProcessBuilder pb2 = new ProcessBuilder(childArgs); + Process p = pb2.start(); + new PrintStream(p.getOutputStream()).print("standard input"); + p.getOutputStream().close(); + ProcessResults r = run(p); + equal(r.exitValue(), 0); + equal(r.out, "standard output"); + equal(r.err, "standard error"); + } } static void checkProcessPid() { @@ -1268,6 +1291,8 @@ public class Basic { if (UnicodeOS.is()) System.out.println("This appears to be a Unicode-based OS."); + System.out.println("Using:" + System.getProperty("jdk.lang.Process.launchMechanism")); + try { testIORedirection(); } catch (Throwable t) { unexpected(t); } diff --git a/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/ConcNativeForkTest.java b/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/ConcNativeForkTest.java new file mode 100644 index 00000000000..f02e4991302 --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/ConcNativeForkTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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 id=POSIX_SPAWN + * @bug 8377907 + * @summary Test that demonstrates the hanging-parent-on-native-concurrent-forks problem + * @requires os.family != "windows" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/manual -Djdk.lang.Process.launchMechanism=POSIX_SPAWN ConcNativeForkTest + */ + +/* + * @test id=FORK + * @bug 8377907 + * @summary Test that demonstrates the hanging-parent-on-native-concurrent-forks problem + * @requires os.family != "windows" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/manual -Djdk.lang.Process.launchMechanism=FORK ConcNativeForkTest + */ + +/* + * @test id=VFORK + * @bug 8377907 + * @summary Test that demonstrates the hanging-parent-on-native-concurrent-forks problem + * @requires os.family == "linux" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/manual -Djdk.lang.Process.launchMechanism=VFORK ConcNativeForkTest + */ + +public class ConcNativeForkTest { + + // How this works: + // - We start a child process via ProcessBuilder. Does not matter what, we just call "/bin/true". + // - Concurrently, we continuously (up to a limit) fork natively; these forks will all exec "sleep 30". + // - If the natively forked child process forks off at the right (wrong) moment, it will catch the open pipe from + // the "/bin/true" child process, and forcing the parent process (this test) to wait in ProcessBuilder.start() + // (inside forkAndExec()) until the natively forked child releases the pipe file descriptors it inherited. + + // Notes: + // + // Obviously, this is racy and depends on scheduler timings of the underlying OS. The test succeeding is + // no proof the bug does not exist (see PipesCloseOnExecTest as a complimentary test that is more reliable, but + // only works on Linux). + // That said, in tests it reliably reproduces the bug on Linux x64 and MacOS Arm. + // + // This test is not well suited for automatic test execution, since the test essentially + // fork-bombs itself, and that may run into issues in containerized CI/CD environments. + + native static boolean prepareNativeForkerThread(int numForks); + native static void releaseNativeForkerThread(); + native static void stopNativeForkerThread(); + + private static final int numIterations = 20; + + public static void main(String[] args) throws Exception { + + System.out.println("jdk.lang.Process.launchMechanism=" + + System.getProperty("jdk.lang.Process.launchMechanism")); + + System.loadLibrary("ConcNativeFork"); + + // A very simple program returning immediately (/bin/true) + ProcessBuilder pb = new ProcessBuilder("true").inheritIO(); + final int numJavaProcesses = 10; + final int numNativeProcesses = 250; + Process[] processes = new Process[numJavaProcesses]; + + for (int iteration = 0; iteration < numIterations; iteration ++) { + + if (!prepareNativeForkerThread(numNativeProcesses)) { + throw new RuntimeException("Failed to start native forker thread (see stdout)"); + } + + long[] durations = new long[numJavaProcesses]; + + releaseNativeForkerThread(); + + for (int np = 0; np < numJavaProcesses; np ++) { + long t1 = System.currentTimeMillis(); + try (Process p = pb.start()) { + durations[np] = System.currentTimeMillis() - t1; + processes[np] = p; + } + } + + stopNativeForkerThread(); + + long longestDuration = 0; + for (int np = 0; np < numJavaProcesses; np ++) { + processes[np].waitFor(); + System.out.printf("Duration: %dms%n", durations[np]); + longestDuration = Math.max(durations[np], longestDuration); + } + + System.out.printf("Longest startup time: %dms%n", longestDuration); + + if (longestDuration >= 30000) { + throw new RuntimeException("Looks like we blocked on native fork"); + } + } + + } + +} diff --git a/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/libConcNativeFork.c b/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/libConcNativeFork.c new file mode 100644 index 00000000000..59729308558 --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/ConcNativeForkTest/libConcNativeFork.c @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "testlib_thread_barriers.h" + +static void trc(const char* fmt, ...) { + char buf [1024]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + printf("(pid: %d): %s\n", (int)getpid(), buf); + fflush(stdout); +} + +static pthread_t tid_forker; + +static pthread_barrier_t start_barrier; +static atomic_bool stop_now = false; + +static void* forkerLoop(void* info) { + + const int numForks = (int)(intptr_t)info; + pid_t* pids = calloc(numForks, sizeof(pid_t)); + + trc("Forker: Waiting for Go."); + + pthread_barrier_wait(&start_barrier); + + for (int i = 0; i < numForks; i++) { + const pid_t pid = fork(); + if (pid == 0) { + /* Exec sleep. Properly opened file descriptors in parents (tagged CLOEXEC) should be released now. + * Note that we use bash to not have to deal with path resolution. For our case, it does not matter if + * sleep is a builtin or not. */ + char* env[] = { "PATH=/usr/bin:/bin", NULL }; + char* argv[] = { "sh", "-c", "sleep 30", NULL }; + execve("/bin/sh", argv, env); + trc("Native child: sleep exec failed? %d", errno); + /* The simplest way to handle this is to just wait here; this *will* cause the test to fail. */ + sleep(120); + trc("Native child: exiting"); + exit(0); + } else { + pids[i] = pid; + sched_yield(); + } + } + + trc("Forker: All native child processes started."); + + /* Wait for test to signal end */ + while (!atomic_load(&stop_now)) { + sleep(1); + } + + trc("Forker: Cleaning up."); + + /* Reap children */ + for (int i = 0; i < numForks; i ++) { + if (pids[i] != 0) { + kill(pids[i], SIGKILL); /* if still running */ + waitpid(pids[i], NULL, 0); + } + } + + trc("Forker: Done."); + + return NULL; +} + +JNIEXPORT jboolean JNICALL +Java_ConcNativeForkTest_prepareNativeForkerThread(JNIEnv* env, jclass cls, jint numForks) +{ + pthread_attr_t attr; + int rc = 0; + + const int cap = 1000; + const int numForksCapped = numForks > cap ? cap : numForks; + if (numForks > numForksCapped) { + trc("Main: Capping max. number of forks at %d", numForksCapped); /* don't forkbomb me */ + } + + if (pthread_barrier_init(&start_barrier, NULL, 2) != 0) { + trc("Main: pthread_barrier_init failed (%d)", errno); + return false; + } + + pthread_attr_init(&attr); + if (pthread_create(&tid_forker, &attr, forkerLoop, (void*)(intptr_t)numForksCapped) != 0) { + trc("Main: pthread_create failed (%d)", errno); + return JNI_FALSE; + } + + trc("Main: Prepared native forker thread"); + + return JNI_TRUE; +} + +JNIEXPORT void JNICALL +Java_ConcNativeForkTest_releaseNativeForkerThread(JNIEnv* env, jclass cls) +{ + pthread_barrier_wait(&start_barrier); + trc("Main: signaled GO"); +} + +JNIEXPORT void JNICALL +Java_ConcNativeForkTest_stopNativeForkerThread(JNIEnv* env, jclass cls) +{ + atomic_store(&stop_now, true); + pthread_join(tid_forker, NULL); + pthread_barrier_destroy(&start_barrier); +} diff --git a/test/jdk/java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java b/test/jdk/java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java index 146c2be563f..aee85e2335f 100644 --- a/test/jdk/java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java +++ b/test/jdk/java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test id=posix_spawn - * @summary Check that we don't leak FDs + * @summary Check that we don't leak FDs to child processes * @requires os.family != "windows" * @library /test/lib * @run main/othervm/native -Djdk.lang.Process.launchMechanism=posix_spawn -agentlib:FDLeaker FDLeakTest @@ -32,7 +32,7 @@ /** * @test id=fork - * @summary Check that we don't leak FDs + * @summary Check that we don't leak FDs to child processes * @requires os.family != "windows" * @library /test/lib * @run main/othervm/native -Djdk.lang.Process.launchMechanism=fork -agentlib:FDLeaker FDLeakTest @@ -40,7 +40,7 @@ /** * @test id=vfork - * @summary Check that we don't leak FDs + * @summary Check that we don't leak FDs to child processes * @requires os.family == "linux" * @library /test/lib * @run main/othervm/native -Djdk.lang.Process.launchMechanism=vfork -agentlib:FDLeaker FDLeakTest diff --git a/test/jdk/java/lang/ProcessBuilder/InheritIOClosed.java b/test/jdk/java/lang/ProcessBuilder/InheritIOClosed.java new file mode 100644 index 00000000000..3e96a49bd3b --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/InheritIOClosed.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2026, 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 + * @summary child process should not hang even if parent process has closed System.out/err + * @bug 8366736 + * @run main/othervm InheritIOClosed close dontclose + * @run main/othervm InheritIOClosed dontclose close + * @run main/othervm InheritIOClosed close close + */ + +import java.nio.file.Path; + +public class InheritIOClosed { + private final static Path JAVA_EXE = + Path.of(System.getProperty("java.home"), "bin", "java"); + + private static final String s = "1234567890".repeat(10); + + public static void main(String[] args) throws Exception { + if (args.length == 2) { + // Main test process + if (args[0].equals("close")) { + System.out.close(); + } + if (args[1].equals("close")) { + System.err.close(); + } + + ProcessBuilder pb = new ProcessBuilder().inheritIO() + .command(JAVA_EXE.toString(), + "-cp", + System.getProperty("java.class.path"), + InheritIOClosed.class.getName()); + Process process = pb.start(); + process.waitFor(); + + System.out.println("Done"); + } else { + // Child process -- print to System.out/err. Without the fix in + // JDK-8366736, this process will hang on Windows. + for (int i = 0; i < 100; i++) { + System.out.println(s); + } + for (int i = 0; i < 100; i++) { + System.err.println(s); + } + } + } +} diff --git a/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java b/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java index a372eeefbf8..b3f52663a59 100644 --- a/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java +++ b/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,21 +23,22 @@ /* * @test - * @bug 8023130 8166026 * @summary Unit test for java.lang.ProcessBuilder inheritance of standard output and standard error streams + * @bug 8023130 8166026 * @requires vm.flagless * @library /test/lib * @build jdk.test.lib.process.* - * @run testng InheritIOTest + * @run junit InheritIOTest */ import java.util.List; import static java.lang.ProcessBuilder.Redirect.INHERIT; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; public class InheritIOTest { @@ -45,25 +46,25 @@ public class InheritIOTest { private static final String EXPECTED_RESULT_STDOUT = "message"; private static final String EXPECTED_RESULT_STDERR = EXIT_VALUE_TEMPLATE.formatted(0); - @DataProvider - public Object[][] testCases() { - return new Object[][]{ - new Object[] { List.of("InheritIOTest$TestInheritIO", "printf", EXPECTED_RESULT_STDOUT) }, - new Object[] { List.of("InheritIOTest$TestRedirectInherit", "printf", EXPECTED_RESULT_STDOUT) } - }; + public static List testCases() { + return List.of( + Arguments.of(List.of("InheritIOTest$TestInheritIO", "printf", EXPECTED_RESULT_STDOUT)), + Arguments.of(List.of("InheritIOTest$TestRedirectInherit", "printf", EXPECTED_RESULT_STDOUT)) + ); } - @Test(dataProvider = "testCases") + @ParameterizedTest + @MethodSource("testCases") public void testInheritWithoutRedirect(List arguments) throws Throwable { ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(processBuilder); outputAnalyzer.shouldHaveExitValue(0); - assertEquals(outputAnalyzer.getStdout(), EXPECTED_RESULT_STDOUT); - assertEquals(outputAnalyzer.getStderr(), EXPECTED_RESULT_STDERR); + assertEquals(EXPECTED_RESULT_STDOUT, outputAnalyzer.getStdout()); + assertEquals(EXPECTED_RESULT_STDERR, outputAnalyzer.getStderr()); } public static class TestInheritIO { - public static void main(String args[]) throws Throwable { + public static void main(String[] args) throws Throwable { int err = new ProcessBuilder(args).inheritIO().start().waitFor(); System.err.printf(EXIT_VALUE_TEMPLATE, err); System.exit(err); @@ -71,7 +72,7 @@ public class InheritIOTest { } public static class TestRedirectInherit { - public static void main(String args[]) throws Throwable { + public static void main(String[] args) throws Throwable { int err = new ProcessBuilder(args) .redirectInput(INHERIT) .redirectOutput(INHERIT) @@ -81,5 +82,4 @@ public class InheritIOTest { System.exit(err); } } - } diff --git a/test/jdk/java/lang/ProcessBuilder/InvalidWorkDir.java b/test/jdk/java/lang/ProcessBuilder/InvalidWorkDir.java new file mode 100644 index 00000000000..310ecf03f97 --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/InvalidWorkDir.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2026, 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 id=FORK + * @bug 8379967 + * @summary Check that passing an invalid work dir yields a corresponding IOE text. + * @requires (os.family != "windows") + * @requires vm.flagless + * @library /test/lib + * @run main/othervm -Xmx64m -Djdk.lang.Process.launchMechanism=FORK InvalidWorkDir + */ + +/** + * @test id=POSIX_SPAWN + * @bug 8379967 + * @summary Check that passing an invalid work dir yields a corresponding IOE text. + * @requires (os.family != "windows") + * @requires vm.flagless + * @library /test/lib + * @run main/othervm -Xmx64m -Djdk.lang.Process.launchMechanism=FORK InvalidWorkDir + */ + +import jdk.test.lib.process.OutputAnalyzer; + +import java.io.File; +import java.io.IOException; + +public class InvalidWorkDir { + + public static void main(String[] args) { + ProcessBuilder bld = new ProcessBuilder("ls").directory(new File("./doesnotexist")); + try(Process p = bld.start()) { + throw new RuntimeException("IOE expected"); + } catch (IOException e) { + if (!e.getMessage().matches(".*Failed to access working directory.*No such file or directory.*")) { + throw new RuntimeException(String.format("got IOE but with different text (%s)", e.getMessage())); + } + } + } + +} diff --git a/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java b/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java index 0098bc531fd..59ce9450cb9 100644 --- a/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java +++ b/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java @@ -39,6 +39,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; public class JspawnhelperProtocol { @@ -55,7 +56,9 @@ public class JspawnhelperProtocol { System.out.println("Recursively executing 'JspawnhelperProtocol " + arg + "'"); Process p = null; try { - p = Runtime.getRuntime().exec(CMD); + // Route any stdout from the child process - be it jspawnhelper error messages or the output of "/bin/pwd" - + // through to the parent process. + p = new ProcessBuilder(CMD).inheritIO().start(); } catch (Exception e) { // Check that exception contains rich message on failure. e.printStackTrace(System.out); @@ -70,12 +73,6 @@ public class JspawnhelperProtocol { System.exit(ERROR + 1); } if (p.exitValue() == 0) { - String pwd = p.inputReader().readLine(); - String realPwd = Path.of("").toAbsolutePath().toString(); - if (!realPwd.equals(pwd)) { - System.out.println("Child process returned '" + pwd + "' (expected '" + realPwd + "')"); - System.exit(ERROR + 2); - } System.out.println(" Successfully executed '" + CMD[0] + "'"); System.exit(0); } else { @@ -89,7 +86,6 @@ public class JspawnhelperProtocol { pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", "JspawnhelperProtocol", "normalExec"); - pb.inheritIO(); Process p = pb.start(); if (!p.waitFor(TIMEOUT, TimeUnit.SECONDS)) { throw new Exception("Parent process timed out"); @@ -97,6 +93,10 @@ public class JspawnhelperProtocol { if (p.exitValue() != 0) { throw new Exception("Parent process exited with " + p.exitValue()); } + OutputAnalyzer output = new OutputAnalyzer(p); + output.shouldContain("Recursively executing 'JspawnhelperProtocol normalExec'"); + String realPwd = Path.of("").toAbsolutePath().toString(); + output.shouldContain(realPwd); } private static void simulateCrashInChild(int stage) throws Exception { @@ -144,7 +144,7 @@ public class JspawnhelperProtocol { try (BufferedReader br = p.inputReader()) { line = br.readLine(); while (line != null && !line.startsWith("posix_spawn:")) { - System.out.println(line); + System.out.println("parent stdout:" + line); line = br.readLine(); } } diff --git a/test/jdk/java/lang/ProcessBuilder/JspawnhelperWarnings.java b/test/jdk/java/lang/ProcessBuilder/JspawnhelperWarnings.java index d9896f16e00..fec0b4f3efd 100644 --- a/test/jdk/java/lang/ProcessBuilder/JspawnhelperWarnings.java +++ b/test/jdk/java/lang/ProcessBuilder/JspawnhelperWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,11 +22,19 @@ */ /* - * @test - * @bug 8325567 8325621 + * @test id=badargs + * @bug 8325567 8325621 8379967 * @requires (os.family == "linux") | (os.family == "aix") | (os.family == "mac") * @library /test/lib - * @run driver JspawnhelperWarnings + * @run driver JspawnhelperWarnings badargs + */ + +/* + * @test id=badversion + * @bug 8325567 8325621 8379967 + * @requires (os.family == "linux") | (os.family == "aix") | (os.family == "mac") + * @library /test/lib + * @run driver JspawnhelperWarnings badversion */ import java.nio.file.Paths; @@ -36,6 +44,13 @@ import jdk.test.lib.process.ProcessTools; public class JspawnhelperWarnings { + // See childproc_errorcodes.h + static final int ESTEP_JSPAWN_ARG_ERROR = 1; + static final int ESTEP_JSPAWN_VERSION_ERROR = 2; + + // See exitCodeFromErrorCode() in childproc_errorcodes.c + static final int EXITCODE_OFFSET = 0x10; + private static void tryWithNArgs(int nArgs) throws Exception { System.out.println("Running jspawnhelper with " + nArgs + " args"); String[] args = new String[nArgs + 1]; @@ -43,9 +58,10 @@ public class JspawnhelperWarnings { args[0] = Paths.get(System.getProperty("java.home"), "lib", "jspawnhelper").toString(); Process p = ProcessTools.startProcess("jspawnhelper", new ProcessBuilder(args)); OutputAnalyzer oa = new OutputAnalyzer(p); - oa.shouldHaveExitValue(1); + oa.shouldHaveExitValue(EXITCODE_OFFSET + ESTEP_JSPAWN_ARG_ERROR); + oa.shouldContain("jspawnhelper fail: (1-0-0)"); oa.shouldContain("This command is not for general use"); - if (nArgs != 2) { + if (nArgs != 1) { oa.shouldContain("Incorrect number of arguments"); } else { oa.shouldContain("Incorrect Java version"); @@ -53,22 +69,33 @@ public class JspawnhelperWarnings { } private static void testVersion() throws Exception { - String[] args = new String[3]; + String[] args = new String[2]; args[0] = Paths.get(System.getProperty("java.home"), "lib", "jspawnhelper").toString(); args[1] = "wrongVersion"; - args[2] = "1:1:1"; Process p = ProcessTools.startProcess("jspawnhelper", new ProcessBuilder(args)); OutputAnalyzer oa = new OutputAnalyzer(p); - oa.shouldHaveExitValue(1); + oa.shouldHaveExitValue(EXITCODE_OFFSET + ESTEP_JSPAWN_VERSION_ERROR); + oa.shouldContain("jspawnhelper fail: (2-0-0)"); oa.shouldContain("This command is not for general use"); oa.shouldContain("Incorrect Java version: wrongVersion"); } public static void main(String[] args) throws Exception { - for (int nArgs = 0; nArgs < 10; nArgs++) { - tryWithNArgs(nArgs); + if (args.length != 1) { + throw new RuntimeException("test argument error"); + } + switch (args[0]) { + case "badargs" -> { + for (int nArgs = 0; nArgs < 10; nArgs++) { + if (nArgs != 1) { + tryWithNArgs(nArgs); + } + } + } + case "badversion" -> { + testVersion(); + } + default -> throw new RuntimeException("test argument error"); } - - testVersion(); } } diff --git a/test/jdk/java/lang/ProcessBuilder/LinuxFDInfo.java b/test/jdk/java/lang/ProcessBuilder/LinuxFDInfo.java new file mode 100644 index 00000000000..6e0b08c5879 --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/LinuxFDInfo.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2026, 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. + */ + +/** + * Accessor for Native calls to get information about File Descriptors. + * If it's a pipe and its Inode number. + */ +public class LinuxFDInfo { + + static { + System.loadLibrary("LinuxFDInfo"); + } + + // Maximum file descriptor to probe for being a pipe, + private final static int MAX_FD = 100; + + // A simple main to print the pipes in this process and their Inode value + public static void main() { + for (int fd = 0; fd < MAX_FD; fd++) { + long inode = getPipeInodeNum(fd); + if (inode != 0) { + System.out.printf("fd: %d, inode: 0x%08x\n", fd, inode); + } + } + } + + // Parse the output from main into a long array of the fd, and Inode. + public static FdAndInode parseFdAndInode(String s) { + String[] args = s.split(","); + return new FdAndInode(Integer.parseUnsignedInt(args[0].split(":")[1].trim()), + Long.parseUnsignedLong(args[1].split(":")[1].trim().substring(2), 16)); + } + + /** + * Return the inode number for the FD, if it is a pipe. + * @param fd file descriptor + * @return the Inode number. + */ + public static native long getPipeInodeNum(int fd); + + public record FdAndInode(int fd, long inode) {} +} diff --git a/test/jdk/java/lang/ProcessBuilder/NonPipelineLeaksFD.java b/test/jdk/java/lang/ProcessBuilder/NonPipelineLeaksFD.java new file mode 100644 index 00000000000..be2c4af3bbe --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/NonPipelineLeaksFD.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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.io.*; + +/* + * @test id=FORK + * @summary Check that we don't accumulate leaked FDs in the parent process + * @requires os.family == "linux" + * @library /test/lib + * @run main/othervm -Djdk.lang.Process.launchMechanism=fork NonPipelineLeaksFD + */ + +/* + * @test id=VFORK + * @summary Check that we don't accumulate leaked FDs in the parent process + * @requires os.family == "linux" + * @library /test/lib + * @run main/othervm -Djdk.lang.Process.launchMechanism=vfork NonPipelineLeaksFD + */ + +/* + * @test id=POSIX_SPAWN + * @summary Check that we don't accumulate leaked FDs in the parent process + * @requires os.family == "linux" + * @library /test/lib + * @run main/othervm -Djdk.lang.Process.launchMechanism=posix_spawn NonPipelineLeaksFD + */ + +public class NonPipelineLeaksFD { + + final static int repeatCount = 50; + + // Similar to PilelineLeaksFD, but where PilelineLeaksFD checks that the parent process + // does not leak file descriptors when invoking a pipeline, here we check that we don't + // leak FDs when executing simple (non-pipelined) programs but we test a wider span of + // redirection modes in both successful and failing variants. + + // How this works: + // + // We execute a mix of failing and succeeding child process starts with various + // flavors of IO redirections many times; we observe the open file descriptors + // before and afterwards. Test fails if we have significantly more file descriptors + // open afterwards than before. + + static int countNumberOfOpenFileDescriptors() { + return new File("/proc/self/fd").list().length; + } + + static void printOpenFileDescriptors() { + long mypid = ProcessHandle.current().pid(); + try(Process p = new ProcessBuilder("lsof", "-p", Long.toString(mypid)) + .inheritIO().start()) { + p.waitFor(); + } catch (InterruptedException | IOException ignored) { + // Quietly swallow; it was just an attempt. + } + } + + static String readFirstLineOf(File f) { + String result; + try (BufferedReader b = new BufferedReader(new FileReader(f))){ + result = b.readLine(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return result; + } + + static void runThisExpectSuccess(ProcessBuilder bld) { + try(Process p = bld.start()) { + p.waitFor(); + if (p.exitValue() != 0) { + throw new RuntimeException("Unexpected exitcode"); + } + } catch (IOException | InterruptedException e) { + throw new RuntimeException(e); + } + } + + static void runThisExpectError(ProcessBuilder bld) { + boolean failed = false; + try(Process p = bld.start()) { + p.waitFor(); + } catch (IOException | InterruptedException e) { + failed = true; + } + if (!failed) { + throw new RuntimeException("Expected Error"); + } + } + + static void runPosWithPipes() { + ProcessBuilder bld = new ProcessBuilder("sh", "-c", "echo hallo"); + runThisExpectSuccess(bld); + } + + static void runPosWithInheritIO() { + ProcessBuilder bld = new ProcessBuilder("sh", "-c", "echo hallo").inheritIO(); + runThisExpectSuccess(bld); + } + + static void runPosWithRedirectToFile() { + File fo = new File("test.out"); + ProcessBuilder bld = new ProcessBuilder("sh", "-c", "echo hallo"); + bld.redirectOutput(ProcessBuilder.Redirect.to(fo)); + runThisExpectSuccess(bld); + if (!readFirstLineOf(fo).equals("hallo")) { + throw new RuntimeException("mismatch"); + } + } + + static void runNegWithPipes() { + ProcessBuilder bld = new ProcessBuilder("doesnotexist"); + runThisExpectError(bld); + } + + static void runNegWithInheritIO() { + ProcessBuilder bld = new ProcessBuilder("doesnotexist").inheritIO(); + runThisExpectError(bld); + } + + static void runNegWithRedirectToFile() { + File fo = new File("test.out"); + ProcessBuilder bld = new ProcessBuilder("doesnotexist"); + bld.redirectOutput(ProcessBuilder.Redirect.to(fo)); + runThisExpectError(bld); + } + + static void doTestNTimesAndCountFDs(Runnable runnable, String name) { + System.out.println(name); + int c1 = countNumberOfOpenFileDescriptors(); + for (int i = 0; i < repeatCount; i++) { + runnable.run(); + } + int c2 = countNumberOfOpenFileDescriptors(); + System.out.printf("%d->%d", c1, c2); + } + + public static void main(String[] args) throws Exception { + System.out.println("jdk.lang.Process.launchMechanism=" + + System.getProperty("jdk.lang.Process.launchMechanism")); + int c1 = countNumberOfOpenFileDescriptors(); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runPosWithPipes, "runPosWithPipes"); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runPosWithInheritIO, "runPosWithInheritIO"); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runPosWithRedirectToFile, "runPosWithRedirectToFile"); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runNegWithPipes, "runNegWithPipes"); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runNegWithInheritIO, "runNegWithInheritIO"); + doTestNTimesAndCountFDs(NonPipelineLeaksFD::runNegWithRedirectToFile, "runNegWithRedirectToFile"); + int c2 = countNumberOfOpenFileDescriptors(); + + System.out.printf("All tests: %d->%d", c1, c2); + printOpenFileDescriptors(); + + final int fudge = 10; + if (c2 > (c1 + fudge)) { + throw new RuntimeException( + String.format("Leak suspected (%d->%d) - see lsof output", c1, c2)); + } + } +} diff --git a/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java b/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java index 92cca736503..d1213a5ee11 100644 --- a/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java +++ b/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java @@ -21,46 +21,50 @@ * questions. */ -import org.junit.jupiter.api.condition.EnabledIf; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.jupiter.api.Assertions.*; -import jdk.test.lib.Utils; import java.io.BufferedReader; import java.io.IOException; import java.io.Writer; -import java.lang.ProcessHandle; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.concurrent.TimeUnit; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; -import java.util.Optional; import java.util.Set; -import java.util.StringJoiner; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + /* - * @test + * @test id=FORK * @bug 8289643 8291760 8291986 - * @requires os.family == "mac" | (os.family == "linux" & !vm.musl) + * @requires os.family == "mac" | os.family == "linux" * @summary File descriptor leak detection with ProcessBuilder.startPipeline * @library /test/lib - * @run junit/othervm/timeout=240 PipelineLeaksFD + * @run junit/othervm/timeout=240 -Djdk.lang.Process.launchMechanism=FORK PipelineLeaksFD + */ + +/* + * @test id=POSIX_SPAWN + * @bug 8289643 8291760 8291986 8379182 + * @requires os.family == "mac" | os.family == "linux" + * @summary File descriptor leak detection with ProcessBuilder.startPipeline + * @library /test/lib + * @run junit/othervm/native/timeout=240 -Djdk.lang.Process.launchMechanism=POSIX_SPAWN PipelineLeaksFD */ public class PipelineLeaksFD { - private static final String OS_NAME = System.getProperty("os.name", "Unknown"); + private static final String TEST_JDK = System.getProperty("test.jdk"); + + private static final String JAVA_LIBRARY_PATH = System.getProperty("java.library.path"); private static final long MY_PID = ProcessHandle.current().pid(); - private static final boolean LSOF_AVAILABLE = checkForLSOF(); + // Maximum file descriptor to probe for being a pipe, + private static final int MAX_FD = 100; // Test cases for pipelines with a number of pipeline sequences public static Object[][] builders() { @@ -76,37 +80,17 @@ public class PipelineLeaksFD { }; } - // True if lsof is runnable and collect pipe usage. - private static boolean lsofAvailable() { - return LSOF_AVAILABLE; - } - - // Check if lsof is available - private static boolean checkForLSOF() { - try { - lsofForPids(MY_PID); - return true; - } catch (IOException ioe) { - System.err.println("Skipping: " + ioe); - return false; - } - } - - @EnabledIf("lsofAvailable") @ParameterizedTest @MethodSource("builders") void checkForLeaks(List builders) throws IOException { - List lsofLines = lsofForPids(MY_PID); - Set pipesBefore = pipesFromLSOF(lsofLines, MY_PID); - if (pipesBefore.size() < 3) { - // Dump all lsof output to aid debugging - System.out.println("Output from lsof"); - lsofLines.forEach(System.err::println); - System.err.println(pipesBefore); - fail("There should be at least 3 pipes before, (0, 1, 2)"); + System.out.println("Using:" + System.getProperty("jdk.lang.Process.launchMechanism")); + Set beforePipes = pipesFromSelf(); + if (beforePipes.size() < 3) { + fail("There should be at least 3 pipes before, (0, 1, 2): is " + + beforePipes.size()); } - printPipes(pipesBefore, "Before start"); + printPipes(beforePipes, "Before start"); List processes = ProcessBuilder.startPipeline(builders); @@ -133,18 +117,14 @@ public class PipelineLeaksFD { processes.forEach(PipelineLeaksFD::waitForQuiet); - lsofLines = lsofForPids(MY_PID); - Set pipesAfter = pipesFromLSOF(lsofLines, MY_PID); - if (!pipesBefore.equals(pipesAfter)) { - Set missing = new HashSet<>(pipesBefore); - missing.removeAll(pipesAfter); - printPipes(missing, "Missing from pipesAfter"); - Set extra = new HashSet<>(pipesAfter); - extra.removeAll(pipesBefore); - printPipes(extra, "Extra pipes in pipesAfter"); - // Dump all lsof output to aid debugging - System.out.println("\nOutput from lsof"); - lsofLines.forEach(System.err::println); + Set afterPipes = pipesFromSelf(); + if (!beforePipes.equals(afterPipes)) { + Set missing = new HashSet<>(beforePipes); + missing.removeAll(afterPipes); + printPipes(missing, "Missing from beforePipes()"); + Set extra = new HashSet<>(afterPipes); + extra.removeAll(beforePipes); + printPipes(extra, "Extra pipes in afterPipes()"); fail("More or fewer pipes than expected"); } } @@ -157,40 +137,46 @@ public class PipelineLeaksFD { }; } - // Test redirectErrorStream (true/false) has the right number of pipes in use - @EnabledIf("lsofAvailable") + // Test redirectErrorStream (true/false) has the right number of pipes in use. + // Spawn the child to report its pipe inode info. @ParameterizedTest() @MethodSource("redirectCases") void checkRedirectErrorStream(boolean redirectError) { - try (Process p = new ProcessBuilder("cat") + + System.out.println("Using:" + System.getProperty("jdk.lang.Process.launchMechanism")); + + try (Process p = new ProcessBuilder(TEST_JDK + "/bin/java", + "--enable-preview", + "-Djava.library.path=" + JAVA_LIBRARY_PATH, + "--enable-native-access=ALL-UNNAMED", "LinuxFDInfo") .redirectErrorStream(redirectError) .start()) { - System.err.printf("Parent PID; %d, Child Pid: %d\n", MY_PID, p.pid()); - List lsofLines = lsofForPids(MY_PID, p.pid()); - final Set pipes = pipesFromLSOF(lsofLines, MY_PID, p.pid()); - printPipes(pipes, "Parent and child pipes"); - // For each of the child standard pipes, check the parent and child uses of the pipe - var pIn = PipeRecord.pipeFor(pipes, p.pid(), 0).orElseThrow(); - Set pIns = PipeRecord.allSamePipes(pipes, pIn); - assertEquals(2, pIns.size(), "StdIn pipe count"); + final Set pipes = pipesFromSelf(); + printPipes(pipes, "Parent pipes"); + List lines = p.inputReader().readAllLines(); + Set childPipes = lines.stream().map(s -> { + var fdAndInode = LinuxFDInfo.parseFdAndInode(s); + return PipeRecord.lookup(fdAndInode.fd(), "0x%08x".formatted(fdAndInode.inode()), p.pid()); + }) + .collect(Collectors.toCollection(LinkedHashSet::new)); + printPipes(childPipes, "child pipes"); + int uniquePipes = childPipes.stream().map(PipeRecord::myKey).collect(Collectors.toSet()).size(); // Number of pipe references depending on whether stderr is redirected to stdout - long expected = redirectError ? 3 : 2; - - var pOut = PipeRecord.pipeFor(pipes, p.pid(), 1).orElseThrow(); - Set pOuts = PipeRecord.allSamePipes(pipes, pOut); - assertEquals(expected, pOuts.size(), "StdOut pipe count"); - - var pErr = PipeRecord.pipeFor(pipes, p.pid(), 2).orElseThrow(); - Set pErrs = PipeRecord.allSamePipes(pipes, pErr); - assertEquals(expected, pErrs.size(), "StdErr pipe count"); + long expected = redirectError ? 2 : 3; + assertEquals(expected, uniquePipes, "Wrong number of unique pipes"); String expectedTypeName = redirectError ? "java.lang.ProcessBuilder$NullInputStream" : "java.lang.ProcessImpl$ProcessPipeInputStream"; assertEquals(expectedTypeName, p.getErrorStream().getClass().getName(), "errorStream type is incorrect"); + + final Set afterPipes = pipesFromSelf(); + if (!pipes.equals(afterPipes)) { + printPipes(afterPipes, "Parent pipes after are different"); + } } catch (IOException ioe) { fail("Process start", ioe); } @@ -207,122 +193,26 @@ public class PipelineLeaksFD { if (st != 0) { System.err.println("non-zero exit status: " + p); } - } catch (InterruptedException ie) { + } catch (InterruptedException ignore) { } } - /** - * Extract the PipeRecords from the `lsof` output for a list of processes - * - * @param lines lines of lsof output - * @param pids varargs list of pids of interest - * @return a Set of PipeRecords for those pids - */ - private static LinkedHashSet pipesFromLSOF(List lines, long... pids) { - Arrays.sort(pids); - return lines.stream() - .map(PipelineLeaksFD::pipeFromLSOF) - .filter(pr -> pr != null && - Arrays.binarySearch(pids, pr.pid()) >= 0) - .collect(Collectors.toCollection(LinkedHashSet::new)); - } - - /** - * Collect the output of `lsof` for all files. - * Files are used for `lsof` input and output to avoid creating pipes. - * @param pids zero or more pids to request data for; none -> all - * @return a List of lines output from `lsof`. - */ - private static List lsofForPids(long... pids) throws IOException { - Path tmpDir = Path.of("."); - String tmpPrefix = "lsof-"; - Path lsofEmptyInput = Files.createTempFile(tmpDir, tmpPrefix, ".empty"); - Path lsofOutput = Files.createTempFile(tmpDir, tmpPrefix, ".tmp"); - - List lsofArgs = new ArrayList<>(); - lsofArgs.add("lsof"); - if (pids.length > 0) { - StringJoiner pidsArg = new StringJoiner(","); - for (long p : pids) { - pidsArg.add(Long.toString(p)); + static Set pipesFromSelf() { + Set pipes = new LinkedHashSet<>(MAX_FD); + for (int fd = 0; fd < MAX_FD; fd++) { + long inode = LinuxFDInfo.getPipeInodeNum(fd); + if (inode != 0) { + pipes.add(PipeRecord.lookup(fd, "0x%08x".formatted(inode), MY_PID)); } - lsofArgs.add("-p"); - lsofArgs.add(pidsArg.toString()); } - - try (Process p = new ProcessBuilder(lsofArgs) - .redirectOutput(lsofOutput.toFile()) - .redirectInput(lsofEmptyInput.toFile()) // empty input - .redirectError(ProcessBuilder.Redirect.DISCARD) // ignored output - .start()) { - boolean status = p.waitFor(Utils.adjustTimeout(120), TimeUnit.SECONDS); - if (!status) { - p.destroyForcibly(); - } - assertTrue(status, "Process 'lsof' failed"); - - return Files.readAllLines(lsofOutput); - } catch (InterruptedException ie) { - throw new IOException("Waiting for lsof exit interrupted", ie); - } - } - - // Return pipe records by parsing the appropriate platform specific `lsof` output. - static PipeRecord pipeFromLSOF(String s) { - return switch (OS_NAME) { - case "Linux" -> pipeFromLinuxLSOF(s); - case "Mac OS X" -> pipeFromMacLSOF(s); - default -> throw new RuntimeException("lsof not supported on platform: " + OS_NAME); - }; - } - - // Return Pipe from lsof output put, or null (on Mac OS X) - // lsof 55221 xxxx 0 PIPE 0xc76402237956a5cb 16384 ->0xfcb0c07ae447908c - // lsof 55221 xxxx 1 PIPE 0xb486e02f86da463e 16384 ->0xf94eacc85896b4e6 - static PipeRecord pipeFromMacLSOF(String s) { - String[] fields = s.split("\\s+"); - if ("PIPE".equals(fields[4])) { - final int pid = Integer.parseInt(fields[1]); - final String myKey = (fields.length > 5) ? fields[5] : ""; - final String otherKey = (fields.length > 7) ? fields[7].substring(2) : ""; - return PipeRecord.lookup(Integer.parseInt(fields[3]), myKey, otherKey, pid); - } - return null; - } - - // Return Pipe from lsof output put, or null (on Linux) - // java 7612 xxxx 14w FIFO 0,12 0t0 117662267 pipe - // java 7612 xxxx 15r FIFO 0,12 0t0 117662268 pipe - static PipeRecord pipeFromLinuxLSOF(String s) { - String[] fields = s.split("\\s+"); - if ("FIFO".equals(fields[4])) { - final int pid = Integer.parseInt(fields[1]); - final String key = (fields.length > 7) ? fields[7] : ""; - final int fdNum = Integer.parseInt(fields[3].substring(0, fields[3].length() - 1)); - return PipeRecord.lookup(fdNum, key, null, pid); - } - return null; + return pipes; } // Identify a pipe by pid, fd, and a key (unique across processes) // Mac OS X has separate keys for read and write sides, both are matched to the same "name" record PipeRecord(long pid, int fd, KeyedString myKey) { - static PipeRecord lookup(int fd, String myKey, String otherKey, int pid) { - return new PipeRecord(pid, fd, KeyedString.getKey(myKey, otherKey)); - } - - // Return the PipeRecord matching the fd and pid - static Optional pipeFor(Set pipes, long pid, int fd) { - return pipes.stream() - .filter(p -> p.fd() == fd && p.pid() == pid) - .findFirst(); - } - - // Return all the PipeRecords with the same key (the same OS pipe identification) - static Set allSamePipes(Set pipes, PipeRecord p) { - return pipes.stream() - .filter(p1 -> p1.myKey().key.equals(p.myKey().key)) - .collect(Collectors.toSet()); + static PipeRecord lookup(int fd, String myKey, long pid) { + return new PipeRecord(pid, fd, KeyedString.getKey(myKey)); } } @@ -343,12 +233,8 @@ public class PipelineLeaksFD { this(s, k); } - static KeyedString getKey(String key, String otherKey) { - var k = map.computeIfAbsent(key, KeyedString::new); - if (otherKey != null) { - map.putIfAbsent(otherKey, k); - } - return k; + static KeyedString getKey(String key) { + return map.computeIfAbsent(key, KeyedString::new); } public String toString() { diff --git a/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/PipesCloseOnExecTest.java b/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/PipesCloseOnExecTest.java new file mode 100644 index 00000000000..1e988f0496c --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/PipesCloseOnExecTest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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 id=FORK + * @bug 8377907 + * @summary Check that we don't open pipes without CLOEXCEC + * @requires os.family == "linux" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/native -Djdk.lang.Process.launchMechanism=FORK PipesCloseOnExecTest + */ + +/* + * @test id=VFORK + * @bug 8377907 + * @summary Check that we don't open pipes without CLOEXCEC + * @requires os.family == "linux" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/native -Djdk.lang.Process.launchMechanism=VFORK PipesCloseOnExecTest + */ + +/* + * @test id=POSIX_SPAWN + * @bug 8377907 + * @summary Check that we don't open pipes without CLOEXCEC + * @requires os.family == "linux" + * @requires vm.flagless + * @library /test/lib + * @run main/othervm/native -Djdk.lang.Process.launchMechanism=POSIX_SPAWN PipesCloseOnExecTest + */ + +import jdk.test.lib.process.OutputAnalyzer; + +import java.io.IOException; +import java.time.LocalTime; + +public class PipesCloseOnExecTest { + + // How this works: + // - We start a child process A. Does not matter what, we just call "/bin/date". + // - Concurrently, we (natively, continuously) iterate all pipe file descriptors in + // the process and count all those that are not tagged with CLOEXEC. Finding one + // counts as error. + + // Note that this test can only reliably succeed with Linux and the xxxBSDs, where + // we have pipe2(2). + // + // On MacOs and AIX, we emulate pipe2(2) with pipe(2) and fcntl(2); therefore we + // have a tiny time window in which a concurrent thread can can observe pipe + // filedescriptors without CLOEXEC. Furthermore, on MacOS, we also have to employ + // the double-dup-trick to workaround a the buggy MacOS implementation of posix_spawn. + // Therefore, on these platforms, the test would (correctly) spot "bad" file descriptors. + + native static boolean startTester(); + native static boolean stopTester(); + + static final int num_tries = 100; + + static void printOpenFileDescriptors() { + long mypid = ProcessHandle.current().pid(); + try(Process p = new ProcessBuilder("lsof", "-p", Long.toString(mypid)) + .inheritIO().start()) { + p.waitFor(); + } catch (InterruptedException | IOException ignored) { + // Quietly swallow; it was just an attempt. + } + } + + public static void main(String[] args) throws Exception { + + System.out.println("jdk.lang.Process.launchMechanism=" + + System.getProperty("jdk.lang.Process.launchMechanism")); + + System.loadLibrary("PipesCloseOnExec"); + + if (!startTester()) { + throw new RuntimeException("Failed to start testers (see stdout)"); + } + + System.out.println(LocalTime.now() + ": Call ProcessBuilder.start..."); + + for (int i = 0; i < num_tries; i ++) { + ProcessBuilder pb = new ProcessBuilder("true").inheritIO(); + new OutputAnalyzer(pb.start()).shouldHaveExitValue(0); + } + + if (!stopTester()) { + printOpenFileDescriptors(); + throw new RuntimeException("Catched FDs without CLOEXEC? Check output."); + } + } +} diff --git a/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/libPipesCloseOnExec.c b/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/libPipesCloseOnExec.c new file mode 100644 index 00000000000..9a090f3bbd5 --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/PipesCloseOnExecTest/libPipesCloseOnExec.c @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "testlib_thread_barriers.h" + +static void trc(const char* fmt, ...) { + char buf [1024]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + printf("%s\n", buf); + fflush(stdout); +} + +/* Set 1 to restrict this test to pipes, 0 to test all file descriptors. + * (for now, we ignore regular files opened with CLOEXEC since loaded jars seem not tagged as CLOEXEc. + * We should probably fix that eventually. */ +#define TEST_PIPES_ONLY 1 + +/* stdin/out/err file descriptors are usually not CLOEXEC */ +#define IGNORE_BELOW 4 + +/* Only query file descriptors up to this point */ +#define MAX_FD 1024 + +static pthread_t tid_tester; + +static pthread_barrier_t start_barrier; +static atomic_bool stop_now = false; + +/* Mainly to prevent tracing the same fd over and over again: + * 1 - present, 2 - present, cloexec */ +static unsigned fd_state[MAX_FD]; + +static bool is_pipe(int fd) { + struct stat mystat; + if (fstat(fd, &mystat) == -1) { + return false; + } + return mystat.st_mode & S_IFIFO; +} + +static void print_fd_details(int fd, char* out, size_t outlen) { + const char* type = "unknown"; + char link[1024] = { 0 }; + char procfd[129]; + struct stat mystat; + + out[0] = '\0'; + + if (fstat(fd, &mystat) == -1) { + snprintf(out, outlen, "%s", errno == EBADF ? "EBADF" : "???"); + return; + } + + switch (mystat.st_mode & S_IFMT) { + case S_IFBLK: type = "blk"; break; + case S_IFCHR: type = "char"; break; + case S_IFDIR: type = "dir"; break; + case S_IFIFO: type = "fifo"; break; + case S_IFLNK: type = "lnk"; break; + case S_IFREG: type = "reg"; break; + case S_IFSOCK: type = "sock"; break; + } + + snprintf(procfd, sizeof(procfd) - 1, "/proc/self/fd/%d", fd); + int linklen = readlink(procfd, link, sizeof(link) - 1); + if (linklen > 0) { + link[linklen] = '\0'; + snprintf(out, outlen, "%s (%s)", type, link); + } else { + snprintf(out, outlen, "%s", type); + } +} + +/* Returns true for error */ +static bool testFD(int fd) { + + int rc = fcntl(fd, F_GETFD); + if (rc == -1) { + return false; + } + + const bool has_cloexec = (rc & FD_CLOEXEC); + const bool is_a_pipe = is_pipe(fd); + const unsigned state = has_cloexec ? 2 : 1; + bool had_error = false; + + if (fd_state[fd] != state) { + fd_state[fd] = state; + char buf[1024]; + print_fd_details(fd, buf, sizeof(buf)); + if (has_cloexec) { + trc("%d: %s", fd, buf); + } else { + if (fd < IGNORE_BELOW) { + trc("%d: %s ** CLOEXEC MISSING ** (ignored - below scanned range)", fd, buf); + } else if (TEST_PIPES_ONLY && !is_a_pipe) { + trc("%d: %s ** CLOEXEC MISSING ** (ignored - not a pipe)", fd, buf); + } else { + trc("%d: %s ** CLOEXEC MISSING ** (ERROR)", fd, buf); + had_error = true; + } + } + } + + return had_error; +} + +static void* testerLoop(void* dummy) { + + pthread_barrier_wait(&start_barrier); + + trc("Tester is alive"); + + bool had_error = false; + + while (!atomic_load(&stop_now)) { + for (int fd = 0; fd < MAX_FD; fd++) { + bool rc = testFD(fd); + had_error = had_error || rc; + } + } + + trc("Tester dies"); + + return had_error ? (void*)1 : NULL; +} + +JNIEXPORT jboolean JNICALL +Java_PipesCloseOnExecTest_startTester(JNIEnv* env, jclass cls) +{ + pthread_attr_t attr; + int rc = 0; + + if (pthread_barrier_init(&start_barrier, NULL, 2) != 0) { + trc("pthread_barrier_init failed (%d)", errno); + return false; + } + + pthread_attr_init(&attr); + if (pthread_create(&tid_tester, &attr, testerLoop, NULL) != 0) { + trc("pthread_create failed (%d)", errno); + return JNI_FALSE; + } + + pthread_barrier_wait(&start_barrier); + + trc("Started tester"); + + return JNI_TRUE; +} + +JNIEXPORT jboolean JNICALL +Java_PipesCloseOnExecTest_stopTester(JNIEnv* env, jclass cls) +{ + atomic_store(&stop_now, true); + + void* retval = NULL; + pthread_join(tid_tester, &retval); + pthread_barrier_destroy(&start_barrier); + + return retval == NULL ? JNI_TRUE : JNI_FALSE; +} diff --git a/test/jdk/java/lang/ProcessBuilder/ProcessReaperCCL.java b/test/jdk/java/lang/ProcessBuilder/ProcessReaperCCL.java index 79593b014c3..605441cb996 100644 --- a/test/jdk/java/lang/ProcessBuilder/ProcessReaperCCL.java +++ b/test/jdk/java/lang/ProcessBuilder/ProcessReaperCCL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,9 +23,9 @@ /* * @test - * @bug 8269488 * @summary verify that Process Reaper threads have a null CCL - * @run testng ProcessReaperCCL + * @bug 8269488 + * @run junit ProcessReaperCCL */ import java.io.File; @@ -34,14 +34,13 @@ import java.net.URLClassLoader; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.testng.Assert; -import org.testng.annotations.Test; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class ProcessReaperCCL { @Test - static void test() throws Exception { + void test() throws Exception { // create a class loader File dir = new File("."); URL[] urls = new URL[] {dir.toURI().toURL()}; @@ -53,12 +52,12 @@ public class ProcessReaperCCL { Process p = pb.start(); CompletableFuture cf = p.onExit(); int exitValue = cf.get().exitValue(); - Assert.assertEquals(exitValue, 0, "error exit value"); + Assertions.assertEquals(0, exitValue, "error exit value"); // Verify all "Process Reaper" threads have a null CCL for (Thread th : Thread.getAllStackTraces().keySet()) { if (th.getName().startsWith("process reaper")) { - Assert.assertEquals(th.getContextClassLoader(), null, "CCL not null"); + Assertions.assertNull(th.getContextClassLoader(), "CCL not null"); } } } diff --git a/test/jdk/java/lang/ProcessBuilder/ProcessStartLoggingTest.java b/test/jdk/java/lang/ProcessBuilder/ProcessStartLoggingTest.java index e9b2fa6b264..2f2bc3c3cee 100644 --- a/test/jdk/java/lang/ProcessBuilder/ProcessStartLoggingTest.java +++ b/test/jdk/java/lang/ProcessBuilder/ProcessStartLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,8 +34,7 @@ import java.util.stream.Stream; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.ParameterizedTest; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.*; /* * @test diff --git a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java index a73451417bf..6bff8d5e592 100644 --- a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java +++ b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,17 +21,10 @@ * questions. */ -import static org.testng.Assert.*; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.*; import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.hexdump.HexPrinter; -import jdk.test.lib.hexdump.HexPrinter.Formatters; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -42,20 +35,23 @@ import java.nio.file.Files; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.charset.UnsupportedCharsetException; -import java.util.List; -import java.util.Locale; +import java.util.stream.Stream; import jtreg.SkippedException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @requires vm.flagless * @library /test/lib - * @build jdk.test.lib.process.ProcessTools jdk.test.lib.hexdump.HexPrinter - * @run testng ReaderWriterTest + * @build jdk.test.lib.process.ProcessTools + * @run junit ReaderWriterTest */ -@Test public class ReaderWriterTest { static final String ASCII = "ASCII: \u0000_A-Z_a-Z_\u007C_\u007D_\u007E_\u007F_;"; @@ -65,13 +61,12 @@ public class ReaderWriterTest { public static final String TESTCHARS = "OneWay: " + ASCII + ISO_8859_1 + FRACTIONS; public static final String ROUND_TRIP_TESTCHARS = "RoundTrip: " + ASCII + ISO_8859_1 + FRACTIONS; - @DataProvider(name="CharsetCases") - static Object[][] charsetCases() { - return new Object[][] { - {"UTF-8"}, - {"ISO8859-1"}, - {"US-ASCII"}, - }; + static Stream charsetCases() { + return Stream.of( + Arguments.of("UTF-8"), + Arguments.of("ISO8859-1"), + Arguments.of("US-ASCII") + ); } /** @@ -93,7 +88,7 @@ public class ReaderWriterTest { if (exitValue != 0) System.out.println("exitValue: " + exitValue); } catch (InterruptedException ie) { - Assert.fail("waitFor interrupted"); + fail("waitFor interrupted"); } } @@ -131,32 +126,28 @@ public class ReaderWriterTest { if (errType == 2 || errType == 3) { pb.redirectErrorStream(true); } - Process p = pb.start(); - // Output has been redirected to a null stream; success is IOException on the write - try { + try (Process p = pb.start()) { + // Output has been redirected to a null stream; success is IOException on the write BufferedWriter wr = p.outputWriter(); - wr.write("X"); - wr.flush(); - Assert.fail("writing to null stream should throw IOException"); - } catch (IOException ioe) { - // Normal, A Null output stream is closed when created. - } + assertThrows(IOException.class, () -> { + wr.write("X"); + wr.flush(); + }); - // InputReader should be empty; and at EOF - BufferedReader inputReader = p.inputReader(); - int ch = inputReader.read(); - Assert.assertEquals(ch, -1, "inputReader not at EOF: ch: " + (char)ch); + // InputReader should be empty; and at EOF + BufferedReader inputReader = p.inputReader(); + int ch = inputReader.read(); + assertEquals(-1, ch, "inputReader not at EOF: ch: " + (char) ch); - // InputReader should be empty; and at EOF - BufferedReader errorReader = p.errorReader(); - ch = errorReader.read(); - Assert.assertEquals(ch, -1, "errorReader not at EOF: ch: " + (char)ch); + // InputReader should be empty; and at EOF + BufferedReader errorReader = p.errorReader(); + ch = errorReader.read(); + assertEquals(-1, ch, "errorReader not at EOF: ch: " + (char) ch); - try { int exitValue = p.waitFor(); if (exitValue != 0) System.out.println("exitValue: " + exitValue); } catch (InterruptedException ie) { - Assert.fail("waitFor interrupted"); + fail("waitFor interrupted"); } } } @@ -181,7 +172,8 @@ public class ReaderWriterTest { * * @param encoding a charset name */ - @Test(dataProvider = "CharsetCases", enabled = true) + @ParameterizedTest + @MethodSource("charsetCases") void testCase(String encoding) throws IOException { Charset cs = null; try { @@ -221,32 +213,10 @@ public class ReaderWriterTest { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "ReaderWriterTest$ChildWithCharset"); - Process p = pb.start(); - try { - writeTestChars(p.outputWriter(null)); - Assert.fail("Process.outputWriter(null) did not throw NPE"); - } catch (NullPointerException npe) { - // expected, ignore - } - try { - checkReader(p.inputReader(null), null, "Out"); - Assert.fail("Process.inputReader(null) did not throw NPE"); - } catch (NullPointerException npe) { - // expected, ignore - } - try { - checkReader(p.errorReader(null), null, "Err"); - Assert.fail("Process.errorReader(null) did not throw NPE"); - } catch (NullPointerException npe) { - // expected, ignore - } - - p.destroyForcibly(); - try { - // Collect the exit status to cleanup after the process; but ignore it - p.waitFor(); - } catch (InterruptedException ie) { - // Ignored + try (Process p = pb.start()) { + assertThrows(NullPointerException.class, () -> writeTestChars(p.outputWriter(null))); + assertThrows(NullPointerException.class, () -> checkReader(p.inputReader(null), null, "Out")); + assertThrows(NullPointerException.class, () -> checkReader(p.errorReader(null), null, "Err")); } } @@ -272,7 +242,7 @@ public class ReaderWriterTest { var writer = p.outputWriter(cs); writer = p.outputWriter(cs); // try again with same writer = p.outputWriter(otherCharset); // this should throw - Assert.fail("Process.outputWriter(otherCharset) did not throw IllegalStateException"); + fail("Process.outputWriter(otherCharset) did not throw IllegalStateException"); } catch (IllegalStateException ile) { // expected, ignore System.out.println(ile); @@ -281,7 +251,7 @@ public class ReaderWriterTest { var reader = p.inputReader(cs); reader = p.inputReader(cs); // try again with same reader = p.inputReader(otherCharset); // this should throw - Assert.fail("Process.inputReader(otherCharset) did not throw IllegalStateException"); + fail("Process.inputReader(otherCharset) did not throw IllegalStateException"); } catch (IllegalStateException ile) { // expected, ignore System.out.println(ile); @@ -290,7 +260,7 @@ public class ReaderWriterTest { var reader = p.errorReader(cs); reader = p.errorReader(cs); // try again with same reader = p.errorReader(otherCharset); // this should throw - Assert.fail("Process.errorReader(otherCharset) did not throw IllegalStateException"); + fail("Process.errorReader(otherCharset) did not throw IllegalStateException"); } catch (IllegalStateException ile) { // expected, ignore System.out.println(ile); @@ -320,13 +290,13 @@ public class ReaderWriterTest { String reencoded = cs.decode(bb).toString(); if (!firstline.equals(reencoded)) diffStrings(firstline, reencoded); - assertEquals(firstline, reencoded, label + " Test Chars"); + assertEquals(reencoded, firstline, label + " Test Chars"); bb = cs.encode(ROUND_TRIP_TESTCHARS); reencoded = cs.decode(bb).toString(); if (!secondline.equals(reencoded)) diffStrings(secondline, reencoded); - assertEquals(secondline, reencoded, label + " Round Trip Test Chars"); + assertEquals(reencoded, secondline, label + " Round Trip Test Chars"); } } diff --git a/test/jdk/java/lang/ProcessBuilder/libLinuxFDInfo.c b/test/jdk/java/lang/ProcessBuilder/libLinuxFDInfo.c new file mode 100644 index 00000000000..3eb4bd15aac --- /dev/null +++ b/test/jdk/java/lang/ProcessBuilder/libLinuxFDInfo.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2026, 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. + */ + +#include "jni.h" +#include + +// If the file descriptor is a PIPE, return the INode. +JNIEXPORT jlong JNICALL +Java_LinuxFDInfo_getPipeInodeNum(JNIEnv *env, jclass cls, jint fd) { +#ifdef S_ISFIFO + struct stat buf; + if (fstat(fd, &buf) != -1 && S_ISFIFO(buf.st_mode)) { + return buf.st_ino; + } +#endif + return 0; +} diff --git a/test/jdk/java/lang/ProcessHandle/Basic.java b/test/jdk/java/lang/ProcessHandle/Basic.java index 09674814283..d0342b35a23 100644 --- a/test/jdk/java/lang/ProcessHandle/Basic.java +++ b/test/jdk/java/lang/ProcessHandle/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,21 +21,22 @@ * questions. */ -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.testng.TestNG; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /* * @test + * @summary Basic tests for ProcessHandler * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management @@ -45,20 +46,18 @@ import org.testng.annotations.Test; * jdk.test.lib.JDKToolLauncher * jdk.test.lib.Platform * jdk.test.lib.process.* - * @run testng Basic - * @summary Basic tests for ProcessHandler - * @author Roger Riggs + * @run junit Basic */ public class Basic { /** * Tests of ProcessHandle.current. */ @Test - public static void test1() { + public void test1() { try { ProcessHandle self = ProcessHandle.current(); ProcessHandle self1 = ProcessHandle.current(); - assertEquals(self, self1); //, "get pid twice should be same %d: %d"); + assertEquals(self1, self); //, "get pid twice should be same %d: %d"); } finally { // Cleanup any left over processes ProcessHandle.current().children().forEach(ProcessHandle::destroy); @@ -69,16 +68,16 @@ public class Basic { * Tests of ProcessHandle.get. */ @Test - public static void test2() { + public void test2() { try { ProcessHandle self = ProcessHandle.current(); long pid = self.pid(); // known native process id Optional self1 = ProcessHandle.of(pid); - assertEquals(self1.get(), self, + assertEquals(self, self1.get(), "ProcessHandle.of(x.pid()) should be equal pid() %d: %d"); Optional ph = ProcessHandle.of(pid); - assertEquals(pid, ph.get().pid()); + assertEquals(ph.get().pid(), pid); } finally { // Cleanup any left over processes ProcessHandle.current().children().forEach(ProcessHandle::destroy); @@ -86,7 +85,7 @@ public class Basic { } @Test - public static void test3() { + public void test3() { // Test can get parent of current ProcessHandle ph = ProcessHandle.current(); try { @@ -99,7 +98,7 @@ public class Basic { } @Test - public static void test4() { + public void test4() { try { Process p = new ProcessBuilder("sleep", "0").start(); p.waitFor(); @@ -118,7 +117,7 @@ public class Basic { } @Test - public static void test5() { + public void test5() { // Always contains itself. ProcessHandle current = ProcessHandle.current(); List list = ProcessHandle.allProcesses().collect(Collectors.toList()); @@ -131,23 +130,17 @@ public class Basic { } } - @Test(expectedExceptions = IllegalStateException.class) - public static void test6() { - ProcessHandle.current().onExit(); + @Test + public void test6() { + Assertions.assertThrows(IllegalStateException.class, () -> { + ProcessHandle.current().onExit(); + }); } - @Test(expectedExceptions = IllegalStateException.class) - public static void test7() { - ProcessHandle.current().destroyForcibly(); + @Test + public void test7() { + Assertions.assertThrows(IllegalStateException.class, () -> { + ProcessHandle.current().destroyForcibly(); + }); } - - // Main can be used to run the tests from the command line with only testng.jar. - @SuppressWarnings("raw_types") - public static void main(String[] args) { - Class[] testclass = {TreeTest.class}; - TestNG testng = new TestNG(); - testng.setTestClasses(testclass); - testng.run(); - } - } diff --git a/test/jdk/java/lang/ProcessHandle/InfoTest.java b/test/jdk/java/lang/ProcessHandle/InfoTest.java index 38c86db3b91..ea2739e14a7 100644 --- a/test/jdk/java/lang/ProcessHandle/InfoTest.java +++ b/test/jdk/java/lang/ProcessHandle/InfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,15 +39,15 @@ import java.util.Optional; import java.util.Random; import java.util.concurrent.TimeUnit; -import org.testng.Assert; -import org.testng.TestNG; -import org.testng.annotations.Test; import jdk.test.lib.Platform; import jdk.test.lib.Utils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /* * @test + * @summary Functions of ProcessHandle.Info * @bug 8077350 8081566 8081567 8098852 8136597 * @requires os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*") * @library /test/lib @@ -59,8 +59,7 @@ import jdk.test.lib.Utils; * jdk.test.lib.JDKToolLauncher * jdk.test.lib.Platform * jdk.test.lib.process.* - * @run testng InfoTest - * @summary Functions of ProcessHandle.Info + * @run junit InfoTest * @author Roger Riggs */ @@ -82,19 +81,11 @@ public class InfoTest { } } - // Main can be used to run the tests from the command line with only testng.jar. - public static void main(String[] args) { - Class[] testclass = {InfoTest.class}; - TestNG testng = new TestNG(); - testng.setTestClasses(testclass); - testng.run(); - } - /** * Test that cputime used shows up in ProcessHandle.info */ @Test - public static void test1() { + public void test1() { System.out.println("Note: when run in samevm mode the cputime of the " + "test runner is included."); ProcessHandle self = ProcessHandle.current(); @@ -108,7 +99,7 @@ public class InfoTest { System.out.printf(" info: %s%n", info); Optional totalCpu = info.totalCpuDuration(); if (totalCpu.isPresent() && (totalCpu.get().compareTo(someCPU) < 0)) { - Assert.fail("reported cputime less than expected: " + someCPU + ", " + + Assertions.fail("reported cputime less than expected: " + someCPU + ", " + "actual: " + info.totalCpuDuration()); } } @@ -117,7 +108,7 @@ public class InfoTest { * Spawn a child with arguments and check they are visible via the ProcessHandle. */ @Test - public static void test2() { + public void test2() { try { long cpuLoopTime = 100; // 100 ms String[] extraArgs = {"pid", "parent", "stdin"}; @@ -170,7 +161,7 @@ public class InfoTest { String expected = Platform.isWindows() ? javaExe + ".exe" : javaExe; Path expectedPath = Paths.get(expected); Path actualPath = Paths.get(command.get()); - Assert.assertTrue(Files.isSameFile(expectedPath, actualPath), + Assertions.assertTrue(Files.isSameFile(expectedPath, actualPath), "Command: expected: " + javaExe + ", actual: " + command.get()); } @@ -179,22 +170,20 @@ public class InfoTest { int offset = args.length - extraArgs.length; for (int i = 0; i < extraArgs.length; i++) { - Assert.assertEquals(args[offset + i], extraArgs[i], + Assertions.assertEquals(extraArgs[i], args[offset + i], "Actual argument mismatch, index: " + i); } // Now check that the first argument is not the same as the executed command - if (args.length > 0) { - Assert.assertNotEquals(args[0], command, - "First argument should not be the executable: args[0]: " - + args[0] + ", command: " + command); - } + Assertions.assertNotEquals(command, args[0], + "First argument should not be the executable: args[0]: " + + args[0] + ", command: " + command); } if (command.isPresent() && info.arguments().isPresent()) { // If both, 'command' and 'arguments' are present, // 'commandLine' is just the concatenation of the two. - Assert.assertTrue(info.commandLine().isPresent(), + Assertions.assertTrue(info.commandLine().isPresent(), "commandLine() must be available"); String javaExe = System.getProperty("test.jdk") + @@ -204,15 +193,15 @@ public class InfoTest { String commandLine = info.commandLine().get(); String commandLineCmd = commandLine.split(" ")[0]; Path commandLineCmdPath = Paths.get(commandLineCmd); - Assert.assertTrue(Files.isSameFile(commandLineCmdPath, expectedPath), + Assertions.assertTrue(Files.isSameFile(commandLineCmdPath, expectedPath), "commandLine() should start with: " + expectedPath + " but starts with " + commandLineCmdPath); - Assert.assertTrue(commandLine.contains(command.get()), + Assertions.assertTrue(commandLine.contains(command.get()), "commandLine() must contain the command: " + command.get()); List allArgs = p1.getArgs(); for (int i = 1; i < allArgs.size(); i++) { - Assert.assertTrue(commandLine.contains(allArgs.get(i)), + Assertions.assertTrue(commandLine.contains(allArgs.get(i)), "commandLine() must contain argument: " + allArgs.get(i)); } } else if (info.commandLine().isPresent() && @@ -222,14 +211,14 @@ public class InfoTest { String commandLine = info.commandLine().get(); String javaExe = "java" + (Platform.isWindows() ? ".exe" : ""); int pos = commandLine.indexOf(javaExe); - Assert.assertTrue(pos > 0, "commandLine() should at least contain 'java'"); + Assertions.assertTrue(pos > 0, "commandLine() should at least contain 'java'"); pos += javaExe.length() + 1; // +1 for the space after the command List allArgs = p1.getArgs(); // First argument is the command - skip it here as we've already checked that. for (int i = 1; (i < allArgs.size()) && (pos + allArgs.get(i).length() < commandLine.length()); i++) { - Assert.assertTrue(commandLine.contains(allArgs.get(i)), + Assertions.assertTrue(commandLine.contains(allArgs.get(i)), "commandLine() must contain argument: " + allArgs.get(i)); pos += allArgs.get(i).length() + 1; } @@ -242,14 +231,14 @@ public class InfoTest { System.out.printf(" info.totalCPU: %s, childCpuTime: %s, diff: %s%n", totalCPU.toNanos(), childCpuTime.toNanos(), childCpuTime.toNanos() - totalCPU.toNanos()); - Assert.assertTrue(checkEpsilon(childCpuTime, totalCPU, epsilon), + Assertions.assertTrue(checkEpsilon(childCpuTime, totalCPU, epsilon), childCpuTime + " should be within " + epsilon + " of " + totalCPU); } - Assert.assertTrue(totalCPU.toNanos() > 0L, + Assertions.assertTrue(totalCPU.toNanos() > 0L, "total cpu time expected > 0ms, actual: " + totalCPU); long t = Utils.adjustTimeout(10L); // Adjusted timeout seconds - Assert.assertTrue(totalCPU.toNanos() < lastCpu.toNanos() + t * 1_000_000_000L, + Assertions.assertTrue(totalCPU.toNanos() < lastCpu.toNanos() + t * 1_000_000_000L, "total cpu time expected < " + t + " seconds more than previous iteration, actual: " + (totalCPU.toNanos() - lastCpu.toNanos())); @@ -258,18 +247,18 @@ public class InfoTest { if (info.startInstant().isPresent()) { Instant startTime = info.startInstant().get(); - Assert.assertTrue(startTime.isBefore(afterStart), + Assertions.assertTrue(startTime.isBefore(afterStart), "startTime after process spawn completed" + startTime + " + > " + afterStart); } } } p1.sendAction("exit"); - Assert.assertTrue(p1.waitFor(Utils.adjustTimeout(30L), TimeUnit.SECONDS), + Assertions.assertTrue(p1.waitFor(Utils.adjustTimeout(30L), TimeUnit.SECONDS), "timeout waiting for process to terminate"); } catch (IOException | InterruptedException ie) { ie.printStackTrace(System.out); - Assert.fail("unexpected exception", ie); + Assertions.fail("unexpected exception", ie); } finally { // Destroy any children that still exist ProcessUtil.destroyProcessTree(ProcessHandle.current()); @@ -280,7 +269,7 @@ public class InfoTest { * Spawn a child with arguments and check they are visible via the ProcessHandle. */ @Test - public static void test3() { + public void test3() { try { for (long sleepTime : Arrays.asList(Utils.adjustTimeout(30), Utils.adjustTimeout(32))) { Process p = spawn("sleep", String.valueOf(sleepTime)); @@ -302,22 +291,22 @@ public class InfoTest { Path executable = Files.readSymbolicLink(Paths.get("/bin/sleep")); expected = executable.getFileName().toString(); } - Assert.assertTrue(command.endsWith(expected), "Command: expected: \'" + + Assertions.assertTrue(command.endsWith(expected), "Command: expected: \'" + expected + "\', actual: " + command); // Verify the command exists and is executable File exe = new File(command); - Assert.assertTrue(exe.exists(), "command must exist: " + exe); - Assert.assertTrue(exe.canExecute(), "command must be executable: " + exe); + Assertions.assertTrue(exe.exists(), "command must exist: " + exe); + Assertions.assertTrue(exe.canExecute(), "command must be executable: " + exe); } if (info.arguments().isPresent()) { String[] args = info.arguments().get(); if (args.length > 0) { - Assert.assertEquals(args[0], String.valueOf(sleepTime)); + Assertions.assertEquals(String.valueOf(sleepTime), args[0]); } } p.destroy(); - Assert.assertTrue(p.waitFor(Utils.adjustTimeout(30), TimeUnit.SECONDS), + Assertions.assertTrue(p.waitFor(Utils.adjustTimeout(30), TimeUnit.SECONDS), "timeout waiting for process to terminate"); } } catch (IOException | InterruptedException ex) { @@ -332,7 +321,7 @@ public class InfoTest { * Cross check the cputime reported from java.management with that for the current process. */ @Test - public static void test4() { + public void test4() { Duration myCputime1 = ProcessUtil.MXBeanCpuTime(); if (Platform.isAix()) { @@ -367,26 +356,26 @@ public class InfoTest { Objects.toString(total2), myCputime2, myCputime2.minus(total2)); Duration epsilon = Duration.ofMillis(200L); // Epsilon is 200ms. - Assert.assertTrue(checkEpsilon(myCputime1, myCputime2, epsilon), + Assertions.assertTrue(checkEpsilon(myCputime1, myCputime2, epsilon), myCputime1.toNanos() + " should be within " + epsilon + " of " + myCputime2.toNanos()); - Assert.assertTrue(checkEpsilon(total1, total2, epsilon), + Assertions.assertTrue(checkEpsilon(total1, total2, epsilon), total1.toNanos() + " should be within " + epsilon + " of " + total2.toNanos()); - Assert.assertTrue(checkEpsilon(myCputime1, total1, epsilon), + Assertions.assertTrue(checkEpsilon(myCputime1, total1, epsilon), myCputime1.toNanos() + " should be within " + epsilon + " of " + total1.toNanos()); - Assert.assertTrue(checkEpsilon(total1, myCputime2, epsilon), + Assertions.assertTrue(checkEpsilon(total1, myCputime2, epsilon), total1.toNanos() + " should be within " + epsilon + " of " + myCputime2.toNanos()); - Assert.assertTrue(checkEpsilon(myCputime2, total2, epsilon), + Assertions.assertTrue(checkEpsilon(myCputime2, total2, epsilon), myCputime2.toNanos() + " should be within " + epsilon + " of " + total2.toNanos()); } } @Test - public static void test5() { + public void test5() { ProcessHandle self = ProcessHandle.current(); Random r = new Random(); for (int i = 0; i < 30; i++) { @@ -458,13 +447,12 @@ public class InfoTest { return; } String user = info.user().get(); - Assert.assertNotNull(user, "User name"); + Assertions.assertNotNull(user, "User name"); if (Platform.isWindows() && "BUILTIN\\Administrators".equals(whoami)) { int bsi = user.lastIndexOf("\\"); - Assert.assertEquals(bsi == -1 ? user : user.substring(bsi + 1), - System.getProperty("user.name"), "User name"); + Assertions.assertEquals(System.getProperty("user.name"), bsi == -1 ? user : user.substring(bsi + 1), "User name"); } else { - Assert.assertEquals(user, whoami, "User name"); + Assertions.assertEquals(whoami, user, "User name"); } } } diff --git a/test/jdk/java/lang/ProcessHandle/OnExitTest.java b/test/jdk/java/lang/ProcessHandle/OnExitTest.java index 79c696efdfc..45c2b51e398 100644 --- a/test/jdk/java/lang/ProcessHandle/OnExitTest.java +++ b/test/jdk/java/lang/ProcessHandle/OnExitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,37 +35,27 @@ import java.util.concurrent.TimeUnit; import jdk.test.lib.Platform; import jdk.test.lib.Utils; -import org.testng.annotations.Test; -import org.testng.Assert; -import org.testng.TestNG; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /* * @test + * @summary Functions of Process.onExit and ProcessHandle.onExit * @bug 8333742 * @requires vm.flagless * @library /test/lib * @modules jdk.management * @build jdk.test.lib.Utils - * @run testng OnExitTest - * @summary Functions of Process.onExit and ProcessHandle.onExit - * @author Roger Riggs + * @run junit OnExitTest */ public class OnExitTest extends ProcessUtil { - @SuppressWarnings("raw_types") - public static void main(String[] args) { - Class[] testclass = { OnExitTest.class}; - TestNG testng = new TestNG(); - testng.setTestClasses(testclass); - testng.run(); - } - /** * Basic test of exitValue and onExit. */ @Test - public static void test1() { + public void test1() { try { int[] exitValues = {0, 1, 10, 259}; for (int value : exitValues) { @@ -73,24 +63,24 @@ public class OnExitTest extends ProcessUtil { if (value == 259 && !Platform.isWindows()) continue; Process p = JavaChild.spawn("exit", Integer.toString(value)); CompletableFuture future = p.onExit(); - future.thenAccept( (ph) -> { + future.thenAccept((ph) -> { int actualExitValue = ph.exitValue(); printf(" javaChild done: %s, exitStatus: %d%n", ph, actualExitValue); - Assert.assertEquals(actualExitValue, value, "actualExitValue incorrect"); - Assert.assertEquals(ph, p, "Different Process passed to thenAccept"); + Assertions.assertEquals(value, actualExitValue, "actualExitValue incorrect"); + Assertions.assertEquals(p, ph, "Different Process passed to thenAccept"); }); Process h = future.get(); - Assert.assertEquals(h, p); - Assert.assertEquals(p.exitValue(), value); - Assert.assertFalse(p.isAlive(), "Process should not be alive"); - Assert.assertEquals(p.waitFor(), value); - Assert.assertTrue(p.waitFor(1, TimeUnit.MILLISECONDS), + Assertions.assertEquals(p, h); + Assertions.assertEquals(value, p.exitValue()); + Assertions.assertFalse(p.isAlive(), "Process should not be alive"); + Assertions.assertEquals(value, p.waitFor()); + Assertions.assertTrue(p.waitFor(1, TimeUnit.MILLISECONDS), "waitFor should return true"); } } catch (IOException | InterruptedException | ExecutionException ex) { - Assert.fail(ex.getMessage(), ex); + Assertions.fail(ex.getMessage(), ex); } finally { destroyProcessTree(ProcessHandle.current()); } @@ -101,7 +91,7 @@ public class OnExitTest extends ProcessUtil { * Spawn 1 child to spawn 3 children each with 2 children. */ @Test - public static void test2() { + public void test2() { // Please note (JDK-8284282): // @@ -176,7 +166,7 @@ public class OnExitTest extends ProcessUtil { // Check that each of the spawned processes is included in the children List remaining = new ArrayList<>(children); processes.forEach((p, parent) -> { - Assert.assertTrue(remaining.remove(p), "spawned process should have been in children"); + Assertions.assertTrue(remaining.remove(p), "spawned process should have been in children"); }); // Remove Win32 system spawned conhost.exe processes @@ -204,7 +194,7 @@ public class OnExitTest extends ProcessUtil { // Verify that all 9 exit handlers were called with the correct ProcessHandle processes.forEach((p, parent) -> { ProcessHandle value = completions.get(p).getNow(null); - Assert.assertEquals(p, value, "onExit.get value expected: " + p + Assertions.assertEquals(value, p, "onExit.get value expected: " + p + ", actual: " + value + ": " + p.info()); }); @@ -212,9 +202,9 @@ public class OnExitTest extends ProcessUtil { // Show the status of the original children children.forEach(p -> printProcess(p, "after onExit:")); - Assert.assertEquals(proc.isAlive(), false, "destroyed process is alive:: %s%n" + proc); + Assertions.assertFalse(proc.isAlive(), "destroyed process is alive:: %s%n" + proc); } catch (IOException | InterruptedException ex) { - Assert.fail(ex.getMessage()); + Assertions.fail(ex.getMessage(), ex); } finally { if (procHandle != null) { destroyProcessTree(procHandle); @@ -231,7 +221,7 @@ public class OnExitTest extends ProcessUtil { * Check that (B) does not complete until (A) has exited. */ @Test - public static void peerOnExitTest() { + public void peerOnExitTest() { String line = null; ArrayBlockingQueue alines = new ArrayBlockingQueue<>(100); ArrayBlockingQueue blines = new ArrayBlockingQueue<>(100); @@ -265,9 +255,9 @@ public class OnExitTest extends ProcessUtil { try { line = blines.poll(5L, TimeUnit.SECONDS); } catch (InterruptedException ie) { - Assert.fail("interrupted", ie); + Assertions.fail("interrupted", ie); } - Assert.assertNull(line, "waitpid didn't wait"); + Assertions.assertNull(line, "waitpid didn't wait"); A.toHandle().onExit().thenAccept(p -> { System.out.printf(" A.toHandle().onExit().A info: %s, now: %s%n", @@ -296,16 +286,16 @@ public class OnExitTest extends ProcessUtil { split = getSplitLine(blines); } while (!"waitpid".equals(split[1])); - Assert.assertEquals(split[2], "false", "Process A should not be alive"); + Assertions.assertEquals("false", split[2], "Process A should not be alive"); B.sendAction("exit", 0L); } catch (IOException ioe) { - Assert.fail("unable to start JavaChild B", ioe); + Assertions.fail("unable to start JavaChild B", ioe); } finally { B.destroyForcibly(); } } catch (IOException ioe2) { - Assert.fail("unable to start JavaChild A", ioe2); + Assertions.fail("unable to start JavaChild A", ioe2); } finally { A.destroyForcibly(); } @@ -328,7 +318,7 @@ public class OnExitTest extends ProcessUtil { } return split; } catch (InterruptedException ie) { - Assert.fail("interrupted", ie); + Assertions.fail("interrupted", ie); return null; } } diff --git a/test/jdk/java/lang/ProcessHandle/TreeTest.java b/test/jdk/java/lang/ProcessHandle/TreeTest.java index cec880f1fef..567cfea2895 100644 --- a/test/jdk/java/lang/ProcessHandle/TreeTest.java +++ b/test/jdk/java/lang/ProcessHandle/TreeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -38,12 +38,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.test.lib.Utils; -import org.testng.Assert; -import org.testng.TestNG; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /* * @test + * @summary Test counting and JavaChild.spawning and counting of Processes. * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc @@ -54,25 +54,15 @@ import org.testng.annotations.Test; * jdk.test.lib.JDKToolLauncher * jdk.test.lib.Platform * jdk.test.lib.process.* - * @run testng/othervm TreeTest - * @summary Test counting and JavaChild.spawning and counting of Processes. + * @run junit/othervm TreeTest * @author Roger Riggs */ public class TreeTest extends ProcessUtil { - // Main can be used to run the tests from the command line with only testng.jar. - @SuppressWarnings("raw_types") - public static void main(String[] args) { - Class[] testclass = {TreeTest.class}; - TestNG testng = new TestNG(); - testng.setTestClasses(testclass); - testng.run(); - } - /** * Test counting and spawning and counting of Processes. */ @Test - public static void test1() { + public void test1() { final int MAXCHILDREN = 2; List spawned = new ArrayList<>(); @@ -92,14 +82,14 @@ public class TreeTest extends ProcessUtil { spawned.stream() .map(Process::toHandle) .filter(p -> !initialChildren.contains(p)) - .forEach(p -> Assert.fail("Spawned process missing from children: " + p)); + .forEach(p -> Assertions.fail("Spawned process missing from children: " + p)); // Send exit command to each spawned Process spawned.forEach(p -> { try { p.sendAction("exit", ""); } catch (IOException ex) { - Assert.fail("IOException in sendAction", ex); + Assertions.fail("IOException in sendAction", ex); } }); @@ -107,7 +97,7 @@ public class TreeTest extends ProcessUtil { spawned.forEach(p -> { do { try { - Assert.assertEquals(p.waitFor(), 0, "exit status incorrect"); + Assertions.assertEquals(0, p.waitFor(), "exit status incorrect"); break; } catch (InterruptedException ex) { continue; // Retry @@ -118,7 +108,7 @@ public class TreeTest extends ProcessUtil { // Verify that ProcessHandle.isAlive sees each of them as not alive for (Process p : spawned) { ProcessHandle ph = p.toHandle(); - Assert.assertFalse(ph.isAlive(), + Assertions.assertFalse(ph.isAlive(), "ProcessHandle.isAlive for exited process: " + ph); } @@ -126,13 +116,13 @@ public class TreeTest extends ProcessUtil { final List afterChildren = getChildren(self); spawned.stream() .map(Process::toHandle) - .filter(p -> afterChildren.contains(p)) - .forEach(p -> Assert.fail("Spawned process missing from children: " + p)); + .filter(afterChildren::contains) + .forEach(p -> Assertions.fail("Spawned process missing from children: " + p)); } catch (IOException ioe) { - Assert.fail("unable to spawn process", ioe); + Assertions.fail("unable to spawn process", ioe); } finally { - // Cleanup any left over processes + // Cleanup any leftover processes spawned.stream() .map(Process::toHandle) .filter(ProcessHandle::isAlive) @@ -147,7 +137,7 @@ public class TreeTest extends ProcessUtil { * Test counting and spawning and counting of Processes. */ @Test - public static void test2() { + public void test2() { try { ConcurrentHashMap processes = new ConcurrentHashMap<>(); @@ -162,12 +152,12 @@ public class TreeTest extends ProcessUtil { ProcessHandle p1Handle = p1.toHandle(); printf(" p1 pid: %d%n", p1.pid()); - // Gather the PIDs from the output of the spawing process + // Gather the PIDs from the output of the spawning process p1.forEachOutputLine((s) -> { String[] split = s.trim().split(" "); if (split.length == 3 && split[1].equals("spawn")) { - Long child = Long.valueOf(split[2]); - Long parent = Long.valueOf(split[0].split(":")[0]); + long child = Long.parseLong(split[2]); + long parent = Long.parseLong(split[0].split(":")[0]); processes.put(ProcessHandle.of(child).get(), ProcessHandle.of(parent).get()); } }); @@ -179,11 +169,11 @@ public class TreeTest extends ProcessUtil { List subprocesses = waitForAllChildren(p1Handle, spawnNew); Optional p1Start = p1Handle.info().startInstant(); for (ProcessHandle ph : subprocesses) { - Assert.assertTrue(ph.isAlive(), "Child should be alive: " + ph); + Assertions.assertTrue(ph.isAlive(), "Child should be alive: " + ph); // Verify each child was started after the parent ph.info().startInstant() .ifPresent(childStart -> p1Start.ifPresent(parentStart -> { - Assert.assertFalse(childStart.isBefore(parentStart), + Assertions.assertFalse(childStart.isBefore(parentStart), String.format("Child process started before parent: child: %s, parent: %s", childStart, parentStart)); })); @@ -217,8 +207,8 @@ public class TreeTest extends ProcessUtil { // Verify that all spawned children show up in the descendants List processes.forEach((p, parent) -> { - Assert.assertEquals(p.isAlive(), true, "Child should be alive: " + p); - Assert.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); + Assertions.assertTrue(p.isAlive(), "Child should be alive: " + p); + Assertions.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); }); // Closing JavaChild's InputStream will cause all children to exit @@ -228,13 +218,13 @@ public class TreeTest extends ProcessUtil { try { p.onExit().get(); // wait for the child to exit } catch (ExecutionException e) { - Assert.fail("waiting for process to exit", e); + Assertions.fail("waiting for process to exit", e); } } p1.waitFor(); // wait for spawned process to exit // Verify spawned processes are no longer alive - processes.forEach((ph, parent) -> Assert.assertFalse(ph.isAlive(), + processes.forEach((ph, parent) -> Assertions.assertFalse(ph.isAlive(), "process should not be alive: " + ph)); } catch (IOException | InterruptedException t) { t.printStackTrace(); @@ -250,7 +240,7 @@ public class TreeTest extends ProcessUtil { * After they exit they should no longer be listed by descendants. */ @Test - public static void test3() { + public void test3() { ConcurrentHashMap processes = new ConcurrentHashMap<>(); try { @@ -269,15 +259,15 @@ public class TreeTest extends ProcessUtil { p1.forEachOutputLine((s) -> { String[] split = s.trim().split(" "); if (split.length == 3 && split[1].equals("spawn")) { - Long child = Long.valueOf(split[2]); - Long parent = Long.valueOf(split[0].split(":")[0]); + long child = Long.parseLong(split[2]); + long parent = Long.parseLong(split[0].split(":")[0]); processes.put(ProcessHandle.of(child).get(), ProcessHandle.of(parent).get()); spawnCount.countDown(); } }); // Wait for all the subprocesses to be listed as started - Assert.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), + Assertions.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), "Timeout waiting for processes to start"); // Debugging; list descendants that are not expected in processes @@ -290,17 +280,17 @@ public class TreeTest extends ProcessUtil { .filter(ph -> !processes.containsKey(ph)) .forEach(ph1 -> ProcessUtil.printProcess(ph1, "Extra process: ")); ProcessUtil.logTaskList(); - Assert.assertEquals(0, count, "Extra processes in descendants"); + Assertions.assertEquals(0, count, "Extra processes in descendants"); } // Verify that all spawned children are alive, show up in the descendants list // then destroy them processes.forEach((p, parent) -> { - Assert.assertEquals(p.isAlive(), true, "Child should be alive: " + p); - Assert.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); + Assertions.assertTrue(p.isAlive(), "Child should be alive: " + p); + Assertions.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); p.destroyForcibly(); }); - Assert.assertEquals(processes.size(), newChildren, "Wrong number of children"); + Assertions.assertEquals(newChildren, processes.size(), "Wrong number of children"); // Wait for each of the processes to exit processes.forEach((p, parent) -> { @@ -317,21 +307,21 @@ public class TreeTest extends ProcessUtil { } printf("Timeout waiting for exit of pid %s, parent: %s, info: %s%n", p, parent, p.info()); - Assert.fail("Process still alive: " + p); + Assertions.fail("Process still alive: " + p); }); p1.destroyForcibly(); p1.waitFor(); // Verify that none of the spawned children are still listed by descendants List remaining = getDescendants(self); - Assert.assertFalse(remaining.remove(p1Handle), "Child p1 should have exited"); + Assertions.assertFalse(remaining.remove(p1Handle), "Child p1 should have exited"); remaining = remaining.stream().filter(processes::containsKey).collect(Collectors.toList()); - Assert.assertEquals(remaining.size(), 0, "Subprocess(es) should have exited: " + remaining); + Assertions.assertEquals(0, remaining.size(), "Subprocess(es) should have exited: " + remaining); } catch (IOException ioe) { - Assert.fail("Spawn of subprocess failed", ioe); + Assertions.fail("Spawn of subprocess failed", ioe); } catch (InterruptedException inte) { - Assert.fail("InterruptedException", inte); + Assertions.fail("InterruptedException", inte); } finally { processes.forEach((p, parent) -> { if (p.isAlive()) { @@ -346,7 +336,7 @@ public class TreeTest extends ProcessUtil { * Test (Not really a test) that dumps the list of all Processes. */ @Test - public static void test4() { + public void test4() { printf(" Parent Child Info%n"); Stream s = ProcessHandle.allProcesses(); ProcessHandle[] processes = s.toArray(ProcessHandle[]::new); @@ -384,7 +374,7 @@ public class TreeTest extends ProcessUtil { } printf("%s %7s, %7s, %s%n", indent, p_parent, p, info); } - Assert.assertFalse(fail, "Parents missing from all Processes"); + Assertions.assertFalse(fail, "Parents missing from all Processes"); } @@ -392,7 +382,7 @@ public class TreeTest extends ProcessUtil { * A test for scale; launch a large number (14) of subprocesses. */ @Test - public static void test5() { + public void test5() { ConcurrentHashMap processes = new ConcurrentHashMap<>(); int factor = 2; @@ -421,15 +411,15 @@ public class TreeTest extends ProcessUtil { p1.forEachOutputLine((s) -> { String[] split = s.trim().split(" "); if (split.length == 3 && split[1].equals("spawn")) { - Long child = Long.valueOf(split[2]); - Long parent = Long.valueOf(split[0].split(":")[0]); + long child = Long.parseLong(split[2]); + long parent = Long.parseLong(split[0].split(":")[0]); processes.put(ProcessHandle.of(child).get(), ProcessHandle.of(parent).get()); spawnCount.countDown(); } }); // Wait for all the subprocesses to be listed as started - Assert.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), + Assertions.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), "Timeout waiting for processes to start"); // Debugging; list descendants that are not expected in processes @@ -442,30 +432,29 @@ public class TreeTest extends ProcessUtil { .filter(ph -> !processes.containsKey(ph)) .forEach(ph1 -> ProcessUtil.printProcess(ph1, "Extra process: ")); ProcessUtil.logTaskList(); - Assert.assertEquals(0, count, "Extra processes in descendants"); + Assertions.assertEquals(0, count, "Extra processes in descendants"); } List subprocesses = getChildren(p1Handle); printf(" children: %s%n", - subprocesses.stream().map(p -> p.pid()) + subprocesses.stream().map(ProcessHandle::pid) .collect(Collectors.toList())); - Assert.assertEquals(getChildren(p1Handle).size(), - factor, "expected direct children"); + Assertions.assertEquals(factor, getChildren(p1Handle).size(), "expected direct children"); count = getDescendants(p1Handle).size(); long totalChildren = factor * factor * factor + factor * factor + factor; - Assert.assertTrue(count >= totalChildren, + Assertions.assertTrue(count >= totalChildren, "expected at least " + totalChildren + ", actual: " + count); List descSubprocesses = getDescendants(p1Handle); printf(" descendants: %s%n", - descSubprocesses.stream().map(p -> p.pid()) + descSubprocesses.stream().map(ProcessHandle::pid) .collect(Collectors.toList())); p1.getOutputStream().close(); // Close stdin for the controlling p1 p1.waitFor(); } catch (InterruptedException | IOException ex) { - Assert.fail("Unexpected Exception", ex); + Assertions.fail("Unexpected Exception", ex); } finally { printf("Duration: %s%n", Duration.between(start, Instant.now())); if (p1 != null) { diff --git a/test/jdk/java/lang/StrictMath/ExhaustingTests.java b/test/jdk/java/lang/StrictMath/ExhaustingTests.java index 143227c4cc3..23b55a50bee 100644 --- a/test/jdk/java/lang/StrictMath/ExhaustingTests.java +++ b/test/jdk/java/lang/StrictMath/ExhaustingTests.java @@ -93,6 +93,8 @@ public class ExhaustingTests { new UnaryTestCase("atan", FdlibmTranslit::atan, StrictMath::atan, DEFAULT_SHIFT), new UnaryTestCase("asinh", FdlibmTranslit::asinh, StrictMath::asinh, DEFAULT_SHIFT), + new UnaryTestCase("acosh", FdlibmTranslit::acosh, StrictMath::acosh, DEFAULT_SHIFT), + new UnaryTestCase("atanh", FdlibmTranslit::atanh, StrictMath::atanh, DEFAULT_SHIFT), }; for (var testCase : testCases) { diff --git a/test/jdk/java/lang/StrictMath/FdlibmTranslit.java b/test/jdk/java/lang/StrictMath/FdlibmTranslit.java index 3001fed911f..ffa18676c90 100644 --- a/test/jdk/java/lang/StrictMath/FdlibmTranslit.java +++ b/test/jdk/java/lang/StrictMath/FdlibmTranslit.java @@ -144,6 +144,14 @@ public class FdlibmTranslit { return Asinh.compute(x); } + public static double acosh(double x) { + return Acosh.compute(x); + } + + public static double atanh(double x) { + return Atanh.compute(x); + } + public static double IEEEremainder(double f1, double f2) { return IEEEremainder.compute(f1, f2); } @@ -2796,4 +2804,91 @@ public class FdlibmTranslit { if(hx>0) return w; else return -w; } } + + /* + * Return the Inverse Hyperbolic Cosine of x + * + * Method : + * Based on + * acosh(x) = log [ x + sqrt(x*x-1) ] + * we have + * acosh(x) := log(x)+ln2, if x is large; else + * := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else + * := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. + * + * Special cases: + * acosh(x) is NaN with signal if x<1. + * acosh(NaN) is NaN without signal. + */ + private static final class Acosh { + private static final double one = 1.0; + private static final double ln2 = 6.93147180559945286227e-01; + static double compute(double x) { + double t; + int hx; + hx = __HI(x); + if(hx<0x3ff00000) { /* x < 1 */ + return (x-x)/(x-x); + } else if(hx >=0x41b00000) { /* x > 2**28 */ + if(hx >=0x7ff00000) { /* x is inf of NaN */ + return x+x; + } else + return log(x)+ln2; /* acosh(huge)=log(2x) */ + } else if(((hx-0x3ff00000)|__LO(x))==0) { + return 0.0; /* acosh(1) = 0 */ + } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ + t=x*x; + return log(2.0*x-one/(x+sqrt(t-one))); + } else { /* 1=0.5 + * 1 2x x + * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) + * 2 1 - x 1 - x + * + * For x<0.5 + * atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) + * + * Special cases: + * atanh(x) is NaN if |x| > 1 with signal; + * atanh(NaN) is that NaN with no signal; + * atanh(+-1) is +-INF with signal. + * + */ + private static final class Atanh { + private static final double zero = 0.0; + private static final double one = 1.0; + private static final double huge = 1.0e300; + + static double compute(double x) { + double t; + int hx,ix; + /*unsigned*/ int lx; + hx = __HI(x); /* high word */ + lx = __LO(x); /* low word */ + ix = hx&0x7fffffff; + if ((ix|((lx|(-lx))>>>31))>0x3ff00000) /* |x|>1 */ + return (x-x)/(x-x); + if(ix==0x3ff00000) + return x/zero; + if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */ + x = __HI(x, ix); /* x <- |x| */ + if(ix<0x3fe00000) { /* x < 0.5 */ + t = x+x; + t = 0.5*log1p(t+t*x/(one-x)); + } else + t = 0.5*log1p((x+x)/(one-x)); + if(hx>=0) return t; else return -t; + } + } } diff --git a/test/jdk/java/lang/StrictMath/HyperbolicTests.java b/test/jdk/java/lang/StrictMath/HyperbolicTests.java index 6dbf3cd90ee..9eaed0a081a 100644 --- a/test/jdk/java/lang/StrictMath/HyperbolicTests.java +++ b/test/jdk/java/lang/StrictMath/HyperbolicTests.java @@ -34,7 +34,7 @@ import java.util.function.DoubleUnaryOperator; * @build FdlibmTranslit * @build HyperbolicTests * @run main HyperbolicTests - * @summary Tests for StrictMath.{sinh, cosh, tanh, asinh} + * @summary Tests for StrictMath.{sinh, cosh, tanh, asinh, acosh, atanh} */ /** @@ -60,11 +60,14 @@ public class HyperbolicTests { failures += testAgainstTranslitSinh(); failures += testAgainstTranslitCosh(); failures += testAgainstTranslitTanh(); + failures += testAgainstTranslitAtanh(); failures += testSinh(); failures += testCosh(); failures += testTanh(); failures += testAsinh(); + failures += testAcosh(); + failures += testAtanh(); if (failures > 0) { System.err.println("Testing the hyperbolics incurred " @@ -80,7 +83,9 @@ public class HyperbolicTests { SINH(HyperbolicTests::testSinhCase, FdlibmTranslit::sinh), COSH(HyperbolicTests::testCoshCase, FdlibmTranslit::cosh), TANH(HyperbolicTests::testTanhCase, FdlibmTranslit::tanh), - ASINH(HyperbolicTests::testAsinhCase, FdlibmTranslit::asinh); + ASINH(HyperbolicTests::testAsinhCase, FdlibmTranslit::asinh), + ACOSH(HyperbolicTests::testAcoshCase, FdlibmTranslit::acosh), + ATANH(HyperbolicTests::testAtanhCase, FdlibmTranslit::atanh); private DoubleDoubleToInt testCase; private DoubleUnaryOperator transliteration; @@ -214,6 +219,31 @@ public class HyperbolicTests { return failures; } + /** + * Test StrictMath.tanh against transliteration port of tanh + */ + private static int testAgainstTranslitAtanh() { + int failures = 0; + double x; + + // Probe near decision points in the FDLIBM algorithm. + double[] decisionPoints = { + 0.0, + + 0x1.0p-28, + -0x1.0p-28, + + 1.0, + -1.0, + }; + + for (double testPoint : decisionPoints) { + failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000, HyperbolicTest.ATANH); + } + + return failures; + } + private interface DoubleDoubleToInt { int apply(double x, double y); } @@ -260,6 +290,16 @@ public class HyperbolicTests { StrictMath::asinh, expected); } + private static int testAcoshCase(double input, double expected) { + return Tests.test("StrictMath.asinh(double)", input, + StrictMath::acosh, expected); + } + + private static int testAtanhCase(double input, double expected) { + return Tests.test("StrictMath.atanh(double)", input, + StrictMath::atanh, expected); + } + private static int testSinh() { int failures = 0; double [][] testCases = { @@ -555,6 +595,13 @@ public class HyperbolicTests { {0x1.fffffffffff92p+1, 0x1.0c1f8a6e80edp+1}, {0x1.0108b83c4bbc8p-1, 0x1.ee9c256f3947ep-2}, {-0x1.c41e527b70f43p-3, -0x1.c0863c7dece22p-3}, + + // Julia worst case + {-0x1.02657ff36d5f3p-2, -0x1.ff75bb69b0bf6p-3}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {0x1.0ab3fc30267c2p-1, 0x1.ffd39fc024fbp-2}, }; for (double[] testCase: testCases) { @@ -563,4 +610,135 @@ public class HyperbolicTests { return failures; } + + private static int testAcosh() { + int failures = 0; + double [][] testCases = { + {0x1.00020000aaaabp+0, 0x1.fffffffff749fp-8}, + {0x1.000346de27853p+0, 0x1.47ae147ae274p-7}, + {0x1.0008000aaab05p+0, 0x1.fffffffffe9f1p-7}, + {0x1.0008000aaab05p+0, 0x1.fffffffffe9f1p-7}, + {0x1.002000aaac169p+0, 0x1.fffffffffe67bp-6}, + {0x1.002000aaac16bp+0, 0x1.ffffffffff679p-6}, + {0x1.00800aab05b1ep+0, 0x1.ffffffffffc9cp-5}, + {0x1.00800aab05b1fp+0, 0x1.ffffffffffe9bp-5}, + {0x1.0147f40224b2ep+0, 0x1.9999999999318p-4}, + {0x1.0147f40224b35p+0, 0x1.9999999999776p-4}, + {0x1.0200aac16db6cp+0, 0x1.ffffffffffe91p-4}, + {0x1.0200aac16db6ep+0, 0x1.fffffffffff91p-4}, + {0x1.080ab05ca613bp+0, 0x1.ffffffffffea5p-3}, + {0x1.080ab05ca6146p+0, 0x1.0000000000001p-2}, + {0x1.20ac1862ae8cep+0, 0x1.fffffffffffedp-2}, + {0x1.20ac1862ae8dp+0, 0x1.ffffffffffffdp-2}, + {0x1.8b07551d9f551p+0, 0x1p+0}, + {0x1.e18fa0df2d9b3p+1, 0x1.ffffffffffffbp+0}, + {0x1.e18fa0df2d9b8p+1, 0x1.ffffffffffffep+0}, + {0x1.e18fa0df2d9bap+1, 0x1.fffffffffffffp+0}, + {0x1.b4ee858de3e68p+4, 0x1.ffffffffffff9p+1}, + {0x1.b4ee858de3e7ap+4, 0x1.ffffffffffffep+1}, + {0x1.b4ee858de3e7dp+4, 0x1.fffffffffffffp+1}, + {0x1.749eaa93f4e5ep+10, 0x1.ffffffffffffcp+2}, + {0x1.749eaa93f4e64p+10, 0x1.ffffffffffffdp+2}, + {0x1.749eaa93f4e76p+10, 0x1p+3}, + {0x1.0f2ebd0a7fb9p+22, 0x1.fffffffffff6fp+3}, + {0x1.0f2ebd0a8005cp+22, 0x1p+4}, + {0x1.1f43fcc4b6316p+45, 0x1.fffffffffffd3p+4}, + {0x1.1f43fcc4b662cp+45, 0x1.fffffffffffffp+4}, + {0x1.fdf25fc26e7cp+1023, 0x1.633c654fee2bap+9}, + {0x1.fdf25fc26e7cp+1023, 0x1.633c654fee2bap+9}, + {0x1.e0976c8f0ebdfp+1, 0x1.ff76fb3f476d5p+0}, + {0x1.ff66e0de4dc6fp+1023, 0x1.633cc2ae1c934p+9}, + {0x1.f97ccb0aef314p+11, 0x1.1ff088806d82ep+3}, + {0x1.fdf28623ef923p+1021, 0x1.628af341989dap+9}, + + // Julia worst case + {0x1.0001ff6afc4bap+0, 0x1.ffb5238940116p-8}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {0x1.0007fd4307b75p+0, 0x1.ffa704d280935p-7}, + {0x1.071334daf83adp+0, 0x1.e063ca7176ffdp-3}, + {0x1.1d7bc19163966p+0, 0x1.e6db4d68a00dcp-2}, + }; + + for (double[] testCase: testCases) { + failures += testAcoshCase(testCase[0], testCase[1]); + } + + return failures; + } + + private static int testAtanh() { + int failures = 0; + double [][] testCases = { + {0x1.5798ee2308c36p-27, 0x1.5798ee2308c37p-27}, + {0x1.ffffffffffffep-26, 0x1p-25}, + {0x1.ffffffffffffep-25, 0x1.0000000000004p-24}, + {0x1.ad7f29abcaf47p-24, 0x1.ad7f29abcaf6p-24}, + {0x1.ad7f29abcaf48p-24, 0x1.ad7f29abcaf61p-24}, + {0x1.ffffffffffffep-24, 0x1.0000000000014p-23}, + {0x1.ffffffffffffep-23, 0x1.0000000000054p-22}, + {0x1.ffffffffffffep-22, 0x1.0000000000154p-21}, + {0x1.ffffffffffffep-21, 0x1.0000000000554p-20}, + {0x1.0c6f7a0b5ed8dp-20, 0x1.0c6f7a0b5f3b3p-20}, + {0x1.ffffffffffffep-20, 0x1.0000000001554p-19}, + {0x1.ffffffffffffep-19, 0x1.0000000005554p-18}, + {0x1.fffffffffffffp-18, 0x1.0000000015555p-17}, + {0x1p-17, 0x1.0000000015555p-17}, + {0x1.4f8b588e368edp-17, 0x1.4f8b588e6698bp-17}, + {0x1.fffffffffffffp-17, 0x1.0000000055555p-16}, + {0x1.fffffffffffffp-16, 0x1.0000000155555p-15}, + {0x1p-15, 0x1.0000000155555p-15}, + {0x1.fffffffffe5ddp-15, 0x1.0000000554844p-14}, + {0x1.fffffffffffffp-15, 0x1.0000000555555p-14}, + {0x1.a36e2eb1c432dp-14, 0x1.a36e2ec938ff8p-14}, + {0x1.ffffffffffffep-14, 0x1.0000001555555p-13}, + {0x1p-13, 0x1.0000001555556p-13}, + {0x1.ffffffffffd51p-13, 0x1.0000005555401p-12}, + {0x1.fffffffffffffp-13, 0x1.0000005555559p-12}, + {0x1.ffffffffffffep-12, 0x1.0000015555587p-11}, + {0x1p-11, 0x1.0000015555588p-11}, + {0x1.fffffffffff1p-11, 0x1.0000055555811p-10}, + {0x1p-10, 0x1.0000055555889p-10}, + {0x1.0624dd2f1a9c6p-10, 0x1.0624e2e91ece1p-10}, + {0x1.0624dd2f1a9f8p-10, 0x1.0624e2e91ed13p-10}, + {0x1.fffffffffffddp-10, 0x1.0000155558877p-9}, + {0x1.fffffffffffffp-10, 0x1.0000155558888p-9}, + {0x1.ffffffffffffcp-9, 0x1.0000555588889p-8}, + {0x1.ffffffffffffep-9, 0x1.000055558888ap-8}, + {0x1.ffffffffffff8p-8, 0x1.0001555888917p-7}, + {0x1.ffffffffffffep-8, 0x1.000155588891ap-7}, + {0x1.47ae147ae1458p-7, 0x1.47b0e059d0574p-7}, + {0x1.47ae147ae1464p-7, 0x1.47b0e059d058p-7}, + {0x1.ffffffffffffep-7, 0x1.000555888ad1bp-6}, + {0x1.fffffffffffffp-7, 0x1.000555888ad1cp-6}, + {0x1.ffffffffffff9p-6, 0x1.001558891aedep-5}, + {0x1.ffffffffffffep-6, 0x1.001558891aee1p-5}, + {0x1.ffffffffffff9p-5, 0x1.005588ad375a9p-4}, + {0x1.fffffffffffffp-5, 0x1.005588ad375acp-4}, + {0x1.9999999999996p-4, 0x1.9af93cd23440ep-4}, + {0x1.9999999999997p-4, 0x1.9af93cd23440fp-4}, + {0x1.fffffffffffffp-4, 0x1.015891c9eaef7p-3}, + {0x1p-3, 0x1.015891c9eaef7p-3}, + {0x1.fffffffffffffp-3, 0x1.058aefa811451p-2}, + {0x1.ffffffffffffcp-2, 0x1.193ea7aad0308p-1}, + {0x1.ffffffffffffep-2, 0x1.193ea7aad0309p-1}, + {0x1.ffffffffffffbp-1, 0x1.1e9067763b478p+4}, + {0x1.ffffffffffffep-1, 0x1.25e4f7b2737fap+4}, + + // Julia worst case + {-0x1.f97fabc0650c4p-4, -0x1.fc16bb2fd3672p-4}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {0x1.ffd834a270fp-10, 0x1.ffd85f432fed2p-10}, + {-0x1.ffbe8dd88527fp-9, -0x1.ffbf38422c2dbp-9}, + {-0x1.e7c1f36602014p-4, -0x1.ea153d6c96817p-4}, + }; + + for (double[] testCase: testCases) + failures += testAtanhCase(testCase[0], testCase[1]); + + return failures; + } } diff --git a/test/jdk/java/lang/StrictMath/PowTests.java b/test/jdk/java/lang/StrictMath/PowTests.java index 4b68c5bdcd6..90482b264fe 100644 --- a/test/jdk/java/lang/StrictMath/PowTests.java +++ b/test/jdk/java/lang/StrictMath/PowTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,9 @@ /* * @test * @bug 8136874 8362376 + * @build Tests + * @build PowTests + * @run main PowTests * @summary Tests for StrictMath.pow */ diff --git a/test/jdk/java/lang/String/Encodings.java b/test/jdk/java/lang/String/Encodings.java index 4714815026e..7974157ede0 100644 --- a/test/jdk/java/lang/String/Encodings.java +++ b/test/jdk/java/lang/String/Encodings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 4085160 4139951 5005831 + * @bug 4085160 4139951 5005831 8372353 * @summary Test that required character encodings are supported */ @@ -106,6 +106,10 @@ public class Encodings { if (!equals(bs, bytes)) throw new Exception(charset + ": String.getBytes failed"); + /* String.encodedLength(Charset charset) */ + if (bs.length != str.encodedLength(charset)) + throw new Exception(charset + ": String.encodedLength failed"); + // Calls to String.getBytes(Charset) shouldn't automatically // use the cached thread-local encoder. if (charset.name().equals("UTF-16BE")) { diff --git a/test/jdk/java/lang/String/Exceptions.java b/test/jdk/java/lang/String/Exceptions.java index 3ba7792f424..15ffe3eac20 100644 --- a/test/jdk/java/lang/String/Exceptions.java +++ b/test/jdk/java/lang/String/Exceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,7 +23,7 @@ /** * @test - * @bug 4472841 4703640 4705681 4705683 4833095 5005831 + * @bug 4472841 4703640 4705681 4705683 4833095 5005831 8372353 * @summary Verify that constructor exceptions are thrown as expected. */ @@ -397,6 +397,14 @@ public class Exceptions { }}); } + private static void encodedLength() { + System.out.println("encodedLength(Charset charset)"); + tryCatch(" null", NullPointerException.class, new Runnable() { + public void run() { + "foo".encodedLength((Charset)null); + }}); + } + private static void contentEquals() { System.out.println("contentEquals(StringBuffer sb)"); tryCatch(" null", NullPointerException.class, new Runnable() { @@ -640,6 +648,7 @@ public class Exceptions { // getBytes(Locale) // getBytes(String) // getBytes(Charset) + encodedLength(); // encodedLength(Charset) contentEquals(); // contentEquals(StringBuffer) compareTo(); // compareTo(String), compareTo(Object) compareToIgnoreCase();// compareToIgnoreCase(String) diff --git a/test/jdk/java/lang/constant/ClassDescTest.java b/test/jdk/java/lang/constant/ClassDescTest.java index ee76d27e8d0..7551edff11a 100644 --- a/test/jdk/java/lang/constant/ClassDescTest.java +++ b/test/jdk/java/lang/constant/ClassDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,23 +31,17 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /* * @test * @bug 8215510 8283075 8338544 * @compile ClassDescTest.java - * @run testng ClassDescTest + * @run junit ClassDescTest * @summary unit tests for java.lang.constant.ClassDesc */ -@Test public class ClassDescTest extends SymbolicDescTest { private void testClassDesc(ClassDesc r) throws ReflectiveOperationException { @@ -73,7 +67,7 @@ public class ClassDescTest extends SymbolicDescTest { } if (!r.isClassOrInterface()) { - assertEquals(r.packageName(), ""); + assertEquals("", r.packageName()); } } @@ -97,18 +91,19 @@ public class ClassDescTest extends SymbolicDescTest { private void testClassDesc(ClassDesc r, Class c) throws ReflectiveOperationException { testClassDesc(r); - assertEquals(r.resolveConstantDesc(LOOKUP), c); - assertEquals(c.describeConstable().orElseThrow(), r); - assertEquals(ClassDesc.ofDescriptor(c.descriptorString()), r); + assertEquals(c, r.resolveConstantDesc(LOOKUP)); + assertEquals(r, c.describeConstable().orElseThrow()); + assertEquals(r, ClassDesc.ofDescriptor(c.descriptorString())); if (r.isArray()) { testClassDesc(r.componentType(), c.componentType()); } if (r.isClassOrInterface()) { - assertEquals(r.packageName(), c.getPackageName()); + assertEquals(c.getPackageName(), r.packageName()); } - assertEquals(r.displayName(), classDisplayName(c)); + assertEquals(classDisplayName(c), r.displayName()); } + @Test public void testSymbolicDescsConstants() throws ReflectiveOperationException { int tested = 0; Field[] fields = ConstantDescs.class.getDeclaredFields(); @@ -132,6 +127,7 @@ public class ClassDescTest extends SymbolicDescTest { assertTrue(tested > 0); } + @Test public void testPrimitiveClassDesc() throws ReflectiveOperationException { for (Primitives p : Primitives.values()) { List descs = List.of(ClassDesc.ofDescriptor(p.descriptor), @@ -140,26 +136,27 @@ public class ClassDescTest extends SymbolicDescTest { for (ClassDesc c : descs) { testClassDesc(c, p.clazz); assertTrue(c.isPrimitive()); - assertEquals(p.descriptor, c.descriptorString()); - assertEquals(p.name, c.displayName()); - descs.forEach(cc -> assertEquals(c, cc)); + assertEquals(c.descriptorString(), p.descriptor); + assertEquals(c.displayName(), p.name); + descs.forEach(cc -> assertEquals(cc, c)); if (p != Primitives.VOID) { testClassDesc(c.arrayType(), p.arrayClass); - assertEquals(c, p.arrayClass.describeConstable().orElseThrow().componentType()); - assertEquals(c, p.classDesc.arrayType().componentType()); + assertEquals(p.arrayClass.describeConstable().orElseThrow().componentType(), c); + assertEquals(p.classDesc.arrayType().componentType(), c); } } for (Primitives other : Primitives.values()) { ClassDesc otherDescr = ClassDesc.ofDescriptor(other.descriptor); if (p != other) - descs.forEach(c -> assertNotEquals(c, otherDescr)); + descs.forEach(c -> assertNotEquals(otherDescr, c)); else - descs.forEach(c -> assertEquals(c, otherDescr)); + descs.forEach(c -> assertEquals(otherDescr, c)); } } } + @Test public void testSimpleClassDesc() throws ReflectiveOperationException { List stringClassDescs = Arrays.asList(ClassDesc.ofDescriptor("Ljava/lang/String;"), @@ -175,22 +172,23 @@ public class ClassDescTest extends SymbolicDescTest { assertEquals("String", r.displayName()); testClassDesc(r.arrayType(), String[].class); testClassDesc(r.arrayType(3), String[][][].class); - stringClassDescs.forEach(rr -> assertEquals(r, rr)); + stringClassDescs.forEach(rr -> assertEquals(rr, r)); } testClassDesc(ClassDesc.of("java.lang.String").arrayType(), String[].class); testClassDesc(ClassDesc.of("java.util.Map").nested("Entry"), Map.Entry.class); - assertEquals(ClassDesc.of("java.lang.String"), ClassDesc.ofDescriptor("Ljava/lang/String;")); - assertEquals(ClassDesc.of("java.lang.String"), ClassDesc.ofInternalName("java/lang/String")); + assertEquals(ClassDesc.ofDescriptor("Ljava/lang/String;"), ClassDesc.of("java.lang.String")); + assertEquals(ClassDesc.ofInternalName("java/lang/String"), ClassDesc.of("java.lang.String")); ClassDesc thisClassDesc = ClassDesc.ofDescriptor("LClassDescTest;"); - assertEquals(thisClassDesc, ClassDesc.of("", "ClassDescTest")); - assertEquals(thisClassDesc, ClassDesc.of("ClassDescTest")); - assertEquals(thisClassDesc.displayName(), "ClassDescTest"); + assertEquals(ClassDesc.of("", "ClassDescTest"), thisClassDesc); + assertEquals(ClassDesc.of("ClassDescTest"), thisClassDesc); + assertEquals("ClassDescTest", thisClassDesc.displayName()); testClassDesc(thisClassDesc, ClassDescTest.class); } + @Test public void testPackageName() { assertEquals("com.foo", ClassDesc.of("com.foo.Bar").packageName()); assertEquals("com.foo", ClassDesc.of("com.foo.Bar").nested("Baz").packageName()); @@ -205,33 +203,19 @@ public class ClassDescTest extends SymbolicDescTest { } private void testBadArrayRank(ClassDesc cr) { - try { - cr.arrayType(-1); - fail(""); - } catch (IllegalArgumentException e) { - // good - } - try { - cr.arrayType(0); - fail(""); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalArgumentException.class, () -> cr.arrayType(-1)); + assertThrows(IllegalArgumentException.class, () -> cr.arrayType(0)); } private void testArrayRankOverflow() { ClassDesc TwoDArrayDesc = String.class.describeConstable().get().arrayType().arrayType(); - try { - TwoDArrayDesc.arrayType(Integer.MAX_VALUE); - fail(""); - } catch (IllegalArgumentException iae) { - // Expected - } + assertThrows(IllegalArgumentException.class, () -> TwoDArrayDesc.arrayType(Integer.MAX_VALUE)); } + @Test public void testArrayClassDesc() throws ReflectiveOperationException { for (String d : basicDescs) { ClassDesc a0 = ClassDesc.ofDescriptor(d); @@ -246,36 +230,32 @@ public class ClassDescTest extends SymbolicDescTest { assertTrue(a2.isArray()); assertFalse(a1.isPrimitive()); assertFalse(a2.isPrimitive()); - assertEquals(a0.descriptorString(), d); - assertEquals(a1.descriptorString(), "[" + a0.descriptorString()); - assertEquals(a2.descriptorString(), "[[" + a0.descriptorString()); + assertEquals(d, a0.descriptorString()); + assertEquals("[" + a0.descriptorString(), a1.descriptorString()); + assertEquals("[[" + a0.descriptorString(), a2.descriptorString()); assertNull(a0.componentType()); - assertEquals(a0, a1.componentType()); - assertEquals(a1, a2.componentType()); + assertEquals(a1.componentType(), a0); + assertEquals(a2.componentType(), a1); - assertNotEquals(a0, a1); - assertNotEquals(a1, a2); + assertNotEquals(a1, a0); + assertNotEquals(a2, a1); - assertEquals(a1, ClassDesc.ofDescriptor("[" + d)); - assertEquals(a2, ClassDesc.ofDescriptor("[[" + d)); - assertEquals(classToDescriptor(a0.resolveConstantDesc(LOOKUP)), a0.descriptorString()); - assertEquals(classToDescriptor(a1.resolveConstantDesc(LOOKUP)), a1.descriptorString()); - assertEquals(classToDescriptor(a2.resolveConstantDesc(LOOKUP)), a2.descriptorString()); + assertEquals(ClassDesc.ofDescriptor("[" + d), a1); + assertEquals(ClassDesc.ofDescriptor("[[" + d), a2); + assertEquals(a0.descriptorString(), classToDescriptor(a0.resolveConstantDesc(LOOKUP))); + assertEquals(a1.descriptorString(), classToDescriptor(a1.resolveConstantDesc(LOOKUP))); + assertEquals(a2.descriptorString(), classToDescriptor(a2.resolveConstantDesc(LOOKUP))); testBadArrayRank(ConstantDescs.CD_int); testBadArrayRank(ConstantDescs.CD_String); testBadArrayRank(ClassDesc.of("Bar")); testArrayRankOverflow(); } - try { - ConstantDescs.CD_void.arrayType(); - fail("Should throw IAE"); - } catch (IllegalArgumentException iae) { - // Expected - } + assertThrows(IllegalArgumentException.class, () -> ConstantDescs.CD_void.arrayType()); } + @Test public void testBadClassDescs() { List badDescriptors = List.of("II", "I;", "Q", "L", "", "java.lang.String", "[]", "Ljava/lang/String", @@ -283,35 +263,19 @@ public class ClassDescTest extends SymbolicDescTest { "La//b;", "L/a;", "La/;"); for (String d : badDescriptors) { - try { - ClassDesc constant = ClassDesc.ofDescriptor(d); - fail(d); - } - catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalArgumentException.class, () -> ClassDesc.ofDescriptor(d), d); } List badBinaryNames = List.of("I;", "[]", "Ljava/lang/String", "Ljava.lang.String;", "java/lang/String", ""); for (String d : badBinaryNames) { - try { - ClassDesc constant = ClassDesc.of(d); - fail(d); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalArgumentException.class, () -> ClassDesc.of(d), d); } List badInternalNames = List.of("I;", "[]", "[Ljava/lang/String;", "Ljava.lang.String;", "java.lang.String", ""); for (String d : badInternalNames) { - try { - ClassDesc constant = ClassDesc.ofInternalName(d); - fail(d); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalArgumentException.class, () -> ClassDesc.ofInternalName(d), d); } for (Primitives p : Primitives.values()) { @@ -321,80 +285,48 @@ public class ClassDescTest extends SymbolicDescTest { ClassDesc stringDesc = ClassDesc.ofDescriptor("Ljava/lang/String;"); ClassDesc stringArrDesc = stringDesc.arrayType(255); - try { - ClassDesc arrGreaterThan255 = stringArrDesc.arrayType(); - fail("can't create an array type descriptor with more than 255 dimensions"); - } catch (IllegalStateException e) { - // good - } - String descWith255ArrayDims = new String(new char[255]).replace('\0', '['); - try { - ClassDesc arrGreaterThan255 = ClassDesc.ofDescriptor(descWith255ArrayDims + "[Ljava/lang/String;"); - fail("can't create an array type descriptor with more than 255 dimensions"); - } catch (IllegalArgumentException e) { - // good - } - try { - ClassDesc arrWith255Dims = ClassDesc.ofDescriptor(descWith255ArrayDims + "Ljava/lang/String;"); - arrWith255Dims.arrayType(1); - fail("can't create an array type descriptor with more than 255 dimensions"); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalStateException.class, () -> stringArrDesc.arrayType(), + "can't create an array type descriptor with more than 255 dimensions"); + String descWith255ArrayDims = "[".repeat(255); + assertThrows(IllegalArgumentException.class, () -> ClassDesc.ofDescriptor(descWith255ArrayDims + "[Ljava/lang/String;"), + "can't create an array type descriptor with more than 255 dimensions"); + ClassDesc arrWith255Dims = ClassDesc.ofDescriptor(descWith255ArrayDims + "Ljava/lang/String;"); + assertThrows(IllegalArgumentException.class, () -> arrWith255Dims.arrayType(1), + "can't create an array type descriptor with more than 255 dimensions"); } private void testBadNestedClasses(ClassDesc cr, String firstNestedName, String... moreNestedNames) { - try { - cr.nested(firstNestedName, moreNestedNames); - fail(""); - } catch (IllegalStateException e) { - // good - } + assertThrows(IllegalStateException.class, () -> cr.nested(firstNestedName, moreNestedNames)); } + @Test public void testLangClasses() { Double d = 1.0; - assertEquals(d.resolveConstantDesc(LOOKUP), d); - assertEquals(d.describeConstable().get(), d); + assertEquals(d, d.resolveConstantDesc(LOOKUP)); + assertEquals(d, d.describeConstable().get()); Integer i = 1; - assertEquals(i.resolveConstantDesc(LOOKUP), i); - assertEquals(i.describeConstable().get(), i); + assertEquals(i, i.resolveConstantDesc(LOOKUP)); + assertEquals(i, i.describeConstable().get()); Float f = 1.0f; - assertEquals(f.resolveConstantDesc(LOOKUP), f); - assertEquals(f.describeConstable().get(), f); + assertEquals(f, f.resolveConstantDesc(LOOKUP)); + assertEquals(f, f.describeConstable().get()); Long l = 1L; - assertEquals(l.resolveConstantDesc(LOOKUP), l); - assertEquals(l.describeConstable().get(), l); + assertEquals(l, l.resolveConstantDesc(LOOKUP)); + assertEquals(l, l.describeConstable().get()); String s = ""; - assertEquals(s.resolveConstantDesc(LOOKUP), s); - assertEquals(s.describeConstable().get(), s); + assertEquals(s, s.resolveConstantDesc(LOOKUP)); + assertEquals(s, s.describeConstable().get()); } + @Test public void testNullNestedClasses() { ClassDesc cd = ClassDesc.of("Bar"); - try { - cd.nested(null); - fail(""); - } catch (NullPointerException e) { - // good - } - - try { - cd.nested("good", null); - fail(""); - } catch (NullPointerException e) { - // good - } - - try { - cd.nested("good", "goodToo", null); - fail(""); - } catch (NullPointerException e) { - // good - } + assertThrows(NullPointerException.class, () -> cd.nested(null)); + assertThrows(NullPointerException.class, () -> cd.nested("good", null)); + assertThrows(NullPointerException.class, () -> cd.nested("good", "goodToo", null)); } } diff --git a/test/jdk/java/lang/constant/CondyDescTest.java b/test/jdk/java/lang/constant/CondyDescTest.java index 08350f7748c..194c12527a2 100644 --- a/test/jdk/java/lang/constant/CondyDescTest.java +++ b/test/jdk/java/lang/constant/CondyDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,52 +33,50 @@ import java.lang.constant.DirectMethodHandleDesc; import java.lang.constant.DynamicConstantDesc; import java.lang.constant.MethodHandleDesc; -import org.testng.annotations.Test; - import static java.lang.constant.ConstantDescs.CD_MethodHandle; import static java.lang.constant.ConstantDescs.CD_Object; import static java.lang.constant.ConstantDescs.CD_String; import static java.lang.constant.ConstantDescs.CD_VarHandle; import static java.lang.constant.ConstantDescs.CD_int; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; /* * @test * @compile CondyDescTest.java - * @run testng CondyDescTest + * @run junit CondyDescTest * @summary unit tests for java.lang.constant.CondyDescTest */ -@Test public class CondyDescTest extends SymbolicDescTest { private final static ConstantDesc[] EMPTY_ARGS = new ConstantDesc[0]; private final static ClassDesc CD_ConstantBootstraps = ClassDesc.of("java.lang.invoke.ConstantBootstraps"); private static void testDCR(DynamicConstantDesc r, T c) throws ReflectiveOperationException { - assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs())); - assertEquals(r.resolveConstantDesc(LOOKUP), c); + assertEquals(DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()), r); + assertEquals(c, r.resolveConstantDesc(LOOKUP)); } private void testVarHandleDesc(DynamicConstantDesc r, VarHandle vh) throws ReflectiveOperationException { testSymbolicDesc(r); - assertEquals(vh.describeConstable().orElseThrow(), r); + assertEquals(r, vh.describeConstable().orElseThrow()); } private static> void testEnumDesc(EnumDesc r, E e) throws ReflectiveOperationException { testSymbolicDesc(r); - assertEquals(r, EnumDesc.of(r.constantType(), r.constantName())); - assertEquals(r.resolveConstantDesc(LOOKUP), e); + assertEquals(EnumDesc.of(r.constantType(), r.constantName()), r); + assertEquals(e, r.resolveConstantDesc(LOOKUP)); } + @Test public void testNullConstant() throws ReflectiveOperationException { DynamicConstantDesc r = (DynamicConstantDesc) ConstantDescs.NULL; - assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs())); + assertEquals(DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()), r); assertNull(r.resolveConstantDesc(LOOKUP)); } @@ -86,6 +84,7 @@ public class CondyDescTest extends SymbolicDescTest { return a + b; } + @Test public void testDynamicConstant() throws ReflectiveOperationException { DirectMethodHandleDesc bsmDesc = ConstantDescs.ofConstantBootstrap(ClassDesc.of("CondyDescTest"), "concatBSM", CD_String, CD_String, CD_String); @@ -93,6 +92,7 @@ public class CondyDescTest extends SymbolicDescTest { testDCR(r, "foobar"); } + @Test public void testNested() throws Throwable { DirectMethodHandleDesc invoker = ConstantDescs.ofConstantBootstrap(CD_ConstantBootstraps, "invoke", CD_Object, CD_MethodHandle, CD_Object.arrayType()); DirectMethodHandleDesc format = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.STATIC, CD_String, "format", @@ -101,7 +101,7 @@ public class CondyDescTest extends SymbolicDescTest { String s = (String) invoker.resolveConstantDesc(LOOKUP) .invoke(LOOKUP, "", String.class, format.resolveConstantDesc(LOOKUP), "%s%s", "moo", "cow"); - assertEquals(s, "moocow"); + assertEquals("moocow", s); DynamicConstantDesc desc = DynamicConstantDesc.of(invoker, format, "%s%s", "moo", "cow"); testDCR(desc, "moocow"); @@ -112,6 +112,7 @@ public class CondyDescTest extends SymbolicDescTest { enum MyEnum { A, B, C } + @Test public void testEnumDesc() throws ReflectiveOperationException { ClassDesc enumClass = ClassDesc.of("CondyDescTest").nested("MyEnum"); @@ -131,6 +132,7 @@ public class CondyDescTest extends SymbolicDescTest { int f; } + @Test public void testVarHandles() throws ReflectiveOperationException { ClassDesc testClass = ClassDesc.of("CondyDescTest").nested("MyClass"); MyClass instance = new MyClass(); @@ -140,20 +142,20 @@ public class CondyDescTest extends SymbolicDescTest { VarHandle varHandle = LOOKUP.findStaticVarHandle(MyClass.class, "sf", int.class); testVarHandleDesc(vhc, varHandle); - assertEquals(varHandle.varType(), int.class); + assertEquals(int.class, varHandle.varType()); varHandle.set(8); assertEquals(8, (int) varHandle.get()); - assertEquals(MyClass.sf, 8); + assertEquals(8, MyClass.sf); // static varHandle vhc = VarHandleDesc.ofField(testClass, "f", CD_int); varHandle = LOOKUP.findVarHandle(MyClass.class, "f", int.class); testVarHandleDesc(vhc, varHandle); - assertEquals(varHandle.varType(), int.class); + assertEquals(int.class, varHandle.varType()); varHandle.set(instance, 9); assertEquals(9, (int) varHandle.get(instance)); - assertEquals(instance.f, 9); + assertEquals(9, instance.f); vhc = VarHandleDesc.ofArray(CD_int.arrayType()); varHandle = MethodHandles.arrayElementVarHandle(int[].class); @@ -215,6 +217,7 @@ public class CondyDescTest extends SymbolicDescTest { } } + @Test public void testLifting() { DynamicConstantDesc unliftedNull = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_NULL_CONSTANT, "_", CD_Object, EMPTY_ARGS); assertEquals(ConstantDescs.NULL, unliftedNull); diff --git a/test/jdk/java/lang/constant/ConstantDescsTest.java b/test/jdk/java/lang/constant/ConstantDescsTest.java index 9b0e73868b9..0d7a85f5425 100644 --- a/test/jdk/java/lang/constant/ConstantDescsTest.java +++ b/test/jdk/java/lang/constant/ConstantDescsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,9 +21,6 @@ * questions. */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDescs; @@ -47,18 +44,20 @@ import java.util.Set; import java.util.stream.Stream; import static java.lang.constant.ConstantDescs.*; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @compile ConstantDescsTest.java - * @run testng ConstantDescsTest + * @run junit ConstantDescsTest * @summary unit tests for java.lang.constant.ConstantDescs */ public class ConstantDescsTest { - @DataProvider(name = "validateFields") - public Object[][] knownFieldsData() { + public static Object[][] knownFieldsData() { return new Object[][]{ {CD_Object, Object.class}, {CD_String, String.class}, @@ -117,10 +116,11 @@ public class ConstantDescsTest { * constants. * @throws ReflectiveOperationException if the test fails */ - @Test(dataProvider = "validateFields") + @ParameterizedTest + @MethodSource("knownFieldsData") public void validateFields(ConstantDesc desc, Object value) throws ReflectiveOperationException { // Use a minimally-trusted lookup - assertEquals(desc.resolveConstantDesc(MethodHandles.publicLookup()), value); + assertEquals(value, desc.resolveConstantDesc(MethodHandles.publicLookup())); } /** diff --git a/test/jdk/java/lang/constant/boottest/java.base/jdk/internal/constant/ConstantUtilsTest.java b/test/jdk/java/lang/constant/ConstantUtilsTest.java similarity index 65% rename from test/jdk/java/lang/constant/boottest/java.base/jdk/internal/constant/ConstantUtilsTest.java rename to test/jdk/java/lang/constant/ConstantUtilsTest.java index 3afcc64bc4a..c614132c7e5 100644 --- a/test/jdk/java/lang/constant/boottest/java.base/jdk/internal/constant/ConstantUtilsTest.java +++ b/test/jdk/java/lang/constant/ConstantUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,55 +21,41 @@ * questions. */ -package jdk.internal.constant; - import java.lang.constant.*; import java.util.*; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.*; -import static org.testng.Assert.*; +import jdk.internal.constant.ConstantAccess; +import jdk.internal.constant.ConstantUtils; +import org.junit.jupiter.api.Test; -/** +/* * @test * @bug 8303930 + * @build java.base/jdk.internal.constant.* * @compile ConstantUtilsTest.java * @modules java.base/jdk.internal.constant - * @run testng ConstantUtilsTest + * @run junit ConstantUtilsTest * @summary unit tests for methods of java.lang.constant.ConstantUtils that are not covered by other unit tests */ -@Test public class ConstantUtilsTest { private static ClassDesc thisClass = ClassDesc.of("MethodHandleDescTest"); + @Test public void testValidateMemberName() { - try { - ConstantUtils.validateMemberName(null, false); - fail(""); - } catch (NullPointerException e) { - // good - } - - try { - ConstantUtils.validateMemberName("", false); - fail(""); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(NullPointerException.class, () -> ConstantUtils.validateMemberName(null, false)); + assertThrows(IllegalArgumentException.class, () -> ConstantUtils.validateMemberName("", false)); List badNames = List.of(".", ";", "[", "/", "<", ">"); for (String n : badNames) { - try { - ConstantUtils.validateMemberName(n, true); - fail(n); - } catch (IllegalArgumentException e) { - // good - } + assertThrows(IllegalArgumentException.class, () -> ConstantUtils.validateMemberName(n, true), n); } } + @Test public void testSkipOverFieldSignatureVoid() { - int ret = ConstantUtils.skipOverFieldSignature("(V)V", 1, 4); - assertEquals(ret, 0, "Descriptor of (V)V starting at index 1, void disallowed"); + int ret = ConstantAccess.skipOverFieldSignature("(V)V", 1, 4); + assertEquals(0, ret, "Descriptor of (V)V starting at index 1, void disallowed"); } } diff --git a/test/jdk/java/lang/constant/DescribeResolveTest.java b/test/jdk/java/lang/constant/DescribeResolveTest.java index cc2a36dd3e2..7a9a11e64d0 100644 --- a/test/jdk/java/lang/constant/DescribeResolveTest.java +++ b/test/jdk/java/lang/constant/DescribeResolveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,21 +23,19 @@ /* * @test - * @run testng DescribeResolveTest + * @run junit DescribeResolveTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.lang.constant.Constable; import java.lang.constant.ConstantDesc; import java.lang.invoke.MethodHandles; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DescribeResolveTest { - @DataProvider public static Object[][] constables() { return new Object[][]{ { true }, @@ -48,7 +46,8 @@ public class DescribeResolveTest { }; } - @Test(dataProvider = "constables") + @ParameterizedTest + @MethodSource("constables") public void testDescribeResolve(Constable constable) throws ReflectiveOperationException { ConstantDesc desc = constable.describeConstable().orElseThrow(); Object resolved = desc.resolveConstantDesc(MethodHandles.lookup()); diff --git a/test/jdk/java/lang/constant/DynamicCallSiteDescTest.java b/test/jdk/java/lang/constant/DynamicCallSiteDescTest.java index 6f5e04efeb0..14d5fadbf01 100644 --- a/test/jdk/java/lang/constant/DynamicCallSiteDescTest.java +++ b/test/jdk/java/lang/constant/DynamicCallSiteDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,109 +21,71 @@ * questions. */ -import java.lang.invoke.MethodType; import java.lang.constant.*; -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static java.lang.constant.ConstantDescs.CD_int; -import static java.lang.constant.ConstantDescs.CD_void; -import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.toList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; -/** +/* * @test * @compile DynamicCallSiteDescTest.java - * @run testng DynamicCallSiteDescTest + * @run junit DynamicCallSiteDescTest * @summary unit tests for java.lang.constant.DynamicCallSiteDesc */ -@Test public class DynamicCallSiteDescTest extends SymbolicDescTest { /* note there is no unit test for method resolveCallSiteDesc as it is being tested in another test in this * suite, IndyDescTest */ + @Test public void testOf() throws ReflectiveOperationException { DirectMethodHandleDesc dmh = ConstantDescs.ofCallsiteBootstrap( ClassDesc.of("BootstrapAndTarget"), "bootstrap", ClassDesc.of("java.lang.invoke.CallSite") ); - try { - DynamicCallSiteDesc.of( - dmh, - "", - MethodTypeDesc.ofDescriptor("()I") - ); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException iae) { - // good - } + assertThrows(IllegalArgumentException.class, () -> DynamicCallSiteDesc.of( + dmh, + "", + MethodTypeDesc.ofDescriptor("()I") + )); - try { - DynamicCallSiteDesc.of( - null, - "getTarget", - MethodTypeDesc.ofDescriptor("()I") - ); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> DynamicCallSiteDesc.of( + null, + "getTarget", + MethodTypeDesc.ofDescriptor("()I") + )); - try { - DynamicCallSiteDesc.of( - dmh, - null, - MethodTypeDesc.ofDescriptor("()I") - ); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> DynamicCallSiteDesc.of( + dmh, + null, + MethodTypeDesc.ofDescriptor("()I") + )); - try { - DynamicCallSiteDesc.of( - dmh, - "getTarget", - null - ); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> DynamicCallSiteDesc.of( + dmh, + "getTarget", + null + )); - try { - DynamicCallSiteDesc.of( - dmh, - "getTarget", - MethodTypeDesc.ofDescriptor("()I"), - null - ); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } - try { - DynamicCallSiteDesc.of( - dmh, - "getTarget", - MethodTypeDesc.ofDescriptor("()I"), - new ConstantDesc[]{ null } - ); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> DynamicCallSiteDesc.of( + dmh, + "getTarget", + MethodTypeDesc.ofDescriptor("()I"), + null + )); + + assertThrows(NullPointerException.class, () -> DynamicCallSiteDesc.of( + dmh, + "getTarget", + MethodTypeDesc.ofDescriptor("()I"), + new ConstantDesc[]{ null } + )); } + @Test public void testWithArgs() throws ReflectiveOperationException { DynamicCallSiteDesc desc = DynamicCallSiteDesc.of(ConstantDescs.ofCallsiteBootstrap( ClassDesc.of("BootstrapAndTarget"), @@ -134,21 +96,11 @@ public class DynamicCallSiteDescTest extends SymbolicDescTest { MethodTypeDesc.ofDescriptor("()I") ); - try { - desc.withArgs(null); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } - - try { - desc.withArgs(new ConstantDesc[]{ null }); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> desc.withArgs(null)); + assertThrows(NullPointerException.class, () -> desc.withArgs(new ConstantDesc[]{ null })); } + @Test public void testWithNameAndType() throws ReflectiveOperationException { DynamicCallSiteDesc desc = DynamicCallSiteDesc.of(ConstantDescs.ofCallsiteBootstrap( ClassDesc.of("BootstrapAndTarget"), @@ -159,21 +111,11 @@ public class DynamicCallSiteDescTest extends SymbolicDescTest { MethodTypeDesc.ofDescriptor("()I") ); - try { - desc.withNameAndType(null, MethodTypeDesc.ofDescriptor("()I")); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } - - try { - desc.withNameAndType("bootstrap", null); - fail("NullPointerException expected"); - } catch (NullPointerException npe) { - // good - } + assertThrows(NullPointerException.class, () -> desc.withNameAndType(null, MethodTypeDesc.ofDescriptor("()I"))); + assertThrows(NullPointerException.class, () -> desc.withNameAndType("bootstrap", null)); } + @Test public void testAccessorsAndFactories() throws ReflectiveOperationException { DynamicCallSiteDesc desc = DynamicCallSiteDesc.of(ConstantDescs.ofCallsiteBootstrap( ClassDesc.of("BootstrapAndTarget"), diff --git a/test/jdk/java/lang/constant/IndyDescTest.java b/test/jdk/java/lang/constant/IndyDescTest.java index 13862fecd0b..9d635c0eb08 100644 --- a/test/jdk/java/lang/constant/IndyDescTest.java +++ b/test/jdk/java/lang/constant/IndyDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,19 +32,19 @@ import java.lang.constant.DynamicCallSiteDesc; import java.lang.constant.MethodHandleDesc; import java.lang.constant.MethodTypeDesc; -import org.testng.annotations.Test; import static java.lang.constant.ConstantDescs.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import org.junit.jupiter.api.Test; -/** +/* * @test * @compile IndyDescTest.java - * @run testng IndyDescTest + * @run junit IndyDescTest * @summary unit tests for java.lang.constant.IndyDescTest */ -@Test public class IndyDescTest { public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, Object... args) { @@ -54,6 +54,7 @@ public class IndyDescTest { return new ConstantCallSite(MethodHandles.constant(String.class, (String) args[0])); } + @Test public void testIndyDesc() throws Throwable { ClassDesc c = ClassDesc.of("IndyDescTest"); MethodTypeDesc mt = MethodTypeDesc.of(CD_CallSite, CD_MethodHandles_Lookup, CD_String, CD_MethodType, CD_Object.arrayType()); @@ -96,6 +97,7 @@ public class IndyDescTest { assertEquals("foo", csd5.invocationName()); } + @Test public void testEqualsHashToString() throws Throwable { ClassDesc c = ClassDesc.of("IndyDescTest"); MethodTypeDesc mt = MethodTypeDesc.of(CD_CallSite, CD_MethodHandles_Lookup, CD_String, CD_MethodType, CD_Object.arrayType()); @@ -109,14 +111,14 @@ public class IndyDescTest { assertNotEquals(csd1, csd3); assertNotEquals(csd1.hashCode(), csd3.hashCode()); - assertEquals(csd1.toString(), "DynamicCallSiteDesc[IndyDescTest::bootstrap(wooga/):()String]"); + assertEquals("DynamicCallSiteDesc[IndyDescTest::bootstrap(wooga/):()String]", csd1.toString()); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testEmptyInvocationName() throws Throwable { ClassDesc c = ClassDesc.of("IndyDescTest"); MethodTypeDesc mt = MethodTypeDesc.of(CD_CallSite, CD_MethodHandles_Lookup, CD_String, CD_MethodType, CD_Object.arrayType()); DirectMethodHandleDesc mh = MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.STATIC, c, "bootstrap", mt); - DynamicCallSiteDesc csd1 = DynamicCallSiteDesc.of(mh, "", MethodTypeDesc.of(CD_String)); + Assertions.assertThrows(IllegalArgumentException.class, () -> DynamicCallSiteDesc.of(mh, "", MethodTypeDesc.of(CD_String))); } } diff --git a/test/jdk/java/lang/constant/MethodHandleDescTest.java b/test/jdk/java/lang/constant/MethodHandleDescTest.java index e8b66daa6b7..68d9dad045b 100644 --- a/test/jdk/java/lang/constant/MethodHandleDescTest.java +++ b/test/jdk/java/lang/constant/MethodHandleDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; -import org.testng.annotations.Test; import static java.lang.constant.ConstantDescs.CD_Void; import static java.lang.constant.ConstantDescs.CD_boolean; @@ -54,20 +53,16 @@ import static java.lang.constant.ConstantDescs.CD_String; import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.CD_void; import static java.lang.invoke.MethodHandleInfo.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Test; -/** +import static org.junit.jupiter.api.Assertions.*; + +/* * @test * @compile MethodHandleDescTest.java - * @run testng MethodHandleDescTest + * @run junit MethodHandleDescTest * @summary unit tests for java.lang.constant.MethodHandleDesc */ -@Test public class MethodHandleDescTest extends SymbolicDescTest { private static ClassDesc helperHolderClass = ClassDesc.of("TestHelpers"); private static ClassDesc testClass = helperHolderClass.nested("TestClass"); @@ -75,13 +70,13 @@ public class MethodHandleDescTest extends SymbolicDescTest { private static ClassDesc testSuperclass = helperHolderClass.nested("TestSuperclass"); - private static void assertMHEquals(MethodHandle a, MethodHandle b) { - MethodHandleInfo ia = LOOKUP.revealDirect(a); - MethodHandleInfo ib = LOOKUP.revealDirect(b); - assertEquals(ia.getDeclaringClass(), ib.getDeclaringClass()); - assertEquals(ia.getName(), ib.getName()); - assertEquals(ia.getMethodType(), ib.getMethodType()); - assertEquals(ia.getReferenceKind(), ib.getReferenceKind()); + private static void assertMHEquals(MethodHandle expected, MethodHandle actual) { + MethodHandleInfo expectedInfo = LOOKUP.revealDirect(expected); + MethodHandleInfo actualInfo = LOOKUP.revealDirect(actual); + assertEquals(expectedInfo.getDeclaringClass(), actualInfo.getDeclaringClass()); + assertEquals(expectedInfo.getName(), actualInfo.getName()); + assertEquals(expectedInfo.getMethodType(), actualInfo.getMethodType()); + assertEquals(expectedInfo.getReferenceKind(), actualInfo.getReferenceKind()); } private void testMethodHandleDesc(MethodHandleDesc r) throws ReflectiveOperationException { @@ -89,8 +84,8 @@ public class MethodHandleDescTest extends SymbolicDescTest { testSymbolicDesc(r); DirectMethodHandleDesc rr = (DirectMethodHandleDesc) r; - assertEquals(r, MethodHandleDesc.of(rr.kind(), rr.owner(), rr.methodName(), rr.lookupDescriptor())); - assertEquals(r.invocationType().resolveConstantDesc(LOOKUP), r.resolveConstantDesc(LOOKUP).type()); + assertEquals(MethodHandleDesc.of(rr.kind(), rr.owner(), rr.methodName(), rr.lookupDescriptor()), r); + assertEquals(r.resolveConstantDesc(LOOKUP).type(), r.invocationType().resolveConstantDesc(LOOKUP)); } else { testSymbolicDescForwardOnly(r); @@ -114,19 +109,20 @@ public class MethodHandleDescTest extends SymbolicDescTest { private void testMethodHandleDesc(MethodHandleDesc r, MethodHandle mh) throws ReflectiveOperationException { testMethodHandleDesc(r); - assertMHEquals(r.resolveConstantDesc(LOOKUP), mh); - assertEquals(mh.describeConstable().orElseThrow(), r); + assertMHEquals(mh, r.resolveConstantDesc(LOOKUP)); + assertEquals(r, mh.describeConstable().orElseThrow()); // compare extractable properties: refKind, owner, name, type MethodHandleInfo mhi = LOOKUP.revealDirect(mh); DirectMethodHandleDesc rr = (DirectMethodHandleDesc) r; - assertEquals(mhi.getDeclaringClass().descriptorString(), rr.owner().descriptorString()); - assertEquals(mhi.getName(), rr.methodName()); - assertEquals(mhi.getReferenceKind(), rr.kind().refKind); + assertEquals(rr.owner().descriptorString(), mhi.getDeclaringClass().descriptorString()); + assertEquals(rr.methodName(), mhi.getName()); + assertEquals(rr.kind().refKind, mhi.getReferenceKind()); MethodType type = mhi.getMethodType(); - assertEquals(type.toMethodDescriptorString(), lookupDescriptor(rr)); + assertEquals(lookupDescriptor(rr), type.toMethodDescriptorString()); } + @Test public void testSimpleMHs() throws ReflectiveOperationException { MethodHandle MH_String_isEmpty = LOOKUP.findVirtual(String.class, "isEmpty", MethodType.fromMethodDescriptorString("()Z", null)); testMethodHandleDesc(MethodHandleDesc.of(Kind.VIRTUAL, CD_String, "isEmpty", "()Z"), MH_String_isEmpty); @@ -147,33 +143,16 @@ public class MethodHandleDescTest extends SymbolicDescTest { MH_ArrayList_new); testMethodHandleDesc(MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList")), MH_ArrayList_new); - // bad constructor non void return type - try { - MethodHandleDesc.of(Kind.CONSTRUCTOR, ClassDesc.of("java.util.ArrayList"), "", "()I"); - fail("should have failed: non void return type for constructor"); - } catch (IllegalArgumentException ex) { - // good - } + assertThrows(IllegalArgumentException.class, () -> MethodHandleDesc.of(Kind.CONSTRUCTOR, ClassDesc.of("java.util.ArrayList"), "", "()I"), + "bad constructor non void return type"); + assertThrows(NullPointerException.class, () -> MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList", null)), + "null list of parameters"); - // null list of parameters - try { - MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList", null)); - fail("should have failed: null list of parameters"); - } catch (NullPointerException ex) { - // good - } - - // null elements in list of parameters - try { - ClassDesc[] paramList = new ClassDesc[1]; - paramList[0] = null; - MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList"), paramList); - fail("should have failed: null content in list of parameters"); - } catch (NullPointerException ex) { - // good - } + assertThrows(NullPointerException.class, () -> MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList"), new ClassDesc[] { null }), + "null elements in list of parameters"); } + @Test public void testAsType() throws Throwable { MethodHandleDesc mhr = MethodHandleDesc.ofMethod(Kind.STATIC, ClassDesc.of("java.lang.Integer"), "valueOf", MethodTypeDesc.of(CD_Integer, CD_int)); @@ -181,41 +160,33 @@ public class MethodHandleDescTest extends SymbolicDescTest { testMethodHandleDesc(takesInteger); MethodHandle mh1 = takesInteger.resolveConstantDesc(LOOKUP); assertEquals((Integer) 3, (Integer) mh1.invokeExact((Integer) 3)); - assertEquals(takesInteger.toString(), "MethodHandleDesc[STATIC/Integer::valueOf(int)Integer].asType(Integer)Integer"); + assertEquals("MethodHandleDesc[STATIC/Integer::valueOf(int)Integer].asType(Integer)Integer", takesInteger.toString()); - try { - Integer i = (Integer) mh1.invokeExact(3); - fail("Expected WMTE"); - } - catch (WrongMethodTypeException ignored) { } + assertThrows(WrongMethodTypeException.class, () -> { + Integer _ = (Integer) mh1.invokeExact(3); + }); MethodHandleDesc takesInt = takesInteger.asType(MethodTypeDesc.of(CD_Integer, CD_int)); testMethodHandleDesc(takesInt); MethodHandle mh2 = takesInt.resolveConstantDesc(LOOKUP); assertEquals((Integer) 3, (Integer) mh2.invokeExact(3)); - try { - Integer i = (Integer) mh2.invokeExact((Integer) 3); - fail("Expected WMTE"); - } - catch (WrongMethodTypeException ignored) { } + assertThrows(WrongMethodTypeException.class, () -> { + Integer _ = (Integer) mh2.invokeExact((Integer) 3); + }); // Short circuit optimization MethodHandleDesc same = mhr.asType(mhr.invocationType()); assertSame(mhr, same); - try { - mhr.asType(null); - fail("Expected NPE"); - } catch (NullPointerException ex) { - // good - } + assertThrows(NullPointerException.class, () -> mhr.asType(null)); // @@@ Test varargs adaptation // @@@ Test bad adaptations and assert runtime error on resolution // @@@ Test intrinsification of adapted MH } + @Test public void testMethodHandleDesc() throws Throwable { MethodHandleDesc ctorDesc = MethodHandleDesc.of(Kind.CONSTRUCTOR, testClass, "", "()V"); MethodHandleDesc staticMethodDesc = MethodHandleDesc.of(Kind.STATIC, testClass, "sm", "(I)I"); @@ -229,14 +200,14 @@ public class MethodHandleDescTest extends SymbolicDescTest { MethodHandleDesc privateStaticMethodDesc = MethodHandleDesc.of(Kind.STATIC, testClass, "psm", "(I)I"); MethodHandleDesc privateStaticIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_STATIC, testInterface, "psm", "(I)I"); - assertEquals(ctorDesc.invocationType(), MethodTypeDesc.of(testClass)); - assertEquals(((DirectMethodHandleDesc) ctorDesc).lookupDescriptor(), "()V"); + assertEquals(MethodTypeDesc.of(testClass), ctorDesc.invocationType()); + assertEquals("()V", ((DirectMethodHandleDesc) ctorDesc).lookupDescriptor()); - assertEquals(staticMethodDesc.invocationType().descriptorString(), "(I)I"); - assertEquals(((DirectMethodHandleDesc) staticMethodDesc).lookupDescriptor(), "(I)I"); + assertEquals("(I)I", staticMethodDesc.invocationType().descriptorString()); + assertEquals("(I)I", ((DirectMethodHandleDesc) staticMethodDesc).lookupDescriptor()); - assertEquals(instanceMethodDesc.invocationType().descriptorString(), "(" + testClass.descriptorString() + "I)I"); - assertEquals(((DirectMethodHandleDesc) instanceMethodDesc).lookupDescriptor(), "(I)I"); + assertEquals("(" + testClass.descriptorString() + "I)I", instanceMethodDesc.invocationType().descriptorString()); + assertEquals("(I)I", ((DirectMethodHandleDesc) instanceMethodDesc).lookupDescriptor()); for (MethodHandleDesc r : List.of(ctorDesc, staticMethodDesc, staticIMethodDesc, instanceMethodDesc, instanceIMethodDesc)) testMethodHandleDesc(r); @@ -257,29 +228,23 @@ public class MethodHandleDescTest extends SymbolicDescTest { assertEquals(5, (int) instanceIMethodDesc.resolveConstantDesc(LOOKUP).invokeExact(instanceI, 5)); assertEquals(5, (int) instanceIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instanceI, 5)); - try { superMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> superMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(-1, (int) superMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance, 5)); - try { superIMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> superIMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(0, (int) superIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance, 5)); - try { privateMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> privateMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(5, (int) privateMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance, 5)); - try { privateIMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> privateIMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(0, (int) privateIMethodDesc.resolveConstantDesc(TestHelpers.TestInterface.LOOKUP).invokeExact(instanceI, 5)); assertEquals(0, (int) privateIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invoke(instanceI, 5)); - try { privateStaticMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> privateStaticMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(5, (int) privateStaticMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(5)); - try { privateStaticIMethodDesc.resolveConstantDesc(LOOKUP); fail(); } - catch (IllegalAccessException e) { /* expected */ } + assertThrows(IllegalAccessException.class, () -> privateStaticIMethodDesc.resolveConstantDesc(LOOKUP)); assertEquals(0, (int) privateStaticIMethodDesc.resolveConstantDesc(TestHelpers.TestInterface.LOOKUP).invokeExact(5)); assertEquals(0, (int) privateStaticIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(5)); @@ -292,34 +257,29 @@ public class MethodHandleDescTest extends SymbolicDescTest { for (MethodHandleDesc r : List.of(staticSetterDesc, staticGetterDesc, staticGetterIDesc, setterDesc, getterDesc)) testMethodHandleDesc(r); - staticSetterDesc.resolveConstantDesc(LOOKUP).invokeExact(6); assertEquals(TestHelpers.TestClass.sf, 6); + staticSetterDesc.resolveConstantDesc(LOOKUP).invokeExact(6); assertEquals(6, TestHelpers.TestClass.sf); assertEquals(6, (int) staticGetterDesc.resolveConstantDesc(LOOKUP).invokeExact()); assertEquals(6, (int) staticGetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact()); - staticSetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(7); assertEquals(TestHelpers.TestClass.sf, 7); + staticSetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(7); assertEquals(7, TestHelpers.TestClass.sf); assertEquals(7, (int) staticGetterDesc.resolveConstantDesc(LOOKUP).invokeExact()); assertEquals(7, (int) staticGetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact()); assertEquals(3, (int) staticGetterIDesc.resolveConstantDesc(LOOKUP).invokeExact()); assertEquals(3, (int) staticGetterIDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact()); - setterDesc.resolveConstantDesc(LOOKUP).invokeExact(instance, 6); assertEquals(instance.f, 6); + setterDesc.resolveConstantDesc(LOOKUP).invokeExact(instance, 6); assertEquals(6, instance.f); assertEquals(6, (int) getterDesc.resolveConstantDesc(LOOKUP).invokeExact(instance)); assertEquals(6, (int) getterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance)); - setterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance, 7); assertEquals(instance.f, 7); + setterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance, 7); assertEquals(7, instance.f); assertEquals(7, (int) getterDesc.resolveConstantDesc(LOOKUP).invokeExact(instance)); assertEquals(7, (int) getterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP).invokeExact(instance)); } private void assertBadArgs(Supplier supplier, String s) { - try { - MethodHandleDesc r = supplier.get(); - fail("Expected failure for " + s); - } - catch (IllegalArgumentException e) { - // succeed - } + assertThrows(IllegalArgumentException.class, supplier::get, s); } + @Test public void testBadFieldMHs() { List badGetterDescs = List.of("()V", "(Ljava/lang/Object;)V", "(I)I", "(Ljava/lang/Object;I)I"); List badStaticGetterDescs = List.of("()V", "(Ljava/lang/Object;)I", "(I)I", "(Ljava/lang/Object;I)I"); @@ -332,11 +292,12 @@ public class MethodHandleDescTest extends SymbolicDescTest { badStaticSetterDescs.forEach(s -> assertBadArgs(() -> MethodHandleDesc.of(STATIC_SETTER, helperHolderClass, "x", s), s)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testBadOwners() { - MethodHandleDesc.ofMethod(VIRTUAL, ClassDesc.ofDescriptor("I"), "x", MethodTypeDesc.ofDescriptor("()I")); + assertThrows(IllegalArgumentException.class, () -> MethodHandleDesc.ofMethod(VIRTUAL, ClassDesc.ofDescriptor("I"), "x", MethodTypeDesc.ofDescriptor("()I"))); } + @Test public void testSymbolicDescsConstants() throws ReflectiveOperationException { int tested = 0; Field[] fields = ConstantDescs.class.getDeclaredFields(); @@ -359,10 +320,11 @@ public class MethodHandleDescTest extends SymbolicDescTest { assertTrue(tested > 0); } + @Test public void testKind() { for (Kind k : Kind.values()) { - assertEquals(Kind.valueOf(k.refKind), Kind.valueOf(k.refKind, k.refKind == MethodHandleInfo.REF_invokeInterface)); - assertEquals(Kind.valueOf(k.refKind, k.isInterface), k); + assertEquals(Kind.valueOf(k.refKind, k.refKind == MethodHandleInfo.REF_invokeInterface), Kind.valueOf(k.refKind)); + assertEquals(k, Kind.valueOf(k.refKind, k.isInterface)); } // let's now verify those cases for which the value of the isInterface parameter is ignored int[] isInterfaceIgnored = new int[] { @@ -374,15 +336,15 @@ public class MethodHandleDescTest extends SymbolicDescTest { REF_invokeInterface }; for (int refKind : isInterfaceIgnored) { - assertEquals(Kind.valueOf(refKind, false), Kind.valueOf(refKind, true)); + assertEquals(Kind.valueOf(refKind, true), Kind.valueOf(refKind, false)); } // some explicit tests for REF_invokeStatic and REF_invokeSpecial - assertNotEquals(Kind.valueOf(REF_invokeStatic, false), Kind.valueOf(REF_invokeStatic, true)); - assertNotEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.valueOf(REF_invokeSpecial, true)); - assertEquals(Kind.valueOf(REF_invokeStatic, false), Kind.STATIC); - assertEquals(Kind.valueOf(REF_invokeStatic, true), Kind.INTERFACE_STATIC); - assertEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.SPECIAL); - assertEquals(Kind.valueOf(REF_invokeSpecial, true), Kind.INTERFACE_SPECIAL); + assertNotEquals(Kind.valueOf(REF_invokeStatic, true), Kind.valueOf(REF_invokeStatic, false)); + assertNotEquals(Kind.valueOf(REF_invokeSpecial, true), Kind.valueOf(REF_invokeSpecial, false)); + assertEquals(Kind.STATIC, Kind.valueOf(REF_invokeStatic, false)); + assertEquals(Kind.INTERFACE_STATIC, Kind.valueOf(REF_invokeStatic, true)); + assertEquals(Kind.SPECIAL, Kind.valueOf(REF_invokeSpecial, false)); + assertEquals(Kind.INTERFACE_SPECIAL, Kind.valueOf(REF_invokeSpecial, true)); } } diff --git a/test/jdk/java/lang/constant/MethodTypeDescTest.java b/test/jdk/java/lang/constant/MethodTypeDescTest.java index 5f7a2fc691f..06a6d5055b8 100644 --- a/test/jdk/java/lang/constant/MethodTypeDescTest.java +++ b/test/jdk/java/lang/constant/MethodTypeDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,21 +32,20 @@ import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.testng.annotations.Test; import static java.lang.constant.ConstantDescs.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; -/** +/* * @test * @bug 8304932 * @compile MethodTypeDescTest.java - * @run testng MethodTypeDescTest + * @run junit MethodTypeDescTest * @summary unit tests for java.lang.constant.MethodTypeDesc */ -@Test public class MethodTypeDescTest extends SymbolicDescTest { private void testMethodTypeDesc(MethodTypeDesc r) throws ReflectiveOperationException { @@ -75,16 +74,16 @@ public class MethodTypeDescTest extends SymbolicDescTest { private void testMethodTypeDesc(MethodTypeDesc r, MethodType mt) throws ReflectiveOperationException { testMethodTypeDesc(r); - assertEquals(r.resolveConstantDesc(LOOKUP), mt); - assertEquals(mt.describeConstable().get(), r); + assertEquals(mt, r.resolveConstantDesc(LOOKUP)); + assertEquals(r, mt.describeConstable().get()); - assertEquals(r.descriptorString(), mt.toMethodDescriptorString()); - assertEquals(r.parameterCount(), mt.parameterCount()); - assertEquals(r.parameterList(), mt.parameterList().stream().map(SymbolicDescTest::classToDesc).collect(toList())); - assertEquals(r.parameterArray(), Stream.of(mt.parameterArray()).map(SymbolicDescTest::classToDesc).toArray(ClassDesc[]::new)); + assertEquals(mt.toMethodDescriptorString(), r.descriptorString()); + assertEquals(mt.parameterCount(), r.parameterCount()); + assertEquals(mt.parameterList().stream().map(SymbolicDescTest::classToDesc).collect(toList()), r.parameterList()); + assertArrayEquals(Stream.of(mt.parameterArray()).map(SymbolicDescTest::classToDesc).toArray(ClassDesc[]::new), r.parameterArray()); for (int i=0; i { - MethodTypeDesc newDesc = mtDesc.changeReturnType(null); - }); + assertThrows(NullPointerException.class, () -> mtDesc.changeReturnType(null)); // changeParamType for (int i=0; i paramTypes[j]) .toArray(ClassDesc[]::new); MethodTypeDesc newDesc = mtDesc.dropParameterTypes(i, i + 1); - assertEquals(newDesc, MethodTypeDesc.of(returnType, ps)); + assertEquals(MethodTypeDesc.of(returnType, ps), newDesc); testMethodTypeDesc(newDesc, mt.dropParameterTypes(i, i+1)); // drop multiple params @@ -147,7 +144,7 @@ public class MethodTypeDescTest extends SymbolicDescTest { var t = new ArrayList<>(Arrays.asList(paramTypes)); t.subList(i, j).clear(); MethodTypeDesc multiDrop = mtDesc.dropParameterTypes(i, j); - assertEquals(multiDrop, MethodTypeDesc.of(returnType, t.toArray(ClassDesc[]::new))); + assertEquals(MethodTypeDesc.of(returnType, t.toArray(ClassDesc[]::new)), multiDrop); testMethodTypeDesc(multiDrop, mt.dropParameterTypes(i, j)); } } @@ -162,7 +159,7 @@ public class MethodTypeDescTest extends SymbolicDescTest { .mapToObj(j -> (j < k) ? paramTypes[j] : (j == k) ? p : paramTypes[j-1]) .toArray(ClassDesc[]::new); MethodTypeDesc newDesc = mtDesc.insertParameterTypes(i, p); - assertEquals(newDesc, MethodTypeDesc.of(returnType, ps)); + assertEquals(MethodTypeDesc.of(returnType, ps), newDesc); testMethodTypeDesc(newDesc, mt.insertParameterTypes(i, p.resolveConstantDesc(LOOKUP))); } @@ -172,7 +169,7 @@ public class MethodTypeDescTest extends SymbolicDescTest { a.addAll(i, Arrays.asList(addition)); MethodTypeDesc newDesc = mtDesc.insertParameterTypes(i, addition); - assertEquals(newDesc, MethodTypeDesc.of(returnType, a.toArray(ClassDesc[]::new))); + assertEquals(MethodTypeDesc.of(returnType, a.toArray(ClassDesc[]::new)), newDesc); testMethodTypeDesc(newDesc, mt.insertParameterTypes(i, Arrays.stream(addition).map(d -> { try { return (Class) d.resolveConstantDesc(LOOKUP); @@ -190,32 +187,28 @@ public class MethodTypeDescTest extends SymbolicDescTest { IntStream.rangeClosed(0, paramDescTypes.length - 1) .mapToObj(i -> ClassDesc.ofDescriptor(paramDescTypes[i])).toArray(ClassDesc[]::new); MethodTypeDesc mtDesc = MethodTypeDesc.of(returnType, paramTypes); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.insertParameterTypes(-1, paramTypes); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.insertParameterTypes(-1, paramTypes)); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.insertParameterTypes(paramTypes.length + 1, paramTypes); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.insertParameterTypes(paramTypes.length + 1, paramTypes)); - expectThrows(IllegalArgumentException.class, () -> { + { ClassDesc[] newParamTypes = new ClassDesc[1]; newParamTypes[0] = CD_void; MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int); - newDesc = newDesc.insertParameterTypes(0, newParamTypes); - }); + assertThrows(IllegalArgumentException.class, () -> newDesc.insertParameterTypes(0, newParamTypes)); + } - expectThrows(NullPointerException.class, () -> { + { MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int); - newDesc = newDesc.insertParameterTypes(0, null); - }); + assertThrows(NullPointerException.class, () -> newDesc.insertParameterTypes(0, null)); + } - expectThrows(NullPointerException.class, () -> { + { ClassDesc[] newParamTypes = new ClassDesc[1]; newParamTypes[0] = null; MethodTypeDesc newDesc = MethodTypeDesc.of(returnType, CD_int); - newDesc = newDesc.insertParameterTypes(0, newParamTypes); - }); + assertThrows(NullPointerException.class, () -> newDesc.insertParameterTypes(0, newParamTypes)); + } } private void badDropParametersTypes(ClassDesc returnType, String... paramDescTypes) { @@ -224,27 +217,18 @@ public class MethodTypeDescTest extends SymbolicDescTest { .mapToObj(i -> ClassDesc.ofDescriptor(paramDescTypes[i])).toArray(ClassDesc[]::new); MethodTypeDesc mtDesc = MethodTypeDesc.of(returnType, paramTypes); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.dropParameterTypes(-1, 0); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.dropParameterTypes(-1, 0)); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.dropParameterTypes(paramTypes.length, 0); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.dropParameterTypes(paramTypes.length, 0)); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.dropParameterTypes(paramTypes.length + 1, 0); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.dropParameterTypes(paramTypes.length + 1, 0)); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.dropParameterTypes(0, paramTypes.length + 1); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.dropParameterTypes(0, paramTypes.length + 1)); - expectThrows(IndexOutOfBoundsException.class, () -> { - MethodTypeDesc newDesc = mtDesc.dropParameterTypes(1, 0); - }); + assertThrows(IndexOutOfBoundsException.class, () -> mtDesc.dropParameterTypes(1, 0)); } + @Test public void testMethodTypeDesc() throws ReflectiveOperationException { for (String r : returnDescs) { assertMethodType(ClassDesc.ofDescriptor(r)); @@ -257,6 +241,7 @@ public class MethodTypeDescTest extends SymbolicDescTest { } } + @Test public void testBadMethodTypeRefs() { // ofDescriptor List badDescriptors = List.of("()II", "()I;", "(I;)", "(I)", "()L", "(V)V", @@ -283,29 +268,32 @@ public class MethodTypeDescTest extends SymbolicDescTest { assertThrows(IllegalArgumentException.class, () -> MethodTypeDesc.of(CD_int, List.of(CD_void))); } + @Test public void testOfArrayImmutability() { ClassDesc[] args = {CD_Object, CD_int}; var mtd = MethodTypeDesc.of(CD_void, args); args[1] = CD_void; - assertEquals(mtd, MethodTypeDesc.of(CD_void, CD_Object, CD_int)); + assertEquals(MethodTypeDesc.of(CD_void, CD_Object, CD_int), mtd); mtd.parameterArray()[1] = CD_void; - assertEquals(mtd, MethodTypeDesc.of(CD_void, CD_Object, CD_int)); + assertEquals(MethodTypeDesc.of(CD_void, CD_Object, CD_int), mtd); } + @Test public void testOfListImmutability() { List args = Arrays.asList(CD_Object, CD_int); var mtd = MethodTypeDesc.of(CD_void, args); args.set(1, CD_void); - assertEquals(mtd, MethodTypeDesc.of(CD_void, CD_Object, CD_int)); + assertEquals(MethodTypeDesc.of(CD_void, CD_Object, CD_int), mtd); assertThrows(UnsupportedOperationException.class, () -> mtd.parameterList().set(1, CD_void)); - assertEquals(mtd, MethodTypeDesc.of(CD_void, CD_Object, CD_int)); + assertEquals(MethodTypeDesc.of(CD_void, CD_Object, CD_int), mtd); } + @Test public void testMissingClass() { var mtd = MTD_void.insertParameterTypes(0, ClassDesc.of("does.not.exist.DoesNotExist")); assertThrows(ReflectiveOperationException.class, () -> mtd.resolveConstantDesc(MethodHandles.publicLookup())); diff --git a/test/jdk/java/lang/constant/NameValidationTest.java b/test/jdk/java/lang/constant/NameValidationTest.java index be266129370..96296ce290e 100644 --- a/test/jdk/java/lang/constant/NameValidationTest.java +++ b/test/jdk/java/lang/constant/NameValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,26 +21,22 @@ * questions. */ -/** +/* * @test * @bug 8215510 * @compile NameValidationTest.java - * @run testng NameValidationTest + * @run junit NameValidationTest * @summary unit tests for verifying member names */ import java.lang.constant.*; -import java.lang.invoke.*; - -import org.testng.annotations.Test; import static java.lang.constant.DirectMethodHandleDesc.*; import static java.lang.constant.ConstantDescs.*; -import static java.lang.constant.DirectMethodHandleDesc.Kind.VIRTUAL; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; -@Test public class NameValidationTest { private static final String[] badMemberNames = new String[] {"xx.xx", "zz;zz", "[l", "aa/aa", ""}; @@ -49,26 +45,17 @@ public class NameValidationTest { private static final String[] badClassNames = new String[] {"zz;zz", "[l", "aa/aa", ".", "a..b"}; private static final String[] goodClassNames = new String[] {"3", "~", "$", "qq", "a.a"}; + @Test public void testMemberNames() { DirectMethodHandleDesc mh = MethodHandleDesc.of(Kind.VIRTUAL, CD_String, "isEmpty", "()Z"); for (String badName : badMemberNames) { - try { - memberNamesHelper(badName, mh, CD_int, null); - fail("Expected failure for name " + badName); - } catch (IllegalArgumentException iae) { - // expected - } - try { - memberNamesHelper(badName, mh, CD_int, new ConstantDesc[0]); - fail("Expected failure for name " + badName); - } catch (IllegalArgumentException iae) { - // expected - } + assertThrows(IllegalArgumentException.class, () -> memberNamesHelper(badName, mh, CD_int, null), badName); + assertThrows(IllegalArgumentException.class, () -> memberNamesHelper(badName, mh, CD_int, new ConstantDesc[0]), badName); } - for (String badName : goodMemberNames) { - memberNamesHelper(badName, mh, CD_int, null); - memberNamesHelper(badName, mh, CD_int, new ConstantDesc[0]); + for (String goodName : goodMemberNames) { + memberNamesHelper(goodName, mh, CD_int, null); + memberNamesHelper(goodName, mh, CD_int, new ConstantDesc[0]); } } @@ -83,14 +70,10 @@ public class NameValidationTest { } } + @Test public void testClassNames() { for (String badName : badClassNames) { - try { - ClassDesc.of(badName); - fail("Expected failure for name " + badName); - } catch (IllegalArgumentException iae) { - // expected - } + assertThrows(IllegalArgumentException.class, () -> ClassDesc.of(badName), badName); } for (String goodName : goodClassNames) { diff --git a/test/jdk/java/lang/constant/SymbolicDescTest.java b/test/jdk/java/lang/constant/SymbolicDescTest.java index 5eb0ca10da6..8d4fcdf6a2c 100644 --- a/test/jdk/java/lang/constant/SymbolicDescTest.java +++ b/test/jdk/java/lang/constant/SymbolicDescTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Stream; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Base class for XxxDesc tests @@ -106,7 +106,7 @@ public abstract class SymbolicDescTest { if (desc instanceof Constable) { Optional opt = (Optional) ((Constable) desc).describeConstable(); ConstantDesc sr = (ConstantDesc) opt.orElseThrow().resolveConstantDesc(LOOKUP); - assertEquals(sr, desc); + assertEquals(desc, sr); } } } diff --git a/test/jdk/java/lang/constant/TypeDescriptorTest.java b/test/jdk/java/lang/constant/TypeDescriptorTest.java index 9ffbd886f41..9253462e223 100644 --- a/test/jdk/java/lang/constant/TypeDescriptorTest.java +++ b/test/jdk/java/lang/constant/TypeDescriptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,37 +22,35 @@ */ import java.lang.invoke.TypeDescriptor; -import java.lang.constant.ClassDesc; - -import org.testng.annotations.Test; import static java.lang.constant.ConstantDescs.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; -/** +/* * @test * @compile TypeDescriptorTest.java - * @run testng TypeDescriptorTest + * @run junit TypeDescriptorTest * @summary unit tests for implementations of java.lang.invoke.TypeDescriptor */ -@Test public class TypeDescriptorTest { private> void testArray(F f, boolean isArray, F component, F array) { if (isArray) { assertTrue(f.isArray()); - assertEquals(f.arrayType(), array); - assertEquals(f.componentType(), component); + assertEquals(array, f.arrayType()); + assertEquals(component, f.componentType()); } else { assertFalse(f.isArray()); - assertEquals(f.arrayType(), array); + assertEquals(array, f.arrayType()); assertNull(f.componentType()); } } + @Test public void testClass() { testArray(int.class, false, null, int[].class); testArray(int[].class, true, int.class, int[][].class); @@ -67,6 +65,7 @@ public class TypeDescriptorTest { assertFalse(String[].class.isPrimitive()); } + @Test public void testClassDesc() { testArray(CD_int, false, null, CD_int.arrayType()); diff --git a/test/jdk/java/lang/constant/boottest/TEST.properties b/test/jdk/java/lang/constant/boottest/TEST.properties deleted file mode 100644 index 565242e959b..00000000000 --- a/test/jdk/java/lang/constant/boottest/TEST.properties +++ /dev/null @@ -1,4 +0,0 @@ -# This file identifies root(s) of the test-ng hierarchy. - -TestNG.dirs = . -lib.dirs = /lib/testlibrary/bootlib diff --git a/test/jdk/java/lang/constant/java.base/jdk/internal/constant/ConstantAccess.java b/test/jdk/java/lang/constant/java.base/jdk/internal/constant/ConstantAccess.java new file mode 100644 index 00000000000..a8d7c2f3f99 --- /dev/null +++ b/test/jdk/java/lang/constant/java.base/jdk/internal/constant/ConstantAccess.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2026, 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 jdk.internal.constant; + +// Exposes package-private methods for testing. +public final class ConstantAccess { + public static int skipOverFieldSignature(String descriptor, int start, int end) { + return ConstantUtils.skipOverFieldSignature(descriptor, start, end); + } +} diff --git a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java index 1e473ccd974..cdaa94e8289 100644 --- a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java +++ b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java @@ -314,8 +314,9 @@ public class GetObjectSizeIntrinsicsTest extends ASimpleInstrumentationTestCase static final int LARGE_INT_ARRAY_SIZE = 1024*1024*1024 + 1024; static final int LARGE_OBJ_ARRAY_SIZE = (4096/(int)REF_SIZE)*1024*1024 + 1024; - static final boolean CCP = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); - static final int ARRAY_HEADER_SIZE = CCP ? 16 : (Platform.is64bit() ? 20 : 16); + // 64-bit: 8mw-4ccp-4len + // 32-bit: 4mw-4ccp-4len-4gap + static final int ARRAY_HEADER_SIZE = 16; final String mode; diff --git a/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/MyRecord.java b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/MyRecord.java new file mode 100644 index 00000000000..e0f4ecc50f5 --- /dev/null +++ b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/MyRecord.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2026, Datadog, Inc. 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.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@MyTypeAnnotation +public record MyRecord(@MyTypeUseAnnotation String filter) { + public static MyRecord parse(String param) { + if (param == null) { + throw new IllegalArgumentException("Filter cannot be null"); + } + return new MyRecord(param); + } +} + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@interface MyTypeAnnotation { +} + +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@interface MyTypeUseAnnotation { +} diff --git a/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/TestRetransformRecord.java b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/TestRetransformRecord.java new file mode 100644 index 00000000000..e8f1ba176d1 --- /dev/null +++ b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/TestRetransformRecord.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2026, Datadog, Inc. 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 8376185 + * @summary Class retransformation on a record type annotation + * @comment This is will rewrite the constant pool and process + * @comment the type annotation + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.compiler + * java.instrument + * @compile ../NamedBuffer.java + * @compile altered/MyRecord.jcod + * @run driver jdk.test.lib.helpers.ClassFileInstaller MyRecord + * @compile MyRecord.java + * @run main RedefineClassHelper + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine*=debug TestRetransformRecord + */ + +/* + * This test is loading a record with type annotation first, then by + * calling retransformClasses, we inject a slightly different record classfile + * where just some constants from the constant pools were swapped. + * It triggers, during the retransformation, a rewrite of the constant pool + * calling VM_RedefineClasses::rewrite_cp_refs_in_record_attribute method. + */ +import java.io.File; +import java.io.FileInputStream; +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.Instrumentation; +import java.security.ProtectionDomain; + +public class TestRetransformRecord { + static final String SRC = System.getProperty("test.src"); + static final String DEST = System.getProperty("test.classes"); + + public static void main(String[] args) throws Exception { + MyRecord.parse("foo"); + File clsfile = new File("MyRecord.class"); + byte[] buf = null; + try (FileInputStream str = new FileInputStream(clsfile)) { + buf = NamedBuffer.loadBufferFromStream(str); + } + Instrumentation inst = RedefineClassHelper.instrumentation; + inst.addTransformer(new IdentityTransformer("MyRecord", buf), true); + inst.retransformClasses(MyRecord.class); + System.out.println(MyRecord.parse("foo")); + } +} + +class IdentityTransformer implements ClassFileTransformer { + private final String className; + private final byte[] buffer; + + public IdentityTransformer(String className, byte[] buffer) { + this.className = className; + this.buffer = buffer; + } + + @Override + public byte[] transform(ClassLoader loader, + String classPath, + Class classBeingRedefined, + ProtectionDomain protectionDomain, + byte[] classfileBuffer) { + if (classPath != null && classPath.equals(className.replace('.', '/'))) { + System.out.println("Transforming " + className); + return buffer; + } + return null; + } +} diff --git a/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/altered/MyRecord.jcod b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/altered/MyRecord.jcod new file mode 100644 index 00000000000..88b4c038a39 --- /dev/null +++ b/test/jdk/java/lang/instrument/RetransformRecordTypeAnn/altered/MyRecord.jcod @@ -0,0 +1,421 @@ +/* + * Copyright (c) 2026, Datadog, Inc. 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. + */ + +/* + * This is a jcod version of the MyRecord classfile. + * Generated from runnning java -jar asmtools.jar jdec MyRecord.class + * Then slightly modified to trigger constant pool rewrite. + * Here the following modifications: + * - constants #10 and #11 were swapped + * - constants #14 and #34 were swapped + */ +class MyRecord { + 0xCAFEBABE; + 0; // minor version + 69; // version + [] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 + Class #4; // #2 + NameAndType #5 #6; // #3 + Utf8 "java/lang/Record"; // #4 + Utf8 ""; // #5 + Utf8 "()V"; // #6 + Field #8 #9; // #7 + Class #11; // #8 + NameAndType #10 #12; // #9 + Utf8 "filter"; // #10 + Utf8 "MyRecord"; // #11 + Utf8 "Ljava/lang/String;"; // #12 + Class #34; // #13 + Utf8 "LMyTypeUseAnnotation;"; // #14 + String #16; // #15 + Utf8 "Filter cannot be null"; // #16 + Method #13 #18; // #17 + NameAndType #5 #19; // #18 + Utf8 "(Ljava/lang/String;)V"; // #19 + Method #8 #18; // #20 + InvokeDynamic 0s #22; // #21 + NameAndType #23 #24; // #22 + Utf8 "toString"; // #23 + Utf8 "(LMyRecord;)Ljava/lang/String;"; // #24 + InvokeDynamic 0s #26; // #25 + NameAndType #27 #28; // #26 + Utf8 "hashCode"; // #27 + Utf8 "(LMyRecord;)I"; // #28 + InvokeDynamic 0s #30; // #29 + NameAndType #31 #32; // #30 + Utf8 "equals"; // #31 + Utf8 "(LMyRecord;Ljava/lang/Object;)Z"; // #32 + Utf8 "RuntimeVisibleTypeAnnotations"; // #33 + Utf8 "java/lang/IllegalArgumentException"; // #34 + Utf8 "Code"; // #35 + Utf8 "LineNumberTable"; // #36 + Utf8 "LocalVariableTable"; // #37 + Utf8 "this"; // #38 + Utf8 "LMyRecord;"; // #39 + Utf8 "MethodParameters"; // #40 + Utf8 "parse"; // #41 + Utf8 "(Ljava/lang/String;)LMyRecord;"; // #42 + Utf8 "param"; // #43 + Utf8 "StackMapTable"; // #44 + Utf8 "()Ljava/lang/String;"; // #45 + Utf8 "()I"; // #46 + Utf8 "(Ljava/lang/Object;)Z"; // #47 + Utf8 "o"; // #48 + Utf8 "Ljava/lang/Object;"; // #49 + Utf8 "SourceFile"; // #50 + Utf8 "MyRecord.java"; // #51 + Utf8 "RuntimeVisibleAnnotations"; // #52 + Utf8 "LMyTypeAnnotation;"; // #53 + Utf8 "Record"; // #54 + Utf8 "BootstrapMethods"; // #55 + String #10; // #56 + MethodHandle 1b #7; // #57 + MethodHandle 6b #59; // #58 + Method #60 #61; // #59 + Class #62; // #60 + NameAndType #63 #64; // #61 + Utf8 "java/lang/runtime/ObjectMethods"; // #62 + Utf8 "bootstrap"; // #63 + Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;"; // #64 + Utf8 "InnerClasses"; // #65 + Class #67; // #66 + Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #67 + Class #69; // #68 + Utf8 "java/lang/invoke/MethodHandles"; // #69 + Utf8 "Lookup"; // #70 + } + + 0x0031; // access + #8; // this_cpx + #2; // super_cpx + + [] { // Interfaces + } // end of Interfaces + + [] { // Fields + { // field + 0x0012; // access + #10; // name_index + #12; // descriptor_index + [] { // Attributes + Attr(#33) { // RuntimeVisibleTypeAnnotations + [] { // annotations + { // type_annotation + 0x13; // target_type: FIELD + []b { // type_paths + } + #14; + [] { // element_value_pairs + } // element_value_pairs + } // type_annotation + } + } // end of RuntimeVisibleTypeAnnotations + } // end of Attributes + } + } // end of Fields + + [] { // Methods + { // method + 0x0001; // access + #5; // name_index + #19; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 2; // max_stack + 2; // max_locals + Bytes[]{ + 0x2A 0xB7 0x00 0x01 0x2A 0x2B 0xB5 0x00 0x07 0xB1; + } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 7; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 10 38 39 0; + 0 10 11 12 1; + } + } // end of LocalVariableTable + } // end of Attributes + } // end of Code + ; + Attr(#40) { // MethodParameters + []b { // MethodParameters + #10 0x0000; + } + } // end of MethodParameters + ; + Attr(#33) { // RuntimeVisibleTypeAnnotations + [] { // annotations + { // type_annotation + 0x16; // target_type: METHOD_FORMAL_PARAMETER + 0x00; // parameter_index + []b { // type_paths + } + #14; + [] { // element_value_pairs + } // element_value_pairs + } // type_annotation + } + } // end of RuntimeVisibleTypeAnnotations + } // end of Attributes + } + ; + { // method + 0x0009; // access + #41; // name_index + #42; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 3; // max_stack + 1; // max_locals + Bytes[]{ + 0x2A 0xC7 0x00 0x0D 0xBB 0x00 0x0D 0x59 0x12 0x0F 0xB7 0x00; + 0x11 0xBF 0xBB 0x00 0x08 0x59 0x2A 0xB7 0x00 0x14 0xB0; + } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 9; + 4 10; + 14 12; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 23 43 12 0; + } + } // end of LocalVariableTable + ; + Attr(#44) { // StackMapTable + [] { // + 14b; // same_frame + } + } // end of StackMapTable + } // end of Attributes + } // end of Code + } // end of Attributes + } + ; + { // method + 0x0011; // access + #23; // name_index + #45; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2A 0xBA 0x00 0x15 0x00 0x00 0xB0; + } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 6; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 7 38 39 0; + } + } // end of LocalVariableTable + } // end of Attributes + } // end of Code + } // end of Attributes + } + ; + { // method + 0x0011; // access + #27; // name_index + #46; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2A 0xBA 0x00 0x19 0x00 0x00 0xAC; + } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 6; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 7 38 39 0; + } + } // end of LocalVariableTable + } // end of Attributes + } // end of Code + } // end of Attributes + } + ; + { // method + 0x0011; // access + #31; // name_index + #47; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 2; // max_stack + 2; // max_locals + Bytes[]{ + 0x2A 0x2B 0xBA 0x00 0x1D 0x00 0x00 0xAC } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 6; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 8 38 39 0; + 0 8 48 49 1; + } + } // end of LocalVariableTable + } // end of Attributes + } // end of Code + } // end of Attributes + } + ; + { // method + 0x0001; // access + #10; // name_index + #45; // descriptor_index + [] { // Attributes + Attr(#35) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2A 0xB4 0x00 0x07 0xB0; + } + [] { // Traps + } // end of Traps + [] { // Attributes + Attr(#36) { // LineNumberTable + [] { // line_number_table + 0 6; + } + } // end of LineNumberTable + ; + Attr(#37) { // LocalVariableTable + [] { // LocalVariableTable + 0 5 38 39 0; + } + } // end of LocalVariableTable + } // end of Attributes + } // end of Code + ; + Attr(#33) { // RuntimeVisibleTypeAnnotations + [] { // annotations + { // type_annotation + 0x14; // target_type: METHOD_RETURN + []b { // type_paths + } + #14; + [] { // element_value_pairs + } // element_value_pairs + } // type_annotation + } + } // end of RuntimeVisibleTypeAnnotations + } // end of Attributes + } + } // end of Methods + + [] { // Attributes + Attr(#50) { // SourceFile + #51; + } // end of SourceFile + ; + Attr(#52) { // RuntimeVisibleAnnotations + [] { // annotations + { // annotation + #53; + [] { // element_value_pairs + } // element_value_pairs + } // annotation + } + } // end of RuntimeVisibleAnnotations + ; + Attr(#54) { // Record + [] { // components + { // component + #10; // name_index + #12; // descriptor_index + [] { // Attributes + Attr(#33) { // RuntimeVisibleTypeAnnotations + [] { // annotations + { // type_annotation + 0x13; // target_type: FIELD + []b { // type_paths + } + #14; + [] { // element_value_pairs + } // element_value_pairs + } // type_annotation + } + } // end of RuntimeVisibleTypeAnnotations + } // end of Attributes + } + } + } // end of Record + ; + Attr(#55) { // BootstrapMethods + [] { // bootstrap_methods + { // bootstrap_method + #58; // bootstrap_method_ref + [] { // bootstrap_arguments + #8; + #56; + #57; + } // bootstrap_arguments + } // bootstrap_method + } + } // end of BootstrapMethods + ; + Attr(#65) { // InnerClasses + [] { // classes + #66 #68 #70 25; + } + } // end of InnerClasses + } // end of Attributes +} diff --git a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java index de1b22c4075..b093f086ba4 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java +++ b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,18 +35,14 @@ * @test * @bug 4982128 * @summary Test low memory detection of non-heap memory pool - * - * @run main/othervm/timeout=600 -Xnoclassgc -XX:MaxMetaspaceSize=32m - * LowMemoryTest2 - */ - -/* - * @test - * @bug 4982128 - * @summary Test low memory detection of non-heap memory pool - * - * @run main/othervm/timeout=600 -Xnoclassgc -XX:MaxMetaspaceSize=16m - * -XX:CompressedClassSpaceSize=4m LowMemoryTest2 + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm/timeout=600 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xnoclassgc -XX:MaxMetaspaceSize=32m LowMemoryTest2 + * @run main/othervm/timeout=600 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xnoclassgc -XX:MaxMetaspaceSize=16m + * -XX:CompressedClassSpaceSize=4m LowMemoryTest2 */ import java.lang.management.*; @@ -54,6 +50,8 @@ import javax.management.*; import javax.management.openmbean.CompositeData; import java.util.*; +import jdk.test.whitebox.WhiteBox; + public class LowMemoryTest2 { private static volatile boolean listenerInvoked = false; @@ -177,7 +175,7 @@ public class LowMemoryTest2 { // If we don't force a GC we may get an // OutOfMemoryException before the counters are updated. System.out.println("Force GC"); - System.gc(); + WhiteBox.getWhiteBox().fullGC(); } isThresholdCountSet = isAnyThresholdCountSet(pools); } diff --git a/test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java b/test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java index 66c3d3f41f5..8f0ed8e48af 100644 --- a/test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java +++ b/test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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 @@ -62,41 +62,60 @@ * @run main/othervm -Dprops=something InputArgument -Dprops=something */ +/* + * @test + * @bug 8378110 + * @summary RuntimeMXBean.getInputArguments() handling of flags from settings file. + * + * @run driver InputArgument generateFlagsFile + * @run main/othervm -XX:+UseFastJNIAccessors -XX:Flags=InputArgument.flags InputArgument + * -XX:+UseFastJNIAccessors -XX:+PrintWarnings -XX:-PrintCommandLineFlags -XX:ErrorLogTimeout=100 + */ + import java.lang.management.*; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; import java.util.ListIterator; public class InputArgument { private static RuntimeMXBean rm = ManagementFactory.getRuntimeMXBean(); - private static String vmOption = null; public static void main(String args[]) throws Exception { - // set the expected input argument - if (args.length > 0) { - vmOption = args[0]; - } - - List options = rm.getInputArguments(); - if (vmOption == null) { + if (args.length == 1 && "generateFlagsFile".equals(args[0])) { + generateFlagsFile(); return; } - boolean testFailed = true; + String[] vmOptions = args; + List options = rm.getInputArguments(); System.out.println("Number of arguments = " + options.size()); int i = 0; for (String arg : options) { System.out.println("Input arg " + i + " = " + arg); i++; - if (arg.equals(vmOption)) { - testFailed = false; - break; - } } - if (testFailed) { - throw new RuntimeException("TEST FAILED: " + - "VM option " + vmOption + " not found"); + + for (String expected : vmOptions) { + boolean found = false; + for (String arg : options) { + if (arg.equals(expected)) { + found = true; + break; + } + } + if (!found) { + throw new RuntimeException("TEST FAILED: " + + "VM option " + expected + " not found"); + } } System.out.println("Test passed."); } + + private static void generateFlagsFile() throws Exception { + // 3 types of flag; both boolean cases and 1 numeric + Files.writeString(Paths.get("", "InputArgument.flags"), + String.format("+PrintWarnings%n-PrintCommandLineFlags%nErrorLogTimeout=100%n")); + } } diff --git a/test/jdk/java/lang/runtime/ObjectMethodsTest.java b/test/jdk/java/lang/runtime/ObjectMethodsTest.java index 951d3b68383..d7ca5912273 100644 --- a/test/jdk/java/lang/runtime/ObjectMethodsTest.java +++ b/test/jdk/java/lang/runtime/ObjectMethodsTest.java @@ -36,11 +36,11 @@ import java.lang.invoke.MethodType; import java.lang.runtime.ObjectMethods; import static java.lang.invoke.MethodType.methodType; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; public class ObjectMethodsTest { @@ -144,8 +144,8 @@ public class ObjectMethodsTest { assertEquals("Empty[]", (String)handle.invokeExact(new Empty())); } - Class NPE = NullPointerException.class; - Class IAE = IllegalArgumentException.class; + private static final Class NPE = NullPointerException.class; + private static final Class IAE = IllegalArgumentException.class; @Test public void exceptions() { @@ -157,25 +157,60 @@ public class ObjectMethodsTest { assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "toString", C.EQUALS_DESC, C.class, "x;y", C.ACCESSORS)); assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "hashCode", C.TO_STRING_DESC, C.class, "x;y", C.ACCESSORS)); assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "equals", C.HASHCODE_DESC, C.class, "x;y", C.ACCESSORS)); + } - record NamePlusType(String mn, MethodType mt) {} - List namePlusTypeList = List.of( + record NamePlusType(String name, MethodType type) {} + + static List namePlusTypeList() { + return List.of( new NamePlusType("toString", C.TO_STRING_DESC), new NamePlusType("equals", C.EQUALS_DESC), new NamePlusType("hashCode", C.HASHCODE_DESC) ); - - for (NamePlusType npt : namePlusTypeList) { - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, npt.mn(), npt.mt(), C.class, "x;y", null)); - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, npt.mn(), npt.mt(), C.class, "x;y", new MethodHandle[]{null})); - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, npt.mn(), npt.mt(), C.class, null, C.ACCESSORS)); - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, npt.mn(), npt.mt(), null, "x;y", C.ACCESSORS)); - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, npt.mn(), null, C.class, "x;y", C.ACCESSORS)); - assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, null, npt.mt(), C.class, "x;y", C.ACCESSORS)); - assertThrows(NPE, () -> ObjectMethods.bootstrap(null, npt.mn(), npt.mt(), C.class, "x;y", C.ACCESSORS)); - } } + @MethodSource("namePlusTypeList") + @ParameterizedTest + void commonExceptions(NamePlusType npt) { + String name = npt.name(); + MethodType type = npt.type(); + + // Null checks + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, "x;y", null)); + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, "x;y", new MethodHandle[]{null})); + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, null, C.ACCESSORS)); + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, null, "x;y", C.ACCESSORS)); + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, name, null, C.class, "x;y", C.ACCESSORS)); + assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, null, type, C.class, "x;y", C.ACCESSORS)); + assertThrows(NPE, () -> ObjectMethods.bootstrap(null, name, type, C.class, "x;y", C.ACCESSORS)); + + // Bad indy call receiver type - change C to this test class + assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, name, type.changeParameterType(0, this.getClass()), C.class, "x;y", C.ACCESSORS)); + + // Bad getter types + var wrongReceiverGetter = assertDoesNotThrow(() -> MethodHandles.lookup().findGetter(this.getClass(), "y", int.class)); + assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, "x;y", + new MethodHandle[]{ + C.ACCESSORS[0], + wrongReceiverGetter, + })); + var extraArgGetter = MethodHandles.dropArguments(C.ACCESSORS[1], 1, int.class); + assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, "x;y", + new MethodHandle[]{ + C.ACCESSORS[0], + extraArgGetter, + })); + var voidReturnGetter = MethodHandles.empty(MethodType.methodType(void.class, C.class)); + assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, name, type, C.class, "x;y", + new MethodHandle[]{ + C.ACCESSORS[0], + voidReturnGetter, + })); + } + + // same field name and type as C::y, for wrongReceiverGetter + private int y; + // Based on the ObjectMethods internal implementation private static int hashCombiner(int x, int y) { return x*31 + y; diff --git a/test/jdk/java/net/DatagramPacket/ReuseBuf.java b/test/jdk/java/net/DatagramPacket/ReuseBuf.java index 232bd07dded..2213f306a8a 100644 --- a/test/jdk/java/net/DatagramPacket/ReuseBuf.java +++ b/test/jdk/java/net/DatagramPacket/ReuseBuf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,71 +21,132 @@ * questions. */ -/** + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketException; +import java.util.concurrent.atomic.AtomicReference; + +/* * @test - * * @bug 4424096 - * - * @summary DatagramPacket spec needs clarification (reuse buf) + * @summary Verify the specification of DatagramPacket.getData() */ -import java.net.*; - public class ReuseBuf { - static String msgs[] = {"Hello World", "Java", "Good Bye"}; - static int port; + private static final String[] msgs = {"Hello World", "Java", "Good Bye"}; - static class ServerThread extends Thread{ - DatagramSocket ds; - public ServerThread() { + static class Server implements Runnable, AutoCloseable { + + private final DatagramSocket ds; + private volatile boolean closed; + private final AtomicReference serverFailure = new AtomicReference<>(); + + public Server(final InetSocketAddress bindAddr) { try { - InetAddress local = InetAddress.getLocalHost(); - InetSocketAddress bindaddr = new InetSocketAddress(local, 0); - ds = new DatagramSocket(bindaddr); - port = ds.getLocalPort(); + this.ds = new DatagramSocket(bindAddr); + } catch (SocketException e) { + throw new RuntimeException(e); + } + System.out.println("Server bound to address: " + this.ds.getLocalSocketAddress()); + } + + private InetSocketAddress getServerAddress() { + return (InetSocketAddress) this.ds.getLocalSocketAddress(); + } + + private static void serverLog(final String msg) { + System.out.println("[server] " + msg); + } + + @Override + public void run() { + serverLog("server processing started"); + try { + doRun(); } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + // no need to be concerned with the exception + // if the server is already closed + if (!closed) { + this.serverFailure.set(e); + System.err.println("server exception: " + e); + e.printStackTrace(); + } + } finally { + close(); } } - public void run() { - byte b[] = new byte[100]; - DatagramPacket dp = new DatagramPacket(b,b.length); - while (true) { - try { - ds.receive(dp); - String reply = new String(dp.getData(), dp.getOffset(), dp.getLength()); - ds.send(new DatagramPacket(reply.getBytes(),reply.length(), - dp.getAddress(),dp.getPort())); - if (reply.equals(msgs[msgs.length-1])) { - break; - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + private void doRun() throws Exception { + byte[] b = new byte[100]; + DatagramPacket dp = new DatagramPacket(b, b.length); + while (!closed) { + serverLog("waiting to receive a message at " + ds.getLocalSocketAddress()); + ds.receive(dp); + String reply = new String(dp.getData(), dp.getOffset(), dp.getLength()); + serverLog("replying to " + dp.getAddress() + ":" + dp.getPort()); + ds.send(new DatagramPacket(reply.getBytes(), reply.length(), + dp.getAddress(), dp.getPort())); + if (reply.equals(msgs[msgs.length - 1])) { + break; } } - ds.close(); + } + + @Override + public void close() { + if (this.closed) { + return; + } + synchronized (this) { + if (this.closed) { + return; + } + this.closed = true; + } + System.out.println("Server closing " + ds.getLocalSocketAddress()); + this.ds.close(); } } - public static void main(String args[]) throws Exception { - ServerThread st = new ServerThread(); - st.start(); - InetAddress local = InetAddress.getLocalHost(); - InetSocketAddress bindaddr = new InetSocketAddress(local, 0); - DatagramSocket ds = new DatagramSocket(bindaddr); - byte b[] = new byte[100]; - DatagramPacket dp = new DatagramPacket(b,b.length); - for (int i = 0; i < msgs.length; i++) { - ds.send(new DatagramPacket(msgs[i].getBytes(),msgs[i].length(), - InetAddress.getLocalHost(), - port)); - ds.receive(dp); - if (!msgs[i].equals(new String(dp.getData(), dp.getOffset(), dp.getLength()))) { - throw new RuntimeException("Msg expected: "+msgs[i] +msgs[i].length()+ - "msg received: "+new String(dp.getData(), dp.getOffset(), dp.getLength())+dp.getLength()); + public static void main(String[] args) throws Exception { + InetSocketAddress loopbackEphemeral = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + Server server; + Thread serverThread; + try (var _ = server = new Server(loopbackEphemeral); + DatagramSocket ds = new DatagramSocket(loopbackEphemeral)) { + + InetSocketAddress destAddr = server.getServerAddress(); + // start the server + serverThread = new Thread(server); + serverThread.start(); + + byte[] b = new byte[100]; + DatagramPacket dp = new DatagramPacket(b, b.length); + for (String msg : msgs) { + System.out.println("sending message from " + ds.getLocalSocketAddress() + + " to " + destAddr); + ds.send(new DatagramPacket(msg.getBytes(), msg.length(), destAddr)); + // wait for a reply from the server + ds.receive(dp); + System.out.println("received message from: " + dp.getAddress() + ":" + dp.getPort()); + String actual = new String(dp.getData(), dp.getOffset(), dp.getLength()); + if (!msg.equals(actual)) { + throw new RuntimeException("Msg expected: " + msg + + " of length: " + msg.length() + + ", actual received: " + actual + " of length: " + dp.getLength()); + } } + System.out.println("All " + msgs.length + " replies received from the server"); + } + // wait for the server thread to complete + System.out.println("awaiting server thread " + serverThread + " to complete"); + serverThread.join(); + Exception serverFailure = server.serverFailure.get(); + if (serverFailure != null) { + System.err.println("Unexpected failure on server: " + serverFailure); + throw serverFailure; } - ds.close(); - System.out.println("Test Passed!!!"); } } diff --git a/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java b/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java index ded087d35e8..86936ae41d0 100644 --- a/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java +++ b/test/jdk/java/net/DatagramSocket/SendReceiveMaxSize.java @@ -22,7 +22,7 @@ */ /* - * @test + * @test id=default * @bug 8242885 8250886 8240901 * @key randomness * @summary This test verifies that on macOS, the send buffer size is configured @@ -34,13 +34,62 @@ * @library /test/lib * @build jdk.test.lib.net.IPSupport * @run testng/othervm SendReceiveMaxSize + */ +/* + * @test id=preferIPv4Stack + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using an IPv4 only socket. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport * @run testng/othervm -Djava.net.preferIPv4Stack=true SendReceiveMaxSize + */ +/* + * @test id=preferIPv6Addresses + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using a dual socket and prefering + * IPv6 addresses. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport * @run testng/othervm -Djava.net.preferIPv6Addresses=true SendReceiveMaxSize */ +/* + * @test id=preferLoopback + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using a dual socket and the loopback + * interface. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run testng/othervm -Dtest.preferLoopback=true SendReceiveMaxSize + */ +/* + * @test id=preferIPv6Loopback + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using a dual socket and the loopback + * interface. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run testng/othervm -Dtest.preferLoopback=true -Djava.net.preferIPv6Addresses=true SendReceiveMaxSize + */ +/* + * @test id=preferIPv4Loopback + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using an IPv4 only socket and the + * loopback interface + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run testng/othervm -Dtest.preferLoopback=true -Djava.net.preferIPv4Stack=true SendReceiveMaxSize + */ import jdk.test.lib.RandomFactory; import jdk.test.lib.Platform; import jdk.test.lib.net.IPSupport; +import jtreg.SkippedException; +import org.testng.SkipException; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -61,6 +110,9 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.expectThrows; public class SendReceiveMaxSize { + + private final static boolean PREFER_LOOPBACK = Boolean.getBoolean("test.preferLoopback"); + private int BUF_LIMIT; private InetAddress HOST_ADDR; private final static int IPV4_SNDBUF = 65507; @@ -75,8 +127,15 @@ public class SendReceiveMaxSize { @BeforeTest public void setUp() throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); - HOST_ADDR = InetAddress.getLocalHost(); + try { + // This method throws jtreg.SkippedException, which is + // interpreted as a test failure by testng + IPSupport.throwSkippedExceptionIfNonOperational(); + } catch (SkippedException skip) { + // throws the appropriate TestNG SkipException + throw new SkipException(skip.getMessage(), skip); + } + HOST_ADDR = PREFER_LOOPBACK ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost(); BUF_LIMIT = (HOST_ADDR instanceof Inet6Address) ? IPV6_SNDBUF : IPV4_SNDBUF; System.out.printf("Host address: %s, Buffer limit: %d%n", HOST_ADDR, BUF_LIMIT); } diff --git a/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java b/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java index dff8b38d3c1..e5bf0b3822d 100644 --- a/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java +++ b/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,11 +21,11 @@ * questions. */ -/** +/* * @test * @library /test/lib * @modules java.management java.base/java.io:+open java.base/java.net:+open - * java.base/sun.net java.base/sun.nio.ch:+open + * java.base/sun.nio.ch:+open * @run main/othervm/timeout=480 UnreferencedDatagramSockets * @run main/othervm/timeout=480 -Djava.net.preferIPv4Stack=true UnreferencedDatagramSockets * @summary Check that unreferenced datagram sockets are closed @@ -41,15 +41,12 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.DatagramPacket; import java.net.DatagramSocket; -import java.net.DatagramSocketImpl; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.channels.DatagramChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayDeque; import java.util.List; import java.util.Optional; @@ -59,7 +56,6 @@ import java.util.concurrent.CountDownLatch; import com.sun.management.UnixOperatingSystemMXBean; import jdk.test.lib.net.IPSupport; -import sun.net.NetProperties; public class UnreferencedDatagramSockets { @@ -191,48 +187,27 @@ public class UnreferencedDatagramSockets { : -1L; } - private static boolean usePlainDatagramSocketImpl() { - PrivilegedAction pa = () -> NetProperties.get("jdk.net.usePlainDatagramSocketImpl"); - String s = AccessController.doPrivileged(pa); - return (s != null) && (s.isEmpty() || s.equalsIgnoreCase("true")); - } - // Reflect to find references in the datagram implementation that will be gc'd private static void extractRefs(DatagramSocket s, String name) { try { Field datagramSocketField = DatagramSocket.class.getDeclaredField("delegate"); datagramSocketField.setAccessible(true); - if (!usePlainDatagramSocketImpl()) { - // DatagramSocket using DatagramSocketAdaptor - Object DatagramSocket = datagramSocketField.get(s); - assert DatagramSocket.getClass() == Class.forName("sun.nio.ch.DatagramSocketAdaptor"); + // DatagramSocket using DatagramSocketAdaptor + Object DatagramSocket = datagramSocketField.get(s); + assert DatagramSocket.getClass() == Class.forName("sun.nio.ch.DatagramSocketAdaptor"); - Method m = DatagramSocket.class.getDeclaredMethod("getChannel"); - m.setAccessible(true); - DatagramChannel datagramChannel = (DatagramChannel) m.invoke(DatagramSocket); + Method m = DatagramSocket.class.getDeclaredMethod("getChannel"); + m.setAccessible(true); + DatagramChannel datagramChannel = (DatagramChannel) m.invoke(DatagramSocket); - assert datagramChannel.getClass() == Class.forName("sun.nio.ch.DatagramChannelImpl"); + assert datagramChannel.getClass() == Class.forName("sun.nio.ch.DatagramChannelImpl"); - Field fileDescriptorField = datagramChannel.getClass().getDeclaredField("fd"); - fileDescriptorField.setAccessible(true); - FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramChannel); - extractRefs(fileDescriptor, name); + Field fileDescriptorField = datagramChannel.getClass().getDeclaredField("fd"); + fileDescriptorField.setAccessible(true); + FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramChannel); + extractRefs(fileDescriptor, name); - } else { - // DatagramSocket using PlainDatagramSocketImpl - Object DatagramSocket = datagramSocketField.get(s); - assert DatagramSocket.getClass() == Class.forName("java.net.NetMulticastSocket"); - - Method m = DatagramSocket.getClass().getDeclaredMethod("getImpl"); - m.setAccessible(true); - DatagramSocketImpl datagramSocketImpl = (DatagramSocketImpl) m.invoke(DatagramSocket); - - Field fileDescriptorField = DatagramSocketImpl.class.getDeclaredField("fd"); - fileDescriptorField.setAccessible(true); - FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramSocketImpl); - extractRefs(fileDescriptor, name); - } } catch (Exception ex) { ex.printStackTrace(); throw new AssertionError("missing field", ex); diff --git a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java index 2a87207c961..0f4faa4065b 100644 --- a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java +++ b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,11 +21,11 @@ * questions. */ -/** +/* * @test * @library /test/lib * @modules java.management java.base/java.io:+open java.base/java.net:+open - * java.base/sun.net java.base/sun.nio.ch:+open + * java.base/sun.nio.ch:+open * @run main/othervm/timeout=480 -Djava.net.preferIPv4Stack=true UnreferencedMulticastSockets * @run main/othervm/timeout=480 UnreferencedMulticastSockets * @summary Check that unreferenced multicast sockets are closed @@ -41,7 +41,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.DatagramPacket; import java.net.DatagramSocket; -import java.net.DatagramSocketImpl; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MulticastSocket; @@ -50,8 +49,6 @@ import java.nio.channels.DatagramChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayDeque; import java.util.List; import java.util.Optional; @@ -61,7 +58,6 @@ import java.util.concurrent.TimeUnit; import jdk.test.lib.net.IPSupport; import com.sun.management.UnixOperatingSystemMXBean; -import sun.net.NetProperties; public class UnreferencedMulticastSockets { @@ -229,12 +225,6 @@ public class UnreferencedMulticastSockets { : -1L; } - private static boolean usePlainDatagramSocketImpl() { - PrivilegedAction pa = () -> NetProperties.get("jdk.net.usePlainDatagramSocketImpl"); - String s = AccessController.doPrivileged(pa); - return (s != null) && (s.isEmpty() || s.equalsIgnoreCase("true")); - } - // Reflect to find references in the datagram implementation that will be gc'd private static void extractRefs(DatagramSocket s, String name) { @@ -242,35 +232,20 @@ public class UnreferencedMulticastSockets { Field datagramSocketField = DatagramSocket.class.getDeclaredField("delegate"); datagramSocketField.setAccessible(true); - if (!usePlainDatagramSocketImpl()) { - // MulticastSocket using DatagramSocketAdaptor - Object MulticastSocket = datagramSocketField.get(s); + // MulticastSocket using DatagramSocketAdaptor + Object MulticastSocket = datagramSocketField.get(s); - Method m = DatagramSocket.class.getDeclaredMethod("getChannel"); - m.setAccessible(true); - DatagramChannel datagramChannel = (DatagramChannel) m.invoke(MulticastSocket); + Method m = DatagramSocket.class.getDeclaredMethod("getChannel"); + m.setAccessible(true); + DatagramChannel datagramChannel = (DatagramChannel) m.invoke(MulticastSocket); - assert datagramChannel.getClass() == Class.forName("sun.nio.ch.DatagramChannelImpl"); + assert datagramChannel.getClass() == Class.forName("sun.nio.ch.DatagramChannelImpl"); - Field fileDescriptorField = datagramChannel.getClass().getDeclaredField("fd"); - fileDescriptorField.setAccessible(true); - FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramChannel); - extractRefs(fileDescriptor, name); + Field fileDescriptorField = datagramChannel.getClass().getDeclaredField("fd"); + fileDescriptorField.setAccessible(true); + FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramChannel); + extractRefs(fileDescriptor, name); - } else { - // MulticastSocket using PlainDatagramSocketImpl - Object MulticastSocket = datagramSocketField.get(s); - assert MulticastSocket.getClass() == Class.forName("java.net.NetMulticastSocket"); - - Method m = MulticastSocket.getClass().getDeclaredMethod("getImpl"); - m.setAccessible(true); - DatagramSocketImpl datagramSocketImpl = (DatagramSocketImpl) m.invoke(MulticastSocket); - - Field fileDescriptorField = DatagramSocketImpl.class.getDeclaredField("fd"); - fileDescriptorField.setAccessible(true); - FileDescriptor fileDescriptor = (FileDescriptor) fileDescriptorField.get(datagramSocketImpl); - extractRefs(fileDescriptor, name); - } } catch (Exception ex) { ex.printStackTrace(); throw new AssertionError("missing field", ex); diff --git a/test/jdk/java/net/URL/Constructor.java b/test/jdk/java/net/URL/Constructor.java index 13eae40d6d4..b1d6dc91bc4 100644 --- a/test/jdk/java/net/URL/Constructor.java +++ b/test/jdk/java/net/URL/Constructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ public class Constructor { entries.addAll(Arrays.asList(jarURLs)); entries.addAll(Arrays.asList(normalHttpURLs)); entries.addAll(Arrays.asList(abnormalHttpURLs)); + entries.addAll(Arrays.asList(blankComponents)); if (hasFtp()) entries.addAll(Arrays.asList(ftpURLs)); URL url; @@ -252,4 +253,20 @@ public class Constructor { "/dir1/entry.txt", "ftp://br:pwd@ftp.foo.com/dir1/entry.txt") }; + + static Entry[] blankComponents = new Entry[] { + new Entry(null, "http://host/path#", "http://host/path#"), + new Entry(null, "http://host/path?", "http://host/path?"), + new Entry(null, "http://host/path?#", "http://host/path?#"), + new Entry(null, "http://host/path#?", "http://host/path#?"), + new Entry(null, "file:/path#", "file:/path#"), + new Entry(null, "file:/path?", "file:/path?"), + new Entry(null, "file:/path?#", "file:/path?#"), + new Entry(null, "file:///path#", "file:/path#"), + new Entry(null, "file:///path?", "file:/path?"), + new Entry(null, "file:/path#?", "file:/path#?"), + new Entry("file:/path", "path?#", "file:/path?#"), + new Entry(null, "file:", "file:"), + new Entry(null, "file:#", "file:#") + }; } diff --git a/test/jdk/java/net/URLClassLoader/HttpTest.java b/test/jdk/java/net/URLClassLoader/HttpTest.java index 620eb34dbaa..09ee6dcfa85 100644 --- a/test/jdk/java/net/URLClassLoader/HttpTest.java +++ b/test/jdk/java/net/URLClassLoader/HttpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,233 +24,298 @@ /** * @test * @bug 4636331 + * @modules jdk.httpserver * @library /test/lib - * @summary Check that URLClassLoader doesn't create excessive http - * connections + * @summary Check that URLClassLoader with HTTP paths lookups produce the expected http requests + * @run junit HttpTest */ import java.net.*; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; +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.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class HttpTest { - /* - * Simple http server to service http requests. Auto shutdown - * if "idle" (no requests) for 10 seconds. Forks worker thread - * to service persistent connections. Work threads shutdown if - * "idle" for 5 seconds. - */ - static class HttpServer implements Runnable { + // HTTP server used to track requests + static HttpServer server; - private static HttpServer svr = null; - private static Counters cnts = null; - private static ServerSocket ss; + // RequestLog for capturing requests + static class RequestLog { + List log = new ArrayList<>(); - private static Object counterLock = new Object(); - private static int getCount = 0; - private static int headCount = 0; - - class Worker extends Thread { - Socket s; - Worker(Socket s) { - this.s = s; - } - - public void run() { - InputStream in = null; - try { - in = s.getInputStream(); - for (;;) { - - // read entire request from client - byte b[] = new byte[1024]; - int n, total=0; - - // max 5 seconds to wait for new request - s.setSoTimeout(5000); - try { - do { - n = in.read(b, total, b.length-total); - // max 0.5 seconds between each segment - // of request. - s.setSoTimeout(500); - if (n > 0) total += n; - } while (n > 0); - } catch (SocketTimeoutException e) { } - - if (total == 0) { - s.close(); - return; - } - - boolean getRequest = false; - if (b[0] == 'G' && b[1] == 'E' && b[2] == 'T') - getRequest = true; - - synchronized (counterLock) { - if (getRequest) - getCount++; - else - headCount++; - } - - // response to client - PrintStream out = new PrintStream( - new BufferedOutputStream( - s.getOutputStream() )); - out.print("HTTP/1.1 200 OK\r\n"); - - out.print("Content-Length: 75000\r\n"); - out.print("\r\n"); - if (getRequest) { - for (int i=0; i<75*1000; i++) { - out.write( (byte)'.' ); - } - } - out.flush(); - - } // for - - } catch (Exception e) { - unexpected(e); - } finally { - if (in != null) { try {in.close(); } catch(IOException e) {unexpected(e);} } - } - } + // Add a request to the log + public synchronized void capture(String method, URI uri) { + log.add(new Request(method, uri)); } - HttpServer() throws Exception { - ss = new ServerSocket(); - ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); + // Clear requests + public synchronized void clear() { + log.clear(); } - public void run() { - try { - // shutdown if no request in 10 seconds. - ss.setSoTimeout(10000); - for (;;) { - Socket s = ss.accept(); - (new Worker(s)).start(); - } - } catch (Exception e) { - } + public synchronized List requests() { + return List.copyOf(log); } - - void unexpected(Exception e) { - System.out.println(e); - e.printStackTrace(); - } - - public static HttpServer create() throws Exception { - if (svr != null) - return svr; - cnts = new Counters(); - svr = new HttpServer(); - (new Thread(svr)).start(); - return svr; - } - - public static void shutdown() throws Exception { - if (svr != null) { - ss.close(); - svr = null; - } - } - - public int port() { - return ss.getLocalPort(); - } - - public static class Counters { - public void reset() { - synchronized (counterLock) { - getCount = 0; - headCount = 0; - } - } - - public int getCount() { - synchronized (counterLock) { - return getCount; - } - } - - public int headCount() { - synchronized (counterLock) { - return headCount; - } - } - - public String toString() { - synchronized (counterLock) { - return "GET count: " + getCount + "; " + - "HEAD count: " + headCount; - } - } - } - - public Counters counters() { - return cnts; - } - } - public static void main(String args[]) throws Exception { - boolean failed = false; + // Represents a single request + record Request(String method, URI path) {} - // create http server - HttpServer svr = HttpServer.create(); + // Request log for this test + static RequestLog log = new RequestLog(); - // create class loader - URL urls[] = { - URIBuilder.newBuilder().scheme("http").loopback().port(svr.port()) - .path("/dir1/").toURL(), - URIBuilder.newBuilder().scheme("http").loopback().port(svr.port()) - .path("/dir2/").toURL(), + // Handlers specific to tests + static Map handlers = new ConcurrentHashMap<>(); + + // URLClassLoader with HTTP URL class path + private static URLClassLoader loader; + + @BeforeAll + static void setup() throws Exception { + server = HttpServer.create(); + server.bind(new InetSocketAddress( + InetAddress.getLoopbackAddress(), 0), 0); + server.createContext("/", e -> { + // Capture request in the log + log.capture(e.getRequestMethod(), e.getRequestURI()); + // Check for custom handler + HttpHandler custom = handlers.get(e.getRequestURI()); + if (custom != null) { + custom.handle(e); + } else { + // Successful responses echo the request path in the body + byte[] response = e.getRequestURI().getPath() + .getBytes(StandardCharsets.UTF_8); + e.sendResponseHeaders(200, response.length); + try (var out = e.getResponseBody()) { + out.write(response); + } + } + e.close(); + }); + server.start(); + int port = server.getAddress().getPort(); + + // Create class loader with two HTTP URLs + URL[] searchPath = new URL[] { + getHttpUri("/dir1/", port), + getHttpUri("/dir2/", port) }; - URLClassLoader cl = new URLClassLoader(urls); + loader = new URLClassLoader(searchPath); + } - // Test 1 - check that getResource does single HEAD request - svr.counters().reset(); - URL url = cl.getResource("foo.gif"); - System.out.println(svr.counters()); + // Create an HTTP URL for the given path and port using the loopback address + private static URL getHttpUri(String path, int port) throws Exception { + return URIBuilder.newBuilder() + .scheme("http") + .loopback() + .port(port) + .path(path).toURL(); + } - if (svr.counters().getCount() > 0 || - svr.counters().headCount() > 1) { - failed = true; + // Add redirect handler for a given path + private static void redirect(String path, String target) { + handlers.put(URI.create(path), e -> { + e.getResponseHeaders().set("Location", target); + e.sendResponseHeaders(301, 0); + }); + } + + // Return 404 not found for a given path + private static void notFound(String path) { + handlers.put(URI.create(path), e -> + e.sendResponseHeaders(404, 0)); + } + + @AfterAll + static void shutdown() { + server.stop(2000); + } + + @BeforeEach + void reset() { + synchronized (log) { + log.clear(); + } + handlers.clear(); + } + + // Check that getResource does single HEAD request + @Test + void getResourceSingleHead() { + URL url = loader.getResource("foo.gif"); + // Expect one HEAD + assertRequests(e -> e + .request("HEAD", "/dir1/foo.gif") + ); + } + + // Check that getResource follows redirects + @Test + void getResourceShouldFollowRedirect() { + redirect("/dir1/foo.gif", "/dir1/target.gif"); + URL url = loader.getResource("foo.gif"); + // Expect extra HEAD for redirect target + assertRequests(e -> e + .request("HEAD", "/dir1/foo.gif") + .request("HEAD", "/dir1/target.gif") + ); + + /* + * Note: Long-standing behavior is that URLClassLoader:getResource + * returns a URL for the requested resource, not the location redirected to + */ + assertEquals("/dir1/foo.gif", url.getPath()); + + } + + // Check that getResource treats a redirect to a not-found resource as a not-found resource + @Test + void getResourceRedirectTargetNotFound() { + redirect("/dir1/foo.gif", "/dir1/target.gif"); + notFound("/dir1/target.gif"); + URL url = loader.getResource("foo.gif"); + // Expect extra HEAD for redirect target and next URL in search path + assertRequests(e -> e + .request("HEAD", "/dir1/foo.gif") + .request("HEAD", "/dir1/target.gif") + .request("HEAD", "/dir2/foo.gif") + + ); + // Should find URL for /dir2 + assertEquals("/dir2/foo.gif", url.getPath()); + } + + // Check that getResourceAsStream does one HEAD and one GET request + @Test + void getResourceAsStreamSingleGet() throws IOException { + // Expect content from the first path + try (var in = loader.getResourceAsStream("foo2.gif")) { + assertEquals("/dir1/foo2.gif", + new String(in.readAllBytes(), StandardCharsets.UTF_8)); + } + // Expect one HEAD, one GET + assertRequests( e -> e + .request("HEAD", "/dir1/foo2.gif") + .request("GET", "/dir1/foo2.gif") + ); + } + + // Check that getResourceAsStream follows redirects + @Test + void getResourceAsStreamFollowRedirect() throws IOException { + redirect("/dir1/foo.gif", "/dir1/target.gif"); + // Expect content from the redirected location + try (var in = loader.getResourceAsStream("foo.gif")) { + assertEquals("/dir1/target.gif", + new String(in.readAllBytes(), StandardCharsets.UTF_8)); } - // Test 2 - check that getResourceAsStream does at most - // one GET request - svr.counters().reset(); - InputStream in = cl.getResourceAsStream("foo2.gif"); - in.close(); - System.out.println(svr.counters()); - if (svr.counters().getCount() > 1) { - failed = true; + /* + * Note: Long standing behavior of URLClassLoader::getResourceAsStream + * is to use HEAD during the findResource resource discovery and to not + * "remember" the HEAD redirect location when performing the GET. This + * explains why we observe two redirects here, one for HEAD, one for GET. + */ + assertRequests( e -> e + .request("HEAD", "/dir1/foo.gif") + .request("HEAD", "/dir1/target.gif") + .request("GET", "/dir1/foo.gif") + .request("GET", "/dir1/target.gif") + ); + } + + // getResourceAsStream on a 404 should try next path + @Test + void getResourceTryNextPath() throws IOException { + // Make the first path return 404 + notFound("/dir1/foo.gif"); + // Expect content from the second path + try (var in = loader.getResourceAsStream("foo.gif")) { + assertEquals("/dir2/foo.gif", + new String(in.readAllBytes(), StandardCharsets.UTF_8)); } + // Expect two HEADs, one GET + assertRequests(e -> e + .request("HEAD", "/dir1/foo.gif") + .request("HEAD", "/dir2/foo.gif") + .request("GET", "/dir2/foo.gif") + ); + } - // Test 3 - check that getResources only does HEAD requests - svr.counters().reset(); - Enumeration e = cl.getResources("foos.gif"); - try { - for (;;) { - e.nextElement(); - } - } catch (NoSuchElementException exc) { } - System.out.println(svr.counters()); - if (svr.counters().getCount() > 1) { - failed = true; - } + // Check that getResources only does HEAD requests + @Test + void getResourcesOnlyHead() throws IOException { + Collections.list(loader.getResources("foos.gif")); + // Expect one HEAD for each path + assertRequests(e -> e + .request("HEAD", "/dir1/foos.gif") + .request("HEAD", "/dir2/foos.gif") + ); + } - // shutdown http server - svr.shutdown(); + // Check that getResources skips 404 URL + @Test + void getResourcesShouldSkipFailedHead() throws IOException { + // Make first path fail with 404 + notFound("/dir1/foos.gif"); + List resources = Collections.list(loader.getResources("foos.gif")); + // Expect one HEAD for each path + assertRequests(e -> e + .request("HEAD", "/dir1/foos.gif") + .request("HEAD", "/dir2/foos.gif") + ); - if (failed) { - throw new Exception("Excessive http connections established - Test failed"); + // Expect a single URL to be returned + assertEquals(1, resources.size()); + } + + // Utils for asserting requests + static class Expect { + List requests = new ArrayList<>(); + + Expect request(String method, String path) { + requests.add(new Request(method, URI.create(path))); + return this; } } + static void assertRequests(Consumer e) { + // Collect expected requests + Expect exp = new Expect(); + e.accept(exp); + List expected = exp.requests; + + // Actual requests + List requests = log.requests(); + + // Verify expected number of requests + assertEquals(expected.size(), requests.size(), "Unexpected request count"); + + // Verify expected requests in order + for (int i = 0; i < expected.size(); i++) { + Request ex = expected.get(i); + Request req = requests.get(i); + // Verify method + assertEquals(ex.method, req.method, + String.format("Request %s has unexpected method %s", i, ex.method) + ); + // Verify path + assertEquals(ex.path, req.path, + String.format("Request %s has unexpected request URI %s", i, ex.path) + ); + } + } } diff --git a/test/jdk/java/net/httpclient/AbstractConnectTimeoutHandshake.java b/test/jdk/java/net/httpclient/AbstractConnectTimeoutHandshake.java index 3febe7145b4..d60fe4f8bcd 100644 --- a/test/jdk/java/net/httpclient/AbstractConnectTimeoutHandshake.java +++ b/test/jdk/java/net/httpclient/AbstractConnectTimeoutHandshake.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -46,24 +46,24 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.time.Duration.*; import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; abstract class AbstractConnectTimeoutHandshake { // The number of iterations each testXXXClient performs. static final int TIMES = 2; - Server server; - URI httpsURI; + private static Server server; + private static URI httpsURI; static final Duration NO_DURATION = null; @@ -79,8 +79,7 @@ abstract class AbstractConnectTimeoutHandshake { static final List METHODS = List.of("GET" , "POST"); static final List VERSIONS = List.of(HTTP_2, HTTP_1_1); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { List l = new ArrayList<>(); for (List timeouts : TIMEOUTS) { Duration connectTimeout = timeouts.get(0); @@ -198,8 +197,8 @@ abstract class AbstractConnectTimeoutHandshake { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = new Server(); httpsURI = URIBuilder.newBuilder() .scheme("https") @@ -210,8 +209,8 @@ abstract class AbstractConnectTimeoutHandshake { out.println("HTTPS URI: " + httpsURI); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { server.close(); out.printf("%n--- teardown ---%n"); diff --git a/test/jdk/java/net/httpclient/AbstractNoBody.java b/test/jdk/java/net/httpclient/AbstractNoBody.java index d0908a6e4cd..43847a2eda1 100644 --- a/test/jdk/java/net/httpclient/AbstractNoBody.java +++ b/test/jdk/java/net/httpclient/AbstractNoBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -38,9 +38,6 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; import static java.lang.System.err; import static java.lang.System.out; @@ -49,8 +46,16 @@ import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; + +// Use TestInstance.Lifecycle.PER_CLASS because we need access +// to this.getClass() in methods that are called from +// @BeforeAll and @AfterAll +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class AbstractNoBody implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @@ -76,7 +81,6 @@ public abstract class AbstractNoBody implements HttpServerAdapters { // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newFixedThreadPool(ITERATION_COUNT * 2); static final ExecutorService serverExecutor = Executors.newFixedThreadPool(ITERATION_COUNT * 4); - static final AtomicLong serverCount = new AtomicLong(); static final AtomicLong clientCount = new AtomicLong(); static final long start = System.nanoTime(); public static String now() { @@ -87,7 +91,6 @@ public abstract class AbstractNoBody implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - @DataProvider(name = "variants") public Object[][] variants() { return new Object[][]{ { http3URI_fixed, false,}, @@ -145,8 +148,8 @@ public abstract class AbstractNoBody implements HttpServerAdapters { var request = newRequestBuilder(http3URI_head) .HEAD().version(HTTP_2).build(); var response = client.send(request, BodyHandlers.ofString()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_2); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_2, response.version()); out.println("\n" + now() + "--- HEAD request succeeded ----\n"); err.println("\n" + now() + "--- HEAD request succeeded ----\n"); return response; @@ -182,7 +185,7 @@ public abstract class AbstractNoBody implements HttpServerAdapters { } } - @BeforeTest + @BeforeAll public void setup() throws Exception { printStamp(START, "setup"); HttpServerAdapters.enableServerLogging(); @@ -252,7 +255,7 @@ public abstract class AbstractNoBody implements HttpServerAdapters { printStamp(END,"setup"); } - @AfterTest + @AfterAll public void teardown() throws Exception { printStamp(START, "teardown"); sharedClient.close(); diff --git a/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java b/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java index ddd9c52fc58..1e8bc461d7f 100644 --- a/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java +++ b/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ -/** +/* * This is not a test. Actual tests are implemented by concrete subclasses. * The abstract class AbstractThrowingPushPromises provides a base framework * to test what happens when push promise handlers and their @@ -62,7 +62,6 @@ import java.net.http.HttpResponse.BodySubscriber; import java.net.http.HttpResponse.PushPromiseHandler; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -104,7 +103,6 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.TestWatcher; -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class AbstractThrowingPushPromises implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @@ -193,14 +191,9 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters @AfterAll - static final void printFailedTests() { + static void printFailedTests() { out.println("\n========================="); try { - // Exceptions should already have been added to FAILURES - // var failed = context.getFailedTests().getAllResults().stream() - // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - // FAILURES.putAll(failed); - out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -339,7 +332,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters HttpRequest req = request(uri); BodyHandler> handler = - new ThrowingBodyHandler((w) -> {}, + new ThrowingBodyHandler<>((w) -> {}, BodyHandlers.ofLines()); Map>>> pushPromises = new ConcurrentHashMap<>(); @@ -387,9 +380,9 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters } // @Test(dataProvider = "variants") - protected void testThrowingAsStringImpl(String uri, - boolean sameClient, - Thrower thrower) + void testThrowingAsStringImpl(String uri, + boolean sameClient, + Thrower thrower) throws Exception { String test = format("testThrowingAsString(%s, %b, %s)", @@ -399,7 +392,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters } //@Test(dataProvider = "variants") - protected void testThrowingAsLinesImpl(String uri, + void testThrowingAsLinesImpl(String uri, boolean sameClient, Thrower thrower) throws Exception @@ -411,9 +404,9 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters } //@Test(dataProvider = "variants") - protected void testThrowingAsInputStreamImpl(String uri, - boolean sameClient, - Thrower thrower) + void testThrowingAsInputStreamImpl(String uri, + boolean sameClient, + Thrower thrower) throws Exception { String test = format("testThrowingAsInputStream(%s, %b, %s)", @@ -424,7 +417,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters private void testThrowing(String name, String uri, boolean sameClient, Supplier> handlers, - Finisher finisher, Thrower thrower) + Finisher finisher, Thrower thrower) throws Exception { out.printf("%n%s%s%n", now(), name); @@ -438,7 +431,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters private void testThrowing(String uri, boolean sameClient, Supplier> handlers, - Finisher finisher, Thrower thrower) + Finisher finisher, Thrower thrower) throws Exception { HttpClient client = null; @@ -452,7 +445,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters ConcurrentMap>> promiseMap = new ConcurrentHashMap<>(); Supplier> throwing = () -> - new ThrowingBodyHandler(where.select(thrower), handlers.get()); + new ThrowingBodyHandler<>(where.select(thrower), handlers.get()); PushPromiseHandler pushHandler = new ThrowingPromiseHandler<>( where.select(thrower), PushPromiseHandler.of((r) -> throwing.get(), promiseMap)); @@ -540,7 +533,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters return check(w, reqURI, resp, thrower, promises, extractor); } - private final List check(Where w, URI reqURI, + private List check(Where w, URI reqURI, HttpResponse resp, Thrower thrower, Map>> promises, @@ -697,7 +690,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters public BodySubscriber apply(HttpResponse.ResponseInfo rinfo) { throwing.accept(Where.BODY_HANDLER); BodySubscriber subscriber = bodyHandler.apply(rinfo); - return new ThrowingBodySubscriber(throwing, subscriber); + return new ThrowingBodySubscriber<>(throwing, subscriber); } } diff --git a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java index 608b6489181..fb67cf02566 100644 --- a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java +++ b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters * ReferenceTracker AggregateRequestBodyTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors,headers,frames * AggregateRequestBodyTest * @summary Tests HttpRequest.BodyPublishers::concat @@ -41,7 +41,6 @@ import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -70,40 +69,43 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.Assert; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; +import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class AggregateRequestBodyTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http1TestServer; // HTTP/1.1 ( http ) - HttpTestServer https1TestServer; // HTTPS/1.1 ( https ) - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - URI http1URI; - URI https1URI; - URI http2URI; - URI https2URI; - URI http3URI; + private static HttpTestServer http1TestServer; // HTTP/1.1 ( http ) + private static HttpTestServer https1TestServer; // HTTPS/1.1 ( https ) + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static URI http1URI; + private static URI https1URI; + private static URI http2URI; + private static URI https2URI; + private static URI http3URI; static final int RESPONSE_CODE = 200; static final int ITERATION_COUNT = 4; @@ -123,8 +125,8 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -150,40 +152,40 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - FAILURES.putAll(failed); - out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -201,7 +203,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { } } - private URI[] uris() { + private static URI[] uris() { return new URI[] { http1URI, https1URI, @@ -211,19 +213,13 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { }; } - static AtomicLong URICOUNT = new AtomicLong(); - - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { URI[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; for (boolean sameClient : List.of(false, true)) { for (URI uri : uris()) { - HttpClient.Version version = null; + final HttpClient.Version version; if (uri.equals(http1URI) || uri.equals(https1URI)) version = HttpClient.Version.HTTP_1_1; else if (uri.equals(http2URI) || uri.equals(https2URI)) version = HttpClient.Version.HTTP_2; else if (uri.equals(http3URI)) version = HTTP_3; @@ -285,8 +281,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { return s; } - @DataProvider(name = "sparseContent") - Object[][] nulls() { + static Object[][] nulls() { return new Object[][] { {"null array", null}, {"null element", strings((String)null)}, @@ -300,12 +295,11 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { static List lengths(long... lengths) { return LongStream.of(lengths) - .mapToObj(Long::valueOf) + .boxed() .collect(Collectors.toList()); } - @DataProvider(name = "contentLengths") - Object[][] contentLengths() { + static Object[][] contentLengths() { return new Object[][] { {-1, lengths(-1)}, {-42, lengths(-42)}, @@ -332,8 +326,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { }; } - @DataProvider(name="negativeRequests") - Object[][] negativeRequests() { + static Object[][] negativeRequests() { return new Object[][] { {0L}, {-1L}, {-2L}, {Long.MIN_VALUE + 1L}, {Long.MIN_VALUE} }; @@ -453,7 +446,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Override public void onComplete() { - resultCF.complete(items.stream().collect(Collectors.toUnmodifiableList())); + resultCF.complete(items.stream().toList()); } public ByteBuffer take() { @@ -492,31 +485,33 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { () -> new AssertionError("Should not happen!")); } - @Test(dataProvider = "sparseContent") // checks that NPE is thrown + @ParameterizedTest // checks that NPE is thrown + @MethodSource("nulls") public void testNullPointerException(String description, String[] content) { - checkSkip(); + out.printf("%n%s-- testNullPointerException %s%n%n", now(), description); BodyPublisher[] publishers = publishers(content); - Assert.assertThrows(NullPointerException.class, () -> BodyPublishers.concat(publishers)); + Assertions.assertThrows(NullPointerException.class, () -> BodyPublishers.concat(publishers)); } // Verifies that an empty array creates a "noBody" publisher @Test public void testEmpty() { - checkSkip(); + out.printf("%n%s-- testEmpty%n%n", now()); BodyPublisher publisher = BodyPublishers.concat(); RequestSubscriber subscriber = new RequestSubscriber(); - assertEquals(publisher.contentLength(), 0); + assertEquals(0, publisher.contentLength()); publisher.subscribe(subscriber); subscriber.subscriptionCF.thenAccept(s -> s.request(1)); List result = subscriber.resultCF.join(); - assertEquals(result, List.of()); + assertEquals(List.of(), result); assertTrue(subscriber.items.isEmpty()); } // verifies that error emitted by upstream publishers are propagated downstream. - @Test(dataProvider = "sparseContent") // nulls are replaced with error publisher + @ParameterizedTest // nulls are replaced with error publisher + @MethodSource("nulls") public void testOnError(String description, String[] content) { - checkSkip(); + out.printf("%n%s-- testOnError %s%n%n", now(), description); final RequestSubscriber subscriber = new RequestSubscriber(); final PublishWithError errorPublisher; final BodyPublisher[] publishers; @@ -556,13 +551,13 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { publisher.subscribe(subscriber); subscriber.subscriptionCF.thenAccept(s -> s.request(Long.MAX_VALUE)); if (errorPublisher.hasErrors()) { - CompletionException ce = expectThrows(CompletionException.class, - () -> subscriber.resultCF.join()); + CompletionException ce = Assertions.assertThrows(CompletionException.class, + subscriber.resultCF::join); out.println(description + ": got expected " + ce); - assertEquals(ce.getCause().getClass(), Exception.class); - assertEquals(stringFromBytes(subscriber.items.stream()) + "", result); + assertEquals(Exception.class, ce.getCause().getClass()); + assertEquals(result, stringFromBytes(subscriber.items.stream()) + ""); } else { - assertEquals(stringFromBytes(subscriber.resultCF.join().stream()), result); + assertEquals(result, stringFromBytes(subscriber.resultCF.join().stream())); out.println(description + ": got expected result: " + result); } } @@ -570,9 +565,10 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // Verifies that if an upstream publisher has an unknown length, the // aggregate publisher will have an unknown length as well. Otherwise // the length should be known. - @Test(dataProvider = "sparseContent") // nulls are replaced with unknown length + @ParameterizedTest // nulls are replaced with unknown length + @MethodSource("nulls") public void testUnknownContentLength(String description, String[] content) { - checkSkip(); + out.printf("%n%s-- testUnknownContentLength %s%n%n", now(), description); if (content == null) { content = BODIES.toArray(String[]::new); description = "BODIES (known length)"; @@ -598,22 +594,23 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { length += content[i].length(); } } - out.printf("testUnknownContentLength(%s): %d%n", description, length); + out.printf("%stestUnknownContentLength(%s): %d%n", now(), description, length); BodyPublisher publisher = BodyPublishers.concat(publishers); - assertEquals(publisher.contentLength(), length, + assertEquals(length, publisher.contentLength(), description.replace("null", "length(-1)")); } - private static final Throwable completionCause(CompletionException x) { + private static Throwable completionCause(CompletionException x) { while (x.getCause() instanceof CompletionException) { x = (CompletionException)x.getCause(); } return x.getCause(); } - @Test(dataProvider = "negativeRequests") + @ParameterizedTest + @MethodSource("negativeRequests") public void testNegativeRequest(long n) { - checkSkip(); + out.printf("%n%s-- testNegativeRequest %s%n%n", now(), n); assert n <= 0 : "test for negative request called with n > 0 : " + n; BodyPublisher[] publishers = ContentLengthPublisher.of(List.of(1L, 2L, 3L)); BodyPublisher publisher = BodyPublishers.concat(publishers); @@ -621,7 +618,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { publisher.subscribe(subscriber); Subscription subscription = subscriber.subscriptionCF.join(); subscription.request(n); - CompletionException expected = expectThrows(CE, () -> subscriber.resultCF.join()); + CompletionException expected = Assertions.assertThrows(CE, subscriber.resultCF::join); Throwable cause = completionCause(expected); if (cause instanceof IllegalArgumentException) { System.out.printf("Got expected IAE for %d: %s%n", n, cause); @@ -637,7 +634,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test public void testPositiveRequests() { - checkSkip(); + out.printf("%n%s-- testPositiveRequests%n%n", now()); // A composite array of publishers BodyPublisher[] publishers = Stream.of( Stream.of(ofStrings("Lorem", " ", "ipsum", " ")), @@ -657,8 +654,8 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { List list1 = requestSubscriber1.resultCF().join(); assertTrue(requestSubscriber1.resultCF().isDone()); String result1 = stringFromBytes(list1.stream()); - assertEquals(result1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); - System.out.println("Got expected sentence with one request: \"%s\"".formatted(result1)); + assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", result1); + System.out.printf("Got expected sentence with one request: \"%s\"%n", result1); // Test that we can split our requests call any which way we want // (whether in the 'middle of a publisher' or at the boundaries. @@ -675,16 +672,17 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { List list2 = requestSubscriber2.resultCF().join(); assertTrue(requestSubscriber2.resultCF().isDone()); String result2 = stringFromBytes(list2.stream()); - assertEquals(result2, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", result2); System.out.println("Got expected sentence with 4 requests: \"%s\"".formatted(result1)); } - @Test(dataProvider = "contentLengths") + @ParameterizedTest + @MethodSource("contentLengths") public void testContentLength(long expected, List lengths) { - checkSkip(); + out.printf("%n%s-- testContentLength expected=%s %s%n%n", now(), expected, lengths); BodyPublisher[] publishers = ContentLengthPublisher.of(lengths); BodyPublisher aggregate = BodyPublishers.concat(publishers); - assertEquals(aggregate.contentLength(), expected, + assertEquals(expected, aggregate.contentLength(), "Unexpected result for %s".formatted(lengths)); } @@ -692,14 +690,13 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // publishers are no longer subscribed etc... @Test public void testCancel() { - checkSkip(); + out.printf("%n%s-- testCancel%n%n", now()); BodyPublisher[] publishers = BODIES.stream() .map(BodyPublishers::ofString) .toArray(BodyPublisher[]::new); BodyPublisher publisher = BodyPublishers.concat(publishers); - assertEquals(publisher.contentLength(), - BODIES.stream().mapToInt(String::length).sum()); + assertEquals(BODIES.stream().mapToInt(String::length).sum(), publisher.contentLength()); Map subscribers = new LinkedHashMap<>(); for (int n=0; n < BODIES.size(); n++) { @@ -731,7 +728,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // subscription was cancelled, so nothing should be received... try { - TimeoutException x = Assert.expectThrows(TimeoutException.class, + TimeoutException x = Assertions.assertThrows(TimeoutException.class, () -> any.get(5, TimeUnit.SECONDS)); out.println("Got expected " + x); } finally { @@ -742,8 +739,8 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { subscribers.get(rs), rs.resultCF)); } Consumer check = (rs) -> { - Assert.assertTrue(rs.items.isEmpty(), subscribers.get(rs) + " has items"); - Assert.assertFalse(rs.resultCF.isDone(), subscribers.get(rs) + " was not cancelled"); + assertTrue(rs.items.isEmpty(), subscribers.get(rs) + " has items"); + assertFalse(rs.resultCF.isDone(), subscribers.get(rs) + " was not cancelled"); out.println(subscribers.get(rs) + ": PASSED"); }; subscribers.keySet().stream().forEach(check); @@ -752,13 +749,12 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // Verifies that cancelling the subscription is propagated downstream @Test public void testCancelSubscription() { - checkSkip(); + out.printf("%n%s-- testCancelSubscription%n%n", now()); PublishWithError upstream = new PublishWithError(BODIES, BODIES.size(), () -> new AssertionError("should not come here")); BodyPublisher publisher = BodyPublishers.concat(upstream); - assertEquals(publisher.contentLength(), - BODIES.stream().mapToInt(String::length).sum()); + assertEquals(BODIES.stream().mapToInt(String::length).sum(), publisher.contentLength()); Map subscribers = new LinkedHashMap<>(); for (int n=0; n < BODIES.size(); n++) { @@ -793,7 +789,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // subscription was cancelled, so nothing should be received... try { - TimeoutException x = Assert.expectThrows(TimeoutException.class, + TimeoutException x = Assertions.assertThrows(TimeoutException.class, () -> any.get(5, TimeUnit.SECONDS)); out.println("Got expected " + x); } finally { @@ -804,17 +800,19 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { subscribers.get(rs), rs.resultCF)); } Consumer check = (rs) -> { - Assert.assertTrue(rs.items.isEmpty(), subscribers.get(rs) + " has items"); - Assert.assertFalse(rs.resultCF.isDone(), subscribers.get(rs) + " was not cancelled"); + assertTrue(rs.items.isEmpty(), subscribers.get(rs) + " has items"); + assertFalse(rs.resultCF.isDone(), subscribers.get(rs) + " was not cancelled"); out.println(subscribers.get(rs) + ": PASSED"); }; subscribers.keySet().stream().forEach(check); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(URI uri, HttpClient.Version version, boolean sameClient) throws Exception { - checkSkip(); + out.printf("%n%s-- test sameClient=%s, version=%s, uri=%s%n%n", + now(), sameClient, version, uri); System.out.printf("Request to %s (sameClient: %s)%n", uri, sameClient); System.err.printf("Request to %s (sameClient: %s)%n", uri, sameClient); @@ -826,7 +824,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { .toArray(HttpRequest.BodyPublisher[]::new) ); - HttpRequest request = HttpRequest.newBuilder(uri) + HttpRequest request = newRequestBuilder(uri) .version(version) .POST(publisher) .build(); @@ -837,14 +835,22 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); int expectedResponse = RESPONSE_CODE; if (response.statusCode() != expectedResponse) - throw new RuntimeException("wrong response code " + Integer.toString(response.statusCode())); - assertEquals(response.body(), BODIES.stream().collect(Collectors.joining())); + throw new RuntimeException("wrong response code " + response.statusCode()); + assertEquals(BODIES.stream().collect(Collectors.joining()), response.body()); } if (!sameClient) client.close(); System.out.println("test: DONE"); } - private URI buildURI(String scheme, String path, int port) { + private static HttpRequest.Builder newRequestBuilder(URI uri) { + var builder = HttpRequest.newBuilder(uri); + if (uri.getPath().contains("/http3/")) { + builder.setOption(H3_DISCOVERY, HTTP_3_URI_ONLY); + } + return builder; + } + + private static URI buildURI(String scheme, String path, int port) { return URIBuilder.newBuilder() .scheme(scheme) .loopback() @@ -853,8 +859,8 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { .buildUnchecked(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { HttpTestHandler handler = new HttpTestEchoHandler(); http1TestServer = HttpTestServer.create(HTTP_1_1); http1TestServer.addHandler(handler, "/http1/echo/"); @@ -884,11 +890,17 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + private static void close(AutoCloseable closeable) throws Exception { + if (closeable == null) return; + out.println("Closing shared client " + closeable); + closeable.close(); + } + + @AfterAll + public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); - sharedClient.close(); + close(sharedClient); sharedClient = null; Thread.sleep(100); AssertionError fail = TRACKER.check(500); diff --git a/test/jdk/java/net/httpclient/AltServiceUsageTest.java b/test/jdk/java/net/httpclient/AltServiceUsageTest.java index 41f3aef9bd1..59ad2179b90 100644 --- a/test/jdk/java/net/httpclient/AltServiceUsageTest.java +++ b/test/jdk/java/net/httpclient/AltServiceUsageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,36 +37,37 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary Verifies that the HTTP client correctly handles various alt-svc usages * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters * - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * AltServiceUsageTest */ public class AltServiceUsageTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer originServer; - private HttpTestServer altServer; + private static HttpTestServer originServer; + private static HttpTestServer altServer; - private DatagramChannel udpNotResponding; + private static DatagramChannel udpNotResponding; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { // attempt to create an HTTP/3 server, an HTTP/2 server, and a // DatagramChannel bound to the same port as the HTTP/2 server int count = 0; @@ -99,7 +100,7 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.err.println("**** All servers started. Test will start shortly ****"); } - private void createServers() throws IOException { + private static void createServers() throws IOException { altServer = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); altServer.addHandler(new All200OKHandler(), "/foo/"); altServer.addHandler(new RequireAltUsedHeader(), "/bar/"); @@ -114,8 +115,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { originServer.start(); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { safeStop(originServer); safeStop(altServer); safeClose(udpNotResponding); @@ -271,14 +272,14 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Issuing request " + reqURI); final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(response.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(response.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(200, response.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, response.body(), "Unexpected response body"); final Optional altSvcHeader = response.headers().firstValue("alt-svc"); - Assert.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); + Assertions.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); System.out.println("Received alt-svc header value: " + altSvcHeader.get()); final String expectedHeader = "h3=\"" + toHostPort(altServer) + "\""; - Assert.assertTrue(altSvcHeader.get().contains(expectedHeader), + Assertions.assertTrue(altSvcHeader.get().contains(expectedHeader), "Unexpected alt-svc header value: " + altSvcHeader.get() + ", was expected to contain: " + expectedHeader); @@ -286,8 +287,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Again issuing request " + reqURI); final HttpResponse secondResponse = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(secondResponse.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(secondResponse.body(), All200OKHandler.RESPONSE_CONTENT, + Assertions.assertEquals(200, secondResponse.statusCode(), "Unexpected response code"); + Assertions.assertEquals(All200OKHandler.RESPONSE_CONTENT, secondResponse.body(), "Unexpected response body"); var TRACKER = ReferenceTracker.INSTANCE; var tracker = TRACKER.getTracker(client); @@ -318,14 +319,14 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Issuing request " + reqURI); final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(response.statusCode(), 421, "Unexpected response code"); - Assert.assertEquals(response.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(421, response.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, response.body(), "Unexpected response body"); final Optional altSvcHeader = response.headers().firstValue("alt-svc"); - Assert.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); + Assertions.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); System.out.println("Received alt-svc header value: " + altSvcHeader.get()); final String expectedHeader = "h3=\"" + toHostPort(altServer) + "\""; - Assert.assertTrue(altSvcHeader.get().contains(expectedHeader), + Assertions.assertTrue(altSvcHeader.get().contains(expectedHeader), "Unexpected alt-svc header value: " + altSvcHeader.get() + ", was expected to contain: " + expectedHeader); @@ -333,8 +334,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Again issuing request " + reqURI); final HttpResponse secondResponse = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(secondResponse.statusCode(), 421, "Unexpected response code"); - Assert.assertEquals(response.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(421, secondResponse.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, response.body(), "Unexpected response body"); var TRACKER = ReferenceTracker.INSTANCE; var tracker = TRACKER.getTracker(client); @@ -369,14 +370,14 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Issuing request " + reqURI); final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(response.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(response.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(200, response.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, response.body(), "Unexpected response body"); final Optional altSvcHeader = response.headers().firstValue("alt-svc"); - Assert.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); + Assertions.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); System.out.println("Received alt-svc header value: " + altSvcHeader.get()); final String expectedHeader = "h3=\"" + toHostPort(altServer) + "\""; - Assert.assertTrue(altSvcHeader.get().contains(expectedHeader), + Assertions.assertTrue(altSvcHeader.get().contains(expectedHeader), "Unexpected alt-svc header value: " + altSvcHeader.get() + ", was expected to contain: " + expectedHeader); @@ -386,8 +387,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Again issuing request " + reqURI); final HttpResponse secondResponse = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(secondResponse.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(secondResponse.body(), RequireAltUsedHeader.RESPONSE_CONTENT, + Assertions.assertEquals(200, secondResponse.statusCode(), "Unexpected response code"); + Assertions.assertEquals(RequireAltUsedHeader.RESPONSE_CONTENT, secondResponse.body(), "Unexpected response body"); var TRACKER = ReferenceTracker.INSTANCE; var tracker = TRACKER.getTracker(client); @@ -424,14 +425,14 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Issuing request " + reqURI); final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(response.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(response.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(200, response.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, response.body(), "Unexpected response body"); final Optional altSvcHeader = response.headers().firstValue("alt-svc"); - Assert.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); + Assertions.assertTrue(altSvcHeader.isPresent(), "alt-svc header is missing in response"); System.out.println("Received alt-svc header value: " + altSvcHeader.get()); final String expectedHeader = "h3=\"" + toHostPort(altServer) + "\""; - Assert.assertTrue(altSvcHeader.get().contains(expectedHeader), + Assertions.assertTrue(altSvcHeader.get().contains(expectedHeader), "Unexpected alt-svc header value: " + altSvcHeader.get() + ", was expected to contain: " + expectedHeader); @@ -439,8 +440,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Again issuing request " + reqURI); final HttpResponse secondResponse = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(secondResponse.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(secondResponse.body(), All200OKHandler.RESPONSE_CONTENT, + Assertions.assertEquals(200, secondResponse.statusCode(), "Unexpected response code"); + Assertions.assertEquals(All200OKHandler.RESPONSE_CONTENT, secondResponse.body(), "Unexpected response body"); // wait for alt-service to expire @@ -452,8 +453,8 @@ public class AltServiceUsageTest implements HttpServerAdapters { System.out.println("Issuing request for a third time " + reqURI); final HttpResponse thirdResponse = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(thirdResponse.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(thirdResponse.body(), H3AltServicePublisher.RESPONSE_CONTENT, + Assertions.assertEquals(200, thirdResponse.statusCode(), "Unexpected response code"); + Assertions.assertEquals(H3AltServicePublisher.RESPONSE_CONTENT, thirdResponse.body(), "Unexpected response body"); var TRACKER = ReferenceTracker.INSTANCE; var tracker = TRACKER.getTracker(client); diff --git a/test/jdk/java/net/httpclient/AsFileDownloadTest.java b/test/jdk/java/net/httpclient/AsFileDownloadTest.java index 88bf95dab02..6e9c4e676cf 100644 --- a/test/jdk/java/net/httpclient/AsFileDownloadTest.java +++ b/test/jdk/java/net/httpclient/AsFileDownloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -63,19 +63,20 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestServer; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpResponse.BodyHandlers.ofFileDownload; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -86,24 +87,24 @@ import static org.testng.Assert.fail; * jdk.test.lib.Platform jdk.test.lib.util.FileUtils * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm/timeout=480 AsFileDownloadTest + * @run junit/othervm/timeout=480 AsFileDownloadTest */ public class AsFileDownloadTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h3TestServer; // HTTP/3 - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h3URI; + private static HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h3TestServer; // HTTP/3 + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h3URI; final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - Path tempDir; + static Path tempDir; static final String[][] contentDispositionValues = new String[][] { // URI query Content-Type header value Expected filename @@ -151,8 +152,7 @@ public class AsFileDownloadTest { { "041", "attachment; filename=\"foo/../../file12.txt\"", "file12.txt" }, }; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { List list = new ArrayList<>(); Arrays.asList(contentDispositionValues).stream() @@ -181,7 +181,8 @@ public class AsFileDownloadTest { return builder.sslContext(sslContext).proxy(Builder.NO_PROXY).build(); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, String contentDispositionValue, String expectedFilename, Optional requestVersion) throws Exception { out.printf("test(%s, %s, %s): starting", uriString, contentDispositionValue, expectedFilename); @@ -207,14 +208,13 @@ public class AsFileDownloadTest { String fileContents = new String(Files.readAllBytes(response.body()), UTF_8); out.println("Got body: " + fileContents); - assertEquals(response.statusCode(), 200); - assertEquals(body.getFileName().toString(), expectedFilename); + assertEquals(200, response.statusCode()); + assertEquals(expectedFilename, body.getFileName().toString()); assertTrue(response.headers().firstValue("Content-Disposition").isPresent()); - assertEquals(response.headers().firstValue("Content-Disposition").get(), - contentDispositionValue); - assertEquals(fileContents, "May the luck of the Irish be with you!"); + assertEquals( contentDispositionValue, response.headers().firstValue("Content-Disposition").get()); + assertEquals("May the luck of the Irish be with you!", fileContents); if (requestVersion.isPresent()) { - assertEquals(response.version(), requestVersion.get(), "unexpected HTTP version" + + assertEquals(requestVersion.get(), response.version(), "unexpected HTTP version" + " in response"); } @@ -254,8 +254,7 @@ public class AsFileDownloadTest { }; - @DataProvider(name = "negative") - public Object[][] negative() { + public static Object[][] negative() { List list = new ArrayList<>(); Arrays.asList(contentDispositionBADValues).stream() @@ -276,7 +275,8 @@ public class AsFileDownloadTest { return list.stream().toArray(Object[][]::new); } - @Test(dataProvider = "negative") + @ParameterizedTest + @MethodSource("negative") void negativeTest(String uriString, String contentDispositionValue, Optional requestVersion) throws Exception { out.printf("negativeTest(%s, %s): starting", uriString, contentDispositionValue); @@ -330,8 +330,8 @@ public class AsFileDownloadTest { return builder; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { tempDir = Paths.get("asFileDownloadTest.tmp.dir"); if (Files.exists(tempDir)) throw new AssertionError("Unexpected test work dir existence: " + tempDir.toString()); @@ -380,8 +380,8 @@ public class AsFileDownloadTest { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); http2TestServer.stop(); @@ -474,11 +474,11 @@ public class AsFileDownloadTest { for (String name : List.of(headerName.toUpperCase(Locale.ROOT), headerName.toLowerCase(Locale.ROOT))) { assertTrue(headers.firstValue(name).isPresent()); - assertEquals(headers.firstValue(name).get(), headerValue.get(0)); - assertEquals(headers.allValues(name).size(), headerValue.size()); - assertEquals(headers.allValues(name), headerValue); - assertEquals(headers.map().get(name).size(), headerValue.size()); - assertEquals(headers.map().get(name), headerValue); + assertEquals(headerValue.get(0), headers.firstValue(name).get()); + assertEquals(headerValue.size(), headers.allValues(name).size()); + assertEquals(headerValue, headers.allValues(name)); + assertEquals(headerValue.size(), headers.map().get(name).size()); + assertEquals(headerValue, headers.map().get(name)); } } } catch (Throwable t) { diff --git a/test/jdk/java/net/httpclient/AsyncExecutorShutdown.java b/test/jdk/java/net/httpclient/AsyncExecutorShutdown.java index 14ed4f63124..308288bb9bf 100644 --- a/test/jdk/java/net/httpclient/AsyncExecutorShutdown.java +++ b/test/jdk/java/net/httpclient/AsyncExecutorShutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * AsyncExecutorShutdown @@ -68,10 +68,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -81,9 +77,14 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class AsyncExecutorShutdown implements HttpServerAdapters { @@ -92,27 +93,26 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { } static final Random RANDOM = RandomFactory.getRandom(); - ExecutorService readerService; + private static ExecutorService readerService; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/2 ( h2+h3 ) - HttpTestServer h3TestServer; // HTTP/2 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h3URI; - String h2h3Head; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/2 ( h2+h3 ) + private static HttpTestServer h3TestServer; // HTTP/2 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h3URI; + private static String h2h3Head; static final String MESSAGE = "AsyncExecutorShutdown message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig() }, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig() }, @@ -124,7 +124,7 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { } static final AtomicLong requestCounter = new AtomicLong(); - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static Throwable getCause(Throwable t) { while (t instanceof CompletionException || t instanceof ExecutionException) { @@ -165,7 +165,8 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { throw new AssertionError(what + ": Unexpected exception: " + cause, cause); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting (%s, %s, %s) ----%n%n", uriString, version, config); ExecutorService executorService = Executors.newCachedThreadPool(); @@ -206,14 +207,14 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { responseCF = client.sendAsync(request, BodyHandlers.ofInputStream()) .thenApply((response) -> { out.println(si + ": Got response: " + response); - assertEquals(response.statusCode(), 200); - if (si >= head) assertEquals(response.version(), version); + assertEquals(200, response.statusCode()); + if (si >= head) assertEquals(version, response.version()); return response; }); bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(AsyncExecutorShutdown::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }); } catch (RejectedExecutionException x) { @@ -275,7 +276,8 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { CompletableFuture.allOf(bodies.toArray(new CompletableFuture[0])).get(); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting (%s, %s, %s) ----%n%n", uriString, version, config); ExecutorService executorService = Executors.newCachedThreadPool(); @@ -316,13 +318,13 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { responseCF = client.sendAsync(request, BodyHandlers.ofInputStream()) .thenApply((response) -> { out.println(si + ": Got response: " + response); - assertEquals(response.statusCode(), 200); - if (si > 0) assertEquals(response.version(), version); + assertEquals(200, response.statusCode()); + if (si > 0) assertEquals(version, response.version()); return response; }); bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(AsyncExecutorShutdown::readBody) - .thenApply((s) -> {assertEquals(s, MESSAGE); return s;}) + .thenApply((s) -> {assertEquals(MESSAGE, s); return s;}) .thenApply((s) -> {out.println(si + ": Got body: " + s); return s;}); } catch (RejectedExecutionException x) { out.println(i + ": Got expected exception: " + x); @@ -397,7 +399,7 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } static void shutdown(ExecutorService executorService) { @@ -409,8 +411,8 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); readerService = Executors.newCachedThreadPool(); @@ -445,8 +447,8 @@ public class AsyncExecutorShutdown implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.checkShutdown(5000); try { diff --git a/test/jdk/java/net/httpclient/AsyncShutdownNow.java b/test/jdk/java/net/httpclient/AsyncShutdownNow.java index 56b0378cf66..7dc13cf08e2 100644 --- a/test/jdk/java/net/httpclient/AsyncShutdownNow.java +++ b/test/jdk/java/net/httpclient/AsyncShutdownNow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * AsyncShutdownNow @@ -70,10 +70,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -84,10 +80,15 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class AsyncShutdownNow implements HttpServerAdapters { @@ -96,27 +97,26 @@ public class AsyncShutdownNow implements HttpServerAdapters { } static final Random RANDOM = RandomFactory.getRandom(); - ExecutorService readerService; + private static ExecutorService readerService; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) - HttpTestServer h3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h2h3Head; - String h3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) + private static HttpTestServer h3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h2h3Head; + private static String h3URI; static final String MESSAGE = "AsyncShutdownNow message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig()}, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig()}, @@ -168,11 +168,11 @@ public class AsyncShutdownNow implements HttpServerAdapters { out.println(step + ": Got response: " + response); out.printf("%s: expect status 200 and version %s (%s) for %s%n", step, version, config, response.request().uri()); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (step == 0 && version == HTTP_3 && firstVersionMayNotMatch) { out.printf("%s: version not checked%n", step); } else { - assertEquals(response.version(), version); + assertEquals(version, response.version()); out.printf("%s: got expected version %s%n", step, response.version()); } return this; @@ -185,7 +185,7 @@ public class AsyncShutdownNow implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } static boolean hasExpectedMessage(IOException io) { @@ -223,7 +223,8 @@ public class AsyncShutdownNow implements HttpServerAdapters { throw new AssertionError(what + ": Unexpected exception: " + cause, cause); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting concurrent (%s, %s, %s) ----%n%n", uriString, version, config); HttpClient client = newClientBuilderForH3() @@ -260,7 +261,7 @@ public class AsyncShutdownNow implements HttpServerAdapters { bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(AsyncShutdownNow::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }); long sleep = RANDOM.nextLong(5); @@ -320,7 +321,8 @@ public class AsyncShutdownNow implements HttpServerAdapters { return failed; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting sequential (%s, %s, %s) ----%n%n", uriString, version, config); @@ -354,7 +356,7 @@ public class AsyncShutdownNow implements HttpServerAdapters { bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(AsyncShutdownNow::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }) .thenApply((s) -> { @@ -403,8 +405,8 @@ public class AsyncShutdownNow implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); readerService = Executors.newCachedThreadPool(); @@ -439,8 +441,8 @@ public class AsyncShutdownNow implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.checkShutdown(5000); try { diff --git a/test/jdk/java/net/httpclient/AuthFilterCacheTest.java b/test/jdk/java/net/httpclient/AuthFilterCacheTest.java index 6d64caa1950..0d87055ff51 100644 --- a/test/jdk/java/net/httpclient/AuthFilterCacheTest.java +++ b/test/jdk/java/net/httpclient/AuthFilterCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,10 +40,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import com.sun.net.httpserver.HttpsServer; import jdk.httpclient.test.lib.common.TestServerConfigurator; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; @@ -54,7 +50,12 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -63,7 +64,7 @@ import static org.testng.Assert.*; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * DigestEchoServer ReferenceTracker jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm -Dtest.requiresHost=true + * @run junit/othervm -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=requests,headers,errors,quic * -Djdk.internal.httpclient.debug=false * AuthFilterCacheTest @@ -81,29 +82,28 @@ public class AuthFilterCacheTest implements HttpServerAdapters { SSLContext.setDefault(context); } - HttpTestServer http1Server; - HttpTestServer http2Server; - HttpTestServer https1Server; - HttpTestServer https2Server; - HttpTestServer h3onlyServer; - HttpTestServer h3altSvcServer; - DigestEchoServer.TunnelingProxy proxy; - URI http1URI; - URI https1URI; - URI http2URI; - URI https2URI; - URI h3onlyURI; - URI h3altSvcURI; - InetSocketAddress proxyAddress; - ProxySelector proxySelector; - MyAuthenticator auth; - HttpClient client; - ExecutorService serverExecutor = Executors.newCachedThreadPool(); - ExecutorService virtualExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual() + private static HttpTestServer http1Server; + private static HttpTestServer http2Server; + private static HttpTestServer https1Server; + private static HttpTestServer https2Server; + private static HttpTestServer h3onlyServer; + private static HttpTestServer h3altSvcServer; + private static DigestEchoServer.TunnelingProxy proxy; + private static URI http1URI; + private static URI https1URI; + private static URI http2URI; + private static URI https2URI; + private static URI h3onlyURI; + private static URI h3altSvcURI; + private static InetSocketAddress proxyAddress; + private static ProxySelector proxySelector; + private static MyAuthenticator auth; + private static HttpClient client; + private static ExecutorService serverExecutor = Executors.newCachedThreadPool(); + private static ExecutorService virtualExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual() .name("HttpClient-Worker", 0).factory()); - @DataProvider(name = "uris") - Object[][] testURIs() { + static Object[][] testURIs() { Object[][] uris = new Object[][]{ {List.of(http1URI.resolve("direct/orig/"), https1URI.resolve("direct/orig/"), @@ -117,8 +117,8 @@ public class AuthFilterCacheTest implements HttpServerAdapters { return uris; } - public HttpClient newHttpClient(ProxySelector ps, Authenticator auth) { - HttpClient.Builder builder = newClientBuilderForH3() + public static HttpClient newHttpClient(ProxySelector ps, Authenticator auth) { + HttpClient.Builder builder = HttpServerAdapters.createClientBuilderForH3() .executor(virtualExecutor) .sslContext(context) .authenticator(auth) @@ -126,8 +126,8 @@ public class AuthFilterCacheTest implements HttpServerAdapters { return builder.build(); } - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { try { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -189,8 +189,8 @@ public class AuthFilterCacheTest implements HttpServerAdapters { .version(HTTP_2).build(); System.out.println("Sending head request: " + headRequest); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(HTTP_2, headResponse.version()); System.out.println("Setup: done"); } catch (Exception x) { @@ -202,8 +202,8 @@ public class AuthFilterCacheTest implements HttpServerAdapters { } } - @AfterClass - public void tearDown() { + @AfterAll + public static void tearDown() { proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop); http1Server = stop(http1Server, HttpTestServer::stop); https1Server = stop(https1Server, HttpTestServer::stop); @@ -378,7 +378,8 @@ public class AuthFilterCacheTest implements HttpServerAdapters { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("testURIs") public void test(List uris) throws Exception { System.out.println("Servers listening at " + uris.stream().map(URI::toString) diff --git a/test/jdk/java/net/httpclient/BasicHTTP2Test.java b/test/jdk/java/net/httpclient/BasicHTTP2Test.java index 586673d62ab..4175aceea3d 100644 --- a/test/jdk/java/net/httpclient/BasicHTTP2Test.java +++ b/test/jdk/java/net/httpclient/BasicHTTP2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +27,7 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * ReferenceTracker - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * BasicHTTP2Test * @summary Basic HTTP/2 test when HTTP/3 is requested @@ -44,37 +44,40 @@ import java.net.http.HttpRequest; import java.net.http.HttpRequest.Builder; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.SSLContext; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; public class BasicHTTP2Test implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String https2URI; - DatagramSocket udp; + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static String https2URI; + private static DatagramSocket udp; // a shared executor helps reduce the amount of threads created by the test static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); @@ -91,8 +94,7 @@ public class BasicHTTP2Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -118,20 +120,37 @@ public class BasicHTTP2Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll static final void printFailedTests() { out.println("\n========================="); try { @@ -152,14 +171,6 @@ public class BasicHTTP2Test implements HttpServerAdapters { } } - private String[] uris() { - return new String[] { - https2URI, - }; - } - - static AtomicLong URICOUNT = new AtomicLong(); - private HttpClient makeNewClient() { clientCount.incrementAndGet(); HttpClient client = HttpClient.newBuilder() @@ -170,37 +181,6 @@ public class BasicHTTP2Test implements HttpServerAdapters { return TRACKER.track(client); } - HttpClient newHttpClient(boolean share) { - if (!share) return makeNewClient(); - HttpClient shared = sharedClient; - if (shared != null) return shared; - synchronized (this) { - shared = sharedClient; - if (shared == null) { - shared = sharedClient = makeNewClient(); - } - return shared; - } - } - - - static void checkStatus(int expected, int found) throws Exception { - if (expected != found) { - System.err.printf ("Test failed: wrong status code %d/%d\n", - expected, found); - throw new RuntimeException("Test failed"); - } - } - - static void checkStrings(String expected, String found) throws Exception { - if (!expected.equals(found)) { - System.err.printf ("Test failed: wrong string %s/%s\n", - expected, found); - throw new RuntimeException("Test failed"); - } - } - - @Test public void testH2() throws Exception { @@ -220,8 +200,8 @@ public class BasicHTTP2Test implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); - assertEquals(response.version(), HTTP_2, "first response version"); + assertEquals(200, response.statusCode(), "first response status"); + assertEquals(HTTP_2, response.version(), "first response version"); Thread.sleep(1000); @@ -232,16 +212,15 @@ public class BasicHTTP2Test implements HttpServerAdapters { response = client.send(request, BodyHandlers.ofString()); out.println("Response #2: " + response); out.println("Version #2: " + response.version()); - assertEquals(response.statusCode(), 200, "second response status"); - assertEquals(response.version(), HTTP_2, "second response version"); + assertEquals(200, response.statusCode(), "second response status"); + assertEquals(HTTP_2, response.version(), "second response version"); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/2 HttpTestHandler handler = new Handler(); - HttpTestHandler h3Handler = new Handler(); https2TestServer = HttpTestServer.create(HTTP_2, sslContext); https2TestServer.addHandler(handler, "/https2/test204/"); @@ -259,11 +238,8 @@ public class BasicHTTP2Test implements HttpServerAdapters { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { - String sharedClientName = - sharedClient == null ? null : sharedClient.toString(); - sharedClient = null; + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(500); try { @@ -271,10 +247,7 @@ public class BasicHTTP2Test implements HttpServerAdapters { https2TestServer.stop(); } finally { if (fail != null) { - if (sharedClientName != null) { - System.err.println("Shared client name is: " + sharedClientName); - } - throw fail; + throw fail; } } } diff --git a/test/jdk/java/net/httpclient/BasicHTTP3Test.java b/test/jdk/java/net/httpclient/BasicHTTP3Test.java index 4508b32e544..aec21e421f9 100644 --- a/test/jdk/java/net/httpclient/BasicHTTP3Test.java +++ b/test/jdk/java/net/httpclient/BasicHTTP3Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import java.net.http.HttpRequest; import java.net.http.HttpRequest.Builder; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; import java.util.List; import java.util.Optional; import java.util.Set; @@ -40,28 +39,32 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; import static java.lang.System.out; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -70,7 +73,7 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; * jdk.httpclient.test.lib.common.HttpServerAdapters * ReferenceTracker * jdk.httpclient.test.lib.quic.QuicStandaloneServer - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djavax.net.debug=all * BasicHTTP3Test @@ -79,20 +82,20 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; public class BasicHTTP3Test implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String https2URI; - HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) - String h3URI; - HttpTestServer h3qv2TestServer; // HTTP/2 ( h2 + h3 on Quic v2, incompatible nego) - String h3URIQv2; - HttpTestServer h3qv2CTestServer; // HTTP/2 ( h2 + h3 on Quic v2, compatible nego) - String h3URIQv2C; - HttpTestServer h3mtlsTestServer; // HTTP/2 ( h2 + h3), h3 requires client cert - String h3mtlsURI; - HttpTestServer h3TestServerWithRetry; // h3 - String h3URIRetry; - HttpTestServer h3TestServerWithTLSHelloRetry; // h3 - String h3URITLSHelloRetry; + static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + static String https2URI; + static HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) + static String h3URI; + static HttpTestServer h3qv2TestServer; // HTTP/2 ( h2 + h3 on Quic v2, incompatible nego) + static String h3URIQv2; + static HttpTestServer h3qv2CTestServer; // HTTP/2 ( h2 + h3 on Quic v2, compatible nego) + static String h3URIQv2C; + static HttpTestServer h3mtlsTestServer; // HTTP/2 ( h2 + h3), h3 requires client cert + static String h3mtlsURI; + static HttpTestServer h3TestServerWithRetry; // h3 + static String h3URIRetry; + static HttpTestServer h3TestServerWithTLSHelloRetry; // h3 + static String h3URITLSHelloRetry; static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test @@ -109,8 +112,8 @@ public class BasicHTTP3Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -136,21 +139,38 @@ public class BasicHTTP3Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass - static final void printFailedTests() { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { out.printf("%n%sCreated %d clients%n", @@ -170,18 +190,14 @@ public class BasicHTTP3Test implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { https2URI, h3URI }; } - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2 * 2][]; int i = 0; @@ -196,11 +212,7 @@ public class BasicHTTP3Test implements HttpServerAdapters { return result; } - @DataProvider(name = "h3URIs") - public Object[][] versions(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] versions() { Object[][] result = { {h3URI}, {h3URIRetry}, {h3URIQv2}, {h3URIQv2C}, @@ -233,9 +245,11 @@ public class BasicHTTP3Test implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient, Optional version) throws Exception { - System.out.println("Request to " + uri); + System.out.printf("%n%s-- test version=%s, sameClient=%s, uri=%s%n%n", + now(), version, sameClient, uri); HttpClient client = newHttpClient(sameClient); @@ -267,8 +281,10 @@ public class BasicHTTP3Test implements HttpServerAdapters { System.out.println("test: DONE"); } - @Test(dataProvider = "h3URIs") + @ParameterizedTest + @MethodSource("versions") public void testH3(final String h3URI) throws Exception { + System.out.printf("%n%s-- testH3 h3URI=%s%n%n", now(), h3URI); HttpClient client = makeNewClient(); URI uri = URI.create(h3URI); Builder builder = HttpRequest.newBuilder(uri) @@ -278,17 +294,17 @@ public class BasicHTTP3Test implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); - assertEquals(response.version(), HTTP_2, "first response version"); + assertEquals(200, response.statusCode(), "first response status"); + assertEquals(HTTP_2, response.version(), "first response version"); request = builder.version(Version.HTTP_3).build(); response = client.send(request, BodyHandlers.ofString()); out.println("Response #2: " + response); out.println("Version #2: " + response.version()); - assertEquals(response.statusCode(), 200, "second response status"); - assertEquals(response.version(), Version.HTTP_3, "second response version"); + assertEquals(200, response.statusCode(), "second response status"); + assertEquals(Version.HTTP_3, response.version(), "second response version"); - if (h3URI == h3mtlsURI) { + if (h3URI.equals(h3mtlsURI)) { assertNotNull(response.sslSession().get().getLocalCertificates()); } else { assertNull(response.sslSession().get().getLocalCertificates()); @@ -303,6 +319,7 @@ public class BasicHTTP3Test implements HttpServerAdapters { // verify that the client handles HTTP/3 reset stream correctly @Test public void testH3Reset() throws Exception { + System.out.printf("%n%s-- testH3Reset uri=%s%n%n", now(), h3URI); HttpClient client = makeNewClient(); URI uri = URI.create(h3URI); Builder builder = HttpRequest.newBuilder(uri) @@ -312,8 +329,8 @@ public class BasicHTTP3Test implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); - assertEquals(response.version(), HTTP_2, "first response version"); + assertEquals(200, response.statusCode(), "first response status"); + assertEquals(HTTP_2, response.version(), "first response version"); // instruct the server side handler to throw an exception // that then causes the test server to reset the stream @@ -341,8 +358,8 @@ public class BasicHTTP3Test implements HttpServerAdapters { if (error != null) throw error; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { https2TestServer = HttpTestServer.create(HTTP_2, sslContext); https2TestServer.addHandler(new Handler(), "/https2/test/"); https2URI = "https://" + https2TestServer.serverAuthority() + "/https2/test/x"; @@ -360,7 +377,7 @@ public class BasicHTTP3Test implements HttpServerAdapters { .enableH3AltServiceOnEphemeralPortWithVersion(QuicVersion.QUIC_V2, false); h3qv2TestServer = HttpTestServer.of(h2q2Server); h3qv2TestServer.addHandler(h3Handler, "/h3/testH3/"); - h3URIQv2 = "https://" + h3qv2TestServer.serverAuthority() + "/h3/testH3/h3qv2";; + h3URIQv2 = "https://" + h3qv2TestServer.serverAuthority() + "/h3/testH3/h3qv2"; assertTrue(h3qv2TestServer.canHandle(HTTP_2, Version.HTTP_3), "Server was expected" + " to handle both HTTP2 and HTTP3, but doesn't"); @@ -369,7 +386,7 @@ public class BasicHTTP3Test implements HttpServerAdapters { .enableH3AltServiceOnEphemeralPortWithVersion(QuicVersion.QUIC_V2, true); h3qv2CTestServer = HttpTestServer.of(h2q2CServer); h3qv2CTestServer.addHandler(h3Handler, "/h3/testH3/"); - h3URIQv2C = "https://" + h3qv2CTestServer.serverAuthority() + "/h3/testH3/h3qv2c";; + h3URIQv2C = "https://" + h3qv2CTestServer.serverAuthority() + "/h3/testH3/h3qv2c"; assertTrue(h3qv2CTestServer.canHandle(HTTP_2, Version.HTTP_3), "Server was expected" + " to handle both HTTP2 and HTTP3, but doesn't"); @@ -411,8 +428,8 @@ public class BasicHTTP3Test implements HttpServerAdapters { h3TestServerWithTLSHelloRetry.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("======================================================="); System.err.println(" Tearing down test"); System.err.println("======================================================="); diff --git a/test/jdk/java/net/httpclient/BasicRedirectTest.java b/test/jdk/java/net/httpclient/BasicRedirectTest.java index d79c39fe47a..d873a64bb1b 100644 --- a/test/jdk/java/net/httpclient/BasicRedirectTest.java +++ b/test/jdk/java/net/httpclient/BasicRedirectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Basic test for redirect and redirect policies * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=trace,headers,requests * -Djdk.internal.httpclient.debug=true * BasicRedirectTest @@ -49,10 +49,6 @@ import java.util.Optional; import java.util.stream.Collectors; import javax.net.ssl.SSLContext; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; @@ -61,39 +57,42 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BasicRedirectTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpURIToMoreSecure; // redirects HTTP to HTTPS - String httpURIToH3MoreSecure; // redirects HTTP to HTTPS/3 - String httpsURI; - String httpsURIToLessSecure; // redirects HTTPS to HTTP - String http2URI; - String http2URIToMoreSecure; // redirects HTTP to HTTPS - String http2URIToH3MoreSecure; // redirects HTTP to HTTPS/3 - String https2URI; - String https2URIToLessSecure; // redirects HTTPS to HTTP - String https3URI; - String https3HeadURI; - String http3URIToLessSecure; // redirects HTTP3 to HTTP - String http3URIToH2cLessSecure; // redirects HTTP3 to h2c + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpURIToMoreSecure; // redirects HTTP to HTTPS + private static String httpURIToH3MoreSecure; // redirects HTTP to HTTPS/3 + private static String httpsURI; + private static String httpsURIToLessSecure; // redirects HTTPS to HTTP + private static String http2URI; + private static String http2URIToMoreSecure; // redirects HTTP to HTTPS + private static String http2URIToH3MoreSecure; // redirects HTTP to HTTPS/3 + private static String https2URI; + private static String https2URIToLessSecure; // redirects HTTPS to HTTP + private static String https3URI; + private static String https3HeadURI; + private static String http3URIToLessSecure; // redirects HTTP3 to HTTP + private static String http3URIToH2cLessSecure; // redirects HTTP3 to h2c static final String MESSAGE = "Is fearr Gaeilge briste, na Bearla cliste"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { httpURI, Redirect.ALWAYS, Optional.empty() }, { httpsURI, Redirect.ALWAYS, Optional.empty() }, @@ -121,8 +120,8 @@ public class BasicRedirectTest implements HttpServerAdapters { }; } - HttpClient createClient(Redirect redirectPolicy, Optional version) throws Exception { - var clientBuilder = newClientBuilderForH3() + static HttpClient createClient(Redirect redirectPolicy, Optional version) throws Exception { + var clientBuilder = HttpServerAdapters.createClientBuilderForH3() .followRedirects(redirectPolicy) .sslContext(sslContext); HttpClient client = version.map(clientBuilder::version) @@ -135,23 +134,24 @@ public class BasicRedirectTest implements HttpServerAdapters { var get = builder.copy().GET().build(); out.printf("%n---- sending initial head request (%s) -----%n", head.uri()); var resp = client.send(head, BodyHandlers.ofString()); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.version(), HTTP_2); + assertEquals(200, resp.statusCode()); + assertEquals(HTTP_2, resp.version()); out.println("HEADERS: " + resp.headers()); var length = resp.headers().firstValueAsLong("Content-Length") .orElseThrow(AssertionError::new); if (length < 0) throw new AssertionError("negative length " + length); out.printf("%n---- sending initial HTTP/3 GET request (%s) -----%n", get.uri()); resp = client.send(get, BodyHandlers.ofString()); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.version(), HTTP_3); - assertEquals(resp.body().getBytes(UTF_8).length, length, + assertEquals(200, resp.statusCode()); + assertEquals(HTTP_3, resp.version()); + assertEquals(length, resp.body().getBytes(UTF_8).length, "body \"" + resp.body() + "\": "); } return client; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, Redirect redirectPolicy, Optional clientVersion) throws Exception { out.printf("%n---- starting positive (%s, %s, %s) ----%n", uriString, redirectPolicy, clientVersion.map(Version::name).orElse("empty")); @@ -169,8 +169,8 @@ public class BasicRedirectTest implements HttpServerAdapters { out.println(" Got body Path: " + response.body()); out.println(" Got response.request: " + response.request()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); // asserts redirected URI in response.request().uri() assertTrue(response.uri().getPath().endsWith("message")); assertPreviousRedirectResponses(request, response, clientVersion); @@ -193,7 +193,7 @@ public class BasicRedirectTest implements HttpServerAdapters { versions.add(response.version()); assertTrue(300 <= response.statusCode() && response.statusCode() <= 309, "Expected 300 <= code <= 309, got:" + response.statusCode()); - assertEquals(response.body(), null, "Unexpected body: " + response.body()); + assertEquals(null, response.body(), "Unexpected body: " + response.body()); String locationHeader = response.headers().firstValue("Location") .orElseThrow(() -> new RuntimeException("no previous Location")); assertTrue(uri.toString().endsWith(locationHeader), @@ -202,7 +202,7 @@ public class BasicRedirectTest implements HttpServerAdapters { } while (response.previousResponse().isPresent()); // initial - assertEquals(initialRequest, response.request(), + assertEquals(response.request(), initialRequest, String.format("Expected initial request [%s] to equal last prev req [%s]", initialRequest, response.request())); if (clientVersion.stream().anyMatch(HTTP_3::equals)) { @@ -214,8 +214,7 @@ public class BasicRedirectTest implements HttpServerAdapters { // -- negatives - @DataProvider(name = "negative") - public Object[][] negative() { + public static Object[][] negative() { return new Object[][] { { httpURI, Redirect.NEVER, Optional.empty() }, { httpsURI, Redirect.NEVER, Optional.empty() }, @@ -238,7 +237,8 @@ public class BasicRedirectTest implements HttpServerAdapters { }; } - @Test(dataProvider = "negative") + @ParameterizedTest + @MethodSource("negative") void testNegatives(String uriString, Redirect redirectPolicy, Optional clientVersion) throws Exception { out.printf("%n---- starting negative (%s, %s, %s) ----%n", uriString, redirectPolicy, @@ -257,8 +257,8 @@ public class BasicRedirectTest implements HttpServerAdapters { out.println(" Got body Path: " + response.body()); out.println(" Got response.request: " + response.request()); - assertEquals(response.statusCode(), 302); - assertEquals(response.body(), "XY"); + assertEquals(302, response.statusCode()); + assertEquals("XY", response.body()); // asserts original URI in response.request().uri() assertTrue(response.uri().equals(uri)); assertFalse(response.previousResponse().isPresent()); @@ -268,8 +268,8 @@ public class BasicRedirectTest implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new BasicHttpRedirectHandler(), "/http1/same/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/same/redirect"; @@ -325,8 +325,8 @@ public class BasicRedirectTest implements HttpServerAdapters { createClient(Redirect.NEVER, Optional.of(HTTP_3)); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/BodySubscribersTest.java b/test/jdk/java/net/httpclient/BodySubscribersTest.java index 21aa4ce3b17..abd86693b83 100644 --- a/test/jdk/java/net/httpclient/BodySubscribersTest.java +++ b/test/jdk/java/net/httpclient/BodySubscribersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +25,7 @@ * @test * @summary Basic test for the standard BodySubscribers default behavior * @bug 8225583 8334028 - * @run testng BodySubscribersTest + * @run junit BodySubscribersTest */ import java.net.http.HttpResponse.BodySubscriber; @@ -34,16 +34,18 @@ import java.nio.file.Path; import java.util.List; import java.util.concurrent.Flow; import java.util.function.Supplier; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpResponse.BodySubscribers.*; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.StandardOpenOption.CREATE; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.expectThrows; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BodySubscribersTest { @@ -78,8 +80,7 @@ public class BodySubscribersTest { @Override public void onComplete() { fail(); } } - @DataProvider(name = "bodySubscriberSuppliers") - public Object[][] bodySubscriberSuppliers() { ; + public static Object[][] bodySubscriberSuppliers() { ; List>> list = List.of( BSSupplier.create("ofByteArray", () -> ofByteArray()), BSSupplier.create("ofInputStream", () -> ofInputStream()), @@ -102,7 +103,8 @@ public class BodySubscribersTest { return list.stream().map(x -> new Object[] { x }).toArray(Object[][]::new); } - @Test(dataProvider = "bodySubscriberSuppliers") + @ParameterizedTest + @MethodSource("bodySubscriberSuppliers") void nulls(Supplier> bodySubscriberSupplier) { BodySubscriber bodySubscriber = bodySubscriberSupplier.get(); boolean subscribed = false; @@ -111,18 +113,18 @@ public class BodySubscribersTest { assertNotNull(bodySubscriber.getBody()); assertNotNull(bodySubscriber.getBody()); assertNotNull(bodySubscriber.getBody()); - expectThrows(NPE, () -> bodySubscriber.onSubscribe(null)); - expectThrows(NPE, () -> bodySubscriber.onSubscribe(null)); - expectThrows(NPE, () -> bodySubscriber.onSubscribe(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onSubscribe(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onSubscribe(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onSubscribe(null)); - expectThrows(NPE, () -> bodySubscriber.onNext(null)); - expectThrows(NPE, () -> bodySubscriber.onNext(null)); - expectThrows(NPE, () -> bodySubscriber.onNext(null)); - expectThrows(NPE, () -> bodySubscriber.onNext(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onNext(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onNext(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onNext(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onNext(null)); - expectThrows(NPE, () -> bodySubscriber.onError(null)); - expectThrows(NPE, () -> bodySubscriber.onError(null)); - expectThrows(NPE, () -> bodySubscriber.onError(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onError(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onError(null)); + Assertions.assertThrows(NPE, () -> bodySubscriber.onError(null)); if (!subscribed) { out.println("subscribing"); @@ -138,7 +140,8 @@ public class BodySubscribersTest { } while (true); } - @Test(dataProvider = "bodySubscriberSuppliers") + @ParameterizedTest + @MethodSource("bodySubscriberSuppliers") void subscribeMoreThanOnce(Supplier> bodySubscriberSupplier) { BodySubscriber bodySubscriber = bodySubscriberSupplier.get(); bodySubscriber.onSubscribe(new Flow.Subscription() { diff --git a/test/jdk/java/net/httpclient/BufferingSubscriberCancelTest.java b/test/jdk/java/net/httpclient/BufferingSubscriberCancelTest.java index a4c5bab55dc..4d73ec31280 100644 --- a/test/jdk/java/net/httpclient/BufferingSubscriberCancelTest.java +++ b/test/jdk/java/net/httpclient/BufferingSubscriberCancelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,33 +32,34 @@ import java.util.concurrent.SubmissionPublisher; import java.util.function.IntSupplier; import java.util.stream.IntStream; import java.net.http.HttpResponse.BodySubscriber; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.Long.MAX_VALUE; import static java.lang.Long.MIN_VALUE; import static java.lang.System.out; import static java.nio.ByteBuffer.wrap; import static java.util.concurrent.TimeUnit.SECONDS; import static java.net.http.HttpResponse.BodySubscribers.buffering; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @summary Direct test for HttpResponse.BodySubscriber.buffering() cancellation - * @run testng/othervm BufferingSubscriberCancelTest + * @run junit/othervm BufferingSubscriberCancelTest */ public class BufferingSubscriberCancelTest { - @DataProvider(name = "bufferSizes") - public Object[][] bufferSizes() { + public static Object[][] bufferSizes() { return new Object[][]{ // bufferSize should be irrelevant {1}, {100}, {511}, {512}, {513}, {1024}, {2047}, {2048} }; } - @Test(dataProvider = "bufferSizes") + @ParameterizedTest + @MethodSource("bufferSizes") public void cancelWithoutAnyItemsPublished(int bufferSize) throws Exception { ExecutorService executor = Executors.newFixedThreadPool(1); SubmissionPublisher> publisher = @@ -85,8 +86,7 @@ public class BufferingSubscriberCancelTest { executor.shutdown(); } - @DataProvider(name = "sizeAndItems") - public Object[][] sizeAndItems() { + public static Object[][] sizeAndItems() { return new Object[][] { // bufferSize and item bytes must be equal to count onNext calls // bufferSize items @@ -103,7 +103,8 @@ public class BufferingSubscriberCancelTest { }; } - @Test(dataProvider = "sizeAndItems") + @ParameterizedTest + @MethodSource("sizeAndItems") public void cancelWithItemsPublished(int bufferSize, List items) throws Exception { @@ -125,12 +126,13 @@ public class BufferingSubscriberCancelTest { IntStream.range(0, ITERATION_TIMES+1).forEach(x -> publisher.submit(items)); assertEqualsWithRetry(publisher::getNumberOfSubscribers, 0); - assertEquals(exposingSubscriber.onNextInvocations, ITERATION_TIMES); + assertEquals(ITERATION_TIMES, exposingSubscriber.onNextInvocations); executor.shutdown(); } // same as above but with more racy conditions, do not wait on the gate - @Test(dataProvider = "sizeAndItems") + @ParameterizedTest + @MethodSource("sizeAndItems") public void cancelWithItemsPublishedNoWait(int bufferSize, List items) throws Exception { @@ -212,6 +214,6 @@ public class BufferingSubscriberCancelTest { return; Thread.sleep(100); } - assertEquals(actual, expected); // will fail with the usual testng message + assertEquals(expected, actual); // will fail with the usual junit message } } diff --git a/test/jdk/java/net/httpclient/BufferingSubscriberErrorCompleteTest.java b/test/jdk/java/net/httpclient/BufferingSubscriberErrorCompleteTest.java index 5292f4b9860..255946232be 100644 --- a/test/jdk/java/net/httpclient/BufferingSubscriberErrorCompleteTest.java +++ b/test/jdk/java/net/httpclient/BufferingSubscriberErrorCompleteTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,30 +32,31 @@ import java.util.concurrent.Phaser; import java.util.concurrent.SubmissionPublisher; import java.util.stream.IntStream; import java.net.http.HttpResponse.BodySubscriber; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.Long.MAX_VALUE; import static java.lang.Long.MIN_VALUE; import static java.nio.ByteBuffer.wrap; import static java.net.http.HttpResponse.BodySubscribers.buffering; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @summary Test for HttpResponse.BodySubscriber.buffering() onError/onComplete - * @run testng/othervm BufferingSubscriberErrorCompleteTest + * @run junit/othervm BufferingSubscriberErrorCompleteTest */ public class BufferingSubscriberErrorCompleteTest { - @DataProvider(name = "illegalDemand") - public Object[][] illegalDemand() { + public static Object[][] illegalDemand() { return new Object[][]{ {0L}, {-1L}, {-5L}, {-100L}, {-101L}, {-100_001L}, {MIN_VALUE} }; } - @Test(dataProvider = "illegalDemand") + @ParameterizedTest + @MethodSource("illegalDemand") public void illegalRequest(long demand) throws Exception { ExecutorService executor = Executors.newFixedThreadPool(1); SubmissionPublisher> publisher = @@ -72,18 +73,17 @@ public class BufferingSubscriberErrorCompleteTest { s.request(demand); gate.arriveAndAwaitAdvance(); - assertEquals(previous + 1, exposingSubscriber.onErrorInvocations); + assertEquals(exposingSubscriber.onErrorInvocations, previous + 1); assertTrue(exposingSubscriber.throwable instanceof IllegalArgumentException, "Expected IAE, got:" + exposingSubscriber.throwable); furtherCancelsRequestsShouldBeNoOp(s); - assertEquals(exposingSubscriber.onErrorInvocations, 1); + assertEquals(1, exposingSubscriber.onErrorInvocations); executor.shutdown(); } - @DataProvider(name = "bufferAndItemSizes") - public Object[][] bufferAndItemSizes() { + public static Object[][] bufferAndItemSizes() { List values = new ArrayList<>(); for (int bufferSize : new int[] { 1, 5, 10, 100, 1000 }) @@ -93,7 +93,8 @@ public class BufferingSubscriberErrorCompleteTest { return values.stream().toArray(Object[][]::new); } - @Test(dataProvider = "bufferAndItemSizes") + @ParameterizedTest + @MethodSource("bufferAndItemSizes") public void onErrorFromPublisher(int bufferSize, int numberOfItems) throws Exception @@ -117,19 +118,19 @@ public class BufferingSubscriberErrorCompleteTest { Subscription s = exposingSubscriber.subscription; - assertEquals(exposingSubscriber.onErrorInvocations, 1); - assertEquals(exposingSubscriber.onCompleteInvocations, 0); - assertEquals(exposingSubscriber.throwable, t); - assertEquals(exposingSubscriber.throwable.getMessage(), - "a message from me to me"); + assertEquals(1, exposingSubscriber.onErrorInvocations); + assertEquals(0, exposingSubscriber.onCompleteInvocations); + assertEquals(t, exposingSubscriber.throwable); + assertEquals("a message from me to me", exposingSubscriber.throwable.getMessage()); furtherCancelsRequestsShouldBeNoOp(s); - assertEquals(exposingSubscriber.onErrorInvocations, 1); - assertEquals(exposingSubscriber.onCompleteInvocations, 0); + assertEquals(1, exposingSubscriber.onErrorInvocations); + assertEquals(0, exposingSubscriber.onCompleteInvocations); executor.shutdown(); } - @Test(dataProvider = "bufferAndItemSizes") + @ParameterizedTest + @MethodSource("bufferAndItemSizes") public void onCompleteFromPublisher(int bufferSize, int numberOfItems) throws Exception @@ -152,14 +153,14 @@ public class BufferingSubscriberErrorCompleteTest { Subscription s = exposingSubscriber.subscription; - assertEquals(exposingSubscriber.onErrorInvocations, 0); - assertEquals(exposingSubscriber.onCompleteInvocations, 1); - assertEquals(exposingSubscriber.throwable, null); + assertEquals(0, exposingSubscriber.onErrorInvocations); + assertEquals(1, exposingSubscriber.onCompleteInvocations); + assertEquals(null, exposingSubscriber.throwable); furtherCancelsRequestsShouldBeNoOp(s); - assertEquals(exposingSubscriber.onErrorInvocations, 0); - assertEquals(exposingSubscriber.onCompleteInvocations, 1); - assertEquals(exposingSubscriber.throwable, null); + assertEquals(0, exposingSubscriber.onErrorInvocations); + assertEquals(1, exposingSubscriber.onCompleteInvocations); + assertEquals(null, exposingSubscriber.throwable); executor.shutdown(); } diff --git a/test/jdk/java/net/httpclient/BufferingSubscriberTest.java b/test/jdk/java/net/httpclient/BufferingSubscriberTest.java index 6d15ba5d3a8..bb33b18ed9c 100644 --- a/test/jdk/java/net/httpclient/BufferingSubscriberTest.java +++ b/test/jdk/java/net/httpclient/BufferingSubscriberTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -38,14 +38,15 @@ import java.net.http.HttpResponse.BodyHandlers; import java.net.http.HttpResponse.BodySubscriber; import java.net.http.HttpResponse.BodySubscribers; import jdk.test.lib.RandomFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.Long.MAX_VALUE; -import static java.lang.Long.min; import static java.lang.System.out; import static java.util.concurrent.CompletableFuture.delayedExecutor; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -54,7 +55,7 @@ import static org.testng.Assert.*; * @key randomness * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=480 -Djdk.internal.httpclient.debug=true BufferingSubscriberTest + * @run junit/othervm/timeout=480 -Djdk.internal.httpclient.debug=true BufferingSubscriberTest */ public class BufferingSubscriberTest { @@ -80,37 +81,41 @@ public class BufferingSubscriberTest { time = time + ms + "ms"; out.println(what + "\t ["+time+"]\t "+ String.format(fmt,args)); } - @DataProvider(name = "negatives") - public Object[][] negatives() { + public static Object[][] negatives() { return new Object[][] { { 0 }, { -1 }, { -1000 } }; } - @Test(dataProvider = "negatives", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("negatives") public void subscriberThrowsIAE(int bufferSize) { - printStamp(START, "subscriberThrowsIAE(%d)", bufferSize); - try { - BodySubscriber bp = BodySubscribers.ofByteArray(); - BodySubscribers.buffering(bp, bufferSize); - } finally { - printStamp(END, "subscriberThrowsIAE(%d)", bufferSize); - } + Assertions.assertThrows(IllegalArgumentException.class, () -> { + printStamp(START, "subscriberThrowsIAE(%d)", bufferSize); + try { + BodySubscriber bp = BodySubscribers.ofByteArray(); + BodySubscribers.buffering(bp, bufferSize); + } finally { + printStamp(END, "subscriberThrowsIAE(%d)", bufferSize); + } + }); } - @Test(dataProvider = "negatives", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("negatives") public void handlerThrowsIAE(int bufferSize) { - printStamp(START, "handlerThrowsIAE(%d)", bufferSize); - try { - BodyHandler bp = BodyHandlers.ofByteArray(); - BodyHandlers.buffering(bp, bufferSize); - } finally { - printStamp(END, "handlerThrowsIAE(%d)", bufferSize); - } + Assertions.assertThrows(IllegalArgumentException.class, () -> { + printStamp(START, "handlerThrowsIAE(%d)", bufferSize); + try { + BodyHandler bp = BodyHandlers.ofByteArray(); + BodyHandlers.buffering(bp, bufferSize); + } finally { + printStamp(END, "handlerThrowsIAE(%d)", bufferSize); + } + }); } // --- - @DataProvider(name = "config") - public Object[][] config() { + public static Object[][] config() { return new Object[][] { // iterations delayMillis numBuffers bufferSize maxBufferSize minBufferSize { 1, 0, 1, 1, 2, 1 }, @@ -129,7 +134,8 @@ public class BufferingSubscriberTest { }; } - @Test(dataProvider = "config") + @ParameterizedTest + @MethodSource("config") public void test(int iterations, int delayMillis, int numBuffers, @@ -282,8 +288,8 @@ public class BufferingSubscriberTest { } count++; onNextInvocations++; - assertNotEquals(sz, 0L, "Unexpected empty buffers"); - items.stream().forEach(b -> assertEquals(b.position(), 0)); + assertNotEquals(0L, sz, "Unexpected empty buffers"); + items.stream().forEach(b -> assertEquals(0, b.position())); assertFalse(noMoreOnNext); if (sz != bufferSize) { @@ -296,20 +302,20 @@ public class BufferingSubscriberTest { "Possibly received last buffer: sz=%d, accumulated=%d, total=%d", sz, totalBytesReceived, totalBytesReceived + sz); } else { - assertEquals(sz, bufferSize, "Expected to receive exactly bufferSize"); + assertEquals(bufferSize, sz, "Expected to receive exactly bufferSize"); } lastSeenSize = sz; // Ensure expected contents for (ByteBuffer b : items) { while (b.hasRemaining()) { - assertEquals(b.get(), (byte) (index % 100)); + assertEquals((byte) (index % 100), b.get()); index++; } } totalBytesReceived += sz; - assertEquals(totalBytesReceived, index); + assertEquals(index, totalBytesReceived); if (delayMillis > 0 && ((expectedTotalSize - totalBytesReceived) > bufferSize)) delayedExecutor.execute(this::requestMore); else diff --git a/test/jdk/java/net/httpclient/CancelRequestTest.java b/test/jdk/java/net/httpclient/CancelRequestTest.java index 2a0ec19a0ed..df808ad2dab 100644 --- a/test/jdk/java/net/httpclient/CancelRequestTest.java +++ b/test/jdk/java/net/httpclient/CancelRequestTest.java @@ -29,7 +29,7 @@ * @key randomness * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * ReferenceTracker CancelRequestTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.enableAllMethodRetry=true * CancelRequestTest */ @@ -38,15 +38,6 @@ import jdk.internal.net.http.common.OperationTrackers.Tracker; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -61,7 +52,6 @@ import java.net.http.HttpOption.Http3DiscoveryMode; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Objects; @@ -76,7 +66,6 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import jdk.httpclient.test.lib.common.HttpServerAdapters; import static java.lang.System.out; @@ -85,10 +74,21 @@ import static java.net.http.HttpClient.Version.*; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CancelRequestTest implements HttpServerAdapters { @@ -97,19 +97,19 @@ public class CancelRequestTest implements HttpServerAdapters { = new ConcurrentHashMap<>(); private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) - HttpTestServer h3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h2h3Head; - String h3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) + private static HttpTestServer h3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h2h3Head; + private static String h3URI; static final long SERVER_LATENCY = 75; static final int MAX_CLIENT_DELAY = 75; @@ -130,8 +130,8 @@ public class CancelRequestTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -157,38 +157,39 @@ public class CancelRequestTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(CancelRequestTest::name, ITestResult::getThrowable)); - FAILURES.putAll(failed); try { out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); @@ -206,7 +207,7 @@ public class CancelRequestTest implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { httpURI, httpsURI, @@ -217,8 +218,7 @@ public class CancelRequestTest implements HttpServerAdapters { }; } - @DataProvider(name = "asyncurls") - public Object[][] asyncurls() { + public static Object[][] asyncurls() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2 * 3][]; //Object[][] result = new Object[uris.length][]; @@ -238,8 +238,7 @@ public class CancelRequestTest implements HttpServerAdapters { return result; } - @DataProvider(name = "urls") - public Object[][] alltests() { + public static Object[][] alltests() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; //Object[][] result = new Object[uris.length][]; @@ -327,7 +326,7 @@ public class CancelRequestTest implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } private static void releaseLatches() { @@ -348,10 +347,10 @@ public class CancelRequestTest implements HttpServerAdapters { return latch; } - @Test(dataProvider = "asyncurls") + @ParameterizedTest + @MethodSource("asyncurls") public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning) throws Exception { - checkSkip(); HttpClient client = null; uri = uri + "/get"; out.printf("%n%s testGetSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning); @@ -386,7 +385,7 @@ public class CancelRequestTest implements HttpServerAdapters { out.println("cf2 after cancel: " + cf2); try { String body = cf2.get().body(); - assertEquals(body, String.join("", BODY.split("\\|"))); + assertEquals(String.join("", BODY.split("\\|")), body); throw new AssertionError("Expected CancellationException not received"); } catch (ExecutionException x) { out.println(now() + "Got expected exception: " + x); @@ -409,7 +408,7 @@ public class CancelRequestTest implements HttpServerAdapters { // completed yet - so wait for it here... try { String body = response.get().body(); - assertEquals(body, String.join("", BODY.split("\\|"))); + assertEquals(String.join("", BODY.split("\\|")), body); if (mayInterruptIfRunning) { // well actually - this could happen... In which case we'll need to // increase the latency in the server handler... @@ -448,10 +447,10 @@ public class CancelRequestTest implements HttpServerAdapters { assertTrue(response.isDone()); assertFalse(response.isCancelled()); - assertEquals(cf1.isCancelled(), hasCancellationException); + assertEquals(hasCancellationException, cf1.isCancelled()); assertTrue(cf2.isDone()); assertFalse(cf2.isCancelled()); - assertEquals(latch.getCount(), 0); + assertEquals(0, latch.getCount()); var error = TRACKER.check(tracker, 1000, (t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0, @@ -464,10 +463,10 @@ public class CancelRequestTest implements HttpServerAdapters { if (!sameClient) client.close(); } - @Test(dataProvider = "asyncurls") + @ParameterizedTest + @MethodSource("asyncurls") public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning) throws Exception { - checkSkip(); uri = uri + "/post"; HttpClient client = null; out.printf("%n%s testPostSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning); @@ -521,7 +520,7 @@ public class CancelRequestTest implements HttpServerAdapters { out.println("cf2 after cancel: " + cf2); try { String body = cf2.get().body(); - assertEquals(body, String.join("", BODY.split("\\|"))); + assertEquals(String.join("", BODY.split("\\|")), body); throw new AssertionError("Expected CancellationException not received"); } catch (ExecutionException x) { out.println(now() + "Got expected exception: " + x); @@ -544,7 +543,7 @@ public class CancelRequestTest implements HttpServerAdapters { // completed yet - so wait for it here... try { String body = response.get().body(); - assertEquals(body, String.join("", BODY.split("\\|"))); + assertEquals(String.join("", BODY.split("\\|")), body); if (mayInterruptIfRunning) { // well actually - this could happen... In which case we'll need to // increase the latency in the server handler... @@ -577,10 +576,10 @@ public class CancelRequestTest implements HttpServerAdapters { assertTrue(response.isDone()); assertFalse(response.isCancelled()); - assertEquals(cf1.isCancelled(), hasCancellationException); + assertEquals(hasCancellationException, cf1.isCancelled()); assertTrue(cf2.isDone()); assertFalse(cf2.isCancelled()); - assertEquals(latch.getCount(), 0); + assertEquals(0, latch.getCount()); var error = TRACKER.check(tracker, 1000, (t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0, @@ -593,10 +592,10 @@ public class CancelRequestTest implements HttpServerAdapters { if (!sameClient) client.close(); } - @Test(dataProvider = "urls") + @ParameterizedTest + @MethodSource("alltests") public void testPostInterrupt(String uri, boolean sameClient) throws Exception { - checkSkip(); HttpClient client = null; out.printf("%n%s testPostInterrupt(%s, %b)%n", now(), uri, sameClient); for (int i=0; i< ITERATION_COUNT; i++) { @@ -661,7 +660,7 @@ public class CancelRequestTest implements HttpServerAdapters { } else { assert failed == null; out.println(now() + req.uri() + ": got body: " + body); - assertEquals(body, String.join("", BODY.split("\\|"))); + assertEquals(String.join("", BODY.split("\\|")), body); } out.println(now() + "next iteration"); @@ -678,8 +677,8 @@ public class CancelRequestTest implements HttpServerAdapters { - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_chunkHandler = new HTTPSlowHandler(); httpTestServer = HttpTestServer.create(HTTP_1_1); @@ -721,8 +720,8 @@ public class CancelRequestTest implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); sharedClient = null; diff --git a/test/jdk/java/net/httpclient/CancelStreamedBodyTest.java b/test/jdk/java/net/httpclient/CancelStreamedBodyTest.java index 0035a3f4302..48f23ebf370 100644 --- a/test/jdk/java/net/httpclient/CancelStreamedBodyTest.java +++ b/test/jdk/java/net/httpclient/CancelStreamedBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,19 +29,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * ReferenceTracker CancelStreamedBodyTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * CancelStreamedBodyTest */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -53,7 +44,6 @@ import java.net.http.HttpClient; import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; import java.net.http.HttpResponse.BodyHandlers; -import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -61,7 +51,6 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.httpclient.test.lib.common.HttpServerAdapters; @@ -72,23 +61,34 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CancelStreamedBodyTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String https3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String https3URI; static final long SERVER_LATENCY = 75; static final int ITERATION_COUNT = 3; @@ -108,8 +108,8 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -135,38 +135,40 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + + @AfterAll + static void printFailedTests() { out.println("\n========================="); - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - FAILURES.putAll(failed); try { out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); @@ -184,7 +186,7 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { https3URI, httpURI, @@ -195,8 +197,7 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { } - @DataProvider(name = "urls") - public Object[][] alltests() { + public static Object[][] alltests() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -265,10 +266,10 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { final static String BODY = "Some string |\n that ?\n can |\n be split ?\n several |\n ways."; - @Test(dataProvider = "urls") + @ParameterizedTest + @MethodSource("alltests") public void testAsLines(String uri, boolean sameClient) throws Exception { - checkSkip(); HttpClient client = null; uri = uri + "/testAsLines"; out.printf("%n%s testAsLines(%s, %b)%n", now(), uri, sameClient); @@ -284,8 +285,8 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { for (int j = 0; j < 2; j++) { try (Stream body = client.send(req, BodyHandlers.ofLines()).body()) { lines = body.limit(j).toList(); - assertEquals(lines, BODY.replaceAll("\\||\\?", "") - .lines().limit(j).toList()); + assertEquals(BODY.replaceAll("\\||\\?", "") + .lines().limit(j).toList(), lines); } // Only check our still alive client for outstanding operations // and outstanding subscribers here: it should have none. @@ -306,10 +307,10 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { } } - @Test(dataProvider = "urls") + @ParameterizedTest + @MethodSource("alltests") public void testInputStream(String uri, boolean sameClient) throws Exception { - checkSkip(); HttpClient client = null; uri = uri + "/testInputStream"; out.printf("%n%s testInputStream(%s, %b)%n", now(), uri, sameClient); @@ -326,7 +327,7 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { try (InputStream is = client.send(req, BodyHandlers.ofInputStream()).body()) { for (int k = 0; k < j; k++) { read = is.read(); - assertEquals(read, BODY.charAt(k)); + assertEquals(BODY.charAt(k), read); } } // Only check our still alive client for outstanding operations @@ -350,8 +351,8 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_chunkHandler = new HTTPSlowHandler(); httpTestServer = HttpTestServer.create(HTTP_1_1); @@ -385,8 +386,8 @@ public class CancelStreamedBodyTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); sharedClient = null; diff --git a/test/jdk/java/net/httpclient/CancelledPartialResponseTest.java b/test/jdk/java/net/httpclient/CancelledPartialResponseTest.java index bb190cfc348..33df36100ad 100644 --- a/test/jdk/java/net/httpclient/CancelledPartialResponseTest.java +++ b/test/jdk/java/net/httpclient/CancelledPartialResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +28,7 @@ * @bug 8309118 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm/timeout=40 -Djdk.internal.httpclient.debug=false -Djdk.httpclient.HttpClient.log=trace,errors,headers + * @run junit/othervm/timeout=40 -Djdk.internal.httpclient.debug=false -Djdk.httpclient.HttpClient.log=trace,errors,headers * CancelledPartialResponseTest */ @@ -47,11 +47,6 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.ResetFrame; import jdk.internal.net.http.http3.Http3Error; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.TestException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; @@ -74,16 +69,22 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.fail; + public class CancelledPartialResponseTest { - Http2TestServer http2TestServer; + private static Http2TestServer http2TestServer; - HttpTestServer http3TestServer; + private static HttpTestServer http3TestServer; // "NoError" urls complete with an exception. "NoError" or "Error" here refers to the error code in the RST_STREAM frame // and not the outcome of the test. - URI warmup, h2PartialResponseResetNoError, h2PartialResponseResetError, h2FullResponseResetNoError, h2FullResponseResetError; - URI h3PartialResponseStopSending, h3FullResponseStopSending; + private static URI warmup, h2PartialResponseResetNoError, h2PartialResponseResetError, h2FullResponseResetNoError, h2FullResponseResetError; + private static URI h3PartialResponseStopSending, h3FullResponseStopSending; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @@ -91,8 +92,7 @@ public class CancelledPartialResponseTest { static PrintStream out = System.out; // TODO: Investigate further if checking against HTTP/3 Full Response is necessary - @DataProvider(name = "testData") - public Object[][] testData() { + public static Object[][] testData() { return new Object[][] { { HTTP_2, h2PartialResponseResetNoError }, { HTTP_2, h2PartialResponseResetError }, // Checks RST_STREAM is processed if client sees no END_STREAM @@ -104,7 +104,8 @@ public class CancelledPartialResponseTest { } - @Test(dataProvider = "testData") + @ParameterizedTest + @MethodSource("testData") public void test(Version version, URI uri) { out.printf("\nTesting with Version: %s, URI: %s\n", version, uri.toASCIIString()); err.printf("\nTesting with Version: %s, URI: %s\n", version, uri.toASCIIString()); @@ -161,8 +162,8 @@ public class CancelledPartialResponseTest { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { http2TestServer = new Http2TestServer(false, 0); http3TestServer = HttpTestServer.create(Http3DiscoveryMode.HTTP_3_URI_ONLY, sslContext); @@ -187,8 +188,8 @@ public class CancelledPartialResponseTest { http3TestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { http2TestServer.stop(); } @@ -246,10 +247,10 @@ public class CancelledPartialResponseTest { switch (exchange.getRequestURI().getPath()) { case "/partialResponse/codeNoError" -> testExchange.addResetToOutputQ(ResetFrame.NO_ERROR); case "/partialResponse/codeError" -> testExchange.addResetToOutputQ(ResetFrame.PROTOCOL_ERROR); - default -> throw new TestException("Invalid Request Path"); + default -> fail("Invalid Request Path"); } } else { - throw new TestException("Wrong Exchange type used"); + fail("Wrong Exchange type used"); } } } @@ -268,10 +269,10 @@ public class CancelledPartialResponseTest { switch (exchange.getRequestURI().getPath()) { case "/fullResponse/codeNoError" -> testExchange.addResetToOutputQ(ResetFrame.NO_ERROR); case "/fullResponse/codeError" -> testExchange.addResetToOutputQ(ResetFrame.PROTOCOL_ERROR); - default -> throw new TestException("Invalid Request Path"); + default -> fail("Invalid Request Path"); } } else { - throw new TestException("Wrong Exchange type used"); + fail("Wrong Exchange type used"); } } } diff --git a/test/jdk/java/net/httpclient/CancelledResponse2.java b/test/jdk/java/net/httpclient/CancelledResponse2.java index 48223e84135..6604fadea20 100644 --- a/test/jdk/java/net/httpclient/CancelledResponse2.java +++ b/test/jdk/java/net/httpclient/CancelledResponse2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.OperationTrackers.Tracker; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -57,15 +53,20 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * @compile ReferenceTracker.java - * @run testng/othervm -Djdk.internal.httpclient.debug=true CancelledResponse2 + * @run junit/othervm -Djdk.internal.httpclient.debug=true CancelledResponse2 */ // -Djdk.internal.httpclient.debug=true public class CancelledResponse2 implements HttpServerAdapters { @@ -74,17 +75,16 @@ public class CancelledResponse2 implements HttpServerAdapters { private static final Random RANDOM = RandomFactory.getRandom(); private static final int MAX_CLIENT_DELAY = 160; - HttpTestServer h2TestServer; - URI h2TestServerURI; - URI h2h3TestServerURI; - URI h2h3HeadTestServerURI; - URI h3TestServerURI; - HttpTestServer h2h3TestServer; - HttpTestServer h3TestServer; + private static HttpTestServer h2TestServer; + private static URI h2TestServerURI; + private static URI h2h3TestServerURI; + private static URI h2h3HeadTestServerURI; + private static URI h3TestServerURI; + private static HttpTestServer h2h3TestServer; + private static HttpTestServer h3TestServer; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - @DataProvider(name = "versions") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][]{ { HTTP_2, null, h2TestServerURI }, { HTTP_3, null, h2h3TestServerURI }, @@ -101,7 +101,8 @@ public class CancelledResponse2 implements HttpServerAdapters { out.println("Unexpected exception: " + x); } } - @Test(dataProvider = "versions") + @ParameterizedTest + @MethodSource("positive") public void test(Version version, Http3DiscoveryMode config, URI uri) throws Exception { for (int i = 0; i < 5; i++) { HttpClient httpClient = newClientBuilderForH3().sslContext(sslContext).version(version).build(); @@ -147,11 +148,11 @@ public class CancelledResponse2 implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, HttpResponse.BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } - @BeforeTest - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { h2TestServer = HttpTestServer.create(HTTP_2, sslContext); h2TestServer.addHandler(new CancelledResponseHandler(), "/h2"); h2TestServerURI = URI.create("https://" + h2TestServer.serverAuthority() + "/h2"); @@ -172,8 +173,8 @@ public class CancelledResponse2 implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { h2TestServer.stop(); h2h3TestServer.stop(); h3TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/ConcurrentResponses.java b/test/jdk/java/net/httpclient/ConcurrentResponses.java index c44452bf4d2..53c85b8e383 100644 --- a/test/jdk/java/net/httpclient/ConcurrentResponses.java +++ b/test/jdk/java/net/httpclient/ConcurrentResponses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * ConcurrentResponses */ @@ -75,29 +75,30 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; import static java.net.http.HttpResponse.BodyHandlers.discarding; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ConcurrentResponses { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer https3TestServer; - String httpFixedURI, httpsFixedURI, httpChunkedURI, httpsChunkedURI; - String http2FixedURI, https2FixedURI, http2VariableURI, https2VariableURI; - String https3FixedURI, https3VariableURI; + private static HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer https3TestServer; + private static String httpFixedURI, httpsFixedURI, httpChunkedURI, httpsChunkedURI; + private static String http2FixedURI, https2FixedURI, http2VariableURI, https2VariableURI; + private static String https3FixedURI, https3VariableURI; static final int CONCURRENT_REQUESTS = 13; static final AtomicInteger IDS = new AtomicInteger(); @@ -131,7 +132,7 @@ public class ConcurrentResponses { */ static final CompletionStage> assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); return CompletableFuture.completedFuture(response); } @@ -141,12 +142,11 @@ public class ConcurrentResponses { */ static final CompletionStage> assertbody(HttpResponse response, T body) { - assertEquals(response.body(), body); + assertEquals(body, response.body()); return CompletableFuture.completedFuture(response); } - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpFixedURI }, { httpsFixedURI }, @@ -164,7 +164,8 @@ public class ConcurrentResponses { // The ofString implementation accumulates data, below a certain threshold // into the byte buffers it is given. - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsString(String uri) throws Exception { int id = IDS.getAndIncrement(); ExecutorService virtualExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual() @@ -204,7 +205,8 @@ public class ConcurrentResponses { // The custom subscriber aggressively attacks any area, between the limit // and the capacity, in the byte buffers it is given, by writing 'X' into it. - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testWithCustomSubscriber(String uri) throws Exception { int id = IDS.getAndIncrement(); ExecutorService virtualExecutor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual() @@ -301,8 +303,8 @@ public class ConcurrentResponses { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); httpTestServer = HttpServer.create(sa, 0); httpTestServer.createContext("/http1/fixed", new Http1FixedHandler()); @@ -342,8 +344,8 @@ public class ConcurrentResponses { https3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/ConnectExceptionTest.java b/test/jdk/java/net/httpclient/ConnectExceptionTest.java index 29ffeca7d5e..0745e2af934 100644 --- a/test/jdk/java/net/httpclient/ConnectExceptionTest.java +++ b/test/jdk/java/net/httpclient/ConnectExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @summary Expect ConnectException for all non-security related connect errors * @bug 8204864 - * @run testng/othervm -Djdk.net.hosts.file=HostFileDoesNotExist ConnectExceptionTest + * @run junit/othervm -Djdk.net.hosts.file=HostFileDoesNotExist ConnectExceptionTest */ import java.io.IOException; @@ -42,11 +42,12 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.util.List; import java.util.concurrent.ExecutionException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ConnectExceptionTest { @@ -64,8 +65,7 @@ public class ConnectExceptionTest { @Override public String toString() { return "NO_PROXY"; } }; - @DataProvider(name = "uris") - public Object[][] uris() { + public static Object[][] uris() { return new Object[][]{ { "http://test.invalid/", NO_PROXY }, { "https://test.invalid/", NO_PROXY }, @@ -74,7 +74,8 @@ public class ConnectExceptionTest { }; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") void testSynchronousGET(String uriString, ProxySelector proxy) throws Exception { out.printf("%n---%ntestSynchronousGET starting uri:%s, proxy:%s%n", uriString, proxy); HttpClient client = HttpClient.newBuilder().proxy(proxy).build(); @@ -90,7 +91,8 @@ public class ConnectExceptionTest { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") void testSynchronousPOST(String uriString, ProxySelector proxy) throws Exception { out.printf("%n---%ntestSynchronousPOST starting uri:%s, proxy:%s%n", uriString, proxy); HttpClient client = HttpClient.newBuilder().proxy(proxy).build(); @@ -108,7 +110,8 @@ public class ConnectExceptionTest { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") void testAsynchronousGET(String uriString, ProxySelector proxy) throws Exception { out.printf("%n---%ntestAsynchronousGET starting uri:%s, proxy:%s%n", uriString, proxy); HttpClient client = HttpClient.newBuilder().proxy(proxy).build(); @@ -129,7 +132,8 @@ public class ConnectExceptionTest { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") void testAsynchronousPOST(String uriString, ProxySelector proxy) throws Exception { out.printf("%n---%ntestAsynchronousPOST starting uri:%s, proxy:%s%n", uriString, proxy); HttpClient client = HttpClient.newBuilder().proxy(proxy).build(); diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeAsync.java b/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeAsync.java index 6cdaf594b1d..e1f4aee1d51 100644 --- a/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeAsync.java +++ b/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeAsync.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +23,9 @@ import java.net.http.HttpClient.Version; import java.time.Duration; -import org.testng.annotations.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -31,14 +33,15 @@ import org.testng.annotations.Test; * @bug 8208391 * @library /test/lib * @build AbstractConnectTimeoutHandshake - * @run testng/othervm ConnectTimeoutHandshakeAsync + * @run junit/othervm ConnectTimeoutHandshakeAsync */ public class ConnectTimeoutHandshakeAsync extends AbstractConnectTimeoutHandshake { - @Test(dataProvider = "variants") @Override + @ParameterizedTest + @MethodSource("variants") public void timeoutAsync(Version requestVersion, String method, Duration connectTimeout, diff --git a/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeSync.java b/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeSync.java index 17ea3041c5b..eb571b2d16c 100644 --- a/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeSync.java +++ b/test/jdk/java/net/httpclient/ConnectTimeoutHandshakeSync.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +23,9 @@ import java.net.http.HttpClient.Version; import java.time.Duration; -import org.testng.annotations.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -31,14 +33,15 @@ import org.testng.annotations.Test; * @bug 8208391 * @library /test/lib * @build AbstractConnectTimeoutHandshake - * @run testng/othervm ConnectTimeoutHandshakeSync + * @run junit/othervm ConnectTimeoutHandshakeSync */ public class ConnectTimeoutHandshakeSync extends AbstractConnectTimeoutHandshake { - @Test(dataProvider = "variants") @Override + @ParameterizedTest + @MethodSource("variants") public void timeoutSync(Version requestVersion, String method, Duration connectTimeout, diff --git a/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java b/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java index 75c7c984a6b..01c166dcb1b 100644 --- a/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java +++ b/test/jdk/java/net/httpclient/ContentLengthHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @bug 8283544 8358942 - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.allowRestrictedHeaders=content-length * -Djdk.internal.httpclient.debug=true * ContentLengthHeaderTest @@ -39,10 +39,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; @@ -59,19 +55,22 @@ import java.util.Optional; import javax.net.ssl.SSLContext; import jdk.test.lib.net.URIBuilder; - import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ContentLengthHeaderTest implements HttpServerAdapters { - final String NO_BODY_PATH = "/no_body"; - final String BODY_PATH = "/body"; + static final String NO_BODY_PATH = "/no_body"; + static final String BODY_PATH = "/body"; static HttpTestServer testContentLengthServerH1; static HttpTestServer testContentLengthServerH2; @@ -79,13 +78,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { static PrintStream testLog = System.err; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpClient hc; - URI testContentLengthURIH1; - URI testContentLengthURIH2; - URI testContentLengthURIH3; + private static HttpClient hc; + private static URI testContentLengthURIH1; + private static URI testContentLengthURIH2; + private static URI testContentLengthURIH3; - @BeforeTest - public void setup() throws IOException, URISyntaxException, InterruptedException { + @BeforeAll + public static void setup() throws IOException, URISyntaxException, InterruptedException { testContentLengthServerH1 = HttpTestServer.create(HTTP_1_1); testContentLengthServerH2 = HttpTestServer.create(HTTP_2, sslContext); testContentLengthServerH3 = HttpTestServer.create(HTTP_3, sslContext); @@ -128,7 +127,7 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { + testContentLengthServerH3.getH3AltService().get().getAddress()); testLog.println("Request URI for Client: " + testContentLengthURIH3); - hc = newClientBuilderForH3() + hc = HttpServerAdapters.createClientBuilderForH3() .proxy(HttpClient.Builder.NO_PROXY) .sslContext(sslContext) .build(); @@ -139,12 +138,12 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .build(); // populate alt-service registry var resp = hc.send(firstReq, BodyHandlers.ofString()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); testLog.println("**** setup done ****"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { testLog.println("**** tearing down ****"); if (testContentLengthServerH1 != null) testContentLengthServerH1.stop(); @@ -154,8 +153,7 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { testContentLengthServerH3.stop(); } - @DataProvider(name = "bodies") - Object[][] bodies() { + static Object[][] bodies() { return new Object[][]{ {HTTP_1_1, URI.create(testContentLengthURIH1 + BODY_PATH)}, {HTTP_2, URI.create(testContentLengthURIH2 + BODY_PATH)}, @@ -163,15 +161,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { }; } - @DataProvider(name = "h1body") - Object[][] h1body() { + static Object[][] h1body() { return new Object[][]{ {HTTP_1_1, URI.create(testContentLengthURIH1 + BODY_PATH)} }; } - @DataProvider(name = "nobodies") - Object[][] nobodies() { + static Object[][] nobodies() { return new Object[][]{ {HTTP_1_1, URI.create(testContentLengthURIH1 + NO_BODY_PATH)}, {HTTP_2, URI.create(testContentLengthURIH2 + NO_BODY_PATH)}, @@ -179,8 +175,9 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { }; } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A GET request with no request body should have no Content-length header + @MethodSource("nobodies") public void getWithNoBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking GET with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -189,12 +186,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A GET request with empty request body should have no Content-length header + @MethodSource("nobodies") public void getWithEmptyBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking GET with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -203,12 +201,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A GET request with empty request body and explicitly added Content-length header + @MethodSource("bodies") public void getWithZeroContentLength(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking GET with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -218,13 +217,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A GET request with a request body should have a Content-length header // in HTTP/1.1 + @MethodSource("bodies") public void getWithBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking GET with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -233,12 +233,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A DELETE request with no request body should have no Content-length header + @MethodSource("nobodies") public void deleteWithNoBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking DELETE with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -247,12 +248,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A DELETE request with empty request body should have no Content-length header + @MethodSource("nobodies") public void deleteWithEmptyBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking DELETE with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -261,13 +263,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A DELETE request with a request body should have a Content-length header // in HTTP/1.1 + @MethodSource("bodies") public void deleteWithBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking DELETE with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -276,12 +279,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A HEAD request with no request body should have no Content-length header + @MethodSource("nobodies") public void headWithNoBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking HEAD with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -290,12 +294,13 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "nobodies") + @ParameterizedTest // A HEAD request with empty request body should have no Content-length header + @MethodSource("nobodies") public void headWithEmptyBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking HEAD with no request body"); HttpRequest req = HttpRequest.newBuilder() @@ -304,13 +309,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A HEAD request with a request body should have a Content-length header // in HTTP/1.1 + @MethodSource("bodies") public void headWithBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking HEAD with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -321,13 +327,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { // Sending this request invokes sendResponseHeaders which emits a warning about including // a Content-length header with a HEAD request HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "h1body") + @ParameterizedTest // A POST request with empty request body should have a Content-length header // in HTTP/1.1 + @MethodSource("h1body") public void postWithEmptyBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking POST with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -336,13 +343,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A POST request with a request body should have a Content-length header // in HTTP/1.1 + @MethodSource("bodies") public void postWithBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking POST with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -351,13 +359,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "h1body") + @ParameterizedTest // A PUT request with empty request body should have a Content-length header // in HTTP/1.1 + @MethodSource("h1body") public void putWithEmptyBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking PUT with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -366,13 +375,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } - @Test(dataProvider = "bodies") + @ParameterizedTest // A PUT request with a request body should have a Content-length header // in HTTP/1.1 + @MethodSource("bodies") public void putWithBody(Version version, URI uri) throws IOException, InterruptedException { testLog.println(version + " Checking PUT with request body"); HttpRequest req = HttpRequest.newBuilder() @@ -381,8 +391,8 @@ public class ContentLengthHeaderTest implements HttpServerAdapters { .uri(uri) .build(); HttpResponse resp = hc.send(req, HttpResponse.BodyHandlers.ofString(UTF_8)); - assertEquals(resp.statusCode(), 200, resp.body()); - assertEquals(resp.version(), version); + assertEquals(200, resp.statusCode(), resp.body()); + assertEquals(version, resp.version()); } public static void handleResponse(long expected, HttpTestExchange ex, String body, int rCode) throws IOException { diff --git a/test/jdk/java/net/httpclient/CookieHeaderTest.java b/test/jdk/java/net/httpclient/CookieHeaderTest.java index cd47262825c..62e62680e03 100644 --- a/test/jdk/java/net/httpclient/CookieHeaderTest.java +++ b/test/jdk/java/net/httpclient/CookieHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,17 +27,13 @@ * @summary Test for multiple vs single cookie header for HTTP/2 vs HTTP/1.1 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.tls.acknowledgeCloseNotify=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * CookieHeaderTest */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; @@ -78,26 +74,31 @@ import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CookieHeaderTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - DummyServer httpDummyServer; - DummyServer httpsDummyServer; - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; - String httpDummy; - String httpsDummy; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static DummyServer httpDummyServer; + private static DummyServer httpsDummyServer; + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; + private static String httpDummy; + private static String httpsDummy; static final String MESSAGE = "Basic CookieHeaderTest message body"; static final int ITERATIONS = 3; @@ -110,8 +111,7 @@ public class CookieHeaderTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { httpURI, HTTP_1_1 }, { httpsURI, HTTP_1_1 }, @@ -129,7 +129,8 @@ public class CookieHeaderTest implements HttpServerAdapters { static final AtomicLong requestCounter = new AtomicLong(); - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, HttpClient.Version version) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); ConcurrentHashMap> cookieHeaders @@ -169,14 +170,15 @@ public class CookieHeaderTest implements HttpServerAdapters { + ", version=" + response.version()); out.println(" Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); - assertEquals(response.headers().allValues("X-Request-Cookie"), - cookies.stream() - .filter(s -> !s.startsWith("LOC")) - .collect(Collectors.toList())); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); + List expectedCookieList = cookies.stream() + .filter(s -> !s.startsWith("LOC")).toList(); + List actualCookieList = response.headers() + .allValues("X-Request-Cookie"); + assertEquals(expectedCookieList, actualCookieList); if (version == HTTP_3 && i > 0) { - assertEquals(response.version(), HTTP_3); + assertEquals(HTTP_3, response.version()); } requestBuilder = HttpRequest.newBuilder(uri) .header("X-uuid", "uuid-" + requestCounter.incrementAndGet()); @@ -192,8 +194,8 @@ public class CookieHeaderTest implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new CookieValidationHandler(), "/http1/cookie/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/cookie/retry"; @@ -228,8 +230,8 @@ public class CookieHeaderTest implements HttpServerAdapters { httpsDummyServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/CustomRequestPublisher.java b/test/jdk/java/net/httpclient/CustomRequestPublisher.java index f26def9a44c..c8d22419852 100644 --- a/test/jdk/java/net/httpclient/CustomRequestPublisher.java +++ b/test/jdk/java/net/httpclient/CustomRequestPublisher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Checks correct handling of Publishers that call onComplete without demand * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm CustomRequestPublisher + * @run junit/othervm CustomRequestPublisher */ import java.net.InetAddress; @@ -51,10 +51,6 @@ import java.net.http.HttpResponse; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; @@ -62,27 +58,31 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CustomRequestPublisher implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { Supplier fixedSupplier = () -> new FixedLengthBodyPublisher(); Supplier unknownSupplier = () -> new UnknownLengthBodyPublisher(); @@ -114,12 +114,12 @@ public class CustomRequestPublisher implements HttpServerAdapters { /** Asserts HTTP Version, and SSLSession presence when applicable. */ static void assertVersionAndSession(int step, HttpResponse response, String uri) { if (uri.contains("http2") || uri.contains("https2")) { - assertEquals(response.version(), HTTP_2); + assertEquals(HTTP_2, response.version()); } else if (uri.contains("http1") || uri.contains("https1")) { - assertEquals(response.version(), HTTP_1_1); + assertEquals(HTTP_1_1, response.version()); } else if (uri.contains("http3")) { - if (step == 0) assertNotEquals(response.version(), HTTP_1_1); - else assertEquals(response.version(), HTTP_3, + if (step == 0) assertNotEquals(HTTP_1_1, response.version()); + else assertEquals(HTTP_3, response.version(), "unexpected response version on step " + step); } else { fail("Unknown HTTP version in test for: " + uri); @@ -160,7 +160,8 @@ public class CustomRequestPublisher implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uri, Supplier bpSupplier, boolean sameClient) throws Exception { @@ -180,13 +181,14 @@ public class CustomRequestPublisher implements HttpServerAdapters { out.println("Got body: " + resp.body()); assertTrue(resp.statusCode() == 200, "Expected 200, got:" + resp.statusCode()); - assertEquals(resp.body(), bodyPublisher.bodyAsString()); + assertEquals(bodyPublisher.bodyAsString(), resp.body()); assertVersionAndSession(i, resp, uri); } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uri, Supplier bpSupplier, boolean sameClient) throws Exception { @@ -207,7 +209,7 @@ public class CustomRequestPublisher implements HttpServerAdapters { out.println("Got body: " + resp.body()); assertTrue(resp.statusCode() == 200, "Expected 200, got:" + resp.statusCode()); - assertEquals(resp.body(), bodyPublisher.bodyAsString()); + assertEquals(bodyPublisher.bodyAsString(), resp.body()); assertVersionAndSession(0, resp, uri); } @@ -337,8 +339,8 @@ public class CustomRequestPublisher implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new HttpTestEchoHandler(), "/http1/echo"); @@ -367,8 +369,8 @@ public class CustomRequestPublisher implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/CustomResponseSubscriber.java b/test/jdk/java/net/httpclient/CustomResponseSubscriber.java index c581491a214..b2695271035 100644 --- a/test/jdk/java/net/httpclient/CustomResponseSubscriber.java +++ b/test/jdk/java/net/httpclient/CustomResponseSubscriber.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm CustomResponseSubscriber + * @run junit/othervm CustomResponseSubscriber */ import java.io.IOException; @@ -59,37 +59,37 @@ import jdk.httpclient.test.lib.http2.Http2Handler; import javax.net.ssl.SSLContext; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CustomResponseSubscriber { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; + private static HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; static final int ITERATION_COUNT = 10; // a shared executor helps reduce the amount of threads created by the test static final Executor executor = Executors.newCachedThreadPool(); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI_fixed, false }, { httpURI_chunk, false }, @@ -118,7 +118,8 @@ public class CustomResponseSubscriber { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsString(String uri, boolean sameClient) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -130,14 +131,14 @@ public class CustomResponseSubscriber { BodyHandler handler = new CRSBodyHandler(); HttpResponse response = client.send(req, handler); String body = response.body(); - assertEquals(body, ""); + assertEquals("", body); } } static class CRSBodyHandler implements BodyHandler { @Override public BodySubscriber apply(HttpResponse.ResponseInfo rinfo) { - assertEquals(rinfo.statusCode(), 200); + assertEquals(200, rinfo.statusCode()); return new CRSBodySubscriber(); } } @@ -185,8 +186,8 @@ public class CustomResponseSubscriber { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpHandler h1_fixedLengthHandler = new HTTP1_FixedLengthHandler(); HttpHandler h1_chunkHandler = new HTTP1_ChunkedHandler(); @@ -226,8 +227,8 @@ public class CustomResponseSubscriber { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/DependentActionsTest.java b/test/jdk/java/net/httpclient/DependentActionsTest.java index 9a77d377497..fcfbb393e5a 100644 --- a/test/jdk/java/net/httpclient/DependentActionsTest.java +++ b/test/jdk/java/net/httpclient/DependentActionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * DependentActionsTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.quic.maxPtoBackoff=9 * DependentActionsTest */ @@ -39,12 +39,6 @@ import java.io.InputStreamReader; import java.lang.StackWalker.StackFrame; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.SkipException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -89,28 +83,35 @@ import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DependentActionsTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; - String http3URI_head; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; + private static String http3URI_head; static final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); @@ -132,7 +133,7 @@ public class DependentActionsTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -158,7 +159,7 @@ public class DependentActionsTest implements HttpServerAdapters { } } - @AfterClass + @AfterAll static final void printFailedTests() { out.println("\n========================="); try { @@ -179,7 +180,7 @@ public class DependentActionsTest implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { httpURI_fixed, httpURI_chunk, @@ -206,8 +207,7 @@ public class DependentActionsTest implements HttpServerAdapters { } } - @DataProvider(name = "noStalls") - public Object[][] noThrows() { + public static Object[][] noThrows() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -220,8 +220,7 @@ public class DependentActionsTest implements HttpServerAdapters { return result; } - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -237,20 +236,21 @@ public class DependentActionsTest implements HttpServerAdapters { return result; } - private HttpClient makeNewClient() { + private static HttpClient makeNewClient() { clientCount.incrementAndGet(); - return newClientBuilderForH3() + return HttpServerAdapters.createClientBuilderForH3() .proxy(Builder.NO_PROXY) .executor(executor) .sslContext(sslContext) .build(); } - HttpClient newHttpClient(boolean share) { + private static final Object zis = new Object(); + static HttpClient newHttpClient(boolean share) { if (!share) return makeNewClient(); HttpClient shared = sharedClient; if (shared != null) return shared; - synchronized (this) { + synchronized (zis) { shared = sharedClient; if (shared == null) { shared = sharedClient = makeNewClient(); @@ -259,7 +259,8 @@ public class DependentActionsTest implements HttpServerAdapters { } } - @Test(dataProvider = "noStalls") + @ParameterizedTest + @MethodSource("noThrows") public void testNoStalls(String uri, boolean sameClient) throws Exception { HttpClient client = null; @@ -279,11 +280,12 @@ public class DependentActionsTest implements HttpServerAdapters { BodyHandlers.ofString()); HttpResponse response = client.send(req, handler); String body = response.body(); - assertEquals(URI.create(body).getPath(), URI.create(uri).getPath()); + assertEquals(URI.create(uri).getPath(), URI.create(body).getPath()); } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsStringAsync(String uri, boolean sameClient, Supplier s) @@ -296,7 +298,8 @@ public class DependentActionsTest implements HttpServerAdapters { this::finish, this::extractString, staller); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsLinesAsync(String uri, boolean sameClient, Supplier s) @@ -309,7 +312,8 @@ public class DependentActionsTest implements HttpServerAdapters { this::finish, this::extractStream, staller); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsInputStreamAsync(String uri, boolean sameClient, Supplier s) @@ -329,11 +333,8 @@ public class DependentActionsTest implements HttpServerAdapters { Staller staller) throws Exception { - if (errorRef.get() != null) { - SkipException sk = new SkipException("skipping due to previous failure: " + name); - sk.setStackTrace(new StackTraceElement[0]); - throw sk; - } + Assumptions.assumeTrue(errorRef.get() == null, + "skipping due to previous failure: " + name); out.printf("%n%s%s%n", now(), name); try { testDependent(uri, sameClient, handlers, finisher, extractor, staller); @@ -376,7 +377,7 @@ public class DependentActionsTest implements HttpServerAdapters { // it's possible that the first request still went through HTTP/2 // if the config was HTTP3_ANY. Retry it - the next time we should // have HTTP/3 - assertEquals(resp.version(), HTTP_3, + assertEquals(HTTP_3, resp.version(), "expected second request to go through HTTP/3 (serverConfig=" + http3TestServer.h3DiscoveryConfig() + ")"); } @@ -479,10 +480,10 @@ public class DependentActionsTest implements HttpServerAdapters { throw new RuntimeException("Test failed in " + w + ": " + response, error); } - assertEquals(result, List.of(response.request().uri().getPath())); + assertEquals(List.of(response.request().uri().getPath()), result); var uriStr = response.request().uri().toString(); if (HTTP_3 != version(uriStr) || http3TestServer.h3DiscoveryConfig() != Http3DiscoveryMode.ANY) { - assertEquals(response.version(), version(uriStr), uriStr); + assertEquals(version(uriStr), response.version(), uriStr); } return response; } finally { @@ -619,7 +620,7 @@ public class DependentActionsTest implements HttpServerAdapters { return null; } - HttpRequest.Builder newRequestBuilder(String uri) { + static HttpRequest.Builder newRequestBuilder(String uri) { var builder = HttpRequest.newBuilder(URI.create(uri)); if (version(uri) == HTTP_3) { builder.version(HTTP_3); @@ -628,21 +629,21 @@ public class DependentActionsTest implements HttpServerAdapters { return builder; } - HttpResponse headRequest(HttpClient client) + static HttpResponse headRequest(HttpClient client) throws IOException, InterruptedException { var request = newRequestBuilder(http3URI_head) .HEAD().version(HTTP_2).build(); var response = client.send(request, BodyHandlers.ofString()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_2); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_2, response.version()); System.out.println("\n--- HEAD request succeeded ----\n"); System.err.println("\n--- HEAD request succeeded ----\n"); return response; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler(); HttpTestHandler h1_chunkHandler = new HTTP_ChunkedHandler(); @@ -703,8 +704,8 @@ public class DependentActionsTest implements HttpServerAdapters { headRequest(newHttpClient(true)); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient = null; httpTestServer.stop(); httpsTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java b/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java index f1b07f7abce..e045f4e22f1 100644 --- a/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java +++ b/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * DependentPromiseActionsTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true DependentPromiseActionsTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true DependentPromiseActionsTest */ import java.io.BufferedReader; @@ -37,11 +37,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStreamReader; import java.lang.StackWalker.StackFrame; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -93,21 +88,26 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DependentPromiseActionsTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; static final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); @@ -129,7 +129,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -155,7 +155,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { } } - @AfterClass + @AfterAll static final void printFailedTests() { out.println("\n========================="); try { @@ -176,7 +176,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { http3URI_fixed, http3URI_chunk, @@ -201,8 +201,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { } } - @DataProvider(name = "noStalls") - public Object[][] noThrows() { + public static Object[][] noThrows() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -215,8 +214,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { return result; } - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -271,7 +269,8 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { return builder.build(); } - @Test(dataProvider = "noStalls") + @ParameterizedTest + @MethodSource("noThrows") public void testNoStalls(String rootUri, boolean sameClient) throws Exception { if (!FAILURES.isEmpty()) return; @@ -287,7 +286,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { HttpRequest req = request(uri); BodyHandler> handler = - new StallingBodyHandler((w) -> {}, + new StallingBodyHandler<>((w) -> {}, BodyHandlers.ofLines()); Map>>> pushPromises = new ConcurrentHashMap<>(); @@ -304,13 +303,13 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { HttpResponse> response = client.sendAsync(req, BodyHandlers.ofLines(), pushHandler).get(); String body = response.body().collect(Collectors.joining("|")); - assertEquals(URI.create(body).getPath(), URI.create(uri).getPath()); + assertEquals(URI.create(uri).getPath(), URI.create(body).getPath()); for (HttpRequest promised : pushPromises.keySet()) { out.printf("%s Received promise: %s%n\tresponse: %s%n", now(), promised, pushPromises.get(promised).get()); String promisedBody = pushPromises.get(promised).get().body() .collect(Collectors.joining("|")); - assertEquals(promisedBody, promised.uri().toASCIIString()); + assertEquals(promised.uri().toASCIIString(), promisedBody); } assertEquals(3, pushPromises.size()); } @@ -321,8 +320,9 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testAsStringAsync(String uri, + @ParameterizedTest + @MethodSource("variants") + void testAsStringAsync(String uri, boolean sameClient, Supplier stallers) throws Exception @@ -334,8 +334,9 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { SubscriberType.EAGER); } - @Test(dataProvider = "variants") - public void testAsLinesAsync(String uri, + @ParameterizedTest + @MethodSource("variants") + void testAsLinesAsync(String uri, boolean sameClient, Supplier stallers) throws Exception @@ -347,8 +348,9 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { SubscriberType.LAZZY); } - @Test(dataProvider = "variants") - public void testAsInputStreamAsync(String uri, + @ParameterizedTest + @MethodSource("variants") + void testAsInputStreamAsync(String uri, boolean sameClient, Supplier stallers) throws Exception @@ -362,7 +364,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { private void testDependent(String name, String uri, boolean sameClient, Supplier> handlers, - Finisher finisher, + Finisher finisher, Extractor extractor, Supplier stallers, SubscriberType subscriberType) @@ -384,7 +386,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { private void testDependent(String rootUri, boolean sameClient, Supplier> handlers, - Finisher finisher, + Finisher finisher, Extractor extractor, Supplier stallers, SubscriberType subscriberType) @@ -424,7 +426,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { enum Where { ON_PUSH_PROMISE, BODY_HANDLER, ON_SUBSCRIBE, ON_NEXT, ON_COMPLETE, ON_ERROR, GET_BODY, BODY_CF; public Consumer select(Consumer consumer) { - return new Consumer() { + return new Consumer<>() { @Override public void accept(Where where) { if (Where.this == where) { @@ -475,10 +477,10 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { staller.acquire(); assert staller.willStall(); try { - BodyHandler handler = new StallingBodyHandler<>( + BodyHandler handler = new StallingBodyHandler<>( where.select(staller), handlers.get()); CompletableFuture> cf = acceptor.apply(handler); - Tuple tuple = new Tuple(failed, cf, staller); + Tuple tuple = new Tuple<>(failed, cf, staller); promiseMap.putIfAbsent(pushPromiseRequest, tuple); CompletableFuture done = cf.whenComplete( (r, t) -> checkThreadAndStack(thread, failed, r, t)); @@ -567,7 +569,7 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { throw new RuntimeException("Test failed in " + w + ": " + uri, error); } - assertEquals(result, List.of(response.request().uri().toASCIIString())); + assertEquals(List.of(response.request().uri().toASCIIString()), result); } finally { staller.reset(); } @@ -582,10 +584,10 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { for (HttpRequest req : ph.promiseMap.keySet()) { finish(w, ph.promiseMap.get(req), extractor); } - assertEquals(ph.promiseMap.size(), 3, + assertEquals(3, ph.promiseMap.size(), "Expected 3 push promises for " + w + " in " + response.request().uri()); - assertEquals(result, List.of(response.request().uri().toASCIIString())); + assertEquals(List.of(response.request().uri().toASCIIString()), result); } @@ -699,8 +701,8 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/2 HttpTestHandler fixedLengthHandler = new HTTP_FixedLengthHandler(); HttpTestHandler chunkedHandler = new HTTP_ChunkedHandler(); @@ -729,8 +731,8 @@ public class DependentPromiseActionsTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { if (sharedClient != null) { sharedClient.close(); } diff --git a/test/jdk/java/net/httpclient/EncodedCharsInURI.java b/test/jdk/java/net/httpclient/EncodedCharsInURI.java index eab9a29b172..19b0a1d651b 100644 --- a/test/jdk/java/net/httpclient/EncodedCharsInURI.java +++ b/test/jdk/java/net/httpclient/EncodedCharsInURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * EncodedCharsInURI - * @run testng/othervm + * @run junit/othervm * -Djdk.tls.acknowledgeCloseNotify=true * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=headers,errors EncodedCharsInURI @@ -38,11 +38,6 @@ import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; @@ -83,32 +78,37 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class EncodedCharsInURI implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - DummyServer httpDummyServer; // HTTP/1.1 [ 2 servers ] - DummyServer httpsDummyServer; // HTTPS/1.1 - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; - String http3URI_head; - String httpDummy; - String httpsDummy; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static DummyServer httpDummyServer; // HTTP/1.1 [ 2 servers ] + private static DummyServer httpsDummyServer; // HTTPS/1.1 + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; + private static String http3URI_head; + private static String httpDummy; + private static String httpsDummy; static final int ITERATION_COUNT = 1; // a shared executor helps reduce the amount of threads created by the test @@ -126,7 +126,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -152,7 +152,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { } } - @AfterClass + @AfterAll static final void printFailedTests() { out.println("\n========================="); try { @@ -172,7 +172,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { httpDummy, httpsDummy, @@ -189,8 +189,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { }; } - @DataProvider(name = "noThrows") - public Object[][] noThrows() { + public static Object[][] noThrows() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; //Object[][] result = new Object[uris.length][]; @@ -216,7 +215,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { return null; } - HttpRequest.Builder newRequestBuilder(String uri) { + static HttpRequest.Builder newRequestBuilder(String uri) { var builder = HttpRequest.newBuilder(URI.create(uri)); if (version(uri) == HTTP_3) { builder.version(HTTP_3); @@ -225,7 +224,7 @@ public class EncodedCharsInURI implements HttpServerAdapters { return builder; } - HttpResponse headRequest(HttpClient client) + static HttpResponse headRequest(HttpClient client) throws IOException, InterruptedException { out.println("\n" + now() + "--- Sending HEAD request ----\n"); @@ -234,27 +233,28 @@ public class EncodedCharsInURI implements HttpServerAdapters { var request = newRequestBuilder(http3URI_head) .HEAD().version(HTTP_2).build(); var response = client.send(request, BodyHandlers.ofString()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_2); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_2, response.version()); out.println("\n" + now() + "--- HEAD request succeeded ----\n"); err.println("\n" + now() + "--- HEAD request succeeded ----\n"); return response; } - private HttpClient makeNewClient() { + private static HttpClient makeNewClient() { clientCount.incrementAndGet(); - return newClientBuilderForH3() + return HttpServerAdapters.createClientBuilderForH3() .executor(executor) .proxy(NO_PROXY) .sslContext(sslContext) .build(); } - HttpClient newHttpClient(boolean share) { + private static final Object zis = new Object(); + static HttpClient newHttpClient(boolean share) { if (!share) return makeNewClient(); HttpClient shared = sharedClient; if (shared != null) return shared; - synchronized (this) { + synchronized (zis) { shared = sharedClient; if (shared == null) { shared = sharedClient = makeNewClient(); @@ -273,7 +273,8 @@ public class EncodedCharsInURI implements HttpServerAdapters { } } - @Test(dataProvider = "noThrows") + @ParameterizedTest + @MethodSource("noThrows") public void testEncodedChars(String uri, boolean sameClient) throws Exception { HttpClient client = null; @@ -302,13 +303,13 @@ public class EncodedCharsInURI implements HttpServerAdapters { } else { out.println("Found expected " + body + " in " + uri); } - assertEquals(response.version(), version(uri)); + assertEquals(version(uri), response.version()); } } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println(now() + "begin setup"); // HTTP/1.1 @@ -387,8 +388,8 @@ public class EncodedCharsInURI implements HttpServerAdapters { err.println(now() + "setup done"); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient.close(); httpTestServer.stop(); httpsTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/EscapedOctetsInURI.java b/test/jdk/java/net/httpclient/EscapedOctetsInURI.java index abb0d7d8541..6ef71b7d22d 100644 --- a/test/jdk/java/net/httpclient/EscapedOctetsInURI.java +++ b/test/jdk/java/net/httpclient/EscapedOctetsInURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * @bug 8198716 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=reqeusts,headers * EscapedOctetsInURI */ @@ -52,10 +52,6 @@ import java.util.List; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.err; import static java.lang.System.out; @@ -65,24 +61,29 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class EscapedOctetsInURI implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; - String http3URI_head; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; + private static String http3URI_head; - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; static final String[][] pathsAndQueryStrings = new String[][] { // partial-path URI query @@ -95,8 +96,7 @@ public class EscapedOctetsInURI implements HttpServerAdapters { { "/012/with%20space", "?target=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody" }, }; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { List list = new ArrayList<>(); for (boolean sameClient : new boolean[] { false, true }) { @@ -140,7 +140,7 @@ public class EscapedOctetsInURI implements HttpServerAdapters { return null; } - HttpRequest.Builder newRequestBuilder(String uri) { + static HttpRequest.Builder newRequestBuilder(String uri) { var builder = HttpRequest.newBuilder(URI.create(uri)); if (version(uri) == HTTP_3) { builder.version(HTTP_3); @@ -149,7 +149,7 @@ public class EscapedOctetsInURI implements HttpServerAdapters { return builder; } - HttpResponse headRequest(HttpClient client) + static HttpResponse headRequest(HttpClient client) throws IOException, InterruptedException { out.println("\n" + now() + "--- Sending HEAD request ----\n"); @@ -158,25 +158,26 @@ public class EscapedOctetsInURI implements HttpServerAdapters { var request = newRequestBuilder(http3URI_head) .HEAD().version(HTTP_2).build(); var response = client.send(request, BodyHandlers.ofString()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_2); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_2, response.version()); out.println("\n" + now() + "--- HEAD request succeeded ----\n"); err.println("\n" + now() + "--- HEAD request succeeded ----\n"); return response; } - private HttpClient makeNewClient() { - return newClientBuilderForH3() + private static HttpClient makeNewClient() { + return HttpServerAdapters.createClientBuilderForH3() .proxy(NO_PROXY) .sslContext(sslContext) .build(); } - HttpClient newHttpClient(boolean share) { + private static final Object zis = new Object(); + static HttpClient newHttpClient(boolean share) { if (!share) return makeNewClient(); HttpClient shared = sharedClient; if (shared != null) return shared; - synchronized (this) { + synchronized (zis) { shared = sharedClient; if (shared == null) { shared = sharedClient = makeNewClient(); @@ -193,7 +194,8 @@ public class EscapedOctetsInURI implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uriString, boolean sameClient) throws Exception { System.out.println("\n--- Starting "); @@ -217,19 +219,20 @@ public class EscapedOctetsInURI implements HttpServerAdapters { out.println("Got response: " + resp); out.println("Got body: " + resp.body()); - assertEquals(resp.statusCode(), 200, + assertEquals(200, resp.statusCode(), "Expected 200, got:" + resp.statusCode()); // the response body should contain the exact escaped request URI URI retrievedURI = URI.create(resp.body()); - assertEquals(retrievedURI.getRawPath(), uri.getRawPath()); - assertEquals(retrievedURI.getRawQuery(), uri.getRawQuery()); - assertEquals(resp.version(), version(uriString)); + assertEquals(uri.getRawPath(), retrievedURI.getRawPath()); + assertEquals(uri.getRawQuery(), retrievedURI.getRawQuery()); + assertEquals(version(uriString), resp.version()); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uriString, boolean sameClient) throws Exception { System.out.println("\n--- Starting "); URI uri = URI.create(uriString); @@ -249,22 +252,22 @@ public class EscapedOctetsInURI implements HttpServerAdapters { .thenApply(response -> { out.println("Got response: " + response); out.println("Got body: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uriString)); + assertEquals(200, response.statusCode()); + assertEquals(version(uriString), response.version()); return response.body(); }) .thenApply(body -> URI.create(body)) .thenAccept(retrievedURI -> { // the body should contain the exact escaped request URI - assertEquals(retrievedURI.getRawPath(), uri.getRawPath()); - assertEquals(retrievedURI.getRawQuery(), uri.getRawQuery()); + assertEquals(uri.getRawPath(), retrievedURI.getRawPath()); + assertEquals(uri.getRawQuery(), retrievedURI.getRawQuery()); }).join(); } } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println(now() + "begin setup"); InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -311,8 +314,8 @@ public class EscapedOctetsInURI implements HttpServerAdapters { err.println(now() + "setup done"); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient.close(); httpTestServer.stop(); httpsTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/ExecutorShutdown.java b/test/jdk/java/net/httpclient/ExecutorShutdown.java index a7cfd56b282..a46ea66f3ae 100644 --- a/test/jdk/java/net/httpclient/ExecutorShutdown.java +++ b/test/jdk/java/net/httpclient/ExecutorShutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * ExecutorShutdown @@ -65,10 +65,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -78,8 +74,13 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ExecutorShutdown implements HttpServerAdapters { @@ -89,25 +90,24 @@ public class ExecutorShutdown implements HttpServerAdapters { static final Random RANDOM = RandomFactory.getRandom(); private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/2 ( h2+h3 ) - HttpTestServer h3TestServer; // HTTP/2 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h3URI; - String h2h3Head; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/2 ( h2+h3 ) + private static HttpTestServer h3TestServer; // HTTP/2 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h3URI; + private static String h2h3Head; static final String MESSAGE = "ExecutorShutdown message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig() }, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig() }, @@ -119,7 +119,7 @@ public class ExecutorShutdown implements HttpServerAdapters { } static final AtomicLong requestCounter = new AtomicLong(); - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static Throwable getCause(Throwable t) { while (t instanceof CompletionException || t instanceof ExecutionException) { @@ -158,7 +158,8 @@ public class ExecutorShutdown implements HttpServerAdapters { throw new AssertionError(what + ": Unexpected exception: " + cause, cause); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); ExecutorService executorService = Executors.newCachedThreadPool(); @@ -209,9 +210,9 @@ public class ExecutorShutdown implements HttpServerAdapters { var cf = responseCF.thenApply((response) -> { out.println(si + ": Got response: " + response); out.println(si + ": Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - if (si >= head) assertEquals(response.version(), version); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + if (si >= head) assertEquals(version, response.version()); + assertEquals(MESSAGE, response.body()); return response; }).exceptionally((t) -> { Throwable cause = getCause(t); @@ -228,7 +229,8 @@ public class ExecutorShutdown implements HttpServerAdapters { } } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting (%s, %s, %s) ----%n%n", uriString, version, config); ExecutorService executorService = Executors.newCachedThreadPool(); @@ -272,9 +274,9 @@ public class ExecutorShutdown implements HttpServerAdapters { responseCF.thenApply((response) -> { out.println(si + ": Got response: " + response); out.println(si + ": Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - if (si > 0) assertEquals(response.version(), version); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + if (si > 0) assertEquals(version, response.version()); + assertEquals(MESSAGE, response.body()); return response; }).handle((r,t) -> { if (t != null) { @@ -305,11 +307,11 @@ public class ExecutorShutdown implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new ServerRequestHandler(), "/http1/exec/"); @@ -342,8 +344,8 @@ public class ExecutorShutdown implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(5000); try { diff --git a/test/jdk/java/net/httpclient/ExpectContinue.java b/test/jdk/java/net/httpclient/ExpectContinue.java index a2d928e6f41..e9ae894f3e1 100644 --- a/test/jdk/java/net/httpclient/ExpectContinue.java +++ b/test/jdk/java/net/httpclient/ExpectContinue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +28,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestServerConfigurator * @modules java.net.http/jdk.internal.net.http.common * jdk.httpserver - * @run testng/othervm ExpectContinue + * @run junit/othervm ExpectContinue */ import com.sun.net.httpserver.HttpExchange; @@ -51,23 +51,24 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ExpectContinue { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - String httpURI; - String httpsURI; + private static HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static String httpURI; + private static String httpsURI; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { httpURI, false, "Billy" }, { httpURI, false, "Bob" }, @@ -76,7 +77,8 @@ public class ExpectContinue { }; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, boolean expectedContinue, String data) throws Exception { @@ -94,17 +96,18 @@ public class ExpectContinue { HttpResponse response = client.send(request, BodyHandlers.ofString()); System.out.println("First response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), data); + assertEquals(200, response.statusCode()); + assertEquals(data, response.body()); // again with the same request, to ensure no Expect header duplication response = client.send(request, BodyHandlers.ofString()); System.out.println("Second response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), data); + assertEquals(200, response.statusCode()); + assertEquals(data, response.body()); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testAsync(String uriString, boolean expectedContinue, String data) { out.printf("test(%s, %s, %s): starting%n", uriString, expectedContinue, data); HttpClient client = HttpClient.newBuilder() @@ -120,14 +123,14 @@ public class ExpectContinue { HttpResponse response = client.sendAsync(request, BodyHandlers.ofString()).join(); System.out.println("First response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), data); + assertEquals(200, response.statusCode()); + assertEquals(data, response.body()); // again with the same request, to ensure no Expect header duplication response = client.sendAsync(request, BodyHandlers.ofString()).join(); System.out.println("Second response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), data); + assertEquals(200, response.statusCode()); + assertEquals(data, response.body()); } // -- Infrastructure @@ -137,8 +140,8 @@ public class ExpectContinue { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); httpTestServer = HttpServer.create(sa, 0); httpTestServer.createContext("/http1/ec", new Http1ExpectContinueHandler()); @@ -153,8 +156,8 @@ public class ExpectContinue { httpsTestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); } diff --git a/test/jdk/java/net/httpclient/ExpectContinueTest.java b/test/jdk/java/net/httpclient/ExpectContinueTest.java index a703fbfaacf..56fa363870a 100644 --- a/test/jdk/java/net/httpclient/ExpectContinueTest.java +++ b/test/jdk/java/net/httpclient/ExpectContinueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +27,7 @@ * @bug 8286171 8307648 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Djdk.internal.httpclient.debug=true -Djdk.httpclient.HttpClient.log=errors ExpectContinueTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true -Djdk.httpclient.HttpClient.log=errors ExpectContinueTest */ @@ -40,11 +40,6 @@ import jdk.httpclient.test.lib.http2.Http2TestServerConnection; import jdk.httpclient.test.lib.http2.Http2TestServerConnection.ResponseHeaders; import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.HeaderFrame; -import org.testng.TestException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLSession; @@ -79,23 +74,29 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ExpectContinueTest implements HttpServerAdapters { - HttpTestServer http1TestServer; // HTTP/1.1 - Http1HangServer http1HangServer; - Http2TestServer http2TestServer; // HTTP/2 + private static HttpTestServer http1TestServer; // HTTP/1.1 + private static Http1HangServer http1HangServer; + private static Http2TestServer http2TestServer; // HTTP/2 - URI getUri, postUri, forcePostUri, hangUri; - URI h2postUri, h2forcePostUri, h2hangUri, h2endStreamUri, h2warmupURI; + private static URI getUri, postUri, forcePostUri, hangUri; + private static URI h2postUri, h2forcePostUri, h2hangUri, h2endStreamUri, h2warmupURI; static PrintStream err = new PrintStream(System.err); static PrintStream out = new PrintStream(System.out); static final String EXPECTATION_FAILED_417 = "417 Expectation Failed"; - @DataProvider(name = "uris") - public Object[][] urisData() { + public static Object[][] urisData() { return new Object[][]{ // URI, Expected Status Code, Will finish with Exception, Protocol Version { postUri, 200, false, HTTP_1_1 }, @@ -107,7 +108,8 @@ public class ExpectContinueTest implements HttpServerAdapters { { h2endStreamUri, 200, true, HTTP_2 }, // Error }; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("urisData") public void test(URI uri, int expectedStatusCode, boolean exceptionally, HttpClient.Version version) throws CancellationException, InterruptedException, ExecutionException, IOException { @@ -135,8 +137,8 @@ public class ExpectContinueTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress saHang = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); http1TestServer = HttpTestServer.create(HTTP_1_1); http1TestServer.addHandler(new GetHandler(), "/http1/get"); @@ -173,8 +175,8 @@ public class ExpectContinueTest implements HttpServerAdapters { http1HangServer.start(); http2TestServer.start(); } - @AfterTest - public void teardown() throws IOException { + @AfterAll + public static void teardown() throws IOException { http1TestServer.stop(); http1HangServer.close(); http2TestServer.stop(); @@ -372,11 +374,11 @@ public class ExpectContinueTest implements HttpServerAdapters { } if (exceptionally && testThrowable != null) { err.println("Finished exceptionally Test throwable: " + testThrowable); - assertEquals(testThrowable.getClass(), ProtocolException.class); + assertEquals(ProtocolException.class, testThrowable.getClass()); } else if (exceptionally) { - throw new TestException("Expected case to finish with an IOException but testException is null"); + fail("Expected case to finish with an IOException but testException is null"); } else if (resp != null) { - assertEquals(resp.statusCode(), expectedStatusCode); + assertEquals(expectedStatusCode, resp.statusCode()); err.println("Request completed successfully for path " + path); err.println("Response Headers: " + resp.headers()); err.println("Response Status Code: " + resp.statusCode()); diff --git a/test/jdk/java/net/httpclient/FilePublisherTest.java b/test/jdk/java/net/httpclient/FilePublisherTest.java index 9501e8054cc..292f770fc30 100644 --- a/test/jdk/java/net/httpclient/FilePublisherTest.java +++ b/test/jdk/java/net/httpclient/FilePublisherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,14 +29,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm FilePublisherTest + * @run junit/othervm FilePublisherTest */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -58,22 +54,27 @@ import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class FilePublisherTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServerAdapters.HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpServerAdapters.HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpServerAdapters.HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpServerAdapters.HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; - FileSystem zipFs; - Path defaultFsPath; - Path zipFsPath; + private static FileSystem zipFs; + private static Path defaultFsPath; + private static Path zipFsPath; // Default file system set up static final String DEFAULT_FS_MSG = "default fs"; @@ -84,12 +85,11 @@ public class FilePublisherTest implements HttpServerAdapters { Files.createFile(file); Files.writeString(file, DEFAULT_FS_MSG); } - assertEquals(Files.readString(file), DEFAULT_FS_MSG); + assertEquals(DEFAULT_FS_MSG, Files.readString(file)); return file; } - @DataProvider(name = "defaultFsData") - public Object[][] defaultFsData() { + public static Object[][] defaultFsData() { return new Object[][]{ { httpURI, defaultFsPath, DEFAULT_FS_MSG, true }, { httpsURI, defaultFsPath, DEFAULT_FS_MSG, true }, @@ -102,7 +102,8 @@ public class FilePublisherTest implements HttpServerAdapters { }; } - @Test(dataProvider = "defaultFsData") + @ParameterizedTest + @MethodSource("defaultFsData") public void testDefaultFs(String uriString, Path path, String expectedMsg, @@ -126,12 +127,11 @@ public class FilePublisherTest implements HttpServerAdapters { Files.createFile(file); Files.writeString(file, ZIP_FS_MSG); } - assertEquals(Files.readString(file), ZIP_FS_MSG); + assertEquals(ZIP_FS_MSG, Files.readString(file)); return file; } - @DataProvider(name = "zipFsData") - public Object[][] zipFsData() { + public static Object[][] zipFsData() { return new Object[][]{ { httpURI, zipFsPath, ZIP_FS_MSG, true }, { httpsURI, zipFsPath, ZIP_FS_MSG, true }, @@ -144,7 +144,8 @@ public class FilePublisherTest implements HttpServerAdapters { }; } - @Test(dataProvider = "zipFsData") + @ParameterizedTest + @MethodSource("zipFsData") public void testZipFs(String uriString, Path path, String expectedMsg, @@ -176,13 +177,13 @@ public class FilePublisherTest implements HttpServerAdapters { var resp = client.send(req, HttpResponse.BodyHandlers.ofString()); out.println("Got response: " + resp); out.println("Got body: " + resp.body()); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.body(), expectedMsg); + assertEquals(200, resp.statusCode()); + assertEquals(expectedMsg, resp.body()); } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { defaultFsPath = defaultFsFile(); zipFs = newZipFs(); zipFsPath = zipFsFile(zipFs); @@ -209,8 +210,8 @@ public class FilePublisherTest implements HttpServerAdapters { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java b/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java index ef9dc7b3077..7fd3061aa3c 100644 --- a/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java +++ b/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,6 @@ import java.net.http.HttpResponse; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import static java.net.http.HttpOption.H3_DISCOVERY; @@ -53,8 +49,14 @@ import static java.util.stream.Collectors.joining; import static java.nio.charset.StandardCharsets.UTF_8; import static java.net.http.HttpRequest.BodyPublishers.fromPublisher; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -62,25 +64,24 @@ import static org.testng.Assert.fail; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=err FlowAdapterPublisherTest + * @run junit/othervm -Djdk.internal.httpclient.debug=err FlowAdapterPublisherTest */ public class FlowAdapterPublisherTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI }, { httpsURI }, @@ -120,7 +121,8 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { return builder; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testByteBufferPublisherUnknownLength(String uri) { String[] body = new String[] { "You know ", "it's summer ", "in Ireland ", "when the ", "rain gets ", "warmer." }; @@ -131,13 +133,14 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { HttpResponse response = client.sendAsync(request, ofString(UTF_8)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, Arrays.stream(body).collect(joining())); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals(Arrays.stream(body).collect(joining()), text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testByteBufferPublisherFixedLength(String uri) { String[] body = new String[] { "You know ", "it's summer ", "in Ireland ", "when the ", "rain gets ", "warmer." }; @@ -149,15 +152,16 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { HttpResponse response = client.sendAsync(request, ofString(UTF_8)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, Arrays.stream(body).collect(joining())); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals(Arrays.stream(body).collect(joining()), text); } } // Flow.Publisher - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testMappedByteBufferPublisherUnknownLength(String uri) { String[] body = new String[] { "God invented ", "whiskey to ", "keep the ", "Irish from ", "ruling the ", "world." }; @@ -168,13 +172,14 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { HttpResponse response = client.sendAsync(request, ofString(UTF_8)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, Arrays.stream(body).collect(joining())); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals(Arrays.stream(body).collect(joining()), text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testMappedByteBufferPublisherFixedLength(String uri) { String[] body = new String[] { "God invented ", "whiskey to ", "keep the ", "Irish from ", "ruling the ", "world." }; @@ -186,9 +191,9 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { HttpResponse response = client.sendAsync(request, ofString(UTF_8)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, Arrays.stream(body).collect(joining())); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals(Arrays.stream(body).collect(joining()), text); } } @@ -196,7 +201,8 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { // not ideal, but necessary to discern correct behavior. They should be // updated if the exception message is updated. - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testPublishTooFew(String uri) throws InterruptedException { String[] body = new String[] { "You know ", "it's summer ", "in Ireland ", "when the ", "rain gets ", "warmer." }; @@ -214,7 +220,8 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testPublishTooMany(String uri) throws InterruptedException { String[] body = new String[] { "You know ", "it's summer ", "in Ireland ", "when the ", "rain gets ", "warmer." }; @@ -356,8 +363,8 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(Version.HTTP_1_1); httpTestServer.addHandler(new HttpEchoHandler(), "/http1/echo"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/echo"; @@ -385,8 +392,8 @@ public class FlowAdapterPublisherTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java b/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java index 0e175cf0f52..32003023d7f 100644 --- a/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java +++ b/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -53,17 +53,19 @@ import java.net.http.HttpResponse.BodySubscribers; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -72,22 +74,22 @@ import static org.testng.Assert.assertTrue; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true FlowAdapterSubscriberTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true FlowAdapterSubscriberTest */ public class FlowAdapterSubscriberTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; static final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); @@ -101,8 +103,7 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI }, { httpsURI }, @@ -154,7 +155,7 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { assertThrows(NPE, () -> BodySubscribers.fromSubscriber(new ListSubscriber(), null)); assertThrows(NPE, () -> BodySubscribers.fromSubscriber(null, null)); - Subscriber subscriber = BodySubscribers.fromSubscriber(new ListSubscriber()); + Subscriber subscriber = BodySubscribers.fromSubscriber(new ListSubscriber()); assertThrows(NPE, () -> subscriber.onSubscribe(null)); assertThrows(NPE, () -> subscriber.onNext(null)); assertThrows(NPE, () -> subscriber.onError(null)); @@ -162,7 +163,8 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { // List - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testListWithFinisher(String uri) { System.out.printf(now() + "testListWithFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -174,13 +176,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, Supplier::get)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "May the luck of the Irish be with you!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("May the luck of the Irish be with you!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testListWithoutFinisher(String uri) { System.out.printf(now() + "testListWithoutFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -192,13 +195,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)).join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "May the luck of the Irish be with you!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("May the luck of the Irish be with you!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testListWithFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testListWithFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -210,13 +214,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, Supplier::get)); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "May the luck of the Irish be with you!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("May the luck of the Irish be with you!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testListWithoutFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testListWithoutFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -228,15 +233,16 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "May the luck of the Irish be with you!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("May the luck of the Irish be with you!", text); } } // Collection - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testCollectionWithFinisher(String uri) { System.out.printf(now() + "testCollectionWithFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -248,13 +254,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, CollectionSubscriber::get)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "What's the craic?"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("What's the craic?", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testCollectionWithoutFinisher(String uri) { System.out.printf(now() + "testCollectionWithoutFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -266,13 +273,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)).join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "What's the craic?"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("What's the craic?", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testCollectionWithFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testCollectionWithFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -284,13 +292,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, CollectionSubscriber::get)); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "What's the craic?"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("What's the craic?", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testCollectionWithoutFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testCollectionWithoutFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -302,15 +311,16 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "What's the craic?"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("What's the craic?", text); } } // Iterable - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testIterableWithFinisher(String uri) { System.out.printf(now() + "testIterableWithFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -322,13 +332,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, Supplier::get)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "We're sucking diesel now!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("We're sucking diesel now!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testIterableWithoutFinisher(String uri) { System.out.printf(now() + "testIterableWithoutFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -340,13 +351,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)).join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "We're sucking diesel now!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("We're sucking diesel now!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testIterableWithFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testIterableWithFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -358,13 +370,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, Supplier::get)); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "We're sucking diesel now!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("We're sucking diesel now!", text); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testIterableWithoutFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testIterableWithoutFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -376,15 +389,16 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); - assertEquals(text, "We're sucking diesel now!"); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); + assertEquals("We're sucking diesel now!", text); } } // Subscriber - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithFinisher(String uri) { System.out.printf(now() + "testObjectWithFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -396,13 +410,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, ObjectSubscriber::get)).join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); assertTrue(text.length() != 0); // what else can be asserted! } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithoutFinisher(String uri) { System.out.printf(now() + "testObjectWithoutFinisher(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -414,13 +429,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)).join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); assertTrue(text.length() != 0); // what else can be asserted! } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testObjectWithFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -432,13 +448,14 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber, ObjectSubscriber::get)); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); assertTrue(text.length() != 0); // what else can be asserted! } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithoutFinisherBlocking(String uri) throws Exception { System.out.printf(now() + "testObjectWithoutFinisherBlocking(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -450,8 +467,8 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { BodyHandlers.fromSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uri)); + assertEquals(200, response.statusCode()); + assertEquals(version(uri), response.version()); assertTrue(text.length() != 0); // what else can be asserted! } } @@ -459,7 +476,8 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { // -- mapping using convenience handlers - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void mappingFromByteArray(String uri) throws Exception { System.out.printf(now() + "mappingFromByteArray(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -470,12 +488,13 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { bas -> new String(bas.getBody().toCompletableFuture().join(), UTF_8))) .thenApply(FlowAdapterSubscriberTest::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, "We're sucking diesel now!")) + .thenAccept(body -> assertEquals("We're sucking diesel now!", body)) .join(); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void mappingFromInputStream(String uri) throws Exception { System.out.printf(now() + "mappingFromInputStream(%s) starting%n", uri); try (HttpClient client = newHttpClient(uri)) { @@ -512,7 +531,7 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { finisher)) .thenApply(FlowAdapterSubscriberTest::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, "May the wind always be at your back.")) + .thenAccept(body -> assertEquals("May the wind always be at your back.", body)) .join(); var error = failed.get(); if (error != null) throw error; @@ -626,13 +645,13 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { } static final HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(response.request().uri().toString())); + assertEquals(200, response.statusCode()); + assertEquals(version(response.request().uri().toString()), response.version()); return response; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(Version.HTTP_1_1); httpTestServer.addHandler(new HttpEchoHandler(), "/http1/echo"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/echo"; @@ -660,8 +679,8 @@ public class FlowAdapterSubscriberTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/ForbiddenHeadTest.java b/test/jdk/java/net/httpclient/ForbiddenHeadTest.java index 57fd627b2b0..f2011766b2b 100644 --- a/test/jdk/java/net/httpclient/ForbiddenHeadTest.java +++ b/test/jdk/java/net/httpclient/ForbiddenHeadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +28,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build DigestEchoServer ForbiddenHeadTest jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.http.auth.tunneling.disabledSchemes * -Djdk.httpclient.HttpClient.log=headers,requests * -Djdk.internal.httpclient.debug=true @@ -36,15 +36,6 @@ */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -61,7 +52,6 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -81,27 +71,40 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; + +import static jdk.httpclient.test.lib.common.HttpServerAdapters.createClientBuilderForH3; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ForbiddenHeadTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - DigestEchoServer.TunnelingProxy proxy; - DigestEchoServer.TunnelingProxy authproxy; - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String https3URI; - HttpClient authClient; - HttpClient noAuthClient; + private static HttpTestServer httpTestServer; // HTTP/1.1 + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static DigestEchoServer.TunnelingProxy proxy; + private static DigestEchoServer.TunnelingProxy authproxy; + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String https3URI; + private static HttpClient authClient; + private static HttpClient noAuthClient; - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static final long SLEEP_AFTER_TEST = 0; // milliseconds static final int ITERATIONS = 3; static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); @@ -142,34 +145,39 @@ public class ForbiddenHeadTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { // Exceptions should already have been added to FAILURES @@ -201,8 +209,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters { static final String MESSAGE = "Unauthorized"; - @DataProvider(name = "all") - public Object[][] allcases() { + public static Object[][] allcases() { List result = new ArrayList<>(); for (boolean useAuth : List.of(true, false)) { for (boolean async : List.of(true, false)) { @@ -226,8 +233,6 @@ public class ForbiddenHeadTest implements HttpServerAdapters { return result.toArray(new Object[0][0]); } - static final AtomicLong requestCounter = new AtomicLong(); - static final Authenticator authenticator = new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { @@ -237,9 +242,9 @@ public class ForbiddenHeadTest implements HttpServerAdapters { static final AtomicLong sleepCount = new AtomicLong(); - @Test(dataProvider = "all") + @ParameterizedTest + @MethodSource("allcases") void test(String uriString, int code, boolean async, boolean useAuth) throws Throwable { - checkSkip(); HttpClient client = useAuth ? authClient : noAuthClient; var name = String.format("test(%s, %d, %s, %s)", uriString, code, async ? "async" : "sync", client.authenticator().isPresent() ? "authClient" : "noAuthClient"); @@ -318,23 +323,23 @@ public class ForbiddenHeadTest implements HttpServerAdapters { out.println(" Got response: " + response); - assertEquals(response.statusCode(), forbidden? FORBIDDEN : code); - assertEquals(response.body(), expectedValue == null ? null : ""); - assertEquals(response.headers().firstValue("X-value"), Optional.ofNullable(expectedValue)); + assertEquals(forbidden? FORBIDDEN : code, response.statusCode()); + assertEquals(expectedValue == null ? null : "", response.body()); + assertEquals(Optional.ofNullable(expectedValue), response.headers().firstValue("X-value")); // when the CONNECT request fails, its body is discarded - but // the response header may still contain its content length. // don't check content length in that case. if (expectedValue != null) { String clen = String.valueOf(expectedValue.getBytes(UTF_8).length); - assertEquals(response.headers().firstValue("Content-Length"), Optional.of(clen)); + assertEquals(Optional.of(clen), response.headers().firstValue("Content-Length")); } } // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new UnauthorizedHandler(), "/http1/"); httpTestServer.addHandler(new UnauthorizedHandler(), "/http2/proxy/"); @@ -357,7 +362,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters { proxy = DigestEchoServer.createHttpsProxyTunnel(DigestEchoServer.HttpAuthSchemeType.NONE); authproxy = DigestEchoServer.createHttpsProxyTunnel(DigestEchoServer.HttpAuthSchemeType.BASIC); - authClient = TRACKER.track(newClientBuilderForH3() + authClient = TRACKER.track(createClientBuilderForH3() .proxy(TestProxySelector.of(proxy, authproxy, httpTestServer)) .sslContext(sslContext) .executor(executor) @@ -365,7 +370,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters { .build()); clientCount.incrementAndGet(); - noAuthClient = TRACKER.track(newClientBuilderForH3() + noAuthClient = TRACKER.track(createClientBuilderForH3() .proxy(TestProxySelector.of(proxy, authproxy, httpTestServer)) .sslContext(sslContext) .executor(executor) @@ -384,8 +389,8 @@ public class ForbiddenHeadTest implements HttpServerAdapters { serverCount.incrementAndGet(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { authClient = noAuthClient = null; Thread.sleep(100); AssertionError fail = TRACKER.check(1500); diff --git a/test/jdk/java/net/httpclient/GZIPInputStreamTest.java b/test/jdk/java/net/httpclient/GZIPInputStreamTest.java index 948ecd4d7cc..1cbb24d81ce 100644 --- a/test/jdk/java/net/httpclient/GZIPInputStreamTest.java +++ b/test/jdk/java/net/httpclient/GZIPInputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,15 +27,11 @@ * @summary Tests that you can map an InputStream to a GZIPInputStream * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters ReferenceTracker - * @run testng/othervm GZIPInputStreamTest + * @run junit/othervm GZIPInputStreamTest */ import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -46,7 +42,6 @@ import java.net.InetAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; -import java.net.http.HttpOption.Http3DiscoveryMode; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; @@ -68,21 +63,26 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class GZIPInputStreamTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer https3TestServer; // HTTP/3 - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String https3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer https3TestServer; // HTTP/3 + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String https3URI; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -154,8 +154,7 @@ public class GZIPInputStreamTest implements HttpServerAdapters { - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI, false }, { httpURI, true }, @@ -170,7 +169,7 @@ public class GZIPInputStreamTest implements HttpServerAdapters { }; } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; HttpClient newHttpClient() { return TRACKER.track(newClientBuilderForH3() .executor(executor) @@ -192,7 +191,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { .build()); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testPlainSyncAsString(String uri, boolean sameClient) throws Exception { out.println("\nSmoke test: verify that the result we get from the server is correct."); out.println("Uses plain send() and `asString` to get the plain string."); @@ -209,7 +209,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testPlainSyncAsInputStream(String uri, boolean sameClient) throws Exception { out.println("Uses plain send() and `asInputStream` - calls readAllBytes() from main thread"); out.println("Uses single threaded executor"); @@ -225,7 +226,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPSyncAsInputStream(String uri, boolean sameClient) throws Exception { out.println("Uses plain send() and `asInputStream` - " + "creates GZIPInputStream and calls readAllBytes() from main thread"); @@ -243,7 +245,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPSyncAsGZIPInputStream(String uri, boolean sameClient) throws Exception { out.println("Uses plain send() and a mapping subscriber to "+ "create the GZIPInputStream. Calls readAllBytes() from main thread"); @@ -262,7 +265,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPSyncAsGZIPInputStreamSupplier(String uri, boolean sameClient) throws Exception { out.println("Uses plain send() and a mapping subscriber to "+ "create a Supplier. Calls Supplier.get() " + @@ -276,7 +280,7 @@ public class GZIPInputStreamTest implements HttpServerAdapters { HttpRequest req = buildRequest(URI.create(uri + "/gz/LoremIpsum.txt.gz")); // This is dangerous, because the finisher will block. // We support this, but the executor must have enough threads. - BodyHandler> handler = new BodyHandler>() { + BodyHandler> handler = new BodyHandler<>() { public HttpResponse.BodySubscriber> apply( HttpResponse.ResponseInfo responseInfo) { @@ -304,7 +308,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testPlainAsyncAsInputStreamBlocks(String uri, boolean sameClient) throws Exception { out.println("Uses sendAsync() and `asInputStream`. Registers a dependent action "+ "that calls readAllBytes()"); @@ -331,7 +336,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPAsyncAsGZIPInputStreamBlocks(String uri, boolean sameClient) throws Exception { out.println("Uses sendAsync() and a mapping subscriber to create a GZIPInputStream. " + "Registers a dependent action that calls readAllBytes()"); @@ -358,7 +364,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPSyncAsGZIPInputStreamBlocks(String uri, boolean sameClient) throws Exception { out.println("Uses sendAsync() and a mapping subscriber to create a GZIPInputStream," + "which is mapped again using a mapping subscriber " + @@ -386,7 +393,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testGZIPSyncAsGZIPInputStreamSupplierInline(String uri, boolean sameClient) throws Exception { out.println("Uses plain send() and a mapping subscriber to "+ "create a Supplier. Calls Supplier.get() " + @@ -432,7 +440,7 @@ public class GZIPInputStreamTest implements HttpServerAdapters { if (!LOREM_IPSUM.equals(responseBody)) { out.println("Response doesn't match"); out.println("[" + LOREM_IPSUM + "] != [" + responseBody + "]"); - assertEquals(LOREM_IPSUM, responseBody); + assertEquals(responseBody, LOREM_IPSUM); } else { out.println("Received expected response."); } @@ -487,8 +495,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { HttpTestHandler plainHandler = new LoremIpsumPlainHandler(); HttpTestHandler gzipHandler = new LoremIpsumGZIPHandler(); @@ -526,8 +534,8 @@ public class GZIPInputStreamTest implements HttpServerAdapters { https3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(500); try { diff --git a/test/jdk/java/net/httpclient/HeadTest.java b/test/jdk/java/net/httpclient/HeadTest.java index 3e05442faf5..3a52cd101b8 100644 --- a/test/jdk/java/net/httpclient/HeadTest.java +++ b/test/jdk/java/net/httpclient/HeadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,14 +27,10 @@ * @summary Tests Client handles HEAD and 304 responses correctly. * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=trace,headers,requests HeadTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=trace,headers,requests HeadTest */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -55,19 +51,24 @@ import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static jdk.httpclient.test.lib.common.HttpServerAdapters.createClientBuilderForH3; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class HeadTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer https3TestServer; // HTTP/3 - String httpURI, httpsURI; - String http2URI, https2URI; - String https3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer https3TestServer; // HTTP/3 + private static String httpURI, httpsURI; + private static String http2URI, https2URI; + private static String https3URI; static final String CONTENT_LEN = "300"; @@ -80,8 +81,7 @@ public class HeadTest implements HttpServerAdapters { static final int HTTP_OK = 200; static final PrintStream out = System.out; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { // HTTP/1.1 { httpURI, "GET", HTTP_NOT_MODIFIED, HTTP_1_1 }, @@ -103,7 +103,8 @@ public class HeadTest implements HttpServerAdapters { }; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, String method, int expResp, Version version) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); @@ -136,17 +137,17 @@ public class HeadTest implements HttpServerAdapters { out.println(" Got response: " + response); - assertEquals(response.statusCode(), expResp); - assertEquals(response.body(), ""); - assertEquals(response.headers().firstValue("Content-length").get(), CONTENT_LEN); - assertEquals(response.version(), request.version().get()); + assertEquals(expResp, response.statusCode()); + assertEquals("", response.body()); + assertEquals(CONTENT_LEN, response.headers().firstValue("Content-length").get()); + assertEquals(request.version().get(), response.version()); } } // -- Infrastructure // TODO: See if test performs better with Vthreads, see H3SimplePost and H3SimpleGet - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new HeadHandler(), "/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/"; @@ -173,8 +174,8 @@ public class HeadTest implements HttpServerAdapters { https3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/HeadersLowerCaseTest.java b/test/jdk/java/net/httpclient/HeadersLowerCaseTest.java index b1e4e569010..00a709a3387 100644 --- a/test/jdk/java/net/httpclient/HeadersLowerCaseTest.java +++ b/test/jdk/java/net/httpclient/HeadersLowerCaseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,6 @@ import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -63,19 +62,18 @@ import static org.junit.jupiter.api.Assertions.assertThrows; * jdk.httpclient.test.lib.common.HttpServerAdapters * @run junit/othervm -Djdk.internal.httpclient.debug=true HeadersLowerCaseTest */ -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HeadersLowerCaseTest implements HttpServerAdapters { private static Set REQUEST_HEADERS; - private HttpTestServer h2server; - private HttpTestServer h3server; - private String h2ReqURIBase; - private String h3ReqURIBase; + private static HttpTestServer h2server; + private static HttpTestServer h3server; + private static String h2ReqURIBase; + private static String h3ReqURIBase; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @BeforeAll - public void beforeAll() throws Exception { + public static void beforeAll() throws Exception { h2server = HttpTestServer.create(HTTP_2, sslContext); h2server.start(); h2ReqURIBase = "https://" + h2server.serverAuthority(); @@ -100,7 +98,7 @@ public class HeadersLowerCaseTest implements HttpServerAdapters { } @AfterAll - public void afterAll() throws Exception { + public static void afterAll() throws Exception { if (h2server != null) { h2server.stop(); } @@ -157,14 +155,14 @@ public class HeadersLowerCaseTest implements HttpServerAdapters { } } - private Stream params() throws Exception { + private static Stream params() throws Exception { return Stream.of( Arguments.of(HTTP_2, new URI(h2ReqURIBase + "/h2verifyReqHeaders")), Arguments.of(Version.HTTP_3, new URI(h3ReqURIBase + "/h3verifyReqHeaders"))); } /** - * Issues a HTTP/2 or HTTP/3 request with header names of varying case (some in lower, + * Issues an HTTP/2 or HTTP/3 request with header names of varying case (some in lower, * some mixed, some upper case) and expects that the client internally converts them * to lower case before encoding and sending to the server. The server side handler verifies * that it receives the header names in lower case and if it doesn't then it returns a diff --git a/test/jdk/java/net/httpclient/HeadersTest1.java b/test/jdk/java/net/httpclient/HeadersTest1.java index 79932dfc92f..26733c1c928 100644 --- a/test/jdk/java/net/httpclient/HeadersTest1.java +++ b/test/jdk/java/net/httpclient/HeadersTest1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8153142 8195138 * @modules java.net.http * jdk.httpserver - * @run testng/othervm HeadersTest1 + * @run junit/othervm HeadersTest1 */ import java.io.IOException; @@ -48,13 +48,13 @@ import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; -import org.testng.annotations.Test; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static java.nio.charset.StandardCharsets.US_ASCII; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class HeadersTest1 { @@ -106,7 +106,7 @@ public class HeadersTest1 { for (String headerName : headernames) { List v2 = hd.allValues(headerName); assertNotNull(v2); - assertEquals(new HashSet<>(v2), Set.of("resp1", "resp2")); + assertEquals(Set.of("resp1", "resp2"), new HashSet<>(v2)); TestKit.assertUnmodifiableList(v2); } @@ -130,7 +130,7 @@ public class HeadersTest1 { // quote List quote = hd.allValues("X-Quote-Response"); - assertEquals(quote, List.of(QUOTED)); + assertEquals(List.of(QUOTED), quote); } finally { server.stop(0); e.shutdownNow(); diff --git a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java index 9f7d2ade62f..a5fb1a39e66 100644 --- a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java +++ b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,9 +51,10 @@ import java.net.http.HttpClient.Version; import java.util.concurrent.atomic.AtomicInteger; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.time.Duration.*; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /* * @test @@ -61,7 +62,7 @@ import static org.testng.Assert.*; * @summary HttpClient[.Builder] API and behaviour checks * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext - * @run testng HttpClientBuilderTest + * @run junit HttpClientBuilderTest */ public class HttpClientBuilderTest { @@ -83,10 +84,10 @@ public class HttpClientBuilderTest { assertFalse(client.connectTimeout().isPresent()); assertFalse(client.executor().isPresent()); assertFalse(client.proxy().isPresent()); - assertTrue(client.sslParameters() != null); - assertTrue(client.followRedirects().equals(HttpClient.Redirect.NEVER)); - assertTrue(client.sslContext() == SSLContext.getDefault()); - assertTrue(client.version().equals(HttpClient.Version.HTTP_2)); + assertNotNull(client.sslParameters()); + assertEquals(Redirect.NEVER, client.followRedirects()); + assertSame(SSLContext.getDefault(), client.sslContext()); + assertEquals(Version.HTTP_2, client.version()); } } } @@ -133,18 +134,18 @@ public class HttpClientBuilderTest { Authenticator a = new TestAuthenticator(); builder.authenticator(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().authenticator().get() == a); + assertSame(a, closer.build().authenticator().get()); } Authenticator b = new TestAuthenticator(); builder.authenticator(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().authenticator().get() == b); + assertSame(b, closer.build().authenticator().get()); } assertThrows(NPE, () -> builder.authenticator(null)); Authenticator c = new TestAuthenticator(); builder.authenticator(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().authenticator().get() == c); + assertSame(c, closer.build().authenticator().get()); } } @@ -154,18 +155,18 @@ public class HttpClientBuilderTest { CookieHandler a = new CookieManager(); builder.cookieHandler(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().cookieHandler().get() == a); + assertSame(a, closer.build().cookieHandler().get()); } CookieHandler b = new CookieManager(); builder.cookieHandler(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().cookieHandler().get() == b); + assertSame(b, closer.build().cookieHandler().get()); } assertThrows(NPE, () -> builder.cookieHandler(null)); CookieManager c = new CookieManager(); builder.cookieHandler(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().cookieHandler().get() == c); + assertSame(c, closer.build().cookieHandler().get()); } } @@ -175,18 +176,18 @@ public class HttpClientBuilderTest { Duration a = Duration.ofSeconds(5); builder.connectTimeout(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().connectTimeout().get() == a); + assertSame(a, closer.build().connectTimeout().get()); } Duration b = Duration.ofMinutes(1); builder.connectTimeout(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().connectTimeout().get() == b); + assertSame(b, closer.build().connectTimeout().get()); } assertThrows(NPE, () -> builder.cookieHandler(null)); Duration c = Duration.ofHours(100); builder.connectTimeout(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().connectTimeout().get() == c); + assertSame(c, closer.build().connectTimeout().get()); } assertThrows(IAE, () -> builder.connectTimeout(ZERO)); @@ -205,18 +206,18 @@ public class HttpClientBuilderTest { TestExecutor a = new TestExecutor(); builder.executor(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().executor().get() == a); + assertSame(a, closer.build().executor().get()); } TestExecutor b = new TestExecutor(); builder.executor(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().executor().get() == b); + assertSame(b, closer.build().executor().get()); } assertThrows(NPE, () -> builder.executor(null)); TestExecutor c = new TestExecutor(); builder.executor(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().executor().get() == c); + assertSame(c, closer.build().executor().get()); } } @@ -226,18 +227,18 @@ public class HttpClientBuilderTest { ProxySelector a = ProxySelector.of(null); builder.proxy(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().proxy().get() == a); + assertSame(a, closer.build().proxy().get()); } ProxySelector b = ProxySelector.of(InetSocketAddress.createUnresolved("foo", 80)); builder.proxy(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().proxy().get() == b); + assertSame(b, closer.build().proxy().get()); } assertThrows(NPE, () -> builder.proxy(null)); ProxySelector c = ProxySelector.of(InetSocketAddress.createUnresolved("bar", 80)); builder.proxy(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().proxy().get() == c); + assertSame(c, closer.build().proxy().get()); } } @@ -249,16 +250,16 @@ public class HttpClientBuilderTest { builder.sslParameters(a); a.setCipherSuites(new String[] { "Z" }); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters() != (a)); + assertNotSame(a, closer.build().sslParameters()); } try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters().getCipherSuites()[0].equals("A")); + assertEquals("A", closer.build().sslParameters().getCipherSuites()[0]); } SSLParameters b = new SSLParameters(); b.setEnableRetransmissions(true); builder.sslParameters(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters() != b); + assertNotSame(b, closer.build().sslParameters()); } try (var closer = closeable(builder)) { assertTrue(closer.build().sslParameters().getEnableRetransmissions()); @@ -269,21 +270,21 @@ public class HttpClientBuilderTest { builder.sslParameters(c); c.setProtocols(new String[] { "D" }); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters().getProtocols()[0].equals("C")); + assertEquals("C", closer.build().sslParameters().getProtocols()[0]); } SSLParameters d = new SSLParameters(); d.setSignatureSchemes(new String[] { "C" }); builder.sslParameters(d); d.setSignatureSchemes(new String[] { "D" }); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters().getSignatureSchemes()[0].equals("C")); + assertEquals("C", closer.build().sslParameters().getSignatureSchemes()[0]); } SSLParameters e = new SSLParameters(); e.setNamedGroups(new String[] { "C" }); builder.sslParameters(e); e.setNamedGroups(new String[] { "D" }); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslParameters().getNamedGroups()[0].equals("C")); + assertEquals("C", closer.build().sslParameters().getNamedGroups()[0]); } // test defaults for needClientAuth and wantClientAuth builder.sslParameters(new SSLParameters()); @@ -321,18 +322,18 @@ public class HttpClientBuilderTest { SSLContext a = SimpleSSLContext.findSSLContext(); builder.sslContext(a); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslContext() == a); + assertSame(a, closer.build().sslContext()); } SSLContext b = SimpleSSLContext.findSSLContext(); builder.sslContext(b); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslContext() == b); + assertSame(b, closer.build().sslContext()); } assertThrows(NPE, () -> builder.sslContext(null)); SSLContext c = SimpleSSLContext.findSSLContext(); builder.sslContext(c); try (var closer = closeable(builder)) { - assertTrue(closer.build().sslContext() == c); + assertSame(c, closer.build().sslContext()); } } @@ -341,16 +342,16 @@ public class HttpClientBuilderTest { HttpClient.Builder builder = HttpClient.newBuilder(); builder.followRedirects(Redirect.ALWAYS); try (var closer = closeable(builder)) { - assertTrue(closer.build().followRedirects() == Redirect.ALWAYS); + assertSame(Redirect.ALWAYS, closer.build().followRedirects()); } builder.followRedirects(Redirect.NEVER); try (var closer = closeable(builder)) { - assertTrue(closer.build().followRedirects() == Redirect.NEVER); + assertSame(Redirect.NEVER, closer.build().followRedirects()); } assertThrows(NPE, () -> builder.followRedirects(null)); builder.followRedirects(Redirect.NORMAL); try (var closer = closeable(builder)) { - assertTrue(closer.build().followRedirects() == Redirect.NORMAL); + assertSame(Redirect.NORMAL, closer.build().followRedirects()); } } @@ -358,37 +359,37 @@ public class HttpClientBuilderTest { public void testVersion() { HttpClient.Builder builder = HttpClient.newBuilder(); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_2); + assertSame(Version.HTTP_2, closer.build().version()); } builder.version(Version.HTTP_3); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_3); + assertSame(Version.HTTP_3, closer.build().version()); } builder.version(Version.HTTP_2); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_2); + assertSame(Version.HTTP_2, closer.build().version()); } builder.version(Version.HTTP_1_1); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_1_1); + assertSame(Version.HTTP_1_1, closer.build().version()); } assertThrows(NPE, () -> builder.version(null)); builder.version(Version.HTTP_3); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_3); + assertSame(Version.HTTP_3, closer.build().version()); } builder.version(Version.HTTP_2); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_2); + assertSame(Version.HTTP_2, closer.build().version()); } builder.version(Version.HTTP_1_1); try (var closer = closeable(builder)) { - assertTrue(closer.build().version() == Version.HTTP_1_1); + assertSame(Version.HTTP_1_1, closer.build().version()); } } @Test - static void testPriority() throws Exception { + void testPriority() throws Exception { HttpClient.Builder builder = HttpClient.newBuilder(); assertThrows(IAE, () -> builder.priority(-1)); assertThrows(IAE, () -> builder.priority(0)); @@ -489,7 +490,7 @@ public class HttpClientBuilderTest { static final URI uri = URI.create("http://foo.com/"); @Test - static void testHttpClientSendArgs() throws Exception { + void testHttpClientSendArgs() throws Exception { try (HttpClient client = HttpClient.newHttpClient()) { HttpRequest request = HttpRequest.newBuilder(uri).build(); @@ -527,21 +528,21 @@ public class HttpClientBuilderTest { // --- @Test - static void testUnsupportedWebSocket() throws Exception { + void testUnsupportedWebSocket() throws Exception { // @implSpec The default implementation of this method throws // {@code UnsupportedOperationException}. assertThrows(UOE, () -> (new MockHttpClient()).newWebSocketBuilder()); } @Test - static void testDefaultShutdown() throws Exception { + void testDefaultShutdown() throws Exception { try (HttpClient client = new MockHttpClient()) { client.shutdown(); // does nothing } } @Test - static void testDefaultShutdownNow() throws Exception { + void testDefaultShutdownNow() throws Exception { try (HttpClient client = new MockHttpClient()) { client.shutdownNow(); // calls shutdown, doesn't wait } @@ -559,18 +560,18 @@ public class HttpClientBuilderTest { } // once from shutdownNow(), and once from close() - assertEquals(shutdownCalled.get(), 2); + assertEquals(2, shutdownCalled.get()); } @Test - static void testDefaultIsTerminated() throws Exception { + void testDefaultIsTerminated() throws Exception { try (HttpClient client = new MockHttpClient()) { assertFalse(client.isTerminated()); } } @Test - static void testDefaultAwaitTermination() throws Exception { + void testDefaultAwaitTermination() throws Exception { try (HttpClient client = new MockHttpClient()) { assertTrue(client.awaitTermination(Duration.ofDays(1))); } @@ -581,7 +582,7 @@ public class HttpClientBuilderTest { } @Test - static void testDefaultClose() { + void testDefaultClose() { AtomicInteger shutdownCalled = new AtomicInteger(); AtomicInteger awaitTerminationCalled = new AtomicInteger(); AtomicInteger shutdownNowCalled = new AtomicInteger(); @@ -616,9 +617,9 @@ public class HttpClientBuilderTest { // awaitTermination() 0->1 -> false // awaitTermination() 1->2 -> true try (HttpClient client = mock) { } - assertEquals(shutdownCalled.get(), 1); // called by close() - assertEquals(shutdownNowCalled.get(), 0); // not called - assertEquals(awaitTerminationCalled.get(), 2); // called by close() twice + assertEquals(1, shutdownCalled.get()); // called by close() + assertEquals(0, shutdownNowCalled.get()); // not called + assertEquals(2, awaitTerminationCalled.get()); // called by close() twice assertFalse(Thread.currentThread().isInterrupted()); // second time around: @@ -629,9 +630,9 @@ public class HttpClientBuilderTest { // calls shutdown() 2->3 // awaitTermination() 3->4 -> true try (HttpClient client = mock) { } - assertEquals(shutdownCalled.get(), 3); // called by close() and shutdownNow() - assertEquals(shutdownNowCalled.get(), 1); // called by close() due to interrupt - assertEquals(awaitTerminationCalled.get(), 4); // called by close twice + assertEquals(3, shutdownCalled.get()); // called by close() and shutdownNow() + assertEquals(1, shutdownNowCalled.get()); // called by close() due to interrupt + assertEquals(4, awaitTerminationCalled.get()); // called by close twice assertTrue(Thread.currentThread().isInterrupted()); assertTrue(Thread.interrupted()); } diff --git a/test/jdk/java/net/httpclient/HttpClientClose.java b/test/jdk/java/net/httpclient/HttpClientClose.java index e71faa8fe4e..0a3fc03424a 100644 --- a/test/jdk/java/net/httpclient/HttpClientClose.java +++ b/test/jdk/java/net/httpclient/HttpClientClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * HttpClientClose @@ -70,10 +70,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -84,10 +80,15 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class HttpClientClose implements HttpServerAdapters { @@ -96,27 +97,26 @@ public class HttpClientClose implements HttpServerAdapters { } static final Random RANDOM = RandomFactory.getRandom(); - ExecutorService readerService; + private static ExecutorService readerService; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) - HttpTestServer h3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h2h3Head; - String h3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) + private static HttpTestServer h3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h2h3Head; + private static String h3URI; static final String MESSAGE = "HttpClientClose message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig()}, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig()}, @@ -128,7 +128,7 @@ public class HttpClientClose implements HttpServerAdapters { } static final AtomicLong requestCounter = new AtomicLong(); - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static String readBody(InputStream body) { try (InputStream in = body) { @@ -138,7 +138,7 @@ public class HttpClientClose implements HttpServerAdapters { } } - private static record CancellingSubscriber(ExchangeResult result) + private record CancellingSubscriber(ExchangeResult result) implements Subscriber { @Override public void onSubscribe(Subscription subscription) { @@ -176,15 +176,15 @@ public class HttpClientClose implements HttpServerAdapters { boolean firstVersionMayNotMatch) { static ExchangeResult afterHead(int step, Version version, Http3DiscoveryMode config) { - return new ExchangeResult(step, version, config, null, false); + return new ExchangeResult<>(step, version, config, null, false); } static ExchangeResult ofSequential(int step, Version version, Http3DiscoveryMode config) { - return new ExchangeResult(step, version, config, null, true); + return new ExchangeResult<>(step, version, config, null, true); } ExchangeResult withResponse(HttpResponse response) { - return new ExchangeResult(step(), version(), config(), response, firstVersionMayNotMatch()); + return new ExchangeResult<>(step(), version(), config(), response, firstVersionMayNotMatch()); } // Ensures that the input stream gets closed in case of assertion @@ -193,11 +193,11 @@ public class HttpClientClose implements HttpServerAdapters { try { out.printf("%s: expect status 200 and version %s (%s) for %s%n", step, version, config, response.request().uri()); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (step == 0 && version == HTTP_3 && firstVersionMayNotMatch) { out.printf("%s: version not checked%n", step); } else { - assertEquals(response.version(), version); + assertEquals(version, response.version()); out.printf("%s: got expected version %s%n", step, response.version()); } } catch (AssertionError error) { @@ -227,10 +227,11 @@ public class HttpClientClose implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting concurrent (%s, %s, %s) ----%n%n", uriString, version, config); Throwable failed = null; @@ -266,7 +267,7 @@ public class HttpClientClose implements HttpServerAdapters { bodyCF = responseCF .thenApplyAsync((resp) -> readBody(si, resp), readerService) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }); long sleep = RANDOM.nextLong(5); @@ -289,7 +290,8 @@ public class HttpClientClose implements HttpServerAdapters { failed == null ? "done" : failed.toString()); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting sequential (%s, %s, %s) ----%n%n", uriString, version, config); Throwable failed = null; @@ -320,7 +322,7 @@ public class HttpClientClose implements HttpServerAdapters { bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(HttpClientClose::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }) .thenApply((s) -> { @@ -340,8 +342,8 @@ public class HttpClientClose implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); readerService = Executors.newCachedThreadPool(); @@ -376,8 +378,8 @@ public class HttpClientClose implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.checkShutdown(5000); try { diff --git a/test/jdk/java/net/httpclient/HttpClientExceptionTest.java b/test/jdk/java/net/httpclient/HttpClientExceptionTest.java index f9c585d955e..dff7219c0c8 100644 --- a/test/jdk/java/net/httpclient/HttpClientExceptionTest.java +++ b/test/jdk/java/net/httpclient/HttpClientExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,8 +21,6 @@ * questions. */ -import org.testng.Assert; -import org.testng.annotations.Test; import java.io.IOException; import java.net.ProtocolFamily; import java.net.http.HttpClient; @@ -34,12 +32,15 @@ import java.nio.channels.Channel; import java.nio.channels.spi.AbstractSelector; import java.nio.channels.spi.SelectorProvider; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + /* * @test * @bug 8248006 * @summary The test checks if UncheckedIOException is thrown * @build HttpClientExceptionTest - * @run testng/othervm -Djava.nio.channels.spi.SelectorProvider=HttpClientExceptionTest$CustomSelectorProvider + * @run junit/othervm -Djava.nio.channels.spi.SelectorProvider=HttpClientExceptionTest$CustomSelectorProvider * HttpClientExceptionTest */ @@ -50,8 +51,8 @@ public class HttpClientExceptionTest { @Test public void testHttpClientException() { for(int i = 0; i < ITERATIONS; i++) { - Assert.assertThrows(HttpClient.newBuilder()::build); - Assert.assertThrows(HttpClient::newHttpClient); + Assertions.assertThrows(Throwable.class, HttpClient.newBuilder()::build); + Assertions.assertThrows(Throwable.class, HttpClient::newHttpClient); } } diff --git a/test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java b/test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java index 10cca697231..f1e8aecbaa4 100644 --- a/test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java +++ b/test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,11 +23,6 @@ import jdk.test.lib.net.IPSupport; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.Closeable; @@ -50,6 +45,12 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + /* * @test * @summary Tests HttpClient usage when configured with a local address to bind @@ -60,7 +61,7 @@ import static java.net.http.HttpClient.Version.HTTP_2; * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.IPSupport * jdk.httpclient.test.lib.common.HttpServerAdapters * - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=frames,ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * -Dsun.net.httpserver.idleInterval=50000 @@ -81,7 +82,7 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { private static final AtomicInteger IDS = new AtomicInteger(); // start various HTTP/HTTPS servers that will be invoked against in the tests - @BeforeClass + @BeforeAll public static void beforeClass() throws Exception { HttpServerAdapters.HttpTestHandler handler = (exchange) -> { // the handler receives a request and sends back a 200 response with the @@ -126,7 +127,7 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { } // stop each of the started servers - @AfterClass + @AfterAll public static void afterClass() throws Exception { // stop each of the server and accumulate any exception // that might happen during stop and finally throw @@ -166,8 +167,7 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { return prevException; } - @DataProvider(name = "params") - private Object[][] paramsProvider() throws Exception { + private static Object[][] paramsProvider() throws Exception { final List testMethodParams = new ArrayList<>(); final URI[] requestURIs = new URI[]{httpURI, httpsURI, http2URI, https2URI}; final Predicate requiresSSLContext = (uri) -> uri.getScheme().equals("https"); @@ -224,7 +224,7 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { // An object that holds a client and that can be closed // Used when closing the client might require closing additional // resources, such as an executor - sealed interface ClientCloseable extends Closeable { + public sealed interface ClientCloseable extends Closeable { HttpClient client(); @@ -261,7 +261,7 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { } // A supplier of ClientCloseable - sealed interface ClientProvider extends Supplier { + public sealed interface ClientProvider extends Supplier { ClientCloseable get(); @@ -323,7 +323,8 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { * seen by the server side handler is the same one as that is set on the * {@code client} */ - @Test(dataProvider = "params") + @ParameterizedTest + @MethodSource("paramsProvider") public void testSend(ClientProvider clientProvider, URI requestURI, InetAddress localAddress) throws Exception { try (var c = clientProvider.get()) { HttpClient client = c.client(); @@ -332,10 +333,10 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { // GET request var req = HttpRequest.newBuilder(requestURI).build(); var resp = client.send(req, HttpResponse.BodyHandlers.ofByteArray()); - Assert.assertEquals(resp.statusCode(), 200, "Unexpected status code"); + Assertions.assertEquals(200, resp.statusCode(), "Unexpected status code"); // verify the address only if a specific one was set on the client if (localAddress != null && !localAddress.isAnyLocalAddress()) { - Assert.assertEquals(resp.body(), localAddress.getAddress(), + Assertions.assertArrayEquals(localAddress.getAddress(), resp.body(), "Unexpected client address seen by the server handler"); } } @@ -347,7 +348,8 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { * seen by the server side handler is the same one as that is set on the * {@code client} */ - @Test(dataProvider = "params") + @ParameterizedTest + @MethodSource("paramsProvider") public void testSendAsync(ClientProvider clientProvider, URI requestURI, InetAddress localAddress) throws Exception { try (var c = clientProvider.get()) { HttpClient client = c.client(); @@ -359,10 +361,10 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { var cf = client.sendAsync(req, HttpResponse.BodyHandlers.ofByteArray()); var resp = cf.get(); - Assert.assertEquals(resp.statusCode(), 200, "Unexpected status code"); + Assertions.assertEquals(200, resp.statusCode(), "Unexpected status code"); // verify the address only if a specific one was set on the client if (localAddress != null && !localAddress.isAnyLocalAddress()) { - Assert.assertEquals(resp.body(), localAddress.getAddress(), + Assertions.assertArrayEquals(localAddress.getAddress(), resp.body(), "Unexpected client address seen by the server handler"); } } @@ -374,7 +376,8 @@ public class HttpClientLocalAddrTest implements HttpServerAdapters { * is used when multiple concurrent threads are involved in sending requests from * the {@code client} */ - @Test(dataProvider = "params") + @ParameterizedTest + @MethodSource("paramsProvider") public void testMultiSendRequests(ClientProvider clientProvider, URI requestURI, InetAddress localAddress) throws Exception { diff --git a/test/jdk/java/net/httpclient/HttpClientShutdown.java b/test/jdk/java/net/httpclient/HttpClientShutdown.java index 4a5583782cb..8532146c1e2 100644 --- a/test/jdk/java/net/httpclient/HttpClientShutdown.java +++ b/test/jdk/java/net/httpclient/HttpClientShutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * HttpClientShutdown @@ -74,10 +74,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -88,10 +84,15 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class HttpClientShutdown implements HttpServerAdapters { @@ -100,27 +101,26 @@ public class HttpClientShutdown implements HttpServerAdapters { } static final Random RANDOM = RandomFactory.getRandom(); - ExecutorService readerService; + private static ExecutorService readerService; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) - HttpTestServer h3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h2h3Head; - String h3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) + private static HttpTestServer h3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h2h3Head; + private static String h3URI; static final String MESSAGE = "HttpClientShutdown message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig()}, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig()}, @@ -216,11 +216,11 @@ public class HttpClientShutdown implements HttpServerAdapters { try { out.printf(now() + "%s: expect status 200 and version %s (%s) for %s%n", step, version, config, response.request().uri()); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (step == 0 && version == HTTP_3 && firstVersionMayNotMatch) { out.printf(now() + "%s: version not checked%n", step); } else { - assertEquals(response.version(), version); + assertEquals(version, response.version()); out.printf(now() + "%s: got expected version %s%n", step, response.version()); } } catch (AssertionError error) { @@ -238,7 +238,7 @@ public class HttpClientShutdown implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } static boolean hasExpectedMessage(IOException io) { @@ -272,7 +272,8 @@ public class HttpClientShutdown implements HttpServerAdapters { throw new AssertionError(what + ": Unexpected exception: " + cause, cause); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- %sstarting concurrent (%s, %s, %s) ----%n%n", now(), uriString, version, config); @@ -310,7 +311,7 @@ public class HttpClientShutdown implements HttpServerAdapters { bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(HttpClientShutdown::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); out.println(now() + si +": Got expected message: " + s); return s; }); @@ -375,7 +376,8 @@ public class HttpClientShutdown implements HttpServerAdapters { return failed; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- %sstarting sequential (%s, %s, %s) ----%n%n", now(), uriString, version, config); @@ -409,7 +411,7 @@ public class HttpClientShutdown implements HttpServerAdapters { bodyCF = responseCF.thenApplyAsync(HttpResponse::body, readerService) .thenApply(HttpClientShutdown::readBody) .thenApply((s) -> { - assertEquals(s, MESSAGE); + assertEquals(MESSAGE, s); return s; }) .thenApply((s) -> { @@ -461,8 +463,8 @@ public class HttpClientShutdown implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); readerService = Executors.newCachedThreadPool(); @@ -498,8 +500,8 @@ public class HttpClientShutdown implements HttpServerAdapters { start = System.nanoTime(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.checkShutdown(5000); try { diff --git a/test/jdk/java/net/httpclient/HttpHeadersOf.java b/test/jdk/java/net/httpclient/HttpHeadersOf.java index 6194ab0a472..77a800b7cf2 100644 --- a/test/jdk/java/net/httpclient/HttpHeadersOf.java +++ b/test/jdk/java/net/httpclient/HttpHeadersOf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @summary Tests for HttpHeaders.of factory method - * @run testng HttpHeadersOf + * @run junit HttpHeadersOf */ import java.net.http.HttpHeaders; @@ -33,13 +33,16 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.function.BiPredicate; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class HttpHeadersOf { @@ -59,12 +62,12 @@ public class HttpHeadersOf { @Override public String toString() { return "REJECT_ALL"; } }; - @DataProvider(name = "predicates") - public Object[][] predicates() { + public static Object[][] predicates() { return new Object[][] { { ACCEPT_ALL }, { REJECT_ALL } }; } - @Test(dataProvider = "predicates") + @ParameterizedTest + @MethodSource("predicates") public void testNull(BiPredicate filter) { assertThrows(NPE, () -> HttpHeaders.of(null, null)); assertThrows(NPE, () -> HttpHeaders.of(null, filter)); @@ -80,8 +83,7 @@ public class HttpHeadersOf { } - @DataProvider(name = "filterMaps") - public Object[][] filterMaps() { + public static Object[][] filterMaps() { List>> maps = List.of( Map.of("A", List.of("B"), "X", List.of("Y", "Z")), Map.of("A", List.of("B", "C"), "X", List.of("Y", "Z")), @@ -90,33 +92,33 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "filterMaps") + @ParameterizedTest + @MethodSource("filterMaps") public void testFilter(Map> map) { HttpHeaders headers = HttpHeaders.of(map, REJECT_ALL); - assertEquals(headers.map().size(), 0); + assertEquals(0, headers.map().size()); assertFalse(headers.firstValue("A").isPresent()); - assertEquals(headers.allValues("A").size(), 0); + assertEquals(0, headers.allValues("A").size()); headers = HttpHeaders.of(map, (name, value) -> { if (name.equals("A")) return true; else return false; }); - assertEquals(headers.map().size(), 1); + assertEquals(1, headers.map().size()); assertTrue(headers.firstValue("A").isPresent()); - assertEquals(headers.allValues("A"), map.get("A")); - assertEquals(headers.allValues("A").size(), map.get("A").size()); + assertEquals(map.get("A"), headers.allValues("A")); + assertEquals(map.get("A").size(), headers.allValues("A").size()); assertFalse(headers.firstValue("X").isPresent()); headers = HttpHeaders.of(map, (name, value) -> { if (name.equals("X")) return true; else return false; }); - assertEquals(headers.map().size(), 1); + assertEquals(1, headers.map().size()); assertTrue(headers.firstValue("X").isPresent()); - assertEquals(headers.allValues("X"), map.get("X")); - assertEquals(headers.allValues("X").size(), map.get("X").size()); + assertEquals(map.get("X"), headers.allValues("X")); + assertEquals(map.get("X").size(), headers.allValues("X").size()); assertFalse(headers.firstValue("A").isPresent()); } - @DataProvider(name = "mapValues") - public Object[][] mapValues() { + public static Object[][] mapValues() { List>> maps = List.of( Map.of("A", List.of("B")), Map.of("A", List.of("B", "C")), @@ -137,18 +139,19 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "mapValues") + @ParameterizedTest + @MethodSource("mapValues") public void testMapValues(Map> map) { HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL); - assertEquals(headers.map().size(), map.size()); + assertEquals(map.size(), headers.map().size()); assertTrue(headers.firstValue("A").isPresent()); assertTrue(headers.firstValue("a").isPresent()); - assertEquals(headers.firstValue("A").get(), "B"); - assertEquals(headers.firstValue("a").get(), "B"); - assertEquals(headers.allValues("A"), map.get("A")); - assertEquals(headers.allValues("a"), map.get("A")); - assertEquals(headers.allValues("F").size(), 0); + assertEquals("B", headers.firstValue("A").get()); + assertEquals("B", headers.firstValue("a").get()); + assertEquals(map.get("A"), headers.allValues("A")); + assertEquals(map.get("A"), headers.allValues("a")); + assertEquals(0, headers.allValues("F").size()); assertTrue(headers.map().get("A").contains("B")); assertFalse(headers.map().get("A").contains("F")); assertThrows(NFE, () -> headers.firstValueAsLong("A")); @@ -167,8 +170,7 @@ public class HttpHeadersOf { } - @DataProvider(name = "caseInsensitivity") - public Object[][] caseInsensitivity() { + public static Object[][] caseInsensitivity() { List>> maps = List.of( Map.of("Accept-Encoding", List.of("gzip, deflate")), Map.of("accept-encoding", List.of("gzip, deflate")), @@ -179,7 +181,8 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "caseInsensitivity") + @ParameterizedTest + @MethodSource("caseInsensitivity") public void testCaseInsensitivity(Map> map) { HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL); @@ -187,11 +190,11 @@ public class HttpHeadersOf { "aCCept-EnCODing", "accepT-encodinG")) { assertTrue(headers.firstValue(name).isPresent()); assertTrue(headers.allValues(name).contains("gzip, deflate")); - assertEquals(headers.firstValue(name).get(), "gzip, deflate"); - assertEquals(headers.allValues(name).size(), 1); - assertEquals(headers.map().size(), 1); - assertEquals(headers.map().get(name).size(), 1); - assertEquals(headers.map().get(name).get(0), "gzip, deflate"); + assertEquals("gzip, deflate", headers.firstValue(name).get()); + assertEquals(1, headers.allValues(name).size()); + assertEquals(1, headers.map().size()); + assertEquals(1, headers.map().get(name).size()); + assertEquals("gzip, deflate", headers.map().get(name).get(0)); } } @@ -212,8 +215,8 @@ public class HttpHeadersOf { HttpHeaders h2 = HttpHeaders.of(m2, ACCEPT_ALL); if (!m1.equals(m2)) mapDiffer++; if (m1.hashCode() != m2.hashCode()) mapHashDiffer++; - assertEquals(h1, h2, "HttpHeaders differ"); - assertEquals(h1.hashCode(), h2.hashCode(), + assertEquals(h2, h1, "HttpHeaders differ"); + assertEquals(h2.hashCode(), h1.hashCode(), "hashCode differ for " + List.of(m1,m2)); } } @@ -221,8 +224,7 @@ public class HttpHeadersOf { assertTrue(mapHashDiffer > 0, "all maps had same hashCode!"); } - @DataProvider(name = "valueAsLong") - public Object[][] valueAsLong() { + public static Object[][] valueAsLong() { return new Object[][] { new Object[] { Map.of("Content-Length", List.of("10")), 10l }, new Object[] { Map.of("Content-Length", List.of("101")), 101l }, @@ -232,15 +234,15 @@ public class HttpHeadersOf { }; } - @Test(dataProvider = "valueAsLong") + @ParameterizedTest + @MethodSource("valueAsLong") public void testValueAsLong(Map> map, long expected) { HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL); - assertEquals(headers.firstValueAsLong("Content-Length").getAsLong(), expected); + assertEquals(expected, headers.firstValueAsLong("Content-Length").getAsLong()); } - @DataProvider(name = "duplicateNames") - public Object[][] duplicateNames() { + public static Object[][] duplicateNames() { List>> maps = List.of( Map.of("X-name", List.of(), "x-name", List.of()), @@ -262,7 +264,8 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "duplicateNames") + @ParameterizedTest + @MethodSource("duplicateNames") public void testDuplicates(Map> map) { HttpHeaders headers; try { @@ -275,8 +278,7 @@ public class HttpHeadersOf { } - @DataProvider(name = "noSplittingJoining") - public Object[][] noSplittingJoining() { + public static Object[][] noSplittingJoining() { List>> maps = List.of( Map.of("A", List.of("B")), Map.of("A", List.of("B", "C")), @@ -296,24 +298,24 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "noSplittingJoining") + @ParameterizedTest + @MethodSource("noSplittingJoining") public void testNoSplittingJoining(Map> map) { HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL); Map> headersMap = headers.map(); - assertEquals(headers.map().size(), map.size()); + assertEquals(map.size(), headers.map().size()); for (Map.Entry> entry : map.entrySet()) { String headerName = entry.getKey(); List headerValues = entry.getValue(); - assertEquals(headerValues, headersMap.get(headerName)); - assertEquals(headerValues, headers.allValues(headerName)); - assertEquals(headerValues.get(0), headers.firstValue(headerName).get()); + assertEquals(headersMap.get(headerName), headerValues); + assertEquals(headers.allValues(headerName), headerValues); + assertEquals(headers.firstValue(headerName).get(), headerValues.get(0)); } } - @DataProvider(name = "trimming") - public Object[][] trimming() { + public static Object[][] trimming() { List>> maps = List.of( Map.of("A", List.of("B")), Map.of(" A", List.of("B")), @@ -331,23 +333,23 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "trimming") + @ParameterizedTest + @MethodSource("trimming") public void testTrimming(Map> map) { HttpHeaders headers = HttpHeaders.of(map, (name, value) -> { - assertEquals(name, "A"); - assertEquals(value, "B"); + assertEquals("A", name); + assertEquals("B", value); return true; }); - assertEquals(headers.map().size(), 1); - assertEquals(headers.firstValue("A").get(), "B"); - assertEquals(headers.allValues("A"), List.of("B")); - assertTrue(headers.map().get("A").equals(List.of("B"))); + assertEquals(1, headers.map().size()); + assertEquals("B", headers.firstValue("A").get()); + assertEquals(List.of("B"), headers.allValues("A")); + assertEquals(List.of("B"), headers.map().get("A")); } - @DataProvider(name = "emptyKey") - public Object[][] emptyKey() { + public static Object[][] emptyKey() { List>> maps = List.of( Map.of("", List.of("B")), Map.of(" ", List.of("B")), @@ -358,7 +360,8 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "emptyKey") + @ParameterizedTest + @MethodSource("emptyKey") public void testEmptyKey(Map> map) { HttpHeaders headers; try { @@ -371,8 +374,7 @@ public class HttpHeadersOf { } - @DataProvider(name = "emptyValue") - public Object[][] emptyValue() { + public static Object[][] emptyValue() { List>> maps = List.of( Map.of("A", List.of("")), Map.of("A", List.of("", "")), @@ -383,40 +385,41 @@ public class HttpHeadersOf { return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "emptyValue") + @ParameterizedTest + @MethodSource("emptyValue") public void testEmptyValue(Map> map) { HttpHeaders headers = HttpHeaders.of(map, (name, value) -> { - assertEquals(value, ""); + assertEquals("", value); return true; }); - assertEquals(headers.map().size(), map.size()); - assertEquals(headers.map().get("A").get(0), ""); - headers.allValues("A").forEach(v -> assertEquals(v, "")); - assertEquals(headers.firstValue("A").get(), ""); + assertEquals(map.size(), headers.map().size()); + assertEquals("", headers.map().get("A").get(0)); + headers.allValues("A").forEach(v -> assertEquals("", v)); + assertEquals("", headers.firstValue("A").get()); } - @DataProvider(name = "noValues") - public Object[][] noValues() { + public static Object[][] noValues() { List>> maps = List.of( Map.of("A", List.of()), Map.of("A", List.of(), "B", List.of()), Map.of("A", List.of(), "B", List.of(), "C", List.of()), - Map.of("A", new ArrayList()), - Map.of("A", new LinkedList()) + Map.of("A", new ArrayList<>()), + Map.of("A", new LinkedList<>()) ); return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "noValues") + @ParameterizedTest + @MethodSource("noValues") public void testNoValues(Map> map) { HttpHeaders headers = HttpHeaders.of(map, (name, value) -> { fail("UNEXPECTED call to filter"); return true; }); - assertEquals(headers.map().size(), 0); - assertEquals(headers.map().get("A"), null); - assertEquals(headers.allValues("A").size(), 0); + assertEquals(0, headers.map().size()); + assertNull(headers.map().get("A")); + assertEquals(0, headers.allValues("A").size()); assertFalse(headers.firstValue("A").isPresent()); } } diff --git a/test/jdk/java/net/httpclient/HttpInputStreamAvailableTest.java b/test/jdk/java/net/httpclient/HttpInputStreamAvailableTest.java index 5cca88716b6..99897a69a8c 100644 --- a/test/jdk/java/net/httpclient/HttpInputStreamAvailableTest.java +++ b/test/jdk/java/net/httpclient/HttpInputStreamAvailableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 * @bug 8306040 * @summary HttpResponseInputStream.available() returns 1 on empty stream @@ -47,19 +47,17 @@ import java.net.http.HttpResponse; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import static org.junit.jupiter.api.Assertions.assertEquals; -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HttpInputStreamAvailableTest { - private HttpServer server; - private int port; - static final String TEST_MESSAGE = "This is test message"; - static final int ZERO = 0; + private static HttpServer server; + private static int port; + private static final String TEST_MESSAGE = "This is test message"; + private static final int ZERO = 0; @BeforeAll - void setup() throws Exception { + static void setup() throws Exception { InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); server = HttpServer.create(addr, 0); @@ -72,69 +70,71 @@ public class HttpInputStreamAvailableTest { } @AfterAll - void teardown() throws Exception { + static void teardown() throws Exception { server.stop(0); } @Test public void test() throws Exception { - HttpClient client = HttpClient + try (HttpClient client = HttpClient .newBuilder() .proxy(HttpClient.Builder.NO_PROXY) - .build(); + .build()) { - URI uri = URIBuilder.newBuilder() - .scheme("http") - .loopback() - .port(port) - .path("/NonZeroResponse/") - .build(); + URI uri = URIBuilder.newBuilder() + .scheme("http") + .loopback() + .port(port) + .path("/NonZeroResponse/") + .build(); - HttpRequest request = HttpRequest - .newBuilder(uri) - .GET() - .build(); + HttpRequest request = HttpRequest + .newBuilder(uri) + .GET() + .build(); - // Send a httpRequest and assert the bytes available - HttpResponse response = client.send(request, - HttpResponse.BodyHandlers.ofInputStream()); - try ( InputStream in = response.body()) { - in.readNBytes(2); - // this is not guaranteed, but a failure here would be surprising - assertEquals(TEST_MESSAGE.length() - 2, in.available()); - //read the remaining data - in.readAllBytes(); - //available should return 0 - assertEquals(ZERO, in.available()); + // Send a httpRequest and assert the bytes available + HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofInputStream()); + try (InputStream in = response.body()) { + in.readNBytes(2); + // this is not guaranteed, but a failure here would be surprising + assertEquals(TEST_MESSAGE.length() - 2, in.available()); + //read the remaining data + in.readAllBytes(); + //available should return 0 + assertEquals(ZERO, in.available()); + } } } @Test public void test1() throws Exception { - HttpClient client = HttpClient + try (HttpClient client = HttpClient .newBuilder() .proxy(HttpClient.Builder.NO_PROXY) - .build(); + .build()) { - URI uri = URIBuilder.newBuilder() - .scheme("http") - .loopback() - .port(port) - .path("/ZeroResponse/") - .build(); + URI uri = URIBuilder.newBuilder() + .scheme("http") + .loopback() + .port(port) + .path("/ZeroResponse/") + .build(); - HttpRequest request = HttpRequest - .newBuilder(uri) - .GET() - .build(); + HttpRequest request = HttpRequest + .newBuilder(uri) + .GET() + .build(); - // Send a httpRequest and assert the bytes available - HttpResponse response = client.send(request, - HttpResponse.BodyHandlers.ofInputStream()); - try ( InputStream in = response.body()) { - assertEquals(ZERO, in.available()); - in.readAllBytes(); - assertEquals(ZERO, in.available()); + // Send a httpRequest and assert the bytes available + HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofInputStream()); + try (InputStream in = response.body()) { + assertEquals(ZERO, in.available()); + in.readAllBytes(); + assertEquals(ZERO, in.available()); + } } } diff --git a/test/jdk/java/net/httpclient/HttpRedirectTest.java b/test/jdk/java/net/httpclient/HttpRedirectTest.java index e03a12a049c..2bf90bbe02c 100644 --- a/test/jdk/java/net/httpclient/HttpRedirectTest.java +++ b/test/jdk/java/net/httpclient/HttpRedirectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,13 @@ import com.sun.net.httpserver.HttpsServer; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.AfterClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -63,7 +60,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import jdk.httpclient.test.lib.common.HttpServerAdapters; -/** +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/* * @test * @bug 8232625 * @summary This test verifies that the HttpClient works correctly when redirecting a post request. @@ -71,7 +73,7 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; * @build jdk.test.lib.net.SimpleSSLContext DigestEchoServer HttpRedirectTest * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm -Dtest.requiresHost=true + * @run junit/othervm -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.debug=false * HttpRedirectTest @@ -85,33 +87,30 @@ public class HttpRedirectTest implements HttpServerAdapters { SSLContext.setDefault(context); } - final AtomicLong requestCounter = new AtomicLong(); - final AtomicLong responseCounter = new AtomicLong(); - HttpTestServer http1Server; - HttpTestServer http2Server; - HttpTestServer https1Server; - HttpTestServer https2Server; - HttpTestServer http3Server; - DigestEchoServer.TunnelingProxy proxy; + static final AtomicLong requestCounter = new AtomicLong(); + private static HttpTestServer http1Server; + private static HttpTestServer http2Server; + private static HttpTestServer https1Server; + private static HttpTestServer https2Server; + private static HttpTestServer http3Server; + private static DigestEchoServer.TunnelingProxy proxy; - URI http1URI; - URI https1URI; - URI http2URI; - URI https2URI; - URI http3URI; - InetSocketAddress proxyAddress; - ProxySelector proxySelector; - HttpClient client; - List> futures = new CopyOnWriteArrayList<>(); - Set pending = new CopyOnWriteArraySet<>(); + private static URI http1URI; + private static URI https1URI; + private static URI http2URI; + private static URI https2URI; + private static URI http3URI; + private static InetSocketAddress proxyAddress; + private static ProxySelector proxySelector; + private static HttpClient client; - final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10, + static final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Shared by HTTP/1.1 servers - final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1, + static final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Used by the client - public HttpClient newHttpClient(ProxySelector ps) { - HttpClient.Builder builder = newClientBuilderForH3() + public static HttpClient newHttpClient(ProxySelector ps) { + HttpClient.Builder builder = HttpServerAdapters.createClientBuilderForH3() .sslContext(context) .executor(clientexec) .followRedirects(HttpClient.Redirect.ALWAYS) @@ -119,8 +118,7 @@ public class HttpRedirectTest implements HttpServerAdapters { return builder.build(); } - @DataProvider(name="uris") - Object[][] testURIs() throws URISyntaxException { + static Object[][] testURIs() { List uris = List.of( http3URI.resolve("direct/orig/"), http1URI.resolve("direct/orig/"), @@ -144,12 +142,11 @@ public class HttpRedirectTest implements HttpServerAdapters { ); Object[][] tests = new Object[redirects.size() * uris.size()][3]; int count = 0; - for (int i=0; i < uris.size(); i++) { - URI u = uris.get(i); - for (int j=0; j < redirects.size() ; j++) { - int code = redirects.get(j).getKey(); - String m = redirects.get(j).getValue(); - tests[count][0] = u.resolve(code +"/"); + for (URI u : uris) { + for (Map.Entry redirect : redirects) { + int code = redirect.getKey(); + String m = redirect.getValue(); + tests[count][0] = u.resolve(code + "/"); tests[count][1] = code; tests[count][2] = m; count++; @@ -158,8 +155,8 @@ public class HttpRedirectTest implements HttpServerAdapters { return tests; } - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { try { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -208,10 +205,8 @@ public class HttpRedirectTest implements HttpServerAdapters { proxySelector = new HttpProxySelector(proxyAddress); client = newHttpClient(proxySelector); System.out.println("Setup: done"); - } catch (Exception x) { + } catch (Exception | Error x) { tearDown(); throw x; - } catch (Error e) { - tearDown(); throw e; } } @@ -222,19 +217,19 @@ public class HttpRedirectTest implements HttpServerAdapters { client.sendAsync(request, HttpResponse.BodyHandlers.ofString()); HttpResponse resp = respCf.join(); if (method.equals("DO_NOT_FOLLOW")) { - assertEquals(resp.statusCode(), code, u + ": status code"); + assertEquals(code, resp.statusCode(), u + ": status code"); } else { - assertEquals(resp.statusCode(), 200, u + ": status code"); + assertEquals(200, resp.statusCode(), u + ": status code"); } if (method.equals("POST")) { - assertEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertEquals(REQUEST_BODY, resp.body(), u + ": body"); } else if (code == 304) { - assertEquals(resp.body(), "", u + ": body"); + assertEquals("", resp.body(), u + ": body"); } else if (method.equals("DO_NOT_FOLLOW")) { - assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); - assertNotEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertNotEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); + assertNotEquals(REQUEST_BODY, resp.body(), u + ": body"); } else { - assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); + assertEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); } } @@ -244,21 +239,21 @@ public class HttpRedirectTest implements HttpServerAdapters { client.sendAsync(request, HttpResponse.BodyHandlers.ofString()); HttpResponse resp = respCf.join(); if (method.equals("DO_NOT_FOLLOW")) { - assertEquals(resp.statusCode(), code, u + ": status code"); + assertEquals(code, resp.statusCode(), u + ": status code"); } else { - assertEquals(resp.statusCode(), 200, u + ": status code"); + assertEquals(200, resp.statusCode(), u + ": status code"); } if (method.equals("POST")) { - assertEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertEquals(REQUEST_BODY, resp.body(), u + ": body"); } else if (code == 304) { - assertEquals(resp.body(), "", u + ": body"); + assertEquals("", resp.body(), u + ": body"); } else if (method.equals("DO_NOT_FOLLOW")) { - assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); - assertNotEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertNotEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); + assertNotEquals(REQUEST_BODY, resp.body(), u + ": body"); } else if (code == 303) { - assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); + assertEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); } else { - assertEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertEquals(REQUEST_BODY, resp.body(), u + ": body"); } } @@ -270,7 +265,8 @@ public class HttpRedirectTest implements HttpServerAdapters { return builder; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("testURIs") public void testPOST(URI uri, int code, String method) throws Exception { URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet()); HttpRequest request = newRequestBuilder(u) @@ -279,7 +275,8 @@ public class HttpRedirectTest implements HttpServerAdapters { testNonIdempotent(u, request, code, method); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("testURIs") public void testPUT(URI uri, int code, String method) throws Exception { URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet()); System.out.println("Testing with " + u); @@ -289,7 +286,8 @@ public class HttpRedirectTest implements HttpServerAdapters { testIdempotent(u, request, code, method); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("testURIs") public void testFoo(URI uri, int code, String method) throws Exception { URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet()); System.out.println("Testing with " + u); @@ -300,7 +298,8 @@ public class HttpRedirectTest implements HttpServerAdapters { testIdempotent(u, request, code, method); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("testURIs") public void testGet(URI uri, int code, String method) throws Exception { URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet()); System.out.println("Testing with " + u); @@ -312,24 +311,24 @@ public class HttpRedirectTest implements HttpServerAdapters { HttpResponse resp = respCf.join(); // body will be preserved except for 304 and 303: this is a GET. if (method.equals("DO_NOT_FOLLOW")) { - assertEquals(resp.statusCode(), code, u + ": status code"); + assertEquals(code, resp.statusCode(), u + ": status code"); } else { - assertEquals(resp.statusCode(), 200, u + ": status code"); + assertEquals(200, resp.statusCode(), u + ": status code"); } if (code == 304) { - assertEquals(resp.body(), "", u + ": body"); + assertEquals("", resp.body(), u + ": body"); } else if (method.equals("DO_NOT_FOLLOW")) { - assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); - assertNotEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertNotEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); + assertNotEquals(REQUEST_BODY, resp.body(), u + ": body"); } else if (code == 303) { - assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body"); + assertEquals(GET_RESPONSE_BODY, resp.body(), u + ": body"); } else { - assertEquals(resp.body(), REQUEST_BODY, u + ": body"); + assertEquals(REQUEST_BODY, resp.body(), u + ": body"); } } - @AfterClass - public void tearDown() { + @AfterAll + public static void tearDown() { proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop); http1Server = stop(http1Server, HttpTestServer::stop); https1Server = stop(https1Server, HttpTestServer::stop); @@ -355,7 +354,7 @@ public class HttpRedirectTest implements HttpServerAdapters { private interface Stoppable { public void stop(T service) throws Exception; } static T stop(T service, Stoppable stop) { - try { if (service != null) stop.stop(service); } catch (Throwable x) { }; + try { if (service != null) stop.stop(service); } catch (Throwable x) { } return null; } diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ByteBufferUtils.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ByteBufferUtils.java index 29276dc7b60..0f9d6a373d4 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ByteBufferUtils.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ByteBufferUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 @@ public final class ByteBufferUtils { private static byte[] bytes(ByteBuffer buffer) { byte[] bytes = new byte[buffer.limit()]; - buffer.get(bytes); + buffer.get(buffer.position(), bytes); return bytes; } diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/FromPublisherTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/FromPublisherTest.java index f05eab0a2e5..7d3e78e0b29 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/FromPublisherTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/FromPublisherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.nio.ByteBuffer; +import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import static java.net.http.HttpRequest.BodyPublishers.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -37,16 +40,18 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @test * @bug 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::fromPublisher` behavior - * @build RecordingSubscriber - * @run junit FromPublisherTest + * @build ByteBufferUtils + * RecordingSubscriber + * ReplayTestSupport + * @run junit ${test.main.class} */ -class FromPublisherTest { +class FromPublisherTest extends ReplayTestSupport { @Test void testNullPublisher() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.fromPublisher(null)); - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.fromPublisher(null, 1)); + assertThrows(NullPointerException.class, () -> fromPublisher(null)); + assertThrows(NullPointerException.class, () -> fromPublisher(null, 1)); } @ParameterizedTest @@ -54,7 +59,7 @@ class FromPublisherTest { void testInvalidContentLength(long contentLength) { IllegalArgumentException exception = assertThrows( IllegalArgumentException.class, - () -> HttpRequest.BodyPublishers.fromPublisher(null, contentLength)); + () -> fromPublisher(null, contentLength)); String exceptionMessage = exception.getMessage(); assertTrue( exceptionMessage.contains("non-positive contentLength"), @@ -64,29 +69,26 @@ class FromPublisherTest { @ParameterizedTest @ValueSource(longs = {1, 2, 3, 4}) void testValidContentLength(long contentLength) { - HttpRequest.BodyPublisher publisher = - HttpRequest.BodyPublishers.fromPublisher(HttpRequest.BodyPublishers.noBody(), contentLength); + BodyPublisher publisher = fromPublisher(noBody(), contentLength); assertEquals(contentLength, publisher.contentLength()); } @Test void testNoContentLength() { - HttpRequest.BodyPublisher publisher = - HttpRequest.BodyPublishers.fromPublisher(HttpRequest.BodyPublishers.noBody()); + BodyPublisher publisher = fromPublisher(noBody()); assertEquals(-1, publisher.contentLength()); } @Test void testNullSubscriber() { - HttpRequest.BodyPublisher publisher = - HttpRequest.BodyPublishers.fromPublisher(HttpRequest.BodyPublishers.noBody()); + BodyPublisher publisher = fromPublisher(noBody()); assertThrows(NullPointerException.class, () -> publisher.subscribe(null)); } @Test void testDelegation() throws InterruptedException { BlockingQueue publisherInvocations = new LinkedBlockingQueue<>(); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.fromPublisher(subscriber -> { + BodyPublisher publisher = fromPublisher(subscriber -> { publisherInvocations.add("subscribe"); publisherInvocations.add(subscriber); }); @@ -97,4 +99,13 @@ class FromPublisherTest { assertTrue(subscriber.invocations.isEmpty()); } + @Override + Iterable createReplayTargets() { + byte[] content = ByteBufferUtils.byteArrayOfLength(10); + ByteBuffer expectedBuffer = ByteBuffer.wrap(content); + BodyPublisher delegatePublisher = ofByteArray(content); + BodyPublisher publisher = fromPublisher(delegatePublisher, delegatePublisher.contentLength()); + return List.of(new ReplayTarget(expectedBuffer, publisher)); + } + } diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/NoBodyTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/NoBodyTest.java index f58e9505c9a..d45482700d6 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/NoBodyTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/NoBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +23,10 @@ import org.junit.jupiter.api.Test; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.nio.ByteBuffer; +import java.util.List; import java.util.concurrent.Flow; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -32,17 +35,19 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @test * @bug 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::noBody` behavior - * @build RecordingSubscriber - * @run junit NoBodyTest + * @build ByteBufferUtils + * RecordingSubscriber + * ReplayTestSupport + * @run junit ${test.main.class} */ -class NoBodyTest { +class NoBodyTest extends ReplayTestSupport { @Test void test() throws InterruptedException { // Create the publisher - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.noBody(); + BodyPublisher publisher = BodyPublishers.noBody(); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -54,4 +59,11 @@ class NoBodyTest { } + @Override + Iterable createReplayTargets() { + ByteBuffer expectedBuffer = ByteBuffer.wrap(new byte[0]); + BodyPublisher publisher = BodyPublishers.noBody(); + return List.of(new ReplayTarget(expectedBuffer, publisher)); + } + } diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArrayTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArrayTest.java index 19f7369125d..25233c9dd99 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArrayTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArrayTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +25,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -39,30 +40,34 @@ import static org.junit.jupiter.api.Assertions.assertThrows; * @test * @bug 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::ofByteArray` behavior - * @build RecordingSubscriber - * @run junit OfByteArrayTest + * + * @build ByteBufferUtils + * RecordingSubscriber + * ReplayTestSupport + * + * @run junit ${test.main.class} * * @comment Using `main/othervm` to initiate tests that depend on a custom-configured JVM - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking "" 0 0 "" - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking a 0 0 "" - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking a 1 0 "" - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking a 0 1 a - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking ab 0 1 a - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking ab 1 1 b - * @run main/othervm -Djdk.httpclient.bufsize=3 OfByteArrayTest testChunking ab 0 2 ab - * @run main/othervm -Djdk.httpclient.bufsize=1 OfByteArrayTest testChunking abc 0 3 a:b:c - * @run main/othervm -Djdk.httpclient.bufsize=2 OfByteArrayTest testChunking abc 0 3 ab:c - * @run main/othervm -Djdk.httpclient.bufsize=2 OfByteArrayTest testChunking abcdef 2 4 cd:ef + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking "" 0 0 "" + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking a 0 0 "" + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking a 1 0 "" + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking a 0 1 a + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking ab 0 1 a + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking ab 1 1 b + * @run main/othervm -Djdk.httpclient.bufsize=3 ${test.main.class} testChunking ab 0 2 ab + * @run main/othervm -Djdk.httpclient.bufsize=1 ${test.main.class} testChunking abc 0 3 a:b:c + * @run main/othervm -Djdk.httpclient.bufsize=2 ${test.main.class} testChunking abc 0 3 ab:c + * @run main/othervm -Djdk.httpclient.bufsize=2 ${test.main.class} testChunking abcdef 2 4 cd:ef */ -public class OfByteArrayTest { +public class OfByteArrayTest extends ReplayTestSupport { private static final Charset CHARSET = StandardCharsets.US_ASCII; @Test void testNullContent() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofByteArray(null)); - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofByteArray(null, 1, 2)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofByteArray(null)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofByteArray(null, 1, 2)); } @ParameterizedTest @@ -78,7 +83,15 @@ public class OfByteArrayTest { byte[] content = contentText.getBytes(CHARSET); assertThrows( IndexOutOfBoundsException.class, - () -> HttpRequest.BodyPublishers.ofByteArray(content, offset, length)); + () -> BodyPublishers.ofByteArray(content, offset, length)); + } + + @Override + Iterable createReplayTargets() { + byte[] content = "this content needs to be replayed again and again".getBytes(CHARSET); + ByteBuffer expectedBuffer = ByteBuffer.wrap(content); + BodyPublisher publisher = BodyPublishers.ofByteArray(content); + return List.of(new ReplayTarget(expectedBuffer, publisher)); } /** @@ -105,7 +118,7 @@ public class OfByteArrayTest { // Create the publisher byte[] content = contentText.getBytes(CHARSET); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArray(content, offset, length); + BodyPublisher publisher = BodyPublishers.ofByteArray(content, offset, length); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArraysTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArraysTest.java index ab051d2020f..10784f7dbee 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArraysTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArraysTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +27,8 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Iterator; @@ -46,15 +47,18 @@ import static org.junit.jupiter.api.Assertions.assertThrows; * @test * @bug 8226303 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::ofByteArrays` behavior + * * @build ByteBufferUtils * RecordingSubscriber + * ReplayTestSupport + * * @run junit OfByteArraysTest * * @comment Using `main/othervm` to initiate tests that depend on a custom-configured JVM * @run main/othervm -Xmx64m OfByteArraysTest testOOM */ -public class OfByteArraysTest { +public class OfByteArraysTest extends ReplayTestSupport { @ParameterizedTest @ValueSource(ints = {0, 1, 2, 3}) @@ -65,7 +69,7 @@ public class OfByteArraysTest { .range(0, length) .mapToObj(i -> new byte[]{(byte) i}) .toList(); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(buffers::iterator); + BodyPublisher publisher = BodyPublishers.ofByteArrays(buffers::iterator); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -95,7 +99,7 @@ public class OfByteArraysTest { case 2 -> List.of(buffer2).iterator(); default -> throw new AssertionError(); }; - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(iterable); + BodyPublisher publisher = BodyPublishers.ofByteArrays(iterable); // Subscribe twice (to force two `Iterable::iterator` invocations) RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -112,14 +116,14 @@ public class OfByteArraysTest { @Test void testNullIterable() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofByteArrays(null)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofByteArrays(null)); } @Test void testNullIterator() throws InterruptedException { // Create the publisher - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(() -> null); + BodyPublisher publisher = BodyPublishers.ofByteArrays(() -> null); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -138,7 +142,7 @@ public class OfByteArraysTest { // Create the publisher List iterable = new ArrayList<>(); iterable.add(null); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(iterable); + BodyPublisher publisher = BodyPublishers.ofByteArrays(iterable); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -156,7 +160,7 @@ public class OfByteArraysTest { // Create the publisher RuntimeException exception = new RuntimeException("failure for `testIteratorCreationException`"); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(() -> { + BodyPublisher publisher = BodyPublishers.ofByteArrays(() -> { throw exception; }); @@ -192,7 +196,7 @@ public class OfByteArraysTest { // Create the publisher IteratorThrowingAtEnd iterator = new IteratorThrowingAtEnd(exceptionIndex, hasNextException, nextException); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(() -> iterator); + BodyPublisher publisher = BodyPublishers.ofByteArrays(() -> iterator); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -257,6 +261,14 @@ public class OfByteArraysTest { } + @Override + Iterable createReplayTargets() { + byte[] byteArray = ByteBufferUtils.byteArrayOfLength(9); + ByteBuffer expectedBuffer = ByteBuffer.wrap(byteArray); + BodyPublisher publisher = BodyPublishers.ofByteArrays(List.of(byteArray)); + return List.of(new ReplayTarget(expectedBuffer, -1, publisher, null)); + } + /** * Initiates tests that depend on a custom-configured JVM. */ @@ -273,7 +285,7 @@ public class OfByteArraysTest { // Create the publisher int length = ByteBufferUtils.findLengthExceedingMaxMemory(); Iterable iterable = createIterableOfLength(length); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofByteArrays(iterable); + BodyPublisher publisher = BodyPublishers.ofByteArrays(iterable); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); diff --git a/test/jdk/java/net/httpclient/FileChannelPublisherTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileChannelTest.java similarity index 96% rename from test/jdk/java/net/httpclient/FileChannelPublisherTest.java rename to test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileChannelTest.java index c9c78791da3..47596f40a5f 100644 --- a/test/jdk/java/net/httpclient/FileChannelPublisherTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileChannelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,12 @@ * @summary Verifies `HttpRequest.BodyPublishers::ofFileChannel` * @library /test/lib * /test/jdk/java/net/httpclient/lib - * @build jdk.httpclient.test.lib.common.HttpServerAdapters + * @build ByteBufferUtils + * RecordingSubscriber + * ReplayTestSupport + * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext - * @run junit FileChannelPublisherTest + * @run junit ${test.main.class} */ import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestHandler; @@ -52,8 +55,10 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; +import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.nio.file.Files; @@ -82,9 +87,9 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class FileChannelPublisherTest { +class OfFileChannelTest extends ReplayTestSupport { - private static final String CLASS_NAME = FileChannelPublisherTest.class.getSimpleName(); + private static final String CLASS_NAME = OfFileChannelTest.class.getSimpleName(); private static final Logger LOGGER = Utils.getDebugLogger(CLASS_NAME::toString, Utils.DEBUG); @@ -650,6 +655,22 @@ class FileChannelPublisherTest { } + @Override + Iterable createReplayTargets() { + int fileLength = 42; + byte[] fileBytes = generateFileBytes(fileLength); + Path filePath = Path.of("replayTarget.txt"); + try { + Files.write(filePath, fileBytes, StandardOpenOption.CREATE); + FileChannel fileChannel = FileChannel.open(filePath); + BodyPublisher publisher = BodyPublishers.ofFileChannel(fileChannel, 0, fileLength); + ByteBuffer expectedBuffer = ByteBuffer.wrap(fileBytes); + return List.of(new ReplayTarget(expectedBuffer, fileLength, publisher, fileChannel)); + } catch (IOException ioe) { + throw new UncheckedIOException(ioe); + } + } + /** * Performs the initial {@code HEAD} request to the specified server. This * effectively admits a connection to the client's pool, where all protocol diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileTest.java index 94b5a596fc6..7287468d600 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.UncheckedIOException; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; import java.nio.ByteBuffer; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -51,15 +52,18 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @test * @bug 8226303 8235459 8358688 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::ofFile` behavior + * * @build ByteBufferUtils * RecordingSubscriber - * @run junit OfFileTest + * ReplayTestSupport + * + * @run junit ${test.main.class} * * @comment Using `main/othervm` to initiate tests that depend on a custom-configured JVM - * @run main/othervm -Xmx64m OfFileTest testOOM + * @run main/othervm -Xmx64m ${test.main.class} testOOM */ -public class OfFileTest { +public class OfFileTest extends ReplayTestSupport { private static final Path DEFAULT_FS_DIR = Path.of(System.getProperty("user.dir", ".")); @@ -89,14 +93,14 @@ public class OfFileTest { @Test void testNullPath() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofFile(null)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofFile(null)); } @ParameterizedTest @MethodSource("parentDirs") void testNonExistentPath(Path parentDir) { Path nonExistentPath = createFilePath(parentDir, "testNonExistentPath"); - assertThrows(FileNotFoundException.class, () -> HttpRequest.BodyPublishers.ofFile(nonExistentPath)); + assertThrows(FileNotFoundException.class, () -> BodyPublishers.ofFile(nonExistentPath)); } @ParameterizedTest @@ -106,7 +110,7 @@ public class OfFileTest { // Create the publisher byte[] fileBytes = ByteBufferUtils.byteArrayOfLength(3); Path filePath = createFile(parentDir, "testNonExistentPathAtSubscribe", fileBytes); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofFile(filePath); + BodyPublisher publisher = BodyPublishers.ofFile(filePath); // Delete the file Files.delete(filePath); @@ -131,7 +135,7 @@ public class OfFileTest { void testIrregularFile(Path parentDir) throws Exception { // Create the publisher - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofFile(parentDir); + BodyPublisher publisher = BodyPublishers.ofFile(parentDir); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -167,7 +171,7 @@ public class OfFileTest { // Create the publisher byte[] fileBytes = ByteBufferUtils.byteArrayOfLength(BIG_FILE_LENGTH); Path filePath = createFile(parentDir, "testFileModificationWhileReading", fileBytes); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofFile(filePath); + BodyPublisher publisher = BodyPublishers.ofFile(filePath); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -210,7 +214,7 @@ public class OfFileTest { // Create the publisher byte[] fileBytes = ByteBufferUtils.byteArrayOfLength(fileLength); Path filePath = createFile(parentDir, "testFileOfLength", fileBytes); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofFile(filePath); + BodyPublisher publisher = BodyPublishers.ofFile(filePath); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -222,6 +226,24 @@ public class OfFileTest { } + @Override + Iterable createReplayTargets() { + byte[] fileBytes = ByteBufferUtils.byteArrayOfLength(3); + ByteBuffer expectedBuffer = ByteBuffer.wrap(fileBytes); + return parentDirs() + .stream() + .map(parentDir -> { + try { + Path filePath = createFile(parentDir, "replayTest", fileBytes); + BodyPublisher publisher = BodyPublishers.ofFile(filePath); + return new ReplayTarget(expectedBuffer, publisher); + } catch (IOException ioe) { + throw new UncheckedIOException(ioe); + } + }) + .toList(); + } + /** * Initiates tests that depend on a custom-configured JVM. */ @@ -248,7 +270,7 @@ public class OfFileTest { // Create the publisher int fileLength = ByteBufferUtils.findLengthExceedingMaxMemory(); Path filePath = createFileOfLength(parentDir, "testOOM", fileLength); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofFile(filePath); + BodyPublisher publisher = BodyPublishers.ofFile(filePath); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfInputStreamTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfInputStreamTest.java index 7688c1674ee..06ed13333ae 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfInputStreamTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfInputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +28,9 @@ import org.junit.jupiter.params.provider.ValueSource; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.nio.ByteBuffer; import java.util.List; import java.util.concurrent.Flow; import java.util.function.Supplier; @@ -41,19 +43,22 @@ import static org.junit.jupiter.api.Assertions.assertThrows; * @test * @bug 8364733 * @summary Verify all specified `HttpRequest.BodyPublishers::ofInputStream` behavior + * * @build ByteBufferUtils * RecordingSubscriber - * @run junit OfInputStreamTest + * ReplayTestSupport + * + * @run junit ${test.main.class} * * @comment Using `main/othervm` to initiate tests that depend on a custom-configured JVM - * @run main/othervm -Xmx64m OfInputStreamTest testOOM + * @run main/othervm -Xmx64m ${test.main.class} testOOM */ -public class OfInputStreamTest { +public class OfInputStreamTest extends ReplayTestSupport { @Test void testNullInputStreamSupplier() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofInputStream(null)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofInputStream(null)); } @Test @@ -61,7 +66,7 @@ public class OfInputStreamTest { // Create the publisher RuntimeException exception = new RuntimeException(); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofInputStream(() -> { throw exception; }); + BodyPublisher publisher = BodyPublishers.ofInputStream(() -> { throw exception; }); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -80,7 +85,7 @@ public class OfInputStreamTest { void testNullInputStream() throws InterruptedException { // Create the publisher - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofInputStream(() -> null); + BodyPublisher publisher = BodyPublishers.ofInputStream(() -> null); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -107,7 +112,7 @@ public class OfInputStreamTest { case 2 -> new ByteArrayInputStream(buffer2); default -> throw new AssertionError(); }; - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofInputStream(inputStreamSupplier); + BodyPublisher publisher = BodyPublishers.ofInputStream(inputStreamSupplier); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -129,7 +134,7 @@ public class OfInputStreamTest { // Create the publisher byte[] content = ByteBufferUtils.byteArrayOfLength(length); InputStream inputStream = new ByteArrayInputStream(content); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofInputStream(() -> inputStream); + BodyPublisher publisher = BodyPublishers.ofInputStream(() -> inputStream); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -148,7 +153,7 @@ public class OfInputStreamTest { // Create the publisher RuntimeException exception = new RuntimeException("failure for `read`"); InputStream inputStream = new InputStreamThrowingOnCompletion(exceptionIndex, exception); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofInputStream(() -> inputStream); + BodyPublisher publisher = BodyPublishers.ofInputStream(() -> inputStream); // Subscribe RecordingSubscriber subscriber = new RecordingSubscriber(); @@ -185,6 +190,14 @@ public class OfInputStreamTest { } + @Override + Iterable createReplayTargets() { + byte[] content = ByteBufferUtils.byteArrayOfLength(10); + ByteBuffer expectedBuffer = ByteBuffer.wrap(content); + BodyPublisher publisher = BodyPublishers.ofInputStream(() -> new ByteArrayInputStream(content)); + return List.of(new ReplayTarget(expectedBuffer, -1, publisher, null)); + } + /** * Initiates tests that depend on a custom-configured JVM. */ @@ -200,8 +213,8 @@ public class OfInputStreamTest { // Create the publisher using an `InputStream` that emits content exceeding the maximum memory int length = ByteBufferUtils.findLengthExceedingMaxMemory(); - HttpRequest.BodyPublisher publisher = - HttpRequest.BodyPublishers.ofInputStream(() -> new InputStream() { + BodyPublisher publisher = + BodyPublishers.ofInputStream(() -> new InputStream() { private int position; diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfStringTest.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfStringTest.java index 143b5ce17da..2e1fcb11f99 100644 --- a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfStringTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,12 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; -import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.List; import java.util.concurrent.Flow; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -41,10 +43,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; * @summary Verify all specified `HttpRequest.BodyPublishers::ofString` behavior * @build ByteBufferUtils * RecordingSubscriber - * @run junit OfStringTest + * ReplayTestSupport + * @run junit ${test.main.class} */ -class OfStringTest { +class OfStringTest extends ReplayTestSupport { private static final Charset CHARSET = StandardCharsets.US_ASCII; @@ -58,7 +61,7 @@ class OfStringTest { contentChars[i] = (char) ('a' + i); } String content = new String(contentChars); - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofString(content, CHARSET); + BodyPublisher publisher = BodyPublishers.ofString(content, CHARSET); // Subscribe assertEquals(length, publisher.contentLength()); @@ -87,7 +90,7 @@ class OfStringTest { void testCharset(String content, Charset charset) throws InterruptedException { // Create the publisher - HttpRequest.BodyPublisher publisher = HttpRequest.BodyPublishers.ofString(content, charset); + BodyPublisher publisher = BodyPublishers.ofString(content, charset); // Subscribe ByteBuffer expectedBuffer = charset.encode(content); @@ -108,12 +111,20 @@ class OfStringTest { @Test void testNullContent() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofString(null, CHARSET)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofString(null, CHARSET)); } @Test void testNullCharset() { - assertThrows(NullPointerException.class, () -> HttpRequest.BodyPublishers.ofString("foo", null)); + assertThrows(NullPointerException.class, () -> BodyPublishers.ofString("foo", null)); + } + + @Override + Iterable createReplayTargets() { + String content = "this content needs to be replayed again and again"; + ByteBuffer expectedBuffer = CHARSET.encode(content); + BodyPublisher publisher = BodyPublishers.ofString(content, CHARSET); + return List.of(new ReplayTarget(expectedBuffer, publisher)); } } diff --git a/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ReplayTestSupport.java b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ReplayTestSupport.java new file mode 100644 index 00000000000..788b59e96b7 --- /dev/null +++ b/test/jdk/java/net/httpclient/HttpRequestBodyPublishers/ReplayTestSupport.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2026, 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 org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.net.http.HttpRequest.BodyPublisher; +import java.nio.ByteBuffer; +import java.util.concurrent.Flow; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for verifying that a request body publisher supports multiple subscriptions, aka. replayable. + */ +public abstract class ReplayTestSupport { + + @ParameterizedTest + @ValueSource(strings = { + // 2 subscriptions + "subscribe-cancel-subscribe-cancel", + "subscribe-cancel-subscribe-request", + "subscribe-request-subscribe-cancel", + "subscribe-request-subscribe-request", + // 3 subscriptions + "subscribe-cancel-subscribe-cancel-subscribe-request", + "subscribe-cancel-subscribe-request-subscribe-cancel", + "subscribe-cancel-subscribe-request-subscribe-request", + "subscribe-request-subscribe-cancel-subscribe-cancel", + "subscribe-request-subscribe-cancel-subscribe-request", + "subscribe-request-subscribe-request-subscribe-cancel", + "subscribe-request-subscribe-request-subscribe-request", + }) + void testReplay(String opSequence) throws Exception { + for (ReplayTarget replayTarget : createReplayTargets()) { + try (replayTarget) { + System.err.printf("Executing test for replay target: %s%n", replayTarget); + testReplay(opSequence, replayTarget); + } + } + } + + private static void testReplay(String opSequence, ReplayTarget replayTarget) throws InterruptedException { + + // Create the publisher + ByteBuffer expectedBuffer = replayTarget.expectedBuffer; + BodyPublisher publisher = replayTarget.publisher; + assertEquals(replayTarget.expectedContentLength, publisher.contentLength()); + + // Execute the specified operations + RecordingSubscriber subscriber = null; + Flow.Subscription subscription = null; + String[] ops = opSequence.split("-"); + for (int opIndex = 0; opIndex < ops.length; opIndex++) { + String op = ops[opIndex]; + System.err.printf("Executing operation at index %s: %s%n", opIndex, op); + switch (op) { + + case "subscribe": { + subscriber = new RecordingSubscriber(); + publisher.subscribe(subscriber); + assertEquals("onSubscribe", subscriber.invocations.take()); + subscription = (Flow.Subscription) subscriber.invocations.take(); + break; + } + + case "request": { + assert subscription != null; + subscription.request(Long.MAX_VALUE); + if (expectedBuffer.hasRemaining()) { + assertEquals("onNext", subscriber.invocations.take()); + ByteBuffer actualBuffer = (ByteBuffer) subscriber.invocations.take(); + ByteBufferUtils.assertEquals(expectedBuffer, actualBuffer, null); + } + assertEquals("onComplete", subscriber.invocations.take()); + break; + } + + case "cancel": { + assert subscription != null; + subscription.cancel(); + break; + } + + default: throw new IllegalArgumentException("Unknown operation: " + op); + + } + } + + } + + abstract Iterable createReplayTargets(); + + public record ReplayTarget( + ByteBuffer expectedBuffer, + int expectedContentLength, + BodyPublisher publisher, + AutoCloseable resource) + implements AutoCloseable { + + public ReplayTarget(ByteBuffer expectedBuffer, BodyPublisher publisher) { + this(expectedBuffer, expectedBuffer.limit(), publisher, null); + } + + @Override + public void close() throws Exception { + if (resource != null) { + resource.close(); + } + } + + } + +} diff --git a/test/jdk/java/net/httpclient/HttpRequestNewBuilderTest.java b/test/jdk/java/net/httpclient/HttpRequestNewBuilderTest.java index d7598ede3be..19afbfbd99b 100644 --- a/test/jdk/java/net/httpclient/HttpRequestNewBuilderTest.java +++ b/test/jdk/java/net/httpclient/HttpRequestNewBuilderTest.java @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2021, 2026, 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 @@ -44,19 +44,21 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Assertions; +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; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -/** +/* * @test * @bug 8252304 8276559 * @summary HttpRequest.newBuilder(HttpRequest) API and behaviour checks -* @run testng/othervm HttpRequestNewBuilderTest +* @run junit/othervm HttpRequestNewBuilderTest */ public class HttpRequestNewBuilderTest { static final Class NPE = NullPointerException.class; @@ -64,21 +66,19 @@ public class HttpRequestNewBuilderTest { record NamedAssertion(String name, BiConsumer test) { } - List REQUEST_ASSERTIONS = List.of( - new NamedAssertion("uri", (r1, r2) -> assertEquals(r1.uri(), r2.uri())), - new NamedAssertion("timeout", (r1, r2) -> assertEquals(r1.timeout(), r2.timeout())), - new NamedAssertion("version", (r1, r2) -> assertEquals(r1.version(), r2.version())), - new NamedAssertion("headers", (r1, r2) -> assertEquals(r1.headers(), r2.headers())), - new NamedAssertion("options", (r1, r2) -> assertEquals(r1.getOption(H3_DISCOVERY), r2.getOption(H3_DISCOVERY))), - new NamedAssertion("expectContinue", (r1, r2) -> assertEquals(r1.expectContinue(), r2.expectContinue())), + static List REQUEST_ASSERTIONS = List.of(new NamedAssertion("uri", (r1, r2) -> assertEquals(r2.uri(), r1.uri())), + new NamedAssertion("timeout", (r1, r2) -> assertEquals(r2.timeout(), r1.timeout())), + new NamedAssertion("version", (r1, r2) -> assertEquals(r2.version(), r1.version())), + new NamedAssertion("headers", (r1, r2) -> assertEquals(r2.headers(), r1.headers())), + new NamedAssertion("options", (r1, r2) -> assertEquals(r2.getOption(H3_DISCOVERY), r1.getOption(H3_DISCOVERY))), + new NamedAssertion("expectContinue", (r1, r2) -> assertEquals(r2.expectContinue(), r1.expectContinue())), new NamedAssertion("method", (r1, r2) -> { - assertEquals(r1.method(), r2.method()); + assertEquals(r2.method(), r1.method()); assertBodyPublisherEqual(r1, r2); }) ); - @DataProvider(name = "testRequests") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { HttpRequest.newBuilder(URI.create("https://uri-1/")).build() }, { HttpRequest.newBuilder(URI.create("https://version-1/")).version(HTTP_1_1).build() }, @@ -152,14 +152,14 @@ public class HttpRequestNewBuilderTest { } // test methods - void assertBodyPublisherEqual(HttpRequest r1, HttpRequest r2) { + static void assertBodyPublisherEqual(HttpRequest r1, HttpRequest r2) { if (r1.bodyPublisher().isPresent()) { assertTrue(r2.bodyPublisher().isPresent()); var bp1 = r1.bodyPublisher().get(); var bp2 = r2.bodyPublisher().get(); - assertEquals(bp1.getClass(), bp2.getClass()); - assertEquals(bp1.contentLength(), bp2.contentLength()); + assertEquals(bp2.getClass(), bp1.getClass()); + assertEquals(bp2.contentLength(), bp1.contentLength()); final class TestSubscriber implements Flow.Subscriber { final BodySubscriber s; @@ -181,7 +181,7 @@ public class HttpRequestNewBuilderTest { bp2.subscribe(new TestSubscriber(bs2)); var b2 = bs2.getBody().toCompletableFuture().join().getBytes(); - assertEquals(b1, b2); + Assertions.assertArrayEquals(b2, b1); } else { assertFalse(r2.bodyPublisher().isPresent()); } @@ -199,9 +199,9 @@ public class HttpRequestNewBuilderTest { var r = HttpRequest.newBuilder(request, (n, v) -> true) .method(methodName, HttpRequest.BodyPublishers.ofString("testData")) .build(); - assertEquals(r.method(), methodName); + assertEquals(methodName, r.method()); assertTrue(r.bodyPublisher().isPresent()); - assertEquals(r.bodyPublisher().get().contentLength(), 8); + assertEquals(8, r.bodyPublisher().get().contentLength()); assertAllOtherElementsEqual(r, request, "method"); // method w/o body @@ -209,9 +209,9 @@ public class HttpRequestNewBuilderTest { var r1 = HttpRequest.newBuilder(request, (n, v) -> true) .method(methodName, noBodyPublisher) .build(); - assertEquals(r1.method(), methodName); + assertEquals(methodName, r1.method()); assertTrue(r1.bodyPublisher().isPresent()); - assertEquals(r1.bodyPublisher().get(), noBodyPublisher); + assertEquals(noBodyPublisher, r1.bodyPublisher().get()); assertAllOtherElementsEqual(r1, request, "method"); } @@ -223,113 +223,125 @@ public class HttpRequestNewBuilderTest { assertThrows(NPE, () -> HttpRequest.newBuilder(null, null)); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") void testBuilder(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true).build(); - assertEquals(r, request); + assertEquals(request, r); assertAllOtherElementsEqual(r, request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testURI(HttpRequest request) { URI newURI = URI.create("http://www.newURI.com/"); var r = HttpRequest.newBuilder(request, (n, v) -> true).uri(newURI).build(); - assertEquals(r.uri(), newURI); + assertEquals(newURI, r.uri()); assertAllOtherElementsEqual(r, request, "uri"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testTimeout(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true).timeout(Duration.ofSeconds(2)).build(); - assertEquals(r.timeout().get().getSeconds(), 2); + assertEquals(2, r.timeout().get().getSeconds()); assertAllOtherElementsEqual(r, request, "timeout"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testVersion(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true).version(HTTP_1_1).build(); - assertEquals(r.version().get(), HTTP_1_1); + assertEquals(HTTP_1_1, r.version().get()); assertAllOtherElementsEqual(r, request, "version"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testGET(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true) .GET() .build(); - assertEquals(r.method(), "GET"); + assertEquals("GET", r.method()); assertTrue(r.bodyPublisher().isEmpty()); assertAllOtherElementsEqual(r, request, "method"); testBodyPublisher("GET", request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testDELETE(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true) .DELETE() .build(); - assertEquals(r.method(), "DELETE"); + assertEquals("DELETE", r.method()); assertTrue(r.bodyPublisher().isEmpty()); assertAllOtherElementsEqual(r, request, "method"); testBodyPublisher("DELETE", request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testPOST(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true) .POST(HttpRequest.BodyPublishers.ofString("testData")) .build(); - assertEquals(r.method(), "POST"); + assertEquals("POST", r.method()); assertTrue(r.bodyPublisher().isPresent()); - assertEquals(r.bodyPublisher().get().contentLength(), 8); + assertEquals(8, r.bodyPublisher().get().contentLength()); assertAllOtherElementsEqual(r, request, "method"); testBodyPublisher("POST", request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testPUT(HttpRequest request) { var r = HttpRequest.newBuilder(request, (n, v) -> true) .PUT(HttpRequest.BodyPublishers.ofString("testData")) .build(); - assertEquals(r.method(), "PUT"); + assertEquals("PUT", r.method()); assertTrue(r.bodyPublisher().isPresent()); - assertEquals(r.bodyPublisher().get().contentLength(), 8); + assertEquals(8, r.bodyPublisher().get().contentLength()); assertAllOtherElementsEqual(r, request, "method"); testBodyPublisher("PUT", request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testUserDefinedMethod(HttpRequest request) { testBodyPublisher("TEST", request); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testAddHeader(HttpRequest request) { BiPredicate filter = (n, v) -> true; var r = HttpRequest.newBuilder(request, filter).headers("newName", "newValue").build(); - assertEquals(r.headers().firstValue("newName").get(), "newValue"); - assertEquals(r.headers().allValues("newName").size(), 1); + assertEquals("newValue", r.headers().firstValue("newName").get()); + assertEquals(1, r.headers().allValues("newName").size()); assertAllOtherElementsEqual(r, request, "headers"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testSetOption(HttpRequest request) { BiPredicate filter = (n, v) -> true; var r = HttpRequest.newBuilder(request, filter).setOption(H3_DISCOVERY, ALT_SVC).build(); - assertEquals(r.getOption(H3_DISCOVERY).get(), ALT_SVC); + assertEquals(ALT_SVC, r.getOption(H3_DISCOVERY).get()); assertAllOtherElementsEqual(r, request, "options"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRemoveHeader(HttpRequest request) { if(!request.headers().map().isEmpty()) { assertTrue(request.headers().map().containsKey("testName1")); @@ -338,13 +350,14 @@ public class HttpRequestNewBuilderTest { var r = HttpRequest.newBuilder(request, filter).build(); assertFalse(r.headers().map().containsKey("testName1")); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRemoveOption(HttpRequest request) { if(!request.getOption(H3_DISCOVERY).isEmpty()) { - assertEquals(request.getOption(H3_DISCOVERY).get(), ANY); + assertEquals(ANY, request.getOption(H3_DISCOVERY).get()); } var r = HttpRequest.newBuilder(request, (a, b) -> true) @@ -353,7 +366,8 @@ public class HttpRequestNewBuilderTest { assertAllOtherElementsEqual(r, request, "options"); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRemoveSingleHeaderValue(HttpRequest request) { if(!request.headers().map().isEmpty()) { assertTrue(request.headers().allValues("testName1").contains("testValue1")); @@ -363,10 +377,12 @@ public class HttpRequestNewBuilderTest { var r = HttpRequest.newBuilder(request, filter).build(); assertFalse(r.headers().map().containsValue("testValue1")); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertFalse(r.headers().allValues("testName1").contains("testValue1")); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRemoveMultipleHeaders(HttpRequest request) { BiPredicate isTestName1Value1 = (n ,v) -> n.equalsIgnoreCase("testName1") && v.equals("testValue1"); @@ -375,34 +391,36 @@ public class HttpRequestNewBuilderTest { var filter = (isTestName1Value1.or(isTestName2Value2)).negate(); var r = HttpRequest.newBuilder(request, filter).build(); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); BiPredicate filter1 = (n, v) -> !(n.equalsIgnoreCase("testName1") && (v.equals("testValue1") || v.equals("testValue2"))); var r1 = HttpRequest.newBuilder(request, filter1).build(); - assertEquals(r1.headers().map(), HttpHeaders.of(request.headers().map(), filter1).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter1).map(), r1.headers().map()); } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRemoveAllHeaders(HttpRequest request) { if (!request.headers().map().isEmpty()) { BiPredicate filter = (n, v) -> false; var r = HttpRequest.newBuilder(request, filter).build(); assertTrue(r.headers().map().isEmpty()); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); } } - @Test(dataProvider = "testRequests") + @ParameterizedTest + @MethodSource("variants") public void testRetainAllHeaders(HttpRequest request) { if (!request.headers().map().isEmpty()) { BiPredicate filter = (n, v) -> true; var r = HttpRequest.newBuilder(request, filter).build(); assertFalse(r.headers().map().isEmpty()); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); } } @@ -414,7 +432,7 @@ public class HttpRequestNewBuilderTest { BiPredicate filter = (n, v) -> !n.equalsIgnoreCase("Foo-Bar"); var r = HttpRequest.newBuilder(request, filter).build(); assertFalse(r.headers().map().containsKey("Foo-Bar")); - assertEquals(r.headers().map(), HttpHeaders.of(request.headers().map(), filter).map()); + assertEquals(HttpHeaders.of(request.headers().map(), filter).map(), r.headers().map()); } @Test diff --git a/test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java b/test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java index 6468175ab59..3b955b8feb7 100644 --- a/test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java +++ b/test/jdk/java/net/httpclient/HttpResponseInputStreamInterruptTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import jdk.test.lib.net.URIBuilder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import java.io.IOException; import java.io.InputStream; @@ -53,18 +52,17 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HttpResponseInputStreamInterruptTest { - HttpServer server; - int port; - private final CountDownLatch interruptReadyLatch = new CountDownLatch(2); - private final CountDownLatch interruptDoneLatch = new CountDownLatch(1); + private static HttpServer server; + private static int port; + private static final CountDownLatch interruptReadyLatch = new CountDownLatch(2); + private static final CountDownLatch interruptDoneLatch = new CountDownLatch(1); static final String FIRST_MESSAGE = "Should be received"; static final String SECOND_MESSAGE = "Shouldn't be received"; @BeforeAll - void before() throws Exception { + static void before() throws Exception { InetAddress loopback = InetAddress.getLoopbackAddress(); InetSocketAddress addr = new InetSocketAddress(loopback, 0); server = HttpServer.create(addr, 0); @@ -75,7 +73,7 @@ public class HttpResponseInputStreamInterruptTest { } @AfterAll - void after() throws Exception { + static void after() throws Exception { server.stop(0); } diff --git a/test/jdk/java/net/httpclient/HttpResponseInputStreamTest.java b/test/jdk/java/net/httpclient/HttpResponseInputStreamTest.java index 2249839e8bb..633c6877716 100644 --- a/test/jdk/java/net/httpclient/HttpResponseInputStreamTest.java +++ b/test/jdk/java/net/httpclient/HttpResponseInputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -38,15 +38,14 @@ import java.util.concurrent.Flow; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import org.testng.annotations.Test; - -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /* * @test * @bug 8197564 8228970 * @summary Simple smoke test for BodySubscriber.asInputStream(); - * @run testng/othervm HttpResponseInputStreamTest + * @run junit/othervm HttpResponseInputStreamTest * @author daniel fuchs */ public class HttpResponseInputStreamTest { @@ -56,7 +55,7 @@ public class HttpResponseInputStreamTest { static class TestException extends IOException {} public static void main(String[] args) throws InterruptedException, ExecutionException { - testOnError(); + new HttpResponseInputStreamTest().testOnError(); } /** @@ -66,7 +65,7 @@ public class HttpResponseInputStreamTest { * @throws ExecutionException */ @Test - public static void testOnError() throws InterruptedException, ExecutionException { + public void testOnError() throws InterruptedException, ExecutionException { CountDownLatch latch = new CountDownLatch(1); BodySubscriber isb = BodySubscribers.ofInputStream(); ErrorTestSubscription s = new ErrorTestSubscription(isb); @@ -160,7 +159,7 @@ public class HttpResponseInputStreamTest { } @Test - public static void testCloseAndSubscribe() + public void testCloseAndSubscribe() throws InterruptedException, ExecutionException { BodySubscriber isb = BodySubscribers.ofInputStream(); @@ -189,34 +188,34 @@ public class HttpResponseInputStreamTest { } @Test - public static void testReadParameters() throws InterruptedException, ExecutionException, IOException { + public void testReadParameters() throws InterruptedException, ExecutionException, IOException { BodySubscriber isb = BodySubscribers.ofInputStream(); InputStream is = isb.getBody().toCompletableFuture().get(); Throwable ex; // len == 0 - assertEquals(is.read(new byte[16], 0, 0), 0); - assertEquals(is.read(new byte[16], 16, 0), 0); + assertEquals(0, is.read(new byte[16], 0, 0)); + assertEquals(0, is.read(new byte[16], 16, 0)); // index == -1 - ex = expectThrows(OOB, () -> is.read(new byte[16], -1, 10)); + ex = assertThrows(OOB, () -> is.read(new byte[16], -1, 10)); System.out.println("OutOfBoundsException thrown as expected: " + ex); // large offset - ex = expectThrows(OOB, () -> is.read(new byte[16], 17, 10)); + ex = assertThrows(OOB, () -> is.read(new byte[16], 17, 10)); System.out.println("OutOfBoundsException thrown as expected: " + ex); - ex = expectThrows(OOB, () -> is.read(new byte[16], 10, 10)); + ex = assertThrows(OOB, () -> is.read(new byte[16], 10, 10)); System.out.println("OutOfBoundsException thrown as expected: " + ex); // null value - ex = expectThrows(NPE, () -> is.read(null, 0, 10)); + ex = assertThrows(NPE, () -> is.read(null, 0, 10)); System.out.println("NullPointerException thrown as expected: " + ex); } @Test - public static void testSubscribeAndClose() + public void testSubscribeAndClose() throws InterruptedException, ExecutionException { BodySubscriber isb = BodySubscribers.ofInputStream(); diff --git a/test/jdk/java/net/httpclient/HttpVersionsTest.java b/test/jdk/java/net/httpclient/HttpVersionsTest.java index a55c2727a00..f047e2902e8 100644 --- a/test/jdk/java/net/httpclient/HttpVersionsTest.java +++ b/test/jdk/java/net/httpclient/HttpVersionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +28,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * jdk.test.lib.Platform - * @run testng/othervm HttpVersionsTest + * @run junit/othervm HttpVersionsTest */ import java.io.IOException; @@ -42,30 +42,30 @@ import java.net.http.HttpResponse; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.net.ssl.SSLContext; -import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.String.format; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class HttpVersionsTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - Http2TestServer http2TestServer; - Http2TestServer https2TestServer; - String http2URI; - String https2URI; + static Http2TestServer http2TestServer; + static Http2TestServer https2TestServer; + static String http2URI; + static String https2URI; static final int ITERATIONS = 3; static final String[] BODY = new String[] { @@ -74,10 +74,9 @@ public class HttpVersionsTest { "I think I'll drink until I stink", "I'll drink until I cannot blink" }; - int nextBodyId; + static int nextBodyId; - @DataProvider(name = "scenarios") - public Object[][] scenarios() { + public static Object[][] scenarios() { return new Object[][] { { http2URI, true }, { https2URI, true }, @@ -87,9 +86,10 @@ public class HttpVersionsTest { } /** Checks that an HTTP/2 request receives an HTTP/2 response. */ - @Test(dataProvider = "scenarios") + @ParameterizedTest + @MethodSource("scenarios") void testHttp2Get(String uri, boolean sameClient) throws Exception { - out.println(format("\n--- testHttp2Get uri:%s, sameClient:%s", uri, sameClient)); + out.printf("\n--- testHttp2Get uri:%s, sameClient:%s%n", uri, sameClient); HttpClient client = null; for (int i=0; i out.println("X-Received-Body:" + s)); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_1_1); - assertEquals(response.body(), ""); - assertEquals(response.headers().firstValue("X-Magic").get(), - "HTTP/1.1 request received by HTTP/2 server"); - assertEquals(response.headers().firstValue("X-Received-Body").get(), ""); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_1_1, response.version()); + assertEquals("", response.body()); + assertEquals("HTTP/1.1 request received by HTTP/2 server", response.headers().firstValue("X-Magic").get()); + assertEquals("", response.headers().firstValue("X-Received-Body").get()); if (uri.startsWith("https")) assertTrue(response.sslSession().isPresent()); } } - @Test(dataProvider = "scenarios") + @ParameterizedTest + @MethodSource("scenarios") void testHttp1dot1Post(String uri, boolean sameClient) throws Exception { - out.println(format("\n--- testHttp1dot1Post uri:%s, sameClient:%s", uri, sameClient)); + out.printf("\n--- testHttp1dot1Post uri:%s, sameClient:%s%n", uri, sameClient); HttpClient client = null; for (int i=0; i out.println("X-Received-Body:" + s)); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_1_1); - assertEquals(response.body(), ""); - assertEquals(response.headers().firstValue("X-Magic").get(), - "HTTP/1.1 request received by HTTP/2 server"); - assertEquals(response.headers().firstValue("X-Received-Body").get(), msg); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_1_1, response.version()); + assertEquals("", response.body()); + assertEquals("HTTP/1.1 request received by HTTP/2 server", response.headers().firstValue("X-Magic").get()); + assertEquals(msg, response.headers().firstValue("X-Received-Body").get()); if (uri.startsWith("https")) assertTrue(response.sslSession().isPresent()); } @@ -203,8 +204,8 @@ public class HttpVersionsTest { static final ExecutorService executor = Executors.newCachedThreadPool(); - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { http2TestServer = new Http2TestServer("localhost", false, 0, executor, 50, null, null, true); http2TestServer.addHandler(new Http2VerEchoHandler(), "/http2/vts"); http2URI = "http://" + http2TestServer.serverAuthority() + "/http2/vts"; @@ -217,8 +218,8 @@ public class HttpVersionsTest { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { http2TestServer.stop(); https2TestServer.stop(); executor.shutdown(); diff --git a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java b/test/jdk/java/net/httpclient/ISO_8859_1_Test.java index d629a6f3105..103284c9d54 100644 --- a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java +++ b/test/jdk/java/net/httpclient/ISO_8859_1_Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * ISO_8859_1_Test * @summary Tests that a client is able to receive ISO-8859-1 encoded header values. @@ -48,7 +48,6 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -60,21 +59,11 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; @@ -82,30 +71,38 @@ import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ISO_8859_1_Test implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - DummyServer http1DummyServer; - HttpTestServer http1TestServer; // HTTP/1.1 ( http ) - HttpTestServer https1TestServer; // HTTPS/1.1 ( https ) - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String http1Dummy; - String http1URI; - String https1URI; - String http2URI; - String https2URI; - String http3URI; + private static DummyServer http1DummyServer; + private static HttpTestServer http1TestServer; // HTTP/1.1 ( http ) + private static HttpTestServer https1TestServer; // HTTPS/1.1 ( https ) + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String http1Dummy; + private static String http1URI; + private static String https1URI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - static final int RESPONSE_CODE = 200; static final int ITERATION_COUNT = 4; - static final Class IAE = IllegalArgumentException.class; - static final Class CE = CompletionException.class; // a shared executor helps reduce the amount of threads created by the test static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); @@ -121,8 +118,8 @@ public class ISO_8859_1_Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -148,40 +145,40 @@ public class ISO_8859_1_Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - FAILURES.putAll(failed); - out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -199,7 +196,7 @@ public class ISO_8859_1_Test implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { http3URI, http1Dummy, @@ -210,13 +207,7 @@ public class ISO_8859_1_Test implements HttpServerAdapters { }; } - static AtomicLong URICOUNT = new AtomicLong(); - - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -265,7 +256,7 @@ public class ISO_8859_1_Test implements HttpServerAdapters { } } - private static final Exception completionCause(CompletionException x) { + private static Exception completionCause(CompletionException x) { Throwable c = x; while (c instanceof CompletionException || c instanceof ExecutionException) { @@ -285,10 +276,11 @@ public class ISO_8859_1_Test implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) throws Exception { - checkSkip(); - System.out.println("Request to " + uri); + + System.out.printf("%n%s-- test sameClient=%s uri=%s%n%n", now(), sameClient, uri); HttpClient client = newHttpClient(uri, sameClient); @@ -307,7 +299,7 @@ public class ISO_8859_1_Test implements HttpServerAdapters { var response = cf.get(); System.out.println("Got: " + response); var value = response.headers().firstValue("Header8859").orElse(null); - assertEquals(value, "U\u00ffU"); + assertEquals("U\u00ffU", value); } System.out.println("HttpClient: PASSED"); if (uri.contains("http1")) { @@ -317,10 +309,10 @@ public class ISO_8859_1_Test implements HttpServerAdapters { conn.connect(); conn.getInputStream().readAllBytes(); var value = conn.getHeaderField("Header8859"); - assertEquals(value, "U\u00ffU", "legacy stack failed"); + assertEquals("U\u00ffU", value, "legacy stack failed"); System.out.println("URLConnection: PASSED"); } - System.out.println("test: DONE"); + System.out.println(now() + "test: DONE"); } static final class DummyServer extends Thread implements AutoCloseable { @@ -335,8 +327,8 @@ public class ISO_8859_1_Test implements HttpServerAdapters { static final InetSocketAddress LOOPBACK = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); final ServerSocket socket; - final CopyOnWriteArrayList accepted = new CopyOnWriteArrayList(); - final CompletableFuture done = new CompletableFuture(); + final CopyOnWriteArrayList accepted = new CopyOnWriteArrayList<>(); + final CompletableFuture done = new CompletableFuture<>(); volatile boolean closed; DummyServer() throws IOException { socket = new ServerSocket(); @@ -387,11 +379,11 @@ public class ISO_8859_1_Test implements HttpServerAdapters { } } - final void close(AutoCloseable toclose) { + void close(AutoCloseable toclose) { try { toclose.close(); } catch (Exception x) {}; } - final public void close() { + public void close() { closed = true; close(socket); accepted.forEach(this::close); @@ -410,8 +402,8 @@ public class ISO_8859_1_Test implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { HttpServerAdapters.HttpTestHandler handler = new ISO88591Handler(); InetSocketAddress loopback = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -448,8 +440,8 @@ public class ISO_8859_1_Test implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); sharedClient = null; diff --git a/test/jdk/java/net/httpclient/IdleConnectionTimeoutTest.java b/test/jdk/java/net/httpclient/IdleConnectionTimeoutTest.java index 78984964895..be7e1db0033 100644 --- a/test/jdk/java/net/httpclient/IdleConnectionTimeoutTest.java +++ b/test/jdk/java/net/httpclient/IdleConnectionTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,6 @@ import jdk.httpclient.test.lib.quic.QuicServerConnection; import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; @@ -56,7 +54,10 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; import static java.net.http.HttpClient.Version.HTTP_2; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -68,45 +69,45 @@ import static org.testng.Assert.assertEquals; * jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.http3.Http3TestServer * - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout=1 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout=1 * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout=20 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout=20 * IdleConnectionTimeoutTest * - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=1 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=1 * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=20 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=20 * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=abc + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=abc * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=-1 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h2=-1 * IdleConnectionTimeoutTest * - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=1 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=1 * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=20 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=20 * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=abc + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=abc * IdleConnectionTimeoutTest - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=-1 + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all -Djdk.httpclient.keepalive.timeout.h3=-1 * IdleConnectionTimeoutTest */ public class IdleConnectionTimeoutTest { - URI timeoutUriH2, noTimeoutUriH2, timeoutUriH3, noTimeoutUriH3, getH3; + private static URI timeoutUriH2, noTimeoutUriH2, timeoutUriH3, noTimeoutUriH3, getH3; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); static volatile QuicServerConnection latestServerConn; final String KEEP_ALIVE_PROPERTY = "jdk.httpclient.keepalive.timeout"; final String IDLE_CONN_PROPERTY_H2 = "jdk.httpclient.keepalive.timeout.h2"; final String IDLE_CONN_PROPERTY_H3 = "jdk.httpclient.keepalive.timeout.h3"; - final String TIMEOUT_PATH = "/serverTimeoutHandler"; - final String NO_TIMEOUT_PATH = "/noServerTimeoutHandler"; + static final String TIMEOUT_PATH = "/serverTimeoutHandler"; + static final String NO_TIMEOUT_PATH = "/noServerTimeoutHandler"; static Http2TestServer http2TestServer; static Http3TestServer http3TestServer; static final PrintStream testLog = System.err; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { http2TestServer = new Http2TestServer(false, 0); http2TestServer.addHandler(new ServerTimeoutHandlerH2(), TIMEOUT_PATH); http2TestServer.addHandler(new ServerNoTimeoutHandlerH2(), NO_TIMEOUT_PATH); @@ -212,7 +213,7 @@ public class IdleConnectionTimeoutTest { HttpRequest hreq = HttpRequest.newBuilder(uri).version(version).GET() .setOption(H3_DISCOVERY, config).build(); HttpResponse hresp = runRequest(hc, hreq, 2750); - assertEquals(hresp.statusCode(), 200, "idleConnectionTimeoutEvent was not expected but occurred"); + assertEquals(200, hresp.statusCode(), "idleConnectionTimeoutEvent was not expected but occurred"); } private void testNoTimeout(HttpClient hc, URI uri, Version version) { @@ -221,13 +222,13 @@ public class IdleConnectionTimeoutTest { HttpRequest hreq = HttpRequest.newBuilder(uri).version(version).GET() .setOption(H3_DISCOVERY, config).build(); HttpResponse hresp = runRequest(hc, hreq, 0); - assertEquals(hresp.statusCode(), 200, "idleConnectionTimeoutEvent was not expected but occurred"); + assertEquals(200, hresp.statusCode(), "idleConnectionTimeoutEvent was not expected but occurred"); } private HttpResponse runRequest(HttpClient hc, HttpRequest req, int sleepTime) { CompletableFuture> request = hc.sendAsync(req, HttpResponse.BodyHandlers.ofString(UTF_8)); HttpResponse hresp = request.join(); - assertEquals(hresp.statusCode(), 200); + assertEquals(200, hresp.statusCode()); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { diff --git a/test/jdk/java/net/httpclient/ImmutableFlowItems.java b/test/jdk/java/net/httpclient/ImmutableFlowItems.java index 3ee4eb28768..e42e2e21a6e 100644 --- a/test/jdk/java/net/httpclient/ImmutableFlowItems.java +++ b/test/jdk/java/net/httpclient/ImmutableFlowItems.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +28,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm ImmutableFlowItems + * @run junit/othervm ImmutableFlowItems */ import java.io.IOException; @@ -58,32 +58,33 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ImmutableFlowItems { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; + private static HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI_fixed }, { httpURI_chunk }, @@ -104,7 +105,8 @@ public class ImmutableFlowItems { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsString(String uri) throws Exception { HttpClient client = newHttpClient(); @@ -114,14 +116,14 @@ public class ImmutableFlowItems { BodyHandler handler = new CRSBodyHandler(); client.sendAsync(req, handler) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, BODY)) + .thenAccept(body -> assertEquals(BODY, body)) .join(); } static class CRSBodyHandler implements BodyHandler { @Override public BodySubscriber apply(HttpResponse.ResponseInfo rinfo) { - assertEquals(rinfo.statusCode(), 200); + assertEquals(200, rinfo.statusCode()); return new CRSBodySubscriber(); } } @@ -138,7 +140,7 @@ public class ImmutableFlowItems { public void onNext(List item) { assertUnmodifiableList(item); long c = item.stream().filter(ByteBuffer::isReadOnly).count(); - assertEquals(c, item.size(), "Unexpected writable buffer in: " +item); + assertEquals(item.size(), c, "Unexpected writable buffer in: " +item); ofString.onNext(item); } @@ -173,8 +175,8 @@ public class ImmutableFlowItems { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpHandler h1_fixedLengthHandler = new HTTP1_FixedLengthHandler(); HttpHandler h1_chunkHandler = new HTTP1_ChunkedHandler(); @@ -214,8 +216,8 @@ public class ImmutableFlowItems { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java b/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java index 10df564bd41..c83d9d67528 100644 --- a/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java +++ b/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Dtest.http.version=http3 + * @run junit/othervm -Dtest.http.version=http3 * -Djdk.internal.httpclient.debug=true * InvalidInputStreamSubscriptionRequest */ @@ -41,7 +41,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Dtest.http.version=http2 InvalidInputStreamSubscriptionRequest + * @run junit/othervm -Dtest.http.version=http2 InvalidInputStreamSubscriptionRequest */ /* * @test id=http1 @@ -51,16 +51,11 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Dtest.http.version=http1 InvalidInputStreamSubscriptionRequest + * @run junit/othervm -Dtest.http.version=http1 InvalidInputStreamSubscriptionRequest */ import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -96,26 +91,31 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -156,7 +156,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters } } - @AfterClass + @AfterAll static final void printFailedTests() { out.println("\n========================="); try { @@ -200,8 +200,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters static final Supplier> OF_INPUTSTREAM = BHS.of(BodyHandlers::ofInputStream, "BodyHandlers::ofInputStream"); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { Object[][] http3 = new Object[][]{ {http3URI_fixed, false, OF_INPUTSTREAM}, {http3URI_chunk, false, OF_INPUTSTREAM}, @@ -244,7 +243,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; HttpClient newHttpClient(String uri) { HttpClient.Builder builder = uri.contains("/http3/") ? newClientBuilderForH3() @@ -265,7 +264,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters return builder; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testNoBody(String uri, boolean sameClient, BHS handlers) throws Exception { @@ -285,7 +285,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters HttpResponse response = client.send(req, badHandler); try (InputStream is = response.body()) { String body = new String(is.readAllBytes(), UTF_8); - assertEquals(body, ""); + assertEquals("", body); if (uri.endsWith("/chunk") && response.version() == HTTP_1_1) { // with /fixed and 0 length @@ -324,7 +324,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testNoBodyAsync(String uri, boolean sameClient, BHS handlers) throws Exception { @@ -352,7 +353,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters }); try { // Get the final result and compare it with the expected body - assertEquals(result.get(), ""); + assertEquals("", result.get()); if (uri.endsWith("/chunk") && response.get().version() == HTTP_1_1) { // with /fixed and 0 length @@ -390,7 +391,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsString(String uri, boolean sameClient, BHS handlers) throws Exception { @@ -409,7 +411,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters HttpResponse response = client.send(req, badHandler); try (InputStream is = response.body()) { String body = new String(is.readAllBytes(), UTF_8); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); throw new RuntimeException("Expected IAE not thrown"); } } catch (Exception x) { @@ -443,7 +445,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsStringAsync(String uri, boolean sameClient, BHS handlers) throws Exception { @@ -470,7 +473,7 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters // Get the final result and compare it with the expected body try { String body = result.get(); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); throw new RuntimeException("Expected IAE not thrown"); } catch (Exception x) { Throwable cause = x; @@ -563,8 +566,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler(); HttpTestHandler h1_chunkHandler = new HTTP_VariableLengthHandler(); @@ -613,8 +616,8 @@ public class InvalidInputStreamSubscriptionRequest implements HttpServerAdapters http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { AssertionError fail = TRACKER.check(1500); try { httpTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/InvalidSSLContextTest.java b/test/jdk/java/net/httpclient/InvalidSSLContextTest.java index be4d3297dd7..0027a7956d5 100644 --- a/test/jdk/java/net/httpclient/InvalidSSLContextTest.java +++ b/test/jdk/java/net/httpclient/InvalidSSLContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * when SSL context is not valid. * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true InvalidSSLContextTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true InvalidSSLContextTest */ import java.io.IOException; @@ -40,7 +40,6 @@ import java.util.concurrent.CompletionException; import java.net.SocketException; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; -import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLSocket; import java.net.http.HttpClient; @@ -49,32 +48,32 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class InvalidSSLContextTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - volatile SSLServerSocket sslServerSocket; - volatile String uri; + static volatile SSLServerSocket sslServerSocket; + static volatile String uri; - @DataProvider(name = "versions") - public Object[][] versions() { + public static Object[][] versions() { return new Object[][]{ { HTTP_1_1 }, { HTTP_2 } }; } - @Test(dataProvider = "versions") + @ParameterizedTest + @MethodSource("versions") public void testSync(Version version) throws Exception { // client-side uses a different context to that of the server-side HttpClient client = HttpClient.newBuilder() @@ -88,14 +87,15 @@ public class InvalidSSLContextTest { try { HttpResponse response = client.send(request, BodyHandlers.discarding()); - Assert.fail("UNEXPECTED response" + response); + Assertions.fail("UNEXPECTED response" + response); } catch (IOException ex) { System.out.println("Caught expected: " + ex); assertExceptionOrCause(SSLException.class, ex); } } - @Test(dataProvider = "versions") + @ParameterizedTest + @MethodSource("versions") public void testAsync(Version version) throws Exception { // client-side uses a different context to that of the server-side HttpClient client = HttpClient.newBuilder() @@ -115,13 +115,13 @@ public class InvalidSSLContextTest { CompletableFuture stage) { stage.handle((result, error) -> { if (result != null) { - Assert.fail("UNEXPECTED result: " + result); + Assertions.fail("UNEXPECTED result: " + result); return null; } if (error instanceof CompletionException) { Throwable cause = error.getCause(); if (cause == null) { - Assert.fail("Unexpected null cause: " + error); + Assertions.fail("Unexpected null cause: " + error); } assertExceptionOrCause(clazz, cause); } else { @@ -133,7 +133,7 @@ public class InvalidSSLContextTest { static void assertExceptionOrCause(Class clazz, Throwable t) { if (t == null) { - Assert.fail("Expected " + clazz + ", caught nothing"); + Assertions.fail("Expected " + clazz + ", caught nothing"); } final Throwable original = t; do { @@ -142,11 +142,11 @@ public class InvalidSSLContextTest { } } while ((t = t.getCause()) != null); original.printStackTrace(System.out); - Assert.fail("Expected " + clazz + "in " + original); + Assertions.fail("Expected " + clazz + "in " + original); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // server-side uses a different context to that of the client-side sslServerSocket = (SSLServerSocket)sslContext .getServerSocketFactory() @@ -169,7 +169,7 @@ public class InvalidSSLContextTest { Thread.sleep(500); s.startHandshake(); s.close(); - Assert.fail("SERVER: UNEXPECTED "); + Assertions.fail("SERVER: UNEXPECTED "); } catch (SSLException | SocketException se) { System.out.println("SERVER: caught expected " + se); } catch (IOException e) { @@ -187,8 +187,8 @@ public class InvalidSSLContextTest { t.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sslServerSocket.close(); } } diff --git a/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java b/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java index c16c9f1747c..692e4d0bea4 100644 --- a/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java +++ b/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,21 +30,15 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm InvalidSubscriptionRequest + * @run junit/othervm InvalidSubscriptionRequest */ -import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.InetAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -74,26 +68,31 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class InvalidSubscriptionRequest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -126,8 +125,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { static final Supplier>>> OF_PUBLISHER_API = BHS.of(BodyHandlers::ofPublisher, "BodyHandlers::ofPublisher"); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { http3URI_fixed, false, OF_PUBLISHER_API }, { http3URI_chunk, false, OF_PUBLISHER_API }, @@ -154,7 +152,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { }; } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; HttpClient newHttpClient(String uri) { HttpClient.Builder builder = uri.contains("/http3/") ? newClientBuilderForH3() @@ -175,8 +173,9 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") - public void testNoBody(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testNoBody(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; Throwable failed = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -196,7 +195,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { // Get the final result and compare it with the expected body try { String body = ofString.getBody().toCompletableFuture().get(); - assertEquals(body, ""); + assertEquals("", body); if (uri.endsWith("/chunk") && response.version() == HTTP_1_1) { // with /fixed and 0 length @@ -231,8 +230,9 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testNoBodyAsync(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testNoBodyAsync(String uri, boolean sameClient, BHS handlers) { HttpClient client = null; Throwable failed = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -257,7 +257,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { }); try { // Get the final result and compare it with the expected body - assertEquals(result.get(), ""); + assertEquals("", result.get()); if (uri.endsWith("/chunk") && response.get().version() == HTTP_1_1) { // with /fixed and 0 length @@ -292,8 +292,9 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testAsString(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testAsString(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; Throwable failed = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -314,7 +315,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { // Get the final result and compare it with the expected body try { String body = ofString.getBody().toCompletableFuture().get(); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); throw new RuntimeException("Expected IAE not thrown"); } catch (Exception x) { Throwable cause = x; @@ -344,8 +345,9 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testAsStringAsync(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testAsStringAsync(String uri, boolean sameClient, BHS handlers) { HttpClient client = null; Throwable failed = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -369,7 +371,7 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { // Get the final result and compare it with the expected body try { String body = result.get(); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); throw new RuntimeException("Expected IAE not thrown"); } catch (Exception x) { Throwable cause = x; @@ -454,13 +456,8 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { } } - static String serverAuthority(HttpServer server) { - return InetAddress.getLoopbackAddress().getHostName() + ":" - + server.getAddress().getPort(); - } - - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler(); HttpTestHandler h1_chunkHandler = new HTTP_VariableLengthHandler(); @@ -509,8 +506,8 @@ public class InvalidSubscriptionRequest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { AssertionError fail = TRACKER.check(500); try { httpTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/LineBodyHandlerTest.java b/test/jdk/java/net/httpclient/LineBodyHandlerTest.java index 45df8d13f7e..ddca2e1f7d2 100644 --- a/test/jdk/java/net/httpclient/LineBodyHandlerTest.java +++ b/test/jdk/java/net/httpclient/LineBodyHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,10 +54,6 @@ import java.util.stream.Stream; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; @@ -66,11 +62,16 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_16; import static java.nio.charset.StandardCharsets.UTF_8; -import static java.net.http.HttpRequest.BodyPublishers.ofString; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -81,29 +82,28 @@ import static org.testng.Assert.assertTrue; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build ReferenceTracker jdk.httpclient.test.lib.http2.Http2TestServer * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:DiagnoseSyncOnValueBasedClasses=1 LineBodyHandlerTest + * @run junit/othervm -XX:+UnlockDiagnosticVMOptions -XX:DiagnoseSyncOnValueBasedClasses=1 LineBodyHandlerTest */ public class LineBodyHandlerTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - final AtomicInteger clientCount = new AtomicInteger(); - HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final AtomicInteger clientCount = new AtomicInteger(); + private static HttpClient sharedClient; - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { http3URI }, { httpURI }, @@ -171,7 +171,7 @@ public class LineBodyHandlerTest implements HttpServerAdapters { StandardCharsets.US_ASCII, "")); } - private static final List lines(String text, String eol) { + private static List lines(String text, String eol) { if (eol == null) { return new BufferedReader(new StringReader(text)).lines().collect(Collectors.toList()); } else { @@ -210,7 +210,8 @@ public class LineBodyHandlerTest implements HttpServerAdapters { return builder; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testStringWithFinisher(String url) { String body = "May the luck of the Irish be with you!"; HttpClient client = newClient(); @@ -226,12 +227,13 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, body); - assertEquals(subscriber.list, lines(body, "\n")); + assertEquals(200, response.statusCode()); + assertEquals(body, text); + assertEquals(lines(body, "\n"), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsStream(String url) { String body = "May the luck of the Irish be with you!"; HttpClient client = newClient(); @@ -247,13 +249,14 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, body); - assertEquals(list, List.of(body)); - assertEquals(list, lines(body, null)); + assertEquals(200, response.statusCode()); + assertEquals(body, text); + assertEquals(List.of(body), list); + assertEquals(lines(body, null), list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testStringWithFinisher2(String url) { String body = "May the luck\r\n\r\n of the Irish be with you!"; HttpClient client = newClient(); @@ -270,12 +273,13 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, body.replace("\r\n", "\n")); - assertEquals(subscriber.list, lines(body, null)); + assertEquals(200, response.statusCode()); + assertEquals(body.replace("\r\n", "\n"), text); + assertEquals(lines(body, null), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsStreamWithCRLF(String url) { String body = "May the luck\r\n\r\n of the Irish be with you!"; HttpClient client = newClient(); @@ -291,15 +295,16 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, "May the luck|| of the Irish be with you!"); - assertEquals(list, List.of("May the luck", + assertEquals(200, response.statusCode()); + assertEquals("May the luck|| of the Irish be with you!", text); + assertEquals(List.of("May the luck", "", - " of the Irish be with you!")); - assertEquals(list, lines(body, null)); + " of the Irish be with you!"), list); + assertEquals(lines(body, null), list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testStringWithFinisherBlocking(String url) throws Exception { String body = "May the luck of the Irish be with you!"; HttpClient client = newClient(); @@ -311,12 +316,13 @@ public class LineBodyHandlerTest implements HttpServerAdapters { BodyHandlers.fromLineSubscriber(subscriber, Supplier::get, "\n")); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, "May the luck of the Irish be with you!"); - assertEquals(subscriber.list, lines(body, "\n")); + assertEquals(200, response.statusCode()); + assertEquals("May the luck of the Irish be with you!", text); + assertEquals(lines(body, "\n"), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testStringWithoutFinisherBlocking(String url) throws Exception { String body = "May the luck of the Irish be with you!"; HttpClient client = newClient(); @@ -328,14 +334,15 @@ public class LineBodyHandlerTest implements HttpServerAdapters { BodyHandlers.fromLineSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, "May the luck of the Irish be with you!"); - assertEquals(subscriber.list, lines(body, null)); + assertEquals(200, response.statusCode()); + assertEquals("May the luck of the Irish be with you!", text); + assertEquals(lines(body, null), subscriber.list); } // Subscriber - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsStreamWithMixedCRLF(String url) { String body = "May\r\n the wind\r\n always be\rat your back.\r\r"; HttpClient client = newClient(); @@ -351,18 +358,19 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May| the wind| always be|at your back.|"); - assertEquals(list, List.of("May", + assertEquals("May| the wind| always be|at your back.|", text); + assertEquals(List.of("May", " the wind", " always be", "at your back.", - "")); - assertEquals(list, lines(body, null)); + ""), list); + assertEquals(lines(body, null), list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsStreamWithMixedCRLF_UTF8(String url) { String body = "May\r\n the wind\r\n always be\rat your back.\r\r"; HttpClient client = newClient(); @@ -378,17 +386,18 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May| the wind| always be|at your back.|"); - assertEquals(list, List.of("May", + assertEquals("May| the wind| always be|at your back.|", text); + assertEquals(List.of("May", " the wind", " always be", - "at your back.", "")); - assertEquals(list, lines(body, null)); + "at your back.", ""), list); + assertEquals(lines(body, null), list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsStreamWithMixedCRLF_UTF16(String url) { String body = "May\r\n the wind\r\n always be\rat your back.\r\r"; HttpClient client = newClient(); @@ -404,18 +413,19 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May| the wind| always be|at your back.|"); - assertEquals(list, List.of("May", + assertEquals("May| the wind| always be|at your back.|", text); + assertEquals(List.of("May", " the wind", " always be", "at your back.", - "")); - assertEquals(list, lines(body, null)); + ""), list); + assertEquals(lines(body, null), list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithFinisher(String url) { String body = "May\r\n the wind\r\n always be\rat your back."; HttpClient client = newClient(); @@ -431,16 +441,17 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May\n the wind\n always be\rat your back."); - assertEquals(subscriber.list, List.of("May", + assertEquals("May\n the wind\n always be\rat your back.", text); + assertEquals(List.of("May", " the wind", - " always be\rat your back.")); - assertEquals(subscriber.list, lines(body, "\r\n")); + " always be\rat your back."), subscriber.list); + assertEquals(lines(body, "\r\n"), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithFinisher_UTF16(String url) { String body = "May\r\n the wind\r\n always be\rat your back.\r\r"; HttpClient client = newClient(); @@ -455,18 +466,19 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May\n the wind\n always be\nat your back.\n"); - assertEquals(subscriber.list, List.of("May", + assertEquals("May\n the wind\n always be\nat your back.\n", text); + assertEquals(List.of("May", " the wind", " always be", "at your back.", - "")); - assertEquals(subscriber.list, lines(body, null)); + ""), subscriber.list); + assertEquals(lines(body, null), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithoutFinisher(String url) { String body = "May\r\n the wind\r\n always be\rat your back."; HttpClient client = newClient(); @@ -482,17 +494,18 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May\n the wind\n always be\nat your back."); - assertEquals(subscriber.list, List.of("May", + assertEquals("May\n the wind\n always be\nat your back.", text); + assertEquals(List.of("May", " the wind", " always be", - "at your back.")); - assertEquals(subscriber.list, lines(body, null)); + "at your back."), subscriber.list); + assertEquals(lines(body, null), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithFinisherBlocking(String url) throws Exception { String body = "May\r\n the wind\r\n always be\nat your back."; HttpClient client = newClient(); @@ -507,16 +520,17 @@ public class LineBodyHandlerTest implements HttpServerAdapters { "\r\n")); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May\n the wind\n always be\nat your back."); - assertEquals(subscriber.list, List.of("May", + assertEquals("May\n the wind\n always be\nat your back.", text); + assertEquals(List.of("May", " the wind", - " always be\nat your back.")); - assertEquals(subscriber.list, lines(body, "\r\n")); + " always be\nat your back."), subscriber.list); + assertEquals(lines(body, "\r\n"), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testObjectWithoutFinisherBlocking(String url) throws Exception { String body = "May\r\n the wind\r\n always be\nat your back."; HttpClient client = newClient(); @@ -529,14 +543,14 @@ public class LineBodyHandlerTest implements HttpServerAdapters { BodyHandlers.fromLineSubscriber(subscriber)); String text = subscriber.get(); System.out.println(text); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(text.length() != 0); // what else can be asserted! - assertEquals(text, "May\n the wind\n always be\nat your back."); - assertEquals(subscriber.list, List.of("May", + assertEquals("May\n the wind\n always be\nat your back.", text); + assertEquals(List.of("May", " the wind", " always be", - "at your back.")); - assertEquals(subscriber.list, lines(body, null)); + "at your back."), subscriber.list); + assertEquals(lines(body, null), subscriber.list); } static private final String LINE = "Bient\u00f4t nous plongerons dans les" + @@ -551,7 +565,8 @@ public class LineBodyHandlerTest implements HttpServerAdapters { return res.toString(); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testBigTextFromLineSubscriber(String url) { HttpClient client = newClient(); String bigtext = bigtext(); @@ -567,12 +582,13 @@ public class LineBodyHandlerTest implements HttpServerAdapters { HttpResponse response = cf.join(); String text = response.body(); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, bigtext.replace("\r\n", "\n")); - assertEquals(subscriber.list, lines(bigtext, "\r\n")); + assertEquals(200, response.statusCode()); + assertEquals(bigtext.replace("\r\n", "\n"), text); + assertEquals(lines(bigtext, "\r\n"), subscriber.list); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testBigTextAsStream(String url) { HttpClient client = newClient(); String bigtext = bigtext(); @@ -588,10 +604,10 @@ public class LineBodyHandlerTest implements HttpServerAdapters { List list = stream.collect(Collectors.toList()); String text = list.stream().collect(Collectors.joining("|")); System.out.println(text); - assertEquals(response.statusCode(), 200); - assertEquals(text, bigtext.replace("\r\n", "|")); - assertEquals(list, List.of(bigtext.split("\r\n"))); - assertEquals(list, lines(bigtext, null)); + assertEquals(200, response.statusCode()); + assertEquals(bigtext.replace("\r\n", "|"), text); + assertEquals(List.of(bigtext.split("\r\n")), list); + assertEquals(lines(bigtext, null), list); } /** An abstract Subscriber that converts all received data into a String. */ @@ -675,8 +691,8 @@ public class LineBodyHandlerTest implements HttpServerAdapters { return Executors.newCachedThreadPool(factory); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1, null, executorFor("HTTP/1.1 Server Thread")); httpTestServer.addHandler(new HttpTestEchoHandler(), "/http1/echo"); @@ -706,8 +722,8 @@ public class LineBodyHandlerTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient = null; try { System.gc(); diff --git a/test/jdk/java/net/httpclient/LineStreamsAndSurrogatesTest.java b/test/jdk/java/net/httpclient/LineStreamsAndSurrogatesTest.java index e082398f3c7..01a7ee9fdbf 100644 --- a/test/jdk/java/net/httpclient/LineStreamsAndSurrogatesTest.java +++ b/test/jdk/java/net/httpclient/LineStreamsAndSurrogatesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,10 +37,11 @@ import java.util.concurrent.SubmissionPublisher; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_16; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /* * @test @@ -48,7 +49,7 @@ import static org.testng.Assert.assertEquals; * In particular tests that surrogate characters are handled * correctly. * @modules java.net.http java.logging - * @run testng/othervm LineStreamsAndSurrogatesTest + * @run junit/othervm LineStreamsAndSurrogatesTest */ public class LineStreamsAndSurrogatesTest { @@ -56,7 +57,7 @@ public class LineStreamsAndSurrogatesTest { static final Class NPE = NullPointerException.class; - private static final List lines(String text) { + private static List lines(String text) { return new BufferedReader(new StringReader(text)).lines().collect(Collectors.toList()); } @@ -100,14 +101,14 @@ public class LineStreamsAndSurrogatesTest { String resp2 = reader.lines().collect(Collectors.joining("")); System.out.println("***** Got2: " + resp2); - assertEquals(resp, resp2); - assertEquals(list, List.of("Bient\u00f4t", + assertEquals(resp2, resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", " les", "", " fr\u00f4\ud801\udc00des", - " t\u00e9n\u00e8bres\ufffd")); + " t\u00e9n\u00e8bres\ufffd"), list); } catch (ExecutionException x) { Throwable cause = x.getCause(); if (cause instanceof MalformedInputException) { @@ -151,18 +152,18 @@ public class LineStreamsAndSurrogatesTest { List list = stream.collect(Collectors.toList()); String resp = list.stream().collect(Collectors.joining("|")); System.out.println("***** Got: " + resp); - assertEquals(resp, text.replace("\r\n", "|") + assertEquals(text.replace("\r\n", "|") .replace("\n","|") - .replace("\r","|")); - assertEquals(list, List.of("Bient\u00f4t", + .replace("\r","|"), resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", "", " les", "", " fr\u00f4\ud801\udc00des", - " t\u00e9n\u00e8bres")); - assertEquals(list, lines(text)); + " t\u00e9n\u00e8bres"), list); + assertEquals(lines(text), list); if (errorRef.get() != null) { throw new RuntimeException("Unexpected exception", errorRef.get()); } @@ -201,15 +202,15 @@ public class LineStreamsAndSurrogatesTest { System.out.println("***** Got: " + resp); String expected = Stream.of(text.split("\r\n|\r|\n")) .collect(Collectors.joining("")); - assertEquals(resp, expected); - assertEquals(list, List.of("Bient\u00f4t", + assertEquals(expected, resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", "", " les fr\u00f4\ud801\udc00des", " t\u00e9n\u00e8bres", - "")); - assertEquals(list, lines(text)); + ""), list); + assertEquals(lines(text), list); if (errorRef.get() != null) { throw new RuntimeException("Unexpected exception", errorRef.get()); } @@ -246,16 +247,16 @@ public class LineStreamsAndSurrogatesTest { List list = stream.collect(Collectors.toList()); String resp = list.stream().collect(Collectors.joining("")); System.out.println("***** Got: " + resp); - assertEquals(resp, text.replace("\n","").replace("\r","")); - assertEquals(list, List.of("Bient\u00f4t", + assertEquals(text.replace("\n","").replace("\r",""), resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", "", " les", "", " fr\u00f4\ud801\udc00des", - " t\u00e9n\u00e8bres")); - assertEquals(list, lines(text)); + " t\u00e9n\u00e8bres"), list); + assertEquals(lines(text), list); if (errorRef.get() != null) { throw new RuntimeException("Unexpected exception", errorRef.get()); } @@ -294,15 +295,15 @@ public class LineStreamsAndSurrogatesTest { System.out.println("***** Got: " + resp); String expected = Stream.of(text.split("\r\n|\r|\n")) .collect(Collectors.joining("")); - assertEquals(resp, expected); - assertEquals(list, List.of("Bient\u00f4t", + assertEquals(expected, resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", "", " les fr\u00f4\ud801\udc00des", " t\u00e9n\u00e8bres", - "")); - assertEquals(list, lines(text)); + ""), list); + assertEquals(lines(text), list); if (errorRef.get() != null) { throw new RuntimeException("Unexpected exception", errorRef.get()); } diff --git a/test/jdk/java/net/httpclient/LineSubscribersAndSurrogatesTest.java b/test/jdk/java/net/httpclient/LineSubscribersAndSurrogatesTest.java index 543ff6e94a1..7932744a4db 100644 --- a/test/jdk/java/net/httpclient/LineSubscribersAndSurrogatesTest.java +++ b/test/jdk/java/net/httpclient/LineSubscribersAndSurrogatesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,11 @@ import java.util.concurrent.SubmissionPublisher; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_16; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /* * @test @@ -53,7 +54,7 @@ import static org.testng.Assert.assertEquals; * In particular tests that surrogate characters are handled * correctly. * @modules java.net.http java.logging - * @run testng/othervm LineSubscribersAndSurrogatesTest + * @run junit/othervm LineSubscribersAndSurrogatesTest */ public class LineSubscribersAndSurrogatesTest { @@ -61,7 +62,7 @@ public class LineSubscribersAndSurrogatesTest { static final Class NPE = NullPointerException.class; - private static final List lines(String text, String eol) { + private static List lines(String text, String eol) { if (eol == null) { return new BufferedReader(new StringReader(text)).lines().collect(Collectors.toList()); } else { @@ -104,14 +105,14 @@ public class LineSubscribersAndSurrogatesTest { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); BufferedReader reader = new BufferedReader(new InputStreamReader(bais, UTF_8)); String resp2 = reader.lines().collect(Collectors.joining("")); - assertEquals(resp, resp2); - assertEquals(subscriber.list, List.of("Bient\u00f4t", + assertEquals(resp2, resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans", " les", "", " fr\u00f4\ud801\udc00des", - " t\u00e9n\u00e8bres\ufffd")); + " t\u00e9n\u00e8bres\ufffd"), subscriber.list); } catch (ExecutionException x) { Throwable cause = x.getCause(); if (cause instanceof MalformedInputException) { @@ -147,10 +148,10 @@ public class LineSubscribersAndSurrogatesTest { "", " fr\u00f4\ud801\udc00des\r", " t\u00e9n\u00e8bres\r"); - assertEquals(subscriber.list, expected); - assertEquals(resp, Stream.of(text.split("\n")).collect(Collectors.joining(""))); - assertEquals(resp, expected.stream().collect(Collectors.joining(""))); - assertEquals(subscriber.list, lines(text, "\n")); + assertEquals(expected, subscriber.list); + assertEquals(Stream.of(text.split("\n")).collect(Collectors.joining("")), resp); + assertEquals(expected.stream().collect(Collectors.joining("")), resp); + assertEquals(lines(text, "\n"), subscriber.list); } @@ -172,14 +173,14 @@ public class LineSubscribersAndSurrogatesTest { publisher.close(); String resp = bodySubscriber.getBody().toCompletableFuture().get(); System.out.println("***** Got: " + resp); - assertEquals(resp, text.replace("\r", "")); - assertEquals(subscriber.list, List.of("Bient\u00f4t", + assertEquals(text.replace("\r", ""), resp); + assertEquals(List.of("Bient\u00f4t", "\n nous plongerons", "\n dans", " les fr\u00f4\ud801\udc00des", "\n t\u00e9n\u00e8bres", - "")); - assertEquals(subscriber.list, lines(text, "\r")); + ""), subscriber.list); + assertEquals(lines(text, "\r"), subscriber.list); } @Test @@ -200,12 +201,12 @@ public class LineSubscribersAndSurrogatesTest { publisher.close(); String resp = bodySubscriber.getBody().toCompletableFuture().get(); System.out.println("***** Got: " + resp); - assertEquals(resp, text.replace("\r\n","")); - assertEquals(subscriber.list, List.of("Bient\u00f4t", + assertEquals(text.replace("\r\n",""), resp); + assertEquals(List.of("Bient\u00f4t", " nous plongerons", " dans\r les fr\u00f4\ud801\udc00des", - " t\u00e9n\u00e8bres")); - assertEquals(subscriber.list, lines(text, "\r\n")); + " t\u00e9n\u00e8bres"), subscriber.list); + assertEquals(lines(text, "\r\n"), subscriber.list); } @@ -234,9 +235,9 @@ public class LineSubscribersAndSurrogatesTest { "", " fr\u00f4\ud801\udc00des", " t\u00e9n\u00e8bres"); - assertEquals(subscriber.list, expected); - assertEquals(resp, expected.stream().collect(Collectors.joining(""))); - assertEquals(subscriber.list, lines(text, null)); + assertEquals(expected, subscriber.list); + assertEquals(expected.stream().collect(Collectors.joining("")), resp); + assertEquals(lines(text, null), subscriber.list); } @Test @@ -265,9 +266,9 @@ public class LineSubscribersAndSurrogatesTest { " fr\u00f4\ud801\udc00des", " t\u00e9n\u00e8bres", ""); - assertEquals(resp, expected.stream().collect(Collectors.joining(""))); - assertEquals(subscriber.list, expected); - assertEquals(subscriber.list, lines(text, null)); + assertEquals(expected.stream().collect(Collectors.joining("")), resp); + assertEquals(expected, subscriber.list); + assertEquals(lines(text, null), subscriber.list); } void testStringWithoutFinisherBR() throws Exception { @@ -293,9 +294,9 @@ public class LineSubscribersAndSurrogatesTest { "", " fr\u00f4\ud801\udc00des", " t\u00e9n\u00e8bres"); - assertEquals(subscriber.text, expected.stream().collect(Collectors.joining(""))); - assertEquals(subscriber.list, expected); - assertEquals(subscriber.list, lines(text, null)); + assertEquals(expected.stream().collect(Collectors.joining("")), subscriber.text); + assertEquals(expected, subscriber.list); + assertEquals(lines(text, null), subscriber.list); } diff --git a/test/jdk/java/net/httpclient/MappingResponseSubscriber.java b/test/jdk/java/net/httpclient/MappingResponseSubscriber.java index 445b4a59e24..75454923e49 100644 --- a/test/jdk/java/net/httpclient/MappingResponseSubscriber.java +++ b/test/jdk/java/net/httpclient/MappingResponseSubscriber.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.common.TestServerConfigurator - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * MappingResponseSubscriber */ @@ -64,30 +64,32 @@ import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class MappingResponseSubscriber { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; + private static HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -95,8 +97,7 @@ public class MappingResponseSubscriber { static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI_fixed, false }, { httpURI_chunk, false }, @@ -125,7 +126,8 @@ public class MappingResponseSubscriber { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsBytes(String uri, boolean sameClient) throws Exception { HttpClient client = null; for (int i = 0; i < ITERATION_COUNT; i++) { @@ -137,7 +139,7 @@ public class MappingResponseSubscriber { BodyHandler handler = new CRSBodyHandler(); HttpResponse response = client.send(req, handler); byte[] body = response.body(); - assertEquals(body, bytes); + Assertions.assertArrayEquals(bytes, body); // if sameClient we will reuse the client for the next // operation, so there's nothing more to do. @@ -163,7 +165,7 @@ public class MappingResponseSubscriber { static class CRSBodyHandler implements BodyHandler { @Override public BodySubscriber apply(HttpResponse.ResponseInfo rinfo) { - assertEquals(rinfo.statusCode(), 200); + assertEquals(200, rinfo.statusCode()); return BodySubscribers.mapping( new CRSBodySubscriber(), (s) -> s.getBytes(UTF_8) ); @@ -213,8 +215,8 @@ public class MappingResponseSubscriber { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpHandler h1_fixedLengthHandler = new HTTP1_FixedLengthHandler(); HttpHandler h1_chunkHandler = new HTTP1_ChunkedHandler(); @@ -254,8 +256,8 @@ public class MappingResponseSubscriber { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(0); httpsTestServer.stop(0); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/MaxStreams.java b/test/jdk/java/net/httpclient/MaxStreams.java index b25f931be9d..00875aceb6f 100644 --- a/test/jdk/java/net/httpclient/MaxStreams.java +++ b/test/jdk/java/net/httpclient/MaxStreams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * @summary Should HttpClient support SETTINGS_MAX_CONCURRENT_STREAMS from the server * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm MaxStreams + * @run junit/othervm MaxStreams */ import java.io.IOException; @@ -53,24 +53,24 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class MaxStreams { - Http2TestServer http2TestServer; // HTTP/2 ( h2c ) - Http2TestServer https2TestServer; // HTTP/2 ( h2 ) - final Http2FixedHandler handler = new Http2FixedHandler(); + private static Http2TestServer http2TestServer; // HTTP/2 ( h2c ) + private static Http2TestServer https2TestServer; // HTTP/2 ( h2 ) + private static final Http2FixedHandler handler = new Http2FixedHandler(); private static final SSLContext ctx = SimpleSSLContext.findSSLContext(); - String http2FixedURI; - String https2FixedURI; - ExecutorService exec; + private static String http2FixedURI; + private static String https2FixedURI; + private static ExecutorService exec; // we send an initial warm up request, then MAX_STREAMS+1 requests // in parallel. The last of them should hit the limit. @@ -81,8 +81,7 @@ public class MaxStreams { static final int MAX_STREAMS = 10; static final String RESPONSE = "Hello world"; - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ {http2FixedURI}, {https2FixedURI}, @@ -92,7 +91,8 @@ public class MaxStreams { } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsString(String uri) throws Exception { CountDownLatch latch = new CountDownLatch(1); handler.setLatch(latch); @@ -161,8 +161,8 @@ public class MaxStreams { System.err.println("Test OK"); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { exec = Executors.newCachedThreadPool(); InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -180,13 +180,13 @@ public class MaxStreams { https2TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("Stopping test server now"); http2TestServer.stop(); } - class Http2FixedHandler implements Http2Handler { + static class Http2FixedHandler implements Http2Handler { final AtomicInteger counter = new AtomicInteger(0); volatile CountDownLatch latch; diff --git a/test/jdk/java/net/httpclient/NoBodyPartOne.java b/test/jdk/java/net/httpclient/NoBodyPartOne.java index 7c7a51c92e7..980f4d8d100 100644 --- a/test/jdk/java/net/httpclient/NoBodyPartOne.java +++ b/test/jdk/java/net/httpclient/NoBodyPartOne.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +27,7 @@ * @summary Test response body handlers/subscribers when there is no body * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=all * NoBodyPartOne @@ -42,16 +42,21 @@ import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +// @TestInstance(TestInstance.Lifecycle.PER_CLASS) +// is inherited from the super class public class NoBodyPartOne extends AbstractNoBody { - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsString(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsString(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -70,12 +75,13 @@ public class NoBodyPartOne extends AbstractNoBody { : BodyHandlers.ofString(UTF_8); HttpResponse response = client.send(req, handler); String body = response.body(); - assertEquals(body, ""); + assertEquals("", body); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsFile(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsFile(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -94,14 +100,15 @@ public class NoBodyPartOne extends AbstractNoBody { Path p = Paths.get("NoBody_testAsFile.txt"); HttpResponse response = client.send(req, BodyHandlers.ofFile(p)); Path bodyPath = response.body(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(Files.exists(bodyPath)); - assertEquals(Files.size(bodyPath), 0, Files.readString(bodyPath)); + assertEquals(0, Files.size(bodyPath), Files.readString(bodyPath)); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsByteArray(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsByteArray(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -119,7 +126,7 @@ public class NoBodyPartOne extends AbstractNoBody { .build(); HttpResponse response = client.send(req, BodyHandlers.ofByteArray()); byte[] body = response.body(); - assertEquals(body.length, 0); + assertEquals(0, body.length); } } } diff --git a/test/jdk/java/net/httpclient/NoBodyPartThree.java b/test/jdk/java/net/httpclient/NoBodyPartThree.java index d5e310d1914..7020f7e2c25 100644 --- a/test/jdk/java/net/httpclient/NoBodyPartThree.java +++ b/test/jdk/java/net/httpclient/NoBodyPartThree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +27,7 @@ * @summary Test request and response body handlers/subscribers when there is no body * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=quic,errors * -Djdk.httpclient.HttpClient.log=all * NoBodyPartThree @@ -46,19 +46,24 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +// @TestInstance(TestInstance.Lifecycle.PER_CLASS) +// is inherited from the super class public class NoBodyPartThree extends AbstractNoBody { static final AtomicInteger REQID = new AtomicInteger(); volatile boolean consumerHasBeenCalled; - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsByteArrayPublisher(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsByteArrayPublisher(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -83,7 +88,7 @@ public class NoBodyPartThree extends AbstractNoBody { consumerHasBeenCalled = false; var response = client.send(req, BodyHandlers.ofByteArrayConsumer(consumer)); assertTrue(consumerHasBeenCalled); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); u = uri + "/testAsByteArrayPublisher/second/" + REQID.getAndIncrement(); req = newRequestBuilder(u + "?echo") @@ -93,12 +98,13 @@ public class NoBodyPartThree extends AbstractNoBody { consumerHasBeenCalled = false; response = client.send(req, BodyHandlers.ofByteArrayConsumer(consumer)); assertTrue(consumerHasBeenCalled); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testStringPublisher(String uri, boolean sameClient) throws Exception { printStamp(START, "testStringPublisher(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -116,14 +122,15 @@ public class NoBodyPartThree extends AbstractNoBody { .build(); System.out.println("sending " + req); HttpResponse response = client.send(req, BodyHandlers.ofInputStream()); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] body = response.body().readAllBytes(); - assertEquals(body.length, 0); + assertEquals(0, body.length); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testInputStreamPublisherBuffering(String uri, boolean sameClient) throws Exception { printStamp(START, "testInputStreamPublisherBuffering(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -142,14 +149,15 @@ public class NoBodyPartThree extends AbstractNoBody { System.out.println("sending " + req); HttpResponse response = client.send(req, BodyHandlers.buffering(BodyHandlers.ofByteArray(), 1024)); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] body = response.body(); - assertEquals(body.length, 0); + assertEquals(0, body.length); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testEmptyArrayPublisher(String uri, boolean sameClient) throws Exception { printStamp(START, "testEmptyArrayPublisher(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -167,8 +175,8 @@ public class NoBodyPartThree extends AbstractNoBody { .build(); System.out.println("sending " + req); var response = client.send(req, BodyHandlers.ofLines()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body().toList(), List.of()); + assertEquals(200, response.statusCode()); + assertEquals(List.of(), response.body().toList()); } } } diff --git a/test/jdk/java/net/httpclient/NoBodyPartTwo.java b/test/jdk/java/net/httpclient/NoBodyPartTwo.java index f7d331cb526..9e7ceb11c55 100644 --- a/test/jdk/java/net/httpclient/NoBodyPartTwo.java +++ b/test/jdk/java/net/httpclient/NoBodyPartTwo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +27,7 @@ * @summary Test response body handlers/subscribers when there is no body * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=all * NoBodyPartTwo @@ -44,17 +44,22 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +// @TestInstance(TestInstance.Lifecycle.PER_CLASS) +// is inherited from the super class public class NoBodyPartTwo extends AbstractNoBody { volatile boolean consumerHasBeenCalled; - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsByteArrayConsumer(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsByteArrayConsumer(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -81,7 +86,8 @@ public class NoBodyPartTwo extends AbstractNoBody { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsInputStream(String uri, boolean sameClient) throws Exception { printStamp(START, "testAsInputStream(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -98,12 +104,13 @@ public class NoBodyPartTwo extends AbstractNoBody { .build(); HttpResponse response = client.send(req, BodyHandlers.ofInputStream()); byte[] body = response.body().readAllBytes(); - assertEquals(body.length, 0); + assertEquals(0, body.length); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testBuffering(String uri, boolean sameClient) throws Exception { printStamp(START, "testBuffering(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -121,12 +128,13 @@ public class NoBodyPartTwo extends AbstractNoBody { HttpResponse response = client.send(req, BodyHandlers.buffering(BodyHandlers.ofByteArray(), 1024)); byte[] body = response.body(); - assertEquals(body.length, 0); + assertEquals(0, body.length); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testDiscard(String uri, boolean sameClient) throws Exception { printStamp(START, "testDiscard(\"%s\", %s)", uri, sameClient); HttpClient client = null; @@ -143,7 +151,7 @@ public class NoBodyPartTwo extends AbstractNoBody { .build(); Object obj = new Object(); HttpResponse response = client.send(req, BodyHandlers.replacing(obj)); - assertEquals(response.body(), obj); + assertEquals(obj, response.body()); } } } diff --git a/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java b/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java index 0a0da6366ad..2e53479a6ee 100644 --- a/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java +++ b/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +29,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * @compile -encoding utf-8 NonAsciiCharsInURI.java - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=requests,headers,errors,quic * NonAsciiCharsInURI */ @@ -51,10 +51,6 @@ import java.util.List; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.err; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; @@ -63,24 +59,29 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class NonAsciiCharsInURI implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; - String http3URI_head; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; + private static String http3URI_head; - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; // € = '\u20AC' => 0xE20x820xAC static final String[][] pathsAndQueryStrings = new String[][] { @@ -93,8 +94,7 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { { "/006/x?url=https://ja.wikipedia.org/wiki/エリザベス1世_(イングランド女王)" }, }; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { List list = new ArrayList<>(); for (boolean sameClient : new boolean[] { false, true }) { @@ -136,7 +136,7 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { return null; } - HttpRequest.Builder newRequestBuilder(String uri) { + static HttpRequest.Builder newRequestBuilder(String uri) { var builder = HttpRequest.newBuilder(URI.create(uri)); if (version(uri) == HTTP_3) { builder.version(HTTP_3); @@ -145,7 +145,7 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { return builder; } - HttpResponse headRequest(HttpClient client) + static HttpResponse headRequest(HttpClient client) throws IOException, InterruptedException { out.println("\n" + now() + "--- Sending HEAD request ----\n"); @@ -154,25 +154,26 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { var request = newRequestBuilder(http3URI_head) .HEAD().version(HTTP_2).build(); var response = client.send(request, BodyHandlers.ofString()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_2); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_2, response.version()); out.println("\n" + now() + "--- HEAD request succeeded ----\n"); err.println("\n" + now() + "--- HEAD request succeeded ----\n"); return response; } - private HttpClient makeNewClient() { - return newClientBuilderForH3() + private static HttpClient makeNewClient() { + return HttpServerAdapters.createClientBuilderForH3() .proxy(NO_PROXY) .sslContext(sslContext) .build(); } - HttpClient newHttpClient(boolean share) { + private static final Object zis = new Object(); + static HttpClient newHttpClient(boolean share) { if (!share) return makeNewClient(); HttpClient shared = sharedClient; if (shared != null) return shared; - synchronized (this) { + synchronized (zis) { shared = sharedClient; if (shared == null) { shared = sharedClient = makeNewClient(); @@ -191,7 +192,8 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { static final int ITERATION_COUNT = 3; // checks upgrade and re-use - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uriString, boolean sameClient) throws Exception { out.println("\n--- Starting "); // The single-argument factory requires any illegal characters in its @@ -215,7 +217,7 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { out.println("Got response: " + resp); out.println("Got body: " + resp.body()); - assertEquals(resp.statusCode(), 200, + assertEquals(200, resp.statusCode(), "Expected 200, got:" + resp.statusCode()); // the response body should contain the toASCIIString @@ -228,12 +230,13 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { } else { out.println("Found expected " + resp.body() + " in " + expectedURIString); } - assertEquals(resp.version(), version(uriString)); + assertEquals(version(uriString), resp.version()); } } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uriString, boolean sameClient) throws Exception { out.println("\n--- Starting "); URI uri = URI.create(uriString); @@ -254,8 +257,8 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { .thenApply(response -> { out.println("Got response: " + response); out.println("Got body: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), version(uriString)); + assertEquals(200, response.statusCode()); + assertEquals(version(uriString), response.version()); return response.body(); }) .thenAccept(body -> { @@ -276,8 +279,8 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println(now() + "begin setup"); HttpTestHandler handler = new HttpUriStringHandler(); @@ -324,8 +327,8 @@ public class NonAsciiCharsInURI implements HttpServerAdapters { err.println(now() + "setup done"); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient.close(); httpTestServer.stop(); httpsTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/NullReturningBodyHandlerTest.java b/test/jdk/java/net/httpclient/NullReturningBodyHandlerTest.java new file mode 100644 index 00000000000..2b2e6b2135d --- /dev/null +++ b/test/jdk/java/net/httpclient/NullReturningBodyHandlerTest.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2026, 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.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Version; +import java.net.http.HttpOption; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandler; +import java.net.http.HttpResponse.BodySubscriber; +import java.net.http.HttpResponse.ResponseInfo; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import javax.net.ssl.SSLContext; + +import jdk.httpclient.test.lib.common.HttpServerAdapters; +import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestEchoHandler; +import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestServer; +import jdk.test.lib.net.SimpleSSLContext; +import jdk.test.lib.net.URIBuilder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static java.net.http.HttpClient.Builder.NO_PROXY; +import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/* + * @test + * @bug 8377796 + * @summary Verify that HttpClient.send()/sendAsync() complete exceptionally + * when BodyHandler.apply() returns null + * @library /test/lib /test/jdk/java/net/httpclient/lib + * @build jdk.httpclient.test.lib.common.HttpServerAdapters + * jdk.test.lib.net.SimpleSSLContext + * jdk.test.lib.net.URIBuilder + * @run junit ${test.main.class} + */ +class NullReturningBodyHandlerTest { + private static final String CTX_PATH = "/" + NullReturningBodyHandlerTest.class.getName(); + + private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); + private static HttpClient client; + + private static HttpTestServer h1HttpServer; + private static HttpTestServer h1HttpsServer; + + private static HttpTestServer h2HttpServer; + private static HttpTestServer h2HttpsServer; + + private static HttpTestServer h3Server; + + @BeforeAll + static void beforeAll() throws Exception { + h1HttpServer = HttpTestServer.create(Version.HTTP_1_1); + h1HttpServer.addHandler(new HttpTestEchoHandler(false), CTX_PATH); + h1HttpServer.start(); + System.err.println("HTTP/1.1 http server started at " + h1HttpServer.getAddress()); + + h1HttpsServer = HttpTestServer.create(Version.HTTP_1_1, sslContext); + h1HttpsServer.addHandler(new HttpTestEchoHandler(false), CTX_PATH); + h1HttpsServer.start(); + System.err.println("HTTP/1.1 https server started at " + h1HttpsServer.getAddress()); + + h2HttpServer = HttpTestServer.create(Version.HTTP_2); + h2HttpServer.addHandler(new HttpTestEchoHandler(false), CTX_PATH); + h2HttpServer.start(); + System.err.println("HTTP/2 http server started at " + h2HttpServer.getAddress()); + + h2HttpsServer = HttpTestServer.create(Version.HTTP_2, sslContext); + h2HttpsServer.addHandler(new HttpTestEchoHandler(false), CTX_PATH); + h2HttpsServer.start(); + System.err.println("HTTP/2 https server started at " + h2HttpsServer.getAddress()); + + h3Server = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); + h3Server.addHandler(new HttpTestEchoHandler(false), CTX_PATH); + h3Server.start(); + System.err.println("HTTP/3 server started at " + h3Server.getAddress()); + + client = HttpServerAdapters.createClientBuilderForH3() + .sslContext(sslContext) + .proxy(NO_PROXY) + .build(); + } + + @AfterAll + static void afterAll() throws Exception { + close(h1HttpServer); + close(h1HttpsServer); + + close(h2HttpServer); + close(h2HttpsServer); + + close(h3Server); + + close(client); + } + + private static void close(final AutoCloseable resource) throws Exception { + if (resource == null) { + return; + } + System.err.println("closing " + resource); + resource.close(); + } + + static List params() throws Exception { + final List args = new ArrayList<>(); + + final URI h1HttpsReq = URIBuilder.newBuilder() + .scheme("https") + .host(h1HttpsServer.getAddress().getAddress()) + .port(h1HttpsServer.getAddress().getPort()) + .path(CTX_PATH) + .query("reqVersion=h1") + .build(); + args.add(Arguments.of(h1HttpsReq, Version.HTTP_1_1, false)); + + final URI h1HttpReq = URIBuilder.newBuilder() + .scheme("http") + .host(h1HttpServer.getAddress().getAddress()) + .port(h1HttpServer.getAddress().getPort()) + .path(CTX_PATH) + .query("reqVersion=h1&scheme=http") + .build(); + args.add(Arguments.of(h1HttpReq, Version.HTTP_1_1, false)); + + final URI h2Req = URIBuilder.newBuilder() + .scheme("https") + .host(h2HttpsServer.getAddress().getAddress()) + .port(h2HttpsServer.getAddress().getPort()) + .path(CTX_PATH) + .query("reqVersion=h2") + .build(); + args.add(Arguments.of(h2Req, Version.HTTP_2, false)); + + final URI h2HttpReq = URIBuilder.newBuilder() + .scheme("http") + .host(h2HttpServer.getAddress().getAddress()) + .port(h2HttpServer.getAddress().getPort()) + .path(CTX_PATH) + .query("reqVersion=h2&scheme=http") + .build(); + // test for HTTP/2 upgrade when there are no already established connections + args.add(Arguments.of(h2HttpReq, Version.HTTP_2, false)); + // test for HTTP/2 upgrade when there is an established connection + args.add(Arguments.of(h2HttpReq, Version.HTTP_2, true)); + + final URI h3Req = URIBuilder.newBuilder() + .scheme("https") + .host(h3Server.getAddress().getAddress()) + .port(h3Server.getAddress().getPort()) + .path(CTX_PATH) + .query("reqVersion=h3") + .build(); + args.add(Arguments.of(h3Req, Version.HTTP_3, false)); + return args; + } + + /* + * Issues a HTTP request with a BodyHandler implementation that returns a null + * BodySubscriber. The test then verifies that the request fails and the exception + * that's raised contains the expected NullPointerException (raised due to + * BodyHandler.apply(...) returning null). + */ + @ParameterizedTest + @MethodSource("params") + void test(final URI reqURI, final Version version, + final boolean requiresWarmupHEADRequest) throws Exception { + if (requiresWarmupHEADRequest) { + // the test only issues a warmup request for HTTP/2 requests + assertEquals(Version.HTTP_2, version, "unexpected HTTP version"); + final HttpRequest head = HttpRequest.newBuilder().HEAD() + .version(version) + .uri(reqURI) + .build(); + System.err.println("issuing warmup head request " + head); + HttpResponse headResp = client.send(head, HttpResponse.BodyHandlers.discarding()); + assertEquals(200, headResp.statusCode(), "unexpected status code for HEAD request"); + } + // now run the actual test + final HttpRequest.Builder builder = HttpRequest.newBuilder() + .version(version) + .uri(reqURI); + if (version == Version.HTTP_3) { + builder.setOption(HttpOption.H3_DISCOVERY, HTTP_3_URI_ONLY); + } + final HttpRequest req = builder.build(); + // test synchronous send() + System.err.println("issuing request " + reqURI); + final IOException ioe = assertThrows(IOException.class, + () -> client.send(req, new AlwaysReturnsNull())); + if (!(ioe.getCause() instanceof NullPointerException)) { + throw ioe; // propagate the original exception + } + // now test with sendAsync() + System.err.println("issuing async request " + reqURI); + final Future> f = client.sendAsync(req, new AlwaysReturnsNull()); + final ExecutionException ee = assertThrows(ExecutionException.class, f::get); + if (!(ee.getCause() instanceof IOException cause) + || !(cause.getCause() instanceof NullPointerException)) { + throw ee; // propagate the original exception + } + } + + private static final class AlwaysReturnsNull implements BodyHandler { + @Override + public BodySubscriber apply(final ResponseInfo responseInfo) { + return null; + } + } +} diff --git a/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileDownloadTest.java b/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileDownloadTest.java index eb397d37b7a..92d359e32c6 100644 --- a/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileDownloadTest.java +++ b/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileDownloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,15 +37,11 @@ * jdk.test.lib.net.SimpleSSLContext * jdk.test.lib.Platform * jdk.test.lib.util.FileUtils - * @run testng/othervm BodyHandlerOfFileDownloadTest + * @run junit/othervm BodyHandlerOfFileDownloadTest */ import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.util.FileUtils; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -73,28 +69,35 @@ import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; import static java.nio.file.StandardOpenOption.WRITE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { static final String MSG = "msg"; static final String contentDispositionValue = "attachment; filename=example.html"; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - FileSystem zipFs; - Path defaultFsPath; - Path zipFsPath; + private static FileSystem zipFs; + private static Path defaultFsPath; + private static Path zipFsPath; // Default file system @@ -106,12 +109,10 @@ public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { return dir; } - @DataProvider(name = "defaultFsData") - public Object[][] defaultFsData() { + public static Object[][] defaultFsData() { return new Object[][]{ { http3URI, defaultFsPath, MSG, true }, { http3URI, defaultFsPath, MSG, false }, - { httpURI, defaultFsPath, MSG, true }, { httpsURI, defaultFsPath, MSG, true }, { http2URI, defaultFsPath, MSG, true }, @@ -123,7 +124,8 @@ public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { }; } - @Test(dataProvider = "defaultFsData") + @ParameterizedTest + @MethodSource("defaultFsData") public void testDefaultFs(String uriString, Path path, String expectedMsg, @@ -171,10 +173,10 @@ public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { out.printf("Resp code: %s\n", resp.statusCode()); out.println("Resp body Path: " + resp.body()); out.printf("Resp body written to file: %s\n", msg); - assertEquals(resp.statusCode(), 200); - assertEquals(msg, expectedMsg); + assertEquals(200, resp.statusCode()); + assertEquals(expectedMsg, msg); assertTrue(resp.headers().firstValue("Content-Disposition").isPresent()); - assertEquals(resp.headers().firstValue("Content-Disposition").get(), contentDispositionValue); + assertEquals(contentDispositionValue, resp.headers().firstValue("Content-Disposition").get()); if (!sameClient) { client.close(); } @@ -199,15 +201,17 @@ public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { return dir; } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testZipFs() { - out.printf("\n\n--- testZipFs(): starting\n"); - BodyHandlers.ofFileDownload(zipFsPath, CREATE, TRUNCATE_EXISTING, WRITE); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + out.printf("\n\n--- testZipFs(): starting\n"); + BodyHandlers.ofFileDownload(zipFsPath, CREATE, TRUNCATE_EXISTING, WRITE); + }); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { defaultFsPath = defaultFsDir(); zipFs = newZipFs(); zipFsPath = zipFsDir(zipFs); @@ -239,8 +243,8 @@ public class BodyHandlerOfFileDownloadTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { if (Files.exists(zipFsPath)) FileUtils.deleteFileTreeWithRetry(zipFsPath); if (Files.exists(defaultFsPath)) diff --git a/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileTest.java b/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileTest.java index 13871933eac..53b8607f294 100644 --- a/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileTest.java +++ b/test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -36,15 +36,11 @@ * jdk.httpclient.test.lib.http2.Queue * jdk.test.lib.net.SimpleSSLContext * jdk.test.lib.Platform jdk.test.lib.util.FileUtils - * @run testng/othervm BodyHandlerOfFileTest + * @run junit/othervm BodyHandlerOfFileTest */ import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.util.FileUtils; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -56,7 +52,10 @@ import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; -import java.nio.file.*; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Map; import jdk.httpclient.test.lib.common.HttpServerAdapters; import static java.lang.System.out; @@ -66,26 +65,31 @@ import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BodyHandlerOfFileTest implements HttpServerAdapters { static final String MSG = "msg"; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - FileSystem zipFs; - Path defaultFsPath; - Path zipFsPath; + private static FileSystem zipFs; + private static Path defaultFsPath; + private static Path zipFsPath; // Default file system set-up @@ -97,8 +101,7 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { return file; } - @DataProvider(name = "defaultFsData") - public Object[][] defaultFsData() { + public static Object[][] defaultFsData() { return new Object[][]{ { http3URI, defaultFsPath, MSG, true }, { http3URI, defaultFsPath, MSG, false }, @@ -114,7 +117,8 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { }; } - @Test(dataProvider = "defaultFsData") + @ParameterizedTest + @MethodSource("defaultFsData") public void testDefaultFs(String uriString, Path path, String expectedMsg, @@ -139,8 +143,7 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { return file; } - @DataProvider(name = "zipFsData") - public Object[][] zipFsData() { + public static Object[][] zipFsData() { return new Object[][]{ { http3URI, zipFsPath, MSG, true }, { http3URI, zipFsPath, MSG, false }, @@ -156,7 +159,8 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { }; } - @Test(dataProvider = "zipFsData") + @ParameterizedTest + @MethodSource("zipFsData") public void testZipFs(String uriString, Path path, String expectedMsg, @@ -203,8 +207,8 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { String msg = Files.readString(path, StandardCharsets.UTF_8); out.printf("Resp code: %s\n", resp.statusCode()); out.printf("Msg written to %s: %s\n", resp.body(), msg); - assertEquals(resp.statusCode(), 200); - assertEquals(msg, expectedMsg); + assertEquals(200, resp.statusCode()); + assertEquals(expectedMsg, msg); if (!sameClient) { client.close(); } @@ -214,8 +218,8 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { defaultFsPath = defaultFsFile(); zipFs = newZipFs(); zipFsPath = zipFsFile(zipFs); @@ -247,8 +251,8 @@ public class BodyHandlerOfFileTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { if (Files.exists(zipFsPath)) FileUtils.deleteFileTreeWithRetry(zipFsPath); if (Files.exists(defaultFsPath)) diff --git a/test/jdk/java/net/httpclient/PathSubscriber/BodySubscriberOfFileTest.java b/test/jdk/java/net/httpclient/PathSubscriber/BodySubscriberOfFileTest.java index d7c9a3af4f1..da0c7220b6b 100644 --- a/test/jdk/java/net/httpclient/PathSubscriber/BodySubscriberOfFileTest.java +++ b/test/jdk/java/net/httpclient/PathSubscriber/BodySubscriberOfFileTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,15 +35,11 @@ * jdk.httpclient.test.lib.http2.OutgoingPushPromise * jdk.httpclient.test.lib.http2.Queue jdk.test.lib.net.SimpleSSLContext * jdk.test.lib.Platform jdk.test.lib.util.FileUtils - * @run testng/othervm BodySubscriberOfFileTest + * @run junit/othervm BodySubscriberOfFileTest */ import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.util.FileUtils; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -58,7 +54,10 @@ import java.net.http.HttpResponse.BodySubscribers; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.nio.file.*; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Map; import java.util.concurrent.Flow; import java.util.stream.IntStream; @@ -70,26 +69,32 @@ import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BodySubscriberOfFileTest implements HttpServerAdapters { static final String MSG = "msg"; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; - FileSystem zipFs; - Path defaultFsPath; - Path zipFsPath; + private static FileSystem zipFs; + private static Path defaultFsPath; + private static Path zipFsPath; // Default file system set-up @@ -101,8 +106,7 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { return file; } - @DataProvider(name = "defaultFsData") - public Object[][] defaultFsData() { + public static Object[][] defaultFsData() { return new Object[][]{ { http3URI, defaultFsPath, MSG, true }, { http3URI, defaultFsPath, MSG, false }, @@ -118,7 +122,8 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { }; } - @Test(dataProvider = "defaultFsData") + @ParameterizedTest + @MethodSource("defaultFsData") public void testDefaultFs(String uriString, Path path, String expectedMsg, @@ -143,8 +148,7 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { return file; } - @DataProvider(name = "zipFsData") - public Object[][] zipFsData() { + public static Object[][] zipFsData() { return new Object[][]{ { http3URI, zipFsPath, MSG, true }, { http3URI, zipFsPath, MSG, false }, @@ -160,7 +164,8 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { }; } - @Test(dataProvider = "zipFsData") + @ParameterizedTest + @MethodSource("zipFsData") public void testZipFs(String uriString, Path path, String expectedMsg, @@ -209,8 +214,8 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { String msg = Files.readString(path, StandardCharsets.UTF_8); out.printf("Resp code: %s\n", resp.statusCode()); out.printf("Msg written to %s: %s\n", resp.body(), msg); - assertEquals(resp.statusCode(), 200); - assertEquals(msg, expectedMsg); + assertEquals(200, resp.statusCode()); + assertEquals(expectedMsg, msg); if (!sameClient) { client.close(); } @@ -240,12 +245,12 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { }); subscriber.onNext(buffers); subscriber.onComplete(); - buffers.forEach(b -> assertEquals(b.remaining(), 0) ); + buffers.forEach(b -> assertEquals(0, b.remaining()) ); assertEquals(expectedSize, Files.size(defaultFsPath)); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { defaultFsPath = defaultFsFile(); zipFs = newZipFs(); zipFsPath = zipFsFile(zipFs); @@ -277,8 +282,8 @@ public class BodySubscriberOfFileTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { if (Files.exists(zipFsPath)) FileUtils.deleteFileTreeWithRetry(zipFsPath); if (Files.exists(defaultFsPath)) diff --git a/test/jdk/java/net/httpclient/PlainProxyConnectionTest.java b/test/jdk/java/net/httpclient/PlainProxyConnectionTest.java index c2fab85f8ff..cd7049285f1 100644 --- a/test/jdk/java/net/httpclient/PlainProxyConnectionTest.java +++ b/test/jdk/java/net/httpclient/PlainProxyConnectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -208,9 +208,9 @@ public class PlainProxyConnectionTest { System.out.println("Server is: " + server.getAddress().toString()); URI uri = new URI("http", null, server.getAddress().getAddress().getHostAddress(), - server.getAddress().getPort(), PATH + "x", + server.getAddress().getPort(), PATH + "/x", null, null); - URI proxiedURI = new URI("http://some.host.that.does.not.exist:4242" + PATH + "x"); + URI proxiedURI = new URI("http://some.host.that.does.not.exist:4242" + PATH + "/x"); performSanityTest(server, uri, proxiedURI); diff --git a/test/jdk/java/net/httpclient/ProxySelectorTest.java b/test/jdk/java/net/httpclient/ProxySelectorTest.java index bf63e5a77b5..bb339e91bdc 100644 --- a/test/jdk/java/net/httpclient/ProxySelectorTest.java +++ b/test/jdk/java/net/httpclient/ProxySelectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,34 +27,20 @@ * @summary checks that a different proxy returned for * the same host:port is taken into account * @library /test/lib /test/jdk/java/net/httpclient/lib - * @build DigestEchoServer ProxySelectorTest jdk.httpclient.test.lib.http2.Http2TestServer + * @build DigestEchoServer ProxySelectorTest * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.http.auth.tunneling.disabledSchemes * -Djdk.httpclient.HttpClient.log=headers,requests * -Djdk.internal.httpclient.debug=true * ProxySelectorTest */ -import com.sun.net.httpserver.HttpServer; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; @@ -63,7 +49,6 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -73,37 +58,44 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import static java.lang.System.err; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; public class ProxySelectorTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 - HttpTestServer proxyHttpTestServer; // HTTP/1.1 - HttpTestServer authProxyHttpTestServer; // HTTP/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - DigestEchoServer.TunnelingProxy proxy; - DigestEchoServer.TunnelingProxy authproxy; - String httpURI; - String httpsURI; - String proxyHttpURI; - String authProxyHttpURI; - String http2URI; - String https2URI; - HttpClient client; + private static HttpTestServer httpTestServer; // HTTP/1.1 + private static HttpTestServer proxyHttpTestServer; // HTTP/1.1 + private static HttpTestServer authProxyHttpTestServer; // HTTP/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static DigestEchoServer.TunnelingProxy proxy; + private static DigestEchoServer.TunnelingProxy authproxy; + private static String httpURI; + private static String httpsURI; + private static String proxyHttpURI; + private static String http2URI; + private static String https2URI; + private static HttpClient client; - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static final long SLEEP_AFTER_TEST = 0; // milliseconds static final int ITERATIONS = 3; static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); @@ -144,34 +136,38 @@ public class ProxySelectorTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests() { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { // Exceptions should already have been added to FAILURES @@ -204,12 +200,10 @@ public class ProxySelectorTest implements HttpServerAdapters { static final int UNAUTHORIZED = 401; static final int PROXY_UNAUTHORIZED = 407; static final int HTTP_OK = 200; - static final String MESSAGE = "Unauthorized"; enum Schemes { HTTP, HTTPS } - @DataProvider(name = "all") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { Schemes.HTTP, HTTP_1_1, httpURI, true}, { Schemes.HTTP, HttpClient.Version.HTTP_2, http2URI, true}, @@ -222,15 +216,13 @@ public class ProxySelectorTest implements HttpServerAdapters { }; } - static final AtomicLong requestCounter = new AtomicLong(); - static final AtomicLong sleepCount = new AtomicLong(); - @Test(dataProvider = "all") + @ParameterizedTest + @MethodSource("positive") void test(Schemes scheme, HttpClient.Version version, String uri, boolean async) throws Throwable { - checkSkip(); var name = String.format("test(%s, %s, %s)", scheme, version, async); out.printf("%n---- starting %s ----%n", name); @@ -260,7 +252,7 @@ public class ProxySelectorTest implements HttpServerAdapters { HttpRequest request = requestBuilder.build(); out.println("Sending request: " + request.uri()); - HttpResponse response = null; + HttpResponse response; if (async) { response = client.send(request, handler); } else { @@ -288,9 +280,11 @@ public class ProxySelectorTest implements HttpServerAdapters { // A plain server or https server should serve it, and we should get 200 OK response = send(client, uri1, BodyHandlers.ofString(), async); out.println("Got response from plain server: " + response); - assertEquals(response.statusCode(), HTTP_OK); - assertEquals(response.headers().firstValue("X-value"), - scheme == Schemes.HTTPS ? Optional.of("https-server") : Optional.of("plain-server")); + assertEquals(HTTP_OK, response.statusCode()); + assertEquals(scheme == Schemes.HTTPS + ? Optional.of("https-server") + : Optional.of("plain-server"), + response.headers().firstValue("X-value")); // Second request should go through a non authenticating proxy. // For a clear connection - a proxy-server should serve it, and we should get 200 OK @@ -298,9 +292,11 @@ public class ProxySelectorTest implements HttpServerAdapters { // authenticating proxy - and we should receive 200 OK from an https-server response = send(client, uri2, BodyHandlers.ofString(), async); out.println("Got response through noauth proxy: " + response); - assertEquals(response.statusCode(), HTTP_OK); - assertEquals(response.headers().firstValue("X-value"), - scheme == Schemes.HTTPS ? Optional.of("https-server") : Optional.of("proxy-server")); + assertEquals(HTTP_OK, response.statusCode()); + assertEquals(scheme == Schemes.HTTPS + ? Optional.of("https-server") + : Optional.of("proxy-server"), + response.headers().firstValue("X-value")); // Third request should go through an authenticating proxy. // For a clear connection - an auth-proxy-server should serve it, and we @@ -310,16 +306,18 @@ public class ProxySelectorTest implements HttpServerAdapters { // proxy - so the X-value header will be absent response = send(client, uri3, BodyHandlers.ofString(), async); out.println("Got response through auth proxy: " + response); - assertEquals(response.statusCode(), PROXY_UNAUTHORIZED); - assertEquals(response.headers().firstValue("X-value"), - scheme == Schemes.HTTPS ? Optional.empty() : Optional.of("auth-proxy-server")); + assertEquals(PROXY_UNAUTHORIZED, response.statusCode()); + assertEquals(scheme == Schemes.HTTPS + ? Optional.empty() + : Optional.of("auth-proxy-server"), + response.headers().firstValue("X-value")); } // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new PlainServerHandler("plain-server"), "/http1/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1"; @@ -368,8 +366,8 @@ public class ProxySelectorTest implements HttpServerAdapters { serverCount.incrementAndGet(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { client = null; Thread.sleep(100); AssertionError fail = TRACKER.check(1500); @@ -387,7 +385,7 @@ public class ProxySelectorTest implements HttpServerAdapters { } } - class TestProxySelector extends ProxySelector { + static final class TestProxySelector extends ProxySelector { @Override public List select(URI uri) { String path = uri.getPath(); @@ -426,11 +424,8 @@ public class ProxySelectorTest implements HttpServerAdapters { String path = t.getRequestURI().getPath(); HttpTestRequestHeaders reqh = t.getRequestHeaders(); HttpTestResponseHeaders rsph = t.getResponseHeaders(); - - String xValue = serverType; rsph.addHeader("X-value", serverType); - t.getResponseHeaders().addHeader("X-value", xValue); byte[] body = "RESPONSE".getBytes(UTF_8); t.sendResponseHeaders(HTTP_OK, body.length); try (var out = t.getResponseBody()) { @@ -449,20 +444,16 @@ public class ProxySelectorTest implements HttpServerAdapters { @Override public void handle(HttpTestExchange t) throws IOException { readAllRequestData(t); // shouldn't be any - String method = t.getRequestMethod(); String path = t.getRequestURI().getPath(); - HttpTestRequestHeaders reqh = t.getRequestHeaders(); HttpTestResponseHeaders rsph = t.getResponseHeaders(); - String xValue = serverType; - String srv = path.contains("/proxy/") ? "proxy" : "server"; String prefix = path.contains("/proxy/") ? "Proxy-" : "WWW-"; int code = path.contains("/proxy/") ? PROXY_UNAUTHORIZED : UNAUTHORIZED; String resp = prefix + "Unauthorized"; rsph.addHeader(prefix + "Authenticate", "Basic realm=\"earth\", charset=\"UTF-8\""); byte[] body = resp.getBytes(UTF_8); - t.getResponseHeaders().addHeader("X-value", xValue); + rsph.addHeader("X-value", serverType); t.sendResponseHeaders(code, body.length); try (var out = t.getResponseBody()) { out.write(body); diff --git a/test/jdk/java/net/httpclient/RedirectMethodChange.java b/test/jdk/java/net/httpclient/RedirectMethodChange.java index b0b130921f5..73e27f6efff 100644 --- a/test/jdk/java/net/httpclient/RedirectMethodChange.java +++ b/test/jdk/java/net/httpclient/RedirectMethodChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Method change during redirection * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm RedirectMethodChange + * @run junit/othervm RedirectMethodChange */ import javax.net.ssl.SSLContext; @@ -41,33 +41,34 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.US_ASCII; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class RedirectMethodChange implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpClient client; + private static HttpClient client; - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; static final String RESPONSE = "Hello world"; static final String POST_BODY = "This is the POST body 123909090909090"; @@ -86,8 +87,7 @@ public class RedirectMethodChange implements HttpServerAdapters { } } - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][] { { http3URI, "GET", 301, "GET" }, { http3URI, "GET", 302, "GET" }, @@ -180,7 +180,8 @@ public class RedirectMethodChange implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uriString, String method, int redirectCode, @@ -195,15 +196,15 @@ public class RedirectMethodChange implements HttpServerAdapters { HttpResponse resp = client.send(req, BodyHandlers.ofString()); System.out.println("Response: " + resp + ", body: " + resp.body()); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.body(), RESPONSE); + assertEquals(200, resp.statusCode()); + assertEquals(RESPONSE, resp.body()); } // -- Infrastructure - @BeforeTest - public void setup() throws Exception { - client = newClientBuilderForH3() + @BeforeAll + public static void setup() throws Exception { + client = HttpServerAdapters.createClientBuilderForH3() .followRedirects(HttpClient.Redirect.NORMAL) .sslContext(sslContext) .build(); @@ -245,8 +246,8 @@ public class RedirectMethodChange implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { client.close(); httpTestServer.stop(); httpsTestServer.stop(); diff --git a/test/jdk/java/net/httpclient/RedirectTimeoutTest.java b/test/jdk/java/net/httpclient/RedirectTimeoutTest.java index e51f394f845..8c2fa8707ae 100644 --- a/test/jdk/java/net/httpclient/RedirectTimeoutTest.java +++ b/test/jdk/java/net/httpclient/RedirectTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,16 +29,11 @@ * an HttpTimeoutException during the redirected request. * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=errors,trace -Djdk.internal.httpclient.debug=false RedirectTimeoutTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=errors,trace -Djdk.internal.httpclient.debug=false RedirectTimeoutTest */ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.TestException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.io.OutputStream; @@ -64,6 +59,12 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static jdk.test.lib.Utils.adjustTimeout; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.fail; + public class RedirectTimeoutTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @@ -75,8 +76,8 @@ public class RedirectTimeoutTest implements HttpServerAdapters { public static final int ITERATIONS = 4; private static final PrintStream out = System.out; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { h1TestServer = HttpTestServer.create(HTTP_1_1); h2TestServer = HttpTestServer.create(HTTP_2); h3TestServer = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); @@ -101,15 +102,14 @@ public class RedirectTimeoutTest implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { h1TestServer.stop(); h2TestServer.stop(); h3TestServer.stop(); } - @DataProvider(name = "testData") - public Object[][] testData() { + public static Object[][] testData() { return new Object[][] { { HTTP_3, h3Uri, h3RedirectUri }, { HTTP_1_1, h1Uri, h1RedirectUri }, @@ -117,7 +117,8 @@ public class RedirectTimeoutTest implements HttpServerAdapters { }; } - @Test(dataProvider = "testData") + @ParameterizedTest + @MethodSource("testData") public void test(Version version, URI uri, URI redirectURI) throws InterruptedException { out.println("Testing for " + version); testRedirectURI = redirectURI; @@ -159,7 +160,7 @@ public class RedirectTimeoutTest implements HttpServerAdapters { } catch (IOException e) { if (e.getClass() == HttpTimeoutException.class) { e.printStackTrace(System.out); - throw new TestException("Timeout from original HttpRequest expired on redirect when it should have been cancelled."); + fail("Timeout from original HttpRequest expired on redirect when it should have been cancelled."); } else { throw new RuntimeException(e); } diff --git a/test/jdk/java/net/httpclient/RedirectWithCookie.java b/test/jdk/java/net/httpclient/RedirectWithCookie.java index b4a4df38721..ad94b124132 100644 --- a/test/jdk/java/net/httpclient/RedirectWithCookie.java +++ b/test/jdk/java/net/httpclient/RedirectWithCookie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Test for cookie handling when redirecting * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=trace,headers,requests * RedirectWithCookie */ @@ -45,10 +45,6 @@ import java.util.List; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; @@ -56,28 +52,32 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class RedirectWithCookie implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; static final String MESSAGE = "BasicRedirectTest message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { http3URI, }, { httpURI, }, @@ -96,7 +96,8 @@ public class RedirectWithCookie implements HttpServerAdapters { return builder; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); var builder = uriString.contains("/http3/") @@ -120,8 +121,8 @@ public class RedirectWithCookie implements HttpServerAdapters { out.println(" Got response: " + response); out.println(" Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); // asserts redirected URI in response.request().uri() assertTrue(response.uri().getPath().endsWith("message")); assertPreviousRedirectResponses(request, response); @@ -142,7 +143,7 @@ public class RedirectWithCookie implements HttpServerAdapters { response = response.previousResponse().get(); assertTrue(300 <= response.statusCode() && response.statusCode() <= 309, "Expected 300 <= code <= 309, got:" + response.statusCode()); - assertEquals(response.body(), null, "Unexpected body: " + response.body()); + assertEquals(null, response.body(), "Unexpected body: " + response.body()); String locationHeader = response.headers().firstValue("Location") .orElseThrow(() -> new RuntimeException("no previous Location")); assertTrue(uri.toString().endsWith(locationHeader), @@ -151,15 +152,15 @@ public class RedirectWithCookie implements HttpServerAdapters { } while (response.previousResponse().isPresent()); // initial - assertEquals(initialRequest, response.request(), + assertEquals(response.request(), initialRequest, String.format("Expected initial request [%s] to equal last prev req [%s]", initialRequest, response.request())); } // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new CookieRedirectHandler(), "/http1/cookie/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/cookie/redirect"; @@ -185,8 +186,8 @@ public class RedirectWithCookie implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/RequestBodyTest.java b/test/jdk/java/net/httpclient/RequestBodyTest.java index e43336610f0..e87cbc694c7 100644 --- a/test/jdk/java/net/httpclient/RequestBodyTest.java +++ b/test/jdk/java/net/httpclient/RequestBodyTest.java @@ -47,11 +47,11 @@ import static java.lang.System.out; import static java.nio.charset.StandardCharsets.*; import static java.nio.file.StandardOpenOption.*; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -62,18 +62,18 @@ import static org.testng.Assert.*; * @build LightWeightHttpServer * @build jdk.test.lib.Platform * @build jdk.test.lib.util.FileUtils - * @run testng/othervm RequestBodyTest + * @run junit/othervm RequestBodyTest */ public class RequestBodyTest { static final String fileroot = System.getProperty("test.src", ".") + "/docs"; static final String midSizedFilename = "/files/notsobigfile.txt"; static final String smallFilename = "/files/smallfile.txt"; - final ConcurrentHashMap failures = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap failures = new ConcurrentHashMap<>(); - HttpClient client; - String httpURI; - String httpsURI; + private static HttpClient client; + private static String httpURI; + private static String httpsURI; enum RequestBody { BYTE_ARRAY, @@ -95,8 +95,8 @@ public class RequestBodyTest { STRING_WITH_CHARSET, } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { LightWeightHttpServer.initServer(); httpURI = LightWeightHttpServer.httproot + "echo/foo"; httpsURI = LightWeightHttpServer.httpsroot + "echo/foo"; @@ -109,8 +109,8 @@ public class RequestBodyTest { .build(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { try { LightWeightHttpServer.stop(); } finally { @@ -127,8 +127,7 @@ public class RequestBodyTest { } } - @DataProvider - public Object[][] exchanges() throws Exception { + public static Object[][] exchanges() throws Exception { List values = new ArrayList<>(); for (boolean async : new boolean[] { false, true }) @@ -143,7 +142,8 @@ public class RequestBodyTest { return values.stream().toArray(Object[][]::new); } - @Test(dataProvider = "exchanges") + @ParameterizedTest + @MethodSource("exchanges") void exchange(String target, RequestBody requestBodyType, ResponseBody responseBodyType, @@ -239,8 +239,8 @@ public class RequestBodyTest { BodyHandler bh = BodyHandlers.ofByteArray(); if (bufferResponseBody) bh = BodyHandlers.buffering(bh, 50); HttpResponse bar = getResponse(client, request, bh, async); - assertEquals(bar.statusCode(), 200); - assertEquals(bar.body(), fileAsBytes); + assertEquals(200, bar.statusCode()); + assertArrayEquals(fileAsBytes, bar.body()); break; case BYTE_ARRAY_CONSUMER: ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -249,46 +249,46 @@ public class RequestBodyTest { if (bufferResponseBody) bh1 = BodyHandlers.buffering(bh1, 49); HttpResponse v = getResponse(client, request, bh1, async); byte[] ba = baos.toByteArray(); - assertEquals(v.statusCode(), 200); - assertEquals(ba, fileAsBytes); + assertEquals(200, v.statusCode()); + assertArrayEquals(fileAsBytes, ba); break; case DISCARD: Object o = new Object(); BodyHandler bh2 = BodyHandlers.replacing(o); if (bufferResponseBody) bh2 = BodyHandlers.buffering(bh2, 51); HttpResponse or = getResponse(client, request, bh2, async); - assertEquals(or.statusCode(), 200); + assertEquals(200, or.statusCode()); assertSame(or.body(), o); break; case FILE: BodyHandler bh3 = BodyHandlers.ofFile(tempFile); if (bufferResponseBody) bh3 = BodyHandlers.buffering(bh3, 48); HttpResponse fr = getResponse(client, request, bh3, async); - assertEquals(fr.statusCode(), 200); - assertEquals(Files.size(tempFile), fileAsString.length()); - assertEquals(Files.readAllBytes(tempFile), fileAsBytes); + assertEquals(200, fr.statusCode()); + assertEquals(fileAsString.length(), Files.size(tempFile)); + assertArrayEquals(fileAsBytes, Files.readAllBytes(tempFile)); break; case FILE_WITH_OPTION: BodyHandler bh4 = BodyHandlers.ofFile(tempFile, CREATE_NEW, WRITE); if (bufferResponseBody) bh4 = BodyHandlers.buffering(bh4, 52); fr = getResponse(client, request, bh4, async); - assertEquals(fr.statusCode(), 200); - assertEquals(Files.size(tempFile), fileAsString.length()); - assertEquals(Files.readAllBytes(tempFile), fileAsBytes); + assertEquals(200, fr.statusCode()); + assertEquals(fileAsString.length(), Files.size(tempFile)); + assertArrayEquals(fileAsBytes, Files.readAllBytes(tempFile)); break; case STRING: BodyHandler bh5 = BodyHandlers.ofString(); if(bufferResponseBody) bh5 = BodyHandlers.buffering(bh5, 47); HttpResponse sr = getResponse(client, request, bh5, async); - assertEquals(sr.statusCode(), 200); - assertEquals(sr.body(), fileAsString); + assertEquals(200, sr.statusCode()); + assertEquals(fileAsString, sr.body()); break; case STRING_WITH_CHARSET: BodyHandler bh6 = BodyHandlers.ofString(StandardCharsets.UTF_8); if (bufferResponseBody) bh6 = BodyHandlers.buffering(bh6, 53); HttpResponse r = getResponse(client, request, bh6, async); - assertEquals(r.statusCode(), 200); - assertEquals(r.body(), fileAsString); + assertEquals(200, r.statusCode()); + assertEquals(fileAsString, r.body()); break; default: throw new AssertionError("Unknown response body:" + responseBodyType); diff --git a/test/jdk/java/net/httpclient/RequestBuilderTest.java b/test/jdk/java/net/httpclient/RequestBuilderTest.java index a83c12f592e..12af908457b 100644 --- a/test/jdk/java/net/httpclient/RequestBuilderTest.java +++ b/test/jdk/java/net/httpclient/RequestBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @bug 8276559 * @summary HttpRequest[.Builder] API and behaviour checks - * @run testng RequestBuilderTest + * @run junit RequestBuilderTest */ import java.net.URI; @@ -49,9 +49,9 @@ import static java.time.Duration.ofNanos; import static java.time.Duration.ofMinutes; import static java.time.Duration.ofSeconds; import static java.time.Duration.ZERO; -import static org.testng.Assert.*; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class RequestBuilderTest { @@ -70,12 +70,12 @@ public class RequestBuilderTest { newBuilder(uri).copy()); for (HttpRequest.Builder builder : builders) { assertFalse(builder.build().expectContinue()); - assertEquals(builder.build().method(), "GET"); + assertEquals("GET", builder.build().method()); assertFalse(builder.build().bodyPublisher().isPresent()); assertFalse(builder.build().version().isPresent()); assertFalse(builder.build().timeout().isPresent()); assertTrue(builder.build().headers() != null); - assertEquals(builder.build().headers().map().size(), 0); + assertEquals(0, builder.build().headers().map().size()); } } @@ -128,61 +128,61 @@ public class RequestBuilderTest { assertThrows(IAE, () -> newBuilder().uri(u)); } - assertEquals(newBuilder(uri).build().uri(), uri); - assertEquals(newBuilder().uri(uri).build().uri(), uri); + assertEquals(uri, newBuilder(uri).build().uri()); + assertEquals(uri, newBuilder().uri(uri).build().uri()); URI https = URI.create("https://foo.com"); - assertEquals(newBuilder(https).build().uri(), https); - assertEquals(newBuilder().uri(https).build().uri(), https); + assertEquals(https, newBuilder(https).build().uri()); + assertEquals(https, newBuilder().uri(https).build().uri()); } @Test public void testMethod() { HttpRequest request = newBuilder(uri).build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).GET().build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).POST(BodyPublishers.ofString("")).GET().build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).PUT(BodyPublishers.ofString("")).GET().build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).DELETE().GET().build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).POST(BodyPublishers.ofString("")).build(); - assertEquals(request.method(), "POST"); + assertEquals("POST", request.method()); assertTrue(request.bodyPublisher().isPresent()); request = newBuilder(uri).PUT(BodyPublishers.ofString("")).build(); - assertEquals(request.method(), "PUT"); + assertEquals("PUT", request.method()); assertTrue(request.bodyPublisher().isPresent()); request = newBuilder(uri).DELETE().build(); - assertEquals(request.method(), "DELETE"); + assertEquals("DELETE", request.method()); assertTrue(!request.bodyPublisher().isPresent()); request = newBuilder(uri).HEAD().build(); - assertEquals(request.method(), "HEAD"); + assertEquals("HEAD", request.method()); assertFalse(request.bodyPublisher().isPresent()); request = newBuilder(uri).GET().POST(BodyPublishers.ofString("")).build(); - assertEquals(request.method(), "POST"); + assertEquals("POST", request.method()); assertTrue(request.bodyPublisher().isPresent()); request = newBuilder(uri).GET().PUT(BodyPublishers.ofString("")).build(); - assertEquals(request.method(), "PUT"); + assertEquals("PUT", request.method()); assertTrue(request.bodyPublisher().isPresent()); request = newBuilder(uri).GET().DELETE().build(); - assertEquals(request.method(), "DELETE"); + assertEquals("DELETE", request.method()); assertTrue(!request.bodyPublisher().isPresent()); // CONNECT is disallowed in the implementation, since it is used for @@ -190,11 +190,11 @@ public class RequestBuilderTest { assertThrows(IAE, () -> newBuilder(uri).method("CONNECT", BodyPublishers.noBody()).build()); request = newBuilder(uri).method("GET", BodyPublishers.noBody()).build(); - assertEquals(request.method(), "GET"); + assertEquals("GET", request.method()); assertTrue(request.bodyPublisher().isPresent()); request = newBuilder(uri).method("POST", BodyPublishers.ofString("")).build(); - assertEquals(request.method(), "POST"); + assertEquals("POST", request.method()); assertTrue(request.bodyPublisher().isPresent()); } @@ -207,7 +207,7 @@ public class RequestBuilderTest { assertThrows(IAE, () -> builder.headers("1").build()); assertThrows(IAE, () -> builder.headers("1", "2", "3").build()); assertThrows(IAE, () -> builder.headers("1", "2", "3", "4", "5").build()); - assertEquals(builder.build().headers().map().size(),0); + assertEquals(0, builder.build().headers().map().size()); List requests = List.of( // same header built from different combinations of the API @@ -219,13 +219,13 @@ public class RequestBuilderTest { ); for (HttpRequest r : requests) { - assertEquals(r.headers().map().size(), 1); + assertEquals(1, r.headers().map().size()); assertTrue(r.headers().firstValue("A").isPresent()); assertTrue(r.headers().firstValue("a").isPresent()); - assertEquals(r.headers().firstValue("A").get(), "B"); - assertEquals(r.headers().allValues("A"), List.of("B")); - assertEquals(r.headers().allValues("C").size(), 0); - assertEquals(r.headers().map().get("A"), List.of("B")); + assertEquals("B", r.headers().firstValue("A").get()); + assertEquals(List.of("B"), r.headers().allValues("A")); + assertEquals(0, r.headers().allValues("C").size()); + assertEquals(List.of("B"), r.headers().map().get("A")); assertThrows(NFE, () -> r.headers().firstValueAsLong("A")); assertFalse(r.headers().firstValue("C").isPresent()); // a non-exhaustive list of mutators @@ -265,14 +265,14 @@ public class RequestBuilderTest { ); for (HttpRequest r : requests) { - assertEquals(r.headers().map().size(), 2); + assertEquals(2, r.headers().map().size()); assertTrue(r.headers().firstValue("A").isPresent()); - assertEquals(r.headers().firstValue("A").get(), "B"); - assertEquals(r.headers().allValues("A"), List.of("B")); + assertEquals("B", r.headers().firstValue("A").get()); + assertEquals(List.of("B"), r.headers().allValues("A")); assertTrue(r.headers().firstValue("C").isPresent()); - assertEquals(r.headers().firstValue("C").get(), "D"); - assertEquals(r.headers().allValues("C"), List.of("D")); - assertEquals(r.headers().map().get("C"), List.of("D")); + assertEquals("D", r.headers().firstValue("C").get()); + assertEquals(List.of("D"), r.headers().allValues("C")); + assertEquals(List.of("D"), r.headers().map().get("C")); assertThrows(NFE, () -> r.headers().firstValueAsLong("C")); assertFalse(r.headers().firstValue("E").isPresent()); // a smaller non-exhaustive list of mutators @@ -304,11 +304,11 @@ public class RequestBuilderTest { ); for (HttpRequest r : requests) { - assertEquals(r.headers().map().size(), 1); + assertEquals(1, r.headers().map().size()); assertTrue(r.headers().firstValue("A").isPresent()); assertTrue(r.headers().allValues("A").containsAll(List.of("B", "C"))); - assertEquals(r.headers().allValues("C").size(), 0); - assertEquals(r.headers().map().get("A"), List.of("B", "C")); + assertEquals(0, r.headers().allValues("C").size()); + assertEquals(List.of("B", "C"), r.headers().map().get("A")); assertThrows(NFE, () -> r.headers().firstValueAsLong("A")); assertFalse(r.headers().firstValue("C").isPresent()); // a non-exhaustive list of mutators @@ -340,11 +340,11 @@ public class RequestBuilderTest { "aCCept-EnCODing", "accepT-encodinG")) { assertTrue(r.headers().firstValue(name).isPresent()); assertTrue(r.headers().allValues(name).contains("gzip, deflate")); - assertEquals(r.headers().firstValue(name).get(), "gzip, deflate"); - assertEquals(r.headers().allValues(name).size(), 1); - assertEquals(r.headers().map().size(), 1); - assertEquals(r.headers().map().get(name).size(), 1); - assertEquals(r.headers().map().get(name).get(0), "gzip, deflate"); + assertEquals("gzip, deflate", r.headers().firstValue(name).get()); + assertEquals(1, r.headers().allValues(name).size()); + assertEquals(1, r.headers().map().size()); + assertEquals(1, r.headers().map().get(name).size()); + assertEquals("gzip, deflate", r.headers().map().get(name).get(0)); } } } @@ -391,7 +391,7 @@ public class RequestBuilderTest { .GET(), "x-" + name, value).build(); String v = req.headers().firstValue("x-" + name).orElseThrow( () -> new RuntimeException("header x-" + name + " not set")); - assertEquals(v, value); + assertEquals(value, v); try { f.withHeader(HttpRequest.newBuilder(uri) .GET(), name, value).build(); @@ -419,27 +419,27 @@ public class RequestBuilderTest { builder.GET().timeout(ofSeconds(5)).version(HTTP_2).setHeader("A", "C"); HttpRequest copyRequest = copy.build(); - assertEquals(copyRequest.uri(), uri); - assertEquals(copyRequest.expectContinue(), true); - assertEquals(copyRequest.headers().map().get("A"), List.of("B")); - assertEquals(copyRequest.method(), "POST"); - assertEquals(copyRequest.bodyPublisher().isPresent(), true); - assertEquals(copyRequest.timeout().get(), ofSeconds(30)); + assertEquals(uri, copyRequest.uri()); + assertEquals(true, copyRequest.expectContinue()); + assertEquals(List.of("B"), copyRequest.headers().map().get("A")); + assertEquals("POST", copyRequest.method()); + assertEquals(true, copyRequest.bodyPublisher().isPresent()); + assertEquals(ofSeconds(30), copyRequest.timeout().get()); assertTrue(copyRequest.version().isPresent()); - assertEquals(copyRequest.version().get(), HTTP_1_1); + assertEquals(HTTP_1_1, copyRequest.version().get()); assertTrue(copyRequest.getOption(H3_DISCOVERY).isPresent()); - assertEquals(copyRequest.getOption(H3_DISCOVERY).get(), HTTP_3_URI_ONLY); + assertEquals(HTTP_3_URI_ONLY, copyRequest.getOption(H3_DISCOVERY).get()); // lazy set URI ( maybe builder as a template ) copyRequest = newBuilder().copy().uri(uri).build(); - assertEquals(copyRequest.uri(), uri); + assertEquals(uri, copyRequest.uri()); builder = newBuilder().header("C", "D"); copy = builder.copy(); copy.uri(uri); copyRequest = copy.build(); - assertEquals(copyRequest.uri(), uri); - assertEquals(copyRequest.headers().firstValue("C").get(), "D"); + assertEquals(uri, copyRequest.uri()); + assertEquals("D", copyRequest.headers().firstValue("C").get()); } @Test @@ -449,42 +449,41 @@ public class RequestBuilderTest { assertThrows(IAE, () -> builder.timeout(ofSeconds(0))); assertThrows(IAE, () -> builder.timeout(ofSeconds(-1))); assertThrows(IAE, () -> builder.timeout(ofNanos(-100))); - assertEquals(builder.timeout(ofNanos(15)).build().timeout().get(), ofNanos(15)); - assertEquals(builder.timeout(ofSeconds(50)).build().timeout().get(), ofSeconds(50)); - assertEquals(builder.timeout(ofMinutes(30)).build().timeout().get(), ofMinutes(30)); + assertEquals(ofNanos(15), builder.timeout(ofNanos(15)).build().timeout().get()); + assertEquals(ofSeconds(50), builder.timeout(ofSeconds(50)).build().timeout().get()); + assertEquals(ofMinutes(30), builder.timeout(ofMinutes(30)).build().timeout().get()); } @Test public void testExpect() { HttpRequest.Builder builder = newBuilder(uri); - assertEquals(builder.build().expectContinue(), false); - assertEquals(builder.expectContinue(true).build().expectContinue(), true); - assertEquals(builder.expectContinue(false).build().expectContinue(), false); - assertEquals(builder.expectContinue(true).build().expectContinue(), true); + assertEquals(false, builder.build().expectContinue()); + assertEquals(true, builder.expectContinue(true).build().expectContinue()); + assertEquals(false, builder.expectContinue(false).build().expectContinue()); + assertEquals(true, builder.expectContinue(true).build().expectContinue()); } @Test public void testEquals() { - assertNotEquals(newBuilder(URI.create("http://foo.com")), - newBuilder(URI.create("http://bar.com"))); + assertNotEquals( newBuilder(URI.create("http://bar.com")), newBuilder(URI.create("http://foo.com"))); HttpRequest.Builder builder = newBuilder(uri); assertEquals(builder.build(), builder.build()); - assertEquals(builder.build(), newBuilder(uri).build()); + assertEquals(newBuilder(uri).build(), builder.build()); builder.POST(BodyPublishers.noBody()); assertEquals(builder.build(), builder.build()); - assertEquals(builder.build(), newBuilder(uri).POST(BodyPublishers.noBody()).build()); - assertEquals(builder.build(), newBuilder(uri).POST(BodyPublishers.ofString("")).build()); - assertNotEquals(builder.build(), newBuilder(uri).build()); - assertNotEquals(builder.build(), newBuilder(uri).GET().build()); - assertNotEquals(builder.build(), newBuilder(uri).PUT(BodyPublishers.noBody()).build()); + assertEquals(newBuilder(uri).POST(BodyPublishers.noBody()).build(), builder.build()); + assertEquals(newBuilder(uri).POST(BodyPublishers.ofString("")).build(), builder.build()); + assertNotEquals(newBuilder(uri).build(), builder.build()); + assertNotEquals(newBuilder(uri).GET().build(), builder.build()); + assertNotEquals(newBuilder(uri).PUT(BodyPublishers.noBody()).build(), builder.build()); builder = newBuilder(uri).header("x", "y"); assertEquals(builder.build(), builder.build()); - assertEquals(builder.build(), newBuilder(uri).header("x", "y").build()); - assertNotEquals(builder.build(), newBuilder(uri).header("x", "Z").build()); - assertNotEquals(builder.build(), newBuilder(uri).header("z", "y").build()); + assertEquals(newBuilder(uri).header("x", "y").build(), builder.build()); + assertNotEquals(newBuilder(uri).header("x", "Z").build(), builder.build()); + assertNotEquals(newBuilder(uri).header("z", "y").build(), builder.build()); } @Test diff --git a/test/jdk/java/net/httpclient/Response1xxTest.java b/test/jdk/java/net/httpclient/Response1xxTest.java index 5cff7a69259..9b54f852510 100644 --- a/test/jdk/java/net/httpclient/Response1xxTest.java +++ b/test/jdk/java/net/httpclient/Response1xxTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,6 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; @@ -54,39 +50,44 @@ import static java.net.http.HttpClient.Version.valueOf; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -/** +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +/* * @test * @bug 8292044 * @summary Tests behaviour of HttpClient when server responds with 102 or 103 status codes * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=headers,requests,responses,errors Response1xxTest */ public class Response1xxTest implements HttpServerAdapters { private static final String EXPECTED_RSP_BODY = "Hello World"; - private ServerSocket serverSocket; - private Http11Server server; - private String http1RequestURIBase; + private static ServerSocket serverSocket; + private static Http11Server server; + private static String http1RequestURIBase; - private HttpTestServer http2Server; // h2c - private String http2RequestURIBase; + private static HttpTestServer http2Server; // h2c + private static String http2RequestURIBase; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer https2Server; // h2 - private String https2RequestURIBase; + private static HttpTestServer https2Server; // h2 + private static String https2RequestURIBase; - private HttpTestServer http3Server; // h3 - private String http3RequestURIBase; + private static HttpTestServer http3Server; // h3 + private static String http3RequestURIBase; - private final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - @BeforeClass - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { serverSocket = new ServerSocket(0, 0, InetAddress.getLoopbackAddress()); server = new Http11Server(serverSocket); new Thread(server).start(); @@ -130,8 +131,8 @@ public class Response1xxTest implements HttpServerAdapters { } - @AfterClass - public void teardown() throws Throwable { + @AfterAll + public static void teardown() throws Throwable { try { assertNoOutstandingClientOps(); } finally { @@ -269,7 +270,7 @@ public class Response1xxTest implements HttpServerAdapters { static String readRequestLine(final Socket sock) throws IOException { final InputStream is = sock.getInputStream(); - final StringBuilder sb = new StringBuilder(""); + final StringBuilder sb = new StringBuilder(); byte[] buf = new byte[1024]; while (!sb.toString().endsWith("\r\n\r\n")) { final int numRead = is.read(buf); @@ -424,10 +425,10 @@ public class Response1xxTest implements HttpServerAdapters { System.out.println("Issuing request to " + requestURI); final HttpResponse response = client.send(request, BodyHandlers.ofString(StandardCharsets.UTF_8)); - Assert.assertEquals(response.version(), version, + Assertions.assertEquals(version, response.version(), "Unexpected HTTP version in response"); - Assert.assertEquals(response.statusCode(), 200, "Unexpected response code"); - Assert.assertEquals(response.body(), EXPECTED_RSP_BODY, "Unexpected response body"); + Assertions.assertEquals(200, response.statusCode(), "Unexpected response code"); + Assertions.assertEquals(EXPECTED_RSP_BODY, response.body(), "Unexpected response body"); } } @@ -484,7 +485,7 @@ public class Response1xxTest implements HttpServerAdapters { .build(); System.out.println("Issuing request to " + requestURI); // we expect the request to timeout - Assert.assertThrows(HttpTimeoutException.class, () -> { + Assertions.assertThrows(HttpTimeoutException.class, () -> { client.send(request, BodyHandlers.ofString(StandardCharsets.UTF_8)); }); } @@ -561,7 +562,7 @@ public class Response1xxTest implements HttpServerAdapters { final HttpRequest request = requestBuilder.build(); System.out.println("Issuing request to " + requestURI); // we expect the request to fail because the server sent an unexpected 101 - Assert.assertThrows(ProtocolException.class, + Assertions.assertThrows(ProtocolException.class, () -> client.send(request, BodyHandlers.ofString(StandardCharsets.UTF_8))); } @@ -571,11 +572,11 @@ public class Response1xxTest implements HttpServerAdapters { final HttpRequest request = HttpRequest.newBuilder(requestURI).build(); System.out.println("Issuing (warmup) request to " + requestURI); final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.discarding()); - Assert.assertEquals(response.statusCode(), 200, "Unexpected response code"); + Assertions.assertEquals(200, response.statusCode(), "Unexpected response code"); } // verifies that the HttpClient being tracked has no outstanding operations - private void assertNoOutstandingClientOps() throws AssertionError { + private static void assertNoOutstandingClientOps() throws AssertionError { System.gc(); final AssertionError refCheckFailure = TRACKER.check(1000); if (refCheckFailure != null) { diff --git a/test/jdk/java/net/httpclient/Response204V2Test.java b/test/jdk/java/net/httpclient/Response204V2Test.java index c9dbd8eccf9..835f7aa65f7 100644 --- a/test/jdk/java/net/httpclient/Response204V2Test.java +++ b/test/jdk/java/net/httpclient/Response204V2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * ReferenceTracker jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * Response204V2Test * @summary Tests that streams are closed after receiving a 204 response. @@ -44,7 +44,6 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -52,19 +51,9 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; @@ -74,15 +63,25 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class Response204V2Test implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String http2URI; + private static String https2URI; + private static String http3URI; static final int RESPONSE_CODE = 204; static final int ITERATION_COUNT = 4; @@ -101,8 +100,8 @@ public class Response204V2Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -128,40 +127,40 @@ public class Response204V2Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static final void printFailedTests() { out.println("\n========================="); try { - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - FAILURES.putAll(failed); - out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -179,7 +178,7 @@ public class Response204V2Test implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { http3URI, http2URI, @@ -187,13 +186,7 @@ public class Response204V2Test implements HttpServerAdapters { }; } - static AtomicLong URICOUNT = new AtomicLong(); - - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; int i = 0; @@ -232,23 +225,6 @@ public class Response204V2Test implements HttpServerAdapters { } } - - static void checkStatus(int expected, int found) throws Exception { - if (expected != found) { - System.err.printf ("Test failed: wrong status code %d/%d\n", - expected, found); - throw new RuntimeException("Test failed"); - } - } - - static void checkStrings(String expected, String found) throws Exception { - if (!expected.equals(found)) { - System.err.printf ("Test failed: wrong string %s/%s\n", - expected, found); - throw new RuntimeException("Test failed"); - } - } - private HttpRequest.Builder newRequestBuilder(URI uri) { var builder = HttpRequest.newBuilder(uri); if (uri.getRawPath().contains("/http3/")) { @@ -258,10 +234,10 @@ public class Response204V2Test implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) throws Exception { - checkSkip(); - out.println("Request to " + uri); + out.printf("%n%s-- test sameClient=%s, uri=%s%n%n", now(), sameClient, uri); HttpClient client = newHttpClient(uri, sameClient); @@ -282,8 +258,8 @@ public class Response204V2Test implements HttpServerAdapters { out.println("test: DONE"); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/2 HttpTestHandler handler204 = new Handler204(); @@ -305,8 +281,8 @@ public class Response204V2Test implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); sharedClient = null; diff --git a/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java b/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java index 123e47e2ac9..19393d99ee9 100644 --- a/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java +++ b/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +28,7 @@ * @modules java.net.http/jdk.internal.net.http.common * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm/timeout=480 ResponseBodyBeforeError + * @run junit/othervm/timeout=480 ResponseBodyBeforeError */ import java.io.Closeable; @@ -54,10 +54,6 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; import java.util.concurrent.Flow; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocketFactory; @@ -67,28 +63,32 @@ import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ResponseBodyBeforeError { - ReplyingServer variableLengthServer; - ReplyingServer variableLengthHttpsServer; - ReplyingServer fixedLengthServer; - ReplyingServer fixedLengthHttpsServer; + private static ReplyingServer variableLengthServer; + private static ReplyingServer variableLengthHttpsServer; + private static ReplyingServer fixedLengthServer; + private static ReplyingServer fixedLengthHttpsServer; - String httpURIVarLen; - String httpsURIVarLen; - String httpURIFixLen; - String httpsURIFixLen; + private static String httpURIVarLen; + private static String httpsURIVarLen; + private static String httpURIFixLen; + private static String httpsURIFixLen; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); static final String EXPECTED_RESPONSE_BODY = "

Heading

Some Text

"; - @DataProvider(name = "sanity") - public Object[][] sanity() { + public static Object[][] sanity() { return new Object[][]{ { httpURIVarLen + "?length=all" }, { httpsURIVarLen + "?length=all" }, @@ -97,7 +97,8 @@ public class ResponseBodyBeforeError { }; } - @Test(dataProvider = "sanity") + @ParameterizedTest + @MethodSource("sanity") void sanity(String url) throws Exception { HttpClient client = HttpClient.newBuilder() .proxy(NO_PROXY) @@ -106,15 +107,14 @@ public class ResponseBodyBeforeError { HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); HttpResponse response = client.send(request, ofString()); String body = response.body(); - assertEquals(body, EXPECTED_RESPONSE_BODY); + assertEquals(EXPECTED_RESPONSE_BODY, body); client.sendAsync(request, ofString()) .thenApply(resp -> resp.body()) - .thenAccept(b -> assertEquals(b, EXPECTED_RESPONSE_BODY)) + .thenAccept(b -> assertEquals(EXPECTED_RESPONSE_BODY, b)) .join(); } - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { Object[][] cases = new Object[][] { // The length query string is the total number of response body // bytes in the reply, before the server closes the connection. The @@ -182,7 +182,8 @@ public class ResponseBodyBeforeError { static final int ITERATION_COUNT = 3; static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testSynchronousAllRequestBody(String url, String expectedPatrialBody, boolean sameClient) @@ -210,7 +211,7 @@ public class ResponseBodyBeforeError { } catch (IOException expected) { String pm = bs.receivedAsString(); out.println("partial body received: " + pm); - assertEquals(pm, expectedPatrialBody); + assertEquals(expectedPatrialBody, pm); } } } finally { @@ -221,7 +222,8 @@ public class ResponseBodyBeforeError { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsynchronousAllRequestBody(String url, String expectedPatrialBody, boolean sameClient) @@ -250,7 +252,7 @@ public class ResponseBodyBeforeError { if (ee.getCause() instanceof IOException) { String pm = bs.receivedAsString(); out.println("partial body received: " + pm); - assertEquals(pm, expectedPatrialBody); + assertEquals(expectedPatrialBody, pm); } else { throw ee; } @@ -536,8 +538,8 @@ public class ResponseBodyBeforeError { + server.getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { SSLContext.setDefault(sslContext); variableLengthServer = new PlainVariableLengthServer(); @@ -557,8 +559,8 @@ public class ResponseBodyBeforeError { + "/https1/fixed/foz"; } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { variableLengthServer.close(); variableLengthHttpsServer.close(); fixedLengthServer.close(); diff --git a/test/jdk/java/net/httpclient/ResponsePublisher.java b/test/jdk/java/net/httpclient/ResponsePublisher.java index ce86a0a3cf5..be135e84b31 100644 --- a/test/jdk/java/net/httpclient/ResponsePublisher.java +++ b/test/jdk/java/net/httpclient/ResponsePublisher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,22 +28,16 @@ * immediately with a Publisher> * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm/timeout=480 ResponsePublisher + * @run junit/othervm/timeout=480 ResponsePublisher */ -import com.sun.net.httpserver.HttpServer; import jdk.internal.net.http.common.OperationTrackers; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.InetAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -73,28 +67,33 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ResponsePublisher implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI_fixed; - String httpURI_chunk; - String httpsURI_fixed; - String httpsURI_chunk; - String http2URI_fixed; - String http2URI_chunk; - String https2URI_fixed; - String https2URI_chunk; - String http3URI_fixed; - String http3URI_chunk; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI_fixed; + private static String httpURI_chunk; + private static String httpsURI_fixed; + private static String httpsURI_chunk; + private static String http2URI_fixed; + private static String http2URI_chunk; + private static String https2URI_fixed; + private static String https2URI_chunk; + private static String http3URI_fixed; + private static String http3URI_chunk; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -139,8 +138,7 @@ public class ResponsePublisher implements HttpServerAdapters { static final Supplier>>> OF_PUBLISHER_TEST = BHS.of(PublishingBodyHandler::new, "PublishingBodyHandler::new"); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { http3URI_fixed, false, OF_PUBLISHER_API }, { http3URI_chunk, false, OF_PUBLISHER_API }, @@ -190,7 +188,7 @@ public class ResponsePublisher implements HttpServerAdapters { }; } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; HttpClient newHttpClient(String uri) { var builder = uri.contains("/http3/") ? newClientBuilderForH3() @@ -210,8 +208,9 @@ public class ResponsePublisher implements HttpServerAdapters { return builder; } - @Test(dataProvider = "variants") - public void testExceptions(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testExceptions(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) @@ -247,7 +246,7 @@ public class ResponsePublisher implements HttpServerAdapters { } // Get the final result and compare it with the expected body String body = ofString.getBody().toCompletableFuture().get(); - assertEquals(body, ""); + assertEquals("", body); // ensure client closes before next iteration if (!sameClient) { var tracker = TRACKER.getTracker(client); @@ -257,8 +256,9 @@ public class ResponsePublisher implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testNoBody(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testNoBody(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) @@ -276,7 +276,7 @@ public class ResponsePublisher implements HttpServerAdapters { response.body().subscribe(ofString); // Get the final result and compare it with the expected body String body = ofString.getBody().toCompletableFuture().get(); - assertEquals(body, ""); + assertEquals("", body); // ensure client closes before next iteration if (!sameClient) { var tracker = TRACKER.getTracker(client); @@ -286,8 +286,9 @@ public class ResponsePublisher implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testNoBodyAsync(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testNoBodyAsync(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) @@ -308,7 +309,7 @@ public class ResponsePublisher implements HttpServerAdapters { return ofString.getBody(); }); // Get the final result and compare it with the expected body - assertEquals(result.get(), ""); + assertEquals("", result.get()); // ensure client closes before next iteration if (!sameClient) { var tracker = TRACKER.getTracker(client); @@ -318,8 +319,9 @@ public class ResponsePublisher implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testAsString(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testAsString(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) @@ -337,7 +339,7 @@ public class ResponsePublisher implements HttpServerAdapters { response.body().subscribe(ofString); // Get the final result and compare it with the expected body String body = ofString.getBody().toCompletableFuture().get(); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); // ensure client closes before next iteration if (!sameClient) { var tracker = TRACKER.getTracker(client); @@ -347,8 +349,9 @@ public class ResponsePublisher implements HttpServerAdapters { } } - @Test(dataProvider = "variants") - public void testAsStringAsync(String uri, boolean sameClient, BHS handlers) throws Exception { + @ParameterizedTest + @MethodSource("variants") + void testAsStringAsync(String uri, boolean sameClient, BHS handlers) throws Exception { HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { if (!sameClient || client == null) @@ -369,7 +372,7 @@ public class ResponsePublisher implements HttpServerAdapters { }); // Get the final result and compare it with the expected body String body = result.get(); - assertEquals(body, WITH_BODY); + assertEquals(WITH_BODY, body); // ensure client closes before next iteration if (!sameClient) { var tracker = TRACKER.getTracker(client); @@ -383,7 +386,7 @@ public class ResponsePublisher implements HttpServerAdapters { static class PublishingBodyHandler implements BodyHandler>> { @Override public BodySubscriber>> apply(HttpResponse.ResponseInfo rinfo) { - assertEquals(rinfo.statusCode(), 200); + assertEquals(200, rinfo.statusCode()); return new PublishingBodySubscriber(); } } @@ -392,7 +395,7 @@ public class ResponsePublisher implements HttpServerAdapters { static class PublishingBodySubscriber implements BodySubscriber>> { private final CompletableFuture subscriptionCF = new CompletableFuture<>(); private final CompletableFuture>> subscribedCF = new CompletableFuture<>(); - private AtomicReference>> subscriberRef = new AtomicReference<>(); + private final AtomicReference>> subscriberRef = new AtomicReference<>(); private final CompletionStage>> body = subscriptionCF.thenCompose((s) -> CompletableFuture.completedStage(this::subscribe)); //CompletableFuture.completedStage(this::subscribe); @@ -449,13 +452,8 @@ public class ResponsePublisher implements HttpServerAdapters { } } - static String serverAuthority(HttpServer server) { - return InetAddress.getLoopbackAddress().getHostName() + ":" - + server.getAddress().getPort(); - } - - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler(); HttpTestHandler h1_chunkHandler = new HTTP_VariableLengthHandler(); @@ -504,8 +502,8 @@ public class ResponsePublisher implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(500); try { diff --git a/test/jdk/java/net/httpclient/RetryPost.java b/test/jdk/java/net/httpclient/RetryPost.java index ccd5dbb2922..67969306acc 100644 --- a/test/jdk/java/net/httpclient/RetryPost.java +++ b/test/jdk/java/net/httpclient/RetryPost.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,8 @@ /* * @test * @summary Ensure that the POST method is retied when the property is set. - * @run testng/othervm -Djdk.httpclient.enableAllMethodRetry RetryPost - * @run testng/othervm -Djdk.httpclient.enableAllMethodRetry=true RetryPost + * @run junit/othervm -Djdk.httpclient.enableAllMethodRetry RetryPost + * @run junit/othervm -Djdk.httpclient.enableAllMethodRetry=true RetryPost */ import java.io.IOException; @@ -41,26 +41,26 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static java.nio.charset.StandardCharsets.US_ASCII; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class RetryPost { - FixedLengthServer fixedLengthServer; - String httpURIFixLen; + private static FixedLengthServer fixedLengthServer; + private static String httpURIFixLen; static final String RESPONSE_BODY = "You use a glass mirror to see your face: you use works of art to see your soul."; - @DataProvider(name = "uris") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][] { { httpURIFixLen, true }, { httpURIFixLen, false }, @@ -71,7 +71,8 @@ public class RetryPost { static final String REQUEST_BODY = "Body"; - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testSynchronousPOST(String url, boolean sameClient) throws Exception { out.print("---\n"); HttpClient client = null; @@ -84,12 +85,13 @@ public class RetryPost { HttpResponse response = client.send(request, ofString()); String body = response.body(); out.println(response + ": " + body); - assertEquals(response.statusCode(), 200); - assertEquals(body, RESPONSE_BODY); + assertEquals(200, response.statusCode()); + assertEquals(RESPONSE_BODY, body); } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsynchronousPOST(String url, boolean sameClient) { out.print("---\n"); HttpClient client = null; @@ -101,9 +103,9 @@ public class RetryPost { .build(); client.sendAsync(request, ofString()) .thenApply(r -> { out.println(r + ": " + r.body()); return r; }) - .thenApply(r -> { assertEquals(r.statusCode(), 200); return r; }) + .thenApply(r -> { assertEquals(200, r.statusCode()); return r; }) .thenApply(HttpResponse::body) - .thenAccept(b -> assertEquals(b, RESPONSE_BODY)) + .thenAccept(b -> assertEquals(RESPONSE_BODY, b)) .join(); } } @@ -223,15 +225,15 @@ public class RetryPost { + server.getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { fixedLengthServer = new FixedLengthServer(); httpURIFixLen = "http://" + serverAuthority(fixedLengthServer) + "/http1/fixed/baz"; } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { fixedLengthServer.close(); } } diff --git a/test/jdk/java/net/httpclient/RetryWithCookie.java b/test/jdk/java/net/httpclient/RetryWithCookie.java index 782d8a0b956..8638693b50d 100644 --- a/test/jdk/java/net/httpclient/RetryWithCookie.java +++ b/test/jdk/java/net/httpclient/RetryWithCookie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,16 +29,12 @@ * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=trace,headers,requests * RetryWithCookie */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -67,28 +63,32 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class RetryWithCookie implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 5 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; static final String MESSAGE = "BasicRedirectTest message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { http3URI, }, { httpURI, }, @@ -99,7 +99,7 @@ public class RetryWithCookie implements HttpServerAdapters { } static final AtomicLong requestCounter = new AtomicLong(); - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; private HttpRequest.Builder newRequestBuilder(URI uri) { var builder = HttpRequest.newBuilder(uri); @@ -110,7 +110,8 @@ public class RetryWithCookie implements HttpServerAdapters { return builder; } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); CookieManager cookieManager = new CookieManager(); @@ -145,9 +146,9 @@ public class RetryWithCookie implements HttpServerAdapters { out.println(" Got response: " + response); out.println(" Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); - assertEquals(response.headers().allValues("X-Request-Cookie"), cookies); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); + assertEquals(cookies, response.headers().allValues("X-Request-Cookie")); request = newRequestBuilder(uri) .header("X-uuid", "uuid-" + requestCounter.incrementAndGet()) .build(); @@ -156,8 +157,8 @@ public class RetryWithCookie implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new CookieRetryHandler(), "/http1/cookie/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/cookie/retry"; @@ -183,8 +184,8 @@ public class RetryWithCookie implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(500); try { diff --git a/test/jdk/java/net/httpclient/SSLExceptionTest.java b/test/jdk/java/net/httpclient/SSLExceptionTest.java index 4fa17c875c3..cf94d1b50f7 100644 --- a/test/jdk/java/net/httpclient/SSLExceptionTest.java +++ b/test/jdk/java/net/httpclient/SSLExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,11 @@ import java.io.UncheckedIOException; import java.net.http.HttpClient; import java.security.NoSuchAlgorithmException; -import org.testng.annotations.Test; -import static org.testng.Assert.expectThrows; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /* * @test @@ -34,7 +36,7 @@ import static org.testng.Assert.fail; * @summary This test verifies exception when resources for * SSLcontext used by HttpClient are not available * @build SSLExceptionTest - * @run testng/othervm -Djdk.tls.client.protocols="InvalidTLSv1.4" + * @run junit/othervm -Djdk.tls.client.protocols="InvalidTLSv1.4" * SSLExceptionTest */ @@ -47,12 +49,12 @@ public class SSLExceptionTest { @Test public void testHttpClientsslException() { for (int i = 0; i < ITERATIONS; i++) { - excp = expectThrows(UncheckedIOException.class, HttpClient.newBuilder()::build); + excp = Assertions.assertThrows(UncheckedIOException.class, HttpClient.newBuilder()::build); noSuchAlgo = excp.getCause().getCause(); if ( !(noSuchAlgo instanceof NoSuchAlgorithmException) ) { fail("Test failed due to wrong exception cause : " + noSuchAlgo); } - excp = expectThrows(UncheckedIOException.class, HttpClient::newHttpClient); + excp = Assertions.assertThrows(UncheckedIOException.class, HttpClient::newHttpClient); noSuchAlgo = excp.getCause().getCause(); if ( !(noSuchAlgo instanceof NoSuchAlgorithmException) ) { fail("Test failed due to wrong exception cause : " + noSuchAlgo); diff --git a/test/jdk/java/net/httpclient/SendResponseHeadersTest.java b/test/jdk/java/net/httpclient/SendResponseHeadersTest.java index df8bc3b0844..2998522616f 100644 --- a/test/jdk/java/net/httpclient/SendResponseHeadersTest.java +++ b/test/jdk/java/net/httpclient/SendResponseHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,16 +27,13 @@ * @library /test/lib * @summary Check that sendResponseHeaders throws an IOException when headers * have already been sent - * @run testng/othervm SendResponseHeadersTest + * @run junit/othervm SendResponseHeadersTest */ 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.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; @@ -54,16 +51,21 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.expectThrows; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class SendResponseHeadersTest { - URI uri; - HttpServer server; - ExecutorService executor; + private static URI uri; + private static HttpServer server; + private static ExecutorService executor; - @BeforeTest - public void setUp() throws IOException, URISyntaxException { + @BeforeAll + public static void setUp() throws IOException, URISyntaxException { var loopback = InetAddress.getLoopbackAddress(); var addr = new InetSocketAddress(loopback, 0); server = HttpServer.create(addr, 0); @@ -94,8 +96,8 @@ public class SendResponseHeadersTest { fail(response.body()); } - @AfterTest - public void tearDown() { + @AfterAll + public static void tearDown() { server.stop(0); executor.shutdown(); } @@ -108,7 +110,7 @@ public class SendResponseHeadersTest { is.readAllBytes(); exchange.sendResponseHeaders(200, 0); try { - IOException io = expectThrows(IOException.class, + IOException io = Assertions.assertThrows(IOException.class, () -> exchange.sendResponseHeaders(200, 0)); System.out.println("Got expected exception: " + io); } catch (Throwable t) { diff --git a/test/jdk/java/net/httpclient/ServerCloseTest.java b/test/jdk/java/net/httpclient/ServerCloseTest.java index 65eb6cfc589..d5e762b15a4 100644 --- a/test/jdk/java/net/httpclient/ServerCloseTest.java +++ b/test/jdk/java/net/httpclient/ServerCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,16 +28,11 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Djdk.tls.acknowledgeCloseNotify=true ServerCloseTest + * @run junit/othervm -Djdk.tls.acknowledgeCloseNotify=true ServerCloseTest */ //* -Djdk.internal.httpclient.debug=true import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; @@ -70,18 +65,22 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class ServerCloseTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - DummyServer httpDummyServer; // HTTP/1.1 [ 2 servers ] - DummyServer httpsDummyServer; // HTTPS/1.1 - String httpDummy; - String httpsDummy; + private static DummyServer httpDummyServer; // HTTP/1.1 [ 2 servers ] + private static DummyServer httpsDummyServer; // HTTPS/1.1 + private static String httpDummy; + private static String httpsDummy; static final int ITERATION_COUNT = 3; // a shared executor helps reduce the amount of threads created by the test @@ -99,7 +98,7 @@ public class ServerCloseTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - private volatile HttpClient sharedClient; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -125,8 +124,8 @@ public class ServerCloseTest implements HttpServerAdapters { } } - @AfterClass - static final void printFailedTests() { + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { out.printf("%n%sCreated %d servers and %d clients%n", @@ -145,15 +144,14 @@ public class ServerCloseTest implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { httpDummy, httpsDummy, }; } - @DataProvider(name = "servers") - public Object[][] noThrows() { + public static Object[][] noThrows() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2][]; //Object[][] result = new Object[uris.length][]; @@ -192,7 +190,8 @@ public class ServerCloseTest implements HttpServerAdapters { final String ENCODED = "/01%252F03/"; - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("noThrows") public void testServerClose(String uri, boolean sameClient) { HttpClient client = null; out.printf("%n%s testServerClose(%s, %b)%n", now(), uri, sameClient); @@ -224,8 +223,8 @@ public class ServerCloseTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); // DummyServer @@ -240,8 +239,8 @@ public class ServerCloseTest implements HttpServerAdapters { httpsDummyServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { sharedClient = null; httpDummyServer.stopServer(); httpsDummyServer.stopServer(); @@ -324,7 +323,7 @@ public class ServerCloseTest implements HttpServerAdapters { // Read all headers until we find the empty line that // signals the end of all headers. String line = requestLine; - while (!line.equals("")) { + while (!line.isEmpty()) { System.out.println(now() + getName() + ": Reading header: " + (line = readLine(ccis))); headers.append(line).append("\r\n"); @@ -338,7 +337,7 @@ public class ServerCloseTest implements HttpServerAdapters { byte[] b = uri.toString().getBytes(UTF_8); if (index >= 0) { index = index + "content-length: ".length(); - String cl = headers.toString().substring(index); + String cl = headers.substring(index); StringTokenizer tk = new StringTokenizer(cl); int len = Integer.parseInt(tk.nextToken()); assert len < b.length * 2; diff --git a/test/jdk/java/net/httpclient/ShortResponseBody.java b/test/jdk/java/net/httpclient/ShortResponseBody.java index b4fd83585ee..5f931cd1ed3 100644 --- a/test/jdk/java/net/httpclient/ShortResponseBody.java +++ b/test/jdk/java/net/httpclient/ShortResponseBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -36,24 +36,16 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.Arrays; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLServerSocketFactory; @@ -64,28 +56,40 @@ import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class ShortResponseBody { - Server closeImmediatelyServer; - Server closeImmediatelyHttpsServer; - Server variableLengthServer; - Server variableLengthHttpsServer; - Server fixedLengthServer; + private static Server closeImmediatelyServer; + private static Server closeImmediatelyHttpsServer; + private static Server variableLengthServer; + private static Server variableLengthHttpsServer; + private static Server fixedLengthServer; - String httpURIClsImed; - String httpsURIClsImed; - String httpURIVarLen; - String httpsURIVarLen; - String httpURIFixLen; + private static String httpURIClsImed; + private static String httpsURIClsImed; + private static String httpURIVarLen; + private static String httpsURIVarLen; + private static String httpURIFixLen; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - SSLParameters sslParameters; - HttpClient client; - int numberOfRequests; + private static SSLParameters sslParameters; + protected static HttpClient client; + private static int numberOfRequests; static final int REQUESTS_PER_CLIENT = 10; // create new client every 10 requests static final long PAUSE_FOR_GC = 5; // 5ms to let gc work @@ -99,7 +103,7 @@ public abstract class ShortResponseBody { static final AtomicLong reqnb = new AtomicLong(); static final AtomicLong ids = new AtomicLong(); - final ThreadFactory factory = new ThreadFactory() { + private static final ThreadFactory factory = new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r, "HttpClient-Worker-" + ids.incrementAndGet()); @@ -107,21 +111,49 @@ public abstract class ShortResponseBody { return thread; } }; - final ExecutorService service = Executors.newCachedThreadPool(factory); - - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); + private static final ExecutorService service = Executors.newCachedThreadPool(factory); + static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); + static final long start = System.nanoTime(); + public static String now() { + long now = System.nanoTime() - start; + long secs = now / 1000_000_000; + long mill = (now % 1000_000_000) / 1000_000; + long nan = now % 1000_000; + return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - @BeforeMethod - void beforeMethod(ITestContext context) { + private static boolean stopAfterFirstFailure() { + return Boolean.getBoolean("jdk.internal.httpclient.debug"); + } + + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } + } + + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @BeforeEach + void beforeMethod() { if (client == null || numberOfRequests == REQUESTS_PER_CLIENT) { numberOfRequests = 0; out.println("--- new client"); @@ -134,22 +166,12 @@ public abstract class ShortResponseBody { } } numberOfRequests++; - if (context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); - } - } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @AfterAll + static void printFailedTests() { out.println("\n=========================\n"); try { - var FAILURES = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - if (FAILURES.isEmpty()) return; out.println("Failed tests: "); FAILURES.entrySet().forEach((e) -> { @@ -162,8 +184,7 @@ public abstract class ShortResponseBody { } } - @DataProvider(name = "sanity") - public Object[][] sanity() { + public static Object[][] sanity() { return new Object[][]{ { httpURIVarLen + "?length=all" }, { httpsURIVarLen + "?length=all" }, @@ -175,22 +196,22 @@ public abstract class ShortResponseBody { return url.replace("%reqnb%", String.valueOf(reqnb.incrementAndGet())); } - @Test(dataProvider = "sanity") + @ParameterizedTest + @MethodSource("sanity") void sanity(String url) throws Exception { url = uniqueURL(url); HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); out.println("Request: " + request); HttpResponse response = client.send(request, ofString()); String body = response.body(); - assertEquals(body, EXPECTED_RESPONSE_BODY); + assertEquals(EXPECTED_RESPONSE_BODY, body); client.sendAsync(request, ofString()) .thenApply(resp -> resp.body()) - .thenAccept(b -> assertEquals(b, EXPECTED_RESPONSE_BODY)) + .thenAccept(b -> assertEquals(EXPECTED_RESPONSE_BODY, b)) .join(); } - @DataProvider(name = "sanityBadRequest") - public Object[][] sanityBadRequest() { + public static Object[][] sanityBadRequest() { return new Object[][]{ { httpURIVarLen }, // no query string { httpsURIVarLen }, @@ -198,18 +219,18 @@ public abstract class ShortResponseBody { }; } - @Test(dataProvider = "sanityBadRequest") + @ParameterizedTest + @MethodSource("sanityBadRequest") void sanityBadRequest(String url) throws Exception { url = uniqueURL(url); HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); out.println("Request: " + request); HttpResponse response = client.send(request, ofString()); - assertEquals(response.statusCode(), 400); - assertEquals(response.body(), ""); + assertEquals(400, response.statusCode()); + assertEquals("", response.body()); } - @DataProvider(name = "uris") - public Object[][] variants(ITestContext context) { + public static Object[][] variants() { String[][] cases = new String[][] { // The length query string is the total number of bytes in the reply, // including headers, before the server closes the connection. The @@ -268,13 +289,6 @@ public abstract class ShortResponseBody { { httpsURIClsImed, "no bytes"}, }; - if (context.getFailedTests().size() > 0) { - // Shorten the log output by preventing useless - // skip traces to be printed for subsequent methods - // if one of the previous @Test method has failed. - return new Object[0][]; - } - return cases; } @@ -618,7 +632,7 @@ public abstract class ShortResponseBody { String response( ) { return RESPONSE; } } - /** A server that issues a, possibly-partial, chunked reply over SSL. */ + /** A server that issues a possibly-partial, chunked reply over SSL. */ static final class SSLVariableLengthServer extends PlainVariableLengthServer { SSLVariableLengthServer() throws IOException { super("SSLVariableLengthServer"); @@ -655,8 +669,8 @@ public abstract class ShortResponseBody { + server.getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { SSLContext.setDefault(sslContext); sslParameters = new SSLParameters(); @@ -682,8 +696,8 @@ public abstract class ShortResponseBody { + "/http1/fixed/req=%reqnb%/baz"; } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { closeImmediatelyServer.close(); closeImmediatelyHttpsServer.close(); variableLengthServer.close(); diff --git a/test/jdk/java/net/httpclient/ShortResponseBodyGet.java b/test/jdk/java/net/httpclient/ShortResponseBodyGet.java index 0a9041020a5..47be508c8c1 100644 --- a/test/jdk/java/net/httpclient/ShortResponseBodyGet.java +++ b/test/jdk/java/net/httpclient/ShortResponseBodyGet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +28,7 @@ * received before a socket exception or eof. * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext ShortResponseBody ShortResponseBodyGet - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=headers,errors,channel * ShortResponseBodyGet */ @@ -38,21 +38,24 @@ import java.net.URI; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.concurrent.ExecutionException; -import org.testng.annotations.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import static java.lang.System.out; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class ShortResponseBodyGet extends ShortResponseBody { - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testSynchronousGET(String urlp, String expectedMsg) throws Exception { - checkSkip(); String url = uniqueURL(urlp); HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); - out.println("Request: " + request); + out.printf("%n%s-- testSynchronousGET Request: %s%n%n", now(), request); try { HttpResponse response = client.send(request, ofString()); String body = response.body(); @@ -67,14 +70,14 @@ public class ShortResponseBodyGet extends ShortResponseBody { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsynchronousGET(String urlp, String expectedMsg) throws Exception { - checkSkip(); String url = uniqueURL(urlp); HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); - out.println("Request: " + request); + out.printf("%n%s-- testAsynchronousGET Request: %s%n%n", now(), request); try { HttpResponse response = client.sendAsync(request, ofString()).get(); String body = response.body(); diff --git a/test/jdk/java/net/httpclient/ShortResponseBodyPost.java b/test/jdk/java/net/httpclient/ShortResponseBodyPost.java index c72540c5990..60d2796b34f 100644 --- a/test/jdk/java/net/httpclient/ShortResponseBodyPost.java +++ b/test/jdk/java/net/httpclient/ShortResponseBodyPost.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +28,7 @@ * received before a socket exception or eof. * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext ShortResponseBody ShortResponseBodyPost - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=headers,errors,channel * -Djdk.internal.httpclient.debug=true * ShortResponseBodyPost @@ -42,10 +42,14 @@ import java.net.http.HttpResponse; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; -import org.testng.annotations.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import static java.lang.System.out; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; + public class ShortResponseBodyPost extends ShortResponseBody { // POST tests are racy in what may be received before writing may cause a @@ -56,16 +60,16 @@ public class ShortResponseBodyPost extends ShortResponseBody { List.of("no bytes", "status line", "header"); - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testSynchronousPOST(String urlp, String expectedMsg) throws Exception { - checkSkip(); String url = uniqueURL(urlp); HttpRequest request = HttpRequest.newBuilder(URI.create(url)) .POST(BodyPublishers.ofInputStream(() -> new InfiniteInputStream())) .build(); - out.println("Request: " + request); + out.printf("%n%s-- testSynchronousPOST Request: %s%n%n", now(), request); try { HttpResponse response = client.send(request, ofString()); String body = response.body(); @@ -86,16 +90,16 @@ public class ShortResponseBodyPost extends ShortResponseBody { } } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("variants") void testAsynchronousPOST(String urlp, String expectedMsg) throws Exception { - checkSkip(); String url = uniqueURL(urlp); HttpRequest request = HttpRequest.newBuilder(URI.create(url)) .POST(BodyPublishers.ofInputStream(() -> new InfiniteInputStream())) .build(); - out.println("Request: " + request); + out.printf("%n%s-- testAsynchronousPOST Request: %s%n%n", now(), request); try { HttpResponse response = client.sendAsync(request, ofString()).get(); String body = response.body(); diff --git a/test/jdk/java/net/httpclient/ShortResponseBodyPostWithRetry.java b/test/jdk/java/net/httpclient/ShortResponseBodyPostWithRetry.java index bd234690526..0ab404e556a 100644 --- a/test/jdk/java/net/httpclient/ShortResponseBodyPostWithRetry.java +++ b/test/jdk/java/net/httpclient/ShortResponseBodyPostWithRetry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext * @build ShortResponseBody ShortResponseBodyPost - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=headers,errors,channel * -Djdk.httpclient.enableAllMethodRetry * -Djdk.internal.httpclient.debug=true diff --git a/test/jdk/java/net/httpclient/ShutdownNow.java b/test/jdk/java/net/httpclient/ShutdownNow.java index 4f9eabbeb4d..e48667d2c69 100644 --- a/test/jdk/java/net/httpclient/ShutdownNow.java +++ b/test/jdk/java/net/httpclient/ShutdownNow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 @@ * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext * jdk.test.lib.RandomFactory jdk.test.lib.Utils * ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * ShutdownNow @@ -66,10 +66,6 @@ import javax.net.ssl.SSLContext; import jdk.test.lib.RandomFactory; import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; @@ -80,9 +76,14 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ShutdownNow implements HttpServerAdapters { @@ -92,25 +93,24 @@ public class ShutdownNow implements HttpServerAdapters { static final Random RANDOM = RandomFactory.getRandom(); private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) - HttpTestServer h3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String h2h3URI; - String h2h3Head; - String h3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer h2h3TestServer; // HTTP/3 ( h2 + h3 ) + private static HttpTestServer h3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String h2h3URI; + private static String h2h3Head; + private static String h3URI; static final String MESSAGE = "ShutdownNow message body"; static final int ITERATIONS = 3; - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { h2h3URI, HTTP_3, h2h3TestServer.h3DiscoveryConfig()}, { h3URI, HTTP_3, h3TestServer.h3DiscoveryConfig()}, @@ -122,7 +122,7 @@ public class ShutdownNow implements HttpServerAdapters { } static final AtomicLong requestCounter = new AtomicLong(); - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; static Throwable getCause(Throwable t) { while (t instanceof CompletionException || t instanceof ExecutionException) { @@ -137,7 +137,7 @@ public class ShutdownNow implements HttpServerAdapters { .HEAD() .build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } static boolean hasExpectedMessage(IOException io) { @@ -176,7 +176,8 @@ public class ShutdownNow implements HttpServerAdapters { throw new AssertionError(what + ": Unexpected exception: " + cause, cause); } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testConcurrent(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting concurrent (%s, %s, %s) ----%n%n", uriString, version, config); HttpClient client = newClientBuilderForH3() @@ -217,8 +218,8 @@ public class ShutdownNow implements HttpServerAdapters { var cf = responseCF.thenApply((response) -> { out.println(si + ": Got response: " + response); out.println(si + ": Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); return response; }).exceptionally((t) -> { Throwable cause = getCause(t); @@ -243,7 +244,8 @@ public class ShutdownNow implements HttpServerAdapters { } } - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void testSequential(String uriString, Version version, Http3DiscoveryMode config) throws Exception { out.printf("%n---- starting sequential (%s, %s, %s) ----%n%n", uriString, version, config); @@ -284,8 +286,8 @@ public class ShutdownNow implements HttpServerAdapters { responseCF.thenApply((response) -> { out.println(si + ": Got response: " + response); out.println(si + ": Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); return response; }).handle((r,t) -> { if (t != null) { @@ -318,8 +320,8 @@ public class ShutdownNow implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("\n**** Setup ****\n"); httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new ServerRequestHandler(), "/http1/exec/"); @@ -352,8 +354,8 @@ public class ShutdownNow implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { Thread.sleep(100); AssertionError fail = TRACKER.check(5000); try { diff --git a/test/jdk/java/net/httpclient/SpecialHeadersTest.java b/test/jdk/java/net/httpclient/SpecialHeadersTest.java index d33135dd4ce..d4d5f2a85e2 100644 --- a/test/jdk/java/net/httpclient/SpecialHeadersTest.java +++ b/test/jdk/java/net/httpclient/SpecialHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,35 +31,22 @@ * jdk.httpclient.test.lib.http2.Http2TestServer * jdk.test.lib.net.SimpleSSLContext * @requires (vm.compMode != "Xcomp") - * @run testng/othervm/timeout=480 + * @run junit/othervm/timeout=480 * -Djdk.httpclient.HttpClient.log=requests,headers,errors * SpecialHeadersTest - * @run testng/othervm/timeout=480 -Djdk.httpclient.allowRestrictedHeaders=Host + * @run junit/othervm/timeout=480 -Djdk.httpclient.allowRestrictedHeaders=Host * -Djdk.httpclient.HttpClient.log=requests,headers,errors * SpecialHeadersTest */ -import com.sun.net.httpserver.HttpServer; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; import jdk.internal.net.http.common.OperationTrackers.Tracker; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpHeaders; @@ -83,9 +70,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; -import java.util.stream.Collectors; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import static java.lang.System.err; import static java.lang.System.out; @@ -93,22 +78,37 @@ import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; +import static java.net.http.HttpOption.H3_DISCOVERY; +import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.nio.charset.StandardCharsets.US_ASCII; -import org.testng.Assert; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class SpecialHeadersTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String https3URI; static final String[][] headerNamesAndValues = new String[][]{ {"User-Agent: "}, @@ -132,8 +132,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { {"hoSt: mixed"} }; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { String prop = System.getProperty("jdk.httpclient.allowRestrictedHeaders"); boolean hostTest = prop != null && prop.equalsIgnoreCase("host"); final String[][] testInput = hostTest ? headerNamesAndValues1 : headerNamesAndValues; @@ -153,6 +152,9 @@ public class SpecialHeadersTest implements HttpServerAdapters { Arrays.asList(testInput).stream() .map(e -> new Object[] {https2URI, e[0], sameClient}) .forEach(list::add); + Arrays.asList(testInput).stream() + .map(e -> new Object[] {https3URI, e[0], sameClient}) + .forEach(list::add); } return list.stream().toArray(Object[][]::new); } @@ -173,8 +175,8 @@ public class SpecialHeadersTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - private volatile HttpClient sharedClient; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static volatile HttpClient sharedClient; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -209,38 +211,39 @@ public class SpecialHeadersTest implements HttpServerAdapters { } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - final AtomicReference skiptests = new AtomicReference<>(); - void checkSkip() { - var skip = skiptests.get(); - if (skip != null) throw skip; - } - static String name(ITestResult result) { - var params = result.getParameters(); - return result.getName() - + (params == null ? "()" : Arrays.toString(result.getParameters())); - } - - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - if (skiptests.get() == null) { - SkipException skip = new SkipException("some tests failed"); - skip.setStackTrace(new StackTraceElement[0]); - skiptests.compareAndSet(null, skip); + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); } } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); + } } - @AfterClass - static final void printFailedTests(ITestContext context) { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); - var failed = context.getFailedTests().getAllResults().stream() - .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); - FAILURES.putAll(failed); try { out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); @@ -260,7 +263,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { private HttpClient makeNewClient() { clientCount.incrementAndGet(); - return HttpClient.newBuilder() + return newClientBuilderForH3() .proxy(NO_PROXY) .executor(executor) .sslContext(sslContext) @@ -307,7 +310,8 @@ public class SpecialHeadersTest implements HttpServerAdapters { if (throwable instanceof Error e) throw e; } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uriString, String headerNameAndValue, boolean sameClient) @@ -335,6 +339,10 @@ public class SpecialHeadersTest implements HttpServerAdapters { } HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); + if (uriString.contains("/http3")) { + requestBuilder.version(HTTP_3); + requestBuilder.setOption(H3_DISCOVERY, HTTP_3_URI_ONLY); + } if (!useDefault) { requestBuilder.header(name, value); } @@ -343,7 +351,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { out.println("Got response: " + resp); out.println("Got body: " + resp.body()); - assertEquals(resp.statusCode(), 200, + assertEquals(200, resp.statusCode(), "Expected 200, got:" + resp.statusCode()); boolean isInitialRequest = i == 0; @@ -366,10 +374,10 @@ public class SpecialHeadersTest implements HttpServerAdapters { : resp.headers().firstValue("X-" + key).get(); out.println("Got X-" + key + ": " + resp.headers().allValues("X-" + key)); if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + assertEquals(value, receivedHeaderString); + assertEquals(List.of(value), resp.headers().allValues("X-" + key)); } else { - assertEquals(resp.headers().allValues("X-" + key).size(), 0); + assertEquals(0, resp.headers().allValues("X-" + key).size()); } } } catch (Throwable x) { @@ -389,7 +397,8 @@ public class SpecialHeadersTest implements HttpServerAdapters { } } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testHomeMadeIllegalHeader(String uriString, String headerNameAndValue, boolean sameClient) @@ -443,7 +452,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { try { HttpResponse response = client.send(req, BodyHandlers.ofString()); - Assert.fail("Unexpected reply: " + response); + Assertions.fail("Unexpected reply: " + response); } catch (IllegalArgumentException ee) { out.println("Got IAE as expected"); } @@ -465,7 +474,8 @@ public class SpecialHeadersTest implements HttpServerAdapters { - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uriString, String headerNameAndValue, boolean sameClient) throws Exception { @@ -490,6 +500,10 @@ public class SpecialHeadersTest implements HttpServerAdapters { } HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); + if (uriString.contains("/http3")) { + requestBuilder.version(HTTP_3); + requestBuilder.setOption(H3_DISCOVERY, HTTP_3_URI_ONLY); + } if (!useDefault) { requestBuilder.header(name, value); } @@ -504,7 +518,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { .thenApply(response -> { out.println("Got response: " + response); out.println("Got body: " + response.body()); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); return response; }) .thenAccept(resp -> { @@ -522,10 +536,10 @@ public class SpecialHeadersTest implements HttpServerAdapters { : resp.headers().firstValue("X-" + key).orElse(null); out.println("Got X-" + key + ": " + resp.headers().allValues("X-" + key)); if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + assertEquals(value, receivedHeaderString); + assertEquals(List.of(value), resp.headers().allValues("X-" + key)); } else { - assertEquals(resp.headers().allValues("X-" + key).size(), 1); + assertEquals(1, resp.headers().allValues("X-" + key).size()); } } }) @@ -552,8 +566,8 @@ public class SpecialHeadersTest implements HttpServerAdapters { + server.getAddress().getPort(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { out.println("--- Starting setup " + now()); HttpTestHandler handler = new HttpUriStringHandler(); @@ -573,14 +587,19 @@ public class SpecialHeadersTest implements HttpServerAdapters { https2TestServer.addHandler(handler, "/https2"); https2URI = "https://" + https2TestServer.serverAuthority() + "/https2"; + http3TestServer = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); + http3TestServer.addHandler(handler, "/http3"); + https3URI = "https://" + http3TestServer.serverAuthority() + "/http3"; + httpTestServer.start(); httpsTestServer.start(); http2TestServer.start(); https2TestServer.start(); + http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { out.println("\n--- Teardown " + now()); HttpClient shared = sharedClient; String sharedClientName = @@ -595,6 +614,7 @@ public class SpecialHeadersTest implements HttpServerAdapters { httpsTestServer.stop(); http2TestServer.stop(); https2TestServer.stop(); + http3TestServer.start(); executor.shutdown(); } finally { if (fail != null) { diff --git a/test/jdk/java/net/httpclient/StreamCloseTest.java b/test/jdk/java/net/httpclient/StreamCloseTest.java index fcb00188581..7b228e69de2 100644 --- a/test/jdk/java/net/httpclient/StreamCloseTest.java +++ b/test/jdk/java/net/httpclient/StreamCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, NTT DATA. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +30,7 @@ * @library /test/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm StreamCloseTest + * @run junit/othervm StreamCloseTest */ import java.io.InputStream; @@ -44,10 +44,10 @@ import java.net.http.HttpResponse.BodyHandlers; import java.net.URI; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import org.testng.Assert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class StreamCloseTest { @@ -82,8 +82,8 @@ public class StreamCloseTest { private static HttpServerAdapters.HttpTestServer httpTestServer; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpServerAdapters.HttpTestServer.create(Version.HTTP_1_1); httpTestServer.addHandler(new HttpServerAdapters.HttpTestEchoHandler(), "/"); URI uri = URI.create("http://" + httpTestServer.serverAuthority() + "/"); @@ -96,8 +96,8 @@ public class StreamCloseTest { requestBuilder = HttpRequest.newBuilder(uri); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); } @@ -108,7 +108,7 @@ public class StreamCloseTest { .POST(BodyPublishers.ofInputStream(() -> in)) .build(); client.send(request, BodyHandlers.discarding()); - Assert.assertTrue(in.closeCalled, "InputStream was not closed!"); + Assertions.assertTrue(in.closeCalled, "InputStream was not closed!"); } @Test @@ -120,9 +120,9 @@ public class StreamCloseTest { try { client.send(request, BodyHandlers.discarding()); } catch (IOException e) { // expected - Assert.assertTrue(in.closeCalled, "InputStream was not closed!"); + Assertions.assertTrue(in.closeCalled, "InputStream was not closed!"); return; } - Assert.fail("IOException should be occurred!"); + Assertions.fail("IOException should be occurred!"); } } diff --git a/test/jdk/java/net/httpclient/StreamingBody.java b/test/jdk/java/net/httpclient/StreamingBody.java index 3fb4f29208e..d0577596038 100644 --- a/test/jdk/java/net/httpclient/StreamingBody.java +++ b/test/jdk/java/net/httpclient/StreamingBody.java @@ -72,20 +72,19 @@ import org.junit.jupiter.api.extension.TestWatcher; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class StreamingBody implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; static final AtomicLong clientCount = new AtomicLong(); static final AtomicLong serverCount = new AtomicLong(); @@ -186,7 +185,7 @@ public class StreamingBody implements HttpServerAdapters { static final String MESSAGE = "StreamingBody message body"; static final int ITERATIONS = 100; - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { http3URI, }, { httpURI, }, @@ -253,7 +252,7 @@ public class StreamingBody implements HttpServerAdapters { // -- Infrastructure @BeforeAll - public void setup() throws Exception { + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new MessageHandler(), "/http1/streamingbody/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/streamingbody/w"; @@ -290,7 +289,7 @@ public class StreamingBody implements HttpServerAdapters { } @AfterAll - public void teardown() throws Exception { + public static void teardown() throws Exception { try { httpTestServer.stop(); httpsTestServer.stop(); @@ -303,7 +302,7 @@ public class StreamingBody implements HttpServerAdapters { } } - static final void printFailedTests() { + static void printFailedTests() { out.println("\n========================="); try { out.printf("%n%sCreated %s servers and %s clients%n", diff --git a/test/jdk/java/net/httpclient/SubscriberAPIExceptions.java b/test/jdk/java/net/httpclient/SubscriberAPIExceptions.java index bf0f7c0bda7..93f55d066e9 100644 --- a/test/jdk/java/net/httpclient/SubscriberAPIExceptions.java +++ b/test/jdk/java/net/httpclient/SubscriberAPIExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,26 +36,26 @@ import java.net.http.HttpResponse.BodySubscriber; import java.net.http.HttpResponse.BodySubscribers; import java.util.function.Function; -import org.testng.annotations.Test; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE; import static java.nio.file.StandardOpenOption.WRITE; import static java.nio.file.StandardOpenOption.READ; -import static org.testng.Assert.assertThrows; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; /* * @test * @summary Basic tests for API specified exceptions from Handler, * and Subscriber convenience static factory methods. - * @run testng SubscriberAPIExceptions + * @run junit SubscriberAPIExceptions */ public class SubscriberAPIExceptions { static final Class NPE = NullPointerException.class; static final Class IAE = IllegalArgumentException.class; - static final Class IOB = IndexOutOfBoundsException.class; @Test public void handlerAPIExceptions() throws Exception { diff --git a/test/jdk/java/net/httpclient/TEST.properties b/test/jdk/java/net/httpclient/TEST.properties index b79f7113952..77705d2f4f1 100644 --- a/test/jdk/java/net/httpclient/TEST.properties +++ b/test/jdk/java/net/httpclient/TEST.properties @@ -20,3 +20,7 @@ modules=java.base/jdk.internal.util \ java.security.jgss \ java.logging \ jdk.httpserver + +# Prevent TestNG-based tests +disallowedActions=testng + diff --git a/test/jdk/java/net/httpclient/TestKitTest.java b/test/jdk/java/net/httpclient/TestKitTest.java index 25f39d90305..2aba794426f 100644 --- a/test/jdk/java/net/httpclient/TestKitTest.java +++ b/test/jdk/java/net/httpclient/TestKitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,6 @@ * questions. */ -import org.testng.annotations.Test; import java.io.IOException; import java.util.ArrayList; @@ -33,15 +32,16 @@ import java.util.LinkedList; import java.util.Map; import java.util.Set; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; /* * @test * @compile TestKit.java - * @run testng TestKitTest + * @run junit TestKitTest */ public final class TestKitTest { @@ -50,15 +50,14 @@ public final class TestKitTest { Integer integer = TestKit.assertNotThrows( () -> TestKit.assertNotThrows(() -> 1) ); - assertEquals(integer, Integer.valueOf(1)); + assertEquals(Integer.valueOf(1), integer); RuntimeException re = TestKit.assertThrows( RuntimeException.class, () -> TestKit.assertNotThrows(() -> { throw new IOException(); }) ); - assertEquals(re.getMessage(), - "Expected to run normally, but threw " - + "java.io.IOException"); + assertEquals("Expected to run normally, but threw " + + "java.io.IOException", re.getMessage()); TestKit.assertNotThrows( () -> TestKit.assertNotThrows(() -> { }) @@ -68,9 +67,8 @@ public final class TestKitTest { RuntimeException.class, () -> TestKit.assertNotThrows((TestKit.ThrowingProcedure) () -> { throw new IOException(); }) ); - assertEquals(re.getMessage(), - "Expected to run normally, but threw " - + "java.io.IOException"); + assertEquals("Expected to run normally, but threw " + + "java.io.IOException", re.getMessage()); } @Test @@ -87,13 +85,13 @@ public final class TestKitTest { () -> TestKit.assertThrows(IOException.class, null) ); assertNotNull(npe); - assertEquals(npe.getMessage(), "code"); + assertEquals("code", npe.getMessage()); npe = TestKit.assertThrows( NullPointerException.class, () -> TestKit.assertThrows(null, () -> { }) ); - assertEquals(npe.getMessage(), "clazz"); + assertEquals("clazz", npe.getMessage()); npe = TestKit.assertThrows( NullPointerException.class, @@ -101,16 +99,15 @@ public final class TestKitTest { ); assertNotNull(npe); assertNull(npe.getMessage()); - assertEquals(npe.getClass(), NullPointerException.class); + assertEquals(NullPointerException.class, npe.getClass()); RuntimeException re = TestKit.assertThrows( RuntimeException.class, () -> TestKit.assertThrows(NullPointerException.class, () -> { }) ); - assertEquals(re.getClass(), RuntimeException.class); - assertEquals(re.getMessage(), - "Expected to catch an exception of type " - + "java.lang.NullPointerException, but caught nothing"); + assertEquals(RuntimeException.class, re.getClass()); + assertEquals("Expected to catch an exception of type " + + "java.lang.NullPointerException, but caught nothing", re.getMessage()); re = TestKit.assertThrows( RuntimeException.class, @@ -118,7 +115,7 @@ public final class TestKitTest { ); assertNotNull(re); assertNull(re.getMessage()); - assertEquals(re.getClass(), NullPointerException.class); + assertEquals(NullPointerException.class, re.getClass()); re = TestKit.assertThrows( RuntimeException.class, @@ -127,10 +124,9 @@ public final class TestKitTest { () -> { throw new IndexOutOfBoundsException(); } )); assertNotNull(re); - assertEquals(re.getClass(), RuntimeException.class); - assertEquals(re.getMessage(), - "Expected to catch an exception of type java.util.IllegalFormatException" - + ", but caught java.lang.IndexOutOfBoundsException"); + assertEquals(RuntimeException.class, re.getClass()); + assertEquals("Expected to catch an exception of type java.util.IllegalFormatException" + + ", but caught java.lang.IndexOutOfBoundsException", re.getMessage()); } @Test diff --git a/test/jdk/java/net/httpclient/TlsContextTest.java b/test/jdk/java/net/httpclient/TlsContextTest.java index 8a5cc99aad3..95cb501d24c 100644 --- a/test/jdk/java/net/httpclient/TlsContextTest.java +++ b/test/jdk/java/net/httpclient/TlsContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -36,19 +36,22 @@ import javax.net.ssl.SSLParameters; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpResponse.BodyHandlers.ofString; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; + import jdk.test.lib.security.SecurityUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + /* * @test * @bug 8239594 8371887 @@ -56,7 +59,7 @@ import jdk.test.lib.security.SecurityUtils; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext TlsContextTest * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Dtest.requiresHost=true + * @run junit/othervm -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.disableHostnameVerification * -Djdk.internal.httpclient.debug=false @@ -67,11 +70,11 @@ public class TlsContextTest implements HttpServerAdapters { static HttpTestServer https2Server; static String https2URI; - SSLContext server; + static SSLContext server; final static Integer ITERATIONS = 3; - @BeforeTest - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { // Re-enable TLSv1 and TLSv1.1 since test depends on them SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); @@ -86,8 +89,7 @@ public class TlsContextTest implements HttpServerAdapters { https2URI = "https://" + https2Server.serverAuthority() + "/server/"; } - @DataProvider(name = "scenarios") - public Object[][] scenarios() throws Exception { + public static Object[][] scenarios() throws Exception { return new Object[][]{ { SimpleSSLContext.findSSLContext("TLS"), HTTP_2, "TLSv1.3" }, { SimpleSSLContext.findSSLContext("TLSv1.2"), HTTP_2, "TLSv1.2" }, @@ -102,7 +104,8 @@ public class TlsContextTest implements HttpServerAdapters { /** * Tests various scenarios between client and server tls handshake with valid http */ - @Test(dataProvider = "scenarios") + @ParameterizedTest + @MethodSource("scenarios") public void testVersionProtocolsNoParams(SSLContext context, Version version, String expectedProtocol) throws Exception { @@ -113,7 +116,8 @@ public class TlsContextTest implements HttpServerAdapters { * Tests various scenarios between client and server tls handshake with valid http, * but with empty SSLParameters */ - @Test(dataProvider = "scenarios") + @ParameterizedTest + @MethodSource("scenarios") public void testVersionProtocolsEmptyParams(SSLContext context, Version version, String expectedProtocol) throws Exception { @@ -150,24 +154,24 @@ public class TlsContextTest implements HttpServerAdapters { private void testAllProtocols(HttpResponse response, String expectedProtocol, - Version clientVersion) throws Exception { + Version clientVersion) { String protocol = response.sslSession().get().getProtocol(); int statusCode = response.statusCode(); Version version = response.version(); out.println("Got Body " + response.body()); out.println("The protocol negotiated is :" + protocol); - assertEquals(statusCode, 200); - assertEquals(protocol, expectedProtocol); + assertEquals(200, statusCode); + assertEquals(expectedProtocol, protocol); if (clientVersion == HTTP_3) { - assertEquals(version, expectedProtocol.equals("TLSv1.1") ? HTTP_1_1 : - expectedProtocol.equals("TLSv1.2") ? HTTP_2 : HTTP_3); + assertEquals(expectedProtocol.equals("TLSv1.1") ? HTTP_1_1 : + expectedProtocol.equals("TLSv1.2") ? HTTP_2 : HTTP_3, version); } else { - assertEquals(version, expectedProtocol.equals("TLSv1.1") ? HTTP_1_1 : HTTP_2); + assertEquals(expectedProtocol.equals("TLSv1.1") ? HTTP_1_1 : HTTP_2, version); } } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { https2Server.stop(); } diff --git a/test/jdk/java/net/httpclient/UnauthorizedTest.java b/test/jdk/java/net/httpclient/UnauthorizedTest.java index 628130f9ffc..1c72bac6cc9 100644 --- a/test/jdk/java/net/httpclient/UnauthorizedTest.java +++ b/test/jdk/java/net/httpclient/UnauthorizedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,16 +32,12 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext ReferenceTracker - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=headers * UnauthorizedTest */ import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -65,24 +61,29 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class UnauthorizedTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; - HttpClient authClient; - HttpClient noAuthClient; + private static HttpTestServer httpTestServer; // HTTP/1.1 + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; + private static HttpClient authClient; + private static HttpClient noAuthClient; static final int ITERATIONS = 3; @@ -100,8 +101,7 @@ public class UnauthorizedTest implements HttpServerAdapters { return new WeakReference<>(client); } - @DataProvider(name = "all") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { http3URI + "/server", UNAUTHORIZED, true, ref(authClient)}, { http3URI + "/server", UNAUTHORIZED, false, ref(authClient)}, @@ -144,8 +144,6 @@ public class UnauthorizedTest implements HttpServerAdapters { }; } - static final AtomicLong requestCounter = new AtomicLong(); - static final Authenticator authenticator = new Authenticator() { }; @@ -158,7 +156,8 @@ public class UnauthorizedTest implements HttpServerAdapters { return builder; } - @Test(dataProvider = "all") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, int code, boolean async, WeakReference clientRef) throws Throwable { HttpClient client = clientRef.get(); out.printf("%n---- starting (%s, %d, %s, %s) ----%n", @@ -195,9 +194,8 @@ public class UnauthorizedTest implements HttpServerAdapters { } out.println(" Got response: " + response); - assertEquals(response.statusCode(), code); - assertEquals(response.body(), - (code == UNAUTHORIZED ? "WWW-" : "Proxy-") + MESSAGE); + assertEquals(code, response.statusCode()); + assertEquals( (code == UNAUTHORIZED ? "WWW-" : "Proxy-") + MESSAGE, response.body()); if (shouldThrow) { throw new RuntimeException("Expected IOException not thrown."); } @@ -205,8 +203,8 @@ public class UnauthorizedTest implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new UnauthorizedHandler(), "/http1/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1"; @@ -225,13 +223,13 @@ public class UnauthorizedTest implements HttpServerAdapters { http3TestServer.addHandler(new UnauthorizedHandler(), "/http3/"); http3URI = "https://" + http3TestServer.serverAuthority() + "/http3"; - authClient = newClientBuilderForH3() + authClient = HttpServerAdapters.createClientBuilderForH3() .proxy(HttpClient.Builder.NO_PROXY) .sslContext(sslContext) .authenticator(authenticator) .build(); - noAuthClient = newClientBuilderForH3() + noAuthClient = HttpServerAdapters.createClientBuilderForH3() .proxy(HttpClient.Builder.NO_PROXY) .sslContext(sslContext) .build(); @@ -243,8 +241,8 @@ public class UnauthorizedTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { // authClient.close(); // noAuthClient.close(); var TRACKER = ReferenceTracker.INSTANCE; diff --git a/test/jdk/java/net/httpclient/UserAuthWithAuthenticator.java b/test/jdk/java/net/httpclient/UserAuthWithAuthenticator.java index 90df367a619..6062fcd9448 100644 --- a/test/jdk/java/net/httpclient/UserAuthWithAuthenticator.java +++ b/test/jdk/java/net/httpclient/UserAuthWithAuthenticator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,17 +21,33 @@ * questions. */ -import java.io.*; -import java.net.*; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Authenticator; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.URI; +import java.net.URISyntaxException; import java.net.http.HttpClient; +import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; -import java.net.http.HttpOption.Http3DiscoveryMode; import java.net.http.HttpResponse; -import javax.net.ssl.*; +import java.util.LinkedList; +import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.regex.*; -import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.net.ssl.SSLContext; + import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; import jdk.httpclient.test.lib.common.HttpServerAdapters; @@ -42,6 +58,8 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import com.sun.net.httpserver.BasicAuthenticator; import org.junit.jupiter.api.Test; +import static java.net.http.HttpOption.H3_DISCOVERY; +import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.nio.charset.StandardCharsets.US_ASCII; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -119,7 +137,7 @@ class UserAuthWithAuthenticator { private static void h3Test(final boolean useHeader, boolean rightPassword) throws Exception { SSLContext sslContext = SimpleSSLContext.findSSLContext(); try (ExecutorService executor = Executors.newCachedThreadPool(); - HttpTestServer server = HttpTestServer.create(Http3DiscoveryMode.HTTP_3_URI_ONLY, sslContext, executor); + HttpTestServer server = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext, executor); HttpClient client = HttpServerAdapters.createClientBuilderForH3() .sslContext(sslContext) .executor(executor) @@ -164,11 +182,18 @@ class UserAuthWithAuthenticator { .build(); var authHeaderValue = authHeaderValue("user", rightPassword ? "pwd" : "wrongPwd"); - HttpRequest req = HttpRequest.newBuilder(uri) + HttpRequest.Builder reqBuilder = HttpRequest.newBuilder(uri) .version(version) .header(useHeader ? "Authorization" : "X-Ignore", authHeaderValue) - .GET() - .build(); + .GET(); + if (version == Version.HTTP_3) { + // we should not attempt to default to TCP since our server is HTTP_3_URI_ONLY + // setting the option on the request also has the effect of telling + // the client that it can use the full HTTP/3 timeout, since the server + // is known to support HTTP/3 + reqBuilder.setOption(H3_DISCOVERY, HTTP_3_URI_ONLY); + } + HttpRequest req = reqBuilder.build(); HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); var sa = (ServerAuth) client.authenticator().orElseThrow(); diff --git a/test/jdk/java/net/httpclient/UserCookieTest.java b/test/jdk/java/net/httpclient/UserCookieTest.java index 3d202914050..f49f44c157c 100644 --- a/test/jdk/java/net/httpclient/UserCookieTest.java +++ b/test/jdk/java/net/httpclient/UserCookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +28,7 @@ * server-cookies for HTTP/2 vs HTTP/1.1 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.tls.acknowledgeCloseNotify=true * -Djdk.httpclient.HttpClient.log=trace,headers,requests * UserCookieTest @@ -68,10 +68,6 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; @@ -80,25 +76,30 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class UserCookieTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer httpTestServer; // HTTP/1.1 [ 7 servers ] - HttpTestServer httpsTestServer; // HTTPS/1.1 - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - HttpTestServer http3TestServer; // HTTP/3 ( h3 ) - DummyServer httpDummyServer; - DummyServer httpsDummyServer; - String httpURI; - String httpsURI; - String http2URI; - String https2URI; - String http3URI; - String httpDummy; - String httpsDummy; + private static HttpTestServer httpTestServer; // HTTP/1.1 [ 7 servers ] + private static HttpTestServer httpsTestServer; // HTTPS/1.1 + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 ) + private static DummyServer httpDummyServer; + private static DummyServer httpsDummyServer; + private static String httpURI; + private static String httpsURI; + private static String http2URI; + private static String https2URI; + private static String http3URI; + private static String httpDummy; + private static String httpsDummy; static final String MESSAGE = "Basic CookieHeaderTest message body"; static final int ITERATIONS = 3; @@ -111,8 +112,7 @@ public class UserCookieTest implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - @DataProvider(name = "positive") - public Object[][] positive() { + public static Object[][] positive() { return new Object[][] { { http3URI, HTTP_3 }, { httpURI, HTTP_1_1 }, @@ -130,7 +130,8 @@ public class UserCookieTest implements HttpServerAdapters { static final AtomicLong requestCounter = new AtomicLong(); - @Test(dataProvider = "positive") + @ParameterizedTest + @MethodSource("positive") void test(String uriString, HttpClient.Version version) throws Exception { out.printf("%n---- starting (%s) ----%n", uriString); ConcurrentHashMap> cookieHeaders @@ -178,12 +179,13 @@ public class UserCookieTest implements HttpServerAdapters { out.println(" Got response: " + response); out.println(" Got body Path: " + response.body()); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MESSAGE); - assertEquals(response.headers().allValues("X-Request-Cookie"), - expectedCookies.stream() - .filter(s -> !s.startsWith("LOC")) - .toList()); + assertEquals(200, response.statusCode()); + assertEquals(MESSAGE, response.body()); + List expectedCookieList = expectedCookies.stream() + .filter(s -> !s.startsWith("LOC")).toList(); + List actualCookieList = response.headers() + .allValues("X-Request-Cookie"); + assertEquals(expectedCookieList, actualCookieList); requestBuilder = HttpRequest.newBuilder(uri) .header("X-uuid", "uuid-" + requestCounter.incrementAndGet()) .header("Cookie", userCookie); @@ -200,8 +202,8 @@ public class UserCookieTest implements HttpServerAdapters { // -- Infrastructure - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { httpTestServer = HttpTestServer.create(HTTP_1_1); httpTestServer.addHandler(new CookieValidationHandler(), "/http1/cookie/"); httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/cookie/retry"; @@ -236,8 +238,8 @@ public class UserCookieTest implements HttpServerAdapters { httpsDummyServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); @@ -575,6 +577,5 @@ public class UserCookieTest implements HttpServerAdapters { return new DummyServer(ss, true); } - } } diff --git a/test/jdk/java/net/httpclient/http2/ErrorTest.java b/test/jdk/java/net/httpclient/http2/ErrorTest.java index 6b36529b38f..0f3bafa571d 100644 --- a/test/jdk/java/net/httpclient/http2/ErrorTest.java +++ b/test/jdk/java/net/httpclient/http2/ErrorTest.java @@ -45,7 +45,7 @@ * java.net.http/jdk.internal.net.http.qpack.writers * java.security.jgss * @modules java.base/jdk.internal.util - * @run testng/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all ErrorTest + * @run junit/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all ErrorTest * @summary check exception thrown when bad TLS parameters selected */ @@ -67,7 +67,7 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.test.lib.net.SimpleSSLContext; import static java.net.http.HttpClient.Version.HTTP_2; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * When selecting an unacceptable cipher suite the TLS handshake will fail. diff --git a/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java b/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java index 2378b0b6982..d788d39b441 100644 --- a/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java +++ b/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java @@ -30,7 +30,7 @@ * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors FixedThreadPoolTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors FixedThreadPoolTest */ import java.net.*; @@ -51,7 +51,7 @@ import static jdk.test.lib.Asserts.assertFileContentsEqual; import static jdk.test.lib.Utils.createTempFile; import static jdk.test.lib.Utils.createTempFileOfSize; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class FixedThreadPoolTest implements HttpServerAdapters { @@ -92,7 +92,7 @@ public class FixedThreadPoolTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(false); diff --git a/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java b/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java index 85d4012494a..7adfd57319c 100644 --- a/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java +++ b/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java @@ -38,7 +38,7 @@ import jdk.test.lib.net.SimpleSSLContext; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_2; @@ -166,21 +166,21 @@ class H2SelectorVTTest implements HttpServerAdapters { final HttpRequest req1 = reqBuilder.copy().GET().build(); System.out.println("\nIssuing request: " + req1); final HttpResponse resp1 = client.send(req1, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp1.statusCode(), "unexpected response code for GET request"); + assertEquals(200, resp1.statusCode(), "unexpected response code for GET request"); assertSelectorThread(client); // POST final HttpRequest req2 = reqBuilder.copy().POST(BodyPublishers.ofString("foo")).build(); System.out.println("\nIssuing request: " + req2); final HttpResponse resp2 = client.send(req2, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp2.statusCode(), "unexpected response code for POST request"); + assertEquals(200, resp2.statusCode(), "unexpected response code for POST request"); assertSelectorThread(client); // HEAD final HttpRequest req3 = reqBuilder.copy().HEAD().build(); System.out.println("\nIssuing request: " + req3); final HttpResponse resp3 = client.send(req3, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp3.statusCode(), "unexpected response code for HEAD request"); + assertEquals(200, resp3.statusCode(), "unexpected response code for HEAD request"); assertSelectorThread(client); } } @@ -219,6 +219,6 @@ class H2SelectorVTTest implements HttpServerAdapters { msg = "%s not found in %s".formatted(name, threads); System.out.printf("%s: %s%n", status, msg); } - Assertions.assertEquals(!isTCPSelectorThreadVirtual(), found, msg); + assertEquals(!isTCPSelectorThreadVirtual(), found, msg); } } diff --git a/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java b/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java index c75a62d0f42..5bcaf95c6fc 100644 --- a/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java +++ b/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * ImplicitPushCancel @@ -51,15 +51,16 @@ import java.util.concurrent.ConcurrentMap; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ImplicitPushCancel { - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -72,11 +73,11 @@ public class ImplicitPushCancel { ); static final String MAIN_RESPONSE_BODY = "the main response body"; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = new Http2TestServer(false, 0); Http2Handler handler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); @@ -87,13 +88,13 @@ public class ImplicitPushCancel { uri = new URI("http://localhost:" + port + "/foo/a/b/c"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static final HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); return response; } @@ -128,11 +129,11 @@ public class ImplicitPushCancel { promises.entrySet().stream().forEach(entry -> { HttpRequest request = entry.getKey(); HttpResponse response = entry.getValue().join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } } ); diff --git a/test/jdk/java/net/httpclient/http2/NoBodyTest.java b/test/jdk/java/net/httpclient/http2/NoBodyTest.java index 3d30c54654a..2459c8eba4b 100644 --- a/test/jdk/java/net/httpclient/http2/NoBodyTest.java +++ b/test/jdk/java/net/httpclient/http2/NoBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8087112 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * NoBodyTest */ @@ -47,10 +47,10 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; -@Test +import org.junit.jupiter.api.Test; + public class NoBodyTest { static int httpPort, httpsPort; static Http2TestServer httpServer, httpsServer; @@ -86,7 +86,7 @@ public class NoBodyTest { } @Test - public static void runtest() throws Exception { + public void runtest() throws Exception { try { initialize(); warmup(false); diff --git a/test/jdk/java/net/httpclient/http2/PostPutTest.java b/test/jdk/java/net/httpclient/http2/PostPutTest.java index 89b192f6171..84e86b556ca 100644 --- a/test/jdk/java/net/httpclient/http2/PostPutTest.java +++ b/test/jdk/java/net/httpclient/http2/PostPutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +28,7 @@ * does not process any data. The client should read all data from the server and close the connection. * @library /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=50 -Djdk.httpclient.HttpClient.log=all + * @run junit/othervm/timeout=50 -Djdk.httpclient.HttpClient.log=all * PostPutTest */ @@ -36,11 +36,6 @@ import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.io.PrintStream; import java.net.URI; @@ -51,19 +46,24 @@ import java.net.http.HttpResponse; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpRequest.BodyPublishers.ofByteArray; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PostPutTest { - Http2TestServer http2TestServer; - URI warmupURI, testHandlerBasicURI, testHandlerCloseBosURI, testHandleNegativeContentLengthURI; + private static Http2TestServer http2TestServer; + private static URI warmupURI, testHandlerBasicURI, testHandlerCloseBosURI, testHandleNegativeContentLengthURI; static PrintStream testLog = System.err; // As per jdk.internal.net.http.WindowController.DEFAULT_INITIAL_WINDOW_SIZE - final int DEFAULT_INITIAL_WINDOW_SIZE = (64 * 1024) - 1; + private static final int DEFAULT_INITIAL_WINDOW_SIZE = (64 * 1024) - 1; // Add on a small amount of arbitrary bytes to see if client hangs when receiving RST_STREAM - byte[] data = new byte[DEFAULT_INITIAL_WINDOW_SIZE + 10]; + private static byte[] data = new byte[DEFAULT_INITIAL_WINDOW_SIZE + 10]; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { http2TestServer = new Http2TestServer(false, 0); http2TestServer.addHandler(new WarmupHandler(), "/Warmup"); http2TestServer.addHandler(new TestHandlerBasic(), "/TestHandlerBasic"); @@ -81,15 +81,14 @@ public class PostPutTest { testLog.println("PostPutTest.setup(): testHandleNegativeContentLengthURI: " + testHandleNegativeContentLengthURI); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { testLog.println("PostPutTest.teardown(): Stopping server"); http2TestServer.stop(); data = null; } - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { HttpRequest over64kPost, over64kPut, over64kPostCloseBos, over64kPutCloseBos, over64kPostNegativeContentLength, over64kPutNegativeContentLength; over64kPost = HttpRequest.newBuilder().version(HTTP_2).POST(ofByteArray(data)).uri(testHandlerBasicURI).build(); over64kPut = HttpRequest.newBuilder().version(HTTP_2).PUT(ofByteArray(data)).uri(testHandlerBasicURI).build(); @@ -117,7 +116,8 @@ public class PostPutTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testOver64kPUT(HttpRequest req, String testMessage) { testLog.println("PostPutTest: Performing test: " + testMessage); HttpClient hc = HttpClient.newBuilder().version(HTTP_2).build(); diff --git a/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java b/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java index e9c6447e600..2d5b5dd4f4e 100644 --- a/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java +++ b/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,9 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.http2.BodyOutputStream * jdk.httpclient.test.lib.http2.OutgoingPushPromise - * @run testng/othervm PushPromiseContinuation + * @run junit/othervm PushPromiseContinuation */ - import javax.net.ssl.SSLSession; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -68,14 +67,13 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.ContinuationFrame; import jdk.internal.net.http.frame.HeaderFrame; -import org.testng.TestException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class PushPromiseContinuation { @@ -85,8 +83,8 @@ public class PushPromiseContinuation { static volatile int continuationCount; static final String mainPromiseBody = "Main Promise Body"; static final String mainResponseBody = "Main Response Body"; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; // Set up simple client-side push promise handler ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); @@ -95,13 +93,13 @@ public class PushPromiseContinuation { pushPromiseMap.put(pushRequest, acceptor.apply(s)); }; - @BeforeMethod + @BeforeEach public void beforeMethod() { pushPromiseMap = new ConcurrentHashMap<>(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = new Http2TestServer(false, 0); server.addHandler(new ServerPushHandler(), "/"); @@ -115,9 +113,8 @@ public class PushPromiseContinuation { uri = new URI("http://localhost:" + port + "/"); } - @AfterTest - public void teardown() { - pushPromiseMap = null; + @AfterAll + public static void teardown() { server.stop(); } @@ -195,29 +192,29 @@ public class PushPromiseContinuation { CompletableFuture> cf = client.sendAsync(hreq, HttpResponse.BodyHandlers.ofString(UTF_8), pph); - CompletionException t = expectThrows(CompletionException.class, () -> cf.join()); - assertEquals(t.getCause().getClass(), ProtocolException.class, + CompletionException t = assertThrows(CompletionException.class, () -> cf.join()); + assertEquals(ProtocolException.class, t.getCause().getClass(), "Expected a ProtocolException but got " + t.getCause()); System.err.println("Client received the following expected exception: " + t.getCause()); faultyServer.stop(); } private void verify(HttpResponse resp) { - assertEquals(resp.statusCode(), 200); - assertEquals(resp.body(), mainResponseBody); + assertEquals(200, resp.statusCode()); + assertEquals(mainResponseBody, resp.body()); if (pushPromiseMap.size() > 1) { System.err.println(pushPromiseMap.entrySet()); - throw new TestException("Results map size is greater than 1"); + fail("Results map size is greater than 1"); } else { // This will only iterate once for (HttpRequest r : pushPromiseMap.keySet()) { HttpResponse serverPushResp = pushPromiseMap.get(r).join(); // Received headers should be the same as the combined PushPromise // frame headers combined with the Continuation frame headers - assertEquals(testHeaders, r.headers()); + assertEquals(r.headers(), testHeaders); // Check status code and push promise body are as expected - assertEquals(serverPushResp.statusCode(), 200); - assertEquals(serverPushResp.body(), mainPromiseBody); + assertEquals(200, serverPushResp.statusCode()); + assertEquals(mainPromiseBody, serverPushResp.body()); } } } diff --git a/test/jdk/java/net/httpclient/http2/RedirectTest.java b/test/jdk/java/net/httpclient/http2/RedirectTest.java index e2acd807bd5..201b56513f6 100644 --- a/test/jdk/java/net/httpclient/http2/RedirectTest.java +++ b/test/jdk/java/net/httpclient/http2/RedirectTest.java @@ -30,7 +30,7 @@ * jdk.httpclient.test.lib.http2.Http2RedirectHandler * jdk.test.lib.Asserts * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=frames,ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * RedirectTest @@ -52,9 +52,10 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2RedirectHandler; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.Test; + public class RedirectTest implements HttpServerAdapters { static int httpPort; static HttpTestServer httpServer; @@ -135,7 +136,7 @@ public class RedirectTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(); diff --git a/test/jdk/java/net/httpclient/http2/ServerPush.java b/test/jdk/java/net/httpclient/http2/ServerPush.java index 7f9c82fb28b..d38b867132b 100644 --- a/test/jdk/java/net/httpclient/http2/ServerPush.java +++ b/test/jdk/java/net/httpclient/http2/ServerPush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +29,7 @@ * @build jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.http2.PushHandler * jdk.test.lib.Utils - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=errors,requests,responses * ServerPush */ @@ -48,13 +48,14 @@ import java.util.concurrent.*; import java.util.function.Consumer; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.PushHandler; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static jdk.test.lib.Utils.createTempFileOfSize; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class ServerPush { @@ -66,11 +67,11 @@ public class ServerPush { static Path tempFile; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { tempFile = createTempFileOfSize(TEMP_FILE_PREFIX, null, FILE_SIZE); server = new Http2TestServer(false, 0); server.addHandler(new PushHandler(tempFile, LOOPS), "/"); @@ -82,8 +83,8 @@ public class ServerPush { uri = new URI("http://localhost:" + port + "/foo/a/b/c"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } @@ -109,10 +110,10 @@ public class ServerPush { System.err.println("results.size: " + resultMap.size()); for (HttpRequest r : resultMap.keySet()) { HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(tempFileAsString, response.body()); } - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } // Test 2 - of(...) populating the given Map, everything as a String @@ -135,10 +136,10 @@ public class ServerPush { System.err.println("results.size: " + resultMap.size()); for (HttpRequest r : resultMap.keySet()) { HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(tempFileAsString, response.body()); } - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } // --- Path --- @@ -177,11 +178,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); String fileAsString = new String(Files.readAllBytes(response.body()), UTF_8); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // Test 4 - of(...) populating the given Map, everything as a Path @@ -204,11 +205,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); String fileAsString = new String(Files.readAllBytes(response.body()), UTF_8); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // --- Consumer --- @@ -263,12 +264,12 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // Test 6 - of(...) populating the given Map, everything as a consumer of optional byte[] @@ -301,11 +302,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } diff --git a/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java b/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java index 3e12a20c15e..9cf2a3f7ae2 100644 --- a/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java +++ b/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses * ServerPushWithDiffTypes @@ -47,9 +47,10 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ServerPushWithDiffTypes { @@ -66,7 +67,7 @@ public class ServerPushWithDiffTypes { ); @Test - public static void test() throws Exception { + public void test() throws Exception { Http2TestServer server = null; try { server = new Http2TestServer(false, 0); @@ -93,7 +94,7 @@ public class ServerPushWithDiffTypes { results.put(request, cf); cf.join(); - assertEquals(results.size(), PUSH_PROMISES.size() + 1); + assertEquals(PUSH_PROMISES.size() + 1, results.size()); for (HttpRequest r : results.keySet()) { URI u = r.uri(); @@ -116,7 +117,7 @@ public class ServerPushWithDiffTypes { String expected = PUSH_PROMISES.get(r.uri().getPath()); if (expected == null) expected = "the main response body"; - assertEquals(result, expected); + assertEquals(expected, result); } } finally { server.stop(); diff --git a/test/jdk/java/net/httpclient/http2/SimpleGet.java b/test/jdk/java/net/httpclient/http2/SimpleGet.java index 692a6583b63..5df3174f820 100644 --- a/test/jdk/java/net/httpclient/http2/SimpleGet.java +++ b/test/jdk/java/net/httpclient/http2/SimpleGet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,11 +27,11 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -XX:+CrashOnOutOfMemoryError SimpleGet - * @run testng/othervm -XX:+CrashOnOutOfMemoryError + * @run junit/othervm -XX:+CrashOnOutOfMemoryError SimpleGet + * @run junit/othervm -XX:+CrashOnOutOfMemoryError * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * SimpleGet - * @run testng/othervm -Dsimpleget.requests=150 + * @run junit/othervm -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 * -Djdk.httpclient.redirects.retrylimit=5 * -Djdk.httpclient.HttpClient.log=errors @@ -62,11 +62,12 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class SimpleGet implements HttpServerAdapters { static HttpTestServer httpsServer; static HttpClient client = null; @@ -117,11 +118,11 @@ public class SimpleGet implements HttpServerAdapters { } public static void main(String[] args) throws Exception { - test(); + new SimpleGet().test(); } @Test - public static void test() throws Exception { + public void test() throws Exception { try { long prestart = System.nanoTime(); initialize(); @@ -132,7 +133,7 @@ public class SimpleGet implements HttpServerAdapters { .GET().build(); long start = System.nanoTime(); var resp = client.send(request, BodyHandlers.ofByteArrayConsumer(b -> {})); - Assert.assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); long elapsed = System.nanoTime() - start; System.out.println("Stat: First request took: " + elapsed + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed) + " ms)"); final int max = property("simpleget.requests", 50); @@ -163,7 +164,7 @@ public class SimpleGet implements HttpServerAdapters { + connections.size() + " connections"); } } - list.forEach((cf) -> Assert.assertEquals(cf.join().statusCode(), 200)); + list.forEach((cf) -> assertEquals(200, cf.join().statusCode())); } catch (Throwable tt) { System.err.println("tt caught"); tt.printStackTrace(); diff --git a/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java b/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java index 3edf0b71305..a36fe29813c 100644 --- a/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java +++ b/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8342075 8343855 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.connectionWindowSize=65535 * -Djdk.httpclient.windowsize=16384 * StreamFlowControlTest @@ -65,30 +65,30 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.SettingsFrame; import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class StreamFlowControlTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String http2URI; - String https2URI; - final AtomicInteger reqid = new AtomicInteger(); + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static String http2URI; + private static String https2URI; + private static final AtomicInteger reqid = new AtomicInteger(); final static int WINDOW = Integer.getInteger("jdk.httpclient.windowsize", 2 * 16 * 1024); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][] { { http2URI, false }, { https2URI, false }, @@ -111,7 +111,8 @@ public class StreamFlowControlTest { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uri, boolean sameClient) throws Exception @@ -142,7 +143,7 @@ public class StreamFlowControlTest { if (sameClient) { String key = response.headers().firstValue("X-Connection-Key").get(); if (label == null) label = key; - assertEquals(key, label, "Unexpected key for " + query); + assertEquals(label, key, "Unexpected key for " + query); } sent.join(); // we have to pull to get the exception, but slow enough @@ -175,7 +176,8 @@ public class StreamFlowControlTest { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uri, boolean sameClient) { @@ -207,7 +209,7 @@ public class StreamFlowControlTest { if (sameClient) { String key = response.headers().firstValue("X-Connection-Key").get(); if (label == null) label = key; - assertEquals(key, label, "Unexpected key for " + query); + assertEquals(label, key, "Unexpected key for " + query); } sent.join(); long wait = uri.startsWith("https://") ? 800 : 350; @@ -264,38 +266,38 @@ public class StreamFlowControlTest { } } - @BeforeTest - public void setup() throws Exception { - var http2TestServer = new Http2TestServer("localhost", false, 0); - http2TestServer.addHandler(new Http2TestHandler(), "/http2/"); - this.http2TestServer = HttpTestServer.of(http2TestServer); - http2URI = "http://" + this.http2TestServer.serverAuthority() + "/http2/x"; + @BeforeAll + public static void setup() throws Exception { + var http2TestServerImpl = new Http2TestServer("localhost", false, 0); + http2TestServerImpl.addHandler(new Http2TestHandler(), "/http2/"); + http2TestServer = HttpTestServer.of(http2TestServerImpl); + http2URI = "http://" + http2TestServer.serverAuthority() + "/http2/x"; - var https2TestServer = new Http2TestServer("localhost", true, sslContext); - https2TestServer.addHandler(new Http2TestHandler(), "/https2/"); - this.https2TestServer = HttpTestServer.of(https2TestServer); - this.https2TestServer.addHandler(new HttpHeadOrGetHandler(), "/https2/head/"); - https2URI = "https://" + this.https2TestServer.serverAuthority() + "/https2/x"; - String h2Head = "https://" + this.https2TestServer.serverAuthority() + "/https2/head/z"; + var https2TestServerImpl = new Http2TestServer("localhost", true, sslContext); + https2TestServerImpl.addHandler(new Http2TestHandler(), "/https2/"); + https2TestServer = HttpTestServer.of(https2TestServerImpl); + https2TestServer.addHandler(new HttpHeadOrGetHandler(), "/https2/head/"); + https2URI = "https://" + https2TestServer.serverAuthority() + "/https2/x"; + String h2Head = "https://" + https2TestServer.serverAuthority() + "/https2/head/z"; // Override the default exchange supplier with a custom one to enable // particular test scenarios - http2TestServer.setExchangeSupplier(FCHttp2TestExchange::new); - https2TestServer.setExchangeSupplier(FCHttp2TestExchange::new); + http2TestServerImpl.setExchangeSupplier(FCHttp2TestExchange::new); + https2TestServerImpl.setExchangeSupplier(FCHttp2TestExchange::new); - this.http2TestServer.start(); - this.https2TestServer.start(); + http2TestServer.start(); + https2TestServer.start(); // warmup to eliminate delay due to SSL class loading and initialization. try (var client = HttpClient.newBuilder().sslContext(sslContext).build()) { var request = HttpRequest.newBuilder(URI.create(h2Head)).HEAD().build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { http2TestServer.stop(); https2TestServer.stop(); } diff --git a/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java index 9fa6f8b728e..9ea331d2d84 100644 --- a/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java +++ b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +28,7 @@ * @bug 8296410 * @library /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all TrailingHeadersTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all TrailingHeadersTest */ import jdk.httpclient.test.lib.http2.OutgoingPushPromise; @@ -36,11 +36,6 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.DataFrame; import jdk.internal.net.http.frame.HeaderFrame; import jdk.internal.net.http.frame.HeadersFrame; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLSession; import java.io.ByteArrayInputStream; @@ -74,24 +69,30 @@ import jdk.httpclient.test.lib.http2.BodyOutputStream; import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TrailingHeadersTest { - Http2TestServer http2TestServer; - URI trailingURI, trailng1xxURI, trailingPushPromiseURI, warmupURI; + private static Http2TestServer http2TestServer; + private static URI trailingURI, trailng1xxURI, trailingPushPromiseURI, warmupURI; static PrintStream testLog = System.err; // Set up simple client-side push promise handler - ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); + private static ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); - @BeforeMethod + @BeforeEach public void beforeMethod() { pushPromiseMap = new ConcurrentHashMap<>(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { Properties props = new Properties(); // For triggering trailing headers to send after Push Promise Response headers are sent props.setProperty("sendTrailingHeadersAfterPushPromise", "1"); @@ -119,12 +120,13 @@ public class TrailingHeadersTest { warmupURI = URI.create("http://" + http2TestServer.serverAuthority() + "/WarmupHandler"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { http2TestServer.stop(); } - @Test(dataProvider = "httpRequests") + @ParameterizedTest + @MethodSource("uris") public void testTrailingHeaders(String description, HttpRequest hRequest, HttpResponse.PushPromiseHandler pph) { testLog.println("testTrailingHeaders(): " + description); HttpClient httpClient = HttpClient.newBuilder().build(); @@ -134,7 +136,7 @@ public class TrailingHeadersTest { testLog.println("testTrailingHeaders(): Performing request: " + hRequest); HttpResponse resp = cf.join(); - assertEquals(resp.statusCode(), 200, "Status code of response should be 200"); + assertEquals(200, resp.statusCode(), "Status code of response should be 200"); // Verify Push Promise was successful if necessary if (pph != null) @@ -144,14 +146,14 @@ public class TrailingHeadersTest { } private void verifyPushPromise() { - assertEquals(pushPromiseMap.size(), 1, "Push Promise should not be greater than 1"); + assertEquals(1, pushPromiseMap.size(), "Push Promise should not be greater than 1"); // This will only iterate once for (HttpRequest r : pushPromiseMap.keySet()) { CompletableFuture> serverPushResp = pushPromiseMap.get(r); // Get the push promise HttpResponse result if present HttpResponse resp = serverPushResp.join(); - assertEquals(resp.body(), "Sample_Push_Data", "Unexpected Push Promise response body"); - assertEquals(resp.statusCode(), 200, "Status code of Push Promise response should be 200"); + assertEquals("Sample_Push_Data", resp.body(), "Unexpected Push Promise response body"); + assertEquals(200, resp.statusCode(), "Status code of Push Promise response should be 200"); } } @@ -162,11 +164,10 @@ public class TrailingHeadersTest { httpClient.sendAsync(warmupReq, BodyHandlers.discarding()).join(); } - @DataProvider(name = "httpRequests") - public Object[][] uris() { + public static Object[][] uris() { HttpResponse.PushPromiseHandler pph = (initial, pushRequest, acceptor) -> { HttpResponse.BodyHandler s = HttpResponse.BodyHandlers.ofString(UTF_8); - pushPromiseMap.put(pushRequest, acceptor.apply(s)); + TrailingHeadersTest.pushPromiseMap.put(pushRequest, acceptor.apply(s)); }; HttpRequest httpGetTrailing = HttpRequest.newBuilder(trailingURI).version(HTTP_2) diff --git a/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java b/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java index 0eb1714da35..07e27a7f2fa 100644 --- a/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java +++ b/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java @@ -29,9 +29,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.jupiter.api.Assertions; -import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HeaderTableTest extends SimpleHeaderTableTest { @@ -76,7 +76,7 @@ public class HeaderTableTest extends SimpleHeaderTableTest { Set expectedIndexes = indexes.get(hName); int actualMinimalIndex = table.indexOf(hName, "blah-blah"); - Assertions.assertTrue(expectedIndexes.contains(-actualMinimalIndex)); + assertTrue(expectedIndexes.contains(-actualMinimalIndex)); }); } diff --git a/test/jdk/java/net/httpclient/http3/BadCipherSuiteErrorTest.java b/test/jdk/java/net/httpclient/http3/BadCipherSuiteErrorTest.java index 727f2c78352..fdfc498b21e 100644 --- a/test/jdk/java/net/httpclient/http3/BadCipherSuiteErrorTest.java +++ b/test/jdk/java/net/httpclient/http3/BadCipherSuiteErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8157105 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all BadCipherSuiteErrorTest + * @run junit/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all BadCipherSuiteErrorTest * @summary check exception thrown when bad TLS parameters selected */ @@ -49,7 +49,7 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * When selecting an unacceptable cipher suite the TLS handshake will fail. diff --git a/test/jdk/java/net/httpclient/http3/GetHTTP3Test.java b/test/jdk/java/net/httpclient/http3/GetHTTP3Test.java index 17fc33f3aa5..800a02eb2c4 100644 --- a/test/jdk/java/net/httpclient/http3/GetHTTP3Test.java +++ b/test/jdk/java/net/httpclient/http3/GetHTTP3Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -44,30 +44,31 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.SSLContext; import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; - +import static org.junit.jupiter.api.Assertions.*; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -76,7 +77,7 @@ import static java.lang.System.out; * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.Utils * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * GetHTTP3Test * @summary Basic HTTP/3 GET test @@ -92,8 +93,8 @@ public class GetHTTP3Test implements HttpServerAdapters { """; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) - String h3URI; + private static HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) + private static String h3URI; static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test @@ -111,10 +112,10 @@ public class GetHTTP3Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - final Set sharedClientHasH3 = ConcurrentHashMap.newKeySet(); - private volatile HttpClient sharedClient; - private boolean directQuicConnectionSupported; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final Set sharedClientHasH3 = ConcurrentHashMap.newKeySet(); + private static volatile HttpClient sharedClient; + private static boolean directQuicConnectionSupported; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -140,21 +141,38 @@ public class GetHTTP3Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass - final void printFailedTests() { + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll + static void printFailedTests() { out.println("\n========================="); try { out.printf("%n%sCreated %d servers and %d clients%n", @@ -174,24 +192,20 @@ public class GetHTTP3Test implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { h3URI, }; } - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2 * 2 * 2][]; int i = 0; for (var version : List.of(Optional.empty(), Optional.of(HTTP_3))) { for (Version firstRequestVersion : List.of(HTTP_2, HTTP_3)) { for (boolean sameClient : List.of(false, true)) { - for (String uri : uris()) { + for (String uri : uris) { result[i++] = new Object[]{uri, firstRequestVersion, sameClient, version}; } } @@ -201,15 +215,6 @@ public class GetHTTP3Test implements HttpServerAdapters { return result; } - @DataProvider(name = "uris") - public Object[][] uris(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } - Object[][] result = {{h3URI}}; - return result; - } - private HttpClient makeNewClient() { clientCount.incrementAndGet(); HttpClient client = newClientBuilderForH3() @@ -235,7 +240,8 @@ public class GetHTTP3Test implements HttpServerAdapters { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsync(String uri, Version firstRequestVersion, boolean sameClient, Optional version) throws Exception { System.out.println("Request to " + uri +"/Async/*" + ", firstRequestVersion=" + firstRequestVersion + @@ -263,17 +269,17 @@ public class GetHTTP3Test implements HttpServerAdapters { } HttpResponse response1 = client.send(headBuilder.build(), BodyHandlers.ofString()); - assertEquals(response1.statusCode(), 200, "Unexpected first response code"); - assertEquals(response1.body(), "", "Unexpected first response body"); + assertEquals(200, response1.statusCode(), "Unexpected first response code"); + assertEquals("", response1.body(), "Unexpected first response body"); boolean expectH3 = sameClient && sharedClientHasH3.contains(headURI.getRawAuthority()); if (firstRequestVersion == HTTP_3) { if (expectH3) { out.println("Expecting HEAD response over HTTP_3"); - assertEquals(response1.version(), HTTP_3, "Unexpected first response version"); + assertEquals(HTTP_3, response1.version(), "Unexpected first response version"); } } else { out.println("Expecting HEAD response over HTTP_2"); - assertEquals(response1.version(), HTTP_2, "Unexpected first response version"); + assertEquals(HTTP_2, response1.version(), "Unexpected first response version"); } out.println("HEAD response version: " + response1.version()); if (response1.version() == HTTP_2) { @@ -329,10 +335,10 @@ public class GetHTTP3Test implements HttpServerAdapters { out.println("Checking response: " + u); var response = e.getValue().get(); out.println("Response is: " + response + ", [version: " + response.version() + "]"); - assertEquals(response.statusCode(), 200,"status for " + u); - assertEquals(response.body(), BODY,"body for " + u); + assertEquals(200, response.statusCode(), "status for " + u); + assertEquals(BODY, response.body(), "body for " + u); if (expectH3) { - assertEquals(response.version(), HTTP_3, "version for " + u); + assertEquals(HTTP_3, response.version(), "version for " + u); } if (response.version() == HTTP_3) { h3Count++; @@ -354,7 +360,8 @@ public class GetHTTP3Test implements HttpServerAdapters { System.out.println("test: DONE"); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") public void testSync(String h3URI) throws Exception { HttpClient client = makeNewClient(); Builder builder = HttpRequest.newBuilder(URI.create(h3URI + "/Sync/GET/1")) @@ -374,22 +381,22 @@ public class GetHTTP3Test implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); + assertEquals(200, response.statusCode(), "first response status"); if (directQuicConnectionSupported) { // TODO unreliable assertion //assertEquals(response.version(), HTTP_3, "Unexpected first response version"); } else { - assertEquals(response.version(), HTTP_2, "Unexpected first response version"); + assertEquals(HTTP_2, response.version(), "Unexpected first response version"); } - assertEquals(response.body(), BODY, "first response body"); + assertEquals(BODY, response.body(), "first response body"); request = builder.uri(URI.create(h3URI + "/Sync/GET/2")).build(); response = client.send(request, BodyHandlers.ofString()); out.println("Response #2: " + response); out.println("Version #2: " + response.version()); - assertEquals(response.statusCode(), 200, "second response status"); - assertEquals(response.version(), HTTP_3, "second response version"); - assertEquals(response.body(), BODY, "second response body"); + assertEquals(200, response.statusCode(), "second response status"); + assertEquals(HTTP_3, response.version(), "second response version"); + assertEquals(BODY, response.body(), "second response body"); var tracker = TRACKER.getTracker(client); client = null; @@ -398,8 +405,8 @@ public class GetHTTP3Test implements HttpServerAdapters { if (error != null) throw error; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { final Http2TestServer h2WithAltService = new Http2TestServer("localhost", true, sslContext).enableH3AltServiceOnSamePort(); h3TestServer = HttpTestServer.of(h2WithAltService); @@ -410,8 +417,8 @@ public class GetHTTP3Test implements HttpServerAdapters { directQuicConnectionSupported = h2WithAltService.supportsH3DirectConnection(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("======================================================="); System.err.println(" Tearing down test"); System.err.println("======================================================="); @@ -453,7 +460,7 @@ public class GetHTTP3Test implements HttpServerAdapters { } try (InputStream is = t.getRequestBody(); OutputStream os = t.getResponseBody()) { - assertEquals(is.readAllBytes().length, 0); + assertEquals(0, is.readAllBytes().length); if (!"HEAD".equals(t.getRequestMethod())) { String[] body = BODY.split("\n"); for (String line : body) { diff --git a/test/jdk/java/net/httpclient/http3/H3BadHeadersTest.java b/test/jdk/java/net/httpclient/http3/H3BadHeadersTest.java index fb0e1ef3085..fff11f4ceb4 100644 --- a/test/jdk/java/net/httpclient/http3/H3BadHeadersTest.java +++ b/test/jdk/java/net/httpclient/http3/H3BadHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,17 +27,13 @@ * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.internal.httpclient.debug=true H3BadHeadersTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true H3BadHeadersTest * @summary this test verifies the behaviour of the HttpClient when presented * with bad headers */ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; @@ -57,10 +53,17 @@ import java.util.concurrent.ExecutionException; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.util.List.of; import static java.util.Map.entry; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class H3BadHeadersTest implements HttpServerAdapters { @@ -76,14 +79,13 @@ public class H3BadHeadersTest implements HttpServerAdapters { static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http3TestServer; // HTTP/3 ( h3 only ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 + h3 ) - String http3URI; - String https2URI; + private static HttpTestServer http3TestServer; // HTTP/3 ( h3 only ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 + h3 ) + private static String http3URI; + private static String https2URI; - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][] { { http3URI, false}, { https2URI, false}, @@ -93,7 +95,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uri, boolean sameClient) throws Exception @@ -126,8 +129,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { .HEAD().setOption(H3_DISCOVERY, config).build(); System.out.println("\nSending HEAD request: " + head); var headResponse = client.send(head, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } URI uriWithQuery = URI.create(uri + "?BAD_HEADERS=" + i); @@ -163,7 +166,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { System.err.printf("%ntest %s, %s, DONE%n%n", uri, sameClient); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uri, boolean sameClient) throws Exception { @@ -199,8 +203,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { System.out.println("\nSending HEAD request: " + head); var headResponse = client.send(head, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } URI uriWithQuery = URI.create(uri + "?BAD_HEADERS=" + i); @@ -246,8 +250,7 @@ public class H3BadHeadersTest implements HttpServerAdapters { // sync with implementation. static void assertDetailMessage(Throwable throwable, int iterationIndex) { try { - assertTrue(throwable instanceof IOException, - "Expected IOException, got, " + throwable); + assertInstanceOf(IOException.class, throwable, "Expected IOException, got, " + throwable); assertNotNull(throwable.getMessage(), "No message for " + throwable); assertTrue(throwable.getMessage().contains("malformed response"), "Expected \"malformed response\" in: " + throwable.getMessage()); @@ -269,8 +272,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { System.out.println("creating servers"); http3TestServer = HttpTestServer.create(Http3DiscoveryMode.HTTP_3_URI_ONLY, sslContext); http3TestServer.addHandler(new BadHeadersHandler(), "/http3/echo"); @@ -285,8 +288,8 @@ public class H3BadHeadersTest implements HttpServerAdapters { System.out.println("server started"); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("\n\n**** stopping servers\n"); System.out.println("stopping servers"); http3TestServer.stop(); diff --git a/test/jdk/java/net/httpclient/http3/H3BasicTest.java b/test/jdk/java/net/httpclient/http3/H3BasicTest.java index a03df11c1a3..bddb9879ae9 100644 --- a/test/jdk/java/net/httpclient/http3/H3BasicTest.java +++ b/test/jdk/java/net/httpclient/http3/H3BasicTest.java @@ -31,7 +31,7 @@ * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * H3BasicTest */ @@ -60,7 +60,6 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; @@ -70,6 +69,8 @@ import static jdk.test.lib.Asserts.assertFileContentsEqual; import static jdk.test.lib.Utils.createTempFile; import static jdk.test.lib.Utils.createTempFileOfSize; +import org.junit.jupiter.api.Test; + public class H3BasicTest implements HttpServerAdapters { private static final Random RANDOM = RandomFactory.getRandom(); @@ -151,7 +152,7 @@ public class H3BasicTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); System.out.println("servers initialized"); diff --git a/test/jdk/java/net/httpclient/http3/H3ConcurrentPush.java b/test/jdk/java/net/httpclient/http3/H3ConcurrentPush.java index 0cdb2f900fd..4392f829258 100644 --- a/test/jdk/java/net/httpclient/http3/H3ConcurrentPush.java +++ b/test/jdk/java/net/httpclient/http3/H3ConcurrentPush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * -Djdk.httpclient.http3.maxConcurrentPushStreams=45 @@ -73,17 +73,18 @@ import java.util.function.Supplier; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3ConcurrentPush implements HttpServerAdapters { @@ -92,7 +93,7 @@ public class H3ConcurrentPush implements HttpServerAdapters { static final PrintStream err = System.err; static final PrintStream out = System.out; - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -105,13 +106,13 @@ public class H3ConcurrentPush implements HttpServerAdapters { ); static final String MAIN_RESPONSE_BODY = "the main response body"; - HttpTestServer server; - URI uri; - URI headURI; - ServerPushHandler pushHandler; + private static HttpTestServer server; + private static URI uri; + private static URI headURI; + private static ServerPushHandler pushHandler; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = HttpTestServer.create(ANY, SimpleSSLContext.findSSLContext()); pushHandler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); server.addHandler(pushHandler, "/push/"); @@ -122,14 +123,14 @@ public class H3ConcurrentPush implements HttpServerAdapters { headURI = new URI("https://" + server.serverAuthority() + "/head/x"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); return response; } @@ -137,8 +138,8 @@ public class H3ConcurrentPush implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(Version.HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } static final class TestPushPromiseHandler implements PushPromiseHandler { @@ -233,16 +234,16 @@ public class H3ConcurrentPush implements HttpServerAdapters { promises.forEach((request, value) -> { HttpResponse response = value.join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } }); int expectedPushes = Math.min(PUSH_PROMISES.size(), maxPushes) + 5; - assertEquals(promises.size(), expectedPushes); + assertEquals(expectedPushes, promises.size()); promises.clear(); @@ -251,12 +252,12 @@ public class H3ConcurrentPush implements HttpServerAdapters { client.sendAsync(HttpRequest.newBuilder(uri).build(), BodyHandlers.ofString()) .thenApply(H3ConcurrentPush::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); } catch (CompletionException c) { throw new AssertionError(c.getCause()); } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // Send with no promise handler, but use pushId bigger than allowed. // This should cause the connection to get closed @@ -268,7 +269,7 @@ public class H3ConcurrentPush implements HttpServerAdapters { client.sendAsync(bigger, BodyHandlers.ofString()) .thenApply(H3ConcurrentPush::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); throw new AssertionError("Expected IOException not thrown"); } catch (CompletionException c) { @@ -287,7 +288,7 @@ public class H3ConcurrentPush implements HttpServerAdapters { throw new AssertionError("Unexpected exception: " + c.getCause(), c.getCause()); } } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // the next time around we should have a new connection, // so we can restart from scratch @@ -298,7 +299,7 @@ public class H3ConcurrentPush implements HttpServerAdapters { var error = errors.stream().findFirst().orElse(null); if (error != null) throw error; var notified = custom.notified; - assertEquals(notified.size(), 9*4*2, "Unexpected notification: " + notified); + assertEquals(9*4*2, notified.size(), "Unexpected notification: " + notified); } } diff --git a/test/jdk/java/net/httpclient/http3/H3ConnectionPoolTest.java b/test/jdk/java/net/httpclient/http3/H3ConnectionPoolTest.java index c90059ccbfd..12956604484 100644 --- a/test/jdk/java/net/httpclient/http3/H3ConnectionPoolTest.java +++ b/test/jdk/java/net/httpclient/http3/H3ConnectionPoolTest.java @@ -25,11 +25,13 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer - * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:hs + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:hs * -Djdk.internal.httpclient.debug=false + * -Djdk.httpclient.keepalive.timeout.h3=480 + * -Djdk.httpclient.quic.idleTimeout=480 + * -Djdk.test.server.quic.idleTimeout=480 * H3ConnectionPoolTest */ @@ -44,7 +46,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; import java.util.function.Supplier; import javax.net.ssl.SSLContext; @@ -53,7 +54,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; @@ -61,9 +61,11 @@ import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; -import static jdk.test.lib.Asserts.assertEquals; -import static jdk.test.lib.Asserts.assertNotEquals; -import static jdk.test.lib.Asserts.assertTrue; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class H3ConnectionPoolTest implements HttpServerAdapters { @@ -172,7 +174,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { } @Test - public static void testH3Only() throws Exception { + public void testH3Only() throws Exception { System.out.println("\nTesting HTTP/3 only"); initialize(true); try (HttpClient client = getClient()) { @@ -212,12 +214,12 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { } @Test - public static void testH2H3WithTwoAltSVC() throws Exception { + public void testH2H3WithTwoAltSVC() throws Exception { testH2H3(false); } @Test - public static void testH2H3WithAltSVCOnSamePort() throws Exception { + public void testH2H3WithAltSVCOnSamePort() throws Exception { testH2H3(true); } @@ -256,7 +258,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response2 = client.send(request2, BodyHandlers.ofString()); assertEquals(HTTP_3, response2.version()); checkStatus(200, response2.statusCode()); - assertNotEquals(response2.connectionLabel().get(), response1.connectionLabel().get()); + assertNotEquals(response1.connectionLabel().get(), response2.connectionLabel().get()); // second request with HTTP3_URI_ONLY should reuse a created connection // It should reuse the advertised connection (from response2) if same @@ -294,8 +296,8 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response2 = client.send(request2, BodyHandlers.ofString()); assertEquals(HTTP_3, response2.version()); checkStatus(200, response2.statusCode()); - assertNotEquals(response2.connectionLabel().get(), h2resp2.connectionLabel().get()); - assertNotEquals(response2.connectionLabel().get(), response1.connectionLabel().get()); + assertNotEquals(h2resp2.connectionLabel().get(), response2.connectionLabel().get()); + assertNotEquals(response1.connectionLabel().get(), response2.connectionLabel().get()); // third request with ALT_SVC should reuse the same advertised // connection (from response2), regardless of same origin... @@ -303,16 +305,16 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response3 = client.send(request3, BodyHandlers.ofString()); assertEquals(HTTP_3, response3.version()); checkStatus(200, response3.statusCode()); - assertEquals(response3.connectionLabel().get(), response2.connectionLabel().get()); - assertNotEquals(response3.connectionLabel().get(), response1.connectionLabel().get()); + assertEquals(response2.connectionLabel().get(), response3.connectionLabel().get()); + assertNotEquals(response1.connectionLabel().get(), response3.connectionLabel().get()); // fourth request with HTTP_3_URI_ONLY should reuse the first connection, // and not reuse the second. HttpRequest request4 = req1Builder.copy().build(); - HttpResponse response4 = client.send(request1, BodyHandlers.ofString()); + HttpResponse response4 = client.send(request4, BodyHandlers.ofString()); assertEquals(HTTP_3, response4.version()); - assertEquals(response4.connectionLabel().get(), response1.connectionLabel().get()); - assertNotEquals(response4.connectionLabel().get(), response3.connectionLabel().get()); + assertEquals(response1.connectionLabel().get(), response4.connectionLabel().get()); + assertNotEquals(response3.connectionLabel().get(), response4.connectionLabel().get()); checkStatus(200, response1.statusCode()); } else { System.out.println("WARNING: Couldn't create HTTP/3 server on same port! Can't test all..."); @@ -328,7 +330,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response2 = client.send(request2, BodyHandlers.ofString()); assertEquals(HTTP_3, response2.version()); checkStatus(200, response2.statusCode()); - assertNotEquals(response2.connectionLabel().get(), h2resp2.connectionLabel().get()); + assertNotEquals(h2resp2.connectionLabel().get(), response2.connectionLabel().get()); // third request with ALT_SVC should reuse the same advertised // connection (from response2), regardless of same origin... @@ -336,7 +338,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response3 = client.send(request3, BodyHandlers.ofString()); assertEquals(HTTP_3, response3.version()); checkStatus(200, response3.statusCode()); - assertEquals(response3.connectionLabel().get(), response2.connectionLabel().get()); + assertEquals(response2.connectionLabel().get(), response3.connectionLabel().get()); } } finally { http3OnlyServer.stop(); @@ -345,12 +347,12 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { } @Test - public static void testParallelH2H3WithTwoAltSVC() throws Exception { + public void testParallelH2H3WithTwoAltSVC() throws Exception { testH2H3Concurrent(false); } @Test - public static void testParallelH2H3WithAltSVCOnSamePort() throws Exception { + public void testParallelH2H3WithAltSVCOnSamePort() throws Exception { testH2H3Concurrent(true); } @@ -416,7 +418,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { response2); assertEquals(HTTP_3, response2.version()); checkStatus(200, response2.statusCode()); - assertNotEquals(response2.connectionLabel().get(), c1Label); + assertNotEquals(c1Label, response2.connectionLabel().get()); if (i == 0) { c2Label = response2.connectionLabel().get(); } @@ -493,8 +495,8 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { if (i == 0) { c2Label = response2.connectionLabel().get(); } - assertNotEquals(response2.connectionLabel().get(), h2resp2.connectionLabel().get()); - assertNotEquals(response2.connectionLabel().get(), c1Label); + assertNotEquals(h2resp2.connectionLabel().get(), response2.connectionLabel().get()); + assertNotEquals(c1Label, response2.connectionLabel().get()); assertEquals(c2Label, response2.connectionLabel().orElse(null)); } var expectedLabels = Set.of(c1Label, c2Label); @@ -506,7 +508,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { response3); assertEquals(HTTP_3, response3.version()); checkStatus(200, response3.statusCode()); - assertNotEquals(response3.connectionLabel().get(), h2resp2.connectionLabel().get()); + assertNotEquals(h2resp2.connectionLabel().get(), response3.connectionLabel().get()); var label = response3.connectionLabel().orElse(""); assertTrue(expectedLabels.contains(label), "Unexpected label: %s not in %s" .formatted(label, expectedLabels)); @@ -525,7 +527,7 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { HttpResponse response2 = client.send(request2, BodyHandlers.ofString()); assertEquals(HTTP_3, response2.version()); checkStatus(200, response2.statusCode()); - assertNotEquals(response2.connectionLabel().get(), h2resp2.connectionLabel().get()); + assertNotEquals(h2resp2.connectionLabel().get(), response2.connectionLabel().get()); // third request with ALT_SVC should reuse the same advertised // connection (from response2), regardless of same origin... @@ -559,21 +561,4 @@ public class H3ConnectionPoolTest implements HttpServerAdapters { } } - static void checkStrings(String expected, String found) throws Exception { - if (!expected.equals(found)) { - System.err.printf("Test failed: wrong string %s/%s\n", - expected, found); - throw new RuntimeException("Test failed"); - } - } - - - static T logExceptionally(String desc, Throwable t) { - System.out.println(desc + " failed: " + t); - System.err.println(desc + " failed: " + t); - if (t instanceof RuntimeException r) throw r; - if (t instanceof Error e) throw e; - throw new CompletionException(t); - } - } diff --git a/test/jdk/java/net/httpclient/http3/H3DataLimitsTest.java b/test/jdk/java/net/httpclient/http3/H3DataLimitsTest.java index 9f509b5440a..8a83b51a174 100644 --- a/test/jdk/java/net/httpclient/http3/H3DataLimitsTest.java +++ b/test/jdk/java/net/httpclient/http3/H3DataLimitsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -44,18 +36,29 @@ import java.net.http.HttpRequest; import java.net.http.HttpRequest.Builder; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* @@ -64,7 +67,7 @@ import static org.testng.Assert.assertEquals; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.quic.QuicStandaloneServer - * @run testng/othervm/timeout=480 -Djdk.internal.httpclient.debug=true + * @run junit/othervm/timeout=480 -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djavax.net.debug=all * H3DataLimitsTest @@ -73,8 +76,8 @@ import static org.testng.Assert.assertEquals; public class H3DataLimitsTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer h3TestServer; - String h3URI; + private static HttpTestServer h3TestServer; + private static String h3URI; static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); @@ -114,20 +117,37 @@ public class H3DataLimitsTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll static void printFailedTests() { out.println("\n========================="); try { @@ -148,13 +168,8 @@ public class H3DataLimitsTest implements HttpServerAdapters { } } - @DataProvider(name = "h3URIs") - public Object[][] versions(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } - Object[][] result = {{h3URI}}; - return result; + public static Object[][] versions() { + return new Object[][] {{h3URI}}; } private HttpClient makeNewClient() { @@ -168,7 +183,8 @@ public class H3DataLimitsTest implements HttpServerAdapters { return client; } - @Test(dataProvider = "h3URIs") + @ParameterizedTest + @MethodSource("versions") public void testHugeResponse(final String h3URI) throws Exception { HttpClient client = makeNewClient(); URI uri = URI.create(h3URI + "?16000000"); @@ -180,17 +196,18 @@ public class H3DataLimitsTest implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); - assertEquals(response.version(), HTTP_3, "first response version"); + assertEquals(200, response.statusCode(), "first response status"); + assertEquals(HTTP_3, response.version(), "first response version"); response = client.send(request, BodyHandlers.ofString()); out.println("Response #2: " + response); out.println("Version #2: " + response.version()); - assertEquals(response.statusCode(), 200, "second response status"); - assertEquals(response.version(), HTTP_3, "second response version"); + assertEquals(200, response.statusCode(), "second response status"); + assertEquals(HTTP_3, response.version(), "second response version"); } - @Test(dataProvider = "h3URIs") + @ParameterizedTest + @MethodSource("versions") public void testManySmallResponses(final String h3URI) throws Exception { HttpClient client = makeNewClient(); URI uri = URI.create(h3URI + "?160000"); @@ -203,13 +220,13 @@ public class H3DataLimitsTest implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #" + i + ": " + response); out.println("Version #" + i + ": " + response.version()); - assertEquals(response.statusCode(), 200, "response status"); - assertEquals(response.version(), HTTP_3, "response version"); + assertEquals(200, response.statusCode(), "response status"); + assertEquals(HTTP_3, response.version(), "response version"); } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // An HTTP/3 server that only supports HTTP/3 h3TestServer = HttpTestServer.of(new Http3TestServer(sslContext)); final HttpTestHandler h3Handler = new Handler(); @@ -220,8 +237,8 @@ public class H3DataLimitsTest implements HttpServerAdapters { h3TestServer.start(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("======================================================="); System.err.println(" Tearing down test"); System.err.println("======================================================="); diff --git a/test/jdk/java/net/httpclient/http3/H3ErrorHandlingTest.java b/test/jdk/java/net/httpclient/http3/H3ErrorHandlingTest.java index 44071ea566d..8dfef7417e3 100644 --- a/test/jdk/java/net/httpclient/http3/H3ErrorHandlingTest.java +++ b/test/jdk/java/net/httpclient/http3/H3ErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,13 +35,6 @@ import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; import jdk.test.lib.Utils; -import org.testng.IRetryAnalyzer; -import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -67,7 +60,14 @@ import java.util.concurrent.TimeUnit; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; /* * @test @@ -82,17 +82,16 @@ import static org.testng.Assert.*; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @build java.net.http/jdk.internal.net.http.Http3ConnectionAccess - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors H3ErrorHandlingTest */ public class H3ErrorHandlingTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private QuicStandaloneServer server; - private String requestURIBase; + private static QuicStandaloneServer server; + private static String requestURIBase; - @DataProvider public static Object[][] controlStreams() { // control / encoder / decoder return new Object[][] {{(byte)0}, {(byte)2}, {(byte)3}}; @@ -148,26 +147,22 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { return result; } - @DataProvider public static Object[][] malformedSettingsFrames() { // 2-byte ID, 2-byte value byte[] settingsFrame = new byte[]{(byte)4,(byte)4,(byte)0x40, (byte)6, (byte)0x40, (byte)6}; return chopFrame(settingsFrame, 1, 2, 3); } - @DataProvider public static Object[][] malformedCancelPushFrames() { byte[] cancelPush = new byte[]{(byte)3,(byte)2, (byte)0x40, (byte)0}; return chopFrame(cancelPush, 0, 1, 3, 9); } - @DataProvider public static Object[][] malformedGoawayFrames() { byte[] goaway = new byte[]{(byte)7,(byte)2, (byte)0x40, (byte)0}; return chopFrame(goaway, 0, 1, 3, 9); } - @DataProvider public static Object[][] malformedResponseHeadersFrames() { byte[] responseHeaders = HexFormat.of().parseHex( "011a0000"+ // headers, length 26, section prefix @@ -176,7 +171,6 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { return chopFrame(responseHeaders, 0, 1, 4, 5, 6, 7); } - @DataProvider public static Object[][] truncatedResponseFrames() { byte[] response = HexFormat.of().parseHex( "01030000"+ // headers, length 3, section prefix @@ -187,7 +181,6 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { return chopBytes(response, 1, 2, 3, 4, 6, 7, 9, 10); } - @DataProvider public static Object[][] truncatedControlFrames() { byte[] response = HexFormat.of().parseHex( "00"+ // stream type: control @@ -198,12 +191,10 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { return chopBytes(response, 2, 3, 4, 6, 7, 9, 10); } - @DataProvider public static Object[][] malformedPushPromiseFrames() { return chopFrame(valid_push_promise, 0, 1, 2, 4, 5, 6); } - @DataProvider public static Object[][] invalidControlFrames() { // frames not valid on the server control stream (after settings) // all except cancel_push / goaway (max_push_id is client-only) @@ -211,7 +202,6 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { {reserved1}, {reserved2}, {reserved3}, {reserved4}}; } - @DataProvider public static Object[][] invalidResponseFrames() { // frames not valid on the response stream // all except headers / push_promise @@ -220,7 +210,6 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { {reserved1}, {reserved2}, {reserved3}, {reserved4}}; } - @DataProvider public static Object[][] invalidPushFrames() { // frames not valid on the push promise stream // all except headers @@ -229,8 +218,8 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { {reserved1}, {reserved2}, {reserved3}, {reserved4}}; } - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { server = QuicStandaloneServer.newBuilder() .availableVersions(new QuicVersion[]{QuicVersion.QUIC_V1}) .sslContext(sslContext) @@ -242,8 +231,8 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { .port(server.getAddress().getPort()).build().toString(); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (server != null) { System.out.println("Stopping server " + server.getAddress()); server.close(); @@ -256,7 +245,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testNonSettingsFrame() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -274,10 +263,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server opens 2 control streams */ - @Test(dataProvider = "controlStreams") + @ParameterizedTest + @MethodSource("controlStreams") public void testTwoControlStreams(byte type) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream, controlStream2; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); @@ -299,10 +289,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server closes control stream */ - @Test(dataProvider = "controlStreams") + @ParameterizedTest + @MethodSource("controlStreams") public void testCloseControlStream(byte type) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var controlscheduler = SequentialScheduler.lockingScheduler(() -> {}); @@ -315,26 +306,34 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { triggerError(errorCF, Http3Error.H3_CLOSED_CRITICAL_STREAM); } - public static class RetryOnce implements IRetryAnalyzer { - boolean retried; - - @Override - public boolean retry(ITestResult iTestResult) { - if (!retried) { - retried = true; - return true; - } - return false; - } - } - /** * Server resets control stream */ - @Test(dataProvider = "controlStreams", retryAnalyzer = RetryOnce.class) + @ParameterizedTest + @MethodSource("controlStreams") public void testResetControlStream(byte type) throws Exception { + try { + System.out.printf("testResetControlStream(%s) - first attempt%n", type); + System.err.printf("%ntestResetControlStream(%s) - first attempt%n", type); + testResetControlStreamImpl(type); + System.out.printf("testResetControlStream(%s) - first attempt succeeded!%n", type); + System.err.printf("%ntestResetControlStream(%s) - first attempt succeeded!%n", type); + } catch (Throwable t) { + System.out.printf("testResetControlStream(%s) - first attempt failed: %s%n", + type, t); + System.err.printf("%ntestResetControlStream(%s) - first attempt failed: %s%n", + type); + System.out.printf("testResetControlStream(%s) - retrying...%n", type); + System.err.printf("%ntestResetControlStream(%s) - retrying...%n", type); + testResetControlStreamImpl(type); + System.out.printf("testResetControlStream(%s) - retry succeeded!%n", type); + System.err.printf("%ntestResetControlStream(%s) - retry succeeded!%n", type); + } + } + + private void testResetControlStreamImpl(byte type) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var controlscheduler = SequentialScheduler.lockingScheduler(() -> {}); @@ -362,10 +361,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends unexpected frame on control stream */ - @Test(dataProvider = "invalidControlFrames") + @ParameterizedTest + @MethodSource("invalidControlFrames") public void testUnexpectedControlFrame(byte[] frame) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -387,10 +387,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed settings frame */ - @Test(dataProvider = "malformedSettingsFrames") + @ParameterizedTest + @MethodSource("malformedSettingsFrames") public void testMalformedSettingsFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -412,10 +413,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed goaway frame */ - @Test(dataProvider = "malformedGoawayFrames") + @ParameterizedTest + @MethodSource("malformedGoawayFrames") public void testMalformedGoawayFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -437,10 +439,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed cancel push frame */ - @Test(dataProvider = "malformedCancelPushFrames") + @ParameterizedTest + @MethodSource("malformedCancelPushFrames") public void testMalformedCancelPushFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -465,7 +468,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testInvalidGoAwaySequence() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -487,7 +490,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testInvalidGoAwayId() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -509,7 +512,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testInvalidCancelPushId() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -529,10 +532,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends unexpected frame on push stream */ - @Test(dataProvider = "invalidPushFrames") + @ParameterizedTest + @MethodSource("invalidPushFrames") public void testUnexpectedPushFrame(byte[] frame) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream pushStream; pushStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -556,10 +560,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed frame on push stream */ - @Test(dataProvider = "malformedResponseHeadersFrames") + @ParameterizedTest + @MethodSource("malformedResponseHeadersFrames") public void testMalformedPushStreamFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream pushStream; pushStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -585,10 +590,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed frame on push stream */ - @Test(dataProvider = "malformedPushPromiseFrames") + @ParameterizedTest + @MethodSource("malformedPushPromiseFrames") public void testMalformedPushPromiseFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { // write PUSH_PROMISE frame s.outputStream().write(frame); // ignore the request stream; we're expecting the client to close the connection @@ -605,7 +611,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testDuplicatePushStream() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream pushStream, pushStream2; pushStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); pushStream2 = c.openNewLocalUniStream(Duration.ZERO).resultNow(); @@ -634,7 +640,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testInvalidPushPromiseId() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { // write PUSH_PROMISE frame s.outputStream().write(huge_id_push_promise); // ignore the request stream; we're expecting the client to close the connection @@ -649,7 +655,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testInvalidPushStreamId() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream pushStream; pushStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -669,10 +675,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends unexpected frame on response stream */ - @Test(dataProvider = "invalidResponseFrames") + @ParameterizedTest + @MethodSource("invalidResponseFrames") public void testUnexpectedResponseFrame(byte[] frame) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { s.outputStream().write(frame); // ignore the request stream; we're expecting the client to close the connection completeUponTermination(c, errorCF); @@ -683,10 +690,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server sends malformed headers frame on response stream */ - @Test(dataProvider = "malformedResponseHeadersFrames") + @ParameterizedTest + @MethodSource("malformedResponseHeadersFrames") public void testMalformedResponseFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { s.outputStream().write(frame); // ignore the request stream; we're expecting the client to close the connection completeUponTermination(c, errorCF); @@ -699,10 +707,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server truncates a frame on the response stream */ - @Test(dataProvider = "truncatedResponseFrames") + @ParameterizedTest + @MethodSource("truncatedResponseFrames") public void testTruncatedResponseFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { try (OutputStream outputStream = s.outputStream()) { outputStream.write(frame); } @@ -715,10 +724,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server truncates a frame on the control stream */ - @Test(dataProvider = "truncatedControlFrames") + @ParameterizedTest + @MethodSource("truncatedControlFrames") public void testTruncatedControlFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var controlscheduler = SequentialScheduler.lockingScheduler(() -> {}); @@ -735,10 +745,11 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { /** * Server truncates a frame on the push stream */ - @Test(dataProvider = "truncatedResponseFrames") + @ParameterizedTest + @MethodSource("truncatedResponseFrames") public void testTruncatedPushStreamFrame(byte[] frame, int bytes) throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream pushStream; pushStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -765,7 +776,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { @Test public void testReservedSettingsFrames() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream controlStream; controlStream = c.openNewLocalUniStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -785,7 +796,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testStatelessReset() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { // stateless reset QuicConnectionId localConnId = c.localConnectionId(); ByteBuffer resetDatagram = c.endpoint().idFactory().statelessReset(localConnId.asReadOnlyBuffer(), 43); @@ -819,10 +830,10 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { * Server opens a bidi stream */ @Test - @Ignore("BiDi streams are rejected by H3 client at QUIC level") + @Disabled("BiDi streams are rejected by H3 client at QUIC level") public void testBidiStream() throws Exception { CompletableFuture errorCF = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { QuicSenderStream bidiStream; bidiStream = c.openNewLocalBidiStream(Duration.ZERO).resultNow(); var scheduler = SequentialScheduler.lockingScheduler(() -> { @@ -842,7 +853,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseQUIC() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.forException( new QuicTransportException("ignored", null, 0, QuicTransportErrors.INTERNAL_ERROR) @@ -859,7 +870,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseCryptoQUIC() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.forException( new QuicTransportException("ignored", null, 0, QuicTransportErrors.CRYPTO_ERROR.from() + 80 /*Alert.INTERNAL_ERROR.id*/, null) @@ -876,7 +887,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseUnknownCryptoQUIC() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.forException( new QuicTransportException("ignored", null, 0, QuicTransportErrors.CRYPTO_ERROR.from() + 5, null) @@ -893,7 +904,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseUnknownQUIC() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.forException( new QuicTransportException("ignored", null, 0, QuicTransportErrors.CRYPTO_ERROR.to() + 1 /*0x200*/, null) @@ -910,7 +921,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseH3() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.appLayerClose(Http3Error.H3_EXCESSIVE_LOAD.code()); tc.peerVisibleReason("testtest"); c.connectionTerminator().terminate(tc); @@ -924,7 +935,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { */ @Test public void testConnectionCloseH3Unknown() throws Exception { - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { TerminationCause tc = TerminationCause.appLayerClose(0x1f21); tc.peerVisibleReason("testtest"); c.connectionTerminator().terminate(tc); @@ -974,7 +985,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { System.out.println("Server reason: \"" + terminationCause.getPeerVisibleReason()+'"'); final long actual = terminationCause.getCloseCode(); // expected - assertEquals(actual, expected.code(), "Expected " + toHexString(expected) + " got 0x" + Long.toHexString(actual)); + assertEquals(expected.code(), actual, "Expected " + toHexString(expected) + " got 0x" + Long.toHexString(actual)); } finally { client.shutdownNow(); } @@ -1027,7 +1038,7 @@ public class H3ErrorHandlingTest implements HttpServerAdapters { System.out.println("Server reason: \"" + terminationCause.getPeerVisibleReason()+'"'); final long actual = terminationCause.getCloseCode(); // expected - assertEquals(actual, http3Error.code(), "Expected " + toHexString(http3Error) + " got 0x" + Long.toHexString(actual)); + assertEquals(http3Error.code(), actual, "Expected " + toHexString(http3Error) + " got 0x" + Long.toHexString(actual)); } finally { client.shutdownNow(); } diff --git a/test/jdk/java/net/httpclient/http3/H3FixedThreadPoolTest.java b/test/jdk/java/net/httpclient/http3/H3FixedThreadPoolTest.java index 6c181186fda..fd0e8214361 100644 --- a/test/jdk/java/net/httpclient/http3/H3FixedThreadPoolTest.java +++ b/test/jdk/java/net/httpclient/http3/H3FixedThreadPoolTest.java @@ -36,7 +36,7 @@ * JTreg on Tier 7 so that, if the client becomes wedged again, the * JTreg timeout handlers can collect more diagnostic information. * - * @run testng/othervm -Djdk.internal.httpclient.debug=err + * @run junit/othervm -Djdk.internal.httpclient.debug=err * -Djdk.httpclient.HttpClient.log=ssl,headers,requests,responses,errors * -Djdk.httpclient.quic.idleTimeout=666666 * -Djdk.test.server.quic.idleTimeout=666666 @@ -69,7 +69,7 @@ import static java.net.http.HttpOption.H3_DISCOVERY; import static jdk.test.lib.Asserts.assertFileContentsEqual; import static jdk.test.lib.Utils.createTempFileOfSize; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class H3FixedThreadPoolTest implements HttpServerAdapters { @@ -118,7 +118,7 @@ public class H3FixedThreadPoolTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(false); diff --git a/test/jdk/java/net/httpclient/http3/H3HeaderSizeLimitTest.java b/test/jdk/java/net/httpclient/http3/H3HeaderSizeLimitTest.java index b48ef9a33f3..d5864989436 100644 --- a/test/jdk/java/net/httpclient/http3/H3HeaderSizeLimitTest.java +++ b/test/jdk/java/net/httpclient/http3/H3HeaderSizeLimitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +29,6 @@ import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; import java.util.concurrent.ExecutionException; import javax.net.ssl.SSLContext; @@ -39,16 +38,16 @@ import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.httpclient.test.lib.quic.QuicServer; import jdk.internal.net.http.Http3ConnectionAccess; import jdk.internal.net.http.http3.ConnectionSettings; -import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary Verifies that the HTTP client respects the SETTINGS_MAX_FIELD_SECTION_SIZE setting on HTTP3 connection @@ -57,7 +56,7 @@ import static java.net.http.HttpOption.H3_DISCOVERY; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @build java.net.http/jdk.internal.net.http.Http3ConnectionAccess - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors H3HeaderSizeLimitTest */ @@ -65,11 +64,11 @@ public class H3HeaderSizeLimitTest implements HttpServerAdapters { private static final long HEADER_SIZE_LIMIT_BYTES = 1024; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer h3Server; - private String requestURIBase; + private static HttpTestServer h3Server; + private static String requestURIBase; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { final QuicServer quicServer = Http3TestServer.quicServerBuilder() .sslContext(sslContext) .build(); @@ -82,8 +81,8 @@ public class H3HeaderSizeLimitTest implements HttpServerAdapters { .port(h3Server.getAddress().getPort()).build().toString(); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (h3Server != null) { System.out.println("Stopping server " + h3Server.getAddress()); h3Server.stop(); @@ -111,7 +110,7 @@ public class H3HeaderSizeLimitTest implements HttpServerAdapters { final HttpResponse response = client.send( reqBuilder.build(), BodyHandlers.discarding()); - Assert.assertEquals(response.statusCode(), 200, "Unexpected status code"); + Assertions.assertEquals(200, response.statusCode(), "Unexpected status code"); if (i == 3) { var cf = Http3ConnectionAccess.peerSettings(client, response); if (!cf.isDone()) { @@ -131,14 +130,14 @@ public class H3HeaderSizeLimitTest implements HttpServerAdapters { } final HttpRequest request = reqBuilder.build(); System.out.println("Issuing request to " + reqURI); - final IOException thrown = Assert.expectThrows(ProtocolException.class, + final IOException thrown = Assertions.assertThrows(ProtocolException.class, () -> client.send(request, BodyHandlers.discarding())); if (!thrown.getMessage().equals("Request headers size exceeds limit set by peer")) { throw thrown; } // test same with async System.out.println("Issuing async request to " + reqURI); - final ExecutionException asyncThrown = Assert.expectThrows(ExecutionException.class, + final ExecutionException asyncThrown = Assertions.assertThrows(ExecutionException.class, () -> client.sendAsync(request, BodyHandlers.discarding()).get()); if (!(asyncThrown.getCause() instanceof ProtocolException)) { System.err.println("Received unexpected cause"); diff --git a/test/jdk/java/net/httpclient/http3/H3HeadersEncoding.java b/test/jdk/java/net/httpclient/http3/H3HeadersEncoding.java index 44ccfac4a6a..6b7b24f049d 100644 --- a/test/jdk/java/net/httpclient/http3/H3HeadersEncoding.java +++ b/test/jdk/java/net/httpclient/http3/H3HeadersEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +27,7 @@ * @build jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.net.SimpleSSLContext * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.httpclient.qpack.encoderTableCapacityLimit=4096 + * @run junit/othervm -Djdk.httpclient.qpack.encoderTableCapacityLimit=4096 * -Djdk.httpclient.qpack.decoderMaxTableCapacity=4096 * -Dhttp3.test.server.encoderAllowedHeaders=* * -Dhttp3.test.server.decoderMaxTableCapacity=4096 @@ -40,9 +40,6 @@ import jdk.test.lib.RandomFactory; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -72,17 +69,21 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static jdk.httpclient.test.lib.common.HttpServerAdapters.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + public class H3HeadersEncoding { private static final int REQUESTS_COUNT = 500; private static final int HEADERS_PER_REQUEST = 20; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http3TestServer; - HeadersHandler serverHeadersHandler; - String http3URI; + private static HttpTestServer http3TestServer; + private static HeadersHandler serverHeadersHandler; + private static String http3URI; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { System.out.println("Creating servers"); http3TestServer = HttpTestServer.create(Http3DiscoveryMode.HTTP_3_URI_ONLY, sslContext); serverHeadersHandler = new HeadersHandler(); @@ -92,8 +93,8 @@ public class H3HeadersEncoding { http3TestServer.start(); } - @AfterTest - public void tearDown() { + @AfterAll + public static void tearDown() { http3TestServer.stop(); } @@ -272,7 +273,7 @@ public class H3HeadersEncoding { } - private class HeadersHandler implements HttpTestHandler { + private static class HeadersHandler implements HttpTestHandler { @Override public void handle(HttpTestExchange t) throws IOException { diff --git a/test/jdk/java/net/httpclient/http3/H3ImplicitPushCancel.java b/test/jdk/java/net/httpclient/http3/H3ImplicitPushCancel.java index 130ccd40cd6..570f84ad620 100644 --- a/test/jdk/java/net/httpclient/http3/H3ImplicitPushCancel.java +++ b/test/jdk/java/net/httpclient/http3/H3ImplicitPushCancel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * H3ImplicitPushCancel @@ -56,17 +56,18 @@ import java.util.concurrent.ConcurrentMap; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3ImplicitPushCancel implements HttpServerAdapters { - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -79,12 +80,12 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { ); static final String MAIN_RESPONSE_BODY = "the main response body"; - HttpTestServer server; - URI uri; - URI headURI; + private static HttpTestServer server; + private static URI uri; + private static URI headURI; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = HttpTestServer.create(ANY, SimpleSSLContext.findSSLContext()); HttpTestHandler pushHandler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); @@ -96,14 +97,14 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { headURI = new URI("https://" + server.serverAuthority() + "/head/x"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); return response; } @@ -111,8 +112,8 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(Version.HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } /* @@ -136,7 +137,7 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { .build(), BodyHandlers.ofString()) .thenApply(H3ImplicitPushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); System.out.println("Got result before error was raised"); throw new AssertionError("should have failed"); @@ -171,14 +172,14 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { promises.putIfAbsent(main.request(), CompletableFuture.completedFuture(main)); promises.forEach((request, value) -> { HttpResponse response = value.join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } }); - assertEquals(promises.size(), PUSH_PROMISES.size() + 1); + assertEquals(PUSH_PROMISES.size() + 1, promises.size()); promises.clear(); @@ -187,13 +188,13 @@ public class H3ImplicitPushCancel implements HttpServerAdapters { client.sendAsync(HttpRequest.newBuilder(uri).build(), BodyHandlers.ofString()) .thenApply(H3ImplicitPushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); } catch (CompletionException c) { throw new AssertionError(c.getCause()); } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); } } diff --git a/test/jdk/java/net/httpclient/http3/H3InsertionsLimitTest.java b/test/jdk/java/net/httpclient/http3/H3InsertionsLimitTest.java index ff38cd4fa98..6eabc23677a 100644 --- a/test/jdk/java/net/httpclient/http3/H3InsertionsLimitTest.java +++ b/test/jdk/java/net/httpclient/http3/H3InsertionsLimitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,13 +27,8 @@ import jdk.httpclient.test.lib.quic.QuicServer; import jdk.internal.net.http.http3.ConnectionSettings; import jdk.internal.net.http.qpack.Encoder; import jdk.internal.net.http.qpack.TableEntry; -import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -44,12 +39,16 @@ import java.net.http.HttpClient; import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; import java.net.http.HttpResponse.BodyHandlers; -import java.time.Duration; import java.util.concurrent.CountDownLatch; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary Verifies that the HTTP client respects the maxLiteralWithIndexing @@ -59,7 +58,7 @@ import static java.net.http.HttpOption.H3_DISCOVERY; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @build java.net.http/jdk.internal.net.http.Http3ConnectionAccess - * @run testng/othervm -Djdk.httpclient.qpack.encoderTableCapacityLimit=4096 + * @run junit/othervm -Djdk.httpclient.qpack.encoderTableCapacityLimit=4096 * -Djdk.internal.httpclient.qpack.allowBlockingEncoding=true * -Djdk.httpclient.qpack.decoderMaxTableCapacity=4096 * -Djdk.httpclient.qpack.decoderBlockedStreams=1024 @@ -75,8 +74,8 @@ public class H3InsertionsLimitTest implements HttpServerAdapters { private static final long HEADER_SIZE_LIMIT_BYTES = 8192; private static final long MAX_SERVER_DT_CAPACITY = 4096; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer h3Server; - private String requestURIBase; + private static HttpTestServer h3Server; + private static String requestURIBase; public static final long MAX_LITERALS_WITH_INDEXING = 32L; private static final CountDownLatch WAIT_FOR_FAILURE = new CountDownLatch(1); @@ -120,8 +119,8 @@ public class H3InsertionsLimitTest implements HttpServerAdapters { exchange.sendResponseHeaders(200, 0); } - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { final QuicServer quicServer = Http3TestServer.quicServerBuilder() .bindAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)) .sslContext(sslContext) @@ -138,8 +137,8 @@ public class H3InsertionsLimitTest implements HttpServerAdapters { .port(h3Server.getAddress().getPort()).build().toString(); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (h3Server != null) { System.out.println("Stopping server " + h3Server.getAddress()); h3Server.stop(); @@ -161,10 +160,10 @@ public class H3InsertionsLimitTest implements HttpServerAdapters { System.out.println("Issuing request to " + reqURI); try { client.send(request, BodyHandlers.discarding()); - Assert.fail("IOException expected"); + Assertions.fail("IOException expected"); } catch (IOException ioe) { System.out.println("Got IOException: " + ioe); - Assert.assertTrue(ioe.getMessage() + Assertions.assertTrue(ioe.getMessage() .contains("Too many literal with indexing")); } finally { WAIT_FOR_FAILURE.countDown(); diff --git a/test/jdk/java/net/httpclient/http3/H3LogHandshakeErrors.java b/test/jdk/java/net/httpclient/http3/H3LogHandshakeErrors.java index f7a258c069c..85a4b6113f0 100644 --- a/test/jdk/java/net/httpclient/http3/H3LogHandshakeErrors.java +++ b/test/jdk/java/net/httpclient/http3/H3LogHandshakeErrors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,8 @@ import java.io.IOException; import java.net.BindException; import java.net.ServerSocket; -import java.net.Socket; import java.net.URI; import java.net.http.HttpClient; -import java.net.http.HttpOption; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; @@ -44,16 +42,16 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.quic.QuicConnectionImpl; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -63,7 +61,7 @@ import static org.testng.Assert.*; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=errors * H3LogHandshakeErrors */ @@ -71,14 +69,14 @@ import static org.testng.Assert.*; public class H3LogHandshakeErrors implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer h3Server; - private ServerSocket tcpServerSocket = null; - private Thread tcpServerThread = null; - private String requestURI; + private static HttpTestServer h3Server; + private static ServerSocket tcpServerSocket = null; + private static Thread tcpServerThread = null; + private static String requestURI; private static Logger clientLogger; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { // create an H3 only server h3Server = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); h3Server.addHandler((exchange) -> exchange.sendResponseHeaders(200, 0), "/hello"); @@ -113,8 +111,8 @@ public class H3LogHandshakeErrors implements HttpServerAdapters { } } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (h3Server != null) { System.out.println("Stopping server " + h3Server.getAddress()); h3Server.stop(); diff --git a/test/jdk/java/net/httpclient/http3/H3MalformedResponseTest.java b/test/jdk/java/net/httpclient/http3/H3MalformedResponseTest.java index 5ef45f8b230..eaab2711479 100644 --- a/test/jdk/java/net/httpclient/http3/H3MalformedResponseTest.java +++ b/test/jdk/java/net/httpclient/http3/H3MalformedResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -458,7 +458,7 @@ class H3MalformedResponseTest { private static BooleanSupplier configureServerResponse(byte[] serverResponseBytes) { var connectionTerminated = new AtomicBoolean(); - SERVER.addHandler((c, s)-> { + SERVER.setHandler((c, s)-> { try (OutputStream outputStream = s.outputStream()) { outputStream.write(serverResponseBytes); } diff --git a/test/jdk/java/net/httpclient/http3/H3MaxInitialTimeoutTest.java b/test/jdk/java/net/httpclient/http3/H3MaxInitialTimeoutTest.java index 27eec672bcd..a93c6a37594 100644 --- a/test/jdk/java/net/httpclient/http3/H3MaxInitialTimeoutTest.java +++ b/test/jdk/java/net/httpclient/http3/H3MaxInitialTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,25 +39,29 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* @@ -68,15 +72,15 @@ import static org.testng.Assert.assertEquals; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.quic.QuicStandaloneServer - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors,quic:controls * -Djdk.httpclient.quic.maxInitialTimeout=1 * H3MaxInitialTimeoutTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors,quic:controls * -Djdk.httpclient.quic.maxInitialTimeout=2 * H3MaxInitialTimeoutTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors,quic:controls * -Djdk.httpclient.quic.maxInitialTimeout=2147483647 * H3MaxInitialTimeoutTest @@ -84,8 +88,8 @@ import static org.testng.Assert.assertEquals; public class H3MaxInitialTimeoutTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - DatagramChannel receiver; - String h3URI; + static DatagramChannel receiver; + static String h3URI; static final Executor executor = new TestExecutor(Executors.newVirtualThreadPerTaskExecutor()); static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); @@ -125,20 +129,37 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll static void printFailedTests() { out.println("\n========================="); try { @@ -159,13 +180,8 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { } } - @DataProvider(name = "h3URIs") - public Object[][] versions(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } - Object[][] result = {{h3URI}}; - return result; + public static Object[][] versions() { + return new Object[][] {{h3URI}}; } private HttpClient makeNewClient(long connectionTimeout) { @@ -180,7 +196,8 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { return client; } - @Test(dataProvider = "h3URIs") + @ParameterizedTest + @MethodSource("versions") public void testTimeout(final String h3URI) throws Exception { long timeout = Long.getLong("jdk.httpclient.quic.maxInitialTimeout", 30); long connectionTimeout = timeout == Integer.MAX_VALUE ? 2 : 10 * timeout; @@ -196,8 +213,8 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); out.println("Response #1: " + response); out.println("Version #1: " + response.version()); - assertEquals(response.statusCode(), 200, "first response status"); - assertEquals(response.version(), HTTP_3, "first response version"); + assertEquals(200, response.statusCode(), "first response status"); + assertEquals(HTTP_3, response.version(), "first response version"); throw new AssertionError("Expected ConnectException not thrown"); } catch (ConnectException c) { String msg = c.getMessage(); @@ -222,8 +239,8 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { receiver = DatagramChannel.open(); receiver.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); h3URI = URIBuilder.newBuilder() @@ -235,8 +252,8 @@ public class H3MaxInitialTimeoutTest implements HttpServerAdapters { .toString(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("======================================================="); System.err.println(" Tearing down test"); System.err.println("======================================================="); diff --git a/test/jdk/java/net/httpclient/http3/H3MemoryHandlingTest.java b/test/jdk/java/net/httpclient/http3/H3MemoryHandlingTest.java index c9474be51c2..0d107486fcd 100644 --- a/test/jdk/java/net/httpclient/http3/H3MemoryHandlingTest.java +++ b/test/jdk/java/net/httpclient/http3/H3MemoryHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,6 @@ import jdk.internal.net.http.quic.streams.QuicBidiStream; import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -52,7 +49,11 @@ import java.util.concurrent.TimeUnit; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -62,7 +63,7 @@ import static org.testng.Assert.*; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @build java.net.http/jdk.internal.net.http.Http3ConnectionAccess - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djdk.httpclient.quic.maxStreamInitialData=16384 @@ -71,11 +72,11 @@ import static org.testng.Assert.*; public class H3MemoryHandlingTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private QuicStandaloneServer server; - private String requestURIBase; + private static QuicStandaloneServer server; + private static String requestURIBase; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { server = QuicStandaloneServer.newBuilder() .availableVersions(new QuicVersion[]{QuicVersion.QUIC_V1}) .sslContext(sslContext) @@ -87,8 +88,8 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { .port(server.getAddress().getPort()).build().toString(); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (server != null) { System.out.println("Stopping server " + server.getAddress()); server.close(); @@ -108,7 +109,7 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { "00ffffffffffffffff"); // data, 2^62 - 1 bytes byte[] kilo = new byte[1024]; final CompletableFuture serverAllWritesDone = new CompletableFuture<>(); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { // verify that the connection stays open completeUponTermination(c, errorCF); try (OutputStream outputStream = s.outputStream()) { @@ -125,19 +126,16 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { serverAllWritesDone.complete(false); } }); - HttpClient client = getHttpClient(); - try { + try (HttpClient client = getHttpClient()) { HttpRequest request = getRequest(); final HttpResponse response1 = client.send( request, BodyHandlers.ofInputStream()); - assertEquals(response1.statusCode(), 200); + assertEquals(200, response1.statusCode()); assertFalse(errorCF.isDone(), "Expected the connection to be open"); assertFalse(serverAllWritesDone.isDone()); response1.body().close(); final boolean done = serverAllWritesDone.get(10, TimeUnit.SECONDS); assertFalse(done, "Too much data was buffered by the client"); - } finally { - client.close(); } } @@ -156,7 +154,7 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { byte[] kilo = new byte[1024]; CountDownLatch writerBlocked = new CountDownLatch(1); - server.addHandler((c,s)-> { + server.setHandler((c, s)-> { // verify that the connection stays open completeUponTermination(c, errorCF); QuicBidiStream qs = s.underlyingBidiStream(); @@ -176,12 +174,12 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { handlerCF.completeExceptionally(e); } }); - HttpClient client = getHttpClient(); - try { + + try (HttpClient client = getHttpClient()) { HttpRequest request = getRequest(); final HttpResponse response1 = client.send( - request, BodyHandlers.ofInputStream()); - assertEquals(response1.statusCode(), 200); + request, BodyHandlers.ofInputStream()); + assertEquals(200, response1.statusCode()); assertFalse(errorCF.isDone(), "Expected the connection to be open"); assertFalse(handlerCF.isDone()); assertTrue(writerBlocked.await(10, TimeUnit.SECONDS), @@ -191,10 +189,8 @@ public class H3MemoryHandlingTest implements HttpServerAdapters { try (InputStream body = response1.body()) { receivedResponse = body.readAllBytes(); } - assertEquals(receivedResponse.length, 32768, + assertEquals(32768, receivedResponse.length, "Unexpected response length"); - } finally { - client.close(); } assertTrue(handlerCF.get(10, TimeUnit.SECONDS), "Unexpected result"); diff --git a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java index 14149da7815..f9ba35359bc 100644 --- a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java +++ b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +29,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=90 * -Djdk.httpclient.quic.maxPtoBackoff=10 @@ -52,7 +55,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=45 * -Djdk.httpclient.quic.maxPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoff=9 @@ -75,10 +81,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError - * -Djdk.httpclient.quic.idleTimeout=120 - * -Djdk.httpclient.keepalive.timeout.h3=120 - * -Djdk.test.server.quic.idleTimeout=90 + * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=120 * -Djdk.httpclient.quic.maxPtoBackoff=9 @@ -100,10 +106,10 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError - * -Djdk.httpclient.quic.idleTimeout=120 - * -Djdk.httpclient.keepalive.timeout.h3=120 - * -Djdk.test.server.quic.idleTimeout=90 + * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=120 * -Djdk.httpclient.quic.maxPtoBackoff=9 @@ -161,14 +167,15 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; import static jdk.internal.net.http.Http3ClientProperties.MAX_STREAM_LIMIT_WAIT_TIMEOUT; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + public class H3MultipleConnectionsToSameHost implements HttpServerAdapters { static HttpTestServer httpsServer; static HttpClient client = null; @@ -223,11 +230,11 @@ public class H3MultipleConnectionsToSameHost implements HttpServerAdapters { } public static void main(String[] args) throws Exception { - test(); + new H3MultipleConnectionsToSameHost().test(); } @Test - public static void test() throws Exception { + public void test() throws Exception { try { long prestart = System.nanoTime(); initialize(); @@ -244,7 +251,7 @@ public class H3MultipleConnectionsToSameHost implements HttpServerAdapters { .GET().build(); long start = System.nanoTime(); var resp = client.send(request, BodyHandlers.ofByteArrayConsumer(b-> {})); - Assert.assertEquals(resp.statusCode(), 200); + Assertions.assertEquals(200, resp.statusCode()); long elapsed = System.nanoTime() - start; System.out.println("First request took: " + elapsed + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed) + " ms)"); final int max = property("simpleget.requests", 50); @@ -298,7 +305,7 @@ public class H3MultipleConnectionsToSameHost implements HttpServerAdapters { } } - list.forEach((cf) -> Assert.assertEquals(cf.join().statusCode(), 200)); + list.forEach((cf) -> Assertions.assertEquals(200, cf.join().statusCode())); client.close(); } catch (Throwable tt) { System.err.println("tt caught"); diff --git a/test/jdk/java/net/httpclient/http3/H3PushCancel.java b/test/jdk/java/net/httpclient/http3/H3PushCancel.java index 324942b67d0..b9e15b7d8e5 100644 --- a/test/jdk/java/net/httpclient/http3/H3PushCancel.java +++ b/test/jdk/java/net/httpclient/http3/H3PushCancel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * -Djdk.httpclient.http3.maxConcurrentPushStreams=5 @@ -69,18 +69,19 @@ import java.util.function.Function; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3PushCancel implements HttpServerAdapters { - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -93,13 +94,13 @@ public class H3PushCancel implements HttpServerAdapters { ); static final String MAIN_RESPONSE_BODY = "the main response body"; - HttpTestServer server; - URI uri; - URI headURI; - ServerPushHandler pushHandler; + private static HttpTestServer server; + private static URI uri; + private static URI headURI; + private static ServerPushHandler pushHandler; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = HttpTestServer.create(ANY, SimpleSSLContext.findSSLContext()); pushHandler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); server.addHandler(pushHandler, "/push/"); @@ -110,14 +111,14 @@ public class H3PushCancel implements HttpServerAdapters { headURI = new URI("https://" + server.serverAuthority() + "/head/x"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); return response; } @@ -125,8 +126,8 @@ public class H3PushCancel implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(Version.HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } @Test @@ -173,14 +174,14 @@ public class H3PushCancel implements HttpServerAdapters { promises.putIfAbsent(main.request(), CompletableFuture.completedFuture(main)); promises.forEach((request, value) -> { HttpResponse response = value.join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } }); - assertEquals(promises.size(), Math.min(PUSH_PROMISES.size(), maxPushes) + 1); + assertEquals(Math.min(PUSH_PROMISES.size(), maxPushes) + 1, promises.size()); promises.clear(); } @@ -190,12 +191,12 @@ public class H3PushCancel implements HttpServerAdapters { client.sendAsync(HttpRequest.newBuilder(uri).build(), BodyHandlers.ofString()) .thenApply(H3PushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); } catch (CompletionException c) { throw new AssertionError(c.getCause()); } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // Send with no promise handler, but use pushId bigger than allowed. // This should cause the connection to get closed @@ -207,7 +208,7 @@ public class H3PushCancel implements HttpServerAdapters { client.sendAsync(bigger, BodyHandlers.ofString()) .thenApply(H3PushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); throw new AssertionError("Expected IOException not thrown"); } catch (CompletionException c) { @@ -226,7 +227,7 @@ public class H3PushCancel implements HttpServerAdapters { throw new AssertionError("Unexpected exception: " + c.getCause(), c.getCause()); } } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // the next time around we should have a new connection // so we can restart from scratch @@ -315,16 +316,16 @@ public class H3PushCancel implements HttpServerAdapters { promises.putIfAbsent(main.request(), CompletableFuture.completedFuture(main)); promises.forEach((request, value) -> { HttpResponse response = value.join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } }); int expectedPushes = Math.min(PUSH_PROMISES.size(), maxPushes) + 1; if (i == 0) expectedPushes--; // pushId == 1 was cancelled - assertEquals(promises.size(), expectedPushes); + assertEquals(expectedPushes, promises.size()); promises.clear(); } @@ -334,12 +335,12 @@ public class H3PushCancel implements HttpServerAdapters { client.sendAsync(HttpRequest.newBuilder(uri).build(), BodyHandlers.ofString()) .thenApply(H3PushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); } catch (CompletionException c) { throw new AssertionError(c.getCause()); } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // Send with no promise handler, but use pushId bigger than allowed. // This should cause the connection to get closed @@ -351,7 +352,7 @@ public class H3PushCancel implements HttpServerAdapters { client.sendAsync(bigger, BodyHandlers.ofString()) .thenApply(H3PushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body ->assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body ->assertEquals(MAIN_RESPONSE_BODY, body)) .join(); throw new AssertionError("Expected IOException not thrown"); } catch (CompletionException c) { @@ -370,7 +371,7 @@ public class H3PushCancel implements HttpServerAdapters { throw new AssertionError("Unexpected exception: " + c.getCause(), c.getCause()); } } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // the next time around we should have a new connection // so we can restart from scratch @@ -379,7 +380,7 @@ public class H3PushCancel implements HttpServerAdapters { errors.forEach(t -> t.printStackTrace(System.out)); var error = errors.stream().findFirst().orElse(null); if (error != null) throw error; - assertEquals(notified.size(), 0, "Unexpected notification: " + notified); + assertEquals(0, notified.size(), "Unexpected notification: " + notified); } } diff --git a/test/jdk/java/net/httpclient/http3/H3RedirectTest.java b/test/jdk/java/net/httpclient/http3/H3RedirectTest.java index 0a5546bc1c1..67a7d99fa71 100644 --- a/test/jdk/java/net/httpclient/http3/H3RedirectTest.java +++ b/test/jdk/java/net/httpclient/http3/H3RedirectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +28,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.common.HttpServerAdapters * @compile ../ReferenceTracker.java - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=frames,ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * H3RedirectTest @@ -50,11 +50,12 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.Test; + public class H3RedirectTest implements HttpServerAdapters { static int httpPort; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); @@ -135,7 +136,7 @@ public class H3RedirectTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(); diff --git a/test/jdk/java/net/httpclient/http3/H3ServerPush.java b/test/jdk/java/net/httpclient/http3/H3ServerPush.java index 83f68a15579..50aa817b155 100644 --- a/test/jdk/java/net/httpclient/http3/H3ServerPush.java +++ b/test/jdk/java/net/httpclient/http3/H3ServerPush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +29,7 @@ * jdk.httpclient.test.lib.http2.PushHandler * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm/timeout=960 + * @run junit/othervm/timeout=960 * -Djdk.httpclient.HttpClient.log=errors,requests,headers * -Djdk.internal.httpclient.debug=false * H3ServerPush @@ -66,13 +66,14 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.PushHandler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static jdk.test.lib.Utils.createTempFileOfSize; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3ServerPush implements HttpServerAdapters { @@ -81,14 +82,14 @@ public class H3ServerPush implements HttpServerAdapters { static final int LOOPS = 13; static final int FILE_SIZE = 512 * 1024 + 343; - static Path tempFile; + private static Path tempFile; - HttpTestServer server; - URI uri; - URI headURI; + private static HttpTestServer server; + private static URI uri; + private static URI headURI; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { tempFile = createTempFileOfSize(CLASS_NAME, ".dat", FILE_SIZE); var sslContext = SimpleSSLContext.findSSLContext(); var h2Server = new Http2TestServer(true, sslContext); @@ -109,12 +110,12 @@ public class H3ServerPush implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(Version.HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } @@ -144,7 +145,7 @@ public class H3ServerPush implements HttpServerAdapters { resultMap.put(request, cf); System.out.println("waiting for response"); var resp = cf.join(); - assertEquals(resp.version(), Version.HTTP_3); + assertEquals(Version.HTTP_3, resp.version()); var seen = new HashSet<>(); resultMap.forEach((k, v) -> { if (seen.add(k)) { @@ -158,16 +159,16 @@ public class H3ServerPush implements HttpServerAdapters { for (HttpRequest r : resultMap.keySet()) { System.out.println("Checking " + r); HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); + assertEquals(tempFileAsString, response.body()); } resultMap.forEach((k, v) -> { if (seen.add(k)) { System.out.println("Got " + v.join()); } }); - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } } @@ -194,11 +195,11 @@ public class H3ServerPush implements HttpServerAdapters { System.err.println("results.size: " + resultMap.size()); for (HttpRequest r : resultMap.keySet()) { HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); + assertEquals(tempFileAsString, response.body()); } - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } } @@ -242,12 +243,12 @@ public class H3ServerPush implements HttpServerAdapters { resultsMap.put(request, cf); for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); String fileAsString = Files.readString(response.body()); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } @@ -274,12 +275,12 @@ public class H3ServerPush implements HttpServerAdapters { resultsMap.put(request, cf); for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); String fileAsString = Files.readString(response.body()); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } @@ -340,13 +341,13 @@ public class H3ServerPush implements HttpServerAdapters { resultsMap.put(request, cf); for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } @@ -384,13 +385,13 @@ public class H3ServerPush implements HttpServerAdapters { resultsMap.put(request, cf); for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), Version.HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(Version.HTTP_3, response.version()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } } diff --git a/test/jdk/java/net/httpclient/http3/H3ServerPushCancel.java b/test/jdk/java/net/httpclient/http3/H3ServerPushCancel.java index 312b9ac507d..b34e2a1567e 100644 --- a/test/jdk/java/net/httpclient/http3/H3ServerPushCancel.java +++ b/test/jdk/java/net/httpclient/http3/H3ServerPushCancel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * -Djdk.httpclient.http3.maxConcurrentPushStreams=45 @@ -73,9 +73,6 @@ import java.util.function.Supplier; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.common.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; @@ -83,10 +80,14 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.H3_DISCOVERY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3ServerPushCancel implements HttpServerAdapters { @@ -95,7 +96,7 @@ public class H3ServerPushCancel implements HttpServerAdapters { static final PrintStream err = System.err; static final PrintStream out = System.out; - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -109,13 +110,13 @@ public class H3ServerPushCancel implements HttpServerAdapters { static final String MAIN_RESPONSE_BODY = "the main response body"; static final int REQUESTS = 5; - HttpTestServer server; - URI uri; - URI headURI; - ServerPushHandler pushHandler; + private static HttpTestServer server; + private static URI uri; + private static URI headURI; + private static ServerPushHandler pushHandler; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = HttpTestServer.create(ANY, SimpleSSLContext.findSSLContext()); pushHandler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); server.addHandler(pushHandler, "/push/"); @@ -126,14 +127,14 @@ public class H3ServerPushCancel implements HttpServerAdapters { headURI = new URI("https://" + server.serverAuthority() + "/head/x"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); - assertEquals(response.version(), HTTP_3); + assertEquals(200, response.statusCode()); + assertEquals(HTTP_3, response.version()); return response; } @@ -141,8 +142,8 @@ public class H3ServerPushCancel implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(HTTP_2, headResponse.version()); } static final class TestPushPromiseHandler implements PushPromiseHandler { @@ -283,14 +284,14 @@ public class H3ServerPushCancel implements HttpServerAdapters { throw new AssertionError("Unexpected message: " + msg, ex); } } else { - assertEquals(join(value).body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), join(value).body()); } expectedPushIds.add(pushId); - } else assertEquals(pushId.getClass(), Http3PushId.class); + } else assertEquals(Http3PushId.class, pushId.getClass()); } else { HttpResponse response = join(value); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(200, response.statusCode()); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } }); @@ -311,12 +312,12 @@ public class H3ServerPushCancel implements HttpServerAdapters { client.sendAsync(HttpRequest.newBuilder(uri).build(), BodyHandlers.ofString()) .thenApply(H3ServerPushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); } catch (CompletionException c) { throw new AssertionError(c.getCause()); } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // Send with no promise handler, but use pushId bigger than allowed. // This should cause the connection to get closed @@ -328,7 +329,7 @@ public class H3ServerPushCancel implements HttpServerAdapters { client.sendAsync(bigger, BodyHandlers.ofString()) .thenApply(H3ServerPushCancel::assert200ResponseCode) .thenApply(HttpResponse::body) - .thenAccept(body -> assertEquals(body, MAIN_RESPONSE_BODY)) + .thenAccept(body -> assertEquals(MAIN_RESPONSE_BODY, body)) .join(); throw new AssertionError("Expected IOException not thrown"); } catch (CompletionException c) { @@ -347,7 +348,7 @@ public class H3ServerPushCancel implements HttpServerAdapters { throw new AssertionError("Unexpected exception: " + c.getCause(), c.getCause()); } } - assertEquals(promises.size(), 0); + assertEquals(0, promises.size()); // the next time around we should have a new connection, // so we can restart from scratch @@ -408,7 +409,7 @@ public class H3ServerPushCancel implements HttpServerAdapters { // excluding those that got cancelled, // we should have received REQUEST-1 notifications // per push promise and per connection - assertEquals(count, (PUSH_PROMISES.size()-3)*2*(REQUESTS-1), + assertEquals((PUSH_PROMISES.size()-3)*2*(REQUESTS-1), count, "Unexpected notification: " + notified); } } diff --git a/test/jdk/java/net/httpclient/http3/H3ServerPushWithDiffTypes.java b/test/jdk/java/net/httpclient/http3/H3ServerPushWithDiffTypes.java index d00012826ef..a863db43c29 100644 --- a/test/jdk/java/net/httpclient/http3/H3ServerPushWithDiffTypes.java +++ b/test/jdk/java/net/httpclient/http3/H3ServerPushWithDiffTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses * H3ServerPushWithDiffTypes @@ -65,11 +65,12 @@ import java.util.function.BiPredicate; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class H3ServerPushWithDiffTypes implements HttpServerAdapters { @@ -89,8 +90,8 @@ public class H3ServerPushWithDiffTypes implements HttpServerAdapters { HttpRequest headRequest = HttpRequest.newBuilder(headURI) .HEAD().version(Version.HTTP_2).build(); var headResponse = client.send(headRequest, BodyHandlers.ofString()); - assertEquals(headResponse.statusCode(), 200); - assertEquals(headResponse.version(), Version.HTTP_2); + assertEquals(200, headResponse.statusCode()); + assertEquals(Version.HTTP_2, headResponse.version()); } @Test @@ -127,13 +128,13 @@ public class H3ServerPushWithDiffTypes implements HttpServerAdapters { results.put(request, cf); cf.join(); - assertEquals(results.size(), PUSH_PROMISES.size() + 1); + assertEquals(PUSH_PROMISES.size() + 1, results.size()); for (HttpRequest r : results.keySet()) { URI u = r.uri(); var resp = results.get(r).get(); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.version(), Version.HTTP_3); + assertEquals(200, resp.statusCode()); + assertEquals(Version.HTTP_3, resp.version()); BodyAndType body = resp.body(); String result; // convert all body types to String for easier comparison @@ -153,7 +154,7 @@ public class H3ServerPushWithDiffTypes implements HttpServerAdapters { String expected = PUSH_PROMISES.get(r.uri().getPath()); if (expected == null) expected = "the main response body"; - assertEquals(result, expected); + assertEquals(expected, result); } } } diff --git a/test/jdk/java/net/httpclient/http3/H3SimpleGet.java b/test/jdk/java/net/httpclient/http3/H3SimpleGet.java index 3745c32afbf..ae113322cd3 100644 --- a/test/jdk/java/net/httpclient/http3/H3SimpleGet.java +++ b/test/jdk/java/net/httpclient/http3/H3SimpleGet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,14 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.httpclient.retryOnStreamlimit=20 * -Djdk.httpclient.redirects.retrylimit=21 * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 * -Djdk.httpclient.retryOnStreamlimit=5 @@ -53,14 +53,14 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.httpclient.retryOnStreamlimit=20 * -Djdk.httpclient.redirects.retrylimit=21 * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 * -Djdk.httpclient.retryOnStreamlimit=5 @@ -77,16 +77,16 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations * -Djdk.httpclient.retryOnStreamlimit=20 * -Djdk.httpclient.redirects.retrylimit=21 * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations * -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 @@ -103,16 +103,16 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * -Djdk.httpclient.retryOnStreamlimit=20 * -Djdk.httpclient.redirects.retrylimit=21 * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 @@ -129,16 +129,16 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * -Djdk.httpclient.retryOnStreamlimit=20 * -Djdk.httpclient.redirects.retrylimit=21 * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * H3SimpleGet - * @run testng/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError + * @run junit/othervm/timeout=480 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError * -Djdk.internal.httpclient.quic.useNioSelector=true * -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 @@ -154,7 +154,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 -Djdk.internal.httpclient.quic.congestionController=reno + * @run junit/othervm/timeout=480 -Djdk.internal.httpclient.quic.congestionController=reno * H3SimpleGet * @summary send multiple GET requests using Reno congestion controller */ @@ -198,13 +198,14 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + public class H3SimpleGet implements HttpServerAdapters { static HttpTestServer httpsServer; static HttpClient client = null; @@ -261,13 +262,13 @@ public class H3SimpleGet implements HttpServerAdapters { } public static void main(String[] args) throws Exception { - test(); + new H3SimpleGet().test(); } static volatile boolean waitBeforeTest = false; @Test - public static void test() throws Exception { + public void test() throws Exception { try { if (waitBeforeTest) { Thread.sleep(20000); @@ -283,7 +284,7 @@ public class H3SimpleGet implements HttpServerAdapters { .GET().build(); long start = System.nanoTime(); var resp = client.send(request, BodyHandlers.ofByteArrayConsumer(b-> {})); - Assert.assertEquals(resp.statusCode(), 200); + Assertions.assertEquals(200, resp.statusCode()); long elapsed = System.nanoTime() - start; System.out.println("Stat: First request took: " + elapsed + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed) + " ms)"); @@ -314,7 +315,7 @@ public class H3SimpleGet implements HttpServerAdapters { + connections.size() + " connections"); } } - list.forEach((cf) -> Assert.assertEquals(cf.join().statusCode(), 200)); + list.forEach((cf) -> Assertions.assertEquals(200, cf.join().statusCode())); } catch (Throwable tt) { System.err.println("tt caught"); tt.printStackTrace(); diff --git a/test/jdk/java/net/httpclient/http3/H3SimplePost.java b/test/jdk/java/net/httpclient/http3/H3SimplePost.java index 4cf46988873..0294f2f69da 100644 --- a/test/jdk/java/net/httpclient/http3/H3SimplePost.java +++ b/test/jdk/java/net/httpclient/http3/H3SimplePost.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=480 H3SimplePost + * @run junit/othervm/timeout=480 H3SimplePost */ // -Djdk.httpclient.HttpClient.log=requests,errors,quic // -Djdk.httpclient.quic.defaultMTU=64000 @@ -37,8 +37,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -61,6 +59,9 @@ import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + public class H3SimplePost implements HttpServerAdapters { static HttpTestServer httpsServer; static HttpClient client = null; @@ -115,11 +116,11 @@ public class H3SimplePost implements HttpServerAdapters { } public static void main(String[] args) throws Exception { - test(); + new H3SimplePost().test(); } @Test - public static void test() throws Exception { + public void test() throws Exception { try { long prestart = System.nanoTime(); initialize(); @@ -140,7 +141,7 @@ public class H3SimplePost implements HttpServerAdapters { .build(); long start = System.nanoTime(); var resp = client.send(getRequest, BodyHandlers.ofByteArrayConsumer(b-> {})); - Assert.assertEquals(resp.statusCode(), 200); + Assertions.assertEquals(200, resp.statusCode()); long elapsed = System.nanoTime() - start; System.out.println("First GET request took: " + elapsed + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed) + " ms)"); final int max = 50; @@ -155,7 +156,7 @@ public class H3SimplePost implements HttpServerAdapters { System.out.println("Next " + max + " POST requests took: " + elapsed2 + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed2) + "ms for " + max + " requests): " + elapsed2 / max + " nanos per request (" + TimeUnit.NANOSECONDS.toMillis(elapsed2) / max + " ms)"); - list.forEach((cf) -> Assert.assertEquals(cf.join().statusCode(), 200)); + list.forEach((cf) -> Assertions.assertEquals(200, cf.join().statusCode())); } catch (Throwable tt) { System.err.println("tt caught"); tt.printStackTrace(); diff --git a/test/jdk/java/net/httpclient/http3/H3SimpleTest.java b/test/jdk/java/net/httpclient/http3/H3SimpleTest.java index 1880d436501..4258f3bac73 100644 --- a/test/jdk/java/net/httpclient/http3/H3SimpleTest.java +++ b/test/jdk/java/net/httpclient/http3/H3SimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,16 +32,17 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary Basic test to verify that simple GET/POST/HEAD @@ -50,21 +51,21 @@ import static java.net.http.HttpOption.H3_DISCOVERY; * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * H3SimpleTest - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djava.net.preferIPv6Addresses=true * H3SimpleTest - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djava.net.preferIPv4Stack=true * H3SimpleTest - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * -Djdk.internal.httpclient.quic.congestionController=reno @@ -74,11 +75,11 @@ import static java.net.http.HttpOption.H3_DISCOVERY; public class H3SimpleTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer h3Server; - private String requestURI; + private static HttpTestServer h3Server; + private static String requestURI; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { // create an H3 only server h3Server = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); h3Server.addHandler((exchange) -> exchange.sendResponseHeaders(200, 0), "/hello"); @@ -87,8 +88,8 @@ public class H3SimpleTest implements HttpServerAdapters { requestURI = "https://" + h3Server.serverAuthority() + "/hello"; } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (h3Server != null) { System.out.println("Stopping server " + h3Server.getAddress()); h3Server.stop(); @@ -113,18 +114,18 @@ public class H3SimpleTest implements HttpServerAdapters { final HttpRequest req1 = reqBuilder.copy().GET().build(); System.out.println("Issuing request: " + req1); final HttpResponse resp1 = client.send(req1, BodyHandlers.discarding()); - Assert.assertEquals(resp1.statusCode(), 200, "unexpected response code for GET request"); + Assertions.assertEquals(200, resp1.statusCode(), "unexpected response code for GET request"); // POST final HttpRequest req2 = reqBuilder.copy().POST(BodyPublishers.ofString("foo")).build(); System.out.println("Issuing request: " + req2); final HttpResponse resp2 = client.send(req2, BodyHandlers.discarding()); - Assert.assertEquals(resp2.statusCode(), 200, "unexpected response code for POST request"); + Assertions.assertEquals(200, resp2.statusCode(), "unexpected response code for POST request"); // HEAD final HttpRequest req3 = reqBuilder.copy().HEAD().build(); System.out.println("Issuing request: " + req3); final HttpResponse resp3 = client.send(req3, BodyHandlers.discarding()); - Assert.assertEquals(resp3.statusCode(), 200, "unexpected response code for HEAD request"); + Assertions.assertEquals(200, resp3.statusCode(), "unexpected response code for HEAD request"); } } diff --git a/test/jdk/java/net/httpclient/http3/H3StopSendingTest.java b/test/jdk/java/net/httpclient/http3/H3StopSendingTest.java index 5b017c15d9b..86b12a1dae6 100644 --- a/test/jdk/java/net/httpclient/http3/H3StopSendingTest.java +++ b/test/jdk/java/net/httpclient/http3/H3StopSendingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Verifies that the client reacts correctly to the receipt of a STOP_SENDING frame. * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm/timeout=40 -Djdk.internal.httpclient.debug=true -Djdk.httpclient.HttpClient.log=trace,errors,headers + * @run junit/othervm/timeout=40 -Djdk.internal.httpclient.debug=true -Djdk.httpclient.HttpClient.log=trace,errors,headers * H3StopSendingTest */ @@ -35,9 +35,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestHandler; import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestServer; import jdk.test.lib.net.SimpleSSLContext; import jdk.internal.net.http.http3.Http3Error; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -53,14 +50,18 @@ import java.util.concurrent.ExecutionException; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class H3StopSendingTest { - HttpTestServer h3TestServer; - HttpRequest postRequestNoError, postRequestError; - HttpRequest postRequestNoErrorWithData, postRequestErrorWithData; - URI h3TestServerUriNoError, h3TestServerUriError; + private static HttpTestServer h3TestServer; + private static HttpRequest postRequestNoError, postRequestError; + private static HttpRequest postRequestNoErrorWithData, postRequestErrorWithData; + private static URI h3TestServerUriNoError, h3TestServerUriError; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); static final String TEST_ROOT_PATH = "/h3_stop_sending_test"; @@ -81,13 +82,13 @@ public class H3StopSendingTest { err.println(resp.headers()); err.println(resp.body()); err.println(resp.statusCode()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); resp = client.sendAsync(postRequestNoErrorWithData, HttpResponse.BodyHandlers.ofString()).get(); err.println(resp.headers()); err.println(resp.body()); err.println(resp.statusCode()); - assertEquals(resp.statusCode(), 200); - assertEquals(resp.body(), RESPONSE_MESSAGE.repeat(MESSAGE_REPEAT)); + assertEquals(200, resp.statusCode()); + assertEquals(RESPONSE_MESSAGE.repeat(MESSAGE_REPEAT), resp.body()); } } @@ -125,8 +126,8 @@ public class H3StopSendingTest { } } - @BeforeTest - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { h3TestServer = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); h3TestServer.addHandler(new ServerRequestStopSendingHandler(), TEST_ROOT_PATH); @@ -162,8 +163,8 @@ public class H3StopSendingTest { .build(); } - @AfterTest - public void afterTest() { + @AfterAll + public static void afterTest() { h3TestServer.stop(); } diff --git a/test/jdk/java/net/httpclient/http3/H3StreamLimitReachedTest.java b/test/jdk/java/net/httpclient/http3/H3StreamLimitReachedTest.java index a4524b9ae5e..1ac4a750d77 100644 --- a/test/jdk/java/net/httpclient/http3/H3StreamLimitReachedTest.java +++ b/test/jdk/java/net/httpclient/http3/H3StreamLimitReachedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -46,7 +46,7 @@ * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:control + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:control * -Djdk.internal.httpclient.debug=false * -Djdk.internal.httpclient.quic.maxBidiStreams=1 * H3StreamLimitReachedTest @@ -77,7 +77,7 @@ * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:control + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors,http3,quic:control * -Djdk.internal.httpclient.debug=false * -Djdk.internal.httpclient.quic.maxBidiStreams=1 * -Djdk.httpclient.http3.maxStreamLimitTimeout=0 @@ -114,7 +114,6 @@ import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; @@ -125,7 +124,9 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static jdk.test.lib.Asserts.assertEquals; import static jdk.test.lib.Asserts.assertNotEquals; import static jdk.test.lib.Asserts.assertTrue; -import static org.testng.Assert.assertFalse; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.Test; public class H3StreamLimitReachedTest implements HttpServerAdapters { @@ -329,7 +330,7 @@ public class H3StreamLimitReachedTest implements HttpServerAdapters { } @Test - public static void testH3Only() throws Exception { + public void testH3Only() throws Exception { System.out.println("\nTesting HTTP/3 only"); initialize(true); try (HttpClient client = getClient()) { @@ -402,12 +403,12 @@ public class H3StreamLimitReachedTest implements HttpServerAdapters { } @Test - public static void testH2H3WithTwoAltSVC() throws Exception { + public void testH2H3WithTwoAltSVC() throws Exception { testH2H3(false); } @Test - public static void testH2H3WithAltSVCOnSamePort() throws Exception { + public void testH2H3WithAltSVCOnSamePort() throws Exception { testH2H3(true); } @@ -627,12 +628,12 @@ public class H3StreamLimitReachedTest implements HttpServerAdapters { } @Test - public static void testParallelH2H3WithTwoAltSVC() throws Exception { + public void testParallelH2H3WithTwoAltSVC() throws Exception { testH2H3Concurrent(false); } @Test - public static void testParallelH2H3WithAltSVCOnSamePort() throws Exception { + public void testParallelH2H3WithAltSVCOnSamePort() throws Exception { testH2H3Concurrent(true); } diff --git a/test/jdk/java/net/httpclient/http3/HTTP3NoBodyTest.java b/test/jdk/java/net/httpclient/http3/HTTP3NoBodyTest.java index 601e40c7dc6..b43ce8dcf79 100644 --- a/test/jdk/java/net/httpclient/http3/HTTP3NoBodyTest.java +++ b/test/jdk/java/net/httpclient/http3/HTTP3NoBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +29,7 @@ * jdk.httpclient.test.lib.http3.Http3TestServer * jdk.httpclient.test.lib.common.HttpServerAdapters * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * HTTP3NoBodyTest * @summary this is a copy of http2/NoBodyTest over HTTP/3 @@ -38,8 +38,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.*; -import javax.net.ssl.*; +import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpHeaders; import java.net.http.HttpRequest; @@ -48,9 +47,12 @@ import java.net.http.HttpOption.Http3DiscoveryMode; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.util.Random; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import javax.net.ssl.SSLContext; + import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; @@ -58,7 +60,6 @@ import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.RandomFactory; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; @@ -66,7 +67,8 @@ import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; -@Test +import org.junit.jupiter.api.Test; + public class HTTP3NoBodyTest { private static final Random RANDOM = RandomFactory.getRandom(); @@ -119,7 +121,7 @@ public class HTTP3NoBodyTest { } @Test - public static void runtest() throws Exception { + public void runtest() throws Exception { try { initialize(); warmup(false); diff --git a/test/jdk/java/net/httpclient/http3/Http3ExpectContinueTest.java b/test/jdk/java/net/httpclient/http3/Http3ExpectContinueTest.java index 53ce6a68d38..1cf6900ed5d 100644 --- a/test/jdk/java/net/httpclient/http3/Http3ExpectContinueTest.java +++ b/test/jdk/java/net/httpclient/http3/Http3ExpectContinueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +27,7 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @compile ../ReferenceTracker.java * @build jdk.httpclient.test.lib.common.HttpServerAdapters - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,headers * Http3ExpectContinueTest */ @@ -36,11 +36,6 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http3.Http3TestServer; import jdk.httpclient.test.lib.quic.QuicServer; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.TestException; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -60,15 +55,20 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import static java.net.http.HttpClient.Version.HTTP_3; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class Http3ExpectContinueTest implements HttpServerAdapters { - ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - Http3TestServer http3TestServer; + private static Http3TestServer http3TestServer; - URI h3postUri, h3forcePostUri, h3hangUri; + private static URI h3postUri, h3forcePostUri, h3hangUri; static PrintStream err = new PrintStream(System.err); static PrintStream out = new PrintStream(System.out); @@ -78,8 +78,7 @@ public class Http3ExpectContinueTest implements HttpServerAdapters { static final String BODY = "Post body"; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - @DataProvider(name = "uris") - public Object[][] urisData() { + public static Object[][] urisData() { return new Object[][]{ // URI, Expected Status Code, Will finish with Exception { h3postUri, 200, false }, @@ -88,7 +87,8 @@ public class Http3ExpectContinueTest implements HttpServerAdapters { }; } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("urisData") public void test(URI uri, int expectedStatusCode, boolean exceptionally) throws CancellationException, InterruptedException, ExecutionException, IOException { @@ -149,8 +149,8 @@ public class Http3ExpectContinueTest implements HttpServerAdapters { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { final QuicServer quicServer = Http3TestServer.quicServerBuilder() .sslContext(sslContext) .build(); @@ -167,8 +167,8 @@ public class Http3ExpectContinueTest implements HttpServerAdapters { http3TestServer.start(); } - @AfterTest - public void teardown() throws IOException { + @AfterAll + public static void teardown() throws IOException { var error = TRACKER.check(500); if (error != null) throw error; http3TestServer.stop(); @@ -233,11 +233,11 @@ public class Http3ExpectContinueTest implements HttpServerAdapters { } if (exceptionally && testThrowable != null) { err.println("Finished exceptionally Test throwable: " + testThrowable); - assertEquals(IOException.class, testThrowable.getClass()); + assertEquals(testThrowable.getClass(), IOException.class); } else if (exceptionally) { - throw new TestException("Expected case to finish with an IOException but testException is null"); + fail("Expected case to finish with an IOException but testException is null"); } else if (resp != null) { - assertEquals(resp.statusCode(), expectedStatusCode); + assertEquals(expectedStatusCode, resp.statusCode()); err.println("Request completed successfully for path " + path); err.println("Response Headers: " + resp.headers()); err.println("Response Status Code: " + resp.statusCode()); diff --git a/test/jdk/java/net/httpclient/http3/PeerUniStreamDispatcherTest.java b/test/jdk/java/net/httpclient/http3/PeerUniStreamDispatcherTest.java index be1b8304bf1..fc6d43bb472 100644 --- a/test/jdk/java/net/httpclient/http3/PeerUniStreamDispatcherTest.java +++ b/test/jdk/java/net/httpclient/http3/PeerUniStreamDispatcherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +23,7 @@ /* * @test - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=out * PeerUniStreamDispatcherTest * @summary Unit test for the PeerUniStreamDispatcher @@ -45,8 +45,8 @@ import jdk.internal.net.http.quic.streams.QuicReceiverStream; import jdk.internal.net.http.quic.streams.QuicStreamReader; import jdk.internal.net.http.quic.streams.QuicStreams; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class PeerUniStreamDispatcherTest { @@ -301,7 +301,7 @@ public class PeerUniStreamDispatcherTest { assertTrue(reader.connected()); int size = VariableLengthEncoder.getEncodedSize(code); ByteBuffer buffer = ByteBuffer.allocate(size); - assertEquals(buffer.remaining(), size); + assertEquals(size, buffer.remaining()); VariableLengthEncoder.encode(buffer, code); buffer.flip(); stream.buffers.add(buffer); @@ -313,7 +313,7 @@ public class PeerUniStreamDispatcherTest { // will loop correctly. size = VariableLengthEncoder.getEncodedSize(1L << 62 - 5); ByteBuffer buffer2 = ByteBuffer.allocate(size); - assertEquals(buffer2.remaining(), size); + assertEquals(size, buffer2.remaining()); VariableLengthEncoder.encode(buffer2, 1L << 62 - 5); buffer2.flip(); stream.buffers.add(ByteBuffer.wrap(new byte[] {buffer2.get()})); @@ -328,7 +328,7 @@ public class PeerUniStreamDispatcherTest { assertFalse(reader.connected()); assertFalse(dispatcher.dispatched.isEmpty()); assertTrue(stream.buffers.isEmpty()); - assertEquals(dispatcher.dispatched.size(), 1); + assertEquals(1, dispatcher.dispatched.size()); var dispatched = dispatcher.dispatched.get(0); checkDispatched(type, code, stream, dispatched); } @@ -343,30 +343,30 @@ public class PeerUniStreamDispatcherTest { case RESERVED -> DispatchedStream.ReservedStream.class; case UNKNOWN -> DispatchedStream.UnknownStream.class; }; - assertEquals(dispatched.getClass(), streamClass, + assertEquals(streamClass, dispatched.getClass(), "unexpected dispatched class " + dispatched + " for " + type); if (dispatched instanceof DispatchedStream.StandardStream st) { System.out.println("Got expected stream: " + st); - assertEquals(st.type(), type); - assertEquals(st.stream, stream); + assertEquals(type, st.type()); + assertEquals(stream, st.stream); } else if (dispatched instanceof DispatchedStream.ReservedStream res) { System.out.println("Got expected stream: " + res); - assertEquals(res.type(), type); - assertEquals(res.stream, stream); - assertEquals(res.code(), code); + assertEquals(type, res.type()); + assertEquals(stream, res.stream); + assertEquals(code, res.code()); assertTrue(Http3Streams.isReserved(res.code())); } else if (dispatched instanceof DispatchedStream.UnknownStream unk) { System.out.println("Got expected stream: " + unk); - assertEquals(unk.type(), type); - assertEquals(unk.stream, stream); - assertEquals(unk.code(), code); + assertEquals(type, unk.type()); + assertEquals(stream, unk.stream); + assertEquals(code, unk.code()); assertFalse(Http3Streams.isReserved(unk.code())); } else if (dispatched instanceof DispatchedStream.PushStream push) { System.out.println("Got expected stream: " + push); - assertEquals(push.type(), type); - assertEquals(push.stream, stream); - assertEquals(push.pushId, 1L << 62 - 5); - assertEquals(push.type(), DISPATCHED_STREAM.PUSH); + assertEquals(type, push.type()); + assertEquals(stream, push.stream); + assertEquals(1L << 62 - 5, push.pushId); + assertEquals(DISPATCHED_STREAM.PUSH, push.type()); } } @@ -406,9 +406,9 @@ public class PeerUniStreamDispatcherTest { SequentialScheduler scheduler = stream.scheduler; assertTrue(reader.connected()); int size = VariableLengthEncoder.getEncodedSize(code); - assertEquals(size, 8); + assertEquals(8, size); ByteBuffer buffer = ByteBuffer.allocate(size); - assertEquals(buffer.remaining(), size); + assertEquals(size, buffer.remaining()); VariableLengthEncoder.encode(buffer, code); buffer.flip(); dispatcher.start(); @@ -428,7 +428,7 @@ public class PeerUniStreamDispatcherTest { assertFalse(reader.connected()); assertFalse(dispatcher.dispatched.isEmpty()); assertTrue(stream.buffers.isEmpty()); - assertEquals(dispatcher.dispatched.size(), 1); + assertEquals(1, dispatcher.dispatched.size()); var dispatched = dispatcher.dispatched.get(0); checkDispatched(type, code, stream, dispatched); } diff --git a/test/jdk/java/net/httpclient/http3/PostHTTP3Test.java b/test/jdk/java/net/httpclient/http3/PostHTTP3Test.java index 90f2c41f4e5..1f109e27ebc 100644 --- a/test/jdk/java/net/httpclient/http3/PostHTTP3Test.java +++ b/test/jdk/java/net/httpclient/http3/PostHTTP3Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,6 +49,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import javax.net.ssl.SSLContext; @@ -56,24 +57,25 @@ import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.ITestContext; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.Http3DiscoveryMode.ALT_SVC; import static java.net.http.HttpOption.Http3DiscoveryMode.ANY; import static java.net.http.HttpOption.H3_DISCOVERY; -import static org.testng.Assert.*; - +import static org.junit.jupiter.api.Assertions.*; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestWatcher; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + /* * @test * @library /test/lib /test/jdk/java/net/httpclient/lib @@ -81,7 +83,7 @@ import static java.lang.System.out; * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.test.lib.Utils * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * PostHTTP3Test * @summary Basic HTTP/3 POST test @@ -97,8 +99,8 @@ public class PostHTTP3Test implements HttpServerAdapters { """; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) - String h3URI; + static HttpTestServer h3TestServer; // HTTP/2 ( h2 + h3) + static String h3URI; static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test @@ -116,10 +118,10 @@ public class PostHTTP3Test implements HttpServerAdapters { return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); } - final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; - final Set sharedClientHasH3 = ConcurrentHashMap.newKeySet(); - private volatile HttpClient sharedClient; - private boolean directQuicConnectionSupported; + private static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private static final Set sharedClientHasH3 = ConcurrentHashMap.newKeySet(); + private static volatile HttpClient sharedClient; + private static boolean directQuicConnectionSupported; static class TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong(); @@ -145,20 +147,37 @@ public class PostHTTP3Test implements HttpServerAdapters { } } - protected boolean stopAfterFirstFailure() { + private static boolean stopAfterFirstFailure() { return Boolean.getBoolean("jdk.internal.httpclient.debug"); } - @BeforeMethod - void beforeMethod(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - var x = new SkipException("Skipping: some test failed"); - x.setStackTrace(new StackTraceElement[0]); - throw x; + static final class TestStopper implements TestWatcher, BeforeEachCallback { + final AtomicReference failed = new AtomicReference<>(); + TestStopper() { } + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (stopAfterFirstFailure()) { + String msg = "Aborting due to: " + cause; + failed.compareAndSet(null, msg); + FAILURES.putIfAbsent(context.getDisplayName(), cause); + System.out.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + System.err.printf("%nTEST FAILED: %s%s%n\tAborting due to %s%n%n", + now(), context.getDisplayName(), cause); + } + } + + @Override + public void beforeEach(ExtensionContext context) { + String msg = failed.get(); + Assumptions.assumeTrue(msg == null, msg); } } - @AfterClass + @RegisterExtension + static final TestStopper stopper = new TestStopper(); + + @AfterAll static void printFailedTests() { out.println("\n========================="); try { @@ -179,24 +198,20 @@ public class PostHTTP3Test implements HttpServerAdapters { } } - private String[] uris() { + private static String[] uris() { return new String[] { h3URI, }; } - @DataProvider(name = "variants") - public Object[][] variants(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } + public static Object[][] variants() { String[] uris = uris(); Object[][] result = new Object[uris.length * 2 * 2 * 2][]; int i = 0; for (var version : List.of(Optional.empty(), Optional.of(HTTP_3))) { for (Version firstRequestVersion : List.of(HTTP_2, HTTP_3)) { for (boolean sameClient : List.of(false, true)) { - for (String uri : uris()) { + for (String uri : uris) { result[i++] = new Object[]{uri, firstRequestVersion, sameClient, version}; } } @@ -206,15 +221,6 @@ public class PostHTTP3Test implements HttpServerAdapters { return result; } - @DataProvider(name = "uris") - public Object[][] uris(ITestContext context) { - if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { - return new Object[0][]; - } - Object[][] result = {{h3URI}}; - return result; - } - private HttpClient makeNewClient() { clientCount.incrementAndGet(); HttpClient client = newClientBuilderForH3() @@ -259,7 +265,8 @@ public class PostHTTP3Test implements HttpServerAdapters { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testAsync(String uri, Version firstRequestVersion, boolean sameClient, Optional version) throws Exception { System.out.println("Request to " + uri +"/Async/*" + ", firstRequestVersion=" + firstRequestVersion + @@ -287,17 +294,17 @@ public class PostHTTP3Test implements HttpServerAdapters { } HttpResponse response1 = client.send(headBuilder.build(), BodyHandlers.ofString()); - assertEquals(response1.statusCode(), 200, "Unexpected first response code"); - assertEquals(response1.body(), "", "Unexpected first response body"); + assertEquals(200, response1.statusCode(), "Unexpected first response code"); + assertEquals("", response1.body(), "Unexpected first response body"); boolean expectH3 = sameClient && sharedClientHasH3.contains(headURI.getRawAuthority()); if (firstRequestVersion == HTTP_3) { if (expectH3) { out.println("Expecting HEAD response over HTTP_3"); - assertEquals(response1.version(), HTTP_3, "Unexpected first response version"); + assertEquals(HTTP_3, response1.version(), "Unexpected first response version"); } } else { out.println("Expecting HEAD response over HTTP_2"); - assertEquals(response1.version(), HTTP_2, "Unexpected first response version"); + assertEquals(HTTP_2, response1.version(), "Unexpected first response version"); } out.println("HEAD response version: " + response1.version()); if (response1.version() == HTTP_2) { @@ -356,10 +363,10 @@ public class PostHTTP3Test implements HttpServerAdapters { out.println("Checking response: " + u); var response = e.getValue().get(); out.println("Response is: " + response + ", [version: " + response.version() + "]"); - assertEquals(response.statusCode(), 200,"status for " + u); - assertEquals(response.body(), BODY,"body for " + u); + assertEquals(200, response.statusCode(), "status for " + u); + assertEquals(BODY, response.body(), "body for " + u); if (expectH3) { - assertEquals(response.version(), HTTP_3, "version for " + u); + assertEquals(HTTP_3, response.version(), "version for " + u); } if (response.version() == HTTP_3) { h3Count++; @@ -381,7 +388,8 @@ public class PostHTTP3Test implements HttpServerAdapters { System.out.println("test: DONE"); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("uris") public void testSync(String h3URI) throws Exception { HttpClient client = makeNewClient(); Builder builder = HttpRequest.newBuilder(URI.create(h3URI + "/Sync/1")) @@ -403,14 +411,14 @@ public class PostHTTP3Test implements HttpServerAdapters { out.println("Response #1: " + response); out.println("Version #1: " + response.version()); out.println("Body #1:\n" + response.body().indent(4)); - assertEquals(response.statusCode(), 200, "first response status"); + assertEquals(200, response.statusCode(), "first response status"); if (directQuicConnectionSupported) { // TODO unreliable assertion //assertEquals(response.version(), HTTP_3, "Unexpected first response version"); } else { - assertEquals(response.version(), HTTP_2, "Unexpected first response version"); + assertEquals(HTTP_2, response.version(), "Unexpected first response version"); } - assertEquals(response.body(), BODY, "first response body"); + assertEquals(BODY, response.body(), "first response body"); request = builder.uri(URI.create(h3URI + "/Sync/2")) .POST(oflines(true, BODY.split("\n"))) @@ -419,9 +427,9 @@ public class PostHTTP3Test implements HttpServerAdapters { out.println("Response #2: " + response); out.println("Version #2: " + response.version()); out.println("Body #2:\n" + response.body().indent(4)); - assertEquals(response.statusCode(), 200, "second response status"); - assertEquals(response.version(), HTTP_3, "second response version"); - assertEquals(response.body(), BODY, "second response body"); + assertEquals(200, response.statusCode(), "second response status"); + assertEquals(HTTP_3, response.version(), "second response version"); + assertEquals(BODY, response.body(), "second response body"); request = builder.uri(URI.create(h3URI + "/Sync/3")) .POST(oflines(true, BODY.split("\n"))) @@ -430,9 +438,9 @@ public class PostHTTP3Test implements HttpServerAdapters { out.println("Response #3: " + response); out.println("Version #3: " + response.version()); out.println("Body #3:\n" + response.body().indent(4)); - assertEquals(response.statusCode(), 200, "third response status"); - assertEquals(response.version(), HTTP_3, "third response version"); - assertEquals(response.body(), BODY, "third response body"); + assertEquals(200, response.statusCode(), "third response status"); + assertEquals(HTTP_3, response.version(), "third response version"); + assertEquals(BODY, response.body(), "third response body"); var tracker = TRACKER.getTracker(client); client = null; @@ -441,8 +449,8 @@ public class PostHTTP3Test implements HttpServerAdapters { if (error != null) throw error; } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { final Http2TestServer h2WithAltService = new Http2TestServer("localhost", true, sslContext) .enableH3AltServiceOnSamePort(); h3TestServer = HttpTestServer.of(h2WithAltService); @@ -454,8 +462,8 @@ public class PostHTTP3Test implements HttpServerAdapters { directQuicConnectionSupported = h2WithAltService.supportsH3DirectConnection(); } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { System.err.println("======================================================="); System.err.println(" Tearing down test"); System.err.println("======================================================="); diff --git a/test/jdk/java/net/httpclient/http3/StopSendingTest.java b/test/jdk/java/net/httpclient/http3/StopSendingTest.java index ff1b8db7bc8..8c9a6f84b65 100644 --- a/test/jdk/java/net/httpclient/http3/StopSendingTest.java +++ b/test/jdk/java/net/httpclient/http3/StopSendingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -44,14 +44,15 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.internal.net.http.ResponseSubscribers; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary Exercises the HTTP3 client to send a STOP_SENDING frame @@ -59,17 +60,17 @@ import static java.net.http.HttpOption.H3_DISCOVERY; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * @compile ../ReferenceTracker.java - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors StopSendingTest */ public class StopSendingTest implements HttpServerAdapters { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer h3Server; - private String requestURIBase; + private static HttpTestServer h3Server; + private static String requestURIBase; - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { h3Server = HttpTestServer.create(HTTP_3_URI_ONLY, sslContext); h3Server.addHandler(new Handler(), "/hello"); h3Server.start(); @@ -79,8 +80,8 @@ public class StopSendingTest implements HttpServerAdapters { } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (h3Server != null) { System.out.println("Stopping server " + h3Server.getAddress()); h3Server.stop(); @@ -154,7 +155,7 @@ public class StopSendingTest implements HttpServerAdapters { // of the Future instance, sometimes the Future.cancel(true) results // in an ExecutionException which wraps the CancellationException. // TODO: fix the actual race condition and then expect only CancellationException here - final Exception actualException = Assert.expectThrows(Exception.class, futureResp::get); + final Exception actualException = Assertions.assertThrows(Exception.class, futureResp::get); if (actualException instanceof CancellationException) { // expected System.out.println("Received the expected CancellationException"); diff --git a/test/jdk/java/net/httpclient/http3/StreamLimitTest.java b/test/jdk/java/net/httpclient/http3/StreamLimitTest.java index e0610cf89b8..9e15db9ceb9 100644 --- a/test/jdk/java/net/httpclient/http3/StreamLimitTest.java +++ b/test/jdk/java/net/httpclient/http3/StreamLimitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,14 +45,15 @@ import jdk.httpclient.test.lib.quic.QuicServerConnection; import jdk.internal.net.http.quic.QuicTransportParameters; import jdk.internal.net.http.quic.QuicTransportParameters.ParameterId; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_3; import static java.net.http.HttpOption.H3_DISCOVERY; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary verifies that when the Quic stream limit is reached @@ -64,17 +65,17 @@ import static java.net.http.HttpOption.H3_DISCOVERY; * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.common.HttpServerAdapters * jdk.httpclient.test.lib.http3.Http3TestServer - * @run testng/othervm -Djdk.internal.httpclient.debug=true StreamLimitTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true StreamLimitTest */ public class StreamLimitTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private HttpTestServer server; - private QuicServer quicServer; - private URI requestURI; - private volatile QuicServerConnection latestServerConn; + private static HttpTestServer server; + private static QuicServer quicServer; + private static URI requestURI; + private static volatile QuicServerConnection latestServerConn; - private final class Handler implements HttpTestHandler { + private static final class Handler implements HttpTestHandler { @Override public void handle(HttpTestExchange exchange) throws IOException { @@ -97,8 +98,8 @@ public class StreamLimitTest { } } - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { quicServer = Http3TestServer.quicServerBuilder().sslContext(sslContext).build(); final Http3TestServer h3Server = new Http3TestServer(quicServer) { @Override @@ -118,8 +119,8 @@ public class StreamLimitTest { requestURI = new URI("https://" + server.serverAuthority() + "/foo"); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { latestServerConn = null; if (server != null) { server.stop(); @@ -161,8 +162,8 @@ public class StreamLimitTest { System.out.println("Sending request " + i + " to " + requestURI); final HttpResponse resp = client.send(req, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(resp.version(), HTTP_3, "Unexpected response version"); - Assert.assertEquals(resp.statusCode(), 200, "Unexpected response code"); + Assertions.assertEquals(HTTP_3, resp.version(), "Unexpected response version"); + Assertions.assertEquals(200, resp.statusCode(), "Unexpected response code"); final String respBody = resp.body(); System.out.println("Request " + i + " was handled by server connection: " + respBody); if (i == 1) { @@ -170,7 +171,7 @@ public class StreamLimitTest { // to this request requestHandledBy = respBody; } else { - Assert.assertEquals(respBody, requestHandledBy, "Request was handled by an" + + Assertions.assertEquals(requestHandledBy, respBody, "Request was handled by an" + " unexpected server connection"); } } @@ -193,20 +194,20 @@ public class StreamLimitTest { + requestURI); final HttpResponse resp = client.send(reqWithTimeout, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(resp.version(), HTTP_3, "Unexpected response version"); - Assert.assertEquals(resp.statusCode(), 200, "Unexpected response code"); + Assertions.assertEquals(HTTP_3, resp.version(), "Unexpected response version"); + Assertions.assertEquals(200, resp.statusCode(), "Unexpected response code"); final String respBody = resp.body(); System.out.println("Request " + i + " was handled by server connection: " + respBody); if (i == 1) { // first request after the limit was hit. // verify that it was handled by a new connection and not the one that handled // the previous N requests - Assert.assertNotEquals(respBody, requestHandledBy, "Request was expected to be" + + Assertions.assertNotEquals(requestHandledBy, respBody, "Request was expected to be" + " handled by a new server connection, but wasn't"); // keep track this new server connection id which responded to this request requestHandledBy = respBody; } else { - Assert.assertEquals(respBody, requestHandledBy, "Request was handled by an" + + Assertions.assertEquals(requestHandledBy, respBody, "Request was handled by an" + " unexpected server connection"); } } @@ -231,13 +232,13 @@ public class StreamLimitTest { " to " + requestURI); final HttpResponse resp = client.send(reqWithTimeout, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(resp.version(), HTTP_3, "Unexpected response version"); - Assert.assertEquals(resp.statusCode(), 200, "Unexpected response code"); + Assertions.assertEquals(HTTP_3, resp.version(), "Unexpected response version"); + Assertions.assertEquals(200, resp.statusCode(), "Unexpected response code"); final String respBody = resp.body(); System.out.println("Request " + i + " was handled by server connection: " + respBody); // all these requests should be handled by the same server connection which handled // the previous requests - Assert.assertEquals(respBody, requestHandledBy, "Request was handled by an" + + Assertions.assertEquals(requestHandledBy, respBody, "Request was handled by an" + " unexpected server connection"); } // at this point the newer limit for bidi stream creation has reached on the client. @@ -254,12 +255,12 @@ public class StreamLimitTest { System.out.println("Sending request, without timeout, to " + requestURI); final HttpResponse finalResp = client.send(finalReq, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(finalResp.version(), HTTP_3, "Unexpected response version"); - Assert.assertEquals(finalResp.statusCode(), 200, "Unexpected response code"); + Assertions.assertEquals(HTTP_3, finalResp.version(), "Unexpected response version"); + Assertions.assertEquals(200, finalResp.statusCode(), "Unexpected response code"); final String finalRespBody = finalResp.body(); System.out.println("Request was handled by server connection: " + finalRespBody); // this request should have been handled by a new server connection - Assert.assertNotEquals(finalRespBody, requestHandledBy, "Request was handled by an" + + Assertions.assertNotEquals(requestHandledBy, finalRespBody, "Request was handled by an" + " unexpected server connection"); } } diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java index 86ea3c8fdcd..b40cef5d4e6 100644 --- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java +++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java @@ -876,6 +876,8 @@ public interface HttpServerAdapters { @Override public void handle(HttpTestExchange t) throws IOException { + System.err.printf("EchoHandler received request to %s from %s (version %s)%n", + t.getRequestURI(), t.getRemoteAddress(), t.getExchangeVersion()); InputStream is = null; OutputStream os = null; try { @@ -895,7 +897,7 @@ public interface HttpServerAdapters { ? t.responseLength(bytes.length) : HttpTestExchange.fixedRsp(bytes.length); t.sendResponseHeaders(200, responseLength); - if (!t.getRequestMethod().equals("HEAD")) { + if (!t.getRequestMethod().equals("HEAD") && bytes.length > 0) { os.write(bytes); } } finally { diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicServerHandler.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicServerHandler.java index 886f15821a6..bef2e40137b 100644 --- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicServerHandler.java +++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicServerHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import jdk.internal.net.http.quic.streams.QuicBidiStream; * Used by server side application code to handle incoming Quic connections and streams associated * with those connections * - * @see QuicStandaloneServer#addHandler(QuicServerHandler) + * @see QuicStandaloneServer#setHandler(QuicServerHandler) */ // TODO: should we make this an abstract class instead of interface? public interface QuicServerHandler { diff --git a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicStandaloneServer.java b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicStandaloneServer.java index b1697064556..a7b5bb42ac2 100644 --- a/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicStandaloneServer.java +++ b/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/quic/QuicStandaloneServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +64,7 @@ public final class QuicStandaloneServer extends QuicServer { setConnectionAcceptor(QuicStandaloneServer::acceptIncoming); } - public void addHandler(final QuicServerHandler handler) { + public void setHandler(final QuicServerHandler handler) { this.handler = handler; } diff --git a/test/jdk/java/net/httpclient/offline/OfflineTesting.java b/test/jdk/java/net/httpclient/offline/OfflineTesting.java index 2f4833bf179..f36a457022e 100644 --- a/test/jdk/java/net/httpclient/offline/OfflineTesting.java +++ b/test/jdk/java/net/httpclient/offline/OfflineTesting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @summary Demonstrates how to achieve testing without network connections * @build DelegatingHttpClient FixedHttpResponse FixedResponseHttpClient - * @run testng/othervm OfflineTesting + * @run junit/othervm OfflineTesting */ import java.io.IOException; @@ -40,13 +40,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiPredicate; -import org.testng.annotations.Test; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class OfflineTesting { @@ -72,9 +74,9 @@ public class OfflineTesting { client.sendAsync(request, BodyHandlers.ofString()) .thenAccept(response -> { System.out.println("response: " + response); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(response.headers().firstValue("Server").isPresent()); - assertEquals(response.body(), "A response message"); + assertEquals("A response message", response.body()); }) .join(); } @@ -91,9 +93,9 @@ public class OfflineTesting { client.sendAsync(request, BodyHandlers.ofByteArray()) .thenAccept(response -> { System.out.println("response: " + response); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); assertTrue(response.headers().firstValue("Content-Type").isPresent()); - assertEquals(response.body(), "A response message".getBytes(UTF_8)); + Assertions.assertArrayEquals("A response message".getBytes(UTF_8), response.body()); }) .join(); } @@ -125,9 +127,9 @@ public class OfflineTesting { try (var client = fixedClient) { client.sendAsync(request, BodyHandlers.ofString()) .thenAccept(response -> { - assertEquals(response.statusCode(), 404); + assertEquals(404, response.statusCode()); response.headers().firstValue("Content-Type") - .ifPresentOrElse(type -> assertEquals(type, "text/html"), + .ifPresentOrElse(type -> assertEquals("text/html", type), () -> fail("Content-Type not present")); assertTrue(response.body().contains("404 Not Found")); }) @@ -151,8 +153,8 @@ public class OfflineTesting { client.sendAsync(request, BodyHandlers.ofString()) .thenAccept(response -> { System.out.println("response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), "Hello World"); + assertEquals(200, response.statusCode()); + assertEquals("Hello World", response.body()); }) .join(); } @@ -172,8 +174,8 @@ public class OfflineTesting { HttpResponse response = client.send(request, BodyHandlers.ofString()); System.out.println("response: " + response); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), "Hello chegar!!"); + assertEquals(200, response.statusCode()); + assertEquals("Hello chegar!!", response.body()); } } diff --git a/test/jdk/java/net/httpclient/quic/AckElicitingTest.java b/test/jdk/java/net/httpclient/quic/AckElicitingTest.java index 47fdb935598..7fbc00f9148 100644 --- a/test/jdk/java/net/httpclient/quic/AckElicitingTest.java +++ b/test/jdk/java/net/httpclient/quic/AckElicitingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -71,8 +71,6 @@ import jdk.internal.net.quic.QuicTLSEngine; import jdk.internal.net.quic.QuicTransportException; import jdk.internal.net.quic.QuicTransportParametersConsumer; import jdk.test.lib.RandomFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.crypto.AEADBadTagException; import javax.net.ssl.SSLParameters; @@ -80,16 +78,19 @@ import javax.net.ssl.SSLSession; import static jdk.internal.net.http.quic.frames.QuicFrame.*; import static jdk.internal.net.http.quic.frames.ConnectionCloseFrame.CONNECTION_CLOSE_VARIANT; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -/** +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/* * @test * @summary tests the logic to decide whether a packet or * a frame is ACK-eliciting. * @library /test/lib - * @run testng AckElicitingTest - * @run testng/othervm -Dseed=-7997973196290088038 AckElicitingTest + * @run junit AckElicitingTest + * @run junit/othervm -Dseed=-7997973196290088038 AckElicitingTest */ public class AckElicitingTest { @@ -307,7 +308,7 @@ public class AckElicitingTest { * {@code obj.ackEliciting()} * @param A concrete subclass of {@link QuicFrame} or {@link QuicPacket} */ - static record TestCase(Class type, + record TestCase(Class type, Function describer, Predicate ackEliciting, T obj, @@ -336,7 +337,7 @@ public class AckElicitingTest { */ public static TestCase of(Class type, T frame, boolean expected) { - return new TestCase(type, TestCase::describeFrame, + return new TestCase<>(type, TestCase::describeFrame, QuicFrame::isAckEliciting, frame, expected); } @@ -349,7 +350,7 @@ public class AckElicitingTest { * @return a new instance of {@code TestCase} */ public static TestCase of(T frame, boolean expected) { - return new TestCase((Class)frame.getClass(), + return new TestCase<>((Class)frame.getClass(), TestCase::describeFrame, QuicFrame::isAckEliciting, frame, expected); @@ -391,7 +392,7 @@ public class AckElicitingTest { * @param a concrete subclass of {@code QuicFrame} * @return a new instance of the given concrete class. */ - T newFrame(Class frameClass) { + static T newFrame(Class frameClass) { var frameType = QuicFrame.frameTypeOf(frameClass); if (frameType == CONNECTION_CLOSE) { if (RANDOM.nextBoolean()) { @@ -454,7 +455,7 @@ public class AckElicitingTest { * @return a list of {@code TestCase} to test all possible concrete * subclasses of {@code QuicFrame} */ - public List> createFramesTests() { + static List> createFramesTests() { List> frames = new ArrayList<>(); frames.add(of(newFrame(AckFrame.class), false)); frames.add(of(newFrame(ConnectionCloseFrame.class), false)); @@ -476,7 +477,7 @@ public class AckElicitingTest { * @param frames a list of frames * @return a new instance of {@code QuicPacket} */ - QuicPacket createPacket(List frames) { + static QuicPacket createPacket(List frames) { PacketType[] values = PacketType.values(); int index = PacketType.NONE.ordinal(); while (index == PacketType.NONE.ordinal()) { @@ -506,9 +507,9 @@ public class AckElicitingTest { * pseudo random list of concrete {@link QuicFrame} instances. * @param ackEliciting whether the returned packet should be * ack eliciting. - * @return + * @return a new QuicPacket */ - QuicPacket createPacket(boolean ackEliciting) { + static QuicPacket createPacket(boolean ackEliciting) { List frames = new ArrayList<>(); int mincount = ackEliciting ? 1 : 0; int ackCount = RANDOM.nextInt(mincount, 5); @@ -542,7 +543,7 @@ public class AckElicitingTest { return createPacket(mergeConsecutivePaddingFrames(frames)); } - private List mergeConsecutivePaddingFrames(List frames) { + private static List mergeConsecutivePaddingFrames(List frames) { var iterator = frames.listIterator(); QuicFrame previous = null; @@ -567,7 +568,7 @@ public class AckElicitingTest { * @return a list of {@code TestCase} to test random instances of * {@code QuicPacket} containing random instances of {@link QuicFrame} */ - public List> createPacketsTests() { + static List> createPacketsTests() { List> packets = new ArrayList<>(); packets.add(of(createPacket(List.of(newFrame(AckFrame.class))), false)); packets.add(of(createPacket(List.of(newFrame(ConnectionCloseFrame.class))), false)); @@ -593,8 +594,7 @@ public class AckElicitingTest { * @return test case to test * {@link QuicFrame#isAckEliciting()} */ - @DataProvider(name = "frames") - public Object[][] framesDataProvider() { + public static Object[][] framesDataProvider() { return createFramesTests().stream() .map(List::of) .map(List::toArray) @@ -607,8 +607,7 @@ public class AckElicitingTest { * @return test case to test * {@link QuicPacket#isAckEliciting()} */ - @DataProvider(name = "packets") - public Object[][] packetsDataProvider() { + public static Object[][] packetsDataProvider() { return createPacketsTests().stream() .map(List::of) .map(List::toArray) @@ -621,8 +620,9 @@ public class AckElicitingTest { * @param test the test inputs * @param a concrete subclass of QuicFrame */ - @Test(dataProvider = "frames") - public void testFrames(TestCase test) { + @ParameterizedTest + @MethodSource("framesDataProvider") + void testFrames(TestCase test) { testAckEliciting(test.type(), test.describer(), test.ackEliciting(), @@ -636,8 +636,9 @@ public class AckElicitingTest { * @param test the test inputs * @param a concrete subclass of QuickPacket */ - @Test(dataProvider = "packets") - public void testPackets(TestCase test) { + @ParameterizedTest + @MethodSource("packetsDataProvider") + void testPackets(TestCase test) { testAckEliciting(test.type(), test.describer(), test.ackEliciting(), @@ -664,7 +665,7 @@ public class AckElicitingTest { type.getSimpleName(), describer.apply(obj), expected); - assertEquals(ackEliciting.test(obj), expected, describer.apply(obj)); + assertEquals(expected, ackEliciting.test(obj), describer.apply(obj)); if (obj instanceof QuicFrame frame) { checkFrame(frame); } else if (obj instanceof QuicPacket packet) { @@ -695,10 +696,10 @@ public class AckElicitingTest { System.out.printf("Comparing frames: %s with %s%n", decoded.getClass().getSimpleName(), expected.getClass().getSimpleName()); - assertEquals(decoded.getClass(), expected.getClass()); - assertEquals(decoded.size(), expected.size()); - assertEquals(decoded.getTypeField(), expected.getTypeField()); - assertEquals(decoded.isAckEliciting(), expected.isAckEliciting()); + assertEquals(expected.getClass(), decoded.getClass()); + assertEquals(expected.size(), decoded.size()); + assertEquals(expected.getTypeField(), decoded.getTypeField()); + assertEquals(expected.isAckEliciting(), decoded.isAckEliciting()); } // This is not a full-fledged test for packet encoding/decoding. @@ -714,13 +715,13 @@ public class AckElicitingTest { encoder.encode(packet, buffer, CONTEXT); buffer.flip(); var decoded = decoder.decode(buffer, CONTEXT); - assertEquals(decoded.size(), packet.size()); - assertEquals(decoded.packetType(), packet.packetType()); - assertEquals(decoded.payloadSize(), packet.payloadSize()); - assertEquals(decoded.isAckEliciting(), packet.isAckEliciting()); + assertEquals(packet.size(), decoded.size()); + assertEquals(packet.packetType(), decoded.packetType()); + assertEquals(packet.payloadSize(), decoded.payloadSize()); + assertEquals(packet.isAckEliciting(), decoded.isAckEliciting()); var frames = packet.frames(); var decodedFrames = decoded.frames(); - assertEquals(decodedFrames.size(), frames.size()); + assertEquals(frames.size(), decodedFrames.size()); } catch (Exception x) { throw new AssertionError(packet.getClass().getName(), x); } diff --git a/test/jdk/java/net/httpclient/quic/AckFrameTest.java b/test/jdk/java/net/httpclient/quic/AckFrameTest.java index 129394f126c..3c8c027e73b 100644 --- a/test/jdk/java/net/httpclient/quic/AckFrameTest.java +++ b/test/jdk/java/net/httpclient/quic/AckFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,20 +21,12 @@ * questions. */ -import jdk.internal.net.http.quic.CodingContext; import jdk.internal.net.http.quic.frames.AckFrame; import jdk.internal.net.http.quic.frames.AckFrame.AckFrameBuilder; import jdk.internal.net.http.quic.frames.AckFrame.AckRange; import jdk.internal.net.http.quic.frames.QuicFrame; -import jdk.internal.net.http.quic.packets.QuicPacket; -import jdk.internal.net.http.quic.packets.QuicPacket.PacketNumberSpace; -import jdk.internal.net.http.quic.QuicConnectionId; -import jdk.internal.net.quic.QuicTLSEngine; import jdk.test.lib.RandomFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; @@ -43,66 +35,24 @@ import java.util.Random; import java.util.function.LongPredicate; import java.util.stream.LongStream; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -/** +/* * @test * @summary tests the logic to build an AckFrame * @library /test/lib - * @run testng AckFrameTest + * @run junit AckFrameTest */ public class AckFrameTest { static final Random RANDOM = RandomFactory.getRandom(); - private static abstract class TestCodingContext implements CodingContext { - TestCodingContext() { } - @Override - public int writePacket(QuicPacket packet, ByteBuffer buffer) { - throw new AssertionError("should not come here!"); - } - @Override - public QuicPacket parsePacket(ByteBuffer src) throws IOException { - throw new AssertionError("should not come here!"); - } - @Override - public boolean verifyToken(QuicConnectionId destinationID, byte[] token) { - return true; - } - @Override - public QuicTLSEngine getTLSEngine() { - throw new AssertionError("should not come here!"); - } - } - - static final int CIDLEN = RANDOM.nextInt(5, QuicConnectionId.MAX_CONNECTION_ID_LENGTH + 1); - - private static final TestCodingContext CONTEXT = new TestCodingContext() { - - @Override - public long largestProcessedPN(PacketNumberSpace packetSpace) { - return 0; - } - - @Override - public long largestAckedPN(PacketNumberSpace packetSpace) { - return 0; - } - - @Override - public int connectionIdLength() { - return CIDLEN; - } - - @Override - public QuicConnectionId originalServerConnId() { - return null; - } - }; - - public static record Acknowledged(long first, long last) { + public record Acknowledged(long first, long last) { public boolean contains(long packet) { return first <= packet && last >= packet; } @@ -116,7 +66,7 @@ public class AckFrameTest { return List.copyOf(res); } } - public static record Packet(long packetNumber) { + public record Packet(long packetNumber) { static List ofAcks(List acks) { return packets(acks); } @@ -125,7 +75,7 @@ public class AckFrameTest { } } - public static record TestCase(List acks, List packets, boolean shuffled) { + public record TestCase(List acks, List packets, boolean shuffled) { public TestCase(List acks) { this(acks, Packet.ofAcks(acks), false); } @@ -137,7 +87,7 @@ public class AckFrameTest { } } - List generateTests() { + static List generateTests() { List tests = new ArrayList<>(); List simples = List.of( new TestCase(List.of(new Acknowledged(5,5))), @@ -177,7 +127,7 @@ public class AckFrameTest { return tests; } - List generateAcks() { + static List generateAcks() { int count = RANDOM.nextInt(3, 10); List acks = new ArrayList<>(count); long prev = -1; @@ -202,22 +152,19 @@ public class AckFrameTest { return res; } - @DataProvider(name = "tests") - public Object[][] tests() { + public static Object[][] tests() { return generateTests().stream() .map(List::of) .map(List::toArray) .toArray(Object[][]::new); } - @Test(dataProvider = "tests") + @ParameterizedTest + @MethodSource("tests") public void testAckFrames(TestCase testCase) { AckFrameBuilder builder = new AckFrameBuilder(); List acks = testCase.acks; List packets = testCase.packets; - long largest = packets.stream() - .mapToLong(Packet::packetNumber) - .max().getAsLong(); System.out.printf("%ntestAckFrames(%s, %s)%n", acks, testCase.shuffled); builder.ackDelay(250); packets.stream().mapToLong(Packet::packetNumber).forEach(builder::addAck); @@ -227,8 +174,8 @@ public class AckFrameTest { checkAcknowledging(builder::isAcknowledging, testCase, packets); AckFrameBuilder dup = new AckFrameBuilder(frame); - assertEquals(frame, dup.build()); - assertEquals(frame, builder.build()); + assertEquals(dup.build(), frame); + assertEquals(builder.build(), frame); checkAcknowledging(dup::isAcknowledging, testCase, packets); packets.stream().mapToLong(Packet::packetNumber).forEach(builder::addAck); @@ -255,25 +202,25 @@ public class AckFrameTest { long largest = testCase.packets.stream() .mapToLong(Packet::packetNumber) .max().getAsLong(); - assertEquals(frame.largestAcknowledged(), largest); + assertEquals(largest, frame.largestAcknowledged()); checkAcknowledging(frame::isAcknowledging, testCase, packets); for (var ack : testCase.acks) { checkRangeAcknowledged(frame, ack.first, ack.last); } - assertEquals(frame, reference); + assertEquals(reference, frame); int size = frame.size(); ByteBuffer buffer = ByteBuffer.allocate(size + 10); buffer.position(5); buffer.limit(size + 5); try { frame.encode(buffer); - assertEquals(buffer.position(), buffer.limit()); + assertEquals(buffer.limit(), buffer.position()); buffer.position(5); buffer.limit(buffer.capacity()); var decoded = QuicFrame.decode(buffer); - assertEquals(buffer.position(), size + 5); - assertEquals(decoded, frame); - assertEquals(decoded, reference); + assertEquals(size + 5, buffer.position()); + assertEquals(frame, decoded); + assertEquals(reference, decoded); } catch (Exception e) { throw new AssertionError("Can't encode or decode frame: " + frame, e); } @@ -327,14 +274,14 @@ public class AckFrameTest { if (isAcknowledging != expected && testCase.shuffled) { System.out.printf(" -> %s%n", packets); } - assertEquals(isAcknowledging, expected, String.valueOf(pn)); + assertEquals(expected, isAcknowledging, String.valueOf(pn)); } for (var p : testCase.packets) { boolean isAcknowledging = isAckPredicate.test(p.packetNumber); if (!isAcknowledging && testCase.shuffled) { System.out.printf(" -> %s%n", packets); } - assertEquals(isAcknowledging, true, p.toString()); + assertEquals(true, isAcknowledging, p.toString()); } } @@ -345,9 +292,9 @@ public class AckFrameTest { assertTrue(frame.isAcknowledging(1), "1 should be acked"); assertFalse(frame.isAcknowledging(0), "0 should not be acked"); assertFalse(frame.isAcknowledging(2), "2 should not be acked"); - assertEquals(frame.smallestAcknowledged(), 1); - assertEquals(frame.largestAcknowledged(), 1); - assertEquals(frame.acknowledged().toArray(), new long[] {1L}); + assertEquals(1, frame.smallestAcknowledged()); + assertEquals(1, frame.largestAcknowledged()); + assertEquals(List.of(1L), frame.acknowledged().boxed().toList()); assertTrue(frame.isRangeAcknowledged(1,1), "[1,1] should be acked"); assertFalse(frame.isRangeAcknowledged(0, 1), "[0,1] should not be acked"); assertFalse(frame.isRangeAcknowledged(1, 2), "[1,2] should not be acked"); @@ -358,9 +305,9 @@ public class AckFrameTest { assertTrue(frame.isAcknowledging(1), "1 should be acked"); assertTrue(frame.isAcknowledging(0), "0 should be acked"); assertFalse(frame.isAcknowledging(2), "2 should not be acked"); - assertEquals(frame.smallestAcknowledged(), 0); - assertEquals(frame.largestAcknowledged(), 1); - assertEquals(frame.acknowledged().toArray(), new long[] {1L, 0L}); + assertEquals(0, frame.smallestAcknowledged()); + assertEquals(1, frame.largestAcknowledged()); + assertEquals(List.of(1L, 0L), frame.acknowledged().boxed().toList()); assertTrue(frame.isRangeAcknowledged(0,0), "[0,0] should be acked"); assertTrue(frame.isRangeAcknowledged(1,1), "[1,1] should be acked"); assertTrue(frame.isRangeAcknowledged(0, 1), "[0,1] should be acked"); diff --git a/test/jdk/java/net/httpclient/quic/BuffersReaderVLTest.java b/test/jdk/java/net/httpclient/quic/BuffersReaderVLTest.java index 5064bbd5cb3..100a6112de5 100644 --- a/test/jdk/java/net/httpclient/quic/BuffersReaderVLTest.java +++ b/test/jdk/java/net/httpclient/quic/BuffersReaderVLTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,29 +27,26 @@ import java.util.List; import jdk.internal.net.http.quic.BuffersReader; import jdk.internal.net.http.quic.BuffersReader.ListBuffersReader; import jdk.internal.net.http.quic.VariableLengthEncoder; -import jtreg.SkippedException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; +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; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @library /test/lib * @modules java.net.http/jdk.internal.net.http.quic - * @run testng/othervm BuffersReaderVLTest + * @run junit/othervm BuffersReaderVLTest * @summary Tests to check quic/util methods encode/decodeVariableLength methods * work as expected. */ public class BuffersReaderVLTest { static final Class IAE = IllegalArgumentException.class; - @DataProvider(name = "decode invariants") - public Object[][] decodeInvariants() { + public static Object[][] decodeInvariants() { return new Object[][] { { new byte[]{7}, 7, 1 }, // 00 @@ -61,8 +58,7 @@ public class BuffersReaderVLTest { { new byte[]{-65}, -1, 0 }, }; } - @DataProvider(name = "prefix invariants") - public Object[][] prefixInvariants() { + public static Object[][] prefixInvariants() { return new Object[][] { { Long.MAX_VALUE, 0, IAE }, @@ -101,44 +97,47 @@ public class BuffersReaderVLTest { }; } - @Test(dataProvider = "decode invariants") + @ParameterizedTest + @MethodSource("decodeInvariants") public void testDecode(byte[] values, long expectedLength, int expectedPosition) { ByteBuffer bb = ByteBuffer.wrap(values); BuffersReader br = BuffersReader.list(bb); var actualLength = VariableLengthEncoder.decode(br); - assertEquals(actualLength, expectedLength); + assertEquals(expectedLength, actualLength); var actualPosition = bb.position(); - assertEquals(actualPosition, expectedPosition); - assertEquals(br.position(), expectedPosition); + assertEquals(expectedPosition, actualPosition); + assertEquals(expectedPosition, br.position()); br.release(); - assertEquals(br.read(), expectedPosition); + assertEquals(expectedPosition, br.read()); } - @Test(dataProvider = "decode invariants") + @ParameterizedTest + @MethodSource("decodeInvariants") public void testPeek(byte[] values, long expectedLength, int expectedPosition) { ByteBuffer bb = ByteBuffer.wrap(values); BuffersReader br = BuffersReader.list(bb); var actualLength = VariableLengthEncoder.peekEncodedValue(br, 0); - assertEquals(actualLength, expectedLength); + assertEquals(expectedLength, actualLength); var actualPosition = bb.position(); - assertEquals(actualPosition, 0); - assertEquals(br.position(), 0); + assertEquals(0, actualPosition); + assertEquals(0, br.position()); br.release(); - assertEquals(br.read(), 0); + assertEquals(0, br.read()); } // Encode the given length and then decodes it and compares // the results, asserting various invariants along the way. - @Test(dataProvider = "prefix invariants") + @ParameterizedTest + @MethodSource("prefixInvariants") public void testEncodeDecode(long length, int expectedPrefix, Class exception) { if (exception != null) { assertThrows(exception, () -> VariableLengthEncoder.getEncodedSize(length)); assertThrows(exception, () -> VariableLengthEncoder.encode(ByteBuffer.allocate(16), length)); } else { var actualSize = VariableLengthEncoder.getEncodedSize(length); - assertEquals(actualSize, 1 << expectedPrefix); + assertEquals(1 << expectedPrefix, actualSize); assertTrue(actualSize > 0, "length is negative or zero: " + actualSize); assertTrue(actualSize < 9, "length is too big: " + actualSize); @@ -158,33 +157,33 @@ public class BuffersReaderVLTest { longer.position(offset); // attempt to encode with a buffer too short - expectThrows(IAE, () -> VariableLengthEncoder.encode(shorter, length)); - assertEquals(shorter.position(), offset); - assertEquals(shorter.limit(), shorter.capacity()); + assertThrows(IAE, () -> VariableLengthEncoder.encode(shorter, length)); + assertEquals(offset, shorter.position()); + assertEquals(shorter.capacity(), shorter.limit()); - assertEquals(shorter.mismatch(shorterref), -1); - assertEquals(shorterref.mismatch(shorter), -1); + assertEquals(-1, shorter.mismatch(shorterref)); + assertEquals(-1, shorterref.mismatch(shorter)); // attempt to encode with a buffer that has the exact size var exactres = VariableLengthEncoder.encode(exact, length); - assertEquals(exactres, actualSize); - assertEquals(exact.position(), actualSize + offset); + assertEquals(actualSize, exactres); + assertEquals(actualSize + offset, exact.position()); assertFalse(exact.hasRemaining()); // attempt to encode with a buffer that has more bytes var longres = VariableLengthEncoder.encode(longer, length); - assertEquals(longres, actualSize); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.limit(), longer.capacity()); - assertEquals(longer.remaining(), 10); + assertEquals(actualSize, longres); + assertEquals(offset + actualSize, longer.position()); + assertEquals(longer.capacity(), longer.limit()); + assertEquals(10, longer.remaining()); // compare encodings // first reset buffer positions for reading. exact.position(offset); longer.position(offset); - assertEquals(longer.mismatch(exact), actualSize); - assertEquals(exact.mismatch(longer), actualSize); + assertEquals(actualSize, longer.mismatch(exact)); + assertEquals(actualSize, exact.mismatch(longer)); // decode with a buffer that is missing the last // byte... @@ -193,23 +192,23 @@ public class BuffersReaderVLTest { shortSlice.limit(offset + actualSize -1); ListBuffersReader br = BuffersReader.list(shortSlice); var actualLength = VariableLengthEncoder.decode(br); - assertEquals(actualLength, -1L); - assertEquals(shortSlice.position(), offset); - assertEquals(shortSlice.limit(), offset + actualSize - 1); - assertEquals(br.position(), offset); - assertEquals(br.limit(), offset + actualSize - 1); + assertEquals(-1L, actualLength); + assertEquals(offset, shortSlice.position()); + assertEquals(offset + actualSize - 1, shortSlice.limit()); + assertEquals(offset, br.position()); + assertEquals(offset + actualSize - 1, br.limit()); br.release(); // decode with the exact buffer br = BuffersReader.list(exact); actualLength = VariableLengthEncoder.decode(br); - assertEquals(actualLength, length); - assertEquals(exact.position(), offset + actualSize); + assertEquals(length, actualLength); + assertEquals(offset + actualSize, exact.position()); assertFalse(exact.hasRemaining()); - assertEquals(br.position(), offset + actualSize); + assertEquals(offset + actualSize, br.position()); assertFalse(br.hasRemaining()); br.release(); - assertEquals(br.read(), actualSize); + assertEquals(actualSize, br.read()); assertFalse(br.hasRemaining()); @@ -217,14 +216,14 @@ public class BuffersReaderVLTest { long read = br.read(); br.add(longer); actualLength = VariableLengthEncoder.decode(br); - assertEquals(actualLength, length); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.remaining(), 10); - assertEquals(br.position(), offset + actualSize); - assertEquals(br.remaining(), 10); + assertEquals(length, actualLength); + assertEquals(offset + actualSize, longer.position()); + assertEquals(10, longer.remaining()); + assertEquals(offset + actualSize, br.position()); + assertEquals(10, br.remaining()); br.release(); - assertEquals(br.read() - read, actualSize); - assertEquals(br.remaining(), 10); + assertEquals(actualSize, br.read() - read); + assertEquals(10, br.remaining()); } } @@ -232,7 +231,8 @@ public class BuffersReaderVLTest { // Encode the given length and then peeks it and compares // the results, asserting various invariants along the way. - @Test(dataProvider = "prefix invariants") + @ParameterizedTest + @MethodSource("prefixInvariants") public void testEncodePeek(long length, int expectedPrefix, Class exception) { if (exception != null) { assertThrows(exception, () -> VariableLengthEncoder.getEncodedSize(length)); @@ -241,7 +241,7 @@ public class BuffersReaderVLTest { } var actualSize = VariableLengthEncoder.getEncodedSize(length); - assertEquals(actualSize, 1 << expectedPrefix); + assertEquals(1 << expectedPrefix, actualSize); assertTrue(actualSize > 0, "length is negative or zero: " + actualSize); assertTrue(actualSize < 9, "length is too big: " + actualSize); @@ -258,24 +258,24 @@ public class BuffersReaderVLTest { // attempt to encode with a buffer that has the exact size var exactres = VariableLengthEncoder.encode(exact, length); - assertEquals(exactres, actualSize); - assertEquals(exact.position(), actualSize + offset); + assertEquals(actualSize, exactres); + assertEquals(actualSize + offset, exact.position()); assertFalse(exact.hasRemaining()); // attempt to encode with a buffer that has more bytes var longres = VariableLengthEncoder.encode(longer, length); - assertEquals(longres, actualSize); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.limit(), longer.capacity()); - assertEquals(longer.remaining(), 10); + assertEquals(actualSize, longres); + assertEquals(offset + actualSize, longer.position()); + assertEquals(longer.capacity(), longer.limit()); + assertEquals(10, longer.remaining()); // compare encodings // first reset buffer positions for reading. exact.position(offset); longer.position(offset); - assertEquals(longer.mismatch(exact), actualSize); - assertEquals(exact.mismatch(longer), actualSize); + assertEquals(actualSize, longer.mismatch(exact)); + assertEquals(actualSize, exact.mismatch(longer)); exact.position(0); longer.position(0); exact.limit(exact.capacity()); @@ -288,38 +288,26 @@ public class BuffersReaderVLTest { shortSlice.limit(offset + actualSize - 1); // need at least one byte to decode the size len... var expectedSize = shortSlice.limit() <= offset ? -1 : actualSize; - assertEquals(VariableLengthEncoder.peekEncodedValueSize(shortSlice, offset), expectedSize); + assertEquals(expectedSize, VariableLengthEncoder.peekEncodedValueSize(shortSlice, offset)); var actualLength = VariableLengthEncoder.peekEncodedValue(shortSlice, offset); - assertEquals(actualLength, -1L); - assertEquals(shortSlice.position(), 0); - assertEquals(shortSlice.limit(), offset + actualSize - 1); + assertEquals(-1L, actualLength); + assertEquals(0, shortSlice.position()); + assertEquals(offset + actualSize - 1, shortSlice.limit()); // decode with the exact buffer - assertEquals(VariableLengthEncoder.peekEncodedValueSize(exact, offset), actualSize); + assertEquals(actualSize, VariableLengthEncoder.peekEncodedValueSize(exact, offset)); actualLength = VariableLengthEncoder.peekEncodedValue(exact, offset); - assertEquals(actualLength, length); - assertEquals(exact.position(), 0); - assertEquals(exact.limit(), exact.capacity()); + assertEquals(length, actualLength); + assertEquals(0, exact.position()); + assertEquals(exact.capacity(), exact.limit()); // decode with the longer buffer - assertEquals(VariableLengthEncoder.peekEncodedValueSize(longer, offset), actualSize); + assertEquals(actualSize, VariableLengthEncoder.peekEncodedValueSize(longer, offset)); actualLength = VariableLengthEncoder.peekEncodedValue(longer, offset); - assertEquals(actualLength, length); - assertEquals(longer.position(), 0); - assertEquals(longer.limit(), longer.capacity()); + assertEquals(length, actualLength); + assertEquals(0, longer.position()); + assertEquals(longer.capacity(), longer.limit()); } } - - - private ByteBuffer getTestBuffer(long length, int capacity) { - return switch (capacity) { - case 0 -> ByteBuffer.allocate(1).put((byte) length); - case 1 -> ByteBuffer.allocate(capacity).put((byte) length); - case 2 -> ByteBuffer.allocate(capacity).putShort((short) length); - case 4 -> ByteBuffer.allocate(capacity).putInt((int) length); - case 8 -> ByteBuffer.allocate(capacity).putLong(length); - default -> throw new SkippedException("bad value used for capacity"); - }; - } } diff --git a/test/jdk/java/net/httpclient/quic/ConnectionIDSTest.java b/test/jdk/java/net/httpclient/quic/ConnectionIDSTest.java index e7fabeeecac..96aeace0898 100644 --- a/test/jdk/java/net/httpclient/quic/ConnectionIDSTest.java +++ b/test/jdk/java/net/httpclient/quic/ConnectionIDSTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,12 +29,13 @@ import java.util.List; import java.util.Map; import jdk.internal.net.http.quic.QuicConnectionIdFactory; -import org.testng.annotations.Test; -import static org.testng.Assert.*; -/** +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +/* * @test - * @run testng/othervm ConnectionIDSTest + * @run junit/othervm ConnectionIDSTest */ public class ConnectionIDSTest { @@ -76,14 +77,14 @@ public class ConnectionIDSTest { int expectedLength = Math.min(length, 20); expectedLength = Math.max(9, expectedLength); long token = idFactory.newToken(); - assertEquals(token, previous +1); + assertEquals(previous +1, token); previous = token; var id = idFactory.newConnectionId(length, token); var cid = new ConnID(token, id); System.out.printf("%s: %s/%s%n", length, token, cid); - assertEquals(id.length, expectedLength); - assertEquals(idFactory.getConnectionIdLength(id), expectedLength); - assertEquals(idFactory.getConnectionIdToken(id), token); + assertEquals(expectedLength, id.length); + assertEquals(expectedLength, idFactory.getConnectionIdLength(id)); + assertEquals(token, idFactory.getConnectionIdToken(id)); ids.add(cid); } @@ -101,9 +102,9 @@ public class ConnectionIDSTest { var id = idFactory.newConnectionId(length, token); var cid = new ConnID(expectedToken, id); System.out.printf("%s: %s/%s%n", length, token, cid); - assertEquals(id.length, length); - assertEquals(idFactory.getConnectionIdLength(id), length); - assertEquals(idFactory.getConnectionIdToken(id), expectedToken); + assertEquals(length, id.length); + assertEquals(length, idFactory.getConnectionIdLength(id)); + assertEquals(expectedToken, idFactory.getConnectionIdToken(id)); ids.add(cid); } } @@ -119,15 +120,15 @@ public class ConnectionIDSTest { var id = idFactory.newConnectionId(length, token); var cid = new ConnID(expectedToken, id); System.out.printf("%s: %s/%s%n", length, token, cid); - assertEquals(id.length, length); - assertEquals(idFactory.getConnectionIdLength(id), length); - assertEquals(idFactory.getConnectionIdToken(id), expectedToken); + assertEquals(length, id.length); + assertEquals(length, idFactory.getConnectionIdLength(id)); + assertEquals(expectedToken, idFactory.getConnectionIdToken(id)); ids.add(cid); } } // now verify uniqueness - Map tested = new HashMap(); + Map tested = new HashMap<>(); record duplicates(ConnID first, ConnID second) {} List duplicates = new ArrayList<>(); for (var cid : ids) { @@ -144,9 +145,9 @@ public class ConnectionIDSTest { // and the token value is too big; check and remove them for (var iter = duplicates.iterator(); iter.hasNext(); ) { var dup = iter.next(); - assertEquals(dup.first.token(), dup.second.token()); - assertEquals(dup.first.bytes().length, dup.second.bytes().length); - assertEquals(dup.first.bytes(), dup.second.bytes()); + assertEquals(dup.second.token(), dup.first.token()); + assertEquals(dup.second.bytes().length, dup.first.bytes().length); + assertArrayEquals(dup.second.bytes(), dup.first.bytes()); long mask = 0x00FFFFFF00000000L; for (int i=0; i<3; i++) { mask = mask << 8; @@ -165,6 +166,6 @@ public class ConnectionIDSTest { for (var dup : duplicates) { System.out.println("unexpected duplicate: " + dup); } - assertEquals(duplicates.size(), 0); + assertEquals(0, duplicates.size()); } } diff --git a/test/jdk/java/net/httpclient/quic/CryptoWriterQueueTest.java b/test/jdk/java/net/httpclient/quic/CryptoWriterQueueTest.java index cfc62625605..422d71ca964 100644 --- a/test/jdk/java/net/httpclient/quic/CryptoWriterQueueTest.java +++ b/test/jdk/java/net/httpclient/quic/CryptoWriterQueueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,18 +23,18 @@ import jdk.internal.net.http.quic.frames.CryptoFrame; import jdk.internal.net.http.quic.streams.CryptoWriterQueue; -import org.testng.annotations.Test; import java.nio.ByteBuffer; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; -/** +/* * @test * @summary Tests jdk.internal.net.http.quic.streams,CryptoWriterQueue * @modules java.net.http/jdk.internal.net.http.quic.streams * java.net.http/jdk.internal.net.http.quic.frames - * @run testng CryptoWriterQueueTest + * @run junit CryptoWriterQueueTest */ public class CryptoWriterQueueTest { @@ -54,7 +54,7 @@ public class CryptoWriterQueueTest { writerQueue.enqueue(buff2); writerQueue.enqueue(buff3); final int expectedRemaining = buff1.remaining() + buff2.remaining() + buff3.remaining(); - assertEquals(writerQueue.remaining(), expectedRemaining, + assertEquals(expectedRemaining, writerQueue.remaining(), "Unexpected remaining bytes in CryptoWriterQueue"); // create frame(s) from the enqueued buffers final int maxPayloadSize = 1134; diff --git a/test/jdk/java/net/httpclient/quic/KeyUpdateTest.java b/test/jdk/java/net/httpclient/quic/KeyUpdateTest.java index d6d287be9e0..eaec0bc8b95 100644 --- a/test/jdk/java/net/httpclient/quic/KeyUpdateTest.java +++ b/test/jdk/java/net/httpclient/quic/KeyUpdateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,12 +48,14 @@ import jdk.internal.net.quic.QuicKeyUnavailableException; import jdk.internal.net.quic.QuicTLSContext; import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + import sun.security.ssl.QuicTLSEngineImpl; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -78,35 +80,35 @@ import static org.testng.Assert.assertTrue; * jdk.test.lib.net.SimpleSSLContext * @comment the test is run with -Djava.security.properties= to augment * the master java.security file - * @run testng/othervm -Djava.security.properties=${test.src}/quic-tls-keylimits-java.security + * @run junit/othervm -Djava.security.properties=${test.src}/quic-tls-keylimits-java.security * -Djdk.internal.httpclient.debug=true * -Djavax.net.debug=all * KeyUpdateTest */ public class KeyUpdateTest { - private QuicStandaloneServer server; + private static QuicStandaloneServer server; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private ExecutorService executor; + private static ExecutorService executor; private static final byte[] HELLO_MSG = "Hello Quic".getBytes(StandardCharsets.UTF_8); private static final EchoHandler handler = new EchoHandler(HELLO_MSG.length); - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { executor = Executors.newCachedThreadPool(); server = QuicStandaloneServer.newBuilder() .availableVersions(new QuicVersion[]{QuicVersion.QUIC_V1}) .sslContext(sslContext) .build(); // add a handler which deals with incoming connections - server.addHandler(handler); + server.setHandler(handler); server.start(); System.out.println("Server started at " + server.getAddress()); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (server != null) { System.out.println("Stopping server " + server.getAddress()); server.close(); @@ -163,7 +165,7 @@ public class KeyUpdateTest { // keep track of the 1-RTT key phase that was used by the client connection final int invocation = i; getKeyPhase(conn.underlyingQuicConnection()).ifPresent((keyPhase) -> { - if (clientConnKeyPhases.empty() || clientConnKeyPhases.peek() != keyPhase) { + if (clientConnKeyPhases.empty() || !keyPhase.equals(clientConnKeyPhases.peek())) { // new key phase detected, add it clientConnKeyPhases.push(keyPhase); System.out.println("Detected client 1-RTT key phase " + keyPhase @@ -223,7 +225,7 @@ public class KeyUpdateTest { // keep track of the 1-RTT key phase that was used by the server connection getKeyPhase(conn).ifPresent((keyPhase) -> { if (this.serverConnKeyPhases.empty() - || this.serverConnKeyPhases.peek() != keyPhase) { + || !keyPhase.equals(this.serverConnKeyPhases.peek())) { // new key phase detected, add it this.serverConnKeyPhases.push(keyPhase); System.out.println("Detected server 1-RTT key phase " + keyPhase diff --git a/test/jdk/java/net/httpclient/quic/OrderedFlowTest.java b/test/jdk/java/net/httpclient/quic/OrderedFlowTest.java index cb95620c00e..a1fafba8760 100644 --- a/test/jdk/java/net/httpclient/quic/OrderedFlowTest.java +++ b/test/jdk/java/net/httpclient/quic/OrderedFlowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,24 +37,24 @@ import jdk.internal.net.http.quic.OrderedFlow; import jdk.internal.net.http.quic.frames.CryptoFrame; import jdk.internal.net.http.quic.frames.QuicFrame; import jdk.internal.net.http.quic.frames.StreamFrame; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -/** +/* * @test * @summary tests the reordering logic implemented by OrderedFlow * and its two concrete subclasses * @library /test/lib - * @run testng OrderedFlowTest - * @run testng/othervm -Dseed=-2680947227866359853 OrderedFlowTest - * @run testng/othervm -Dseed=-273117134353023275 OrderedFlowTest - * @run testng/othervm -Dseed=3649132517916066643 OrderedFlowTest - * @run testng/othervm -Dseed=4568737726943220431 OrderedFlowTest + * @run junit OrderedFlowTest + * @run junit/othervm -Dseed=-2680947227866359853 OrderedFlowTest + * @run junit/othervm -Dseed=-273117134353023275 OrderedFlowTest + * @run junit/othervm -Dseed=3649132517916066643 OrderedFlowTest + * @run junit/othervm -Dseed=4568737726943220431 OrderedFlowTest */ public class OrderedFlowTest { @@ -135,13 +135,13 @@ public class OrderedFlowTest { """; interface FramesFactory { - public T create(int offset, String payload, boolean fin); - public int length(T frame); - public long offset(T frame); - public String getPayload(T frame); - public OrderedFlow flow(); - public Class frameType(); - public Comparator comparator(); + T create(int offset, String payload, boolean fin); + int length(T frame); + long offset(T frame); + String getPayload(T frame); + OrderedFlow flow(); + Class frameType(); + Comparator comparator(); } static class StreamFrameFactory implements FramesFactory { @@ -307,7 +307,7 @@ public class OrderedFlowTest { // not be buffered. static TestData reversed(TestData data) { List sorted = new ArrayList<>(data.frames()); - Collections.sort(sorted, data.framesComparator().reversed()); + sorted.sort(data.framesComparator().reversed()); return new TestData<>(data.frameType(),data.flowSupplier(), data.payloadAccessor(), data.framesComparator(), List.copyOf(sorted), data.expectedResult(), data.duplicates(), true); @@ -336,8 +336,7 @@ public class OrderedFlowTest { return List.copyOf(result); } - @DataProvider(name="CryptoFrame") - Object[][] generateCryptoFrames() { + static Object[][] generateCryptoFrames() { return generateData(new CryptoFrameFactory()) .stream() .map(List::of) @@ -345,8 +344,7 @@ public class OrderedFlowTest { .toArray(Object[][]::new); } - @DataProvider(name="StreamFrame") - Object[][] generateStreanFrames() { + static Object[][] generateStreanFrames() { return generateData(new StreamFrameFactory()) .stream() .map(List::of) @@ -380,21 +378,23 @@ public class OrderedFlowTest { "buffered data %s exceeds or equals payload size %s".formatted(buffered, size)); while (received != null) { var payload = testData.payloadAccessor.apply(received); - assertNotEquals(payload, "", "empty frames not expected: " + received); + assertNotEquals("", payload, "empty frames not expected: " + received); result.append(payload); received = flow.poll(); } } - assertEquals(result.toString(), testData.expectedResult); + assertEquals(testData.expectedResult, result.toString()); } - @Test(dataProvider = "CryptoFrame") - public void testCryptoFlow(TestData testData) { + @ParameterizedTest + @MethodSource("generateCryptoFrames") + void testCryptoFlow(TestData testData) { testOrderedFlow(testData, CryptoFrame::offset); } - @Test(dataProvider = "StreamFrame") - public void testStreamFlow(TestData testData) { + @ParameterizedTest + @MethodSource("generateStreanFrames") + void testStreamFlow(TestData testData) { testOrderedFlow(testData, StreamFrame::offset); } diff --git a/test/jdk/java/net/httpclient/quic/PacerTest.java b/test/jdk/java/net/httpclient/quic/PacerTest.java index d54f4125a46..aebbbce34d3 100644 --- a/test/jdk/java/net/httpclient/quic/PacerTest.java +++ b/test/jdk/java/net/httpclient/quic/PacerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,20 +26,21 @@ import jdk.internal.net.http.quic.QuicCongestionController; import jdk.internal.net.http.quic.QuicPacer; import jdk.internal.net.http.quic.QuicRttEstimator; import jdk.internal.net.http.quic.packets.QuicPacket; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.time.temporal.ChronoUnit; import java.util.Collection; import java.util.List; import java.util.stream.Stream; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test - * @run testng/othervm -Djdk.httpclient.quic.timerFrequency=1000 PacerTest + * @run junit/othervm -Djdk.httpclient.quic.timerFrequency=1000 PacerTest */ public class PacerTest { @@ -136,8 +137,7 @@ public class PacerTest { int initialPermit, int periodicPermit, boolean slowStart) { } - @DataProvider - public Object[][] pacerFirstFlight() { + public static Object[][] pacerFirstFlight() { return List.of( // Should permit initial window before blocking new TestCase(1200, 10, 32, 16, 10, 4, true), @@ -150,7 +150,8 @@ public class PacerTest { .toArray(Object[][]::new); } - @Test(dataProvider = "pacerFirstFlight") + @ParameterizedTest + @MethodSource("pacerFirstFlight") public void testBasicPacing(TestCase test) { int maxDatagramSize = test.maxDatagramSize; int packetsInIW = test.packetsInIW; diff --git a/test/jdk/java/net/httpclient/quic/PacketEncodingTest.java b/test/jdk/java/net/httpclient/quic/PacketEncodingTest.java index 495e8d41403..a96904c8410 100644 --- a/test/jdk/java/net/httpclient/quic/PacketEncodingTest.java +++ b/test/jdk/java/net/httpclient/quic/PacketEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,8 +52,6 @@ import jdk.internal.net.http.quic.QuicConnectionId; import jdk.internal.net.quic.QuicTLSEngine; import jdk.internal.net.quic.QuicTransportParametersConsumer; import jdk.internal.net.http.quic.VariableLengthEncoder; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.crypto.AEADBadTagException; import javax.net.ssl.SSLParameters; @@ -71,29 +69,32 @@ import java.util.function.IntFunction; import java.util.stream.Collectors; import static jdk.internal.net.http.quic.packets.QuicPacketNumbers.computePacketNumberLength; -import static org.testng.Assert.*; -/** +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/* * @test * @library /test/lib * @summary test packet encoding and decoding in unencrypted form and without * any network involvement. - * @run testng/othervm -Dseed=2646683818688275736 PacketEncodingTest - * @run testng/othervm -Dseed=-3723256402256409075 PacketEncodingTest - * @run testng/othervm -Dseed=-3689060484817342283 PacketEncodingTest - * @run testng/othervm -Dseed=2425718686525936108 PacketEncodingTest - * @run testng/othervm -Dseed=-2996954753243104355 PacketEncodingTest - * @run testng/othervm -Dseed=8750823652999067800 PacketEncodingTest - * @run testng/othervm -Dseed=2906555779406889127 PacketEncodingTest - * @run testng/othervm -Dseed=902801756808168822 PacketEncodingTest - * @run testng/othervm -Dseed=5643545543196691308 PacketEncodingTest - * @run testng/othervm -Dseed=2646683818688275736 PacketEncodingTest - * @run testng/othervm -Djdk.internal.httpclient.debug=true PacketEncodingTest + * @run junit/othervm -Dseed=2646683818688275736 PacketEncodingTest + * @run junit/othervm -Dseed=-3723256402256409075 PacketEncodingTest + * @run junit/othervm -Dseed=-3689060484817342283 PacketEncodingTest + * @run junit/othervm -Dseed=2425718686525936108 PacketEncodingTest + * @run junit/othervm -Dseed=-2996954753243104355 PacketEncodingTest + * @run junit/othervm -Dseed=8750823652999067800 PacketEncodingTest + * @run junit/othervm -Dseed=2906555779406889127 PacketEncodingTest + * @run junit/othervm -Dseed=902801756808168822 PacketEncodingTest + * @run junit/othervm -Dseed=5643545543196691308 PacketEncodingTest + * @run junit/othervm -Dseed=2646683818688275736 PacketEncodingTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true PacketEncodingTest */ public class PacketEncodingTest { - @DataProvider - public Object[][] longHeaderPacketProvider() { + public static Object[][] longHeaderPacketProvider() { final QuicVersion[] quicVersions = QuicVersion.values(); final List params = new ArrayList<>(); for (final QuicVersion version : quicVersions) { @@ -117,8 +118,7 @@ public class PacketEncodingTest { return params.toArray(Object[][]::new); } - @DataProvider - public Object[][] shortHeaderPacketProvider() { + public static Object[][] shortHeaderPacketProvider() { final QuicVersion[] quicVersions = QuicVersion.values(); final List params = new ArrayList<>(); for (final QuicVersion version : quicVersions) { @@ -141,8 +141,7 @@ public class PacketEncodingTest { return params.toArray(Object[][]::new); } - @DataProvider - public Object[][] versionAndRetryProvider() { + public static Object[][] versionAndRetryProvider() { final QuicVersion[] quicVersions = QuicVersion.values(); final List params = new ArrayList<>(); for (final QuicVersion version : quicVersions) { @@ -393,23 +392,23 @@ public class PacketEncodingTest { QuicConnectionId destConnectionId, List payload) { // Check created packet - assertEquals(packet.headersType(), HeadersType.LONG); - assertEquals(packet.packetType(), packetType); + assertEquals(HeadersType.LONG, packet.headersType()); + assertEquals(packetType, packet.packetType()); boolean hasLength = switch (packetType) { case VERSIONS, RETRY -> false; default -> true; }; - assertEquals(packet.hasLength(), hasLength); - assertEquals(packet.numberSpace(), packetNumberSpace); + assertEquals(hasLength, packet.hasLength()); + assertEquals(packetNumberSpace, packet.numberSpace()); if (payload == null) { assertTrue(packet.frames().isEmpty()); } else { - assertEquals(getBuffers(packet.frames()), getBuffers(payload)); + assertEquals(getBuffers(payload), getBuffers(packet.frames())); } - assertEquals(packet.version(), versionNumber); - assertEquals(packet.packetNumber(), packetNumber); - assertEquals(packet.sourceId(), srcConnectionId); - assertEquals(packet.destinationId(), destConnectionId); + assertEquals(versionNumber, packet.version()); + assertEquals(packetNumber, packet.packetNumber()); + assertEquals(srcConnectionId, packet.sourceId()); + assertEquals(destConnectionId, packet.destinationId()); } @@ -446,11 +445,11 @@ public class PacketEncodingTest { PacketType packetType, int versionNumber, QuicConnectionId srcConnectionId, QuicConnectionId destConnectionId) { - assertEquals(QuicPacketDecoder.peekHeaderType(datagram, offset), HeadersType.LONG); - assertEquals(QuicPacketDecoder.of(datagram, offset).peekPacketType(datagram, offset), packetType); + assertEquals(HeadersType.LONG, QuicPacketDecoder.peekHeaderType(datagram, offset)); + assertEquals(packetType, QuicPacketDecoder.of(datagram, offset).peekPacketType(datagram, offset)); LongHeader header = QuicPacketDecoder.peekLongHeader(datagram, offset); assertNotNull(header, "Could not parse packet header"); - assertEquals(header.version(), versionNumber); + assertEquals(versionNumber, header.version()); assertTrue(header.destinationId() .matches(destConnectionId.asReadOnlyBuffer()), "Destination ID doesn't match"); assertTrue(header.sourceId() @@ -494,10 +493,10 @@ public class PacketEncodingTest { padding.encode(buf); } if (insert) { - assertEquals(buf.position(), remaining); - assertEquals(buf.remaining(), payloadSize - remaining); + assertEquals(remaining, buf.position()); + assertEquals(payloadSize - remaining, buf.remaining()); } else { - assertEquals(buf.remaining(), 0); + assertEquals(0, buf.remaining()); } return List.copyOf(frames); } @@ -507,7 +506,7 @@ public class PacketEncodingTest { int size = outgoingQuicPacket.size(); ByteBuffer buffer = ByteBuffer.allocate(size); encoder.encode(outgoingQuicPacket, buffer, context); - assertEquals(buffer.position(), size, " for " + outgoingQuicPacket); + assertEquals(size, buffer.position(), " for " + outgoingQuicPacket); buffer.flip(); return buffer; } @@ -520,33 +519,34 @@ public class PacketEncodingTest { List payload, int minSize) { // Check created packet - assertEquals(packet.headersType(), HeadersType.SHORT); - assertEquals(packet.packetType(), packetType); - assertEquals(packet.hasLength(), false); - assertEquals(packet.numberSpace(), packetNumberSpace); - assertEquals(getBuffers(packet.frames()), getBuffers(payload, minSize)); - assertEquals(packet.packetNumber(), packetNumber); - assertEquals(packet.destinationId(), destConnectionId); + assertEquals(HeadersType.SHORT, packet.headersType()); + assertEquals(packetType, packet.packetType()); + assertEquals(false, packet.hasLength()); + assertEquals(packetNumberSpace, packet.numberSpace()); + assertEquals(getBuffers(payload, minSize), getBuffers(packet.frames())); + assertEquals(packetNumber, packet.packetNumber()); + assertEquals(destConnectionId, packet.destinationId()); } private void checkShortHeaderPacketAt(ByteBuffer datagram, int offset, PacketType packetType, QuicConnectionId destConnectionId, CodingContext context) { - assertEquals(QuicPacketDecoder.peekHeaderType(datagram, offset), HeadersType.SHORT); - assertEquals(QuicPacketDecoder.of(QuicVersion.QUIC_V1).peekPacketType(datagram, offset), packetType); - assertEquals(QuicPacketDecoder.peekVersion(datagram, offset), 0); + assertEquals(HeadersType.SHORT, QuicPacketDecoder.peekHeaderType(datagram, offset)); + assertEquals(packetType, QuicPacketDecoder.of(QuicVersion.QUIC_V1).peekPacketType(datagram, offset)); + assertEquals(0, QuicPacketDecoder.peekVersion(datagram, offset)); int pos = datagram.position(); if (pos != offset) datagram.position(offset); try { - assertEquals(QuicPacketDecoder.peekShortConnectionId(datagram, destConnectionId.length()) - .mismatch(destConnectionId.asReadOnlyBuffer()), -1); + assertEquals(-1, QuicPacketDecoder.peekShortConnectionId(datagram, destConnectionId.length()) + .mismatch(destConnectionId.asReadOnlyBuffer())); } finally { if (pos != offset) datagram.position(pos); } } - @Test(dataProvider = "longHeaderPacketProvider") + @ParameterizedTest + @MethodSource("longHeaderPacketProvider") public void testInitialPacket(QuicVersion quicVersion, int srcIdLength, int destIdLength, long packetNumber, long largestAcked) throws Exception { System.out.printf("%ntestInitialPacket(qv:%s, scid:%d, dcid:%d, pn:%d, ack:%d)%n", @@ -557,12 +557,12 @@ public class PacketEncodingTest { .newConnectionId(destIdLength, IDS.incrementAndGet()); assert destid.length <= 20; final QuicConnectionId destConnectionId = new PeerConnectionId(destid); - assertEquals(destid.length, destConnectionId.length(), "dcid length"); + assertEquals(destConnectionId.length(), destid.length, "dcid length"); destIdLength = destid.length; byte[] srcid = randomIdBytes(srcIdLength); final QuicConnectionId srcConnectionId = new PeerConnectionId(srcid); - assertEquals(srcid.length, srcConnectionId.length(), "scid length"); + assertEquals(srcConnectionId.length(), srcid.length, "scid length"); int bound = MAX_DATAGRAM_IPV6 - srcIdLength - destid.length - 7 - QuicPacketNumbers.computePacketNumberLength(packetNumber, largestAcked) @@ -603,8 +603,8 @@ public class PacketEncodingTest { byte[] payload = new byte[payloadSize]; List frames = frames(payload, padding != 0); - assertEquals(frames.stream().mapToInt(QuicFrame::size) - .reduce(0, Math::addExact), payloadSize); + assertEquals(payloadSize, frames.stream().mapToInt(QuicFrame::size) + .reduce(0, Math::addExact)); // Create an initial packet @@ -626,7 +626,7 @@ public class PacketEncodingTest { largestAcked, frames2, context); - assertEquals(padding, padding + (1200 - packet2.size())); + assertEquals(padding + (1200 - packet2.size()), padding); } // Check created packet @@ -640,10 +640,10 @@ public class PacketEncodingTest { checkLongHeaderPacket(initialPacket, PacketType.INITIAL, quicVersion.versionNumber(), PacketNumberSpace.INITIAL, packetNumber, srcConnectionId, destConnectionId, frames, padding); - assertEquals(initialPacket.tokenLength(), tokenLength); - assertEquals(initialPacket.token(), token); - assertEquals(initialPacket.hasLength(), true); - assertEquals(initialPacket.length(), packetNumberLength + payloadSize + padding); + assertEquals(tokenLength, initialPacket.tokenLength()); + assertEquals(token, initialPacket.token()); + assertEquals(true, initialPacket.hasLength()); + assertEquals(packetNumberLength + payloadSize + padding, initialPacket.length()); // Check that peeking at the encoded packet returns correct information @@ -682,9 +682,9 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(datagram.capacity()); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), second); + assertEquals(second, datagram.position()); decoder.skipPacket(datagram, second); - assertEquals(datagram.remaining(), offset); + assertEquals(offset, datagram.remaining()); datagram.position(offset); int size = second - offset; @@ -692,23 +692,24 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof InitialPacket, "decoded: " + decodedPacket); InitialPacket initialDecoded = InitialPacket.class.cast(decodedPacket); checkLongHeaderPacket(initialDecoded, PacketType.INITIAL, quicVersion.versionNumber(), PacketNumberSpace.INITIAL, packetNumber, srcConnectionId, destConnectionId, frames, padding); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); - assertEquals(initialDecoded.tokenLength(), tokenLength); - assertEquals(initialDecoded.token(), token); - assertEquals(initialDecoded.length(), initialPacket.length()); - assertEquals(initialDecoded.length(), packetNumberLength + payloadSize + padding); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); + assertEquals(tokenLength, initialDecoded.tokenLength()); + assertArrayEquals(token, initialDecoded.token()); + assertEquals(initialPacket.length(), initialDecoded.length()); + assertEquals(packetNumberLength + payloadSize + padding, initialDecoded.length()); } - assertEquals(datagram.position(), second + second - offset); + assertEquals(second + second - offset, datagram.position()); } - @Test(dataProvider = "longHeaderPacketProvider") + @ParameterizedTest + @MethodSource("longHeaderPacketProvider") public void testHandshakePacket(QuicVersion quicVersion, int srcIdLength, int destIdLength, long packetNumber, long largestAcked) throws Exception { System.out.printf("%ntestHandshakePacket(qv:%s, scid:%d, dcid:%d, pn:%d, ack:%d)%n", @@ -757,8 +758,8 @@ public class PacketEncodingTest { checkLongHeaderPacket(handshakePacket, PacketType.HANDSHAKE, quicVersion.versionNumber(), PacketNumberSpace.HANDSHAKE, packetNumber, srcConnectionId, destConnectionId, frames); - assertEquals(handshakePacket.hasLength(), true); - assertEquals(handshakePacket.length(), packetNumberLength + payloadSize); + assertEquals(true, handshakePacket.hasLength()); + assertEquals(packetNumberLength + payloadSize, handshakePacket.length()); // Decode the two packets in the datagram // Check that peeking at the encoded packet returns correct information @@ -797,9 +798,9 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(datagram.capacity()); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), second); + assertEquals(second, datagram.position()); decoder.skipPacket(datagram, second); - assertEquals(datagram.remaining(), offset); + assertEquals(offset, datagram.remaining()); datagram.position(offset); int size = second - offset; @@ -807,21 +808,22 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof HandshakePacket, "decoded: " + decodedPacket); HandshakePacket handshakeDecoded = HandshakePacket.class.cast(decodedPacket); checkLongHeaderPacket(handshakeDecoded, PacketType.HANDSHAKE, quicVersion.versionNumber(), PacketNumberSpace.HANDSHAKE, packetNumber, srcConnectionId, destConnectionId, frames); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); - assertEquals(handshakeDecoded.length(), handshakePacket.length()); - assertEquals(handshakeDecoded.length(), packetNumberLength + payloadSize); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); + assertEquals(handshakePacket.length(), handshakeDecoded.length()); + assertEquals(packetNumberLength + payloadSize, handshakeDecoded.length()); } - assertEquals(datagram.position(), second + second - offset); + assertEquals(second + second - offset, datagram.position()); } - @Test(dataProvider = "longHeaderPacketProvider") + @ParameterizedTest + @MethodSource("longHeaderPacketProvider") public void testZeroRTTPacket(QuicVersion quicVersion, int srcIdLength, int destIdLength, long packetNumber, long largestAcked) throws Exception { System.out.printf("%ntestZeroRTTPacket(qv:%s, scid:%d, dcid:%d, pn:%d, ack:%d)%n", @@ -870,8 +872,8 @@ public class PacketEncodingTest { checkLongHeaderPacket(zeroRttPacket, PacketType.ZERORTT, quicVersion.versionNumber(), PacketNumberSpace.APPLICATION, packetNumber, srcConnectionId, destConnectionId, frames); - assertEquals(zeroRttPacket.hasLength(), true); - assertEquals(zeroRttPacket.length(), packetNumberLength + payloadSize); + assertEquals(true, zeroRttPacket.hasLength()); + assertEquals(packetNumberLength + payloadSize, zeroRttPacket.length()); // Check that peeking at the encoded packet returns correct information ByteBuffer encoded = toByteBuffer(encoder, packet, context); @@ -909,9 +911,9 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(datagram.capacity()); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), second); + assertEquals(second, datagram.position()); decoder.skipPacket(datagram, second); - assertEquals(datagram.remaining(), offset); + assertEquals(offset, datagram.remaining()); // Decode the two packets in the datagram datagram.position(offset); @@ -920,21 +922,22 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof ZeroRttPacket, "decoded: " + decodedPacket); ZeroRttPacket zeroRttDecoded = ZeroRttPacket.class.cast(decodedPacket); checkLongHeaderPacket(zeroRttDecoded, PacketType.ZERORTT, quicVersion.versionNumber(), PacketNumberSpace.APPLICATION, packetNumber, srcConnectionId, destConnectionId, frames); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); - assertEquals(zeroRttDecoded.length(), zeroRttPacket.length()); - assertEquals(zeroRttDecoded.length(), packetNumberLength + payloadSize); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); + assertEquals(zeroRttPacket.length(), zeroRttDecoded.length()); + assertEquals(packetNumberLength + payloadSize, zeroRttDecoded.length()); } - assertEquals(datagram.position(), second + second - offset); + assertEquals(second + second - offset, datagram.position()); } - @Test(dataProvider = "versionAndRetryProvider") + @ParameterizedTest + @MethodSource("versionAndRetryProvider") public void testVersionNegotiationPacket(QuicVersion quicVersion, int srcIdLength, int destIdLength) throws Exception { System.out.printf("%ntestVersionNegotiationPacket(qv:%s, scid:%d, dcid:%d, pn:%d, ack:%d)%n", @@ -965,9 +968,9 @@ public class PacketEncodingTest { checkLongHeaderPacket(versionPacket, PacketType.VERSIONS, 0, PacketNumberSpace.NONE, -1, srcConnectionId, destConnectionId, null); - assertEquals(versionPacket.hasLength(), false); - assertEquals(versionPacket.supportedVersions(), - versionList.stream().mapToInt(Integer::intValue).toArray()); + assertEquals(false, versionPacket.hasLength()); + assertArrayEquals(versionList.stream().mapToInt(Integer::intValue).toArray(), + versionPacket.supportedVersions()); CodingContext context = new TestCodingContext() { @Override public long largestProcessedPN(PacketNumberSpace packetSpace) { @@ -1009,8 +1012,8 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(datagram.capacity()); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), end); - assertEquals(datagram.remaining(), 0); + assertEquals(end, datagram.position()); + assertEquals(0, datagram.remaining()); // Decode the two packets in the datagram datagram.position(offset); @@ -1019,21 +1022,22 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof VersionNegotiationPacket, "decoded: " + decodedPacket); VersionNegotiationPacket decodedVersion = VersionNegotiationPacket.class.cast(decodedPacket); checkLongHeaderPacket(decodedVersion, PacketType.VERSIONS, 0, PacketNumberSpace.NONE, -1, srcConnectionId, destConnectionId, null); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); - assertEquals(decodedVersion.supportedVersions(), - versionList.stream().mapToInt(Integer::intValue).toArray()); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); + assertArrayEquals(versionList.stream().mapToInt(Integer::intValue).toArray(), + decodedVersion.supportedVersions()); } - assertEquals(datagram.position(), end); + assertEquals(end, datagram.position()); } - @Test(dataProvider = "versionAndRetryProvider") + @ParameterizedTest + @MethodSource("versionAndRetryProvider") public void testRetryPacket(QuicVersion quicVersion, int srcIdLength, int destIdLength) throws Exception { System.out.printf("%ntestRetryPacket(qv:%s, scid:%d, dcid:%d, pn:%d, ack:%d)%n", @@ -1067,9 +1071,9 @@ public class PacketEncodingTest { checkLongHeaderPacket(retryPacket, PacketType.RETRY, quicVersion.versionNumber(), PacketNumberSpace.NONE, -1, srcConnectionId, destConnectionId, null); - assertEquals(retryPacket.hasLength(), false); - assertEquals(retryPacket.retryToken(), retryToken); - assertEquals(retryPacket.size(), expectedSize); + assertEquals(false, retryPacket.hasLength()); + assertArrayEquals(retryToken, retryPacket.retryToken()); + assertEquals(expectedSize, retryPacket.size()); CodingContext context = new TestCodingContext() { @Override public long largestProcessedPN(PacketNumberSpace packetSpace) { @@ -1112,8 +1116,8 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(datagram.capacity()); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), end); - assertEquals(datagram.remaining(), 0); + assertEquals(end, datagram.position()); + assertEquals(0, datagram.remaining()); // Decode the two packets in the datagram datagram.position(offset); @@ -1122,21 +1126,22 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof RetryPacket, "decoded: " + decodedPacket); RetryPacket decodedRetry = RetryPacket.class.cast(decodedPacket); checkLongHeaderPacket(decodedRetry, PacketType.RETRY, quicVersion.versionNumber(), PacketNumberSpace.NONE, -1, srcConnectionId, destConnectionId, null); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); - assertEquals(decodedPacket.size(), expectedSize); - assertEquals(decodedRetry.retryToken(), retryToken); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); + assertEquals(expectedSize, decodedPacket.size()); + assertArrayEquals(retryToken, decodedRetry.retryToken()); } - assertEquals(datagram.position(), end); + assertEquals(end, datagram.position()); } - @Test(dataProvider = "shortHeaderPacketProvider") + @ParameterizedTest + @MethodSource("shortHeaderPacketProvider") public void testOneRTTPacket(QuicVersion quicVersion, int destIdLength, long packetNumber, long largestAcked) throws Exception { System.out.printf("%ntestOneRTTPacket(qv:%s, dcid:%d, pn:%d, ack:%d)%n", @@ -1186,8 +1191,8 @@ public class PacketEncodingTest { checkShortHeaderPacket(packet, PacketType.ONERTT, PacketNumberSpace.APPLICATION, packetNumber, destConnectionId, frames, minPayloadSize); - assertEquals(packet.hasLength(), false); - assertEquals(packet.size(), expectedSize); + assertEquals(false, packet.hasLength()); + assertEquals(expectedSize, packet.size()); // Check that peeking at the encoded packet returns correct information ByteBuffer encoded = toByteBuffer(encoder, packet, context); @@ -1218,9 +1223,9 @@ public class PacketEncodingTest { datagram.position(0); datagram.limit(end); decoder.skipPacket(datagram, offset); - assertEquals(datagram.position(), offset + expectedSize); - assertEquals(datagram.position(), datagram.limit()); - assertEquals(datagram.position(), datagram.capacity() - offset); + assertEquals(offset + expectedSize, datagram.position()); + assertEquals(datagram.limit(), datagram.position()); + assertEquals(datagram.capacity() - offset, datagram.position()); // Decode the packet in the datagram @@ -1230,7 +1235,7 @@ public class PacketEncodingTest { int pos = datagram.position(); System.out.printf("Decoding packet: %d at %d%n", (i+1), pos); var decodedPacket = decoder.decode(datagram, context); - assertEquals(datagram.position(), pos + size); + assertEquals(pos + size, datagram.position()); assertTrue(decodedPacket instanceof OneRttPacket, "decoded: " + decodedPacket); OneRttPacket oneRttDecoded = OneRttPacket.class.cast(decodedPacket); List expectedFrames = frames; @@ -1258,12 +1263,12 @@ public class PacketEncodingTest { checkShortHeaderPacket(oneRttDecoded, PacketType.ONERTT, PacketNumberSpace.APPLICATION, packetNumber, destConnectionId, expectedFrames, minPayloadSize); - assertEquals(decodedPacket.size(), packet.size()); - assertEquals(decodedPacket.size(), size); + assertEquals(packet.size(), decodedPacket.size()); + assertEquals(size, decodedPacket.size()); } - assertEquals(datagram.position(), offset + size); - assertEquals(datagram.remaining(), 0); - assertEquals(datagram.limit(), end); + assertEquals(offset + size, datagram.position()); + assertEquals(0, datagram.remaining()); + assertEquals(end, datagram.limit()); } @@ -1299,15 +1304,15 @@ public class PacketEncodingTest { ByteBuffer.wrap(new byte[] {16, 17}), ByteBuffer.wrap(new byte[] {18, 19, 20}) ); - assertEquals(Utils.mismatch(match1, match1), -1); - assertEquals(Utils.mismatch(match2, match2), -1); - assertEquals(Utils.mismatch(match3, match3), -1); - assertEquals(Utils.mismatch(match1, match2), -1); - assertEquals(Utils.mismatch(match2, match1), -1); - assertEquals(Utils.mismatch(match1, match3), -1); - assertEquals(Utils.mismatch(match3, match1), -1); - assertEquals(Utils.mismatch(match2, match3), -1); - assertEquals(Utils.mismatch(match3, match2), -1); + assertEquals(-1, Utils.mismatch(match1, match1)); + assertEquals(-1, Utils.mismatch(match2, match2)); + assertEquals(-1, Utils.mismatch(match3, match3)); + assertEquals(-1, Utils.mismatch(match1, match2)); + assertEquals(-1, Utils.mismatch(match2, match1)); + assertEquals(-1, Utils.mismatch(match1, match3)); + assertEquals(-1, Utils.mismatch(match3, match1)); + assertEquals(-1, Utils.mismatch(match2, match3)); + assertEquals(-1, Utils.mismatch(match3, match2)); } @Test @@ -1413,25 +1418,25 @@ public class PacketEncodingTest { ByteBuffer.wrap(new byte[] {18, 19, 20, 41, 42, 43}) ); - assertEquals(Utils.mismatch(nomatch0, nomatch0), -1L); - assertEquals(Utils.mismatch(nomatch10, nomatch10), -1L); - assertEquals(Utils.mismatch(nomatch19, nomatch19), -1L); - assertEquals(Utils.mismatch(morematch1, morematch1), -1L); - assertEquals(Utils.mismatch(morematch2, morematch2), -1L); - assertEquals(Utils.mismatch(morematch3, morematch3), -1L); - assertEquals(Utils.mismatch(morematch2, morematch3), -1L); - assertEquals(Utils.mismatch(morematch3, morematch2), -1L); + assertEquals(-1L, Utils.mismatch(nomatch0, nomatch0)); + assertEquals(-1L, Utils.mismatch(nomatch10, nomatch10)); + assertEquals(-1L, Utils.mismatch(nomatch19, nomatch19)); + assertEquals(-1L, Utils.mismatch(morematch1, morematch1)); + assertEquals(-1L, Utils.mismatch(morematch2, morematch2)); + assertEquals(-1L, Utils.mismatch(morematch3, morematch3)); + assertEquals(-1L, Utils.mismatch(morematch2, morematch3)); + assertEquals(-1L, Utils.mismatch(morematch3, morematch2)); for (var match : List.of(match1, match2, match3)) { - assertEquals(Utils.mismatch(match, nomatch0), 0L); - assertEquals(Utils.mismatch(match, nomatch10), 10L); - assertEquals(Utils.mismatch(match, nomatch19), 19L); - assertEquals(Utils.mismatch(nomatch0, match), 0L); - assertEquals(Utils.mismatch(nomatch10, match), 10L); - assertEquals(Utils.mismatch(nomatch19, match), 19L); + assertEquals(0L, Utils.mismatch(match, nomatch0)); + assertEquals(10L, Utils.mismatch(match, nomatch10)); + assertEquals(19L, Utils.mismatch(match, nomatch19)); + assertEquals(0L, Utils.mismatch(nomatch0, match)); + assertEquals(10L, Utils.mismatch(nomatch10, match)); + assertEquals(19L, Utils.mismatch(nomatch19, match)); for (var morematch : List.of(morematch1, morematch2, morematch3)) { - assertEquals(Utils.mismatch(match, morematch), 20L); - assertEquals(Utils.mismatch(morematch, match), 20L); + assertEquals(20L, Utils.mismatch(match, morematch)); + assertEquals(20L, Utils.mismatch(morematch, match)); } } diff --git a/test/jdk/java/net/httpclient/quic/PacketLossTest.java b/test/jdk/java/net/httpclient/quic/PacketLossTest.java index 1f75e1feb95..a597c826e73 100644 --- a/test/jdk/java/net/httpclient/quic/PacketLossTest.java +++ b/test/jdk/java/net/httpclient/quic/PacketLossTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -158,7 +158,7 @@ public class PacketLossTest { private static void startServer(final QuicStandaloneServer server) throws IOException { // add a handler which deals with incoming connections - server.addHandler(new EchoHandler(HELLO_MSG.length)); + server.setHandler(new EchoHandler(HELLO_MSG.length)); server.start(); System.out.println("Server " + server.name() + " started at " + server.getAddress()); } diff --git a/test/jdk/java/net/httpclient/quic/PacketNumbersTest.java b/test/jdk/java/net/httpclient/quic/PacketNumbersTest.java index 3a4237d0847..c018079ea4e 100644 --- a/test/jdk/java/net/httpclient/quic/PacketNumbersTest.java +++ b/test/jdk/java/net/httpclient/quic/PacketNumbersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,16 +27,17 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; import jdk.internal.net.http.quic.packets.QuicPacketNumbers; -import org.testng.SkipException; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.expectThrows; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -/** +/* * @test - * @run testng PacketNumbersTest + * @run junit PacketNumbersTest */ public class PacketNumbersTest { @@ -85,8 +86,7 @@ public class PacketNumbersTest { } } - @DataProvider - public Object[][] encode() { + public static Object[][] encode() { return List.of( // these first three test cases are extracted from RFC 9000, appendix A.2 and A.3 new TestCase("success", 0xa82f9b32L, 0xa82f30eaL, EncodeResult.success(0x9b32)), @@ -127,19 +127,18 @@ public class PacketNumbersTest { .toArray(Object[][]::new); } - @Test(dataProvider = "encode") + @ParameterizedTest + @MethodSource("encode") public void testEncodePacketNumber(TestCase test) { System.out.println(test); if (test.result().assertion()) { - if (!QuicPacketNumbers.class.desiredAssertionStatus()) { - throw new SkipException("needs assertion enabled (-esa)"); - } - Throwable t = expectThrows(test.result().failure(), test::encode); + Assumptions.assumeFalse(!QuicPacketNumbers.class.desiredAssertionStatus(), "needs assertion enabled (-esa)"); + Throwable t = Assertions.assertThrows(test.result().failure(), test::encode); System.out.println("Got expected assertion: " + t); return; } if (test.result().fail()) { - Throwable t = expectThrows(test.result().failure(), test::encode); + Throwable t = Assertions.assertThrows(test.result().failure(), test::encode); System.out.println("Got expected exception: " + t); return; @@ -152,8 +151,8 @@ public class PacketNumbersTest { } // encode the full PN - check that the truncated PN == expected - assertEquals(truncated, test.result().expected()); + assertEquals(test.result().expected(), truncated); // check that decode(encoded) == fullPN - assertEquals(test.decode(), test.fullPN()); + assertEquals(test.fullPN(), test.decode()); } } diff --git a/test/jdk/java/net/httpclient/quic/PacketSpaceManagerTest.java b/test/jdk/java/net/httpclient/quic/PacketSpaceManagerTest.java index 40497ec13da..fe3b748a2fa 100644 --- a/test/jdk/java/net/httpclient/quic/PacketSpaceManagerTest.java +++ b/test/jdk/java/net/httpclient/quic/PacketSpaceManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -73,34 +73,35 @@ import jdk.internal.net.quic.QuicVersion; import jdk.internal.net.quic.QuicTransportException; import jdk.internal.net.quic.QuicTransportParametersConsumer; import jdk.test.lib.RandomFactory; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.crypto.AEADBadTagException; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSession; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -/** +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/* * @test * @summary tests the logic to build an AckFrame * @library /test/lib * @library ../debug * @build java.net.http/jdk.internal.net.http.common.TestLoggerUtil - * @run testng/othervm PacketSpaceManagerTest - * @run testng/othervm -Dseed=-7947549564260911920 PacketSpaceManagerTest - * @run testng/othervm -Dseed=-5413111674202728207 PacketSpaceManagerTest - * @run testng/othervm -Dseed=-176652423987357212 PacketSpaceManagerTest - * @run testng/othervm -Dseed=6550551791799910315 PacketSpaceManagerTest - * @run testng/othervm -Dseed=-4159871071396382784 PacketSpaceManagerTest - * @run testng/othervm -Dseed=2252276218459363615 PacketSpaceManagerTest - * @run testng/othervm -Dseed=-5130588140709404919 PacketSpaceManagerTest + * @run junit/othervm PacketSpaceManagerTest + * @run junit/othervm -Dseed=-7947549564260911920 PacketSpaceManagerTest + * @run junit/othervm -Dseed=-5413111674202728207 PacketSpaceManagerTest + * @run junit/othervm -Dseed=-176652423987357212 PacketSpaceManagerTest + * @run junit/othervm -Dseed=6550551791799910315 PacketSpaceManagerTest + * @run junit/othervm -Dseed=-4159871071396382784 PacketSpaceManagerTest + * @run junit/othervm -Dseed=2252276218459363615 PacketSpaceManagerTest + * @run junit/othervm -Dseed=-5130588140709404919 PacketSpaceManagerTest */ // -Djdk.internal.httpclient.debug=true public class PacketSpaceManagerTest { @@ -337,7 +338,7 @@ public class PacketSpaceManagerTest { * @param first the first packet acknowledged, inclusive * @param last the last packet acknowledged, inclusive */ - public static record Acknowledged(long first, long last) { + public record Acknowledged(long first, long last) { public Acknowledged { assert first >= 0 && first <= last; } @@ -360,7 +361,7 @@ public class PacketSpaceManagerTest { * @param packetNumber the packet number of the packet to send * @param delay a delay before the next packet should be emitted */ - public static record Packet(long packetNumber, long delay) { + public record Packet(long packetNumber, long delay) { Packet(long packetNumber) { this(packetNumber, RANDOM.nextLong(1, 255)); } @@ -391,7 +392,7 @@ public class PacketSpaceManagerTest { * before it's been emitted). * @param shuffled whether the list of packets is shuffled. */ - public static record TestCase(List acks, + public record TestCase(List acks, List packets, List ackframes, boolean shuffled) { @@ -440,7 +441,7 @@ public class PacketSpaceManagerTest { * a list of special testcases, and a list of random testcases. * @return A list of TestCases to test. */ - List generateTests() { + static List generateTests() { List tests = new ArrayList<>(); List simples = List.of( new TestCase(List.of(new Acknowledged(5,5))), @@ -485,7 +486,7 @@ public class PacketSpaceManagerTest { * A packet should only be present once. * @return a random list of increasing acknowledgement ranges. */ - List generateAcks() { + static List generateAcks() { int count = RANDOM.nextInt(3, 10); List acks = new ArrayList<>(count); long prev = -1; @@ -516,8 +517,7 @@ public class PacketSpaceManagerTest { return res; } - @DataProvider(name = "tests") - public Object[][] tests() { + public static Object[][] tests() { return generateTests().stream() .map(List::of) .map(List::toArray) @@ -757,7 +757,7 @@ public class PacketSpaceManagerTest { final CopyOnWriteArrayList retransmissions = new CopyOnWriteArrayList<>(); final CopyOnWriteArrayList successfulExpectations = new CopyOnWriteArrayList<>(); - static record Retransmission(long packetNumber, Deadline atOrAfter, long largestAckSent) { + record Retransmission(long packetNumber, Deadline atOrAfter, long largestAckSent) { boolean isFor(long number) { return number == packetNumber; } @@ -774,7 +774,7 @@ public class PacketSpaceManagerTest { * the test. * This method checks that the retransmission logic works as * expected. - * @throws Exception + * @throws Exception if the call fails */ // TODO: in the end we need to check that everything that was // expected to happen happened. What is missing is to @@ -890,7 +890,7 @@ public class PacketSpaceManagerTest { .stream().filter(AckFrame.class::isInstance) .map(AckFrame.class::cast) .toList(); - assertEquals(frames.size(), 1, + assertEquals(1, frames.size(), "unexpected ack frames: " + frames); AckFrame ackFrame = ackFrames.get(0); LongStream.range(firstAckPaket, lastAckPacket + 1) @@ -1029,10 +1029,11 @@ public class PacketSpaceManagerTest { void check() { assertFalse(now().isBefore(timeSource.first.plusMillis(timeline))); assertTrue(expectedRetransmissions.isEmpty()); - assertEquals(retransmissions.stream() + assertEquals(successfulExpectations.stream() .map(Retransmission::packetNumber) .filter(pn -> pn <= maxPacketNumber).toList(), - successfulExpectations.stream().map(Retransmission::packetNumber) + retransmissions.stream() + .map(Retransmission::packetNumber) .filter(pn -> pn <= maxPacketNumber).toList()); for (Retransmission r : retransmissions) { if (r.packetNumber > maxPacketNumber || @@ -1040,14 +1041,14 @@ public class PacketSpaceManagerTest { List succesful = successfulExpectations.stream() .filter(s -> s.isFor(r.packetNumber)) .toList(); - assertEquals(succesful.size(), 1); + assertEquals(1, succesful.size()); succesful.forEach(s -> assertFalse(s.atOrAfter.isAfter(r.atOrAfter))); } List acknowledged = new ArrayList<>(acknowledgePackets(allAcks.build())); Collections.sort(acknowledged); - assertEquals(acknowledged, test.packets.stream() - .map(Packet::packetNumber).sorted().toList()); + assertEquals(test.packets.stream() + .map(Packet::packetNumber).sorted().toList(), acknowledged); } // TODO: add a LongStream acknowledged() to AckFrame - write a spliterator @@ -1073,8 +1074,8 @@ public class PacketSpaceManagerTest { default String negation() { return (this == FALSE) ? "doesn't " : ""; } - Assertion TRUE = Assert::assertTrue; - Assertion FALSE = Assert::assertFalse; + Assertion TRUE = Assertions::assertTrue; + Assertion FALSE = Assertions::assertFalse; } static void assertContains(Assertion assertion, List list, long number, String desc) { assertion.check(list.contains(number), @@ -1115,7 +1116,8 @@ public class PacketSpaceManagerTest { } } - @Test(dataProvider = "tests") + @ParameterizedTest + @MethodSource("tests") public void testPacketSpaceManager(TestCase testCase) throws Exception { System.out.printf("%n ------- testPacketSpaceManager ------- %n"); SynchronousTestDriver driver = new SynchronousTestDriver(testCase); diff --git a/test/jdk/java/net/httpclient/quic/QuicFramesDecoderTest.java b/test/jdk/java/net/httpclient/quic/QuicFramesDecoderTest.java index f0d4b316e46..ef0801e6c18 100644 --- a/test/jdk/java/net/httpclient/quic/QuicFramesDecoderTest.java +++ b/test/jdk/java/net/httpclient/quic/QuicFramesDecoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,20 +24,20 @@ import jdk.internal.net.http.quic.frames.QuicFrame; import jdk.internal.net.quic.QuicTransportErrors; import jdk.internal.net.quic.QuicTransportException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.nio.ByteBuffer; import java.util.HexFormat; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @library /test/lib * @summary Tests to check QUIC frame decoding errors are handled correctly - * @run testng/othervm QuicFramesDecoderTest + * @run junit/othervm QuicFramesDecoderTest */ public class QuicFramesDecoderTest { @@ -181,7 +181,6 @@ public class QuicFramesDecoderTest { private static final byte[] NEW_CONNECTION_ID_ZERO = HexFormat.of().parseHex("181716"+ "00"+"0f0e0d0c0b0a09080706050403020100"); - @DataProvider public static Object[][] goodFrames() { return new Object[][]{ new Object[]{"ack without ecn", ACK_BASE, false}, @@ -226,7 +225,6 @@ public class QuicFramesDecoderTest { }; } - @DataProvider public static Object[][] badFrames() { return new Object[][]{ new Object[]{"ack without ecn, negative pn", ACK_NEG_BASE}, @@ -242,7 +240,8 @@ public class QuicFramesDecoderTest { }; } - @Test(dataProvider = "goodFrames") + @ParameterizedTest + @MethodSource("goodFrames") public void testReencode(String desc, byte[] frame, boolean bloated) throws Exception { // check if the goodFrames provider indeed contains good frames ByteBuffer buf = ByteBuffer.wrap(frame); @@ -250,16 +249,17 @@ public class QuicFramesDecoderTest { assertFalse(buf.hasRemaining(), buf.remaining() + " bytes left in buffer after parsing"); // some frames deliberately use suboptimal encoding, skip them if (bloated) return; - assertEquals(qf.size(), frame.length, "Frame size mismatch"); + assertEquals(frame.length, qf.size(), "Frame size mismatch"); buf.clear(); ByteBuffer encoded = ByteBuffer.allocate(frame.length); qf.encode(encoded); assertFalse(encoded.hasRemaining(), "Actual frame length mismatch"); encoded.flip(); - assertEquals(buf, encoded, "Encoded buffer is different from the original one"); + assertEquals(encoded, buf, "Encoded buffer is different from the original one"); } - @Test(dataProvider = "goodFrames") + @ParameterizedTest + @MethodSource("goodFrames") public void testToString(String desc, byte[] frame, boolean bloated) throws Exception { // check if the goodFrames provider indeed contains good frames ByteBuffer buf = ByteBuffer.wrap(frame); @@ -268,7 +268,8 @@ public class QuicFramesDecoderTest { System.out.println(qf); // should not throw } - @Test(dataProvider = "goodFrames") + @ParameterizedTest + @MethodSource("goodFrames") public void testTruncatedFrame(String desc, byte[] frame, boolean bloated) throws Exception { // check if parsing a truncated frame throws the right error ByteBuffer buf = ByteBuffer.wrap(frame); @@ -279,12 +280,13 @@ public class QuicFramesDecoderTest { var qf = QuicFrame.decode(buf); fail("Expected the decoder to throw on length " + i + ", got: " + qf); } catch (QuicTransportException e) { - assertEquals(e.getErrorCode(), QuicTransportErrors.FRAME_ENCODING_ERROR.code()); + assertEquals(QuicTransportErrors.FRAME_ENCODING_ERROR.code(), e.getErrorCode()); } } } - @Test(dataProvider = "badFrames") + @ParameterizedTest + @MethodSource("badFrames") public void testBadFrame(String desc, byte[] frame) throws Exception { // check if parsing a bad frame throws the right error ByteBuffer buf = ByteBuffer.wrap(frame); @@ -292,7 +294,7 @@ public class QuicFramesDecoderTest { var qf = QuicFrame.decode(buf); fail("Expected the decoder to throw, got: "+qf); } catch (QuicTransportException e) { - assertEquals(e.getErrorCode(), QuicTransportErrors.FRAME_ENCODING_ERROR.code()); + assertEquals(QuicTransportErrors.FRAME_ENCODING_ERROR.code(), e.getErrorCode()); } } } diff --git a/test/jdk/java/net/httpclient/quic/QuicRequestResponseTest.java b/test/jdk/java/net/httpclient/quic/QuicRequestResponseTest.java index 9d5c35f5414..2393ac7df12 100644 --- a/test/jdk/java/net/httpclient/quic/QuicRequestResponseTest.java +++ b/test/jdk/java/net/httpclient/quic/QuicRequestResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,9 +43,10 @@ import jdk.internal.net.http.quic.QuicClient; import jdk.internal.net.quic.QuicTLSContext; import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -54,31 +55,31 @@ import org.testng.annotations.Test; * jdk.httpclient.test.lib.quic.ClientConnection * jdk.httpclient.test.lib.common.TestUtil * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true QuicRequestResponseTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true QuicRequestResponseTest */ public class QuicRequestResponseTest { - private QuicStandaloneServer server; + private static QuicStandaloneServer server; private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - private ExecutorService executor; + private static ExecutorService executor; private static final byte[] HELLO_MSG = "Hello Quic".getBytes(StandardCharsets.UTF_8); - @BeforeClass - public void beforeClass() throws Exception { + @BeforeAll + public static void beforeClass() throws Exception { executor = Executors.newCachedThreadPool(); server = QuicStandaloneServer.newBuilder() .availableVersions(new QuicVersion[]{QuicVersion.QUIC_V1}) .sslContext(sslContext) .build(); // add a handler which deals with incoming connections - server.addHandler(new EchoHandler(HELLO_MSG.length)); + server.setHandler(new EchoHandler(HELLO_MSG.length)); server.start(); System.out.println("Server started at " + server.getAddress()); } - @AfterClass - public void afterClass() throws Exception { + @AfterAll + public static void afterClass() throws Exception { if (server != null) { System.out.println("Stopping server " + server.getAddress()); server.close(); diff --git a/test/jdk/java/net/httpclient/quic/StatelessResetReceiptTest.java b/test/jdk/java/net/httpclient/quic/StatelessResetReceiptTest.java index a20494095bd..9f7852740b4 100644 --- a/test/jdk/java/net/httpclient/quic/StatelessResetReceiptTest.java +++ b/test/jdk/java/net/httpclient/quic/StatelessResetReceiptTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -128,7 +128,7 @@ public class StatelessResetReceiptTest { public void testActiveConnection() throws Exception { final CompletableFuture serverConnCF = new MinimalFuture<>(); final NotifyingHandler handler = new NotifyingHandler(serverConnCF); - server.addHandler(handler); + server.setHandler(handler); try (final QuicClient client = createClient()) { // create a QUIC connection to the server final ClientConnection conn = ClientConnection.establishConnection(client, @@ -162,7 +162,7 @@ public class StatelessResetReceiptTest { public void testClosingConnection() throws Exception { final CompletableFuture serverConnCF = new MinimalFuture<>(); final NotifyingHandler handler = new NotifyingHandler(serverConnCF); - server.addHandler(handler); + server.setHandler(handler); try (final QuicClient client = createClient()) { // create a QUIC connection to the server final ClientConnection conn = ClientConnection.establishConnection(client, @@ -215,7 +215,7 @@ public class StatelessResetReceiptTest { public void testDrainingConnection() throws Exception { final CompletableFuture serverConnCF = new MinimalFuture<>(); final NotifyingHandler handler = new NotifyingHandler(serverConnCF); - server.addHandler(handler); + server.setHandler(handler); try (final QuicClient client = createClient()) { // create a QUIC connection to the server final ClientConnection conn = ClientConnection.establishConnection(client, diff --git a/test/jdk/java/net/httpclient/quic/VariableLengthTest.java b/test/jdk/java/net/httpclient/quic/VariableLengthTest.java index aec3e999812..cf05b91b18f 100644 --- a/test/jdk/java/net/httpclient/quic/VariableLengthTest.java +++ b/test/jdk/java/net/httpclient/quic/VariableLengthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,32 +22,31 @@ */ import jdk.internal.net.http.quic.VariableLengthEncoder; import jtreg.SkippedException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.ByteBuffer; import java.util.List; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; +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; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test * @library /test/lib * @modules java.net.http/jdk.internal.net.http.quic - * @run testng/othervm VariableLengthTest + * @run junit/othervm VariableLengthTest * @summary Tests to check quic/util methods encode/decodeVariableLength methods * work as expected. */ public class VariableLengthTest { static final Class IAE = IllegalArgumentException.class; - @DataProvider(name = "decode invariants") - public Object[][] decodeInvariants() { + public static Object[][] decodeInvariants() { return new Object[][] { { new byte[]{7}, 7, 1 }, // 00 @@ -59,8 +58,7 @@ public class VariableLengthTest { { new byte[]{-65}, -1, 0 }, }; } - @DataProvider(name = "encode invariants") - public Object[][] encodeInvariants() { + public static Object[][] encodeInvariants() { return new Object[][] { { 7, 1, null }, // 00 @@ -71,8 +69,7 @@ public class VariableLengthTest { { -1, 0, IAE }, }; } - @DataProvider(name = "prefix invariants") - public Object[][] prefixInvariants() { + public static Object[][] prefixInvariants() { return new Object[][] { { Long.MAX_VALUE, 0, IAE }, @@ -111,27 +108,30 @@ public class VariableLengthTest { }; } - @Test(dataProvider = "decode invariants") + @ParameterizedTest + @MethodSource("decodeInvariants") public void testDecode(byte[] values, long expectedLength, int expectedPosition) { ByteBuffer bb = ByteBuffer.wrap(values); var actualLength = VariableLengthEncoder.decode(bb); - assertEquals(actualLength, expectedLength); + assertEquals(expectedLength, actualLength); var actualPosition = bb.position(); - assertEquals(actualPosition, expectedPosition); + assertEquals(expectedPosition, actualPosition); } - @Test(dataProvider = "decode invariants") + @ParameterizedTest + @MethodSource("decodeInvariants") public void testPeek(byte[] values, long expectedLength, int expectedPosition) { ByteBuffer bb = ByteBuffer.wrap(values); var actualLength = VariableLengthEncoder.peekEncodedValue(bb, 0); - assertEquals(actualLength, expectedLength); + assertEquals(expectedLength, actualLength); var actualPosition = bb.position(); - assertEquals(actualPosition, 0); + assertEquals(0, actualPosition); } - @Test(dataProvider = "encode invariants") + @ParameterizedTest + @MethodSource("encodeInvariants") public void testEncode(long length, int capacity, Class exception) throws IOException { var actualBuffer = ByteBuffer.allocate(capacity); var expectedBuffer = getTestBuffer(length, capacity); @@ -140,46 +140,48 @@ public class VariableLengthTest { assertThrows(exception, () -> VariableLengthEncoder.encode(actualBuffer, length)); // if method fails ensure that position hasn't changed var actualPosition = actualBuffer.position(); - assertEquals(actualPosition, capacity); + assertEquals(capacity, actualPosition); } else { VariableLengthEncoder.encode(actualBuffer, length); var actualPosition = actualBuffer.position(); - assertEquals(actualPosition, capacity); + assertEquals(capacity, actualPosition); // check length prefix int firstByte = actualBuffer.get(0) & 0xFF; int lengthPrefix = firstByte & 0xC0; lengthPrefix >>= 6; int expectedValue = (int)(Math.log(capacity) / Math.log(2)); - assertEquals(lengthPrefix, expectedValue); + assertEquals(expectedValue, lengthPrefix); // check length encoded in buffer correctly int b = firstByte & 0x3F; actualBuffer.put(0, (byte) b); - assertEquals(actualBuffer.compareTo(expectedBuffer), 0); + assertEquals(0, actualBuffer.compareTo(expectedBuffer)); } } - @Test(dataProvider = "prefix invariants") + @ParameterizedTest + @MethodSource("prefixInvariants") public void testLengthPrefix(long length, int expectedPrefix, Class exception) { if (exception != null) { assertThrows(exception, () -> VariableLengthEncoder.getVariableLengthPrefix(length)); } else { var actualValue = VariableLengthEncoder.getVariableLengthPrefix(length); - assertEquals(actualValue, expectedPrefix); + assertEquals(expectedPrefix, actualValue); } } // Encode the given length and then decodes it and compares // the results, asserting various invariants along the way. - @Test(dataProvider = "prefix invariants") + @ParameterizedTest + @MethodSource("prefixInvariants") public void testEncodeDecode(long length, int expectedPrefix, Class exception) { if (exception != null) { assertThrows(exception, () -> VariableLengthEncoder.getEncodedSize(length)); assertThrows(exception, () -> VariableLengthEncoder.encode(ByteBuffer.allocate(16), length)); } else { var actualSize = VariableLengthEncoder.getEncodedSize(length); - assertEquals(actualSize, 1 << expectedPrefix); + assertEquals(1 << expectedPrefix, actualSize); assertTrue(actualSize > 0, "length is negative or zero: " + actualSize); assertTrue(actualSize < 9, "length is too big: " + actualSize); @@ -199,33 +201,33 @@ public class VariableLengthTest { longer.position(offset); // attempt to encode with a buffer too short - expectThrows(IAE, () -> VariableLengthEncoder.encode(shorter, length)); - assertEquals(shorter.position(), offset); - assertEquals(shorter.limit(), shorter.capacity()); + assertThrows(IAE, () -> VariableLengthEncoder.encode(shorter, length)); + assertEquals(offset, shorter.position()); + assertEquals(shorter.capacity(), shorter.limit()); - assertEquals(shorter.mismatch(shorterref), -1); - assertEquals(shorterref.mismatch(shorter), -1); + assertEquals(-1, shorter.mismatch(shorterref)); + assertEquals(-1, shorterref.mismatch(shorter)); // attempt to encode with a buffer that has the exact size var exactres = VariableLengthEncoder.encode(exact, length); - assertEquals(exactres, actualSize); - assertEquals(exact.position(), actualSize + offset); + assertEquals(actualSize, exactres); + assertEquals(actualSize + offset, exact.position()); assertFalse(exact.hasRemaining()); // attempt to encode with a buffer that has more bytes var longres = VariableLengthEncoder.encode(longer, length); - assertEquals(longres, actualSize); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.limit(), longer.capacity()); - assertEquals(longer.remaining(), 10); + assertEquals(actualSize, longres); + assertEquals(offset + actualSize, longer.position()); + assertEquals(longer.capacity(), longer.limit()); + assertEquals(10, longer.remaining()); // compare encodings // first reset buffer positions for reading. exact.position(offset); longer.position(offset); - assertEquals(longer.mismatch(exact), actualSize); - assertEquals(exact.mismatch(longer), actualSize); + assertEquals(actualSize, longer.mismatch(exact)); + assertEquals(actualSize, exact.mismatch(longer)); // decode with a buffer that is missing the last // byte... @@ -233,21 +235,21 @@ public class VariableLengthTest { shortSlice.position(offset); shortSlice.limit(offset + actualSize -1); var actualLength = VariableLengthEncoder.decode(shortSlice); - assertEquals(actualLength, -1L); - assertEquals(shortSlice.position(), offset); - assertEquals(shortSlice.limit(), offset + actualSize - 1); + assertEquals(-1L, actualLength); + assertEquals(offset, shortSlice.position()); + assertEquals(offset + actualSize - 1, shortSlice.limit()); // decode with the exact buffer actualLength = VariableLengthEncoder.decode(exact); - assertEquals(actualLength, length); - assertEquals(exact.position(), offset + actualSize); + assertEquals(length, actualLength); + assertEquals(offset + actualSize, exact.position()); assertFalse(exact.hasRemaining()); // decode with the longer buffer actualLength = VariableLengthEncoder.decode(longer); - assertEquals(actualLength, length); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.remaining(), 10); + assertEquals(length, actualLength); + assertEquals(offset + actualSize, longer.position()); + assertEquals(10, longer.remaining()); } } @@ -255,7 +257,8 @@ public class VariableLengthTest { // Encode the given length and then peeks it and compares // the results, asserting various invariants along the way. - @Test(dataProvider = "prefix invariants") + @ParameterizedTest + @MethodSource("prefixInvariants") public void testEncodePeek(long length, int expectedPrefix, Class exception) { if (exception != null) { assertThrows(exception, () -> VariableLengthEncoder.getEncodedSize(length)); @@ -264,7 +267,7 @@ public class VariableLengthTest { } var actualSize = VariableLengthEncoder.getEncodedSize(length); - assertEquals(actualSize, 1 << expectedPrefix); + assertEquals(1 << expectedPrefix, actualSize); assertTrue(actualSize > 0, "length is negative or zero: " + actualSize); assertTrue(actualSize < 9, "length is too big: " + actualSize); @@ -281,24 +284,24 @@ public class VariableLengthTest { // attempt to encode with a buffer that has the exact size var exactres = VariableLengthEncoder.encode(exact, length); - assertEquals(exactres, actualSize); - assertEquals(exact.position(), actualSize + offset); + assertEquals(actualSize, exactres); + assertEquals(actualSize + offset, exact.position()); assertFalse(exact.hasRemaining()); // attempt to encode with a buffer that has more bytes var longres = VariableLengthEncoder.encode(longer, length); - assertEquals(longres, actualSize); - assertEquals(longer.position(), offset + actualSize); - assertEquals(longer.limit(), longer.capacity()); - assertEquals(longer.remaining(), 10); + assertEquals(actualSize, longres); + assertEquals(offset + actualSize, longer.position()); + assertEquals(longer.capacity(), longer.limit()); + assertEquals(10, longer.remaining()); // compare encodings // first reset buffer positions for reading. exact.position(offset); longer.position(offset); - assertEquals(longer.mismatch(exact), actualSize); - assertEquals(exact.mismatch(longer), actualSize); + assertEquals(actualSize, longer.mismatch(exact)); + assertEquals(actualSize, exact.mismatch(longer)); exact.position(0); longer.position(0); exact.limit(exact.capacity()); @@ -311,25 +314,25 @@ public class VariableLengthTest { shortSlice.limit(offset + actualSize - 1); // need at least one byte to decode the size len... var expectedSize = shortSlice.limit() <= offset ? -1 : actualSize; - assertEquals(VariableLengthEncoder.peekEncodedValueSize(shortSlice, offset), expectedSize); + assertEquals(expectedSize, VariableLengthEncoder.peekEncodedValueSize(shortSlice, offset)); var actualLength = VariableLengthEncoder.peekEncodedValue(shortSlice, offset); - assertEquals(actualLength, -1L); - assertEquals(shortSlice.position(), 0); - assertEquals(shortSlice.limit(), offset + actualSize - 1); + assertEquals(-1L, actualLength); + assertEquals(0, shortSlice.position()); + assertEquals(offset + actualSize - 1, shortSlice.limit()); // decode with the exact buffer - assertEquals(VariableLengthEncoder.peekEncodedValueSize(exact, offset), actualSize); + assertEquals(actualSize, VariableLengthEncoder.peekEncodedValueSize(exact, offset)); actualLength = VariableLengthEncoder.peekEncodedValue(exact, offset); - assertEquals(actualLength, length); - assertEquals(exact.position(), 0); - assertEquals(exact.limit(), exact.capacity()); + assertEquals(length, actualLength); + assertEquals(0, exact.position()); + assertEquals(exact.capacity(), exact.limit()); // decode with the longer buffer - assertEquals(VariableLengthEncoder.peekEncodedValueSize(longer, offset), actualSize); + assertEquals(actualSize, VariableLengthEncoder.peekEncodedValueSize(longer, offset)); actualLength = VariableLengthEncoder.peekEncodedValue(longer, offset); - assertEquals(actualLength, length); - assertEquals(longer.position(), 0); - assertEquals(longer.limit(), longer.capacity()); + assertEquals(length, actualLength); + assertEquals(0, longer.position()); + assertEquals(longer.capacity(), longer.limit()); } } diff --git a/test/jdk/java/net/httpclient/quic/VersionNegotiationTest.java b/test/jdk/java/net/httpclient/quic/VersionNegotiationTest.java index 973477a63dc..6b40bf84a8e 100644 --- a/test/jdk/java/net/httpclient/quic/VersionNegotiationTest.java +++ b/test/jdk/java/net/httpclient/quic/VersionNegotiationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,13 +41,15 @@ import jdk.internal.net.http.quic.QuicClient; import jdk.internal.net.quic.QuicTLSContext; import jdk.internal.net.quic.QuicVersion; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /* * @test @@ -57,19 +59,19 @@ import static org.testng.Assert.expectThrows; * jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.quic.ClientConnection * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true VersionNegotiationTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true VersionNegotiationTest */ public class VersionNegotiationTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); private static ExecutorService executor; - @BeforeClass + @BeforeAll public static void beforeClass() throws Exception { executor = Executors.newCachedThreadPool(); } - @AfterClass + @AfterAll public static void afterClass() throws Exception { if (executor != null) executor.shutdown(); } @@ -96,7 +98,7 @@ public class VersionNegotiationTest { try (final QuicServer server = createAndStartServer(serverVersion)) { System.out.println("Attempting to connect " + client.getAvailableVersions() + " client to a " + server.getAvailableVersions() + " server"); - final IOException thrown = expectThrows(IOException.class, + final IOException thrown = Assertions.assertThrows(IOException.class, () -> ClientConnection.establishConnection(client, server.getAddress())); // a version negotiation failure (since it happens during a QUIC connection // handshake) gets thrown as a SSLHandshakeException @@ -105,7 +107,7 @@ public class VersionNegotiationTest { } System.out.println("Received (potentially expected) exception: " + sslhe); // additional check to make sure it was thrown for the right reason - assertEquals(sslhe.getMessage(), "QUIC connection establishment failed"); + assertEquals("QUIC connection establishment failed", sslhe.getMessage()); // underlying cause of SSLHandshakeException should be version negotiation failure final Throwable underlyingCause = sslhe.getCause(); assertNotNull(underlyingCause, "missing cause in SSLHandshakeException"); @@ -124,7 +126,7 @@ public class VersionNegotiationTest { .availableVersions(new QuicVersion[]{version}) .sslContext(sslContext) .build(); - server.addHandler(new ExceptionThrowingHandler()); + server.setHandler(new ExceptionThrowingHandler()); server.start(); System.out.println("Quic server with version " + version + " started at " + server.getAddress()); return server; diff --git a/test/jdk/java/net/httpclient/quic/tls/PacketEncryptionTest.java b/test/jdk/java/net/httpclient/quic/tls/PacketEncryptionTest.java index ed1cbc08de0..d80e473696a 100644 --- a/test/jdk/java/net/httpclient/quic/tls/PacketEncryptionTest.java +++ b/test/jdk/java/net/httpclient/quic/tls/PacketEncryptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +25,6 @@ import jdk.internal.net.quic.QuicKeyUnavailableException; import jdk.internal.net.quic.QuicTLSContext; import jdk.internal.net.quic.QuicTLSEngine; import jdk.internal.net.quic.QuicTransportException; -import org.testng.annotations.Test; import sun.security.ssl.QuicTLSEngineImpl; import sun.security.ssl.QuicTLSEngineImplAccessor; @@ -40,8 +39,11 @@ import java.util.HexFormat; import java.util.function.IntFunction; import static jdk.internal.net.quic.QuicVersion.QUIC_V1; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * @test @@ -50,7 +52,7 @@ import static org.testng.Assert.fail; * java.base/jdk.internal.net.quic * @build java.base/sun.security.ssl.QuicTLSEngineImplAccessor * @summary known-answer test for packet encryption and decryption - * @run testng/othervm PacketEncryptionTest + * @run junit/othervm PacketEncryptionTest */ public class PacketEncryptionTest { @@ -183,7 +185,7 @@ public class PacketEncryptionTest { clientEngine.encryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, clientEngine, 0x0f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_C_PAYLOAD); + assertEquals(ENCRYPTED_C_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -202,26 +204,25 @@ public class PacketEncryptionTest { String expectedContents = INITIAL_C_HEADER + INITIAL_C_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } - @Test(expectedExceptions = AEADBadTagException.class) - public void testDecryptClientInitialPacketBadTag() throws Exception { - QuicTLSEngine serverEngine = getQuicV1Engine(SSLContext.getDefault(), false); - ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); - serverEngine.deriveInitialKeys(QUIC_V1, dcid); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_C_PAYLOAD)); - unprotect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, serverEngine, 0x0f); - ByteBuffer src = packet.asReadOnlyBuffer(); - packet.position(INITIAL_C_PAYLOAD_OFFSET); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - - serverEngine.decryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, -1, - src, INITIAL_C_PAYLOAD_OFFSET, packet); - fail("Decryption should have failed"); + @Test + public void testDecryptClientInitialPacketBadTag() { + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngine serverEngine = getQuicV1Engine(SSLContext.getDefault(), false); + ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); + serverEngine.deriveInitialKeys(QUIC_V1, dcid); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_C_PAYLOAD)); + unprotect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, serverEngine, 0x0f); + ByteBuffer src = packet.asReadOnlyBuffer(); + packet.position(INITIAL_C_PAYLOAD_OFFSET); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + serverEngine.decryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, -1, + src, INITIAL_C_PAYLOAD_OFFSET, packet); + fail("Decryption should have failed"); + }); } @Test @@ -242,7 +243,7 @@ public class PacketEncryptionTest { serverEngine.encryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_S_PN, new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_S_PN_OFFSET, INITIAL_S_PAYLOAD_OFFSET - INITIAL_S_PN_OFFSET, serverEngine, 0x0f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_S_PAYLOAD); + assertEquals(ENCRYPTED_S_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -261,7 +262,7 @@ public class PacketEncryptionTest { String expectedContents = INITIAL_S_HEADER + INITIAL_S_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } @Test @@ -302,7 +303,7 @@ public class PacketEncryptionTest { clientEngine.signRetryPacket(QUIC_V1, dcid, src, packet); - assertEquals(HexFormat.of().formatHex(packet.array()), SIGNED_RETRY); + assertEquals(SIGNED_RETRY, HexFormat.of().formatHex(packet.array())); } @Test @@ -315,17 +316,17 @@ public class PacketEncryptionTest { clientEngine.verifyRetryPacket(QUIC_V1, dcid, packet); } - @Test(expectedExceptions = AEADBadTagException.class) - public void testVerifyBadRetry() throws NoSuchAlgorithmException, AEADBadTagException, QuicTransportException { - QuicTLSEngine clientEngine = getQuicV1Engine(SSLContext.getDefault(), true); - ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(SIGNED_RETRY)); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - clientEngine.verifyRetryPacket(QUIC_V1, dcid, packet); - fail("Verification should have failed"); + @Test + public void testVerifyBadRetry() { + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngine clientEngine = getQuicV1Engine(SSLContext.getDefault(), true); + ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(SIGNED_RETRY)); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + clientEngine.verifyRetryPacket(QUIC_V1, dcid, packet); + fail("Verification should have failed"); + }); } @Test @@ -346,7 +347,7 @@ public class PacketEncryptionTest { clientEngine.encryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN , new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, clientEngine, 0x1f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_ONERTT_PAYLOAD); + assertEquals(ENCRYPTED_ONERTT_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -367,7 +368,7 @@ public class PacketEncryptionTest { String expectedContents = ONERTT_HEADER + ONERTT_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } @Test @@ -397,25 +398,24 @@ public class PacketEncryptionTest { serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, keyPhase, src, ONERTT_PAYLOAD_OFFSET, packet); } - @Test(expectedExceptions = AEADBadTagException.class) - public void testDecryptChaChaBadTag() throws Exception { - QuicTLSEngineImpl serverEngine = (QuicTLSEngineImpl) getQuicV1Engine(SSLContext.getDefault(), false); - // mark the TLS handshake as FINISHED - QuicTLSEngineImplAccessor.completeHandshake(serverEngine); - SecretKey key = new SecretKeySpec(HexFormat.of().parseHex(ONERTT_SECRET), 0, 32, "ChaCha20-Poly1305"); - QuicTLSEngineImplAccessor.testDeriveOneRTTKeys(QUIC_V1, serverEngine, key, key, "TLS_CHACHA20_POLY1305_SHA256", false); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_ONERTT_PAYLOAD)); - unprotect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, serverEngine, 0x1f); - ByteBuffer src = packet.asReadOnlyBuffer(); - packet.position(ONERTT_PAYLOAD_OFFSET); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - - serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, (byte) 0, - src, ONERTT_PAYLOAD_OFFSET, packet); - fail("Decryption should have failed"); + @Test + public void testDecryptChaChaBadTag() { + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngineImpl serverEngine = (QuicTLSEngineImpl) getQuicV1Engine(SSLContext.getDefault(), false); + // mark the TLS handshake as FINISHED + QuicTLSEngineImplAccessor.completeHandshake(serverEngine); + SecretKey key = new SecretKeySpec(HexFormat.of().parseHex(ONERTT_SECRET), 0, 32, "ChaCha20-Poly1305"); + QuicTLSEngineImplAccessor.testDeriveOneRTTKeys(QUIC_V1, serverEngine, key, key, "TLS_CHACHA20_POLY1305_SHA256", false); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_ONERTT_PAYLOAD)); + unprotect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, serverEngine, 0x1f); + ByteBuffer src = packet.asReadOnlyBuffer(); + packet.position(ONERTT_PAYLOAD_OFFSET); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, (byte) 0, + src, ONERTT_PAYLOAD_OFFSET, packet); + fail("Decryption should have failed"); + }); } diff --git a/test/jdk/java/net/httpclient/quic/tls/Quicv2PacketEncryptionTest.java b/test/jdk/java/net/httpclient/quic/tls/Quicv2PacketEncryptionTest.java index a506495ed5e..285fa2e4cd4 100644 --- a/test/jdk/java/net/httpclient/quic/tls/Quicv2PacketEncryptionTest.java +++ b/test/jdk/java/net/httpclient/quic/tls/Quicv2PacketEncryptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +25,6 @@ import jdk.internal.net.quic.QuicKeyUnavailableException; import jdk.internal.net.quic.QuicTLSContext; import jdk.internal.net.quic.QuicTLSEngine; import jdk.internal.net.quic.QuicTransportException; -import org.testng.annotations.Test; import sun.security.ssl.QuicTLSEngineImpl; import sun.security.ssl.QuicTLSEngineImplAccessor; @@ -40,8 +39,11 @@ import java.util.HexFormat; import java.util.function.IntFunction; import static jdk.internal.net.quic.QuicVersion.QUIC_V2; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * @test @@ -50,7 +52,7 @@ import static org.testng.Assert.fail; * java.base/jdk.internal.net.quic * @build java.base/sun.security.ssl.QuicTLSEngineImplAccessor * @summary known-answer test for packet encryption and decryption with Quic v2 - * @run testng/othervm Quicv2PacketEncryptionTest + * @run junit/othervm Quicv2PacketEncryptionTest */ public class Quicv2PacketEncryptionTest { @@ -182,7 +184,7 @@ public class Quicv2PacketEncryptionTest { clientEngine.encryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, clientEngine, 0x0f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_C_PAYLOAD); + assertEquals(ENCRYPTED_C_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -200,25 +202,24 @@ public class Quicv2PacketEncryptionTest { String expectedContents = INITIAL_C_HEADER + INITIAL_C_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } - @Test(expectedExceptions = AEADBadTagException.class) + @Test public void testDecryptClientInitialPacketBadTag() throws Exception { - QuicTLSEngine serverEngine = getQuicV2Engine(SSLContext.getDefault(), false); - ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); - serverEngine.deriveInitialKeys(QUIC_V2, dcid); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_C_PAYLOAD)); - unprotect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, serverEngine, 0x0f); - ByteBuffer src = packet.asReadOnlyBuffer(); - packet.position(INITIAL_C_PAYLOAD_OFFSET); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - - serverEngine.decryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, -1, src, INITIAL_C_PAYLOAD_OFFSET, packet); - fail("Decryption should have failed"); + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngine serverEngine = getQuicV2Engine(SSLContext.getDefault(), false); + ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); + serverEngine.deriveInitialKeys(QUIC_V2, dcid); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_C_PAYLOAD)); + unprotect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_C_PN_OFFSET, INITIAL_C_PAYLOAD_OFFSET - INITIAL_C_PN_OFFSET, serverEngine, 0x0f); + ByteBuffer src = packet.asReadOnlyBuffer(); + packet.position(INITIAL_C_PAYLOAD_OFFSET); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + serverEngine.decryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_C_PN, -1, src, INITIAL_C_PAYLOAD_OFFSET, packet); + fail("Decryption should have failed"); + }); } @Test @@ -239,7 +240,7 @@ public class Quicv2PacketEncryptionTest { serverEngine.encryptPacket(QuicTLSEngine.KeySpace.INITIAL, INITIAL_S_PN, new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.INITIAL, packet, INITIAL_S_PN_OFFSET, INITIAL_S_PAYLOAD_OFFSET - INITIAL_S_PN_OFFSET, serverEngine, 0x0f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_S_PAYLOAD); + assertEquals(ENCRYPTED_S_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -257,7 +258,7 @@ public class Quicv2PacketEncryptionTest { String expectedContents = INITIAL_S_HEADER + INITIAL_S_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } @Test @@ -298,7 +299,7 @@ public class Quicv2PacketEncryptionTest { clientEngine.signRetryPacket(QUIC_V2, dcid, src, packet); - assertEquals(HexFormat.of().formatHex(packet.array()), SIGNED_RETRY); + assertEquals(SIGNED_RETRY, HexFormat.of().formatHex(packet.array())); } @Test @@ -311,17 +312,17 @@ public class Quicv2PacketEncryptionTest { clientEngine.verifyRetryPacket(QUIC_V2, dcid, packet); } - @Test(expectedExceptions = AEADBadTagException.class) + @Test public void testVerifyBadRetry() throws NoSuchAlgorithmException, AEADBadTagException, QuicTransportException { - QuicTLSEngine clientEngine = getQuicV2Engine(SSLContext.getDefault(), true); - ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(SIGNED_RETRY)); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - clientEngine.verifyRetryPacket(QUIC_V2, dcid, packet); - fail("Verification should have failed"); + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngine clientEngine = getQuicV2Engine(SSLContext.getDefault(), true); + ByteBuffer dcid = ByteBuffer.wrap(HexFormat.of().parseHex(INITIAL_DCID)); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(SIGNED_RETRY)); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + clientEngine.verifyRetryPacket(QUIC_V2, dcid, packet); + fail("Verification should have failed"); + }); } @Test @@ -342,7 +343,7 @@ public class Quicv2PacketEncryptionTest { clientEngine.encryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN , new FixedHeaderContent(header), payload, packet); protect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, clientEngine, 0x1f); - assertEquals(HexFormat.of().formatHex(packet.array()), ENCRYPTED_ONERTT_PAYLOAD); + assertEquals(ENCRYPTED_ONERTT_PAYLOAD, HexFormat.of().formatHex(packet.array())); } @Test @@ -362,7 +363,7 @@ public class Quicv2PacketEncryptionTest { String expectedContents = ONERTT_HEADER + ONERTT_PAYLOAD; - assertEquals(HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length()), expectedContents); + assertEquals(expectedContents, HexFormat.of().formatHex(packet.array()).substring(0, expectedContents.length())); } @Test @@ -392,24 +393,23 @@ public class Quicv2PacketEncryptionTest { serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, keyphase, src, ONERTT_PAYLOAD_OFFSET, packet); } - @Test(expectedExceptions = AEADBadTagException.class) + @Test public void testDecryptChaChaBadTag() throws Exception { - QuicTLSEngineImpl serverEngine = (QuicTLSEngineImpl) getQuicV2Engine(SSLContext.getDefault(), false); - // mark the TLS handshake as FINISHED - QuicTLSEngineImplAccessor.completeHandshake(serverEngine); - SecretKey key = new SecretKeySpec(HexFormat.of().parseHex(ONERTT_SECRET), 0, 32, "ChaCha20-Poly1305"); - QuicTLSEngineImplAccessor.testDeriveOneRTTKeys(QUIC_V2, serverEngine, key, key, "TLS_CHACHA20_POLY1305_SHA256", false); - - ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_ONERTT_PAYLOAD)); - unprotect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, serverEngine, 0x1f); - ByteBuffer src = packet.asReadOnlyBuffer(); - packet.position(ONERTT_PAYLOAD_OFFSET); - - // change one byte of AEAD tag - packet.put(packet.limit() - 1, (byte)0); - - serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, 0, src, ONERTT_PAYLOAD_OFFSET, packet); - fail("Decryption should have failed"); + Assertions.assertThrows(AEADBadTagException.class, () -> { + QuicTLSEngineImpl serverEngine = (QuicTLSEngineImpl) getQuicV2Engine(SSLContext.getDefault(), false); + // mark the TLS handshake as FINISHED + QuicTLSEngineImplAccessor.completeHandshake(serverEngine); + SecretKey key = new SecretKeySpec(HexFormat.of().parseHex(ONERTT_SECRET), 0, 32, "ChaCha20-Poly1305"); + QuicTLSEngineImplAccessor.testDeriveOneRTTKeys(QUIC_V2, serverEngine, key, key, "TLS_CHACHA20_POLY1305_SHA256", false); + ByteBuffer packet = ByteBuffer.wrap(HexFormat.of().parseHex(ENCRYPTED_ONERTT_PAYLOAD)); + unprotect(QuicTLSEngine.KeySpace.ONE_RTT, packet, ONERTT_PN_OFFSET, ONERTT_PAYLOAD_OFFSET - ONERTT_PN_OFFSET, serverEngine, 0x1f); + ByteBuffer src = packet.asReadOnlyBuffer(); + packet.position(ONERTT_PAYLOAD_OFFSET); + // change one byte of AEAD tag + packet.put(packet.limit() - 1, (byte)0); + serverEngine.decryptPacket(QuicTLSEngine.KeySpace.ONE_RTT, ONERTT_PN, 0, src, ONERTT_PAYLOAD_OFFSET, packet); + fail("Decryption should have failed"); + }); } diff --git a/test/jdk/java/net/httpclient/security/filePerms/FileProcessorPermissionTest.java b/test/jdk/java/net/httpclient/security/filePerms/FileProcessorPermissionTest.java index c8920771727..361b053fe43 100644 --- a/test/jdk/java/net/httpclient/security/filePerms/FileProcessorPermissionTest.java +++ b/test/jdk/java/net/httpclient/security/filePerms/FileProcessorPermissionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @summary Basic checks for File Processors - * @run testng/othervm FileProcessorPermissionTest + * @run junit/othervm FileProcessorPermissionTest */ import java.nio.file.Path; @@ -32,9 +32,9 @@ import java.nio.file.Paths; import java.util.List; import java.net.http.HttpRequest; import java.net.http.HttpResponse.BodyHandlers; -import org.testng.annotations.Test; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Test; public class FileProcessorPermissionTest { diff --git a/test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java b/test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java index d54e27b89ce..c8d7bb64b36 100644 --- a/test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java +++ b/test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @summary Verifies security checks are performed before existence checks * in pre-defined body processors APIs - * @run testng/othervm SecurityBeforeFile + * @run junit/othervm SecurityBeforeFile */ import java.io.FileNotFoundException; @@ -35,11 +35,13 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse.BodyHandlers; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.fail; public class SecurityBeforeFile { @@ -57,8 +59,7 @@ public class SecurityBeforeFile { } } - @DataProvider(name = "handlerOpenOptions") - public Object[][] handlerOpenOptions() { + public static Object[][] handlerOpenOptions() { return new Object[][] { { new OpenOption[] { } }, { new OpenOption[] { CREATE } }, @@ -66,7 +67,8 @@ public class SecurityBeforeFile { }; } - @Test(dataProvider = "handlerOpenOptions") + @ParameterizedTest + @MethodSource("handlerOpenOptions") public void BodyHandlersOfFileDownload(OpenOption[] openOptions) { Path p = Paths.get("doesNotExistDir"); if (Files.exists(p)) diff --git a/test/jdk/java/net/httpclient/websocket/Abort.java b/test/jdk/java/net/httpclient/websocket/Abort.java index 99c94de83f0..a6088f8cce2 100644 --- a/test/jdk/java/net/httpclient/websocket/Abort.java +++ b/test/jdk/java/net/httpclient/websocket/Abort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,11 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * Abort */ -import org.testng.annotations.Test; import java.io.IOException; import java.net.ProtocolException; @@ -44,10 +43,12 @@ import java.util.concurrent.TimeoutException; import static java.net.http.HttpClient.newHttpClient; import static java.net.http.WebSocket.NORMAL_CLOSURE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; public class Abort { @@ -79,7 +80,7 @@ public class Abort { TimeUnit.SECONDS.sleep(5); List inv = listener.invocationsSoFar(); // no more invocations after onOpen as WebSocket was aborted - assertEquals(inv, List.of(MockListener.Invocation.onOpen(webSocket))); + assertEquals(List.of(MockListener.Invocation.onOpen(webSocket)), inv); } finally { webSocket.abort(); } @@ -119,7 +120,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onText(webSocket, "", true)); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -159,7 +160,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onBinary(webSocket, ByteBuffer.allocate(0), true)); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -198,7 +199,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onPing(webSocket, ByteBuffer.allocate(0))); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -237,7 +238,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onPong(webSocket, ByteBuffer.allocate(0))); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -277,7 +278,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onClose(webSocket, 1005, "")); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -318,7 +319,7 @@ public class Abort { MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onError(webSocket, ProtocolException.class)); System.out.println("actual invocations:" + Arrays.toString(inv.toArray())); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -396,7 +397,7 @@ public class Abort { ws.abort(); assertTrue(ws.isInputClosed()); assertTrue(ws.isOutputClosed()); - assertEquals(ws.getSubprotocol(), ""); + assertEquals("", ws.getSubprotocol()); } // at this point valid requests MUST be a no-op: for (int j = 0; j < 3; j++) { diff --git a/test/jdk/java/net/httpclient/websocket/AutomaticPong.java b/test/jdk/java/net/httpclient/websocket/AutomaticPong.java index 1999781b82f..b438cb8e728 100644 --- a/test/jdk/java/net/httpclient/websocket/AutomaticPong.java +++ b/test/jdk/java/net/httpclient/websocket/AutomaticPong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,11 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * AutomaticPong */ import jdk.internal.net.http.websocket.Frame; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.http.WebSocket; @@ -39,10 +37,14 @@ import java.nio.charset.StandardCharsets; import java.util.List; import static java.net.http.HttpClient.newHttpClient; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class AutomaticPong { /* @@ -86,7 +88,7 @@ public class AutomaticPong { MockListener.Invocation.onPing(webSocket, hello), MockListener.Invocation.onClose(webSocket, 1005, "") ); - assertEquals(actual, expected); + assertEquals(expected, actual); } finally { webSocket.abort(); } @@ -104,7 +106,8 @@ public class AutomaticPong { * b) the last Pong corresponds to the last Ping * c) there are no unrelated Pongs */ - @Test(dataProvider = "nPings") + @ParameterizedTest + @MethodSource("nPings") public void automaticPongs(int nPings) throws Exception { // big enough to not bother with resize ByteBuffer buffer = ByteBuffer.allocate(65536); @@ -133,7 +136,7 @@ public class AutomaticPong { .join(); try { List inv = listener.invocations(); - assertEquals(inv.size(), nPings + 2); // n * onPing + onOpen + onClose + assertEquals(nPings + 2, inv.size()); // n * onPing + onOpen + onClose ByteBuffer data = server.read(); Frame.Reader reader = new Frame.Reader(); @@ -171,7 +174,7 @@ public class AutomaticPong { closed = true; return; } - assertEquals(value, Frame.Opcode.PONG); + assertEquals(Frame.Opcode.PONG, value); } @Override @@ -182,7 +185,7 @@ public class AutomaticPong { @Override public void payloadLen(long value) { if (!closed) - assertEquals(value, 4); + assertEquals(4, value); } @Override @@ -222,8 +225,7 @@ public class AutomaticPong { } - @DataProvider(name = "nPings") - public Object[][] nPings() { + public static Object[][] nPings() { return new Object[][]{{1}, {2}, {4}, {8}, {9}, {256}}; } } diff --git a/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java b/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java index 7bf2564a04f..1865ca05e4f 100644 --- a/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java +++ b/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,12 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * BlowupOutputQueue */ -import org.testng.annotations.Test; - import java.io.IOException; import java.net.http.WebSocket; import java.nio.ByteBuffer; @@ -43,7 +41,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.testng.Assert.assertFalse; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; public class BlowupOutputQueue extends PendingOperations { diff --git a/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java index 25a6893ff13..6854cacbcc2 100644 --- a/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java +++ b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +29,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestServerConfigurator * @modules java.net.http/jdk.internal.net.http.common * jdk.httpserver - * @run testng/othervm -Djdk.internal.httpclient.debug=true HandshakeUrlEncodingTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true HandshakeUrlEncodingTest */ import com.sun.net.httpserver.HttpHandler; @@ -39,10 +39,6 @@ import com.sun.net.httpserver.HttpExchange; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -58,20 +54,25 @@ import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + + public class HandshakeUrlEncodingTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; - HttpsServer httpsTestServer; - String httpURI; - String httpsURI; + private static HttpServer httpTestServer; + private static HttpsServer httpsTestServer; + private static String httpURI; + private static String httpsURI; static String queryPart; @@ -79,8 +80,7 @@ public class HandshakeUrlEncodingTest { // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newCachedThreadPool(); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI, false }, { httpsURI, false }, @@ -97,7 +97,8 @@ public class HandshakeUrlEncodingTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) { HttpClient client = null; out.println("The url is " + uri); @@ -119,22 +120,21 @@ public class HandshakeUrlEncodingTest { final WebSocketHandshakeException wse = (WebSocketHandshakeException) t; assertNotNull(wse.getResponse()); assertNotNull(wse.getResponse().uri()); - assertNotNull(wse.getResponse().statusCode()); final String rawQuery = wse.getResponse().uri().getRawQuery(); final String expectedRawQuery = "&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; - assertEquals(rawQuery, expectedRawQuery); + assertEquals(expectedRawQuery, rawQuery); final String body = (String) wse.getResponse().body(); final String expectedBody = "/?" + expectedRawQuery; - assertEquals(body, expectedBody); + assertEquals(expectedBody, body); out.println("Status code is " + wse.getResponse().statusCode()); out.println("Response is " + wse.getResponse()); - assertEquals(wse.getResponse().statusCode(), 400); + assertEquals(400, wse.getResponse().statusCode()); } } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); queryPart = "?&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; httpTestServer = HttpServer.create(sa, 10); @@ -164,8 +164,8 @@ public class HandshakeUrlEncodingTest { httpsTestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { httpTestServer.stop(0); httpsTestServer.stop(0); executor.shutdownNow(); diff --git a/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java b/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java index 6293b1b6c71..75ae5423f00 100644 --- a/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java +++ b/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.HeaderWriterTest */ diff --git a/test/jdk/java/net/httpclient/websocket/MaskerDriver.java b/test/jdk/java/net/httpclient/websocket/MaskerDriver.java index b84ea1fff5c..e81417c25ef 100644 --- a/test/jdk/java/net/httpclient/websocket/MaskerDriver.java +++ b/test/jdk/java/net/httpclient/websocket/MaskerDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.MaskerTest */ diff --git a/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java b/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java index 9831bb59297..68a23d0be88 100644 --- a/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java +++ b/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.MessageQueueTest */ diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java index 5a410251593..4a5ae315e91 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,28 +24,30 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPingClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingBinaryPingClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingBinaryPingClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java index bef3d258850..a8330faeb3f 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,28 +24,30 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPongClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingBinaryPongClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingBinaryPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingOperations.java b/test/jdk/java/net/httpclient/websocket/PendingOperations.java index b4d7d7e2222..32350a1ab41 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingOperations.java +++ b/test/jdk/java/net/httpclient/websocket/PendingOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,9 +21,6 @@ * questions. */ -import org.testng.annotations.AfterMethod; -import org.testng.annotations.DataProvider; - import java.io.IOException; import java.net.http.HttpClient; import java.net.http.WebSocket; @@ -35,6 +32,8 @@ import java.util.function.BooleanSupplier; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; +import org.junit.jupiter.api.AfterEach; + /* Common infrastructure for tests that check pending operations */ public class PendingOperations { @@ -54,7 +53,7 @@ public class PendingOperations { return newBuilder().proxy(NO_PROXY).build(); } - @AfterMethod + @AfterEach public void cleanup() { // make sure we have a trace both on System.out and System.err // to help with diagnosis. @@ -85,8 +84,7 @@ public class PendingOperations { Support.assertNotDone(future); } - @DataProvider(name = "booleans") - public Object[][] booleans() { + public static Object[][] booleans() { return new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}}; } diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java index c1c314395e8..e07ebe0d03a 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPingBinaryClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPingBinaryClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPingBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java index 82666fafe67..eae01f804a4 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPingTextClose */ @@ -33,14 +33,15 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPingTextClose extends PendingOperations { static boolean debug = false; // avoid too verbose output @@ -48,7 +49,8 @@ public class PendingPingTextClose extends PendingOperations { CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPingTextClose(boolean last) throws Exception { try { repeatable(() -> { diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java index 0aa2f24c660..32640853b00 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPongBinaryClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPongBinaryClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPongBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java index f919a6706ad..f4d6c84c2f5 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPongTextClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPongTextClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPongTextClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java b/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java index 39c8bbdc444..76f12430804 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,13 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.sendBufferSize=8192 * PendingTextPingClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -40,13 +38,17 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingTextPingClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingTextPingClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java index 8fa90400760..a2a41a73d7b 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,13 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.sendBufferSize=8192 * PendingTextPongClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -40,13 +38,17 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingTextPongClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingTextPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/ReaderDriver.java b/test/jdk/java/net/httpclient/websocket/ReaderDriver.java index 0b874792b4f..3e195be046d 100644 --- a/test/jdk/java/net/httpclient/websocket/ReaderDriver.java +++ b/test/jdk/java/net/httpclient/websocket/ReaderDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,6 +25,8 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm/timeout=240 --add-reads java.net.http=ALL-UNNAMED java.net.http/jdk.internal.net.http.websocket.ReaderTest + * @run junit/othervm/timeout=240 + * --add-reads java.net.http=ALL-UNNAMED + * java.net.http/jdk.internal.net.http.websocket.ReaderTest */ public final class ReaderDriver { } diff --git a/test/jdk/java/net/httpclient/websocket/SecureSupport.java b/test/jdk/java/net/httpclient/websocket/SecureSupport.java index 8b565768c29..41709d2fedb 100644 --- a/test/jdk/java/net/httpclient/websocket/SecureSupport.java +++ b/test/jdk/java/net/httpclient/websocket/SecureSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,18 +22,9 @@ */ import java.io.IOException; -import java.net.Socket; import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import static org.testng.Assert.assertThrows; /** * Helper class to create instances of DummySecureWebSocketServer which diff --git a/test/jdk/java/net/httpclient/websocket/SendTest.java b/test/jdk/java/net/httpclient/websocket/SendTest.java index 39021131156..b3a433b5c29 100644 --- a/test/jdk/java/net/httpclient/websocket/SendTest.java +++ b/test/jdk/java/net/httpclient/websocket/SendTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,22 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * SendTest */ -import org.testng.annotations.Test; - import java.io.IOException; import java.net.http.WebSocket; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; import static java.net.http.WebSocket.NORMAL_CLOSURE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SendTest { @@ -90,7 +90,7 @@ public class SendTest { try { webSocket.sendClose(NORMAL_CLOSURE, "").join(); assertTrue(webSocket.isOutputClosed()); - assertEquals(webSocket.getSubprotocol(), ""); + assertEquals("", webSocket.getSubprotocol()); webSocket.request(1); // No exceptions must be thrown } finally { webSocket.abort(); diff --git a/test/jdk/java/net/httpclient/websocket/Support.java b/test/jdk/java/net/httpclient/websocket/Support.java index 1323ae35105..73f840ff7eb 100644 --- a/test/jdk/java/net/httpclient/websocket/Support.java +++ b/test/jdk/java/net/httpclient/websocket/Support.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +32,8 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertFalse; public class Support { diff --git a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java index 90db79dc8ef..f28d84b2f20 100644 --- a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java +++ b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +29,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestServerConfigurator * @modules java.net.http/jdk.internal.net.http.common * jdk.httpserver - * @run testng/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest */ import com.sun.net.httpserver.HttpHandler; @@ -37,8 +37,6 @@ import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsServer; import com.sun.net.httpserver.HttpExchange; - - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -49,10 +47,6 @@ import java.net.http.WebSocketHandshakeException; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.net.InetSocketAddress; import java.net.URI; @@ -62,29 +56,33 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class WSHandshakeExceptionTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - String httpURI; - String httpsURI; - String httpNonUtf8URI; - String httpsNonUtf8URI; - HttpClient sharedClient; + private static HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static String httpURI; + private static String httpsURI; + private static String httpNonUtf8URI; + private static String httpsNonUtf8URI; + private static HttpClient sharedClient; static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newCachedThreadPool(); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI, false }, { httpsURI, false }, @@ -106,7 +104,8 @@ public class WSHandshakeExceptionTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) { HttpClient client = sharedClient; boolean pause; @@ -132,7 +131,7 @@ public class WSHandshakeExceptionTest { WebSocketHandshakeException wse = (WebSocketHandshakeException) t; assertNotNull(wse.getResponse()); assertNotNull(wse.getResponse().body()); - assertEquals(wse.getResponse().body().getClass(), String.class); + assertEquals(String.class, wse.getResponse().body().getClass()); String body = (String)wse.getResponse().body(); out.println("Status code is " + wse.getResponse().statusCode()); out.println("Response is " + body); @@ -145,7 +144,7 @@ public class WSHandshakeExceptionTest { // default HttpServer 404 body expected assertTrue(body.contains("404")); } - assertEquals(wse.getResponse().statusCode(), 404); + assertEquals(404, wse.getResponse().statusCode()); } } } @@ -159,8 +158,8 @@ public class WSHandshakeExceptionTest { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); httpTestServer = HttpServer.create(sa, 0); @@ -178,8 +177,8 @@ public class WSHandshakeExceptionTest { httpsTestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { sharedClient = null; gc(100); httpTestServer.stop(0); diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java index b28b8f59875..beef8cb42a4 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,12 +26,9 @@ * @bug 8159053 * @build DummyWebSocketServer * Support - * @run testng/othervm WebSocketBuilderTest + * @run junit/othervm WebSocketBuilderTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.net.URI; import java.net.http.HttpClient; import java.net.http.WebSocket; @@ -42,7 +39,10 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * In some places in this test a new String is created out of a string literal. @@ -98,7 +98,8 @@ public final class WebSocketBuilderTest { .connectTimeout(null)); } - @Test(dataProvider = "badURIs") + @ParameterizedTest + @MethodSource("badURIs") void illegalURI(URI uri) { WebSocket.Builder b = HttpClient.newHttpClient().newWebSocketBuilder(); assertFails(IllegalArgumentException.class, @@ -129,7 +130,8 @@ public final class WebSocketBuilderTest { // TODO: test for bad syntax headers // TODO: test for overwrites (subprotocols) and additions (headers) - @Test(dataProvider = "badSubprotocols") + @ParameterizedTest + @MethodSource("badSubprotocols") public void illegalSubprotocolsSyntax(String s) { WebSocket.Builder b = HttpClient.newHttpClient() .newWebSocketBuilder() @@ -138,7 +140,8 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @Test(dataProvider = "duplicatingSubprotocols") + @ParameterizedTest + @MethodSource("duplicatingSubprotocols") public void illegalSubprotocolsDuplicates(String mostPreferred, String[] lesserPreferred) { WebSocket.Builder b = HttpClient.newHttpClient() @@ -148,7 +151,8 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @Test(dataProvider = "badConnectTimeouts") + @ParameterizedTest + @MethodSource("badConnectTimeouts") public void illegalConnectTimeout(Duration d) { WebSocket.Builder b = HttpClient.newHttpClient() .newWebSocketBuilder() @@ -157,8 +161,7 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @DataProvider - public Object[][] badURIs() { + public static Object[][] badURIs() { return new Object[][]{ {URI.create("http://example.com")}, {URI.create("ftp://example.com")}, @@ -167,8 +170,7 @@ public final class WebSocketBuilderTest { }; } - @DataProvider - public Object[][] badConnectTimeouts() { + public static Object[][] badConnectTimeouts() { return new Object[][]{ {Duration.ofDays(0)}, {Duration.ofDays(-1)}, @@ -188,7 +190,6 @@ public final class WebSocketBuilderTest { // https://tools.ietf.org/html/rfc7230#section-3.2.6 // https://tools.ietf.org/html/rfc20 - @DataProvider public static Object[][] badSubprotocols() { return new Object[][]{ {""}, @@ -215,7 +216,6 @@ public final class WebSocketBuilderTest { }; } - @DataProvider public static Object[][] duplicatingSubprotocols() { return new Object[][]{ {"a.b.c", new String[]{"a.b.c"}}, diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java index 0099104e872..56474555235 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8159053 - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.websocket.writeBufferSize=1024 @@ -32,8 +32,6 @@ */ import jdk.internal.net.http.websocket.Frame; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.http.WebSocket; @@ -43,8 +41,11 @@ import java.util.List; import java.util.Random; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /* @@ -52,7 +53,7 @@ import static org.testng.Assert.assertTrue; * possible fragmentation. */ public class WebSocketExtendedTest { -// * run testng/othervm +// * run junit/othervm // * -Djdk.httpclient.websocket.writeBufferSize=16 // * -Djdk.httpclient.sendBufferSize=32 WebSocketTextTest @@ -65,7 +66,8 @@ public class WebSocketExtendedTest { // FIXME ensure subsequent (sendText/Binary, false) only CONTINUATIONs - @Test(dataProvider = "binary") + @ParameterizedTest + @MethodSource("binary") public void binary(ByteBuffer expected) throws IOException, InterruptedException { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -76,15 +78,16 @@ public class WebSocketExtendedTest { ws.sendBinary(expected.duplicate(), true).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); assertTrue(f.last()); - assertEquals(f.opcode(), Frame.Opcode.BINARY); - assertEquals(f.data(), expected); + assertEquals(Frame.Opcode.BINARY, f.opcode()); + assertEquals(expected, f.data()); } } - @Test(dataProvider = "pingPong") + @ParameterizedTest + @MethodSource("pingPongSizes") public void ping(ByteBuffer expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -95,17 +98,18 @@ public class WebSocketExtendedTest { ws.sendPing(expected.duplicate()).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.PING); + assertEquals(Frame.Opcode.PING, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(expected.remaining()); actual.put(f.data()); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); } } - @Test(dataProvider = "pingPong") + @ParameterizedTest + @MethodSource("pingPongSizes") public void pong(ByteBuffer expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -116,17 +120,18 @@ public class WebSocketExtendedTest { ws.sendPong(expected.duplicate()).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.PONG); + assertEquals(Frame.Opcode.PONG, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(expected.remaining()); actual.put(f.data()); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); } } - @Test(dataProvider = "close") + @ParameterizedTest + @MethodSource("closeArguments") public void close(int statusCode, String reason) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -137,18 +142,19 @@ public class WebSocketExtendedTest { ws.sendClose(statusCode, reason).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.CLOSE); + assertEquals(Frame.Opcode.CLOSE, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(Frame.MAX_CONTROL_FRAME_PAYLOAD_LENGTH); actual.put(f.data()); actual.flip(); - assertEquals(actual.getChar(), statusCode); - assertEquals(StandardCharsets.UTF_8.decode(actual).toString(), reason); + assertEquals(statusCode, actual.getChar()); + assertEquals(reason, StandardCharsets.UTF_8.decode(actual).toString()); } } - @Test(dataProvider = "text") + @ParameterizedTest + @MethodSource("texts") public void text(String expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -163,12 +169,11 @@ public class WebSocketExtendedTest { ByteBuffer actual = ByteBuffer.allocate(maxBytes); frames.stream().forEachOrdered(f -> actual.put(f.data())); actual.flip(); - assertEquals(StandardCharsets.UTF_8.decode(actual).toString(), expected); + assertEquals(expected, StandardCharsets.UTF_8.decode(actual).toString()); } } - @DataProvider(name = "pingPong") - public Object[][] pingPongSizes() { + public static Object[][] pingPongSizes() { return new Object[][]{ {bytes( 0)}, {bytes( 1)}, @@ -177,8 +182,7 @@ public class WebSocketExtendedTest { }; } - @DataProvider(name = "close") - public Object[][] closeArguments() { + public static Object[][] closeArguments() { return new Object[][]{ {WebSocket.NORMAL_CLOSURE, utf8String( 0)}, {WebSocket.NORMAL_CLOSURE, utf8String( 1)}, @@ -216,16 +220,14 @@ public class WebSocketExtendedTest { return str.toString(); } - @DataProvider(name = "text") - public Object[][] texts() { + public static Object[][] texts() { return new Object[][]{ {utf8String( 0)}, {utf8String(1024)}, }; } - @DataProvider(name = "binary") - public Object[][] binary() { + public static Object[][] binary() { return new Object[][]{ {bytes( 0)}, {bytes(1024)}, diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java index 46758b2fe6e..a410aa9fe75 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +28,7 @@ * @library /test/lib * @compile SecureSupport.java DummySecureWebSocketServer.java ../ProxyServer.java * @build jdk.test.lib.net.SimpleSSLContext WebSocketProxyTest - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,headers @@ -61,16 +61,18 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import static java.net.http.HttpClient.newBuilder; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.FileAssert.fail; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class WebSocketProxyTest { @@ -132,8 +134,7 @@ public class WebSocketProxyTest { @Override public String toString() { return "AUTH_TUNNELING_PROXY_SERVER"; } }; - @DataProvider(name = "servers") - public Object[][] servers() { + public static Object[][] servers() { return new Object[][] { { SERVER_WITH_CANNED_DATA, TUNNELING_PROXY_SERVER }, { SERVER_WITH_CANNED_DATA, AUTH_TUNNELING_PROXY_SERVER }, @@ -175,7 +176,8 @@ public class WebSocketProxyTest { return "%s and %s %s".formatted(actual, expected, message); } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingBinaryMessages (Function serverSupplier, Supplier proxyServerSupplier) @@ -263,7 +265,7 @@ public class WebSocketProxyTest { .join(); List a = actual.join(); - assertEquals(ofBytes(a), ofBytes(expected), diagnose(a, expected)); + assertEquals(ofBytes(expected), ofBytes(a), diagnose(a, expected)); } } @@ -359,7 +361,7 @@ public class WebSocketProxyTest { } catch (CompletionException expected) { WebSocketHandshakeException e = (WebSocketHandshakeException)expected.getCause(); HttpResponse response = e.getResponse(); - assertEquals(response.statusCode(), 407); + assertEquals(407, response.statusCode()); } } } @@ -398,7 +400,7 @@ public class WebSocketProxyTest { } } - @BeforeMethod + @BeforeEach public void breakBetweenTests() { System.gc(); try {Thread.sleep(100); } catch (InterruptedException x) { /* OK */ } diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java index 43bcb054b7d..2b1df3d7e87 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,10 @@ * @library ../access * @build DummyWebSocketServer * java.net.http/jdk.internal.net.http.HttpClientTimerAccess - * @run testng/othervm + * @run junit/othervm * WebSocketTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.Authenticator; @@ -63,9 +61,13 @@ import static java.net.http.HttpClient.newBuilder; import static java.net.http.WebSocket.NORMAL_CLOSURE; import static java.nio.charset.StandardCharsets.UTF_8; import static jdk.internal.net.http.HttpClientTimerAccess.assertNoResponseTimerEventRegistrations; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class WebSocketTest { @@ -264,8 +266,7 @@ public class WebSocketTest { } } - @DataProvider(name = "sequence") - public Object[][] data1() { + public static Object[][] data1() { int[] CLOSE = { 0x81, 0x00, // "" 0x82, 0x00, // [] @@ -292,7 +293,8 @@ public class WebSocketTest { }; } - @Test(dataProvider = "sequence") + @ParameterizedTest + @MethodSource("data1") public void listenerSequentialOrder(int[] binary, long requestSize) throws IOException { @@ -470,8 +472,7 @@ public class WebSocketTest { @Override public String toString() { return "AUTH_SERVER_WITH_CANNED_DATA"; } }; - @DataProvider(name = "servers") - public Object[][] servers() { + public static Object[][] servers() { return new Object[][] { { SERVER_WITH_CANNED_DATA }, { AUTH_SERVER_WITH_CANNED_DATA }, @@ -507,7 +508,8 @@ public class WebSocketTest { return "%s and %s %s".formatted(actual, expected, message); } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingBinaryMessages (Function serverSupplier) throws IOException @@ -600,14 +602,15 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(ofBytes(a), ofBytes(expected), diagnose(a, expected)); + assertEquals(ofBytes(expected), ofBytes(a), diagnose(a, expected)); } finally { webSocket.abort(); } } } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingTextMessages (Function serverSupplier) throws IOException @@ -683,7 +686,7 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(a, expected); + assertEquals(expected, a); } finally { webSocket.abort(); } @@ -694,7 +697,8 @@ public class WebSocketTest { * Exercises the scenario where requests for more messages are made prior to * completing the returned CompletionStage instances. */ - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void aggregatingTextMessages (Function serverSupplier) throws IOException @@ -784,7 +788,7 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(a, expected); + assertEquals(expected, a); } finally { webSocket.abort(); } @@ -853,7 +857,7 @@ public class WebSocketTest { } catch (CompletionException expected) { WebSocketHandshakeException e = (WebSocketHandshakeException)expected.getCause(); HttpResponse response = e.getResponse(); - assertEquals(response.statusCode(), 401); + assertEquals(401, response.statusCode()); } } } diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java index 0e55eaf521f..59a66591c93 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.Frame.HeaderWriter; import jdk.internal.net.http.websocket.Frame.Opcode; @@ -32,10 +31,12 @@ import java.util.OptionalInt; import static java.util.OptionalInt.empty; import static java.util.OptionalInt.of; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.TestSupport.assertThrows; import static jdk.internal.net.http.websocket.TestSupport.forEachPermutation; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class HeaderWriterTest { private long cases, frames; @@ -109,7 +110,7 @@ public class HeaderWriterTest { ByteBuffer actual = ByteBuffer.allocate(Frame.MAX_HEADER_SIZE_BYTES + 2); writer.write(actual); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); }); } } diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java index 7eb892f12ea..cb59b9f7213 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,17 +23,17 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; - import java.nio.ByteBuffer; import java.security.SecureRandom; import java.util.stream.IntStream; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.Frame.Masker.applyMask; import static jdk.internal.net.http.websocket.TestSupport.forEachBufferPartition; import static jdk.internal.net.http.websocket.TestSupport.fullCopy; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class MaskerTest { private static final SecureRandom random = new SecureRandom(); @@ -98,14 +98,14 @@ public class MaskerTest { int dstRemaining = dstCopy.remaining(); int masked = Math.min(srcRemaining, dstRemaining); // 1. position check - assertEquals(src.position(), srcCopy.position() + masked); - assertEquals(dst.position(), dstCopy.position() + masked); + assertEquals(srcCopy.position() + masked, src.position()); + assertEquals(dstCopy.position() + masked, dst.position()); // 2. masking check src.position(srcCopy.position()); dst.position(dstCopy.position()); for (; src.hasRemaining() && dst.hasRemaining(); offset = (offset + 1) & 3) { - assertEquals(dst.get(), src.get() ^ maskBytes[offset]); + assertEquals(src.get() ^ maskBytes[offset], dst.get()); } // 3. corruption check // 3.1 src contents haven't changed @@ -113,7 +113,7 @@ public class MaskerTest { int srcLimit = src.limit(); src.clear(); srcCopy.clear(); - assertEquals(src, srcCopy); + assertEquals(srcCopy, src); src.limit(srcLimit).position(srcPosition); // restore src // 3.2 dst leading and trailing regions' contents haven't changed int dstPosition = dst.position(); @@ -122,11 +122,11 @@ public class MaskerTest { // leading dst.position(0).limit(dstInitialPosition); dstCopy.position(0).limit(dstInitialPosition); - assertEquals(dst, dstCopy); + assertEquals(dstCopy, dst); // trailing dst.limit(dst.capacity()).position(dstLimit); dstCopy.limit(dst.capacity()).position(dstLimit); - assertEquals(dst, dstCopy); + assertEquals(dstCopy, dst); // restore dst dst.position(dstPosition).limit(dstLimit); return offset; diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java index 61503f0e235..73cab76df28 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,9 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -46,10 +43,14 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; import static jdk.internal.net.http.websocket.MessageQueue.effectiveCapacityOf; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +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; /* * A unit test for MessageQueue. The test is aware of the details of the queue @@ -59,7 +60,6 @@ public class MessageQueueTest { private static final Random r = new SecureRandom(); - @DataProvider(name = "illegalCapacities") public static Object[][] illegalCapacities() { return new Object[][]{ new Object[]{Integer.MIN_VALUE}, @@ -69,17 +69,20 @@ public class MessageQueueTest { }; } - @Test(dataProvider = "illegalCapacities") + @ParameterizedTest + @MethodSource("illegalCapacities") public void illegalCapacity(int n) { assertThrows(IllegalArgumentException.class, () -> new MessageQueue(n)); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void emptiness(int n) { assertTrue(new MessageQueue(n).isEmpty()); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void fullness(int n) throws IOException { MessageQueue q = new MessageQueue(n); int cap = effectiveCapacityOf(n); @@ -97,7 +100,7 @@ public class MessageQueueTest { for (int i = 0; i < cap; i++) { Message expected = referenceQueue.remove(); Message actual = new Remover().removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } } @@ -144,7 +147,8 @@ public class MessageQueueTest { action, future); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void caterpillarWalk(int n) throws IOException { // System.out.println("n: " + n); int cap = effectiveCapacityOf(n); @@ -164,7 +168,7 @@ public class MessageQueueTest { for (int i = 0; i < p; i++) { Message expected = referenceQueue.remove(); Message actual = remover.removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } assertTrue(q.isEmpty()); } @@ -243,7 +247,7 @@ public class MessageQueueTest { f.get(); // Just to check for exceptions } consumer.get(); // Waiting for consumer to collect all the messages - assertEquals(actualList.size(), expectedList.size()); + assertEquals(expectedList.size(), actualList.size()); for (Message m : expectedList) { assertTrue(actualList.remove(m)); } @@ -257,7 +261,8 @@ public class MessageQueueTest { } } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void testSingleThreaded(int n) throws IOException { Queue referenceQueue = new LinkedList<>(); MessageQueue q = new MessageQueue(n); @@ -271,13 +276,12 @@ public class MessageQueueTest { for (int i = 0; i < cap; i++) { Message expected = referenceQueue.remove(); Message actual = new Remover().removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } assertTrue(q.isEmpty()); } - @DataProvider(name = "capacities") - public Object[][] capacities() { + public static Object[][] capacities() { return new Object[][]{ new Object[]{ 1}, new Object[]{ 2}, diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java index c53ac88f69c..c7b1ab80fbd 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.Frame.Opcode; import java.nio.ByteBuffer; @@ -35,10 +34,12 @@ import java.util.function.IntUnaryOperator; import static java.util.OptionalInt.empty; import static java.util.OptionalInt.of; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.TestSupport.assertThrows; import static jdk.internal.net.http.websocket.TestSupport.forEachBufferPartition; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ReaderTest { private long cases, frames; @@ -128,15 +129,15 @@ public class ReaderTest { for (ByteBuffer b : buffers) { r.readFrame(b, c); } - assertEquals(fin, c.fin()); - assertEquals(rsv1, c.rsv1()); - assertEquals(rsv2, c.rsv2()); - assertEquals(rsv3, c.rsv3()); - assertEquals(opcode, c.opcode()); - assertEquals(mask.isPresent(), c.mask()); - assertEquals(payloadLen, c.payloadLen()); - assertEquals(mask, c.maskingKey()); - assertEquals(payloadLen == 0, c.isEndFrame()); + assertEquals(c.fin(), fin); + assertEquals(c.rsv1(), rsv1); + assertEquals(c.rsv2(), rsv2); + assertEquals(c.rsv3(), rsv3); + assertEquals(c.opcode(), opcode); + assertEquals(c.mask(), mask.isPresent()); + assertEquals(c.payloadLen(), payloadLen); + assertEquals(c.maskingKey(), mask); + assertEquals(c.isEndFrame(), payloadLen == 0); }); } diff --git a/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java b/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java index 787486dbd84..c8e4faa1ad3 100644 --- a/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java +++ b/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @summary Basic sanity checks for WebSocket URI from the Builder * @compile ../DummyWebSocketServer.java ../../ProxyServer.java - * @run testng/othervm WSSanityTest + * @run junit/othervm WSSanityTest */ import java.io.IOException; @@ -38,20 +38,21 @@ import java.net.URI; import java.util.List; import java.net.http.HttpClient; import java.net.http.WebSocket; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; public class WSSanityTest { - URI wsURI; - DummyWebSocketServer webSocketServer; - InetSocketAddress proxyAddress; + private static URI wsURI; + private static DummyWebSocketServer webSocketServer; + private static InetSocketAddress proxyAddress; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { ProxyServer proxyServer = new ProxyServer(0, true); proxyAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), proxyServer.getPort()); @@ -63,8 +64,8 @@ public class WSSanityTest { System.out.println("DummyWebSocketServer: " + wsURI); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { webSocketServer.close(); } @@ -75,8 +76,7 @@ public class WSSanityTest { T run() throws Exception; } - @DataProvider(name = "passingScenarios") - public Object[][] passingScenarios() { + public static Object[][] passingScenarios() { HttpClient noProxyClient = HttpClient.newHttpClient(); return new Object[][]{ { (ExceptionAction)() -> { @@ -146,14 +146,15 @@ public class WSSanityTest { HttpClient client = HttpClient.newBuilder().proxy(ps).build(); client.newWebSocketBuilder() .buildAsync(wsURI, noOpListener).get().abort(); - assertEquals(ps.count(), 1); // ps.select only invoked once + assertEquals(1, ps.count()); // ps.select only invoked once return null; }, "7" }, }; } - @Test(dataProvider = "passingScenarios") + @ParameterizedTest + @MethodSource("passingScenarios") public void testScenarios(ExceptionAction action, String dataProviderId) throws Exception { diff --git a/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java b/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java index 589e5409044..b9e5f2d58fe 100644 --- a/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java +++ b/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,17 +48,19 @@ import jdk.internal.net.http.HttpClientAccess; import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.AltSvcFrame; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static jdk.internal.net.http.AltServicesRegistry.AltService; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test - * @summary This test verifies alt-svc registry updation for frames + * @summary This test verifies alt-svc registry updating for frames * @library /test/lib /test/jdk/java/net/httpclient/lib * @build java.net.http/jdk.internal.net.http.HttpClientAccess * jdk.httpclient.test.lib.http2.Http2TestServer @@ -82,7 +84,7 @@ import static org.testng.Assert.assertTrue; * java.base/sun.net.www.http * java.base/sun.net.www * java.base/sun.net - * @run testng/othervm + * @run junit/othervm * -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.disableHostnameVerification @@ -90,7 +92,6 @@ import static org.testng.Assert.assertTrue; * AltSvcFrameTest */ - public class AltSvcFrameTest { private static final String IGNORED_HOST = "www.should-be-ignored.com"; @@ -109,18 +110,23 @@ public class AltSvcFrameTest { static HttpClient client; private static final SSLContext server = SimpleSSLContext.findSSLContext(); - @BeforeTest - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { getRegistry(); https2Server = new Http2TestServer("localhost", true, server); https2Server.addHandler(new AltSvcFrameTestHandler(), "/"); https2Server.setExchangeSupplier(AltSvcFrameTest.CFTHttp2TestExchange::new); https2Server.start(); https2URI = "https://" + https2Server.serverAuthority() + "/"; - - } + @AfterAll + public static void tearDown() { + if (client != null) client.close(); + if (https2Server != null) https2Server.stop(); + } + + static AltServicesRegistry getRegistry() { client = HttpClient.newBuilder() .sslContext(server) @@ -139,7 +145,7 @@ public class AltSvcFrameTest { .GET() .build(); HttpResponse response = client.send(request, ofString()); - assertEquals(response.statusCode(), 200, "unexpected response code"); + assertEquals(200, response.statusCode(), "unexpected response code"); final List services = registry.lookup(URI.create(https2URI), "h3").toList(); System.out.println("Alt services in registry for " + https2URI + " = " + services); final boolean hasExpectedAltSvc = services.stream().anyMatch( @@ -158,7 +164,7 @@ public class AltSvcFrameTest { .GET() .build(); HttpResponse response = client.send(request, ofString()); - assertEquals(response.statusCode(), 200, "unexpected response code"); + assertEquals(200, response.statusCode(), "unexpected response code"); final List services = registry.lookup( URI.create(FOO_BAR_ORIGIN), "h3").toList(); System.out.println("Alt services in registry for " + FOO_BAR_ORIGIN + " = " + services); diff --git a/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java b/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java index b853f715415..682082ba9f8 100644 --- a/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java +++ b/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,6 @@ import jdk.internal.net.http.AltServicesRegistry; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -46,6 +44,10 @@ import java.util.concurrent.Executors; import static jdk.internal.net.http.AltServicesRegistry.AltService; import static java.net.http.HttpResponse.BodyHandlers.ofString; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary This test verifies alt-svc registry updates @@ -73,7 +75,7 @@ import static java.net.http.HttpResponse.BodyHandlers.ofString; * java.base/sun.net.www * java.base/sun.net * java.base/jdk.internal.util - * @run testng/othervm + * @run junit/othervm * -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.disableHostnameVerification @@ -81,7 +83,6 @@ import static java.net.http.HttpResponse.BodyHandlers.ofString; * AltSvcRegistryTest */ - public class AltSvcRegistryTest implements HttpServerAdapters { static HttpTestServer https2Server; @@ -89,8 +90,8 @@ public class AltSvcRegistryTest implements HttpServerAdapters { static HttpClient client; private static final SSLContext server = SimpleSSLContext.findSSLContext(); - @BeforeTest - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { getRegistry(); final ExecutorService executor = Executors.newCachedThreadPool(); https2Server = HttpServerAdapters.HttpTestServer.of( @@ -98,8 +99,12 @@ public class AltSvcRegistryTest implements HttpServerAdapters { https2Server.addHandler(new AltSvcRegistryTestHandler("https", https2Server), "/"); https2Server.start(); https2URI = "https://" + https2Server.serverAuthority() + "/"; + } - + @AfterAll + public static void tearDown() { + if (client != null) client.close(); + if (https2Server != null) https2Server.stop(); } static AltServicesRegistry getRegistry() { diff --git a/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java b/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java index e932455e409..5808c380593 100644 --- a/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.AuthenticationFilterTest + * @run junit java.net.http/jdk.internal.net.http.AuthenticationFilterTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java b/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java index 5c18fd84a0f..54127855386 100644 --- a/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * @summary Verifies that the HTTP Client, by default, uses the system-wide * proxy selector, and that that selector supports the standard HTTP proxy * system properties. - * @run testng/othervm + * @run junit/othervm * -Dhttp.proxyHost=foo.proxy.com * -Dhttp.proxyPort=9876 * -Dhttp.nonProxyHosts=*.direct.com diff --git a/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java b/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java index ea442878261..c8b793a289c 100644 --- a/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http.common - * @run testng java.net.http/jdk.internal.net.http.common.DemandTest + * @run junit java.net.http/jdk.internal.net.http.common.DemandTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java b/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java index c24a733db3b..4468b5d6eb6 100644 --- a/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,5 +25,5 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/timeout=480 java.net.http/jdk.internal.net.http.FlowTest + * @run junit/timeout=480 java.net.http/jdk.internal.net.http.FlowTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java b/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java index 9b3c8878669..7edc555d8a6 100644 --- a/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @bug 8195823 * @modules java.net.http/jdk.internal.net.http.frame - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.frame.FramesDecoderTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java b/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java index b18142601a5..f3b9d410b51 100644 --- a/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,5 +25,5 @@ * @test * @bug 8195138 * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.Http1HeaderParserTest + * @run junit java.net.http/jdk.internal.net.http.Http1HeaderParserTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java b/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java index 316ca29e2a6..90fe6816adc 100644 --- a/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http.common - * @run testng java.net.http/jdk.internal.net.http.common.MinimalFutureTest + * @run junit java.net.http/jdk.internal.net.http.common.MinimalFutureTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java b/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java index ab44fba5ecd..7ca448b7892 100644 --- a/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,10 @@ * @test * @bug 8151299 8164704 * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm java.net.http/jdk.internal.net.http.RawChannelTest + * @run junit/othervm java.net.http/jdk.internal.net.http.RawChannelTest */ // use -// @run testng/othervm -Dseed=6434511950803022575 +// @run junit/othervm -Dseed=6434511950803022575 // java.net.http/jdk.internal.net.http.RawChannelTest // to reproduce a failure with a particular seed (e.g. 6434511950803022575) // if this test is observed failing with that seed diff --git a/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java index d641513b298..b4b3e59326d 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.SSLEchoTubeTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java index a49f53a844a..cb8e9801ca8 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +28,7 @@ * downReader doesn't request any * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djavax.net.debug=ssl:handshake * java.net.http/jdk.internal.net.http.SSLFlowDelegateTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java index b1994777b14..2c73de26648 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.SSLTubeTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java index 226e644e903..54d66d04cff 100644 --- a/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,5 +25,5 @@ * @test * @bug 8151299 8164704 * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.SelectorTest + * @run junit java.net.http/jdk.internal.net.http.SelectorTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java b/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java index 7943bfceaa0..16ac4aaefb8 100644 --- a/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,5 +26,5 @@ * @bug 8207960 * @modules java.net.http/jdk.internal.net.http * @summary Non-negative WINDOW_UPDATE increments may leave the stream window size negative - * @run testng/othervm java.net.http/jdk.internal.net.http.WindowControllerTest + * @run junit/othervm java.net.http/jdk.internal.net.http.WindowControllerTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java b/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java index 7ea2b07e3a7..dfc808ff68b 100644 --- a/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.WrapperTest + * @run junit java.net.http/jdk.internal.net.http.WrapperTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java index 944f8ae0872..699b537c980 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,17 +26,13 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLTube; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; -import java.util.StringTokenizer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java index 415caeb1196..2e9672e4725 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,6 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.HttpHeadersBuilder; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.annotations.AfterClass; import java.lang.ref.Reference; import java.net.Authenticator; @@ -55,12 +52,15 @@ import static java.util.stream.Collectors.joining; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; public class AuthenticationFilterTest { - @DataProvider(name = "uris") - public Object[][] responses() { + public static Object[][] responses() { return new Object[][] { { "http://foo.com", HTTP_1_1, null }, { "http://foo.com", HTTP_2, null }, @@ -135,7 +135,8 @@ public class AuthenticationFilterTest { return s == null || s.isEmpty(); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("responses") public void testAuthentication(String uri, Version v, String proxy) throws Exception { String test = format("testAuthentication: {\"%s\", %s, \"%s\"}", uri, v, proxy); try { @@ -146,8 +147,8 @@ public class AuthenticationFilterTest { } } - @AfterClass - public void printDiagnostic() { + @AfterAll + public static void printDiagnostic() { if (FAILED.isEmpty()) { out.println("All tests passed"); return; @@ -183,7 +184,7 @@ public class AuthenticationFilterTest { HttpClientImpl client = facade.impl; AuthenticationFilter filter = new AuthenticationFilter(); - assertEquals(authenticator.COUNTER.get(), 0); + assertEquals(0, authenticator.COUNTER.get()); // Creates the first HttpRequestImpl, and call filter.request() with // it. The expectation is that the filter will not add any credentials, @@ -202,7 +203,7 @@ public class AuthenticationFilterTest { HttpHeaders hdrs = req.getSystemHeadersBuilder().build(); assertFalse(hdrs.firstValue(authorization(true)).isPresent()); assertFalse(hdrs.firstValue(authorization(false)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 0); + assertEquals(0, authenticator.COUNTER.get()); // Creates the Response to the first request, and call filter.response // with it. That response has a 401 or 407 status code. @@ -221,9 +222,9 @@ public class AuthenticationFilterTest { out.println("Checking filter's response to " + unauthorized + " from " + uri); - assertTrue(next != null, "next should not be null"); + assertNotNull(next, "next should not be null"); String[] up = check(reqURI, next.getSystemHeadersBuilder().build(), proxy); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now simulate a new successful exchange to get the credentials in the cache // We first call filter.request with the request that was previously @@ -241,8 +242,8 @@ public class AuthenticationFilterTest { HttpHeaders h = HttpHeaders.of(Collections.emptyMap(), ACCEPT_ALL); response = new Response(next, exchange,h, null, 200, v); next = filter.response(response); - assertTrue(next == null, "next should be null"); - assertEquals(authenticator.COUNTER.get(), 1); + assertNull(next, "next should be null"); + assertEquals(1, authenticator.COUNTER.get()); // Now verify that the cache is used for the next request to the same server. // We're going to create a request to the same server by appending "/bar" to @@ -270,7 +271,7 @@ public class AuthenticationFilterTest { + " with proxy " + req2.proxy()); String[] up2 = check(reqURI, req2.getSystemHeadersBuilder().build(), proxy); assertTrue(Arrays.deepEquals(up, up2), format("%s:%s != %s:%s", up2[0], up2[1], up[0], up[1])); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now verify that the cache is not used if we send a request to a different server. // We're going to append ".bar" to the original request host name, and feed that @@ -316,7 +317,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h3, false)) .collect(joining(":"))); assertFalse(h3.firstValue(authorization(false)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now we will verify that credentials for proxies are not used for servers and // conversely. @@ -365,7 +366,7 @@ public class AuthenticationFilterTest { String[] up4 = check(reqURI, h4, proxy); assertTrue(Arrays.deepEquals(up, up4), format("%s:%s != %s:%s", up4[0], up4[1], up[0], up[1])); } - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); if (proxy != null) { // Now if we were using a proxy, we're going to send the same request than @@ -380,7 +381,7 @@ public class AuthenticationFilterTest { MultiExchange multi5 = new MultiExchange(origReq5, req5, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI + " with a proxy " + req5.proxy()); - assertTrue(req5.proxy() == null, "req5.proxy() should be null"); + assertNull(req5.proxy(), "req5.proxy() should be null"); Exchange exchange5 = new Exchange<>(req5, multi5); filter.request(req5, multi5); out.println("Check that filter has not added server credentials from cache for " @@ -398,7 +399,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h5, true)) .collect(joining(":"))); assertFalse(h5.firstValue(authorization(true)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now simulate a 401 response from the server HttpHeadersBuilder headers5Builder = new HttpHeadersBuilder(); @@ -410,11 +411,11 @@ public class AuthenticationFilterTest { out.println("Simulating " + unauthorized + " response from " + uri); HttpRequestImpl next5 = filter.response(response5); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); out.println("Checking filter's response to " + unauthorized + " from " + uri); - assertTrue(next5 != null, "next5 should not be null"); + assertNotNull(next5, "next5 should not be null"); String[] up5 = check(reqURI, next5.getSystemHeadersBuilder().build(), null); // now simulate a 200 response from the server @@ -423,7 +424,7 @@ public class AuthenticationFilterTest { h = HttpHeaders.of(Map.of(), ACCEPT_ALL); response5 = new Response(next5, exchange5, h, null, 200, v); filter.response(response5); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); // now send the request again, with proxy this time, and it should have both // server auth and proxy auth @@ -433,7 +434,7 @@ public class AuthenticationFilterTest { MultiExchange multi6 = new MultiExchange(origReq6, req6, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI + " with a proxy " + req6.proxy()); - assertTrue(req6.proxy() != null, "req6.proxy() should not be null"); + assertNotNull(req6.proxy(), "req6.proxy() should not be null"); Exchange exchange6 = new Exchange<>(req6, multi6); filter.request(req6, multi6); out.println("Check that filter has added server credentials from cache for " @@ -444,7 +445,7 @@ public class AuthenticationFilterTest { + reqURI + " (proxy: " + req6.proxy() + ")"); String[] up6 = check(reqURI, h6, proxy); assertTrue(Arrays.deepEquals(up, up6), format("%s:%s != %s:%s", up6[0], up6[1], up[0], up[1])); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); } if (proxy == null && uri.contains("x/y/z")) { @@ -456,7 +457,7 @@ public class AuthenticationFilterTest { MultiExchange multi7 = new MultiExchange(origReq7, req7, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI7 + " with a proxy " + req7.proxy()); - assertTrue(req7.proxy() == null, "req7.proxy() should be null"); + assertNull(req7.proxy(), "req7.proxy() should be null"); Exchange exchange7 = new Exchange<>(req7, multi7); filter.request(req7, multi7); out.println("Check that filter has not added server credentials from cache for " @@ -475,7 +476,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h7, true)) .collect(joining(":"))); assertFalse(h7.firstValue(authorization(true)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); } @@ -516,7 +517,7 @@ public class AuthenticationFilterTest { out.println("user:password: " + u + ":" + p); String protocol = proxy != null ? "http" : reqURI.getScheme(); String expectedUser = "u." + protocol; - assertEquals(u, expectedUser); + assertEquals(expectedUser, u); String host = proxy == null ? reqURI.getHost() : proxy.substring(0, proxy.lastIndexOf(':')); int port = proxy == null ? reqURI.getPort() @@ -524,7 +525,7 @@ public class AuthenticationFilterTest { String expectedPw = concat(requestorType(proxy!=null), "basic", protocol, host, port, "earth", reqURI.toURL()); - assertEquals(p, expectedPw); + assertEquals(expectedPw, p); return new String[] {u, p}; } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java index 96d08ae2c34..819b02e7fc7 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +29,9 @@ import java.net.ProxySelector; import java.net.URI; import java.net.http.HttpClient; import java.util.List; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DefaultProxy { @@ -42,7 +43,7 @@ public class DefaultProxy { public void testDefault() { ProxySelector ps = getProxySelector(); System.out.println("HttpClientImpl proxySelector:" + ps); - assertEquals(ps, ProxySelector.getDefault()); + assertEquals(ProxySelector.getDefault(), ps); } // From the test driver @@ -56,21 +57,21 @@ public class DefaultProxy { URI uri = URI.create("http://foo.com/example.html"); List plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); Proxy proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.HTTP); + assertEquals(Proxy.Type.HTTP, proxy.type()); InetSocketAddress expectedAddr = InetSocketAddress.createUnresolved("foo.proxy.com", 9876); - assertEquals(proxy.address(), expectedAddr); + assertEquals(expectedAddr, proxy.address()); // nonProxyHosts uri = URI.create("http://foo.direct.com/example.html"); plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.DIRECT); - assertEquals(proxy.address(), null); + assertEquals(Proxy.Type.DIRECT, proxy.type()); + assertEquals(null, proxy.address()); } // From the test driver @@ -83,21 +84,21 @@ public class DefaultProxy { URI uri = URI.create("https://foo.com/example.html"); List plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); Proxy proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.HTTP); + assertEquals(Proxy.Type.HTTP, proxy.type()); InetSocketAddress expectedAddr = InetSocketAddress.createUnresolved("secure.proxy.com", 5443); - assertEquals(proxy.address(), expectedAddr); + assertEquals(expectedAddr, proxy.address()); // nonProxyHosts uri = URI.create("https://foo.direct.com/example.html"); plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.DIRECT); - assertEquals(proxy.address(), null); + assertEquals(Proxy.Type.DIRECT, proxy.type()); + assertEquals(null, proxy.address()); } } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java index 3e9e967c061..cd05196b653 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,8 +32,6 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.util.List; -import java.util.Random; -import java.util.StringTokenizer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; @@ -47,10 +45,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import javax.net.ssl.*; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import jdk.internal.net.http.common.SSLFlowDelegate; -@Test +import org.junit.jupiter.api.Test; + public class FlowTest extends AbstractRandomTest { private final SubmissionPublisher> srcPublisher; @@ -241,7 +239,7 @@ public class FlowTest extends AbstractRandomTest { private void clientReader() { try { InputStream is = clientSock.getInputStream(); - final int bufsize = FlowTest.randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); println("clientReader: bufsize = " + bufsize); while (true) { byte[] buf = new byte[bufsize]; @@ -315,8 +313,8 @@ public class FlowTest extends AbstractRandomTest { private final AtomicInteger loopCount = new AtomicInteger(); public String monitor() { - return "serverLoopback: loopcount = " + loopCount.toString() - + " clientRead: count = " + readCount.toString(); + return "serverLoopback: loopcount = " + loopCount.get() + + " clientRead: count = " + readCount.get(); } // thread2 @@ -324,7 +322,7 @@ public class FlowTest extends AbstractRandomTest { try { InputStream is = serverSock.getInputStream(); OutputStream os = serverSock.getOutputStream(); - final int bufsize = FlowTest.randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); println("serverLoopback: bufsize = " + bufsize); byte[] bb = new byte[bufsize]; while (true) { diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java index 9bde9109095..a4c7b76aba8 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,22 +36,22 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.IntStream; import sun.net.www.MessageHeader; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; import static java.lang.System.out; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; // Mostly verifies the "new" Http1HeaderParser returns the same results as the // tried and tested sun.net.www.MessageHeader. public class Http1HeaderParserTest { - @DataProvider(name = "responses") - public Object[][] responses() { + public static Object[][] responses() { List responses = new ArrayList<>(); String[] basic = @@ -316,7 +316,8 @@ public class Http1HeaderParserTest { } - @Test(dataProvider = "responses") + @ParameterizedTest + @MethodSource("responses") public void verifyHeaders(String respString) throws Exception { System.out.println("\ntesting:\n\t" + respString .replace("\r\n", "") @@ -339,7 +340,7 @@ public class Http1HeaderParserTest { String statusLine1 = messageHeaderMap.get(null).get(0); String statusLine2 = decoder.statusLine(); if (statusLine1.startsWith("HTTP")) {// skip the case where MH's messes up the status-line - assertEquals(statusLine2, statusLine1, "Status-line not equal"); + assertEquals(statusLine1, statusLine2, "Status-line not equal"); } else { assertTrue(statusLine2.startsWith("HTTP/1."), "Status-line not HTTP/1."); } @@ -356,7 +357,7 @@ public class Http1HeaderParserTest { assertHeadersEqual(messageHeaderMap, decoderMap1, "messageHeaderMap not equal to decoderMap1"); - assertEquals(availableBytes, b.remaining(), + assertEquals(b.remaining(), availableBytes, String.format("stream available (%d) not equal to remaining (%d)", availableBytes, b.remaining())); // byte at a time @@ -366,14 +367,13 @@ public class Http1HeaderParserTest { .collect(toList()); while (decoder.parse(buffers.remove(0)) != true); Map> decoderMap2 = decoder.headers().map(); - assertEquals(availableBytes, buffers.size(), + assertEquals(buffers.size(), availableBytes, "stream available not equals to remaining buffers"); - assertEquals(decoderMap1, decoderMap2, "decoder maps not equal"); + assertEquals(decoderMap2, decoderMap1, "decoder maps not equal"); } - @DataProvider(name = "errors") - public Object[][] errors() { + public static Object[][] errors() { List responses = new ArrayList<>(); // These responses are parsed, somewhat, by MessageHeaders but give @@ -451,12 +451,15 @@ public class Http1HeaderParserTest { return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "errors", expectedExceptions = ProtocolException.class) + @ParameterizedTest + @MethodSource("errors") public void errors(String respString) throws ProtocolException { - byte[] bytes = respString.getBytes(US_ASCII); - Http1HeaderParser decoder = new Http1HeaderParser(); - ByteBuffer b = ByteBuffer.wrap(bytes); - decoder.parse(b); + assertThrows(ProtocolException.class, () -> { + byte[] bytes = respString.getBytes(US_ASCII); + Http1HeaderParser decoder = new Http1HeaderParser(); + ByteBuffer b = ByteBuffer.wrap(bytes); + decoder.parse(b); + }); } void assertHeadersEqual(Map> expected, @@ -466,7 +469,7 @@ public class Http1HeaderParserTest { if (expected.equals(actual)) return; - assertEquals(expected.size(), actual.size(), + assertEquals(actual.size(), expected.size(), format("%s. Expected size %d, actual size %s. %nexpected= %s,%n actual=%s.", msg, expected.size(), actual.size(), mapToString(expected), mapToString(actual))); @@ -479,7 +482,7 @@ public class Http1HeaderParserTest { if (key.equalsIgnoreCase(other.getKey())) { found = true; List otherValues = other.getValue(); - assertEquals(values.size(), otherValues.size(), + assertEquals(otherValues.size(), values.size(), format("%s. Expected list size %d, actual size %s", msg, values.size(), otherValues.size())); if (!(values.containsAll(otherValues) && otherValues.containsAll(values))) @@ -508,11 +511,11 @@ public class Http1HeaderParserTest { public static void main(String... args) throws Exception { Http1HeaderParserTest test = new Http1HeaderParserTest(); int count = 0; - for (Object[] objs : test.responses()) { + for (Object[] objs : Http1HeaderParserTest.responses()) { out.println("Testing " + count++ + ", " + objs[0]); test.verifyHeaders((String) objs[0]); } - for (Object[] objs : test.errors()) { + for (Object[] objs : Http1HeaderParserTest.errors()) { out.println("Testing " + count++ + ", " + objs[0]); try { test.errors((String) objs[0]); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java index f6bcdcb4d33..62ca237d2f1 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,10 +47,11 @@ import java.net.http.HttpResponse; import java.util.concurrent.atomic.AtomicReference; import jdk.internal.net.http.websocket.RawChannel; -import org.testng.annotations.Test; import static java.net.http.HttpResponse.BodyHandlers.discarding; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * This test exercises mechanics of _independent_ reads and writes on the @@ -222,8 +223,8 @@ public class RawChannelTest { closeChannel(chan); }); exit.await(); // All done, we need to compare results: - assertEquals(clientRead.get(), serverWritten.get()); - assertEquals(serverRead.get(), clientWritten.get()); + assertEquals(serverWritten.get(), clientRead.get()); + assertEquals(clientWritten.get(), serverRead.get()); Throwable serverError = testServer.failed.get(); if (serverError != null) { throw new AssertionError("TestServer failed: " diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java index 2884b74eee5..4316a46a25c 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +28,6 @@ import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLTube; import jdk.internal.net.http.common.SequentialScheduler; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.ByteBuffer; @@ -44,7 +43,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -@Test +import org.junit.jupiter.api.Test; + public class SSLEchoTubeTest extends AbstractSSLTubeTest { @Test diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java index 6b031bdfa58..32511de173b 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,10 +58,11 @@ import jdk.internal.net.http.common.Logger; import jdk.internal.net.http.common.SSLFlowDelegate; import jdk.internal.net.http.common.SubscriberWrapper; import jdk.internal.net.http.common.Utils; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; // jtreg test definition for this test resides in SSLFlowDelegateTestDriver.java public class SSLFlowDelegateTest { @@ -70,38 +71,38 @@ public class SSLFlowDelegateTest { private static final Random random = new Random(); private static final byte DATA_BYTE = (byte) random.nextInt(); - private ExecutorService executor; - private SSLParameters sslParams; - private SSLServerSocket sslServerSocket; - private SSLEngine clientEngine; - private CompletableFuture testCompletion; + private static ExecutorService executor; + private static SSLParameters sslParams; + private static SSLServerSocket sslServerSocket; + private static SSLEngine clientEngine; + private static CompletableFuture testCompletion; - @BeforeTest - public void beforeTest() throws Exception { - this.executor = Executors.newCachedThreadPool(); - this.testCompletion = new CompletableFuture<>(); + @BeforeAll + public static void beforeTest() throws Exception { + executor = Executors.newCachedThreadPool(); + testCompletion = new CompletableFuture<>(); final SSLParameters sp = new SSLParameters(); sp.setApplicationProtocols(new String[]{ALPN}); - this.sslParams = sp; + sslParams = sp; var sslContext = SimpleSSLContextWhiteboxAdapter.findSSLContext(); - this.sslServerSocket = startServer(sslContext); - println(debugTag, "Server started at " + this.sslServerSocket.getInetAddress() + ":" - + this.sslServerSocket.getLocalPort()); + sslServerSocket = startServer(sslContext); + println(debugTag, "Server started at " + sslServerSocket.getInetAddress() + ":" + + sslServerSocket.getLocalPort()); - this.clientEngine = createClientEngine(sslContext); + clientEngine = createClientEngine(sslContext); } - @AfterTest - public void afterTest() throws Exception { - if (this.sslServerSocket != null) { - println(debugTag, "Closing server socket " + this.sslServerSocket); - this.sslServerSocket.close(); + @AfterAll + public static void afterTest() throws Exception { + if (sslServerSocket != null) { + println(debugTag, "Closing server socket " + sslServerSocket); + sslServerSocket.close(); } - if (this.executor != null) { - println(debugTag, "Shutting down the executor " + this.executor); - this.executor.shutdownNow(); + if (executor != null) { + println(debugTag, "Shutting down the executor " + executor); + executor.shutdownNow(); } } @@ -117,30 +118,30 @@ public class SSLFlowDelegateTest { } } - private SSLServerSocket createSSLServerSocket( + private static SSLServerSocket createSSLServerSocket( final SSLContext ctx, final InetSocketAddress bindAddr) throws IOException { final SSLServerSocketFactory fac = ctx.getServerSocketFactory(); final SSLServerSocket sslServerSocket = (SSLServerSocket) fac.createServerSocket(); sslServerSocket.setReuseAddress(false); - sslServerSocket.setSSLParameters(this.sslParams); + sslServerSocket.setSSLParameters(sslParams); sslServerSocket.bind(bindAddr); return sslServerSocket; } - private SSLServerSocket startServer(final SSLContext ctx) throws Exception { + private static SSLServerSocket startServer(final SSLContext ctx) throws Exception { final SSLServerSocket sslServerSocket = createSSLServerSocket(ctx, new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); final Runnable serverResponsePusher = new ServerResponsePusher(sslServerSocket, - this.testCompletion); + testCompletion); final Thread serverThread = new Thread(serverResponsePusher, "serverResponsePusher"); // start the thread which will accept() a socket connection and send data over it serverThread.start(); return sslServerSocket; } - private SSLEngine createClientEngine(final SSLContext ctx) { + private static SSLEngine createClientEngine(final SSLContext ctx) { final SSLEngine clientEngine = ctx.createSSLEngine(); - clientEngine.setSSLParameters(this.sslParams); + clientEngine.setSSLParameters(sslParams); clientEngine.setUseClientMode(true); return clientEngine; } @@ -170,7 +171,7 @@ public class SSLFlowDelegateTest { // in various places in this test. If the "testCompletion" completes before // the "soleExpectedAppData" completes (typically due to some exception), // then we complete the "soleExpectedAppData" too. - this.testCompletion.whenComplete((r, t) -> { + testCompletion.whenComplete((r, t) -> { if (soleExpectedAppData.isDone()) { return; } @@ -221,7 +222,7 @@ public class SSLFlowDelegateTest { println(debugTag, "Waiting for handshake to complete"); final String negotiatedALPN = sslFlowDelegate.alpn().join(); println(debugTag, "handshake completed, with negotiated ALPN: " + negotiatedALPN); - Assert.assertEquals(negotiatedALPN, ALPN, "unexpected ALPN negotiated"); + assertEquals(ALPN, negotiatedALPN, "unexpected ALPN negotiated"); try { // now wait for the initial (and the only) chunk of application data to be // received by the AppResponseReceiver @@ -254,7 +255,7 @@ public class SSLFlowDelegateTest { private void failTest(final CompletionException ce) { final Throwable cause = ce.getCause(); - Assert.fail(cause.getMessage() == null ? "test failed" : cause.getMessage(), cause); + fail(cause.getMessage() == null ? "test failed" : cause.getMessage(), cause); } // uses reflection to get hold of the SSLFlowDelegate.reader.outputQ member field, @@ -288,7 +289,7 @@ public class SSLFlowDelegateTest { } println(debugTag, "num unsolicited bytes so far = " + numUnsolicitated); } - Assert.assertEquals(numUnsolicitated, 0, + assertEquals(0, numUnsolicitated, "SSLFlowDelegate has accumulated " + numUnsolicitated + " unsolicited bytes"); } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java index ac6a235b8e2..bb8d583e07b 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLFlowDelegate; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -51,7 +50,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SubmissionPublisher; import java.util.concurrent.atomic.AtomicInteger; -@Test +import org.junit.jupiter.api.Test; + public class SSLTubeTest extends AbstractSSLTubeTest { @Test @@ -125,7 +125,7 @@ public class SSLTubeTest extends AbstractSSLTubeTest { private void clientReader() { try { InputStream is = clientSock.getInputStream(); - final int bufsize = randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); System.out.println("clientReader: bufsize = " + bufsize); while (true) { byte[] buf = new byte[bufsize]; @@ -137,7 +137,7 @@ public class SSLTubeTest extends AbstractSSLTubeTest { allBytesReceived.await(); System.out.println("clientReader: closing publisher"); publisher.close(); - sleep(2000); + AbstractSSLTubeTest.sleep(2000); Utils.close(is, clientSock); return; } @@ -206,13 +206,13 @@ public class SSLTubeTest extends AbstractSSLTubeTest { try { InputStream is = serverSock.getInputStream(); OutputStream os = serverSock.getOutputStream(); - final int bufsize = randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); System.out.println("serverLoopback: bufsize = " + bufsize); byte[] bb = new byte[bufsize]; while (true) { int n = is.read(bb); if (n == -1) { - sleep(2000); + AbstractSSLTubeTest.sleep(2000); is.close(); os.close(); serverSock.close(); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java index 5b8da3b9979..3027df0436e 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,20 +31,20 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.net.http.HttpClient; import java.net.http.HttpResponse; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.RawChannel; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.concurrent.TimeUnit.SECONDS; import static java.net.http.HttpResponse.BodyHandlers.discarding; +import org.junit.jupiter.api.Test; + /** * Whitebox test of selector mechanics. Currently only a simple test * setting one read and one write event is done. It checks that the * write event occurs first, followed by the read event and then no * further events occur despite the conditions actually still existing. */ -@Test public class SelectorTest { AtomicInteger counter = new AtomicInteger(); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java index 0a94f471575..5df3b4227e6 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,92 +23,93 @@ package jdk.internal.net.http; -import org.testng.annotations.Test; import static jdk.internal.net.http.frame.SettingsFrame.DEFAULT_INITIAL_WINDOW_SIZE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class WindowControllerTest { @Test public void testConnectionWindowOverflow() { WindowController wc = new WindowController(); - assertEquals(wc.connectionWindowSize(), DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), DEFAULT_INITIAL_WINDOW_SIZE); + assertEquals(DEFAULT_INITIAL_WINDOW_SIZE, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(DEFAULT_INITIAL_WINDOW_SIZE, wc.connectionWindowSize()); wc.registerStream(1, DEFAULT_INITIAL_WINDOW_SIZE); wc.tryAcquire(DEFAULT_INITIAL_WINDOW_SIZE - 1, 1, null); - assertEquals(wc.connectionWindowSize(), 1); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), 1); + assertEquals(1, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(1, wc.connectionWindowSize()); wc.increaseConnectionWindow(Integer.MAX_VALUE - 1 -1); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE - 1); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE - 1); + assertEquals(Integer.MAX_VALUE - 1, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(Integer.MAX_VALUE - 1, wc.connectionWindowSize()); wc.increaseConnectionWindow(1); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE); - assertEquals(wc.increaseConnectionWindow(1), false); - assertEquals(wc.increaseConnectionWindow(100), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE); + assertEquals(Integer.MAX_VALUE, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(1)); + assertEquals(false, wc.increaseConnectionWindow(100)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(Integer.MAX_VALUE, wc.connectionWindowSize()); } @Test public void testStreamWindowOverflow() { WindowController wc = new WindowController(); wc.registerStream(1, DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); wc.registerStream(3, DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseStreamWindow(100, 3), true); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 3), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 3), false); + assertEquals(true, wc.increaseStreamWindow(100, 3)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 3)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 3)); wc.registerStream(5, 0); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 5), true); - assertEquals(wc.increaseStreamWindow(1, 5), false); - assertEquals(wc.increaseStreamWindow(1, 5), false); - assertEquals(wc.increaseStreamWindow(10, 5), false); + assertEquals(true, wc.increaseStreamWindow(Integer.MAX_VALUE, 5)); + assertEquals(false, wc.increaseStreamWindow(1, 5)); + assertEquals(false, wc.increaseStreamWindow(1, 5)); + assertEquals(false, wc.increaseStreamWindow(10, 5)); wc.registerStream(7, -1); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 7), true); - assertEquals(wc.increaseStreamWindow(1, 7), true); - assertEquals(wc.increaseStreamWindow(1, 7), false); - assertEquals(wc.increaseStreamWindow(10, 7), false); + assertEquals(true, wc.increaseStreamWindow(Integer.MAX_VALUE, 7)); + assertEquals(true, wc.increaseStreamWindow(1, 7)); + assertEquals(false, wc.increaseStreamWindow(1, 7)); + assertEquals(false, wc.increaseStreamWindow(10, 7)); wc.registerStream(9, -1); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(10, 9), true); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 9), false); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(10, 9)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 9)); wc.registerStream(11, -10); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.streamWindowSize(11), 1); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 11), false); - assertEquals(wc.streamWindowSize(11), 1); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(1, wc.streamWindowSize(11)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 11)); + assertEquals(1, wc.streamWindowSize(11)); } @Test @@ -125,9 +126,9 @@ public class WindowControllerTest { wc.tryAcquire(51, 5 , null); wc.adjustActiveStreams(-200); - assertEquals(wc.streamWindowSize(1), -149); - assertEquals(wc.streamWindowSize(3), -150); - assertEquals(wc.streamWindowSize(5), -151); + assertEquals(-149, wc.streamWindowSize(1)); + assertEquals(-150, wc.streamWindowSize(3)); + assertEquals(-151, wc.streamWindowSize(5)); } static final Class IE = InternalError.class; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java index 6dad2cc75b5..bc69c425678 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,11 +27,10 @@ import java.nio.ByteBuffer; import java.util.LinkedList; import java.util.List; import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import org.testng.annotations.Test; import jdk.internal.net.http.common.SubscriberWrapper; -@Test +import org.junit.jupiter.api.Test; + public class WrapperTest { static final int LO_PRI = 1; static final int HI_PRI = 2; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java index 4ea604fd488..1ea72f472e9 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,15 +23,16 @@ package jdk.internal.net.http.common; -import org.testng.annotations.Test; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicReference; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DemandTest { @@ -59,53 +60,61 @@ public class DemandTest { public void test03() { Demand d = new Demand(); d.increase(3); - assertEquals(d.decreaseAndGet(3), 3); + assertEquals(3, d.decreaseAndGet(3)); } @Test public void test04() { Demand d = new Demand(); d.increase(3); - assertEquals(d.decreaseAndGet(5), 3); + assertEquals(3, d.decreaseAndGet(5)); } @Test public void test05() { Demand d = new Demand(); d.increase(7); - assertEquals(d.decreaseAndGet(4), 4); + assertEquals(4, d.decreaseAndGet(4)); } @Test public void test06() { Demand d = new Demand(); - assertEquals(d.decreaseAndGet(3), 0); + assertEquals(0, d.decreaseAndGet(3)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test07() { - Demand d = new Demand(); - d.increase(0); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(0); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test08() { - Demand d = new Demand(); - d.increase(-1); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(-1); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test09() { - Demand d = new Demand(); - d.increase(10); - d.decreaseAndGet(0); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(10); + d.decreaseAndGet(0); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test10() { - Demand d = new Demand(); - d.increase(13); - d.decreaseAndGet(-3); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(13); + d.decreaseAndGet(-3); + }); } @Test @@ -169,7 +178,7 @@ public class DemandTest { assertTrue(d.isFulfilled()); } - @Test(invocationCount = 32) + @Test public void test15() throws InterruptedException { int N = Math.max(2, Runtime.getRuntime().availableProcessors() + 1); int M = ((N + 1) * N) / 2; // 1 + 2 + 3 + ... N @@ -187,7 +196,7 @@ public class DemandTest { error.compareAndSet(null, e); } try { - assertEquals(d.decreaseAndGet(j), j); + assertEquals(j, d.decreaseAndGet(j)); } catch (Throwable t) { error.compareAndSet(null, t); } finally { @@ -197,6 +206,6 @@ public class DemandTest { } stop.await(); assertTrue(d.isFulfilled()); - assertEquals(error.get(), null); + assertNull(error.get()); } } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java index 01798a645a2..2c33f6f0018 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,19 +23,19 @@ package jdk.internal.net.http.common; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; public class MinimalFutureTest { - @Test(dataProvider = "futures") + @ParameterizedTest + @MethodSource("futures") public void test(CompletableFuture mf) { ExecutorService executor = Executors.newSingleThreadExecutor(); try { @@ -134,8 +134,7 @@ public class MinimalFutureTest { } - @DataProvider(name = "futures") - public Object[][] futures() { + public static Object[][] futures() { MinimalFuture mf = new MinimalFuture<>(); mf.completeExceptionally(new Throwable()); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java index 3db439d1c00..e8acc95c1d2 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,15 +27,15 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class FramesDecoderTest { - abstract class TestFrameProcessor implements FramesDecoder.FrameProcessor { + abstract static class TestFrameProcessor implements FramesDecoder.FrameProcessor { protected volatile int count; public int numberOfFramesDecoded() { return count; } } @@ -69,17 +69,17 @@ public class FramesDecoderTest { assertTrue(frame instanceof DataFrame); DataFrame dataFrame = (DataFrame) frame; List list = dataFrame.getData(); - assertEquals(list.size(), 1); + assertEquals(1, list.size()); ByteBuffer data = list.get(0); byte[] bytes = new byte[data.remaining()]; data.get(bytes); if (count == 0) { - assertEquals(new String(bytes, UTF_8), "XXXX"); + assertEquals("XXXX", new String(bytes, UTF_8)); out.println("First data received:" + data); - assertEquals(data.position(), data.limit()); // since bytes read - assertEquals(data.limit(), data.capacity()); + assertEquals(data.limit(), data.position()); // since bytes read + assertEquals(data.capacity(), data.limit()); } else { - assertEquals(new String(bytes, UTF_8), "YYYY"); + assertEquals("YYYY", new String(bytes, UTF_8)); out.println("Second data received:" + data); } count++; @@ -89,7 +89,7 @@ public class FramesDecoderTest { out.println("Sending " + combined + " to decoder: "); decoder.decode(combined); - Assert.assertEquals(testFrameProcessor.numberOfFramesDecoded(), 2); + assertEquals(2, testFrameProcessor.numberOfFramesDecoded()); } @@ -119,15 +119,15 @@ public class FramesDecoderTest { assertTrue(frame instanceof DataFrame); DataFrame dataFrame = (DataFrame) frame; List list = dataFrame.getData(); - assertEquals(list.size(), 1); + assertEquals(1, list.size()); ByteBuffer data = list.get(0); byte[] bytes = new byte[data.remaining()]; data.get(bytes); - assertEquals(new String(bytes, UTF_8), "XXXX"); + assertEquals("XXXX", new String(bytes, UTF_8)); out.println("First data received:" + data); - assertEquals(data.position(), data.limit()); // since bytes read + assertEquals(data.limit(), data.position()); // since bytes read //assertNotEquals(data.limit(), data.capacity()); - assertEquals(data.capacity(), 1024 - 9 /*frame header*/); + assertEquals(1024 - 9 /*frame header*/, data.capacity()); count++; } }; @@ -135,6 +135,6 @@ public class FramesDecoderTest { out.println("Sending " + combined + " to decoder: "); decoder.decode(combined); - Assert.assertEquals(testFrameProcessor.numberOfFramesDecoded(), 1); + assertEquals(1, testFrameProcessor.numberOfFramesDecoded()); } } diff --git a/test/jdk/java/nio/Buffer/BulkPutBuffer.java b/test/jdk/java/nio/Buffer/BulkPutBuffer.java index d1d10ebff87..85ebb624d0f 100644 --- a/test/jdk/java/nio/Buffer/BulkPutBuffer.java +++ b/test/jdk/java/nio/Buffer/BulkPutBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,18 +41,22 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.stream.Stream; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 8219014 8245121 * @summary Ensure that a bulk put of a buffer into another is correct. * @compile BulkPutBuffer.java - * @run testng/othervm BulkPutBuffer + * @run junit/othervm BulkPutBuffer */ public class BulkPutBuffer { static final long SEED = System.nanoTime(); @@ -195,95 +199,64 @@ public class BulkPutBuffer { nextType = lookup.findVirtual(MyRandom.class, "next" + name, MethodType.methodType(elementType)); } catch (IllegalAccessException | NoSuchMethodException e) { - throw new AssertionError(e); + throw new RuntimeException(e); } } Buffer create(int capacity) throws Throwable { - Class bufferType = typeToAttr.get(elementType).type; + if (bufferType == ByteBuffer.class || kind == BufferKind.DIRECT || + kind == BufferKind.HEAP_VIEW) { - try { - if (bufferType == ByteBuffer.class || - kind == BufferKind.DIRECT || kind == BufferKind.HEAP_VIEW) { - int len = capacity*typeToAttr.get(elementType).bytes; - ByteBuffer bb = (ByteBuffer)allocBB.invoke(len); - byte[] bytes = new byte[len]; - RND.nextBytes(bytes); - bb.put(0, bytes); - if (bufferType == ByteBuffer.class) { - return (Buffer)bb; - } else { - bb.order(order); - return (Buffer)asTypeBuffer.invoke(bb); - } - } else if (bufferType == CharBuffer.class && - kind == BufferKind.STRING) { - char[] array = new char[capacity]; - for (int i = 0; i < capacity; i++) { - array[i] = RND.nextChar(); - } - return CharBuffer.wrap(new String(array)); + int len = capacity*typeToAttr.get(elementType).bytes; + ByteBuffer bb = (ByteBuffer)allocBB.invoke(len); + byte[] bytes = new byte[len]; + RND.nextBytes(bytes); + bb.put(0, bytes); + if (bufferType == ByteBuffer.class) { + return (Buffer)bb; } else { - Buffer buf = (Buffer)alloc.invoke(capacity); - for (int i = 0; i < capacity; i++) { - putAbs.invoke(buf, i, nextType.invoke(RND)); - } - return buf; + bb.order(order); + return (Buffer)asTypeBuffer.invoke(bb); } - } catch (Exception e) { - throw new AssertionError(e); + } else if (bufferType == CharBuffer.class && + kind == BufferKind.STRING) { + char[] array = new char[capacity]; + for (int i = 0; i < capacity; i++) { + array[i] = RND.nextChar(); + } + return CharBuffer.wrap(new String(array)); + } else { + Buffer buf = (Buffer)alloc.invoke(capacity); + for (int i = 0; i < capacity; i++) { + putAbs.invoke(buf, i, nextType.invoke(RND)); + } + return buf; } } void copy(Buffer src, int srcOff, Buffer dst, int dstOff, int length) throws Throwable { - try { - for (int i = 0; i < length; i++) { - putAbs.invoke(dst, dstOff + i, getAbs.invoke(src, srcOff + i)); - } - } catch (ReadOnlyBufferException ro) { - throw ro; - } catch (Exception e) { - throw new AssertionError(e); + for (int i = 0; i < length; i++) { + putAbs.invoke(dst, dstOff + i, getAbs.invoke(src, srcOff + i)); } } Buffer asReadOnlyBuffer(Buffer buf) throws Throwable { - try { - return (Buffer)asReadOnlyBuffer.invoke(buf); - } catch (Exception e) { - throw new AssertionError(e); - } + return (Buffer)asReadOnlyBuffer.invoke(buf); } void put(Buffer src, int srcOff, Buffer dst, int dstOff, int length) throws Throwable { - try { - putBufAbs.invoke(dst, dstOff, src, srcOff, length); - } catch (ReadOnlyBufferException ro) { - throw ro; - } catch (Exception e) { - throw new AssertionError(e); - } + putBufAbs.invoke(dst, dstOff, src, srcOff, length); } void put(Buffer src, Buffer dst) throws Throwable { - try { - putBufRel.invoke(dst, src); - } catch (ReadOnlyBufferException ro) { - throw ro; - } catch (Exception e) { - throw new AssertionError(e); - } + putBufRel.invoke(dst, src); } boolean equals(Buffer src, Buffer dst) throws Throwable { - try { - return Boolean.class.cast(equals.invoke(dst, src)); - } catch (Exception e) { - throw new AssertionError(e); - } + return Boolean.class.cast(equals.invoke(dst, src)); } } @@ -297,68 +270,58 @@ public class BulkPutBuffer { return proxies; } - @DataProvider - static Object[][] proxies() { - ArrayList args = new ArrayList<>(); + static Stream proxies() { + List args = new ArrayList(); for (Class type : typeToAttr.keySet()) { + List proxies = getProxies(type); for (BufferProxy proxy : proxies) { - args.add(new Object[] {proxy}); + args.add(proxy); } } - return args.toArray(Object[][]::new); + return args.stream(); } - @DataProvider - static Object[][] proxyPairs() { - List args = new ArrayList<>(); + static Stream proxyPairs() { + List args = new ArrayList(); for (Class type : typeToAttr.keySet()) { List proxies = getProxies(type); for (BufferProxy proxy1 : proxies) { for (BufferProxy proxy2 : proxies) { - args.add(new Object[] {proxy1, proxy2}); + args.add(Arguments.of(proxy1, proxy2)); } } } - return args.toArray(Object[][]::new); + return args.stream(); } - private static void expectThrows(Class exClass, Assert.ThrowingRunnable r) { - try { - r.run(); - } catch(Throwable e) { - if (e.getClass() != exClass && e.getCause().getClass() != exClass) { - throw new RuntimeException("Expected " + exClass + - "; got " + e.getCause().getClass(), e); - } - } - } - - @Test(dataProvider = "proxies") - public static void testExceptions(BufferProxy bp) throws Throwable { + @ParameterizedTest + @MethodSource("proxies") + public void testExceptions(BufferProxy bp) throws Throwable { int cap = 27; Buffer buf = bp.create(cap); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, -1, buf, 0, 1)); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, 0, buf, -1, 1)); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, 1, buf, 0, cap)); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, 0, buf, 1, cap)); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, 0, buf, 0, cap + 1)); - expectThrows(IndexOutOfBoundsException.class, + assertThrows(IndexOutOfBoundsException.class, () -> bp.put(buf, 0, buf, 0, Integer.MAX_VALUE)); Buffer rob = buf.isReadOnly() ? buf : bp.asReadOnlyBuffer(buf); - expectThrows(ReadOnlyBufferException.class, + assertThrows(ReadOnlyBufferException.class, () -> bp.put(buf, 0, rob, 0, cap)); } - @Test(dataProvider = "proxies") - public static void testSelf(BufferProxy bp) throws Throwable { + @ParameterizedTest + @MethodSource("proxies") + public void testSelf(BufferProxy bp) throws Throwable { for (int i = 0; i < ITERATIONS; i++) { int cap = RND.nextInt(MAX_CAPACITY); Buffer buf = bp.create(cap); @@ -371,7 +334,7 @@ public class BulkPutBuffer { Buffer lowerCopy = bp.create(lowerLength); if (lowerCopy.isReadOnly()) { - Assert.expectThrows(ReadOnlyBufferException.class, + assertThrows(ReadOnlyBufferException.class, () -> bp.copy(lower, 0, lowerCopy, 0, lowerLength)); break; } @@ -385,7 +348,7 @@ public class BulkPutBuffer { bp.put(lower, middle); middle.flip(); - Assert.assertTrue(bp.equals(lowerCopy, middle), + assertTrue(bp.equals(lowerCopy, middle), String.format("%d %s %d %d %d %d%n", SEED, buf.getClass().getName(), cap, lowerOffset, lowerLength, middleOffset)); @@ -395,15 +358,16 @@ public class BulkPutBuffer { bp.put(buf, lowerOffset, buf, middleOffset, lowerLength); - Assert.assertTrue(bp.equals(lowerCopy, middle), + assertTrue(bp.equals(lowerCopy, middle), String.format("%d %s %d %d %d %d%n", SEED, buf.getClass().getName(), cap, lowerOffset, lowerLength, middleOffset)); } } - @Test(dataProvider = "proxyPairs") - public static void testPairs(BufferProxy bp, BufferProxy sbp) throws Throwable { + @ParameterizedTest + @MethodSource("proxyPairs") + public void testPairs(BufferProxy bp, BufferProxy sbp) throws Throwable { for (int i = 0; i < ITERATIONS; i++) { int cap = Math.max(4, RND.nextInt(MAX_CAPACITY)); int cap2 = cap/2; @@ -426,7 +390,7 @@ public class BulkPutBuffer { src.limit(slim); if (buf.isReadOnly()) { - Assert.expectThrows(ReadOnlyBufferException.class, + assertThrows(ReadOnlyBufferException.class, () -> bp.put(src, buf)); break; } @@ -438,7 +402,7 @@ public class BulkPutBuffer { buf.reset(); src.reset(); - Assert.assertTrue(bp.equals(src, buf), + assertTrue(bp.equals(src, buf), String.format("%d %s %d %d %d %s %d %d %d%n", SEED, buf.getClass().getName(), cap, pos, lim, src.getClass().getName(), scap, spos, slim)); @@ -452,7 +416,7 @@ public class BulkPutBuffer { buf.position(pos); buf.limit(lim); - Assert.assertTrue(bp.equals(src, buf), + assertTrue(bp.equals(src, buf), String.format("%d %s %d %d %d %s %d %d %d%n", SEED, buf.getClass().getName(), cap, pos, lim, src.getClass().getName(), scap, spos, slim)); diff --git a/test/jdk/java/nio/Buffer/ByteBufferViews.java b/test/jdk/java/nio/Buffer/ByteBufferViews.java index f0136939d53..17bd6af4033 100644 --- a/test/jdk/java/nio/Buffer/ByteBufferViews.java +++ b/test/jdk/java/nio/Buffer/ByteBufferViews.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,9 @@ /* @test * @summary Binary data and view tests for byte buffers * @bug 8159257 8258955 - * @run testng ByteBufferViews + * @run junit ByteBufferViews */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -46,8 +43,15 @@ import java.util.function.IntFunction; import java.util.function.IntUnaryOperator; import java.util.function.UnaryOperator; import java.util.stream.Collectors; +import java.util.stream.Stream; -import static org.testng.Assert.*; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.fail; public class ByteBufferViews { static final int SIZE = 32; @@ -127,14 +131,15 @@ public class ByteBufferViews { // Creates a cross product of test arguments for // buffer allocator functions and buffer view functions - static Object[][] product(List> la, - List> lb) { + static Stream product(List> la, + List> lb) { return la.stream().flatMap(lae -> lb.stream(). - map(lbe -> List.of( - lae.getKey() + " -> " + lbe.getKey(), - lae.getValue(), - lbe.getValue()).toArray() - )).toArray(Object[][]::new); + map(lbe -> Arguments.of + ( + lae.getKey() + " -> " + lbe.getKey(), + lae.getValue(), + lbe.getValue()) + )); } static void assertValues(int i, Object bValue, Object bbValue, ByteBuffer bb) { @@ -167,8 +172,7 @@ public class ByteBufferViews { } - @DataProvider - public static Object[][] shortViewProvider() { + public static Stream shortBufferViews() { List>> bfs = List.of( Map.entry("bb.asShortBuffer()", bb -> bb.asShortBuffer()), @@ -186,7 +190,8 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "shortViewProvider") + @ParameterizedTest + @MethodSource("shortBufferViews") public void testShortGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -213,7 +218,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "shortViewProvider") + @ParameterizedTest + @MethodSource("shortBufferViews") public void testShortPut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); @@ -271,8 +277,7 @@ public class ByteBufferViews { } } - @DataProvider - public static Object[][] charViewProvider() { + public static Stream charBufferViews() { List>> bfs = List.of( Map.entry("bb.asCharBuffer()", bb -> bb.asCharBuffer()), @@ -290,7 +295,8 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "charViewProvider") + @ParameterizedTest + @MethodSource("charBufferViews") public void testCharGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -317,7 +323,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "charViewProvider") + @ParameterizedTest + @MethodSource("charBufferViews") public void testCharPut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); @@ -368,8 +375,7 @@ public class ByteBufferViews { } - @DataProvider - public static Object[][] intViewProvider() { + public static Stream intBufferViews() { List>> bfs = List.of( Map.entry("bb.asIntBuffer()", bb -> bb.asIntBuffer()), @@ -387,7 +393,8 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "intViewProvider") + @ParameterizedTest + @MethodSource("intBufferViews") public void testIntGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -414,7 +421,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "intViewProvider") + @ParameterizedTest + @MethodSource("intBufferViews") public void testIntPut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); @@ -475,8 +483,7 @@ public class ByteBufferViews { } - @DataProvider - public static Object[][] longViewProvider() { + public static Stream longBufferViews() { List>> bfs = List.of( Map.entry("bb.asLongBuffer()", bb -> bb.asLongBuffer()), @@ -494,7 +501,8 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "longViewProvider") + @ParameterizedTest + @MethodSource("longBufferViews") public void testLongGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -521,7 +529,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "longViewProvider") + @ParameterizedTest + @MethodSource("longBufferViews") public void testLongPut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); @@ -587,9 +596,7 @@ public class ByteBufferViews { } } - - @DataProvider - public static Object[][] floatViewProvider() { + public static Stream floatBufferViews() { List>> bfs = List.of( Map.entry("bb.asFloatBuffer()", bb -> bb.asFloatBuffer()), @@ -607,7 +614,8 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "floatViewProvider") + @ParameterizedTest + @MethodSource("floatBufferViews") public void testFloatGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -634,7 +642,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "floatViewProvider") + @ParameterizedTest + @MethodSource("floatBufferViews") public void testFloatPut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); @@ -684,10 +693,7 @@ public class ByteBufferViews { return Float.intBitsToFloat(getIntFromBytes(bb, i)); } - - - @DataProvider - public static Object[][] doubleViewProvider() { + public static Stream doubleBufferViews() { List>> bfs = List.of( Map.entry("bb.asDoubleBuffer()", bb -> bb.asDoubleBuffer()), @@ -705,7 +711,7 @@ public class ByteBufferViews { return product(BYTE_BUFFER_FUNCTIONS, bfs); } - @Test(dataProvider = "doubleViewProvider") + @MethodSource("doubleBufferViews") public void testDoubleGet(String desc, IntFunction fbb, Function fbi) { ByteBuffer bb = allocate(fbb); @@ -732,7 +738,8 @@ public class ByteBufferViews { } - @Test(dataProvider = "doubleViewProvider") + @ParameterizedTest + @MethodSource("doubleBufferViews") public void testDoublePut(String desc, IntFunction fbb, Function fbi) { ByteBuffer bbfilled = allocate(fbb); diff --git a/test/jdk/java/nio/Buffer/Chars.java b/test/jdk/java/nio/Buffer/Chars.java index 01b53ea2405..1b978eecb74 100644 --- a/test/jdk/java/nio/Buffer/Chars.java +++ b/test/jdk/java/nio/Buffer/Chars.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,7 +25,7 @@ * @test * @bug 8014854 * @summary Exercises CharBuffer#chars on each of the CharBuffer types - * @run testng Chars + * @run junit Chars * @key randomness */ @@ -35,11 +35,13 @@ import java.nio.CharBuffer; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Chars { @@ -98,8 +100,7 @@ public class Chars { buffers.add(randomizeRange(cb.asReadOnlyBuffer())); } - @DataProvider(name = "charbuffers") - public Object[][] createCharBuffers() { + private static Stream createCharBuffers() { List buffers = new ArrayList<>(); // heap @@ -119,20 +120,21 @@ public class Chars { // read-only buffer backed by a CharSequence buffers.add(CharBuffer.wrap(randomize(CharBuffer.allocate(SIZE)))); - Object[][] params = new Object[buffers.size()][]; + List params = new ArrayList(); for (int i = 0; i < buffers.size(); i++) { CharBuffer cb = buffers.get(i); - params[i] = new Object[] { cb.getClass().getName(), cb }; + params.add((Arguments.of(cb.getClass().getName(), cb))); } - return params; + return params.stream(); } - @Test(dataProvider = "charbuffers") + @ParameterizedTest + @MethodSource("createCharBuffers") public void testChars(String type, CharBuffer cb) { - System.out.format("%s position=%d, limit=%d%n", type, cb.position(), cb.limit()); + System.err.format("%s position=%d, limit=%d%n", type, cb.position(), cb.limit()); int expected = intSum(cb); - assertEquals(cb.chars().sum(), expected); - assertEquals(cb.chars().parallel().sum(), expected); + assertEquals(expected, cb.chars().sum()); + assertEquals(expected, cb.chars().parallel().sum()); } } diff --git a/test/jdk/java/nio/Buffer/EqualsCompareTest.java b/test/jdk/java/nio/Buffer/EqualsCompareTest.java index 03bd7c26a58..8c098767253 100644 --- a/test/jdk/java/nio/Buffer/EqualsCompareTest.java +++ b/test/jdk/java/nio/Buffer/EqualsCompareTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,10 +21,6 @@ * questions. */ -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -48,15 +44,25 @@ import java.util.Set; import java.util.function.BiFunction; import java.util.function.LongFunction; import java.util.stream.IntStream; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.StandardOpenOption.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 8193085 8199773 * @summary tests for buffer equals and compare - * @run testng EqualsCompareTest + * @run junit EqualsCompareTest */ public class EqualsCompareTest { @@ -446,89 +452,66 @@ public class EqualsCompareTest { } } - static Object[][] bufferTypes; - - @DataProvider - public static Object[][] bufferTypesProvider() { - if (bufferTypes == null) { - bufferTypes = new Object[][]{ - {new BufferType.Bytes(BufferKind.HEAP)}, - {new BufferType.Bytes(BufferKind.DIRECT)}, - {new BufferType.Chars(BufferKind.HEAP)}, - {new BufferType.Chars(BufferKind.HEAP_VIEW)}, - {new BufferType.Chars(BufferKind.DIRECT)}, - {new BufferType.Shorts(BufferKind.HEAP)}, - {new BufferType.Shorts(BufferKind.HEAP_VIEW)}, - {new BufferType.Shorts(BufferKind.DIRECT)}, - {new BufferType.Ints(BufferKind.HEAP)}, - {new BufferType.Ints(BufferKind.HEAP_VIEW)}, - {new BufferType.Ints(BufferKind.DIRECT)}, - {new BufferType.Floats(BufferKind.HEAP)}, - {new BufferType.Floats(BufferKind.HEAP_VIEW)}, - {new BufferType.Floats(BufferKind.DIRECT)}, - {new BufferType.Longs(BufferKind.HEAP)}, - {new BufferType.Longs(BufferKind.HEAP_VIEW)}, - {new BufferType.Longs(BufferKind.DIRECT)}, - {new BufferType.Doubles(BufferKind.HEAP)}, - {new BufferType.Doubles(BufferKind.HEAP_VIEW)}, - {new BufferType.Doubles(BufferKind.DIRECT)}, - }; - } - return bufferTypes; + public static Stream bufferTypesSource() { + return Stream.of + (new BufferType.Bytes(BufferKind.HEAP), + new BufferType.Bytes(BufferKind.DIRECT), + new BufferType.Chars(BufferKind.HEAP), + new BufferType.Chars(BufferKind.HEAP_VIEW), + new BufferType.Chars(BufferKind.DIRECT), + new BufferType.Shorts(BufferKind.HEAP), + new BufferType.Shorts(BufferKind.HEAP_VIEW), + new BufferType.Shorts(BufferKind.DIRECT), + new BufferType.Ints(BufferKind.HEAP), + new BufferType.Ints(BufferKind.HEAP_VIEW), + new BufferType.Ints(BufferKind.DIRECT), + new BufferType.Floats(BufferKind.HEAP), + new BufferType.Floats(BufferKind.HEAP_VIEW), + new BufferType.Floats(BufferKind.DIRECT), + new BufferType.Longs(BufferKind.HEAP), + new BufferType.Longs(BufferKind.HEAP_VIEW), + new BufferType.Longs(BufferKind.DIRECT), + new BufferType.Doubles(BufferKind.HEAP), + new BufferType.Doubles(BufferKind.HEAP_VIEW), + new BufferType.Doubles(BufferKind.DIRECT)); } - - static Object[][] floatbufferTypes; - - @DataProvider - public static Object[][] floatBufferTypesProvider() { - if (floatbufferTypes == null) { + public static Stream floatBufferTypesSource() { LongFunction bTof = rb -> Float.intBitsToFloat((int) rb); LongFunction bToD = Double::longBitsToDouble; - floatbufferTypes = new Object[][]{ - // canonical and non-canonical NaNs - // If conversion is a signalling NaN it may be subject to conversion to a - // quiet NaN on some processors, even if a copy is performed - // The tests assume that if conversion occurs it does not convert to the - // canonical NaN - new Object[]{new BufferType.Floats(BufferKind.HEAP), 0x7fc00000L, 0x7f800001L, bTof}, - new Object[]{new BufferType.Floats(BufferKind.HEAP_VIEW), 0x7fc00000L, 0x7f800001L, bTof}, - new Object[]{new BufferType.Floats(BufferKind.DIRECT), 0x7fc00000L, 0x7f800001L, bTof}, - new Object[]{new BufferType.Doubles(BufferKind.HEAP), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD}, - new Object[]{new BufferType.Doubles(BufferKind.HEAP_VIEW), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD}, - new Object[]{new BufferType.Doubles(BufferKind.DIRECT), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD}, + return Stream.of + (// canonical and non-canonical NaNs + // If conversion is a signalling NaN it may be subject to conversion to a + // quiet NaN on some processors, even if a copy is performed + // The tests assume that if conversion occurs it does not convert to the + // canonical NaN + Arguments.of(new BufferType.Floats(BufferKind.HEAP), 0x7fc00000L, 0x7f800001L, bTof), + Arguments.of(new BufferType.Floats(BufferKind.HEAP_VIEW), 0x7fc00000L, 0x7f800001L, bTof), + Arguments.of(new BufferType.Floats(BufferKind.DIRECT), 0x7fc00000L, 0x7f800001L, bTof), + Arguments.of(new BufferType.Doubles(BufferKind.HEAP), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD), + Arguments.of(new BufferType.Doubles(BufferKind.HEAP_VIEW), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD), + Arguments.of(new BufferType.Doubles(BufferKind.DIRECT), 0x7ff8000000000000L, 0x7ff0000000000001L, bToD), - // +0.0 and -0.0 - new Object[]{new BufferType.Floats(BufferKind.HEAP), 0x0L, 0x80000000L, bTof}, - new Object[]{new BufferType.Floats(BufferKind.HEAP_VIEW), 0x0L, 0x80000000L, bTof}, - new Object[]{new BufferType.Floats(BufferKind.DIRECT), 0x0L, 0x80000000L, bTof}, - new Object[]{new BufferType.Doubles(BufferKind.HEAP), 0x0L, 0x8000000000000000L, bToD}, - new Object[]{new BufferType.Doubles(BufferKind.HEAP_VIEW), 0x0L, 0x8000000000000000L, bToD}, - new Object[]{new BufferType.Doubles(BufferKind.DIRECT), 0x0L, 0x8000000000000000L, bToD}, - }; - } - return floatbufferTypes; + // +0.0 and -0.0 + Arguments.of(new BufferType.Floats(BufferKind.HEAP), 0x0L, 0x80000000L, bTof), + Arguments.of(new BufferType.Floats(BufferKind.HEAP_VIEW), 0x0L, 0x80000000L, bTof), + Arguments.of(new BufferType.Floats(BufferKind.DIRECT), 0x0L, 0x80000000L, bTof), + Arguments.of(new BufferType.Doubles(BufferKind.HEAP), 0x0L, 0x8000000000000000L, bToD), + Arguments.of(new BufferType.Doubles(BufferKind.HEAP_VIEW), 0x0L, 0x8000000000000000L, bToD), + Arguments.of(new BufferType.Doubles(BufferKind.DIRECT), 0x0L, 0x8000000000000000L, bToD)); } - - static Object[][] charBufferTypes; - - @DataProvider - public static Object[][] charBufferTypesProvider() { - if (charBufferTypes == null) { - charBufferTypes = new Object[][]{ - {new BufferType.Chars(BufferKind.HEAP)}, - {new BufferType.Chars(BufferKind.HEAP_VIEW)}, - {new BufferType.Chars(BufferKind.DIRECT)}, - }; - } - return charBufferTypes; + public static Stream charBufferTypesSource() { + return Stream.of + (Arguments.of(new BufferType.Chars(BufferKind.HEAP)), + Arguments.of(new BufferType.Chars(BufferKind.HEAP_VIEW)), + Arguments.of(new BufferType.Chars(BufferKind.DIRECT))); } - // Tests all primitive buffers - @Test(dataProvider = "bufferTypesProvider") + @ParameterizedTest + @MethodSource("bufferTypesSource") void testBuffers(BufferType bufferType) { // Test with buffers of the same byte order (BE) @@ -559,7 +542,8 @@ public class EqualsCompareTest { } // Tests float and double buffers with edge-case values (NaN, -0.0, +0.0) - @Test(dataProvider = "floatBufferTypesProvider") + @ParameterizedTest + @MethodSource("floatBufferTypesSource") public void testFloatBuffers( BufferType bufferType, long rawBitsA, long rawBitsB, @@ -596,17 +580,18 @@ public class EqualsCompareTest { // Sanity check int size = arraySizeFor(bufferType.elementType); - Assert.assertTrue(bufferType.pairWiseEquals(allAs.apply(bufferType, size), - allBs.apply(bufferType, size))); - Assert.assertTrue(bufferType.equals(allAs.apply(bufferType, size), - allBs.apply(bufferType, size))); + assertTrue(bufferType.pairWiseEquals(allAs.apply(bufferType, size), + allBs.apply(bufferType, size))); + assertTrue(bufferType.equals(allAs.apply(bufferType, size), + allBs.apply(bufferType, size))); testBufferType(bufferType, allAs, allBs); testBufferType(bufferType, allAs, halfBs); } // Tests CharBuffer for region sources and CharSequence sources - @Test(dataProvider = "charBufferTypesProvider") + @ParameterizedTest + @MethodSource("charBufferTypesSource") public void testCharBuffers(BufferType.Chars charBufferType) { BiFunction constructor = (at, s) -> { @@ -623,7 +608,6 @@ public class EqualsCompareTest { testBufferType(charBufferType, constructor, constructorX); } - > void testBufferType(BT bt, BiFunction aConstructor, @@ -652,26 +636,26 @@ public class EqualsCompareTest { : b; boolean eq = bt.pairWiseEquals(as, bs); - Assert.assertEquals(bt.equals(as, bs), eq); - Assert.assertEquals(bt.equals(bs, as), eq); + assertEquals(eq, bt.equals(as, bs)); + assertEquals(eq, bt.equals(bs, as)); if (eq) { - Assert.assertEquals(bt.compare(as, bs), 0); - Assert.assertEquals(bt.compare(bs, as), 0); + assertEquals(0, bt.compare(as, bs)); + assertEquals(0, bt.compare(bs, as)); // If buffers are equal, there shall be no mismatch - Assert.assertEquals(bt.mismatch(as, bs), -1); - Assert.assertEquals(bt.mismatch(bs, as), -1); + assertEquals(-1, bt.mismatch(as, bs)); + assertEquals(-1, bt.mismatch(bs, as)); } else { int aCb = bt.compare(as, bs); int bCa = bt.compare(bs, as); int v = Integer.signum(aCb) * Integer.signum(bCa); - Assert.assertTrue(v == -1); + assertEquals(-1, v); int aMs = bt.mismatch(as, bs); int bMs = bt.mismatch(bs, as); - Assert.assertNotEquals(aMs, -1); - Assert.assertEquals(aMs, bMs); + assertNotEquals(-1, aMs); + assertEquals(bMs, aMs); } } } @@ -686,17 +670,17 @@ public class EqualsCompareTest { // Create common prefix with a length of i - aFrom bt.set(c, i, -1); - Assert.assertFalse(bt.equals(c, a)); + assertFalse(bt.equals(c, a)); int cCa = bt.compare(cs, as); int aCc = bt.compare(as, cs); int v = Integer.signum(cCa) * Integer.signum(aCc); - Assert.assertTrue(v == -1); + assertEquals(-1, v); int cMa = bt.mismatch(cs, as); int aMc = bt.mismatch(as, cs); - Assert.assertEquals(cMa, aMc); - Assert.assertEquals(cMa, i - aFrom); + assertEquals(aMc, cMa); + assertEquals(i - aFrom, cMa); } } } @@ -731,8 +715,8 @@ public class EqualsCompareTest { try (FileChannel fc = FileChannel.open(path, READ, DELETE_ON_CLOSE)) { MappedByteBuffer one = fc.map(FileChannel.MapMode.READ_ONLY, 0, bytes.length); ByteBuffer two = ByteBuffer.wrap(bytes); - Assert.assertEquals(one, two); - Assert.assertEquals(one.hashCode(), two.hashCode()); + assertEquals(two, one); + assertEquals(two.hashCode(), one.hashCode()); } } } diff --git a/test/jdk/java/nio/Buffer/ReachabilityTest.java b/test/jdk/java/nio/Buffer/ReachabilityTest.java index 2b0a2710b46..114077b3626 100644 --- a/test/jdk/java/nio/Buffer/ReachabilityTest.java +++ b/test/jdk/java/nio/Buffer/ReachabilityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,9 @@ /* @test * @bug 8208362 * @summary Tests reachability from source to dependent direct byte buffers - * @run testng ReachabilityTest + * @run junit ReachabilityTest */ -import org.testng.Assert; -import org.testng.annotations.Test; - import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; @@ -41,8 +38,14 @@ import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.function.UnaryOperator; +import org.junit.jupiter.api.Test; + import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class ReachabilityTest { @Test @@ -98,13 +101,13 @@ public class ReachabilityTest { } } } catch (InterruptedException unexpected) { - throw new AssertionError("unexpected InterruptedException"); + fail("unexpected InterruptedException"); } // Some or all of the intermediate values must be GC'ed - Assert.assertTrue(collected); + assertTrue(collected); // The root should never be GC'ed - Assert.assertNotNull(root.get()); + assertNotNull(root.get()); Reference.reachabilityFence(t); } diff --git a/test/jdk/java/nio/MappedByteBuffer/ForceViews.java b/test/jdk/java/nio/MappedByteBuffer/ForceViews.java index 57ddac28cdf..950b35dc0c3 100644 --- a/test/jdk/java/nio/MappedByteBuffer/ForceViews.java +++ b/test/jdk/java/nio/MappedByteBuffer/ForceViews.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,46 +25,31 @@ * @test * @bug 4833719 * @summary Verify MappedByteBuffer force on compact, duplicate, and slice views - * @run testng ForceViews + * @run junit ForceViews */ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.ReadOnlyBufferException; import java.nio.channels.FileChannel; -import static java.nio.channels.FileChannel.MapMode.*; import java.nio.file.Path; -import static java.nio.file.StandardOpenOption.*; import java.util.function.BiFunction; +import java.util.stream.Stream; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static java.nio.channels.FileChannel.MapMode.*; +import static java.nio.file.StandardOpenOption.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ForceViews { static record Segment(int position, int length) {} - private FileChannel fc; - - @BeforeTest(alwaysRun=true) - public void openChannel() throws IOException { - Path file = Path.of(".", "junk"); - fc = FileChannel.open(file, CREATE_NEW, READ, WRITE, DELETE_ON_CLOSE); - ByteBuffer buf = ByteBuffer.wrap(new byte[1024]); - fc.write(buf); - fc.position(0); - } - - @AfterTest(alwaysRun=true) - public void closeChannel() throws IOException { - fc.close(); - } - - @DataProvider - public Object[][] provider() throws IOException { + public static Stream provider() throws IOException { BiFunction absSlice = (m, s) -> { return m.slice(s.position, s.length); }; BiFunction relSlice = @@ -75,42 +60,47 @@ public class ForceViews { BiFunction compact = (m, s) -> { return m.compact(); }; - Object[][] result = new Object[][] { - {"Absolute slice", fc, 256, 512, 128, 128, 32, 32, absSlice}, - {"Relative slice", fc, 256, 512, 0, 128, 32, 32, relSlice}, - {"Duplicate", fc, 256, 512, 0, 256, 32, 32, duplicate}, - {"Compact", fc, 256, 512, 0, 256, 32, 32, compact} - }; - - return result; + return Stream.of + (Arguments.of("Absolute slice", 256, 512, 128, 128, 32, 32, absSlice), + Arguments.of("Relative slice", 256, 512, 0, 128, 32, 32, relSlice), + Arguments.of("Duplicate", 256, 512, 0, 256, 32, 32, duplicate), + Arguments.of("Compact", 256, 512, 0, 256, 32, 32, compact)); } - @Test(dataProvider = "provider") - public void test(String tst, FileChannel fc, int mapPosition, int mapLength, - int sliceIndex, int sliceLength, int regionOffset, int regionLength, - BiFunction f) + @ParameterizedTest + @MethodSource("provider") + public void test(String tst, int mapPosition, int mapLength, + int sliceIndex, int sliceLength, int regionOffset, + int regionLength, + BiFunction f) throws Exception { - MappedByteBuffer mbb = fc.map(READ_WRITE, mapPosition, mapLength); - mbb = f.apply(mbb, new Segment(sliceIndex, sliceLength)); - for (int i = regionOffset; i < regionOffset + regionLength; i++) { - mbb.put(i, (byte)i); - } - mbb.force(regionOffset, regionOffset + regionLength); - int fcPos = mapPosition + sliceIndex + regionOffset; - int mbbPos = regionOffset; - int length = regionLength; + Path file = Path.of(".", "junk"); + try (FileChannel fc = FileChannel.open(file, CREATE, READ, WRITE, DELETE_ON_CLOSE)) { + fc.write(ByteBuffer.wrap(new byte[1024])); + fc.position(0); - ByteBuffer buf = ByteBuffer.allocate(length); - fc.position(fcPos); - fc.read(buf); - for (int i = 0; i < length; i++) { - int fcVal = buf.get(i); - int mbbVal = mbb.get(mbbPos + i); - int val = regionOffset + i; - Assert.assertTrue(fcVal == val && mbbVal == val, - String.format("%s: i %d, fcVal %d, mbbVal %d, val %d", - tst, i, fcVal, mbbVal, val)); + MappedByteBuffer mbb = fc.map(READ_WRITE, mapPosition, mapLength); + mbb = f.apply(mbb, new Segment(sliceIndex, sliceLength)); + for (int i = regionOffset; i < regionOffset + regionLength; i++) { + mbb.put(i, (byte)i); + } + mbb.force(regionOffset, regionOffset + regionLength); + + int fcPos = mapPosition + sliceIndex + regionOffset; + int mbbPos = regionOffset; + int length = regionLength; + + ByteBuffer buf = ByteBuffer.allocate(length); + fc.position(fcPos); + fc.read(buf); + for (int i = 0; i < length; i++) { + int fcVal = buf.get(i); + int mbbVal = mbb.get(mbbPos + i); + int val = regionOffset + i; + assertEquals(val, fcVal); + assertEquals(val, mbbVal); + } } } } diff --git a/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java b/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java index 7abbf064b40..962d7728a55 100644 --- a/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java +++ b/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +23,7 @@ /* @test * @bug 8202252 - * @run testng CompletionHandlerRelease + * @run junit CompletionHandlerRelease * @summary Verify that reference to CompletionHandler is cleared after use */ @@ -44,10 +44,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; public class CompletionHandlerRelease { @Test @@ -132,16 +134,16 @@ public class CompletionHandlerRelease { } } - private AsynchronousChannelGroup GROUP; + private static AsynchronousChannelGroup GROUP; - @BeforeTest - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { GROUP = AsynchronousChannelGroup.withFixedThreadPool(2, Executors.defaultThreadFactory()); } - @AfterTest - void cleanup() throws IOException { + @AfterAll + static void cleanup() throws IOException { GROUP.shutdownNow(); } @@ -199,13 +201,13 @@ public class CompletionHandlerRelease { } } - private void waitForRefToClear(Reference ref, ReferenceQueue queue) + private static void waitForRefToClear(Reference ref, ReferenceQueue queue) throws InterruptedException { Reference r; while ((r = queue.remove(20)) == null) { System.gc(); } - assertEquals(r, ref); + assertSame(ref, r); assertNull(r.get()); } } diff --git a/test/jdk/java/nio/channels/Channels/EncodingTest.java b/test/jdk/java/nio/channels/Channels/EncodingTest.java index 1f2530ae41b..341439524c1 100644 --- a/test/jdk/java/nio/channels/Channels/EncodingTest.java +++ b/test/jdk/java/nio/channels/Channels/EncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,16 +34,21 @@ import java.nio.charset.Charset; import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @test * @bug 8183743 * @summary Test to verify the new overload method with Charset functions the same * as the existing method that takes a charset name. - * @run testng EncodingTest + * @run junit EncodingTest */ public class EncodingTest { static final int ITERATIONS = 2; @@ -73,53 +78,50 @@ public class EncodingTest { } } - String testFile = Paths.get(USER_DIR, "channelsEncodingTest.txt").toString(); - String testIllegalInput = Paths.get(USER_DIR, "channelsIllegalInputTest.txt").toString(); - String testIllegalOutput = Paths.get(USER_DIR, "channelsIllegalOutputTest.txt").toString(); + static String testFile = Paths.get(USER_DIR, "channelsEncodingTest.txt").toString(); + static String testIllegalInput = Paths.get(USER_DIR, "channelsIllegalInputTest.txt").toString(); + static String testIllegalOutput = Paths.get(USER_DIR, "channelsIllegalOutputTest.txt").toString(); /* * DataProvider for read and write test. * Writes and reads with the same encoding */ - @DataProvider(name = "writeAndRead") - public Object[][] getWRParameters() { - return new Object[][]{ - {testFile, StandardCharsets.ISO_8859_1.name(), null, - StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, - {testFile, null, StandardCharsets.ISO_8859_1, - StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, - {testFile, StandardCharsets.UTF_8.name(), null, - StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, - {testFile, null, StandardCharsets.UTF_8, - StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8} - }; + public static Stream writeAndRead() { + return Stream.of + (Arguments.of(testFile, StandardCharsets.ISO_8859_1.name(), null, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1), + Arguments.of(testFile, null, StandardCharsets.ISO_8859_1, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1), + Arguments.of(testFile, StandardCharsets.UTF_8.name(), null, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8), + Arguments.of(testFile, null, StandardCharsets.UTF_8, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8) + ); } /* * DataProvider for illegal input test * Writes the data in ISO8859 and reads with UTF8, expects MalformedInputException */ - @DataProvider(name = "illegalInput") - public Object[][] getParameters() { - return new Object[][]{ - {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, StandardCharsets.UTF_8.name(), null}, - {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, null, StandardCharsets.UTF_8}, - {testIllegalInput, null, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8.name(), null}, - {testIllegalInput, null, StandardCharsets.ISO_8859_1, null, StandardCharsets.UTF_8}, - }; + public static Stream illegalInput() { + return Stream.of + (Arguments.of(testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, StandardCharsets.UTF_8.name(), null), + Arguments.of(testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, null, StandardCharsets.UTF_8), + Arguments.of(testIllegalInput, null, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8.name(), null), + Arguments.of(testIllegalInput, null, StandardCharsets.ISO_8859_1, null, StandardCharsets.UTF_8) + ); } /* * DataProvider for illegal output test * Attemps to write some malformed chars, expects MalformedInputException */ - @DataProvider(name = "illegalOutput") - public Object[][] getWriteParameters() { - return new Object[][]{ - {testIllegalOutput, StandardCharsets.UTF_8.name(), null}, - {testIllegalOutput, null, StandardCharsets.UTF_8} - }; + public static Stream illegalOutput() { + return Stream.of + (Arguments.of(testIllegalOutput, StandardCharsets.UTF_8.name(), null), + Arguments.of(testIllegalOutput, null, StandardCharsets.UTF_8) + ); } /** @@ -140,7 +142,8 @@ public class EncodingTest { * @param charsetReader the charset for creating the reader * @throws Exception */ - @Test(dataProvider = "writeAndRead") + @ParameterizedTest + @MethodSource("writeAndRead") public void testWriteAndRead(String file, String csnWriter, Charset charsetWriter, String csnReader, Charset charsetReader) throws Exception { writeToFile(data, file, csnWriter, charsetWriter); @@ -148,7 +151,7 @@ public class EncodingTest { String result1 = readFileToString(file, csnReader, null); String result2 = readFileToString(file, null, charsetReader); - Assert.assertEquals(result1, result2); + assertEquals(result1, result2); } /** @@ -162,11 +165,14 @@ public class EncodingTest { * @param charsetReader the charset for creating the reader * @throws Exception */ - @Test(dataProvider = "illegalInput", expectedExceptions = MalformedInputException.class) + @ParameterizedTest + @MethodSource( "illegalInput") void testMalformedInput(String file, String csnWriter, Charset charsetWriter, - String csnReader, Charset charsetReader) throws Exception { + String csnReader, Charset charsetReader) + throws Exception { writeToFile(data, file, csnWriter, charsetWriter); - readFileToString(file, csnReader, charsetReader); + assertThrows(MalformedInputException.class, + () -> readFileToString(file, csnReader, charsetReader)); } /** @@ -178,23 +184,22 @@ public class EncodingTest { * @param charset the charset * @throws Exception */ - @Test(dataProvider = "illegalOutput", expectedExceptions = MalformedInputException.class) + @ParameterizedTest + @MethodSource("illegalOutput") public void testMalformedOutput(String fileName, String csn, Charset charset) - throws Exception { + throws Exception { try (FileOutputStream fos = new FileOutputStream(fileName); - WritableByteChannel wbc = (WritableByteChannel) fos.getChannel();) { - Writer writer; - if (csn != null) { - writer = Channels.newWriter(wbc, csn); - } else { - writer = Channels.newWriter(wbc, charset); - } - - for (int i = 0; i < ITERATIONS; i++) { - writer.write(illChars); - } - writer.flush(); - writer.close(); + WritableByteChannel wbc = (WritableByteChannel) fos.getChannel();) { + Charset cs = (csn != null) ? Charset.forName(csn) : charset; + Writer writer = Channels.newWriter(wbc, cs); + assertThrows(MalformedInputException.class, () -> { + try (writer) { + for (int i = 0; i < ITERATIONS; i++) { + writer.write(illChars); + } + writer.flush(); + } + }); } } diff --git a/test/jdk/java/nio/channels/Channels/ReadXBytes.java b/test/jdk/java/nio/channels/Channels/ReadXBytes.java index 1ea500f355d..4b296bb021e 100644 --- a/test/jdk/java/nio/channels/Channels/ReadXBytes.java +++ b/test/jdk/java/nio/channels/Channels/ReadXBytes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ * @library /test/lib * @build jdk.test.lib.RandomFactory * @modules java.base/jdk.internal.util - * @run testng/othervm/timeout=900 -Xmx12G ReadXBytes + * @run junit/othervm/timeout=900 -Xmx12g ReadXBytes * @key randomness */ import java.io.File; @@ -48,20 +48,24 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Random; +import java.util.stream.IntStream; import jdk.internal.util.ArraysSupport; import static java.nio.file.StandardOpenOption.*; import jdk.test.lib.RandomFactory; -import org.testng.Assert; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ReadXBytes { @@ -193,7 +197,7 @@ public class ReadXBytes { (length, cis) -> { byte[] bytes = cis.readAllBytes(); assertNotNull(bytes); - assertEquals(bytes.length, 0L); + assertEquals(0, bytes.length); } ); } @@ -206,7 +210,7 @@ public class ReadXBytes { cis.skipNBytes(length); byte[] bytes = cis.readAllBytes(); assertNotNull(bytes); - assertEquals(bytes.length, 0); + assertEquals(0, bytes.length); } ); } @@ -218,9 +222,9 @@ public class ReadXBytes { (length, cis, fis) -> { byte[] cisBytes = cis.readAllBytes(); assertNotNull(cisBytes); - assertEquals(cisBytes.length, (long)length); + assertEquals(length, cisBytes.length); byte[] fisBytes = fis.readAllBytes(); - assertEquals(cisBytes, fisBytes); + assertArrayEquals(fisBytes, cisBytes); } ); } @@ -236,20 +240,19 @@ public class ReadXBytes { ); } - // Provides an array of lengths - @DataProvider - public Object[][] lengthProvider() throws IOException { - return new Object[][] { - {1 + RAND.nextInt(1)}, - {1 + RAND.nextInt(Byte.MAX_VALUE)}, - {1 + RAND.nextInt(Short.MAX_VALUE)}, - {1 + RAND.nextInt(1_000_000)}, - {1 + RAND.nextInt(BIG_LENGTH)} - }; + // Provides a stream of lengths + public static IntStream fileLengths() throws IOException { + return IntStream.of + (1 + RAND.nextInt(1), + 1 + RAND.nextInt(Byte.MAX_VALUE), + 1 + RAND.nextInt(Short.MAX_VALUE), + 1 + RAND.nextInt(1_000_000), + 1 + RAND.nextInt(BIG_LENGTH)); } // Verifies readAllBytes() accuracy for random lengths and initial positions - @Test(dataProvider = "lengthProvider") + @ParameterizedTest + @MethodSource("fileLengths") public void readAllBytes(int len) throws IOException { dataTest(len, (length) -> createFileWithRandomContent(length), (length, cis, fis) -> { @@ -257,10 +260,10 @@ public class ReadXBytes { cis.skipNBytes(position); byte[] cisBytes = cis.readAllBytes(); assertNotNull(cisBytes); - assertEquals(cisBytes.length, length - position); + assertEquals(length - position, cisBytes.length); fis.skipNBytes(position); byte[] fisBytes = fis.readAllBytes(); - assertEquals(cisBytes, fisBytes); + assertArrayEquals(fisBytes, cisBytes); } ); } @@ -285,7 +288,7 @@ public class ReadXBytes { (length, cis) -> { byte[] bytes = cis.readNBytes(1); assertNotNull(bytes); - assertEquals(bytes.length, 0); + assertEquals(0, bytes.length); } ); } @@ -298,7 +301,7 @@ public class ReadXBytes { cis.skipNBytes(length); byte[] bytes = cis.readNBytes(1); assertNotNull(bytes); - assertEquals(bytes.length, 0); + assertEquals(0, bytes.length); } ); } @@ -310,9 +313,9 @@ public class ReadXBytes { (length, cis, fis) -> { byte[] cisBytes = cis.readNBytes(BIG_LENGTH); assertNotNull(cisBytes); - assertEquals(cisBytes.length, (long)length); + assertEquals(length, cisBytes.length); byte[] fisBytes = fis.readNBytes(BIG_LENGTH); - assertEquals(cisBytes, fisBytes); + assertArrayEquals(fisBytes, cisBytes); } ); } @@ -327,16 +330,17 @@ public class ReadXBytes { cis.skipNBytes(BIG_LENGTH); byte[] cisBytes = cis.readNBytes(n); assertNotNull(cisBytes); - assertEquals(cisBytes.length, n); + assertEquals(n, cisBytes.length); fis.skipNBytes(BIG_LENGTH); byte[] fisBytes = fis.readNBytes(n); - assertEquals(cisBytes, fisBytes); + assertArrayEquals(fisBytes, cisBytes); } ); } // Verifies readNBytes() accuracy for random lengths and initial positions - @Test(dataProvider = "lengthProvider") + @ParameterizedTest + @MethodSource("fileLengths") public void readNBytes(int len) throws IOException { dataTest(len, (length) -> createFileWithRandomContent(length), (length, cis, fis) -> { @@ -346,10 +350,10 @@ public class ReadXBytes { cis.skipNBytes(position); byte[] cisBytes = cis.readNBytes(n); assertNotNull(cisBytes); - assertEquals(cisBytes.length, n); + assertEquals(n, cisBytes.length); fis.skipNBytes(position); byte[] fisBytes = fis.readNBytes(n); - assertEquals(cisBytes, fisBytes); + assertArrayEquals(fisBytes, cisBytes); } ); } diff --git a/test/jdk/java/nio/channels/Channels/SocketChannelStreams.java b/test/jdk/java/nio/channels/Channels/SocketChannelStreams.java index 519de1e725f..0eab36dc3ee 100644 --- a/test/jdk/java/nio/channels/Channels/SocketChannelStreams.java +++ b/test/jdk/java/nio/channels/Channels/SocketChannelStreams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +25,7 @@ * @bug 8279339 8371718 * @summary Exercise InputStream/OutputStream returned by Channels.newXXXStream * when channel is a SocketChannel - * @run testng SocketChannelStreams + * @run junit SocketChannelStreams */ import java.io.Closeable; @@ -48,101 +48,112 @@ import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.testng.annotations.*; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; -@Test public class SocketChannelStreams { // Maximum size of internal temporary buffer private static final int MAX_BUFFER_SIZE = 128*1024; - private ScheduledExecutorService executor; + private static ScheduledExecutorService executor; - @BeforeClass() - public void init() { + @BeforeAll() + public static void init() { executor = Executors.newSingleThreadScheduledExecutor(); } - @AfterClass - public void finish() { + @AfterAll + public static void finish() { executor.shutdown(); } /** * Test read when bytes are available. */ + @Test public void testRead1() throws Exception { withConnection((sc, peer) -> { write(peer, 99); int n = Channels.newInputStream(sc).read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read blocking before bytes are available. */ + @Test public void testRead2() throws Exception { withConnection((sc, peer) -> { scheduleWrite(peer, 99, 1000); int n = Channels.newInputStream(sc).read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read after peer has closed connection. */ + @Test public void testRead3() throws Exception { withConnection((sc, peer) -> { peer.close(); int n = Channels.newInputStream(sc).read(); - assertEquals(n, -1); + assertEquals(-1, n); }); } /** * Test read blocking before peer closes connection. */ + @Test public void testRead4() throws Exception { withConnection((sc, peer) -> { scheduleClose(peer, 1000); int n = Channels.newInputStream(sc).read(); - assertEquals(n, -1); + assertEquals(-1, n); }); } /** * Test async close of channel when thread blocked in read. */ + @Test public void testRead5() throws Exception { withConnection((sc, peer) -> { scheduleClose(sc, 2000); InputStream in = Channels.newInputStream(sc); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); }); } /** * Test async close of input stream, when thread blocked in read. */ + @Test public void testRead6() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); scheduleClose(in, 2000); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); }); } /** * Test interrupted status set before read. */ + @Test public void testRead7() throws Exception { withConnection((sc, peer) -> { Thread.currentThread().interrupt(); try { InputStream in = Channels.newInputStream(sc); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); } finally { Thread.interrupted(); // clear interrupt } @@ -153,12 +164,13 @@ public class SocketChannelStreams { /** * Test interrupt of thread blocked in read. */ + @Test public void testRead8() throws Exception { withConnection((sc, peer) -> { Future interrupter = scheduleInterrupt(Thread.currentThread(), 2000); try { InputStream in = Channels.newInputStream(sc); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); } finally { interrupter.cancel(true); Thread.interrupted(); // clear interrupt @@ -170,35 +182,38 @@ public class SocketChannelStreams { /** * Test that read is untimed when SO_TIMEOUT is set on the Socket adaptor. */ + @Test public void testRead9() throws Exception { withConnection((sc, peer) -> { sc.socket().setSoTimeout(100); scheduleWrite(peer, 99, 2000); // read should block until bytes are available int b = Channels.newInputStream(sc).read(); - assertTrue(b == 99); + assertEquals(99, b); }); } /** * Test write. */ + @Test public void testWrite1() throws Exception { withConnection((sc, peer) -> { OutputStream out = Channels.newOutputStream(sc); out.write(99); int n = read(peer); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test async close of channel when thread blocked in write. */ + @Test public void testWrite2() throws Exception { withConnection((sc, peer) -> { scheduleClose(sc, 2000); - expectThrows(IOException.class, () -> { + assertThrows(IOException.class, () -> { OutputStream out = Channels.newOutputStream(sc); byte[] data = new byte[64*1000]; while (true) { @@ -211,11 +226,12 @@ public class SocketChannelStreams { /** * Test async close of output stream when thread blocked in write. */ + @Test public void testWrite3() throws Exception { withConnection((sc, peer) -> { OutputStream out = Channels.newOutputStream(sc); scheduleClose(out, 2000); - expectThrows(IOException.class, () -> { + assertThrows(IOException.class, () -> { byte[] data = new byte[64*1000]; while (true) { out.write(data); @@ -227,12 +243,13 @@ public class SocketChannelStreams { /** * Test interrupted status set before write. */ + @Test public void testWrite4() throws Exception { withConnection((sc, peer) -> { Thread.currentThread().interrupt(); try { OutputStream out = Channels.newOutputStream(sc); - expectThrows(IOException.class, () -> out.write(99)); + assertThrows(IOException.class, () -> out.write(99)); } finally { Thread.interrupted(); // clear interrupt } @@ -243,11 +260,12 @@ public class SocketChannelStreams { /** * Test interrupt of thread blocked in write. */ + @Test public void testWrite5() throws Exception { withConnection((sc, peer) -> { Future interrupter = scheduleInterrupt(Thread.currentThread(), 2000); try { - expectThrows(IOException.class, () -> { + assertThrows(IOException.class, () -> { OutputStream out = Channels.newOutputStream(sc); byte[] data = new byte[64*1000]; while (true) { @@ -266,6 +284,7 @@ public class SocketChannelStreams { * Test read when another thread is blocked in write. The read should * complete immediately. */ + @Test public void testConcurrentReadWrite1() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); @@ -283,7 +302,7 @@ public class SocketChannelStreams { // test read, should not be blocked by writer thread write(peer, 99); int n = in.read(); - assertEquals(n, 99); + assertEquals(99, n); }); } @@ -291,6 +310,7 @@ public class SocketChannelStreams { * Test read when another thread is blocked in write. The read should * block until bytes are available. */ + @Test public void testConcurrentReadWrite2() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); @@ -308,13 +328,14 @@ public class SocketChannelStreams { // test read, should not be blocked by writer thread scheduleWrite(peer, 99, 500); int n = in.read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test writing when another thread is blocked in read. */ + @Test public void testConcurrentReadWrite3() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); @@ -329,74 +350,79 @@ public class SocketChannelStreams { // test write, should not be blocked by reader thread out.write(99); int n = read(peer); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read/write when channel configured non-blocking. */ + @Test public void testIllegalBlockingMode() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); OutputStream out = Channels.newOutputStream(sc); sc.configureBlocking(false); - expectThrows(IllegalBlockingModeException.class, () -> in.read()); - expectThrows(IllegalBlockingModeException.class, () -> out.write(99)); + assertThrows(IllegalBlockingModeException.class, () -> in.read()); + assertThrows(IllegalBlockingModeException.class, () -> out.write(99)); }); } /** * Test NullPointerException. */ + @Test public void testNullPointerException() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); OutputStream out = Channels.newOutputStream(sc); - expectThrows(NullPointerException.class, () -> in.read(null)); - expectThrows(NullPointerException.class, () -> in.read(null, 0, 0)); + assertThrows(NullPointerException.class, () -> in.read(null)); + assertThrows(NullPointerException.class, () -> in.read(null, 0, 0)); - expectThrows(NullPointerException.class, () -> out.write(null)); - expectThrows(NullPointerException.class, () -> out.write(null, 0, 0)); + assertThrows(NullPointerException.class, () -> out.write(null)); + assertThrows(NullPointerException.class, () -> out.write(null, 0, 0)); }); } /** * Test IndexOutOfBoundsException. */ + @Test public void testIndexOutOfBoundsException() throws Exception { withConnection((sc, peer) -> { InputStream in = Channels.newInputStream(sc); OutputStream out = Channels.newOutputStream(sc); byte[] ba = new byte[100]; - expectThrows(IndexOutOfBoundsException.class, () -> in.read(ba, -1, 1)); - expectThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 0, -1)); - expectThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 0, 1000)); - expectThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 1, 100)); + assertThrows(IndexOutOfBoundsException.class, () -> in.read(ba, -1, 1)); + assertThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 0, -1)); + assertThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 0, 1000)); + assertThrows(IndexOutOfBoundsException.class, () -> in.read(ba, 1, 100)); - expectThrows(IndexOutOfBoundsException.class, () -> out.write(ba, -1, 1)); - expectThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 0, -1)); - expectThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 0, 1000)); - expectThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 1, 100)); + assertThrows(IndexOutOfBoundsException.class, () -> out.write(ba, -1, 1)); + assertThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 0, -1)); + assertThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 0, 1000)); + assertThrows(IndexOutOfBoundsException.class, () -> out.write(ba, 1, 100)); }); } /** * Test that internal buffers have at most MAX_BUFFER_SIZE bytes remaining. */ + @Test public void testReadLimit() throws IOException { InputStream in = Channels.newInputStream(new TestChannel()); byte[] b = new byte[3*MAX_BUFFER_SIZE]; int n = in.read(b, 0, b.length); - assertEquals(n, MAX_BUFFER_SIZE); + assertEquals(MAX_BUFFER_SIZE, n); } /** * Test that internal buffers have at most MAX_BUFFER_SIZE bytes remaining. */ + @Test public void testWriteLimit() throws IOException { OutputStream out = Channels.newOutputStream(new TestChannel()); byte[] b = new byte[3*MAX_BUFFER_SIZE]; diff --git a/test/jdk/java/nio/channels/Channels/TransferTo.java b/test/jdk/java/nio/channels/Channels/TransferTo.java index b02bf7b3649..a9626978dbe 100644 --- a/test/jdk/java/nio/channels/Channels/TransferTo.java +++ b/test/jdk/java/nio/channels/Channels/TransferTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,17 +37,20 @@ import java.nio.file.Path; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=720 TransferTo + * @run junit/othervm/timeout=720 TransferTo * @bug 8265891 * @summary Tests whether sun.nio.ChannelInputStream.transferTo conforms to the * InputStream.transferTo specification @@ -59,41 +62,37 @@ public class TransferTo extends TransferToBase { * Provides test scenarios, i.e., combinations of input and output streams * to be tested. */ - @DataProvider - public static Object[][] streamCombinations() { - return new Object[][] { - // tests FileChannel.transferTo(FileChannel) optimized case - {fileChannelInput(), fileChannelOutput()}, + public static Stream streamCombinations() { + return Stream.of + (// tests FileChannel.transferTo(FileChannel) optimized case + Arguments.of(fileChannelInput(), fileChannelOutput()), - // tests FileChannel.transferTo(SelectableChannelOutput) - // optimized case - {fileChannelInput(), selectableChannelOutput()}, + // tests FileChannel.transferTo(SelectableChannelOutput) + // optimized case + Arguments.of(fileChannelInput(), selectableChannelOutput()), - // tests FileChannel.transferTo(WritableByteChannelOutput) - // optimized case - {fileChannelInput(), writableByteChannelOutput()}, + // tests FileChannel.transferTo(WritableByteChannelOutput) + // optimized case + Arguments.of(fileChannelInput(), writableByteChannelOutput()), - // tests InputStream.transferTo(OutputStream) default case - {readableByteChannelInput(), defaultOutput()} - }; + // tests InputStream.transferTo(OutputStream) default case + Arguments.of(readableByteChannelInput(), defaultOutput())); } /* * Input streams to be tested. */ - @DataProvider - public static Object[][] inputStreamProviders() { - return new Object[][] { - {fileChannelInput()}, - {readableByteChannelInput()} - }; + public static Stream inputStreamProviders() { + return Stream.of(Arguments.of(fileChannelInput()), + Arguments.of(readableByteChannelInput())); } /* * Testing API compliance: input stream must throw NullPointerException * when parameter "out" is null. */ - @Test(dataProvider = "inputStreamProviders") + @ParameterizedTest + @MethodSource("inputStreamProviders") public void testNullPointerException(InputStreamProvider inputStreamProvider) { assertNullPointerException(inputStreamProvider); } @@ -102,7 +101,8 @@ public class TransferTo extends TransferToBase { * Testing API compliance: complete content of input stream must be * transferred to output stream. */ - @Test(dataProvider = "streamCombinations") + @ParameterizedTest + @MethodSource("streamCombinations") public void testStreamContents(InputStreamProvider inputStreamProvider, OutputStreamProvider outputStreamProvider) throws Exception { assertStreamContents(inputStreamProvider, outputStreamProvider); diff --git a/test/jdk/java/nio/channels/Channels/TransferTo2.java b/test/jdk/java/nio/channels/Channels/TransferTo2.java index bd7e13c3a9b..0e02803c8d3 100644 --- a/test/jdk/java/nio/channels/Channels/TransferTo2.java +++ b/test/jdk/java/nio/channels/Channels/TransferTo2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,11 @@ import java.io.OutputStream; import java.io.IOException; import java.nio.channels.Channels; import java.nio.channels.Pipe; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.lang.String.format; @@ -35,7 +37,7 @@ import static java.lang.String.format; * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=180 TransferTo2 + * @run junit/othervm/timeout=180 TransferTo2 * @bug 8278268 * @summary Tests FileChannel.transferFrom() optimized case * @key randomness @@ -46,33 +48,29 @@ public class TransferTo2 extends TransferToBase { * Provides test scenarios, i.e., combinations of input and output streams * to be tested. */ - @DataProvider - public static Object[][] streamCombinations() { - return new Object[][] { - // tests FileChannel.transferFrom(SelectableChannelOutput) optimized case - {selectableChannelInput(), fileChannelOutput()}, + public static Stream streamCombinations() { + return Stream.of + (// tests FileChannel.transferFrom(SelectableChannelOutput) optimized case + Arguments.of(selectableChannelInput(), fileChannelOutput()), - // tests FileChannel.transferFrom(ReadableByteChannelInput) optimized case - {readableByteChannelInput(), fileChannelOutput()}, - }; + // tests FileChannel.transferFrom(ReadableByteChannelInput) optimized case + Arguments.of(readableByteChannelInput(), fileChannelOutput())); } /* * Input streams to be tested. */ - @DataProvider - public static Object[][] inputStreamProviders() { - return new Object[][] { - {selectableChannelInput()}, - {readableByteChannelInput()} - }; + public static Stream inputStreamProviders() { + return Stream.of(Arguments.of(selectableChannelInput()), + Arguments.of(readableByteChannelInput())); } /* * Testing API compliance: input stream must throw NullPointerException * when parameter "out" is null. */ - @Test(dataProvider = "inputStreamProviders") + @ParameterizedTest + @MethodSource("inputStreamProviders") public void testNullPointerException(InputStreamProvider inputStreamProvider) { assertNullPointerException(inputStreamProvider); } @@ -81,7 +79,8 @@ public class TransferTo2 extends TransferToBase { * Testing API compliance: complete content of input stream must be * transferred to output stream. */ - @Test(dataProvider = "streamCombinations") + @ParameterizedTest + @MethodSource("streamCombinations") public void testStreamContents(InputStreamProvider inputStreamProvider, OutputStreamProvider outputStreamProvider) throws Exception { assertStreamContents(inputStreamProvider, outputStreamProvider); diff --git a/test/jdk/java/nio/channels/Channels/TransferToBase.java b/test/jdk/java/nio/channels/Channels/TransferToBase.java index 53ca283ae78..482fb1f262c 100644 --- a/test/jdk/java/nio/channels/Channels/TransferToBase.java +++ b/test/jdk/java/nio/channels/Channels/TransferToBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,9 +43,9 @@ import jdk.test.lib.RandomFactory; import static java.lang.String.format; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; class TransferToBase { static final int MIN_SIZE = 10_000; @@ -88,7 +88,7 @@ class TransferToBase { long reported = in.transferTo(out); int count = inBytes.length - posIn; - assertEquals(reported, count, format("reported %d bytes but should report %d", reported, count)); + assertEquals(count, reported); byte[] outBytes = recorder.get().get(); assertTrue(Arrays.equals(inBytes, posIn, posIn + count, outBytes, posOut, posOut + count), @@ -238,11 +238,11 @@ class TransferToBase { // compare reported transferred bytes, must be 3 GB // less the value of the initial position - assertEquals(count, BYTES_WRITTEN - initPos); + assertEquals(BYTES_WRITTEN - initPos, count); } // compare content of both files, failing if different - assertEquals(Files.mismatch(sourceFile, targetFile), -1); + assertEquals(-1, Files.mismatch(sourceFile, targetFile)); } finally { Files.delete(targetFile); diff --git a/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferFrom.java b/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferFrom.java index f57d6cca963..1dc17f6f5fc 100644 --- a/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferFrom.java +++ b/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferFrom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,13 +30,13 @@ import java.nio.file.Files; import static java.nio.file.StandardOpenOption.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=720 TransferTo_2GB_transferFrom + * @run junit/othervm/timeout=720 TransferTo_2GB_transferFrom * @bug 8278268 * @summary Tests if ChannelInputStream.transferFrom correctly * transfers 2GB+ using FileChannel.transferFrom(ReadableByteChannel). diff --git a/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferTo.java b/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferTo.java index fdd3bddb126..174b89bd988 100644 --- a/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferTo.java +++ b/test/jdk/java/nio/channels/Channels/TransferTo_2GB_transferTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,13 +29,13 @@ import java.nio.file.Files; import static java.nio.file.StandardOpenOption.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /* * @test * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/othervm/timeout=720 TransferTo_2GB_transferTo + * @run junit/othervm/timeout=720 TransferTo_2GB_transferTo * @bug 8265891 * @summary Tests if ChannelInputStream.transferTo correctly * transfers 2GB+ using FileChannel.transferTo(WritableByteChannel). diff --git a/test/jdk/java/nio/channels/DatagramChannel/AdaptorConnect.java b/test/jdk/java/nio/channels/DatagramChannel/AdaptorConnect.java index a609089e459..bf6b9023eb4 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/AdaptorConnect.java +++ b/test/jdk/java/nio/channels/DatagramChannel/AdaptorConnect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 8232673 * @summary Test DatagramChannel socket adaptor connect method with illegal args - * @run testng AdaptorConnect + * @run junit AdaptorConnect */ import java.net.DatagramSocket; @@ -34,10 +34,9 @@ import java.net.SocketException; import java.nio.channels.DatagramChannel; import static java.net.InetAddress.getLoopbackAddress; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; -@Test public class AdaptorConnect { /** @@ -59,6 +58,7 @@ public class AdaptorConnect { /** * Test connect method with an open socket. */ + @Test public void testOpenSocket() throws Exception { try (DatagramChannel dc = DatagramChannel.open()) { DatagramSocket s = dc.socket(); @@ -66,42 +66,43 @@ public class AdaptorConnect { testConnectWithIllegalArguments(s); // should not be bound or connected - assertTrue(s.getLocalSocketAddress() == null); - assertTrue(s.getRemoteSocketAddress() == null); + assertNull(s.getLocalSocketAddress()); + assertNull(s.getRemoteSocketAddress()); // connect(SocketAddress) var remote1 = new InetSocketAddress(getLoopbackAddress(), 7001); s.connect(remote1); - assertEquals(s.getRemoteSocketAddress(), remote1); + assertEquals(remote1, s.getRemoteSocketAddress()); testConnectWithIllegalArguments(s); - assertEquals(s.getRemoteSocketAddress(), remote1); + assertEquals(remote1, s.getRemoteSocketAddress()); // connect(SocketAddress) var remote2 = new InetSocketAddress(getLoopbackAddress(), 7002); s.connect(remote2); - assertEquals(s.getRemoteSocketAddress(), remote2); + assertEquals(remote2, s.getRemoteSocketAddress()); testConnectWithIllegalArguments(s); - assertEquals(s.getRemoteSocketAddress(), remote2); + assertEquals(remote2, s.getRemoteSocketAddress()); // connect(InetAddress, int) var remote3 = new InetSocketAddress(getLoopbackAddress(), 7003); s.connect(remote3.getAddress(), remote3.getPort()); - assertEquals(s.getRemoteSocketAddress(), remote3); + assertEquals(remote3, s.getRemoteSocketAddress()); testConnectWithIllegalArguments(s); - assertEquals(s.getRemoteSocketAddress(), remote3); + assertEquals(remote3, s.getRemoteSocketAddress()); // connect(InetAddress, int) var remote4 = new InetSocketAddress(getLoopbackAddress(), 7004); s.connect(remote4.getAddress(), remote4.getPort()); - assertEquals(s.getRemoteSocketAddress(), remote4); + assertEquals(remote4, s.getRemoteSocketAddress()); testConnectWithIllegalArguments(s); - assertEquals(s.getRemoteSocketAddress(), remote4); + assertEquals(remote4, s.getRemoteSocketAddress()); } } /** * Test connect method with a closed socket. */ + @Test public void testClosedSocket() throws Exception { DatagramChannel dc = DatagramChannel.open(); DatagramSocket s = dc.socket(); diff --git a/test/jdk/java/nio/channels/DatagramChannel/AdaptorGetters.java b/test/jdk/java/nio/channels/DatagramChannel/AdaptorGetters.java index 9e12f46be04..69f5a76c12d 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/AdaptorGetters.java +++ b/test/jdk/java/nio/channels/DatagramChannel/AdaptorGetters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 8232673 * @summary Test the DatagramChannel socket adaptor getter methods - * @run testng AdaptorGetters + * @run junit AdaptorGetters */ import java.net.DatagramSocket; @@ -32,15 +32,15 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.DatagramChannel; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; -@Test public class AdaptorGetters { /** * Test getters on unbound socket, before and after it is closed. */ + @Test public void testUnboundSocket() throws Exception { DatagramChannel dc = DatagramChannel.open(); DatagramSocket s = dc.socket(); @@ -53,12 +53,12 @@ public class AdaptorGetters { // local address assertTrue(s.getLocalAddress().isAnyLocalAddress()); - assertTrue(s.getLocalPort() == 0); - assertTrue(s.getLocalSocketAddress() == null); + assertEquals(0, s.getLocalPort()); + assertNull(s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); } finally { dc.close(); @@ -70,19 +70,20 @@ public class AdaptorGetters { assertTrue(s.isClosed()); // local address - assertTrue(s.getLocalAddress() == null); - assertTrue(s.getLocalPort() == -1); - assertTrue(s.getLocalSocketAddress() == null); + assertNull(s.getLocalAddress()); + assertEquals(-1, s.getLocalPort()); + assertNull(s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); - assertTrue((s.getRemoteSocketAddress() == null)); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); + assertNull(s.getRemoteSocketAddress()); } /** * Test getters on bound socket, before and after it is closed. */ + @Test public void testBoundSocket() throws Exception { DatagramChannel dc = DatagramChannel.open(); DatagramSocket s = dc.socket(); @@ -96,14 +97,14 @@ public class AdaptorGetters { assertFalse(s.isClosed()); // local address - assertEquals(s.getLocalAddress(), localAddress.getAddress()); - assertTrue(s.getLocalPort() == localAddress.getPort()); - assertEquals(s.getLocalSocketAddress(), localAddress); + assertEquals(localAddress.getAddress(), s.getLocalAddress()); + assertEquals(localAddress.getPort(), s.getLocalPort()); + assertEquals(localAddress, s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); - assertTrue((s.getRemoteSocketAddress() == null)); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); + assertNull(s.getRemoteSocketAddress()); } finally { dc.close(); @@ -115,19 +116,20 @@ public class AdaptorGetters { assertTrue(s.isClosed()); // local address - assertTrue(s.getLocalAddress() == null); - assertTrue(s.getLocalPort() == -1); - assertTrue(s.getLocalSocketAddress() == null); + assertNull(s.getLocalAddress()); + assertEquals(-1, s.getLocalPort()); + assertNull(s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); - assertTrue((s.getRemoteSocketAddress() == null)); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); + assertNull(s.getRemoteSocketAddress()); } /** * Test getters on connected socket, before and after it is closed. */ + @Test public void testConnectedSocket() throws Exception { var loopback = InetAddress.getLoopbackAddress(); var remoteAddress = new InetSocketAddress(loopback, 7777); @@ -143,14 +145,14 @@ public class AdaptorGetters { assertFalse(s.isClosed()); // local address - assertEquals(s.getLocalAddress(), localAddress.getAddress()); - assertTrue(s.getLocalPort() == localAddress.getPort()); - assertEquals(s.getLocalSocketAddress(), localAddress); + assertEquals(localAddress.getAddress(), s.getLocalAddress()); + assertEquals(localAddress.getPort(), s.getLocalPort()); + assertEquals(localAddress, s.getLocalSocketAddress()); // remote address - assertEquals(s.getInetAddress(), remoteAddress.getAddress()); - assertTrue(s.getPort() == remoteAddress.getPort()); - assertEquals(s.getRemoteSocketAddress(), remoteAddress); + assertEquals(remoteAddress.getAddress(), s.getInetAddress()); + assertEquals(remoteAddress.getPort(), s.getPort()); + assertEquals(remoteAddress, s.getRemoteSocketAddress()); } finally { dc.close(); @@ -162,19 +164,20 @@ public class AdaptorGetters { assertTrue(s.isClosed()); // local address - assertTrue(s.getLocalAddress() == null); - assertTrue(s.getLocalPort() == -1); - assertTrue(s.getLocalSocketAddress() == null); + assertNull(s.getLocalAddress()); + assertEquals(-1, s.getLocalPort()); + assertNull(s.getLocalSocketAddress()); // remote address - assertEquals(s.getInetAddress(), remoteAddress.getAddress()); - assertTrue(s.getPort() == remoteAddress.getPort()); - assertEquals(s.getRemoteSocketAddress(), remoteAddress); + assertEquals(remoteAddress.getAddress(), s.getInetAddress()); + assertEquals(remoteAddress.getPort(), s.getPort()); + assertEquals(remoteAddress, s.getRemoteSocketAddress()); } /** * Test getters on disconnected socket, before and after it is closed. */ + @Test public void testDisconnectedSocket() throws Exception { DatagramChannel dc = DatagramChannel.open(); DatagramSocket s = dc.socket(); @@ -191,14 +194,14 @@ public class AdaptorGetters { assertFalse(s.isClosed()); // local address - assertEquals(s.getLocalAddress(), localAddress.getAddress()); - assertTrue(s.getLocalPort() == localAddress.getPort()); - assertEquals(s.getLocalSocketAddress(), localAddress); + assertEquals(localAddress.getAddress(), s.getLocalAddress()); + assertEquals(localAddress.getPort(), s.getLocalPort()); + assertEquals(localAddress, s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); - assertTrue((s.getRemoteSocketAddress() == null)); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); + assertNull(s.getRemoteSocketAddress()); } finally { @@ -211,13 +214,13 @@ public class AdaptorGetters { assertTrue(s.isClosed()); // local address - assertTrue(s.getLocalAddress() == null); - assertTrue(s.getLocalPort() == -1); - assertTrue(s.getLocalSocketAddress() == null); + assertNull(s.getLocalAddress()); + assertEquals(-1, s.getLocalPort()); + assertNull(s.getLocalSocketAddress()); // remote address - assertTrue(s.getInetAddress() == null); - assertTrue(s.getPort() == -1); - assertTrue((s.getRemoteSocketAddress() == null)); + assertNull(s.getInetAddress()); + assertEquals(-1, s.getPort()); + assertNull(s.getRemoteSocketAddress()); } } diff --git a/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java b/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java index de59984dae1..44a34ea3e55 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java +++ b/test/jdk/java/nio/channels/DatagramChannel/AfterDisconnect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,9 @@ * @bug 8231880 8231258 * @library /test/lib * @summary Test DatagramChannel bound to specific address/ephemeral port after disconnect - * @run testng/othervm AfterDisconnect - * @run testng/othervm -Djava.net.preferIPv4Stack=true AfterDisconnect - * @run testng/othervm -Djava.net.preferIPv6Addresses=true AfterDisconnect + * @run junit/othervm AfterDisconnect + * @run junit/othervm -Djava.net.preferIPv4Stack=true AfterDisconnect + * @run junit/othervm -Djava.net.preferIPv6Addresses=true AfterDisconnect */ import java.io.IOException; @@ -49,15 +49,17 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; -import org.testng.annotations.Test; -import static org.testng.Assert.*; - import jdk.test.lib.net.IPSupport; +import org.junit.jupiter.api.Test; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; + public class AfterDisconnect { interface RetryableTest { - public void runTest() throws T; + void runTest() throws T; } // retry the given lambda (RetryableTest) if an exception @@ -81,7 +83,7 @@ public class AfterDisconnect { * When calling {@link DatagramChannel#disconnect()} a {@link BindException} * may occur. In which case we want to retry the test. */ - class BindExceptionOnDisconnect extends BindException { + static class BindExceptionOnDisconnect extends BindException { BindExceptionOnDisconnect(BindException x) { super(x.getMessage()); initCause(x); @@ -149,8 +151,8 @@ public class AfterDisconnect { dc.connect(remote); assertTrue(dc.isConnected()); - assertEquals(dc.getLocalAddress(), local); - assertEquals(dc.getRemoteAddress(), remote); + assertEquals(local, dc.getLocalAddress()); + assertEquals(remote, dc.getRemoteAddress()); try { dc.disconnect(); @@ -158,8 +160,8 @@ public class AfterDisconnect { throw new BindExceptionOnDisconnect(x); } assertFalse(dc.isConnected()); - assertEquals(dc.getLocalAddress(), local); - assertTrue(dc.getRemoteAddress() == null); + assertEquals(local, dc.getLocalAddress()); + assertNull(dc.getRemoteAddress()); } } @@ -192,7 +194,7 @@ public class AfterDisconnect { /** * Returns a map of the given channel's socket options and values. */ - private Map, Object> options(DatagramChannel dc) throws IOException { + private Map, Object> options(DatagramChannel dc) { Map, Object> map = new HashMap<>(); for (SocketOption option : dc.supportedOptions()) { try { @@ -229,15 +231,15 @@ public class AfterDisconnect { // check blocking mode with non-blocking receive ByteBuffer bb = ByteBuffer.allocate(100); SocketAddress sender = dc.receive(bb); - assertTrue(sender == null); + assertNull(sender); // send datagram and ensure that channel is selected - dc.send(ByteBuffer.wrap("Hello".getBytes("UTF-8")), dc.getLocalAddress()); + dc.send(ByteBuffer.wrap("Hello".getBytes(UTF_8)), dc.getLocalAddress()); assertFalse(key.isReadable()); while (sel.select() == 0); assertTrue(key.isReadable()); sender = dc.receive(bb); - assertEquals(sender, dc.getLocalAddress()); + assertEquals(dc.getLocalAddress(), sender); // cancel key, flush from Selector, and restore blocking mode key.cancel(); @@ -273,10 +275,10 @@ public class AfterDisconnect { assertTrue(key.isValid()); // send datagram to multicast group, should be received - dc.send(ByteBuffer.wrap("Hello".getBytes("UTF-8")), dc.getLocalAddress()); + dc.send(ByteBuffer.wrap("Hello".getBytes(UTF_8)), dc.getLocalAddress()); ByteBuffer bb = ByteBuffer.allocate(100); SocketAddress sender = dc.receive(bb); - assertEquals(sender, dc.getLocalAddress()); + assertEquals(dc.getLocalAddress(), sender); // drop membership key.drop(); diff --git a/test/jdk/java/nio/channels/DatagramChannel/ConnectExceptions.java b/test/jdk/java/nio/channels/DatagramChannel/ConnectExceptions.java index a913f1f42e9..a89c4798c08 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/ConnectExceptions.java +++ b/test/jdk/java/nio/channels/DatagramChannel/ConnectExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,26 +25,32 @@ * @bug 8198753 * @summary Test DatagramChannel connect exceptions * @library .. - * @run testng ConnectExceptions + * @run junit ConnectExceptions */ -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.channels.AlreadyConnectedException; +import java.nio.channels.DatagramChannel; +import java.nio.channels.UnresolvedAddressException; +import java.nio.channels.UnsupportedAddressTypeException; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class ConnectExceptions { - static DatagramChannel sndChannel; - static DatagramChannel rcvChannel; - static InetSocketAddress sender; - static InetSocketAddress receiver; + private DatagramChannel sndChannel; + private DatagramChannel rcvChannel; + private InetSocketAddress sender; + private InetSocketAddress receiver; - @BeforeTest - public static void setup() throws Exception { + @BeforeEach + public void setup() throws Exception { sndChannel = DatagramChannel.open(); sndChannel.bind(null); InetAddress address = InetAddress.getLocalHost(); @@ -60,29 +66,40 @@ public class ConnectExceptions { rcvChannel.socket().getLocalPort()); } - @Test(expectedExceptions = UnsupportedAddressTypeException.class) - public static void unsupportedAddressTypeException() throws Exception { - rcvChannel.connect(sender); - sndChannel.connect(new SocketAddress() {}); - } - - @Test(expectedExceptions = UnresolvedAddressException.class) - public static void unresolvedAddressException() throws Exception { - String host = TestUtil.UNRESOLVABLE_HOST; - InetSocketAddress unresolvable = new InetSocketAddress (host, 37); - sndChannel.connect(unresolvable); - } - - @Test(expectedExceptions = AlreadyConnectedException.class) - public static void alreadyConnectedException() throws Exception { - sndChannel.connect(receiver); - InetSocketAddress random = new InetSocketAddress(0); - sndChannel.connect(random); - } - - @AfterTest - public static void cleanup() throws Exception { + @AfterEach + public void cleanup() throws Exception { rcvChannel.close(); sndChannel.close(); } + + @Test + public void unsupportedAddressTypeException() throws IOException { + rcvChannel.connect(sender); + assertThrows(UnsupportedAddressTypeException.class, () -> { + sndChannel.connect(new SocketAddress() {}); + }); + } + + @Test + public void unresolvedAddressException() throws IOException { + String host = TestUtil.UNRESOLVABLE_HOST; + InetSocketAddress unresolvable = new InetSocketAddress (host, 37); + assertThrows(UnresolvedAddressException.class, () -> { + sndChannel.connect(unresolvable); + }); + sndChannel.connect(receiver); + assertThrows(UnresolvedAddressException.class, () -> { + sndChannel.connect(unresolvable); + }); + } + + @Test + public void alreadyConnectedException() throws IOException { + sndChannel.connect(receiver); + assertThrows(AlreadyConnectedException.class, () -> { + InetSocketAddress random = new InetSocketAddress(0); + sndChannel.connect(random); + }); + } + } diff --git a/test/jdk/java/nio/channels/DatagramChannel/ConnectPortZero.java b/test/jdk/java/nio/channels/DatagramChannel/ConnectPortZero.java index 4aa28e5226e..3ddad9ef526 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/ConnectPortZero.java +++ b/test/jdk/java/nio/channels/DatagramChannel/ConnectPortZero.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,10 +21,6 @@ * questions. */ -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.InetAddress; @@ -38,7 +34,15 @@ import static jdk.test.lib.net.IPSupport.hasIPv6; import static jdk.test.lib.net.IPSupport.hasIPv4; import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; -import static org.testng.Assert.assertThrows; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +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 @@ -46,51 +50,54 @@ import static org.testng.Assert.assertThrows; * @library /test/lib * @build jdk.test.lib.net.IPSupport * @summary Check that DatagramChannel throws expected Exception when connecting to port 0 - * @run testng ConnectPortZero - * @run testng/othervm -Djava.net.preferIPv4Stack=true ConnectPortZero + * @run junit ConnectPortZero + * @run junit/othervm -Djava.net.preferIPv4Stack=true ConnectPortZero */ public class ConnectPortZero { - private InetSocketAddress loopbackZeroAddr, wildcardZeroAddr; - private DatagramChannel datagramChannel, datagramChannelIPv4, datagramChannelIPv6; - private List channels; + private static InetSocketAddress loopbackZeroAddr, wildcardZeroAddr; + private static DatagramChannel datagramChannel, datagramChannelIPv4, datagramChannelIPv6; + private static List channels; private static final Class SE = SocketException.class; - @BeforeTest - public void setUp() throws IOException { + @BeforeAll + public static void setUp() throws IOException { wildcardZeroAddr = new InetSocketAddress(0); loopbackZeroAddr = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); channels = new ArrayList<>(); datagramChannel = DatagramChannel.open(); - channels.add(new Object[]{datagramChannel}); + channels.add(datagramChannel); if (hasIPv4()) { datagramChannelIPv4 = DatagramChannel.open(INET); - channels.add(new Object[]{datagramChannelIPv4}); + channels.add(datagramChannelIPv4); } if (hasIPv6()) { datagramChannelIPv6 = DatagramChannel.open(INET6); - channels.add(new Object[]{datagramChannelIPv6}); + channels.add(datagramChannelIPv6); } } - @DataProvider(name = "data") - public Object[][] variants() { - return channels.toArray(Object[][]::new); + @AfterAll + public static void tearDown() throws IOException { + for(DatagramChannel ch : channels) { + ch.close(); + } } - @Test(dataProvider = "data") + public static List channels() { + return channels; + } + + @ParameterizedTest + @MethodSource("channels") public void testChannelConnect(DatagramChannel dc) { + assertTrue(dc.isOpen()); + assertFalse(dc.isConnected()); assertThrows(SE, () -> dc.connect(loopbackZeroAddr)); assertThrows(SE, () -> dc.connect(wildcardZeroAddr)); } - @AfterTest - public void tearDown() throws IOException { - for(Object[] ch : channels) { - ((DatagramChannel)ch[0]).close(); - } - } } diff --git a/test/jdk/java/nio/channels/DatagramChannel/ConnectedSend.java b/test/jdk/java/nio/channels/DatagramChannel/ConnectedSend.java index d761f8db3f0..78e5a37294f 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/ConnectedSend.java +++ b/test/jdk/java/nio/channels/DatagramChannel/ConnectedSend.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,23 +25,27 @@ * @bug 4849277 7183800 * @summary Test DatagramChannel send while connected * @library .. - * @run testng ConnectedSend + * @run junit ConnectedSend * @author Mike McCloskey */ -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.charset.*; -import org.testng.annotations.Test; -import static org.testng.Assert.*; + +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.channels.DatagramChannel; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class ConnectedSend { // Check if DatagramChannel.send while connected can include // address without throwing @Test - public static void sendToConnectedAddress() throws Exception { + public void sendToConnectedAddress() throws Exception { DatagramChannel sndChannel = DatagramChannel.open(); sndChannel.bind(null); InetAddress address = InetAddress.getLocalHost(); @@ -68,7 +72,7 @@ public class ConnectedSend { bb.clear(); rcvChannel.receive(bb); bb.flip(); - CharBuffer cb = Charset.forName("US-ASCII").newDecoder().decode(bb); + CharBuffer cb = StandardCharsets.US_ASCII.newDecoder().decode(bb); assertTrue(cb.toString().startsWith("h"), "Unexpected message content"); rcvChannel.close(); @@ -79,7 +83,7 @@ public class ConnectedSend { // that has not been initialized with an address; the legacy // datagram socket will send in this case @Test - public static void sendAddressedPacket() throws Exception { + public void sendAddressedPacket() throws Exception { DatagramChannel sndChannel = DatagramChannel.open(); sndChannel.bind(null); InetAddress address = InetAddress.getLocalHost(); @@ -99,19 +103,19 @@ public class ConnectedSend { rcvChannel.connect(sender); sndChannel.connect(receiver); - byte b[] = "hello".getBytes("UTF-8"); + byte[] b = "hello".getBytes(StandardCharsets.UTF_8); DatagramPacket pkt = new DatagramPacket(b, b.length); sndChannel.socket().send(pkt); ByteBuffer bb = ByteBuffer.allocate(256); rcvChannel.receive(bb); bb.flip(); - CharBuffer cb = Charset.forName("US-ASCII").newDecoder().decode(bb); + CharBuffer cb = StandardCharsets.US_ASCII.newDecoder().decode(bb); assertTrue(cb.toString().startsWith("h"), "Unexpected message content"); // Check that the pkt got set with the target address; // This is legacy behavior - assertEquals(pkt.getSocketAddress(), receiver, + assertEquals(receiver, pkt.getSocketAddress(), "Unexpected address set on packet"); rcvChannel.close(); diff --git a/test/jdk/java/nio/channels/DatagramChannel/SRTest.java b/test/jdk/java/nio/channels/DatagramChannel/SRTest.java index 9a7309cc46e..5ad66e6cdff 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SRTest.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SRTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,13 +23,19 @@ /* @test * @summary Test DatagramChannel's send and receive methods - * @run testng/othervm/timeout=20 SRTest + * @run junit/othervm SRTest */ -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.io.IOException; +import java.io.PrintStream; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketException; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.channels.DatagramChannel; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutorService; @@ -37,22 +43,24 @@ import java.util.concurrent.Executors; import java.util.stream.Stream; import static java.nio.charset.StandardCharsets.US_ASCII; -import org.testng.annotations.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class SRTest { - ExecutorService executorService; + static ExecutorService executorService; static PrintStream log = System.err; static final String DATA_STRING = "hello"; - @BeforeClass - public void beforeClass() { + @BeforeAll + public static void beforeClass() { executorService = Executors.newCachedThreadPool(); } - @AfterClass - public void afterClass() { + @AfterAll + public static void afterClass() { executorService.shutdown(); } diff --git a/test/jdk/java/nio/channels/DatagramChannel/SendExceptions.java b/test/jdk/java/nio/channels/DatagramChannel/SendExceptions.java index 343ab1b8232..94508f9b6e2 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SendExceptions.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SendExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,27 +25,34 @@ * @bug 4675045 8198753 * @summary Test DatagramChannel send exceptions * @library .. - * @run testng SendExceptions + * @run junit SendExceptions */ -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.AlreadyConnectedException; +import java.nio.channels.DatagramChannel; +import java.nio.channels.UnresolvedAddressException; +import java.nio.channels.UnsupportedAddressTypeException; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class SendExceptions { - static DatagramChannel sndChannel; - static DatagramChannel rcvChannel; - static InetSocketAddress sender; - static InetSocketAddress receiver; - static ByteBuffer buf = ByteBuffer.allocate(17); + private DatagramChannel sndChannel; + private DatagramChannel rcvChannel; + private InetSocketAddress sender; + private InetSocketAddress receiver; + static final ByteBuffer buf = ByteBuffer.allocate(17); - @BeforeTest - public static void setup() throws Exception { + @BeforeEach + public void setup() throws Exception { + buf.rewind(); sndChannel = DatagramChannel.open(); sndChannel.bind(null); InetAddress address = InetAddress.getLocalHost(); @@ -61,29 +68,43 @@ public class SendExceptions { rcvChannel.socket().getLocalPort()); } - @Test(expectedExceptions = UnsupportedAddressTypeException.class) - public static void unsupportedAddressTypeException() throws Exception { - rcvChannel.connect(sender); - sndChannel.send(buf, new SocketAddress() {}); - } - - @Test(expectedExceptions = UnresolvedAddressException.class) - public static void unresolvedAddressException() throws Exception { - String host = TestUtil.UNRESOLVABLE_HOST; - InetSocketAddress unresolvable = new InetSocketAddress (host, 37); - sndChannel.send(buf, unresolvable); - } - - @Test(expectedExceptions = AlreadyConnectedException.class) - public static void alreadyConnectedException() throws Exception { - sndChannel.connect(receiver); - InetSocketAddress random = new InetSocketAddress(0); - sndChannel.send(buf, random); - } - - @AfterTest - public static void cleanup() throws Exception { + @AfterEach + public void cleanup() throws Exception { rcvChannel.close(); sndChannel.close(); } + + @Test + public void unsupportedAddressTypeException() throws IOException { + assertThrows(UnsupportedAddressTypeException.class, () -> { + sndChannel.send(buf, new SocketAddress() {}); + }); + rcvChannel.connect(sender); + assertThrows(UnsupportedAddressTypeException.class, () -> { + sndChannel.send(buf, new SocketAddress() {}); + }); + sndChannel.connect(receiver); + assertThrows(UnsupportedAddressTypeException.class, () -> { + sndChannel.send(buf, new SocketAddress() {}); + }); + } + + @Test + public void unresolvedAddressException() { + String host = TestUtil.UNRESOLVABLE_HOST; + InetSocketAddress unresolvable = new InetSocketAddress (host, 37); + assertThrows(UnresolvedAddressException.class, () -> { + sndChannel.send(buf, unresolvable); + }); + } + + @Test + public void alreadyConnectedException() throws IOException { + sndChannel.connect(receiver); + InetSocketAddress random = new InetSocketAddress(0); + assertThrows(AlreadyConnectedException.class, () -> { + sndChannel.send(buf, random); + }); + } + } diff --git a/test/jdk/java/nio/channels/DatagramChannel/SendPortZero.java b/test/jdk/java/nio/channels/DatagramChannel/SendPortZero.java index 6a8b9f24d41..9733dad83f8 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SendPortZero.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SendPortZero.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,11 +21,6 @@ * questions. */ -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -39,7 +34,13 @@ import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static jdk.test.lib.net.IPSupport.hasIPv4; import static jdk.test.lib.net.IPSupport.hasIPv6; -import static org.testng.Assert.assertThrows; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test @@ -47,20 +48,20 @@ import static org.testng.Assert.assertThrows; * @library /test/lib * @build jdk.test.lib.net.IPSupport * @summary Check that DatagramChannel throws expected Exception when sending to port 0 - * @run testng/othervm SendPortZero - * @run testng/othervm -Djava.net.preferIPv4Stack=true SendPortZero + * @run junit/othervm SendPortZero + * @run junit/othervm -Djava.net.preferIPv4Stack=true SendPortZero */ public class SendPortZero { - private ByteBuffer buf; - private List channels; - private InetSocketAddress loopbackZeroAddr, wildcardZeroAddr; - private DatagramChannel datagramChannel, datagramChannelIPv4, datagramChannelIPv6; + private static ByteBuffer buf; + private static List channels; + private static InetSocketAddress loopbackZeroAddr, wildcardZeroAddr; + private static DatagramChannel datagramChannel, datagramChannelIPv4, datagramChannelIPv6; private static final Class SE = SocketException.class; - @BeforeTest - public void setUp() throws IOException { + @BeforeAll + public static void setUp() throws IOException { buf = ByteBuffer.wrap("test".getBytes()); wildcardZeroAddr = new InetSocketAddress(0); @@ -69,32 +70,34 @@ public class SendPortZero { channels = new ArrayList<>(); datagramChannel = DatagramChannel.open(); - channels.add(new Object[]{datagramChannel}); + channels.add(datagramChannel); if (hasIPv4()) { datagramChannelIPv4 = DatagramChannel.open(INET); - channels.add(new Object[]{datagramChannelIPv4}); + channels.add(datagramChannelIPv4); } if (hasIPv6()) { datagramChannelIPv6 = DatagramChannel.open(INET6); - channels.add(new Object[]{datagramChannelIPv6}); + channels.add(datagramChannelIPv6); } } - @DataProvider(name = "data") - public Object[][] variants() { - return channels.toArray(Object[][]::new); + @AfterAll + public static void tearDown() throws IOException { + for(DatagramChannel ch : channels) { + ch.close(); + } } - @Test(dataProvider = "data") + public static List channels() { + return channels; + } + + @ParameterizedTest + @MethodSource("channels") public void testChannelSend(DatagramChannel dc) { + assertTrue(dc.isOpen()); assertThrows(SE, () -> dc.send(buf, loopbackZeroAddr)); assertThrows(SE, () -> dc.send(buf, wildcardZeroAddr)); } - @AfterTest - public void tearDown() throws IOException { - for(Object[] ch : channels) { - ((DatagramChannel)ch[0]).close(); - } - } } diff --git a/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java b/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java index 8d74fd8a387..cb6e66dd5de 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SendReceiveMaxSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,25 +22,49 @@ */ /* - * @test + * @test id=default * @bug 8239355 8242885 8240901 * @key randomness * @summary Check that it is possible to send and receive datagrams of * maximum size on macOS. * @library /test/lib * @build jdk.test.lib.net.IPSupport - * @run testng/othervm SendReceiveMaxSize - * @run testng/othervm -Djava.net.preferIPv4Stack=true SendReceiveMaxSize + * @run junit/othervm SendReceiveMaxSize + */ +/* + * @test id=preferIPv4Stack + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using an IPv4 only socket. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run junit/othervm -Djava.net.preferIPv4Stack=true SendReceiveMaxSize + */ +/* + * @test id=preferIPv6Loopback + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using a dual socket and the loopback + * interface. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run junit/othervm -Dtest.preferLoopback=true SendReceiveMaxSize + */ +/* + * @test id=preferIPv4Loopback + * @key randomness + * @summary Check that it is possible to send and receive datagrams of + * maximum size on macOS, using an IPv4 only socket and the + * loopback interface + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * @run junit/othervm -Dtest.preferLoopback=true -Djava.net.preferIPv4Stack=true SendReceiveMaxSize */ import jdk.test.lib.RandomFactory; import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.Platform; import jdk.test.lib.net.IPSupport; -import org.testng.Assert; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.Inet4Address; @@ -51,6 +75,7 @@ import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.DatagramChannel; import java.util.ArrayList; +import java.util.List; import java.util.Random; import java.util.function.Predicate; @@ -61,64 +86,74 @@ import static java.net.StandardSocketOptions.SO_RCVBUF; import static jdk.test.lib.net.IPSupport.hasIPv4; import static jdk.test.lib.net.IPSupport.hasIPv6; import static jdk.test.lib.net.IPSupport.preferIPv4Stack; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SendReceiveMaxSize { private final static Class IOE = IOException.class; private final static Random random = RandomFactory.getRandom(); + private final static boolean PREFER_LOOPBACK = Boolean.getBoolean("test.preferLoopback"); public interface DatagramChannelSupplier { DatagramChannel open() throws IOException; } static DatagramChannelSupplier supplier(DatagramChannelSupplier supplier) { return supplier; } - @BeforeTest - public void setUp() { + @BeforeAll + public static void setUp() { IPSupport.throwSkippedExceptionIfNonOperational(); } - @DataProvider - public Object[][] invariants() throws IOException { - var testcases = new ArrayList(); + public static List testCases() throws IOException { + var testcases = new ArrayList(); var nc = NetworkConfiguration.probe(); + var ipv4Loopback = (Inet4Address) InetAddress.getByName("127.0.0.1"); + var ipv6Loopback = (Inet6Address) InetAddress.getByName("::1"); if (hasIPv4()) { - InetAddress IPv4Addr = nc.ip4Addresses() + InetAddress IPv4Addr = PREFER_LOOPBACK ? ipv4Loopback + : nc.ip4Addresses() .filter(Predicate.not(InetAddress::isLoopbackAddress)) .findFirst() - .orElse((Inet4Address) InetAddress.getByName("127.0.0.1")); - testcases.add(new Object[]{ + .orElse(ipv4Loopback); + testcases.add(Arguments.of( supplier(() -> DatagramChannel.open()), IPSupport.getMaxUDPSendBufSizeIPv4(), IPv4Addr - }); - testcases.add(new Object[]{ + )); + testcases.add(Arguments.of( supplier(() -> DatagramChannel.open(INET)), IPSupport.getMaxUDPSendBufSizeIPv4(), IPv4Addr - }); + )); } if (!preferIPv4Stack() && hasIPv6()) { - InetAddress IPv6Addr = nc.ip6Addresses() + InetAddress IPv6Addr = PREFER_LOOPBACK ? ipv6Loopback + : nc.ip6Addresses() .filter(Predicate.not(InetAddress::isLoopbackAddress)) .findFirst() - .orElse((Inet6Address) InetAddress.getByName("::1")); - testcases.add(new Object[]{ + .orElse(ipv6Loopback); + testcases.add(Arguments.of( supplier(() -> DatagramChannel.open()), IPSupport.getMaxUDPSendBufSizeIPv6(), IPv6Addr - }); - testcases.add(new Object[]{ + )); + testcases.add(Arguments.of( supplier(() -> DatagramChannel.open(INET6)), IPSupport.getMaxUDPSendBufSizeIPv6(), IPv6Addr - }); + )); } - return testcases.toArray(Object[][]::new); + return testcases; } - @Test(dataProvider = "invariants") + @ParameterizedTest + @MethodSource("testCases") public void testGetOption(DatagramChannelSupplier supplier, int capacity, InetAddress host) throws IOException { if (Platform.isOSX()) { @@ -128,7 +163,8 @@ public class SendReceiveMaxSize { } } - @Test(dataProvider = "invariants") + @ParameterizedTest + @MethodSource("testCases") public void testSendReceiveMaxSize(DatagramChannelSupplier supplier, int capacity, InetAddress host) throws IOException { try (var receiver = DatagramChannel.open()) { @@ -173,8 +209,8 @@ public class SendReceiveMaxSize { // check that data has been fragmented and re-assembled correctly at receiver System.out.println("sendBuf: " + sendBuf); System.out.println("receiveBuf: " + receiveBuf); - assertEquals(sendBuf, receiveBuf); - assertEquals(sendBuf.compareTo(receiveBuf), 0); + assertEquals(receiveBuf, sendBuf); + assertEquals(0, sendBuf.compareTo(receiveBuf)); testData = new byte[capacity - 1]; random.nextBytes(testData); @@ -200,8 +236,8 @@ public class SendReceiveMaxSize { // check that data has been fragmented and re-assembled correctly at receiver System.out.println("sendBuf: " + sendBuf); System.out.println("receiveBuf: " + receiveBuf); - assertEquals(sendBuf, receiveBuf); - assertEquals(sendBuf.compareTo(receiveBuf), 0); + assertEquals(receiveBuf, sendBuf); + assertEquals(0, sendBuf.compareTo(receiveBuf)); var failSendBuf = ByteBuffer.allocate(capacity + 1); assertThrows(IOE, () -> sender.send(failSendBuf, addr)); diff --git a/test/jdk/java/nio/channels/FileChannel/MapToMemorySegmentTest.java b/test/jdk/java/nio/channels/FileChannel/MapToMemorySegmentTest.java index de89e318fc3..bd2097176ca 100644 --- a/test/jdk/java/nio/channels/FileChannel/MapToMemorySegmentTest.java +++ b/test/jdk/java/nio/channels/FileChannel/MapToMemorySegmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 8281412 * @summary Test FileChannel::map to MemorySegment with custom file channel - * @run testng/othervm MapToMemorySegmentTest + * @run junit/othervm MapToMemorySegmentTest */ import java.io.File; @@ -39,10 +39,10 @@ import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import org.testng.annotations.Test; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class MapToMemorySegmentTest { @@ -58,13 +58,14 @@ public class MapToMemorySegmentTest { } } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test public void testCustomFileChannel() throws IOException { var arena = Arena.ofConfined(); var fc = FileChannel.open(tempPath, StandardOpenOption.WRITE, StandardOpenOption.READ); var fileChannel = new CustomFileChannel(fc); - try (arena; fileChannel){ - fileChannel.map(FileChannel.MapMode.READ_WRITE, 1L, 10L, arena); + try (arena; fileChannel) { + assertThrows(UnsupportedOperationException.class, + () -> fileChannel.map(FileChannel.MapMode.READ_WRITE, 1L, 10L, arena)); } } diff --git a/test/jdk/java/nio/channels/FileChannel/Transfer.java b/test/jdk/java/nio/channels/FileChannel/Transfer.java index 51adba60b06..1afc38a61bd 100644 --- a/test/jdk/java/nio/channels/FileChannel/Transfer.java +++ b/test/jdk/java/nio/channels/FileChannel/Transfer.java @@ -27,7 +27,7 @@ * @library .. * @library /test/lib * @build jdk.test.lib.RandomFactory - * @run testng/timeout=300 Transfer + * @run junit/timeout=300 Transfer * @key randomness */ @@ -54,8 +54,13 @@ import java.util.concurrent.TimeUnit; import jdk.test.lib.RandomFactory; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Transfer { @@ -83,25 +88,22 @@ public class Transfer { long oldSourcePosition = sourceChannel.position(); long bytesWritten = sinkChannel.transferFrom(sourceChannel, 0, 10); - if (bytesWritten != 10) - throw new RuntimeException("Transfer failed"); + assertEquals(10, bytesWritten, "Transfer failed"); - if (sourceChannel.position() == oldSourcePosition) - throw new RuntimeException("Source position didn't change"); + assertNotEquals(oldSourcePosition, sourceChannel.position(), + "Source position didn't change"); - if (sinkChannel.position() != oldSinkPosition) - throw new RuntimeException("Sink position changed"); + assertEquals(oldSinkPosition, sinkChannel.position(), + "Sink position changed"); - if (sinkChannel.size() != 10) - throw new RuntimeException("Unexpected sink size"); + assertEquals(10, sinkChannel.size(), "Unexpected sink size"); bytesWritten = sinkChannel.transferFrom(sourceChannel, 1000, 10); - if (bytesWritten > 10) - throw new RuntimeException("Wrote too many bytes"); + assertFalse(bytesWritten > 10, "Wrote too many bytes"); - if (sinkChannel.size() != 1000 + bytesWritten) - throw new RuntimeException("Unexpected sink size"); + assertEquals(1000 + bytesWritten, sinkChannel.size(), + "Unexpected sink size"); sourceChannel.close(); sinkChannel.close(); @@ -130,8 +132,7 @@ public class Transfer { int totalWritten = 0; while (totalWritten < size + 10) { int written = sink.write(outgoingdata); - if (written < 0) - throw new Exception("Write failed"); + assertTrue(written >= 0, "Write failed"); totalWritten += written; } @@ -143,14 +144,11 @@ public class Transfer { long bytesWritten = fc.transferFrom(source, 0, size); fc.force(true); - if (bytesWritten != size) - throw new RuntimeException("Transfer failed"); + assertEquals(size, bytesWritten, "Transfer failed"); - if (fc.position() != oldPosition) - throw new RuntimeException("Position changed"); + assertEquals(oldPosition, fc.position(), "Position changed"); - if (fc.size() != size) - throw new RuntimeException("Unexpected sink size "+ fc.size()); + assertEquals(size, fc.size(), "Unexpected sink size "+ fc.size()); fc.close(); sink.close(); @@ -168,7 +166,7 @@ public class Transfer { CharSequence csq = "Reality is greater than the sum of its parts."; Files.writeString(source.toPath(), csq); final long length = csq.length(); - Assert.assertEquals(source.length(), length); + assertEquals(length, source.length()); File target = File.createTempFile("before", "after"); target.deleteOnExit(); @@ -183,7 +181,7 @@ public class Transfer { long n = chSource.transferTo(length, 16385, chTarget); // At the end of the input so no bytes should be transferred - Assert.assertEquals(n, 0); + assertEquals(0, n); } } @@ -251,8 +249,7 @@ public class Transfer { fc1.transferTo(0, srcData.length + 1, fc2); - if (fc2.size() > 4) - throw new Exception("xferTest03 failed"); + assertFalse(fc2.size() > 4, "xferTest03 failed"); fc1.close(); fc2.close(); @@ -273,9 +270,7 @@ public class Transfer { while ((c = r.read()) != -1) sb.append((char)c); String contents = sb.toString(); - if (! contents.equals(expected)) - throw new Exception("expected: " + expected - + ", got: " + contents); + assertEquals(expected, contents); r.close(); } @@ -301,8 +296,7 @@ public class Transfer { new RandomAccessFile(sink, "rw").getChannel(); long n = sinkChannel.transferFrom(sourceChannel, 0L, sourceChannel.size()); // overflow - if (n != remaining) - throw new Exception("n == " + n + ", remaining == " + remaining); + assertEquals(remaining, n); sinkChannel.close(); sourceChannel.close(); @@ -363,9 +357,8 @@ public class Transfer { FileChannel fc1 = new FileOutputStream(source).getChannel(); FileChannel fc2 = new RandomAccessFile(target, "rw").getChannel(); try { - fc2.transferFrom(fc1, 0L, 0); - throw new RuntimeException("NonReadableChannelException expected"); - } catch (NonReadableChannelException expected) { + assertThrows(NonReadableChannelException.class, + () -> fc2.transferFrom(fc1, 0L, 0)); } finally { fc1.close(); fc2.close(); diff --git a/test/jdk/java/nio/channels/FileChannel/Transfer4GBFile.java b/test/jdk/java/nio/channels/FileChannel/Transfer4GBFile.java index b8c026c983c..0766f4ffb45 100644 --- a/test/jdk/java/nio/channels/FileChannel/Transfer4GBFile.java +++ b/test/jdk/java/nio/channels/FileChannel/Transfer4GBFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,7 +25,7 @@ * @bug 4638365 * @summary Test FileChannel.transferFrom and transferTo for 4GB files * @build FileChannelUtils - * @run testng/timeout=300 Transfer4GBFile + * @run junit/timeout=300 Transfer4GBFile */ import java.io.BufferedWriter; @@ -38,10 +38,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static java.nio.file.StandardOpenOption.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class Transfer4GBFile { private static PrintStream err = System.err; @@ -71,10 +73,8 @@ public class Transfer4GBFile { long bytesWritten = sourceChannel.transferTo(testSize - 40, 10, sinkChannel); - if (bytesWritten != 10) { - throw new RuntimeException("Transfer test 4 failed " + - bytesWritten); - } + assertEquals(10, bytesWritten, + "Transfer test 4 failed " + bytesWritten); } Files.delete(source); @@ -112,10 +112,8 @@ public class Transfer4GBFile { FileChannel sinkChannel = FileChannel.open(sink, WRITE)) { long bytesWritten = sinkChannel.transferFrom(sourceChannel, testSize - 40, 10); - if (bytesWritten != 10) { - throw new RuntimeException("Transfer test 5 failed " + - bytesWritten); - } + assertEquals(10, bytesWritten, + "Transfer test 5 failed " + bytesWritten); } Files.delete(source); diff --git a/test/jdk/java/nio/channels/FileChannel/TransferTo6GBFile.java b/test/jdk/java/nio/channels/FileChannel/TransferTo6GBFile.java index 9ca6df0c870..791a0718a75 100644 --- a/test/jdk/java/nio/channels/FileChannel/TransferTo6GBFile.java +++ b/test/jdk/java/nio/channels/FileChannel/TransferTo6GBFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,7 +25,7 @@ * @bug 6253145 * @summary Test FileChannel.transferTo with file positions up to 8GB * @build FileChannelUtils - * @run testng/timeout=300 TransferTo6GBFile + * @run junit/timeout=300 TransferTo6GBFile */ import java.io.IOException; @@ -40,10 +40,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static java.nio.file.StandardOpenOption.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class TransferTo6GBFile { private static PrintStream err = System.err; @@ -126,16 +130,14 @@ public class TransferTo6GBFile { long nread = 0; while (nread < count) { int n = source.read(readbuf); - if (n < 0) - throw new RuntimeException("Premature EOF!"); + assertTrue(n >= 0, "Premature EOF!"); nread += n; } // check reply from echo server readbuf.flip(); sendbuf.flip(); - if (!readbuf.equals(sendbuf)) - throw new RuntimeException("Echoed bytes do not match!"); + assertEquals(sendbuf, readbuf, "Echoed bytes do not match!"); readbuf.clear(); sendbuf.clear(); } diff --git a/test/jdk/java/nio/channels/FileLock/Overlaps.java b/test/jdk/java/nio/channels/FileLock/Overlaps.java index 64293e2996d..3e3b92ac67e 100644 --- a/test/jdk/java/nio/channels/FileLock/Overlaps.java +++ b/test/jdk/java/nio/channels/FileLock/Overlaps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,7 +25,7 @@ * @test * @bug 5041655 * @summary Verify FileLock.overlaps - * @run testng Overlaps + * @run junit Overlaps */ import java.io.IOException; import java.nio.ByteBuffer; @@ -33,15 +33,18 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.file.Files; import java.nio.file.Path; +import java.util.stream.Stream; import static java.lang.Boolean.*; import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.assertEquals; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class Overlaps { private static final long POS = 27; @@ -49,47 +52,46 @@ public class Overlaps { private static FileChannel fc; - @BeforeClass - public void before() throws IOException { + @BeforeAll + public static void before() throws IOException { Path path = Files.createTempFile(Path.of("."), "foo", ".bar"); fc = FileChannel.open(path, CREATE, WRITE, DELETE_ON_CLOSE); fc.position(POS); fc.write(ByteBuffer.wrap(new byte[(int)SIZE])); } - @AfterClass - public void after() throws IOException { + @AfterAll + public static void after() throws IOException { fc.close(); } - @DataProvider - public Object[][] ranges() { - return new Object[][] { - {POS, SIZE, -1,-1, FALSE}, - {POS, SIZE, 0, -1, FALSE}, - {POS, SIZE, POS - 1, -1, FALSE}, - {POS, SIZE, POS + SIZE/2, -1, FALSE}, - {POS, SIZE, POS + SIZE, -1, FALSE}, - {POS, SIZE, -1, POS, FALSE}, - {POS, SIZE, -1, POS + SIZE/2, TRUE}, - {POS, SIZE, POS - 2, 1, FALSE}, - {POS, SIZE, POS + 1, 1, TRUE}, - {POS, SIZE, POS + SIZE/2, 0, TRUE}, - {POS, SIZE, Long.MAX_VALUE, 2, FALSE}, - {POS, SIZE, POS + SIZE / 2, Long.MAX_VALUE, TRUE}, - {POS, SIZE, 0, 0, TRUE}, - {Long.MAX_VALUE - SIZE/2, 0, 0, SIZE, FALSE}, - {Long.MAX_VALUE - SIZE/2, 0, Long.MAX_VALUE - SIZE/4, SIZE, TRUE}, - {Long.MAX_VALUE - SIZE/2, 0, Long.MAX_VALUE - SIZE, 0, TRUE}, - {Long.MAX_VALUE - SIZE, 0, Long.MAX_VALUE - SIZE/2, 0, TRUE} - }; + public static Stream ranges() { + return Stream.of( + Arguments.of(POS, SIZE, -1, -1, FALSE), + Arguments.of(POS, SIZE, 0, -1, FALSE), + Arguments.of(POS, SIZE, POS - 1, -1, FALSE), + Arguments.of(POS, SIZE, POS + SIZE/2, -1, FALSE), + Arguments.of(POS, SIZE, POS + SIZE, -1, FALSE), + Arguments.of(POS, SIZE, -1, POS, FALSE), + Arguments.of(POS, SIZE, -1, POS + SIZE/2, TRUE), + Arguments.of(POS, SIZE, POS - 2, 1, FALSE), + Arguments.of(POS, SIZE, POS + 1, 1, TRUE), + Arguments.of(POS, SIZE, POS + SIZE/2, 0, TRUE), + Arguments.of(POS, SIZE, Long.MAX_VALUE, 2, FALSE), + Arguments.of(POS, SIZE, POS + SIZE / 2, Long.MAX_VALUE, TRUE), + Arguments.of(POS, SIZE, 0, 0, TRUE), + Arguments.of(Long.MAX_VALUE - SIZE/2, 0, 0, SIZE, FALSE), + Arguments.of(Long.MAX_VALUE - SIZE/2, 0, Long.MAX_VALUE - SIZE/4, SIZE, TRUE), + Arguments.of(Long.MAX_VALUE - SIZE/2, 0, Long.MAX_VALUE - SIZE, 0, TRUE), + Arguments.of(Long.MAX_VALUE - SIZE, 0, Long.MAX_VALUE - SIZE/2, 0, TRUE)); } - @Test(dataProvider = "ranges") + @ParameterizedTest + @MethodSource("ranges") public void overlaps(long lockPos, long lockSize, long pos, long size, boolean overlaps) throws IOException { try (FileLock lock = fc.lock(lockPos, lockSize, false)) { - assertEquals(lock.overlaps(pos, size), overlaps); + assertEquals(overlaps, lock.overlaps(pos, size)); } } } diff --git a/test/jdk/java/nio/channels/SelectionKey/AtomicUpdates.java b/test/jdk/java/nio/channels/SelectionKey/AtomicUpdates.java index 8e5bee51b71..e609530ff69 100644 --- a/test/jdk/java/nio/channels/SelectionKey/AtomicUpdates.java +++ b/test/jdk/java/nio/channels/SelectionKey/AtomicUpdates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +23,7 @@ /* @test * @bug 6350055 - * @run testng AtomicUpdates + * @run junit AtomicUpdates * @summary Unit test for SelectionKey interestOpsOr and interestOpsAnd */ @@ -37,15 +37,19 @@ import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.Test; import static java.nio.channels.SelectionKey.OP_READ; import static java.nio.channels.SelectionKey.OP_WRITE; import static java.nio.channels.SelectionKey.OP_CONNECT; import static java.nio.channels.SelectionKey.OP_ACCEPT; -import static org.testng.Assert.*; -@Test +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + public class AtomicUpdates { private SelectionKey keyFor(SocketChannel sc) { @@ -94,74 +98,69 @@ public class AtomicUpdates { } private void test(SelectionKey key) { - assertTrue(key.channel() instanceof SocketChannel); + assertInstanceOf(SocketChannel.class, key.channel()); key.interestOps(0); // 0 -> 0 int previous = key.interestOpsOr(0); - assertTrue(previous == 0); - assertTrue(key.interestOps() == 0); + assertEquals(0, previous); + assertEquals(0, key.interestOps()); // 0 -> OP_CONNECT previous = key.interestOpsOr(OP_CONNECT); - assertTrue(previous == 0); - assertTrue(key.interestOps() == OP_CONNECT); + assertEquals(0, previous); + assertEquals(OP_CONNECT, key.interestOps()); // OP_CONNECT -> OP_CONNECT previous = key.interestOpsOr(0); - assertTrue(previous == OP_CONNECT); - assertTrue(key.interestOps() == OP_CONNECT); + assertEquals(OP_CONNECT, previous); + assertEquals(OP_CONNECT, key.interestOps()); // OP_CONNECT -> OP_CONNECT | OP_READ | OP_WRITE previous = key.interestOpsOr(OP_READ | OP_WRITE); - assertTrue(previous == OP_CONNECT); - assertTrue(key.interestOps() == (OP_CONNECT | OP_READ | OP_WRITE)); + assertEquals(OP_CONNECT, previous); + assertEquals(OP_CONNECT | OP_READ | OP_WRITE, key.interestOps()); // OP_CONNECT | OP_READ | OP_WRITE -> OP_CONNECT previous = key.interestOpsAnd(~(OP_READ | OP_WRITE)); - assertTrue(previous == (OP_CONNECT | OP_READ | OP_WRITE)); - assertTrue(key.interestOps() == OP_CONNECT); + assertEquals(OP_CONNECT | OP_READ | OP_WRITE, previous); + assertEquals(OP_CONNECT, key.interestOps()); // OP_CONNECT -> 0 previous = key.interestOpsAnd(~OP_CONNECT); - assertTrue(previous == OP_CONNECT); - assertTrue(key.interestOps() == 0); + assertEquals(OP_CONNECT, previous); + assertEquals(0, key.interestOps()); // OP_READ | OP_WRITE -> OP_READ | OP_WRITE key.interestOps(OP_READ | OP_WRITE); previous = key.interestOpsAnd(~OP_ACCEPT); - assertTrue(previous == (OP_READ | OP_WRITE)); - assertTrue(key.interestOps() == (OP_READ | OP_WRITE)); + assertEquals(OP_READ | OP_WRITE, previous); + assertEquals(OP_READ | OP_WRITE, key.interestOps()); // OP_READ | OP_WRITE -> 0 previous = key.interestOpsAnd(0); - assertTrue(previous == (OP_READ | OP_WRITE)); - assertTrue(key.interestOps() == 0); + assertEquals(OP_READ | OP_WRITE, previous); + assertEquals(0, key.interestOps()); // 0 -> 0 previous = key.interestOpsAnd(0); - assertTrue(previous == 0); - assertTrue(key.interestOps() == 0); + assertEquals(0, previous); + assertEquals(0, key.interestOps()); - try { - key.interestOpsOr(OP_ACCEPT); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException expected) { } + assertThrows(IllegalArgumentException.class, + () -> key.interestOpsOr(OP_ACCEPT)); key.cancel(); - try { - key.interestOpsOr(OP_READ); - fail("CancelledKeyException expected"); - } catch (CancelledKeyException expected) { } - try { - key.interestOpsAnd(~OP_READ); - fail("CancelledKeyException expected"); - } catch (CancelledKeyException expected) { } + assertThrows(CancelledKeyException.class, + () -> key.interestOpsOr(OP_READ)); + assertThrows(CancelledKeyException.class, + () -> key.interestOpsAnd(~OP_READ)); } /** * Test default implementation of interestOpsOr/interestOpsAnd */ + @Test public void testDefaultImplementation() throws Exception { try (SocketChannel sc = SocketChannel.open()) { SelectionKey key = keyFor(sc); @@ -172,6 +171,7 @@ public class AtomicUpdates { /** * Test the default provider implementation of SelectionKey. */ + @Test public void testNioImplementation() throws Exception { try (SocketChannel sc = SocketChannel.open(); Selector sel = Selector.open()) { diff --git a/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java b/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java index 1a2ada51bce..b90a68ffd04 100644 --- a/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java +++ b/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,12 @@ /* @test * @summary Unit test for Selector.select/selectNow(Consumer) * @bug 8199433 8208780 - * @run testng SelectWithConsumer + * @run junit SelectWithConsumer */ /* @test * @requires (os.family == "windows") - * @run testng/othervm -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.WindowsSelectorProvider SelectWithConsumer + * @run junit/othervm -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.WindowsSelectorProvider SelectWithConsumer */ import java.io.Closeable; @@ -49,11 +49,16 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import static java.util.concurrent.TimeUnit.*; -import org.testng.annotations.AfterTest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Test public class SelectWithConsumer { /** @@ -81,46 +86,47 @@ public class SelectWithConsumer { // select(Consumer) notifiedOps.set(0); int n = sel.select(k -> { - assertTrue(Thread.currentThread() == callerThread); - assertTrue(k == key); + assertSame(callerThread, Thread.currentThread()); + assertSame(key, k); int readyOps = key.readyOps(); - assertTrue((readyOps & interestOps) != 0); - assertTrue((readyOps & notifiedOps.get()) == 0); + assertNotEquals(0, readyOps & interestOps); + assertEquals(0, readyOps & notifiedOps.get()); notifiedOps.set(notifiedOps.get() | readyOps); }); assertTrue((n == 1) ^ (expectedOps == 0)); - assertTrue(notifiedOps.get() == expectedOps); + assertEquals(expectedOps, notifiedOps.get()); // select(Consumer, timeout) notifiedOps.set(0); n = sel.select(k -> { - assertTrue(Thread.currentThread() == callerThread); - assertTrue(k == key); + assertSame(callerThread, Thread.currentThread()); + assertSame(key, k); int readyOps = key.readyOps(); - assertTrue((readyOps & interestOps) != 0); - assertTrue((readyOps & notifiedOps.get()) == 0); + assertNotEquals(0, readyOps & interestOps); + assertEquals(0, readyOps & notifiedOps.get()); notifiedOps.set(notifiedOps.get() | readyOps); }, 1000); assertTrue((n == 1) ^ (expectedOps == 0)); - assertTrue(notifiedOps.get() == expectedOps); + assertEquals(expectedOps, notifiedOps.get()); // selectNow(Consumer) notifiedOps.set(0); n = sel.selectNow(k -> { - assertTrue(Thread.currentThread() == callerThread); - assertTrue(k == key); + assertSame(callerThread, Thread.currentThread()); + assertSame(key, k); int readyOps = key.readyOps(); - assertTrue((readyOps & interestOps) != 0); - assertTrue((readyOps & notifiedOps.get()) == 0); + assertNotEquals(0, readyOps & interestOps); + assertEquals(0, readyOps & notifiedOps.get()); notifiedOps.set(notifiedOps.get() | readyOps); }); assertTrue((n == 1) ^ (expectedOps == 0)); - assertTrue(notifiedOps.get() == expectedOps); + assertEquals(expectedOps, notifiedOps.get()); } /** * Test that an action is performed when a channel is ready for reading. */ + @Test public void testReadable() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -142,6 +148,7 @@ public class SelectWithConsumer { /** * Test that an action is performed when a channel is ready for writing. */ + @Test public void testWritable() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -161,6 +168,7 @@ public class SelectWithConsumer { * Test that an action is performed when a channel is ready for both * reading and writing. */ + @Test public void testReadableAndWriteable() throws Exception { ServerSocketChannel ssc = null; SocketChannel sc = null; @@ -188,6 +196,7 @@ public class SelectWithConsumer { /** * Test that the action is called for two selected channels */ + @Test public void testTwoChannels() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -217,8 +226,8 @@ public class SelectWithConsumer { assertTrue(k == key1 || k == key2); counter.incrementAndGet(); }); - assertTrue(n == 2); - assertTrue(counter.get() == 2); + assertEquals(2, n); + assertEquals(2, counter.get()); // select(Consumer, timeout) counter.set(0); @@ -226,8 +235,8 @@ public class SelectWithConsumer { assertTrue(k == key1 || k == key2); counter.incrementAndGet(); }, 1000); - assertTrue(n == 2); - assertTrue(counter.get() == 2); + assertEquals(2, n); + assertEquals(2, counter.get()); // selectNow(Consumer) counter.set(0); @@ -235,8 +244,8 @@ public class SelectWithConsumer { assertTrue(k == key1 || k == key2); counter.incrementAndGet(); }); - assertTrue(n == 2); - assertTrue(counter.get() == 2); + assertEquals(2, n); + assertEquals(2, counter.get()); } finally { closePipe(p); } @@ -245,6 +254,7 @@ public class SelectWithConsumer { /** * Test calling select twice, the action should be invoked each time */ + @Test public void testRepeatedSelect1() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -269,6 +279,7 @@ public class SelectWithConsumer { * Test calling select twice. An I/O operation is performed after the * first select so the channel will not be selected by the second select. */ + @Test public void testRepeatedSelect2() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -301,6 +312,7 @@ public class SelectWithConsumer { /** * Test timeout */ + @Test public void testTimeout() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -311,7 +323,7 @@ public class SelectWithConsumer { long start = millisTime(); int n = sel.select(k -> assertTrue(false), 1000L); expectDuration(start, 500, Long.MAX_VALUE); - assertTrue(n == 0); + assertEquals(0, n); } finally { closePipe(p); } @@ -320,12 +332,13 @@ public class SelectWithConsumer { /** * Test wakeup prior to select */ + @Test public void testWakeupBeforeSelect() throws Exception { // select(Consumer) try (Selector sel = Selector.open()) { sel.wakeup(); int n = sel.select(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); } // select(Consumer, timeout) @@ -334,19 +347,20 @@ public class SelectWithConsumer { long start = millisTime(); int n = sel.select(k -> assertTrue(false), 60*1000); expectDuration(start, 0, 20_000); - assertTrue(n == 0); + assertEquals(0, n); } } /** * Test wakeup during select */ + @Test public void testWakeupDuringSelect() throws Exception { // select(Consumer) try (Selector sel = Selector.open()) { scheduleWakeup(sel, 1, SECONDS); int n = sel.select(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); } // select(Consumer, timeout) @@ -355,19 +369,20 @@ public class SelectWithConsumer { long start = millisTime(); int n = sel.select(k -> assertTrue(false), 60*1000); expectDuration(start, 0, 20_000); - assertTrue(n == 0); + assertEquals(0, n); } } /** * Test invoking select with interrupted status set */ + @Test public void testInterruptBeforeSelect() throws Exception { // select(Consumer) try (Selector sel = Selector.open()) { Thread.currentThread().interrupt(); int n = sel.select(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); assertTrue(Thread.currentThread().isInterrupted()); assertTrue(sel.isOpen()); } finally { @@ -380,7 +395,7 @@ public class SelectWithConsumer { long start = millisTime(); int n = sel.select(k -> assertTrue(false), 60*1000); expectDuration(start, 0, 20_000); - assertTrue(n == 0); + assertEquals(0, n); assertTrue(Thread.currentThread().isInterrupted()); assertTrue(sel.isOpen()); } finally { @@ -391,12 +406,13 @@ public class SelectWithConsumer { /** * Test interrupt thread during select */ + @Test public void testInterruptDuringSelect() throws Exception { // select(Consumer) try (Selector sel = Selector.open()) { scheduleInterrupt(Thread.currentThread(), 1, SECONDS); int n = sel.select(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); assertTrue(Thread.currentThread().isInterrupted()); assertTrue(sel.isOpen()); } finally { @@ -407,7 +423,7 @@ public class SelectWithConsumer { try (Selector sel = Selector.open()) { scheduleInterrupt(Thread.currentThread(), 1, SECONDS); int n = sel.select(k -> assertTrue(false), 60*1000); - assertTrue(n == 0); + assertEquals(0, n); assertTrue(Thread.currentThread().isInterrupted()); assertTrue(sel.isOpen()); } finally { @@ -418,34 +434,38 @@ public class SelectWithConsumer { /** * Test invoking select on a closed selector */ - @Test(expectedExceptions = ClosedSelectorException.class) + @Test public void testClosedSelector1() throws Exception { Selector sel = Selector.open(); sel.close(); - sel.select(k -> assertTrue(false)); + assertThrows(ClosedSelectorException.class, + () -> sel.select(k -> assertTrue(false))); } - @Test(expectedExceptions = ClosedSelectorException.class) + @Test public void testClosedSelector2() throws Exception { Selector sel = Selector.open(); sel.close(); - sel.select(k -> assertTrue(false), 1000); + assertThrows(ClosedSelectorException.class, + () -> sel.select(k -> assertTrue(false), 1000)); } - @Test(expectedExceptions = ClosedSelectorException.class) + @Test public void testClosedSelector3() throws Exception { Selector sel = Selector.open(); sel.close(); - sel.selectNow(k -> assertTrue(false)); + assertThrows(ClosedSelectorException.class, + () -> sel.selectNow(k -> assertTrue(false))); } /** * Test closing selector while in a selection operation */ + @Test public void testCloseDuringSelect() throws Exception { // select(Consumer) try (Selector sel = Selector.open()) { scheduleClose(sel, 3, SECONDS); int n = sel.select(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); assertFalse(sel.isOpen()); } @@ -458,7 +478,7 @@ public class SelectWithConsumer { long after = System.nanoTime(); long selectDuration = (after - start) / 1000000; long scheduleDuration = (start - before) / 1000000; - assertTrue(n == 0); + assertEquals(0, n); assertTrue(selectDuration > 2000 && selectDuration < 10*1000, "select took " + selectDuration + " ms schedule took " + scheduleDuration + " ms"); @@ -469,7 +489,7 @@ public class SelectWithConsumer { /** * Test action closing selector */ - @Test(expectedExceptions = ClosedSelectorException.class) + @Test public void testActionClosingSelector() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -482,12 +502,14 @@ public class SelectWithConsumer { sink.write(messageBuffer()); // should relay ClosedSelectorException - sel.select(k -> { - assertTrue(k == key); - try { - sel.close(); - } catch (IOException ioe) { } - }); + assertThrows(ClosedSelectorException.class, + () -> sel.select(k -> { + assertTrue(k == key); + try { + sel.close(); + } catch (IOException ioe) { } + }) + ); } finally { closePipe(p); } @@ -497,6 +519,7 @@ public class SelectWithConsumer { * Test that the action is invoked while synchronized on the selector and * its selected-key set. */ + @Test public void testLocks() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -510,7 +533,7 @@ public class SelectWithConsumer { // select(Consumer) sel.select(k -> { - assertTrue(k == key); + assertSame(key, k); assertTrue(Thread.holdsLock(sel)); assertFalse(Thread.holdsLock(sel.keys())); assertTrue(Thread.holdsLock(sel.selectedKeys())); @@ -518,7 +541,7 @@ public class SelectWithConsumer { // select(Consumer, timeout) sel.select(k -> { - assertTrue(k == key); + assertSame(key, k); assertTrue(Thread.holdsLock(sel)); assertFalse(Thread.holdsLock(sel.keys())); assertTrue(Thread.holdsLock(sel.selectedKeys())); @@ -526,7 +549,7 @@ public class SelectWithConsumer { // selectNow(Consumer) sel.selectNow(k -> { - assertTrue(k == key); + assertSame(key, k); assertTrue(Thread.holdsLock(sel)); assertFalse(Thread.holdsLock(sel.keys())); assertTrue(Thread.holdsLock(sel.selectedKeys())); @@ -540,6 +563,7 @@ public class SelectWithConsumer { * Test that selection operations remove cancelled keys from the selector's * key and selected-key sets. */ + @Test public void testCancel() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -569,7 +593,7 @@ public class SelectWithConsumer { // cancel key1 key1.cancel(); int n = sel.selectNow(k -> assertTrue(k == key2)); - assertTrue(n == 1); + assertEquals(1, n); assertFalse(sel.keys().contains(key1)); assertTrue(sel.keys().contains(key2)); assertFalse(sel.selectedKeys().contains(key1)); @@ -578,7 +602,7 @@ public class SelectWithConsumer { // cancel key2 key2.cancel(); n = sel.selectNow(k -> assertTrue(false)); - assertTrue(n == 0); + assertEquals(0, n); assertFalse(sel.keys().contains(key1)); assertFalse(sel.keys().contains(key2)); assertFalse(sel.selectedKeys().contains(key1)); @@ -591,6 +615,7 @@ public class SelectWithConsumer { /** * Test an action invoking select() */ + @Test public void testReentrantSelect1() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -611,7 +636,7 @@ public class SelectWithConsumer { } catch (IllegalStateException expected) { } }); - assertTrue(n == 1); + assertEquals(1, n); } finally { closePipe(p); } @@ -620,6 +645,7 @@ public class SelectWithConsumer { /** * Test an action invoking selectNow() */ + @Test public void testReentrantSelect2() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -640,7 +666,7 @@ public class SelectWithConsumer { } catch (IllegalStateException expected) { } }); - assertTrue(n == 1); + assertEquals(1, n); } finally { closePipe(p); } @@ -649,6 +675,7 @@ public class SelectWithConsumer { /** * Test an action invoking select(Consumer) */ + @Test public void testReentrantSelect3() throws Exception { Pipe p = Pipe.open(); try (Selector sel = Selector.open()) { @@ -669,7 +696,7 @@ public class SelectWithConsumer { } catch (IllegalStateException expected) { } }); - assertTrue(n == 1); + assertEquals(1, n); } finally { closePipe(p); } @@ -678,42 +705,46 @@ public class SelectWithConsumer { /** * Negative timeout */ - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testNegativeTimeout() throws Exception { try (Selector sel = Selector.open()) { - sel.select(k -> { }, -1L); + assertThrows(IllegalArgumentException.class, + () -> sel.select(k -> { }, -1L)); } } /** * Null action */ - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNull1() throws Exception { try (Selector sel = Selector.open()) { - sel.select(null); + assertThrows(NullPointerException.class, + () -> sel.select(null)); } } - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNull2() throws Exception { try (Selector sel = Selector.open()) { - sel.select(null, 1000); + assertThrows(NullPointerException.class, + () -> sel.select(null, 1000)); } } - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNull3() throws Exception { try (Selector sel = Selector.open()) { - sel.selectNow(null); + assertThrows(NullPointerException.class, + () -> sel.selectNow(null)); } } // -- support methods --- - private final ScheduledExecutorService POOL = Executors.newScheduledThreadPool(1); + private static final ScheduledExecutorService POOL = Executors.newScheduledThreadPool(1); - @AfterTest - void shutdownThreadPool() { + @AfterAll + static void shutdownThreadPool() { POOL.shutdown(); } diff --git a/test/jdk/java/nio/channels/Selector/UpdateReadyOps.java b/test/jdk/java/nio/channels/Selector/UpdateReadyOps.java index 57a563c6a59..87b512fe495 100644 --- a/test/jdk/java/nio/channels/Selector/UpdateReadyOps.java +++ b/test/jdk/java/nio/channels/Selector/UpdateReadyOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @run testng UpdateReadyOps + * @run junit UpdateReadyOps * @summary Test that the ready set from a selection operation is bitwise-disjoined * into a key's ready set when the key is already in the selected-key set */ @@ -37,16 +37,19 @@ import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Test public class UpdateReadyOps { /** * Test that OP_WRITE is preserved when updating the ready set of a key in * the selected-key set to add OP_READ. */ + @Test public void testOpWritePreserved() throws Exception { try (ConnectionPair pair = new ConnectionPair(); Selector sel = Selector.open()) { @@ -58,14 +61,14 @@ public class UpdateReadyOps { SelectionKey key = sc1.register(sel, SelectionKey.OP_WRITE); int updated = sel.select(); - assertTrue(updated == 1); + assertEquals(1, updated); assertTrue(sel.selectedKeys().contains(key)); assertFalse(key.isReadable()); assertTrue(key.isWritable()); // select again, should be no updates updated = sel.select(); - assertTrue(updated == 0); + assertEquals(0, updated); assertTrue(sel.selectedKeys().contains(key)); assertFalse(key.isReadable()); assertTrue(key.isWritable()); @@ -78,16 +81,17 @@ public class UpdateReadyOps { key.interestOps(SelectionKey.OP_READ); updated = sel.select(); - assertTrue(updated == 1); - assertTrue(sel.selectedKeys().size() == 1); + assertEquals(1, updated); + assertEquals(1, sel.selectedKeys().size()); assertTrue(key.isReadable()); assertTrue(key.isWritable()); - assertTrue(key.readyOps() == (SelectionKey.OP_READ|SelectionKey.OP_WRITE)); + assertEquals(SelectionKey.OP_READ|SelectionKey.OP_WRITE, + key.readyOps()); // select again, should be no updates updated = sel.select(); - assertTrue(updated == 0); - assertTrue(sel.selectedKeys().size() == 1); + assertEquals(0, updated); + assertEquals(1, sel.selectedKeys().size()); assertTrue(key.isReadable()); assertTrue(key.isWritable()); } @@ -97,6 +101,7 @@ public class UpdateReadyOps { * Test that OP_READ is preserved when updating the ready set of a key in * the selected-key set to add OP_WRITE. */ + @Test public void testOpReadPreserved() throws Exception { try (ConnectionPair pair = new ConnectionPair(); Selector sel = Selector.open()) { @@ -111,32 +116,32 @@ public class UpdateReadyOps { sc2.write(helloMessage()); int updated = sel.select(); - assertTrue(updated == 1); - assertTrue(sel.selectedKeys().size() == 1); + assertEquals(1, updated); + assertEquals(1, sel.selectedKeys().size()); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isReadable()); assertFalse(key.isWritable()); // select again, should be no updates updated = sel.select(); - assertTrue(updated == 0); + assertEquals(0, updated); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isReadable()); assertFalse(key.isWritable()); key.interestOps(SelectionKey.OP_WRITE); updated = sel.select(); - assertTrue(updated == 1); - assertTrue(sel.selectedKeys().size() == 1); + assertEquals(1, updated); + assertEquals(1, sel.selectedKeys().size()); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isReadable()); assertTrue(key.isWritable()); - assertTrue(key.readyOps() == (SelectionKey.OP_READ|SelectionKey.OP_WRITE)); + assertEquals(SelectionKey.OP_READ|SelectionKey.OP_WRITE, key.readyOps()); // select again, should be no updates updated = sel.select(); - assertTrue(updated == 0); - assertTrue(sel.selectedKeys().size() == 1); + assertEquals(0, updated); + assertEquals(1, sel.selectedKeys().size()); assertTrue(key.isReadable()); assertTrue(key.isWritable()); } diff --git a/test/jdk/java/nio/channels/SocketChannel/AdaptorStreams.java b/test/jdk/java/nio/channels/SocketChannel/AdaptorStreams.java index 3487ae45de1..240d9e3baf7 100644 --- a/test/jdk/java/nio/channels/SocketChannel/AdaptorStreams.java +++ b/test/jdk/java/nio/channels/SocketChannel/AdaptorStreams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,7 +23,7 @@ /* @test * @bug 8222774 4430139 - * @run testng AdaptorStreams + * @run junit AdaptorStreams * @summary Exercise socket adaptor input/output streams */ @@ -44,77 +44,82 @@ import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; -@Test public class AdaptorStreams { /** * Test read when bytes are available */ + @Test public void testRead1() throws Exception { withConnection((sc, peer) -> { peer.getOutputStream().write(99); int n = sc.socket().getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read blocking before bytes are available */ + @Test public void testRead2() throws Exception { withConnection((sc, peer) -> { scheduleWrite(peer.getOutputStream(), 99, 1000); int n = sc.socket().getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read when peer has closed connection */ + @Test public void testRead3() throws Exception { withConnection((sc, peer) -> { peer.close(); int n = sc.socket().getInputStream().read(); - assertEquals(n, -1); + assertEquals(-1, n); }); } /** * Test read blocking before peer closes connection */ + @Test public void testRead4() throws Exception { withConnection((sc, peer) -> { scheduleClose(peer, 1000); int n = sc.socket().getInputStream().read(); - assertEquals(n, -1); + assertEquals(-1, n); }); } /** * Test async close of socket when thread blocked in read */ + @Test public void testRead5() throws Exception { withConnection((sc, peer) -> { scheduleClose(sc, 2000); InputStream in = sc.socket().getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); }); } /** * Test interrupted status set before read */ + @Test public void testRead6() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); Thread.currentThread().interrupt(); try { InputStream in = s.getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); } finally { Thread.interrupted(); // clear interrupt } @@ -125,13 +130,14 @@ public class AdaptorStreams { /** * Test interrupt of thread blocked in read */ + @Test public void testRead7() throws Exception { withConnection((sc, peer) -> { Future interrupter = scheduleInterrupt(Thread.currentThread(), 2000); Socket s = sc.socket(); try { InputStream in = s.getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); } finally { interrupter.cancel(true); Thread.interrupted(); // clear interrupt @@ -143,68 +149,74 @@ public class AdaptorStreams { /** * Test read when channel is configured non-blocking */ + @Test public void testRead8() throws Exception { withConnection((sc, peer) -> { sc.configureBlocking(false); InputStream in = sc.socket().getInputStream(); - expectThrows(IllegalBlockingModeException.class, () -> in.read()); + assertThrows(IllegalBlockingModeException.class, () -> in.read()); }); } /** * Test timed read when bytes are available */ + @Test public void testTimedRead1() throws Exception { withConnection((sc, peer) -> { peer.getOutputStream().write(99); Socket s = sc.socket(); s.setSoTimeout(60_000); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test timed read blocking before bytes are available */ + @Test public void testTimedRead2() throws Exception { withConnection((sc, peer) -> { scheduleWrite(peer.getOutputStream(), 99, 1000); Socket s = sc.socket(); s.setSoTimeout(60_000); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test timed read when the read times out */ + @Test public void testTimedRead3() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); s.setSoTimeout(500); InputStream in = s.getInputStream(); - expectThrows(SocketTimeoutException.class, () -> in.read()); + assertThrows(SocketTimeoutException.class, () -> in.read()); }); } /** * Test async close of socket when thread blocked in timed read */ + @Test public void testTimedRead4() throws Exception { withConnection((sc, peer) -> { scheduleClose(sc, 2000); Socket s = sc.socket(); s.setSoTimeout(60_000); InputStream in = s.getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); }); } /** * Test interrupted status set before timed read */ + @Test public void testTimedRead5() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -212,7 +224,7 @@ public class AdaptorStreams { try { s.setSoTimeout(60_000); InputStream in = s.getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); } finally { Thread.interrupted(); // clear interrupt } @@ -223,6 +235,7 @@ public class AdaptorStreams { /** * Test interrupt of thread blocked in timed read */ + @Test public void testTimedRead6() throws Exception { withConnection((sc, peer) -> { Future interrupter = scheduleInterrupt(Thread.currentThread(), 2000); @@ -230,7 +243,7 @@ public class AdaptorStreams { try { s.setSoTimeout(60_000); InputStream in = s.getInputStream(); - expectThrows(IOException.class, () -> in.read()); + assertThrows(IOException.class, () -> in.read()); assertTrue(s.isClosed()); } finally { interrupter.cancel(true); @@ -243,10 +256,11 @@ public class AdaptorStreams { /** * Test async close of socket when thread blocked in write */ + @Test public void testWrite1() throws Exception { withConnection((sc, peer) -> { scheduleClose(sc, 2000); - expectThrows(IOException.class, () -> { + assertThrows(IOException.class, () -> { OutputStream out = sc.socket().getOutputStream(); byte[] data = new byte[64*1000]; while (true) { @@ -259,13 +273,14 @@ public class AdaptorStreams { /** * Test interrupted status set before write */ + @Test public void testWrite2() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); Thread.currentThread().interrupt(); try { OutputStream out = s.getOutputStream(); - expectThrows(IOException.class, () -> out.write(99)); + assertThrows(IOException.class, () -> out.write(99)); } finally { Thread.interrupted(); // clear interrupt } @@ -276,12 +291,13 @@ public class AdaptorStreams { /** * Test interrupt of thread blocked in write */ + @Test public void testWrite3() throws Exception { withConnection((sc, peer) -> { Future interrupter = scheduleInterrupt(Thread.currentThread(), 2000); Socket s = sc.socket(); try { - expectThrows(IOException.class, () -> { + assertThrows(IOException.class, () -> { OutputStream out = sc.socket().getOutputStream(); byte[] data = new byte[64*1000]; while (true) { @@ -299,11 +315,12 @@ public class AdaptorStreams { /** * Test write when channel is configured non-blocking */ + @Test public void testWrite4() throws Exception { withConnection((sc, peer) -> { sc.configureBlocking(false); OutputStream out = sc.socket().getOutputStream(); - expectThrows(IllegalBlockingModeException.class, () -> out.write(99)); + assertThrows(IllegalBlockingModeException.class, () -> out.write(99)); }); } @@ -311,6 +328,7 @@ public class AdaptorStreams { * Test read when there are bytes available and another thread is blocked * in write */ + @Test public void testConcurrentReadWrite1() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -328,13 +346,14 @@ public class AdaptorStreams { // test read when bytes are available peer.getOutputStream().write(99); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test read blocking when another thread is blocked in write */ + @Test public void testConcurrentReadWrite2() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -352,13 +371,14 @@ public class AdaptorStreams { // test read blocking until bytes are available scheduleWrite(peer.getOutputStream(), 99, 500); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test writing when another thread is blocked in read */ + @Test public void testConcurrentReadWrite3() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -372,7 +392,7 @@ public class AdaptorStreams { // test write s.getOutputStream().write(99); int n = peer.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } @@ -380,6 +400,7 @@ public class AdaptorStreams { * Test timed read when there are bytes available and another thread is * blocked in write */ + @Test public void testConcurrentTimedReadWrite1() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -398,13 +419,14 @@ public class AdaptorStreams { peer.getOutputStream().write(99); s.setSoTimeout(60_000); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test timed read blocking when another thread is blocked in write */ + @Test public void testConcurrentTimedReadWrite2() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -423,13 +445,14 @@ public class AdaptorStreams { scheduleWrite(peer.getOutputStream(), 99, 500); s.setSoTimeout(60_000); int n = s.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } /** * Test writing when another thread is blocked in read */ + @Test public void testConcurrentTimedReadWrite3() throws Exception { withConnection((sc, peer) -> { Socket s = sc.socket(); @@ -444,7 +467,7 @@ public class AdaptorStreams { // test write s.getOutputStream().write(99); int n = peer.getInputStream().read(); - assertEquals(n, 99); + assertEquals(99, n); }); } diff --git a/test/jdk/java/nio/channels/Selector/ConnectionRefusedMessage.java b/test/jdk/java/nio/channels/SocketChannel/ConnectionRefusedMessage.java similarity index 92% rename from test/jdk/java/nio/channels/Selector/ConnectionRefusedMessage.java rename to test/jdk/java/nio/channels/SocketChannel/ConnectionRefusedMessage.java index 04490f63efe..d71bc6569cb 100644 --- a/test/jdk/java/nio/channels/Selector/ConnectionRefusedMessage.java +++ b/test/jdk/java/nio/channels/SocketChannel/ConnectionRefusedMessage.java @@ -42,7 +42,8 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; * @summary Verify that when a SocketChannel is registered with a Selector * with an interest in CONNECT operation, then SocketChannel.finishConnect() * throws the correct exception message, if the connect() fails - * @run junit ${test.main.class} + * @run junit/othervm -Djdk.includeInExceptions=hostInfoExclSocket ${test.main.class} + * @run junit/othervm -Djdk.includeInExceptions=hostInfo -Dcheck.relaxed=true ${test.main.class} */ class ConnectionRefusedMessage { @@ -108,10 +109,14 @@ class ConnectionRefusedMessage { } private static void assertExceptionMessage(final ConnectException ce) { - if (!"Connection refused".equals(ce.getMessage())) { - // propagate the original exception - fail("unexpected exception message: " + ce.getMessage(), ce); + if ("Connection refused".equals(ce.getMessage())) { + return; } + if (Boolean.getBoolean("check.relaxed") && ce.getMessage() != null && ce.getMessage().startsWith("Connection refused")) { + return; + } + // propagate the original exception + fail("unexpected exception message: " + ce.getMessage(), ce); } // Try to find a suitable port to provoke a "Connection Refused" error. diff --git a/test/jdk/java/nio/channels/SocketChannel/ConnectionReset.java b/test/jdk/java/nio/channels/SocketChannel/ConnectionReset.java index 759d819fa4f..2d89d708110 100644 --- a/test/jdk/java/nio/channels/SocketChannel/ConnectionReset.java +++ b/test/jdk/java/nio/channels/SocketChannel/ConnectionReset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,9 +21,9 @@ * questions. */ -/** +/* * @test - * @run testng ConnectionReset + * @run junit ConnectionReset * @summary Test behavior of SocketChannel.read and the Socket adaptor read * and available methods when a connection is reset */ @@ -36,12 +36,10 @@ import java.net.ServerSocket; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; -import java.lang.reflect.Method; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; -@Test public class ConnectionReset { static final int REPEAT_COUNT = 5; @@ -50,6 +48,7 @@ public class ConnectionReset { * Tests SocketChannel.read when the connection is reset and there are no * bytes to read. */ + @Test public void testSocketChannelReadNoData() throws IOException { System.out.println("testSocketChannelReadNoData"); withResetConnection(null, sc -> { @@ -69,6 +68,7 @@ public class ConnectionReset { * Tests SocketChannel.read when the connection is reset and there are bytes * to read. */ + @Test public void testSocketChannelReadData() throws IOException { System.out.println("testSocketChannelReadData"); byte[] data = { 1, 2, 3 }; @@ -99,6 +99,7 @@ public class ConnectionReset { * Tests available before Socket read when the connection is reset and there * are no bytes to read. */ + @Test public void testAvailableBeforeSocketReadNoData() throws IOException { System.out.println("testAvailableBeforeSocketReadNoData"); withResetConnection(null, sc -> { @@ -107,7 +108,7 @@ public class ConnectionReset { for (int i=0; i %d%n", bytesAvailable); - assertTrue(bytesAvailable == 0); + assertEquals(0, bytesAvailable); try { int bytesRead = in.read(); if (bytesRead == -1) { @@ -127,6 +128,7 @@ public class ConnectionReset { * Tests available before Socket read when the connection is reset and there * are bytes to read. */ + @Test public void testAvailableBeforeSocketReadData() throws IOException { System.out.println("testAvailableBeforeSocketReadData"); byte[] data = { 1, 2, 3 }; @@ -160,6 +162,7 @@ public class ConnectionReset { * Tests Socket read before available when the connection is reset and there * are no bytes to read. */ + @Test public void testSocketReadNoDataBeforeAvailable() throws IOException { System.out.println("testSocketReadNoDataBeforeAvailable"); withResetConnection(null, sc -> { @@ -179,7 +182,7 @@ public class ConnectionReset { } int bytesAvailable = in.available(); System.out.format("available => %d%n", bytesAvailable); - assertTrue(bytesAvailable == 0); + assertEquals(0, bytesAvailable); } }); } @@ -188,6 +191,7 @@ public class ConnectionReset { * Tests Socket read before available when the connection is reset and there * are bytes to read. */ + @Test public void testSocketReadDataBeforeAvailable() throws IOException { System.out.println("testSocketReadDataBeforeAvailable"); byte[] data = { 1, 2, 3 }; diff --git a/test/jdk/java/nio/channels/SocketChannel/ReadWriteAfterClose.java b/test/jdk/java/nio/channels/SocketChannel/ReadWriteAfterClose.java index 037e750a552..0af09df4949 100644 --- a/test/jdk/java/nio/channels/SocketChannel/ReadWriteAfterClose.java +++ b/test/jdk/java/nio/channels/SocketChannel/ReadWriteAfterClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,9 +21,6 @@ * questions. */ -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import java.io.IOException; import java.net.InetAddress; @@ -34,38 +31,45 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /* * @test * @bug 8246707 - * @library /test/lib * @summary Reading or Writing to a closed SocketChannel should throw a ClosedChannelException - * @run testng/othervm ReadWriteAfterClose + * @run junit/othervm ReadWriteAfterClose */ public class ReadWriteAfterClose { - private ServerSocketChannel listener; - private SocketAddress saddr; + private static ServerSocketChannel listener; + private static SocketAddress saddr; private static final int bufCapacity = 4; private static final int bufArraySize = 4; private static final Class CCE = ClosedChannelException.class; - @BeforeTest - public void setUp() throws IOException { + @BeforeAll + public static void setUp() throws IOException { listener = ServerSocketChannel.open(); listener.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); saddr = listener.getLocalAddress(); } + @AfterAll + public static void tearDown() throws IOException { + if (listener != null) listener.close(); + } + @Test public void testWriteAfterClose1() throws IOException { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer bufWrite = ByteBuffer.allocate(bufCapacity); - Throwable ex = expectThrows(CCE, () -> sc.write(bufWrite)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.write(bufWrite)); + assertSame(CCE, ex.getClass()); } @Test @@ -73,8 +77,8 @@ public class ReadWriteAfterClose { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer[] bufArrayWrite = allocateBufArray(); - Throwable ex = expectThrows(CCE, () -> sc.write(bufArrayWrite)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.write(bufArrayWrite)); + assertSame(CCE, ex.getClass()); } @Test @@ -82,8 +86,8 @@ public class ReadWriteAfterClose { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer[] bufArrayWrite = allocateBufArray(); - Throwable ex = expectThrows(CCE, () -> sc.write(bufArrayWrite, 0, bufArraySize)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.write(bufArrayWrite, 0, bufArraySize)); + assertSame(CCE, ex.getClass()); } @Test @@ -91,8 +95,8 @@ public class ReadWriteAfterClose { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer dst = ByteBuffer.allocate(bufCapacity); - Throwable ex = expectThrows(CCE, () -> sc.read(dst)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.read(dst)); + assertSame(CCE, ex.getClass()); } @Test @@ -100,8 +104,8 @@ public class ReadWriteAfterClose { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer[] dstArray = allocateBufArray(); - Throwable ex = expectThrows(CCE, () -> sc.read(dstArray)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.read(dstArray)); + assertSame(CCE, ex.getClass()); } @Test @@ -109,8 +113,8 @@ public class ReadWriteAfterClose { SocketChannel sc = SocketChannel.open(saddr); sc.close(); ByteBuffer[] dstArray = allocateBufArray(); - Throwable ex = expectThrows(CCE, () -> sc.read(dstArray, 0, bufArraySize)); - assertEquals(ex.getClass(), CCE); + Throwable ex = assertThrows(CCE, () -> sc.read(dstArray, 0, bufArraySize)); + assertSame(CCE, ex.getClass()); } public ByteBuffer[] allocateBufArray() { @@ -120,8 +124,4 @@ public class ReadWriteAfterClose { return bufArr; } - @AfterTest - public void tearDown() throws IOException { - listener.close(); - } } \ No newline at end of file diff --git a/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java b/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java index 63be790c478..60e41af6288 100644 --- a/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java +++ b/test/jdk/java/nio/channels/etc/LocalSocketAddressType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,40 +26,44 @@ * @summary Test local address type * @library /test/lib * @build jdk.test.lib.NetworkConfiguration - * @run testng/othervm LocalSocketAddressType - * @run testng/othervm -Djava.net.preferIPv4Stack=true LocalSocketAddressType + * @run junit/othervm LocalSocketAddressType + * @run junit/othervm -Djava.net.preferIPv4Stack=true LocalSocketAddressType */ import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.net.IPSupport; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import java.net.*; +import java.net.InetAddress; +import java.net.InetSocketAddress; import java.nio.channels.DatagramChannel; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.Iterator; -import java.util.stream.Collectors; import java.util.stream.Stream; -import static java.lang.Boolean.parseBoolean; -import static java.lang.System.getProperty; import static java.lang.System.out; -import static jdk.test.lib.Asserts.assertEquals; -import static jdk.test.lib.Asserts.assertTrue; import static jdk.test.lib.net.IPSupport.*; +import jtreg.SkippedException; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class LocalSocketAddressType { - @BeforeTest() - public void setup() { + @BeforeAll() + public static void setup() { IPSupport.printPlatformSupport(out); - throwSkippedExceptionIfNonOperational(); + try { + throwSkippedExceptionIfNonOperational(); + } catch (SkippedException skippedException) { + // jtreg.SkippedException would cause a JUnit test to fail + Assumptions.assumeTrue(false, skippedException.getMessage()); + } } - @DataProvider(name = "addresses") public static Iterator addresses() throws Exception { NetworkConfiguration nc = NetworkConfiguration.probe(); return Stream.concat(nc.ip4Addresses(), nc.ip6Addresses()) @@ -67,36 +71,39 @@ public class LocalSocketAddressType { .iterator(); } - @Test(dataProvider = "addresses") - public static void testSocketChannel(InetSocketAddress addr) throws Exception { + @ParameterizedTest + @MethodSource("addresses") + public void testSocketChannel(InetSocketAddress addr) throws Exception { try (var c = SocketChannel.open()) { Class cls = addr.getAddress().getClass(); InetAddress ia = ((InetSocketAddress)c.bind(addr).getLocalAddress()).getAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); ia = c.socket().getLocalAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); } } - @Test(dataProvider = "addresses") - public static void testServerSocketChannel(InetSocketAddress addr) throws Exception { + @ParameterizedTest + @MethodSource("addresses") + public void testServerSocketChannel(InetSocketAddress addr) throws Exception { try (var c = ServerSocketChannel.open()) { Class cls = addr.getAddress().getClass(); InetAddress ia = ((InetSocketAddress)c.bind(addr).getLocalAddress()).getAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); ia = c.socket().getInetAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); } } - @Test(dataProvider = "addresses") - public static void testDatagramChannel(InetSocketAddress addr) throws Exception { + @ParameterizedTest + @MethodSource("addresses") + public void testDatagramChannel(InetSocketAddress addr) throws Exception { try (var c = DatagramChannel.open()) { Class cls = addr.getAddress().getClass(); InetAddress ia = ((InetSocketAddress)c.bind(addr).getLocalAddress()).getAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); ia = c.socket().getLocalAddress(); - assertEquals(ia.getClass(), cls); + assertEquals(cls, ia.getClass()); } } } diff --git a/test/jdk/java/nio/channels/etc/OpenAndConnect.java b/test/jdk/java/nio/channels/etc/OpenAndConnect.java index b183076e49d..0e0347ebb57 100644 --- a/test/jdk/java/nio/channels/etc/OpenAndConnect.java +++ b/test/jdk/java/nio/channels/etc/OpenAndConnect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,23 +23,32 @@ import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.net.IPSupport; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; -import java.net.*; -import java.nio.channels.*; -import java.util.Arrays; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ProtocolFamily; +import java.net.SocketAddress; +import java.nio.channels.DatagramChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; import java.util.List; import java.util.LinkedList; -import static java.lang.System.getProperty; import static java.lang.System.out; import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static jdk.test.lib.net.IPSupport.*; +import jtreg.SkippedException; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + /* * @test * @summary Test SocketChannel, ServerSocketChannel and DatagramChannel @@ -48,10 +57,9 @@ import static jdk.test.lib.net.IPSupport.*; * addresses (Inet4Address, Inet6Address). * @library /test/lib * @build jdk.test.lib.NetworkConfiguration - * @run testng/othervm OpenAndConnect + * @run junit/othervm OpenAndConnect */ - public class OpenAndConnect { static final Inet4Address IA4ANYLOCAL; static final Inet6Address IA6ANYLOCAL; @@ -77,11 +85,16 @@ public class OpenAndConnect { } } - @BeforeTest() - public void setup() { + @BeforeAll() + public static void setup() { NetworkConfiguration.printSystemConfiguration(out); IPSupport.printPlatformSupport(out); - throwSkippedExceptionIfNonOperational(); + try { + throwSkippedExceptionIfNonOperational(); + } catch (SkippedException skippedException) { + // jtreg.SkippedException would cause a JUnit test to fail + Assumptions.assumeTrue(false, skippedException.getMessage()); + } out.println("IA4LOCAL: " + IA4LOCAL); out.println("IA6LOCAL: " + IA6LOCAL); @@ -91,9 +104,8 @@ public class OpenAndConnect { out.println("IA6LOOPBACK: " + IA6LOOPBACK); } - @DataProvider(name = "openConnect") - public Object[][] openConnect() { - LinkedList l = new LinkedList<>(); + public static List openConnect() { + LinkedList l = new LinkedList<>(); if (IPSupport.hasIPv4()) { l.addAll(openConnectV4Tests); if (IA4LOCAL != null) { @@ -112,7 +124,7 @@ public class OpenAndConnect { l.addAll(openConnectV4LocalAndV6Tests); } } - return l.toArray(new Object[][]{}); + return l; } // +----- sfam is server/first socket family @@ -127,92 +139,91 @@ public class OpenAndConnect { // | | | | this is address used for connect // | | | | also. // | | | | - // | | | | - // | | | | - // | | | | - // + + + + - // { sfam, saddr, cfam, caddr, } + // | | | +---------------+ + // | | | | + // | | +---------------+ | + // | | | | + // | +---------------+ | | + // | | | | + // +---------------+ | | | + // | | | | + // + + + + + // Arguments.of( sfam, saddr, cfam, caddr, ) // Basic tests for when an IPv4 is available - public static List openConnectV4Tests = - Arrays.asList(new Object[][] { - { INET, IA4LOOPBACK, INET, IA4LOOPBACK }, - { INET, IA4LOOPBACK, null, IA4LOOPBACK }, - { INET, IA4ANYLOCAL, null, IA4LOOPBACK }, - { INET, IA4ANYLOCAL, INET, IA4LOOPBACK }, - { null, IA4LOOPBACK, INET, IA4ANYLOCAL }, - { null, IA4LOOPBACK, INET, IA4LOOPBACK }, - { null, IA4LOOPBACK, INET, null }, - { null, IA4LOOPBACK, null, null } - }); + public static List openConnectV4Tests = + List.of(Arguments.of( INET, IA4LOOPBACK, INET, IA4LOOPBACK ), + Arguments.of( INET, IA4LOOPBACK, null, IA4LOOPBACK ), + Arguments.of( INET, IA4ANYLOCAL, null, IA4LOOPBACK ), + Arguments.of( INET, IA4ANYLOCAL, INET, IA4LOOPBACK ), + Arguments.of( null, IA4LOOPBACK, INET, IA4ANYLOCAL ), + Arguments.of( null, IA4LOOPBACK, INET, IA4LOOPBACK ), + Arguments.of( null, IA4LOOPBACK, INET, null ), + Arguments.of( null, IA4LOOPBACK, null, null ) + ); // Additional tests for when an IPv4 local address is available - public List openConnectV4LocalTests = - Arrays.asList(new Object[][] { - { INET, IA4LOCAL, INET, IA4LOCAL }, - { INET, IA4LOCAL, null, IA4LOCAL }, - { INET, IA4LOCAL, null, DONT_BIND }, - { INET, IA4ANYLOCAL, INET, IA4LOCAL }, - { INET, IA4ANYLOCAL, null, IA4LOCAL }, - { null, IA4LOCAL, INET, IA4ANYLOCAL }, - { null, IA4LOCAL, INET, IA4LOCAL }, - { null, IA4LOCAL, INET, null }, - { null, IA4LOCAL, null, null } - }); + public static List openConnectV4LocalTests = + List.of(Arguments.of( INET, IA4LOCAL, INET, IA4LOCAL ), + Arguments.of( INET, IA4LOCAL, null, IA4LOCAL ), + Arguments.of( INET, IA4LOCAL, null, DONT_BIND ), + Arguments.of( INET, IA4ANYLOCAL, INET, IA4LOCAL ), + Arguments.of( INET, IA4ANYLOCAL, null, IA4LOCAL ), + Arguments.of( null, IA4LOCAL, INET, IA4ANYLOCAL ), + Arguments.of( null, IA4LOCAL, INET, IA4LOCAL ), + Arguments.of( null, IA4LOCAL, INET, null ), + Arguments.of( null, IA4LOCAL, null, null ) + ); // Basic tests for when an IPv6 is available - public List openConnectV6Tests = - Arrays.asList(new Object[][] { - { INET6, IA6ANYLOCAL, null, IA6LOOPBACK }, - { INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK }, - { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }, - { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }, - { null, IA6ANYLOCAL, null, IA6LOOPBACK }, - { null, IA6ANYLOCAL, INET6, IA6LOOPBACK }, - { null, IA6LOOPBACK, INET6, IA6LOOPBACK }, - { null, IA6LOOPBACK, INET6, DONT_BIND }, - { null, IA6LOOPBACK, INET6, null }, - { null, IA6LOOPBACK, null, IA6LOOPBACK }, - { null, IA6LOOPBACK, null, null }, - { null, IA6LOOPBACK, INET6, IA6ANYLOCAL }, - { null, IA6LOOPBACK, null, IA6ANYLOCAL } - }); + public static List openConnectV6Tests = + List.of(Arguments.of( INET6, IA6ANYLOCAL, null, IA6LOOPBACK ), + Arguments.of( INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK ), + Arguments.of( INET6, IA6LOOPBACK, INET6, IA6LOOPBACK ), + Arguments.of( INET6, IA6LOOPBACK, INET6, IA6LOOPBACK ), + Arguments.of( null, IA6ANYLOCAL, null, IA6LOOPBACK ), + Arguments.of( null, IA6ANYLOCAL, INET6, IA6LOOPBACK ), + Arguments.of( null, IA6LOOPBACK, INET6, IA6LOOPBACK ), + Arguments.of( null, IA6LOOPBACK, INET6, DONT_BIND ), + Arguments.of( null, IA6LOOPBACK, INET6, null ), + Arguments.of( null, IA6LOOPBACK, null, IA6LOOPBACK ), + Arguments.of( null, IA6LOOPBACK, null, null ), + Arguments.of( null, IA6LOOPBACK, INET6, IA6ANYLOCAL ), + Arguments.of( null, IA6LOOPBACK, null, IA6ANYLOCAL ) + ); // Additional tests for when an IPv6 local address is available - public List openConnectV6LocalTests = - Arrays.asList(new Object[][] { - { INET6, IA6ANYLOCAL, null, IA6LOCAL }, - { INET6, IA6ANYLOCAL, INET6, IA6LOCAL }, - { INET6, IA6LOCAL, INET6, IA6LOCAL }, - { INET6, IA6LOCAL, null, IA6LOCAL }, - { INET6, IA6LOCAL, null, DONT_BIND }, - { INET6, IA6LOCAL, INET6, IA6LOCAL }, - { null, IA6ANYLOCAL, null, IA6LOCAL }, - { null, IA6ANYLOCAL, INET6, IA6LOCAL }, - { null, IA6LOCAL, INET6, IA6LOCAL }, - { null, IA6LOCAL, INET6, IA6ANYLOCAL }, - { null, IA6LOCAL, null, IA6ANYLOCAL }, - { null, IA6LOCAL, null, IA6LOCAL }, - { null, IA6LOCAL, INET6, null }, - { null, IA6LOCAL, null, null } - }); + public static List openConnectV6LocalTests = + List.of(Arguments.of( INET6, IA6ANYLOCAL, null, IA6LOCAL ), + Arguments.of( INET6, IA6ANYLOCAL, INET6, IA6LOCAL ), + Arguments.of( INET6, IA6LOCAL, INET6, IA6LOCAL ), + Arguments.of( INET6, IA6LOCAL, null, IA6LOCAL ), + Arguments.of( INET6, IA6LOCAL, null, DONT_BIND ), + Arguments.of( INET6, IA6LOCAL, INET6, IA6LOCAL ), + Arguments.of( null, IA6ANYLOCAL, null, IA6LOCAL ), + Arguments.of( null, IA6ANYLOCAL, INET6, IA6LOCAL ), + Arguments.of( null, IA6LOCAL, INET6, IA6LOCAL ), + Arguments.of( null, IA6LOCAL, INET6, IA6ANYLOCAL ), + Arguments.of( null, IA6LOCAL, null, IA6ANYLOCAL ), + Arguments.of( null, IA6LOCAL, null, IA6LOCAL ), + Arguments.of( null, IA6LOCAL, INET6, null ), + Arguments.of( null, IA6LOCAL, null, null ) + ); // Additional tests for when IPv4 and IPv6 are available - public List openConnectV4AndV6Tests = - Arrays.asList(new Object[][] { - { null, IA4LOOPBACK, INET6, IA6ANYLOCAL }, - { null, IA4LOOPBACK, null, IA6ANYLOCAL }, - { null, IA4LOOPBACK, INET6, DONT_BIND }, - { null, IA4LOOPBACK, INET6, null } - }); + public static List openConnectV4AndV6Tests = + List.of(Arguments.of( null, IA4LOOPBACK, INET6, IA6ANYLOCAL ), + Arguments.of( null, IA4LOOPBACK, null, IA6ANYLOCAL ), + Arguments.of( null, IA4LOOPBACK, INET6, DONT_BIND ), + Arguments.of( null, IA4LOOPBACK, INET6, null ) + ); // Additional tests for when IPv4 local address and IPv6 are available - public List openConnectV4LocalAndV6Tests = - Arrays.asList(new Object[][] { - { null, IA4LOCAL, INET6, IA6ANYLOCAL }, - { null, IA4LOCAL, INET6, null }, - { null, IA4LOCAL, null, IA6ANYLOCAL } - }); + public static List openConnectV4LocalAndV6Tests = + List.of(Arguments.of( null, IA4LOCAL, INET6, IA6ANYLOCAL ), + Arguments.of( null, IA4LOCAL, INET6, null ), + Arguments.of( null, IA4LOCAL, null, IA6ANYLOCAL ) + ); /** * If the destination address is the wildcard, it is replaced by the alternate @@ -227,7 +238,8 @@ public class OpenAndConnect { return isa; } - @Test(dataProvider = "openConnect") + @ParameterizedTest + @MethodSource("openConnect") public void scOpenAndConnect(ProtocolFamily sfam, InetAddress saddr, ProtocolFamily cfam, @@ -248,7 +260,8 @@ public class OpenAndConnect { } } - @Test(dataProvider = "openConnect") + @ParameterizedTest + @MethodSource("openConnect") public void dcOpenAndConnect(ProtocolFamily sfam, InetAddress saddr, ProtocolFamily cfam, diff --git a/test/jdk/java/nio/channels/etc/ProtocolFamilies.java b/test/jdk/java/nio/channels/etc/ProtocolFamilies.java index 45226e9a97e..7f823ff35a8 100644 --- a/test/jdk/java/nio/channels/etc/ProtocolFamilies.java +++ b/test/jdk/java/nio/channels/etc/ProtocolFamilies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,20 +23,38 @@ import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.net.IPSupport; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.Assert.ThrowingRunnable; + import java.io.IOException; -import java.net.*; -import java.nio.channels.*; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ProtocolFamily; +import java.net.SocketAddress; +import java.net.StandardProtocolFamily; +import java.net.UnknownHostException; +import java.nio.channels.DatagramChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.nio.channels.UnsupportedAddressTypeException; import java.nio.channels.spi.SelectorProvider; +import java.util.List; + import static java.lang.System.out; import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; import static jdk.test.lib.net.IPSupport.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; + +import jtreg.SkippedException; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test @@ -44,8 +62,8 @@ import static org.testng.Assert.assertThrows; * with various ProtocolFamily combinations * @library /test/lib * @build jdk.test.lib.NetworkConfiguration - * @run testng ProtocolFamilies - * @run testng/othervm -Djava.net.preferIPv4Stack=true ProtocolFamilies + * @run junit ProtocolFamilies + * @run junit/othervm -Djava.net.preferIPv4Stack=true ProtocolFamilies */ @@ -55,11 +73,16 @@ public class ProtocolFamilies { static Inet4Address ia4; static Inet6Address ia6; - @BeforeTest() - public void setup() throws Exception { + @BeforeAll() + public static void setup() throws Exception { NetworkConfiguration.printSystemConfiguration(out); IPSupport.printPlatformSupport(out); - throwSkippedExceptionIfNonOperational(); + try { + throwSkippedExceptionIfNonOperational(); + } catch (SkippedException skippedException) { + // jtreg.SkippedException would cause a JUnit test to fail + Assumptions.assumeTrue(false, skippedException.getMessage()); + } ia4 = getLocalIPv4Address(); ia6 = getLocalIPv6Address(); @@ -70,111 +93,89 @@ public class ProtocolFamilies { static final Class UATE = UnsupportedAddressTypeException.class; static final Class UOE = UnsupportedOperationException.class; - @DataProvider(name = "open") - public Object[][] open() { + public static List open() { if (hasIPv6 && !preferIPv4) { - return new Object[][]{ - { INET, null }, - { INET6, null } - }; + return List.of( + Arguments.of( INET, null ), + Arguments.of( INET6, null ) + ); } else { - return new Object[][]{ - { INET, null }, - { INET6, UOE } - }; + return List.of( + Arguments.of( INET, null ), + Arguments.of( INET6, UOE ) + ); } } - @Test(dataProvider = "open") + @ParameterizedTest + @MethodSource("open") public void scOpen(StandardProtocolFamily family, Class expectedException) - throws Throwable + throws IOException { - SocketChannel sc = null; - try { - if (expectedException == UOE) { - try { - sc = openSC(family); - } catch (UnsupportedOperationException e) {} - } else { - sc = openSC(family); - } - } finally { - if (sc != null) - sc.close(); + if (expectedException != null) { + assertThrows(expectedException, () -> openSC(family)); + } else { + try (var _ = openSC(family)) { } } } - @Test(dataProvider = "open") + @ParameterizedTest + @MethodSource("open") public void sscOpen(StandardProtocolFamily family, Class expectedException) - throws Throwable + throws IOException { - ServerSocketChannel ssc = null; - try { - if (expectedException == UOE) { - try { - ssc = openSSC(family); - } catch (UnsupportedOperationException e) {} - } else { - openSSC(family); - } - } finally { - if (ssc != null) - ssc.close(); + if (expectedException != null) { + assertThrows(expectedException, () -> openSSC(family)); + } else { + try (var _ = openSSC(family)) { } } } - @Test(dataProvider = "open") + @ParameterizedTest + @MethodSource("open") public void dcOpen(StandardProtocolFamily family, Class expectedException) - throws Throwable + throws IOException { - DatagramChannel dc = null; - try { - if (expectedException == UOE) { - try { - dc = openDC(family); - } catch (UnsupportedOperationException e) {} - } else { - openDC(family); - } - } finally { - if (dc != null) - dc.close(); + if (expectedException != null) { + assertThrows(expectedException, () -> openDC(family)); + } else { + try (var _ = openDC(family)) { } } } - @DataProvider(name = "openBind") - public Object[][] openBind() { + public static List openBind() { if (hasIPv6 && !preferIPv4) { - return new Object[][]{ - { INET, INET, null }, - { INET, INET6, UATE }, - { INET, null, null }, - { INET6, INET, null }, - { INET6, INET6, null }, - { INET6, null, null }, - { null, INET, null }, - { null, INET6, null }, - { null, null, null } - }; + return List.of( + Arguments.of( INET, INET, null ), + Arguments.of( INET, INET6, UATE ), + Arguments.of( INET, null, null ), + Arguments.of( INET6, INET, null ), + Arguments.of( INET6, INET6, null ), + Arguments.of( INET6, null, null ), + Arguments.of( null, INET, null ), + Arguments.of( null, INET6, null ), + Arguments.of( null, null, null ) + ); } else { - return new Object[][]{ - { INET, INET, null }, - { INET, INET6, UATE }, - { INET, null, null }, - { null, INET, null }, - { null, INET6, UATE }, - { null, null, null } - }; + return List.of( + Arguments.of( INET, INET, null ), + Arguments.of( INET, INET6, UATE ), + Arguments.of( INET, null, null ), + Arguments.of( null, INET, null ), + Arguments.of( null, INET6, UATE ), + Arguments.of( null, null, null ) + ); } } // SocketChannel open - INET, INET6, default // SocketChannel bind - INET, INET6, null - @Test(dataProvider = "openBind") + @ParameterizedTest + @MethodSource("openBind") public void scOpenBind(StandardProtocolFamily ofamily, StandardProtocolFamily bfamily, Class expectedException) @@ -182,9 +183,9 @@ public class ProtocolFamilies { { try (SocketChannel sc = openSC(ofamily)) { SocketAddress addr = getSocketAddress(bfamily); - ThrowingRunnable bindOp = () -> sc.bind(addr); - if (expectedException == null) - bindOp.run(); + Executable bindOp = () -> sc.bind(addr); + if (expectedException == null) + bindOp.execute(); else assertThrows(expectedException, bindOp); } @@ -193,7 +194,8 @@ public class ProtocolFamilies { // ServerSocketChannel open - INET, INET6, default // ServerSocketChannel bind - INET, INET6, null - @Test(dataProvider = "openBind") + @ParameterizedTest + @MethodSource("openBind") public void sscOpenBind(StandardProtocolFamily ofamily, StandardProtocolFamily bfamily, Class expectedException) @@ -201,9 +203,9 @@ public class ProtocolFamilies { { try (ServerSocketChannel ssc = openSSC(ofamily)) { SocketAddress addr = getSocketAddress(bfamily); - ThrowingRunnable bindOp = () -> ssc.bind(addr); + Executable bindOp = () -> ssc.bind(addr); if (expectedException == null) - bindOp.run(); + bindOp.execute(); else assertThrows(expectedException, bindOp); } @@ -212,7 +214,8 @@ public class ProtocolFamilies { // DatagramChannel open - INET, INET6, default // DatagramChannel bind - INET, INET6, null - @Test(dataProvider = "openBind") + @ParameterizedTest + @MethodSource("openBind") public void dcOpenBind(StandardProtocolFamily ofamily, StandardProtocolFamily bfamily, Class expectedException) @@ -220,9 +223,9 @@ public class ProtocolFamilies { { try (DatagramChannel dc = openDC(ofamily)) { SocketAddress addr = getSocketAddress(bfamily); - ThrowingRunnable bindOp = () -> dc.bind(addr); + Executable bindOp = () -> dc.bind(addr); if (expectedException == null) - bindOp.run(); + bindOp.execute(); else assertThrows(expectedException, bindOp); } @@ -231,32 +234,32 @@ public class ProtocolFamilies { // SocketChannel open - INET, INET6, default // SocketChannel connect - INET, INET6, default - @DataProvider(name = "openConnect") - public Object[][] openConnect() { + public static List openConnect() { if (hasIPv6 && !preferIPv4) { - return new Object[][]{ - { INET, INET, null }, - { INET, INET6, null }, - { INET, null, null }, - { INET6, INET, UATE }, - { INET6, INET6, null }, - { INET6, null, null }, - { null, INET, UATE }, - { null, INET6, null }, - { null, null, null } - }; + return List.of( + Arguments.of( INET, INET, null ), + Arguments.of( INET, INET6, null ), + Arguments.of( INET, null, null ), + Arguments.of( INET6, INET, UATE ), + Arguments.of( INET6, INET6, null ), + Arguments.of( INET6, null, null ), + Arguments.of( null, INET, UATE ), + Arguments.of( null, INET6, null ), + Arguments.of( null, null, null ) + ); } else { // INET6 channels cannot be created - UOE - tested elsewhere - return new Object[][]{ - { INET, INET, null }, - { INET, null, null }, - { null, INET, null }, - { null, null, null } - }; + return List.of( + Arguments.of( INET, INET, null ), + Arguments.of( INET, null, null ), + Arguments.of( null, INET, null ), + Arguments.of( null, null, null ) + ); } } - @Test(dataProvider = "openConnect") + @ParameterizedTest + @MethodSource("openConnect") public void scOpenConnect(StandardProtocolFamily sfamily, StandardProtocolFamily cfamily, Class expectedException) @@ -279,7 +282,7 @@ public class ProtocolFamilies { // Tests null handling @Test public void testNulls() { - assertThrows(NPE, () -> SocketChannel.open((ProtocolFamily)null)); + assertThrows(NPE, () -> SocketChannel.open((ProtocolFamily) null)); assertThrows(NPE, () -> ServerSocketChannel.open(null)); assertThrows(NPE, () -> DatagramChannel.open(null)); diff --git a/test/jdk/java/nio/channels/spi/SelectorProvider/TestDefaultImplementation.java b/test/jdk/java/nio/channels/spi/SelectorProvider/TestDefaultImplementation.java index 6d402949982..e17b16dadc7 100644 --- a/test/jdk/java/nio/channels/spi/SelectorProvider/TestDefaultImplementation.java +++ b/test/jdk/java/nio/channels/spi/SelectorProvider/TestDefaultImplementation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,19 +25,22 @@ * @test * @bug 8254692 * @summary Basic test for java.nio.channels.spi.SelectorProvider.java default implementation - * @run testng TestDefaultImplementation + * @run junit TestDefaultImplementation */ -import org.testng.annotations.Test; - import java.io.IOException; import java.net.ProtocolFamily; -import java.nio.channels.*; +import java.nio.channels.DatagramChannel; +import java.nio.channels.Pipe; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; import java.nio.channels.spi.AbstractSelector; import java.nio.channels.spi.SelectorProvider; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; public class TestDefaultImplementation { static final Class UOE = UnsupportedOperationException.class; @@ -67,4 +70,4 @@ public class TestDefaultImplementation { @Override public ServerSocketChannel openServerSocketChannel() { return null; } @Override public SocketChannel openSocketChannel() { return null; } } -} \ No newline at end of file +} diff --git a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java index 934bf509d88..897fc6236dc 100644 --- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java +++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -36,7 +36,7 @@ * UnixSocketTest StateTest StateTestService EchoTest EchoService * UnixDomainChannelTest CloseTest Launcher Util * CheckIPv6Test CheckIPv6Service - * @run testng/othervm/native InheritedChannelTest + * @run junit/othervm/native InheritedChannelTest * @key intermittent */ @@ -45,14 +45,16 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Platform; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.Arrays.asList; @@ -64,19 +66,18 @@ public class InheritedChannelTest { private static final Path libraryPath = Paths.get(System.getProperty("java.library.path")); - @DataProvider - public Object[][] testCases() { - return new Object[][] { - { "UnixDomainChannelTest", List.of(UnixDomainChannelTest.class.getName())}, - { "UnixSocketTest", List.of(UnixSocketTest.class.getName())}, - { "StateTest", List.of(StateTest.class.getName(), "-Dtest.classes="+TEST_CLASSES)}, - { "EchoTest", List.of(EchoTest.class.getName()) }, - { "CheckIPv6Test", List.of(CheckIPv6Test.class.getName()) }, - { "CloseTest", List.of(CloseTest.class.getName()) }, - }; + public static Stream testCases() { + return Stream.of + (Arguments.of( "UnixDomainChannelTest", List.of(UnixDomainChannelTest.class.getName())), + Arguments.of( "UnixSocketTest", List.of(UnixSocketTest.class.getName())), + Arguments.of( "StateTest", List.of(StateTest.class.getName(), "-Dtest.classes="+TEST_CLASSES)), + Arguments.of( "EchoTest", List.of(EchoTest.class.getName())), + Arguments.of( "CheckIPv6Test", List.of(CheckIPv6Test.class.getName())), + Arguments.of( "CloseTest", List.of(CloseTest.class.getName()))); } - @Test(dataProvider = "testCases") + @ParameterizedTest + @MethodSource("testCases") public void test(String desc, List opts) throws Throwable { String pathVar = Platform.sharedLibraryPathVariableName(); System.out.println(pathVar + "=" + libraryPath); diff --git a/test/jdk/java/nio/channels/unixdomain/EmptySunPathForSocketFile.java b/test/jdk/java/nio/channels/unixdomain/EmptySunPathForSocketFile.java index 79f8ead7aa2..ec47babdff3 100644 --- a/test/jdk/java/nio/channels/unixdomain/EmptySunPathForSocketFile.java +++ b/test/jdk/java/nio/channels/unixdomain/EmptySunPathForSocketFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,11 +21,11 @@ * questions. */ -/** +/* * @test * @bug 8256461 * @modules java.base/sun.nio.fs - * @run testng EmptySunPathForSocketFile + * @run junit EmptySunPathForSocketFile */ import java.nio.file.FileSystems; @@ -33,7 +33,8 @@ import java.nio.file.Path; import java.nio.file.spi.FileSystemProvider; import sun.nio.fs.AbstractFileSystemProvider; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * Check that AbstractFileSystemProvider.getSunPathForSocketFile with @@ -41,9 +42,14 @@ import static org.testng.Assert.assertEquals; */ public class EmptySunPathForSocketFile { public static void main(String[] args) throws Exception { + new EmptySunPathForSocketFile().test(); + } + + @Test + public void test() { Path path = Path.of(""); FileSystemProvider provider = FileSystems.getDefault().provider(); byte[] bb = ((AbstractFileSystemProvider) provider).getSunPathForSocketFile(path); - assertEquals(bb, new byte[0]); + assertArrayEquals(new byte[0], bb); } } diff --git a/test/jdk/java/nio/channels/unixdomain/FileAttributes.java b/test/jdk/java/nio/channels/unixdomain/FileAttributes.java index 3ff92a6bc05..5e9b65f90b2 100644 --- a/test/jdk/java/nio/channels/unixdomain/FileAttributes.java +++ b/test/jdk/java/nio/channels/unixdomain/FileAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,35 +21,34 @@ * questions. */ -/** +/* * @test * @bug 8252971 - * @library /test/lib - * @run testng FileAttributes + * @run junit FileAttributes */ import java.io.IOException; import java.io.File; -import java.net.*; -import java.nio.channels.*; +import java.net.UnixDomainSocketAddress; +import java.nio.channels.SocketChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; -import java.util.Arrays; -import org.testng.annotations.Test; -import org.testng.SkipException; import static java.net.StandardProtocolFamily.UNIX; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** */ public class FileAttributes { @Test - public static void test() throws Exception { + public void test() throws Exception { checkSupported(); Path path = null; try (var chan = SocketChannel.open(UNIX)) { @@ -89,7 +88,7 @@ public class FileAttributes { try { SocketChannel.open(UNIX).close(); } catch (UnsupportedOperationException e) { - throw new SkipException("Unix domain channels not supported"); + Assumptions.assumeTrue(false, "Unix domain channels not supported"); } catch (Exception e) { // continue test to see what problem is } diff --git a/test/jdk/java/nio/channels/unixdomain/IOExchanges.java b/test/jdk/java/nio/channels/unixdomain/IOExchanges.java index 33a7b5ef3c4..9924d02504a 100644 --- a/test/jdk/java/nio/channels/unixdomain/IOExchanges.java +++ b/test/jdk/java/nio/channels/unixdomain/IOExchanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,38 +21,45 @@ * questions. */ -/** +/* * @test * @bug 8245194 - * @run testng/othervm/timeout=480 IOExchanges + * @run junit/othervm/timeout=480 IOExchanges */ import java.io.IOException; -import java.net.*; -import java.nio.channels.*; +import java.net.ProtocolFamily; +import java.net.SocketAddress; +import java.net.UnixDomainSocketAddress; import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; import java.nio.file.Files; +import java.util.List; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.net.StandardProtocolFamily.*; import static java.nio.channels.SelectionKey.OP_ACCEPT; import static java.nio.channels.SelectionKey.OP_READ; import static java.nio.channels.SelectionKey.OP_WRITE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class IOExchanges { static boolean unixDomainSupported = true; - @BeforeTest() - public void setup() { + @BeforeAll() + public static void setup() { try { - SocketChannel.open(UNIX); + SocketChannel.open(UNIX).close(); } catch (IOException | UnsupportedOperationException e) { unixDomainSupported = false; out.println("Unix domain channels not supported"); @@ -72,8 +79,8 @@ public class IOExchanges { } public static void deleteFile(SocketAddress addr) throws Exception { - if (addr instanceof UnixDomainSocketAddress) { - Files.deleteIfExists(((UnixDomainSocketAddress) addr).getPath()); + if (addr instanceof UnixDomainSocketAddress uaddr) { + Files.deleteIfExists(uaddr.getPath()); } } @@ -118,18 +125,12 @@ public class IOExchanges { SPINBAccep_NBConn_NBIO_RW_12a */ - @DataProvider(name = "family") - public Object[][] family() { - return unixDomainSupported ? - new Object[][] { - { UNIX }, - { INET }} - : new Object[][] { - { INET } - }; + public static List family() { + return unixDomainSupported ? List.of(INET, UNIX) : List.of(INET); } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_BConn_BIO_WR_1(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -140,25 +141,26 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x01).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } }); t.start(); try (SocketChannel sc = ssc.accept()) { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x01); + assertEquals(0x01, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_BConn_BIO_RW_2(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -169,25 +171,26 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x02); + assertEquals(0x02, bb.get(0)); } }); t.start(); try (SocketChannel sc = ssc.accept()) { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x02).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_BConn_BIO_WR_3(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family); @@ -199,28 +202,29 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x03).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } }); t.start(); ssc.configureBlocking(false).register(selector, OP_ACCEPT); - assertEquals(selector.select(), 1); + assertEquals(1, selector.select()); try (SocketChannel sc = ssc.accept()) { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x03); + assertEquals(0x03, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_BConn_BIO_RW_4(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family); @@ -232,21 +236,21 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x04); + assertEquals(0x04, bb.get(0)); } }); t.start(); ssc.configureBlocking(false).register(selector, OP_ACCEPT); - assertEquals(selector.select(), 1); + assertEquals(1, selector.select()); try (SocketChannel sc = ssc.accept()) { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x04).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } t.awaitCompletion(); @@ -254,7 +258,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_BConn_BIO_WR_5(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -265,9 +270,9 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x05).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } }); t.start(); @@ -284,16 +289,17 @@ public class IOExchanges { try (SocketChannel sc = accepted) { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x05); + assertEquals(0x05, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_BConn_BIO_RW_6(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -304,9 +310,9 @@ public class IOExchanges { try (SocketChannel sc = openSocketChannel(family)) { assertTrue(sc.connect(addr)); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x06); + assertEquals(0x06, bb.get(0)); } }); t.start(); @@ -323,9 +329,9 @@ public class IOExchanges { try (SocketChannel sc = accepted) { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x06).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); } t.awaitCompletion(); @@ -336,7 +342,8 @@ public class IOExchanges { // Similar to the previous six scenarios, but with same-thread // non-blocking connect. - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_NBConn_BIO_WR_7(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -352,16 +359,16 @@ public class IOExchanges { sc.configureBlocking(true); TestThread t = TestThread.of("t7", () -> { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x07).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc2.read(bb), 1); + assertEquals(1, sc2.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x07); + assertEquals(0x07, bb.get(0)); sc2.shutdownOutput(); t.awaitCompletion(); } @@ -370,7 +377,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_NBConn_BIO_RW_8(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -386,17 +394,17 @@ public class IOExchanges { sc.configureBlocking(true); TestThread t = TestThread.of("t8", () -> { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x08); + assertEquals(0x08, bb.get(0)); sc.shutdownOutput(); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x08).flip(); - assertEquals(sc2.write(bb), 1); + assertEquals(1, sc2.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc2.read(bb.clear()), -1); + assertEquals(-1, sc2.read(bb.clear())); t.awaitCompletion(); } } @@ -404,7 +412,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_NBConn_BIO_WR_9(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -417,23 +426,23 @@ public class IOExchanges { sc.connect(addr); ssc.configureBlocking(false).register(selector, OP_ACCEPT); - assertEquals(selector.select(), 1); + assertEquals(1, selector.select()); try (SocketChannel sc2 = ssc.accept()) { assertTrue(sc.finishConnect()); sc.configureBlocking(true); TestThread t = TestThread.of("t9", () -> { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x09).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc2.read(bb), 1); + assertEquals(1, sc2.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x09); + assertEquals(0x09, bb.get(0)); sc2.shutdownOutput(); t.awaitCompletion(); } @@ -442,7 +451,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_NBConn_BIO_RW_10(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -455,24 +465,24 @@ public class IOExchanges { sc.connect(addr); ssc.configureBlocking(false).register(selector, OP_ACCEPT); - assertEquals(selector.select(), 1); + assertEquals(1, selector.select()); try (SocketChannel sc2 = ssc.accept()) { assertTrue(sc.finishConnect()); sc.configureBlocking(true); TestThread t = TestThread.of("t10", () -> { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x10); + assertEquals(0x10, bb.get(0)); sc.shutdownOutput(); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x10).flip(); - assertEquals(sc2.write(bb), 1); + assertEquals(1, sc2.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc2.read(bb.clear()), -1); + assertEquals(-1, sc2.read(bb.clear())); t.awaitCompletion(); } } @@ -480,7 +490,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_NBConn_BIO_WR_11(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -506,16 +517,16 @@ public class IOExchanges { sc.configureBlocking(true); TestThread t = TestThread.of("t11", () -> { ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x11).flip(); - assertEquals(sc.write(bb), 1); + assertEquals(1, sc.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc.read(bb.clear()), -1); + assertEquals(-1, sc.read(bb.clear())); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc2.read(bb), 1); + assertEquals(1, sc2.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x11); + assertEquals(0x11, bb.get(0)); sc2.shutdownOutput(); t.awaitCompletion(); } @@ -524,7 +535,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_NBConn_BIO_RW_12(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -550,17 +562,17 @@ public class IOExchanges { sc.configureBlocking(true); TestThread t = TestThread.of("t12", () -> { ByteBuffer bb = ByteBuffer.allocate(10); - assertEquals(sc.read(bb), 1); + assertEquals(1, sc.read(bb)); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x12); + assertEquals(0x12, bb.get(0)); sc.shutdownOutput(); }); t.start(); ByteBuffer bb = ByteBuffer.allocate(10).put((byte) 0x12).flip(); - assertEquals(sc2.write(bb), 1); + assertEquals(1, sc2.write(bb)); out.printf("wrote: 0x%x%n", bb.get(0)); - assertEquals(sc2.read(bb.clear()), -1); + assertEquals(-1, sc2.read(bb.clear())); t.awaitCompletion(); } } @@ -572,7 +584,8 @@ public class IOExchanges { // Similar to the previous twelve scenarios but with non-blocking IO // --- - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_BConn_NBIO_WR_1a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -589,13 +602,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); @@ -608,16 +621,17 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x1A); + assertEquals(0x1A, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_BConn_NBIO_RW_2a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -634,9 +648,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x2A); + assertEquals(0x2A, bb.get(0)); } }); t.start(); @@ -649,20 +663,21 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_BConn_NBIO_WR_3a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family); @@ -680,19 +695,19 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); ssc.configureBlocking(false).register(aselector, OP_ACCEPT); - assertEquals(aselector.select(), 1); + assertEquals(1, aselector.select()); try (SocketChannel sc = ssc.accept(); Selector selector = Selector.open()) { @@ -702,16 +717,17 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x3A); + assertEquals(0x3A, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_BConn_NBIO_RW_4a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family); @@ -729,15 +745,15 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x4A); + assertEquals(0x4A, bb.get(0)); } }); t.start(); ssc.configureBlocking(false).register(aselector, OP_ACCEPT); - assertEquals(aselector.select(), 1); + assertEquals(1, aselector.select()); try (SocketChannel sc = ssc.accept(); Selector selector = Selector.open()) { @@ -747,20 +763,21 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_BConn_NBIO_WR_5a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -777,13 +794,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); @@ -806,16 +823,17 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x5A); + assertEquals(0x5A, bb.get(0)); } t.awaitCompletion(); deleteFile(addr); } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINNBAccep_BConn_NBIO_RW_6a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -832,9 +850,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x6A); + assertEquals(0x6A, bb.get(0)); } }); t.start(); @@ -857,13 +875,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); @@ -874,7 +892,8 @@ public class IOExchanges { // Similar to the previous six scenarios but with same-thread // non-blocking connect. - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_NBConn_NBIO_WR_7a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -895,13 +914,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); @@ -913,9 +932,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), 0x7A); + assertEquals(0x7A, bb.get(0)); sc2.shutdownOutput(); } t.awaitCompletion(); @@ -925,7 +944,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void BAccep_NBConn_NBIO_RW_8a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -945,9 +965,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), (byte) 0x8A); + assertEquals((byte) 0x8A, bb.get(0)); sc.shutdownOutput(); } }); @@ -960,13 +980,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); } @@ -975,7 +995,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_NBConn_NBIO_WR_9a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -988,7 +1009,7 @@ public class IOExchanges { Selector aselector = Selector.open(); ssc.configureBlocking(false).register(aselector, OP_ACCEPT); - assertEquals(aselector.select(), 1); + assertEquals(1, aselector.select()); try (SocketChannel sc2 = ssc.accept()) { assertTrue(sc.finishConnect()); @@ -1000,13 +1021,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); @@ -1018,9 +1039,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), (byte) 0x9A); + assertEquals((byte) 0x9A, bb.get(0)); sc2.shutdownOutput(); } t.awaitCompletion(); @@ -1030,7 +1051,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SELNBAccep_NBConn_NBIO_RW_10a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -1043,7 +1065,7 @@ public class IOExchanges { Selector aselector = Selector.open(); ssc.configureBlocking(false).register(aselector, OP_ACCEPT); - assertEquals(aselector.select(), 1); + assertEquals(1, aselector.select()); try (SocketChannel sc2 = ssc.accept()) { assertTrue(sc.finishConnect()); @@ -1054,9 +1076,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), (byte) 0xAA); + assertEquals((byte) 0xAA, bb.get(0)); sc.shutdownOutput(); } }); @@ -1069,13 +1091,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); } @@ -1084,7 +1106,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINBAccep_NBConn_NBIO_WR_11a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -1115,13 +1138,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } }); t.start(); @@ -1133,9 +1156,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), (byte) 0xBA); + assertEquals((byte) 0xBA, bb.get(0)); sc2.shutdownOutput(); } t.awaitCompletion(); @@ -1145,7 +1168,8 @@ public class IOExchanges { } } - @Test(dataProvider = "family") + @ParameterizedTest + @MethodSource("family") public void SPINBAccep_NBConn_NBIO_RW_12a(ProtocolFamily family) throws Throwable { try (ServerSocketChannel ssc = openServerSocketChannel(family)) { @@ -1175,9 +1199,9 @@ public class IOExchanges { selector.select(); int c; while ((c = sc.read(bb)) == 0) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("read: 0x%x%n", bb.get(0)); - assertEquals(bb.get(0), (byte) 0xCA); + assertEquals((byte) 0xCA, bb.get(0)); sc.shutdownOutput(); } }); @@ -1190,13 +1214,13 @@ public class IOExchanges { selector.select(); int c; while ((c = sc2.write(bb)) < 1) ; - assertEquals(c, 1); + assertEquals(1, c); out.printf("wrote: 0x%x%n", bb.get(0)); k.interestOps(OP_READ); selector.select(); bb.clear(); while ((c = sc2.read(bb)) == 0) ; - assertEquals(c, -1); + assertEquals(-1, c); } t.awaitCompletion(); } diff --git a/test/jdk/java/nio/channels/unixdomain/NullTest.java b/test/jdk/java/nio/channels/unixdomain/NullTest.java index ed96cfdecc9..97a5b1d1b8e 100644 --- a/test/jdk/java/nio/channels/unixdomain/NullTest.java +++ b/test/jdk/java/nio/channels/unixdomain/NullTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,10 +21,10 @@ * questions. */ -/** +/* * @test * @bug 8245194 - * @run testng NullTest + * @run junit NullTest */ import java.net.ProtocolFamily; @@ -32,8 +32,9 @@ import java.net.SocketAddress; import java.net.UnixDomainSocketAddress; import java.nio.channels.*; import java.nio.file.Path; -import org.testng.annotations.Test; -import static org.testng.Assert.assertThrows; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Check for NPE @@ -45,7 +46,7 @@ public class NullTest { NullPointerException.class; @Test - public static void runTest() throws Exception { + public void runTest() throws Exception { assertThrows(NPE, () -> SocketChannel.open((ProtocolFamily)null)); assertThrows(NPE, () -> SocketChannel.open((SocketAddress)null)); assertThrows(NPE, () -> ServerSocketChannel.open((ProtocolFamily)null)); diff --git a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java index be33ecb70f2..f3caf94775e 100644 --- a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java +++ b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,22 +34,19 @@ * jdk.test.lib.Platform * jdk.test.lib.process.* * Default - * @run testng DefaultCharsetTest + * @run junit DefaultCharsetTest */ -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import java.util.Map; +import java.util.stream.Stream; -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultCharsetTest { @@ -58,28 +55,27 @@ public class DefaultCharsetTest { private static final Map env = pb.environment(); private static String UNSUPPORTED = null; - @BeforeClass + @BeforeAll public static void checkSupports() throws Exception { UNSUPPORTED = runWithLocale("nonexist"); } - @DataProvider - public static Iterator locales() { - List data = new ArrayList<>(); - data.add(new String[]{"en_US", "iso-8859-1"}); - data.add(new String[]{"ja_JP.utf8", "utf-8"}); - data.add(new String[]{"tr_TR", "iso-8859-9"}); - data.add(new String[]{"C", "us-ascii"}); - data.add(new String[]{"ja_JP", "x-euc-jp-linux"}); - data.add(new String[]{"ja_JP.eucjp", "x-euc-jp-linux"}); - data.add(new String[]{"ja_JP.ujis", "x-euc-jp-linux"}); - data.add(new String[]{"ja_JP.utf8", "utf-8"}); - return data.iterator(); + public static Stream locales() { + return Stream.of( + Arguments.of("en_US", "iso-8859-1"), + Arguments.of("ja_JP.utf8", "utf-8"), + Arguments.of("tr_TR", "iso-8859-9"), + Arguments.of("C", "us-ascii"), + Arguments.of("ja_JP", "x-euc-jp-linux"), + Arguments.of("ja_JP.eucjp", "x-euc-jp-linux"), + Arguments.of("ja_JP.ujis", "x-euc-jp-linux"), + Arguments.of("ja_JP.utf8", "utf-8") + ); } - @Test(dataProvider = "locales") - public void testDefaultCharset(String locale, String expectedCharset) - throws Exception { + @ParameterizedTest + @MethodSource("locales") + public void testDefaultCharset(String locale, String expectedCharset) throws Exception { String actual = runWithLocale(locale); if (UNSUPPORTED.equals(actual)) { System.out.println(locale + ": Locale not supported, skipping..."); diff --git a/test/jdk/java/nio/charset/Charset/ForName.java b/test/jdk/java/nio/charset/Charset/ForName.java index d8a1e2f72d3..6af903a3c8a 100644 --- a/test/jdk/java/nio/charset/Charset/ForName.java +++ b/test/jdk/java/nio/charset/Charset/ForName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,49 +25,51 @@ * @summary Unit test for forName(String, Charset) * @bug 8270490 * @modules jdk.charsets - * @run testng ForName + * @run junit ForName */ import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.StandardCharsets; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -@Test public class ForName { - @DataProvider - Object[][] params() { - return new Object[][] { - {"UTF-8", null, StandardCharsets.UTF_8}, - {"UTF-8", StandardCharsets.US_ASCII, StandardCharsets.UTF_8}, - {"windows-31j", StandardCharsets.US_ASCII, Charset.forName("windows-31j")}, - {"foo", StandardCharsets.US_ASCII, StandardCharsets.US_ASCII}, - {"foo", null, null}, - {"\u3042", null, null}, - {"\u3042", StandardCharsets.UTF_8, StandardCharsets.UTF_8}, - }; + static Stream params() { + return Stream.of( + Arguments.of("UTF-8", null, StandardCharsets.UTF_8), + Arguments.of("UTF-8", StandardCharsets.US_ASCII, StandardCharsets.UTF_8), + Arguments.of("windows-31j", StandardCharsets.US_ASCII, Charset.forName("windows-31j")), + Arguments.of("foo", StandardCharsets.US_ASCII, StandardCharsets.US_ASCII), + Arguments.of("foo", null, null), + Arguments.of("\u3042", null, null), + Arguments.of("\u3042", StandardCharsets.UTF_8, StandardCharsets.UTF_8) + ); } - @DataProvider - Object[][] paramsIAE() { - return new Object[][] { - {null, null}, - {null, StandardCharsets.UTF_8}, - }; + static Stream paramsIAE() { + return Stream.of( + Arguments.of(null, null), + Arguments.of(null, StandardCharsets.UTF_8) + ); } - @Test(dataProvider="params") - public void testForName_2arg(String name, Charset fallback, Charset expected) throws Exception { + @ParameterizedTest + @MethodSource("params") + public void testForName_2arg(String name, Charset fallback, Charset expected) { var cs = Charset.forName(name, fallback); - assertEquals(cs, expected); + assertEquals(expected, cs); } - @Test(dataProvider="paramsIAE", expectedExceptions=IllegalArgumentException.class) - public void testForName_2arg_IAE(String name, Charset fallback) throws Exception { - Charset.forName(name, fallback); + @ParameterizedTest + @MethodSource("paramsIAE") + public void testForName_2arg_IAE(String name, Charset fallback) { + assertThrows(IllegalArgumentException.class, () -> Charset.forName(name, fallback)); } } diff --git a/test/jdk/java/nio/charset/CharsetDecoder/CoderMalfunctionErrorTest.java b/test/jdk/java/nio/charset/CharsetDecoder/CoderMalfunctionErrorTest.java index 79091071ea3..5e830b955b6 100644 --- a/test/jdk/java/nio/charset/CharsetDecoder/CoderMalfunctionErrorTest.java +++ b/test/jdk/java/nio/charset/CharsetDecoder/CoderMalfunctionErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,26 +23,30 @@ /* @test * @bug 8253832 - * @run testng CoderMalfunctionErrorTest * @summary Check CoderMalfunctionError is thrown for any RuntimeException * on CharsetDecoder.decodeLoop() invocation. + * @run junit CoderMalfunctionErrorTest */ -import org.testng.annotations.Test; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.*; -@Test +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + public class CoderMalfunctionErrorTest { - @Test (expectedExceptions = CoderMalfunctionError.class) + + @Test public void testDecodeLoop() { - new CharsetDecoder(StandardCharsets.US_ASCII, 1, 1) { + assertThrows(CoderMalfunctionError.class, + () -> new CharsetDecoder(StandardCharsets.US_ASCII, 1, 1) { @Override protected CoderResult decodeLoop(ByteBuffer byteBuffer, CharBuffer charBuffer) { throw new RuntimeException("This exception should be wrapped in CoderMalfunctionError"); } - }.decode(null, null, true); + }.decode(null, null, true)); } } diff --git a/test/jdk/java/nio/charset/CharsetEncoder/CoderMalfunctionErrorTest.java b/test/jdk/java/nio/charset/CharsetEncoder/CoderMalfunctionErrorTest.java index ffd73164d9f..e917126d461 100644 --- a/test/jdk/java/nio/charset/CharsetEncoder/CoderMalfunctionErrorTest.java +++ b/test/jdk/java/nio/charset/CharsetEncoder/CoderMalfunctionErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,26 +23,29 @@ /* @test * @bug 8253832 - * @run testng CoderMalfunctionErrorTest + * @run junit CoderMalfunctionErrorTest * @summary Check CoderMalfunctionError is thrown for any RuntimeException * on CharsetEncoder.encodeLoop() invocation. */ -import org.testng.annotations.Test; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.*; -@Test +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + public class CoderMalfunctionErrorTest { - @Test (expectedExceptions = CoderMalfunctionError.class) + @Test public void testEncodeLoop() { - new CharsetEncoder(StandardCharsets.US_ASCII, 1, 1) { + assertThrows(CoderMalfunctionError.class, + () -> new CharsetEncoder(StandardCharsets.US_ASCII, 1, 1) { @Override protected CoderResult encodeLoop(CharBuffer charBuffer, ByteBuffer byteBuffer) { throw new RuntimeException("This exception should be wrapped in CoderMalfunctionError"); } - }.encode(null, null, true); + }.encode(null, null, true)); } } diff --git a/test/jdk/java/nio/charset/spi/CharsetProviderBasicTest.java b/test/jdk/java/nio/charset/spi/CharsetProviderBasicTest.java index abf46d81b1c..8b0e74d4360 100644 --- a/test/jdk/java/nio/charset/spi/CharsetProviderBasicTest.java +++ b/test/jdk/java/nio/charset/spi/CharsetProviderBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,28 +35,25 @@ * jdk.test.lib.util.JarUtils * FooCharset FooProvider CharsetTest * @run driver SetupJar - * @run testng CharsetProviderBasicTest + * @run junit CharsetProviderBasicTest */ import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Stream; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.Arrays.asList; public class CharsetProviderBasicTest { - private static final String TEST_SRC = System.getProperty("test.src"); - private static final List DEFAULT_CSS = List.of( "US-ASCII", "8859_1", "iso-ir-6", "UTF-16", "windows-1252", "!BAR", "cp1252" ); @@ -69,14 +66,15 @@ public class CharsetProviderBasicTest { .equals(locale); } - @DataProvider - public static Iterator testCases() { - return Stream.of("", "ja_JP.eucJP", "tr_TR") - .map(locale -> new Object[]{locale, "FOO"}) - .iterator(); + public static Stream testCases() { + return Stream.of("", + "ja_JP.eucJP", + "tr_TR") + .map(locale -> Arguments.of(locale, "FOO")); } - @Test(dataProvider = "testCases") + @ParameterizedTest + @MethodSource("testCases") public void testDefaultCharset(String locale, String css) throws Throwable { if ((System.getProperty("os.name").startsWith("Windows") || !checkSupports(locale)) && (!locale.isEmpty())) { diff --git a/test/jdk/java/nio/file/Files/BytesAndLines.java b/test/jdk/java/nio/file/Files/BytesAndLines.java index ca486ab87fc..1d51021e786 100644 --- a/test/jdk/java/nio/file/Files/BytesAndLines.java +++ b/test/jdk/java/nio/file/Files/BytesAndLines.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,38 +24,47 @@ /* @test * @bug 7006126 8020669 8024788 8019526 * @build BytesAndLines PassThroughFileSystem - * @run testng BytesAndLines + * @run junit BytesAndLines * @summary Unit test for methods for Files readAllBytes, readAllLines and * and write methods. * @key randomness */ -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.OpenOption; -import static java.nio.file.StandardOpenOption.*; +import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.CharacterCodingException; import java.nio.charset.MalformedInputException; import java.nio.charset.UnmappableCharacterException; -import static java.nio.charset.StandardCharsets.*; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.concurrent.Callable; -import java.io.IOException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static java.nio.charset.StandardCharsets.*; +import static java.nio.file.StandardOpenOption.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertLinesMatch; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -@Test(groups = "unit") public class BytesAndLines { // data for text files @@ -66,15 +75,15 @@ public class BytesAndLines { private static Random RAND = new Random(); // file used by most tests - private Path tmpfile; + private static Path tmpfile; - @BeforeClass - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { tmpfile = Files.createTempFile("blah", null); } - @AfterClass - void cleanup() throws IOException { + @AfterAll + static void cleanup() throws IOException { Files.deleteIfExists(tmpfile); } @@ -90,6 +99,7 @@ public class BytesAndLines { /** * Exercise NullPointerException */ + @Test public void testNulls() { Path file = Paths.get("foo"); byte[] bytes = new byte[100]; @@ -118,18 +128,13 @@ public class BytesAndLines { } private void checkNullPointerException(Callable c) { - try { - c.call(); - fail("NullPointerException expected"); - } catch (NullPointerException ignore) { - } catch (Exception e) { - fail(e + " not expected"); - } + assertThrows(NullPointerException.class, () -> c.call()); } /** * Exercise Files.readAllBytes(Path) on varied file sizes */ + @Test public void testReadAllBytes() throws IOException { int size = 0; while (size <= 16*1024) { @@ -145,7 +150,7 @@ public class BytesAndLines { // check expected bytes are read byte[] read = Files.readAllBytes(tmpfile); - assertTrue(Arrays.equals(read, expected), "Bytes read not the same as written"); + assertArrayEquals(expected, read, "Bytes read not the same as written"); } /** @@ -153,13 +158,14 @@ public class BytesAndLines { * special because file sizes are reported as 0 even though the file * has content. */ + @Test + @EnabledOnOs(OS.LINUX) public void testReadAllBytesOnProcFS() throws IOException { // read from procfs - if (System.getProperty("os.name").equals("Linux")) { - Path statFile = Paths.get("/proc/self/stat"); - byte[] data = Files.readAllBytes(statFile); - assertTrue(data.length > 0, "Files.readAllBytes('" + statFile + "') failed to read"); - } + Path statFile = Paths.get("/proc/self/stat"); + byte[] data = Files.readAllBytes(statFile); + assertTrue(data.length > 0, + "Files.readAllBytes('" + statFile + "') failed to read"); } /** @@ -167,6 +173,7 @@ public class BytesAndLines { * because readAllBytes was originally implemented to use FileChannel * and so may not be supported by custom file system providers. */ + @Test public void testReadAllBytesOnCustomFS() throws IOException { Path myfile = PassThroughFileSystem.create().getPath("myfile"); try { @@ -175,7 +182,7 @@ public class BytesAndLines { byte[] b1 = genBytes(size); Files.write(myfile, b1); byte[] b2 = Files.readAllBytes(myfile); - assertTrue(Arrays.equals(b1, b2), "bytes not equal"); + assertArrayEquals(b1, b2, "bytes not equal"); size += 512; } } finally { @@ -186,6 +193,7 @@ public class BytesAndLines { /** * Exercise Files.write(Path, byte[], OpenOption...) on various sizes */ + @Test public void testWriteBytes() throws IOException { int size = 0; while (size < 16*1024) { @@ -198,10 +206,10 @@ public class BytesAndLines { private void testWriteBytes(int size, boolean append) throws IOException { byte[] bytes = genBytes(size); Path result = Files.write(tmpfile, bytes); - assertTrue(result == tmpfile); + assertSame(tmpfile, result); if (append) { Files.write(tmpfile, bytes, APPEND); - assertTrue(Files.size(tmpfile) == size*2); + assertEquals(size*2, Files.size(tmpfile)); } byte[] expected; @@ -214,12 +222,13 @@ public class BytesAndLines { } byte[] read = Files.readAllBytes(tmpfile); - assertTrue(Arrays.equals(read, expected), "Bytes read not the same as written"); + assertArrayEquals(expected, read, "Bytes read not the same as written"); } /** * Exercise Files.readAllLines(Path, Charset) */ + @Test public void testReadAllLines() throws IOException { // zero lines Files.write(tmpfile, new byte[0]); @@ -230,23 +239,22 @@ public class BytesAndLines { byte[] hi = { (byte)'h', (byte)'i' }; Files.write(tmpfile, hi); lines = Files.readAllLines(tmpfile, US_ASCII); - assertTrue(lines.size() == 1, "One line expected"); - assertTrue(lines.get(0).equals("hi"), "'Hi' expected"); + assertEquals(1, lines.size(), "One line expected"); + assertEquals("hi", lines.get(0), "'Hi' expected"); // two lines using platform's line separator List expected = Arrays.asList("hi", "there"); Files.write(tmpfile, expected, US_ASCII); assertTrue(Files.size(tmpfile) > 0, "File is empty"); lines = Files.readAllLines(tmpfile, US_ASCII); - assertTrue(lines.equals(expected), "Unexpected lines"); + assertLinesMatch(expected, lines, "Unexpected lines"); // MalformedInputException byte[] bad = { (byte)0xff, (byte)0xff }; Files.write(tmpfile, bad); - try { - Files.readAllLines(tmpfile, US_ASCII); - fail("MalformedInputException expected"); - } catch (MalformedInputException ignore) { } + assertThrows(MalformedInputException.class, + () -> Files.readAllLines(tmpfile, US_ASCII), + "MalformedInputException expected"); } /** @@ -254,24 +262,27 @@ public class BytesAndLines { * is special because file sizes are reported as 0 even though the file * has content. */ + @Test + @EnabledOnOs(OS.LINUX) public void testReadAllLinesOnProcFS() throws IOException { - if (System.getProperty("os.name").equals("Linux")) { - Path statFile = Paths.get("/proc/self/stat"); - List lines = Files.readAllLines(statFile); - assertTrue(lines.size() > 0, "Files.readAllLines('" + statFile + "') failed to read"); - } + Path statFile = Paths.get("/proc/self/stat"); + List lines = Files.readAllLines(statFile); + assertTrue(lines.size() > 0, + "Files.readAllLines('" + statFile + "') failed to read"); } /** * Exercise Files.readAllLines(Path) */ + @Test public void testReadAllLinesUTF8() throws IOException { Files.write(tmpfile, encodeAsUTF8(EN_STRING + "\n" + JA_STRING)); List lines = Files.readAllLines(tmpfile); - assertTrue(lines.size() == 2, "Read " + lines.size() + " lines instead of 2"); - assertTrue(lines.get(0).equals(EN_STRING)); - assertTrue(lines.get(1).equals(JA_STRING)); + assertEquals(2, lines.size(), + "Read " + lines.size() + " lines instead of 2"); + assertEquals(EN_STRING, lines.get(0)); + assertEquals(JA_STRING, lines.get(1)); // a sample of malformed sequences testReadAllLinesMalformedUTF8((byte)0xFF); // one-byte sequence @@ -284,57 +295,55 @@ public class BytesAndLines { ByteBuffer bb = UTF_8.newEncoder().encode(CharBuffer.wrap(s)); byte[] result = new byte[bb.limit()]; bb.get(result); - assertTrue(bb.remaining() == 0); + assertEquals(0, bb.remaining()); return result; } private void testReadAllLinesMalformedUTF8(byte... bytes) throws IOException { Files.write(tmpfile, bytes); - try { - Files.readAllLines(tmpfile); - fail("MalformedInputException expected"); - } catch (MalformedInputException ignore) { } + assertThrows(MalformedInputException.class, + () -> Files.readAllLines(tmpfile)); } /** * Exercise Files.write(Path, Iterable, Charset, OpenOption...) */ + @Test public void testWriteLines() throws IOException { // zero lines Path result = Files.write(tmpfile, Collections.emptyList(), US_ASCII); - assert(Files.size(tmpfile) == 0); - assert(result == tmpfile); + assertEquals(0, Files.size(tmpfile)); + assertSame(tmpfile, result); // two lines List lines = Arrays.asList("hi", "there"); Files.write(tmpfile, lines, US_ASCII); List actual = Files.readAllLines(tmpfile, US_ASCII); - assertTrue(actual.equals(lines), "Unexpected lines"); + assertLinesMatch(lines, actual, "Unexpected lines"); // append two lines Files.write(tmpfile, lines, US_ASCII, APPEND); List expected = new ArrayList<>(); expected.addAll(lines); expected.addAll(lines); - assertTrue(expected.size() == 4, "List should have 4 elements"); + assertEquals(4, expected.size()); actual = Files.readAllLines(tmpfile, US_ASCII); - assertTrue(actual.equals(expected), "Unexpected lines"); + assertLinesMatch(expected, actual, "Unexpected lines"); // UnmappableCharacterException - try { - String s = "\u00A0\u00A1"; - Files.write(tmpfile, Arrays.asList(s), US_ASCII); - fail("UnmappableCharacterException expected"); - } catch (UnmappableCharacterException ignore) { } + String s = "\u00A0\u00A1"; + assertThrows(UnmappableCharacterException.class, + () -> Files.write(tmpfile, Arrays.asList(s), US_ASCII)); } /** * Exercise Files.write(Path, Iterable, OpenOption...) */ + @Test public void testWriteLinesUTF8() throws IOException { List lines = Arrays.asList(EN_STRING, JA_STRING); Files.write(tmpfile, lines); List actual = Files.readAllLines(tmpfile, UTF_8); - assertTrue(actual.equals(lines), "Unexpected lines"); + assertLinesMatch(lines, actual, "Unexpected lines"); } } diff --git a/test/jdk/java/nio/file/Files/CallWithInterruptSet.java b/test/jdk/java/nio/file/Files/CallWithInterruptSet.java index 3d7bfd2c518..59d6a6a7ecb 100644 --- a/test/jdk/java/nio/file/Files/CallWithInterruptSet.java +++ b/test/jdk/java/nio/file/Files/CallWithInterruptSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,24 @@ /* * @test * @bug 8205612 - * @run testng CallWithInterruptSet + * @run junit CallWithInterruptSet * @summary Test invoking Files methods with the interrupted status set */ -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CallWithInterruptSet { @@ -49,7 +51,7 @@ public class CallWithInterruptSet { Thread.currentThread().interrupt(); try { byte[] bytes = Files.readAllBytes(file); - assertTrue(bytes.length == 100); + assertEquals(100, bytes.length); } finally { assertTrue(Thread.interrupted()); // clear interrupt } @@ -76,7 +78,7 @@ public class CallWithInterruptSet { } finally { assertTrue(Thread.interrupted()); // clear interrupt } - assertTrue(Files.size(file) == 10); + assertEquals(10, Files.size(file)); } @Test @@ -86,7 +88,7 @@ public class CallWithInterruptSet { Thread.currentThread().interrupt(); try { String msg = Files.readString(file); - assertEquals(msg, "hello"); + assertEquals("hello", msg); } finally { assertTrue(Thread.interrupted()); // clear interrupt } @@ -102,7 +104,7 @@ public class CallWithInterruptSet { assertTrue(Thread.interrupted()); // clear interrupt } String msg = Files.readString(file); - assertEquals(msg, "hello"); + assertEquals("hello", msg); } @Test @@ -112,7 +114,7 @@ public class CallWithInterruptSet { Thread.currentThread().interrupt(); try (BufferedReader reader = Files.newBufferedReader(file)) { String msg = reader.readLine(); - assertEquals(msg, "hello"); + assertEquals("hello", msg); } finally { assertTrue(Thread.interrupted()); // clear interrupt } @@ -128,7 +130,7 @@ public class CallWithInterruptSet { assertTrue(Thread.interrupted()); // clear interrupt } String msg = Files.readString(file); - assertEquals(msg, "hello"); + assertEquals("hello", msg); } private Path mkfile() throws IOException { diff --git a/test/jdk/java/nio/file/Files/CopyProcFile.java b/test/jdk/java/nio/file/Files/CopyProcFile.java index 892ac6b0eb4..c187aaed861 100644 --- a/test/jdk/java/nio/file/Files/CopyProcFile.java +++ b/test/jdk/java/nio/file/Files/CopyProcFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,20 +33,23 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.function.ToLongBiFunction; +import java.util.stream.Stream; import static java.nio.file.StandardOpenOption.*; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; /* * @test * @bug 8293502 * @requires (os.family == "linux") * @summary Ensure that copying from a file in /proc works - * @run testng/othervm CopyProcFile + * @run junit/othervm CopyProcFile */ public class CopyProcFile { static final String SOURCE = "/proc/version"; @@ -112,8 +115,8 @@ public class CopyProcFile { } } - @BeforeTest(alwaysRun=true) - public void createBufferedCopy() throws IOException { + @BeforeAll + public static void createBufferedCopy() throws IOException { System.out.printf("Using source file \"%s\"%n", SOURCE); try { theSize = bufferedCopy(SOURCE, BUFFERED_COPY); @@ -129,8 +132,8 @@ public class CopyProcFile { } } - @AfterTest(alwaysRun=true) - public void deleteBufferedCopy() { + @AfterAll + public static void deleteBufferedCopy() { try { Files.delete(Path.of(BUFFERED_COPY)); } catch (IOException ignore) {} @@ -148,18 +151,17 @@ public class CopyProcFile { } } - @DataProvider - static Object[][] functions() throws IOException { - List funcs = new ArrayList<>(); - funcs.add(new Object[] {new FHolder((s, d) -> copy(s, d))}); - funcs.add(new Object[] {new FHolder((s, d) -> transferToIO(s, d))}); - funcs.add(new Object[] {new FHolder((s, d) -> transferToNIO(s, d))}); - funcs.add(new Object[] {new FHolder((s, d) -> transferFrom(s, d))}); - return funcs.toArray(Object[][]::new); + static Stream functions() throws IOException { + return Stream.of + (new FHolder((s, d) -> copy(s, d)), + new FHolder((s, d) -> transferToIO(s, d)), + new FHolder((s, d) -> transferToNIO(s, d)), + new FHolder((s, d) -> transferFrom(s, d))); } - @Test(dataProvider = "functions") - public static void testCopyAndTransfer(FHolder f) throws IOException { + @ParameterizedTest + @MethodSource("functions") + public void testCopyAndTransfer(FHolder f) throws IOException { try { long size = f.apply(SOURCE, TARGET); if (size != theSize) { @@ -168,9 +170,7 @@ public class CopyProcFile { } long mismatch = Files.mismatch(Path.of(BUFFERED_COPY), Path.of(TARGET)); - if (mismatch != -1) { - throw new RuntimeException("Target does not match copy"); - } + assertEquals(-1, mismatch, "Target does not match copy"); } finally { try { Files.delete(Path.of(TARGET)); diff --git a/test/jdk/java/nio/file/Files/CreateDirectories.java b/test/jdk/java/nio/file/Files/CreateDirectories.java index fc5a5025955..9912b442cfd 100644 --- a/test/jdk/java/nio/file/Files/CreateDirectories.java +++ b/test/jdk/java/nio/file/Files/CreateDirectories.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,16 +26,18 @@ import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Path; -import static org.testng.Assert.*; -import org.testng.SkipException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.api.Assumptions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test * @bug 8032220 8293792 8307976 * @summary Test java.nio.file.Files.createDirectories method * @library .. - * @run testng CreateDirectories + * @run junit CreateDirectories */ public class CreateDirectories { @@ -46,12 +48,10 @@ public class CreateDirectories { public void testSymlinkDir() throws Exception { // create a temp dir as the "root" in which we will run our tests. final Path top = TestUtil.createTemporaryDirectory(); - if (!TestUtil.supportsSymbolicLinks(top)) { - System.out.println("Skipping tests since symbolic links isn't " + - "supported under directory "+ top); - throw new SkipException("Symbolic links not supported"); - } - System.out.println("Running tests under directory " + top.toAbsolutePath()); + Assumptions.assumeTrue(TestUtil.supportsSymbolicLinks(top), + "Skipping as symbolic links are not supported under in " + top); + System.err.println("Running tests under directory " + + top.toAbsolutePath()); final Path fooDir = Files.createDirectory(top.resolve("foo")); assertTrue(Files.isDirectory(fooDir), fooDir + " was expected to be a directory but wasn't"); diff --git a/test/jdk/java/nio/file/Files/Mismatch.java b/test/jdk/java/nio/file/Files/Mismatch.java index 8746f448ad0..0d0446ed96e 100644 --- a/test/jdk/java/nio/file/Files/Mismatch.java +++ b/test/jdk/java/nio/file/Files/Mismatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,12 +21,6 @@ * questions. */ -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -36,13 +30,23 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.spi.FileSystemProvider; import java.util.Map; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + /* @test * @bug 8202285 * @build Mismatch - * @run testng Mismatch + * @run junit Mismatch * @summary Unit test for the Files.mismatch method. */ public class Mismatch { @@ -55,29 +59,28 @@ public class Mismatch { private static final Map ZIPFS_MAP = Map.of("create", "true"); // temporary test directory where all test files will be created - Path testDir; + static Path testDir; - @BeforeClass - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { testDir = Files.createTempDirectory("testMismatch"); } - @AfterClass - void cleanup() throws IOException { + @AfterAll + static void cleanup() throws IOException { // clean up files created under the test directory Files.walk(testDir).map(Path::toFile).forEach(File::delete); Files.deleteIfExists(testDir); } /* - * DataProvider for mismatch test. Provides the following fields: + * MethodSource for mismatch test. Provides the following fields: * path1 -- the path to a file * path2 -- the path to another file * expected -- expected result of the mismatch method * note -- a note about the test */ - @DataProvider(name = "testMismatch") - public Object[][] getDataForMismatch() throws IOException { + public static Stream getDataForMismatch() throws IOException { // an non-existent file Path foo = Paths.get("nonexistentfile"); @@ -147,151 +150,148 @@ public class Mismatch { Path test1065000m532500 = createASCIIFile(testDir, "test1065000m532500", size, size >> 1, '%'); Path test1065000m1064999 = createASCIIFile(testDir, "test1065000m1064999", size, 1064999, '$'); - return new Object[][]{ - // Spec Case 1: the two paths locate the same file , even if one does not exist - {foo, foo, MISMATCH_NO, "Same file, no mismatch"}, - {test1024a, test1024a, MISMATCH_NO, "Same file, no mismatch"}, + return Stream.of + (// Spec Case 1: the two paths locate the same file , even if one does not exist + Arguments.of(foo, foo, MISMATCH_NO, "Same file, no mismatch"), + Arguments.of(test1024a, test1024a, MISMATCH_NO, "Same file, no mismatch"), - // Spec Case 2: The two files are the same size, and every byte in the first file - // is identical to the corresponding byte in the second file. - {test0a, test0b, MISMATCH_NO, "Sizes == 0, no mismatch"}, - {test147a, test147b, MISMATCH_NO, "size = 147 < buffer = 8192, no mismatch"}, - {test1024a, test1024b, MISMATCH_NO, "size = 1024 < buffer = 8192, no mismatch"}, - {test8192a, test8192b, MISMATCH_NO, "size = 8192 = buffer = 8192, no mismatch"}, - {test65536a, test65536b, MISMATCH_NO, "read 8 * full buffer, no mismatch"}, - {test70025a, test70025b, MISMATCH_NO, "read 8 * full buffer plus a partial buffer, no mismatch"}, + // Spec Case 2: The two files are the same size, and every byte in the first file + // is identical to the corresponding byte in the second file. + Arguments.of(test0a, test0b, MISMATCH_NO, "Sizes == 0, no mismatch"), + Arguments.of(test147a, test147b, MISMATCH_NO, "size = 147 < buffer = 8192, no mismatch"), + Arguments.of(test1024a, test1024b, MISMATCH_NO, "size = 1024 < buffer = 8192, no mismatch"), + Arguments.of(test8192a, test8192b, MISMATCH_NO, "size = 8192 = buffer = 8192, no mismatch"), + Arguments.of(test65536a, test65536b, MISMATCH_NO, "read 8 * full buffer, no mismatch"), + Arguments.of(test70025a, test70025b, MISMATCH_NO, "read 8 * full buffer plus a partial buffer, no mismatch"), - /** - * Spec Case 3: the value returned is the position of the first mismatched byte - * Impl: the impl uses a buffer 8192. The testcases below covers a range of files - * with sizes <= and > the buffer size. The last buffer is either full or partially full. - */ + /* + * Spec Case 3: the value returned is the position of the first mismatched byte + * Impl: the impl uses a buffer 8192. The testcases below covers a range of files + * with sizes <= and > the buffer size. The last buffer is either full or partially full. + */ - // edge case, one of the file sizes is zero - // also covers Spec Case 4 and 6 - {test147a, test147m0, 0, "mismatch = 0 (at the beginning)"}, - {test65536m0, test65536a, 0, "mismatch = 0 (at the beginning)"}, + // edge case, one of the file sizes is zero + // also covers Spec Case 4 and 6 + Arguments.of(test147a, test147m0, 0, "mismatch = 0 (at the beginning)"), + Arguments.of(test65536m0, test65536a, 0, "mismatch = 0 (at the beginning)"), - /** - * Compares files of equal sizes - */ - // small files - {test147a, test147m70, 70, "read one partial buffer, mismatch = 70"}, - {test147a, test147m146, 146, "read one partial buffer, mismatch = 146 (end)"}, - {test1024a, test1024m512, 512, "read one partial buffer, mismatch = 512"}, - {test1024a, test1024m1023, 1023, "read one partial buffer, mismatch = 1023 (end)"}, + /* + * Compares files of equal sizes + */ + // small files + Arguments.of(test147a, test147m70, 70, "read one partial buffer, mismatch = 70"), + Arguments.of(test147a, test147m146, 146, "read one partial buffer, mismatch = 146 (end)"), + Arguments.of(test1024a, test1024m512, 512, "read one partial buffer, mismatch = 512"), + Arguments.of(test1024a, test1024m1023, 1023, "read one partial buffer, mismatch = 1023 (end)"), - // file size >= Impl's Buffer Size - {test8192a, test8192m4096, 4096, "read one buffer, mismatch = 4096 "}, - {test8192a, test8192m8191, 8191, "read one buffer, mismatch = 8191 (at the end)"}, + // file size >= Impl's Buffer Size + Arguments.of(test8192a, test8192m4096, 4096, "read one buffer, mismatch = 4096 "), + Arguments.of(test8192a, test8192m8191, 8191, "read one buffer, mismatch = 8191 (at the end)"), - // file size = n * Impl's Buffer Size - {test65536a, test65536m32768, 32768, "read through half of the file, mismatch = 32768"}, - {test65536a, test65536m65535, 65535, "read through the whole file, mismatch = 65535 (at the end)"}, + // file size = n * Impl's Buffer Size + Arguments.of(test65536a, test65536m32768, 32768, "read through half of the file, mismatch = 32768"), + Arguments.of(test65536a, test65536m65535, 65535, "read through the whole file, mismatch = 65535 (at the end)"), - // file size = n * Impl's Buffer Size + x - {test70025a, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"}, - {test70025a, test70025m35000, 35000, "read about half of the file, mismatch = 35000"}, - {test70025a, test70025m70024, 70024, "read through the whole file, mismatch = 70024 (at the end)"}, + // file size = n * Impl's Buffer Size + x + Arguments.of(test70025a, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"), + Arguments.of(test70025a, test70025m35000, 35000, "read about half of the file, mismatch = 35000"), + Arguments.of(test70025a, test70025m70024, 70024, "read through the whole file, mismatch = 70024 (at the end)"), - /** - * Compares files of unequal sizes - */ - {test8192m8191, test70025m35000, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"}, - {test65536m32768, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"}, - {test70025m70024, test1065000m532500, 70024, "mismatch at the end of the 1st file, mismatch = 70024"}, + /* + * Compares files of unequal sizes + */ + Arguments.of(test8192m8191, test70025m35000, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"), + Arguments.of(test65536m32768, test70025m8400, 8400, "mismatch in the 2nd buffer, mismatch = 8400"), + Arguments.of(test70025m70024, test1065000m532500, 70024, "mismatch at the end of the 1st file, mismatch = 70024"), - /** - * Spec Case 4: returns the size of the smaller file (in bytes) when the files are - * different sizes and every byte of the smaller file is identical to the corresponding - * byte of the larger file. - * Impl: similar to case 3, covers a range of file sizes - */ - {test147a, test1024a, 147, "mismatch is the length of the smaller file: 147"}, - {test1024a, test8192a, 1024, "mismatch is the length of the smaller file: 1024"}, - {test1024a, test65536a, 1024, "mismatch is the length of the smaller file: 1024"}, - {test8192a, test65536a, 8192, "mismatch is the length of the smaller file: 8192"}, - {test70025a, test65536a, 65536, "mismatch is the length of the smaller file: 65536"}, - {test1048576a, test1065000m1064999, 1048576, "mismatch is the length of the smaller file: 1048576"}, + /* + * Spec Case 4: returns the size of the smaller file (in bytes) when the files are + * different sizes and every byte of the smaller file is identical to the corresponding + * byte of the larger file. + * Impl: similar to case 3, covers a range of file sizes + */ + Arguments.of(test147a, test1024a, 147, "mismatch is the length of the smaller file: 147"), + Arguments.of(test1024a, test8192a, 1024, "mismatch is the length of the smaller file: 1024"), + Arguments.of(test1024a, test65536a, 1024, "mismatch is the length of the smaller file: 1024"), + Arguments.of(test8192a, test65536a, 8192, "mismatch is the length of the smaller file: 8192"), + Arguments.of(test70025a, test65536a, 65536, "mismatch is the length of the smaller file: 65536"), + Arguments.of(test1048576a, test1065000m1064999, 1048576, "mismatch is the length of the smaller file: 1048576"), - // Spec Case 5: This method is always reflexive (for Path f , mismatch(f,f) returns -1L) - // See tests for Spec Case 1. + // Spec Case 5: This method is always reflexive (for Path f , mismatch(f,f) returns -1L) + // See tests for Spec Case 1. - // Spec Case 6: If the file system and files remain static, then this method is symmetric - // (for two Paths f and g, mismatch(f,g) will return the same value as mismatch(g,f)). - // The following tests are selected from tests for Spec Case 3 with the order of - // file paths switched, the returned values are the same as those for Case 3: - {test147m70, test147a, 70, "read one partial buffer, mismatch = 70"}, - {test147m146, test147a, 146, "read one partial buffer, mismatch = 146 (end)"}, - {test1024m512, test1024a, 512, "read one partial buffer, mismatch = 512"}, - {test1024m1023, test1024a, 1023, "read one partial buffer, mismatch = 1023 (end)"}, + // Spec Case 6: If the file system and files remain static, then this method is symmetric + // (for two Paths f and g, mismatch(f,g) will return the same value as mismatch(g,f)). + // The following tests are selected from tests for Spec Case 3 with the order of + // file paths switched, the returned values are the same as those for Case 3: + Arguments.of(test147m70, test147a, 70, "read one partial buffer, mismatch = 70"), + Arguments.of(test147m146, test147a, 146, "read one partial buffer, mismatch = 146 (end)"), + Arguments.of(test1024m512, test1024a, 512, "read one partial buffer, mismatch = 512"), + Arguments.of(test1024m1023, test1024a, 1023, "read one partial buffer, mismatch = 1023 (end)"), - {test70025m35000, test8192m8191, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"}, - {test70025m8400, test65536m32768, 8400, "mismatch in the 2nd buffer, mismatch = 8400"}, - {test1065000m532500, test70025m70024, 70024, "mismatch at the end of the 1st file, mismatch = 70024"}, - }; + Arguments.of(test70025m35000, test8192m8191, 8191, "mismatch at the end of the 1st file/buffer, mismatch = 8191"), + Arguments.of(test70025m8400, test65536m32768, 8400, "mismatch in the 2nd buffer, mismatch = 8400"), + Arguments.of(test1065000m532500, test70025m70024, 70024, "mismatch at the end of the 1st file, mismatch = 70024") + ); } /* - * DataProvider for mismatch tests involving ZipFS using a few test cases selected + * MethodSource for mismatch tests involving ZipFS using a few test cases selected * from those of the original mismatch tests. */ - @DataProvider(name = "testMismatchZipfs") - public Object[][] getDataForMismatchZipfs() throws IOException { + public static Stream getDataForMismatchZipfs() throws IOException { Path test1200 = createASCIIFile(testDir, "test1200", 1200, -1, ' '); Path test9500 = createASCIIFile(testDir, "test9500", 9500, -1, ' '); Path test9500m4200 = createASCIIFile(testDir, "test9500m4200", 9500, 4200, '!'); Path test80025 = createASCIIFile(testDir, "test80025", 80025, -1, ' '); Path test1028500 = createASCIIFile(testDir, "test1028500", 1028500, -1, ' '); - return new Object[][]{ - {test1200, test1200, MISMATCH_NO, "Compares the file and its copy in zip, no mismatch"}, - {test9500, test9500m4200, 4200, - "Compares a copy of test9500m4200 in zip with test9500, shall return 4200"}, - {test80025, test1028500, 80025, "mismatch is the length of the smaller file: 80025"}, - }; + return Stream.of + ( + Arguments.of(test1200, test1200, MISMATCH_NO, "Compares the file and its copy in zip, no mismatch"), + Arguments.of(test9500, test9500m4200, 4200, + "Compares a copy of test9500m4200 in zip with test9500, shall return 4200"), + Arguments.of(test80025, test1028500, 80025, + "mismatch is the length of the smaller file: 80025") + ); } /* - * DataProvider for verifying null handling. + * MethodSource for verifying null handling. */ - @DataProvider(name = "testFileNull") - public Object[][] getDataForNull() throws IOException { + public static Stream getDataForNull() throws IOException { Path test = createASCIIFile(testDir, "testNonNull", 2200, -1, ' '); - return new Object[][]{ - {(Path)null, (Path)null}, - {(Path)null, test}, - {test, (Path)null}, - }; + return Stream.of(Arguments.of((Path)null, (Path)null), + Arguments.of((Path)null, test), + Arguments.of(test, (Path)null)); } /* - * DataProvider for verifying how the mismatch method handles the situation + * MethodSource for verifying how the mismatch method handles the situation * when one or both files do not exist. */ - @DataProvider(name = "testFileNotExist") - public Object[][] getDataForFileNotExist() throws IOException { + public static Stream getDataForFileNotExist() throws IOException { Path test = createASCIIFile(testDir, "testFileNotExist", 3200, -1, ' '); - return new Object[][]{ - {Paths.get("foo"), Paths.get("bar")}, - {Paths.get("foo"), test}, - {test, Paths.get("bar")}, - }; + return Stream.of + (Arguments.of(Paths.get("foo"), Paths.get("bar")), + Arguments.of("foo", test), + Arguments.of(test, Paths.get("bar"))); } /** - * Tests the mismatch method. Refer to the dataProvider testMismatch for more - * details about the cases. + * Tests the mismatch method. Refer to the dataProvider getDataForNull for + * more details about the cases. * @param path the path to a file * @param path2 the path to another file * @param expected the expected result * @param msg the message about the test * @throws IOException if the test fails */ - @Test(dataProvider = "testMismatch", priority = 0) + @ParameterizedTest + @MethodSource("getDataForMismatch") public void testMismatch(Path path, Path path2, long expected, String msg) throws IOException { - Assert.assertEquals(Files.mismatch(path, path2), expected, msg); + assertEquals(expected, Files.mismatch(path, path2), msg); } /** @@ -302,7 +302,8 @@ public class Mismatch { * @param msg the message about the test * @throws IOException if the test fails */ - @Test(dataProvider = "testMismatchZipfs", priority = 1) + @ParameterizedTest + @MethodSource("getDataForMismatchZipfs") public void testMismatchZipfs(Path path, Path path2, long expected, String msg) throws IOException { Path zipPath = Paths.get(testDir.toString(), "TestWithFSZip.zip"); @@ -311,9 +312,9 @@ public class Mismatch { Files.copy(path, copy, REPLACE_EXISTING); if (path2 == null) { - Assert.assertEquals(Files.mismatch(copy, path), expected, msg); + assertEquals(expected, Files.mismatch(copy, path), msg); } else { - Assert.assertEquals(Files.mismatch(copy, path2), expected, msg); + assertEquals(expected, Files.mismatch(copy, path2), msg); } } } @@ -324,9 +325,11 @@ public class Mismatch { * @param path2 the path to another file * @throws NullPointerException as expected */ - @Test(dataProvider = "testFileNull", priority = 2, expectedExceptions = NullPointerException.class) + @ParameterizedTest + @MethodSource("getDataForNull") public void testMismatchNull(Path path, Path path2) throws Exception { - long result = Files.mismatch(path, path2); + assertThrows(NullPointerException.class, + () -> Files.mismatch(path, path2)); } /** @@ -335,9 +338,11 @@ public class Mismatch { * @param path2 the path to another file * @throws IOException as expected */ - @Test(dataProvider = "testFileNotExist", priority = 2, expectedExceptions = IOException.class) + @ParameterizedTest + @MethodSource("getDataForFileNotExist") public void testMismatchNotExist(Path path, Path path2) throws IOException { - long result = Files.mismatch(path, path2); + assertThrows(IOException.class, + () -> {long result = Files.mismatch(path, path2);}); } /** diff --git a/test/jdk/java/nio/file/Files/ReadWriteString.java b/test/jdk/java/nio/file/Files/ReadWriteString.java index 8b5241fa1cf..3510f41e979 100644 --- a/test/jdk/java/nio/file/Files/ReadWriteString.java +++ b/test/jdk/java/nio/file/Files/ReadWriteString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +27,21 @@ import java.nio.charset.Charset; import java.nio.charset.CharacterCodingException; import java.nio.charset.MalformedInputException; import java.nio.charset.UnmappableCharacterException; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.Callable; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; @@ -36,36 +51,31 @@ import static java.nio.charset.StandardCharsets.UTF_16LE; import static java.nio.charset.StandardCharsets.UTF_32; import static java.nio.charset.StandardCharsets.UTF_32BE; import static java.nio.charset.StandardCharsets.UTF_32LE; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.Path; -import java.nio.file.Paths; + import static java.nio.file.StandardOpenOption.APPEND; import static java.nio.file.StandardOpenOption.CREATE; -import java.util.Arrays; -import java.util.Random; -import java.util.concurrent.Callable; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /* @test * @bug 8201276 8205058 8209576 8287541 8288589 8325590 * @build ReadWriteString PassThroughFileSystem - * @run testng ReadWriteString + * @run junit ReadWriteString * @summary Unit test for methods for Files readString and write methods. * @key randomness * @modules jdk.charsets */ -@Test(groups = "readwrite") public class ReadWriteString { // data for text files - final String TEXT_UNICODE = "\u201CHello\u201D"; - final String TEXT_ASCII = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n abcdefghijklmnopqrstuvwxyz\n 1234567890\n"; + final static String TEXT_UNICODE = "\u201CHello\u201D"; + final static String TEXT_ASCII = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n abcdefghijklmnopqrstuvwxyz\n 1234567890\n"; final static String TEXT_PERSON_CART_WHEELING = "\ud83e\udd38"; private static final String JA_STRING = "\u65e5\u672c\u8a9e\u6587\u5b57\u5217"; private static final Charset WINDOWS_1252 = Charset.forName("windows-1252"); @@ -85,96 +95,85 @@ public class ReadWriteString { return baos.toByteArray(); } catch (IOException ex) { // in case it happens, fail the test - throw new RuntimeException(ex); + fail(ex); + return null; // appease the compiler } } // file used by testReadWrite, testReadString and testWriteString - private Path[] testFiles = new Path[3]; + private static Path[] testFiles = new Path[3]; /* - * DataProvider for malformed write test. Provides the following fields: + * MethodSource for malformed write test. Provides the following fields: * file path, malformed input string, charset */ - @DataProvider(name = "malformedWrite") - public Object[][] getMalformedWrite() throws IOException { + public static Stream getMalformedWrite() throws IOException { Path path = Files.createFile(Path.of("malformedWrite")); - return new Object[][]{ - {path, "\ud800", null}, //the default Charset is UTF_8 - {path, "\u00A0\u00A1", US_ASCII}, - {path, "\ud800", UTF_8}, - {path, JA_STRING, ISO_8859_1}, - {path, "\u041e", WINDOWS_1252}, // cyrillic capital letter O - {path, "\u091c", WINDOWS_31J}, // devanagari letter ja - }; + return Stream.of + (Arguments.of(path, "\ud800", null), //the default Charset is UTF_8 + Arguments.of(path, "\u00A0\u00A1", US_ASCII), + Arguments.of(path, "\ud800", UTF_8), + Arguments.of(path, JA_STRING, ISO_8859_1), + Arguments.of(path, "\u041e", WINDOWS_1252), // cyrillic capital letter O + Arguments.of(path, "\u091c", WINDOWS_31J)); // devanagari letter ja } /* - * DataProvider for illegal input test + * MethodSource for illegal input test * Writes the data in ISO8859 and reads with UTF_8, expects MalformedInputException */ - @DataProvider(name = "illegalInput") - public Object[][] getIllegalInput() throws IOException { + public static Stream getIllegalInput() throws IOException { Path path = Files.createFile(Path.of("illegalInput")); - return new Object[][]{ - {path, data, ISO_8859_1, null}, - {path, data, ISO_8859_1, UTF_8} - }; + return Stream.of(Arguments.of(path, data, ISO_8859_1, null), + Arguments.of(path, data, ISO_8859_1, UTF_8)); } /* - * DataProvider for illegal input bytes test + * MethodSource for illegal input bytes test */ - @DataProvider(name = "illegalInputBytes") - public Object[][] getIllegalInputBytes() throws IOException { - return new Object[][]{ - {new byte[] {(byte)0x00, (byte)0x20, (byte)0x00}, UTF_16, MalformedInputException.class}, - {new byte[] {-50}, UTF_16, MalformedInputException.class}, - {new byte[] {(byte)0x81}, WINDOWS_1252, UnmappableCharacterException.class}, // unused in Cp1252 - {new byte[] {(byte)0x81, (byte)0xff}, WINDOWS_31J, UnmappableCharacterException.class}, // invalid trailing byte - }; + public static Stream getIllegalInputBytes() throws IOException { + return Stream.of + (Arguments.of(new byte[] {(byte)0x00, (byte)0x20, (byte)0x00}, UTF_16, MalformedInputException.class), + Arguments.of(new byte[] {-50}, UTF_16, MalformedInputException.class), + Arguments.of(new byte[] {(byte)0x81}, WINDOWS_1252, UnmappableCharacterException.class), // unused in Cp1252 + Arguments.of(new byte[] {(byte)0x81, (byte)0xff}, WINDOWS_31J, UnmappableCharacterException.class)); // invalid trailing byte } /* - * DataProvider for writeString test + * MethodSource for writeString test * Writes the data using both the existing and new method and compares the results. */ - @DataProvider(name = "testWriteString") - public Object[][] getWriteString() { - - return new Object[][]{ - {testFiles[1], testFiles[2], TEXT_ASCII, US_ASCII, null}, - {testFiles[1], testFiles[2], TEXT_ASCII, US_ASCII, US_ASCII}, - {testFiles[1], testFiles[2], TEXT_UNICODE, UTF_8, null}, - {testFiles[1], testFiles[2], TEXT_UNICODE, UTF_8, UTF_8} - }; + public static Stream getWriteString() { + return Stream.of + (Arguments.of(testFiles[1], testFiles[2], TEXT_ASCII, US_ASCII, null), + Arguments.of(testFiles[1], testFiles[2], TEXT_ASCII, US_ASCII, US_ASCII), + Arguments.of(testFiles[1], testFiles[2], TEXT_UNICODE, UTF_8, null), + Arguments.of(testFiles[1], testFiles[2], TEXT_UNICODE, UTF_8, UTF_8)); } /* - * DataProvider for readString test + * MethodSource for readString test * Reads the file using both the existing and new method and compares the results. */ - @DataProvider(name = "testReadString") - public Object[][] getReadString() { - return new Object[][]{ - {testFiles[1], TEXT_ASCII, US_ASCII, US_ASCII}, - {testFiles[1], TEXT_ASCII, US_ASCII, UTF_8}, - {testFiles[1], TEXT_UNICODE, UTF_8, null}, - {testFiles[1], TEXT_UNICODE, UTF_8, UTF_8}, - {testFiles[1], TEXT_ASCII, US_ASCII, ISO_8859_1}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16, UTF_16}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16BE, UTF_16BE}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16LE, UTF_16LE}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32, UTF_32}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32BE, UTF_32BE}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32LE, UTF_32LE}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, WINDOWS_1252, WINDOWS_1252}, - {testFiles[1], TEXT_PERSON_CART_WHEELING, WINDOWS_31J, WINDOWS_31J} - }; + public static Stream getReadString() { + return Stream.of + (Arguments.of(testFiles[1], TEXT_ASCII, US_ASCII, US_ASCII), + Arguments.of(testFiles[1], TEXT_ASCII, US_ASCII, UTF_8), + Arguments.of(testFiles[1], TEXT_UNICODE, UTF_8, null), + Arguments.of(testFiles[1], TEXT_UNICODE, UTF_8, UTF_8), + Arguments.of(testFiles[1], TEXT_ASCII, US_ASCII, ISO_8859_1), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16, UTF_16), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16BE, UTF_16BE), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_16LE, UTF_16LE), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32, UTF_32), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32BE, UTF_32BE), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, UTF_32LE, UTF_32LE), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, WINDOWS_1252, WINDOWS_1252), + Arguments.of(testFiles[1], TEXT_PERSON_CART_WHEELING, WINDOWS_31J, WINDOWS_31J)); } - @BeforeClass - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { testFiles[0] = Files.createFile(Path.of("readWriteString")); testFiles[1] = Files.createFile(Path.of("writeString_file1")); testFiles[2] = Files.createFile(Path.of("writeString_file2")); @@ -225,7 +224,8 @@ public class ReadWriteString { * This method compares the results written by the existing write method and * the writeString method added since 11. */ - @Test(dataProvider = "testWriteString") + @ParameterizedTest + @MethodSource("getWriteString") public void testWriteString(Path path, Path path2, String text, Charset cs, Charset cs2) throws IOException { Files.write(path, text.getBytes(cs)); @@ -237,14 +237,15 @@ public class ReadWriteString { } byte[] bytes = Files.readAllBytes(path); byte[] bytes2 = Files.readAllBytes(path2); - assertTrue((Arrays.compare(bytes, bytes2) == 0), "The bytes should be the same"); + assertArrayEquals(bytes2, bytes, "The bytes should be the same"); } /** * Verifies that the readString method added since 11 behaves the same as * constructing a string from the existing readAllBytes method. */ - @Test(dataProvider = "testReadString") + @ParameterizedTest + @MethodSource("getReadString") public void testReadString(Path path, String text, Charset cs, Charset cs2) throws IOException { Files.write(path, text.getBytes(cs)); String str = new String(Files.readAllBytes(path), cs); @@ -252,7 +253,7 @@ public class ReadWriteString { // readString @since 11 String str2 = (cs2 == null) ? Files.readString(path) : Files.readString(path, cs2); - assertTrue((str.equals(str2)), "The strings should be the same"); + assertEquals(str, str2, "The strings should be the same"); } /** @@ -264,13 +265,17 @@ public class ReadWriteString { * @param cs the Charset * @throws IOException if the input is malformed */ - @Test(dataProvider = "malformedWrite", expectedExceptions = UnmappableCharacterException.class) + @ParameterizedTest + @MethodSource("getMalformedWrite") public void testMalformedWrite(Path path, String s, Charset cs) throws IOException { - if (cs == null) { - Files.writeString(path, s); - } else { - Files.writeString(path, s, cs); - } + assertThrows(UnmappableCharacterException.class, + () -> { + if (cs == null) { + Files.writeString(path, s); + } else { + Files.writeString(path, s, cs); + } + }); } /** @@ -283,15 +288,19 @@ public class ReadWriteString { * @param csRead the Charset to use for reading the file * @throws IOException when the Charset used for reading the file is incorrect */ - @Test(dataProvider = "illegalInput", expectedExceptions = MalformedInputException.class) + @ParameterizedTest + @MethodSource("getIllegalInput") public void testMalformedRead(Path path, byte[] data, Charset csWrite, Charset csRead) throws IOException { String temp = new String(data, csWrite); Files.writeString(path, temp, csWrite); - if (csRead == null) { - Files.readString(path); - } else { - Files.readString(path, csRead); - } + assertThrows(MalformedInputException.class, + () -> { + if (csRead == null) { + Files.readString(path); + } else { + Files.readString(path, csRead); + } + }); } /** @@ -303,20 +312,19 @@ public class ReadWriteString { * @param expected exception class * @throws IOException when the Charset used for reading the file is incorrect */ - @Test(dataProvider = "illegalInputBytes") + @ParameterizedTest + @MethodSource("getIllegalInputBytes") public void testMalformedReadBytes(byte[] data, Charset csRead, Class expected) throws IOException { Path path = Path.of("illegalInputBytes"); Files.write(path, data); try { Files.readString(path, csRead); - } catch (MalformedInputException | UnmappableCharacterException e) { - if (expected.isInstance(e)) { - // success - return; - } + } catch (MalformedInputException e) { + assertInstanceOf(MalformedInputException.class, e); + } catch (UnmappableCharacterException e) { + assertInstanceOf(UnmappableCharacterException.class, e); } - throw new RuntimeException("An instance of " + expected + " should be thrown"); } // Verify File.readString with UTF16 to confirm proper string length and contents. @@ -326,22 +334,16 @@ public class ReadWriteString { String original = "🤸"; // "\ud83e\udd38"; Files.writeString(testFiles[0], original, UTF_16); String actual = Files.readString(testFiles[0], UTF_16); - if (!actual.equals(original)) { + if (!original.equals(actual)) { System.out.printf("expected (%s), was (%s)\n", original, actual); System.out.printf("expected UTF_16 bytes: %s\n", Arrays.toString(original.getBytes(UTF_16))); System.out.printf("actual UTF_16 bytes: %s\n", Arrays.toString(actual.getBytes(UTF_16))); } - assertEquals(actual, original, "Round trip string mismatch with multi-byte encoding"); + assertEquals(original, actual, "Round trip string mismatch with multi-byte encoding"); } private void checkNullPointerException(Callable c) { - try { - c.call(); - fail("NullPointerException expected"); - } catch (NullPointerException ignore) { - } catch (Exception e) { - fail(e + " not expected"); - } + assertThrows(NullPointerException.class, () -> c.call()); } private void testReadWrite(int size, Charset cs, boolean append) throws IOException { @@ -355,14 +357,14 @@ public class ReadWriteString { } //System.out.println(result.toUri().toASCIIString()); - assertTrue(result == testFiles[0]); + assertSame(result, testFiles[0]); if (append) { if (cs == null) { Files.writeString(testFiles[0], str, APPEND); } else { Files.writeString(testFiles[0], str, cs, APPEND); } - assertTrue(Files.size(testFiles[0]) == size * 2); + assertEquals(size * 2, Files.size(testFiles[0])); } @@ -379,7 +381,7 @@ public class ReadWriteString { read = Files.readString(result, cs); } - assertTrue(read.equals(expected), "String read not the same as written"); + assertEquals(expected, read, "String read not the same as written"); } static final char[] CHARS = "abcdefghijklmnopqrstuvwxyz \r\n".toCharArray(); diff --git a/test/jdk/java/nio/file/Files/SetLastModifiedTime.java b/test/jdk/java/nio/file/Files/SetLastModifiedTime.java index d06b78b2922..c4e5547fb14 100644 --- a/test/jdk/java/nio/file/Files/SetLastModifiedTime.java +++ b/test/jdk/java/nio/file/Files/SetLastModifiedTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,19 +27,20 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.FileTime; -import org.testng.annotations.Test; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @test * @bug 4313887 8062949 8191872 * @library .. - * @run testng SetLastModifiedTime + * @run junit SetLastModifiedTime * @summary Unit test for Files.setLastModifiedTime */ @@ -47,13 +48,13 @@ public class SetLastModifiedTime { static Path testDir; - @BeforeClass - void createTestDirectory() throws Exception { + @BeforeAll + static void createTestDirectory() throws Exception { testDir = TestUtil.createTemporaryDirectory(); } - @AfterClass - void removeTestDirectory() throws Exception { + @AfterAll + static void removeTestDirectory() throws Exception { TestUtil.removeAll(testDir); } @@ -65,12 +66,12 @@ public class SetLastModifiedTime { FileTime zero = FileTime.fromMillis(0L); Path result = Files.setLastModifiedTime(path, zero); - assertTrue(result == path); - assertEquals(Files.getLastModifiedTime(path), zero); + assertSame(path, result); + assertEquals(zero, Files.getLastModifiedTime(path)); result = Files.setLastModifiedTime(path, now); - assertTrue(result == path); - assertEquals(Files.getLastModifiedTime(path), now); + assertSame(path, result); + assertEquals(now, Files.getLastModifiedTime(path)); } @Test @@ -100,20 +101,14 @@ public class SetLastModifiedTime { Path path = Paths.get("foo"); FileTime zero = FileTime.fromMillis(0L); - try { - Files.setLastModifiedTime(null, zero); - assertTrue(false); - } catch (NullPointerException expected) { } + assertThrows(NullPointerException.class, + () -> Files.setLastModifiedTime(null, zero)); - try { - Files.setLastModifiedTime(path, null); - assertTrue(false); - } catch (NullPointerException expected) { } + assertThrows(NullPointerException.class, + () -> Files.setLastModifiedTime(path, null)); - try { - Files.setLastModifiedTime(null, null); - assertTrue(false); - } catch (NullPointerException expected) { } + assertThrows(NullPointerException.class, + () -> Files.setLastModifiedTime(null, null)); } @Test @@ -127,7 +122,7 @@ public class SetLastModifiedTime { long nioTime = Files.getLastModifiedTime(path).toMillis(); assertTrue(ioTime == timeMillis || ioTime == 1000*(timeMillis/1000), "File.lastModified() not in {time, 1000*(time/1000)}"); - assertEquals(nioTime, ioTime, + assertEquals(ioTime, nioTime, "File.lastModified() != Files.getLastModifiedTime().toMillis()"); } } diff --git a/test/jdk/java/nio/file/Files/StreamTest.java b/test/jdk/java/nio/file/Files/StreamTest.java index 0c93a622322..e9e6195ec0a 100644 --- a/test/jdk/java/nio/file/Files/StreamTest.java +++ b/test/jdk/java/nio/file/Files/StreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,7 +25,7 @@ * @bug 8006884 8019526 8132539 * @library .. * @build PassThroughFileSystem FaultyFileSystem - * @run testng StreamTest + * @run junit StreamTest * @summary Unit test for java.nio.file.Files methods that return a Stream */ @@ -35,9 +35,9 @@ import java.nio.charset.Charset; import java.nio.charset.MalformedInputException; import java.nio.file.DirectoryIteratorException; import java.nio.file.DirectoryStream; +import java.nio.file.Files; import java.nio.file.FileSystemLoopException; import java.nio.file.FileVisitOption; -import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; @@ -51,14 +51,23 @@ import java.util.Set; import java.util.TreeSet; import java.util.concurrent.Callable; import java.util.function.BiPredicate; -import java.util.stream.Stream; import java.util.stream.Collectors; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -@Test(groups = "unit") public class StreamTest { /** * Default test folder @@ -77,8 +86,8 @@ public class StreamTest { static Path[] all; static Path[] allFollowLinks; - @BeforeClass - void setupTestFolder() throws IOException { + @BeforeAll + static void setupTestFolder() throws IOException { testFolder = TestUtil.createTemporaryDirectory(); supportsSymbolicLinks = TestUtil.supportsSymbolicLinks(testFolder); TreeSet set = new TreeSet<>(); @@ -133,53 +142,57 @@ public class StreamTest { allFollowLinks = set.toArray(new Path[0]); } - @AfterClass - void cleanupTestFolder() throws IOException { + @AfterAll + static void cleanupTestFolder() throws IOException { TestUtil.removeAll(testFolder); } + @Test public void testBasic() { try (Stream s = Files.list(testFolder)) { Object[] actual = s.sorted().toArray(); - assertEquals(actual, level1); + assertArrayEquals(level1, actual); } catch (IOException ioe) { fail("Unexpected IOException"); } try (Stream s = Files.list(testFolder.resolve("empty"))) { int count = s.mapToInt(p -> 1).reduce(0, Integer::sum); - assertEquals(count, 0, "Expect empty stream."); + assertEquals(0, count, "Expect empty stream."); } catch (IOException ioe) { fail("Unexpected IOException"); } } + @Test public void testWalk() { try (Stream s = Files.walk(testFolder)) { Object[] actual = s.sorted().toArray(); - assertEquals(actual, all); + assertArrayEquals(all, actual); } catch (IOException ioe) { fail("Unexpected IOException"); } } + @Test public void testWalkOneLevel() { try (Stream s = Files.walk(testFolder, 1)) { Object[] actual = s.filter(path -> ! path.equals(testFolder)) .sorted() .toArray(); - assertEquals(actual, level1); + assertArrayEquals(level1, actual); } catch (IOException ioe) { fail("Unexpected IOException"); } } + @Test public void testWalkFollowLink() { // If link is not supported, the directory structure won't have link. // We still want to test the behavior with FOLLOW_LINKS option. try (Stream s = Files.walk(testFolder, FileVisitOption.FOLLOW_LINKS)) { Object[] actual = s.sorted().toArray(); - assertEquals(actual, allFollowLinks); + assertArrayEquals(allFollowLinks, actual); } catch (IOException ioe) { fail("Unexpected IOException"); } @@ -211,6 +224,7 @@ public class StreamTest { } } + @Test public void testWalkFollowLinkLoop() { if (!supportsSymbolicLinks) { return; @@ -257,6 +271,7 @@ public class StreamTest { dir2.resolve(Paths.get("lnDir", "lnDir2"))); validateFileSystemLoopException(linkdir, linkdir.resolve(Paths.get("lnDir2", "lnDir"))); + Files.delete(cause); } catch(IOException ioe) { fail("Unexpected IOException " + ioe); } @@ -280,44 +295,46 @@ public class StreamTest { } } + @Test public void testFind() throws IOException { PathBiPredicate pred = new PathBiPredicate((path, attrs) -> true); try (Stream s = Files.find(testFolder, Integer.MAX_VALUE, pred)) { Set result = s.collect(Collectors.toCollection(TreeSet::new)); - assertEquals(pred.visited(), all); - assertEquals(result.toArray(new Path[0]), pred.visited()); + assertArrayEquals(all, pred.visited()); + assertArrayEquals(pred.visited(), result.toArray(new Path[0])); } pred = new PathBiPredicate((path, attrs) -> attrs.isSymbolicLink()); try (Stream s = Files.find(testFolder, Integer.MAX_VALUE, pred)) { s.forEach(path -> assertTrue(Files.isSymbolicLink(path))); - assertEquals(pred.visited(), all); + assertArrayEquals(all, pred.visited()); } pred = new PathBiPredicate((path, attrs) -> path.getFileName().toString().startsWith("e")); try (Stream s = Files.find(testFolder, Integer.MAX_VALUE, pred)) { s.forEach(path -> assertEquals(path.getFileName().toString(), "empty")); - assertEquals(pred.visited(), all); + assertArrayEquals(all, pred.visited()); } pred = new PathBiPredicate((path, attrs) -> path.getFileName().toString().startsWith("l") && attrs.isRegularFile()); try (Stream s = Files.find(testFolder, Integer.MAX_VALUE, pred)) { s.forEach(path -> fail("Expect empty stream")); - assertEquals(pred.visited(), all); + assertArrayEquals(all, pred.visited()); } } // Test borrowed from BytesAndLines + @Test public void testLines() throws IOException { final Charset US_ASCII = Charset.forName("US-ASCII"); Path tmpfile = Files.createTempFile("blah", "txt"); try { // zero lines - assertTrue(Files.size(tmpfile) == 0, "File should be empty"); + assertEquals(0, Files.size(tmpfile), "File should be empty"); try (Stream s = Files.lines(tmpfile)) { checkLines(s, Collections.emptyList()); } @@ -367,31 +384,21 @@ public class StreamTest { private void checkLines(Stream s, List expected) { List lines = s.collect(Collectors.toList()); - assertTrue(lines.size() == expected.size(), "Unexpected number of lines"); + assertEquals(expected.size(), lines.size(), "Unexpected number of lines"); assertTrue(lines.equals(expected), "Unexpected content"); } private void checkMalformedInputException(Stream s) { - try { - List lines = s.collect(Collectors.toList()); - fail("UncheckedIOException expected"); - } catch (UncheckedIOException ex) { - IOException cause = ex.getCause(); - assertTrue(cause instanceof MalformedInputException, - "MalformedInputException expected"); - } + assertThrows(UncheckedIOException.class, + () -> s.collect(Collectors.toList()), + "MalformedInputException expected"); } private void checkNullPointerException(Callable c) { - try { - c.call(); - fail("NullPointerException expected"); - } catch (NullPointerException ignore) { - } catch (Exception e) { - fail(e + " not expected"); - } + assertThrows(NullPointerException.class, () -> c.call()); } + @Test public void testDirectoryIteratorException() throws IOException { Path dir = testFolder.resolve("dir2"); Path trigger = dir.resolve("DirectoryIteratorException"); @@ -404,22 +411,21 @@ public class StreamTest { Path fakeRoot = fs.getRoot(); try { try (Stream s = Files.list(fakeRoot)) { - s.forEach(path -> assertEquals(path.getFileName().toString(), "DirectoryIteratorException")); + s.forEach(path -> assertEquals("DirectoryIteratorException", path.getFileName().toString())); } } catch (UncheckedIOException uioe) { fail("Unexpected exception."); } fsp.setFaultyMode(true); - try { - try (DirectoryStream ds = Files.newDirectoryStream(fakeRoot)) { - Iterator itor = ds.iterator(); - while (itor.hasNext()) { - itor.next(); - } - } - fail("Shoule throw DirectoryIteratorException"); - } catch (DirectoryIteratorException die) { + try (DirectoryStream ds = Files.newDirectoryStream(fakeRoot)) { + Iterator itor = ds.iterator(); + assertThrows(DirectoryIteratorException.class, + () -> { + while (itor.hasNext()) { + itor.next(); + } + }); } try { @@ -427,7 +433,8 @@ public class StreamTest { s.forEach(path -> fail("should not get here")); } } catch (UncheckedIOException uioe) { - assertTrue(uioe.getCause() instanceof FaultyFileSystem.FaultyException); + assertInstanceOf(FaultyFileSystem.FaultyException.class, + uioe.getCause()); } catch (DirectoryIteratorException die) { fail("Should have been converted into UncheckedIOException."); } @@ -440,6 +447,7 @@ public class StreamTest { } } + @Test public void testUncheckedIOException() throws IOException { Path triggerFile = testFolder.resolve(Paths.get("dir2", "IOException")); Files.createFile(triggerFile); @@ -454,21 +462,22 @@ public class StreamTest { Path fakeRoot = fs.getRoot(); try (Stream s = Files.list(fakeRoot.resolve("dir2"))) { // only one file - s.forEach(path -> assertEquals(path.getFileName().toString(), "IOException")); + s.forEach(path -> assertEquals("IOException", path.getFileName().toString())); } try (Stream s = Files.walk(fakeRoot.resolve("empty"))) { String[] result = s.map(path -> path.getFileName().toString()) .toArray(String[]::new); // ordered as depth-first - assertEquals(result, new String[] { "empty", "IOException", "file"}); + assertArrayEquals(new String[] { "empty", "IOException", "file"}, result); } fsp.setFaultyMode(true); try (Stream s = Files.list(fakeRoot.resolve("dir2"))) { s.forEach(path -> fail("should have caused exception")); } catch (UncheckedIOException uioe) { - assertTrue(uioe.getCause() instanceof FaultyFileSystem.FaultyException); + assertInstanceOf(FaultyFileSystem.FaultyException.class, + uioe.getCause()); } try (Stream s = Files.walk(fakeRoot.resolve("empty"))) { @@ -476,7 +485,8 @@ public class StreamTest { .toArray(String[]::new); fail("should not reach here due to IOException"); } catch (UncheckedIOException uioe) { - assertTrue(uioe.getCause() instanceof FaultyFileSystem.FaultyException); + assertInstanceOf(FaultyFileSystem.FaultyException.class, + uioe.getCause()); } try (Stream s = Files.walk( @@ -486,7 +496,7 @@ public class StreamTest { .toArray(String[]::new); fail("should not reach here due to IOException"); } catch (IOException ioe) { - assertTrue(ioe instanceof FaultyFileSystem.FaultyException); + assertInstanceOf(FaultyFileSystem.FaultyException.class, ioe); } catch (UncheckedIOException ex) { fail("Top level should be repored as is"); } @@ -500,52 +510,47 @@ public class StreamTest { } } + @Test public void testConstructException() { try (Stream s = Files.lines(testFolder.resolve("notExist"), Charset.forName("UTF-8"))) { - s.forEach(l -> fail("File is not even exist!")); + s.forEach(l -> fail("File does not even exist!")); } catch (IOException ioe) { - assertTrue(ioe instanceof NoSuchFileException); + assertInstanceOf(NoSuchFileException.class, ioe); } } + @Test public void testClosedStream() throws IOException { try (Stream s = Files.list(testFolder)) { s.close(); - Object[] actual = s.sorted().toArray(); - fail("Operate on closed stream should throw IllegalStateException"); - } catch (IllegalStateException ex) { - // expected + assertThrows(IllegalStateException.class, + () -> s.sorted().toArray()); } try (Stream s = Files.walk(testFolder)) { s.close(); - Object[] actual = s.sorted().toArray(); - fail("Operate on closed stream should throw IllegalStateException"); - } catch (IllegalStateException ex) { - // expected + assertThrows(IllegalStateException.class, + () -> s.sorted().toArray()); } try (Stream s = Files.find(testFolder, Integer.MAX_VALUE, (p, attr) -> true)) { s.close(); - Object[] actual = s.sorted().toArray(); - fail("Operate on closed stream should throw IllegalStateException"); - } catch (IllegalStateException ex) { - // expected + assertThrows(IllegalStateException.class, + () -> s.sorted().toArray()); } } + @Test + @EnabledOnOs(OS.LINUX) public void testProcFile() throws IOException { - if (System.getProperty("os.name").equals("Linux")) { - Path path = Paths.get("/proc/cpuinfo"); - if (Files.exists(path)) { - String NEW_LINE = System.getProperty("line.separator"); - String s = - Files.lines(path).collect(Collectors.joining(NEW_LINE)); - if (s.length() == 0) { - fail("Files.lines(\"" + path + "\") returns no data"); - } - } + Path path = Paths.get("/proc/cpuinfo"); + if (Files.exists(path)) { + String NEW_LINE = System.getProperty("line.separator"); + String s = + Files.lines(path).collect(Collectors.joining(NEW_LINE)); + assertNotEquals(0, s.length(), + "Files.lines(\"" + path + "\") returns no data"); } } } diff --git a/test/jdk/java/nio/file/Files/SubstDrive.java b/test/jdk/java/nio/file/Files/SubstDrive.java index 94fdeadcef3..fd21b9f007e 100644 --- a/test/jdk/java/nio/file/Files/SubstDrive.java +++ b/test/jdk/java/nio/file/Files/SubstDrive.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2020 Microsoft Corporation. All rights reserved. - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,32 +23,35 @@ * */ +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.nio.file.*; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.*; - -import static org.testng.Assert.*; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; -import org.testng.SkipException; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /* @test * @summary Test Files' public APIs with drives created using the subst command on Windows. * @requires (os.family == "windows") * @library /test/lib .. * @build SubstDrive - * @run testng SubstDrive + * @run junit SubstDrive */ public class SubstDrive { @@ -62,26 +65,24 @@ public class SubstDrive { * deleted when the test finishes. * + Find a drive that is available for use with subst. */ - @BeforeClass - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { TEST_TEMP_DIRECTORY = Files.createTempDirectory("tmp"); - System.out.printf("Test directory is at %s\n", TEST_TEMP_DIRECTORY); + System.err.printf("Test directory is at %s\n", TEST_TEMP_DIRECTORY); Optional substDrive = findAvailableDrive(TEST_TEMP_DIRECTORY); - if (!substDrive.isPresent()) { - throw new SkipException( - "Could not find any available drive to use with subst, skipping the tests"); - } + Assumptions.assumeTrue(substDrive.isPresent(), + "Could not find any available drive to use with subst"); SUBST_DRIVE = substDrive.get(); - System.out.printf("Using drive %s\n with subst", SUBST_DRIVE); + System.err.printf("Using drive %s\n with subst", SUBST_DRIVE); } /** * Delete the root temporary directory together with all of its contents * when all tests finish. */ - @AfterClass - public void removeRootTempDirectory() throws IOException { + @AfterAll + public static void removeRootTempDirectory() throws IOException { TestUtil.removeAll(TEST_TEMP_DIRECTORY); } @@ -90,7 +91,7 @@ public class SubstDrive { * unmap the drive after every test so that subsequent ones can reuse * the drive. */ - @AfterMethod + @AfterEach public void deleteSubstDrive() throws IOException { Stream substitutedDrives = substFindMappedDrives(); // Only delete `SUBST_DRIVE` if it is currently being substituted @@ -114,7 +115,7 @@ public class SubstDrive { assertTrue(Files.exists(p)); Files.writeString(p, fileContents); - assertEquals(Files.readString(p), fileContents); + assertEquals(fileContents, Files.readString(p)); } /** @@ -193,7 +194,7 @@ public class SubstDrive { Map attr1 = Files.readAttributes(SUBST_DRIVE, "*"); Map attr2 = Files.readAttributes(tempDirectory, "*"); - assertEquals(attr1, attr2); + assertEquals(attr2, attr1); } /** @@ -287,19 +288,19 @@ public class SubstDrive { Path tempFile = Path.of(SUBST_DRIVE.toString(), "test.txt"); String contents = "Hello world!"; Files.writeString(tempFile, contents); - assertEquals(Files.readString(tempFile), contents); + assertEquals(contents, Files.readString(tempFile)); Path link = Path.of(SUBST_DRIVE.toString(), "link"); Files.createSymbolicLink(link, tempFile); - assertEquals(Files.readString(link), contents); - assertEquals(Files.isExecutable(link), Files.isExecutable(tempFile)); - assertEquals(Files.isReadable(link), Files.isReadable(tempFile)); - assertEquals(Files.isDirectory(link), Files.isDirectory(tempFile)); - assertEquals(Files.isHidden(link), Files.isHidden(tempFile)); - assertEquals(Files.isRegularFile(link), Files.isRegularFile(tempFile)); - assertEquals(Files.isWritable(link), Files.isWritable(tempFile)); - assertEquals(Files.getOwner(link), Files.getOwner(tempFile)); + assertEquals(contents, Files.readString(link)); + assertEquals(Files.isExecutable(tempFile), Files.isExecutable(link)); + assertEquals(Files.isReadable(tempFile), Files.isReadable(link)); + assertEquals(Files.isDirectory(tempFile), Files.isDirectory(link)); + assertEquals(Files.isHidden(tempFile), Files.isHidden(link)); + assertEquals(Files.isRegularFile(tempFile), Files.isRegularFile(link)); + assertEquals(Files.isWritable(tempFile), Files.isWritable(link)); + assertEquals(Files.getOwner(tempFile), Files.getOwner(link)); } /** @@ -319,16 +320,15 @@ public class SubstDrive { substCreate(SUBST_DRIVE, tempLink); - assertEquals( - Files.readAttributes(SUBST_DRIVE, "*"), - Files.readAttributes(tempDirectory, "*")); + assertTrue(Files.readAttributes(tempDirectory, "*") + .equals(Files.readAttributes(SUBST_DRIVE, "*"))); assertTrue(Files.isWritable(SUBST_DRIVE)); Path tempFile = Files.createTempFile(SUBST_DRIVE, "prefix", "suffix"); String contents = "Hello world!"; Files.writeString(tempFile, contents); - assertEquals(Files.readString(tempFile), contents); + assertEquals(contents, Files.readString(tempFile)); Path tempDirectory2 = Files.createTempDirectory(TEST_TEMP_DIRECTORY, "tmp"); Path copy = Path.of(tempDirectory2.toString(), "copied"); @@ -341,7 +341,7 @@ public class SubstDrive { Files.move(tempFile, cut); assertTrue(Files.notExists(tempFile)); assertTrue(Files.exists(cut)); - assertEquals(Files.readString(cut), contents); + assertEquals(contents, Files.readString(cut)); } /** @@ -361,9 +361,8 @@ public class SubstDrive { substCreate(SUBST_DRIVE, tempLink); - assertEquals( - Files.readAttributes(SUBST_DRIVE, "*"), - Files.readAttributes(tempDirectory, "*")); + assertTrue(Files.readAttributes(tempDirectory, "*") + .equals(Files.readAttributes(SUBST_DRIVE, "*"))); assertTrue(Files.isWritable(SUBST_DRIVE)); } @@ -372,7 +371,7 @@ public class SubstDrive { * Run a command and optionally prints stdout contents to * `customOutputStream`. */ - private void runCmd(ProcessBuilder pb, PrintStream customOutputStream) { + private static void runCmd(ProcessBuilder pb, PrintStream customOutputStream) { try { PrintStream ps = customOutputStream != null ? customOutputStream : @@ -383,8 +382,8 @@ public class SubstDrive { int exitCode = outputAnalyzer.getExitValue(); assertEquals( - exitCode /* actual value */, 0 /* expected value */, + exitCode /* actual value */, String.format( "Command `%s` failed with exit code %d", pb.command(), @@ -402,7 +401,7 @@ public class SubstDrive { * For reference, see: * https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst */ - private void substCreate(Path drive, Path path) { + private static void substCreate(Path drive, Path path) { runCmd( new ProcessBuilder( "cmd", "/c", "subst", drive.toString(), path.toString()), @@ -414,7 +413,7 @@ public class SubstDrive { * For reference, see: * https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst */ - private void substDelete(Path drive) throws IOException { + private static void substDelete(Path drive) throws IOException { runCmd( new ProcessBuilder( "cmd", "/c", "subst", drive.toString(), "/D"), @@ -454,7 +453,7 @@ public class SubstDrive { * subst can fail if the drive to be mapped already exists. The method returns * a drive that is available. */ - private Optional findAvailableDrive(Path tempDirectory) { + private static Optional findAvailableDrive(Path tempDirectory) { for (char letter = 'Z'; letter >= 'A'; letter--) { try { Path p = Path.of(letter + ":"); diff --git a/test/jdk/java/nio/file/Files/walkFileTree/FindTest.java b/test/jdk/java/nio/file/Files/walkFileTree/FindTest.java index 9fb16a7b14c..beacee44bbb 100644 --- a/test/jdk/java/nio/file/Files/walkFileTree/FindTest.java +++ b/test/jdk/java/nio/file/Files/walkFileTree/FindTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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,15 +34,15 @@ * jdk.test.lib.Platform * jdk.test.lib.process.* * CreateFileTree - * @run testng/othervm -Djava.io.tmpdir=. FindTest + * @run junit/othervm -Djava.io.tmpdir=. FindTest */ import java.io.IOException; +import java.nio.file.Files; import java.nio.file.FileSystemLoopException; import java.nio.file.FileVisitOption; -import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; -import java.nio.file.Files; +import java.nio.file.FileVisitResult; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; @@ -56,11 +56,11 @@ import java.util.stream.Collectors; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FindTest { @@ -69,7 +69,7 @@ public class FindTest { private static Path top; private static String TOP; - @BeforeClass + @BeforeAll public static void createFileTree() throws Exception { top = CreateFileTree.create(); TOP = top.toAbsolutePath().toString(); @@ -107,7 +107,7 @@ public class FindTest { throws IOException { List expectedList = Arrays.asList(expected.getStdout() .split(System.lineSeparator())); - assertEquals(actual.size(), expectedList.size()); + assertEquals(expectedList.size(), actual.size()); assertTrue(actual.removeAll(expectedList)); } diff --git a/test/jdk/java/nio/file/spi/TestDelegation.java b/test/jdk/java/nio/file/spi/TestDelegation.java index 0b9bc9de7f7..f09b636c156 100644 --- a/test/jdk/java/nio/file/spi/TestDelegation.java +++ b/test/jdk/java/nio/file/spi/TestDelegation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,11 +21,6 @@ * questions. */ -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.net.URI; import java.nio.file.*; @@ -34,26 +29,34 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; -import static org.testng.AssertJUnit.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @test * @summary Verifies that a FileSystemProvider's implementation of the exists * and readAttributesIfExists methods are invoked * @compile testfsp/testfsp/TestProvider.java - * @run testng TestDelegation + * @run junit TestDelegation */ public class TestDelegation { // Non-existent Path to be used by the test - private Path nonExistentFile; + private static Path nonExistentFile; // Path to Temp directory used by the test - private Path tempDirectory; + private static Path tempDirectory; // Valid file Path used by the test - private Path fileThatExists; + private static Path fileThatExists; // The FileSystemProvider used by the test - private MyProvider myProvider; + private static MyProvider myProvider; /** * Create the FileSystemProvider, the FileSystem and @@ -61,8 +64,8 @@ public class TestDelegation { * * @throws IOException if an error occurs */ - @BeforeClass - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { myProvider = new MyProvider(); FileSystem fs = myProvider.getFileSystem(URI.create("/")); // Path to Current Working Directory @@ -73,7 +76,7 @@ public class TestDelegation { } /** - * DataProvider that is used to test Files::exists. The DataProvider's + * MethodSource that is used to test Files::exists. The Arguments' * elements are: *
    *
  • Path to validate
  • @@ -81,17 +84,14 @@ public class TestDelegation { *
* @return The test parameter data */ - @DataProvider - private Object[][] testExists() { - return new Object[][]{ - {tempDirectory, true}, - {fileThatExists, true}, - {nonExistentFile, false} - }; + private static Stream testExists() { + return Stream.of(Arguments.of(tempDirectory, true), + Arguments.of(fileThatExists, true), + Arguments.of(nonExistentFile, false)); } /** - * DataProvider that is used to test Files::isDirectory. The DataProvider's + * MethodSource that is used to test Files::isDirectory. The Arguments' * elements are: *
    *
  • Path to validate
  • @@ -99,16 +99,13 @@ public class TestDelegation { *
* @return The test parameter data */ - @DataProvider - private Object[][] testIsDirectory() { - return new Object[][]{ - {tempDirectory, true}, - {fileThatExists, false}, - {nonExistentFile, false} - }; + private static Stream testIsDirectory() { + return Stream.of(Arguments.of(tempDirectory, true), + Arguments.of(fileThatExists, false), + Arguments.of(nonExistentFile, false)); } /** - * DataProvider that is used to test Files::isRegularFile. The DataProvider's + * MethodSource that is used to test Files::isRegularFile. The MethodSource's * elements are: *
    *
  • Path to validate
  • @@ -116,19 +113,16 @@ public class TestDelegation { *
* @return The test parameter data */ - @DataProvider - private Object[][] testIsRegularFile() { - return new Object[][]{ - {tempDirectory, false}, - {fileThatExists, true}, - {nonExistentFile, false} - }; + private static Stream testIsRegularFile() { + return Stream.of(Arguments.of(tempDirectory, false), + Arguments.of(fileThatExists, true), + Arguments.of(nonExistentFile, false)); } /** * Clear our Map prior to each test run */ - @BeforeMethod + @BeforeEach public void resetParams() { myProvider.resetCalls(); } @@ -140,9 +134,10 @@ public class TestDelegation { * @param p the path to the file to test * @param exists does the path exist */ - @Test(dataProvider = "testExists") + @ParameterizedTest + @MethodSource("testExists") public void testExists(Path p, boolean exists) { - assertEquals(Files.exists(p), exists); + assertEquals(exists, Files.exists(p)); // We should only have called exists once assertEquals(1, myProvider.findCall("exists").size()); assertEquals(0, myProvider.findCall("readAttributesIfExists").size()); @@ -155,9 +150,10 @@ public class TestDelegation { * @param p the path to the file to test * @param isDir is the path a directory */ - @Test(dataProvider = "testIsDirectory") + @ParameterizedTest + @MethodSource("testIsDirectory") public void testIsDirectory(Path p, boolean isDir) { - assertEquals(Files.isDirectory(p), isDir); + assertEquals(isDir, Files.isDirectory(p)); // We should only have called readAttributesIfExists once assertEquals(0, myProvider.findCall("exists").size()); assertEquals(1, myProvider.findCall("readAttributesIfExists").size()); @@ -170,9 +166,10 @@ public class TestDelegation { * @param p the path to the file to test * @param isFile is the path a regular file */ - @Test(dataProvider = "testIsRegularFile") + @ParameterizedTest + @MethodSource("testIsRegularFile") public void testIsRegularFile(Path p, boolean isFile) { - assertEquals(Files.isRegularFile(p), isFile); + assertEquals(isFile, Files.isRegularFile(p)); // We should only have called readAttributesIfExists once assertEquals(0, myProvider.findCall("exists").size()); assertEquals(1, myProvider.findCall("readAttributesIfExists").size()); diff --git a/test/hotspot/jtreg/runtime/cds/SharedStringsWb.java b/test/jdk/java/security/KeyStore/DisabledKnownType.java similarity index 50% rename from test/hotspot/jtreg/runtime/cds/SharedStringsWb.java rename to test/jdk/java/security/KeyStore/DisabledKnownType.java index 5a4d24e4fdf..70b7228f4c2 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStringsWb.java +++ b/test/jdk/java/security/KeyStore/DisabledKnownType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, 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,34 +21,33 @@ * questions. */ -import jdk.test.whitebox.WhiteBox; +/** + * @test + * @bug 8373690 + * @summary verify that the exception message indicates the keystore type + * when the type is disabled instead of being unrecognized + * @run main/othervm -Djdk.crypto.disabledAlgorithms=KeyStore.PKCS12 DisabledKnownType + */ -// This class is used by the test SharedStrings.java -// It should be launched in CDS mode -public class SharedStringsWb { +import java.security.KeyStore; +import java.security.KeyStoreException; + +public class DisabledKnownType { public static void main(String[] args) throws Exception { - WhiteBox wb = WhiteBox.getWhiteBox(); - - if (!wb.areSharedStringsMapped()) { - System.out.println("Shared strings are not mapped, assuming PASS"); - return; - } - - // The string below is known to be added to CDS archive - String s = ""; - String internedS = s.intern(); - - // Check that it's a valid string - if (s.getClass() != String.class || !(s instanceof String)) { - throw new RuntimeException("Shared string is not a valid String: FAIL"); - } - - if (wb.isSharedInternedString(internedS)) { - System.out.println("Found shared string, result: PASS"); - } else { - throw new RuntimeException("String is not shared, result: FAIL"); + String cacertsPath = System.getProperty("java.home") + + "/lib/security/cacerts"; + try { + KeyStore ks = KeyStore.getInstance(new java.io.File(cacertsPath), + "changeit".toCharArray()); + throw new RuntimeException("Expected KeyStoreException not thrown"); + } catch (KeyStoreException kse) { + if (kse.getMessage().contains("PKCS12")) { + System.out.println("Passed: expected ex thrown: " + kse); + } else { + // pass it up + throw kse; + } } } } - diff --git a/test/jdk/java/util/Arrays/ArraysEqCmpTest.java b/test/jdk/java/util/Arrays/ArraysEqCmpTest.java index a2bb9ce6a79..5e987746771 100644 --- a/test/jdk/java/util/Arrays/ArraysEqCmpTest.java +++ b/test/jdk/java/util/Arrays/ArraysEqCmpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,12 +25,9 @@ * @test * @bug 8033148 8141409 * @summary tests for array equals and compare - * @run testng ArraysEqCmpTest + * @run junit ArraysEqCmpTest */ -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -46,6 +43,13 @@ import java.util.function.BiFunction; import java.util.function.LongFunction; import java.util.stream.IntStream; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ArraysEqCmpTest { // Maximum width in bits @@ -588,7 +592,6 @@ public class ArraysEqCmpTest { static Object[][] arrayTypes; - @DataProvider public static Object[][] arrayTypesProvider() { if (arrayTypes == null) { arrayTypes = new Object[][]{ @@ -613,7 +616,6 @@ public class ArraysEqCmpTest { static Object[][] floatArrayTypes; - @DataProvider public static Object[][] floatArrayTypesProvider() { if (floatArrayTypes == null) { LongFunction bTof = rb -> Float.intBitsToFloat((int) rb); @@ -629,7 +631,6 @@ public class ArraysEqCmpTest { static Object[][] objectArrayTypes; - @DataProvider public static Object[][] objectArrayTypesProvider() { if (objectArrayTypes == null) { LongFunction bTof = rb -> Float.intBitsToFloat((int) rb); @@ -646,7 +647,6 @@ public class ArraysEqCmpTest { static Object[][] signedUnsignedArrayTypes; - @DataProvider public static Object[][] signedUnsignedArrayTypes() { if (signedUnsignedArrayTypes == null) { signedUnsignedArrayTypes = new Object[][]{ @@ -661,7 +661,8 @@ public class ArraysEqCmpTest { // Equality and comparison tests - @Test(dataProvider = "arrayTypesProvider") + @ParameterizedTest + @MethodSource("arrayTypesProvider") public void testArray(ArrayType arrayType) { BiFunction, Integer, Object> constructor = (at, s) -> { Object a = at.construct(s); @@ -677,7 +678,8 @@ public class ArraysEqCmpTest { testArrayType(arrayType, constructor, cloner); } - @Test(dataProvider = "floatArrayTypesProvider") + @ParameterizedTest + @MethodSource("floatArrayTypesProvider") public void testPrimitiveFloatArray( ArrayType arrayType, long canonicalNanRawBits, long nonCanonicalNanRawBits, @@ -722,7 +724,8 @@ public class ArraysEqCmpTest { testArrayType(arrayType, canonicalNaNs, halfNonCanonicalNaNs); } - @Test(dataProvider = "objectArrayTypesProvider") + @ParameterizedTest + @MethodSource("objectArrayTypesProvider") public void testNullElementsInObjectArray(ArrayType arrayType) { BiFunction, Object, Object> cloner = ArrayType::copyOf; @@ -752,11 +755,12 @@ public class ArraysEqCmpTest { Integer[] a = new Integer[]{null, 0}; Integer[] b = new Integer[]{0, 0}; - Assert.assertTrue(Arrays.compare(a, b) < 0); - Assert.assertTrue(Arrays.compare(b, a) > 0); + Assertions.assertTrue(Arrays.compare(a, b) < 0); + Assertions.assertTrue(Arrays.compare(b, a) > 0); } - @Test(dataProvider = "objectArrayTypesProvider") + @ParameterizedTest + @MethodSource("objectArrayTypesProvider") public void testSameRefElementsInObjectArray(ArrayType arrayType) { BiFunction, Object, Object> cloner = ArrayType::copyOf; @@ -796,7 +800,8 @@ public class ArraysEqCmpTest { cloner); } - @Test(dataProvider = "signedUnsignedArrayTypes") + @ParameterizedTest + @MethodSource("signedUnsignedArrayTypes") public void testSignedUnsignedArray(ArrayType sat, ArrayType uat) { BiFunction, Integer, Object> constructor = (at, s) -> { Object a = at.construct(s); @@ -824,8 +829,8 @@ public class ArraysEqCmpTest { int sc = sat.compare(ac, aFrom, aTo, a, aFrom, aTo); int uc = uat.compare(ac, aFrom, aTo, a, aFrom, aTo); - Assert.assertTrue(sc < 0); - Assert.assertTrue(uc > 0); + Assertions.assertTrue(sc < 0); + Assertions.assertTrue(uc > 0); } } } @@ -854,31 +859,31 @@ public class ArraysEqCmpTest { Object bnr = at.copyOf(b, bFrom, bTo); boolean eq = isEqual(at, a, aFrom, aTo, b, bFrom, bTo); - Assert.assertEquals(at.equals(a, aFrom, aTo, b, bFrom, bTo), eq); - Assert.assertEquals(at.equals(b, bFrom, bTo, a, aFrom, aTo), eq); - Assert.assertEquals(at.equals(anr, bnr), eq); - Assert.assertEquals(at.equals(bnr, anr), eq); + Assertions.assertEquals(eq, at.equals(a, aFrom, aTo, b, bFrom, bTo)); + Assertions.assertEquals(eq, at.equals(b, bFrom, bTo, a, aFrom, aTo)); + Assertions.assertEquals(eq, at.equals(anr, bnr)); + Assertions.assertEquals(eq, at.equals(bnr, anr)); if (eq) { - Assert.assertEquals(at.compare(a, aFrom, aTo, b, bFrom, bTo), 0); - Assert.assertEquals(at.compare(b, bFrom, bTo, a, aFrom, aTo), 0); - Assert.assertEquals(at.compare(anr, bnr), 0); - Assert.assertEquals(at.compare(bnr, anr), 0); + Assertions.assertEquals(0, at.compare(a, aFrom, aTo, b, bFrom, bTo)); + Assertions.assertEquals(0, at.compare(b, bFrom, bTo, a, aFrom, aTo)); + Assertions.assertEquals(0, at.compare(anr, bnr)); + Assertions.assertEquals(0, at.compare(bnr, anr)); - Assert.assertEquals(at.mismatch(a, aFrom, aTo, b, bFrom, bTo), -1); - Assert.assertEquals(at.mismatch(b, bFrom, bTo, a, aFrom, aTo), -1); - Assert.assertEquals(at.mismatch(anr, bnr), -1); - Assert.assertEquals(at.mismatch(bnr, anr), -1); + Assertions.assertEquals(-1, at.mismatch(a, aFrom, aTo, b, bFrom, bTo)); + Assertions.assertEquals(-1, at.mismatch(b, bFrom, bTo, a, aFrom, aTo)); + Assertions.assertEquals(-1, at.mismatch(anr, bnr)); + Assertions.assertEquals(-1, at.mismatch(bnr, anr)); } else { int aCb = at.compare(a, aFrom, aTo, b, bFrom, bTo); int bCa = at.compare(b, bFrom, bTo, a, aFrom, aTo); int v = Integer.signum(aCb) * Integer.signum(bCa); - Assert.assertTrue(v == -1); + Assertions.assertTrue(v == -1); int anrCbnr = at.compare(anr, bnr); int bnrCanr = at.compare(bnr, anr); - Assert.assertEquals(anrCbnr, aCb); - Assert.assertEquals(bnrCanr, bCa); + Assertions.assertEquals(aCb, anrCbnr); + Assertions.assertEquals(bCa, bnrCanr); int aMb = at.mismatch(a, aFrom, aTo, b, bFrom, bTo); @@ -886,18 +891,18 @@ public class ArraysEqCmpTest { int anrMbnr = at.mismatch(anr, bnr); int bnrManr = at.mismatch(bnr, anr); - Assert.assertNotEquals(aMb, -1); - Assert.assertEquals(aMb, bMa); - Assert.assertNotEquals(anrMbnr, -1); - Assert.assertEquals(anrMbnr, bnrManr); - Assert.assertEquals(aMb, anrMbnr); - Assert.assertEquals(bMa, bnrManr); + Assertions.assertNotEquals(-1, aMb); + Assertions.assertEquals(bMa, aMb); + Assertions.assertNotEquals(-1, anrMbnr); + Assertions.assertEquals(bnrManr, anrMbnr); + Assertions.assertEquals(anrMbnr, aMb); + Assertions.assertEquals(bnrManr, bMa); // Common or proper prefix - Assert.assertTrue(at.equals(a, aFrom, aFrom + aMb, b, bFrom, bFrom + aMb)); + Assertions.assertTrue(at.equals(a, aFrom, aFrom + aMb, b, bFrom, bFrom + aMb)); if (aMb < Math.min(aLength, bLength)) { // Common prefix - Assert.assertFalse(isEqual(at, a, aFrom + aMb, b, bFrom + aMb)); + Assertions.assertFalse(isEqual(at, a, aFrom + aMb, b, bFrom + aMb)); } } } @@ -912,29 +917,29 @@ public class ArraysEqCmpTest { Object acnr = at.copyOf(ac, aFrom, aTo); Object anr = at.copyOf(a, aFrom, aTo); - Assert.assertFalse(at.equals(ac, aFrom, aTo, a, aFrom, aTo)); - Assert.assertFalse(at.equals(acnr, anr)); + Assertions.assertFalse(at.equals(ac, aFrom, aTo, a, aFrom, aTo)); + Assertions.assertFalse(at.equals(acnr, anr)); int acCa = at.compare(ac, aFrom, aTo, a, aFrom, aTo); int aCac = at.compare(a, aFrom, aTo, ac, aFrom, aTo); int v = Integer.signum(acCa) * Integer.signum(aCac); - Assert.assertTrue(v == -1); + Assertions.assertTrue(v == -1); int acnrCanr = at.compare(acnr, anr); int anrCacnr = at.compare(anr, acnr); - Assert.assertEquals(acnrCanr, acCa); - Assert.assertEquals(anrCacnr, aCac); + Assertions.assertEquals(acCa, acnrCanr); + Assertions.assertEquals(aCac, anrCacnr); int acMa = at.mismatch(ac, aFrom, aTo, a, aFrom, aTo); int aMac = at.mismatch(a, aFrom, aTo, ac, aFrom, aTo); - Assert.assertEquals(acMa, aMac); - Assert.assertEquals(acMa, i - aFrom); + Assertions.assertEquals(aMac, acMa); + Assertions.assertEquals(i - aFrom, acMa); int acnrManr = at.mismatch(acnr, anr); int anrMacnr = at.mismatch(anr, acnr); - Assert.assertEquals(acnrManr, anrMacnr); - Assert.assertEquals(acnrManr, i - aFrom); + Assertions.assertEquals(anrMacnr, acnrManr); + Assertions.assertEquals(i - aFrom, acnrManr); } } } @@ -986,24 +991,26 @@ public class ArraysEqCmpTest { // Null array reference tests - @Test(dataProvider = "arrayTypesProvider") + @ParameterizedTest + @MethodSource("arrayTypesProvider") public void testNullArrayRefs(ArrayType arrayType) { Object n = null; Object a = arrayType.construct(0); - Assert.assertTrue(arrayType.equals(n, n)); - Assert.assertFalse(arrayType.equals(n, a)); - Assert.assertFalse(arrayType.equals(a, n)); + Assertions.assertTrue(arrayType.equals(n, n)); + Assertions.assertFalse(arrayType.equals(n, a)); + Assertions.assertFalse(arrayType.equals(a, n)); - Assert.assertEquals(arrayType.compare(n, n), 0); - Assert.assertTrue(arrayType.compare(n, a) < 0); - Assert.assertTrue(arrayType.compare(a, n) > 0); + Assertions.assertEquals(0, arrayType.compare(n, n)); + Assertions.assertTrue(arrayType.compare(n, a) < 0); + Assertions.assertTrue(arrayType.compare(a, n) > 0); } // Exception throwing tests - @Test(dataProvider = "arrayTypesProvider") + @ParameterizedTest + @MethodSource("arrayTypesProvider") public void testNPEs(ArrayType arrayType) { Object[] values = new Object[]{null, arrayType.construct(0)}; @@ -1046,7 +1053,8 @@ public class ArraysEqCmpTest { } } - @Test(dataProvider = "arrayTypesProvider") + @ParameterizedTest + @MethodSource("arrayTypesProvider") public void testIAEs(ArrayType arrayType) { List values = Arrays.asList(0, 1); @@ -1065,7 +1073,8 @@ public class ArraysEqCmpTest { } } - @Test(dataProvider = "arrayTypesProvider") + @ParameterizedTest + @MethodSource("arrayTypesProvider") public void testAIOBEs(ArrayType arrayType) { List froms = Arrays.asList(-1, 0); @@ -1110,7 +1119,7 @@ public class ArraysEqCmpTest { catch (Throwable t) { caught = t; } - Assert.assertNotNull(caught); - Assert.assertTrue(expected.isInstance(caught)); + Assertions.assertNotNull(caught); + Assertions.assertTrue(expected.isInstance(caught)); } } \ No newline at end of file diff --git a/test/jdk/java/util/Arrays/AsList.java b/test/jdk/java/util/Arrays/AsList.java index c64c473a822..b02f1dcbe68 100644 --- a/test/jdk/java/util/Arrays/AsList.java +++ b/test/jdk/java/util/Arrays/AsList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,11 +21,11 @@ * questions. */ -/** +/* * @test * @bug 8155600 * @summary Tests for Arrays.asList() - * @run testng AsList + * @run junit AsList */ import java.util.Arrays; @@ -33,46 +33,35 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.stream.IntStream; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AsList { /* * Iterator contract test */ - @Test(dataProvider = "Arrays") + @ParameterizedTest + @MethodSource("arrays") public void testIterator(Object[] array) { Iterator itr = Arrays.asList(array).iterator(); - for (int i = 0; i < array.length; i++) { + for (Object o : array) { assertTrue(itr.hasNext()); assertTrue(itr.hasNext()); // must be idempotent - assertSame(array[i], itr.next()); - try { - itr.remove(); - fail("Remove must throw"); - } catch (UnsupportedOperationException ex) { - // expected - } + assertSame(o, itr.next()); + assertThrows(UnsupportedOperationException.class, itr::remove); } - assertFalse(itr.hasNext()); for (int i = 0; i < 3; i++) { assertFalse(itr.hasNext()); - try { - itr.next(); - fail("Next succeed when there's no data left"); - } catch (NoSuchElementException ex) { - // expected - } + assertThrows(NoSuchElementException.class, itr::next); } } - @DataProvider(name = "Arrays") public static Object[][] arrays() { - Object[][] arrays = { + return new Object[][] { { new Object[] { } }, { new Object[] { 1 } }, { new Object[] { null } }, @@ -87,7 +76,5 @@ public class AsList { { new Object[] { "a", "a", "a", "a" } }, { IntStream.range(0, 100).boxed().toArray() } }; - - return arrays; } } diff --git a/test/jdk/java/util/Arrays/Correct.java b/test/jdk/java/util/Arrays/Correct.java index f69ea9160ff..dce169bb0fc 100644 --- a/test/jdk/java/util/Arrays/Correct.java +++ b/test/jdk/java/util/Arrays/Correct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,17 +25,19 @@ * @test * @bug 4726380 8037097 * @summary Check that different sorts give equivalent results. - * @run testng Correct * @key randomness + * @run junit Correct */ import java.util.*; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.fail; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class Correct { static final Random rnd = new Random(); @@ -50,11 +52,12 @@ public class Correct { Integer[] array2 = Arrays.copyOf(array1, array1.length); Arrays.sort(array1, array1.length/3, array1.length/2); stupidSort(array2, array2.length/3, array2.length/2); - assertEquals(array1, array2, "Arrays did not match. size=" + size); + Assertions.assertArrayEquals(array2, array1, "Arrays did not match. size=" + size); } } - @Test(dataProvider = "Comparators") + @ParameterizedTest + @MethodSource("comparators") public void testComparatorSort(Comparator comparator) { for (int i=0; i comparators() { Object[][] comparators = new Object[][] { new Object[] { Comparator.naturalOrder() }, diff --git a/test/jdk/java/util/Arrays/SetAllTest.java b/test/jdk/java/util/Arrays/SetAllTest.java index 23a3578cf69..25a229d23d4 100644 --- a/test/jdk/java/util/Arrays/SetAllTest.java +++ b/test/jdk/java/util/Arrays/SetAllTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,11 +25,9 @@ * @test * @bug 8012650 * @summary Unit test for setAll, parallelSetAll variants - * @run testng SetAllTest + * @run junit SetAllTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.util.Arrays; import java.util.function.IntFunction; @@ -37,12 +35,15 @@ import java.util.function.IntToDoubleFunction; import java.util.function.IntToLongFunction; import java.util.function.IntUnaryOperator; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class SetAllTest { private static final IntFunction toString = i -> "N" + Integer.valueOf(i); private static final IntFunction fillString = i -> "X"; @@ -93,52 +94,51 @@ public class SetAllTest { { "fill", 3, fillDouble, new double[] { 3.14, 3.14, 3.14 }} }; - @DataProvider(name="string") public Object[][] stringTests() { return stringData; } - @DataProvider(name="int") public Object[][] intTests() { return intData; } - @DataProvider(name="long") public Object[][] longTests() { return longData; } - @DataProvider(name="double") public Object[][] doubleTests() { return doubleData; } - @Test(dataProvider = "string") + @ParameterizedTest + @MethodSource("stringTests") public void testSetAllString(String name, int size, IntFunction generator, String[] expected) { String[] result = new String[size]; Arrays.setAll(result, generator); - assertEquals(result, expected, "setAll(String[], IntFunction) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "setAll(String[], IntFunction) case " + name + " failed."); // ensure fresh array result = new String[size]; Arrays.parallelSetAll(result, generator); - assertEquals(result, expected, "parallelSetAll(String[], IntFunction) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "parallelSetAll(String[], IntFunction) case " + name + " failed."); } - @Test(dataProvider = "int") + @ParameterizedTest + @MethodSource("intTests") public void testSetAllInt(String name, int size, IntUnaryOperator generator, int[] expected) { int[] result = new int[size]; Arrays.setAll(result, generator); - assertEquals(result, expected, "setAll(int[], IntUnaryOperator) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "setAll(int[], IntUnaryOperator) case " + name + " failed."); // ensure fresh array result = new int[size]; Arrays.parallelSetAll(result, generator); - assertEquals(result, expected, "parallelSetAll(int[], IntUnaryOperator) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "parallelSetAll(int[], IntUnaryOperator) case " + name + " failed."); } - @Test(dataProvider = "long") + @ParameterizedTest + @MethodSource("longTests") public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) { long[] result = new long[size]; Arrays.setAll(result, generator); - assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "setAll(long[], IntToLongFunction) case " + name + " failed."); // ensure fresh array result = new long[size]; Arrays.parallelSetAll(result, generator); - assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed."); + Assertions.assertArrayEquals(expected, result, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed."); } private void assertDoubleArrayEquals(double[] actual, double[] expected, double delta, String msg) { @@ -151,7 +151,8 @@ public class SetAllTest { } } - @Test(dataProvider = "double") + @ParameterizedTest + @MethodSource("doubleTests") public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) { double[] result = new double[size]; Arrays.setAll(result, generator); diff --git a/test/jdk/java/util/Arrays/SortingNearlySortedPrimitive.java b/test/jdk/java/util/Arrays/SortingNearlySortedPrimitive.java index b2c8d6ec45b..b9ad458688e 100644 --- a/test/jdk/java/util/Arrays/SortingNearlySortedPrimitive.java +++ b/test/jdk/java/util/Arrays/SortingNearlySortedPrimitive.java @@ -1,6 +1,6 @@ /* * Copyright 2015 Goldman Sachs. - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,11 +30,9 @@ * sorted and if so employs and optimizes merge sort rather than a * Dual-Pivot QuickSort. * - * @run testng SortingNearlySortedPrimitive + * @run junit SortingNearlySortedPrimitive */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; @@ -44,6 +42,12 @@ import java.util.function.IntFunction; import java.util.stream.IntStream; import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class SortingNearlySortedPrimitive { static final int BASE = 3; @@ -112,7 +116,6 @@ public class SortingNearlySortedPrimitive { } - @DataProvider(name = "shapes") public Object[][] createShapes() { Stream> baseCases = Stream.of( List.of("hiZeroLowTest", (IntFunction) this::hiZeroLowData), @@ -141,7 +144,8 @@ public class SortingNearlySortedPrimitive { return nl.toArray(); } - @Test(dataProvider = "shapes") + @ParameterizedTest + @MethodSource("createShapes") public void testShapes(String testName, IntFunction dataMethod, int size) { int[] intSourceArray = dataMethod.apply(size); diff --git a/test/jdk/java/util/Arrays/StreamAndSpliterator.java b/test/jdk/java/util/Arrays/StreamAndSpliterator.java index c28b7c4d588..eaf0b02f369 100644 --- a/test/jdk/java/util/Arrays/StreamAndSpliterator.java +++ b/test/jdk/java/util/Arrays/StreamAndSpliterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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,21 +21,20 @@ * questions. */ -/** +/* * @test * @bug 8037857 * @summary tests for stream and spliterator factory methods - * @run testng StreamAndSpliterator + * @run junit StreamAndSpliterator */ -import org.testng.annotations.Test; import java.util.Arrays; import java.util.Spliterators; -import org.testng.Assert.ThrowingRunnable; - -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; public class StreamAndSpliterator { @Test @@ -127,11 +126,11 @@ public class StreamAndSpliterator { assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0)); } - void assertThrowsNPE(ThrowingRunnable r) { + void assertThrowsNPE(Executable r) { assertThrows(NullPointerException.class, r); } - void assertThrowsAIOOB(ThrowingRunnable r) { + void assertThrowsAIOOB(Executable r) { assertThrows(ArrayIndexOutOfBoundsException.class, r); } } diff --git a/test/jdk/java/util/Arrays/TEST.properties b/test/jdk/java/util/Arrays/TEST.properties new file mode 100644 index 00000000000..8e0b6e58824 --- /dev/null +++ b/test/jdk/java/util/Arrays/TEST.properties @@ -0,0 +1 @@ +disallowedActions=testng diff --git a/test/jdk/java/util/Arrays/largeMemory/ParallelPrefix.java b/test/jdk/java/util/Arrays/largeMemory/ParallelPrefix.java index 41bff170259..8ebf5453187 100644 --- a/test/jdk/java/util/Arrays/largeMemory/ParallelPrefix.java +++ b/test/jdk/java/util/Arrays/largeMemory/ParallelPrefix.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,13 +21,12 @@ * questions. */ -/** +/* * @test * @bug 8014076 8025067 * @summary unit test for Arrays.ParallelPrefix(). - * @author Tristan Yan * @modules java.management jdk.management - * @run testng/othervm -Xms256m -Xmx1024m ParallelPrefix + * @run junit/othervm -Xms256m -Xmx1024m ParallelPrefix */ import java.lang.management.ManagementFactory; @@ -40,11 +39,16 @@ import java.util.function.LongBinaryOperator; import java.util.stream.IntStream; import java.util.stream.LongStream; import com.sun.management.OperatingSystemMXBean; -import static org.testng.Assert.*; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.annotations.BeforeSuite; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ParallelPrefix { //Array size less than MIN_PARTITION private static final int SMALL_ARRAY_SIZE = 1 << 3; @@ -60,7 +64,7 @@ public class ParallelPrefix { private static int[] arraySizeCollection; - @BeforeSuite + @BeforeAll public static void setup() { java.lang.management.OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean(); @@ -90,7 +94,6 @@ public class ParallelPrefix { System.out.println("System memory is not large enough, remove large array size test"); } - @DataProvider(name = "intSet") public static Object[][] intSet(){ return genericData(size -> IntStream.range(0, size).toArray(), new IntBinaryOperator[]{ @@ -98,7 +101,6 @@ public class ParallelPrefix { Integer::min}); } - @DataProvider(name = "longSet") public static Object[][] longSet(){ return genericData(size -> LongStream.range(0, size).toArray(), new LongBinaryOperator[]{ @@ -106,7 +108,6 @@ public class ParallelPrefix { Long::min}); } - @DataProvider(name = "doubleSet") public static Object[][] doubleSet(){ return genericData(size -> IntStream.range(0, size).mapToDouble(i -> (double)i).toArray(), new DoubleBinaryOperator[]{ @@ -114,7 +115,6 @@ public class ParallelPrefix { Double::min}); } - @DataProvider(name = "stringSet") public static Object[][] stringSet(){ Function stringsFunc = size -> IntStream.range(0, size).mapToObj(Integer::toString).toArray(String[]::new); @@ -142,7 +142,8 @@ public class ParallelPrefix { return data; } - @Test(dataProvider="intSet") + @ParameterizedTest + @MethodSource("intSet") public void testParallelPrefixForInt(int[] data, int fromIndex, int toIndex, IntBinaryOperator op) { int[] sequentialResult = data.clone(); for (int index = fromIndex + 1; index < toIndex; index++) { @@ -151,14 +152,15 @@ public class ParallelPrefix { int[] parallelResult = data.clone(); Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op); - assertArraysEqual(parallelResult, sequentialResult); + assertArraysEqual(sequentialResult, parallelResult); int[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex); Arrays.parallelPrefix(parallelRangeResult, op); - assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex)); + assertArraysEqual(Arrays.copyOfRange(sequentialResult, fromIndex, toIndex), parallelRangeResult); } - @Test(dataProvider="longSet") + @ParameterizedTest + @MethodSource("longSet") public void testParallelPrefixForLong(long[] data, int fromIndex, int toIndex, LongBinaryOperator op) { long[] sequentialResult = data.clone(); for (int index = fromIndex + 1; index < toIndex; index++) { @@ -167,14 +169,15 @@ public class ParallelPrefix { long[] parallelResult = data.clone(); Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op); - assertArraysEqual(parallelResult, sequentialResult); + assertArraysEqual(sequentialResult, parallelResult); long[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex); Arrays.parallelPrefix(parallelRangeResult, op); - assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex)); + assertArraysEqual(Arrays.copyOfRange(sequentialResult, fromIndex, toIndex), parallelRangeResult); } - @Test(dataProvider="doubleSet") + @ParameterizedTest + @MethodSource("doubleSet") public void testParallelPrefixForDouble(double[] data, int fromIndex, int toIndex, DoubleBinaryOperator op) { double[] sequentialResult = data.clone(); for (int index = fromIndex + 1; index < toIndex; index++) { @@ -183,14 +186,15 @@ public class ParallelPrefix { double[] parallelResult = data.clone(); Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op); - assertArraysEqual(parallelResult, sequentialResult); + assertArraysEqual(sequentialResult, parallelResult); double[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex); Arrays.parallelPrefix(parallelRangeResult, op); - assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex)); + assertArraysEqual(Arrays.copyOfRange(sequentialResult, fromIndex, toIndex), parallelRangeResult); } - @Test(dataProvider="stringSet") + @ParameterizedTest + @MethodSource("stringSet") public void testParallelPrefixForStringr(String[] data , int fromIndex, int toIndex, BinaryOperator op) { String[] sequentialResult = data.clone(); for (int index = fromIndex + 1; index < toIndex; index++) { @@ -199,11 +203,11 @@ public class ParallelPrefix { String[] parallelResult = data.clone(); Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op); - assertArraysEqual(parallelResult, sequentialResult); + assertArraysEqual(sequentialResult, parallelResult); String[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex); Arrays.parallelPrefix(parallelRangeResult, op); - assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex)); + assertArraysEqual(Arrays.copyOfRange(sequentialResult, fromIndex, toIndex), parallelRangeResult); } @Test @@ -258,48 +262,48 @@ public class ParallelPrefix { // "library" code - private void assertThrowsNPE(ThrowingRunnable r) { + private void assertThrowsNPE(Executable r) { assertThrows(NullPointerException.class, r); } - private void assertThrowsIAE(ThrowingRunnable r) { + private void assertThrowsIAE(Executable r) { assertThrows(IllegalArgumentException.class, r); } - private void assertThrowsAIOOB(ThrowingRunnable r) { + private void assertThrowsAIOOB(Executable r) { assertThrows(ArrayIndexOutOfBoundsException.class, r); } - static void assertArraysEqual(int[] actual, int[] expected) { + static void assertArraysEqual(int[] expected, int[] actual) { try { - assertEquals(actual, expected, ""); + assertArrayEquals(expected, actual, ""); } catch (AssertionError x) { throw new AssertionError(String.format("Expected:%s, actual:%s", Arrays.toString(expected), Arrays.toString(actual)), x); } } - static void assertArraysEqual(long[] actual, long[] expected) { + static void assertArraysEqual(long[] expected, long[] actual) { try { - assertEquals(actual, expected, ""); + assertArrayEquals(expected, actual, ""); } catch (AssertionError x) { throw new AssertionError(String.format("Expected:%s, actual:%s", Arrays.toString(expected), Arrays.toString(actual)), x); } } - static void assertArraysEqual(double[] actual, double[] expected) { + static void assertArraysEqual(double[] expected, double[] actual) { try { - assertEquals(actual, expected, ""); + assertArrayEquals(expected, actual, ""); } catch (AssertionError x) { throw new AssertionError(String.format("Expected:%s, actual:%s", Arrays.toString(expected), Arrays.toString(actual)), x); } } - static void assertArraysEqual(String[] actual, String[] expected) { + static void assertArraysEqual(String[] expected, String[] actual) { try { - assertEquals(actual, expected, ""); + assertArrayEquals(expected, actual, ""); } catch (AssertionError x) { throw new AssertionError(String.format("Expected:%s, actual:%s", Arrays.toString(expected), Arrays.toString(actual)), x); diff --git a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java index 24c6e181ccc..ec4c2355d18 100644 --- a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java +++ b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,8 +28,6 @@ import java.nio.file.Paths; import java.util.List; import java.util.stream.Stream; -import jdk.test.lib.JDKToolLauncher; -import jdk.test.lib.Utils; import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.process.ProcessTools; @@ -185,30 +183,4 @@ public class ModuleTestUtil { } } } - - /** - * Run the module test with "useOldISOCodes=true". - * - * @param mp module path - * @param mn module name - * @param localeList locale list - */ - public static void runModuleWithLegacyCode(String mp, String mn, List localeList) - throws Throwable { - List args = List.of( - "-ea", "-esa", - "-Djava.locale.useOldISOCodes=true", - "-p", mp, - "-m", mn); - // Build process (with VM flags) - ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - Stream.concat(args.stream(), localeList.stream()).toList()); - // Evaluate process status - int exitCode = ProcessTools.executeCommand(pb).getExitValue(); - - if (exitCode != 0) { - throw new RuntimeException("Execution of the test failed. " - + "Unexpected exit code: " + exitCode); - } - } -} \ No newline at end of file +} diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java b/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java index c17c4622ecb..f3432a733b4 100644 --- a/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java +++ b/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ * jdk.test.lib.compiler.CompilerUtils * jdk.test.lib.process.ProcessTools * ModuleTestUtil - * @run junit BasicTest + * @run junit/timeout=200 BasicTest */ import java.nio.file.Path; @@ -132,7 +132,6 @@ public class BasicTest { moduleList.forEach(mn -> ModuleTestUtil.prepareModule(srcPath, modPath, mn, resFormat)); ModuleTestUtil.runModule(modPath.toString(), MAIN, localeList); - ModuleTestUtil.runModuleWithLegacyCode(modPath.toString(), MAIN, localeList); } @Test @@ -206,4 +205,4 @@ public class BasicTest { assertEquals(exitCode, 0, "Create extra_modlocal.jar failed. " + "Unexpected exit code: " + exitCode); } -} \ No newline at end of file +} diff --git a/test/jdk/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java b/test/jdk/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java index ece63bfe813..c8f882b599d 100644 --- a/test/jdk/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java +++ b/test/jdk/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,12 +126,19 @@ public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper List exp; + List expRev; + Map mExp; + Map mExpRev; + SpliteratorDataBuilder(List data, List exp) { this.data = data; this.exp = exp; + this.expRev = new ArrayList<>(exp); + Collections.reverse(this.expRev); this.mExp = createMap(exp); + this.mExpRev = createMap(expRev); } Map createMap(List l) { @@ -166,12 +173,23 @@ public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper addMap(m, description); } + void addDescendingMap(Function, ? extends Map> m) { + String description = "new " + m.apply(Collections.emptyMap()).getClass().getName(); + addDescendingMap(m, description); + } + void addMap(Function, ? extends Map> m, String description) { add(description + ".keySet().spliterator()", () -> m.apply(mExp).keySet().spliterator()); add(description + ".values().spliterator()", () -> m.apply(mExp).values().spliterator()); add(description + ".entrySet().spliterator()", mExp.entrySet(), () -> m.apply(mExp).entrySet().spliterator()); } + void addDescendingMap(Function, ? extends Map> m, String description) { + add(description + ".keySet().spliterator()", expRev, () -> m.apply(mExp).keySet().spliterator()); + add(description + ".values().spliterator()", expRev, () -> m.apply(mExp).values().spliterator()); + add(description + ".entrySet().spliterator()", mExpRev.entrySet(), () -> m.apply(mExp).entrySet().spliterator()); + } + StringBuilder joiner(String description) { return new StringBuilder(description). append(" {"). @@ -639,8 +657,14 @@ public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper return cm; }, "new java.util.WeakHashMap(1, size + 1)"); - // @@@ Descending maps etc db.addMap(TreeMap::new); + db.addMap(m -> new TreeMap<>(m).tailMap(Integer.MIN_VALUE)); + db.addMap(m -> new TreeMap<>(m).headMap(Integer.MAX_VALUE)); + db.addMap(m -> new TreeMap<>(m).subMap(Integer.MIN_VALUE, Integer.MAX_VALUE)); + db.addDescendingMap(m -> new TreeMap<>(m).descendingMap()); + db.addDescendingMap(m -> new TreeMap<>(m).descendingMap().tailMap(Integer.MAX_VALUE)); + db.addDescendingMap(m -> new TreeMap<>(m).descendingMap().headMap(Integer.MIN_VALUE)); + db.addDescendingMap(m -> new TreeMap<>(m).descendingMap().subMap(Integer.MAX_VALUE, Integer.MIN_VALUE)); db.addMap(ConcurrentHashMap::new); diff --git a/test/jdk/java/util/TimeZone/TimeZoneData/VERSION b/test/jdk/java/util/TimeZone/TimeZoneData/VERSION index 76d146afc71..2f72d7dbcb2 100644 --- a/test/jdk/java/util/TimeZone/TimeZoneData/VERSION +++ b/test/jdk/java/util/TimeZone/TimeZoneData/VERSION @@ -1 +1 @@ -tzdata2025c +tzdata2026a diff --git a/test/jdk/java/util/concurrent/forkjoin/Starvation.java b/test/jdk/java/util/concurrent/forkjoin/Starvation.java index f3336a3c7e9..3db83688d45 100644 --- a/test/jdk/java/util/concurrent/forkjoin/Starvation.java +++ b/test/jdk/java/util/concurrent/forkjoin/Starvation.java @@ -28,7 +28,6 @@ */ import java.util.concurrent.Callable; import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinTask; import java.util.concurrent.atomic.AtomicInteger; public class Starvation { @@ -43,7 +42,7 @@ public class Starvation { while (count.get() == c) Thread.onSpinWait(); return null; }}; - static void testSubmitExternalCallable() throws Exception { + public static void main(String[] args) throws Exception { try (var pool = new ForkJoinPool(2)) { for (int i = 0; i < 100_000; i++) { var future1 = pool.submit(new AwaitCount(i)); @@ -54,21 +53,4 @@ public class Starvation { } } } - - static void testSubmitAdaptedCallable() throws Exception { - try (var pool = new ForkJoinPool(2)) { - for (int i = 0; i < 100_000; i++) { - var future1 = pool.submit(new AwaitCount(i)); - var future2 = pool.submit(ForkJoinTask.adapt(noop)); - future2.get(); - count.set(i + 1); - future1.get(); - } - } - } - - public static void main(String[] args) throws Exception { - testSubmitExternalCallable(); - testSubmitAdaptedCallable(); - } } diff --git a/test/jdk/java/util/jar/Attributes/IterationOrder.java b/test/jdk/java/util/jar/Attributes/IterationOrder.java index 4028d71e7c4..edd1d9b8bc8 100644 --- a/test/jdk/java/util/jar/Attributes/IterationOrder.java +++ b/test/jdk/java/util/jar/Attributes/IterationOrder.java @@ -1,5 +1,6 @@ /* * Copyright 2014 Google, Inc. All Rights Reserved. + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +25,26 @@ /* @test * @bug 8062194 * @summary Ensure Attribute iteration order is the insertion order. + * @run junit IterationOrder */ +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import java.util.Arrays; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.fail; public class IterationOrder { - static void checkOrder(Attributes.Name k0, String v0, + + @ParameterizedTest + @MethodSource + void checkOrderTest(Attributes.Name k0, String v0, Attributes.Name k1, String v1, Attributes.Name k2, String v2) { Attributes x = new Attributes(); @@ -48,7 +60,7 @@ public class IterationOrder { && entries[1].getValue() == v1 && entries[2].getKey() == k2 && entries[2].getValue() == v2)) { - throw new AssertionError(Arrays.toString(entries)); + fail(Arrays.toString(entries)); } Object[] keys = x.keySet().toArray(); @@ -56,19 +68,21 @@ public class IterationOrder { && keys[0] == k0 && keys[1] == k1 && keys[2] == k2)) { - throw new AssertionError(Arrays.toString(keys)); + fail(Arrays.toString(keys)); } } - public static void main(String[] args) throws Exception { + static Stream checkOrderTest() { Attributes.Name k0 = Name.MANIFEST_VERSION; Attributes.Name k1 = Name.MAIN_CLASS; Attributes.Name k2 = Name.SEALED; String v0 = "42.0"; String v1 = "com.google.Hello"; String v2 = "yes"; - checkOrder(k0, v0, k1, v1, k2, v2); - checkOrder(k1, v1, k0, v0, k2, v2); - checkOrder(k2, v2, k1, v1, k0, v0); + return Stream.of( + Arguments.of(k0, v0, k1, v1, k2, v2), + Arguments.of(k1, v1, k0, v0, k2, v2), + Arguments.of(k2, v2, k1, v1, k0, v0) + ); } } diff --git a/test/jdk/java/util/jar/Attributes/Name.java b/test/jdk/java/util/jar/Attributes/Name.java index 78306028698..843038cb820 100644 --- a/test/jdk/java/util/jar/Attributes/Name.java +++ b/test/jdk/java/util/jar/Attributes/Name.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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,17 +25,20 @@ @bug 4199981 @summary Make sure empty string is not a valid Attributes name. - */ + @run junit Name + */ +import org.junit.jupiter.api.Test; import java.util.jar.Attributes; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class Name { - public static void main(String[] args) throws Exception { - try { - Attributes.Name name = new Attributes.Name(""); - throw new Exception("empty string should be rejected"); - } catch (IllegalArgumentException e) { - } + + @Test + void emptyStringTest() { + assertThrows(IllegalArgumentException.class, () -> new Attributes.Name(""), + "empty string should be rejected"); } } diff --git a/test/jdk/java/util/jar/Attributes/NullAndEmptyKeysAndValues.java b/test/jdk/java/util/jar/Attributes/NullAndEmptyKeysAndValues.java index c62ddcced8a..e99825d235e 100644 --- a/test/jdk/java/util/jar/Attributes/NullAndEmptyKeysAndValues.java +++ b/test/jdk/java/util/jar/Attributes/NullAndEmptyKeysAndValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +21,6 @@ * questions. */ -import static java.nio.charset.StandardCharsets.UTF_8; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -31,14 +29,16 @@ import java.util.jar.Manifest; import java.util.jar.Attributes.Name; import java.lang.reflect.Field; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; /** * @test * @bug 8066619 * @modules java.base/java.util.jar:+open - * @run testng/othervm --enable-final-field-mutation=ALL-UNNAMED NullAndEmptyKeysAndValues + * @run junit/othervm --enable-final-field-mutation=ALL-UNNAMED NullAndEmptyKeysAndValues * @summary Tests manifests with {@code null} and empty string {@code ""} * values as section name, header name, or value in both main and named * attributes sections. @@ -108,7 +108,7 @@ public class NullAndEmptyKeysAndValues { attr.set(mf, mainAtts); mf.getMainAttributes().put(Name.MANIFEST_VERSION, "1.0"); mf = writeAndRead(mf); - assertEquals(mf.getMainAttributes().getValue(SOME_KEY), NULL_TEXT); + assertEquals(NULL_TEXT, mf.getMainAttributes().getValue(SOME_KEY)); } @Test @@ -122,7 +122,7 @@ public class NullAndEmptyKeysAndValues { attr.set(mf, mainAtts); mf.getMainAttributes().put(Name.MANIFEST_VERSION, "1.0"); mf = writeAndRead(mf); - assertEquals(mf.getMainAttributes().getValue(SOME_KEY), EMPTY_STR); + assertEquals(EMPTY_STR, mf.getMainAttributes().getValue(SOME_KEY)); } @Test @@ -171,8 +171,7 @@ public class NullAndEmptyKeysAndValues { map.put(new Name(SOME_KEY), null); }}); mf = writeAndRead(mf); - assertEquals(mf.getEntries().get(SOME_KEY).getValue(SOME_KEY), - NULL_TEXT); + assertEquals(NULL_TEXT, mf.getEntries().get(SOME_KEY).getValue(SOME_KEY)); } @Test @@ -183,8 +182,7 @@ public class NullAndEmptyKeysAndValues { map.put(new Name(SOME_KEY), EMPTY_STR); }}); mf = writeAndRead(mf); - assertEquals(mf.getEntries().get(SOME_KEY).getValue(SOME_KEY), - EMPTY_STR); + assertEquals(EMPTY_STR, mf.getEntries().get(SOME_KEY).getValue(SOME_KEY)); } static Manifest writeAndRead(Manifest mf) throws IOException { diff --git a/test/jdk/java/util/jar/Attributes/PutAndPutAll.java b/test/jdk/java/util/jar/Attributes/PutAndPutAll.java index f459daf8c2e..bd61ba1e92d 100644 --- a/test/jdk/java/util/jar/Attributes/PutAndPutAll.java +++ b/test/jdk/java/util/jar/Attributes/PutAndPutAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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,31 +25,27 @@ @bug 4165833 4167600 @summary Test if put and putAll will test for illegal arguments. - */ + @run junit PutAndPutAll + */ +import org.junit.jupiter.api.Test; + import java.util.jar.Attributes; import java.util.HashMap; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class PutAndPutAll { - public static void main(String[] args) throws Exception { + + @Test + void classCastTest() { Attributes at = new Attributes(); - try{ - at.put("this is not an Attributes.Name", "value"); - throw new Exception("put should check for non Attributes.Name names"); - } catch (ClassCastException e) { - } - - try{ - at.put(new Attributes.Name("name"), new Integer(0)); - throw new Exception("put should check for non String values"); - } catch (ClassCastException e) { - } - - try { - at.putAll(new HashMap()); - throw new Exception("putAll should check for non Attributes maps"); - } catch (ClassCastException e) { - } + assertThrows(ClassCastException.class, + () -> at.put("this is not an Attributes.Name", "value"), "put should check for non Attributes.Name names"); + assertThrows(ClassCastException.class, + () -> at.put(new Attributes.Name("name"), new Integer(0)), "put should check for non String values"); + assertThrows(ClassCastException.class, + () -> at.putAll(new HashMap()), "putAll should check for non Attributes maps"); } } diff --git a/test/jdk/java/util/jar/Attributes/TestAttrsNL.java b/test/jdk/java/util/jar/Attributes/TestAttrsNL.java index 34f7e4c4502..abfd3df6cd7 100644 --- a/test/jdk/java/util/jar/Attributes/TestAttrsNL.java +++ b/test/jdk/java/util/jar/Attributes/TestAttrsNL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,19 +24,28 @@ /* @test * @bug 8200530 * @summary Test Attributes newline + * @run junit TestAttrsNL */ +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; import java.util.jar.Manifest; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.io.ByteArrayInputStream; import java.util.Map; +import java.util.stream.Stream; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestAttrsNL { - public static void main(String[] args) throws Throwable { + static Stream newLineAttributesTest() throws IOException { String manifestStr = "Manifest-Version: 1.0\r\n" + @@ -68,16 +77,16 @@ public class TestAttrsNL { new Name("key44"), "value44" ); - test(new Manifest(new ByteArrayInputStream(manifestStr.getBytes(UTF_8))), - mainAttrsExped, attrsExped); + var normal = Arguments.of(new Manifest(new ByteArrayInputStream(manifestStr.getBytes(UTF_8))), + mainAttrsExped, attrsExped); - test(new Manifest(new ByteArrayInputStream( - manifestStr.replaceAll("\r\n", "\r").getBytes(UTF_8))), - mainAttrsExped, attrsExped); + var carriage = Arguments.of(new Manifest(new ByteArrayInputStream( + manifestStr.replaceAll("\r\n", "\r").getBytes(UTF_8))), + mainAttrsExped, attrsExped); - test(new Manifest(new ByteArrayInputStream( - manifestStr.replaceAll("\r\n", "\n").getBytes(UTF_8))), - mainAttrsExped, attrsExped); + var newLine = Arguments.of(new Manifest(new ByteArrayInputStream( + manifestStr.replaceAll("\r\n", "\n").getBytes(UTF_8))), + mainAttrsExped, attrsExped); // mixed manifestStr = @@ -93,31 +102,33 @@ public class TestAttrsNL { "key22: value22\n END\r\n" + "key33: value33\r \n" + "key44: value44\n"; - test(new Manifest(new ByteArrayInputStream(manifestStr.getBytes(UTF_8))), + var mixed = Arguments.of(new Manifest(new ByteArrayInputStream(manifestStr.getBytes(UTF_8))), mainAttrsExped, attrsExped); - + return Stream.of(normal, carriage, newLine, mixed); } - private static void test(Manifest m, + @ParameterizedTest + @MethodSource + void newLineAttributesTest(Manifest m, Map mainAttrsExped, Map attrsExped) { Attributes mainAttrs = m.getMainAttributes(); mainAttrsExped.forEach( (k, v) -> { - if (!mainAttrs.containsKey(k) || !mainAttrs.get(k).equals(v)) { - System.out.printf(" containsKey(%s) : %b%n", k, mainAttrs.containsKey(k)); - System.out.printf(" get(%s) : %s%n", k, mainAttrs.get(k)); - throw new RuntimeException("expected attr: k=<" + k + ">, v=<" + v + ">"); - } + var expectedMsg = "expected attr: k=<" + k + ">, v=<" + v + ">"; + assertTrue(mainAttrs.containsKey(k), + " containsKey(%s) : %b%n%s".formatted(k, mainAttrs.containsKey(k), expectedMsg)); + assertEquals(v, mainAttrs.get(k), + " get(%s) : %s%n%s".formatted(k, mainAttrs.get(k), expectedMsg)); }); Attributes attrs = m.getAttributes("Hello"); attrs.forEach( (k, v) -> { - if (!attrs.containsKey(k) || !attrs.get(k).equals(v)) { - System.out.printf(" containsKey(%s) : %b%n", k, attrs.containsKey(k)); - System.out.printf(" get(%s) : %s%n", k, attrs.get(k)); - throw new RuntimeException("expected attr: k=<" + k + ">, v=<" + v + ">"); - } + var expectedMsg = "expected attr: k=<" + k + ">, v=<" + v + ">"; + assertTrue(attrs.containsKey(k), + " containsKey(%s) : %b%n%s".formatted(k, attrs.containsKey(k), expectedMsg)); + assertEquals(v, attrs.get(k), + " get(%s) : %s%n%s".formatted(k, attrs.get(k), expectedMsg)); }); } } diff --git a/test/jdk/java/util/jar/JarEntry/GetMethodsReturnClones.java b/test/jdk/java/util/jar/JarEntry/GetMethodsReturnClones.java index 3c4f06dd6f0..a9b35220de3 100644 --- a/test/jdk/java/util/jar/JarEntry/GetMethodsReturnClones.java +++ b/test/jdk/java/util/jar/JarEntry/GetMethodsReturnClones.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,20 +26,28 @@ * @bug 6337925 * @summary Ensure that callers cannot modify the internal JarEntry cert and * codesigner arrays. - * @author Sean Mullan + * @run junit GetMethodsReturnClones */ +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.io.IOException; import java.io.InputStream; import java.security.CodeSigner; import java.security.cert.Certificate; import java.util.*; import java.util.jar.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class GetMethodsReturnClones { private static final String BASE = System.getProperty("test.src", ".") + System.getProperty("file.separator"); + private static List jarEntries; - public static void main(String[] args) throws Exception { + @BeforeAll() + static void setupEntries() throws IOException { List entries = new ArrayList<>(); try (JarFile jf = new JarFile(BASE + "test.jar", true)) { byte[] buffer = new byte[8192]; @@ -55,23 +63,29 @@ public class GetMethodsReturnClones { } } } + jarEntries = entries; + } - for (JarEntry je : entries) { + @Test + void certsTest() { + for (JarEntry je : jarEntries) { Certificate[] certs = je.getCertificates(); - CodeSigner[] signers = je.getCodeSigners(); if (certs != null) { certs[0] = null; certs = je.getCertificates(); - if (certs[0] == null) { - throw new Exception("Modified internal certs array"); - } + assertNotNull(certs[0], "Modified internal certs array"); } + } + } + + @Test + void signersTest() { + for (JarEntry je : jarEntries) { + CodeSigner[] signers = je.getCodeSigners(); if (signers != null) { signers[0] = null; signers = je.getCodeSigners(); - if (signers[0] == null) { - throw new Exception("Modified internal codesigners array"); - } + assertNotNull(signers[0], "Modified internal codesigners array"); } } } diff --git a/test/jdk/java/util/jar/JarFile/Constructor.java b/test/jdk/java/util/jar/JarFile/Constructor.java index 8c1a8623e61..071c68fdd9e 100644 --- a/test/jdk/java/util/jar/JarFile/Constructor.java +++ b/test/jdk/java/util/jar/JarFile/Constructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,55 +21,45 @@ * questions. */ -/** +/* * @test * @bug 4842702 8211765 * @summary Check that constructors throw specified exceptions - * @author Martin Buchholz + * @run junit Constructor */ +import org.junit.jupiter.api.Test; + import java.util.jar.JarFile; import java.io.File; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class Constructor { - private static void Unreached (Object o) - throws Exception - { - // Should never get here - throw new Exception ("Expected exception was not thrown"); - } - public static void main(String[] args) - throws Exception - { - try { Unreached (new JarFile ((File) null, true, JarFile.OPEN_READ)); } - catch (NullPointerException e) {} + @Test + void constructorTest() { - try { Unreached (new JarFile ((File) null, true)); } - catch (NullPointerException e) {} + assertThrows(NullPointerException.class, () -> new JarFile ((File) null, true, JarFile.OPEN_READ)); - try { Unreached (new JarFile ((File) null)); } - catch (NullPointerException e) {} + assertThrows(NullPointerException.class, () -> new JarFile ((File) null, true)); - try { Unreached (new JarFile ((String) null, true)); } - catch (NullPointerException e) {} + assertThrows(NullPointerException.class, () -> new JarFile ((File) null)); - try { Unreached (new JarFile ((String) null)); } - catch (NullPointerException e) {} + assertThrows(NullPointerException.class, () -> new JarFile ((String) null, true)); - try { Unreached (new JarFile ("NoSuchJar.jar")); } - catch (IOException e) {} + assertThrows(NullPointerException.class, () -> new JarFile ((String) null)); - try { Unreached (new JarFile (new File ("NoSuchJar.jar"))); } - catch (IOException e) {} + assertThrows(IOException.class, () -> new JarFile ("NoSuchJar.jar")); + + assertThrows(IOException.class, () -> new JarFile (new File ("NoSuchJar.jar"))); // Test that an IOExcception is thrown when an invalid charater // is part of the path on Windows and Unix final String invalidOSPath = System.getProperty("os.name") .startsWith("Windows") ? "C:\\*" : "foo\u0000bar"; - try { Unreached (new JarFile (invalidOSPath)); } - catch (IOException e) {} + assertThrows(IOException.class, () -> new JarFile (invalidOSPath)); } } diff --git a/test/jdk/java/util/jar/JarFile/IgnoreUnrelatedSignatureFiles.java b/test/jdk/java/util/jar/JarFile/IgnoreUnrelatedSignatureFiles.java index 0f55702c1f6..e5a32dfde73 100644 --- a/test/jdk/java/util/jar/JarFile/IgnoreUnrelatedSignatureFiles.java +++ b/test/jdk/java/util/jar/JarFile/IgnoreUnrelatedSignatureFiles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 * @bug 8300140 * @summary Make sure signature related files in subdirectories of META-INF are not considered for verification @@ -29,12 +29,14 @@ * @modules java.base/sun.security.util * @modules java.base/sun.security.tools.keytool * @modules jdk.jartool/sun.security.tools.jarsigner - * @run main/othervm IgnoreUnrelatedSignatureFiles + * @run junit/othervm IgnoreUnrelatedSignatureFiles */ import jdk.internal.access.JavaUtilZipFileAccess; import jdk.internal.access.SharedSecrets; import jdk.security.jarsigner.JarSigner; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import sun.security.tools.jarsigner.Main; import sun.security.util.SignatureFileVerifier; @@ -62,6 +64,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class IgnoreUnrelatedSignatureFiles { private static final JavaUtilZipFileAccess JUZA = SharedSecrets.getJavaUtilZipFileAccess(); @@ -69,56 +75,76 @@ public class IgnoreUnrelatedSignatureFiles { // This path resides in a subdirectory of META-INF, so it should not be considered signature related public static final String SUBDIR_SF_PATH = "META-INF/subdirectory/META-INF/SIGNER.SF"; + // Jars used for testing. See `setupJars` below for setup + static Path j; + static Path s; + static Path m; + static Path sm; + static Path ca; + static Path cas; - public static void main(String[] args) throws Exception { - + @BeforeAll + static void setupJars() throws Exception { // Regular signed JAR - Path j = createJarFile(); - Path s = signJarFile(j, "SIGNER1", "signed"); + j = createJarFile(); + s = signJarFile(j, "SIGNER1", "signed"); // Singed JAR with unrelated signature files - Path m = moveSignatureRelated(s); - Path sm = signJarFile(m, "SIGNER2", "modified-signed"); + m = moveSignatureRelated(s); + sm = signJarFile(m, "SIGNER2", "modified-signed"); // Signed JAR with custom SIG-* files - Path ca = createCustomAlgJar(); - Path cas = signJarFile(ca, "SIGNER1", "custom-signed"); + ca = createCustomAlgJar(); + cas = signJarFile(ca, "SIGNER1", "custom-signed"); + } - // 0: Sanity check that the basic signed JAR verifies + // Sanity check that the basic signed JAR verifies + @Test + void signedJarVerifyTest() throws IOException { try (JarFile jf = new JarFile(s.toFile(), true)) { Map entries = jf.getManifest().getEntries(); - if (entries.size() != 1) { - throw new Exception("Expected a single manifest entry for the digest of a.txt, instead found entries: " + entries.keySet()); - } + assertEquals(1, entries.size(), + "Expected a single manifest entry for the digest of a.txt, instead found entries: " + entries.keySet()); JarEntry entry = jf.getJarEntry("a.txt"); try (InputStream in = jf.getInputStream(entry)) { in.transferTo(OutputStream.nullOutputStream()); } } - // 1: Check ZipFile.Source.isSignatureRelated + } + + // Check ZipFile.Source.isSignatureRelated + @Test + void zipFileSourceIsSignatureRelatedTest() throws IOException { try (JarFile jarFile = new JarFile(m.toFile())) { List manifestAndSignatureRelatedFiles = JUZA.getManifestAndSignatureRelatedFiles(jarFile); for (String signatureRelatedFile : manifestAndSignatureRelatedFiles) { String dir = signatureRelatedFile.substring(0, signatureRelatedFile.lastIndexOf("/")); - if (!"META-INF".equals(dir)) { - throw new Exception("Signature related file does not reside directly in META-INF/ : " + signatureRelatedFile); - } + assertEquals("META-INF", dir, + "Signature related file does not reside directly in META-INF/ : " + signatureRelatedFile); } } + } - // 2: Check SignatureFileVerifier.isSigningRelated - if (SignatureFileVerifier.isSigningRelated(SUBDIR_SF_PATH)) { - throw new Exception("Signature related file does not reside directly in META-INF/ : " + SUBDIR_SF_PATH); - } + // Check SignatureFileVerifier.isSigningRelated + @Test + void sigFileVerifierIsSigningRelatedTest() { + assertFalse(SignatureFileVerifier.isSigningRelated(SUBDIR_SF_PATH), + "Signature related file does not reside directly in META-INF/ : " + SUBDIR_SF_PATH); + } - // 3: Check JarInputStream with doVerify = true + // Check JarInputStream with doVerify = true + @Test + void jarIStreamDoVerifyTest() throws IOException { try (JarInputStream in = new JarInputStream(Files.newInputStream(m), true)) { - while (in.getNextEntry() != null) { + while (in.getNextEntry() != null) { in.transferTo(OutputStream.nullOutputStream()); } } + } - // 4: Check that a JAR containing unrelated .SF, .RSA files is signed as-if it is unsigned + // Check that a JAR containing unrelated .SF, .RSA files is signed as-if it is unsigned + @Test + void unrelatedFilesUnsignedTest() throws IOException { try (ZipFile zf = new ZipFile(sm.toFile())) { ZipEntry mf = zf.getEntry("META-INF/MANIFEST.MF"); try (InputStream stream = zf.getInputStream(mf)) { @@ -126,19 +152,24 @@ public class IgnoreUnrelatedSignatureFiles { // When JarSigner considers a jar to not be already signed, // the 'Manifest-Version' attributed name will be case-normalized // Assert that manifest-version is not in lowercase - if (manifest.startsWith("manifest-version")) { - throw new Exception("JarSigner unexpectedly treated unsigned jar as signed"); - } + assertFalse(manifest.startsWith("manifest-version"), + "JarSigner unexpectedly treated unsigned jar as signed"); } } + } - // 5: Check that a JAR containing non signature related .SF, .RSA files can be signed + // Check that a JAR containing non signature related .SF, .RSA files can be signed + @Test + void nonSigFileIsSignableTest() throws Exception { try (JarFile jf = new JarFile(sm.toFile(), true)) { checkSignedBy(jf, "a.txt", "CN=SIGNER2"); checkSignedBy(jf, "META-INF/subdirectory/META-INF/SIGNER1.SF", "CN=SIGNER2"); } + } - // 6: Check that JarSigner does not move unrelated [SF,RSA] files to the beginning of signed JARs + // Check that JarSigner does not move unrelated [SF,RSA] files to the beginning of signed JARs + @Test + void jarSignerDoesNotMoveUnrelatedTest() throws IOException { try (JarFile zf = new JarFile(sm.toFile())) { List actualOrder = zf.stream().map(ZipEntry::getName).toList(); @@ -154,23 +185,25 @@ public class IgnoreUnrelatedSignatureFiles { "META-INF/subdirectory2/META-INF/SIGNER1.RSA" ); - if (!expectedOrder.equals(actualOrder)) { - String msg = (""" + assertEquals(expectedOrder, actualOrder, (""" Unexpected file order in JAR with unrelated SF,RSA files Expected order: %s Actual order: %s""") - .formatted(expectedOrder, actualOrder); - throw new Exception(msg); - } + .formatted(expectedOrder, actualOrder)); } + } - // 7: Check that jarsigner ignores unrelated signature files + // Check that jarsigner ignores unrelated signature files + @Test + void jarSignerIgnoresUnrelatedTest() throws Exception { String message = jarSignerVerify(m); - if (message.contains("WARNING")) { - throw new Exception("jarsigner output contains unexpected warning: " +message); - } + assertFalse(message.contains("WARNING"), + "jarsigner output contains unexpected warning: " + message); + } - // 8: Check that SignatureFileVerifier.isSigningRelated handles custom SIG-* files correctly + // Check that SignatureFileVerifier.isSigningRelated handles custom SIG-* files correctly + @Test + void customSIGFilesTest() throws IOException { try (JarFile jf = new JarFile(cas.toFile(), true)) { // These files are not signature-related and should be signed @@ -185,10 +218,9 @@ public class IgnoreUnrelatedSignatureFiles { Set actualSigned = jf.getManifest().getEntries().keySet(); - if (!expectedSigned.equals(actualSigned)) { - throw new Exception("Unexpected MANIFEST entries. Expected %s, got %s" - .formatted(expectedSigned, actualSigned)); - } + assertEquals(expectedSigned, actualSigned, + "Unexpected MANIFEST entries. Expected %s, got %s" + .formatted(expectedSigned, actualSigned)); } } @@ -220,22 +252,17 @@ public class IgnoreUnrelatedSignatureFiles { // Verify that the entry is signed CodeSigner[] signers = je.getCodeSigners(); - if (signers == null) { - throw new Exception(String.format("Expected %s to be signed", name)); - } + assertNotNull(signers, "Expected %s to be signed".formatted(name)); // There should be a single signer - if (signers.length != 1) { - throw new Exception(String.format("Expected %s to be signed by exactly one signer", name)); - } + assertEquals(1, signers.length, + "Expected %s to be signed by exactly one signer".formatted(name)); String actualSigner = ((X509Certificate) signers[0] .getSignerCertPath().getCertificates().get(0)) .getIssuerX500Principal().getName(); - - if (!actualSigner.equals(expectedSigner)) { - throw new Exception(String.format("Expected %s to be signed by %s, was signed by %s", name, expectedSigner, actualSigner)); - } + assertEquals(expectedSigner, actualSigner, + "Expected %s to be signed by %s, was signed by %s".formatted(name, expectedSigner, actualSigner)); } /** diff --git a/test/jdk/java/util/jar/JarFile/JarBacktickManifest.java b/test/jdk/java/util/jar/JarFile/JarBacktickManifest.java index 65d54a67a47..66edf3ae3ee 100644 --- a/test/jdk/java/util/jar/JarFile/JarBacktickManifest.java +++ b/test/jdk/java/util/jar/JarFile/JarBacktickManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +27,7 @@ * @summary Make sure scanning manifest doesn't throw AIOOBE on certain strings containing backticks. * @library /test/lib/ * @build jdk.test.lib.util.JarBuilder - * @run testng JarBacktickManifest + * @run junit JarBacktickManifest */ import java.io.File; @@ -35,19 +35,20 @@ import java.io.IOException; import java.nio.file.Files; import java.util.jar.JarFile; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import jdk.test.lib.util.JarBuilder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; + public class JarBacktickManifest { public static final String VERIFY_MANIFEST_JAR = "verifyManifest.jar"; - @BeforeClass - public void initialize() throws Exception { + @BeforeAll + public static void initialize() throws Exception { JarBuilder jb = new JarBuilder(VERIFY_MANIFEST_JAR); jb.addAttribute("Test", " Class-`Path` "); jb.addAttribute("Test2", " Multi-`Release "); @@ -55,14 +56,14 @@ public class JarBacktickManifest { } @Test - public void test() throws Exception { + public void backtickTest() throws Exception { try (JarFile jf = new JarFile(VERIFY_MANIFEST_JAR)) { // do not set runtime versioning - Assert.assertFalse(jf.isMultiRelease(), "Shouldn't be multi-release"); + assertFalse(jf.isMultiRelease(), "Shouldn't be multi-release"); } } - @AfterClass - public void close() throws IOException { + @AfterAll + public static void close() throws IOException { Files.delete(new File(VERIFY_MANIFEST_JAR).toPath()); } } diff --git a/test/jdk/java/util/jar/JarFile/JarNoManifest.java b/test/jdk/java/util/jar/JarFile/JarNoManifest.java index 971ce92f9e9..31301e28975 100644 --- a/test/jdk/java/util/jar/JarFile/JarNoManifest.java +++ b/test/jdk/java/util/jar/JarFile/JarNoManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,25 @@ /* @test @bug 4771616 @summary JarFile.maybeInstantiateVerifier must check for absence of manifest + @run junit JarNoManifest */ +import org.junit.jupiter.api.Test; + import java.io.*; import java.util.jar.*; import java.util.zip.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + public class JarNoManifest { - public static void main(String[] args) throws Exception { - File f = new File(System.getProperty("test.src","."), "no-manifest.jar"); - JarFile jar = new JarFile(f); - ZipEntry entry = jar.getEntry("JarNoManifest.java"); - // The following throws a NullPointerException when the bug is present - InputStream in = jar.getInputStream(entry); - } + + @Test + void absentManifestTest() throws IOException { + File f = new File(System.getProperty("test.src", "."), "no-manifest.jar"); + JarFile jar = new JarFile(f); + ZipEntry entry = jar.getEntry("JarNoManifest.java"); + // The following throws a NullPointerException when the bug is present + assertDoesNotThrow(() -> jar.getInputStream(entry)); + } } diff --git a/test/jdk/java/util/jar/JarFile/MevNPE.java b/test/jdk/java/util/jar/JarFile/MevNPE.java index f8627d33324..20ac9f2d796 100644 --- a/test/jdk/java/util/jar/JarFile/MevNPE.java +++ b/test/jdk/java/util/jar/JarFile/MevNPE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,27 @@ /* @test * @bug 7023056 * @summary NPE from sun.security.util.ManifestEntryVerifier.verify during Maven build + * @run junit MevNPE */ +import org.junit.jupiter.api.Test; + import java.io.*; import java.util.jar.*; public class MevNPE { - public static void main(String[] args) throws Exception { + + @Test + void noNpeTest() throws IOException { File f = new File(System.getProperty("test.src", "."), "Signed.jar"); try (JarFile jf = new JarFile(f, true)) { try (InputStream s1 = jf.getInputStream( jf.getJarEntry(JarFile.MANIFEST_NAME))) { s1.read(new byte[10000]); - }; + } try (InputStream s2 = jf.getInputStream( jf.getJarEntry(JarFile.MANIFEST_NAME))) { s2.read(new byte[10000]); - }; + } } } } diff --git a/test/jdk/java/util/jar/JarFile/ScanSignedJar.java b/test/jdk/java/util/jar/JarFile/ScanSignedJar.java index fe49cea24aa..75b4732645d 100644 --- a/test/jdk/java/util/jar/JarFile/ScanSignedJar.java +++ b/test/jdk/java/util/jar/JarFile/ScanSignedJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, 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,29 +21,35 @@ * questions. */ -/** +/* * @test * @bug 4953126 * @summary Check that a signed JAR file containing an unsupported signer info * attribute can be parsed successfully. + * @run junit ScanSignedJar */ +import org.junit.jupiter.api.Test; + import java.io.File; +import java.io.IOException; import java.io.InputStream; -import java.security.cert.Certificate; import java.util.Enumeration; import java.util.jar.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class ScanSignedJar { - public static void main(String[] args) throws Exception { + @Test + void unsupportedSignerTest() throws IOException { boolean isSigned = false; try (JarFile file = new JarFile(new File(System.getProperty("test.src","."), - "bogus-signerinfo-attr.jar"))) { + "bogus-signerinfo-attr.jar"))) { byte[] buffer = new byte[8192]; - for (Enumeration entries = file.entries(); entries.hasMoreElements();) { - JarEntry entry = (JarEntry) entries.nextElement(); + for (Enumeration entries = file.entries(); entries.hasMoreElements();) { + JarEntry entry = entries.nextElement(); try (InputStream jis = file.getInputStream(entry)) { while (jis.read(buffer, 0, buffer.length) != -1) { // read the jar entry @@ -53,14 +59,9 @@ public class ScanSignedJar { isSigned = true; } System.out.println((isSigned ? "[signed] " : "\t ") + - entry.getName()); + entry.getName()); } } - - if (isSigned) { - System.out.println("\nJAR file has signed entries"); - } else { - throw new Exception("Failed to detect that the JAR file is signed"); - } + assertTrue(isSigned, "Failed to detect that the JAR file is signed"); } } diff --git a/test/jdk/java/util/jar/JarFile/SignedJarFileGetInputStream.java b/test/jdk/java/util/jar/JarFile/SignedJarFileGetInputStream.java index 84ad357079d..9e524d5afd0 100644 --- a/test/jdk/java/util/jar/JarFile/SignedJarFileGetInputStream.java +++ b/test/jdk/java/util/jar/JarFile/SignedJarFileGetInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,45 +24,38 @@ /* @test * @bug 4845692 8206863 * @summary JarFile.getInputStream should not throw when jar file is signed - * @author Martin Buchholz + * @run junit SignedJarFileGetInputStream */ +import org.junit.jupiter.api.Test; + import java.io.*; import java.util.*; import java.util.jar.*; import java.util.zip.*; -public class SignedJarFileGetInputStream { - public static void main(String args[]) throws Throwable { - JarFile jar = new JarFile( - new File(System.getProperty("test.src", "."), "Signed.jar")); +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; +public class SignedJarFileGetInputStream { + + @Test + void signedJarTest() throws IOException { + JarFile jar = new JarFile( + new File(System.getProperty("test.src", "."), "Signed.jar")); for (Enumeration e = jar.entries(); e.hasMoreElements();) { JarEntry entry = (JarEntry) e.nextElement(); - InputStream is = jar.getInputStream(new ZipEntry(entry.getName())); + InputStream is = assertDoesNotThrow(() -> jar.getInputStream(new ZipEntry(entry.getName()))); is.close(); } - // read(), available() on closed stream should throw IOException InputStream is = jar.getInputStream(new ZipEntry("Test.class")); is.close(); byte[] buffer = new byte[1]; - try { - is.read(); - throw new AssertionError("Should have thrown IOException"); - } catch (IOException success) {} - try { - is.read(buffer); - throw new AssertionError("Should have thrown IOException"); - } catch (IOException success) {} - try { - is.read(buffer, 0, buffer.length); - throw new AssertionError("Should have thrown IOException"); - } catch (IOException success) {} - try { - is.available(); - throw new AssertionError("Should have thrown IOException"); - } catch (IOException success) {} + assertThrows(IOException.class, () -> is.read()); + assertThrows(IOException.class, () -> is.read(buffer)); + assertThrows(IOException.class, () -> is.read(buffer, 0, buffer.length)); + assertThrows(IOException.class, () -> is.available()); } } diff --git a/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java b/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java index a6f9955a507..a6326be622a 100644 --- a/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java +++ b/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,15 +21,21 @@ * questions. */ -/** +/* * @test * @modules java.base/sun.security.tools.keytool * @summary JARs with pending block files (where .RSA comes before .SF) should verify correctly + * @run junit SignedJarPendingBlock */ import jdk.security.jarsigner.JarSigner; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.FieldSource; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.StandardCharsets; @@ -42,32 +48,47 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class SignedJarPendingBlock { - public static void main(String[] args) throws Exception { + static Path signed; + static Path pendingBlocks; + static Path invalid; + + // Construct the test data + @BeforeAll + static void setup() throws Exception { Path jar = createJarFile(); - Path signed = signJarFile(jar); - Path pendingBlocks = moveBlockFirst(signed); - Path invalid = invalidate(pendingBlocks); - - // 1: Regular signed JAR with no pending blocks should verify - checkSigned(signed); - - // 2: Signed jar with pending blocks should verify - checkSigned(pendingBlocks); - - // 3: Invalid signed jar with pending blocks should throw SecurityException - try { - checkSigned(invalid); - throw new Exception("Expected invalid digest to be detected"); - } catch (SecurityException se) { - // Ignore - } + signed = signJarFile(jar); + pendingBlocks = moveBlockFirst(signed); + invalid = invalidate(pendingBlocks); } - private static void checkSigned(Path b) throws Exception { - try (JarFile jf = new JarFile(b.toFile(), true)) { + // Regular signed JAR with no pending blocks should verify + @Test + void checkValidSignedJar() { + assertDoesNotThrow(() -> checkSigned(signed), + "Valid digest should not fail"); + } + // Signed jar with pending blocks should verify + @Test + void checkValidSignedPendingJar() { + assertDoesNotThrow(() -> checkSigned(pendingBlocks), + "Valid digest should not fail"); + } + + // Invalid signed jar with pending blocks should throw SecurityException + @Test + void checkInvalidSignedJar() { + assertThrows(SecurityException.class, () -> checkSigned(invalid), + "Expected invalid digest to be detected"); + } + + private static void checkSigned(Path b) throws IOException { + try (JarFile jf = new JarFile(b.toFile(), true)) { JarEntry je = jf.getJarEntry("a.txt"); try (InputStream in = jf.getInputStream(je)) { in.transferTo(OutputStream.nullOutputStream()); diff --git a/test/jdk/java/util/jar/JarFile/SorryClosed.java b/test/jdk/java/util/jar/JarFile/SorryClosed.java index 19481347394..38950539c57 100644 --- a/test/jdk/java/util/jar/JarFile/SorryClosed.java +++ b/test/jdk/java/util/jar/JarFile/SorryClosed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,43 +24,49 @@ /* @test * @bug 4910572 * @summary Accessing a closed jar file should generate IllegalStateException. - * @author Martin Buchholz + * @run junit SorryClosed */ +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.io.File; import java.util.jar.JarFile; import java.util.zip.ZipEntry; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class SorryClosed { - public static void main(String args[]) throws IOException { - File file = new File(System.getProperty("test.src","."), "test.jar"); - String testEntryName = "test.class"; + private static final File file = new File(System.getProperty("test.src", "."), "test.jar"); + private static final String testEntryName = "test.class"; - try { - JarFile f = new JarFile(file); - ZipEntry e = f.getEntry(testEntryName); - f.close(); - f.getInputStream(e); - } catch (IllegalStateException e) {} // OK + @Test + void getInputStreamTest() throws IOException { + JarFile f = new JarFile(file); + ZipEntry e = f.getEntry(testEntryName); + f.close(); + assertThrows(IllegalStateException.class, () -> f.getInputStream(e)); + } - try { - JarFile f = new JarFile(file); - f.close(); - f.getEntry(testEntryName); - } catch (IllegalStateException e) {} // OK + @Test + void getEntryTest() throws IOException { + JarFile f = new JarFile(file); + f.close(); + assertThrows(IllegalStateException.class, () -> f.getEntry(testEntryName)); + } - try { - JarFile f = new JarFile(file); - f.close(); - f.getJarEntry(testEntryName); - } catch (IllegalStateException e) {} // OK + @Test + void getJarEntryTest() throws IOException { + JarFile f = new JarFile(file); + f.close(); + assertThrows(IllegalStateException.class, () -> f.getJarEntry(testEntryName)); + } - try { - JarFile f = new JarFile(file); - f.close(); - f.getManifest(); - } catch (IllegalStateException e) {} // OK + @Test + void getManifestTest() throws IOException { + JarFile f = new JarFile(file); + f.close(); + assertThrows(IllegalStateException.class, f::getManifest); } } diff --git a/test/jdk/java/util/jar/JarFile/TurkCert.java b/test/jdk/java/util/jar/JarFile/TurkCert.java index 68e3d83e002..216fd535e2b 100644 --- a/test/jdk/java/util/jar/JarFile/TurkCert.java +++ b/test/jdk/java/util/jar/JarFile/TurkCert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, 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,38 +21,35 @@ * questions. */ -/** +/* * @test * @bug 4624534 * @summary Make sure jar certificates work for Turkish locale - * @author kladko + * @run junit/othervm -Duser.language=tr -Duser.country=TR TurkCert */ +import org.junit.jupiter.api.Test; + import java.util.*; import java.util.jar.*; import java.security.cert.*; import java.io.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class TurkCert { - public static void main(String[] args) throws Exception{ - Locale reservedLocale = Locale.getDefault(); - try { - Locale.setDefault(Locale.of("tr", "TR")); - File f = new File(System.getProperty("test.src","."), "test.jar"); - try (JarFile jf = new JarFile(f, true)) { - JarEntry je = (JarEntry)jf.getEntry("test.class"); - try (InputStream is = jf.getInputStream(je)) { - byte[] b = new byte[1024]; - while (is.read(b) != -1) { - } - } - if (je.getCertificates() == null) { - throw new Exception("Null certificate for test.class."); + + @Test + void turkishLocaleTest() throws IOException { + File f = new File(System.getProperty("test.src", "."), "test.jar"); + try (JarFile jf = new JarFile(f, true)) { + JarEntry je = (JarEntry)jf.getEntry("test.class"); + try (InputStream is = jf.getInputStream(je)) { + byte[] b = new byte[1024]; + while (is.read(b) != -1) { } } - } finally { - // restore the default locale - Locale.setDefault(reservedLocale); + assertNotNull(je.getCertificates(), "Null certificate for test.class."); } } } diff --git a/test/jdk/java/util/jar/JarFile/VerifySignedJar.java b/test/jdk/java/util/jar/JarFile/VerifySignedJar.java index bd5490502c9..e1602c0aa46 100644 --- a/test/jdk/java/util/jar/JarFile/VerifySignedJar.java +++ b/test/jdk/java/util/jar/JarFile/VerifySignedJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, 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,18 +21,20 @@ * questions. */ -/** +/* * @test - * @library /test/lib * @modules java.base/sun.security.x509 * @modules java.base/sun.security.tools.keytool * @bug 4419266 4842702 * @summary Make sure verifying signed Jar doesn't throw SecurityException + * @run junit VerifySignedJar */ import jdk.security.jarsigner.JarSigner; +import org.junit.jupiter.api.Test; import sun.security.tools.keytool.CertAndKeyGen; import sun.security.x509.X500Name; +import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; @@ -40,21 +42,24 @@ import java.security.KeyStore; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Collections; -import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; -import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import static jdk.test.lib.Utils.runAndCheckException; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class VerifySignedJar { - public static void main(String[] args) throws Exception { - + @Test + void signedJarSecurityExceptionTest() throws Exception { Path j = createJar(); Path s = signJar(j, keyEntry("cn=duke")); @@ -70,38 +75,30 @@ public class VerifySignedJar { } // Read ZIP and JAR entries by name - Objects.requireNonNull(jf.getEntry("getprop.class")); - Objects.requireNonNull(jf.getJarEntry("getprop.class")); + assertNotNull(jf.getEntry("getprop.class")); + assertNotNull(jf.getJarEntry("getprop.class")); // Make sure we throw NPE on null parameters - runAndCheckException(() -> jf.getEntry(null), NullPointerException.class); - runAndCheckException(() -> jf.getJarEntry(null), NullPointerException.class); - runAndCheckException(() -> jf.getInputStream(null), NullPointerException.class); + assertThrows(NullPointerException.class, () -> jf.getEntry(null)); + assertThrows(NullPointerException.class, () -> jf.getJarEntry(null)); + assertThrows(NullPointerException.class, () -> jf.getInputStream(null)); } catch (SecurityException se) { - throw new Exception("Got SecurityException when verifying signed " + - "jar:" + se); + fail("Got SecurityException when verifying signed jar:" + se); } } // Check that a JAR entry is signed by an expected DN - private static void checkSignedBy(JarEntry e, String expectedDn) throws Exception { + private static void checkSignedBy(JarEntry e, String expectedDn) { Certificate[] certs = e.getCertificates(); - if (certs == null || certs.length == 0) { - throw new Exception("JarEntry has no certificates: " + e.getName()); - } - - if (certs[0] instanceof X509Certificate x) { - String name = x.getSubjectX500Principal().getName(); - if (!name.equalsIgnoreCase(expectedDn)) { - throw new Exception("Expected entry signed by %s, was %s".formatted(name, expectedDn)); - } - } else { - throw new Exception("Expected JarEntry.getCertificate to return X509Certificate"); - } + assertNotNull(certs, "JarEntry has no certificates: " + e.getName()); + assertNotEquals(0, certs.length, "JarEntry has no certificates: " + e.getName()); + var x = assertInstanceOf(X509Certificate.class, certs[0], "Expected JarEntry.getCertificate to return X509Certificate"); + String name = x.getSubjectX500Principal().getName(); + assertTrue(name.equalsIgnoreCase(expectedDn), "Expected entry signed by %s, was %s".formatted(name, expectedDn)); } - private static Path createJar() throws Exception { + private static Path createJar() throws IOException { Path j = Path.of("unsigned.jar"); try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(j))){ out.putNextEntry(new JarEntry("getprop.class")); diff --git a/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java b/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java index 4d191d7b3cd..b4b7fda081e 100644 --- a/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java +++ b/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,8 +33,7 @@ * jdk.test.lib.JDKToolLauncher * MultiThreadLoad FooService * @modules java.base/jdk.internal.access:+open - * @run main MultiProviderTest - * @run main MultiProviderTest sign + * @run junit MultiProviderTest */ import java.io.File; @@ -51,27 +50,33 @@ import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.util.Arrays.asList; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; public class MultiProviderTest { private static final String METAINFO = "META-INF/services/FooService"; - private static String COMBO_CP = Utils.TEST_CLASS_PATH + File.pathSeparator; private static String TEST_CLASS_PATH = System.getProperty("test.classes", "."); - private static boolean signJars = false; static final int NUM_JARS = 5; + // Reset per each test run under JUnit default lifecycle + private boolean signJars = false; + private String COMBO_CP = Utils.TEST_CLASS_PATH + File.pathSeparator; private static final String KEYSTORE = "keystore.jks"; private static final String ALIAS = "JavaTest"; private static final String STOREPASS = "changeit"; private static final String KEYPASS = "changeit"; - public static void main(String[] args) throws Throwable { - signJars = args.length >=1 && args[0].equals("sign"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void classLoadingTest(boolean sign) throws Throwable { + signJars = sign; initialize(); List cmds = new ArrayList<>(); cmds.add(JDKToolFinder.getJDKTool("java")); @@ -86,18 +91,16 @@ public class MultiProviderTest { "MultiThreadLoad", TEST_CLASS_PATH)); - try { + assertDoesNotThrow(() -> { OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(cmds.stream() - .filter(t -> !t.isEmpty()) - .toArray(String[]::new)) + .filter(t -> !t.isEmpty()) + .toArray(String[]::new)) .shouldHaveExitValue(0); System.out.println("Output:" + outputAnalyzer.getOutput()); - } catch (Throwable t) { - throw new RuntimeException("Unexpected fail.", t); - } + }); } - public static void initialize() throws Throwable { + public void initialize() throws Throwable { if (signJars) { genKey(); } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java index e8abec354ed..1ba25ef6985 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ * CreateMultiReleaseTestJars * jdk.test.lib.compiler.Compiler * jdk.test.lib.util.JarBuilder - * @run testng MultiReleaseJarAPI + * @run junit MultiReleaseJarAPI */ import java.io.File; @@ -44,37 +44,41 @@ import java.util.Map; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; import java.util.jar.JarFile; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import jdk.test.lib.RandomFactory; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; public class MultiReleaseJarAPI { private static final Random RANDOM = RandomFactory.getRandom(); - String userdir = System.getProperty("user.dir","."); - CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); - File unversioned = new File(userdir, "unversioned.jar"); - File multirelease = new File(userdir, "multi-release.jar"); - File signedmultirelease = new File(userdir, "signed-multi-release.jar"); + private static final String userdir = System.getProperty("user.dir", "."); + private static final CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); + private static final File unversioned = new File(userdir, "unversioned.jar"); + private static final File multirelease = new File(userdir, "multi-release.jar"); + private static final File signedmultirelease = new File(userdir, "signed-multi-release.jar"); - - @BeforeClass - public void initialize() throws Exception { + @BeforeAll + public static void initialize() throws Exception { creator.compileEntries(); creator.buildUnversionedJar(); creator.buildMultiReleaseJar(); creator.buildSignedMultiReleaseJar(); } - @AfterClass - public void close() throws IOException { + @AfterAll + public static void close() throws IOException { Files.delete(unversioned.toPath()); Files.delete(multirelease.toPath()); Files.delete(signedmultirelease.toPath()); @@ -83,19 +87,19 @@ public class MultiReleaseJarAPI { @Test public void isMultiReleaseJar() throws Exception { try (JarFile jf = new JarFile(unversioned)) { - Assert.assertFalse(jf.isMultiRelease()); + assertFalse(jf.isMultiRelease()); } try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.version())) { - Assert.assertFalse(jf.isMultiRelease()); + assertFalse(jf.isMultiRelease()); } try (JarFile jf = new JarFile(multirelease)) { - Assert.assertTrue(jf.isMultiRelease()); + assertTrue(jf.isMultiRelease()); } try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.version())) { - Assert.assertTrue(jf.isMultiRelease()); + assertTrue(jf.isMultiRelease()); } testCustomMultiReleaseValue("true", true); @@ -155,45 +159,46 @@ public class MultiReleaseJarAPI { creator.buildCustomMultiReleaseJar(fileName, value, extraAttributes); File custom = new File(userdir, fileName); try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) { - Assert.assertEquals(jf.isMultiRelease(), expected); + assertEquals(expected, jf.isMultiRelease()); } Files.delete(custom.toPath()); } - @DataProvider(name = "versions") - public Object[][] createVersionData() throws Exception { - return new Object[][]{ - {JarFile.baseVersion(), 8}, - {JarFile.runtimeVersion(), Runtime.version().major()}, - {Runtime.version(), Runtime.version().major()}, - {Runtime.Version.parse("7.1"), JarFile.baseVersion().major()}, - {Runtime.Version.parse("9"), 9}, - {Runtime.Version.parse("9.1.5-ea+200"), 9} - }; + public static Stream createVersionData() { + return Stream.of( + Arguments.of(JarFile.baseVersion(), 8), + Arguments.of(JarFile.runtimeVersion(), Runtime.version().major()), + Arguments.of(Runtime.version(), Runtime.version().major()), + Arguments.of(Runtime.Version.parse("7.1"), JarFile.baseVersion().major()), + Arguments.of(Runtime.Version.parse("9"), 9), + Arguments.of(Runtime.Version.parse("9.1.5-ea+200"), 9) + ); } - @Test(dataProvider="versions") + @ParameterizedTest + @MethodSource("createVersionData") public void testVersioning(Runtime.Version value, int xpected) throws Exception { Runtime.Version expected = Runtime.Version.parse(String.valueOf(xpected)); Runtime.Version base = JarFile.baseVersion(); // multi-release jar, opened as unversioned try (JarFile jar = new JarFile(multirelease)) { - Assert.assertEquals(jar.getVersion(), base); + assertEquals(base, jar.getVersion()); } System.err.println("test versioning for Release " + value); try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) { - Assert.assertEquals(jf.getVersion(), expected); + assertEquals(expected, jf.getVersion()); } // regular, unversioned, jar try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) { - Assert.assertEquals(jf.getVersion(), base); + assertEquals(base, jf.getVersion()); } } - @Test(dataProvider="versions") + @ParameterizedTest + @MethodSource("createVersionData") public void testAliasing(Runtime.Version version, int xpected) throws Exception { int n = Math.max(version.major(), JarFile.baseVersion().major()); Runtime.Version value = Runtime.Version.parse(String.valueOf(n)); @@ -231,7 +236,7 @@ public class MultiReleaseJarAPI { } assert versionedBytes.length > 0; - Assert.assertTrue(Arrays.equals(baseBytes, versionedBytes)); + assertTrue(Arrays.equals(baseBytes, versionedBytes)); } @Test @@ -243,11 +248,11 @@ public class MultiReleaseJarAPI { try (JarFile jf = new JarFile(multirelease)) { ze1 = jf.getEntry(vname); } - Assert.assertEquals(ze1.getName(), vname); + assertEquals(vname, ze1.getName()); try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) { ze2 = jf.getEntry(rname); } - Assert.assertEquals(ze2.getName(), rname); - Assert.assertNotEquals(ze1.getName(), ze2.getName()); + assertEquals(rname, ze2.getName()); + assertNotEquals(ze2.getName(), ze1.getName()); } } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java index 16f764c6674..7d3a933a619 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,17 +31,17 @@ * @build CreateMultiReleaseTestJars * jdk.test.lib.compiler.Compiler * jdk.test.lib.util.JarBuilder - * @run testng MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=0 MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=8 MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=9 MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=100 MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties - * @run testng/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties + * @run junit MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=0 MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=8 MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=9 MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=100 MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties + * @run junit/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties */ import java.io.IOException; @@ -56,16 +56,19 @@ import java.util.concurrent.Executors; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.SimpleFileServer; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class MultiReleaseJarHttpProperties extends MultiReleaseJarProperties { private HttpServer server; private ExecutorService executor; static final String TESTCONTEXT = "/multi-release.jar"; //mapped to local file path - @BeforeClass + @BeforeAll public void initialize() throws Exception { server = SimpleFileServer.createFileServer(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), Path.of(System.getProperty("user.dir", ".")), SimpleFileServer.OutputLevel.INFO); @@ -86,7 +89,7 @@ public class MultiReleaseJarHttpProperties extends MultiReleaseJarProperties { rootClass = cldr.loadClass("version.Main"); } - @AfterClass + @AfterAll public void close() throws IOException { // Windows requires server to stop before file is deleted if (server != null) { diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java index cbc9516542e..a742a593868 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,17 +29,17 @@ * @build CreateMultiReleaseTestJars * jdk.test.lib.compiler.Compiler * jdk.test.lib.util.JarBuilder - * @run testng MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=0 MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=8 MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=9 MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=100 MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties - * @run testng/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties + * @run junit MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=0 MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=8 MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=9 MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=100 MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties + * @run junit/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties */ import java.io.File; @@ -54,12 +54,15 @@ import java.nio.file.Files; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +import static org.junit.jupiter.api.Assertions.*; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class MultiReleaseJarProperties { final static int BASE_VERSION = JarFile.baseVersion().major(); @@ -70,7 +73,7 @@ public class MultiReleaseJarProperties { protected ClassLoader cldr; protected Class rootClass; - @BeforeClass + @BeforeAll public void initialize() throws Exception { CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); creator.compileEntries(); @@ -97,7 +100,7 @@ public class MultiReleaseJarProperties { rootClass = cldr.loadClass("version.Main"); } - @AfterClass + @AfterAll public void close() throws IOException { ((URLClassLoader) cldr).close(); Files.delete(multirelease.toPath()); @@ -115,7 +118,7 @@ public class MultiReleaseJarProperties { protected void invokeMethod(Class vcls, int expected) throws Throwable { MethodType mt = MethodType.methodType(int.class); MethodHandle mh = MethodHandles.lookup().findVirtual(vcls, "getVersion", mt); - Assert.assertEquals(expected, (int) mh.invoke(vcls.newInstance())); + assertEquals(expected, (int) mh.invoke(vcls.newInstance())); } /* @@ -177,7 +180,7 @@ public class MultiReleaseJarProperties { resource = new String(bytes); } String match = "return " + rtVersion + ";"; - Assert.assertTrue(resource.contains(match)); + assertTrue(resource.contains(match)); } @Test @@ -194,6 +197,6 @@ public class MultiReleaseJarProperties { resource = new String(bytes); } String match = "return " + rtVersion + ";"; - Assert.assertTrue(resource.contains(match)); + assertTrue(resource.contains(match)); } } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java index ec18cad0817..7e0bb2c1ca7 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +29,7 @@ * @build CreateMultiReleaseTestJars * jdk.test.lib.compiler.Compiler * jdk.test.lib.util.JarBuilder - * @run testng MultiReleaseJarSecurity + * @run junit MultiReleaseJarSecurity */ import java.io.File; @@ -38,45 +38,45 @@ import java.io.InputStream; import java.nio.file.Files; import java.security.CodeSigner; import java.security.cert.Certificate; -import java.util.Arrays; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipFile; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class MultiReleaseJarSecurity { static final int MAJOR_VERSION = Runtime.version().major(); - String userdir = System.getProperty("user.dir","."); - File multirelease = new File(userdir, "multi-release.jar"); - File signedmultirelease = new File(userdir, "signed-multi-release.jar"); + static final String USER_DIR = System.getProperty("user.dir", "."); + static final File MULTI_RELEASE = new File(USER_DIR, "multi-release.jar"); + static final File SIGNED_MULTI_RELEASE = new File(USER_DIR, "signed-multi-release.jar"); - @BeforeClass - public void initialize() throws Exception { + @BeforeAll + public static void initialize() throws Exception { CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); creator.compileEntries(); creator.buildMultiReleaseJar(); creator.buildSignedMultiReleaseJar(); } - @AfterClass - public void close() throws IOException { - Files.delete(multirelease.toPath()); - Files.delete(signedmultirelease.toPath()); + @AfterAll + public static void close() throws IOException { + Files.delete(MULTI_RELEASE.toPath()); + Files.delete(SIGNED_MULTI_RELEASE.toPath()); } @Test public void testCertsAndSigners() throws IOException { - try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, Runtime.version())) { + try (JarFile jf = new JarFile(SIGNED_MULTI_RELEASE, true, ZipFile.OPEN_READ, Runtime.version())) { CertsAndSigners vcas = new CertsAndSigners(jf, jf.getJarEntry("version/Version.class")); CertsAndSigners rcas = new CertsAndSigners(jf, jf.getJarEntry("META-INF/versions/" + MAJOR_VERSION + "/version/Version.class")); - Assert.assertTrue(Arrays.equals(rcas.getCertificates(), vcas.getCertificates())); - Assert.assertTrue(Arrays.equals(rcas.getCodeSigners(), vcas.getCodeSigners())); + assertArrayEquals(rcas.getCertificates(), vcas.getCertificates()); + assertArrayEquals(rcas.getCodeSigners(), vcas.getCodeSigners()); } } diff --git a/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java b/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java index dbff39f814e..f88ab0821ae 100644 --- a/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java +++ b/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +28,7 @@ * @library /test/lib * @build jdk.test.lib.Platform * jdk.test.lib.util.FileUtils - * @run testng TestVersionedStream + * @run junit TestVersionedStream */ import java.io.File; @@ -41,7 +41,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -54,18 +53,20 @@ import java.util.stream.Stream; import java.util.zip.ZipFile; import jdk.test.lib.util.FileUtils; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; public class TestVersionedStream { - private final Path userdir; - private final Set unversionedEntryNames; + private static final Path userdir; + private static final Set unversionedEntryNames; private static final int LATEST_VERSION = Runtime.version().feature(); - public TestVersionedStream() throws IOException { + static { userdir = Paths.get(System.getProperty("user.dir", ".")); // These are not real class files even though they end with .class. @@ -91,8 +92,7 @@ public class TestVersionedStream { "--release " + LATEST_VERSION + " -C v" + LATEST_VERSION + " ."); System.out.println("Contents of mmr.jar\n======="); - - try(JarFile jf = new JarFile("mmr.jar")) { + try (JarFile jf = new JarFile("mmr.jar")) { unversionedEntryNames = jf.stream() .map(je -> je.getName()) .peek(System.out::println) @@ -100,13 +100,14 @@ public class TestVersionedStream { ? nm.replaceFirst("META-INF/versions/\\d+/", "") : nm) .collect(Collectors.toCollection(LinkedHashSet::new)); + } catch (IOException e) { + throw new RuntimeException("Failed to init \"unversionedEntryNames\"", e); } - System.out.println("======="); } - @AfterClass - public void close() throws IOException { + @AfterAll + public static void close() throws IOException { Files.walk(userdir, 1) .filter(p -> !p.equals(userdir)) .forEach(p -> { @@ -122,53 +123,41 @@ public class TestVersionedStream { }); } - @DataProvider - public Object[][] data() { - return new Object[][] { - {Runtime.Version.parse("8")}, - {Runtime.Version.parse("9")}, - {Runtime.Version.parse("10")}, - {Runtime.Version.parse(Integer.toString(LATEST_VERSION))}, - {JarFile.baseVersion()}, - {JarFile.runtimeVersion()} - }; + public static Stream arguments() { + return Stream.of( + Runtime.Version.parse("8"), + Runtime.Version.parse("9"), + Runtime.Version.parse("10"), + Runtime.Version.parse(Integer.toString(LATEST_VERSION)), + JarFile.baseVersion(), + JarFile.runtimeVersion() + ); } - @Test(dataProvider="data") - public void test(Runtime.Version version) throws Exception { + @ParameterizedTest + @MethodSource("arguments") + public void versionTest(Runtime.Version version) throws Exception { try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version); Stream jes = jf.versionedStream()) { - Assert.assertNotNull(jes); + assertNotNull(jes); // put versioned entries in list so we can reuse them List versionedEntries = jes.collect(Collectors.toList()); - Assert.assertTrue(versionedEntries.size() > 0); + assertTrue(versionedEntries.size() > 0); // also keep the names - List versionedNames = new ArrayList<>(versionedEntries.size()); + List versionedNames = versionedEntries.stream() + .map(JarEntry::getName) + .collect(Collectors.toList()); // verify the correct order while building enames - Iterator allIt = unversionedEntryNames.iterator(); - Iterator verIt = versionedEntries.iterator(); - boolean match = false; + List unversionedOrder = new ArrayList<>(unversionedEntryNames); + unversionedOrder.retainAll(versionedNames); - while (verIt.hasNext()) { - match = false; - if (!allIt.hasNext()) break; - String name = verIt.next().getName(); - versionedNames.add(name); - while (allIt.hasNext()) { - if (name.equals(allIt.next())) { - match = true; - break; - } - } - } - if (!match) { - Assert.fail("versioned entries not in same order as unversioned entries"); - } + assertIterableEquals(unversionedOrder, versionedNames, + "versioned entries not in same order as unversioned entries"); // verify the contents: // value.[0] end of the path @@ -205,21 +194,21 @@ public class TestVersionedStream { expected.put("q/Bar.class", new String[] { "q/Bar.class", "META-INF/versions/10/q/Bar.class"}); } else { - Assert.fail("Test out of date, please add more cases"); + fail("Test out of date, please add more cases"); } } expected.entrySet().stream().forEach(e -> { String name = e.getKey(); int i = versionedNames.indexOf(name); - Assert.assertTrue(i != -1, name + " not in enames"); + assertTrue(i != -1, name + " not in enames"); JarEntry je = versionedEntries.get(i); try (InputStream is = jf.getInputStream(je)) { String s = new String(is.readAllBytes()).replaceAll(System.lineSeparator(), ""); // end of the path - Assert.assertTrue(s.endsWith(e.getValue()[0]), s); + assertTrue(s.endsWith(e.getValue()[0]), s); // getRealName() - Assert.assertTrue(je.getRealName().equals(e.getValue()[1])); + assertTrue(je.getRealName().equals(e.getValue()[1])); } catch (IOException x) { throw new UncheckedIOException(x); } @@ -227,12 +216,12 @@ public class TestVersionedStream { if (!unversionedEntryNames.contains("META-INF/Foo.class") || versionedNames.indexOf("META-INF/Foo.class") != -1) { - Assert.fail("versioned META-INF/Foo.class test failed"); + fail("versioned META-INF/Foo.class test failed"); } } } - private void createFiles(String... files) { + private static void createFiles(String... files) { ArrayList list = new ArrayList(); Arrays.stream(files) .map(f -> Paths.get(userdir.toAbsolutePath().toString(), f)) @@ -248,7 +237,7 @@ public class TestVersionedStream { }}); } - private void jar(String args) { + private static void jar(String args) { ToolProvider jar = ToolProvider.findFirst("jar").orElseThrow(); jar.run(System.out, System.err, args.split(" +")); } diff --git a/test/jdk/java/util/jar/JarInputStream/EmptyJar.java b/test/jdk/java/util/jar/JarInputStream/EmptyJar.java index 9762455460c..ff961844685 100644 --- a/test/jdk/java/util/jar/JarInputStream/EmptyJar.java +++ b/test/jdk/java/util/jar/JarInputStream/EmptyJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,18 +26,22 @@ @summary Make sure JarInputStream constructor will not throw NullPointerException when the JAR file is empty. - */ + @run junit EmptyJar + */ + +import org.junit.jupiter.api.Test; import java.util.jar.*; import java.io.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + public class EmptyJar { - public static void main(String args[]) throws Exception { - try { - JarInputStream is = new JarInputStream - (new ByteArrayInputStream(new byte[0])); - } catch (NullPointerException e) { - throw new Exception("unexpected NullPointerException"); - } + + @Test + void npeTest() { + // Ensure no NPE is thrown + assertDoesNotThrow(() -> new JarInputStream(new ByteArrayInputStream(new byte[0])), + "unexpected NullPointerException"); } } diff --git a/test/jdk/java/util/jar/JarInputStream/ExtraFileInMetaInf.java b/test/jdk/java/util/jar/JarInputStream/ExtraFileInMetaInf.java index 45865ec0b8f..fe88d225444 100644 --- a/test/jdk/java/util/jar/JarInputStream/ExtraFileInMetaInf.java +++ b/test/jdk/java/util/jar/JarInputStream/ExtraFileInMetaInf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,16 +27,24 @@ * @summary JarInputStream doesn't provide certificates for some file under META-INF * @modules java.base/sun.security.tools.keytool * jdk.jartool/sun.security.tools.jarsigner + * @run junit ExtraFileInMetaInf */ +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import java.util.jar.*; import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -public class ExtraFileInMetaInf { - public static void main(String args[]) throws Exception { +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; +public class ExtraFileInMetaInf { + + @BeforeAll + static void setup() throws Exception { // Create a zip file with 2 entries try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("x.jar"))) { @@ -44,7 +52,6 @@ public class ExtraFileInMetaInf { zos.write(new byte[10]); zos.putNextEntry(new ZipEntry("x")); zos.write(new byte[10]); - zos.close(); } // Sign it @@ -54,7 +61,10 @@ public class ExtraFileInMetaInf { "-keyalg rsa -alias a -dname CN=A -genkeypair").split(" ")); sun.security.tools.jarsigner.Main.main( "-keystore ks -storepass changeit x.jar a".split(" ")); + } + @Test + void checkSignedTest() throws IOException { // Check if the entries are signed try (JarInputStream jis = new JarInputStream(new FileInputStream("x.jar"))) { @@ -63,9 +73,7 @@ public class ExtraFileInMetaInf { String name = je.toString(); if (name.equals("META-INF/SUB/file") || name.equals("x")) { while (jis.read(new byte[1000]) >= 0); - if (je.getCertificates() == null) { - throw new Exception(name + " not signed"); - } + assertNotNull(je.getCertificates(), name + " not signed"); } } } diff --git a/test/jdk/java/util/jar/JarInputStream/ScanSignedJar.java b/test/jdk/java/util/jar/JarInputStream/ScanSignedJar.java index 86dbf793e74..23e0a81c4cf 100644 --- a/test/jdk/java/util/jar/JarInputStream/ScanSignedJar.java +++ b/test/jdk/java/util/jar/JarInputStream/ScanSignedJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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,13 +25,19 @@ * @test * @bug 6284489 * @summary Confirm that JarEntry.getCertificates identifies signed entries. + * @run junit ScanSignedJar */ +import org.junit.jupiter.api.Test; + +import java.io.IOException; import java.net.URL; import java.security.CodeSigner; import java.security.cert.Certificate; import java.util.jar.*; +import static org.junit.jupiter.api.Assertions.fail; + /* * Confirm that the signed entries in a JAR file are identified correctly * when JarEntry.getCertificates is used to extract the signer's certificates. @@ -43,13 +49,13 @@ import java.util.jar.*; public class ScanSignedJar { private static final String JAR_LOCATION = - "file:" + - System.getProperty("test.src", ".") + - System.getProperty("file.separator") + - "signed.jar"; - - public static void main(String[] args) throws Exception { + "file:" + + System.getProperty("test.src", ".") + + System.getProperty("file.separator") + + "signed.jar"; + @Test + void signedJarTest() throws IOException { System.out.println("Opening " + JAR_LOCATION + "..."); JarInputStream inStream = new JarInputStream(new URL(JAR_LOCATION).openStream(), true); @@ -71,7 +77,7 @@ public class ScanSignedJar { System.out.println("[unsigned]\t" + name + "\t(" + size + " bytes)"); if (name.equals("Count.class")) { - throw new Exception("Count.class should be signed"); + fail("Count.class should be signed"); } } else if (signers != null && certificates != null) { System.out.println("[" + signers.length + @@ -80,7 +86,7 @@ public class ScanSignedJar { } else { System.out.println("[*ERROR*]\t" + name + "\t(" + size + " bytes)"); - throw new Exception("Cannot determine whether the entry is " + + fail("Cannot determine whether the entry is " + "signed or unsigned (signers[] doesn't match certs[])."); } } diff --git a/test/jdk/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java b/test/jdk/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java index 2e74eb10069..47dc572aa6b 100644 --- a/test/jdk/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java +++ b/test/jdk/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,32 +26,32 @@ * @bug 6544278 * @summary Confirm the JarInputStream throws the SecurityException when * verifying an indexed jar file with corrupted signature + * @run junit TestIndexedJarWithBadSignature */ +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.io.FileInputStream; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class TestIndexedJarWithBadSignature { - public static void main(String...args) throws Throwable { + @Test + void securityExceptionTest() throws IOException { try (JarInputStream jis = new JarInputStream( - new FileInputStream(System.getProperty("test.src", ".") + - System.getProperty("file.separator") + - "BadSignedJar.jar"))) - { - JarEntry je1 = jis.getNextJarEntry(); - while(je1!=null){ - System.out.println("Jar Entry1==>"+je1.getName()); - je1 = jis.getNextJarEntry(); // This should throw Security Exception - } - throw new RuntimeException( - "Test Failed:Security Exception not being thrown"); - } catch (IOException ie){ - ie.printStackTrace(); - } catch (SecurityException e) { - System.out.println("Test passed: Security Exception thrown as expected"); + new FileInputStream(System.getProperty("test.src", ".") + + System.getProperty("file.separator") + + "BadSignedJar.jar"))) { + assertThrows(SecurityException.class, () -> { + JarEntry je1; + while ((je1 = jis.getNextJarEntry()) != null) { + System.out.println("Jar Entry1==>" + je1.getName()); + } + }); } } } diff --git a/test/jdk/java/util/jar/Manifest/CreateManifest.java b/test/jdk/java/util/jar/Manifest/CreateManifest.java index 6655089b56d..2eee24fb0be 100644 --- a/test/jdk/java/util/jar/Manifest/CreateManifest.java +++ b/test/jdk/java/util/jar/Manifest/CreateManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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,40 +27,43 @@ * @summary Jar tools fails to generate manifest correctly when boundary condition hit * @modules jdk.jartool/sun.tools.jar * @compile -XDignore.symbol.file=true CreateManifest.java - * @run main CreateManifest + * @run junit CreateManifest */ +import org.junit.jupiter.api.Test; + +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.jar.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class CreateManifest { -public static void main(String arg[]) throws Exception { + @Test + void boundaryTest() throws IOException { + String jarFileName = "test.jar"; + String ManifestName = "MANIFEST.MF"; - String jarFileName = "test.jar"; - String ManifestName = "MANIFEST.MF"; + // create the MANIFEST.MF file + Files.write(Paths.get(ManifestName), FILE_CONTENTS.getBytes()); - // create the MANIFEST.MF file - Files.write(Paths.get(ManifestName), FILE_CONTENTS.getBytes()); + String [] args = new String [] { "cvfm", jarFileName, ManifestName}; + sun.tools.jar.Main jartool = + new sun.tools.jar.Main(System.out, System.err, "jar"); + jartool.run(args); - String [] args = new String [] { "cvfm", jarFileName, ManifestName}; - sun.tools.jar.Main jartool = - new sun.tools.jar.Main(System.out, System.err, "jar"); - jartool.run(args); - - try (JarFile jf = new JarFile(jarFileName)) { - Manifest m = jf.getManifest(); - String result = m.getMainAttributes().getValue("Class-path"); - if (result == null) - throw new RuntimeException("Failed to add Class-path attribute to manifest"); - } finally { - Files.deleteIfExists(Paths.get(jarFileName)); - Files.deleteIfExists(Paths.get(ManifestName)); + try (JarFile jf = new JarFile(jarFileName)) { + Manifest m = jf.getManifest(); + String result = m.getMainAttributes().getValue("Class-path"); + assertNotNull(result, "Failed to add Class-path attribute to manifest"); + } finally { + Files.deleteIfExists(Paths.get(jarFileName)); + Files.deleteIfExists(Paths.get(ManifestName)); + } } -} - private static final String FILE_CONTENTS = "Class-path: \n" + " /ade/dtsao_re/oracle/emcore//lib/em-core-testconsole-uimodel.jar \n" + diff --git a/test/jdk/java/util/jar/Manifest/IncludeInExceptionsTest.java b/test/jdk/java/util/jar/Manifest/IncludeInExceptionsTest.java index 1e272015087..52d3783b4cf 100644 --- a/test/jdk/java/util/jar/Manifest/IncludeInExceptionsTest.java +++ b/test/jdk/java/util/jar/Manifest/IncludeInExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 @@ * questions. */ -import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; @@ -30,17 +29,27 @@ import java.util.concurrent.Callable; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; +import static sun.security.util.SecurityProperties.INCLUDE_JAR_NAME_IN_EXCEPTIONS; -/** +/* * @test * @bug 8216362 - * @run main/othervm -Djdk.includeInExceptions=jar IncludeInExceptionsTest yes - * @run main/othervm IncludeInExceptionsTest - * @summary Verify that the property jdk.net.includeInExceptions works as expected - * when an error occurs while reading an invalid Manifest file. + * @summary Verify that the property jdk.includeInExceptions works as expected + * when an error occurs while reading an invalid Manifest file. + * @modules java.base/sun.security.util + * @run junit/othervm -Djdk.includeInExceptions=jar IncludeInExceptionsTest + * @run junit/othervm -Djdk.includeInExceptions= IncludeInExceptionsTest + * @run junit/othervm IncludeInExceptionsTest */ + /* * @see Manifest#Manifest(JarVerifier,InputStream,String) * @see Manifest#getErrorPosition @@ -66,36 +75,25 @@ public class IncludeInExceptionsTest { return jar; } - static void test(Callable attempt, boolean includeInExceptions) throws Exception { - try { - attempt.call(); - throw new AssertionError("Excpected Exception not thrown"); - } catch (IOException e) { - boolean foundFileName = e.getMessage().contains(FILENAME); - if(includeInExceptions && !foundFileName) { - throw new AssertionError("JAR file name expected but not found in error message"); - } else if (foundFileName && !includeInExceptions) { - throw new AssertionError("JAR file name found but should not be in error message"); - } + @ParameterizedTest + @MethodSource("manifests") + void testInvalidManifest(Callable attempt) { + var ioException = assertThrows(IOException.class, attempt::call); + boolean foundFileName = ioException.getMessage().contains(FILENAME); + if (INCLUDE_JAR_NAME_IN_EXCEPTIONS && !foundFileName) { + fail("JAR file name expected but not found in error message"); + } else if (foundFileName && !INCLUDE_JAR_NAME_IN_EXCEPTIONS) { + fail("JAR file name found but should not be in error message"); } } - public static void main(String[] args) throws Exception { - - boolean includeInExceptions; - if(args.length > 0) { - includeInExceptions = true; - System.out.println("**** Running test WITH -Djdk.includeInExceptions=jar"); - } else { - includeInExceptions = false; - System.out.println("**** Running test WITHOUT -Djdk.includeInExceptions=jar"); - } - - test(() -> new JarFile(createJarInvalidManifest(FILENAME)).getManifest(), - includeInExceptions); - test(() -> new JarFile(createJarInvalidManifest("Verifying-" + FILENAME), - true).getManifest(), includeInExceptions); + static Stream> manifests() { + Callable jarName = () -> new JarFile(createJarInvalidManifest(FILENAME)).getManifest(); + Callable jarNameVerify = () -> new JarFile(createJarInvalidManifest("Verifying-" + FILENAME), + true).getManifest(); + return Stream.of( + jarName, + jarNameVerify + ); } - } - diff --git a/test/jdk/java/util/jar/Manifest/LineBreakLineWidth.java b/test/jdk/java/util/jar/Manifest/LineBreakLineWidth.java index 8009db75601..f33bd7a276f 100644 --- a/test/jdk/java/util/jar/Manifest/LineBreakLineWidth.java +++ b/test/jdk/java/util/jar/Manifest/LineBreakLineWidth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,23 +21,22 @@ * questions. */ -import static java.nio.charset.StandardCharsets.UTF_8; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.util.jar.Manifest; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; /** * @test * @bug 6372077 - * @run testng LineBreakLineWidth + * @run junit LineBreakLineWidth * @summary write valid manifests with respect to line breaks * and read any line width */ @@ -99,16 +98,10 @@ public class LineBreakLineWidth { assertMainAndSectionValues(mf, name, value); } - static void writeInvalidManifestThrowsException(String name, String value) - throws IOException { - try { - writeManifest(name, value); - } catch (IllegalArgumentException e) { - // no invalid manifest was produced which is considered acceptable - return; - } - - fail("no error writing manifest considered invalid"); + static void writeInvalidManifestThrowsException(String name, String value) { + // no invalid manifest was produced which is considered acceptable + assertThrows(IllegalArgumentException.class, + () -> writeManifest(name, value), "no error writing manifest considered invalid"); } /** @@ -278,8 +271,8 @@ public class LineBreakLineWidth { String mainValue = mf.getMainAttributes().getValue(name); String sectionValue = mf.getAttributes(name).getValue(name); - assertEquals(value, mainValue, "value different in main section"); - assertEquals(value, sectionValue, "value different in named section"); + assertEquals(mainValue, value, "value different in main section"); + assertEquals(sectionValue, value, "value different in named section"); } } diff --git a/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java b/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java index 28921bba868..cad0048f098 100644 --- a/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java +++ b/test/jdk/java/util/jar/Manifest/ValueUtf8Coding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +21,6 @@ * questions. */ -import static java.nio.charset.StandardCharsets.UTF_8; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -32,13 +30,15 @@ import java.util.jar.Manifest; import java.util.List; import java.util.ArrayList; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; /** * @test * @bug 8066619 8351567 - * @run testng ValueUtf8Coding + * @run junit ValueUtf8Coding * @summary Tests encoding and decoding manifest header values to and from * UTF-8 with the complete Unicode character set. */ /* @@ -187,11 +187,11 @@ public class ValueUtf8Coding { String value = values.get(i); Name name = azName(i); - assertEquals(mf.getMainAttributes().getValue(name), value, + assertEquals(value, mf.getMainAttributes().getValue(name), "main attributes header value"); Attributes attributes = mf.getAttributes(value); assertNotNull(attributes, "named section"); - assertEquals(attributes.getValue(name), value, + assertEquals(value, attributes.getValue(name), "named section attributes value"); } } diff --git a/test/jdk/java/util/jar/Manifest/WriteBinaryStructure.java b/test/jdk/java/util/jar/Manifest/WriteBinaryStructure.java index 379de6b1adb..f91b518aa6c 100644 --- a/test/jdk/java/util/jar/Manifest/WriteBinaryStructure.java +++ b/test/jdk/java/util/jar/Manifest/WriteBinaryStructure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,22 +21,22 @@ * questions. */ -import static java.nio.charset.StandardCharsets.UTF_8; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.util.jar.Manifest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; -/** +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; + +/* * @test * @bug 8066619 - * @run testng WriteBinaryStructure * @summary Tests that jar manifests are written in a particular structure + * @run junit WriteBinaryStructure */ public class WriteBinaryStructure { @@ -47,10 +47,11 @@ public class WriteBinaryStructure { mf.getMainAttributes().put(new Name("Key"), "Value"); ByteArrayOutputStream buf = new ByteArrayOutputStream(); mf.write(buf); - assertEquals(buf.toByteArray(), ( + assertArrayEquals(( "Manifest-Version: 1.0\r\n" + "Key: Value\r\n" + - "\r\n").getBytes(UTF_8)); + "\r\n").getBytes(UTF_8), + buf.toByteArray()); } @Test @@ -62,12 +63,12 @@ public class WriteBinaryStructure { attributes.put(new Name("Key"), "Value"); ByteArrayOutputStream buf = new ByteArrayOutputStream(); mf.write(buf); - assertEquals(buf.toByteArray(), ( + assertArrayEquals(( "Manifest-Version: 1.0\r\n" + "\r\n" + "Name: Individual-Section-Name\r\n" + "Key: Value\r\n" + - "\r\n").getBytes(UTF_8)); + "\r\n").getBytes(UTF_8), + buf.toByteArray()); } - } diff --git a/test/jdk/java/util/jar/TestExtra.java b/test/jdk/java/util/jar/TestExtra.java index fa6408ba570..776b5e67d14 100644 --- a/test/jdk/java/util/jar/TestExtra.java +++ b/test/jdk/java/util/jar/TestExtra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2026, 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,180 +21,84 @@ * questions. */ -/** +/* * @test * @bug 6480504 6303183 * @summary Test that client-provided data in the extra field is written and * read correctly, taking into account the JAR_MAGIC written into the extra - * field of the first entry of JAR files. - * @author Dave Bristor + * field of the first entry of JAR files. ZIP file specific. + * @run junit TestExtra */ +import org.junit.jupiter.api.Test; + import java.io.*; import java.nio.charset.Charset; -import java.util.Arrays; +import java.nio.charset.StandardCharsets; import java.util.jar.*; import java.util.zip.*; -/** - * Tests that the get/set operations on extra data in zip and jar files work - * as advertised. The base class tests ZIP files, the member class - * TestJarExtra checks JAR files. - */ -public class TestExtra { - static final int JAR_MAGIC = 0xcafe; // private IN JarOutputStream.java - static final int TEST_HEADER = 0xbabe; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; - static final Charset ascii = Charset.forName("ASCII"); +// Tests that the get/set operations on extra data in ZIP files work as advertised. +public class TestExtra { + + static final int TEST_HEADER = 0xbabe; + static final Charset ascii = StandardCharsets.US_ASCII; // ZipEntry extra data static final byte[][] extra = new byte[][] { - ascii.encode("hello, world").array(), - ascii.encode("foo bar").array() + ascii.encode("hello, world").array(), + ascii.encode("foo bar").array() }; - // For naming entries in JAR/ZIP streams - int count = 1; + // For naming entries in ZIP streams + static int count = 1; // Use byte arrays instead of files - ByteArrayOutputStream baos; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - // JAR/ZIP content written here. - ZipOutputStream zos; + // ZIP content written here. + ZipOutputStream zos = assertDoesNotThrow(() -> getOutputStream(baos)); - public static void realMain(String[] args) throws Throwable{ - new TestExtra().testHeaderPlusData(); - - new TestJarExtra().testHeaderPlusData(); - new TestJarExtra().testHeaderOnly(); - new TestJarExtra().testClientJarMagic(); - } - - TestExtra() { - try { - baos = new ByteArrayOutputStream(); - zos = getOutputStream(baos); - } catch (Throwable t) { - unexpected(t); - } - } - - /** Test that a header + data set by client works. */ + // Test that a header + data set by client works. + @Test void testHeaderPlusData() throws IOException { for (byte[] b : extra) { ZipEntry ze = getEntry(); byte[] data = new byte[b.length + 4]; set16(data, 0, TEST_HEADER); set16(data, 2, b.length); - for (int i = 0; i < b.length; i++) { - data[i + 4] = b[i]; - } + System.arraycopy(b, 0, data, 4, b.length); ze.setExtra(data); zos.putNextEntry(ze); } zos.close(); - ZipInputStream zis = getInputStream(); - ZipEntry ze = zis.getNextEntry(); checkEntry(ze, 0, extra[0].length); - ze = zis.getNextEntry(); checkEntry(ze, 1, extra[1].length); } - /** Test that a header only (i.e., no extra "data") set by client works. */ - void testHeaderOnly() throws IOException { - ZipEntry ze = getEntry(); - byte[] data = new byte[4]; - set16(data, 0, TEST_HEADER); - set16(data, 2, 0); // Length of data is 0. - ze.setExtra(data); - zos.putNextEntry(ze); - - zos.close(); - - ZipInputStream zis = getInputStream(); - - ze = zis.getNextEntry(); - checkExtra(data, ze.getExtra()); - checkEntry(ze, 0, 0); - } - - /** Tests the client providing extra data which uses JAR_MAGIC header. */ - void testClientJarMagic() throws IOException { - ZipEntry ze = getEntry(); - byte[] data = new byte[8]; - - set16(data, 0, TEST_HEADER); - set16(data, 2, 0); // Length of data is 0. - set16(data, 4, JAR_MAGIC); - set16(data, 6, 0); // Length of data is 0. - - ze.setExtra(data); - zos.putNextEntry(ze); - - zos.close(); - - ZipInputStream zis = getInputStream(); - ze = zis.getNextEntry(); - byte[] e = ze.getExtra(); - checkExtra(data, ze.getExtra()); - checkEntry(ze, 0, 0); - } - - // check if all "expected" extra fields equal to their - // corresponding fields in "extra". The "extra" might have - // timestamp fields added by ZOS. - static void checkExtra(byte[] expected, byte[] extra) { - if (expected == null) - return; - int off = 0; - int len = expected.length; - while (off + 4 < len) { - int tag = get16(expected, off); - int sz = get16(expected, off + 2); - int off0 = 0; - int len0 = extra.length; - boolean matched = false; - while (off0 + 4 < len0) { - int tag0 = get16(extra, off0); - int sz0 = get16(extra, off0 + 2); - if (tag == tag0 && sz == sz0) { - matched = true; - for (int i = 0; i < sz; i++) { - if (expected[off + i] != extra[off0 +i]) - matched = false; - } - break; - } - off0 += (4 + sz0); - } - if (!matched) { - fail("Expected extra data [tag=" + tag + "sz=" + sz + "] check failed"); - } - off += (4 + sz); - } - } - - /** Check that the entry's extra data is correct. */ + // Check that the entry's extra data is correct. void checkEntry(ZipEntry ze, int count, int dataLength) { byte[] extraData = ze.getExtra(); byte[] data = getField(TEST_HEADER, extraData); - if (!check(data != null, "unexpected null data for TEST_HEADER")) { - return; - } - + assertNotNull(data, "unexpected null data for TEST_HEADER"); if (dataLength == 0) { - check(data.length == 0, "unexpected non-zero data length for TEST_HEADER"); + assertEquals(0, data.length, "unexpected non-zero data length for TEST_HEADER"); } else { - check(Arrays.equals(extra[count], data), - "failed to get entry " + ze.getName() - + ", expected " + new String(extra[count]) + ", got '" + new String(data) + "'"); + assertArrayEquals(data, extra[count], + "failed to get entry " + ze.getName() + + ", expected " + new String(extra[count]) + ", got '" + new String(data) + "'"); } } - /** Look up descriptor in data, returning corresponding byte[]. */ + // Look up descriptor in data, returning corresponding byte[]. static byte[] getField(int descriptor, byte[] data) { byte[] rc = null; try { @@ -218,69 +122,23 @@ public class TestExtra { ZipInputStream getInputStream() { return new ZipInputStream( - new ByteArrayInputStream(baos.toByteArray())); + new ByteArrayInputStream(baos.toByteArray())); } - ZipOutputStream getOutputStream(ByteArrayOutputStream baos) throws IOException { + ZipOutputStream getOutputStream(ByteArrayOutputStream baos) { return new ZipOutputStream(baos); } - ZipInputStream getInputStream(ByteArrayInputStream bais) throws IOException { - return new ZipInputStream(bais); + ZipEntry getEntry() { + return new ZipEntry("zip" + count++ + ".txt"); } - ZipEntry getEntry() { return new ZipEntry("zip" + count++ + ".txt"); } - - - private static int get16(byte[] b, int off) { - return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8); + static int get16(byte[] b, int off) { + return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8); } - private static void set16(byte[] b, int off, int value) { - b[off+0] = (byte)value; - b[off+1] = (byte)(value >> 8); + static void set16(byte[] b, int off, int value) { + b[off + 0] = (byte) value; + b[off + 1] = (byte) (value >> 8); } - - /** Test extra field of a JAR file. */ - static class TestJarExtra extends TestExtra { - ZipOutputStream getOutputStream(ByteArrayOutputStream baos) throws IOException { - return new JarOutputStream(baos); - } - - ZipInputStream getInputStream(ByteArrayInputStream bais) throws IOException { - return new JarInputStream(bais); - } - - ZipEntry getEntry() { return new ZipEntry("jar" + count++ + ".txt"); } - - void checkEntry(ZipEntry ze, int count, int dataLength) { - // zeroth entry should have JAR_MAGIC - if (count == 0) { - byte[] extraData = ze.getExtra(); - byte[] data = getField(JAR_MAGIC, extraData); - if (!check(data != null, "unexpected null data for JAR_MAGIC")) { - check(data.length != 0, "unexpected non-zero data length for JAR_MAGIC"); - } - } - // In a jar file, the first ZipEntry should have both JAR_MAGIC - // and the TEST_HEADER, so check that also. - super.checkEntry(ze, count, dataLength); - } - } - - //--------------------- Infrastructure --------------------------- - static volatile int passed = 0, failed = 0; - static void pass() {passed++;} - static void fail() {failed++; Thread.dumpStack();} - static void fail(String msg) {System.out.println(msg); fail();} - static void unexpected(Throwable t) {failed++; t.printStackTrace();} - static void check(boolean cond) {if (cond) pass(); else fail();} - static boolean check(boolean cond, String msg) {if (cond) pass(); else fail(msg); return cond; } - static void equal(Object x, Object y) { - if (x == null ? y == null : x.equals(y)) pass(); - else fail(x + " not equal to " + y);} - public static void main(String[] args) throws Throwable { - try {realMain(args);} catch (Throwable t) {unexpected(t);} - System.out.println("\nPassed = " + passed + " failed = " + failed); - if (failed > 0) throw new Error("Some tests failed");} } diff --git a/test/jdk/java/util/jar/TestJarExtra.java b/test/jdk/java/util/jar/TestJarExtra.java new file mode 100644 index 00000000000..6619727bfe8 --- /dev/null +++ b/test/jdk/java/util/jar/TestJarExtra.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2026, 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 6480504 6303183 + * @summary Test that client-provided data in the extra field is written and + * read correctly, taking into account the JAR_MAGIC written into the extra + * field of the first entry of JAR files. Jar file specific. + * @run junit TestJarExtra + */ + +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +// Tests that the get/set operations on extra data in JAR files work as advertised. +public class TestJarExtra { + + static final int JAR_MAGIC = 0xcafe; // private IN JarOutputStream.java + static final int TEST_HEADER = 0xbabe; + // For naming entries in JAR streams + static int count = 1; + static final Charset ascii = StandardCharsets.US_ASCII; + // ZipEntry extra data + static final byte[][] extra = new byte[][] { + ascii.encode("hello, world").array(), + ascii.encode("foo bar").array() + }; + + // Use byte arrays instead of files + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + // JAR content written here. + JarOutputStream jos = assertDoesNotThrow(() -> getOutputStream(baos)); + + // Test that a header + data set by client works. + @Test + void testHeaderPlusData() throws IOException { + for (byte[] b : extra) { + ZipEntry ze = getEntry(); + byte[] data = new byte[b.length + 4]; + set16(data, 0, TEST_HEADER); + set16(data, 2, b.length); + System.arraycopy(b, 0, data, 4, b.length); + ze.setExtra(data); + jos.putNextEntry(ze); + } + jos.close(); + ZipInputStream zis = getInputStream(); + ZipEntry ze = zis.getNextEntry(); + checkEntry(ze, 0, extra[0].length); + ze = zis.getNextEntry(); + checkEntry(ze, 1, extra[1].length); + } + + // Test that a header only (i.e., no extra "data") set by client works. + @Test + void testHeaderOnly() throws IOException { + ZipEntry ze = getEntry(); + byte[] data = new byte[4]; + set16(data, 0, TEST_HEADER); + set16(data, 2, 0); // Length of data is 0. + ze.setExtra(data); + jos.putNextEntry(ze); + jos.close(); + ZipInputStream zis = getInputStream(); + ze = zis.getNextEntry(); + checkExtra(data, ze.getExtra()); + checkEntry(ze, 0, 0); + } + + // Tests the client providing extra data which uses JAR_MAGIC header. + @Test + void testClientJarMagic() throws IOException { + ZipEntry ze = getEntry(); + byte[] data = new byte[8]; + set16(data, 0, TEST_HEADER); + set16(data, 2, 0); // Length of data is 0. + set16(data, 4, JAR_MAGIC); + set16(data, 6, 0); // Length of data is 0. + ze.setExtra(data); + jos.putNextEntry(ze); + jos.close(); + ZipInputStream zis = getInputStream(); + ze = zis.getNextEntry(); + byte[] e = ze.getExtra(); + checkExtra(data, ze.getExtra()); + checkEntry(ze, 0, 0); + } + + JarOutputStream getOutputStream(ByteArrayOutputStream baos) throws IOException { + return new JarOutputStream(baos); + } + + ZipInputStream getInputStream() { + return new ZipInputStream( + new ByteArrayInputStream(baos.toByteArray())); + } + + ZipEntry getEntry() { + return new ZipEntry("jar" + count++ + ".txt"); + } + + // check if all "expected" extra fields equal to their + // corresponding fields in "extra". The "extra" might have + // timestamp fields added by ZOS. + static void checkExtra(byte[] expected, byte[] extra) { + if (expected == null) + return; + int off = 0; + int len = expected.length; + while (off + 4 < len) { + int tag = get16(expected, off); + int sz = get16(expected, off + 2); + int off0 = 0; + int len0 = extra.length; + boolean matched = false; + while (off0 + 4 < len0) { + int tag0 = get16(extra, off0); + int sz0 = get16(extra, off0 + 2); + if (tag == tag0 && sz == sz0) { + matched = true; + for (int i = 0; i < sz; i++) { + if (expected[off + i] != extra[off0 + i]) + matched = false; + } + break; + } + off0 += (4 + sz0); + } + if (!matched) { + fail("Expected extra data [tag=" + tag + "sz=" + sz + "] check failed"); + } + off += (4 + sz); + } + } + + void checkEntry(ZipEntry ze, int count, int dataLength) { + // zeroth entry should have JAR_MAGIC + if (count == 0) { + byte[] extraData = ze.getExtra(); + byte[] data = getField(JAR_MAGIC, extraData); + assertNotNull(data, "unexpected null data for JAR_MAGIC"); + assertEquals(0, data.length, "unexpected non-zero data length for JAR_MAGIC"); + } + // In a JAR file, the first ZipEntry should have both JAR_MAGIC + // and the TEST_HEADER, so check that also. + byte[] extraData = ze.getExtra(); + byte[] data = getField(TEST_HEADER, extraData); + assertNotNull(data, "unexpected null data for TEST_HEADER"); + if (dataLength == 0) { + assertEquals(0, data.length, "unexpected non-zero data length for TEST_HEADER"); + } else { + assertArrayEquals(data, extra[count], + "failed to get entry " + ze.getName() + + ", expected " + new String(extra[count]) + ", got '" + new String(data) + "'"); + } + } + + // Look up descriptor in data, returning corresponding byte[]. + static byte[] getField(int descriptor, byte[] data) { + byte[] rc = null; + try { + int i = 0; + while (i < data.length) { + if (get16(data, i) == descriptor) { + int length = get16(data, i + 2); + rc = new byte[length]; + for (int j = 0; j < length; j++) { + rc[j] = data[i + 4 + j]; + } + return rc; + } + i += get16(data, i + 2) + 4; + } + } catch (ArrayIndexOutOfBoundsException e) { + // descriptor not found + } + return rc; + } + + static int get16(byte[] b, int off) { + return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8); + } + + static void set16(byte[] b, int off, int value) { + b[off + 0] = (byte) value; + b[off + 1] = (byte) (value >> 8); + } +} diff --git a/test/jdk/java/util/logging/ParentLoggersTest.java b/test/jdk/java/util/logging/ParentLoggersTest.java index 8aae7e95d74..55a93249ca8 100644 --- a/test/jdk/java/util/logging/ParentLoggersTest.java +++ b/test/jdk/java/util/logging/ParentLoggersTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6498300 8377457 + * @bug 6498300 8377457 8379548 * * @summary regression: parent loggers are not properly registered * @author ss45998 diff --git a/test/jdk/java/util/prefs/PrefsSpiTest.java b/test/jdk/java/util/prefs/PrefsSpiTest.java index 0369c60cae2..08fff81a552 100644 --- a/test/jdk/java/util/prefs/PrefsSpiTest.java +++ b/test/jdk/java/util/prefs/PrefsSpiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +28,7 @@ * @library /test/lib * @build jdk.test.lib.util.JarUtils jdk.test.lib.process.* * PrefsSpi StubPreferencesFactory StubPreferences - * @run testng PrefsSpiTest + * @run junit PrefsSpiTest */ import java.io.File; @@ -36,16 +36,13 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.nio.file.StandardOpenOption.CREATE; import static java.util.Arrays.asList; @@ -53,14 +50,19 @@ import static java.util.Arrays.asList; import static jdk.test.lib.Utils.TEST_CLASSES; import static jdk.test.lib.Utils.TEST_CLASS_PATH; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + public class PrefsSpiTest { private static final Path SPIJAR = Path.of("extDir", "PrefsSpi.jar"); private static final String SPIJAR_CP = TEST_CLASS_PATH + File.pathSeparator + SPIJAR.toString(); - @BeforeClass - public void initialize() throws Exception { + @BeforeAll + public static void initialize() throws Exception { Path xdir = Path.of("jarDir"); Path config = xdir.resolve("META-INF/services/java.util.prefs.PreferencesFactory"); @@ -77,19 +79,18 @@ public class PrefsSpiTest { JarUtils.createJarFile(SPIJAR, xdir); } - @DataProvider - public Object[][] testCases() { - return new Object[][]{ - // CLI options, runtime arguments - {List.of("-cp", SPIJAR_CP, - "-Djava.util.prefs.PreferencesFactory=StubPreferencesFactory"), - "StubPreferences"}, - {List.of("-cp", TEST_CLASS_PATH), "java.util.prefs.*"}, - {List.of("-cp", SPIJAR_CP), "StubPreferences"} - }; + public static Stream testCases() { + return Stream.of + (// CLI options, runtime arguments + Arguments.of(List.of("-cp", SPIJAR_CP, + "-Djava.util.prefs.PreferencesFactory=StubPreferencesFactory"), + "StubPreferences"), + Arguments.of(List.of("-cp", TEST_CLASS_PATH), "java.util.prefs.*"), + Arguments.of(List.of("-cp", SPIJAR_CP), "StubPreferences")); } - @Test(dataProvider = "testCases") + @ParameterizedTest + @MethodSource("testCases") public void testProvider(List opts, String pattern) throws Throwable { List args = new ArrayList<>(); args.add(JDKToolFinder.getJDKTool("java")); diff --git a/test/jdk/java/util/zip/InflaterOutputStreamTest.java b/test/jdk/java/util/zip/InflaterOutputStreamTest.java new file mode 100644 index 00000000000..3f588d95c0c --- /dev/null +++ b/test/jdk/java/util/zip/InflaterOutputStreamTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2026, 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.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.Deflater; +import java.util.zip.Inflater; +import java.util.zip.InflaterOutputStream; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static java.nio.charset.StandardCharsets.US_ASCII; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + +/* + * @test + * @bug 8369181 + * @summary Verify the behaviour of basic operations on InflaterOutputStream + * @run junit ${test.main.class} + */ +class InflaterOutputStreamTest { + + private static final byte[] INPUT_CONTENT = "hello world".getBytes(US_ASCII); + private static byte[] COMPRESSED_CONTENT; + + @BeforeAll + static void beforeAll() throws Exception { + // created the compressed content + final ByteArrayOutputStream compressedBaos = new ByteArrayOutputStream(); + try (Deflater compressor = new Deflater()) { + compressor.setInput(INPUT_CONTENT); + compressor.finish(); + while (!compressor.finished()) { + final byte[] tmpBuffer = new byte[100]; + final int numCompressed = compressor.deflate(tmpBuffer); + compressedBaos.write(tmpBuffer, 0, numCompressed); + } + } + COMPRESSED_CONTENT = compressedBaos.toByteArray(); + } + + static List inflaterOutputStreams() { + final List args = new ArrayList<>(); + args.add(Arguments.of(new InflaterOutputStream(new ByteArrayOutputStream()))); + args.add(Arguments.of(new InflaterOutputStream(new ByteArrayOutputStream(), + new Inflater()))); + args.add(Arguments.of(new InflaterOutputStream(new ByteArrayOutputStream(), + new Inflater(), 1024))); + return args; + } + + /* + * Verify that write() methods throw an IOException when the InflaterOutputStream + * is already closed. + */ + @ParameterizedTest + @MethodSource("inflaterOutputStreams") + void testWriteAfterClose(final InflaterOutputStream ios) throws Exception { + ios.close(); + IOException ioe = assertThrows(IOException.class, () -> ios.write(COMPRESSED_CONTENT)); + // verify it failed for right reason + assertStreamClosedIOE(ioe); + } + + /* + * Verify that flush() throws an IOException when the InflaterOutputStream + * is already closed + */ + @ParameterizedTest + @MethodSource("inflaterOutputStreams") + void testFlushAfterClose(final InflaterOutputStream ios) throws Exception { + ios.close(); + final IOException ioe = assertThrows(IOException.class, ios::flush); + // verify it failed for right reason + assertStreamClosedIOE(ioe); + } + + /* + * Verify that finish() throws an IOException when the InflaterOutputStream + * is already closed. + */ + @ParameterizedTest + @MethodSource("inflaterOutputStreams") + void testFinishAfterClose(final InflaterOutputStream ios) throws Exception { + ios.close(); + final IOException ioe = assertThrows(IOException.class, ios::finish); + // verify it failed for right reason + assertStreamClosedIOE(ioe); + } + + /* + * Verify that after finish() is called on an InflaterOutputStream that was constructed + * without specifying a Inflater, any subsequent writes will throw an IOException. + */ + @Test + void testWriteAfterFinish() throws IOException { + // InflaterOutputStream that constructs an internal default Inflater + final InflaterOutputStream ios = new InflaterOutputStream(new ByteArrayOutputStream()); + ios.finish(); + final IOException ioe = assertThrows(IOException.class, () -> ios.write(COMPRESSED_CONTENT)); + final String msg = ioe.getMessage(); + // verify that it's the right IOException + if (msg == null || !msg.contains("Inflater closed")) { + // propagate the original exception + fail("unexpected exception message in IOException", ioe); + } + + // repeat with a InflaterOutputStream that is passed a Inflater + try (Inflater intf = new Inflater(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + InflaterOutputStream stream = new InflaterOutputStream(baos, intf)) { + + stream.finish(); + // not expected to throw any exception + stream.write(COMPRESSED_CONTENT); + stream.flush(); + // verify the decompressed content is as expected + final byte[] decompressed = baos.toByteArray(); + assertArrayEquals(INPUT_CONTENT, decompressed, "unexpected decompressed content"); + } + } + + private void assertStreamClosedIOE(final IOException ioe) { + final String msg = ioe.getMessage(); + if (msg == null || !msg.contains("Stream closed")) { + // propagate the original exception + fail("unexpected exception message in IOException", ioe); + } + } +} diff --git a/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java b/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java index 7adcfb9c128..7ca71c9890a 100644 --- a/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java +++ b/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,33 +25,26 @@ * @bug 8272746 * @modules java.base/jdk.internal.util * @summary Verify that ZipFile rejects files with CEN sizes exceeding the implementation limit + * @library /test/lib + * @build jdk.test.lib.util.ZipUtils * @run junit/othervm EndOfCenValidation */ import jdk.internal.util.ArraysSupport; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import java.io.*; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.channels.FileChannel; -import java.nio.charset.StandardCharsets; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.HexFormat; -import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; -import java.util.zip.ZipOutputStream; -import static org.junit.jupiter.api.Assertions.*; +import static jdk.test.lib.util.ZipUtils.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * This test augments {@link TestTooManyEntries}. It creates sparse ZIPs where @@ -65,36 +58,13 @@ import static org.junit.jupiter.api.Assertions.*; public class EndOfCenValidation { // Zip files produced by this test - public static final Path CEN_TOO_LARGE_ZIP = Path.of("cen-size-too-large.zip"); - public static final Path INVALID_CEN_SIZE = Path.of("invalid-zen-size.zip"); - public static final Path BAD_CEN_OFFSET_ZIP = Path.of("bad-cen-offset.zip"); - // Some ZipFile constants for manipulating the 'End of central directory record' (END header) - private static final int ENDHDR = ZipFile.ENDHDR; // End of central directory record size - private static final int ENDSIZ = ZipFile.ENDSIZ; // Offset of CEN size field within ENDHDR - private static final int ENDOFF = ZipFile.ENDOFF; // Offset of CEN offset field within ENDHDR + static final Path CEN_TOO_LARGE_ZIP = Path.of("cen-size-too-large.zip"); + static final Path INVALID_CEN_SIZE = Path.of("invalid-zen-size.zip"); + static final Path BAD_CEN_OFFSET_ZIP = Path.of("bad-cen-offset.zip"); + static final Path BAD_ENTRY_COUNT_ZIP = Path.of("bad-entry-count.zip"); + // Maximum allowed CEN size allowed by ZipFile - private static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; - - // Expected message when CEN size does not match file size - private static final String INVALID_CEN_BAD_SIZE = "invalid END header (bad central directory size)"; - // Expected message when CEN offset is too large - private static final String INVALID_CEN_BAD_OFFSET = "invalid END header (bad central directory offset)"; - // Expected message when CEN size is too large - private static final String INVALID_CEN_SIZE_TOO_LARGE = "invalid END header (central directory size too large)"; - // Expected message when total entry count is too large - private static final String INVALID_BAD_ENTRY_COUNT = "invalid END header (total entries count too large)"; - - // A valid ZIP file, used as a template - private byte[] zipBytes; - - /** - * Create a valid ZIP file, used as a template - * @throws IOException if an error occurs - */ - @BeforeEach - public void setup() throws IOException { - zipBytes = templateZip(); - } + static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * Delete big files after test, in case the file system did not support sparse files. @@ -105,6 +75,7 @@ public class EndOfCenValidation { Files.deleteIfExists(CEN_TOO_LARGE_ZIP); Files.deleteIfExists(INVALID_CEN_SIZE); Files.deleteIfExists(BAD_CEN_OFFSET_ZIP); + Files.deleteIfExists(BAD_ENTRY_COUNT_ZIP); } /** @@ -115,14 +86,8 @@ public class EndOfCenValidation { @Test public void shouldRejectTooLargeCenSize() throws IOException { int size = MAX_CEN_SIZE + 1; - Path zip = zipWithModifiedEndRecord(size, true, 0, CEN_TOO_LARGE_ZIP); - - ZipException ex = assertThrows(ZipException.class, () -> { - new ZipFile(zip.toFile()); - }); - - assertEquals(INVALID_CEN_SIZE_TOO_LARGE, ex.getMessage()); + verifyRejection(zip, INVALID_CEN_SIZE_TOO_LARGE); } /** @@ -133,16 +98,9 @@ public class EndOfCenValidation { */ @Test public void shouldRejectInvalidCenSize() throws IOException { - int size = MAX_CEN_SIZE; - Path zip = zipWithModifiedEndRecord(size, false, 0, INVALID_CEN_SIZE); - - ZipException ex = assertThrows(ZipException.class, () -> { - new ZipFile(zip.toFile()); - }); - - assertEquals(INVALID_CEN_BAD_SIZE, ex.getMessage()); + verifyRejection(zip, INVALID_CEN_BAD_SIZE); } /** @@ -153,16 +111,9 @@ public class EndOfCenValidation { */ @Test public void shouldRejectInvalidCenOffset() throws IOException { - int size = MAX_CEN_SIZE; - Path zip = zipWithModifiedEndRecord(size, true, 100, BAD_CEN_OFFSET_ZIP); - - ZipException ex = assertThrows(ZipException.class, () -> { - new ZipFile(zip.toFile()); - }); - - assertEquals(INVALID_CEN_BAD_OFFSET, ex.getMessage()); + verifyRejection(zip, INVALID_CEN_BAD_OFFSET); } /** @@ -181,192 +132,20 @@ public class EndOfCenValidation { Long.MAX_VALUE // Unreasonably large }) public void shouldRejectBadTotalEntries(long totalEntries) throws IOException { - /** - * A small ZIP using the ZIP64 format. - * - * ZIP created using: "echo -n hello | zip zip64.zip -" - * Hex encoded using: "cat zip64.zip | xxd -ps" - * - * The file has the following structure: - * - * 0000 LOCAL HEADER #1 04034B50 - * 0004 Extract Zip Spec 2D '4.5' - * 0005 Extract OS 00 'MS-DOS' - * 0006 General Purpose Flag 0000 - * 0008 Compression Method 0000 'Stored' - * 000A Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' - * 000E CRC 363A3020 - * 0012 Compressed Length FFFFFFFF - * 0016 Uncompressed Length FFFFFFFF - * 001A Filename Length 0001 - * 001C Extra Length 0014 - * 001E Filename '-' - * 001F Extra ID #0001 0001 'ZIP64' - * 0021 Length 0010 - * 0023 Uncompressed Size 0000000000000006 - * 002B Compressed Size 0000000000000006 - * 0033 PAYLOAD hello. - * - * 0039 CENTRAL HEADER #1 02014B50 - * 003D Created Zip Spec 1E '3.0' - * 003E Created OS 03 'Unix' - * 003F Extract Zip Spec 2D '4.5' - * 0040 Extract OS 00 'MS-DOS' - * 0041 General Purpose Flag 0000 - * 0043 Compression Method 0000 'Stored' - * 0045 Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' - * 0049 CRC 363A3020 - * 004D Compressed Length 00000006 - * 0051 Uncompressed Length FFFFFFFF - * 0055 Filename Length 0001 - * 0057 Extra Length 000C - * 0059 Comment Length 0000 - * 005B Disk Start 0000 - * 005D Int File Attributes 0001 - * [Bit 0] 1 Text Data - * 005F Ext File Attributes 11B00000 - * 0063 Local Header Offset 00000000 - * 0067 Filename '-' - * 0068 Extra ID #0001 0001 'ZIP64' - * 006A Length 0008 - * 006C Uncompressed Size 0000000000000006 - * - * 0074 ZIP64 END CENTRAL DIR 06064B50 - * RECORD - * 0078 Size of record 000000000000002C - * 0080 Created Zip Spec 1E '3.0' - * 0081 Created OS 03 'Unix' - * 0082 Extract Zip Spec 2D '4.5' - * 0083 Extract OS 00 'MS-DOS' - * 0084 Number of this disk 00000000 - * 0088 Central Dir Disk no 00000000 - * 008C Entries in this disk 0000000000000001 - * 0094 Total Entries 0000000000000001 - * 009C Size of Central Dir 000000000000003B - * 00A4 Offset to Central dir 0000000000000039 - * - * 00AC ZIP64 END CENTRAL DIR 07064B50 - * LOCATOR - * 00B0 Central Dir Disk no 00000000 - * 00B4 Offset to Central dir 0000000000000074 - * 00BC Total no of Disks 00000001 - * - * 00C0 END CENTRAL HEADER 06054B50 - * 00C4 Number of this disk 0000 - * 00C6 Central Dir Disk no 0000 - * 00C8 Entries in this disk 0001 - * 00CA Total Entries 0001 - * 00CC Size of Central Dir 0000003B - * 00D0 Offset to Central Dir FFFFFFFF - * 00D4 Comment Length 0000 - */ + Path zip = zip64WithModifiedTotalEntries(BAD_ENTRY_COUNT_ZIP, totalEntries); + verifyRejection(zip, INVALID_BAD_ENTRY_COUNT); + } - byte[] zipBytes = HexFormat.of().parseHex(""" - 504b03042d000000000078ab475920303a36ffffffffffffffff01001400 - 2d010010000600000000000000060000000000000068656c6c6f0a504b01 - 021e032d000000000078ab475920303a3606000000ffffffff01000c0000 - 00000001000000b011000000002d010008000600000000000000504b0606 - 2c000000000000001e032d00000000000000000001000000000000000100 - 0000000000003b000000000000003900000000000000504b060700000000 - 740000000000000001000000504b050600000000010001003b000000ffff - ffff0000 - """.replaceAll("\n","")); - - // Buffer to manipulate the above ZIP - ByteBuffer buf = ByteBuffer.wrap(zipBytes).order(ByteOrder.LITTLE_ENDIAN); - // Offset of the 'total entries' in the 'ZIP64 END CENTRAL DIR' record - // Update ZIP64 entry count to a value which cannot possibly fit in the small CEN - buf.putLong(0x94, totalEntries); - // The corresponding END field needs the ZIP64 magic value - buf.putShort(0xCA, (short) 0xFFFF); - // Write the ZIP to disk - Path zipFile = Path.of("bad-entry-count.zip"); - Files.write(zipFile, zipBytes); - - // Verify that the END header is rejected + /** + * Verify that ZipFile rejects the ZIP file with a ZipException + * with the given message + * @param zip ZIP file to open + * @param msg exception message to expect + */ + private static void verifyRejection(Path zip, String msg) { ZipException ex = assertThrows(ZipException.class, () -> { - try (var zf = new ZipFile(zipFile.toFile())) { - } + new ZipFile(zip.toFile()); }); - - assertEquals(INVALID_BAD_ENTRY_COUNT, ex.getMessage()); - } - - /** - * Create an ZIP file with a single entry, then modify the CEN size - * in the 'End of central directory record' (END header) to the given size. - * - * The CEN is optionally "inflated" with trailing zero bytes such that - * its actual size matches the one stated in the END header. - * - * The CEN offset is optiontially adjusted by the given amount - * - * The resulting ZIP is technically not valid, but it does allow us - * to test that large or invalid CEN sizes are rejected - * @param cenSize the CEN size to put in the END record - * @param inflateCen if true, zero-pad the CEN to the desired size - * @param cenOffAdjust Adjust the CEN offset field of the END record with this amount - * @throws IOException if an error occurs - */ - private Path zipWithModifiedEndRecord(int cenSize, - boolean inflateCen, - int cenOffAdjust, - Path zip) throws IOException { - - // A byte buffer for reading the END - ByteBuffer buffer = ByteBuffer.wrap(zipBytes.clone()).order(ByteOrder.LITTLE_ENDIAN); - - // Offset of the END header - int endOffset = buffer.limit() - ENDHDR; - - // Modify the CEN size - int sizeOffset = endOffset + ENDSIZ; - int currentCenSize = buffer.getInt(sizeOffset); - buffer.putInt(sizeOffset, cenSize); - - // Optionally modify the CEN offset - if (cenOffAdjust != 0) { - int offOffset = endOffset + ENDOFF; - int currentCenOff = buffer.getInt(offOffset); - buffer.putInt(offOffset, currentCenOff + cenOffAdjust); - } - - // When creating a sparse file, the file must not already exit - Files.deleteIfExists(zip); - - // Open a FileChannel for writing a sparse file - EnumSet options = EnumSet.of(StandardOpenOption.CREATE_NEW, - StandardOpenOption.WRITE, - StandardOpenOption.SPARSE); - - try (FileChannel channel = FileChannel.open(zip, options)) { - - // Write everything up to END - channel.write(buffer.slice(0, buffer.limit() - ENDHDR)); - - if (inflateCen) { - // Inject "empty bytes" to make the actual CEN size match the END - int injectBytes = cenSize - currentCenSize; - channel.position(channel.position() + injectBytes); - } - // Write the modified END - channel.write(buffer.slice(buffer.limit() - ENDHDR, ENDHDR)); - } - return zip; - } - - /** - * Produce a byte array of a ZIP with a single entry - * - * @throws IOException if an error occurs - */ - private byte[] templateZip() throws IOException { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - try (ZipOutputStream zo = new ZipOutputStream(bout)) { - ZipEntry entry = new ZipEntry("duke.txt"); - zo.putNextEntry(entry); - zo.write("duke".getBytes(StandardCharsets.UTF_8)); - } - return bout.toByteArray(); + assertEquals(msg, ex.getMessage()); } } diff --git a/test/jdk/javax/accessibility/8377745/VoiceOverHyperlinkRole.java b/test/jdk/javax/accessibility/8377745/VoiceOverHyperlinkRole.java new file mode 100644 index 00000000000..0d18d320360 --- /dev/null +++ b/test/jdk/javax/accessibility/8377745/VoiceOverHyperlinkRole.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2026, 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 javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.border.EmptyBorder; + +/* + * @test + * @key headful + * @bug 8377745 + * @summary manual test for VoiceOver reading links correctly + * @requires os.family == "mac" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual VoiceOverHyperlinkRole + */ + +public class VoiceOverHyperlinkRole { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = "INSTRUCTIONS (Mac-only):\n" + + "1. Open VoiceOver\n" + + "2. Move the VoiceOver cursor over the link.\n" + + "3. Observe how VoiceOver identifies the link.\n\n" + + "Expected behavior: VoiceOver should identify it as a " + + "\"link\". It should not say \"text element\", \"text\" " + + "or \"hyperlink\".\n\n" + + "If you select the link using \"Accessibility " + + "Inspector\": it should identify its role as AXLink."; + + PassFailJFrame.builder() + .title("VoiceOverHyperlinkRole Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(VoiceOverHyperlinkRole::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + + p.add(createText("This button uses `AccessibleRole.HYPERLINK:`")); + p.add(createLink(AccessibleRole.HYPERLINK)); + + // for debugging / experimentation: + boolean tryOtherRoles = false; + if (tryOtherRoles) { + p.add(createText( + "This button uses `new AccessibleRole(\"Link\") {}`:")); + p.add(createLink(new AccessibleRole("Link") {})); + p.add(createText( + "This button uses `new AccessibleRole(\"link\") {}`:")); + p.add(createLink(new AccessibleRole("link") {})); + p.add(createText( + "This button uses `new AccessibleRole(\"AXLink\") {}`:")); + p.add(createLink(new AccessibleRole("AXLink") {})); + } + + JFrame frame = new JFrame(); + frame.getContentPane().add(p); + frame.pack(); + return frame; + } + + private static JTextArea createText(String text) { + JTextArea textArea = new JTextArea(text); + textArea.setOpaque(false); + textArea.setEditable(false); + textArea.setBorder(new EmptyBorder(20, 10, 3, 10)); + return textArea; + } + + private static JButton createLink(AccessibleRole role) { + String text = "https://bugs.openjdk.org/"; + JButton button = new JButton(text) { + public AccessibleContext getAccessibleContext() { + if (accessibleContext == null) { + accessibleContext = new AccessibleJButton() { + @Override + public AccessibleRole getAccessibleRole() { + return role; + } + }; + } + return accessibleContext; + } + }; + button.setContentAreaFilled(false); + button.setBorderPainted(false); + return button; + } +} diff --git a/test/jdk/javax/sound/sampled/Clip/bug5070081.java b/test/jdk/javax/sound/sampled/Clip/bug5070081.java index e7bf7e30de2..89e9d591d28 100644 --- a/test/jdk/javax/sound/sampled/Clip/bug5070081.java +++ b/test/jdk/javax/sound/sampled/Clip/bug5070081.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,8 @@ import javax.sound.sampled.LineUnavailableException; /* * @test - * @bug 5070081 + * @key sound + * @bug 5070081 8376152 * @summary Tests that javax.sound.sampled.Clip does not loses position through * stop/start */ diff --git a/test/jdk/javax/swing/JComponent/8043610/bug8043610.java b/test/jdk/javax/swing/JComponent/8043610/bug8043610.java deleted file mode 100644 index 7eb371d1a0e..00000000000 --- a/test/jdk/javax/swing/JComponent/8043610/bug8043610.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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 - * @key headful - * @bug 8043610 - * @summary Tests that JComponent invalidate, revalidate and repaint methods could - * be called from any thread - * @author Petr Pchelko - * @modules java.desktop/sun.awt - */ - -import sun.awt.SunToolkit; - -import javax.swing.*; -import java.awt.*; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicReference; - -public class bug8043610 { - private static volatile JFrame frame; - private static volatile JComponent component; - - public static void main(String[] args) throws Exception { - ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group"); - ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG"); - try { - Thread stubThread = new Thread(stubTG, SunToolkit::createNewAppContext); - stubThread.start(); - stubThread.join(); - - CountDownLatch startSwingLatch = new CountDownLatch(1); - new Thread(swingTG, () -> { - SunToolkit.createNewAppContext(); - SwingUtilities.invokeLater(() -> { - frame = new JFrame(); - component = new JLabel("Test Text"); - frame.add(component); - frame.setBounds(100, 100, 100, 100); - frame.setVisible(true); - startSwingLatch.countDown(); - }); - }).start(); - startSwingLatch.await(); - - AtomicReference caughtException = new AtomicReference<>(); - Thread checkThread = new Thread(getRootThreadGroup(), () -> { - try { - component.invalidate(); - component.revalidate(); - component.repaint(new Rectangle(0, 0, 0, 0)); - } catch (Exception e) { - caughtException.set(e); - } - }); - checkThread.start(); - checkThread.join(); - - if (caughtException.get() != null) { - throw new RuntimeException("Failed. Caught exception!", caughtException.get()); - } - } finally { - new Thread(swingTG, () -> SwingUtilities.invokeLater(() -> { - if (frame != null) { - frame.dispose(); - } - })).start(); - } - } - - private static ThreadGroup getRootThreadGroup() { - ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); - ThreadGroup parentTG = currentTG.getParent(); - while (parentTG != null) { - currentTG = parentTG; - parentTG = currentTG.getParent(); - } - return currentTG; - } -} diff --git a/test/jdk/javax/swing/JFileChooser/FileSystemView/SystemIconPixelDataTest.java b/test/jdk/javax/swing/JFileChooser/FileSystemView/SystemIconPixelDataTest.java new file mode 100644 index 00000000000..c71c7a3e6a9 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/FileSystemView/SystemIconPixelDataTest.java @@ -0,0 +1,93 @@ +/* + * Copyright Amazon.com Inc. 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.awt.EventQueue; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.swing.Icon; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.filechooser.FileSystemView; + +/** + * @test + * @bug 8376253 + * @summary FileSystemView may not report system icons when -Xcheck:jni enabled + * @key headful + * @run main SystemIconPixelDataTest + * @run main/othervm -Xcheck:jni SystemIconPixelDataTest + */ +public final class SystemIconPixelDataTest { + + public static void main(String[] args) throws Exception { + for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + AtomicBoolean ok = new AtomicBoolean(); + EventQueue.invokeAndWait(() -> ok.set(setLookAndFeel(laf))); + if (ok.get()) { + EventQueue.invokeAndWait(SystemIconPixelDataTest::test); + } + } + } + + private static boolean setLookAndFeel(LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + System.out.println("LookAndFeel: " + laf.getClassName()); + return true; + } catch (UnsupportedLookAndFeelException ignored) { + return false; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static void test() { + FileSystemView fsv = FileSystemView.getFileSystemView(); + File home = fsv.getHomeDirectory(); + Icon icon = fsv.getSystemIcon(home); + if (icon == null) { + return; + } + int w = icon.getIconWidth(); + int h = icon.getIconHeight(); + if (w <= 0 || h <= 0) { + throw new RuntimeException("Invalid icon size: " + w + "x" + h); + } + var img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = img.createGraphics(); + icon.paintIcon(null, g, 0, 0); + g.dispose(); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (img.getRGB(x, y) != 0) { + return; + } + } + } + throw new RuntimeException("All pixels are zero"); + } +} diff --git a/test/jdk/javax/swing/JInternalFrame/TestNonMaximizedNormalBounds.java b/test/jdk/javax/swing/JInternalFrame/TestNonMaximizedNormalBounds.java new file mode 100644 index 00000000000..67faeeb5bb1 --- /dev/null +++ b/test/jdk/javax/swing/JInternalFrame/TestNonMaximizedNormalBounds.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2026, 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 + * @key headful + * @bug 8267961 + * @summary Verify JInternalFrame.getNormalBounds() + * returns getBounds() value in non-maximized state + * @run main TestNonMaximizedNormalBounds + */ + +import java.awt.Rectangle; +import javax.swing.JDesktopPane; +import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; +import java.beans.PropertyVetoException; + +public class TestNonMaximizedNormalBounds { + + private static volatile Rectangle bounds; + private static volatile Rectangle normalBounds; + private static JInternalFrame jif; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + Rectangle bounds = new Rectangle(96, 97, 98, 99); + Rectangle nbounds = new Rectangle(196, 197, 198, 199); + JDesktopPane p = new JDesktopPane(); + jif = new JInternalFrame(); + p.add(jif); + jif.setBounds(bounds); + jif.setNormalBounds(nbounds); + }); + Thread.sleep(100); + SwingUtilities.invokeAndWait(() -> { + try { + jif.setMaximum(false); + } catch (PropertyVetoException e) { + throw new RuntimeException(e); + } + }); + Thread.sleep(100); + SwingUtilities.invokeAndWait(() -> { + normalBounds = jif.getNormalBounds(); + bounds = jif.getBounds(); + }); + if (!normalBounds.equals(bounds)) { + System.out.println("normalBounds " + normalBounds + " getBounds " + bounds); + throw new RuntimeException("normalBounds not equal to getBounds in non-maximized state"); + } + } +} diff --git a/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java b/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java index 8b60bf8beec..ebd563624cd 100644 --- a/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java +++ b/test/jdk/javax/swing/JTable/8236907/LastVisibleRow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @key headful @@ -59,11 +60,9 @@ public class LastVisibleRow { Point clkPoint; try { testRobot = new Robot(); - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - createAndShowGUI(); - } - }); + testRobot.setAutoWaitForIdle(true); + testRobot.setAutoDelay(30); + SwingUtilities.invokeAndWait(LastVisibleRow::createAndShowGUI); testRobot.delay(1000); testRobot.waitForIdle(); BufferedImage bufferedImageBefore = testRobot.createScreenCapture(getCaptureRect()); @@ -73,7 +72,7 @@ public class LastVisibleRow { mouseEvents(clkPoint); testRobot.waitForIdle(); clearSelect(); - testRobot.delay(1000); + resetMousePos(); testRobot.waitForIdle(); BufferedImage bufferedImageAfter = testRobot.createScreenCapture(getCaptureRect()); @@ -137,43 +136,37 @@ public class LastVisibleRow { testRobot.delay(50); } + private static void resetMousePos() { + testRobot.mouseMove(50, 50); + testRobot.delay(50); + } + // getMousePosition Actions for last row click private static Point getMousePosition() throws Exception { final Point[] clickPoint = new Point[1]; - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - clickPoint[0] = getCellClickPoint(2, 0); - } - }); + SwingUtilities.invokeAndWait((Runnable) () -> clickPoint[0] = getCellClickPoint(2, 0)); return clickPoint[0]; } // Clears the selected table row private static void clearSelect() throws Exception { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - table.getSelectionModel().clearSelection(); - table.setFocusable(false); - } + SwingUtilities.invokeAndWait((Runnable) () -> { + table.getSelectionModel().clearSelection(); + table.setFocusable(false); }); } // getCaptureRect Method - To Compute the Rectangle Area of last row private static Rectangle getCaptureRect() throws InterruptedException, InvocationTargetException { final Rectangle[] captureRect = new Rectangle[1]; - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - Rectangle cellRect = table.getCellRect(2, 0, true); - Point point = new Point(cellRect.x, cellRect.y); - SwingUtilities.convertPointToScreen(point, table); + SwingUtilities.invokeAndWait((Runnable) () -> { + Rectangle cellRect = table.getCellRect(2, 0, true); + Point point = new Point(cellRect.x, cellRect.y); + SwingUtilities.convertPointToScreen(point, table); - captureRect[0] = new Rectangle(point.x+5, point.y+2, - table.getColumnCount() * cellRect.width - 10, - cellRect.height-2); - } + captureRect[0] = new Rectangle(point.x + 5, point.y + 2, + table.getColumnCount() * cellRect.width - 10, + cellRect.height - 2); }); return captureRect[0]; } diff --git a/test/jdk/javax/swing/ToolTipManager/Test6657026.java b/test/jdk/javax/swing/ToolTipManager/Test6657026.java deleted file mode 100644 index 0678d57f768..00000000000 --- a/test/jdk/javax/swing/ToolTipManager/Test6657026.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6657026 - * @summary Tests shared ToolTipManager in different application contexts - * @author Sergey Malenkov - * @modules java.desktop/sun.awt - */ - -import sun.awt.SunToolkit; -import javax.swing.ToolTipManager; - -public class Test6657026 implements Runnable { - - private static final int DISMISS = 4000; - private static final int INITIAL = 750; - private static final int RESHOW = 500; - - public static void main(String[] args) throws InterruptedException { - ToolTipManager manager = ToolTipManager.sharedInstance(); - if (DISMISS != manager.getDismissDelay()) { - throw new Error("unexpected dismiss delay"); - } - if (INITIAL != manager.getInitialDelay()) { - throw new Error("unexpected initial delay"); - } - if (RESHOW != manager.getReshowDelay()) { - throw new Error("unexpected reshow delay"); - } - manager.setDismissDelay(DISMISS + 1); - manager.setInitialDelay(INITIAL + 1); - manager.setReshowDelay(RESHOW + 1); - - ThreadGroup group = new ThreadGroup("$$$"); - Thread thread = new Thread(group, new Test6657026()); - thread.start(); - thread.join(); - } - - public void run() { - SunToolkit.createNewAppContext(); - ToolTipManager manager = ToolTipManager.sharedInstance(); - if (DISMISS != manager.getDismissDelay()) { - throw new Error("shared dismiss delay"); - } - if (INITIAL != manager.getInitialDelay()) { - throw new Error("shared initial delay"); - } - if (RESHOW != manager.getReshowDelay()) { - throw new Error("shared reshow delay"); - } - } -} diff --git a/test/jdk/javax/swing/plaf/metal/MetalTitlePaneBug.java b/test/jdk/javax/swing/plaf/metal/MetalTitlePaneBug.java new file mode 100644 index 00000000000..dde6249752d --- /dev/null +++ b/test/jdk/javax/swing/plaf/metal/MetalTitlePaneBug.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2026, 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 8078744 + * @summary Verifies right half of system menu icon on title bar + * activates when clicked + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MetalTitlePaneBug + */ + +import javax.swing.JFrame; +import javax.swing.UIManager; + +public class MetalTitlePaneBug { + + static final String INSTRUCTIONS = """ + A Frame is shown with a titlepane. + Click on the left edge of the system menu icon on the title pane. + It should show "Restore", "Minimize", "Maximize", "Close" menu. + Click on the right edge of the system menu icon. + It should also show "Restore", "Minimize", "Maximize", "Close" menu. + If it shows, press Pass else press Fail. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(MetalTitlePaneBug::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame.setDefaultLookAndFeelDecorated(true); + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(200, 100); + return frame; + } +} diff --git a/test/jdk/javax/swing/plaf/windows/bug4991587.java b/test/jdk/javax/swing/plaf/windows/bug4991587.java index e4e4fde2b86..439bdd4cc61 100644 --- a/test/jdk/javax/swing/plaf/windows/bug4991587.java +++ b/test/jdk/javax/swing/plaf/windows/bug4991587.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, 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,7 +23,7 @@ /* * @test - * @bug 4991587 + * @bug 4991587 8359433 * @requires (os.family == "windows") * @summary Tests that disabled JButton text is positioned properly in Windows L&F * @modules java.desktop/com.sun.java.swing.plaf.windows diff --git a/test/jdk/javax/swing/text/html/CSS/8231286/HtmlFontSizeTest.java b/test/jdk/javax/swing/text/html/CSS/8231286/HtmlFontSizeTest.java index 9bdf4dbfae8..eea0a969e77 100644 --- a/test/jdk/javax/swing/text/html/CSS/8231286/HtmlFontSizeTest.java +++ b/test/jdk/javax/swing/text/html/CSS/8231286/HtmlFontSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,8 +51,8 @@ public class HtmlFontSizeTest { htmlPane.setEditorKit(kit); String htmlString = "\n" - + "\n" - + "

This should be 16 pt.

\n" + + "\n" + + "

This should be 32 pt.

\n" + "\n" + ""; @@ -71,10 +71,16 @@ public class HtmlFontSizeTest { System.out.println("size with W3C:" + w3cFrameSize); System.out.println("size without W3C:" + stdFrameSize); - float ratio = (float)w3cFrameSize.width / (float)stdFrameSize.width; - System.out.println("w3cFrameSize.width/stdFrameSize.width " + ratio); + float widthRatio = (float)w3cFrameSize.width / (float)stdFrameSize.width; + System.out.println("w3cFrameSize.width/stdFrameSize.width " + widthRatio); - if (!"1.3".equals(String.format(Locale.ENGLISH, "%.1f", ratio))) { + float heightRatio = (float)w3cFrameSize.height / (float)stdFrameSize.height; + System.out.println("w3cFrameSize.height/stdFrameSize.height " + heightRatio); + + float avgRatio = (widthRatio + heightRatio) / 2.0f; + System.out.println("Average ratio of two dimensions " + avgRatio); + + if (!"1.3".equals(String.format(Locale.ENGLISH, "%.1f", avgRatio))) { throw new RuntimeException("HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS"); } } diff --git a/test/jdk/jdk/classfile/VerifierSelfTest.java b/test/jdk/jdk/classfile/VerifierSelfTest.java index 7d1dae6f519..12458b1586e 100644 --- a/test/jdk/jdk/classfile/VerifierSelfTest.java +++ b/test/jdk/jdk/classfile/VerifierSelfTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,12 +37,14 @@ import static java.lang.constant.ConstantDescs.*; import java.lang.constant.MethodTypeDesc; import java.lang.invoke.MethodHandleInfo; +import java.lang.invoke.MethodHandles; import java.net.URI; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -59,6 +61,9 @@ import jdk.internal.classfile.impl.BufWriterImpl; import jdk.internal.classfile.impl.DirectClassBuilder; import jdk.internal.classfile.impl.UnboundAttribute; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.*; @@ -418,6 +423,71 @@ class VerifierSelfTest { return lst; } + enum ComparisonInstruction { + IF_ACMPEQ(Opcode.IF_ACMPEQ, 2), + IF_ACMPNE(Opcode.IF_ACMPNE, 2), + IFNONNULL(Opcode.IFNONNULL, 1), + IFNULL(Opcode.IFNULL, 1); + final Opcode opcode; + final int argCount; + ComparisonInstruction(Opcode opcode, int argCount) { + this.opcode = opcode; + this.argCount = argCount; + } + } + + enum UninitializeKind { + UNINITIALIZED, UNINITIALIZED_THIS + } + + @ParameterizedTest + @MethodSource("uninitializedInBytecodeClasses") + public void testUninitializedInComparisons(ComparisonInstruction inst, UninitializeKind kind) throws Throwable { + var bytes = ClassFile.of(ClassFile.StackMapsOption.DROP_STACK_MAPS).build(ClassDesc.of("Test"), clb -> clb + .withMethodBody(INIT_NAME, MTD_void, 0, cob -> { + StackMapFrameInfo.VerificationTypeInfo uninitializeInfo; + if (kind == UninitializeKind.UNINITIALIZED) { + uninitializeInfo = StackMapFrameInfo.UninitializedVerificationTypeInfo.of(cob.newBoundLabel()); + cob.new_(CD_Object); + } else { + uninitializeInfo = StackMapFrameInfo.SimpleVerificationTypeInfo.UNINITIALIZED_THIS; + cob.aload(0); + } + + // Stack: uninitializeInfo + for (int i = 0; i < inst.argCount; i++) { + cob.dup(); + } + var dest = cob.newLabel(); + cob.branch(inst.opcode, dest) + .nop() + .labelBinding(dest) + .with(StackMapTableAttribute.of(List.of(StackMapFrameInfo.of(dest, + List.of(StackMapFrameInfo.SimpleVerificationTypeInfo.UNINITIALIZED_THIS), + List.of(uninitializeInfo))))) + .invokespecial(CD_Object, INIT_NAME, MTD_void); + if (kind == UninitializeKind.UNINITIALIZED) { + // still need to call super constructor + cob.aload(0) + .invokespecial(CD_Object, INIT_NAME, MTD_void); + } + cob.return_(); + })); + var errors = ClassFile.of().verify(bytes); + assertNotEquals(List.of(), errors, () -> errors + " : " + ClassFile.of().parse(bytes).toDebugString()); + var lookup = MethodHandles.lookup(); + assertThrows(VerifyError.class, () -> lookup.defineHiddenClass(bytes, true)); // force JVM verification + } + + public static Stream uninitializedInBytecodeClasses() { + return Arrays.stream(ComparisonInstruction.values()) + .mapMulti((inst, sink) -> { + for (var kind : UninitializeKind.values()) { + sink.accept(Arguments.of(inst, kind)); + } + }); + } + @Test // JDK-8350029 void testInvokeSpecialInterfacePatch() { var runClass = ClassDesc.of("Run"); diff --git a/test/jdk/jdk/incubator/vector/BasicFloat16ArithTests.java b/test/jdk/jdk/incubator/vector/BasicFloat16ArithTests.java index 755745394fc..cdc7ce566f7 100644 --- a/test/jdk/jdk/incubator/vector/BasicFloat16ArithTests.java +++ b/test/jdk/jdk/incubator/vector/BasicFloat16ArithTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -38,6 +38,8 @@ public class BasicFloat16ArithTests { private static float NaNf = Float.NaN; private static final float MAX_VAL_FP16 = 0x1.ffcp15f; + private static final float MIN_NRM_FP16 = 0x1.0p-14f; + private static final float MIN_VAL_FP16 = 0x1.0p-24f; public static void main(String... args) { checkBitWise(); @@ -145,9 +147,9 @@ public class BasicFloat16ArithTests { checkInt(PRECISION, 11, "Float16.PRECISION"); checkInt(SIZE, 16, "Float16.SIZE"); - checkFloat16(MIN_VALUE, 0x1.0p-24f, "Float16.MIN_VALUE"); - checkFloat16(MIN_NORMAL, 0x1.0p-14f, "Float16.MIN_NORMAL"); - checkFloat16(MAX_VALUE, 65504.0f, "Float16.MAX_VALUE"); + checkFloat16(MIN_VALUE, MIN_VAL_FP16, "Float16.MIN_VALUE"); + checkFloat16(MIN_NORMAL, MIN_NRM_FP16, "Float16.MIN_NORMAL"); + checkFloat16(MAX_VALUE, 65504.0f, "Float16.MAX_VALUE"); checkFloat16(POSITIVE_INFINITY, InfinityF, "+infinity"); checkFloat16(NEGATIVE_INFINITY, -InfinityF, "-infinity"); @@ -389,12 +391,12 @@ public class BasicFloat16ArithTests { { NaNf, MAX_EXPONENT + 1}, // Subnormal and almost subnormal values - {-0.0f, MIN_EXPONENT - 1}, - {+0.0f, MIN_EXPONENT - 1}, - { 0x1.0p-24f, MIN_EXPONENT - 1}, // Float16.MIN_VALUE - {-0x1.0p-24f, MIN_EXPONENT - 1}, // Float16.MIN_VALUE - { 0x1.0p-14f, MIN_EXPONENT}, // Float16.MIN_NORMAL - {-0x1.0p-14f, MIN_EXPONENT}, // Float16.MIN_NORMAL + {-0.0f, MIN_EXPONENT - 1}, + {+0.0f, MIN_EXPONENT - 1}, + { MIN_VAL_FP16, MIN_EXPONENT - 1}, + {-MIN_VAL_FP16, MIN_EXPONENT - 1}, + { MIN_NRM_FP16, MIN_EXPONENT}, + {-MIN_NRM_FP16, MIN_EXPONENT}, // Normal values { 1.0f, 0}, @@ -424,17 +426,17 @@ public class BasicFloat16ArithTests { { NaNf, NaNf}, // Zeros, subnormals, and MIN_VALUE all have MIN_VALUE as an ulp. - {-0.0f, 0x1.0p-24f}, - {+0.0f, 0x1.0p-24f}, - { 0x1.0p-24f, 0x1.0p-24f}, - {-0x1.0p-24f, 0x1.0p-24f}, - { 0x1.0p-14f, 0x1.0p-24f}, - {-0x1.0p-14f, 0x1.0p-24f}, + {-0.0f, MIN_VAL_FP16}, + {+0.0f, MIN_VAL_FP16}, + { MIN_VAL_FP16, MIN_VAL_FP16}, + {-MIN_VAL_FP16, MIN_VAL_FP16}, + { MIN_NRM_FP16, MIN_VAL_FP16}, + {-MIN_NRM_FP16, MIN_VAL_FP16}, - // ulp is 10 bits away - {0x1.0p0f, 0x0.004p0f}, // 1.0f - {0x1.0p1f, 0x0.004p1f}, // 2.0f - {0x1.0p2f, 0x0.004p2f}, // 4.0f + // ulp is (PRECISION - 1) = 10 bits away + {0x1.0p0f, 0x1.0p-10f}, // 1.0f + {0x1.0p1f, 0x1.0p-9f}, // 2.0f + {0x1.0p2f, 0x1.0p-8f}, // 4.0f {MAX_VAL_FP16*0.5f, 0x0.004p14f}, {MAX_VAL_FP16, 0x0.004p15f}, @@ -507,12 +509,12 @@ public class BasicFloat16ArithTests { } private static void checkValueOfLong() { - checkFloat16(valueOf(-65_521), Float.NEGATIVE_INFINITY, "-infinity"); - checkFloat16(valueOf(-65_520), Float.NEGATIVE_INFINITY, "-infinity"); - checkFloat16(valueOf(-65_519), -MAX_VALUE.floatValue(), "-MAX_VALUE"); - checkFloat16(valueOf(65_519), MAX_VALUE.floatValue(), "MAX_VALUE"); - checkFloat16(valueOf(65_520), Float.POSITIVE_INFINITY, "+infinity"); - checkFloat16(valueOf(65_521), Float.POSITIVE_INFINITY, "+infinity"); + checkFloat16(valueOf(-65_521), Float.NEGATIVE_INFINITY, "-65_521"); + checkFloat16(valueOf(-65_520), Float.NEGATIVE_INFINITY, "-65_520"); + checkFloat16(valueOf(-65_519), -MAX_VALUE.floatValue(), "-65_519"); + checkFloat16(valueOf( 65_519), MAX_VALUE.floatValue(), "65_519"); + checkFloat16(valueOf( 65_520), Float.POSITIVE_INFINITY, "65_520"); + checkFloat16(valueOf( 65_521), Float.POSITIVE_INFINITY, "65_521"); } private static void checkValueOfString() { @@ -792,7 +794,7 @@ public class BasicFloat16ArithTests { // threshold; subtracting a non-zero finite value will // result in MAX_VALUE, adding zero or a positive // value will overflow. - {0x1.2p10f, 0x1.c7p5f, -0x1.0p-14f, + {0x1.2p10f, 0x1.c7p5f, -MIN_NRM_FP16, MAX_VAL_FP16}, {0x1.2p10f, 0x1.c7p5f, -0.0f, @@ -801,7 +803,7 @@ public class BasicFloat16ArithTests { {0x1.2p10f, 0x1.c7p5f, +0.0f, InfinityF}, - {0x1.2p10f, 0x1.c7p5f, +0x1.0p-14f, + {0x1.2p10f, 0x1.c7p5f, +MIN_NRM_FP16, InfinityF}, {0x1.2p10f, 0x1.c7p5f, InfinityF, diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ByteVector128LoadStoreTests.java index 1a50b5d8945..0fa23ef55e1 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Byte128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ByteVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Byte128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ByteVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/ByteVector128Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Byte128VectorTests.java rename to test/jdk/jdk/incubator/vector/ByteVector128Tests.java index fa801f05a19..ca6fa537ac4 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Byte128VectorTests extends AbstractVectorTest { +public class ByteVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_128; @@ -1574,6 +1574,59 @@ public class Byte128VectorTests extends AbstractVectorTest { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1590,9 +1643,6 @@ public class Byte128VectorTests extends AbstractVectorTest { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1701,11 +1751,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1718,15 +1768,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::ADD); + assertArraysEquals(r, a, b, ByteVector128Tests::ADD); } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte128VectorTests(IntFunction fa, IntFunction fb) { + static void addByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1737,11 +1787,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::add); + assertArraysEquals(r, a, b, ByteVector128Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1757,11 +1807,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1775,15 +1825,15 @@ public class Byte128VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::add); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::add); } static byte SUB(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void SUBByte128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1796,15 +1846,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::SUB); + assertArraysEquals(r, a, b, ByteVector128Tests::SUB); } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte128VectorTests(IntFunction fa, IntFunction fb) { + static void subByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1815,11 +1865,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::sub); + assertArraysEquals(r, a, b, ByteVector128Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void SUBByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1835,11 +1885,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::SUB); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1853,15 +1903,15 @@ public class Byte128VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::sub); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::sub); } static byte MUL(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MULByte128VectorTests(IntFunction fa, IntFunction fb) { + static void MULByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1874,15 +1924,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::MUL); + assertArraysEquals(r, a, b, ByteVector128Tests::MUL); } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte128VectorTests(IntFunction fa, IntFunction fb) { + static void mulByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1893,11 +1943,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::mul); + assertArraysEquals(r, a, b, ByteVector128Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void MULByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1913,11 +1963,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::MUL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1931,7 +1981,7 @@ public class Byte128VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::mul); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::mul); } static byte DIV(byte a, byte b) { @@ -1939,7 +1989,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void DIVByte128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1954,7 +2004,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::DIV); + assertArraysEquals(r, a, b, ByteVector128Tests::DIV); } static byte div(byte a, byte b) { @@ -1962,7 +2012,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte128VectorTests(IntFunction fa, IntFunction fb) { + static void divByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::div); + assertArraysEquals(r, a, b, ByteVector128Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void DIVByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1999,11 +2049,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::DIV); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2021,15 +2071,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::div); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::div); } static byte FIRST_NONZERO(byte a, byte b) { - return (byte)((a)!=0?a:b); + return (byte)(firstNonZero(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void FIRST_NONZEROByte128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2042,11 +2092,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void FIRST_NONZEROByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2062,7 +2112,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -2070,7 +2120,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ANDByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2083,7 +2133,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::AND); + assertArraysEquals(r, a, b, ByteVector128Tests::AND); } static byte and(byte a, byte b) { @@ -2091,7 +2141,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte128VectorTests(IntFunction fa, IntFunction fb) { + static void andByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2152,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::and); + assertArraysEquals(r, a, b, ByteVector128Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2122,7 +2172,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::AND); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::AND); } static byte AND_NOT(byte a, byte b) { @@ -2130,7 +2180,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void AND_NOTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2143,11 +2193,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ByteVector128Tests::AND_NOT); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void AND_NOTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2163,7 +2213,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::AND_NOT); } static byte OR(byte a, byte b) { @@ -2171,7 +2221,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ORByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2184,7 +2234,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::OR); + assertArraysEquals(r, a, b, ByteVector128Tests::OR); } static byte or(byte a, byte b) { @@ -2192,7 +2242,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte128VectorTests(IntFunction fa, IntFunction fb) { + static void orByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2203,11 +2253,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::or); + assertArraysEquals(r, a, b, ByteVector128Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2223,7 +2273,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::OR); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::OR); } static byte XOR(byte a, byte b) { @@ -2231,7 +2281,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void XORByte128VectorTests(IntFunction fa, IntFunction fb) { + static void XORByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2244,11 +2294,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::XOR); + assertArraysEquals(r, a, b, ByteVector128Tests::XOR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void XORByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2264,11 +2314,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::XOR); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2278,11 +2328,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2295,11 +2345,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::add); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2309,11 +2359,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2326,11 +2376,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::sub); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2340,11 +2390,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2357,11 +2407,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::mul); } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2373,11 +2423,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2392,11 +2442,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::div); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2406,11 +2456,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2420,11 +2470,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2437,11 +2487,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2451,11 +2501,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2465,11 +2515,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2482,11 +2532,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector128Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2496,11 +2546,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteVector128Tests::OR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2513,11 +2563,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector128Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDByteVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2527,11 +2577,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteVector128Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDByteVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2544,7 +2594,7 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector128Tests::ADD); } static byte LSHL(byte a, byte b) { @@ -2552,7 +2602,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2565,11 +2615,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::LSHL); + assertArraysEquals(r, a, b, ByteVector128Tests::LSHL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2585,7 +2635,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::LSHL); } static byte ASHR(byte a, byte b) { @@ -2593,7 +2643,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2606,11 +2656,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::ASHR); + assertArraysEquals(r, a, b, ByteVector128Tests::ASHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2626,7 +2676,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::ASHR); } static byte LSHR(byte a, byte b) { @@ -2634,7 +2684,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2647,11 +2697,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::LSHR); + assertArraysEquals(r, a, b, ByteVector128Tests::LSHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2667,7 +2717,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::LSHR); } static byte LSHL_unary(byte a, byte b) { @@ -2675,7 +2725,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLByteVector128TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2687,11 +2737,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ByteVector128Tests::LSHL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2706,7 +2756,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector128Tests::LSHL_unary); } static byte LSHR_unary(byte a, byte b) { @@ -2714,7 +2764,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRByteVector128TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2726,11 +2776,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector128Tests::LSHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2745,7 +2795,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector128Tests::LSHR_unary); } static byte ASHR_unary(byte a, byte b) { @@ -2753,7 +2803,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRByteVector128TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2765,11 +2815,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector128Tests::ASHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2784,7 +2834,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector128Tests::ASHR_unary); } static byte ROR(byte a, byte b) { @@ -2792,7 +2842,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte128VectorTests(IntFunction fa, IntFunction fb) { + static void RORByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2805,11 +2855,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::ROR); + assertArraysEquals(r, a, b, ByteVector128Tests::ROR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2825,7 +2875,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::ROR); } static byte ROL(byte a, byte b) { @@ -2833,7 +2883,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ROLByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2846,11 +2896,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::ROL); + assertArraysEquals(r, a, b, ByteVector128Tests::ROL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2866,7 +2916,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::ROL); } static byte ROR_unary(byte a, byte b) { @@ -2874,7 +2924,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORByteVector128TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2886,11 +2936,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ByteVector128Tests::ROR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORByteVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2905,7 +2955,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector128Tests::ROR_unary); } static byte ROL_unary(byte a, byte b) { @@ -2913,7 +2963,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLByteVector128TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2925,11 +2975,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ByteVector128Tests::ROL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2944,14 +2994,14 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector128Tests::ROL_unary); } static byte LSHR_binary_const(byte a) { return (byte)(((a & 0xFF) >>> CONST_SHIFT)); } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHRByte128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRByteVector128TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2962,11 +3012,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ByteVector128Tests::LSHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHRByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRByteVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2980,7 +3030,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector128Tests::LSHR_binary_const); } static byte LSHL_binary_const(byte a) { @@ -2988,7 +3038,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHLByte128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLByteVector128TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2999,11 +3049,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ByteVector128Tests::LSHL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHLByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLByteVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3017,7 +3067,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector128Tests::LSHL_binary_const); } static byte ASHR_binary_const(byte a) { @@ -3025,7 +3075,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ASHRByte128VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRByteVector128TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3036,11 +3086,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ByteVector128Tests::ASHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ASHRByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRByteVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3054,7 +3104,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector128Tests::ASHR_binary_const); } static byte ROR_binary_const(byte a) { @@ -3062,7 +3112,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void RORByte128VectorTestsScalarShiftConst(IntFunction fa) { + static void RORByteVector128TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3073,11 +3123,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ByteVector128Tests::ROR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void RORByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORByteVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3091,7 +3141,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector128Tests::ROR_binary_const); } static byte ROL_binary_const(byte a) { @@ -3099,7 +3149,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ROLByte128VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLByteVector128TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3110,11 +3160,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ByteVector128Tests::ROL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ROLByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLByteVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3128,14 +3178,14 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector128Tests::ROL_binary_const); } static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MINByte128VectorTestsWithMemOp(IntFunction fa) { + static void MINByteVector128TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3146,13 +3196,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte128VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, ByteVector128Tests::MIN); } static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void minByte128VectorTestsWithMemOp(IntFunction fa) { + static void minByteVector128TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3163,13 +3213,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte128VectorTests::min); + assertArraysEquals(r, a, (byte)10, ByteVector128Tests::min); } static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINByteVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3182,13 +3232,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte128VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, mask, ByteVector128Tests::MIN); } static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MAXByte128VectorTestsWithMemOp(IntFunction fa) { + static void MAXByteVector128TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3199,13 +3249,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte128VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, ByteVector128Tests::MAX); } static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void maxByte128VectorTestsWithMemOp(IntFunction fa) { + static void maxByteVector128TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3216,13 +3266,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte128VectorTests::max); + assertArraysEquals(r, a, (byte)10, ByteVector128Tests::max); } static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXByteVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3235,15 +3285,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte128VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, mask, ByteVector128Tests::MAX); } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte128VectorTests(IntFunction fa, IntFunction fb) { + static void MINByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3256,15 +3306,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::MIN); + assertArraysEquals(r, a, b, ByteVector128Tests::MIN); } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte128VectorTests(IntFunction fa, IntFunction fb) { + static void minByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3275,15 +3325,15 @@ public class Byte128VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::min); + assertArraysEquals(r, a, b, ByteVector128Tests::min); } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3296,15 +3346,15 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::MAX); + assertArraysEquals(r, a, b, ByteVector128Tests::MAX); } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maxByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3315,7 +3365,7 @@ public class Byte128VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte128VectorTests::max); + assertArraysEquals(r, a, b, ByteVector128Tests::max); } static byte UMIN(byte a, byte b) { @@ -3323,7 +3373,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMINByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UMINByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3336,11 +3386,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::UMIN); + assertArraysEquals(r, a, b, ByteVector128Tests::UMIN); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMINByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3356,7 +3406,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::UMIN); } static byte UMAX(byte a, byte b) { @@ -3364,7 +3414,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMAXByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3377,11 +3427,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::UMAX); + assertArraysEquals(r, a, b, ByteVector128Tests::UMAX); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMAXByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3397,7 +3447,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::UMAX); } static byte SADD(byte a, byte b) { @@ -3405,7 +3455,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SADDByte128VectorTests(IntFunction fa, IntFunction fb) { + static void SADDByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3418,11 +3468,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::SADD); + assertArraysEquals(r, a, b, ByteVector128Tests::SADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SADDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3438,7 +3488,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::SADD); } static byte SSUB(byte a, byte b) { @@ -3446,7 +3496,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SSUBByte128VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3459,11 +3509,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::SSUB); + assertArraysEquals(r, a, b, ByteVector128Tests::SSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SSUBByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3479,7 +3529,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::SSUB); } static byte SUADD(byte a, byte b) { @@ -3487,7 +3537,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUADDByte128VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3500,11 +3550,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::SUADD); + assertArraysEquals(r, a, b, ByteVector128Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUADDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3520,7 +3570,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::SUADD); } static byte SUSUB(byte a, byte b) { @@ -3528,7 +3578,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUSUBByte128VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3541,11 +3591,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::SUSUB); + assertArraysEquals(r, a, b, ByteVector128Tests::SUSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUSUBByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3561,11 +3611,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::SUSUB); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3575,11 +3625,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3589,11 +3639,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::min); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3603,11 +3653,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3617,10 +3667,10 @@ public class Byte128VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteVector128Tests::max); } @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider") - static void SUADDAssocByte128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocByteVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -3637,11 +3687,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Byte128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ByteVector128Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3662,13 +3712,13 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Byte128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteVector128Tests::SUADD); } static byte ANDReduce(byte[] a, int idx) { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3677,14 +3727,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ANDReduceAll(byte[] a) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ANDReduceByte128VectorTests(IntFunction fa) { + static void ANDReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3695,12 +3745,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::ANDReduce, Byte128VectorTests::ANDReduceAll); + ByteVector128Tests::ANDReduce, ByteVector128Tests::ANDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3708,20 +3758,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = AND_IDENTITY; - assertEquals((byte) (id & id), id, + assertEquals((byte) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id & x), x); - assertEquals((byte) (x & id), x); + assertEquals((byte) (scalar_and(id, x)), x); + assertEquals((byte) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id & x), x, + assertEquals((byte) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x & id), x, + assertEquals((byte) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3730,7 +3780,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3739,14 +3789,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ANDReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3759,18 +3809,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::ANDReduceMasked, Byte128VectorTests::ANDReduceAllMasked); + ByteVector128Tests::ANDReduceMasked, ByteVector128Tests::ANDReduceAllMasked); } static byte ORReduce(byte[] a, int idx) { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3779,14 +3829,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ORReduceAll(byte[] a) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ORReduceByte128VectorTests(IntFunction fa) { + static void ORReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3797,12 +3847,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::ORReduce, Byte128VectorTests::ORReduceAll); + ByteVector128Tests::ORReduce, ByteVector128Tests::ORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3810,20 +3860,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = OR_IDENTITY; - assertEquals((byte) (id | id), id, + assertEquals((byte) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id | x), x); - assertEquals((byte) (x | id), x); + assertEquals((byte) (scalar_or(id, x)), x); + assertEquals((byte) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id | x), x, + assertEquals((byte) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x | id), x, + assertEquals((byte) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3832,7 +3882,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3841,14 +3891,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ORReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3861,18 +3911,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::ORReduceMasked, Byte128VectorTests::ORReduceAllMasked); + ByteVector128Tests::ORReduceMasked, ByteVector128Tests::ORReduceAllMasked); } static byte XORReduce(byte[] a, int idx) { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3881,14 +3931,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte XORReduceAll(byte[] a) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void XORReduceByte128VectorTests(IntFunction fa) { + static void XORReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3899,12 +3949,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::XORReduce, Byte128VectorTests::XORReduceAll); + ByteVector128Tests::XORReduce, ByteVector128Tests::XORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3912,20 +3962,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = XOR_IDENTITY; - assertEquals((byte) (id ^ id), id, + assertEquals((byte) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id ^ x), x); - assertEquals((byte) (x ^ id), x); + assertEquals((byte) (scalar_xor(id, x)), x); + assertEquals((byte) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id ^ x), x, + assertEquals((byte) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x ^ id), x, + assertEquals((byte) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3934,7 +3984,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3943,14 +3993,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void XORReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3963,18 +4013,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::XORReduceMasked, Byte128VectorTests::XORReduceAllMasked); + ByteVector128Tests::XORReduceMasked, ByteVector128Tests::XORReduceAllMasked); } static byte ADDReduce(byte[] a, int idx) { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3983,14 +4033,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ADDReduceAll(byte[] a) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceByte128VectorTests(IntFunction fa) { + static void ADDReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4001,12 +4051,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::ADDReduce, Byte128VectorTests::ADDReduceAll); + ByteVector128Tests::ADDReduce, ByteVector128Tests::ADDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4014,20 +4064,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = ADD_IDENTITY; - assertEquals((byte) (id + id), id, + assertEquals((byte) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id + x), x); - assertEquals((byte) (x + id), x); + assertEquals((byte) (scalar_add(id, x)), x); + assertEquals((byte) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id + x), x, + assertEquals((byte) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x + id), x, + assertEquals((byte) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4036,7 +4086,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4045,14 +4095,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4065,18 +4115,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::ADDReduceMasked, Byte128VectorTests::ADDReduceAllMasked); + ByteVector128Tests::ADDReduceMasked, ByteVector128Tests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4085,14 +4135,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MULReduceAll(byte[] a) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MULReduceByte128VectorTests(IntFunction fa) { + static void MULReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4103,12 +4153,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::MULReduce, Byte128VectorTests::MULReduceAll); + ByteVector128Tests::MULReduce, ByteVector128Tests::MULReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4116,20 +4166,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MUL_IDENTITY; - assertEquals((byte) (id * id), id, + assertEquals((byte) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id * x), x); - assertEquals((byte) (x * id), x); + assertEquals((byte) (scalar_mul(id, x)), x); + assertEquals((byte) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id * x), x, + assertEquals((byte) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x * id), x, + assertEquals((byte) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4138,7 +4188,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4147,14 +4197,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MULReduceAllMasked(byte[] a, boolean[] mask) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MULReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4167,18 +4217,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::MULReduceMasked, Byte128VectorTests::MULReduceAllMasked); + ByteVector128Tests::MULReduceMasked, ByteVector128Tests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4187,14 +4237,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MINReduceAll(byte[] a) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MINReduceByte128VectorTests(IntFunction fa) { + static void MINReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4205,12 +4255,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::MINReduce, Byte128VectorTests::MINReduceAll); + ByteVector128Tests::MINReduce, ByteVector128Tests::MINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4218,20 +4268,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MIN_IDENTITY; - assertEquals((byte) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.min(id, x), x); - assertEquals((byte) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4240,7 +4290,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4249,14 +4299,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MINReduceAllMasked(byte[] a, boolean[] mask) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4269,18 +4319,18 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::MINReduceMasked, Byte128VectorTests::MINReduceAllMasked); + ByteVector128Tests::MINReduceMasked, ByteVector128Tests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4289,14 +4339,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MAXReduceAll(byte[] a) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MAXReduceByte128VectorTests(IntFunction fa) { + static void MAXReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4307,12 +4357,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::MAXReduce, Byte128VectorTests::MAXReduceAll); + ByteVector128Tests::MAXReduce, ByteVector128Tests::MAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4320,20 +4370,20 @@ public class Byte128VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MAX_IDENTITY; - assertEquals((byte) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.max(id, x), x); - assertEquals((byte) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4342,7 +4392,7 @@ public class Byte128VectorTests extends AbstractVectorTest { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4351,14 +4401,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4371,12 +4421,12 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::MAXReduceMasked, Byte128VectorTests::MAXReduceAllMasked); + ByteVector128Tests::MAXReduceMasked, ByteVector128Tests::MAXReduceAllMasked); } static byte UMINReduce(byte[] a, int idx) { @@ -4398,7 +4448,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMINReduceByte128VectorTests(IntFunction fa) { + static void UMINReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4414,7 +4464,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::UMINReduce, Byte128VectorTests::UMINReduceAll); + ByteVector128Tests::UMINReduce, ByteVector128Tests::UMINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4460,7 +4510,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMINReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4478,7 +4528,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::UMINReduceMasked, Byte128VectorTests::UMINReduceAllMasked); + ByteVector128Tests::UMINReduceMasked, ByteVector128Tests::UMINReduceAllMasked); } static byte UMAXReduce(byte[] a, int idx) { @@ -4500,7 +4550,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMAXReduceByte128VectorTests(IntFunction fa) { + static void UMAXReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4516,7 +4566,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::UMAXReduce, Byte128VectorTests::UMAXReduceAll); + ByteVector128Tests::UMAXReduce, ByteVector128Tests::UMAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4562,7 +4612,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4580,7 +4630,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::UMAXReduceMasked, Byte128VectorTests::UMAXReduceAllMasked); + ByteVector128Tests::UMAXReduceMasked, ByteVector128Tests::UMAXReduceAllMasked); } static byte FIRST_NONZEROReduce(byte[] a, int idx) { @@ -4602,7 +4652,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void FIRST_NONZEROReduceByte128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4618,7 +4668,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::FIRST_NONZEROReduce, Byte128VectorTests::FIRST_NONZEROReduceAll); + ByteVector128Tests::FIRST_NONZEROReduce, ByteVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4664,7 +4714,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void FIRST_NONZEROReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4682,7 +4732,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::FIRST_NONZEROReduceMasked, Byte128VectorTests::FIRST_NONZEROReduceAllMasked); + ByteVector128Tests::FIRST_NONZEROReduceMasked, ByteVector128Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4695,7 +4745,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueByte128VectorTests(IntFunction fm) { + static void anyTrueByteVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4706,7 +4756,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector128Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4719,7 +4769,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueByte128VectorTests(IntFunction fm) { + static void allTrueByteVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4730,7 +4780,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector128Tests::allTrue); } static byte SUADDReduce(byte[] a, int idx) { @@ -4752,7 +4802,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingUnaryOpProvider") - static void SUADDReduceByte128VectorTests(IntFunction fa) { + static void SUADDReduceByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4768,7 +4818,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte128VectorTests::SUADDReduce, Byte128VectorTests::SUADDReduceAll); + ByteVector128Tests::SUADDReduce, ByteVector128Tests::SUADDReduceAll); } @Test(dataProvider = "byteSaturatingUnaryOpProvider") @@ -4813,7 +4863,7 @@ public class Byte128VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider") - static void SUADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4831,11 +4881,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::SUADDReduceMasked, Byte128VectorTests::SUADDReduceAllMasked); + ByteVector128Tests::SUADDReduceMasked, ByteVector128Tests::SUADDReduceAllMasked); } @Test(dataProvider = "byteBinaryOpProvider") - static void withByte128VectorTests(IntFunction fa, IntFunction fb) { + static void withByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -4858,7 +4908,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_DEFAULTByte128VectorTests(IntFunction fa) { + static void IS_DEFAULTByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4875,7 +4925,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_DEFAULTMaskedByte128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4899,7 +4949,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_NEGATIVEByte128VectorTests(IntFunction fa) { + static void IS_NEGATIVEByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4916,7 +4966,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_NEGATIVEMaskedByte128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4936,7 +4986,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void LTByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4955,7 +5005,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ltByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4974,7 +5024,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4997,7 +5047,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void GTByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5016,7 +5066,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5039,7 +5089,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte128VectorTests(IntFunction fa, IntFunction fb) { + static void EQByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5058,7 +5108,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte128VectorTests(IntFunction fa, IntFunction fb) { + static void eqByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5077,7 +5127,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5100,7 +5150,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void NEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void NEByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5119,7 +5169,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void NEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5142,7 +5192,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void LEByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5161,7 +5211,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5184,7 +5234,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void GEByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5203,7 +5253,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5226,7 +5276,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ULTByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5245,7 +5295,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5268,7 +5318,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5287,7 +5337,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5310,7 +5360,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5329,7 +5379,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5352,7 +5402,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteVector128Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5371,7 +5421,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5394,7 +5444,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5404,13 +5454,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5424,13 +5474,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5440,13 +5490,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTByteVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5460,13 +5510,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (byte)((long)b[i])))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5476,13 +5526,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5496,13 +5546,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5512,13 +5562,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQByteVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5532,7 +5582,7 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (byte)((long)b[i])))); } } } @@ -5542,7 +5592,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte128VectorTests(IntFunction fa, IntFunction fb, + static void blendByteVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5558,11 +5608,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte128VectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteVector128Tests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") - static void RearrangeByte128VectorTests(IntFunction fa, + static void RearrangeByteVector128Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5579,7 +5629,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") - static void RearrangeByte128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeByteVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -5597,7 +5647,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void compressByte128VectorTests(IntFunction fa, + static void compressByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5615,7 +5665,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void expandByte128VectorTests(IntFunction fa, + static void expandByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5633,7 +5683,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void getByte128VectorTests(IntFunction fa) { + static void getByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5789,7 +5839,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastByte128VectorTests(IntFunction fa) { + static void BroadcastByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5803,7 +5853,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZeroByte128VectorTests(IntFunction fa) { + static void ZeroByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5828,7 +5878,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void sliceUnaryByte128VectorTests(IntFunction fa) { + static void sliceUnaryByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5839,7 +5889,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteVector128Tests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { @@ -5856,7 +5906,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void sliceBinaryByte128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryByteVector128TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5869,7 +5919,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Byte128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteVector128Tests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { @@ -5886,7 +5936,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void sliceByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5903,7 +5953,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Byte128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ByteVector128Tests::slice); } static byte[] unsliceUnary(byte[] a, int origin, int idx) { @@ -5920,7 +5970,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void unsliceUnaryByte128VectorTests(IntFunction fa) { + static void unsliceUnaryByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5931,7 +5981,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteVector128Tests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { @@ -5957,7 +6007,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void unsliceBinaryByte128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryByteVector128TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5971,7 +6021,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Byte128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteVector128Tests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { @@ -6011,7 +6061,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void unsliceByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6028,7 +6078,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Byte128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteVector128Tests::unslice); } static byte BITWISE_BLEND(byte a, byte b, byte c) { @@ -6040,7 +6090,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6055,11 +6105,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Byte128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6072,11 +6122,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Byte128VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ByteVector128Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6094,11 +6144,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Byte128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6109,11 +6159,11 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6124,11 +6174,11 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6139,11 +6189,11 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6154,11 +6204,11 @@ public class Byte128VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6173,11 +6223,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Byte128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6192,11 +6242,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Byte128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6207,11 +6257,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6222,11 +6272,11 @@ public class Byte128VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte128VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector128Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6240,19 +6290,19 @@ public class Byte128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Byte128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteVector128Tests::BITWISE_BLEND); } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void NEGByte128VectorTests(IntFunction fa) { + static void NEGByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6263,11 +6313,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::NEG); + assertArraysEquals(r, a, ByteVector128Tests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") - static void negByte128VectorTests(IntFunction fa) { + static void negByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6278,11 +6328,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::neg); + assertArraysEquals(r, a, ByteVector128Tests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NEGMaskedByte128VectorTests(IntFunction fa, + static void NEGMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6296,19 +6346,19 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::NEG); + assertArraysEquals(r, a, mask, ByteVector128Tests::NEG); } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void ABSByte128VectorTests(IntFunction fa) { + static void ABSByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6319,11 +6369,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::ABS); + assertArraysEquals(r, a, ByteVector128Tests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") - static void absByte128VectorTests(IntFunction fa) { + static void absByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6334,11 +6384,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::abs); + assertArraysEquals(r, a, ByteVector128Tests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ABSMaskedByte128VectorTests(IntFunction fa, + static void ABSMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6352,7 +6402,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::ABS); + assertArraysEquals(r, a, mask, ByteVector128Tests::ABS); } static byte NOT(byte a) { @@ -6364,7 +6414,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void NOTByte128VectorTests(IntFunction fa) { + static void NOTByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6375,11 +6425,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::NOT); + assertArraysEquals(r, a, ByteVector128Tests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") - static void notByte128VectorTests(IntFunction fa) { + static void notByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6390,11 +6440,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::not); + assertArraysEquals(r, a, ByteVector128Tests::not); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NOTMaskedByte128VectorTests(IntFunction fa, + static void NOTMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6408,7 +6458,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::NOT); + assertArraysEquals(r, a, mask, ByteVector128Tests::NOT); } static byte ZOMO(byte a) { @@ -6416,7 +6466,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZOMOByte128VectorTests(IntFunction fa) { + static void ZOMOByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6427,11 +6477,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::ZOMO); + assertArraysEquals(r, a, ByteVector128Tests::ZOMO); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ZOMOMaskedByte128VectorTests(IntFunction fa, + static void ZOMOMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6445,7 +6495,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteVector128Tests::ZOMO); } static byte BIT_COUNT(byte a) { @@ -6453,7 +6503,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BIT_COUNTByte128VectorTests(IntFunction fa) { + static void BIT_COUNTByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6464,11 +6514,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ByteVector128Tests::BIT_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void BIT_COUNTMaskedByte128VectorTests(IntFunction fa, + static void BIT_COUNTMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6482,7 +6532,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ByteVector128Tests::BIT_COUNT); } static byte TRAILING_ZEROS_COUNT(byte a) { @@ -6490,7 +6540,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void TRAILING_ZEROS_COUNTByte128VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6501,11 +6551,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector128Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedByte128VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6519,7 +6569,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector128Tests::TRAILING_ZEROS_COUNT); } static byte LEADING_ZEROS_COUNT(byte a) { @@ -6527,7 +6577,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LEADING_ZEROS_COUNTByte128VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6538,11 +6588,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector128Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedByte128VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6556,7 +6606,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector128Tests::LEADING_ZEROS_COUNT); } static byte REVERSE(byte a) { @@ -6564,7 +6614,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSEByte128VectorTests(IntFunction fa) { + static void REVERSEByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6575,11 +6625,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::REVERSE); + assertArraysEquals(r, a, ByteVector128Tests::REVERSE); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSEMaskedByte128VectorTests(IntFunction fa, + static void REVERSEMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6593,7 +6643,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ByteVector128Tests::REVERSE); } static byte REVERSE_BYTES(byte a) { @@ -6601,7 +6651,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSE_BYTESByte128VectorTests(IntFunction fa) { + static void REVERSE_BYTESByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6612,11 +6662,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ByteVector128Tests::REVERSE_BYTES); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedByte128VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedByteVector128Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6630,7 +6680,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ByteVector128Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6638,7 +6688,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6651,7 +6701,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::band); + assertArraysEquals(r, a, b, ByteVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6659,7 +6709,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6672,7 +6722,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::bor); + assertArraysEquals(r, a, b, ByteVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6680,7 +6730,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6693,7 +6743,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::bxor); + assertArraysEquals(r, a, b, ByteVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6701,7 +6751,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6714,7 +6764,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::bandNot); + assertArraysEquals(r, a, b, ByteVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6722,7 +6772,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6735,7 +6785,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte128VectorTests::beq); + assertArraysEquals(r, a, b, ByteVector128Tests::beq); } static boolean unot(boolean a) { @@ -6743,7 +6793,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotByte128VectorTests(IntFunction fa) { + static void masknotByteVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6754,7 +6804,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::unot); + assertArraysEquals(r, a, ByteVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6771,7 +6821,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongByte128VectorTests(IntFunction fa) { + static void maskFromToLongByteVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6785,7 +6835,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltByteVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6795,13 +6845,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqByteVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6811,13 +6861,13 @@ public class Byte128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteUnaryOpProvider") - static void toIntArrayByte128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6828,7 +6878,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toLongArrayByte128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6839,7 +6889,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toDoubleArrayByte128VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6850,7 +6900,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toStringByte128VectorTestsSmokeTest(IntFunction fa) { + static void toStringByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6863,7 +6913,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void hashCodeByte128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6877,7 +6927,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void reinterpretAsBytesByte128VectorTestsSmokeTest(IntFunction fa) { + static void reinterpretAsBytesByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6891,7 +6941,7 @@ public class Byte128VectorTests extends AbstractVectorTest { static long ADDReduceLong(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6900,14 +6950,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(byte[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((byte)res, (byte)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceLongByte128VectorTests(IntFunction fa) { + static void ADDReduceLongByteVector128Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6918,19 +6968,20 @@ public class Byte128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Byte128VectorTests::ADDReduceLong, Byte128VectorTests::ADDReduceAllLong); + ByteVector128Tests::ADDReduceLong, ByteVector128Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6939,14 +6990,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((byte)res, (byte)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceLongByte128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongByteVector128TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6959,16 +7010,16 @@ public class Byte128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Byte128VectorTests::ADDReduceLongMasked, Byte128VectorTests::ADDReduceAllLongMasked); + ByteVector128Tests::ADDReduceLongMasked, ByteVector128Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastLongByte128VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongByteVector128TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6979,7 +7030,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendByteVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6993,12 +7044,12 @@ public class Byte128VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector128Tests::blend); } @Test(dataProvider = "byteUnaryOpSelectFromProvider") - static void SelectFromByte128VectorTests(IntFunction fa, + static void SelectFromByteVector128Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); byte[] order = fs.apply(a.length, SPECIES.length()); @@ -7014,7 +7065,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorByte128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorByteVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] idx = fc.apply(SPECIES.length()); @@ -7032,7 +7083,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") - static void SelectFromByte128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromByteVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -7051,7 +7102,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousByte128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousByteVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7067,7 +7118,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringByte128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringByteVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7081,7 +7132,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsByte128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsByteVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7095,7 +7146,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsByte128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsByteVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7111,7 +7162,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeByte128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeByteVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7133,7 +7184,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountByte128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountByteVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7144,7 +7195,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ByteVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7158,7 +7209,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueByte128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueByteVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7169,7 +7220,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ByteVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7183,7 +7234,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueByte128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueByteVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7194,11 +7245,11 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ByteVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressByte128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressByteVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7226,7 +7277,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeByte128VectorTestsSmokeTest(int offset) { + static void indexInRangeByteVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7240,7 +7291,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongByte128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongByteVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7267,14 +7318,14 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundByte128VectorTestsSmokeTest(int length) { + static void loopBoundByteVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongByte128VectorTestsSmokeTest(int _length) { + static void loopBoundLongByteVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7282,21 +7333,21 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeByte128VectorTestsSmokeTest() { + static void ElementSizeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Byte.SIZE); } @Test - static void VectorShapeByte128VectorTestsSmokeTest() { + static void VectorShapeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesByte128VectorTestsSmokeTest() { + static void ShapeWithLanesByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(byte.class); @@ -7304,32 +7355,32 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeByte128VectorTestsSmokeTest() { + static void ElementTypeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementType() == byte.class); } @Test - static void SpeciesElementSizeByte128VectorTestsSmokeTest() { + static void SpeciesElementSizeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementSize() == Byte.SIZE); } @Test - static void VectorTypeByte128VectorTestsSmokeTest() { + static void VectorTypeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesByte128VectorTestsSmokeTest() { + static void WithLanesByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(byte.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeByte128VectorTestsSmokeTest() { + static void WithShapeByteVector128TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7337,7 +7388,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueByte128VectorTestsSmokeTest() { + static void MaskAllTrueByteVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ByteVector256LoadStoreTests.java index 1b1f6c0ed36..f57bc3e65b9 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Byte256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ByteVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Byte256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ByteVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/ByteVector256Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Byte256VectorTests.java rename to test/jdk/jdk/incubator/vector/ByteVector256Tests.java index ec8958e0605..5c32d4a7f74 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Byte256VectorTests extends AbstractVectorTest { +public class ByteVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_256; @@ -1574,6 +1574,59 @@ public class Byte256VectorTests extends AbstractVectorTest { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1590,9 +1643,6 @@ public class Byte256VectorTests extends AbstractVectorTest { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1701,11 +1751,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1718,15 +1768,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::ADD); + assertArraysEquals(r, a, b, ByteVector256Tests::ADD); } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte256VectorTests(IntFunction fa, IntFunction fb) { + static void addByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1737,11 +1787,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::add); + assertArraysEquals(r, a, b, ByteVector256Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1757,11 +1807,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1775,15 +1825,15 @@ public class Byte256VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::add); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::add); } static byte SUB(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void SUBByte256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1796,15 +1846,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::SUB); + assertArraysEquals(r, a, b, ByteVector256Tests::SUB); } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte256VectorTests(IntFunction fa, IntFunction fb) { + static void subByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1815,11 +1865,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::sub); + assertArraysEquals(r, a, b, ByteVector256Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void SUBByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1835,11 +1885,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::SUB); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1853,15 +1903,15 @@ public class Byte256VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::sub); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::sub); } static byte MUL(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MULByte256VectorTests(IntFunction fa, IntFunction fb) { + static void MULByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1874,15 +1924,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::MUL); + assertArraysEquals(r, a, b, ByteVector256Tests::MUL); } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte256VectorTests(IntFunction fa, IntFunction fb) { + static void mulByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1893,11 +1943,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::mul); + assertArraysEquals(r, a, b, ByteVector256Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void MULByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1913,11 +1963,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::MUL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1931,7 +1981,7 @@ public class Byte256VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::mul); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::mul); } static byte DIV(byte a, byte b) { @@ -1939,7 +1989,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void DIVByte256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1954,7 +2004,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::DIV); + assertArraysEquals(r, a, b, ByteVector256Tests::DIV); } static byte div(byte a, byte b) { @@ -1962,7 +2012,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte256VectorTests(IntFunction fa, IntFunction fb) { + static void divByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::div); + assertArraysEquals(r, a, b, ByteVector256Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void DIVByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1999,11 +2049,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::DIV); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2021,15 +2071,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::div); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::div); } static byte FIRST_NONZERO(byte a, byte b) { - return (byte)((a)!=0?a:b); + return (byte)(firstNonZero(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void FIRST_NONZEROByte256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2042,11 +2092,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void FIRST_NONZEROByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2062,7 +2112,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -2070,7 +2120,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ANDByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2083,7 +2133,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::AND); + assertArraysEquals(r, a, b, ByteVector256Tests::AND); } static byte and(byte a, byte b) { @@ -2091,7 +2141,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte256VectorTests(IntFunction fa, IntFunction fb) { + static void andByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2152,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::and); + assertArraysEquals(r, a, b, ByteVector256Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2122,7 +2172,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::AND); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::AND); } static byte AND_NOT(byte a, byte b) { @@ -2130,7 +2180,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void AND_NOTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2143,11 +2193,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ByteVector256Tests::AND_NOT); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void AND_NOTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2163,7 +2213,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::AND_NOT); } static byte OR(byte a, byte b) { @@ -2171,7 +2221,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ORByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2184,7 +2234,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::OR); + assertArraysEquals(r, a, b, ByteVector256Tests::OR); } static byte or(byte a, byte b) { @@ -2192,7 +2242,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte256VectorTests(IntFunction fa, IntFunction fb) { + static void orByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2203,11 +2253,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::or); + assertArraysEquals(r, a, b, ByteVector256Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2223,7 +2273,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::OR); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::OR); } static byte XOR(byte a, byte b) { @@ -2231,7 +2281,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void XORByte256VectorTests(IntFunction fa, IntFunction fb) { + static void XORByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2244,11 +2294,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::XOR); + assertArraysEquals(r, a, b, ByteVector256Tests::XOR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void XORByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2264,11 +2314,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::XOR); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2278,11 +2328,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2295,11 +2345,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::add); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2309,11 +2359,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2326,11 +2376,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::sub); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2340,11 +2390,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2357,11 +2407,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::mul); } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2373,11 +2423,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2392,11 +2442,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::div); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2406,11 +2456,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2420,11 +2470,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2437,11 +2487,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2451,11 +2501,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2465,11 +2515,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2482,11 +2532,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector256Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2496,11 +2546,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteVector256Tests::OR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2513,11 +2563,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector256Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDByteVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2527,11 +2577,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteVector256Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDByteVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2544,7 +2594,7 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector256Tests::ADD); } static byte LSHL(byte a, byte b) { @@ -2552,7 +2602,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2565,11 +2615,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::LSHL); + assertArraysEquals(r, a, b, ByteVector256Tests::LSHL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2585,7 +2635,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::LSHL); } static byte ASHR(byte a, byte b) { @@ -2593,7 +2643,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2606,11 +2656,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::ASHR); + assertArraysEquals(r, a, b, ByteVector256Tests::ASHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2626,7 +2676,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::ASHR); } static byte LSHR(byte a, byte b) { @@ -2634,7 +2684,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2647,11 +2697,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::LSHR); + assertArraysEquals(r, a, b, ByteVector256Tests::LSHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2667,7 +2717,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::LSHR); } static byte LSHL_unary(byte a, byte b) { @@ -2675,7 +2725,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLByteVector256TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2687,11 +2737,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ByteVector256Tests::LSHL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2706,7 +2756,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector256Tests::LSHL_unary); } static byte LSHR_unary(byte a, byte b) { @@ -2714,7 +2764,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRByteVector256TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2726,11 +2776,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector256Tests::LSHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2745,7 +2795,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector256Tests::LSHR_unary); } static byte ASHR_unary(byte a, byte b) { @@ -2753,7 +2803,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRByteVector256TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2765,11 +2815,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector256Tests::ASHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2784,7 +2834,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector256Tests::ASHR_unary); } static byte ROR(byte a, byte b) { @@ -2792,7 +2842,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte256VectorTests(IntFunction fa, IntFunction fb) { + static void RORByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2805,11 +2855,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::ROR); + assertArraysEquals(r, a, b, ByteVector256Tests::ROR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2825,7 +2875,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::ROR); } static byte ROL(byte a, byte b) { @@ -2833,7 +2883,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ROLByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2846,11 +2896,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::ROL); + assertArraysEquals(r, a, b, ByteVector256Tests::ROL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2866,7 +2916,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::ROL); } static byte ROR_unary(byte a, byte b) { @@ -2874,7 +2924,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORByteVector256TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2886,11 +2936,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ByteVector256Tests::ROR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORByteVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2905,7 +2955,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector256Tests::ROR_unary); } static byte ROL_unary(byte a, byte b) { @@ -2913,7 +2963,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLByteVector256TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2925,11 +2975,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ByteVector256Tests::ROL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2944,14 +2994,14 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector256Tests::ROL_unary); } static byte LSHR_binary_const(byte a) { return (byte)(((a & 0xFF) >>> CONST_SHIFT)); } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHRByte256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRByteVector256TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2962,11 +3012,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ByteVector256Tests::LSHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHRByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRByteVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2980,7 +3030,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector256Tests::LSHR_binary_const); } static byte LSHL_binary_const(byte a) { @@ -2988,7 +3038,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHLByte256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLByteVector256TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2999,11 +3049,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ByteVector256Tests::LSHL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHLByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLByteVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3017,7 +3067,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector256Tests::LSHL_binary_const); } static byte ASHR_binary_const(byte a) { @@ -3025,7 +3075,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ASHRByte256VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRByteVector256TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3036,11 +3086,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ByteVector256Tests::ASHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ASHRByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRByteVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3054,7 +3104,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector256Tests::ASHR_binary_const); } static byte ROR_binary_const(byte a) { @@ -3062,7 +3112,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void RORByte256VectorTestsScalarShiftConst(IntFunction fa) { + static void RORByteVector256TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3073,11 +3123,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ByteVector256Tests::ROR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void RORByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORByteVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3091,7 +3141,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector256Tests::ROR_binary_const); } static byte ROL_binary_const(byte a) { @@ -3099,7 +3149,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ROLByte256VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLByteVector256TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3110,11 +3160,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ByteVector256Tests::ROL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ROLByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLByteVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3128,14 +3178,14 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector256Tests::ROL_binary_const); } static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MINByte256VectorTestsWithMemOp(IntFunction fa) { + static void MINByteVector256TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3146,13 +3196,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte256VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, ByteVector256Tests::MIN); } static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void minByte256VectorTestsWithMemOp(IntFunction fa) { + static void minByteVector256TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3163,13 +3213,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte256VectorTests::min); + assertArraysEquals(r, a, (byte)10, ByteVector256Tests::min); } static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINByteVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3182,13 +3232,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte256VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, mask, ByteVector256Tests::MIN); } static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MAXByte256VectorTestsWithMemOp(IntFunction fa) { + static void MAXByteVector256TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3199,13 +3249,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte256VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, ByteVector256Tests::MAX); } static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void maxByte256VectorTestsWithMemOp(IntFunction fa) { + static void maxByteVector256TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3216,13 +3266,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte256VectorTests::max); + assertArraysEquals(r, a, (byte)10, ByteVector256Tests::max); } static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXByteVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3235,15 +3285,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte256VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, mask, ByteVector256Tests::MAX); } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte256VectorTests(IntFunction fa, IntFunction fb) { + static void MINByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3256,15 +3306,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::MIN); + assertArraysEquals(r, a, b, ByteVector256Tests::MIN); } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte256VectorTests(IntFunction fa, IntFunction fb) { + static void minByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3275,15 +3325,15 @@ public class Byte256VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::min); + assertArraysEquals(r, a, b, ByteVector256Tests::min); } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3296,15 +3346,15 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::MAX); + assertArraysEquals(r, a, b, ByteVector256Tests::MAX); } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maxByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3315,7 +3365,7 @@ public class Byte256VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte256VectorTests::max); + assertArraysEquals(r, a, b, ByteVector256Tests::max); } static byte UMIN(byte a, byte b) { @@ -3323,7 +3373,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMINByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UMINByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3336,11 +3386,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::UMIN); + assertArraysEquals(r, a, b, ByteVector256Tests::UMIN); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMINByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3356,7 +3406,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::UMIN); } static byte UMAX(byte a, byte b) { @@ -3364,7 +3414,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMAXByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3377,11 +3427,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::UMAX); + assertArraysEquals(r, a, b, ByteVector256Tests::UMAX); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMAXByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3397,7 +3447,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::UMAX); } static byte SADD(byte a, byte b) { @@ -3405,7 +3455,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SADDByte256VectorTests(IntFunction fa, IntFunction fb) { + static void SADDByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3418,11 +3468,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::SADD); + assertArraysEquals(r, a, b, ByteVector256Tests::SADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SADDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3438,7 +3488,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::SADD); } static byte SSUB(byte a, byte b) { @@ -3446,7 +3496,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SSUBByte256VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3459,11 +3509,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::SSUB); + assertArraysEquals(r, a, b, ByteVector256Tests::SSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SSUBByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3479,7 +3529,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::SSUB); } static byte SUADD(byte a, byte b) { @@ -3487,7 +3537,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUADDByte256VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3500,11 +3550,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::SUADD); + assertArraysEquals(r, a, b, ByteVector256Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUADDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3520,7 +3570,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::SUADD); } static byte SUSUB(byte a, byte b) { @@ -3528,7 +3578,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUSUBByte256VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3541,11 +3591,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::SUSUB); + assertArraysEquals(r, a, b, ByteVector256Tests::SUSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUSUBByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3561,11 +3611,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::SUSUB); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3575,11 +3625,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3589,11 +3639,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::min); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3603,11 +3653,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3617,10 +3667,10 @@ public class Byte256VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteVector256Tests::max); } @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider") - static void SUADDAssocByte256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocByteVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -3637,11 +3687,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Byte256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ByteVector256Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3662,13 +3712,13 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Byte256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteVector256Tests::SUADD); } static byte ANDReduce(byte[] a, int idx) { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3677,14 +3727,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ANDReduceAll(byte[] a) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ANDReduceByte256VectorTests(IntFunction fa) { + static void ANDReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3695,12 +3745,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::ANDReduce, Byte256VectorTests::ANDReduceAll); + ByteVector256Tests::ANDReduce, ByteVector256Tests::ANDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3708,20 +3758,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = AND_IDENTITY; - assertEquals((byte) (id & id), id, + assertEquals((byte) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id & x), x); - assertEquals((byte) (x & id), x); + assertEquals((byte) (scalar_and(id, x)), x); + assertEquals((byte) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id & x), x, + assertEquals((byte) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x & id), x, + assertEquals((byte) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3730,7 +3780,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3739,14 +3789,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ANDReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3759,18 +3809,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::ANDReduceMasked, Byte256VectorTests::ANDReduceAllMasked); + ByteVector256Tests::ANDReduceMasked, ByteVector256Tests::ANDReduceAllMasked); } static byte ORReduce(byte[] a, int idx) { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3779,14 +3829,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ORReduceAll(byte[] a) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ORReduceByte256VectorTests(IntFunction fa) { + static void ORReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3797,12 +3847,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::ORReduce, Byte256VectorTests::ORReduceAll); + ByteVector256Tests::ORReduce, ByteVector256Tests::ORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3810,20 +3860,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = OR_IDENTITY; - assertEquals((byte) (id | id), id, + assertEquals((byte) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id | x), x); - assertEquals((byte) (x | id), x); + assertEquals((byte) (scalar_or(id, x)), x); + assertEquals((byte) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id | x), x, + assertEquals((byte) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x | id), x, + assertEquals((byte) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3832,7 +3882,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3841,14 +3891,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ORReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3861,18 +3911,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::ORReduceMasked, Byte256VectorTests::ORReduceAllMasked); + ByteVector256Tests::ORReduceMasked, ByteVector256Tests::ORReduceAllMasked); } static byte XORReduce(byte[] a, int idx) { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3881,14 +3931,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte XORReduceAll(byte[] a) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void XORReduceByte256VectorTests(IntFunction fa) { + static void XORReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3899,12 +3949,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::XORReduce, Byte256VectorTests::XORReduceAll); + ByteVector256Tests::XORReduce, ByteVector256Tests::XORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3912,20 +3962,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = XOR_IDENTITY; - assertEquals((byte) (id ^ id), id, + assertEquals((byte) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id ^ x), x); - assertEquals((byte) (x ^ id), x); + assertEquals((byte) (scalar_xor(id, x)), x); + assertEquals((byte) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id ^ x), x, + assertEquals((byte) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x ^ id), x, + assertEquals((byte) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3934,7 +3984,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3943,14 +3993,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void XORReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3963,18 +4013,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::XORReduceMasked, Byte256VectorTests::XORReduceAllMasked); + ByteVector256Tests::XORReduceMasked, ByteVector256Tests::XORReduceAllMasked); } static byte ADDReduce(byte[] a, int idx) { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3983,14 +4033,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ADDReduceAll(byte[] a) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceByte256VectorTests(IntFunction fa) { + static void ADDReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4001,12 +4051,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::ADDReduce, Byte256VectorTests::ADDReduceAll); + ByteVector256Tests::ADDReduce, ByteVector256Tests::ADDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4014,20 +4064,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = ADD_IDENTITY; - assertEquals((byte) (id + id), id, + assertEquals((byte) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id + x), x); - assertEquals((byte) (x + id), x); + assertEquals((byte) (scalar_add(id, x)), x); + assertEquals((byte) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id + x), x, + assertEquals((byte) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x + id), x, + assertEquals((byte) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4036,7 +4086,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4045,14 +4095,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4065,18 +4115,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::ADDReduceMasked, Byte256VectorTests::ADDReduceAllMasked); + ByteVector256Tests::ADDReduceMasked, ByteVector256Tests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4085,14 +4135,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MULReduceAll(byte[] a) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MULReduceByte256VectorTests(IntFunction fa) { + static void MULReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4103,12 +4153,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::MULReduce, Byte256VectorTests::MULReduceAll); + ByteVector256Tests::MULReduce, ByteVector256Tests::MULReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4116,20 +4166,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MUL_IDENTITY; - assertEquals((byte) (id * id), id, + assertEquals((byte) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id * x), x); - assertEquals((byte) (x * id), x); + assertEquals((byte) (scalar_mul(id, x)), x); + assertEquals((byte) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id * x), x, + assertEquals((byte) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x * id), x, + assertEquals((byte) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4138,7 +4188,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4147,14 +4197,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MULReduceAllMasked(byte[] a, boolean[] mask) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MULReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4167,18 +4217,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::MULReduceMasked, Byte256VectorTests::MULReduceAllMasked); + ByteVector256Tests::MULReduceMasked, ByteVector256Tests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4187,14 +4237,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MINReduceAll(byte[] a) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MINReduceByte256VectorTests(IntFunction fa) { + static void MINReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4205,12 +4255,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::MINReduce, Byte256VectorTests::MINReduceAll); + ByteVector256Tests::MINReduce, ByteVector256Tests::MINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4218,20 +4268,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MIN_IDENTITY; - assertEquals((byte) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.min(id, x), x); - assertEquals((byte) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4240,7 +4290,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4249,14 +4299,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MINReduceAllMasked(byte[] a, boolean[] mask) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4269,18 +4319,18 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::MINReduceMasked, Byte256VectorTests::MINReduceAllMasked); + ByteVector256Tests::MINReduceMasked, ByteVector256Tests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4289,14 +4339,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MAXReduceAll(byte[] a) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MAXReduceByte256VectorTests(IntFunction fa) { + static void MAXReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4307,12 +4357,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::MAXReduce, Byte256VectorTests::MAXReduceAll); + ByteVector256Tests::MAXReduce, ByteVector256Tests::MAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4320,20 +4370,20 @@ public class Byte256VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MAX_IDENTITY; - assertEquals((byte) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.max(id, x), x); - assertEquals((byte) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4342,7 +4392,7 @@ public class Byte256VectorTests extends AbstractVectorTest { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4351,14 +4401,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4371,12 +4421,12 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::MAXReduceMasked, Byte256VectorTests::MAXReduceAllMasked); + ByteVector256Tests::MAXReduceMasked, ByteVector256Tests::MAXReduceAllMasked); } static byte UMINReduce(byte[] a, int idx) { @@ -4398,7 +4448,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMINReduceByte256VectorTests(IntFunction fa) { + static void UMINReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4414,7 +4464,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::UMINReduce, Byte256VectorTests::UMINReduceAll); + ByteVector256Tests::UMINReduce, ByteVector256Tests::UMINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4460,7 +4510,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMINReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4478,7 +4528,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::UMINReduceMasked, Byte256VectorTests::UMINReduceAllMasked); + ByteVector256Tests::UMINReduceMasked, ByteVector256Tests::UMINReduceAllMasked); } static byte UMAXReduce(byte[] a, int idx) { @@ -4500,7 +4550,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMAXReduceByte256VectorTests(IntFunction fa) { + static void UMAXReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4516,7 +4566,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::UMAXReduce, Byte256VectorTests::UMAXReduceAll); + ByteVector256Tests::UMAXReduce, ByteVector256Tests::UMAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4562,7 +4612,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4580,7 +4630,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::UMAXReduceMasked, Byte256VectorTests::UMAXReduceAllMasked); + ByteVector256Tests::UMAXReduceMasked, ByteVector256Tests::UMAXReduceAllMasked); } static byte FIRST_NONZEROReduce(byte[] a, int idx) { @@ -4602,7 +4652,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void FIRST_NONZEROReduceByte256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4618,7 +4668,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::FIRST_NONZEROReduce, Byte256VectorTests::FIRST_NONZEROReduceAll); + ByteVector256Tests::FIRST_NONZEROReduce, ByteVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4664,7 +4714,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void FIRST_NONZEROReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4682,7 +4732,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::FIRST_NONZEROReduceMasked, Byte256VectorTests::FIRST_NONZEROReduceAllMasked); + ByteVector256Tests::FIRST_NONZEROReduceMasked, ByteVector256Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4695,7 +4745,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueByte256VectorTests(IntFunction fm) { + static void anyTrueByteVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4706,7 +4756,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector256Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4719,7 +4769,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueByte256VectorTests(IntFunction fm) { + static void allTrueByteVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4730,7 +4780,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector256Tests::allTrue); } static byte SUADDReduce(byte[] a, int idx) { @@ -4752,7 +4802,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingUnaryOpProvider") - static void SUADDReduceByte256VectorTests(IntFunction fa) { + static void SUADDReduceByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4768,7 +4818,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte256VectorTests::SUADDReduce, Byte256VectorTests::SUADDReduceAll); + ByteVector256Tests::SUADDReduce, ByteVector256Tests::SUADDReduceAll); } @Test(dataProvider = "byteSaturatingUnaryOpProvider") @@ -4813,7 +4863,7 @@ public class Byte256VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider") - static void SUADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4831,11 +4881,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::SUADDReduceMasked, Byte256VectorTests::SUADDReduceAllMasked); + ByteVector256Tests::SUADDReduceMasked, ByteVector256Tests::SUADDReduceAllMasked); } @Test(dataProvider = "byteBinaryOpProvider") - static void withByte256VectorTests(IntFunction fa, IntFunction fb) { + static void withByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -4858,7 +4908,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_DEFAULTByte256VectorTests(IntFunction fa) { + static void IS_DEFAULTByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4875,7 +4925,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_DEFAULTMaskedByte256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4899,7 +4949,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_NEGATIVEByte256VectorTests(IntFunction fa) { + static void IS_NEGATIVEByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4916,7 +4966,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_NEGATIVEMaskedByte256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4936,7 +4986,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void LTByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4955,7 +5005,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ltByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4974,7 +5024,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4997,7 +5047,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void GTByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5016,7 +5066,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5039,7 +5089,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte256VectorTests(IntFunction fa, IntFunction fb) { + static void EQByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5058,7 +5108,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte256VectorTests(IntFunction fa, IntFunction fb) { + static void eqByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5077,7 +5127,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5100,7 +5150,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void NEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void NEByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5119,7 +5169,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void NEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5142,7 +5192,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void LEByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5161,7 +5211,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5184,7 +5234,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void GEByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5203,7 +5253,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5226,7 +5276,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ULTByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5245,7 +5295,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5268,7 +5318,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5287,7 +5337,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5310,7 +5360,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5329,7 +5379,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5352,7 +5402,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteVector256Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5371,7 +5421,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5394,7 +5444,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5404,13 +5454,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5424,13 +5474,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5440,13 +5490,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTByteVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5460,13 +5510,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (byte)((long)b[i])))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5476,13 +5526,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5496,13 +5546,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5512,13 +5562,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQByteVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5532,7 +5582,7 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (byte)((long)b[i])))); } } } @@ -5542,7 +5592,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte256VectorTests(IntFunction fa, IntFunction fb, + static void blendByteVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5558,11 +5608,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte256VectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteVector256Tests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") - static void RearrangeByte256VectorTests(IntFunction fa, + static void RearrangeByteVector256Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5579,7 +5629,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") - static void RearrangeByte256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeByteVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -5597,7 +5647,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void compressByte256VectorTests(IntFunction fa, + static void compressByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5615,7 +5665,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void expandByte256VectorTests(IntFunction fa, + static void expandByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5633,7 +5683,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void getByte256VectorTests(IntFunction fa) { + static void getByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5789,7 +5839,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastByte256VectorTests(IntFunction fa) { + static void BroadcastByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5803,7 +5853,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZeroByte256VectorTests(IntFunction fa) { + static void ZeroByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5828,7 +5878,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void sliceUnaryByte256VectorTests(IntFunction fa) { + static void sliceUnaryByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5839,7 +5889,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteVector256Tests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { @@ -5856,7 +5906,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void sliceBinaryByte256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryByteVector256TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5869,7 +5919,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Byte256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteVector256Tests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { @@ -5886,7 +5936,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void sliceByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5903,7 +5953,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Byte256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ByteVector256Tests::slice); } static byte[] unsliceUnary(byte[] a, int origin, int idx) { @@ -5920,7 +5970,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void unsliceUnaryByte256VectorTests(IntFunction fa) { + static void unsliceUnaryByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5931,7 +5981,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteVector256Tests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { @@ -5957,7 +6007,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void unsliceBinaryByte256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryByteVector256TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5971,7 +6021,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Byte256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteVector256Tests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { @@ -6011,7 +6061,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void unsliceByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6028,7 +6078,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Byte256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteVector256Tests::unslice); } static byte BITWISE_BLEND(byte a, byte b, byte c) { @@ -6040,7 +6090,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6055,11 +6105,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6072,11 +6122,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ByteVector256Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6094,11 +6144,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6109,11 +6159,11 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6124,11 +6174,11 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6139,11 +6189,11 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6154,11 +6204,11 @@ public class Byte256VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6173,11 +6223,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6192,11 +6242,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6207,11 +6257,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6222,11 +6272,11 @@ public class Byte256VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector256Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6240,19 +6290,19 @@ public class Byte256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteVector256Tests::BITWISE_BLEND); } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void NEGByte256VectorTests(IntFunction fa) { + static void NEGByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6263,11 +6313,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::NEG); + assertArraysEquals(r, a, ByteVector256Tests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") - static void negByte256VectorTests(IntFunction fa) { + static void negByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6278,11 +6328,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::neg); + assertArraysEquals(r, a, ByteVector256Tests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NEGMaskedByte256VectorTests(IntFunction fa, + static void NEGMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6296,19 +6346,19 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::NEG); + assertArraysEquals(r, a, mask, ByteVector256Tests::NEG); } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void ABSByte256VectorTests(IntFunction fa) { + static void ABSByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6319,11 +6369,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::ABS); + assertArraysEquals(r, a, ByteVector256Tests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") - static void absByte256VectorTests(IntFunction fa) { + static void absByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6334,11 +6384,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::abs); + assertArraysEquals(r, a, ByteVector256Tests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ABSMaskedByte256VectorTests(IntFunction fa, + static void ABSMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6352,7 +6402,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::ABS); + assertArraysEquals(r, a, mask, ByteVector256Tests::ABS); } static byte NOT(byte a) { @@ -6364,7 +6414,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void NOTByte256VectorTests(IntFunction fa) { + static void NOTByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6375,11 +6425,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::NOT); + assertArraysEquals(r, a, ByteVector256Tests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") - static void notByte256VectorTests(IntFunction fa) { + static void notByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6390,11 +6440,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::not); + assertArraysEquals(r, a, ByteVector256Tests::not); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NOTMaskedByte256VectorTests(IntFunction fa, + static void NOTMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6408,7 +6458,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::NOT); + assertArraysEquals(r, a, mask, ByteVector256Tests::NOT); } static byte ZOMO(byte a) { @@ -6416,7 +6466,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZOMOByte256VectorTests(IntFunction fa) { + static void ZOMOByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6427,11 +6477,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::ZOMO); + assertArraysEquals(r, a, ByteVector256Tests::ZOMO); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ZOMOMaskedByte256VectorTests(IntFunction fa, + static void ZOMOMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6445,7 +6495,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteVector256Tests::ZOMO); } static byte BIT_COUNT(byte a) { @@ -6453,7 +6503,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BIT_COUNTByte256VectorTests(IntFunction fa) { + static void BIT_COUNTByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6464,11 +6514,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ByteVector256Tests::BIT_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void BIT_COUNTMaskedByte256VectorTests(IntFunction fa, + static void BIT_COUNTMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6482,7 +6532,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ByteVector256Tests::BIT_COUNT); } static byte TRAILING_ZEROS_COUNT(byte a) { @@ -6490,7 +6540,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void TRAILING_ZEROS_COUNTByte256VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6501,11 +6551,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector256Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedByte256VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6519,7 +6569,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector256Tests::TRAILING_ZEROS_COUNT); } static byte LEADING_ZEROS_COUNT(byte a) { @@ -6527,7 +6577,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LEADING_ZEROS_COUNTByte256VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6538,11 +6588,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector256Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedByte256VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6556,7 +6606,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector256Tests::LEADING_ZEROS_COUNT); } static byte REVERSE(byte a) { @@ -6564,7 +6614,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSEByte256VectorTests(IntFunction fa) { + static void REVERSEByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6575,11 +6625,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::REVERSE); + assertArraysEquals(r, a, ByteVector256Tests::REVERSE); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSEMaskedByte256VectorTests(IntFunction fa, + static void REVERSEMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6593,7 +6643,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ByteVector256Tests::REVERSE); } static byte REVERSE_BYTES(byte a) { @@ -6601,7 +6651,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSE_BYTESByte256VectorTests(IntFunction fa) { + static void REVERSE_BYTESByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6612,11 +6662,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ByteVector256Tests::REVERSE_BYTES); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedByte256VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedByteVector256Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6630,7 +6680,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ByteVector256Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6638,7 +6688,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6651,7 +6701,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::band); + assertArraysEquals(r, a, b, ByteVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6659,7 +6709,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6672,7 +6722,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::bor); + assertArraysEquals(r, a, b, ByteVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6680,7 +6730,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6693,7 +6743,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::bxor); + assertArraysEquals(r, a, b, ByteVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6701,7 +6751,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6714,7 +6764,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::bandNot); + assertArraysEquals(r, a, b, ByteVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6722,7 +6772,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6735,7 +6785,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte256VectorTests::beq); + assertArraysEquals(r, a, b, ByteVector256Tests::beq); } static boolean unot(boolean a) { @@ -6743,7 +6793,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotByte256VectorTests(IntFunction fa) { + static void masknotByteVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6754,7 +6804,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::unot); + assertArraysEquals(r, a, ByteVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6771,7 +6821,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongByte256VectorTests(IntFunction fa) { + static void maskFromToLongByteVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6785,7 +6835,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltByteVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6795,13 +6845,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqByteVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6811,13 +6861,13 @@ public class Byte256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteUnaryOpProvider") - static void toIntArrayByte256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6828,7 +6878,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toLongArrayByte256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6839,7 +6889,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toDoubleArrayByte256VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6850,7 +6900,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toStringByte256VectorTestsSmokeTest(IntFunction fa) { + static void toStringByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6863,7 +6913,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void hashCodeByte256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6877,7 +6927,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void reinterpretAsBytesByte256VectorTestsSmokeTest(IntFunction fa) { + static void reinterpretAsBytesByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6891,7 +6941,7 @@ public class Byte256VectorTests extends AbstractVectorTest { static long ADDReduceLong(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6900,14 +6950,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(byte[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((byte)res, (byte)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceLongByte256VectorTests(IntFunction fa) { + static void ADDReduceLongByteVector256Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6918,19 +6968,20 @@ public class Byte256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Byte256VectorTests::ADDReduceLong, Byte256VectorTests::ADDReduceAllLong); + ByteVector256Tests::ADDReduceLong, ByteVector256Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6939,14 +6990,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((byte)res, (byte)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceLongByte256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongByteVector256TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6959,16 +7010,16 @@ public class Byte256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Byte256VectorTests::ADDReduceLongMasked, Byte256VectorTests::ADDReduceAllLongMasked); + ByteVector256Tests::ADDReduceLongMasked, ByteVector256Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastLongByte256VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongByteVector256TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6979,7 +7030,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendByteVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6993,12 +7044,12 @@ public class Byte256VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector256Tests::blend); } @Test(dataProvider = "byteUnaryOpSelectFromProvider") - static void SelectFromByte256VectorTests(IntFunction fa, + static void SelectFromByteVector256Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); byte[] order = fs.apply(a.length, SPECIES.length()); @@ -7014,7 +7065,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorByte256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorByteVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] idx = fc.apply(SPECIES.length()); @@ -7032,7 +7083,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") - static void SelectFromByte256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromByteVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -7051,7 +7102,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousByte256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousByteVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7067,7 +7118,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringByte256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringByteVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7081,7 +7132,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsByte256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsByteVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7095,7 +7146,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsByte256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsByteVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7111,7 +7162,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeByte256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeByteVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7133,7 +7184,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountByte256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountByteVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7144,7 +7195,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ByteVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7158,7 +7209,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueByte256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueByteVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7169,7 +7220,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ByteVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7183,7 +7234,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueByte256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueByteVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7194,11 +7245,11 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ByteVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressByte256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressByteVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7226,7 +7277,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeByte256VectorTestsSmokeTest(int offset) { + static void indexInRangeByteVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7240,7 +7291,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongByte256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongByteVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7267,14 +7318,14 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundByte256VectorTestsSmokeTest(int length) { + static void loopBoundByteVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongByte256VectorTestsSmokeTest(int _length) { + static void loopBoundLongByteVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7282,21 +7333,21 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeByte256VectorTestsSmokeTest() { + static void ElementSizeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Byte.SIZE); } @Test - static void VectorShapeByte256VectorTestsSmokeTest() { + static void VectorShapeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesByte256VectorTestsSmokeTest() { + static void ShapeWithLanesByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(byte.class); @@ -7304,32 +7355,32 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeByte256VectorTestsSmokeTest() { + static void ElementTypeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementType() == byte.class); } @Test - static void SpeciesElementSizeByte256VectorTestsSmokeTest() { + static void SpeciesElementSizeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementSize() == Byte.SIZE); } @Test - static void VectorTypeByte256VectorTestsSmokeTest() { + static void VectorTypeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesByte256VectorTestsSmokeTest() { + static void WithLanesByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(byte.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeByte256VectorTestsSmokeTest() { + static void WithShapeByteVector256TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7337,7 +7388,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueByte256VectorTestsSmokeTest() { + static void MaskAllTrueByteVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ByteVector512LoadStoreTests.java index 61168532de0..0a9189927b1 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Byte512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ByteVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Byte512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ByteVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/ByteVector512Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Byte512VectorTests.java rename to test/jdk/jdk/incubator/vector/ByteVector512Tests.java index 711cff6bca3..094f3bbebdc 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Byte512VectorTests extends AbstractVectorTest { +public class ByteVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_512; @@ -1574,6 +1574,59 @@ public class Byte512VectorTests extends AbstractVectorTest { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1590,9 +1643,6 @@ public class Byte512VectorTests extends AbstractVectorTest { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1701,11 +1751,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1718,15 +1768,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::ADD); + assertArraysEquals(r, a, b, ByteVector512Tests::ADD); } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte512VectorTests(IntFunction fa, IntFunction fb) { + static void addByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1737,11 +1787,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::add); + assertArraysEquals(r, a, b, ByteVector512Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1757,11 +1807,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1775,15 +1825,15 @@ public class Byte512VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::add); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::add); } static byte SUB(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void SUBByte512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1796,15 +1846,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::SUB); + assertArraysEquals(r, a, b, ByteVector512Tests::SUB); } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte512VectorTests(IntFunction fa, IntFunction fb) { + static void subByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1815,11 +1865,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::sub); + assertArraysEquals(r, a, b, ByteVector512Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void SUBByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1835,11 +1885,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::SUB); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1853,15 +1903,15 @@ public class Byte512VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::sub); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::sub); } static byte MUL(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MULByte512VectorTests(IntFunction fa, IntFunction fb) { + static void MULByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1874,15 +1924,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::MUL); + assertArraysEquals(r, a, b, ByteVector512Tests::MUL); } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte512VectorTests(IntFunction fa, IntFunction fb) { + static void mulByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1893,11 +1943,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::mul); + assertArraysEquals(r, a, b, ByteVector512Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void MULByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1913,11 +1963,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::MUL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1931,7 +1981,7 @@ public class Byte512VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::mul); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::mul); } static byte DIV(byte a, byte b) { @@ -1939,7 +1989,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void DIVByte512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1954,7 +2004,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::DIV); + assertArraysEquals(r, a, b, ByteVector512Tests::DIV); } static byte div(byte a, byte b) { @@ -1962,7 +2012,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte512VectorTests(IntFunction fa, IntFunction fb) { + static void divByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::div); + assertArraysEquals(r, a, b, ByteVector512Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void DIVByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1999,11 +2049,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::DIV); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2021,15 +2071,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::div); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::div); } static byte FIRST_NONZERO(byte a, byte b) { - return (byte)((a)!=0?a:b); + return (byte)(firstNonZero(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void FIRST_NONZEROByte512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2042,11 +2092,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void FIRST_NONZEROByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2062,7 +2112,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -2070,7 +2120,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ANDByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2083,7 +2133,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::AND); + assertArraysEquals(r, a, b, ByteVector512Tests::AND); } static byte and(byte a, byte b) { @@ -2091,7 +2141,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte512VectorTests(IntFunction fa, IntFunction fb) { + static void andByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2152,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::and); + assertArraysEquals(r, a, b, ByteVector512Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2122,7 +2172,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::AND); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::AND); } static byte AND_NOT(byte a, byte b) { @@ -2130,7 +2180,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void AND_NOTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2143,11 +2193,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ByteVector512Tests::AND_NOT); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void AND_NOTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2163,7 +2213,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::AND_NOT); } static byte OR(byte a, byte b) { @@ -2171,7 +2221,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ORByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2184,7 +2234,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::OR); + assertArraysEquals(r, a, b, ByteVector512Tests::OR); } static byte or(byte a, byte b) { @@ -2192,7 +2242,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte512VectorTests(IntFunction fa, IntFunction fb) { + static void orByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2203,11 +2253,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::or); + assertArraysEquals(r, a, b, ByteVector512Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2223,7 +2273,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::OR); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::OR); } static byte XOR(byte a, byte b) { @@ -2231,7 +2281,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void XORByte512VectorTests(IntFunction fa, IntFunction fb) { + static void XORByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2244,11 +2294,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::XOR); + assertArraysEquals(r, a, b, ByteVector512Tests::XOR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void XORByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2264,11 +2314,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::XOR); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2278,11 +2328,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2295,11 +2345,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::add); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2309,11 +2359,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2326,11 +2376,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::sub); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2340,11 +2390,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2357,11 +2407,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::mul); } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2373,11 +2423,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2392,11 +2442,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::div); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2406,11 +2456,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2420,11 +2470,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2437,11 +2487,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2451,11 +2501,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2465,11 +2515,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2482,11 +2532,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector512Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2496,11 +2546,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteVector512Tests::OR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2513,11 +2563,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector512Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDByteVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2527,11 +2577,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteVector512Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDByteVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2544,7 +2594,7 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector512Tests::ADD); } static byte LSHL(byte a, byte b) { @@ -2552,7 +2602,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2565,11 +2615,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::LSHL); + assertArraysEquals(r, a, b, ByteVector512Tests::LSHL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2585,7 +2635,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::LSHL); } static byte ASHR(byte a, byte b) { @@ -2593,7 +2643,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2606,11 +2656,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::ASHR); + assertArraysEquals(r, a, b, ByteVector512Tests::ASHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2626,7 +2676,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::ASHR); } static byte LSHR(byte a, byte b) { @@ -2634,7 +2684,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2647,11 +2697,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::LSHR); + assertArraysEquals(r, a, b, ByteVector512Tests::LSHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2667,7 +2717,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::LSHR); } static byte LSHL_unary(byte a, byte b) { @@ -2675,7 +2725,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLByteVector512TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2687,11 +2737,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ByteVector512Tests::LSHL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2706,7 +2756,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector512Tests::LSHL_unary); } static byte LSHR_unary(byte a, byte b) { @@ -2714,7 +2764,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRByteVector512TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2726,11 +2776,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector512Tests::LSHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2745,7 +2795,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector512Tests::LSHR_unary); } static byte ASHR_unary(byte a, byte b) { @@ -2753,7 +2803,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRByteVector512TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2765,11 +2815,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector512Tests::ASHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2784,7 +2834,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector512Tests::ASHR_unary); } static byte ROR(byte a, byte b) { @@ -2792,7 +2842,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte512VectorTests(IntFunction fa, IntFunction fb) { + static void RORByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2805,11 +2855,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::ROR); + assertArraysEquals(r, a, b, ByteVector512Tests::ROR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2825,7 +2875,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::ROR); } static byte ROL(byte a, byte b) { @@ -2833,7 +2883,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ROLByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2846,11 +2896,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::ROL); + assertArraysEquals(r, a, b, ByteVector512Tests::ROL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2866,7 +2916,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::ROL); } static byte ROR_unary(byte a, byte b) { @@ -2874,7 +2924,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORByteVector512TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2886,11 +2936,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ByteVector512Tests::ROR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORByteVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2905,7 +2955,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector512Tests::ROR_unary); } static byte ROL_unary(byte a, byte b) { @@ -2913,7 +2963,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLByteVector512TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2925,11 +2975,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ByteVector512Tests::ROL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2944,14 +2994,14 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector512Tests::ROL_unary); } static byte LSHR_binary_const(byte a) { return (byte)(((a & 0xFF) >>> CONST_SHIFT)); } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHRByte512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRByteVector512TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2962,11 +3012,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ByteVector512Tests::LSHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHRByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRByteVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2980,7 +3030,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector512Tests::LSHR_binary_const); } static byte LSHL_binary_const(byte a) { @@ -2988,7 +3038,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHLByte512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLByteVector512TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2999,11 +3049,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ByteVector512Tests::LSHL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHLByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLByteVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3017,7 +3067,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector512Tests::LSHL_binary_const); } static byte ASHR_binary_const(byte a) { @@ -3025,7 +3075,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ASHRByte512VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRByteVector512TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3036,11 +3086,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ByteVector512Tests::ASHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ASHRByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRByteVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3054,7 +3104,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector512Tests::ASHR_binary_const); } static byte ROR_binary_const(byte a) { @@ -3062,7 +3112,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void RORByte512VectorTestsScalarShiftConst(IntFunction fa) { + static void RORByteVector512TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3073,11 +3123,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ByteVector512Tests::ROR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void RORByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORByteVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3091,7 +3141,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector512Tests::ROR_binary_const); } static byte ROL_binary_const(byte a) { @@ -3099,7 +3149,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ROLByte512VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLByteVector512TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3110,11 +3160,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ByteVector512Tests::ROL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ROLByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLByteVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3128,14 +3178,14 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector512Tests::ROL_binary_const); } static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MINByte512VectorTestsWithMemOp(IntFunction fa) { + static void MINByteVector512TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3146,13 +3196,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte512VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, ByteVector512Tests::MIN); } static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void minByte512VectorTestsWithMemOp(IntFunction fa) { + static void minByteVector512TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3163,13 +3213,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte512VectorTests::min); + assertArraysEquals(r, a, (byte)10, ByteVector512Tests::min); } static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINByteVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3182,13 +3232,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte512VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, mask, ByteVector512Tests::MIN); } static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MAXByte512VectorTestsWithMemOp(IntFunction fa) { + static void MAXByteVector512TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3199,13 +3249,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte512VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, ByteVector512Tests::MAX); } static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void maxByte512VectorTestsWithMemOp(IntFunction fa) { + static void maxByteVector512TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3216,13 +3266,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte512VectorTests::max); + assertArraysEquals(r, a, (byte)10, ByteVector512Tests::max); } static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXByteVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3235,15 +3285,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte512VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, mask, ByteVector512Tests::MAX); } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte512VectorTests(IntFunction fa, IntFunction fb) { + static void MINByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3256,15 +3306,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::MIN); + assertArraysEquals(r, a, b, ByteVector512Tests::MIN); } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte512VectorTests(IntFunction fa, IntFunction fb) { + static void minByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3275,15 +3325,15 @@ public class Byte512VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::min); + assertArraysEquals(r, a, b, ByteVector512Tests::min); } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3296,15 +3346,15 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::MAX); + assertArraysEquals(r, a, b, ByteVector512Tests::MAX); } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maxByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3315,7 +3365,7 @@ public class Byte512VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte512VectorTests::max); + assertArraysEquals(r, a, b, ByteVector512Tests::max); } static byte UMIN(byte a, byte b) { @@ -3323,7 +3373,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMINByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UMINByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3336,11 +3386,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::UMIN); + assertArraysEquals(r, a, b, ByteVector512Tests::UMIN); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMINByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3356,7 +3406,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::UMIN); } static byte UMAX(byte a, byte b) { @@ -3364,7 +3414,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMAXByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3377,11 +3427,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::UMAX); + assertArraysEquals(r, a, b, ByteVector512Tests::UMAX); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMAXByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3397,7 +3447,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::UMAX); } static byte SADD(byte a, byte b) { @@ -3405,7 +3455,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SADDByte512VectorTests(IntFunction fa, IntFunction fb) { + static void SADDByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3418,11 +3468,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::SADD); + assertArraysEquals(r, a, b, ByteVector512Tests::SADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SADDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3438,7 +3488,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::SADD); } static byte SSUB(byte a, byte b) { @@ -3446,7 +3496,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SSUBByte512VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3459,11 +3509,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::SSUB); + assertArraysEquals(r, a, b, ByteVector512Tests::SSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SSUBByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3479,7 +3529,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::SSUB); } static byte SUADD(byte a, byte b) { @@ -3487,7 +3537,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUADDByte512VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3500,11 +3550,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::SUADD); + assertArraysEquals(r, a, b, ByteVector512Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUADDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3520,7 +3570,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::SUADD); } static byte SUSUB(byte a, byte b) { @@ -3528,7 +3578,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUSUBByte512VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3541,11 +3591,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::SUSUB); + assertArraysEquals(r, a, b, ByteVector512Tests::SUSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUSUBByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3561,11 +3611,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::SUSUB); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3575,11 +3625,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3589,11 +3639,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::min); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3603,11 +3653,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3617,10 +3667,10 @@ public class Byte512VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteVector512Tests::max); } @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider") - static void SUADDAssocByte512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocByteVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -3637,11 +3687,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Byte512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ByteVector512Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3662,13 +3712,13 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Byte512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteVector512Tests::SUADD); } static byte ANDReduce(byte[] a, int idx) { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3677,14 +3727,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ANDReduceAll(byte[] a) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ANDReduceByte512VectorTests(IntFunction fa) { + static void ANDReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3695,12 +3745,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::ANDReduce, Byte512VectorTests::ANDReduceAll); + ByteVector512Tests::ANDReduce, ByteVector512Tests::ANDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3708,20 +3758,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = AND_IDENTITY; - assertEquals((byte) (id & id), id, + assertEquals((byte) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id & x), x); - assertEquals((byte) (x & id), x); + assertEquals((byte) (scalar_and(id, x)), x); + assertEquals((byte) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id & x), x, + assertEquals((byte) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x & id), x, + assertEquals((byte) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3730,7 +3780,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3739,14 +3789,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ANDReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3759,18 +3809,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::ANDReduceMasked, Byte512VectorTests::ANDReduceAllMasked); + ByteVector512Tests::ANDReduceMasked, ByteVector512Tests::ANDReduceAllMasked); } static byte ORReduce(byte[] a, int idx) { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3779,14 +3829,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ORReduceAll(byte[] a) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ORReduceByte512VectorTests(IntFunction fa) { + static void ORReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3797,12 +3847,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::ORReduce, Byte512VectorTests::ORReduceAll); + ByteVector512Tests::ORReduce, ByteVector512Tests::ORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3810,20 +3860,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = OR_IDENTITY; - assertEquals((byte) (id | id), id, + assertEquals((byte) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id | x), x); - assertEquals((byte) (x | id), x); + assertEquals((byte) (scalar_or(id, x)), x); + assertEquals((byte) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id | x), x, + assertEquals((byte) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x | id), x, + assertEquals((byte) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3832,7 +3882,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3841,14 +3891,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ORReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3861,18 +3911,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::ORReduceMasked, Byte512VectorTests::ORReduceAllMasked); + ByteVector512Tests::ORReduceMasked, ByteVector512Tests::ORReduceAllMasked); } static byte XORReduce(byte[] a, int idx) { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3881,14 +3931,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte XORReduceAll(byte[] a) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void XORReduceByte512VectorTests(IntFunction fa) { + static void XORReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3899,12 +3949,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::XORReduce, Byte512VectorTests::XORReduceAll); + ByteVector512Tests::XORReduce, ByteVector512Tests::XORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3912,20 +3962,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = XOR_IDENTITY; - assertEquals((byte) (id ^ id), id, + assertEquals((byte) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id ^ x), x); - assertEquals((byte) (x ^ id), x); + assertEquals((byte) (scalar_xor(id, x)), x); + assertEquals((byte) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id ^ x), x, + assertEquals((byte) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x ^ id), x, + assertEquals((byte) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3934,7 +3984,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3943,14 +3993,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void XORReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3963,18 +4013,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::XORReduceMasked, Byte512VectorTests::XORReduceAllMasked); + ByteVector512Tests::XORReduceMasked, ByteVector512Tests::XORReduceAllMasked); } static byte ADDReduce(byte[] a, int idx) { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3983,14 +4033,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ADDReduceAll(byte[] a) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceByte512VectorTests(IntFunction fa) { + static void ADDReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4001,12 +4051,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::ADDReduce, Byte512VectorTests::ADDReduceAll); + ByteVector512Tests::ADDReduce, ByteVector512Tests::ADDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4014,20 +4064,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = ADD_IDENTITY; - assertEquals((byte) (id + id), id, + assertEquals((byte) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id + x), x); - assertEquals((byte) (x + id), x); + assertEquals((byte) (scalar_add(id, x)), x); + assertEquals((byte) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id + x), x, + assertEquals((byte) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x + id), x, + assertEquals((byte) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4036,7 +4086,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4045,14 +4095,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4065,18 +4115,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::ADDReduceMasked, Byte512VectorTests::ADDReduceAllMasked); + ByteVector512Tests::ADDReduceMasked, ByteVector512Tests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4085,14 +4135,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MULReduceAll(byte[] a) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MULReduceByte512VectorTests(IntFunction fa) { + static void MULReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4103,12 +4153,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::MULReduce, Byte512VectorTests::MULReduceAll); + ByteVector512Tests::MULReduce, ByteVector512Tests::MULReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4116,20 +4166,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MUL_IDENTITY; - assertEquals((byte) (id * id), id, + assertEquals((byte) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id * x), x); - assertEquals((byte) (x * id), x); + assertEquals((byte) (scalar_mul(id, x)), x); + assertEquals((byte) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id * x), x, + assertEquals((byte) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x * id), x, + assertEquals((byte) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4138,7 +4188,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4147,14 +4197,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MULReduceAllMasked(byte[] a, boolean[] mask) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MULReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4167,18 +4217,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::MULReduceMasked, Byte512VectorTests::MULReduceAllMasked); + ByteVector512Tests::MULReduceMasked, ByteVector512Tests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4187,14 +4237,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MINReduceAll(byte[] a) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MINReduceByte512VectorTests(IntFunction fa) { + static void MINReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4205,12 +4255,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::MINReduce, Byte512VectorTests::MINReduceAll); + ByteVector512Tests::MINReduce, ByteVector512Tests::MINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4218,20 +4268,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MIN_IDENTITY; - assertEquals((byte) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.min(id, x), x); - assertEquals((byte) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4240,7 +4290,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4249,14 +4299,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MINReduceAllMasked(byte[] a, boolean[] mask) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4269,18 +4319,18 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::MINReduceMasked, Byte512VectorTests::MINReduceAllMasked); + ByteVector512Tests::MINReduceMasked, ByteVector512Tests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4289,14 +4339,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MAXReduceAll(byte[] a) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MAXReduceByte512VectorTests(IntFunction fa) { + static void MAXReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4307,12 +4357,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::MAXReduce, Byte512VectorTests::MAXReduceAll); + ByteVector512Tests::MAXReduce, ByteVector512Tests::MAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4320,20 +4370,20 @@ public class Byte512VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MAX_IDENTITY; - assertEquals((byte) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.max(id, x), x); - assertEquals((byte) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4342,7 +4392,7 @@ public class Byte512VectorTests extends AbstractVectorTest { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4351,14 +4401,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4371,12 +4421,12 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::MAXReduceMasked, Byte512VectorTests::MAXReduceAllMasked); + ByteVector512Tests::MAXReduceMasked, ByteVector512Tests::MAXReduceAllMasked); } static byte UMINReduce(byte[] a, int idx) { @@ -4398,7 +4448,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMINReduceByte512VectorTests(IntFunction fa) { + static void UMINReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4414,7 +4464,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::UMINReduce, Byte512VectorTests::UMINReduceAll); + ByteVector512Tests::UMINReduce, ByteVector512Tests::UMINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4460,7 +4510,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMINReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4478,7 +4528,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::UMINReduceMasked, Byte512VectorTests::UMINReduceAllMasked); + ByteVector512Tests::UMINReduceMasked, ByteVector512Tests::UMINReduceAllMasked); } static byte UMAXReduce(byte[] a, int idx) { @@ -4500,7 +4550,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMAXReduceByte512VectorTests(IntFunction fa) { + static void UMAXReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4516,7 +4566,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::UMAXReduce, Byte512VectorTests::UMAXReduceAll); + ByteVector512Tests::UMAXReduce, ByteVector512Tests::UMAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4562,7 +4612,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4580,7 +4630,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::UMAXReduceMasked, Byte512VectorTests::UMAXReduceAllMasked); + ByteVector512Tests::UMAXReduceMasked, ByteVector512Tests::UMAXReduceAllMasked); } static byte FIRST_NONZEROReduce(byte[] a, int idx) { @@ -4602,7 +4652,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void FIRST_NONZEROReduceByte512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4618,7 +4668,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::FIRST_NONZEROReduce, Byte512VectorTests::FIRST_NONZEROReduceAll); + ByteVector512Tests::FIRST_NONZEROReduce, ByteVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4664,7 +4714,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void FIRST_NONZEROReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4682,7 +4732,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::FIRST_NONZEROReduceMasked, Byte512VectorTests::FIRST_NONZEROReduceAllMasked); + ByteVector512Tests::FIRST_NONZEROReduceMasked, ByteVector512Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4695,7 +4745,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueByte512VectorTests(IntFunction fm) { + static void anyTrueByteVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4706,7 +4756,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector512Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4719,7 +4769,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueByte512VectorTests(IntFunction fm) { + static void allTrueByteVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4730,7 +4780,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector512Tests::allTrue); } static byte SUADDReduce(byte[] a, int idx) { @@ -4752,7 +4802,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingUnaryOpProvider") - static void SUADDReduceByte512VectorTests(IntFunction fa) { + static void SUADDReduceByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4768,7 +4818,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte512VectorTests::SUADDReduce, Byte512VectorTests::SUADDReduceAll); + ByteVector512Tests::SUADDReduce, ByteVector512Tests::SUADDReduceAll); } @Test(dataProvider = "byteSaturatingUnaryOpProvider") @@ -4813,7 +4863,7 @@ public class Byte512VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider") - static void SUADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4831,11 +4881,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::SUADDReduceMasked, Byte512VectorTests::SUADDReduceAllMasked); + ByteVector512Tests::SUADDReduceMasked, ByteVector512Tests::SUADDReduceAllMasked); } @Test(dataProvider = "byteBinaryOpProvider") - static void withByte512VectorTests(IntFunction fa, IntFunction fb) { + static void withByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -4858,7 +4908,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_DEFAULTByte512VectorTests(IntFunction fa) { + static void IS_DEFAULTByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4875,7 +4925,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_DEFAULTMaskedByte512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4899,7 +4949,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_NEGATIVEByte512VectorTests(IntFunction fa) { + static void IS_NEGATIVEByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4916,7 +4966,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_NEGATIVEMaskedByte512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4936,7 +4986,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void LTByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4955,7 +5005,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ltByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4974,7 +5024,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4997,7 +5047,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void GTByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5016,7 +5066,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5039,7 +5089,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte512VectorTests(IntFunction fa, IntFunction fb) { + static void EQByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5058,7 +5108,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte512VectorTests(IntFunction fa, IntFunction fb) { + static void eqByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5077,7 +5127,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5100,7 +5150,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void NEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void NEByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5119,7 +5169,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void NEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5142,7 +5192,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void LEByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5161,7 +5211,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5184,7 +5234,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void GEByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5203,7 +5253,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5226,7 +5276,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ULTByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5245,7 +5295,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5268,7 +5318,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5287,7 +5337,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5310,7 +5360,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5329,7 +5379,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5352,7 +5402,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteVector512Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5371,7 +5421,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5394,7 +5444,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5404,13 +5454,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5424,13 +5474,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5440,13 +5490,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTByteVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5460,13 +5510,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (byte)((long)b[i])))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5476,13 +5526,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5496,13 +5546,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5512,13 +5562,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQByteVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5532,7 +5582,7 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (byte)((long)b[i])))); } } } @@ -5542,7 +5592,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte512VectorTests(IntFunction fa, IntFunction fb, + static void blendByteVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5558,11 +5608,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte512VectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteVector512Tests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") - static void RearrangeByte512VectorTests(IntFunction fa, + static void RearrangeByteVector512Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5579,7 +5629,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") - static void RearrangeByte512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeByteVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -5597,7 +5647,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void compressByte512VectorTests(IntFunction fa, + static void compressByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5615,7 +5665,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void expandByte512VectorTests(IntFunction fa, + static void expandByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5633,7 +5683,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void getByte512VectorTests(IntFunction fa) { + static void getByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5789,7 +5839,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastByte512VectorTests(IntFunction fa) { + static void BroadcastByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5803,7 +5853,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZeroByte512VectorTests(IntFunction fa) { + static void ZeroByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5828,7 +5878,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void sliceUnaryByte512VectorTests(IntFunction fa) { + static void sliceUnaryByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5839,7 +5889,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteVector512Tests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { @@ -5856,7 +5906,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void sliceBinaryByte512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryByteVector512TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5869,7 +5919,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Byte512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteVector512Tests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { @@ -5886,7 +5936,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void sliceByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5903,7 +5953,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Byte512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ByteVector512Tests::slice); } static byte[] unsliceUnary(byte[] a, int origin, int idx) { @@ -5920,7 +5970,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void unsliceUnaryByte512VectorTests(IntFunction fa) { + static void unsliceUnaryByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5931,7 +5981,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteVector512Tests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { @@ -5957,7 +6007,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void unsliceBinaryByte512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryByteVector512TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5971,7 +6021,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Byte512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteVector512Tests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { @@ -6011,7 +6061,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void unsliceByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6028,7 +6078,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Byte512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteVector512Tests::unslice); } static byte BITWISE_BLEND(byte a, byte b, byte c) { @@ -6040,7 +6090,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6055,11 +6105,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Byte512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6072,11 +6122,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Byte512VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ByteVector512Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6094,11 +6144,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Byte512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6109,11 +6159,11 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6124,11 +6174,11 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6139,11 +6189,11 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6154,11 +6204,11 @@ public class Byte512VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6173,11 +6223,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Byte512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6192,11 +6242,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Byte512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6207,11 +6257,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6222,11 +6272,11 @@ public class Byte512VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte512VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector512Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6240,19 +6290,19 @@ public class Byte512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Byte512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteVector512Tests::BITWISE_BLEND); } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void NEGByte512VectorTests(IntFunction fa) { + static void NEGByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6263,11 +6313,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::NEG); + assertArraysEquals(r, a, ByteVector512Tests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") - static void negByte512VectorTests(IntFunction fa) { + static void negByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6278,11 +6328,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::neg); + assertArraysEquals(r, a, ByteVector512Tests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NEGMaskedByte512VectorTests(IntFunction fa, + static void NEGMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6296,19 +6346,19 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::NEG); + assertArraysEquals(r, a, mask, ByteVector512Tests::NEG); } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void ABSByte512VectorTests(IntFunction fa) { + static void ABSByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6319,11 +6369,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::ABS); + assertArraysEquals(r, a, ByteVector512Tests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") - static void absByte512VectorTests(IntFunction fa) { + static void absByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6334,11 +6384,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::abs); + assertArraysEquals(r, a, ByteVector512Tests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ABSMaskedByte512VectorTests(IntFunction fa, + static void ABSMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6352,7 +6402,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::ABS); + assertArraysEquals(r, a, mask, ByteVector512Tests::ABS); } static byte NOT(byte a) { @@ -6364,7 +6414,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void NOTByte512VectorTests(IntFunction fa) { + static void NOTByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6375,11 +6425,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::NOT); + assertArraysEquals(r, a, ByteVector512Tests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") - static void notByte512VectorTests(IntFunction fa) { + static void notByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6390,11 +6440,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::not); + assertArraysEquals(r, a, ByteVector512Tests::not); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NOTMaskedByte512VectorTests(IntFunction fa, + static void NOTMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6408,7 +6458,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::NOT); + assertArraysEquals(r, a, mask, ByteVector512Tests::NOT); } static byte ZOMO(byte a) { @@ -6416,7 +6466,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZOMOByte512VectorTests(IntFunction fa) { + static void ZOMOByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6427,11 +6477,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::ZOMO); + assertArraysEquals(r, a, ByteVector512Tests::ZOMO); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ZOMOMaskedByte512VectorTests(IntFunction fa, + static void ZOMOMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6445,7 +6495,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteVector512Tests::ZOMO); } static byte BIT_COUNT(byte a) { @@ -6453,7 +6503,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BIT_COUNTByte512VectorTests(IntFunction fa) { + static void BIT_COUNTByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6464,11 +6514,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ByteVector512Tests::BIT_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void BIT_COUNTMaskedByte512VectorTests(IntFunction fa, + static void BIT_COUNTMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6482,7 +6532,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ByteVector512Tests::BIT_COUNT); } static byte TRAILING_ZEROS_COUNT(byte a) { @@ -6490,7 +6540,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void TRAILING_ZEROS_COUNTByte512VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6501,11 +6551,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector512Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedByte512VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6519,7 +6569,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector512Tests::TRAILING_ZEROS_COUNT); } static byte LEADING_ZEROS_COUNT(byte a) { @@ -6527,7 +6577,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LEADING_ZEROS_COUNTByte512VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6538,11 +6588,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector512Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedByte512VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6556,7 +6606,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector512Tests::LEADING_ZEROS_COUNT); } static byte REVERSE(byte a) { @@ -6564,7 +6614,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSEByte512VectorTests(IntFunction fa) { + static void REVERSEByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6575,11 +6625,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::REVERSE); + assertArraysEquals(r, a, ByteVector512Tests::REVERSE); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSEMaskedByte512VectorTests(IntFunction fa, + static void REVERSEMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6593,7 +6643,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ByteVector512Tests::REVERSE); } static byte REVERSE_BYTES(byte a) { @@ -6601,7 +6651,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSE_BYTESByte512VectorTests(IntFunction fa) { + static void REVERSE_BYTESByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6612,11 +6662,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ByteVector512Tests::REVERSE_BYTES); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedByte512VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedByteVector512Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6630,7 +6680,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ByteVector512Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6638,7 +6688,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6651,7 +6701,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::band); + assertArraysEquals(r, a, b, ByteVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6659,7 +6709,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6672,7 +6722,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::bor); + assertArraysEquals(r, a, b, ByteVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6680,7 +6730,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6693,7 +6743,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::bxor); + assertArraysEquals(r, a, b, ByteVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6701,7 +6751,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6714,7 +6764,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::bandNot); + assertArraysEquals(r, a, b, ByteVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6722,7 +6772,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6735,7 +6785,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte512VectorTests::beq); + assertArraysEquals(r, a, b, ByteVector512Tests::beq); } static boolean unot(boolean a) { @@ -6743,7 +6793,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotByte512VectorTests(IntFunction fa) { + static void masknotByteVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6754,7 +6804,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::unot); + assertArraysEquals(r, a, ByteVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6771,7 +6821,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongByte512VectorTests(IntFunction fa) { + static void maskFromToLongByteVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6785,7 +6835,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltByteVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6795,13 +6845,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqByteVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6811,13 +6861,13 @@ public class Byte512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteUnaryOpProvider") - static void toIntArrayByte512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6828,7 +6878,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toLongArrayByte512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6839,7 +6889,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toDoubleArrayByte512VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6850,7 +6900,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toStringByte512VectorTestsSmokeTest(IntFunction fa) { + static void toStringByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6863,7 +6913,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void hashCodeByte512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6877,7 +6927,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void reinterpretAsBytesByte512VectorTestsSmokeTest(IntFunction fa) { + static void reinterpretAsBytesByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6891,7 +6941,7 @@ public class Byte512VectorTests extends AbstractVectorTest { static long ADDReduceLong(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6900,14 +6950,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(byte[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((byte)res, (byte)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceLongByte512VectorTests(IntFunction fa) { + static void ADDReduceLongByteVector512Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6918,19 +6968,20 @@ public class Byte512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Byte512VectorTests::ADDReduceLong, Byte512VectorTests::ADDReduceAllLong); + ByteVector512Tests::ADDReduceLong, ByteVector512Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6939,14 +6990,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((byte)res, (byte)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceLongByte512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongByteVector512TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6959,16 +7010,16 @@ public class Byte512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Byte512VectorTests::ADDReduceLongMasked, Byte512VectorTests::ADDReduceAllLongMasked); + ByteVector512Tests::ADDReduceLongMasked, ByteVector512Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastLongByte512VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongByteVector512TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6979,7 +7030,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendByteVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6993,12 +7044,12 @@ public class Byte512VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector512Tests::blend); } @Test(dataProvider = "byteUnaryOpSelectFromProvider") - static void SelectFromByte512VectorTests(IntFunction fa, + static void SelectFromByteVector512Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); byte[] order = fs.apply(a.length, SPECIES.length()); @@ -7014,7 +7065,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorByte512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorByteVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] idx = fc.apply(SPECIES.length()); @@ -7032,7 +7083,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") - static void SelectFromByte512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromByteVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -7051,7 +7102,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousByte512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousByteVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7067,7 +7118,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringByte512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringByteVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7081,7 +7132,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsByte512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsByteVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7095,7 +7146,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsByte512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsByteVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7111,7 +7162,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeByte512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeByteVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7133,7 +7184,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountByte512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountByteVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7144,7 +7195,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ByteVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7158,7 +7209,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueByte512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueByteVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7169,7 +7220,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ByteVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7183,7 +7234,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueByte512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueByteVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7194,11 +7245,11 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ByteVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressByte512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressByteVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7226,7 +7277,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeByte512VectorTestsSmokeTest(int offset) { + static void indexInRangeByteVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7240,7 +7291,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongByte512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongByteVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7267,14 +7318,14 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundByte512VectorTestsSmokeTest(int length) { + static void loopBoundByteVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongByte512VectorTestsSmokeTest(int _length) { + static void loopBoundLongByteVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7282,21 +7333,21 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeByte512VectorTestsSmokeTest() { + static void ElementSizeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Byte.SIZE); } @Test - static void VectorShapeByte512VectorTestsSmokeTest() { + static void VectorShapeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesByte512VectorTestsSmokeTest() { + static void ShapeWithLanesByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(byte.class); @@ -7304,32 +7355,32 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeByte512VectorTestsSmokeTest() { + static void ElementTypeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementType() == byte.class); } @Test - static void SpeciesElementSizeByte512VectorTestsSmokeTest() { + static void SpeciesElementSizeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementSize() == Byte.SIZE); } @Test - static void VectorTypeByte512VectorTestsSmokeTest() { + static void VectorTypeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesByte512VectorTestsSmokeTest() { + static void WithLanesByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(byte.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeByte512VectorTestsSmokeTest() { + static void WithShapeByteVector512TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7337,7 +7388,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueByte512VectorTestsSmokeTest() { + static void MaskAllTrueByteVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ByteVector64LoadStoreTests.java index 9b0687c73f2..2b9637d28dc 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Byte64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ByteVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Byte64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ByteVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/ByteVector64Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Byte64VectorTests.java rename to test/jdk/jdk/incubator/vector/ByteVector64Tests.java index b71d642d447..e8ff81678cd 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Byte64VectorTests extends AbstractVectorTest { +public class ByteVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_64; @@ -1574,6 +1574,59 @@ public class Byte64VectorTests extends AbstractVectorTest { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1590,9 +1643,6 @@ public class Byte64VectorTests extends AbstractVectorTest { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1701,11 +1751,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1718,15 +1768,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::ADD); + assertArraysEquals(r, a, b, ByteVector64Tests::ADD); } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte64VectorTests(IntFunction fa, IntFunction fb) { + static void addByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1737,11 +1787,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::add); + assertArraysEquals(r, a, b, ByteVector64Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1757,11 +1807,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1775,15 +1825,15 @@ public class Byte64VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::add); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::add); } static byte SUB(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void SUBByte64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1796,15 +1846,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::SUB); + assertArraysEquals(r, a, b, ByteVector64Tests::SUB); } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte64VectorTests(IntFunction fa, IntFunction fb) { + static void subByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1815,11 +1865,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::sub); + assertArraysEquals(r, a, b, ByteVector64Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void SUBByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1835,11 +1885,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::SUB); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1853,15 +1903,15 @@ public class Byte64VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::sub); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::sub); } static byte MUL(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MULByte64VectorTests(IntFunction fa, IntFunction fb) { + static void MULByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1874,15 +1924,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::MUL); + assertArraysEquals(r, a, b, ByteVector64Tests::MUL); } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte64VectorTests(IntFunction fa, IntFunction fb) { + static void mulByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1893,11 +1943,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::mul); + assertArraysEquals(r, a, b, ByteVector64Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void MULByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1913,11 +1963,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::MUL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1931,7 +1981,7 @@ public class Byte64VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::mul); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::mul); } static byte DIV(byte a, byte b) { @@ -1939,7 +1989,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void DIVByte64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1954,7 +2004,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::DIV); + assertArraysEquals(r, a, b, ByteVector64Tests::DIV); } static byte div(byte a, byte b) { @@ -1962,7 +2012,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte64VectorTests(IntFunction fa, IntFunction fb) { + static void divByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::div); + assertArraysEquals(r, a, b, ByteVector64Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void DIVByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1999,11 +2049,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::DIV); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2021,15 +2071,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::div); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::div); } static byte FIRST_NONZERO(byte a, byte b) { - return (byte)((a)!=0?a:b); + return (byte)(firstNonZero(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void FIRST_NONZEROByte64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2042,11 +2092,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void FIRST_NONZEROByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2062,7 +2112,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -2070,7 +2120,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ANDByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2083,7 +2133,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::AND); + assertArraysEquals(r, a, b, ByteVector64Tests::AND); } static byte and(byte a, byte b) { @@ -2091,7 +2141,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte64VectorTests(IntFunction fa, IntFunction fb) { + static void andByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2152,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::and); + assertArraysEquals(r, a, b, ByteVector64Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2122,7 +2172,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::AND); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::AND); } static byte AND_NOT(byte a, byte b) { @@ -2130,7 +2180,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void AND_NOTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2143,11 +2193,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ByteVector64Tests::AND_NOT); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void AND_NOTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2163,7 +2213,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::AND_NOT); } static byte OR(byte a, byte b) { @@ -2171,7 +2221,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ORByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2184,7 +2234,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::OR); + assertArraysEquals(r, a, b, ByteVector64Tests::OR); } static byte or(byte a, byte b) { @@ -2192,7 +2242,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte64VectorTests(IntFunction fa, IntFunction fb) { + static void orByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2203,11 +2253,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::or); + assertArraysEquals(r, a, b, ByteVector64Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2223,7 +2273,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::OR); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::OR); } static byte XOR(byte a, byte b) { @@ -2231,7 +2281,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void XORByte64VectorTests(IntFunction fa, IntFunction fb) { + static void XORByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2244,11 +2294,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::XOR); + assertArraysEquals(r, a, b, ByteVector64Tests::XOR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void XORByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2264,11 +2314,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::XOR); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2278,11 +2328,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2295,11 +2345,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::add); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2309,11 +2359,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2326,11 +2376,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::sub); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2340,11 +2390,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2357,11 +2407,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::mul); } @Test(dataProvider = "byteBinaryOpProvider") - static void divByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2373,11 +2423,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2392,11 +2442,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::div); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2406,11 +2456,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void orByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2420,11 +2470,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2437,11 +2487,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2451,11 +2501,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void andByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2465,11 +2515,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2482,11 +2532,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Byte64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteVector64Tests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2496,11 +2546,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteVector64Tests::OR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByte64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2513,11 +2563,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector64Tests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDByteVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2527,11 +2577,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Byte64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteVector64Tests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByte64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDByteVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2544,7 +2594,7 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector64Tests::ADD); } static byte LSHL(byte a, byte b) { @@ -2552,7 +2602,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2565,11 +2615,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::LSHL); + assertArraysEquals(r, a, b, ByteVector64Tests::LSHL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2585,7 +2635,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::LSHL); } static byte ASHR(byte a, byte b) { @@ -2593,7 +2643,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2606,11 +2656,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::ASHR); + assertArraysEquals(r, a, b, ByteVector64Tests::ASHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2626,7 +2676,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::ASHR); } static byte LSHR(byte a, byte b) { @@ -2634,7 +2684,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2647,11 +2697,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::LSHR); + assertArraysEquals(r, a, b, ByteVector64Tests::LSHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2667,7 +2717,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::LSHR); } static byte LSHL_unary(byte a, byte b) { @@ -2675,7 +2725,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByte64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLByteVector64TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2687,11 +2737,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ByteVector64Tests::LSHL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByte64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2706,7 +2756,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector64Tests::LSHL_unary); } static byte LSHR_unary(byte a, byte b) { @@ -2714,7 +2764,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByte64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRByteVector64TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2726,11 +2776,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector64Tests::LSHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByte64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2745,7 +2795,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector64Tests::LSHR_unary); } static byte ASHR_unary(byte a, byte b) { @@ -2753,7 +2803,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByte64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRByteVector64TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2765,11 +2815,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ByteVector64Tests::ASHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByte64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2784,7 +2834,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector64Tests::ASHR_unary); } static byte ROR(byte a, byte b) { @@ -2792,7 +2842,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte64VectorTests(IntFunction fa, IntFunction fb) { + static void RORByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2805,11 +2855,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::ROR); + assertArraysEquals(r, a, b, ByteVector64Tests::ROR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2825,7 +2875,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::ROR); } static byte ROL(byte a, byte b) { @@ -2833,7 +2883,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ROLByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2846,11 +2896,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::ROL); + assertArraysEquals(r, a, b, ByteVector64Tests::ROL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2866,7 +2916,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::ROL); } static byte ROR_unary(byte a, byte b) { @@ -2874,7 +2924,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByte64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORByteVector64TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2886,11 +2936,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ByteVector64Tests::ROR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByte64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORByteVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2905,7 +2955,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector64Tests::ROR_unary); } static byte ROL_unary(byte a, byte b) { @@ -2913,7 +2963,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByte64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLByteVector64TestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2925,11 +2975,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Byte64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ByteVector64Tests::ROL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByte64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLByteVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2944,14 +2994,14 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVector64Tests::ROL_unary); } static byte LSHR_binary_const(byte a) { return (byte)(((a & 0xFF) >>> CONST_SHIFT)); } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHRByte64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRByteVector64TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2962,11 +3012,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ByteVector64Tests::LSHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHRByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRByteVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2980,7 +3030,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector64Tests::LSHR_binary_const); } static byte LSHL_binary_const(byte a) { @@ -2988,7 +3038,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHLByte64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLByteVector64TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2999,11 +3049,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ByteVector64Tests::LSHL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHLByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLByteVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3017,7 +3067,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector64Tests::LSHL_binary_const); } static byte ASHR_binary_const(byte a) { @@ -3025,7 +3075,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ASHRByte64VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRByteVector64TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3036,11 +3086,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ByteVector64Tests::ASHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ASHRByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRByteVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3054,7 +3104,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector64Tests::ASHR_binary_const); } static byte ROR_binary_const(byte a) { @@ -3062,7 +3112,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void RORByte64VectorTestsScalarShiftConst(IntFunction fa) { + static void RORByteVector64TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3073,11 +3123,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ByteVector64Tests::ROR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void RORByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORByteVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3091,7 +3141,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector64Tests::ROR_binary_const); } static byte ROL_binary_const(byte a) { @@ -3099,7 +3149,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ROLByte64VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLByteVector64TestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3110,11 +3160,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Byte64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ByteVector64Tests::ROL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ROLByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLByteVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3128,14 +3178,14 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Byte64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVector64Tests::ROL_binary_const); } static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MINByte64VectorTestsWithMemOp(IntFunction fa) { + static void MINByteVector64TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3146,13 +3196,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte64VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, ByteVector64Tests::MIN); } static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void minByte64VectorTestsWithMemOp(IntFunction fa) { + static void minByteVector64TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3163,13 +3213,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte64VectorTests::min); + assertArraysEquals(r, a, (byte)10, ByteVector64Tests::min); } static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINByteVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3182,13 +3232,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte64VectorTests::MIN); + assertArraysEquals(r, a, (byte)10, mask, ByteVector64Tests::MIN); } static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MAXByte64VectorTestsWithMemOp(IntFunction fa) { + static void MAXByteVector64TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3199,13 +3249,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte64VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, ByteVector64Tests::MAX); } static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void maxByte64VectorTestsWithMemOp(IntFunction fa) { + static void maxByteVector64TestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3216,13 +3266,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, Byte64VectorTests::max); + assertArraysEquals(r, a, (byte)10, ByteVector64Tests::max); } static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXByteVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3235,15 +3285,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, Byte64VectorTests::MAX); + assertArraysEquals(r, a, (byte)10, mask, ByteVector64Tests::MAX); } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte64VectorTests(IntFunction fa, IntFunction fb) { + static void MINByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3256,15 +3306,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::MIN); + assertArraysEquals(r, a, b, ByteVector64Tests::MIN); } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte64VectorTests(IntFunction fa, IntFunction fb) { + static void minByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3275,15 +3325,15 @@ public class Byte64VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::min); + assertArraysEquals(r, a, b, ByteVector64Tests::min); } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3296,15 +3346,15 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::MAX); + assertArraysEquals(r, a, b, ByteVector64Tests::MAX); } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maxByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3315,7 +3365,7 @@ public class Byte64VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Byte64VectorTests::max); + assertArraysEquals(r, a, b, ByteVector64Tests::max); } static byte UMIN(byte a, byte b) { @@ -3323,7 +3373,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMINByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UMINByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3336,11 +3386,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::UMIN); + assertArraysEquals(r, a, b, ByteVector64Tests::UMIN); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMINByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3356,7 +3406,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::UMIN); } static byte UMAX(byte a, byte b) { @@ -3364,7 +3414,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMAXByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3377,11 +3427,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::UMAX); + assertArraysEquals(r, a, b, ByteVector64Tests::UMAX); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMAXByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3397,7 +3447,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::UMAX); } static byte SADD(byte a, byte b) { @@ -3405,7 +3455,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SADDByte64VectorTests(IntFunction fa, IntFunction fb) { + static void SADDByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3418,11 +3468,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::SADD); + assertArraysEquals(r, a, b, ByteVector64Tests::SADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SADDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3438,7 +3488,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::SADD); } static byte SSUB(byte a, byte b) { @@ -3446,7 +3496,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SSUBByte64VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3459,11 +3509,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::SSUB); + assertArraysEquals(r, a, b, ByteVector64Tests::SSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SSUBByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3479,7 +3529,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::SSUB); } static byte SUADD(byte a, byte b) { @@ -3487,7 +3537,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUADDByte64VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3500,11 +3550,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::SUADD); + assertArraysEquals(r, a, b, ByteVector64Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUADDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3520,7 +3570,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::SUADD); } static byte SUSUB(byte a, byte b) { @@ -3528,7 +3578,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUSUBByte64VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3541,11 +3591,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::SUSUB); + assertArraysEquals(r, a, b, ByteVector64Tests::SUSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUSUBByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3561,11 +3611,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::SUSUB); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3575,11 +3625,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3589,11 +3639,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::min); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3603,11 +3653,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3617,10 +3667,10 @@ public class Byte64VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Byte64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteVector64Tests::max); } @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider") - static void SUADDAssocByte64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocByteVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -3637,11 +3687,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Byte64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ByteVector64Tests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3662,13 +3712,13 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Byte64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteVector64Tests::SUADD); } static byte ANDReduce(byte[] a, int idx) { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3677,14 +3727,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ANDReduceAll(byte[] a) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ANDReduceByte64VectorTests(IntFunction fa) { + static void ANDReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3695,12 +3745,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::ANDReduce, Byte64VectorTests::ANDReduceAll); + ByteVector64Tests::ANDReduce, ByteVector64Tests::ANDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3708,20 +3758,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = AND_IDENTITY; - assertEquals((byte) (id & id), id, + assertEquals((byte) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id & x), x); - assertEquals((byte) (x & id), x); + assertEquals((byte) (scalar_and(id, x)), x); + assertEquals((byte) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id & x), x, + assertEquals((byte) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x & id), x, + assertEquals((byte) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3730,7 +3780,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3739,14 +3789,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ANDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3759,18 +3809,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::ANDReduceMasked, Byte64VectorTests::ANDReduceAllMasked); + ByteVector64Tests::ANDReduceMasked, ByteVector64Tests::ANDReduceAllMasked); } static byte ORReduce(byte[] a, int idx) { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3779,14 +3829,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ORReduceAll(byte[] a) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ORReduceByte64VectorTests(IntFunction fa) { + static void ORReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3797,12 +3847,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::ORReduce, Byte64VectorTests::ORReduceAll); + ByteVector64Tests::ORReduce, ByteVector64Tests::ORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3810,20 +3860,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = OR_IDENTITY; - assertEquals((byte) (id | id), id, + assertEquals((byte) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id | x), x); - assertEquals((byte) (x | id), x); + assertEquals((byte) (scalar_or(id, x)), x); + assertEquals((byte) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id | x), x, + assertEquals((byte) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x | id), x, + assertEquals((byte) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3832,7 +3882,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3841,14 +3891,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3861,18 +3911,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::ORReduceMasked, Byte64VectorTests::ORReduceAllMasked); + ByteVector64Tests::ORReduceMasked, ByteVector64Tests::ORReduceAllMasked); } static byte XORReduce(byte[] a, int idx) { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3881,14 +3931,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte XORReduceAll(byte[] a) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void XORReduceByte64VectorTests(IntFunction fa) { + static void XORReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3899,12 +3949,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::XORReduce, Byte64VectorTests::XORReduceAll); + ByteVector64Tests::XORReduce, ByteVector64Tests::XORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3912,20 +3962,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = XOR_IDENTITY; - assertEquals((byte) (id ^ id), id, + assertEquals((byte) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id ^ x), x); - assertEquals((byte) (x ^ id), x); + assertEquals((byte) (scalar_xor(id, x)), x); + assertEquals((byte) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id ^ x), x, + assertEquals((byte) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x ^ id), x, + assertEquals((byte) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3934,7 +3984,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3943,14 +3993,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void XORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3963,18 +4013,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::XORReduceMasked, Byte64VectorTests::XORReduceAllMasked); + ByteVector64Tests::XORReduceMasked, ByteVector64Tests::XORReduceAllMasked); } static byte ADDReduce(byte[] a, int idx) { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3983,14 +4033,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ADDReduceAll(byte[] a) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceByte64VectorTests(IntFunction fa) { + static void ADDReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4001,12 +4051,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::ADDReduce, Byte64VectorTests::ADDReduceAll); + ByteVector64Tests::ADDReduce, ByteVector64Tests::ADDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4014,20 +4064,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = ADD_IDENTITY; - assertEquals((byte) (id + id), id, + assertEquals((byte) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id + x), x); - assertEquals((byte) (x + id), x); + assertEquals((byte) (scalar_add(id, x)), x); + assertEquals((byte) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id + x), x, + assertEquals((byte) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x + id), x, + assertEquals((byte) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4036,7 +4086,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4045,14 +4095,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4065,18 +4115,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::ADDReduceMasked, Byte64VectorTests::ADDReduceAllMasked); + ByteVector64Tests::ADDReduceMasked, ByteVector64Tests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4085,14 +4135,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MULReduceAll(byte[] a) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MULReduceByte64VectorTests(IntFunction fa) { + static void MULReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4103,12 +4153,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::MULReduce, Byte64VectorTests::MULReduceAll); + ByteVector64Tests::MULReduce, ByteVector64Tests::MULReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4116,20 +4166,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MUL_IDENTITY; - assertEquals((byte) (id * id), id, + assertEquals((byte) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id * x), x); - assertEquals((byte) (x * id), x); + assertEquals((byte) (scalar_mul(id, x)), x); + assertEquals((byte) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id * x), x, + assertEquals((byte) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x * id), x, + assertEquals((byte) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4138,7 +4188,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4147,14 +4197,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MULReduceAllMasked(byte[] a, boolean[] mask) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MULReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4167,18 +4217,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::MULReduceMasked, Byte64VectorTests::MULReduceAllMasked); + ByteVector64Tests::MULReduceMasked, ByteVector64Tests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4187,14 +4237,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MINReduceAll(byte[] a) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MINReduceByte64VectorTests(IntFunction fa) { + static void MINReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4205,12 +4255,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::MINReduce, Byte64VectorTests::MINReduceAll); + ByteVector64Tests::MINReduce, ByteVector64Tests::MINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4218,20 +4268,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MIN_IDENTITY; - assertEquals((byte) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.min(id, x), x); - assertEquals((byte) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4240,7 +4290,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4249,14 +4299,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MINReduceAllMasked(byte[] a, boolean[] mask) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4269,18 +4319,18 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::MINReduceMasked, Byte64VectorTests::MINReduceAllMasked); + ByteVector64Tests::MINReduceMasked, ByteVector64Tests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4289,14 +4339,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MAXReduceAll(byte[] a) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MAXReduceByte64VectorTests(IntFunction fa) { + static void MAXReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4307,12 +4357,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::MAXReduce, Byte64VectorTests::MAXReduceAll); + ByteVector64Tests::MAXReduce, ByteVector64Tests::MAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4320,20 +4370,20 @@ public class Byte64VectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MAX_IDENTITY; - assertEquals((byte) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.max(id, x), x); - assertEquals((byte) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4342,7 +4392,7 @@ public class Byte64VectorTests extends AbstractVectorTest { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4351,14 +4401,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4371,12 +4421,12 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::MAXReduceMasked, Byte64VectorTests::MAXReduceAllMasked); + ByteVector64Tests::MAXReduceMasked, ByteVector64Tests::MAXReduceAllMasked); } static byte UMINReduce(byte[] a, int idx) { @@ -4398,7 +4448,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMINReduceByte64VectorTests(IntFunction fa) { + static void UMINReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4414,7 +4464,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::UMINReduce, Byte64VectorTests::UMINReduceAll); + ByteVector64Tests::UMINReduce, ByteVector64Tests::UMINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4460,7 +4510,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4478,7 +4528,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::UMINReduceMasked, Byte64VectorTests::UMINReduceAllMasked); + ByteVector64Tests::UMINReduceMasked, ByteVector64Tests::UMINReduceAllMasked); } static byte UMAXReduce(byte[] a, int idx) { @@ -4500,7 +4550,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMAXReduceByte64VectorTests(IntFunction fa) { + static void UMAXReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4516,7 +4566,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::UMAXReduce, Byte64VectorTests::UMAXReduceAll); + ByteVector64Tests::UMAXReduce, ByteVector64Tests::UMAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4562,7 +4612,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4580,7 +4630,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::UMAXReduceMasked, Byte64VectorTests::UMAXReduceAllMasked); + ByteVector64Tests::UMAXReduceMasked, ByteVector64Tests::UMAXReduceAllMasked); } static byte FIRST_NONZEROReduce(byte[] a, int idx) { @@ -4602,7 +4652,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void FIRST_NONZEROReduceByte64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4618,7 +4668,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::FIRST_NONZEROReduce, Byte64VectorTests::FIRST_NONZEROReduceAll); + ByteVector64Tests::FIRST_NONZEROReduce, ByteVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4664,7 +4714,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void FIRST_NONZEROReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4682,7 +4732,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::FIRST_NONZEROReduceMasked, Byte64VectorTests::FIRST_NONZEROReduceAllMasked); + ByteVector64Tests::FIRST_NONZEROReduceMasked, ByteVector64Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4695,7 +4745,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueByte64VectorTests(IntFunction fm) { + static void anyTrueByteVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4706,7 +4756,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector64Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4719,7 +4769,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueByte64VectorTests(IntFunction fm) { + static void allTrueByteVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4730,7 +4780,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteVector64Tests::allTrue); } static byte SUADDReduce(byte[] a, int idx) { @@ -4752,7 +4802,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingUnaryOpProvider") - static void SUADDReduceByte64VectorTests(IntFunction fa) { + static void SUADDReduceByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4768,7 +4818,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Byte64VectorTests::SUADDReduce, Byte64VectorTests::SUADDReduceAll); + ByteVector64Tests::SUADDReduce, ByteVector64Tests::SUADDReduceAll); } @Test(dataProvider = "byteSaturatingUnaryOpProvider") @@ -4813,7 +4863,7 @@ public class Byte64VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider") - static void SUADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4831,11 +4881,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::SUADDReduceMasked, Byte64VectorTests::SUADDReduceAllMasked); + ByteVector64Tests::SUADDReduceMasked, ByteVector64Tests::SUADDReduceAllMasked); } @Test(dataProvider = "byteBinaryOpProvider") - static void withByte64VectorTests(IntFunction fa, IntFunction fb) { + static void withByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -4858,7 +4908,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_DEFAULTByte64VectorTests(IntFunction fa) { + static void IS_DEFAULTByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4875,7 +4925,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_DEFAULTMaskedByte64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4899,7 +4949,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_NEGATIVEByte64VectorTests(IntFunction fa) { + static void IS_NEGATIVEByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4916,7 +4966,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_NEGATIVEMaskedByte64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4936,7 +4986,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void LTByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4955,7 +5005,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ltByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4974,7 +5024,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4997,7 +5047,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void GTByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5016,7 +5066,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5039,7 +5089,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte64VectorTests(IntFunction fa, IntFunction fb) { + static void EQByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5058,7 +5108,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte64VectorTests(IntFunction fa, IntFunction fb) { + static void eqByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5077,7 +5127,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5100,7 +5150,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void NEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void NEByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5119,7 +5169,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void NEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5142,7 +5192,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void LEByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5161,7 +5211,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5184,7 +5234,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void GEByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5203,7 +5253,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5226,7 +5276,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ULTByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5245,7 +5295,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5268,7 +5318,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5287,7 +5337,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5310,7 +5360,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5329,7 +5379,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5352,7 +5402,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteVector64Tests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5371,7 +5421,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5394,7 +5444,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5404,13 +5454,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5424,13 +5474,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void LTByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5440,13 +5490,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByte64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTByteVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5460,13 +5510,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (byte)((long)b[i])))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5476,13 +5526,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5496,13 +5546,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5512,13 +5562,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByte64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQByteVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5532,7 +5582,7 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (byte)((long)b[i])))); } } } @@ -5542,7 +5592,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte64VectorTests(IntFunction fa, IntFunction fb, + static void blendByteVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5558,11 +5608,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Byte64VectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteVector64Tests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") - static void RearrangeByte64VectorTests(IntFunction fa, + static void RearrangeByteVector64Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5579,7 +5629,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") - static void RearrangeByte64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeByteVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -5597,7 +5647,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void compressByte64VectorTests(IntFunction fa, + static void compressByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5615,7 +5665,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void expandByte64VectorTests(IntFunction fa, + static void expandByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5633,7 +5683,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void getByte64VectorTests(IntFunction fa) { + static void getByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5789,7 +5839,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastByte64VectorTests(IntFunction fa) { + static void BroadcastByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5803,7 +5853,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZeroByte64VectorTests(IntFunction fa) { + static void ZeroByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5828,7 +5878,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void sliceUnaryByte64VectorTests(IntFunction fa) { + static void sliceUnaryByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5839,7 +5889,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteVector64Tests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { @@ -5856,7 +5906,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void sliceBinaryByte64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryByteVector64TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5869,7 +5919,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Byte64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteVector64Tests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { @@ -5886,7 +5936,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void sliceByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5903,7 +5953,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Byte64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ByteVector64Tests::slice); } static byte[] unsliceUnary(byte[] a, int origin, int idx) { @@ -5920,7 +5970,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void unsliceUnaryByte64VectorTests(IntFunction fa) { + static void unsliceUnaryByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5931,7 +5981,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Byte64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteVector64Tests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { @@ -5957,7 +6007,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void unsliceBinaryByte64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryByteVector64TestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5971,7 +6021,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Byte64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteVector64Tests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { @@ -6011,7 +6061,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void unsliceByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6028,7 +6078,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Byte64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteVector64Tests::unslice); } static byte BITWISE_BLEND(byte a, byte b, byte c) { @@ -6040,7 +6090,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6055,11 +6105,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Byte64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6072,11 +6122,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Byte64VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ByteVector64Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6094,11 +6144,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Byte64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6109,11 +6159,11 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6124,11 +6174,11 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6139,11 +6189,11 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6154,11 +6204,11 @@ public class Byte64VectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6173,11 +6223,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Byte64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6192,11 +6242,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Byte64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByte64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6207,11 +6257,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByte64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6222,11 +6272,11 @@ public class Byte64VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Byte64VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVector64Tests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByte64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6240,19 +6290,19 @@ public class Byte64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Byte64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteVector64Tests::BITWISE_BLEND); } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void NEGByte64VectorTests(IntFunction fa) { + static void NEGByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6263,11 +6313,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::NEG); + assertArraysEquals(r, a, ByteVector64Tests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") - static void negByte64VectorTests(IntFunction fa) { + static void negByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6278,11 +6328,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::neg); + assertArraysEquals(r, a, ByteVector64Tests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NEGMaskedByte64VectorTests(IntFunction fa, + static void NEGMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6296,19 +6346,19 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::NEG); + assertArraysEquals(r, a, mask, ByteVector64Tests::NEG); } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void ABSByte64VectorTests(IntFunction fa) { + static void ABSByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6319,11 +6369,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::ABS); + assertArraysEquals(r, a, ByteVector64Tests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") - static void absByte64VectorTests(IntFunction fa) { + static void absByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6334,11 +6384,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::abs); + assertArraysEquals(r, a, ByteVector64Tests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ABSMaskedByte64VectorTests(IntFunction fa, + static void ABSMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6352,7 +6402,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::ABS); + assertArraysEquals(r, a, mask, ByteVector64Tests::ABS); } static byte NOT(byte a) { @@ -6364,7 +6414,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void NOTByte64VectorTests(IntFunction fa) { + static void NOTByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6375,11 +6425,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::NOT); + assertArraysEquals(r, a, ByteVector64Tests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") - static void notByte64VectorTests(IntFunction fa) { + static void notByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6390,11 +6440,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::not); + assertArraysEquals(r, a, ByteVector64Tests::not); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NOTMaskedByte64VectorTests(IntFunction fa, + static void NOTMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6408,7 +6458,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::NOT); + assertArraysEquals(r, a, mask, ByteVector64Tests::NOT); } static byte ZOMO(byte a) { @@ -6416,7 +6466,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZOMOByte64VectorTests(IntFunction fa) { + static void ZOMOByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6427,11 +6477,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::ZOMO); + assertArraysEquals(r, a, ByteVector64Tests::ZOMO); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ZOMOMaskedByte64VectorTests(IntFunction fa, + static void ZOMOMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6445,7 +6495,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteVector64Tests::ZOMO); } static byte BIT_COUNT(byte a) { @@ -6453,7 +6503,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BIT_COUNTByte64VectorTests(IntFunction fa) { + static void BIT_COUNTByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6464,11 +6514,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ByteVector64Tests::BIT_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void BIT_COUNTMaskedByte64VectorTests(IntFunction fa, + static void BIT_COUNTMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6482,7 +6532,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ByteVector64Tests::BIT_COUNT); } static byte TRAILING_ZEROS_COUNT(byte a) { @@ -6490,7 +6540,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void TRAILING_ZEROS_COUNTByte64VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6501,11 +6551,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector64Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedByte64VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6519,7 +6569,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector64Tests::TRAILING_ZEROS_COUNT); } static byte LEADING_ZEROS_COUNT(byte a) { @@ -6527,7 +6577,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LEADING_ZEROS_COUNTByte64VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6538,11 +6588,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVector64Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedByte64VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6556,7 +6606,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVector64Tests::LEADING_ZEROS_COUNT); } static byte REVERSE(byte a) { @@ -6564,7 +6614,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSEByte64VectorTests(IntFunction fa) { + static void REVERSEByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6575,11 +6625,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::REVERSE); + assertArraysEquals(r, a, ByteVector64Tests::REVERSE); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSEMaskedByte64VectorTests(IntFunction fa, + static void REVERSEMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6593,7 +6643,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ByteVector64Tests::REVERSE); } static byte REVERSE_BYTES(byte a) { @@ -6601,7 +6651,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSE_BYTESByte64VectorTests(IntFunction fa) { + static void REVERSE_BYTESByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6612,11 +6662,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ByteVector64Tests::REVERSE_BYTES); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedByte64VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedByteVector64Tests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6630,7 +6680,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Byte64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ByteVector64Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6638,7 +6688,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6651,7 +6701,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::band); + assertArraysEquals(r, a, b, ByteVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6659,7 +6709,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6672,7 +6722,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::bor); + assertArraysEquals(r, a, b, ByteVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6680,7 +6730,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6693,7 +6743,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::bxor); + assertArraysEquals(r, a, b, ByteVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6701,7 +6751,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6714,7 +6764,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::bandNot); + assertArraysEquals(r, a, b, ByteVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6722,7 +6772,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6735,7 +6785,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Byte64VectorTests::beq); + assertArraysEquals(r, a, b, ByteVector64Tests::beq); } static boolean unot(boolean a) { @@ -6743,7 +6793,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotByte64VectorTests(IntFunction fa) { + static void masknotByteVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6754,7 +6804,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::unot); + assertArraysEquals(r, a, ByteVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6771,7 +6821,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongByte64VectorTests(IntFunction fa) { + static void maskFromToLongByteVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6785,7 +6835,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltByteVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6795,13 +6845,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpProvider") - static void eqByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqByteVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6811,13 +6861,13 @@ public class Byte64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteUnaryOpProvider") - static void toIntArrayByte64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6828,7 +6878,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toLongArrayByte64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6839,7 +6889,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toDoubleArrayByte64VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6850,7 +6900,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toStringByte64VectorTestsSmokeTest(IntFunction fa) { + static void toStringByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6863,7 +6913,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void hashCodeByte64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6877,7 +6927,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void reinterpretAsBytesByte64VectorTestsSmokeTest(IntFunction fa) { + static void reinterpretAsBytesByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6891,7 +6941,7 @@ public class Byte64VectorTests extends AbstractVectorTest { static long ADDReduceLong(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6900,14 +6950,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(byte[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((byte)res, (byte)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceLongByte64VectorTests(IntFunction fa) { + static void ADDReduceLongByteVector64Tests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6918,19 +6968,20 @@ public class Byte64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Byte64VectorTests::ADDReduceLong, Byte64VectorTests::ADDReduceAllLong); + ByteVector64Tests::ADDReduceLong, ByteVector64Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6939,14 +6990,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((byte)res, (byte)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceLongByte64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongByteVector64TestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6959,16 +7010,16 @@ public class Byte64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Byte64VectorTests::ADDReduceLongMasked, Byte64VectorTests::ADDReduceAllLongMasked); + ByteVector64Tests::ADDReduceLongMasked, ByteVector64Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastLongByte64VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongByteVector64TestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6979,7 +7030,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendByteVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6993,12 +7044,12 @@ public class Byte64VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Byte64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVector64Tests::blend); } @Test(dataProvider = "byteUnaryOpSelectFromProvider") - static void SelectFromByte64VectorTests(IntFunction fa, + static void SelectFromByteVector64Tests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); byte[] order = fs.apply(a.length, SPECIES.length()); @@ -7014,7 +7065,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorByte64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorByteVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] idx = fc.apply(SPECIES.length()); @@ -7032,7 +7083,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") - static void SelectFromByte64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromByteVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -7051,7 +7102,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousByte64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousByteVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7067,7 +7118,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringByte64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringByteVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7081,7 +7132,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsByte64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsByteVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7095,7 +7146,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsByte64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsByteVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7111,7 +7162,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeByte64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeByteVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7133,7 +7184,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountByte64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountByteVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7144,7 +7195,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ByteVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7158,7 +7209,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueByte64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueByteVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7169,7 +7220,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ByteVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7183,7 +7234,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueByte64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueByteVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7194,11 +7245,11 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Byte64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ByteVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressByte64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressByteVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7226,7 +7277,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeByte64VectorTestsSmokeTest(int offset) { + static void indexInRangeByteVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7240,7 +7291,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongByte64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongByteVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7267,14 +7318,14 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundByte64VectorTestsSmokeTest(int length) { + static void loopBoundByteVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongByte64VectorTestsSmokeTest(int _length) { + static void loopBoundLongByteVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7282,21 +7333,21 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeByte64VectorTestsSmokeTest() { + static void ElementSizeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Byte.SIZE); } @Test - static void VectorShapeByte64VectorTestsSmokeTest() { + static void VectorShapeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesByte64VectorTestsSmokeTest() { + static void ShapeWithLanesByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(byte.class); @@ -7304,32 +7355,32 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeByte64VectorTestsSmokeTest() { + static void ElementTypeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementType() == byte.class); } @Test - static void SpeciesElementSizeByte64VectorTestsSmokeTest() { + static void SpeciesElementSizeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementSize() == Byte.SIZE); } @Test - static void VectorTypeByte64VectorTestsSmokeTest() { + static void VectorTypeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesByte64VectorTestsSmokeTest() { + static void WithLanesByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(byte.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeByte64VectorTestsSmokeTest() { + static void WithShapeByteVector64TestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7337,7 +7388,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueByte64VectorTestsSmokeTest() { + static void MaskAllTrueByteVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ByteVectorMaxLoadStoreTests.java index 76c6e9ff49f..93af9674906 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation ByteMaxVectorLoadStoreTests + * -XX:-TieredCompilation ByteVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class ByteMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ByteVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java index ccbc2e078b9..c53710c3fdd 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class ByteMaxVectorTests extends AbstractVectorTest { +public class ByteVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = ByteVector.SPECIES_MAX; @@ -1378,7 +1378,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static final List> BYTE_SHUFFLE_GENERATORS = List.of( withToStringBi("shuffle[random]", (Integer l, Integer m) -> { byte[] a = new byte[l]; - int upper = Math.min(Byte.MAX_VALUE + 1, m); + int upper = m; for (int i = 0; i < 1; i++) { a[i] = (byte)RAND.nextInt(upper); } @@ -1580,6 +1580,59 @@ public class ByteMaxVectorTests extends AbstractVectorTest { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1596,9 +1649,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1707,11 +1757,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1724,15 +1774,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::ADD); + assertArraysEquals(r, a, b, ByteVectorMaxTests::ADD); } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1743,11 +1793,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::add); + assertArraysEquals(r, a, b, ByteVectorMaxTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1763,11 +1813,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1781,15 +1831,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::add); } static byte SUB(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void SUBByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1802,15 +1852,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::SUB); + assertArraysEquals(r, a, b, ByteVectorMaxTests::SUB); } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1821,11 +1871,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::sub); + assertArraysEquals(r, a, b, ByteVectorMaxTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void SUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1841,11 +1891,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::SUB); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1859,15 +1909,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::sub); } static byte MUL(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MULByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1880,15 +1930,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::MUL); + assertArraysEquals(r, a, b, ByteVectorMaxTests::MUL); } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1899,11 +1949,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::mul); + assertArraysEquals(r, a, b, ByteVectorMaxTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void MULByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1919,11 +1969,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::MUL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -1937,7 +1987,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::mul); } static byte DIV(byte a, byte b) { @@ -1945,7 +1995,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void DIVByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1960,7 +2010,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::DIV); + assertArraysEquals(r, a, b, ByteVectorMaxTests::DIV); } static byte div(byte a, byte b) { @@ -1968,7 +2018,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void divByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -1983,11 +2033,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::div); + assertArraysEquals(r, a, b, ByteVectorMaxTests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void DIVByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2005,11 +2055,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::DIV); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2027,15 +2077,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::div); } static byte FIRST_NONZERO(byte a, byte b) { - return (byte)((a)!=0?a:b); + return (byte)(firstNonZero(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void FIRST_NONZEROByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2048,11 +2098,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ByteVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void FIRST_NONZEROByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2068,7 +2118,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::FIRST_NONZERO); } static byte AND(byte a, byte b) { @@ -2076,7 +2126,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ANDByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2089,7 +2139,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::AND); + assertArraysEquals(r, a, b, ByteVectorMaxTests::AND); } static byte and(byte a, byte b) { @@ -2097,7 +2147,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void andByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void andByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2108,11 +2158,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::and); + assertArraysEquals(r, a, b, ByteVectorMaxTests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2128,7 +2178,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::AND); } static byte AND_NOT(byte a, byte b) { @@ -2136,7 +2186,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void AND_NOTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2149,11 +2199,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, ByteVectorMaxTests::AND_NOT); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void AND_NOTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2169,7 +2219,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::AND_NOT); } static byte OR(byte a, byte b) { @@ -2177,7 +2227,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ORByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2190,7 +2240,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::OR); + assertArraysEquals(r, a, b, ByteVectorMaxTests::OR); } static byte or(byte a, byte b) { @@ -2198,7 +2248,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void orByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void orByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2209,11 +2259,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::or); + assertArraysEquals(r, a, b, ByteVectorMaxTests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2229,7 +2279,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::OR); } static byte XOR(byte a, byte b) { @@ -2237,7 +2287,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void XORByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void XORByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2250,11 +2300,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::XOR); + assertArraysEquals(r, a, b, ByteVectorMaxTests::XOR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void XORByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2270,11 +2320,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::XOR); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::XOR); } @Test(dataProvider = "byteBinaryOpProvider") - static void addByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2284,11 +2334,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::add); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2301,11 +2351,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::add); } @Test(dataProvider = "byteBinaryOpProvider") - static void subByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2315,11 +2365,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::sub); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void subByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2332,11 +2382,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::sub); } @Test(dataProvider = "byteBinaryOpProvider") - static void mulByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2346,11 +2396,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::mul); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2363,11 +2413,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::mul); } @Test(dataProvider = "byteBinaryOpProvider") - static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2379,11 +2429,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::div); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2398,11 +2448,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::div); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2412,11 +2462,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2426,11 +2476,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::or); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2443,11 +2493,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ANDByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2457,11 +2507,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void andByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2471,11 +2521,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::and); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ANDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2488,11 +2538,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ByteVectorMaxTests::AND); } @Test(dataProvider = "byteBinaryOpProvider") - static void ORByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORByteVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2502,11 +2552,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ByteVectorMaxTests::OR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ORByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORByteVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2519,11 +2569,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVectorMaxTests::OR); } @Test(dataProvider = "byteBinaryOpProvider") - static void ADDByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDByteVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2533,11 +2583,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ByteVectorMaxTests::ADD); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ADDByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDByteVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2550,7 +2600,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVectorMaxTests::ADD); } static byte LSHL(byte a, byte b) { @@ -2558,7 +2608,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHLByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2571,11 +2621,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, ByteVectorMaxTests::LSHL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2591,7 +2641,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::LSHL); } static byte ASHR(byte a, byte b) { @@ -2599,7 +2649,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ASHRByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2612,11 +2662,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, ByteVectorMaxTests::ASHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2632,7 +2682,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::ASHR); } static byte LSHR(byte a, byte b) { @@ -2640,7 +2690,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHRByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2653,11 +2703,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, ByteVectorMaxTests::LSHR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2673,7 +2723,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::LSHR); } static byte LSHL_unary(byte a, byte b) { @@ -2681,7 +2731,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHLByteMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLByteVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2693,11 +2743,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ByteVectorMaxTests::LSHL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHLByteMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLByteVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2712,7 +2762,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVectorMaxTests::LSHL_unary); } static byte LSHR_unary(byte a, byte b) { @@ -2720,7 +2770,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void LSHRByteMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRByteVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2732,11 +2782,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ByteVectorMaxTests::LSHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void LSHRByteMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRByteVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2751,7 +2801,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVectorMaxTests::LSHR_unary); } static byte ASHR_unary(byte a, byte b) { @@ -2759,7 +2809,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ASHRByteMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRByteVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2771,11 +2821,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ByteVectorMaxTests::ASHR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ASHRByteMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRByteVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2790,7 +2840,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVectorMaxTests::ASHR_unary); } static byte ROR(byte a, byte b) { @@ -2798,7 +2848,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void RORByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2811,11 +2861,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::ROR); + assertArraysEquals(r, a, b, ByteVectorMaxTests::ROR); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2831,7 +2881,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::ROR); } static byte ROL(byte a, byte b) { @@ -2839,7 +2889,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ROLByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2852,11 +2902,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::ROL); + assertArraysEquals(r, a, b, ByteVectorMaxTests::ROL); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2872,7 +2922,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::ROL); } static byte ROR_unary(byte a, byte b) { @@ -2880,7 +2930,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void RORByteMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORByteVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2892,11 +2942,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ByteVectorMaxTests::ROR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void RORByteMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORByteVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2911,7 +2961,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVectorMaxTests::ROR_unary); } static byte ROL_unary(byte a, byte b) { @@ -2919,7 +2969,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void ROLByteMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLByteVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2931,11 +2981,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ByteVectorMaxTests::ROL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void ROLByteMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLByteVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -2950,14 +3000,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ByteVectorMaxTests::ROL_unary); } static byte LSHR_binary_const(byte a) { return (byte)(((a & 0xFF) >>> CONST_SHIFT)); } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHRByteMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRByteVectorMaxTestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2968,11 +3018,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ByteVectorMaxTests::LSHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRByteVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -2986,7 +3036,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVectorMaxTests::LSHR_binary_const); } static byte LSHL_binary_const(byte a) { @@ -2994,7 +3044,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LSHLByteMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLByteVectorMaxTestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3005,11 +3055,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ByteVectorMaxTests::LSHL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LSHLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLByteVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3023,7 +3073,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVectorMaxTests::LSHL_binary_const); } static byte ASHR_binary_const(byte a) { @@ -3031,7 +3081,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ASHRByteMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRByteVectorMaxTestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3042,11 +3092,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ByteMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ByteVectorMaxTests::ASHR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ASHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRByteVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3060,7 +3110,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVectorMaxTests::ASHR_binary_const); } static byte ROR_binary_const(byte a) { @@ -3068,7 +3118,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void RORByteMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void RORByteVectorMaxTestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3079,11 +3129,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ByteMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ByteVectorMaxTests::ROR_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void RORByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORByteVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3097,7 +3147,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ByteVectorMaxTests::ROR_binary_const); } static byte ROL_binary_const(byte a) { @@ -3105,7 +3155,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ROLByteMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ROLByteVectorMaxTestsScalarShiftConst(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3116,11 +3166,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ByteMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ByteVectorMaxTests::ROL_binary_const); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ROLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLByteVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3134,14 +3184,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ByteVectorMaxTests::ROL_binary_const); } static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MINByteMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINByteVectorMaxTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3152,13 +3202,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MIN); + assertArraysEquals(r, a, (byte)10, ByteVectorMaxTests::MIN); } static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void minByteMaxVectorTestsWithMemOp(IntFunction fa) { + static void minByteVectorMaxTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3169,13 +3219,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::min); + assertArraysEquals(r, a, (byte)10, ByteVectorMaxTests::min); } static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINByteVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3188,13 +3238,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, ByteMaxVectorTests::MIN); + assertArraysEquals(r, a, (byte)10, mask, ByteVectorMaxTests::MIN); } static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void MAXByteMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXByteVectorMaxTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3205,13 +3255,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MAX); + assertArraysEquals(r, a, (byte)10, ByteVectorMaxTests::MAX); } static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpProvider") - static void maxByteMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxByteVectorMaxTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3222,13 +3272,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::max); + assertArraysEquals(r, a, (byte)10, ByteVectorMaxTests::max); } static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXByteVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3241,15 +3291,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (byte)10, mask, ByteMaxVectorTests::MAX); + assertArraysEquals(r, a, (byte)10, mask, ByteVectorMaxTests::MAX); } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3262,15 +3312,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::MIN); + assertArraysEquals(r, a, b, ByteVectorMaxTests::MIN); } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3281,15 +3331,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::min); + assertArraysEquals(r, a, b, ByteVectorMaxTests::min); } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3302,15 +3352,15 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::MAX); + assertArraysEquals(r, a, b, ByteVectorMaxTests::MAX); } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3321,7 +3371,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ByteMaxVectorTests::max); + assertArraysEquals(r, a, b, ByteVectorMaxTests::max); } static byte UMIN(byte a, byte b) { @@ -3329,7 +3379,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMINByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMINByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3342,11 +3392,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, ByteVectorMaxTests::UMIN); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMINByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3362,7 +3412,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::UMIN); } static byte UMAX(byte a, byte b) { @@ -3370,7 +3420,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void UMAXByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMAXByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3383,11 +3433,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, ByteVectorMaxTests::UMAX); } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void UMAXByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3403,7 +3453,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::UMAX); } static byte SADD(byte a, byte b) { @@ -3411,7 +3461,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SADDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SADDByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3424,11 +3474,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::SADD); + assertArraysEquals(r, a, b, ByteVectorMaxTests::SADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3444,7 +3494,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SADD); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::SADD); } static byte SSUB(byte a, byte b) { @@ -3452,7 +3502,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SSUBByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SSUBByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3465,11 +3515,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, ByteVectorMaxTests::SSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SSUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3485,7 +3535,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::SSUB); } static byte SUADD(byte a, byte b) { @@ -3493,7 +3543,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUADDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUADDByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3506,11 +3556,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, ByteVectorMaxTests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3526,7 +3576,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::SUADD); } static byte SUSUB(byte a, byte b) { @@ -3534,7 +3584,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingBinaryOpProvider") - static void SUSUBByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3547,11 +3597,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, ByteVectorMaxTests::SUSUB); } @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") - static void SUSUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3567,11 +3617,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::SUSUB); } @Test(dataProvider = "byteBinaryOpProvider") - static void MINByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3581,11 +3631,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::MIN); } @Test(dataProvider = "byteBinaryOpProvider") - static void minByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3595,11 +3645,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::min); } @Test(dataProvider = "byteBinaryOpProvider") - static void MAXByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3609,11 +3659,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::MAX); } @Test(dataProvider = "byteBinaryOpProvider") - static void maxByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -3623,10 +3673,10 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, ByteVectorMaxTests::max); } @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider") - static void SUADDAssocByteMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocByteVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -3643,11 +3693,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, ByteMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ByteVectorMaxTests::SUADD); } @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -3668,13 +3718,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteVectorMaxTests::SUADD); } static byte ANDReduce(byte[] a, int idx) { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3683,14 +3733,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ANDReduceAll(byte[] a) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ANDReduceByteMaxVectorTests(IntFunction fa) { + static void ANDReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3701,12 +3751,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::ANDReduce, ByteMaxVectorTests::ANDReduceAll); + ByteVectorMaxTests::ANDReduce, ByteVectorMaxTests::ANDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3714,20 +3764,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = AND_IDENTITY; - assertEquals((byte) (id & id), id, + assertEquals((byte) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id & x), x); - assertEquals((byte) (x & id), x); + assertEquals((byte) (scalar_and(id, x)), x); + assertEquals((byte) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id & x), x, + assertEquals((byte) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x & id), x, + assertEquals((byte) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3736,7 +3786,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3745,14 +3795,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ANDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3765,18 +3815,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::ANDReduceMasked, ByteMaxVectorTests::ANDReduceAllMasked); + ByteVectorMaxTests::ANDReduceMasked, ByteVectorMaxTests::ANDReduceAllMasked); } static byte ORReduce(byte[] a, int idx) { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3785,14 +3835,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ORReduceAll(byte[] a) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ORReduceByteMaxVectorTests(IntFunction fa) { + static void ORReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3803,12 +3853,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::ORReduce, ByteMaxVectorTests::ORReduceAll); + ByteVectorMaxTests::ORReduce, ByteVectorMaxTests::ORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3816,20 +3866,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = OR_IDENTITY; - assertEquals((byte) (id | id), id, + assertEquals((byte) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id | x), x); - assertEquals((byte) (x | id), x); + assertEquals((byte) (scalar_or(id, x)), x); + assertEquals((byte) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id | x), x, + assertEquals((byte) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x | id), x, + assertEquals((byte) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3838,7 +3888,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3847,14 +3897,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3867,18 +3917,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::ORReduceMasked, ByteMaxVectorTests::ORReduceAllMasked); + ByteVectorMaxTests::ORReduceMasked, ByteVectorMaxTests::ORReduceAllMasked); } static byte XORReduce(byte[] a, int idx) { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3887,14 +3937,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte XORReduceAll(byte[] a) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void XORReduceByteMaxVectorTests(IntFunction fa) { + static void XORReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -3905,12 +3955,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::XORReduce, ByteMaxVectorTests::XORReduceAll); + ByteVectorMaxTests::XORReduce, ByteVectorMaxTests::XORReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -3918,20 +3968,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = XOR_IDENTITY; - assertEquals((byte) (id ^ id), id, + assertEquals((byte) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id ^ x), x); - assertEquals((byte) (x ^ id), x); + assertEquals((byte) (scalar_xor(id, x)), x); + assertEquals((byte) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id ^ x), x, + assertEquals((byte) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x ^ id), x, + assertEquals((byte) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3940,7 +3990,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3949,14 +3999,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void XORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3969,18 +4019,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::XORReduceMasked, ByteMaxVectorTests::XORReduceAllMasked); + ByteVectorMaxTests::XORReduceMasked, ByteVectorMaxTests::XORReduceAllMasked); } static byte ADDReduce(byte[] a, int idx) { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3989,14 +4039,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ADDReduceAll(byte[] a) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceByteMaxVectorTests(IntFunction fa) { + static void ADDReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4007,12 +4057,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::ADDReduce, ByteMaxVectorTests::ADDReduceAll); + ByteVectorMaxTests::ADDReduce, ByteVectorMaxTests::ADDReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4020,20 +4070,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = ADD_IDENTITY; - assertEquals((byte) (id + id), id, + assertEquals((byte) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id + x), x); - assertEquals((byte) (x + id), x); + assertEquals((byte) (scalar_add(id, x)), x); + assertEquals((byte) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id + x), x, + assertEquals((byte) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x + id), x, + assertEquals((byte) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4042,7 +4092,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4051,14 +4101,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { byte res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4071,18 +4121,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::ADDReduceMasked, ByteMaxVectorTests::ADDReduceAllMasked); + ByteVectorMaxTests::ADDReduceMasked, ByteVectorMaxTests::ADDReduceAllMasked); } static byte MULReduce(byte[] a, int idx) { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4091,14 +4141,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MULReduceAll(byte[] a) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MULReduceByteMaxVectorTests(IntFunction fa) { + static void MULReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4109,12 +4159,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::MULReduce, ByteMaxVectorTests::MULReduceAll); + ByteVectorMaxTests::MULReduce, ByteVectorMaxTests::MULReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4122,20 +4172,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MUL_IDENTITY; - assertEquals((byte) (id * id), id, + assertEquals((byte) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) (id * x), x); - assertEquals((byte) (x * id), x); + assertEquals((byte) (scalar_mul(id, x)), x); + assertEquals((byte) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((byte) (id * x), x, + assertEquals((byte) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((byte) (x * id), x, + assertEquals((byte) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4144,7 +4194,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4153,14 +4203,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MULReduceAllMasked(byte[] a, boolean[] mask) { byte res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MULReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4173,18 +4223,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::MULReduceMasked, ByteMaxVectorTests::MULReduceAllMasked); + ByteVectorMaxTests::MULReduceMasked, ByteVectorMaxTests::MULReduceAllMasked); } static byte MINReduce(byte[] a, int idx) { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4193,14 +4243,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MINReduceAll(byte[] a) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MINReduceByteMaxVectorTests(IntFunction fa) { + static void MINReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4211,12 +4261,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::MINReduce, ByteMaxVectorTests::MINReduceAll); + ByteVectorMaxTests::MINReduce, ByteVectorMaxTests::MINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4224,20 +4274,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MIN_IDENTITY; - assertEquals((byte) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.min(id, x), x); - assertEquals((byte) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4246,7 +4296,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4255,14 +4305,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MINReduceAllMasked(byte[] a, boolean[] mask) { byte res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4275,18 +4325,18 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (byte) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::MINReduceMasked, ByteMaxVectorTests::MINReduceAllMasked); + ByteVectorMaxTests::MINReduceMasked, ByteVectorMaxTests::MINReduceAllMasked); } static byte MAXReduce(byte[] a, int idx) { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4295,14 +4345,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MAXReduceAll(byte[] a) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void MAXReduceByteMaxVectorTests(IntFunction fa) { + static void MAXReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4313,12 +4363,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::MAXReduce, ByteMaxVectorTests::MAXReduceAll); + ByteVectorMaxTests::MAXReduce, ByteVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4326,20 +4376,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte[] a = fa.apply(SPECIES.length()); byte id = MAX_IDENTITY; - assertEquals((byte) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); byte x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((byte) Math.max(id, x), x); - assertEquals((byte) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((byte) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((byte) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4348,7 +4398,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { byte res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4357,14 +4407,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { byte res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4377,12 +4427,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector av = ByteVector.fromArray(SPECIES, a, i); byte v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (byte) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked); + ByteVectorMaxTests::MAXReduceMasked, ByteVectorMaxTests::MAXReduceAllMasked); } static byte UMINReduce(byte[] a, int idx) { @@ -4404,7 +4454,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMINReduceByteMaxVectorTests(IntFunction fa) { + static void UMINReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4420,7 +4470,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::UMINReduce, ByteMaxVectorTests::UMINReduceAll); + ByteVectorMaxTests::UMINReduce, ByteVectorMaxTests::UMINReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4466,7 +4516,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4484,7 +4534,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::UMINReduceMasked, ByteMaxVectorTests::UMINReduceAllMasked); + ByteVectorMaxTests::UMINReduceMasked, ByteVectorMaxTests::UMINReduceAllMasked); } static byte UMAXReduce(byte[] a, int idx) { @@ -4506,7 +4556,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void UMAXReduceByteMaxVectorTests(IntFunction fa) { + static void UMAXReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4522,7 +4572,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::UMAXReduce, ByteMaxVectorTests::UMAXReduceAll); + ByteVectorMaxTests::UMAXReduce, ByteVectorMaxTests::UMAXReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4568,7 +4618,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void UMAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4586,7 +4636,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::UMAXReduceMasked, ByteMaxVectorTests::UMAXReduceAllMasked); + ByteVectorMaxTests::UMAXReduceMasked, ByteVectorMaxTests::UMAXReduceAllMasked); } static byte FIRST_NONZEROReduce(byte[] a, int idx) { @@ -4608,7 +4658,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4624,7 +4674,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::FIRST_NONZEROReduce, ByteMaxVectorTests::FIRST_NONZEROReduceAll); + ByteVectorMaxTests::FIRST_NONZEROReduce, ByteVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "byteUnaryOpProvider") @@ -4670,7 +4720,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4688,7 +4738,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::FIRST_NONZEROReduceMasked, ByteMaxVectorTests::FIRST_NONZEROReduceAllMasked); + ByteVectorMaxTests::FIRST_NONZEROReduceMasked, ByteVectorMaxTests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4701,7 +4751,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueByteMaxVectorTests(IntFunction fm) { + static void anyTrueByteVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4712,7 +4762,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ByteVectorMaxTests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4725,7 +4775,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueByteMaxVectorTests(IntFunction fm) { + static void allTrueByteVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4736,7 +4786,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ByteVectorMaxTests::allTrue); } static byte SUADDReduce(byte[] a, int idx) { @@ -4758,7 +4808,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSaturatingUnaryOpProvider") - static void SUADDReduceByteMaxVectorTests(IntFunction fa) { + static void SUADDReduceByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; @@ -4774,7 +4824,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ByteMaxVectorTests::SUADDReduce, ByteMaxVectorTests::SUADDReduceAll); + ByteVectorMaxTests::SUADDReduce, ByteVectorMaxTests::SUADDReduceAll); } @Test(dataProvider = "byteSaturatingUnaryOpProvider") @@ -4819,7 +4869,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider") - static void SUADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4837,11 +4887,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::SUADDReduceMasked, ByteMaxVectorTests::SUADDReduceAllMasked); + ByteVectorMaxTests::SUADDReduceMasked, ByteVectorMaxTests::SUADDReduceAllMasked); } @Test(dataProvider = "byteBinaryOpProvider") - static void withByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -4864,7 +4914,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_DEFAULTByteMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4881,7 +4931,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_DEFAULTMaskedByteMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4905,7 +4955,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpProvider") - static void IS_NEGATIVEByteMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVEByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4922,7 +4972,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTestOpMaskProvider") - static void IS_NEGATIVEMaskedByteMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4942,7 +4992,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4961,7 +5011,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4980,7 +5030,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5003,7 +5053,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5022,7 +5072,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5045,7 +5095,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void EQByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5064,7 +5114,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void eqByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5083,7 +5133,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5106,7 +5156,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void NEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NEByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5125,7 +5175,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void NEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5148,7 +5198,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LEByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5167,7 +5217,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5190,7 +5240,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void GEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GEByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5209,7 +5259,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void GEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5232,7 +5282,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULTByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5251,7 +5301,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5274,7 +5324,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5293,7 +5343,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5316,7 +5366,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ULEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5335,7 +5385,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void ULEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5358,7 +5408,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void UGEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteVectorMaxTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5377,7 +5427,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpMaskProvider") - static void UGEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5400,7 +5450,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5410,13 +5460,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5430,13 +5480,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void LTByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTByteVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5446,13 +5496,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void LTByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTByteVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5466,13 +5516,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (byte)((long)b[i])))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5482,13 +5532,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5502,13 +5552,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "byteCompareOpProvider") - static void EQByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQByteVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5518,13 +5568,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @Test(dataProvider = "byteCompareOpMaskProvider") - static void EQByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQByteVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5538,7 +5588,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (byte)((long)b[i])))); } } } @@ -5548,7 +5598,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByteMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendByteVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5564,11 +5614,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, ByteVectorMaxTests::blend); } @Test(dataProvider = "byteUnaryOpShuffleProvider") - static void RearrangeByteMaxVectorTests(IntFunction fa, + static void RearrangeByteVectorMaxTests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5585,7 +5635,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpShuffleMaskProvider") - static void RearrangeByteMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeByteVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -5603,7 +5653,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void compressByteMaxVectorTests(IntFunction fa, + static void compressByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5621,7 +5671,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void expandByteMaxVectorTests(IntFunction fa, + static void expandByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5639,7 +5689,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void getByteMaxVectorTests(IntFunction fa) { + static void getByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -5795,7 +5845,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastByteMaxVectorTests(IntFunction fa) { + static void BroadcastByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5809,7 +5859,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZeroByteMaxVectorTests(IntFunction fa) { + static void ZeroByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5834,7 +5884,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void sliceUnaryByteMaxVectorTests(IntFunction fa) { + static void sliceUnaryByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5845,7 +5895,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, ByteMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ByteVectorMaxTests::sliceUnary); } static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) { @@ -5862,7 +5912,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void sliceBinaryByteMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryByteVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5875,7 +5925,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, ByteMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ByteVectorMaxTests::sliceBinary); } static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) { @@ -5892,7 +5942,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void sliceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -5909,7 +5959,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, ByteMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ByteVectorMaxTests::slice); } static byte[] unsliceUnary(byte[] a, int origin, int idx) { @@ -5926,7 +5976,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void unsliceUnaryByteMaxVectorTests(IntFunction fa) { + static void unsliceUnaryByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5937,7 +5987,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, ByteMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ByteVectorMaxTests::unsliceUnary); } static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) { @@ -5963,7 +6013,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpProvider") - static void unsliceBinaryByteMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryByteVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -5977,7 +6027,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, ByteMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ByteVectorMaxTests::unsliceBinary); } static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) { @@ -6017,7 +6067,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void unsliceByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6034,7 +6084,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, ByteMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ByteVectorMaxTests::unslice); } static byte BITWISE_BLEND(byte a, byte b, byte c) { @@ -6046,7 +6096,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByteMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6061,11 +6111,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByteMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6078,11 +6128,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ByteVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6100,11 +6150,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6115,11 +6165,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6130,11 +6180,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6145,11 +6195,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6160,11 +6210,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { ByteVector cv = ByteVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6179,11 +6229,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDByteVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6213,11 +6263,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "byteTernaryOpProvider") - static void bitwiseBlendByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendByteVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] c = fc.apply(SPECIES.length()); @@ -6228,11 +6278,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ByteVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "byteTernaryOpMaskProvider") - static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDByteVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6246,19 +6296,19 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteVectorMaxTests::BITWISE_BLEND); } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void NEGByteMaxVectorTests(IntFunction fa) { + static void NEGByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6269,11 +6319,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::NEG); + assertArraysEquals(r, a, ByteVectorMaxTests::NEG); } @Test(dataProvider = "byteUnaryOpProvider") - static void negByteMaxVectorTests(IntFunction fa) { + static void negByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6284,11 +6334,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::neg); + assertArraysEquals(r, a, ByteVectorMaxTests::neg); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NEGMaskedByteMaxVectorTests(IntFunction fa, + static void NEGMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6302,19 +6352,19 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::NEG); } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") - static void ABSByteMaxVectorTests(IntFunction fa) { + static void ABSByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6325,11 +6375,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::ABS); + assertArraysEquals(r, a, ByteVectorMaxTests::ABS); } @Test(dataProvider = "byteUnaryOpProvider") - static void absByteMaxVectorTests(IntFunction fa) { + static void absByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6340,11 +6390,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::abs); + assertArraysEquals(r, a, ByteVectorMaxTests::abs); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ABSMaskedByteMaxVectorTests(IntFunction fa, + static void ABSMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6358,7 +6408,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::ABS); } static byte NOT(byte a) { @@ -6370,7 +6420,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void NOTByteMaxVectorTests(IntFunction fa) { + static void NOTByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6381,11 +6431,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::NOT); + assertArraysEquals(r, a, ByteVectorMaxTests::NOT); } @Test(dataProvider = "byteUnaryOpProvider") - static void notByteMaxVectorTests(IntFunction fa) { + static void notByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6396,11 +6446,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::not); + assertArraysEquals(r, a, ByteVectorMaxTests::not); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void NOTMaskedByteMaxVectorTests(IntFunction fa, + static void NOTMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6414,7 +6464,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::NOT); } static byte ZOMO(byte a) { @@ -6422,7 +6472,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void ZOMOByteMaxVectorTests(IntFunction fa) { + static void ZOMOByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6433,11 +6483,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::ZOMO); + assertArraysEquals(r, a, ByteVectorMaxTests::ZOMO); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ZOMOMaskedByteMaxVectorTests(IntFunction fa, + static void ZOMOMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6451,7 +6501,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::ZOMO); } static byte BIT_COUNT(byte a) { @@ -6459,7 +6509,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void BIT_COUNTByteMaxVectorTests(IntFunction fa) { + static void BIT_COUNTByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6470,11 +6520,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, ByteVectorMaxTests::BIT_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void BIT_COUNTMaskedByteMaxVectorTests(IntFunction fa, + static void BIT_COUNTMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6488,7 +6538,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::BIT_COUNT); } static byte TRAILING_ZEROS_COUNT(byte a) { @@ -6496,7 +6546,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void TRAILING_ZEROS_COUNTByteMaxVectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6507,11 +6557,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVectorMaxTests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6525,7 +6575,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::TRAILING_ZEROS_COUNT); } static byte LEADING_ZEROS_COUNT(byte a) { @@ -6533,7 +6583,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void LEADING_ZEROS_COUNTByteMaxVectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6544,11 +6594,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ByteVectorMaxTests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6562,7 +6612,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::LEADING_ZEROS_COUNT); } static byte REVERSE(byte a) { @@ -6570,7 +6620,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSEByteMaxVectorTests(IntFunction fa) { + static void REVERSEByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6581,11 +6631,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE); + assertArraysEquals(r, a, ByteVectorMaxTests::REVERSE); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSEMaskedByteMaxVectorTests(IntFunction fa, + static void REVERSEMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6599,7 +6649,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::REVERSE); } static byte REVERSE_BYTES(byte a) { @@ -6607,7 +6657,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void REVERSE_BYTESByteMaxVectorTests(IntFunction fa) { + static void REVERSE_BYTESByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6618,11 +6668,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ByteVectorMaxTests::REVERSE_BYTES); } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedByteMaxVectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedByteVectorMaxTests(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); @@ -6636,7 +6686,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ByteVectorMaxTests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6644,7 +6694,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6657,7 +6707,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::band); + assertArraysEquals(r, a, b, ByteVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -6665,7 +6715,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6678,7 +6728,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::bor); + assertArraysEquals(r, a, b, ByteVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6686,7 +6736,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6699,7 +6749,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::bxor); + assertArraysEquals(r, a, b, ByteVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6707,7 +6757,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6720,7 +6770,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, ByteVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6728,7 +6778,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6741,7 +6791,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ByteMaxVectorTests::beq); + assertArraysEquals(r, a, b, ByteVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -6749,7 +6799,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotByteMaxVectorTests(IntFunction fa) { + static void masknotByteVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6760,7 +6810,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::unot); + assertArraysEquals(r, a, ByteVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6777,7 +6827,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongByteMaxVectorTests(IntFunction fa) { + static void maskFromToLongByteVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6791,7 +6841,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteCompareOpProvider") - static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltByteVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6801,13 +6851,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "byteCompareOpProvider") - static void eqByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqByteVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6817,13 +6867,13 @@ public class ByteMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "byteUnaryOpProvider") - static void toIntArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6834,7 +6884,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toLongArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6845,7 +6895,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toDoubleArrayByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6856,7 +6906,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void toStringByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6869,7 +6919,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void hashCodeByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6883,7 +6933,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpProvider") - static void reinterpretAsBytesByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void reinterpretAsBytesByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6897,7 +6947,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static long ADDReduceLong(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6906,14 +6956,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLong(byte[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((byte)res, (byte)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "byteUnaryOpProvider") - static void ADDReduceLongByteMaxVectorTests(IntFunction fa) { + static void ADDReduceLongByteVectorMaxTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6924,19 +6974,20 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEquals(r, ra, a, - ByteMaxVectorTests::ADDReduceLong, ByteMaxVectorTests::ADDReduceAllLong); + ByteVectorMaxTests::ADDReduceLong, ByteVectorMaxTests::ADDReduceAllLong); } static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6945,14 +6996,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((byte)res, (byte)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "byteUnaryOpMaskProvider") - static void ADDReduceLongByteMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongByteVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6965,16 +7016,16 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((byte)ra, (byte)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - ByteMaxVectorTests::ADDReduceLongMasked, ByteMaxVectorTests::ADDReduceAllLongMasked); + ByteVectorMaxTests::ADDReduceLongMasked, ByteVectorMaxTests::ADDReduceAllLongMasked); } @Test(dataProvider = "byteUnaryOpProvider") - static void BroadcastLongByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongByteVectorMaxTestsSmokeTest(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = new byte[a.length]; @@ -6985,7 +7036,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteBinaryOpMaskProvider") - static void blendByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendByteVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -6999,12 +7050,12 @@ public class ByteMaxVectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ByteVectorMaxTests::blend); } @Test(dataProvider = "byteUnaryOpSelectFromProvider") - static void SelectFromByteMaxVectorTests(IntFunction fa, + static void SelectFromByteVectorMaxTests(IntFunction fa, BiFunction fs) { byte[] a = fa.apply(SPECIES.length()); byte[] order = fs.apply(a.length, SPECIES.length()); @@ -7020,7 +7071,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorByteMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorByteVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] idx = fc.apply(SPECIES.length()); @@ -7038,7 +7089,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider") - static void SelectFromByteMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromByteVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -7057,7 +7108,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousByteMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousByteVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7073,7 +7124,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringByteMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringByteVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7087,7 +7138,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsByteMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsByteVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7101,7 +7152,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsByteVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7117,7 +7168,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeByteVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7139,7 +7190,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountByteVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7150,7 +7201,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ByteVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7164,7 +7215,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueByteVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7175,7 +7226,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ByteVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7189,7 +7240,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueByteVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7200,11 +7251,11 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ByteVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressByteMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressByteVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7232,7 +7283,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeByteMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeByteVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7246,7 +7297,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongByteMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongByteVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7273,14 +7324,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundByteMaxVectorTestsSmokeTest(int length) { + static void loopBoundByteVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongByteMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongByteVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7288,21 +7339,21 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementSizeByteMaxVectorTestsSmokeTest() { + static void ElementSizeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Byte.SIZE); } @Test - static void VectorShapeByteMaxVectorTestsSmokeTest() { + static void VectorShapeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesByteMaxVectorTestsSmokeTest() { + static void ShapeWithLanesByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(byte.class); @@ -7310,32 +7361,32 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementTypeByteMaxVectorTestsSmokeTest() { + static void ElementTypeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementType() == byte.class); } @Test - static void SpeciesElementSizeByteMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().elementSize() == Byte.SIZE); } @Test - static void VectorTypeByteMaxVectorTestsSmokeTest() { + static void VectorTypeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesByteMaxVectorTestsSmokeTest() { + static void WithLanesByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(byte.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeByteMaxVectorTestsSmokeTest() { + static void WithShapeByteVectorMaxTestsSmokeTest() { ByteVector av = ByteVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7343,7 +7394,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueByteMaxVectorTestsSmokeTest() { + static void MaskAllTrueByteVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector128LoadStoreTests.java index e4a0a6bf40e..68349a6afd9 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Double128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation DoubleVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Double128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class DoubleVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Double128VectorTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector128Tests.java index 685590f06e1..1457e5a51ca 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Double128VectorTests extends AbstractVectorTest { +public class DoubleVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_128; @@ -1584,6 +1584,205 @@ relativeError)); return Double.compare(a, (double) 0) != 0 ? a : b; } + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1677,11 +1876,11 @@ relativeError)); } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1694,15 +1893,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::ADD); + assertArraysEquals(r, a, b, DoubleVector128Tests::ADD); } static double add(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void addDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1713,11 +1912,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::add); + assertArraysEquals(r, a, b, DoubleVector128Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1733,11 +1932,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1751,15 +1950,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double128VectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::add); } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void SUBDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1772,15 +1971,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::SUB); + assertArraysEquals(r, a, b, DoubleVector128Tests::SUB); } static double sub(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void subDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1791,11 +1990,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::sub); + assertArraysEquals(r, a, b, DoubleVector128Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void SUBDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1811,11 +2010,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1829,15 +2028,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double128VectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::sub); } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MULDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void MULDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1850,15 +2049,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::MUL); + assertArraysEquals(r, a, b, DoubleVector128Tests::MUL); } static double mul(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void mulDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1869,11 +2068,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::mul); + assertArraysEquals(r, a, b, DoubleVector128Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void MULDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1889,11 +2088,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1907,15 +2106,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double128VectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::mul); } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void DIVDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1928,15 +2127,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::DIV); + assertArraysEquals(r, a, b, DoubleVector128Tests::DIV); } static double div(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void divDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1947,11 +2146,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::div); + assertArraysEquals(r, a, b, DoubleVector128Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void DIVDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1967,11 +2166,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1985,15 +2184,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double128VectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::div); } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void FIRST_NONZERODouble128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZERODoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2006,11 +2205,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void FIRST_NONZERODouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZERODoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2026,11 +2225,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2040,11 +2239,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector128Tests::add); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2071,11 +2270,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector128Tests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2301,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector128Tests::mul); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2133,11 +2332,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector128Tests::div); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2164,11 +2363,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Double128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleVector128Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDDoubleVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2181,13 +2380,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Double128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector128Tests::ADD); } static DoubleVector bv_MIN = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MINDouble128VectorTestsWithMemOp(IntFunction fa) { + static void MINDoubleVector128TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double128VectorTests::MIN); + assertArraysEquals(r, a, (double)10, DoubleVector128Tests::MIN); } static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void minDouble128VectorTestsWithMemOp(IntFunction fa) { + static void minDoubleVector128TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double128VectorTests::min); + assertArraysEquals(r, a, (double)10, DoubleVector128Tests::min); } static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINDouble128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINDoubleVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2234,13 +2433,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double128VectorTests::MIN); + assertArraysEquals(r, a, (double)10, mask, DoubleVector128Tests::MIN); } static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXDouble128VectorTestsWithMemOp(IntFunction fa) { + static void MAXDoubleVector128TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double128VectorTests::MAX); + assertArraysEquals(r, a, (double)10, DoubleVector128Tests::MAX); } static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void maxDouble128VectorTestsWithMemOp(IntFunction fa) { + static void maxDoubleVector128TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double128VectorTests::max); + assertArraysEquals(r, a, (double)10, DoubleVector128Tests::max); } static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXDouble128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXDoubleVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2287,15 +2486,15 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double128VectorTests::MAX); + assertArraysEquals(r, a, (double)10, mask, DoubleVector128Tests::MAX); } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void MINDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2308,15 +2507,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::MIN); + assertArraysEquals(r, a, b, DoubleVector128Tests::MIN); } static double min(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void minDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2327,15 +2526,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::min); + assertArraysEquals(r, a, b, DoubleVector128Tests::min); } static double MAX(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2348,15 +2547,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::MAX); + assertArraysEquals(r, a, b, DoubleVector128Tests::MAX); } static double max(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maxDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2367,11 +2566,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double128VectorTests::max); + assertArraysEquals(r, a, b, DoubleVector128Tests::max); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2381,11 +2580,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2395,11 +2594,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::min); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2409,11 +2608,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2423,13 +2622,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleVector128Tests::max); } static double ADDReduce(double[] a, int idx) { double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2438,14 +2637,14 @@ relativeError)); static double ADDReduceAll(double[] a) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceDouble128VectorTests(IntFunction fa) { + static void ADDReduceDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2456,12 +2655,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector128Tests::ADDReduce, DoubleVector128Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2469,20 +2668,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = ADD_IDENTITY; - assertEquals((double) (id + id), id, + assertEquals((double) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id + x), x); - assertEquals((double) (x + id), x); + assertEquals((double) (scalar_add(id, x)), x); + assertEquals((double) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id + x), x, + assertEquals((double) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x + id), x, + assertEquals((double) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2491,7 +2690,7 @@ relativeError)); double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2500,14 +2699,14 @@ relativeError)); static double ADDReduceAllMasked(double[] a, boolean[] mask) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2520,18 +2719,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector128Tests::ADDReduceMasked, DoubleVector128Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static double MULReduce(double[] a, int idx) { double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2540,14 +2739,14 @@ relativeError)); static double MULReduceAll(double[] a) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MULReduceDouble128VectorTests(IntFunction fa) { + static void MULReduceDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2558,12 +2757,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector128Tests::MULReduce, DoubleVector128Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2571,20 +2770,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MUL_IDENTITY; - assertEquals((double) (id * id), id, + assertEquals((double) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id * x), x); - assertEquals((double) (x * id), x); + assertEquals((double) (scalar_mul(id, x)), x); + assertEquals((double) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id * x), x, + assertEquals((double) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x * id), x, + assertEquals((double) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2593,7 +2792,7 @@ relativeError)); double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2602,14 +2801,14 @@ relativeError)); static double MULReduceAllMasked(double[] a, boolean[] mask) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MULReduceDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2622,18 +2821,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector128Tests::MULReduceMasked, DoubleVector128Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static double MINReduce(double[] a, int idx) { double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2642,14 +2841,14 @@ relativeError)); static double MINReduceAll(double[] a) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MINReduceDouble128VectorTests(IntFunction fa) { + static void MINReduceDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2660,12 +2859,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double128VectorTests::MINReduce, Double128VectorTests::MINReduceAll); + DoubleVector128Tests::MINReduce, DoubleVector128Tests::MINReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2673,20 +2872,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MIN_IDENTITY; - assertEquals((double) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.min(id, x), x); - assertEquals((double) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2695,7 +2894,7 @@ relativeError)); double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2704,14 +2903,14 @@ relativeError)); static double MINReduceAllMasked(double[] a, boolean[] mask) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINReduceDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2724,18 +2923,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::MINReduceMasked, Double128VectorTests::MINReduceAllMasked); + DoubleVector128Tests::MINReduceMasked, DoubleVector128Tests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2744,14 +2943,14 @@ relativeError)); static double MAXReduceAll(double[] a) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXReduceDouble128VectorTests(IntFunction fa) { + static void MAXReduceDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2762,12 +2961,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double128VectorTests::MAXReduce, Double128VectorTests::MAXReduceAll); + DoubleVector128Tests::MAXReduce, DoubleVector128Tests::MAXReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2775,20 +2974,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MAX_IDENTITY; - assertEquals((double) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.max(id, x), x); - assertEquals((double) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2797,7 +2996,7 @@ relativeError)); double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2806,14 +3005,14 @@ relativeError)); static double MAXReduceAllMasked(double[] a, boolean[] mask) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXReduceDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2826,12 +3025,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::MAXReduceMasked, Double128VectorTests::MAXReduceAllMasked); + DoubleVector128Tests::MAXReduceMasked, DoubleVector128Tests::MAXReduceAllMasked); } static double FIRST_NONZEROReduce(double[] a, int idx) { @@ -2853,7 +3052,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2869,7 +3068,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Double128VectorTests::FIRST_NONZEROReduce, Double128VectorTests::FIRST_NONZEROReduceAll); + DoubleVector128Tests::FIRST_NONZEROReduce, DoubleVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2915,7 +3114,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void FIRST_NONZEROReduceDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2933,11 +3132,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::FIRST_NONZEROReduceMasked, Double128VectorTests::FIRST_NONZEROReduceAllMasked); + DoubleVector128Tests::FIRST_NONZEROReduceMasked, DoubleVector128Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "doubleBinaryOpProvider") - static void withDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void withDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2960,7 +3159,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_DEFAULTDouble128VectorTests(IntFunction fa) { + static void IS_DEFAULTDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_DEFAULTMaskedDouble128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3001,7 +3200,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NEGATIVEDouble128VectorTests(IntFunction fa) { + static void IS_NEGATIVEDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NEGATIVEMaskedDouble128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3038,11 +3237,11 @@ relativeError)); } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_FINITEDouble128VectorTests(IntFunction fa) { + static void IS_FINITEDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3059,7 +3258,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_FINITEMaskedDouble128VectorTests(IntFunction fa, + static void IS_FINITEMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3079,11 +3278,11 @@ relativeError)); } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NANDouble128VectorTests(IntFunction fa) { + static void IS_NANDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3100,7 +3299,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NANMaskedDouble128VectorTests(IntFunction fa, + static void IS_NANMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3120,11 +3319,11 @@ relativeError)); } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_INFINITEDouble128VectorTests(IntFunction fa) { + static void IS_INFINITEDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3141,7 +3340,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_INFINITEMaskedDouble128VectorTests(IntFunction fa, + static void IS_INFINITEMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3161,7 +3360,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void LTDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3180,7 +3379,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void ltDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3199,7 +3398,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3222,7 +3421,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GTDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void GTDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3241,7 +3440,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GTDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3264,7 +3463,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void EQDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3283,7 +3482,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void eqDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3302,7 +3501,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3325,7 +3524,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void NEDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void NEDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3344,7 +3543,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void NEDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3367,7 +3566,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LEDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void LEDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3386,7 +3585,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LEDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3409,7 +3608,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GEDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void GEDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3428,7 +3627,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GEDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3451,7 +3650,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3461,13 +3660,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3481,13 +3680,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3497,13 +3696,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3517,13 +3716,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (double)((long)b[i])))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3533,13 +3732,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3553,13 +3752,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3569,13 +3768,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3589,7 +3788,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (double)((long)b[i])))); } } } @@ -3599,7 +3798,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble128VectorTests(IntFunction fa, IntFunction fb, + static void blendDoubleVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3615,11 +3814,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double128VectorTests::blend); + assertArraysEquals(r, a, b, mask, DoubleVector128Tests::blend); } @Test(dataProvider = "doubleUnaryOpShuffleProvider") - static void RearrangeDouble128VectorTests(IntFunction fa, + static void RearrangeDoubleVector128Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3636,7 +3835,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") - static void RearrangeDouble128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeDoubleVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -3654,7 +3853,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void compressDouble128VectorTests(IntFunction fa, + static void compressDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3672,7 +3871,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void expandDouble128VectorTests(IntFunction fa, + static void expandDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3690,7 +3889,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void getDouble128VectorTests(IntFunction fa) { + static void getDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3846,7 +4045,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void BroadcastDouble128VectorTests(IntFunction fa) { + static void BroadcastDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3860,7 +4059,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ZeroDouble128VectorTests(IntFunction fa) { + static void ZeroDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3885,7 +4084,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sliceUnaryDouble128VectorTests(IntFunction fa) { + static void sliceUnaryDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3896,7 +4095,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleVector128Tests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { @@ -3913,7 +4112,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void sliceBinaryDouble128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryDoubleVector128TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3926,7 +4125,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Double128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleVector128Tests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { @@ -3943,7 +4142,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void sliceDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3960,7 +4159,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Double128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleVector128Tests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { @@ -3977,7 +4176,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void unsliceUnaryDouble128VectorTests(IntFunction fa) { + static void unsliceUnaryDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3988,7 +4187,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleVector128Tests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { @@ -4014,7 +4213,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void unsliceBinaryDouble128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryDoubleVector128TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -4028,7 +4227,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Double128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleVector128Tests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { @@ -4068,7 +4267,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void unsliceDouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceDoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4085,19 +4284,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Double128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleVector128Tests::unslice); } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINDouble128VectorTests(IntFunction fa) { + static void SINDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4108,19 +4307,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SIN, Double128VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::SIN, DoubleVector128Tests::strictSIN); } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPDouble128VectorTests(IntFunction fa) { + static void EXPDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4131,19 +4330,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXP, Double128VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::EXP, DoubleVector128Tests::strictEXP); } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG1PDouble128VectorTests(IntFunction fa) { + static void LOG1PDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4154,19 +4353,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG1P, Double128VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::LOG1P, DoubleVector128Tests::strictLOG1P); } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOGDouble128VectorTests(IntFunction fa) { + static void LOGDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4177,19 +4376,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG, Double128VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::LOG, DoubleVector128Tests::strictLOG); } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG10Double128VectorTests(IntFunction fa) { + static void LOG10DoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4200,19 +4399,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG10, Double128VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::LOG10, DoubleVector128Tests::strictLOG10); } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPM1Double128VectorTests(IntFunction fa) { + static void EXPM1DoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4223,19 +4422,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXPM1, Double128VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::EXPM1, DoubleVector128Tests::strictEXPM1); } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSDouble128VectorTests(IntFunction fa) { + static void COSDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4246,19 +4445,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COS, Double128VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::COS, DoubleVector128Tests::strictCOS); } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANDouble128VectorTests(IntFunction fa) { + static void TANDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4269,19 +4468,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TAN, Double128VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::TAN, DoubleVector128Tests::strictTAN); } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINHDouble128VectorTests(IntFunction fa) { + static void SINHDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4292,19 +4491,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SINH, Double128VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::SINH, DoubleVector128Tests::strictSINH); } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSHDouble128VectorTests(IntFunction fa) { + static void COSHDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4315,19 +4514,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COSH, Double128VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::COSH, DoubleVector128Tests::strictCOSH); } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANHDouble128VectorTests(IntFunction fa) { + static void TANHDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4338,19 +4537,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TANH, Double128VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::TANH, DoubleVector128Tests::strictTANH); } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ASINDouble128VectorTests(IntFunction fa) { + static void ASINDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4361,19 +4560,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ASIN, Double128VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::ASIN, DoubleVector128Tests::strictASIN); } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ACOSDouble128VectorTests(IntFunction fa) { + static void ACOSDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4384,19 +4583,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ACOS, Double128VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::ACOS, DoubleVector128Tests::strictACOS); } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ATANDouble128VectorTests(IntFunction fa) { + static void ATANDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4407,19 +4606,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ATAN, Double128VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::ATAN, DoubleVector128Tests::strictATAN); } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void CBRTDouble128VectorTests(IntFunction fa) { + static void CBRTDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4430,19 +4629,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::CBRT, Double128VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector128Tests::CBRT, DoubleVector128Tests::strictCBRT); } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void HYPOTDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4455,20 +4654,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::HYPOT, Double128VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::HYPOT, DoubleVector128Tests::strictHYPOT); } static double POW(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictPOW(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void POWDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4481,20 +4680,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::POW, DoubleVector128Tests::strictPOW); } static double pow(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictpow(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void powDoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4507,20 +4706,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::pow, DoubleVector128Tests::strictpow); } static double ATAN2(double a, double b) { - return (double)(Math.atan2((double)a, (double)b)); + return (double)(scalar_atan2(a, b)); } static double strictATAN2(double a, double b) { - return (double)(StrictMath.atan2((double)a, (double)b)); + return (double)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ATAN2Double128VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2DoubleVector128Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4533,12 +4732,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::ATAN2, Double128VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::ATAN2, DoubleVector128Tests::strictATAN2); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4548,12 +4747,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::POW, DoubleVector128Tests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4563,20 +4762,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector128Tests::pow, DoubleVector128Tests::strictpow); } static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4598,11 +4797,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Double128VectorTests::FMA); + assertArraysEquals(r, a, b, c, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4622,11 +4821,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Double128VectorTests::fma); + assertArraysEquals(r, a, b, c, DoubleVector128Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMADoubleVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4651,11 +4850,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4666,11 +4865,11 @@ relativeError)); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4681,11 +4880,11 @@ relativeError)); DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4700,11 +4899,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4719,11 +4918,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4741,11 +4940,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector128Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4763,11 +4962,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector128Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4788,19 +4987,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleVector128Tests::FMA); } static double NEG(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } static double neg(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void NEGDouble128VectorTests(IntFunction fa) { + static void NEGDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4811,11 +5010,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::NEG); + assertArraysEquals(r, a, DoubleVector128Tests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") - static void negDouble128VectorTests(IntFunction fa) { + static void negDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4826,11 +5025,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::neg); + assertArraysEquals(r, a, DoubleVector128Tests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void NEGMaskedDouble128VectorTests(IntFunction fa, + static void NEGMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4844,19 +5043,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double128VectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleVector128Tests::NEG); } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ABSDouble128VectorTests(IntFunction fa) { + static void ABSDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4867,11 +5066,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::ABS); + assertArraysEquals(r, a, DoubleVector128Tests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") - static void absDouble128VectorTests(IntFunction fa) { + static void absDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4882,11 +5081,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::abs); + assertArraysEquals(r, a, DoubleVector128Tests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ABSMaskedDouble128VectorTests(IntFunction fa, + static void ABSMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4900,19 +5099,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double128VectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleVector128Tests::ABS); } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SQRTDouble128VectorTests(IntFunction fa) { + static void SQRTDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4923,11 +5122,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::SQRT); + assertArraysEquals(r, a, DoubleVector128Tests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sqrtDouble128VectorTests(IntFunction fa) { + static void sqrtDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4938,11 +5137,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::sqrt); + assertArraysEquals(r, a, DoubleVector128Tests::sqrt); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void SQRTMaskedDouble128VectorTests(IntFunction fa, + static void SQRTMaskedDoubleVector128Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4956,7 +5155,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double128VectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleVector128Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4964,7 +5163,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4977,7 +5176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::band); + assertArraysEquals(r, a, b, DoubleVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4985,7 +5184,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4998,7 +5197,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::bor); + assertArraysEquals(r, a, b, DoubleVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -5006,7 +5205,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5019,7 +5218,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::bxor); + assertArraysEquals(r, a, b, DoubleVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5027,7 +5226,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5040,7 +5239,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::bandNot); + assertArraysEquals(r, a, b, DoubleVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5048,7 +5247,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5061,7 +5260,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double128VectorTests::beq); + assertArraysEquals(r, a, b, DoubleVector128Tests::beq); } static boolean unot(boolean a) { @@ -5069,7 +5268,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotDouble128VectorTests(IntFunction fa) { + static void masknotDoubleVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5080,7 +5279,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::unot); + assertArraysEquals(r, a, DoubleVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5097,7 +5296,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongDouble128VectorTests(IntFunction fa) { + static void maskFromToLongDoubleVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5111,7 +5310,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltDoubleVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5121,13 +5320,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqDoubleVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5137,13 +5336,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubletoIntUnaryOpProvider") - static void toIntArrayDouble128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayDoubleVector128TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5154,7 +5353,7 @@ relativeError)); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void toLongArrayDouble128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayDoubleVector128TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5166,7 +5365,7 @@ relativeError)); @Test(dataProvider = "doubleUnaryOpProvider") - static void toStringDouble128VectorTestsSmokeTest(IntFunction fa) { + static void toStringDoubleVector128TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5179,7 +5378,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void hashCodeDouble128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeDoubleVector128TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5196,7 +5395,7 @@ relativeError)); static long ADDReduceLong(double[] a, int idx) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5205,14 +5404,14 @@ relativeError)); static long ADDReduceAllLong(double[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((double)res, (double)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceLongDouble128VectorTests(IntFunction fa) { + static void ADDReduceLongDoubleVector128Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5223,19 +5422,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Double128VectorTests::ADDReduceLong, Double128VectorTests::ADDReduceAllLong); + DoubleVector128Tests::ADDReduceLong, DoubleVector128Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5244,14 +5444,14 @@ relativeError)); static long ADDReduceAllLongMasked(double[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((double)res, (double)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceLongDouble128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongDoubleVector128TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5264,16 +5464,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Double128VectorTests::ADDReduceLongMasked, Double128VectorTests::ADDReduceAllLongMasked); + DoubleVector128Tests::ADDReduceLongMasked, DoubleVector128Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void BroadcastLongDouble128VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongDoubleVector128TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -5284,7 +5484,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendDoubleVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5298,12 +5498,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Double128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector128Tests::blend); } @Test(dataProvider = "doubleUnaryOpSelectFromProvider") - static void SelectFromDouble128VectorTests(IntFunction fa, + static void SelectFromDoubleVector128Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); double[] order = fs.apply(a.length, SPECIES.length()); @@ -5319,7 +5519,7 @@ relativeError)); } @Test(dataProvider = "doubleSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorDouble128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorDoubleVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] idx = fc.apply(SPECIES.length()); @@ -5337,7 +5537,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") - static void SelectFromDouble128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromDoubleVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -5356,7 +5556,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousDouble128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousDoubleVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5372,7 +5572,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringDouble128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringDoubleVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5386,7 +5586,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsDouble128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsDoubleVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5400,7 +5600,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsDouble128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsDoubleVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5416,7 +5616,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeDouble128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeDoubleVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5438,7 +5638,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountDouble128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountDoubleVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5449,7 +5649,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, DoubleVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5463,7 +5663,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueDouble128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueDoubleVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5474,7 +5674,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5488,7 +5688,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueDouble128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueDoubleVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5499,11 +5699,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressDouble128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressDoubleVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5531,7 +5731,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeDouble128VectorTestsSmokeTest(int offset) { + static void indexInRangeDoubleVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5545,7 +5745,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongDouble128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongDoubleVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5572,14 +5772,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundDouble128VectorTestsSmokeTest(int length) { + static void loopBoundDoubleVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongDouble128VectorTestsSmokeTest(int _length) { + static void loopBoundLongDoubleVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5587,21 +5787,21 @@ relativeError)); } @Test - static void ElementSizeDouble128VectorTestsSmokeTest() { + static void ElementSizeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Double.SIZE); } @Test - static void VectorShapeDouble128VectorTestsSmokeTest() { + static void VectorShapeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesDouble128VectorTestsSmokeTest() { + static void ShapeWithLanesDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(double.class); @@ -5609,32 +5809,32 @@ relativeError)); } @Test - static void ElementTypeDouble128VectorTestsSmokeTest() { + static void ElementTypeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementType() == double.class); } @Test - static void SpeciesElementSizeDouble128VectorTestsSmokeTest() { + static void SpeciesElementSizeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementSize() == Double.SIZE); } @Test - static void VectorTypeDouble128VectorTestsSmokeTest() { + static void VectorTypeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesDouble128VectorTestsSmokeTest() { + static void WithLanesDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(double.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeDouble128VectorTestsSmokeTest() { + static void WithShapeDoubleVector128TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5642,7 +5842,7 @@ relativeError)); } @Test - static void MaskAllTrueDouble128VectorTestsSmokeTest() { + static void MaskAllTrueDoubleVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector256LoadStoreTests.java index 56d5608a89d..b966bafb299 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Double256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation DoubleVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Double256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class DoubleVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Double256VectorTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector256Tests.java index d39b6f9c923..e417abe52e6 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Double256VectorTests extends AbstractVectorTest { +public class DoubleVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_256; @@ -1584,6 +1584,205 @@ relativeError)); return Double.compare(a, (double) 0) != 0 ? a : b; } + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1677,11 +1876,11 @@ relativeError)); } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1694,15 +1893,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::ADD); + assertArraysEquals(r, a, b, DoubleVector256Tests::ADD); } static double add(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void addDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1713,11 +1912,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::add); + assertArraysEquals(r, a, b, DoubleVector256Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1733,11 +1932,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1751,15 +1950,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double256VectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::add); } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void SUBDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1772,15 +1971,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::SUB); + assertArraysEquals(r, a, b, DoubleVector256Tests::SUB); } static double sub(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void subDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1791,11 +1990,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::sub); + assertArraysEquals(r, a, b, DoubleVector256Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void SUBDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1811,11 +2010,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1829,15 +2028,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double256VectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::sub); } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MULDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void MULDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1850,15 +2049,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::MUL); + assertArraysEquals(r, a, b, DoubleVector256Tests::MUL); } static double mul(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void mulDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1869,11 +2068,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::mul); + assertArraysEquals(r, a, b, DoubleVector256Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void MULDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1889,11 +2088,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1907,15 +2106,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double256VectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::mul); } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void DIVDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1928,15 +2127,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::DIV); + assertArraysEquals(r, a, b, DoubleVector256Tests::DIV); } static double div(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void divDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1947,11 +2146,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::div); + assertArraysEquals(r, a, b, DoubleVector256Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void DIVDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1967,11 +2166,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1985,15 +2184,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double256VectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::div); } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void FIRST_NONZERODouble256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZERODoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2006,11 +2205,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void FIRST_NONZERODouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZERODoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2026,11 +2225,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2040,11 +2239,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector256Tests::add); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2071,11 +2270,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector256Tests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2301,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector256Tests::mul); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2133,11 +2332,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector256Tests::div); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2164,11 +2363,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Double256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleVector256Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDDoubleVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2181,13 +2380,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Double256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector256Tests::ADD); } static DoubleVector bv_MIN = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MINDouble256VectorTestsWithMemOp(IntFunction fa) { + static void MINDoubleVector256TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double256VectorTests::MIN); + assertArraysEquals(r, a, (double)10, DoubleVector256Tests::MIN); } static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void minDouble256VectorTestsWithMemOp(IntFunction fa) { + static void minDoubleVector256TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double256VectorTests::min); + assertArraysEquals(r, a, (double)10, DoubleVector256Tests::min); } static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINDouble256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINDoubleVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2234,13 +2433,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double256VectorTests::MIN); + assertArraysEquals(r, a, (double)10, mask, DoubleVector256Tests::MIN); } static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXDouble256VectorTestsWithMemOp(IntFunction fa) { + static void MAXDoubleVector256TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double256VectorTests::MAX); + assertArraysEquals(r, a, (double)10, DoubleVector256Tests::MAX); } static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void maxDouble256VectorTestsWithMemOp(IntFunction fa) { + static void maxDoubleVector256TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double256VectorTests::max); + assertArraysEquals(r, a, (double)10, DoubleVector256Tests::max); } static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXDouble256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXDoubleVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2287,15 +2486,15 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double256VectorTests::MAX); + assertArraysEquals(r, a, (double)10, mask, DoubleVector256Tests::MAX); } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void MINDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2308,15 +2507,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::MIN); + assertArraysEquals(r, a, b, DoubleVector256Tests::MIN); } static double min(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void minDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2327,15 +2526,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::min); + assertArraysEquals(r, a, b, DoubleVector256Tests::min); } static double MAX(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2348,15 +2547,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::MAX); + assertArraysEquals(r, a, b, DoubleVector256Tests::MAX); } static double max(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maxDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2367,11 +2566,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double256VectorTests::max); + assertArraysEquals(r, a, b, DoubleVector256Tests::max); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2381,11 +2580,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2395,11 +2594,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::min); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2409,11 +2608,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2423,13 +2622,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleVector256Tests::max); } static double ADDReduce(double[] a, int idx) { double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2438,14 +2637,14 @@ relativeError)); static double ADDReduceAll(double[] a) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceDouble256VectorTests(IntFunction fa) { + static void ADDReduceDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2456,12 +2655,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double256VectorTests::ADDReduce, Double256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector256Tests::ADDReduce, DoubleVector256Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2469,20 +2668,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = ADD_IDENTITY; - assertEquals((double) (id + id), id, + assertEquals((double) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id + x), x); - assertEquals((double) (x + id), x); + assertEquals((double) (scalar_add(id, x)), x); + assertEquals((double) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id + x), x, + assertEquals((double) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x + id), x, + assertEquals((double) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2491,7 +2690,7 @@ relativeError)); double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2500,14 +2699,14 @@ relativeError)); static double ADDReduceAllMasked(double[] a, boolean[] mask) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2520,18 +2719,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::ADDReduceMasked, Double256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector256Tests::ADDReduceMasked, DoubleVector256Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static double MULReduce(double[] a, int idx) { double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2540,14 +2739,14 @@ relativeError)); static double MULReduceAll(double[] a) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MULReduceDouble256VectorTests(IntFunction fa) { + static void MULReduceDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2558,12 +2757,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double256VectorTests::MULReduce, Double256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector256Tests::MULReduce, DoubleVector256Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2571,20 +2770,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MUL_IDENTITY; - assertEquals((double) (id * id), id, + assertEquals((double) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id * x), x); - assertEquals((double) (x * id), x); + assertEquals((double) (scalar_mul(id, x)), x); + assertEquals((double) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id * x), x, + assertEquals((double) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x * id), x, + assertEquals((double) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2593,7 +2792,7 @@ relativeError)); double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2602,14 +2801,14 @@ relativeError)); static double MULReduceAllMasked(double[] a, boolean[] mask) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MULReduceDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2622,18 +2821,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::MULReduceMasked, Double256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector256Tests::MULReduceMasked, DoubleVector256Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static double MINReduce(double[] a, int idx) { double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2642,14 +2841,14 @@ relativeError)); static double MINReduceAll(double[] a) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MINReduceDouble256VectorTests(IntFunction fa) { + static void MINReduceDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2660,12 +2859,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double256VectorTests::MINReduce, Double256VectorTests::MINReduceAll); + DoubleVector256Tests::MINReduce, DoubleVector256Tests::MINReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2673,20 +2872,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MIN_IDENTITY; - assertEquals((double) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.min(id, x), x); - assertEquals((double) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2695,7 +2894,7 @@ relativeError)); double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2704,14 +2903,14 @@ relativeError)); static double MINReduceAllMasked(double[] a, boolean[] mask) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINReduceDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2724,18 +2923,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::MINReduceMasked, Double256VectorTests::MINReduceAllMasked); + DoubleVector256Tests::MINReduceMasked, DoubleVector256Tests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2744,14 +2943,14 @@ relativeError)); static double MAXReduceAll(double[] a) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXReduceDouble256VectorTests(IntFunction fa) { + static void MAXReduceDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2762,12 +2961,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double256VectorTests::MAXReduce, Double256VectorTests::MAXReduceAll); + DoubleVector256Tests::MAXReduce, DoubleVector256Tests::MAXReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2775,20 +2974,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MAX_IDENTITY; - assertEquals((double) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.max(id, x), x); - assertEquals((double) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2797,7 +2996,7 @@ relativeError)); double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2806,14 +3005,14 @@ relativeError)); static double MAXReduceAllMasked(double[] a, boolean[] mask) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXReduceDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2826,12 +3025,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::MAXReduceMasked, Double256VectorTests::MAXReduceAllMasked); + DoubleVector256Tests::MAXReduceMasked, DoubleVector256Tests::MAXReduceAllMasked); } static double FIRST_NONZEROReduce(double[] a, int idx) { @@ -2853,7 +3052,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void FIRST_NONZEROReduceDouble256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2869,7 +3068,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Double256VectorTests::FIRST_NONZEROReduce, Double256VectorTests::FIRST_NONZEROReduceAll); + DoubleVector256Tests::FIRST_NONZEROReduce, DoubleVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2915,7 +3114,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void FIRST_NONZEROReduceDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2933,11 +3132,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::FIRST_NONZEROReduceMasked, Double256VectorTests::FIRST_NONZEROReduceAllMasked); + DoubleVector256Tests::FIRST_NONZEROReduceMasked, DoubleVector256Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "doubleBinaryOpProvider") - static void withDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void withDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2960,7 +3159,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_DEFAULTDouble256VectorTests(IntFunction fa) { + static void IS_DEFAULTDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_DEFAULTMaskedDouble256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3001,7 +3200,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NEGATIVEDouble256VectorTests(IntFunction fa) { + static void IS_NEGATIVEDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NEGATIVEMaskedDouble256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3038,11 +3237,11 @@ relativeError)); } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_FINITEDouble256VectorTests(IntFunction fa) { + static void IS_FINITEDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3059,7 +3258,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_FINITEMaskedDouble256VectorTests(IntFunction fa, + static void IS_FINITEMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3079,11 +3278,11 @@ relativeError)); } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NANDouble256VectorTests(IntFunction fa) { + static void IS_NANDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3100,7 +3299,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NANMaskedDouble256VectorTests(IntFunction fa, + static void IS_NANMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3120,11 +3319,11 @@ relativeError)); } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_INFINITEDouble256VectorTests(IntFunction fa) { + static void IS_INFINITEDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3141,7 +3340,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_INFINITEMaskedDouble256VectorTests(IntFunction fa, + static void IS_INFINITEMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3161,7 +3360,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void LTDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3180,7 +3379,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void ltDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3199,7 +3398,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3222,7 +3421,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GTDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void GTDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3241,7 +3440,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GTDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3264,7 +3463,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void EQDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3283,7 +3482,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void eqDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3302,7 +3501,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3325,7 +3524,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void NEDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void NEDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3344,7 +3543,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void NEDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3367,7 +3566,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LEDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void LEDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3386,7 +3585,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LEDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3409,7 +3608,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GEDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void GEDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3428,7 +3627,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GEDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3451,7 +3650,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3461,13 +3660,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3481,13 +3680,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3497,13 +3696,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3517,13 +3716,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (double)((long)b[i])))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3533,13 +3732,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3553,13 +3752,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3569,13 +3768,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3589,7 +3788,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (double)((long)b[i])))); } } } @@ -3599,7 +3798,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble256VectorTests(IntFunction fa, IntFunction fb, + static void blendDoubleVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3615,11 +3814,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double256VectorTests::blend); + assertArraysEquals(r, a, b, mask, DoubleVector256Tests::blend); } @Test(dataProvider = "doubleUnaryOpShuffleProvider") - static void RearrangeDouble256VectorTests(IntFunction fa, + static void RearrangeDoubleVector256Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3636,7 +3835,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") - static void RearrangeDouble256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeDoubleVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -3654,7 +3853,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void compressDouble256VectorTests(IntFunction fa, + static void compressDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3672,7 +3871,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void expandDouble256VectorTests(IntFunction fa, + static void expandDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3690,7 +3889,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void getDouble256VectorTests(IntFunction fa) { + static void getDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3846,7 +4045,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void BroadcastDouble256VectorTests(IntFunction fa) { + static void BroadcastDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3860,7 +4059,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ZeroDouble256VectorTests(IntFunction fa) { + static void ZeroDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3885,7 +4084,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sliceUnaryDouble256VectorTests(IntFunction fa) { + static void sliceUnaryDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3896,7 +4095,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleVector256Tests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { @@ -3913,7 +4112,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void sliceBinaryDouble256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryDoubleVector256TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3926,7 +4125,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Double256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleVector256Tests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { @@ -3943,7 +4142,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void sliceDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3960,7 +4159,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Double256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleVector256Tests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { @@ -3977,7 +4176,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void unsliceUnaryDouble256VectorTests(IntFunction fa) { + static void unsliceUnaryDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3988,7 +4187,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleVector256Tests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { @@ -4014,7 +4213,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void unsliceBinaryDouble256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryDoubleVector256TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -4028,7 +4227,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Double256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleVector256Tests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { @@ -4068,7 +4267,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void unsliceDouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceDoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4085,19 +4284,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Double256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleVector256Tests::unslice); } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINDouble256VectorTests(IntFunction fa) { + static void SINDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4108,19 +4307,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SIN, Double256VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::SIN, DoubleVector256Tests::strictSIN); } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPDouble256VectorTests(IntFunction fa) { + static void EXPDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4131,19 +4330,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXP, Double256VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::EXP, DoubleVector256Tests::strictEXP); } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG1PDouble256VectorTests(IntFunction fa) { + static void LOG1PDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4154,19 +4353,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG1P, Double256VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::LOG1P, DoubleVector256Tests::strictLOG1P); } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOGDouble256VectorTests(IntFunction fa) { + static void LOGDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4177,19 +4376,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG, Double256VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::LOG, DoubleVector256Tests::strictLOG); } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG10Double256VectorTests(IntFunction fa) { + static void LOG10DoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4200,19 +4399,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::LOG10, Double256VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::LOG10, DoubleVector256Tests::strictLOG10); } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPM1Double256VectorTests(IntFunction fa) { + static void EXPM1DoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4223,19 +4422,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::EXPM1, Double256VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::EXPM1, DoubleVector256Tests::strictEXPM1); } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSDouble256VectorTests(IntFunction fa) { + static void COSDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4246,19 +4445,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COS, Double256VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::COS, DoubleVector256Tests::strictCOS); } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANDouble256VectorTests(IntFunction fa) { + static void TANDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4269,19 +4468,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TAN, Double256VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::TAN, DoubleVector256Tests::strictTAN); } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINHDouble256VectorTests(IntFunction fa) { + static void SINHDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4292,19 +4491,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::SINH, Double256VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::SINH, DoubleVector256Tests::strictSINH); } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSHDouble256VectorTests(IntFunction fa) { + static void COSHDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4315,19 +4514,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::COSH, Double256VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::COSH, DoubleVector256Tests::strictCOSH); } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANHDouble256VectorTests(IntFunction fa) { + static void TANHDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4338,19 +4537,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::TANH, Double256VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::TANH, DoubleVector256Tests::strictTANH); } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ASINDouble256VectorTests(IntFunction fa) { + static void ASINDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4361,19 +4560,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ASIN, Double256VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::ASIN, DoubleVector256Tests::strictASIN); } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ACOSDouble256VectorTests(IntFunction fa) { + static void ACOSDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4384,19 +4583,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ACOS, Double256VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::ACOS, DoubleVector256Tests::strictACOS); } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ATANDouble256VectorTests(IntFunction fa) { + static void ATANDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4407,19 +4606,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::ATAN, Double256VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::ATAN, DoubleVector256Tests::strictATAN); } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void CBRTDouble256VectorTests(IntFunction fa) { + static void CBRTDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4430,19 +4629,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double256VectorTests::CBRT, Double256VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector256Tests::CBRT, DoubleVector256Tests::strictCBRT); } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void HYPOTDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4455,20 +4654,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::HYPOT, Double256VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::HYPOT, DoubleVector256Tests::strictHYPOT); } static double POW(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictPOW(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void POWDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4481,20 +4680,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::POW, Double256VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::POW, DoubleVector256Tests::strictPOW); } static double pow(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictpow(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void powDoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4507,20 +4706,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::pow, Double256VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::pow, DoubleVector256Tests::strictpow); } static double ATAN2(double a, double b) { - return (double)(Math.atan2((double)a, (double)b)); + return (double)(scalar_atan2(a, b)); } static double strictATAN2(double a, double b) { - return (double)(StrictMath.atan2((double)a, (double)b)); + return (double)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ATAN2Double256VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2DoubleVector256Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4533,12 +4732,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::ATAN2, Double256VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::ATAN2, DoubleVector256Tests::strictATAN2); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4548,12 +4747,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::POW, Double256VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::POW, DoubleVector256Tests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4563,20 +4762,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double256VectorTests::pow, Double256VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector256Tests::pow, DoubleVector256Tests::strictpow); } static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4598,11 +4797,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Double256VectorTests::FMA); + assertArraysEquals(r, a, b, c, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4622,11 +4821,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Double256VectorTests::fma); + assertArraysEquals(r, a, b, c, DoubleVector256Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMADoubleVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4651,11 +4850,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4666,11 +4865,11 @@ relativeError)); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4681,11 +4880,11 @@ relativeError)); DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4700,11 +4899,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4719,11 +4918,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4741,11 +4940,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double256VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector256Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4763,11 +4962,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double256VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector256Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4788,19 +4987,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double256VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleVector256Tests::FMA); } static double NEG(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } static double neg(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void NEGDouble256VectorTests(IntFunction fa) { + static void NEGDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4811,11 +5010,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::NEG); + assertArraysEquals(r, a, DoubleVector256Tests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") - static void negDouble256VectorTests(IntFunction fa) { + static void negDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4826,11 +5025,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::neg); + assertArraysEquals(r, a, DoubleVector256Tests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void NEGMaskedDouble256VectorTests(IntFunction fa, + static void NEGMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4844,19 +5043,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double256VectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleVector256Tests::NEG); } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ABSDouble256VectorTests(IntFunction fa) { + static void ABSDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4867,11 +5066,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::ABS); + assertArraysEquals(r, a, DoubleVector256Tests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") - static void absDouble256VectorTests(IntFunction fa) { + static void absDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4882,11 +5081,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::abs); + assertArraysEquals(r, a, DoubleVector256Tests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ABSMaskedDouble256VectorTests(IntFunction fa, + static void ABSMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4900,19 +5099,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double256VectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleVector256Tests::ABS); } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SQRTDouble256VectorTests(IntFunction fa) { + static void SQRTDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4923,11 +5122,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::SQRT); + assertArraysEquals(r, a, DoubleVector256Tests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sqrtDouble256VectorTests(IntFunction fa) { + static void sqrtDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4938,11 +5137,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::sqrt); + assertArraysEquals(r, a, DoubleVector256Tests::sqrt); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void SQRTMaskedDouble256VectorTests(IntFunction fa, + static void SQRTMaskedDoubleVector256Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4956,7 +5155,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double256VectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleVector256Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4964,7 +5163,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4977,7 +5176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::band); + assertArraysEquals(r, a, b, DoubleVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4985,7 +5184,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4998,7 +5197,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::bor); + assertArraysEquals(r, a, b, DoubleVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -5006,7 +5205,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5019,7 +5218,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::bxor); + assertArraysEquals(r, a, b, DoubleVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5027,7 +5226,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5040,7 +5239,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::bandNot); + assertArraysEquals(r, a, b, DoubleVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5048,7 +5247,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5061,7 +5260,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double256VectorTests::beq); + assertArraysEquals(r, a, b, DoubleVector256Tests::beq); } static boolean unot(boolean a) { @@ -5069,7 +5268,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotDouble256VectorTests(IntFunction fa) { + static void masknotDoubleVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5080,7 +5279,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::unot); + assertArraysEquals(r, a, DoubleVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5097,7 +5296,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongDouble256VectorTests(IntFunction fa) { + static void maskFromToLongDoubleVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5111,7 +5310,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltDoubleVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5121,13 +5320,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqDoubleVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5137,13 +5336,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubletoIntUnaryOpProvider") - static void toIntArrayDouble256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayDoubleVector256TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5154,7 +5353,7 @@ relativeError)); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void toLongArrayDouble256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayDoubleVector256TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5166,7 +5365,7 @@ relativeError)); @Test(dataProvider = "doubleUnaryOpProvider") - static void toStringDouble256VectorTestsSmokeTest(IntFunction fa) { + static void toStringDoubleVector256TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5179,7 +5378,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void hashCodeDouble256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeDoubleVector256TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5196,7 +5395,7 @@ relativeError)); static long ADDReduceLong(double[] a, int idx) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5205,14 +5404,14 @@ relativeError)); static long ADDReduceAllLong(double[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((double)res, (double)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceLongDouble256VectorTests(IntFunction fa) { + static void ADDReduceLongDoubleVector256Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5223,19 +5422,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Double256VectorTests::ADDReduceLong, Double256VectorTests::ADDReduceAllLong); + DoubleVector256Tests::ADDReduceLong, DoubleVector256Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5244,14 +5444,14 @@ relativeError)); static long ADDReduceAllLongMasked(double[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((double)res, (double)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceLongDouble256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongDoubleVector256TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5264,16 +5464,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Double256VectorTests::ADDReduceLongMasked, Double256VectorTests::ADDReduceAllLongMasked); + DoubleVector256Tests::ADDReduceLongMasked, DoubleVector256Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void BroadcastLongDouble256VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongDoubleVector256TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -5284,7 +5484,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendDoubleVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5298,12 +5498,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Double256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector256Tests::blend); } @Test(dataProvider = "doubleUnaryOpSelectFromProvider") - static void SelectFromDouble256VectorTests(IntFunction fa, + static void SelectFromDoubleVector256Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); double[] order = fs.apply(a.length, SPECIES.length()); @@ -5319,7 +5519,7 @@ relativeError)); } @Test(dataProvider = "doubleSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorDouble256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorDoubleVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] idx = fc.apply(SPECIES.length()); @@ -5337,7 +5537,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") - static void SelectFromDouble256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromDoubleVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -5356,7 +5556,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousDouble256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousDoubleVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5372,7 +5572,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringDouble256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringDoubleVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5386,7 +5586,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsDouble256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsDoubleVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5400,7 +5600,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsDouble256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsDoubleVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5416,7 +5616,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeDouble256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeDoubleVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5438,7 +5638,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountDouble256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountDoubleVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5449,7 +5649,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, DoubleVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5463,7 +5663,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueDouble256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueDoubleVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5474,7 +5674,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5488,7 +5688,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueDouble256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueDoubleVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5499,11 +5699,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressDouble256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressDoubleVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5531,7 +5731,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeDouble256VectorTestsSmokeTest(int offset) { + static void indexInRangeDoubleVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5545,7 +5745,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongDouble256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongDoubleVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5572,14 +5772,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundDouble256VectorTestsSmokeTest(int length) { + static void loopBoundDoubleVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongDouble256VectorTestsSmokeTest(int _length) { + static void loopBoundLongDoubleVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5587,21 +5787,21 @@ relativeError)); } @Test - static void ElementSizeDouble256VectorTestsSmokeTest() { + static void ElementSizeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Double.SIZE); } @Test - static void VectorShapeDouble256VectorTestsSmokeTest() { + static void VectorShapeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesDouble256VectorTestsSmokeTest() { + static void ShapeWithLanesDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(double.class); @@ -5609,32 +5809,32 @@ relativeError)); } @Test - static void ElementTypeDouble256VectorTestsSmokeTest() { + static void ElementTypeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementType() == double.class); } @Test - static void SpeciesElementSizeDouble256VectorTestsSmokeTest() { + static void SpeciesElementSizeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementSize() == Double.SIZE); } @Test - static void VectorTypeDouble256VectorTestsSmokeTest() { + static void VectorTypeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesDouble256VectorTestsSmokeTest() { + static void WithLanesDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(double.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeDouble256VectorTestsSmokeTest() { + static void WithShapeDoubleVector256TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5642,7 +5842,7 @@ relativeError)); } @Test - static void MaskAllTrueDouble256VectorTestsSmokeTest() { + static void MaskAllTrueDoubleVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector512LoadStoreTests.java index ea76ba814d5..cb60f7363af 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Double512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation DoubleVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Double512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class DoubleVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Double512VectorTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector512Tests.java index 7983ae0efe7..d23b2bf1511 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Double512VectorTests extends AbstractVectorTest { +public class DoubleVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_512; @@ -1584,6 +1584,205 @@ relativeError)); return Double.compare(a, (double) 0) != 0 ? a : b; } + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1677,11 +1876,11 @@ relativeError)); } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1694,15 +1893,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::ADD); + assertArraysEquals(r, a, b, DoubleVector512Tests::ADD); } static double add(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void addDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1713,11 +1912,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::add); + assertArraysEquals(r, a, b, DoubleVector512Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1733,11 +1932,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1751,15 +1950,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double512VectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::add); } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void SUBDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1772,15 +1971,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::SUB); + assertArraysEquals(r, a, b, DoubleVector512Tests::SUB); } static double sub(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void subDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1791,11 +1990,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::sub); + assertArraysEquals(r, a, b, DoubleVector512Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void SUBDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1811,11 +2010,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1829,15 +2028,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double512VectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::sub); } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MULDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void MULDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1850,15 +2049,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::MUL); + assertArraysEquals(r, a, b, DoubleVector512Tests::MUL); } static double mul(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void mulDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1869,11 +2068,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::mul); + assertArraysEquals(r, a, b, DoubleVector512Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void MULDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1889,11 +2088,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1907,15 +2106,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double512VectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::mul); } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void DIVDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1928,15 +2127,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::DIV); + assertArraysEquals(r, a, b, DoubleVector512Tests::DIV); } static double div(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void divDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1947,11 +2146,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::div); + assertArraysEquals(r, a, b, DoubleVector512Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void DIVDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1967,11 +2166,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1985,15 +2184,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double512VectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::div); } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void FIRST_NONZERODouble512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZERODoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2006,11 +2205,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void FIRST_NONZERODouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZERODoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2026,11 +2225,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2040,11 +2239,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector512Tests::add); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2071,11 +2270,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector512Tests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2301,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector512Tests::mul); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2133,11 +2332,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector512Tests::div); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2164,11 +2363,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Double512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleVector512Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDDoubleVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2181,13 +2380,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Double512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector512Tests::ADD); } static DoubleVector bv_MIN = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MINDouble512VectorTestsWithMemOp(IntFunction fa) { + static void MINDoubleVector512TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double512VectorTests::MIN); + assertArraysEquals(r, a, (double)10, DoubleVector512Tests::MIN); } static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void minDouble512VectorTestsWithMemOp(IntFunction fa) { + static void minDoubleVector512TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double512VectorTests::min); + assertArraysEquals(r, a, (double)10, DoubleVector512Tests::min); } static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINDouble512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINDoubleVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2234,13 +2433,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double512VectorTests::MIN); + assertArraysEquals(r, a, (double)10, mask, DoubleVector512Tests::MIN); } static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXDouble512VectorTestsWithMemOp(IntFunction fa) { + static void MAXDoubleVector512TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double512VectorTests::MAX); + assertArraysEquals(r, a, (double)10, DoubleVector512Tests::MAX); } static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void maxDouble512VectorTestsWithMemOp(IntFunction fa) { + static void maxDoubleVector512TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double512VectorTests::max); + assertArraysEquals(r, a, (double)10, DoubleVector512Tests::max); } static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXDouble512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXDoubleVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2287,15 +2486,15 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double512VectorTests::MAX); + assertArraysEquals(r, a, (double)10, mask, DoubleVector512Tests::MAX); } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void MINDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2308,15 +2507,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::MIN); + assertArraysEquals(r, a, b, DoubleVector512Tests::MIN); } static double min(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void minDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2327,15 +2526,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::min); + assertArraysEquals(r, a, b, DoubleVector512Tests::min); } static double MAX(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2348,15 +2547,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::MAX); + assertArraysEquals(r, a, b, DoubleVector512Tests::MAX); } static double max(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maxDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2367,11 +2566,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double512VectorTests::max); + assertArraysEquals(r, a, b, DoubleVector512Tests::max); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2381,11 +2580,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2395,11 +2594,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::min); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2409,11 +2608,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2423,13 +2622,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleVector512Tests::max); } static double ADDReduce(double[] a, int idx) { double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2438,14 +2637,14 @@ relativeError)); static double ADDReduceAll(double[] a) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceDouble512VectorTests(IntFunction fa) { + static void ADDReduceDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2456,12 +2655,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double512VectorTests::ADDReduce, Double512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector512Tests::ADDReduce, DoubleVector512Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2469,20 +2668,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = ADD_IDENTITY; - assertEquals((double) (id + id), id, + assertEquals((double) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id + x), x); - assertEquals((double) (x + id), x); + assertEquals((double) (scalar_add(id, x)), x); + assertEquals((double) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id + x), x, + assertEquals((double) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x + id), x, + assertEquals((double) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2491,7 +2690,7 @@ relativeError)); double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2500,14 +2699,14 @@ relativeError)); static double ADDReduceAllMasked(double[] a, boolean[] mask) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2520,18 +2719,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::ADDReduceMasked, Double512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector512Tests::ADDReduceMasked, DoubleVector512Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static double MULReduce(double[] a, int idx) { double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2540,14 +2739,14 @@ relativeError)); static double MULReduceAll(double[] a) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MULReduceDouble512VectorTests(IntFunction fa) { + static void MULReduceDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2558,12 +2757,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double512VectorTests::MULReduce, Double512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector512Tests::MULReduce, DoubleVector512Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2571,20 +2770,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MUL_IDENTITY; - assertEquals((double) (id * id), id, + assertEquals((double) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id * x), x); - assertEquals((double) (x * id), x); + assertEquals((double) (scalar_mul(id, x)), x); + assertEquals((double) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id * x), x, + assertEquals((double) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x * id), x, + assertEquals((double) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2593,7 +2792,7 @@ relativeError)); double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2602,14 +2801,14 @@ relativeError)); static double MULReduceAllMasked(double[] a, boolean[] mask) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MULReduceDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2622,18 +2821,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::MULReduceMasked, Double512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector512Tests::MULReduceMasked, DoubleVector512Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static double MINReduce(double[] a, int idx) { double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2642,14 +2841,14 @@ relativeError)); static double MINReduceAll(double[] a) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MINReduceDouble512VectorTests(IntFunction fa) { + static void MINReduceDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2660,12 +2859,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double512VectorTests::MINReduce, Double512VectorTests::MINReduceAll); + DoubleVector512Tests::MINReduce, DoubleVector512Tests::MINReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2673,20 +2872,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MIN_IDENTITY; - assertEquals((double) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.min(id, x), x); - assertEquals((double) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2695,7 +2894,7 @@ relativeError)); double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2704,14 +2903,14 @@ relativeError)); static double MINReduceAllMasked(double[] a, boolean[] mask) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINReduceDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2724,18 +2923,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::MINReduceMasked, Double512VectorTests::MINReduceAllMasked); + DoubleVector512Tests::MINReduceMasked, DoubleVector512Tests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2744,14 +2943,14 @@ relativeError)); static double MAXReduceAll(double[] a) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXReduceDouble512VectorTests(IntFunction fa) { + static void MAXReduceDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2762,12 +2961,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double512VectorTests::MAXReduce, Double512VectorTests::MAXReduceAll); + DoubleVector512Tests::MAXReduce, DoubleVector512Tests::MAXReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2775,20 +2974,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MAX_IDENTITY; - assertEquals((double) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.max(id, x), x); - assertEquals((double) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2797,7 +2996,7 @@ relativeError)); double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2806,14 +3005,14 @@ relativeError)); static double MAXReduceAllMasked(double[] a, boolean[] mask) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXReduceDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2826,12 +3025,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::MAXReduceMasked, Double512VectorTests::MAXReduceAllMasked); + DoubleVector512Tests::MAXReduceMasked, DoubleVector512Tests::MAXReduceAllMasked); } static double FIRST_NONZEROReduce(double[] a, int idx) { @@ -2853,7 +3052,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void FIRST_NONZEROReduceDouble512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2869,7 +3068,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Double512VectorTests::FIRST_NONZEROReduce, Double512VectorTests::FIRST_NONZEROReduceAll); + DoubleVector512Tests::FIRST_NONZEROReduce, DoubleVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2915,7 +3114,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void FIRST_NONZEROReduceDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2933,11 +3132,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::FIRST_NONZEROReduceMasked, Double512VectorTests::FIRST_NONZEROReduceAllMasked); + DoubleVector512Tests::FIRST_NONZEROReduceMasked, DoubleVector512Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "doubleBinaryOpProvider") - static void withDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void withDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2960,7 +3159,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_DEFAULTDouble512VectorTests(IntFunction fa) { + static void IS_DEFAULTDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_DEFAULTMaskedDouble512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3001,7 +3200,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NEGATIVEDouble512VectorTests(IntFunction fa) { + static void IS_NEGATIVEDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NEGATIVEMaskedDouble512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3038,11 +3237,11 @@ relativeError)); } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_FINITEDouble512VectorTests(IntFunction fa) { + static void IS_FINITEDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3059,7 +3258,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_FINITEMaskedDouble512VectorTests(IntFunction fa, + static void IS_FINITEMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3079,11 +3278,11 @@ relativeError)); } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NANDouble512VectorTests(IntFunction fa) { + static void IS_NANDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3100,7 +3299,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NANMaskedDouble512VectorTests(IntFunction fa, + static void IS_NANMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3120,11 +3319,11 @@ relativeError)); } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_INFINITEDouble512VectorTests(IntFunction fa) { + static void IS_INFINITEDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3141,7 +3340,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_INFINITEMaskedDouble512VectorTests(IntFunction fa, + static void IS_INFINITEMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3161,7 +3360,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void LTDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3180,7 +3379,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void ltDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3199,7 +3398,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3222,7 +3421,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GTDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void GTDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3241,7 +3440,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GTDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3264,7 +3463,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void EQDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3283,7 +3482,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void eqDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3302,7 +3501,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3325,7 +3524,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void NEDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void NEDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3344,7 +3543,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void NEDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3367,7 +3566,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LEDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void LEDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3386,7 +3585,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LEDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3409,7 +3608,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GEDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void GEDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3428,7 +3627,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GEDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3451,7 +3650,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3461,13 +3660,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3481,13 +3680,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3497,13 +3696,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3517,13 +3716,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (double)((long)b[i])))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3533,13 +3732,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3553,13 +3752,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3569,13 +3768,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3589,7 +3788,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (double)((long)b[i])))); } } } @@ -3599,7 +3798,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble512VectorTests(IntFunction fa, IntFunction fb, + static void blendDoubleVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3615,11 +3814,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double512VectorTests::blend); + assertArraysEquals(r, a, b, mask, DoubleVector512Tests::blend); } @Test(dataProvider = "doubleUnaryOpShuffleProvider") - static void RearrangeDouble512VectorTests(IntFunction fa, + static void RearrangeDoubleVector512Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3636,7 +3835,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") - static void RearrangeDouble512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeDoubleVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -3654,7 +3853,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void compressDouble512VectorTests(IntFunction fa, + static void compressDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3672,7 +3871,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void expandDouble512VectorTests(IntFunction fa, + static void expandDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3690,7 +3889,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void getDouble512VectorTests(IntFunction fa) { + static void getDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3846,7 +4045,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void BroadcastDouble512VectorTests(IntFunction fa) { + static void BroadcastDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3860,7 +4059,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ZeroDouble512VectorTests(IntFunction fa) { + static void ZeroDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3885,7 +4084,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sliceUnaryDouble512VectorTests(IntFunction fa) { + static void sliceUnaryDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3896,7 +4095,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleVector512Tests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { @@ -3913,7 +4112,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void sliceBinaryDouble512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryDoubleVector512TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3926,7 +4125,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Double512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleVector512Tests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { @@ -3943,7 +4142,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void sliceDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3960,7 +4159,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Double512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleVector512Tests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { @@ -3977,7 +4176,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void unsliceUnaryDouble512VectorTests(IntFunction fa) { + static void unsliceUnaryDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3988,7 +4187,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleVector512Tests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { @@ -4014,7 +4213,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void unsliceBinaryDouble512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryDoubleVector512TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -4028,7 +4227,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Double512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleVector512Tests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { @@ -4068,7 +4267,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void unsliceDouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceDoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4085,19 +4284,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Double512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleVector512Tests::unslice); } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINDouble512VectorTests(IntFunction fa) { + static void SINDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4108,19 +4307,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::SIN, Double512VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::SIN, DoubleVector512Tests::strictSIN); } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPDouble512VectorTests(IntFunction fa) { + static void EXPDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4131,19 +4330,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::EXP, Double512VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::EXP, DoubleVector512Tests::strictEXP); } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG1PDouble512VectorTests(IntFunction fa) { + static void LOG1PDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4154,19 +4353,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG1P, Double512VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::LOG1P, DoubleVector512Tests::strictLOG1P); } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOGDouble512VectorTests(IntFunction fa) { + static void LOGDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4177,19 +4376,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG, Double512VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::LOG, DoubleVector512Tests::strictLOG); } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG10Double512VectorTests(IntFunction fa) { + static void LOG10DoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4200,19 +4399,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::LOG10, Double512VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::LOG10, DoubleVector512Tests::strictLOG10); } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPM1Double512VectorTests(IntFunction fa) { + static void EXPM1DoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4223,19 +4422,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::EXPM1, Double512VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::EXPM1, DoubleVector512Tests::strictEXPM1); } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSDouble512VectorTests(IntFunction fa) { + static void COSDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4246,19 +4445,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::COS, Double512VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::COS, DoubleVector512Tests::strictCOS); } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANDouble512VectorTests(IntFunction fa) { + static void TANDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4269,19 +4468,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::TAN, Double512VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::TAN, DoubleVector512Tests::strictTAN); } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINHDouble512VectorTests(IntFunction fa) { + static void SINHDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4292,19 +4491,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::SINH, Double512VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::SINH, DoubleVector512Tests::strictSINH); } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSHDouble512VectorTests(IntFunction fa) { + static void COSHDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4315,19 +4514,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::COSH, Double512VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::COSH, DoubleVector512Tests::strictCOSH); } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANHDouble512VectorTests(IntFunction fa) { + static void TANHDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4338,19 +4537,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::TANH, Double512VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::TANH, DoubleVector512Tests::strictTANH); } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ASINDouble512VectorTests(IntFunction fa) { + static void ASINDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4361,19 +4560,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ASIN, Double512VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::ASIN, DoubleVector512Tests::strictASIN); } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ACOSDouble512VectorTests(IntFunction fa) { + static void ACOSDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4384,19 +4583,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ACOS, Double512VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::ACOS, DoubleVector512Tests::strictACOS); } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ATANDouble512VectorTests(IntFunction fa) { + static void ATANDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4407,19 +4606,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::ATAN, Double512VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::ATAN, DoubleVector512Tests::strictATAN); } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void CBRTDouble512VectorTests(IntFunction fa) { + static void CBRTDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4430,19 +4629,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double512VectorTests::CBRT, Double512VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector512Tests::CBRT, DoubleVector512Tests::strictCBRT); } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void HYPOTDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4455,20 +4654,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::HYPOT, Double512VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::HYPOT, DoubleVector512Tests::strictHYPOT); } static double POW(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictPOW(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void POWDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4481,20 +4680,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::POW, Double512VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::POW, DoubleVector512Tests::strictPOW); } static double pow(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictpow(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void powDoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4507,20 +4706,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::pow, Double512VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::pow, DoubleVector512Tests::strictpow); } static double ATAN2(double a, double b) { - return (double)(Math.atan2((double)a, (double)b)); + return (double)(scalar_atan2(a, b)); } static double strictATAN2(double a, double b) { - return (double)(StrictMath.atan2((double)a, (double)b)); + return (double)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ATAN2Double512VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2DoubleVector512Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4533,12 +4732,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::ATAN2, Double512VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::ATAN2, DoubleVector512Tests::strictATAN2); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4548,12 +4747,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::POW, Double512VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::POW, DoubleVector512Tests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4563,20 +4762,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double512VectorTests::pow, Double512VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector512Tests::pow, DoubleVector512Tests::strictpow); } static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4598,11 +4797,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Double512VectorTests::FMA); + assertArraysEquals(r, a, b, c, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4622,11 +4821,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Double512VectorTests::fma); + assertArraysEquals(r, a, b, c, DoubleVector512Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMADoubleVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4651,11 +4850,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Double512VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4666,11 +4865,11 @@ relativeError)); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Double512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4681,11 +4880,11 @@ relativeError)); DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Double512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4700,11 +4899,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Double512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4719,11 +4918,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Double512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4741,11 +4940,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double512VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector512Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4763,11 +4962,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double512VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector512Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4788,19 +4987,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double512VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleVector512Tests::FMA); } static double NEG(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } static double neg(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void NEGDouble512VectorTests(IntFunction fa) { + static void NEGDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4811,11 +5010,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::NEG); + assertArraysEquals(r, a, DoubleVector512Tests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") - static void negDouble512VectorTests(IntFunction fa) { + static void negDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4826,11 +5025,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::neg); + assertArraysEquals(r, a, DoubleVector512Tests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void NEGMaskedDouble512VectorTests(IntFunction fa, + static void NEGMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4844,19 +5043,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double512VectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleVector512Tests::NEG); } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ABSDouble512VectorTests(IntFunction fa) { + static void ABSDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4867,11 +5066,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::ABS); + assertArraysEquals(r, a, DoubleVector512Tests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") - static void absDouble512VectorTests(IntFunction fa) { + static void absDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4882,11 +5081,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::abs); + assertArraysEquals(r, a, DoubleVector512Tests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ABSMaskedDouble512VectorTests(IntFunction fa, + static void ABSMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4900,19 +5099,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double512VectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleVector512Tests::ABS); } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SQRTDouble512VectorTests(IntFunction fa) { + static void SQRTDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4923,11 +5122,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::SQRT); + assertArraysEquals(r, a, DoubleVector512Tests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sqrtDouble512VectorTests(IntFunction fa) { + static void sqrtDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4938,11 +5137,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::sqrt); + assertArraysEquals(r, a, DoubleVector512Tests::sqrt); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void SQRTMaskedDouble512VectorTests(IntFunction fa, + static void SQRTMaskedDoubleVector512Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4956,7 +5155,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double512VectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleVector512Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4964,7 +5163,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4977,7 +5176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::band); + assertArraysEquals(r, a, b, DoubleVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4985,7 +5184,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4998,7 +5197,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::bor); + assertArraysEquals(r, a, b, DoubleVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -5006,7 +5205,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5019,7 +5218,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::bxor); + assertArraysEquals(r, a, b, DoubleVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5027,7 +5226,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5040,7 +5239,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::bandNot); + assertArraysEquals(r, a, b, DoubleVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5048,7 +5247,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5061,7 +5260,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double512VectorTests::beq); + assertArraysEquals(r, a, b, DoubleVector512Tests::beq); } static boolean unot(boolean a) { @@ -5069,7 +5268,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotDouble512VectorTests(IntFunction fa) { + static void masknotDoubleVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5080,7 +5279,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::unot); + assertArraysEquals(r, a, DoubleVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5097,7 +5296,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongDouble512VectorTests(IntFunction fa) { + static void maskFromToLongDoubleVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5111,7 +5310,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltDoubleVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5121,13 +5320,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqDoubleVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5137,13 +5336,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubletoIntUnaryOpProvider") - static void toIntArrayDouble512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayDoubleVector512TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5154,7 +5353,7 @@ relativeError)); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void toLongArrayDouble512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayDoubleVector512TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5166,7 +5365,7 @@ relativeError)); @Test(dataProvider = "doubleUnaryOpProvider") - static void toStringDouble512VectorTestsSmokeTest(IntFunction fa) { + static void toStringDoubleVector512TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5179,7 +5378,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void hashCodeDouble512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeDoubleVector512TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5196,7 +5395,7 @@ relativeError)); static long ADDReduceLong(double[] a, int idx) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5205,14 +5404,14 @@ relativeError)); static long ADDReduceAllLong(double[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((double)res, (double)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceLongDouble512VectorTests(IntFunction fa) { + static void ADDReduceLongDoubleVector512Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5223,19 +5422,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Double512VectorTests::ADDReduceLong, Double512VectorTests::ADDReduceAllLong); + DoubleVector512Tests::ADDReduceLong, DoubleVector512Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5244,14 +5444,14 @@ relativeError)); static long ADDReduceAllLongMasked(double[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((double)res, (double)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceLongDouble512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongDoubleVector512TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5264,16 +5464,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Double512VectorTests::ADDReduceLongMasked, Double512VectorTests::ADDReduceAllLongMasked); + DoubleVector512Tests::ADDReduceLongMasked, DoubleVector512Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void BroadcastLongDouble512VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongDoubleVector512TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -5284,7 +5484,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendDoubleVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5298,12 +5498,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Double512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector512Tests::blend); } @Test(dataProvider = "doubleUnaryOpSelectFromProvider") - static void SelectFromDouble512VectorTests(IntFunction fa, + static void SelectFromDoubleVector512Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); double[] order = fs.apply(a.length, SPECIES.length()); @@ -5319,7 +5519,7 @@ relativeError)); } @Test(dataProvider = "doubleSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorDouble512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorDoubleVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] idx = fc.apply(SPECIES.length()); @@ -5337,7 +5537,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") - static void SelectFromDouble512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromDoubleVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -5356,7 +5556,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousDouble512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousDoubleVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5372,7 +5572,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringDouble512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringDoubleVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5386,7 +5586,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsDouble512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsDoubleVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5400,7 +5600,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsDouble512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsDoubleVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5416,7 +5616,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeDouble512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeDoubleVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5438,7 +5638,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountDouble512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountDoubleVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5449,7 +5649,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, DoubleVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5463,7 +5663,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueDouble512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueDoubleVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5474,7 +5674,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5488,7 +5688,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueDouble512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueDoubleVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5499,11 +5699,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressDouble512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressDoubleVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5531,7 +5731,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeDouble512VectorTestsSmokeTest(int offset) { + static void indexInRangeDoubleVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5545,7 +5745,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongDouble512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongDoubleVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5572,14 +5772,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundDouble512VectorTestsSmokeTest(int length) { + static void loopBoundDoubleVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongDouble512VectorTestsSmokeTest(int _length) { + static void loopBoundLongDoubleVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5587,21 +5787,21 @@ relativeError)); } @Test - static void ElementSizeDouble512VectorTestsSmokeTest() { + static void ElementSizeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Double.SIZE); } @Test - static void VectorShapeDouble512VectorTestsSmokeTest() { + static void VectorShapeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesDouble512VectorTestsSmokeTest() { + static void ShapeWithLanesDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(double.class); @@ -5609,32 +5809,32 @@ relativeError)); } @Test - static void ElementTypeDouble512VectorTestsSmokeTest() { + static void ElementTypeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementType() == double.class); } @Test - static void SpeciesElementSizeDouble512VectorTestsSmokeTest() { + static void SpeciesElementSizeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementSize() == Double.SIZE); } @Test - static void VectorTypeDouble512VectorTestsSmokeTest() { + static void VectorTypeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesDouble512VectorTestsSmokeTest() { + static void WithLanesDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(double.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeDouble512VectorTestsSmokeTest() { + static void WithShapeDoubleVector512TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5642,7 +5842,7 @@ relativeError)); } @Test - static void MaskAllTrueDouble512VectorTestsSmokeTest() { + static void MaskAllTrueDoubleVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector64LoadStoreTests.java index 30c4b92aa86..f07f5be00db 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Double64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation DoubleVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Double64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class DoubleVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Double64VectorTests.java rename to test/jdk/jdk/incubator/vector/DoubleVector64Tests.java index 2cc56b1bce3..d2aff0b7ea5 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Double64VectorTests extends AbstractVectorTest { +public class DoubleVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_64; @@ -1584,6 +1584,205 @@ relativeError)); return Double.compare(a, (double) 0) != 0 ? a : b; } + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1677,11 +1876,11 @@ relativeError)); } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1694,15 +1893,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::ADD); + assertArraysEquals(r, a, b, DoubleVector64Tests::ADD); } static double add(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void addDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1713,11 +1912,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::add); + assertArraysEquals(r, a, b, DoubleVector64Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1733,11 +1932,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1751,15 +1950,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double64VectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::add); } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void SUBDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1772,15 +1971,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::SUB); + assertArraysEquals(r, a, b, DoubleVector64Tests::SUB); } static double sub(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void subDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1791,11 +1990,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::sub); + assertArraysEquals(r, a, b, DoubleVector64Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void SUBDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1811,11 +2010,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1829,15 +2028,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double64VectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::sub); } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MULDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void MULDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1850,15 +2049,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::MUL); + assertArraysEquals(r, a, b, DoubleVector64Tests::MUL); } static double mul(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void mulDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1869,11 +2068,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::mul); + assertArraysEquals(r, a, b, DoubleVector64Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void MULDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1889,11 +2088,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1907,15 +2106,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double64VectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::mul); } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void DIVDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1928,15 +2127,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::DIV); + assertArraysEquals(r, a, b, DoubleVector64Tests::DIV); } static double div(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void divDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1947,11 +2146,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::div); + assertArraysEquals(r, a, b, DoubleVector64Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void DIVDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1967,11 +2166,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1985,15 +2184,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Double64VectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::div); } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void FIRST_NONZERODouble64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZERODoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2006,11 +2205,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void FIRST_NONZERODouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZERODoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2026,11 +2225,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2040,11 +2239,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector64Tests::add); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2071,11 +2270,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector64Tests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2102,11 +2301,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector64Tests::mul); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2133,11 +2332,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Double64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVector64Tests::div); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDDoubleVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2164,11 +2363,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Double64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleVector64Tests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDouble64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDDoubleVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2181,13 +2380,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Double64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector64Tests::ADD); } static DoubleVector bv_MIN = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MINDouble64VectorTestsWithMemOp(IntFunction fa) { + static void MINDoubleVector64TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double64VectorTests::MIN); + assertArraysEquals(r, a, (double)10, DoubleVector64Tests::MIN); } static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void minDouble64VectorTestsWithMemOp(IntFunction fa) { + static void minDoubleVector64TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double64VectorTests::min); + assertArraysEquals(r, a, (double)10, DoubleVector64Tests::min); } static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINDoubleVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2234,13 +2433,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double64VectorTests::MIN); + assertArraysEquals(r, a, (double)10, mask, DoubleVector64Tests::MIN); } static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXDouble64VectorTestsWithMemOp(IntFunction fa) { + static void MAXDoubleVector64TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double64VectorTests::MAX); + assertArraysEquals(r, a, (double)10, DoubleVector64Tests::MAX); } static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void maxDouble64VectorTestsWithMemOp(IntFunction fa) { + static void maxDoubleVector64TestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, Double64VectorTests::max); + assertArraysEquals(r, a, (double)10, DoubleVector64Tests::max); } static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXDoubleVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2287,15 +2486,15 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, Double64VectorTests::MAX); + assertArraysEquals(r, a, (double)10, mask, DoubleVector64Tests::MAX); } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void MINDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2308,15 +2507,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::MIN); + assertArraysEquals(r, a, b, DoubleVector64Tests::MIN); } static double min(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void minDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2327,15 +2526,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::min); + assertArraysEquals(r, a, b, DoubleVector64Tests::min); } static double MAX(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2348,15 +2547,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::MAX); + assertArraysEquals(r, a, b, DoubleVector64Tests::MAX); } static double max(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maxDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2367,11 +2566,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Double64VectorTests::max); + assertArraysEquals(r, a, b, DoubleVector64Tests::max); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2381,11 +2580,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2395,11 +2594,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::min); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2409,11 +2608,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2423,13 +2622,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Double64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleVector64Tests::max); } static double ADDReduce(double[] a, int idx) { double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2438,14 +2637,14 @@ relativeError)); static double ADDReduceAll(double[] a) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceDouble64VectorTests(IntFunction fa) { + static void ADDReduceDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2456,12 +2655,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double64VectorTests::ADDReduce, Double64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector64Tests::ADDReduce, DoubleVector64Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2469,20 +2668,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = ADD_IDENTITY; - assertEquals((double) (id + id), id, + assertEquals((double) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id + x), x); - assertEquals((double) (x + id), x); + assertEquals((double) (scalar_add(id, x)), x); + assertEquals((double) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id + x), x, + assertEquals((double) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x + id), x, + assertEquals((double) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2491,7 +2690,7 @@ relativeError)); double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2500,14 +2699,14 @@ relativeError)); static double ADDReduceAllMasked(double[] a, boolean[] mask) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2520,18 +2719,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::ADDReduceMasked, Double64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVector64Tests::ADDReduceMasked, DoubleVector64Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static double MULReduce(double[] a, int idx) { double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2540,14 +2739,14 @@ relativeError)); static double MULReduceAll(double[] a) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MULReduceDouble64VectorTests(IntFunction fa) { + static void MULReduceDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2558,12 +2757,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double64VectorTests::MULReduce, Double64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector64Tests::MULReduce, DoubleVector64Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2571,20 +2770,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MUL_IDENTITY; - assertEquals((double) (id * id), id, + assertEquals((double) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id * x), x); - assertEquals((double) (x * id), x); + assertEquals((double) (scalar_mul(id, x)), x); + assertEquals((double) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id * x), x, + assertEquals((double) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x * id), x, + assertEquals((double) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2593,7 +2792,7 @@ relativeError)); double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2602,14 +2801,14 @@ relativeError)); static double MULReduceAllMasked(double[] a, boolean[] mask) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MULReduceDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2622,18 +2821,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::MULReduceMasked, Double64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVector64Tests::MULReduceMasked, DoubleVector64Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static double MINReduce(double[] a, int idx) { double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2642,14 +2841,14 @@ relativeError)); static double MINReduceAll(double[] a) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MINReduceDouble64VectorTests(IntFunction fa) { + static void MINReduceDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2660,12 +2859,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double64VectorTests::MINReduce, Double64VectorTests::MINReduceAll); + DoubleVector64Tests::MINReduce, DoubleVector64Tests::MINReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2673,20 +2872,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MIN_IDENTITY; - assertEquals((double) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.min(id, x), x); - assertEquals((double) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2695,7 +2894,7 @@ relativeError)); double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2704,14 +2903,14 @@ relativeError)); static double MINReduceAllMasked(double[] a, boolean[] mask) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINReduceDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2724,18 +2923,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::MINReduceMasked, Double64VectorTests::MINReduceAllMasked); + DoubleVector64Tests::MINReduceMasked, DoubleVector64Tests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2744,14 +2943,14 @@ relativeError)); static double MAXReduceAll(double[] a) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXReduceDouble64VectorTests(IntFunction fa) { + static void MAXReduceDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2762,12 +2961,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Double64VectorTests::MAXReduce, Double64VectorTests::MAXReduceAll); + DoubleVector64Tests::MAXReduce, DoubleVector64Tests::MAXReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2775,20 +2974,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MAX_IDENTITY; - assertEquals((double) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.max(id, x), x); - assertEquals((double) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2797,7 +2996,7 @@ relativeError)); double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2806,14 +3005,14 @@ relativeError)); static double MAXReduceAllMasked(double[] a, boolean[] mask) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXReduceDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2826,12 +3025,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::MAXReduceMasked, Double64VectorTests::MAXReduceAllMasked); + DoubleVector64Tests::MAXReduceMasked, DoubleVector64Tests::MAXReduceAllMasked); } static double FIRST_NONZEROReduce(double[] a, int idx) { @@ -2853,7 +3052,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void FIRST_NONZEROReduceDouble64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2869,7 +3068,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Double64VectorTests::FIRST_NONZEROReduce, Double64VectorTests::FIRST_NONZEROReduceAll); + DoubleVector64Tests::FIRST_NONZEROReduce, DoubleVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2915,7 +3114,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void FIRST_NONZEROReduceDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2933,11 +3132,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::FIRST_NONZEROReduceMasked, Double64VectorTests::FIRST_NONZEROReduceAllMasked); + DoubleVector64Tests::FIRST_NONZEROReduceMasked, DoubleVector64Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "doubleBinaryOpProvider") - static void withDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void withDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2960,7 +3159,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_DEFAULTDouble64VectorTests(IntFunction fa) { + static void IS_DEFAULTDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_DEFAULTMaskedDouble64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3001,7 +3200,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NEGATIVEDouble64VectorTests(IntFunction fa) { + static void IS_NEGATIVEDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NEGATIVEMaskedDouble64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3038,11 +3237,11 @@ relativeError)); } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_FINITEDouble64VectorTests(IntFunction fa) { + static void IS_FINITEDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3059,7 +3258,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_FINITEMaskedDouble64VectorTests(IntFunction fa, + static void IS_FINITEMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3079,11 +3278,11 @@ relativeError)); } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NANDouble64VectorTests(IntFunction fa) { + static void IS_NANDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3100,7 +3299,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NANMaskedDouble64VectorTests(IntFunction fa, + static void IS_NANMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3120,11 +3319,11 @@ relativeError)); } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_INFINITEDouble64VectorTests(IntFunction fa) { + static void IS_INFINITEDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3141,7 +3340,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_INFINITEMaskedDouble64VectorTests(IntFunction fa, + static void IS_INFINITEMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3161,7 +3360,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void LTDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3180,7 +3379,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void ltDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3199,7 +3398,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3222,7 +3421,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GTDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void GTDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3241,7 +3440,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GTDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3264,7 +3463,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void EQDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3283,7 +3482,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void eqDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3302,7 +3501,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3325,7 +3524,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void NEDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void NEDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3344,7 +3543,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void NEDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3367,7 +3566,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LEDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void LEDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3386,7 +3585,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LEDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3409,7 +3608,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GEDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void GEDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3428,7 +3627,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GEDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3451,7 +3650,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3461,13 +3660,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3481,13 +3680,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3497,13 +3696,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDouble64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTDoubleVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3517,13 +3716,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (double)((long)b[i])))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3533,13 +3732,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3553,13 +3752,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3569,13 +3768,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDouble64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQDoubleVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3589,7 +3788,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (double)((long)b[i])))); } } } @@ -3599,7 +3798,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble64VectorTests(IntFunction fa, IntFunction fb, + static void blendDoubleVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3615,11 +3814,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Double64VectorTests::blend); + assertArraysEquals(r, a, b, mask, DoubleVector64Tests::blend); } @Test(dataProvider = "doubleUnaryOpShuffleProvider") - static void RearrangeDouble64VectorTests(IntFunction fa, + static void RearrangeDoubleVector64Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3636,7 +3835,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") - static void RearrangeDouble64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeDoubleVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -3654,7 +3853,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void compressDouble64VectorTests(IntFunction fa, + static void compressDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3672,7 +3871,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void expandDouble64VectorTests(IntFunction fa, + static void expandDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3690,7 +3889,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void getDouble64VectorTests(IntFunction fa) { + static void getDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3846,7 +4045,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void BroadcastDouble64VectorTests(IntFunction fa) { + static void BroadcastDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3860,7 +4059,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ZeroDouble64VectorTests(IntFunction fa) { + static void ZeroDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3885,7 +4084,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sliceUnaryDouble64VectorTests(IntFunction fa) { + static void sliceUnaryDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3896,7 +4095,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleVector64Tests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { @@ -3913,7 +4112,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void sliceBinaryDouble64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryDoubleVector64TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3926,7 +4125,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Double64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleVector64Tests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { @@ -3943,7 +4142,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void sliceDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3960,7 +4159,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Double64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleVector64Tests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { @@ -3977,7 +4176,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void unsliceUnaryDouble64VectorTests(IntFunction fa) { + static void unsliceUnaryDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3988,7 +4187,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Double64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleVector64Tests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { @@ -4014,7 +4213,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void unsliceBinaryDouble64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryDoubleVector64TestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -4028,7 +4227,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Double64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleVector64Tests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { @@ -4068,7 +4267,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void unsliceDouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceDoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4085,19 +4284,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Double64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleVector64Tests::unslice); } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINDouble64VectorTests(IntFunction fa) { + static void SINDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4108,19 +4307,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::SIN, Double64VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::SIN, DoubleVector64Tests::strictSIN); } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPDouble64VectorTests(IntFunction fa) { + static void EXPDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4131,19 +4330,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::EXP, Double64VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::EXP, DoubleVector64Tests::strictEXP); } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG1PDouble64VectorTests(IntFunction fa) { + static void LOG1PDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4154,19 +4353,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG1P, Double64VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::LOG1P, DoubleVector64Tests::strictLOG1P); } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOGDouble64VectorTests(IntFunction fa) { + static void LOGDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4177,19 +4376,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG, Double64VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::LOG, DoubleVector64Tests::strictLOG); } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG10Double64VectorTests(IntFunction fa) { + static void LOG10DoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4200,19 +4399,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::LOG10, Double64VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::LOG10, DoubleVector64Tests::strictLOG10); } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPM1Double64VectorTests(IntFunction fa) { + static void EXPM1DoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4223,19 +4422,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::EXPM1, Double64VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::EXPM1, DoubleVector64Tests::strictEXPM1); } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSDouble64VectorTests(IntFunction fa) { + static void COSDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4246,19 +4445,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::COS, Double64VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::COS, DoubleVector64Tests::strictCOS); } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANDouble64VectorTests(IntFunction fa) { + static void TANDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4269,19 +4468,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::TAN, Double64VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::TAN, DoubleVector64Tests::strictTAN); } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINHDouble64VectorTests(IntFunction fa) { + static void SINHDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4292,19 +4491,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::SINH, Double64VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::SINH, DoubleVector64Tests::strictSINH); } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSHDouble64VectorTests(IntFunction fa) { + static void COSHDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4315,19 +4514,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::COSH, Double64VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::COSH, DoubleVector64Tests::strictCOSH); } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANHDouble64VectorTests(IntFunction fa) { + static void TANHDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4338,19 +4537,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::TANH, Double64VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::TANH, DoubleVector64Tests::strictTANH); } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ASINDouble64VectorTests(IntFunction fa) { + static void ASINDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4361,19 +4560,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ASIN, Double64VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::ASIN, DoubleVector64Tests::strictASIN); } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ACOSDouble64VectorTests(IntFunction fa) { + static void ACOSDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4384,19 +4583,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ACOS, Double64VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::ACOS, DoubleVector64Tests::strictACOS); } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ATANDouble64VectorTests(IntFunction fa) { + static void ATANDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4407,19 +4606,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::ATAN, Double64VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::ATAN, DoubleVector64Tests::strictATAN); } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void CBRTDouble64VectorTests(IntFunction fa) { + static void CBRTDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4430,19 +4629,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Double64VectorTests::CBRT, Double64VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleVector64Tests::CBRT, DoubleVector64Tests::strictCBRT); } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void HYPOTDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4455,20 +4654,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::HYPOT, Double64VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::HYPOT, DoubleVector64Tests::strictHYPOT); } static double POW(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictPOW(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void POWDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4481,20 +4680,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::POW, Double64VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::POW, DoubleVector64Tests::strictPOW); } static double pow(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictpow(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void powDoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4507,20 +4706,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::pow, Double64VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::pow, DoubleVector64Tests::strictpow); } static double ATAN2(double a, double b) { - return (double)(Math.atan2((double)a, (double)b)); + return (double)(scalar_atan2(a, b)); } static double strictATAN2(double a, double b) { - return (double)(StrictMath.atan2((double)a, (double)b)); + return (double)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ATAN2Double64VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2DoubleVector64Tests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4533,12 +4732,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::ATAN2, Double64VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::ATAN2, DoubleVector64Tests::strictATAN2); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4548,12 +4747,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::POW, Double64VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::POW, DoubleVector64Tests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4563,20 +4762,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double64VectorTests::pow, Double64VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVector64Tests::pow, DoubleVector64Tests::strictpow); } static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4598,11 +4797,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Double64VectorTests::FMA); + assertArraysEquals(r, a, b, c, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4622,11 +4821,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Double64VectorTests::fma); + assertArraysEquals(r, a, b, c, DoubleVector64Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMADoubleVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4651,11 +4850,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Double64VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4666,11 +4865,11 @@ relativeError)); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4681,11 +4880,11 @@ relativeError)); DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4700,11 +4899,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Double64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4719,11 +4918,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Double64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADouble64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4741,11 +4940,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector64Tests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDouble64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4763,11 +4962,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Double64VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVector64Tests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADouble64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4788,19 +4987,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleVector64Tests::FMA); } static double NEG(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } static double neg(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void NEGDouble64VectorTests(IntFunction fa) { + static void NEGDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4811,11 +5010,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::NEG); + assertArraysEquals(r, a, DoubleVector64Tests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") - static void negDouble64VectorTests(IntFunction fa) { + static void negDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4826,11 +5025,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::neg); + assertArraysEquals(r, a, DoubleVector64Tests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void NEGMaskedDouble64VectorTests(IntFunction fa, + static void NEGMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4844,19 +5043,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double64VectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleVector64Tests::NEG); } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ABSDouble64VectorTests(IntFunction fa) { + static void ABSDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4867,11 +5066,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::ABS); + assertArraysEquals(r, a, DoubleVector64Tests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") - static void absDouble64VectorTests(IntFunction fa) { + static void absDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4882,11 +5081,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::abs); + assertArraysEquals(r, a, DoubleVector64Tests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ABSMaskedDouble64VectorTests(IntFunction fa, + static void ABSMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4900,19 +5099,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double64VectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleVector64Tests::ABS); } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SQRTDouble64VectorTests(IntFunction fa) { + static void SQRTDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4923,11 +5122,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::SQRT); + assertArraysEquals(r, a, DoubleVector64Tests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sqrtDouble64VectorTests(IntFunction fa) { + static void sqrtDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4938,11 +5137,11 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::sqrt); + assertArraysEquals(r, a, DoubleVector64Tests::sqrt); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void SQRTMaskedDouble64VectorTests(IntFunction fa, + static void SQRTMaskedDoubleVector64Tests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4956,7 +5155,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Double64VectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleVector64Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4964,7 +5163,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4977,7 +5176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::band); + assertArraysEquals(r, a, b, DoubleVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4985,7 +5184,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4998,7 +5197,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::bor); + assertArraysEquals(r, a, b, DoubleVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -5006,7 +5205,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5019,7 +5218,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::bxor); + assertArraysEquals(r, a, b, DoubleVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5027,7 +5226,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5040,7 +5239,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::bandNot); + assertArraysEquals(r, a, b, DoubleVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5048,7 +5247,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5061,7 +5260,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Double64VectorTests::beq); + assertArraysEquals(r, a, b, DoubleVector64Tests::beq); } static boolean unot(boolean a) { @@ -5069,7 +5268,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotDouble64VectorTests(IntFunction fa) { + static void masknotDoubleVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5080,7 +5279,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::unot); + assertArraysEquals(r, a, DoubleVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5097,7 +5296,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongDouble64VectorTests(IntFunction fa) { + static void maskFromToLongDoubleVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5111,7 +5310,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltDoubleVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5121,13 +5320,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqDoubleVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5137,13 +5336,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubletoIntUnaryOpProvider") - static void toIntArrayDouble64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayDoubleVector64TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5154,7 +5353,7 @@ relativeError)); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void toLongArrayDouble64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayDoubleVector64TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5166,7 +5365,7 @@ relativeError)); @Test(dataProvider = "doubleUnaryOpProvider") - static void toStringDouble64VectorTestsSmokeTest(IntFunction fa) { + static void toStringDoubleVector64TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5179,7 +5378,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void hashCodeDouble64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeDoubleVector64TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5196,7 +5395,7 @@ relativeError)); static long ADDReduceLong(double[] a, int idx) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5205,14 +5404,14 @@ relativeError)); static long ADDReduceAllLong(double[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((double)res, (double)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceLongDouble64VectorTests(IntFunction fa) { + static void ADDReduceLongDoubleVector64Tests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5223,19 +5422,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Double64VectorTests::ADDReduceLong, Double64VectorTests::ADDReduceAllLong); + DoubleVector64Tests::ADDReduceLong, DoubleVector64Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5244,14 +5444,14 @@ relativeError)); static long ADDReduceAllLongMasked(double[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((double)res, (double)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceLongDouble64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongDoubleVector64TestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5264,16 +5464,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Double64VectorTests::ADDReduceLongMasked, Double64VectorTests::ADDReduceAllLongMasked); + DoubleVector64Tests::ADDReduceLongMasked, DoubleVector64Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void BroadcastLongDouble64VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongDoubleVector64TestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -5284,7 +5484,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendDoubleVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5298,12 +5498,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Double64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVector64Tests::blend); } @Test(dataProvider = "doubleUnaryOpSelectFromProvider") - static void SelectFromDouble64VectorTests(IntFunction fa, + static void SelectFromDoubleVector64Tests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); double[] order = fs.apply(a.length, SPECIES.length()); @@ -5319,7 +5519,7 @@ relativeError)); } @Test(dataProvider = "doubleSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorDouble64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorDoubleVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] idx = fc.apply(SPECIES.length()); @@ -5337,7 +5537,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") - static void SelectFromDouble64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromDoubleVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -5356,7 +5556,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousDouble64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousDoubleVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5372,7 +5572,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringDouble64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringDoubleVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5386,7 +5586,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsDouble64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsDoubleVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5400,7 +5600,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsDouble64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsDoubleVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5416,7 +5616,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeDouble64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeDoubleVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5438,7 +5638,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountDouble64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountDoubleVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5449,7 +5649,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, DoubleVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5463,7 +5663,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueDouble64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueDoubleVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5474,7 +5674,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5488,7 +5688,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueDouble64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueDoubleVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5499,11 +5699,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Double64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, DoubleVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressDouble64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressDoubleVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5531,7 +5731,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeDouble64VectorTestsSmokeTest(int offset) { + static void indexInRangeDoubleVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5545,7 +5745,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongDouble64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongDoubleVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5572,14 +5772,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundDouble64VectorTestsSmokeTest(int length) { + static void loopBoundDoubleVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongDouble64VectorTestsSmokeTest(int _length) { + static void loopBoundLongDoubleVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5587,21 +5787,21 @@ relativeError)); } @Test - static void ElementSizeDouble64VectorTestsSmokeTest() { + static void ElementSizeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Double.SIZE); } @Test - static void VectorShapeDouble64VectorTestsSmokeTest() { + static void VectorShapeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesDouble64VectorTestsSmokeTest() { + static void ShapeWithLanesDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(double.class); @@ -5609,32 +5809,32 @@ relativeError)); } @Test - static void ElementTypeDouble64VectorTestsSmokeTest() { + static void ElementTypeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementType() == double.class); } @Test - static void SpeciesElementSizeDouble64VectorTestsSmokeTest() { + static void SpeciesElementSizeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementSize() == Double.SIZE); } @Test - static void VectorTypeDouble64VectorTestsSmokeTest() { + static void VectorTypeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesDouble64VectorTestsSmokeTest() { + static void WithLanesDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(double.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeDouble64VectorTestsSmokeTest() { + static void WithShapeDoubleVector64TestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5642,7 +5842,7 @@ relativeError)); } @Test - static void MaskAllTrueDouble64VectorTestsSmokeTest() { + static void MaskAllTrueDoubleVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/DoubleVectorMaxLoadStoreTests.java index 7d372239435..e52ce2aa0d4 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation DoubleMaxVectorLoadStoreTests + * -XX:-TieredCompilation DoubleVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class DoubleMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class DoubleVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java index 9130698d5e4..2684ae2d0c6 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class DoubleMaxVectorTests extends AbstractVectorTest { +public class DoubleVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = DoubleVector.SPECIES_MAX; @@ -1590,6 +1590,205 @@ relativeError)); return Double.compare(a, (double) 0) != 0 ? a : b; } + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1683,11 +1882,11 @@ relativeError)); } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1700,15 +1899,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::ADD); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::ADD); } static double add(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1719,11 +1918,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::add); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1739,11 +1938,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1757,15 +1956,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::add); } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void SUBDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1778,15 +1977,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::SUB); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::SUB); } static double sub(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1797,11 +1996,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::sub); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void SUBDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1817,11 +2016,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::SUB); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1835,15 +2034,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::sub); } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MULDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1856,15 +2055,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::MUL); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::MUL); } static double mul(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1875,11 +2074,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::mul); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void MULDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1895,11 +2094,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::MUL); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1913,15 +2112,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::mul); } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void DIVDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1934,15 +2133,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::DIV); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::DIV); } static double div(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -1953,11 +2152,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::div); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void DIVDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1973,11 +2172,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::DIV); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -1991,15 +2190,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::div); } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void FIRST_NONZERODoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZERODoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2012,11 +2211,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void FIRST_NONZERODoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZERODoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2032,11 +2231,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "doubleBinaryOpProvider") - static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2046,11 +2245,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::add); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2063,11 +2262,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVectorMaxTests::add); } @Test(dataProvider = "doubleBinaryOpProvider") - static void subDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2077,11 +2276,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::sub); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void subDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2094,11 +2293,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVectorMaxTests::sub); } @Test(dataProvider = "doubleBinaryOpProvider") - static void mulDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2108,11 +2307,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::mul); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2125,11 +2324,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVectorMaxTests::mul); } @Test(dataProvider = "doubleBinaryOpProvider") - static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2139,11 +2338,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::div); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2156,11 +2355,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, DoubleVectorMaxTests::div); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ADDDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDDoubleVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2170,11 +2369,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, DoubleMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, DoubleVectorMaxTests::ADD); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void ADDDoubleMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDDoubleVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -2187,13 +2386,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVectorMaxTests::ADD); } static DoubleVector bv_MIN = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MINDoubleMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINDoubleVectorMaxTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2204,13 +2403,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::MIN); + assertArraysEquals(r, a, (double)10, DoubleVectorMaxTests::MIN); } static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void minDoubleMaxVectorTestsWithMemOp(IntFunction fa) { + static void minDoubleVectorMaxTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2221,13 +2420,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::min); + assertArraysEquals(r, a, (double)10, DoubleVectorMaxTests::min); } static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINDoubleVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2240,13 +2439,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, DoubleMaxVectorTests::MIN); + assertArraysEquals(r, a, (double)10, mask, DoubleVectorMaxTests::MIN); } static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXDoubleMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXDoubleVectorMaxTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2257,13 +2456,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::MAX); + assertArraysEquals(r, a, (double)10, DoubleVectorMaxTests::MAX); } static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpProvider") - static void maxDoubleMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxDoubleVectorMaxTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2274,13 +2473,13 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::max); + assertArraysEquals(r, a, (double)10, DoubleVectorMaxTests::max); } static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXDoubleVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2293,15 +2492,15 @@ relativeError)); } } - assertArraysEquals(r, a, (double)10, mask, DoubleMaxVectorTests::MAX); + assertArraysEquals(r, a, (double)10, mask, DoubleVectorMaxTests::MAX); } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2314,15 +2513,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::MIN); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::MIN); } static double min(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2333,15 +2532,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::min); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::min); } static double MAX(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2354,15 +2553,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::MAX); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::MAX); } static double max(double a, double b) { - return (double)(Math.max(a, b)); + return (double)(scalar_max(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2373,11 +2572,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::max); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::max); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MINDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2387,11 +2586,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::MIN); } @Test(dataProvider = "doubleBinaryOpProvider") - static void minDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2401,11 +2600,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::min); } @Test(dataProvider = "doubleBinaryOpProvider") - static void MAXDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2415,11 +2614,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::MAX); } @Test(dataProvider = "doubleBinaryOpProvider") - static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2429,13 +2628,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, DoubleVectorMaxTests::max); } static double ADDReduce(double[] a, int idx) { double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2444,14 +2643,14 @@ relativeError)); static double ADDReduceAll(double[] a) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceDoubleMaxVectorTests(IntFunction fa) { + static void ADDReduceDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2462,12 +2661,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVectorMaxTests::ADDReduce, DoubleVectorMaxTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2475,20 +2674,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = ADD_IDENTITY; - assertEquals((double) (id + id), id, + assertEquals((double) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id + x), x); - assertEquals((double) (x + id), x); + assertEquals((double) (scalar_add(id, x)), x); + assertEquals((double) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id + x), x, + assertEquals((double) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x + id), x, + assertEquals((double) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2497,7 +2696,7 @@ relativeError)); double res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2506,14 +2705,14 @@ relativeError)); static double ADDReduceAllMasked(double[] a, boolean[] mask) { double res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2526,18 +2725,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + DoubleVectorMaxTests::ADDReduceMasked, DoubleVectorMaxTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static double MULReduce(double[] a, int idx) { double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2546,14 +2745,14 @@ relativeError)); static double MULReduceAll(double[] a) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MULReduceDoubleMaxVectorTests(IntFunction fa) { + static void MULReduceDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2564,12 +2763,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVectorMaxTests::MULReduce, DoubleVectorMaxTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2577,20 +2776,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MUL_IDENTITY; - assertEquals((double) (id * id), id, + assertEquals((double) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) (id * x), x); - assertEquals((double) (x * id), x); + assertEquals((double) (scalar_mul(id, x)), x); + assertEquals((double) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((double) (id * x), x, + assertEquals((double) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((double) (x * id), x, + assertEquals((double) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2599,7 +2798,7 @@ relativeError)); double res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2608,14 +2807,14 @@ relativeError)); static double MULReduceAllMasked(double[] a, boolean[] mask) { double res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MULReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2628,18 +2827,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + DoubleVectorMaxTests::MULReduceMasked, DoubleVectorMaxTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static double MINReduce(double[] a, int idx) { double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2648,14 +2847,14 @@ relativeError)); static double MINReduceAll(double[] a) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MINReduceDoubleMaxVectorTests(IntFunction fa) { + static void MINReduceDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2666,12 +2865,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - DoubleMaxVectorTests::MINReduce, DoubleMaxVectorTests::MINReduceAll); + DoubleVectorMaxTests::MINReduce, DoubleVectorMaxTests::MINReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2679,20 +2878,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MIN_IDENTITY; - assertEquals((double) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.min(id, x), x); - assertEquals((double) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2701,7 +2900,7 @@ relativeError)); double res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2710,14 +2909,14 @@ relativeError)); static double MINReduceAllMasked(double[] a, boolean[] mask) { double res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MINReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2730,18 +2929,18 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (double) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::MINReduceMasked, DoubleMaxVectorTests::MINReduceAllMasked); + DoubleVectorMaxTests::MINReduceMasked, DoubleVectorMaxTests::MINReduceAllMasked); } static double MAXReduce(double[] a, int idx) { double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2750,14 +2949,14 @@ relativeError)); static double MAXReduceAll(double[] a) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void MAXReduceDoubleMaxVectorTests(IntFunction fa) { + static void MAXReduceDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2768,12 +2967,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - DoubleMaxVectorTests::MAXReduce, DoubleMaxVectorTests::MAXReduceAll); + DoubleVectorMaxTests::MAXReduce, DoubleVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2781,20 +2980,20 @@ relativeError)); double[] a = fa.apply(SPECIES.length()); double id = MAX_IDENTITY; - assertEquals((double) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); double x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((double) Math.max(id, x), x); - assertEquals((double) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((double) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((double) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2803,7 +3002,7 @@ relativeError)); double res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2812,14 +3011,14 @@ relativeError)); static double MAXReduceAllMasked(double[] a, boolean[] mask) { double res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2832,12 +3031,12 @@ relativeError)); DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); double v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (double) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::MAXReduceMasked, DoubleMaxVectorTests::MAXReduceAllMasked); + DoubleVectorMaxTests::MAXReduceMasked, DoubleVectorMaxTests::MAXReduceAllMasked); } static double FIRST_NONZEROReduce(double[] a, int idx) { @@ -2859,7 +3058,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); double ra = 0; @@ -2875,7 +3074,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - DoubleMaxVectorTests::FIRST_NONZEROReduce, DoubleMaxVectorTests::FIRST_NONZEROReduceAll); + DoubleVectorMaxTests::FIRST_NONZEROReduce, DoubleVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -2921,7 +3120,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2939,11 +3138,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::FIRST_NONZEROReduceMasked, DoubleMaxVectorTests::FIRST_NONZEROReduceAllMasked); + DoubleVectorMaxTests::FIRST_NONZEROReduceMasked, DoubleVectorMaxTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "doubleBinaryOpProvider") - static void withDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -2966,7 +3165,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_DEFAULTDoubleMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2983,7 +3182,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_DEFAULTMaskedDoubleMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3007,7 +3206,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NEGATIVEDoubleMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVEDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3024,7 +3223,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NEGATIVEMaskedDoubleMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3044,11 +3243,11 @@ relativeError)); } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_FINITEDoubleMaxVectorTests(IntFunction fa) { + static void IS_FINITEDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3065,7 +3264,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_FINITEMaskedDoubleMaxVectorTests(IntFunction fa, + static void IS_FINITEMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3085,11 +3284,11 @@ relativeError)); } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_NANDoubleMaxVectorTests(IntFunction fa) { + static void IS_NANDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3106,7 +3305,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_NANMaskedDoubleMaxVectorTests(IntFunction fa, + static void IS_NANMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3126,11 +3325,11 @@ relativeError)); } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") - static void IS_INFINITEDoubleMaxVectorTests(IntFunction fa) { + static void IS_INFINITEDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3147,7 +3346,7 @@ relativeError)); } @Test(dataProvider = "doubleTestOpMaskProvider") - static void IS_INFINITEMaskedDoubleMaxVectorTests(IntFunction fa, + static void IS_INFINITEMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3167,7 +3366,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3186,7 +3385,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3205,7 +3404,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3228,7 +3427,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GTDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3247,7 +3446,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GTDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3270,7 +3469,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3289,7 +3488,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3308,7 +3507,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3331,7 +3530,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void NEDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NEDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3350,7 +3549,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void NEDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3373,7 +3572,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LEDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LEDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3392,7 +3591,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LEDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3415,7 +3614,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void GEDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GEDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3434,7 +3633,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void GEDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3457,7 +3656,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3467,13 +3666,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3487,13 +3686,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void LTDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTDoubleVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3503,13 +3702,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void LTDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTDoubleVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3523,13 +3722,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (double)((long)b[i])))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3539,13 +3738,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3559,13 +3758,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void EQDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQDoubleVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3575,13 +3774,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @Test(dataProvider = "doubleCompareOpMaskProvider") - static void EQDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQDoubleVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3595,7 +3794,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (double)((long)b[i])))); } } } @@ -3605,7 +3804,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDoubleMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendDoubleVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3621,11 +3820,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, DoubleVectorMaxTests::blend); } @Test(dataProvider = "doubleUnaryOpShuffleProvider") - static void RearrangeDoubleMaxVectorTests(IntFunction fa, + static void RearrangeDoubleVectorMaxTests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3642,7 +3841,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider") - static void RearrangeDoubleMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeDoubleVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -3660,7 +3859,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void compressDoubleMaxVectorTests(IntFunction fa, + static void compressDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3678,7 +3877,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void expandDoubleMaxVectorTests(IntFunction fa, + static void expandDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3696,7 +3895,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void getDoubleMaxVectorTests(IntFunction fa) { + static void getDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -3852,7 +4051,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void BroadcastDoubleMaxVectorTests(IntFunction fa) { + static void BroadcastDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3866,7 +4065,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ZeroDoubleMaxVectorTests(IntFunction fa) { + static void ZeroDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3891,7 +4090,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sliceUnaryDoubleMaxVectorTests(IntFunction fa) { + static void sliceUnaryDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3902,7 +4101,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, DoubleMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, DoubleVectorMaxTests::sliceUnary); } static double[] sliceBinary(double[] a, double[] b, int origin, int idx) { @@ -3919,7 +4118,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void sliceBinaryDoubleMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryDoubleVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -3932,7 +4131,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, DoubleMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, DoubleVectorMaxTests::sliceBinary); } static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) { @@ -3949,7 +4148,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void sliceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -3966,7 +4165,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, DoubleMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, DoubleVectorMaxTests::slice); } static double[] unsliceUnary(double[] a, int origin, int idx) { @@ -3983,7 +4182,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void unsliceUnaryDoubleMaxVectorTests(IntFunction fa) { + static void unsliceUnaryDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3994,7 +4193,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, DoubleMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, DoubleVectorMaxTests::unsliceUnary); } static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) { @@ -4020,7 +4219,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void unsliceBinaryDoubleMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryDoubleVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -4034,7 +4233,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, DoubleMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, DoubleVectorMaxTests::unsliceBinary); } static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) { @@ -4074,7 +4273,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void unsliceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4091,19 +4290,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, DoubleMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, DoubleVectorMaxTests::unslice); } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINDoubleMaxVectorTests(IntFunction fa) { + static void SINDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4114,19 +4313,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::SIN, DoubleVectorMaxTests::strictSIN); } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPDoubleMaxVectorTests(IntFunction fa) { + static void EXPDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4137,19 +4336,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::EXP, DoubleVectorMaxTests::strictEXP); } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG1PDoubleMaxVectorTests(IntFunction fa) { + static void LOG1PDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4160,19 +4359,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::LOG1P, DoubleVectorMaxTests::strictLOG1P); } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOGDoubleMaxVectorTests(IntFunction fa) { + static void LOGDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4183,19 +4382,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::LOG, DoubleVectorMaxTests::strictLOG); } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void LOG10DoubleMaxVectorTests(IntFunction fa) { + static void LOG10DoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4206,19 +4405,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::LOG10, DoubleVectorMaxTests::strictLOG10); } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void EXPM1DoubleMaxVectorTests(IntFunction fa) { + static void EXPM1DoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4229,19 +4428,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::EXPM1, DoubleVectorMaxTests::strictEXPM1); } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSDoubleMaxVectorTests(IntFunction fa) { + static void COSDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4252,19 +4451,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::COS, DoubleVectorMaxTests::strictCOS); } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANDoubleMaxVectorTests(IntFunction fa) { + static void TANDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4275,19 +4474,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::TAN, DoubleVectorMaxTests::strictTAN); } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SINHDoubleMaxVectorTests(IntFunction fa) { + static void SINHDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4298,19 +4497,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::SINH, DoubleVectorMaxTests::strictSINH); } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void COSHDoubleMaxVectorTests(IntFunction fa) { + static void COSHDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4321,19 +4520,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::COSH, DoubleVectorMaxTests::strictCOSH); } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void TANHDoubleMaxVectorTests(IntFunction fa) { + static void TANHDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4344,19 +4543,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::TANH, DoubleVectorMaxTests::strictTANH); } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ASINDoubleMaxVectorTests(IntFunction fa) { + static void ASINDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4367,19 +4566,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::ASIN, DoubleVectorMaxTests::strictASIN); } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ACOSDoubleMaxVectorTests(IntFunction fa) { + static void ACOSDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4390,19 +4589,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::ACOS, DoubleVectorMaxTests::strictACOS); } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ATANDoubleMaxVectorTests(IntFunction fa) { + static void ATANDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4413,19 +4612,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::ATAN, DoubleVectorMaxTests::strictATAN); } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void CBRTDoubleMaxVectorTests(IntFunction fa) { + static void CBRTDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4436,19 +4635,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, DoubleVectorMaxTests::CBRT, DoubleVectorMaxTests::strictCBRT); } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void HYPOTDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4461,20 +4660,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::HYPOT, DoubleMaxVectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::HYPOT, DoubleVectorMaxTests::strictHYPOT); } static double POW(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictPOW(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void POWDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4487,20 +4686,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::POW, DoubleVectorMaxTests::strictPOW); } static double pow(double a, double b) { - return (double)(Math.pow((double)a, (double)b)); + return (double)(scalar_pow(a, b)); } static double strictpow(double a, double b) { - return (double)(StrictMath.pow((double)a, (double)b)); + return (double)(strict_scalar_pow(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void powDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4513,20 +4712,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::pow, DoubleVectorMaxTests::strictpow); } static double ATAN2(double a, double b) { - return (double)(Math.atan2((double)a, (double)b)); + return (double)(scalar_atan2(a, b)); } static double strictATAN2(double a, double b) { - return (double)(StrictMath.atan2((double)a, (double)b)); + return (double)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") - static void ATAN2DoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2DoubleVectorMaxTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4539,12 +4738,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::ATAN2, DoubleMaxVectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::ATAN2, DoubleVectorMaxTests::strictATAN2); } @Test(dataProvider = "doubleBinaryOpProvider") - static void POWDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4554,12 +4753,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::POW, DoubleVectorMaxTests::strictPOW); } @Test(dataProvider = "doubleBinaryOpProvider") - static void powDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4569,20 +4768,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleVectorMaxTests::pow, DoubleVectorMaxTests::strictpow); } static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADoubleMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4604,11 +4803,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDoubleMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4628,11 +4827,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma); + assertArraysEquals(r, a, b, c, DoubleVectorMaxTests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMADoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4657,11 +4856,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4672,11 +4871,11 @@ relativeError)); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADoubleMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); @@ -4687,11 +4886,11 @@ relativeError)); DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4706,11 +4905,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADoubleMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -4725,11 +4924,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void FMADoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMADoubleVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("FMA") { case "fma": case "lanewise_FMA": @@ -4747,11 +4946,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVectorMaxTests::FMA); } @Test(dataProvider = "doubleTernaryOpProvider") - static void fmaDoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaDoubleVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int count = INVOC_COUNT; switch ("fma") { case "fma": case "lanewise_FMA": @@ -4769,11 +4968,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleVectorMaxTests::fma); } @Test(dataProvider = "doubleTernaryOpMaskProvider") - static void FMADoubleMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMADoubleVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int count = INVOC_COUNT; switch ("FMA") { @@ -4794,19 +4993,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleVectorMaxTests::FMA); } static double NEG(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } static double neg(double a) { - return (double)(-((double)a)); + return (double)(scalar_neg((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void NEGDoubleMaxVectorTests(IntFunction fa) { + static void NEGDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4817,11 +5016,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::NEG); + assertArraysEquals(r, a, DoubleVectorMaxTests::NEG); } @Test(dataProvider = "doubleUnaryOpProvider") - static void negDoubleMaxVectorTests(IntFunction fa) { + static void negDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4832,11 +5031,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::neg); + assertArraysEquals(r, a, DoubleVectorMaxTests::neg); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void NEGMaskedDoubleMaxVectorTests(IntFunction fa, + static void NEGMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4850,19 +5049,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, DoubleMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, DoubleVectorMaxTests::NEG); } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void ABSDoubleMaxVectorTests(IntFunction fa) { + static void ABSDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4873,11 +5072,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::ABS); + assertArraysEquals(r, a, DoubleVectorMaxTests::ABS); } @Test(dataProvider = "doubleUnaryOpProvider") - static void absDoubleMaxVectorTests(IntFunction fa) { + static void absDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4888,11 +5087,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::abs); + assertArraysEquals(r, a, DoubleVectorMaxTests::abs); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ABSMaskedDoubleMaxVectorTests(IntFunction fa, + static void ABSMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4906,19 +5105,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, DoubleMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, DoubleVectorMaxTests::ABS); } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void SQRTDoubleMaxVectorTests(IntFunction fa) { + static void SQRTDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4929,11 +5128,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::SQRT); + assertArraysEquals(r, a, DoubleVectorMaxTests::SQRT); } @Test(dataProvider = "doubleUnaryOpProvider") - static void sqrtDoubleMaxVectorTests(IntFunction fa) { + static void sqrtDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4944,11 +5143,11 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::sqrt); + assertArraysEquals(r, a, DoubleVectorMaxTests::sqrt); } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void SQRTMaskedDoubleMaxVectorTests(IntFunction fa, + static void SQRTMaskedDoubleVectorMaxTests(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); @@ -4962,7 +5161,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT); + assertArraysEquals(r, a, mask, DoubleVectorMaxTests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4970,7 +5169,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4983,7 +5182,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::band); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -4991,7 +5190,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5004,7 +5203,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::bor); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -5012,7 +5211,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5025,7 +5224,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::bxor); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5033,7 +5232,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5046,7 +5245,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5054,7 +5253,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5067,7 +5266,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, DoubleMaxVectorTests::beq); + assertArraysEquals(r, a, b, DoubleVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -5075,7 +5274,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotDoubleMaxVectorTests(IntFunction fa) { + static void masknotDoubleVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5086,7 +5285,7 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::unot); + assertArraysEquals(r, a, DoubleVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5103,7 +5302,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongDoubleMaxVectorTests(IntFunction fa) { + static void maskFromToLongDoubleVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5117,7 +5316,7 @@ relativeError)); } @Test(dataProvider = "doubleCompareOpProvider") - static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltDoubleVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5127,13 +5326,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "doubleCompareOpProvider") - static void eqDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqDoubleVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5143,13 +5342,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "doubletoIntUnaryOpProvider") - static void toIntArrayDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayDoubleVectorMaxTestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5160,7 +5359,7 @@ relativeError)); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void toLongArrayDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayDoubleVectorMaxTestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5172,7 +5371,7 @@ relativeError)); @Test(dataProvider = "doubleUnaryOpProvider") - static void toStringDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringDoubleVectorMaxTestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5185,7 +5384,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpProvider") - static void hashCodeDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeDoubleVectorMaxTestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5202,7 +5401,7 @@ relativeError)); static long ADDReduceLong(double[] a, int idx) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5211,14 +5410,14 @@ relativeError)); static long ADDReduceAllLong(double[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((double)res, (double)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "doubleUnaryOpProvider") - static void ADDReduceLongDoubleMaxVectorTests(IntFunction fa) { + static void ADDReduceLongDoubleVectorMaxTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5229,19 +5428,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEquals(r, ra, a, - DoubleMaxVectorTests::ADDReduceLong, DoubleMaxVectorTests::ADDReduceAllLong); + DoubleVectorMaxTests::ADDReduceLong, DoubleVectorMaxTests::ADDReduceAllLong); } static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5250,14 +5450,14 @@ relativeError)); static long ADDReduceAllLongMasked(double[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((double)res, (double)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "doubleUnaryOpMaskProvider") - static void ADDReduceLongDoubleMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongDoubleVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5270,16 +5470,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((double)ra, (double)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - DoubleMaxVectorTests::ADDReduceLongMasked, DoubleMaxVectorTests::ADDReduceAllLongMasked); + DoubleVectorMaxTests::ADDReduceLongMasked, DoubleVectorMaxTests::ADDReduceAllLongMasked); } @Test(dataProvider = "doubletoLongUnaryOpProvider") - static void BroadcastLongDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongDoubleVectorMaxTestsSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = new double[a.length]; @@ -5290,7 +5490,7 @@ relativeError)); } @Test(dataProvider = "doubleBinaryOpMaskProvider") - static void blendDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendDoubleVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); @@ -5304,12 +5504,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, DoubleMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, DoubleVectorMaxTests::blend); } @Test(dataProvider = "doubleUnaryOpSelectFromProvider") - static void SelectFromDoubleMaxVectorTests(IntFunction fa, + static void SelectFromDoubleVectorMaxTests(IntFunction fa, BiFunction fs) { double[] a = fa.apply(SPECIES.length()); double[] order = fs.apply(a.length, SPECIES.length()); @@ -5325,7 +5525,7 @@ relativeError)); } @Test(dataProvider = "doubleSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorDoubleMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorDoubleVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] idx = fc.apply(SPECIES.length()); @@ -5343,7 +5543,7 @@ relativeError)); } @Test(dataProvider = "doubleUnaryOpSelectFromMaskProvider") - static void SelectFromDoubleMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromDoubleVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -5362,7 +5562,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousDoubleMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousDoubleVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5378,7 +5578,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringDoubleMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringDoubleVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5392,7 +5592,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsDoubleMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsDoubleVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5406,7 +5606,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsDoubleVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5422,7 +5622,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeDoubleVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5444,7 +5644,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountDoubleVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5455,7 +5655,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, DoubleVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5469,7 +5669,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueDoubleVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5480,7 +5680,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, DoubleVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5494,7 +5694,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueDoubleVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5505,11 +5705,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, DoubleVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressDoubleMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressDoubleVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5537,7 +5737,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeDoubleMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeDoubleVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5551,7 +5751,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongDoubleMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongDoubleVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5578,14 +5778,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundDoubleMaxVectorTestsSmokeTest(int length) { + static void loopBoundDoubleVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongDoubleMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongDoubleVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5593,21 +5793,21 @@ relativeError)); } @Test - static void ElementSizeDoubleMaxVectorTestsSmokeTest() { + static void ElementSizeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Double.SIZE); } @Test - static void VectorShapeDoubleMaxVectorTestsSmokeTest() { + static void VectorShapeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesDoubleMaxVectorTestsSmokeTest() { + static void ShapeWithLanesDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(double.class); @@ -5615,32 +5815,32 @@ relativeError)); } @Test - static void ElementTypeDoubleMaxVectorTestsSmokeTest() { + static void ElementTypeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementType() == double.class); } @Test - static void SpeciesElementSizeDoubleMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().elementSize() == Double.SIZE); } @Test - static void VectorTypeDoubleMaxVectorTestsSmokeTest() { + static void VectorTypeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesDoubleMaxVectorTestsSmokeTest() { + static void WithLanesDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(double.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeDoubleMaxVectorTestsSmokeTest() { + static void WithShapeDoubleVectorMaxTestsSmokeTest() { DoubleVector av = DoubleVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5648,7 +5848,7 @@ relativeError)); } @Test - static void MaskAllTrueDoubleMaxVectorTestsSmokeTest() { + static void MaskAllTrueDoubleVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/FloatVector128LoadStoreTests.java index 33a02167a90..5ef419f940d 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Float128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation FloatVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Float128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class FloatVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/FloatVector128Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Float128VectorTests.java rename to test/jdk/jdk/incubator/vector/FloatVector128Tests.java index 71ca2b3b701..151ea17a886 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Float128VectorTests extends AbstractVectorTest { +public class FloatVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_128; @@ -1601,6 +1601,205 @@ relativeError)); return Float.compare(a, (float) 0) != 0 ? a : b; } + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1694,11 +1893,11 @@ relativeError)); } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1711,15 +1910,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::ADD); + assertArraysEquals(r, a, b, FloatVector128Tests::ADD); } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void addFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1730,11 +1929,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::add); + assertArraysEquals(r, a, b, FloatVector128Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1750,11 +1949,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1768,15 +1967,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float128VectorTests::add); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::add); } static float SUB(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void SUBFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1789,15 +1988,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::SUB); + assertArraysEquals(r, a, b, FloatVector128Tests::SUB); } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void subFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1808,11 +2007,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::sub); + assertArraysEquals(r, a, b, FloatVector128Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void SUBFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1828,11 +2027,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::SUB); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1846,15 +2045,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float128VectorTests::sub); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::sub); } static float MUL(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MULFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void MULFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1867,15 +2066,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::MUL); + assertArraysEquals(r, a, b, FloatVector128Tests::MUL); } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void mulFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1886,11 +2085,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::mul); + assertArraysEquals(r, a, b, FloatVector128Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void MULFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1906,11 +2105,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::MUL); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1924,15 +2123,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float128VectorTests::mul); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::mul); } static float DIV(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void DIVFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1945,15 +2144,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::DIV); + assertArraysEquals(r, a, b, FloatVector128Tests::DIV); } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void divFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1964,11 +2163,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::div); + assertArraysEquals(r, a, b, FloatVector128Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void DIVFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1984,11 +2183,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::DIV); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2002,15 +2201,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float128VectorTests::div); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::div); } static float FIRST_NONZERO(float a, float b) { - return (float)(Double.doubleToLongBits(a)!=0?a:b); + return (float)(firstNonZero(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void FIRST_NONZEROFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2023,11 +2222,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void FIRST_NONZEROFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2043,11 +2242,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2074,11 +2273,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector128Tests::add); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2105,11 +2304,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector128Tests::sub); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2136,11 +2335,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector128Tests::mul); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2167,11 +2366,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector128Tests::div); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDFloatVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2380,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Float128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatVector128Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDFloatVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Float128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector128Tests::ADD); } static FloatVector bv_MIN = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MINFloat128VectorTestsWithMemOp(IntFunction fa) { + static void MINFloatVector128TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float128VectorTests::MIN); + assertArraysEquals(r, a, (float)10, FloatVector128Tests::MIN); } static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void minFloat128VectorTestsWithMemOp(IntFunction fa) { + static void minFloatVector128TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2232,13 +2431,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float128VectorTests::min); + assertArraysEquals(r, a, (float)10, FloatVector128Tests::min); } static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINFloatVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float128VectorTests::MIN); + assertArraysEquals(r, a, (float)10, mask, FloatVector128Tests::MIN); } static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MAXFloat128VectorTestsWithMemOp(IntFunction fa) { + static void MAXFloatVector128TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float128VectorTests::MAX); + assertArraysEquals(r, a, (float)10, FloatVector128Tests::MAX); } static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void maxFloat128VectorTestsWithMemOp(IntFunction fa) { + static void maxFloatVector128TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2285,13 +2484,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float128VectorTests::max); + assertArraysEquals(r, a, (float)10, FloatVector128Tests::max); } static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXFloatVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2304,15 +2503,15 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float128VectorTests::MAX); + assertArraysEquals(r, a, (float)10, mask, FloatVector128Tests::MAX); } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void MINFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2325,15 +2524,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::MIN); + assertArraysEquals(r, a, b, FloatVector128Tests::MIN); } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void minFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2344,15 +2543,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::min); + assertArraysEquals(r, a, b, FloatVector128Tests::min); } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2365,15 +2564,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::MAX); + assertArraysEquals(r, a, b, FloatVector128Tests::MAX); } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maxFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2583,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float128VectorTests::max); + assertArraysEquals(r, a, b, FloatVector128Tests::max); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2398,11 +2597,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2412,11 +2611,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::min); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2426,11 +2625,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2440,13 +2639,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatVector128Tests::max); } static float ADDReduce(float[] a, int idx) { float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2455,14 +2654,14 @@ relativeError)); static float ADDReduceAll(float[] a) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceFloat128VectorTests(IntFunction fa) { + static void ADDReduceFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2473,12 +2672,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float128VectorTests::ADDReduce, Float128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector128Tests::ADDReduce, FloatVector128Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2486,20 +2685,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = ADD_IDENTITY; - assertEquals((float) (id + id), id, + assertEquals((float) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id + x), x); - assertEquals((float) (x + id), x); + assertEquals((float) (scalar_add(id, x)), x); + assertEquals((float) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id + x), x, + assertEquals((float) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x + id), x, + assertEquals((float) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2508,7 +2707,7 @@ relativeError)); float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2517,14 +2716,14 @@ relativeError)); static float ADDReduceAllMasked(float[] a, boolean[] mask) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2537,18 +2736,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::ADDReduceMasked, Float128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector128Tests::ADDReduceMasked, FloatVector128Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static float MULReduce(float[] a, int idx) { float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2557,14 +2756,14 @@ relativeError)); static float MULReduceAll(float[] a) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MULReduceFloat128VectorTests(IntFunction fa) { + static void MULReduceFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2575,12 +2774,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float128VectorTests::MULReduce, Float128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector128Tests::MULReduce, FloatVector128Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2588,20 +2787,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MUL_IDENTITY; - assertEquals((float) (id * id), id, + assertEquals((float) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id * x), x); - assertEquals((float) (x * id), x); + assertEquals((float) (scalar_mul(id, x)), x); + assertEquals((float) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id * x), x, + assertEquals((float) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x * id), x, + assertEquals((float) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2610,7 +2809,7 @@ relativeError)); float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2619,14 +2818,14 @@ relativeError)); static float MULReduceAllMasked(float[] a, boolean[] mask) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MULReduceFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2639,18 +2838,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::MULReduceMasked, Float128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector128Tests::MULReduceMasked, FloatVector128Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static float MINReduce(float[] a, int idx) { float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2659,14 +2858,14 @@ relativeError)); static float MINReduceAll(float[] a) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MINReduceFloat128VectorTests(IntFunction fa) { + static void MINReduceFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2677,12 +2876,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float128VectorTests::MINReduce, Float128VectorTests::MINReduceAll); + FloatVector128Tests::MINReduce, FloatVector128Tests::MINReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2690,20 +2889,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MIN_IDENTITY; - assertEquals((float) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.min(id, x), x); - assertEquals((float) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2712,7 +2911,7 @@ relativeError)); float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2721,14 +2920,14 @@ relativeError)); static float MINReduceAllMasked(float[] a, boolean[] mask) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINReduceFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2741,18 +2940,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::MINReduceMasked, Float128VectorTests::MINReduceAllMasked); + FloatVector128Tests::MINReduceMasked, FloatVector128Tests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2761,14 +2960,14 @@ relativeError)); static float MAXReduceAll(float[] a) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MAXReduceFloat128VectorTests(IntFunction fa) { + static void MAXReduceFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2779,12 +2978,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float128VectorTests::MAXReduce, Float128VectorTests::MAXReduceAll); + FloatVector128Tests::MAXReduce, FloatVector128Tests::MAXReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2792,20 +2991,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MAX_IDENTITY; - assertEquals((float) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.max(id, x), x); - assertEquals((float) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2814,7 +3013,7 @@ relativeError)); float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2823,14 +3022,14 @@ relativeError)); static float MAXReduceAllMasked(float[] a, boolean[] mask) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXReduceFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2843,12 +3042,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::MAXReduceMasked, Float128VectorTests::MAXReduceAllMasked); + FloatVector128Tests::MAXReduceMasked, FloatVector128Tests::MAXReduceAllMasked); } static float FIRST_NONZEROReduce(float[] a, int idx) { @@ -2870,7 +3069,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void FIRST_NONZEROReduceFloat128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2886,7 +3085,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Float128VectorTests::FIRST_NONZEROReduce, Float128VectorTests::FIRST_NONZEROReduceAll); + FloatVector128Tests::FIRST_NONZEROReduce, FloatVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2932,7 +3131,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void FIRST_NONZEROReduceFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2950,11 +3149,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::FIRST_NONZEROReduceMasked, Float128VectorTests::FIRST_NONZEROReduceAllMasked); + FloatVector128Tests::FIRST_NONZEROReduceMasked, FloatVector128Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "floatBinaryOpProvider") - static void withFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void withFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_DEFAULTFloat128VectorTests(IntFunction fa) { + static void IS_DEFAULTFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2994,7 +3193,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_DEFAULTMaskedFloat128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NEGATIVEFloat128VectorTests(IntFunction fa) { + static void IS_NEGATIVEFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3035,7 +3234,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NEGATIVEMaskedFloat128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3055,11 +3254,11 @@ relativeError)); } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_FINITEFloat128VectorTests(IntFunction fa) { + static void IS_FINITEFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3076,7 +3275,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_FINITEMaskedFloat128VectorTests(IntFunction fa, + static void IS_FINITEMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3096,11 +3295,11 @@ relativeError)); } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NANFloat128VectorTests(IntFunction fa) { + static void IS_NANFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3117,7 +3316,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NANMaskedFloat128VectorTests(IntFunction fa, + static void IS_NANMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3137,11 +3336,11 @@ relativeError)); } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_INFINITEFloat128VectorTests(IntFunction fa) { + static void IS_INFINITEFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3158,7 +3357,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_INFINITEMaskedFloat128VectorTests(IntFunction fa, + static void IS_INFINITEMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3178,7 +3377,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void LTFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3197,7 +3396,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void ltFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3216,7 +3415,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3239,7 +3438,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GTFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void GTFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3258,7 +3457,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GTFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3281,7 +3480,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void EQFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3300,7 +3499,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void eqFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3319,7 +3518,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3342,7 +3541,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void NEFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void NEFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3361,7 +3560,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void NEFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3384,7 +3583,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LEFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void LEFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3403,7 +3602,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LEFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3426,7 +3625,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GEFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void GEFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3445,7 +3644,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GEFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3468,7 +3667,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3478,13 +3677,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3498,13 +3697,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3514,13 +3713,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTFloatVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3534,13 +3733,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (float)((long)b[i])))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3550,13 +3749,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3570,13 +3769,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3586,13 +3785,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQFloatVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3606,7 +3805,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (float)((long)b[i])))); } } } @@ -3616,7 +3815,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat128VectorTests(IntFunction fa, IntFunction fb, + static void blendFloatVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3632,11 +3831,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float128VectorTests::blend); + assertArraysEquals(r, a, b, mask, FloatVector128Tests::blend); } @Test(dataProvider = "floatUnaryOpShuffleProvider") - static void RearrangeFloat128VectorTests(IntFunction fa, + static void RearrangeFloatVector128Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3653,7 +3852,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") - static void RearrangeFloat128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeFloatVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -3671,7 +3870,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void compressFloat128VectorTests(IntFunction fa, + static void compressFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3689,7 +3888,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void expandFloat128VectorTests(IntFunction fa, + static void expandFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3707,7 +3906,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void getFloat128VectorTests(IntFunction fa) { + static void getFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3863,7 +4062,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void BroadcastFloat128VectorTests(IntFunction fa) { + static void BroadcastFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3877,7 +4076,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ZeroFloat128VectorTests(IntFunction fa) { + static void ZeroFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3902,7 +4101,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void sliceUnaryFloat128VectorTests(IntFunction fa) { + static void sliceUnaryFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3913,7 +4112,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatVector128Tests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { @@ -3930,7 +4129,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void sliceBinaryFloat128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryFloatVector128TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3943,7 +4142,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Float128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatVector128Tests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { @@ -3960,7 +4159,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void sliceFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3977,7 +4176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Float128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatVector128Tests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { @@ -3994,7 +4193,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void unsliceUnaryFloat128VectorTests(IntFunction fa) { + static void unsliceUnaryFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -4005,7 +4204,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatVector128Tests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { @@ -4031,7 +4230,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void unsliceBinaryFloat128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryFloatVector128TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -4045,7 +4244,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Float128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatVector128Tests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { @@ -4085,7 +4284,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void unsliceFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4102,19 +4301,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Float128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatVector128Tests::unslice); } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINFloat128VectorTests(IntFunction fa) { + static void SINFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4125,19 +4324,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SIN, Float128VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::SIN, FloatVector128Tests::strictSIN); } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPFloat128VectorTests(IntFunction fa) { + static void EXPFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4148,19 +4347,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXP, Float128VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::EXP, FloatVector128Tests::strictEXP); } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG1PFloat128VectorTests(IntFunction fa) { + static void LOG1PFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4171,19 +4370,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG1P, Float128VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::LOG1P, FloatVector128Tests::strictLOG1P); } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOGFloat128VectorTests(IntFunction fa) { + static void LOGFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4194,19 +4393,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG, Float128VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::LOG, FloatVector128Tests::strictLOG); } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG10Float128VectorTests(IntFunction fa) { + static void LOG10FloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4217,19 +4416,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG10, Float128VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::LOG10, FloatVector128Tests::strictLOG10); } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPM1Float128VectorTests(IntFunction fa) { + static void EXPM1FloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4240,19 +4439,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXPM1, Float128VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::EXPM1, FloatVector128Tests::strictEXPM1); } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSFloat128VectorTests(IntFunction fa) { + static void COSFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4263,19 +4462,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COS, Float128VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::COS, FloatVector128Tests::strictCOS); } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANFloat128VectorTests(IntFunction fa) { + static void TANFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4286,19 +4485,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TAN, Float128VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::TAN, FloatVector128Tests::strictTAN); } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINHFloat128VectorTests(IntFunction fa) { + static void SINHFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4309,19 +4508,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SINH, Float128VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::SINH, FloatVector128Tests::strictSINH); } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSHFloat128VectorTests(IntFunction fa) { + static void COSHFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4332,19 +4531,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COSH, Float128VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::COSH, FloatVector128Tests::strictCOSH); } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANHFloat128VectorTests(IntFunction fa) { + static void TANHFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4355,19 +4554,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TANH, Float128VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::TANH, FloatVector128Tests::strictTANH); } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ASINFloat128VectorTests(IntFunction fa) { + static void ASINFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4378,19 +4577,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ASIN, Float128VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::ASIN, FloatVector128Tests::strictASIN); } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ACOSFloat128VectorTests(IntFunction fa) { + static void ACOSFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4401,19 +4600,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ACOS, Float128VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::ACOS, FloatVector128Tests::strictACOS); } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ATANFloat128VectorTests(IntFunction fa) { + static void ATANFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4424,19 +4623,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ATAN, Float128VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::ATAN, FloatVector128Tests::strictATAN); } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void CBRTFloat128VectorTests(IntFunction fa) { + static void CBRTFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4447,19 +4646,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::CBRT, Float128VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatVector128Tests::CBRT, FloatVector128Tests::strictCBRT); } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void HYPOTFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4472,20 +4671,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::HYPOT, Float128VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::HYPOT, FloatVector128Tests::strictHYPOT); } static float POW(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictPOW(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void POWFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4498,20 +4697,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::POW, FloatVector128Tests::strictPOW); } static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void powFloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4524,20 +4723,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::pow, FloatVector128Tests::strictpow); } static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ATAN2Float128VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2FloatVector128Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4550,12 +4749,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::ATAN2, Float128VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::ATAN2, FloatVector128Tests::strictATAN2); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4565,12 +4764,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::POW, FloatVector128Tests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4580,20 +4779,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector128Tests::pow, FloatVector128Tests::strictpow); } static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4608,11 +4807,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Float128VectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4625,11 +4824,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Float128VectorTests::fma); + assertArraysEquals(r, a, b, c, FloatVector128Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMAFloatVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4647,11 +4846,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4662,11 +4861,11 @@ relativeError)); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4677,11 +4876,11 @@ relativeError)); FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4696,11 +4895,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4715,11 +4914,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4730,11 +4929,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector128Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4745,11 +4944,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector128Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4763,19 +4962,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatVector128Tests::FMA); } static float NEG(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } static float neg(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void NEGFloat128VectorTests(IntFunction fa) { + static void NEGFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4786,11 +4985,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::NEG); + assertArraysEquals(r, a, FloatVector128Tests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") - static void negFloat128VectorTests(IntFunction fa) { + static void negFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4801,11 +5000,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::neg); + assertArraysEquals(r, a, FloatVector128Tests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void NEGMaskedFloat128VectorTests(IntFunction fa, + static void NEGMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4819,19 +5018,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float128VectorTests::NEG); + assertArraysEquals(r, a, mask, FloatVector128Tests::NEG); } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ABSFloat128VectorTests(IntFunction fa) { + static void ABSFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4842,11 +5041,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::ABS); + assertArraysEquals(r, a, FloatVector128Tests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") - static void absFloat128VectorTests(IntFunction fa) { + static void absFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4857,11 +5056,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::abs); + assertArraysEquals(r, a, FloatVector128Tests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ABSMaskedFloat128VectorTests(IntFunction fa, + static void ABSMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4875,19 +5074,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float128VectorTests::ABS); + assertArraysEquals(r, a, mask, FloatVector128Tests::ABS); } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SQRTFloat128VectorTests(IntFunction fa) { + static void SQRTFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4898,11 +5097,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::SQRT); + assertArraysEquals(r, a, FloatVector128Tests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") - static void sqrtFloat128VectorTests(IntFunction fa) { + static void sqrtFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4913,11 +5112,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::sqrt); + assertArraysEquals(r, a, FloatVector128Tests::sqrt); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void SQRTMaskedFloat128VectorTests(IntFunction fa, + static void SQRTMaskedFloatVector128Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4931,7 +5130,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float128VectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatVector128Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4939,7 +5138,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4952,7 +5151,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::band); + assertArraysEquals(r, a, b, FloatVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4960,7 +5159,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4973,7 +5172,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::bor); + assertArraysEquals(r, a, b, FloatVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -4981,7 +5180,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4994,7 +5193,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::bxor); + assertArraysEquals(r, a, b, FloatVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5002,7 +5201,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5015,7 +5214,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::bandNot); + assertArraysEquals(r, a, b, FloatVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5023,7 +5222,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5036,7 +5235,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float128VectorTests::beq); + assertArraysEquals(r, a, b, FloatVector128Tests::beq); } static boolean unot(boolean a) { @@ -5044,7 +5243,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotFloat128VectorTests(IntFunction fa) { + static void masknotFloatVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5055,7 +5254,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::unot); + assertArraysEquals(r, a, FloatVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5072,7 +5271,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongFloat128VectorTests(IntFunction fa) { + static void maskFromToLongFloatVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5086,7 +5285,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltFloatVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5096,13 +5295,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqFloatVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5112,13 +5311,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floattoIntUnaryOpProvider") - static void toIntArrayFloat128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5129,7 +5328,7 @@ relativeError)); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void toLongArrayFloat128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5140,7 +5339,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toDoubleArrayFloat128VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5151,7 +5350,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toStringFloat128VectorTestsSmokeTest(IntFunction fa) { + static void toStringFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5164,7 +5363,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void hashCodeFloat128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5181,7 +5380,7 @@ relativeError)); static long ADDReduceLong(float[] a, int idx) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5190,14 +5389,14 @@ relativeError)); static long ADDReduceAllLong(float[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((float)res, (float)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceLongFloat128VectorTests(IntFunction fa) { + static void ADDReduceLongFloatVector128Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5208,19 +5407,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Float128VectorTests::ADDReduceLong, Float128VectorTests::ADDReduceAllLong); + FloatVector128Tests::ADDReduceLong, FloatVector128Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5229,14 +5429,14 @@ relativeError)); static long ADDReduceAllLongMasked(float[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((float)res, (float)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceLongFloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongFloatVector128TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5249,16 +5449,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Float128VectorTests::ADDReduceLongMasked, Float128VectorTests::ADDReduceAllLongMasked); + FloatVector128Tests::ADDReduceLongMasked, FloatVector128Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void BroadcastLongFloat128VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongFloatVector128TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -5269,7 +5469,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendFloatVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5283,12 +5483,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Float128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector128Tests::blend); } @Test(dataProvider = "floatUnaryOpSelectFromProvider") - static void SelectFromFloat128VectorTests(IntFunction fa, + static void SelectFromFloatVector128Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); float[] order = fs.apply(a.length, SPECIES.length()); @@ -5304,7 +5504,7 @@ relativeError)); } @Test(dataProvider = "floatSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorFloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorFloatVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] idx = fc.apply(SPECIES.length()); @@ -5322,7 +5522,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") - static void SelectFromFloat128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromFloatVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -5341,7 +5541,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousFloat128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousFloatVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5357,7 +5557,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringFloat128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringFloatVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5371,7 +5571,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsFloat128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsFloatVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5385,7 +5585,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsFloat128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsFloatVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5401,7 +5601,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeFloat128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeFloatVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5423,7 +5623,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountFloat128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountFloatVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5434,7 +5634,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, FloatVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5448,7 +5648,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueFloat128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueFloatVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5459,7 +5659,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, FloatVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5473,7 +5673,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueFloat128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueFloatVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5484,11 +5684,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, FloatVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressFloat128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressFloatVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5516,7 +5716,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeFloat128VectorTestsSmokeTest(int offset) { + static void indexInRangeFloatVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5530,7 +5730,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongFloat128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongFloatVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5557,14 +5757,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundFloat128VectorTestsSmokeTest(int length) { + static void loopBoundFloatVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongFloat128VectorTestsSmokeTest(int _length) { + static void loopBoundLongFloatVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5572,21 +5772,21 @@ relativeError)); } @Test - static void ElementSizeFloat128VectorTestsSmokeTest() { + static void ElementSizeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Float.SIZE); } @Test - static void VectorShapeFloat128VectorTestsSmokeTest() { + static void VectorShapeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesFloat128VectorTestsSmokeTest() { + static void ShapeWithLanesFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(float.class); @@ -5594,32 +5794,32 @@ relativeError)); } @Test - static void ElementTypeFloat128VectorTestsSmokeTest() { + static void ElementTypeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementType() == float.class); } @Test - static void SpeciesElementSizeFloat128VectorTestsSmokeTest() { + static void SpeciesElementSizeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementSize() == Float.SIZE); } @Test - static void VectorTypeFloat128VectorTestsSmokeTest() { + static void VectorTypeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesFloat128VectorTestsSmokeTest() { + static void WithLanesFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(float.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeFloat128VectorTestsSmokeTest() { + static void WithShapeFloatVector128TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5627,7 +5827,7 @@ relativeError)); } @Test - static void MaskAllTrueFloat128VectorTestsSmokeTest() { + static void MaskAllTrueFloatVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/FloatVector256LoadStoreTests.java index 0c1d8e9d443..a889bb5e8c8 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Float256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation FloatVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Float256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class FloatVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/FloatVector256Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Float256VectorTests.java rename to test/jdk/jdk/incubator/vector/FloatVector256Tests.java index cc61a5cdc5d..5315b69a5b6 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Float256VectorTests extends AbstractVectorTest { +public class FloatVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_256; @@ -1601,6 +1601,205 @@ relativeError)); return Float.compare(a, (float) 0) != 0 ? a : b; } + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1694,11 +1893,11 @@ relativeError)); } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1711,15 +1910,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::ADD); + assertArraysEquals(r, a, b, FloatVector256Tests::ADD); } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void addFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1730,11 +1929,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::add); + assertArraysEquals(r, a, b, FloatVector256Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1750,11 +1949,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1768,15 +1967,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float256VectorTests::add); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::add); } static float SUB(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void SUBFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1789,15 +1988,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::SUB); + assertArraysEquals(r, a, b, FloatVector256Tests::SUB); } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void subFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1808,11 +2007,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::sub); + assertArraysEquals(r, a, b, FloatVector256Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void SUBFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1828,11 +2027,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::SUB); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1846,15 +2045,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float256VectorTests::sub); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::sub); } static float MUL(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MULFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void MULFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1867,15 +2066,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::MUL); + assertArraysEquals(r, a, b, FloatVector256Tests::MUL); } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void mulFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1886,11 +2085,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::mul); + assertArraysEquals(r, a, b, FloatVector256Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void MULFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1906,11 +2105,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::MUL); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1924,15 +2123,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float256VectorTests::mul); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::mul); } static float DIV(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void DIVFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1945,15 +2144,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::DIV); + assertArraysEquals(r, a, b, FloatVector256Tests::DIV); } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void divFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1964,11 +2163,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::div); + assertArraysEquals(r, a, b, FloatVector256Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void DIVFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1984,11 +2183,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::DIV); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2002,15 +2201,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float256VectorTests::div); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::div); } static float FIRST_NONZERO(float a, float b) { - return (float)(Double.doubleToLongBits(a)!=0?a:b); + return (float)(firstNonZero(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void FIRST_NONZEROFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2023,11 +2222,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void FIRST_NONZEROFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2043,11 +2242,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2074,11 +2273,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector256Tests::add); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2105,11 +2304,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector256Tests::sub); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2136,11 +2335,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector256Tests::mul); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2167,11 +2366,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector256Tests::div); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDFloatVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2380,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Float256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatVector256Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDFloatVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Float256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector256Tests::ADD); } static FloatVector bv_MIN = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MINFloat256VectorTestsWithMemOp(IntFunction fa) { + static void MINFloatVector256TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float256VectorTests::MIN); + assertArraysEquals(r, a, (float)10, FloatVector256Tests::MIN); } static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void minFloat256VectorTestsWithMemOp(IntFunction fa) { + static void minFloatVector256TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2232,13 +2431,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float256VectorTests::min); + assertArraysEquals(r, a, (float)10, FloatVector256Tests::min); } static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINFloatVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float256VectorTests::MIN); + assertArraysEquals(r, a, (float)10, mask, FloatVector256Tests::MIN); } static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MAXFloat256VectorTestsWithMemOp(IntFunction fa) { + static void MAXFloatVector256TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float256VectorTests::MAX); + assertArraysEquals(r, a, (float)10, FloatVector256Tests::MAX); } static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void maxFloat256VectorTestsWithMemOp(IntFunction fa) { + static void maxFloatVector256TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2285,13 +2484,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float256VectorTests::max); + assertArraysEquals(r, a, (float)10, FloatVector256Tests::max); } static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXFloatVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2304,15 +2503,15 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float256VectorTests::MAX); + assertArraysEquals(r, a, (float)10, mask, FloatVector256Tests::MAX); } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void MINFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2325,15 +2524,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::MIN); + assertArraysEquals(r, a, b, FloatVector256Tests::MIN); } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void minFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2344,15 +2543,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::min); + assertArraysEquals(r, a, b, FloatVector256Tests::min); } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2365,15 +2564,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::MAX); + assertArraysEquals(r, a, b, FloatVector256Tests::MAX); } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maxFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2583,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float256VectorTests::max); + assertArraysEquals(r, a, b, FloatVector256Tests::max); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2398,11 +2597,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2412,11 +2611,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::min); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2426,11 +2625,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2440,13 +2639,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatVector256Tests::max); } static float ADDReduce(float[] a, int idx) { float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2455,14 +2654,14 @@ relativeError)); static float ADDReduceAll(float[] a) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceFloat256VectorTests(IntFunction fa) { + static void ADDReduceFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2473,12 +2672,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float256VectorTests::ADDReduce, Float256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector256Tests::ADDReduce, FloatVector256Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2486,20 +2685,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = ADD_IDENTITY; - assertEquals((float) (id + id), id, + assertEquals((float) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id + x), x); - assertEquals((float) (x + id), x); + assertEquals((float) (scalar_add(id, x)), x); + assertEquals((float) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id + x), x, + assertEquals((float) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x + id), x, + assertEquals((float) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2508,7 +2707,7 @@ relativeError)); float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2517,14 +2716,14 @@ relativeError)); static float ADDReduceAllMasked(float[] a, boolean[] mask) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2537,18 +2736,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::ADDReduceMasked, Float256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector256Tests::ADDReduceMasked, FloatVector256Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static float MULReduce(float[] a, int idx) { float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2557,14 +2756,14 @@ relativeError)); static float MULReduceAll(float[] a) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MULReduceFloat256VectorTests(IntFunction fa) { + static void MULReduceFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2575,12 +2774,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float256VectorTests::MULReduce, Float256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector256Tests::MULReduce, FloatVector256Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2588,20 +2787,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MUL_IDENTITY; - assertEquals((float) (id * id), id, + assertEquals((float) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id * x), x); - assertEquals((float) (x * id), x); + assertEquals((float) (scalar_mul(id, x)), x); + assertEquals((float) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id * x), x, + assertEquals((float) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x * id), x, + assertEquals((float) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2610,7 +2809,7 @@ relativeError)); float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2619,14 +2818,14 @@ relativeError)); static float MULReduceAllMasked(float[] a, boolean[] mask) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MULReduceFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2639,18 +2838,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::MULReduceMasked, Float256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector256Tests::MULReduceMasked, FloatVector256Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static float MINReduce(float[] a, int idx) { float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2659,14 +2858,14 @@ relativeError)); static float MINReduceAll(float[] a) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MINReduceFloat256VectorTests(IntFunction fa) { + static void MINReduceFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2677,12 +2876,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float256VectorTests::MINReduce, Float256VectorTests::MINReduceAll); + FloatVector256Tests::MINReduce, FloatVector256Tests::MINReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2690,20 +2889,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MIN_IDENTITY; - assertEquals((float) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.min(id, x), x); - assertEquals((float) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2712,7 +2911,7 @@ relativeError)); float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2721,14 +2920,14 @@ relativeError)); static float MINReduceAllMasked(float[] a, boolean[] mask) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINReduceFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2741,18 +2940,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::MINReduceMasked, Float256VectorTests::MINReduceAllMasked); + FloatVector256Tests::MINReduceMasked, FloatVector256Tests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2761,14 +2960,14 @@ relativeError)); static float MAXReduceAll(float[] a) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MAXReduceFloat256VectorTests(IntFunction fa) { + static void MAXReduceFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2779,12 +2978,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float256VectorTests::MAXReduce, Float256VectorTests::MAXReduceAll); + FloatVector256Tests::MAXReduce, FloatVector256Tests::MAXReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2792,20 +2991,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MAX_IDENTITY; - assertEquals((float) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.max(id, x), x); - assertEquals((float) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2814,7 +3013,7 @@ relativeError)); float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2823,14 +3022,14 @@ relativeError)); static float MAXReduceAllMasked(float[] a, boolean[] mask) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXReduceFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2843,12 +3042,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::MAXReduceMasked, Float256VectorTests::MAXReduceAllMasked); + FloatVector256Tests::MAXReduceMasked, FloatVector256Tests::MAXReduceAllMasked); } static float FIRST_NONZEROReduce(float[] a, int idx) { @@ -2870,7 +3069,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void FIRST_NONZEROReduceFloat256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2886,7 +3085,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Float256VectorTests::FIRST_NONZEROReduce, Float256VectorTests::FIRST_NONZEROReduceAll); + FloatVector256Tests::FIRST_NONZEROReduce, FloatVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2932,7 +3131,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void FIRST_NONZEROReduceFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2950,11 +3149,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::FIRST_NONZEROReduceMasked, Float256VectorTests::FIRST_NONZEROReduceAllMasked); + FloatVector256Tests::FIRST_NONZEROReduceMasked, FloatVector256Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "floatBinaryOpProvider") - static void withFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void withFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_DEFAULTFloat256VectorTests(IntFunction fa) { + static void IS_DEFAULTFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2994,7 +3193,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_DEFAULTMaskedFloat256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NEGATIVEFloat256VectorTests(IntFunction fa) { + static void IS_NEGATIVEFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3035,7 +3234,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NEGATIVEMaskedFloat256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3055,11 +3254,11 @@ relativeError)); } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_FINITEFloat256VectorTests(IntFunction fa) { + static void IS_FINITEFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3076,7 +3275,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_FINITEMaskedFloat256VectorTests(IntFunction fa, + static void IS_FINITEMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3096,11 +3295,11 @@ relativeError)); } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NANFloat256VectorTests(IntFunction fa) { + static void IS_NANFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3117,7 +3316,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NANMaskedFloat256VectorTests(IntFunction fa, + static void IS_NANMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3137,11 +3336,11 @@ relativeError)); } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_INFINITEFloat256VectorTests(IntFunction fa) { + static void IS_INFINITEFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3158,7 +3357,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_INFINITEMaskedFloat256VectorTests(IntFunction fa, + static void IS_INFINITEMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3178,7 +3377,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void LTFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3197,7 +3396,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void ltFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3216,7 +3415,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3239,7 +3438,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GTFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void GTFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3258,7 +3457,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GTFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3281,7 +3480,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void EQFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3300,7 +3499,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void eqFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3319,7 +3518,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3342,7 +3541,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void NEFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void NEFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3361,7 +3560,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void NEFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3384,7 +3583,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LEFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void LEFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3403,7 +3602,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LEFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3426,7 +3625,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GEFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void GEFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3445,7 +3644,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GEFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3468,7 +3667,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3478,13 +3677,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3498,13 +3697,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3514,13 +3713,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTFloatVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3534,13 +3733,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (float)((long)b[i])))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3550,13 +3749,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3570,13 +3769,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3586,13 +3785,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQFloatVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3606,7 +3805,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (float)((long)b[i])))); } } } @@ -3616,7 +3815,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat256VectorTests(IntFunction fa, IntFunction fb, + static void blendFloatVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3632,11 +3831,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float256VectorTests::blend); + assertArraysEquals(r, a, b, mask, FloatVector256Tests::blend); } @Test(dataProvider = "floatUnaryOpShuffleProvider") - static void RearrangeFloat256VectorTests(IntFunction fa, + static void RearrangeFloatVector256Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3653,7 +3852,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") - static void RearrangeFloat256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeFloatVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -3671,7 +3870,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void compressFloat256VectorTests(IntFunction fa, + static void compressFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3689,7 +3888,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void expandFloat256VectorTests(IntFunction fa, + static void expandFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3707,7 +3906,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void getFloat256VectorTests(IntFunction fa) { + static void getFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3863,7 +4062,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void BroadcastFloat256VectorTests(IntFunction fa) { + static void BroadcastFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3877,7 +4076,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ZeroFloat256VectorTests(IntFunction fa) { + static void ZeroFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3902,7 +4101,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void sliceUnaryFloat256VectorTests(IntFunction fa) { + static void sliceUnaryFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3913,7 +4112,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatVector256Tests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { @@ -3930,7 +4129,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void sliceBinaryFloat256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryFloatVector256TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3943,7 +4142,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Float256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatVector256Tests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { @@ -3960,7 +4159,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void sliceFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3977,7 +4176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Float256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatVector256Tests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { @@ -3994,7 +4193,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void unsliceUnaryFloat256VectorTests(IntFunction fa) { + static void unsliceUnaryFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -4005,7 +4204,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatVector256Tests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { @@ -4031,7 +4230,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void unsliceBinaryFloat256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryFloatVector256TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -4045,7 +4244,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Float256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatVector256Tests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { @@ -4085,7 +4284,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void unsliceFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4102,19 +4301,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Float256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatVector256Tests::unslice); } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINFloat256VectorTests(IntFunction fa) { + static void SINFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4125,19 +4324,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::SIN, Float256VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::SIN, FloatVector256Tests::strictSIN); } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPFloat256VectorTests(IntFunction fa) { + static void EXPFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4148,19 +4347,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::EXP, Float256VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::EXP, FloatVector256Tests::strictEXP); } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG1PFloat256VectorTests(IntFunction fa) { + static void LOG1PFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4171,19 +4370,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG1P, Float256VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::LOG1P, FloatVector256Tests::strictLOG1P); } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOGFloat256VectorTests(IntFunction fa) { + static void LOGFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4194,19 +4393,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG, Float256VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::LOG, FloatVector256Tests::strictLOG); } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG10Float256VectorTests(IntFunction fa) { + static void LOG10FloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4217,19 +4416,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::LOG10, Float256VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::LOG10, FloatVector256Tests::strictLOG10); } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPM1Float256VectorTests(IntFunction fa) { + static void EXPM1FloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4240,19 +4439,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::EXPM1, Float256VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::EXPM1, FloatVector256Tests::strictEXPM1); } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSFloat256VectorTests(IntFunction fa) { + static void COSFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4263,19 +4462,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::COS, Float256VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::COS, FloatVector256Tests::strictCOS); } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANFloat256VectorTests(IntFunction fa) { + static void TANFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4286,19 +4485,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::TAN, Float256VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::TAN, FloatVector256Tests::strictTAN); } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINHFloat256VectorTests(IntFunction fa) { + static void SINHFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4309,19 +4508,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::SINH, Float256VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::SINH, FloatVector256Tests::strictSINH); } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSHFloat256VectorTests(IntFunction fa) { + static void COSHFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4332,19 +4531,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::COSH, Float256VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::COSH, FloatVector256Tests::strictCOSH); } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANHFloat256VectorTests(IntFunction fa) { + static void TANHFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4355,19 +4554,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::TANH, Float256VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::TANH, FloatVector256Tests::strictTANH); } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ASINFloat256VectorTests(IntFunction fa) { + static void ASINFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4378,19 +4577,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ASIN, Float256VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::ASIN, FloatVector256Tests::strictASIN); } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ACOSFloat256VectorTests(IntFunction fa) { + static void ACOSFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4401,19 +4600,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ACOS, Float256VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::ACOS, FloatVector256Tests::strictACOS); } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ATANFloat256VectorTests(IntFunction fa) { + static void ATANFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4424,19 +4623,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::ATAN, Float256VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::ATAN, FloatVector256Tests::strictATAN); } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void CBRTFloat256VectorTests(IntFunction fa) { + static void CBRTFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4447,19 +4646,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float256VectorTests::CBRT, Float256VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatVector256Tests::CBRT, FloatVector256Tests::strictCBRT); } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void HYPOTFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4472,20 +4671,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::HYPOT, Float256VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::HYPOT, FloatVector256Tests::strictHYPOT); } static float POW(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictPOW(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void POWFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4498,20 +4697,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::POW, Float256VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::POW, FloatVector256Tests::strictPOW); } static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void powFloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4524,20 +4723,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::pow, Float256VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::pow, FloatVector256Tests::strictpow); } static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ATAN2Float256VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2FloatVector256Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4550,12 +4749,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::ATAN2, Float256VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::ATAN2, FloatVector256Tests::strictATAN2); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4565,12 +4764,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::POW, Float256VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::POW, FloatVector256Tests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4580,20 +4779,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float256VectorTests::pow, Float256VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector256Tests::pow, FloatVector256Tests::strictpow); } static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4608,11 +4807,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Float256VectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4625,11 +4824,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Float256VectorTests::fma); + assertArraysEquals(r, a, b, c, FloatVector256Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMAFloatVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4647,11 +4846,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Float256VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4662,11 +4861,11 @@ relativeError)); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4677,11 +4876,11 @@ relativeError)); FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4696,11 +4895,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Float256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4715,11 +4914,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Float256VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4730,11 +4929,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float256VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector256Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4745,11 +4944,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float256VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector256Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4763,19 +4962,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float256VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatVector256Tests::FMA); } static float NEG(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } static float neg(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void NEGFloat256VectorTests(IntFunction fa) { + static void NEGFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4786,11 +4985,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::NEG); + assertArraysEquals(r, a, FloatVector256Tests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") - static void negFloat256VectorTests(IntFunction fa) { + static void negFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4801,11 +5000,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::neg); + assertArraysEquals(r, a, FloatVector256Tests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void NEGMaskedFloat256VectorTests(IntFunction fa, + static void NEGMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4819,19 +5018,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float256VectorTests::NEG); + assertArraysEquals(r, a, mask, FloatVector256Tests::NEG); } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ABSFloat256VectorTests(IntFunction fa) { + static void ABSFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4842,11 +5041,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::ABS); + assertArraysEquals(r, a, FloatVector256Tests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") - static void absFloat256VectorTests(IntFunction fa) { + static void absFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4857,11 +5056,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::abs); + assertArraysEquals(r, a, FloatVector256Tests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ABSMaskedFloat256VectorTests(IntFunction fa, + static void ABSMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4875,19 +5074,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float256VectorTests::ABS); + assertArraysEquals(r, a, mask, FloatVector256Tests::ABS); } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SQRTFloat256VectorTests(IntFunction fa) { + static void SQRTFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4898,11 +5097,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::SQRT); + assertArraysEquals(r, a, FloatVector256Tests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") - static void sqrtFloat256VectorTests(IntFunction fa) { + static void sqrtFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4913,11 +5112,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::sqrt); + assertArraysEquals(r, a, FloatVector256Tests::sqrt); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void SQRTMaskedFloat256VectorTests(IntFunction fa, + static void SQRTMaskedFloatVector256Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4931,7 +5130,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float256VectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatVector256Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4939,7 +5138,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4952,7 +5151,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::band); + assertArraysEquals(r, a, b, FloatVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4960,7 +5159,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4973,7 +5172,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::bor); + assertArraysEquals(r, a, b, FloatVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -4981,7 +5180,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4994,7 +5193,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::bxor); + assertArraysEquals(r, a, b, FloatVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5002,7 +5201,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5015,7 +5214,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::bandNot); + assertArraysEquals(r, a, b, FloatVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5023,7 +5222,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5036,7 +5235,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float256VectorTests::beq); + assertArraysEquals(r, a, b, FloatVector256Tests::beq); } static boolean unot(boolean a) { @@ -5044,7 +5243,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotFloat256VectorTests(IntFunction fa) { + static void masknotFloatVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5055,7 +5254,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::unot); + assertArraysEquals(r, a, FloatVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5072,7 +5271,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongFloat256VectorTests(IntFunction fa) { + static void maskFromToLongFloatVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5086,7 +5285,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltFloatVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5096,13 +5295,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqFloatVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5112,13 +5311,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floattoIntUnaryOpProvider") - static void toIntArrayFloat256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5129,7 +5328,7 @@ relativeError)); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void toLongArrayFloat256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5140,7 +5339,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toDoubleArrayFloat256VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5151,7 +5350,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toStringFloat256VectorTestsSmokeTest(IntFunction fa) { + static void toStringFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5164,7 +5363,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void hashCodeFloat256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5181,7 +5380,7 @@ relativeError)); static long ADDReduceLong(float[] a, int idx) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5190,14 +5389,14 @@ relativeError)); static long ADDReduceAllLong(float[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((float)res, (float)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceLongFloat256VectorTests(IntFunction fa) { + static void ADDReduceLongFloatVector256Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5208,19 +5407,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Float256VectorTests::ADDReduceLong, Float256VectorTests::ADDReduceAllLong); + FloatVector256Tests::ADDReduceLong, FloatVector256Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5229,14 +5429,14 @@ relativeError)); static long ADDReduceAllLongMasked(float[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((float)res, (float)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceLongFloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongFloatVector256TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5249,16 +5449,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Float256VectorTests::ADDReduceLongMasked, Float256VectorTests::ADDReduceAllLongMasked); + FloatVector256Tests::ADDReduceLongMasked, FloatVector256Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void BroadcastLongFloat256VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongFloatVector256TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -5269,7 +5469,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendFloatVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5283,12 +5483,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Float256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector256Tests::blend); } @Test(dataProvider = "floatUnaryOpSelectFromProvider") - static void SelectFromFloat256VectorTests(IntFunction fa, + static void SelectFromFloatVector256Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); float[] order = fs.apply(a.length, SPECIES.length()); @@ -5304,7 +5504,7 @@ relativeError)); } @Test(dataProvider = "floatSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorFloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorFloatVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] idx = fc.apply(SPECIES.length()); @@ -5322,7 +5522,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") - static void SelectFromFloat256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromFloatVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -5341,7 +5541,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousFloat256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousFloatVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5357,7 +5557,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringFloat256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringFloatVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5371,7 +5571,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsFloat256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsFloatVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5385,7 +5585,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsFloat256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsFloatVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5401,7 +5601,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeFloat256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeFloatVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5423,7 +5623,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountFloat256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountFloatVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5434,7 +5634,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, FloatVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5448,7 +5648,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueFloat256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueFloatVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5459,7 +5659,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, FloatVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5473,7 +5673,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueFloat256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueFloatVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5484,11 +5684,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, FloatVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressFloat256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressFloatVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5516,7 +5716,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeFloat256VectorTestsSmokeTest(int offset) { + static void indexInRangeFloatVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5530,7 +5730,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongFloat256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongFloatVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5557,14 +5757,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundFloat256VectorTestsSmokeTest(int length) { + static void loopBoundFloatVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongFloat256VectorTestsSmokeTest(int _length) { + static void loopBoundLongFloatVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5572,21 +5772,21 @@ relativeError)); } @Test - static void ElementSizeFloat256VectorTestsSmokeTest() { + static void ElementSizeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Float.SIZE); } @Test - static void VectorShapeFloat256VectorTestsSmokeTest() { + static void VectorShapeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesFloat256VectorTestsSmokeTest() { + static void ShapeWithLanesFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(float.class); @@ -5594,32 +5794,32 @@ relativeError)); } @Test - static void ElementTypeFloat256VectorTestsSmokeTest() { + static void ElementTypeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementType() == float.class); } @Test - static void SpeciesElementSizeFloat256VectorTestsSmokeTest() { + static void SpeciesElementSizeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementSize() == Float.SIZE); } @Test - static void VectorTypeFloat256VectorTestsSmokeTest() { + static void VectorTypeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesFloat256VectorTestsSmokeTest() { + static void WithLanesFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(float.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeFloat256VectorTestsSmokeTest() { + static void WithShapeFloatVector256TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5627,7 +5827,7 @@ relativeError)); } @Test - static void MaskAllTrueFloat256VectorTestsSmokeTest() { + static void MaskAllTrueFloatVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/FloatVector512LoadStoreTests.java index b3fe49e2121..3a33f0175b4 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Float512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation FloatVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Float512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class FloatVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/FloatVector512Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Float512VectorTests.java rename to test/jdk/jdk/incubator/vector/FloatVector512Tests.java index 830001ac268..6a958511439 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Float512VectorTests extends AbstractVectorTest { +public class FloatVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_512; @@ -1601,6 +1601,205 @@ relativeError)); return Float.compare(a, (float) 0) != 0 ? a : b; } + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1694,11 +1893,11 @@ relativeError)); } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1711,15 +1910,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::ADD); + assertArraysEquals(r, a, b, FloatVector512Tests::ADD); } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void addFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1730,11 +1929,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::add); + assertArraysEquals(r, a, b, FloatVector512Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1750,11 +1949,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1768,15 +1967,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float512VectorTests::add); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::add); } static float SUB(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void SUBFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1789,15 +1988,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::SUB); + assertArraysEquals(r, a, b, FloatVector512Tests::SUB); } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void subFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1808,11 +2007,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::sub); + assertArraysEquals(r, a, b, FloatVector512Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void SUBFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1828,11 +2027,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::SUB); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1846,15 +2045,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float512VectorTests::sub); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::sub); } static float MUL(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MULFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void MULFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1867,15 +2066,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::MUL); + assertArraysEquals(r, a, b, FloatVector512Tests::MUL); } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void mulFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1886,11 +2085,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::mul); + assertArraysEquals(r, a, b, FloatVector512Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void MULFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1906,11 +2105,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::MUL); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1924,15 +2123,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float512VectorTests::mul); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::mul); } static float DIV(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void DIVFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1945,15 +2144,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::DIV); + assertArraysEquals(r, a, b, FloatVector512Tests::DIV); } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void divFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1964,11 +2163,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::div); + assertArraysEquals(r, a, b, FloatVector512Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void DIVFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1984,11 +2183,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::DIV); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2002,15 +2201,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float512VectorTests::div); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::div); } static float FIRST_NONZERO(float a, float b) { - return (float)(Double.doubleToLongBits(a)!=0?a:b); + return (float)(firstNonZero(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void FIRST_NONZEROFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2023,11 +2222,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void FIRST_NONZEROFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2043,11 +2242,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2074,11 +2273,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector512Tests::add); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2105,11 +2304,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector512Tests::sub); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2136,11 +2335,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector512Tests::mul); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2167,11 +2366,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector512Tests::div); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDFloatVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2380,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Float512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatVector512Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDFloatVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Float512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector512Tests::ADD); } static FloatVector bv_MIN = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MINFloat512VectorTestsWithMemOp(IntFunction fa) { + static void MINFloatVector512TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float512VectorTests::MIN); + assertArraysEquals(r, a, (float)10, FloatVector512Tests::MIN); } static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void minFloat512VectorTestsWithMemOp(IntFunction fa) { + static void minFloatVector512TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2232,13 +2431,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float512VectorTests::min); + assertArraysEquals(r, a, (float)10, FloatVector512Tests::min); } static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINFloatVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float512VectorTests::MIN); + assertArraysEquals(r, a, (float)10, mask, FloatVector512Tests::MIN); } static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MAXFloat512VectorTestsWithMemOp(IntFunction fa) { + static void MAXFloatVector512TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float512VectorTests::MAX); + assertArraysEquals(r, a, (float)10, FloatVector512Tests::MAX); } static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void maxFloat512VectorTestsWithMemOp(IntFunction fa) { + static void maxFloatVector512TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2285,13 +2484,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float512VectorTests::max); + assertArraysEquals(r, a, (float)10, FloatVector512Tests::max); } static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXFloatVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2304,15 +2503,15 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float512VectorTests::MAX); + assertArraysEquals(r, a, (float)10, mask, FloatVector512Tests::MAX); } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void MINFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2325,15 +2524,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::MIN); + assertArraysEquals(r, a, b, FloatVector512Tests::MIN); } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void minFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2344,15 +2543,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::min); + assertArraysEquals(r, a, b, FloatVector512Tests::min); } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2365,15 +2564,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::MAX); + assertArraysEquals(r, a, b, FloatVector512Tests::MAX); } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maxFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2583,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float512VectorTests::max); + assertArraysEquals(r, a, b, FloatVector512Tests::max); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2398,11 +2597,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2412,11 +2611,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::min); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2426,11 +2625,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2440,13 +2639,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatVector512Tests::max); } static float ADDReduce(float[] a, int idx) { float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2455,14 +2654,14 @@ relativeError)); static float ADDReduceAll(float[] a) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceFloat512VectorTests(IntFunction fa) { + static void ADDReduceFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2473,12 +2672,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float512VectorTests::ADDReduce, Float512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector512Tests::ADDReduce, FloatVector512Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2486,20 +2685,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = ADD_IDENTITY; - assertEquals((float) (id + id), id, + assertEquals((float) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id + x), x); - assertEquals((float) (x + id), x); + assertEquals((float) (scalar_add(id, x)), x); + assertEquals((float) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id + x), x, + assertEquals((float) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x + id), x, + assertEquals((float) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2508,7 +2707,7 @@ relativeError)); float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2517,14 +2716,14 @@ relativeError)); static float ADDReduceAllMasked(float[] a, boolean[] mask) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2537,18 +2736,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::ADDReduceMasked, Float512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector512Tests::ADDReduceMasked, FloatVector512Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static float MULReduce(float[] a, int idx) { float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2557,14 +2756,14 @@ relativeError)); static float MULReduceAll(float[] a) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MULReduceFloat512VectorTests(IntFunction fa) { + static void MULReduceFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2575,12 +2774,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float512VectorTests::MULReduce, Float512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector512Tests::MULReduce, FloatVector512Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2588,20 +2787,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MUL_IDENTITY; - assertEquals((float) (id * id), id, + assertEquals((float) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id * x), x); - assertEquals((float) (x * id), x); + assertEquals((float) (scalar_mul(id, x)), x); + assertEquals((float) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id * x), x, + assertEquals((float) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x * id), x, + assertEquals((float) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2610,7 +2809,7 @@ relativeError)); float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2619,14 +2818,14 @@ relativeError)); static float MULReduceAllMasked(float[] a, boolean[] mask) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MULReduceFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2639,18 +2838,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::MULReduceMasked, Float512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector512Tests::MULReduceMasked, FloatVector512Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static float MINReduce(float[] a, int idx) { float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2659,14 +2858,14 @@ relativeError)); static float MINReduceAll(float[] a) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MINReduceFloat512VectorTests(IntFunction fa) { + static void MINReduceFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2677,12 +2876,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float512VectorTests::MINReduce, Float512VectorTests::MINReduceAll); + FloatVector512Tests::MINReduce, FloatVector512Tests::MINReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2690,20 +2889,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MIN_IDENTITY; - assertEquals((float) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.min(id, x), x); - assertEquals((float) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2712,7 +2911,7 @@ relativeError)); float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2721,14 +2920,14 @@ relativeError)); static float MINReduceAllMasked(float[] a, boolean[] mask) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINReduceFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2741,18 +2940,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::MINReduceMasked, Float512VectorTests::MINReduceAllMasked); + FloatVector512Tests::MINReduceMasked, FloatVector512Tests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2761,14 +2960,14 @@ relativeError)); static float MAXReduceAll(float[] a) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MAXReduceFloat512VectorTests(IntFunction fa) { + static void MAXReduceFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2779,12 +2978,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float512VectorTests::MAXReduce, Float512VectorTests::MAXReduceAll); + FloatVector512Tests::MAXReduce, FloatVector512Tests::MAXReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2792,20 +2991,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MAX_IDENTITY; - assertEquals((float) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.max(id, x), x); - assertEquals((float) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2814,7 +3013,7 @@ relativeError)); float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2823,14 +3022,14 @@ relativeError)); static float MAXReduceAllMasked(float[] a, boolean[] mask) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXReduceFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2843,12 +3042,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::MAXReduceMasked, Float512VectorTests::MAXReduceAllMasked); + FloatVector512Tests::MAXReduceMasked, FloatVector512Tests::MAXReduceAllMasked); } static float FIRST_NONZEROReduce(float[] a, int idx) { @@ -2870,7 +3069,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void FIRST_NONZEROReduceFloat512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2886,7 +3085,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Float512VectorTests::FIRST_NONZEROReduce, Float512VectorTests::FIRST_NONZEROReduceAll); + FloatVector512Tests::FIRST_NONZEROReduce, FloatVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2932,7 +3131,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void FIRST_NONZEROReduceFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2950,11 +3149,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::FIRST_NONZEROReduceMasked, Float512VectorTests::FIRST_NONZEROReduceAllMasked); + FloatVector512Tests::FIRST_NONZEROReduceMasked, FloatVector512Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "floatBinaryOpProvider") - static void withFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void withFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_DEFAULTFloat512VectorTests(IntFunction fa) { + static void IS_DEFAULTFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2994,7 +3193,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_DEFAULTMaskedFloat512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NEGATIVEFloat512VectorTests(IntFunction fa) { + static void IS_NEGATIVEFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3035,7 +3234,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NEGATIVEMaskedFloat512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3055,11 +3254,11 @@ relativeError)); } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_FINITEFloat512VectorTests(IntFunction fa) { + static void IS_FINITEFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3076,7 +3275,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_FINITEMaskedFloat512VectorTests(IntFunction fa, + static void IS_FINITEMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3096,11 +3295,11 @@ relativeError)); } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NANFloat512VectorTests(IntFunction fa) { + static void IS_NANFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3117,7 +3316,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NANMaskedFloat512VectorTests(IntFunction fa, + static void IS_NANMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3137,11 +3336,11 @@ relativeError)); } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_INFINITEFloat512VectorTests(IntFunction fa) { + static void IS_INFINITEFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3158,7 +3357,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_INFINITEMaskedFloat512VectorTests(IntFunction fa, + static void IS_INFINITEMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3178,7 +3377,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void LTFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3197,7 +3396,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void ltFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3216,7 +3415,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3239,7 +3438,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GTFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void GTFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3258,7 +3457,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GTFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3281,7 +3480,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void EQFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3300,7 +3499,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void eqFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3319,7 +3518,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3342,7 +3541,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void NEFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void NEFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3361,7 +3560,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void NEFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3384,7 +3583,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LEFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void LEFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3403,7 +3602,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LEFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3426,7 +3625,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GEFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void GEFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3445,7 +3644,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GEFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3468,7 +3667,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3478,13 +3677,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3498,13 +3697,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3514,13 +3713,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTFloatVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3534,13 +3733,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (float)((long)b[i])))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3550,13 +3749,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3570,13 +3769,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3586,13 +3785,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQFloatVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3606,7 +3805,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (float)((long)b[i])))); } } } @@ -3616,7 +3815,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat512VectorTests(IntFunction fa, IntFunction fb, + static void blendFloatVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3632,11 +3831,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float512VectorTests::blend); + assertArraysEquals(r, a, b, mask, FloatVector512Tests::blend); } @Test(dataProvider = "floatUnaryOpShuffleProvider") - static void RearrangeFloat512VectorTests(IntFunction fa, + static void RearrangeFloatVector512Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3653,7 +3852,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") - static void RearrangeFloat512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeFloatVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -3671,7 +3870,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void compressFloat512VectorTests(IntFunction fa, + static void compressFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3689,7 +3888,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void expandFloat512VectorTests(IntFunction fa, + static void expandFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3707,7 +3906,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void getFloat512VectorTests(IntFunction fa) { + static void getFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3863,7 +4062,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void BroadcastFloat512VectorTests(IntFunction fa) { + static void BroadcastFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3877,7 +4076,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ZeroFloat512VectorTests(IntFunction fa) { + static void ZeroFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3902,7 +4101,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void sliceUnaryFloat512VectorTests(IntFunction fa) { + static void sliceUnaryFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3913,7 +4112,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatVector512Tests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { @@ -3930,7 +4129,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void sliceBinaryFloat512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryFloatVector512TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3943,7 +4142,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Float512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatVector512Tests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { @@ -3960,7 +4159,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void sliceFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3977,7 +4176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Float512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatVector512Tests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { @@ -3994,7 +4193,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void unsliceUnaryFloat512VectorTests(IntFunction fa) { + static void unsliceUnaryFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -4005,7 +4204,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatVector512Tests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { @@ -4031,7 +4230,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void unsliceBinaryFloat512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryFloatVector512TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -4045,7 +4244,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Float512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatVector512Tests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { @@ -4085,7 +4284,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void unsliceFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4102,19 +4301,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Float512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatVector512Tests::unslice); } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINFloat512VectorTests(IntFunction fa) { + static void SINFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4125,19 +4324,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::SIN, Float512VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::SIN, FloatVector512Tests::strictSIN); } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPFloat512VectorTests(IntFunction fa) { + static void EXPFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4148,19 +4347,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::EXP, Float512VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::EXP, FloatVector512Tests::strictEXP); } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG1PFloat512VectorTests(IntFunction fa) { + static void LOG1PFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4171,19 +4370,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG1P, Float512VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::LOG1P, FloatVector512Tests::strictLOG1P); } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOGFloat512VectorTests(IntFunction fa) { + static void LOGFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4194,19 +4393,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG, Float512VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::LOG, FloatVector512Tests::strictLOG); } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG10Float512VectorTests(IntFunction fa) { + static void LOG10FloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4217,19 +4416,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::LOG10, Float512VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::LOG10, FloatVector512Tests::strictLOG10); } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPM1Float512VectorTests(IntFunction fa) { + static void EXPM1FloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4240,19 +4439,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::EXPM1, Float512VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::EXPM1, FloatVector512Tests::strictEXPM1); } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSFloat512VectorTests(IntFunction fa) { + static void COSFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4263,19 +4462,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::COS, Float512VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::COS, FloatVector512Tests::strictCOS); } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANFloat512VectorTests(IntFunction fa) { + static void TANFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4286,19 +4485,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::TAN, Float512VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::TAN, FloatVector512Tests::strictTAN); } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINHFloat512VectorTests(IntFunction fa) { + static void SINHFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4309,19 +4508,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::SINH, Float512VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::SINH, FloatVector512Tests::strictSINH); } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSHFloat512VectorTests(IntFunction fa) { + static void COSHFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4332,19 +4531,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::COSH, Float512VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::COSH, FloatVector512Tests::strictCOSH); } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANHFloat512VectorTests(IntFunction fa) { + static void TANHFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4355,19 +4554,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::TANH, Float512VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::TANH, FloatVector512Tests::strictTANH); } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ASINFloat512VectorTests(IntFunction fa) { + static void ASINFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4378,19 +4577,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ASIN, Float512VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::ASIN, FloatVector512Tests::strictASIN); } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ACOSFloat512VectorTests(IntFunction fa) { + static void ACOSFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4401,19 +4600,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ACOS, Float512VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::ACOS, FloatVector512Tests::strictACOS); } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ATANFloat512VectorTests(IntFunction fa) { + static void ATANFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4424,19 +4623,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::ATAN, Float512VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::ATAN, FloatVector512Tests::strictATAN); } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void CBRTFloat512VectorTests(IntFunction fa) { + static void CBRTFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4447,19 +4646,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float512VectorTests::CBRT, Float512VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatVector512Tests::CBRT, FloatVector512Tests::strictCBRT); } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void HYPOTFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4472,20 +4671,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::HYPOT, Float512VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::HYPOT, FloatVector512Tests::strictHYPOT); } static float POW(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictPOW(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void POWFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4498,20 +4697,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::POW, Float512VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::POW, FloatVector512Tests::strictPOW); } static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void powFloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4524,20 +4723,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::pow, Float512VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::pow, FloatVector512Tests::strictpow); } static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ATAN2Float512VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2FloatVector512Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4550,12 +4749,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::ATAN2, Float512VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::ATAN2, FloatVector512Tests::strictATAN2); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4565,12 +4764,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::POW, Float512VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::POW, FloatVector512Tests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4580,20 +4779,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float512VectorTests::pow, Float512VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector512Tests::pow, FloatVector512Tests::strictpow); } static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4608,11 +4807,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Float512VectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4625,11 +4824,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Float512VectorTests::fma); + assertArraysEquals(r, a, b, c, FloatVector512Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMAFloatVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4647,11 +4846,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Float512VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4662,11 +4861,11 @@ relativeError)); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4677,11 +4876,11 @@ relativeError)); FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4696,11 +4895,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Float512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4715,11 +4914,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Float512VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4730,11 +4929,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float512VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector512Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4745,11 +4944,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float512VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector512Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4763,19 +4962,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float512VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatVector512Tests::FMA); } static float NEG(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } static float neg(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void NEGFloat512VectorTests(IntFunction fa) { + static void NEGFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4786,11 +4985,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::NEG); + assertArraysEquals(r, a, FloatVector512Tests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") - static void negFloat512VectorTests(IntFunction fa) { + static void negFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4801,11 +5000,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::neg); + assertArraysEquals(r, a, FloatVector512Tests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void NEGMaskedFloat512VectorTests(IntFunction fa, + static void NEGMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4819,19 +5018,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float512VectorTests::NEG); + assertArraysEquals(r, a, mask, FloatVector512Tests::NEG); } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ABSFloat512VectorTests(IntFunction fa) { + static void ABSFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4842,11 +5041,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::ABS); + assertArraysEquals(r, a, FloatVector512Tests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") - static void absFloat512VectorTests(IntFunction fa) { + static void absFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4857,11 +5056,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::abs); + assertArraysEquals(r, a, FloatVector512Tests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ABSMaskedFloat512VectorTests(IntFunction fa, + static void ABSMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4875,19 +5074,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float512VectorTests::ABS); + assertArraysEquals(r, a, mask, FloatVector512Tests::ABS); } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SQRTFloat512VectorTests(IntFunction fa) { + static void SQRTFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4898,11 +5097,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::SQRT); + assertArraysEquals(r, a, FloatVector512Tests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") - static void sqrtFloat512VectorTests(IntFunction fa) { + static void sqrtFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4913,11 +5112,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::sqrt); + assertArraysEquals(r, a, FloatVector512Tests::sqrt); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void SQRTMaskedFloat512VectorTests(IntFunction fa, + static void SQRTMaskedFloatVector512Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4931,7 +5130,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float512VectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatVector512Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4939,7 +5138,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4952,7 +5151,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::band); + assertArraysEquals(r, a, b, FloatVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4960,7 +5159,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4973,7 +5172,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::bor); + assertArraysEquals(r, a, b, FloatVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -4981,7 +5180,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4994,7 +5193,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::bxor); + assertArraysEquals(r, a, b, FloatVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5002,7 +5201,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5015,7 +5214,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::bandNot); + assertArraysEquals(r, a, b, FloatVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5023,7 +5222,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5036,7 +5235,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float512VectorTests::beq); + assertArraysEquals(r, a, b, FloatVector512Tests::beq); } static boolean unot(boolean a) { @@ -5044,7 +5243,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotFloat512VectorTests(IntFunction fa) { + static void masknotFloatVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5055,7 +5254,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::unot); + assertArraysEquals(r, a, FloatVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5072,7 +5271,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongFloat512VectorTests(IntFunction fa) { + static void maskFromToLongFloatVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5086,7 +5285,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltFloatVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5096,13 +5295,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqFloatVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5112,13 +5311,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floattoIntUnaryOpProvider") - static void toIntArrayFloat512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5129,7 +5328,7 @@ relativeError)); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void toLongArrayFloat512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5140,7 +5339,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toDoubleArrayFloat512VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5151,7 +5350,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toStringFloat512VectorTestsSmokeTest(IntFunction fa) { + static void toStringFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5164,7 +5363,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void hashCodeFloat512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5181,7 +5380,7 @@ relativeError)); static long ADDReduceLong(float[] a, int idx) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5190,14 +5389,14 @@ relativeError)); static long ADDReduceAllLong(float[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((float)res, (float)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceLongFloat512VectorTests(IntFunction fa) { + static void ADDReduceLongFloatVector512Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5208,19 +5407,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Float512VectorTests::ADDReduceLong, Float512VectorTests::ADDReduceAllLong); + FloatVector512Tests::ADDReduceLong, FloatVector512Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5229,14 +5429,14 @@ relativeError)); static long ADDReduceAllLongMasked(float[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((float)res, (float)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceLongFloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongFloatVector512TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5249,16 +5449,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Float512VectorTests::ADDReduceLongMasked, Float512VectorTests::ADDReduceAllLongMasked); + FloatVector512Tests::ADDReduceLongMasked, FloatVector512Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void BroadcastLongFloat512VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongFloatVector512TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -5269,7 +5469,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendFloatVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5283,12 +5483,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Float512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector512Tests::blend); } @Test(dataProvider = "floatUnaryOpSelectFromProvider") - static void SelectFromFloat512VectorTests(IntFunction fa, + static void SelectFromFloatVector512Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); float[] order = fs.apply(a.length, SPECIES.length()); @@ -5304,7 +5504,7 @@ relativeError)); } @Test(dataProvider = "floatSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorFloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorFloatVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] idx = fc.apply(SPECIES.length()); @@ -5322,7 +5522,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") - static void SelectFromFloat512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromFloatVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -5341,7 +5541,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousFloat512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousFloatVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5357,7 +5557,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringFloat512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringFloatVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5371,7 +5571,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsFloat512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsFloatVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5385,7 +5585,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsFloat512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsFloatVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5401,7 +5601,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeFloat512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeFloatVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5423,7 +5623,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountFloat512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountFloatVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5434,7 +5634,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, FloatVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5448,7 +5648,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueFloat512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueFloatVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5459,7 +5659,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, FloatVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5473,7 +5673,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueFloat512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueFloatVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5484,11 +5684,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, FloatVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressFloat512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressFloatVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5516,7 +5716,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeFloat512VectorTestsSmokeTest(int offset) { + static void indexInRangeFloatVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5530,7 +5730,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongFloat512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongFloatVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5557,14 +5757,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundFloat512VectorTestsSmokeTest(int length) { + static void loopBoundFloatVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongFloat512VectorTestsSmokeTest(int _length) { + static void loopBoundLongFloatVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5572,21 +5772,21 @@ relativeError)); } @Test - static void ElementSizeFloat512VectorTestsSmokeTest() { + static void ElementSizeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Float.SIZE); } @Test - static void VectorShapeFloat512VectorTestsSmokeTest() { + static void VectorShapeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesFloat512VectorTestsSmokeTest() { + static void ShapeWithLanesFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(float.class); @@ -5594,32 +5794,32 @@ relativeError)); } @Test - static void ElementTypeFloat512VectorTestsSmokeTest() { + static void ElementTypeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementType() == float.class); } @Test - static void SpeciesElementSizeFloat512VectorTestsSmokeTest() { + static void SpeciesElementSizeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementSize() == Float.SIZE); } @Test - static void VectorTypeFloat512VectorTestsSmokeTest() { + static void VectorTypeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesFloat512VectorTestsSmokeTest() { + static void WithLanesFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(float.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeFloat512VectorTestsSmokeTest() { + static void WithShapeFloatVector512TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5627,7 +5827,7 @@ relativeError)); } @Test - static void MaskAllTrueFloat512VectorTestsSmokeTest() { + static void MaskAllTrueFloatVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/FloatVector64LoadStoreTests.java index afa08dc8f33..359558abbd1 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Float64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation FloatVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Float64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class FloatVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/FloatVector64Tests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/Float64VectorTests.java rename to test/jdk/jdk/incubator/vector/FloatVector64Tests.java index 4a8f917b50e..b06dff18194 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Float64VectorTests extends AbstractVectorTest { +public class FloatVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_64; @@ -1601,6 +1601,205 @@ relativeError)); return Float.compare(a, (float) 0) != 0 ? a : b; } + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1694,11 +1893,11 @@ relativeError)); } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1711,15 +1910,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::ADD); + assertArraysEquals(r, a, b, FloatVector64Tests::ADD); } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void addFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1730,11 +1929,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::add); + assertArraysEquals(r, a, b, FloatVector64Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1750,11 +1949,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1768,15 +1967,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float64VectorTests::add); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::add); } static float SUB(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void SUBFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1789,15 +1988,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::SUB); + assertArraysEquals(r, a, b, FloatVector64Tests::SUB); } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void subFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1808,11 +2007,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::sub); + assertArraysEquals(r, a, b, FloatVector64Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void SUBFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1828,11 +2027,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::SUB); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1846,15 +2045,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float64VectorTests::sub); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::sub); } static float MUL(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MULFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void MULFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1867,15 +2066,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::MUL); + assertArraysEquals(r, a, b, FloatVector64Tests::MUL); } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void mulFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1886,11 +2085,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::mul); + assertArraysEquals(r, a, b, FloatVector64Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void MULFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1906,11 +2105,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::MUL); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1924,15 +2123,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float64VectorTests::mul); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::mul); } static float DIV(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void DIVFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1945,15 +2144,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::DIV); + assertArraysEquals(r, a, b, FloatVector64Tests::DIV); } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void divFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1964,11 +2163,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::div); + assertArraysEquals(r, a, b, FloatVector64Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void DIVFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1984,11 +2183,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::DIV); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2002,15 +2201,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Float64VectorTests::div); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::div); } static float FIRST_NONZERO(float a, float b) { - return (float)(Double.doubleToLongBits(a)!=0?a:b); + return (float)(firstNonZero(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void FIRST_NONZEROFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2023,11 +2222,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void FIRST_NONZEROFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2043,11 +2242,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2057,11 +2256,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2074,11 +2273,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector64Tests::add); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2088,11 +2287,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2105,11 +2304,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector64Tests::sub); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2119,11 +2318,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2136,11 +2335,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector64Tests::mul); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2150,11 +2349,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2167,11 +2366,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatVector64Tests::div); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDFloatVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2380,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Float64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatVector64Tests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloat64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDFloatVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2198,13 +2397,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Float64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector64Tests::ADD); } static FloatVector bv_MIN = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MINFloat64VectorTestsWithMemOp(IntFunction fa) { + static void MINFloatVector64TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2215,13 +2414,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float64VectorTests::MIN); + assertArraysEquals(r, a, (float)10, FloatVector64Tests::MIN); } static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void minFloat64VectorTestsWithMemOp(IntFunction fa) { + static void minFloatVector64TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2232,13 +2431,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float64VectorTests::min); + assertArraysEquals(r, a, (float)10, FloatVector64Tests::min); } static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINFloatVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2251,13 +2450,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float64VectorTests::MIN); + assertArraysEquals(r, a, (float)10, mask, FloatVector64Tests::MIN); } static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MAXFloat64VectorTestsWithMemOp(IntFunction fa) { + static void MAXFloatVector64TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2268,13 +2467,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float64VectorTests::MAX); + assertArraysEquals(r, a, (float)10, FloatVector64Tests::MAX); } static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void maxFloat64VectorTestsWithMemOp(IntFunction fa) { + static void maxFloatVector64TestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2285,13 +2484,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, Float64VectorTests::max); + assertArraysEquals(r, a, (float)10, FloatVector64Tests::max); } static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXFloatVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2304,15 +2503,15 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, Float64VectorTests::MAX); + assertArraysEquals(r, a, (float)10, mask, FloatVector64Tests::MAX); } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void MINFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2325,15 +2524,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::MIN); + assertArraysEquals(r, a, b, FloatVector64Tests::MIN); } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void minFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2344,15 +2543,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::min); + assertArraysEquals(r, a, b, FloatVector64Tests::min); } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2365,15 +2564,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::MAX); + assertArraysEquals(r, a, b, FloatVector64Tests::MAX); } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maxFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2583,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Float64VectorTests::max); + assertArraysEquals(r, a, b, FloatVector64Tests::max); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2398,11 +2597,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2412,11 +2611,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::min); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2426,11 +2625,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2440,13 +2639,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Float64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatVector64Tests::max); } static float ADDReduce(float[] a, int idx) { float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2455,14 +2654,14 @@ relativeError)); static float ADDReduceAll(float[] a) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceFloat64VectorTests(IntFunction fa) { + static void ADDReduceFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2473,12 +2672,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float64VectorTests::ADDReduce, Float64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector64Tests::ADDReduce, FloatVector64Tests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2486,20 +2685,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = ADD_IDENTITY; - assertEquals((float) (id + id), id, + assertEquals((float) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id + x), x); - assertEquals((float) (x + id), x); + assertEquals((float) (scalar_add(id, x)), x); + assertEquals((float) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id + x), x, + assertEquals((float) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x + id), x, + assertEquals((float) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2508,7 +2707,7 @@ relativeError)); float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2517,14 +2716,14 @@ relativeError)); static float ADDReduceAllMasked(float[] a, boolean[] mask) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2537,18 +2736,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::ADDReduceMasked, Float64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVector64Tests::ADDReduceMasked, FloatVector64Tests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static float MULReduce(float[] a, int idx) { float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2557,14 +2756,14 @@ relativeError)); static float MULReduceAll(float[] a) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MULReduceFloat64VectorTests(IntFunction fa) { + static void MULReduceFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2575,12 +2774,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float64VectorTests::MULReduce, Float64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector64Tests::MULReduce, FloatVector64Tests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2588,20 +2787,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MUL_IDENTITY; - assertEquals((float) (id * id), id, + assertEquals((float) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id * x), x); - assertEquals((float) (x * id), x); + assertEquals((float) (scalar_mul(id, x)), x); + assertEquals((float) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id * x), x, + assertEquals((float) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x * id), x, + assertEquals((float) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2610,7 +2809,7 @@ relativeError)); float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2619,14 +2818,14 @@ relativeError)); static float MULReduceAllMasked(float[] a, boolean[] mask) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MULReduceFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2639,18 +2838,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::MULReduceMasked, Float64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVector64Tests::MULReduceMasked, FloatVector64Tests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static float MINReduce(float[] a, int idx) { float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2659,14 +2858,14 @@ relativeError)); static float MINReduceAll(float[] a) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MINReduceFloat64VectorTests(IntFunction fa) { + static void MINReduceFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2677,12 +2876,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float64VectorTests::MINReduce, Float64VectorTests::MINReduceAll); + FloatVector64Tests::MINReduce, FloatVector64Tests::MINReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2690,20 +2889,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MIN_IDENTITY; - assertEquals((float) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.min(id, x), x); - assertEquals((float) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2712,7 +2911,7 @@ relativeError)); float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2721,14 +2920,14 @@ relativeError)); static float MINReduceAllMasked(float[] a, boolean[] mask) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINReduceFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2741,18 +2940,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::MINReduceMasked, Float64VectorTests::MINReduceAllMasked); + FloatVector64Tests::MINReduceMasked, FloatVector64Tests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2761,14 +2960,14 @@ relativeError)); static float MAXReduceAll(float[] a) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MAXReduceFloat64VectorTests(IntFunction fa) { + static void MAXReduceFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2779,12 +2978,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Float64VectorTests::MAXReduce, Float64VectorTests::MAXReduceAll); + FloatVector64Tests::MAXReduce, FloatVector64Tests::MAXReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2792,20 +2991,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MAX_IDENTITY; - assertEquals((float) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.max(id, x), x); - assertEquals((float) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2814,7 +3013,7 @@ relativeError)); float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2823,14 +3022,14 @@ relativeError)); static float MAXReduceAllMasked(float[] a, boolean[] mask) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXReduceFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2843,12 +3042,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::MAXReduceMasked, Float64VectorTests::MAXReduceAllMasked); + FloatVector64Tests::MAXReduceMasked, FloatVector64Tests::MAXReduceAllMasked); } static float FIRST_NONZEROReduce(float[] a, int idx) { @@ -2870,7 +3069,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void FIRST_NONZEROReduceFloat64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2886,7 +3085,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - Float64VectorTests::FIRST_NONZEROReduce, Float64VectorTests::FIRST_NONZEROReduceAll); + FloatVector64Tests::FIRST_NONZEROReduce, FloatVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2932,7 +3131,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void FIRST_NONZEROReduceFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2950,11 +3149,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::FIRST_NONZEROReduceMasked, Float64VectorTests::FIRST_NONZEROReduceAllMasked); + FloatVector64Tests::FIRST_NONZEROReduceMasked, FloatVector64Tests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "floatBinaryOpProvider") - static void withFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void withFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2977,7 +3176,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_DEFAULTFloat64VectorTests(IntFunction fa) { + static void IS_DEFAULTFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -2994,7 +3193,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_DEFAULTMaskedFloat64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3018,7 +3217,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NEGATIVEFloat64VectorTests(IntFunction fa) { + static void IS_NEGATIVEFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3035,7 +3234,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NEGATIVEMaskedFloat64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3055,11 +3254,11 @@ relativeError)); } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_FINITEFloat64VectorTests(IntFunction fa) { + static void IS_FINITEFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3076,7 +3275,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_FINITEMaskedFloat64VectorTests(IntFunction fa, + static void IS_FINITEMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3096,11 +3295,11 @@ relativeError)); } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NANFloat64VectorTests(IntFunction fa) { + static void IS_NANFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3117,7 +3316,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NANMaskedFloat64VectorTests(IntFunction fa, + static void IS_NANMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3137,11 +3336,11 @@ relativeError)); } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_INFINITEFloat64VectorTests(IntFunction fa) { + static void IS_INFINITEFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3158,7 +3357,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_INFINITEMaskedFloat64VectorTests(IntFunction fa, + static void IS_INFINITEMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3178,7 +3377,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void LTFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3197,7 +3396,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void ltFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3216,7 +3415,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3239,7 +3438,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GTFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void GTFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3258,7 +3457,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GTFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3281,7 +3480,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void EQFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3300,7 +3499,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void eqFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3319,7 +3518,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3342,7 +3541,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void NEFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void NEFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3361,7 +3560,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void NEFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3384,7 +3583,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LEFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void LEFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3403,7 +3602,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LEFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3426,7 +3625,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GEFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void GEFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3445,7 +3644,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GEFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3468,7 +3667,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3478,13 +3677,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3498,13 +3697,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3514,13 +3713,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTFloatVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3534,13 +3733,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (float)((long)b[i])))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3550,13 +3749,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3570,13 +3769,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3586,13 +3785,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQFloatVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3606,7 +3805,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (float)((long)b[i])))); } } } @@ -3616,7 +3815,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat64VectorTests(IntFunction fa, IntFunction fb, + static void blendFloatVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3632,11 +3831,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, Float64VectorTests::blend); + assertArraysEquals(r, a, b, mask, FloatVector64Tests::blend); } @Test(dataProvider = "floatUnaryOpShuffleProvider") - static void RearrangeFloat64VectorTests(IntFunction fa, + static void RearrangeFloatVector64Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3653,7 +3852,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") - static void RearrangeFloat64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeFloatVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -3671,7 +3870,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void compressFloat64VectorTests(IntFunction fa, + static void compressFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3689,7 +3888,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void expandFloat64VectorTests(IntFunction fa, + static void expandFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3707,7 +3906,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void getFloat64VectorTests(IntFunction fa) { + static void getFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3863,7 +4062,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void BroadcastFloat64VectorTests(IntFunction fa) { + static void BroadcastFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3877,7 +4076,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ZeroFloat64VectorTests(IntFunction fa) { + static void ZeroFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3902,7 +4101,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void sliceUnaryFloat64VectorTests(IntFunction fa) { + static void sliceUnaryFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3913,7 +4112,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatVector64Tests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { @@ -3930,7 +4129,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void sliceBinaryFloat64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryFloatVector64TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3943,7 +4142,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, Float64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatVector64Tests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { @@ -3960,7 +4159,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void sliceFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3977,7 +4176,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, Float64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatVector64Tests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { @@ -3994,7 +4193,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void unsliceUnaryFloat64VectorTests(IntFunction fa) { + static void unsliceUnaryFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -4005,7 +4204,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, Float64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatVector64Tests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { @@ -4031,7 +4230,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void unsliceBinaryFloat64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryFloatVector64TestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -4045,7 +4244,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, Float64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatVector64Tests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { @@ -4085,7 +4284,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void unsliceFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4102,19 +4301,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, Float64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatVector64Tests::unslice); } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINFloat64VectorTests(IntFunction fa) { + static void SINFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4125,19 +4324,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::SIN, Float64VectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::SIN, FloatVector64Tests::strictSIN); } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPFloat64VectorTests(IntFunction fa) { + static void EXPFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4148,19 +4347,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXP, Float64VectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::EXP, FloatVector64Tests::strictEXP); } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG1PFloat64VectorTests(IntFunction fa) { + static void LOG1PFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4171,19 +4370,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG1P, Float64VectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::LOG1P, FloatVector64Tests::strictLOG1P); } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOGFloat64VectorTests(IntFunction fa) { + static void LOGFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4194,19 +4393,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG, Float64VectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::LOG, FloatVector64Tests::strictLOG); } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG10Float64VectorTests(IntFunction fa) { + static void LOG10FloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4217,19 +4416,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG10, Float64VectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::LOG10, FloatVector64Tests::strictLOG10); } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPM1Float64VectorTests(IntFunction fa) { + static void EXPM1FloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4240,19 +4439,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXPM1, Float64VectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::EXPM1, FloatVector64Tests::strictEXPM1); } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSFloat64VectorTests(IntFunction fa) { + static void COSFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4263,19 +4462,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COS, Float64VectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::COS, FloatVector64Tests::strictCOS); } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANFloat64VectorTests(IntFunction fa) { + static void TANFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4286,19 +4485,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TAN, Float64VectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::TAN, FloatVector64Tests::strictTAN); } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINHFloat64VectorTests(IntFunction fa) { + static void SINHFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4309,19 +4508,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::SINH, Float64VectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::SINH, FloatVector64Tests::strictSINH); } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSHFloat64VectorTests(IntFunction fa) { + static void COSHFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4332,19 +4531,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COSH, Float64VectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::COSH, FloatVector64Tests::strictCOSH); } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANHFloat64VectorTests(IntFunction fa) { + static void TANHFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4355,19 +4554,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TANH, Float64VectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::TANH, FloatVector64Tests::strictTANH); } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ASINFloat64VectorTests(IntFunction fa) { + static void ASINFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4378,19 +4577,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ASIN, Float64VectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::ASIN, FloatVector64Tests::strictASIN); } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ACOSFloat64VectorTests(IntFunction fa) { + static void ACOSFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4401,19 +4600,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ACOS, Float64VectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::ACOS, FloatVector64Tests::strictACOS); } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ATANFloat64VectorTests(IntFunction fa) { + static void ATANFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4424,19 +4623,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ATAN, Float64VectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::ATAN, FloatVector64Tests::strictATAN); } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void CBRTFloat64VectorTests(IntFunction fa) { + static void CBRTFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4447,19 +4646,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::CBRT, Float64VectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatVector64Tests::CBRT, FloatVector64Tests::strictCBRT); } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void HYPOTFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4472,20 +4671,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::HYPOT, Float64VectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::HYPOT, FloatVector64Tests::strictHYPOT); } static float POW(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictPOW(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void POWFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4498,20 +4697,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::POW, FloatVector64Tests::strictPOW); } static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void powFloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4524,20 +4723,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::pow, FloatVector64Tests::strictpow); } static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ATAN2Float64VectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2FloatVector64Tests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4550,12 +4749,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::ATAN2, Float64VectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::ATAN2, FloatVector64Tests::strictATAN2); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4565,12 +4764,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::POW, FloatVector64Tests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4580,20 +4779,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVector64Tests::pow, FloatVector64Tests::strictpow); } static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4608,11 +4807,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, Float64VectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4625,11 +4824,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Float64VectorTests::fma); + assertArraysEquals(r, a, b, c, FloatVector64Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMAFloatVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4647,11 +4846,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4662,11 +4861,11 @@ relativeError)); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4677,11 +4876,11 @@ relativeError)); FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4696,11 +4895,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4715,11 +4914,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4730,11 +4929,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector64Tests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4745,11 +4944,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVector64Tests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloat64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4763,19 +4962,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatVector64Tests::FMA); } static float NEG(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } static float neg(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void NEGFloat64VectorTests(IntFunction fa) { + static void NEGFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4786,11 +4985,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::NEG); + assertArraysEquals(r, a, FloatVector64Tests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") - static void negFloat64VectorTests(IntFunction fa) { + static void negFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4801,11 +5000,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::neg); + assertArraysEquals(r, a, FloatVector64Tests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void NEGMaskedFloat64VectorTests(IntFunction fa, + static void NEGMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4819,19 +5018,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float64VectorTests::NEG); + assertArraysEquals(r, a, mask, FloatVector64Tests::NEG); } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ABSFloat64VectorTests(IntFunction fa) { + static void ABSFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4842,11 +5041,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::ABS); + assertArraysEquals(r, a, FloatVector64Tests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") - static void absFloat64VectorTests(IntFunction fa) { + static void absFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4857,11 +5056,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::abs); + assertArraysEquals(r, a, FloatVector64Tests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ABSMaskedFloat64VectorTests(IntFunction fa, + static void ABSMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4875,19 +5074,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float64VectorTests::ABS); + assertArraysEquals(r, a, mask, FloatVector64Tests::ABS); } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SQRTFloat64VectorTests(IntFunction fa) { + static void SQRTFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4898,11 +5097,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::SQRT); + assertArraysEquals(r, a, FloatVector64Tests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") - static void sqrtFloat64VectorTests(IntFunction fa) { + static void sqrtFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4913,11 +5112,11 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::sqrt); + assertArraysEquals(r, a, FloatVector64Tests::sqrt); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void SQRTMaskedFloat64VectorTests(IntFunction fa, + static void SQRTMaskedFloatVector64Tests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4931,7 +5130,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, Float64VectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatVector64Tests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4939,7 +5138,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4952,7 +5151,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::band); + assertArraysEquals(r, a, b, FloatVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -4960,7 +5159,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4973,7 +5172,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::bor); + assertArraysEquals(r, a, b, FloatVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -4981,7 +5180,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4994,7 +5193,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::bxor); + assertArraysEquals(r, a, b, FloatVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5002,7 +5201,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5015,7 +5214,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::bandNot); + assertArraysEquals(r, a, b, FloatVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5023,7 +5222,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5036,7 +5235,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, Float64VectorTests::beq); + assertArraysEquals(r, a, b, FloatVector64Tests::beq); } static boolean unot(boolean a) { @@ -5044,7 +5243,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotFloat64VectorTests(IntFunction fa) { + static void masknotFloatVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5055,7 +5254,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::unot); + assertArraysEquals(r, a, FloatVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5072,7 +5271,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongFloat64VectorTests(IntFunction fa) { + static void maskFromToLongFloatVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5086,7 +5285,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltFloatVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5096,13 +5295,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqFloatVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5112,13 +5311,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floattoIntUnaryOpProvider") - static void toIntArrayFloat64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5129,7 +5328,7 @@ relativeError)); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void toLongArrayFloat64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5140,7 +5339,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toDoubleArrayFloat64VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5151,7 +5350,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toStringFloat64VectorTestsSmokeTest(IntFunction fa) { + static void toStringFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5164,7 +5363,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void hashCodeFloat64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5181,7 +5380,7 @@ relativeError)); static long ADDReduceLong(float[] a, int idx) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5190,14 +5389,14 @@ relativeError)); static long ADDReduceAllLong(float[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((float)res, (float)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceLongFloat64VectorTests(IntFunction fa) { + static void ADDReduceLongFloatVector64Tests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5208,19 +5407,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Float64VectorTests::ADDReduceLong, Float64VectorTests::ADDReduceAllLong); + FloatVector64Tests::ADDReduceLong, FloatVector64Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5229,14 +5429,14 @@ relativeError)); static long ADDReduceAllLongMasked(float[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((float)res, (float)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceLongFloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongFloatVector64TestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5249,16 +5449,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Float64VectorTests::ADDReduceLongMasked, Float64VectorTests::ADDReduceAllLongMasked); + FloatVector64Tests::ADDReduceLongMasked, FloatVector64Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void BroadcastLongFloat64VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongFloatVector64TestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -5269,7 +5469,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendFloatVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5283,12 +5483,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Float64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVector64Tests::blend); } @Test(dataProvider = "floatUnaryOpSelectFromProvider") - static void SelectFromFloat64VectorTests(IntFunction fa, + static void SelectFromFloatVector64Tests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); float[] order = fs.apply(a.length, SPECIES.length()); @@ -5304,7 +5504,7 @@ relativeError)); } @Test(dataProvider = "floatSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorFloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorFloatVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] idx = fc.apply(SPECIES.length()); @@ -5322,7 +5522,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") - static void SelectFromFloat64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromFloatVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -5341,7 +5541,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousFloat64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousFloatVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5357,7 +5557,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringFloat64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringFloatVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5371,7 +5571,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsFloat64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsFloatVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5385,7 +5585,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsFloat64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsFloatVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5401,7 +5601,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeFloat64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeFloatVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5423,7 +5623,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountFloat64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountFloatVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5434,7 +5634,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, FloatVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5448,7 +5648,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueFloat64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueFloatVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5459,7 +5659,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, FloatVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5473,7 +5673,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueFloat64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueFloatVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5484,11 +5684,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, Float64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, FloatVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressFloat64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressFloatVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5516,7 +5716,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeFloat64VectorTestsSmokeTest(int offset) { + static void indexInRangeFloatVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5530,7 +5730,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongFloat64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongFloatVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5557,14 +5757,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundFloat64VectorTestsSmokeTest(int length) { + static void loopBoundFloatVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongFloat64VectorTestsSmokeTest(int _length) { + static void loopBoundLongFloatVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5572,21 +5772,21 @@ relativeError)); } @Test - static void ElementSizeFloat64VectorTestsSmokeTest() { + static void ElementSizeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Float.SIZE); } @Test - static void VectorShapeFloat64VectorTestsSmokeTest() { + static void VectorShapeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesFloat64VectorTestsSmokeTest() { + static void ShapeWithLanesFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(float.class); @@ -5594,32 +5794,32 @@ relativeError)); } @Test - static void ElementTypeFloat64VectorTestsSmokeTest() { + static void ElementTypeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementType() == float.class); } @Test - static void SpeciesElementSizeFloat64VectorTestsSmokeTest() { + static void SpeciesElementSizeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementSize() == Float.SIZE); } @Test - static void VectorTypeFloat64VectorTestsSmokeTest() { + static void VectorTypeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesFloat64VectorTestsSmokeTest() { + static void WithLanesFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(float.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeFloat64VectorTestsSmokeTest() { + static void WithShapeFloatVector64TestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5627,7 +5827,7 @@ relativeError)); } @Test - static void MaskAllTrueFloat64VectorTestsSmokeTest() { + static void MaskAllTrueFloatVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/FloatVectorMaxLoadStoreTests.java index 931e9b78306..d1832ea8e3a 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation FloatMaxVectorLoadStoreTests + * -XX:-TieredCompilation FloatVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class FloatMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class FloatVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java similarity index 86% rename from test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java index 6ea96388706..9b84e852c1c 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -55,7 +55,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class FloatMaxVectorTests extends AbstractVectorTest { +public class FloatVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = FloatVector.SPECIES_MAX; @@ -1607,6 +1607,205 @@ relativeError)); return Float.compare(a, (float) 0) != 0 ? a : b; } + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1700,11 +1899,11 @@ relativeError)); } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1717,15 +1916,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::ADD); + assertArraysEquals(r, a, b, FloatVectorMaxTests::ADD); } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1736,11 +1935,11 @@ relativeError)); av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::add); + assertArraysEquals(r, a, b, FloatVectorMaxTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1756,11 +1955,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1774,15 +1973,15 @@ relativeError)); av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::add); } static float SUB(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void SUBFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1795,15 +1994,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::SUB); + assertArraysEquals(r, a, b, FloatVectorMaxTests::SUB); } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1814,11 +2013,11 @@ relativeError)); av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::sub); + assertArraysEquals(r, a, b, FloatVectorMaxTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void SUBFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1834,11 +2033,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::SUB); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1852,15 +2051,15 @@ relativeError)); av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::sub); } static float MUL(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MULFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1873,15 +2072,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::MUL); + assertArraysEquals(r, a, b, FloatVectorMaxTests::MUL); } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1892,11 +2091,11 @@ relativeError)); av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::mul); + assertArraysEquals(r, a, b, FloatVectorMaxTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void MULFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1912,11 +2111,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::MUL); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1930,15 +2129,15 @@ relativeError)); av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::mul); } static float DIV(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void DIVFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1951,15 +2150,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::DIV); + assertArraysEquals(r, a, b, FloatVectorMaxTests::DIV); } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -1970,11 +2169,11 @@ relativeError)); av.div(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::div); + assertArraysEquals(r, a, b, FloatVectorMaxTests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void DIVFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -1990,11 +2189,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::DIV); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2008,15 +2207,15 @@ relativeError)); av.div(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::div); } static float FIRST_NONZERO(float a, float b) { - return (float)(Double.doubleToLongBits(a)!=0?a:b); + return (float)(firstNonZero(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void FIRST_NONZEROFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2029,11 +2228,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, FloatVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void FIRST_NONZEROFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2049,11 +2248,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "floatBinaryOpProvider") - static void addFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2063,11 +2262,11 @@ relativeError)); av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::add); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void addFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2080,11 +2279,11 @@ relativeError)); av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, FloatVectorMaxTests::add); } @Test(dataProvider = "floatBinaryOpProvider") - static void subFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2094,11 +2293,11 @@ relativeError)); av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::sub); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void subFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2111,11 +2310,11 @@ relativeError)); av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, FloatVectorMaxTests::sub); } @Test(dataProvider = "floatBinaryOpProvider") - static void mulFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2125,11 +2324,11 @@ relativeError)); av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::mul); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void mulFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2142,11 +2341,11 @@ relativeError)); av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, FloatVectorMaxTests::mul); } @Test(dataProvider = "floatBinaryOpProvider") - static void divFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2156,11 +2355,11 @@ relativeError)); av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::div); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void divFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2173,11 +2372,11 @@ relativeError)); av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, FloatMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, FloatVectorMaxTests::div); } @Test(dataProvider = "floatBinaryOpProvider") - static void ADDFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDFloatVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2187,11 +2386,11 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, FloatMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, FloatVectorMaxTests::ADD); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void ADDFloatMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDFloatVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -2204,13 +2403,13 @@ relativeError)); av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, FloatMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVectorMaxTests::ADD); } static FloatVector bv_MIN = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MINFloatMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINFloatVectorMaxTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2221,13 +2420,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::MIN); + assertArraysEquals(r, a, (float)10, FloatVectorMaxTests::MIN); } static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void minFloatMaxVectorTestsWithMemOp(IntFunction fa) { + static void minFloatVectorMaxTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2238,13 +2437,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::min); + assertArraysEquals(r, a, (float)10, FloatVectorMaxTests::min); } static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINFloatVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2257,13 +2456,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, FloatMaxVectorTests::MIN); + assertArraysEquals(r, a, (float)10, mask, FloatVectorMaxTests::MIN); } static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void MAXFloatMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXFloatVectorMaxTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2274,13 +2473,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::MAX); + assertArraysEquals(r, a, (float)10, FloatVectorMaxTests::MAX); } static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpProvider") - static void maxFloatMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxFloatVectorMaxTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2291,13 +2490,13 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::max); + assertArraysEquals(r, a, (float)10, FloatVectorMaxTests::max); } static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXFloatVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2310,15 +2509,15 @@ relativeError)); } } - assertArraysEquals(r, a, (float)10, mask, FloatMaxVectorTests::MAX); + assertArraysEquals(r, a, (float)10, mask, FloatVectorMaxTests::MAX); } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2331,15 +2530,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::MIN); + assertArraysEquals(r, a, b, FloatVectorMaxTests::MIN); } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2350,15 +2549,15 @@ relativeError)); av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::min); + assertArraysEquals(r, a, b, FloatVectorMaxTests::min); } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2371,15 +2570,15 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::MAX); + assertArraysEquals(r, a, b, FloatVectorMaxTests::MAX); } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2390,11 +2589,11 @@ relativeError)); av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, FloatMaxVectorTests::max); + assertArraysEquals(r, a, b, FloatVectorMaxTests::max); } @Test(dataProvider = "floatBinaryOpProvider") - static void MINFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2404,11 +2603,11 @@ relativeError)); av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::MIN); } @Test(dataProvider = "floatBinaryOpProvider") - static void minFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2418,11 +2617,11 @@ relativeError)); av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::min); } @Test(dataProvider = "floatBinaryOpProvider") - static void MAXFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2432,11 +2631,11 @@ relativeError)); av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::MAX); } @Test(dataProvider = "floatBinaryOpProvider") - static void maxFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2446,13 +2645,13 @@ relativeError)); av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, FloatMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, FloatVectorMaxTests::max); } static float ADDReduce(float[] a, int idx) { float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2461,14 +2660,14 @@ relativeError)); static float ADDReduceAll(float[] a) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceFloatMaxVectorTests(IntFunction fa) { + static void ADDReduceFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2479,12 +2678,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - FloatMaxVectorTests::ADDReduce, FloatMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVectorMaxTests::ADDReduce, FloatVectorMaxTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2492,20 +2691,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = ADD_IDENTITY; - assertEquals((float) (id + id), id, + assertEquals((float) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id + x), x); - assertEquals((float) (x + id), x); + assertEquals((float) (scalar_add(id, x)), x); + assertEquals((float) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id + x), x, + assertEquals((float) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x + id), x, + assertEquals((float) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -2514,7 +2713,7 @@ relativeError)); float res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -2523,14 +2722,14 @@ relativeError)); static float ADDReduceAllMasked(float[] a, boolean[] mask) { float res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2543,18 +2742,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::ADDReduceMasked, FloatMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); + FloatVectorMaxTests::ADDReduceMasked, FloatVectorMaxTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } static float MULReduce(float[] a, int idx) { float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2563,14 +2762,14 @@ relativeError)); static float MULReduceAll(float[] a) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MULReduceFloatMaxVectorTests(IntFunction fa) { + static void MULReduceFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2581,12 +2780,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - FloatMaxVectorTests::MULReduce, FloatMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVectorMaxTests::MULReduce, FloatVectorMaxTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2594,20 +2793,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MUL_IDENTITY; - assertEquals((float) (id * id), id, + assertEquals((float) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) (id * x), x); - assertEquals((float) (x * id), x); + assertEquals((float) (scalar_mul(id, x)), x); + assertEquals((float) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((float) (id * x), x, + assertEquals((float) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((float) (x * id), x, + assertEquals((float) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -2616,7 +2815,7 @@ relativeError)); float res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -2625,14 +2824,14 @@ relativeError)); static float MULReduceAllMasked(float[] a, boolean[] mask) { float res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MULReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2645,18 +2844,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::MULReduceMasked, FloatMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); + FloatVectorMaxTests::MULReduceMasked, FloatVectorMaxTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } static float MINReduce(float[] a, int idx) { float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2665,14 +2864,14 @@ relativeError)); static float MINReduceAll(float[] a) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MINReduceFloatMaxVectorTests(IntFunction fa) { + static void MINReduceFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2683,12 +2882,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - FloatMaxVectorTests::MINReduce, FloatMaxVectorTests::MINReduceAll); + FloatVectorMaxTests::MINReduce, FloatVectorMaxTests::MINReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2696,20 +2895,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MIN_IDENTITY; - assertEquals((float) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.min(id, x), x); - assertEquals((float) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -2718,7 +2917,7 @@ relativeError)); float res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -2727,14 +2926,14 @@ relativeError)); static float MINReduceAllMasked(float[] a, boolean[] mask) { float res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MINReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2747,18 +2946,18 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (float) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::MINReduceMasked, FloatMaxVectorTests::MINReduceAllMasked); + FloatVectorMaxTests::MINReduceMasked, FloatVectorMaxTests::MINReduceAllMasked); } static float MAXReduce(float[] a, int idx) { float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2767,14 +2966,14 @@ relativeError)); static float MAXReduceAll(float[] a) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void MAXReduceFloatMaxVectorTests(IntFunction fa) { + static void MAXReduceFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2785,12 +2984,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - FloatMaxVectorTests::MAXReduce, FloatMaxVectorTests::MAXReduceAll); + FloatVectorMaxTests::MAXReduce, FloatVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2798,20 +2997,20 @@ relativeError)); float[] a = fa.apply(SPECIES.length()); float id = MAX_IDENTITY; - assertEquals((float) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); float x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((float) Math.max(id, x), x); - assertEquals((float) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((float) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((float) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -2820,7 +3019,7 @@ relativeError)); float res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -2829,14 +3028,14 @@ relativeError)); static float MAXReduceAllMasked(float[] a, boolean[] mask) { float res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void MAXReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2849,12 +3048,12 @@ relativeError)); FloatVector av = FloatVector.fromArray(SPECIES, a, i); float v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (float) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::MAXReduceMasked, FloatMaxVectorTests::MAXReduceAllMasked); + FloatVectorMaxTests::MAXReduceMasked, FloatVectorMaxTests::MAXReduceAllMasked); } static float FIRST_NONZEROReduce(float[] a, int idx) { @@ -2876,7 +3075,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void FIRST_NONZEROReduceFloatMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); float ra = 0; @@ -2892,7 +3091,7 @@ relativeError)); } assertReductionArraysEquals(r, ra, a, - FloatMaxVectorTests::FIRST_NONZEROReduce, FloatMaxVectorTests::FIRST_NONZEROReduceAll); + FloatVectorMaxTests::FIRST_NONZEROReduce, FloatVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "floatUnaryOpProvider") @@ -2938,7 +3137,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void FIRST_NONZEROReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2956,11 +3155,11 @@ relativeError)); } assertReductionArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::FIRST_NONZEROReduceMasked, FloatMaxVectorTests::FIRST_NONZEROReduceAllMasked); + FloatVectorMaxTests::FIRST_NONZEROReduceMasked, FloatVectorMaxTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "floatBinaryOpProvider") - static void withFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -2983,7 +3182,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_DEFAULTFloatMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3000,7 +3199,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_DEFAULTMaskedFloatMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3024,7 +3223,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NEGATIVEFloatMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVEFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3041,7 +3240,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NEGATIVEMaskedFloatMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3061,11 +3260,11 @@ relativeError)); } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_FINITEFloatMaxVectorTests(IntFunction fa) { + static void IS_FINITEFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3082,7 +3281,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_FINITEMaskedFloatMaxVectorTests(IntFunction fa, + static void IS_FINITEMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3102,11 +3301,11 @@ relativeError)); } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_NANFloatMaxVectorTests(IntFunction fa) { + static void IS_NANFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3123,7 +3322,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_NANMaskedFloatMaxVectorTests(IntFunction fa, + static void IS_NANMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3143,11 +3342,11 @@ relativeError)); } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") - static void IS_INFINITEFloatMaxVectorTests(IntFunction fa) { + static void IS_INFINITEFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -3164,7 +3363,7 @@ relativeError)); } @Test(dataProvider = "floatTestOpMaskProvider") - static void IS_INFINITEMaskedFloatMaxVectorTests(IntFunction fa, + static void IS_INFINITEMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3184,7 +3383,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3203,7 +3402,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3222,7 +3421,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3245,7 +3444,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GTFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3264,7 +3463,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GTFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3287,7 +3486,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3306,7 +3505,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3325,7 +3524,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3348,7 +3547,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void NEFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NEFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3367,7 +3566,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void NEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3390,7 +3589,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LEFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LEFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3409,7 +3608,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3432,7 +3631,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void GEFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GEFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3451,7 +3650,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpMaskProvider") - static void GEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3474,7 +3673,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3484,13 +3683,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3504,13 +3703,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void LTFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTFloatVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3520,13 +3719,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void LTFloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTFloatVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3540,13 +3739,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (float)((long)b[i])))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3556,13 +3755,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3576,13 +3775,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "floatCompareOpProvider") - static void EQFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQFloatVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3592,13 +3791,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @Test(dataProvider = "floatCompareOpMaskProvider") - static void EQFloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQFloatVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3612,7 +3811,7 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (float)((long)b[i])))); } } } @@ -3622,7 +3821,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloatMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendFloatVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3638,11 +3837,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, FloatVectorMaxTests::blend); } @Test(dataProvider = "floatUnaryOpShuffleProvider") - static void RearrangeFloatMaxVectorTests(IntFunction fa, + static void RearrangeFloatVectorMaxTests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -3659,7 +3858,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpShuffleMaskProvider") - static void RearrangeFloatMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeFloatVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -3677,7 +3876,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void compressFloatMaxVectorTests(IntFunction fa, + static void compressFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3695,7 +3894,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void expandFloatMaxVectorTests(IntFunction fa, + static void expandFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3713,7 +3912,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void getFloatMaxVectorTests(IntFunction fa) { + static void getFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -3869,7 +4068,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void BroadcastFloatMaxVectorTests(IntFunction fa) { + static void BroadcastFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3883,7 +4082,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ZeroFloatMaxVectorTests(IntFunction fa) { + static void ZeroFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3908,7 +4107,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void sliceUnaryFloatMaxVectorTests(IntFunction fa) { + static void sliceUnaryFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -3919,7 +4118,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, FloatMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, FloatVectorMaxTests::sliceUnary); } static float[] sliceBinary(float[] a, float[] b, int origin, int idx) { @@ -3936,7 +4135,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void sliceBinaryFloatMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryFloatVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -3949,7 +4148,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, FloatMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, FloatVectorMaxTests::sliceBinary); } static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) { @@ -3966,7 +4165,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void sliceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -3983,7 +4182,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, mask, FloatMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, FloatVectorMaxTests::slice); } static float[] unsliceUnary(float[] a, int origin, int idx) { @@ -4000,7 +4199,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void unsliceUnaryFloatMaxVectorTests(IntFunction fa) { + static void unsliceUnaryFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -4011,7 +4210,7 @@ relativeError)); } } - assertArraysEquals(r, a, origin, FloatMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, FloatVectorMaxTests::unsliceUnary); } static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) { @@ -4037,7 +4236,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpProvider") - static void unsliceBinaryFloatMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryFloatVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -4051,7 +4250,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, FloatMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, FloatVectorMaxTests::unsliceBinary); } static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) { @@ -4091,7 +4290,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void unsliceFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4108,19 +4307,19 @@ relativeError)); } } - assertArraysEquals(r, a, b, origin, part, mask, FloatMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, FloatVectorMaxTests::unslice); } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINFloatMaxVectorTests(IntFunction fa) { + static void SINFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4131,19 +4330,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::SIN, FloatMaxVectorTests::strictSIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::SIN, FloatVectorMaxTests::strictSIN); } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPFloatMaxVectorTests(IntFunction fa) { + static void EXPFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4154,19 +4353,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::EXP, FloatMaxVectorTests::strictEXP); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::EXP, FloatVectorMaxTests::strictEXP); } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG1PFloatMaxVectorTests(IntFunction fa) { + static void LOG1PFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4177,19 +4376,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG1P, FloatMaxVectorTests::strictLOG1P); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::LOG1P, FloatVectorMaxTests::strictLOG1P); } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOGFloatMaxVectorTests(IntFunction fa) { + static void LOGFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4200,19 +4399,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG, FloatMaxVectorTests::strictLOG); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::LOG, FloatVectorMaxTests::strictLOG); } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void LOG10FloatMaxVectorTests(IntFunction fa) { + static void LOG10FloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4223,19 +4422,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::LOG10, FloatMaxVectorTests::strictLOG10); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::LOG10, FloatVectorMaxTests::strictLOG10); } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void EXPM1FloatMaxVectorTests(IntFunction fa) { + static void EXPM1FloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4246,19 +4445,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::EXPM1, FloatMaxVectorTests::strictEXPM1); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::EXPM1, FloatVectorMaxTests::strictEXPM1); } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSFloatMaxVectorTests(IntFunction fa) { + static void COSFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4269,19 +4468,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::COS, FloatMaxVectorTests::strictCOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::COS, FloatVectorMaxTests::strictCOS); } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANFloatMaxVectorTests(IntFunction fa) { + static void TANFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4292,19 +4491,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::TAN, FloatMaxVectorTests::strictTAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::TAN, FloatVectorMaxTests::strictTAN); } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SINHFloatMaxVectorTests(IntFunction fa) { + static void SINHFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4315,19 +4514,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::SINH, FloatMaxVectorTests::strictSINH); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::SINH, FloatVectorMaxTests::strictSINH); } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void COSHFloatMaxVectorTests(IntFunction fa) { + static void COSHFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4338,19 +4537,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::COSH, FloatMaxVectorTests::strictCOSH); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::COSH, FloatVectorMaxTests::strictCOSH); } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void TANHFloatMaxVectorTests(IntFunction fa) { + static void TANHFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4361,19 +4560,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::TANH, FloatMaxVectorTests::strictTANH); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::TANH, FloatVectorMaxTests::strictTANH); } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ASINFloatMaxVectorTests(IntFunction fa) { + static void ASINFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4384,19 +4583,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ASIN, FloatMaxVectorTests::strictASIN); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::ASIN, FloatVectorMaxTests::strictASIN); } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ACOSFloatMaxVectorTests(IntFunction fa) { + static void ACOSFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4407,19 +4606,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ACOS, FloatMaxVectorTests::strictACOS); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::ACOS, FloatVectorMaxTests::strictACOS); } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ATANFloatMaxVectorTests(IntFunction fa) { + static void ATANFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4430,19 +4629,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::ATAN, FloatMaxVectorTests::strictATAN); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::ATAN, FloatVectorMaxTests::strictATAN); } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void CBRTFloatMaxVectorTests(IntFunction fa) { + static void CBRTFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4453,19 +4652,19 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, FloatMaxVectorTests::CBRT, FloatMaxVectorTests::strictCBRT); + assertArraysEqualsWithinOneUlp(r, a, FloatVectorMaxTests::CBRT, FloatVectorMaxTests::strictCBRT); } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void HYPOTFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void HYPOTFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4478,20 +4677,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::HYPOT, FloatMaxVectorTests::strictHYPOT); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::HYPOT, FloatVectorMaxTests::strictHYPOT); } static float POW(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictPOW(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void POWFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4504,20 +4703,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::POW, FloatVectorMaxTests::strictPOW); } static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void powFloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4530,20 +4729,20 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::pow, FloatVectorMaxTests::strictpow); } static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") - static void ATAN2FloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ATAN2FloatVectorMaxTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4556,12 +4755,12 @@ relativeError)); } } - assertArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::ATAN2, FloatMaxVectorTests::strictATAN2); + assertArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::ATAN2, FloatVectorMaxTests::strictATAN2); } @Test(dataProvider = "floatBinaryOpProvider") - static void POWFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void POWFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4571,12 +4770,12 @@ relativeError)); av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::POW, FloatMaxVectorTests::strictPOW); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::POW, FloatVectorMaxTests::strictPOW); } @Test(dataProvider = "floatBinaryOpProvider") - static void powFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void powFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4586,20 +4785,20 @@ relativeError)); av.pow(b[i]).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatMaxVectorTests::pow, FloatMaxVectorTests::strictpow); + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, FloatVectorMaxTests::pow, FloatVectorMaxTests::strictpow); } static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4614,11 +4813,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4631,11 +4830,11 @@ relativeError)); av.fma(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, FloatMaxVectorTests::fma); + assertArraysEquals(r, a, b, c, FloatVectorMaxTests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FMAFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4653,11 +4852,11 @@ relativeError)); } } - assertArraysEquals(r, a, b, c, mask, FloatMaxVectorTests::FMA); + assertArraysEquals(r, a, b, c, mask, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4668,11 +4867,11 @@ relativeError)); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloatMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4683,11 +4882,11 @@ relativeError)); FloatVector cv = FloatVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4702,11 +4901,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, FloatMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, c, mask, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloatMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4721,11 +4920,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatMaxVectorTests::FMA); + assertAltBroadcastArraysEquals(r, a, b, c, mask, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void FMAFloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void FMAFloatVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4736,11 +4935,11 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVectorMaxTests::FMA); } @Test(dataProvider = "floatTernaryOpProvider") - static void fmaFloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void fmaFloatVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); @@ -4751,11 +4950,11 @@ relativeError)); av.fma(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, FloatMaxVectorTests::fma); + assertDoubleBroadcastArraysEquals(r, a, b, c, FloatVectorMaxTests::fma); } @Test(dataProvider = "floatTernaryOpMaskProvider") - static void FMAFloatMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void FMAFloatVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -4769,19 +4968,19 @@ relativeError)); av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatMaxVectorTests::FMA); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FloatVectorMaxTests::FMA); } static float NEG(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } static float neg(float a) { - return (float)(-((float)a)); + return (float)(scalar_neg((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void NEGFloatMaxVectorTests(IntFunction fa) { + static void NEGFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4792,11 +4991,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::NEG); + assertArraysEquals(r, a, FloatVectorMaxTests::NEG); } @Test(dataProvider = "floatUnaryOpProvider") - static void negFloatMaxVectorTests(IntFunction fa) { + static void negFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4807,11 +5006,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::neg); + assertArraysEquals(r, a, FloatVectorMaxTests::neg); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void NEGMaskedFloatMaxVectorTests(IntFunction fa, + static void NEGMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4825,19 +5024,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, FloatMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, FloatVectorMaxTests::NEG); } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void ABSFloatMaxVectorTests(IntFunction fa) { + static void ABSFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4848,11 +5047,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::ABS); + assertArraysEquals(r, a, FloatVectorMaxTests::ABS); } @Test(dataProvider = "floatUnaryOpProvider") - static void absFloatMaxVectorTests(IntFunction fa) { + static void absFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4863,11 +5062,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::abs); + assertArraysEquals(r, a, FloatVectorMaxTests::abs); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ABSMaskedFloatMaxVectorTests(IntFunction fa, + static void ABSMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4881,19 +5080,19 @@ relativeError)); } } - assertArraysEquals(r, a, mask, FloatMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, FloatVectorMaxTests::ABS); } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") - static void SQRTFloatMaxVectorTests(IntFunction fa) { + static void SQRTFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4904,11 +5103,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::SQRT); + assertArraysEquals(r, a, FloatVectorMaxTests::SQRT); } @Test(dataProvider = "floatUnaryOpProvider") - static void sqrtFloatMaxVectorTests(IntFunction fa) { + static void sqrtFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4919,11 +5118,11 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::sqrt); + assertArraysEquals(r, a, FloatVectorMaxTests::sqrt); } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void SQRTMaskedFloatMaxVectorTests(IntFunction fa, + static void SQRTMaskedFloatVectorMaxTests(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); @@ -4937,7 +5136,7 @@ relativeError)); } } - assertArraysEquals(r, a, mask, FloatMaxVectorTests::SQRT); + assertArraysEquals(r, a, mask, FloatVectorMaxTests::SQRT); } static boolean band(boolean a, boolean b) { @@ -4945,7 +5144,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4958,7 +5157,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::band); + assertArraysEquals(r, a, b, FloatVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -4966,7 +5165,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -4979,7 +5178,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::bor); + assertArraysEquals(r, a, b, FloatVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -4987,7 +5186,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5000,7 +5199,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::bxor); + assertArraysEquals(r, a, b, FloatVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -5008,7 +5207,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5021,7 +5220,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, FloatVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -5029,7 +5228,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5042,7 +5241,7 @@ relativeError)); } } - assertArraysEquals(r, a, b, FloatMaxVectorTests::beq); + assertArraysEquals(r, a, b, FloatVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -5050,7 +5249,7 @@ relativeError)); } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotFloatMaxVectorTests(IntFunction fa) { + static void masknotFloatVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -5061,7 +5260,7 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::unot); + assertArraysEquals(r, a, FloatVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -5078,7 +5277,7 @@ relativeError)); } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongFloatMaxVectorTests(IntFunction fa) { + static void maskFromToLongFloatVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5092,7 +5291,7 @@ relativeError)); } @Test(dataProvider = "floatCompareOpProvider") - static void ltFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltFloatVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5102,13 +5301,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "floatCompareOpProvider") - static void eqFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqFloatVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5118,13 +5317,13 @@ relativeError)); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "floattoIntUnaryOpProvider") - static void toIntArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5135,7 +5334,7 @@ relativeError)); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void toLongArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5146,7 +5345,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toDoubleArrayFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5157,7 +5356,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void toStringFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5170,7 +5369,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpProvider") - static void hashCodeFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5187,7 +5386,7 @@ relativeError)); static long ADDReduceLong(float[] a, int idx) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -5196,14 +5395,14 @@ relativeError)); static long ADDReduceAllLong(float[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((float)res, (float)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "floatUnaryOpProvider") - static void ADDReduceLongFloatMaxVectorTests(IntFunction fa) { + static void ADDReduceLongFloatVectorMaxTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -5214,19 +5413,20 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEquals(r, ra, a, - FloatMaxVectorTests::ADDReduceLong, FloatMaxVectorTests::ADDReduceAllLong); + FloatVectorMaxTests::ADDReduceLong, FloatVectorMaxTests::ADDReduceAllLong); } static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -5235,14 +5435,14 @@ relativeError)); static long ADDReduceAllLongMasked(float[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((float)res, (float)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "floatUnaryOpMaskProvider") - static void ADDReduceLongFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongFloatVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5255,16 +5455,16 @@ relativeError)); } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((float)ra, (float)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - FloatMaxVectorTests::ADDReduceLongMasked, FloatMaxVectorTests::ADDReduceAllLongMasked); + FloatVectorMaxTests::ADDReduceLongMasked, FloatVectorMaxTests::ADDReduceAllLongMasked); } @Test(dataProvider = "floattoLongUnaryOpProvider") - static void BroadcastLongFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongFloatVectorMaxTestsSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = new float[a.length]; @@ -5275,7 +5475,7 @@ relativeError)); } @Test(dataProvider = "floatBinaryOpMaskProvider") - static void blendFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendFloatVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); @@ -5289,12 +5489,12 @@ relativeError)); av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, FloatMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, FloatVectorMaxTests::blend); } @Test(dataProvider = "floatUnaryOpSelectFromProvider") - static void SelectFromFloatMaxVectorTests(IntFunction fa, + static void SelectFromFloatVectorMaxTests(IntFunction fa, BiFunction fs) { float[] a = fa.apply(SPECIES.length()); float[] order = fs.apply(a.length, SPECIES.length()); @@ -5310,7 +5510,7 @@ relativeError)); } @Test(dataProvider = "floatSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorFloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorFloatVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] idx = fc.apply(SPECIES.length()); @@ -5328,7 +5528,7 @@ relativeError)); } @Test(dataProvider = "floatUnaryOpSelectFromMaskProvider") - static void SelectFromFloatMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromFloatVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -5347,7 +5547,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousFloatMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousFloatVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5363,7 +5563,7 @@ relativeError)); } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringFloatMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringFloatVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5377,7 +5577,7 @@ relativeError)); } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsFloatMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsFloatVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -5391,7 +5591,7 @@ relativeError)); } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsFloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsFloatVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -5407,7 +5607,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskHashCodeFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeFloatVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -5429,7 +5629,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskTrueCountFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountFloatVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5440,7 +5640,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, FloatVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -5454,7 +5654,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskLastTrueFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueFloatVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5465,7 +5665,7 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, FloatVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -5479,7 +5679,7 @@ relativeError)); } @Test(dataProvider = "maskProvider") - static void maskFirstTrueFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueFloatVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5490,11 +5690,11 @@ relativeError)); } } - assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, FloatVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressFloatMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressFloatVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -5522,7 +5722,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeFloatMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeFloatVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5536,7 +5736,7 @@ relativeError)); } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongFloatMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongFloatVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -5563,14 +5763,14 @@ relativeError)); } @Test(dataProvider = "lengthProvider") - static void loopBoundFloatMaxVectorTestsSmokeTest(int length) { + static void loopBoundFloatVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongFloatMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongFloatVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -5578,21 +5778,21 @@ relativeError)); } @Test - static void ElementSizeFloatMaxVectorTestsSmokeTest() { + static void ElementSizeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Float.SIZE); } @Test - static void VectorShapeFloatMaxVectorTestsSmokeTest() { + static void VectorShapeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesFloatMaxVectorTestsSmokeTest() { + static void ShapeWithLanesFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(float.class); @@ -5600,32 +5800,32 @@ relativeError)); } @Test - static void ElementTypeFloatMaxVectorTestsSmokeTest() { + static void ElementTypeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementType() == float.class); } @Test - static void SpeciesElementSizeFloatMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().elementSize() == Float.SIZE); } @Test - static void VectorTypeFloatMaxVectorTestsSmokeTest() { + static void VectorTypeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesFloatMaxVectorTestsSmokeTest() { + static void WithLanesFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(float.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeFloatMaxVectorTestsSmokeTest() { + static void WithShapeFloatVectorMaxTestsSmokeTest() { FloatVector av = FloatVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -5633,7 +5833,7 @@ relativeError)); } @Test - static void MaskAllTrueFloatMaxVectorTestsSmokeTest() { + static void MaskAllTrueFloatVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/IntVector128LoadStoreTests.java index f6e640e9615..dd865141e08 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Int128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation IntVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Int128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class IntVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = IntVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/IntVector128Tests.java similarity index 87% rename from test/jdk/jdk/incubator/vector/Int512VectorTests.java rename to test/jdk/jdk/incubator/vector/IntVector128Tests.java index d2eda11e6f5..d62f5d8df00 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,10 +56,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Int512VectorTests extends AbstractVectorTest { +public class IntVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = - IntVector.SPECIES_512; + IntVector.SPECIES_128; static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); static void assertEquals(int actual, int expected) { @@ -121,7 +121,7 @@ public class Int512VectorTests extends AbstractVectorTest { private static final int UMIN_IDENTITY = (int)-1; // Maximum unsigned value private static final int XOR_IDENTITY = (int)0; - static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); static void assertArraysStrictlyEquals(int[] r, int[] a) { for (int i = 0; i < a.length; i++) { @@ -1531,6 +1531,59 @@ public class Int512VectorTests extends AbstractVectorTest { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1547,9 +1600,6 @@ public class Int512VectorTests extends AbstractVectorTest { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1663,11 +1713,11 @@ public class Int512VectorTests extends AbstractVectorTest { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1680,15 +1730,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::ADD); + assertArraysEquals(r, a, b, IntVector128Tests::ADD); } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt512VectorTests(IntFunction fa, IntFunction fb) { + static void addIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1699,11 +1749,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::add); + assertArraysEquals(r, a, b, IntVector128Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1719,11 +1769,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntVector128Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1737,15 +1787,15 @@ public class Int512VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int512VectorTests::add); + assertArraysEquals(r, a, b, mask, IntVector128Tests::add); } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void SUBInt512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1758,15 +1808,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::SUB); + assertArraysEquals(r, a, b, IntVector128Tests::SUB); } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt512VectorTests(IntFunction fa, IntFunction fb) { + static void subIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1777,11 +1827,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::sub); + assertArraysEquals(r, a, b, IntVector128Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void SUBInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1797,11 +1847,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntVector128Tests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1815,15 +1865,15 @@ public class Int512VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int512VectorTests::sub); + assertArraysEquals(r, a, b, mask, IntVector128Tests::sub); } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MULInt512VectorTests(IntFunction fa, IntFunction fb) { + static void MULIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1836,15 +1886,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::MUL); + assertArraysEquals(r, a, b, IntVector128Tests::MUL); } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt512VectorTests(IntFunction fa, IntFunction fb) { + static void mulIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1855,11 +1905,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::mul); + assertArraysEquals(r, a, b, IntVector128Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void MULInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1875,11 +1925,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntVector128Tests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1893,7 +1943,7 @@ public class Int512VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int512VectorTests::mul); + assertArraysEquals(r, a, b, mask, IntVector128Tests::mul); } static int DIV(int a, int b) { @@ -1901,7 +1951,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void DIVInt512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1916,7 +1966,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::DIV); + assertArraysEquals(r, a, b, IntVector128Tests::DIV); } static int div(int a, int b) { @@ -1924,7 +1974,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void divInt512VectorTests(IntFunction fa, IntFunction fb) { + static void divIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1939,11 +1989,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::div); + assertArraysEquals(r, a, b, IntVector128Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void DIVInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1961,11 +2011,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntVector128Tests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1983,15 +2033,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::div); + assertArraysEquals(r, a, b, mask, IntVector128Tests::div); } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void FIRST_NONZEROInt512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2004,11 +2054,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, IntVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void FIRST_NONZEROInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2024,7 +2074,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntVector128Tests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -2032,7 +2082,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ANDIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2045,7 +2095,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::AND); + assertArraysEquals(r, a, b, IntVector128Tests::AND); } static int and(int a, int b) { @@ -2053,7 +2103,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void andInt512VectorTests(IntFunction fa, IntFunction fb) { + static void andIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2064,11 +2114,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::and); + assertArraysEquals(r, a, b, IntVector128Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2084,7 +2134,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::AND); + assertArraysEquals(r, a, b, mask, IntVector128Tests::AND); } static int AND_NOT(int a, int b) { @@ -2092,7 +2142,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void AND_NOTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2105,11 +2155,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntVector128Tests::AND_NOT); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void AND_NOTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2125,7 +2175,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, IntVector128Tests::AND_NOT); } static int OR(int a, int b) { @@ -2133,7 +2183,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ORIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2146,7 +2196,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::OR); + assertArraysEquals(r, a, b, IntVector128Tests::OR); } static int or(int a, int b) { @@ -2154,7 +2204,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void orInt512VectorTests(IntFunction fa, IntFunction fb) { + static void orIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2165,11 +2215,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::or); + assertArraysEquals(r, a, b, IntVector128Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2185,7 +2235,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::OR); + assertArraysEquals(r, a, b, mask, IntVector128Tests::OR); } static int XOR(int a, int b) { @@ -2193,7 +2243,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void XORInt512VectorTests(IntFunction fa, IntFunction fb) { + static void XORIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2206,11 +2256,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::XOR); + assertArraysEquals(r, a, b, IntVector128Tests::XOR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void XORInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2226,7 +2276,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntVector128Tests::XOR); } static int COMPRESS_BITS(int a, int b) { @@ -2234,7 +2284,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void COMPRESS_BITSInt512VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2247,11 +2297,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, IntVector128Tests::COMPRESS_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void COMPRESS_BITSInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2267,7 +2317,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, IntVector128Tests::COMPRESS_BITS); } static int EXPAND_BITS(int a, int b) { @@ -2275,7 +2325,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void EXPAND_BITSInt512VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2288,11 +2338,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, IntVector128Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void EXPAND_BITSInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2308,11 +2358,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, IntVector128Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2322,11 +2372,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2339,11 +2389,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::add); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2353,11 +2403,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2370,11 +2420,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::sub); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2434,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2401,11 +2451,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::mul); } @Test(dataProvider = "intBinaryOpProvider") - static void divInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2436,11 +2486,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::div); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2450,11 +2500,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void orInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2464,11 +2514,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2481,11 +2531,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2495,11 +2545,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void andInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2509,11 +2559,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2526,11 +2576,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntVector128Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2540,11 +2590,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntVector128Tests::OR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2557,11 +2607,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector128Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDIntVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2571,11 +2621,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntVector128Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDIntVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2588,7 +2638,7 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector128Tests::ADD); } static int LSHL(int a, int b) { @@ -2596,7 +2646,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2609,11 +2659,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::LSHL); + assertArraysEquals(r, a, b, IntVector128Tests::LSHL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2629,7 +2679,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, IntVector128Tests::LSHL); } static int ASHR(int a, int b) { @@ -2637,7 +2687,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2650,11 +2700,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::ASHR); + assertArraysEquals(r, a, b, IntVector128Tests::ASHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2670,7 +2720,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, IntVector128Tests::ASHR); } static int LSHR(int a, int b) { @@ -2678,7 +2728,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2691,11 +2741,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::LSHR); + assertArraysEquals(r, a, b, IntVector128Tests::LSHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2711,7 +2761,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, IntVector128Tests::LSHR); } static int LSHL_unary(int a, int b) { @@ -2719,7 +2769,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLIntVector128TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2731,11 +2781,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntVector128Tests::LSHL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2750,7 +2800,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector128Tests::LSHL_unary); } static int LSHR_unary(int a, int b) { @@ -2758,7 +2808,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRIntVector128TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2770,11 +2820,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntVector128Tests::LSHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2789,7 +2839,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector128Tests::LSHR_unary); } static int ASHR_unary(int a, int b) { @@ -2797,7 +2847,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRIntVector128TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2809,11 +2859,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntVector128Tests::ASHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2828,7 +2878,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector128Tests::ASHR_unary); } static int ROR(int a, int b) { @@ -2836,7 +2886,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt512VectorTests(IntFunction fa, IntFunction fb) { + static void RORIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2849,11 +2899,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::ROR); + assertArraysEquals(r, a, b, IntVector128Tests::ROR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2869,7 +2919,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::ROR); + assertArraysEquals(r, a, b, mask, IntVector128Tests::ROR); } static int ROL(int a, int b) { @@ -2877,7 +2927,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ROLIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2890,11 +2940,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::ROL); + assertArraysEquals(r, a, b, IntVector128Tests::ROL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2910,7 +2960,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::ROL); + assertArraysEquals(r, a, b, mask, IntVector128Tests::ROL); } static int ROR_unary(int a, int b) { @@ -2918,7 +2968,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORIntVector128TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2930,11 +2980,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, IntVector128Tests::ROR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORIntVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2949,7 +2999,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector128Tests::ROR_unary); } static int ROL_unary(int a, int b) { @@ -2957,7 +3007,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLIntVector128TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2969,11 +3019,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, IntVector128Tests::ROL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2988,14 +3038,14 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector128Tests::ROL_unary); } static int LSHR_binary_const(int a) { return (int)((a >>> CONST_SHIFT)); } @Test(dataProvider = "intUnaryOpProvider") - static void LSHRInt512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRIntVector128TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3006,11 +3056,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, IntVector128Tests::LSHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHRInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRIntVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3024,7 +3074,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector128Tests::LSHR_binary_const); } static int LSHL_binary_const(int a) { @@ -3032,7 +3082,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LSHLInt512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLIntVector128TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3043,11 +3093,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, IntVector128Tests::LSHL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHLInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLIntVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3061,7 +3111,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector128Tests::LSHL_binary_const); } static int ASHR_binary_const(int a) { @@ -3069,7 +3119,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ASHRInt512VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRIntVector128TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3080,11 +3130,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, IntVector128Tests::ASHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ASHRInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRIntVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3098,7 +3148,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector128Tests::ASHR_binary_const); } static int ROR_binary_const(int a) { @@ -3106,7 +3156,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void RORInt512VectorTestsScalarShiftConst(IntFunction fa) { + static void RORIntVector128TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3117,11 +3167,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, IntVector128Tests::ROR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void RORInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORIntVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3135,7 +3185,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector128Tests::ROR_binary_const); } static int ROL_binary_const(int a) { @@ -3143,7 +3193,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ROLInt512VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLIntVector128TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3154,11 +3204,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, IntVector128Tests::ROL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ROLInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLIntVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3172,14 +3222,14 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector128Tests::ROL_binary_const); } static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MINInt512VectorTestsWithMemOp(IntFunction fa) { + static void MINIntVector128TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int512VectorTests::MIN); + assertArraysEquals(r, a, (int)10, IntVector128Tests::MIN); } static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void minInt512VectorTestsWithMemOp(IntFunction fa) { + static void minIntVector128TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int512VectorTests::min); + assertArraysEquals(r, a, (int)10, IntVector128Tests::min); } static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINIntVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,13 +3276,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int512VectorTests::MIN); + assertArraysEquals(r, a, (int)10, mask, IntVector128Tests::MIN); } static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MAXInt512VectorTestsWithMemOp(IntFunction fa) { + static void MAXIntVector128TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3243,13 +3293,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int512VectorTests::MAX); + assertArraysEquals(r, a, (int)10, IntVector128Tests::MAX); } static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void maxInt512VectorTestsWithMemOp(IntFunction fa) { + static void maxIntVector128TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3260,13 +3310,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int512VectorTests::max); + assertArraysEquals(r, a, (int)10, IntVector128Tests::max); } static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXIntVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3279,15 +3329,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int512VectorTests::MAX); + assertArraysEquals(r, a, (int)10, mask, IntVector128Tests::MAX); } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt512VectorTests(IntFunction fa, IntFunction fb) { + static void MINIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3300,15 +3350,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::MIN); + assertArraysEquals(r, a, b, IntVector128Tests::MIN); } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt512VectorTests(IntFunction fa, IntFunction fb) { + static void minIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3319,15 +3369,15 @@ public class Int512VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::min); + assertArraysEquals(r, a, b, IntVector128Tests::min); } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3340,15 +3390,15 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::MAX); + assertArraysEquals(r, a, b, IntVector128Tests::MAX); } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maxIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3359,7 +3409,7 @@ public class Int512VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int512VectorTests::max); + assertArraysEquals(r, a, b, IntVector128Tests::max); } static int UMIN(int a, int b) { @@ -3367,7 +3417,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMINInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UMINIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3380,11 +3430,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::UMIN); + assertArraysEquals(r, a, b, IntVector128Tests::UMIN); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMINInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3400,7 +3450,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, IntVector128Tests::UMIN); } static int UMAX(int a, int b) { @@ -3408,7 +3458,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMAXInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3421,11 +3471,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::UMAX); + assertArraysEquals(r, a, b, IntVector128Tests::UMAX); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMAXInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3441,7 +3491,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, IntVector128Tests::UMAX); } static int SADD(int a, int b) { @@ -3449,7 +3499,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SADDInt512VectorTests(IntFunction fa, IntFunction fb) { + static void SADDIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3462,11 +3512,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::SADD); + assertArraysEquals(r, a, b, IntVector128Tests::SADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SADDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3482,7 +3532,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::SADD); + assertArraysEquals(r, a, b, mask, IntVector128Tests::SADD); } static int SSUB(int a, int b) { @@ -3490,7 +3540,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SSUBInt512VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3503,11 +3553,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::SSUB); + assertArraysEquals(r, a, b, IntVector128Tests::SSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SSUBInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3523,7 +3573,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, IntVector128Tests::SSUB); } static int SUADD(int a, int b) { @@ -3531,7 +3581,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUADDInt512VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3544,11 +3594,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::SUADD); + assertArraysEquals(r, a, b, IntVector128Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUADDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3564,7 +3614,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, IntVector128Tests::SUADD); } static int SUSUB(int a, int b) { @@ -3572,7 +3622,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUSUBInt512VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3585,11 +3635,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::SUSUB); + assertArraysEquals(r, a, b, IntVector128Tests::SUSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUSUBInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3605,11 +3655,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, IntVector128Tests::SUSUB); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3619,11 +3669,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::MIN); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3633,11 +3683,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::min); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3647,11 +3697,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::MAX); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3661,10 +3711,10 @@ public class Int512VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntVector128Tests::max); } @Test(dataProvider = "intSaturatingBinaryOpAssocProvider") - static void SUADDAssocInt512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocIntVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -3681,11 +3731,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Int512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, IntVector128Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3706,13 +3756,13 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Int512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntVector128Tests::SUADD); } static int ANDReduce(int[] a, int idx) { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3721,14 +3771,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ANDReduceAll(int[] a) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ANDReduceInt512VectorTests(IntFunction fa) { + static void ANDReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3739,12 +3789,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::ANDReduce, Int512VectorTests::ANDReduceAll); + IntVector128Tests::ANDReduce, IntVector128Tests::ANDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3752,20 +3802,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = AND_IDENTITY; - assertEquals((int) (id & id), id, + assertEquals((int) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id & x), x); - assertEquals((int) (x & id), x); + assertEquals((int) (scalar_and(id, x)), x); + assertEquals((int) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id & x), x, + assertEquals((int) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x & id), x, + assertEquals((int) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3774,7 +3824,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3783,14 +3833,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ANDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3803,18 +3853,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::ANDReduceMasked, Int512VectorTests::ANDReduceAllMasked); + IntVector128Tests::ANDReduceMasked, IntVector128Tests::ANDReduceAllMasked); } static int ORReduce(int[] a, int idx) { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3823,14 +3873,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ORReduceAll(int[] a) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ORReduceInt512VectorTests(IntFunction fa) { + static void ORReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3841,12 +3891,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::ORReduce, Int512VectorTests::ORReduceAll); + IntVector128Tests::ORReduce, IntVector128Tests::ORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3854,20 +3904,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = OR_IDENTITY; - assertEquals((int) (id | id), id, + assertEquals((int) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id | x), x); - assertEquals((int) (x | id), x); + assertEquals((int) (scalar_or(id, x)), x); + assertEquals((int) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id | x), x, + assertEquals((int) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x | id), x, + assertEquals((int) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3876,7 +3926,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3885,14 +3935,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3905,18 +3955,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::ORReduceMasked, Int512VectorTests::ORReduceAllMasked); + IntVector128Tests::ORReduceMasked, IntVector128Tests::ORReduceAllMasked); } static int XORReduce(int[] a, int idx) { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3925,14 +3975,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int XORReduceAll(int[] a) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void XORReduceInt512VectorTests(IntFunction fa) { + static void XORReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3943,12 +3993,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::XORReduce, Int512VectorTests::XORReduceAll); + IntVector128Tests::XORReduce, IntVector128Tests::XORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3956,20 +4006,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = XOR_IDENTITY; - assertEquals((int) (id ^ id), id, + assertEquals((int) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id ^ x), x); - assertEquals((int) (x ^ id), x); + assertEquals((int) (scalar_xor(id, x)), x); + assertEquals((int) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id ^ x), x, + assertEquals((int) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x ^ id), x, + assertEquals((int) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3978,7 +4028,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3987,14 +4037,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void XORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4007,18 +4057,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::XORReduceMasked, Int512VectorTests::XORReduceAllMasked); + IntVector128Tests::XORReduceMasked, IntVector128Tests::XORReduceAllMasked); } static int ADDReduce(int[] a, int idx) { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4027,14 +4077,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ADDReduceAll(int[] a) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceInt512VectorTests(IntFunction fa) { + static void ADDReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4045,12 +4095,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::ADDReduce, Int512VectorTests::ADDReduceAll); + IntVector128Tests::ADDReduce, IntVector128Tests::ADDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4058,20 +4108,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = ADD_IDENTITY; - assertEquals((int) (id + id), id, + assertEquals((int) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id + x), x); - assertEquals((int) (x + id), x); + assertEquals((int) (scalar_add(id, x)), x); + assertEquals((int) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id + x), x, + assertEquals((int) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x + id), x, + assertEquals((int) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4080,7 +4130,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4089,14 +4139,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int ADDReduceAllMasked(int[] a, boolean[] mask) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4109,18 +4159,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::ADDReduceMasked, Int512VectorTests::ADDReduceAllMasked); + IntVector128Tests::ADDReduceMasked, IntVector128Tests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4129,14 +4179,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MULReduceAll(int[] a) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MULReduceInt512VectorTests(IntFunction fa) { + static void MULReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4147,12 +4197,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::MULReduce, Int512VectorTests::MULReduceAll); + IntVector128Tests::MULReduce, IntVector128Tests::MULReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4160,20 +4210,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MUL_IDENTITY; - assertEquals((int) (id * id), id, + assertEquals((int) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id * x), x); - assertEquals((int) (x * id), x); + assertEquals((int) (scalar_mul(id, x)), x); + assertEquals((int) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id * x), x, + assertEquals((int) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x * id), x, + assertEquals((int) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4182,7 +4232,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4191,14 +4241,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MULReduceAllMasked(int[] a, boolean[] mask) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MULReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4211,18 +4261,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::MULReduceMasked, Int512VectorTests::MULReduceAllMasked); + IntVector128Tests::MULReduceMasked, IntVector128Tests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4231,14 +4281,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MINReduceAll(int[] a) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MINReduceInt512VectorTests(IntFunction fa) { + static void MINReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4249,12 +4299,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::MINReduce, Int512VectorTests::MINReduceAll); + IntVector128Tests::MINReduce, IntVector128Tests::MINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4262,20 +4312,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MIN_IDENTITY; - assertEquals((int) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.min(id, x), x); - assertEquals((int) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4284,7 +4334,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4293,14 +4343,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MINReduceAllMasked(int[] a, boolean[] mask) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4313,18 +4363,18 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::MINReduceMasked, Int512VectorTests::MINReduceAllMasked); + IntVector128Tests::MINReduceMasked, IntVector128Tests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4333,14 +4383,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MAXReduceAll(int[] a) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MAXReduceInt512VectorTests(IntFunction fa) { + static void MAXReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4351,12 +4401,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::MAXReduce, Int512VectorTests::MAXReduceAll); + IntVector128Tests::MAXReduce, IntVector128Tests::MAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4364,20 +4414,20 @@ public class Int512VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MAX_IDENTITY; - assertEquals((int) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.max(id, x), x); - assertEquals((int) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4386,7 +4436,7 @@ public class Int512VectorTests extends AbstractVectorTest { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4395,14 +4445,14 @@ public class Int512VectorTests extends AbstractVectorTest { static int MAXReduceAllMasked(int[] a, boolean[] mask) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4415,12 +4465,12 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::MAXReduceMasked, Int512VectorTests::MAXReduceAllMasked); + IntVector128Tests::MAXReduceMasked, IntVector128Tests::MAXReduceAllMasked); } static int UMINReduce(int[] a, int idx) { @@ -4442,7 +4492,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMINReduceInt512VectorTests(IntFunction fa) { + static void UMINReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4458,7 +4508,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::UMINReduce, Int512VectorTests::UMINReduceAll); + IntVector128Tests::UMINReduce, IntVector128Tests::UMINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4504,7 +4554,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4522,7 +4572,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::UMINReduceMasked, Int512VectorTests::UMINReduceAllMasked); + IntVector128Tests::UMINReduceMasked, IntVector128Tests::UMINReduceAllMasked); } static int UMAXReduce(int[] a, int idx) { @@ -4544,7 +4594,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMAXReduceInt512VectorTests(IntFunction fa) { + static void UMAXReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4560,7 +4610,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::UMAXReduce, Int512VectorTests::UMAXReduceAll); + IntVector128Tests::UMAXReduce, IntVector128Tests::UMAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4606,7 +4656,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4624,7 +4674,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::UMAXReduceMasked, Int512VectorTests::UMAXReduceAllMasked); + IntVector128Tests::UMAXReduceMasked, IntVector128Tests::UMAXReduceAllMasked); } static int FIRST_NONZEROReduce(int[] a, int idx) { @@ -4646,7 +4696,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void FIRST_NONZEROReduceInt512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4662,7 +4712,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::FIRST_NONZEROReduce, Int512VectorTests::FIRST_NONZEROReduceAll); + IntVector128Tests::FIRST_NONZEROReduce, IntVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4708,7 +4758,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void FIRST_NONZEROReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4726,7 +4776,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::FIRST_NONZEROReduceMasked, Int512VectorTests::FIRST_NONZEROReduceAllMasked); + IntVector128Tests::FIRST_NONZEROReduceMasked, IntVector128Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4739,7 +4789,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueInt512VectorTests(IntFunction fm) { + static void anyTrueIntVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4750,7 +4800,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntVector128Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4763,7 +4813,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueInt512VectorTests(IntFunction fm) { + static void allTrueIntVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4774,7 +4824,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntVector128Tests::allTrue); } static int SUADDReduce(int[] a, int idx) { @@ -4796,7 +4846,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingUnaryOpProvider") - static void SUADDReduceInt512VectorTests(IntFunction fa) { + static void SUADDReduceIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4812,7 +4862,7 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int512VectorTests::SUADDReduce, Int512VectorTests::SUADDReduceAll); + IntVector128Tests::SUADDReduce, IntVector128Tests::SUADDReduceAll); } @Test(dataProvider = "intSaturatingUnaryOpProvider") @@ -4857,7 +4907,7 @@ public class Int512VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "intSaturatingUnaryOpMaskProvider") - static void SUADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4875,11 +4925,11 @@ public class Int512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::SUADDReduceMasked, Int512VectorTests::SUADDReduceAllMasked); + IntVector128Tests::SUADDReduceMasked, IntVector128Tests::SUADDReduceAllMasked); } @Test(dataProvider = "intBinaryOpProvider") - static void withInt512VectorTests(IntFunction fa, IntFunction fb) { + static void withIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -4902,7 +4952,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_DEFAULTInt512VectorTests(IntFunction fa) { + static void IS_DEFAULTIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4919,7 +4969,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_DEFAULTMaskedInt512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4943,7 +4993,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_NEGATIVEInt512VectorTests(IntFunction fa) { + static void IS_NEGATIVEIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4960,7 +5010,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_NEGATIVEMaskedInt512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4980,7 +5030,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void LTIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4999,7 +5049,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ltIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5018,7 +5068,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5041,7 +5091,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void GTIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5060,7 +5110,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5083,7 +5133,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void EQInt512VectorTests(IntFunction fa, IntFunction fb) { + static void EQIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5102,7 +5152,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void eqInt512VectorTests(IntFunction fa, IntFunction fb) { + static void eqIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5121,7 +5171,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5144,7 +5194,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void NEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void NEIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5163,7 +5213,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void NEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5186,7 +5236,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void LEIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5205,7 +5255,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5228,7 +5278,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void GEIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5247,7 +5297,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5270,7 +5320,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5289,7 +5339,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5312,7 +5362,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5331,7 +5381,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5354,7 +5404,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5373,7 +5423,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5396,7 +5446,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntVector128Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5415,7 +5465,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5438,7 +5488,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5448,13 +5498,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5468,13 +5518,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void LTInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5484,13 +5534,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTIntVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5504,13 +5554,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (int)((long)b[i])))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5520,13 +5570,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5540,13 +5590,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5556,13 +5606,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQIntVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5576,7 +5626,7 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (int)((long)b[i])))); } } } @@ -5586,7 +5636,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt512VectorTests(IntFunction fa, IntFunction fb, + static void blendIntVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5602,11 +5652,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int512VectorTests::blend); + assertArraysEquals(r, a, b, mask, IntVector128Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void RearrangeInt512VectorTests(IntFunction fa, + static void RearrangeIntVector128Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void RearrangeInt512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeIntVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -5641,7 +5691,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void compressInt512VectorTests(IntFunction fa, + static void compressIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5659,7 +5709,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void expandInt512VectorTests(IntFunction fa, + static void expandIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5677,7 +5727,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void getInt512VectorTests(IntFunction fa) { + static void getIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5833,7 +5883,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastInt512VectorTests(IntFunction fa) { + static void BroadcastIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5847,7 +5897,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZeroInt512VectorTests(IntFunction fa) { + static void ZeroIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5872,7 +5922,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void sliceUnaryInt512VectorTests(IntFunction fa) { + static void sliceUnaryIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5883,7 +5933,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntVector128Tests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { @@ -5900,7 +5950,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void sliceBinaryInt512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryIntVector128TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5913,7 +5963,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Int512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntVector128Tests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { @@ -5930,7 +5980,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void sliceInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5947,7 +5997,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Int512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, IntVector128Tests::slice); } static int[] unsliceUnary(int[] a, int origin, int idx) { @@ -5964,7 +6014,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void unsliceUnaryInt512VectorTests(IntFunction fa) { + static void unsliceUnaryIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5975,7 +6025,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntVector128Tests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { @@ -6001,7 +6051,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void unsliceBinaryInt512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryIntVector128TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -6015,7 +6065,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Int512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntVector128Tests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { @@ -6055,7 +6105,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void unsliceInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6072,7 +6122,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Int512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, IntVector128Tests::unslice); } static int BITWISE_BLEND(int a, int b, int c) { @@ -6084,7 +6134,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Int512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6116,11 +6166,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Int512VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, IntVector128Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6138,11 +6188,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Int512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6153,11 +6203,11 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6168,11 +6218,11 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntVector128Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Int512VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int512VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector128Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6217,11 +6267,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Int512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6236,11 +6286,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Int512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6251,11 +6301,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6266,11 +6316,11 @@ public class Int512VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int512VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector128Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6284,19 +6334,19 @@ public class Int512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Int512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntVector128Tests::BITWISE_BLEND); } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void NEGInt512VectorTests(IntFunction fa) { + static void NEGIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6307,11 +6357,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::NEG); + assertArraysEquals(r, a, IntVector128Tests::NEG); } @Test(dataProvider = "intUnaryOpProvider") - static void negInt512VectorTests(IntFunction fa) { + static void negIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6322,11 +6372,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::neg); + assertArraysEquals(r, a, IntVector128Tests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NEGMaskedInt512VectorTests(IntFunction fa, + static void NEGMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6340,19 +6390,19 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::NEG); + assertArraysEquals(r, a, mask, IntVector128Tests::NEG); } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void ABSInt512VectorTests(IntFunction fa) { + static void ABSIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6363,11 +6413,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::ABS); + assertArraysEquals(r, a, IntVector128Tests::ABS); } @Test(dataProvider = "intUnaryOpProvider") - static void absInt512VectorTests(IntFunction fa) { + static void absIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6378,11 +6428,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::abs); + assertArraysEquals(r, a, IntVector128Tests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ABSMaskedInt512VectorTests(IntFunction fa, + static void ABSMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6396,7 +6446,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::ABS); + assertArraysEquals(r, a, mask, IntVector128Tests::ABS); } static int NOT(int a) { @@ -6408,7 +6458,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void NOTInt512VectorTests(IntFunction fa) { + static void NOTIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6419,11 +6469,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::NOT); + assertArraysEquals(r, a, IntVector128Tests::NOT); } @Test(dataProvider = "intUnaryOpProvider") - static void notInt512VectorTests(IntFunction fa) { + static void notIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6434,11 +6484,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::not); + assertArraysEquals(r, a, IntVector128Tests::not); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NOTMaskedInt512VectorTests(IntFunction fa, + static void NOTMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6452,7 +6502,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::NOT); + assertArraysEquals(r, a, mask, IntVector128Tests::NOT); } static int ZOMO(int a) { @@ -6460,7 +6510,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZOMOInt512VectorTests(IntFunction fa) { + static void ZOMOIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6471,11 +6521,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::ZOMO); + assertArraysEquals(r, a, IntVector128Tests::ZOMO); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ZOMOMaskedInt512VectorTests(IntFunction fa, + static void ZOMOMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6489,7 +6539,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntVector128Tests::ZOMO); } static int BIT_COUNT(int a) { @@ -6497,7 +6547,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BIT_COUNTInt512VectorTests(IntFunction fa) { + static void BIT_COUNTIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6508,11 +6558,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, IntVector128Tests::BIT_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void BIT_COUNTMaskedInt512VectorTests(IntFunction fa, + static void BIT_COUNTMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6526,7 +6576,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, IntVector128Tests::BIT_COUNT); } static int TRAILING_ZEROS_COUNT(int a) { @@ -6534,7 +6584,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void TRAILING_ZEROS_COUNTInt512VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6545,11 +6595,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector128Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedInt512VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6563,7 +6613,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector128Tests::TRAILING_ZEROS_COUNT); } static int LEADING_ZEROS_COUNT(int a) { @@ -6571,7 +6621,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LEADING_ZEROS_COUNTInt512VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6582,11 +6632,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector128Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedInt512VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6600,7 +6650,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector128Tests::LEADING_ZEROS_COUNT); } static int REVERSE(int a) { @@ -6608,7 +6658,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSEInt512VectorTests(IntFunction fa) { + static void REVERSEIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6619,11 +6669,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::REVERSE); + assertArraysEquals(r, a, IntVector128Tests::REVERSE); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSEMaskedInt512VectorTests(IntFunction fa, + static void REVERSEMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6637,7 +6687,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::REVERSE); + assertArraysEquals(r, a, mask, IntVector128Tests::REVERSE); } static int REVERSE_BYTES(int a) { @@ -6645,7 +6695,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSE_BYTESInt512VectorTests(IntFunction fa) { + static void REVERSE_BYTESIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6656,11 +6706,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, IntVector128Tests::REVERSE_BYTES); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedInt512VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedIntVector128Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6674,7 +6724,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, IntVector128Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6682,7 +6732,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6695,7 +6745,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::band); + assertArraysEquals(r, a, b, IntVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6703,7 +6753,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6716,7 +6766,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::bor); + assertArraysEquals(r, a, b, IntVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6724,7 +6774,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6737,7 +6787,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::bxor); + assertArraysEquals(r, a, b, IntVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6745,7 +6795,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6758,7 +6808,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::bandNot); + assertArraysEquals(r, a, b, IntVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6766,7 +6816,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6779,7 +6829,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int512VectorTests::beq); + assertArraysEquals(r, a, b, IntVector128Tests::beq); } static boolean unot(boolean a) { @@ -6787,7 +6837,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotInt512VectorTests(IntFunction fa) { + static void masknotIntVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6798,7 +6848,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::unot); + assertArraysEquals(r, a, IntVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6815,7 +6865,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongInt512VectorTests(IntFunction fa) { + static void maskFromToLongIntVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6829,7 +6879,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltIntVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6839,13 +6889,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpProvider") - static void eqInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqIntVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6855,13 +6905,13 @@ public class Int512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intUnaryOpProvider") - static void toIntArrayInt512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6872,7 +6922,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toLongArrayInt512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6883,7 +6933,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toDoubleArrayInt512VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6894,7 +6944,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toStringInt512VectorTestsSmokeTest(IntFunction fa) { + static void toStringIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6907,7 +6957,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void hashCodeInt512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6924,7 +6974,7 @@ public class Int512VectorTests extends AbstractVectorTest { static long ADDReduceLong(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6933,14 +6983,14 @@ public class Int512VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(int[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((int)res, (int)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceLongInt512VectorTests(IntFunction fa) { + static void ADDReduceLongIntVector128Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6951,19 +7001,20 @@ public class Int512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Int512VectorTests::ADDReduceLong, Int512VectorTests::ADDReduceAllLong); + IntVector128Tests::ADDReduceLong, IntVector128Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6972,14 +7023,14 @@ public class Int512VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(int[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((int)res, (int)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceLongInt512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongIntVector128TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6992,16 +7043,16 @@ public class Int512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Int512VectorTests::ADDReduceLongMasked, Int512VectorTests::ADDReduceAllLongMasked); + IntVector128Tests::ADDReduceLongMasked, IntVector128Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastLongInt512VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongIntVector128TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7012,7 +7063,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendIntVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -7026,12 +7077,12 @@ public class Int512VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Int512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector128Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void SelectFromInt512VectorTests(IntFunction fa, + static void SelectFromIntVector128Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -7047,7 +7098,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorInt512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorIntVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] idx = fc.apply(SPECIES.length()); @@ -7065,7 +7116,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void SelectFromInt512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromIntVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -7084,7 +7135,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousInt512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousIntVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7100,7 +7151,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringInt512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringIntVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7114,7 +7165,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsInt512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsIntVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7128,7 +7179,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsInt512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsIntVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7144,7 +7195,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeInt512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeIntVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7166,7 +7217,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountInt512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountIntVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7177,7 +7228,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, IntVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7191,7 +7242,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueInt512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueIntVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7202,7 +7253,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, IntVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7216,7 +7267,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueInt512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueIntVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7227,11 +7278,11 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, IntVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressInt512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressIntVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7259,7 +7310,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeInt512VectorTestsSmokeTest(int offset) { + static void indexInRangeIntVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7273,7 +7324,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongInt512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongIntVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7300,14 +7351,14 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundInt512VectorTestsSmokeTest(int length) { + static void loopBoundIntVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongInt512VectorTestsSmokeTest(int _length) { + static void loopBoundLongIntVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7315,21 +7366,21 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeInt512VectorTestsSmokeTest() { + static void ElementSizeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Integer.SIZE); } @Test - static void VectorShapeInt512VectorTestsSmokeTest() { + static void VectorShapeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); - assert(vsh.equals(VectorShape.S_512_BIT)); + assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesInt512VectorTestsSmokeTest() { + static void ShapeWithLanesIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(int.class); @@ -7337,32 +7388,32 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeInt512VectorTestsSmokeTest() { + static void ElementTypeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementType() == int.class); } @Test - static void SpeciesElementSizeInt512VectorTestsSmokeTest() { + static void SpeciesElementSizeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementSize() == Integer.SIZE); } @Test - static void VectorTypeInt512VectorTestsSmokeTest() { + static void VectorTypeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesInt512VectorTestsSmokeTest() { + static void WithLanesIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(int.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeInt512VectorTestsSmokeTest() { + static void WithShapeIntVector128TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7370,7 +7421,7 @@ public class Int512VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueInt512VectorTestsSmokeTest() { + static void MaskAllTrueIntVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/IntVector256LoadStoreTests.java index 333757be0f8..ea98a287ded 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Int256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation IntVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Int256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class IntVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = IntVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/IntVector256Tests.java similarity index 87% rename from test/jdk/jdk/incubator/vector/Int256VectorTests.java rename to test/jdk/jdk/incubator/vector/IntVector256Tests.java index f9f0faad32b..bb2d1d717f4 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Int256VectorTests extends AbstractVectorTest { +public class IntVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = IntVector.SPECIES_256; @@ -1531,6 +1531,59 @@ public class Int256VectorTests extends AbstractVectorTest { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1547,9 +1600,6 @@ public class Int256VectorTests extends AbstractVectorTest { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1663,11 +1713,11 @@ public class Int256VectorTests extends AbstractVectorTest { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1680,15 +1730,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::ADD); + assertArraysEquals(r, a, b, IntVector256Tests::ADD); } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt256VectorTests(IntFunction fa, IntFunction fb) { + static void addIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1699,11 +1749,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::add); + assertArraysEquals(r, a, b, IntVector256Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1719,11 +1769,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntVector256Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1737,15 +1787,15 @@ public class Int256VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int256VectorTests::add); + assertArraysEquals(r, a, b, mask, IntVector256Tests::add); } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void SUBInt256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1758,15 +1808,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::SUB); + assertArraysEquals(r, a, b, IntVector256Tests::SUB); } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt256VectorTests(IntFunction fa, IntFunction fb) { + static void subIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1777,11 +1827,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::sub); + assertArraysEquals(r, a, b, IntVector256Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void SUBInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1797,11 +1847,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntVector256Tests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1815,15 +1865,15 @@ public class Int256VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int256VectorTests::sub); + assertArraysEquals(r, a, b, mask, IntVector256Tests::sub); } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MULInt256VectorTests(IntFunction fa, IntFunction fb) { + static void MULIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1836,15 +1886,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::MUL); + assertArraysEquals(r, a, b, IntVector256Tests::MUL); } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt256VectorTests(IntFunction fa, IntFunction fb) { + static void mulIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1855,11 +1905,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::mul); + assertArraysEquals(r, a, b, IntVector256Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void MULInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1875,11 +1925,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntVector256Tests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1893,7 +1943,7 @@ public class Int256VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int256VectorTests::mul); + assertArraysEquals(r, a, b, mask, IntVector256Tests::mul); } static int DIV(int a, int b) { @@ -1901,7 +1951,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void DIVInt256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1916,7 +1966,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::DIV); + assertArraysEquals(r, a, b, IntVector256Tests::DIV); } static int div(int a, int b) { @@ -1924,7 +1974,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void divInt256VectorTests(IntFunction fa, IntFunction fb) { + static void divIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1939,11 +1989,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::div); + assertArraysEquals(r, a, b, IntVector256Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void DIVInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1961,11 +2011,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntVector256Tests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1983,15 +2033,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::div); + assertArraysEquals(r, a, b, mask, IntVector256Tests::div); } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void FIRST_NONZEROInt256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2004,11 +2054,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, IntVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void FIRST_NONZEROInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2024,7 +2074,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntVector256Tests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -2032,7 +2082,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ANDIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2045,7 +2095,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::AND); + assertArraysEquals(r, a, b, IntVector256Tests::AND); } static int and(int a, int b) { @@ -2053,7 +2103,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void andInt256VectorTests(IntFunction fa, IntFunction fb) { + static void andIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2064,11 +2114,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::and); + assertArraysEquals(r, a, b, IntVector256Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2084,7 +2134,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::AND); + assertArraysEquals(r, a, b, mask, IntVector256Tests::AND); } static int AND_NOT(int a, int b) { @@ -2092,7 +2142,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void AND_NOTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2105,11 +2155,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntVector256Tests::AND_NOT); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void AND_NOTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2125,7 +2175,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, IntVector256Tests::AND_NOT); } static int OR(int a, int b) { @@ -2133,7 +2183,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ORIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2146,7 +2196,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::OR); + assertArraysEquals(r, a, b, IntVector256Tests::OR); } static int or(int a, int b) { @@ -2154,7 +2204,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void orInt256VectorTests(IntFunction fa, IntFunction fb) { + static void orIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2165,11 +2215,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::or); + assertArraysEquals(r, a, b, IntVector256Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2185,7 +2235,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::OR); + assertArraysEquals(r, a, b, mask, IntVector256Tests::OR); } static int XOR(int a, int b) { @@ -2193,7 +2243,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void XORInt256VectorTests(IntFunction fa, IntFunction fb) { + static void XORIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2206,11 +2256,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::XOR); + assertArraysEquals(r, a, b, IntVector256Tests::XOR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void XORInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2226,7 +2276,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntVector256Tests::XOR); } static int COMPRESS_BITS(int a, int b) { @@ -2234,7 +2284,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void COMPRESS_BITSInt256VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2247,11 +2297,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, IntVector256Tests::COMPRESS_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void COMPRESS_BITSInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2267,7 +2317,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, IntVector256Tests::COMPRESS_BITS); } static int EXPAND_BITS(int a, int b) { @@ -2275,7 +2325,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void EXPAND_BITSInt256VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2288,11 +2338,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, IntVector256Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void EXPAND_BITSInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2308,11 +2358,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, IntVector256Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2322,11 +2372,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2339,11 +2389,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::add); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2353,11 +2403,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2370,11 +2420,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::sub); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2434,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2401,11 +2451,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::mul); } @Test(dataProvider = "intBinaryOpProvider") - static void divInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2436,11 +2486,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::div); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2450,11 +2500,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void orInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2464,11 +2514,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2481,11 +2531,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2495,11 +2545,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void andInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2509,11 +2559,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2526,11 +2576,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntVector256Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2540,11 +2590,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntVector256Tests::OR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2557,11 +2607,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector256Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDIntVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2571,11 +2621,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntVector256Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDIntVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2588,7 +2638,7 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector256Tests::ADD); } static int LSHL(int a, int b) { @@ -2596,7 +2646,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2609,11 +2659,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::LSHL); + assertArraysEquals(r, a, b, IntVector256Tests::LSHL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2629,7 +2679,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, IntVector256Tests::LSHL); } static int ASHR(int a, int b) { @@ -2637,7 +2687,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2650,11 +2700,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::ASHR); + assertArraysEquals(r, a, b, IntVector256Tests::ASHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2670,7 +2720,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, IntVector256Tests::ASHR); } static int LSHR(int a, int b) { @@ -2678,7 +2728,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2691,11 +2741,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::LSHR); + assertArraysEquals(r, a, b, IntVector256Tests::LSHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2711,7 +2761,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, IntVector256Tests::LSHR); } static int LSHL_unary(int a, int b) { @@ -2719,7 +2769,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLIntVector256TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2731,11 +2781,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntVector256Tests::LSHL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2750,7 +2800,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector256Tests::LSHL_unary); } static int LSHR_unary(int a, int b) { @@ -2758,7 +2808,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRIntVector256TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2770,11 +2820,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntVector256Tests::LSHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2789,7 +2839,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector256Tests::LSHR_unary); } static int ASHR_unary(int a, int b) { @@ -2797,7 +2847,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRIntVector256TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2809,11 +2859,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntVector256Tests::ASHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2828,7 +2878,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector256Tests::ASHR_unary); } static int ROR(int a, int b) { @@ -2836,7 +2886,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt256VectorTests(IntFunction fa, IntFunction fb) { + static void RORIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2849,11 +2899,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::ROR); + assertArraysEquals(r, a, b, IntVector256Tests::ROR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2869,7 +2919,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::ROR); + assertArraysEquals(r, a, b, mask, IntVector256Tests::ROR); } static int ROL(int a, int b) { @@ -2877,7 +2927,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ROLIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2890,11 +2940,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::ROL); + assertArraysEquals(r, a, b, IntVector256Tests::ROL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2910,7 +2960,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::ROL); + assertArraysEquals(r, a, b, mask, IntVector256Tests::ROL); } static int ROR_unary(int a, int b) { @@ -2918,7 +2968,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORIntVector256TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2930,11 +2980,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, IntVector256Tests::ROR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORIntVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2949,7 +2999,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector256Tests::ROR_unary); } static int ROL_unary(int a, int b) { @@ -2957,7 +3007,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLIntVector256TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2969,11 +3019,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, IntVector256Tests::ROL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2988,14 +3038,14 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector256Tests::ROL_unary); } static int LSHR_binary_const(int a) { return (int)((a >>> CONST_SHIFT)); } @Test(dataProvider = "intUnaryOpProvider") - static void LSHRInt256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRIntVector256TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3006,11 +3056,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, IntVector256Tests::LSHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHRInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRIntVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3024,7 +3074,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector256Tests::LSHR_binary_const); } static int LSHL_binary_const(int a) { @@ -3032,7 +3082,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LSHLInt256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLIntVector256TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3043,11 +3093,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, IntVector256Tests::LSHL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHLInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLIntVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3061,7 +3111,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector256Tests::LSHL_binary_const); } static int ASHR_binary_const(int a) { @@ -3069,7 +3119,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ASHRInt256VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRIntVector256TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3080,11 +3130,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, IntVector256Tests::ASHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ASHRInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRIntVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3098,7 +3148,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector256Tests::ASHR_binary_const); } static int ROR_binary_const(int a) { @@ -3106,7 +3156,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void RORInt256VectorTestsScalarShiftConst(IntFunction fa) { + static void RORIntVector256TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3117,11 +3167,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, IntVector256Tests::ROR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void RORInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORIntVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3135,7 +3185,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector256Tests::ROR_binary_const); } static int ROL_binary_const(int a) { @@ -3143,7 +3193,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ROLInt256VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLIntVector256TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3154,11 +3204,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, IntVector256Tests::ROL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ROLInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLIntVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3172,14 +3222,14 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector256Tests::ROL_binary_const); } static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MINInt256VectorTestsWithMemOp(IntFunction fa) { + static void MINIntVector256TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int256VectorTests::MIN); + assertArraysEquals(r, a, (int)10, IntVector256Tests::MIN); } static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void minInt256VectorTestsWithMemOp(IntFunction fa) { + static void minIntVector256TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int256VectorTests::min); + assertArraysEquals(r, a, (int)10, IntVector256Tests::min); } static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINIntVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,13 +3276,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int256VectorTests::MIN); + assertArraysEquals(r, a, (int)10, mask, IntVector256Tests::MIN); } static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MAXInt256VectorTestsWithMemOp(IntFunction fa) { + static void MAXIntVector256TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3243,13 +3293,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int256VectorTests::MAX); + assertArraysEquals(r, a, (int)10, IntVector256Tests::MAX); } static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void maxInt256VectorTestsWithMemOp(IntFunction fa) { + static void maxIntVector256TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3260,13 +3310,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int256VectorTests::max); + assertArraysEquals(r, a, (int)10, IntVector256Tests::max); } static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXIntVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3279,15 +3329,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int256VectorTests::MAX); + assertArraysEquals(r, a, (int)10, mask, IntVector256Tests::MAX); } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt256VectorTests(IntFunction fa, IntFunction fb) { + static void MINIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3300,15 +3350,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::MIN); + assertArraysEquals(r, a, b, IntVector256Tests::MIN); } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt256VectorTests(IntFunction fa, IntFunction fb) { + static void minIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3319,15 +3369,15 @@ public class Int256VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::min); + assertArraysEquals(r, a, b, IntVector256Tests::min); } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3340,15 +3390,15 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::MAX); + assertArraysEquals(r, a, b, IntVector256Tests::MAX); } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maxIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3359,7 +3409,7 @@ public class Int256VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int256VectorTests::max); + assertArraysEquals(r, a, b, IntVector256Tests::max); } static int UMIN(int a, int b) { @@ -3367,7 +3417,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMINInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UMINIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3380,11 +3430,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::UMIN); + assertArraysEquals(r, a, b, IntVector256Tests::UMIN); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMINInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3400,7 +3450,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, IntVector256Tests::UMIN); } static int UMAX(int a, int b) { @@ -3408,7 +3458,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMAXInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3421,11 +3471,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::UMAX); + assertArraysEquals(r, a, b, IntVector256Tests::UMAX); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMAXInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3441,7 +3491,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, IntVector256Tests::UMAX); } static int SADD(int a, int b) { @@ -3449,7 +3499,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SADDInt256VectorTests(IntFunction fa, IntFunction fb) { + static void SADDIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3462,11 +3512,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::SADD); + assertArraysEquals(r, a, b, IntVector256Tests::SADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SADDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3482,7 +3532,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::SADD); + assertArraysEquals(r, a, b, mask, IntVector256Tests::SADD); } static int SSUB(int a, int b) { @@ -3490,7 +3540,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SSUBInt256VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3503,11 +3553,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::SSUB); + assertArraysEquals(r, a, b, IntVector256Tests::SSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SSUBInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3523,7 +3573,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, IntVector256Tests::SSUB); } static int SUADD(int a, int b) { @@ -3531,7 +3581,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUADDInt256VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3544,11 +3594,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::SUADD); + assertArraysEquals(r, a, b, IntVector256Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUADDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3564,7 +3614,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, IntVector256Tests::SUADD); } static int SUSUB(int a, int b) { @@ -3572,7 +3622,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUSUBInt256VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3585,11 +3635,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::SUSUB); + assertArraysEquals(r, a, b, IntVector256Tests::SUSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUSUBInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3605,11 +3655,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, IntVector256Tests::SUSUB); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3619,11 +3669,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::MIN); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3633,11 +3683,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::min); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3647,11 +3697,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::MAX); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3661,10 +3711,10 @@ public class Int256VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntVector256Tests::max); } @Test(dataProvider = "intSaturatingBinaryOpAssocProvider") - static void SUADDAssocInt256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocIntVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -3681,11 +3731,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Int256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, IntVector256Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3706,13 +3756,13 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Int256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntVector256Tests::SUADD); } static int ANDReduce(int[] a, int idx) { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3721,14 +3771,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ANDReduceAll(int[] a) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ANDReduceInt256VectorTests(IntFunction fa) { + static void ANDReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3739,12 +3789,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::ANDReduce, Int256VectorTests::ANDReduceAll); + IntVector256Tests::ANDReduce, IntVector256Tests::ANDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3752,20 +3802,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = AND_IDENTITY; - assertEquals((int) (id & id), id, + assertEquals((int) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id & x), x); - assertEquals((int) (x & id), x); + assertEquals((int) (scalar_and(id, x)), x); + assertEquals((int) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id & x), x, + assertEquals((int) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x & id), x, + assertEquals((int) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3774,7 +3824,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3783,14 +3833,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ANDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3803,18 +3853,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::ANDReduceMasked, Int256VectorTests::ANDReduceAllMasked); + IntVector256Tests::ANDReduceMasked, IntVector256Tests::ANDReduceAllMasked); } static int ORReduce(int[] a, int idx) { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3823,14 +3873,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ORReduceAll(int[] a) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ORReduceInt256VectorTests(IntFunction fa) { + static void ORReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3841,12 +3891,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::ORReduce, Int256VectorTests::ORReduceAll); + IntVector256Tests::ORReduce, IntVector256Tests::ORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3854,20 +3904,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = OR_IDENTITY; - assertEquals((int) (id | id), id, + assertEquals((int) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id | x), x); - assertEquals((int) (x | id), x); + assertEquals((int) (scalar_or(id, x)), x); + assertEquals((int) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id | x), x, + assertEquals((int) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x | id), x, + assertEquals((int) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3876,7 +3926,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3885,14 +3935,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3905,18 +3955,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::ORReduceMasked, Int256VectorTests::ORReduceAllMasked); + IntVector256Tests::ORReduceMasked, IntVector256Tests::ORReduceAllMasked); } static int XORReduce(int[] a, int idx) { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3925,14 +3975,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int XORReduceAll(int[] a) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void XORReduceInt256VectorTests(IntFunction fa) { + static void XORReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3943,12 +3993,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::XORReduce, Int256VectorTests::XORReduceAll); + IntVector256Tests::XORReduce, IntVector256Tests::XORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3956,20 +4006,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = XOR_IDENTITY; - assertEquals((int) (id ^ id), id, + assertEquals((int) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id ^ x), x); - assertEquals((int) (x ^ id), x); + assertEquals((int) (scalar_xor(id, x)), x); + assertEquals((int) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id ^ x), x, + assertEquals((int) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x ^ id), x, + assertEquals((int) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3978,7 +4028,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3987,14 +4037,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void XORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4007,18 +4057,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::XORReduceMasked, Int256VectorTests::XORReduceAllMasked); + IntVector256Tests::XORReduceMasked, IntVector256Tests::XORReduceAllMasked); } static int ADDReduce(int[] a, int idx) { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4027,14 +4077,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ADDReduceAll(int[] a) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceInt256VectorTests(IntFunction fa) { + static void ADDReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4045,12 +4095,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::ADDReduce, Int256VectorTests::ADDReduceAll); + IntVector256Tests::ADDReduce, IntVector256Tests::ADDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4058,20 +4108,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = ADD_IDENTITY; - assertEquals((int) (id + id), id, + assertEquals((int) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id + x), x); - assertEquals((int) (x + id), x); + assertEquals((int) (scalar_add(id, x)), x); + assertEquals((int) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id + x), x, + assertEquals((int) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x + id), x, + assertEquals((int) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4080,7 +4130,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4089,14 +4139,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int ADDReduceAllMasked(int[] a, boolean[] mask) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4109,18 +4159,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::ADDReduceMasked, Int256VectorTests::ADDReduceAllMasked); + IntVector256Tests::ADDReduceMasked, IntVector256Tests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4129,14 +4179,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MULReduceAll(int[] a) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MULReduceInt256VectorTests(IntFunction fa) { + static void MULReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4147,12 +4197,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::MULReduce, Int256VectorTests::MULReduceAll); + IntVector256Tests::MULReduce, IntVector256Tests::MULReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4160,20 +4210,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MUL_IDENTITY; - assertEquals((int) (id * id), id, + assertEquals((int) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id * x), x); - assertEquals((int) (x * id), x); + assertEquals((int) (scalar_mul(id, x)), x); + assertEquals((int) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id * x), x, + assertEquals((int) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x * id), x, + assertEquals((int) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4182,7 +4232,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4191,14 +4241,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MULReduceAllMasked(int[] a, boolean[] mask) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MULReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4211,18 +4261,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::MULReduceMasked, Int256VectorTests::MULReduceAllMasked); + IntVector256Tests::MULReduceMasked, IntVector256Tests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4231,14 +4281,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MINReduceAll(int[] a) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MINReduceInt256VectorTests(IntFunction fa) { + static void MINReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4249,12 +4299,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::MINReduce, Int256VectorTests::MINReduceAll); + IntVector256Tests::MINReduce, IntVector256Tests::MINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4262,20 +4312,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MIN_IDENTITY; - assertEquals((int) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.min(id, x), x); - assertEquals((int) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4284,7 +4334,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4293,14 +4343,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MINReduceAllMasked(int[] a, boolean[] mask) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4313,18 +4363,18 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::MINReduceMasked, Int256VectorTests::MINReduceAllMasked); + IntVector256Tests::MINReduceMasked, IntVector256Tests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4333,14 +4383,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MAXReduceAll(int[] a) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MAXReduceInt256VectorTests(IntFunction fa) { + static void MAXReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4351,12 +4401,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::MAXReduce, Int256VectorTests::MAXReduceAll); + IntVector256Tests::MAXReduce, IntVector256Tests::MAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4364,20 +4414,20 @@ public class Int256VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MAX_IDENTITY; - assertEquals((int) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.max(id, x), x); - assertEquals((int) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4386,7 +4436,7 @@ public class Int256VectorTests extends AbstractVectorTest { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4395,14 +4445,14 @@ public class Int256VectorTests extends AbstractVectorTest { static int MAXReduceAllMasked(int[] a, boolean[] mask) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4415,12 +4465,12 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::MAXReduceMasked, Int256VectorTests::MAXReduceAllMasked); + IntVector256Tests::MAXReduceMasked, IntVector256Tests::MAXReduceAllMasked); } static int UMINReduce(int[] a, int idx) { @@ -4442,7 +4492,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMINReduceInt256VectorTests(IntFunction fa) { + static void UMINReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4458,7 +4508,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::UMINReduce, Int256VectorTests::UMINReduceAll); + IntVector256Tests::UMINReduce, IntVector256Tests::UMINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4504,7 +4554,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4522,7 +4572,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::UMINReduceMasked, Int256VectorTests::UMINReduceAllMasked); + IntVector256Tests::UMINReduceMasked, IntVector256Tests::UMINReduceAllMasked); } static int UMAXReduce(int[] a, int idx) { @@ -4544,7 +4594,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMAXReduceInt256VectorTests(IntFunction fa) { + static void UMAXReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4560,7 +4610,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::UMAXReduce, Int256VectorTests::UMAXReduceAll); + IntVector256Tests::UMAXReduce, IntVector256Tests::UMAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4606,7 +4656,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4624,7 +4674,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::UMAXReduceMasked, Int256VectorTests::UMAXReduceAllMasked); + IntVector256Tests::UMAXReduceMasked, IntVector256Tests::UMAXReduceAllMasked); } static int FIRST_NONZEROReduce(int[] a, int idx) { @@ -4646,7 +4696,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void FIRST_NONZEROReduceInt256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4662,7 +4712,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::FIRST_NONZEROReduce, Int256VectorTests::FIRST_NONZEROReduceAll); + IntVector256Tests::FIRST_NONZEROReduce, IntVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4708,7 +4758,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void FIRST_NONZEROReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4726,7 +4776,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::FIRST_NONZEROReduceMasked, Int256VectorTests::FIRST_NONZEROReduceAllMasked); + IntVector256Tests::FIRST_NONZEROReduceMasked, IntVector256Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4739,7 +4789,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueInt256VectorTests(IntFunction fm) { + static void anyTrueIntVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4750,7 +4800,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntVector256Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4763,7 +4813,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueInt256VectorTests(IntFunction fm) { + static void allTrueIntVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4774,7 +4824,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntVector256Tests::allTrue); } static int SUADDReduce(int[] a, int idx) { @@ -4796,7 +4846,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingUnaryOpProvider") - static void SUADDReduceInt256VectorTests(IntFunction fa) { + static void SUADDReduceIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4812,7 +4862,7 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int256VectorTests::SUADDReduce, Int256VectorTests::SUADDReduceAll); + IntVector256Tests::SUADDReduce, IntVector256Tests::SUADDReduceAll); } @Test(dataProvider = "intSaturatingUnaryOpProvider") @@ -4857,7 +4907,7 @@ public class Int256VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "intSaturatingUnaryOpMaskProvider") - static void SUADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4875,11 +4925,11 @@ public class Int256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::SUADDReduceMasked, Int256VectorTests::SUADDReduceAllMasked); + IntVector256Tests::SUADDReduceMasked, IntVector256Tests::SUADDReduceAllMasked); } @Test(dataProvider = "intBinaryOpProvider") - static void withInt256VectorTests(IntFunction fa, IntFunction fb) { + static void withIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -4902,7 +4952,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_DEFAULTInt256VectorTests(IntFunction fa) { + static void IS_DEFAULTIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4919,7 +4969,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_DEFAULTMaskedInt256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4943,7 +4993,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_NEGATIVEInt256VectorTests(IntFunction fa) { + static void IS_NEGATIVEIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4960,7 +5010,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_NEGATIVEMaskedInt256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4980,7 +5030,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void LTIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4999,7 +5049,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ltIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5018,7 +5068,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5041,7 +5091,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void GTIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5060,7 +5110,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5083,7 +5133,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void EQInt256VectorTests(IntFunction fa, IntFunction fb) { + static void EQIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5102,7 +5152,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void eqInt256VectorTests(IntFunction fa, IntFunction fb) { + static void eqIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5121,7 +5171,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5144,7 +5194,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void NEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void NEIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5163,7 +5213,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void NEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5186,7 +5236,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void LEIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5205,7 +5255,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5228,7 +5278,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void GEIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5247,7 +5297,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5270,7 +5320,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5289,7 +5339,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5312,7 +5362,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5331,7 +5381,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5354,7 +5404,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5373,7 +5423,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5396,7 +5446,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntVector256Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5415,7 +5465,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5438,7 +5488,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5448,13 +5498,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5468,13 +5518,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void LTInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5484,13 +5534,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTIntVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5504,13 +5554,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (int)((long)b[i])))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5520,13 +5570,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5540,13 +5590,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5556,13 +5606,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQIntVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5576,7 +5626,7 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (int)((long)b[i])))); } } } @@ -5586,7 +5636,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt256VectorTests(IntFunction fa, IntFunction fb, + static void blendIntVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5602,11 +5652,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int256VectorTests::blend); + assertArraysEquals(r, a, b, mask, IntVector256Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void RearrangeInt256VectorTests(IntFunction fa, + static void RearrangeIntVector256Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void RearrangeInt256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeIntVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -5641,7 +5691,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void compressInt256VectorTests(IntFunction fa, + static void compressIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5659,7 +5709,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void expandInt256VectorTests(IntFunction fa, + static void expandIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5677,7 +5727,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void getInt256VectorTests(IntFunction fa) { + static void getIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5833,7 +5883,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastInt256VectorTests(IntFunction fa) { + static void BroadcastIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5847,7 +5897,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZeroInt256VectorTests(IntFunction fa) { + static void ZeroIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5872,7 +5922,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void sliceUnaryInt256VectorTests(IntFunction fa) { + static void sliceUnaryIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5883,7 +5933,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntVector256Tests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { @@ -5900,7 +5950,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void sliceBinaryInt256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryIntVector256TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5913,7 +5963,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Int256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntVector256Tests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { @@ -5930,7 +5980,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void sliceInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5947,7 +5997,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Int256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, IntVector256Tests::slice); } static int[] unsliceUnary(int[] a, int origin, int idx) { @@ -5964,7 +6014,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void unsliceUnaryInt256VectorTests(IntFunction fa) { + static void unsliceUnaryIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5975,7 +6025,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntVector256Tests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { @@ -6001,7 +6051,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void unsliceBinaryInt256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryIntVector256TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -6015,7 +6065,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Int256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntVector256Tests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { @@ -6055,7 +6105,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void unsliceInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6072,7 +6122,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Int256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, IntVector256Tests::unslice); } static int BITWISE_BLEND(int a, int b, int c) { @@ -6084,7 +6134,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Int256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6116,11 +6166,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Int256VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, IntVector256Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6138,11 +6188,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Int256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6153,11 +6203,11 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6168,11 +6218,11 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntVector256Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Int256VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int256VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector256Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6217,11 +6267,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Int256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6236,11 +6286,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Int256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6251,11 +6301,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6266,11 +6316,11 @@ public class Int256VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int256VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector256Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6284,19 +6334,19 @@ public class Int256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Int256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntVector256Tests::BITWISE_BLEND); } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void NEGInt256VectorTests(IntFunction fa) { + static void NEGIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6307,11 +6357,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::NEG); + assertArraysEquals(r, a, IntVector256Tests::NEG); } @Test(dataProvider = "intUnaryOpProvider") - static void negInt256VectorTests(IntFunction fa) { + static void negIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6322,11 +6372,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::neg); + assertArraysEquals(r, a, IntVector256Tests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NEGMaskedInt256VectorTests(IntFunction fa, + static void NEGMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6340,19 +6390,19 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::NEG); + assertArraysEquals(r, a, mask, IntVector256Tests::NEG); } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void ABSInt256VectorTests(IntFunction fa) { + static void ABSIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6363,11 +6413,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::ABS); + assertArraysEquals(r, a, IntVector256Tests::ABS); } @Test(dataProvider = "intUnaryOpProvider") - static void absInt256VectorTests(IntFunction fa) { + static void absIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6378,11 +6428,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::abs); + assertArraysEquals(r, a, IntVector256Tests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ABSMaskedInt256VectorTests(IntFunction fa, + static void ABSMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6396,7 +6446,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::ABS); + assertArraysEquals(r, a, mask, IntVector256Tests::ABS); } static int NOT(int a) { @@ -6408,7 +6458,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void NOTInt256VectorTests(IntFunction fa) { + static void NOTIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6419,11 +6469,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::NOT); + assertArraysEquals(r, a, IntVector256Tests::NOT); } @Test(dataProvider = "intUnaryOpProvider") - static void notInt256VectorTests(IntFunction fa) { + static void notIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6434,11 +6484,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::not); + assertArraysEquals(r, a, IntVector256Tests::not); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NOTMaskedInt256VectorTests(IntFunction fa, + static void NOTMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6452,7 +6502,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::NOT); + assertArraysEquals(r, a, mask, IntVector256Tests::NOT); } static int ZOMO(int a) { @@ -6460,7 +6510,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZOMOInt256VectorTests(IntFunction fa) { + static void ZOMOIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6471,11 +6521,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::ZOMO); + assertArraysEquals(r, a, IntVector256Tests::ZOMO); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ZOMOMaskedInt256VectorTests(IntFunction fa, + static void ZOMOMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6489,7 +6539,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntVector256Tests::ZOMO); } static int BIT_COUNT(int a) { @@ -6497,7 +6547,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BIT_COUNTInt256VectorTests(IntFunction fa) { + static void BIT_COUNTIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6508,11 +6558,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, IntVector256Tests::BIT_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void BIT_COUNTMaskedInt256VectorTests(IntFunction fa, + static void BIT_COUNTMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6526,7 +6576,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, IntVector256Tests::BIT_COUNT); } static int TRAILING_ZEROS_COUNT(int a) { @@ -6534,7 +6584,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void TRAILING_ZEROS_COUNTInt256VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6545,11 +6595,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector256Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedInt256VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6563,7 +6613,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector256Tests::TRAILING_ZEROS_COUNT); } static int LEADING_ZEROS_COUNT(int a) { @@ -6571,7 +6621,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LEADING_ZEROS_COUNTInt256VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6582,11 +6632,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector256Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedInt256VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6600,7 +6650,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector256Tests::LEADING_ZEROS_COUNT); } static int REVERSE(int a) { @@ -6608,7 +6658,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSEInt256VectorTests(IntFunction fa) { + static void REVERSEIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6619,11 +6669,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::REVERSE); + assertArraysEquals(r, a, IntVector256Tests::REVERSE); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSEMaskedInt256VectorTests(IntFunction fa, + static void REVERSEMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6637,7 +6687,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::REVERSE); + assertArraysEquals(r, a, mask, IntVector256Tests::REVERSE); } static int REVERSE_BYTES(int a) { @@ -6645,7 +6695,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSE_BYTESInt256VectorTests(IntFunction fa) { + static void REVERSE_BYTESIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6656,11 +6706,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, IntVector256Tests::REVERSE_BYTES); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedInt256VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedIntVector256Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6674,7 +6724,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, IntVector256Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6682,7 +6732,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6695,7 +6745,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::band); + assertArraysEquals(r, a, b, IntVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6703,7 +6753,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6716,7 +6766,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::bor); + assertArraysEquals(r, a, b, IntVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6724,7 +6774,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6737,7 +6787,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::bxor); + assertArraysEquals(r, a, b, IntVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6745,7 +6795,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6758,7 +6808,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::bandNot); + assertArraysEquals(r, a, b, IntVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6766,7 +6816,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6779,7 +6829,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int256VectorTests::beq); + assertArraysEquals(r, a, b, IntVector256Tests::beq); } static boolean unot(boolean a) { @@ -6787,7 +6837,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotInt256VectorTests(IntFunction fa) { + static void masknotIntVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6798,7 +6848,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::unot); + assertArraysEquals(r, a, IntVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6815,7 +6865,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongInt256VectorTests(IntFunction fa) { + static void maskFromToLongIntVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6829,7 +6879,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltIntVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6839,13 +6889,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpProvider") - static void eqInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqIntVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6855,13 +6905,13 @@ public class Int256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intUnaryOpProvider") - static void toIntArrayInt256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6872,7 +6922,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toLongArrayInt256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6883,7 +6933,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toDoubleArrayInt256VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6894,7 +6944,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toStringInt256VectorTestsSmokeTest(IntFunction fa) { + static void toStringIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6907,7 +6957,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void hashCodeInt256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6924,7 +6974,7 @@ public class Int256VectorTests extends AbstractVectorTest { static long ADDReduceLong(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6933,14 +6983,14 @@ public class Int256VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(int[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((int)res, (int)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceLongInt256VectorTests(IntFunction fa) { + static void ADDReduceLongIntVector256Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6951,19 +7001,20 @@ public class Int256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Int256VectorTests::ADDReduceLong, Int256VectorTests::ADDReduceAllLong); + IntVector256Tests::ADDReduceLong, IntVector256Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6972,14 +7023,14 @@ public class Int256VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(int[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((int)res, (int)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceLongInt256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongIntVector256TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6992,16 +7043,16 @@ public class Int256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Int256VectorTests::ADDReduceLongMasked, Int256VectorTests::ADDReduceAllLongMasked); + IntVector256Tests::ADDReduceLongMasked, IntVector256Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastLongInt256VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongIntVector256TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7012,7 +7063,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendIntVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -7026,12 +7077,12 @@ public class Int256VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Int256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector256Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void SelectFromInt256VectorTests(IntFunction fa, + static void SelectFromIntVector256Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -7047,7 +7098,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorInt256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorIntVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] idx = fc.apply(SPECIES.length()); @@ -7065,7 +7116,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void SelectFromInt256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromIntVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -7084,7 +7135,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousInt256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousIntVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7100,7 +7151,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringInt256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringIntVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7114,7 +7165,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsInt256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsIntVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7128,7 +7179,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsInt256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsIntVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7144,7 +7195,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeInt256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeIntVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7166,7 +7217,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountInt256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountIntVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7177,7 +7228,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, IntVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7191,7 +7242,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueInt256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueIntVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7202,7 +7253,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, IntVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7216,7 +7267,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueInt256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueIntVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7227,11 +7278,11 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, IntVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressInt256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressIntVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7259,7 +7310,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeInt256VectorTestsSmokeTest(int offset) { + static void indexInRangeIntVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7273,7 +7324,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongInt256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongIntVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7300,14 +7351,14 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundInt256VectorTestsSmokeTest(int length) { + static void loopBoundIntVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongInt256VectorTestsSmokeTest(int _length) { + static void loopBoundLongIntVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7315,21 +7366,21 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeInt256VectorTestsSmokeTest() { + static void ElementSizeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Integer.SIZE); } @Test - static void VectorShapeInt256VectorTestsSmokeTest() { + static void VectorShapeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesInt256VectorTestsSmokeTest() { + static void ShapeWithLanesIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(int.class); @@ -7337,32 +7388,32 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeInt256VectorTestsSmokeTest() { + static void ElementTypeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementType() == int.class); } @Test - static void SpeciesElementSizeInt256VectorTestsSmokeTest() { + static void SpeciesElementSizeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementSize() == Integer.SIZE); } @Test - static void VectorTypeInt256VectorTestsSmokeTest() { + static void VectorTypeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesInt256VectorTestsSmokeTest() { + static void WithLanesIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(int.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeInt256VectorTestsSmokeTest() { + static void WithShapeIntVector256TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7370,7 +7421,7 @@ public class Int256VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueInt256VectorTestsSmokeTest() { + static void MaskAllTrueIntVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/IntVector512LoadStoreTests.java index 1479dc57df5..189a5540f7d 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Int512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation IntVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Int512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class IntVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = IntVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/IntVector512Tests.java similarity index 87% rename from test/jdk/jdk/incubator/vector/Int128VectorTests.java rename to test/jdk/jdk/incubator/vector/IntVector512Tests.java index 1f254abbf0c..5ceba4e88ec 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,10 +56,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Int128VectorTests extends AbstractVectorTest { +public class IntVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = - IntVector.SPECIES_128; + IntVector.SPECIES_512; static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); static void assertEquals(int actual, int expected) { @@ -121,7 +121,7 @@ public class Int128VectorTests extends AbstractVectorTest { private static final int UMIN_IDENTITY = (int)-1; // Maximum unsigned value private static final int XOR_IDENTITY = (int)0; - static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); static void assertArraysStrictlyEquals(int[] r, int[] a) { for (int i = 0; i < a.length; i++) { @@ -1531,6 +1531,59 @@ public class Int128VectorTests extends AbstractVectorTest { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1547,9 +1600,6 @@ public class Int128VectorTests extends AbstractVectorTest { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1663,11 +1713,11 @@ public class Int128VectorTests extends AbstractVectorTest { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1680,15 +1730,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::ADD); + assertArraysEquals(r, a, b, IntVector512Tests::ADD); } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt128VectorTests(IntFunction fa, IntFunction fb) { + static void addIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1699,11 +1749,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::add); + assertArraysEquals(r, a, b, IntVector512Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1719,11 +1769,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntVector512Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1737,15 +1787,15 @@ public class Int128VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int128VectorTests::add); + assertArraysEquals(r, a, b, mask, IntVector512Tests::add); } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void SUBInt128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1758,15 +1808,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::SUB); + assertArraysEquals(r, a, b, IntVector512Tests::SUB); } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt128VectorTests(IntFunction fa, IntFunction fb) { + static void subIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1777,11 +1827,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::sub); + assertArraysEquals(r, a, b, IntVector512Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void SUBInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1797,11 +1847,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntVector512Tests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1815,15 +1865,15 @@ public class Int128VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int128VectorTests::sub); + assertArraysEquals(r, a, b, mask, IntVector512Tests::sub); } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MULInt128VectorTests(IntFunction fa, IntFunction fb) { + static void MULIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1836,15 +1886,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::MUL); + assertArraysEquals(r, a, b, IntVector512Tests::MUL); } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt128VectorTests(IntFunction fa, IntFunction fb) { + static void mulIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1855,11 +1905,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::mul); + assertArraysEquals(r, a, b, IntVector512Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void MULInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1875,11 +1925,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntVector512Tests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1893,7 +1943,7 @@ public class Int128VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int128VectorTests::mul); + assertArraysEquals(r, a, b, mask, IntVector512Tests::mul); } static int DIV(int a, int b) { @@ -1901,7 +1951,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void DIVInt128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1916,7 +1966,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::DIV); + assertArraysEquals(r, a, b, IntVector512Tests::DIV); } static int div(int a, int b) { @@ -1924,7 +1974,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void divInt128VectorTests(IntFunction fa, IntFunction fb) { + static void divIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1939,11 +1989,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::div); + assertArraysEquals(r, a, b, IntVector512Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void DIVInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1961,11 +2011,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntVector512Tests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1983,15 +2033,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::div); + assertArraysEquals(r, a, b, mask, IntVector512Tests::div); } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void FIRST_NONZEROInt128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2004,11 +2054,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, IntVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void FIRST_NONZEROInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2024,7 +2074,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntVector512Tests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -2032,7 +2082,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ANDIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2045,7 +2095,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::AND); + assertArraysEquals(r, a, b, IntVector512Tests::AND); } static int and(int a, int b) { @@ -2053,7 +2103,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void andInt128VectorTests(IntFunction fa, IntFunction fb) { + static void andIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2064,11 +2114,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::and); + assertArraysEquals(r, a, b, IntVector512Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2084,7 +2134,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::AND); + assertArraysEquals(r, a, b, mask, IntVector512Tests::AND); } static int AND_NOT(int a, int b) { @@ -2092,7 +2142,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void AND_NOTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2105,11 +2155,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntVector512Tests::AND_NOT); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void AND_NOTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2125,7 +2175,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, IntVector512Tests::AND_NOT); } static int OR(int a, int b) { @@ -2133,7 +2183,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ORIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2146,7 +2196,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::OR); + assertArraysEquals(r, a, b, IntVector512Tests::OR); } static int or(int a, int b) { @@ -2154,7 +2204,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void orInt128VectorTests(IntFunction fa, IntFunction fb) { + static void orIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2165,11 +2215,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::or); + assertArraysEquals(r, a, b, IntVector512Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2185,7 +2235,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::OR); + assertArraysEquals(r, a, b, mask, IntVector512Tests::OR); } static int XOR(int a, int b) { @@ -2193,7 +2243,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void XORInt128VectorTests(IntFunction fa, IntFunction fb) { + static void XORIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2206,11 +2256,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::XOR); + assertArraysEquals(r, a, b, IntVector512Tests::XOR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void XORInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2226,7 +2276,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntVector512Tests::XOR); } static int COMPRESS_BITS(int a, int b) { @@ -2234,7 +2284,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void COMPRESS_BITSInt128VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2247,11 +2297,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, IntVector512Tests::COMPRESS_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void COMPRESS_BITSInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2267,7 +2317,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, IntVector512Tests::COMPRESS_BITS); } static int EXPAND_BITS(int a, int b) { @@ -2275,7 +2325,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void EXPAND_BITSInt128VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2288,11 +2338,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, IntVector512Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void EXPAND_BITSInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2308,11 +2358,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, IntVector512Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2322,11 +2372,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2339,11 +2389,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::add); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2353,11 +2403,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2370,11 +2420,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::sub); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2434,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2401,11 +2451,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::mul); } @Test(dataProvider = "intBinaryOpProvider") - static void divInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2436,11 +2486,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::div); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2450,11 +2500,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void orInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2464,11 +2514,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2481,11 +2531,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2495,11 +2545,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void andInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2509,11 +2559,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2526,11 +2576,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntVector512Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2540,11 +2590,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntVector512Tests::OR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2557,11 +2607,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector512Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDIntVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2571,11 +2621,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntVector512Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDIntVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2588,7 +2638,7 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector512Tests::ADD); } static int LSHL(int a, int b) { @@ -2596,7 +2646,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2609,11 +2659,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::LSHL); + assertArraysEquals(r, a, b, IntVector512Tests::LSHL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2629,7 +2679,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, IntVector512Tests::LSHL); } static int ASHR(int a, int b) { @@ -2637,7 +2687,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2650,11 +2700,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::ASHR); + assertArraysEquals(r, a, b, IntVector512Tests::ASHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2670,7 +2720,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, IntVector512Tests::ASHR); } static int LSHR(int a, int b) { @@ -2678,7 +2728,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2691,11 +2741,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::LSHR); + assertArraysEquals(r, a, b, IntVector512Tests::LSHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2711,7 +2761,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, IntVector512Tests::LSHR); } static int LSHL_unary(int a, int b) { @@ -2719,7 +2769,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLIntVector512TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2731,11 +2781,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntVector512Tests::LSHL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2750,7 +2800,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector512Tests::LSHL_unary); } static int LSHR_unary(int a, int b) { @@ -2758,7 +2808,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRIntVector512TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2770,11 +2820,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntVector512Tests::LSHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2789,7 +2839,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector512Tests::LSHR_unary); } static int ASHR_unary(int a, int b) { @@ -2797,7 +2847,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRIntVector512TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2809,11 +2859,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntVector512Tests::ASHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2828,7 +2878,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector512Tests::ASHR_unary); } static int ROR(int a, int b) { @@ -2836,7 +2886,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt128VectorTests(IntFunction fa, IntFunction fb) { + static void RORIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2849,11 +2899,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::ROR); + assertArraysEquals(r, a, b, IntVector512Tests::ROR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2869,7 +2919,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::ROR); + assertArraysEquals(r, a, b, mask, IntVector512Tests::ROR); } static int ROL(int a, int b) { @@ -2877,7 +2927,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ROLIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2890,11 +2940,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::ROL); + assertArraysEquals(r, a, b, IntVector512Tests::ROL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2910,7 +2960,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::ROL); + assertArraysEquals(r, a, b, mask, IntVector512Tests::ROL); } static int ROR_unary(int a, int b) { @@ -2918,7 +2968,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORIntVector512TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2930,11 +2980,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, IntVector512Tests::ROR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORIntVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2949,7 +2999,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector512Tests::ROR_unary); } static int ROL_unary(int a, int b) { @@ -2957,7 +3007,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLIntVector512TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2969,11 +3019,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, IntVector512Tests::ROL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2988,14 +3038,14 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector512Tests::ROL_unary); } static int LSHR_binary_const(int a) { return (int)((a >>> CONST_SHIFT)); } @Test(dataProvider = "intUnaryOpProvider") - static void LSHRInt128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRIntVector512TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3006,11 +3056,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, IntVector512Tests::LSHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHRInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRIntVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3024,7 +3074,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector512Tests::LSHR_binary_const); } static int LSHL_binary_const(int a) { @@ -3032,7 +3082,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LSHLInt128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLIntVector512TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3043,11 +3093,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, IntVector512Tests::LSHL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHLInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLIntVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3061,7 +3111,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector512Tests::LSHL_binary_const); } static int ASHR_binary_const(int a) { @@ -3069,7 +3119,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ASHRInt128VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRIntVector512TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3080,11 +3130,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, IntVector512Tests::ASHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ASHRInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRIntVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3098,7 +3148,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector512Tests::ASHR_binary_const); } static int ROR_binary_const(int a) { @@ -3106,7 +3156,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void RORInt128VectorTestsScalarShiftConst(IntFunction fa) { + static void RORIntVector512TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3117,11 +3167,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, IntVector512Tests::ROR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void RORInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORIntVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3135,7 +3185,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector512Tests::ROR_binary_const); } static int ROL_binary_const(int a) { @@ -3143,7 +3193,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ROLInt128VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLIntVector512TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3154,11 +3204,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, IntVector512Tests::ROL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ROLInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLIntVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3172,14 +3222,14 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector512Tests::ROL_binary_const); } static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MINInt128VectorTestsWithMemOp(IntFunction fa) { + static void MINIntVector512TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int128VectorTests::MIN); + assertArraysEquals(r, a, (int)10, IntVector512Tests::MIN); } static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void minInt128VectorTestsWithMemOp(IntFunction fa) { + static void minIntVector512TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int128VectorTests::min); + assertArraysEquals(r, a, (int)10, IntVector512Tests::min); } static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINIntVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,13 +3276,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int128VectorTests::MIN); + assertArraysEquals(r, a, (int)10, mask, IntVector512Tests::MIN); } static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MAXInt128VectorTestsWithMemOp(IntFunction fa) { + static void MAXIntVector512TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3243,13 +3293,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int128VectorTests::MAX); + assertArraysEquals(r, a, (int)10, IntVector512Tests::MAX); } static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void maxInt128VectorTestsWithMemOp(IntFunction fa) { + static void maxIntVector512TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3260,13 +3310,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int128VectorTests::max); + assertArraysEquals(r, a, (int)10, IntVector512Tests::max); } static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXIntVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3279,15 +3329,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int128VectorTests::MAX); + assertArraysEquals(r, a, (int)10, mask, IntVector512Tests::MAX); } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt128VectorTests(IntFunction fa, IntFunction fb) { + static void MINIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3300,15 +3350,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::MIN); + assertArraysEquals(r, a, b, IntVector512Tests::MIN); } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt128VectorTests(IntFunction fa, IntFunction fb) { + static void minIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3319,15 +3369,15 @@ public class Int128VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::min); + assertArraysEquals(r, a, b, IntVector512Tests::min); } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3340,15 +3390,15 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::MAX); + assertArraysEquals(r, a, b, IntVector512Tests::MAX); } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maxIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3359,7 +3409,7 @@ public class Int128VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int128VectorTests::max); + assertArraysEquals(r, a, b, IntVector512Tests::max); } static int UMIN(int a, int b) { @@ -3367,7 +3417,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMINInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UMINIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3380,11 +3430,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::UMIN); + assertArraysEquals(r, a, b, IntVector512Tests::UMIN); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMINInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3400,7 +3450,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, IntVector512Tests::UMIN); } static int UMAX(int a, int b) { @@ -3408,7 +3458,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMAXInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3421,11 +3471,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::UMAX); + assertArraysEquals(r, a, b, IntVector512Tests::UMAX); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMAXInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3441,7 +3491,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, IntVector512Tests::UMAX); } static int SADD(int a, int b) { @@ -3449,7 +3499,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SADDInt128VectorTests(IntFunction fa, IntFunction fb) { + static void SADDIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3462,11 +3512,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::SADD); + assertArraysEquals(r, a, b, IntVector512Tests::SADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SADDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3482,7 +3532,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::SADD); + assertArraysEquals(r, a, b, mask, IntVector512Tests::SADD); } static int SSUB(int a, int b) { @@ -3490,7 +3540,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SSUBInt128VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3503,11 +3553,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::SSUB); + assertArraysEquals(r, a, b, IntVector512Tests::SSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SSUBInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3523,7 +3573,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, IntVector512Tests::SSUB); } static int SUADD(int a, int b) { @@ -3531,7 +3581,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUADDInt128VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3544,11 +3594,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::SUADD); + assertArraysEquals(r, a, b, IntVector512Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUADDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3564,7 +3614,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, IntVector512Tests::SUADD); } static int SUSUB(int a, int b) { @@ -3572,7 +3622,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUSUBInt128VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3585,11 +3635,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::SUSUB); + assertArraysEquals(r, a, b, IntVector512Tests::SUSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUSUBInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3605,11 +3655,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, IntVector512Tests::SUSUB); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3619,11 +3669,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::MIN); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3633,11 +3683,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::min); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3647,11 +3697,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::MAX); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3661,10 +3711,10 @@ public class Int128VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntVector512Tests::max); } @Test(dataProvider = "intSaturatingBinaryOpAssocProvider") - static void SUADDAssocInt128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocIntVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -3681,11 +3731,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Int128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, IntVector512Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3706,13 +3756,13 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Int128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntVector512Tests::SUADD); } static int ANDReduce(int[] a, int idx) { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3721,14 +3771,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ANDReduceAll(int[] a) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ANDReduceInt128VectorTests(IntFunction fa) { + static void ANDReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3739,12 +3789,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::ANDReduce, Int128VectorTests::ANDReduceAll); + IntVector512Tests::ANDReduce, IntVector512Tests::ANDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3752,20 +3802,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = AND_IDENTITY; - assertEquals((int) (id & id), id, + assertEquals((int) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id & x), x); - assertEquals((int) (x & id), x); + assertEquals((int) (scalar_and(id, x)), x); + assertEquals((int) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id & x), x, + assertEquals((int) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x & id), x, + assertEquals((int) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3774,7 +3824,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3783,14 +3833,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ANDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3803,18 +3853,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::ANDReduceMasked, Int128VectorTests::ANDReduceAllMasked); + IntVector512Tests::ANDReduceMasked, IntVector512Tests::ANDReduceAllMasked); } static int ORReduce(int[] a, int idx) { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3823,14 +3873,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ORReduceAll(int[] a) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ORReduceInt128VectorTests(IntFunction fa) { + static void ORReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3841,12 +3891,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::ORReduce, Int128VectorTests::ORReduceAll); + IntVector512Tests::ORReduce, IntVector512Tests::ORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3854,20 +3904,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = OR_IDENTITY; - assertEquals((int) (id | id), id, + assertEquals((int) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id | x), x); - assertEquals((int) (x | id), x); + assertEquals((int) (scalar_or(id, x)), x); + assertEquals((int) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id | x), x, + assertEquals((int) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x | id), x, + assertEquals((int) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3876,7 +3926,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3885,14 +3935,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3905,18 +3955,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::ORReduceMasked, Int128VectorTests::ORReduceAllMasked); + IntVector512Tests::ORReduceMasked, IntVector512Tests::ORReduceAllMasked); } static int XORReduce(int[] a, int idx) { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3925,14 +3975,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int XORReduceAll(int[] a) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void XORReduceInt128VectorTests(IntFunction fa) { + static void XORReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3943,12 +3993,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::XORReduce, Int128VectorTests::XORReduceAll); + IntVector512Tests::XORReduce, IntVector512Tests::XORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3956,20 +4006,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = XOR_IDENTITY; - assertEquals((int) (id ^ id), id, + assertEquals((int) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id ^ x), x); - assertEquals((int) (x ^ id), x); + assertEquals((int) (scalar_xor(id, x)), x); + assertEquals((int) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id ^ x), x, + assertEquals((int) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x ^ id), x, + assertEquals((int) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3978,7 +4028,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3987,14 +4037,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void XORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4007,18 +4057,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::XORReduceMasked, Int128VectorTests::XORReduceAllMasked); + IntVector512Tests::XORReduceMasked, IntVector512Tests::XORReduceAllMasked); } static int ADDReduce(int[] a, int idx) { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4027,14 +4077,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ADDReduceAll(int[] a) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceInt128VectorTests(IntFunction fa) { + static void ADDReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4045,12 +4095,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::ADDReduce, Int128VectorTests::ADDReduceAll); + IntVector512Tests::ADDReduce, IntVector512Tests::ADDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4058,20 +4108,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = ADD_IDENTITY; - assertEquals((int) (id + id), id, + assertEquals((int) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id + x), x); - assertEquals((int) (x + id), x); + assertEquals((int) (scalar_add(id, x)), x); + assertEquals((int) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id + x), x, + assertEquals((int) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x + id), x, + assertEquals((int) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4080,7 +4130,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4089,14 +4139,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int ADDReduceAllMasked(int[] a, boolean[] mask) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4109,18 +4159,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::ADDReduceMasked, Int128VectorTests::ADDReduceAllMasked); + IntVector512Tests::ADDReduceMasked, IntVector512Tests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4129,14 +4179,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MULReduceAll(int[] a) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MULReduceInt128VectorTests(IntFunction fa) { + static void MULReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4147,12 +4197,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::MULReduce, Int128VectorTests::MULReduceAll); + IntVector512Tests::MULReduce, IntVector512Tests::MULReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4160,20 +4210,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MUL_IDENTITY; - assertEquals((int) (id * id), id, + assertEquals((int) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id * x), x); - assertEquals((int) (x * id), x); + assertEquals((int) (scalar_mul(id, x)), x); + assertEquals((int) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id * x), x, + assertEquals((int) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x * id), x, + assertEquals((int) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4182,7 +4232,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4191,14 +4241,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MULReduceAllMasked(int[] a, boolean[] mask) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MULReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4211,18 +4261,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::MULReduceMasked, Int128VectorTests::MULReduceAllMasked); + IntVector512Tests::MULReduceMasked, IntVector512Tests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4231,14 +4281,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MINReduceAll(int[] a) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MINReduceInt128VectorTests(IntFunction fa) { + static void MINReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4249,12 +4299,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::MINReduce, Int128VectorTests::MINReduceAll); + IntVector512Tests::MINReduce, IntVector512Tests::MINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4262,20 +4312,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MIN_IDENTITY; - assertEquals((int) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.min(id, x), x); - assertEquals((int) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4284,7 +4334,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4293,14 +4343,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MINReduceAllMasked(int[] a, boolean[] mask) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4313,18 +4363,18 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::MINReduceMasked, Int128VectorTests::MINReduceAllMasked); + IntVector512Tests::MINReduceMasked, IntVector512Tests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4333,14 +4383,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MAXReduceAll(int[] a) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MAXReduceInt128VectorTests(IntFunction fa) { + static void MAXReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4351,12 +4401,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::MAXReduce, Int128VectorTests::MAXReduceAll); + IntVector512Tests::MAXReduce, IntVector512Tests::MAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4364,20 +4414,20 @@ public class Int128VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MAX_IDENTITY; - assertEquals((int) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.max(id, x), x); - assertEquals((int) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4386,7 +4436,7 @@ public class Int128VectorTests extends AbstractVectorTest { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4395,14 +4445,14 @@ public class Int128VectorTests extends AbstractVectorTest { static int MAXReduceAllMasked(int[] a, boolean[] mask) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4415,12 +4465,12 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::MAXReduceMasked, Int128VectorTests::MAXReduceAllMasked); + IntVector512Tests::MAXReduceMasked, IntVector512Tests::MAXReduceAllMasked); } static int UMINReduce(int[] a, int idx) { @@ -4442,7 +4492,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMINReduceInt128VectorTests(IntFunction fa) { + static void UMINReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4458,7 +4508,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::UMINReduce, Int128VectorTests::UMINReduceAll); + IntVector512Tests::UMINReduce, IntVector512Tests::UMINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4504,7 +4554,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4522,7 +4572,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::UMINReduceMasked, Int128VectorTests::UMINReduceAllMasked); + IntVector512Tests::UMINReduceMasked, IntVector512Tests::UMINReduceAllMasked); } static int UMAXReduce(int[] a, int idx) { @@ -4544,7 +4594,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMAXReduceInt128VectorTests(IntFunction fa) { + static void UMAXReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4560,7 +4610,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::UMAXReduce, Int128VectorTests::UMAXReduceAll); + IntVector512Tests::UMAXReduce, IntVector512Tests::UMAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4606,7 +4656,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4624,7 +4674,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::UMAXReduceMasked, Int128VectorTests::UMAXReduceAllMasked); + IntVector512Tests::UMAXReduceMasked, IntVector512Tests::UMAXReduceAllMasked); } static int FIRST_NONZEROReduce(int[] a, int idx) { @@ -4646,7 +4696,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void FIRST_NONZEROReduceInt128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4662,7 +4712,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::FIRST_NONZEROReduce, Int128VectorTests::FIRST_NONZEROReduceAll); + IntVector512Tests::FIRST_NONZEROReduce, IntVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4708,7 +4758,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void FIRST_NONZEROReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4726,7 +4776,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::FIRST_NONZEROReduceMasked, Int128VectorTests::FIRST_NONZEROReduceAllMasked); + IntVector512Tests::FIRST_NONZEROReduceMasked, IntVector512Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4739,7 +4789,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueInt128VectorTests(IntFunction fm) { + static void anyTrueIntVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4750,7 +4800,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntVector512Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4763,7 +4813,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueInt128VectorTests(IntFunction fm) { + static void allTrueIntVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4774,7 +4824,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntVector512Tests::allTrue); } static int SUADDReduce(int[] a, int idx) { @@ -4796,7 +4846,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingUnaryOpProvider") - static void SUADDReduceInt128VectorTests(IntFunction fa) { + static void SUADDReduceIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4812,7 +4862,7 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int128VectorTests::SUADDReduce, Int128VectorTests::SUADDReduceAll); + IntVector512Tests::SUADDReduce, IntVector512Tests::SUADDReduceAll); } @Test(dataProvider = "intSaturatingUnaryOpProvider") @@ -4857,7 +4907,7 @@ public class Int128VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "intSaturatingUnaryOpMaskProvider") - static void SUADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4875,11 +4925,11 @@ public class Int128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::SUADDReduceMasked, Int128VectorTests::SUADDReduceAllMasked); + IntVector512Tests::SUADDReduceMasked, IntVector512Tests::SUADDReduceAllMasked); } @Test(dataProvider = "intBinaryOpProvider") - static void withInt128VectorTests(IntFunction fa, IntFunction fb) { + static void withIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -4902,7 +4952,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_DEFAULTInt128VectorTests(IntFunction fa) { + static void IS_DEFAULTIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4919,7 +4969,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_DEFAULTMaskedInt128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4943,7 +4993,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_NEGATIVEInt128VectorTests(IntFunction fa) { + static void IS_NEGATIVEIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4960,7 +5010,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_NEGATIVEMaskedInt128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4980,7 +5030,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void LTIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4999,7 +5049,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ltIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5018,7 +5068,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5041,7 +5091,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void GTIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5060,7 +5110,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5083,7 +5133,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void EQInt128VectorTests(IntFunction fa, IntFunction fb) { + static void EQIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5102,7 +5152,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void eqInt128VectorTests(IntFunction fa, IntFunction fb) { + static void eqIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5121,7 +5171,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5144,7 +5194,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void NEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void NEIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5163,7 +5213,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void NEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5186,7 +5236,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void LEIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5205,7 +5255,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5228,7 +5278,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void GEIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5247,7 +5297,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5270,7 +5320,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5289,7 +5339,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5312,7 +5362,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5331,7 +5381,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5354,7 +5404,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5373,7 +5423,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5396,7 +5446,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntVector512Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5415,7 +5465,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5438,7 +5488,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5448,13 +5498,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5468,13 +5518,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void LTInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5484,13 +5534,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTIntVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5504,13 +5554,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (int)((long)b[i])))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5520,13 +5570,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5540,13 +5590,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5556,13 +5606,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQIntVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5576,7 +5626,7 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (int)((long)b[i])))); } } } @@ -5586,7 +5636,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt128VectorTests(IntFunction fa, IntFunction fb, + static void blendIntVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5602,11 +5652,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int128VectorTests::blend); + assertArraysEquals(r, a, b, mask, IntVector512Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void RearrangeInt128VectorTests(IntFunction fa, + static void RearrangeIntVector512Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void RearrangeInt128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeIntVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -5641,7 +5691,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void compressInt128VectorTests(IntFunction fa, + static void compressIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5659,7 +5709,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void expandInt128VectorTests(IntFunction fa, + static void expandIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5677,7 +5727,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void getInt128VectorTests(IntFunction fa) { + static void getIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5833,7 +5883,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastInt128VectorTests(IntFunction fa) { + static void BroadcastIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5847,7 +5897,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZeroInt128VectorTests(IntFunction fa) { + static void ZeroIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5872,7 +5922,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void sliceUnaryInt128VectorTests(IntFunction fa) { + static void sliceUnaryIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5883,7 +5933,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntVector512Tests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { @@ -5900,7 +5950,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void sliceBinaryInt128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryIntVector512TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5913,7 +5963,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Int128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntVector512Tests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { @@ -5930,7 +5980,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void sliceInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5947,7 +5997,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Int128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, IntVector512Tests::slice); } static int[] unsliceUnary(int[] a, int origin, int idx) { @@ -5964,7 +6014,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void unsliceUnaryInt128VectorTests(IntFunction fa) { + static void unsliceUnaryIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5975,7 +6025,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntVector512Tests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { @@ -6001,7 +6051,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void unsliceBinaryInt128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryIntVector512TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -6015,7 +6065,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Int128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntVector512Tests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { @@ -6055,7 +6105,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void unsliceInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6072,7 +6122,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Int128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, IntVector512Tests::unslice); } static int BITWISE_BLEND(int a, int b, int c) { @@ -6084,7 +6134,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6116,11 +6166,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, IntVector512Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6138,11 +6188,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6153,11 +6203,11 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6168,11 +6218,11 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntVector512Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Int128VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector512Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6217,11 +6267,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6236,11 +6286,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6251,11 +6301,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6266,11 +6316,11 @@ public class Int128VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector512Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6284,19 +6334,19 @@ public class Int128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntVector512Tests::BITWISE_BLEND); } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void NEGInt128VectorTests(IntFunction fa) { + static void NEGIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6307,11 +6357,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::NEG); + assertArraysEquals(r, a, IntVector512Tests::NEG); } @Test(dataProvider = "intUnaryOpProvider") - static void negInt128VectorTests(IntFunction fa) { + static void negIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6322,11 +6372,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::neg); + assertArraysEquals(r, a, IntVector512Tests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NEGMaskedInt128VectorTests(IntFunction fa, + static void NEGMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6340,19 +6390,19 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::NEG); + assertArraysEquals(r, a, mask, IntVector512Tests::NEG); } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void ABSInt128VectorTests(IntFunction fa) { + static void ABSIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6363,11 +6413,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::ABS); + assertArraysEquals(r, a, IntVector512Tests::ABS); } @Test(dataProvider = "intUnaryOpProvider") - static void absInt128VectorTests(IntFunction fa) { + static void absIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6378,11 +6428,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::abs); + assertArraysEquals(r, a, IntVector512Tests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ABSMaskedInt128VectorTests(IntFunction fa, + static void ABSMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6396,7 +6446,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::ABS); + assertArraysEquals(r, a, mask, IntVector512Tests::ABS); } static int NOT(int a) { @@ -6408,7 +6458,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void NOTInt128VectorTests(IntFunction fa) { + static void NOTIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6419,11 +6469,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::NOT); + assertArraysEquals(r, a, IntVector512Tests::NOT); } @Test(dataProvider = "intUnaryOpProvider") - static void notInt128VectorTests(IntFunction fa) { + static void notIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6434,11 +6484,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::not); + assertArraysEquals(r, a, IntVector512Tests::not); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NOTMaskedInt128VectorTests(IntFunction fa, + static void NOTMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6452,7 +6502,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::NOT); + assertArraysEquals(r, a, mask, IntVector512Tests::NOT); } static int ZOMO(int a) { @@ -6460,7 +6510,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZOMOInt128VectorTests(IntFunction fa) { + static void ZOMOIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6471,11 +6521,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::ZOMO); + assertArraysEquals(r, a, IntVector512Tests::ZOMO); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ZOMOMaskedInt128VectorTests(IntFunction fa, + static void ZOMOMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6489,7 +6539,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntVector512Tests::ZOMO); } static int BIT_COUNT(int a) { @@ -6497,7 +6547,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BIT_COUNTInt128VectorTests(IntFunction fa) { + static void BIT_COUNTIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6508,11 +6558,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, IntVector512Tests::BIT_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void BIT_COUNTMaskedInt128VectorTests(IntFunction fa, + static void BIT_COUNTMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6526,7 +6576,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, IntVector512Tests::BIT_COUNT); } static int TRAILING_ZEROS_COUNT(int a) { @@ -6534,7 +6584,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void TRAILING_ZEROS_COUNTInt128VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6545,11 +6595,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector512Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedInt128VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6563,7 +6613,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector512Tests::TRAILING_ZEROS_COUNT); } static int LEADING_ZEROS_COUNT(int a) { @@ -6571,7 +6621,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LEADING_ZEROS_COUNTInt128VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6582,11 +6632,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector512Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedInt128VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6600,7 +6650,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector512Tests::LEADING_ZEROS_COUNT); } static int REVERSE(int a) { @@ -6608,7 +6658,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSEInt128VectorTests(IntFunction fa) { + static void REVERSEIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6619,11 +6669,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::REVERSE); + assertArraysEquals(r, a, IntVector512Tests::REVERSE); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSEMaskedInt128VectorTests(IntFunction fa, + static void REVERSEMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6637,7 +6687,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::REVERSE); + assertArraysEquals(r, a, mask, IntVector512Tests::REVERSE); } static int REVERSE_BYTES(int a) { @@ -6645,7 +6695,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSE_BYTESInt128VectorTests(IntFunction fa) { + static void REVERSE_BYTESIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6656,11 +6706,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, IntVector512Tests::REVERSE_BYTES); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedInt128VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedIntVector512Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6674,7 +6724,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, IntVector512Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6682,7 +6732,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6695,7 +6745,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::band); + assertArraysEquals(r, a, b, IntVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6703,7 +6753,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6716,7 +6766,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::bor); + assertArraysEquals(r, a, b, IntVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6724,7 +6774,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6737,7 +6787,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::bxor); + assertArraysEquals(r, a, b, IntVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6745,7 +6795,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6758,7 +6808,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::bandNot); + assertArraysEquals(r, a, b, IntVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6766,7 +6816,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6779,7 +6829,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int128VectorTests::beq); + assertArraysEquals(r, a, b, IntVector512Tests::beq); } static boolean unot(boolean a) { @@ -6787,7 +6837,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotInt128VectorTests(IntFunction fa) { + static void masknotIntVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6798,7 +6848,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::unot); + assertArraysEquals(r, a, IntVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6815,7 +6865,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongInt128VectorTests(IntFunction fa) { + static void maskFromToLongIntVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6829,7 +6879,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltIntVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6839,13 +6889,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpProvider") - static void eqInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqIntVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6855,13 +6905,13 @@ public class Int128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intUnaryOpProvider") - static void toIntArrayInt128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6872,7 +6922,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toLongArrayInt128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6883,7 +6933,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toDoubleArrayInt128VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6894,7 +6944,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toStringInt128VectorTestsSmokeTest(IntFunction fa) { + static void toStringIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6907,7 +6957,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void hashCodeInt128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6924,7 +6974,7 @@ public class Int128VectorTests extends AbstractVectorTest { static long ADDReduceLong(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6933,14 +6983,14 @@ public class Int128VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(int[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((int)res, (int)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceLongInt128VectorTests(IntFunction fa) { + static void ADDReduceLongIntVector512Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6951,19 +7001,20 @@ public class Int128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Int128VectorTests::ADDReduceLong, Int128VectorTests::ADDReduceAllLong); + IntVector512Tests::ADDReduceLong, IntVector512Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6972,14 +7023,14 @@ public class Int128VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(int[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((int)res, (int)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceLongInt128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongIntVector512TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6992,16 +7043,16 @@ public class Int128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Int128VectorTests::ADDReduceLongMasked, Int128VectorTests::ADDReduceAllLongMasked); + IntVector512Tests::ADDReduceLongMasked, IntVector512Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastLongInt128VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongIntVector512TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7012,7 +7063,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendIntVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -7026,12 +7077,12 @@ public class Int128VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector512Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void SelectFromInt128VectorTests(IntFunction fa, + static void SelectFromIntVector512Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -7047,7 +7098,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorInt128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorIntVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] idx = fc.apply(SPECIES.length()); @@ -7065,7 +7116,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void SelectFromInt128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromIntVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -7084,7 +7135,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousInt128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousIntVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7100,7 +7151,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringInt128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringIntVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7114,7 +7165,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsInt128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsIntVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7128,7 +7179,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsInt128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsIntVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7144,7 +7195,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeInt128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeIntVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7166,7 +7217,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountInt128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountIntVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7177,7 +7228,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, IntVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7191,7 +7242,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueInt128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueIntVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7202,7 +7253,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, IntVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7216,7 +7267,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueInt128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueIntVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7227,11 +7278,11 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, IntVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressInt128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressIntVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7259,7 +7310,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeInt128VectorTestsSmokeTest(int offset) { + static void indexInRangeIntVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7273,7 +7324,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongInt128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongIntVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7300,14 +7351,14 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundInt128VectorTestsSmokeTest(int length) { + static void loopBoundIntVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongInt128VectorTestsSmokeTest(int _length) { + static void loopBoundLongIntVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7315,21 +7366,21 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeInt128VectorTestsSmokeTest() { + static void ElementSizeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Integer.SIZE); } @Test - static void VectorShapeInt128VectorTestsSmokeTest() { + static void VectorShapeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); - assert(vsh.equals(VectorShape.S_128_BIT)); + assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesInt128VectorTestsSmokeTest() { + static void ShapeWithLanesIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(int.class); @@ -7337,32 +7388,32 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeInt128VectorTestsSmokeTest() { + static void ElementTypeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementType() == int.class); } @Test - static void SpeciesElementSizeInt128VectorTestsSmokeTest() { + static void SpeciesElementSizeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementSize() == Integer.SIZE); } @Test - static void VectorTypeInt128VectorTestsSmokeTest() { + static void VectorTypeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesInt128VectorTestsSmokeTest() { + static void WithLanesIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(int.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeInt128VectorTestsSmokeTest() { + static void WithShapeIntVector512TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7370,7 +7421,7 @@ public class Int128VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueInt128VectorTestsSmokeTest() { + static void MaskAllTrueIntVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/IntVector64LoadStoreTests.java index 5dfc0ac2f4f..418a8bb8581 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Int64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation IntVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Int64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class IntVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = IntVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/IntVector64Tests.java similarity index 87% rename from test/jdk/jdk/incubator/vector/Int64VectorTests.java rename to test/jdk/jdk/incubator/vector/IntVector64Tests.java index 6eb6322ba2b..9d3849a2c04 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Int64VectorTests extends AbstractVectorTest { +public class IntVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = IntVector.SPECIES_64; @@ -1531,6 +1531,59 @@ public class Int64VectorTests extends AbstractVectorTest { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1547,9 +1600,6 @@ public class Int64VectorTests extends AbstractVectorTest { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1663,11 +1713,11 @@ public class Int64VectorTests extends AbstractVectorTest { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1680,15 +1730,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::ADD); + assertArraysEquals(r, a, b, IntVector64Tests::ADD); } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt64VectorTests(IntFunction fa, IntFunction fb) { + static void addIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1699,11 +1749,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::add); + assertArraysEquals(r, a, b, IntVector64Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1719,11 +1769,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntVector64Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1737,15 +1787,15 @@ public class Int64VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int64VectorTests::add); + assertArraysEquals(r, a, b, mask, IntVector64Tests::add); } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void SUBInt64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1758,15 +1808,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::SUB); + assertArraysEquals(r, a, b, IntVector64Tests::SUB); } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt64VectorTests(IntFunction fa, IntFunction fb) { + static void subIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1777,11 +1827,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::sub); + assertArraysEquals(r, a, b, IntVector64Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void SUBInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1797,11 +1847,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntVector64Tests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1815,15 +1865,15 @@ public class Int64VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int64VectorTests::sub); + assertArraysEquals(r, a, b, mask, IntVector64Tests::sub); } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MULInt64VectorTests(IntFunction fa, IntFunction fb) { + static void MULIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1836,15 +1886,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::MUL); + assertArraysEquals(r, a, b, IntVector64Tests::MUL); } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt64VectorTests(IntFunction fa, IntFunction fb) { + static void mulIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1855,11 +1905,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::mul); + assertArraysEquals(r, a, b, IntVector64Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void MULInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1875,11 +1925,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntVector64Tests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1893,7 +1943,7 @@ public class Int64VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Int64VectorTests::mul); + assertArraysEquals(r, a, b, mask, IntVector64Tests::mul); } static int DIV(int a, int b) { @@ -1901,7 +1951,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void DIVInt64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1916,7 +1966,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::DIV); + assertArraysEquals(r, a, b, IntVector64Tests::DIV); } static int div(int a, int b) { @@ -1924,7 +1974,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void divInt64VectorTests(IntFunction fa, IntFunction fb) { + static void divIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1939,11 +1989,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::div); + assertArraysEquals(r, a, b, IntVector64Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void DIVInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1961,11 +2011,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntVector64Tests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1983,15 +2033,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::div); + assertArraysEquals(r, a, b, mask, IntVector64Tests::div); } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void FIRST_NONZEROInt64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2004,11 +2054,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, IntVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void FIRST_NONZEROInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2024,7 +2074,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntVector64Tests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -2032,7 +2082,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ANDIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2045,7 +2095,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::AND); + assertArraysEquals(r, a, b, IntVector64Tests::AND); } static int and(int a, int b) { @@ -2053,7 +2103,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void andInt64VectorTests(IntFunction fa, IntFunction fb) { + static void andIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2064,11 +2114,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::and); + assertArraysEquals(r, a, b, IntVector64Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2084,7 +2134,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::AND); + assertArraysEquals(r, a, b, mask, IntVector64Tests::AND); } static int AND_NOT(int a, int b) { @@ -2092,7 +2142,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void AND_NOTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2105,11 +2155,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntVector64Tests::AND_NOT); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void AND_NOTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2125,7 +2175,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, IntVector64Tests::AND_NOT); } static int OR(int a, int b) { @@ -2133,7 +2183,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ORIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2146,7 +2196,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::OR); + assertArraysEquals(r, a, b, IntVector64Tests::OR); } static int or(int a, int b) { @@ -2154,7 +2204,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void orInt64VectorTests(IntFunction fa, IntFunction fb) { + static void orIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2165,11 +2215,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::or); + assertArraysEquals(r, a, b, IntVector64Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2185,7 +2235,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::OR); + assertArraysEquals(r, a, b, mask, IntVector64Tests::OR); } static int XOR(int a, int b) { @@ -2193,7 +2243,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void XORInt64VectorTests(IntFunction fa, IntFunction fb) { + static void XORIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2206,11 +2256,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::XOR); + assertArraysEquals(r, a, b, IntVector64Tests::XOR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void XORInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2226,7 +2276,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntVector64Tests::XOR); } static int COMPRESS_BITS(int a, int b) { @@ -2234,7 +2284,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void COMPRESS_BITSInt64VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2247,11 +2297,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, IntVector64Tests::COMPRESS_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void COMPRESS_BITSInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2267,7 +2317,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, IntVector64Tests::COMPRESS_BITS); } static int EXPAND_BITS(int a, int b) { @@ -2275,7 +2325,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void EXPAND_BITSInt64VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2288,11 +2338,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, IntVector64Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void EXPAND_BITSInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2308,11 +2358,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, IntVector64Tests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpProvider") - static void addInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2322,11 +2372,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2339,11 +2389,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::add); } @Test(dataProvider = "intBinaryOpProvider") - static void subInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2353,11 +2403,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2370,11 +2420,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::sub); } @Test(dataProvider = "intBinaryOpProvider") - static void mulInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2384,11 +2434,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2401,11 +2451,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::mul); } @Test(dataProvider = "intBinaryOpProvider") - static void divInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2436,11 +2486,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::div); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2450,11 +2500,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void orInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2464,11 +2514,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2481,11 +2531,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ANDInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2495,11 +2545,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void andInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2509,11 +2559,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2526,11 +2576,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Int64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntVector64Tests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void ORInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2540,11 +2590,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntVector64Tests::OR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORInt64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2557,11 +2607,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector64Tests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDIntVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2571,11 +2621,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Int64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntVector64Tests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDInt64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDIntVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2588,7 +2638,7 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector64Tests::ADD); } static int LSHL(int a, int b) { @@ -2596,7 +2646,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2609,11 +2659,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::LSHL); + assertArraysEquals(r, a, b, IntVector64Tests::LSHL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2629,7 +2679,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, IntVector64Tests::LSHL); } static int ASHR(int a, int b) { @@ -2637,7 +2687,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2650,11 +2700,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::ASHR); + assertArraysEquals(r, a, b, IntVector64Tests::ASHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2670,7 +2720,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, IntVector64Tests::ASHR); } static int LSHR(int a, int b) { @@ -2678,7 +2728,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2691,11 +2741,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::LSHR); + assertArraysEquals(r, a, b, IntVector64Tests::LSHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2711,7 +2761,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, IntVector64Tests::LSHR); } static int LSHL_unary(int a, int b) { @@ -2719,7 +2769,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLInt64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLIntVector64TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2731,11 +2781,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntVector64Tests::LSHL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLInt64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2750,7 +2800,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector64Tests::LSHL_unary); } static int LSHR_unary(int a, int b) { @@ -2758,7 +2808,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRInt64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRIntVector64TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2770,11 +2820,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntVector64Tests::LSHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRInt64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2789,7 +2839,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector64Tests::LSHR_unary); } static int ASHR_unary(int a, int b) { @@ -2797,7 +2847,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRInt64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRIntVector64TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2809,11 +2859,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntVector64Tests::ASHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRInt64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2828,7 +2878,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector64Tests::ASHR_unary); } static int ROR(int a, int b) { @@ -2836,7 +2886,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt64VectorTests(IntFunction fa, IntFunction fb) { + static void RORIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2849,11 +2899,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::ROR); + assertArraysEquals(r, a, b, IntVector64Tests::ROR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2869,7 +2919,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::ROR); + assertArraysEquals(r, a, b, mask, IntVector64Tests::ROR); } static int ROL(int a, int b) { @@ -2877,7 +2927,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ROLIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2890,11 +2940,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::ROL); + assertArraysEquals(r, a, b, IntVector64Tests::ROL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2910,7 +2960,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::ROL); + assertArraysEquals(r, a, b, mask, IntVector64Tests::ROL); } static int ROR_unary(int a, int b) { @@ -2918,7 +2968,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORInt64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORIntVector64TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2930,11 +2980,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, IntVector64Tests::ROR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORInt64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORIntVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2949,7 +2999,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector64Tests::ROR_unary); } static int ROL_unary(int a, int b) { @@ -2957,7 +3007,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLInt64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLIntVector64TestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2969,11 +3019,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Int64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, IntVector64Tests::ROL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLInt64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLIntVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2988,14 +3038,14 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVector64Tests::ROL_unary); } static int LSHR_binary_const(int a) { return (int)((a >>> CONST_SHIFT)); } @Test(dataProvider = "intUnaryOpProvider") - static void LSHRInt64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRIntVector64TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3006,11 +3056,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, IntVector64Tests::LSHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHRInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRIntVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3024,7 +3074,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector64Tests::LSHR_binary_const); } static int LSHL_binary_const(int a) { @@ -3032,7 +3082,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LSHLInt64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLIntVector64TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3043,11 +3093,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, IntVector64Tests::LSHL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHLInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLIntVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3061,7 +3111,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector64Tests::LSHL_binary_const); } static int ASHR_binary_const(int a) { @@ -3069,7 +3119,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ASHRInt64VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRIntVector64TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3080,11 +3130,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, IntVector64Tests::ASHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ASHRInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRIntVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3098,7 +3148,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector64Tests::ASHR_binary_const); } static int ROR_binary_const(int a) { @@ -3106,7 +3156,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void RORInt64VectorTestsScalarShiftConst(IntFunction fa) { + static void RORIntVector64TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3117,11 +3167,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, IntVector64Tests::ROR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void RORInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORIntVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3135,7 +3185,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, IntVector64Tests::ROR_binary_const); } static int ROL_binary_const(int a) { @@ -3143,7 +3193,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ROLInt64VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLIntVector64TestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3154,11 +3204,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Int64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, IntVector64Tests::ROL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ROLInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLIntVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3172,14 +3222,14 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Int64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, IntVector64Tests::ROL_binary_const); } static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MINInt64VectorTestsWithMemOp(IntFunction fa) { + static void MINIntVector64TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int64VectorTests::MIN); + assertArraysEquals(r, a, (int)10, IntVector64Tests::MIN); } static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void minInt64VectorTestsWithMemOp(IntFunction fa) { + static void minIntVector64TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int64VectorTests::min); + assertArraysEquals(r, a, (int)10, IntVector64Tests::min); } static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINIntVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,13 +3276,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int64VectorTests::MIN); + assertArraysEquals(r, a, (int)10, mask, IntVector64Tests::MIN); } static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MAXInt64VectorTestsWithMemOp(IntFunction fa) { + static void MAXIntVector64TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3243,13 +3293,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int64VectorTests::MAX); + assertArraysEquals(r, a, (int)10, IntVector64Tests::MAX); } static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void maxInt64VectorTestsWithMemOp(IntFunction fa) { + static void maxIntVector64TestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3260,13 +3310,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, Int64VectorTests::max); + assertArraysEquals(r, a, (int)10, IntVector64Tests::max); } static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXIntVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3279,15 +3329,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, Int64VectorTests::MAX); + assertArraysEquals(r, a, (int)10, mask, IntVector64Tests::MAX); } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt64VectorTests(IntFunction fa, IntFunction fb) { + static void MINIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3300,15 +3350,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::MIN); + assertArraysEquals(r, a, b, IntVector64Tests::MIN); } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt64VectorTests(IntFunction fa, IntFunction fb) { + static void minIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3319,15 +3369,15 @@ public class Int64VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::min); + assertArraysEquals(r, a, b, IntVector64Tests::min); } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3340,15 +3390,15 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::MAX); + assertArraysEquals(r, a, b, IntVector64Tests::MAX); } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maxIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3359,7 +3409,7 @@ public class Int64VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Int64VectorTests::max); + assertArraysEquals(r, a, b, IntVector64Tests::max); } static int UMIN(int a, int b) { @@ -3367,7 +3417,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMINInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UMINIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3380,11 +3430,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::UMIN); + assertArraysEquals(r, a, b, IntVector64Tests::UMIN); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMINInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3400,7 +3450,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, IntVector64Tests::UMIN); } static int UMAX(int a, int b) { @@ -3408,7 +3458,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMAXInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3421,11 +3471,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::UMAX); + assertArraysEquals(r, a, b, IntVector64Tests::UMAX); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMAXInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3441,7 +3491,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, IntVector64Tests::UMAX); } static int SADD(int a, int b) { @@ -3449,7 +3499,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SADDInt64VectorTests(IntFunction fa, IntFunction fb) { + static void SADDIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3462,11 +3512,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::SADD); + assertArraysEquals(r, a, b, IntVector64Tests::SADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SADDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3482,7 +3532,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::SADD); + assertArraysEquals(r, a, b, mask, IntVector64Tests::SADD); } static int SSUB(int a, int b) { @@ -3490,7 +3540,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SSUBInt64VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3503,11 +3553,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::SSUB); + assertArraysEquals(r, a, b, IntVector64Tests::SSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SSUBInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3523,7 +3573,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, IntVector64Tests::SSUB); } static int SUADD(int a, int b) { @@ -3531,7 +3581,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUADDInt64VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3544,11 +3594,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::SUADD); + assertArraysEquals(r, a, b, IntVector64Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUADDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3564,7 +3614,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, IntVector64Tests::SUADD); } static int SUSUB(int a, int b) { @@ -3572,7 +3622,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUSUBInt64VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3585,11 +3635,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::SUSUB); + assertArraysEquals(r, a, b, IntVector64Tests::SUSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUSUBInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3605,11 +3655,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, IntVector64Tests::SUSUB); } @Test(dataProvider = "intBinaryOpProvider") - static void MINInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3619,11 +3669,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::MIN); } @Test(dataProvider = "intBinaryOpProvider") - static void minInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3633,11 +3683,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::min); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3647,11 +3697,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::MAX); } @Test(dataProvider = "intBinaryOpProvider") - static void maxInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3661,10 +3711,10 @@ public class Int64VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Int64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntVector64Tests::max); } @Test(dataProvider = "intSaturatingBinaryOpAssocProvider") - static void SUADDAssocInt64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocIntVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -3681,11 +3731,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Int64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, IntVector64Tests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3706,13 +3756,13 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Int64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntVector64Tests::SUADD); } static int ANDReduce(int[] a, int idx) { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3721,14 +3771,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ANDReduceAll(int[] a) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ANDReduceInt64VectorTests(IntFunction fa) { + static void ANDReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3739,12 +3789,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::ANDReduce, Int64VectorTests::ANDReduceAll); + IntVector64Tests::ANDReduce, IntVector64Tests::ANDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3752,20 +3802,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = AND_IDENTITY; - assertEquals((int) (id & id), id, + assertEquals((int) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id & x), x); - assertEquals((int) (x & id), x); + assertEquals((int) (scalar_and(id, x)), x); + assertEquals((int) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id & x), x, + assertEquals((int) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x & id), x, + assertEquals((int) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3774,7 +3824,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3783,14 +3833,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ANDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3803,18 +3853,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::ANDReduceMasked, Int64VectorTests::ANDReduceAllMasked); + IntVector64Tests::ANDReduceMasked, IntVector64Tests::ANDReduceAllMasked); } static int ORReduce(int[] a, int idx) { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3823,14 +3873,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ORReduceAll(int[] a) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ORReduceInt64VectorTests(IntFunction fa) { + static void ORReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3841,12 +3891,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::ORReduce, Int64VectorTests::ORReduceAll); + IntVector64Tests::ORReduce, IntVector64Tests::ORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3854,20 +3904,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = OR_IDENTITY; - assertEquals((int) (id | id), id, + assertEquals((int) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id | x), x); - assertEquals((int) (x | id), x); + assertEquals((int) (scalar_or(id, x)), x); + assertEquals((int) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id | x), x, + assertEquals((int) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x | id), x, + assertEquals((int) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3876,7 +3926,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3885,14 +3935,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3905,18 +3955,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::ORReduceMasked, Int64VectorTests::ORReduceAllMasked); + IntVector64Tests::ORReduceMasked, IntVector64Tests::ORReduceAllMasked); } static int XORReduce(int[] a, int idx) { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3925,14 +3975,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int XORReduceAll(int[] a) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void XORReduceInt64VectorTests(IntFunction fa) { + static void XORReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3943,12 +3993,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::XORReduce, Int64VectorTests::XORReduceAll); + IntVector64Tests::XORReduce, IntVector64Tests::XORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3956,20 +4006,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = XOR_IDENTITY; - assertEquals((int) (id ^ id), id, + assertEquals((int) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id ^ x), x); - assertEquals((int) (x ^ id), x); + assertEquals((int) (scalar_xor(id, x)), x); + assertEquals((int) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id ^ x), x, + assertEquals((int) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x ^ id), x, + assertEquals((int) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3978,7 +4028,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3987,14 +4037,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void XORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4007,18 +4057,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::XORReduceMasked, Int64VectorTests::XORReduceAllMasked); + IntVector64Tests::XORReduceMasked, IntVector64Tests::XORReduceAllMasked); } static int ADDReduce(int[] a, int idx) { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4027,14 +4077,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ADDReduceAll(int[] a) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceInt64VectorTests(IntFunction fa) { + static void ADDReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4045,12 +4095,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::ADDReduce, Int64VectorTests::ADDReduceAll); + IntVector64Tests::ADDReduce, IntVector64Tests::ADDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4058,20 +4108,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = ADD_IDENTITY; - assertEquals((int) (id + id), id, + assertEquals((int) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id + x), x); - assertEquals((int) (x + id), x); + assertEquals((int) (scalar_add(id, x)), x); + assertEquals((int) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id + x), x, + assertEquals((int) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x + id), x, + assertEquals((int) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4080,7 +4130,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4089,14 +4139,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int ADDReduceAllMasked(int[] a, boolean[] mask) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4109,18 +4159,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::ADDReduceMasked, Int64VectorTests::ADDReduceAllMasked); + IntVector64Tests::ADDReduceMasked, IntVector64Tests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4129,14 +4179,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MULReduceAll(int[] a) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MULReduceInt64VectorTests(IntFunction fa) { + static void MULReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4147,12 +4197,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::MULReduce, Int64VectorTests::MULReduceAll); + IntVector64Tests::MULReduce, IntVector64Tests::MULReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4160,20 +4210,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MUL_IDENTITY; - assertEquals((int) (id * id), id, + assertEquals((int) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id * x), x); - assertEquals((int) (x * id), x); + assertEquals((int) (scalar_mul(id, x)), x); + assertEquals((int) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id * x), x, + assertEquals((int) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x * id), x, + assertEquals((int) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4182,7 +4232,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4191,14 +4241,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MULReduceAllMasked(int[] a, boolean[] mask) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MULReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4211,18 +4261,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::MULReduceMasked, Int64VectorTests::MULReduceAllMasked); + IntVector64Tests::MULReduceMasked, IntVector64Tests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4231,14 +4281,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MINReduceAll(int[] a) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MINReduceInt64VectorTests(IntFunction fa) { + static void MINReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4249,12 +4299,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::MINReduce, Int64VectorTests::MINReduceAll); + IntVector64Tests::MINReduce, IntVector64Tests::MINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4262,20 +4312,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MIN_IDENTITY; - assertEquals((int) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.min(id, x), x); - assertEquals((int) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4284,7 +4334,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4293,14 +4343,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MINReduceAllMasked(int[] a, boolean[] mask) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4313,18 +4363,18 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::MINReduceMasked, Int64VectorTests::MINReduceAllMasked); + IntVector64Tests::MINReduceMasked, IntVector64Tests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4333,14 +4383,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MAXReduceAll(int[] a) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MAXReduceInt64VectorTests(IntFunction fa) { + static void MAXReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4351,12 +4401,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::MAXReduce, Int64VectorTests::MAXReduceAll); + IntVector64Tests::MAXReduce, IntVector64Tests::MAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4364,20 +4414,20 @@ public class Int64VectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MAX_IDENTITY; - assertEquals((int) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.max(id, x), x); - assertEquals((int) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4386,7 +4436,7 @@ public class Int64VectorTests extends AbstractVectorTest { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4395,14 +4445,14 @@ public class Int64VectorTests extends AbstractVectorTest { static int MAXReduceAllMasked(int[] a, boolean[] mask) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4415,12 +4465,12 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::MAXReduceMasked, Int64VectorTests::MAXReduceAllMasked); + IntVector64Tests::MAXReduceMasked, IntVector64Tests::MAXReduceAllMasked); } static int UMINReduce(int[] a, int idx) { @@ -4442,7 +4492,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMINReduceInt64VectorTests(IntFunction fa) { + static void UMINReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4458,7 +4508,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::UMINReduce, Int64VectorTests::UMINReduceAll); + IntVector64Tests::UMINReduce, IntVector64Tests::UMINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4504,7 +4554,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4522,7 +4572,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::UMINReduceMasked, Int64VectorTests::UMINReduceAllMasked); + IntVector64Tests::UMINReduceMasked, IntVector64Tests::UMINReduceAllMasked); } static int UMAXReduce(int[] a, int idx) { @@ -4544,7 +4594,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMAXReduceInt64VectorTests(IntFunction fa) { + static void UMAXReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4560,7 +4610,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::UMAXReduce, Int64VectorTests::UMAXReduceAll); + IntVector64Tests::UMAXReduce, IntVector64Tests::UMAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4606,7 +4656,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4624,7 +4674,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::UMAXReduceMasked, Int64VectorTests::UMAXReduceAllMasked); + IntVector64Tests::UMAXReduceMasked, IntVector64Tests::UMAXReduceAllMasked); } static int FIRST_NONZEROReduce(int[] a, int idx) { @@ -4646,7 +4696,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void FIRST_NONZEROReduceInt64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4662,7 +4712,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::FIRST_NONZEROReduce, Int64VectorTests::FIRST_NONZEROReduceAll); + IntVector64Tests::FIRST_NONZEROReduce, IntVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4708,7 +4758,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void FIRST_NONZEROReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4726,7 +4776,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::FIRST_NONZEROReduceMasked, Int64VectorTests::FIRST_NONZEROReduceAllMasked); + IntVector64Tests::FIRST_NONZEROReduceMasked, IntVector64Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4739,7 +4789,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueInt64VectorTests(IntFunction fm) { + static void anyTrueIntVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4750,7 +4800,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntVector64Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4763,7 +4813,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueInt64VectorTests(IntFunction fm) { + static void allTrueIntVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4774,7 +4824,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Int64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntVector64Tests::allTrue); } static int SUADDReduce(int[] a, int idx) { @@ -4796,7 +4846,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingUnaryOpProvider") - static void SUADDReduceInt64VectorTests(IntFunction fa) { + static void SUADDReduceIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4812,7 +4862,7 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Int64VectorTests::SUADDReduce, Int64VectorTests::SUADDReduceAll); + IntVector64Tests::SUADDReduce, IntVector64Tests::SUADDReduceAll); } @Test(dataProvider = "intSaturatingUnaryOpProvider") @@ -4857,7 +4907,7 @@ public class Int64VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "intSaturatingUnaryOpMaskProvider") - static void SUADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4875,11 +4925,11 @@ public class Int64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::SUADDReduceMasked, Int64VectorTests::SUADDReduceAllMasked); + IntVector64Tests::SUADDReduceMasked, IntVector64Tests::SUADDReduceAllMasked); } @Test(dataProvider = "intBinaryOpProvider") - static void withInt64VectorTests(IntFunction fa, IntFunction fb) { + static void withIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -4902,7 +4952,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_DEFAULTInt64VectorTests(IntFunction fa) { + static void IS_DEFAULTIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4919,7 +4969,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_DEFAULTMaskedInt64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4943,7 +4993,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_NEGATIVEInt64VectorTests(IntFunction fa) { + static void IS_NEGATIVEIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4960,7 +5010,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_NEGATIVEMaskedInt64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4980,7 +5030,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void LTIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4999,7 +5049,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ltIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5018,7 +5068,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5041,7 +5091,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void GTIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5060,7 +5110,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5083,7 +5133,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void EQInt64VectorTests(IntFunction fa, IntFunction fb) { + static void EQIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5102,7 +5152,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void eqInt64VectorTests(IntFunction fa, IntFunction fb) { + static void eqIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5121,7 +5171,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5144,7 +5194,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void NEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void NEIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5163,7 +5213,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void NEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5186,7 +5236,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void LEIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5205,7 +5255,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5228,7 +5278,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void GEIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5247,7 +5297,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5270,7 +5320,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5289,7 +5339,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5312,7 +5362,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5331,7 +5381,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5354,7 +5404,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5373,7 +5423,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5396,7 +5446,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntVector64Tests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5415,7 +5465,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5438,7 +5488,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5448,13 +5498,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5468,13 +5518,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void LTInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5484,13 +5534,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTInt64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTIntVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5504,13 +5554,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (int)((long)b[i])))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5520,13 +5570,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5540,13 +5590,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5556,13 +5606,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQInt64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQIntVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5576,7 +5626,7 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (int)((long)b[i])))); } } } @@ -5586,7 +5636,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt64VectorTests(IntFunction fa, IntFunction fb, + static void blendIntVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5602,11 +5652,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Int64VectorTests::blend); + assertArraysEquals(r, a, b, mask, IntVector64Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void RearrangeInt64VectorTests(IntFunction fa, + static void RearrangeIntVector64Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void RearrangeInt64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeIntVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -5641,7 +5691,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void compressInt64VectorTests(IntFunction fa, + static void compressIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5659,7 +5709,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void expandInt64VectorTests(IntFunction fa, + static void expandIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5677,7 +5727,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void getInt64VectorTests(IntFunction fa) { + static void getIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5833,7 +5883,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastInt64VectorTests(IntFunction fa) { + static void BroadcastIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5847,7 +5897,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZeroInt64VectorTests(IntFunction fa) { + static void ZeroIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5872,7 +5922,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void sliceUnaryInt64VectorTests(IntFunction fa) { + static void sliceUnaryIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5883,7 +5933,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntVector64Tests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { @@ -5900,7 +5950,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void sliceBinaryInt64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryIntVector64TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5913,7 +5963,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Int64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntVector64Tests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { @@ -5930,7 +5980,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void sliceInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5947,7 +5997,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Int64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, IntVector64Tests::slice); } static int[] unsliceUnary(int[] a, int origin, int idx) { @@ -5964,7 +6014,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void unsliceUnaryInt64VectorTests(IntFunction fa) { + static void unsliceUnaryIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5975,7 +6025,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Int64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntVector64Tests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { @@ -6001,7 +6051,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void unsliceBinaryInt64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryIntVector64TestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -6015,7 +6065,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Int64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntVector64Tests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { @@ -6055,7 +6105,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void unsliceInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6072,7 +6122,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Int64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, IntVector64Tests::unslice); } static int BITWISE_BLEND(int a, int b, int c) { @@ -6084,7 +6134,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Int64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6116,11 +6166,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, IntVector64Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6138,11 +6188,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Int64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6153,11 +6203,11 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6168,11 +6218,11 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntVector64Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Int64VectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, IntVector64Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6217,11 +6267,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Int64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6236,11 +6286,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Int64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDInt64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6251,11 +6301,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendInt64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6266,11 +6316,11 @@ public class Int64VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Int64VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVector64Tests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDInt64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6284,19 +6334,19 @@ public class Int64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Int64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntVector64Tests::BITWISE_BLEND); } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void NEGInt64VectorTests(IntFunction fa) { + static void NEGIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6307,11 +6357,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::NEG); + assertArraysEquals(r, a, IntVector64Tests::NEG); } @Test(dataProvider = "intUnaryOpProvider") - static void negInt64VectorTests(IntFunction fa) { + static void negIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6322,11 +6372,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::neg); + assertArraysEquals(r, a, IntVector64Tests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NEGMaskedInt64VectorTests(IntFunction fa, + static void NEGMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6340,19 +6390,19 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::NEG); + assertArraysEquals(r, a, mask, IntVector64Tests::NEG); } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void ABSInt64VectorTests(IntFunction fa) { + static void ABSIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6363,11 +6413,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::ABS); + assertArraysEquals(r, a, IntVector64Tests::ABS); } @Test(dataProvider = "intUnaryOpProvider") - static void absInt64VectorTests(IntFunction fa) { + static void absIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6378,11 +6428,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::abs); + assertArraysEquals(r, a, IntVector64Tests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ABSMaskedInt64VectorTests(IntFunction fa, + static void ABSMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6396,7 +6446,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::ABS); + assertArraysEquals(r, a, mask, IntVector64Tests::ABS); } static int NOT(int a) { @@ -6408,7 +6458,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void NOTInt64VectorTests(IntFunction fa) { + static void NOTIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6419,11 +6469,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::NOT); + assertArraysEquals(r, a, IntVector64Tests::NOT); } @Test(dataProvider = "intUnaryOpProvider") - static void notInt64VectorTests(IntFunction fa) { + static void notIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6434,11 +6484,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::not); + assertArraysEquals(r, a, IntVector64Tests::not); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NOTMaskedInt64VectorTests(IntFunction fa, + static void NOTMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6452,7 +6502,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::NOT); + assertArraysEquals(r, a, mask, IntVector64Tests::NOT); } static int ZOMO(int a) { @@ -6460,7 +6510,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZOMOInt64VectorTests(IntFunction fa) { + static void ZOMOIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6471,11 +6521,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::ZOMO); + assertArraysEquals(r, a, IntVector64Tests::ZOMO); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ZOMOMaskedInt64VectorTests(IntFunction fa, + static void ZOMOMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6489,7 +6539,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntVector64Tests::ZOMO); } static int BIT_COUNT(int a) { @@ -6497,7 +6547,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BIT_COUNTInt64VectorTests(IntFunction fa) { + static void BIT_COUNTIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6508,11 +6558,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, IntVector64Tests::BIT_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void BIT_COUNTMaskedInt64VectorTests(IntFunction fa, + static void BIT_COUNTMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6526,7 +6576,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, IntVector64Tests::BIT_COUNT); } static int TRAILING_ZEROS_COUNT(int a) { @@ -6534,7 +6584,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void TRAILING_ZEROS_COUNTInt64VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6545,11 +6595,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector64Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedInt64VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6563,7 +6613,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector64Tests::TRAILING_ZEROS_COUNT); } static int LEADING_ZEROS_COUNT(int a) { @@ -6571,7 +6621,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LEADING_ZEROS_COUNTInt64VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6582,11 +6632,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVector64Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedInt64VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6600,7 +6650,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVector64Tests::LEADING_ZEROS_COUNT); } static int REVERSE(int a) { @@ -6608,7 +6658,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSEInt64VectorTests(IntFunction fa) { + static void REVERSEIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6619,11 +6669,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::REVERSE); + assertArraysEquals(r, a, IntVector64Tests::REVERSE); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSEMaskedInt64VectorTests(IntFunction fa, + static void REVERSEMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6637,7 +6687,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::REVERSE); + assertArraysEquals(r, a, mask, IntVector64Tests::REVERSE); } static int REVERSE_BYTES(int a) { @@ -6645,7 +6695,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSE_BYTESInt64VectorTests(IntFunction fa) { + static void REVERSE_BYTESIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6656,11 +6706,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, IntVector64Tests::REVERSE_BYTES); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedInt64VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedIntVector64Tests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6674,7 +6724,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Int64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, IntVector64Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6682,7 +6732,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6695,7 +6745,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::band); + assertArraysEquals(r, a, b, IntVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6703,7 +6753,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6716,7 +6766,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::bor); + assertArraysEquals(r, a, b, IntVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6724,7 +6774,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6737,7 +6787,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::bxor); + assertArraysEquals(r, a, b, IntVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6745,7 +6795,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6758,7 +6808,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::bandNot); + assertArraysEquals(r, a, b, IntVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6766,7 +6816,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6779,7 +6829,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Int64VectorTests::beq); + assertArraysEquals(r, a, b, IntVector64Tests::beq); } static boolean unot(boolean a) { @@ -6787,7 +6837,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotInt64VectorTests(IntFunction fa) { + static void masknotIntVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6798,7 +6848,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::unot); + assertArraysEquals(r, a, IntVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6815,7 +6865,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongInt64VectorTests(IntFunction fa) { + static void maskFromToLongIntVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6829,7 +6879,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltIntVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6839,13 +6889,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpProvider") - static void eqInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqIntVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6855,13 +6905,13 @@ public class Int64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intUnaryOpProvider") - static void toIntArrayInt64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6872,7 +6922,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toLongArrayInt64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6883,7 +6933,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toDoubleArrayInt64VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6894,7 +6944,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toStringInt64VectorTestsSmokeTest(IntFunction fa) { + static void toStringIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6907,7 +6957,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void hashCodeInt64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6924,7 +6974,7 @@ public class Int64VectorTests extends AbstractVectorTest { static long ADDReduceLong(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6933,14 +6983,14 @@ public class Int64VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(int[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((int)res, (int)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceLongInt64VectorTests(IntFunction fa) { + static void ADDReduceLongIntVector64Tests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6951,19 +7001,20 @@ public class Int64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Int64VectorTests::ADDReduceLong, Int64VectorTests::ADDReduceAllLong); + IntVector64Tests::ADDReduceLong, IntVector64Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6972,14 +7023,14 @@ public class Int64VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(int[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((int)res, (int)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceLongInt64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongIntVector64TestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6992,16 +7043,16 @@ public class Int64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Int64VectorTests::ADDReduceLongMasked, Int64VectorTests::ADDReduceAllLongMasked); + IntVector64Tests::ADDReduceLongMasked, IntVector64Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastLongInt64VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongIntVector64TestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7012,7 +7063,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendIntVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -7026,12 +7077,12 @@ public class Int64VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Int64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVector64Tests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void SelectFromInt64VectorTests(IntFunction fa, + static void SelectFromIntVector64Tests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -7047,7 +7098,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorInt64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorIntVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] idx = fc.apply(SPECIES.length()); @@ -7065,7 +7116,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void SelectFromInt64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromIntVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -7084,7 +7135,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousInt64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousIntVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7100,7 +7151,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringInt64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringIntVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7114,7 +7165,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsInt64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsIntVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7128,7 +7179,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsInt64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsIntVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7144,7 +7195,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeInt64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeIntVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7166,7 +7217,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountInt64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountIntVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7177,7 +7228,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, IntVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7191,7 +7242,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueInt64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueIntVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7202,7 +7253,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, IntVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7216,7 +7267,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueInt64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueIntVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7227,11 +7278,11 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Int64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, IntVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressInt64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressIntVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7259,7 +7310,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeInt64VectorTestsSmokeTest(int offset) { + static void indexInRangeIntVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7273,7 +7324,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongInt64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongIntVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7300,14 +7351,14 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundInt64VectorTestsSmokeTest(int length) { + static void loopBoundIntVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongInt64VectorTestsSmokeTest(int _length) { + static void loopBoundLongIntVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7315,21 +7366,21 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeInt64VectorTestsSmokeTest() { + static void ElementSizeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Integer.SIZE); } @Test - static void VectorShapeInt64VectorTestsSmokeTest() { + static void VectorShapeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesInt64VectorTestsSmokeTest() { + static void ShapeWithLanesIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(int.class); @@ -7337,32 +7388,32 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeInt64VectorTestsSmokeTest() { + static void ElementTypeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementType() == int.class); } @Test - static void SpeciesElementSizeInt64VectorTestsSmokeTest() { + static void SpeciesElementSizeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementSize() == Integer.SIZE); } @Test - static void VectorTypeInt64VectorTestsSmokeTest() { + static void VectorTypeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesInt64VectorTestsSmokeTest() { + static void WithLanesIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(int.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeInt64VectorTestsSmokeTest() { + static void WithShapeIntVector64TestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7370,7 +7421,7 @@ public class Int64VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueInt64VectorTestsSmokeTest() { + static void MaskAllTrueIntVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/IntVectorMaxLoadStoreTests.java index d72c428659f..c9adfe802b6 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/IntVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation IntMaxVectorLoadStoreTests + * -XX:-TieredCompilation IntVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class IntMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class IntVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = IntVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java similarity index 87% rename from test/jdk/jdk/incubator/vector/IntMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/IntVectorMaxTests.java index fc4cf4ea21e..6c671a81bf1 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class IntMaxVectorTests extends AbstractVectorTest { +public class IntVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = IntVector.SPECIES_MAX; @@ -1537,6 +1537,59 @@ public class IntMaxVectorTests extends AbstractVectorTest { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1553,9 +1606,6 @@ public class IntMaxVectorTests extends AbstractVectorTest { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1669,11 +1719,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1686,15 +1736,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::ADD); + assertArraysEquals(r, a, b, IntVectorMaxTests::ADD); } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void addIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1705,11 +1755,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::add); + assertArraysEquals(r, a, b, IntVectorMaxTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1725,11 +1775,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1743,15 +1793,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::add); } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void SUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1764,15 +1814,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::SUB); + assertArraysEquals(r, a, b, IntVectorMaxTests::SUB); } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void subIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1783,11 +1833,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::sub); + assertArraysEquals(r, a, b, IntVectorMaxTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void SUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1803,11 +1853,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::SUB); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1821,15 +1871,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::sub); } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MULIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1842,15 +1892,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::MUL); + assertArraysEquals(r, a, b, IntVectorMaxTests::MUL); } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void mulIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1861,11 +1911,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::mul); + assertArraysEquals(r, a, b, IntVectorMaxTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void MULIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1881,11 +1931,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::MUL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1899,7 +1949,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::mul); } static int DIV(int a, int b) { @@ -1907,7 +1957,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void DIVIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1922,7 +1972,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::DIV); + assertArraysEquals(r, a, b, IntVectorMaxTests::DIV); } static int div(int a, int b) { @@ -1930,7 +1980,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void divIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -1945,11 +1995,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::div); + assertArraysEquals(r, a, b, IntVectorMaxTests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void DIVIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1967,11 +2017,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::DIV); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -1989,15 +2039,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::div); } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void FIRST_NONZEROIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2010,11 +2060,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, IntVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void FIRST_NONZEROIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2030,7 +2080,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::FIRST_NONZERO); } static int AND(int a, int b) { @@ -2038,7 +2088,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ANDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ANDIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2051,7 +2101,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::AND); + assertArraysEquals(r, a, b, IntVectorMaxTests::AND); } static int and(int a, int b) { @@ -2059,7 +2109,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void andIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void andIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2070,11 +2120,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::and); + assertArraysEquals(r, a, b, IntVectorMaxTests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2090,7 +2140,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::AND); } static int AND_NOT(int a, int b) { @@ -2098,7 +2148,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void AND_NOTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2111,11 +2161,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, IntVectorMaxTests::AND_NOT); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void AND_NOTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2131,7 +2181,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::AND_NOT); } static int OR(int a, int b) { @@ -2139,7 +2189,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ORIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ORIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2152,7 +2202,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::OR); + assertArraysEquals(r, a, b, IntVectorMaxTests::OR); } static int or(int a, int b) { @@ -2160,7 +2210,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void orIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void orIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2171,11 +2221,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::or); + assertArraysEquals(r, a, b, IntVectorMaxTests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2191,7 +2241,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::OR); } static int XOR(int a, int b) { @@ -2199,7 +2249,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void XORIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void XORIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2212,11 +2262,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::XOR); + assertArraysEquals(r, a, b, IntVectorMaxTests::XOR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void XORIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2232,7 +2282,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::XOR); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::XOR); } static int COMPRESS_BITS(int a, int b) { @@ -2240,7 +2290,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void COMPRESS_BITSIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2253,11 +2303,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, IntVectorMaxTests::COMPRESS_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void COMPRESS_BITSIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2273,7 +2323,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::COMPRESS_BITS); } static int EXPAND_BITS(int a, int b) { @@ -2281,7 +2331,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void EXPAND_BITSIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2294,11 +2344,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, IntVectorMaxTests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void EXPAND_BITSIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2314,11 +2364,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::EXPAND_BITS); } @Test(dataProvider = "intBinaryOpProvider") - static void addIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2328,11 +2378,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::add); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void addIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2345,11 +2395,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::add); } @Test(dataProvider = "intBinaryOpProvider") - static void subIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2359,11 +2409,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::sub); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void subIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2376,11 +2426,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::sub); } @Test(dataProvider = "intBinaryOpProvider") - static void mulIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2390,11 +2440,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::mul); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void mulIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2407,11 +2457,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::mul); } @Test(dataProvider = "intBinaryOpProvider") - static void divIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2423,11 +2473,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::div); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void divIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2442,11 +2492,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::div); } @Test(dataProvider = "intBinaryOpProvider") - static void ORIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2456,11 +2506,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void orIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2470,11 +2520,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::or); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2487,11 +2537,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ANDIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2501,11 +2551,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void andIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2515,11 +2565,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::and); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ANDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2532,11 +2582,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, IntVectorMaxTests::AND); } @Test(dataProvider = "intBinaryOpProvider") - static void ORIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORIntVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2546,11 +2596,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, IntVectorMaxTests::OR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ORIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORIntVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2563,11 +2613,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVectorMaxTests::OR); } @Test(dataProvider = "intBinaryOpProvider") - static void ADDIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDIntVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2577,11 +2627,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, IntVectorMaxTests::ADD); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ADDIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDIntVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2594,7 +2644,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVectorMaxTests::ADD); } static int LSHL(int a, int b) { @@ -2602,7 +2652,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHLIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2615,11 +2665,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, IntVectorMaxTests::LSHL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2635,7 +2685,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::LSHL); } static int ASHR(int a, int b) { @@ -2643,7 +2693,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ASHRIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2656,11 +2706,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, IntVectorMaxTests::ASHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2676,7 +2726,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::ASHR); } static int LSHR(int a, int b) { @@ -2684,7 +2734,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHRIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2697,11 +2747,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, IntVectorMaxTests::LSHR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2717,7 +2767,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::LSHR); } static int LSHL_unary(int a, int b) { @@ -2725,7 +2775,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHLIntMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLIntVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2737,11 +2787,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, IntVectorMaxTests::LSHL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHLIntMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLIntVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2756,7 +2806,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVectorMaxTests::LSHL_unary); } static int LSHR_unary(int a, int b) { @@ -2764,7 +2814,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void LSHRIntMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRIntVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2776,11 +2826,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, IntVectorMaxTests::LSHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void LSHRIntMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRIntVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2795,7 +2845,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVectorMaxTests::LSHR_unary); } static int ASHR_unary(int a, int b) { @@ -2803,7 +2853,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ASHRIntMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRIntVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2815,11 +2865,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, IntVectorMaxTests::ASHR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ASHRIntMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRIntVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2834,7 +2884,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVectorMaxTests::ASHR_unary); } static int ROR(int a, int b) { @@ -2842,7 +2892,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void RORIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2855,11 +2905,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::ROR); + assertArraysEquals(r, a, b, IntVectorMaxTests::ROR); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2875,7 +2925,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::ROR); } static int ROL(int a, int b) { @@ -2883,7 +2933,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ROLIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2896,11 +2946,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::ROL); + assertArraysEquals(r, a, b, IntVectorMaxTests::ROL); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2916,7 +2966,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::ROL); } static int ROR_unary(int a, int b) { @@ -2924,7 +2974,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void RORIntMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORIntVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2936,11 +2986,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, IntVectorMaxTests::ROR_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void RORIntMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORIntVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2955,7 +3005,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, IntVectorMaxTests::ROR_unary); } static int ROL_unary(int a, int b) { @@ -2963,7 +3013,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void ROLIntMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLIntVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -2975,11 +3025,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, IntVectorMaxTests::ROL_unary); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void ROLIntMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLIntVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -2994,14 +3044,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, IntVectorMaxTests::ROL_unary); } static int LSHR_binary_const(int a) { return (int)((a >>> CONST_SHIFT)); } @Test(dataProvider = "intUnaryOpProvider") - static void LSHRIntMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRIntVectorMaxTestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3012,11 +3062,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, IntMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, IntVectorMaxTests::LSHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRIntVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3030,7 +3080,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVectorMaxTests::LSHR_binary_const); } static int LSHL_binary_const(int a) { @@ -3038,7 +3088,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LSHLIntMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLIntVectorMaxTestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3049,11 +3099,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, IntMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, IntVectorMaxTests::LSHL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LSHLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLIntVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3067,7 +3117,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, IntVectorMaxTests::LSHL_binary_const); } static int ASHR_binary_const(int a) { @@ -3075,7 +3125,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ASHRIntMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRIntVectorMaxTestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3086,11 +3136,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, IntMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, IntVectorMaxTests::ASHR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ASHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRIntVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3104,7 +3154,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, IntVectorMaxTests::ASHR_binary_const); } static int ROR_binary_const(int a) { @@ -3112,7 +3162,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void RORIntMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void RORIntVectorMaxTestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3123,11 +3173,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, IntMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, IntVectorMaxTests::ROR_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void RORIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORIntVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3141,7 +3191,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, IntVectorMaxTests::ROR_binary_const); } static int ROL_binary_const(int a) { @@ -3149,7 +3199,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ROLIntMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ROLIntVectorMaxTestsScalarShiftConst(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3160,11 +3210,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, IntMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, IntVectorMaxTests::ROL_binary_const); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ROLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLIntVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3178,14 +3228,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, IntVectorMaxTests::ROL_binary_const); } static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MINIntMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINIntVectorMaxTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3196,13 +3246,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, IntMaxVectorTests::MIN); + assertArraysEquals(r, a, (int)10, IntVectorMaxTests::MIN); } static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void minIntMaxVectorTestsWithMemOp(IntFunction fa) { + static void minIntVectorMaxTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3213,13 +3263,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, IntMaxVectorTests::min); + assertArraysEquals(r, a, (int)10, IntVectorMaxTests::min); } static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINIntVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3232,13 +3282,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, IntMaxVectorTests::MIN); + assertArraysEquals(r, a, (int)10, mask, IntVectorMaxTests::MIN); } static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void MAXIntMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXIntVectorMaxTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3249,13 +3299,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, IntMaxVectorTests::MAX); + assertArraysEquals(r, a, (int)10, IntVectorMaxTests::MAX); } static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpProvider") - static void maxIntMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxIntVectorMaxTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3266,13 +3316,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, IntMaxVectorTests::max); + assertArraysEquals(r, a, (int)10, IntVectorMaxTests::max); } static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXIntVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3285,15 +3335,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (int)10, mask, IntMaxVectorTests::MAX); + assertArraysEquals(r, a, (int)10, mask, IntVectorMaxTests::MAX); } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MINIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3306,15 +3356,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::MIN); + assertArraysEquals(r, a, b, IntVectorMaxTests::MIN); } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void minIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3325,15 +3375,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::min); + assertArraysEquals(r, a, b, IntVectorMaxTests::min); } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3346,15 +3396,15 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::MAX); + assertArraysEquals(r, a, b, IntVectorMaxTests::MAX); } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") - static void maxIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3365,7 +3415,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, IntMaxVectorTests::max); + assertArraysEquals(r, a, b, IntVectorMaxTests::max); } static int UMIN(int a, int b) { @@ -3373,7 +3423,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMINIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMINIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3386,11 +3436,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, IntVectorMaxTests::UMIN); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMINIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3406,7 +3456,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::UMIN); } static int UMAX(int a, int b) { @@ -3414,7 +3464,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void UMAXIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMAXIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3427,11 +3477,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, IntVectorMaxTests::UMAX); } @Test(dataProvider = "intBinaryOpMaskProvider") - static void UMAXIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3447,7 +3497,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::UMAX); } static int SADD(int a, int b) { @@ -3455,7 +3505,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SADDIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3468,11 +3518,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::SADD); + assertArraysEquals(r, a, b, IntVectorMaxTests::SADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3488,7 +3538,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SADD); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::SADD); } static int SSUB(int a, int b) { @@ -3496,7 +3546,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SSUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SSUBIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3509,11 +3559,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, IntVectorMaxTests::SSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SSUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3529,7 +3579,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::SSUB); } static int SUADD(int a, int b) { @@ -3537,7 +3587,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUADDIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3550,11 +3600,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, IntVectorMaxTests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3570,7 +3620,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::SUADD); } static int SUSUB(int a, int b) { @@ -3578,7 +3628,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingBinaryOpProvider") - static void SUSUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3591,11 +3641,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, IntVectorMaxTests::SUSUB); } @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") - static void SUSUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3611,11 +3661,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::SUSUB); } @Test(dataProvider = "intBinaryOpProvider") - static void MINIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3625,11 +3675,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::MIN); } @Test(dataProvider = "intBinaryOpProvider") - static void minIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3639,11 +3689,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::min); } @Test(dataProvider = "intBinaryOpProvider") - static void MAXIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3653,11 +3703,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::MAX); } @Test(dataProvider = "intBinaryOpProvider") - static void maxIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -3667,10 +3717,10 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, IntVectorMaxTests::max); } @Test(dataProvider = "intSaturatingBinaryOpAssocProvider") - static void SUADDAssocIntMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocIntVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -3687,11 +3737,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, IntMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, IntVectorMaxTests::SUADD); } @Test(dataProvider = "intSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -3712,13 +3762,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, IntVectorMaxTests::SUADD); } static int ANDReduce(int[] a, int idx) { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3727,14 +3777,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ANDReduceAll(int[] a) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ANDReduceIntMaxVectorTests(IntFunction fa) { + static void ANDReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3745,12 +3795,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::ANDReduce, IntMaxVectorTests::ANDReduceAll); + IntVectorMaxTests::ANDReduce, IntVectorMaxTests::ANDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3758,20 +3808,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = AND_IDENTITY; - assertEquals((int) (id & id), id, + assertEquals((int) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id & x), x); - assertEquals((int) (x & id), x); + assertEquals((int) (scalar_and(id, x)), x); + assertEquals((int) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id & x), x, + assertEquals((int) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x & id), x, + assertEquals((int) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3780,7 +3830,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3789,14 +3839,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ANDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3809,18 +3859,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::ANDReduceMasked, IntMaxVectorTests::ANDReduceAllMasked); + IntVectorMaxTests::ANDReduceMasked, IntVectorMaxTests::ANDReduceAllMasked); } static int ORReduce(int[] a, int idx) { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3829,14 +3879,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ORReduceAll(int[] a) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ORReduceIntMaxVectorTests(IntFunction fa) { + static void ORReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3847,12 +3897,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::ORReduce, IntMaxVectorTests::ORReduceAll); + IntVectorMaxTests::ORReduce, IntVectorMaxTests::ORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3860,20 +3910,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = OR_IDENTITY; - assertEquals((int) (id | id), id, + assertEquals((int) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id | x), x); - assertEquals((int) (x | id), x); + assertEquals((int) (scalar_or(id, x)), x); + assertEquals((int) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id | x), x, + assertEquals((int) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x | id), x, + assertEquals((int) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3882,7 +3932,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3891,14 +3941,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3911,18 +3961,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::ORReduceMasked, IntMaxVectorTests::ORReduceAllMasked); + IntVectorMaxTests::ORReduceMasked, IntVectorMaxTests::ORReduceAllMasked); } static int XORReduce(int[] a, int idx) { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3931,14 +3981,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int XORReduceAll(int[] a) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void XORReduceIntMaxVectorTests(IntFunction fa) { + static void XORReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -3949,12 +3999,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::XORReduce, IntMaxVectorTests::XORReduceAll); + IntVectorMaxTests::XORReduce, IntVectorMaxTests::XORReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -3962,20 +4012,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = XOR_IDENTITY; - assertEquals((int) (id ^ id), id, + assertEquals((int) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id ^ x), x); - assertEquals((int) (x ^ id), x); + assertEquals((int) (scalar_xor(id, x)), x); + assertEquals((int) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id ^ x), x, + assertEquals((int) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x ^ id), x, + assertEquals((int) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3984,7 +4034,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3993,14 +4043,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void XORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4013,18 +4063,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::XORReduceMasked, IntMaxVectorTests::XORReduceAllMasked); + IntVectorMaxTests::XORReduceMasked, IntVectorMaxTests::XORReduceAllMasked); } static int ADDReduce(int[] a, int idx) { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4033,14 +4083,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ADDReduceAll(int[] a) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceIntMaxVectorTests(IntFunction fa) { + static void ADDReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4051,12 +4101,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::ADDReduce, IntMaxVectorTests::ADDReduceAll); + IntVectorMaxTests::ADDReduce, IntVectorMaxTests::ADDReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4064,20 +4114,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = ADD_IDENTITY; - assertEquals((int) (id + id), id, + assertEquals((int) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id + x), x); - assertEquals((int) (x + id), x); + assertEquals((int) (scalar_add(id, x)), x); + assertEquals((int) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id + x), x, + assertEquals((int) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x + id), x, + assertEquals((int) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4086,7 +4136,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4095,14 +4145,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int ADDReduceAllMasked(int[] a, boolean[] mask) { int res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4115,18 +4165,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::ADDReduceMasked, IntMaxVectorTests::ADDReduceAllMasked); + IntVectorMaxTests::ADDReduceMasked, IntVectorMaxTests::ADDReduceAllMasked); } static int MULReduce(int[] a, int idx) { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4135,14 +4185,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MULReduceAll(int[] a) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MULReduceIntMaxVectorTests(IntFunction fa) { + static void MULReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4153,12 +4203,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::MULReduce, IntMaxVectorTests::MULReduceAll); + IntVectorMaxTests::MULReduce, IntVectorMaxTests::MULReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4166,20 +4216,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MUL_IDENTITY; - assertEquals((int) (id * id), id, + assertEquals((int) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) (id * x), x); - assertEquals((int) (x * id), x); + assertEquals((int) (scalar_mul(id, x)), x); + assertEquals((int) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((int) (id * x), x, + assertEquals((int) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((int) (x * id), x, + assertEquals((int) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4188,7 +4238,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4197,14 +4247,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MULReduceAllMasked(int[] a, boolean[] mask) { int res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MULReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4217,18 +4267,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::MULReduceMasked, IntMaxVectorTests::MULReduceAllMasked); + IntVectorMaxTests::MULReduceMasked, IntVectorMaxTests::MULReduceAllMasked); } static int MINReduce(int[] a, int idx) { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4237,14 +4287,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MINReduceAll(int[] a) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MINReduceIntMaxVectorTests(IntFunction fa) { + static void MINReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4255,12 +4305,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::MINReduce, IntMaxVectorTests::MINReduceAll); + IntVectorMaxTests::MINReduce, IntVectorMaxTests::MINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4268,20 +4318,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MIN_IDENTITY; - assertEquals((int) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.min(id, x), x); - assertEquals((int) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4290,7 +4340,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4299,14 +4349,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MINReduceAllMasked(int[] a, boolean[] mask) { int res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4319,18 +4369,18 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (int) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::MINReduceMasked, IntMaxVectorTests::MINReduceAllMasked); + IntVectorMaxTests::MINReduceMasked, IntVectorMaxTests::MINReduceAllMasked); } static int MAXReduce(int[] a, int idx) { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4339,14 +4389,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MAXReduceAll(int[] a) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void MAXReduceIntMaxVectorTests(IntFunction fa) { + static void MAXReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4357,12 +4407,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::MAXReduce, IntMaxVectorTests::MAXReduceAll); + IntVectorMaxTests::MAXReduce, IntVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4370,20 +4420,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { int[] a = fa.apply(SPECIES.length()); int id = MAX_IDENTITY; - assertEquals((int) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); int x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((int) Math.max(id, x), x); - assertEquals((int) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((int) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((int) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4392,7 +4442,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { int res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4401,14 +4451,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static int MAXReduceAllMasked(int[] a, boolean[] mask) { int res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4421,12 +4471,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector av = IntVector.fromArray(SPECIES, a, i); int v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (int) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked); + IntVectorMaxTests::MAXReduceMasked, IntVectorMaxTests::MAXReduceAllMasked); } static int UMINReduce(int[] a, int idx) { @@ -4448,7 +4498,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMINReduceIntMaxVectorTests(IntFunction fa) { + static void UMINReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4464,7 +4514,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::UMINReduce, IntMaxVectorTests::UMINReduceAll); + IntVectorMaxTests::UMINReduce, IntVectorMaxTests::UMINReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4510,7 +4560,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4528,7 +4578,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::UMINReduceMasked, IntMaxVectorTests::UMINReduceAllMasked); + IntVectorMaxTests::UMINReduceMasked, IntVectorMaxTests::UMINReduceAllMasked); } static int UMAXReduce(int[] a, int idx) { @@ -4550,7 +4600,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void UMAXReduceIntMaxVectorTests(IntFunction fa) { + static void UMAXReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4566,7 +4616,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::UMAXReduce, IntMaxVectorTests::UMAXReduceAll); + IntVectorMaxTests::UMAXReduce, IntVectorMaxTests::UMAXReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4612,7 +4662,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void UMAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4630,7 +4680,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::UMAXReduceMasked, IntMaxVectorTests::UMAXReduceAllMasked); + IntVectorMaxTests::UMAXReduceMasked, IntVectorMaxTests::UMAXReduceAllMasked); } static int FIRST_NONZEROReduce(int[] a, int idx) { @@ -4652,7 +4702,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4668,7 +4718,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::FIRST_NONZEROReduce, IntMaxVectorTests::FIRST_NONZEROReduceAll); + IntVectorMaxTests::FIRST_NONZEROReduce, IntVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "intUnaryOpProvider") @@ -4714,7 +4764,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void FIRST_NONZEROReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4732,7 +4782,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::FIRST_NONZEROReduceMasked, IntMaxVectorTests::FIRST_NONZEROReduceAllMasked); + IntVectorMaxTests::FIRST_NONZEROReduceMasked, IntVectorMaxTests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4745,7 +4795,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueIntMaxVectorTests(IntFunction fm) { + static void anyTrueIntVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4756,7 +4806,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, IntVectorMaxTests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4769,7 +4819,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueIntMaxVectorTests(IntFunction fm) { + static void allTrueIntVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4780,7 +4830,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, IntVectorMaxTests::allTrue); } static int SUADDReduce(int[] a, int idx) { @@ -4802,7 +4852,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSaturatingUnaryOpProvider") - static void SUADDReduceIntMaxVectorTests(IntFunction fa) { + static void SUADDReduceIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); int ra = 0; @@ -4818,7 +4868,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - IntMaxVectorTests::SUADDReduce, IntMaxVectorTests::SUADDReduceAll); + IntVectorMaxTests::SUADDReduce, IntVectorMaxTests::SUADDReduceAll); } @Test(dataProvider = "intSaturatingUnaryOpProvider") @@ -4863,7 +4913,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "intSaturatingUnaryOpMaskProvider") - static void SUADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4881,11 +4931,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::SUADDReduceMasked, IntMaxVectorTests::SUADDReduceAllMasked); + IntVectorMaxTests::SUADDReduceMasked, IntVectorMaxTests::SUADDReduceAllMasked); } @Test(dataProvider = "intBinaryOpProvider") - static void withIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -4908,7 +4958,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_DEFAULTIntMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4925,7 +4975,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_DEFAULTMaskedIntMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4949,7 +4999,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpProvider") - static void IS_NEGATIVEIntMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVEIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4966,7 +5016,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTestOpMaskProvider") - static void IS_NEGATIVEMaskedIntMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4986,7 +5036,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5005,7 +5055,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5024,7 +5074,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5047,7 +5097,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5066,7 +5116,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5089,7 +5139,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void EQIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5108,7 +5158,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void eqIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5127,7 +5177,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5150,7 +5200,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void NEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NEIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5169,7 +5219,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void NEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5192,7 +5242,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LEIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5211,7 +5261,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void LEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5234,7 +5284,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void GEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GEIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5253,7 +5303,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void GEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5276,7 +5326,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5295,7 +5345,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5318,7 +5368,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5337,7 +5387,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5360,7 +5410,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ULEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5379,7 +5429,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void ULEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5402,7 +5452,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void UGEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntVectorMaxTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5421,7 +5471,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpMaskProvider") - static void UGEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5444,7 +5494,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void LTIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5454,13 +5504,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5474,13 +5524,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void LTIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTIntVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5490,13 +5540,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void LTIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTIntVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5510,13 +5560,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (int)((long)b[i])))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5526,13 +5576,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5546,13 +5596,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "intCompareOpProvider") - static void EQIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQIntVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5562,13 +5612,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @Test(dataProvider = "intCompareOpMaskProvider") - static void EQIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQIntVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5582,7 +5632,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (int)((long)b[i])))); } } } @@ -5592,7 +5642,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendIntMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendIntVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5608,11 +5658,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, IntMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, IntVectorMaxTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void RearrangeIntMaxVectorTests(IntFunction fa, + static void RearrangeIntVectorMaxTests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5629,7 +5679,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void RearrangeIntMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeIntVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -5647,7 +5697,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void compressIntMaxVectorTests(IntFunction fa, + static void compressIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5665,7 +5715,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpMaskProvider") - static void expandIntMaxVectorTests(IntFunction fa, + static void expandIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5683,7 +5733,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void getIntMaxVectorTests(IntFunction fa) { + static void getIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -5839,7 +5889,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastIntMaxVectorTests(IntFunction fa) { + static void BroadcastIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5853,7 +5903,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZeroIntMaxVectorTests(IntFunction fa) { + static void ZeroIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5878,7 +5928,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void sliceUnaryIntMaxVectorTests(IntFunction fa) { + static void sliceUnaryIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5889,7 +5939,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, IntMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, IntVectorMaxTests::sliceUnary); } static int[] sliceBinary(int[] a, int[] b, int origin, int idx) { @@ -5906,7 +5956,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void sliceBinaryIntMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryIntVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -5919,7 +5969,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, IntMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, IntVectorMaxTests::sliceBinary); } static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) { @@ -5936,7 +5986,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void sliceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -5953,7 +6003,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, IntMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, IntVectorMaxTests::slice); } static int[] unsliceUnary(int[] a, int origin, int idx) { @@ -5970,7 +6020,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void unsliceUnaryIntMaxVectorTests(IntFunction fa) { + static void unsliceUnaryIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5981,7 +6031,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, IntMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, IntVectorMaxTests::unsliceUnary); } static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) { @@ -6007,7 +6057,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpProvider") - static void unsliceBinaryIntMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryIntVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -6021,7 +6071,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, IntMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, IntVectorMaxTests::unsliceBinary); } static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) { @@ -6061,7 +6111,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void unsliceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6078,7 +6128,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, IntMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, IntVectorMaxTests::unslice); } static int BITWISE_BLEND(int a, int b, int c) { @@ -6090,7 +6140,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDIntMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6105,11 +6155,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendIntMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6122,11 +6172,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, IntVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6144,11 +6194,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6159,11 +6209,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6174,11 +6224,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6189,11 +6239,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector bv = IntVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6204,11 +6254,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { IntVector cv = IntVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6223,11 +6273,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6242,11 +6292,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDIntVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6257,11 +6307,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "intTernaryOpProvider") - static void bitwiseBlendIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendIntVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] c = fc.apply(SPECIES.length()); @@ -6272,11 +6322,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, IntVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "intTernaryOpMaskProvider") - static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDIntVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6290,19 +6340,19 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntVectorMaxTests::BITWISE_BLEND); } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void NEGIntMaxVectorTests(IntFunction fa) { + static void NEGIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6313,11 +6363,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::NEG); + assertArraysEquals(r, a, IntVectorMaxTests::NEG); } @Test(dataProvider = "intUnaryOpProvider") - static void negIntMaxVectorTests(IntFunction fa) { + static void negIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6328,11 +6378,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::neg); + assertArraysEquals(r, a, IntVectorMaxTests::neg); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NEGMaskedIntMaxVectorTests(IntFunction fa, + static void NEGMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6346,19 +6396,19 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, IntVectorMaxTests::NEG); } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") - static void ABSIntMaxVectorTests(IntFunction fa) { + static void ABSIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6369,11 +6419,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::ABS); + assertArraysEquals(r, a, IntVectorMaxTests::ABS); } @Test(dataProvider = "intUnaryOpProvider") - static void absIntMaxVectorTests(IntFunction fa) { + static void absIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6384,11 +6434,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::abs); + assertArraysEquals(r, a, IntVectorMaxTests::abs); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ABSMaskedIntMaxVectorTests(IntFunction fa, + static void ABSMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6402,7 +6452,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, IntVectorMaxTests::ABS); } static int NOT(int a) { @@ -6414,7 +6464,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void NOTIntMaxVectorTests(IntFunction fa) { + static void NOTIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6425,11 +6475,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::NOT); + assertArraysEquals(r, a, IntVectorMaxTests::NOT); } @Test(dataProvider = "intUnaryOpProvider") - static void notIntMaxVectorTests(IntFunction fa) { + static void notIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6440,11 +6490,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::not); + assertArraysEquals(r, a, IntVectorMaxTests::not); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void NOTMaskedIntMaxVectorTests(IntFunction fa, + static void NOTMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6458,7 +6508,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, IntVectorMaxTests::NOT); } static int ZOMO(int a) { @@ -6466,7 +6516,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void ZOMOIntMaxVectorTests(IntFunction fa) { + static void ZOMOIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6477,11 +6527,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::ZOMO); + assertArraysEquals(r, a, IntVectorMaxTests::ZOMO); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ZOMOMaskedIntMaxVectorTests(IntFunction fa, + static void ZOMOMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6495,7 +6545,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, IntVectorMaxTests::ZOMO); } static int BIT_COUNT(int a) { @@ -6503,7 +6553,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void BIT_COUNTIntMaxVectorTests(IntFunction fa) { + static void BIT_COUNTIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6514,11 +6564,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, IntVectorMaxTests::BIT_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void BIT_COUNTMaskedIntMaxVectorTests(IntFunction fa, + static void BIT_COUNTMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6532,7 +6582,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, IntVectorMaxTests::BIT_COUNT); } static int TRAILING_ZEROS_COUNT(int a) { @@ -6540,7 +6590,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void TRAILING_ZEROS_COUNTIntMaxVectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6551,11 +6601,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVectorMaxTests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedIntMaxVectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6569,7 +6619,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVectorMaxTests::TRAILING_ZEROS_COUNT); } static int LEADING_ZEROS_COUNT(int a) { @@ -6577,7 +6627,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void LEADING_ZEROS_COUNTIntMaxVectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6588,11 +6638,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, IntVectorMaxTests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedIntMaxVectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6606,7 +6656,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, IntVectorMaxTests::LEADING_ZEROS_COUNT); } static int REVERSE(int a) { @@ -6614,7 +6664,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSEIntMaxVectorTests(IntFunction fa) { + static void REVERSEIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6625,11 +6675,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::REVERSE); + assertArraysEquals(r, a, IntVectorMaxTests::REVERSE); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSEMaskedIntMaxVectorTests(IntFunction fa, + static void REVERSEMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6643,7 +6693,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::REVERSE); + assertArraysEquals(r, a, mask, IntVectorMaxTests::REVERSE); } static int REVERSE_BYTES(int a) { @@ -6651,7 +6701,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void REVERSE_BYTESIntMaxVectorTests(IntFunction fa) { + static void REVERSE_BYTESIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6662,11 +6712,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, IntVectorMaxTests::REVERSE_BYTES); } @Test(dataProvider = "intUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedIntMaxVectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedIntVectorMaxTests(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); @@ -6680,7 +6730,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, IntMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, IntVectorMaxTests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6688,7 +6738,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6701,7 +6751,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::band); + assertArraysEquals(r, a, b, IntVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -6709,7 +6759,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6722,7 +6772,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::bor); + assertArraysEquals(r, a, b, IntVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6730,7 +6780,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6743,7 +6793,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::bxor); + assertArraysEquals(r, a, b, IntVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6751,7 +6801,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6764,7 +6814,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, IntVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6772,7 +6822,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6785,7 +6835,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, IntMaxVectorTests::beq); + assertArraysEquals(r, a, b, IntVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -6793,7 +6843,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotIntMaxVectorTests(IntFunction fa) { + static void masknotIntVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6804,7 +6854,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::unot); + assertArraysEquals(r, a, IntVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6821,7 +6871,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongIntMaxVectorTests(IntFunction fa) { + static void maskFromToLongIntVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6835,7 +6885,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intCompareOpProvider") - static void ltIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltIntVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6845,13 +6895,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "intCompareOpProvider") - static void eqIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqIntVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -6861,13 +6911,13 @@ public class IntMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "intUnaryOpProvider") - static void toIntArrayIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6878,7 +6928,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toLongArrayIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6889,7 +6939,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toDoubleArrayIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6900,7 +6950,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void toStringIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6913,7 +6963,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpProvider") - static void hashCodeIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6930,7 +6980,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { static long ADDReduceLong(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6939,14 +6989,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLong(int[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((int)res, (int)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "intUnaryOpProvider") - static void ADDReduceLongIntMaxVectorTests(IntFunction fa) { + static void ADDReduceLongIntVectorMaxTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6957,19 +7007,20 @@ public class IntMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEquals(r, ra, a, - IntMaxVectorTests::ADDReduceLong, IntMaxVectorTests::ADDReduceAllLong); + IntVectorMaxTests::ADDReduceLong, IntVectorMaxTests::ADDReduceAllLong); } static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6978,14 +7029,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(int[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((int)res, (int)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "intUnaryOpMaskProvider") - static void ADDReduceLongIntMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongIntVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6998,16 +7049,16 @@ public class IntMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((int)ra, (int)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - IntMaxVectorTests::ADDReduceLongMasked, IntMaxVectorTests::ADDReduceAllLongMasked); + IntVectorMaxTests::ADDReduceLongMasked, IntVectorMaxTests::ADDReduceAllLongMasked); } @Test(dataProvider = "intUnaryOpProvider") - static void BroadcastLongIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongIntVectorMaxTestsSmokeTest(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7018,7 +7069,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intBinaryOpMaskProvider") - static void blendIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendIntVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -7032,12 +7083,12 @@ public class IntMaxVectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, IntVectorMaxTests::blend); } @Test(dataProvider = "intUnaryOpShuffleProvider") - static void SelectFromIntMaxVectorTests(IntFunction fa, + static void SelectFromIntVectorMaxTests(IntFunction fa, BiFunction fs) { int[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -7053,7 +7104,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorIntMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorIntVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); int[] idx = fc.apply(SPECIES.length()); @@ -7071,7 +7122,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "intUnaryOpShuffleMaskProvider") - static void SelectFromIntMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromIntVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -7090,7 +7141,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousIntMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousIntVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7106,7 +7157,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringIntMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringIntVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7120,7 +7171,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsIntMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsIntVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7134,7 +7185,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsIntVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7150,7 +7201,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeIntVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7172,7 +7223,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountIntVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7183,7 +7234,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, IntVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7197,7 +7248,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueIntVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7208,7 +7259,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, IntVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7222,7 +7273,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueIntVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7233,11 +7284,11 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, IntVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressIntMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressIntVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7265,7 +7316,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeIntMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeIntVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7279,7 +7330,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongIntMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongIntVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7306,14 +7357,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundIntMaxVectorTestsSmokeTest(int length) { + static void loopBoundIntVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongIntMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongIntVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7321,21 +7372,21 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementSizeIntMaxVectorTestsSmokeTest() { + static void ElementSizeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Integer.SIZE); } @Test - static void VectorShapeIntMaxVectorTestsSmokeTest() { + static void VectorShapeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesIntMaxVectorTestsSmokeTest() { + static void ShapeWithLanesIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(int.class); @@ -7343,32 +7394,32 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementTypeIntMaxVectorTestsSmokeTest() { + static void ElementTypeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementType() == int.class); } @Test - static void SpeciesElementSizeIntMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().elementSize() == Integer.SIZE); } @Test - static void VectorTypeIntMaxVectorTestsSmokeTest() { + static void VectorTypeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesIntMaxVectorTestsSmokeTest() { + static void WithLanesIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(int.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeIntMaxVectorTestsSmokeTest() { + static void WithShapeIntVectorMaxTestsSmokeTest() { IntVector av = IntVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7376,7 +7427,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueIntMaxVectorTestsSmokeTest() { + static void MaskAllTrueIntVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/LongVector128LoadStoreTests.java index 20df291542f..3aa9c93e0d7 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Long128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation LongVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Long128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class LongVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = LongVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/LongVector128Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Long128VectorTests.java rename to test/jdk/jdk/incubator/vector/LongVector128Tests.java index 9847f79fc04..49e2e1a0078 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Long128VectorTests extends AbstractVectorTest { +public class LongVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = LongVector.SPECIES_128; @@ -1547,6 +1547,59 @@ public class Long128VectorTests extends AbstractVectorTest { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1563,9 +1616,6 @@ public class Long128VectorTests extends AbstractVectorTest { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1679,11 +1729,11 @@ public class Long128VectorTests extends AbstractVectorTest { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1696,15 +1746,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::ADD); + assertArraysEquals(r, a, b, LongVector128Tests::ADD); } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong128VectorTests(IntFunction fa, IntFunction fb) { + static void addLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1715,11 +1765,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::add); + assertArraysEquals(r, a, b, LongVector128Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1735,11 +1785,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, LongVector128Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1753,15 +1803,15 @@ public class Long128VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long128VectorTests::add); + assertArraysEquals(r, a, b, mask, LongVector128Tests::add); } static long SUB(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void SUBLong128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1774,15 +1824,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::SUB); + assertArraysEquals(r, a, b, LongVector128Tests::SUB); } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong128VectorTests(IntFunction fa, IntFunction fb) { + static void subLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1793,11 +1843,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::sub); + assertArraysEquals(r, a, b, LongVector128Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void SUBLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1813,11 +1863,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, LongVector128Tests::SUB); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1831,15 +1881,15 @@ public class Long128VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long128VectorTests::sub); + assertArraysEquals(r, a, b, mask, LongVector128Tests::sub); } static long MUL(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MULLong128VectorTests(IntFunction fa, IntFunction fb) { + static void MULLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1852,15 +1902,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::MUL); + assertArraysEquals(r, a, b, LongVector128Tests::MUL); } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong128VectorTests(IntFunction fa, IntFunction fb) { + static void mulLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1871,11 +1921,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::mul); + assertArraysEquals(r, a, b, LongVector128Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void MULLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1891,11 +1941,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, LongVector128Tests::MUL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1909,7 +1959,7 @@ public class Long128VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long128VectorTests::mul); + assertArraysEquals(r, a, b, mask, LongVector128Tests::mul); } static long DIV(long a, long b) { @@ -1917,7 +1967,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void DIVLong128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1932,7 +1982,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::DIV); + assertArraysEquals(r, a, b, LongVector128Tests::DIV); } static long div(long a, long b) { @@ -1940,7 +1990,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void divLong128VectorTests(IntFunction fa, IntFunction fb) { + static void divLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1955,11 +2005,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::div); + assertArraysEquals(r, a, b, LongVector128Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void DIVLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, LongVector128Tests::DIV); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1999,15 +2049,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::div); + assertArraysEquals(r, a, b, mask, LongVector128Tests::div); } static long FIRST_NONZERO(long a, long b) { - return (long)((a)!=0?a:b); + return (long)(firstNonZero(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void FIRST_NONZEROLong128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2020,11 +2070,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void FIRST_NONZEROLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2040,7 +2090,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongVector128Tests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -2048,7 +2098,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ANDLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2061,7 +2111,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::AND); + assertArraysEquals(r, a, b, LongVector128Tests::AND); } static long and(long a, long b) { @@ -2069,7 +2119,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void andLong128VectorTests(IntFunction fa, IntFunction fb) { + static void andLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2080,11 +2130,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::and); + assertArraysEquals(r, a, b, LongVector128Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2100,7 +2150,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::AND); + assertArraysEquals(r, a, b, mask, LongVector128Tests::AND); } static long AND_NOT(long a, long b) { @@ -2108,7 +2158,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void AND_NOTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2121,11 +2171,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, LongVector128Tests::AND_NOT); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void AND_NOTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2141,7 +2191,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongVector128Tests::AND_NOT); } static long OR(long a, long b) { @@ -2149,7 +2199,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ORLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2162,7 +2212,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::OR); + assertArraysEquals(r, a, b, LongVector128Tests::OR); } static long or(long a, long b) { @@ -2170,7 +2220,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void orLong128VectorTests(IntFunction fa, IntFunction fb) { + static void orLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2231,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::or); + assertArraysEquals(r, a, b, LongVector128Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2201,7 +2251,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::OR); + assertArraysEquals(r, a, b, mask, LongVector128Tests::OR); } static long XOR(long a, long b) { @@ -2209,7 +2259,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void XORLong128VectorTests(IntFunction fa, IntFunction fb) { + static void XORLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2222,11 +2272,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::XOR); + assertArraysEquals(r, a, b, LongVector128Tests::XOR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void XORLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2242,7 +2292,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::XOR); + assertArraysEquals(r, a, b, mask, LongVector128Tests::XOR); } static long COMPRESS_BITS(long a, long b) { @@ -2250,7 +2300,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void COMPRESS_BITSLong128VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2263,11 +2313,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, LongVector128Tests::COMPRESS_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void COMPRESS_BITSLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2283,7 +2333,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, LongVector128Tests::COMPRESS_BITS); } static long EXPAND_BITS(long a, long b) { @@ -2291,7 +2341,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void EXPAND_BITSLong128VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2304,11 +2354,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, LongVector128Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void EXPAND_BITSLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2324,11 +2374,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, LongVector128Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2338,11 +2388,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2355,11 +2405,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::add); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2369,11 +2419,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2386,11 +2436,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::sub); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2400,11 +2450,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::mul); } @Test(dataProvider = "longBinaryOpProvider") - static void divLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2433,11 +2483,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2452,11 +2502,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::div); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2466,11 +2516,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void orLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2480,11 +2530,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2497,11 +2547,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2511,11 +2561,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void andLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2525,11 +2575,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2542,11 +2592,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongVector128Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongVector128Tests::OR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2573,11 +2623,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector128Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDLongVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2587,11 +2637,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongVector128Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDLongVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2604,7 +2654,7 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector128Tests::ADD); } static long LSHL(long a, long b) { @@ -2612,7 +2662,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2625,11 +2675,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::LSHL); + assertArraysEquals(r, a, b, LongVector128Tests::LSHL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2645,7 +2695,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, LongVector128Tests::LSHL); } static long ASHR(long a, long b) { @@ -2653,7 +2703,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2666,11 +2716,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::ASHR); + assertArraysEquals(r, a, b, LongVector128Tests::ASHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2686,7 +2736,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, LongVector128Tests::ASHR); } static long LSHR(long a, long b) { @@ -2694,7 +2744,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2707,11 +2757,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::LSHR); + assertArraysEquals(r, a, b, LongVector128Tests::LSHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2727,7 +2777,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, LongVector128Tests::LSHR); } static long LSHL_unary(long a, long b) { @@ -2735,7 +2785,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLLongVector128TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2747,11 +2797,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, LongVector128Tests::LSHL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2766,7 +2816,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector128Tests::LSHL_unary); } static long LSHR_unary(long a, long b) { @@ -2774,7 +2824,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRLongVector128TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2786,11 +2836,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, LongVector128Tests::LSHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2805,7 +2855,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector128Tests::LSHR_unary); } static long ASHR_unary(long a, long b) { @@ -2813,7 +2863,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRLongVector128TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2825,11 +2875,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, LongVector128Tests::ASHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2844,7 +2894,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector128Tests::ASHR_unary); } static long ROR(long a, long b) { @@ -2852,7 +2902,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong128VectorTests(IntFunction fa, IntFunction fb) { + static void RORLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2865,11 +2915,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::ROR); + assertArraysEquals(r, a, b, LongVector128Tests::ROR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2885,7 +2935,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::ROR); + assertArraysEquals(r, a, b, mask, LongVector128Tests::ROR); } static long ROL(long a, long b) { @@ -2893,7 +2943,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ROLLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2906,11 +2956,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::ROL); + assertArraysEquals(r, a, b, LongVector128Tests::ROL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2926,7 +2976,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::ROL); + assertArraysEquals(r, a, b, mask, LongVector128Tests::ROL); } static long ROR_unary(long a, long b) { @@ -2934,7 +2984,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORLongVector128TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2946,11 +2996,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, LongVector128Tests::ROR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORLongVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2965,7 +3015,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector128Tests::ROR_unary); } static long ROL_unary(long a, long b) { @@ -2973,7 +3023,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLLongVector128TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2985,11 +3035,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, LongVector128Tests::ROL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3004,14 +3054,14 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector128Tests::ROL_unary); } static long LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT)); } @Test(dataProvider = "longUnaryOpProvider") - static void LSHRLong128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRLongVector128TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3022,11 +3072,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, LongVector128Tests::LSHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHRLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRLongVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3040,7 +3090,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector128Tests::LSHR_binary_const); } static long LSHL_binary_const(long a) { @@ -3048,7 +3098,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LSHLLong128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLLongVector128TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3059,11 +3109,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, LongVector128Tests::LSHL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHLLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLLongVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3077,7 +3127,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector128Tests::LSHL_binary_const); } static long ASHR_binary_const(long a) { @@ -3085,7 +3135,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ASHRLong128VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRLongVector128TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3096,11 +3146,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, LongVector128Tests::ASHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ASHRLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRLongVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3114,7 +3164,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector128Tests::ASHR_binary_const); } static long ROR_binary_const(long a) { @@ -3122,7 +3172,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void RORLong128VectorTestsScalarShiftConst(IntFunction fa) { + static void RORLongVector128TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3133,11 +3183,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, LongVector128Tests::ROR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void RORLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORLongVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3151,7 +3201,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector128Tests::ROR_binary_const); } static long ROL_binary_const(long a) { @@ -3159,7 +3209,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ROLLong128VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLLongVector128TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3170,11 +3220,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, LongVector128Tests::ROL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ROLLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLLongVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3188,14 +3238,14 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector128Tests::ROL_binary_const); } static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MINLong128VectorTestsWithMemOp(IntFunction fa) { + static void MINLongVector128TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3206,13 +3256,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long128VectorTests::MIN); + assertArraysEquals(r, a, (long)10, LongVector128Tests::MIN); } static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void minLong128VectorTestsWithMemOp(IntFunction fa) { + static void minLongVector128TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3223,13 +3273,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long128VectorTests::min); + assertArraysEquals(r, a, (long)10, LongVector128Tests::min); } static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINLongVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3242,13 +3292,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long128VectorTests::MIN); + assertArraysEquals(r, a, (long)10, mask, LongVector128Tests::MIN); } static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MAXLong128VectorTestsWithMemOp(IntFunction fa) { + static void MAXLongVector128TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3259,13 +3309,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long128VectorTests::MAX); + assertArraysEquals(r, a, (long)10, LongVector128Tests::MAX); } static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void maxLong128VectorTestsWithMemOp(IntFunction fa) { + static void maxLongVector128TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3276,13 +3326,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long128VectorTests::max); + assertArraysEquals(r, a, (long)10, LongVector128Tests::max); } static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXLongVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3295,15 +3345,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long128VectorTests::MAX); + assertArraysEquals(r, a, (long)10, mask, LongVector128Tests::MAX); } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong128VectorTests(IntFunction fa, IntFunction fb) { + static void MINLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3316,15 +3366,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::MIN); + assertArraysEquals(r, a, b, LongVector128Tests::MIN); } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong128VectorTests(IntFunction fa, IntFunction fb) { + static void minLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3335,15 +3385,15 @@ public class Long128VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::min); + assertArraysEquals(r, a, b, LongVector128Tests::min); } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3356,15 +3406,15 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::MAX); + assertArraysEquals(r, a, b, LongVector128Tests::MAX); } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maxLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3375,7 +3425,7 @@ public class Long128VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long128VectorTests::max); + assertArraysEquals(r, a, b, LongVector128Tests::max); } static long UMIN(long a, long b) { @@ -3383,7 +3433,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMINLong128VectorTests(IntFunction fa, IntFunction fb) { + static void UMINLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3396,11 +3446,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::UMIN); + assertArraysEquals(r, a, b, LongVector128Tests::UMIN); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMINLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3416,7 +3466,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, LongVector128Tests::UMIN); } static long UMAX(long a, long b) { @@ -3424,7 +3474,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMAXLong128VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3437,11 +3487,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::UMAX); + assertArraysEquals(r, a, b, LongVector128Tests::UMAX); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMAXLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3457,7 +3507,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, LongVector128Tests::UMAX); } static long SADD(long a, long b) { @@ -3465,7 +3515,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SADDLong128VectorTests(IntFunction fa, IntFunction fb) { + static void SADDLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3478,11 +3528,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::SADD); + assertArraysEquals(r, a, b, LongVector128Tests::SADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SADDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3498,7 +3548,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::SADD); + assertArraysEquals(r, a, b, mask, LongVector128Tests::SADD); } static long SSUB(long a, long b) { @@ -3506,7 +3556,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SSUBLong128VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3519,11 +3569,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::SSUB); + assertArraysEquals(r, a, b, LongVector128Tests::SSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SSUBLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3539,7 +3589,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, LongVector128Tests::SSUB); } static long SUADD(long a, long b) { @@ -3547,7 +3597,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUADDLong128VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3560,11 +3610,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::SUADD); + assertArraysEquals(r, a, b, LongVector128Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUADDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3580,7 +3630,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, LongVector128Tests::SUADD); } static long SUSUB(long a, long b) { @@ -3588,7 +3638,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUSUBLong128VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3601,11 +3651,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::SUSUB); + assertArraysEquals(r, a, b, LongVector128Tests::SUSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUSUBLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3621,11 +3671,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, LongVector128Tests::SUSUB); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3635,11 +3685,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::MIN); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3649,11 +3699,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::min); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3663,11 +3713,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::MAX); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3677,10 +3727,10 @@ public class Long128VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongVector128Tests::max); } @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") - static void SUADDAssocLong128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocLongVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -3697,11 +3747,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Long128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, LongVector128Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3722,13 +3772,13 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Long128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongVector128Tests::SUADD); } static long ANDReduce(long[] a, int idx) { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3737,14 +3787,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ANDReduceAll(long[] a) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ANDReduceLong128VectorTests(IntFunction fa) { + static void ANDReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3755,12 +3805,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::ANDReduce, Long128VectorTests::ANDReduceAll); + LongVector128Tests::ANDReduce, LongVector128Tests::ANDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3768,20 +3818,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = AND_IDENTITY; - assertEquals((long) (id & id), id, + assertEquals((long) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id & x), x); - assertEquals((long) (x & id), x); + assertEquals((long) (scalar_and(id, x)), x); + assertEquals((long) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id & x), x, + assertEquals((long) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x & id), x, + assertEquals((long) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3790,7 +3840,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3799,14 +3849,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ANDReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3819,18 +3869,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::ANDReduceMasked, Long128VectorTests::ANDReduceAllMasked); + LongVector128Tests::ANDReduceMasked, LongVector128Tests::ANDReduceAllMasked); } static long ORReduce(long[] a, int idx) { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3839,14 +3889,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ORReduceAll(long[] a) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ORReduceLong128VectorTests(IntFunction fa) { + static void ORReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3857,12 +3907,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::ORReduce, Long128VectorTests::ORReduceAll); + LongVector128Tests::ORReduce, LongVector128Tests::ORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3870,20 +3920,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = OR_IDENTITY; - assertEquals((long) (id | id), id, + assertEquals((long) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id | x), x); - assertEquals((long) (x | id), x); + assertEquals((long) (scalar_or(id, x)), x); + assertEquals((long) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id | x), x, + assertEquals((long) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x | id), x, + assertEquals((long) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3892,7 +3942,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3901,14 +3951,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ORReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3921,18 +3971,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::ORReduceMasked, Long128VectorTests::ORReduceAllMasked); + LongVector128Tests::ORReduceMasked, LongVector128Tests::ORReduceAllMasked); } static long XORReduce(long[] a, int idx) { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3941,14 +3991,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long XORReduceAll(long[] a) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void XORReduceLong128VectorTests(IntFunction fa) { + static void XORReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3959,12 +4009,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::XORReduce, Long128VectorTests::XORReduceAll); + LongVector128Tests::XORReduce, LongVector128Tests::XORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3972,20 +4022,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = XOR_IDENTITY; - assertEquals((long) (id ^ id), id, + assertEquals((long) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id ^ x), x); - assertEquals((long) (x ^ id), x); + assertEquals((long) (scalar_xor(id, x)), x); + assertEquals((long) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id ^ x), x, + assertEquals((long) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x ^ id), x, + assertEquals((long) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3994,7 +4044,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -4003,14 +4053,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void XORReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4023,18 +4073,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::XORReduceMasked, Long128VectorTests::XORReduceAllMasked); + LongVector128Tests::XORReduceMasked, LongVector128Tests::XORReduceAllMasked); } static long ADDReduce(long[] a, int idx) { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4043,14 +4093,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ADDReduceAll(long[] a) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLong128VectorTests(IntFunction fa) { + static void ADDReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4061,12 +4111,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::ADDReduce, Long128VectorTests::ADDReduceAll); + LongVector128Tests::ADDReduce, LongVector128Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4074,20 +4124,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = ADD_IDENTITY; - assertEquals((long) (id + id), id, + assertEquals((long) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id + x), x); - assertEquals((long) (x + id), x); + assertEquals((long) (scalar_add(id, x)), x); + assertEquals((long) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id + x), x, + assertEquals((long) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x + id), x, + assertEquals((long) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4096,7 +4146,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4105,14 +4155,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long ADDReduceAllMasked(long[] a, boolean[] mask) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4125,18 +4175,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::ADDReduceMasked, Long128VectorTests::ADDReduceAllMasked); + LongVector128Tests::ADDReduceMasked, LongVector128Tests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4145,14 +4195,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MULReduceAll(long[] a) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MULReduceLong128VectorTests(IntFunction fa) { + static void MULReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4163,12 +4213,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::MULReduce, Long128VectorTests::MULReduceAll); + LongVector128Tests::MULReduce, LongVector128Tests::MULReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4176,20 +4226,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MUL_IDENTITY; - assertEquals((long) (id * id), id, + assertEquals((long) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id * x), x); - assertEquals((long) (x * id), x); + assertEquals((long) (scalar_mul(id, x)), x); + assertEquals((long) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id * x), x, + assertEquals((long) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x * id), x, + assertEquals((long) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4198,7 +4248,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4207,14 +4257,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MULReduceAllMasked(long[] a, boolean[] mask) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MULReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4227,18 +4277,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::MULReduceMasked, Long128VectorTests::MULReduceAllMasked); + LongVector128Tests::MULReduceMasked, LongVector128Tests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4247,14 +4297,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MINReduceAll(long[] a) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MINReduceLong128VectorTests(IntFunction fa) { + static void MINReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4265,12 +4315,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::MINReduce, Long128VectorTests::MINReduceAll); + LongVector128Tests::MINReduce, LongVector128Tests::MINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4278,20 +4328,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MIN_IDENTITY; - assertEquals((long) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.min(id, x), x); - assertEquals((long) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4300,7 +4350,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4309,14 +4359,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MINReduceAllMasked(long[] a, boolean[] mask) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4329,18 +4379,18 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::MINReduceMasked, Long128VectorTests::MINReduceAllMasked); + LongVector128Tests::MINReduceMasked, LongVector128Tests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4349,14 +4399,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MAXReduceAll(long[] a) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MAXReduceLong128VectorTests(IntFunction fa) { + static void MAXReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4367,12 +4417,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::MAXReduce, Long128VectorTests::MAXReduceAll); + LongVector128Tests::MAXReduce, LongVector128Tests::MAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4380,20 +4430,20 @@ public class Long128VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MAX_IDENTITY; - assertEquals((long) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.max(id, x), x); - assertEquals((long) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4402,7 +4452,7 @@ public class Long128VectorTests extends AbstractVectorTest { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4411,14 +4461,14 @@ public class Long128VectorTests extends AbstractVectorTest { static long MAXReduceAllMasked(long[] a, boolean[] mask) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4431,12 +4481,12 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::MAXReduceMasked, Long128VectorTests::MAXReduceAllMasked); + LongVector128Tests::MAXReduceMasked, LongVector128Tests::MAXReduceAllMasked); } static long UMINReduce(long[] a, int idx) { @@ -4458,7 +4508,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMINReduceLong128VectorTests(IntFunction fa) { + static void UMINReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4474,7 +4524,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::UMINReduce, Long128VectorTests::UMINReduceAll); + LongVector128Tests::UMINReduce, LongVector128Tests::UMINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4520,7 +4570,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMINReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4538,7 +4588,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::UMINReduceMasked, Long128VectorTests::UMINReduceAllMasked); + LongVector128Tests::UMINReduceMasked, LongVector128Tests::UMINReduceAllMasked); } static long UMAXReduce(long[] a, int idx) { @@ -4560,7 +4610,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMAXReduceLong128VectorTests(IntFunction fa) { + static void UMAXReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4576,7 +4626,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::UMAXReduce, Long128VectorTests::UMAXReduceAll); + LongVector128Tests::UMAXReduce, LongVector128Tests::UMAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4622,7 +4672,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4640,7 +4690,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::UMAXReduceMasked, Long128VectorTests::UMAXReduceAllMasked); + LongVector128Tests::UMAXReduceMasked, LongVector128Tests::UMAXReduceAllMasked); } static long FIRST_NONZEROReduce(long[] a, int idx) { @@ -4662,7 +4712,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void FIRST_NONZEROReduceLong128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4678,7 +4728,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::FIRST_NONZEROReduce, Long128VectorTests::FIRST_NONZEROReduceAll); + LongVector128Tests::FIRST_NONZEROReduce, LongVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4724,7 +4774,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void FIRST_NONZEROReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4742,7 +4792,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::FIRST_NONZEROReduceMasked, Long128VectorTests::FIRST_NONZEROReduceAllMasked); + LongVector128Tests::FIRST_NONZEROReduceMasked, LongVector128Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4755,7 +4805,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueLong128VectorTests(IntFunction fm) { + static void anyTrueLongVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4766,7 +4816,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongVector128Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4779,7 +4829,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueLong128VectorTests(IntFunction fm) { + static void allTrueLongVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4790,7 +4840,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongVector128Tests::allTrue); } static long SUADDReduce(long[] a, int idx) { @@ -4812,7 +4862,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingUnaryOpProvider") - static void SUADDReduceLong128VectorTests(IntFunction fa) { + static void SUADDReduceLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4828,7 +4878,7 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::SUADDReduce, Long128VectorTests::SUADDReduceAll); + LongVector128Tests::SUADDReduce, LongVector128Tests::SUADDReduceAll); } @Test(dataProvider = "longSaturatingUnaryOpProvider") @@ -4873,7 +4923,7 @@ public class Long128VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") - static void SUADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4891,11 +4941,11 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::SUADDReduceMasked, Long128VectorTests::SUADDReduceAllMasked); + LongVector128Tests::SUADDReduceMasked, LongVector128Tests::SUADDReduceAllMasked); } @Test(dataProvider = "longBinaryOpProvider") - static void withLong128VectorTests(IntFunction fa, IntFunction fb) { + static void withLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -4918,7 +4968,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_DEFAULTLong128VectorTests(IntFunction fa) { + static void IS_DEFAULTLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4935,7 +4985,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_DEFAULTMaskedLong128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4959,7 +5009,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_NEGATIVELong128VectorTests(IntFunction fa) { + static void IS_NEGATIVELongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4976,7 +5026,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_NEGATIVEMaskedLong128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4996,7 +5046,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void LTLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5015,7 +5065,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ltLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5034,7 +5084,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5057,7 +5107,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void GTLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5076,7 +5126,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5099,7 +5149,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void EQLong128VectorTests(IntFunction fa, IntFunction fb) { + static void EQLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5118,7 +5168,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void eqLong128VectorTests(IntFunction fa, IntFunction fb) { + static void eqLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5137,7 +5187,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5160,7 +5210,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void NELong128VectorTests(IntFunction fa, IntFunction fb) { + static void NELongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5179,7 +5229,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void NELong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NELongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5202,7 +5252,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LELong128VectorTests(IntFunction fa, IntFunction fb) { + static void LELongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5221,7 +5271,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LELong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LELongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5244,7 +5294,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GELong128VectorTests(IntFunction fa, IntFunction fb) { + static void GELongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5263,7 +5313,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GELong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GELongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5286,7 +5336,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void ULTLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5305,7 +5355,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5328,7 +5378,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5347,7 +5397,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5370,7 +5420,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULELong128VectorTests(IntFunction fa, IntFunction fb) { + static void ULELongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5389,7 +5439,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULELong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULELongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5412,7 +5462,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGELong128VectorTests(IntFunction fa, IntFunction fb) { + static void UGELongVector128Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5431,7 +5481,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGELong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGELongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5454,7 +5504,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5464,13 +5514,13 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5484,14 +5534,14 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "longCompareOpProvider") - static void EQLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5501,13 +5551,13 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5521,7 +5571,7 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5532,7 +5582,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void blendLong128VectorTests(IntFunction fa, IntFunction fb, + static void blendLongVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5548,11 +5598,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long128VectorTests::blend); + assertArraysEquals(r, a, b, mask, LongVector128Tests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") - static void RearrangeLong128VectorTests(IntFunction fa, + static void RearrangeLongVector128Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5569,7 +5619,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") - static void RearrangeLong128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeLongVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -5587,7 +5637,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void compressLong128VectorTests(IntFunction fa, + static void compressLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5605,7 +5655,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void expandLong128VectorTests(IntFunction fa, + static void expandLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void getLong128VectorTests(IntFunction fa) { + static void getLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5779,7 +5829,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BroadcastLong128VectorTests(IntFunction fa) { + static void BroadcastLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5793,7 +5843,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZeroLong128VectorTests(IntFunction fa) { + static void ZeroLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5818,7 +5868,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void sliceUnaryLong128VectorTests(IntFunction fa) { + static void sliceUnaryLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5829,7 +5879,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongVector128Tests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { @@ -5846,7 +5896,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void sliceBinaryLong128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryLongVector128TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5859,7 +5909,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Long128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongVector128Tests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { @@ -5876,7 +5926,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void sliceLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5893,7 +5943,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Long128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, LongVector128Tests::slice); } static long[] unsliceUnary(long[] a, int origin, int idx) { @@ -5910,7 +5960,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void unsliceUnaryLong128VectorTests(IntFunction fa) { + static void unsliceUnaryLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5921,7 +5971,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongVector128Tests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { @@ -5947,7 +5997,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void unsliceBinaryLong128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryLongVector128TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5961,7 +6011,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Long128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongVector128Tests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { @@ -6001,7 +6051,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void unsliceLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6018,7 +6068,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Long128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongVector128Tests::unslice); } static long BITWISE_BLEND(long a, long b, long c) { @@ -6030,7 +6080,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6045,11 +6095,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Long128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6062,11 +6112,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Long128VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, LongVector128Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6084,11 +6134,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Long128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6114,11 +6164,11 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6129,11 +6179,11 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongVector128Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6144,11 +6194,11 @@ public class Long128VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long128VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector128Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6163,11 +6213,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Long128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6182,11 +6232,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Long128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6197,11 +6247,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6212,11 +6262,11 @@ public class Long128VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long128VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector128Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6230,19 +6280,19 @@ public class Long128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongVector128Tests::BITWISE_BLEND); } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void NEGLong128VectorTests(IntFunction fa) { + static void NEGLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6253,11 +6303,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::NEG); + assertArraysEquals(r, a, LongVector128Tests::NEG); } @Test(dataProvider = "longUnaryOpProvider") - static void negLong128VectorTests(IntFunction fa) { + static void negLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6268,11 +6318,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::neg); + assertArraysEquals(r, a, LongVector128Tests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NEGMaskedLong128VectorTests(IntFunction fa, + static void NEGMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6286,19 +6336,19 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::NEG); + assertArraysEquals(r, a, mask, LongVector128Tests::NEG); } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void ABSLong128VectorTests(IntFunction fa) { + static void ABSLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6309,11 +6359,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::ABS); + assertArraysEquals(r, a, LongVector128Tests::ABS); } @Test(dataProvider = "longUnaryOpProvider") - static void absLong128VectorTests(IntFunction fa) { + static void absLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6324,11 +6374,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::abs); + assertArraysEquals(r, a, LongVector128Tests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ABSMaskedLong128VectorTests(IntFunction fa, + static void ABSMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6342,7 +6392,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::ABS); + assertArraysEquals(r, a, mask, LongVector128Tests::ABS); } static long NOT(long a) { @@ -6354,7 +6404,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void NOTLong128VectorTests(IntFunction fa) { + static void NOTLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6365,11 +6415,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::NOT); + assertArraysEquals(r, a, LongVector128Tests::NOT); } @Test(dataProvider = "longUnaryOpProvider") - static void notLong128VectorTests(IntFunction fa) { + static void notLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6380,11 +6430,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::not); + assertArraysEquals(r, a, LongVector128Tests::not); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NOTMaskedLong128VectorTests(IntFunction fa, + static void NOTMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6398,7 +6448,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::NOT); + assertArraysEquals(r, a, mask, LongVector128Tests::NOT); } static long ZOMO(long a) { @@ -6406,7 +6456,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZOMOLong128VectorTests(IntFunction fa) { + static void ZOMOLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6417,11 +6467,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::ZOMO); + assertArraysEquals(r, a, LongVector128Tests::ZOMO); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ZOMOMaskedLong128VectorTests(IntFunction fa, + static void ZOMOMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6435,7 +6485,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongVector128Tests::ZOMO); } static long BIT_COUNT(long a) { @@ -6443,7 +6493,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BIT_COUNTLong128VectorTests(IntFunction fa) { + static void BIT_COUNTLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6454,11 +6504,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, LongVector128Tests::BIT_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void BIT_COUNTMaskedLong128VectorTests(IntFunction fa, + static void BIT_COUNTMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6472,7 +6522,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, LongVector128Tests::BIT_COUNT); } static long TRAILING_ZEROS_COUNT(long a) { @@ -6480,7 +6530,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void TRAILING_ZEROS_COUNTLong128VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6491,11 +6541,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector128Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedLong128VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6509,7 +6559,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector128Tests::TRAILING_ZEROS_COUNT); } static long LEADING_ZEROS_COUNT(long a) { @@ -6517,7 +6567,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LEADING_ZEROS_COUNTLong128VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6528,11 +6578,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector128Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedLong128VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6546,7 +6596,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector128Tests::LEADING_ZEROS_COUNT); } static long REVERSE(long a) { @@ -6554,7 +6604,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSELong128VectorTests(IntFunction fa) { + static void REVERSELongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6565,11 +6615,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::REVERSE); + assertArraysEquals(r, a, LongVector128Tests::REVERSE); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSEMaskedLong128VectorTests(IntFunction fa, + static void REVERSEMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6583,7 +6633,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::REVERSE); + assertArraysEquals(r, a, mask, LongVector128Tests::REVERSE); } static long REVERSE_BYTES(long a) { @@ -6591,7 +6641,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSE_BYTESLong128VectorTests(IntFunction fa) { + static void REVERSE_BYTESLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6602,11 +6652,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, LongVector128Tests::REVERSE_BYTES); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedLong128VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedLongVector128Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6620,7 +6670,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, LongVector128Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6628,7 +6678,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6641,7 +6691,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::band); + assertArraysEquals(r, a, b, LongVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6649,7 +6699,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6662,7 +6712,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::bor); + assertArraysEquals(r, a, b, LongVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6670,7 +6720,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6683,7 +6733,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::bxor); + assertArraysEquals(r, a, b, LongVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6691,7 +6741,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6704,7 +6754,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::bandNot); + assertArraysEquals(r, a, b, LongVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6712,7 +6762,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6725,7 +6775,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long128VectorTests::beq); + assertArraysEquals(r, a, b, LongVector128Tests::beq); } static boolean unot(boolean a) { @@ -6733,7 +6783,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotLong128VectorTests(IntFunction fa) { + static void masknotLongVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6744,7 +6794,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::unot); + assertArraysEquals(r, a, LongVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6761,7 +6811,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongLong128VectorTests(IntFunction fa) { + static void maskFromToLongLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6775,7 +6825,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltLongVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6785,13 +6835,13 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpProvider") - static void eqLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqLongVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6801,13 +6851,13 @@ public class Long128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longtoIntUnaryOpProvider") - static void toIntArrayLong128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayLongVector128TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6818,7 +6868,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toLongArrayLong128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayLongVector128TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6829,7 +6879,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toDoubleArrayLong128VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayLongVector128TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6840,7 +6890,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toStringLong128VectorTestsSmokeTest(IntFunction fa) { + static void toStringLongVector128TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6853,7 +6903,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void hashCodeLong128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeLongVector128TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6869,7 +6919,7 @@ public class Long128VectorTests extends AbstractVectorTest { @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongLong128VectorTests(IntFunction fa) { + static void ADDReduceLongLongVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -6885,11 +6935,11 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long128VectorTests::ADDReduce, Long128VectorTests::ADDReduceAll); + LongVector128Tests::ADDReduce, LongVector128Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongLong128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongLongVector128TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6907,11 +6957,11 @@ public class Long128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long128VectorTests::ADDReduceMasked, Long128VectorTests::ADDReduceAllMasked); + LongVector128Tests::ADDReduceMasked, LongVector128Tests::ADDReduceAllMasked); } @Test(dataProvider = "longUnaryOpSelectFromProvider") - static void SelectFromLong128VectorTests(IntFunction fa, + static void SelectFromLongVector128Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, SPECIES.length()); @@ -6927,7 +6977,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorLong128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorLongVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] idx = fc.apply(SPECIES.length()); @@ -6945,7 +6995,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") - static void SelectFromLong128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromLongVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -6964,7 +7014,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousLong128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousLongVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6980,7 +7030,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringLong128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringLongVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6994,7 +7044,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsLong128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsLongVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7008,7 +7058,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsLong128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsLongVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7024,7 +7074,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeLong128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeLongVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7046,7 +7096,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountLong128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountLongVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7057,7 +7107,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, LongVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7071,7 +7121,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueLong128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueLongVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7082,7 +7132,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, LongVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7096,7 +7146,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueLong128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueLongVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7107,11 +7157,11 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, LongVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressLong128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressLongVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7139,7 +7189,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLong128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7153,7 +7203,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongLong128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongLongVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7180,14 +7230,14 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundLong128VectorTestsSmokeTest(int length) { + static void loopBoundLongVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongLong128VectorTestsSmokeTest(int _length) { + static void loopBoundLongLongVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7195,21 +7245,21 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeLong128VectorTestsSmokeTest() { + static void ElementSizeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Long.SIZE); } @Test - static void VectorShapeLong128VectorTestsSmokeTest() { + static void VectorShapeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesLong128VectorTestsSmokeTest() { + static void ShapeWithLanesLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(long.class); @@ -7217,32 +7267,32 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeLong128VectorTestsSmokeTest() { + static void ElementTypeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementType() == long.class); } @Test - static void SpeciesElementSizeLong128VectorTestsSmokeTest() { + static void SpeciesElementSizeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementSize() == Long.SIZE); } @Test - static void VectorTypeLong128VectorTestsSmokeTest() { + static void VectorTypeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesLong128VectorTestsSmokeTest() { + static void WithLanesLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeLong128VectorTestsSmokeTest() { + static void WithShapeLongVector128TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7250,7 +7300,7 @@ public class Long128VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueLong128VectorTestsSmokeTest() { + static void MaskAllTrueLongVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/LongVector256LoadStoreTests.java index 675536ee67b..411c48dc7cb 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Long256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation LongVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Long256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class LongVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = LongVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/LongVector256Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Long256VectorTests.java rename to test/jdk/jdk/incubator/vector/LongVector256Tests.java index 0f3e3347480..84c8da4e800 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Long256VectorTests extends AbstractVectorTest { +public class LongVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = LongVector.SPECIES_256; @@ -1547,6 +1547,59 @@ public class Long256VectorTests extends AbstractVectorTest { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1563,9 +1616,6 @@ public class Long256VectorTests extends AbstractVectorTest { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1679,11 +1729,11 @@ public class Long256VectorTests extends AbstractVectorTest { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1696,15 +1746,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::ADD); + assertArraysEquals(r, a, b, LongVector256Tests::ADD); } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong256VectorTests(IntFunction fa, IntFunction fb) { + static void addLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1715,11 +1765,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::add); + assertArraysEquals(r, a, b, LongVector256Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1735,11 +1785,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, LongVector256Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1753,15 +1803,15 @@ public class Long256VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long256VectorTests::add); + assertArraysEquals(r, a, b, mask, LongVector256Tests::add); } static long SUB(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void SUBLong256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1774,15 +1824,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::SUB); + assertArraysEquals(r, a, b, LongVector256Tests::SUB); } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong256VectorTests(IntFunction fa, IntFunction fb) { + static void subLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1793,11 +1843,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::sub); + assertArraysEquals(r, a, b, LongVector256Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void SUBLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1813,11 +1863,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, LongVector256Tests::SUB); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1831,15 +1881,15 @@ public class Long256VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long256VectorTests::sub); + assertArraysEquals(r, a, b, mask, LongVector256Tests::sub); } static long MUL(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MULLong256VectorTests(IntFunction fa, IntFunction fb) { + static void MULLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1852,15 +1902,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::MUL); + assertArraysEquals(r, a, b, LongVector256Tests::MUL); } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong256VectorTests(IntFunction fa, IntFunction fb) { + static void mulLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1871,11 +1921,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::mul); + assertArraysEquals(r, a, b, LongVector256Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void MULLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1891,11 +1941,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, LongVector256Tests::MUL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1909,7 +1959,7 @@ public class Long256VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long256VectorTests::mul); + assertArraysEquals(r, a, b, mask, LongVector256Tests::mul); } static long DIV(long a, long b) { @@ -1917,7 +1967,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void DIVLong256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1932,7 +1982,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::DIV); + assertArraysEquals(r, a, b, LongVector256Tests::DIV); } static long div(long a, long b) { @@ -1940,7 +1990,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void divLong256VectorTests(IntFunction fa, IntFunction fb) { + static void divLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1955,11 +2005,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::div); + assertArraysEquals(r, a, b, LongVector256Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void DIVLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, LongVector256Tests::DIV); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1999,15 +2049,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::div); + assertArraysEquals(r, a, b, mask, LongVector256Tests::div); } static long FIRST_NONZERO(long a, long b) { - return (long)((a)!=0?a:b); + return (long)(firstNonZero(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void FIRST_NONZEROLong256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2020,11 +2070,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void FIRST_NONZEROLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2040,7 +2090,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongVector256Tests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -2048,7 +2098,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ANDLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2061,7 +2111,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::AND); + assertArraysEquals(r, a, b, LongVector256Tests::AND); } static long and(long a, long b) { @@ -2069,7 +2119,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void andLong256VectorTests(IntFunction fa, IntFunction fb) { + static void andLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2080,11 +2130,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::and); + assertArraysEquals(r, a, b, LongVector256Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2100,7 +2150,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::AND); + assertArraysEquals(r, a, b, mask, LongVector256Tests::AND); } static long AND_NOT(long a, long b) { @@ -2108,7 +2158,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void AND_NOTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2121,11 +2171,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, LongVector256Tests::AND_NOT); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void AND_NOTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2141,7 +2191,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongVector256Tests::AND_NOT); } static long OR(long a, long b) { @@ -2149,7 +2199,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ORLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2162,7 +2212,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::OR); + assertArraysEquals(r, a, b, LongVector256Tests::OR); } static long or(long a, long b) { @@ -2170,7 +2220,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void orLong256VectorTests(IntFunction fa, IntFunction fb) { + static void orLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2231,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::or); + assertArraysEquals(r, a, b, LongVector256Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2201,7 +2251,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::OR); + assertArraysEquals(r, a, b, mask, LongVector256Tests::OR); } static long XOR(long a, long b) { @@ -2209,7 +2259,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void XORLong256VectorTests(IntFunction fa, IntFunction fb) { + static void XORLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2222,11 +2272,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::XOR); + assertArraysEquals(r, a, b, LongVector256Tests::XOR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void XORLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2242,7 +2292,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::XOR); + assertArraysEquals(r, a, b, mask, LongVector256Tests::XOR); } static long COMPRESS_BITS(long a, long b) { @@ -2250,7 +2300,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void COMPRESS_BITSLong256VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2263,11 +2313,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, LongVector256Tests::COMPRESS_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void COMPRESS_BITSLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2283,7 +2333,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, LongVector256Tests::COMPRESS_BITS); } static long EXPAND_BITS(long a, long b) { @@ -2291,7 +2341,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void EXPAND_BITSLong256VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2304,11 +2354,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, LongVector256Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void EXPAND_BITSLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2324,11 +2374,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, LongVector256Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2338,11 +2388,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2355,11 +2405,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::add); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2369,11 +2419,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2386,11 +2436,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::sub); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2400,11 +2450,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::mul); } @Test(dataProvider = "longBinaryOpProvider") - static void divLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2433,11 +2483,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2452,11 +2502,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::div); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2466,11 +2516,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void orLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2480,11 +2530,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2497,11 +2547,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2511,11 +2561,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void andLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2525,11 +2575,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2542,11 +2592,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongVector256Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongVector256Tests::OR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2573,11 +2623,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector256Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDLongVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2587,11 +2637,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongVector256Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDLongVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2604,7 +2654,7 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector256Tests::ADD); } static long LSHL(long a, long b) { @@ -2612,7 +2662,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2625,11 +2675,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::LSHL); + assertArraysEquals(r, a, b, LongVector256Tests::LSHL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2645,7 +2695,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, LongVector256Tests::LSHL); } static long ASHR(long a, long b) { @@ -2653,7 +2703,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2666,11 +2716,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::ASHR); + assertArraysEquals(r, a, b, LongVector256Tests::ASHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2686,7 +2736,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, LongVector256Tests::ASHR); } static long LSHR(long a, long b) { @@ -2694,7 +2744,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2707,11 +2757,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::LSHR); + assertArraysEquals(r, a, b, LongVector256Tests::LSHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2727,7 +2777,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, LongVector256Tests::LSHR); } static long LSHL_unary(long a, long b) { @@ -2735,7 +2785,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLLongVector256TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2747,11 +2797,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, LongVector256Tests::LSHL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2766,7 +2816,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector256Tests::LSHL_unary); } static long LSHR_unary(long a, long b) { @@ -2774,7 +2824,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRLongVector256TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2786,11 +2836,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, LongVector256Tests::LSHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2805,7 +2855,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector256Tests::LSHR_unary); } static long ASHR_unary(long a, long b) { @@ -2813,7 +2863,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRLongVector256TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2825,11 +2875,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, LongVector256Tests::ASHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2844,7 +2894,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector256Tests::ASHR_unary); } static long ROR(long a, long b) { @@ -2852,7 +2902,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong256VectorTests(IntFunction fa, IntFunction fb) { + static void RORLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2865,11 +2915,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::ROR); + assertArraysEquals(r, a, b, LongVector256Tests::ROR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2885,7 +2935,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::ROR); + assertArraysEquals(r, a, b, mask, LongVector256Tests::ROR); } static long ROL(long a, long b) { @@ -2893,7 +2943,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ROLLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2906,11 +2956,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::ROL); + assertArraysEquals(r, a, b, LongVector256Tests::ROL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2926,7 +2976,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::ROL); + assertArraysEquals(r, a, b, mask, LongVector256Tests::ROL); } static long ROR_unary(long a, long b) { @@ -2934,7 +2984,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORLongVector256TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2946,11 +2996,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, LongVector256Tests::ROR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORLongVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2965,7 +3015,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector256Tests::ROR_unary); } static long ROL_unary(long a, long b) { @@ -2973,7 +3023,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLLongVector256TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2985,11 +3035,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, LongVector256Tests::ROL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3004,14 +3054,14 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector256Tests::ROL_unary); } static long LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT)); } @Test(dataProvider = "longUnaryOpProvider") - static void LSHRLong256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRLongVector256TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3022,11 +3072,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, LongVector256Tests::LSHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHRLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRLongVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3040,7 +3090,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector256Tests::LSHR_binary_const); } static long LSHL_binary_const(long a) { @@ -3048,7 +3098,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LSHLLong256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLLongVector256TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3059,11 +3109,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, LongVector256Tests::LSHL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHLLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLLongVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3077,7 +3127,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector256Tests::LSHL_binary_const); } static long ASHR_binary_const(long a) { @@ -3085,7 +3135,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ASHRLong256VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRLongVector256TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3096,11 +3146,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, LongVector256Tests::ASHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ASHRLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRLongVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3114,7 +3164,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector256Tests::ASHR_binary_const); } static long ROR_binary_const(long a) { @@ -3122,7 +3172,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void RORLong256VectorTestsScalarShiftConst(IntFunction fa) { + static void RORLongVector256TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3133,11 +3183,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, LongVector256Tests::ROR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void RORLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORLongVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3151,7 +3201,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector256Tests::ROR_binary_const); } static long ROL_binary_const(long a) { @@ -3159,7 +3209,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ROLLong256VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLLongVector256TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3170,11 +3220,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, LongVector256Tests::ROL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ROLLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLLongVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3188,14 +3238,14 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector256Tests::ROL_binary_const); } static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MINLong256VectorTestsWithMemOp(IntFunction fa) { + static void MINLongVector256TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3206,13 +3256,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long256VectorTests::MIN); + assertArraysEquals(r, a, (long)10, LongVector256Tests::MIN); } static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void minLong256VectorTestsWithMemOp(IntFunction fa) { + static void minLongVector256TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3223,13 +3273,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long256VectorTests::min); + assertArraysEquals(r, a, (long)10, LongVector256Tests::min); } static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINLongVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3242,13 +3292,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long256VectorTests::MIN); + assertArraysEquals(r, a, (long)10, mask, LongVector256Tests::MIN); } static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MAXLong256VectorTestsWithMemOp(IntFunction fa) { + static void MAXLongVector256TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3259,13 +3309,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long256VectorTests::MAX); + assertArraysEquals(r, a, (long)10, LongVector256Tests::MAX); } static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void maxLong256VectorTestsWithMemOp(IntFunction fa) { + static void maxLongVector256TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3276,13 +3326,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long256VectorTests::max); + assertArraysEquals(r, a, (long)10, LongVector256Tests::max); } static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXLongVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3295,15 +3345,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long256VectorTests::MAX); + assertArraysEquals(r, a, (long)10, mask, LongVector256Tests::MAX); } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong256VectorTests(IntFunction fa, IntFunction fb) { + static void MINLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3316,15 +3366,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::MIN); + assertArraysEquals(r, a, b, LongVector256Tests::MIN); } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong256VectorTests(IntFunction fa, IntFunction fb) { + static void minLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3335,15 +3385,15 @@ public class Long256VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::min); + assertArraysEquals(r, a, b, LongVector256Tests::min); } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3356,15 +3406,15 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::MAX); + assertArraysEquals(r, a, b, LongVector256Tests::MAX); } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maxLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3375,7 +3425,7 @@ public class Long256VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long256VectorTests::max); + assertArraysEquals(r, a, b, LongVector256Tests::max); } static long UMIN(long a, long b) { @@ -3383,7 +3433,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMINLong256VectorTests(IntFunction fa, IntFunction fb) { + static void UMINLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3396,11 +3446,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::UMIN); + assertArraysEquals(r, a, b, LongVector256Tests::UMIN); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMINLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3416,7 +3466,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, LongVector256Tests::UMIN); } static long UMAX(long a, long b) { @@ -3424,7 +3474,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMAXLong256VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3437,11 +3487,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::UMAX); + assertArraysEquals(r, a, b, LongVector256Tests::UMAX); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMAXLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3457,7 +3507,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, LongVector256Tests::UMAX); } static long SADD(long a, long b) { @@ -3465,7 +3515,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SADDLong256VectorTests(IntFunction fa, IntFunction fb) { + static void SADDLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3478,11 +3528,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::SADD); + assertArraysEquals(r, a, b, LongVector256Tests::SADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SADDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3498,7 +3548,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::SADD); + assertArraysEquals(r, a, b, mask, LongVector256Tests::SADD); } static long SSUB(long a, long b) { @@ -3506,7 +3556,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SSUBLong256VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3519,11 +3569,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::SSUB); + assertArraysEquals(r, a, b, LongVector256Tests::SSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SSUBLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3539,7 +3589,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, LongVector256Tests::SSUB); } static long SUADD(long a, long b) { @@ -3547,7 +3597,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUADDLong256VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3560,11 +3610,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::SUADD); + assertArraysEquals(r, a, b, LongVector256Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUADDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3580,7 +3630,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, LongVector256Tests::SUADD); } static long SUSUB(long a, long b) { @@ -3588,7 +3638,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUSUBLong256VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3601,11 +3651,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::SUSUB); + assertArraysEquals(r, a, b, LongVector256Tests::SUSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUSUBLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3621,11 +3671,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, LongVector256Tests::SUSUB); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3635,11 +3685,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::MIN); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3649,11 +3699,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::min); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3663,11 +3713,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::MAX); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3677,10 +3727,10 @@ public class Long256VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongVector256Tests::max); } @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") - static void SUADDAssocLong256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocLongVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -3697,11 +3747,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Long256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, LongVector256Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3722,13 +3772,13 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Long256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongVector256Tests::SUADD); } static long ANDReduce(long[] a, int idx) { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3737,14 +3787,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ANDReduceAll(long[] a) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ANDReduceLong256VectorTests(IntFunction fa) { + static void ANDReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3755,12 +3805,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::ANDReduce, Long256VectorTests::ANDReduceAll); + LongVector256Tests::ANDReduce, LongVector256Tests::ANDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3768,20 +3818,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = AND_IDENTITY; - assertEquals((long) (id & id), id, + assertEquals((long) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id & x), x); - assertEquals((long) (x & id), x); + assertEquals((long) (scalar_and(id, x)), x); + assertEquals((long) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id & x), x, + assertEquals((long) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x & id), x, + assertEquals((long) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3790,7 +3840,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3799,14 +3849,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ANDReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3819,18 +3869,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::ANDReduceMasked, Long256VectorTests::ANDReduceAllMasked); + LongVector256Tests::ANDReduceMasked, LongVector256Tests::ANDReduceAllMasked); } static long ORReduce(long[] a, int idx) { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3839,14 +3889,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ORReduceAll(long[] a) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ORReduceLong256VectorTests(IntFunction fa) { + static void ORReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3857,12 +3907,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::ORReduce, Long256VectorTests::ORReduceAll); + LongVector256Tests::ORReduce, LongVector256Tests::ORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3870,20 +3920,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = OR_IDENTITY; - assertEquals((long) (id | id), id, + assertEquals((long) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id | x), x); - assertEquals((long) (x | id), x); + assertEquals((long) (scalar_or(id, x)), x); + assertEquals((long) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id | x), x, + assertEquals((long) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x | id), x, + assertEquals((long) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3892,7 +3942,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3901,14 +3951,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ORReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3921,18 +3971,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::ORReduceMasked, Long256VectorTests::ORReduceAllMasked); + LongVector256Tests::ORReduceMasked, LongVector256Tests::ORReduceAllMasked); } static long XORReduce(long[] a, int idx) { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3941,14 +3991,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long XORReduceAll(long[] a) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void XORReduceLong256VectorTests(IntFunction fa) { + static void XORReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3959,12 +4009,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::XORReduce, Long256VectorTests::XORReduceAll); + LongVector256Tests::XORReduce, LongVector256Tests::XORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3972,20 +4022,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = XOR_IDENTITY; - assertEquals((long) (id ^ id), id, + assertEquals((long) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id ^ x), x); - assertEquals((long) (x ^ id), x); + assertEquals((long) (scalar_xor(id, x)), x); + assertEquals((long) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id ^ x), x, + assertEquals((long) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x ^ id), x, + assertEquals((long) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3994,7 +4044,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -4003,14 +4053,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void XORReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4023,18 +4073,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::XORReduceMasked, Long256VectorTests::XORReduceAllMasked); + LongVector256Tests::XORReduceMasked, LongVector256Tests::XORReduceAllMasked); } static long ADDReduce(long[] a, int idx) { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4043,14 +4093,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ADDReduceAll(long[] a) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLong256VectorTests(IntFunction fa) { + static void ADDReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4061,12 +4111,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll); + LongVector256Tests::ADDReduce, LongVector256Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4074,20 +4124,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = ADD_IDENTITY; - assertEquals((long) (id + id), id, + assertEquals((long) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id + x), x); - assertEquals((long) (x + id), x); + assertEquals((long) (scalar_add(id, x)), x); + assertEquals((long) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id + x), x, + assertEquals((long) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x + id), x, + assertEquals((long) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4096,7 +4146,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4105,14 +4155,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long ADDReduceAllMasked(long[] a, boolean[] mask) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4125,18 +4175,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked); + LongVector256Tests::ADDReduceMasked, LongVector256Tests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4145,14 +4195,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MULReduceAll(long[] a) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MULReduceLong256VectorTests(IntFunction fa) { + static void MULReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4163,12 +4213,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::MULReduce, Long256VectorTests::MULReduceAll); + LongVector256Tests::MULReduce, LongVector256Tests::MULReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4176,20 +4226,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MUL_IDENTITY; - assertEquals((long) (id * id), id, + assertEquals((long) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id * x), x); - assertEquals((long) (x * id), x); + assertEquals((long) (scalar_mul(id, x)), x); + assertEquals((long) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id * x), x, + assertEquals((long) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x * id), x, + assertEquals((long) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4198,7 +4248,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4207,14 +4257,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MULReduceAllMasked(long[] a, boolean[] mask) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MULReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4227,18 +4277,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::MULReduceMasked, Long256VectorTests::MULReduceAllMasked); + LongVector256Tests::MULReduceMasked, LongVector256Tests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4247,14 +4297,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MINReduceAll(long[] a) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MINReduceLong256VectorTests(IntFunction fa) { + static void MINReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4265,12 +4315,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::MINReduce, Long256VectorTests::MINReduceAll); + LongVector256Tests::MINReduce, LongVector256Tests::MINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4278,20 +4328,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MIN_IDENTITY; - assertEquals((long) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.min(id, x), x); - assertEquals((long) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4300,7 +4350,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4309,14 +4359,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MINReduceAllMasked(long[] a, boolean[] mask) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4329,18 +4379,18 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::MINReduceMasked, Long256VectorTests::MINReduceAllMasked); + LongVector256Tests::MINReduceMasked, LongVector256Tests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4349,14 +4399,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MAXReduceAll(long[] a) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MAXReduceLong256VectorTests(IntFunction fa) { + static void MAXReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4367,12 +4417,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::MAXReduce, Long256VectorTests::MAXReduceAll); + LongVector256Tests::MAXReduce, LongVector256Tests::MAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4380,20 +4430,20 @@ public class Long256VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MAX_IDENTITY; - assertEquals((long) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.max(id, x), x); - assertEquals((long) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4402,7 +4452,7 @@ public class Long256VectorTests extends AbstractVectorTest { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4411,14 +4461,14 @@ public class Long256VectorTests extends AbstractVectorTest { static long MAXReduceAllMasked(long[] a, boolean[] mask) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4431,12 +4481,12 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked); + LongVector256Tests::MAXReduceMasked, LongVector256Tests::MAXReduceAllMasked); } static long UMINReduce(long[] a, int idx) { @@ -4458,7 +4508,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMINReduceLong256VectorTests(IntFunction fa) { + static void UMINReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4474,7 +4524,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::UMINReduce, Long256VectorTests::UMINReduceAll); + LongVector256Tests::UMINReduce, LongVector256Tests::UMINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4520,7 +4570,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMINReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4538,7 +4588,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::UMINReduceMasked, Long256VectorTests::UMINReduceAllMasked); + LongVector256Tests::UMINReduceMasked, LongVector256Tests::UMINReduceAllMasked); } static long UMAXReduce(long[] a, int idx) { @@ -4560,7 +4610,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMAXReduceLong256VectorTests(IntFunction fa) { + static void UMAXReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4576,7 +4626,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::UMAXReduce, Long256VectorTests::UMAXReduceAll); + LongVector256Tests::UMAXReduce, LongVector256Tests::UMAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4622,7 +4672,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4640,7 +4690,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::UMAXReduceMasked, Long256VectorTests::UMAXReduceAllMasked); + LongVector256Tests::UMAXReduceMasked, LongVector256Tests::UMAXReduceAllMasked); } static long FIRST_NONZEROReduce(long[] a, int idx) { @@ -4662,7 +4712,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void FIRST_NONZEROReduceLong256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4678,7 +4728,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::FIRST_NONZEROReduce, Long256VectorTests::FIRST_NONZEROReduceAll); + LongVector256Tests::FIRST_NONZEROReduce, LongVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4724,7 +4774,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void FIRST_NONZEROReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4742,7 +4792,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::FIRST_NONZEROReduceMasked, Long256VectorTests::FIRST_NONZEROReduceAllMasked); + LongVector256Tests::FIRST_NONZEROReduceMasked, LongVector256Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4755,7 +4805,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueLong256VectorTests(IntFunction fm) { + static void anyTrueLongVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4766,7 +4816,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongVector256Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4779,7 +4829,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueLong256VectorTests(IntFunction fm) { + static void allTrueLongVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4790,7 +4840,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongVector256Tests::allTrue); } static long SUADDReduce(long[] a, int idx) { @@ -4812,7 +4862,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingUnaryOpProvider") - static void SUADDReduceLong256VectorTests(IntFunction fa) { + static void SUADDReduceLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4828,7 +4878,7 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::SUADDReduce, Long256VectorTests::SUADDReduceAll); + LongVector256Tests::SUADDReduce, LongVector256Tests::SUADDReduceAll); } @Test(dataProvider = "longSaturatingUnaryOpProvider") @@ -4873,7 +4923,7 @@ public class Long256VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") - static void SUADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4891,11 +4941,11 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::SUADDReduceMasked, Long256VectorTests::SUADDReduceAllMasked); + LongVector256Tests::SUADDReduceMasked, LongVector256Tests::SUADDReduceAllMasked); } @Test(dataProvider = "longBinaryOpProvider") - static void withLong256VectorTests(IntFunction fa, IntFunction fb) { + static void withLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -4918,7 +4968,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_DEFAULTLong256VectorTests(IntFunction fa) { + static void IS_DEFAULTLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4935,7 +4985,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_DEFAULTMaskedLong256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4959,7 +5009,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_NEGATIVELong256VectorTests(IntFunction fa) { + static void IS_NEGATIVELongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4976,7 +5026,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_NEGATIVEMaskedLong256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4996,7 +5046,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void LTLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5015,7 +5065,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ltLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5034,7 +5084,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5057,7 +5107,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void GTLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5076,7 +5126,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5099,7 +5149,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void EQLong256VectorTests(IntFunction fa, IntFunction fb) { + static void EQLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5118,7 +5168,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void eqLong256VectorTests(IntFunction fa, IntFunction fb) { + static void eqLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5137,7 +5187,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5160,7 +5210,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void NELong256VectorTests(IntFunction fa, IntFunction fb) { + static void NELongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5179,7 +5229,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void NELong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NELongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5202,7 +5252,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LELong256VectorTests(IntFunction fa, IntFunction fb) { + static void LELongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5221,7 +5271,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LELong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LELongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5244,7 +5294,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GELong256VectorTests(IntFunction fa, IntFunction fb) { + static void GELongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5263,7 +5313,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GELong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GELongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5286,7 +5336,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void ULTLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5305,7 +5355,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5328,7 +5378,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5347,7 +5397,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5370,7 +5420,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULELong256VectorTests(IntFunction fa, IntFunction fb) { + static void ULELongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5389,7 +5439,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULELong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULELongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5412,7 +5462,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGELong256VectorTests(IntFunction fa, IntFunction fb) { + static void UGELongVector256Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5431,7 +5481,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGELong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGELongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5454,7 +5504,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5464,13 +5514,13 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5484,14 +5534,14 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "longCompareOpProvider") - static void EQLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5501,13 +5551,13 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5521,7 +5571,7 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5532,7 +5582,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void blendLong256VectorTests(IntFunction fa, IntFunction fb, + static void blendLongVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5548,11 +5598,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long256VectorTests::blend); + assertArraysEquals(r, a, b, mask, LongVector256Tests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") - static void RearrangeLong256VectorTests(IntFunction fa, + static void RearrangeLongVector256Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5569,7 +5619,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") - static void RearrangeLong256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeLongVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -5587,7 +5637,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void compressLong256VectorTests(IntFunction fa, + static void compressLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5605,7 +5655,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void expandLong256VectorTests(IntFunction fa, + static void expandLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void getLong256VectorTests(IntFunction fa) { + static void getLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5779,7 +5829,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BroadcastLong256VectorTests(IntFunction fa) { + static void BroadcastLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5793,7 +5843,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZeroLong256VectorTests(IntFunction fa) { + static void ZeroLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5818,7 +5868,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void sliceUnaryLong256VectorTests(IntFunction fa) { + static void sliceUnaryLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5829,7 +5879,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongVector256Tests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { @@ -5846,7 +5896,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void sliceBinaryLong256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryLongVector256TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5859,7 +5909,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Long256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongVector256Tests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { @@ -5876,7 +5926,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void sliceLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5893,7 +5943,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Long256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, LongVector256Tests::slice); } static long[] unsliceUnary(long[] a, int origin, int idx) { @@ -5910,7 +5960,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void unsliceUnaryLong256VectorTests(IntFunction fa) { + static void unsliceUnaryLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5921,7 +5971,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongVector256Tests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { @@ -5947,7 +5997,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void unsliceBinaryLong256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryLongVector256TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5961,7 +6011,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Long256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongVector256Tests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { @@ -6001,7 +6051,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void unsliceLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6018,7 +6068,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Long256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongVector256Tests::unslice); } static long BITWISE_BLEND(long a, long b, long c) { @@ -6030,7 +6080,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6045,11 +6095,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6062,11 +6112,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, LongVector256Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6084,11 +6134,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6114,11 +6164,11 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6129,11 +6179,11 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongVector256Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6144,11 +6194,11 @@ public class Long256VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector256Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6163,11 +6213,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6182,11 +6232,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6197,11 +6247,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6212,11 +6262,11 @@ public class Long256VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector256Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6230,19 +6280,19 @@ public class Long256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongVector256Tests::BITWISE_BLEND); } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void NEGLong256VectorTests(IntFunction fa) { + static void NEGLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6253,11 +6303,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::NEG); + assertArraysEquals(r, a, LongVector256Tests::NEG); } @Test(dataProvider = "longUnaryOpProvider") - static void negLong256VectorTests(IntFunction fa) { + static void negLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6268,11 +6318,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::neg); + assertArraysEquals(r, a, LongVector256Tests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NEGMaskedLong256VectorTests(IntFunction fa, + static void NEGMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6286,19 +6336,19 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::NEG); + assertArraysEquals(r, a, mask, LongVector256Tests::NEG); } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void ABSLong256VectorTests(IntFunction fa) { + static void ABSLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6309,11 +6359,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::ABS); + assertArraysEquals(r, a, LongVector256Tests::ABS); } @Test(dataProvider = "longUnaryOpProvider") - static void absLong256VectorTests(IntFunction fa) { + static void absLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6324,11 +6374,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::abs); + assertArraysEquals(r, a, LongVector256Tests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ABSMaskedLong256VectorTests(IntFunction fa, + static void ABSMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6342,7 +6392,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::ABS); + assertArraysEquals(r, a, mask, LongVector256Tests::ABS); } static long NOT(long a) { @@ -6354,7 +6404,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void NOTLong256VectorTests(IntFunction fa) { + static void NOTLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6365,11 +6415,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::NOT); + assertArraysEquals(r, a, LongVector256Tests::NOT); } @Test(dataProvider = "longUnaryOpProvider") - static void notLong256VectorTests(IntFunction fa) { + static void notLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6380,11 +6430,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::not); + assertArraysEquals(r, a, LongVector256Tests::not); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NOTMaskedLong256VectorTests(IntFunction fa, + static void NOTMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6398,7 +6448,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::NOT); + assertArraysEquals(r, a, mask, LongVector256Tests::NOT); } static long ZOMO(long a) { @@ -6406,7 +6456,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZOMOLong256VectorTests(IntFunction fa) { + static void ZOMOLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6417,11 +6467,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::ZOMO); + assertArraysEquals(r, a, LongVector256Tests::ZOMO); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ZOMOMaskedLong256VectorTests(IntFunction fa, + static void ZOMOMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6435,7 +6485,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongVector256Tests::ZOMO); } static long BIT_COUNT(long a) { @@ -6443,7 +6493,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BIT_COUNTLong256VectorTests(IntFunction fa) { + static void BIT_COUNTLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6454,11 +6504,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, LongVector256Tests::BIT_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void BIT_COUNTMaskedLong256VectorTests(IntFunction fa, + static void BIT_COUNTMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6472,7 +6522,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, LongVector256Tests::BIT_COUNT); } static long TRAILING_ZEROS_COUNT(long a) { @@ -6480,7 +6530,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void TRAILING_ZEROS_COUNTLong256VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6491,11 +6541,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector256Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedLong256VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6509,7 +6559,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector256Tests::TRAILING_ZEROS_COUNT); } static long LEADING_ZEROS_COUNT(long a) { @@ -6517,7 +6567,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LEADING_ZEROS_COUNTLong256VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6528,11 +6578,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector256Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedLong256VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6546,7 +6596,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector256Tests::LEADING_ZEROS_COUNT); } static long REVERSE(long a) { @@ -6554,7 +6604,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSELong256VectorTests(IntFunction fa) { + static void REVERSELongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6565,11 +6615,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::REVERSE); + assertArraysEquals(r, a, LongVector256Tests::REVERSE); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSEMaskedLong256VectorTests(IntFunction fa, + static void REVERSEMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6583,7 +6633,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::REVERSE); + assertArraysEquals(r, a, mask, LongVector256Tests::REVERSE); } static long REVERSE_BYTES(long a) { @@ -6591,7 +6641,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSE_BYTESLong256VectorTests(IntFunction fa) { + static void REVERSE_BYTESLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6602,11 +6652,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, LongVector256Tests::REVERSE_BYTES); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedLong256VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedLongVector256Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6620,7 +6670,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, LongVector256Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6628,7 +6678,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6641,7 +6691,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::band); + assertArraysEquals(r, a, b, LongVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6649,7 +6699,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6662,7 +6712,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::bor); + assertArraysEquals(r, a, b, LongVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6670,7 +6720,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6683,7 +6733,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::bxor); + assertArraysEquals(r, a, b, LongVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6691,7 +6741,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6704,7 +6754,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::bandNot); + assertArraysEquals(r, a, b, LongVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6712,7 +6762,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6725,7 +6775,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long256VectorTests::beq); + assertArraysEquals(r, a, b, LongVector256Tests::beq); } static boolean unot(boolean a) { @@ -6733,7 +6783,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotLong256VectorTests(IntFunction fa) { + static void masknotLongVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6744,7 +6794,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::unot); + assertArraysEquals(r, a, LongVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6761,7 +6811,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongLong256VectorTests(IntFunction fa) { + static void maskFromToLongLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6775,7 +6825,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltLongVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6785,13 +6835,13 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpProvider") - static void eqLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqLongVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6801,13 +6851,13 @@ public class Long256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longtoIntUnaryOpProvider") - static void toIntArrayLong256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayLongVector256TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6818,7 +6868,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toLongArrayLong256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayLongVector256TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6829,7 +6879,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toDoubleArrayLong256VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayLongVector256TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6840,7 +6890,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toStringLong256VectorTestsSmokeTest(IntFunction fa) { + static void toStringLongVector256TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6853,7 +6903,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void hashCodeLong256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeLongVector256TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6869,7 +6919,7 @@ public class Long256VectorTests extends AbstractVectorTest { @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongLong256VectorTests(IntFunction fa) { + static void ADDReduceLongLongVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -6885,11 +6935,11 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll); + LongVector256Tests::ADDReduce, LongVector256Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongLong256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongLongVector256TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6907,11 +6957,11 @@ public class Long256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked); + LongVector256Tests::ADDReduceMasked, LongVector256Tests::ADDReduceAllMasked); } @Test(dataProvider = "longUnaryOpSelectFromProvider") - static void SelectFromLong256VectorTests(IntFunction fa, + static void SelectFromLongVector256Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, SPECIES.length()); @@ -6927,7 +6977,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorLong256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorLongVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] idx = fc.apply(SPECIES.length()); @@ -6945,7 +6995,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") - static void SelectFromLong256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromLongVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -6964,7 +7014,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousLong256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousLongVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6980,7 +7030,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringLong256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringLongVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6994,7 +7044,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsLong256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsLongVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7008,7 +7058,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsLong256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsLongVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7024,7 +7074,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeLong256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeLongVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7046,7 +7096,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountLong256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountLongVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7057,7 +7107,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, LongVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7071,7 +7121,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueLong256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueLongVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7082,7 +7132,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, LongVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7096,7 +7146,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueLong256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueLongVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7107,11 +7157,11 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, LongVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressLong256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressLongVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7139,7 +7189,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLong256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7153,7 +7203,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongLong256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongLongVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7180,14 +7230,14 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundLong256VectorTestsSmokeTest(int length) { + static void loopBoundLongVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongLong256VectorTestsSmokeTest(int _length) { + static void loopBoundLongLongVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7195,21 +7245,21 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeLong256VectorTestsSmokeTest() { + static void ElementSizeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Long.SIZE); } @Test - static void VectorShapeLong256VectorTestsSmokeTest() { + static void VectorShapeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesLong256VectorTestsSmokeTest() { + static void ShapeWithLanesLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(long.class); @@ -7217,32 +7267,32 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeLong256VectorTestsSmokeTest() { + static void ElementTypeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementType() == long.class); } @Test - static void SpeciesElementSizeLong256VectorTestsSmokeTest() { + static void SpeciesElementSizeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementSize() == Long.SIZE); } @Test - static void VectorTypeLong256VectorTestsSmokeTest() { + static void VectorTypeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesLong256VectorTestsSmokeTest() { + static void WithLanesLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeLong256VectorTestsSmokeTest() { + static void WithShapeLongVector256TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7250,7 +7300,7 @@ public class Long256VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueLong256VectorTestsSmokeTest() { + static void MaskAllTrueLongVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/LongVector512LoadStoreTests.java index dfdafc91d1a..095616595f8 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Long512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation LongVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Long512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class LongVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = LongVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/LongVector512Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Long512VectorTests.java rename to test/jdk/jdk/incubator/vector/LongVector512Tests.java index a575c80a0ce..00d8c4b010a 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Long512VectorTests extends AbstractVectorTest { +public class LongVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = LongVector.SPECIES_512; @@ -1547,6 +1547,59 @@ public class Long512VectorTests extends AbstractVectorTest { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1563,9 +1616,6 @@ public class Long512VectorTests extends AbstractVectorTest { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1679,11 +1729,11 @@ public class Long512VectorTests extends AbstractVectorTest { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1696,15 +1746,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::ADD); + assertArraysEquals(r, a, b, LongVector512Tests::ADD); } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong512VectorTests(IntFunction fa, IntFunction fb) { + static void addLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1715,11 +1765,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::add); + assertArraysEquals(r, a, b, LongVector512Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1735,11 +1785,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, LongVector512Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1753,15 +1803,15 @@ public class Long512VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long512VectorTests::add); + assertArraysEquals(r, a, b, mask, LongVector512Tests::add); } static long SUB(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void SUBLong512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1774,15 +1824,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::SUB); + assertArraysEquals(r, a, b, LongVector512Tests::SUB); } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong512VectorTests(IntFunction fa, IntFunction fb) { + static void subLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1793,11 +1843,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::sub); + assertArraysEquals(r, a, b, LongVector512Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void SUBLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1813,11 +1863,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, LongVector512Tests::SUB); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1831,15 +1881,15 @@ public class Long512VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long512VectorTests::sub); + assertArraysEquals(r, a, b, mask, LongVector512Tests::sub); } static long MUL(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MULLong512VectorTests(IntFunction fa, IntFunction fb) { + static void MULLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1852,15 +1902,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::MUL); + assertArraysEquals(r, a, b, LongVector512Tests::MUL); } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong512VectorTests(IntFunction fa, IntFunction fb) { + static void mulLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1871,11 +1921,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::mul); + assertArraysEquals(r, a, b, LongVector512Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void MULLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1891,11 +1941,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, LongVector512Tests::MUL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1909,7 +1959,7 @@ public class Long512VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long512VectorTests::mul); + assertArraysEquals(r, a, b, mask, LongVector512Tests::mul); } static long DIV(long a, long b) { @@ -1917,7 +1967,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void DIVLong512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1932,7 +1982,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::DIV); + assertArraysEquals(r, a, b, LongVector512Tests::DIV); } static long div(long a, long b) { @@ -1940,7 +1990,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void divLong512VectorTests(IntFunction fa, IntFunction fb) { + static void divLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1955,11 +2005,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::div); + assertArraysEquals(r, a, b, LongVector512Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void DIVLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, LongVector512Tests::DIV); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1999,15 +2049,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::div); + assertArraysEquals(r, a, b, mask, LongVector512Tests::div); } static long FIRST_NONZERO(long a, long b) { - return (long)((a)!=0?a:b); + return (long)(firstNonZero(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void FIRST_NONZEROLong512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2020,11 +2070,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void FIRST_NONZEROLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2040,7 +2090,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongVector512Tests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -2048,7 +2098,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ANDLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2061,7 +2111,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::AND); + assertArraysEquals(r, a, b, LongVector512Tests::AND); } static long and(long a, long b) { @@ -2069,7 +2119,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void andLong512VectorTests(IntFunction fa, IntFunction fb) { + static void andLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2080,11 +2130,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::and); + assertArraysEquals(r, a, b, LongVector512Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2100,7 +2150,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::AND); + assertArraysEquals(r, a, b, mask, LongVector512Tests::AND); } static long AND_NOT(long a, long b) { @@ -2108,7 +2158,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void AND_NOTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2121,11 +2171,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, LongVector512Tests::AND_NOT); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void AND_NOTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2141,7 +2191,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongVector512Tests::AND_NOT); } static long OR(long a, long b) { @@ -2149,7 +2199,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ORLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2162,7 +2212,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::OR); + assertArraysEquals(r, a, b, LongVector512Tests::OR); } static long or(long a, long b) { @@ -2170,7 +2220,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void orLong512VectorTests(IntFunction fa, IntFunction fb) { + static void orLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2231,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::or); + assertArraysEquals(r, a, b, LongVector512Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2201,7 +2251,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::OR); + assertArraysEquals(r, a, b, mask, LongVector512Tests::OR); } static long XOR(long a, long b) { @@ -2209,7 +2259,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void XORLong512VectorTests(IntFunction fa, IntFunction fb) { + static void XORLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2222,11 +2272,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::XOR); + assertArraysEquals(r, a, b, LongVector512Tests::XOR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void XORLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2242,7 +2292,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::XOR); + assertArraysEquals(r, a, b, mask, LongVector512Tests::XOR); } static long COMPRESS_BITS(long a, long b) { @@ -2250,7 +2300,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void COMPRESS_BITSLong512VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2263,11 +2313,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, LongVector512Tests::COMPRESS_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void COMPRESS_BITSLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2283,7 +2333,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, LongVector512Tests::COMPRESS_BITS); } static long EXPAND_BITS(long a, long b) { @@ -2291,7 +2341,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void EXPAND_BITSLong512VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2304,11 +2354,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, LongVector512Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void EXPAND_BITSLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2324,11 +2374,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, LongVector512Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2338,11 +2388,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2355,11 +2405,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::add); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2369,11 +2419,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2386,11 +2436,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::sub); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2400,11 +2450,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::mul); } @Test(dataProvider = "longBinaryOpProvider") - static void divLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2433,11 +2483,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2452,11 +2502,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::div); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2466,11 +2516,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void orLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2480,11 +2530,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2497,11 +2547,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2511,11 +2561,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void andLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2525,11 +2575,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2542,11 +2592,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongVector512Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongVector512Tests::OR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2573,11 +2623,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector512Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDLongVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2587,11 +2637,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongVector512Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDLongVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2604,7 +2654,7 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector512Tests::ADD); } static long LSHL(long a, long b) { @@ -2612,7 +2662,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2625,11 +2675,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::LSHL); + assertArraysEquals(r, a, b, LongVector512Tests::LSHL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2645,7 +2695,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, LongVector512Tests::LSHL); } static long ASHR(long a, long b) { @@ -2653,7 +2703,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2666,11 +2716,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::ASHR); + assertArraysEquals(r, a, b, LongVector512Tests::ASHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2686,7 +2736,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, LongVector512Tests::ASHR); } static long LSHR(long a, long b) { @@ -2694,7 +2744,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2707,11 +2757,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::LSHR); + assertArraysEquals(r, a, b, LongVector512Tests::LSHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2727,7 +2777,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, LongVector512Tests::LSHR); } static long LSHL_unary(long a, long b) { @@ -2735,7 +2785,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLLongVector512TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2747,11 +2797,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, LongVector512Tests::LSHL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2766,7 +2816,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector512Tests::LSHL_unary); } static long LSHR_unary(long a, long b) { @@ -2774,7 +2824,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRLongVector512TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2786,11 +2836,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, LongVector512Tests::LSHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2805,7 +2855,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector512Tests::LSHR_unary); } static long ASHR_unary(long a, long b) { @@ -2813,7 +2863,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRLongVector512TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2825,11 +2875,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, LongVector512Tests::ASHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2844,7 +2894,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector512Tests::ASHR_unary); } static long ROR(long a, long b) { @@ -2852,7 +2902,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong512VectorTests(IntFunction fa, IntFunction fb) { + static void RORLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2865,11 +2915,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::ROR); + assertArraysEquals(r, a, b, LongVector512Tests::ROR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2885,7 +2935,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::ROR); + assertArraysEquals(r, a, b, mask, LongVector512Tests::ROR); } static long ROL(long a, long b) { @@ -2893,7 +2943,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ROLLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2906,11 +2956,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::ROL); + assertArraysEquals(r, a, b, LongVector512Tests::ROL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2926,7 +2976,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::ROL); + assertArraysEquals(r, a, b, mask, LongVector512Tests::ROL); } static long ROR_unary(long a, long b) { @@ -2934,7 +2984,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORLongVector512TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2946,11 +2996,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, LongVector512Tests::ROR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORLongVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2965,7 +3015,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector512Tests::ROR_unary); } static long ROL_unary(long a, long b) { @@ -2973,7 +3023,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLLongVector512TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2985,11 +3035,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, LongVector512Tests::ROL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3004,14 +3054,14 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector512Tests::ROL_unary); } static long LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT)); } @Test(dataProvider = "longUnaryOpProvider") - static void LSHRLong512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRLongVector512TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3022,11 +3072,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, LongVector512Tests::LSHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHRLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRLongVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3040,7 +3090,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector512Tests::LSHR_binary_const); } static long LSHL_binary_const(long a) { @@ -3048,7 +3098,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LSHLLong512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLLongVector512TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3059,11 +3109,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, LongVector512Tests::LSHL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHLLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLLongVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3077,7 +3127,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector512Tests::LSHL_binary_const); } static long ASHR_binary_const(long a) { @@ -3085,7 +3135,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ASHRLong512VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRLongVector512TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3096,11 +3146,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, LongVector512Tests::ASHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ASHRLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRLongVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3114,7 +3164,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector512Tests::ASHR_binary_const); } static long ROR_binary_const(long a) { @@ -3122,7 +3172,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void RORLong512VectorTestsScalarShiftConst(IntFunction fa) { + static void RORLongVector512TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3133,11 +3183,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, LongVector512Tests::ROR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void RORLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORLongVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3151,7 +3201,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector512Tests::ROR_binary_const); } static long ROL_binary_const(long a) { @@ -3159,7 +3209,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ROLLong512VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLLongVector512TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3170,11 +3220,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, LongVector512Tests::ROL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ROLLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLLongVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3188,14 +3238,14 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector512Tests::ROL_binary_const); } static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MINLong512VectorTestsWithMemOp(IntFunction fa) { + static void MINLongVector512TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3206,13 +3256,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long512VectorTests::MIN); + assertArraysEquals(r, a, (long)10, LongVector512Tests::MIN); } static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void minLong512VectorTestsWithMemOp(IntFunction fa) { + static void minLongVector512TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3223,13 +3273,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long512VectorTests::min); + assertArraysEquals(r, a, (long)10, LongVector512Tests::min); } static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINLongVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3242,13 +3292,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long512VectorTests::MIN); + assertArraysEquals(r, a, (long)10, mask, LongVector512Tests::MIN); } static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MAXLong512VectorTestsWithMemOp(IntFunction fa) { + static void MAXLongVector512TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3259,13 +3309,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long512VectorTests::MAX); + assertArraysEquals(r, a, (long)10, LongVector512Tests::MAX); } static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void maxLong512VectorTestsWithMemOp(IntFunction fa) { + static void maxLongVector512TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3276,13 +3326,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long512VectorTests::max); + assertArraysEquals(r, a, (long)10, LongVector512Tests::max); } static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXLongVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3295,15 +3345,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long512VectorTests::MAX); + assertArraysEquals(r, a, (long)10, mask, LongVector512Tests::MAX); } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong512VectorTests(IntFunction fa, IntFunction fb) { + static void MINLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3316,15 +3366,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::MIN); + assertArraysEquals(r, a, b, LongVector512Tests::MIN); } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong512VectorTests(IntFunction fa, IntFunction fb) { + static void minLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3335,15 +3385,15 @@ public class Long512VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::min); + assertArraysEquals(r, a, b, LongVector512Tests::min); } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3356,15 +3406,15 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::MAX); + assertArraysEquals(r, a, b, LongVector512Tests::MAX); } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maxLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3375,7 +3425,7 @@ public class Long512VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long512VectorTests::max); + assertArraysEquals(r, a, b, LongVector512Tests::max); } static long UMIN(long a, long b) { @@ -3383,7 +3433,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMINLong512VectorTests(IntFunction fa, IntFunction fb) { + static void UMINLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3396,11 +3446,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::UMIN); + assertArraysEquals(r, a, b, LongVector512Tests::UMIN); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMINLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3416,7 +3466,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, LongVector512Tests::UMIN); } static long UMAX(long a, long b) { @@ -3424,7 +3474,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMAXLong512VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3437,11 +3487,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::UMAX); + assertArraysEquals(r, a, b, LongVector512Tests::UMAX); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMAXLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3457,7 +3507,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, LongVector512Tests::UMAX); } static long SADD(long a, long b) { @@ -3465,7 +3515,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SADDLong512VectorTests(IntFunction fa, IntFunction fb) { + static void SADDLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3478,11 +3528,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::SADD); + assertArraysEquals(r, a, b, LongVector512Tests::SADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SADDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3498,7 +3548,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::SADD); + assertArraysEquals(r, a, b, mask, LongVector512Tests::SADD); } static long SSUB(long a, long b) { @@ -3506,7 +3556,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SSUBLong512VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3519,11 +3569,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::SSUB); + assertArraysEquals(r, a, b, LongVector512Tests::SSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SSUBLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3539,7 +3589,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, LongVector512Tests::SSUB); } static long SUADD(long a, long b) { @@ -3547,7 +3597,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUADDLong512VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3560,11 +3610,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::SUADD); + assertArraysEquals(r, a, b, LongVector512Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUADDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3580,7 +3630,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, LongVector512Tests::SUADD); } static long SUSUB(long a, long b) { @@ -3588,7 +3638,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUSUBLong512VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3601,11 +3651,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::SUSUB); + assertArraysEquals(r, a, b, LongVector512Tests::SUSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUSUBLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3621,11 +3671,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, LongVector512Tests::SUSUB); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3635,11 +3685,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::MIN); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3649,11 +3699,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::min); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3663,11 +3713,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::MAX); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3677,10 +3727,10 @@ public class Long512VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongVector512Tests::max); } @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") - static void SUADDAssocLong512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocLongVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -3697,11 +3747,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Long512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, LongVector512Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3722,13 +3772,13 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Long512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongVector512Tests::SUADD); } static long ANDReduce(long[] a, int idx) { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3737,14 +3787,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ANDReduceAll(long[] a) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ANDReduceLong512VectorTests(IntFunction fa) { + static void ANDReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3755,12 +3805,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::ANDReduce, Long512VectorTests::ANDReduceAll); + LongVector512Tests::ANDReduce, LongVector512Tests::ANDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3768,20 +3818,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = AND_IDENTITY; - assertEquals((long) (id & id), id, + assertEquals((long) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id & x), x); - assertEquals((long) (x & id), x); + assertEquals((long) (scalar_and(id, x)), x); + assertEquals((long) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id & x), x, + assertEquals((long) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x & id), x, + assertEquals((long) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3790,7 +3840,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3799,14 +3849,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ANDReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3819,18 +3869,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::ANDReduceMasked, Long512VectorTests::ANDReduceAllMasked); + LongVector512Tests::ANDReduceMasked, LongVector512Tests::ANDReduceAllMasked); } static long ORReduce(long[] a, int idx) { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3839,14 +3889,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ORReduceAll(long[] a) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ORReduceLong512VectorTests(IntFunction fa) { + static void ORReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3857,12 +3907,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::ORReduce, Long512VectorTests::ORReduceAll); + LongVector512Tests::ORReduce, LongVector512Tests::ORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3870,20 +3920,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = OR_IDENTITY; - assertEquals((long) (id | id), id, + assertEquals((long) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id | x), x); - assertEquals((long) (x | id), x); + assertEquals((long) (scalar_or(id, x)), x); + assertEquals((long) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id | x), x, + assertEquals((long) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x | id), x, + assertEquals((long) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3892,7 +3942,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3901,14 +3951,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ORReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3921,18 +3971,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::ORReduceMasked, Long512VectorTests::ORReduceAllMasked); + LongVector512Tests::ORReduceMasked, LongVector512Tests::ORReduceAllMasked); } static long XORReduce(long[] a, int idx) { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3941,14 +3991,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long XORReduceAll(long[] a) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void XORReduceLong512VectorTests(IntFunction fa) { + static void XORReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3959,12 +4009,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::XORReduce, Long512VectorTests::XORReduceAll); + LongVector512Tests::XORReduce, LongVector512Tests::XORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3972,20 +4022,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = XOR_IDENTITY; - assertEquals((long) (id ^ id), id, + assertEquals((long) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id ^ x), x); - assertEquals((long) (x ^ id), x); + assertEquals((long) (scalar_xor(id, x)), x); + assertEquals((long) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id ^ x), x, + assertEquals((long) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x ^ id), x, + assertEquals((long) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3994,7 +4044,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -4003,14 +4053,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void XORReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4023,18 +4073,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::XORReduceMasked, Long512VectorTests::XORReduceAllMasked); + LongVector512Tests::XORReduceMasked, LongVector512Tests::XORReduceAllMasked); } static long ADDReduce(long[] a, int idx) { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4043,14 +4093,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ADDReduceAll(long[] a) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLong512VectorTests(IntFunction fa) { + static void ADDReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4061,12 +4111,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::ADDReduce, Long512VectorTests::ADDReduceAll); + LongVector512Tests::ADDReduce, LongVector512Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4074,20 +4124,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = ADD_IDENTITY; - assertEquals((long) (id + id), id, + assertEquals((long) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id + x), x); - assertEquals((long) (x + id), x); + assertEquals((long) (scalar_add(id, x)), x); + assertEquals((long) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id + x), x, + assertEquals((long) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x + id), x, + assertEquals((long) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4096,7 +4146,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4105,14 +4155,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long ADDReduceAllMasked(long[] a, boolean[] mask) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4125,18 +4175,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::ADDReduceMasked, Long512VectorTests::ADDReduceAllMasked); + LongVector512Tests::ADDReduceMasked, LongVector512Tests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4145,14 +4195,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MULReduceAll(long[] a) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MULReduceLong512VectorTests(IntFunction fa) { + static void MULReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4163,12 +4213,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::MULReduce, Long512VectorTests::MULReduceAll); + LongVector512Tests::MULReduce, LongVector512Tests::MULReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4176,20 +4226,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MUL_IDENTITY; - assertEquals((long) (id * id), id, + assertEquals((long) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id * x), x); - assertEquals((long) (x * id), x); + assertEquals((long) (scalar_mul(id, x)), x); + assertEquals((long) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id * x), x, + assertEquals((long) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x * id), x, + assertEquals((long) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4198,7 +4248,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4207,14 +4257,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MULReduceAllMasked(long[] a, boolean[] mask) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MULReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4227,18 +4277,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::MULReduceMasked, Long512VectorTests::MULReduceAllMasked); + LongVector512Tests::MULReduceMasked, LongVector512Tests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4247,14 +4297,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MINReduceAll(long[] a) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MINReduceLong512VectorTests(IntFunction fa) { + static void MINReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4265,12 +4315,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::MINReduce, Long512VectorTests::MINReduceAll); + LongVector512Tests::MINReduce, LongVector512Tests::MINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4278,20 +4328,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MIN_IDENTITY; - assertEquals((long) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.min(id, x), x); - assertEquals((long) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4300,7 +4350,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4309,14 +4359,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MINReduceAllMasked(long[] a, boolean[] mask) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4329,18 +4379,18 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::MINReduceMasked, Long512VectorTests::MINReduceAllMasked); + LongVector512Tests::MINReduceMasked, LongVector512Tests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4349,14 +4399,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MAXReduceAll(long[] a) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MAXReduceLong512VectorTests(IntFunction fa) { + static void MAXReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4367,12 +4417,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::MAXReduce, Long512VectorTests::MAXReduceAll); + LongVector512Tests::MAXReduce, LongVector512Tests::MAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4380,20 +4430,20 @@ public class Long512VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MAX_IDENTITY; - assertEquals((long) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.max(id, x), x); - assertEquals((long) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4402,7 +4452,7 @@ public class Long512VectorTests extends AbstractVectorTest { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4411,14 +4461,14 @@ public class Long512VectorTests extends AbstractVectorTest { static long MAXReduceAllMasked(long[] a, boolean[] mask) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4431,12 +4481,12 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::MAXReduceMasked, Long512VectorTests::MAXReduceAllMasked); + LongVector512Tests::MAXReduceMasked, LongVector512Tests::MAXReduceAllMasked); } static long UMINReduce(long[] a, int idx) { @@ -4458,7 +4508,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMINReduceLong512VectorTests(IntFunction fa) { + static void UMINReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4474,7 +4524,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::UMINReduce, Long512VectorTests::UMINReduceAll); + LongVector512Tests::UMINReduce, LongVector512Tests::UMINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4520,7 +4570,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMINReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4538,7 +4588,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::UMINReduceMasked, Long512VectorTests::UMINReduceAllMasked); + LongVector512Tests::UMINReduceMasked, LongVector512Tests::UMINReduceAllMasked); } static long UMAXReduce(long[] a, int idx) { @@ -4560,7 +4610,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMAXReduceLong512VectorTests(IntFunction fa) { + static void UMAXReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4576,7 +4626,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::UMAXReduce, Long512VectorTests::UMAXReduceAll); + LongVector512Tests::UMAXReduce, LongVector512Tests::UMAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4622,7 +4672,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4640,7 +4690,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::UMAXReduceMasked, Long512VectorTests::UMAXReduceAllMasked); + LongVector512Tests::UMAXReduceMasked, LongVector512Tests::UMAXReduceAllMasked); } static long FIRST_NONZEROReduce(long[] a, int idx) { @@ -4662,7 +4712,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void FIRST_NONZEROReduceLong512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4678,7 +4728,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::FIRST_NONZEROReduce, Long512VectorTests::FIRST_NONZEROReduceAll); + LongVector512Tests::FIRST_NONZEROReduce, LongVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4724,7 +4774,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void FIRST_NONZEROReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4742,7 +4792,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::FIRST_NONZEROReduceMasked, Long512VectorTests::FIRST_NONZEROReduceAllMasked); + LongVector512Tests::FIRST_NONZEROReduceMasked, LongVector512Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4755,7 +4805,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueLong512VectorTests(IntFunction fm) { + static void anyTrueLongVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4766,7 +4816,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongVector512Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4779,7 +4829,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueLong512VectorTests(IntFunction fm) { + static void allTrueLongVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4790,7 +4840,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongVector512Tests::allTrue); } static long SUADDReduce(long[] a, int idx) { @@ -4812,7 +4862,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingUnaryOpProvider") - static void SUADDReduceLong512VectorTests(IntFunction fa) { + static void SUADDReduceLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4828,7 +4878,7 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::SUADDReduce, Long512VectorTests::SUADDReduceAll); + LongVector512Tests::SUADDReduce, LongVector512Tests::SUADDReduceAll); } @Test(dataProvider = "longSaturatingUnaryOpProvider") @@ -4873,7 +4923,7 @@ public class Long512VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") - static void SUADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4891,11 +4941,11 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::SUADDReduceMasked, Long512VectorTests::SUADDReduceAllMasked); + LongVector512Tests::SUADDReduceMasked, LongVector512Tests::SUADDReduceAllMasked); } @Test(dataProvider = "longBinaryOpProvider") - static void withLong512VectorTests(IntFunction fa, IntFunction fb) { + static void withLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -4918,7 +4968,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_DEFAULTLong512VectorTests(IntFunction fa) { + static void IS_DEFAULTLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4935,7 +4985,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_DEFAULTMaskedLong512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4959,7 +5009,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_NEGATIVELong512VectorTests(IntFunction fa) { + static void IS_NEGATIVELongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4976,7 +5026,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_NEGATIVEMaskedLong512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4996,7 +5046,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void LTLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5015,7 +5065,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ltLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5034,7 +5084,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5057,7 +5107,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void GTLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5076,7 +5126,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5099,7 +5149,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void EQLong512VectorTests(IntFunction fa, IntFunction fb) { + static void EQLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5118,7 +5168,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void eqLong512VectorTests(IntFunction fa, IntFunction fb) { + static void eqLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5137,7 +5187,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5160,7 +5210,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void NELong512VectorTests(IntFunction fa, IntFunction fb) { + static void NELongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5179,7 +5229,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void NELong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NELongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5202,7 +5252,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LELong512VectorTests(IntFunction fa, IntFunction fb) { + static void LELongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5221,7 +5271,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LELong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LELongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5244,7 +5294,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GELong512VectorTests(IntFunction fa, IntFunction fb) { + static void GELongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5263,7 +5313,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GELong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GELongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5286,7 +5336,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void ULTLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5305,7 +5355,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5328,7 +5378,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5347,7 +5397,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5370,7 +5420,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULELong512VectorTests(IntFunction fa, IntFunction fb) { + static void ULELongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5389,7 +5439,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULELong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULELongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5412,7 +5462,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGELong512VectorTests(IntFunction fa, IntFunction fb) { + static void UGELongVector512Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5431,7 +5481,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGELong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGELongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5454,7 +5504,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5464,13 +5514,13 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5484,14 +5534,14 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "longCompareOpProvider") - static void EQLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5501,13 +5551,13 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5521,7 +5571,7 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5532,7 +5582,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void blendLong512VectorTests(IntFunction fa, IntFunction fb, + static void blendLongVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5548,11 +5598,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long512VectorTests::blend); + assertArraysEquals(r, a, b, mask, LongVector512Tests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") - static void RearrangeLong512VectorTests(IntFunction fa, + static void RearrangeLongVector512Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5569,7 +5619,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") - static void RearrangeLong512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeLongVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -5587,7 +5637,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void compressLong512VectorTests(IntFunction fa, + static void compressLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5605,7 +5655,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void expandLong512VectorTests(IntFunction fa, + static void expandLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void getLong512VectorTests(IntFunction fa) { + static void getLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5779,7 +5829,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BroadcastLong512VectorTests(IntFunction fa) { + static void BroadcastLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5793,7 +5843,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZeroLong512VectorTests(IntFunction fa) { + static void ZeroLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5818,7 +5868,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void sliceUnaryLong512VectorTests(IntFunction fa) { + static void sliceUnaryLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5829,7 +5879,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongVector512Tests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { @@ -5846,7 +5896,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void sliceBinaryLong512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryLongVector512TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5859,7 +5909,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Long512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongVector512Tests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { @@ -5876,7 +5926,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void sliceLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5893,7 +5943,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Long512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, LongVector512Tests::slice); } static long[] unsliceUnary(long[] a, int origin, int idx) { @@ -5910,7 +5960,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void unsliceUnaryLong512VectorTests(IntFunction fa) { + static void unsliceUnaryLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5921,7 +5971,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongVector512Tests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { @@ -5947,7 +5997,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void unsliceBinaryLong512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryLongVector512TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5961,7 +6011,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Long512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongVector512Tests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { @@ -6001,7 +6051,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void unsliceLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6018,7 +6068,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Long512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongVector512Tests::unslice); } static long BITWISE_BLEND(long a, long b, long c) { @@ -6030,7 +6080,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6045,11 +6095,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Long512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6062,11 +6112,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Long512VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, LongVector512Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6084,11 +6134,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Long512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6114,11 +6164,11 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6129,11 +6179,11 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongVector512Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6144,11 +6194,11 @@ public class Long512VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long512VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector512Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6163,11 +6213,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Long512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6182,11 +6232,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Long512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6197,11 +6247,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6212,11 +6262,11 @@ public class Long512VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long512VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector512Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6230,19 +6280,19 @@ public class Long512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongVector512Tests::BITWISE_BLEND); } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void NEGLong512VectorTests(IntFunction fa) { + static void NEGLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6253,11 +6303,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::NEG); + assertArraysEquals(r, a, LongVector512Tests::NEG); } @Test(dataProvider = "longUnaryOpProvider") - static void negLong512VectorTests(IntFunction fa) { + static void negLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6268,11 +6318,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::neg); + assertArraysEquals(r, a, LongVector512Tests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NEGMaskedLong512VectorTests(IntFunction fa, + static void NEGMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6286,19 +6336,19 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::NEG); + assertArraysEquals(r, a, mask, LongVector512Tests::NEG); } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void ABSLong512VectorTests(IntFunction fa) { + static void ABSLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6309,11 +6359,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::ABS); + assertArraysEquals(r, a, LongVector512Tests::ABS); } @Test(dataProvider = "longUnaryOpProvider") - static void absLong512VectorTests(IntFunction fa) { + static void absLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6324,11 +6374,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::abs); + assertArraysEquals(r, a, LongVector512Tests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ABSMaskedLong512VectorTests(IntFunction fa, + static void ABSMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6342,7 +6392,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::ABS); + assertArraysEquals(r, a, mask, LongVector512Tests::ABS); } static long NOT(long a) { @@ -6354,7 +6404,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void NOTLong512VectorTests(IntFunction fa) { + static void NOTLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6365,11 +6415,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::NOT); + assertArraysEquals(r, a, LongVector512Tests::NOT); } @Test(dataProvider = "longUnaryOpProvider") - static void notLong512VectorTests(IntFunction fa) { + static void notLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6380,11 +6430,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::not); + assertArraysEquals(r, a, LongVector512Tests::not); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NOTMaskedLong512VectorTests(IntFunction fa, + static void NOTMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6398,7 +6448,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::NOT); + assertArraysEquals(r, a, mask, LongVector512Tests::NOT); } static long ZOMO(long a) { @@ -6406,7 +6456,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZOMOLong512VectorTests(IntFunction fa) { + static void ZOMOLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6417,11 +6467,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::ZOMO); + assertArraysEquals(r, a, LongVector512Tests::ZOMO); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ZOMOMaskedLong512VectorTests(IntFunction fa, + static void ZOMOMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6435,7 +6485,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongVector512Tests::ZOMO); } static long BIT_COUNT(long a) { @@ -6443,7 +6493,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BIT_COUNTLong512VectorTests(IntFunction fa) { + static void BIT_COUNTLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6454,11 +6504,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, LongVector512Tests::BIT_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void BIT_COUNTMaskedLong512VectorTests(IntFunction fa, + static void BIT_COUNTMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6472,7 +6522,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, LongVector512Tests::BIT_COUNT); } static long TRAILING_ZEROS_COUNT(long a) { @@ -6480,7 +6530,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void TRAILING_ZEROS_COUNTLong512VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6491,11 +6541,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector512Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedLong512VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6509,7 +6559,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector512Tests::TRAILING_ZEROS_COUNT); } static long LEADING_ZEROS_COUNT(long a) { @@ -6517,7 +6567,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LEADING_ZEROS_COUNTLong512VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6528,11 +6578,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector512Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedLong512VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6546,7 +6596,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector512Tests::LEADING_ZEROS_COUNT); } static long REVERSE(long a) { @@ -6554,7 +6604,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSELong512VectorTests(IntFunction fa) { + static void REVERSELongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6565,11 +6615,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::REVERSE); + assertArraysEquals(r, a, LongVector512Tests::REVERSE); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSEMaskedLong512VectorTests(IntFunction fa, + static void REVERSEMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6583,7 +6633,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::REVERSE); + assertArraysEquals(r, a, mask, LongVector512Tests::REVERSE); } static long REVERSE_BYTES(long a) { @@ -6591,7 +6641,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSE_BYTESLong512VectorTests(IntFunction fa) { + static void REVERSE_BYTESLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6602,11 +6652,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, LongVector512Tests::REVERSE_BYTES); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedLong512VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedLongVector512Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6620,7 +6670,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, LongVector512Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6628,7 +6678,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6641,7 +6691,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::band); + assertArraysEquals(r, a, b, LongVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6649,7 +6699,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6662,7 +6712,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::bor); + assertArraysEquals(r, a, b, LongVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6670,7 +6720,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6683,7 +6733,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::bxor); + assertArraysEquals(r, a, b, LongVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6691,7 +6741,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6704,7 +6754,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::bandNot); + assertArraysEquals(r, a, b, LongVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6712,7 +6762,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6725,7 +6775,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long512VectorTests::beq); + assertArraysEquals(r, a, b, LongVector512Tests::beq); } static boolean unot(boolean a) { @@ -6733,7 +6783,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotLong512VectorTests(IntFunction fa) { + static void masknotLongVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6744,7 +6794,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::unot); + assertArraysEquals(r, a, LongVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6761,7 +6811,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongLong512VectorTests(IntFunction fa) { + static void maskFromToLongLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6775,7 +6825,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltLongVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6785,13 +6835,13 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpProvider") - static void eqLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqLongVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6801,13 +6851,13 @@ public class Long512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longtoIntUnaryOpProvider") - static void toIntArrayLong512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayLongVector512TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6818,7 +6868,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toLongArrayLong512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayLongVector512TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6829,7 +6879,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toDoubleArrayLong512VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayLongVector512TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6840,7 +6890,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toStringLong512VectorTestsSmokeTest(IntFunction fa) { + static void toStringLongVector512TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6853,7 +6903,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void hashCodeLong512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeLongVector512TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6869,7 +6919,7 @@ public class Long512VectorTests extends AbstractVectorTest { @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongLong512VectorTests(IntFunction fa) { + static void ADDReduceLongLongVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -6885,11 +6935,11 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long512VectorTests::ADDReduce, Long512VectorTests::ADDReduceAll); + LongVector512Tests::ADDReduce, LongVector512Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongLong512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongLongVector512TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6907,11 +6957,11 @@ public class Long512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long512VectorTests::ADDReduceMasked, Long512VectorTests::ADDReduceAllMasked); + LongVector512Tests::ADDReduceMasked, LongVector512Tests::ADDReduceAllMasked); } @Test(dataProvider = "longUnaryOpSelectFromProvider") - static void SelectFromLong512VectorTests(IntFunction fa, + static void SelectFromLongVector512Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, SPECIES.length()); @@ -6927,7 +6977,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorLong512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorLongVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] idx = fc.apply(SPECIES.length()); @@ -6945,7 +6995,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") - static void SelectFromLong512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromLongVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -6964,7 +7014,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousLong512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousLongVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6980,7 +7030,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringLong512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringLongVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6994,7 +7044,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsLong512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsLongVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7008,7 +7058,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsLong512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsLongVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7024,7 +7074,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeLong512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeLongVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7046,7 +7096,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountLong512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountLongVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7057,7 +7107,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, LongVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7071,7 +7121,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueLong512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueLongVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7082,7 +7132,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, LongVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7096,7 +7146,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueLong512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueLongVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7107,11 +7157,11 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, LongVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressLong512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressLongVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7139,7 +7189,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLong512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7153,7 +7203,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongLong512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongLongVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7180,14 +7230,14 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundLong512VectorTestsSmokeTest(int length) { + static void loopBoundLongVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongLong512VectorTestsSmokeTest(int _length) { + static void loopBoundLongLongVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7195,21 +7245,21 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeLong512VectorTestsSmokeTest() { + static void ElementSizeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Long.SIZE); } @Test - static void VectorShapeLong512VectorTestsSmokeTest() { + static void VectorShapeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesLong512VectorTestsSmokeTest() { + static void ShapeWithLanesLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(long.class); @@ -7217,32 +7267,32 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeLong512VectorTestsSmokeTest() { + static void ElementTypeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementType() == long.class); } @Test - static void SpeciesElementSizeLong512VectorTestsSmokeTest() { + static void SpeciesElementSizeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementSize() == Long.SIZE); } @Test - static void VectorTypeLong512VectorTestsSmokeTest() { + static void VectorTypeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesLong512VectorTestsSmokeTest() { + static void WithLanesLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeLong512VectorTestsSmokeTest() { + static void WithShapeLongVector512TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7250,7 +7300,7 @@ public class Long512VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueLong512VectorTestsSmokeTest() { + static void MaskAllTrueLongVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/LongVector64LoadStoreTests.java index c4894fd86a4..c1eb1e87561 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Long64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation LongVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Long64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class LongVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = LongVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/LongVector64Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Long64VectorTests.java rename to test/jdk/jdk/incubator/vector/LongVector64Tests.java index 3118ce5a4a2..d4cdfe54ad2 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Long64VectorTests extends AbstractVectorTest { +public class LongVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = LongVector.SPECIES_64; @@ -1547,6 +1547,59 @@ public class Long64VectorTests extends AbstractVectorTest { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1563,9 +1616,6 @@ public class Long64VectorTests extends AbstractVectorTest { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1679,11 +1729,11 @@ public class Long64VectorTests extends AbstractVectorTest { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1696,15 +1746,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::ADD); + assertArraysEquals(r, a, b, LongVector64Tests::ADD); } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong64VectorTests(IntFunction fa, IntFunction fb) { + static void addLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1715,11 +1765,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::add); + assertArraysEquals(r, a, b, LongVector64Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1735,11 +1785,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, LongVector64Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1753,15 +1803,15 @@ public class Long64VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long64VectorTests::add); + assertArraysEquals(r, a, b, mask, LongVector64Tests::add); } static long SUB(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void SUBLong64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1774,15 +1824,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::SUB); + assertArraysEquals(r, a, b, LongVector64Tests::SUB); } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong64VectorTests(IntFunction fa, IntFunction fb) { + static void subLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1793,11 +1843,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::sub); + assertArraysEquals(r, a, b, LongVector64Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void SUBLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1813,11 +1863,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, LongVector64Tests::SUB); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1831,15 +1881,15 @@ public class Long64VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long64VectorTests::sub); + assertArraysEquals(r, a, b, mask, LongVector64Tests::sub); } static long MUL(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MULLong64VectorTests(IntFunction fa, IntFunction fb) { + static void MULLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1852,15 +1902,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::MUL); + assertArraysEquals(r, a, b, LongVector64Tests::MUL); } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong64VectorTests(IntFunction fa, IntFunction fb) { + static void mulLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1871,11 +1921,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::mul); + assertArraysEquals(r, a, b, LongVector64Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void MULLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1891,11 +1941,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, LongVector64Tests::MUL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1909,7 +1959,7 @@ public class Long64VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Long64VectorTests::mul); + assertArraysEquals(r, a, b, mask, LongVector64Tests::mul); } static long DIV(long a, long b) { @@ -1917,7 +1967,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void DIVLong64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1932,7 +1982,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::DIV); + assertArraysEquals(r, a, b, LongVector64Tests::DIV); } static long div(long a, long b) { @@ -1940,7 +1990,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void divLong64VectorTests(IntFunction fa, IntFunction fb) { + static void divLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1955,11 +2005,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::div); + assertArraysEquals(r, a, b, LongVector64Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void DIVLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1977,11 +2027,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, LongVector64Tests::DIV); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1999,15 +2049,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::div); + assertArraysEquals(r, a, b, mask, LongVector64Tests::div); } static long FIRST_NONZERO(long a, long b) { - return (long)((a)!=0?a:b); + return (long)(firstNonZero(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void FIRST_NONZEROLong64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2020,11 +2070,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void FIRST_NONZEROLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2040,7 +2090,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongVector64Tests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -2048,7 +2098,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ANDLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2061,7 +2111,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::AND); + assertArraysEquals(r, a, b, LongVector64Tests::AND); } static long and(long a, long b) { @@ -2069,7 +2119,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void andLong64VectorTests(IntFunction fa, IntFunction fb) { + static void andLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2080,11 +2130,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::and); + assertArraysEquals(r, a, b, LongVector64Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2100,7 +2150,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::AND); + assertArraysEquals(r, a, b, mask, LongVector64Tests::AND); } static long AND_NOT(long a, long b) { @@ -2108,7 +2158,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void AND_NOTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2121,11 +2171,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, LongVector64Tests::AND_NOT); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void AND_NOTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2141,7 +2191,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongVector64Tests::AND_NOT); } static long OR(long a, long b) { @@ -2149,7 +2199,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ORLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2162,7 +2212,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::OR); + assertArraysEquals(r, a, b, LongVector64Tests::OR); } static long or(long a, long b) { @@ -2170,7 +2220,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void orLong64VectorTests(IntFunction fa, IntFunction fb) { + static void orLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2181,11 +2231,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::or); + assertArraysEquals(r, a, b, LongVector64Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2201,7 +2251,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::OR); + assertArraysEquals(r, a, b, mask, LongVector64Tests::OR); } static long XOR(long a, long b) { @@ -2209,7 +2259,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void XORLong64VectorTests(IntFunction fa, IntFunction fb) { + static void XORLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2222,11 +2272,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::XOR); + assertArraysEquals(r, a, b, LongVector64Tests::XOR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void XORLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2242,7 +2292,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::XOR); + assertArraysEquals(r, a, b, mask, LongVector64Tests::XOR); } static long COMPRESS_BITS(long a, long b) { @@ -2250,7 +2300,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void COMPRESS_BITSLong64VectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2263,11 +2313,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, LongVector64Tests::COMPRESS_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void COMPRESS_BITSLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2283,7 +2333,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, LongVector64Tests::COMPRESS_BITS); } static long EXPAND_BITS(long a, long b) { @@ -2291,7 +2341,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void EXPAND_BITSLong64VectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2304,11 +2354,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, LongVector64Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void EXPAND_BITSLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2324,11 +2374,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, LongVector64Tests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpProvider") - static void addLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2338,11 +2388,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2355,11 +2405,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::add); } @Test(dataProvider = "longBinaryOpProvider") - static void subLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2369,11 +2419,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2386,11 +2436,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::sub); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2400,11 +2450,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::mul); } @Test(dataProvider = "longBinaryOpProvider") - static void divLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2433,11 +2483,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2452,11 +2502,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::div); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2466,11 +2516,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void orLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2480,11 +2530,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2497,11 +2547,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2511,11 +2561,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void andLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2525,11 +2575,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2542,11 +2592,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongVector64Tests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLong64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongVector64Tests::OR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLong64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2573,11 +2623,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector64Tests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLong64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDLongVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2587,11 +2637,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongVector64Tests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLong64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDLongVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2604,7 +2654,7 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVector64Tests::ADD); } static long LSHL(long a, long b) { @@ -2612,7 +2662,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2625,11 +2675,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::LSHL); + assertArraysEquals(r, a, b, LongVector64Tests::LSHL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2645,7 +2695,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, LongVector64Tests::LSHL); } static long ASHR(long a, long b) { @@ -2653,7 +2703,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2666,11 +2716,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::ASHR); + assertArraysEquals(r, a, b, LongVector64Tests::ASHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2686,7 +2736,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, LongVector64Tests::ASHR); } static long LSHR(long a, long b) { @@ -2694,7 +2744,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2707,11 +2757,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::LSHR); + assertArraysEquals(r, a, b, LongVector64Tests::LSHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2727,7 +2777,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, LongVector64Tests::LSHR); } static long LSHL_unary(long a, long b) { @@ -2735,7 +2785,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLong64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLLongVector64TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2747,11 +2797,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, LongVector64Tests::LSHL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLong64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2766,7 +2816,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector64Tests::LSHL_unary); } static long LSHR_unary(long a, long b) { @@ -2774,7 +2824,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLong64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRLongVector64TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2786,11 +2836,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, LongVector64Tests::LSHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLong64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2805,7 +2855,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector64Tests::LSHR_unary); } static long ASHR_unary(long a, long b) { @@ -2813,7 +2863,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLong64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRLongVector64TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2825,11 +2875,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, LongVector64Tests::ASHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLong64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2844,7 +2894,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector64Tests::ASHR_unary); } static long ROR(long a, long b) { @@ -2852,7 +2902,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong64VectorTests(IntFunction fa, IntFunction fb) { + static void RORLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2865,11 +2915,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::ROR); + assertArraysEquals(r, a, b, LongVector64Tests::ROR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2885,7 +2935,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::ROR); + assertArraysEquals(r, a, b, mask, LongVector64Tests::ROR); } static long ROL(long a, long b) { @@ -2893,7 +2943,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ROLLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2906,11 +2956,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::ROL); + assertArraysEquals(r, a, b, LongVector64Tests::ROL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2926,7 +2976,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::ROL); + assertArraysEquals(r, a, b, mask, LongVector64Tests::ROL); } static long ROR_unary(long a, long b) { @@ -2934,7 +2984,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLong64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORLongVector64TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2946,11 +2996,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, LongVector64Tests::ROR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLong64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORLongVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2965,7 +3015,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector64Tests::ROR_unary); } static long ROL_unary(long a, long b) { @@ -2973,7 +3023,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLong64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLLongVector64TestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2985,11 +3035,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Long64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, LongVector64Tests::ROL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLong64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLLongVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3004,14 +3054,14 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVector64Tests::ROL_unary); } static long LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT)); } @Test(dataProvider = "longUnaryOpProvider") - static void LSHRLong64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRLongVector64TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3022,11 +3072,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, LongVector64Tests::LSHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHRLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRLongVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3040,7 +3090,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector64Tests::LSHR_binary_const); } static long LSHL_binary_const(long a) { @@ -3048,7 +3098,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LSHLLong64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLLongVector64TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3059,11 +3109,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, LongVector64Tests::LSHL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHLLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLLongVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3077,7 +3127,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector64Tests::LSHL_binary_const); } static long ASHR_binary_const(long a) { @@ -3085,7 +3135,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ASHRLong64VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRLongVector64TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3096,11 +3146,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, LongVector64Tests::ASHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ASHRLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRLongVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3114,7 +3164,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector64Tests::ASHR_binary_const); } static long ROR_binary_const(long a) { @@ -3122,7 +3172,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void RORLong64VectorTestsScalarShiftConst(IntFunction fa) { + static void RORLongVector64TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3133,11 +3183,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, LongVector64Tests::ROR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void RORLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORLongVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3151,7 +3201,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, LongVector64Tests::ROR_binary_const); } static long ROL_binary_const(long a) { @@ -3159,7 +3209,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ROLLong64VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLLongVector64TestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3170,11 +3220,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Long64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, LongVector64Tests::ROL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ROLLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLLongVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3188,14 +3238,14 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Long64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, LongVector64Tests::ROL_binary_const); } static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MINLong64VectorTestsWithMemOp(IntFunction fa) { + static void MINLongVector64TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3206,13 +3256,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long64VectorTests::MIN); + assertArraysEquals(r, a, (long)10, LongVector64Tests::MIN); } static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void minLong64VectorTestsWithMemOp(IntFunction fa) { + static void minLongVector64TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3223,13 +3273,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long64VectorTests::min); + assertArraysEquals(r, a, (long)10, LongVector64Tests::min); } static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINLongVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3242,13 +3292,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long64VectorTests::MIN); + assertArraysEquals(r, a, (long)10, mask, LongVector64Tests::MIN); } static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MAXLong64VectorTestsWithMemOp(IntFunction fa) { + static void MAXLongVector64TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3259,13 +3309,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long64VectorTests::MAX); + assertArraysEquals(r, a, (long)10, LongVector64Tests::MAX); } static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void maxLong64VectorTestsWithMemOp(IntFunction fa) { + static void maxLongVector64TestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3276,13 +3326,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, Long64VectorTests::max); + assertArraysEquals(r, a, (long)10, LongVector64Tests::max); } static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXLongVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3295,15 +3345,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, Long64VectorTests::MAX); + assertArraysEquals(r, a, (long)10, mask, LongVector64Tests::MAX); } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong64VectorTests(IntFunction fa, IntFunction fb) { + static void MINLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3316,15 +3366,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::MIN); + assertArraysEquals(r, a, b, LongVector64Tests::MIN); } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong64VectorTests(IntFunction fa, IntFunction fb) { + static void minLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3335,15 +3385,15 @@ public class Long64VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::min); + assertArraysEquals(r, a, b, LongVector64Tests::min); } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3356,15 +3406,15 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::MAX); + assertArraysEquals(r, a, b, LongVector64Tests::MAX); } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maxLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3375,7 +3425,7 @@ public class Long64VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Long64VectorTests::max); + assertArraysEquals(r, a, b, LongVector64Tests::max); } static long UMIN(long a, long b) { @@ -3383,7 +3433,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMINLong64VectorTests(IntFunction fa, IntFunction fb) { + static void UMINLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3396,11 +3446,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::UMIN); + assertArraysEquals(r, a, b, LongVector64Tests::UMIN); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMINLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3416,7 +3466,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, LongVector64Tests::UMIN); } static long UMAX(long a, long b) { @@ -3424,7 +3474,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMAXLong64VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3437,11 +3487,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::UMAX); + assertArraysEquals(r, a, b, LongVector64Tests::UMAX); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMAXLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3457,7 +3507,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, LongVector64Tests::UMAX); } static long SADD(long a, long b) { @@ -3465,7 +3515,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SADDLong64VectorTests(IntFunction fa, IntFunction fb) { + static void SADDLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3478,11 +3528,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::SADD); + assertArraysEquals(r, a, b, LongVector64Tests::SADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SADDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3498,7 +3548,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::SADD); + assertArraysEquals(r, a, b, mask, LongVector64Tests::SADD); } static long SSUB(long a, long b) { @@ -3506,7 +3556,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SSUBLong64VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3519,11 +3569,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::SSUB); + assertArraysEquals(r, a, b, LongVector64Tests::SSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SSUBLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3539,7 +3589,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, LongVector64Tests::SSUB); } static long SUADD(long a, long b) { @@ -3547,7 +3597,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUADDLong64VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3560,11 +3610,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::SUADD); + assertArraysEquals(r, a, b, LongVector64Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUADDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3580,7 +3630,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, LongVector64Tests::SUADD); } static long SUSUB(long a, long b) { @@ -3588,7 +3638,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUSUBLong64VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3601,11 +3651,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::SUSUB); + assertArraysEquals(r, a, b, LongVector64Tests::SUSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUSUBLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3621,11 +3671,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, LongVector64Tests::SUSUB); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3635,11 +3685,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::MIN); } @Test(dataProvider = "longBinaryOpProvider") - static void minLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3649,11 +3699,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::min); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3663,11 +3713,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::MAX); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3677,10 +3727,10 @@ public class Long64VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Long64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongVector64Tests::max); } @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") - static void SUADDAssocLong64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocLongVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -3697,11 +3747,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Long64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, LongVector64Tests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3722,13 +3772,13 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Long64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongVector64Tests::SUADD); } static long ANDReduce(long[] a, int idx) { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3737,14 +3787,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ANDReduceAll(long[] a) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ANDReduceLong64VectorTests(IntFunction fa) { + static void ANDReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3755,12 +3805,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::ANDReduce, Long64VectorTests::ANDReduceAll); + LongVector64Tests::ANDReduce, LongVector64Tests::ANDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3768,20 +3818,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = AND_IDENTITY; - assertEquals((long) (id & id), id, + assertEquals((long) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id & x), x); - assertEquals((long) (x & id), x); + assertEquals((long) (scalar_and(id, x)), x); + assertEquals((long) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id & x), x, + assertEquals((long) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x & id), x, + assertEquals((long) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3790,7 +3840,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3799,14 +3849,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ANDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3819,18 +3869,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::ANDReduceMasked, Long64VectorTests::ANDReduceAllMasked); + LongVector64Tests::ANDReduceMasked, LongVector64Tests::ANDReduceAllMasked); } static long ORReduce(long[] a, int idx) { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3839,14 +3889,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ORReduceAll(long[] a) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ORReduceLong64VectorTests(IntFunction fa) { + static void ORReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3857,12 +3907,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::ORReduce, Long64VectorTests::ORReduceAll); + LongVector64Tests::ORReduce, LongVector64Tests::ORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3870,20 +3920,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = OR_IDENTITY; - assertEquals((long) (id | id), id, + assertEquals((long) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id | x), x); - assertEquals((long) (x | id), x); + assertEquals((long) (scalar_or(id, x)), x); + assertEquals((long) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id | x), x, + assertEquals((long) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x | id), x, + assertEquals((long) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3892,7 +3942,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3901,14 +3951,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3921,18 +3971,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::ORReduceMasked, Long64VectorTests::ORReduceAllMasked); + LongVector64Tests::ORReduceMasked, LongVector64Tests::ORReduceAllMasked); } static long XORReduce(long[] a, int idx) { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3941,14 +3991,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long XORReduceAll(long[] a) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void XORReduceLong64VectorTests(IntFunction fa) { + static void XORReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3959,12 +4009,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::XORReduce, Long64VectorTests::XORReduceAll); + LongVector64Tests::XORReduce, LongVector64Tests::XORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3972,20 +4022,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = XOR_IDENTITY; - assertEquals((long) (id ^ id), id, + assertEquals((long) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id ^ x), x); - assertEquals((long) (x ^ id), x); + assertEquals((long) (scalar_xor(id, x)), x); + assertEquals((long) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id ^ x), x, + assertEquals((long) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x ^ id), x, + assertEquals((long) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3994,7 +4044,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -4003,14 +4053,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void XORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4023,18 +4073,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::XORReduceMasked, Long64VectorTests::XORReduceAllMasked); + LongVector64Tests::XORReduceMasked, LongVector64Tests::XORReduceAllMasked); } static long ADDReduce(long[] a, int idx) { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4043,14 +4093,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ADDReduceAll(long[] a) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLong64VectorTests(IntFunction fa) { + static void ADDReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4061,12 +4111,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll); + LongVector64Tests::ADDReduce, LongVector64Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4074,20 +4124,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = ADD_IDENTITY; - assertEquals((long) (id + id), id, + assertEquals((long) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id + x), x); - assertEquals((long) (x + id), x); + assertEquals((long) (scalar_add(id, x)), x); + assertEquals((long) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id + x), x, + assertEquals((long) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x + id), x, + assertEquals((long) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4096,7 +4146,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4105,14 +4155,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long ADDReduceAllMasked(long[] a, boolean[] mask) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4125,18 +4175,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked); + LongVector64Tests::ADDReduceMasked, LongVector64Tests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4145,14 +4195,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MULReduceAll(long[] a) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MULReduceLong64VectorTests(IntFunction fa) { + static void MULReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4163,12 +4213,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::MULReduce, Long64VectorTests::MULReduceAll); + LongVector64Tests::MULReduce, LongVector64Tests::MULReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4176,20 +4226,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MUL_IDENTITY; - assertEquals((long) (id * id), id, + assertEquals((long) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id * x), x); - assertEquals((long) (x * id), x); + assertEquals((long) (scalar_mul(id, x)), x); + assertEquals((long) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id * x), x, + assertEquals((long) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x * id), x, + assertEquals((long) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4198,7 +4248,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4207,14 +4257,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MULReduceAllMasked(long[] a, boolean[] mask) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MULReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4227,18 +4277,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::MULReduceMasked, Long64VectorTests::MULReduceAllMasked); + LongVector64Tests::MULReduceMasked, LongVector64Tests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4247,14 +4297,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MINReduceAll(long[] a) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MINReduceLong64VectorTests(IntFunction fa) { + static void MINReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4265,12 +4315,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::MINReduce, Long64VectorTests::MINReduceAll); + LongVector64Tests::MINReduce, LongVector64Tests::MINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4278,20 +4328,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MIN_IDENTITY; - assertEquals((long) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.min(id, x), x); - assertEquals((long) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4300,7 +4350,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4309,14 +4359,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MINReduceAllMasked(long[] a, boolean[] mask) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4329,18 +4379,18 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::MINReduceMasked, Long64VectorTests::MINReduceAllMasked); + LongVector64Tests::MINReduceMasked, LongVector64Tests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4349,14 +4399,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MAXReduceAll(long[] a) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MAXReduceLong64VectorTests(IntFunction fa) { + static void MAXReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4367,12 +4417,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::MAXReduce, Long64VectorTests::MAXReduceAll); + LongVector64Tests::MAXReduce, LongVector64Tests::MAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4380,20 +4430,20 @@ public class Long64VectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MAX_IDENTITY; - assertEquals((long) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.max(id, x), x); - assertEquals((long) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4402,7 +4452,7 @@ public class Long64VectorTests extends AbstractVectorTest { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4411,14 +4461,14 @@ public class Long64VectorTests extends AbstractVectorTest { static long MAXReduceAllMasked(long[] a, boolean[] mask) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4431,12 +4481,12 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::MAXReduceMasked, Long64VectorTests::MAXReduceAllMasked); + LongVector64Tests::MAXReduceMasked, LongVector64Tests::MAXReduceAllMasked); } static long UMINReduce(long[] a, int idx) { @@ -4458,7 +4508,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMINReduceLong64VectorTests(IntFunction fa) { + static void UMINReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4474,7 +4524,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::UMINReduce, Long64VectorTests::UMINReduceAll); + LongVector64Tests::UMINReduce, LongVector64Tests::UMINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4520,7 +4570,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4538,7 +4588,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::UMINReduceMasked, Long64VectorTests::UMINReduceAllMasked); + LongVector64Tests::UMINReduceMasked, LongVector64Tests::UMINReduceAllMasked); } static long UMAXReduce(long[] a, int idx) { @@ -4560,7 +4610,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMAXReduceLong64VectorTests(IntFunction fa) { + static void UMAXReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4576,7 +4626,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::UMAXReduce, Long64VectorTests::UMAXReduceAll); + LongVector64Tests::UMAXReduce, LongVector64Tests::UMAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4622,7 +4672,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4640,7 +4690,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::UMAXReduceMasked, Long64VectorTests::UMAXReduceAllMasked); + LongVector64Tests::UMAXReduceMasked, LongVector64Tests::UMAXReduceAllMasked); } static long FIRST_NONZEROReduce(long[] a, int idx) { @@ -4662,7 +4712,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void FIRST_NONZEROReduceLong64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4678,7 +4728,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::FIRST_NONZEROReduce, Long64VectorTests::FIRST_NONZEROReduceAll); + LongVector64Tests::FIRST_NONZEROReduce, LongVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4724,7 +4774,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void FIRST_NONZEROReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4742,7 +4792,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::FIRST_NONZEROReduceMasked, Long64VectorTests::FIRST_NONZEROReduceAllMasked); + LongVector64Tests::FIRST_NONZEROReduceMasked, LongVector64Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4755,7 +4805,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueLong64VectorTests(IntFunction fm) { + static void anyTrueLongVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4766,7 +4816,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongVector64Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4779,7 +4829,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueLong64VectorTests(IntFunction fm) { + static void allTrueLongVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4790,7 +4840,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Long64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongVector64Tests::allTrue); } static long SUADDReduce(long[] a, int idx) { @@ -4812,7 +4862,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingUnaryOpProvider") - static void SUADDReduceLong64VectorTests(IntFunction fa) { + static void SUADDReduceLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4828,7 +4878,7 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::SUADDReduce, Long64VectorTests::SUADDReduceAll); + LongVector64Tests::SUADDReduce, LongVector64Tests::SUADDReduceAll); } @Test(dataProvider = "longSaturatingUnaryOpProvider") @@ -4873,7 +4923,7 @@ public class Long64VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") - static void SUADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4891,11 +4941,11 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::SUADDReduceMasked, Long64VectorTests::SUADDReduceAllMasked); + LongVector64Tests::SUADDReduceMasked, LongVector64Tests::SUADDReduceAllMasked); } @Test(dataProvider = "longBinaryOpProvider") - static void withLong64VectorTests(IntFunction fa, IntFunction fb) { + static void withLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -4918,7 +4968,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_DEFAULTLong64VectorTests(IntFunction fa) { + static void IS_DEFAULTLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4935,7 +4985,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_DEFAULTMaskedLong64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4959,7 +5009,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_NEGATIVELong64VectorTests(IntFunction fa) { + static void IS_NEGATIVELongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4976,7 +5026,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_NEGATIVEMaskedLong64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4996,7 +5046,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void LTLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5015,7 +5065,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ltLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5034,7 +5084,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5057,7 +5107,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void GTLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5076,7 +5126,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5099,7 +5149,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void EQLong64VectorTests(IntFunction fa, IntFunction fb) { + static void EQLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5118,7 +5168,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void eqLong64VectorTests(IntFunction fa, IntFunction fb) { + static void eqLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5137,7 +5187,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5160,7 +5210,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void NELong64VectorTests(IntFunction fa, IntFunction fb) { + static void NELongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5179,7 +5229,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void NELong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NELongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5202,7 +5252,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LELong64VectorTests(IntFunction fa, IntFunction fb) { + static void LELongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5221,7 +5271,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LELong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LELongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5244,7 +5294,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GELong64VectorTests(IntFunction fa, IntFunction fb) { + static void GELongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5263,7 +5313,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GELong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GELongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5286,7 +5336,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void ULTLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5305,7 +5355,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5328,7 +5378,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5347,7 +5397,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5370,7 +5420,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULELong64VectorTests(IntFunction fa, IntFunction fb) { + static void ULELongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5389,7 +5439,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULELong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULELongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5412,7 +5462,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGELong64VectorTests(IntFunction fa, IntFunction fb) { + static void UGELongVector64Tests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5431,7 +5481,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGELong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGELongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5454,7 +5504,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5464,13 +5514,13 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5484,14 +5534,14 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "longCompareOpProvider") - static void EQLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5501,13 +5551,13 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5521,7 +5571,7 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5532,7 +5582,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void blendLong64VectorTests(IntFunction fa, IntFunction fb, + static void blendLongVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5548,11 +5598,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Long64VectorTests::blend); + assertArraysEquals(r, a, b, mask, LongVector64Tests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") - static void RearrangeLong64VectorTests(IntFunction fa, + static void RearrangeLongVector64Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5569,7 +5619,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") - static void RearrangeLong64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeLongVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -5587,7 +5637,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void compressLong64VectorTests(IntFunction fa, + static void compressLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5605,7 +5655,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void expandLong64VectorTests(IntFunction fa, + static void expandLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5623,7 +5673,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void getLong64VectorTests(IntFunction fa) { + static void getLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5779,7 +5829,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BroadcastLong64VectorTests(IntFunction fa) { + static void BroadcastLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5793,7 +5843,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZeroLong64VectorTests(IntFunction fa) { + static void ZeroLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5818,7 +5868,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void sliceUnaryLong64VectorTests(IntFunction fa) { + static void sliceUnaryLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5829,7 +5879,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongVector64Tests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { @@ -5846,7 +5896,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void sliceBinaryLong64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryLongVector64TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5859,7 +5909,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Long64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongVector64Tests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { @@ -5876,7 +5926,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void sliceLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5893,7 +5943,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Long64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, LongVector64Tests::slice); } static long[] unsliceUnary(long[] a, int origin, int idx) { @@ -5910,7 +5960,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void unsliceUnaryLong64VectorTests(IntFunction fa) { + static void unsliceUnaryLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5921,7 +5971,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Long64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongVector64Tests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { @@ -5947,7 +5997,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void unsliceBinaryLong64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryLongVector64TestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5961,7 +6011,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Long64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongVector64Tests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { @@ -6001,7 +6051,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void unsliceLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6018,7 +6068,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Long64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongVector64Tests::unslice); } static long BITWISE_BLEND(long a, long b, long c) { @@ -6030,7 +6080,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6045,11 +6095,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6062,11 +6112,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, LongVector64Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6084,11 +6134,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6099,11 +6149,11 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6114,11 +6164,11 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6129,11 +6179,11 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongVector64Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6144,11 +6194,11 @@ public class Long64VectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, LongVector64Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6163,11 +6213,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6182,11 +6232,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLong64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6197,11 +6247,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLong64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6212,11 +6262,11 @@ public class Long64VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVector64Tests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLong64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6230,19 +6280,19 @@ public class Long64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongVector64Tests::BITWISE_BLEND); } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void NEGLong64VectorTests(IntFunction fa) { + static void NEGLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6253,11 +6303,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::NEG); + assertArraysEquals(r, a, LongVector64Tests::NEG); } @Test(dataProvider = "longUnaryOpProvider") - static void negLong64VectorTests(IntFunction fa) { + static void negLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6268,11 +6318,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::neg); + assertArraysEquals(r, a, LongVector64Tests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NEGMaskedLong64VectorTests(IntFunction fa, + static void NEGMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6286,19 +6336,19 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::NEG); + assertArraysEquals(r, a, mask, LongVector64Tests::NEG); } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void ABSLong64VectorTests(IntFunction fa) { + static void ABSLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6309,11 +6359,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::ABS); + assertArraysEquals(r, a, LongVector64Tests::ABS); } @Test(dataProvider = "longUnaryOpProvider") - static void absLong64VectorTests(IntFunction fa) { + static void absLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6324,11 +6374,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::abs); + assertArraysEquals(r, a, LongVector64Tests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ABSMaskedLong64VectorTests(IntFunction fa, + static void ABSMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6342,7 +6392,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::ABS); + assertArraysEquals(r, a, mask, LongVector64Tests::ABS); } static long NOT(long a) { @@ -6354,7 +6404,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void NOTLong64VectorTests(IntFunction fa) { + static void NOTLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6365,11 +6415,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::NOT); + assertArraysEquals(r, a, LongVector64Tests::NOT); } @Test(dataProvider = "longUnaryOpProvider") - static void notLong64VectorTests(IntFunction fa) { + static void notLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6380,11 +6430,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::not); + assertArraysEquals(r, a, LongVector64Tests::not); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NOTMaskedLong64VectorTests(IntFunction fa, + static void NOTMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6398,7 +6448,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::NOT); + assertArraysEquals(r, a, mask, LongVector64Tests::NOT); } static long ZOMO(long a) { @@ -6406,7 +6456,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZOMOLong64VectorTests(IntFunction fa) { + static void ZOMOLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6417,11 +6467,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::ZOMO); + assertArraysEquals(r, a, LongVector64Tests::ZOMO); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ZOMOMaskedLong64VectorTests(IntFunction fa, + static void ZOMOMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6435,7 +6485,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongVector64Tests::ZOMO); } static long BIT_COUNT(long a) { @@ -6443,7 +6493,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BIT_COUNTLong64VectorTests(IntFunction fa) { + static void BIT_COUNTLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6454,11 +6504,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, LongVector64Tests::BIT_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void BIT_COUNTMaskedLong64VectorTests(IntFunction fa, + static void BIT_COUNTMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6472,7 +6522,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, LongVector64Tests::BIT_COUNT); } static long TRAILING_ZEROS_COUNT(long a) { @@ -6480,7 +6530,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void TRAILING_ZEROS_COUNTLong64VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6491,11 +6541,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector64Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedLong64VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6509,7 +6559,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector64Tests::TRAILING_ZEROS_COUNT); } static long LEADING_ZEROS_COUNT(long a) { @@ -6517,7 +6567,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LEADING_ZEROS_COUNTLong64VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6528,11 +6578,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVector64Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedLong64VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6546,7 +6596,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVector64Tests::LEADING_ZEROS_COUNT); } static long REVERSE(long a) { @@ -6554,7 +6604,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSELong64VectorTests(IntFunction fa) { + static void REVERSELongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6565,11 +6615,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::REVERSE); + assertArraysEquals(r, a, LongVector64Tests::REVERSE); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSEMaskedLong64VectorTests(IntFunction fa, + static void REVERSEMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6583,7 +6633,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::REVERSE); + assertArraysEquals(r, a, mask, LongVector64Tests::REVERSE); } static long REVERSE_BYTES(long a) { @@ -6591,7 +6641,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSE_BYTESLong64VectorTests(IntFunction fa) { + static void REVERSE_BYTESLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6602,11 +6652,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, LongVector64Tests::REVERSE_BYTES); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedLong64VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedLongVector64Tests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6620,7 +6670,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Long64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, LongVector64Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6628,7 +6678,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6641,7 +6691,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::band); + assertArraysEquals(r, a, b, LongVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6649,7 +6699,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6662,7 +6712,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::bor); + assertArraysEquals(r, a, b, LongVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6670,7 +6720,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6683,7 +6733,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::bxor); + assertArraysEquals(r, a, b, LongVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6691,7 +6741,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6704,7 +6754,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::bandNot); + assertArraysEquals(r, a, b, LongVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6712,7 +6762,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6725,7 +6775,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Long64VectorTests::beq); + assertArraysEquals(r, a, b, LongVector64Tests::beq); } static boolean unot(boolean a) { @@ -6733,7 +6783,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotLong64VectorTests(IntFunction fa) { + static void masknotLongVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6744,7 +6794,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::unot); + assertArraysEquals(r, a, LongVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6761,7 +6811,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongLong64VectorTests(IntFunction fa) { + static void maskFromToLongLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6775,7 +6825,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltLongVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6785,13 +6835,13 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpProvider") - static void eqLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqLongVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6801,13 +6851,13 @@ public class Long64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longtoIntUnaryOpProvider") - static void toIntArrayLong64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayLongVector64TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6818,7 +6868,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toLongArrayLong64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayLongVector64TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6829,7 +6879,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toDoubleArrayLong64VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayLongVector64TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6840,7 +6890,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toStringLong64VectorTestsSmokeTest(IntFunction fa) { + static void toStringLongVector64TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6853,7 +6903,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void hashCodeLong64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeLongVector64TestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6869,7 +6919,7 @@ public class Long64VectorTests extends AbstractVectorTest { @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongLong64VectorTests(IntFunction fa) { + static void ADDReduceLongLongVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -6885,11 +6935,11 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll); + LongVector64Tests::ADDReduce, LongVector64Tests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongLong64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongLongVector64TestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6907,11 +6957,11 @@ public class Long64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked); + LongVector64Tests::ADDReduceMasked, LongVector64Tests::ADDReduceAllMasked); } @Test(dataProvider = "longUnaryOpSelectFromProvider") - static void SelectFromLong64VectorTests(IntFunction fa, + static void SelectFromLongVector64Tests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, SPECIES.length()); @@ -6927,7 +6977,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorLong64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorLongVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] idx = fc.apply(SPECIES.length()); @@ -6945,7 +6995,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") - static void SelectFromLong64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromLongVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -6964,7 +7014,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousLong64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousLongVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6980,7 +7030,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringLong64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringLongVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6994,7 +7044,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsLong64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsLongVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7008,7 +7058,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsLong64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsLongVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7024,7 +7074,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeLong64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeLongVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7046,7 +7096,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountLong64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountLongVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7057,7 +7107,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, LongVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7071,7 +7121,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueLong64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueLongVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7082,7 +7132,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, LongVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7096,7 +7146,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueLong64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueLongVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7107,11 +7157,11 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, LongVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressLong64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressLongVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7139,7 +7189,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLong64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7153,7 +7203,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongLong64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongLongVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7180,14 +7230,14 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundLong64VectorTestsSmokeTest(int length) { + static void loopBoundLongVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongLong64VectorTestsSmokeTest(int _length) { + static void loopBoundLongLongVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7195,21 +7245,21 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeLong64VectorTestsSmokeTest() { + static void ElementSizeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Long.SIZE); } @Test - static void VectorShapeLong64VectorTestsSmokeTest() { + static void VectorShapeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesLong64VectorTestsSmokeTest() { + static void ShapeWithLanesLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(long.class); @@ -7217,32 +7267,32 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeLong64VectorTestsSmokeTest() { + static void ElementTypeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementType() == long.class); } @Test - static void SpeciesElementSizeLong64VectorTestsSmokeTest() { + static void SpeciesElementSizeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementSize() == Long.SIZE); } @Test - static void VectorTypeLong64VectorTestsSmokeTest() { + static void VectorTypeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesLong64VectorTestsSmokeTest() { + static void WithLanesLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeLong64VectorTestsSmokeTest() { + static void WithShapeLongVector64TestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7250,7 +7300,7 @@ public class Long64VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueLong64VectorTestsSmokeTest() { + static void MaskAllTrueLongVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/LongVectorMaxLoadStoreTests.java index 6994ee7c770..cb5bb74424a 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/LongVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation LongMaxVectorLoadStoreTests + * -XX:-TieredCompilation LongVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class LongMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class LongVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = LongVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongVectorMaxTests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/LongMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/LongVectorMaxTests.java index 0e19a587093..597169b00f5 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class LongMaxVectorTests extends AbstractVectorTest { +public class LongVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = LongVector.SPECIES_MAX; @@ -1553,6 +1553,59 @@ public class LongMaxVectorTests extends AbstractVectorTest { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1569,9 +1622,6 @@ public class LongMaxVectorTests extends AbstractVectorTest { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1685,11 +1735,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1702,15 +1752,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::ADD); + assertArraysEquals(r, a, b, LongVectorMaxTests::ADD); } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void addLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1721,11 +1771,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::add); + assertArraysEquals(r, a, b, LongVectorMaxTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1741,11 +1791,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1759,15 +1809,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::add); } static long SUB(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void SUBLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1780,15 +1830,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::SUB); + assertArraysEquals(r, a, b, LongVectorMaxTests::SUB); } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void subLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1799,11 +1849,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::sub); + assertArraysEquals(r, a, b, LongVectorMaxTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void SUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1819,11 +1869,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::SUB); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1837,15 +1887,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::sub); } static long MUL(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MULLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1858,15 +1908,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::MUL); + assertArraysEquals(r, a, b, LongVectorMaxTests::MUL); } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1877,11 +1927,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::mul); + assertArraysEquals(r, a, b, LongVectorMaxTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void MULLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1897,11 +1947,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::MUL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1915,7 +1965,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::mul); } static long DIV(long a, long b) { @@ -1923,7 +1973,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void DIVLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1938,7 +1988,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::DIV); + assertArraysEquals(r, a, b, LongVectorMaxTests::DIV); } static long div(long a, long b) { @@ -1946,7 +1996,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void divLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -1961,11 +2011,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::div); + assertArraysEquals(r, a, b, LongVectorMaxTests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void DIVLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -1983,11 +2033,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::DIV); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2005,15 +2055,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::div); } static long FIRST_NONZERO(long a, long b) { - return (long)((a)!=0?a:b); + return (long)(firstNonZero(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void FIRST_NONZEROLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2026,11 +2076,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, LongVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void FIRST_NONZEROLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2046,7 +2096,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::FIRST_NONZERO); } static long AND(long a, long b) { @@ -2054,7 +2104,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ANDLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2067,7 +2117,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::AND); + assertArraysEquals(r, a, b, LongVectorMaxTests::AND); } static long and(long a, long b) { @@ -2075,7 +2125,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void andLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void andLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2086,11 +2136,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::and); + assertArraysEquals(r, a, b, LongVectorMaxTests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2106,7 +2156,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::AND); } static long AND_NOT(long a, long b) { @@ -2114,7 +2164,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void AND_NOTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2127,11 +2177,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, LongVectorMaxTests::AND_NOT); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void AND_NOTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2147,7 +2197,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::AND_NOT); } static long OR(long a, long b) { @@ -2155,7 +2205,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ORLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ORLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2168,7 +2218,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::OR); + assertArraysEquals(r, a, b, LongVectorMaxTests::OR); } static long or(long a, long b) { @@ -2176,7 +2226,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void orLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void orLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2187,11 +2237,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::or); + assertArraysEquals(r, a, b, LongVectorMaxTests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2207,7 +2257,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::OR); } static long XOR(long a, long b) { @@ -2215,7 +2265,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void XORLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void XORLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2228,11 +2278,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::XOR); + assertArraysEquals(r, a, b, LongVectorMaxTests::XOR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void XORLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2248,7 +2298,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::XOR); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::XOR); } static long COMPRESS_BITS(long a, long b) { @@ -2256,7 +2306,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void COMPRESS_BITSLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void COMPRESS_BITSLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2269,11 +2319,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, LongVectorMaxTests::COMPRESS_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void COMPRESS_BITSLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void COMPRESS_BITSLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2289,7 +2339,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::COMPRESS_BITS); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::COMPRESS_BITS); } static long EXPAND_BITS(long a, long b) { @@ -2297,7 +2347,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void EXPAND_BITSLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EXPAND_BITSLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2310,11 +2360,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, LongVectorMaxTests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void EXPAND_BITSLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EXPAND_BITSLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2330,11 +2380,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::EXPAND_BITS); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::EXPAND_BITS); } @Test(dataProvider = "longBinaryOpProvider") - static void addLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2344,11 +2394,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::add); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void addLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2361,11 +2411,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::add); } @Test(dataProvider = "longBinaryOpProvider") - static void subLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2375,11 +2425,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::sub); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void subLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2392,11 +2442,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::sub); } @Test(dataProvider = "longBinaryOpProvider") - static void mulLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2406,11 +2456,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::mul); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void mulLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2423,11 +2473,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::mul); } @Test(dataProvider = "longBinaryOpProvider") - static void divLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2439,11 +2489,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::div); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void divLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2458,11 +2508,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::div); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2472,11 +2522,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void orLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2486,11 +2536,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::or); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2503,11 +2553,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ANDLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2517,11 +2567,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void andLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2531,11 +2581,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::and); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ANDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2548,11 +2598,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, LongVectorMaxTests::AND); } @Test(dataProvider = "longBinaryOpProvider") - static void ORLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORLongVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2562,11 +2612,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, LongVectorMaxTests::OR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ORLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORLongVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2579,11 +2629,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVectorMaxTests::OR); } @Test(dataProvider = "longBinaryOpProvider") - static void ADDLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDLongVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2593,11 +2643,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, LongVectorMaxTests::ADD); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ADDLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDLongVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2610,7 +2660,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, LongVectorMaxTests::ADD); } static long LSHL(long a, long b) { @@ -2618,7 +2668,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHLLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2631,11 +2681,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, LongVectorMaxTests::LSHL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2651,7 +2701,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::LSHL); } static long ASHR(long a, long b) { @@ -2659,7 +2709,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ASHRLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2672,11 +2722,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, LongVectorMaxTests::ASHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2692,7 +2742,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::ASHR); } static long LSHR(long a, long b) { @@ -2700,7 +2750,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHRLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2713,11 +2763,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, LongVectorMaxTests::LSHR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2733,7 +2783,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::LSHR); } static long LSHL_unary(long a, long b) { @@ -2741,7 +2791,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHLLongMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLLongVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2753,11 +2803,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, LongVectorMaxTests::LSHL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHLLongMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLLongVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2772,7 +2822,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVectorMaxTests::LSHL_unary); } static long LSHR_unary(long a, long b) { @@ -2780,7 +2830,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void LSHRLongMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRLongVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2792,11 +2842,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, LongVectorMaxTests::LSHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void LSHRLongMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRLongVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2811,7 +2861,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVectorMaxTests::LSHR_unary); } static long ASHR_unary(long a, long b) { @@ -2819,7 +2869,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ASHRLongMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRLongVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2831,11 +2881,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, LongVectorMaxTests::ASHR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ASHRLongMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRLongVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2850,7 +2900,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVectorMaxTests::ASHR_unary); } static long ROR(long a, long b) { @@ -2858,7 +2908,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void RORLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2871,11 +2921,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::ROR); + assertArraysEquals(r, a, b, LongVectorMaxTests::ROR); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2891,7 +2941,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::ROR); } static long ROL(long a, long b) { @@ -2899,7 +2949,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ROLLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2912,11 +2962,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::ROL); + assertArraysEquals(r, a, b, LongVectorMaxTests::ROL); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2932,7 +2982,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::ROL); } static long ROR_unary(long a, long b) { @@ -2940,7 +2990,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void RORLongMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORLongVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2952,11 +3002,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, LongVectorMaxTests::ROR_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void RORLongMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORLongVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -2971,7 +3021,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, LongVectorMaxTests::ROR_unary); } static long ROL_unary(long a, long b) { @@ -2979,7 +3029,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void ROLLongMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLLongVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -2991,11 +3041,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, LongVectorMaxTests::ROL_unary); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void ROLLongMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLLongVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3010,14 +3060,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, LongVectorMaxTests::ROL_unary); } static long LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT)); } @Test(dataProvider = "longUnaryOpProvider") - static void LSHRLongMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRLongVectorMaxTestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3028,11 +3078,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, LongMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, LongVectorMaxTests::LSHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRLongVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3046,7 +3096,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVectorMaxTests::LSHR_binary_const); } static long LSHL_binary_const(long a) { @@ -3054,7 +3104,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LSHLLongMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLLongVectorMaxTestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3065,11 +3115,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, LongMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, LongVectorMaxTests::LSHL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LSHLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLLongVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3083,7 +3133,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, LongVectorMaxTests::LSHL_binary_const); } static long ASHR_binary_const(long a) { @@ -3091,7 +3141,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ASHRLongMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRLongVectorMaxTestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3102,11 +3152,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, LongMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, LongVectorMaxTests::ASHR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ASHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRLongVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3120,7 +3170,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, LongVectorMaxTests::ASHR_binary_const); } static long ROR_binary_const(long a) { @@ -3128,7 +3178,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void RORLongMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void RORLongVectorMaxTestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3139,11 +3189,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, LongMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, LongVectorMaxTests::ROR_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void RORLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORLongVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3157,7 +3207,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, LongVectorMaxTests::ROR_binary_const); } static long ROL_binary_const(long a) { @@ -3165,7 +3215,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ROLLongMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ROLLongVectorMaxTestsScalarShiftConst(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3176,11 +3226,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, LongMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, LongVectorMaxTests::ROL_binary_const); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ROLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLLongVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3194,14 +3244,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, LongVectorMaxTests::ROL_binary_const); } static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MINLongMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINLongVectorMaxTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3212,13 +3262,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MIN); + assertArraysEquals(r, a, (long)10, LongVectorMaxTests::MIN); } static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void minLongMaxVectorTestsWithMemOp(IntFunction fa) { + static void minLongVectorMaxTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3229,13 +3279,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, LongMaxVectorTests::min); + assertArraysEquals(r, a, (long)10, LongVectorMaxTests::min); } static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINLongVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3248,13 +3298,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, LongMaxVectorTests::MIN); + assertArraysEquals(r, a, (long)10, mask, LongVectorMaxTests::MIN); } static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void MAXLongMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXLongVectorMaxTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3265,13 +3315,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MAX); + assertArraysEquals(r, a, (long)10, LongVectorMaxTests::MAX); } static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpProvider") - static void maxLongMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxLongVectorMaxTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3282,13 +3332,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, LongMaxVectorTests::max); + assertArraysEquals(r, a, (long)10, LongVectorMaxTests::max); } static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXLongVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3301,15 +3351,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (long)10, mask, LongMaxVectorTests::MAX); + assertArraysEquals(r, a, (long)10, mask, LongVectorMaxTests::MAX); } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3322,15 +3372,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::MIN); + assertArraysEquals(r, a, b, LongVectorMaxTests::MIN); } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void minLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3341,15 +3391,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::min); + assertArraysEquals(r, a, b, LongVectorMaxTests::min); } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3362,15 +3412,15 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::MAX); + assertArraysEquals(r, a, b, LongVectorMaxTests::MAX); } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3381,7 +3431,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, LongMaxVectorTests::max); + assertArraysEquals(r, a, b, LongVectorMaxTests::max); } static long UMIN(long a, long b) { @@ -3389,7 +3439,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMINLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMINLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3402,11 +3452,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, LongVectorMaxTests::UMIN); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMINLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3422,7 +3472,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::UMIN); } static long UMAX(long a, long b) { @@ -3430,7 +3480,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void UMAXLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMAXLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3443,11 +3493,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, LongVectorMaxTests::UMAX); } @Test(dataProvider = "longBinaryOpMaskProvider") - static void UMAXLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3463,7 +3513,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::UMAX); } static long SADD(long a, long b) { @@ -3471,7 +3521,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SADDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SADDLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3484,11 +3534,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::SADD); + assertArraysEquals(r, a, b, LongVectorMaxTests::SADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3504,7 +3554,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SADD); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::SADD); } static long SSUB(long a, long b) { @@ -3512,7 +3562,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SSUBLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SSUBLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3525,11 +3575,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, LongVectorMaxTests::SSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SSUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3545,7 +3595,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::SSUB); } static long SUADD(long a, long b) { @@ -3553,7 +3603,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUADDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUADDLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3566,11 +3616,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, LongVectorMaxTests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3586,7 +3636,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::SUADD); } static long SUSUB(long a, long b) { @@ -3594,7 +3644,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingBinaryOpProvider") - static void SUSUBLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3607,11 +3657,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, LongVectorMaxTests::SUSUB); } @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") - static void SUSUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3627,11 +3677,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::SUSUB); } @Test(dataProvider = "longBinaryOpProvider") - static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3641,11 +3691,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::MIN); } @Test(dataProvider = "longBinaryOpProvider") - static void minLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3655,11 +3705,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::min); } @Test(dataProvider = "longBinaryOpProvider") - static void MAXLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3669,11 +3719,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::MAX); } @Test(dataProvider = "longBinaryOpProvider") - static void maxLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -3683,10 +3733,10 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, LongVectorMaxTests::max); } @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") - static void SUADDAssocLongMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocLongVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -3703,11 +3753,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, LongMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, LongVectorMaxTests::SUADD); } @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -3728,13 +3778,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongVectorMaxTests::SUADD); } static long ANDReduce(long[] a, int idx) { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3743,14 +3793,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ANDReduceAll(long[] a) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ANDReduceLongMaxVectorTests(IntFunction fa) { + static void ANDReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3761,12 +3811,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::ANDReduce, LongMaxVectorTests::ANDReduceAll); + LongVectorMaxTests::ANDReduce, LongVectorMaxTests::ANDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3774,20 +3824,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = AND_IDENTITY; - assertEquals((long) (id & id), id, + assertEquals((long) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id & x), x); - assertEquals((long) (x & id), x); + assertEquals((long) (scalar_and(id, x)), x); + assertEquals((long) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id & x), x, + assertEquals((long) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x & id), x, + assertEquals((long) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3796,7 +3846,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3805,14 +3855,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ANDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3825,18 +3875,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::ANDReduceMasked, LongMaxVectorTests::ANDReduceAllMasked); + LongVectorMaxTests::ANDReduceMasked, LongVectorMaxTests::ANDReduceAllMasked); } static long ORReduce(long[] a, int idx) { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3845,14 +3895,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ORReduceAll(long[] a) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ORReduceLongMaxVectorTests(IntFunction fa) { + static void ORReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3863,12 +3913,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::ORReduce, LongMaxVectorTests::ORReduceAll); + LongVectorMaxTests::ORReduce, LongVectorMaxTests::ORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3876,20 +3926,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = OR_IDENTITY; - assertEquals((long) (id | id), id, + assertEquals((long) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id | x), x); - assertEquals((long) (x | id), x); + assertEquals((long) (scalar_or(id, x)), x); + assertEquals((long) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id | x), x, + assertEquals((long) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x | id), x, + assertEquals((long) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3898,7 +3948,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3907,14 +3957,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3927,18 +3977,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::ORReduceMasked, LongMaxVectorTests::ORReduceAllMasked); + LongVectorMaxTests::ORReduceMasked, LongVectorMaxTests::ORReduceAllMasked); } static long XORReduce(long[] a, int idx) { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3947,14 +3997,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long XORReduceAll(long[] a) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void XORReduceLongMaxVectorTests(IntFunction fa) { + static void XORReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -3965,12 +4015,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::XORReduce, LongMaxVectorTests::XORReduceAll); + LongVectorMaxTests::XORReduce, LongVectorMaxTests::XORReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -3978,20 +4028,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = XOR_IDENTITY; - assertEquals((long) (id ^ id), id, + assertEquals((long) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id ^ x), x); - assertEquals((long) (x ^ id), x); + assertEquals((long) (scalar_xor(id, x)), x); + assertEquals((long) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id ^ x), x, + assertEquals((long) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x ^ id), x, + assertEquals((long) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -4000,7 +4050,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -4009,14 +4059,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void XORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4029,18 +4079,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::XORReduceMasked, LongMaxVectorTests::XORReduceAllMasked); + LongVectorMaxTests::XORReduceMasked, LongVectorMaxTests::XORReduceAllMasked); } static long ADDReduce(long[] a, int idx) { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4049,14 +4099,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ADDReduceAll(long[] a) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongMaxVectorTests(IntFunction fa) { + static void ADDReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4067,12 +4117,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); + LongVectorMaxTests::ADDReduce, LongVectorMaxTests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4080,20 +4130,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = ADD_IDENTITY; - assertEquals((long) (id + id), id, + assertEquals((long) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id + x), x); - assertEquals((long) (x + id), x); + assertEquals((long) (scalar_add(id, x)), x); + assertEquals((long) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id + x), x, + assertEquals((long) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x + id), x, + assertEquals((long) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4102,7 +4152,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4111,14 +4161,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllMasked(long[] a, boolean[] mask) { long res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4131,18 +4181,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); + LongVectorMaxTests::ADDReduceMasked, LongVectorMaxTests::ADDReduceAllMasked); } static long MULReduce(long[] a, int idx) { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4151,14 +4201,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MULReduceAll(long[] a) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MULReduceLongMaxVectorTests(IntFunction fa) { + static void MULReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4169,12 +4219,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::MULReduce, LongMaxVectorTests::MULReduceAll); + LongVectorMaxTests::MULReduce, LongVectorMaxTests::MULReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4182,20 +4232,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MUL_IDENTITY; - assertEquals((long) (id * id), id, + assertEquals((long) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) (id * x), x); - assertEquals((long) (x * id), x); + assertEquals((long) (scalar_mul(id, x)), x); + assertEquals((long) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((long) (id * x), x, + assertEquals((long) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((long) (x * id), x, + assertEquals((long) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4204,7 +4254,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4213,14 +4263,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MULReduceAllMasked(long[] a, boolean[] mask) { long res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MULReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4233,18 +4283,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::MULReduceMasked, LongMaxVectorTests::MULReduceAllMasked); + LongVectorMaxTests::MULReduceMasked, LongVectorMaxTests::MULReduceAllMasked); } static long MINReduce(long[] a, int idx) { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4253,14 +4303,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MINReduceAll(long[] a) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MINReduceLongMaxVectorTests(IntFunction fa) { + static void MINReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4271,12 +4321,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::MINReduce, LongMaxVectorTests::MINReduceAll); + LongVectorMaxTests::MINReduce, LongVectorMaxTests::MINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4284,20 +4334,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MIN_IDENTITY; - assertEquals((long) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.min(id, x), x); - assertEquals((long) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4306,7 +4356,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4315,14 +4365,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MINReduceAllMasked(long[] a, boolean[] mask) { long res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4335,18 +4385,18 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (long) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::MINReduceMasked, LongMaxVectorTests::MINReduceAllMasked); + LongVectorMaxTests::MINReduceMasked, LongVectorMaxTests::MINReduceAllMasked); } static long MAXReduce(long[] a, int idx) { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4355,14 +4405,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MAXReduceAll(long[] a) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "longUnaryOpProvider") - static void MAXReduceLongMaxVectorTests(IntFunction fa) { + static void MAXReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4373,12 +4423,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::MAXReduce, LongMaxVectorTests::MAXReduceAll); + LongVectorMaxTests::MAXReduce, LongVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4386,20 +4436,20 @@ public class LongMaxVectorTests extends AbstractVectorTest { long[] a = fa.apply(SPECIES.length()); long id = MAX_IDENTITY; - assertEquals((long) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); long x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((long) Math.max(id, x), x); - assertEquals((long) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((long) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((long) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4408,7 +4458,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { long res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4417,14 +4467,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static long MAXReduceAllMasked(long[] a, boolean[] mask) { long res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "longUnaryOpMaskProvider") - static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4437,12 +4487,12 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector av = LongVector.fromArray(SPECIES, a, i); long v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (long) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked); + LongVectorMaxTests::MAXReduceMasked, LongVectorMaxTests::MAXReduceAllMasked); } static long UMINReduce(long[] a, int idx) { @@ -4464,7 +4514,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMINReduceLongMaxVectorTests(IntFunction fa) { + static void UMINReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4480,7 +4530,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::UMINReduce, LongMaxVectorTests::UMINReduceAll); + LongVectorMaxTests::UMINReduce, LongVectorMaxTests::UMINReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4526,7 +4576,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4544,7 +4594,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::UMINReduceMasked, LongMaxVectorTests::UMINReduceAllMasked); + LongVectorMaxTests::UMINReduceMasked, LongVectorMaxTests::UMINReduceAllMasked); } static long UMAXReduce(long[] a, int idx) { @@ -4566,7 +4616,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void UMAXReduceLongMaxVectorTests(IntFunction fa) { + static void UMAXReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4582,7 +4632,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::UMAXReduce, LongMaxVectorTests::UMAXReduceAll); + LongVectorMaxTests::UMAXReduce, LongVectorMaxTests::UMAXReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4628,7 +4678,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void UMAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4646,7 +4696,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::UMAXReduceMasked, LongMaxVectorTests::UMAXReduceAllMasked); + LongVectorMaxTests::UMAXReduceMasked, LongVectorMaxTests::UMAXReduceAllMasked); } static long FIRST_NONZEROReduce(long[] a, int idx) { @@ -4668,7 +4718,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4684,7 +4734,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::FIRST_NONZEROReduce, LongMaxVectorTests::FIRST_NONZEROReduceAll); + LongVectorMaxTests::FIRST_NONZEROReduce, LongVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "longUnaryOpProvider") @@ -4730,7 +4780,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void FIRST_NONZEROReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4748,7 +4798,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::FIRST_NONZEROReduceMasked, LongMaxVectorTests::FIRST_NONZEROReduceAllMasked); + LongVectorMaxTests::FIRST_NONZEROReduceMasked, LongVectorMaxTests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4761,7 +4811,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueLongMaxVectorTests(IntFunction fm) { + static void anyTrueLongVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4772,7 +4822,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, LongVectorMaxTests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4785,7 +4835,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueLongMaxVectorTests(IntFunction fm) { + static void allTrueLongVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4796,7 +4846,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, LongVectorMaxTests::allTrue); } static long SUADDReduce(long[] a, int idx) { @@ -4818,7 +4868,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSaturatingUnaryOpProvider") - static void SUADDReduceLongMaxVectorTests(IntFunction fa) { + static void SUADDReduceLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -4834,7 +4884,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::SUADDReduce, LongMaxVectorTests::SUADDReduceAll); + LongVectorMaxTests::SUADDReduce, LongVectorMaxTests::SUADDReduceAll); } @Test(dataProvider = "longSaturatingUnaryOpProvider") @@ -4879,7 +4929,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") - static void SUADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4897,11 +4947,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::SUADDReduceMasked, LongMaxVectorTests::SUADDReduceAllMasked); + LongVectorMaxTests::SUADDReduceMasked, LongVectorMaxTests::SUADDReduceAllMasked); } @Test(dataProvider = "longBinaryOpProvider") - static void withLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -4924,7 +4974,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_DEFAULTLongMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4941,7 +4991,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_DEFAULTMaskedLongMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4965,7 +5015,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpProvider") - static void IS_NEGATIVELongMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVELongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4982,7 +5032,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTestOpMaskProvider") - static void IS_NEGATIVEMaskedLongMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -5002,7 +5052,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5021,7 +5071,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5040,7 +5090,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5063,7 +5113,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5082,7 +5132,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5105,7 +5155,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void EQLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5124,7 +5174,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void eqLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5143,7 +5193,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5166,7 +5216,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void NELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NELongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5185,7 +5235,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void NELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NELongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5208,7 +5258,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LELongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5227,7 +5277,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void LELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LELongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5250,7 +5300,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void GELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GELongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5269,7 +5319,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void GELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GELongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5292,7 +5342,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULTLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5311,7 +5361,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5334,7 +5384,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5353,7 +5403,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5376,7 +5426,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ULELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULELongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5395,7 +5445,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void ULELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULELongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5418,7 +5468,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void UGELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGELongVectorMaxTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5437,7 +5487,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpMaskProvider") - static void UGELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGELongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5460,7 +5510,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void LTLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5470,13 +5520,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5490,14 +5540,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "longCompareOpProvider") - static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5507,13 +5557,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpMaskProvider") - static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5527,7 +5577,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5538,7 +5588,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void blendLongMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendLongVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5554,11 +5604,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, LongVectorMaxTests::blend); } @Test(dataProvider = "longUnaryOpShuffleProvider") - static void RearrangeLongMaxVectorTests(IntFunction fa, + static void RearrangeLongVectorMaxTests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5575,7 +5625,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpShuffleMaskProvider") - static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeLongVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -5593,7 +5643,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void compressLongMaxVectorTests(IntFunction fa, + static void compressLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5611,7 +5661,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpMaskProvider") - static void expandLongMaxVectorTests(IntFunction fa, + static void expandLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5629,7 +5679,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void getLongMaxVectorTests(IntFunction fa) { + static void getLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -5785,7 +5835,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BroadcastLongMaxVectorTests(IntFunction fa) { + static void BroadcastLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5799,7 +5849,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZeroLongMaxVectorTests(IntFunction fa) { + static void ZeroLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5824,7 +5874,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void sliceUnaryLongMaxVectorTests(IntFunction fa) { + static void sliceUnaryLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5835,7 +5885,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, LongVectorMaxTests::sliceUnary); } static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { @@ -5852,7 +5902,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void sliceBinaryLongMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryLongVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5865,7 +5915,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, LongVectorMaxTests::sliceBinary); } static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { @@ -5882,7 +5932,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void sliceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -5899,7 +5949,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, LongMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, LongVectorMaxTests::slice); } static long[] unsliceUnary(long[] a, int origin, int idx) { @@ -5916,7 +5966,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void unsliceUnaryLongMaxVectorTests(IntFunction fa) { + static void unsliceUnaryLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5927,7 +5977,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, LongVectorMaxTests::unsliceUnary); } static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { @@ -5953,7 +6003,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpProvider") - static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryLongVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -5967,7 +6017,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, LongVectorMaxTests::unsliceBinary); } static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { @@ -6007,7 +6057,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longBinaryOpMaskProvider") - static void unsliceLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6024,7 +6074,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, LongVectorMaxTests::unslice); } static long BITWISE_BLEND(long a, long b, long c) { @@ -6036,7 +6086,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLongMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6051,11 +6101,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLongMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6068,11 +6118,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, LongVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6090,11 +6140,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6105,11 +6155,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6120,11 +6170,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6135,11 +6185,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector bv = LongVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6150,11 +6200,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { LongVector cv = LongVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6169,11 +6219,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6188,11 +6238,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDLongVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6203,11 +6253,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "longTernaryOpProvider") - static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendLongVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.apply(SPECIES.length()); @@ -6218,11 +6268,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, LongVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "longTernaryOpMaskProvider") - static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDLongVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6236,19 +6286,19 @@ public class LongMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongVectorMaxTests::BITWISE_BLEND); } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void NEGLongMaxVectorTests(IntFunction fa) { + static void NEGLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6259,11 +6309,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::NEG); + assertArraysEquals(r, a, LongVectorMaxTests::NEG); } @Test(dataProvider = "longUnaryOpProvider") - static void negLongMaxVectorTests(IntFunction fa) { + static void negLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6274,11 +6324,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::neg); + assertArraysEquals(r, a, LongVectorMaxTests::neg); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NEGMaskedLongMaxVectorTests(IntFunction fa, + static void NEGMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6292,19 +6342,19 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, LongVectorMaxTests::NEG); } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") - static void ABSLongMaxVectorTests(IntFunction fa) { + static void ABSLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6315,11 +6365,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::ABS); + assertArraysEquals(r, a, LongVectorMaxTests::ABS); } @Test(dataProvider = "longUnaryOpProvider") - static void absLongMaxVectorTests(IntFunction fa) { + static void absLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6330,11 +6380,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::abs); + assertArraysEquals(r, a, LongVectorMaxTests::abs); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ABSMaskedLongMaxVectorTests(IntFunction fa, + static void ABSMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6348,7 +6398,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, LongVectorMaxTests::ABS); } static long NOT(long a) { @@ -6360,7 +6410,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void NOTLongMaxVectorTests(IntFunction fa) { + static void NOTLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6371,11 +6421,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::NOT); + assertArraysEquals(r, a, LongVectorMaxTests::NOT); } @Test(dataProvider = "longUnaryOpProvider") - static void notLongMaxVectorTests(IntFunction fa) { + static void notLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6386,11 +6436,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::not); + assertArraysEquals(r, a, LongVectorMaxTests::not); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void NOTMaskedLongMaxVectorTests(IntFunction fa, + static void NOTMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6404,7 +6454,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, LongVectorMaxTests::NOT); } static long ZOMO(long a) { @@ -6412,7 +6462,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void ZOMOLongMaxVectorTests(IntFunction fa) { + static void ZOMOLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6423,11 +6473,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::ZOMO); + assertArraysEquals(r, a, LongVectorMaxTests::ZOMO); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ZOMOMaskedLongMaxVectorTests(IntFunction fa, + static void ZOMOMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6441,7 +6491,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, LongVectorMaxTests::ZOMO); } static long BIT_COUNT(long a) { @@ -6449,7 +6499,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void BIT_COUNTLongMaxVectorTests(IntFunction fa) { + static void BIT_COUNTLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6460,11 +6510,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, LongVectorMaxTests::BIT_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void BIT_COUNTMaskedLongMaxVectorTests(IntFunction fa, + static void BIT_COUNTMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6478,7 +6528,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, LongVectorMaxTests::BIT_COUNT); } static long TRAILING_ZEROS_COUNT(long a) { @@ -6486,7 +6536,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void TRAILING_ZEROS_COUNTLongMaxVectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6497,11 +6547,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVectorMaxTests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6515,7 +6565,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVectorMaxTests::TRAILING_ZEROS_COUNT); } static long LEADING_ZEROS_COUNT(long a) { @@ -6523,7 +6573,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void LEADING_ZEROS_COUNTLongMaxVectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6534,11 +6584,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, LongVectorMaxTests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6552,7 +6602,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, LongVectorMaxTests::LEADING_ZEROS_COUNT); } static long REVERSE(long a) { @@ -6560,7 +6610,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSELongMaxVectorTests(IntFunction fa) { + static void REVERSELongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6571,11 +6621,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::REVERSE); + assertArraysEquals(r, a, LongVectorMaxTests::REVERSE); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSEMaskedLongMaxVectorTests(IntFunction fa, + static void REVERSEMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6589,7 +6639,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE); + assertArraysEquals(r, a, mask, LongVectorMaxTests::REVERSE); } static long REVERSE_BYTES(long a) { @@ -6597,7 +6647,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void REVERSE_BYTESLongMaxVectorTests(IntFunction fa) { + static void REVERSE_BYTESLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6608,11 +6658,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, LongVectorMaxTests::REVERSE_BYTES); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedLongMaxVectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedLongVectorMaxTests(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); @@ -6626,7 +6676,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, LongVectorMaxTests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6634,7 +6684,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6647,7 +6697,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::band); + assertArraysEquals(r, a, b, LongVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -6655,7 +6705,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6668,7 +6718,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::bor); + assertArraysEquals(r, a, b, LongVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6676,7 +6726,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6689,7 +6739,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::bxor); + assertArraysEquals(r, a, b, LongVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6697,7 +6747,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6710,7 +6760,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, LongVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6718,7 +6768,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6731,7 +6781,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, LongMaxVectorTests::beq); + assertArraysEquals(r, a, b, LongVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -6739,7 +6789,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotLongMaxVectorTests(IntFunction fa) { + static void masknotLongVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6750,7 +6800,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::unot); + assertArraysEquals(r, a, LongVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6767,7 +6817,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongLongMaxVectorTests(IntFunction fa) { + static void maskFromToLongLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6781,7 +6831,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longCompareOpProvider") - static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltLongVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6791,13 +6841,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "longCompareOpProvider") - static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqLongVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -6807,13 +6857,13 @@ public class LongMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "longtoIntUnaryOpProvider") - static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayLongVectorMaxTestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6824,7 +6874,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayLongVectorMaxTestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6835,7 +6885,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayLongVectorMaxTestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6846,7 +6896,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void toStringLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringLongVectorMaxTestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6859,7 +6909,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpProvider") - static void hashCodeLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeLongVectorMaxTestsSmokeTest(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6875,7 +6925,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { @Test(dataProvider = "longUnaryOpProvider") - static void ADDReduceLongLongMaxVectorTests(IntFunction fa) { + static void ADDReduceLongLongVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0; @@ -6891,11 +6941,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); + LongVectorMaxTests::ADDReduce, LongVectorMaxTests::ADDReduceAll); } @Test(dataProvider = "longUnaryOpMaskProvider") - static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongLongVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6913,11 +6963,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); + LongVectorMaxTests::ADDReduceMasked, LongVectorMaxTests::ADDReduceAllMasked); } @Test(dataProvider = "longUnaryOpSelectFromProvider") - static void SelectFromLongMaxVectorTests(IntFunction fa, + static void SelectFromLongVectorMaxTests(IntFunction fa, BiFunction fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, SPECIES.length()); @@ -6933,7 +6983,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorLongMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorLongVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] idx = fc.apply(SPECIES.length()); @@ -6951,7 +7001,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") - static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromLongVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -6970,7 +7020,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousLongVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6986,7 +7036,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringLongMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringLongVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7000,7 +7050,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsLongMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsLongVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7014,7 +7064,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsLongVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7030,7 +7080,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeLongVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7052,7 +7102,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountLongVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7063,7 +7113,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, LongVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7077,7 +7127,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueLongVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7088,7 +7138,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, LongVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7102,7 +7152,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueLongVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7113,11 +7163,11 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, LongVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressLongMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressLongVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7145,7 +7195,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7159,7 +7209,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongLongMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongLongVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7186,14 +7236,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundLongMaxVectorTestsSmokeTest(int length) { + static void loopBoundLongVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongLongMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongLongVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7201,21 +7251,21 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementSizeLongMaxVectorTestsSmokeTest() { + static void ElementSizeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Long.SIZE); } @Test - static void VectorShapeLongMaxVectorTestsSmokeTest() { + static void VectorShapeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesLongMaxVectorTestsSmokeTest() { + static void ShapeWithLanesLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(long.class); @@ -7223,32 +7273,32 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementTypeLongMaxVectorTestsSmokeTest() { + static void ElementTypeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementType() == long.class); } @Test - static void SpeciesElementSizeLongMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().elementSize() == Long.SIZE); } @Test - static void VectorTypeLongMaxVectorTestsSmokeTest() { + static void VectorTypeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesLongMaxVectorTestsSmokeTest() { + static void WithLanesLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeLongMaxVectorTestsSmokeTest() { + static void WithShapeLongVectorMaxTestsSmokeTest() { LongVector av = LongVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7256,7 +7306,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueLongMaxVectorTestsSmokeTest() { + static void MaskAllTrueLongVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortVector128LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ShortVector128LoadStoreTests.java index 18974b65164..2c9a9198be9 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector128LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Short128VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ShortVector128LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Short128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ShortVector128LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_128; diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/ShortVector128Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Short128VectorTests.java rename to test/jdk/jdk/incubator/vector/ShortVector128Tests.java index 50dc1931663..85e7d715182 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector128Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortVector128Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Short128VectorTests extends AbstractVectorTest { +public class ShortVector128Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_128; @@ -1565,6 +1565,59 @@ public class Short128VectorTests extends AbstractVectorTest { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1581,9 +1634,6 @@ public class Short128VectorTests extends AbstractVectorTest { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1692,11 +1742,11 @@ public class Short128VectorTests extends AbstractVectorTest { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ADDShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1709,15 +1759,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::ADD); + assertArraysEquals(r, a, b, ShortVector128Tests::ADD); } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort128VectorTests(IntFunction fa, IntFunction fb) { + static void addShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1728,11 +1778,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::add); + assertArraysEquals(r, a, b, ShortVector128Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1748,11 +1798,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1766,15 +1816,15 @@ public class Short128VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short128VectorTests::add); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::add); } static short SUB(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void SUBShort128VectorTests(IntFunction fa, IntFunction fb) { + static void SUBShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1787,15 +1837,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::SUB); + assertArraysEquals(r, a, b, ShortVector128Tests::SUB); } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort128VectorTests(IntFunction fa, IntFunction fb) { + static void subShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1806,11 +1856,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::sub); + assertArraysEquals(r, a, b, ShortVector128Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void SUBShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1826,11 +1876,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::SUB); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1844,15 +1894,15 @@ public class Short128VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short128VectorTests::sub); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::sub); } static short MUL(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MULShort128VectorTests(IntFunction fa, IntFunction fb) { + static void MULShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1865,15 +1915,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::MUL); + assertArraysEquals(r, a, b, ShortVector128Tests::MUL); } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort128VectorTests(IntFunction fa, IntFunction fb) { + static void mulShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1884,11 +1934,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::mul); + assertArraysEquals(r, a, b, ShortVector128Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MULShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1904,11 +1954,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::MUL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1922,7 +1972,7 @@ public class Short128VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short128VectorTests::mul); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::mul); } static short DIV(short a, short b) { @@ -1930,7 +1980,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void DIVShort128VectorTests(IntFunction fa, IntFunction fb) { + static void DIVShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1945,7 +1995,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::DIV); + assertArraysEquals(r, a, b, ShortVector128Tests::DIV); } static short div(short a, short b) { @@ -1953,7 +2003,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort128VectorTests(IntFunction fa, IntFunction fb) { + static void divShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1968,11 +2018,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::div); + assertArraysEquals(r, a, b, ShortVector128Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void DIVShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1990,11 +2040,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::DIV); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2012,15 +2062,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::div); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::div); } static short FIRST_NONZERO(short a, short b) { - return (short)((a)!=0?a:b); + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void FIRST_NONZEROShort128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2033,11 +2083,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortVector128Tests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void FIRST_NONZEROShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2053,7 +2103,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -2061,7 +2111,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ANDShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2074,7 +2124,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::AND); + assertArraysEquals(r, a, b, ShortVector128Tests::AND); } static short and(short a, short b) { @@ -2082,7 +2132,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort128VectorTests(IntFunction fa, IntFunction fb) { + static void andShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2093,11 +2143,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::and); + assertArraysEquals(r, a, b, ShortVector128Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2113,7 +2163,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::AND); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::AND); } static short AND_NOT(short a, short b) { @@ -2121,7 +2171,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void AND_NOTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2134,11 +2184,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ShortVector128Tests::AND_NOT); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void AND_NOTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2154,7 +2204,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::AND_NOT); } static short OR(short a, short b) { @@ -2162,7 +2212,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ORShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2175,7 +2225,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::OR); + assertArraysEquals(r, a, b, ShortVector128Tests::OR); } static short or(short a, short b) { @@ -2183,7 +2233,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort128VectorTests(IntFunction fa, IntFunction fb) { + static void orShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2194,11 +2244,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::or); + assertArraysEquals(r, a, b, ShortVector128Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2214,7 +2264,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::OR); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::OR); } static short XOR(short a, short b) { @@ -2222,7 +2272,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void XORShort128VectorTests(IntFunction fa, IntFunction fb) { + static void XORShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2235,11 +2285,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::XOR); + assertArraysEquals(r, a, b, ShortVector128Tests::XOR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void XORShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2255,11 +2305,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::XOR); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2269,11 +2319,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2286,11 +2336,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::add); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2300,11 +2350,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2317,11 +2367,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::sub); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2331,11 +2381,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2348,11 +2398,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::mul); } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2364,11 +2414,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2383,11 +2433,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::div); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2397,11 +2447,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2411,11 +2461,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2428,11 +2478,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2442,11 +2492,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2456,11 +2506,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2473,11 +2523,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector128Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2487,11 +2537,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortVector128Tests::OR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2504,11 +2554,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector128Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDShortVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2518,11 +2568,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortVector128Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDShortVector128TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2535,7 +2585,7 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector128Tests::ADD); } static short LSHL(short a, short b) { @@ -2543,7 +2593,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::LSHL); + assertArraysEquals(r, a, b, ShortVector128Tests::LSHL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2576,7 +2626,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::LSHL); } static short ASHR(short a, short b) { @@ -2584,7 +2634,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2597,11 +2647,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::ASHR); + assertArraysEquals(r, a, b, ShortVector128Tests::ASHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2617,7 +2667,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::ASHR); } static short LSHR(short a, short b) { @@ -2625,7 +2675,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort128VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2638,11 +2688,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::LSHR); + assertArraysEquals(r, a, b, ShortVector128Tests::LSHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2658,7 +2708,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::LSHR); } static short LSHL_unary(short a, short b) { @@ -2666,7 +2716,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLShortVector128TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2678,11 +2728,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ShortVector128Tests::LSHL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2697,7 +2747,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector128Tests::LSHL_unary); } static short LSHR_unary(short a, short b) { @@ -2705,7 +2755,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRShortVector128TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2717,11 +2767,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector128Tests::LSHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2736,7 +2786,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector128Tests::LSHR_unary); } static short ASHR_unary(short a, short b) { @@ -2744,7 +2794,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRShortVector128TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2756,11 +2806,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector128Tests::ASHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2775,7 +2825,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector128Tests::ASHR_unary); } static short ROR(short a, short b) { @@ -2783,7 +2833,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort128VectorTests(IntFunction fa, IntFunction fb) { + static void RORShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2796,11 +2846,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::ROR); + assertArraysEquals(r, a, b, ShortVector128Tests::ROR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2816,7 +2866,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::ROR); } static short ROL(short a, short b) { @@ -2824,7 +2874,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ROLShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2837,11 +2887,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::ROL); + assertArraysEquals(r, a, b, ShortVector128Tests::ROL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2857,7 +2907,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::ROL); } static short ROR_unary(short a, short b) { @@ -2865,7 +2915,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORShortVector128TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2877,11 +2927,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ShortVector128Tests::ROR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORShortVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2896,7 +2946,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector128Tests::ROR_unary); } static short ROL_unary(short a, short b) { @@ -2904,7 +2954,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort128VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLShortVector128TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2916,11 +2966,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ShortVector128Tests::ROL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort128VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector128TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2935,14 +2985,14 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector128Tests::ROL_unary); } static short LSHR_binary_const(short a) { return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHRShort128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRShortVector128TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2953,11 +3003,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ShortVector128Tests::LSHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHRShort128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRShortVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2971,7 +3021,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector128Tests::LSHR_binary_const); } static short LSHL_binary_const(short a) { @@ -2979,7 +3029,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHLShort128VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLShortVector128TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2990,11 +3040,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ShortVector128Tests::LSHL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHLShort128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLShortVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3008,7 +3058,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector128Tests::LSHL_binary_const); } static short ASHR_binary_const(short a) { @@ -3016,7 +3066,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ASHRShort128VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRShortVector128TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3027,11 +3077,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ShortVector128Tests::ASHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ASHRShort128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRShortVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3045,7 +3095,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short128VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector128Tests::ASHR_binary_const); } static short ROR_binary_const(short a) { @@ -3053,7 +3103,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void RORShort128VectorTestsScalarShiftConst(IntFunction fa) { + static void RORShortVector128TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3064,11 +3114,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ShortVector128Tests::ROR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void RORShort128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORShortVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3082,7 +3132,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short128VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector128Tests::ROR_binary_const); } static short ROL_binary_const(short a) { @@ -3090,7 +3140,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ROLShort128VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLShortVector128TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3101,11 +3151,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ShortVector128Tests::ROL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ROLShort128VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLShortVector128TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3119,14 +3169,14 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short128VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector128Tests::ROL_binary_const); } static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MINShort128VectorTestsWithMemOp(IntFunction fa) { + static void MINShortVector128TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3137,13 +3187,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short128VectorTests::MIN); + assertArraysEquals(r, a, (short)10, ShortVector128Tests::MIN); } static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void minShort128VectorTestsWithMemOp(IntFunction fa) { + static void minShortVector128TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3154,13 +3204,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short128VectorTests::min); + assertArraysEquals(r, a, (short)10, ShortVector128Tests::min); } static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINShortVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3173,13 +3223,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short128VectorTests::MIN); + assertArraysEquals(r, a, (short)10, mask, ShortVector128Tests::MIN); } static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MAXShort128VectorTestsWithMemOp(IntFunction fa) { + static void MAXShortVector128TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short128VectorTests::MAX); + assertArraysEquals(r, a, (short)10, ShortVector128Tests::MAX); } static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void maxShort128VectorTestsWithMemOp(IntFunction fa) { + static void maxShortVector128TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short128VectorTests::max); + assertArraysEquals(r, a, (short)10, ShortVector128Tests::max); } static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXShortVector128TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,15 +3276,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short128VectorTests::MAX); + assertArraysEquals(r, a, (short)10, mask, ShortVector128Tests::MAX); } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort128VectorTests(IntFunction fa, IntFunction fb) { + static void MINShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3247,15 +3297,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::MIN); + assertArraysEquals(r, a, b, ShortVector128Tests::MIN); } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort128VectorTests(IntFunction fa, IntFunction fb) { + static void minShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3266,15 +3316,15 @@ public class Short128VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::min); + assertArraysEquals(r, a, b, ShortVector128Tests::min); } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort128VectorTests(IntFunction fa, IntFunction fb) { + static void MAXShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3287,15 +3337,15 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::MAX); + assertArraysEquals(r, a, b, ShortVector128Tests::MAX); } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maxShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3306,7 +3356,7 @@ public class Short128VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short128VectorTests::max); + assertArraysEquals(r, a, b, ShortVector128Tests::max); } static short UMIN(short a, short b) { @@ -3314,7 +3364,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMINShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UMINShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3327,11 +3377,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::UMIN); + assertArraysEquals(r, a, b, ShortVector128Tests::UMIN); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMINShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3347,7 +3397,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::UMIN); } static short UMAX(short a, short b) { @@ -3355,7 +3405,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMAXShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3368,11 +3418,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::UMAX); + assertArraysEquals(r, a, b, ShortVector128Tests::UMAX); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMAXShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3388,7 +3438,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::UMAX); } static short SADD(short a, short b) { @@ -3396,7 +3446,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SADDShort128VectorTests(IntFunction fa, IntFunction fb) { + static void SADDShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3409,11 +3459,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::SADD); + assertArraysEquals(r, a, b, ShortVector128Tests::SADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SADDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3429,7 +3479,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::SADD); } static short SSUB(short a, short b) { @@ -3437,7 +3487,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SSUBShort128VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3450,11 +3500,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::SSUB); + assertArraysEquals(r, a, b, ShortVector128Tests::SSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SSUBShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3470,7 +3520,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::SSUB); } static short SUADD(short a, short b) { @@ -3478,7 +3528,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUADDShort128VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3491,11 +3541,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::SUADD); + assertArraysEquals(r, a, b, ShortVector128Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUADDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3511,7 +3561,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::SUADD); } static short SUSUB(short a, short b) { @@ -3519,7 +3569,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUSUBShort128VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3532,11 +3582,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::SUSUB); + assertArraysEquals(r, a, b, ShortVector128Tests::SUSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUSUBShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3552,11 +3602,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::SUSUB); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3566,11 +3616,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3580,11 +3630,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::min); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3594,11 +3644,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3608,10 +3658,10 @@ public class Short128VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short128VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortVector128Tests::max); } @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider") - static void SUADDAssocShort128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocShortVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -3628,11 +3678,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Short128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ShortVector128Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3653,13 +3703,13 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Short128VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortVector128Tests::SUADD); } static short ANDReduce(short[] a, int idx) { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3668,14 +3718,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ANDReduceAll(short[] a) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ANDReduceShort128VectorTests(IntFunction fa) { + static void ANDReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3686,12 +3736,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::ANDReduce, Short128VectorTests::ANDReduceAll); + ShortVector128Tests::ANDReduce, ShortVector128Tests::ANDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3699,20 +3749,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = AND_IDENTITY; - assertEquals((short) (id & id), id, + assertEquals((short) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id & x), x); - assertEquals((short) (x & id), x); + assertEquals((short) (scalar_and(id, x)), x); + assertEquals((short) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id & x), x, + assertEquals((short) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x & id), x, + assertEquals((short) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3721,7 +3771,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3730,14 +3780,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ANDReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3750,18 +3800,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::ANDReduceMasked, Short128VectorTests::ANDReduceAllMasked); + ShortVector128Tests::ANDReduceMasked, ShortVector128Tests::ANDReduceAllMasked); } static short ORReduce(short[] a, int idx) { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3770,14 +3820,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ORReduceAll(short[] a) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ORReduceShort128VectorTests(IntFunction fa) { + static void ORReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3788,12 +3838,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::ORReduce, Short128VectorTests::ORReduceAll); + ShortVector128Tests::ORReduce, ShortVector128Tests::ORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3801,20 +3851,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = OR_IDENTITY; - assertEquals((short) (id | id), id, + assertEquals((short) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id | x), x); - assertEquals((short) (x | id), x); + assertEquals((short) (scalar_or(id, x)), x); + assertEquals((short) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id | x), x, + assertEquals((short) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x | id), x, + assertEquals((short) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3823,7 +3873,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3832,14 +3882,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ORReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3852,18 +3902,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::ORReduceMasked, Short128VectorTests::ORReduceAllMasked); + ShortVector128Tests::ORReduceMasked, ShortVector128Tests::ORReduceAllMasked); } static short XORReduce(short[] a, int idx) { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3872,14 +3922,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short XORReduceAll(short[] a) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void XORReduceShort128VectorTests(IntFunction fa) { + static void XORReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3890,12 +3940,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::XORReduce, Short128VectorTests::XORReduceAll); + ShortVector128Tests::XORReduce, ShortVector128Tests::XORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3903,20 +3953,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = XOR_IDENTITY; - assertEquals((short) (id ^ id), id, + assertEquals((short) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id ^ x), x); - assertEquals((short) (x ^ id), x); + assertEquals((short) (scalar_xor(id, x)), x); + assertEquals((short) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id ^ x), x, + assertEquals((short) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x ^ id), x, + assertEquals((short) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3925,7 +3975,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3934,14 +3984,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void XORReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3954,18 +4004,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::XORReduceMasked, Short128VectorTests::XORReduceAllMasked); + ShortVector128Tests::XORReduceMasked, ShortVector128Tests::XORReduceAllMasked); } static short ADDReduce(short[] a, int idx) { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3974,14 +4024,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ADDReduceAll(short[] a) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceShort128VectorTests(IntFunction fa) { + static void ADDReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3992,12 +4042,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::ADDReduce, Short128VectorTests::ADDReduceAll); + ShortVector128Tests::ADDReduce, ShortVector128Tests::ADDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4005,20 +4055,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = ADD_IDENTITY; - assertEquals((short) (id + id), id, + assertEquals((short) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id + x), x); - assertEquals((short) (x + id), x); + assertEquals((short) (scalar_add(id, x)), x); + assertEquals((short) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id + x), x, + assertEquals((short) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x + id), x, + assertEquals((short) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4027,7 +4077,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4036,14 +4086,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short ADDReduceAllMasked(short[] a, boolean[] mask) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4056,18 +4106,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::ADDReduceMasked, Short128VectorTests::ADDReduceAllMasked); + ShortVector128Tests::ADDReduceMasked, ShortVector128Tests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4076,14 +4126,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MULReduceAll(short[] a) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MULReduceShort128VectorTests(IntFunction fa) { + static void MULReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4094,12 +4144,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::MULReduce, Short128VectorTests::MULReduceAll); + ShortVector128Tests::MULReduce, ShortVector128Tests::MULReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4107,20 +4157,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MUL_IDENTITY; - assertEquals((short) (id * id), id, + assertEquals((short) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id * x), x); - assertEquals((short) (x * id), x); + assertEquals((short) (scalar_mul(id, x)), x); + assertEquals((short) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id * x), x, + assertEquals((short) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x * id), x, + assertEquals((short) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4129,7 +4179,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4138,14 +4188,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MULReduceAllMasked(short[] a, boolean[] mask) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MULReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4158,18 +4208,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::MULReduceMasked, Short128VectorTests::MULReduceAllMasked); + ShortVector128Tests::MULReduceMasked, ShortVector128Tests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4178,14 +4228,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MINReduceAll(short[] a) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MINReduceShort128VectorTests(IntFunction fa) { + static void MINReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4196,12 +4246,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::MINReduce, Short128VectorTests::MINReduceAll); + ShortVector128Tests::MINReduce, ShortVector128Tests::MINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4209,20 +4259,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MIN_IDENTITY; - assertEquals((short) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.min(id, x), x); - assertEquals((short) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4231,7 +4281,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4240,14 +4290,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MINReduceAllMasked(short[] a, boolean[] mask) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4260,18 +4310,18 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::MINReduceMasked, Short128VectorTests::MINReduceAllMasked); + ShortVector128Tests::MINReduceMasked, ShortVector128Tests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4280,14 +4330,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MAXReduceAll(short[] a) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MAXReduceShort128VectorTests(IntFunction fa) { + static void MAXReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4298,12 +4348,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::MAXReduce, Short128VectorTests::MAXReduceAll); + ShortVector128Tests::MAXReduce, ShortVector128Tests::MAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4311,20 +4361,20 @@ public class Short128VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MAX_IDENTITY; - assertEquals((short) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.max(id, x), x); - assertEquals((short) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4333,7 +4383,7 @@ public class Short128VectorTests extends AbstractVectorTest { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4342,14 +4392,14 @@ public class Short128VectorTests extends AbstractVectorTest { static short MAXReduceAllMasked(short[] a, boolean[] mask) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4362,12 +4412,12 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::MAXReduceMasked, Short128VectorTests::MAXReduceAllMasked); + ShortVector128Tests::MAXReduceMasked, ShortVector128Tests::MAXReduceAllMasked); } static short UMINReduce(short[] a, int idx) { @@ -4389,7 +4439,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMINReduceShort128VectorTests(IntFunction fa) { + static void UMINReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4405,7 +4455,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::UMINReduce, Short128VectorTests::UMINReduceAll); + ShortVector128Tests::UMINReduce, ShortVector128Tests::UMINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4451,7 +4501,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMINReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4469,7 +4519,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::UMINReduceMasked, Short128VectorTests::UMINReduceAllMasked); + ShortVector128Tests::UMINReduceMasked, ShortVector128Tests::UMINReduceAllMasked); } static short UMAXReduce(short[] a, int idx) { @@ -4491,7 +4541,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMAXReduceShort128VectorTests(IntFunction fa) { + static void UMAXReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4507,7 +4557,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::UMAXReduce, Short128VectorTests::UMAXReduceAll); + ShortVector128Tests::UMAXReduce, ShortVector128Tests::UMAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4553,7 +4603,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4571,7 +4621,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::UMAXReduceMasked, Short128VectorTests::UMAXReduceAllMasked); + ShortVector128Tests::UMAXReduceMasked, ShortVector128Tests::UMAXReduceAllMasked); } static short FIRST_NONZEROReduce(short[] a, int idx) { @@ -4593,7 +4643,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void FIRST_NONZEROReduceShort128VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4609,7 +4659,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::FIRST_NONZEROReduce, Short128VectorTests::FIRST_NONZEROReduceAll); + ShortVector128Tests::FIRST_NONZEROReduce, ShortVector128Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4655,7 +4705,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void FIRST_NONZEROReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4673,7 +4723,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::FIRST_NONZEROReduceMasked, Short128VectorTests::FIRST_NONZEROReduceAllMasked); + ShortVector128Tests::FIRST_NONZEROReduceMasked, ShortVector128Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4686,7 +4736,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueShort128VectorTests(IntFunction fm) { + static void anyTrueShortVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4697,7 +4747,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short128VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector128Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4710,7 +4760,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueShort128VectorTests(IntFunction fm) { + static void allTrueShortVector128Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4721,7 +4771,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short128VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector128Tests::allTrue); } static short SUADDReduce(short[] a, int idx) { @@ -4743,7 +4793,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingUnaryOpProvider") - static void SUADDReduceShort128VectorTests(IntFunction fa) { + static void SUADDReduceShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4759,7 +4809,7 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short128VectorTests::SUADDReduce, Short128VectorTests::SUADDReduceAll); + ShortVector128Tests::SUADDReduce, ShortVector128Tests::SUADDReduceAll); } @Test(dataProvider = "shortSaturatingUnaryOpProvider") @@ -4804,7 +4854,7 @@ public class Short128VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider") - static void SUADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4822,11 +4872,11 @@ public class Short128VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::SUADDReduceMasked, Short128VectorTests::SUADDReduceAllMasked); + ShortVector128Tests::SUADDReduceMasked, ShortVector128Tests::SUADDReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void withShort128VectorTests(IntFunction fa, IntFunction fb) { + static void withShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -4849,7 +4899,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_DEFAULTShort128VectorTests(IntFunction fa) { + static void IS_DEFAULTShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4866,7 +4916,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_DEFAULTMaskedShort128VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4890,7 +4940,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_NEGATIVEShort128VectorTests(IntFunction fa) { + static void IS_NEGATIVEShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4907,7 +4957,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_NEGATIVEMaskedShort128VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4927,7 +4977,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void LTShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4946,7 +4996,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ltShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4965,7 +5015,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4988,7 +5038,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void GTShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5007,7 +5057,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5030,7 +5080,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort128VectorTests(IntFunction fa, IntFunction fb) { + static void EQShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5049,7 +5099,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort128VectorTests(IntFunction fa, IntFunction fb) { + static void eqShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5068,7 +5118,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5091,7 +5141,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void NEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void NEShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5110,7 +5160,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void NEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5133,7 +5183,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void LEShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5152,7 +5202,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5175,7 +5225,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void GEShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5194,7 +5244,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5217,7 +5267,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ULTShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5236,7 +5286,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5259,7 +5309,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5278,7 +5328,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5301,7 +5351,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5320,7 +5370,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5343,7 +5393,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortVector128Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5362,7 +5412,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5385,7 +5435,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5395,13 +5445,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5415,13 +5465,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5431,13 +5481,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTShortVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5451,13 +5501,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (short)((long)b[i])))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5467,13 +5517,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5487,13 +5537,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5503,13 +5553,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQShortVector128TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5523,7 +5573,7 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (short)((long)b[i])))); } } } @@ -5533,7 +5583,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort128VectorTests(IntFunction fa, IntFunction fb, + static void blendShortVector128Tests(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5549,11 +5599,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short128VectorTests::blend); + assertArraysEquals(r, a, b, mask, ShortVector128Tests::blend); } @Test(dataProvider = "shortUnaryOpShuffleProvider") - static void RearrangeShort128VectorTests(IntFunction fa, + static void RearrangeShortVector128Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5570,7 +5620,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") - static void RearrangeShort128VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeShortVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -5588,7 +5638,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void compressShort128VectorTests(IntFunction fa, + static void compressShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5606,7 +5656,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void expandShort128VectorTests(IntFunction fa, + static void expandShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5624,7 +5674,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void getShort128VectorTests(IntFunction fa) { + static void getShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5780,7 +5830,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastShort128VectorTests(IntFunction fa) { + static void BroadcastShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5794,7 +5844,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZeroShort128VectorTests(IntFunction fa) { + static void ZeroShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5819,7 +5869,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void sliceUnaryShort128VectorTests(IntFunction fa) { + static void sliceUnaryShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5830,7 +5880,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short128VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortVector128Tests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { @@ -5847,7 +5897,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void sliceBinaryShort128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryShortVector128TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5860,7 +5910,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Short128VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortVector128Tests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { @@ -5877,7 +5927,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void sliceShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5894,7 +5944,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Short128VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortVector128Tests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { @@ -5911,7 +5961,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void unsliceUnaryShort128VectorTests(IntFunction fa) { + static void unsliceUnaryShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5922,7 +5972,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short128VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortVector128Tests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { @@ -5948,7 +5998,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void unsliceBinaryShort128VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryShortVector128TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5962,7 +6012,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Short128VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortVector128Tests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { @@ -6002,7 +6052,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void unsliceShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6019,7 +6069,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Short128VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortVector128Tests::unslice); } static short BITWISE_BLEND(short a, short b, short c) { @@ -6031,7 +6081,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6046,11 +6096,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6063,11 +6113,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortVector128Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector128TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6085,11 +6135,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6100,11 +6150,11 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6115,11 +6165,11 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6130,11 +6180,11 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector128TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6145,11 +6195,11 @@ public class Short128VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6164,11 +6214,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector128TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector128TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6213,11 +6263,11 @@ public class Short128VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector128Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector128TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6231,19 +6281,19 @@ public class Short128VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortVector128Tests::BITWISE_BLEND); } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void NEGShort128VectorTests(IntFunction fa) { + static void NEGShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6254,11 +6304,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::NEG); + assertArraysEquals(r, a, ShortVector128Tests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") - static void negShort128VectorTests(IntFunction fa) { + static void negShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6269,11 +6319,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::neg); + assertArraysEquals(r, a, ShortVector128Tests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedShort128VectorTests(IntFunction fa, + static void NEGMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6287,19 +6337,19 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::NEG); + assertArraysEquals(r, a, mask, ShortVector128Tests::NEG); } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void ABSShort128VectorTests(IntFunction fa) { + static void ABSShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6310,11 +6360,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::ABS); + assertArraysEquals(r, a, ShortVector128Tests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") - static void absShort128VectorTests(IntFunction fa) { + static void absShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6325,11 +6375,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::abs); + assertArraysEquals(r, a, ShortVector128Tests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedShort128VectorTests(IntFunction fa, + static void ABSMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6343,7 +6393,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::ABS); + assertArraysEquals(r, a, mask, ShortVector128Tests::ABS); } static short NOT(short a) { @@ -6355,7 +6405,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void NOTShort128VectorTests(IntFunction fa) { + static void NOTShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6366,11 +6416,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::NOT); + assertArraysEquals(r, a, ShortVector128Tests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") - static void notShort128VectorTests(IntFunction fa) { + static void notShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6381,11 +6431,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::not); + assertArraysEquals(r, a, ShortVector128Tests::not); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NOTMaskedShort128VectorTests(IntFunction fa, + static void NOTMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6399,7 +6449,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::NOT); + assertArraysEquals(r, a, mask, ShortVector128Tests::NOT); } static short ZOMO(short a) { @@ -6407,7 +6457,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZOMOShort128VectorTests(IntFunction fa) { + static void ZOMOShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6418,11 +6468,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::ZOMO); + assertArraysEquals(r, a, ShortVector128Tests::ZOMO); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ZOMOMaskedShort128VectorTests(IntFunction fa, + static void ZOMOMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6436,7 +6486,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortVector128Tests::ZOMO); } static short BIT_COUNT(short a) { @@ -6444,7 +6494,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BIT_COUNTShort128VectorTests(IntFunction fa) { + static void BIT_COUNTShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6455,11 +6505,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ShortVector128Tests::BIT_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void BIT_COUNTMaskedShort128VectorTests(IntFunction fa, + static void BIT_COUNTMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6473,7 +6523,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ShortVector128Tests::BIT_COUNT); } static short TRAILING_ZEROS_COUNT(short a) { @@ -6481,7 +6531,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void TRAILING_ZEROS_COUNTShort128VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6492,11 +6542,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector128Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedShort128VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6510,7 +6560,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector128Tests::TRAILING_ZEROS_COUNT); } static short LEADING_ZEROS_COUNT(short a) { @@ -6518,7 +6568,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LEADING_ZEROS_COUNTShort128VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6529,11 +6579,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector128Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedShort128VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6547,7 +6597,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector128Tests::LEADING_ZEROS_COUNT); } static short REVERSE(short a) { @@ -6555,7 +6605,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSEShort128VectorTests(IntFunction fa) { + static void REVERSEShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6566,11 +6616,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::REVERSE); + assertArraysEquals(r, a, ShortVector128Tests::REVERSE); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSEMaskedShort128VectorTests(IntFunction fa, + static void REVERSEMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6584,7 +6634,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ShortVector128Tests::REVERSE); } static short REVERSE_BYTES(short a) { @@ -6592,7 +6642,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSE_BYTESShort128VectorTests(IntFunction fa) { + static void REVERSE_BYTESShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6603,11 +6653,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ShortVector128Tests::REVERSE_BYTES); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedShort128VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedShortVector128Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6621,7 +6671,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short128VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ShortVector128Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6629,7 +6679,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6642,7 +6692,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::band); + assertArraysEquals(r, a, b, ShortVector128Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6650,7 +6700,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskorShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6663,7 +6713,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::bor); + assertArraysEquals(r, a, b, ShortVector128Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6671,7 +6721,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6684,7 +6734,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::bxor); + assertArraysEquals(r, a, b, ShortVector128Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6692,7 +6742,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6705,7 +6755,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::bandNot); + assertArraysEquals(r, a, b, ShortVector128Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6713,7 +6763,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6726,7 +6776,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short128VectorTests::beq); + assertArraysEquals(r, a, b, ShortVector128Tests::beq); } static boolean unot(boolean a) { @@ -6734,7 +6784,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotShort128VectorTests(IntFunction fa) { + static void masknotShortVector128Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6745,7 +6795,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::unot); + assertArraysEquals(r, a, ShortVector128Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6762,7 +6812,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongShort128VectorTests(IntFunction fa) { + static void maskFromToLongShortVector128Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6776,7 +6826,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltShortVector128TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6786,13 +6836,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqShortVector128TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6802,13 +6852,13 @@ public class Short128VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortUnaryOpProvider") - static void toIntArrayShort128VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6819,7 +6869,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toLongArrayShort128VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6830,7 +6880,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toDoubleArrayShort128VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6841,7 +6891,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toStringShort128VectorTestsSmokeTest(IntFunction fa) { + static void toStringShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6854,7 +6904,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void hashCodeShort128VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6871,7 +6921,7 @@ public class Short128VectorTests extends AbstractVectorTest { static long ADDReduceLong(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6880,14 +6930,14 @@ public class Short128VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(short[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((short)res, (short)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceLongShort128VectorTests(IntFunction fa) { + static void ADDReduceLongShortVector128Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6898,19 +6948,20 @@ public class Short128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Short128VectorTests::ADDReduceLong, Short128VectorTests::ADDReduceAllLong); + ShortVector128Tests::ADDReduceLong, ShortVector128Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6919,14 +6970,14 @@ public class Short128VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((short)res, (short)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceLongShort128VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongShortVector128TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6939,16 +6990,16 @@ public class Short128VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Short128VectorTests::ADDReduceLongMasked, Short128VectorTests::ADDReduceAllLongMasked); + ShortVector128Tests::ADDReduceLongMasked, ShortVector128Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastLongShort128VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongShortVector128TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -6959,7 +7010,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendShortVector128TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6973,12 +7024,12 @@ public class Short128VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector128Tests::blend); } @Test(dataProvider = "shortUnaryOpSelectFromProvider") - static void SelectFromShort128VectorTests(IntFunction fa, + static void SelectFromShortVector128Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); short[] order = fs.apply(a.length, SPECIES.length()); @@ -6994,7 +7045,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorShort128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorShortVector128Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] idx = fc.apply(SPECIES.length()); @@ -7012,7 +7063,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") - static void SelectFromShort128VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromShortVector128TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -7031,7 +7082,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousShort128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousShortVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7047,7 +7098,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringShort128VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringShortVector128TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7061,7 +7112,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsShort128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsShortVector128TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7075,7 +7126,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsShort128VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsShortVector128Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7091,7 +7142,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeShort128VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeShortVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7113,7 +7164,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountShort128VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountShortVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7124,7 +7175,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short128VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ShortVector128Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7138,7 +7189,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueShort128VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueShortVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7149,7 +7200,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short128VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ShortVector128Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7163,7 +7214,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueShort128VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueShortVector128TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7174,11 +7225,11 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short128VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ShortVector128Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressShort128VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressShortVector128TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7206,7 +7257,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeShort128VectorTestsSmokeTest(int offset) { + static void indexInRangeShortVector128TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7220,7 +7271,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongShort128VectorTestsSmokeTest(int offset) { + static void indexInRangeLongShortVector128TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7247,14 +7298,14 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundShort128VectorTestsSmokeTest(int length) { + static void loopBoundShortVector128TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongShort128VectorTestsSmokeTest(int _length) { + static void loopBoundLongShortVector128TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7262,21 +7313,21 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeShort128VectorTestsSmokeTest() { + static void ElementSizeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Short.SIZE); } @Test - static void VectorShapeShort128VectorTestsSmokeTest() { + static void VectorShapeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_128_BIT)); } @Test - static void ShapeWithLanesShort128VectorTestsSmokeTest() { + static void ShapeWithLanesShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(short.class); @@ -7284,32 +7335,32 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeShort128VectorTestsSmokeTest() { + static void ElementTypeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementType() == short.class); } @Test - static void SpeciesElementSizeShort128VectorTestsSmokeTest() { + static void SpeciesElementSizeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementSize() == Short.SIZE); } @Test - static void VectorTypeShort128VectorTestsSmokeTest() { + static void VectorTypeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesShort128VectorTestsSmokeTest() { + static void WithLanesShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(short.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeShort128VectorTestsSmokeTest() { + static void WithShapeShortVector128TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7317,7 +7368,7 @@ public class Short128VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueShort128VectorTestsSmokeTest() { + static void MaskAllTrueShortVector128TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortVector256LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ShortVector256LoadStoreTests.java index a7f1d67659e..70ed351908f 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector256LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Short256VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ShortVector256LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Short256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ShortVector256LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_256; diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/ShortVector256Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Short256VectorTests.java rename to test/jdk/jdk/incubator/vector/ShortVector256Tests.java index b23014665af..df379b64e3a 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector256Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortVector256Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Short256VectorTests extends AbstractVectorTest { +public class ShortVector256Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_256; @@ -1565,6 +1565,59 @@ public class Short256VectorTests extends AbstractVectorTest { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1581,9 +1634,6 @@ public class Short256VectorTests extends AbstractVectorTest { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1692,11 +1742,11 @@ public class Short256VectorTests extends AbstractVectorTest { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ADDShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1709,15 +1759,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::ADD); + assertArraysEquals(r, a, b, ShortVector256Tests::ADD); } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort256VectorTests(IntFunction fa, IntFunction fb) { + static void addShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1728,11 +1778,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::add); + assertArraysEquals(r, a, b, ShortVector256Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1748,11 +1798,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1766,15 +1816,15 @@ public class Short256VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short256VectorTests::add); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::add); } static short SUB(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void SUBShort256VectorTests(IntFunction fa, IntFunction fb) { + static void SUBShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1787,15 +1837,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::SUB); + assertArraysEquals(r, a, b, ShortVector256Tests::SUB); } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort256VectorTests(IntFunction fa, IntFunction fb) { + static void subShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1806,11 +1856,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::sub); + assertArraysEquals(r, a, b, ShortVector256Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void SUBShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1826,11 +1876,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::SUB); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1844,15 +1894,15 @@ public class Short256VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short256VectorTests::sub); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::sub); } static short MUL(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MULShort256VectorTests(IntFunction fa, IntFunction fb) { + static void MULShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1865,15 +1915,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::MUL); + assertArraysEquals(r, a, b, ShortVector256Tests::MUL); } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort256VectorTests(IntFunction fa, IntFunction fb) { + static void mulShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1884,11 +1934,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::mul); + assertArraysEquals(r, a, b, ShortVector256Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MULShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1904,11 +1954,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::MUL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1922,7 +1972,7 @@ public class Short256VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short256VectorTests::mul); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::mul); } static short DIV(short a, short b) { @@ -1930,7 +1980,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void DIVShort256VectorTests(IntFunction fa, IntFunction fb) { + static void DIVShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1945,7 +1995,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::DIV); + assertArraysEquals(r, a, b, ShortVector256Tests::DIV); } static short div(short a, short b) { @@ -1953,7 +2003,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort256VectorTests(IntFunction fa, IntFunction fb) { + static void divShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1968,11 +2018,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::div); + assertArraysEquals(r, a, b, ShortVector256Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void DIVShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1990,11 +2040,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::DIV); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2012,15 +2062,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::div); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::div); } static short FIRST_NONZERO(short a, short b) { - return (short)((a)!=0?a:b); + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void FIRST_NONZEROShort256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2033,11 +2083,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortVector256Tests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void FIRST_NONZEROShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2053,7 +2103,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -2061,7 +2111,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ANDShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2074,7 +2124,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::AND); + assertArraysEquals(r, a, b, ShortVector256Tests::AND); } static short and(short a, short b) { @@ -2082,7 +2132,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort256VectorTests(IntFunction fa, IntFunction fb) { + static void andShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2093,11 +2143,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::and); + assertArraysEquals(r, a, b, ShortVector256Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2113,7 +2163,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::AND); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::AND); } static short AND_NOT(short a, short b) { @@ -2121,7 +2171,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void AND_NOTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2134,11 +2184,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ShortVector256Tests::AND_NOT); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void AND_NOTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2154,7 +2204,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::AND_NOT); } static short OR(short a, short b) { @@ -2162,7 +2212,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ORShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2175,7 +2225,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::OR); + assertArraysEquals(r, a, b, ShortVector256Tests::OR); } static short or(short a, short b) { @@ -2183,7 +2233,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort256VectorTests(IntFunction fa, IntFunction fb) { + static void orShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2194,11 +2244,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::or); + assertArraysEquals(r, a, b, ShortVector256Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2214,7 +2264,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::OR); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::OR); } static short XOR(short a, short b) { @@ -2222,7 +2272,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void XORShort256VectorTests(IntFunction fa, IntFunction fb) { + static void XORShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2235,11 +2285,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::XOR); + assertArraysEquals(r, a, b, ShortVector256Tests::XOR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void XORShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2255,11 +2305,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::XOR); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2269,11 +2319,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2286,11 +2336,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::add); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2300,11 +2350,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2317,11 +2367,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::sub); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2331,11 +2381,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2348,11 +2398,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::mul); } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2364,11 +2414,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2383,11 +2433,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::div); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2397,11 +2447,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2411,11 +2461,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2428,11 +2478,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2442,11 +2492,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2456,11 +2506,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2473,11 +2523,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector256Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2487,11 +2537,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortVector256Tests::OR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2504,11 +2554,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector256Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDShortVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2518,11 +2568,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortVector256Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDShortVector256TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2535,7 +2585,7 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector256Tests::ADD); } static short LSHL(short a, short b) { @@ -2543,7 +2593,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::LSHL); + assertArraysEquals(r, a, b, ShortVector256Tests::LSHL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2576,7 +2626,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::LSHL); } static short ASHR(short a, short b) { @@ -2584,7 +2634,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2597,11 +2647,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::ASHR); + assertArraysEquals(r, a, b, ShortVector256Tests::ASHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2617,7 +2667,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::ASHR); } static short LSHR(short a, short b) { @@ -2625,7 +2675,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort256VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2638,11 +2688,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::LSHR); + assertArraysEquals(r, a, b, ShortVector256Tests::LSHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2658,7 +2708,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::LSHR); } static short LSHL_unary(short a, short b) { @@ -2666,7 +2716,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLShortVector256TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2678,11 +2728,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ShortVector256Tests::LSHL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2697,7 +2747,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector256Tests::LSHL_unary); } static short LSHR_unary(short a, short b) { @@ -2705,7 +2755,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRShortVector256TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2717,11 +2767,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector256Tests::LSHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2736,7 +2786,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector256Tests::LSHR_unary); } static short ASHR_unary(short a, short b) { @@ -2744,7 +2794,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRShortVector256TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2756,11 +2806,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector256Tests::ASHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2775,7 +2825,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector256Tests::ASHR_unary); } static short ROR(short a, short b) { @@ -2783,7 +2833,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort256VectorTests(IntFunction fa, IntFunction fb) { + static void RORShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2796,11 +2846,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::ROR); + assertArraysEquals(r, a, b, ShortVector256Tests::ROR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2816,7 +2866,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::ROR); } static short ROL(short a, short b) { @@ -2824,7 +2874,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ROLShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2837,11 +2887,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::ROL); + assertArraysEquals(r, a, b, ShortVector256Tests::ROL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2857,7 +2907,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::ROL); } static short ROR_unary(short a, short b) { @@ -2865,7 +2915,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORShortVector256TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2877,11 +2927,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ShortVector256Tests::ROR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORShortVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2896,7 +2946,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector256Tests::ROR_unary); } static short ROL_unary(short a, short b) { @@ -2904,7 +2954,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort256VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLShortVector256TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2916,11 +2966,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ShortVector256Tests::ROL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort256VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector256TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2935,14 +2985,14 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector256Tests::ROL_unary); } static short LSHR_binary_const(short a) { return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHRShort256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRShortVector256TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2953,11 +3003,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ShortVector256Tests::LSHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHRShort256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRShortVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2971,7 +3021,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector256Tests::LSHR_binary_const); } static short LSHL_binary_const(short a) { @@ -2979,7 +3029,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHLShort256VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLShortVector256TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2990,11 +3040,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ShortVector256Tests::LSHL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHLShort256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLShortVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3008,7 +3058,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector256Tests::LSHL_binary_const); } static short ASHR_binary_const(short a) { @@ -3016,7 +3066,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ASHRShort256VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRShortVector256TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3027,11 +3077,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ShortVector256Tests::ASHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ASHRShort256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRShortVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3045,7 +3095,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short256VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector256Tests::ASHR_binary_const); } static short ROR_binary_const(short a) { @@ -3053,7 +3103,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void RORShort256VectorTestsScalarShiftConst(IntFunction fa) { + static void RORShortVector256TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3064,11 +3114,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ShortVector256Tests::ROR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void RORShort256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORShortVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3082,7 +3132,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short256VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector256Tests::ROR_binary_const); } static short ROL_binary_const(short a) { @@ -3090,7 +3140,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ROLShort256VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLShortVector256TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3101,11 +3151,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ShortVector256Tests::ROL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ROLShort256VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLShortVector256TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3119,14 +3169,14 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short256VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector256Tests::ROL_binary_const); } static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MINShort256VectorTestsWithMemOp(IntFunction fa) { + static void MINShortVector256TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3137,13 +3187,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short256VectorTests::MIN); + assertArraysEquals(r, a, (short)10, ShortVector256Tests::MIN); } static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void minShort256VectorTestsWithMemOp(IntFunction fa) { + static void minShortVector256TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3154,13 +3204,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short256VectorTests::min); + assertArraysEquals(r, a, (short)10, ShortVector256Tests::min); } static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINShortVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3173,13 +3223,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short256VectorTests::MIN); + assertArraysEquals(r, a, (short)10, mask, ShortVector256Tests::MIN); } static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MAXShort256VectorTestsWithMemOp(IntFunction fa) { + static void MAXShortVector256TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short256VectorTests::MAX); + assertArraysEquals(r, a, (short)10, ShortVector256Tests::MAX); } static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void maxShort256VectorTestsWithMemOp(IntFunction fa) { + static void maxShortVector256TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short256VectorTests::max); + assertArraysEquals(r, a, (short)10, ShortVector256Tests::max); } static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXShortVector256TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,15 +3276,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short256VectorTests::MAX); + assertArraysEquals(r, a, (short)10, mask, ShortVector256Tests::MAX); } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort256VectorTests(IntFunction fa, IntFunction fb) { + static void MINShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3247,15 +3297,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::MIN); + assertArraysEquals(r, a, b, ShortVector256Tests::MIN); } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort256VectorTests(IntFunction fa, IntFunction fb) { + static void minShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3266,15 +3316,15 @@ public class Short256VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::min); + assertArraysEquals(r, a, b, ShortVector256Tests::min); } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort256VectorTests(IntFunction fa, IntFunction fb) { + static void MAXShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3287,15 +3337,15 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::MAX); + assertArraysEquals(r, a, b, ShortVector256Tests::MAX); } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maxShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3306,7 +3356,7 @@ public class Short256VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short256VectorTests::max); + assertArraysEquals(r, a, b, ShortVector256Tests::max); } static short UMIN(short a, short b) { @@ -3314,7 +3364,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMINShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UMINShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3327,11 +3377,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::UMIN); + assertArraysEquals(r, a, b, ShortVector256Tests::UMIN); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMINShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3347,7 +3397,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::UMIN); } static short UMAX(short a, short b) { @@ -3355,7 +3405,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMAXShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3368,11 +3418,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::UMAX); + assertArraysEquals(r, a, b, ShortVector256Tests::UMAX); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMAXShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3388,7 +3438,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::UMAX); } static short SADD(short a, short b) { @@ -3396,7 +3446,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SADDShort256VectorTests(IntFunction fa, IntFunction fb) { + static void SADDShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3409,11 +3459,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::SADD); + assertArraysEquals(r, a, b, ShortVector256Tests::SADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SADDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3429,7 +3479,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::SADD); } static short SSUB(short a, short b) { @@ -3437,7 +3487,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SSUBShort256VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3450,11 +3500,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::SSUB); + assertArraysEquals(r, a, b, ShortVector256Tests::SSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SSUBShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3470,7 +3520,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::SSUB); } static short SUADD(short a, short b) { @@ -3478,7 +3528,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUADDShort256VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3491,11 +3541,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::SUADD); + assertArraysEquals(r, a, b, ShortVector256Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUADDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3511,7 +3561,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::SUADD); } static short SUSUB(short a, short b) { @@ -3519,7 +3569,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUSUBShort256VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3532,11 +3582,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::SUSUB); + assertArraysEquals(r, a, b, ShortVector256Tests::SUSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUSUBShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3552,11 +3602,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::SUSUB); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3566,11 +3616,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3580,11 +3630,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::min); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3594,11 +3644,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3608,10 +3658,10 @@ public class Short256VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short256VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortVector256Tests::max); } @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider") - static void SUADDAssocShort256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocShortVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -3628,11 +3678,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Short256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ShortVector256Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3653,13 +3703,13 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Short256VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortVector256Tests::SUADD); } static short ANDReduce(short[] a, int idx) { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3668,14 +3718,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ANDReduceAll(short[] a) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ANDReduceShort256VectorTests(IntFunction fa) { + static void ANDReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3686,12 +3736,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::ANDReduce, Short256VectorTests::ANDReduceAll); + ShortVector256Tests::ANDReduce, ShortVector256Tests::ANDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3699,20 +3749,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = AND_IDENTITY; - assertEquals((short) (id & id), id, + assertEquals((short) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id & x), x); - assertEquals((short) (x & id), x); + assertEquals((short) (scalar_and(id, x)), x); + assertEquals((short) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id & x), x, + assertEquals((short) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x & id), x, + assertEquals((short) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3721,7 +3771,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3730,14 +3780,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ANDReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3750,18 +3800,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::ANDReduceMasked, Short256VectorTests::ANDReduceAllMasked); + ShortVector256Tests::ANDReduceMasked, ShortVector256Tests::ANDReduceAllMasked); } static short ORReduce(short[] a, int idx) { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3770,14 +3820,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ORReduceAll(short[] a) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ORReduceShort256VectorTests(IntFunction fa) { + static void ORReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3788,12 +3838,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::ORReduce, Short256VectorTests::ORReduceAll); + ShortVector256Tests::ORReduce, ShortVector256Tests::ORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3801,20 +3851,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = OR_IDENTITY; - assertEquals((short) (id | id), id, + assertEquals((short) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id | x), x); - assertEquals((short) (x | id), x); + assertEquals((short) (scalar_or(id, x)), x); + assertEquals((short) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id | x), x, + assertEquals((short) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x | id), x, + assertEquals((short) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3823,7 +3873,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3832,14 +3882,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ORReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3852,18 +3902,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::ORReduceMasked, Short256VectorTests::ORReduceAllMasked); + ShortVector256Tests::ORReduceMasked, ShortVector256Tests::ORReduceAllMasked); } static short XORReduce(short[] a, int idx) { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3872,14 +3922,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short XORReduceAll(short[] a) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void XORReduceShort256VectorTests(IntFunction fa) { + static void XORReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3890,12 +3940,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::XORReduce, Short256VectorTests::XORReduceAll); + ShortVector256Tests::XORReduce, ShortVector256Tests::XORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3903,20 +3953,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = XOR_IDENTITY; - assertEquals((short) (id ^ id), id, + assertEquals((short) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id ^ x), x); - assertEquals((short) (x ^ id), x); + assertEquals((short) (scalar_xor(id, x)), x); + assertEquals((short) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id ^ x), x, + assertEquals((short) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x ^ id), x, + assertEquals((short) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3925,7 +3975,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3934,14 +3984,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void XORReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3954,18 +4004,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::XORReduceMasked, Short256VectorTests::XORReduceAllMasked); + ShortVector256Tests::XORReduceMasked, ShortVector256Tests::XORReduceAllMasked); } static short ADDReduce(short[] a, int idx) { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3974,14 +4024,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ADDReduceAll(short[] a) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceShort256VectorTests(IntFunction fa) { + static void ADDReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3992,12 +4042,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::ADDReduce, Short256VectorTests::ADDReduceAll); + ShortVector256Tests::ADDReduce, ShortVector256Tests::ADDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4005,20 +4055,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = ADD_IDENTITY; - assertEquals((short) (id + id), id, + assertEquals((short) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id + x), x); - assertEquals((short) (x + id), x); + assertEquals((short) (scalar_add(id, x)), x); + assertEquals((short) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id + x), x, + assertEquals((short) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x + id), x, + assertEquals((short) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4027,7 +4077,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4036,14 +4086,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short ADDReduceAllMasked(short[] a, boolean[] mask) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4056,18 +4106,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::ADDReduceMasked, Short256VectorTests::ADDReduceAllMasked); + ShortVector256Tests::ADDReduceMasked, ShortVector256Tests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4076,14 +4126,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MULReduceAll(short[] a) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MULReduceShort256VectorTests(IntFunction fa) { + static void MULReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4094,12 +4144,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::MULReduce, Short256VectorTests::MULReduceAll); + ShortVector256Tests::MULReduce, ShortVector256Tests::MULReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4107,20 +4157,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MUL_IDENTITY; - assertEquals((short) (id * id), id, + assertEquals((short) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id * x), x); - assertEquals((short) (x * id), x); + assertEquals((short) (scalar_mul(id, x)), x); + assertEquals((short) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id * x), x, + assertEquals((short) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x * id), x, + assertEquals((short) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4129,7 +4179,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4138,14 +4188,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MULReduceAllMasked(short[] a, boolean[] mask) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MULReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4158,18 +4208,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::MULReduceMasked, Short256VectorTests::MULReduceAllMasked); + ShortVector256Tests::MULReduceMasked, ShortVector256Tests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4178,14 +4228,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MINReduceAll(short[] a) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MINReduceShort256VectorTests(IntFunction fa) { + static void MINReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4196,12 +4246,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::MINReduce, Short256VectorTests::MINReduceAll); + ShortVector256Tests::MINReduce, ShortVector256Tests::MINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4209,20 +4259,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MIN_IDENTITY; - assertEquals((short) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.min(id, x), x); - assertEquals((short) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4231,7 +4281,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4240,14 +4290,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MINReduceAllMasked(short[] a, boolean[] mask) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4260,18 +4310,18 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::MINReduceMasked, Short256VectorTests::MINReduceAllMasked); + ShortVector256Tests::MINReduceMasked, ShortVector256Tests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4280,14 +4330,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MAXReduceAll(short[] a) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MAXReduceShort256VectorTests(IntFunction fa) { + static void MAXReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4298,12 +4348,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::MAXReduce, Short256VectorTests::MAXReduceAll); + ShortVector256Tests::MAXReduce, ShortVector256Tests::MAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4311,20 +4361,20 @@ public class Short256VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MAX_IDENTITY; - assertEquals((short) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.max(id, x), x); - assertEquals((short) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4333,7 +4383,7 @@ public class Short256VectorTests extends AbstractVectorTest { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4342,14 +4392,14 @@ public class Short256VectorTests extends AbstractVectorTest { static short MAXReduceAllMasked(short[] a, boolean[] mask) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4362,12 +4412,12 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked); + ShortVector256Tests::MAXReduceMasked, ShortVector256Tests::MAXReduceAllMasked); } static short UMINReduce(short[] a, int idx) { @@ -4389,7 +4439,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMINReduceShort256VectorTests(IntFunction fa) { + static void UMINReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4405,7 +4455,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::UMINReduce, Short256VectorTests::UMINReduceAll); + ShortVector256Tests::UMINReduce, ShortVector256Tests::UMINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4451,7 +4501,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMINReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4469,7 +4519,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::UMINReduceMasked, Short256VectorTests::UMINReduceAllMasked); + ShortVector256Tests::UMINReduceMasked, ShortVector256Tests::UMINReduceAllMasked); } static short UMAXReduce(short[] a, int idx) { @@ -4491,7 +4541,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMAXReduceShort256VectorTests(IntFunction fa) { + static void UMAXReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4507,7 +4557,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::UMAXReduce, Short256VectorTests::UMAXReduceAll); + ShortVector256Tests::UMAXReduce, ShortVector256Tests::UMAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4553,7 +4603,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4571,7 +4621,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::UMAXReduceMasked, Short256VectorTests::UMAXReduceAllMasked); + ShortVector256Tests::UMAXReduceMasked, ShortVector256Tests::UMAXReduceAllMasked); } static short FIRST_NONZEROReduce(short[] a, int idx) { @@ -4593,7 +4643,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void FIRST_NONZEROReduceShort256VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4609,7 +4659,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::FIRST_NONZEROReduce, Short256VectorTests::FIRST_NONZEROReduceAll); + ShortVector256Tests::FIRST_NONZEROReduce, ShortVector256Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4655,7 +4705,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void FIRST_NONZEROReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4673,7 +4723,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::FIRST_NONZEROReduceMasked, Short256VectorTests::FIRST_NONZEROReduceAllMasked); + ShortVector256Tests::FIRST_NONZEROReduceMasked, ShortVector256Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4686,7 +4736,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueShort256VectorTests(IntFunction fm) { + static void anyTrueShortVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4697,7 +4747,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short256VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector256Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4710,7 +4760,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueShort256VectorTests(IntFunction fm) { + static void allTrueShortVector256Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4721,7 +4771,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector256Tests::allTrue); } static short SUADDReduce(short[] a, int idx) { @@ -4743,7 +4793,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingUnaryOpProvider") - static void SUADDReduceShort256VectorTests(IntFunction fa) { + static void SUADDReduceShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4759,7 +4809,7 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short256VectorTests::SUADDReduce, Short256VectorTests::SUADDReduceAll); + ShortVector256Tests::SUADDReduce, ShortVector256Tests::SUADDReduceAll); } @Test(dataProvider = "shortSaturatingUnaryOpProvider") @@ -4804,7 +4854,7 @@ public class Short256VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider") - static void SUADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4822,11 +4872,11 @@ public class Short256VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::SUADDReduceMasked, Short256VectorTests::SUADDReduceAllMasked); + ShortVector256Tests::SUADDReduceMasked, ShortVector256Tests::SUADDReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void withShort256VectorTests(IntFunction fa, IntFunction fb) { + static void withShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -4849,7 +4899,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_DEFAULTShort256VectorTests(IntFunction fa) { + static void IS_DEFAULTShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4866,7 +4916,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_DEFAULTMaskedShort256VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4890,7 +4940,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_NEGATIVEShort256VectorTests(IntFunction fa) { + static void IS_NEGATIVEShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4907,7 +4957,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_NEGATIVEMaskedShort256VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4927,7 +4977,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void LTShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4946,7 +4996,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ltShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4965,7 +5015,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4988,7 +5038,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void GTShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5007,7 +5057,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5030,7 +5080,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort256VectorTests(IntFunction fa, IntFunction fb) { + static void EQShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5049,7 +5099,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort256VectorTests(IntFunction fa, IntFunction fb) { + static void eqShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5068,7 +5118,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5091,7 +5141,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void NEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void NEShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5110,7 +5160,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void NEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5133,7 +5183,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void LEShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5152,7 +5202,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5175,7 +5225,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void GEShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5194,7 +5244,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5217,7 +5267,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ULTShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5236,7 +5286,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5259,7 +5309,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5278,7 +5328,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5301,7 +5351,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5320,7 +5370,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5343,7 +5393,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortVector256Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5362,7 +5412,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5385,7 +5435,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5395,13 +5445,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5415,13 +5465,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5431,13 +5481,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTShortVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5451,13 +5501,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (short)((long)b[i])))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5467,13 +5517,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5487,13 +5537,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5503,13 +5553,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQShortVector256TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5523,7 +5573,7 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (short)((long)b[i])))); } } } @@ -5533,7 +5583,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort256VectorTests(IntFunction fa, IntFunction fb, + static void blendShortVector256Tests(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5549,11 +5599,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short256VectorTests::blend); + assertArraysEquals(r, a, b, mask, ShortVector256Tests::blend); } @Test(dataProvider = "shortUnaryOpShuffleProvider") - static void RearrangeShort256VectorTests(IntFunction fa, + static void RearrangeShortVector256Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5570,7 +5620,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") - static void RearrangeShort256VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeShortVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -5588,7 +5638,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void compressShort256VectorTests(IntFunction fa, + static void compressShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5606,7 +5656,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void expandShort256VectorTests(IntFunction fa, + static void expandShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5624,7 +5674,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void getShort256VectorTests(IntFunction fa) { + static void getShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5780,7 +5830,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastShort256VectorTests(IntFunction fa) { + static void BroadcastShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5794,7 +5844,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZeroShort256VectorTests(IntFunction fa) { + static void ZeroShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5819,7 +5869,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void sliceUnaryShort256VectorTests(IntFunction fa) { + static void sliceUnaryShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5830,7 +5880,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short256VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortVector256Tests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { @@ -5847,7 +5897,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void sliceBinaryShort256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryShortVector256TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5860,7 +5910,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Short256VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortVector256Tests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { @@ -5877,7 +5927,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void sliceShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5894,7 +5944,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Short256VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortVector256Tests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { @@ -5911,7 +5961,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void unsliceUnaryShort256VectorTests(IntFunction fa) { + static void unsliceUnaryShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5922,7 +5972,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short256VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortVector256Tests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { @@ -5948,7 +5998,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void unsliceBinaryShort256VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryShortVector256TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5962,7 +6012,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Short256VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortVector256Tests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { @@ -6002,7 +6052,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void unsliceShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6019,7 +6069,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Short256VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortVector256Tests::unslice); } static short BITWISE_BLEND(short a, short b, short c) { @@ -6031,7 +6081,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6046,11 +6096,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6063,11 +6113,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortVector256Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector256TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6085,11 +6135,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6100,11 +6150,11 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6115,11 +6165,11 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6130,11 +6180,11 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector256TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6145,11 +6195,11 @@ public class Short256VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6164,11 +6214,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector256TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector256TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6213,11 +6263,11 @@ public class Short256VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector256Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector256TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6231,19 +6281,19 @@ public class Short256VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortVector256Tests::BITWISE_BLEND); } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void NEGShort256VectorTests(IntFunction fa) { + static void NEGShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6254,11 +6304,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::NEG); + assertArraysEquals(r, a, ShortVector256Tests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") - static void negShort256VectorTests(IntFunction fa) { + static void negShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6269,11 +6319,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::neg); + assertArraysEquals(r, a, ShortVector256Tests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedShort256VectorTests(IntFunction fa, + static void NEGMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6287,19 +6337,19 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::NEG); + assertArraysEquals(r, a, mask, ShortVector256Tests::NEG); } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void ABSShort256VectorTests(IntFunction fa) { + static void ABSShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6310,11 +6360,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::ABS); + assertArraysEquals(r, a, ShortVector256Tests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") - static void absShort256VectorTests(IntFunction fa) { + static void absShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6325,11 +6375,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::abs); + assertArraysEquals(r, a, ShortVector256Tests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedShort256VectorTests(IntFunction fa, + static void ABSMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6343,7 +6393,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::ABS); + assertArraysEquals(r, a, mask, ShortVector256Tests::ABS); } static short NOT(short a) { @@ -6355,7 +6405,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void NOTShort256VectorTests(IntFunction fa) { + static void NOTShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6366,11 +6416,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::NOT); + assertArraysEquals(r, a, ShortVector256Tests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") - static void notShort256VectorTests(IntFunction fa) { + static void notShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6381,11 +6431,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::not); + assertArraysEquals(r, a, ShortVector256Tests::not); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NOTMaskedShort256VectorTests(IntFunction fa, + static void NOTMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6399,7 +6449,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::NOT); + assertArraysEquals(r, a, mask, ShortVector256Tests::NOT); } static short ZOMO(short a) { @@ -6407,7 +6457,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZOMOShort256VectorTests(IntFunction fa) { + static void ZOMOShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6418,11 +6468,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::ZOMO); + assertArraysEquals(r, a, ShortVector256Tests::ZOMO); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ZOMOMaskedShort256VectorTests(IntFunction fa, + static void ZOMOMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6436,7 +6486,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortVector256Tests::ZOMO); } static short BIT_COUNT(short a) { @@ -6444,7 +6494,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BIT_COUNTShort256VectorTests(IntFunction fa) { + static void BIT_COUNTShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6455,11 +6505,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ShortVector256Tests::BIT_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void BIT_COUNTMaskedShort256VectorTests(IntFunction fa, + static void BIT_COUNTMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6473,7 +6523,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ShortVector256Tests::BIT_COUNT); } static short TRAILING_ZEROS_COUNT(short a) { @@ -6481,7 +6531,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void TRAILING_ZEROS_COUNTShort256VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6492,11 +6542,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector256Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedShort256VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6510,7 +6560,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector256Tests::TRAILING_ZEROS_COUNT); } static short LEADING_ZEROS_COUNT(short a) { @@ -6518,7 +6568,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LEADING_ZEROS_COUNTShort256VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6529,11 +6579,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector256Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedShort256VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6547,7 +6597,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector256Tests::LEADING_ZEROS_COUNT); } static short REVERSE(short a) { @@ -6555,7 +6605,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSEShort256VectorTests(IntFunction fa) { + static void REVERSEShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6566,11 +6616,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::REVERSE); + assertArraysEquals(r, a, ShortVector256Tests::REVERSE); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSEMaskedShort256VectorTests(IntFunction fa, + static void REVERSEMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6584,7 +6634,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ShortVector256Tests::REVERSE); } static short REVERSE_BYTES(short a) { @@ -6592,7 +6642,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSE_BYTESShort256VectorTests(IntFunction fa) { + static void REVERSE_BYTESShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6603,11 +6653,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ShortVector256Tests::REVERSE_BYTES); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedShort256VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedShortVector256Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6621,7 +6671,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short256VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ShortVector256Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6629,7 +6679,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6642,7 +6692,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::band); + assertArraysEquals(r, a, b, ShortVector256Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6650,7 +6700,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskorShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6663,7 +6713,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::bor); + assertArraysEquals(r, a, b, ShortVector256Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6671,7 +6721,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6684,7 +6734,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::bxor); + assertArraysEquals(r, a, b, ShortVector256Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6692,7 +6742,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6705,7 +6755,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::bandNot); + assertArraysEquals(r, a, b, ShortVector256Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6713,7 +6763,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6726,7 +6776,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short256VectorTests::beq); + assertArraysEquals(r, a, b, ShortVector256Tests::beq); } static boolean unot(boolean a) { @@ -6734,7 +6784,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotShort256VectorTests(IntFunction fa) { + static void masknotShortVector256Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6745,7 +6795,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::unot); + assertArraysEquals(r, a, ShortVector256Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6762,7 +6812,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongShort256VectorTests(IntFunction fa) { + static void maskFromToLongShortVector256Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6776,7 +6826,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltShortVector256TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6786,13 +6836,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqShortVector256TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6802,13 +6852,13 @@ public class Short256VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortUnaryOpProvider") - static void toIntArrayShort256VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6819,7 +6869,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toLongArrayShort256VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6830,7 +6880,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toDoubleArrayShort256VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6841,7 +6891,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toStringShort256VectorTestsSmokeTest(IntFunction fa) { + static void toStringShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6854,7 +6904,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void hashCodeShort256VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6871,7 +6921,7 @@ public class Short256VectorTests extends AbstractVectorTest { static long ADDReduceLong(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6880,14 +6930,14 @@ public class Short256VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(short[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((short)res, (short)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceLongShort256VectorTests(IntFunction fa) { + static void ADDReduceLongShortVector256Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6898,19 +6948,20 @@ public class Short256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Short256VectorTests::ADDReduceLong, Short256VectorTests::ADDReduceAllLong); + ShortVector256Tests::ADDReduceLong, ShortVector256Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6919,14 +6970,14 @@ public class Short256VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((short)res, (short)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceLongShort256VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongShortVector256TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6939,16 +6990,16 @@ public class Short256VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Short256VectorTests::ADDReduceLongMasked, Short256VectorTests::ADDReduceAllLongMasked); + ShortVector256Tests::ADDReduceLongMasked, ShortVector256Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastLongShort256VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongShortVector256TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -6959,7 +7010,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendShortVector256TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6973,12 +7024,12 @@ public class Short256VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector256Tests::blend); } @Test(dataProvider = "shortUnaryOpSelectFromProvider") - static void SelectFromShort256VectorTests(IntFunction fa, + static void SelectFromShortVector256Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); short[] order = fs.apply(a.length, SPECIES.length()); @@ -6994,7 +7045,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorShort256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorShortVector256Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] idx = fc.apply(SPECIES.length()); @@ -7012,7 +7063,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") - static void SelectFromShort256VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromShortVector256TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -7031,7 +7082,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousShort256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousShortVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7047,7 +7098,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringShort256VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringShortVector256TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7061,7 +7112,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsShort256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsShortVector256TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7075,7 +7126,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsShort256VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsShortVector256Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7091,7 +7142,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeShort256VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeShortVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7113,7 +7164,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountShort256VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountShortVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7124,7 +7175,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ShortVector256Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7138,7 +7189,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueShort256VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueShortVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7149,7 +7200,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ShortVector256Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7163,7 +7214,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueShort256VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueShortVector256TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7174,11 +7225,11 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ShortVector256Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressShort256VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressShortVector256TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7206,7 +7257,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeShort256VectorTestsSmokeTest(int offset) { + static void indexInRangeShortVector256TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7220,7 +7271,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongShort256VectorTestsSmokeTest(int offset) { + static void indexInRangeLongShortVector256TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7247,14 +7298,14 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundShort256VectorTestsSmokeTest(int length) { + static void loopBoundShortVector256TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongShort256VectorTestsSmokeTest(int _length) { + static void loopBoundLongShortVector256TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7262,21 +7313,21 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeShort256VectorTestsSmokeTest() { + static void ElementSizeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Short.SIZE); } @Test - static void VectorShapeShort256VectorTestsSmokeTest() { + static void VectorShapeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_256_BIT)); } @Test - static void ShapeWithLanesShort256VectorTestsSmokeTest() { + static void ShapeWithLanesShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(short.class); @@ -7284,32 +7335,32 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeShort256VectorTestsSmokeTest() { + static void ElementTypeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementType() == short.class); } @Test - static void SpeciesElementSizeShort256VectorTestsSmokeTest() { + static void SpeciesElementSizeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementSize() == Short.SIZE); } @Test - static void VectorTypeShort256VectorTestsSmokeTest() { + static void VectorTypeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesShort256VectorTestsSmokeTest() { + static void WithLanesShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(short.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeShort256VectorTestsSmokeTest() { + static void WithShapeShortVector256TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7317,7 +7368,7 @@ public class Short256VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueShort256VectorTestsSmokeTest() { + static void MaskAllTrueShortVector256TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortVector512LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ShortVector512LoadStoreTests.java index accbe0008b5..74e485e3391 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector512LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Short512VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ShortVector512LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Short512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ShortVector512LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_512; diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/ShortVector512Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Short512VectorTests.java rename to test/jdk/jdk/incubator/vector/ShortVector512Tests.java index 7a08de22cb8..ae5804c3688 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector512Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortVector512Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Short512VectorTests extends AbstractVectorTest { +public class ShortVector512Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_512; @@ -1565,6 +1565,59 @@ public class Short512VectorTests extends AbstractVectorTest { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1581,9 +1634,6 @@ public class Short512VectorTests extends AbstractVectorTest { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1692,11 +1742,11 @@ public class Short512VectorTests extends AbstractVectorTest { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ADDShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1709,15 +1759,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::ADD); + assertArraysEquals(r, a, b, ShortVector512Tests::ADD); } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort512VectorTests(IntFunction fa, IntFunction fb) { + static void addShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1728,11 +1778,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::add); + assertArraysEquals(r, a, b, ShortVector512Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1748,11 +1798,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1766,15 +1816,15 @@ public class Short512VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short512VectorTests::add); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::add); } static short SUB(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void SUBShort512VectorTests(IntFunction fa, IntFunction fb) { + static void SUBShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1787,15 +1837,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::SUB); + assertArraysEquals(r, a, b, ShortVector512Tests::SUB); } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort512VectorTests(IntFunction fa, IntFunction fb) { + static void subShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1806,11 +1856,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::sub); + assertArraysEquals(r, a, b, ShortVector512Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void SUBShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1826,11 +1876,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::SUB); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1844,15 +1894,15 @@ public class Short512VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short512VectorTests::sub); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::sub); } static short MUL(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MULShort512VectorTests(IntFunction fa, IntFunction fb) { + static void MULShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1865,15 +1915,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::MUL); + assertArraysEquals(r, a, b, ShortVector512Tests::MUL); } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort512VectorTests(IntFunction fa, IntFunction fb) { + static void mulShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1884,11 +1934,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::mul); + assertArraysEquals(r, a, b, ShortVector512Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MULShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1904,11 +1954,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::MUL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1922,7 +1972,7 @@ public class Short512VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short512VectorTests::mul); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::mul); } static short DIV(short a, short b) { @@ -1930,7 +1980,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void DIVShort512VectorTests(IntFunction fa, IntFunction fb) { + static void DIVShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1945,7 +1995,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::DIV); + assertArraysEquals(r, a, b, ShortVector512Tests::DIV); } static short div(short a, short b) { @@ -1953,7 +2003,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort512VectorTests(IntFunction fa, IntFunction fb) { + static void divShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1968,11 +2018,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::div); + assertArraysEquals(r, a, b, ShortVector512Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void DIVShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1990,11 +2040,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::DIV); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2012,15 +2062,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::div); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::div); } static short FIRST_NONZERO(short a, short b) { - return (short)((a)!=0?a:b); + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void FIRST_NONZEROShort512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2033,11 +2083,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortVector512Tests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void FIRST_NONZEROShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2053,7 +2103,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -2061,7 +2111,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ANDShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2074,7 +2124,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::AND); + assertArraysEquals(r, a, b, ShortVector512Tests::AND); } static short and(short a, short b) { @@ -2082,7 +2132,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort512VectorTests(IntFunction fa, IntFunction fb) { + static void andShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2093,11 +2143,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::and); + assertArraysEquals(r, a, b, ShortVector512Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2113,7 +2163,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::AND); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::AND); } static short AND_NOT(short a, short b) { @@ -2121,7 +2171,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void AND_NOTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2134,11 +2184,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ShortVector512Tests::AND_NOT); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void AND_NOTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2154,7 +2204,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::AND_NOT); } static short OR(short a, short b) { @@ -2162,7 +2212,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ORShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2175,7 +2225,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::OR); + assertArraysEquals(r, a, b, ShortVector512Tests::OR); } static short or(short a, short b) { @@ -2183,7 +2233,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort512VectorTests(IntFunction fa, IntFunction fb) { + static void orShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2194,11 +2244,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::or); + assertArraysEquals(r, a, b, ShortVector512Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2214,7 +2264,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::OR); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::OR); } static short XOR(short a, short b) { @@ -2222,7 +2272,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void XORShort512VectorTests(IntFunction fa, IntFunction fb) { + static void XORShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2235,11 +2285,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::XOR); + assertArraysEquals(r, a, b, ShortVector512Tests::XOR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void XORShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2255,11 +2305,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::XOR); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2269,11 +2319,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2286,11 +2336,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::add); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2300,11 +2350,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2317,11 +2367,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::sub); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2331,11 +2381,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2348,11 +2398,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::mul); } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2364,11 +2414,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2383,11 +2433,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::div); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2397,11 +2447,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2411,11 +2461,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2428,11 +2478,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2442,11 +2492,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2456,11 +2506,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2473,11 +2523,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short512VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector512Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2487,11 +2537,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortVector512Tests::OR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2504,11 +2554,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short512VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector512Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDShortVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2518,11 +2568,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortVector512Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDShortVector512TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2535,7 +2585,7 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short512VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector512Tests::ADD); } static short LSHL(short a, short b) { @@ -2543,7 +2593,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::LSHL); + assertArraysEquals(r, a, b, ShortVector512Tests::LSHL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2576,7 +2626,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::LSHL); } static short ASHR(short a, short b) { @@ -2584,7 +2634,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2597,11 +2647,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::ASHR); + assertArraysEquals(r, a, b, ShortVector512Tests::ASHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2617,7 +2667,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::ASHR); } static short LSHR(short a, short b) { @@ -2625,7 +2675,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort512VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2638,11 +2688,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::LSHR); + assertArraysEquals(r, a, b, ShortVector512Tests::LSHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2658,7 +2708,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::LSHR); } static short LSHL_unary(short a, short b) { @@ -2666,7 +2716,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLShortVector512TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2678,11 +2728,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ShortVector512Tests::LSHL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2697,7 +2747,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector512Tests::LSHL_unary); } static short LSHR_unary(short a, short b) { @@ -2705,7 +2755,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRShortVector512TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2717,11 +2767,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector512Tests::LSHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2736,7 +2786,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector512Tests::LSHR_unary); } static short ASHR_unary(short a, short b) { @@ -2744,7 +2794,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRShortVector512TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2756,11 +2806,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector512Tests::ASHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2775,7 +2825,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector512Tests::ASHR_unary); } static short ROR(short a, short b) { @@ -2783,7 +2833,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort512VectorTests(IntFunction fa, IntFunction fb) { + static void RORShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2796,11 +2846,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::ROR); + assertArraysEquals(r, a, b, ShortVector512Tests::ROR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2816,7 +2866,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::ROR); } static short ROL(short a, short b) { @@ -2824,7 +2874,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ROLShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2837,11 +2887,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::ROL); + assertArraysEquals(r, a, b, ShortVector512Tests::ROL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2857,7 +2907,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::ROL); } static short ROR_unary(short a, short b) { @@ -2865,7 +2915,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORShortVector512TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2877,11 +2927,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ShortVector512Tests::ROR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORShortVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2896,7 +2946,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector512Tests::ROR_unary); } static short ROL_unary(short a, short b) { @@ -2904,7 +2954,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort512VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLShortVector512TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2916,11 +2966,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ShortVector512Tests::ROL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort512VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector512TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2935,14 +2985,14 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector512Tests::ROL_unary); } static short LSHR_binary_const(short a) { return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHRShort512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRShortVector512TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2953,11 +3003,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ShortVector512Tests::LSHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHRShort512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRShortVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2971,7 +3021,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short512VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector512Tests::LSHR_binary_const); } static short LSHL_binary_const(short a) { @@ -2979,7 +3029,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHLShort512VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLShortVector512TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2990,11 +3040,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ShortVector512Tests::LSHL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHLShort512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLShortVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3008,7 +3058,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short512VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector512Tests::LSHL_binary_const); } static short ASHR_binary_const(short a) { @@ -3016,7 +3066,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ASHRShort512VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRShortVector512TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3027,11 +3077,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ShortVector512Tests::ASHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ASHRShort512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRShortVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3045,7 +3095,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short512VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector512Tests::ASHR_binary_const); } static short ROR_binary_const(short a) { @@ -3053,7 +3103,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void RORShort512VectorTestsScalarShiftConst(IntFunction fa) { + static void RORShortVector512TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3064,11 +3114,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ShortVector512Tests::ROR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void RORShort512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORShortVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3082,7 +3132,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short512VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector512Tests::ROR_binary_const); } static short ROL_binary_const(short a) { @@ -3090,7 +3140,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ROLShort512VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLShortVector512TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3101,11 +3151,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ShortVector512Tests::ROL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ROLShort512VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLShortVector512TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3119,14 +3169,14 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short512VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector512Tests::ROL_binary_const); } static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MINShort512VectorTestsWithMemOp(IntFunction fa) { + static void MINShortVector512TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3137,13 +3187,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short512VectorTests::MIN); + assertArraysEquals(r, a, (short)10, ShortVector512Tests::MIN); } static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void minShort512VectorTestsWithMemOp(IntFunction fa) { + static void minShortVector512TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3154,13 +3204,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short512VectorTests::min); + assertArraysEquals(r, a, (short)10, ShortVector512Tests::min); } static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINShortVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3173,13 +3223,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short512VectorTests::MIN); + assertArraysEquals(r, a, (short)10, mask, ShortVector512Tests::MIN); } static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MAXShort512VectorTestsWithMemOp(IntFunction fa) { + static void MAXShortVector512TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short512VectorTests::MAX); + assertArraysEquals(r, a, (short)10, ShortVector512Tests::MAX); } static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void maxShort512VectorTestsWithMemOp(IntFunction fa) { + static void maxShortVector512TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short512VectorTests::max); + assertArraysEquals(r, a, (short)10, ShortVector512Tests::max); } static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXShortVector512TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,15 +3276,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short512VectorTests::MAX); + assertArraysEquals(r, a, (short)10, mask, ShortVector512Tests::MAX); } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort512VectorTests(IntFunction fa, IntFunction fb) { + static void MINShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3247,15 +3297,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::MIN); + assertArraysEquals(r, a, b, ShortVector512Tests::MIN); } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort512VectorTests(IntFunction fa, IntFunction fb) { + static void minShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3266,15 +3316,15 @@ public class Short512VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::min); + assertArraysEquals(r, a, b, ShortVector512Tests::min); } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort512VectorTests(IntFunction fa, IntFunction fb) { + static void MAXShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3287,15 +3337,15 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::MAX); + assertArraysEquals(r, a, b, ShortVector512Tests::MAX); } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maxShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3306,7 +3356,7 @@ public class Short512VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short512VectorTests::max); + assertArraysEquals(r, a, b, ShortVector512Tests::max); } static short UMIN(short a, short b) { @@ -3314,7 +3364,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMINShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UMINShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3327,11 +3377,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::UMIN); + assertArraysEquals(r, a, b, ShortVector512Tests::UMIN); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMINShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3347,7 +3397,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::UMIN); } static short UMAX(short a, short b) { @@ -3355,7 +3405,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMAXShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3368,11 +3418,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::UMAX); + assertArraysEquals(r, a, b, ShortVector512Tests::UMAX); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMAXShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3388,7 +3438,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::UMAX); } static short SADD(short a, short b) { @@ -3396,7 +3446,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SADDShort512VectorTests(IntFunction fa, IntFunction fb) { + static void SADDShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3409,11 +3459,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::SADD); + assertArraysEquals(r, a, b, ShortVector512Tests::SADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SADDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3429,7 +3479,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::SADD); } static short SSUB(short a, short b) { @@ -3437,7 +3487,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SSUBShort512VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3450,11 +3500,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::SSUB); + assertArraysEquals(r, a, b, ShortVector512Tests::SSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SSUBShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3470,7 +3520,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::SSUB); } static short SUADD(short a, short b) { @@ -3478,7 +3528,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUADDShort512VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3491,11 +3541,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::SUADD); + assertArraysEquals(r, a, b, ShortVector512Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUADDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3511,7 +3561,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::SUADD); } static short SUSUB(short a, short b) { @@ -3519,7 +3569,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUSUBShort512VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3532,11 +3582,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::SUSUB); + assertArraysEquals(r, a, b, ShortVector512Tests::SUSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUSUBShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3552,11 +3602,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::SUSUB); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3566,11 +3616,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3580,11 +3630,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::min); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3594,11 +3644,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3608,10 +3658,10 @@ public class Short512VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short512VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortVector512Tests::max); } @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider") - static void SUADDAssocShort512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocShortVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -3628,11 +3678,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Short512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ShortVector512Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3653,13 +3703,13 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Short512VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortVector512Tests::SUADD); } static short ANDReduce(short[] a, int idx) { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3668,14 +3718,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ANDReduceAll(short[] a) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ANDReduceShort512VectorTests(IntFunction fa) { + static void ANDReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3686,12 +3736,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::ANDReduce, Short512VectorTests::ANDReduceAll); + ShortVector512Tests::ANDReduce, ShortVector512Tests::ANDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3699,20 +3749,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = AND_IDENTITY; - assertEquals((short) (id & id), id, + assertEquals((short) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id & x), x); - assertEquals((short) (x & id), x); + assertEquals((short) (scalar_and(id, x)), x); + assertEquals((short) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id & x), x, + assertEquals((short) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x & id), x, + assertEquals((short) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3721,7 +3771,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3730,14 +3780,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ANDReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3750,18 +3800,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::ANDReduceMasked, Short512VectorTests::ANDReduceAllMasked); + ShortVector512Tests::ANDReduceMasked, ShortVector512Tests::ANDReduceAllMasked); } static short ORReduce(short[] a, int idx) { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3770,14 +3820,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ORReduceAll(short[] a) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ORReduceShort512VectorTests(IntFunction fa) { + static void ORReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3788,12 +3838,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::ORReduce, Short512VectorTests::ORReduceAll); + ShortVector512Tests::ORReduce, ShortVector512Tests::ORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3801,20 +3851,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = OR_IDENTITY; - assertEquals((short) (id | id), id, + assertEquals((short) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id | x), x); - assertEquals((short) (x | id), x); + assertEquals((short) (scalar_or(id, x)), x); + assertEquals((short) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id | x), x, + assertEquals((short) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x | id), x, + assertEquals((short) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3823,7 +3873,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3832,14 +3882,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ORReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3852,18 +3902,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::ORReduceMasked, Short512VectorTests::ORReduceAllMasked); + ShortVector512Tests::ORReduceMasked, ShortVector512Tests::ORReduceAllMasked); } static short XORReduce(short[] a, int idx) { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3872,14 +3922,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short XORReduceAll(short[] a) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void XORReduceShort512VectorTests(IntFunction fa) { + static void XORReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3890,12 +3940,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::XORReduce, Short512VectorTests::XORReduceAll); + ShortVector512Tests::XORReduce, ShortVector512Tests::XORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3903,20 +3953,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = XOR_IDENTITY; - assertEquals((short) (id ^ id), id, + assertEquals((short) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id ^ x), x); - assertEquals((short) (x ^ id), x); + assertEquals((short) (scalar_xor(id, x)), x); + assertEquals((short) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id ^ x), x, + assertEquals((short) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x ^ id), x, + assertEquals((short) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3925,7 +3975,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3934,14 +3984,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void XORReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3954,18 +4004,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::XORReduceMasked, Short512VectorTests::XORReduceAllMasked); + ShortVector512Tests::XORReduceMasked, ShortVector512Tests::XORReduceAllMasked); } static short ADDReduce(short[] a, int idx) { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3974,14 +4024,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ADDReduceAll(short[] a) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceShort512VectorTests(IntFunction fa) { + static void ADDReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3992,12 +4042,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::ADDReduce, Short512VectorTests::ADDReduceAll); + ShortVector512Tests::ADDReduce, ShortVector512Tests::ADDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4005,20 +4055,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = ADD_IDENTITY; - assertEquals((short) (id + id), id, + assertEquals((short) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id + x), x); - assertEquals((short) (x + id), x); + assertEquals((short) (scalar_add(id, x)), x); + assertEquals((short) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id + x), x, + assertEquals((short) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x + id), x, + assertEquals((short) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4027,7 +4077,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4036,14 +4086,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short ADDReduceAllMasked(short[] a, boolean[] mask) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4056,18 +4106,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::ADDReduceMasked, Short512VectorTests::ADDReduceAllMasked); + ShortVector512Tests::ADDReduceMasked, ShortVector512Tests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4076,14 +4126,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MULReduceAll(short[] a) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MULReduceShort512VectorTests(IntFunction fa) { + static void MULReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4094,12 +4144,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::MULReduce, Short512VectorTests::MULReduceAll); + ShortVector512Tests::MULReduce, ShortVector512Tests::MULReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4107,20 +4157,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MUL_IDENTITY; - assertEquals((short) (id * id), id, + assertEquals((short) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id * x), x); - assertEquals((short) (x * id), x); + assertEquals((short) (scalar_mul(id, x)), x); + assertEquals((short) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id * x), x, + assertEquals((short) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x * id), x, + assertEquals((short) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4129,7 +4179,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4138,14 +4188,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MULReduceAllMasked(short[] a, boolean[] mask) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MULReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4158,18 +4208,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::MULReduceMasked, Short512VectorTests::MULReduceAllMasked); + ShortVector512Tests::MULReduceMasked, ShortVector512Tests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4178,14 +4228,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MINReduceAll(short[] a) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MINReduceShort512VectorTests(IntFunction fa) { + static void MINReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4196,12 +4246,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::MINReduce, Short512VectorTests::MINReduceAll); + ShortVector512Tests::MINReduce, ShortVector512Tests::MINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4209,20 +4259,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MIN_IDENTITY; - assertEquals((short) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.min(id, x), x); - assertEquals((short) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4231,7 +4281,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4240,14 +4290,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MINReduceAllMasked(short[] a, boolean[] mask) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4260,18 +4310,18 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::MINReduceMasked, Short512VectorTests::MINReduceAllMasked); + ShortVector512Tests::MINReduceMasked, ShortVector512Tests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4280,14 +4330,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MAXReduceAll(short[] a) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MAXReduceShort512VectorTests(IntFunction fa) { + static void MAXReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4298,12 +4348,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::MAXReduce, Short512VectorTests::MAXReduceAll); + ShortVector512Tests::MAXReduce, ShortVector512Tests::MAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4311,20 +4361,20 @@ public class Short512VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MAX_IDENTITY; - assertEquals((short) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.max(id, x), x); - assertEquals((short) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4333,7 +4383,7 @@ public class Short512VectorTests extends AbstractVectorTest { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4342,14 +4392,14 @@ public class Short512VectorTests extends AbstractVectorTest { static short MAXReduceAllMasked(short[] a, boolean[] mask) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4362,12 +4412,12 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::MAXReduceMasked, Short512VectorTests::MAXReduceAllMasked); + ShortVector512Tests::MAXReduceMasked, ShortVector512Tests::MAXReduceAllMasked); } static short UMINReduce(short[] a, int idx) { @@ -4389,7 +4439,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMINReduceShort512VectorTests(IntFunction fa) { + static void UMINReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4405,7 +4455,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::UMINReduce, Short512VectorTests::UMINReduceAll); + ShortVector512Tests::UMINReduce, ShortVector512Tests::UMINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4451,7 +4501,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMINReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4469,7 +4519,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::UMINReduceMasked, Short512VectorTests::UMINReduceAllMasked); + ShortVector512Tests::UMINReduceMasked, ShortVector512Tests::UMINReduceAllMasked); } static short UMAXReduce(short[] a, int idx) { @@ -4491,7 +4541,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMAXReduceShort512VectorTests(IntFunction fa) { + static void UMAXReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4507,7 +4557,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::UMAXReduce, Short512VectorTests::UMAXReduceAll); + ShortVector512Tests::UMAXReduce, ShortVector512Tests::UMAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4553,7 +4603,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4571,7 +4621,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::UMAXReduceMasked, Short512VectorTests::UMAXReduceAllMasked); + ShortVector512Tests::UMAXReduceMasked, ShortVector512Tests::UMAXReduceAllMasked); } static short FIRST_NONZEROReduce(short[] a, int idx) { @@ -4593,7 +4643,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void FIRST_NONZEROReduceShort512VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4609,7 +4659,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::FIRST_NONZEROReduce, Short512VectorTests::FIRST_NONZEROReduceAll); + ShortVector512Tests::FIRST_NONZEROReduce, ShortVector512Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4655,7 +4705,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void FIRST_NONZEROReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4673,7 +4723,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::FIRST_NONZEROReduceMasked, Short512VectorTests::FIRST_NONZEROReduceAllMasked); + ShortVector512Tests::FIRST_NONZEROReduceMasked, ShortVector512Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4686,7 +4736,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueShort512VectorTests(IntFunction fm) { + static void anyTrueShortVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4697,7 +4747,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short512VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector512Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4710,7 +4760,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueShort512VectorTests(IntFunction fm) { + static void allTrueShortVector512Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4721,7 +4771,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short512VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector512Tests::allTrue); } static short SUADDReduce(short[] a, int idx) { @@ -4743,7 +4793,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingUnaryOpProvider") - static void SUADDReduceShort512VectorTests(IntFunction fa) { + static void SUADDReduceShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4759,7 +4809,7 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short512VectorTests::SUADDReduce, Short512VectorTests::SUADDReduceAll); + ShortVector512Tests::SUADDReduce, ShortVector512Tests::SUADDReduceAll); } @Test(dataProvider = "shortSaturatingUnaryOpProvider") @@ -4804,7 +4854,7 @@ public class Short512VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider") - static void SUADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4822,11 +4872,11 @@ public class Short512VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::SUADDReduceMasked, Short512VectorTests::SUADDReduceAllMasked); + ShortVector512Tests::SUADDReduceMasked, ShortVector512Tests::SUADDReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void withShort512VectorTests(IntFunction fa, IntFunction fb) { + static void withShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -4849,7 +4899,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_DEFAULTShort512VectorTests(IntFunction fa) { + static void IS_DEFAULTShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4866,7 +4916,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_DEFAULTMaskedShort512VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4890,7 +4940,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_NEGATIVEShort512VectorTests(IntFunction fa) { + static void IS_NEGATIVEShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4907,7 +4957,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_NEGATIVEMaskedShort512VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4927,7 +4977,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void LTShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4946,7 +4996,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ltShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4965,7 +5015,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4988,7 +5038,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void GTShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5007,7 +5057,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5030,7 +5080,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort512VectorTests(IntFunction fa, IntFunction fb) { + static void EQShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5049,7 +5099,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort512VectorTests(IntFunction fa, IntFunction fb) { + static void eqShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5068,7 +5118,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5091,7 +5141,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void NEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void NEShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5110,7 +5160,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void NEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5133,7 +5183,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void LEShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5152,7 +5202,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5175,7 +5225,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void GEShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5194,7 +5244,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5217,7 +5267,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ULTShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5236,7 +5286,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5259,7 +5309,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5278,7 +5328,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5301,7 +5351,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5320,7 +5370,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5343,7 +5393,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortVector512Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5362,7 +5412,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5385,7 +5435,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5395,13 +5445,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5415,13 +5465,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5431,13 +5481,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTShortVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5451,13 +5501,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (short)((long)b[i])))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5467,13 +5517,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5487,13 +5537,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5503,13 +5553,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQShortVector512TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5523,7 +5573,7 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (short)((long)b[i])))); } } } @@ -5533,7 +5583,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort512VectorTests(IntFunction fa, IntFunction fb, + static void blendShortVector512Tests(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5549,11 +5599,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short512VectorTests::blend); + assertArraysEquals(r, a, b, mask, ShortVector512Tests::blend); } @Test(dataProvider = "shortUnaryOpShuffleProvider") - static void RearrangeShort512VectorTests(IntFunction fa, + static void RearrangeShortVector512Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5570,7 +5620,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") - static void RearrangeShort512VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeShortVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -5588,7 +5638,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void compressShort512VectorTests(IntFunction fa, + static void compressShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5606,7 +5656,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void expandShort512VectorTests(IntFunction fa, + static void expandShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5624,7 +5674,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void getShort512VectorTests(IntFunction fa) { + static void getShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5780,7 +5830,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastShort512VectorTests(IntFunction fa) { + static void BroadcastShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5794,7 +5844,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZeroShort512VectorTests(IntFunction fa) { + static void ZeroShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5819,7 +5869,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void sliceUnaryShort512VectorTests(IntFunction fa) { + static void sliceUnaryShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5830,7 +5880,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short512VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortVector512Tests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { @@ -5847,7 +5897,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void sliceBinaryShort512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryShortVector512TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5860,7 +5910,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Short512VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortVector512Tests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { @@ -5877,7 +5927,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void sliceShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5894,7 +5944,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Short512VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortVector512Tests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { @@ -5911,7 +5961,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void unsliceUnaryShort512VectorTests(IntFunction fa) { + static void unsliceUnaryShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5922,7 +5972,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short512VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortVector512Tests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { @@ -5948,7 +5998,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void unsliceBinaryShort512VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryShortVector512TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5962,7 +6012,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Short512VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortVector512Tests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { @@ -6002,7 +6052,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void unsliceShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6019,7 +6069,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Short512VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortVector512Tests::unslice); } static short BITWISE_BLEND(short a, short b, short c) { @@ -6031,7 +6081,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6046,11 +6096,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Short512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6063,11 +6113,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortVector512Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector512TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6085,11 +6135,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6100,11 +6150,11 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6115,11 +6165,11 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6130,11 +6180,11 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector512TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6145,11 +6195,11 @@ public class Short512VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6164,11 +6214,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector512TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector512TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6213,11 +6263,11 @@ public class Short512VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short512VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector512Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector512TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6231,19 +6281,19 @@ public class Short512VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short512VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortVector512Tests::BITWISE_BLEND); } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void NEGShort512VectorTests(IntFunction fa) { + static void NEGShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6254,11 +6304,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::NEG); + assertArraysEquals(r, a, ShortVector512Tests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") - static void negShort512VectorTests(IntFunction fa) { + static void negShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6269,11 +6319,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::neg); + assertArraysEquals(r, a, ShortVector512Tests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedShort512VectorTests(IntFunction fa, + static void NEGMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6287,19 +6337,19 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::NEG); + assertArraysEquals(r, a, mask, ShortVector512Tests::NEG); } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void ABSShort512VectorTests(IntFunction fa) { + static void ABSShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6310,11 +6360,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::ABS); + assertArraysEquals(r, a, ShortVector512Tests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") - static void absShort512VectorTests(IntFunction fa) { + static void absShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6325,11 +6375,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::abs); + assertArraysEquals(r, a, ShortVector512Tests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedShort512VectorTests(IntFunction fa, + static void ABSMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6343,7 +6393,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::ABS); + assertArraysEquals(r, a, mask, ShortVector512Tests::ABS); } static short NOT(short a) { @@ -6355,7 +6405,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void NOTShort512VectorTests(IntFunction fa) { + static void NOTShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6366,11 +6416,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::NOT); + assertArraysEquals(r, a, ShortVector512Tests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") - static void notShort512VectorTests(IntFunction fa) { + static void notShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6381,11 +6431,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::not); + assertArraysEquals(r, a, ShortVector512Tests::not); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NOTMaskedShort512VectorTests(IntFunction fa, + static void NOTMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6399,7 +6449,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::NOT); + assertArraysEquals(r, a, mask, ShortVector512Tests::NOT); } static short ZOMO(short a) { @@ -6407,7 +6457,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZOMOShort512VectorTests(IntFunction fa) { + static void ZOMOShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6418,11 +6468,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::ZOMO); + assertArraysEquals(r, a, ShortVector512Tests::ZOMO); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ZOMOMaskedShort512VectorTests(IntFunction fa, + static void ZOMOMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6436,7 +6486,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortVector512Tests::ZOMO); } static short BIT_COUNT(short a) { @@ -6444,7 +6494,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BIT_COUNTShort512VectorTests(IntFunction fa) { + static void BIT_COUNTShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6455,11 +6505,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ShortVector512Tests::BIT_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void BIT_COUNTMaskedShort512VectorTests(IntFunction fa, + static void BIT_COUNTMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6473,7 +6523,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ShortVector512Tests::BIT_COUNT); } static short TRAILING_ZEROS_COUNT(short a) { @@ -6481,7 +6531,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void TRAILING_ZEROS_COUNTShort512VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6492,11 +6542,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector512Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedShort512VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6510,7 +6560,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector512Tests::TRAILING_ZEROS_COUNT); } static short LEADING_ZEROS_COUNT(short a) { @@ -6518,7 +6568,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LEADING_ZEROS_COUNTShort512VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6529,11 +6579,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector512Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedShort512VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6547,7 +6597,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector512Tests::LEADING_ZEROS_COUNT); } static short REVERSE(short a) { @@ -6555,7 +6605,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSEShort512VectorTests(IntFunction fa) { + static void REVERSEShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6566,11 +6616,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::REVERSE); + assertArraysEquals(r, a, ShortVector512Tests::REVERSE); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSEMaskedShort512VectorTests(IntFunction fa, + static void REVERSEMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6584,7 +6634,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ShortVector512Tests::REVERSE); } static short REVERSE_BYTES(short a) { @@ -6592,7 +6642,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSE_BYTESShort512VectorTests(IntFunction fa) { + static void REVERSE_BYTESShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6603,11 +6653,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ShortVector512Tests::REVERSE_BYTES); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedShort512VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedShortVector512Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6621,7 +6671,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short512VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ShortVector512Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6629,7 +6679,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6642,7 +6692,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::band); + assertArraysEquals(r, a, b, ShortVector512Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6650,7 +6700,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskorShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6663,7 +6713,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::bor); + assertArraysEquals(r, a, b, ShortVector512Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6671,7 +6721,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6684,7 +6734,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::bxor); + assertArraysEquals(r, a, b, ShortVector512Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6692,7 +6742,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6705,7 +6755,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::bandNot); + assertArraysEquals(r, a, b, ShortVector512Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6713,7 +6763,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6726,7 +6776,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short512VectorTests::beq); + assertArraysEquals(r, a, b, ShortVector512Tests::beq); } static boolean unot(boolean a) { @@ -6734,7 +6784,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotShort512VectorTests(IntFunction fa) { + static void masknotShortVector512Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6745,7 +6795,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::unot); + assertArraysEquals(r, a, ShortVector512Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6762,7 +6812,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongShort512VectorTests(IntFunction fa) { + static void maskFromToLongShortVector512Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6776,7 +6826,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltShortVector512TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6786,13 +6836,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqShortVector512TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6802,13 +6852,13 @@ public class Short512VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortUnaryOpProvider") - static void toIntArrayShort512VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6819,7 +6869,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toLongArrayShort512VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6830,7 +6880,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toDoubleArrayShort512VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6841,7 +6891,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toStringShort512VectorTestsSmokeTest(IntFunction fa) { + static void toStringShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6854,7 +6904,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void hashCodeShort512VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6871,7 +6921,7 @@ public class Short512VectorTests extends AbstractVectorTest { static long ADDReduceLong(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6880,14 +6930,14 @@ public class Short512VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(short[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((short)res, (short)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceLongShort512VectorTests(IntFunction fa) { + static void ADDReduceLongShortVector512Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6898,19 +6948,20 @@ public class Short512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Short512VectorTests::ADDReduceLong, Short512VectorTests::ADDReduceAllLong); + ShortVector512Tests::ADDReduceLong, ShortVector512Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6919,14 +6970,14 @@ public class Short512VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((short)res, (short)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceLongShort512VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongShortVector512TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6939,16 +6990,16 @@ public class Short512VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Short512VectorTests::ADDReduceLongMasked, Short512VectorTests::ADDReduceAllLongMasked); + ShortVector512Tests::ADDReduceLongMasked, ShortVector512Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastLongShort512VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongShortVector512TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -6959,7 +7010,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendShortVector512TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6973,12 +7024,12 @@ public class Short512VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Short512VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector512Tests::blend); } @Test(dataProvider = "shortUnaryOpSelectFromProvider") - static void SelectFromShort512VectorTests(IntFunction fa, + static void SelectFromShortVector512Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); short[] order = fs.apply(a.length, SPECIES.length()); @@ -6994,7 +7045,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorShort512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorShortVector512Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] idx = fc.apply(SPECIES.length()); @@ -7012,7 +7063,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") - static void SelectFromShort512VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromShortVector512TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -7031,7 +7082,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousShort512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousShortVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7047,7 +7098,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringShort512VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringShortVector512TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7061,7 +7112,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsShort512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsShortVector512TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7075,7 +7126,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsShort512VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsShortVector512Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7091,7 +7142,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeShort512VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeShortVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7113,7 +7164,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountShort512VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountShortVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7124,7 +7175,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short512VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ShortVector512Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7138,7 +7189,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueShort512VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueShortVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7149,7 +7200,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short512VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ShortVector512Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7163,7 +7214,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueShort512VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueShortVector512TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7174,11 +7225,11 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short512VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ShortVector512Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressShort512VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressShortVector512TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7206,7 +7257,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeShort512VectorTestsSmokeTest(int offset) { + static void indexInRangeShortVector512TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7220,7 +7271,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongShort512VectorTestsSmokeTest(int offset) { + static void indexInRangeLongShortVector512TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7247,14 +7298,14 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundShort512VectorTestsSmokeTest(int length) { + static void loopBoundShortVector512TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongShort512VectorTestsSmokeTest(int _length) { + static void loopBoundLongShortVector512TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7262,21 +7313,21 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeShort512VectorTestsSmokeTest() { + static void ElementSizeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Short.SIZE); } @Test - static void VectorShapeShort512VectorTestsSmokeTest() { + static void VectorShapeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_512_BIT)); } @Test - static void ShapeWithLanesShort512VectorTestsSmokeTest() { + static void ShapeWithLanesShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(short.class); @@ -7284,32 +7335,32 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeShort512VectorTestsSmokeTest() { + static void ElementTypeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementType() == short.class); } @Test - static void SpeciesElementSizeShort512VectorTestsSmokeTest() { + static void SpeciesElementSizeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementSize() == Short.SIZE); } @Test - static void VectorTypeShort512VectorTestsSmokeTest() { + static void VectorTypeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesShort512VectorTestsSmokeTest() { + static void WithLanesShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(short.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeShort512VectorTestsSmokeTest() { + static void WithShapeShortVector512TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7317,7 +7368,7 @@ public class Short512VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueShort512VectorTestsSmokeTest() { + static void MaskAllTrueShortVector512TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortVector64LoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ShortVector64LoadStoreTests.java index 063b3e8ca61..d48c781886c 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector64LoadStoreTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation Short64VectorLoadStoreTests + * @run testng/othervm -XX:-TieredCompilation ShortVector64LoadStoreTests * */ @@ -50,7 +50,7 @@ import java.util.List; import java.util.function.*; @Test -public class Short64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ShortVector64LoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_64; diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/ShortVector64Tests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/Short64VectorTests.java rename to test/jdk/jdk/incubator/vector/ShortVector64Tests.java index 4181dbce164..5f84682f02f 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector64Tests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortVector64Tests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class Short64VectorTests extends AbstractVectorTest { +public class ShortVector64Tests extends AbstractVectorTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_64; @@ -1565,6 +1565,59 @@ public class Short64VectorTests extends AbstractVectorTest { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1581,9 +1634,6 @@ public class Short64VectorTests extends AbstractVectorTest { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1692,11 +1742,11 @@ public class Short64VectorTests extends AbstractVectorTest { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ADDShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1709,15 +1759,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::ADD); + assertArraysEquals(r, a, b, ShortVector64Tests::ADD); } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort64VectorTests(IntFunction fa, IntFunction fb) { + static void addShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1728,11 +1778,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::add); + assertArraysEquals(r, a, b, ShortVector64Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1748,11 +1798,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::ADD); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1766,15 +1816,15 @@ public class Short64VectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short64VectorTests::add); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::add); } static short SUB(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void SUBShort64VectorTests(IntFunction fa, IntFunction fb) { + static void SUBShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1787,15 +1837,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::SUB); + assertArraysEquals(r, a, b, ShortVector64Tests::SUB); } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort64VectorTests(IntFunction fa, IntFunction fb) { + static void subShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1806,11 +1856,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::sub); + assertArraysEquals(r, a, b, ShortVector64Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void SUBShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1826,11 +1876,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::SUB); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::SUB); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void subShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1844,15 +1894,15 @@ public class Short64VectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short64VectorTests::sub); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::sub); } static short MUL(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MULShort64VectorTests(IntFunction fa, IntFunction fb) { + static void MULShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1865,15 +1915,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::MUL); + assertArraysEquals(r, a, b, ShortVector64Tests::MUL); } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort64VectorTests(IntFunction fa, IntFunction fb) { + static void mulShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1884,11 +1934,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::mul); + assertArraysEquals(r, a, b, ShortVector64Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MULShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1904,11 +1954,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::MUL); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::MUL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1922,7 +1972,7 @@ public class Short64VectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Short64VectorTests::mul); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::mul); } static short DIV(short a, short b) { @@ -1930,7 +1980,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void DIVShort64VectorTests(IntFunction fa, IntFunction fb) { + static void DIVShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1945,7 +1995,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::DIV); + assertArraysEquals(r, a, b, ShortVector64Tests::DIV); } static short div(short a, short b) { @@ -1953,7 +2003,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort64VectorTests(IntFunction fa, IntFunction fb) { + static void divShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1968,11 +2018,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::div); + assertArraysEquals(r, a, b, ShortVector64Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void DIVShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1990,11 +2040,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::DIV); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::DIV); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void divShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2012,15 +2062,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::div); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::div); } static short FIRST_NONZERO(short a, short b) { - return (short)((a)!=0?a:b); + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void FIRST_NONZEROShort64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2033,11 +2083,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortVector64Tests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void FIRST_NONZEROShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2053,7 +2103,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -2061,7 +2111,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ANDShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2074,7 +2124,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::AND); + assertArraysEquals(r, a, b, ShortVector64Tests::AND); } static short and(short a, short b) { @@ -2082,7 +2132,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort64VectorTests(IntFunction fa, IntFunction fb) { + static void andShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2093,11 +2143,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::and); + assertArraysEquals(r, a, b, ShortVector64Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2113,7 +2163,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::AND); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::AND); } static short AND_NOT(short a, short b) { @@ -2121,7 +2171,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void AND_NOTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2134,11 +2184,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, ShortVector64Tests::AND_NOT); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void AND_NOTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2154,7 +2204,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::AND_NOT); } static short OR(short a, short b) { @@ -2162,7 +2212,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ORShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2175,7 +2225,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::OR); + assertArraysEquals(r, a, b, ShortVector64Tests::OR); } static short or(short a, short b) { @@ -2183,7 +2233,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort64VectorTests(IntFunction fa, IntFunction fb) { + static void orShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2194,11 +2244,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::or); + assertArraysEquals(r, a, b, ShortVector64Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2214,7 +2264,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::OR); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::OR); } static short XOR(short a, short b) { @@ -2222,7 +2272,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void XORShort64VectorTests(IntFunction fa, IntFunction fb) { + static void XORShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2235,11 +2285,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::XOR); + assertArraysEquals(r, a, b, ShortVector64Tests::XOR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void XORShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2255,11 +2305,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::XOR); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::XOR); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2269,11 +2319,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2286,11 +2336,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::add); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2300,11 +2350,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2317,11 +2367,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::sub); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2331,11 +2381,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2348,11 +2398,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::mul); } @Test(dataProvider = "shortBinaryOpProvider") - static void divShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2364,11 +2414,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2383,11 +2433,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::div); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2397,11 +2447,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void orShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2411,11 +2461,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2428,11 +2478,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2442,11 +2492,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void andShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2456,11 +2506,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2473,11 +2523,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortVector64Tests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2487,11 +2537,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortVector64Tests::OR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2504,11 +2554,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector64Tests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDShortVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2518,11 +2568,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortVector64Tests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDShortVector64TestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2535,7 +2585,7 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector64Tests::ADD); } static short LSHL(short a, short b) { @@ -2543,7 +2593,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHLShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2556,11 +2606,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::LSHL); + assertArraysEquals(r, a, b, ShortVector64Tests::LSHL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2576,7 +2626,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::LSHL); } static short ASHR(short a, short b) { @@ -2584,7 +2634,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ASHRShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2597,11 +2647,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::ASHR); + assertArraysEquals(r, a, b, ShortVector64Tests::ASHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2617,7 +2667,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::ASHR); } static short LSHR(short a, short b) { @@ -2625,7 +2675,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort64VectorTests(IntFunction fa, IntFunction fb) { + static void LSHRShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2638,11 +2688,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::LSHR); + assertArraysEquals(r, a, b, ShortVector64Tests::LSHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2658,7 +2708,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::LSHR); } static short LSHL_unary(short a, short b) { @@ -2666,7 +2716,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShort64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLShortVector64TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2678,11 +2728,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ShortVector64Tests::LSHL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShort64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2697,7 +2747,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector64Tests::LSHL_unary); } static short LSHR_unary(short a, short b) { @@ -2705,7 +2755,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShort64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRShortVector64TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2717,11 +2767,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector64Tests::LSHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShort64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2736,7 +2786,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector64Tests::LSHR_unary); } static short ASHR_unary(short a, short b) { @@ -2744,7 +2794,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShort64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRShortVector64TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2756,11 +2806,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ShortVector64Tests::ASHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShort64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2775,7 +2825,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector64Tests::ASHR_unary); } static short ROR(short a, short b) { @@ -2783,7 +2833,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort64VectorTests(IntFunction fa, IntFunction fb) { + static void RORShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2796,11 +2846,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::ROR); + assertArraysEquals(r, a, b, ShortVector64Tests::ROR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2816,7 +2866,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::ROR); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::ROR); } static short ROL(short a, short b) { @@ -2824,7 +2874,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ROLShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2837,11 +2887,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::ROL); + assertArraysEquals(r, a, b, ShortVector64Tests::ROL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2857,7 +2907,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::ROL); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::ROL); } static short ROR_unary(short a, short b) { @@ -2865,7 +2915,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShort64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORShortVector64TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2877,11 +2927,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ShortVector64Tests::ROR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShort64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORShortVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2896,7 +2946,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector64Tests::ROR_unary); } static short ROL_unary(short a, short b) { @@ -2904,7 +2954,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShort64VectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLShortVector64TestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2916,11 +2966,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, Short64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ShortVector64Tests::ROL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShort64VectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLShortVector64TestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2935,14 +2985,14 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVector64Tests::ROL_unary); } static short LSHR_binary_const(short a) { return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHRShort64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRShortVector64TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2953,11 +3003,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ShortVector64Tests::LSHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHRShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRShortVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2971,7 +3021,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector64Tests::LSHR_binary_const); } static short LSHL_binary_const(short a) { @@ -2979,7 +3029,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHLShort64VectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLShortVector64TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2990,11 +3040,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ShortVector64Tests::LSHL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHLShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLShortVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3008,7 +3058,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector64Tests::LSHL_binary_const); } static short ASHR_binary_const(short a) { @@ -3016,7 +3066,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ASHRShort64VectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRShortVector64TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3027,11 +3077,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ShortVector64Tests::ASHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ASHRShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRShortVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3045,7 +3095,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short64VectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector64Tests::ASHR_binary_const); } static short ROR_binary_const(short a) { @@ -3053,7 +3103,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void RORShort64VectorTestsScalarShiftConst(IntFunction fa) { + static void RORShortVector64TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3064,11 +3114,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ShortVector64Tests::ROR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void RORShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORShortVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3082,7 +3132,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short64VectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector64Tests::ROR_binary_const); } static short ROL_binary_const(short a) { @@ -3090,7 +3140,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ROLShort64VectorTestsScalarShiftConst(IntFunction fa) { + static void ROLShortVector64TestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3101,11 +3151,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, Short64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ShortVector64Tests::ROL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ROLShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLShortVector64TestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3119,14 +3169,14 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, Short64VectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVector64Tests::ROL_binary_const); } static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MINShort64VectorTestsWithMemOp(IntFunction fa) { + static void MINShortVector64TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3137,13 +3187,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short64VectorTests::MIN); + assertArraysEquals(r, a, (short)10, ShortVector64Tests::MIN); } static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void minShort64VectorTestsWithMemOp(IntFunction fa) { + static void minShortVector64TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3154,13 +3204,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short64VectorTests::min); + assertArraysEquals(r, a, (short)10, ShortVector64Tests::min); } static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINShortVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3173,13 +3223,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short64VectorTests::MIN); + assertArraysEquals(r, a, (short)10, mask, ShortVector64Tests::MIN); } static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MAXShort64VectorTestsWithMemOp(IntFunction fa) { + static void MAXShortVector64TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3190,13 +3240,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short64VectorTests::MAX); + assertArraysEquals(r, a, (short)10, ShortVector64Tests::MAX); } static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void maxShort64VectorTestsWithMemOp(IntFunction fa) { + static void maxShortVector64TestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3207,13 +3257,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, Short64VectorTests::max); + assertArraysEquals(r, a, (short)10, ShortVector64Tests::max); } static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXShortVector64TestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3226,15 +3276,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, Short64VectorTests::MAX); + assertArraysEquals(r, a, (short)10, mask, ShortVector64Tests::MAX); } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort64VectorTests(IntFunction fa, IntFunction fb) { + static void MINShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3247,15 +3297,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::MIN); + assertArraysEquals(r, a, b, ShortVector64Tests::MIN); } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort64VectorTests(IntFunction fa, IntFunction fb) { + static void minShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3266,15 +3316,15 @@ public class Short64VectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::min); + assertArraysEquals(r, a, b, ShortVector64Tests::min); } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort64VectorTests(IntFunction fa, IntFunction fb) { + static void MAXShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3287,15 +3337,15 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::MAX); + assertArraysEquals(r, a, b, ShortVector64Tests::MAX); } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maxShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3306,7 +3356,7 @@ public class Short64VectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, Short64VectorTests::max); + assertArraysEquals(r, a, b, ShortVector64Tests::max); } static short UMIN(short a, short b) { @@ -3314,7 +3364,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMINShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UMINShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3327,11 +3377,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::UMIN); + assertArraysEquals(r, a, b, ShortVector64Tests::UMIN); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMINShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3347,7 +3397,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::UMIN); } static short UMAX(short a, short b) { @@ -3355,7 +3405,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMAXShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UMAXShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3368,11 +3418,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::UMAX); + assertArraysEquals(r, a, b, ShortVector64Tests::UMAX); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMAXShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3388,7 +3438,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::UMAX); } static short SADD(short a, short b) { @@ -3396,7 +3446,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SADDShort64VectorTests(IntFunction fa, IntFunction fb) { + static void SADDShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3409,11 +3459,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::SADD); + assertArraysEquals(r, a, b, ShortVector64Tests::SADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SADDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3429,7 +3479,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::SADD); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::SADD); } static short SSUB(short a, short b) { @@ -3437,7 +3487,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SSUBShort64VectorTests(IntFunction fa, IntFunction fb) { + static void SSUBShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3450,11 +3500,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::SSUB); + assertArraysEquals(r, a, b, ShortVector64Tests::SSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SSUBShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3470,7 +3520,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::SSUB); } static short SUADD(short a, short b) { @@ -3478,7 +3528,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUADDShort64VectorTests(IntFunction fa, IntFunction fb) { + static void SUADDShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3491,11 +3541,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::SUADD); + assertArraysEquals(r, a, b, ShortVector64Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUADDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3511,7 +3561,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::SUADD); } static short SUSUB(short a, short b) { @@ -3519,7 +3569,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUSUBShort64VectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3532,11 +3582,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::SUSUB); + assertArraysEquals(r, a, b, ShortVector64Tests::SUSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUSUBShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3552,11 +3602,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::SUSUB); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3566,11 +3616,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3580,11 +3630,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::min); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3594,11 +3644,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3608,10 +3658,10 @@ public class Short64VectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, Short64VectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortVector64Tests::max); } @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider") - static void SUADDAssocShort64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocShortVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -3628,11 +3678,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, Short64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ShortVector64Tests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3653,13 +3703,13 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Short64VectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortVector64Tests::SUADD); } static short ANDReduce(short[] a, int idx) { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3668,14 +3718,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ANDReduceAll(short[] a) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ANDReduceShort64VectorTests(IntFunction fa) { + static void ANDReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3686,12 +3736,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::ANDReduce, Short64VectorTests::ANDReduceAll); + ShortVector64Tests::ANDReduce, ShortVector64Tests::ANDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3699,20 +3749,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = AND_IDENTITY; - assertEquals((short) (id & id), id, + assertEquals((short) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id & x), x); - assertEquals((short) (x & id), x); + assertEquals((short) (scalar_and(id, x)), x); + assertEquals((short) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id & x), x, + assertEquals((short) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x & id), x, + assertEquals((short) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3721,7 +3771,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3730,14 +3780,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ANDReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3750,18 +3800,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::ANDReduceMasked, Short64VectorTests::ANDReduceAllMasked); + ShortVector64Tests::ANDReduceMasked, ShortVector64Tests::ANDReduceAllMasked); } static short ORReduce(short[] a, int idx) { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3770,14 +3820,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ORReduceAll(short[] a) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ORReduceShort64VectorTests(IntFunction fa) { + static void ORReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3788,12 +3838,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::ORReduce, Short64VectorTests::ORReduceAll); + ShortVector64Tests::ORReduce, ShortVector64Tests::ORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3801,20 +3851,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = OR_IDENTITY; - assertEquals((short) (id | id), id, + assertEquals((short) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id | x), x); - assertEquals((short) (x | id), x); + assertEquals((short) (scalar_or(id, x)), x); + assertEquals((short) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id | x), x, + assertEquals((short) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x | id), x, + assertEquals((short) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3823,7 +3873,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3832,14 +3882,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ORReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3852,18 +3902,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::ORReduceMasked, Short64VectorTests::ORReduceAllMasked); + ShortVector64Tests::ORReduceMasked, ShortVector64Tests::ORReduceAllMasked); } static short XORReduce(short[] a, int idx) { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3872,14 +3922,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short XORReduceAll(short[] a) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void XORReduceShort64VectorTests(IntFunction fa) { + static void XORReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3890,12 +3940,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::XORReduce, Short64VectorTests::XORReduceAll); + ShortVector64Tests::XORReduce, ShortVector64Tests::XORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3903,20 +3953,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = XOR_IDENTITY; - assertEquals((short) (id ^ id), id, + assertEquals((short) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id ^ x), x); - assertEquals((short) (x ^ id), x); + assertEquals((short) (scalar_xor(id, x)), x); + assertEquals((short) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id ^ x), x, + assertEquals((short) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x ^ id), x, + assertEquals((short) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3925,7 +3975,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3934,14 +3984,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void XORReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3954,18 +4004,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::XORReduceMasked, Short64VectorTests::XORReduceAllMasked); + ShortVector64Tests::XORReduceMasked, ShortVector64Tests::XORReduceAllMasked); } static short ADDReduce(short[] a, int idx) { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3974,14 +4024,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ADDReduceAll(short[] a) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceShort64VectorTests(IntFunction fa) { + static void ADDReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3992,12 +4042,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::ADDReduce, Short64VectorTests::ADDReduceAll); + ShortVector64Tests::ADDReduce, ShortVector64Tests::ADDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4005,20 +4055,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = ADD_IDENTITY; - assertEquals((short) (id + id), id, + assertEquals((short) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id + x), x); - assertEquals((short) (x + id), x); + assertEquals((short) (scalar_add(id, x)), x); + assertEquals((short) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id + x), x, + assertEquals((short) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x + id), x, + assertEquals((short) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4027,7 +4077,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4036,14 +4086,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short ADDReduceAllMasked(short[] a, boolean[] mask) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4056,18 +4106,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::ADDReduceMasked, Short64VectorTests::ADDReduceAllMasked); + ShortVector64Tests::ADDReduceMasked, ShortVector64Tests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4076,14 +4126,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MULReduceAll(short[] a) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MULReduceShort64VectorTests(IntFunction fa) { + static void MULReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4094,12 +4144,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::MULReduce, Short64VectorTests::MULReduceAll); + ShortVector64Tests::MULReduce, ShortVector64Tests::MULReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4107,20 +4157,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MUL_IDENTITY; - assertEquals((short) (id * id), id, + assertEquals((short) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id * x), x); - assertEquals((short) (x * id), x); + assertEquals((short) (scalar_mul(id, x)), x); + assertEquals((short) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id * x), x, + assertEquals((short) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x * id), x, + assertEquals((short) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4129,7 +4179,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4138,14 +4188,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MULReduceAllMasked(short[] a, boolean[] mask) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MULReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4158,18 +4208,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::MULReduceMasked, Short64VectorTests::MULReduceAllMasked); + ShortVector64Tests::MULReduceMasked, ShortVector64Tests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4178,14 +4228,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MINReduceAll(short[] a) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MINReduceShort64VectorTests(IntFunction fa) { + static void MINReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4196,12 +4246,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::MINReduce, Short64VectorTests::MINReduceAll); + ShortVector64Tests::MINReduce, ShortVector64Tests::MINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4209,20 +4259,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MIN_IDENTITY; - assertEquals((short) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.min(id, x), x); - assertEquals((short) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4231,7 +4281,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4240,14 +4290,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MINReduceAllMasked(short[] a, boolean[] mask) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4260,18 +4310,18 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::MINReduceMasked, Short64VectorTests::MINReduceAllMasked); + ShortVector64Tests::MINReduceMasked, ShortVector64Tests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4280,14 +4330,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MAXReduceAll(short[] a) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MAXReduceShort64VectorTests(IntFunction fa) { + static void MAXReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4298,12 +4348,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::MAXReduce, Short64VectorTests::MAXReduceAll); + ShortVector64Tests::MAXReduce, ShortVector64Tests::MAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4311,20 +4361,20 @@ public class Short64VectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MAX_IDENTITY; - assertEquals((short) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.max(id, x), x); - assertEquals((short) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4333,7 +4383,7 @@ public class Short64VectorTests extends AbstractVectorTest { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4342,14 +4392,14 @@ public class Short64VectorTests extends AbstractVectorTest { static short MAXReduceAllMasked(short[] a, boolean[] mask) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4362,12 +4412,12 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::MAXReduceMasked, Short64VectorTests::MAXReduceAllMasked); + ShortVector64Tests::MAXReduceMasked, ShortVector64Tests::MAXReduceAllMasked); } static short UMINReduce(short[] a, int idx) { @@ -4389,7 +4439,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMINReduceShort64VectorTests(IntFunction fa) { + static void UMINReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4405,7 +4455,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::UMINReduce, Short64VectorTests::UMINReduceAll); + ShortVector64Tests::UMINReduce, ShortVector64Tests::UMINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4451,7 +4501,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMINReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4469,7 +4519,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::UMINReduceMasked, Short64VectorTests::UMINReduceAllMasked); + ShortVector64Tests::UMINReduceMasked, ShortVector64Tests::UMINReduceAllMasked); } static short UMAXReduce(short[] a, int idx) { @@ -4491,7 +4541,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMAXReduceShort64VectorTests(IntFunction fa) { + static void UMAXReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4507,7 +4557,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::UMAXReduce, Short64VectorTests::UMAXReduceAll); + ShortVector64Tests::UMAXReduce, ShortVector64Tests::UMAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4553,7 +4603,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4571,7 +4621,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::UMAXReduceMasked, Short64VectorTests::UMAXReduceAllMasked); + ShortVector64Tests::UMAXReduceMasked, ShortVector64Tests::UMAXReduceAllMasked); } static short FIRST_NONZEROReduce(short[] a, int idx) { @@ -4593,7 +4643,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void FIRST_NONZEROReduceShort64VectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4609,7 +4659,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::FIRST_NONZEROReduce, Short64VectorTests::FIRST_NONZEROReduceAll); + ShortVector64Tests::FIRST_NONZEROReduce, ShortVector64Tests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4655,7 +4705,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void FIRST_NONZEROReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4673,7 +4723,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::FIRST_NONZEROReduceMasked, Short64VectorTests::FIRST_NONZEROReduceAllMasked); + ShortVector64Tests::FIRST_NONZEROReduceMasked, ShortVector64Tests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4686,7 +4736,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueShort64VectorTests(IntFunction fm) { + static void anyTrueShortVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4697,7 +4747,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short64VectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector64Tests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4710,7 +4760,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueShort64VectorTests(IntFunction fm) { + static void allTrueShortVector64Tests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4721,7 +4771,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, Short64VectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortVector64Tests::allTrue); } static short SUADDReduce(short[] a, int idx) { @@ -4743,7 +4793,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingUnaryOpProvider") - static void SUADDReduceShort64VectorTests(IntFunction fa) { + static void SUADDReduceShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4759,7 +4809,7 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - Short64VectorTests::SUADDReduce, Short64VectorTests::SUADDReduceAll); + ShortVector64Tests::SUADDReduce, ShortVector64Tests::SUADDReduceAll); } @Test(dataProvider = "shortSaturatingUnaryOpProvider") @@ -4804,7 +4854,7 @@ public class Short64VectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider") - static void SUADDReduceShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4822,11 +4872,11 @@ public class Short64VectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::SUADDReduceMasked, Short64VectorTests::SUADDReduceAllMasked); + ShortVector64Tests::SUADDReduceMasked, ShortVector64Tests::SUADDReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void withShort64VectorTests(IntFunction fa, IntFunction fb) { + static void withShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -4849,7 +4899,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_DEFAULTShort64VectorTests(IntFunction fa) { + static void IS_DEFAULTShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4866,7 +4916,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_DEFAULTMaskedShort64VectorTests(IntFunction fa, + static void IS_DEFAULTMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4890,7 +4940,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_NEGATIVEShort64VectorTests(IntFunction fa) { + static void IS_NEGATIVEShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4907,7 +4957,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_NEGATIVEMaskedShort64VectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4927,7 +4977,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void LTShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4946,7 +4996,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ltShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4965,7 +5015,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4988,7 +5038,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void GTShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5007,7 +5057,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5030,7 +5080,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort64VectorTests(IntFunction fa, IntFunction fb) { + static void EQShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5049,7 +5099,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort64VectorTests(IntFunction fa, IntFunction fb) { + static void eqShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5068,7 +5118,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5091,7 +5141,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void NEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void NEShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5110,7 +5160,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void NEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5133,7 +5183,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void LEShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5152,7 +5202,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5175,7 +5225,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void GEShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5194,7 +5244,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5217,7 +5267,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ULTShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5236,7 +5286,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5259,7 +5309,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5278,7 +5328,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5301,7 +5351,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5320,7 +5370,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5343,7 +5393,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortVector64Tests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5362,7 +5412,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5385,7 +5435,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5395,13 +5445,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5415,13 +5465,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void LTShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5431,13 +5481,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTShortVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5451,13 +5501,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (short)((long)b[i])))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5467,13 +5517,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5487,13 +5537,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5503,13 +5553,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQShortVector64TestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5523,7 +5573,7 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (short)((long)b[i])))); } } } @@ -5533,7 +5583,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort64VectorTests(IntFunction fa, IntFunction fb, + static void blendShortVector64Tests(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5549,11 +5599,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, Short64VectorTests::blend); + assertArraysEquals(r, a, b, mask, ShortVector64Tests::blend); } @Test(dataProvider = "shortUnaryOpShuffleProvider") - static void RearrangeShort64VectorTests(IntFunction fa, + static void RearrangeShortVector64Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5570,7 +5620,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") - static void RearrangeShort64VectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeShortVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -5588,7 +5638,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void compressShort64VectorTests(IntFunction fa, + static void compressShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5606,7 +5656,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void expandShort64VectorTests(IntFunction fa, + static void expandShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5624,7 +5674,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void getShort64VectorTests(IntFunction fa) { + static void getShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5780,7 +5830,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastShort64VectorTests(IntFunction fa) { + static void BroadcastShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5794,7 +5844,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZeroShort64VectorTests(IntFunction fa) { + static void ZeroShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5819,7 +5869,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void sliceUnaryShort64VectorTests(IntFunction fa) { + static void sliceUnaryShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5830,7 +5880,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short64VectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortVector64Tests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { @@ -5847,7 +5897,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void sliceBinaryShort64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryShortVector64TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5860,7 +5910,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, Short64VectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortVector64Tests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { @@ -5877,7 +5927,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void sliceShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5894,7 +5944,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, Short64VectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortVector64Tests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { @@ -5911,7 +5961,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void unsliceUnaryShort64VectorTests(IntFunction fa) { + static void unsliceUnaryShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5922,7 +5972,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, Short64VectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortVector64Tests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { @@ -5948,7 +5998,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void unsliceBinaryShort64VectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryShortVector64TestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5962,7 +6012,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, Short64VectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortVector64Tests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { @@ -6002,7 +6052,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void unsliceShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6019,7 +6069,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, Short64VectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortVector64Tests::unslice); } static short BITWISE_BLEND(short a, short b, short c) { @@ -6031,7 +6081,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6046,11 +6096,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6063,11 +6113,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortVector64Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector64TestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6085,11 +6135,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6100,11 +6150,11 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6115,11 +6165,11 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6130,11 +6180,11 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector64TestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6145,11 +6195,11 @@ public class Short64VectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6164,11 +6214,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector64TestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6183,11 +6233,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShort64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6198,11 +6248,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShort64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVector64TestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6213,11 +6263,11 @@ public class Short64VectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVector64Tests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShort64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVector64TestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6231,19 +6281,19 @@ public class Short64VectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortVector64Tests::BITWISE_BLEND); } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void NEGShort64VectorTests(IntFunction fa) { + static void NEGShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6254,11 +6304,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::NEG); + assertArraysEquals(r, a, ShortVector64Tests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") - static void negShort64VectorTests(IntFunction fa) { + static void negShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6269,11 +6319,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::neg); + assertArraysEquals(r, a, ShortVector64Tests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedShort64VectorTests(IntFunction fa, + static void NEGMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6287,19 +6337,19 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::NEG); + assertArraysEquals(r, a, mask, ShortVector64Tests::NEG); } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void ABSShort64VectorTests(IntFunction fa) { + static void ABSShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6310,11 +6360,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::ABS); + assertArraysEquals(r, a, ShortVector64Tests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") - static void absShort64VectorTests(IntFunction fa) { + static void absShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6325,11 +6375,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::abs); + assertArraysEquals(r, a, ShortVector64Tests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedShort64VectorTests(IntFunction fa, + static void ABSMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6343,7 +6393,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::ABS); + assertArraysEquals(r, a, mask, ShortVector64Tests::ABS); } static short NOT(short a) { @@ -6355,7 +6405,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void NOTShort64VectorTests(IntFunction fa) { + static void NOTShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6366,11 +6416,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::NOT); + assertArraysEquals(r, a, ShortVector64Tests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") - static void notShort64VectorTests(IntFunction fa) { + static void notShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6381,11 +6431,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::not); + assertArraysEquals(r, a, ShortVector64Tests::not); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NOTMaskedShort64VectorTests(IntFunction fa, + static void NOTMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6399,7 +6449,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::NOT); + assertArraysEquals(r, a, mask, ShortVector64Tests::NOT); } static short ZOMO(short a) { @@ -6407,7 +6457,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZOMOShort64VectorTests(IntFunction fa) { + static void ZOMOShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6418,11 +6468,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::ZOMO); + assertArraysEquals(r, a, ShortVector64Tests::ZOMO); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ZOMOMaskedShort64VectorTests(IntFunction fa, + static void ZOMOMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6436,7 +6486,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortVector64Tests::ZOMO); } static short BIT_COUNT(short a) { @@ -6444,7 +6494,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BIT_COUNTShort64VectorTests(IntFunction fa) { + static void BIT_COUNTShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6455,11 +6505,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, ShortVector64Tests::BIT_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void BIT_COUNTMaskedShort64VectorTests(IntFunction fa, + static void BIT_COUNTMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6473,7 +6523,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ShortVector64Tests::BIT_COUNT); } static short TRAILING_ZEROS_COUNT(short a) { @@ -6481,7 +6531,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void TRAILING_ZEROS_COUNTShort64VectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6492,11 +6542,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector64Tests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedShort64VectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6510,7 +6560,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector64Tests::TRAILING_ZEROS_COUNT); } static short LEADING_ZEROS_COUNT(short a) { @@ -6518,7 +6568,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LEADING_ZEROS_COUNTShort64VectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6529,11 +6579,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVector64Tests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedShort64VectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6547,7 +6597,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVector64Tests::LEADING_ZEROS_COUNT); } static short REVERSE(short a) { @@ -6555,7 +6605,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSEShort64VectorTests(IntFunction fa) { + static void REVERSEShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6566,11 +6616,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::REVERSE); + assertArraysEquals(r, a, ShortVector64Tests::REVERSE); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSEMaskedShort64VectorTests(IntFunction fa, + static void REVERSEMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6584,7 +6634,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::REVERSE); + assertArraysEquals(r, a, mask, ShortVector64Tests::REVERSE); } static short REVERSE_BYTES(short a) { @@ -6592,7 +6642,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSE_BYTESShort64VectorTests(IntFunction fa) { + static void REVERSE_BYTESShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6603,11 +6653,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ShortVector64Tests::REVERSE_BYTES); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedShort64VectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedShortVector64Tests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6621,7 +6671,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, Short64VectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ShortVector64Tests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6629,7 +6679,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6642,7 +6692,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::band); + assertArraysEquals(r, a, b, ShortVector64Tests::band); } static boolean bor(boolean a, boolean b) { @@ -6650,7 +6700,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskorShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6663,7 +6713,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::bor); + assertArraysEquals(r, a, b, ShortVector64Tests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6671,7 +6721,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskxorShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6684,7 +6734,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::bxor); + assertArraysEquals(r, a, b, ShortVector64Tests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6692,7 +6742,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6705,7 +6755,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::bandNot); + assertArraysEquals(r, a, b, ShortVector64Tests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6713,7 +6763,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskeqShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6726,7 +6776,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, Short64VectorTests::beq); + assertArraysEquals(r, a, b, ShortVector64Tests::beq); } static boolean unot(boolean a) { @@ -6734,7 +6784,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotShort64VectorTests(IntFunction fa) { + static void masknotShortVector64Tests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6745,7 +6795,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::unot); + assertArraysEquals(r, a, ShortVector64Tests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6762,7 +6812,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongShort64VectorTests(IntFunction fa) { + static void maskFromToLongShortVector64Tests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6776,7 +6826,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltShortVector64TestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6786,13 +6836,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpProvider") - static void eqShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqShortVector64TestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6802,13 +6852,13 @@ public class Short64VectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortUnaryOpProvider") - static void toIntArrayShort64VectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6819,7 +6869,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toLongArrayShort64VectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6830,7 +6880,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toDoubleArrayShort64VectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6841,7 +6891,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toStringShort64VectorTestsSmokeTest(IntFunction fa) { + static void toStringShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6854,7 +6904,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void hashCodeShort64VectorTestsSmokeTest(IntFunction fa) { + static void hashCodeShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6871,7 +6921,7 @@ public class Short64VectorTests extends AbstractVectorTest { static long ADDReduceLong(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6880,14 +6930,14 @@ public class Short64VectorTests extends AbstractVectorTest { static long ADDReduceAllLong(short[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((short)res, (short)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceLongShort64VectorTests(IntFunction fa) { + static void ADDReduceLongShortVector64Tests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6898,19 +6948,20 @@ public class Short64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEquals(r, ra, a, - Short64VectorTests::ADDReduceLong, Short64VectorTests::ADDReduceAllLong); + ShortVector64Tests::ADDReduceLong, ShortVector64Tests::ADDReduceAllLong); } static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6919,14 +6970,14 @@ public class Short64VectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((short)res, (short)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceLongShort64VectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongShortVector64TestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6939,16 +6990,16 @@ public class Short64VectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - Short64VectorTests::ADDReduceLongMasked, Short64VectorTests::ADDReduceAllLongMasked); + ShortVector64Tests::ADDReduceLongMasked, ShortVector64Tests::ADDReduceAllLongMasked); } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastLongShort64VectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongShortVector64TestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -6959,7 +7010,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendShortVector64TestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6973,12 +7024,12 @@ public class Short64VectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVector64Tests::blend); } @Test(dataProvider = "shortUnaryOpSelectFromProvider") - static void SelectFromShort64VectorTests(IntFunction fa, + static void SelectFromShortVector64Tests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); short[] order = fs.apply(a.length, SPECIES.length()); @@ -6994,7 +7045,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorShort64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorShortVector64Tests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] idx = fc.apply(SPECIES.length()); @@ -7012,7 +7063,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") - static void SelectFromShort64VectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromShortVector64TestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -7031,7 +7082,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousShort64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousShortVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7047,7 +7098,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringShort64VectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringShortVector64TestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7061,7 +7112,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsShort64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsShortVector64TestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7075,7 +7126,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsShort64VectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsShortVector64Tests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7091,7 +7142,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeShort64VectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeShortVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7113,7 +7164,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountShort64VectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountShortVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7124,7 +7175,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ShortVector64Tests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7138,7 +7189,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueShort64VectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueShortVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7149,7 +7200,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ShortVector64Tests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7163,7 +7214,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueShort64VectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueShortVector64TestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7174,11 +7225,11 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ShortVector64Tests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressShort64VectorTestsSmokeTest(IntFunction fa) { + static void maskCompressShortVector64TestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7206,7 +7257,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeShort64VectorTestsSmokeTest(int offset) { + static void indexInRangeShortVector64TestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7220,7 +7271,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongShort64VectorTestsSmokeTest(int offset) { + static void indexInRangeLongShortVector64TestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7247,14 +7298,14 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundShort64VectorTestsSmokeTest(int length) { + static void loopBoundShortVector64TestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongShort64VectorTestsSmokeTest(int _length) { + static void loopBoundLongShortVector64TestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7262,21 +7313,21 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test - static void ElementSizeShort64VectorTestsSmokeTest() { + static void ElementSizeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Short.SIZE); } @Test - static void VectorShapeShort64VectorTestsSmokeTest() { + static void VectorShapeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_64_BIT)); } @Test - static void ShapeWithLanesShort64VectorTestsSmokeTest() { + static void ShapeWithLanesShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(short.class); @@ -7284,32 +7335,32 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test - static void ElementTypeShort64VectorTestsSmokeTest() { + static void ElementTypeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementType() == short.class); } @Test - static void SpeciesElementSizeShort64VectorTestsSmokeTest() { + static void SpeciesElementSizeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementSize() == Short.SIZE); } @Test - static void VectorTypeShort64VectorTestsSmokeTest() { + static void VectorTypeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesShort64VectorTestsSmokeTest() { + static void WithLanesShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(short.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeShort64VectorTestsSmokeTest() { + static void WithShapeShortVector64TestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7317,7 +7368,7 @@ public class Short64VectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueShort64VectorTestsSmokeTest() { + static void MaskAllTrueShortVector64TestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortVectorMaxLoadStoreTests.java similarity index 99% rename from test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java rename to test/jdk/jdk/incubator/vector/ShortVectorMaxLoadStoreTests.java index ebed7dd0226..24683f1e5d7 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVectorMaxLoadStoreTests.java @@ -28,7 +28,7 @@ * @library /test/lib * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:-TieredCompilation ShortMaxVectorLoadStoreTests + * -XX:-TieredCompilation ShortVectorMaxLoadStoreTests * */ @@ -52,7 +52,7 @@ import java.util.List; import java.util.function.*; @Test -public class ShortMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { +public class ShortVectorMaxLoadStoreTests extends AbstractVectorLoadStoreTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_MAX; diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java similarity index 88% rename from test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java rename to test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java index f71cf3ca322..5451ad6c50e 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortVectorMaxTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Test -public class ShortMaxVectorTests extends AbstractVectorTest { +public class ShortVectorMaxTests extends AbstractVectorTest { static final VectorSpecies SPECIES = ShortVector.SPECIES_MAX; @@ -1571,6 +1571,59 @@ public class ShortMaxVectorTests extends AbstractVectorTest { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1587,9 +1640,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; - } @Test static void smokeTest1() { @@ -1698,11 +1748,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ADDShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1715,15 +1765,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::ADD); + assertArraysEquals(r, a, b, ShortVectorMaxTests::ADD); } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1734,11 +1784,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.add(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::add); + assertArraysEquals(r, a, b, ShortVectorMaxTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ADDShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1754,11 +1804,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1772,15 +1822,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.add(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::add); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::add); } static short SUB(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void SUBShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUBShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1793,15 +1843,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::SUB); + assertArraysEquals(r, a, b, ShortVectorMaxTests::SUB); } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void subShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1812,11 +1862,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.sub(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::sub); + assertArraysEquals(r, a, b, ShortVectorMaxTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void SUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUBShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1832,11 +1882,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUB); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::SUB); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void subShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1850,15 +1900,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.sub(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::sub); } static short MUL(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MULShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MULShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1871,15 +1921,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::MUL); + assertArraysEquals(r, a, b, ShortVectorMaxTests::MUL); } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void mulShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1890,11 +1940,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.mul(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::mul); + assertArraysEquals(r, a, b, ShortVectorMaxTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MULShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void MULShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1910,11 +1960,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::MUL); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::MUL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void mulShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1928,7 +1978,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.mul(bv, vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::mul); } static short DIV(short a, short b) { @@ -1936,7 +1986,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void DIVShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void DIVShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1951,7 +2001,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::DIV); + assertArraysEquals(r, a, b, ShortVectorMaxTests::DIV); } static short div(short a, short b) { @@ -1959,7 +2009,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void divShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void divShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1974,11 +2024,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::div); + assertArraysEquals(r, a, b, ShortVectorMaxTests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void DIVShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void DIVShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1996,11 +2046,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::DIV); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::DIV); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void divShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2018,15 +2068,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::div); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::div); } static short FIRST_NONZERO(short a, short b) { - return (short)((a)!=0?a:b); + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void FIRST_NONZEROShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2039,11 +2089,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, ShortVectorMaxTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void FIRST_NONZEROShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void FIRST_NONZEROShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2059,7 +2109,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::FIRST_NONZERO); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::FIRST_NONZERO); } static short AND(short a, short b) { @@ -2067,7 +2117,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ANDShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2080,7 +2130,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::AND); + assertArraysEquals(r, a, b, ShortVectorMaxTests::AND); } static short and(short a, short b) { @@ -2088,7 +2138,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void andShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void andShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2099,11 +2149,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.and(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::and); + assertArraysEquals(r, a, b, ShortVectorMaxTests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ANDShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2119,7 +2169,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::AND); } static short AND_NOT(short a, short b) { @@ -2127,7 +2177,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void AND_NOTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void AND_NOTShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2140,11 +2190,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, ShortVectorMaxTests::AND_NOT); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void AND_NOTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void AND_NOTShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2160,7 +2210,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND_NOT); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::AND_NOT); } static short OR(short a, short b) { @@ -2168,7 +2218,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ORShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2181,7 +2231,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::OR); + assertArraysEquals(r, a, b, ShortVectorMaxTests::OR); } static short or(short a, short b) { @@ -2189,7 +2239,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void orShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void orShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2200,11 +2250,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.or(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::or); + assertArraysEquals(r, a, b, ShortVectorMaxTests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ORShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2220,7 +2270,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::OR); } static short XOR(short a, short b) { @@ -2228,7 +2278,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void XORShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void XORShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2241,11 +2291,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::XOR); + assertArraysEquals(r, a, b, ShortVectorMaxTests::XOR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void XORShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void XORShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2261,11 +2311,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::XOR); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::XOR); } @Test(dataProvider = "shortBinaryOpProvider") - static void addShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void addShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2275,11 +2325,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.add(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void addShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void addShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2292,11 +2342,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.add(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::add); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::add); } @Test(dataProvider = "shortBinaryOpProvider") - static void subShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void subShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2306,11 +2356,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.sub(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::sub); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void subShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void subShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2323,11 +2373,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.sub(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::sub); } @Test(dataProvider = "shortBinaryOpProvider") - static void mulShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void mulShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2337,11 +2387,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.mul(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::mul); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void mulShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void mulShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2354,11 +2404,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.mul(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::mul); } @Test(dataProvider = "shortBinaryOpProvider") - static void divShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void divShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2370,11 +2420,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.div(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::div); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void divShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void divShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2389,11 +2439,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.div(b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::div); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::div); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2403,11 +2453,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void orShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void orShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2417,11 +2467,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.or(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::or); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::or); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2434,11 +2484,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ANDShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ANDShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2448,11 +2498,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void andShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void andShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2462,11 +2512,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.and(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::and); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::and); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ANDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void ANDShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2479,11 +2529,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND); + assertBroadcastArraysEquals(r, a, b, mask, ShortVectorMaxTests::AND); } @Test(dataProvider = "shortBinaryOpProvider") - static void ORShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ORShortVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2493,11 +2543,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, ShortVectorMaxTests::OR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ORShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ORShortVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2510,11 +2560,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVectorMaxTests::OR); } @Test(dataProvider = "shortBinaryOpProvider") - static void ADDShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void ADDShortVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2524,11 +2574,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, ShortVectorMaxTests::ADD); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ADDShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + static void ADDShortVectorMaxTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2541,7 +2591,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVectorMaxTests::ADD); } static short LSHL(short a, short b) { @@ -2549,7 +2599,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHLShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2562,11 +2612,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, ShortVectorMaxTests::LSHL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2582,7 +2632,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::LSHL); } static short ASHR(short a, short b) { @@ -2590,7 +2640,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ASHRShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2603,11 +2653,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, ShortVectorMaxTests::ASHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2623,7 +2673,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::ASHR); } static short LSHR(short a, short b) { @@ -2631,7 +2681,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LSHRShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2644,11 +2694,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, ShortVectorMaxTests::LSHR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2664,7 +2714,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::LSHR); } static short LSHL_unary(short a, short b) { @@ -2672,7 +2722,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHLShortMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHLShortVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2684,11 +2734,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, ShortVectorMaxTests::LSHL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHLShortMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHLShortVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2703,7 +2753,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVectorMaxTests::LSHL_unary); } static short LSHR_unary(short a, short b) { @@ -2711,7 +2761,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void LSHRShortMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void LSHRShortVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2723,11 +2773,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, ShortVectorMaxTests::LSHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void LSHRShortMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void LSHRShortVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2742,7 +2792,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVectorMaxTests::LSHR_unary); } static short ASHR_unary(short a, short b) { @@ -2750,7 +2800,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ASHRShortMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ASHRShortVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2762,11 +2812,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, ShortVectorMaxTests::ASHR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ASHRShortMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ASHRShortVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2781,7 +2831,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVectorMaxTests::ASHR_unary); } static short ROR(short a, short b) { @@ -2789,7 +2839,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void RORShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2802,11 +2852,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::ROR); + assertArraysEquals(r, a, b, ShortVectorMaxTests::ROR); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void RORShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2822,7 +2872,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::ROR); } static short ROL(short a, short b) { @@ -2830,7 +2880,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ROLShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2843,11 +2893,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::ROL); + assertArraysEquals(r, a, b, ShortVectorMaxTests::ROL); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ROLShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2863,7 +2913,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::ROL); } static short ROR_unary(short a, short b) { @@ -2871,7 +2921,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void RORShortMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void RORShortVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2883,11 +2933,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, ShortVectorMaxTests::ROR_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void RORShortMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void RORShortVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2902,7 +2952,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVectorMaxTests::ROR_unary); } static short ROL_unary(short a, short b) { @@ -2910,7 +2960,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void ROLShortMaxVectorTestsScalarShift(IntFunction fa, IntFunction fb) { + static void ROLShortVectorMaxTestsScalarShift(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2922,11 +2972,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, ShortVectorMaxTests::ROL_unary); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void ROLShortMaxVectorTestsScalarShiftMasked(IntFunction fa, IntFunction fb, + static void ROLShortVectorMaxTestsScalarShiftMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -2941,14 +2991,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL_unary); + assertShiftArraysEquals(r, a, b, mask, ShortVectorMaxTests::ROL_unary); } static short LSHR_binary_const(short a) { return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHRShortMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHRShortVectorMaxTestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2959,11 +3009,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, ShortVectorMaxTests::LSHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHRShortVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2977,7 +3027,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVectorMaxTests::LSHR_binary_const); } static short LSHL_binary_const(short a) { @@ -2985,7 +3035,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LSHLShortMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void LSHLShortVectorMaxTestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -2996,11 +3046,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, ShortVectorMaxTests::LSHL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LSHLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void LSHLShortVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3014,7 +3064,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVectorMaxTests::LSHL_binary_const); } static short ASHR_binary_const(short a) { @@ -3022,7 +3072,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ASHRShortMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ASHRShortVectorMaxTestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3033,11 +3083,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ShortMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, ShortVectorMaxTests::ASHR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ASHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ASHRShortVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3051,7 +3101,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ASHR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVectorMaxTests::ASHR_binary_const); } static short ROR_binary_const(short a) { @@ -3059,7 +3109,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void RORShortMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void RORShortVectorMaxTestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3070,11 +3120,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ShortMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, ShortVectorMaxTests::ROR_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void RORShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void RORShortVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3088,7 +3138,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROR_binary_const); + assertShiftConstEquals(r, a, mask, ShortVectorMaxTests::ROR_binary_const); } static short ROL_binary_const(short a) { @@ -3096,7 +3146,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ROLShortMaxVectorTestsScalarShiftConst(IntFunction fa) { + static void ROLShortVectorMaxTestsScalarShiftConst(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3107,11 +3157,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, ShortMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, ShortVectorMaxTests::ROL_binary_const); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ROLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, + static void ROLShortVectorMaxTestsScalarShiftMaskedConst(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3125,14 +3175,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROL_binary_const); + assertShiftConstEquals(r, a, mask, ShortVectorMaxTests::ROL_binary_const); } static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MINShortMaxVectorTestsWithMemOp(IntFunction fa) { + static void MINShortVectorMaxTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3143,13 +3193,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MIN); + assertArraysEquals(r, a, (short)10, ShortVectorMaxTests::MIN); } static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void minShortMaxVectorTestsWithMemOp(IntFunction fa) { + static void minShortVectorMaxTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3160,13 +3210,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::min); + assertArraysEquals(r, a, (short)10, ShortVectorMaxTests::min); } static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MINShortVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3179,13 +3229,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, ShortMaxVectorTests::MIN); + assertArraysEquals(r, a, (short)10, mask, ShortVectorMaxTests::MIN); } static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void MAXShortMaxVectorTestsWithMemOp(IntFunction fa) { + static void MAXShortVectorMaxTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3196,13 +3246,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MAX); + assertArraysEquals(r, a, (short)10, ShortVectorMaxTests::MAX); } static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpProvider") - static void maxShortMaxVectorTestsWithMemOp(IntFunction fa) { + static void maxShortVectorMaxTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3213,13 +3263,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::max); + assertArraysEquals(r, a, (short)10, ShortVectorMaxTests::max); } static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { + static void MAXShortVectorMaxTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3232,15 +3282,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, (short)10, mask, ShortMaxVectorTests::MAX); + assertArraysEquals(r, a, (short)10, mask, ShortVectorMaxTests::MAX); } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MINShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3253,15 +3303,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::MIN); + assertArraysEquals(r, a, b, ShortVectorMaxTests::MIN); } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void minShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3272,15 +3322,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.min(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::min); + assertArraysEquals(r, a, b, ShortVectorMaxTests::min); } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void MAXShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3293,15 +3343,15 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::MAX); + assertArraysEquals(r, a, b, ShortVectorMaxTests::MAX); } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maxShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3312,7 +3362,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.max(bv).intoArray(r, i); } - assertArraysEquals(r, a, b, ShortMaxVectorTests::max); + assertArraysEquals(r, a, b, ShortVectorMaxTests::max); } static short UMIN(short a, short b) { @@ -3320,7 +3370,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMINShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMINShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3333,11 +3383,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, ShortVectorMaxTests::UMIN); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMINShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMINShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3353,7 +3403,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMIN); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::UMIN); } static short UMAX(short a, short b) { @@ -3361,7 +3411,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void UMAXShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UMAXShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3374,11 +3424,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, ShortVectorMaxTests::UMAX); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void UMAXShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UMAXShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3394,7 +3444,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMAX); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::UMAX); } static short SADD(short a, short b) { @@ -3402,7 +3452,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SADDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SADDShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3415,11 +3465,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::SADD); + assertArraysEquals(r, a, b, ShortVectorMaxTests::SADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SADDShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3435,7 +3485,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SADD); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::SADD); } static short SSUB(short a, short b) { @@ -3443,7 +3493,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SSUBShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SSUBShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3456,11 +3506,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, ShortVectorMaxTests::SSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SSUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SSUBShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3476,7 +3526,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SSUB); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::SSUB); } static short SUADD(short a, short b) { @@ -3484,7 +3534,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUADDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUADDShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3497,11 +3547,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, ShortVectorMaxTests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3517,7 +3567,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUADD); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::SUADD); } static short SUSUB(short a, short b) { @@ -3525,7 +3575,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingBinaryOpProvider") - static void SUSUBShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void SUSUBShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3538,11 +3588,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, ShortVectorMaxTests::SUSUB); } @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") - static void SUSUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUSUBShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3558,11 +3608,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUSUB); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::SUSUB); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MINShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3572,11 +3622,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::MIN); } @Test(dataProvider = "shortBinaryOpProvider") - static void minShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void minShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3586,11 +3636,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.min(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::min); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::min); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void MAXShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3600,11 +3650,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MAX); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::MAX); } @Test(dataProvider = "shortBinaryOpProvider") - static void maxShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void maxShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -3614,10 +3664,10 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.max(b[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::max); + assertBroadcastArraysEquals(r, a, b, ShortVectorMaxTests::max); } @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider") - static void SUADDAssocShortMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SUADDAssocShortVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -3634,11 +3684,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, ShortMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, ShortVectorMaxTests::SUADD); } @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider") - static void SUADDAssocShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void SUADDAssocShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -3659,13 +3709,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortMaxVectorTests::SUADD); + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortVectorMaxTests::SUADD); } static short ANDReduce(short[] a, int idx) { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3674,14 +3724,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ANDReduceAll(short[] a) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ANDReduceShortMaxVectorTests(IntFunction fa) { + static void ANDReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3692,12 +3742,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::ANDReduce, ShortMaxVectorTests::ANDReduceAll); + ShortVectorMaxTests::ANDReduce, ShortVectorMaxTests::ANDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3705,20 +3755,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = AND_IDENTITY; - assertEquals((short) (id & id), id, + assertEquals((short) (scalar_and(id, id)), id, "AND(AND_IDENTITY, AND_IDENTITY) != AND_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id & x), x); - assertEquals((short) (x & id), x); + assertEquals((short) (scalar_and(id, x)), x); + assertEquals((short) (scalar_and(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id & x), x, + assertEquals((short) (scalar_and(id, x)), x, "AND(AND_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x & id), x, + assertEquals((short) (scalar_and(x, id)), x, "AND(" + x + ", AND_IDENTITY) != " + x); } } @@ -3727,7 +3777,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = AND_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3736,14 +3786,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = AND_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ANDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ANDReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3756,18 +3806,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.AND, vmask); r[i] = v; - ra &= v; + ra = scalar_and(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::ANDReduceMasked, ShortMaxVectorTests::ANDReduceAllMasked); + ShortVectorMaxTests::ANDReduceMasked, ShortVectorMaxTests::ANDReduceAllMasked); } static short ORReduce(short[] a, int idx) { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3776,14 +3826,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ORReduceAll(short[] a) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ORReduceShortMaxVectorTests(IntFunction fa) { + static void ORReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3794,12 +3844,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::ORReduce, ShortMaxVectorTests::ORReduceAll); + ShortVectorMaxTests::ORReduce, ShortVectorMaxTests::ORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3807,20 +3857,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = OR_IDENTITY; - assertEquals((short) (id | id), id, + assertEquals((short) (scalar_or(id, id)), id, "OR(OR_IDENTITY, OR_IDENTITY) != OR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id | x), x); - assertEquals((short) (x | id), x); + assertEquals((short) (scalar_or(id, x)), x); + assertEquals((short) (scalar_or(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id | x), x, + assertEquals((short) (scalar_or(id, x)), x, "OR(OR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x | id), x, + assertEquals((short) (scalar_or(x, id)), x, "OR(" + x + ", OR_IDENTITY) != " + x); } } @@ -3829,7 +3879,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = OR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3838,14 +3888,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = OR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ORReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3858,18 +3908,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.OR, vmask); r[i] = v; - ra |= v; + ra = scalar_or(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::ORReduceMasked, ShortMaxVectorTests::ORReduceAllMasked); + ShortVectorMaxTests::ORReduceMasked, ShortVectorMaxTests::ORReduceAllMasked); } static short XORReduce(short[] a, int idx) { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3878,14 +3928,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short XORReduceAll(short[] a) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void XORReduceShortMaxVectorTests(IntFunction fa) { + static void XORReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3896,12 +3946,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::XORReduce, ShortMaxVectorTests::XORReduceAll); + ShortVectorMaxTests::XORReduce, ShortVectorMaxTests::XORReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -3909,20 +3959,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = XOR_IDENTITY; - assertEquals((short) (id ^ id), id, + assertEquals((short) (scalar_xor(id, id)), id, "XOR(XOR_IDENTITY, XOR_IDENTITY) != XOR_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id ^ x), x); - assertEquals((short) (x ^ id), x); + assertEquals((short) (scalar_xor(id, x)), x); + assertEquals((short) (scalar_xor(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id ^ x), x, + assertEquals((short) (scalar_xor(id, x)), x, "XOR(XOR_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x ^ id), x, + assertEquals((short) (scalar_xor(x, id)), x, "XOR(" + x + ", XOR_IDENTITY) != " + x); } } @@ -3931,7 +3981,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = XOR_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3940,14 +3990,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = XOR_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void XORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void XORReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -3960,18 +4010,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.XOR, vmask); r[i] = v; - ra ^= v; + ra = scalar_xor(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::XORReduceMasked, ShortMaxVectorTests::XORReduceAllMasked); + ShortVectorMaxTests::XORReduceMasked, ShortVectorMaxTests::XORReduceAllMasked); } static short ADDReduce(short[] a, int idx) { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -3980,14 +4030,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ADDReduceAll(short[] a) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceShortMaxVectorTests(IntFunction fa) { + static void ADDReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -3998,12 +4048,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::ADDReduce, ShortMaxVectorTests::ADDReduceAll); + ShortVectorMaxTests::ADDReduce, ShortVectorMaxTests::ADDReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4011,20 +4061,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = ADD_IDENTITY; - assertEquals((short) (id + id), id, + assertEquals((short) (scalar_add(id, id)), id, "ADD(ADD_IDENTITY, ADD_IDENTITY) != ADD_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id + x), x); - assertEquals((short) (x + id), x); + assertEquals((short) (scalar_add(id, x)), x); + assertEquals((short) (scalar_add(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id + x), x, + assertEquals((short) (scalar_add(id, x)), x, "ADD(ADD_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x + id), x, + assertEquals((short) (scalar_add(x, id)), x, "ADD(" + x + ", ADD_IDENTITY) != " + x); } } @@ -4033,7 +4083,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = ADD_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; @@ -4042,14 +4092,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short ADDReduceAllMasked(short[] a, boolean[] mask) { short res = ADD_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4062,18 +4112,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.ADD, vmask); r[i] = v; - ra += v; + ra = scalar_add(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::ADDReduceMasked, ShortMaxVectorTests::ADDReduceAllMasked); + ShortVectorMaxTests::ADDReduceMasked, ShortVectorMaxTests::ADDReduceAllMasked); } static short MULReduce(short[] a, int idx) { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4082,14 +4132,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MULReduceAll(short[] a) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MULReduceShortMaxVectorTests(IntFunction fa) { + static void MULReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4100,12 +4150,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::MULReduce, ShortMaxVectorTests::MULReduceAll); + ShortVectorMaxTests::MULReduce, ShortVectorMaxTests::MULReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4113,20 +4163,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MUL_IDENTITY; - assertEquals((short) (id * id), id, + assertEquals((short) (scalar_mul(id, id)), id, "MUL(MUL_IDENTITY, MUL_IDENTITY) != MUL_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) (id * x), x); - assertEquals((short) (x * id), x); + assertEquals((short) (scalar_mul(id, x)), x); + assertEquals((short) (scalar_mul(x, id)), x); } } catch (AssertionError e) { - assertEquals((short) (id * x), x, + assertEquals((short) (scalar_mul(id, x)), x, "MUL(MUL_IDENTITY, " + x + ") != " + x); - assertEquals((short) (x * id), x, + assertEquals((short) (scalar_mul(x, id)), x, "MUL(" + x + ", MUL_IDENTITY) != " + x); } } @@ -4135,7 +4185,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = MUL_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; @@ -4144,14 +4194,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MULReduceAllMasked(short[] a, boolean[] mask) { short res = MUL_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MULReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MULReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4164,18 +4214,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MUL, vmask); r[i] = v; - ra *= v; + ra = scalar_mul(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::MULReduceMasked, ShortMaxVectorTests::MULReduceAllMasked); + ShortVectorMaxTests::MULReduceMasked, ShortVectorMaxTests::MULReduceAllMasked); } static short MINReduce(short[] a, int idx) { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4184,14 +4234,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MINReduceAll(short[] a) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MINReduceShortMaxVectorTests(IntFunction fa) { + static void MINReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4202,12 +4252,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::MINReduce, ShortMaxVectorTests::MINReduceAll); + ShortVectorMaxTests::MINReduce, ShortVectorMaxTests::MINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4215,20 +4265,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MIN_IDENTITY; - assertEquals((short) Math.min(id, id), id, + assertEquals(scalar_min(id, id), id, "MIN(MIN_IDENTITY, MIN_IDENTITY) != MIN_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.min(id, x), x); - assertEquals((short) Math.min(x, id), x); + assertEquals(scalar_min(id, x), x); + assertEquals(scalar_min(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.min(id, x), x, + assertEquals(scalar_min(id, x), x, "MIN(MIN_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.min(x, id), x, + assertEquals(scalar_min(x, id), x, "MIN(" + x + ", MIN_IDENTITY) != " + x); } } @@ -4237,7 +4287,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = MIN_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; @@ -4246,14 +4296,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MINReduceAllMasked(short[] a, boolean[] mask) { short res = MIN_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MINReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4266,18 +4316,18 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MIN, vmask); r[i] = v; - ra = (short) Math.min(ra, v); + ra = scalar_min(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::MINReduceMasked, ShortMaxVectorTests::MINReduceAllMasked); + ShortVectorMaxTests::MINReduceMasked, ShortVectorMaxTests::MINReduceAllMasked); } static short MAXReduce(short[] a, int idx) { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4286,14 +4336,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MAXReduceAll(short[] a) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void MAXReduceShortMaxVectorTests(IntFunction fa) { + static void MAXReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4304,12 +4354,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::MAXReduce, ShortMaxVectorTests::MAXReduceAll); + ShortVectorMaxTests::MAXReduce, ShortVectorMaxTests::MAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4317,20 +4367,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short[] a = fa.apply(SPECIES.length()); short id = MAX_IDENTITY; - assertEquals((short) Math.max(id, id), id, + assertEquals(scalar_max(id, id), id, "MAX(MAX_IDENTITY, MAX_IDENTITY) != MAX_IDENTITY"); short x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals((short) Math.max(id, x), x); - assertEquals((short) Math.max(x, id), x); + assertEquals(scalar_max(id, x), x); + assertEquals(scalar_max(x, id), x); } } catch (AssertionError e) { - assertEquals((short) Math.max(id, x), x, + assertEquals(scalar_max(id, x), x, "MAX(MAX_IDENTITY, " + x + ") != " + x); - assertEquals((short) Math.max(x, id), x, + assertEquals(scalar_max(x, id), x, "MAX(" + x + ", MAX_IDENTITY) != " + x); } } @@ -4339,7 +4389,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { short res = MAX_IDENTITY; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; @@ -4348,14 +4398,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static short MAXReduceAllMasked(short[] a, boolean[] mask) { short res = MAX_IDENTITY; for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void MAXReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4368,12 +4418,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector av = ShortVector.fromArray(SPECIES, a, i); short v = av.reduceLanes(VectorOperators.MAX, vmask); r[i] = v; - ra = (short) Math.max(ra, v); + ra = scalar_max(ra, v); } } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked); + ShortVectorMaxTests::MAXReduceMasked, ShortVectorMaxTests::MAXReduceAllMasked); } static short UMINReduce(short[] a, int idx) { @@ -4395,7 +4445,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMINReduceShortMaxVectorTests(IntFunction fa) { + static void UMINReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4411,7 +4461,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::UMINReduce, ShortMaxVectorTests::UMINReduceAll); + ShortVectorMaxTests::UMINReduce, ShortVectorMaxTests::UMINReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4457,7 +4507,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMINReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4475,7 +4525,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::UMINReduceMasked, ShortMaxVectorTests::UMINReduceAllMasked); + ShortVectorMaxTests::UMINReduceMasked, ShortVectorMaxTests::UMINReduceAllMasked); } static short UMAXReduce(short[] a, int idx) { @@ -4497,7 +4547,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void UMAXReduceShortMaxVectorTests(IntFunction fa) { + static void UMAXReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4513,7 +4563,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::UMAXReduce, ShortMaxVectorTests::UMAXReduceAll); + ShortVectorMaxTests::UMAXReduce, ShortVectorMaxTests::UMAXReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4559,7 +4609,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void UMAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void UMAXReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4577,7 +4627,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::UMAXReduceMasked, ShortMaxVectorTests::UMAXReduceAllMasked); + ShortVectorMaxTests::UMAXReduceMasked, ShortVectorMaxTests::UMAXReduceAllMasked); } static short FIRST_NONZEROReduce(short[] a, int idx) { @@ -4599,7 +4649,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction fa) { + static void FIRST_NONZEROReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4615,7 +4665,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::FIRST_NONZEROReduce, ShortMaxVectorTests::FIRST_NONZEROReduceAll); + ShortVectorMaxTests::FIRST_NONZEROReduce, ShortVectorMaxTests::FIRST_NONZEROReduceAll); } @Test(dataProvider = "shortUnaryOpProvider") @@ -4661,7 +4711,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void FIRST_NONZEROReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void FIRST_NONZEROReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4679,7 +4729,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::FIRST_NONZEROReduceMasked, ShortMaxVectorTests::FIRST_NONZEROReduceAllMasked); + ShortVectorMaxTests::FIRST_NONZEROReduceMasked, ShortVectorMaxTests::FIRST_NONZEROReduceAllMasked); } static boolean anyTrue(boolean[] a, int idx) { @@ -4692,7 +4742,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void anyTrueShortMaxVectorTests(IntFunction fm) { + static void anyTrueShortVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4703,7 +4753,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::anyTrue); + assertReductionBoolArraysEquals(r, mask, ShortVectorMaxTests::anyTrue); } static boolean allTrue(boolean[] a, int idx) { @@ -4716,7 +4766,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolUnaryOpProvider") - static void allTrueShortMaxVectorTests(IntFunction fm) { + static void allTrueShortVectorMaxTests(IntFunction fm) { boolean[] mask = fm.apply(SPECIES.length()); boolean[] r = fmr.apply(SPECIES.length()); @@ -4727,7 +4777,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue); + assertReductionBoolArraysEquals(r, mask, ShortVectorMaxTests::allTrue); } static short SUADDReduce(short[] a, int idx) { @@ -4749,7 +4799,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSaturatingUnaryOpProvider") - static void SUADDReduceShortMaxVectorTests(IntFunction fa) { + static void SUADDReduceShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); short ra = 0; @@ -4765,7 +4815,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEquals(r, ra, a, - ShortMaxVectorTests::SUADDReduce, ShortMaxVectorTests::SUADDReduceAll); + ShortVectorMaxTests::SUADDReduce, ShortVectorMaxTests::SUADDReduceAll); } @Test(dataProvider = "shortSaturatingUnaryOpProvider") @@ -4810,7 +4860,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { return res; } @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider") - static void SUADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void SUADDReduceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4828,11 +4878,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } assertReductionArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::SUADDReduceMasked, ShortMaxVectorTests::SUADDReduceAllMasked); + ShortVectorMaxTests::SUADDReduceMasked, ShortVectorMaxTests::SUADDReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void withShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -4855,7 +4905,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_DEFAULTShortMaxVectorTests(IntFunction fa) { + static void IS_DEFAULTShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4872,7 +4922,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_DEFAULTMaskedShortMaxVectorTests(IntFunction fa, + static void IS_DEFAULTMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4896,7 +4946,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpProvider") - static void IS_NEGATIVEShortMaxVectorTests(IntFunction fa) { + static void IS_NEGATIVEShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -4913,7 +4963,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTestOpMaskProvider") - static void IS_NEGATIVEMaskedShortMaxVectorTests(IntFunction fa, + static void IS_NEGATIVEMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -4933,7 +4983,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LTShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4952,7 +5002,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ltShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4971,7 +5021,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LTShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4994,7 +5044,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GTShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5013,7 +5063,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GTShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5036,7 +5086,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void EQShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void EQShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5055,7 +5105,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void eqShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void eqShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5074,7 +5124,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void EQShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5097,7 +5147,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void NEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void NEShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5116,7 +5166,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void NEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void NEShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5139,7 +5189,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void LEShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5158,7 +5208,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void LEShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5181,7 +5231,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void GEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void GEShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5200,7 +5250,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void GEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void GEShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5223,7 +5273,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULTShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5242,7 +5292,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5265,7 +5315,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5284,7 +5334,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5307,7 +5357,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ULEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5326,7 +5376,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void ULEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5349,7 +5399,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void UGEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortVectorMaxTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5368,7 +5418,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UGEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5391,7 +5441,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void LTShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5401,13 +5451,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void LTShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5421,13 +5471,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void LTShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void LTShortVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5437,13 +5487,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void LTShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void LTShortVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5457,13 +5507,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], (short)((long)b[i])))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5473,13 +5523,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + static void EQShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5493,13 +5543,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @Test(dataProvider = "shortCompareOpProvider") - static void EQShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + static void EQShortVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5509,13 +5559,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + assertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @Test(dataProvider = "shortCompareOpMaskProvider") - static void EQShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + static void EQShortVectorMaxTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5529,7 +5579,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], (short)((long)b[i])))); } } } @@ -5539,7 +5589,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShortMaxVectorTests(IntFunction fa, IntFunction fb, + static void blendShortVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5555,11 +5605,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend); + assertArraysEquals(r, a, b, mask, ShortVectorMaxTests::blend); } @Test(dataProvider = "shortUnaryOpShuffleProvider") - static void RearrangeShortMaxVectorTests(IntFunction fa, + static void RearrangeShortVectorMaxTests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, SPECIES.length()); @@ -5576,7 +5626,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") - static void RearrangeShortMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void RearrangeShortVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -5594,7 +5644,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void compressShortMaxVectorTests(IntFunction fa, + static void compressShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5612,7 +5662,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void expandShortMaxVectorTests(IntFunction fa, + static void expandShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5630,7 +5680,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void getShortMaxVectorTests(IntFunction fa) { + static void getShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -5786,7 +5836,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastShortMaxVectorTests(IntFunction fa) { + static void BroadcastShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5800,7 +5850,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZeroShortMaxVectorTests(IntFunction fa) { + static void ZeroShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5825,7 +5875,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void sliceUnaryShortMaxVectorTests(IntFunction fa) { + static void sliceUnaryShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5836,7 +5886,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, ShortMaxVectorTests::sliceUnary); + assertArraysEquals(r, a, origin, ShortVectorMaxTests::sliceUnary); } static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { @@ -5853,7 +5903,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void sliceBinaryShortMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void sliceBinaryShortVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5866,7 +5916,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, ShortMaxVectorTests::sliceBinary); + assertArraysEquals(r, a, b, origin, ShortVectorMaxTests::sliceBinary); } static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { @@ -5883,7 +5933,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void sliceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void sliceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -5900,7 +5950,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, mask, ShortMaxVectorTests::slice); + assertArraysEquals(r, a, b, origin, mask, ShortVectorMaxTests::slice); } static short[] unsliceUnary(short[] a, int origin, int idx) { @@ -5917,7 +5967,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void unsliceUnaryShortMaxVectorTests(IntFunction fa) { + static void unsliceUnaryShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; int origin = RAND.nextInt(SPECIES.length()); @@ -5928,7 +5978,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, origin, ShortMaxVectorTests::unsliceUnary); + assertArraysEquals(r, a, origin, ShortVectorMaxTests::unsliceUnary); } static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { @@ -5954,7 +6004,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpProvider") - static void unsliceBinaryShortMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + static void unsliceBinaryShortVectorMaxTestsBinary(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -5968,7 +6018,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, ShortMaxVectorTests::unsliceBinary); + assertArraysEquals(r, a, b, origin, part, ShortVectorMaxTests::unsliceBinary); } static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { @@ -6008,7 +6058,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void unsliceShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void unsliceShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6025,7 +6075,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, origin, part, mask, ShortMaxVectorTests::unslice); + assertArraysEquals(r, a, b, origin, part, mask, ShortVectorMaxTests::unslice); } static short BITWISE_BLEND(short a, short b, short c) { @@ -6037,7 +6087,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShortMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6052,11 +6102,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShortMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6069,11 +6119,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(bv, cv).intoArray(r, i); } - assertArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); + assertArraysEquals(r, a, b, c, ShortVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVectorMaxTestsMasked(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6091,11 +6141,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertArraysEquals(r, a, b, c, mask, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6106,11 +6156,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6121,11 +6171,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6136,11 +6186,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); av.bitwiseBlend(bv, c[i]).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); + assertBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVectorMaxTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6151,11 +6201,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { ShortVector cv = ShortVector.fromArray(SPECIES, c, i); av.bitwiseBlend(b[i], cv).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); + assertAltBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6170,11 +6220,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); } - assertBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertBroadcastArraysEquals(r, a, b, c, mask, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVectorMaxTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6189,11 +6239,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); } - assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void BITWISE_BLENDShortVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6204,11 +6254,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::BITWISE_BLEND); } @Test(dataProvider = "shortTernaryOpProvider") - static void bitwiseBlendShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + static void bitwiseBlendShortVectorMaxTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] c = fc.apply(SPECIES.length()); @@ -6219,11 +6269,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.bitwiseBlend(b[i], c[i]).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); + assertDoubleBroadcastArraysEquals(r, a, b, c, ShortVectorMaxTests::bitwiseBlend); } @Test(dataProvider = "shortTernaryOpMaskProvider") - static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + static void BITWISE_BLENDShortVectorMaxTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6237,19 +6287,19 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); } - assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortVectorMaxTests::BITWISE_BLEND); } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void NEGShortMaxVectorTests(IntFunction fa) { + static void NEGShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6260,11 +6310,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::NEG); + assertArraysEquals(r, a, ShortVectorMaxTests::NEG); } @Test(dataProvider = "shortUnaryOpProvider") - static void negShortMaxVectorTests(IntFunction fa) { + static void negShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6275,11 +6325,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::neg); + assertArraysEquals(r, a, ShortVectorMaxTests::neg); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedShortMaxVectorTests(IntFunction fa, + static void NEGMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6293,19 +6343,19 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::NEG); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::NEG); } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") - static void ABSShortMaxVectorTests(IntFunction fa) { + static void ABSShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6316,11 +6366,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::ABS); + assertArraysEquals(r, a, ShortVectorMaxTests::ABS); } @Test(dataProvider = "shortUnaryOpProvider") - static void absShortMaxVectorTests(IntFunction fa) { + static void absShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6331,11 +6381,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::abs); + assertArraysEquals(r, a, ShortVectorMaxTests::abs); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedShortMaxVectorTests(IntFunction fa, + static void ABSMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6349,7 +6399,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::ABS); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::ABS); } static short NOT(short a) { @@ -6361,7 +6411,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void NOTShortMaxVectorTests(IntFunction fa) { + static void NOTShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6372,11 +6422,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::NOT); + assertArraysEquals(r, a, ShortVectorMaxTests::NOT); } @Test(dataProvider = "shortUnaryOpProvider") - static void notShortMaxVectorTests(IntFunction fa) { + static void notShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6387,11 +6437,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::not); + assertArraysEquals(r, a, ShortVectorMaxTests::not); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NOTMaskedShortMaxVectorTests(IntFunction fa, + static void NOTMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6405,7 +6455,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::NOT); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::NOT); } static short ZOMO(short a) { @@ -6413,7 +6463,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void ZOMOShortMaxVectorTests(IntFunction fa) { + static void ZOMOShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6424,11 +6474,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::ZOMO); + assertArraysEquals(r, a, ShortVectorMaxTests::ZOMO); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ZOMOMaskedShortMaxVectorTests(IntFunction fa, + static void ZOMOMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6442,7 +6492,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::ZOMO); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::ZOMO); } static short BIT_COUNT(short a) { @@ -6450,7 +6500,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void BIT_COUNTShortMaxVectorTests(IntFunction fa) { + static void BIT_COUNTShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6461,11 +6511,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, ShortVectorMaxTests::BIT_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void BIT_COUNTMaskedShortMaxVectorTests(IntFunction fa, + static void BIT_COUNTMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6479,7 +6529,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::BIT_COUNT); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::BIT_COUNT); } static short TRAILING_ZEROS_COUNT(short a) { @@ -6487,7 +6537,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void TRAILING_ZEROS_COUNTShortMaxVectorTests(IntFunction fa) { + static void TRAILING_ZEROS_COUNTShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6498,11 +6548,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVectorMaxTests::TRAILING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void TRAILING_ZEROS_COUNTMaskedShortMaxVectorTests(IntFunction fa, + static void TRAILING_ZEROS_COUNTMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6516,7 +6566,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::TRAILING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::TRAILING_ZEROS_COUNT); } static short LEADING_ZEROS_COUNT(short a) { @@ -6524,7 +6574,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void LEADING_ZEROS_COUNTShortMaxVectorTests(IntFunction fa) { + static void LEADING_ZEROS_COUNTShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6535,11 +6585,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, ShortVectorMaxTests::LEADING_ZEROS_COUNT); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void LEADING_ZEROS_COUNTMaskedShortMaxVectorTests(IntFunction fa, + static void LEADING_ZEROS_COUNTMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6553,7 +6603,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::LEADING_ZEROS_COUNT); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::LEADING_ZEROS_COUNT); } static short REVERSE(short a) { @@ -6561,7 +6611,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSEShortMaxVectorTests(IntFunction fa) { + static void REVERSEShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6572,11 +6622,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::REVERSE); + assertArraysEquals(r, a, ShortVectorMaxTests::REVERSE); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSEMaskedShortMaxVectorTests(IntFunction fa, + static void REVERSEMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6590,7 +6640,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::REVERSE); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::REVERSE); } static short REVERSE_BYTES(short a) { @@ -6598,7 +6648,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void REVERSE_BYTESShortMaxVectorTests(IntFunction fa) { + static void REVERSE_BYTESShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6609,11 +6659,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, ShortVectorMaxTests::REVERSE_BYTES); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void REVERSE_BYTESMaskedShortMaxVectorTests(IntFunction fa, + static void REVERSE_BYTESMaskedShortVectorMaxTests(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -6627,7 +6677,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, mask, ShortMaxVectorTests::REVERSE_BYTES); + assertArraysEquals(r, a, mask, ShortVectorMaxTests::REVERSE_BYTES); } static boolean band(boolean a, boolean b) { @@ -6635,7 +6685,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6648,7 +6698,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::band); + assertArraysEquals(r, a, b, ShortVectorMaxTests::band); } static boolean bor(boolean a, boolean b) { @@ -6656,7 +6706,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskorShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskorShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6669,7 +6719,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::bor); + assertArraysEquals(r, a, b, ShortVectorMaxTests::bor); } static boolean bxor(boolean a, boolean b) { @@ -6677,7 +6727,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskxorShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskxorShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6690,7 +6740,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::bxor); + assertArraysEquals(r, a, b, ShortVectorMaxTests::bxor); } static boolean bandNot(boolean a, boolean b) { @@ -6698,7 +6748,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskandNotShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskandNotShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6711,7 +6761,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::bandNot); + assertArraysEquals(r, a, b, ShortVectorMaxTests::bandNot); } static boolean beq(boolean a, boolean b) { @@ -6719,7 +6769,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskeqShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskeqShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6732,7 +6782,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, b, ShortMaxVectorTests::beq); + assertArraysEquals(r, a, b, ShortVectorMaxTests::beq); } static boolean unot(boolean a) { @@ -6740,7 +6790,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskUnaryOpProvider") - static void masknotShortMaxVectorTests(IntFunction fa) { + static void masknotShortVectorMaxTests(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); boolean[] r = new boolean[a.length]; @@ -6751,7 +6801,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::unot); + assertArraysEquals(r, a, ShortVectorMaxTests::unot); } private static final long LONG_MASK_BITS = 0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()); @@ -6768,7 +6818,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "longMaskProvider") - static void maskFromToLongShortMaxVectorTests(IntFunction fa) { + static void maskFromToLongShortVectorMaxTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = new long[a.length]; @@ -6782,7 +6832,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortCompareOpProvider") - static void ltShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + static void ltShortVectorMaxTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6792,13 +6842,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @Test(dataProvider = "shortCompareOpProvider") - static void eqShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + static void eqShortVectorMaxTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6808,13 +6858,13 @@ public class ShortMaxVectorTests extends AbstractVectorTest { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @Test(dataProvider = "shortUnaryOpProvider") - static void toIntArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void toIntArrayShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6825,7 +6875,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toLongArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void toLongArrayShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6836,7 +6886,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toDoubleArrayShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void toDoubleArrayShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6847,7 +6897,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void toStringShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void toStringShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6860,7 +6910,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpProvider") - static void hashCodeShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void hashCodeShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -6877,7 +6927,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static long ADDReduceLong(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -6886,14 +6936,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLong(short[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add((short)res, (short)ADDReduceLong(a, i)); } return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ADDReduceLongShortMaxVectorTests(IntFunction fa) { + static void ADDReduceLongShortVectorMaxTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); long ra = 0; @@ -6904,19 +6954,20 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEquals(r, ra, a, - ShortMaxVectorTests::ADDReduceLong, ShortMaxVectorTests::ADDReduceAllLong); + ShortVectorMaxTests::ADDReduceLong, ShortVectorMaxTests::ADDReduceAllLong); } static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -6925,14 +6976,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add((short)res, (short)ADDReduceLongMasked(a, i, mask)); } return res; } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ADDReduceLongShortMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + static void ADDReduceLongShortVectorMaxTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); long[] r = lfr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -6945,16 +6996,16 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add((short)ra, (short)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, - ShortMaxVectorTests::ADDReduceLongMasked, ShortMaxVectorTests::ADDReduceAllLongMasked); + ShortVectorMaxTests::ADDReduceLongMasked, ShortVectorMaxTests::ADDReduceAllLongMasked); } @Test(dataProvider = "shortUnaryOpProvider") - static void BroadcastLongShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void BroadcastLongShortVectorMaxTestsSmokeTest(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = new short[a.length]; @@ -6965,7 +7016,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + static void blendShortVectorMaxTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -6979,12 +7030,12 @@ public class ShortMaxVectorTests extends AbstractVectorTest { av.blend((long)b[i], vmask).intoArray(r, i); } } - assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend); + assertBroadcastLongArraysEquals(r, a, b, mask, ShortVectorMaxTests::blend); } @Test(dataProvider = "shortUnaryOpSelectFromProvider") - static void SelectFromShortMaxVectorTests(IntFunction fa, + static void SelectFromShortVectorMaxTests(IntFunction fa, BiFunction fs) { short[] a = fa.apply(SPECIES.length()); short[] order = fs.apply(a.length, SPECIES.length()); @@ -7000,7 +7051,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") - static void SelectFromTwoVectorShortMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + static void SelectFromTwoVectorShortVectorMaxTests(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] idx = fc.apply(SPECIES.length()); @@ -7018,7 +7069,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") - static void SelectFromShortMaxVectorTestsMaskedSmokeTest(IntFunction fa, + static void SelectFromShortVectorMaxTestsMaskedSmokeTest(IntFunction fa, BiFunction fs, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -7037,7 +7088,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleMiscellaneousShortMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleMiscellaneousShortVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7053,7 +7104,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleProvider") - static void shuffleToStringShortMaxVectorTestsSmokeTest(BiFunction fs) { + static void shuffleToStringShortVectorMaxTestsSmokeTest(BiFunction fs) { int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7067,7 +7118,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "shuffleCompareOpProvider") - static void shuffleEqualsShortMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + static void shuffleEqualsShortVectorMaxTestsSmokeTest(BiFunction fa, BiFunction fb) { int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); @@ -7081,7 +7132,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "boolMaskBinaryOpProvider") - static void maskEqualsShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void maskEqualsShortVectorMaxTests(IntFunction fa, IntFunction fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); @@ -7097,7 +7148,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskHashCodeShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskHashCodeShortVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -7119,7 +7170,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskTrueCountShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskTrueCountShortVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7130,7 +7181,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskTrueCount); + assertMaskReductionArraysEquals(r, a, ShortVectorMaxTests::maskTrueCount); } static int maskLastTrue(boolean[] a, int idx) { @@ -7144,7 +7195,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskLastTrueShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskLastTrueShortVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7155,7 +7206,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskLastTrue); + assertMaskReductionArraysEquals(r, a, ShortVectorMaxTests::maskLastTrue); } static int maskFirstTrue(boolean[] a, int idx) { @@ -7169,7 +7220,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "maskProvider") - static void maskFirstTrueShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskFirstTrueShortVectorMaxTestsSmokeTest(IntFunction fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = new int[a.length]; @@ -7180,11 +7231,11 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskFirstTrue); + assertMaskReductionArraysEquals(r, a, ShortVectorMaxTests::maskFirstTrue); } @Test(dataProvider = "maskProvider") - static void maskCompressShortMaxVectorTestsSmokeTest(IntFunction fa) { + static void maskCompressShortVectorMaxTestsSmokeTest(IntFunction fa) { int trueCount = 0; boolean[] a = fa.apply(SPECIES.length()); @@ -7212,7 +7263,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeShortMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeShortVectorMaxTestsSmokeTest(int offset) { int limit = SPECIES.length() * BUFFER_REPS; for (int i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7226,7 +7277,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "offsetProvider") - static void indexInRangeLongShortMaxVectorTestsSmokeTest(int offset) { + static void indexInRangeLongShortVectorMaxTestsSmokeTest(int offset) { long limit = SPECIES.length() * BUFFER_REPS; for (long i = 0; i < limit; i += SPECIES.length()) { var actualMask = SPECIES.indexInRange(i + offset, limit); @@ -7253,14 +7304,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test(dataProvider = "lengthProvider") - static void loopBoundShortMaxVectorTestsSmokeTest(int length) { + static void loopBoundShortVectorMaxTestsSmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); assertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") - static void loopBoundLongShortMaxVectorTestsSmokeTest(int _length) { + static void loopBoundLongShortVectorMaxTestsSmokeTest(int _length) { long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); @@ -7268,21 +7319,21 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementSizeShortMaxVectorTestsSmokeTest() { + static void ElementSizeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); int elsize = av.elementSize(); assertEquals(elsize, Short.SIZE); } @Test - static void VectorShapeShortMaxVectorTestsSmokeTest() { + static void VectorShapeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); assert(vsh.equals(VectorShape.S_Max_BIT)); } @Test - static void ShapeWithLanesShortMaxVectorTestsSmokeTest() { + static void ShapeWithLanesShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = vsh.withLanes(short.class); @@ -7290,32 +7341,32 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test - static void ElementTypeShortMaxVectorTestsSmokeTest() { + static void ElementTypeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementType() == short.class); } @Test - static void SpeciesElementSizeShortMaxVectorTestsSmokeTest() { + static void SpeciesElementSizeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().elementSize() == Short.SIZE); } @Test - static void VectorTypeShortMaxVectorTestsSmokeTest() { + static void VectorTypeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); assert(av.species().vectorType() == av.getClass()); } @Test - static void WithLanesShortMaxVectorTestsSmokeTest() { + static void WithLanesShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorSpecies species = av.species().withLanes(short.class); assert(species.equals(SPECIES)); } @Test - static void WithShapeShortMaxVectorTestsSmokeTest() { + static void WithShapeShortVectorMaxTestsSmokeTest() { ShortVector av = ShortVector.zero(SPECIES); VectorShape vsh = av.shape(); VectorSpecies species = av.species().withShape(vsh); @@ -7323,7 +7374,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } @Test - static void MaskAllTrueShortMaxVectorTestsSmokeTest() { + static void MaskAllTrueShortVectorMaxTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh index d2528b13b78..4e961e2f2b0 100644 --- a/test/jdk/jdk/incubator/vector/gen-template.sh +++ b/test/jdk/jdk/incubator/vector/gen-template.sh @@ -383,6 +383,7 @@ function gen_bool_reduction_op { gen_op_tmpl $bool_reduction_scalar "$@" gen_op_tmpl $bool_reduction_template "$@" } + function gen_saturating_reduction_op { echo "Generating saturating reduction op $1 ($2)..." gen_op_tmpl $reduction_scalar_func "$@" @@ -434,13 +435,13 @@ fi # ALU binary ops. # Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant. -gen_binary_alu_op "ADD+add+withMask" "a + b" -gen_binary_alu_op "SUB+sub+withMask" "a - b" -gen_binary_alu_op "MUL+mul+withMask" "a \* b" -gen_binary_alu_op "DIV+div+withMask" "a \/ b" "FP" +gen_binary_alu_op "ADD+add+withMask" "scalar_add(a, b)" +gen_binary_alu_op "SUB+sub+withMask" "scalar_sub(a, b)" +gen_binary_alu_op "MUL+mul+withMask" "scalar_mul(a, b)" +gen_binary_alu_op "DIV+div+withMask" "scalar_div(a, b)" "FP" gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" -gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b" +gen_binary_alu_op "FIRST_NONZERO" "firstNonZero(a, b)" gen_binary_alu_op "AND+and" "a \& b" "BITWISE" gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" gen_binary_alu_op "OR+or" "a | b" "BITWISE" @@ -449,16 +450,16 @@ gen_binary_alu_op "XOR" "a ^ b" "BITWISE" gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong" gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong" # Generate the broadcast versions -gen_binary_alu_bcst_op "add+withMask" "a + b" -gen_binary_alu_bcst_op "sub+withMask" "a - b" -gen_binary_alu_bcst_op "mul+withMask" "a \* b" -gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP" +gen_binary_alu_bcst_op "add+withMask" "scalar_add(a, b)" +gen_binary_alu_bcst_op "sub+withMask" "scalar_sub(a, b)" +gen_binary_alu_bcst_op "mul+withMask" "scalar_mul(a, b)" +gen_binary_alu_bcst_op "div+withMask" "scalar_div(a, b)" "FP" gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" gen_binary_alu_bcst_op "AND+and" "a \& b" "BITWISE" gen_binary_alu_bcst_long_op "OR" "a | b" "BITWISE" -gen_binary_alu_bcst_long_op "ADD" "a + b" +gen_binary_alu_bcst_long_op "ADD" "scalar_add(a, b)" # Shifts gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" @@ -494,30 +495,30 @@ gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" # Binary operation with one memory operand -gen_binary_alu_mem_op "MIN+min+withMask", "Math.min(a, b)" -gen_binary_alu_mem_op "MAX+max+withMask", "Math.max(a, b)" +gen_binary_alu_mem_op "MIN+min+withMask", "scalar_min(a, b)" +gen_binary_alu_mem_op "MAX+max+withMask", "scalar_max(a, b)" # Masked reductions. -gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" -gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" +gen_binary_op_no_masked "MIN+min" "scalar_min(a, b)" +gen_binary_op_no_masked "MAX+max" "scalar_max(a, b)" gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" -gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" -gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" +gen_binary_bcst_op_no_masked "MIN+min" "scalar_min(a, b)" +gen_binary_bcst_op_no_masked "MAX+max" "scalar_max(a, b)" gen_saturating_binary_op_associative "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" # Reductions. -gen_reduction_op "AND" "\&" "BITWISE" "AND_IDENTITY" -gen_reduction_op "OR" "|" "BITWISE" "OR_IDENTITY" -gen_reduction_op "XOR" "^" "BITWISE" "XOR_IDENTITY" -gen_reduction_op "ADD" "+" "" "ADD_IDENTITY" -gen_reduction_op "MUL" "*" "" "MUL_IDENTITY" -gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "MIN_IDENTITY" -gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "MAX_IDENTITY" +gen_reduction_op "AND" "scalar_and" "BITWISE" "AND_IDENTITY" +gen_reduction_op "OR" "scalar_or" "BITWISE" "OR_IDENTITY" +gen_reduction_op "XOR" "scalar_xor" "BITWISE" "XOR_IDENTITY" +gen_reduction_op "ADD" "scalar_add" "" "ADD_IDENTITY" +gen_reduction_op "MUL" "scalar_mul" "" "MUL_IDENTITY" +gen_reduction_op_func "MIN" "scalar_min" "" "MIN_IDENTITY" +gen_reduction_op_func "MAX" "scalar_max" "" "MAX_IDENTITY" gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "UMIN_IDENTITY" gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "UMAX_IDENTITY" gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "FIRST_NONZERO_IDENTITY" @@ -535,9 +536,9 @@ gen_with_op "withLane" "" "" "" # Tests gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0" gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0" -gen_op_tmpl $test_template "IS_FINITE" "\$Boxtype\$.isFinite(a)" "FP" -gen_op_tmpl $test_template "IS_NAN" "\$Boxtype\$.isNaN(a)" "FP" -gen_op_tmpl $test_template "IS_INFINITE" "\$Boxtype\$.isInfinite(a)" "FP" +gen_op_tmpl $test_template "IS_FINITE" "isFinite(a)" "FP" +gen_op_tmpl $test_template "IS_NAN" "isNaN(a)" "FP" +gen_op_tmpl $test_template "IS_INFINITE" "isInfinite(a)" "FP" # Compares gen_compare_op "LT+lt" "lt" @@ -553,8 +554,8 @@ gen_compare_op "ULE" "ule" "BITWISE" gen_compare_op "UGE" "uge" "BITWISE" -gen_compare_bcst_op "LT" "<" -gen_compare_bcst_op "EQ" "==" +gen_compare_bcst_op "LT" "lt" +gen_compare_bcst_op "EQ" "eq" # Blend. gen_op_tmpl $blend "blend" "" @@ -585,28 +586,28 @@ gen_op_tmpl $unslice1_template "unsliceBinary" "" gen_op_tmpl $unslice1_masked_template "unslice" "" # Math -gen_op_tmpl $unary_math_template "SIN" "Math.sin((double)a)" "FP" -gen_op_tmpl $unary_math_template "EXP" "Math.exp((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG1P" "Math.log1p((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG" "Math.log((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG10" "Math.log10((double)a)" "FP" -gen_op_tmpl $unary_math_template "EXPM1" "Math.expm1((double)a)" "FP" -gen_op_tmpl $unary_math_template "COS" "Math.cos((double)a)" "FP" -gen_op_tmpl $unary_math_template "TAN" "Math.tan((double)a)" "FP" -gen_op_tmpl $unary_math_template "SINH" "Math.sinh((double)a)" "FP" -gen_op_tmpl $unary_math_template "COSH" "Math.cosh((double)a)" "FP" -gen_op_tmpl $unary_math_template "TANH" "Math.tanh((double)a)" "FP" -gen_op_tmpl $unary_math_template "ASIN" "Math.asin((double)a)" "FP" -gen_op_tmpl $unary_math_template "ACOS" "Math.acos((double)a)" "FP" -gen_op_tmpl $unary_math_template "ATAN" "Math.atan((double)a)" "FP" -gen_op_tmpl $unary_math_template "CBRT" "Math.cbrt((double)a)" "FP" -gen_op_tmpl $binary_math_template "HYPOT" "Math.hypot((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_template "ATAN2" "Math.atan2((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" +gen_op_tmpl $unary_math_template "SIN" "scalar_sin(a)" "FP" +gen_op_tmpl $unary_math_template "EXP" "scalar_exp(a)" "FP" +gen_op_tmpl $unary_math_template "LOG1P" "scalar_log1p(a)" "FP" +gen_op_tmpl $unary_math_template "LOG" "scalar_log(a)" "FP" +gen_op_tmpl $unary_math_template "LOG10" "scalar_log10(a)" "FP" +gen_op_tmpl $unary_math_template "EXPM1" "scalar_expm1(a)" "FP" +gen_op_tmpl $unary_math_template "COS" "scalar_cos(a)" "FP" +gen_op_tmpl $unary_math_template "TAN" "scalar_tan(a)" "FP" +gen_op_tmpl $unary_math_template "SINH" "scalar_sinh(a)" "FP" +gen_op_tmpl $unary_math_template "COSH" "scalar_cosh(a)" "FP" +gen_op_tmpl $unary_math_template "TANH" "scalar_tanh(a)" "FP" +gen_op_tmpl $unary_math_template "ASIN" "scalar_asin(a)" "FP" +gen_op_tmpl $unary_math_template "ACOS" "scalar_acos(a)" "FP" +gen_op_tmpl $unary_math_template "ATAN" "scalar_atan(a)" "FP" +gen_op_tmpl $unary_math_template "CBRT" "scalar_cbrt(a)" "FP" +gen_op_tmpl $binary_math_template "HYPOT" "scalar_hypot(a, b)" "FP" +gen_op_tmpl $binary_math_template "POW+pow" "scalar_pow(a, b)" "FP" +gen_op_tmpl $binary_math_template "ATAN2" "scalar_atan2(a, b)" "FP" +gen_op_tmpl $binary_math_broadcast_template "POW+pow" "scalar_pow(a, b)" "FP" # Ternary operations. -gen_ternary_alu_op "FMA+fma" "Math.fma(a, b, c)" "FP" +gen_ternary_alu_op "FMA+fma" "scalar_fma(a, b, c)" "FP" gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP" gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" @@ -614,11 +615,11 @@ gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP" gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" # Unary operations. -gen_unary_alu_op "NEG+neg" "-((\$type\$)a)" -gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)" +gen_unary_alu_op "NEG+neg" "scalar_neg((\$type\$)a)" +gen_unary_alu_op "ABS+abs" "scalar_abs((\$type\$)a)" gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" -gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP" +gen_unary_alu_op "SQRT+sqrt" "scalar_sqrt(a)" "FP" gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong" gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte" gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short" diff --git a/test/jdk/jdk/incubator/vector/gen-tests.sh b/test/jdk/jdk/incubator/vector/gen-tests.sh index 239e53367c0..8b5c4cac616 100644 --- a/test/jdk/jdk/incubator/vector/gen-tests.sh +++ b/test/jdk/jdk/incubator/vector/gen-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2026, 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,6 @@ do abstractvectortype=${typeprefix}${Type}Vector abstractvectorteststype=${typeprefix}${Type}VectorTests - abstractbitsvectortype=${typeprefix}${Bitstype}Vector abstractfpvectortype=${typeprefix}${Fptype}Vector args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" @@ -136,12 +135,12 @@ do for bits in 64 128 256 512 Max do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorTests - vectorbenchtype=${typeprefix}${Type}${bits}Vector - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector + vectortype=${typeprefix}${Type}$Vector{bits} + vectorteststype=${typeprefix}${Type}Vector${bits}Tests + vectorbenchtype=${typeprefix}${Type}Vector${bits} + masktype=${typeprefix}${Type}$Mask{bits} + bitsvectortype=${typeprefix}${Bitstype}Vector${bits} + fpvectortype=${typeprefix}${Fptype}Vector${bits} shape=S${bits}Bit Shape=S_${bits}_BIT if [[ "${vectortype}" == "ByteMaxVector" ]]; then @@ -211,12 +210,12 @@ do # For each size for bits in 64 128 256 512 Max do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests - vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector + vectortype=${typeprefix}${Type}Vector${bits} + vectorteststype=${typeprefix}${Type}Vector${bits}LoadStoreTests + vectorbenchtype=${typeprefix}${Type}Vector${bits}LoadStore + masktype=${typeprefix}${Type}Mask${bits} + bitsvectortype=${typeprefix}${Bitstype}Vector${bits} + fpvectortype=${typeprefix}${Fptype}Vector${bits} shape=S${bits}Bit Shape=S_${bits}_BIT if [[ "${vectortype}" == "ByteMaxVector" ]]; then diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template index 82e20d594b6..73e02bf68dd 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template @@ -10,7 +10,7 @@ $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); $type$ v = av.reduceLanes(VectorOperators.[[TEST]], vmask); r[i] = v; - ra [[TEST_OP]]= v; + ra = [[TEST_OP]](ra, v); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template index 3edc2b27e3e..94fae420cdd 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template @@ -8,7 +8,7 @@ $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); $type$ v = av.reduceLanes(VectorOperators.[[TEST]]); r[i] = v; - ra [[TEST_OP]]= v; + ra = [[TEST_OP]](ra, v); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template index a3d44526db9..1866c28e2ba 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template @@ -4,7 +4,7 @@ } static $type$ strict[[TEST]]($type$ a, $type$ b) { - return ($type$)(Strict[[TEST_OP]]); + return ($type$)(strict_[[TEST_OP]]); } @Test(dataProvider = "$type$BinaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template index 92e612e8184..faae74426e7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template @@ -10,7 +10,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] [[TEST_OP]] b[i]); + assertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], b[i])); } } } @@ -30,7 +30,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] [[TEST_OP]] b[i])); + assertEquals(mv.laneIsSet(j), mask[j] && ([[TEST_OP]](a[i + j], b[i]))); } } } @@ -47,7 +47,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] [[TEST_OP]] ($type$)((long)b[i])); + assertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], ($type$)((long)b[i]))); } } } @@ -67,7 +67,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] [[TEST_OP]] ($type$)((long)b[i]))); + assertEquals(mv.laneIsSet(j), mask[j] && ([[TEST_OP]](a[i + j], ($type$)((long)b[i])))); } } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template index 8411565628d..5ad7623d2c0 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template @@ -10,7 +10,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -26,7 +26,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -123,7 +123,7 @@ static long ADDReduceLong($type$[] a, int idx) { $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return (long)res; @@ -132,7 +132,7 @@ static long ADDReduceAllLong($type$[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLong(a, i); + res = (long)scalar_add(($type$)res, ($type$)ADDReduceLong(a, i)); } return res; @@ -150,8 +150,8 @@ } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add(($type$)ra, ($type$)r[i]); } assertReductionLongArraysEquals(r, ra, a, @@ -161,8 +161,9 @@ static long ADDReduceLongMasked($type$[] a, int idx, boolean[] mask) { $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) - res += a[i]; + if (mask[i % SPECIES.length()]) { + res = scalar_add(res, a[i]); + } } return (long)res; @@ -171,7 +172,7 @@ static long ADDReduceAllLongMasked($type$[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceLongMasked(a, i, mask); + res = (long)scalar_add(($type$)res, ($type$)ADDReduceLongMasked(a, i, mask)); } return res; @@ -191,8 +192,8 @@ } ra = 0; - for (int i = 0; i < a.length; i ++) { - ra += r[i]; + for (int i = 0; i < a.length; i++) { + ra = (long)scalar_add(($type$)ra, ($type$)r[i]); } assertReductionLongArraysEqualsMasked(r, ra, a, mask, diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template index ab383e61256..1565c9f3551 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template @@ -3,7 +3,7 @@ $type$ res = [[TEST_INIT]]; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res [[TEST_OP]]= a[i]; + res = [[TEST_OP]](res, a[i]); } return res; @@ -12,7 +12,7 @@ static $type$ [[TEST]]ReduceAllMasked($type$[] a, boolean[] mask) { $type$ res = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { - res [[TEST_OP]]= [[TEST]]ReduceMasked(a, i, mask); + res = [[TEST_OP]](res, [[TEST]]ReduceMasked(a, i, mask)); } return res; diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template index 88586fa8129..63d154df112 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template @@ -2,7 +2,7 @@ static $type$ [[TEST]]Reduce($type$[] a, int idx) { $type$ res = [[TEST_INIT]]; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res [[TEST_OP]]= a[i]; + res = [[TEST_OP]](res, a[i]); } return res; @@ -11,7 +11,7 @@ static $type$ [[TEST]]ReduceAll($type$[] a) { $type$ res = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { - res [[TEST_OP]]= [[TEST]]Reduce(a, i); + res = [[TEST_OP]](res, [[TEST]]Reduce(a, i)); } return res; diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template index 25ae3ba2f12..d82b5533c4f 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-op.template @@ -15,20 +15,20 @@ $type$[] a = fa.apply(SPECIES.length()); $type$ id = [[TEST_INIT]]; - assertEquals(($type$) (id [[TEST_OP]] id), id, + assertEquals(($type$) ([[TEST_OP]](id, id)), id, "[[TEST]]([[TEST_INIT]], [[TEST_INIT]]) != [[TEST_INIT]]"); $type$ x = 0; try { for (int i = 0; i < a.length; i++) { x = a[i]; - assertEquals(($type$) (id [[TEST_OP]] x), x); - assertEquals(($type$) (x [[TEST_OP]] id), x); + assertEquals(($type$) ([[TEST_OP]](id, x)), x); + assertEquals(($type$) ([[TEST_OP]](x, id)), x); } } catch (AssertionError e) { - assertEquals(($type$) (id [[TEST_OP]] x), x, + assertEquals(($type$) ([[TEST_OP]](id, x)), x, "[[TEST]]([[TEST_INIT]], " + x + ") != " + x); - assertEquals(($type$) (x [[TEST_OP]] id), x, + assertEquals(($type$) ([[TEST_OP]](x, id)), x, "[[TEST]](" + x + ", [[TEST_INIT]]) != " + x); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template index 52293d9f614..f6943a0b40b 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template @@ -4,7 +4,7 @@ } static $type$ strict[[TEST]]($type$ a) { - return ($type$)(Strict[[TEST_OP]]); + return ($type$)(strict_[[TEST_OP]]); } @Test(dataProvider = "$type$UnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index 00a7766492c..e1434dccb2b 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -1943,6 +1943,214 @@ relativeError)); static boolean ge($type$ a, $type$ b) { return a >= b; } + + static $type$ firstNonZero($type$ a, $type$ b) { + return $Wideboxtype$.compare(a, ($type$) 0) != 0 ? a : b; + } + +#if[BITWISE] + static $type$ scalar_or($type$ a, $type$ b) { + return ($type$)(a | b); + } + + static $type$ scalar_and($type$ a, $type$ b) { + return ($type$)(a & b); + } + + static $type$ scalar_xor($type$ a, $type$ b) { + return ($type$)(a ^ b); + } +#end[BITWISE]; + + static $type$ scalar_add($type$ a, $type$ b) { + return ($type$)(a + b); + } + + static $type$ scalar_sub($type$ a, $type$ b) { + return ($type$)(a - b); + } + + static $type$ scalar_mul($type$ a, $type$ b) { + return ($type$)(a * b); + } + + static $type$ scalar_min($type$ a, $type$ b) { + return ($type$)(Math.min(a, b)); + } + + static $type$ scalar_max($type$ a, $type$ b) { + return ($type$)(Math.max(a, b)); + } + + static $type$ scalar_div($type$ a, $type$ b) { + return ($type$)(a / b); + } + + static $type$ scalar_fma($type$ a, $type$ b, $type$ c) { + return ($type$)(Math.fma(a, b, c)); + } + + static $type$ scalar_abs($type$ a) { + return ($type$)(Math.abs(a)); + } + + static $type$ scalar_neg($type$ a) { + return (($type$)-a); + } + +#if[!BITWISE] + static $type$ scalar_sin($type$ a) { + return ($type$)Math.sin((double)a); + } + + static $type$ scalar_exp($type$ a) { + return ($type$)Math.exp((double)a); + } + + static $type$ scalar_log1p($type$ a) { + return ($type$)Math.log1p((double)a); + } + + static $type$ scalar_log($type$ a) { + return ($type$)Math.log((double)a); + } + + static $type$ scalar_log10($type$ a) { + return ($type$)Math.log10((double)a); + } + + static $type$ scalar_expm1($type$ a) { + return ($type$)Math.expm1((double)a); + } + + static $type$ scalar_cos($type$ a) { + return ($type$)Math.cos((double)a); + } + + static $type$ scalar_tan($type$ a) { + return ($type$)Math.tan((double)a); + } + + static $type$ scalar_sinh($type$ a) { + return ($type$)Math.sinh((double)a); + } + + static $type$ scalar_cosh($type$ a) { + return ($type$)Math.cosh((double)a); + } + + static $type$ scalar_tanh($type$ a) { + return ($type$)Math.tanh((double)a); + } + + static $type$ scalar_asin($type$ a) { + return ($type$)Math.asin((double)a); + } + + static $type$ scalar_acos($type$ a) { + return ($type$)Math.acos((double)a); + } + + static $type$ scalar_atan($type$ a) { + return ($type$)Math.atan((double)a); + } + + static $type$ scalar_cbrt($type$ a) { + return ($type$)Math.cbrt((double)a); + } + + static $type$ scalar_sqrt($type$ a) { + return ($type$)Math.sqrt((double)a); + } + + static $type$ scalar_hypot($type$ a, $type$ b) { + return ($type$)Math.hypot((double)a, (double)b); + } + + static $type$ scalar_pow($type$ a, $type$ b) { + return ($type$)Math.pow((double)a, (double)b); + } + + static $type$ scalar_atan2($type$ a, $type$ b) { + return ($type$)Math.atan2((double)a, (double)b); + } + + static $type$ strict_scalar_sin($type$ a) { + return ($type$)StrictMath.sin((double)a); + } + + static $type$ strict_scalar_exp($type$ a) { + return ($type$)StrictMath.exp((double)a); + } + + static $type$ strict_scalar_log1p($type$ a) { + return ($type$)StrictMath.log1p((double)a); + } + + static $type$ strict_scalar_log($type$ a) { + return ($type$)StrictMath.log((double)a); + } + + static $type$ strict_scalar_log10($type$ a) { + return ($type$)StrictMath.log10((double)a); + } + + static $type$ strict_scalar_expm1($type$ a) { + return ($type$)StrictMath.expm1((double)a); + } + + static $type$ strict_scalar_cos($type$ a) { + return ($type$)StrictMath.cos((double)a); + } + + static $type$ strict_scalar_tan($type$ a) { + return ($type$)StrictMath.tan((double)a); + } + + static $type$ strict_scalar_sinh($type$ a) { + return ($type$)StrictMath.sinh((double)a); + } + + static $type$ strict_scalar_cosh($type$ a) { + return ($type$)StrictMath.cosh((double)a); + } + + static $type$ strict_scalar_tanh($type$ a) { + return ($type$)StrictMath.tanh((double)a); + } + + static $type$ strict_scalar_asin($type$ a) { + return ($type$)StrictMath.asin((double)a); + } + + static $type$ strict_scalar_acos($type$ a) { + return ($type$)StrictMath.acos((double)a); + } + + static $type$ strict_scalar_atan($type$ a) { + return ($type$)StrictMath.atan((double)a); + } + + static $type$ strict_scalar_cbrt($type$ a) { + return ($type$)StrictMath.cbrt((double)a); + } + + static $type$ strict_scalar_sqrt($type$ a) { + return ($type$)StrictMath.sqrt((double)a); + } + + static $type$ strict_scalar_hypot($type$ a, $type$ b) { + return ($type$)StrictMath.hypot((double)a, (double)b); + } + + static $type$ strict_scalar_pow($type$ a, $type$ b) { + return ($type$)StrictMath.pow((double)a, (double)b); + } + + static $type$ strict_scalar_atan2($type$ a, $type$ b) { + return ($type$)StrictMath.atan2((double)a, (double)b); + } +#end[!BITWISE] #if[!FP] static boolean ult($type$ a, $type$ b) { @@ -1962,9 +2170,17 @@ relativeError)); } #end[!FP] - static $type$ firstNonZero($type$ a, $type$ b) { - return $Boxtype$.compare(a, ($type$) 0) != 0 ? a : b; +#if[FP] + static boolean isNaN($type$ a) { + return $Wideboxtype$.isNaN(a); } + static boolean isFinite($type$ a) { + return $Wideboxtype$.isFinite(a); + } + static boolean isInfinite($type$ a) { + return $Wideboxtype$.isInfinite(a); + } +#end[FP] @Test static void smokeTest1() { diff --git a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java index b86593d84ba..47df5da36f9 100644 --- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java +++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test * @requires vm.flagless - * @requires test.thread.factory == null + * @requires test.thread.factory == "" * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.zipfs diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java index 1234655f31a..960a4ca73d2 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestRecordingCopy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,7 @@ */ package jdk.jfr.api.recording.misc; +import jdk.jfr.FlightRecorder; import jdk.jfr.Recording; import jdk.jfr.RecordingState; import jdk.jfr.consumer.RecordedEvent; @@ -79,8 +80,14 @@ public class TestRecordingCopy { Asserts.assertEquals(stoppedCopy.getState(), RecordingState.STOPPED); assertCopy(stoppedCopy, original); - // Clean-up original.close(); + int beforeCount = FlightRecorder.getFlightRecorder().getRecordings().size(); + Recording closedCopy = original.copy(true); + Asserts.assertEquals(closedCopy.getState(), RecordingState.CLOSED); + int afterCount = FlightRecorder.getFlightRecorder().getRecordings().size(); + Asserts.assertEquals(beforeCount, afterCount); + + // Clean-up runningCopy.stop(); runningCopy.close(); stoppedCopy.close(); diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java index 9112cfbc247..9cc3141cd2d 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationInNewTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,10 @@ import jdk.test.whitebox.WhiteBox; public class TestObjectAllocationInNewTLABEvent { private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB; - private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); - - private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16; + // 64-bit COH: MW8 + L4 + End Alignment = 16 + // 64-bit -COH: MW8 + K4 + L4 = 16 + // 32-bit : MW4 + K4 + L4 + End Alignment = 16 + private static final int BYTE_ARRAY_OVERHEAD = 16; private static final int OBJECT_SIZE = 128 * 1024; private static final int OBJECTS_TO_ALLOCATE = 100; diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java index a7695b76849..9a4f0f28974 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,10 @@ import jdk.test.whitebox.WhiteBox; public class TestObjectAllocationOutsideTLABEvent { private static final String EVENT_NAME = EventNames.ObjectAllocationOutsideTLAB; - private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); - - private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16; + // 64-bit COH: MW8 + L4 + End Alignment = 16 + // 64-bit -COH: MW8 + K4 + L4 = 16 + // 32-bit : MW4 + K4 + L4 + End Alignment = 16 + private static final int BYTE_ARRAY_OVERHEAD = 16; private static final int OBJECT_SIZE = 128 * 1024; private static final int OBJECTS_TO_ALLOCATE = 100; diff --git a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java index 47f5b31f881..214f7336a73 100644 --- a/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java +++ b/test/jdk/jdk/jfr/event/allocation/TestObjectAllocationSampleEventThrottling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,9 +52,10 @@ import jdk.test.whitebox.WhiteBox; public class TestObjectAllocationSampleEventThrottling { private static final String EVENT_NAME = EventNames.ObjectAllocationSample; - private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); - - private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16; + // 64-bit COH: MW8 + L4 + End Alignment = 16 + // 64-bit -COH: MW8 + K4 + L4 = 16 + // 32-bit : MW4 + K4 + L4 + End Alignment = 16 + private static final int BYTE_ARRAY_OVERHEAD = 16; private static final int OBJECT_SIZE = 128 * 1024; private static final int OBJECTS_TO_ALLOCATE = 100; diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java index 9694c054f6a..20e611fc671 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java @@ -131,10 +131,10 @@ public class TestCompilerInlining { if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) { return IntStream.rangeClosed(LEVEL_SIMPLE, WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue()).toArray(); } - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { return new int[] { LEVEL_FULL_OPTIMIZATION }; } - if (Platform.isClient() || Platform.isEmulatedClient()) { + if (Platform.isClient()) { return new int[] { LEVEL_SIMPLE }; } throw new Error("TESTBUG: unknown VM"); diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java index 33884d448bf..0433e157f3d 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerPhase.java @@ -42,7 +42,6 @@ import jdk.test.whitebox.WhiteBox; * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. - * -XX:-NeverActAsServerClassMachine * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:CompileOnly=jdk.jfr.event.compiler.TestCompilerPhase::dummyMethod * -XX:+SegmentedCodeCache -Xbootclasspath/a:. diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java index e64d6f83ab8..6217de6e235 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +25,6 @@ package jdk.jfr.event.gc.detailed; import java.util.List; -import static gc.testlibrary.Allocation.blackHole; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; import jdk.test.lib.jfr.EventNames; @@ -36,7 +35,7 @@ import jdk.test.lib.jfr.Events; * @requires vm.hasJFR & vm.gc.Z * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent + * @run main/othervm -XX:+UseZGC -Xmx64M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent */ public class TestZRelocationSetEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java index 29e1de24224..8ece7bf12d7 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -36,7 +36,7 @@ import jdk.test.lib.jfr.Events; * @requires vm.hasJFR & vm.gc.Z * @requires vm.flagless * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent + * @run main/othervm -XX:+UseZGC -Xmx64M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent */ public class TestZRelocationSetGroupEvent { diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java index f70d7a85f16..b880bd93bc5 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,6 @@ import jdk.test.lib.jfr.GCHelper; * @run main/othervm -XX:+UseSerialGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial */ -/** - * @test - * @bug 8264008 - * @requires vm.flagless - * @requires vm.hasJFR & vm.bits == 64 - * @requires vm.gc == "Serial" | vm.gc == null - * @library /test/lib /test/jdk - * @run main/othervm -XX:+UseSerialGC -XX:-UseCompressedClassPointers - * jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial - */ public class TestHeapSummaryEventDefNewSerial { public static void main(String[] args) throws Exception { HeapSummaryEventAllGcs.test(GCHelper.gcDefNew, GCHelper.gcSerialOld); diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java b/test/jdk/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java index 0ab663f130a..d7e6b3209d3 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,7 +70,7 @@ public class ObjectCountEventVerifier { private static long expectedFooArraySize(long count) { boolean runsOn32Bit = System.getProperty("sun.arch.data.model").equals("32"); int bytesPerWord = runsOn32Bit ? 4 : 8; - int objectHeaderSize = bytesPerWord * 3; // length will be aligned on 64 bits + int objectHeaderSize = runsOn32Bit ? 12 : 16; int alignmentInOopArray = runsOn32Bit ? 4 : 0; int ptrSize = bytesPerWord; return objectHeaderSize + alignmentInOopArray + count * ptrSize; diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java index eb69289aa5e..fbf2d8b543d 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import jdk.test.lib.jfr.GCHelper; * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != false * @library /test/lib /test/jdk - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1ConcurrentMark + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1ConcurrentMark */ public class TestObjectCountAfterGCEventWithG1ConcurrentMark { public static void main(String[] args) throws Exception { diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java index 6e91cf4c644..758ab6988b5 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import jdk.test.lib.jfr.GCHelper; * @requires (vm.gc == "G1" | vm.gc == null) * & vm.opt.ExplicitGCInvokesConcurrent != true * @library /test/lib /test/jdk - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1FullCollection + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1FullCollection */ public class TestObjectCountAfterGCEventWithG1FullCollection { public static void main(String[] args) throws Exception { diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java index 2a17e540be8..ac43d0d24e4 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import jdk.test.lib.jfr.GCHelper; * @requires vm.hasJFR * @requires vm.gc == "Parallel" | vm.gc == null * @library /test/lib /test/jdk - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithParallelOld + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithParallelOld */ public class TestObjectCountAfterGCEventWithParallelOld { public static void main(String[] args) throws Exception { diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java index 888eb089027..eac0e935fea 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import jdk.test.lib.jfr.GCHelper; * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithSerial + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithSerial */ public class TestObjectCountAfterGCEventWithSerial { public static void main(String[] args) throws Exception { diff --git a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java index a9034ba0eaa..0a5d48e83c8 100644 --- a/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java +++ b/test/jdk/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,7 +39,7 @@ import jdk.test.lib.jfr.Events; * @requires vm.hasJFR * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:MarkSweepDeadRatio=0 -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountEvent + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:-UseCompressedOops -XX:MarkSweepDeadRatio=0 -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountEvent */ public class TestObjectCountEvent { private static final String objectCountEventPath = EventNames.ObjectCount; diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java index 1346c36c04f..64389a0e921 100644 --- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java +++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 +29,7 @@ package jdk.jfr.event.gc.stacktrace; * * @requires vm.gc == "null" | vm.gc == "G1" * @library /test/lib /test/jdk - * @run main/othervm -XX:MaxNewSize=10M -Xmx128M -XX:+UseG1GC -Xlog:gc* + * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseG1GC -Xlog:gc* * -XX:FlightRecorderOptions:stackdepth=256 * jdk.jfr.event.gc.stacktrace.TestG1OldAllocationPendingStackTrace */ diff --git a/test/jdk/jdk/jfr/event/oldobject/OldObjects.java b/test/jdk/jdk/jfr/event/oldobject/OldObjects.java index ba90bb10a9e..bb0ca27836e 100644 --- a/test/jdk/jdk/jfr/event/oldobject/OldObjects.java +++ b/test/jdk/jdk/jfr/event/oldobject/OldObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -276,4 +276,16 @@ final public class OldObjects { throw new RuntimeException("Reference chain max length not respected. Found a chain of length " + length); } } + + public static int countChains(List events) throws IOException { + int found = 0; + for (RecordedEvent e : events) { + RecordedObject ro = e.getValue("object"); + if (ro.getValue("referrer") != null) { + found++; + } + } + System.out.println("Found chains: " + found); + return found; + } } diff --git a/test/jdk/jdk/jfr/event/oldobject/TestDFSWithSmallStack.java b/test/jdk/jdk/jfr/event/oldobject/TestDFSWithSmallStack.java new file mode 100644 index 00000000000..d25a6cd5f67 --- /dev/null +++ b/test/jdk/jdk/jfr/event/oldobject/TestDFSWithSmallStack.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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 jdk.jfr.event.oldobject; + +import java.util.LinkedList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test id=dfsonly + * @summary Tests that DFS works with a small stack + * @library /test/lib /test/jdk + * @requires vm.hasJFR + * @modules jdk.jfr/jdk.jfr.internal.test + * @run main/othervm -Xmx2g -XX:VMThreadStackSize=512 jdk.jfr.event.oldobject.TestDFSWithSmallStack dfsonly + */ + +/** + * @test id=bfsdfs + * @summary Tests that DFS works with a small stack + * @library /test/lib /test/jdk + * @requires vm.hasJFR + * @modules jdk.jfr/jdk.jfr.internal.test + * @run main/othervm -Xmx2g -XX:VMThreadStackSize=512 jdk.jfr.event.oldobject.TestDFSWithSmallStack bfsdfs + */ +public class TestDFSWithSmallStack { + + // Tests depth first search with a small stack. + + // An non-zero exit code, together with a missing hs-err file or possibly a missing jfr file, + // indicates a native stack overflow happened and is a fail condition for this test. + + // We build up an array of linked lists, each containing enough entries for DFS search to + // max out max_dfs_depth (but not greatly surpass it). + + private static final int TOTAL_OBJECTS = 10_000_000; + private static final int OBJECTS_PER_LIST = 5_000; + public static LinkedList[] leak; + + public static void main(String... args) throws Exception { + + switch (args[0]) { + case "dfsonly" -> WhiteBox.setSkipBFS(true); + case "bfsdfs" -> {} /* ignored */ + default -> throw new RuntimeException("Invalid argument"); + } + + WhiteBox.setWriteAllObjectSamples(true); + int count = 10; + + while (count > 0) { + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).with("cutoff", "infinity"); + r.start(); + leak = new LinkedList[TOTAL_OBJECTS / OBJECTS_PER_LIST]; + for (int i = 0; i < leak.length; i++) { + leak[i] = new LinkedList(); + for (int j = 0; j < OBJECTS_PER_LIST; j++) { + leak[i].add(new Object()); + } + } + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + if (OldObjects.countChains(events) >= 30) { + return; + } + System.out.println("Not enough chains found, retrying."); + } + count--; + leak = null; + } + } +} diff --git a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java index 0dccbc4495a..022a9c27674 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,6 +23,7 @@ package jdk.jfr.event.runtime; import static jdk.test.lib.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertEquals; import java.nio.file.Paths; import java.time.Duration; @@ -31,7 +32,6 @@ import java.util.*; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; -import jdk.test.lib.Asserts; import jdk.test.lib.jfr.EventNames; import jdk.test.lib.jfr.Events; import jdk.test.whitebox.WhiteBox; @@ -65,43 +65,30 @@ public class TestSafepointEvents { recording.stop(); try { - // Verify that each event type was seen at least once - List events = Events.fromRecording(recording); - for (String name : EVENT_NAMES) { - boolean found = false; - for (RecordedEvent event : events) { - found = event.getEventType().getName().equals(name); - if (found) { - break; - } - } - assertTrue(found, "Expected event from test [" + name + "]"); - } - // Collect all events grouped by safepoint id SortedMap> safepointIds = new TreeMap<>(); - for (RecordedEvent event : events) { + for (RecordedEvent event : Events.fromRecording(recording)) { Long safepointId = event.getValue("safepointId"); - if (!safepointIds.containsKey(safepointId)) { - safepointIds.put(safepointId, new HashSet<>()); - } - safepointIds.get(safepointId).add(event.getEventType().getName()); + String eventName = event.getEventType().getName(); + safepointIds.computeIfAbsent(safepointId, k -> new HashSet<>()).add(eventName); } - // The last safepoint may be related to stopping the recording and can thus be - // incomplete - so if there is more than one, ignore the last one - if (safepointIds.size() > 1) { - safepointIds.remove(safepointIds.lastKey()); - } - Asserts.assertGreaterThanOrEqual(safepointIds.size(), 1, "At least 1 safepoint must have occured"); - - // Verify that each safepoint id has an occurence of every event type, - // this ensures that all events related to a given safepoint had the same id - for (Set safepointEvents : safepointIds.values()) { - for (String name : EVENT_NAMES) { - assertTrue(safepointEvents.contains(name), "Expected event '" + name + "' to be present"); + // Select the first set that is complete. + Set safepointEvents = null; + for (Long key : safepointIds.keySet()) { + safepointEvents = safepointIds.get(key); + if (safepointEvents.size() == EVENT_NAMES.length) { + break; } } + assertEquals(safepointEvents.size(), EVENT_NAMES.length, + "At least one safepoint id should map to a set containing an instance of each enabled event type."); + + // Verify that the selected set contains an instance of each enabled event type. + for (String name : EVENT_NAMES) { + assertTrue(safepointEvents.contains(name), "Expected event '" + name + "' to be present"); + } + } catch (Throwable e) { recording.dump(Paths.get("failed.jfr")); throw e; diff --git a/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java b/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java index e1e135ab0b7..63d5dd16da9 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java @@ -52,7 +52,7 @@ public class TestThrowableInstrumentation { public static void main(String[] args) { // Compile Throwable:: with C1 (if available) if (!WHITE_BOX.enqueueInitializerForCompilation(java.lang.Throwable.class, COMP_LEVEL_SIMPLE)) { - if (!Platform.isServer() || isTieredCompilationEnabled() || Platform.isEmulatedClient()) { + if (!Platform.isServer() || isTieredCompilationEnabled()) { throw new RuntimeException("Unable to compile Throwable:: with C1"); } } diff --git a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java index 2571530a470..ebee42b52df 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,8 +28,9 @@ import java.lang.management.RuntimeMXBean; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; -import java.util.stream.Collectors; +import java.util.Properties; +import jdk.internal.vm.VMSupport; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; import jdk.test.lib.Asserts; @@ -38,6 +39,8 @@ import jdk.test.lib.jfr.Events; /** * @test + * @modules java.base/jdk.internal.vm + * @modules java.management * @requires vm.flagless * @requires vm.gc == "Serial" | vm.gc == null * @requires vm.hasJFR @@ -69,13 +72,12 @@ public class TestVMInfoEvent { Asserts.fail(String.format("%s does not contain %s", jvmVersion, mbean.getVmVersion())); } - String jvmArgs = Events.assertField(event, "jvmArguments").notNull().getValue(); - String jvmFlags = Events.assertField(event, "jvmFlags").notNull().getValue(); Long pid = Events.assertField(event, "pid").atLeast(0L).getValue(); Asserts.assertEquals(pid, ProcessHandle.current().pid()); - String eventArgs = (jvmFlags.trim() + " " + jvmArgs).trim(); - String beanArgs = mbean.getInputArguments().stream().collect(Collectors.joining(" ")); - Asserts.assertEquals(eventArgs, beanArgs, "Wrong inputArgs"); + + Properties agentProps = VMSupport.getAgentProperties(); + Events.assertField(event, "jvmArguments").equal(agentProps.getProperty("sun.jvm.args")); + Events.assertField(event, "jvmFlags").equal(agentProps.getProperty("sun.jvm.flags")); final String javaCommand = mbean.getSystemProperties().get("sun.java.command"); Events.assertField(event, "javaArguments").equal(javaCommand); diff --git a/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java b/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java index 75ed0d14ca5..502eefd5375 100644 --- a/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java +++ b/test/jdk/jdk/jfr/jvm/TestJFRIntrinsic.java @@ -131,10 +131,10 @@ public class TestJFRIntrinsic { int maxLevel = flagValue.intValue(); return IntStream.rangeClosed(1, maxLevel).toArray(); } else { - if (Platform.isServer() && !Platform.isEmulatedClient()) { + if (Platform.isServer()) { return new int[]{4}; } - if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { + if (Platform.isClient() || Platform.isMinimal()) { return new int[]{1}; } } diff --git a/test/jdk/jdk/nio/Basic.java b/test/jdk/jdk/nio/Basic.java index 02fcfbc4a4d..68f8f00e309 100644 --- a/test/jdk/jdk/nio/Basic.java +++ b/test/jdk/jdk/nio/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @bug 8198372 * @modules jdk.net java.base/sun.nio.ch:+open - * @run testng Basic + * @run junit Basic * @summary Basic tests for jdk.nio.Channels */ @@ -48,10 +48,14 @@ import jdk.nio.Channels.SelectableChannelCloser; import sun.nio.ch.IOUtil; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -@Test public class Basic { /** @@ -119,6 +123,7 @@ public class Basic { /** * Basic test of channel registered with Selector */ + @Test public void testSelect() throws IOException { Selector sel = Selector.open(); try (Connection connection = Connection.open()) { @@ -131,7 +136,7 @@ public class Basic { ch.configureBlocking(false); SelectionKey key = ch.register(sel, SelectionKey.OP_READ); int n = sel.selectNow(); - assertTrue(n == 0); + assertEquals(0, n); // write bytes to other end of connection SocketChannel peer = connection.channel2(); @@ -141,7 +146,7 @@ public class Basic { // channel should be selected n = sel.select(); - assertTrue(n == 1); + assertEquals(1, n); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isReadable()); assertFalse(key.isWritable()); @@ -150,7 +155,7 @@ public class Basic { // change interest set for writing, channel should be selected key.interestOps(SelectionKey.OP_WRITE); n = sel.select(); - assertTrue(n == 1); + assertEquals(1, n); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isWritable()); assertFalse(key.isReadable()); @@ -159,7 +164,7 @@ public class Basic { // change interest set for reading + writing, channel should be selected key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); n = sel.select(); - assertTrue(n == 1); + assertEquals(1, n); assertTrue(sel.selectedKeys().contains(key)); assertTrue(key.isWritable()); assertTrue(key.isReadable()); @@ -168,7 +173,7 @@ public class Basic { // change interest set to 0 to deregister, channel should not be selected key.interestOps(0); n = sel.selectNow(); - assertTrue(n == 0); + assertEquals(0, n); } finally { sel.close(); @@ -178,6 +183,7 @@ public class Basic { /** * Test that the SelectableChannelCloser implCloseChannel method is invoked. */ + @Test public void testImplCloseChannel() throws IOException { try (Connection connection = Connection.open()) { FileDescriptor fd = getFD(connection.channel1()); @@ -189,11 +195,11 @@ public class Basic { ch.close(); // implCloseChannel should been invoked once - assertTrue(closer.closeCount == 1); - assertTrue(closer.invokedToClose == ch); + assertEquals(1, closer.closeCount); + assertSame(ch, closer.invokedToClose); // implReleaseChannel should not have been invoked - assertTrue(closer.releaseCount == 0); + assertEquals(0, closer.releaseCount); } } } @@ -201,6 +207,7 @@ public class Basic { /** * Test that the SelectableChannelCloser implReleaseChannel method is invoked. */ + @Test public void testImplReleaseChannel() throws IOException { Selector sel = Selector.open(); try (Connection connection = Connection.open()) { @@ -217,50 +224,53 @@ public class Basic { ch.close(); // implCloseChannel should have been invoked - assertTrue(closer.closeCount == 1); - assertTrue(closer.invokedToClose == ch); + assertEquals(1, closer.closeCount); + assertSame(ch, closer.invokedToClose); // implReleaseChannel should not have been invoked - assertTrue(closer.releaseCount == 0); + assertEquals(0, closer.releaseCount); // flush the selector sel.selectNow(); // implReleaseChannel should have been invoked - assertTrue(closer.releaseCount == 1); - assertTrue(closer.invokedToRelease == ch); + assertEquals(1, closer.releaseCount); + assertSame(ch, closer.invokedToRelease); } finally { sel.close(); } } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void testInvalidFileDescriptor() throws IOException { FileDescriptor fd = IOUtil.newFD(-1); - Channels.readWriteSelectableChannel(fd, new SelectableChannelCloser() { - @Override - public void implCloseChannel(SelectableChannel sc) { } - @Override - public void implReleaseChannel(SelectableChannel sc) { } - }); + assertThrows + (IllegalArgumentException.class, + () -> Channels.readWriteSelectableChannel(fd, new SelectableChannelCloser() { + @Override + public void implCloseChannel(SelectableChannel sc) { } + @Override + public void implReleaseChannel(SelectableChannel sc) { }})); } - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNullFileDescriptor() throws IOException { - Channels.readWriteSelectableChannel(null, new SelectableChannelCloser() { - @Override - public void implCloseChannel(SelectableChannel sc) { } - @Override - public void implReleaseChannel(SelectableChannel sc) { } - }); + assertThrows + (NullPointerException.class, + () -> Channels.readWriteSelectableChannel(null, new SelectableChannelCloser() { + @Override + public void implCloseChannel(SelectableChannel sc) { } + @Override + public void implReleaseChannel(SelectableChannel sc) { }})); } - @Test(expectedExceptions = NullPointerException.class) + @Test public void testNullCloser() throws IOException { try (Connection connection = Connection.open()) { FileDescriptor fd = getFD(connection.channel1()); - Channels.readWriteSelectableChannel(fd, null); + assertThrows(NullPointerException.class, + () -> Channels.readWriteSelectableChannel(fd, null)); } } @@ -271,7 +281,8 @@ public class Basic { f.setAccessible(true); return (FileDescriptor) f.get(sc); } catch (Exception e) { - throw new Error(e); + fail(e); + return null; // appease compiler } } } diff --git a/test/jdk/jdk/nio/zipfs/Basic.java b/test/jdk/jdk/nio/zipfs/Basic.java index faaf634f93c..8416145299a 100644 --- a/test/jdk/jdk/nio/zipfs/Basic.java +++ b/test/jdk/jdk/nio/zipfs/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,15 +21,18 @@ * questions. */ +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.net.URISyntaxException; import java.nio.file.AccessMode; import java.nio.file.ClosedFileSystemException; import java.nio.file.FileStore; -import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.PathMatcher; import java.nio.file.ProviderMismatchException; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; @@ -37,103 +40,135 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.spi.FileSystemProvider; import java.net.URI; import java.io.IOException; -import java.util.Collections; import java.util.Map; + import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; -/** +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +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 8038500 8040059 8150366 8150496 8147539 8290047 * @summary Basic test for zip provider - * * @modules jdk.zipfs - * @run main Basic + * @run junit Basic */ - public class Basic { - public static void main(String[] args) throws Exception { - // Test: zip should be returned in provider list - boolean found = false; - for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { - if (provider.getScheme().equalsIgnoreCase("jar")) { - found = true; - break; - } - } - if (!found) - throw new RuntimeException("'jar' provider not installed"); - // create JAR file for test - Path jarFile = Utils.createJarFile("basic.jar", + static Path jarFile; + static URI uri; + + @BeforeAll + static void setup() throws IOException, URISyntaxException { + jarFile = Utils.createJarFile("basic.jar", "META-INF/services/java.nio.file.spi.FileSystemProvider"); + uri = new URI("jar", jarFile.toUri().toString(), null); + } + @AfterAll + static void cleanUp() throws IOException { + Files.deleteIfExists(jarFile); + } + + @Test + void providerListTest() { + // Test: zip should be returned in provider list + assertTrue(FileSystemProvider.installedProviders().stream() + .anyMatch(p -> p.getScheme().equalsIgnoreCase("jar")), + "'jar' provider not installed"); + } + + @Test + void newFileSystemTest() throws IOException { + // To test `newFileSystem`, close the shared FileSystem + var fs = FileSystems.newFileSystem(uri, Map.of()); + fs.close(); // Test: FileSystems#newFileSystem(Path) - Map env = Collections.emptyMap(); FileSystems.newFileSystem(jarFile).close(); - // Test: FileSystems#newFileSystem(URI) - URI uri = new URI("jar", jarFile.toUri().toString(), null); - FileSystem fs = FileSystems.newFileSystem(uri, env, null); + FileSystems.newFileSystem(uri, Map.of()).close(); + } - // Test: exercise toUri method - String expected = uri.toString() + "!/foo"; - String actual = fs.getPath("/foo").toUri().toString(); - if (!actual.equals(expected)) { - throw new RuntimeException("toUri returned '" + actual + - "', expected '" + expected + "'"); + @Test + void toUriTest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: exercise toUri method + String expected = uri.toString() + "!/foo"; + String actual = fs.getPath("/foo").toUri().toString(); + assertEquals(expected, actual, "toUri returned '" + actual + + "', expected '" + expected + "'"); } + } - // Test: exercise directory iterator and retrieval of basic attributes - Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); + @Test + void directoryIteratorTest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: exercise directory iterator and retrieval of basic attributes + Files.walkFileTree(fs.getPath("/"), new FileTreePrinter()); + } + } - // Test: copy file from zip file to current (scratch) directory - Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); - if (Files.exists(source)) { - Path target = Path.of(source.getFileName().toString()); - Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); - try { - long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); - long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); - if (s2 != s1) - throw new RuntimeException("target size != source size"); - } finally { - Files.delete(target); + @Test + void copyFileTest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: copy file from zip file to current (scratch) directory + Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider"); + if (Files.exists(source)) { + Path target = Path.of(source.getFileName().toString()); + Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); + try { + long s1 = Files.readAttributes(source, BasicFileAttributes.class).size(); + long s2 = Files.readAttributes(target, BasicFileAttributes.class).size(); + assertEquals(s1, s2, "target size != source size"); + } finally { + Files.delete(target); + } } } + } - // Test: FileStore - FileStore store = Files.getFileStore(fs.getPath("/")); - if (!store.supportsFileAttributeView("basic")) - throw new RuntimeException("BasicFileAttributeView should be supported"); - - // Test: watch register should throw PME - try { - fs.getPath("/") - .register(FileSystems.getDefault().newWatchService(), ENTRY_CREATE); - throw new RuntimeException("watch service is not supported"); - } catch (ProviderMismatchException x) { } - - // Test: IllegalArgumentException - try { - PathMatcher pm = fs.getPathMatcher(":glob"); - throw new RuntimeException("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException iae) { - } - try { - PathMatcher pm = fs.getPathMatcher("glob:"); - } catch (IllegalArgumentException iae) { - iae.printStackTrace(); - throw new RuntimeException("Unexpected IllegalArgumentException"); + @Test + void fileStoreTest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: FileStore + FileStore store = Files.getFileStore(fs.getPath("/")); + assertTrue(store.supportsFileAttributeView("basic"), + "BasicFileAttributeView should be supported"); } + } + @Test + void watchRegisterNPETest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: watch register should throw PME + assertThrows(ProviderMismatchException.class, () -> fs.getPath("/") + .register(FileSystems.getDefault().newWatchService(), ENTRY_CREATE), + "watch service is not supported"); + } + } + + @Test + void pathMatcherIAETest() throws IOException { + try (var fs = FileSystems.newFileSystem(uri, Map.of())) { + // Test: IllegalArgumentException + assertThrows(IllegalArgumentException.class, () -> fs.getPathMatcher(":glob"), + "IllegalArgumentException not thrown"); + assertDoesNotThrow(() -> fs.getPathMatcher("glob:"), + "Unexpected IllegalArgumentException"); + } + } + + @Test + void closedFileSystemTest() throws IOException { // Test: ClosedFileSystemException + var fs = FileSystems.newFileSystem(uri, Map.of()); fs.close(); - if (fs.isOpen()) - throw new RuntimeException("FileSystem should be closed"); - try { - fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ); - } catch (ClosedFileSystemException x) { } - - Files.deleteIfExists(jarFile); + assertFalse(fs.isOpen(), "FileSystem should be closed"); + assertThrows(ClosedFileSystemException.class, + () -> fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ)); } // FileVisitor that pretty prints a file tree diff --git a/test/jdk/jdk/nio/zipfs/CRCWriteTest.java b/test/jdk/jdk/nio/zipfs/CRCWriteTest.java index 3f333ae9a44..268f8f42faf 100644 --- a/test/jdk/jdk/nio/zipfs/CRCWriteTest.java +++ b/test/jdk/jdk/nio/zipfs/CRCWriteTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 @@ * questions. * */ -import org.testng.annotations.Test; import java.io.FileInputStream; import java.io.IOException; @@ -32,20 +31,20 @@ import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * @test * @bug 8232879 * @summary Test OutputStream::write with Zip FS * @modules jdk.zipfs - * @run testng/othervm CRCWriteTest + * @run junit/othervm CRCWriteTest */ public class CRCWriteTest { @@ -114,16 +113,16 @@ public class CRCWriteTest { // check entries with ZipFile API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertEquals(entries.length, zf.size()); + assertEquals(zf.size(), entries.length); // Check compression method and content of each entry for (Entry e : entries) { ZipEntry ze = zf.getEntry(e.name); assertNotNull(ze); - assertEquals(e.method, ze.getMethod()); + assertEquals(ze.getMethod(), e.method); try (InputStream in = zf.getInputStream(ze)) { byte[] bytes = in.readAllBytes(); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } @@ -134,9 +133,9 @@ public class CRCWriteTest { new ZipInputStream(new FileInputStream(zipfile.toFile()))) { ZipEntry ze; while ((ze = zis.getNextEntry()) != null) { - assertEquals(e.method, ze.getMethod()); + assertEquals(ze.getMethod(), e.method); byte[] bytes = zis.readAllBytes(); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } @@ -147,13 +146,13 @@ public class CRCWriteTest { Path top = fs.getPath("/"); long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) -> attrs.isRegularFile()).count(); - assertEquals(entries.length, count); + assertEquals(count, entries.length); // check content of each entry for (Entry e : entries) { Path file = fs.getPath(e.name); byte[] bytes = Files.readAllBytes(file); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } diff --git a/test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java b/test/jdk/jdk/nio/zipfs/ChannelTests.java similarity index 93% rename from test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java rename to test/jdk/jdk/nio/zipfs/ChannelTests.java index 3c7d18988b7..ffeed251649 100644 --- a/test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java +++ b/test/jdk/jdk/nio/zipfs/ChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,9 +21,9 @@ * questions. * */ -package test; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import util.ZipFsBaseTest; import java.io.ByteArrayOutputStream; @@ -33,7 +33,11 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.SeekableByteChannel; -import java.nio.file.*; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.Map; import java.util.Random; @@ -41,15 +45,24 @@ import java.util.Set; import java.util.zip.ZipEntry; import static java.nio.charset.StandardCharsets.UTF_8; -import static java.nio.file.StandardOpenOption.*; -import static org.testng.Assert.*; +import static java.nio.file.StandardOpenOption.APPEND; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.CREATE_NEW; +import static java.nio.file.StandardOpenOption.READ; +import static java.nio.file.StandardOpenOption.WRITE; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; -/** +/* * @test * @bug 8242006 * @summary Improve FileChannel and SeekableByteChannel Zip FS test coverage * @modules jdk.zipfs - * @run testng test.ChannelTests + * @run junit ChannelTests */ public class ChannelTests extends ZipFsBaseTest { @@ -81,7 +94,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcFromOSToZipTest(final Map env, final int compression) throws Exception { Entry e00 = Entry.of("Entry-00", compression, FIFTH_MAJOR); @@ -108,7 +122,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcFromZipToOSTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -125,7 +140,7 @@ public class ChannelTests extends ZipFsBaseTest { } // Check to see if the file exists and the bytes match assertTrue(Files.isRegularFile(osFile)); - assertEquals(Files.readAllBytes(osFile), e0.bytes); + assertArrayEquals(e0.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(zipFile); Files.deleteIfExists(osFile); } @@ -138,7 +153,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcFromZipToZipTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -170,7 +186,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param expectedCompression The compression to be used when copying the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap") + @ParameterizedTest + @MethodSource("copyMoveMap") public void sbcChangeCompressionTest(final Map env, final int compression, final int expectedCompression) throws Exception { @@ -206,7 +223,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcReadTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -222,7 +240,7 @@ public class ChannelTests extends ZipFsBaseTest { int bytesRead = sbc.read(buf); // Check to see if the expected bytes were read byte[] result = Arrays.copyOfRange(buf.array(), 0, bytesRead); - assertEquals(THE_SLAMS.getBytes(UTF_8), result); + assertArrayEquals(THE_SLAMS.getBytes(UTF_8), result); } Files.deleteIfExists(zipFile); } @@ -234,7 +252,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcWriteTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -261,7 +280,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcAppendTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -291,7 +311,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcTruncateTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -317,7 +338,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcFAETest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -344,7 +366,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcCloseTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -369,7 +392,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcCCETest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -401,7 +425,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcSizeTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -412,17 +437,17 @@ public class ChannelTests extends ZipFsBaseTest { try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); SeekableByteChannel sbc = Files.newByteChannel( zipfs.getPath(e0.name), Set.of(READ))) { - assertEquals(sbc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), sbc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); SeekableByteChannel sbc = Files.newByteChannel(zipfs.getPath(e0.name))) { - assertEquals(sbc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), sbc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); SeekableByteChannel sbc = Files.newByteChannel(zipfs.getPath("Entry-01") , Set.of(CREATE, WRITE))) { sbc.write(ByteBuffer.wrap(FIFTH_MAJOR.getBytes(UTF_8))); - assertEquals(sbc.size(), FIFTH_MAJOR.length()); + assertEquals(FIFTH_MAJOR.length(), sbc.size()); } Files.deleteIfExists(zipFile); } @@ -435,7 +460,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcOpenClosedTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -462,7 +488,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void sbcPositionTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -480,7 +507,7 @@ public class ChannelTests extends ZipFsBaseTest { for (var i = 0; i < fSize; i++) { long pos = RANDOM.nextInt(seed); sbc.position(pos); - assertEquals(sbc.position(), pos); + assertEquals(pos, sbc.position()); } } Files.deleteIfExists(zipFile); @@ -496,7 +523,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcFromOSToZipTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -522,7 +550,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcFromZipToOSTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -538,7 +567,7 @@ public class ChannelTests extends ZipFsBaseTest { } // Check to see if the file exists and the bytes match assertTrue(Files.isRegularFile(osFile)); - assertEquals(Files.readAllBytes(osFile), e0.bytes); + assertArrayEquals(e0.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(zipFile); Files.deleteIfExists(osFile); } @@ -551,7 +580,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcFromZipToZipTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -583,7 +613,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param expectedCompression The compression to be used when copying the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap") + @ParameterizedTest + @MethodSource("copyMoveMap") public void fcChangeCompressionTest(final Map env, final int compression, final int expectedCompression) throws Exception { @@ -620,7 +651,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcAppendTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -647,7 +679,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTruncateTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -672,7 +705,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcMapTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -701,7 +735,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcOpenClosedTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -728,7 +763,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcFAETest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -752,7 +788,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcCloseTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -777,7 +814,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcCCETest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -839,7 +877,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcReadTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -854,7 +893,7 @@ public class ChannelTests extends ZipFsBaseTest { int bytesRead = fc.read(buf); // Check to see if the expected bytes were read byte[] result = Arrays.copyOfRange(buf.array(), 0, bytesRead); - assertEquals(THE_SLAMS.getBytes(UTF_8), result); + assertArrayEquals(THE_SLAMS.getBytes(UTF_8), result); } Files.deleteIfExists(zipFile); } @@ -867,7 +906,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcReadPosTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -882,7 +922,7 @@ public class ChannelTests extends ZipFsBaseTest { int bytesRead = fc.read(buf, GRAND_SLAMS_HEADER.length()); // Check to see if the expected bytes were read byte[] result = Arrays.copyOfRange(buf.array(), 0, bytesRead); - assertEquals(GRAND_SLAMS.getBytes(UTF_8), result); + assertArrayEquals(GRAND_SLAMS.getBytes(UTF_8), result); } Files.deleteIfExists(zipFile); } @@ -895,7 +935,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcReadArrayTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -921,7 +962,7 @@ public class ChannelTests extends ZipFsBaseTest { bos.write(b.array()); } // Check to see if the returned byte array is what is expected - assertEquals(e0.bytes, bos.toByteArray()); + assertArrayEquals(bos.toByteArray(), e0.bytes); } Files.deleteIfExists(zipFile); } @@ -934,7 +975,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcReadArrayWithOffsetTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -969,7 +1011,7 @@ public class ChannelTests extends ZipFsBaseTest { bos.write(b.array()); } // Check to see if the returned byte array is what is expected - assertEquals(GRAND_SLAMS.getBytes(UTF_8), bos.toByteArray()); + assertArrayEquals(GRAND_SLAMS.getBytes(UTF_8), bos.toByteArray()); Files.deleteIfExists(zipFile); } @@ -981,7 +1023,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferToZipTest(final Map env, final int compression) throws Exception { Entry e00 = Entry.of("Entry-00", compression, THE_SLAMS); @@ -995,7 +1038,7 @@ public class ChannelTests extends ZipFsBaseTest { } // Verify the entry was copied verify(zipFile, e00); - assertEquals(Files.readAllBytes(osFile), e00.bytes); + assertArrayEquals(e00.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(osFile); Files.deleteIfExists(zipFile); } @@ -1008,7 +1051,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferToOsTest(final Map env, final int compression) throws Exception { Entry e00 = Entry.of("Entry-00", compression, THE_SLAMS); @@ -1021,7 +1065,7 @@ public class ChannelTests extends ZipFsBaseTest { fcTransferTo(zipfs.getPath(e00.name), osFile); } // Verify the entry was copied - assertEquals(Files.readAllBytes(osFile), e00.bytes); + assertArrayEquals(e00.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(osFile); Files.deleteIfExists(zipFile); } @@ -1034,7 +1078,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferToZipToZipTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -1065,7 +1110,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferFromOsTest(final Map env, final int compression) throws Exception { Entry e00 = Entry.of("Entry-00", compression, THE_SLAMS); @@ -1079,7 +1125,7 @@ public class ChannelTests extends ZipFsBaseTest { } // Verify the entry was copied zip(zipFile, env, e00); - assertEquals(Files.readAllBytes(osFile), e00.bytes); + assertArrayEquals(e00.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(osFile); Files.deleteIfExists(zipFile); } @@ -1092,7 +1138,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferFromZipTest(final Map env, final int compression) throws Exception { Entry e00 = Entry.of("Entry-00", compression, THE_SLAMS); @@ -1105,7 +1152,7 @@ public class ChannelTests extends ZipFsBaseTest { fcTransferFrom(zipfs.getPath(e00.name), osFile); } // Verify the bytes match - assertEquals(Files.readAllBytes(osFile), e00.bytes); + assertArrayEquals(e00.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(osFile); Files.deleteIfExists(zipFile); } @@ -1118,7 +1165,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTransferFromZipToZipTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -1148,7 +1196,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcWriteTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -1174,7 +1223,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcWritePosTest(final Map env, final int compression) throws Exception { // Use this value to replace the value specified for AUSTRALIAN_OPEN @@ -1209,7 +1259,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcWriteArrayTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -1227,7 +1278,7 @@ public class ChannelTests extends ZipFsBaseTest { FileChannel fc = FileChannel.open(zipfs.getPath(e0.name), Set.of(CREATE, WRITE))) { fc.write(bb); - assertEquals(fc.size(), GRAND_SLAMS.length()); + assertEquals(GRAND_SLAMS.length(), fc.size()); } // Verify the entry was created verify(zipFile, e0); @@ -1242,7 +1293,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcWriteArrayWithOffsetTest(final Map env, final int compression) throws Exception { @@ -1276,7 +1328,7 @@ public class ChannelTests extends ZipFsBaseTest { fc.position(GRAND_SLAMS_HEADER.length()); // Replace the original values fc.write(bb, 0, 2); - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } // Verify the entry was updated verify(zipFile, e0.content(updatedFile)); @@ -1290,7 +1342,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcForceWriteTest(final Map env, final int compression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS); @@ -1317,7 +1370,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcPositionTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -1334,7 +1388,7 @@ public class ChannelTests extends ZipFsBaseTest { for (var i = 0; i < fSize; i++) { long pos = RANDOM.nextInt(seed); fc.position(pos); - assertEquals(fc.position(), pos); + assertEquals(pos, fc.position()); } } Files.deleteIfExists(zipFile); @@ -1347,7 +1401,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcSizeTest(final Map env, final int compression) throws Exception { Path osFile = Path.of("GrandSlams.txt"); @@ -1360,29 +1415,29 @@ public class ChannelTests extends ZipFsBaseTest { // Validate the file sizes match try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath(e0.name))) { - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath(e0.name), Set.of(READ))) { - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath(e0.name), Set.of(READ, WRITE))) { - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath(e0.name), Set.of(WRITE))) { - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath(e0.name), Set.of(APPEND))) { - assertEquals(fc.size(), THE_SLAMS.length()); + assertEquals(THE_SLAMS.length(), fc.size()); } try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env); FileChannel fc = FileChannel.open(zipfs.getPath("Entry-01"), Set.of(CREATE, WRITE))) { fc.write(ByteBuffer.wrap(FIFTH_MAJOR.getBytes(UTF_8))); - assertEquals(fc.size(), FIFTH_MAJOR.length()); + assertEquals(FIFTH_MAJOR.length(), fc.size()); } Files.deleteIfExists(zipFile); Files.deleteIfExists(osFile); @@ -1395,7 +1450,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcLockTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); @@ -1426,7 +1482,8 @@ public class ChannelTests extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void fcTryLockTest(final Map env, final int compression) throws Exception { Path zipFile = generatePath(HERE, "test", ".zip"); diff --git a/test/jdk/jdk/nio/zipfs/CompressionModeTest.java b/test/jdk/jdk/nio/zipfs/CompressionModeTest.java index 1b024d4addf..1307f6f4ed7 100644 --- a/test/jdk/jdk/nio/zipfs/CompressionModeTest.java +++ b/test/jdk/jdk/nio/zipfs/CompressionModeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,6 @@ * */ -import org.testng.annotations.*; import java.io.IOException; import java.io.InputStream; @@ -32,22 +31,27 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.security.SecureRandom; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import static java.lang.String.format; import static java.util.stream.Collectors.joining; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * @test * @bug 8231093 * @summary Test Zip FS compressionMethod property * @modules jdk.zipfs - * @run testng CompressionModeTest + * @run junit CompressionModeTest */ public class CompressionModeTest { @@ -77,7 +81,8 @@ public class CompressionModeTest { * @throws Exception If an error occurs during the creation, verification or * deletion of the ZIP file */ - @Test(dataProvider = "validCompressionMethods", enabled = true) + @ParameterizedTest + @MethodSource("validCompressionMethods") public void testValidCompressionMehods(Map env, int compression) throws Exception { @@ -99,7 +104,8 @@ public class CompressionModeTest { * @throws Exception if an error occurs other than the expected * IllegalArgumentException */ - @Test(dataProvider = "invalidCompressionMethod") + @ParameterizedTest + @MethodSource("invalidCompressionMethod") public void testInvalidCompressionMethod(Map env) throws Exception { System.out.printf("ZIP FS Map = %s%n ", formatMap(env)); Path zipfile = generatePath(HERE, "test", ".zip"); @@ -131,44 +137,42 @@ public class CompressionModeTest { } /** - * DataProvider used to validate that you can create a ZIP file with and + * MethodSource used to validate that you can create a ZIP file with and * without compression. */ - @DataProvider(name = "validCompressionMethods") - private Object[][] validCompressionMethods() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED}, - {Map.of("create", "true", "compressionMethod", "STORED"), - ZipEntry.STORED}, - {Map.of("create", "true", "compressionMethod", "DEFLATED"), - ZipEntry.DEFLATED}, - {Map.of("create", "true", "compressionMethod", "stored"), - ZipEntry.STORED}, - {Map.of("create", "true", "compressionMethod", "deflated"), - ZipEntry.DEFLATED} - }; + private static Stream validCompressionMethods() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "compressionMethod", "STORED"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "compressionMethod", "DEFLATED"), + ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "compressionMethod", "stored"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "compressionMethod", "deflated"), + ZipEntry.DEFLATED) + ); } /** - * DataProvider used to validate that an IllegalArgumentException is thrown + * MethodSource used to validate that an IllegalArgumentException is thrown * for an invalid value for the compressionMethod property. */ - @DataProvider(name = "invalidCompressionMethod") - private Object[][] invalidCompressionMethod() { + private static Stream invalidCompressionMethod() { HashMap map = new HashMap<>(); map.put("create", "true"); map.put("compressionMethod", null); - return new Object[][]{ - {map}, - {Map.of("create", "true", "compressionMethod", "")}, - {Map.of("create", "true", "compressionMethod", - Integer.parseInt("5"))}, - {Map.of("create", "true", "compressionMethod", "invalid")} - }; + return Stream.of( + Arguments.of(map), + Arguments.of(Map.of("create", "true", "compressionMethod", "")), + Arguments.of(Map.of("create", "true", "compressionMethod", + Integer.parseInt("5"))), + Arguments.of(Map.of("create", "true", "compressionMethod", "invalid")) + ); } /** @@ -186,16 +190,16 @@ public class CompressionModeTest { // check entries with ZIP API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertEquals(entries, zf.size()); + assertEquals(zf.size(), entries); // check compression method and content of each entry for (int i = start; i < entries; i++) { ZipEntry ze = zf.getEntry("Entry-" + i); assertNotNull(ze); - assertEquals(method, ze.getMethod()); + assertEquals(ze.getMethod(), method); try (InputStream is = zf.getInputStream(ze)) { byte[] bytes = is.readAllBytes(); - assertTrue(Arrays.equals(bytes, ZIP_FILE_ENTRY)); + assertArrayEquals(ZIP_FILE_ENTRY, bytes); } } } @@ -209,13 +213,13 @@ public class CompressionModeTest { path.getFileName() != null && path.getFileName().toString().equals("META-INF"))) .count(); - assertEquals(entries, count); + assertEquals(count, entries); // check content of each entry for (int i = start; i < entries; i++) { Path file = fs.getPath("Entry-" + i); byte[] bytes = Files.readAllBytes(file); - assertTrue(Arrays.equals(bytes, ZIP_FILE_ENTRY)); + assertArrayEquals(ZIP_FILE_ENTRY, bytes); } } } diff --git a/test/jdk/jdk/nio/zipfs/CopyMoveTests.java b/test/jdk/jdk/nio/zipfs/CopyMoveTests.java index 1991528f521..fc941bfe056 100644 --- a/test/jdk/jdk/nio/zipfs/CopyMoveTests.java +++ b/test/jdk/jdk/nio/zipfs/CopyMoveTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,29 +22,32 @@ * */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.security.SecureRandom; -import java.util.Arrays; import java.util.Map; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import static java.lang.String.format; import static java.util.stream.Collectors.joining; -import static org.testng.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * @test * @bug 8231766 * @summary Test Files::copy and Files::move with Zip FS * @modules jdk.zipfs - * @run testng/othervm CopyMoveTests + * @run junit/othervm CopyMoveTests */ public class CopyMoveTests { // Enable debugging output @@ -58,33 +61,31 @@ public class CopyMoveTests { private static final SecureRandom random = new SecureRandom(); /* - * DataProvider used to verify that a FileAlreadyExistsException is + * MethodSource used to verify that a FileAlreadyExistsException is * thrown with copying a file without the REPLACE_EXISTING option */ - @DataProvider(name = "zipfsMap") - private Object[][] zipfsMap() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED} - }; + private static Stream zipfsMap() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED) + ); } /* - * DataProvider used to verify that an entry may be copied or moved within + * MethodSource used to verify that an entry may be copied or moved within * a Zip file system with the correct compression method */ - @DataProvider(name = "copyMoveMap") - private Object[][] copyMoveMap() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED, ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED, ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED, ZipEntry.STORED} - }; + private static Stream copyMoveMap() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED, ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED, ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED, ZipEntry.STORED) + ); } /** @@ -96,7 +97,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when copying the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void copyTest(Map createMap, int compression, int expectedCompression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, ZIP_FILE_VALUE); @@ -127,7 +129,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when copying the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void copyZipToZipTest(Map createMap, int compression, int expectedCompression) throws Exception { Entry e0 = Entry.of("Entry-0", compression, ZIP_FILE_VALUE); @@ -163,7 +166,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when copying the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void copyFromOsTest(Map createMap, int compression, int expectedCompression) throws Exception { @@ -196,7 +200,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when moving the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void CopyFromZipTest(Map createMap, int compression, int expectedCompression) throws Exception { @@ -217,7 +222,7 @@ public class CopyMoveTests { verify(zipFile, e0, e1); // Check to see if the file exists and the bytes match assertTrue(Files.isRegularFile(osFile)); - assertEquals(Files.readAllBytes(osFile), e0.bytes); + assertArrayEquals(e0.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(zipFile); Files.deleteIfExists(osFile); } @@ -231,7 +236,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when moving the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void moveTest(Map createMap, int compression, int expectedCompression) throws Exception { @@ -261,7 +267,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when moving the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void moveZipToZipTest(Map createMap, int compression, int expectedCompression) throws Exception { @@ -299,7 +306,8 @@ public class CopyMoveTests { * @param expectedCompression The compression to be used when moving the entry * @throws Exception If an error occurs */ - @Test(dataProvider = "copyMoveMap", enabled = true) + @ParameterizedTest + @MethodSource("copyMoveMap") public void moveFromZipTest(Map createMap, int compression, int expectedCompression) throws Exception { @@ -320,7 +328,7 @@ public class CopyMoveTests { verify(zipFile, e1); // Check to see if the file exists and the bytes match assertTrue(Files.isRegularFile(osFile)); - assertEquals(Files.readAllBytes(osFile), e0.bytes); + assertArrayEquals(e0.bytes, Files.readAllBytes(osFile)); Files.deleteIfExists(zipFile); Files.deleteIfExists(osFile); } @@ -332,7 +340,8 @@ public class CopyMoveTests { * @param createMap Properties used for creating the ZIP Filesystem * @throws Exception if an error occurs */ - @Test(dataProvider = "zipfsMap", enabled = true) + @ParameterizedTest + @MethodSource("zipfsMap") public void testFAEWithCopy(Map createMap, int compression) throws Exception { if (DEBUG) { @@ -444,17 +453,17 @@ public class CopyMoveTests { // check entries with zip API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertEquals(entries.length, zf.size()); + assertEquals(zf.size(), entries.length); // check compression method and content of each entry for (Entry e : entries) { ZipEntry ze = zf.getEntry(e.name); //System.out.printf("Name: %s, method: %s, Expected Method: %s%n", e.name, ze.getMethod(), e.method); assertNotNull(ze); - assertEquals(e.method, ze.getMethod()); + assertEquals(ze.getMethod(), e.method); try (InputStream in = zf.getInputStream(ze)) { byte[] bytes = in.readAllBytes(); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } @@ -465,13 +474,13 @@ public class CopyMoveTests { Path top = fs.getPath("/"); long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) -> attrs.isRegularFile()).count(); - assertEquals(entries.length, count); + assertEquals(count, entries.length); // check content of each entry for (Entry e : entries) { Path file = fs.getPath(e.name); byte[] bytes = Files.readAllBytes(file); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } diff --git a/test/jdk/jdk/nio/zipfs/DirectoryStreamTests.java b/test/jdk/jdk/nio/zipfs/DirectoryStreamTests.java index 0a255caa812..6aaaa4d5cd7 100644 --- a/test/jdk/jdk/nio/zipfs/DirectoryStreamTests.java +++ b/test/jdk/jdk/nio/zipfs/DirectoryStreamTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,10 +21,6 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.file.*; @@ -33,9 +29,17 @@ import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import java.util.regex.PatternSyntaxException; +import java.util.stream.Stream; import java.util.zip.ZipException; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * @test @@ -43,7 +47,7 @@ import static org.testng.Assert.*; * @summary ZIP File System tests that leverage DirectoryStream * @modules jdk.zipfs * @compile DirectoryStreamTests.java - * @run testng DirectoryStreamTests + * @run junit DirectoryStreamTests */ public class DirectoryStreamTests { @@ -65,8 +69,8 @@ public class DirectoryStreamTests { /** * Create the JAR files used by the tests */ - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { emptyJarFile = Paths.get("emptyDir.jar"); try (FileSystem zipfs = ZIPFS_PROVIDER.newFileSystem(emptyJarFile, ZIPFS_MAP)) { @@ -80,8 +84,8 @@ public class DirectoryStreamTests { /** * Remove JAR files used by test as part of clean-up */ - @AfterClass - public void tearDown() throws Exception { + @AfterAll + public static void tearDown() throws Exception { Files.deleteIfExists(jarFile); Files.deleteIfExists(emptyJarFile); } @@ -91,7 +95,8 @@ public class DirectoryStreamTests { * System and that the returned Iterator correctly indicates whether the * filter has been matched */ - @Test(dataProvider = "filterTestValues") + @ParameterizedTest + @MethodSource("filterValues") public void test0000(String glob, boolean expectedResult, String errMsg) throws Exception { @@ -106,7 +111,7 @@ public class DirectoryStreamTests { } })) { - assertEquals(ds.iterator().hasNext(), expectedResult, errMsg); + assertEquals(expectedResult, ds.iterator().hasNext(), errMsg); } } @@ -114,7 +119,8 @@ public class DirectoryStreamTests { * Validate that you can specify a glob using the ZIP File System and that the * returned Iterator correctly indicates whether the glob pattern has been matched */ - @Test(dataProvider = "filterTestValues") + @ParameterizedTest + @MethodSource("filterValues") public void test0001(String glob, boolean expectedResult, String errMsg) throws Exception { @@ -122,7 +128,7 @@ public class DirectoryStreamTests { ZIPFS_PROVIDER.newFileSystem(Paths.get("basic.jar"), UNZIPFS_MAP); DirectoryStream ds = Files.newDirectoryStream(zipfs.getPath("/"), glob)) { - assertEquals(ds.iterator().hasNext(), expectedResult, errMsg); + assertEquals(expectedResult, ds.iterator().hasNext(), errMsg); } } @@ -144,7 +150,8 @@ public class DirectoryStreamTests { * Validate that the correct type of paths are returned when creating a * DirectoryStream */ - @Test(dataProvider = "startPaths") + @ParameterizedTest + @MethodSource("Name") public void test0003(String startPath, String expectedPath) throws IOException { try (FileSystem zipfs = @@ -153,9 +160,8 @@ public class DirectoryStreamTests { Files.newDirectoryStream(zipfs.getPath(startPath))) { for (Path entry : stream) { - assertTrue(entry.toString().equals(expectedPath), - String.format("Error: Expected path %s not found when" - + " starting at %s%n", expectedPath, entry)); + assertEquals(entry.toString(), expectedPath, String.format("Error: Expected path %s not found when" + + " starting at %s%n", expectedPath, entry)); } } } @@ -310,35 +316,31 @@ public class DirectoryStreamTests { /** * Glob values to use to validate filtering */ - @DataProvider(name = "filterTestValues") - public static Object[][] filterValues() { + public static Stream filterValues() { String expectedMsg = "Error: Matching entries were expected but not found!!!"; String notExpectedMsg = "Error: No matching entries expected but were found!!!"; - return new Object[][]{ - - {"M*", true, expectedMsg}, - {"I*", false, notExpectedMsg} - }; + return Stream.of( + Arguments.of("M*", true, expectedMsg), + Arguments.of("I*", false, notExpectedMsg) + ); } /** * Starting Path for the DirectoryStream and the expected path to be returned * when traversing the stream */ - @DataProvider(name = "startPaths") - public static Object[][] Name() { - return new Object[][]{ - - {"META-INF", "META-INF/services"}, - {"/META-INF", "/META-INF/services"}, - {"/META-INF/../META-INF","/META-INF/../META-INF/services" }, - {"./META-INF", "./META-INF/services"}, - {"", "META-INF"}, - {"/", "/META-INF"}, - {".", "./META-INF"}, - {"./", "./META-INF"} - }; + public static Stream Name() { + return Stream.of( + Arguments.of("META-INF", "META-INF/services"), + Arguments.of("/META-INF", "/META-INF/services"), + Arguments.of("/META-INF/../META-INF", "/META-INF/../META-INF/services" ), + Arguments.of("./META-INF", "./META-INF/services"), + Arguments.of("", "META-INF"), + Arguments.of("/", "/META-INF"), + Arguments.of(".", "./META-INF"), + Arguments.of("./", "./META-INF") + ); } /** diff --git a/test/jdk/jdk/nio/zipfs/EndOfCenValidation.java b/test/jdk/jdk/nio/zipfs/EndOfCenValidation.java new file mode 100644 index 00000000000..e8012cc3ea3 --- /dev/null +++ b/test/jdk/jdk/nio/zipfs/EndOfCenValidation.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2023, 2026, 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 + * @modules java.base/jdk.internal.util + * @summary Verify that ZipFileSystem rejects files with CEN sizes exceeding the implementation limit + * @library /test/lib + * @build jdk.test.lib.util.ZipUtils + * @run junit/othervm EndOfCenValidation + */ + +import jdk.internal.util.ArraysSupport; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.zip.ZipException; + +import static jdk.test.lib.util.ZipUtils.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * This test augments {@link TestTooManyEntries}. It creates sparse ZIPs where + * the CEN size is inflated to the desired value. This helps this test run + * fast with much less resources. + * + * While the CEN in these files are zero-filled and the produced ZIPs are technically + * invalid, the CEN is never actually read by ZipFileSystem since it does + * 'End of central directory record' (END header) validation before reading the CEN. + */ +public class EndOfCenValidation { + + // Zip files produced by this test + static final Path CEN_TOO_LARGE_ZIP = Path.of("cen-size-too-large.zip"); + static final Path INVALID_CEN_SIZE = Path.of("invalid-zen-size.zip"); + static final Path BAD_CEN_OFFSET_ZIP = Path.of("bad-cen-offset.zip"); + static final Path BAD_ENTRY_COUNT_ZIP = Path.of("bad-entry-count.zip"); + + // Maximum allowed CEN size allowed by ZipFileSystem + static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; + + /** + * Delete big files after test, in case the file system did not support sparse files. + * @throws IOException if an error occurs + */ + @AfterEach + public void cleanup() throws IOException { + Files.deleteIfExists(CEN_TOO_LARGE_ZIP); + Files.deleteIfExists(INVALID_CEN_SIZE); + Files.deleteIfExists(BAD_CEN_OFFSET_ZIP); + Files.deleteIfExists(BAD_ENTRY_COUNT_ZIP); + } + + /** + * Validates that an 'End of central directory record' (END header) with a CEN + * length exceeding {@link #MAX_CEN_SIZE} limit is rejected + * @throws IOException if an error occurs + */ + @Test + public void shouldRejectTooLargeCenSize() throws IOException { + int size = MAX_CEN_SIZE + 1; + Path zip = zipWithModifiedEndRecord(size, true, 0, CEN_TOO_LARGE_ZIP); + verifyRejection(zip, INVALID_CEN_SIZE_TOO_LARGE); + } + + /** + * Validate that an 'End of central directory record' (END header) + * where the value of the CEN size field exceeds the position of + * the END header is rejected. + * @throws IOException if an error occurs + */ + @Test + public void shouldRejectInvalidCenSize() throws IOException { + int size = MAX_CEN_SIZE; + Path zip = zipWithModifiedEndRecord(size, false, 0, INVALID_CEN_SIZE); + verifyRejection(zip, INVALID_CEN_BAD_SIZE); + } + + /** + * Validate that an 'End of central directory record' (the END header) + * where the value of the CEN offset field is larger than the position + * of the END header minus the CEN size is rejected + * @throws IOException if an error occurs + */ + @Test + public void shouldRejectInvalidCenOffset() throws IOException { + int size = MAX_CEN_SIZE; + Path zip = zipWithModifiedEndRecord(size, true, 100, BAD_CEN_OFFSET_ZIP); + verifyRejection(zip, INVALID_CEN_BAD_OFFSET); + } + + /** + * Validate that a 'Zip64 End of Central Directory' record (the END header) + * where the value of the 'total entries' field is larger than what fits + * in the CEN size is rejected. + * + * @throws IOException if an error occurs + */ + @ParameterizedTest + @ValueSource(longs = { + -1, // Negative + Long.MIN_VALUE, // Very negative + 0x3B / 3L - 1, // Cannot fit in test ZIP's CEN + MAX_CEN_SIZE / 3 + 1, // Too large to allocate int[] entries array + Long.MAX_VALUE // Unreasonably large + }) + public void shouldRejectBadTotalEntries(long totalEntries) throws IOException { + Path zip = zip64WithModifiedTotalEntries(BAD_ENTRY_COUNT_ZIP, totalEntries); + verifyRejection(zip, INVALID_BAD_ENTRY_COUNT); + } + + /** + * Verify that ZipFileSystem.newFileSystem rejects the ZIP file with a ZipException + * with the given message + * @param zip ZIP file to open + * @param msg exception message to expect + */ + private static void verifyRejection(Path zip, String msg) { + ZipException ex = assertThrows(ZipException.class, + () -> FileSystems.newFileSystem(zip)); + assertEquals(msg, ex.getMessage()); + } +} diff --git a/test/jdk/jdk/nio/zipfs/HasDotDotTest.java b/test/jdk/jdk/nio/zipfs/HasDotDotTest.java index 6c6111dd0ab..26a4a597d3a 100644 --- a/test/jdk/jdk/nio/zipfs/HasDotDotTest.java +++ b/test/jdk/jdk/nio/zipfs/HasDotDotTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,8 +21,6 @@ * questions. * */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -37,14 +35,20 @@ import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * @test * @bug 8251329 * @summary Excercise Zip FS with "." or ".." in a Zip Entry name * @modules jdk.zipfs - * @run testng/othervm HasDotDotTest + * @run junit/othervm HasDotDotTest */ public class HasDotDotTest { // Zip file to be created @@ -56,22 +60,21 @@ public class HasDotDotTest { private static final boolean DEBUG = false; /** - * DataProvider containing Zip entry names which should result in an IOException + * MethodSource containing Zip entry names which should result in an IOException * @return Array of Zip entry names */ - @DataProvider - private Object[][] checkForDotOrDotDotPaths() { - return new Object[][]{ - {"/./foo"}, - {"/../foo"}, - {"/../foo/.."}, - {"/foo/.."}, - {"/foo/."}, - {"/.."}, - {"/."}, - {"/.foo/./"}, - {"/.././"}, - }; + private static Stream checkForDotOrDotDotPaths() { + return Stream.of( + Arguments.of("/./foo"), + Arguments.of("/../foo"), + Arguments.of("/../foo/.."), + Arguments.of("/foo/.."), + Arguments.of("/foo/."), + Arguments.of("/.."), + Arguments.of("/."), + Arguments.of("/.foo/./"), + Arguments.of("/.././") + ); } // Zip entry names to create a Zip file with for validating they are not @@ -111,7 +114,8 @@ public class HasDotDotTest { * @param path * @throws IOException */ - @Test(dataProvider = "checkForDotOrDotDotPaths") + @ParameterizedTest + @MethodSource("checkForDotOrDotDotPaths") public void hasDotOrDotDotTest(String path) throws IOException { if (DEBUG) { System.out.printf("Validating entry: %s%n", path); @@ -147,7 +151,7 @@ public class HasDotDotTest { } } Arrays.sort(EXPECTED_PATHS); - assertTrue(Arrays.equals(entries, EXPECTED_PATHS)); + assertArrayEquals(EXPECTED_PATHS, entries); } } Files.deleteIfExists(ZIPFILE); diff --git a/test/jdk/jdk/nio/zipfs/InvalidZipHeaderTests.java b/test/jdk/jdk/nio/zipfs/InvalidZipHeaderTests.java index 92acc98eb84..7a16f3026f2 100644 --- a/test/jdk/jdk/nio/zipfs/InvalidZipHeaderTests.java +++ b/test/jdk/jdk/nio/zipfs/InvalidZipHeaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,10 +21,6 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.FileOutputStream; import java.io.IOException; @@ -36,9 +32,17 @@ import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.stream.Collectors; +import java.util.stream.Stream; import static java.nio.file.Files.walk; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * @test @@ -46,7 +50,7 @@ import static org.testng.Assert.*; * @summary Validate that you can iterate a ZIP file with invalid ZIP header entries * @modules jdk.zipfs * @compile InvalidZipHeaderTests.java - * @run testng InvalidZipHeaderTests + * @run junit InvalidZipHeaderTests */ public class InvalidZipHeaderTests { @@ -57,16 +61,16 @@ public class InvalidZipHeaderTests { /** * Create the JAR files used by the tests */ - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { createInvalidJarFile(); } /** * Remove JAR files used by test as part of clean-up */ - @AfterClass - public void tearDown() throws Exception { + @AfterAll + public static void tearDown() throws Exception { Files.deleteIfExists(Path.of(INVALID_JAR_FILE)); } @@ -75,17 +79,17 @@ public class InvalidZipHeaderTests { * Validate that you can walk a ZIP archive with header entries * such as "foo//" */ - @Test(dataProvider = "startPaths") + @ParameterizedTest + @MethodSource("Name") public void walkInvalidHeaderTest(String startPath, List expectedPaths) throws IOException { try (FileSystem zipfs = FileSystems.newFileSystem(Path.of(INVALID_JAR_FILE))) { List result = walk(zipfs.getPath(startPath)) .map(f -> f.toString()).collect(Collectors.toList()); - assertTrue(result.equals(expectedPaths), - String.format("Error: Expected paths not found when walking" - + "%s, starting at %s%n", INVALID_JAR_FILE, - startPath)); + assertEquals(result, expectedPaths, String.format("Error: Expected paths not found when walking" + + "%s, starting at %s%n", INVALID_JAR_FILE, + startPath)); } } @@ -94,18 +98,16 @@ public class InvalidZipHeaderTests { * Starting Path for walking the ZIP archive and the expected paths to be returned * when traversing the archive */ - @DataProvider(name = "startPaths") - public static Object[][] Name() { - return new Object[][]{ - - {"luckydog", List.of("luckydog", "luckydog/outfile.txt")}, - {"/luckydog", List.of("/luckydog", "/luckydog/outfile.txt")}, - {"./luckydog", List.of("./luckydog", "./luckydog/outfile.txt")}, - {"", List.of( "", "luckydog", "luckydog/outfile.txt")}, - {"/", List.of("/", "/luckydog", "/luckydog/outfile.txt")}, - {".", List.of(".", "./luckydog", "./luckydog/outfile.txt")}, - {"./", List.of(".", "./luckydog", "./luckydog/outfile.txt")} - }; + public static Stream Name() { + return Stream.of( + Arguments.of("luckydog", List.of("luckydog", "luckydog/outfile.txt")), + Arguments.of("/luckydog", List.of("/luckydog", "/luckydog/outfile.txt")), + Arguments.of("./luckydog", List.of("./luckydog", "./luckydog/outfile.txt")), + Arguments.of("", List.of( "", "luckydog", "luckydog/outfile.txt")), + Arguments.of("/", List.of("/", "/luckydog", "/luckydog/outfile.txt")), + Arguments.of(".", List.of(".", "./luckydog", "./luckydog/outfile.txt")), + Arguments.of("./", List.of(".", "./luckydog", "./luckydog/outfile.txt")) + ); } /** diff --git a/test/jdk/jdk/nio/zipfs/LargeCompressedEntrySizeTest.java b/test/jdk/jdk/nio/zipfs/LargeCompressedEntrySizeTest.java index 1dcfe461dda..44ec884db2d 100644 --- a/test/jdk/jdk/nio/zipfs/LargeCompressedEntrySizeTest.java +++ b/test/jdk/jdk/nio/zipfs/LargeCompressedEntrySizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,9 +22,6 @@ * */ -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; import java.io.IOException; import java.io.OutputStream; @@ -36,24 +33,28 @@ import java.util.Collections; import java.util.Random; import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + /** * @test * @bug 8190753 8011146 * @summary Verify that using zip filesystem for opening an outputstream for a zip entry whose * compressed size is large, doesn't run into "Negative initial size" exception - * @run testng/manual/othervm LargeCompressedEntrySizeTest + * @run junit/manual/othervm LargeCompressedEntrySizeTest */ public class LargeCompressedEntrySizeTest { private static final String LARGE_FILE_NAME = "LargeZipEntry.txt"; private static final String ZIP_FILE_NAME = "8190753-test-compressed-size.zip"; - @BeforeMethod + @BeforeEach public void setUp() throws IOException { deleteFiles(); } - @AfterMethod + @AfterEach public void tearDown() throws IOException { deleteFiles(); } diff --git a/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java b/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java index 3b05f3339d7..45251c95718 100644 --- a/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java +++ b/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,32 +22,37 @@ * */ -import org.testng.annotations.*; - import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.*; import java.security.SecureRandom; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.function.Consumer; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import static java.lang.Boolean.TRUE; import static java.lang.String.format; import static java.util.stream.Collectors.joining; -import static org.testng.Assert.*; -/** +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +/* * @test * @bug 8230870 * @summary Test ZIP Filesystem behavior with ~64k entries * @modules jdk.zipfs - * @run testng LargeEntriesTest + * @run junit/othervm LargeEntriesTest */ public class LargeEntriesTest { @@ -86,34 +91,41 @@ public class LargeEntriesTest { private static final SecureRandom random = new SecureRandom(); /** - * Fields used for timing runs + * Fields used for timing runs. + * Toggle on by running with "-Dtiming.enabled=true". */ private static int testNumberRunning; private static long runningTestTime; private static long startTestRunTime; private static final double NANOS_IN_SECOND = 1_000_000_000.0; + private static final boolean TIMING_ENABLED = + Boolean.getBoolean("timing.enabled"); - @BeforeTest(enabled = false) - public void beforeTest() { + @BeforeAll + public static void beforeTest() { + if (!TIMING_ENABLED) return; startTestRunTime = System.nanoTime(); } - @AfterTest(enabled = false) - public void afterTest() { + @AfterAll + public static void afterTest() { + if (!TIMING_ENABLED) return; long endTestRunTime = System.nanoTime(); long duration = endTestRunTime - startTestRunTime; System.out.printf("#### Completed test run, total running time: %.4f in seconds%n", duration / NANOS_IN_SECOND); } - @BeforeMethod(enabled = false) - public static void beforeMethod() { + @BeforeEach + public void beforeMethod() { + if (!TIMING_ENABLED) return; runningTestTime = System.nanoTime(); System.out.printf("**** Starting test number: %s%n", testNumberRunning); } - @AfterMethod(enabled = false) + @AfterEach public void afterMethod() { + if (!TIMING_ENABLED) return; long endRunningTestTime = System.nanoTime(); long duration = endRunningTestTime - runningTestTime; System.out.printf("**** Completed test number: %s, Time: %.4f%n", @@ -132,7 +144,8 @@ public class LargeEntriesTest { * @throws Exception If an error occurs during the creation, verification or * deletion of the ZIP file */ - @Test(dataProvider = "zipfsMap", enabled = true) + @ParameterizedTest + @MethodSource("zipfsMap") public void testZip(Map env, int compression) throws Exception { System.out.printf("ZIP FS Map = %s, Compression mode= %s%n ", @@ -158,7 +171,8 @@ public class LargeEntriesTest { * @throws Exception If an error occurs during the creation, verification or * deletion of the ZIP file */ - @Test(dataProvider = "zip64Map", enabled = true) + @ParameterizedTest + @MethodSource("zip64Map") public void testForceZIP64End(Map env, int compression) throws Exception { System.out.printf("ZIP FS Map = %s, Compression mode= %s%n ", @@ -183,7 +197,8 @@ public class LargeEntriesTest { * @throws Exception If an error occurs during the creation, verification or * deletion of the JAR file */ - @Test(dataProvider = "zipfsMap", enabled = true) + @ParameterizedTest + @MethodSource("zipfsMap") public void testJar(Map env, int compression) throws Exception { for (int entries = ZIP64_ENTRIES - 1; entries < ZIP64_ENTRIES + 2; entries++) { Path jar = generatePath(HERE, "test", ".jar"); @@ -271,36 +286,34 @@ public class LargeEntriesTest { } /* - * DataProvider used to validate that you can create a ZIP file with and + * MethodSource used to validate that you can create a ZIP file with and * without compression. */ - @DataProvider(name = "zipfsMap") - private Object[][] zipfsMap() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED} - }; + private static Stream zipfsMap() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED) + ); } /* - * DataProvider used to validate that you can create a ZIP file with/without + * MethodSource used to validate that you can create a ZIP file with/without * ZIP64 format extensions */ - @DataProvider(name = "zip64Map") - private Object[][] zip64Map() { - return new Object[][]{ - {Map.of("create", "true", "forceZIP64End", "true"), - ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true", - "forceZIP64End", "true"), ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "false", - "forceZIP64End", "false"), ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true", - "forceZIP64End", "false"), ZipEntry.STORED} - }; + private static Stream zip64Map() { + return Stream.of( + Arguments.of(Map.of("create", "true", "forceZIP64End", "true"), + ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true", + "forceZIP64End", "true"), ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "false", + "forceZIP64End", "false"), ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true", + "forceZIP64End", "false"), ZipEntry.STORED) + ); } /** @@ -319,16 +332,16 @@ public class LargeEntriesTest { // check entries with ZIP API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertEquals(entries, zf.size()); + assertEquals(zf.size(), entries); // check compression method and content of each entry for (int i = start; i < entries; i++) { ZipEntry ze = zf.getEntry("Entry-" + i); assertNotNull(ze); - assertEquals(method, ze.getMethod()); + assertEquals(ze.getMethod(), method); try (InputStream is = zf.getInputStream(ze)) { byte[] bytes = is.readAllBytes(); - assertTrue(Arrays.equals(bytes, ZIP_FILE_ENTRY)); + assertArrayEquals(ZIP_FILE_ENTRY, bytes); } } } @@ -342,13 +355,13 @@ public class LargeEntriesTest { path.getFileName() != null && path.getFileName().toString().equals("META-INF"))) .count(); - assertEquals(entries, count); + assertEquals(count, entries); // check content of each entry for (int i = start; i < entries; i++) { Path file = fs.getPath("Entry-" + i); byte[] bytes = Files.readAllBytes(file); - assertTrue(Arrays.equals(bytes, ZIP_FILE_ENTRY)); + assertArrayEquals(ZIP_FILE_ENTRY, bytes); } } @@ -359,7 +372,7 @@ public class LargeEntriesTest { boolean requireZip64 = entries >= ZIP64_ENTRIES || isZip64Forced; System.out.printf(" isZip64Forced = %s, foundZip64= %s, requireZip64= %s%n", isZip64Forced, foundZip64, requireZip64); - assertEquals(requireZip64, foundZip64); + assertEquals(foundZip64, requireZip64); } @@ -515,7 +528,7 @@ public class LargeEntriesTest { * @return This Result object */ Result assertSuccess() { - assertEquals(ec, 0, format("Expected ec 0, received: %s, output [%s]", ec, output)); + assertEquals(0, ec, format("Expected ec 0, received: %s, output [%s]", ec, output)); return this; } diff --git a/test/jdk/jdk/nio/zipfs/testng/test/ManifestOrderTest.java b/test/jdk/jdk/nio/zipfs/ManifestOrderTest.java similarity index 91% rename from test/jdk/jdk/nio/zipfs/testng/test/ManifestOrderTest.java rename to test/jdk/jdk/nio/zipfs/ManifestOrderTest.java index e3ee1bac778..7eb8f70d1b7 100644 --- a/test/jdk/jdk/nio/zipfs/testng/test/ManifestOrderTest.java +++ b/test/jdk/jdk/nio/zipfs/ManifestOrderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,33 +21,45 @@ * questions. * */ -package test; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import util.ZipFsBaseTest; import java.io.InputStream; import java.io.OutputStream; -import java.nio.file.*; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.jar.*; +import java.util.jar.Attributes; import java.util.jar.Attributes.Name; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.Manifest; import java.util.spi.ToolProvider; import java.util.stream.Collectors; import java.util.zip.ZipEntry; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -/** +/* * @test * @bug 8211917 * @summary Validate that Zip FS will always add META-INF/MANIFEST.MF to the * beginning of a Zip file allowing the Manifest be found and processed * by java.util.jar.JarInputStream. - + * @run junit ManifestOrderTest */ public class ManifestOrderTest extends ZipFsBaseTest { @@ -73,8 +85,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { /** * Create the Manifests and Map of attributes included in the Manifests */ - @BeforeSuite - public void setup() { + @BeforeAll + public static void setup() { String jdkVendor = System.getProperty("java.vendor"); String jdkVersion = System.getProperty("java.version"); String attributeKey = "Player"; @@ -109,7 +121,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testJarWithManifestAddedFirst(final Map env, final int compression) throws Exception { @@ -137,7 +150,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testJarWithManifestAddedLast(final Map env, final int compression) throws Exception { final Path jarPath = generatePath(HERE, "test", ".jar"); @@ -164,7 +178,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testJarWithManifestAddedInBetween(final Map env, final int compression) throws Exception { @@ -192,7 +207,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testJarWithNoManifest(final Map env, final int compression) throws Exception { final Path jarPath = generatePath(HERE, "test", ".jar"); @@ -218,7 +234,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testManifestCopiedFromOSFile(final Map env, final int compression) throws Exception { final Path jarPath = generatePath(HERE, "test", ".jar"); @@ -248,7 +265,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void copyJarToJarTest(final Map env, final int compression) throws Exception { final Path jarPath = generatePath(HERE, "test", ".jar"); @@ -290,7 +308,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "compressionMethods") + @ParameterizedTest + @MethodSource("compressionMethods") public void testJarToolGeneratedJarWithManifest(final int compression) throws Exception { @@ -319,7 +338,7 @@ public class ManifestOrderTest extends ZipFsBaseTest { jarPath.getFileName().toString(), manifestFile.toAbsolutePath().toString(), "-C", tmpdir.toAbsolutePath().toString(), "."); - assertEquals(exitCode, 0, "jar tool exited with failure"); + assertEquals(0, exitCode, "jar tool exited with failure"); verify(jarPath, MANIFEST_ATTRS, compression, entries); // Add an additional entry and re-verify @@ -338,7 +357,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void createWithManifestTest(final Map env, final int compression) throws Exception { Path jarPath = generatePath(HERE, "test", ".jar"); @@ -373,7 +393,8 @@ public class ManifestOrderTest extends ZipFsBaseTest { * @param compression The compression used when writing the entries * @throws Exception If an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void updateManifestTest(final Map env, final int compression) throws Exception { final Path jarPath = generatePath(HERE, "test", ".jar"); @@ -442,12 +463,12 @@ public class ManifestOrderTest extends ZipFsBaseTest { } final Entry e = expected.remove(je.getName()); assertNotNull(e, "Unexpected entry in jar "); - assertEquals(je.getMethod(), e.method, "Compression method mismatch"); - assertEquals(jis.readAllBytes(), e.bytes); + assertEquals(e.method, je.getMethod(), "Compression method mismatch"); + assertArrayEquals(e.bytes, jis.readAllBytes()); je = jis.getNextJarEntry(); } - assertEquals(expected.size(), 0, "Missing entries in jar!"); + assertEquals(0, expected.size(), "Missing entries in jar!"); } } @@ -462,14 +483,14 @@ public class ManifestOrderTest extends ZipFsBaseTest { System.out.printf("Entry Name: %s, method: %s, Expected Method: %s%n", e.name, je.getMethod(), e.method); } - assertEquals(e.method, je.getMethod(), "Compression methods mismatch"); + assertEquals(je.getMethod(), e.method, "Compression methods mismatch"); try (InputStream in = jf.getInputStream(je)) { byte[] bytes = in.readAllBytes(); if (DEBUG) { System.out.printf("bytes= %s, actual=%s%n", new String(bytes), new String(e.bytes)); } - assertTrue(Arrays.equals(bytes, e.bytes), "Entries do not match"); + assertArrayEquals(bytes, e.bytes, "Entries do not match"); } } } @@ -480,7 +501,7 @@ public class ManifestOrderTest extends ZipFsBaseTest { Path top = fs.getPath("/"); long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) -> attrs.isRegularFile()).count(); - assertEquals(entries.length + (!attributes.isEmpty() ? 1 : 0), count); + assertEquals(count, entries.length + (!attributes.isEmpty() ? 1 : 0)); Path mf = fs.getPath("META-INF", "MANIFEST.MF"); Manifest m = null; @@ -497,7 +518,7 @@ public class ManifestOrderTest extends ZipFsBaseTest { System.out.printf("Entry name = %s, bytes= %s, actual=%s%n", e.name, new String(Files.readAllBytes(file)), new String(e.bytes)); } - assertEquals(Files.readAllBytes(file), e.bytes); + assertArrayEquals(e.bytes, Files.readAllBytes(file)); } } } @@ -519,7 +540,7 @@ public class ManifestOrderTest extends ZipFsBaseTest { System.out.printf("Key: %s, Value: %s%n", k, v); } assertTrue(attrs.containsKey(k)); - assertEquals(v, attrs.get(k)); + assertEquals(attrs.get(k), v); }); } else { assertNull(m, "Manifest was found!"); diff --git a/test/jdk/jdk/nio/zipfs/NewFileSystemTests.java b/test/jdk/jdk/nio/zipfs/NewFileSystemTests.java index d9da79be126..b72fc765b68 100644 --- a/test/jdk/jdk/nio/zipfs/NewFileSystemTests.java +++ b/test/jdk/jdk/nio/zipfs/NewFileSystemTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,11 +21,6 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.SkipException; import java.io.IOException; import java.net.URI; @@ -36,14 +31,26 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Iterator; import java.util.Map; +import java.util.stream.Stream; + import jdk.test.lib.Platform; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullSource; /** * @test @@ -52,7 +59,7 @@ import static org.testng.Assert.assertTrue; * @modules jdk.zipfs * @library /test/lib * @compile NewFileSystemTests.java - * @run testng NewFileSystemTests + * @run junit NewFileSystemTests */ public class NewFileSystemTests { @@ -68,8 +75,8 @@ public class NewFileSystemTests { /** * Create the JAR file used by the tests */ - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { jarFile = Utils.createJarFile("basic.jar", "README"); jarURI = new URI(ZIPFS_SCHEME, jarFile.toUri().toString(), null); @@ -79,8 +86,8 @@ public class NewFileSystemTests { /** * Remove JAR file used by test as part of clean-up */ - @AfterClass - public void tearDown() throws Exception { + @AfterAll + public static void tearDown() throws Exception { Files.deleteIfExists(jarFile); } @@ -117,7 +124,9 @@ public class NewFileSystemTests { * * @throws IOException */ - @Test(dataProvider = "classLoaders") + @ParameterizedTest + @MethodSource("classLoaders") + @NullSource public void testNewFileSystemPathClassLoader(ClassLoader cl) throws Exception { try (FileSystem zipfs = FileSystems.newFileSystem(Path.of("basic.jar"), cl)) { @@ -131,7 +140,9 @@ public class NewFileSystemTests { * * @throws IOException */ - @Test(dataProvider = "classLoaders") + @ParameterizedTest + @MethodSource("classLoaders") + @NullSource public void testNewFileSystemPathMapClassLoader(ClassLoader cl) throws Exception { try (FileSystem zipfs = FileSystems.newFileSystem(Path.of("basic.jar"), ZIPFS_OPTIONS, cl)) { @@ -158,7 +169,9 @@ public class NewFileSystemTests { * * @throws IOException */ - @Test(dataProvider = "classLoaders") + @ParameterizedTest + @MethodSource("classLoaders") + @NullSource public void testNewFileSystemURIMapClassLoader(ClassLoader cl) throws Exception { try (FileSystem zipfs = FileSystems.newFileSystem(jarURI, ZIPFS_OPTIONS, cl)) { @@ -184,17 +197,17 @@ public class NewFileSystemTests { * opened if the underlying file is missing, but even with this set, a ZIP * file system cannot be opened for conflicting or invalid access modes. */ - @DataProvider(name = "badEnvMap") - protected Object[][] badEnvMap() { - return new Object[][]{ - {Map.of(), NoSuchFileException.class}, - {Map.of("accessMode", "readOnly"), NoSuchFileException.class}, - {Map.of("accessMode", "readWrite"), NoSuchFileException.class}, - {Map.of("create", true, "accessMode", "readOnly"), IllegalArgumentException.class}, - {Map.of("create", true, "accessMode", "badValue"), IllegalArgumentException.class}, - }; + protected static Stream badEnvMap() { + return Stream.of( + Arguments.of(Map.of(), NoSuchFileException.class), + Arguments.of(Map.of("accessMode", "readOnly"), NoSuchFileException.class), + Arguments.of(Map.of("accessMode", "readWrite"), NoSuchFileException.class), + Arguments.of(Map.of("create", true, "accessMode", "readOnly"), IllegalArgumentException.class), + Arguments.of(Map.of("create", true, "accessMode", "badValue"), IllegalArgumentException.class) + ); } - @Test(dataProvider = "badEnvMap") + @ParameterizedTest + @MethodSource("badEnvMap") public void badArgumentsFailure(Map env, Class exception) throws IOException { assertThrows(exception, () -> FileSystems.newFileSystem(Path.of("no_such.zip"), env)); } @@ -209,9 +222,7 @@ public class NewFileSystemTests { Path multiReleaseJar = createMultiReleaseJar(); try (FileSystem fs = FileSystems.newFileSystem(multiReleaseJar, Map.of("accessMode", "readWrite"))) { assertFalse(fs.isReadOnly()); - assertEquals( - Files.readString(fs.getPath("file.txt"), UTF_8), - "Default version", + assertEquals("Default version", Files.readString(fs.getPath("file.txt"), UTF_8), "unexpected file content"); } } @@ -222,9 +233,7 @@ public class NewFileSystemTests { */ @Test public void readOnlyZipFileFailure() throws IOException { - if (Platform.isRoot()) { - throw new SkipException("Test skipped when executed by root user."); - } + Assumptions.assumeFalse(Platform.isRoot(), "Test skipped when executed by root user."); // Underlying file is read-only. Path readOnlyZip = Utils.createJarFile("read_only.zip", Map.of("file.txt", "Hello World")); // In theory this can fail, and we should avoid unwanted false-negatives. @@ -243,9 +252,7 @@ public class NewFileSystemTests { Path multiReleaseJar = createMultiReleaseJar(); try (FileSystem fs = FileSystems.newFileSystem(multiReleaseJar, Map.of("releaseVersion", "1"))) { assertTrue(fs.isReadOnly()); - assertEquals( - Files.readString(fs.getPath("file.txt"), UTF_8), - "First version", + assertEquals("First version", Files.readString(fs.getPath("file.txt"), UTF_8), "unexpected file content"); } } @@ -273,15 +280,13 @@ public class NewFileSystemTests { } /* - * DataProvider used to verify that a Zip file system may be returned + * MethodSource used to verify that a Zip file system may be returned * when specifying a class loader */ - @DataProvider(name = "classLoaders") - private Object[][] classLoaders() { - return new Object[][]{ - {null}, - {ClassLoader.getSystemClassLoader()} - }; + private static Stream classLoaders() { + return Stream.of( + Arguments.of(ClassLoader.getSystemClassLoader()) + ); } /** @@ -294,11 +299,11 @@ public class NewFileSystemTests { assertNotNull(fs, "Error: FileSystem was not returned"); assertTrue(fs.provider().getScheme().equalsIgnoreCase(ZIPFS_SCHEME)); assertTrue(fs.isOpen()); - assertEquals(fs.getSeparator(), "/"); + assertEquals("/", fs.getSeparator()); // one root Iterator roots = fs.getRootDirectories().iterator(); - assertTrue(roots.next().toString().equals("/")); + assertEquals("/", roots.next().toString()); assertFalse(roots.hasNext()); } } diff --git a/test/jdk/jdk/nio/zipfs/NonExistentPathTests.java b/test/jdk/jdk/nio/zipfs/NonExistentPathTests.java index 20ed552212c..70c864c44ea 100644 --- a/test/jdk/jdk/nio/zipfs/NonExistentPathTests.java +++ b/test/jdk/jdk/nio/zipfs/NonExistentPathTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,17 +21,15 @@ * questions. * */ -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import java.io.IOException; import java.net.URI; -import java.nio.file.FileSystemNotFoundException; import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.Map; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; /** * @test @@ -39,7 +37,7 @@ import static org.testng.Assert.assertThrows; * @summary Validate the correct Exception is thrown if the Zip/JAR is not found * * @modules jdk.zipfs - * @run testng/othervm NonExistentPathTests + * @run junit/othervm NonExistentPathTests */ public class NonExistentPathTests { private static final String ZIPFS_SCHEME = "jar"; diff --git a/test/jdk/jdk/nio/zipfs/PathOps.java b/test/jdk/jdk/nio/zipfs/PathOps.java index 0fefd16fa0f..86b7946eba2 100644 --- a/test/jdk/jdk/nio/zipfs/PathOps.java +++ b/test/jdk/jdk/nio/zipfs/PathOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, 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,596 +21,548 @@ * questions. */ +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; + import java.io.IOException; -import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.ProviderMismatchException; +import java.util.Objects; +import java.util.stream.Stream; -/** - * +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/* * @test - * @bug 8038500 8040059 8139956 8146754 8172921 8186142 + * @bug 8038500 8040059 8139956 8146754 8172921 8186142 8326487 * @summary Tests path operations for zip provider. - * * @modules jdk.zipfs - * @run main PathOps - * @run main/othervm PathOps + * @run junit PathOps + * @run junit/othervm PathOps */ - public class PathOps { - static final java.io.PrintStream out = System.out; - static FileSystem fs; + // create empty JAR file, testing doesn't require any contents + static Path emptyJar; - private Path path; - private Exception exc; - - private PathOps(String first, String... more) { - out.println(); - try { - path = fs.getPath(first, more); - out.format("%s -> %s", first, path); - } catch (Exception x) { - exc = x; - out.format("%s -> %s", first, x); - } - out.println(); + @BeforeAll + static void setup() throws IOException { + emptyJar = Utils.createJarFile("empty.jar"); } - Path path() { - return path; - } - - void fail() { - throw new RuntimeException("PathOps failed"); - } - - void checkPath() { - if (path == null) { - throw new InternalError("path is null"); + // Ensure NPEs are thrown for null inputs on Path ops + @Test + void nullPointerTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + Path path = fs.getPath("foo"); + assertThrows(NullPointerException.class, () -> path.resolve((String) null)); + assertThrows(NullPointerException.class, () -> path.relativize(null)); + assertThrows(NullPointerException.class, () -> path.compareTo(null)); + assertThrows(NullPointerException.class, () -> path.startsWith((Path) null)); + assertThrows(NullPointerException.class, () -> path.endsWith((Path) null)); } } - void check(Object result, String expected) { - out.format("\tExpected: %s\n", expected); - out.format("\tActual: %s\n", result); - if (result == null) { - if (expected == null) return; - } else { - // compare string representations - if (expected != null && result.toString().equals(expected.toString())) - return; - } - fail(); - } - - void check(Object result, boolean expected) { - check(result, Boolean.toString(expected)); - } - - PathOps root(String expected) { - out.println("check root"); - checkPath(); - check(path.getRoot(), expected); - return this; - } - - PathOps parent(String expected) { - out.println("check parent"); - checkPath(); - check(path.getParent(), expected); - return this; - } - - PathOps name(String expected) { - out.println("check name"); - checkPath(); - check(path.getFileName(), expected); - return this; - } - - PathOps element(int index, String expected) { - out.format("check element %d\n", index); - checkPath(); - check(path.getName(index), expected); - return this; - } - - PathOps subpath(int startIndex, int endIndex, String expected) { - out.format("test subpath(%d,%d)\n", startIndex, endIndex); - checkPath(); - check(path.subpath(startIndex, endIndex), expected); - return this; - } - - PathOps starts(String prefix) { - out.format("test startsWith with %s\n", prefix); - checkPath(); - Path s = fs.getPath(prefix); - check(path.startsWith(s), true); - return this; - } - - PathOps notStarts(String prefix) { - out.format("test not startsWith with %s\n", prefix); - checkPath(); - Path s = fs.getPath(prefix); - check(path.startsWith(s), false); - return this; - } - - PathOps ends(String suffix) { - out.format("test endsWith %s\n", suffix); - checkPath(); - Path s = fs.getPath(suffix); - check(path.endsWith(s), true); - return this; - } - - PathOps notEnds(String suffix) { - out.format("test not endsWith %s\n", suffix); - checkPath(); - Path s = fs.getPath(suffix); - check(path.endsWith(s), false); - return this; - } - - PathOps absolute() { - out.println("check path is absolute"); - checkPath(); - check(path.isAbsolute(), true); - return this; - } - - PathOps notAbsolute() { - out.println("check path is not absolute"); - checkPath(); - check(path.isAbsolute(), false); - return this; - } - - PathOps resolve(String other, String expected) { - out.format("test resolve %s\n", other); - checkPath(); - check(path.resolve(other), expected); - return this; - } - - PathOps resolvePath(String other, String expected) { - out.format("test resolve %s\n", other); - checkPath(); - check(path.resolve(fs.getPath(other)), expected); - return this; - } - - PathOps resolveSibling(String other, String expected) { - out.format("test resolveSibling %s\n", other); - checkPath(); - check(path.resolveSibling(other), expected); - return this; - } - - PathOps relativize(String other, String expected) { - out.format("test relativize %s\n", other); - checkPath(); - Path that = fs.getPath(other); - check(path.relativize(that), expected); - return this; - } - - PathOps normalize(String expected) { - out.println("check normalized path"); - checkPath(); - check(path.normalize(), expected); - return this; - } - - PathOps string(String expected) { - out.println("check string representation"); - checkPath(); - check(path, expected); - return this; - } - - PathOps isSameFile(String target) { - try { - out.println("check two paths are same"); - checkPath(); - check(Files.isSameFile(path, test(target).path()), true); - } catch (IOException ioe) { - fail(); - } - return this; - } - - PathOps invalid() { - if (!(exc instanceof InvalidPathException)) { - out.println("InvalidPathException not thrown as expected"); - fail(); - } - return this; - } - - static PathOps test(String s) { - return new PathOps(s); - } - - static PathOps test(String first, String... more) { - return new PathOps(first, more); - } - - // -- PathOpss -- - - static void header(String s) { - out.println(); - out.println(); - out.println("-- " + s + " --"); - } - - static void doPathOpTests() { - header("Path operations"); - - // construction - test("/") - .string("/"); - test("/", "") - .string("/"); - test("/", "foo") - .string("/foo"); - test("/", "/foo") - .string("/foo"); - test("/", "foo/") - .string("/foo"); - test("foo", "bar", "gus") - .string("foo/bar/gus"); - test("") - .string(""); - test("", "/") - .string("/"); - test("", "foo", "", "bar", "", "/gus") - .string("foo/bar/gus"); - - // all components - test("/a/b/c") - .root("/") - .parent("/a/b") - .name("c"); - - // root component only - test("/") - .root("/") - .parent(null) - .name(null); - - // no root component - test("a/b") - .root(null) - .parent("a") - .name("b"); - - // name component only - test("foo") - .root(null) - .parent(null) - .name("foo"); - - // startsWith - test("") - .starts("") - .notStarts("/"); - test("/") - .starts("/") - .notStarts("/foo"); - test("/foo") - .starts("/") - .starts("/foo") - .notStarts("/f") - .notStarts(""); - test("/foo/bar") - .starts("/") - .starts("/foo") - .starts("/foo/") - .starts("/foo/bar") - .notStarts("/f") - .notStarts("foo") - .notStarts("foo/bar") - .notStarts(""); - test("foo") - .starts("foo") - .notStarts("f"); - test("foo/bar") - .starts("foo") - .starts("foo/") - .starts("foo/bar") - .notStarts("f") - .notStarts("/foo") - .notStarts("/foo/bar"); - - // endsWith - test("") - .ends("") - .notEnds("/"); - test("/") - .ends("/") - .notEnds("foo") - .notEnds("/foo"); - test("/foo") - .ends("foo") - .ends("/foo") - .notEnds("/"); - test("/foo/bar") - .ends("bar") - .ends("foo/bar") - .ends("foo/bar/") - .ends("/foo/bar") - .notEnds("/bar"); - test("/foo/bar/") - .ends("bar") - .ends("foo/bar") - .ends("foo/bar/") - .ends("/foo/bar") - .notEnds("/bar"); - test("foo") - .ends("foo"); - test("foo/bar") - .ends("bar") - .ends("bar/") - .ends("foo/bar/") - .ends("foo/bar"); - - // elements - test("a/b/c") - .element(0,"a") - .element(1,"b") - .element(2,"c"); - - // isAbsolute - test("/") - .absolute(); - test("/tmp") - .absolute(); - test("tmp") - .notAbsolute(); - test("") - .notAbsolute(); - - // resolve - test("/tmp") - .resolve("foo", "/tmp/foo") - .resolve("/foo", "/foo") - .resolve("", "/tmp"); - test("tmp") - .resolve("foo", "tmp/foo") - .resolve("/foo", "/foo") - .resolve("", "tmp"); - test("") - .resolve("", "") - .resolve("foo", "foo") - .resolve("/foo", "/foo"); - test("/") - .resolve("", "/") - .resolve("foo", "/foo") - .resolve("/foo", "/foo") - .resolve("/foo/", "/foo"); - - // resolve(Path) - test("/tmp") - .resolvePath("foo", "/tmp/foo") - .resolvePath("/foo", "/foo") - .resolvePath("", "/tmp"); - test("tmp") - .resolvePath("foo", "tmp/foo") - .resolvePath("/foo", "/foo") - .resolvePath("", "tmp"); - test("") - .resolvePath("", "") - .resolvePath("foo", "foo") - .resolvePath("/foo", "/foo"); - test("/") - .resolvePath("", "/") - .resolvePath("foo", "/foo") - .resolvePath("/foo", "/foo") - .resolvePath("/foo/", "/foo"); - - // resolveSibling - test("foo") - .resolveSibling("bar", "bar") - .resolveSibling("/bar", "/bar") - .resolveSibling("", ""); - test("foo/bar") - .resolveSibling("gus", "foo/gus") - .resolveSibling("/gus", "/gus") - .resolveSibling("", "foo"); - test("/foo") - .resolveSibling("gus", "/gus") - .resolveSibling("/gus", "/gus") - .resolveSibling("", "/"); - test("/foo/bar") - .resolveSibling("gus", "/foo/gus") - .resolveSibling("/gus", "/gus") - .resolveSibling("", "/foo"); - test("") - .resolveSibling("foo", "foo") - .resolveSibling("/foo", "/foo") - .resolve("", ""); - - // relativize - test("/a/b/c") - .relativize("/a/b/c", "") - .relativize("/a/b/c/d/e", "d/e") - .relativize("/a/x", "../../x") - .relativize("/x", "../../../x"); - test("a/b/c") - .relativize("a/b/c/d", "d") - .relativize("a/x", "../../x") - .relativize("x", "../../../x") - .relativize("", "../../.."); - test("") - .relativize("a", "a") - .relativize("a/b/c", "a/b/c") - .relativize("", ""); - test("/") - .relativize("/a", "a") - .relativize("/a/c", "a/c"); - // 8146754 - test("/tmp/path") - .relativize("/tmp/path/a.txt", "a.txt"); - test("/tmp/path/") - .relativize("/tmp/path/a.txt", "a.txt"); - - // normalize - test("/") - .normalize("/"); - test("foo") - .normalize("foo"); - test("/foo") - .normalize("/foo"); - test(".") - .normalize(""); - test("..") - .normalize(".."); - test("/..") - .normalize("/"); - test("/../..") - .normalize("/"); - test("foo/.") - .normalize("foo"); - test("./foo") - .normalize("foo"); - test("foo/..") - .normalize(""); - test("../foo") - .normalize("../foo"); - test("../../foo") - .normalize("../../foo"); - test("foo/bar/..") - .normalize("foo"); - test("foo/bar/gus/../..") - .normalize("foo"); - test("/foo/bar/gus/../..") - .normalize("/foo"); - test("/./.") - .normalize("/"); - test("/.") - .normalize("/"); - test("/./abc") - .normalize("/abc"); - // invalid - test("foo\u0000bar") - .invalid(); - test("\u0000foo") - .invalid(); - test("bar\u0000") - .invalid(); - test("//foo\u0000bar") - .invalid(); - test("//\u0000foo") - .invalid(); - test("//bar\u0000") - .invalid(); - - // normalization - test("//foo//bar") - .string("/foo/bar") - .root("/") - .parent("/foo") - .name("bar"); - - // isSameFile - test("/fileDoesNotExist") - .isSameFile("/fileDoesNotExist"); - - // 8139956 - out.println("check getNameCount"); - int nc = fs.getPath("/").relativize(fs.getPath("/")).getNameCount(); - if (nc != 1) { - out.format("\tExpected: 1\n"); - out.format("\tActual: %d\n", nc); - throw new RuntimeException("getNameCount of empty path failed"); - } - } - - static void npes() { - header("NullPointerException"); - - Path path = fs.getPath("foo"); - - try { - path.resolve((String)null); - throw new RuntimeException("NullPointerException not thrown"); - } catch (NullPointerException npe) { - } - - try { - path.relativize(null); - throw new RuntimeException("NullPointerException not thrown"); - } catch (NullPointerException npe) { - } - - try { - path.compareTo(null); - throw new RuntimeException("NullPointerException not thrown"); - } catch (NullPointerException npe) { - } - - try { - path.startsWith((Path)null); - throw new RuntimeException("NullPointerException not thrown"); - } catch (NullPointerException npe) { - } - - try { - path.endsWith((Path)null); - throw new RuntimeException("NullPointerException not thrown"); - } catch (NullPointerException npe) { - } - - } - - static void mismatchedProviders() { - header("ProviderMismatchException"); - Path path = fs.getPath("foo"); + // Ensure correct behavior when paths are provided by mismatched providers + @Test + void mismatchedProvidersTest() throws IOException { Path other = Paths.get("foo"); - try { - path.compareTo(other); - throw new RuntimeException("ProviderMismatchException not thrown"); - } catch (ProviderMismatchException pme) {} - - try { - path.resolve(other); - throw new RuntimeException("ProviderMismatchException not thrown"); - } catch (ProviderMismatchException pme) {} - - try { - path.relativize(other); - throw new RuntimeException("ProviderMismatchException not thrown"); - } catch (ProviderMismatchException pme) {} - - try { - if (path.startsWith(other)) - throw new RuntimeException("providerMismatched startsWith() returns true "); - if (path.endsWith(other)) - throw new RuntimeException("providerMismatched endsWith() returns true "); - } catch (ProviderMismatchException pme) { - throw new RuntimeException("ProviderMismatchException is thrown for starts/endsWith()"); + try (var fs = FileSystems.newFileSystem(emptyJar)) { + Path path = fs.getPath("foo"); + assertThrows(ProviderMismatchException.class, () -> path.compareTo(other)); + assertThrows(ProviderMismatchException.class, () -> path.resolve(other)); + assertThrows(ProviderMismatchException.class, () -> path.relativize(other)); + assertFalse(path.startsWith(other), "providerMismatched startsWith() returns true "); + assertFalse(path.endsWith(other), "providerMismatched endsWith() returns true "); } } - public static void main(String[] args) throws IOException { - // create empty JAR file, test doesn't require any contents - Path emptyJar = Utils.createJarFile("empty.jar"); - - fs = FileSystems.newFileSystem(emptyJar); - try { - npes(); - mismatchedProviders(); - doPathOpTests(); - } finally { - fs.close(); + // Ensure correct construction of paths when given sequence of strings + @ParameterizedTest + @MethodSource + void constructionTest(String first, String[] more, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + string(fs.getPath(first, more), expected); } } + + static Stream constructionTest() { + return Stream.of( + Arguments.of("/", new String[]{}, "/"), + Arguments.of("/", new String[]{""}, "/"), + Arguments.of("/", new String[]{"foo"}, "/foo"), + Arguments.of("/", new String[]{"/foo"}, "/foo"), + Arguments.of("/", new String[]{"foo/"}, "/foo"), + Arguments.of("foo", new String[]{"bar", "gus"}, "foo/bar/gus"), + Arguments.of("", new String[]{}, ""), + Arguments.of("", new String[]{"/"}, "/"), + Arguments.of("", new String[]{"foo", "", "bar", "", "/gus"}, "foo/bar/gus") + ); + } + + // Ensure proper root, parent, and name components + @Test + void allComponentsTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath("/a/b/c"); + root(path, "/"); + parent(path, "/a/b"); + name(path, "c"); + } + } + + // Ensure correct name count for root only and empty name + @ParameterizedTest + @MethodSource + void nameCountTest(String first, String root, String parent, String name, int nameCount) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + root(path, root); + parent(path, parent); + name(path, name); + assertNotNull(path); + assertEquals(nameCount, path.getNameCount()); + } + } + + static Stream nameCountTest() { + return Stream.of( + // root component only + Arguments.of("/", "/", null, null, 0), + // empty name + Arguments.of("", null, null, "", 1) + ); + } + + // Ensure correct parent and name behavior for no root and name only + @ParameterizedTest + @MethodSource + void parentNameTest(String first, String root, String parent, String name) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + root(path, root); + parent(path, parent); + name(path, name); + } + } + + static Stream parentNameTest() { + return Stream.of( + // no root component + Arguments.of("a/b", null, "a", "b"), + // name component only + Arguments.of("foo", null, null, "foo") + ); + } + + // Ensure correct (positive) `startsWith` behavior + @ParameterizedTest + @MethodSource + void startsWithTest(String first, String prefix) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + Path s = fs.getPath(prefix); + assertTrue(path.startsWith(s)); + } + } + + static Stream startsWithTest() { + return Stream.of( + Arguments.of("", ""), + Arguments.of("/", "/"), + Arguments.of("foo", "foo"), + Arguments.of("/foo", "/"), + Arguments.of("/foo", "/foo"), + Arguments.of("/foo/bar", "/"), + Arguments.of("/foo/bar", "/foo"), + Arguments.of("/foo/bar", "/foo/"), + Arguments.of("/foo/bar", "/foo/bar"), + Arguments.of("foo/bar", "foo"), + Arguments.of("foo/bar", "foo/"), + Arguments.of("foo/bar", "foo/bar") + ); + } + + // Ensure correct (negative) `startsWith` behavior + @ParameterizedTest + @MethodSource + void notStartsWithTest(String first, String prefix) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + Path s = fs.getPath(prefix); + assertFalse(path.startsWith(s)); + } + } + + static Stream notStartsWithTest() { + return Stream.of( + Arguments.of("", "/"), + Arguments.of("/", "/foo"), + Arguments.of("foo", "f"), + Arguments.of("/foo", "/f"), + Arguments.of("/foo", ""), + Arguments.of("/foo/bar", "/f"), + Arguments.of("/foo/bar", "foo"), + Arguments.of("/foo/bar", "foo/bar"), + Arguments.of("/foo/bar", ""), + Arguments.of("foo/bar", "f"), + Arguments.of("foo/bar", "/foo"), + Arguments.of("foo/bar", "/foo/bar") + ); + } + + // Ensure correct (positive) `endsWith` behavior + @ParameterizedTest + @MethodSource + void endsWithTest(String first, String suffix) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + Path s = fs.getPath(suffix); + assertTrue(path.endsWith(s)); + } + } + + static Stream endsWithTest() { + return Stream.of( + Arguments.of("", ""), + Arguments.of("/", "/"), + Arguments.of("/foo", "foo"), + Arguments.of("/foo","/foo"), + Arguments.of("/foo/bar", "bar"), + Arguments.of("/foo/bar", "foo/bar"), + Arguments.of("/foo/bar", "foo/bar/"), + Arguments.of("/foo/bar", "/foo/bar"), + Arguments.of("/foo/bar/", "bar"), + Arguments.of("/foo/bar/", "foo/bar"), + Arguments.of("/foo/bar/", "foo/bar/"), + Arguments.of("/foo/bar/", "/foo/bar"), + Arguments.of("foo", "foo"), + Arguments.of("foo/bar", "bar"), + Arguments.of("foo/bar", "bar/"), + Arguments.of("foo/bar", "foo/bar/"), + Arguments.of("foo/bar", "foo/bar") + ); + } + + // Ensure correct (negative) `endsWith` behavior + @ParameterizedTest + @MethodSource + void notEndsWithTest(String first, String suffix) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + Path s = fs.getPath(suffix); + assertFalse(path.endsWith(s)); + } + } + + static Stream notEndsWithTest() { + return Stream.of( + Arguments.of("", "/"), + Arguments.of("/", "foo"), + Arguments.of("/", "/foo"), + Arguments.of("/foo", "/"), + Arguments.of("/foo/bar", "/bar"), + Arguments.of("/foo/bar/", "/bar") + ); + } + + // Ensure `getName` returns correct String at index + @ParameterizedTest + @MethodSource + void elementTest(int index, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath("a/b/c"); + assertNotNull(path); + assertEquals(expected, path.getName(index).toString()); + } + } + + static Stream elementTest() { + return Stream.of( + Arguments.of(0, "a"), + Arguments.of(1, "b"), + Arguments.of(2, "c") + ); + } + + // Ensure expected behavior for absolute paths + @ParameterizedTest + @ValueSource(strings = {"/", "/tmp"} ) + void isAbsoluteTest(String first) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + assertTrue(path.isAbsolute()); + } + } + + // Ensure expected behavior for non-absolute paths + @ParameterizedTest + @ValueSource(strings = {"tmp", ""} ) + void notAbsoluteTest(String first) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + assertFalse(path.isAbsolute()); + } + } + + // Ensure correct append and replacement behavior for `resolve(String)` + @ParameterizedTest + @MethodSource + void resolveTest(String first, String other, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + resolve(fs.getPath(first), other, expected); + } + } + + static Stream resolveTest() { + return Stream.of( + Arguments.of("/tmp", "foo", "/tmp/foo"), + Arguments.of("/tmp", "/foo", "/foo"), + Arguments.of("/tmp", "", "/tmp"), + Arguments.of("tmp", "foo", "tmp/foo"), + Arguments.of("tmp", "/foo", "/foo"), + Arguments.of("tmp", "", "tmp"), + Arguments.of("", "", ""), + Arguments.of("", "foo", "foo"), + Arguments.of("", "/foo", "/foo"), + Arguments.of("/", "", "/"), + Arguments.of("/", "foo", "/foo"), + Arguments.of("/", "/foo", "/foo"), + Arguments.of("/", "/foo/", "/foo") + ); + } + + // Ensure correct append and replacement behavior for `resolve(Path)` + @ParameterizedTest + @MethodSource + void resolvePathTest(String first, String other, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + assertEquals(expected, path.resolve(fs.getPath(other)).toString()); + } + } + + static Stream resolvePathTest() { + return Stream.of( + Arguments.of("/tmp", "foo", "/tmp/foo"), + Arguments.of("/tmp", "/foo", "/foo"), + Arguments.of("/tmp", "", "/tmp"), + Arguments.of("tmp", "foo", "tmp/foo"), + Arguments.of("tmp", "/foo", "/foo"), + Arguments.of("tmp", "", "tmp"), + Arguments.of("", "", ""), + Arguments.of("", "foo", "foo"), + Arguments.of("", "/foo", "/foo"), + Arguments.of("/", "", "/"), + Arguments.of("/", "foo", "/foo"), + Arguments.of("/", "/foo", "/foo"), + Arguments.of("/", "/foo/", "/foo") + ); + } + + // Ensure correct behavior for `resolveSibling` + @ParameterizedTest + @MethodSource + void resolveSiblingTest(String first, String other, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + resolveSibling(fs.getPath(first), other, expected); + } + } + + static Stream resolveSiblingTest() { + return Stream.of( + Arguments.of("foo", "bar", "bar"), + Arguments.of("foo", "/bar", "/bar"), + Arguments.of("foo", "", ""), + Arguments.of("foo/bar", "gus", "foo/gus"), + Arguments.of("foo/bar", "/gus", "/gus"), + Arguments.of("foo/bar", "", "foo"), + Arguments.of("/foo", "gus", "/gus"), + Arguments.of("/foo", "/gus", "/gus"), + Arguments.of("/foo", "", "/"), + Arguments.of("/foo/bar", "gus", "/foo/gus"), + Arguments.of("/foo/bar", "/gus", "/gus"), + Arguments.of("/foo/bar", "", "/foo") + ); + } + + // Checking `resolve` and `resolveSibling` behavior for empty path + @Test + void resolveSiblingAndResolveTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(""); + resolveSibling(path, "foo", "foo"); + resolveSibling(path, "/foo", "/foo"); + resolve(path, "", ""); + } + } + + // Ensure correct behavior of `relativize`. i.e. Relative path should be + // produced between two given paths + @ParameterizedTest + @MethodSource + void relativizeTest(String first, String other, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + Path that = fs.getPath(other); + assertEquals(expected, path.relativize(that).toString()); + } + } + + static Stream relativizeTest() { + return Stream.of( + Arguments.of("/a/b/c", "/a/b/c", ""), + Arguments.of("/a/b/c", "/a/b/c/d/e", "d/e"), + Arguments.of("/a/b/c", "/a/x", "../../x"), + Arguments.of("/a/b/c", "/x", "../../../x"), + Arguments.of("a/b/c", "a/b/c/d", "d"), + Arguments.of("a/b/c", "a/x", "../../x"), + Arguments.of("a/b/c", "x", "../../../x"), + Arguments.of("a/b/c", "", "../../.."), + Arguments.of("", "a", "a"), + Arguments.of("", "a/b/c", "a/b/c"), + Arguments.of("", "", ""), + Arguments.of("/", "/a", "a"), + Arguments.of("/", "/a/c", "a/c"), + // 8146754 + Arguments.of("/tmp/path", "/tmp/path/a.txt", "a.txt"), + Arguments.of("/tmp/path/", "/tmp/path/a.txt", "a.txt") + ); + } + + // Ensure correct behavior of `normalize`. i.e. redundant elements should be removed. + @ParameterizedTest + @MethodSource + void normalizeTest(String first, String expected) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath(first); + assertNotNull(path); + assertEquals(expected, path.normalize().toString()); + } + } + + static Stream normalizeTest() { + return Stream.of( + Arguments.of("/", "/"), + Arguments.of("foo", "foo"), + Arguments.of("/foo", "/foo"), + Arguments.of(".", ""), + Arguments.of("..", ".."), + Arguments.of("/..", "/"), + Arguments.of("/../..", "/"), + Arguments.of("foo/.", "foo"), + Arguments.of("./foo", "foo"), + Arguments.of("foo/..", ""), + Arguments.of("../foo", "../foo"), + Arguments.of("../../foo", "../../foo"), + Arguments.of("foo/bar/..", "foo"), + Arguments.of("foo/bar/gus/../..", "foo"), + Arguments.of("/foo/bar/gus/../..", "/foo"), + Arguments.of("/./.", "/"), + Arguments.of("/.", "/"), + Arguments.of("/./abc", "/abc") + ); + } + + // Check IPE is thrown for invalid path Strings + @ParameterizedTest + @MethodSource + void invalidTest(String first) throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + assertThrows(InvalidPathException.class, () -> fs.getPath(first)); + } + } + + static Stream invalidTest() { + return Stream.of( + "foo\u0000bar", + "\u0000foo", + "bar\u0000", + "//foo\u0000bar", + "//\u0000foo", + "//bar\u0000" + ); + } + + // Check that repeated forward slash is normalized correctly + @Test + void normalizationTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath("//foo//bar"); + string(path, "/foo/bar"); + root(path, "/"); + parent(path, "/foo"); + name(path, "bar"); + } + } + + @Test // Check that identical paths refer to the same file + void isSameFileTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + var path = fs.getPath("/fileDoesNotExist"); + assertNotNull(path); + assertTrue(Files.isSameFile(path, fs.getPath("/fileDoesNotExist"))); + } + } + + // Regression test for 8139956: Ensure `relativize` of equivalent paths + // produces an empty path -> `getNameCount` returns 1 + @Test + void getNameCountTest() throws IOException { + try (var fs = FileSystems.newFileSystem(emptyJar)) { + int nc = fs.getPath("/").relativize(fs.getPath("/")).getNameCount(); + assertEquals(1, nc, "getNameCount of empty path failed"); + } + } + + // Utilities for testing + static void root(Path path, String expected) { + assertNotNull(path); + assertEquals(expected, Objects.toString(path.getRoot(), null)); + } + + static void parent(Path path, String expected) { + assertNotNull(path); + assertEquals(expected, Objects.toString(path.getParent(), null)); + } + + static void name(Path path, String expected) { + assertNotNull(path); + assertEquals(expected, Objects.toString(path.getFileName(), null)); + } + + static void resolve(Path path, String other, String expected) { + assertNotNull(path); + assertEquals(expected, path.resolve(other).toString()); + } + + static void resolveSibling(Path path, String other, String expected) { + assertNotNull(path); + assertEquals(expected, path.resolveSibling(other).toString()); + } + + static void string(Path path, String expected) { + assertNotNull(path); + assertEquals(expected, path.toString()); + } } diff --git a/test/jdk/jdk/nio/zipfs/testng/test/PosixAttributeViewTest.java b/test/jdk/jdk/nio/zipfs/PosixAttributeViewTest.java similarity index 77% rename from test/jdk/jdk/nio/zipfs/testng/test/PosixAttributeViewTest.java rename to test/jdk/jdk/nio/zipfs/PosixAttributeViewTest.java index 7734ea733c9..ff20741135d 100644 --- a/test/jdk/jdk/nio/zipfs/testng/test/PosixAttributeViewTest.java +++ b/test/jdk/jdk/nio/zipfs/PosixAttributeViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,12 +21,12 @@ * questions. * */ -package test; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import util.ZipFsBaseTest; import java.io.IOException; @@ -36,13 +36,15 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.PosixFileAttributeView; import java.util.Map; +import java.util.stream.Stream; import java.util.zip.ZipEntry; -/** +/* * @test * @bug 8273935 * @summary Validate that Files.getFileAttributeView will not throw an * Exception when the attribute view PosixFileAttributeView is not available + * @run junit PosixAttributeViewTest */ public class PosixAttributeViewTest extends ZipFsBaseTest { public static final String ZIP_ENTRY = "Entry-0"; @@ -52,8 +54,8 @@ public class PosixAttributeViewTest extends ZipFsBaseTest { * Create initial Zip File * @throws IOException if an error occurs */ - @BeforeTest - public void setup() throws IOException { + @BeforeAll + public static void setup() throws IOException { Files.deleteIfExists(ZIP_FILE); Entry entry = Entry.of(ZIP_ENTRY, ZipEntry.DEFLATED, "Tennis Anyone"); @@ -64,22 +66,21 @@ public class PosixAttributeViewTest extends ZipFsBaseTest { * Remove Zip File used by Test * @throws IOException if an error occurs */ - @AfterTest - public void cleanup() throws IOException { + @AfterAll + public static void cleanup() throws IOException { Files.deleteIfExists(ZIP_FILE); } /** - * DataProvider used to specify the Map indicating whether Posix + * MethodSource used to specify the Map indicating whether Posix * file attributes have been enabled * @return map of the Zip FS properties to configure */ - @DataProvider - protected Object[][] zipfsMap() { - return new Object[][]{ - {Map.of()}, - {Map.of("enablePosixFileAttributes", "true")} - }; + protected static Stream zipfsMap() { + return Stream.of( + Arguments.of(Map.of()), + Arguments.of(Map.of("enablePosixFileAttributes", "true")) + ); } /** @@ -89,7 +90,8 @@ public class PosixAttributeViewTest extends ZipFsBaseTest { * @param env map of the Zip FS properties to configure * @throws Exception if an error occurs */ - @Test(dataProvider = "zipfsMap") + @ParameterizedTest + @MethodSource("zipfsMap") public void testPosixAttributeView(Map env) throws Exception { try (FileSystem fs = FileSystems.newFileSystem(ZIP_FILE, env)) { Path entry = fs.getPath(ZIP_ENTRY); diff --git a/test/jdk/jdk/nio/zipfs/PropertyPermissionTests.java b/test/jdk/jdk/nio/zipfs/PropertyPermissionTests.java index de8992bce74..5f31d87f81c 100644 --- a/test/jdk/jdk/nio/zipfs/PropertyPermissionTests.java +++ b/test/jdk/jdk/nio/zipfs/PropertyPermissionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,9 +21,6 @@ * questions. */ -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.file.FileSystem; @@ -33,13 +30,18 @@ import java.nio.file.Paths; import java.nio.file.spi.FileSystemProvider; import java.util.Map; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + + /** * @test * @bug 8210469 * @summary Verify ZIP FileSystem works with a Security Manager * @modules jdk.zipfs * @compile PropertyPermissionTests.java - * @run testng/othervm PropertyPermissionTests + * @run junit/othervm PropertyPermissionTests */ public class PropertyPermissionTests { @@ -55,8 +57,8 @@ public class PropertyPermissionTests { /** * Create the JAR files used by the tests */ - @BeforeClass - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { jarFile = Utils.createJarFile("basic.jar", "META-INF/services/java.nio.file.spi.FileSystemProvider"); } @@ -64,8 +66,8 @@ public class PropertyPermissionTests { /** * Remove JAR files used by test as part of clean-up */ - @AfterClass - public void tearDown() throws Exception { + @AfterAll + public static void tearDown() throws Exception { Files.deleteIfExists(jarFile); } diff --git a/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java b/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java index 82369b4fe39..95446da9267 100644 --- a/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java +++ b/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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,12 +26,15 @@ /* * @test * @bug 8234011 - * @summary Check that jdk.nio.zipfs.ZipFileSystem doesn't cache more than ZipFileSystem.MAX_FLATER Inflater/Deflater objects - * @run main ReleaseDeflater + * @summary Check that jdk.nio.zipfs.ZipFileSystem doesn't cache more than + * ZipFileSystem.MAX_FLATER Inflater/Deflater objects. * @modules jdk.zipfs/jdk.nio.zipfs:+open - * @author Volker Simonis + * @run junit ReleaseDeflater */ +import org.junit.jupiter.api.Test; + +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Field; @@ -44,8 +48,12 @@ import java.util.List; import java.util.Map; import java.util.ArrayList; +import static org.junit.jupiter.api.Assertions.assertFalse; + public class ReleaseDeflater { - public static void main(String[] args) throws Throwable { + + @Test + void cacheTest() throws IOException, IllegalAccessException { Path zipFile = Paths.get("ReleaseDeflaterTest.zip"); try (FileSystem fs = FileSystems.newFileSystem(zipFile, Map.of("create", true))) { FileSystemProvider zprov = fs.provider(); @@ -75,15 +83,11 @@ public class ReleaseDeflater { Field inflaters = fs.getClass().getDeclaredField("inflaters"); inflaters.setAccessible(true); int inflater_count = ((List) inflaters.get(fs)).size(); - if (inflater_count > MAX_FLATERS) { - throw new Exception("Too many inflaters " + inflater_count); - } + assertFalse(inflater_count > MAX_FLATERS, "Too many inflaters " + inflater_count); Field deflaters = fs.getClass().getDeclaredField("deflaters"); deflaters.setAccessible(true); int deflater_count = ((List) deflaters.get(fs)).size(); - if (deflater_count > MAX_FLATERS) { - throw new Exception("Too many deflaters " + deflater_count); - } + assertFalse(deflater_count > MAX_FLATERS, "Too many deflaters " + deflater_count); } catch (NoSuchFieldException nsfe) { // Probably the implementation has changed, so there's not much we can do... throw new RuntimeException("Implementation of jdk.nio.zipfs.ZipFileSystem changed - disable or fix the test"); @@ -91,6 +95,5 @@ public class ReleaseDeflater { } finally { Files.deleteIfExists(zipFile); } - } } diff --git a/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java b/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java index 6611efced82..8a65f08afc2 100644 --- a/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java +++ b/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,6 @@ * */ -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; @@ -32,7 +31,6 @@ import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.Map; import java.util.spi.ToolProvider; import java.util.zip.CRC32; @@ -40,16 +38,16 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * @test * @bug 8229887 * @summary Validate ZIP FileSystem can replace existing STORED and DEFLATED entries * @modules jdk.zipfs - * @run testng UpdateEntryTest + * @run junit UpdateEntryTest */ -@Test public class UpdateEntryTest { private static final Path HERE = Path.of("."); @@ -109,6 +107,7 @@ public class UpdateEntryTest { * Validate that you can replace an existing entry in a JAR file that * was added with the STORED(no-compression) option */ + @Test public void testReplaceStoredEntry() throws IOException { String jarFileName = "updateStoredEntry.jar"; String storedFileName = "storedFile.txt"; @@ -132,6 +131,7 @@ public class UpdateEntryTest { /** * Test updating an entry that is STORED (not compressed) */ + @Test public void test1() throws IOException { Entry e1 = Entry.of("foo", ZipEntry.STORED, "hello"); Entry e2 = Entry.of("bar", ZipEntry.STORED, "world"); @@ -141,6 +141,7 @@ public class UpdateEntryTest { /** * Test updating an entry that is DEFLATED (compressed) */ + @Test public void test2() throws IOException { Entry e1 = Entry.of("foo", ZipEntry.DEFLATED, "hello"); Entry e2 = Entry.of("bar", ZipEntry.STORED, "world"); @@ -183,16 +184,16 @@ public class UpdateEntryTest { // check entries with zip API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertTrue(zf.size() == entries.length); + assertEquals(zf.size(), entries.length); // check compression method and content of each entry for (Entry e : entries) { ZipEntry ze = zf.getEntry(e.name); - assertTrue(ze != null); - assertTrue(ze.getMethod() == e.method); + assertNotNull(ze); + assertEquals(ze.getMethod(), e.method); try (InputStream in = zf.getInputStream(ze)) { byte[] bytes = in.readAllBytes(); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } @@ -203,13 +204,13 @@ public class UpdateEntryTest { Path top = fs.getPath("/"); long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) -> attrs.isRegularFile()).count(); - assertTrue(count == entries.length); + assertEquals(count, entries.length); // check content of each entry for (Entry e : entries) { Path file = fs.getPath(e.name); byte[] bytes = Files.readAllBytes(file); - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } diff --git a/test/jdk/jdk/nio/zipfs/ZFSTests.java b/test/jdk/jdk/nio/zipfs/ZFSTests.java index f00ff58f877..b4e625dfe38 100644 --- a/test/jdk/jdk/nio/zipfs/ZFSTests.java +++ b/test/jdk/jdk/nio/zipfs/ZFSTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,20 @@ /* @test * @bug 7156873 8040059 8028480 8034773 8153248 8061777 8197398 8210394 * @summary ZipFileSystem regression tests - * * @modules jdk.zipfs - * @run main ZFSTests - * @run main/othervm ZFSTests + * @run junit ZFSTests + * @run junit/othervm ZFSTests */ +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.OutputStream; import java.net.URI; import java.nio.ByteBuffer; import java.nio.channels.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.spi.*; @@ -45,16 +47,16 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + public class ZFSTests { - public static void main(String[] args) throws Throwable { - test8197398(); - test7156873(); - test8061777(); - tests(); - } + static final Charset ASCII = StandardCharsets.US_ASCII; - static void test8197398() throws Throwable { + @Test + void test8197398() throws Throwable { // root entry "/" Path path = Paths.get("rootdir.zip"); @@ -72,33 +74,29 @@ public class ZFSTests { } AtomicInteger cnt = new AtomicInteger(); int max = 3; - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + try (FileSystem fs = FileSystems.newFileSystem(uri, Map.of())) { Files.walkFileTree(fs.getRootDirectories().iterator().next(), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (cnt.incrementAndGet() > max) - throw new RuntimeException("visited too many files/dirs"); + assertFalse(cnt.incrementAndGet() > max, "visited too many files/dirs"); files.remove(file.toString()); - if (!Arrays.equals(Files.readAllBytes(file), file.toString().getBytes())) - throw new RuntimeException("visited files has wrong content: " + file); + assertArrayEquals(file.toString().getBytes(), Files.readAllBytes(file), + "visited files has wrong content: " + file); return FileVisitResult.CONTINUE; } @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) - throws IOException { - if (cnt.incrementAndGet() > max) - throw new RuntimeException("visited too many files/dirs"); + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { + assertFalse(cnt.incrementAndGet() > max, "visited too many files/dirs"); dirs.remove(dir.toString()); return FileVisitResult.CONTINUE; } }); - if (cnt.get() != max || dirs.size() != 0 || files.size() != 0) - throw new RuntimeException("walk files/dirs failed"); - + assertFalse(cnt.get() != max || dirs.size() != 0 || files.size() != 0, + "walk files/dirs failed"); } finally { Files.deleteIfExists(path); } @@ -119,15 +117,15 @@ public class ZFSTests { zos.write("/fooo/bar".getBytes()); } - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + try (FileSystem fs = FileSystems.newFileSystem(uri, Map.of())) { Files.walkFileTree(fs.getRootDirectories().iterator().next(), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { files.remove(file.toString()); - if (!Arrays.equals(Files.readAllBytes(file), file.toString().getBytes())) - throw new RuntimeException("visited files has wrong content: " + file); + assertArrayEquals(file.toString().getBytes(), Files.readAllBytes(file), + "visited files has wrong content: " + file); return FileVisitResult.CONTINUE; } @Override @@ -137,8 +135,8 @@ public class ZFSTests { return FileVisitResult.CONTINUE; } }); - if (dirs.size() != 0 || files.size() != 0) - throw new RuntimeException("walk files/dirs failed"); + assertFalse(dirs.size() != 0 || files.size() != 0, + "walk files/dirs failed"); // for next test: updated any entry, the result zipfs file should have no // absolute path entry @@ -151,22 +149,22 @@ public class ZFSTests { files.add("/foo"); files.add("/bar"); files.add("/fooo/bar"); - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + try (FileSystem fs = FileSystems.newFileSystem(uri, Map.of())) { Files.walk(fs.getPath("/")).forEach( p -> { if (Files.isDirectory(p)) { dirs.remove(p.toString()); } else { files.remove(p.toString()); try { - if (!Arrays.equals(Files.readAllBytes(p), p.toString().getBytes())) - throw new RuntimeException("visited files has wrong content: " + p); + assertArrayEquals(p.toString().getBytes(), Files.readAllBytes(p), + "visited files has wrong content: " + p); } catch (IOException x) { throw new RuntimeException(x); } } }); - if (dirs.size() != 0 || files.size() != 0) - throw new RuntimeException("walk files/dirs failed"); + assertFalse(dirs.size() != 0 || files.size() != 0, + "walk files/dirs failed"); } // updated zip file should not have "/" and entry with absolute path @@ -175,17 +173,16 @@ public class ZFSTests { .map(ZipEntry::toString) .sorted() .toArray(String[]::new); - if (!Arrays.equals(entries, new String[] {"bar", "foo", "fooo/", "fooo/bar" })) { - System.out.println("unexpeded: " + Arrays.toString(entries)); - throw new RuntimeException("unexpected entreis in updated zipfs file"); - } + assertArrayEquals(new String[] {"bar", "foo", "fooo/", "fooo/bar" }, entries, + "unexpected entreis in updated zipfs file"); } } finally { Files.deleteIfExists(path); } } - static void test7156873() throws Throwable { + @Test + void test7156873() throws Throwable { String DIRWITHSPACE = "testdir with spaces"; Path dir = Paths.get(DIRWITHSPACE); Path path = Paths.get(DIRWITHSPACE, "file.zip"); @@ -201,7 +198,8 @@ public class ZFSTests { } } - static void test8061777() throws Throwable { + @Test + void test8061777() throws Throwable { Path path = Paths.get("file.zip"); try { URI uri = URI.create("jar:" + path.toUri()); @@ -212,24 +210,25 @@ public class ZFSTests { FileSystemProvider fsp = fs.provider(); Path p = fs.getPath("/\u8868\u7533.txt"); // 0x95 0x5c 0x90 0x5c try (OutputStream os = fsp.newOutputStream(p)) { - os.write("Hello!".getBytes("ASCII")); + os.write("Hello!".getBytes(ASCII)); } Path dir = fs.getPath("/"); Files.list(dir) .forEach( child -> { System.out.println("child:" + child); - if (!child.toString().equals(p.toString())) - throw new RuntimeException("wrong path name created"); + assertEquals(p.toString(), child.toString(), + "wrong path name created"); }); - if (!"Hello!".equals(new String(Files.readAllBytes(p), "ASCII"))) - throw new RuntimeException("wrong content in newly created file"); + assertEquals("Hello!", new String(Files.readAllBytes(p), ASCII), + "wrong content in newly created file"); } } finally { Files.deleteIfExists(path); } } - static void tests() throws Throwable { + @Test + void tests() throws Throwable { Path path = Paths.get("file.zip"); try { URI uri = URI.create("jar:" + path.toUri()); @@ -245,16 +244,14 @@ public class ZFSTests { StandardOpenOption.WRITE, StandardOpenOption.APPEND); try (FileChannel ch = fsp.newFileChannel(p, options)) { - ch.write(ByteBuffer.wrap("Hello!".getBytes("ASCII"))); + ch.write(ByteBuffer.wrap("Hello!".getBytes(ASCII))); } // 8034773 try (OutputStream os = fsp.newOutputStream(p, new OpenOption[0])) { - os.write("Hello2!".getBytes("ASCII")); - } - if (!"Hello2!".equals(new String( - Files.readAllBytes(fs.getPath("test.txt"))))) { - throw new RuntimeException("failed to open as truncate_existing"); + os.write("Hello2!".getBytes(ASCII)); } + assertEquals("Hello2!", new String( + Files.readAllBytes(fs.getPath("test.txt"))), "failed to open as truncate_existing"); options = EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.APPEND, @@ -273,8 +270,8 @@ public class ZFSTests { Files.list(dir) .forEach( child -> { System.out.println("child:" + child); - if (child.toString().endsWith("/")) - throw new RuntimeException("subdir names ends with /"); + assertFalse(child.toString().endsWith("/"), + "subdir names ends with /"); }); } } finally { diff --git a/test/jdk/jdk/nio/zipfs/ZeroDate.java b/test/jdk/jdk/nio/zipfs/ZeroDate.java index ff702f63488..9c7f3abef0d 100644 --- a/test/jdk/jdk/nio/zipfs/ZeroDate.java +++ b/test/jdk/jdk/nio/zipfs/ZeroDate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ import static java.util.zip.ZipFile.CENTIM; import static java.util.zip.ZipFile.ENDHDR; import static java.util.zip.ZipFile.ENDOFF; import static java.util.zip.ZipFile.LOCTIM; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.io.InputStream; @@ -40,11 +41,17 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.Collections; +import java.util.Map; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import jdk.test.lib.Utils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /* @test * @bug 8184940 8186227 8188869 @@ -53,42 +60,54 @@ import jdk.test.lib.Utils; * @author Liam Miller-Cushon * @modules jdk.zipfs * @library /test/lib + * @run junit ZeroDate */ public class ZeroDate { - public static void main(String[] args) throws Exception { - // create a zip file, and read it in as a byte array - Path path = Utils.createTempFile("bad", ".zip"); - try { - try (OutputStream os = Files.newOutputStream(path); - ZipOutputStream zos = new ZipOutputStream(os)) { - ZipEntry e = new ZipEntry("x"); - zos.putNextEntry(e); - zos.write((int) 'x'); - } - int len = (int) Files.size(path); - byte[] data = new byte[len]; - try (InputStream is = Files.newInputStream(path)) { - is.read(data); - } + static Path path; + static byte[] data; - // year, month, day are zero - testDate(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay()); - // only year is zero - testDate(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay()); - // month is greater than 12 - testDate(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay()); - // 30th of February - testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay()); - // 30th of February, 24:60:60 - testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1, - LocalDateTime.of(1980, 3, 2, 1, 1, 0)); - } finally { - Files.delete(path); + @BeforeAll + static void setup() throws IOException { + // create a zip file, and read it in as a byte array + path = Utils.createTempFile("bad", ".zip"); + try (OutputStream os = Files.newOutputStream(path); + ZipOutputStream zos = new ZipOutputStream(os)) { + ZipEntry e = new ZipEntry("x"); + zos.putNextEntry(e); + zos.write((int) 'x'); + } + int len = (int) Files.size(path); + data = new byte[len]; + try (InputStream is = Files.newInputStream(path)) { + is.read(data); } } - private static void testDate(byte[] data, int date, LocalDateTime expected) throws IOException { + @AfterAll + static void cleanup () throws IOException { + Files.delete(path); + } + + static Stream dateData() { + return Stream.of( + // year, month, day are zero + Arguments.of(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay()), + // only year is zero + Arguments.of(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay()), + // month is greater than 12 + Arguments.of(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay()), + // 30th of February + Arguments.of(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay()), + // 30th of February, 24:60:60 + Arguments.of(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1, + LocalDateTime.of(1980, 3, 2, 1, 1, 0)) + ); + } + + @ParameterizedTest + @MethodSource("dateData") + void testDate(byte[] data, int date, LocalDateTime expected) throws IOException { // set the datetime int endpos = data.length - ENDHDR; int cenpos = u16(data, endpos + ENDOFF); @@ -102,7 +121,7 @@ public class ZeroDate { os.write(data); } URI uri = URI.create("jar:" + path.toUri()); - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + try (FileSystem fs = FileSystems.newFileSystem(uri, Map.of())) { Path entry = fs.getPath("x"); Instant actualInstant = Files.readAttributes(entry, BasicFileAttributes.class) @@ -110,10 +129,8 @@ public class ZeroDate { .toInstant(); Instant expectedInstant = expected.atZone(ZoneId.systemDefault()).toInstant(); - if (!actualInstant.equals(expectedInstant)) { - throw new AssertionError( - String.format("actual: %s, expected: %s", actualInstant, expectedInstant)); - } + assertEquals(expectedInstant, actualInstant, + String.format("actual: %s, expected: %s", actualInstant, expectedInstant)); } finally { Files.delete(path); } diff --git a/test/jdk/jdk/nio/zipfs/ZipFSOutputStreamTest.java b/test/jdk/jdk/nio/zipfs/ZipFSOutputStreamTest.java index 8175eec070d..4e797b57380 100644 --- a/test/jdk/jdk/nio/zipfs/ZipFSOutputStreamTest.java +++ b/test/jdk/jdk/nio/zipfs/ZipFSOutputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,11 +22,6 @@ * */ -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; @@ -37,6 +32,16 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.Map; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -44,7 +49,7 @@ import java.util.Map; * @summary Verify that the outputstream created for zip file entries, through the ZipFileSystem * works fine for varying sizes of the zip file entries * @bug 8190753 8011146 8279536 - * @run testng/timeout=300 ZipFSOutputStreamTest + * @run junit/timeout=300 ZipFSOutputStreamTest */ public class ZipFSOutputStreamTest { // List of files to be added to the ZIP file along with their sizes in bytes @@ -56,12 +61,12 @@ public class ZipFSOutputStreamTest { private static final Path ZIP_FILE = Path.of("zipfs-outputstream-test.zip"); - @BeforeMethod + @BeforeEach public void setUp() throws IOException { deleteFiles(); } - @AfterMethod + @AfterEach public void tearDown() throws IOException { deleteFiles(); } @@ -70,13 +75,12 @@ public class ZipFSOutputStreamTest { Files.deleteIfExists(ZIP_FILE); } - @DataProvider(name = "zipFSCreationEnv") - private Object[][] zipFSCreationEnv() { - return new Object[][]{ - {Map.of("create", "true", "noCompression", "true")}, // STORED - {Map.of("create", "true", "noCompression", "false")} // DEFLATED + private static Stream zipFSCreationEnv() { + return Stream.of( + Arguments.of(Map.of("create", "true", "noCompression", "true")), // STORED + Arguments.of(Map.of("create", "true", "noCompression", "false")) // DEFLATED - }; + ); } /** @@ -84,7 +88,8 @@ public class ZipFSOutputStreamTest { * by the ZipFileSystem. Then verify that the generated zip file entries are as expected, * both in size and content */ - @Test(dataProvider = "zipFSCreationEnv") + @ParameterizedTest + @MethodSource("zipFSCreationEnv") public void testOutputStream(final Map env) throws Exception { final byte[] chunk = new byte[1024]; // fill it with some fixed content (the fixed content will later on help ease @@ -117,12 +122,12 @@ public class ZipFSOutputStreamTest { while ((numRead = is.read(buf)) != -1) { totalRead += numRead; // verify the content - Assert.assertEquals(Arrays.mismatch(buf, 0, numRead, chunk, 0, numRead), -1, + assertEquals(-1, Arrays.mismatch(buf, 0, numRead, chunk, 0, numRead), "Unexpected content in " + entryPath); } System.out.println("Read entry " + entryPath + " of bytes " + totalRead + " in " + (System.currentTimeMillis() - start) + " milli seconds"); - Assert.assertEquals(totalRead, (long) entry.getValue(), + assertEquals((long) entry.getValue(), totalRead, "Unexpected number of bytes read from zip entry " + entryPath); } } diff --git a/test/jdk/jdk/nio/zipfs/ZipFSPermissionsTest.java b/test/jdk/jdk/nio/zipfs/ZipFSPermissionsTest.java index d5e0a03a9fa..24cba1f301b 100644 --- a/test/jdk/jdk/nio/zipfs/ZipFSPermissionsTest.java +++ b/test/jdk/jdk/nio/zipfs/ZipFSPermissionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,8 +22,6 @@ * */ -import org.testng.SkipException; -import org.testng.annotations.*; import java.io.IOException; import java.nio.file.FileSystem; @@ -36,9 +34,21 @@ import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import static java.nio.file.attribute.PosixFilePermission.*; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullSource; /** * @test @@ -46,7 +56,7 @@ import static org.testng.Assert.assertEquals; * @summary Updating an existing zip file does not preserve original permissions * @library /test/lib * @modules jdk.zipfs - * @run testng/othervm ZipFSPermissionsTest + * @run junit/othervm ZipFSPermissionsTest */ public class ZipFSPermissionsTest { @@ -62,18 +72,14 @@ public class ZipFSPermissionsTest { /** * Create the files used by the test */ - @BeforeSuite - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { boolean supportsPosix = FileSystems.getDefault() .supportedFileAttributeViews().contains("posix"); - // Check to see if File System supports POSIX permissions - if (supportsPosix) { - System.out.println("File Store Supports Posix"); - } else { - // As there is no POSIX permission support, skip running the test - throw new SkipException("Cannot set permissions on this File Store"); - } + + Assumptions.assumeTrue(supportsPosix, "Cannot set permissions on this File Store"); + System.out.println("File Store Supports Posix"); Files.writeString(entry0, "Tennis Pro"); Files.writeString(entry1, "Tennis is a lifetime sport!"); } @@ -81,7 +87,7 @@ public class ZipFSPermissionsTest { /** * Re-create the initial Zip file prior to each run. */ - @BeforeMethod + @BeforeEach public void before() throws Exception { Files.deleteIfExists(zipFile); zip(zipFile, Map.of("create", "true"), entry0); @@ -90,7 +96,7 @@ public class ZipFSPermissionsTest { /** * Remove Zip file used by test after each run. */ - @AfterMethod + @AfterEach public void tearDown() throws Exception { Files.deleteIfExists(zipFile); } @@ -98,8 +104,8 @@ public class ZipFSPermissionsTest { /** * Remove files used by test as part of final test run clean-up */ - @AfterSuite - public void suiteCleanUp() throws Exception { + @AfterAll + public static void suiteCleanUp() throws Exception { Files.deleteIfExists(zipFile); Files.deleteIfExists(entry0); Files.deleteIfExists(entry1); @@ -112,7 +118,9 @@ public class ZipFSPermissionsTest { * file * @throws Exception If an error occurs */ - @Test(dataProvider = "posixPermissions") + @ParameterizedTest + @MethodSource("posixPermissions") + @NullSource public void testZipPerms(Set newPerms) throws Exception { if (DEBUG) { System.out.printf("Test Run with perms= %s%n", newPerms); @@ -138,7 +146,7 @@ public class ZipFSPermissionsTest { // Zip file PosixFileAttributes afterAttrs = getPosixAttributes(zipFile); displayPermissions("Permissions after updating the Zip File", zipFile); - assertEquals(afterAttrs.permissions(), newPerms, + assertEquals(newPerms, afterAttrs.permissions(), "Permissions were not updated as expected!"); } @@ -206,23 +214,21 @@ public class ZipFSPermissionsTest { } /* - * DataProvider used to verify the permissions on a Zip file + * MethodSource used to verify the permissions on a Zip file * are as expected after updating the Zip file */ - @DataProvider(name = "posixPermissions") - private Object[][] posixPermissions() { - return new Object[][]{ - {null}, - {Set.of(OWNER_READ, OWNER_WRITE, OTHERS_READ)}, - {Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE)}, - {Set.of(OWNER_READ, OWNER_WRITE, OTHERS_READ, OTHERS_WRITE)}, - {Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, OTHERS_READ, - OTHERS_WRITE, OTHERS_EXECUTE)}, - {Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, + private static Stream posixPermissions() { + return Stream.of( + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, OTHERS_READ)), + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE)), + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, OTHERS_READ, OTHERS_WRITE)), + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, OTHERS_READ, + OTHERS_WRITE, OTHERS_EXECUTE)), + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE,GROUP_EXECUTE, OTHERS_READ, - OTHERS_WRITE, OTHERS_EXECUTE)}, - {Set.of(OWNER_READ, OWNER_WRITE, GROUP_READ, GROUP_WRITE, - OTHERS_READ, OTHERS_WRITE)}, - }; + OTHERS_WRITE, OTHERS_EXECUTE)), + Arguments.of(Set.of(OWNER_READ, OWNER_WRITE, GROUP_READ, GROUP_WRITE, + OTHERS_READ, OTHERS_WRITE)) + ); } } diff --git a/test/jdk/jdk/nio/zipfs/ZipFSTester.java b/test/jdk/jdk/nio/zipfs/ZipFSTester.java index e6300a90004..84135fd0d7d 100644 --- a/test/jdk/jdk/nio/zipfs/ZipFSTester.java +++ b/test/jdk/jdk/nio/zipfs/ZipFSTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2026, 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,6 +21,9 @@ * questions. */ +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -68,6 +71,13 @@ import java.util.zip.ZipOutputStream; import static java.nio.file.StandardOpenOption.*; import static java.nio.file.StandardCopyOption.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /* * Tests various zipfs operations. @@ -78,57 +88,46 @@ import static java.nio.file.StandardCopyOption.*; * 8131067 8034802 8210899 8273961 8271079 8299864 * @summary Test Zip filesystem provider * @modules jdk.zipfs - * @run main ZipFSTester - * @run main/othervm ZipFSTester + * @run junit ZipFSTester + * @run junit/othervm ZipFSTester */ - public class ZipFSTester { - public static void main(String[] args) throws Exception { - // create JAR file for test, actual contents don't matter - Path jarFile = Utils.createJarFile("tester.jar", + + private static final Random RDM = new Random(); + + // create JAR file for test, actual contents don't matter + static Path jarFile; + + @BeforeAll + static void setup() throws Exception { + jarFile = Utils.createJarFile("tester.jar", "META-INF/MANIFEST.MF", "dir1/foo", "dir2/bar", "dir1/dir3/fooo"); - - try (FileSystem fs = newZipFileSystem(jarFile, Collections.emptyMap())) { - test0(fs); - test1(fs); - test2(fs); - testFileStoreNullArgs(fs); // more tests - } - testStreamChannel(); - testTime(jarFile); - test8069211(); - test8131067(); } - private static final Random RDM = new Random(); - - static void test0(FileSystem fs) - throws Exception - { + @Test + void test0() throws Exception { List list = new LinkedList<>(); - try (ZipFile zf = new ZipFile(fs.toString())) { + try (var fs = newZipFileSystem(jarFile, Map.of()); + ZipFile zf = new ZipFile(fs.toString())) { Enumeration zes = zf.entries(); while (zes.hasMoreElements()) { list.add(zes.nextElement().getName()); } for (String pname : list) { Path path = fs.getPath(pname); - if (!Files.exists(path)) - throw new RuntimeException("path existence check failed!"); + assertTrue(Files.exists(path), "path existence check failed!"); while ((path = path.getParent()) != null) { - if (!Files.exists(path)) - throw new RuntimeException("parent existence check failed!"); + assertTrue(Files.exists(path), "parent existence check failed!"); } } } } - static void test1(FileSystem fs0) - throws Exception - { + @Test + void test1() throws Exception { // prepare a src for testing Path src = getTempPath(); String tmpName = src.toString(); @@ -142,11 +141,12 @@ public class ZipFSTester { Path tmpfsPath = getTempPath(); Map env = new HashMap(); env.put("create", "true"); - try (FileSystem copy = newZipFileSystem(tmpfsPath, env)) { - z2zcopy(fs0, copy, "/", 0); + try (var fs = newZipFileSystem(jarFile, Map.of()); + FileSystem copy = newZipFileSystem(tmpfsPath, env)) { + z2zcopy(fs, copy, "/", 0); // copy the test jar itself in - Files.copy(Paths.get(fs0.toString()), copy.getPath("/foo.jar")); + Files.copy(Paths.get(fs.toString()), copy.getPath("/foo.jar")); Path zpath = copy.getPath("/foo.jar"); try (FileSystem zzfs = FileSystems.newFileSystem(zpath)) { Files.copy(src, zzfs.getPath("/srcInjarjar")); @@ -158,23 +158,15 @@ public class ZipFSTester { FileSystemProvider provider = fs.provider(); // newFileSystem(path...) should not throw exception try (FileSystem fsPath = provider.newFileSystem(tmpfsPath, new HashMap())){} - try (FileSystem fsUri = provider.newFileSystem( - new URI("jar", tmpfsPath.toUri().toString(), null), - new HashMap())) - { - throw new RuntimeException("newFileSystem(URI...) does not throw exception"); - } catch (FileSystemAlreadyExistsException fsaee) {} - - try { - provider.newFileSystem(new File(System.getProperty("test.src", ".")).toPath(), - new HashMap()); - throw new RuntimeException("newFileSystem() opens a directory as zipfs"); - } catch (UnsupportedOperationException uoe) {} - - try { - provider.newFileSystem(src, new HashMap()); - throw new RuntimeException("newFileSystem() opens a non-zip file as zipfs"); - } catch (UnsupportedOperationException uoe) {} + assertThrows(FileSystemAlreadyExistsException.class, + () -> provider.newFileSystem(new URI("jar", tmpfsPath.toUri().toString(), null), + new HashMap<>()), "newFileSystem(URI...) does not throw exception"); + assertThrows(UnsupportedOperationException.class, + () -> provider.newFileSystem(new File(System.getProperty("test.src", ".")).toPath(), + new HashMap<>()), "newFileSystem() opens a directory as zipfs"); + assertThrows(UnsupportedOperationException.class, + () -> provider.newFileSystem(src, new HashMap()), + "newFileSystem() opens a non-zip file as zipfs"); // walk walk(fs.getPath("/")); @@ -193,15 +185,13 @@ public class ZipFSTester { // delete Files.delete(dst); - if (Files.exists(dst)) - throw new RuntimeException("Failed!"); + assertFalse(Files.exists(dst)); // moveout Path dst3 = Paths.get(tmpName + "_Tmp"); Files.move(dst2, dst3); checkEqual(src, dst3); - if (Files.exists(dst2)) - throw new RuntimeException("Failed!"); + assertFalse(Files.exists(dst2)); // copyback + move Files.copy(dst3, dst); @@ -211,11 +201,9 @@ public class ZipFSTester { // delete Files.delete(dst4); - if (Files.exists(dst4)) - throw new RuntimeException("Failed!"); + assertFalse(Files.exists(dst4)); Files.delete(dst3); - if (Files.exists(dst3)) - throw new RuntimeException("Failed!"); + assertFalse(Files.exists(dst3)); // move (existing entry) Path dst5 = fs.getPath("META-INF/MANIFEST.MF"); @@ -227,12 +215,7 @@ public class ZipFSTester { // newInputStream on dir Path parent = dst2.getParent(); - try { - Files.newInputStream(parent); - throw new RuntimeException("Failed"); - } catch (FileSystemException e) { - // expected fse - } + assertThrows(FileSystemException.class, () -> Files.newInputStream(parent)); // rmdirs try { @@ -278,8 +261,8 @@ public class ZipFSTester { } } - static void test2(FileSystem fs) throws Exception { - + @Test + void test2() throws Exception { Path fs1Path = getTempPath(); Path fs2Path = getTempPath(); Path fs3Path = getTempPath(); @@ -293,129 +276,137 @@ public class ZipFSTester { final FileSystem fs3 = newZipFileSystem(fs3Path, env); System.out.println("copy src: fs -> fs0..."); - z2zcopy(fs, fs0, "/", 0); // copy fs -> fs1 - fs0.close(); // dump to file + try (var fs = newZipFileSystem(jarFile, Map.of())) { + z2zcopy(fs, fs0, "/", 0); // copy fs -> fs1 + fs0.close(); // dump to file - System.out.println("open fs0 as fs1"); - env = new HashMap(); - final FileSystem fs1 = newZipFileSystem(fs1Path, env); + System.out.println("open fs0 as fs1"); + env = new HashMap(); + final FileSystem fs1 = newZipFileSystem(fs1Path, env); - System.out.println("listing..."); - final ArrayList files = new ArrayList<>(); - final ArrayList dirs = new ArrayList<>(); - list(fs1.getPath("/"), files, dirs); + System.out.println("listing..."); + final ArrayList files = new ArrayList<>(); + final ArrayList dirs = new ArrayList<>(); + list(fs1.getPath("/"), files, dirs); - Thread t0 = new Thread(new Runnable() { - public void run() { - List list = new ArrayList<>(dirs); - Collections.shuffle(list); - for (String path : list) { - try { - z2zcopy(fs1, fs2, path, 0); - } catch (Exception x) { - x.printStackTrace(); - } - } - } - - }); - - Thread t1 = new Thread(new Runnable() { - public void run() { - List list = new ArrayList<>(dirs); - Collections.shuffle(list); - for (String path : list) { - try { - z2zcopy(fs1, fs2, path, 1); - } catch (Exception x) { - x.printStackTrace(); - } - } - } - - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - List list = new ArrayList<>(dirs); - Collections.shuffle(list); - for (String path : list) { - try { - z2zcopy(fs1, fs2, path, 2); - } catch (Exception x) { - x.printStackTrace(); - } - } - } - - }); - - Thread t3 = new Thread(new Runnable() { - public void run() { - List list = new ArrayList<>(files); - Collections.shuffle(list); - while (!list.isEmpty()) { - Iterator itr = list.iterator(); - while (itr.hasNext()) { - String path = itr.next(); + Thread t0 = new Thread(new Runnable() { + public void run() { + List list = new ArrayList<>(dirs); + Collections.shuffle(list); + for (String path : list) { try { - if (Files.exists(fs2.getPath(path))) { - z2zmove(fs2, fs3, path); - itr.remove(); - } - } catch (FileAlreadyExistsException x) { - itr.remove(); + z2zcopy(fs1, fs2, path, 0); } catch (Exception x) { x.printStackTrace(); } } } + + }); + + Thread t1 = new Thread(new Runnable() { + public void run() { + List list = new ArrayList<>(dirs); + Collections.shuffle(list); + for (String path : list) { + try { + z2zcopy(fs1, fs2, path, 1); + } catch (Exception x) { + x.printStackTrace(); + } + } + } + + }); + + Thread t2 = new Thread(new Runnable() { + public void run() { + List list = new ArrayList<>(dirs); + Collections.shuffle(list); + for (String path : list) { + try { + z2zcopy(fs1, fs2, path, 2); + } catch (Exception x) { + x.printStackTrace(); + } + } + } + + }); + + Thread t3 = new Thread(new Runnable() { + public void run() { + List list = new ArrayList<>(files); + Collections.shuffle(list); + while (!list.isEmpty()) { + Iterator itr = list.iterator(); + while (itr.hasNext()) { + String path = itr.next(); + try { + if (Files.exists(fs2.getPath(path))) { + z2zmove(fs2, fs3, path); + itr.remove(); + } + } catch (FileAlreadyExistsException x) { + itr.remove(); + } catch (Exception x) { + x.printStackTrace(); + } + } + } + } + + }); + + System.out.println("copying/removing..."); + t0.start(); + t1.start(); + t2.start(); + t3.start(); + t0.join(); + t1.join(); + t2.join(); + t3.join(); + + System.out.println("closing: fs1, fs2"); + fs1.close(); + fs2.close(); + + int failed = 0; + System.out.println("checkEqual: fs vs fs3"); + for (String path : files) { + try { + checkEqual(fs.getPath(path), fs3.getPath(path)); + } catch (IOException x) { + //x.printStackTrace(); + failed++; + } } + System.out.println("closing: fs3"); + fs3.close(); - }); + System.out.println("opening: fs3 as fs4"); + FileSystem fs4 = newZipFileSystem(fs3Path, env); - System.out.println("copying/removing..."); - t0.start(); t1.start(); t2.start(); t3.start(); - t0.join(); t1.join(); t2.join(); t3.join(); - System.out.println("closing: fs1, fs2"); - fs1.close(); - fs2.close(); + ArrayList files2 = new ArrayList<>(); + ArrayList dirs2 = new ArrayList<>(); + list(fs4.getPath("/"), files2, dirs2); - int failed = 0; - System.out.println("checkEqual: fs vs fs3"); - for (String path : files) { - try { - checkEqual(fs.getPath(path), fs3.getPath(path)); - } catch (IOException x) { - //x.printStackTrace(); - failed++; + System.out.println("checkEqual: fs vs fs4"); + for (String path : files2) { + checkEqual(fs.getPath(path), fs4.getPath(path)); } + System.out.println("walking: fs4"); + walk(fs4.getPath("/")); + System.out.println("closing: fs4"); + fs4.close(); + System.out.printf("failed=%d%n", failed); + + Files.delete(fs1Path); + Files.delete(fs2Path); + Files.delete(fs3Path); } - System.out.println("closing: fs3"); - fs3.close(); - - System.out.println("opening: fs3 as fs4"); - FileSystem fs4 = newZipFileSystem(fs3Path, env); - - - ArrayList files2 = new ArrayList<>(); - ArrayList dirs2 = new ArrayList<>(); - list(fs4.getPath("/"), files2, dirs2); - - System.out.println("checkEqual: fs vs fs4"); - for (String path : files2) { - checkEqual(fs.getPath(path), fs4.getPath(path)); - } - System.out.println("walking: fs4"); - walk(fs4.getPath("/")); - System.out.println("closing: fs4"); - fs4.close(); - System.out.printf("failed=%d%n", failed); - - Files.delete(fs1Path); - Files.delete(fs2Path); - Files.delete(fs3Path); } static final int METHOD_STORED = 0; @@ -448,29 +439,21 @@ public class ZipFSTester { CRC32 crc32 = new CRC32(); crc32.update(expected); - if (((Long)Files.getAttribute(path, "zip:crc")).intValue() != - (int)crc32.getValue()) { - System.out.printf(" getAttribute.crc <%s> failed %x vs %x ...%n", + assertEquals((int)crc32.getValue(), ((Long)Files.getAttribute(path, "zip:crc")).intValue(), + " getAttribute.crc <%s> failed %x vs %x ...%n".formatted( path.toString(), ((Long)Files.getAttribute(path, "zip:crc")).intValue(), - (int)crc32.getValue()); - throw new RuntimeException("CHECK FAILED!"); - } + (int)crc32.getValue())); - if (((Long)Files.getAttribute(path, "zip:size")).intValue() != expected.length) { - System.out.printf(" getAttribute.size <%s> failed %x vs %x ...%n", + assertEquals(expected.length, ((Long)Files.getAttribute(path, "zip:size")).intValue(), + " getAttribute.size <%s> failed %x vs %x ...%n".formatted( path.toString(), ((Long)Files.getAttribute(path, "zip:size")).intValue(), - expected.length); - throw new RuntimeException("CHECK FAILED!"); - } + expected.length)); //streams try (InputStream is = Files.newInputStream(path)) { - if (!Arrays.equals(is.readAllBytes(), expected)) { - System.out.printf(" newInputStream <%s> failed...%n", path.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertArrayEquals(expected, is.readAllBytes(), " newInputStream <%s> failed...%n".formatted(path.toString())); } // channels -- via sun.nio.ch.ChannelInputStream @@ -478,17 +461,12 @@ public class ZipFSTester { InputStream is = Channels.newInputStream(sbc)) { // check all bytes match - if (!Arrays.equals(is.readAllBytes(), expected)) { - System.out.printf(" newByteChannel <%s> failed...%n", path.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertArrayEquals(expected, is.readAllBytes(), + " newByteChannel <%s> failed...%n".formatted(path.toString())); // Check if read position is at the end - if (sbc.position() != expected.length) { - System.out.printf("pos [%s]: size=%d, position=%d%n", - path.toString(), expected.length, sbc.position()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(expected.length, sbc.position(), "pos [%s]: size=%d, position=%d%n".formatted( + path.toString(), expected.length, sbc.position())); // Check position(x) + read() at the random/specific pos/len byte[] buf = new byte[1024]; @@ -503,21 +481,20 @@ public class ZipFSTester { // System.out.printf(" --> %d, %d%n", pos, len); bb.position(0).limit(len); // bb.flip().limit(len); int expectedReadResult = sbc.size() == 0 ? -1 : len; - if (sbc.position(pos).position() != pos || + assertFalse(sbc.position(pos).position() != pos || sbc.read(bb) != expectedReadResult || - !Arrays.equals(buf, 0, bb.position(), expected, pos, pos + len)) { - System.out.printf("read()/position() failed%n"); - throw new RuntimeException("CHECK FAILED!"); - } + !Arrays.equals(buf, 0, bb.position(), expected, pos, pos + len), + "read()/position() failed%n"); } } catch (IOException x) { x.printStackTrace(); - throw new RuntimeException("CHECK FAILED!"); + fail("CHECK FAILED!"); } } // test entry stream/channel reading - static void testStreamChannel() throws Exception { + @Test + void testStreamChannel() throws Exception { Path zpath = getTempPath(); try { var crc = new CRC32(); @@ -542,7 +519,7 @@ public class ZipFSTester { zos.closeEntry(); } } - try (var zfs = newZipFileSystem(zpath, Collections.emptyMap())) { + try (var zfs = newZipFileSystem(zpath, Map.of())) { for (Object[] e : entries) { Path path = zfs.getPath((String)e[0]); byte[] bytes = (byte[])e[2]; @@ -561,7 +538,7 @@ public class ZipFSTester { } } } - try (var zfs = newZipFileSystem(zpath, Collections.emptyMap())) { + try (var zfs = newZipFileSystem(zpath, Map.of())) { for (Object[] e : entries) { checkRead(zfs.getPath((String)e[0]), (byte[])e[2]); } @@ -574,7 +551,7 @@ public class ZipFSTester { Files.write(zfs.getPath((String)e[0]), (byte[])e[2]); } } - try (var zfs = newZipFileSystem(zpath, Collections.emptyMap())) { + try (var zfs = newZipFileSystem(zpath, Map.of())) { for (Object[] e : entries) { checkRead(zfs.getPath((String)e[0]), (byte[])e[2]); } @@ -591,7 +568,7 @@ public class ZipFSTester { } } } - try (var zfs = newZipFileSystem(zpath, Collections.emptyMap())) { + try (var zfs = newZipFileSystem(zpath, Map.of())) { for (Object[] e : entries) { checkRead(zfs.getPath((String)e[0]), (byte[])e[2]); } @@ -604,9 +581,10 @@ public class ZipFSTester { } // test file stamp - static void testTime(Path src) throws Exception { + @Test + void testTime() throws Exception { BasicFileAttributes attrs = Files - .getFileAttributeView(src, BasicFileAttributeView.class) + .getFileAttributeView(jarFile, BasicFileAttributeView.class) .readAttributes(); // create a new filesystem, copy this file into it Map env = new HashMap(); @@ -616,8 +594,8 @@ public class ZipFSTester { System.out.println("test copy with timestamps..."); // copyin Path dst = getPathWithParents(fs, "me"); - Files.copy(src, dst, COPY_ATTRIBUTES); - checkEqual(src, dst); + Files.copy(jarFile, dst, COPY_ATTRIBUTES); + checkEqual(jarFile, dst); System.out.println("mtime: " + attrs.lastModifiedTime()); System.out.println("ctime: " + attrs.creationTime()); System.out.println("atime: " + attrs.lastAccessTime()); @@ -630,20 +608,19 @@ public class ZipFSTester { System.out.println("atime: " + dstAttrs.lastAccessTime()); // 1-second granularity - if (attrs.lastModifiedTime().to(TimeUnit.SECONDS) != + assertFalse(attrs.lastModifiedTime().to(TimeUnit.SECONDS) != dstAttrs.lastModifiedTime().to(TimeUnit.SECONDS) || attrs.lastAccessTime().to(TimeUnit.SECONDS) != dstAttrs.lastAccessTime().to(TimeUnit.SECONDS) || attrs.creationTime().to(TimeUnit.SECONDS) != - dstAttrs.creationTime().to(TimeUnit.SECONDS)) { - throw new RuntimeException("Timestamp Copy Failed!"); - } + dstAttrs.creationTime().to(TimeUnit.SECONDS), "Timestamp Copy Failed!"); } finally { Files.delete(fsPath); } } - static void test8069211() throws Exception { + @Test + void test8069211() throws Exception { // create a new filesystem, copy this file into it Map env = new HashMap(); env.put("create", "true"); @@ -655,18 +632,17 @@ public class ZipFSTester { out.close(); } try (FileSystem fs = newZipFileSystem(fsPath, new HashMap())) { - if (!Arrays.equals(Files.readAllBytes(fs.getPath("/foo")), - "hello".getBytes())) { - throw new RuntimeException("entry close() failed"); - } + assertArrayEquals("hello".getBytes(), Files.readAllBytes(fs.getPath("/foo")), + "entry close() failed"); } catch (Exception x) { - throw new RuntimeException("entry close() failed", x); + fail("entry close() failed", x); } finally { Files.delete(fsPath); } } - static void test8131067() throws Exception { + @Test + void test8131067() throws Exception { Map env = new HashMap(); env.put("create", "true"); @@ -677,10 +653,8 @@ public class ZipFSTester { try (FileSystem fs = newZipFileSystem(fsPath, env);) { Files.write(fs.getPath("/foo"), "hello".getBytes()); URI fooUri = fs.getPath("/foo").toUri(); - if (!Arrays.equals(Files.readAllBytes(Paths.get(fooUri)), - "hello".getBytes())) { - throw new RuntimeException("entry close() failed"); - } + assertArrayEquals("hello".getBytes(), Files.readAllBytes(Paths.get(fooUri)), + "entry close() failed"); } finally { Files.delete(fsPath); } @@ -868,19 +842,13 @@ public class ZipFSTester { int nDst = 0; while (nDst < nSrc) { int n = isDst.read(bufDst, nDst, nSrc - nDst); - if (n == -1) { - System.out.printf("checking <%s> vs <%s>...%n", - src.toString(), dst.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertNotEquals(-1, n, "checking <%s> vs <%s>...%n".formatted( + src.toString(), dst.toString())); nDst += n; } while (--nSrc >= 0) { - if (bufSrc[nSrc] != bufDst[nSrc]) { - System.out.printf("checking <%s> vs <%s>...%n", - src.toString(), dst.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(bufSrc[nSrc], bufDst[nSrc], "checking <%s> vs <%s>...%n".formatted( + src.toString(), dst.toString())); nSrc--; } } @@ -890,29 +858,20 @@ public class ZipFSTester { try (SeekableByteChannel chSrc = Files.newByteChannel(src); SeekableByteChannel chDst = Files.newByteChannel(dst)) { - if (chSrc.size() != chDst.size()) { - System.out.printf("src[%s].size=%d, dst[%s].size=%d%n", + assertEquals(chSrc.size(), chDst.size(), "src[%s].size=%d, dst[%s].size=%d%n".formatted( chSrc.toString(), chSrc.size(), - chDst.toString(), chDst.size()); - throw new RuntimeException("CHECK FAILED!"); - } + chDst.toString(), chDst.size())); ByteBuffer bbSrc = ByteBuffer.allocate(8192); ByteBuffer bbDst = ByteBuffer.allocate(8192); int nSrc = 0; while ((nSrc = chSrc.read(bbSrc)) != -1) { int nDst = chDst.read(bbDst); - if (nSrc != nDst) { - System.out.printf("checking <%s> vs <%s>...%n", - src.toString(), dst.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(nSrc, nDst, + "checking <%s> vs <%s>...%n".formatted(src.toString(), dst.toString())); while (--nSrc >= 0) { - if (bbSrc.get(nSrc) != bbDst.get(nSrc)) { - System.out.printf("checking <%s> vs <%s>...%n", - src.toString(), dst.toString()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(bbSrc.get(nSrc), bbDst.get(nSrc), + "checking <%s> vs <%s>...%n".formatted(src.toString(), dst.toString())); nSrc--; } bbSrc.flip(); @@ -920,18 +879,12 @@ public class ZipFSTester { } // Check if source read position is at the end - if (chSrc.position() != chSrc.size()) { - System.out.printf("src[%s]: size=%d, position=%d%n", - chSrc.toString(), chSrc.size(), chSrc.position()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(chSrc.position(), chSrc.size(), "src[%s]: size=%d, position=%d%n".formatted( + chSrc.toString(), chSrc.size(), chSrc.position())); // Check if destination read position is at the end - if (chDst.position() != chDst.size()) { - System.out.printf("dst[%s]: size=%d, position=%d%n", - chDst.toString(), chDst.size(), chDst.position()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(chDst.position(), chDst.size(), "dst[%s]: size=%d, position=%d%n".formatted( + chDst.toString(), chDst.size(), chDst.position())); // Check position(x) + read() at the specific pos/len for (int i = 0; i < 10; i++) { @@ -996,18 +949,12 @@ public class ZipFSTester { } // Check if source read position is at the end - if (srcCh.position() != srcCh.size()) { - System.out.printf("src[%s]: size=%d, position=%d%n", - srcCh.toString(), srcCh.size(), srcCh.position()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(srcCh.position(), srcCh.size(), "src[%s]: size=%d, position=%d%n".formatted( + srcCh.toString(), srcCh.size(), srcCh.position())); // Check if destination write position is at the end - if (dstCh.position() != dstCh.size()) { - System.out.printf("dst[%s]: size=%d, position=%d%n", - dstCh.toString(), dstCh.size(), dstCh.position()); - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(dstCh.position(), dstCh.size(), "dst[%s]: size=%d, position=%d%n".formatted( + dstCh.toString(), dstCh.size(), dstCh.position())); } } @@ -1037,17 +984,13 @@ public class ZipFSTester { try (SeekableByteChannel sbc = Files.newByteChannel(path)) { System.out.printf(" sbc[0]: pos=%d, size=%d%n", sbc.position(), sbc.size()); - if (sbc.position() != 0) { - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(0, sbc.position()); bb = ByteBuffer.allocate((int)sbc.size()); n = sbc.read(bb); System.out.printf(" sbc[1]: read=%d, pos=%d, size=%d%n", n, sbc.position(), sbc.size()); - if (sbc.position() != sbc.size()) { - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(sbc.position(), sbc.size()); bb2 = ByteBuffer.allocate((int)sbc.size()); } @@ -1057,16 +1000,13 @@ public class ZipFSTester { sbc.position(N); System.out.printf(" sbc[2]: pos=%d, size=%d%n", sbc.position(), sbc.size()); - if (sbc.position() != N) { - throw new RuntimeException("CHECK FAILED!"); - } + assertEquals(N, sbc.position()); bb2.limit(100); n = sbc.read(bb2); System.out.printf(" sbc[3]: read=%d, pos=%d, size=%d%n", n, sbc.position(), sbc.size()); - if (n < 0 || sbc.position() != (N + n)) { - throw new RuntimeException("CHECK FAILED!"); - } + assertFalse(n < 0); + assertFalse(sbc.position() != (N + n)); System.out.printf(" sbc[4]: bb[%d]=%d, bb1[0]=%d%n", N, bb.get(N) & 0xff, bb2.get(0) & 0xff); } @@ -1086,38 +1026,22 @@ public class ZipFSTester { /** * Tests if certain methods throw a NullPointerException if invoked with null * as specified in java.nio.file.package-info.java - * @param fs file system containing at least one ZipFileStore * * @see 8299864 */ - static void testFileStoreNullArgs(FileSystem fs) { - FileStore store = fs.getFileStores().iterator().next(); + @Test + void testFileStoreNullArgs() throws Exception { + try (var fs = newZipFileSystem(jarFile, Map.of())) { + // file system containing at least one ZipFileStore + FileStore store = fs.getFileStores().iterator().next(); - // Make sure we are testing the right thing - if (!"jdk.nio.zipfs.ZipFileStore".equals(store.getClass().getName())) - throw new AssertionError(store.getClass().getName()); + // Make sure we are testing the right thing + assertEquals("jdk.nio.zipfs.ZipFileStore", store.getClass().getName()); - assertThrowsNPE(() -> store.supportsFileAttributeView((String) null)); - assertThrowsNPE(() -> store.supportsFileAttributeView((Class) null)); - assertThrowsNPE(() -> store.getAttribute(null)); - assertThrowsNPE(() -> store.getFileStoreAttributeView(null)); - } - - @FunctionalInterface - private interface ThrowingRunnable { - void run() throws Exception; - } - - static void assertThrowsNPE(ThrowingRunnable r) { - try { - r.run(); - // Didn't throw an exception - throw new AssertionError(); - } catch (NullPointerException expected) { - // happy path - } catch (Exception e) { - throw new AssertionError(e); + assertThrows(NullPointerException.class, () -> store.supportsFileAttributeView((String) null)); + assertThrows(NullPointerException.class, () -> store.supportsFileAttributeView((Class) null)); + assertThrows(NullPointerException.class, () -> store.getAttribute(null)); + assertThrows(NullPointerException.class, () -> store.getFileStoreAttributeView(null)); } } - } diff --git a/test/jdk/jdk/nio/zipfs/jarfs/JFSTester.java b/test/jdk/jdk/nio/zipfs/jarfs/JFSTester.java index 82505e24e6c..46bb27dcf10 100644 --- a/test/jdk/jdk/nio/zipfs/jarfs/JFSTester.java +++ b/test/jdk/jdk/nio/zipfs/jarfs/JFSTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,12 +30,9 @@ * @library /test/lib/ * @build jdk.test.lib.util.JarBuilder * jdk.test.lib.compiler.Compiler - * @run testng JFSTester + * @run junit JFSTester */ -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import java.io.IOException; import java.io.UncheckedIOException; @@ -52,35 +49,41 @@ import java.util.stream.Collectors; import jdk.test.lib.util.JarBuilder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + public class JFSTester { - private URI jarURI; + private static URI jarURI; - final private String root_dir1_leaf1_txt = "This is leaf 1." + System.lineSeparator(); - final private String root_dir1_leaf2_txt = "This is leaf 2." + System.lineSeparator(); - final private String root_dir2_leaf3_txt = "This is leaf 3." + System.lineSeparator(); - final private String root_dir2_leaf4_txt = "This is leaf 4." + System.lineSeparator(); - final private String v9_root_dir2_leaf3_txt = "This is version 9 leaf 3." + System.lineSeparator(); - final private String v9_root_dir2_leaf4_txt = "This is version 9 leaf 4." + System.lineSeparator(); - final private String v9_root_dir3_leaf5_txt = "This is version 9 leaf 5." + System.lineSeparator(); - final private String v9_root_dir3_leaf6_txt = "This is version 9 leaf 6." + System.lineSeparator(); - final private String v10_root_dir3_leaf5_txt = "This is version 10 leaf 5." + System.lineSeparator(); - final private String v10_root_dir3_leaf6_txt = "This is version 10 leaf 6." + System.lineSeparator(); + private static final String ROOT_DIR_1_LEAF_1_TXT = "This is leaf 1." + System.lineSeparator(); + private static final String ROOT_DIR_1_LEAF_2_TXT = "This is leaf 2." + System.lineSeparator(); + private static final String ROOT_DIR_2_LEAF_3_TXT = "This is leaf 3." + System.lineSeparator(); + private static final String ROOT_DIR_2_LEAF_4_TXT = "This is leaf 4." + System.lineSeparator(); + private static final String V_9_ROOT_DIR_2_LEAF_3_TXT = "This is version 9 leaf 3." + System.lineSeparator(); + private static final String V_9_ROOT_DIR_2_LEAF_4_TXT = "This is version 9 leaf 4." + System.lineSeparator(); + private static final String V_9_ROOT_DIR_3_LEAF_5_TXT = "This is version 9 leaf 5." + System.lineSeparator(); + private static final String V_9_ROOT_DIR_3_LEAF_6_TXT = "This is version 9 leaf 6." + System.lineSeparator(); + private static final String V_10_ROOT_DIR_3_LEAF_5_TXT = "This is version 10 leaf 5." + System.lineSeparator(); + private static final String V_10_ROOT_DIR_3_LEAF_6_TXT = "This is version 10 leaf 6." + System.lineSeparator(); - @BeforeClass - public void initialize() throws Exception { + @BeforeAll + public static void initialize() throws Exception { Path jarfile = Paths.get("test.jar"); JarBuilder jb = new JarBuilder(jarfile.toString()); jb.addAttribute("Multi-Release", "true"); - jb.addEntry("root/dir1/leaf1.txt", root_dir1_leaf1_txt.getBytes()); - jb.addEntry("root/dir1/leaf2.txt", root_dir1_leaf2_txt.getBytes()); - jb.addEntry("root/dir2/leaf3.txt", root_dir2_leaf3_txt.getBytes()); - jb.addEntry("root/dir2/leaf4.txt", root_dir2_leaf4_txt.getBytes()); - jb.addEntry("META-INF/versions/9/root/dir2/leaf3.txt", v9_root_dir2_leaf3_txt.getBytes()); - jb.addEntry("META-INF/versions/9/root/dir2/leaf4.txt", v9_root_dir2_leaf4_txt.getBytes()); - jb.addEntry("META-INF/versions/9/root/dir3/leaf5.txt", v9_root_dir3_leaf5_txt.getBytes()); - jb.addEntry("META-INF/versions/9/root/dir3/leaf6.txt", v9_root_dir3_leaf6_txt.getBytes()); - jb.addEntry("META-INF/versions/10/root/dir3/leaf5.txt", v10_root_dir3_leaf5_txt.getBytes()); - jb.addEntry("META-INF/versions/10/root/dir3/leaf6.txt", v10_root_dir3_leaf6_txt.getBytes()); + jb.addEntry("root/dir1/leaf1.txt", ROOT_DIR_1_LEAF_1_TXT.getBytes()); + jb.addEntry("root/dir1/leaf2.txt", ROOT_DIR_1_LEAF_2_TXT.getBytes()); + jb.addEntry("root/dir2/leaf3.txt", ROOT_DIR_2_LEAF_3_TXT.getBytes()); + jb.addEntry("root/dir2/leaf4.txt", ROOT_DIR_2_LEAF_4_TXT.getBytes()); + jb.addEntry("META-INF/versions/9/root/dir2/leaf3.txt", V_9_ROOT_DIR_2_LEAF_3_TXT.getBytes()); + jb.addEntry("META-INF/versions/9/root/dir2/leaf4.txt", V_9_ROOT_DIR_2_LEAF_4_TXT.getBytes()); + jb.addEntry("META-INF/versions/9/root/dir3/leaf5.txt", V_9_ROOT_DIR_3_LEAF_5_TXT.getBytes()); + jb.addEntry("META-INF/versions/9/root/dir3/leaf6.txt", V_9_ROOT_DIR_3_LEAF_6_TXT.getBytes()); + jb.addEntry("META-INF/versions/10/root/dir3/leaf5.txt", V_10_ROOT_DIR_3_LEAF_5_TXT.getBytes()); + jb.addEntry("META-INF/versions/10/root/dir3/leaf6.txt", V_10_ROOT_DIR_3_LEAF_6_TXT.getBytes()); jb.build(); System.out.println("Created " + jarfile + ": " + Files.exists(jarfile)); jarURI = new URI("jar", jarfile.toUri().toString(), null); @@ -92,38 +95,38 @@ public class JFSTester { Map env = new HashMap<>(); Set contents = doTest(env); Set expectedContents = Set.of( - root_dir1_leaf1_txt, - root_dir1_leaf2_txt, - root_dir2_leaf3_txt, - root_dir2_leaf4_txt + ROOT_DIR_1_LEAF_1_TXT, + ROOT_DIR_1_LEAF_2_TXT, + ROOT_DIR_2_LEAF_3_TXT, + ROOT_DIR_2_LEAF_4_TXT ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); // open file as multi-release for version 9 env.put("multi-release", "9"); contents = doTest(env); expectedContents = Set.of( - root_dir1_leaf1_txt, - root_dir1_leaf2_txt, - v9_root_dir2_leaf3_txt, - v9_root_dir2_leaf4_txt, - v9_root_dir3_leaf5_txt, - v9_root_dir3_leaf6_txt + ROOT_DIR_1_LEAF_1_TXT, + ROOT_DIR_1_LEAF_2_TXT, + V_9_ROOT_DIR_2_LEAF_3_TXT, + V_9_ROOT_DIR_2_LEAF_4_TXT, + V_9_ROOT_DIR_3_LEAF_5_TXT, + V_9_ROOT_DIR_3_LEAF_6_TXT ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); // open file as multi-release for version 10 env.put("multi-release", "10"); contents = doTest(env); expectedContents = Set.of( - root_dir1_leaf1_txt, - root_dir1_leaf2_txt, - v9_root_dir2_leaf3_txt, - v9_root_dir2_leaf4_txt, - v10_root_dir3_leaf5_txt, - v10_root_dir3_leaf6_txt + ROOT_DIR_1_LEAF_1_TXT, + ROOT_DIR_1_LEAF_2_TXT, + V_9_ROOT_DIR_2_LEAF_3_TXT, + V_9_ROOT_DIR_2_LEAF_4_TXT, + V_10_ROOT_DIR_3_LEAF_5_TXT, + V_10_ROOT_DIR_3_LEAF_6_TXT ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); } private Set doTest(Map env) throws IOException { @@ -158,7 +161,7 @@ public class JFSTester { "!/root/dir2/leaf3.txt", "!/root/dir2/leaf4.txt" ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); // open file as multi-release for version 9 env.put("multi-release", "9"); @@ -171,7 +174,7 @@ public class JFSTester { "!/META-INF/versions/9/root/dir3/leaf5.txt", "!/META-INF/versions/9/root/dir3/leaf6.txt" ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); // open file as multi-release for version 10 env.put("multi-release", "10"); @@ -184,7 +187,7 @@ public class JFSTester { "!/META-INF/versions/10/root/dir3/leaf5.txt", "!/META-INF/versions/10/root/dir3/leaf6.txt" ); - Assert.assertEquals(contents, expectedContents); + assertEquals(expectedContents, contents); } private Set doTestUri(Map env) throws IOException { diff --git a/test/jdk/jdk/nio/zipfs/jarfs/MultiReleaseJarTest.java b/test/jdk/jdk/nio/zipfs/jarfs/MultiReleaseJarTest.java index 1a336278089..ad0b47a75ee 100644 --- a/test/jdk/jdk/nio/zipfs/jarfs/MultiReleaseJarTest.java +++ b/test/jdk/jdk/nio/zipfs/jarfs/MultiReleaseJarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ * @build CreateMultiReleaseTestJars * jdk.test.lib.util.JarBuilder * jdk.test.lib.compiler.Compiler - * @run testng MultiReleaseJarTest + * @run junit MultiReleaseJarTest */ import java.io.IOException; @@ -46,11 +46,22 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; -import org.testng.Assert; -import org.testng.annotations.*; import jdk.test.lib.util.JarBuilder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class MultiReleaseJarTest { final private int MAJOR_VERSION = Runtime.version().feature(); private static final String PROPERTY_RELEASE_VERSION = "releaseVersion"; @@ -69,7 +80,7 @@ public class MultiReleaseJarTest { private URI mruri; private URI smruri; - @BeforeClass + @BeforeAll public void initialize() throws Exception { creator.compileEntries(); creator.buildUnversionedJar(); @@ -90,55 +101,51 @@ public class MultiReleaseJarTest { Files.delete(Paths.get(userdir, "short-multi-release.jar")); } - @DataProvider(name="strings") - public Object[][] createStrings() { - return new Object[][]{ - {"runtime", MAJOR_VERSION, "8"}, - {null, 8, Integer.toString(MAJOR_VERSION)}, - {"8", 8, "9"}, - {"9", 9, null}, - {Integer.toString(MAJOR_VERSION), MAJOR_VERSION, "8"}, - {Integer.toString(MAJOR_VERSION+1), MAJOR_VERSION, "8"}, - {"50", MAJOR_VERSION, "9"} - }; + public Stream createStrings() { + return Stream.of( + Arguments.of("runtime", MAJOR_VERSION, "8"), + Arguments.of(null, 8, Integer.toString(MAJOR_VERSION)), + Arguments.of("8", 8, "9"), + Arguments.of("9", 9, null), + Arguments.of(Integer.toString(MAJOR_VERSION), MAJOR_VERSION, "8"), + Arguments.of(Integer.toString(MAJOR_VERSION+1), MAJOR_VERSION, "8"), + Arguments.of("50", MAJOR_VERSION, "9") + ); } - @DataProvider(name="integers") - public Object[][] createIntegers() { - return new Object[][] { - {null, 8, Integer.valueOf(9)}, - {Integer.valueOf(8), 8, Integer.valueOf(9)}, - {Integer.valueOf(9), 9, Integer.valueOf(MAJOR_VERSION)}, - {Integer.valueOf(MAJOR_VERSION), MAJOR_VERSION, Integer.valueOf(8)}, - {Integer.valueOf(MAJOR_VERSION + 1), MAJOR_VERSION, null}, - {Integer.valueOf(100), MAJOR_VERSION, Integer.valueOf(8)} - }; + public Stream createIntegers() { + return Stream.of( + Arguments.of(null, 8, Integer.valueOf(9)), + Arguments.of(Integer.valueOf(8), 8, Integer.valueOf(9)), + Arguments.of(Integer.valueOf(9), 9, Integer.valueOf(MAJOR_VERSION)), + Arguments.of(Integer.valueOf(MAJOR_VERSION), MAJOR_VERSION, Integer.valueOf(8)), + Arguments.of(Integer.valueOf(MAJOR_VERSION + 1), MAJOR_VERSION, null), + Arguments.of(Integer.valueOf(100), MAJOR_VERSION, Integer.valueOf(8)) + ); } - @DataProvider(name="versions") - public Object[][] createVersions() { - return new Object[][] { - {null, 8, Version.parse("14")}, - {Version.parse("8"), 8, Version.parse("7")}, - {Version.parse("9"), 9, null}, - {Version.parse(Integer.toString(MAJOR_VERSION)), MAJOR_VERSION, Version.parse("8")}, - {Version.parse(Integer.toString(MAJOR_VERSION) + 1), MAJOR_VERSION, Version.parse("9")}, - {Version.parse("100"), MAJOR_VERSION, Version.parse("14")} - }; + public Stream createVersions() { + return Stream.of( + Arguments.of(null, 8, Version.parse("14")), + Arguments.of(Version.parse("8"), 8, Version.parse("7")), + Arguments.of(Version.parse("9"), 9, null), + Arguments.of(Version.parse(Integer.toString(MAJOR_VERSION)), MAJOR_VERSION, Version.parse("8")), + Arguments.of(Version.parse(Integer.toString(MAJOR_VERSION) + 1), MAJOR_VERSION, Version.parse("9")), + Arguments.of(Version.parse("100"), MAJOR_VERSION, Version.parse("14")) + ); } - @DataProvider(name="invalidVersions") - public Object[][] invalidVersions() { - return new Object[][] { - {Map.of(PROPERTY_RELEASE_VERSION, "")}, - {Map.of(PROPERTY_RELEASE_VERSION, "invalid")}, - {Map.of(PROPERTY_RELEASE_VERSION, "0")}, - {Map.of(PROPERTY_RELEASE_VERSION, "-1")}, - {Map.of(PROPERTY_RELEASE_VERSION, "11.0.1")}, - {Map.of(PROPERTY_RELEASE_VERSION, new ArrayList())}, - {Map.of(PROPERTY_RELEASE_VERSION, Integer.valueOf(0))}, - {Map.of(PROPERTY_RELEASE_VERSION, Integer.valueOf(-1))} - }; + public Stream invalidVersions() { + return Stream.of( + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, "")), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, "invalid")), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, "0")), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, "-1")), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, "11.0.1")), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, new ArrayList())), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, Integer.valueOf(0))), + Arguments.of(Map.of(PROPERTY_RELEASE_VERSION, Integer.valueOf(-1))) + ); } // Not the best test but all I can do since ZipFileSystem @@ -148,16 +155,16 @@ public class MultiReleaseJarTest { Map env = new HashMap<>(); // no configuration, treat multi-release jar as unversioned try (FileSystem fs = FileSystems.newFileSystem(mruri, env)) { - Assert.assertTrue(readAndCompare(fs, 8)); + assertTrue(readAndCompare(fs, 8)); } env.put(PROPERTY_RELEASE_VERSION, "runtime"); // a configuration and jar file is multi-release try (FileSystem fs = FileSystems.newFileSystem(mruri, env)) { - Assert.assertTrue(readAndCompare(fs, MAJOR_VERSION)); + assertTrue(readAndCompare(fs, MAJOR_VERSION)); } // a configuration but jar file is unversioned try (FileSystem fs = FileSystems.newFileSystem(uvuri, env)) { - Assert.assertTrue(readAndCompare(fs, 8)); + assertTrue(readAndCompare(fs, 8)); } } @@ -167,7 +174,8 @@ public class MultiReleaseJarTest { return src.contains("return " + expected); } - @Test(dataProvider="strings") + @ParameterizedTest + @MethodSource("createStrings") public void testStrings(String value, int expected, String ignorable) throws Throwable { stringEnv.clear(); stringEnv.put(PROPERTY_RELEASE_VERSION, value); @@ -176,7 +184,8 @@ public class MultiReleaseJarTest { runTest(stringEnv, expected); } - @Test(dataProvider="integers") + @ParameterizedTest + @MethodSource("createIntegers") public void testIntegers(Integer value, int expected, Integer ignorable) throws Throwable { integerEnv.clear(); integerEnv.put(PROPERTY_RELEASE_VERSION, value); @@ -185,7 +194,8 @@ public class MultiReleaseJarTest { runTest(integerEnv, expected); } - @Test(dataProvider="versions") + @ParameterizedTest + @MethodSource("createVersions") public void testVersions(Version value, int expected, Version ignorable) throws Throwable { versionEnv.clear(); versionEnv.put(PROPERTY_RELEASE_VERSION, value); @@ -210,30 +220,34 @@ public class MultiReleaseJarTest { * @throws Throwable Exception thrown for anything other than the expected * IllegalArgumentException */ - @Test(dataProvider="invalidVersions") + @ParameterizedTest + @MethodSource("invalidVersions") public void testInvalidVersions(Map env) throws Throwable { - Assert.assertThrows(IllegalArgumentException.class, () -> + assertThrows(IllegalArgumentException.class, () -> FileSystems.newFileSystem(Path.of(userdir, "multi-release.jar"), env)); } // The following tests are for backwards compatibility to validate that // the original property still works - @Test(dataProvider="strings") + @ParameterizedTest + @MethodSource("createStrings") public void testMRStrings(String value, int expected, String ignorable) throws Throwable { stringEnv.clear(); stringEnv.put(PROPERTY_MULTI_RELEASE, value); runTest(stringEnv, expected); } - @Test(dataProvider="integers") + @ParameterizedTest + @MethodSource("createIntegers") public void testMRIntegers(Integer value, int expected, Integer ignorable) throws Throwable { integerEnv.clear(); integerEnv.put(PROPERTY_MULTI_RELEASE, value); runTest(integerEnv, expected); } - @Test(dataProvider="versions") + @ParameterizedTest + @MethodSource("createVersions") public void testMRVersions(Version value, int expected, Version ignorable) throws Throwable { versionEnv.clear(); versionEnv.put(PROPERTY_MULTI_RELEASE, value); @@ -250,7 +264,7 @@ public class MultiReleaseJarTest { byte [] bytes = Files.readAllBytes(version); Class vcls = (new ByteArrayClassLoader(fs)).defineClass(className, bytes); MethodHandle mh = MethodHandles.lookup().findVirtual(vcls, "getVersion", mt); - Assert.assertEquals((int)mh.invoke(vcls.getDeclaredConstructor().newInstance()), expected); + assertEquals(expected, (int)mh.invoke(vcls.getDeclaredConstructor().newInstance())); } } @@ -281,7 +295,7 @@ public class MultiReleaseJarTest { jb.build(); Map env = Map.of(PROPERTY_RELEASE_VERSION, "runtime"); try (FileSystem fs = FileSystems.newFileSystem(uri, env)) { - Assert.assertTrue(true); + assertTrue(true); } Files.delete(jfpath); } @@ -300,9 +314,9 @@ public class MultiReleaseJarTest { URI customJar = new URI("jar", ssp , null); try (FileSystem fs = FileSystems.newFileSystem(customJar, env)) { if (expected) { - Assert.assertTrue(readAndCompare(fs, MAJOR_VERSION)); + assertTrue(readAndCompare(fs, MAJOR_VERSION)); } else { - Assert.assertTrue(readAndCompare(fs, 8)); + assertTrue(readAndCompare(fs, 8)); } } Files.delete(filePath); diff --git a/test/jdk/jdk/nio/zipfs/testng/TEST.properties b/test/jdk/jdk/nio/zipfs/testng/TEST.properties deleted file mode 100644 index f069323c2f9..00000000000 --- a/test/jdk/jdk/nio/zipfs/testng/TEST.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Zip FS unit tests uses TestNG -modules = jdk.zipfs -TestNG.dirs = . - diff --git a/test/jdk/jdk/nio/zipfs/testng/util/ZipFsBaseTest.java b/test/jdk/jdk/nio/zipfs/util/ZipFsBaseTest.java similarity index 80% rename from test/jdk/jdk/nio/zipfs/testng/util/ZipFsBaseTest.java rename to test/jdk/jdk/nio/zipfs/util/ZipFsBaseTest.java index 6686ff0e920..1e6e1a385b1 100644 --- a/test/jdk/jdk/nio/zipfs/testng/util/ZipFsBaseTest.java +++ b/test/jdk/jdk/nio/zipfs/util/ZipFsBaseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,7 +23,7 @@ */ package util; -import org.testng.annotations.DataProvider; +import org.junit.jupiter.params.provider.Arguments; import java.io.File; import java.io.IOException; @@ -34,7 +34,6 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.security.SecureRandom; -import java.util.Arrays; import java.util.Comparator; import java.util.Map; import java.util.stream.Stream; @@ -43,7 +42,9 @@ import java.util.zip.ZipFile; import static java.lang.String.format; import static java.util.stream.Collectors.joining; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ZipFsBaseTest { @@ -53,49 +54,46 @@ public class ZipFsBaseTest { private static final SecureRandom random = new SecureRandom(); /** - * DataProvider used to specify the Zip FS properties to use when creating + * MethodSource used to specify the Zip FS properties to use when creating * the Zip File along with the compression method used * * @return Zip FS properties and compression method used by the tests */ - @DataProvider(name = "zipfsMap") - protected Object[][] zipfsMap() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED} - }; + protected static Stream zipfsMap() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED) + ); } /* - * DataProvider used to verify that an entry can be copied or moved within + * MethodSource used to verify that an entry can be copied or moved within * a Zip file system using a different compression from when the entry * was first created */ - @DataProvider(name = "copyMoveMap") - protected Object[][] copyMoveMap() { - return new Object[][]{ - {Map.of("create", "true"), ZipEntry.DEFLATED, ZipEntry.STORED}, - {Map.of("create", "true", "noCompression", "true"), - ZipEntry.STORED, ZipEntry.DEFLATED}, - {Map.of("create", "true", "noCompression", "false"), - ZipEntry.DEFLATED, ZipEntry.STORED} - }; + protected static Stream copyMoveMap() { + return Stream.of( + Arguments.of(Map.of("create", "true"), ZipEntry.DEFLATED, ZipEntry.STORED), + Arguments.of(Map.of("create", "true", "noCompression", "true"), + ZipEntry.STORED, ZipEntry.DEFLATED), + Arguments.of(Map.of("create", "true", "noCompression", "false"), + ZipEntry.DEFLATED, ZipEntry.STORED) + ); } /** - * DataProvider with the compression methods to be used for a given test run + * MethodSource with the compression methods to be used for a given test run * * @return Compression methods to test with */ - @DataProvider(name = "compressionMethods") - protected Object[][] compressionMethods() { - return new Object[][]{ - {ZipEntry.DEFLATED}, - {ZipEntry.STORED} - }; + protected static Stream compressionMethods() { + return Stream.of( + Arguments.of(ZipEntry.DEFLATED), + Arguments.of(ZipEntry.STORED) + ); } /** @@ -137,7 +135,7 @@ public class ZipFsBaseTest { // check entries with Zip API try (ZipFile zf = new ZipFile(zipfile.toFile())) { // check entry count - assertEquals(entries.length, zf.size()); + assertEquals(zf.size(), entries.length); // Check compression method and content of each entry for (Entry e : entries) { @@ -147,7 +145,7 @@ public class ZipFsBaseTest { System.out.printf("Entry Name: %s, method: %s, Expected Method: %s%n", e.name, ze.getMethod(), e.method); } - assertEquals(e.method, ze.getMethod()); + assertEquals(ze.getMethod(), e.method); try (InputStream in = zf.getInputStream(ze)) { byte[] bytes = in.readAllBytes(); if (DEBUG) { @@ -155,7 +153,7 @@ public class ZipFsBaseTest { new String(bytes), new String(e.bytes)); } - assertTrue(Arrays.equals(bytes, e.bytes)); + assertArrayEquals(bytes, e.bytes); } } } @@ -166,7 +164,7 @@ public class ZipFsBaseTest { Path top = fs.getPath("/"); long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) -> attrs.isRegularFile()).count(); - assertEquals(entries.length, count); + assertEquals(count, entries.length); // Check content of each entry for (Entry e : entries) { @@ -175,7 +173,7 @@ public class ZipFsBaseTest { System.out.printf("Entry name = %s, bytes= %s, actual=%s%n", e.name, new String(Files.readAllBytes(file)), new String(e.bytes)); } - assertEquals(Files.readAllBytes(file), e.bytes); + assertArrayEquals(e.bytes, Files.readAllBytes(file)); } } } @@ -189,7 +187,7 @@ public class ZipFsBaseTest { * @param source The path of the file to add to the Zip File * @throws IOException If an error occurs while creating/updating the Zip file */ - protected void zip(Path zipFile, Map env, Path source) throws IOException { + protected static void zip(Path zipFile, Map env, Path source) throws IOException { if (DEBUG) { System.out.printf("File:%s, adding:%s%n", zipFile.toAbsolutePath(), source); } @@ -208,7 +206,7 @@ public class ZipFsBaseTest { * @param entries The entries to add to the Zip File * @throws IOException If an error occurs while creating the Zip file */ - protected void zip(Path zipFile, Map env, + protected static void zip(Path zipFile, Map env, Entry... entries) throws IOException { if (DEBUG) { System.out.printf("Creating file: %s, env: %s%n", zipFile, formatMap(env)); diff --git a/test/jdk/sun/java2d/OpenGL/FlipCoexistTest.java b/test/jdk/sun/java2d/OpenGL/FlipCoexistTest.java new file mode 100644 index 00000000000..beb5da887b4 --- /dev/null +++ b/test/jdk/sun/java2d/OpenGL/FlipCoexistTest.java @@ -0,0 +1,134 @@ +/* + * Copyright Amazon.com Inc. 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.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferStrategy; +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; + +/** + * @test + * @bug 8378201 + * @key headful + * @summary Verifies that WINDOW and FLIP_BACKBUFFER surfaces sharing the same X + * Window render and flip correctly + * @run main/othervm FlipCoexistTest + * @run main/othervm -Dsun.java2d.opengl=True FlipCoexistTest + */ +public final class FlipCoexistTest { + + private static final int SIZE = 200; + private static final int TOLERANCE = 10; + + public static void main(String[] args) throws Exception { + Frame f = new Frame("FlipCoexistTest"); + try { + f.setUndecorated(true); + f.setSize(SIZE, SIZE); + f.setLocation(100, 100); + f.setVisible(true); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + + int w = f.getWidth(); + int h = f.getHeight(); + + // Fill window RED via direct render (WINDOW surface) + Graphics g = f.getGraphics(); + g.setColor(Color.RED); + g.fillRect(0, 0, w, h); + g.dispose(); + robot.waitForIdle(); + robot.delay(500); + + // Request flip if available, blit is also useful to cover + f.createBufferStrategy(2); + BufferStrategy bs = f.getBufferStrategy(); + + // Render BLUE to back buffer, do not flip yet + Graphics bg = bs.getDrawGraphics(); + bg.setColor(Color.BLUE); + bg.fillRect(0, 0, w, h); + bg.dispose(); + + // Paint small GREEN rect via direct render + g = f.getGraphics(); + g.setColor(Color.GREEN); + g.fillRect(0, 0, 10, 10); + g.dispose(); + robot.waitForIdle(); + robot.delay(500); + + // GREEN rect must be visible + check(robot, f, 5, 5, Color.GREEN, "small rect"); + + // RED must survive the context round-trip + check(robot, f, w / 2, h / 2, Color.RED, "survived"); + + // Show back buffer, BLUE must appear + bs.show(); + + robot.waitForIdle(); + robot.delay(500); + check(robot, f, w / 2, h / 2, Color.BLUE, "flip"); + } finally { + f.dispose(); + } + } + + private static void check(Robot robot, Frame frame, int x, int y, Color exp, + String desc) + { + Point loc = frame.getLocationOnScreen(); + Color c = robot.getPixelColor(loc.x + x, loc.y + y); + if (!isAlmostEqual(c, exp)) { + saveImage(robot, frame, desc); + throw new RuntimeException("%s: %s != %s".formatted(desc, exp, c)); + } + } + + private static void saveImage(Robot r, Frame f, String name) { + try { + Rectangle rect = f.getBounds(); + BufferedImage img = r.createScreenCapture(rect); + ImageIO.write(img, "png", new File(name + ".png")); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static boolean isAlmostEqual(Color c1, Color c2) { + return Math.abs(c1.getRed() - c2.getRed()) <= TOLERANCE + && Math.abs(c1.getGreen() - c2.getGreen()) <= TOLERANCE + && Math.abs(c1.getBlue() - c2.getBlue()) <= TOLERANCE; + } +} diff --git a/test/jdk/sun/java2d/OpenGL/MultiWindowFillTest.java b/test/jdk/sun/java2d/OpenGL/MultiWindowFillTest.java new file mode 100644 index 00000000000..59c58d944d7 --- /dev/null +++ b/test/jdk/sun/java2d/OpenGL/MultiWindowFillTest.java @@ -0,0 +1,122 @@ +/* + * Copyright Amazon.com Inc. 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.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; + +/** + * @test + * @bug 8378201 + * @key headful + * @summary Verifies that window content survives a GL context switch to another + * window and back + * @run main/othervm MultiWindowFillTest + * @run main/othervm -Dsun.java2d.opengl=True MultiWindowFillTest + */ +public final class MultiWindowFillTest { + + private static final int SIZE = 100; + private static final int TOLERANCE = 10; + + public static void main(String[] args) throws Exception { + Frame f1 = new Frame("f1"); + Frame f2 = new Frame("f2"); + try { + f1.setUndecorated(true); + f1.setSize(SIZE, SIZE); + f1.setLocation(100, 100); + f2.setUndecorated(true); + f2.setSize(SIZE, SIZE); + f2.setLocation(300, 100); + + f1.setVisible(true); + f2.setVisible(true); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + + int w = f1.getWidth(); + int h = f1.getHeight(); + + // Fill both, initializes surfaces + fill(f1, Color.RED, w, h); + fill(f2, Color.BLUE, w, h); + + // Touch both again + fill(f1, Color.RED, 2, 2); + fill(f2, Color.BLUE, 2, 2); + + robot.waitForIdle(); + robot.delay(1000); + + check(robot, f1, w, h, Color.RED, "f1 red"); + check(robot, f2, w, h, Color.BLUE, "f2 blue"); + } finally { + f1.dispose(); + f2.dispose(); + } + } + + private static void fill(Frame frame, Color c, int w, int h) { + Graphics g = frame.getGraphics(); + g.setColor(c); + g.fillRect(0, 0, w, h); + g.dispose(); + } + + private static void check(Robot robot, Frame frame, int w, int h, + Color exp, String desc) + { + Point loc = frame.getLocationOnScreen(); + Color c = robot.getPixelColor(loc.x + w / 2, loc.y + h / 2); + if (!isAlmostEqual(c, exp)) { + saveImage(robot, frame, desc); + throw new RuntimeException("%s: %s != %s".formatted(desc, exp, c)); + } + } + + private static void saveImage(Robot r, Frame f, String name) { + try { + Rectangle rect = f.getBounds(); + BufferedImage img = r.createScreenCapture(rect); + ImageIO.write(img, "png", new File(name + ".png")); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static boolean isAlmostEqual(Color c1, Color c2) { + return Math.abs(c1.getRed() - c2.getRed()) <= TOLERANCE + && Math.abs(c1.getGreen() - c2.getGreen()) <= TOLERANCE + && Math.abs(c1.getBlue() - c2.getBlue()) <= TOLERANCE; + } +} diff --git a/test/jdk/sun/net/www/protocol/jar/JarURLConnectionCertsAndCodeSigners.java b/test/jdk/sun/net/www/protocol/jar/JarURLConnectionCertsAndCodeSigners.java new file mode 100644 index 00000000000..9b786938e10 --- /dev/null +++ b/test/jdk/sun/net/www/protocol/jar/JarURLConnectionCertsAndCodeSigners.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2026, 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.io.InputStream; +import java.io.OutputStream; +import java.net.JarURLConnection; +import java.net.URI; +import java.net.URLConnection; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.CodeSigner; +import java.security.KeyStore; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.zip.ZipFile; + +import jdk.security.jarsigner.JarSigner; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import sun.security.tools.keytool.CertAndKeyGen; +import sun.security.x509.X500Name; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; + +/* + * @test + * @bug 8378003 + * @summary Verify that JarURLConnection.getCertificates() and + * JarURLConnection.getJarEntry().getCodeSigners() returns the + * expected results for entries in a signed JAR file + * @modules java.base/sun.security.x509 + * java.base/sun.security.tools.keytool + * @run junit ${test.main.class} + */ +class JarURLConnectionCertsAndCodeSigners { + + private static final String JAR_ENTRY_NAME = "foo-bar"; + private static final String CERT_SUBJECT = "CN=duke"; + private static Path SIGNED_JAR; + + @BeforeAll + static void beforeAll() throws Exception { + final KeyStore.PrivateKeyEntry key = generatePrivateKey(); + SIGNED_JAR = createSignedJar(key); + } + + /* + * Verifies that JarURLConnection.getCertificates() returns the correct + * certificates for entries in a signed JAR file. + */ + @Test + void testCertificates() throws Exception { + final URI uri = new URI("jar:" + SIGNED_JAR.toUri() + "!/" + JAR_ENTRY_NAME); + System.err.println("running test against signed JAR entry: " + uri); + final URLConnection urlConn = uri.toURL().openConnection(); + assertInstanceOf(JarURLConnection.class, urlConn, "unexpected URLConnection type"); + final JarURLConnection jarURLConn = (JarURLConnection) urlConn; + try (InputStream is = jarURLConn.getInputStream()) { + is.readAllBytes(); + } + Certificate[] prevIterationCerts = null; + for (int i = 1; i <= 2; i++) { + final Certificate[] certs = jarURLConn.getCertificates(); + assertNotNull(certs, "null certificates for signed JAR entry: " + uri); + assertNotEquals(0, certs.length, "empty certificates for signed JAR entry: " + uri); + assertInstanceOf(X509Certificate.class, certs[0], "unexpected certificate type"); + final String subject = ((X509Certificate) certs[0]).getSubjectX500Principal().getName(); + assertEquals(CERT_SUBJECT, subject, "unexpected subject in certificate"); + if (i > 1) { + // verify that each call to getCertificates() returns + // a new instance of the array. + // intentional identity check + assertNotSame(prevIterationCerts, certs, "getCertificates() did not return" + + " a new array"); + } + prevIterationCerts = certs; + } + } + + /* + * Verifies that JarURLConnection.getJarEntry().getCodeSigners() returns the correct + * codesigners for entries in a signed JAR file. + */ + @Test + void testCodeSigners() throws Exception { + final URI uri = new URI("jar:" + SIGNED_JAR.toUri() + "!/" + JAR_ENTRY_NAME); + System.err.println("running test against signed JAR entry: " + uri); + final URLConnection urlConn = uri.toURL().openConnection(); + assertInstanceOf(JarURLConnection.class, urlConn, "unexpected URLConnection type"); + final JarURLConnection jarURLConn = (JarURLConnection) urlConn; + try (InputStream is = jarURLConn.getInputStream()) { + is.readAllBytes(); + } + CodeSigner[] prevIterationCodeSigners = null; + for (int i = 1; i <= 2; i++) { + final CodeSigner[] codeSigners = jarURLConn.getJarEntry().getCodeSigners(); + assertNotNull(codeSigners, "null codesigners for signed JAR entry: " + uri); + assertNotEquals(0, codeSigners.length, "empty codesigners for signed JAR entry: " + uri); + final List certs = codeSigners[0].getSignerCertPath().getCertificates(); + assertNotNull(certs, "null certificates from codesigner"); + assertNotEquals(0, certs.size(), "empty certificates from codesigner"); + assertInstanceOf(X509Certificate.class, certs.getFirst(), "unexpected certificate type"); + final String subject = ((X509Certificate) certs.getFirst()).getSubjectX500Principal().getName(); + assertEquals(CERT_SUBJECT, subject, "unexpected subject in certificate"); + if (i > 1) { + // verify that each call to getCodeSigners() returns + // a new instance of the array. + // intentional identity check + assertNotSame(prevIterationCodeSigners, codeSigners, "getCodeSigners() did not" + + " return a new array"); + } + prevIterationCodeSigners = codeSigners; + } + } + + private static KeyStore.PrivateKeyEntry generatePrivateKey() throws Exception { + final CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); + gen.generate(1048); // Small key size makes test run faster + final long oneDay = TimeUnit.DAYS.toSeconds(1); + final Certificate cert = gen.getSelfCertificate(new X500Name(CERT_SUBJECT), oneDay); + return new KeyStore.PrivateKeyEntry(gen.getPrivateKey(), new Certificate[]{cert}); + } + + private static Path createSignedJar(final KeyStore.PrivateKeyEntry privateKey) + throws Exception { + + // first create a unsigned JAR + final Path unsignedJar = Path.of("test-8377985-unsigned.jar"); + final Manifest manifest = new Manifest(); + final Attributes mainAttributes = manifest.getMainAttributes(); + mainAttributes.putValue("Manifest-Version", "1.0"); + try (OutputStream os = Files.newOutputStream(unsignedJar); + JarOutputStream jaros = new JarOutputStream(os, manifest)) { + jaros.putNextEntry(new JarEntry(JAR_ENTRY_NAME)); + jaros.write(new byte[]{0x42}); + jaros.closeEntry(); + } + + // use a JarSigner to sign the JAR + final JarSigner signer = new JarSigner.Builder(privateKey) + .signerName("abcdef") + .digestAlgorithm("SHA-256") + .signatureAlgorithm("SHA256withRSA") + .build(); + + final Path signedJar = Path.of("test-8377985-signed.jar"); + try (ZipFile zip = new ZipFile(unsignedJar.toFile()); + OutputStream out = Files.newOutputStream(signedJar)) { + signer.sign(zip, out); + } + return signedJar; + } +} diff --git a/test/jdk/sun/nio/cs/StreamEncoderOut.java b/test/jdk/sun/nio/cs/StreamEncoderOut.java index 90a22512311..90b4aee838d 100644 --- a/test/jdk/sun/nio/cs/StreamEncoderOut.java +++ b/test/jdk/sun/nio/cs/StreamEncoderOut.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,8 @@ /* @test @bug 8030179 @summary test if the charset encoder deails with surrogate correctly - * @run testng/othervm -esa StreamEncoderOut + * @run junit/othervm -esa StreamEncoderOut */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.io.OutputStream; @@ -35,9 +33,12 @@ import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import static java.util.stream.Collectors.joining; -@Test public class StreamEncoderOut { enum Input { @@ -57,14 +58,11 @@ public class StreamEncoderOut { } } - @DataProvider(name = "CharsetAndString") - // [Charset, Input] - public static Object[][] makeStreamTestData() { + public static Stream makeStreamTestData() { // Cross product of supported charsets and inputs - return Charset.availableCharsets().values().stream(). - filter(Charset::canEncode). - flatMap(cs -> Stream.of(Input.values()).map(i -> new Object[]{cs, i})). - toArray(Object[][]::new); + return Charset.availableCharsets().values().stream() + .filter(Charset::canEncode) + .flatMap(cs -> Stream.of(Input.values()).map(i -> Arguments.of(cs, i))); } private static String generate(String s, int n) { @@ -79,7 +77,8 @@ public class StreamEncoderOut { public void write(int b) throws IOException {} }; - @Test(dataProvider = "CharsetAndString") + @ParameterizedTest + @MethodSource("makeStreamTestData") public void test(Charset cs, Input input) throws IOException { OutputStreamWriter w = new OutputStreamWriter(DEV_NULL, cs); String t = generate(input.value, 8193); diff --git a/test/jdk/sun/nio/cs/TestStringCoding.java b/test/jdk/sun/nio/cs/TestStringCoding.java index d708ef180a2..b81ffb07d20 100644 --- a/test/jdk/sun/nio/cs/TestStringCoding.java +++ b/test/jdk/sun/nio/cs/TestStringCoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 6636323 6636319 7040220 7096080 7183053 8080248 8054307 + * @bug 6636323 6636319 7040220 7096080 7183053 8080248 8054307 8372353 * @summary Test if StringCoding and NIO result have the same de/encoding result * @library /test/lib * @modules java.base/sun.nio.cs @@ -169,6 +169,12 @@ public class TestStringCoding { if (!Arrays.equals(baSC, baNIO)) { throw new RuntimeException("getBytes(cs) failed -> " + cs.name()); } + //encodedLength(cs); + int encodedLength = str.encodedLength(cs); + if (baSC.length != encodedLength) { + throw new RuntimeException(String.format("encodedLength failed (%d != %d) -> %s", + baSC.length, encodedLength, cs.name())); + } return baSC; } diff --git a/test/jdk/sun/nio/cs/TestUnicodeReversedBOM.java b/test/jdk/sun/nio/cs/TestUnicodeReversedBOM.java index d76bf2f6034..ca0798c13e5 100644 --- a/test/jdk/sun/nio/cs/TestUnicodeReversedBOM.java +++ b/test/jdk/sun/nio/cs/TestUnicodeReversedBOM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,16 +26,18 @@ * @bug 8216140 * @summary Test reversed BOM (U+FFFE) in the middle of a byte buffer * passes through during decoding with UnicodeDecoder. - * @run testng TestUnicodeReversedBOM + * @run junit TestUnicodeReversedBOM */ + import java.nio.charset.*; import java.nio.*; import java.util.*; +import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@Test public class TestUnicodeReversedBOM { private static byte[] A_REVERSED_BE = {(byte)0x0, (byte)'A', (byte)0xff, (byte)0xfe}; @@ -46,26 +48,25 @@ public class TestUnicodeReversedBOM { private static byte[] BOM_REVERSED_LE = {(byte)0xff, (byte)0xfe, (byte)0xfe, (byte)0xff}; - @DataProvider - // [(byte[])byte array, (Charset)cs] - public static Object[][] ReversedBOM() { - return new Object[][] { - {A_REVERSED_BE, StandardCharsets.UTF_16}, - {A_REVERSED_LE, StandardCharsets.UTF_16}, - {A_REVERSED_BE, StandardCharsets.UTF_16BE}, - {A_REVERSED_LE, StandardCharsets.UTF_16BE}, - {A_REVERSED_BE, StandardCharsets.UTF_16LE}, - {A_REVERSED_LE, StandardCharsets.UTF_16LE}, - {BOM_REVERSED_BE, StandardCharsets.UTF_16}, - {BOM_REVERSED_LE, StandardCharsets.UTF_16}, - {BOM_REVERSED_BE, StandardCharsets.UTF_16BE}, - {BOM_REVERSED_LE, StandardCharsets.UTF_16BE}, - {BOM_REVERSED_BE, StandardCharsets.UTF_16LE}, - {BOM_REVERSED_LE, StandardCharsets.UTF_16LE}, - }; + public static Stream ReversedBOM() { + return Stream.of( + Arguments.of(A_REVERSED_BE, StandardCharsets.UTF_16), + Arguments.of(A_REVERSED_LE, StandardCharsets.UTF_16), + Arguments.of(A_REVERSED_BE, StandardCharsets.UTF_16BE), + Arguments.of(A_REVERSED_LE, StandardCharsets.UTF_16BE), + Arguments.of(A_REVERSED_BE, StandardCharsets.UTF_16LE), + Arguments.of(A_REVERSED_LE, StandardCharsets.UTF_16LE), + Arguments.of(BOM_REVERSED_BE, StandardCharsets.UTF_16), + Arguments.of(BOM_REVERSED_LE, StandardCharsets.UTF_16), + Arguments.of(BOM_REVERSED_BE, StandardCharsets.UTF_16BE), + Arguments.of(BOM_REVERSED_LE, StandardCharsets.UTF_16BE), + Arguments.of(BOM_REVERSED_BE, StandardCharsets.UTF_16LE), + Arguments.of(BOM_REVERSED_LE, StandardCharsets.UTF_16LE) + ); } - @Test(dataProvider = "ReversedBOM") + @ParameterizedTest + @MethodSource("ReversedBOM") public void testReversedBOM(byte[] ba, Charset cs) throws CharacterCodingException { cs.newDecoder() .onMalformedInput(CodingErrorAction.REPORT) diff --git a/test/jdk/sun/security/ec/xec/TestXDH.java b/test/jdk/sun/security/ec/xec/TestXDH.java index a32da875fa5..30c3b433406 100644 --- a/test/jdk/sun/security/ec/xec/TestXDH.java +++ b/test/jdk/sun/security/ec/xec/TestXDH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,20 +23,32 @@ /* * @test - * @bug 8171277 8206915 + * @bug 8171277 8206915 8368841 * @summary Test XDH key agreement * @library /test/lib - * @build jdk.test.lib.Convert * @run main TestXDH */ -import java.security.*; -import java.security.spec.*; -import javax.crypto.*; +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.InvalidParameterException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PublicKey; +import java.security.PrivateKey; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.security.spec.NamedParameterSpec; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.security.spec.XECPublicKeySpec; +import java.security.spec.XECPrivateKeySpec; +import javax.crypto.KeyAgreement; import java.util.Arrays; import java.util.HexFormat; -import jdk.test.lib.Convert; import jdk.test.lib.hexdump.ASN1Formatter; import jdk.test.lib.hexdump.HexPrinter; @@ -354,7 +366,6 @@ public class TestXDH { throw new RuntimeException("fail: expected=" + result + ", actual=" + HexFormat.of().withUpperCase().formatHex(sharedSecret)); } - } private static void runDiffieHellmanTest(String curveName, String a_pri, @@ -365,9 +376,8 @@ public class TestXDH { KeySpec privateSpec = new XECPrivateKeySpec(paramSpec, HexFormat.of().parseHex(a_pri)); PrivateKey privateKey = kf.generatePrivate(privateSpec); - boolean clearHighBit = curveName.equals("X25519"); KeySpec publicSpec = new XECPublicKeySpec(paramSpec, - Convert.hexStringToBigInteger(clearHighBit, b_pub)); + hexStringToBigInteger(b_pub)); PublicKey publicKey = kf.generatePublic(publicSpec); byte[] encodedPrivateKey = privateKey.getEncoded(); @@ -394,6 +404,21 @@ public class TestXDH { } } + /* + * Converts a hexidecimal string to the corresponding little-endian + * number as a BigInteger + */ + private static BigInteger hexStringToBigInteger(String str) { + BigInteger result = BigInteger.ZERO; + for (int i = 0; i < str.length() / 2; i++) { + int curVal = Character.digit(str.charAt(2 * i), 16); + curVal <<= 4; + curVal += Character.digit(str.charAt(2 * i + 1), 16); + result = result.add(BigInteger.valueOf(curVal).shiftLeft(8 * i)); + } + return result; + } + /* * Ensure that SunEC rejects parameters/points for the wrong curve * when the algorithm ID for a specific curve is specified. diff --git a/test/jdk/sun/security/ec/xec/TestXECOps.java b/test/jdk/sun/security/ec/xec/TestXECOps.java index cdbcf95fc0b..a7533b89c02 100644 --- a/test/jdk/sun/security/ec/xec/TestXECOps.java +++ b/test/jdk/sun/security/ec/xec/TestXECOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,9 @@ * @run main TestXECOps */ -import sun.security.ec.*; - +import sun.security.ec.XECOperations; +import sun.security.ec.XECParameters; +import java.math.BigInteger; import java.security.spec.NamedParameterSpec; import java.util.*; import jdk.test.lib.Convert; @@ -93,6 +94,7 @@ public class TestXECOps { XECParameters.get(RuntimeException::new, paramSpec); XECOperations ops = new XECOperations(settings); + // Test encodedPointMultiply(byte[] k, byte[] u) byte[] basePoint = Convert.byteToByteArray(settings.getBasePoint(), settings.getBytes()); byte[] a = HexFormat.of().parseHex(a_str); @@ -101,18 +103,29 @@ public class TestXECOps { byte[] a_copy = Arrays.copyOf(a, a.length); byte[] b_copy = Arrays.copyOf(b, b.length); - byte[] basePoint_copy = Arrays.copyOf(basePoint, basePoint.length); byte[] resultA = ops.encodedPointMultiply(b, ops.encodedPointMultiply(a, basePoint)); byte[] resultB = ops.encodedPointMultiply(a_copy, - ops.encodedPointMultiply(b_copy, basePoint_copy)); + ops.encodedPointMultiply(b_copy, basePoint)); if (!Arrays.equals(resultA, expectedResult)) { throw new RuntimeException("fail"); } if (!Arrays.equals(resultB, expectedResult)) { throw new RuntimeException("fail"); } + + // Test encodedPointMultiply(byte[] k, BigInteger u) + reverse(basePoint); + BigInteger bp = new BigInteger(1, basePoint); + byte[] c = HexFormat.of().parseHex(a_str); + byte[] d = HexFormat.of().parseHex(b_str); + + byte[] res0 = ops.encodedPointMultiply(d, + ops.encodedPointMultiply(c, bp)); + if (!Arrays.equals(res0, expectedResult)) { + throw new RuntimeException("bigint fail"); + } } private void runTest(String opName, String k_in_str, @@ -125,12 +138,31 @@ public class TestXECOps { NamedParameterSpec paramSpec = new NamedParameterSpec(opName); XECParameters settings = XECParameters.get(RuntimeException::new, paramSpec); - XECOperations ops = new XECOperations(settings); - byte[] u_out = ops.encodedPointMultiply(k_in, u_in); - if (!Arrays.equals(u_out, u_out_expected)) { + // Test encodedPointMultiply(byte[] k, byte[] u) + XECOperations ops = new XECOperations(settings); + byte[] res0 = ops.encodedPointMultiply(k_in, u_in); + + if (!Arrays.equals(res0, u_out_expected)) { throw new RuntimeException("fail"); } + + // Test encodedPointMultiply(byte[] k, BigInteger u) + reverse(u_in); + BigInteger u = new BigInteger(1, u_in); + byte[] res1 = ops.encodedPointMultiply(k_in, u); + + if (!Arrays.equals(res1, u_out_expected)) { + throw new RuntimeException("fail"); + } + } + + private static void reverse(byte[] array) { + for (int i = 0; i < array.length / 2; i++) { + byte temp = array[i]; + array[i] = array[array.length - i - 1]; + array[array.length - i - 1] = temp; + } } } diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java b/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java index ebd2c1c3436..4c9ab1faf81 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6687725 + * @bug 6687725 8365883 * @summary Test internal PKCS5Padding impl with various error conditions. * @author Valerie Peng * @library /test/lib .. @@ -35,6 +35,7 @@ import java.security.AlgorithmParameters; import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.security.Security; +import java.util.Arrays; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; @@ -80,7 +81,7 @@ public class TestPKCS5PaddingError extends PKCS11Test { private void doTest(final Provider p) throws Exception { try { - byte[] plainText = new byte[200]; + byte[] plainText = "testtexttesttext".getBytes(); // 16 bytes text for (CI currTest : TEST_LIST) { System.out.println("===" + currTest.transformation + "==="); @@ -88,14 +89,16 @@ public class TestPKCS5PaddingError extends PKCS11Test { KeyGenerator kg = KeyGenerator.getInstance(currTest.keyAlgo, p); SecretKey key = kg.generateKey(); - Cipher c1 = Cipher.getInstance(currTest.transformation, + // Encrypting without padding to guarantee bad padding + // exception when decrypting + Cipher c1 = Cipher.getInstance(currTest.transformation + .replace("/PKCS5Padding", "/NoPadding"), sunJCEProvider); c1.init(Cipher.ENCRYPT_MODE, key); byte[] cipherText = c1.doFinal(plainText); AlgorithmParameters params = c1.getParameters(); Cipher c2 = Cipher.getInstance(currTest.transformation, p); c2.init(Cipher.DECRYPT_MODE, key, params); - c2.doFinal(cipherText); // 1st test: wrong output length // NOTE: Skip NSS since it reports CKR_DEVICE_ERROR when the @@ -118,9 +121,17 @@ public class TestPKCS5PaddingError extends PKCS11Test { // 2nd test: wrong padding value try { System.out.println("Testing with wrong padding bytes"); - cipherText[cipherText.length - 1]++; - c2.doFinal(cipherText); - System.out.println("WARNING: Expected BPE NOT thrown"); + byte[] result = c2.doFinal(cipherText); + + final String errorDescription = + "Decrypted text " + Arrays.toString(result); + if (Arrays.equals(result, plainText)) { + System.out.println("WARNING: initial text and " + + "decoded text are the same"); + } + System.out.println(errorDescription); + throw new RuntimeException( + "Expected BPE NOT thrown \n" + errorDescription); } catch (BadPaddingException bpe) { // expected } catch (Exception ex) { diff --git a/test/jdk/sun/security/provider/acvp/ML_DSA_Test.java b/test/jdk/sun/security/provider/acvp/ML_DSA_Test.java index ac56642b8d7..f76f3d8b9a8 100644 --- a/test/jdk/sun/security/provider/acvp/ML_DSA_Test.java +++ b/test/jdk/sun/security/provider/acvp/ML_DSA_Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -88,13 +88,13 @@ public class ML_DSA_Test { for (var t : kat.get("testGroups").asArray()) { var pname = t.get("parameterSet").asString(); System.out.println(">> " + pname + " sign"); - var det = Boolean.parseBoolean(t.get("deterministic").asString()); + var det = t.get("deterministic").asBoolean(); if (t.get("signatureInterface").asString().equals("internal")) { ML_DSA_Impls.version = ML_DSA_Impls.Version.DRAFT; } else { ML_DSA_Impls.version = ML_DSA_Impls.Version.FINAL; } - if (t.get("externalMu").asString().equals("true")) { + if (t.get("externalMu").asBoolean()) { continue; // Not supported } for (var c : t.get("tests").asArray()) { @@ -139,7 +139,7 @@ public class ML_DSA_Test { ML_DSA_Impls.version = ML_DSA_Impls.Version.FINAL; } - if (t.get("externalMu").asString().equals("true")) { + if (t.get("externalMu").asBoolean()) { continue; // Not supported } @@ -157,7 +157,7 @@ public class ML_DSA_Test { public byte[] getEncoded() { return toByteArray(c.get("pk").asString()); } }; // Only ML-DSA sigVer has negative tests - var expected = Boolean.parseBoolean(c.get("testPassed").asString()); + var expected = c.get("testPassed").asBoolean(); var actual = true; try { s.initVerify(pk); diff --git a/test/jdk/sun/security/provider/pqc/PrivateKeyEncodings.java b/test/jdk/sun/security/provider/pqc/PrivateKeyEncodings.java index 25060d0b74e..39183eb9881 100644 --- a/test/jdk/sun/security/provider/pqc/PrivateKeyEncodings.java +++ b/test/jdk/sun/security/provider/pqc/PrivateKeyEncodings.java @@ -26,7 +26,7 @@ * @bug 8347938 * @library /test/lib * @summary ensure ML-KEM and ML-DSA encodings consistent with - * draft-ietf-lamps-kyber-certificates-11 and RFC 9881 + * RFC 9935 and RFC 9881 * @modules java.base/com.sun.crypto.provider * java.base/sun.security.pkcs * java.base/sun.security.provider @@ -62,17 +62,17 @@ import java.util.stream.Collectors; public class PrivateKeyEncodings { public static void main(String[] args) throws Exception { - // Example keys and certificates draft-ietf-lamps-kyber-certificates-11, Appendix B - // (https://datatracker.ietf.org/doc/html/draft-ietf-lamps-kyber-certificates-11#autoid-17) - // and RFC 9881, Appendix C.3 - // (https://datatracker.ietf.org/doc/html/rfc9881#name-example-certificates) + // Example keys and certificates in RFC 9935, Appendix C + // (https://datatracker.ietf.org/doc/html/rfc9935#name-examples) + // and RFC 9881, Appendix C + // (https://datatracker.ietf.org/doc/html/rfc9881#name-examples) // // These data can be retrieved from the following GitHub releases: // https://github.com/lamps-wg/kyber-certificates/releases/tag/draft-ietf-lamps-kyber-certificates-11 // https://github.com/lamps-wg/dilithium-certificates/releases/tag/draft-ietf-lamps-dilithium-certificates-13 // // Although the release tags include "draft", these values are the - // same as those in the final RFC 9881. + // same as those in the final RFCs. try (var kemReader = RepositoryFileReader.of(RepositoryFileReader.KYBER_CERTIFICATES.class, "kyber-certificates-draft-ietf-lamps-kyber-certificates-11/"); var dsaReader = RepositoryFileReader.of(RepositoryFileReader.DILITHIUM_CERTIFICATES.class, diff --git a/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java b/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java new file mode 100644 index 00000000000..82314c31dcf --- /dev/null +++ b/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2026, 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 8379433 + * @summary Test expected DecapsulateException thrown by Hybrid KEM implementation + * @modules java.base/sun.security.ssl + * @run main/othervm TestHybrid +*/ +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Provider; +import java.util.Arrays; +import javax.crypto.DecapsulateException; +import javax.crypto.KEM; + +public class TestHybrid { + + public static void main(String[] args) throws Exception { + + Class clazz = Class.forName("sun.security.ssl.HybridProvider"); + Provider p = (Provider) clazz.getField("PROVIDER").get(null); + + String alg = "X25519MLKEM768"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(alg, p); + KeyPair kp = kpg.generateKeyPair(); + + KEM kem = KEM.getInstance(alg, p); + KEM.Encapsulator e = kem.newEncapsulator(kp.getPublic()); + KEM.Decapsulator d = kem.newDecapsulator(kp.getPrivate()); + + int secretSize = e.secretSize(); + KEM.Encapsulated enc = e.encapsulate(); + byte[] ciphertext = enc.encapsulation(); + + byte[] badCiphertext = Arrays.copyOf(ciphertext, + ciphertext.length - 1); + try { + d.decapsulate(badCiphertext, 0, secretSize, "Generic"); + throw new RuntimeException( + "Expected DecapsulateException not thrown"); + } catch (DecapsulateException expected) { + System.out.println("Expected DecapsulateException thrown"); + } + } +} diff --git a/test/jdk/sun/security/ssl/SSLLogger/DebugPropertyValuesTest.java b/test/jdk/sun/security/ssl/SSLLogger/DebugPropertyValuesTest.java index 77f585d6d55..59becf3b664 100644 --- a/test/jdk/sun/security/ssl/SSLLogger/DebugPropertyValuesTest.java +++ b/test/jdk/sun/security/ssl/SSLLogger/DebugPropertyValuesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +23,7 @@ /** * @test - * @bug 8350582 8340312 8369995 8044609 8372004 + * @bug 8350582 8340312 8369995 8044609 8372004 8371333 * @library /test/lib /javax/net/ssl/templates * @summary Correct the parsing of the ssl value in javax.net.debug * @run junit DebugPropertyValuesTest @@ -60,8 +60,8 @@ public class DebugPropertyValuesTest extends SSLSocketTemplate { "supported_versions")); debugMessages.put("handshake-expand", List.of("\"logger\".*: \"javax.net.ssl\",", - "\"specifics\" : \\[", - "\"message\".*: \"Produced ClientHello handshake message")); + "\"specifics\" : \\[", + "\"message\".*: \"Produced ClientHello handshake message")); debugMessages.put("keymanager", List.of("Choosing key:")); debugMessages.put("packet", List.of("Raw write")); debugMessages.put("plaintext", @@ -73,11 +73,13 @@ public class DebugPropertyValuesTest extends SSLSocketTemplate { debugMessages.put("session", List.of("Session initialized:")); debugMessages.put("ssl", List.of("jdk.tls.keyLimits:")); debugMessages.put("sslctx", - List.of("trigger seeding of SecureRandom")); + List.of("trigger seeding of SecureRandom", + // Available list should finish with this style + "TLS_EMPTY_RENEGOTIATION_INFO_SCSV]", + "Ignore disabled cipher suites for protocols: " + + "\\[TLSv1.3, TLSv1.2\\]")); debugMessages.put("trustmanager", List.of("adding as trusted certificates")); - debugMessages.put("verbose", - List.of("Ignore unsupported cipher suite:")); debugMessages.put("help", List.of("print this help message and exit", "verbose handshake message printing")); @@ -110,17 +112,16 @@ public class DebugPropertyValuesTest extends SSLSocketTemplate { Arguments.of(List.of("-Djavax.net.debug=all"), List.of("handshake", "keymanager", "packet", "plaintext", "record", "session", "ssl", - "sslctx", "trustmanager", "verbose")), + "sslctx", "trustmanager")), // ssl should print most details except verbose details Arguments.of(List.of("-Djavax.net.debug=ssl"), List.of("handshake", "keymanager", "record", "session", "ssl", - "sslctx", "trustmanager", "verbose")), + "sslctx", "trustmanager")), // allow expand option for more verbose output Arguments.of( List.of("-Djavax.net.debug=ssl,handshake,expand"), - List.of("handshake", "handshake-expand", - "ssl", "verbose")), + List.of("handshake", "handshake-expand", "ssl")), // filtering on record option, with expand Arguments.of(List.of("-Djavax.net.debug=ssl:record,expand"), List.of("record", "record-expand", "ssl")), @@ -142,12 +143,12 @@ public class DebugPropertyValuesTest extends SSLSocketTemplate { Arguments.of(List.of("-Djavax.net.debug=ssl,typo"), List.of("handshake", "keymanager", "record", "session", "ssl", - "sslctx", "trustmanager", "verbose")), + "sslctx", "trustmanager")), // ssltypo contains "ssl". Treat like "ssl" Arguments.of(List.of("-Djavax.net.debug=ssltypo"), List.of("handshake", "keymanager", "record", "session", "ssl", - "sslctx", "trustmanager", "verbose")), + "sslctx", "trustmanager")), // plaintext is valid for record option Arguments.of(List.of("-Djavax.net.debug=ssl:record:plaintext"), List.of("plaintext", "record", "ssl")), @@ -168,7 +169,7 @@ public class DebugPropertyValuesTest extends SSLSocketTemplate { List.of("handshake", "javax.net.debug.logger", "keymanager", "packet", "plaintext", "record", "session", "ssl", - "sslctx", "trustmanager", "verbose")) + "sslctx", "trustmanager")) ); } diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketReset.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketReset.java index 6b0f365edc7..64779facd26 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketReset.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketReset.java @@ -21,16 +21,14 @@ * questions. */ -// -// Please run in othervm mode. SunJSSE does not support dynamic system -// properties, no way to re-use system properties in samevm/agentvm mode. -// - /* * @test * @bug 8268965 * @summary Socket reset issue for TLS socket close - * @run main/othervm -Djdk.net.usePlainSocketImpl=true SSLSocketReset + * @comment The test uses SSLContext.getDefault(), so we use othervm to prevent + * usage of unexpected default SSLContext that might be set by some + * other test + * @run main/othervm SSLSocketReset */ import javax.net.ssl.*; diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java index e084bdd3367..dc0610ce8c8 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketSSLEngineCloseInbound.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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,6 +29,7 @@ /* * @test * @bug 8273553 8253368 + * @library /test/lib * @summary sun.security.ssl.SSLEngineImpl.closeInbound also has similar error * of JDK-8253368 * @run main/othervm SSLSocketSSLEngineCloseInbound TLSv1.3 @@ -79,12 +80,30 @@ * read() ... ChangeCipherSpec * read() ... Finished */ -import javax.net.ssl.*; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLEngineResult.*; -import java.io.*; -import java.net.*; -import java.security.*; -import java.nio.*; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManagerFactory; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.security.KeyStore; +import java.security.Security; +import java.util.concurrent.CountDownLatch; + +import jdk.test.lib.Utils; public class SSLSocketSSLEngineCloseInbound { @@ -124,6 +143,8 @@ public class SSLSocketSSLEngineCloseInbound { private ByteBuffer cTOs; // "reliable" transport client->server private ByteBuffer sTOc; // "reliable" transport server->client + private final CountDownLatch serverReadyLatch = new CountDownLatch(1); + /* * The following is to set up the keystores/trust material. */ @@ -224,7 +245,7 @@ public class SSLSocketSSLEngineCloseInbound { // server-side socket that will read try (Socket socket = serverSocket.accept()) { - socket.setSoTimeout(500); + socket.setSoTimeout((int)Utils.adjustTimeout(500)); InputStream is = socket.getInputStream(); OutputStream os = socket.getOutputStream(); @@ -289,6 +310,8 @@ public class SSLSocketSSLEngineCloseInbound { throw new Exception("Server session is not valid"); } + // Server signals client it has finished writing + serverReadyLatch.countDown(); return; } @@ -315,6 +338,8 @@ public class SSLSocketSSLEngineCloseInbound { } } } finally { + // Release the latch if an exception is thrown. + serverReadyLatch.countDown(); if (serverException != null) { if (clientException != null) { serverException.initCause(clientException); @@ -342,7 +367,8 @@ public class SSLSocketSSLEngineCloseInbound { public void run() { // client-side socket try (SSLSocket sslSocket = (SSLSocket)sslc.getSocketFactory(). - createSocket("localhost", port)) { + createSocket(InetAddress.getLoopbackAddress(), + port)) { clientSocket = sslSocket; OutputStream os = sslSocket.getOutputStream(); @@ -365,9 +391,9 @@ public class SSLSocketSSLEngineCloseInbound { throw new Exception("Client's session is not valid"); } - // Give server a chance to read before we shutdown via - // the try-with-resources block. - Thread.sleep(2000); + // Client waits for server to finish sending data + // before shutdown. + serverReadyLatch.await(); } catch (Exception e) { clientException = e; } diff --git a/test/jdk/sun/security/ssl/X509KeyManager/SelfSignedCertKeyType.java b/test/jdk/sun/security/ssl/X509KeyManager/SelfSignedCertKeyType.java new file mode 100644 index 00000000000..2395020de08 --- /dev/null +++ b/test/jdk/sun/security/ssl/X509KeyManager/SelfSignedCertKeyType.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2026, 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 static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNotNull; + +import java.math.BigInteger; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.X509ExtendedKeyManager; +import jdk.test.lib.security.CertificateBuilder; + +/* + * @test + * @bug 8379191 + * @summary SunX509KeyManagerImpl alias chooser methods returns null for EC_EC + * @modules java.base/sun.security.x509 + * java.base/sun.security.util + * @library /test/lib + * @run main SelfSignedCertKeyType SunX509 + * @run main SelfSignedCertKeyType PKIX + */ + +public class SelfSignedCertKeyType { + + private static final String CERT_ALIAS = "testalias"; + private static final String KEY_ALG = "EC"; + private static final String KEY_TYPE = "EC_EC"; + private static final String CERT_SIG_ALG = "SHA256withECDSA"; + + public static void main(String[] args) throws Exception { + if (args.length != 1) { + throw new RuntimeException("Wrong number of arguments"); + } + + X509ExtendedKeyManager km = getKeyManager(args[0]); + + String serverAlias = km.chooseServerAlias(KEY_TYPE, null, null); + String engineServerAlias = km.chooseEngineServerAlias( + KEY_TYPE, null, null); + String clientAlias = km.chooseClientAlias( + new String[]{KEY_TYPE}, null, null); + String engineClientAlias = km.chooseEngineClientAlias( + new String[]{KEY_TYPE}, null, null); + + for (String alias : new String[]{serverAlias, + engineServerAlias, clientAlias, engineClientAlias}) { + assertNotNull(alias); + assertEquals(CERT_ALIAS, normalizeAlias(alias)); + } + } + + // PKIX KeyManager adds a cache prefix to an alias. + private static String normalizeAlias(String alias) { + return alias.substring(alias.lastIndexOf(".") + 1); + } + + // Returns a KeyManager with a single self-signed certificate. + private static X509ExtendedKeyManager getKeyManager(String kmAlg) + throws Exception { + KeyPair caKeys = KeyPairGenerator.getInstance(KEY_ALG) + .generateKeyPair(); + X509Certificate trustedCert = createTrustedCert(caKeys); + + // create a key store + KeyStore ks = KeyStore.getInstance("PKCS12"); + ks.load(null, null); + + // import the trusted cert + ks.setCertificateEntry("TLS Signer", trustedCert); + + // generate certificate chain + Certificate[] chain = new Certificate[1]; + chain[0] = trustedCert; + + // import the key entry. + final char[] passphrase = "passphrase".toCharArray(); + ks.setKeyEntry(CERT_ALIAS, caKeys.getPrivate(), passphrase, chain); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(kmAlg); + kmf.init(ks, passphrase); + + return (X509ExtendedKeyManager) kmf.getKeyManagers()[0]; + } + + private static X509Certificate createTrustedCert(KeyPair caKeys) + throws Exception { + return new CertificateBuilder() + .setSubjectName("O=CA-Org, L=Some-City, ST=Some-State, C=US") + .setPublicKey(caKeys.getPublic()) + .setNotBefore( + Date.from(Instant.now().minus(1, ChronoUnit.HOURS))) + .setNotAfter(Date.from(Instant.now().plus(1, ChronoUnit.HOURS))) + .setSerialNumber(BigInteger.valueOf( + new SecureRandom().nextLong(1000000) + 1)) + .addSubjectKeyIdExt(caKeys.getPublic()) + .addAuthorityKeyIdExt(caKeys.getPublic()) + .addKeyUsageExt(new boolean[]{ + true, true, true, true, true, true, true}) + .addBasicConstraintsExt(true, true, 1) + .build(null, caKeys.getPrivate(), CERT_SIG_ALG); + } +} diff --git a/test/jdk/sun/security/util/HexDumpEncoderTests.java b/test/jdk/sun/security/util/HexDumpEncoderTests.java index 9ff08cdb192..53f9001ae7a 100644 --- a/test/jdk/sun/security/util/HexDumpEncoderTests.java +++ b/test/jdk/sun/security/util/HexDumpEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +27,10 @@ import sun.security.util.HexDumpEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.util.Arrays; /* @@ -38,7 +42,6 @@ import java.util.Arrays; */ public class HexDumpEncoderTests { - private static String[] getTestCommand(final String encoding) { return new String[]{ "--add-modules", "java.base", @@ -54,24 +57,34 @@ public class HexDumpEncoderTests { final var resultIso = ProcessTools.executeTestJava(testCommandIso); resultIso.shouldHaveExitValue(0); + final String latin1ResultFromFile = Files.readString( + Path.of("ISO-8859-1.txt")); - // This will take all available StandardCharsets and test them all comparing to the ISO_8859_1 - // Dome im parallel, as this is significantly faster + // This will take all available StandardCharsets and test them all + // comparing to the ISO_8859_1. + // Done im parallel, as this is significantly faster Arrays.stream(StandardCharsets.class.getDeclaredFields()) .parallel() .forEach(field -> { - if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { + if (java.lang.reflect.Modifier + .isStatic(field.getModifiers())) { try { - final var charset = (Charset) field.get(StandardCharsets.ISO_8859_1); // getting the charset to test + // getting the charset to test + final var charset = (Charset) field.get(null); - final var testCommand = getTestCommand(charset.name()); + final var testCommand = + getTestCommand(charset.name()); - final var result = ProcessTools.executeTestJava(testCommand); + final var result = + ProcessTools.executeTestJava(testCommand); result.shouldHaveExitValue(0); + final String resultFromFile = Files.readString( + Path.of(charset.name()+".txt")); - // The outputs of the ISO encoding must be identical to the one tested - Asserts.assertEquals(resultIso.getStdout(), - result.getStdout(), + // The outputs of the ISO encoding must be identical + // to the one tested + Asserts.assertEquals(latin1ResultFromFile, + resultFromFile, "Encoding " + charset.name()); } catch (Exception e) { throw new RuntimeException(e); @@ -86,14 +99,26 @@ public class HexDumpEncoderTests { * This will test the encode and encode buffer functions at once, * as they are both representing the string in LATIN_1 *

- * The output is put as a system.out + * The output is put to the file in scratch dir with corresponding + * encoding name */ public static void main(String[] args) throws Exception { final var encoder = new HexDumpEncoder(); - System.out.printf("\nCert Encoded With Encode Buffer: %s\n", encoder.encodeBuffer(new byte[100])); - System.out.printf("\nCert Encoded With Encode: %s\n", encoder.encode(new byte[100])); + final String encodeBufferResult = + encoder.encodeBuffer(new byte[100]); + final String encodeResult = encoder.encode(new byte[100]); + + final String content = String.format(""" + Cert Encoded With Encode Buffer: %s + Cert Encoded With Encode: %s""", + encodeBufferResult, encodeResult); + Files.writeString( + Paths.get(Charset.defaultCharset().displayName() + ".txt"), + content, + StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING); } } } diff --git a/test/jdk/sun/security/util/math/TestIntegerModuloP.java b/test/jdk/sun/security/util/math/TestIntegerModuloP.java index e1c02365424..f2b73223efc 100644 --- a/test/jdk/sun/security/util/math/TestIntegerModuloP.java +++ b/test/jdk/sun/security/util/math/TestIntegerModuloP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +27,7 @@ * @summary Test proper operation of integer field arithmetic * @modules java.base/sun.security.util java.base/sun.security.util.math java.base/sun.security.util.math.intpoly * @build BigIntegerModuloP - * @run main TestIntegerModuloP sun.security.util.math.intpoly.IntegerPolynomial25519 32 0 + * @run main TestIntegerModuloP sun.security.util.math.intpoly.IntegerPolynomial25519 31 0 */ /* diff --git a/test/jdk/sun/text/IntHashtable/Bug4705389.java b/test/jdk/sun/text/IntHashtable/Bug4705389.java index bb688439706..c74dd03b532 100644 --- a/test/jdk/sun/text/IntHashtable/Bug4705389.java +++ b/test/jdk/sun/text/IntHashtable/Bug4705389.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 4705389 * @summary Make sure to find removed slots, which test case will be timed out without the fix. * @modules java.base/sun.text - * @run main/timeout=10 Bug4705389 */ import sun.text.IntHashtable; diff --git a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java index 92f73597ce6..559b6b7d5a4 100644 --- a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java @@ -33,7 +33,6 @@ import java.util.List; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Platform; -import jdk.test.lib.Utils; /* * @test @@ -182,5 +181,10 @@ public class TestJcmdSanity { output.shouldNotContain("*** Handler was modified!"); output.shouldNotContain("*** Expected: "); // e.g. *** Expected: javaSignalHandler in ... } + + // Should find file descriptor counting on Mac and Linux + if (Platform.isLinux() || Platform.isOSX()) { + output.shouldMatch("Open File Descriptors: \\d+"); + } } } diff --git a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java index 75f2af6db5a..412a811d219 100644 --- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java +++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @summary Basic test for jhsdb launcher * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @build jdk.test.lib.apps.* * @run main/timeout=480 BasicLauncherTest */ diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java index c59e2b0e040..5ef1dadcb62 100644 --- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8163346 * @summary Test hashing of extended characters in Serviceability Agent. * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile -encoding utf8 HeapDumpTest.java * @run main/timeout=240 HeapDumpTest diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java b/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java index bd5a400225f..fffbe439f94 100644 --- a/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 +25,7 @@ * @test * @bug 8230731 8001227 8231635 8231634 8196969 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile JShellHeapDumpTest.java * @run main/timeout=240 JShellHeapDumpTest nosleep diff --git a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java index 6fbc96362a9..a9e5f7aeffe 100644 --- a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 +25,7 @@ * @test * @bug 8225715 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile JShellHeapDumpTest.java * @run main/timeout=240 JShellHeapDumpTest diff --git a/test/jdk/sun/tools/jhsdb/JStackStressTest.java b/test/jdk/sun/tools/jhsdb/JStackStressTest.java index 97945b6092b..a28cdf3be5a 100644 --- a/test/jdk/sun/tools/jhsdb/JStackStressTest.java +++ b/test/jdk/sun/tools/jhsdb/JStackStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,6 +25,7 @@ * @test * @bug 8262271 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/timeout=240 JStackStressTest */ diff --git a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index 659eac2ee8f..b2c7ba0ef87 100644 --- a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 jdk.test.lib.Utils; * @summary Unit test for jmap utility test heap configuration reader * * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @modules java.management * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java index 80eda6fc091..d743485373e 100644 --- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java +++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,10 +76,8 @@ public class DeadlockDetectionTest { } try { - String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData"); - theApp = new LingeredAppWithDeadlock(); - LingeredApp.startApp(theApp, vmArgs); + LingeredApp.startApp(theApp, "-XX:+UsePerfData"); OutputAnalyzer output = jstack(Long.toString(theApp.getPid())); System.out.println(output.getOutput()); diff --git a/test/jdk/sun/util/resources/TimeZone/Bug8139107.java b/test/jdk/sun/util/resources/TimeZone/Bug8139107.java index e00d4c88889..575dd7c291e 100644 --- a/test/jdk/sun/util/resources/TimeZone/Bug8139107.java +++ b/test/jdk/sun/util/resources/TimeZone/Bug8139107.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,13 @@ * @summary Test that date parsing with DateTimeFormatter pattern * that contains timezone field doesn't trigger NPE. All supported * locales are tested. - * @run testng/timeout=480 Bug8139107 + * @run junit/timeout=480 Bug8139107 */ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.Locale; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.Test; public class Bug8139107 { diff --git a/test/jdk/sun/util/resources/TimeZone/ChineseTimeZoneNameTest.java b/test/jdk/sun/util/resources/TimeZone/ChineseTimeZoneNameTest.java index 335d147f9ab..258edc38a59 100644 --- a/test/jdk/sun/util/resources/TimeZone/ChineseTimeZoneNameTest.java +++ b/test/jdk/sun/util/resources/TimeZone/ChineseTimeZoneNameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8275721 8174269 * @modules jdk.localedata * @summary Checks Chinese time zone names for `UTC` using CLDR are consistent - * @run testng ChineseTimeZoneNameTest + * @run junit ChineseTimeZoneNameTest */ import java.time.Instant; @@ -35,11 +35,10 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Locale; -import static org.testng.Assert.assertEquals; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; -@Test public class ChineseTimeZoneNameTest { private static final Locale SIMPLIFIED_CHINESE = Locale.forLanguageTag("zh-Hans"); @@ -47,8 +46,7 @@ public class ChineseTimeZoneNameTest { private static final ZonedDateTime EPOCH_UTC = ZonedDateTime.ofInstant(Instant.ofEpochSecond (0), ZoneId.of ("UTC")); - @DataProvider(name="locales") - Object[][] data() { + private static Object[][] data() { return new Object[][] { {Locale.CHINESE, SIMPLIFIED_CHINESE}, {Locale.SIMPLIFIED_CHINESE, SIMPLIFIED_CHINESE}, @@ -61,11 +59,12 @@ public class ChineseTimeZoneNameTest { }; } - @Test(dataProvider="locales") + @ParameterizedTest + @MethodSource("data") public void test_ChineseTimeZoneNames(Locale testLoc, Locale resourceLoc) { - assertEquals(DateTimeFormatter.ofPattern("z", testLoc).format(EPOCH_UTC), - DateTimeFormatter.ofPattern("z", resourceLoc).format(EPOCH_UTC)); - assertEquals(DateTimeFormatter.ofPattern("zzzz", testLoc).format(EPOCH_UTC), - DateTimeFormatter.ofPattern("zzzz", resourceLoc).format(EPOCH_UTC)); + assertEquals(DateTimeFormatter.ofPattern("z", resourceLoc).format(EPOCH_UTC), + DateTimeFormatter.ofPattern("z", testLoc).format(EPOCH_UTC)); + assertEquals(DateTimeFormatter.ofPattern("zzzz", resourceLoc).format(EPOCH_UTC), + DateTimeFormatter.ofPattern("zzzz", testLoc).format(EPOCH_UTC)); } } diff --git a/test/jdk/sun/util/resources/cldr/Bug8202764.java b/test/jdk/sun/util/resources/cldr/Bug8202764.java index 6f3e40e6201..e7fa110671a 100644 --- a/test/jdk/sun/util/resources/cldr/Bug8202764.java +++ b/test/jdk/sun/util/resources/cldr/Bug8202764.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,11 +28,9 @@ * @summary Checks time zone names are consistent with aliased ids, * between DateFormatSymbols.getZoneStrings() and getDisplayName() * of TimeZone/ZoneId classes - * @run testng/othervm Bug8202764 + * @run junit/othervm Bug8202764 */ -import static org.testng.Assert.assertEquals; - import java.time.ZoneId; import java.time.format.TextStyle; import java.text.DateFormatSymbols; @@ -41,7 +39,8 @@ import java.util.Locale; import java.util.Set; import java.util.TimeZone; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Bug8202764 { @@ -53,15 +52,15 @@ public class Bug8202764 { .forEach(zone -> { System.out.println(zone[0]); TimeZone tz = TimeZone.getTimeZone(zone[0]); - assertEquals(zone[1], tz.getDisplayName(false, TimeZone.LONG, Locale.US)); - assertEquals(zone[2], tz.getDisplayName(false, TimeZone.SHORT, Locale.US)); - assertEquals(zone[3], tz.getDisplayName(true, TimeZone.LONG, Locale.US)); - assertEquals(zone[4], tz.getDisplayName(true, TimeZone.SHORT, Locale.US)); + assertEquals(tz.getDisplayName(false, TimeZone.LONG, Locale.US), zone[1]); + assertEquals(tz.getDisplayName(false, TimeZone.SHORT, Locale.US), zone[2]); + assertEquals(tz.getDisplayName(true, TimeZone.LONG, Locale.US), zone[3]); + assertEquals(tz.getDisplayName(true, TimeZone.SHORT, Locale.US), zone[4]); if (zoneIds.contains(zone[0])) { // Some of the ids, e.g. three-letter ids are not supported in ZoneId ZoneId zi = tz.toZoneId(); - assertEquals(zone[5], zi.getDisplayName(TextStyle.FULL, Locale.US)); - assertEquals(zone[6], zi.getDisplayName(TextStyle.SHORT, Locale.US)); + assertEquals(zi.getDisplayName(TextStyle.FULL, Locale.US), zone[5]); + assertEquals(zi.getDisplayName(TextStyle.SHORT, Locale.US), zone[6]); } }); } diff --git a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java index 05b0114f1b4..6d21cd5613a 100644 --- a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java +++ b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +28,7 @@ * @modules jdk.localedata * @summary Checks CLDR time zone names are generated correctly at * either build or runtime - * @run testng TimeZoneNamesTest + * @run junit TimeZoneNamesTest */ import java.text.DateFormatSymbols; @@ -39,16 +39,15 @@ import java.util.Locale; import java.util.Objects; import java.util.TimeZone; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; -@Test public class TimeZoneNamesTest { - @DataProvider - Object[][] sampleTZs() { + private static Object[][] sampleTZs() { return new Object[][] { // tzid, locale, style, expected @@ -219,19 +218,20 @@ public class TimeZoneNamesTest { } - @Test(dataProvider="sampleTZs") + @ParameterizedTest + @MethodSource("sampleTZs") public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, String ldst, String sdst, String lgen, String sgen) { // Standard time - assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.LONG, locale), lstd); - assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.SHORT, locale), sstd); + assertEquals(lstd, TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.LONG, locale)); + assertEquals(sstd, TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.SHORT, locale)); // daylight saving time - assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.LONG, locale), ldst); - assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.SHORT, locale), sdst); + assertEquals(ldst, TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.LONG, locale)); + assertEquals(sdst, TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.SHORT, locale)); // generic name - assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.FULL, locale), lgen); - assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.SHORT, locale), sgen); + assertEquals(lgen, ZoneId.of(tzid).getDisplayName(TextStyle.FULL, locale)); + assertEquals(sgen, ZoneId.of(tzid).getDisplayName(TextStyle.SHORT, locale)); } // Make sure getZoneStrings() returns non-empty string array diff --git a/test/jdk/tools/jimage/JImageBadFileTest.java b/test/jdk/tools/jimage/JImageBadFileTest.java new file mode 100644 index 00000000000..d25c994b265 --- /dev/null +++ b/test/jdk/tools/jimage/JImageBadFileTest.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2026, 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.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Consumer; + +import jdk.test.lib.Utils; + +import static java.nio.file.StandardOpenOption.READ; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.util.regex.Pattern.quote; + +/* + * @test + * @summary Tests to verify behavior for "invalid" jimage files + * @library /test/lib + * @modules jdk.jlink/jdk.tools.jimage + * @build jdk.test.lib.Asserts + * @run main JImageBadFileTest + */ +public class JImageBadFileTest extends JImageCliTest { + // src/java.base/share/native/libjimage/imageFile.hpp + // + // 31 -------- bits -------- 0 + // IDX +-------------------------+ + // 0 | Magic (0xCAFEDADA) | + // +------------+------------+ + // 1 | Major Vers | Minor Vers | + // +------------+------------+ + // 2 | Flags | + // +-------------------------+ + // 3 | Resource Count | + // +-------------------------+ + // 4 | Table Length | + // +-------------------------+ + // 5 | Attributes Size | + // +-------------------------+ + // 6 | Strings Size | + // +-------------------------+ + private static final int HEADER_SIZE_BYTES = 7 * 4; + + /** + * Helper to copy the default jimage file for the runtime under test and + * allow it to be corrupted in various ways. + * + * @param label label for the temporary file (arbitrary debug name) + * @param maxLen maximum number of bytes to copy (-1 to copy all) + * @param headerFn function which may corrupt specific header values + * @return the path of a temporary jimage file in the test directory containing + * the possibly corrupted jimage file (caller should delete) + */ + private Path writeModifiedJimage(String label, int maxLen, Consumer headerFn) + throws IOException { + int remaining = maxLen >= 0 ? maxLen : Integer.MAX_VALUE; + Path dst = Utils.createTempFile("modules-" + label, ""); + try (InputStream rest = Files.newInputStream(Path.of(getImagePath()), READ); + OutputStream out = Files.newOutputStream(dst, TRUNCATE_EXISTING)) { + ByteBuffer bytes = ByteBuffer.wrap(rest.readNBytes(HEADER_SIZE_BYTES)); + bytes.order(ByteOrder.nativeOrder()); + headerFn.accept(bytes.asIntBuffer()); + int headerSize = Math.min(remaining, HEADER_SIZE_BYTES); + out.write(bytes.array(), 0, headerSize); + remaining -= headerSize; + if (remaining > 0) { + byte[] block = new byte[8192]; + do { + int copySize = Math.min(remaining, block.length); + out.write(block, 0, rest.readNBytes(block, 0, copySize)); + remaining -= copySize; + } while (rest.available() > 0 && remaining > 0); + } + return dst.toAbsolutePath(); + } + } + + public void testBadMagicNumber() throws IOException { + // Flip some bits in the magic number. + Path tempJimage = writeModifiedJimage("bad_magic", -1, b -> b.put(0, b.get(1) ^ 0x1010)); + JImageResult result = jimage("info", tempJimage.toString()); + result.assertShowsError(); + assertMatches(quote("Unable to open"), result.output); + assertMatches(quote("is not an image file"), result.output); + } + + public void testMismatchedVersion() throws IOException { + // Add one to minor version (lowest bits). + Path tempJimage = writeModifiedJimage("bad_version", -1, b -> b.put(1, b.get(1) + 1)); + JImageResult result = jimage("info", tempJimage.toString()); + result.assertShowsError(); + assertMatches(quote("Unable to open"), result.output); + assertMatches(quote("/bin/jimage"), result.output); + assertMatches(quote("not the correct version"), result.output); + assertMatches("Major: \\d+", result.output); + assertMatches("Minor: \\d+", result.output); + } + + public void testTruncatedHeader() throws IOException { + // Copy less than the header. + Path tempJimage = writeModifiedJimage("truncated_header", HEADER_SIZE_BYTES - 4, b -> {}); + JImageResult result = jimage("info", tempJimage.toString()); + result.assertShowsError(); + assertMatches(quote("Unable to open"), result.output); + assertMatches(quote("is not an image file"), result.output); + } + + public void testTruncatedData() throws IOException { + // Copy more than the header, but definitely less than the whole file. + Path tempJimage = writeModifiedJimage("truncated_data", HEADER_SIZE_BYTES + 1024, b -> {}); + JImageResult result = jimage("info", tempJimage.toString()); + result.assertShowsError(); + assertMatches(quote("Unable to open"), result.output); + assertMatches("image file \".*\" is corrupted", result.output); + } + + public void testGoodFileCopy() throws IOException { + // Self test that the file copying isn't itself corrupting anything. + Path tempJimage = writeModifiedJimage("good_file", -1, b -> {}); + jimage("info", tempJimage.toString()).assertSuccess(); + } + + public static void main(String[] args) throws Throwable { + new JImageBadFileTest().runTests(); + } +} diff --git a/test/jdk/tools/jpackage/TEST.properties b/test/jdk/tools/jpackage/TEST.properties index 19eda305364..99af197b989 100644 --- a/test/jdk/tools/jpackage/TEST.properties +++ b/test/jdk/tools/jpackage/TEST.properties @@ -8,12 +8,12 @@ requires.properties = \ jpackage.test.SQETest \ jpackage.test.MacSignTests -maxOutputSize = 2000000 +maxOutputSize = 10000000 # Run jpackage tests on windows platform sequentially. # Having "share" directory in the list affects tests on other platforms. # The better option would be: -# if (platfrom == windowws) { +# if (platfrom == windows) { # exclusiveAccess.dirs=share windows # } # but conditionals are not supported by jtreg configuration files. @@ -29,4 +29,6 @@ modules = \ jdk.jpackage/jdk.jpackage.internal.util.function \ jdk.jpackage/jdk.jpackage.internal.resources:+open \ java.base/jdk.internal.util \ + java.base/sun.security.util \ + java.base/sun.security.x509 \ jdk.jlink/jdk.tools.jlink.internal diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedArgumentTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedArgumentTest.java new file mode 100644 index 00000000000..8653e9c7508 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedArgumentTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.nio.file.Path; +import jdk.jpackage.test.CannedFormattedStringTest.Formatter; +import org.junit.jupiter.api.Test; + +class CannedArgumentTest { + + @Test + void test_cannedAbsolutePath() { + var a = Formatter.MESSAGE_FORMAT.create("Current directory: {0}", CannedArgument.cannedAbsolutePath("foo")); + assertEquals("Current directory: " + Path.of("foo").toAbsolutePath(), a.getValue()); + assertEquals("Current directory: {0}+[AbsolutePath(foo)]", a.toString()); + } +} diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedFormattedStringTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedFormattedStringTest.java new file mode 100644 index 00000000000..2e4ad9ab754 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/CannedFormattedStringTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; + +import java.text.MessageFormat; +import java.util.List; +import java.util.function.BiFunction; +import org.junit.jupiter.api.Test; + +class CannedFormattedStringTest { + + @Test + void test_getValue() { + var a = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + assertEquals("Hello Duke! Bye Duke", a.getValue()); + assertEquals("Hello {0}! Bye {0}+[Duke]", a.toString()); + + var b = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}"); + assertEquals("Hello {0}! Bye {0}", b.getValue()); + assertEquals("Hello {0}! Bye {0}", b.toString()); + } + + @Test + void test_equals() { + var a = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + var b = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + + assertEquals(a, b); + + a = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + b = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Java"); + + assertNotEquals(a, b); + } + + @Test + void test_addPrefix() { + var a = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + var b = a.addPrefix("{0} and {0}").addPrefix("They say: {0}"); + var str = "Hello Duke! Bye Duke"; + assertEquals(str, a.getValue()); + assertEquals("They say: " + str + " and " + str, b.getValue()); + assertEquals("They say: {0}+[{0} and {0}, Hello {0}! Bye {0}, Duke]", b.toString()); + + var c = a.addPrefix("{0} and {0}").addPrefix("They say: {0}"); + assertEquals(c, b); + assertNotSame(b, c); + } + + @Test + void test_mapArgs() { + var a = Formatter.MESSAGE_FORMAT.create("Hello {0}! Bye {0}", "Duke"); + var b = a.mapArgs(arg -> { + assertEquals("Duke", arg); + return "Java"; + }); + + assertEquals("Hello Duke! Bye Duke", a.getValue()); + assertEquals("Hello Java! Bye Java", b.getValue()); + } + + enum Formatter implements BiFunction { + MESSAGE_FORMAT { + @Override + public String apply(String format, Object[] formatArgs) { + return MessageFormat.format(format, formatArgs); + } + }, + ; + + CannedFormattedString create(String format, Object ... formatArgs) { + return new CannedFormattedString(this, format, List.of(formatArgs)); + } + } +} diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java new file mode 100644 index 00000000000..0512d03b76a --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +class JPackageStringBundleTest { + + @Test + void test_cannedFormattedString() { + assertFalse(JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty").getValue().isBlank()); + } + + @Test + void test_cannedFormattedString_equals() { + var a = JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty"); + var b = JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty"); + + assertEquals(a, b); + + a = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "foo"); + b = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "foo"); + + assertEquals(a, b); + + a = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "foo"); + b = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "bar"); + + assertNotEquals(a, b); + } + + @Test + void test_cannedFormattedStringAsPattern() { + var pred = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.version-string-empty", UNREACHABLE_FORMAT_ARG_MAPPER).asMatchPredicate(); + + var str = JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty").getValue(); + assertTrue(pred.test(str)); + assertFalse(pred.test(str + str)); + } + + @Test + void test_cannedFormattedStringAsPattern_with_arg() { + var pred = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", DEFAULT_FORMAT_ARG_MAPPER, "foo").asMatchPredicate(); + + for (var err : List.of("foo", "bar", "", "Unexpected value")) { + var str = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", err).getValue(); + assertTrue(pred.test(str)); + assertFalse(pred.test(err)); + } + } + + @ParameterizedTest + @MethodSource + void test_cannedFormattedString_wrong_argument_count(CannedFormattedString cannedStr) { + assertThrowsExactly(IllegalArgumentException.class, cannedStr::getValue); + } + + @Test + void test_cannedFormattedStringAsPattern_wrong_argument_count() { + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.version-string-empty", UNREACHABLE_FORMAT_ARG_MAPPER, "foo"); + }); + + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", UNREACHABLE_FORMAT_ARG_MAPPER); + }); + + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", UNREACHABLE_FORMAT_ARG_MAPPER, "foo", "bar"); + }); + } + + @ParameterizedTest + @MethodSource + void test_toPattern(TestSpec test) { + var pattern = JPackageStringBundle.toPattern(new MessageFormat(test.formatter()), test.formatArgMapper(), test.args().toArray()); + assertEquals(test.expectedPattern().toString(), pattern.toString()); + } + + private static Collection test_cannedFormattedString_wrong_argument_count() { + return List.of( + JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty", "foo"), + JPackageStringBundle.MAIN.cannedFormattedString("message.error-header"), + JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "foo", "bar") + ); + } + + private static Collection test_toPattern() { + + var testCases = new ArrayList(); + + testCases.addAll(List.of( + TestSpec.create("", Pattern.compile("")), + TestSpec.create("", Pattern.compile(""), "foo") + )); + + for (List args : List.of(List.of(), List.of("foo"))) { + Stream.of( + "Stop." + ).map(formatter -> { + return new TestSpec(formatter, args, Pattern.compile(Pattern.quote(formatter))); + }).forEach(testCases::add); + } + + testCases.add(TestSpec.create("Hello {1} {0}{1}!", Pattern.compile("\\QHello \\E.*\\Q \\E.*.*\\Q!\\E"), "foo", "bar")); + testCases.add(TestSpec.create("Hello {1} {0}{0} {0}{0}{0} {0}", Pattern.compile("\\QHello \\E.*\\Q \\E.*\\Q \\E.*\\Q \\E.*"), "foo", "bar")); + testCases.add(TestSpec.create("{0}{0}", Pattern.compile(".*"), "foo")); + + return testCases; + } + + record TestSpec(String formatter, List args, Pattern expectedPattern) { + TestSpec { + Objects.requireNonNull(formatter); + Objects.requireNonNull(args); + Objects.requireNonNull(expectedPattern); + } + + Function formatArgMapper() { + if (Pattern.compile(Pattern.quote(formatter)).toString().equals(expectedPattern.toString())) { + return UNREACHABLE_FORMAT_ARG_MAPPER; + } else { + return DEFAULT_FORMAT_ARG_MAPPER; + } + } + + static TestSpec create(String formatter, Pattern expectedPattern, Object... args) { + return new TestSpec(formatter, List.of(args), expectedPattern); + } + } + + private static final Pattern DEFAULT_FORMAT_ARG_PATTERN = Pattern.compile(".*"); + + private static final Function DEFAULT_FORMAT_ARG_MAPPER = _ -> { + return DEFAULT_FORMAT_ARG_PATTERN; + }; + + private static final Function UNREACHABLE_FORMAT_ARG_MAPPER = _ -> { + throw new AssertionError(); + }; +} diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/MacHelperTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/MacHelperTest.java index 5d14f021eaf..b8f7bfd456e 100644 --- a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/MacHelperTest.java +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/MacHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,14 +31,20 @@ import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Stream; import jdk.jpackage.internal.util.PListReader; import jdk.jpackage.internal.util.XmlUtils; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -public class MacHelperTest { +public class MacHelperTest extends JUnitAdapter { @Test public void test_flatMapPList() { @@ -105,6 +111,18 @@ public class MacHelperTest { ), props); } + @ParameterizedTest + @MethodSource + public void test_appImageSigned(SignedTestSpec spec) { + spec.test(MacHelper::appImageSigned); + } + + @ParameterizedTest + @MethodSource + public void test_nativePackageSigned(SignedTestSpec spec) { + spec.test(MacHelper::nativePackageSigned); + } + private static String createPListXml(String ...xml) { final List content = new ArrayList<>(); content.add(""); @@ -125,4 +143,126 @@ public class MacHelperTest { throw new RuntimeException(ex); } } + + private static Stream test_appImageSigned() { + + List data = new ArrayList<>(); + + for (var signingIdentityOption : List.of( + List.of(), + List.of("--mac-signing-key-user-name", "foo"), + List.of("--mac-app-image-sign-identity", "foo"), + List.of("--mac-installer-sign-identity", "foo"), + List.of("--mac-installer-sign-identity", "foo", "--mac-app-image-sign-identity", "bar") + )) { + for (var type : List.of(PackageType.IMAGE, PackageType.MAC_DMG, PackageType.MAC_PKG)) { + for (var withMacSign : List.of(true, false)) { + if (signingIdentityOption.contains("--mac-installer-sign-identity") && type != PackageType.MAC_PKG) { + continue; + } + + var builder = SignedTestSpec.build().type(type).cmdline(signingIdentityOption); + if (withMacSign) { + builder.cmdline("--mac-sign"); + if (Stream.of( + "--mac-signing-key-user-name", + "--mac-app-image-sign-identity" + ).anyMatch(signingIdentityOption::contains) || signingIdentityOption.isEmpty()) { + builder.signed(); + } + } + + data.add(builder); + } + } + } + + return data.stream().map(SignedTestSpec.Builder::create); + } + + private static Stream test_nativePackageSigned() { + + List data = new ArrayList<>(); + + for (var signingIdentityOption : List.of( + List.of(), + List.of("--mac-signing-key-user-name", "foo"), + List.of("--mac-app-image-sign-identity", "foo"), + List.of("--mac-installer-sign-identity", "foo"), + List.of("--mac-installer-sign-identity", "foo", "--mac-app-image-sign-identity", "bar") + )) { + for (var type : List.of(PackageType.MAC_DMG, PackageType.MAC_PKG)) { + for (var withMacSign : List.of(true, false)) { + if (signingIdentityOption.contains("--mac-installer-sign-identity") && type != PackageType.MAC_PKG) { + continue; + } + + var builder = SignedTestSpec.build().type(type).cmdline(signingIdentityOption); + if (withMacSign) { + builder.cmdline("--mac-sign"); + if (type == PackageType.MAC_PKG && (Stream.of( + "--mac-signing-key-user-name", + "--mac-installer-sign-identity" + ).anyMatch(signingIdentityOption::contains) || signingIdentityOption.isEmpty())) { + builder.signed(); + } + } + + data.add(builder); + } + } + } + + return data.stream().map(SignedTestSpec.Builder::create); + } + + private record SignedTestSpec(boolean expectedSigned, PackageType type, List cmdline) { + + SignedTestSpec { + Objects.requireNonNull(type); + cmdline.forEach(Objects::requireNonNull); + } + + void test(Function func) { + var actualSigned = func.apply((new JPackageCommand().addArguments(cmdline).setPackageType(type))); + assertEquals(expectedSigned, actualSigned); + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + SignedTestSpec create() { + return new SignedTestSpec( + expectedSigned, + Optional.ofNullable(type).orElse(PackageType.IMAGE), + cmdline); + } + + Builder signed() { + expectedSigned = true; + return this; + } + + Builder type(PackageType v) { + type = v; + return this; + } + + Builder cmdline(String... args) { + return cmdline(List.of(args)); + } + + Builder cmdline(List v) { + cmdline.addAll(v); + return this; + } + + private boolean expectedSigned; + private PackageType type; + private List cmdline = new ArrayList<>(); + } + } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java index 55b13a06620..ce2cb6f6b57 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java @@ -26,6 +26,7 @@ import static java.util.stream.Collectors.toMap; import static jdk.jpackage.internal.util.function.ThrowingConsumer.toConsumer; import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction; import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; +import static jdk.jpackage.test.JPackageCommand.DEFAULT_VERSION; import java.io.IOException; import java.nio.file.Path; @@ -41,7 +42,6 @@ import javax.xml.stream.XMLStreamWriter; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import jdk.internal.util.OperatingSystem; import jdk.jpackage.internal.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -66,7 +66,7 @@ public record AppImageFile(String mainLauncherName, Optional mainLaunche } public AppImageFile(String mainLauncherName, Optional mainLauncherClassName) { - this(mainLauncherName, mainLauncherClassName, "1.0", false, Map.of(mainLauncherName, Map.of())); + this(mainLauncherName, mainLauncherClassName, DEFAULT_VERSION, false, Map.of(mainLauncherName, Map.of())); } public AppImageFile(String mainLauncherName, String mainLauncherClassName) { @@ -195,13 +195,16 @@ public record AppImageFile(String mainLauncherName, Optional mainLaunche } private static String getPlatform() { - return PLATFORM_LABELS.get(OperatingSystem.current()); + if (TKit.isLinux()) { + return "linux"; + } else if (TKit.isWindows()) { + return "windows"; + } else if (TKit.isOSX()) { + return "macOS"; + } else { + throw new IllegalStateException(); + } } private static final String FILENAME = ".jpackage.xml"; - - private static final Map PLATFORM_LABELS = Map.of( - OperatingSystem.LINUX, "linux", - OperatingSystem.WINDOWS, "windows", - OperatingSystem.MACOS, "macOS"); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedArgument.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedArgument.java index b50d12ac4ec..346b172fa35 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedArgument.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedArgument.java @@ -22,7 +22,37 @@ */ package jdk.jpackage.test; +import java.nio.file.Path; +import java.util.Objects; +import java.util.function.Supplier; + @FunctionalInterface public interface CannedArgument { + public String getValue(); + + public static CannedArgument create(Supplier supplier, String label) { + Objects.requireNonNull(supplier); + Objects.requireNonNull(label); + return new CannedArgument() { + + @Override + public String getValue() { + return supplier.get().toString(); + } + + @Override + public String toString( ) { + return label; + } + }; + } + + public static Object cannedAbsolutePath(Path v) { + return create(v::toAbsolutePath, String.format("AbsolutePath(%s)", v)); + } + + public static Object cannedAbsolutePath(String v) { + return cannedAbsolutePath(Path.of(v)); + } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedFormattedString.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedFormattedString.java index 09f867da786..cc31c416d44 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedFormattedString.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CannedFormattedString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,55 +22,30 @@ */ package jdk.jpackage.test; -import java.nio.file.Path; import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.function.BiFunction; -import java.util.function.Supplier; import java.util.function.UnaryOperator; +import java.util.regex.Pattern; import java.util.stream.Stream; -public record CannedFormattedString(BiFunction formatter, String key, Object[] args) implements CannedArgument { - - public static CannedArgument cannedArgument(Supplier supplier, String label) { - Objects.requireNonNull(supplier); - Objects.requireNonNull(label); - return new CannedArgument() { - - @Override - public String getValue() { - return supplier.get().toString(); - } - - @Override - public String toString( ) { - return label; - } - }; - } - - public static Object cannedAbsolutePath(Path v) { - return cannedArgument(() -> v.toAbsolutePath(), String.format("AbsolutePath(%s)", v)); - } - - public static Object cannedAbsolutePath(String v) { - return cannedAbsolutePath(Path.of(v)); - } +public record CannedFormattedString(BiFunction formatter, String key, List args) implements CannedArgument { public CannedFormattedString mapArgs(UnaryOperator mapper) { - return new CannedFormattedString(formatter, key, Stream.of(args).map(mapper).toArray()); + return new CannedFormattedString(formatter, key, args.stream().map(mapper).toList()); } public CannedFormattedString { Objects.requireNonNull(formatter); Objects.requireNonNull(key); Objects.requireNonNull(args); - List.of(args).forEach(Objects::requireNonNull); + args.forEach(Objects::requireNonNull); } + @Override public String getValue() { - return formatter.apply(key, Stream.of(args).map(arg -> { + return formatter.apply(key, args.stream().map(arg -> { if (arg instanceof CannedArgument cannedArg) { return cannedArg.getValue(); } else { @@ -80,19 +55,46 @@ public record CannedFormattedString(BiFunction formatt } public CannedFormattedString addPrefix(String prefixKey) { - Objects.requireNonNull(prefixKey); - return new CannedFormattedString((theKey, theArgs) -> { - var str = formatter.apply((String)theArgs[0], Arrays.copyOfRange(theArgs, 1, theArgs.length)); - return formatter.apply(theKey, new Object[] {str}); - }, prefixKey, Stream.concat(Stream.of(key), Stream.of(args)).toArray()); + return new CannedFormattedString( + new AddPrefixFormatter(formatter), prefixKey, Stream.concat(Stream.of(key), args.stream()).toList()); } @Override public String toString() { - if (args.length == 0) { + if (args.isEmpty()) { return String.format("%s", key); } else { - return String.format("%s+%s", key, List.of(args)); + return String.format("%s+%s", key, args); + } + } + + public interface Spec { + + String format(); + List modelArgs(); + + default CannedFormattedString asCannedFormattedString(Object ... args) { + if (args.length != modelArgs().size()) { + throw new IllegalArgumentException(); + } + return JPackageStringBundle.MAIN.cannedFormattedString(format(), args); + } + + default Pattern asPattern() { + return JPackageStringBundle.MAIN.cannedFormattedStringAsPattern(format(), modelArgs().toArray()); + } + } + + private record AddPrefixFormatter(BiFunction formatter) implements BiFunction { + + AddPrefixFormatter { + Objects.requireNonNull(formatter); + } + + @Override + public String apply(String format, Object[] formatArgs) { + var str = formatter.apply((String)formatArgs[0], Arrays.copyOfRange(formatArgs, 1, formatArgs.length)); + return formatter.apply(format, new Object[] {str}); } } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index da6af4bed33..b173d345596 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -43,7 +43,7 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; +import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -61,6 +61,10 @@ import java.util.spi.ToolProvider; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import jdk.jpackage.internal.model.DottedVersion; +import jdk.jpackage.internal.util.MacBundle; +import jdk.jpackage.internal.util.Result; +import jdk.jpackage.internal.util.RuntimeReleaseFile; import jdk.jpackage.internal.util.function.ExceptionBox; import jdk.jpackage.internal.util.function.ThrowingConsumer; import jdk.jpackage.internal.util.function.ThrowingFunction; @@ -102,6 +106,7 @@ public class JPackageCommand extends CommandArguments { executeInDirectory = cmd.executeInDirectory; winMsiLogFile = cmd.winMsiLogFile; unpackedPackageDirectory = cmd.unpackedPackageDirectory; + explicitVersion = cmd.explicitVersion; } JPackageCommand createImmutableCopy() { @@ -245,7 +250,101 @@ public class JPackageCommand extends CommandArguments { } public String version() { - return getArgumentValue("--app-version", () -> "1.0"); + return PropertyFinder.findAppProperty(this, + PropertyFinder.of(Optional.ofNullable(explicitVersion)) + .or(PropertyFinder.cmdlineOptionWithValue("--app-version")) + .or(JPackageCommand::derivedVersion), + PropertyFinder.appImageFile(appImageFile -> { + return appImageFile.version(); + }) + ).orElse(DEFAULT_VERSION); + } + + private Optional derivedVersion() { + if (isRuntime()) { + var predefinedRuntimePath = Path.of(getArgumentValue("--runtime-image")); + if (TKit.isOSX()) { + // This is a macOS runtime bundle. + return MacBundle.fromPath(predefinedRuntimePath).map(predefinedRuntimeBundle -> { + return Result.>of(() -> { + // This is a macOS runtime bundle created from the predefined runtime bundle (not a predefined runtime directory). + // The version of this bundle should be copied from the Info.plist file of the predefined runtime bundle. + return MacHelper.readPList(predefinedRuntimeBundle.infoPlistFile()).findValue("CFBundleVersion"); + }).value().flatMap(x -> x).or(() -> { + // Failed to read version from the Info.plist file of the predefined runtime bundle. + // Try to read it from the "release" file of the predefined runtime directory. + return normalizedVersionFromRuntimeReleaseFile(predefinedRuntimeBundle.homeDir()); + }); + }).orElseGet(() -> { + return normalizedVersionFromRuntimeReleaseFile(predefinedRuntimePath); + }); + } else { + return normalizedVersionFromRuntimeReleaseFile(predefinedRuntimePath); + } + } else { + return Optional.empty(); + } + } + + private Optional normalizedVersionFromRuntimeReleaseFile(Path runtimeDir) { + return Result.of(() -> { + return RuntimeReleaseFile.loadFromRuntime(runtimeDir).getJavaVersion().toString(); + }, Exception.class).value().map(JPackageCommand::normalizeDerivedVersion).map(map -> { + return Objects.requireNonNull(map.get(packageType())); + }); + } + + public static Map normalizeDerivedVersion(String version) { + var dotted = DottedVersion.lazy(version); + + var map = new HashMap(); + + // Linux + map.put(PackageType.LINUX_IMAGE, version); + map.put(PackageType.LINUX_DEB, version); + if (dotted.getUnprocessedSuffix().contains("-")) { + map.put(PackageType.LINUX_RPM, dotted.toComponentsString()); + } else { + map.put(PackageType.LINUX_RPM, version); + } + + // macOS + PackageType.ALL_MAC.forEach(type -> { + map.put(type, dotted.trim(3).pad(1).toComponentsString()); + }); + + // Windows + PackageType.ALL_WINDOWS.forEach(type -> { + DottedVersion ver; + if (dotted.getComponentsCount() < 2) { + ver = dotted.pad(2); + } else { + ver = dotted.trim(4); + } + map.put(type, ver.toComponentsString()); + }); + + map.put(PackageType.IMAGE, Objects.requireNonNull(map.get(PackageType.appImageForOS(PackageType.IMAGE.os())))); + + return map; + } + + /** + * Sets application version. + *

+ * Use this method to explicitly set the application version. Normally, the + * application version can be derived from the command line, but sometimes, when + * jpackage derives it from other sources, the {@code JPackageCommand} class + * can't get it correctly. Use this method in these uncommon cases. + * + * @param v the application version or {@code null} to reset previously set + * value + * @return this + */ + public JPackageCommand version(String v) { + verifyMutable(); + explicitVersion = v; + return this; } public String name() { @@ -293,7 +392,6 @@ public class JPackageCommand extends CommandArguments { } public JPackageCommand setFakeRuntime() { - verifyMutable(); addPrerequisiteAction(cmd -> { cmd.setArgumentValue("--runtime-image", createInputRuntimeImage(RuntimeImageType.RUNTIME_TYPE_FAKE)); }); @@ -301,12 +399,22 @@ public class JPackageCommand extends CommandArguments { return this; } + public JPackageCommand usePredefinedAppImage(JPackageCommand appImageCmd) { + appImageCmd.verifyIsOfType(PackageType.IMAGE); + verifyIsOfType(PackageType.IMAGE); + appImageCmd.getVerifyActionsWithRole(ActionRole.LAUNCHER_VERIFIER).forEach(verifier -> { + addVerifyAction(verifier, ActionRole.LAUNCHER_VERIFIER); + }); + return usePredefinedAppImage(appImageCmd.outputBundle()); + } + public JPackageCommand usePredefinedAppImage(Path predefinedAppImagePath) { return setArgumentValue("--app-image", Objects.requireNonNull(predefinedAppImagePath)) .removeArgumentWithValue("--input"); } JPackageCommand addPrerequisiteAction(ThrowingConsumer action) { + verifyMutable(); prerequisiteActions.add(action); return this; } @@ -322,6 +430,7 @@ public class JPackageCommand extends CommandArguments { } JPackageCommand addVerifyAction(ThrowingConsumer action, ActionRole actionRole) { + verifyMutable(); verifyActions.add(action, actionRole); return this; } @@ -950,13 +1059,13 @@ public class JPackageCommand extends CommandArguments { } public String getValue(CannedFormattedString str) { - return new CannedFormattedString(str.formatter(), str.key(), Stream.of(str.args()).map(arg -> { + return new CannedFormattedString(str.formatter(), str.key(), str.args().stream().map(arg -> { if (arg instanceof CannedArgument cannedArg) { return cannedArg.value(this); } else { return arg; } - }).toArray()).getValue(); + }).toList()).getValue(); } public JPackageCommand validateOut(CannedFormattedString... strings) { @@ -969,6 +1078,53 @@ public class JPackageCommand extends CommandArguments { return this; } + public JPackageCommand validateOutput( + Class messageGroup, + Consumer validatorMutator, + List expectedMessages) { + + Objects.requireNonNull(validatorMutator); + + if (!messageGroup.isEnum()) { + throw new IllegalArgumentException(); + } + + var messageSpecs = messageGroup.getEnumConstants(); + + var expectMessageFormats = expectedMessages.stream().map(CannedFormattedString::key).toList(); + + var groupMessageFormats = Stream.of(messageSpecs) + .map(CannedFormattedString.Spec::format) + .collect(Collectors.toMap(x -> x, x -> x)) + .keySet(); + + if (!groupMessageFormats.containsAll(expectMessageFormats)) { + // Expected format strings should be a subset of the group format strings. + throw new IllegalArgumentException(); + } + + if (!expectedMessages.isEmpty()) { + new JPackageOutputValidator().expectMatchingStrings(expectedMessages).mutate(validatorMutator).applyTo(this); + } + + Stream.of(messageSpecs).filter(spec -> { + return !expectMessageFormats.contains(spec.format()); + }).map(CannedFormattedString.Spec::asPattern).map(pattern -> { + return TKit.assertTextStream(pattern).negate(); + }).forEach(validator -> { + new JPackageOutputValidator().add(validator).stdoutAndStderr().applyTo(this); + }); + + return this; + } + + public JPackageCommand validateOutput( + Class messageGroup, + Consumer validatorMutator, + CannedFormattedString... expected) { + return validateOutput(messageGroup, validatorMutator, List.of(expected)); + } + public boolean isWithToolProvider() { return toolProviderSource.toolProvider().isPresent(); } @@ -1050,6 +1206,10 @@ public class JPackageCommand extends CommandArguments { final var directoriesAssert = new ReadOnlyPathsAssert(copy); + standardAssertOutputValidators().forEach(validator -> { + validator.applyTo(copy); + }); + Executor.Result result; if (expectedExitCode.isEmpty()) { result = copy.createExecutor().executeWithoutExitCodeCheck(); @@ -1064,7 +1224,7 @@ public class JPackageCommand extends CommandArguments { ConfigFilesStasher.INSTANCE.accept(this); } - for (final var validator: validators) { + for (final var validator: copy.validators) { validator.accept(result); } @@ -1292,7 +1452,7 @@ public class JPackageCommand extends CommandArguments { } }), MAC_BUNDLE_UNSIGNED_SIGNATURE(cmd -> { - if (TKit.isOSX() && !MacHelper.appImageSigned(cmd)) { + if (TKit.isOSX()) { MacHelper.verifyUnsignedBundleSignature(cmd); } }), @@ -1316,7 +1476,14 @@ public class JPackageCommand extends CommandArguments { }), PREDEFINED_APP_IMAGE_COPY(cmd -> { Optional.ofNullable(cmd.getArgumentValue("--app-image")).filter(_ -> { - return !TKit.isOSX() || !MacHelper.signPredefinedAppImage(cmd); + if (!TKit.isOSX() || !cmd.hasArgument("--mac-sign")) { + return true; + } else { + var signAppImage = MacHelper.signPredefinedAppImage(cmd) + || MacHelper.hasAppImageSignIdentity(cmd) + || MacHelper.isSignWithoutSignIdentity(cmd); + return !signAppImage; + } }).filter(_ -> { // Don't examine the contents of the output app image if this is Linux package installing in the "/usr" subtree. return Optional.ofNullable(cmd.onLinuxPackageInstallDir(null, _ -> false)).orElse(true); @@ -1368,10 +1535,38 @@ public class JPackageCommand extends CommandArguments { TKit.assertFileExists(cmd.appLayout().libapplauncher()); } }), + LINUX_PACKAGE_ARCH(cmd -> { + if (TKit.isLinux() && !cmd.isImagePackageType()) { + var asserter = TKit.assertTextStream(LinuxUnexpectedBundleArchRegexp.VALUE).negate(); + return Stream.of(true, false).map(stderr -> { + var validator = new JPackageOutputValidator(); + if (stderr) { + return validator.stderr(); + } else { + return validator; + } + }).map(validator -> { + return validator.add(asserter); + }).toList(); + } else { + return List.of(); + } + }), ; - StandardAssert(Consumer action) { + StandardAssert( + Consumer action, + Function> outputValidatorsSupplier) { this.action = action; + this.outputValidatorsSupplier = outputValidatorsSupplier; + } + + StandardAssert(Consumer action) { + this(Objects.requireNonNull(action), null); + } + + StandardAssert(Function> outputValidatorsSupplier) { + this(null, Objects.requireNonNull(outputValidatorsSupplier)); } private static JPackageCommand convertFromRuntime(JPackageCommand cmd) { @@ -1383,7 +1578,38 @@ public class JPackageCommand extends CommandArguments { return copy; } + Stream outputValidators(JPackageCommand cmd) { + Objects.requireNonNull(cmd); + return Optional.ofNullable(outputValidatorsSupplier).map(v -> { + return v.apply(cmd); + }).stream().flatMap(Collection::stream); + } + + void apply(JPackageCommand cmd) { + Objects.requireNonNull(cmd); + if (action != null) { + action.accept(cmd); + } + } + private final Consumer action; + private final Function> outputValidatorsSupplier; + + private static final class LinuxUnexpectedBundleArchRegexp { + private static final Pattern ANY = Pattern.compile(".*"); + private static final Pattern ARCHITECTURE_PROPERTY = Pattern.compile("Arch|Architecture"); + + static final Pattern VALUE = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.unexpected-package-property", arg -> { + return switch ((String)arg) { + case "propertyName" -> { + yield ARCHITECTURE_PROPERTY; + } + default -> { + yield ANY; + } + }; + }, "propertyName", "expectedValue", "actualValue", "customResource"); + } } public JPackageCommand setStandardAsserts(StandardAssert ... asserts) { @@ -1400,11 +1626,17 @@ public class JPackageCommand extends CommandArguments { JPackageCommand runStandardAsserts() { for (var standardAssert : standardAsserts.stream().sorted().toList()) { - standardAssert.action.accept(this); + standardAssert.apply(this); } return this; } + private List standardAssertOutputValidators() { + return standardAsserts.stream().sorted().flatMap(standardAssert -> { + return standardAssert.outputValidators(this); + }).toList(); + } + private boolean expectAppImageFile() { if (isRuntime()) { return false; @@ -1838,6 +2070,7 @@ public class JPackageCommand extends CommandArguments { private Path executeInDirectory; private Path winMsiLogFile; private Path unpackedPackageDirectory; + private String explicitVersion; private Set readOnlyPathAsserts = Set.of(ReadOnlyPathAssert.values()); private Set standardAsserts = Set.of(StandardAssert.values()); private List> validators = new ArrayList<>(); @@ -1846,7 +2079,9 @@ public class JPackageCommand extends CommandArguments { VALUE } - private static final Map PACKAGE_TYPES = Stream.of(PackageType.values()).collect(toMap(PackageType::getType, x -> x)); + private static final Map PACKAGE_TYPES = Stream.of(PackageType.values()).filter(type -> { + return type.isNative() || type == PackageType.IMAGE; + }).collect(toMap(PackageType::getType, x -> x)); // Set the property to the path of run-time image to speed up // building app images and platform bundles by avoiding running jlink. @@ -1855,6 +2090,8 @@ public class JPackageCommand extends CommandArguments { // `--runtime-image` parameter set. public static final Path DEFAULT_RUNTIME_IMAGE = Optional.ofNullable(TKit.getConfigProperty("runtime-image")).map(Path::of).orElse(null); + public static final String DEFAULT_VERSION = "1.0"; + // [HH:mm:ss.SSS] private static final Pattern TIMESTAMP_REGEXP = Pattern.compile( "^\\[\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d\\] "); diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageOutputValidator.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageOutputValidator.java index c5c9c018b6a..8817ca0b730 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageOutputValidator.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageOutputValidator.java @@ -43,7 +43,7 @@ public final class JPackageOutputValidator { } public JPackageOutputValidator(JPackageOutputValidator other) { - stdout = other.stdout; + stream = other.stream; match = other.match; matchTimestamps = other.matchTimestamps; stripTimestamps = other.stripTimestamps; @@ -59,7 +59,7 @@ public final class JPackageOutputValidator { * @return this */ public JPackageOutputValidator stdout() { - stdout = true; + stream = StdStream.OUT; return this; } @@ -68,7 +68,16 @@ public final class JPackageOutputValidator { * @return this */ public JPackageOutputValidator stderr() { - stdout = false; + stream = StdStream.ERR; + return this; + } + + /** + * Configures this validator to validate both stdout and stderr. + * @return this + */ + public JPackageOutputValidator stdoutAndStderr() { + stream = StdStream.OUT_AND_ERR; return this; } @@ -131,6 +140,11 @@ public final class JPackageOutputValidator { return this; } + public JPackageOutputValidator mutate(Consumer mutator) { + mutator.accept(this); + return this; + } + public void applyTo(JPackageCommand cmd) { toResultConsumer(cmd).ifPresent(cmd::validateResult); } @@ -171,7 +185,7 @@ public final class JPackageOutputValidator { } public JPackageOutputValidator compose(JPackageOutputValidator other) { - if (stdout != other.stdout) { + if (stream != other.stream) { throw new IllegalArgumentException(); } if (match != other.match) { @@ -188,7 +202,7 @@ public final class JPackageOutputValidator { private Optional> toResultConsumer(JPackageCommand cmd) { return toStringIteratorConsumer(cmd).map(validator -> { - return toResultConsumer(validator, stdout, match, label()); + return toResultConsumer(validator, stream, match, label()); }); } @@ -244,7 +258,11 @@ public final class JPackageOutputValidator { } private String label() { - return stdout ? "'stdout'" : "'stderr'"; + return switch (stream) { + case OUT -> "'stdout'"; + case ERR -> "'stderr'"; + case OUT_AND_ERR -> "'stdout+stderr'"; + }; } private Consumer> decorate(TKit.TextStreamVerifier validator) { @@ -256,17 +274,16 @@ public final class JPackageOutputValidator { } private static Consumer toResultConsumer( - Consumer> validator, boolean stdout, boolean match, String label) { + Consumer> validator, StdStream stream, boolean match, String label) { Objects.requireNonNull(validator); Objects.requireNonNull(label); return result -> { - List content; - if (stdout) { - content = result.stdout(); - } else { - content = result.stderr(); - } + List content = switch (stream) { + case OUT -> result.stdout(); + case ERR -> result.stderr(); + case OUT_AND_ERR -> result.getOutput(); + }; if (match) { TKit.trace(String.format("Checking %s for exact match against defined validators...", label)); @@ -371,7 +388,14 @@ public final class JPackageOutputValidator { } } - boolean stdout = true; + private enum StdStream { + OUT, + ERR, + OUT_AND_ERR, + ; + } + + StdStream stream = StdStream.OUT; boolean match; boolean matchTimestamps; boolean stripTimestamps; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java index 9425b84472c..688b16a8e09 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,10 +23,17 @@ package jdk.jpackage.test; +import static jdk.jpackage.internal.util.function.ExceptionBox.toUnchecked; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.MessageFormat; -import static jdk.jpackage.internal.util.function.ExceptionBox.toUnchecked; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.regex.Pattern; public enum JPackageStringBundle { @@ -42,6 +49,9 @@ public enum JPackageStringBundle { } catch (ClassNotFoundException|NoSuchMethodException ex) { throw toUnchecked(ex); } + formatter = (String key, Object[] args) -> { + return new FormattedMessage(key, args).value(); + }; } /** @@ -55,19 +65,107 @@ public enum JPackageStringBundle { } } - private String getFormattedString(String key, Object[] args) { - var str = getString(key); - if (args.length != 0) { - return MessageFormat.format(str, args); - } else { - return str; - } + public CannedFormattedString cannedFormattedString(String key, Object ... args) { + return new CannedFormattedString(formatter, key, List.of(args)); } - public CannedFormattedString cannedFormattedString(String key, Object ... args) { - return new CannedFormattedString(this::getFormattedString, key, args); + public Pattern cannedFormattedStringAsPattern(String key, Function formatArgMapper, Object ... args) { + var fm = new FormattedMessage(key, args); + return fm.messageFormat().map(mf -> { + return toPattern(mf, formatArgMapper, args); + }).orElseGet(() -> { + return Pattern.compile(Pattern.quote(fm.value())); + }); + } + + public Pattern cannedFormattedStringAsPattern(String key, Object ... args) { + return cannedFormattedStringAsPattern(key, MATCH_ANY, args); + } + + static Pattern toPattern(MessageFormat mf, Function formatArgMapper, Object ... args) { + Objects.requireNonNull(mf); + Objects.requireNonNull(formatArgMapper); + + var patternSb = new StringBuilder(); + var runSb = new StringBuilder(); + + var it = mf.formatToCharacterIterator(args); + while (it.getIndex() < it.getEndIndex()) { + var runBegin = it.getRunStart(); + var runEnd = it.getRunLimit(); + if (runEnd < runBegin) { + throw new IllegalStateException(); + } + + var attrs = it.getAttributes(); + if (attrs.isEmpty()) { + // Regular text run. + runSb.setLength(0); + it.setIndex(runBegin); + for (int counter = runEnd - runBegin; counter != 0; --counter) { + runSb.append(it.current()); + it.next(); + } + patternSb.append(Pattern.quote(runSb.toString())); + } else { + // Format run. + int argi = (Integer)attrs.get(MessageFormat.Field.ARGUMENT); + var arg = args[argi]; + var pattern = Objects.requireNonNull(formatArgMapper.apply(arg)); + patternSb.append(pattern.toString()); + it.setIndex(runEnd); + } + } + + return Pattern.compile(patternSb.toString()); + } + + private final class FormattedMessage { + + FormattedMessage(String key, Object[] args) { + List.of(args).forEach(Objects::requireNonNull); + + var formatter = getString(key); + + var mf = new MessageFormat(formatter); + var formatCount = mf.getFormatsByArgumentIndex().length; + if (formatCount != args.length) { + throw new IllegalArgumentException(String.format( + "Expected %d arguments for [%s] string, but given %d", formatCount, key, args.length)); + } + + if (formatCount == 0) { + this.mf = null; + value = formatter; + } else { + this.mf = mf; + value = mf.format(args); + } + } + + String value() { + return value; + } + + Optional messageFormat() { + return Optional.ofNullable(mf); + } + + private final String value; + private final MessageFormat mf; } private final Class i18nClass; private final Method i18nClass_getString; + private final BiFunction formatter; + + private static final Function MATCH_ANY = new Function<>() { + + @Override + public Pattern apply(Object v) { + return PATTERN; + } + + private static final Pattern PATTERN = Pattern.compile(".*"); + }; } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java index 0bbf71fe0cd..4ca4b918355 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 +27,7 @@ package jdk.jpackage.test; import java.nio.file.Path; import java.util.spi.ToolProvider; +import jdk.internal.util.OperatingSystem; public enum JavaTool { JAVA, JAVAC, JPACKAGE, JAR, JLINK, JMOD, JSHELL; @@ -50,7 +51,7 @@ public enum JavaTool { private Path relativePathInJavaHome() { Path path = Path.of("bin", toolName()); - if (TKit.isWindows()) { + if (OperatingSystem.isWindows()) { path = path.getParent().resolve(path.getFileName().toString() + ".exe"); } return path; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherVerifier.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherVerifier.java index f9fcfb905af..7657517bad5 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherVerifier.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherVerifier.java @@ -372,14 +372,21 @@ public final class LauncherVerifier { TKit.assertTrue(entitlements.isPresent(), String.format("Check [%s] launcher is signed with entitlements", name)); + String expectedEntitlementsOrigin; + var customFile = Optional.ofNullable(cmd.getArgumentValue("--mac-entitlements")).map(Path::of); - if (customFile.isEmpty()) { + if (customFile.isPresent()) { + expectedEntitlementsOrigin = String.format("custom entitlements from [%s] file", customFile.get()); + } else { // Try from the resource dir. var resourceDirFile = Optional.ofNullable(cmd.getArgumentValue("--resource-dir")).map(Path::of).map(resourceDir -> { return resourceDir.resolve(cmd.name() + ".entitlements"); }).filter(Files::exists); if (resourceDirFile.isPresent()) { customFile = resourceDirFile; + expectedEntitlementsOrigin = "custom entitlements from the resource directory"; + } else { + expectedEntitlementsOrigin = null; } } @@ -388,11 +395,14 @@ public final class LauncherVerifier { expected = new PListReader(Files.readAllBytes(customFile.orElseThrow())).toMap(true); } else if (cmd.hasArgument("--mac-app-store")) { expected = DefaultEntitlements.APP_STORE; + expectedEntitlementsOrigin = "App Store entitlements"; } else { + expectedEntitlementsOrigin = "default entitlements"; expected = DefaultEntitlements.STANDARD; } - TKit.assertEquals(expected, entitlements.orElseThrow().toMap(true), String.format("Check [%s] launcher is signed with expected entitlements", name)); + TKit.assertEquals(expected, entitlements.orElseThrow().toMap(true), + String.format("Check [%s] launcher is signed with %s", name, expectedEntitlementsOrigin)); } private void executeLauncher(JPackageCommand cmd) throws IOException { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java index 78562b2ed26..66462bedfd7 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java @@ -26,6 +26,7 @@ import static java.util.Collections.unmodifiableSortedSet; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import java.io.IOException; import java.io.UncheckedIOException; @@ -36,7 +37,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -46,35 +46,34 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; +import jdk.internal.util.Architecture; import jdk.jpackage.internal.util.PathUtils; +import jdk.jpackage.internal.util.Result; import jdk.jpackage.internal.util.function.ThrowingConsumer; import jdk.jpackage.test.LauncherShortcut.InvokeShortcutSpec; import jdk.jpackage.test.PackageTest.PackageHandlers; public final class LinuxHelper { - private static String getReleaseSuffix(JPackageCommand cmd) { - final String value; - final PackageType packageType = cmd.packageType(); - switch (packageType) { - case LINUX_DEB: - value = Optional.ofNullable(cmd.getArgumentValue( - "--linux-app-release", () -> null)).map(v -> "-" + v).orElse( - ""); - break; - case LINUX_RPM: - value = "-" + cmd.getArgumentValue("--linux-app-release", - () -> "1"); - break; - - default: - value = null; + static String getReleaseSuffix(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.LINUX); + var release = Optional.ofNullable(cmd.getArgumentValue("--linux-app-release")); + switch (cmd.packageType()) { + case LINUX_DEB -> { + return release.map(v -> "-" + v).orElse(""); + } + case LINUX_RPM -> { + return "-" + release.orElse("1"); + } + default -> { + throw new UnsupportedOperationException(); + } } - return value; } public static String getPackageName(JPackageCommand cmd) { @@ -333,10 +332,14 @@ public final class LinuxHelper { long packageSize = getInstalledPackageSizeKB(cmd); TKit.trace("InstalledPackageSize: " + packageSize); TKit.assertNotEquals(0, packageSize, String.format( - "Check installed size of [%s] package in not zero", packageName)); + "Check installed size of [%s] package is not zero", packageName)); final boolean checkPrerequisites; - if (cmd.isRuntime()) { + if (NativePackageType.VALUE != cmd.packageType()) { + // Alien packaging (DEB packaging on RPM Linux or RPM packaging on Debian). + // Don't validate required packages. + checkPrerequisites = false; + } else if (cmd.isRuntime()) { Path runtimeDir = cmd.appRuntimeDirectory(); Set expectedCriticalRuntimePaths = CRITICAL_RUNTIME_FILES.stream().map( runtimeDir::resolve).collect(toSet()); @@ -850,29 +853,7 @@ public final class LinuxHelper { } public static String getDefaultPackageArch(PackageType type) { - if (archs == null) { - archs = new HashMap<>(); - } - - String arch = archs.get(type); - if (arch == null) { - final Executor exec; - switch (type) { - case LINUX_DEB: - exec = Executor.of("dpkg", "--print-architecture"); - break; - - case LINUX_RPM: - exec = Executor.of("rpmbuild", "--eval=%{_target_cpu}"); - break; - - default: - throw new UnsupportedOperationException(); - } - arch = exec.executeAndGetFirstLineOfOutput(); - archs.put(type, arch); - } - return arch; + return LinuxPackageArchitecture.get(type); } private static String getServiceUnitFileName(String packageName, String launcherName) { @@ -960,7 +941,62 @@ public final class LinuxHelper { static final Set CRITICAL_RUNTIME_FILES = Set.of(Path.of( "lib/server/libjvm.so")); - private static Map archs; + private enum LinuxPackageArchitecture implements Supplier { + RPM("rpmbuild", "--eval=%{_target_cpu}"), + DEB("dpkg", "--print-architecture"), + ; + + LinuxPackageArchitecture(String... cmdline) { + this.cmdline = List.of(cmdline); + } + + static String get(PackageType type) { + Objects.requireNonNull(type); + if (type.isSupported()) { + return ARCHS.get(type).get(); + } else { + return Architecture.current().name().toLowerCase(); + } + } + + @Override + public String get() { + return Executor.of(cmdline).executeAndGetFirstLineOfOutput(); + } + + private final List cmdline; + + private static final Map> ARCHS = Map.of( + PackageType.LINUX_RPM, runOnce(RPM), + PackageType.LINUX_DEB, runOnce(DEB)); + } + + private static final class NativePackageType { + + static final PackageType VALUE; + + private static boolean isDebian() { + // we are just going to run "dpkg -s coreutils" and assume Debian + // or derivative if no error is returned. + return Result.of(Executor.of("dpkg", "-s", "coreutils")::execute).hasValue(); + } + + private static boolean isRpm() { + // we are just going to run "rpm -q rpm" and assume RPM + // or derivative if no error is returned. + return Result.of(Executor.of("rpm", "-q", "rpm")::execute).hasValue(); + } + + static { + if (isDebian()) { + VALUE = PackageType.LINUX_DEB; + } else if (isRpm()) { + VALUE = PackageType.LINUX_RPM; + } else { + VALUE = null; + } + } + } private static final Pattern XDG_CMD_ICON_SIZE_PATTERN = Pattern.compile("\\s--size\\s+(\\d+)\\b"); diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java index 1191cd02221..1372058d440 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java @@ -76,6 +76,7 @@ import jdk.jpackage.internal.util.RetryExecutor; import jdk.jpackage.internal.util.XmlUtils; import jdk.jpackage.internal.util.function.ThrowingConsumer; import jdk.jpackage.internal.util.function.ThrowingSupplier; +import jdk.jpackage.test.MacSign.CertificateHash; import jdk.jpackage.test.MacSign.CertificateRequest; import jdk.jpackage.test.MacSign.CertificateType; import jdk.jpackage.test.MacSign.ResolvedKeychain; @@ -259,10 +260,7 @@ public final class MacHelper { * predefined app image in place and {@code false} otherwise. */ public static boolean signPredefinedAppImage(JPackageCommand cmd) { - Objects.requireNonNull(cmd); - if (!TKit.isOSX()) { - throw new UnsupportedOperationException(); - } + cmd.verifyIsOfType(PackageType.MAC_DMG, PackageType.MAC_PKG, PackageType.IMAGE); return cmd.hasArgument("--mac-sign") && cmd.hasArgument("--app-image") && cmd.isImagePackageType(); } @@ -279,10 +277,7 @@ public final class MacHelper { * otherwise. */ public static boolean appImageSigned(JPackageCommand cmd) { - Objects.requireNonNull(cmd); - if (!TKit.isOSX()) { - throw new UnsupportedOperationException(); - } + cmd.verifyIsOfType(PackageType.MAC_DMG, PackageType.MAC_PKG, PackageType.IMAGE); var runtimeImageBundle = Optional.ofNullable(cmd.getArgumentValue("--runtime-image")).map(Path::of).flatMap(MacBundle::fromPath); var appImage = Optional.ofNullable(cmd.getArgumentValue("--app-image")).map(Path::of); @@ -291,23 +286,102 @@ public final class MacHelper { // If the predefined runtime is a signed bundle, bundled image should be signed too. return true; } else if (appImage.map(MacHelper::isBundleSigned).orElse(false)) { - // The external app image is signed, so the app image is signed too. + // The predefined app image is signed, so the app image is signed too. return true; } - if (!cmd.isImagePackageType() && appImage.isPresent()) { - // Building a ".pkg" or a ".dmg" bundle from the predefined app image. - // The predefined app image is unsigned, so the app image bundled - // in the output native package will be unsigned too - // (even if the ".pkg" file may be signed itself, and we never sign ".dmg" files). - return false; - } - if (!cmd.hasArgument("--mac-sign")) { return false; + } else { + return isSignWithoutSignIdentity(cmd) || hasAppImageSignIdentity(cmd); } + } - return (cmd.hasArgument("--mac-signing-key-user-name") || cmd.hasArgument("--mac-app-image-sign-identity")); + /** + * Returns {@code true} if the given jpackage command line is configured such + * that the native package it will produce will be signed. + * + * @param cmd the jpackage command to examine + * @return {@code true} if the given jpackage command line is configured such + * the native package it will produce will be signed and {@code false} + * otherwise. + */ + public static boolean nativePackageSigned(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.MAC); + + switch (cmd.packageType()) { + case MAC_DMG -> { + return false; + } + case MAC_PKG -> { + if (!cmd.hasArgument("--mac-sign")) { + return false; + } else { + return isSignWithoutSignIdentity(cmd) || hasPkgInstallerSignIdentity(cmd); + } + } + default -> { + throw new IllegalStateException(); + } + } + } + + /** + * Returns {@code true} if the given jpackage command line has app image signing + * identity option. The command line must have "--mac-sign" option. + * + * @param cmd the jpackage command to examine + * @return {@code true} if the given jpackage command line has app image signing + * identity option and {@code false} otherwise. + */ + public static boolean hasAppImageSignIdentity(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.MAC_DMG, PackageType.MAC_PKG, PackageType.IMAGE); + if (!cmd.hasArgument("--mac-sign")) { + throw new IllegalArgumentException(); + } + return Stream.of( + "--mac-signing-key-user-name", + "--mac-app-image-sign-identity" + ).anyMatch(cmd::hasArgument); + } + + /** + * Returns {@code true} if the given jpackage command line has PKG installer signing + * identity option. The command line must have "--mac-sign" option. + * + * @param cmd the jpackage command to examine + * @return {@code true} if the given jpackage command line has PKG installer signing + * identity option and {@code false} otherwise. + */ + public static boolean hasPkgInstallerSignIdentity(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.MAC_PKG); + if (!cmd.hasArgument("--mac-sign")) { + throw new IllegalArgumentException(); + } + return Stream.of( + "--mac-signing-key-user-name", + "--mac-installer-sign-identity" + ).anyMatch(cmd::hasArgument); + } + + /** + * Returns {@code true} if the given jpackage command line doesn't have signing + * identity options. The command line must have "--mac-sign" option. + * + * @param cmd the jpackage command to examine + * @return {@code true} if the given jpackage command line doesn't have signing + * identity options and {@code false} otherwise. + */ + public static boolean isSignWithoutSignIdentity(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.MAC_DMG, PackageType.MAC_PKG, PackageType.IMAGE); + if (!cmd.hasArgument("--mac-sign")) { + throw new IllegalArgumentException(); + } + return Stream.of( + "--mac-signing-key-user-name", + "--mac-app-image-sign-identity", + "--mac-installer-sign-identity" + ).noneMatch(cmd::hasArgument); } public static void writeFaPListFragment(JPackageCommand cmd, XMLStreamWriter xml) { @@ -702,6 +776,14 @@ public final class MacHelper { MacSign.CertificateType.CODE_SIGN, Name.KEY_IDENTITY_APP_IMAGE, MacSign.CertificateType.INSTALLER, Name.KEY_IDENTITY_INSTALLER)), + /** + * "--mac-installer-sign-identity" or "--mac-app-image-sign-identity" option + * with the SHA1 of a signing certificate + */ + SIGN_KEY_IDENTITY_SHA1(Map.of( + MacSign.CertificateType.CODE_SIGN, Name.KEY_IDENTITY_APP_IMAGE, + MacSign.CertificateType.INSTALLER, Name.KEY_IDENTITY_INSTALLER)), + /** * "--mac-app-image-sign-identity" regardless of the type of signing identity * (for signing app image or .pkg installer). @@ -714,6 +796,12 @@ public final class MacHelper { */ SIGN_KEY_IDENTITY_INSTALLER(Name.KEY_IDENTITY_INSTALLER), + /** + * No explicit option specifying signing identity. jpackage will pick one from + * the specified keychain. + */ + SIGN_KEY_IMPLICIT, + ; Type(Map optionNameMap) { @@ -736,11 +824,24 @@ public final class MacHelper { return optionNameMapper.apply(Objects.requireNonNull(certType)); } + public boolean passThrough() { + return Stream.of(MacSign.CertificateType.values()) + .map(this::mapOptionName) + .flatMap(Optional::stream) + .map(Name::passThrough) + .distinct() + .reduce((_, _) -> { + throw new IllegalStateException(); + }).orElse(false); + } + public static Type[] defaultValues() { return new Type[] { SIGN_KEY_USER_SHORT_NAME, SIGN_KEY_USER_FULL_NAME, - SIGN_KEY_IDENTITY + SIGN_KEY_IDENTITY, + SIGN_KEY_IDENTITY_SHA1, + SIGN_KEY_IMPLICIT }; } @@ -751,7 +852,7 @@ public final class MacHelper { public String toString() { var sb = new StringBuilder(); sb.append('{'); - applyTo((optionName, _) -> { + type.mapOptionName(certRequest.type()).ifPresent(optionName -> { sb.append(optionName); switch (type) { case SIGN_KEY_USER_FULL_NAME -> { @@ -762,6 +863,9 @@ public final class MacHelper { sb.append("=").append(ENQUOTER.applyTo(optionValue)); }); } + case SIGN_KEY_IDENTITY_SHA1 -> { + sb.append("/sha1"); + } default -> { // NOP } @@ -787,12 +891,16 @@ public final class MacHelper { } public List asCmdlineArgs() { - String[] args = new String[2]; - applyTo((optionName, optionValue) -> { - args[0] = optionName; - args[1] = optionValue; - }); - return List.of(args); + if (type == Type.SIGN_KEY_IMPLICIT) { + return List.of(); + } else { + String[] args = new String[2]; + applyTo((optionName, optionValue) -> { + args[0] = optionName; + args[1] = optionValue; + }); + return List.of(args); + } } public Optional passThrough() { @@ -817,6 +925,9 @@ public final class MacHelper { case SIGN_KEY_USER_SHORT_NAME -> { return certRequest.shortName(); } + case SIGN_KEY_IDENTITY_SHA1 -> { + return CertificateHash.of(certRequest.cert()).toString(); + } default -> { throw new IllegalStateException(); } @@ -960,18 +1071,21 @@ public final class MacHelper { } static void verifyUnsignedBundleSignature(JPackageCommand cmd) { - if (!cmd.isImagePackageType()) { + + if (!cmd.isImagePackageType() && !nativePackageSigned(cmd)) { MacSignVerify.assertUnsigned(cmd.outputBundle()); } - final Path bundleRoot; - if (cmd.isImagePackageType()) { - bundleRoot = cmd.outputBundle(); - } else { - bundleRoot = cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory()); - } + if (!appImageSigned(cmd)) { + final Path bundleRoot; + if (cmd.isImagePackageType()) { + bundleRoot = cmd.outputBundle(); + } else { + bundleRoot = cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory()); + } - MacSignVerify.assertAdhocSigned(bundleRoot); + MacSignVerify.assertAdhocSigned(bundleRoot); + } } static PackageHandlers createDmgPackageHandlers() { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java index 4dbb2bc1e18..81e5da34140 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java @@ -63,9 +63,12 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Stream; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; +import jdk.internal.util.OSVersion; +import jdk.jpackage.internal.util.MemoizingSupplier; import jdk.jpackage.internal.util.function.ExceptionBox; import jdk.jpackage.internal.util.function.ThrowingConsumer; import jdk.jpackage.internal.util.function.ThrowingSupplier; @@ -231,7 +234,7 @@ import jdk.jpackage.internal.util.function.ThrowingSupplier; * An untrusted certificate can NOT be used with /usr/bin/codesign. Use * *

- * /usr/bin/security security add-trusted-cert -k foo.keychain cert.pem
+ * /usr/bin/security add-trusted-cert -k foo.keychain cert.pem
  * 
* * command to add trusted certificate from "cert.pem" file to "foo.keychain" @@ -280,8 +283,15 @@ public final class MacSign { return sb.toString(); } + public static Builder build() { + return new Builder(); + } + public static final class Builder { + private Builder() { + } + public Builder name(String v) { keychainBuilder.name(v); return this; @@ -306,8 +316,8 @@ public final class MacSign { return new KeychainWithCertsSpec(keychain, List.copyOf(certs)); } - private Keychain.Builder keychainBuilder = new Keychain.Builder(); - private List certs = new ArrayList<>(); + private final Keychain.Builder keychainBuilder = Keychain.build(); + private final List certs = new ArrayList<>(); } } @@ -326,8 +336,15 @@ public final class MacSign { } } + public static Builder build() { + return new Builder(); + } + public static final class Builder { + private Builder() { + } + public Builder name(String v) { name = v; return this; @@ -424,7 +441,21 @@ public final class MacSign { } Keychain unlock() { - createExecutor("unlock-keychain").execute(); + var exec = createExecutor("unlock-keychain"); + + exec.execute(); + + if (UnlockKeychainWithOsascript.VALUE) { + exec = Executor.of("osascript") + .addArguments(SIGN_UTILS_SCRIPT.toString(), "run-shell-script") + .addArgument(Stream.concat( + Stream.of(exec.getExecutable().orElseThrow().toString()), + exec.getAllArguments().stream() + ).collect(joining(" "))); + + exec.execute(); + } + return this; } @@ -560,29 +591,43 @@ public final class MacSign { } private static CertificateStats create(KeychainWithCertsSpec spec) { - final var allCertificates = spec.keychain().findCertificates(); final List allResolvedCertificateRequests = new ArrayList<>(); final Map unmappedCertificates = new HashMap<>(); - withTempDirectory(workDir -> { - for (final var cert : allCertificates) { - ResolvedCertificateRequest resolvedCertificateRequest; - try { - resolvedCertificateRequest = new ResolvedCertificateRequest(cert); - } catch (RuntimeException ex) { - unmappedCertificates.put(cert, ExceptionBox.unbox(ex)); - continue; - } + final Runnable workload = () -> { + final var allCertificates = spec.keychain().findCertificates(); + withTempDirectory(workDir -> { + for (final var cert : allCertificates) { + ResolvedCertificateRequest resolvedCertificateRequest; + try { + resolvedCertificateRequest = new ResolvedCertificateRequest(cert); + } catch (RuntimeException ex) { + unmappedCertificates.put(cert, ExceptionBox.unbox(ex)); + continue; + } - if (spec.certificateRequests().stream().anyMatch(resolvedCertificateRequest.installed()::match)) { - final var certFile = workDir.resolve(CertificateHash.of(cert).toString() + ".pem"); - final var verifyStatus = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); - resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifyStatus); - } + if (spec.certificateRequests().stream().anyMatch(resolvedCertificateRequest.installed()::match)) { + final var certFile = workDir.resolve(CertificateHash.of(cert).toString() + ".pem"); + final var verifyStatus = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); + resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifyStatus); + } - allResolvedCertificateRequests.add(resolvedCertificateRequest); - } - }); + allResolvedCertificateRequests.add(resolvedCertificateRequest); + } + }); + }; + + // Starting from some macOS version, it is no longer necessary to have the keychain + // in the list of keychains when running the "/usr/bin/security verify-cert ..." command to verify its certificate(s). + // The exact version when they relaxed this constraint is unknown, but it is still required on Catalina 10.15.7. + // On Catalina, if the keychain is not in the list of keychains, "/usr/bin/security verify-cert ..." command + // executed on the certificates of this keychain returns "untrusted" result. + if (OSVersion.current().compareTo(new OSVersion(10, 16)) < 0) { + // macOS Catalina or older + withKeychains(spec).addToSearchList().run(workload); + } else { + workload.run(); + } return new CertificateStats(allResolvedCertificateRequests, List.copyOf(spec.certificateRequests()), unmappedCertificates); @@ -599,12 +644,7 @@ public final class MacSign { @Override public String toString() { - final var sb = new StringBuilder(); - sb.append(frame("BEGIN " + label)); - sb.append(ENCODER.encodeToString(data)); - sb.append("\n"); - sb.append(frame("END " + label)); - return sb.toString(); + return PemDataFormatter.format(label, data); } static PemData of(X509Certificate cert) { @@ -619,6 +659,21 @@ public final class MacSign { throw new UncheckedIOException(ex); } } + } + + private final class PemDataFormatter { + + static String format(String label, byte[] data) { + Objects.requireNonNull(label); + Objects.requireNonNull(data); + + final var sb = new StringBuilder(); + sb.append(frame("BEGIN " + label)); + sb.append(ENCODER.encodeToString(data)); + sb.append("\n"); + sb.append(frame("END " + label)); + return sb.toString(); + } private static String frame(String str) { return String.format("-----%s-----\n", Objects.requireNonNull(str)); @@ -627,6 +682,11 @@ public final class MacSign { private static final Base64.Encoder ENCODER = Base64.getMimeEncoder(64, "\n".getBytes()); } + public static String formatX509Certificate(X509Certificate cert) { + Objects.requireNonNull(cert); + return PemDataFormatter.format("CERTIFICATE", toSupplier(cert::getEncoded).get()); + } + public enum DigestAlgorithm { SHA1(20, () -> MessageDigest.getInstance("SHA-1")), SHA256(32, () -> MessageDigest.getInstance("SHA-256")); @@ -773,8 +833,15 @@ public final class MacSign { return COMPARATOR.compare(this, o); } + public static Builder build() { + return new Builder(); + } + public static final class Builder { + private Builder() { + } + public Builder userName(String v) { userName = v; return this; @@ -1068,6 +1135,15 @@ public final class MacSign { return !missingKeychain && !missingCertificates && !invalidCertificates; } + /** + * Creates an empty keychain with unique name in the work directory of the current test. + */ + public static Keychain createEmptyKeychain() { + return Keychain.build() + .name(TKit.createUniquePath(TKit.workDir().resolve("empty.keychain")).toAbsolutePath().toString()) + .create().create(); + } + public static Keychain.UsageBuilder withKeychains(KeychainWithCertsSpec... keychains) { return withKeychains(Stream.of(keychains).map(KeychainWithCertsSpec::keychain).toArray(Keychain[]::new)); } @@ -1100,9 +1176,14 @@ public final class MacSign { public static void withKeychain(Consumer consumer, Consumer mutator, ResolvedKeychain keychain) { Objects.requireNonNull(consumer); - withKeychains(() -> { + Objects.requireNonNull(mutator); + if (keychain.isMock()) { consumer.accept(keychain); - }, mutator, keychain.spec().keychain()); + } else { + withKeychains(() -> { + consumer.accept(keychain); + }, mutator, keychain.spec().keychain()); + } } public static void withKeychain(Consumer consumer, ResolvedKeychain keychain) { @@ -1111,7 +1192,15 @@ public final class MacSign { public static final class ResolvedKeychain { public ResolvedKeychain(KeychainWithCertsSpec spec) { + isMock = false; this.spec = Objects.requireNonNull(spec); + certMapSupplier = MemoizingSupplier.runOnce(() -> { + return MacSign.mapCertificateRequests(spec); + }); + } + + public static ResolvedKeychain createMock(String name, Map certs) { + return new ResolvedKeychain(name, certs); } public KeychainWithCertsSpec spec() { @@ -1122,15 +1211,30 @@ public final class MacSign { return spec.keychain().name(); } - public Map mapCertificateRequests() { - if (certMap == null) { - synchronized (this) { - if (certMap == null) { - certMap = MacSign.mapCertificateRequests(spec); - } - } + public boolean isMock() { + return isMock; + } + + public ResolvedKeychain toMock(Map signEnv) { + if (isMock) { + throw new UnsupportedOperationException("Already a mock"); } - return certMap; + + var comm = Comm.compare(Set.copyOf(spec.certificateRequests()), signEnv.keySet()); + if (!comm.unique1().isEmpty()) { + throw new IllegalArgumentException(String.format( + "Signing environment missing %s certificate request mappings in [%s] keychain", + comm.unique1(), name())); + } + + var certs = new HashMap<>(signEnv); + certs.keySet().retainAll(comm.common()); + + return createMock(name(), certs); + } + + public Map mapCertificateRequests() { + return certMapSupplier.get(); } public Function asCertificateResolver() { @@ -1145,8 +1249,23 @@ public final class MacSign { }; } + private ResolvedKeychain(String name, Map certs) { + + var keychainBuilder = KeychainWithCertsSpec.build().name(Objects.requireNonNull(name)); + certs.keySet().forEach(keychainBuilder::addCert); + + var certsCopy = Map.copyOf(Objects.requireNonNull(certs)); + + isMock = true; + spec = keychainBuilder.create(); + certMapSupplier = MemoizingSupplier.runOnce(() -> { + return certsCopy; + }); + } + + private final boolean isMock; private final KeychainWithCertsSpec spec; - private volatile Map certMap; + private final Supplier> certMapSupplier; } private static Map mapCertificateRequests(KeychainWithCertsSpec spec) { @@ -1182,7 +1301,11 @@ public final class MacSign { for (final var quite : List.of(true, false)) { result = security("verify-cert", "-L", "-n", quite ? "-q" : "-v", - "-c", certFile.normalize().toString(), + // Use "-r" option to verify the certificate against itself. + // "-c" option works on newer macOS versions, but on older ones (at least on Catalina 10.15.7), + // in case there are two self-signed certificates with the same name in the given keychain, + // it links them in the certificate list and fails verification. + "-r", certFile.normalize().toString(), "-k", keychain.name(), "-p", resolvedCertificateRequest.installed().type().verifyPolicy()).saveOutput(!quite).executeWithoutExitCodeCheck(); if (result.getExitCode() == 0) { @@ -1373,4 +1496,10 @@ public final class MacSign { // faketime is not a standard macOS command. // One way to get it is with Homebrew. private static final Path FAKETIME = Path.of(Optional.ofNullable(TKit.getConfigProperty("faketime")).orElse("/usr/local/bin/faketime")); + + // Run the "/usr/bin/system unlock-keychain" command in Terminal.app if + // the current process runs in an SSH session and the OS version is macOS Catalina or older. + private static final class UnlockKeychainWithOsascript { + static final boolean VALUE = System.getenv("SSH_CONNECTION") != null && OSVersion.current().compareTo(new OSVersion(10, 16)) < 0; + } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java index 01c510070be..404811ea0f8 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java @@ -93,8 +93,11 @@ public final class MacSignVerify { final var exec = Executor.of( "/usr/bin/codesign", "-d", - "--entitlements", "-", - "--xml", path.toString()).saveOutput().dumpOutput().binaryOutput(); + // `--entitlements :-` will print entitlements as XML plist in the stdout and "Executable=..." message to the stderr. + // Prefer this option combination to `--entitlements - --xml` as + // the latter doesn't work on older macOS releases (Proved unsupported on Catalina 10.15.7). + "--entitlements", ":-", + path.toString()).saveOutput().dumpOutput().binaryOutput(); final var result = exec.execute(); var xml = result.byteStdout(); if (xml.length == 0) { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MsiDatabase.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MsiDatabase.java index 6b3fae07d41..6c92e820f2e 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MsiDatabase.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MsiDatabase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,9 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,9 +44,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.IntStream; +import java.util.stream.Stream; -final class MsiDatabase { +public final class MsiDatabase { static MsiDatabase load(Path msiFile, Path idtFileOutputDir, Set tableNames) { try { @@ -61,7 +64,7 @@ final class MsiDatabase { .execute(0); var tables = orderedTableNames.stream().map(tableName -> { - return Map.entry(tableName, idtFileOutputDir.resolve(tableName + ".idt")); + return Map.entry(tableName, idtFileOutputDir.resolve(tableName.tableName() + ".idt")); }).filter(e -> { return Files.exists(e.getValue()); }).collect(Collectors.toMap(Map.Entry::getKey, e -> { @@ -81,6 +84,8 @@ final class MsiDatabase { FILE("File"), PROPERTY("Property"), SHORTCUT("Shortcut"), + CONTROL_EVENT("ControlEvent"), + INSTALL_UI_SEQUENCE("InstallUISequence"), ; Table(String name) { @@ -95,6 +100,7 @@ final class MsiDatabase { static final Set
FIND_PROPERTY_REQUIRED_TABLES = Set.of(PROPERTY); static final Set
LIST_SHORTCUTS_REQUIRED_TABLES = Set.of(COMPONENT, DIRECTORY, FILE, SHORTCUT); + static final Set
UI_ALTERATIONS_REQUIRED_TABLES = Set.of(CONTROL_EVENT, INSTALL_UI_SEQUENCE); } @@ -120,12 +126,7 @@ final class MsiDatabase { } Collection listShortcuts() { - var shortcuts = tables.get(Table.SHORTCUT); - if (shortcuts == null) { - return List.of(); - } - return IntStream.range(0, shortcuts.rowCount()).mapToObj(i -> { - var row = shortcuts.row(i); + return rows(Table.SHORTCUT).map(row -> { var shortcutPath = directoryPath(row.apply("Directory_")).resolve(fileNameFromFieldValue(row.apply("Name"))); var workDir = directoryPath(row.apply("WkDir")); var shortcutTarget = Path.of(expandFormattedString(row.apply("Target"))); @@ -133,6 +134,53 @@ final class MsiDatabase { }).toList(); } + UIAlterations uiAlterations() { + + var includeActions = Set.of("WelcomeEulaDlg", "WelcomeDlg"); + var actions = actionSequence(Table.INSTALL_UI_SEQUENCE).filter(action -> { + return includeActions.contains(action.action()); + }).sorted(Comparator.comparing(Action::sequence)).toList(); + + // Custom jpackage dialogs. + var jpackageDialogs = Set.of("InstallDirNotEmptyDlg", "ShortcutPromptDlg"); + + var includeControls = Set.of("Next", "Back"); + var controlEvents = rows(Table.CONTROL_EVENT).map(row -> { + return new ControlEvent( + row.apply("Dialog_"), + row.apply("Control_"), + row.apply("Event"), + row.apply("Argument"), + row.apply("Condition"), + Integer.parseInt(row.apply("Ordering"))); + }).filter(controlEvent -> { + if (jpackageDialogs.contains(controlEvent.dialog())) { + // Include controls of all custom jpackage dialogs. + return true; + } + + if (controlEvent.ordering() >= 6) { + // jpackage assumes the standard WiX UI doesn't define control events + // for dialog sequences it alters with the order higher than 6. + // Include all such items. + + if (includeControls.contains(controlEvent.control())) { + // Include only specific controls that jpackage alters. + return true; + } + } + + return false; + }).sorted(Comparator.comparing(ControlEvent::dialog) + .thenComparing(ControlEvent::control) + .thenComparing(ControlEvent::event) + .thenComparing(ControlEvent::argument) + .thenComparing(ControlEvent::condition) + .thenComparing(Comparator.comparingInt(ControlEvent::ordering))).toList(); + + return new UIAlterations(actions, controlEvents); + } + record Shortcut(Path path, Path target, Path workDir) { Shortcut { @@ -148,6 +196,49 @@ final class MsiDatabase { } } + public record Action(String action, String condition, int sequence) { + public Action { + Objects.requireNonNull(action); + Objects.requireNonNull(condition); + } + } + + public record ControlEvent( + String dialog, + String control, + String event, + String argument, + String condition, + int ordering) { + + public ControlEvent { + Objects.requireNonNull(dialog); + Objects.requireNonNull(control); + Objects.requireNonNull(event); + Objects.requireNonNull(argument); + Objects.requireNonNull(condition); + } + } + + public record UIAlterations(Collection installUISequence, Collection controlEvents) { + + public UIAlterations { + Objects.requireNonNull(installUISequence); + } + } + + private Stream actionSequence(Table tableName) { + return rows(tableName).map(row -> { + return new Action(row.apply("Action"), row.apply("Condition"), Integer.parseInt(row.apply("Sequence"))); + }); + } + + private Stream> rows(Table tableName) { + return Optional.ofNullable(tables.get(tableName)).stream().flatMap(table -> { + return IntStream.range(0, table.rowCount()).mapToObj(table::row); + }); + } + private Path directoryPath(String directoryId) { var table = tables.get(Table.DIRECTORY); Path result = null; @@ -339,20 +430,28 @@ final class MsiDatabase { var columns = headerLines.get(0).split("\t"); - var header = headerLines.get(2).split("\t", 4); - if (header.length == 3) { - if (Pattern.matches("^[1-9]\\d+$", header[0])) { - charset = Charset.forName(header[0]); - } else { - throw new IllegalArgumentException(String.format( - "Unexpected charset name [%s] in [%s] file", header[0], idtFile)); - } - } else if (header.length != 2) { + int tableNameIdx; + + var header = headerLines.get(2).split("\t"); + if (Pattern.matches("^[1-9]\\d+$", header[0])) { + charset = Charset.forName(header[0]); + tableNameIdx = 1; + } else { + tableNameIdx = 0; + } + + if (header.length < (tableNameIdx + 2)) { throw new IllegalArgumentException(String.format( "Unexpected number of fields (%d) in the 3rd line of [%s] file", header.length, idtFile)); } + var tableName = header[tableNameIdx]; + List primaryKeys = Arrays.asList(header).subList(tableNameIdx + 1, header.length); + + TKit.trace(String.format("Table in [%s] file: charset=%s; name=%s; primary keys=%s", + idtFile, charset, tableName, primaryKeys)); + return new IdtFileHeader(charset, List.of(columns)); } catch (IOException ex) { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageType.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageType.java index 085e782ea40..df020d39fc8 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageType.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageType.java @@ -48,16 +48,22 @@ public enum PackageType { LINUX_RPM(".rpm", OperatingSystem.LINUX), MAC_DMG(".dmg", OperatingSystem.MACOS), MAC_PKG(".pkg", OperatingSystem.MACOS), - IMAGE; + IMAGE(OperatingSystem.current()), + WIN_IMAGE(OperatingSystem.WINDOWS), + LINUX_IMAGE(OperatingSystem.LINUX), + MAC_IMAGE(OperatingSystem.MACOS), + ; - PackageType() { + PackageType(OperatingSystem os) { + this.os = Objects.requireNonNull(os); type = "app-image"; suffix = null; - supported = true; - enabled = true; + supported = (os == OperatingSystem.current()); + enabled = supported; } PackageType(String packageName, String bundleSuffix, OperatingSystem os) { + this.os = Objects.requireNonNull(os); type = Objects.requireNonNull(packageName); suffix = Objects.requireNonNull(bundleSuffix); supported = isSupported(new BundlingOperationDescriptor(os, type)); @@ -88,10 +94,29 @@ public enum PackageType { return enabled; } + public boolean isAppImage() { + return type.equals(IMAGE.type); + } + + public boolean isNative() { + return !isAppImage(); + } + public String getType() { return type; } + public OperatingSystem os() { + return os; + } + + public static PackageType appImageForOS(OperatingSystem os) { + Objects.requireNonNull(os); + return Stream.of(LINUX_IMAGE, MAC_IMAGE, WIN_IMAGE).filter(type -> { + return type.os() == os; + }).findFirst().orElseThrow(); + } + public static RuntimeException throwSkippedExceptionIfNativePackagingUnavailable() { if (NATIVE.stream().noneMatch(PackageType::isSupported)) { TKit.throwSkippedException("None of the native packagers supported in this environment"); @@ -115,6 +140,7 @@ public enum PackageType { return new LinkedHashSet<>(List.of(types)); } + private final OperatingSystem os; private final String type; private final String suffix; private final boolean enabled; @@ -126,6 +152,10 @@ public enum PackageType { public static final Set NATIVE = Stream.of(LINUX, WINDOWS, MAC) .flatMap(Collection::stream).collect(Collectors.toUnmodifiableSet()); + public static final Set ALL_LINUX = orderedSet(LINUX_IMAGE, LINUX_DEB, LINUX_RPM); + public static final Set ALL_WINDOWS = orderedSet(WIN_IMAGE, WIN_MSI, WIN_EXE); + public static final Set ALL_MAC = orderedSet(MAC_IMAGE, MAC_DMG, MAC_PKG); + private static final class Inner { private static final Set DISABLED_PACKAGERS = Optional.ofNullable( TKit.tokenizeConfigProperty("disabledPackagers")).orElse( diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PathDeletionPreventer.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PathDeletionPreventer.java new file mode 100644 index 00000000000..d16b63d9c69 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PathDeletionPreventer.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test; + +import java.io.Closeable; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileLock; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.PosixFilePermission; +import java.util.Objects; +import java.util.Set; +import java.util.function.Supplier; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.SetBuilder; + +/** + * Path deletion preventer. Encapsulates platform-specifics of how to make a + * file or a directory non-deletable. + *

+ * Implementation should be sufficient to make {@code Files#delete(Path)} + * applied to the path protected from deletion throw. + */ +public sealed interface PathDeletionPreventer { + + enum Implementation { + /** + * Uses Java file lock to prevent deletion of a file. + * Works on Windows. Doesn't work on Linux and macOS. + */ + FILE_CHANNEL_LOCK, + + /** + * Removes write permission from a non-empty directory to prevent its deletion. + * Works on Linux and macOS. Doesn't work on Windows. + */ + READ_ONLY_NON_EMPTY_DIRECTORY, + ; + } + + Implementation implementation(); + + Closeable preventPathDeletion(Path path) throws IOException; + + enum FileChannelLockPathDeletionPreventer implements PathDeletionPreventer { + INSTANCE; + + @Override + public Implementation implementation() { + return Implementation.FILE_CHANNEL_LOCK; + } + + @Override + public Closeable preventPathDeletion(Path path) throws IOException { + return new UndeletablePath(path); + } + + private static final class UndeletablePath implements Closeable { + + UndeletablePath(Path file) throws IOException { + var fos = new FileOutputStream(Objects.requireNonNull(file).toFile()); + boolean lockCreated = false; + try { + this.lock = fos.getChannel().lock(); + this.fos = fos; + lockCreated = true; + } finally { + if (!lockCreated) { + fos.close(); + } + } + } + + @Override + public void close() throws IOException { + try { + lock.close(); + } finally { + fos.close(); + } + } + + private final FileOutputStream fos; + private final FileLock lock; + } + } + + enum ReadOnlyDirectoryPathDeletionPreventer implements PathDeletionPreventer { + INSTANCE; + + @Override + public Implementation implementation() { + return Implementation.READ_ONLY_NON_EMPTY_DIRECTORY; + } + + @Override + public Closeable preventPathDeletion(Path path) throws IOException { + return new UndeletablePath(path); + } + + private static final class UndeletablePath implements Closeable { + + UndeletablePath(Path dir) throws IOException { + this.dir = Objects.requireNonNull(dir); + + // Deliberately don't use Files#createDirectories() as don't want to create missing directories. + try { + Files.createDirectory(dir); + Files.createFile(dir.resolve("empty")); + } catch (FileAlreadyExistsException ex) { + } + + perms = Files.getPosixFilePermissions(dir); + if (perms.contains(PosixFilePermission.OWNER_WRITE)) { + Files.setPosixFilePermissions(dir, SetBuilder.build() + .add(perms) + .remove(PosixFilePermission.OWNER_WRITE) + .emptyAllowed(true) + .create()); + } + } + + @Override + public void close() throws IOException { + if (perms.contains(PosixFilePermission.OWNER_WRITE)) { + Files.setPosixFilePermissions(dir, perms); + } + } + + private final Path dir; + private final Set perms; + } + } + + static final PathDeletionPreventer DEFAULT = new Supplier() { + + @Override + public PathDeletionPreventer get() { + switch (OperatingSystem.current()) { + case WINDOWS -> { + return FileChannelLockPathDeletionPreventer.INSTANCE; + } + default -> { + return ReadOnlyDirectoryPathDeletionPreventer.INSTANCE; + } + } + } + + }.get(); +} diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java index 3d7ac490350..46425ceccbd 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,6 +21,7 @@ * questions. */ package jdk.jpackage.test; + import static jdk.jpackage.test.AdditionalLauncher.getAdditionalLauncherProperties; import java.nio.file.Path; @@ -66,8 +67,13 @@ final class PropertyFinder { } static Finder nop() { + return of(Optional.empty()); + } + + static Finder of(Optional v) { + Objects.requireNonNull(v); return target -> { - return Optional.empty(); + return v; }; } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java index 88d11d75f45..04b828677ca 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java @@ -37,7 +37,6 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; -import java.nio.file.StandardCopyOption; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; @@ -77,6 +76,9 @@ import jdk.jpackage.internal.util.function.ThrowingUnaryOperator; public final class TKit { + private static final ScopedValue STATE = ScopedValue.newInstance(); + private static final State DEFAULT_STATE = State.build().initDefaults().mutable(false).create(); + public static final Path TEST_SRC_ROOT = Functional.identity(() -> { Path root = Path.of(System.getProperty("test.src")); @@ -128,6 +130,15 @@ public final class TKit { } } + public static void withOperatingSystem(ThrowingRunnable action, OperatingSystem os) { + Objects.requireNonNull(action); + Objects.requireNonNull(os); + + withState(action, stateBuilder -> { + stateBuilder.os(os); + }); + } + public static void withState(ThrowingRunnable action, Consumer stateBuilderMutator) { Objects.requireNonNull(action); Objects.requireNonNull(stateBuilderMutator); @@ -233,21 +244,25 @@ public final class TKit { } public static boolean isWindows() { - return OperatingSystem.isWindows(); + return TKit.state().os == OperatingSystem.WINDOWS; } public static boolean isOSX() { - return OperatingSystem.isMacOS(); + return TKit.state().os == OperatingSystem.MACOS; } public static boolean isLinux() { - return OperatingSystem.isLinux(); + return TKit.state().os == OperatingSystem.LINUX; } public static boolean isLinuxAPT() { return isLinux() && Files.exists(Path.of("/usr/bin/apt-get")); } + public static boolean isMockingOperatingSystem() { + return TKit.state().os != OperatingSystem.current(); + } + private static String addTimestamp(String msg) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); Date time = new Date(System.currentTimeMillis()); @@ -590,25 +605,6 @@ public final class TKit { return JtregSkippedExceptionClass.INSTANCE.isInstance(t); } - public static Path createRelativePathCopy(final Path file) { - Path fileCopy = ThrowingSupplier.toSupplier(() -> { - Path localPath = createTempFile(file.getFileName()); - Files.copy(file, localPath, StandardCopyOption.REPLACE_EXISTING); - return localPath; - }).get().toAbsolutePath().normalize(); - - final Path basePath = Path.of(".").toAbsolutePath().normalize(); - try { - return basePath.relativize(fileCopy); - } catch (IllegalArgumentException ex) { - // May happen on Windows: java.lang.IllegalArgumentException: 'other' has different root - trace(String.format("Failed to relativize [%s] at [%s]", fileCopy, - basePath)); - printStackTrace(ex); - } - return file; - } - public static void waitForFileCreated(Path fileToWaitFor, Duration timeout, Duration afterCreatedTimeout) throws IOException { waitForFileCreated(fileToWaitFor, timeout); @@ -1314,6 +1310,7 @@ public final class TKit { public static final class State { private State( + OperatingSystem os, TestInstance currentTest, PrintStream out, PrintStream err, @@ -1323,10 +1320,12 @@ public final class TKit { boolean verboseJPackage, boolean verboseTestSetup) { + Objects.requireNonNull(os); Objects.requireNonNull(out); Objects.requireNonNull(err); Objects.requireNonNull(properties); + this.os = os; this.currentTest = currentTest; this.out = out; this.err = err; @@ -1371,6 +1370,7 @@ public final class TKit { static final class Builder { Builder initDefaults() { + os = null; currentTest = null; out = System.out; err = System.err; @@ -1403,6 +1403,7 @@ public final class TKit { } Builder initFrom(State state) { + os = state.os; currentTest = state.currentTest; out = state.out; err = state.err; @@ -1418,6 +1419,11 @@ public final class TKit { return this; } + Builder os(OperatingSystem v) { + os = v; + return this; + } + Builder currentTest(TestInstance v) { currentTest = v; return this; @@ -1449,6 +1455,7 @@ public final class TKit { State create() { return new State( + Optional.ofNullable(os).orElseGet(OperatingSystem::current), currentTest, out, err, @@ -1459,6 +1466,7 @@ public final class TKit { verboseTestSetup); } + private OperatingSystem os; private TestInstance currentTest; private PrintStream out; private PrintStream err; @@ -1474,6 +1482,7 @@ public final class TKit { } + private OperatingSystem os; private final TestInstance currentTest; private final PrintStream out; private final PrintStream err; @@ -1486,8 +1495,4 @@ public final class TKit { private final boolean verboseJPackage; private final boolean verboseTestSetup; } - - - private static final ScopedValue STATE = ScopedValue.newInstance(); - private static final State DEFAULT_STATE = State.build().initDefaults().mutable(false).create(); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index c7b55ed1de7..98e9c4bfe61 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -276,6 +276,11 @@ public class WindowsHelper { return MsiDatabaseCache.INSTANCE.findProperty(cmd.outputBundle(), propertyName).orElseThrow(); } + public static MsiDatabase.UIAlterations getUIAlterations(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.WIN_MSI); + return MsiDatabaseCache.INSTANCE.uiAlterations(cmd.outputBundle()); + } + static Collection getMsiShortcuts(JPackageCommand cmd) { cmd.verifyIsOfType(PackageType.WIN_MSI); return MsiDatabaseCache.INSTANCE.listShortcuts(cmd.outputBundle()); @@ -572,6 +577,10 @@ public class WindowsHelper { return ensureTables(msiPath, MsiDatabase.Table.LIST_SHORTCUTS_REQUIRED_TABLES).listShortcuts(); } + MsiDatabase.UIAlterations uiAlterations(Path msiPath) { + return ensureTables(msiPath, MsiDatabase.Table.UI_ALTERATIONS_REQUIRED_TABLES).uiAlterations(); + } + MsiDatabase ensureTables(Path msiPath, Set tableNames) { Objects.requireNonNull(msiPath); try { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/CommandAction.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/CommandAction.java index d9ab38e006a..c4899a5376f 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/CommandAction.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/CommandAction.java @@ -60,6 +60,36 @@ public interface CommandAction { public MockIllegalStateException unexpectedArguments() { return new MockIllegalStateException(String.format("Unexpected arguments: %s", args)); } + + public Context shift(int count) { + if (count < 0) { + throw new IllegalArgumentException(); + } else if (count == 0) { + return this; + } else { + return new Context(out, err, args.subList(Integer.min(count, args.size()), args.size())); + } + } + + public Context shift() { + return shift(1); + } + + public void printlnOut(Object obj) { + out.println(obj); + } + + public void printlnOut(String str) { + out.println(str); + } + + public void printlnErr(Object obj) { + err.println(obj); + } + + public void printlnErr(String str) { + err.println(str); + } } /** diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/MockIllegalStateException.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/MockIllegalStateException.java index 1817587364a..4656e1d4f7b 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/MockIllegalStateException.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/mock/MockIllegalStateException.java @@ -22,13 +22,15 @@ */ package jdk.jpackage.test.mock; +import java.util.Objects; + /** * Indicates command mock internal error. */ public final class MockIllegalStateException extends IllegalStateException { public MockIllegalStateException(String msg) { - super(msg); + super(Objects.requireNonNull(msg)); } private static final long serialVersionUID = 1L; diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/JPackageMockUtils.java similarity index 76% rename from test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java rename to test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/JPackageMockUtils.java index e88077a6c9d..085102390ff 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/JPackageMockUtils.java @@ -21,18 +21,27 @@ * questions. */ -package jdk.jpackage.internal; +package jdk.jpackage.test.stdmock; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; import java.io.PrintWriter; +import java.lang.reflect.Constructor; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; +import java.util.function.Supplier; import java.util.function.UnaryOperator; import java.util.spi.ToolProvider; +import java.util.stream.Collectors; import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.Executor; +import jdk.jpackage.internal.ExecutorFactory; +import jdk.jpackage.internal.Globals; +import jdk.jpackage.internal.ObjectFactory; import jdk.jpackage.internal.cli.CliBundlingEnvironment; import jdk.jpackage.internal.cli.Main; import jdk.jpackage.internal.util.function.ExceptionBox; @@ -41,11 +50,11 @@ import jdk.jpackage.test.mock.ToolProviderCommandMock; import jdk.jpackage.test.mock.VerbatimCommandMock; /** - * Bridges "jdk.jpackage.internal" and "jdk.jpackage.test.mock" packages. + * Utilities to create jpackage mock. */ -public final class MockUtils { +public final class JPackageMockUtils { - private MockUtils() { + private JPackageMockUtils() { } public static JPackageToolProviderBuilder buildJPackage() { @@ -58,30 +67,23 @@ public final class MockUtils { return createJPackageToolProvider(os(), createObjectFactory()); } - public Consumer createGlobalsMutator() { - var objectFactory = createObjectFactory(); - return globals -> { - globals.objectFactory(objectFactory); - }; - } - public void applyToGlobals() { - createGlobalsMutator().accept(Globals.instance()); + Globals.instance().objectFactory(createObjectFactory()); } - ExecutorFactory createExecutorFactory() { - var commandMocksExecutorFactory = Optional.ofNullable(script).map(MockUtils::withCommandMocks).map(mapper -> { + public ExecutorFactory createExecutorFactory() { + var commandMocksExecutorFactory = Optional.ofNullable(script).map(JPackageMockUtils::withCommandMocks).map(mapper -> { return mapper.apply(ExecutorFactory.DEFAULT); }).orElse(ExecutorFactory.DEFAULT); - var recordingExecutorFactory = Optional.ofNullable(listener).map(MockUtils::withCommandListener).map(mapper -> { + var recordingExecutorFactory = Optional.ofNullable(listener).map(JPackageMockUtils::withCommandListener).map(mapper -> { return mapper.apply(commandMocksExecutorFactory); }).orElse(commandMocksExecutorFactory); return recordingExecutorFactory; } - ObjectFactory createObjectFactory() { + public ObjectFactory createObjectFactory() { var executorFactory = createExecutorFactory(); if (executorFactory == ExecutorFactory.DEFAULT) { return ObjectFactory.DEFAULT; @@ -125,6 +127,31 @@ public final class MockUtils { return createJPackageToolProvider(OperatingSystem.current(), script); } + public static Map> availableBundlingEnvironments() { + return Map.ofEntries( + Map.entry(OperatingSystem.WINDOWS, "WinBundlingEnvironment"), + Map.entry(OperatingSystem.LINUX, "LinuxBundlingEnvironment"), + Map.entry(OperatingSystem.MACOS, "MacBundlingEnvironment") + ).entrySet().stream().map(e -> { + Constructor ctor; + try { + ctor = Class.forName("jdk.jpackage.internal." + e.getValue()).getConstructor(); + } catch (NoSuchMethodException | SecurityException ex) { + throw ExceptionBox.toUnchecked(ex); + } catch (ClassNotFoundException ex) { + return Optional.>>empty(); + } + return Optional.of(Map.entry(e.getKey(), toSupplier(() -> { + return (CliBundlingEnvironment)ctor.newInstance(); + }))); + }).flatMap(Optional::stream).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + public static CliBundlingEnvironment createBundlingEnvironment(OperatingSystem os) { + Objects.requireNonNull(os); + return Objects.requireNonNull(availableBundlingEnvironments().get(os)).get(); + } + private static UnaryOperator withCommandListener(Consumer> listener) { Objects.requireNonNull(listener); return executorFactory -> { @@ -180,41 +207,13 @@ public final class MockUtils { }; } - public static CliBundlingEnvironment createBundlingEnvironment(OperatingSystem os) { - Objects.requireNonNull(os); - - String bundlingEnvironmentClassName; - switch (os) { - case WINDOWS -> { - bundlingEnvironmentClassName = "WinBundlingEnvironment"; - } - case LINUX -> { - bundlingEnvironmentClassName = "LinuxBundlingEnvironment"; - } - case MACOS -> { - bundlingEnvironmentClassName = "MacBundlingEnvironment"; - } - default -> { - throw new IllegalArgumentException(); - } - } - - return toSupplier(() -> { - var ctor = Class.forName(String.join(".", - DefaultBundlingEnvironment.class.getPackageName(), - bundlingEnvironmentClassName - )).getConstructor(); - return (CliBundlingEnvironment)ctor.newInstance(); - }).get(); - } - - static ToolProvider createJPackageToolProvider(OperatingSystem os, ObjectFactory of) { + private static ToolProvider createJPackageToolProvider(OperatingSystem os, ObjectFactory of) { Objects.requireNonNull(os); Objects.requireNonNull(of); - var impl = new Main.Provider(DefaultBundlingEnvironment.runOnce(() -> { + var impl = new Main.Provider(runOnce(() -> { return createBundlingEnvironment(os); - })); + }), os); return new ToolProvider() { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSecurityMock.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSecurityMock.java new file mode 100644 index 00000000000..fe9a67f1889 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSecurityMock.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test.stdmock; + +import java.nio.file.Path; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import jdk.jpackage.test.MacSign; +import jdk.jpackage.test.MacSign.CertificateRequest; +import jdk.jpackage.test.MacSign.ResolvedKeychain; +import jdk.jpackage.test.mock.CommandAction; +import jdk.jpackage.test.mock.MockIllegalStateException; + +/** + * Mocks /usr/bin/security command. + */ +final class MacSecurityMock implements CommandAction { + + MacSecurityMock(MacSignMockUtils.SignEnv signEnv) { + Objects.requireNonNull(signEnv); + + var keychains = signEnv.keychains(); + + var stdUserKeychains = Stream.of(StandardKeychain.values()).map(StandardKeychain::keychainName).filter(name -> { + // Add standard keychain unless it is defined in the signing environment. + return keychains.stream().noneMatch(keychain -> { + return keychain.name().equals(name); + }); + }).map(name -> { + // Assume the standard keychain is empty. + return ResolvedKeychain.createMock(name, Map.of()); + }); + + allKnownKeychains = Stream.of( + stdUserKeychains, + keychains.stream() + ).flatMap(x -> x).collect(Collectors.toUnmodifiableMap(ResolvedKeychain::name, x -> x)); + + currentKeychains.addAll(Stream.of(StandardKeychain.values()) + .map(StandardKeychain::keychainName) + .map(allKnownKeychains::get) + .map(Objects::requireNonNull).toList()); + } + + @Override + public Optional run(Context context) { + switch (context.args().getFirst()) { + case "list-keychains" -> { + listKeychains(context.shift()); + return Optional.of(0); + } + case "find-certificate" -> { + findCertificate(context.shift()); + return Optional.of(0); + } + default -> { + throw context.unexpectedArguments(); + } + } + } + + private void listKeychains(Context context) { + if (context.args().getFirst().equals("-s")) { + currentKeychains.clear(); + currentKeychains.addAll(context.shift().args().stream().map(name -> { + return Optional.ofNullable(allKnownKeychains.get(name)).orElseThrow(() -> { + throw new MockIllegalStateException(String.format("Unknown keychain name: %s", name)); + }); + }).toList()); + } else if (context.args().isEmpty()) { + currentKeychains.stream().map(keychain -> { + return String.format(" \"%s\"", keychain.name()); + }).forEach(context::printlnOut); + } else { + throw context.unexpectedArguments(); + } + } + + private void findCertificate(Context context) { + + var args = new ArrayList<>(context.args()); + for (var mandatoryArg : List.of("-p", "-a")) { + if (!args.remove(mandatoryArg)) { + throw context.unexpectedArguments(); + } + } + + var certNameFilter = context.findOptionValue("-c").map(certNameSubstr -> { + + // Remove option name and its value. + var idx = args.indexOf("-c"); + args.remove(idx); + args.remove(idx); + + Predicate> pred = e -> { + return e.getKey().name().contains(certNameSubstr); + }; + return pred; + }); + + Stream keychains; + if (args.isEmpty()) { + keychains = currentKeychains.stream(); + } else { + // Remaining arguments must be keychain names. + keychains = args.stream().map(keychainName -> { + return Optional.ofNullable(allKnownKeychains.get(keychainName)).orElseThrow(() -> { + throw new MockIllegalStateException(String.format("Unknown keychain name: %s", keychainName)); + }); + }); + } + + var certStream = keychains.flatMap(keychain -> { + return keychain.mapCertificateRequests().entrySet().stream(); + }); + + if (certNameFilter.isPresent()) { + certStream = certStream.filter(certNameFilter.get()); + } + + certStream.map(Map.Entry::getValue).map(MacSign::formatX509Certificate).forEach(formattedCert -> { + context.out().print(formattedCert); + }); + } + + // Keep the order of the items as the corresponding keychains appear + // in the output of the "/usr/bin/security list-keychains" command. + private enum StandardKeychain { + USER_KEYCHAIN { + @Override + String keychainName() { + return Path.of(System.getProperty("user.home")).resolve("Library/Keychains/login.keychain-db").toString(); + } + }, + SYSTEM_KEYCHAIN { + @Override + String keychainName() { + return "/Library/Keychains/System.keychain"; + } + }, + ; + + abstract String keychainName(); + } + + private final List currentKeychains = new ArrayList(); + private final Map allKnownKeychains; +} diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSignMockUtils.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSignMockUtils.java new file mode 100644 index 00000000000..164261a6000 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/stdmock/MacSignMockUtils.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.test.stdmock; + +import static jdk.jpackage.internal.util.function.ExceptionBox.toUnchecked; +import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction; +import static jdk.jpackage.internal.util.function.ThrowingRunnable.toRunnable; +import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; +import jdk.jpackage.internal.util.function.ExceptionBox; +import jdk.jpackage.test.MacSign.CertificateRequest; +import jdk.jpackage.test.MacSign.KeychainWithCertsSpec; +import jdk.jpackage.test.MacSign.ResolvedKeychain; +import jdk.jpackage.test.mock.CommandActionSpec; +import jdk.jpackage.test.mock.CommandActionSpecs; +import jdk.jpackage.test.mock.CommandMockSpec; + + +/** + * Utilities to create macOS signing tool mocks. + */ +public final class MacSignMockUtils { + + private MacSignMockUtils() { + } + + public static Map resolveCertificateRequests( + Collection certificateRequests) { + Objects.requireNonNull(certificateRequests); + + var caKeys = createKeyPair(); + + Function resolver = toFunction(certRequest -> { + var builder = new CertificateBuilder() + .setSubjectName("CN=" + certRequest.name()) + .setPublicKey(caKeys.getPublic()) + .setSerialNumber(BigInteger.ONE) + .addSubjectKeyIdExt(caKeys.getPublic()) + .addAuthorityKeyIdExt(caKeys.getPublic()); + + Instant from; + Instant to; + if (certRequest.expired()) { + from = LocalDate.now().minusDays(10).atStartOfDay(ZoneId.systemDefault()).toInstant(); + to = from.plus(Duration.ofDays(1)); + } else { + from = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant(); + to = from.plus(Duration.ofDays(certRequest.days())); + } + builder.setValidity(Date.from(from), Date.from(to)); + + return builder.build(null, caKeys.getPrivate()); + }); + + return certificateRequests.stream() + .distinct() + .collect(Collectors.toUnmodifiableMap(x -> x, resolver)); + } + + public static Map resolveCertificateRequests( + CertificateRequest... certificateRequests) { + return resolveCertificateRequests(List.of(certificateRequests)); + } + + public static final class SignEnv { + + public SignEnv(List spec) { + Objects.requireNonNull(spec); + + spec.stream().map(keychain -> { + return keychain.keychain().name(); + }).collect(Collectors.toMap(x -> x, x -> x, (a, b) -> { + throw new IllegalArgumentException(String.format("Multiple keychains with the same name: %s", a)); + })); + + this.spec = List.copyOf(spec); + this.env = resolveCertificateRequests( + spec.stream().map(KeychainWithCertsSpec::certificateRequests).flatMap(Collection::stream).toList()); + } + + public SignEnv(KeychainWithCertsSpec... spec) { + this(List.of(spec)); + } + + public List keychains() { + return spec.stream().map(ResolvedKeychain::new).map(keychain -> { + return keychain.toMock(env); + }).toList(); + } + + public Map env() { + return env; + } + + private final Map env; + private final List spec; + } + + public static CommandMockSpec securityMock(SignEnv signEnv) { + var action = CommandActionSpec.create("/usr/bin/security", new MacSecurityMock(signEnv)); + return new CommandMockSpec(action.description(), CommandActionSpecs.build().action(action).create()); + } + + private static KeyPair createKeyPair() { + try { + var kpg = KeyPairGenerator.getInstance("RSA"); + return kpg.generateKeyPair(); + } catch (NoSuchAlgorithmException ex) { + throw ExceptionBox.toUnchecked(ex); + } + } + + // + // Reflection proxy for jdk.test.lib.security.CertificateBuilder class. + // + // Can't use it directly because it is impossible to cherry-pick this class from the JDK test lib in JUnit tests due to limitations of jtreg. + // + // Shared jpackage JUnit tests don't require "jdk.jpackage.test.stdmock", but they depend on "jdk.jpackage.test" package. + // Source code for these two packages resides in the same directory tree, so jtreg will pull in classes from both packages for the jpackage JUnit tests. + // Static dependency on jdk.test.lib.security.CertificateBuilder class will force pulling in the entire JDK test lib, because of jtreg limitations. + // + // Use dynamic dependency as a workaround. Tests that require jdk.test.lib.security.CertificateBuilder class, should have + // + // /* + // * ... + // * @library /test/lib + // * @build jdk.test.lib.security.CertificateBuilder + // */ + // + // in their declarations. They also should have + // + // --add-exports java.base/sun.security.x509=ALL-UNNAMED + // --add-exports java.base/sun.security.util=ALL-UNNAMED + // + // on javac and java command lines. + // + private static final class CertificateBuilder { + + CertificateBuilder() { + instance = toSupplier(ctor::newInstance).get(); + } + + CertificateBuilder setSubjectName(String v) { + toRunnable(() -> { + setSubjectName.invoke(instance, v); + }).run(); + return this; + } + + CertificateBuilder setPublicKey(PublicKey v) { + toRunnable(() -> { + setPublicKey.invoke(instance, v); + }).run(); + return this; + } + + CertificateBuilder setSerialNumber(BigInteger v) { + toRunnable(() -> { + setSerialNumber.invoke(instance, v); + }).run(); + return this; + } + + CertificateBuilder addSubjectKeyIdExt(PublicKey v) { + toRunnable(() -> { + addSubjectKeyIdExt.invoke(instance, v); + }).run(); + return this; + } + + CertificateBuilder addAuthorityKeyIdExt(PublicKey v) { + toRunnable(() -> { + addAuthorityKeyIdExt.invoke(instance, v); + }).run(); + return this; + } + + CertificateBuilder setValidity(Date from, Date to) { + toRunnable(() -> { + setValidity.invoke(instance, from, to); + }).run(); + return this; + } + + X509Certificate build(X509Certificate issuerCert, PrivateKey issuerKey) throws IOException, CertificateException { + try { + return (X509Certificate)toSupplier(() -> { + return build.invoke(instance, issuerCert, issuerKey); + }).get(); + } catch (ExceptionBox box) { + switch (ExceptionBox.unbox(box)) { + case IOException ex -> { + throw ex; + } + case CertificateException ex -> { + throw ex; + } + default -> { + throw box; + } + } + } + } + + private final Object instance; + + private static final Constructor ctor; + private static final Method setSubjectName; + private static final Method setPublicKey; + private static final Method setSerialNumber; + private static final Method addSubjectKeyIdExt; + private static final Method addAuthorityKeyIdExt; + private static final Method setValidity; + private static final Method build; + + static { + try { + var certificateBuilderClass = Class.forName("jdk.test.lib.security.CertificateBuilder"); + + ctor = certificateBuilderClass.getConstructor(); + + setSubjectName = certificateBuilderClass.getMethod("setSubjectName", String.class); + + setPublicKey = certificateBuilderClass.getMethod("setPublicKey", PublicKey.class); + + setSerialNumber = certificateBuilderClass.getMethod("setSerialNumber", BigInteger.class); + + addSubjectKeyIdExt = certificateBuilderClass.getMethod("addSubjectKeyIdExt", PublicKey.class); + + addAuthorityKeyIdExt = certificateBuilderClass.getMethod("addAuthorityKeyIdExt", PublicKey.class); + + setValidity = certificateBuilderClass.getMethod("setValidity", Date.class, Date.class); + + build = certificateBuilderClass.getMethod("build", X509Certificate.class, PrivateKey.class); + + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) { + throw toUnchecked(ex); + } + } + } +} diff --git a/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxPackageArchTest.java b/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxPackageArchTest.java index baf03a32142..d1332fc59e5 100644 --- a/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxPackageArchTest.java +++ b/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxPackageArchTest.java @@ -37,6 +37,7 @@ import jdk.jpackage.test.mock.CommandActionSpecs; import jdk.jpackage.test.mock.CommandMockExit; import jdk.jpackage.test.mock.CommandMockSpec; import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -137,7 +138,7 @@ public class LinuxPackageArchTest { Globals.main(() -> { - MockUtils.buildJPackage().script(script).applyToGlobals(); + JPackageMockUtils.buildJPackage().script(script).applyToGlobals(); Result arch = LinuxPackageArch.create(pkgType); diff --git a/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxSystemEnvironmentTest.java b/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxSystemEnvironmentTest.java index 8ff958491b1..5104dd1b252 100644 --- a/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxSystemEnvironmentTest.java +++ b/test/jdk/tools/jpackage/junit/linux/jdk.jpackage/jdk/jpackage/internal/LinuxSystemEnvironmentTest.java @@ -34,6 +34,7 @@ import jdk.jpackage.test.mock.CommandActionSpecs; import jdk.jpackage.test.mock.CommandMockExit; import jdk.jpackage.test.mock.CommandMockSpec; import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -86,7 +87,7 @@ public class LinuxSystemEnvironmentTest { Globals.main(() -> { - MockUtils.buildJPackage().script(script).applyToGlobals(); + JPackageMockUtils.buildJPackage().script(script).applyToGlobals(); var actual = LinuxSystemEnvironment.detectNativePackageType(); diff --git a/test/jdk/tools/jpackage/junit/linux/junit.java b/test/jdk/tools/jpackage/junit/linux/junit.java index 0fd337c812c..ba06cb30db7 100644 --- a/test/jdk/tools/jpackage/junit/linux/junit.java +++ b/test/jdk/tools/jpackage/junit/linux/junit.java @@ -36,9 +36,9 @@ * @requires (os.family == "linux") * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.mock.* + * @build jdk.jpackage.test.stdmock.* * @compile/module=jdk.jpackage -Xlint:all -Werror * jdk/jpackage/internal/LinuxSystemEnvironmentTest.java - * ../../share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java * @run junit jdk.jpackage/jdk.jpackage.internal.LinuxSystemEnvironmentTest */ @@ -57,8 +57,8 @@ * @requires (os.family == "linux") * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.mock.* + * @build jdk.jpackage.test.stdmock.* * @compile/module=jdk.jpackage -Xlint:all -Werror * jdk/jpackage/internal/LinuxPackageArchTest.java - * ../../share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java * @run junit jdk.jpackage/jdk.jpackage.internal.LinuxPackageArchTest */ diff --git a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/ActiveKeychainListTest.java b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/ActiveKeychainListTest.java new file mode 100644 index 00000000000..2ff5317e60d --- /dev/null +++ b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/ActiveKeychainListTest.java @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal; + +import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import jdk.jpackage.test.mock.CommandAction; +import jdk.jpackage.test.mock.CommandActionSpec; +import jdk.jpackage.test.mock.CommandActionSpecs; +import jdk.jpackage.test.mock.CommandMockSpec; +import jdk.jpackage.test.mock.MockIllegalStateException; +import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.stdmock.JPackageMockUtils; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class ActiveKeychainListTest { + + @ParameterizedTest + @CsvSource(value = { + "'','',''", + "a,'',a", + "'',a,a", + "a,a,a", + "abc,b,abc", + "abc,ba,abc", + "abc,bad,abcd", + "ac,b,acb" + }) + void test_ctor_and_createForPlatform(String initial, String requested, String current) throws IOException { + + var initialKeychains = parseKeychainList(initial); + var requestedKeychains = parseKeychainList(requested); + + var securityMock = new SecurityKeychainListMock(true); + initialKeychains.stream().map(Keychain::name).forEach(securityMock.keychainNames()::add); + + Globals.main(toSupplier(() -> { + securityMock.applyToGlobals(); + Globals.instance().setProperty(ActiveKeychainList.class, false); + + assertTrue(ActiveKeychainList.createForPlatform(requestedKeychains.toArray(Keychain[]::new)).isEmpty()); + + var akl = new ActiveKeychainList(List.copyOf(requestedKeychains)); + try (akl) { + assertEquals(initialKeychains, akl.restoreKeychains()); + assertEquals(requestedKeychains, akl.requestedKeychains()); + assertEquals(parseKeychainList(current), akl.currentKeychains()); + assertEquals(akl.currentKeychains(), securityMock.keychains()); + } + + assertEquals(initialKeychains, akl.restoreKeychains()); + assertEquals(requestedKeychains, akl.requestedKeychains()); + assertEquals(parseKeychainList(current), akl.currentKeychains()); + assertEquals(initialKeychains, securityMock.keychains()); + + return 0; + })); + } + + @ParameterizedTest + @CsvSource(value = { + "'','','',true", + "'','','',false", + + "a,'','',true", + "a,'',a,false", + + "'',a,a,true", + "'',a,a,false", + + "a,a,a,true", + "a,a,a,false", + + "abc,b,b,true", + "abc,b,abc,false", + + "abc,ba,ba,true", + "abc,ba,abc,false", + + "abc,bad,bad,true", + "abc,bad,abcd,false", + + "ac,b,b,true", + "ac,b,acb,false" + }) + void testCtorWithForced(String initial, String requested, String current, boolean forced) throws IOException { + + var initialKeychains = parseKeychainList(initial); + var requestedKeychains = parseKeychainList(requested); + + var securityMock = new SecurityKeychainListMock(forced); + securityMock.keychainNames().addAll(List.of("foo", "bar")); + + Globals.main(toSupplier(() -> { + securityMock.applyToGlobals(); + + var akl = new ActiveKeychainList(List.copyOf(requestedKeychains), List.copyOf(initialKeychains), forced); + try (akl) { + assertEquals(initialKeychains, akl.restoreKeychains()); + assertEquals(requestedKeychains, akl.requestedKeychains()); + assertEquals(parseKeychainList(current), akl.currentKeychains()); + assertEquals(akl.currentKeychains(), securityMock.keychains()); + } + + assertEquals(initialKeychains, akl.restoreKeychains()); + assertEquals(requestedKeychains, akl.requestedKeychains()); + assertEquals(parseKeychainList(current), akl.currentKeychains()); + assertEquals(initialKeychains, securityMock.keychains()); + + return 0; + })); + } + + @ParameterizedTest + @CsvSource(value = { + "'','',", + "a,'',", + "'',a,a", + "a,a,a", + "abc,b,abc", + "abc,ba,abc", + "abc,bad,abcd", + "ac,b,acb" + }) + void test_withKeychain(String initial, String requested, String current) throws IOException { + + var initialKeychains = parseKeychainList(initial); + var requestedKeychains = parseKeychainList(requested); + + for (boolean isRequired : List.of(true, false)) { + var securityMock = new SecurityKeychainListMock(true); + initialKeychains.stream().map(Keychain::name).forEach(securityMock.keychainNames()::add); + + Consumer> workload = keychains -> { + assertEquals(requestedKeychains, keychains); + if (isRequired && current != null) { + assertEquals(parseKeychainList(current), securityMock.keychains()); + } else { + assertEquals(initialKeychains, securityMock.keychains()); + } + }; + + Globals.main(toSupplier(() -> { + Globals.instance().setProperty(ActiveKeychainList.class, isRequired); + + securityMock.applyToGlobals(); + ActiveKeychainList.withKeychains(workload, requestedKeychains); + + assertEquals(initialKeychains, securityMock.keychains()); + + if (requestedKeychains.size() == 1) { + securityMock.applyToGlobals(); + ActiveKeychainList.withKeychain(keychain -> { + workload.accept(List.of(keychain)); + }, requestedKeychains.getFirst()); + + assertEquals(initialKeychains, securityMock.keychains()); + } + + return 0; + })); + } + } + + /** + * Mocks "/usr/bin/security list-keychain" command. + */ + record SecurityKeychainListMock(List keychainNames, boolean isReadAllowed) implements CommandAction { + + SecurityKeychainListMock { + Objects.requireNonNull(keychainNames); + } + + SecurityKeychainListMock(boolean isReadAllowed) { + this(new ArrayList<>(), isReadAllowed); + } + + List keychains() { + return keychainNames.stream().map(Keychain::new).toList(); + } + + void applyToGlobals() { + CommandActionSpec actionSpec = CommandActionSpec.create("/usr/bin/security", this); + + var script = Script.build() + .commandMockBuilderMutator(mockBuilder -> { + // Limit the number of times the mock can be executed. + // It should be one or twice. + // Once, when ActiveKeychainList is constructed such that it doesn't read + // the current active keychain list from the "/usr/bin/security" command, but takes it from the parameter. + // Twice, when ActiveKeychainList is constructed such that it read + // the current active keychain list from the "/usr/bin/security" command. + mockBuilder.repeat(isReadAllowed ? 2 : 1); + }) + // Replace "/usr/bin/security" with the mock bound to the keychain mock. + .map(new CommandMockSpec(actionSpec.description(), "security-list-keychain", CommandActionSpecs.build().action(actionSpec).create())) + .createLoop(); + + JPackageMockUtils.buildJPackage() + .script(script) + .listener(System.out::println) + .applyToGlobals(); + } + + @Override + public Optional run(Context context) throws Exception, MockIllegalStateException { + final var origContext = context; + + if (!context.args().getFirst().equals("list-keychains")) { + throw origContext.unexpectedArguments(); + } + + context = context.shift(); + + if (context.args().isEmpty()) { + if (isReadAllowed) { + keychainNames.stream().map(k -> { + return new StringBuilder().append('"').append(k).append('"').toString(); + }).forEach(context::printlnOut); + } else { + throw origContext.unexpectedArguments(); + } + } else if (context.args().getFirst().equals("-s")) { + keychainNames.clear(); + keychainNames.addAll(context.shift().args()); + } else { + throw origContext.unexpectedArguments(); + } + + return Optional.of(0); + } + } + + private static List parseKeychainList(String str) { + return str.chars().mapToObj(chr -> { + return new StringBuilder().append((char)chr).toString(); + }).map(Keychain::new).toList(); + } +} diff --git a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacApplicationBuilderTest.java b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacApplicationBuilderTest.java new file mode 100644 index 00000000000..559e8d53827 --- /dev/null +++ b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacApplicationBuilderTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal; + +import static jdk.jpackage.internal.MacPackagingPipeline.APPLICATION_LAYOUT; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import jdk.jpackage.internal.model.ApplicationLaunchers; +import jdk.jpackage.internal.model.ConfigException; +import jdk.jpackage.internal.model.Launcher; +import jdk.jpackage.internal.model.LauncherStartupInfo; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class MacApplicationBuilderTest { + + @ParameterizedTest + @CsvSource({ + "NAME,!fo#o,foo", + "NAME,bar,bar", + "MAIN_LAUNCHER_CLASSNAME,foo.b$ar.Hello,foo.bar", + "MAIN_LAUNCHER_CLASSNAME,Hello$2,Hello2", + "NAME,!#,", + }) + void testDerivedBundleIdentifier(ApplicationBuilderProperty type, String value, String expectedBundleIdentifier) { + + var builder = buildApplication(); + var macBuilder = new MacApplicationBuilder(builder); + + type.applyTo(value, builder, macBuilder); + + if (expectedBundleIdentifier != null) { + assertEquals(expectedBundleIdentifier, macBuilder.create().bundleIdentifier()); + } else { + var ex = assertThrowsExactly(ConfigException.class, macBuilder::create); + assertEquals(I18N.format("error.invalid-derived-bundle-identifier"), ex.getMessage()); + assertEquals(I18N.format("error.invalid-derived-bundle-identifier.advice"), ex.getAdvice()); + } + } + + private static ApplicationBuilder buildApplication() { + return new ApplicationBuilder().appImageLayout(APPLICATION_LAYOUT); + } + + enum ApplicationBuilderProperty { + NAME { + void applyTo(String value, ApplicationBuilder builder, MacApplicationBuilder macBuilder) { + builder.name(Objects.requireNonNull(value)); + } + }, + MAIN_LAUNCHER_CLASSNAME { + void applyTo(String value, ApplicationBuilder builder, MacApplicationBuilder macBuilder) { + var startupInfo = new LauncherStartupInfo.Stub(Objects.requireNonNull(value), List.of(), List.of(), List.of()); + var launcher = new Launcher.Stub( + startupInfo.simpleClassName(), + Optional.of(startupInfo), + List.of(), + false, + "", + Optional.empty(), + null, + Map.of()); + builder.launchers(new ApplicationLaunchers(launcher)); + } + } + ; + + abstract void applyTo(String value, ApplicationBuilder builder, MacApplicationBuilder macBuilder); + } +} diff --git a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgPackagerTest.java b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgPackagerTest.java index e5da383142a..3b71d53e2db 100644 --- a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgPackagerTest.java +++ b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgPackagerTest.java @@ -56,6 +56,7 @@ import jdk.jpackage.test.mock.CommandMockSpec; import jdk.jpackage.test.mock.MockIllegalStateException; import jdk.jpackage.test.mock.ScriptSpec; import jdk.jpackage.test.mock.ScriptSpecInDir; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -174,13 +175,12 @@ public class MacDmgPackagerTest { private static void runPackagingMock(Path workDir, MacDmgSystemEnvironment sysEnv) { - var app = new ApplicationBuilder() + var appBuilder = new ApplicationBuilder() .appImageLayout(MacPackagingPipeline.APPLICATION_LAYOUT) .runtimeBuilder(createRuntimeBuilder()) - .name("foo") - .create(); + .name("foo"); - var macApp = new MacApplicationBuilder(app).create(); + var macApp = new MacApplicationBuilder(appBuilder).create(); var macDmgPkg = new MacDmgPackageBuilder(new MacPackageBuilder(new PackageBuilder(macApp, MAC_DMG))).create(); @@ -240,7 +240,7 @@ public class MacDmgPackagerTest { var script = dir(Objects.requireNonNull(workDir)).create(); - ExecutorFactory executorFactory = MockUtils.buildJPackage() + ExecutorFactory executorFactory = JPackageMockUtils.buildJPackage() .script(script).listener(System.out::println).createExecutorFactory(); var objectFactory = ObjectFactory.build() @@ -406,14 +406,14 @@ public class MacDmgPackagerTest { } } - private final static BiConsumer> EXPAND_PATH = (path, sink) -> { + private static final BiConsumer> EXPAND_PATH = (path, sink) -> { do { sink.accept(path); path = path.getParent(); } while (path != null); }; - private final static List DMG_ICON_FILES = Stream.of( + private static final List DMG_ICON_FILES = Stream.of( ".VolumeIcon.icns", ".background/background.tiff" ).map(Path::of).collect(Collectors.toUnmodifiableList()); diff --git a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgSystemEnvironmentTest.java b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgSystemEnvironmentTest.java index de2b07e86a6..8e892106cb4 100644 --- a/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgSystemEnvironmentTest.java +++ b/test/jdk/tools/jpackage/junit/macosx/jdk.jpackage/jdk/jpackage/internal/MacDmgSystemEnvironmentTest.java @@ -32,11 +32,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import jdk.jpackage.internal.util.RetryExecutor; import jdk.jpackage.test.mock.CommandActionSpecs; import jdk.jpackage.test.mock.CommandMockExit; import jdk.jpackage.test.mock.CommandMockSpec; import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -143,7 +143,7 @@ public class MacDmgSystemEnvironmentTest { }).createSequence(); Globals.main(() -> { - MockUtils.buildJPackage().script(script).applyToGlobals(); + JPackageMockUtils.buildJPackage().script(script).applyToGlobals(); var actual = MacDmgSystemEnvironment.findSetFileUtility(); diff --git a/test/jdk/tools/jpackage/junit/macosx/junit.java b/test/jdk/tools/jpackage/junit/macosx/junit.java index c7fd2bc5f8d..55d309a5d7c 100644 --- a/test/jdk/tools/jpackage/junit/macosx/junit.java +++ b/test/jdk/tools/jpackage/junit/macosx/junit.java @@ -36,9 +36,9 @@ * @requires (os.family == "mac") * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.mock.* + * @build jdk.jpackage.test.stdmock.* * @compile/module=jdk.jpackage -Xlint:all -Werror * jdk/jpackage/internal/MacDmgSystemEnvironmentTest.java - * ../../share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java * @run junit jdk.jpackage/jdk.jpackage.internal.MacDmgSystemEnvironmentTest */ @@ -47,8 +47,27 @@ * @requires (os.family == "mac") * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.mock.* + * @build jdk.jpackage.test.stdmock.* * @compile/module=jdk.jpackage -Xlint:all -Werror * jdk/jpackage/internal/MacDmgPackagerTest.java - * ../../share/jdk.jpackage/jdk/jpackage/internal/MockUtils.java * @run junit jdk.jpackage/jdk.jpackage.internal.MacDmgPackagerTest */ + +/* @test + * @summary Test ActiveKeychainListTest + * @requires (os.family == "mac") + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.mock.* + * @build jdk.jpackage.test.stdmock.* + * @compile/module=jdk.jpackage -Xlint:all -Werror + * jdk/jpackage/internal/ActiveKeychainListTest.java + * @run junit jdk.jpackage/jdk.jpackage.internal.ActiveKeychainListTest + */ + +/* @test + * @summary Test MacApplicationBuilderTest + * @requires (os.family == "mac") + * @compile/module=jdk.jpackage -Xlint:all -Werror + * jdk/jpackage/internal/MacApplicationBuilderTest.java + * @run junit jdk.jpackage/jdk.jpackage.internal.MacApplicationBuilderTest + */ diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/AppImageFileTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/AppImageFileTest.java index 8fdcc96acff..85b15d77052 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/AppImageFileTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/AppImageFileTest.java @@ -108,7 +108,9 @@ public class AppImageFileTest { @Test public void testNoSuchFile() throws IOException { - var ex = assertThrowsExactly(JPackageException.class, () -> AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder))); + var ex = assertThrowsExactly(JPackageException.class, () -> { + AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder), OperatingSystem.current()); + }); Assertions.assertEquals(I18N.format("error.missing-app-image-file", ".jpackage.xml", tempFolder), ex.getMessage()); assertNull(ex.getCause()); } @@ -117,7 +119,9 @@ public class AppImageFileTest { public void testDirectory() throws IOException { Files.createDirectory(AppImageFile.getPathInAppImage(DUMMY_LAYOUT.resolveAt(tempFolder))); - var ex = assertThrowsExactly(JPackageException.class, () -> AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder))); + var ex = assertThrowsExactly(JPackageException.class, () -> { + AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder), OperatingSystem.current()); + }); Assertions.assertEquals(I18N.format("error.reading-app-image-file", ".jpackage.xml", tempFolder), ex.getMessage()); assertNotNull(ex.getCause()); } @@ -131,7 +135,9 @@ public class AppImageFileTest { Files.writeString(appImageFile, ""); try (var out = new FileOutputStream(appImageFile.toFile()); var lock = out.getChannel().lock()) { - var ex = assertThrowsExactly(JPackageException.class, () -> AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder))); + var ex = assertThrowsExactly(JPackageException.class, () -> { + AppImageFile.load(DUMMY_LAYOUT.resolveAt(tempFolder), OperatingSystem.current()); + }); Assertions.assertEquals(I18N.format("error.reading-app-image-file", ".jpackage.xml", tempFolder), ex.getMessage()); assertNotNull(ex.getCause()); } @@ -237,7 +243,7 @@ public class AppImageFileTest { final var copy = toSupplier(() -> { var layout = DUMMY_LAYOUT.resolveAt(dir); new AppImageFile(app).save(layout); - return AppImageFile.load(layout); + return AppImageFile.load(layout, OperatingSystem.current()); }).get(); assertEquals(createExternalApplication(OperatingSystem.current()), copy); @@ -638,7 +644,7 @@ public class AppImageFileTest { private static final ApplicationLayout DUMMY_LAYOUT = ApplicationLayout.build().setAll("").create(); - private final static Map OPTIONS = Stream.of(AppImageFileOptionScope.values()) + private static final Map OPTIONS = Stream.of(AppImageFileOptionScope.values()) .flatMap(AppImageFileOptionScope::options) .collect(toMap(OptionValue::id, OptionValue::getName)); diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/DefaultBundlingEnvironmentTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/DefaultBundlingEnvironmentTest.java index 709f0f8413b..ac05f5e2b69 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/DefaultBundlingEnvironmentTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/DefaultBundlingEnvironmentTest.java @@ -54,6 +54,7 @@ import jdk.jpackage.test.mock.CommandActionSpecs; import jdk.jpackage.test.mock.CommandMock; import jdk.jpackage.test.mock.CommandMockExit; import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.api.Test; @@ -96,7 +97,7 @@ public class DefaultBundlingEnvironmentTest extends JUnitAdapter { var script = createMockScript(op); - ToolProvider jpackage = MockUtils.buildJPackage() + ToolProvider jpackage = JPackageMockUtils.buildJPackage() .os(op.os()) .script(script) .listener(executedCommands::add).create(); diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/TempDirectoryTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/TempDirectoryTest.java new file mode 100644 index 00000000000..221e7d9f433 --- /dev/null +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/TempDirectoryTest.java @@ -0,0 +1,570 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Stream; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.cli.Options; +import jdk.jpackage.internal.cli.StandardOption; +import jdk.jpackage.internal.util.FileUtils; +import jdk.jpackage.internal.util.RetryExecutor; +import jdk.jpackage.internal.util.function.ThrowingFunction; +import jdk.jpackage.internal.util.function.ThrowingSupplier; +import jdk.jpackage.test.PathDeletionPreventer; +import jdk.jpackage.test.PathDeletionPreventer.ReadOnlyDirectoryPathDeletionPreventer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.MethodSource; + +public class TempDirectoryTest { + + @Test + void test_directory_use(@TempDir Path tempDirPath) throws IOException { + try (var tempDir = new TempDirectory(Optional.of(tempDirPath), RetryExecutorFactory.DEFAULT)) { + assertEquals(tempDir.path(), tempDirPath); + assertFalse(tempDir.deleteOnClose()); + + var cmdline = Options.of(Map.of()); + assertSame(cmdline, tempDir.map(cmdline)); + } + + assertTrue(Files.isDirectory(tempDirPath)); + } + + @Test + void test_directory_new() throws IOException { + var tempDir = new TempDirectory(Optional.empty(), RetryExecutorFactory.DEFAULT); + try (tempDir) { + assertTrue(Files.isDirectory(tempDir.path())); + assertTrue(tempDir.deleteOnClose()); + + var cmdline = Options.of(Map.of()); + var mappedCmdline = tempDir.map(cmdline); + assertEquals(tempDir.path(), StandardOption.TEMP_ROOT.getFrom(mappedCmdline)); + } + + assertFalse(Files.isDirectory(tempDir.path())); + } + + @SuppressWarnings("try") + @ParameterizedTest + @MethodSource + void test_close(CloseType closeType, @TempDir Path root) { + Globals.main(ThrowingSupplier.toSupplier(() -> { + test_close_impl(closeType, root); + return 0; + })); + } + + @ParameterizedTest + @MethodSource + void test_DirectoryListing_listFilesAndEmptyDirectories( + ListFilesAndEmptyDirectoriesTestSpec test, @TempDir Path root) throws IOException { + test.run(root); + } + + @Test + void test_DirectoryListing_listFilesAndEmptyDirectories_negative(@TempDir Path root) throws IOException { + assertThrowsExactly(IllegalArgumentException.class, () -> { + TempDirectory.DirectoryListing.listFilesAndEmptyDirectories(root, -1); + }); + } + + @ParameterizedTest + @CsvSource({"100", "101", "1", "0"}) + void test_DirectoryListing_listFilesAndEmptyDirectories_nonexistent(int limit, @TempDir Path root) throws IOException { + + var path = root.resolve("foo"); + + var listing = TempDirectory.DirectoryListing.listFilesAndEmptyDirectories(path, limit); + assertTrue(listing.complete()); + + List expected; + if (limit == 0) { + expected = List.of(); + } else { + expected = List.of(path); + } + assertEquals(expected, listing.paths()); + } + + private static Stream test_close() { + switch (PathDeletionPreventer.DEFAULT.implementation()) { + case READ_ONLY_NON_EMPTY_DIRECTORY -> { + return Stream.of(CloseType.values()); + } + default -> { + return Stream.of(CloseType.values()) + .filter(Predicate.not(Set.of( + CloseType.FAIL_NO_LEFTOVER_FILES, + CloseType.FAIL_NO_LEFTOVER_FILES_VERBOSE)::contains)); + } + } + } + + @SuppressWarnings({ "try" }) + private void test_close_impl(CloseType closeType, Path root) throws IOException { + var logSink = new StringWriter(); + var logPrintWriter = new PrintWriter(logSink, true); + Globals.instance().loggerOutputStreams(logPrintWriter, logPrintWriter); + if (closeType.isVerbose()) { + Globals.instance().loggerVerbose(); + } + + final var workDir = root.resolve("workdir"); + Files.createDirectories(workDir); + + final Path leftoverPath; + final TempDirectory tempDir; + + switch (closeType) { + case FAIL_NO_LEFTOVER_FILES_VERBOSE, FAIL_NO_LEFTOVER_FILES -> { + leftoverPath = workDir; + tempDir = new TempDirectory(workDir, true, new RetryExecutorFactory() { + @Override + public RetryExecutor retryExecutor(Class exceptionType) { + return new RetryExecutor(exceptionType).setSleepFunction(_ -> {}); + } + }); + + // Lock the parent directory of the work directory and don't create any files in the work directory. + // This should trigger the error message about the failure to delete the empty work directory. + try (var lockWorkDir = ReadOnlyDirectoryPathDeletionPreventer.INSTANCE.preventPathDeletion(workDir.getParent())) { + tempDir.close(); + } + } + default -> { + Files.createFile(workDir.resolve("b")); + + final var lockedPath = workDir.resolve("a"); + switch (PathDeletionPreventer.DEFAULT.implementation()) { + case FILE_CHANNEL_LOCK -> { + Files.createFile(lockedPath); + leftoverPath = lockedPath; + } + case READ_ONLY_NON_EMPTY_DIRECTORY -> { + Files.createDirectories(lockedPath); + leftoverPath = lockedPath.resolve("a"); + Files.createFile(leftoverPath); + } + default -> { + throw new AssertionError(); + } + } + + tempDir = new TempDirectory(workDir, true, new RetryExecutorFactory() { + @Override + public RetryExecutor retryExecutor(Class exceptionType) { + var config = new RetryExecutorMock.Config(lockedPath, closeType.isSuccess()); + return new RetryExecutorMock<>(exceptionType, config); + } + }); + + tempDir.close(); + } + } + + logPrintWriter.flush(); + var logMessages = new BufferedReader(new StringReader(logSink.toString())).lines().toList(); + + assertTrue(Files.isDirectory(root)); + + if (closeType.isSuccess()) { + assertFalse(Files.exists(tempDir.path())); + assertEquals(List.of(), logMessages); + } else { + assertTrue(Files.isDirectory(tempDir.path())); + assertTrue(Files.exists(leftoverPath)); + assertFalse(Files.exists(tempDir.path().resolve("b"))); + + String errMessage; + switch (closeType) { + case FAIL_SOME_LEFTOVER_FILES_VERBOSE, FAIL_SOME_LEFTOVER_FILES -> { + errMessage = "warning.tempdir.cleanup-file-failed"; + } + case FAIL_NO_LEFTOVER_FILES_VERBOSE, FAIL_NO_LEFTOVER_FILES -> { + errMessage = "warning.tempdir.cleanup-failed"; + } + default -> { + throw new AssertionError(); + } + } + assertEquals(List.of(I18N.format(errMessage, leftoverPath)), logMessages.subList(0, 1)); + + if (closeType.isVerbose()) { + // Check the log contains a stacktrace + assertNotEquals(1, logMessages.size()); + } + FileUtils.deleteRecursive(tempDir.path()); + } + } + + private static Collection test_DirectoryListing_listFilesAndEmptyDirectories() { + + var testCases = new ArrayList(); + + Supplier builder = ListFilesAndEmptyDirectoriesTestSpec::build; + + Stream.of( + builder.get().dirs("").complete(), + builder.get().dirs("").limit(0), + builder.get().dirs("foo").complete(), + builder.get().dirs("foo").limit(0), + builder.get().dirs("foo").limit(1).complete(), + builder.get().dirs("foo").limit(2).complete(), + builder.get().dirs("a/b/c").files("foo").files("b/b", "b/c").complete(), + builder.get().dirs("a/b/c").files("foo").files("b/b", "b/c").limit(4).complete(), + builder.get().dirs("a/b/c").files("foo").files("b/b", "b/c").limit(3) + ).map(ListFilesAndEmptyDirectoriesTestSpec.Builder::create).forEach(testCases::add); + + if (!OperatingSystem.isWindows()) { + Stream.of( + // A directory with the sibling symlink pointing to this directory + builder.get().dirs("foo").symlink("foo-symlink", "foo").complete(), + // A file with the sibling symlink pointing to this file + builder.get().symlink("foo-symlink", "foo").files("foo").complete(), + // A dangling symlink + builder.get().nonexistent("foo/bar/buz").symlink("dangling-symlink", "foo/bar/buz").complete() + ).map(ListFilesAndEmptyDirectoriesTestSpec.Builder::create).forEach(testCases::add); + } + + return testCases; + } + + enum CloseType { + SUCCEED, + FAIL_SOME_LEFTOVER_FILES, + FAIL_SOME_LEFTOVER_FILES_VERBOSE, + FAIL_NO_LEFTOVER_FILES, + FAIL_NO_LEFTOVER_FILES_VERBOSE, + ; + + boolean isSuccess() { + return this == SUCCEED; + } + + boolean isVerbose() { + return name().endsWith("_VERBOSE"); + } + } + + private static final class RetryExecutorMock extends RetryExecutor { + + RetryExecutorMock(Class exceptionType, Config config) { + super(exceptionType); + setSleepFunction(_ -> {}); + this.config = Objects.requireNonNull(config); + } + + @SuppressWarnings({ "try", "unchecked" }) + @Override + public RetryExecutor setExecutable(ThrowingFunction>, T, E> v) { + return super.setExecutable(context -> { + if (context.isLastAttempt() && config.unlockOnLastAttempt()) { + return v.apply(context); + } else { + try (var lock = PathDeletionPreventer.DEFAULT.preventPathDeletion(config.lockedPath())) { + return v.apply(context); + } catch (IOException ex) { + if (exceptionType().isInstance(ex)) { + throw (E)ex; + } else { + throw new AssertionError(); + } + } + } + }); + }; + + private final Config config; + + record Config(Path lockedPath, boolean unlockOnLastAttempt) { + Config { + Objects.requireNonNull(lockedPath); + } + } + } + + sealed interface FileSpec extends Comparable { + Path path(); + Path create(Path root) throws IOException; + public default int compareTo(FileSpec other) { + return path().compareTo(other.path()); + } + + static File file(Path path) { + return new File(path); + } + + static Directory dir(Path path) { + return new Directory(path); + } + + static Nonexistent nonexistent(Path path) { + return new Nonexistent(path); + } + + static Symlink symlink(Path path, FileSpec target) { + return new Symlink(path, target); + } + }; + + record File(Path path) implements FileSpec { + File { + path = normalizePath(path); + if (path.getNameCount() == 0) { + throw new IllegalArgumentException(); + } + } + + @Override + public Path create(Path root) throws IOException { + var resolvedPath = root.resolve(path); + if (!Files.isRegularFile(resolvedPath)) { + Files.createDirectories(resolvedPath.getParent()); + Files.createFile(resolvedPath); + } + return resolvedPath; + } + + @Override + public String toString() { + return String.format("f:%s", path); + } + } + + record Nonexistent(Path path) implements FileSpec { + Nonexistent { + path = normalizePath(path); + if (path.getNameCount() == 0) { + throw new IllegalArgumentException(); + } + } + + @Override + public Path create(Path root) throws IOException { + return root.resolve(path); + } + + @Override + public String toString() { + return String.format("x:%s", path); + } + } + + record Symlink(Path path, FileSpec target) implements FileSpec { + Symlink { + path = normalizePath(path); + if (path.getNameCount() == 0) { + throw new IllegalArgumentException(); + } + Objects.requireNonNull(target); + } + + @Override + public Path create(Path root) throws IOException { + var resolvedPath = root.resolve(path); + var targetPath = target.create(root); + Files.createDirectories(resolvedPath.getParent()); + return Files.createSymbolicLink(resolvedPath, targetPath); + } + + @Override + public String toString() { + return String.format("s:%s->%s", path, target); + } + } + + record Directory(Path path) implements FileSpec { + Directory { + path = normalizePath(path); + } + + @Override + public Path create(Path root) throws IOException { + return Files.createDirectories(root.resolve(path)); + } + + @Override + public String toString() { + return String.format("d:%s", path); + } + } + + private static Path normalizePath(Path path) { + path = path.normalize(); + if (path.isAbsolute()) { + throw new IllegalArgumentException(); + } + return path; + } + + private record ListFilesAndEmptyDirectoriesTestSpec(Set input, int limit, boolean complete) { + + ListFilesAndEmptyDirectoriesTestSpec { + Objects.requireNonNull(input); + + if (!(input instanceof SortedSet)) { + input = new TreeSet<>(input); + } + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + ListFilesAndEmptyDirectoriesTestSpec create() { + return new ListFilesAndEmptyDirectoriesTestSpec(Set.copyOf(input), limit, complete); + } + + Builder files(String... paths) { + Stream.of(paths).map(Path::of).map(FileSpec::file).forEach(input::add); + return this; + } + + Builder dirs(String... paths) { + Stream.of(paths).map(Path::of).map(FileSpec::dir).forEach(input::add); + return this; + } + + Builder nonexistent(String... paths) { + Stream.of(paths).map(Path::of).map(FileSpec::nonexistent).forEach(input::add); + return this; + } + + Builder symlink(String path, String target) { + Objects.requireNonNull(target); + + var targetSpec = input.stream().filter(v -> { + return v.path().equals(Path.of(target)); + }).findFirst(); + + if (targetSpec.isEmpty()) { + var v = FileSpec.file(Path.of(target)); + input.add(v); + targetSpec = Optional.ofNullable(v); + } + + input.add(FileSpec.symlink(Path.of(path), targetSpec.get())); + + return this; + } + + Builder limit(int v) { + limit = v; + return this; + } + + Builder complete(boolean v) { + complete = v; + return this; + } + + Builder complete() { + return complete(true); + } + + private final Set input = new HashSet<>(); + private int limit = Integer.MAX_VALUE; + private boolean complete; + } + + void run(Path root) throws IOException { + for (var v : input) { + v.create(root); + } + + for (var v : input) { + Predicate validator; + switch (v) { + case File _ -> { + validator = Files::isRegularFile; + } + case Directory _ -> { + validator = Files::isDirectory; + } + case Symlink _ -> { + validator = Files::isSymbolicLink; + } + case Nonexistent _ -> { + validator = Predicate.not(Files::exists); + } + } + assertTrue(validator.test(root.resolve(v.path()))); + } + + var listing = TempDirectory.DirectoryListing.listFilesAndEmptyDirectories(root, limit); + assertEquals(complete, listing.complete()); + + if (complete) { + var actual = listing.paths().stream().peek(p -> { + assertTrue(p.startsWith(root)); + }).map(root::relativize).sorted().toList(); + var expected = input.stream() + .filter(Predicate.not(Nonexistent.class::isInstance)) + .map(FileSpec::path) + .sorted() + .toList(); + assertEquals(expected, actual); + } else { + assertEquals(limit, listing.paths().size()); + } + } + + @Override + public String toString() { + return String.format("%s; limit=%d; complete=%s", input, limit, complete); + } + } +} diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java index 239ce0d0ce9..1b89d23c301 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java @@ -50,7 +50,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.internal.util.OperatingSystem; import jdk.jpackage.internal.Globals; -import jdk.jpackage.internal.MockUtils; import jdk.jpackage.internal.model.ConfigException; import jdk.jpackage.internal.model.ExecutableAttributesWithCapturedOutput; import jdk.jpackage.internal.model.JPackageException; @@ -67,6 +66,7 @@ import jdk.jpackage.test.TKit; import jdk.jpackage.test.mock.CommandActionSpecs; import jdk.jpackage.test.mock.Script; import jdk.jpackage.test.mock.VerbatimCommandMock; +import jdk.jpackage.test.stdmock.JPackageMockUtils; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; @@ -124,9 +124,8 @@ public class MainTest extends JUnitAdapter { var jpackageToolProviderMock = new ToolProvider() { @Override public int run(PrintWriter out, PrintWriter err, String... args) { - var globalsMutator = MockUtils.buildJPackage().script(script).createGlobalsMutator(); - return Globals.main(() -> { - globalsMutator.accept(Globals.instance()); + return Globals.main(() -> { + JPackageMockUtils.buildJPackage().script(script).applyToGlobals(); var result = ExecutionResult.create(args); @@ -155,6 +154,7 @@ public class MainTest extends JUnitAdapter { JPackageCommand.helloAppImage() .ignoreDefaultVerbose(true) + .ignoreDefaultRuntime(true) .useToolProvider(jpackageToolProviderMock) .execute(jpackageExitCode); } @@ -462,7 +462,11 @@ public class MainTest extends JUnitAdapter { var stdout = new StringWriter(); var stderr = new StringWriter(); - var exitCode = Main.run(new PrintWriter(stdout), new PrintWriter(stderr), args); + var os = OperatingSystem.current(); + var exitCode = Main.run(os, () -> { + CliBundlingEnvironment bundlingEnv = JPackageMockUtils.createBundlingEnvironment(os); + return bundlingEnv; + }, new PrintWriter(stdout), new PrintWriter(stderr), args); return new ExecutionResult(lines(stdout.toString()), lines(stderr.toString()), exitCode); } diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsProcessorTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsProcessorTest.java index 53b726d8f1a..499aab2f24a 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsProcessorTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -664,7 +664,7 @@ public class OptionsProcessorTest { var optionsBuilder = Utils.buildParser(os, bundlingEnv).create().apply(stringArgs).orElseThrow(); - var op = new OptionsProcessor(optionsBuilder, bundlingEnv); + var op = new OptionsProcessor(optionsBuilder, OperatingSystem.current(), bundlingEnv); Collection> errors; if (expectedValidationErrorsOrdered) { diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes index 40f73e624b6..a7a65402b9c 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes @@ -18,27 +18,38 @@ ErrorTest.test(IMAGE; args-add=[--module, com.foo.bar, --runtime-image, @@JAVA_H ErrorTest.test(IMAGE; args-add=[--module, java.base, --runtime-image, @@JAVA_HOME@@]; errors=[message.error-header+[ERR_NoMainClass]]) ErrorTest.test(LINUX_DEB; app-desc=Hello; args-add=[--linux-package-name, #]; errors=[message.error-header+[error.deb-invalid-value-for-package-name, #], message.advice-header+[error.deb-invalid-value-for-package-name.advice]]) ErrorTest.test(LINUX_RPM; app-desc=Hello; args-add=[--linux-package-name, #]; errors=[message.error-header+[error.rpm-invalid-value-for-package-name, #], message.advice-header+[error.rpm-invalid-value-for-package-name.advice]]) -ErrorTest.test(MAC_PKG; app-desc=Hello; args-add=[--mac-package-identifier, #1]; errors=[message.error-header+[message.invalid-identifier, #1], message.advice-header+[message.invalid-identifier.advice]]) ErrorTest.test(NATIVE; app-desc=Hello; args-add=[--mac-app-store, --runtime-image, @@JAVA_HOME@@]; errors=[message.error-header+[error.invalid-runtime-image-bin-dir, @@JAVA_HOME@@], message.advice-header+[error.invalid-runtime-image-bin-dir.advice, --mac-app-store]]) ErrorTest.test(NATIVE; app-desc=Hello; args-add=[--runtime-image, @@EMPTY_DIR@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@EMPTY_DIR@@, lib/**/libjli.dylib]]) ErrorTest.test(NATIVE; app-desc=Hello; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_BUNDLE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_BUNDLE@@, Contents/Home/lib/**/libjli.dylib]]) ErrorTest.test(NATIVE; app-desc=Hello; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_IMAGE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_IMAGE@@, lib/**/libjli.dylib]]) +ErrorTest.test(NATIVE; args-add=[--app-image, @@MAC_APP_IMAGE_INVALID_INFO_PLIST@@]; errors=[message.error-header+[error.invalid-app-image-plist-file, @@MAC_APP_IMAGE_INVALID_INFO_PLIST@@]]) ErrorTest.test(NATIVE; args-add=[--runtime-image, @@EMPTY_DIR@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@EMPTY_DIR@@, lib/**/libjli.dylib]]) ErrorTest.test(NATIVE; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_BUNDLE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_BUNDLE@@, Contents/Home/lib/**/libjli.dylib]]) ErrorTest.test(NATIVE; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_IMAGE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_IMAGE@@, lib/**/libjli.dylib]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.3.4.5]; errors=[message.error-header+[error.msi-product-version-components, 1.2.3.4.5], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range, 1.2.65536], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range, 1.256], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1234]; errors=[message.error-header+[error.msi-product-version-components, 1234], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range, 256.1], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--launcher-as-service]; errors=[message.error-header+[error.missing-service-installer], message.advice-header+[error.missing-service-installer.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.3.4.5]; errors=[message.error-header+[error.msi-product-version-components, 1.2.3.4.5], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range, 1.2.65536], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range, 1.256], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1234]; errors=[message.error-header+[error.msi-product-version-components, 1234], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range, 256.1], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--launcher-as-service]; errors=[message.error-header+[error.missing-service-installer], message.advice-header+[error.missing-service-installer.advice]]) ErrorTest.test(args-add=[@foo]; errors=[message.error-header+[ERR_CannotParseOptions, foo]]) +ErrorTest.testMacSignAppStoreInvalidRuntime +ErrorTest.testMacSignWithoutIdentity(IMAGE; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(IMAGE; args-add=[--app-image, @@APP_IMAGE_WITH_SHORT_NAME@@, --mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(MAC_DMG; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(MAC_DMG; args-add=[--app-image, @@APP_IMAGE_WITH_SHORT_NAME@@, --mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN], message.error-header+[error.cert.not.found, INSTALLER, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@KEYCHAIN_WITH_APP_IMAGE_CERT@@]; args-del=[--name]; errors=[message.error-header+[error.cert.not.found, INSTALLER, KEYCHAIN_WITH_APP_IMAGE_CERT]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@KEYCHAIN_WITH_PKG_CERT@@]; args-del=[--name]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, KEYCHAIN_WITH_PKG_CERT]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; args-add=[--app-image, @@APP_IMAGE_WITH_SHORT_NAME@@, --mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN], message.error-header+[error.cert.not.found, INSTALLER, EMPTY_KEYCHAIN]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; args-add=[--mac-sign, --mac-signing-keychain, @@KEYCHAIN_WITH_APP_IMAGE_CERT@@, --app-image, @@APP_IMAGE_WITH_SHORT_NAME@@]; errors=[message.error-header+[error.cert.not.found, INSTALLER, KEYCHAIN_WITH_APP_IMAGE_CERT]]) +ErrorTest.testMacSignWithoutIdentity(MAC_PKG; args-add=[--mac-sign, --mac-signing-keychain, @@KEYCHAIN_WITH_PKG_CERT@@, --app-image, @@APP_IMAGE_WITH_SHORT_NAME@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, KEYCHAIN_WITH_PKG_CERT]]) ErrorTest.testMacSigningIdentityValidation(IMAGE, --mac-app-image-sign-identity, true) ErrorTest.testMacSigningIdentityValidation(IMAGE, --mac-signing-key-user-name, false) ErrorTest.testMacSigningIdentityValidation(MAC_DMG, --mac-app-image-sign-identity, true) diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.java index 9976a71ef3f..3381677cb61 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.java @@ -105,7 +105,7 @@ public class OptionsValidationFailTest { final var firstErr = errors.stream().findFirst().orElseThrow(); errorReporter.reportError(firstErr); }).map(builder -> { - var result = new OptionsProcessor(builder, bundlingEnv).validate(); + var result = new OptionsProcessor(builder, OperatingSystem.current(), bundlingEnv).validate(); if (result.hasValue()) { return 0; } else { diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/StandardOptionTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/StandardOptionTest.java index 58a78edb627..4d47bced8f1 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/StandardOptionTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/StandardOptionTest.java @@ -58,6 +58,7 @@ import jdk.jpackage.internal.cli.StandardOption.LauncherProperty; import jdk.jpackage.internal.model.AppImageBundleType; import jdk.jpackage.internal.model.BundleType; import jdk.jpackage.internal.model.JPackageException; +import jdk.jpackage.internal.model.ConfigException; import jdk.jpackage.internal.model.LauncherShortcut; import jdk.jpackage.internal.model.LauncherShortcutStartupDirectory; import jdk.jpackage.internal.util.RootedPath; @@ -71,6 +72,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; @@ -258,6 +260,40 @@ public class StandardOptionTest extends JUnitAdapter.TestSrcInitializer { }).toList(), result.errors()); } + @ParameterizedTest + @ValueSource(strings = { + ".", + "a-b.c", + "A", + "com.acme.Foo" + }) + void test_MAC_BUNDLE_IDENTIFIER_valid(String id) { + + var spec = StandardOption.MAC_BUNDLE_IDENTIFIER.getSpec(); + + var result = spec.convert(spec.name(), StringToken.of(id)).orElseThrow(); + + assertEquals(result, id); + } + + @ParameterizedTest + @ValueSource(strings = { + "", + ",", + "Hello!" + }) + void test_MAC_BUNDLE_IDENTIFIER_invalid(String id) { + + var spec = StandardOption.MAC_BUNDLE_IDENTIFIER.getSpec(); + + var result = spec.convert(spec.name(), StringToken.of(id)); + + var ex = assertThrows(ConfigException.class, result::orElseThrow); + + assertEquals(I18N.format("error.parameter-not-mac-bundle-identifier", id, spec.name().formatForCommandLine()), ex.getMessage()); + assertEquals(I18N.format("error.parameter-not-mac-bundle-identifier.advice"), ex.getAdvice()); + } + @ParameterizedTest @EnumSource(OptionMutatorTest.TestType.class) public void test_pathOptionMutator(OptionMutatorTest.TestType type) { diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/help-windows.txt b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/help-windows.txt index b72ba310f3f..e30a5bb7f9b 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/help-windows.txt +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/help-windows.txt @@ -189,17 +189,23 @@ Platform dependent options for creating the application package: --win-help-url URL where user can obtain further information or technical support --win-menu [] - Request to add a Start menu shortcut for this application + Adds a Start menu shortcut for this application, or requests + to do so if --win-shortcut-prompt is specified --win-menu-group

Start Menu group this application is placed in --win-per-user-install - Request to perform an install on a per-user basis + Installs the application on a per-user basis. + Without this option installs per-machine --win-shortcut [] - Request to add desktop shortcut for this application + Adds a desktop shortcut for this application, or requests + to do so if --win-shortcut-prompt is specified --win-shortcut-prompt - Adds a dialog to enable the user to choose if shortcuts - will be created by installer. + Adds a dialog if at least one of --win-menu or --win-shortcut + are specified to enable the user to choose if these shortcuts + will be created by the installer --win-update-url URL of available application update information --win-upgrade-uuid UUID associated with upgrades for this package + --win-with-ui + Enforces the installer to have UI diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/jpackage-options.md b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/jpackage-options.md index 60b79451547..59ae0d176c1 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/jpackage-options.md +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/jpackage-options.md @@ -29,7 +29,7 @@ | --linux-shortcut | linux-deb, linux-rpm | x | x | x | USE_LAST | | --mac-app-category | mac-bundle | x | x | | USE_LAST | | --mac-app-image-sign-identity | mac | x | x | | USE_LAST | -| --mac-app-store | mac-bundle | x | x | | USE_LAST | +| --mac-app-store | mac | x | x | | USE_LAST | | --mac-dmg-content | mac-dmg | x | x | | CONCATENATE | | --mac-entitlements | mac | x | x | | USE_LAST | | --mac-installer-sign-identity | mac-pkg | x | x | | USE_LAST | @@ -61,3 +61,4 @@ | --win-shortcut-prompt | win-exe, win-msi | x | x | | USE_LAST | | --win-update-url | win-exe, win-msi | x | x | | USE_LAST | | --win-upgrade-uuid | win-exe, win-msi | x | x | | USE_LAST | +| --win-with-ui | win-exe, win-msi | x | x | | USE_LAST | diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java index 885ea31f726..65f9c71a910 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,18 +22,22 @@ */ package jdk.jpackage.internal.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Function; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrowsExactly; -import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; @@ -51,14 +55,6 @@ public class DottedVersionTest { this(input, type.createVersion, "", expectedComponentCount, input); } - static TestConfig greedy(String input, int expectedComponentCount, String expectedToComponent) { - return new TestConfig(input, Type.GREEDY.createVersion, "", expectedComponentCount, expectedToComponent); - } - - static TestConfig greedy(String input, int expectedComponentCount) { - return new TestConfig(input, Type.GREEDY.createVersion, "", expectedComponentCount, input); - } - static TestConfig lazy(String input, String expectedSuffix, int expectedComponentCount, String expectedToComponent) { return new TestConfig(input, Type.LAZY.createVersion, expectedSuffix, expectedComponentCount, expectedToComponent); } @@ -71,6 +67,7 @@ public class DottedVersionTest { assertEquals(cfg.expectedSuffix(), dv.getUnprocessedSuffix()); assertEquals(cfg.expectedComponentCount(), dv.getComponents().length); assertEquals(cfg.expectedToComponent(), dv.toComponentsString()); + assertEquals(dv.toString(), cfg.input()); } private static List testValid() { @@ -108,12 +105,107 @@ public class DottedVersionTest { TestConfig.lazy("+1", "+1", 0, ""), TestConfig.lazy("-1", "-1", 0, ""), TestConfig.lazy("-0", "-0", 0, ""), - TestConfig.lazy("+0", "+0", 0, "") + TestConfig.lazy("+0", "+0", 0, ""), + TestConfig.lazy("+0", "+0", 0, ""), + TestConfig.lazy("1.2.3+ea", "+ea", 3, "1.2.3"), + TestConfig.lazy(".7", ".7", 0, ""), + TestConfig.lazy(".+7", ".+7", 0, "") )); return data; } + @ParameterizedTest + @MethodSource + public void test_trim(DottedVersion ver, String expectedStr, int limit) { + var expected = DottedVersion.lazy(expectedStr); + var actual = ver.trim(limit); + assertEquals(expected, actual); + if (limit >= ver.getComponents().length) { + assertSame(ver, actual); + } else { + assertNotSame(ver, actual); + } + assertEquals(expectedStr, actual.toString()); + } + + @ParameterizedTest + @MethodSource("test_trim_pad_negative") + public void test_trim_negative(DottedVersion ver, int limit) { + assertThrowsExactly(IllegalArgumentException.class, () -> { + ver.trim(limit); + }); + } + + private static Stream test_trim() { + + var testCases = new ArrayList(); + + for (var suffix : List.of("", ".foo", "-ea", "+345")) { + testCases.addAll(List.of( + Arguments.of("1.02.3" + suffix, "" + suffix, 0), + Arguments.of("1.02.3" + suffix, "1" + suffix, 1), + Arguments.of("1.02.3" + suffix, "1.02" + suffix, 2), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 3), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 4) + )); + } + + return testCases.stream().map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + @ParameterizedTest + @MethodSource + public void test_pad(DottedVersion ver, String expectedStr, int limit) { + var expected = DottedVersion.lazy(expectedStr); + var actual = ver.pad(limit); + assertEquals(expected, actual); + if (limit <= ver.getComponents().length) { + assertSame(ver, actual); + } else { + assertNotSame(ver, actual); + } + assertEquals(expectedStr, actual.toString()); + } + + @ParameterizedTest + @MethodSource("test_trim_pad_negative") + public void test_pad_negative(DottedVersion ver, int limit) { + assertThrowsExactly(IllegalArgumentException.class, () -> { + ver.pad(limit); + }); + } + + private static Stream test_pad() { + + var testCases = new ArrayList(); + + for (var suffix : List.of("", ".foo", "-ea", "+345")) { + testCases.addAll(List.of( + Arguments.of("" + suffix, "" + suffix, 0), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 0), + Arguments.of("" + suffix, "0" + suffix, 1), + Arguments.of("1" + suffix, "1" + suffix, 1), + Arguments.of("1" + suffix, "1.0" + suffix, 2), + Arguments.of("1.02.3" + suffix, "1.02.3.0.0" + suffix, 5) + )); + } + + return testCases.stream().map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + private static Stream test_trim_pad_negative() { + return Stream.of( + Arguments.of("10.5.foo", -1) + ).map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + private static Arguments mapFirstStringToDottedVersion(Arguments v) { + var objs = v.get(); + objs[0] = DottedVersion.lazy((String)objs[0]); + return Arguments.of(objs); + } + record InvalidVersionTestSpec(String version, String invalidComponent) { public InvalidVersionTestSpec { Objects.requireNonNull(version); diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/CommandOutputControlTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/CommandOutputControlTest.java index d71cf7c4d41..b179f32447f 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/CommandOutputControlTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/CommandOutputControlTest.java @@ -458,7 +458,7 @@ public class CommandOutputControlTest { processDestroyer.get().join(); } - @DisabledOnOs(value = OS.MAC, disabledReason = "Closing a stream doesn't consistently cause a trouble as it should") + @DisabledOnOs(value = {OS.MAC, OS.LINUX}, disabledReason = "Closing a stream doesn't consistently cause a trouble as expected") @ParameterizedTest @EnumSource(OutputStreams.class) public void test_close_streams(OutputStreams action) throws InterruptedException, IOException { diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/MemoizingSupplierTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/MemoizingSupplierTest.java new file mode 100644 index 00000000000..654071359cb --- /dev/null +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/MemoizingSupplierTest.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal.util; + +import static jdk.jpackage.internal.util.function.ThrowingRunnable.toRunnable; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; + +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.function.Supplier; +import java.util.stream.IntStream; +import org.junit.jupiter.api.Test; + + +class MemoizingSupplierTest { + + @Test + void test() { + var supplier = count(() -> "foo"); + var runOnceSupplier = MemoizingSupplier.runOnce(supplier); + + assertEquals(0, supplier.counter()); + + assertEquals("foo", runOnceSupplier.get()); + assertEquals("foo", runOnceSupplier.get()); + + assertEquals(1, supplier.counter()); + } + + @Test + void test_null() { + CountingSupplier supplier = count(() -> null); + var runOnceSupplier = MemoizingSupplier.runOnce(supplier); + + assertEquals(0, supplier.counter()); + + assertEquals(null, runOnceSupplier.get()); + assertEquals(null, runOnceSupplier.get()); + + assertEquals(1, supplier.counter()); + } + + @Test + void test_throws_Exception() { + CountingSupplier supplier = count(() -> { + throw new IllegalStateException("Kaput!"); + }); + var runOnceSupplier = MemoizingSupplier.runOnce(supplier); + + assertEquals(0, supplier.counter()); + + assertThrowsExactly(IllegalStateException.class, () -> { + runOnceSupplier.get(); + }); + + assertThrowsExactly(IllegalStateException.class, () -> { + runOnceSupplier.get(); + }); + + assertEquals(1, supplier.counter()); + } + + @Test + void test_throws_Error() { + CountingSupplier supplier = count(() -> { + throw new Error("Grand kaput!"); + }); + var runOnceSupplier = MemoizingSupplier.runOnce(supplier); + + assertEquals(0, supplier.counter()); + + assertThrowsExactly(Error.class, () -> { + runOnceSupplier.get(); + }); + + assertThrowsExactly(Error.class, () -> { + runOnceSupplier.get(); + }); + + assertEquals(1, supplier.counter()); + } + + @Test + void testAsync() throws InterruptedException { + var supplier = count(() -> "foo"); + var runOnceSupplier = MemoizingSupplier.runOnce(supplier); + + final var supplierCount = 100; + final var supplierExecutor = Executors.newVirtualThreadPerTaskExecutor(); + + // Schedule invoking "runOnceSupplier.get()" in a separate virtual threads. + // Start and suspend threads, waiting until all scheduled threads have started. + // After all scheduled threads start, resume them. + // This should result in multiple simultaneous "runOnceSupplier.get()" calls. + + var readyLatch = new CountDownLatch(supplierCount); + var startLatch = new CountDownLatch(1); + + var futures = IntStream.range(0, supplierCount).mapToObj(_ -> { + return CompletableFuture.runAsync(toRunnable(() -> { + readyLatch.countDown(); + startLatch.await(); + runOnceSupplier.get(); + + }), supplierExecutor); + }).toList(); + + readyLatch.await(); + startLatch.countDown(); + + CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join(); + + assertEquals(1, supplier.counter()); + } + + private static CountingSupplier count(Supplier supplier) { + return new CountingSupplier<>(supplier); + } + + private static final class CountingSupplier implements Supplier { + + CountingSupplier(Supplier impl) { + this.impl = Objects.requireNonNull(impl); + } + + @Override + public T get() { + counter++; + return impl.get(); + } + + int counter() { + return counter; + } + + private int counter; + private final Supplier impl; + } +} diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/RuntimeReleaseFileTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/RuntimeReleaseFileTest.java new file mode 100644 index 00000000000..097f63d51ab --- /dev/null +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/RuntimeReleaseFileTest.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal.util; + +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.assertThrowsExactly; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.io.Writer; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.Properties; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class RuntimeReleaseFileTest { + + @Test + void test_invalid_input(@TempDir Path workdir) { + assertThrows(IOException.class, () -> { + new RuntimeReleaseFile(workdir); + }); + } + + @Test + void test_findRawProperty(@TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFile(workdir, Map.of("Name", "John", "Company", "\"Acme LTD\""))); + + assertEquals(Optional.empty(), releaseFile.findRawProperty("foo")); + assertEquals(Optional.of("John"), releaseFile.findRawProperty("Name")); + assertEquals(Optional.of("\"Acme LTD\""), releaseFile.findRawProperty("Company")); + } + + @Test + void test_findProperty(@TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFile(workdir, Map.of("Name", "John", "Company", "\"Acme LTD\""))); + + assertEquals(Optional.empty(), releaseFile.findProperty("foo")); + assertEquals(Optional.of("John"), releaseFile.findProperty("Name")); + assertEquals(Optional.of("Acme LTD"), releaseFile.findProperty("Company")); + } + + @ParameterizedTest + @CsvSource({ + "foo, foo", + "\"foo\", foo", + "'foo', 'foo'", + "\"f\"o\"o\", f\"o\"o", + "\"foo, \"foo", + "foo\", foo\"", + }) + void test_findProperty(String rawValue, String expectedValue, @TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFile(workdir, Map.of("FOO", rawValue))); + + assertEquals(expectedValue, releaseFile.findProperty("FOO").orElseThrow()); + } + + @ParameterizedTest + @CsvSource({ + "\"27.1.2\", 27.1.2", + "27.1.2, 27.1.2", + "\"27.1.2-ea\", 27.1.2-ea", + "27.1.2-ea, 27.1.2-ea", + "\"27.1.2+15\", 27.1.2+15", + "27.1.2+15, 27.1.2+15", + }) + void test_getJavaVersion(String version, String expectedVersion, @TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFileWithValue(workdir, "JAVA_VERSION", version)); + + final var value = releaseFile.getJavaVersion(); + + assertEquals(expectedVersion, value.toString()); + } + + @ParameterizedTest + @CsvSource({ + "\"7.1.2+foo\"", + "\"foo\"", + "\"\"", + "7.1.2+foo", + "foo", + "''" + }) + void test_getJavaVersion_invalid(String version, @TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFileWithValue(workdir, "JAVA_VERSION", version)); + + var ex = assertThrows(RuntimeException.class, releaseFile::getJavaVersion); + + assertFalse(NoSuchElementException.class.isInstance(ex)); + } + + @Test + void test_without_version(@TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFileWithValue(workdir, "JDK_VERSION", "\"27.1.2\"")); + + assertThrowsExactly(NoSuchElementException.class, releaseFile::getJavaVersion); + } + + @Test + void test_getModules(@TempDir Path workdir) throws IOException { + var releaseFile = new RuntimeReleaseFile(createPropFileWithValue(workdir, "MODULES", "foo bar\t buz ")); + + assertEquals(List.of("foo", "bar", "buz"), releaseFile.getModules()); + } + + @Test + void test_current() throws IOException { + var releaseFile = new RuntimeReleaseFile(Path.of(System.getProperty("java.home")).resolve("release")); + + final var expectedVersion = Runtime.version(); + final var actualVersion = releaseFile.getJavaVersion(); + + assertEquals(expectedVersion.version(), actualVersion.version()); + + final var expectedModules = ModuleFinder.ofSystem().findAll().stream() + .map(ModuleReference::descriptor).map(ModuleDescriptor::name).sorted().toList(); + final var actualModules = releaseFile.getModules().stream().sorted().toList(); + + assertEquals(expectedModules, actualModules); + } + + private Path createPropFileWithValue(Path workdir, String name, String value) { + return createPropFile(workdir, Map.of(name, value)); + } + + private Path createPropFile(Path workdir, Map input) { + Path releaseFile = workdir.resolve("foo"); + Properties props = new Properties(); + props.putAll(input); + + try (Writer writer = Files.newBufferedWriter(releaseFile)) { + props.store(writer, null); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + + return releaseFile; + } +} diff --git a/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/WixVariablesTest.java b/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/WixVariablesTest.java new file mode 100644 index 00000000000..a9d83c8d544 --- /dev/null +++ b/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/WixVariablesTest.java @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal; + +import static jdk.jpackage.internal.WixToolset.WixToolsetType.Wix4; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import jdk.jpackage.internal.WixToolset.WixToolsetType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; + +class WixVariablesTest { + + @Test + void test_define() { + assertEquals(List.of("-d", "foo=yes"), new WixVariables().define("foo").toWixCommandLine(Wix4)); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void test_define_null(boolean immutable) { + assertThrows(NullPointerException.class, vars -> { + vars.define(null); + }, create(immutable)); + } + + @Test + void test_put() { + assertEquals(List.of("-d", "foo=bar"), new WixVariables().put("foo", "bar").toWixCommandLine(Wix4)); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void test_put_null(boolean immutable) { + assertThrows(NullPointerException.class, vars -> { + vars.put("foo", null); + }, create(immutable)); + + assertThrows(NullPointerException.class, vars -> { + vars.put(null, "foo"); + }, create(immutable)); + } + + @Test + void test_putAll() { + assertEquals(List.of("-d", "foo=bar"), new WixVariables().putAll(Map.of("foo", "bar")).toWixCommandLine(Wix4)); + assertEquals(List.of("-d", "foo=yes"), new WixVariables().putAll(new WixVariables().define("foo")).toWixCommandLine(Wix4)); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void test_putAll_null(boolean immutable) { + + assertThrows(NullPointerException.class, vars -> { + vars.putAll((Map)null); + }, create(immutable)); + + assertThrows(NullPointerException.class, vars -> { + vars.putAll((WixVariables)null); + }, create(immutable)); + + final var expectedExceptionType = immutable ? IllegalStateException.class : NullPointerException.class; + + var other = new HashMap(); + + other.clear(); + other.put("foo", null); + assertThrows(expectedExceptionType, vars -> { + vars.putAll(other); + }, create(immutable)); + + other.clear(); + other.put(null, "foo"); + assertThrows(expectedExceptionType, vars -> { + vars.putAll(other); + }, create(immutable)); + } + + @Test + void testImmutable() { + var vars = new WixVariables().define("foo").createdImmutableCopy(); + + assertThrows(IllegalStateException.class, _ -> { + vars.putAll(Map.of()); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.putAll(new WixVariables()); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.define("foo"); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.put("foo", "bar"); + }, vars); + + for (var allowOverrides : List.of(true, false)) { + assertThrows(IllegalStateException.class, _ -> { + vars.allowOverrides(allowOverrides); + }, vars); + } + } + + @Test + void testDefaultOverridable() { + var vars = new WixVariables().define("foo"); + + assertThrows(IllegalStateException.class, _ -> { + vars.define("foo"); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.put("foo", "no"); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.put("foo", "yes"); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.putAll(Map.of("foo", "A", "bar", "B")); + }, vars); + + assertThrows(IllegalStateException.class, _ -> { + vars.putAll(new WixVariables().putAll(Map.of("foo", "A", "bar", "B"))); + }, vars); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testOverridable_define(boolean overridable) { + var vars = new WixVariables().allowOverrides(overridable).define("foo"); + + if (overridable) { + vars.define("foo"); + } else { + assertThrows(IllegalStateException.class, _ -> { + vars.define("foo"); + }, vars); + vars.allowOverrides(true); + vars.define("foo"); + } + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testOverridable_put(boolean overridable) { + var vars = new WixVariables().allowOverrides(overridable).define("foo"); + + if (overridable) { + vars.put("foo", "bar"); + assertEquals(List.of("-d", "foo=bar"), vars.toWixCommandLine(Wix4)); + } else { + assertThrows(IllegalStateException.class, _ -> { + vars.put("foo", "bar"); + }, vars); + vars.allowOverrides(true); + vars.put("foo", "bar"); + assertEquals(List.of("-d", "foo=bar"), vars.toWixCommandLine(Wix4)); + } + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testOverridable_putAll(boolean overridable) { + var vars = new WixVariables().allowOverrides(overridable).define("foo"); + + var other = Map.of("foo", "A", "bar", "B"); + + if (overridable) { + vars.putAll(other); + assertEquals(List.of("-d", "bar=B", "-d", "foo=A"), vars.toWixCommandLine(Wix4)); + } else { + assertThrows(IllegalStateException.class, _ -> { + vars.putAll(other); + }, vars); + vars.allowOverrides(true); + vars.putAll(other); + assertEquals(List.of("-d", "bar=B", "-d", "foo=A"), vars.toWixCommandLine(Wix4)); + } + } + + @Test + void test_createdImmutableCopy() { + var vars = new WixVariables().define("foo"); + + var copy = vars.createdImmutableCopy(); + + assertNotSame(vars, copy); + + assertSame(copy, copy.createdImmutableCopy()); + + assertEquals(List.of("-d", "foo=yes"), copy.toWixCommandLine(Wix4)); + + vars.allowOverrides(true).put("foo", "bar"); + assertEquals(List.of("-d", "foo=bar"), vars.toWixCommandLine(Wix4)); + assertEquals(List.of("-d", "foo=yes"), copy.toWixCommandLine(Wix4)); + } + + @ParameterizedTest + @EnumSource(WixToolsetType.class) + void test_toWixCommandLine(WixToolsetType wixType) { + var args = new WixVariables().define("foo").put("bar", "a").toWixCommandLine(wixType); + + var expectedArgs = switch (wixType) { + case Wix3 -> { + yield List.of("-dbar=a", "-dfoo=yes"); + } + case Wix4 -> { + yield List.of("-d", "bar=a", "-d", "foo=yes"); + } + }; + + assertEquals(expectedArgs, args); + } + + private static WixVariables create(boolean immutable) { + var vars = new WixVariables(); + if (immutable) { + return vars.createdImmutableCopy(); + } else { + return vars; + } + } + + private static void assertThrows( + Class expectedExceptionType, Consumer mutator, WixVariables vars) { + + var content = vars.toWixCommandLine(Wix4); + + assertThrowsExactly(expectedExceptionType, () -> { + mutator.accept(vars); + }); + + assertEquals(content, vars.toWixCommandLine(Wix4)); + } +} diff --git a/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/wixui/UISpecTest.java b/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/wixui/UISpecTest.java new file mode 100644 index 00000000000..08e7796ca50 --- /dev/null +++ b/test/jdk/tools/jpackage/junit/windows/jdk.jpackage/jdk/jpackage/internal/wixui/UISpecTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2026, 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 jdk.jpackage.internal.wixui; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +class UISpecTest { + + @ParameterizedTest + @MethodSource + void test(UIConfig cfg) { + var uiSpec = UISpec.create(cfg); + + validateCustomDialogSequence(uiSpec.customDialogSequence()); + } + + private static Collection test() { + + var testCases = new ArrayList(); + + for (boolean withInstallDirChooserDlg : List.of(true, false)) { + for (boolean withShortcutPromptDlg : List.of(true, false)) { + for (boolean withLicenseDlg : List.of(true, false)) { + testCases.add(UIConfig.build() + .withInstallDirChooserDlg(withInstallDirChooserDlg) + .withShortcutPromptDlg(withShortcutPromptDlg) + .withLicenseDlg(withLicenseDlg) + .create()); + } + } + } + + return testCases; + } + + static void validateCustomDialogSequence(Map seq) { + seq.entrySet().stream().map(DialogControl::new).collect(Collectors.toMap(x -> x, x -> x, (a, b) -> { + throw new AssertionError(String.format( + "Dialog [%s] has multiple Publish elements associated with [%s] control", a.host(), a.hostedControl())); + })); + } + + record DialogControl(Dialog host, Control hostedControl) { + DialogControl { + Objects.requireNonNull(host); + Objects.requireNonNull(hostedControl); + } + + DialogControl(DialogPair pair, Publish publish) { + this(pair.first(), publish.control()); + } + + DialogControl(Map.Entry e) { + this(e.getKey(), e.getValue()); + } + } +} diff --git a/test/jdk/tools/jpackage/junit/windows/junit.java b/test/jdk/tools/jpackage/junit/windows/junit.java index d27a282f0dc..1a1d0d58f7e 100644 --- a/test/jdk/tools/jpackage/junit/windows/junit.java +++ b/test/jdk/tools/jpackage/junit/windows/junit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,3 +28,20 @@ * jdk/jpackage/internal/ExecutableOSVersionTest.java * @run junit jdk.jpackage/jdk.jpackage.internal.ExecutableOSVersionTest */ + +/* @test + * @summary WixVariables unit tests + * @requires (os.family == "windows") + * @compile/module=jdk.jpackage -Xlint:all -Werror + * jdk/jpackage/internal/WixVariablesTest.java + * @run junit jdk.jpackage/jdk.jpackage.internal.WixVariablesTest + */ + +/* @test + * @summary UiSpec unit tests + * @requires (os.family == "windows") + * @modules jdk.jpackage/jdk.jpackage.internal.wixui:open + * @compile/module=jdk.jpackage -Xlint:all -Werror + * jdk/jpackage/internal/wixui/UISpecTest.java + * @run junit jdk.jpackage/jdk.jpackage.internal.wixui.UISpecTest + */ diff --git a/test/jdk/tools/jpackage/linux/LinuxResourceTest.java b/test/jdk/tools/jpackage/linux/LinuxResourceTest.java index b82706fc2c2..503c4db77fb 100644 --- a/test/jdk/tools/jpackage/linux/LinuxResourceTest.java +++ b/test/jdk/tools/jpackage/linux/LinuxResourceTest.java @@ -30,6 +30,7 @@ import java.util.Objects; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.CannedFormattedString; import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageCommand.StandardAssert; import jdk.jpackage.test.JPackageOutputValidator; import jdk.jpackage.test.LinuxHelper; import jdk.jpackage.test.PackageTest; @@ -66,7 +67,7 @@ public class LinuxResourceTest { final var packageProp = property("Package", "dont-install-me"); final var verProp = property("Version", "1.2.3-R2"); - final var arhProp = property("Architecture", "bar"); + final var archProp = property("Architecture", "bar"); TKit.createTextFile(controlFile, List.of( packageProp.format(), @@ -74,13 +75,15 @@ public class LinuxResourceTest { "Section: APPLICATION_SECTION", "Maintainer: APPLICATION_MAINTAINER", "Priority: optional", - arhProp.format(), + archProp.format(), "Provides: dont-install-me", "Description: APPLICATION_DESCRIPTION", "Installed-Size: APPLICATION_INSTALLED_SIZE", "Depends: PACKAGE_DEFAULT_DEPENDENCIES" )); + cmd.excludeStandardAsserts(StandardAssert.LINUX_PACKAGE_ARCH); + new JPackageOutputValidator() .expectMatchingStrings(MAIN.cannedFormattedString( "message.using-custom-resource", @@ -92,7 +95,7 @@ public class LinuxResourceTest { packageProp.expectedValue(LinuxHelper.getPackageName(cmd)).token("APPLICATION_PACKAGE").resourceDirFile(controlFile).validateOutput(cmd); verProp.expectedValue(cmd.version()).token("APPLICATION_VERSION_WITH_RELEASE").resourceDirFile(controlFile).validateOutput(cmd); - arhProp.expectedValue(LinuxHelper.getDefaultPackageArch(cmd.packageType())).token("APPLICATION_ARCH").resourceDirFile(controlFile).validateOutput(cmd); + archProp.expectedValue(LinuxHelper.getDefaultPackageArch(cmd.packageType())).token("APPLICATION_ARCH").resourceDirFile(controlFile).validateOutput(cmd); }) .forTypes(PackageType.LINUX_RPM) .addInitializer(cmd -> { diff --git a/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java b/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java index 67a5cf6b609..f8638735a6a 100644 --- a/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java +++ b/test/jdk/tools/jpackage/macosx/MacPropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,11 +21,20 @@ * questions. */ -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.MacHelper; -import jdk.jpackage.test.JPackageCommand; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import jdk.jpackage.test.Annotations.ParameterSupplier; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.CannedFormattedString; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageOutputValidator; +import jdk.jpackage.test.MacHelper; +import jdk.jpackage.test.TKit; /** @@ -43,30 +52,198 @@ import jdk.jpackage.test.Annotations.Parameter; * --jpt-run=MacPropertiesTest */ public class MacPropertiesTest { - @Test - @Parameter("MacPackageNameTest") - public void testPackageName(String packageName) { - testParameterInAppImage("--mac-package-name", "CFBundleName", - packageName); - } @Test - @Parameter("Foo") - public void testPackageIdetifier(String packageId) { - testParameterInAppImage("--mac-package-identifier", "CFBundleIdentifier", - packageId); + @ParameterSupplier + public void test(TestSpec spec) { + spec.run(); } - private static void testParameterInAppImage(String jpackageParameterName, - String plistKeyName, String value) { - JPackageCommand cmd = JPackageCommand.helloAppImage() - .addArguments(jpackageParameterName, value); + public static Collection test() { - cmd.executeAndAssertHelloAppImageCreated(); + var testCases = new ArrayList(); - var plist = MacHelper.readPListFromAppImage(cmd.outputBundle()); + testCases.addAll(List.of( + TestSpec.build("CFBundleName").addArgs("--mac-package-name", "MacPackageNameTest").expect("MacPackageNameTest"), + TestSpec.build("CFBundleIdentifier").addArgs("--mac-package-identifier", "Foo").expect("Foo"), + // Should derive from the input data. + TestSpec.build("CFBundleIdentifier").appDesc("com.acme.Hello").expect("com.acme").expect(BundleIdentifierMessage.VALUE.asCannedFormattedString("com.acme")) + )); - TKit.assertEquals(value, plist.queryValue(plistKeyName), String.format( - "Check value of %s plist key", plistKeyName)); + return testCases.stream().map(TestSpec.Builder::create).map(v -> { + return new Object[] {v}; + }).toList(); + } + + enum BundleIdentifierMessage implements CannedFormattedString.Spec { + VALUE("message.derived-bundle-identifier", "bundle-id"), + ; + + BundleIdentifierMessage(String key, Object ... args) { + this.key = Objects.requireNonNull(key); + this.args = List.of(args); + } + + @Override + public String format() { + return key; + } + + @Override + public List modelArgs() { + return args; + } + + private final String key; + private final List args; + } + + record TestSpec( + Optional appDesc, + List addArgs, + List delArgs, + List expectedTraceMessages, + String expectedInfoPlistKeyValue, + String infoPlistKey, + Optional> traceMessagesClass) { + + TestSpec { + Objects.requireNonNull(addArgs); + Objects.requireNonNull(delArgs); + Objects.requireNonNull(expectedTraceMessages); + Objects.requireNonNull(expectedInfoPlistKeyValue); + Objects.requireNonNull(infoPlistKey); + Objects.requireNonNull(traceMessagesClass); + } + + void run() { + var cmd = appDesc.map(JPackageCommand::helloAppImage).orElseGet(JPackageCommand::helloAppImage) + .setFakeRuntime().addArguments(addArgs); + + delArgs.forEach(cmd::removeArgumentWithValue); + + Consumer validatorMutator = validator -> { + validator.matchTimestamps().stripTimestamps(); + }; + + traceMessagesClass.ifPresentOrElse(v -> { + cmd.validateOutput(v, validatorMutator, expectedTraceMessages); + }, () -> { + new JPackageOutputValidator() + .mutate(validatorMutator) + .expectMatchingStrings(expectedTraceMessages) + .applyTo(cmd); + }); + + cmd.executeAndAssertHelloAppImageCreated(); + + var plist = MacHelper.readPListFromAppImage(cmd.outputBundle()); + + TKit.assertEquals( + expectedInfoPlistKeyValue, + plist.queryValue(infoPlistKey), + String.format("Check value of %s plist key", infoPlistKey)); + } + + @Override + public String toString() { + var tokens = new ArrayList(); + + tokens.add(String.format("%s=>%s", infoPlistKey, expectedInfoPlistKeyValue)); + + appDesc.ifPresent(v -> { + tokens.add("app-desc=" + v); + }); + + if (!addArgs.isEmpty()) { + tokens.add("args-add=" + addArgs); + } + + if (!delArgs.isEmpty()) { + tokens.add("args-del=" + delArgs); + } + + if (!expectedTraceMessages.isEmpty()) { + tokens.add("expect=" + expectedTraceMessages); + } + + return tokens.stream().collect(Collectors.joining("; ")); + } + + static Builder build() { + return new Builder(); + } + + static Builder build(String infoPlistKey) { + return build().infoPlistKey(Objects.requireNonNull(infoPlistKey)); + } + + static final class Builder { + + TestSpec create() { + + Class traceMessagesClass = switch (Objects.requireNonNull(infoPlistKey)) { + case "CFBundleIdentifier" -> BundleIdentifierMessage.class; + case "CFBundleName" -> null; + default -> { + throw new IllegalStateException(); + } + }; + + return new TestSpec( + Optional.ofNullable(appDesc), + addArgs, + delArgs, + expectedTraceMessages, + expectedInfoPlistKeyValue, + infoPlistKey, + Optional.ofNullable(traceMessagesClass)); + } + + Builder appDesc(String v) { + appDesc = v; + return this; + } + + Builder addArgs(List v) { + addArgs.addAll(v); + return this; + } + + Builder addArgs(String... args) { + return addArgs(List.of(args)); + } + + Builder delArgs(List v) { + delArgs.addAll(v); + return this; + } + + Builder delArgs(String... args) { + return delArgs(List.of(args)); + } + + Builder expect(CannedFormattedString traceMessage) { + expectedTraceMessages.add(traceMessage); + return this; + } + + Builder expect(String v) { + expectedInfoPlistKeyValue = v; + return this; + } + + Builder infoPlistKey(String v) { + infoPlistKey = v; + return this; + } + + private String appDesc; + private final List addArgs = new ArrayList<>(); + private final List delArgs = new ArrayList<>(); + private final List expectedTraceMessages = new ArrayList<>(); + private String expectedInfoPlistKeyValue; + private String infoPlistKey; + } } } diff --git a/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java b/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java index 0f299cb5a24..fc146270ab8 100644 --- a/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java @@ -64,7 +64,6 @@ public class SigningAppImageTest { var testAL = new AdditionalLauncher("testAL"); testAL.applyTo(cmd); - cmd.executeAndAssertHelloAppImageCreated(); MacSign.withKeychain(keychain -> { sign.addTo(cmd); @@ -82,10 +81,17 @@ public class SigningAppImageTest { SigningBase.StandardCertificateRequest.CODESIGN_UNICODE )) { for (var signIdentityType : SignKeyOption.Type.defaultValues()) { - data.add(new SignKeyOptionWithKeychain( - signIdentityType, - certRequest, - SigningBase.StandardKeychain.MAIN.keychain())); + SigningBase.StandardKeychain keychain; + if (signIdentityType == SignKeyOption.Type.SIGN_KEY_IMPLICIT) { + keychain = SigningBase.StandardKeychain.SINGLE; + if (!keychain.contains(certRequest)) { + continue; + } + } else { + keychain = SigningBase.StandardKeychain.MAIN; + } + + data.add(new SignKeyOptionWithKeychain(signIdentityType, certRequest, keychain.keychain())); } } diff --git a/test/jdk/tools/jpackage/macosx/SigningAppImageTwoStepsTest.java b/test/jdk/tools/jpackage/macosx/SigningAppImageTwoStepsTest.java index 2c7ae205e69..20af9572044 100644 --- a/test/jdk/tools/jpackage/macosx/SigningAppImageTwoStepsTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningAppImageTwoStepsTest.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.jpackage.test.AdditionalLauncher; @@ -68,6 +69,22 @@ public class SigningAppImageTwoStepsTest { spec.test(); } + @Test + public static void testAppStore() { + + var sign = new SignKeyOptionWithKeychain( + SignKeyOption.Type.SIGN_KEY_USER_SHORT_NAME, + SigningBase.StandardCertificateRequest.CODESIGN, + SigningBase.StandardKeychain.MAIN.keychain()); + + var spec = new TestSpec(Optional.empty(), sign); + + spec.signAppImage(spec.createAppImage(), Optional.of(cmd -> { + cmd.addArgument("--mac-app-store"); + })); + } + + public record TestSpec(Optional signAppImage, SignKeyOptionWithKeychain sign) { public TestSpec { @@ -93,6 +110,11 @@ public class SigningAppImageTwoStepsTest { return new TestSpec(Optional.ofNullable(signAppImage), sign); } + Builder keychain(SigningBase.StandardKeychain v) { + keychain = Objects.requireNonNull(v); + return this; + } + Builder certRequest(SigningBase.StandardCertificateRequest v) { certRequest = Objects.requireNonNull(v); return this; @@ -117,9 +139,10 @@ public class SigningAppImageTwoStepsTest { return new SignKeyOptionWithKeychain( signIdentityType, certRequest, - SigningBase.StandardKeychain.MAIN.keychain()); + keychain.keychain()); } + private SigningBase.StandardKeychain keychain = SigningBase.StandardKeychain.MAIN; private SigningBase.StandardCertificateRequest certRequest = SigningBase.StandardCertificateRequest.CODESIGN; private SignKeyOption.Type signIdentityType = SignKeyOption.Type.SIGN_KEY_IDENTITY; @@ -127,7 +150,7 @@ public class SigningAppImageTwoStepsTest { private SignKeyOptionWithKeychain sign; } - void test() { + JPackageCommand createAppImage() { var appImageCmd = JPackageCommand.helloAppImage() .setFakeRuntime() .setArgumentValue("--dest", TKit.createTempDirectory("appimage")); @@ -144,18 +167,39 @@ public class SigningAppImageTwoStepsTest { }, signOption.keychain()); }, appImageCmd::execute); - var cmd = new JPackageCommand() - .setPackageType(PackageType.IMAGE) - .addArguments("--app-image", appImageCmd.outputBundle()) - .mutate(sign::addTo); + return appImageCmd; + } - cmd.executeAndAssertHelloAppImageCreated(); - MacSignVerify.verifyAppImageSigned(cmd, sign.certRequest()); + void signAppImage(JPackageCommand appImageCmd, Optional> mutator) { + Objects.requireNonNull(appImageCmd); + Objects.requireNonNull(mutator); + + MacSign.withKeychain(keychain -> { + var cmd = new JPackageCommand() + .setPackageType(PackageType.IMAGE) + .usePredefinedAppImage(appImageCmd) + .mutate(sign::addTo); + + mutator.ifPresent(cmd::mutate); + + cmd.executeAndAssertHelloAppImageCreated(); + MacSignVerify.verifyAppImageSigned(cmd, sign.certRequest()); + }, sign.keychain()); + } + + void test() { + signAppImage(createAppImage(), Optional.empty()); } } public static Collection test() { + var signIdentityTypes = List.of( + SignKeyOption.Type.SIGN_KEY_USER_SHORT_NAME, + SignKeyOption.Type.SIGN_KEY_IDENTITY_APP_IMAGE, + SignKeyOption.Type.SIGN_KEY_IMPLICIT + ); + List data = new ArrayList<>(); for (var appImageSign : withAndWithout(SignKeyOption.Type.SIGN_KEY_IDENTITY)) { @@ -167,9 +211,12 @@ public class SigningAppImageTwoStepsTest { .certRequest(SigningBase.StandardCertificateRequest.CODESIGN_ACME_TECH_LTD) .signAppImage(); }); - for (var signIdentityType : SignKeyOption.Type.defaultValues()) { + for (var signIdentityType : signIdentityTypes) { builder.signIdentityType(signIdentityType) .certRequest(SigningBase.StandardCertificateRequest.CODESIGN); + if (signIdentityType == SignKeyOption.Type.SIGN_KEY_IMPLICIT) { + builder.keychain(SigningBase.StandardKeychain.SINGLE); + } data.add(builder.sign().create()); } } diff --git a/test/jdk/tools/jpackage/macosx/SigningBase.java b/test/jdk/tools/jpackage/macosx/SigningBase.java index 5f4367e6096..e7e2d7e44cf 100644 --- a/test/jdk/tools/jpackage/macosx/SigningBase.java +++ b/test/jdk/tools/jpackage/macosx/SigningBase.java @@ -38,7 +38,7 @@ import jdk.jpackage.test.TKit; * @test * @summary Setup the environment for jpackage macos signing tests. * Creates required keychains and signing identities. - * Does NOT run any jpackag tests. + * Does NOT run any jpackage tests. * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @compile -Xlint:all -Werror SigningBase.java @@ -51,7 +51,7 @@ import jdk.jpackage.test.TKit; * @test * @summary Tear down the environment for jpackage macos signing tests. * Deletes required keychains and signing identities. - * Does NOT run any jpackag tests. + * Does NOT run any jpackage tests. * @library /test/jdk/tools/jpackage/helpers * @build jdk.jpackage.test.* * @compile -Xlint:all -Werror SigningBase.java @@ -83,7 +83,7 @@ public class SigningBase { } private static CertificateRequest.Builder cert() { - return new CertificateRequest.Builder(); + return CertificateRequest.build(); } private final CertificateRequest spec; @@ -118,6 +118,12 @@ public class SigningBase { StandardCertificateRequest.PKG, StandardCertificateRequest.CODESIGN_COPY, StandardCertificateRequest.PKG_COPY), + /** + * A keychain with a single certificate for each role. + */ + SINGLE("jpackagerTest-single.keychain", + StandardCertificateRequest.CODESIGN, + StandardCertificateRequest.PKG), ; StandardKeychain(String keychainName, StandardCertificateRequest... certs) { @@ -145,7 +151,7 @@ public class SigningBase { } private static KeychainWithCertsSpec.Builder keychain(String name) { - return new KeychainWithCertsSpec.Builder().name(name); + return KeychainWithCertsSpec.build().name(name); } private static List signingEnv() { @@ -164,13 +170,13 @@ public class SigningBase { } public static void verifySignTestEnvReady() { - if (!Inner.SIGN_ENV_READY) { + if (!SignEnvReady.VALUE) { TKit.throwSkippedException(new IllegalStateException("Misconfigured signing test environment")); } } - private final class Inner { - private static final boolean SIGN_ENV_READY = MacSign.isDeployed(StandardKeychain.signingEnv()); + private final class SignEnvReady { + static final boolean VALUE = MacSign.isDeployed(StandardKeychain.signingEnv()); } private static final String NAME_ASCII = "jpackage.openjdk.java.net"; diff --git a/test/jdk/tools/jpackage/macosx/SigningPackageTest.java b/test/jdk/tools/jpackage/macosx/SigningPackageTest.java index 8a93ce5f749..cc2e7026d72 100644 --- a/test/jdk/tools/jpackage/macosx/SigningPackageTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningPackageTest.java @@ -65,7 +65,7 @@ import jdk.jpackage.test.PackageType; * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=SigningPackageTest.test * --jpt-space-subst=* - * --jpt-include=({--mac-signing-key-user-name:*CODESIGN},*{--mac-signing-key-user-name:*PKG},*MAC_DMG+MAC_PKG) + * --jpt-include=({KEY_USER_NAME:*CODESIGN},*{KEY_USER_NAME:*PKG},*MAC_DMG+MAC_PKG) * --jpt-before-run=SigningBase.verifySignTestEnvReady */ @@ -94,7 +94,7 @@ public class SigningPackageTest { } public static Collection test() { - return TestSpec.testCases(true).stream().map(v -> { + return TestSpec.testCases().stream().map(v -> { return new Object[] {v}; }).toList(); } @@ -126,7 +126,10 @@ public class SigningPackageTest { } if (appImageSignOption.isEmpty()) { - if (packageSignOption.get().type() != SignKeyOption.Type.SIGN_KEY_IDENTITY) { + if (!List.of( + SignKeyOption.Type.SIGN_KEY_IDENTITY, + SignKeyOption.Type.SIGN_KEY_IDENTITY_SHA1 + ).contains(packageSignOption.get().type())) { // They request to sign the .pkg installer without // the "--mac-installer-sign-identity" option, // but didn't specify a signing option for the packaged app image. @@ -204,15 +207,61 @@ public class SigningPackageTest { } MacSign.ResolvedKeychain keychain() { - return SigningBase.StandardKeychain.MAIN.keychain(); + return chooseKeychain(Stream.of( + appImageSignOption.stream(), + packageSignOption.stream() + ).flatMap(x -> x).map(SignKeyOption::type).findFirst().orElseThrow()).keychain(); } - static List testCases(boolean withUnicode) { + /** + * Types of test cases to skip. + */ + enum SkipTestCases { + /** + * Skip test cases with signing identities/key names with symbols outside of the + * ASCII codepage. + */ + SKIP_UNICODE, + /** + * Skip test cases in which the value of the "--mac-signing-key-user-name" + * option is the full signing identity name. + */ + SKIP_SIGN_KEY_USER_FULL_NAME, + /** + * Skip test cases in which the value of the "--mac-installer-sign-identity" or + * "--mac-app-image-sign-identity" option is the SHA1 digest of the signing + * certificate. + */ + SKIP_SIGN_KEY_IDENTITY_SHA1, + ; + } + + static List minimalTestCases() { + return testCases(SkipTestCases.values()); + } + + static List testCases(SkipTestCases... skipTestCases) { + + final var skipTestCasesAsSet = Set.of(skipTestCases); + + final var signIdentityTypes = Stream.of(SignKeyOption.Type.defaultValues()).filter(v -> { + switch (v) { + case SIGN_KEY_USER_FULL_NAME -> { + return !skipTestCasesAsSet.contains(SkipTestCases.SKIP_SIGN_KEY_USER_FULL_NAME); + } + case SIGN_KEY_IDENTITY_SHA1 -> { + return !skipTestCasesAsSet.contains(SkipTestCases.SKIP_SIGN_KEY_IDENTITY_SHA1); + } + default -> { + return true; + } + } + }).toList(); List data = new ArrayList<>(); List> certRequestGroups; - if (withUnicode) { + if (!skipTestCasesAsSet.contains(SkipTestCases.SKIP_UNICODE)) { certRequestGroups = List.of( List.of(SigningBase.StandardCertificateRequest.CODESIGN, SigningBase.StandardCertificateRequest.PKG), List.of(SigningBase.StandardCertificateRequest.CODESIGN_UNICODE, SigningBase.StandardCertificateRequest.PKG_UNICODE) @@ -224,19 +273,33 @@ public class SigningPackageTest { } for (var certRequests : certRequestGroups) { - for (var signIdentityType : SignKeyOption.Type.defaultValues()) { - var keychain = SigningBase.StandardKeychain.MAIN.keychain(); + for (var signIdentityType : signIdentityTypes) { + if (signIdentityType == SignKeyOption.Type.SIGN_KEY_IMPLICIT + && !SigningBase.StandardKeychain.SINGLE.contains(certRequests.getFirst())) { + // Skip invalid test case: the keychain for testing signing without + // an explicitly specified signing key option doesn't have this signing key. + break; + } + + if (signIdentityType.passThrough() && !certRequests.contains(SigningBase.StandardCertificateRequest.CODESIGN)) { + // Using a pass-through signing option. + // Doesn't make sense to waste time on testing it with multiple certificates. + // Skip the test cases using non "default" certificate. + break; + } + + var keychain = chooseKeychain(signIdentityType).keychain(); var appImageSignKeyOption = new SignKeyOption(signIdentityType, certRequests.getFirst(), keychain); var pkgSignKeyOption = new SignKeyOption(signIdentityType, certRequests.getLast(), keychain); switch (signIdentityType) { - case SIGN_KEY_IDENTITY -> { + case SIGN_KEY_IDENTITY, SIGN_KEY_IDENTITY_SHA1 -> { // Use "--mac-installer-sign-identity" and "--mac-app-image-sign-identity" signing options. // They allows to sign the packaged app image and the installer (.pkg) separately. data.add(new TestSpec(Optional.of(appImageSignKeyOption), Optional.empty(), PackageType.MAC)); data.add(new TestSpec(Optional.empty(), Optional.of(pkgSignKeyOption), PackageType.MAC_PKG)); } - case SIGN_KEY_USER_SHORT_NAME -> { + case SIGN_KEY_USER_SHORT_NAME, SIGN_KEY_IMPLICIT -> { // Use "--mac-signing-key-user-name" signing option with short user name or implicit signing option. // It signs both the packaged app image and the installer (.pkg). // Thus, if the installer is not signed, it can be used only with .dmg packaging. @@ -263,5 +326,13 @@ public class SigningPackageTest { return data; } + + private static SigningBase.StandardKeychain chooseKeychain(SignKeyOption.Type signIdentityType) { + if (signIdentityType == SignKeyOption.Type.SIGN_KEY_IMPLICIT) { + return SigningBase.StandardKeychain.SINGLE; + } else { + return SigningBase.StandardKeychain.MAIN; + } + } } } diff --git a/test/jdk/tools/jpackage/macosx/SigningPackageTwoStepTest.java b/test/jdk/tools/jpackage/macosx/SigningPackageTwoStepTest.java index 23195c9a856..d0de9c8c704 100644 --- a/test/jdk/tools/jpackage/macosx/SigningPackageTwoStepTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningPackageTwoStepTest.java @@ -108,7 +108,7 @@ public class SigningPackageTwoStepTest { appImageSignOption = Optional.empty(); } - for (var signPackage : SigningPackageTest.TestSpec.testCases(false)) { + for (var signPackage : SigningPackageTest.TestSpec.minimalTestCases()) { data.add(new TwoStepsTestSpec(appImageSignOption, signPackage)); } } diff --git a/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java b/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java index 604399ebd7a..42a0e6fd664 100644 --- a/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java @@ -37,6 +37,8 @@ import jdk.jpackage.internal.util.Slot; import jdk.jpackage.test.Annotations.ParameterSupplier; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageOutputValidator; +import jdk.jpackage.test.JPackageStringBundle; import jdk.jpackage.test.MacHelper; import jdk.jpackage.test.MacHelper.ResolvableCertificateRequest; import jdk.jpackage.test.MacHelper.SignKeyOption; @@ -98,6 +100,13 @@ public class SigningRuntimeImagePackageTest { cmd.ignoreDefaultRuntime(true); cmd.removeArgumentWithValue("--input"); cmd.setArgumentValue("--runtime-image", predefinedRuntime.get()); + + // `warning.per.user.app.image.signed` warning doesn't apply to runtime bundling. + // Ensure the warning is not in the output. + new JPackageOutputValidator().add(TKit.assertTextStream( + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("warning.per.user.app.image.signed", "file") + ).negate()).stdoutAndStderr().applyTo(cmd); + }).addInstallVerifier(cmd -> { MacSignVerify.verifyAppImageSigned(cmd, signRuntime.certRequest()); }).run(); @@ -125,7 +134,7 @@ public class SigningRuntimeImagePackageTest { runtimeSignOption = Optional.empty(); } - for (var signPackage : SigningPackageTest.TestSpec.testCases(false)) { + for (var signPackage : SigningPackageTest.TestSpec.minimalTestCases()) { data.add(new RuntimeTestSpec(runtimeSignOption, runtimeType, signPackage)); } } @@ -200,7 +209,7 @@ public class SigningRuntimeImagePackageTest { // This way we can test if jpackage keeps or replaces the signature of // the predefined runtime bundle when backing it in the pkg or dmg installer. return new SignKeyOptionWithKeychain( - SignKeyOption.Type.SIGN_KEY_USER_SHORT_NAME, + SignKeyOption.Type.SIGN_KEY_IDENTITY_APP_IMAGE, SigningBase.StandardCertificateRequest.CODESIGN_ACME_TECH_LTD, SigningBase.StandardKeychain.MAIN.keychain()); } diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/ControlEvents.md new file mode 100644 index 00000000000..39e6b535e69 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/ControlEvents.md @@ -0,0 +1,8 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| InstallDirNotEmptyDlg | No | NewDialog | InstallDirDlg | 1 | 1 | +| InstallDirNotEmptyDlg | Yes | NewDialog | ShortcutPromptDlg | 1 | 1 | +| ShortcutPromptDlg | Back | NewDialog | InstallDirDlg | 1 | 1 | +| ShortcutPromptDlg | Cancel | SpawnDialog | CancelDlg | 1 | 1 | +| ShortcutPromptDlg | Next | NewDialog | VerifyReadyDlg | 1 | 1 | +| VerifyReadyDlg | Back | NewDialog | ShortcutPromptDlg | NOT Installed | 6 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license+shortcut_prompt/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/ControlEvents.md new file mode 100644 index 00000000000..1d908b0508a --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/ControlEvents.md @@ -0,0 +1,4 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| InstallDirNotEmptyDlg | No | NewDialog | InstallDirDlg | 1 | 1 | +| InstallDirNotEmptyDlg | Yes | NewDialog | VerifyReadyDlg | 1 | 1 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+license/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/ControlEvents.md new file mode 100644 index 00000000000..93d11c944e0 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/ControlEvents.md @@ -0,0 +1,10 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| InstallDirDlg | Back | NewDialog | WelcomeDlg | NOT Installed | 6 | +| InstallDirNotEmptyDlg | No | NewDialog | InstallDirDlg | 1 | 1 | +| InstallDirNotEmptyDlg | Yes | NewDialog | ShortcutPromptDlg | 1 | 1 | +| ShortcutPromptDlg | Back | NewDialog | InstallDirDlg | 1 | 1 | +| ShortcutPromptDlg | Cancel | SpawnDialog | CancelDlg | 1 | 1 | +| ShortcutPromptDlg | Next | NewDialog | VerifyReadyDlg | 1 | 1 | +| VerifyReadyDlg | Back | NewDialog | ShortcutPromptDlg | NOT Installed | 6 | +| WelcomeDlg | Next | NewDialog | InstallDirDlg | NOT Installed | 6 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser+shortcut_prompt/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/ControlEvents.md new file mode 100644 index 00000000000..2fcc387732a --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/ControlEvents.md @@ -0,0 +1,6 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| InstallDirDlg | Back | NewDialog | WelcomeDlg | NOT Installed | 6 | +| InstallDirNotEmptyDlg | No | NewDialog | InstallDirDlg | 1 | 1 | +| InstallDirNotEmptyDlg | Yes | NewDialog | VerifyReadyDlg | 1 | 1 | +| WelcomeDlg | Next | NewDialog | InstallDirDlg | NOT Installed | 6 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/dir_chooser/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/ControlEvents.md new file mode 100644 index 00000000000..72e8b80ca08 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/ControlEvents.md @@ -0,0 +1,7 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| LicenseAgreementDlg | Next | NewDialog | ShortcutPromptDlg | LicenseAccepted = "1" | 6 | +| ShortcutPromptDlg | Back | NewDialog | LicenseAgreementDlg | 1 | 1 | +| ShortcutPromptDlg | Cancel | SpawnDialog | CancelDlg | 1 | 1 | +| ShortcutPromptDlg | Next | NewDialog | VerifyReadyDlg | 1 | 1 | +| VerifyReadyDlg | Back | NewDialog | ShortcutPromptDlg | NOT Installed | 6 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license+shortcut_prompt/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/ControlEvents.md new file mode 100644 index 00000000000..7a9bcca86f3 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/ControlEvents.md @@ -0,0 +1,2 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/InstallUISequence.md new file mode 100644 index 00000000000..3008e0db54b --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/license/InstallUISequence.md @@ -0,0 +1,4 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | Installed AND PATCH | +| WelcomeEulaDlg | NOT Installed | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/ControlEvents.md new file mode 100644 index 00000000000..a93b0ecbff1 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/ControlEvents.md @@ -0,0 +1,7 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | +| ShortcutPromptDlg | Back | NewDialog | WelcomeDlg | NOT Installed | 6 | +| ShortcutPromptDlg | Cancel | SpawnDialog | CancelDlg | 1 | 1 | +| ShortcutPromptDlg | Next | NewDialog | VerifyReadyDlg | 1 | 1 | +| VerifyReadyDlg | Back | NewDialog | ShortcutPromptDlg | NOT Installed | 6 | +| WelcomeDlg | Next | NewDialog | ShortcutPromptDlg | NOT Installed | 6 | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/InstallUISequence.md new file mode 100644 index 00000000000..e583dfa4982 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/shortcut_prompt/InstallUISequence.md @@ -0,0 +1,3 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | NOT Installed OR PATCH | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/ControlEvents.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/ControlEvents.md new file mode 100644 index 00000000000..7a9bcca86f3 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/ControlEvents.md @@ -0,0 +1,2 @@ +| Dialog | Control | Event | Argument | Condition | Ordering | +| --- | --- | --- | --- | --- | --- | diff --git a/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/InstallUISequence.md b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/InstallUISequence.md new file mode 100644 index 00000000000..6e3eef39f43 --- /dev/null +++ b/test/jdk/tools/jpackage/resources/WinInstallerUiTest/ui/InstallUISequence.md @@ -0,0 +1,4 @@ +| Action | Condition | +| --- | --- | +| WelcomeDlg | Installed AND PATCH | +| WelcomeEulaDlg | 0 | diff --git a/test/jdk/tools/jpackage/resources/msi-export.js b/test/jdk/tools/jpackage/resources/msi-export.js index d639f19ca44..6cb5ab5a781 100644 --- a/test/jdk/tools/jpackage/resources/msi-export.js +++ b/test/jdk/tools/jpackage/resources/msi-export.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -71,7 +71,7 @@ function exportTables(db, outputDir, requestedTableNames) { var msi = WScript.arguments(0) var outputDir = WScript.arguments(1) var tables = {} - for (var i = 0; i !== WScript.arguments.Count(); i++) { + for (var i = 2; i !== WScript.arguments.Count(); i++) { tables[WScript.arguments(i)] = true } diff --git a/test/jdk/tools/jpackage/share/AppVersionTest.java b/test/jdk/tools/jpackage/share/AppVersionTest.java index ad96a9b9e0c..598ee1551b3 100644 --- a/test/jdk/tools/jpackage/share/AppVersionTest.java +++ b/test/jdk/tools/jpackage/share/AppVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,15 +22,46 @@ */ +import static java.util.stream.Collectors.toUnmodifiableMap; +import static java.util.stream.Collectors.toUnmodifiableSet; +import static jdk.jpackage.internal.util.PListWriter.writeDict; +import static jdk.jpackage.internal.util.PListWriter.writePList; +import static jdk.jpackage.internal.util.XmlUtils.createXml; +import static jdk.jpackage.internal.util.XmlUtils.toXmlConsumer; +import static jdk.jpackage.test.JPackageCommand.DEFAULT_VERSION; +import static jdk.jpackage.test.JPackageCommand.normalizeDerivedVersion; +import static jdk.jpackage.test.JPackageCommand.RuntimeImageType.RUNTIME_TYPE_FAKE; + import java.io.IOException; -import java.util.Collection; +import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import javax.xml.xpath.XPathExpressionException; -import jdk.jpackage.test.AppImageFile; -import jdk.jpackage.test.Annotations.Parameters; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Predicate; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.MacBundle; +import jdk.jpackage.internal.util.RuntimeReleaseFile; +import jdk.jpackage.internal.util.Slot; +import jdk.jpackage.test.Annotations.ParameterSupplier; import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.AppImageFile; +import jdk.jpackage.test.CannedFormattedString; +import jdk.jpackage.test.ConfigurationTarget; import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageCommand.StandardAssert; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.MacHelper; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.RunnablePackageTest.Action; import jdk.jpackage.test.TKit; /* @@ -45,54 +76,942 @@ import jdk.jpackage.test.TKit; public final class AppVersionTest { - @Parameters - public static Collection input() { - List data = new ArrayList<>(); + @Test + @ParameterSupplier + public static void testApp(AppTestSpec testSpec) { - data.addAll(List.of(new Object[][]{ - // Default jpackage version - {"1.0", "Hello", null}, - {"1.0", "com.other/com.other.Hello", null}, - // Version should be picked from --app-version - {"3.1", "Hello", new String[]{"--app-version", "3.1"}}, - {"3.2", "com.other/com.other.Hello", new String[]{"--app-version", - "3.2"}}, - // Version should be picked from the last --app-version - {"3.3", "Hello", new String[]{"--app-version", "4", "--app-version", - "3.3"}}, - {"7.8", "com.other/com.other.Hello", new String[]{"--app-version", - "4", "--app-version", "7.8"}}, - // Pick version from jar - {"3.10.17", "com.other/com.other.Hello@3.10.17", null}, - // Ignore version in jar if --app-version given - {"7.5.81", "com.other/com.other.Hello@3.10.17", new String[]{ - "--app-version", "7.5.81"}} - })); + var moduleVersionSource = testSpec.findVersionSource(ModuleVersionSource.class); - return data; - } + ConfigurationTarget cfg; + if (testSpec.isImagePackageType()) { + var cmd = moduleVersionSource.map(ModuleVersionSource::appDesc) + .map(JPackageCommand::helloAppImage) + .orElseGet(JPackageCommand::helloAppImage); + cfg = new ConfigurationTarget(cmd); + } else { + var nativeTest = new PackageTest().forTypes(testSpec.spec().expected().keySet()); + moduleVersionSource + .map(ModuleVersionSource::appDesc) + .ifPresentOrElse(nativeTest::configureHelloApp, nativeTest::configureHelloApp); - public AppVersionTest(String expectedVersion, String javaAppDesc, - String[] jpackageArgs) { - this.expectedVersion = expectedVersion; - this.javaAppDesc = javaAppDesc; - this.jpackageArgs = jpackageArgs; + cfg = new ConfigurationTarget(nativeTest); + } + + cfg.addInitializer(JPackageCommand::setFakeRuntime); + + cfg.addInitializer(testSpec::applyTo); + + cfg.cmd().ifPresent(JPackageCommand::executeAndAssertHelloAppImageCreated); + + testSpec.validateVersion(cfg); + + cfg.test().ifPresent(pkg -> { + pkg.run(testSpec.spec().packageTestActions()); + }); } @Test - public void test() throws XPathExpressionException, IOException { - JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc); - if (jpackageArgs != null) { - cmd.addArguments(jpackageArgs); - } - cmd.executeAndAssertHelloAppImageCreated(); + @ParameterSupplier + @ParameterSupplier(value = "testMacPredefinedRuntimeBundle", ifOS = OperatingSystem.MACOS) + public static void testRuntime(RuntimeTestSpec testSpec) { - String actualVersion = AppImageFile.load(cmd.outputBundle()).version(); - TKit.assertEquals(expectedVersion, actualVersion, - "Check application version"); + var predefinedRuntimeDir = Slot.createEmpty(); + new PackageTest() + .forTypes(testSpec.spec().expected().keySet()) + .addRunOnceInitializer(() -> { + predefinedRuntimeDir.set(testSpec.createRuntime()); + }) + .addInitializer(cmd -> { + cmd.removeArgumentWithValue("--input").setArgumentValue("--runtime-image", predefinedRuntimeDir.get()); + }) + .addInitializer(testSpec::applyTo) + .mutate(test -> { + testSpec.validateVersion(new ConfigurationTarget(test)); + }) + .run(testSpec.spec().packageTestActions()); } - private final String expectedVersion; - private final String javaAppDesc; - private final String[] jpackageArgs; + public static Collection testApp() { + + List testCases = new ArrayList<>(); + + for (var modular : List.of(true, false)) { + String appDesc; + if (modular) { + appDesc = "com.other/com.other.Hello"; + } else { + appDesc = "Hello"; + } + + // Default version. + AppTestSpec.create(appDesc, TestSpec.build().expectDefaultVersion(), testCases::add); + + // Pick version from the command line. + AppTestSpec.create(appDesc, TestSpec.build().versionFromCmdline("3.1"), testCases::add); + } + + // Pick version from the modular jar. + AppTestSpec.create(TestSpec.build() + .versionFromAppModule("com.other/com.other.Hello@3.10.16"), testCases::add); + + // Pick version from the command line, ignore version of the modular jar. + AppTestSpec.create(TestSpec.build() + .versionFromAppModule("com.other/com.other.Hello@3.10.18") + .versionFromCmdline("7.5.81"), testCases::add); + + // Pick version from the modular jar. Apply package-specific normalization. + for (var ver : List.of( + "30.10.17.204.899-foo" + )) { + var versionSource = new ModuleVersionSource("com.other/com.other.Hello@" + ver); + + var builder = TestSpec.build().versionSource(versionSource); + for (var e : TestSpec.Builder.getExpectedVersions(versionSource).entrySet()) { + builder.withTypes(e.getKey()).expect(e.getValue()); + } + + AppTestSpec.create(builder, testCases::add); + } + + return testCases.stream().map(v -> { + return new Object[] {v}; + }).toList(); + } + + public static Collection testRuntime() { + + List testCases = new ArrayList<>(); + + // Default version. + RuntimeTestSpec.create(TestSpec.build().expectDefaultVersion(), testCases::add); + + // Pick version from the command line. + RuntimeTestSpec.create(TestSpec.build().versionFromCmdline("3.1"), testCases::add); + + // Invalid versions. + for (var ver : List.of("foo", "", "17.21.3+foo")) { + RuntimeTestSpec.create(TestSpec.build().versionFromReleaseFile(ver).expectDefaultVersion(), testCases::add); + } + + // Valid version values (see java.lang.Runtime.Version javadoc and https://openjdk.org/jeps/223) + for (var suffix : jep223VersionSuffixes()) { + for (var vnum : List.of("17", "17.1", "17.1.2", "17.1.2.3", "17.1.2.3.5")) { + var ver = new RuntimeReleaseFileVersionSource(vnum + suffix); + + var builder = TestSpec.build().versionSource(ver); + for (var e : TestSpec.Builder.getExpectedVersions(ver).entrySet()) { + builder.withTypes(e.getKey()).expect(e.getValue()); + } + + RuntimeTestSpec.create(builder, testCases::add); + } + } + + return testCases.stream().map(v -> { + return new Object[] {v}; + }).toList(); + } + + public static Collection testMacPredefinedRuntimeBundle() { + + List testCases = new ArrayList<>(); + + var appendTestCases = skipImagePackageType(testSpec -> { + for (var runtimeType : List.of( + RuntimeType.MAC_BUNDLE_PLIST_FILE_MALFORMED, + RuntimeType.MAC_BUNDLE_PLIST_WITHOUT_VERSION + )) { + testCases.add(new RuntimeTestSpec(runtimeType, testSpec)); + } + }); + + // Invalid version. + TestSpec.build().versionFromReleaseFile("foo").expectDefaultVersion().create(appendTestCases); + + // Valid versions. + for (var suffix : List.of("", "-foo")) { + for (var vnum : List.of("17", "17.1", "17.1.2", "17.1.2.3")) { + var ver = new RuntimeReleaseFileVersionSource(vnum + suffix); + + var builder = TestSpec.build().versionSource(ver); + var allBundleTypes = TestSpec.Builder.getExpectedVersions(ver); + for (var bundleType : PackageType.MAC) { + builder.withTypes(bundleType).expect(Objects.requireNonNull(allBundleTypes.get(bundleType))); + } + + builder.create(appendTestCases); + } + } + + return testCases.stream().map(v -> { + return new Object[] {v}; + }).toList(); + } + + private static List jep223VersionSuffixes() { + var suffixes = new HashSet(); + for (var pre : List.of("", "-ea")) { + for (var build : List.of("", "+5678")) { + for (var opt : List.of("", "-foo", "-12.UZ3")) { + if (pre.isEmpty() && build.isEmpty() && !opt.isEmpty()) { + suffixes.add("+" + opt); + } else { + suffixes.add(pre + build + opt); + } + } + } + } + return suffixes.stream().sorted().peek(suffix -> { + // Validate version suffixes. + Runtime.Version.parse("11" + suffix); + }).toList(); + } + + enum Message implements CannedFormattedString.Spec { + VERSION_FROM_MODULE("message.module-version", "version", "module"), + VERSION_FROM_RELEASE_FILE("message.release-version", "version"), + VERSION_NORMALIZED("message.version-normalized", "version", "version"), + ; + + Message(String key, Object ... args) { + this.key = Objects.requireNonNull(key); + this.args = List.of(args); + } + + @Override + public String format() { + return key; + } + + @Override + public List modelArgs() { + return args; + } + + private final String key; + private final List args; + } + + sealed interface VersionSource { + String version(); + + VersionSource copyWithVersion(String v); + } + + enum DefaultVersionSource implements VersionSource { + INSTANCE; + + @Override + public String version() { + return DEFAULT_VERSION; + } + + @Override + public VersionSource copyWithVersion(String v) { + return this; + } + } + + record ModuleVersionSource(String appDesc) implements VersionSource { + + ModuleVersionSource { + Objects.requireNonNull(appDesc); + if (JavaAppDesc.parse(appDesc).moduleVersion() == null) { + throw new IllegalArgumentException(); + } + } + + @Override + public String version() { + return JavaAppDesc.parse(appDesc).moduleVersion(); + } + + @Override + public VersionSource copyWithVersion(String v) { + return new ModuleVersionSource(moduleName() + "@" + Objects.requireNonNull(v)); + } + + String moduleName() { + return JavaAppDesc.parse(appDesc).moduleName(); + } + + @Override + public String toString() { + return appDesc; + } + } + + record CmdlineVersionSource(String version) implements VersionSource { + + CmdlineVersionSource { + Objects.requireNonNull(version); + } + + @Override + public VersionSource copyWithVersion(String v) { + return new CmdlineVersionSource(v); + } + + @Override + public String toString() { + return String.format("--app-version=[%s]", version); + } + } + + record RuntimeReleaseFileVersionSource(String version) implements VersionSource { + + RuntimeReleaseFileVersionSource { + Objects.requireNonNull(version); + } + + @Override + public VersionSource copyWithVersion(String v) { + return new RuntimeReleaseFileVersionSource(v); + } + + @Override + public String toString() { + return String.format("JAVA_VERSION=[%s]", version); + } + } + + record Expected(String version, List messages) { + + Expected { + Objects.requireNonNull(version); + Objects.requireNonNull(messages); + } + + void applyTo(JPackageCommand cmd) { + cmd.version(version).validateOutput(Message.class, validator -> { + validator.matchTimestamps().stripTimestamps(); + }, messages); + } + + @Override + public String toString() { + var sb = new StringBuilder(); + sb.append(version); + if (!messages.isEmpty()) { + sb.append("; ").append(messages); + } + return sb.toString(); + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + Expected create() { + return new Expected(version, List.copyOf(messages)); + } + + Builder version(String v) { + version = v; + return this; + } + + Builder messages(List v) { + messages.addAll(v); + return this; + } + + Builder messages(CannedFormattedString... v) { + return messages(List.of(v)); + } + + Builder message(Message message, Object ... args) { + return messages(message.asCannedFormattedString(args)); + } + + private String version; + private final List messages = new ArrayList<>(); + } + } + + record TestSpec(Collection versions, Map expected) { + + TestSpec { + Objects.requireNonNull(versions); + Objects.requireNonNull(expected); + + if (expected.isEmpty()) { + throw new IllegalArgumentException(); + } + + if (expected.keySet().contains(PackageType.IMAGE) && !Collections.disjoint(expected.keySet(), PackageType.NATIVE)) { + throw new IllegalArgumentException("Mixing of native and app image packaging"); + } + + if (expected.keySet().stream().map(PackageType::os).distinct().count() != 1) { + throw new IllegalArgumentException("All package types must be for the same OS"); + } + } + + Optional findVersionSource(Class versionSourceType) { + Objects.requireNonNull(versionSourceType); + return versions.stream().filter(versionSourceType::isInstance).map(versionSourceType::cast).findFirst(); + } + + void applyTo(JPackageCommand cmd) { + Objects.requireNonNull(cmd); + findVersionSource(CmdlineVersionSource.class).ifPresent(ver -> { + cmd.setArgumentValue("--app-version", ver.version()); + }); + expected.get(cmd.packageType()).applyTo(cmd); + } + + void validateVersion(ConfigurationTarget cfg) { + cfg.cmd().ifPresent(cmd -> { + var actualVersion = AppImageFile.load(cmd.outputBundle()).version(); + TKit.assertEquals(expected.get(cmd.packageType()).version(), actualVersion, "Check application version"); + }); + cfg.test().ifPresent(test -> { + expected.entrySet().forEach(e -> { + nativeBundleVersionPropertyName(e.getKey()).ifPresent(propertyName -> { + test.forTypes(e.getKey(), _ -> { + test.addBundlePropertyVerifier(propertyName, e.getValue().version()); + }); + }); + }); + }); + + if (os() == OperatingSystem.MACOS) { + cfg.addInstallVerifier(cmd -> { + final var bundleRoot = cmd.isImagePackageType() ? cmd.outputBundle() + : cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory()); + var plist = MacHelper.readPListFromAppImage(bundleRoot); + var expectedVersion = expected.get(cmd.packageType()).version(); + for (var prop : List.of("CFBundleVersion", "CFBundleShortVersionString")) { + TKit.assertEquals(expectedVersion, plist.queryValue(prop), + String.format("Check the value of '%s' property in [%s] bundle", prop, bundleRoot)); + } + }); + } + } + + boolean isImagePackageType() { + return expected.keySet().contains(PackageType.IMAGE); + } + + Action[] packageTestActions() { + if (os() == OperatingSystem.MACOS) { + return Action.CREATE_AND_UNPACK; + } else { + return new Action[] {Action.CREATE}; + } + } + + OperatingSystem os() { + return expected.keySet().iterator().next().os(); + } + + @Override + public String toString() { + var sb = new StringBuilder(); + + switch (versions.size()) { + case 0 -> { + } + case 1 -> { + sb.append(versions.iterator().next()).append("; "); + } + default -> { + sb.append("versions=").append(versions).append("; "); + } + } + + sb.append("expect="); + if (expected.values().stream().distinct().count() == 1) { + sb.append(expected.keySet().stream().sorted().toList()).append(":"); + sb.append(expected.values().iterator().next()); + } else { + sb.append('[').append(expected).append(']'); + } + + return sb.toString(); + } + + private static Optional nativeBundleVersionPropertyName(PackageType type) { + switch (type) { + case LINUX_DEB, LINUX_RPM -> { + return Optional.of("Version"); + } + case WIN_MSI -> { + return Optional.of("ProductVersion"); + } + default -> { + return Optional.empty(); + } + } + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + Builder() { + } + + Builder(Builder other) { + currentTypes = other.currentTypes; + currentExpectedVersion = other.currentExpectedVersion; + pendingCommit = other.pendingCommit; + versions.addAll(other.versions); + expected.putAll(other.expected); + } + + Builder copy() { + return new Builder(this); + } + + void create(Consumer sink) { + Objects.requireNonNull(sink); + if (pendingCommit) { + copy().expect(expectedVersion()).commit().create(sink); + } else { + var types = expected.keySet(); + var copiedVersions = List.copyOf(versions); + if (types.contains(PackageType.IMAGE) && !Collections.disjoint(types, PackageType.NATIVE)) { + sink.accept(new TestSpec(copiedVersions, Map.of(PackageType.IMAGE, expected.get(PackageType.IMAGE)))); + var copy = new HashMap<>(expected); + copy.remove(PackageType.IMAGE); + sink.accept(new TestSpec(copiedVersions, copy)); + } else { + new TestSpec(copiedVersions, Map.copyOf(expected)); + } + } + } + + Builder versionSource(VersionSource v) { + if (Objects.requireNonNull(v) == DefaultVersionSource.INSTANCE) { + throw new IllegalArgumentException(); + } + versions.add(v); + pendingCommit = true; + return this; + } + + Builder versionFromCmdline(String v) { + return versionSource(new CmdlineVersionSource(v)); + } + + Builder versionFromAppModule(String v) { + return versionSource(new ModuleVersionSource(v)); + } + + Builder versionFromReleaseFile(String v) { + return versionSource(new RuntimeReleaseFileVersionSource(v)); + } + + Builder expect(VersionSource v) { + currentExpectedVersion = v; + pendingCommit = true; + return this; + } + + Builder expectDefaultVersion() { + return expect(DefaultVersionSource.INSTANCE); + } + + Builder expectVersionFromCmdline(String v) { + return expect(new CmdlineVersionSource(v)); + } + + Builder expectVersionFromAppModule(String appDesc) { + return expect(new ModuleVersionSource(appDesc)); + } + + Builder expectVersionFromReleaseFile(String v) { + return expect(new RuntimeReleaseFileVersionSource(v)); + } + + Builder withTypes(Set types) { + if (types.isEmpty()) { + types = ALL_TYPES; + } + + if (!currentTypes.equals(types)) { + commit(); + currentTypes = types; + } + + return this; + } + + Builder withTypes(PackageType ... types) { + return withTypes(Set.of(types)); + } + + static Map getExpectedVersions(VersionSource versionSource) { + var map = new HashMap(normalizeDerivedVersion(versionSource.version()).entrySet() + .stream() + .collect(toUnmodifiableMap(Map.Entry::getKey, e -> { + return versionSource.copyWithVersion(e.getValue()); + }) + )); + + ALL_TYPES.forEach(type -> { + map.putIfAbsent(type, DefaultVersionSource.INSTANCE); + }); + + return map; + } + + private VersionSource expectedVersion() { + return Optional.ofNullable(currentExpectedVersion).or(() -> { + return versions.stream().filter(CmdlineVersionSource.class::isInstance).findFirst(); + }).or(() -> { + if (versions.size() == 1) { + return Optional.of(versions.getFirst()); + } else { + return Optional.empty(); + } + }).orElseThrow(IllegalStateException::new); + } + + private Builder commit() { + pendingCommit = false; + + if (versions.isEmpty() && currentExpectedVersion == null) { + // Nothing to commit. + return this; + } + + var filteredTypes = normalize(currentTypes); + if (filteredTypes.isEmpty()) { + // Version configuration is not supported on the current OS. + return this; + } + + VersionSource expectedVersion = expectedVersion(); + + VersionSource versionSource; + if (expectedVersion == DefaultVersionSource.INSTANCE) { + versionSource = expectedVersion; + } else { + versionSource = versions.stream().filter(expectedVersion.getClass()::isInstance).findFirst().orElseThrow(); + } + + var expectedBuilder = Expected.build().version(expectedVersion.version()); + switch (versionSource) { + case ModuleVersionSource ver -> { + expectedBuilder.message(Message.VERSION_FROM_MODULE, ver.version(), ver.moduleName()); + } + case RuntimeReleaseFileVersionSource ver -> { + expectedBuilder.message(Message.VERSION_FROM_RELEASE_FILE, ver.version()); + } + default -> { + // NOP + } + } + + if (!versionSource.version().equals(expectedVersion.version())) { + expectedBuilder.message(Message.VERSION_NORMALIZED, expectedVersion.version(), versionSource.version()); + } + + var expectedValue = expectedBuilder.create(); + filteredTypes.forEach(type -> { + expected.put(type, expectedValue); + }); + + return this; + } + + private static Set normalize(Collection types) { + return types.stream().filter(type -> { + return type.os() == OperatingSystem.current(); + }) + // Filter out "exe" packaging as it is a duplicate of "msi" packaging and + // the testing lib can't validate properties of embedded msi file. + .filter(Predicate.isEqual(PackageType.WIN_EXE).negate()) + .map(type -> { + if (type.isAppImage()) { + return PackageType.IMAGE; + } else { + return type; + } + }).collect(toUnmodifiableSet()); + } + + private Set currentTypes = ALL_TYPES; + private VersionSource currentExpectedVersion; + private boolean pendingCommit; + private final List versions = new ArrayList<>(); + private final Map expected = new HashMap<>(); + + private static final Set ALL_TYPES = Set.of(PackageType.values()); + } + } + + record AppTestSpec(String appDesc, TestSpec spec) { + + AppTestSpec { + Objects.requireNonNull(appDesc); + Objects.requireNonNull(spec); + } + + AppTestSpec(TestSpec spec) { + this(spec.findVersionSource(ModuleVersionSource.class).orElseThrow().appDesc(), spec); + } + + static void create(String appDesc, TestSpec.Builder specBuilder, Consumer sink) { + Objects.requireNonNull(appDesc); + Objects.requireNonNull(sink); + specBuilder.create(spec -> { + sink.accept(new AppTestSpec(appDesc, spec)); + }); + } + + static void create(TestSpec.Builder specBuilder, Consumer sink) { + Objects.requireNonNull(sink); + specBuilder.create(spec -> { + sink.accept(new AppTestSpec(spec)); + }); + } + + Optional findVersionSource(Class versionSourceType) { + return spec.findVersionSource(versionSourceType); + } + + void applyTo(JPackageCommand cmd) { + spec.applyTo(cmd); + } + + void validateVersion(ConfigurationTarget cfg) { + spec.validateVersion(cfg); + } + + boolean isImagePackageType() { + return spec.isImagePackageType(); + } + + @Override + public String toString() { + var sb = new StringBuilder(); + if (spec.findVersionSource(ModuleVersionSource.class).map(ModuleVersionSource::appDesc).filter(appDesc::equals).isEmpty()) { + sb.append("app-desc=").append(appDesc()).append("; "); + } + sb.append(spec); + return sb.toString(); + } + } + + /** + * Type of the predefined runtime. + */ + enum RuntimeType { + /** + * A directory with the standard Java runtime structure. + */ + IMAGE, + /** + * macOS bundle with valid Info.plist file. + */ + MAC_BUNDLE, + /** + * macOS bundle with malformed Info.plist file. + */ + MAC_BUNDLE_PLIST_FILE_MALFORMED, + /** + * macOS bundle with Info.plist file without version. + */ + MAC_BUNDLE_PLIST_WITHOUT_VERSION, + ; + } + + record RuntimeTestSpec(RuntimeType type, TestSpec spec) { + + RuntimeTestSpec { + Objects.requireNonNull(type); + Objects.requireNonNull(spec); + if (spec.isImagePackageType()) { + throw new IllegalArgumentException(); + } + if (type == RuntimeType.MAC_BUNDLE && spec.os() != OperatingSystem.MACOS) { + throw new IllegalArgumentException("Bundle runtime is supported for macOS native packaging only"); + } + } + + static void create(TestSpec.Builder specBuilder, Consumer sink) { + Objects.requireNonNull(sink); + specBuilder.create(skipImagePackageType(spec -> { + if (spec.os() != OperatingSystem.MACOS) { + sink.accept(new RuntimeTestSpec(RuntimeType.IMAGE, spec)); + } else { + sink.accept(new RuntimeTestSpec(RuntimeType.IMAGE, spec)); + + if (spec.findVersionSource(CmdlineVersionSource.class).isPresent()) { + // Disable "AppVersionTest.testRuntime(mac_bundle; versions=[--app-version=[3.1], plist=[1.22.333]]; expect=[MAC_DMG, MAC_PKG]:3.1)" test for now + // as it will fail because jpackage halfway ignores the "--app-version" + // and any option in general that makes its way into the Info.plist file. + // When building a runtime from the predefined runtime bundle, + // jpackage copies the Info.plist file from the predefined runtime bundle into the output bundle verbatim. + return; + } + + var plistVersionSource = new InheritPListVersionSource(MAC_PREDEFINED_RUNTIME_BUNDLE_VERSION); + var specBuilderCopy = specBuilder.copy().versionSource(plistVersionSource).withTypes(PackageType.ALL_MAC); + if (spec.findVersionSource(CmdlineVersionSource.class).isEmpty()) { + specBuilderCopy.expect(plistVersionSource); + } + specBuilderCopy.create(skipImagePackageType(augmentedSpec -> { + sink.accept(new RuntimeTestSpec(RuntimeType.MAC_BUNDLE, augmentedSpec)); + })); + } + })); + } + + Optional findVersionSource(Class versionSourceType) { + return spec.findVersionSource(versionSourceType); + } + + void applyTo(JPackageCommand cmd) { + switch (type) { + case MAC_BUNDLE_PLIST_FILE_MALFORMED, MAC_BUNDLE_PLIST_WITHOUT_VERSION -> { + // Don't validate signature of the output bundle. If the Info.plist file is malformed, it will fail with the error: + // + // [22:59:25.374] TRACE: Command [/usr/bin/codesign --verify --deep --strict --verbose=2 RuntimeAppVersionTest.jdk](6) exited with exit code 3 and the following output: + // [22:59:25.375] TRACE: 2026-03-05 22:59:25.353 codesign[11351:61024] There was an error parsing the Info.plist for the bundle at URL <0x7f81e140ae70>: NSCocoaErrorDomain - 3840 + // [22:59:25.376] TRACE: 2026-03-05 22:59:25.370 codesign[11351:61024] There was an error parsing the Info.plist for the bundle at URL <0x7f81e1413b90>: NSCocoaErrorDomain - 3840 + // [22:59:25.376] TRACE: --prepared:RuntimeAppVersionTest.jdk/Contents/MacOS/libjli.dylib + // [22:59:25.377] TRACE: --validated:RuntimeAppVersionTest.jdk/Contents/MacOS/libjli.dylib + // + cmd.excludeStandardAsserts(StandardAssert.MAC_BUNDLE_UNSIGNED_SIGNATURE); + // This one will also fail. + cmd.excludeStandardAsserts(StandardAssert.MAC_RUNTIME_PLIST_JDK_KEY); + } + default -> { + // NOP + } + } + spec.applyTo(cmd); + } + + void validateVersion(ConfigurationTarget cfg) { + switch (type) { + case MAC_BUNDLE_PLIST_FILE_MALFORMED, MAC_BUNDLE_PLIST_WITHOUT_VERSION -> { + cfg.addInstallVerifier(cmd -> { + final var bundleRoot = cmd.isImagePackageType() ? cmd.outputBundle() + : cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory()); + final var infoPlist = new MacBundle(bundleRoot).infoPlistFile(); + TKit.assertFileExists(infoPlist); + TKit.trace(String.format("Bundle version property in [%s] file is unavailable. Skip validation", infoPlist)); + }); + } + default -> { + spec.validateVersion(cfg); + } + } + } + + Path createRuntime() throws IOException { + return createRuntime(type, findVersionSource(RuntimeReleaseFileVersionSource.class).map(VersionSource::version)); + } + + @Override + public String toString() { + return new StringBuilder().append(type.name().toLowerCase()).append("; ").append(spec).toString(); + } + + private record InheritPListVersionSource(String version) implements VersionSource { + + InheritPListVersionSource { + Objects.requireNonNull(version); + } + + @Override + public VersionSource copyWithVersion(String v) { + return new InheritPListVersionSource(v); + } + + @Override + public String toString() { + return String.format("plist=[%s]", version); + } + } + + private Path createRuntime(RuntimeType type, Optional releaseFileVersion) throws IOException { + Objects.requireNonNull(type); + Objects.requireNonNull(releaseFileVersion); + + Path predefinedRuntimeDir; + Path runtimeDir = switch (type) { + case IMAGE -> { + predefinedRuntimeDir = JPackageCommand.createInputRuntimeImage(RUNTIME_TYPE_FAKE); + yield predefinedRuntimeDir; + } + case MAC_BUNDLE -> { + releaseFileVersion.ifPresent(ver -> { + if (ver.equals(MAC_PREDEFINED_RUNTIME_BUNDLE_VERSION)) { + // The value of `JAVA_VERSION` property in the "release" file of the runtime + // and the value of the `CFBundleVersion` property in the plist file should be different + // to test corner cases of version picking logic. + throw new IllegalArgumentException(); + } + }); + + // Create macOS bundle with `MAC_PREDEFINED_RUNTIME_BUNDLE_VERSION` version. + // The idea is to have different values of `JAVA_VERSION` property in the "release" file + // of the runtime and the value of the `CFBundleVersion` property in the plist file. + predefinedRuntimeDir = MacHelper.buildRuntimeBundle().type(RUNTIME_TYPE_FAKE).mutator(cmd -> { + cmd.setArgumentValue("--app-version", MAC_PREDEFINED_RUNTIME_BUNDLE_VERSION); + }).create(); + yield MacBundle.fromPath(predefinedRuntimeDir).orElseThrow().homeDir(); + } + case MAC_BUNDLE_PLIST_FILE_MALFORMED, MAC_BUNDLE_PLIST_WITHOUT_VERSION -> { + predefinedRuntimeDir = MacHelper.buildRuntimeBundle().type(RUNTIME_TYPE_FAKE).create(); + var plistFile = new MacBundle(predefinedRuntimeDir).infoPlistFile(); + + switch (type) { + case MAC_BUNDLE_PLIST_FILE_MALFORMED -> { + TKit.trace(String.format("Create invalid plist file [%s]", plistFile)); + } + case MAC_BUNDLE_PLIST_WITHOUT_VERSION -> { + TKit.trace(String.format("Create empty plist file [%s]", plistFile)); + } + default -> { + throw new AssertionError(); + } + } + + createXml(plistFile, xml -> { + writePList(xml, toXmlConsumer(() -> { + if (type == RuntimeType.MAC_BUNDLE_PLIST_WITHOUT_VERSION) { + writeDict(xml, toXmlConsumer(() -> { + })); + } + })); + }); + yield MacBundle.fromPath(predefinedRuntimeDir).orElseThrow().homeDir(); + } + default -> { + throw new AssertionError(); + } + }; + + releaseFileVersion.ifPresent(ver -> { + TKit.createPropertiesFile( + RuntimeReleaseFile.releaseFilePathInRuntime(runtimeDir), + Map.of("JAVA_VERSION", "\"" + ver + "\"")); + }); + + return predefinedRuntimeDir; + } + + static final String MAC_PREDEFINED_RUNTIME_BUNDLE_VERSION = "1.22.333"; + } + + private static Consumer skipImagePackageType(Consumer consumer) { + Objects.requireNonNull(consumer); + return spec -> { + if (!spec.isImagePackageType()) { + consumer.accept(spec); + } + }; + } } diff --git a/test/jdk/tools/jpackage/share/ErrorTest.java b/test/jdk/tools/jpackage/share/ErrorTest.java index 86390a85068..ed5865024fa 100644 --- a/test/jdk/tools/jpackage/share/ErrorTest.java +++ b/test/jdk/tools/jpackage/share/ErrorTest.java @@ -26,10 +26,15 @@ import static java.util.stream.Collectors.toMap; import static jdk.internal.util.OperatingSystem.LINUX; import static jdk.internal.util.OperatingSystem.MACOS; import static jdk.internal.util.OperatingSystem.WINDOWS; +import static jdk.jpackage.internal.util.PListWriter.writePList; +import static jdk.jpackage.internal.util.XmlUtils.createXml; +import static jdk.jpackage.internal.util.XmlUtils.toXmlConsumer; import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction; +import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; import static jdk.jpackage.test.JPackageCommand.makeAdvice; import static jdk.jpackage.test.JPackageCommand.makeError; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -45,22 +50,39 @@ import java.util.function.UnaryOperator; import java.util.regex.Pattern; import java.util.stream.IntStream; import java.util.stream.Stream; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.MacBundle; import jdk.jpackage.internal.util.TokenReplace; import jdk.jpackage.test.Annotations.Parameter; import jdk.jpackage.test.Annotations.ParameterSupplier; import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.ApplicationLayout; import jdk.jpackage.test.CannedArgument; import jdk.jpackage.test.CannedFormattedString; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.JPackageOutputValidator; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.MacSign; +import jdk.jpackage.test.MacSign.CertificateRequest; +import jdk.jpackage.test.MacSign.CertificateType; +import jdk.jpackage.test.MacSign.KeychainWithCertsSpec; +import jdk.jpackage.test.MacSign.ResolvedKeychain; +import jdk.jpackage.test.MacSign.StandardCertificateNamePrefix; import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; +import jdk.jpackage.test.mock.Script; +import jdk.jpackage.test.mock.VerbatimCommandMock; +import jdk.jpackage.test.stdmock.JPackageMockUtils; +import jdk.jpackage.test.stdmock.MacSignMockUtils; /* * @test * @summary Test jpackage output for erroneous input * @library /test/jdk/tools/jpackage/helpers + * @library /test/lib * @build jdk.jpackage.test.* + * @build jdk.jpackage.test.stdmock.* + * @build jdk.test.lib.security.CertificateBuilder * @compile -Xlint:all -Werror ErrorTest.java * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ErrorTest @@ -71,7 +93,10 @@ import jdk.jpackage.test.TKit; * @test * @summary Test jpackage output for erroneous input * @library /test/jdk/tools/jpackage/helpers + * @library /test/lib * @build jdk.jpackage.test.* + * @build jdk.jpackage.test.stdmock.* + * @build jdk.test.lib.security.CertificateBuilder * @compile -Xlint:all -Werror ErrorTest.java * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=ErrorTest @@ -81,39 +106,71 @@ import jdk.jpackage.test.TKit; public final class ErrorTest { enum Token { - JAVA_HOME(cmd -> { + JAVA_HOME(() -> { return System.getProperty("java.home"); }), - APP_IMAGE(cmd -> { + APP_IMAGE(() -> { + final var appImageRoot = TKit.createTempDirectory("appimage"); + + final var appImageCmd = JPackageCommand.helloAppImage() + // Use the default jpackage tool provider to create an application image. + // The ErrorTest is used from the OptionsValidationFailTest unit tests that override + // the default jpackage tool provider with the implementation that doesn't do packaging + // and can not create a valid application image. + .useToolProvider(JavaTool.JPACKAGE.asToolProvider()) + .setFakeRuntime().setArgumentValue("--dest", appImageRoot); + + appImageCmd.execute(); + + return appImageCmd.outputBundle(); + }), + APP_IMAGE_WITH_SHORT_NAME(() -> { final var appImageRoot = TKit.createTempDirectory("appimage"); final var appImageCmd = JPackageCommand.helloAppImage() .setFakeRuntime().setArgumentValue("--dest", appImageRoot); + // Let jpackage pick the name from the main class (Hello). It qualifies as the "short" name. + appImageCmd.removeArgumentWithValue("--name"); + appImageCmd.execute(); - return appImageCmd.outputBundle().toString(); + return appImageCmd.outputBundle(); }), - INVALID_MAC_RUNTIME_BUNDLE(toFunction(cmd -> { + MAC_APP_IMAGE_INVALID_INFO_PLIST(toFunction(cmd -> { + var appImageDir = (Path)APP_IMAGE.expand(cmd).orElseThrow(); + // Replace the default Info.plist file with an empty one. + var plistFile = new MacBundle(appImageDir).infoPlistFile(); + TKit.trace(String.format("Create invalid plist file [%s]", plistFile)); + createXml(plistFile, xml -> { + writePList(xml, toXmlConsumer(() -> { + })); + }); + return appImageDir; + })), + INVALID_MAC_RUNTIME_BUNDLE(toSupplier(() -> { // Has "Contents/MacOS/libjli.dylib", but missing "Contents/Home/lib/libjli.dylib". final Path root = TKit.createTempDirectory("mac-invalid-runtime-bundle"); Files.createDirectories(root.resolve("Contents/Home")); Files.createFile(root.resolve("Contents/Info.plist")); Files.createDirectories(root.resolve("Contents/MacOS")); Files.createFile(root.resolve("Contents/MacOS/libjli.dylib")); - return root.toString(); + return root; })), - INVALID_MAC_RUNTIME_IMAGE(toFunction(cmd -> { + INVALID_MAC_RUNTIME_IMAGE(toSupplier(() -> { // Has some files in the "lib" subdirectory, but doesn't have the "lib/libjli.dylib" file. final Path root = TKit.createTempDirectory("mac-invalid-runtime-image"); Files.createDirectories(root.resolve("lib")); Files.createFile(root.resolve("lib/foo")); - return root.toString(); + return root; })), - EMPTY_DIR(toFunction(cmd -> { + EMPTY_DIR(() -> { return TKit.createTempDirectory("empty-dir"); - })), + }), ADD_LAUNCHER_PROPERTY_FILE, + EMPTY_KEYCHAIN, + KEYCHAIN_WITH_APP_IMAGE_CERT, + KEYCHAIN_WITH_PKG_CERT, ; private Token() { @@ -124,6 +181,12 @@ public final class ErrorTest { this.valueSupplier = Optional.of(valueSupplier); } + private Token(Supplier valueSupplier) { + this(_ -> { + return valueSupplier.get(); + }); + } + String token() { return makeToken(name()); } @@ -558,7 +621,7 @@ public final class ErrorTest { } public static Collection invalidAppVersion() { - return fromTestSpecBuilders(Stream.of( + return toTestArgs(Stream.of( // Invalid app version. Just cover all different error messages. // Extensive testing of invalid version strings is done in DottedVersionTest unit test. testSpec().addArgs("--app-version", "").error("error.version-string-empty"), @@ -601,7 +664,7 @@ public final class ErrorTest { argsStream = Stream.concat(argsStream, Stream.of(List.of("--win-console"))); } - return fromTestSpecBuilders(argsStream.map(args -> { + return toTestArgs(argsStream.map(args -> { var builder = testSpec().noAppDesc().nativeType() .addArgs("--runtime-image", Token.JAVA_HOME.token()) .addArgs(args); @@ -629,7 +692,7 @@ public final class ErrorTest { } public static Collection testAdditionLaunchers() { - return fromTestSpecBuilders(Stream.of( + return toTestArgs(Stream.of( testSpec().addArgs("--add-launcher", Token.ADD_LAUNCHER_PROPERTY_FILE.token()) .error("error.parameter-add-launcher-malformed", Token.ADD_LAUNCHER_PROPERTY_FILE, "--add-launcher"), testSpec().removeArgs("--name").addArgs("--name", "foo", "--add-launcher", "foo=" + Token.ADD_LAUNCHER_PROPERTY_FILE.token()) @@ -637,6 +700,221 @@ public final class ErrorTest { )); } + @Test(ifOS = MACOS) + public static void testMacSignAppStoreInvalidRuntime() throws IOException { + + // Create app image with the runtime directory content that will fail the subsequent signing jpackage command. + var appImageCmd = JPackageCommand.helloAppImage().setFakeRuntime(); + appImageCmd.executeAndAssertImageCreated(); + Files.createDirectory(appImageCmd.appLayout().runtimeHomeDirectory().resolve("bin")); + + final var keychain = SignEnvMock.SingleCertificateKeychain.FOO.keychain(); + + var spec = testSpec() + .noAppDesc() + .addArgs("--mac-app-store", "--mac-sign", "--app-image", appImageCmd.outputBundle().toString()) + .error("error.invalid-app-image-runtime-image-bin-dir", + ApplicationLayout.macAppImage().runtimeHomeDirectory(), appImageCmd.outputBundle()) + .create(); + + TKit.withNewState(() -> { + var script = Script.build() + // Disable the mutation making mocks "run once". + .commandMockBuilderMutator(null) + // Replace "/usr/bin/security" with the mock bound to the keychain mock. + .map(MacSignMockUtils.securityMock(SignEnvMock.VALUE)) + // Don't mock other external commands. + .use(VerbatimCommandMock.INSTANCE) + .createLoop(); + + // Create jpackage tool provider using the /usr/bin/security mock. + var jpackage = JPackageMockUtils.createJPackageToolProvider(OperatingSystem.MACOS, script); + + // Override the default jpackage tool provider with the one using the /usr/bin/security mock. + JPackageCommand.useToolProviderByDefault(jpackage); + + spec.test(); + }); + } + + @Test(ifOS = MACOS) + @ParameterSupplier + @ParameterSupplier("testMacPkgSignWithoutIdentity") + public static void testMacSignWithoutIdentity(TestSpec spec) { + // The test calls JPackageCommand.useToolProviderByDefault(), + // which alters global variables in the test library, + // so run the test case with a new global state to isolate the alteration of the globals. + TKit.withNewState(() -> { + testMacSignWithoutIdentityWithNewTKitState(spec); + }); + } + + private static void testMacSignWithoutIdentityWithNewTKitState(TestSpec spec) { + final Token keychainToken = spec.expectedMessages().stream().flatMap(cannedStr -> { + return cannedStr.args().stream().filter(Token.class::isInstance).map(Token.class::cast).filter(token -> { + switch (token) { + case EMPTY_KEYCHAIN, KEYCHAIN_WITH_APP_IMAGE_CERT, KEYCHAIN_WITH_PKG_CERT -> { + return true; + } + default -> { + return false; + } + } + }); + }).distinct().reduce((a, b) -> { + throw new IllegalStateException(String.format( + "Error messages %s reference multiple keychains: %s and %s", spec.expectedMessages(), a, b)); + }).orElseThrow(); + + final ResolvedKeychain keychain; + + switch (keychainToken) { + case EMPTY_KEYCHAIN -> { + keychain = new ResolvedKeychain(new KeychainWithCertsSpec(MacSign.createEmptyKeychain(), List.of())); + } + case KEYCHAIN_WITH_APP_IMAGE_CERT, KEYCHAIN_WITH_PKG_CERT -> { + CertificateType existingCertType; + switch (keychainToken) { + case KEYCHAIN_WITH_APP_IMAGE_CERT -> { + existingCertType = CertificateType.CODE_SIGN; + } + case KEYCHAIN_WITH_PKG_CERT -> { + existingCertType = CertificateType.INSTALLER; + } + default -> { + throw new AssertionError(); + } + } + + keychain = Stream.of(SignEnvMock.SingleCertificateKeychain.values()).filter(k -> { + return k.certificateType() == existingCertType; + }).findFirst().orElseThrow().keychain(); + + var script = Script.build() + // Disable the mutation making mocks "run once". + .commandMockBuilderMutator(null) + // Replace "/usr/bin/security" with the mock bound to the keychain mock. + .map(MacSignMockUtils.securityMock(SignEnvMock.VALUE)) + // Don't mock other external commands. + .use(VerbatimCommandMock.INSTANCE) + .createLoop(); + + // Create jpackage tool provider using the /usr/bin/security mock. + var jpackage = JPackageMockUtils.createJPackageToolProvider(OperatingSystem.MACOS, script); + + // Override the default jpackage tool provider with the one using the /usr/bin/security mock. + JPackageCommand.useToolProviderByDefault(jpackage); + } + default -> { + throw new AssertionError(); + } + } + + MacSign.withKeychain(_ -> { + spec.mapExpectedMessages(cannedStr -> { + return cannedStr.mapArgs(arg -> { + switch (arg) { + case StandardCertificateNamePrefix certPrefix -> { + return certPrefix.value(); + } + case Token _ -> { + return keychain.name(); + } + default -> { + return arg; + } + } + }); + }).test(Map.of(keychainToken, _ -> keychain.name())); + }, keychain); + } + + public static Collection testMacSignWithoutIdentity() { + final List testCases = new ArrayList<>(); + + final var signArgs = List.of("--mac-sign", "--mac-signing-keychain", Token.EMPTY_KEYCHAIN.token()); + final var appImageArgs = List.of("--app-image", Token.APP_IMAGE_WITH_SHORT_NAME.token()); + + for (var withAppImage : List.of(true, false)) { + var builder = testSpec(); + if (withAppImage) { + builder.noAppDesc().addArgs(appImageArgs); + } + builder.addArgs(signArgs); + + for (var type: List.of(PackageType.IMAGE, PackageType.MAC_PKG, PackageType.MAC_DMG)) { + builder.setMessages().error("error.cert.not.found", + MacSign.StandardCertificateNamePrefix.CODE_SIGN, Token.EMPTY_KEYCHAIN); + switch (type) { + case MAC_PKG -> { + // jpackage must report two errors: + // 1. It can't find signing identity to sign the app image + // 2. It can't find signing identity to sign the PKG installer + builder.error("error.cert.not.found", + MacSign.StandardCertificateNamePrefix.INSTALLER, Token.EMPTY_KEYCHAIN); + } + default -> { + // NOP + } + } + var testSpec = builder.type(type).create(); + testCases.add(testSpec); + } + } + + return toTestArgs(testCases); + } + + public static Collection testMacPkgSignWithoutIdentity() { + final List testCases = new ArrayList<>(); + + final var appImageArgs = List.of("--app-image", Token.APP_IMAGE_WITH_SHORT_NAME.token()); + + for (var withAppImage : List.of(true, false)) { + for (var existingCertType : CertificateType.values()) { + Token keychain; + StandardCertificateNamePrefix missingCertificateNamePrefix; + switch (existingCertType) { + case INSTALLER -> { + keychain = Token.KEYCHAIN_WITH_PKG_CERT; + missingCertificateNamePrefix = StandardCertificateNamePrefix.CODE_SIGN; + } + case CODE_SIGN -> { + keychain = Token.KEYCHAIN_WITH_APP_IMAGE_CERT; + missingCertificateNamePrefix = StandardCertificateNamePrefix.INSTALLER; + } + default -> { + throw new AssertionError(); + } + } + + var builder = testSpec() + .type(PackageType.MAC_PKG) + .addArgs("--mac-sign", "--mac-signing-keychain", keychain.token()) + .error("error.cert.not.found", missingCertificateNamePrefix, keychain); + + if (withAppImage) { + builder.noAppDesc().addArgs(appImageArgs); + } else { + /* + * Use shorter name to avoid + * + * [03:08:55.623] --mac-package-name is set to 'MacSignWithoutIdentityErrorTest', which is longer than 16 characters. For a better Mac experience consider shortening it. + * + * in the output. + * The same idea is behind using the "APP_IMAGE_WITH_SHORT_NAME" token + * instead of the "APP_IMAGE" for the predefined app image. + */ + builder.removeArgs("--name"); + } + + testCases.add(builder); + } + } + + return toTestArgs(testCases); + } + @Test @ParameterSupplier("invalidNames") public static void testInvalidAppName(InvalidName name) { @@ -703,13 +981,13 @@ public final class ErrorTest { .error("error.msi-product-version-components", "1.2.3.4.5") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "256.1") - .error("error.msi-product-version-major-out-of-range", "256.1") + .error("error.msi-product-version-major-out-of-range") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "1.256") - .error("error.msi-product-version-minor-out-of-range", "1.256") + .error("error.msi-product-version-minor-out-of-range") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "1.2.65536") - .error("error.msi-product-version-build-out-of-range", "1.2.65536") + .error("error.msi-product-version-build-out-of-range") .advice("error.version-string-wrong-format.advice") ); }).flatMap(x -> x).map(TestSpec.Builder::create).toList()); @@ -737,8 +1015,8 @@ public final class ErrorTest { testSpec().noAppDesc().addArgs("--app-image", Token.APP_IMAGE.token()) .error("error.app-image.mac-sign.required"), testSpec().type(PackageType.MAC_PKG).addArgs("--mac-package-identifier", "#1") - .error("message.invalid-identifier", "#1") - .advice("message.invalid-identifier.advice"), + .error("error.parameter-not-mac-bundle-identifier", "#1", "--mac-package-identifier") + .advice("error.parameter-not-mac-bundle-identifier.advice"), // Bundle for mac app store should not have runtime commands testSpec().nativeType().addArgs("--mac-app-store", "--jlink-options", "--bind-services") .error("ERR_MissingJLinkOptMacAppStore", "--strip-native-commands"), @@ -746,7 +1024,11 @@ public final class ErrorTest { testSpec().noAppDesc().nativeType().addArgs("--app-image", Token.EMPTY_DIR.token()) .error("error.parameter-not-mac-bundle", JPackageCommand.cannedArgument(cmd -> { return Path.of(cmd.getArgumentValue("--app-image")); - }, Token.EMPTY_DIR.token()), "--app-image") + }, Token.EMPTY_DIR.token()), "--app-image"), + testSpec().nativeType().noAppDesc().addArgs("--app-image", Token.MAC_APP_IMAGE_INVALID_INFO_PLIST.token()) + .error("error.invalid-app-image-plist-file", JPackageCommand.cannedArgument(cmd -> { + return new MacBundle(Path.of(cmd.getArgumentValue("--app-image"))).infoPlistFile(); + }, Token.MAC_APP_IMAGE_INVALID_INFO_PLIST.token())) ).map(TestSpec.Builder::create).toList()); macInvalidRuntime(testCases::add); @@ -754,8 +1036,7 @@ public final class ErrorTest { // Test a few app-image options that should not be used when signing external app image testCases.addAll(Stream.of( new ArgumentGroup("--app-version", "2.0"), - new ArgumentGroup("--name", "foo"), - new ArgumentGroup("--mac-app-store") + new ArgumentGroup("--name", "foo") ).flatMap(argGroup -> { var withoutSign = testSpec() .noAppDesc() @@ -1007,8 +1288,14 @@ public final class ErrorTest { ); } - private static Collection toTestArgs(Stream stream) { - return stream.filter(v -> { + private static Collection toTestArgs(Stream stream) { + return stream.map(v -> { + if (v instanceof TestSpec.Builder builder) { + return builder.create(); + } else { + return v; + } + }).filter(v -> { if (v instanceof TestSpec ts) { return ts.isSupported(); } else { @@ -1019,8 +1306,8 @@ public final class ErrorTest { }).toList(); } - private static Collection fromTestSpecBuilders(Stream stream) { - return toTestArgs(stream.map(TestSpec.Builder::create)); + private static Collection toTestArgs(Collection col) { + return toTestArgs(col.stream()); } private static String adjustTextStreamVerifierArg(String str) { @@ -1028,4 +1315,40 @@ public final class ErrorTest { } private static final Pattern LINE_SEP_REGEXP = Pattern.compile("\\R"); + + private final class SignEnvMock { + + enum SingleCertificateKeychain { + FOO(CertificateType.CODE_SIGN), + BAR(CertificateType.INSTALLER), + ; + + SingleCertificateKeychain(CertificateType certificateType) { + this.keychain = KeychainWithCertsSpec.build() + .name(name().toLowerCase() + ".keychain") + .addCert(CertificateRequest.build() + .userName(name().toLowerCase()) + .type(Objects.requireNonNull(certificateType))) + .create(); + } + + static List signingEnv() { + return Stream.of(values()).map(v -> { + return v.keychain; + }).toList(); + } + + CertificateType certificateType() { + return keychain.certificateRequests().getFirst().type(); + } + + ResolvedKeychain keychain() { + return new ResolvedKeychain(keychain).toMock(VALUE.env()); + } + + private final KeychainWithCertsSpec keychain; + } + + static final MacSignMockUtils.SignEnv VALUE = new MacSignMockUtils.SignEnv(SingleCertificateKeychain.signingEnv()); + } } diff --git a/test/jdk/tools/jpackage/share/FileAssociationsTest.java b/test/jdk/tools/jpackage/share/FileAssociationsTest.java index c9bd690d73f..0af7e7a54ff 100644 --- a/test/jdk/tools/jpackage/share/FileAssociationsTest.java +++ b/test/jdk/tools/jpackage/share/FileAssociationsTest.java @@ -23,6 +23,8 @@ import static java.util.Map.entry; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import jdk.jpackage.test.Annotations.Parameter; @@ -84,7 +86,7 @@ public class FileAssociationsTest { @Test @Parameter("true") @Parameter("false") - public static void test(boolean includeDescription) { + public static void test(boolean includeDescription) throws IOException { PackageTest packageTest = new PackageTest(); // Not supported @@ -96,10 +98,8 @@ public class FileAssociationsTest { } fa.applyTo(packageTest); - Path icon = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon" - + TKit.ICON_SUFFIX)); - - icon = TKit.createRelativePathCopy(icon); + var icon = TKit.createTempDirectory("icon-dir").resolve(ICON.getFileName()); + Files.copy(ICON, icon); new FileAssociations("jptest2") .setFilename("fa2") @@ -151,4 +151,6 @@ public class FileAssociationsTest { .addInitializer(JPackageCommand::setFakeRuntime) .setExpectedExitCode(1); } + + private static final Path ICON = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon" + TKit.ICON_SUFFIX)); } diff --git a/test/jdk/tools/jpackage/share/InstallDirTest.java b/test/jdk/tools/jpackage/share/InstallDirTest.java index 81d1fb3556e..4d5c1979190 100644 --- a/test/jdk/tools/jpackage/share/InstallDirTest.java +++ b/test/jdk/tools/jpackage/share/InstallDirTest.java @@ -102,10 +102,7 @@ public class InstallDirTest { .forTypes(PackageType.LINUX) .addInitializer(cmd -> { cmd.addArguments("--install-dir", installDir); - cmd.saveConsoleOutput(true); - }) - .addBundleVerifier((cmd, result) -> { - cmd.validateErr(JPackageCommand.makeError("error.invalid-install-dir")); + cmd.validateErr(JPackageCommand.makeError("error.invalid-install-dir", installDir)); }) .run(); } diff --git a/test/jdk/tools/jpackage/share/LicenseTest.java b/test/jdk/tools/jpackage/share/LicenseTest.java index 9c2d1077584..bf4c26fe76a 100644 --- a/test/jdk/tools/jpackage/share/LicenseTest.java +++ b/test/jdk/tools/jpackage/share/LicenseTest.java @@ -21,21 +21,23 @@ * questions. */ +import static jdk.internal.util.OperatingSystem.LINUX; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import static jdk.internal.util.OperatingSystem.LINUX; +import jdk.jpackage.internal.util.Slot; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.LinuxHelper; import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.LinuxHelper; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; /** @@ -93,11 +95,7 @@ public class LicenseTest { @Test public static void testCommon() { - PackageTest test = new PackageTest().configureHelloApp() - .addInitializer(cmd -> { - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - LICENSE_FILE)); - }); + PackageTest test = new PackageTest().configureHelloApp().mutate(LicenseTest::setLicenseFile); initMacDmgLicenseVerifier(test.forTypes(PackageType.MAC_DMG)); initLinuxLicenseVerifier(test.forTypes(PackageType.LINUX)); @@ -127,19 +125,16 @@ public class LicenseTest { @Test(ifOS = LINUX) public static void testCustomDebianCopyright() { - new CustomDebianCopyrightTest().run(); + new CustomDebianCopyrightTest(false).run(); } @Test(ifOS = LINUX) public static void testCustomDebianCopyrightSubst() { - new CustomDebianCopyrightTest().withSubstitution(true).run(); + new CustomDebianCopyrightTest(true).run(); } private static PackageTest initMacDmgLicenseVerifier(PackageTest test) { - return test - .addBundleVerifier(cmd -> { - verifyLicenseFileInDMGPackage(cmd); - }); + return test.addBundleVerifier(LicenseTest::verifyLicenseFileInDMGPackage); } private static void verifyLicenseFileInDMGPackage(JPackageCommand cmd) @@ -179,10 +174,9 @@ public class LicenseTest { PackageTest test = new PackageTest() .forTypes(PackageType.LINUX) .configureHelloApp() + .addInitializer(JPackageCommand::setFakeRuntime) + .mutate(LicenseTest::setLicenseFile) .addInitializer(cmd -> { - cmd.setFakeRuntime(); - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - LICENSE_FILE)); cmd.addArguments("--install-dir", installDir); }); @@ -191,6 +185,18 @@ public class LicenseTest { test.run(); } + private static void setLicenseFile(PackageTest test) { + var inputLicenseFile = Slot.createEmpty(); + + test.addRunOnceInitializer(() -> { + var dir = TKit.createTempDirectory("license-dir"); + inputLicenseFile.set(dir.resolve(LICENSE_FILE.getFileName())); + Files.copy(LICENSE_FILE, inputLicenseFile.get()); + }).addInitializer(cmd -> { + cmd.setArgumentValue("--license-file", inputLicenseFile.get()); + }); + } + private static Path rpmLicenseFile(JPackageCommand cmd) { final Path licenseRoot = Path.of( new Executor() @@ -296,12 +302,36 @@ public class LicenseTest { TKit.assertPathExists(licenseFile.getParent(), false); } - private static class CustomDebianCopyrightTest { - CustomDebianCopyrightTest() { - withSubstitution(false); + private record CustomDebianCopyrightTest(boolean withSubstitution) { + + private String copyright() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "Duke (C)"; + } else { + return "Java (C)"; + } } - private List licenseFileText(String copyright, String licenseText) { + private String licenseText() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "The quick brown fox\n jumps over the lazy dog"; + } else { + return "How vexingly quick daft zebras jump!"; + } + } + + private String name() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "CustomDebianCopyrightWithSubst"; + } else { + return "CustomDebianCopyright"; + } + } + + static private List licenseFileText(String copyright, String licenseText) { List lines = new ArrayList<>(List.of( String.format("Copyright=%s", copyright), "Foo", @@ -313,28 +343,14 @@ public class LicenseTest { private List licenseFileText() { if (withSubstitution) { - return licenseFileText("APPLICATION_COPYRIGHT", - "APPLICATION_LICENSE_TEXT"); + return licenseFileText("APPLICATION_COPYRIGHT", "APPLICATION_LICENSE_TEXT"); } else { return expectedLicenseFileText(); } } private List expectedLicenseFileText() { - return licenseFileText(copyright, licenseText); - } - - CustomDebianCopyrightTest withSubstitution(boolean v) { - withSubstitution = v; - // Different values just to make easy to figure out from the test log which test was executed. - if (v) { - copyright = "Duke (C)"; - licenseText = "The quick brown fox\n jumps over the lazy dog"; - } else { - copyright = "Java (C)"; - licenseText = "How vexingly quick daft zebras jump!"; - } - return this; + return licenseFileText(copyright(), licenseText()); } void run() { @@ -343,20 +359,19 @@ public class LicenseTest { .addInitializer(cmd -> { // Create source license file. Files.write(srcLicenseFile, List.of( - licenseText.split("\\R", -1))); + licenseText().split("\\R", -1))); cmd.setFakeRuntime(); - cmd.setArgumentValue("--name", String.format("%s%s", - withSubstitution ? "CustomDebianCopyrightWithSubst" : "CustomDebianCopyright", - cmd.name())); + cmd.setArgumentValue("--name", String.format("%s%s", name(), cmd.name())); cmd.addArguments("--license-file", srcLicenseFile); - cmd.addArguments("--copyright", copyright); - cmd.addArguments("--resource-dir", RESOURCE_DIR); + cmd.addArguments("--copyright", copyright()); + + var resourceDir = TKit.createTempDirectory("resources"); + + cmd.addArguments("--resource-dir", resourceDir); // Create copyright template file in a resource dir. - Files.createDirectories(RESOURCE_DIR); - Files.write(RESOURCE_DIR.resolve("copyright"), - licenseFileText()); + Files.write(resourceDir.resolve("copyright"), licenseFileText()); }) .addInstallVerifier(cmd -> { Path installedLicenseFile = linuxLicenseFile(cmd); @@ -368,12 +383,6 @@ public class LicenseTest { }) .run(); } - - private boolean withSubstitution; - private String copyright; - private String licenseText; - - private final Path RESOURCE_DIR = TKit.workDir().resolve("resources"); } private static final Path LICENSE_FILE = TKit.TEST_SRC_ROOT.resolve( diff --git a/test/jdk/tools/jpackage/share/ModularAppTest.java b/test/jdk/tools/jpackage/share/ModularAppTest.java new file mode 100644 index 00000000000..b14d70cc8f3 --- /dev/null +++ b/test/jdk/tools/jpackage/share/ModularAppTest.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2026, 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 static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; +import javax.xml.xpath.XPathExpressionException; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.MacBundle; +import jdk.jpackage.internal.util.Slot; +import jdk.jpackage.internal.util.TokenReplace; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.ParameterSupplier; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.CannedFormattedString; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.TKit; + + +/* + * @test + * @summary jpackage bundling modular app + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile -Xlint:all -Werror ModularAppTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ModularAppTest + */ + +public final class ModularAppTest { + + @Test + @ParameterSupplier + public void test(TestSpec spec) { + spec.run(); + } + + /** + * Test case for JDK-8233265. Adding modules in .jmod files for non-modular app + * results in unexpected jpackage failure. + */ + @Test + @Parameter("Hello!") + @Parameter("com.foo/com.foo.ModuleApp") + public void test8233265(String mainAppDesc) throws IOException { + JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); + + // The test should make jpackage invoke jlink. + cmd.ignoreDefaultRuntime(true); + + var modulePath = Optional.ofNullable(cmd.getArgumentValue("--module-path")).map(Path::of).orElseGet(() -> { + var newModulePath = TKit.createTempDirectory("input-modules"); + cmd.addArguments("--module-path", newModulePath); + return newModulePath; + }); + + JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); + HelloApp.createBundle(extraModule, modulePath); + cmd.addArguments("--add-modules", extraModule.moduleName()); + + cmd.executeAndAssertHelloAppImageCreated(); + } + + /** + * Test case for JDK-8248254. App's module in the predefined runtime directory; + * no "--module-path" option on the command line. jpackage should find the app's + * module in the predefined runtime. + */ + @Test + @Parameter("IMAGE") + @Parameter(value = "MAC_BUNDLE", ifOS = OperatingSystem.MACOS) + public void test8248254(RuntimeType runtimeType) throws XPathExpressionException, IOException { + + final var appDesc = JavaAppDesc.parse("me.mymodule/me.mymodule.Main"); + + new JPackageCommand() + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + .setDefaultInputOutput() + .removeArgumentWithValue("--input") + .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) + .setArgumentValue("--runtime-image", bakeModuleInRuntime(appDesc, runtimeType)) + .executeAndAssertHelloAppImageCreated(); + } + + /** + * Test case for JDK-8261518. App's module is baked into the predefined runtime + * image with jlink; no "--module-path" option on the command line. If there is + * a non-modular jar in the current directory, jpackage used to throw. + */ + @Test + @Parameter("IMAGE") + @Parameter(value = "MAC_BUNDLE", ifOS = OperatingSystem.MACOS) + public void test8261518(RuntimeType runtimeType) throws XPathExpressionException, IOException { + + final var appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); + + final var fooJarDir = TKit.createTempDirectory("foo"); + + // Create "foo.jar" in dedicated directory. + HelloApp.createBundle(JavaAppDesc.parse("foo.jar:"), fooJarDir); + + new JPackageCommand() + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + .setDefaultInputOutput() + .removeArgumentWithValue("--input") + .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) + .setArgumentValue("--runtime-image", bakeModuleInRuntime(appDesc, runtimeType).toAbsolutePath()) + // Run jpackage in the directory with "foo.jar" + .setDirectory(fooJarDir).useToolProvider(false) + .executeAndAssertHelloAppImageCreated(); + } + + private static Path bakeModuleInRuntime(JavaAppDesc appDesc, RuntimeType runtimeType) throws IOException { + + final var moduleOutputDir = TKit.createTempDirectory("modules"); + HelloApp.createBundle(appDesc, moduleOutputDir); + + final var workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir; + switch (runtimeType) { + case IMAGE -> { + jlinkOutputDir = workDir; + } + case MAC_BUNDLE -> { + var macBundle = new MacBundle(workDir); + + // Create macOS bundle structure sufficient to pass jpackage validation. + Files.createDirectories(macBundle.homeDir().getParent()); + Files.createDirectories(macBundle.macOsDir()); + Files.createFile(macBundle.infoPlistFile()); + jlinkOutputDir = macBundle.homeDir(); + } + default -> { + throw new AssertionError(); + } + } + + // List of modules required for the test app. + final var modules = new String[] { + "java.base", + "java.desktop", + appDesc.moduleName() + }; + + new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", String.join(",", modules), + "--output", jlinkOutputDir.toString(), + "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages", + "--strip-native-commands") + .execute(); + + return workDir; + } + + enum RuntimeType { + IMAGE, + MAC_BUNDLE, + ; + } + + record TestSpec(List paths, String appDesc) { + TestSpec { + Objects.requireNonNull(paths); + Objects.requireNonNull(appDesc); + Objects.requireNonNull(JavaAppDesc.parse(appDesc).moduleName()); + } + + boolean isWithGoodPath() { + var isWithGoodPath = Slot.createEmpty(); + paths.forEach(path -> { + ALL_TOKENS.applyTo(path, token -> { + if (token.equals(Token.GOOD_DIR.token())) { + isWithGoodPath.set(true); + } + return token; + }); + }); + return isWithGoodPath.find().isPresent(); + } + + void run() { + var emptyDir = runOnce(() -> { + return TKit.createTempDirectory("empty-dir"); + }); + + var nonExistingDir = runOnce(() -> { + return TKit.withTempDirectory("non-existing-dir", x -> {}); + }); + + var goodDir = runOnce(() -> { + return TKit.createTempDirectory("modules"); + }); + + var theAppDesc = JavaAppDesc.parse(appDesc); + + HelloApp.createBundle(theAppDesc, goodDir.get()); + + var cmd = new JPackageCommand() + .setArgumentValue("--dest", TKit.workDir().resolve("output")) + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + // Ignore runtime that can be set for all tests. Usually if default + // runtime is set, it is fake one to save time on running jlink and + // copying megabytes of data from Java home to application image. + // We need proper runtime for this test. + .ignoreDefaultRuntime(true) + .addArguments("--module", String.join("/", theAppDesc.moduleName(), theAppDesc.className())); + + if (TKit.isWindows()) { + cmd.addArguments("--win-console"); + } + + paths.stream().map(path -> { + return ALL_TOKENS.applyTo(path, token -> { + return (switch (Token.valueOf(token.substring(2, token.length() - 2))) { + case EMPTY_DIR -> { + yield emptyDir; + } + case GOOD_DIR -> { + yield goodDir; + } + case NON_EXISTING_DIR -> { + yield nonExistingDir; + } + default -> { + throw new AssertionError(); + } + }).get(); + }); + }).mapMulti((path, acc) -> { + acc.accept("--module-path"); + acc.accept(path); + }).forEach(cmd::addArgument); + + if (isWithGoodPath()) { + cmd.executeAndAssertHelloAppImageCreated(); + } else { + final CannedFormattedString expectedErrorMessage; + if (paths.isEmpty()) { + expectedErrorMessage = JPackageCommand.makeError( + "ERR_MissingArgument2", "--runtime-image", "--module-path"); + } else { + expectedErrorMessage = JPackageCommand.makeError( + "error.no-module-in-path", theAppDesc.moduleName()); + } + + cmd.validateErr(expectedErrorMessage).execute(1); + } + } + + private static final TokenReplace ALL_TOKENS = + new TokenReplace(Stream.of(Token.values()).map(Token::token).toArray(String[]::new)); + } + + public static Collection test() { + + var testCases = new ArrayList(); + + for (String appDesc : List.of( + "benvenuto.jar:com.jar.foo/com.jar.foo.Hello", + "benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello" + )) { + Stream.>of( + Stream.of(Token.GOOD_DIR, Token.EMPTY_DIR, Token.NON_EXISTING_DIR).map(Token::token), + Stream.of(Token.EMPTY_DIR, Token.NON_EXISTING_DIR, Token.GOOD_DIR).map(Token::token), + Stream.of(Token.GOOD_DIR.token() + "/a/b/c/d", Token.GOOD_DIR.token()), + Stream.of(), + Stream.of(Token.EMPTY_DIR).map(Token::token) + ).map(Stream::toList).map(paths -> { + return new TestSpec(paths, appDesc); + }).forEach(testCases::add); + } + + return testCases.stream().map(v -> { + return new Object[] {v}; + }).toList(); + } + + enum Token { + GOOD_DIR, + EMPTY_DIR, + NON_EXISTING_DIR, + ; + + String token() { + return makeToken(name()); + } + + private static String makeToken(String v) { + Objects.requireNonNull(v); + return String.format("@@%s@@", v); + } + } +} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest.java b/test/jdk/tools/jpackage/share/ModulePathTest.java deleted file mode 100644 index 583dd1eb0c4..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2019, 2026, 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.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import jdk.jpackage.test.CannedFormattedString; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JPackageStringBundle; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest - */ - -public final class ModulePathTest { - - @Parameters - public static Collection data() { - return List.of(new String[][]{ - {GOOD_PATH, EMPTY_DIR, NON_EXISTING_DIR}, - {EMPTY_DIR, NON_EXISTING_DIR, GOOD_PATH}, - {GOOD_PATH + "/a/b/c/d", GOOD_PATH}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR), - String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {}, - {EMPTY_DIR} - }); - } - - public ModulePathTest(String... modulePathArgs) { - this.modulePathArgs = List.of(modulePathArgs); - } - - @Test - @Parameter("benvenuto.jar:com.jar.foo/com.jar.foo.Hello") - @Parameter("benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello") - public void test(String javaAppDesc) throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - - Path goodModulePath = TKit.createTempDirectory("modules"); - - HelloApp.createBundle(appDesc, goodModulePath); - - JPackageCommand cmd = new JPackageCommand() - .setArgumentValue("--dest", TKit.workDir().resolve("output")) - .setDefaultAppName() - .setPackageType(PackageType.IMAGE); - - if (TKit.isWindows()) { - cmd.addArguments("--win-console"); - } - - cmd.addArguments("--module", String.join("/", appDesc.moduleName(), - appDesc.className())); - - // Ignore runtime that can be set for all tests. Usually if default - // runtime is set, it is fake one to save time on running jlink and - // copying megabytes of data from Java home to application image. - // We need proper runtime for this test. - cmd.ignoreDefaultRuntime(true); - - Path emptyDir = TKit.createTempDirectory("empty-dir"); - Path nonExistingDir = TKit.withTempDirectory("non-existing-dir", x -> {}); - - Function substitute = str -> { - String v = str; - v = v.replace(GOOD_PATH, goodModulePath.toString()); - v = v.replace(EMPTY_DIR, emptyDir.toString()); - v = v.replace(NON_EXISTING_DIR, nonExistingDir.toString()); - return v; - }; - - boolean withGoodPath = modulePathArgs.stream().anyMatch( - s -> s.contains(GOOD_PATH)); - - cmd.addArguments(modulePathArgs.stream().map(arg -> Stream.of( - "--module-path", substitute.apply(arg))).flatMap(s -> s).collect( - Collectors.toList())); - - if (withGoodPath) { - cmd.executeAndAssertHelloAppImageCreated(); - } else { - final CannedFormattedString expectedErrorMessage; - if (modulePathArgs.isEmpty()) { - expectedErrorMessage = JPackageCommand.makeError( - "ERR_MissingArgument2", "--runtime-image", "--module-path"); - } else { - expectedErrorMessage = JPackageCommand.makeError( - "error.no-module-in-path", appDesc.moduleName()); - } - - cmd.validateErr(expectedErrorMessage).execute(1); - } - } - - private final List modulePathArgs; - - private static final String GOOD_PATH = "@GoodPath@"; - private static final String EMPTY_DIR = "@EmptyDir@"; - private static final String NON_EXISTING_DIR = "@NonExistingDir@"; -} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest2.java b/test/jdk/tools/jpackage/share/ModulePathTest2.java deleted file mode 100644 index b2cc674e7e9..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest2.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.io.IOException; -import java.nio.file.Path; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest2.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest2 - */ - -public final class ModulePathTest2 { - - /** - * Test case for JDK-8233265. - * Adding modules in .jmod files for non-modular app results in unexpected - * jpackage failure. - * @param mainAppDesc - */ - @Test - @Parameter("Hello!") - @Parameter("com.foo/com.foo.ModuleApp") - public void test8233265(String mainAppDesc) throws IOException { - JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); - - // The test should make jpackage invoke jlink. - cmd.ignoreDefaultRuntime(true); - - Path modulePath = cmd.getArgumentValue("--module-path", () -> null, Path::of); - if (modulePath == null) { - modulePath = TKit.createTempDirectory("input-modules"); - cmd.addArguments("--module-path", modulePath); - } - - JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); - HelloApp.createBundle(extraModule, modulePath); - cmd.addArguments("--add-modules", extraModule.moduleName()); - - cmd.executeAndAssertHelloAppImageCreated(); - } -} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest3.java b/test/jdk/tools/jpackage/share/ModulePathTest3.java deleted file mode 100644 index c3960c0d4c8..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest3.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.xml.xpath.XPathExpressionException; -import jdk.jpackage.test.AppImageFile; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary jpackage for app's module linked in external runtime - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest3.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest3 - */ - -public final class ModulePathTest3 { - - public ModulePathTest3(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - /** - * Test case for JDK-8248254. - * App's module in runtime directory. - */ - @Test - public void test8248254() throws XPathExpressionException, IOException { - testIt("me.mymodule/me.mymodule.Main"); - } - - private void testIt(String mainAppDesc) throws XPathExpressionException, - IOException { - final JavaAppDesc appDesc = JavaAppDesc.parse(mainAppDesc); - final Path moduleOutputDir = TKit.createTempDirectory("modules"); - HelloApp.createBundle(appDesc, moduleOutputDir); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", appDesc.moduleName(), - "--output", jlinkOutputDir.toString(), - "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages", - "--strip-native-commands") - .execute(); - - JPackageCommand cmd = new JPackageCommand() - .setDefaultAppName() - .setPackageType(PackageType.IMAGE) - .setDefaultInputOutput() - .removeArgumentWithValue("--input") - .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) - .setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - - cmd.executeAndAssertHelloAppImageCreated(); - - if (appDesc.moduleVersion() != null) { - String actualVersion = AppImageFile.load(cmd.outputBundle()).version(); - TKit.assertEquals(appDesc.moduleVersion(), actualVersion, - "Check application version"); - } - } - - @Parameters - public static Collection data() { - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff --git a/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java b/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java deleted file mode 100644 index 91679945925..00000000000 --- a/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.io.IOException; -import java.nio.file.Files; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import java.nio.file.Path; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.HelloApp; - - -/* - * @test - * @summary test '--runtime-image' option of jpackage - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror NoMPathRuntimeTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=NoMPathRuntimeTest - */ - -public final class NoMPathRuntimeTest { - - public NoMPathRuntimeTest(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - @Test - public void test() throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); - - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - - // Build module jar. - cmd.executePrerequisiteActions(); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - // List of modules required for test app. - final var modules = new String[] { - "java.base", - "java.desktop" - }; - - Executor jlink = new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", String.join(",", modules), - "--output", jlinkOutputDir.toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages"); - - jlink.addArguments("--add-modules", appDesc.moduleName(), - "--module-path", Path.of(cmd.getArgumentValue("--module-path")) - .resolve("hello.jar").toString()); - - jlink.execute(); - - // non-modular jar in current dir caused error whe no module-path given - cmd.removeArgumentWithValue("--module-path"); - - cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - Path junkJar = null; - try { - // create a non-modular jar in the current directory - junkJar = HelloApp.createBundle( - JavaAppDesc.parse("junk.jar:Hello"), Path.of(".")); - - cmd.executeAndAssertHelloAppImageCreated(); - } finally { - if (junkJar != null) { - TKit.deleteIfExists(junkJar); - } - } - - } - - @Parameters - public static Collection data() { - - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff --git a/test/jdk/tools/jpackage/share/RuntimePackageTest.java b/test/jdk/tools/jpackage/share/RuntimePackageTest.java index 6cc668f94f9..87fd3496ba5 100644 --- a/test/jdk/tools/jpackage/share/RuntimePackageTest.java +++ b/test/jdk/tools/jpackage/share/RuntimePackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,6 +23,7 @@ import static jdk.internal.util.OperatingSystem.LINUX; import static jdk.internal.util.OperatingSystem.MACOS; +import static jdk.jpackage.test.JPackageCommand.DEFAULT_VERSION; import static jdk.jpackage.test.TKit.assertFalse; import static jdk.jpackage.test.TKit.assertTrue; @@ -81,12 +82,26 @@ public class RuntimePackageTest { @Test public static void test() { - init().run(); + init() + .addInitializer(cmd -> { + // JDK-8357404 enables jpackage to pick a version from the "release" file + // of the predefined runtime when bundling the runtime package. + // This makes the output of this test dependent on the version of the running JDK + // and will be an inconvenience for SQE testing. + // Explicitly specify the package version to fulfill expectations of SQE. + cmd.setArgumentValue("--app-version", DEFAULT_VERSION); + }) + .run(); } @Test(ifOS = MACOS) public static void testFromBundle() { - init(MacHelper::createRuntimeBundle).run(); + init(() -> { + return MacHelper.buildRuntimeBundle().mutator(cmd -> { + // Set custom version in the Info.plist file of the predefined runtime bundle. + cmd.addArguments("--app-version", "17.52"); + }).create(); + }).run(); } @Test(ifOS = LINUX) diff --git a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java index 7dcf025a506..e9238c1a6f7 100644 --- a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java +++ b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,119 +21,315 @@ * questions. */ +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardOpenOption; import java.util.ArrayList; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameters; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import jdk.jpackage.internal.util.Slot; +import jdk.jpackage.test.Annotations.ParameterSupplier; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.MsiDatabase; +import jdk.jpackage.test.MsiDatabase.UIAlterations; +import jdk.jpackage.test.MsiDatabase.ControlEvent; +import jdk.jpackage.test.PackageTest; import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.RunnablePackageTest.Action; import jdk.jpackage.test.TKit; +import jdk.jpackage.test.WindowsHelper; /** - * Test all possible combinations of --win-dir-chooser, --win-shortcut-prompt + * Test combinations of --win-dir-chooser, --win-shortcut-prompt, --win-with-ui, * and --license parameters. */ /* * @test - * @summary jpackage with --win-dir-chooser, --win-shortcut-prompt and --license parameters + * @summary jpackage with --win-dir-chooser, --win-shortcut-prompt, --with-with-ui and --license parameters * @library /test/jdk/tools/jpackage/helpers * @key jpackagePlatformPackage * @build jdk.jpackage.test.* * @build WinInstallerUiTest * @requires (os.family == "windows") + * @requires (jpackage.test.SQETest != null) + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=WinInstallerUiTest + * --jpt-exclude=(dir_chooser) + * --jpt-exclude=(license) + * --jpt-exclude=+ui + */ + +/* + * @test + * @summary jpackage with --win-dir-chooser, --win-shortcut-prompt, --with-with-ui and --license parameters + * @library /test/jdk/tools/jpackage/helpers + * @key jpackagePlatformPackage + * @build jdk.jpackage.test.* + * @build WinInstallerUiTest + * @requires (os.family == "windows") + * @requires (jpackage.test.SQETest == null) * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinInstallerUiTest */ + public class WinInstallerUiTest { - public WinInstallerUiTest(Boolean withDirChooser, Boolean withLicense, - Boolean withShortcutPrompt) { - this.withShortcutPrompt = withShortcutPrompt; - this.withDirChooser = withDirChooser; - this.withLicense = withLicense; + @Test + @ParameterSupplier + public void test(TestSpec spec) { + spec.run(); } - @Parameters - public static List data() { - List data = new ArrayList<>(); - for (var withDirChooser : List.of(Boolean.TRUE, Boolean.FALSE)) { - for (var withLicense : List.of(Boolean.TRUE, Boolean.FALSE)) { - for (var withShortcutPrompt : List.of(Boolean.TRUE, Boolean.FALSE)) { + public static void updateExpectedMsiTables() { + for (var spec : testCases()) { + spec.createTest(true).addBundleVerifier(cmd -> { + spec.save(WindowsHelper.getUIAlterations(cmd)); + }).run(Action.CREATE); + } + } + + record TestSpec( + boolean withDirChooser, + boolean withLicense, + boolean withShortcutPrompt, + boolean withUi) { + + TestSpec { + if (!withDirChooser && !withLicense && !withShortcutPrompt && !withUi) { + throw new IllegalArgumentException(); + } + } + + @Override + public String toString() { + var tokens = new ArrayList(); + if (withDirChooser) { + tokens.add("dir_chooser"); + } + + if (withShortcutPrompt) { + tokens.add("shortcut_prompt"); + } + + if (withLicense) { + tokens.add("license"); + } + + if (withUi) { + tokens.add("ui"); + } + + return tokens.stream().sorted().collect(Collectors.joining("+")); + } + + TestSpec copyWithUi(boolean withUi) { + return new TestSpec(withDirChooser, withLicense, withShortcutPrompt, withUi); + } + + TestSpec copyWithUi() { + return copyWithUi(true); + } + + TestSpec copyWithoutUi() { + return copyWithUi(false); + } + + void run() { + createTest(false).forTypes(PackageType.WIN_MSI).addBundleVerifier(cmd -> { + var expectedFilesDir = expectedFilesDir(); + + var expectedInstallUISequence = Files.readAllLines(expectedFilesDir.resolve(INSTALL_UI_SEQUENCE_FILE)); + var expectedControlEvents = Files.readAllLines(expectedFilesDir.resolve(CONTROL_EVENTS_FILE)); + + var uiAlterations = WindowsHelper.getUIAlterations(cmd); + + var actualInstallUISequence = actionSequenceToMarkdownTable(uiAlterations.installUISequence()); + var actualControlEvents = controlEventsToMarkdownTable(uiAlterations.controlEvents()); + + TKit.assertStringListEquals(expectedInstallUISequence, actualInstallUISequence, + String.format("Check alterations to the `InstallUISequence` MSI table match the contents of [%s] file", + expectedFilesDir.resolve(INSTALL_UI_SEQUENCE_FILE))); + + TKit.assertStringListEquals(expectedControlEvents, actualControlEvents, + String.format("Check alterations to the `ControlEvents` MSI table match the contents of [%s] file", + expectedFilesDir.resolve(CONTROL_EVENTS_FILE))); + }).run(); + } + + PackageTest createTest(boolean onlyMsi) { + return new PackageTest() + .forTypes(onlyMsi ? Set.of(PackageType.WIN_MSI) : PackageType.WINDOWS) + .configureHelloApp() + .addInitializer(JPackageCommand::setFakeRuntime) + .addInitializer(this::setPackageName) + .mutate(test -> { + if (withDirChooser) { + test.addInitializer(cmd -> cmd.addArgument("--win-dir-chooser")); + } + + if (withShortcutPrompt) { + test.addInitializer(cmd -> { + cmd.addArgument("--win-shortcut-prompt"); + cmd.addArgument("--win-menu"); + cmd.addArgument("--win-shortcut"); + }); + } + + if (withLicense) { + setLicenseFile(test); + } + + if (withUi) { + test.addInitializer(cmd -> cmd.addArgument("--win-with-ui")); + } + }); + } + + private void setPackageName(JPackageCommand cmd) { + StringBuilder sb = new StringBuilder(cmd.name()); + sb.append("With"); + if (withDirChooser) { + sb.append("Dc"); // DirChooser + } + if (withShortcutPrompt) { + sb.append("Sp"); // ShortcutPrompt + } + if (withLicense) { + sb.append("L"); // License + } + if (withUi) { + sb.append("Ui"); // UI + } + cmd.setArgumentValue("--name", sb.toString()); + } + + void save(UIAlterations uiAlterations) { + var expectedFilesDir = expectedFilesDir(); + + write(expectedFilesDir.resolve(INSTALL_UI_SEQUENCE_FILE), + actionSequenceToMarkdownTable(uiAlterations.installUISequence())); + + write(expectedFilesDir.resolve(CONTROL_EVENTS_FILE), + controlEventsToMarkdownTable(uiAlterations.controlEvents())); + } + + private Path expectedFilesDir() { + if ((withDirChooser || withShortcutPrompt || withLicense) && withUi) { + return copyWithoutUi().expectedFilesDir(); + } else { + return EXPECTED_MSI_TABLES_ROOT.resolve(toString()); + } + } + + private void write(Path file, List lines) { + try { + Files.createDirectories(file.getParent()); + Files.write(file, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + private static List toMarkdownTable(List header, Stream content) { + return Stream.of( + Stream.of(header.toArray(String[]::new)), + Stream.of(Collections.nCopies(header.size(), "---").toArray(String[]::new)), + content + ).flatMap(x -> x).map(row -> { + return Stream.of(row).map(v -> { + // Escape the pipe (|) character. + return v.replaceAll(Pattern.quote("|"), "|"); + }).collect(Collectors.joining(" | ", "| ", " |")); + }).toList(); + } + + private static List actionSequenceToMarkdownTable(Collection actions) { + return toMarkdownTable( + List.of("Action", "Condition"), + actions.stream().map(action -> { + return toStringArray(action.action(), action.condition()); + }) + ); + } + + private static List controlEventsToMarkdownTable(Collection controlEvents) { + return toMarkdownTable( + List.of("Dialog", "Control", "Event", "Argument", "Condition", "Ordering"), + controlEvents.stream().map(controlEvent -> { + return toStringArray( + controlEvent.dialog(), + controlEvent.control(), + controlEvent.event(), + controlEvent.argument(), + controlEvent.condition(), + Integer.toString(controlEvent.ordering())); + }) + ); + } + + private static String[] toStringArray(String... items) { + return items; + } + + private static final String CONTROL_EVENTS_FILE = "ControlEvents.md"; + private static final String INSTALL_UI_SEQUENCE_FILE = "InstallUISequence.md"; + } + + public static Collection test() { + return Stream.concat( + testCases().stream().filter(Predicate.not(TestSpec::withUi)).map(TestSpec::copyWithUi), + testCases().stream() + ).map(v -> { + return new Object[] {v}; + }).toList(); + } + + private static Collection testCases() { + var testCases = new ArrayList(); + + for (var withDirChooser : List.of(true, false)) { + for (var withLicense : List.of(true, false)) { + for (var withShortcutPrompt : List.of(true, false)) { if (!withDirChooser && !withLicense && !withShortcutPrompt) { // Duplicates SimplePackageTest continue; } - if (withDirChooser && !withLicense && !withShortcutPrompt) { - // Duplicates WinDirChooserTest - continue; - } - - if (!withDirChooser && withLicense && !withShortcutPrompt) { - // Duplicates LicenseTest - continue; - } - - data.add(new Object[]{withDirChooser, withLicense, - withShortcutPrompt}); + testCases.add(new TestSpec(withDirChooser, withLicense, withShortcutPrompt, false)); } } } - return data; + // Enforce UI + testCases.add(new TestSpec(false, false, false, true)); + + return testCases; } - @Test - public void test() { - PackageTest test = new PackageTest() - .forTypes(PackageType.WINDOWS) - .configureHelloApp(); + private static void setLicenseFile(PackageTest test) { + var inputLicenseFile = Slot.createEmpty(); - test.addInitializer(JPackageCommand::setFakeRuntime); - test.addInitializer(this::setPackageName); - - if (withDirChooser) { - test.addInitializer(cmd -> cmd.addArgument("--win-dir-chooser")); - } - - if (withShortcutPrompt) { - test.addInitializer(cmd -> { - cmd.addArgument("--win-shortcut-prompt"); - cmd.addArgument("--win-menu"); - cmd.addArgument("--win-shortcut"); - }); - } - - if (withLicense) { - test.addInitializer(cmd -> { - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - TKit.TEST_SRC_ROOT.resolve(Path.of("resources", - "license.txt")))); - }); - } - - test.run(); + test.addRunOnceInitializer(() -> { + var dir = TKit.createTempDirectory("license-dir"); + inputLicenseFile.set(dir.resolve(LICENSE_FILE.getFileName())); + Files.copy(LICENSE_FILE, inputLicenseFile.get()); + }).addInitializer(cmd -> { + cmd.setArgumentValue("--license-file", inputLicenseFile.get()); + }); } - private void setPackageName(JPackageCommand cmd) { - StringBuilder sb = new StringBuilder(cmd.name()); - sb.append("With"); - if (withDirChooser) { - sb.append("Dc"); // DirChooser - } - if (withShortcutPrompt) { - sb.append("Sp"); // ShortcutPrompt - } - if (withLicense) { - sb.append("L"); // License - } - cmd.setArgumentValue("--name", sb.toString()); - } + private static final Path LICENSE_FILE = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "license.txt")); - private final boolean withDirChooser; - private final boolean withLicense; - private final boolean withShortcutPrompt; + private static final Path EXPECTED_MSI_TABLES_ROOT = TKit.TEST_SRC_ROOT.resolve( + Path.of("resources", WinInstallerUiTest.class.getSimpleName())); } diff --git a/test/jdk/tools/jpackage/windows/WinL10nTest.java b/test/jdk/tools/jpackage/windows/WinL10nTest.java index 14139013318..4d983df2598 100644 --- a/test/jdk/tools/jpackage/windows/WinL10nTest.java +++ b/test/jdk/tools/jpackage/windows/WinL10nTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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,22 +21,22 @@ * questions. */ +import static jdk.jpackage.test.WindowsHelper.getWixTypeFromVerboseJPackageOutput; +import static jdk.jpackage.test.WindowsHelper.WixType.WIX3; + import java.io.IOException; import java.nio.file.Path; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameters; - import java.util.Arrays; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Executor; -import static jdk.jpackage.test.WindowsHelper.WixType.WIX3; -import static jdk.jpackage.test.WindowsHelper.getWixTypeFromVerboseJPackageOutput; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.TKit; /* * @test @@ -124,8 +124,17 @@ public class WinL10nTest { var toolFileName = wixToolName + ".exe"; return (s) -> { s = s.trim(); - return s.startsWith(toolFileName) || ((s.contains(String.format("\\%s ", toolFileName)) && s. - contains(" -out "))); + + if (s.startsWith(toolFileName)) { + return true; + } + + // Accommodate for: + // 'C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe' ... + // light.exe ... + return Stream.of("\\%s ", "\\%s' ").map(format -> { + return String.format(format, toolFileName); + }).anyMatch(s::contains) && s.contains(" -out "); }; } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 70e619f3d3d..16fd32e626b 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -107,7 +107,6 @@ public class VMProps implements Callable> { map.put("vm.debug", this::vmDebug); map.put("vm.jvmci", this::vmJvmci); map.put("vm.jvmci.enabled", this::vmJvmciEnabled); - map.put("vm.emulatedClient", this::vmEmulatedClient); // vm.hasSA is "true" if the VM contains the serviceability agent // and jhsdb. map.put("vm.hasSA", this::vmHasSA); @@ -299,18 +298,6 @@ public class VMProps implements Callable> { return "" + Compiler.isJVMCIEnabled(); } - - /** - * @return true if VM runs in emulated-client mode and false otherwise. - */ - protected String vmEmulatedClient() { - String vmInfo = System.getProperty("java.vm.info"); - if (vmInfo == null) { - return errorWithMessage("Can't get 'java.vm.info' property"); - } - return "" + vmInfo.contains(" emulated-client"); - } - /** * @return supported CPU features */ @@ -487,8 +474,7 @@ public class VMProps implements Callable> { /** * @return true if it's possible for "java -Xshare:dump" to write Java heap objects - * with the current set of jtreg VM options. For example, false will be returned - * if -XX:-UseCompressedClassPointers is specified. + * with the current set of jtreg VM options. */ protected String vmCDSCanWriteArchivedJavaHeap() { return "" + ("true".equals(vmCDS()) && WB.canWriteJavaHeapArchive()); @@ -496,8 +482,7 @@ public class VMProps implements Callable> { /** * @return true if it's possible for "java -Xshare:dump" to write Java heap objects - * with the current set of jtreg VM options. For example, false will be returned - * if -XX:-UseCompressedClassPointers is specified. + * with the current set of jtreg VM options. */ protected String vmCDSCanWriteMappedArchivedJavaHeap() { return "" + ("true".equals(vmCDS()) && WB.canWriteMappedJavaHeapArchive()); @@ -505,8 +490,7 @@ public class VMProps implements Callable> { /** * @return true if it's possible for "java -Xshare:dump" to write Java heap objects - * with the current set of jtreg VM options. For example, false will be returned - * if -XX:-UseCompressedClassPointers is specified. + * with the current set of jtreg VM options. */ protected String vmCDSCanWriteStreamedArchivedJavaHeap() { return "" + ("true".equals(vmCDS()) && WB.canWriteStreamedJavaHeapArchive()); diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT index 434cf91b0ec..c76f99d1396 100644 --- a/test/langtools/TEST.ROOT +++ b/test/langtools/TEST.ROOT @@ -17,11 +17,6 @@ groups=TEST.groups # Minimum jtreg version requiredVersion=8.2.1+1 -# Use new module options -useNewOptions=true - -# Use --patch-module instead of -Xmodule: -useNewPatchModule=true # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/test/langtools/jdk/internal/shellsupport/doc/FullJavadocHelperTest.java b/test/langtools/jdk/internal/shellsupport/doc/FullJavadocHelperTest.java index fcfd40b3292..5219b8e9080 100644 --- a/test/langtools/jdk/internal/shellsupport/doc/FullJavadocHelperTest.java +++ b/test/langtools/jdk/internal/shellsupport/doc/FullJavadocHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,19 +30,19 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.jshell/jdk.internal.shellsupport.doc * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask - * @run testng/timeout=900/othervm -Xmx1024m FullJavadocHelperTest + * @run junit/timeout=900/othervm -Xmx1024m FullJavadocHelperTest */ import java.io.IOException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -@Test public class FullJavadocHelperTest { /* * Long-running test to retrieve doc comments for enclosed elements of all JDK classes. */ + @Test public void testAllDocs() throws IOException { new JavadocHelperTest().retrieveDocComments(Boolean.TRUE::booleanValue); } diff --git a/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java b/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java index 153c010c33d..2ee326e26f9 100644 --- a/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java +++ b/test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,21 +27,21 @@ * @summary Test JavadocFormatter * @library /tools/lib * @modules jdk.jshell/jdk.internal.shellsupport.doc - * @run testng JavadocFormatterTest + * @run junit JavadocFormatterTest */ import java.util.Objects; import jdk.internal.shellsupport.doc.JavadocFormatter; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -@Test public class JavadocFormatterTest { private static final String CODE_RESET = "\033[0m"; private static final String CODE_HIGHLIGHT = "\033[1m"; private static final String CODE_UNDERLINE = "\033[4m"; + @Test public void testReflow() { String actual; String expected; @@ -401,6 +401,7 @@ public class JavadocFormatterTest { } } + @Test public void testSpaceAtEndOfLine() { String header = "Class Class.forName(Module module, String name)"; String javadoc = """ diff --git a/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java b/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java index e82553a4cfe..4f739d38d3d 100644 --- a/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java +++ b/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.jshell/jdk.internal.shellsupport.doc * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask - * @run testng JavadocHelperTest + * @run junit JavadocHelperTest * @key randomness */ @@ -69,13 +69,13 @@ import javax.tools.ToolProvider; import com.sun.source.util.JavacTask; import jdk.internal.shellsupport.doc.JavadocHelper; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Test public class JavadocHelperTest { + @Test public void testJavadoc() throws Exception { doTestJavadoc("", t -> t.getElements().getTypeElement("test.Super"), @@ -93,6 +93,7 @@ public class JavadocHelperTest { " @return value\n"); } + @Test public void testInheritNoJavadoc() throws Exception { doTestJavadoc("", getSubTest, @@ -107,6 +108,7 @@ public class JavadocHelperTest { " @return value\n"); } + @Test public void testInheritFull() throws Exception { doTestJavadoc(" /**\n" + " * Prefix {@inheritDoc} suffix.\n" + @@ -131,6 +133,7 @@ public class JavadocHelperTest { " @return prefix value suffix\n"); } + @Test public void testInheritMissingParam() throws Exception { doTestJavadoc(" /**\n" + " * Prefix {@inheritDoc} suffix.\n" + @@ -154,6 +157,7 @@ public class JavadocHelperTest { " @return prefix value suffix\n"); } + @Test public void testInheritMissingFirstParam() throws Exception { doTestJavadoc(" /**\n" + " * Prefix {@inheritDoc} suffix.\n" + @@ -177,6 +181,7 @@ public class JavadocHelperTest { " @return prefix value suffix\n"); } + @Test public void testInheritMissingThrows() throws Exception { doTestJavadoc(" /**\n" + " * Prefix {@inheritDoc} suffix.\n" + @@ -200,6 +205,7 @@ public class JavadocHelperTest { " @return prefix value suffix\n"); } + @Test public void testInheritMissingReturn() throws Exception { doTestJavadoc(" /**\n" + " * Prefix {@inheritDoc} suffix.\n" + @@ -223,6 +229,7 @@ public class JavadocHelperTest { "@return value\n"); } + @Test public void testInheritAllButOne() throws Exception { doTestJavadoc(" /**\n" + " * @throws IllegalArgumentException {@inheritDoc}\n" + @@ -238,6 +245,7 @@ public class JavadocHelperTest { "@return value\n"); } + @Test public void testInheritEmpty() throws Exception { doTestJavadoc(" /**\n" + " */\n", @@ -260,6 +268,7 @@ public class JavadocHelperTest { "@return \n"); } + @Test public void testEmptyValue() throws Exception { doTestJavadoc(" /**\n" + " */\n", @@ -282,6 +291,7 @@ public class JavadocHelperTest { "@return \n"); } + @Test public void testShortComment() throws Exception { doTestJavadoc(" /**Test.*/\n", getSubTest, @@ -295,6 +305,7 @@ public class JavadocHelperTest { "@return value\n"); } + @Test public void testMarkdown() throws Exception { doTestJavadoc(""" /// Prefix {@inheritDoc} suffix. @@ -328,6 +339,7 @@ public class JavadocHelperTest { @return prefix value suffix"""); } + @Test public void testMarkdown2() throws Exception { doTestJavadoc(""" /// {@inheritDoc} @@ -352,6 +364,7 @@ public class JavadocHelperTest { @since snc"""); } + @Test public void testMarkdown3() throws Exception { doTestJavadoc(""" /// {@inheritDoc} @@ -373,6 +386,7 @@ public class JavadocHelperTest { """); } + @Test public void testMarkdown4() throws Exception { doTestJavadoc(""" /// {@inheritDoc} @@ -397,6 +411,7 @@ public class JavadocHelperTest { @since snc"""); } + @Test public void testMarkdown5() throws Exception { doTestJavadoc(""" ///[define classes][java.lang.invoke.MethodHandles.Lookup#defineClass(byte\\[\\])] @@ -417,6 +432,7 @@ public class JavadocHelperTest { @since snc"""); } + @Test public void testMarkdown6() throws Exception { doTestJavadoc(""" ///Text1 [define classes][java.lang.invoke.MethodHandles.Lookup#defineClass(byte\\[\\])] @@ -503,7 +519,7 @@ public class JavadocHelperTest { try (JavadocHelper helper = JavadocHelper.create(task, Arrays.asList(srcZip))) { String javadoc = helper.getResolvedDocComment(el); - assertEquals(javadoc, expectedJavadoc); + assertEquals(expectedJavadoc, javadoc); } } } @@ -547,6 +563,7 @@ public class JavadocHelperTest { * Set the system property `seed` to a random seed to reproduce * a specific run of this test. */ + @Test public void testRandomDocs() throws IOException { Random random = new Random(getSeed()); // Run test on 2% of classes, which corresponds to ~ 140 classes diff --git a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java index f3294f6647c..57854396cf4 100644 --- a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java +++ b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 8017191 8182765 8200432 8239804 8250766 8262992 8281944 8307377 + * 8284315 * @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -103,7 +104,12 @@ public class TestSeeTag extends JavadocTester {
See Also:
    -
  • Object
  • +
  • +
    + invalid reference +
    Object[]
    +
    +
  • invalid reference diff --git a/test/langtools/jdk/javadoc/doclet/testSpecTag/TestSpecTag.java b/test/langtools/jdk/javadoc/doclet/testSpecTag/TestSpecTag.java index e914f8022fd..1c3e8306d7b 100644 --- a/test/langtools/jdk/javadoc/doclet/testSpecTag/TestSpecTag.java +++ b/test/langtools/jdk/javadoc/doclet/testSpecTag/TestSpecTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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,7 +23,7 @@ /* * @test - * @bug 6251738 8226279 8297802 8305407 + * @bug 6251738 8226279 8297802 8305407 8309748 * @summary JDK-8226279 javadoc should support a new at-spec tag * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -343,16 +343,15 @@ public class TestSpecTag extends JavadocTester { checkOutput("external-specs.html", true, """ -
    \ - \ - \ -
    + +
    +
    +
    External Specifications
    +
    Specification
    @@ -369,7 +368,25 @@ public class TestSpecTag extends JavadocTester { -
    """); +
    """, + """ + """); } @Test diff --git a/test/langtools/jdk/jshell/ConcurrentHistoryLoadingTest.java b/test/langtools/jdk/jshell/ConcurrentHistoryLoadingTest.java new file mode 100644 index 00000000000..926dbbf50b4 --- /dev/null +++ b/test/langtools/jdk/jshell/ConcurrentHistoryLoadingTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2026, 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.io.ByteArrayInputStream; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.prefs.Preferences; + +import jdk.jshell.tool.JavaShellToolBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/* + * @test + * @bug 8347418 + * @summary Verify that loading of JShell history doesn't lead to a + * NullPointerException when the Preferences are modified concurrently. + * @run junit ConcurrentHistoryLoadingTest + */ +public class ConcurrentHistoryLoadingTest { + + private static final String HISTORY_LINE_PREFIX = "HISTORY_LINE_"; + + @Test + public void testConcurrentHistoryLoading() throws Throwable { + AtomicBoolean removeOnAccess = new AtomicBoolean(); + Preferences testPrefs = new ReplToolTesting.MemoryPreferences() { + @Override + protected String getSpi(String key) { + String result = super.getSpi(key); + if (key.startsWith(HISTORY_LINE_PREFIX) && removeOnAccess.getAndSet(false)) { + for (String key2Remote : keysSpi()) { + remove(key2Remote); + } + } + return result; + } + }; + StringBuilder input = new StringBuilder(); + int max = 10; + for (int j = 0; j < max; j++) { + input.append("int x").append(j).append(" = 42\n"); + } + JavaShellToolBuilder + .builder() + .persistence(testPrefs) + .in(new ByteArrayInputStream(input.toString().getBytes()), null) + .start(); + Assertions.assertEquals(10, Arrays.stream(testPrefs.keys()) + .filter(key -> key.startsWith(HISTORY_LINE_PREFIX)) + .count()); + removeOnAccess.set(true); + JavaShellToolBuilder + .builder() + .persistence(testPrefs) + .in(new ByteArrayInputStream(input.toString().getBytes()), null) + .start(); + + } +} diff --git a/test/langtools/jdk/jshell/InputUITest.java b/test/langtools/jdk/jshell/InputUITest.java index 1a420d2c345..6886e1302a2 100644 --- a/test/langtools/jdk/jshell/InputUITest.java +++ b/test/langtools/jdk/jshell/InputUITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8356165 8358552 + * @bug 8356165 8358552 8378251 * @summary Check user input works properly * @modules * jdk.compiler/com.sun.tools.javac.api @@ -99,4 +99,34 @@ public class InputUITest extends UITesting { waitOutput(out, patternQuote("==> 65")); }, false); } -} \ No newline at end of file + + @Test + public void testAltBackspaceDeletesPreviousWord() throws Exception { + doRunTest((inputSink, out) -> { + inputSink.write("int x = 12 24" + ESC_DEL + "\n"); + waitOutput(out, "int x = 12 24\u001B\\[2D\u001B\\[K\n" + + "\u001B\\[\\?2004lx ==> 12\n" + + "\u001B\\[\\?2004h" + PROMPT); + inputSink.write("System.in" + ESC_DEL + "out.println(x)\n"); + waitOutput(out, "System.in\u001B\\[2D\u001B\\[Kout.println\\(x\\)\u001B\\[3D\u001B\\[3C\n" + + "\u001B\\[\\?2004l12\n" + + "\u001B\\[\\?2004h" + PROMPT); + }, false); + } + + @Test + public void testAltDDeletesNextWord() throws Exception { + doRunTest((inputSink, out) -> { + inputSink.write("int x = 12 24" + ESC_B + ESC_D + "\n"); + waitOutput(out, "int x = 12 24\u001B\\[2D\u001B\\[K\n" + + "\u001B\\[\\?2004lx ==> 12\n" + + "\u001B\\[\\?2004h" + PROMPT); + inputSink.write("System.in.println" + ESC_B + ESC_B + ESC_D + + "out" + ESC_F + ESC_F + "(x)\n"); + waitOutput(out, "System.in.println\u001B\\[7D\u001B\\[3D\u001B\\[2P" + + "\u001B\\[1@o\u001B\\[1@u\u001B\\[1@t\u001B\\[C\u001B\\[7C\\(x\\)\u001B\\[3D\u001B\\[3C\n" + + "\u001B\\[\\?2004l12\n" + + "\u001B\\[\\?2004h" + PROMPT); + }, false); + } +} diff --git a/test/langtools/jdk/jshell/ReplToolTesting.java b/test/langtools/jdk/jshell/ReplToolTesting.java index 429a0a7ce02..2dabf29e1f9 100644 --- a/test/langtools/jdk/jshell/ReplToolTesting.java +++ b/test/langtools/jdk/jshell/ReplToolTesting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -914,7 +914,7 @@ public class ReplToolTesting { } } - public static final class MemoryPreferences extends AbstractPreferences { + public static class MemoryPreferences extends AbstractPreferences { private final Map values = new HashMap<>(); private final Map nodes = new HashMap<>(); @@ -943,17 +943,17 @@ public class ReplToolTesting { } @Override - protected void removeNodeSpi() throws BackingStoreException { + protected void removeNodeSpi() { ((MemoryPreferences) parent()).nodes.remove(name()); } @Override - protected String[] keysSpi() throws BackingStoreException { + protected String[] keysSpi() { return values.keySet().toArray(new String[0]); } @Override - protected String[] childrenNamesSpi() throws BackingStoreException { + protected String[] childrenNamesSpi() { return nodes.keySet().toArray(new String[0]); } @@ -963,11 +963,11 @@ public class ReplToolTesting { } @Override - protected void syncSpi() throws BackingStoreException { + protected void syncSpi() { } @Override - protected void flushSpi() throws BackingStoreException { + protected void flushSpi() { } } diff --git a/test/langtools/jdk/jshell/TerminalNoExecTest.java b/test/langtools/jdk/jshell/TerminalNoExecTest.java index 3d76157fd26..d7cd20046af 100644 --- a/test/langtools/jdk/jshell/TerminalNoExecTest.java +++ b/test/langtools/jdk/jshell/TerminalNoExecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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,7 +39,7 @@ import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.concurrent.TimeUnit; +import java.util.HashMap; import java.util.concurrent.atomic.AtomicBoolean; import jdk.jfr.consumer.RecordingStream; import jdk.jshell.tool.JavaShellToolBuilder; @@ -58,7 +58,9 @@ public class TerminalNoExecTest { spawnedNewProcess.set(true); }); rs.startAsync(); - JavaShellToolBuilder.builder().run("--execution=local", "--no-startup"); + JavaShellToolBuilder.builder() + .persistence(new HashMap<>()) + .run("--execution=local", "--no-startup"); rs.stop(); } if (spawnedNewProcess.get()) { diff --git a/test/langtools/jdk/jshell/UITesting.java b/test/langtools/jdk/jshell/UITesting.java index a1bd8f35dee..d63a8460889 100644 --- a/test/langtools/jdk/jshell/UITesting.java +++ b/test/langtools/jdk/jshell/UITesting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -53,6 +53,10 @@ public class UITesting { protected static final String UP = "\033[A"; protected static final String DOWN = "\033[B"; protected static final String CTRL_D = "\u0004"; + protected static final String ESC_DEL = "\u001B\u007F"; // ESC + DEL (common Alt+Backspace) + protected static final String ESC_B = "\u001Bb"; // ESC + b (common Alt+b) + protected static final String ESC_F = "\u001Bf"; // ESC + f (common Alt+f) + protected static final String ESC_D = "\u001Bd"; // ESC + d (common Alt+d) private final boolean laxLineEndings; public UITesting() { diff --git a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java index 0760352e23b..c3aa92d1f37 100644 --- a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java +++ b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,6 +112,10 @@ public class CompilationTestCase extends JavacTemplateTestBase { assertCompile(expandMarkers(constructs), () -> assertCompileSucceededWithWarning(warning), false); } + protected void assertOKWithWarning(String warning, int numberOfTimes, String... constructs) { + assertCompile(expandMarkers(constructs), () -> assertCompileSucceededWithWarning(warning, numberOfTimes), false); + } + protected void assertFail(String expectedDiag, String... constructs) { assertCompile(expandMarkers(constructs), () -> assertCompileFailed(expectedDiag), false); } diff --git a/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java b/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java index 47f496b5891..87ee54b375a 100644 --- a/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java +++ b/test/langtools/lib/combo/tools/javac/combo/Diagnostics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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 @@ -84,6 +84,12 @@ public class Diagnostics implements javax.tools.DiagnosticListener d.getCode().equals(key)); } + public boolean containsWarningKey(String key, int numberOfWarnings) { + return diags.stream() + .filter(d -> d.getKind() == Diagnostic.Kind.WARNING || d.getKind() == Diagnostic.Kind.MANDATORY_WARNING) + .filter(d -> d.getCode().equals(key)).count() == numberOfWarnings; + } + /** Get the error keys */ public List errorKeys() { return diags.stream() diff --git a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java index ed5936210a8..3b4b67e7968 100644 --- a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java +++ b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java @@ -154,6 +154,14 @@ public abstract class JavacTemplateTestBase { } } + protected void assertCompileSucceededWithWarning(String warning, int numberOfWarnings) { + if (diags.errorsFound()) + fail("Expected successful compilation"); + if (!diags.containsWarningKey(warning, numberOfWarnings)) { + fail(String.format("Expected compilation warning with %s, found %s", warning, diags.keys())); + } + } + /** * If the provided boolean is true, assert all previous compiles succeeded, * otherwise assert that a compile failed. diff --git a/test/langtools/tools/doclint/ReferenceTest.java b/test/langtools/tools/doclint/ReferenceTest.java index ca677d64927..63512d1efc4 100644 --- a/test/langtools/tools/doclint/ReferenceTest.java +++ b/test/langtools/tools/doclint/ReferenceTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 8020556 8002154 8200432 8177280 + * @bug 8004832 8020556 8002154 8200432 8177280 8284315 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester diff --git a/test/langtools/tools/doclint/ReferenceTest.out b/test/langtools/tools/doclint/ReferenceTest.out index 0b39ea20a41..4232f7b12ba 100644 --- a/test/langtools/tools/doclint/ReferenceTest.out +++ b/test/langtools/tools/doclint/ReferenceTest.out @@ -31,12 +31,24 @@ ReferenceTest.java:71: error: reference not found ReferenceTest.java:74: error: reference not found * @see not.Found ^ +ReferenceTest.java:79: error: reference not found + * {@link java.lang.String[]} + ^ +ReferenceTest.java:80: error: reference not found + * {@link java.lang.String[]#equals} + ^ ReferenceTest.java:81: error: reference not found * {@link not.Found[]} ^ +ReferenceTest.java:82: error: reference not found + * @see java.lang.String[] + ^ +ReferenceTest.java:83: error: reference not found + * @see java.lang.String[]#equals + ^ ReferenceTest.java:84: error: reference not found * @see not.Found[] ^ -12 errors +16 errors 1 warning diff --git a/test/langtools/tools/javac/annotations/6365854/test1.out b/test/langtools/tools/javac/annotations/6365854/test1.out index c8bf69b095d..e69de29bb2d 100644 --- a/test/langtools/tools/javac/annotations/6365854/test1.out +++ b/test/langtools/tools/javac/annotations/6365854/test1.out @@ -1,2 +0,0 @@ -TestCore.class:-:-: compiler.warn.annotation.method.not.found.reason: test.annotation.TestAnnotation, test, (compiler.misc.class.file.not.found: test.annotation.TestAnnotation) -1 warning diff --git a/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.java b/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.java index 7f5d49e38c9..d0c19c3ec09 100644 --- a/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.java +++ b/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.java @@ -3,7 +3,7 @@ * @summary compiler is crashing with AssertionError for annotations with unknown target type * @bug 8296010 * @build A - * @compile/fail/ref=CrashOnUnknownTargetTypeTest.out -XDrawDiagnostics CrashOnUnknownTargetTypeTest.java + * @compile/fail/ref=CrashOnUnknownTargetTypeTest.out -XDrawDiagnostics -Xlint:classfile CrashOnUnknownTargetTypeTest.java */ public class CrashOnUnknownTargetTypeTest { diff --git a/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.out b/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.out index 8e6925a0e0d..d46ea56acef 100644 --- a/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.out +++ b/test/langtools/tools/javac/annotations/crashOnUnknownAttr/CrashOnUnknownTargetTypeTest.out @@ -1,5 +1,5 @@ -- compiler.warn.unknown.enum.constant: ElementType.class, java.lang.annotation.ElementType, NO_SUCH -- compiler.warn.unknown.enum.constant: String.class, java.lang.annotation.ElementType, NO_SUCH +A.class:-:-: compiler.warn.unknown.enum.constant: ElementType.class, java.lang.annotation.ElementType, NO_SUCH +A.class:-:-: compiler.warn.unknown.enum.constant: String.class, java.lang.annotation.ElementType, NO_SUCH CrashOnUnknownTargetTypeTest.java:10:5: compiler.err.annotation.unrecognized.attribute.name: A, NO_SUCH CrashOnUnknownTargetTypeTest.java:11:5: compiler.err.annotation.unrecognized.attribute.name: A, NO_SUCH CrashOnUnknownTargetTypeTest.java:12:14: compiler.err.annotation.unrecognized.attribute.name: A, NO_SUCH diff --git a/test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/ComplexGeneratedInRepeating.java b/test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/ComplexGeneratedInRepeating.java new file mode 100644 index 00000000000..2ddb15a64ea --- /dev/null +++ b/test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/ComplexGeneratedInRepeating.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2026, 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 8378524 + * @summary Check that repeating annotations whose attributes are not-yet-generated classes and their members work. + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit ComplexGeneratedInRepeating + */ + +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.TypeElement; +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +public class ComplexGeneratedInRepeating { + + Path base; + ToolBox tb = new ToolBox(); + + @Test + void testMember() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + new JavacTask(tb) + .options("-d", classes.toString()) + .sources(""" + package test; + + import java.lang.annotation.Repeatable; + + @Rep(Constants.C) + @Rep(Constants.C) + public class Test {} + + @Repeatable(Reps.class) + @interface Rep { + int value(); + } + @interface Reps { + Rep[] value(); + } + """) + .processors(new ProcessorImpl()) + .run() + .writeAll(); + } + + @Test + void testUnresolvableMember() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + List out = new JavacTask(tb) + .options("-d", classes.toString(), "-XDrawDiagnostics", "-nowarn") + .sources(""" + package test; + + import java.lang.annotation.Repeatable; + + @Rep(Constants.C) + @Rep(Constants.Unknown) + public class Test {} + + @Repeatable(Reps.class) + @interface Rep { + int value(); + } + @interface Reps { + Rep[] value(); + } + """) + .processors(new ProcessorImpl()) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + tb.checkEqual(out, List.of( + "Test.java:6:15: compiler.err.cant.resolve.location: kindname.variable, Unknown, , , (compiler.misc.location: kindname.class, test.Constants, null)", + "1 error")); + } + + @Test + void testIncompatibleMember() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + List out = new JavacTask(tb) + .options("-d", classes.toString(), "-XDrawDiagnostics", "-nowarn") + .sources(""" + package test; + + import java.lang.annotation.Repeatable; + + @Rep(Constants.C) + @Rep(Constants.S) + public class Test {} + + @Repeatable(Reps.class) + @interface Rep { + int value(); + } + @interface Reps { + Rep[] value(); + } + """) + .processors(new ProcessorImpl()) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + tb.checkEqual(out, List.of( + "Test.java:6:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, int)", + "1 error")); + } + + @Test + void testAnnotation() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + new JavacTask(tb) + .options("-d", classes.toString()) + .sources(""" + package test; + + import java.lang.annotation.Repeatable; + + @Rep(@Ann(Constants.C)) + @Rep(@Ann(Constants.C)) + public class Test {} + + @Repeatable(Reps.class) + @interface Rep { + Ann value(); + } + @interface Reps { + Rep[] value(); + } + """) + .processors(new ProcessorImpl()) + .run() + .writeAll(); + } + + @SupportedAnnotationTypes("*") + private static class ProcessorImpl extends AbstractProcessor { + + int round = 0; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (round++ == 0) { + try (Writer w = processingEnv.getFiler().createSourceFile("test.Constants").openWriter()) { + w.append(""" + package test; + public class Constants { + public static final int C = 0; + public static final String S = ""; + } + """); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + try (Writer w = processingEnv.getFiler().createSourceFile("test.Ann").openWriter()) { + w.append(""" + package test; + public @interface Ann { + int value(); + } + """); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + } + return false; + } + } + + @BeforeEach + public void setUp(TestInfo info) { + base = Paths.get(".") + .resolve(info.getTestMethod() + .orElseThrow() + .getName()); + } +} diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/IncorrectCastOffsetTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/IncorrectCastOffsetTest.java new file mode 100644 index 00000000000..7a00cf1c897 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/IncorrectCastOffsetTest.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2026, 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 8214934 8379201 + * @summary Wrong type annotation offset on casts on expressions + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.jdeps/com.sun.tools.javap + * @build toolbox.ToolBox toolbox.JavapTask + * @run compile -g:none IncorrectCastOffsetTest.java + * @run main IncorrectCastOffsetTest + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import java.util.List; + +import toolbox.JavapTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class IncorrectCastOffsetTest { + @Target(ElementType.TYPE_USE) + @Retention(RetentionPolicy.RUNTIME) + @interface TypeUse {} + + @Target(ElementType.TYPE_USE) + @Retention(RetentionPolicy.RUNTIME) + @interface TypeUse2 {} + + class AnnotatedCast1 { + private static String checkcast(boolean test, Object obj, Object obj2) { + return (@TypeUse String)(test ? obj : obj2); + } + } + + class AnnotatedCast2 { + private static String checkcast(Object obj) { + return (@TypeUse String)(obj); + } + } + + class AnnotatedCast3 { + private static String checkcast(boolean test, Object obj, Object obj2) { + return (@TypeUse @TypeUse2 String)(test ? obj : obj2); + } + } + + class AnnotatedCast4 { + private static String checkcast(Object obj) { + return (@TypeUse String)(@TypeUse2 CharSequence)(obj); + } + } + + ToolBox tb; + + IncorrectCastOffsetTest() { + tb = new ToolBox(); + } + + public static void main(String args[]) { + IncorrectCastOffsetTest incorrectCastOffsetTest = new IncorrectCastOffsetTest(); + incorrectCastOffsetTest.run(); + } + + void run() { + test("IncorrectCastOffsetTest$AnnotatedCast1.class", + /* + * generated code: + * 0: iload_0 + * 1: ifeq 8 + * 4: aload_1 + * 5: goto 9 + * 8: aload_2 + * 9: checkcast #13 // class java/lang/String + * 12: areturn + */ + List.of( + "RuntimeVisibleTypeAnnotations:", + "0: #24(): CAST, offset=9, type_index=0", + "IncorrectCastOffsetTest$TypeUse" + ) + ); + test("IncorrectCastOffsetTest$AnnotatedCast2.class", + /* + * generated code: + * 0: aload_0 + * 1: checkcast #13 // class java/lang/String + * 4: areturn + */ + List.of( + "RuntimeVisibleTypeAnnotations:", + "0: #23(): CAST, offset=1, type_index=0", + "IncorrectCastOffsetTest$TypeUse" + ) + ); + test("IncorrectCastOffsetTest$AnnotatedCast3.class", + /* + * generated code: + * 0: iload_0 + * 1: ifeq 8 + * 4: aload_1 + * 5: goto 9 + * 8: aload_2 + * 9: checkcast #13 // class java/lang/String + * 12: areturn + */ + List.of( + "RuntimeVisibleTypeAnnotations:", + "0: #24(): CAST, offset=9, type_index=0", + "IncorrectCastOffsetTest$TypeUse", + "1: #25(): CAST, offset=9, type_index=0", + "IncorrectCastOffsetTest$TypeUse2" + ) + ); + test("IncorrectCastOffsetTest$AnnotatedCast4.class", + /* + * generated code: + * 0: aload_0 + * 1: checkcast #13 // class java/lang/CharSequence + * 4: checkcast #15 // class java/lang/String + * 7: areturn + */ + List.of( + "RuntimeVisibleTypeAnnotations:", + "0: #25(): CAST, offset=4, type_index=0", + "IncorrectCastOffsetTest$TypeUse", + "1: #26(): CAST, offset=1, type_index=0", + "IncorrectCastOffsetTest$TypeUse2" + ) + ); + } + + void test(String clazz, List expectedOutput) { + Path pathToClass = Paths.get(ToolBox.testClasses, clazz); + String javapOut = new JavapTask(tb) + .options("-v", "-p") + .classes(pathToClass.toString()) + .run() + .getOutput(Task.OutputKind.DIRECT); + + for (String expected : expectedOutput) { + if (!javapOut.contains(expected)) { + throw new AssertionError("unexpected output"); + } + } + } + +} diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsOnVariables.java b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsOnVariables.java new file mode 100644 index 00000000000..2e68e18f8f7 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsOnVariables.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2026, 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 8371155 + * @summary Verify type annotations on local-like variables are propagated to + * their types at an appropriate time. + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run main TypeAnnotationsOnVariables + */ + +import com.sun.source.tree.LambdaExpressionTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.VariableTree; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.UnionType; +import toolbox.JavacTask; +import toolbox.ToolBox; + +public class TypeAnnotationsOnVariables { + + public static void main(String... args) throws Exception { + new TypeAnnotationsOnVariables().run(); + } + + ToolBox tb = new ToolBox(); + + void run() throws Exception { + typeAnnotationInConstantExpressionFieldInit(Paths.get(".")); + } + + void typeAnnotationInConstantExpressionFieldInit(Path base) throws Exception { + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + import java.lang.annotation.ElementType; + import java.lang.annotation.Target; + import java.util.function.Supplier; + + class Test { + @Target(ElementType.TYPE_USE) + @interface TypeAnno { } + + @TypeAnno Supplier r_f_i = () -> "r_f_i"; + static @TypeAnno Supplier r_f_s = () -> "r_f_s"; + + { + @TypeAnno Supplier r_init_i = () -> "r_init_i"; + } + + static { + @TypeAnno Supplier r_init_s = () -> "r_init_s"; + } + + void m() { + @TypeAnno Supplier r_m_i = () -> "r_m_i"; + } + + static void g() { + @TypeAnno Supplier r_g_s = () -> "r_g_s"; + } + + void h() { + t_cr(() -> "t_cr"); + } + + void i() { + t_no_cr((@TypeAnno Supplier)() -> "t_no_cr"); + } + + void j() { + t_no_cr((java.io.Serializable & @TypeAnno Supplier)() -> "t_no_cr"); + } + + void k() throws Throwable { + try (@TypeAnno AutoCloseable ac = () -> {}) {} + } + + void l() { + try { + } catch (@TypeAnno Exception e1) {} + } + + void n() { + try { + } catch (@TypeAnno final Exception e2) {} + } + + void o() { + try { + } catch (@TypeAnno IllegalStateException | @TypeAnno NullPointerException | IllegalArgumentException e3) {} + } + + void t_cr(@TypeAnno Supplier r_p) { } + void t_no_cr(@TypeAnno Supplier r_p) { } + } + """); + Files.createDirectories(classes); + List actual = new ArrayList<>(); + new JavacTask(tb) + .options("-d", classes.toString()) + .files(tb.findJavaFiles(src)) + .callback(task -> { + task.addTaskListener(new TaskListener() { + @Override + public void finished(TaskEvent e) { + if (e.getKind() != TaskEvent.Kind.ANALYZE) { + return ; + } + Trees trees = Trees.instance(task); + new TreePathScanner() { + @Override + public Void visitVariable(VariableTree node, Void p) { + actual.add(node.getName() + ": " + typeToString(trees.getTypeMirror(getCurrentPath()))); + return super.visitVariable(node, p); + } + @Override + public Void visitLambdaExpression(LambdaExpressionTree node, Void p) { + actual.add(treeToString(node)+ ": " + typeToString(trees.getTypeMirror(getCurrentPath()))); + return super.visitLambdaExpression(node, p); + } + }.scan(e.getCompilationUnit(), null); + } + }); + }) + .run() + .writeAll(); + + List expected = List.of( + "r_f_i: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_f_i\": java.util.function.@Test.TypeAnno Supplier", + "r_f_s: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_f_s\": java.util.function.@Test.TypeAnno Supplier", + "r_init_i: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_init_i\": java.util.function.@Test.TypeAnno Supplier", + "r_init_s: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_init_s\": java.util.function.@Test.TypeAnno Supplier", + "r_m_i: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_m_i\": java.util.function.@Test.TypeAnno Supplier", + "r_g_s: java.util.function.@Test.TypeAnno Supplier", + "()->\"r_g_s\": java.util.function.@Test.TypeAnno Supplier", + "()->\"t_cr\": java.util.function.@Test.TypeAnno Supplier", + "()->\"t_no_cr\": java.util.function.@Test.TypeAnno Supplier", + "()->\"t_no_cr\": java.lang.Object&java.io.Serializable&java.util.function.@Test.TypeAnno Supplier", + "ac: java.lang.@Test.TypeAnno AutoCloseable", + "()->{ }: java.lang.@Test.TypeAnno AutoCloseable", + "e1: java.lang.@Test.TypeAnno Exception", + "e2: java.lang.@Test.TypeAnno Exception", + "e3: java.lang.@Test.TypeAnno IllegalStateException | java.lang.@Test.TypeAnno NullPointerException | java.lang.IllegalArgumentException", + "r_p: java.util.function.@Test.TypeAnno Supplier", + "r_p: java.util.function.@Test.TypeAnno Supplier" + ); + + actual.forEach(System.out::println); + if (!expected.equals(actual)) { + throw new AssertionError("Expected: " + expected + ", but got: " + actual); + } + } + + static String typeToString(TypeMirror type) { + if (type != null && type.getKind() == TypeKind.UNION) { + return ((UnionType) type).getAlternatives().stream().map(t -> typeToString(t)).collect(Collectors.joining(" | ")); + } else { + return String.valueOf(type); + } + } + + static String treeToString(Tree tree) { + if (tree.toString().contains("\n")) { + System.err.println("!!!"); + } + return String.valueOf(tree).replaceAll("\\R", " "); + } +} diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsPositionsOnRecords.java b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsPositionsOnRecords.java index dfa266ef035..b8ee32fcacd 100644 --- a/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsPositionsOnRecords.java +++ b/test/langtools/tools/javac/annotations/typeAnnotations/TypeAnnotationsPositionsOnRecords.java @@ -78,6 +78,17 @@ public class TypeAnnotationsPositionsOnRecords { record Record6(String t1, @Nullable String t2) { public Record6 {} } + + class Test2 { + @Target(ElementType.TYPE_USE) + @Retention(RetentionPolicy.RUNTIME) + public @interface Anno {} + + class Foo {} + record Record7(Test2.@Anno Foo foo) { + public Record7 {} // compact constructor + } + } """; public static void main(String... args) throws Exception { @@ -100,6 +111,8 @@ public class TypeAnnotationsPositionsOnRecords { "Record5.class").toUri()), 1); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Record6.class").toUri()), 1); + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), + "Test2$Record7.class").toUri()), 0); } void compileTestClass() throws Exception { @@ -110,6 +123,7 @@ public class TypeAnnotationsPositionsOnRecords { void checkClassFile(final File cfile, int... taPositions) throws Exception { ClassModel classFile = ClassFile.of().parse(cfile.toPath()); + System.err.println("-----------loading " + cfile.getPath()); int accessorPos = 0; int checkedAccessors = 0; for (MethodModel method : classFile.methods()) { diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/classfile/BridgeShouldHaveNoInteriorAnnotationsTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/BridgeShouldHaveNoInteriorAnnotationsTest.java index 0ec1a790d72..3426bfedd30 100644 --- a/test/langtools/tools/javac/annotations/typeAnnotations/classfile/BridgeShouldHaveNoInteriorAnnotationsTest.java +++ b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/BridgeShouldHaveNoInteriorAnnotationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -71,7 +71,7 @@ public class BridgeShouldHaveNoInteriorAnnotationsTest }; - // Expected output can't be directly encoded into NestedLambdasCastedTest !!! + // Expected output can't be directly encoded into BridgeShouldHaveNoInteriorAnnotationsTest !!! static class OutputExpectedOnceHolder { public String[] outputs = { "0: #120(): CAST, offset=1, type_index=0, location=[TYPE_ARGUMENT(0)]", diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/classfile/LocalClassesTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/LocalClassesTest.java new file mode 100644 index 00000000000..66b55c8d209 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/classfile/LocalClassesTest.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2026, 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 8371817 + * @summary Check for type annotating types that refer to local classes read + * from classfiles + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit LocalClassesTest + */ + +import com.sun.source.tree.ClassTree; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import toolbox.JavacTask; +import toolbox.ToolBox; + +public class LocalClassesTest { + + ToolBox tb = new ToolBox(); + Path base; + + @Test + void test() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + + Map local2enclosing = new HashMap<>(); + new JavacTask(tb) + .options("-d", classes.toString()) + .sources(""" + import java.lang.annotation.ElementType; + import java.lang.annotation.Target; + + public class Test { + public static void m1() { + class Local1 { + @Nullable Local1 l; + } + } + public void m2() { + class Local2 { + @Nullable Local2 l; + } + } + } + + @Target({ElementType.TYPE_USE}) + @interface Nullable {} + """) + .callback(task -> { + task.addTaskListener(new TaskListener() { + @Override + public void finished(TaskEvent e) { + if (e.getKind() == TaskEvent.Kind.ANALYZE) { + Trees trees = Trees.instance(task); + new TreePathScanner<>() { + @Override + public Object visitClass(ClassTree node, Object p) { + if (node.getSimpleName().toString().startsWith("Local")) { + Element el = trees.getElement(getCurrentPath()); + TypeMirror type = trees.getTypeMirror(getCurrentPath()); + local2enclosing.put(el.getSimpleName().toString(), ((DeclaredType) type).getEnclosingType().toString()); + } + return super.visitClass(node, p); + } + }.scan(e.getCompilationUnit(), null); + } + } + }); + }) + .run() + .writeAll(); + + Path classes2 = base.resolve("classes2"); + Files.createDirectories(classes2); + + ProcessorImpl p = new ProcessorImpl(); + new JavacTask(tb) + .options("-cp", classes.toString(), "-d", classes2.toString()) + .processors(p) + .classes("Test$1Local1", "Test$1Local2") + .run() + .writeAll(); + + Assertions.assertEquals(local2enclosing.get("Local1"), p.local2enclosing.get("Local1")); + Assertions.assertEquals(local2enclosing.get("Local2"), p.local2enclosing.get("Local2")); + } + + @SupportedAnnotationTypes("*") + private static class ProcessorImpl extends AbstractProcessor { + private Map local2enclosing = new HashMap<>(); + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (TypeElement te : ElementFilter.typesIn(roundEnv.getRootElements())) { + if (te.getSimpleName().toString().startsWith("Local")) { + local2enclosing.put(te.getSimpleName().toString(), ((DeclaredType) te.asType()).getEnclosingType().toString()); + } + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); + } + } + + @BeforeEach + public void setup(TestInfo info) { + base = Paths.get(".") + .resolve(info.getTestMethod() + .orElseThrow() + .getName()); + } +} diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables-old.out b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables-old.out new file mode 100644 index 00000000000..2b447e4a842 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables-old.out @@ -0,0 +1,7 @@ +VarVariables.java:34:36: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.deconstruction.patterns), 19, 21 +VarVariables.java:18:9: compiler.err.annotation.type.not.applicable +VarVariables.java:24:14: compiler.err.annotation.type.not.applicable +VarVariables.java:27:14: compiler.err.annotation.type.not.applicable +VarVariables.java:32:14: compiler.err.annotation.type.not.applicable +VarVariables.java:36:37: compiler.err.annotation.type.not.applicable +6 errors diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.java b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.java new file mode 100644 index 00000000000..a47b8b31da7 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.java @@ -0,0 +1,52 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8371683 + * @summary Test that type annotations cannot appears on 'var' variables + * @compile/fail/ref=VarVariables.out -XDrawDiagnostics VarVariables.java + * @compile/fail/ref=VarVariables-old.out --release 19 -XDrawDiagnostics -XDshould-stop.at=FLOW VarVariables.java + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.util.List; +import java.util.function.Consumer; + +class VarVariables { + private void test(Object o) { + @DA var v1 = ""; + @DTA var v2 = ""; + @TA var v3 = ""; + Consumer c1 = (@DA var v) -> {}; + Consumer c2 = (@DTA var v) -> {}; + Consumer c3 = (@TA var v) -> {}; + for (@DA var v = ""; !v.isEmpty(); ) {} + for (@DTA var v = ""; !v.isEmpty(); ) {} + for (@TA var v = ""; !v.isEmpty(); ) {} + for (@DA var v : List.of("")) {} + for (@DTA var v : List.of("")) {} + for (@TA var v : List.of("")) {} + try (@DA var v = open()) { + } catch (Exception ex) {} + try (@DTA var v = open()) { + } catch (Exception ex) {} + try (@TA var v = open()) { + } catch (Exception ex) {} + boolean b1 = o instanceof R(@DA var v); + boolean b2 = o instanceof R(@DTA var v); + boolean b3 = o instanceof R(@TA var v); + } + + private AutoCloseable open() { + return null; + } + record R(String str) {} + + @Target(ElementType.TYPE_USE) + @interface TA { } + + @Target({ElementType.TYPE_USE, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @interface DTA { } + + @Target({ElementType.LOCAL_VARIABLE, ElementType.PARAMETER}) + @interface DA { } +} diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.out b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.out new file mode 100644 index 00000000000..7f055040855 --- /dev/null +++ b/test/langtools/tools/javac/annotations/typeAnnotations/failures/target/VarVariables.out @@ -0,0 +1,7 @@ +VarVariables.java:18:9: compiler.err.annotation.type.not.applicable +VarVariables.java:21:32: compiler.err.annotation.type.not.applicable +VarVariables.java:24:14: compiler.err.annotation.type.not.applicable +VarVariables.java:27:14: compiler.err.annotation.type.not.applicable +VarVariables.java:32:14: compiler.err.annotation.type.not.applicable +VarVariables.java:36:37: compiler.err.annotation.type.not.applicable +6 errors diff --git a/test/langtools/tools/javac/api/TestGetScopeResult.java b/test/langtools/tools/javac/api/TestGetScopeResult.java index 533c640096e..adae4ccdb5a 100644 --- a/test/langtools/tools/javac/api/TestGetScopeResult.java +++ b/test/langtools/tools/javac/api/TestGetScopeResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8205418 8207229 8207230 8230847 8245786 8247334 8248641 8240658 8246774 8274347 8347989 + * @bug 8205418 8207229 8207230 8230847 8245786 8247334 8248641 8240658 8246774 8274347 8347989 8308637 * @summary Test the outcomes from Trees.getScope * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.comp @@ -100,6 +100,7 @@ public class TestGetScopeResult { new TestGetScopeResult().testNestedSwitchExpression(); new TestGetScopeResult().testModuleImportScope(); new TestGetScopeResult().testClassTypeSetInEnterGetScope(); + new TestGetScopeResult().testNotYetAttributedGetScope(); } public void run() throws IOException { @@ -966,6 +967,110 @@ public class TestGetScopeResult { } } + void testNotYetAttributedGetScope() throws IOException { //JDK-8308637 + JavacTool c = JavacTool.create(); + record TestCase(String code, List> expected) {} + TestCase[] cases = new TestCase[] { + new TestCase(""" + class B { + public class Test {} + void m() { + this.new Test() {}; + } + } + """, + List.of(List.of("super:java.lang.Object", + "this:B"))), + new TestCase(""" + class B { + public class Test {} + void m() { + int local1 = 0; + new Test() {}; + this.new Test() {}; + class Inner { + class InnerNested { + void m() { + int local2 = 0; + new Test() {}; + B.this.new Test() {}; + } + } + } + } + } + """, + List.of( + List.of("local1:int", + "super:java.lang.Object", + "this:B"), + List.of(":", + "local1:int", + "super:java.lang.Object", + "this:B"), + List.of("local2:int", + "super:java.lang.Object", + "this:Inner.InnerNested", + "super:java.lang.Object", + "this:Inner", + "Inner:Inner", + ":", + ":", + "local1:int", + "super:java.lang.Object", + "this:B"), + List.of(":", + "local2:int", + "super:java.lang.Object", + "this:Inner.InnerNested", + "super:java.lang.Object", + "this:Inner", + "Inner:Inner", + ":", + ":", + "local1:int", + "super:java.lang.Object", + "this:B") + )), + }; + try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { + for (TestCase tc : cases) { + JavaFileObject input = + SimpleJavaFileObject.forSource(URI.create("myfo:///Test.java"), tc.code()); + JavacTask t = (JavacTask) c.getTask(null, fm, null, null, null, + List.of(input)); + Trees trees = Trees.instance(t); + List> actual = new ArrayList<>(); + + t.addTaskListener(new TaskListener() { + @Override + public void finished(TaskEvent e) { + if (e.getKind() == TaskEvent.Kind.ENTER) { + new TreePathScanner() { + @Override + public Void visitIdentifier(IdentifierTree node, Void p) { + if (node.getName().contentEquals("Test")) { + Scope scope = trees.getScope(getCurrentPath()); + actual.add(dumpScope(scope)); + } + return super.visitIdentifier(node, p); + } + }.scan(e.getCompilationUnit(), null); + } + } + + }); + + t.analyze(); + + if (!tc.expected().equals(actual)) { + throw new AssertionError("Unexpected Scope content: " + actual + + ", expected: " + tc.expected()); + } + } + } + } + private List dumpScope(Scope scope) { List content = new ArrayList<>(); while (scope.getEnclosingClass() != null) { diff --git a/test/langtools/tools/javac/classreader/Annotations.java b/test/langtools/tools/javac/classreader/Annotations.java new file mode 100644 index 00000000000..30d0ae48b9a --- /dev/null +++ b/test/langtools/tools/javac/classreader/Annotations.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2026, 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 8305250 + * @summary Check behavior w.r.t. annotations missing from the classpath. + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit Annotations + */ + +import java.nio.file.Files; +import java.util.List; +import java.nio.file.Path; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import toolbox.ToolBox; +import toolbox.JavacTask; +import toolbox.Task; + +public class Annotations { + private ToolBox tb = new ToolBox(); + private Path base; + + @Test + public void testParameterModifiersNotVisible() throws Exception { + Path ann = base.resolve("annotations"); + Path annSrc = ann.resolve("src"); + Path annClasses = ann.resolve("classes"); + + tb.writeJavaFiles(annSrc, + """ + package annotations; + public @interface Ann { + public E e(); + } + """, + """ + package annotations; + public enum E { + A; + } + """); + + Files.createDirectories(annClasses); + + new JavacTask(tb) + .outdir(annClasses) + .files(tb.findJavaFiles(annSrc)) + .run() + .writeAll(); + + Path lib = base.resolve("lib"); + Path libSrc = lib.resolve("src"); + Path libClasses = lib.resolve("classes"); + + tb.writeJavaFiles(libSrc, + """ + package lib; + import annotations.*; + @Ann(e = E.A) + public class Lib { + } + """); + + Files.createDirectories(libClasses); + + new JavacTask(tb) + .outdir(libClasses) + .classpath(annClasses) + .files(tb.findJavaFiles(libSrc)) + .run() + .writeAll(); + + Path test = base.resolve("test"); + Path testSrc = test.resolve("src"); + Path testClasses = test.resolve("classes"); + + tb.writeJavaFiles(testSrc, + """ + package test; + import lib.*; + public class Test { + Lib l; + } + """); + + Files.createDirectories(testClasses); + + //annotations available, no errors/warnings: + new JavacTask(tb) + .outdir(testClasses) + .classpath(libClasses, annClasses) + .options("-Werror", "-Xlint:classfile") + .files(tb.findJavaFiles(testSrc)) + .run() + .writeAll(); + + //annotation and enum missing, no errors/warnings: + new JavacTask(tb) + .outdir(testClasses) + .classpath(libClasses) + .options("-Werror", "-Xlint:classfile") + .files(tb.findJavaFiles(testSrc)) + .run() + .writeAll(); + + tb.writeJavaFiles(annSrc, + """ + package annotations; + public enum E { + B; + } + """); + + Files.createDirectories(annClasses); + + new JavacTask(tb) + .outdir(annClasses) + .files(tb.findJavaFiles(annSrc)) + .run() + .writeAll(); + + List log; + + //enum missing the enum constant recorded in the classfile, report warning: + log = new JavacTask(tb) + .outdir(testClasses) + .classpath(libClasses, annClasses) + .options("-Xlint:classfile", "-XDrawDiagnostics") + .files(tb.findJavaFiles(testSrc)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + tb.checkEqual(log, + List.of("Lib.class:-:-: compiler.warn.unknown.enum.constant: E.class, annotations.E, A", + "1 warning")); + + //enum is missing, but the annotation is not, report warning: + Files.delete(annClasses.resolve("annotations").resolve("E.class")); + + log = new JavacTask(tb) + .outdir(testClasses) + .classpath(libClasses, annClasses) + .options("-Xlint:classfile", "-XDrawDiagnostics") + .files(tb.findJavaFiles(testSrc)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + tb.checkEqual(log, + List.of("Lib.class:-:-: compiler.warn.unknown.enum.constant.reason: Ann.class, annotations.E, A, (compiler.misc.class.file.not.found: annotations.E)", + "1 warning")); + + tb.writeJavaFiles(annSrc, + """ + package annotations; + public @interface Ann { + public E nue(); + } + """, + """ + package annotations; + public enum E { + A; + } + """); + + new JavacTask(tb) + .outdir(annClasses) + .files(tb.findJavaFiles(annSrc)) + .run() + .writeAll(); + + //enum is OK and the annotation exists, but the annotation is missing the required attribute method, report warning: + log = new JavacTask(tb) + .outdir(testClasses) + .classpath(libClasses, annClasses) + .options("-Xlint:classfile", "-XDrawDiagnostics") + .files(tb.findJavaFiles(testSrc)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + tb.checkEqual(log, + List.of("Lib.class:-:-: compiler.warn.annotation.method.not.found: annotations.Ann, e", + "1 warning")); + } + + @BeforeEach + public void setup(TestInfo ti) { + base = Path.of(".").resolve(ti.getTestMethod().orElseThrow().getName()); + } +} diff --git a/test/langtools/tools/javac/diags/CheckExamples.java b/test/langtools/tools/javac/diags/CheckExamples.java index 502f5fa8b88..7a188614080 100644 --- a/test/langtools/tools/javac/diags/CheckExamples.java +++ b/test/langtools/tools/javac/diags/CheckExamples.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2026, 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,12 +45,22 @@ import java.util.*; /** * Check invariants for a set of examples. + * + * READ THIS IF THIS TEST FAILS AFTER ADDING A NEW KEY TO 'compiler.properties': + * The 'examples' subdirectory contains a number of examples which provoke + * the reporting of most of the compiler message keys. + * * -- each example should exactly declare the keys that will be generated when * it is run. + * -- this is done by the "// key:"-comment in each fine. * -- together, the examples should cover the set of resource keys in the * compiler.properties bundle. A list of exceptions may be given in the * not-yet.txt file. Entries on the not-yet.txt list should not be * covered by examples. + * -- some keys are only reported by the compiler when specific options are + * supplied. For the purposes of this test, this can be specified by a + * comment e.g. like this: "// options: -Xlint:empty" + * * When new keys are added to the resource bundle, it is strongly recommended * that corresponding new examples be added here, if at all practical, instead * of simply and lazily being added to the not-yet.txt list. diff --git a/test/langtools/tools/javac/doctree/ReferenceTest.java b/test/langtools/tools/javac/doctree/ReferenceTest.java index 540cb9a6621..83a10ee4d20 100644 --- a/test/langtools/tools/javac/doctree/ReferenceTest.java +++ b/test/langtools/tools/javac/doctree/ReferenceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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,7 +23,7 @@ /* * @test - * @bug 7021614 8278373 8164094 8371248 + * @bug 7021614 8278373 8164094 8371248 8284315 * @summary extend com.sun.source API to support parsing javadoc comments * @summary check references in at-see and {at-link} tags * @modules jdk.compiler @@ -56,6 +56,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.tools.Diagnostic.Kind; @@ -84,11 +85,14 @@ import javax.tools.Diagnostic.Kind; * {@link #trees Field} * {@link #getSupportedSourceVersion Method} * {@link #init(ProcessingEnvironment Method} - * {@link double Class} + * {@link double type-only:double} + * {@link int type-only:int} + * {@link void type-only:void} * {@link double.NAN Bad} * {@link double#NAN Bad} * {@link double#double Bad} * {@link java.base/double Bad} + * {@link jdk.javadoc/double Bad} * * {@link List Interface} * {@link List.add Bad} @@ -100,15 +104,20 @@ import javax.tools.Diagnostic.Kind; * {@link Map.Entry#getKey Method} * {@link Map.Entry#setValue(Object) Method} * - * {@link java.base/java.util.List Bad} + * {@link java.lang.String[] type-only:array} + * {@link java.lang.String[].length Bad} + * {@link java.lang.String[]#length type-only:int} + * {@link java.lang.String[]#length() Bad} + * + * {@link java.base/java.util.List Interface} * {@link java.base/java.util.List.add Bad} - * {@link java.base/java.util.List#add Bad} - * {@link java.base/java.util.List#add(Object) Bad} - * {@link java.base/java.util.Map.Entry Bad} - * {@link java.base/java.util.Map.Entry Bad} + * {@link java.base/java.util.List#add Method} + * {@link java.base/java.util.List#add(Object) Method} + * {@link java.base/java.util.Map.Entry Interface} + * {@link java.base/java.util.Map.Entry Interface} * {@link java.base/java.util.Map.Entry.getKey Bad} - * {@link java.base/java.util.Map.Entry#getKey Bad} - * {@link java.base/java.util.Map.Entry#setValue(Object) Bad} + * {@link java.base/java.util.Map.Entry#getKey Method} + * {@link java.base/java.util.Map.Entry#setValue(Object) Method} * * @see java.lang Package * @see java.lang.ERROR Bad @@ -127,6 +136,14 @@ import javax.tools.Diagnostic.Kind; * @see java.lang.String#ERROR Bad * @see java.lang.String#equals(Object) Method * + * @see java.lang.String[] type-only:array + * @see java.lang.String[].length Bad + * @see java.lang.String[]#length type-only:int + * @see java.lang.String[]#length() Bad + * + * @see jdk.javadoc/jdk.javadoc.doclet.Doclet Interface + * @see jdk.compiler/jdk.javadoc.doclet.Doclet Bad + * * @see AbstractProcessor Class * * @see List#add(Object) Method @@ -200,15 +217,23 @@ public class ReferenceTest extends AbstractProcessor { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); + TypeMirror type = trees.getType(new DocTreePath(getCurrentPath(), tree)); + if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); + if (type == null) { + error(tree, "Did not find type for element " + found); + } else if (!erasure(type).equals(erasure(found.asType()))) { + error(tree, "Type " + erasure(type) + " does not match element " + erasure(found.asType())); + } } String expect = "UNKNOWN"; - if (label.size() > 0 && label.get(0) instanceof TextTree) - expect = ((TextTree) label.get(0)).getBody(); + if (!label.isEmpty() && label.getFirst() instanceof TextTree) { + expect = ((TextTree) label.getFirst()).getBody(); + } if (expect.startsWith("signature:")) { expect = expect.substring("signature:".length()); @@ -216,12 +241,25 @@ public class ReferenceTest extends AbstractProcessor { String signature = found.getKind().name() + ":" + elementSignature(found); if (!expect.equalsIgnoreCase(signature)) { - error(tree, "Unexpected value found: " + signature +", expected: " + expect); + error(tree, "Unexpected value found: " + signature + ", expected: " + expect); + } + } else if (expect.startsWith("type-only:")) { + expect = expect.substring("type-only:".length()); + if (found != null) { + error(tree, "Found element for type-only reference: " + found); + } + if (type == null) { + error(tree, "Found no type, expected: " + expect); + } else if (!expect.equalsIgnoreCase(type.getKind().name())) { + error(tree, "Found unexpected type: " + type + ", expected: " + expect); } } else { if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } + if (expect.equalsIgnoreCase("bad") && type != null) { + error(tree, "Found unexpected type: " + type + ", expected none"); + } } } @@ -252,6 +290,12 @@ public class ReferenceTest extends AbstractProcessor { default -> throw new AssertionError("Unhandled type kind: " + type.getKind()); }; } + + TypeMirror erasure(TypeMirror type) { + return type.getKind() == TypeKind.DECLARED + ? processingEnv.getTypeUtils().erasure(type) + : type; + } } /** @@ -317,11 +361,17 @@ class ReferenceTestExtras { * @see #X Field * @see #X() Method * @see #m Method + * @see X Type_Parameter + * @see Y Type_Parameter + * @see X#wait Method + * @see X#wait() Method + * @see Y#getSupportedSourceVersion Method + * @see Y#init(ProcessingEnvironment) Method * @see Inner#X Bad * @see Inner#X() Bad * @see Inner#m Bad */ - interface Inner {} + interface Inner {} } diff --git a/test/langtools/tools/javac/implicitCompile/APImplicitClassesWarnings.java b/test/langtools/tools/javac/implicitCompile/APImplicitClassesWarnings.java new file mode 100644 index 00000000000..dc60c6cc78a --- /dev/null +++ b/test/langtools/tools/javac/implicitCompile/APImplicitClassesWarnings.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2026, 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 8378740 + * @summary Verify warnings are properly suppressed for the combination of + * annotation processing and implicit compilation + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit APImplicitClassesWarnings + */ + + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class APImplicitClassesWarnings { + + final ToolBox tb = new ToolBox(); + Path base; + + @Test + public void testCorrectSource() throws Exception { + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package test; + + @Deprecated(forRemoval=true) + public class Depr { + } + """, + """ + package test; + public class Use { + Implicit implicit; + Depr depr; + } + """, + """ + package test; + public interface Implicit {} + """); + Files.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-d", classes.toString(), + "-XDrawDiagnostics", + "-implicit:class", + "-sourcepath", src.toString()) + .files(src.resolve("test").resolve("Depr.java"), + src.resolve("test").resolve("Use.java")) + .processors(new ProcessorImpl()) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = List.of( + "Use.java:4:5: compiler.warn.has.been.deprecated.for.removal: test.Depr, test", + "Use.java:4:5: compiler.warn.has.been.deprecated.for.removal: test.Depr, test", + "Use.java:4:5: compiler.warn.has.been.deprecated.for.removal: test.Depr, test", + "3 warnings" + ); + + tb.checkEqual(expected, log); + } + + @Test + public void testCorrectSuppress() throws Exception { + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + //note the added @SuppressWarnings("removal"): + """ + package test; + + @Deprecated(forRemoval=true) + public class Depr { + } + """, + """ + package test; + public class Use { + Implicit implicit; + @SuppressWarnings("removal") + Depr depr; + } + """, + """ + package test; + public interface Implicit {} + """); + Files.createDirectories(classes); + + new JavacTask(tb) + .options("-d", classes.toString(), + "-Werror", + "-implicit:class", + "-sourcepath", src.toString()) + .files(src.resolve("test").resolve("Depr.java"), + src.resolve("test").resolve("Use.java")) + .processors(new ProcessorImpl()) + .run() + .writeAll(); + } + + @SupportedAnnotationTypes("*") + private static class ProcessorImpl extends AbstractProcessor { + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + return false; + } + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + } + + @BeforeEach + public void setUp(TestInfo info) { + base = Paths.get(".") + .resolve(info.getTestMethod().orElseThrow().getName()); + } +} diff --git a/test/langtools/tools/javac/launcher/SourceLauncherTest.java b/test/langtools/tools/javac/launcher/SourceLauncherTest.java index 37d50674855..d0cf11a0327 100644 --- a/test/langtools/tools/javac/launcher/SourceLauncherTest.java +++ b/test/langtools/tools/javac/launcher/SourceLauncherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8192920 8204588 8246774 8248843 8268869 8235876 8328339 8335896 8344706 - * 8362237 + * 8362237 8376534 * @summary Test source launcher * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -670,6 +670,7 @@ public class SourceLauncherTest extends TestRunner { tb.writeJavaFiles(base, "public class Main { public static void main(String... args) {}}"); String log = new JavaTask(tb) .vmOptions("--source", "21") + .includeStandardOptions(false) // Do not inherit --enable-preview .className(base.resolve("Main.java").toString()) .run(Task.Expect.SUCCESS) .getOutput(Task.OutputKind.STDERR); @@ -890,6 +891,57 @@ public class SourceLauncherTest extends TestRunner { "correct\n"); } + @Test + public void testInheritedMain(Path base) throws IOException { + tb.writeJavaFiles(base, + """ + class Sub extends Super {} + """, + """ + class Super { + void main() { + System.out.println(getClass().getName()); + } + } + """); + testSuccess(base.resolve("Sub.java"), + "Sub\n"); + } + + @Test + public void testInheritedMainFromAbstract(Path base) throws IOException { + tb.writeJavaFiles(base, + """ + class Sub extends Super {} + """, + """ + abstract class Super { + void main() { + System.out.println(getClass().getName()); + } + } + """); + testSuccess(base.resolve("Sub.java"), + "Sub\n"); + } + + @Test + public void testInheritedMainFromInterface(Path base) throws IOException { + tb.writeJavaFiles(base, + """ + public class Sub implements Super {} + """, + """ + public interface Super { + default void main() { + System.out.println(getClass().getName()); + } + } + """); + testSuccess(base.resolve("Sub.java"), + "Sub\n"); + } + Result run(Path file, List runtimeArgs, List appArgs) { List args = new ArrayList<>(); args.add(file.toString()); diff --git a/test/langtools/tools/javac/lvti/VarAccessibility.java b/test/langtools/tools/javac/lvti/VarAccessibility.java new file mode 100644 index 00000000000..d39d706faea --- /dev/null +++ b/test/langtools/tools/javac/lvti/VarAccessibility.java @@ -0,0 +1,393 @@ +/* + * Copyright (c) 2026, 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 + * @summary Check behavior of var when the inferred type is inaccessible + * @library /tools/lib + * @modules java.logging + * java.sql + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit VarAccessibility + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Objects; + +import org.junit.jupiter.api.Test; + +import toolbox.JavacTask; +import toolbox.JavaTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class VarAccessibility { + + private static final ToolBox tb = new ToolBox(); + + @Test + public void testInaccessibleInferredTypeLocalVariable() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + public class API { + public static PackagePrivate get() { + return new PackagePrivate(); + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + var v = API.get(); + System.out.println(v); + } + } + """); + + Files.createDirectories(classes); + + new JavacTask(tb) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll(); + + var out = new JavaTask(tb) + .classpath(classes.toString()) + .className("p2.Test") + .run() + .writeAll() + .getOutputLines(Task.OutputKind.STDOUT); + + var expectedOut = List.of("pass"); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + + @Test + public void testInaccessibleInferredTypeForEachIterable() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + import java.util.List; + public class API { + public static Iterable get() { + return List.of(new PackagePrivate()); + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + for (var v : API.get()) { + System.out.println(v); + } + } + } + """); + + Files.createDirectories(classes); + + var out = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of( + "Test.java:5:22: compiler.err.not.def.public.cant.access: p1.PackagePrivate, p1", + "1 error"); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + + @Test + public void testInaccessibleInferredTypeForEachArray() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + import java.util.List; + public class API { + public static PackagePrivate[] get() { + return new PackagePrivate[] {new PackagePrivate()}; + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + for (var v : API.get()) { + System.out.println(v); + } + } + } + """); + + Files.createDirectories(classes); + + new JavacTask(tb) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll(); + + var out = new JavaTask(tb) + .classpath(classes.toString()) + .className("p2.Test") + .run() + .writeAll() + .getOutputLines(Task.OutputKind.STDOUT); + + var expectedOut = List.of("pass"); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + + @Test + public void testInaccessibleInferredTypeLambda() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + import java.util.function.Consumer; + public class API { + public static void run(Consumer c) { + c.accept(new PackagePrivate()); + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + API.run(v -> System.out.println(v)); + API.run((var v) -> System.out.println(v)); + } + } + """); + + Files.createDirectories(classes); + + var out = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of( + "Test.java:5:17: compiler.err.not.def.public.cant.access: p1.PackagePrivate, p1", + "Test.java:6:17: compiler.err.not.def.public.cant.access: p1.PackagePrivate, p1", + "2 errors"); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + + @Test + public void testInaccessibleInferredTypeCanUse() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + public class API { + public static PackagePrivate get() { + return null; + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + var v = API.get(); + System.out.println(v.toString()); + } + } + """); + + Files.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of( + "Test.java:6:29: compiler.err.not.def.access.class.intf.cant.access: toString(), p1.PackagePrivate", + "1 error" + ); + + if (!Objects.equals(expectedOut, log)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + log); + + } + } + + @Test + public void testInaccessibleInferredBindingPattern() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + public record API(PackagePrivate p) { + public static API create() { + return new API(new PackagePrivate()); + } + } + """, + """ + package p1; + class PackagePrivate { + public String toString() { + return "pass"; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + Object o = API.create(); + if (o instanceof API(var v)) { + System.out.println(v.toString()); + } + } + } + """); + + Files.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of( + "Test.java:7:33: compiler.err.not.def.access.class.intf.cant.access: toString(), p1.PackagePrivate", + "1 error" + ); + + if (!Objects.equals(expectedOut, log)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + log); + + } + } +} diff --git a/test/langtools/tools/javac/lvti/VarWarnings.java b/test/langtools/tools/javac/lvti/VarWarnings.java new file mode 100644 index 00000000000..a1fbadc0393 --- /dev/null +++ b/test/langtools/tools/javac/lvti/VarWarnings.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2026, 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 + * @summary Check behavior of warnings related to var + * @library /tools/lib + * @modules java.logging + * java.sql + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit VarWarnings + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Objects; + +import org.junit.jupiter.api.Test; + +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class VarWarnings { + + private static final ToolBox tb = new ToolBox(); + + @Test + public void testDeprecationWarning() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + import java.util.List; + import java.util.function.Consumer; + @SuppressWarnings("deprecation") + public class API { + public static DeprOutter get() { + return new DeprOutter<>(); + } + public static Iterable> getIterable() { + return null; + } + public static void run(Consumer> task) { + } + } + """, + """ + package p1; + @Deprecated + public class DeprInner { + } + """, + """ + package p1; + @Deprecated + public class DeprOutter { + public T get() { + return null; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + var v1 = API.get(); + API.run(v -> v.get().toString()); + API.run((var v) -> v.get().toString()); + for (var v2 : API.getIterable()) {} + } + } + """); + + Files.createDirectories(classes); + + var out = new JavacTask(tb) + .options("-XDrawDiagnostics", + "-Werror", + "-Xlint:deprecation") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of(""); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + + @Test + public void testRawTypeWarning() throws Exception { + Path base = Paths.get("."); + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + tb.writeJavaFiles(src, + """ + package p1; + import java.util.List; + import java.util.function.Consumer; + @SuppressWarnings("rawtypes") + public class API { + public static RawOutter get() { + return new RawOutter<>(); + } + public static Iterable> getIterable() { + return null; + } + public static void run(Consumer> task) { + } + } + """, + """ + package p1; + public class RawInner { + } + """, + """ + package p1; + public class RawOutter { + public T get() { + return null; + } + } + """, + """ + package p2; + import p1.API; + public class Test { + public static void main(String... args) { + var v1 = API.get(); + API.run(v -> v.get().toString()); + API.run((var v) -> v.get().toString()); + for (var v2 : API.getIterable()) {} + } + } + """); + + Files.createDirectories(classes); + + var out = new JavacTask(tb) + .options("-XDrawDiagnostics", + "-Werror", + "-Xlint:rawtypes") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + var expectedOut = List.of(""); + + if (!Objects.equals(expectedOut, out)) { + throw new AssertionError("Incorrect Output, expected: " + expectedOut + + ", actual: " + out); + + } + } + +} diff --git a/test/langtools/tools/javac/parser/DeclarationEndPositions.java b/test/langtools/tools/javac/parser/DeclarationEndPositions.java index c61a92e80cd..fe4ca8c1652 100644 --- a/test/langtools/tools/javac/parser/DeclarationEndPositions.java +++ b/test/langtools/tools/javac/parser/DeclarationEndPositions.java @@ -86,10 +86,12 @@ public class DeclarationEndPositions { // For variable declarations using "var", verify the "var" position if (tree instanceof JCVariableDecl varDecl && varDecl.declaredUsingVar()) { - int vpos = varDecl.typePos; - if (!input.substring(vpos).startsWith("var")) { + int varStart = varDecl.vartype.getStartPosition(); + int varEnd = varDecl.vartype.getEndPosition(); + + if (!input.substring(varStart, varEnd).startsWith("var")) { throw new AssertionError(String.format( - "wrong %s pos %d for \"%s\" in \"%s\"", "var", vpos, tree, input)); + "wrong %s start pos %d end pos %d for \"%s\" in \"%s\"", "var", varStart, varEnd, tree, input)); } } } diff --git a/test/langtools/tools/javac/parser/JavacParserTest.java b/test/langtools/tools/javac/parser/JavacParserTest.java index 25aeb19f1bb..0bce1ef017c 100644 --- a/test/langtools/tools/javac/parser/JavacParserTest.java +++ b/test/langtools/tools/javac/parser/JavacParserTest.java @@ -87,7 +87,9 @@ import javax.tools.ToolProvider; import com.sun.source.tree.CaseTree; import com.sun.source.tree.DefaultCaseLabelTree; +import com.sun.source.tree.IdentifierTree; import com.sun.source.tree.ModuleTree; +import com.sun.source.tree.VarTypeTree; import com.sun.source.util.TreePathScanner; import com.sun.tools.javac.api.JavacTaskPool; import com.sun.tools.javac.api.JavacTaskPool.Worker; @@ -1070,8 +1072,8 @@ public class JavacParserTest extends TestCase { VariableTree stmt2 = (VariableTree) method.getBody().getStatements().get(1); Tree v1Type = stmt1.getType(); Tree v2Type = stmt2.getType(); - assertEquals("Implicit type for v1 is not correct: ", Kind.PRIMITIVE_TYPE, v1Type.getKind()); - assertEquals("Implicit type for v2 is not correct: ", Kind.PRIMITIVE_TYPE, v2Type.getKind()); + assertEquals("Implicit type for v1 is not correct: ", Kind.VAR_TYPE, v1Type.getKind()); + assertEquals("Implicit type for v2 is not correct: ", Kind.VAR_TYPE, v2Type.getKind()); } @Test @@ -3151,6 +3153,37 @@ public class JavacParserTest extends TestCase { codes); } + @Test + void testVarPositions() throws IOException { + String code = """ + public class Test { + void t() { + var v = + } + } + """; + DiagnosticCollector coll = + new DiagnosticCollector<>(); + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, coll, + null, + null, Arrays.asList(new MyFileObject(code))); + Trees trees = Trees.instance(ct); + SourcePositions sp = trees.getSourcePositions(); + CompilationUnitTree cut = ct.parse().iterator().next(); + new TreeScanner() { + @Override + public Void visitVarType(VarTypeTree node, Void p) { + long start = sp.getStartPosition(cut, node); + long end = sp.getEndPosition(cut, node); + String text = code.substring((int) start, (int) end); + assertEquals("var start pos", + "var", + text); + return null; + } + }; + } + void run(String[] args) throws Exception { int passed = 0, failed = 0; final Pattern p = (args != null && args.length > 0) diff --git a/test/langtools/tools/javac/patterns/BindingPatternVarTypeModel.java b/test/langtools/tools/javac/patterns/BindingPatternVarTypeModel.java index e63cbeb2008..01d742eb9e3 100644 --- a/test/langtools/tools/javac/patterns/BindingPatternVarTypeModel.java +++ b/test/langtools/tools/javac/patterns/BindingPatternVarTypeModel.java @@ -83,7 +83,7 @@ public class BindingPatternVarTypeModel { new TreeScanner() { @Override public Void visitBindingPattern(BindingPatternTree node, Void p) { - if (node.getVariable().getType().getKind() != Tree.Kind.PRIMITIVE_TYPE) { + if (node.getVariable().getType().getKind() != Tree.Kind.VAR_TYPE) { throw new AssertionError("Unexpected type for var: " + node.getVariable().getType().getKind() + ":" + node.getVariable().getType()); diff --git a/test/langtools/tools/javac/patterns/BreakAndLoops.java b/test/langtools/tools/javac/patterns/BreakAndLoops.java index 31ad8908f53..777d5ae4f42 100644 --- a/test/langtools/tools/javac/patterns/BreakAndLoops.java +++ b/test/langtools/tools/javac/patterns/BreakAndLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -237,4 +237,4 @@ public class BreakAndLoops extends ComboInstance { return code; } } -} \ No newline at end of file +} diff --git a/test/langtools/tools/javac/patterns/InstanceOfModelTest.java b/test/langtools/tools/javac/patterns/InstanceOfModelTest.java index b756c9263bd..288abec9659 100644 --- a/test/langtools/tools/javac/patterns/InstanceOfModelTest.java +++ b/test/langtools/tools/javac/patterns/InstanceOfModelTest.java @@ -79,7 +79,7 @@ public class InstanceOfModelTest { List expectedInstanceOf = List.of( "null:R", "R r:R", - "R(int v):null" + "R(var v):null" ); if (!Objects.equals(expectedInstanceOf, instanceOf)) { diff --git a/test/langtools/tools/javac/platform/createsymbols/CreateSymbolsReproducibleTest.java b/test/langtools/tools/javac/platform/createsymbols/CreateSymbolsReproducibleTest.java index ee3bb8c897d..334db17fe39 100644 --- a/test/langtools/tools/javac/platform/createsymbols/CreateSymbolsReproducibleTest.java +++ b/test/langtools/tools/javac/platform/createsymbols/CreateSymbolsReproducibleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,6 +41,7 @@ import org.junit.jupiter.api.Test; * @summary verifies that the ct.sym file created by build.tools.symbolgenerator.CreateSymbols * is reproducible * @library /test/lib + * @requires os.arch != "s390x" * @modules java.compiler * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.jvm diff --git a/test/langtools/tools/javac/preview/PreviewAutoSuppress.java b/test/langtools/tools/javac/preview/PreviewAutoSuppress.java index 058ccdf0a2a..f2096aff648 100644 --- a/test/langtools/tools/javac/preview/PreviewAutoSuppress.java +++ b/test/langtools/tools/javac/preview/PreviewAutoSuppress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, 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 @@ -44,6 +44,8 @@ import java.nio.file.Paths; import java.util.List; public class PreviewAutoSuppress extends TestRunner { + // Major version number (e.g. '27'). + private static final String FEATURE_VERSION = String.valueOf(Runtime.version().feature()); protected ToolBox tb; @@ -83,7 +85,7 @@ public class PreviewAutoSuppress extends TestRunner { List log = new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) .options("--enable-preview", - "-source", String.valueOf(Runtime.version().feature()), + "-source", FEATURE_VERSION, "-Xlint:preview", "-XDforcePreview", "-XDrawDiagnostics") @@ -182,7 +184,7 @@ public class PreviewAutoSuppress extends TestRunner { "--add-exports", "java.base/preview.api=ALL-UNNAMED", "--enable-preview", "-Xlint:preview", - "-source", String.valueOf(Runtime.version().feature()), + "-source", FEATURE_VERSION, "-XDrawDiagnostics") .files(tb.findJavaFiles(testSrc)) .run() diff --git a/test/langtools/tools/javac/processing/model/util/types/TestAsElement.java b/test/langtools/tools/javac/processing/model/util/types/TestAsElement.java index 6ac714752c3..cc82c5adddd 100644 --- a/test/langtools/tools/javac/processing/model/util/types/TestAsElement.java +++ b/test/langtools/tools/javac/processing/model/util/types/TestAsElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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,7 +23,7 @@ /* * @test - * @bug 8300857 + * @bug 8300857 8379156 * @summary Test Types.asElement in cases specified to return null * @library /tools/javac/lib * @build JavacTestingAbstractProcessor TestAsElement @@ -55,18 +55,23 @@ public class TestAsElement extends JavacTestingAbstractProcessor { } private void testNullCases() { - // Test all primitive types + // Test all primitive types and arrays of primitive types for (TypeKind typeKind : TypeKind.values()) { if (typeKind.isPrimitive() ) { - expectNullAsElement(typeUtils.getPrimitiveType(typeKind)); + var primType = typeUtils.getPrimitiveType(typeKind); + expectNullAsElement(primType); + expectNullAsElement(typeUtils.getArrayType(primType)); } } expectNullAsElement(typeUtils.getNoType(TypeKind.VOID)); expectNullAsElement(typeUtils.getNoType(TypeKind.NONE)); expectNullAsElement(typeUtils.getNullType()); - Element objectElement = eltUtils.getTypeElement("java.lang.Object"); - expectNullAsElement(typeUtils.getWildcardType(objectElement.asType(), null)); + Element objectElement = eltUtils.getTypeElement("java.lang.Object"); + TypeMirror objectType = objectElement.asType(); + expectNullAsElement(typeUtils.getWildcardType(objectType, null)); + // check Object[] + expectNullAsElement(typeUtils.getArrayType(objectType)); // Loop over the ExecutableTypes for Object's methods for(var methodElt : ElementFilter.methodsIn(objectElement.getEnclosedElements())) { diff --git a/test/langtools/tools/javac/records/RecordCompilationTests.java b/test/langtools/tools/javac/records/RecordCompilationTests.java index a8384ba4692..48b5cdd8588 100644 --- a/test/langtools/tools/javac/records/RecordCompilationTests.java +++ b/test/langtools/tools/javac/records/RecordCompilationTests.java @@ -2169,4 +2169,56 @@ class RecordCompilationTests extends CompilationTestCase { """ ); } + + @Test + void testDeprecatedJavadoc() { + String[] previousOptions = getCompileOptions(); + try { + setCompileOptions(new String[] {"-Xlint:deprecation"}); + assertOKWithWarning("compiler.warn.has.been.deprecated", + """ + record R( + /** + * @deprecated + */ + @Deprecated + int i + ) {} + class Client { + R r; + int j = r.i(); + } + """ + ); + assertOKWithWarning("compiler.warn.has.been.deprecated", + """ + record R( + @Deprecated + int i + ) {} + class Client { + R r; + int j = r.i(); + } + """ + ); + // javadoc tag only has no effect + assertOK( + """ + record R( + /** + * @deprecated + */ + int i + ) {} + class Client { + R r; + int j = r.i(); + } + """ + ); + } finally { + setCompileOptions(previousOptions); + } + } } diff --git a/test/langtools/tools/javac/records/RecordReading.java b/test/langtools/tools/javac/records/RecordReading.java index 6133a04fca9..e57a7f77ceb 100644 --- a/test/langtools/tools/javac/records/RecordReading.java +++ b/test/langtools/tools/javac/records/RecordReading.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ * @run main RecordReading */ - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; diff --git a/test/langtools/tools/javac/recovery/ClassBlockExits.java b/test/langtools/tools/javac/recovery/ClassBlockExits.java index b1c54b456ae..3ac04cbe991 100644 --- a/test/langtools/tools/javac/recovery/ClassBlockExits.java +++ b/test/langtools/tools/javac/recovery/ClassBlockExits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -138,4 +138,4 @@ public class ClassBlockExits extends ComboInstance { return code; } } -} \ No newline at end of file +} diff --git a/test/langtools/tools/javac/tree/VarTree.java b/test/langtools/tools/javac/tree/VarTree.java index 6efd080bd4f..70caf66862e 100644 --- a/test/langtools/tools/javac/tree/VarTree.java +++ b/test/langtools/tools/javac/tree/VarTree.java @@ -52,27 +52,27 @@ public class VarTree { public static void main(String... args) throws Exception { VarTree test = new VarTree(); test.run("|var testVar = 0;| ", - "int testVar = 0"); + "var testVar = 0"); test.run("|var testVar = 0;| undef undef;", - "int testVar = 0"); + "var testVar = 0"); test.run("|final var testVar = 0;| ", - "final int testVar = 0"); + "final var testVar = 0"); test.run("for (|var testVar| : java.util.Arrays.asList(0, 1)) {}", - "java.lang.Integer testVar"); + "var testVar"); test.run("for (|final var testVar| : java.util.Arrays.asList(0, 1)) {}", - "final java.lang.Integer testVar"); + "final var testVar"); test.run("java.util.function.Consumer c = |testVar| -> {};", - "java.lang.String testVar"); + "/*missing*/ testVar"); //TODO: is the /*missing*/ here ideal? test.run("java.util.function.Consumer c = (|testVar|) -> {};", - "java.lang.String testVar"); + "/*missing*/ testVar"); //TODO: is the /*missing*/ here ideal? test.run("java.util.function.Consumer c = (|var testVar|) -> {};", - "java.lang.String testVar"); + "var testVar"); test.run("java.util.function.Consumer c = (|final var testVar|) -> {};", - "final java.lang.String testVar"); + "final var testVar"); test.run("record Rec(int x) { }; switch (null) { case Rec(|var testVar|) -> {} default -> {} };", - "int testVar"); + "var testVar"); test.run("record Rec(int x) { }; switch (null) { case Rec(|final var testVar|) -> {} default -> {} };", - "final int testVar"); + "final var testVar"); } void run(String code, String expected) throws IOException { @@ -136,11 +136,13 @@ public class VarTree { throw new AssertionError("Unexpected span: " + snip); } - int typeStart = (int) trees.getSourcePositions().getStartPosition(cut, node.getType()); - int typeEnd = (int) trees.getSourcePositions().getEndPosition(cut, node.getType()); + if (node.getType() != null) { + int typeStart = (int) trees.getSourcePositions().getStartPosition(cut, node.getType()); + int typeEnd = (int) trees.getSourcePositions().getEndPosition(cut, node.getType()); - if (typeStart != (-1) && typeEnd != (-1)) { - throw new AssertionError("Unexpected type position: " + typeStart + ", " + typeEnd); + if (typeStart + 3 != typeEnd) { + throw new AssertionError("Unexpected type position: " + typeStart + ", " + typeEnd); + } } found[0] = true; diff --git a/test/langtools/tools/javac/tree/VarWarnPosition.java b/test/langtools/tools/javac/tree/VarWarnPosition.java index f1d5f4346d0..5cdfa41d6ef 100644 --- a/test/langtools/tools/javac/tree/VarWarnPosition.java +++ b/test/langtools/tools/javac/tree/VarWarnPosition.java @@ -25,6 +25,9 @@ public class VarWarnPosition { // Test 4 Consumer c3 = (final var d) -> { }; + + // Test 5 + var d = deprecatedList.get(0); } } diff --git a/test/langtools/tools/javac/tree/VarWarnPosition.out b/test/langtools/tools/javac/tree/VarWarnPosition.out index 87a4ca3a1fd..0bd92acd035 100644 --- a/test/langtools/tools/javac/tree/VarWarnPosition.out +++ b/test/langtools/tools/javac/tree/VarWarnPosition.out @@ -1,8 +1,4 @@ -VarWarnPosition.java:18:14: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package VarWarnPosition.java:21:18: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package -VarWarnPosition.java:21:28: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package VarWarnPosition.java:24:18: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package -VarWarnPosition.java:24:30: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package VarWarnPosition.java:27:18: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package -VarWarnPosition.java:27:36: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package -7 warnings +3 warnings \ No newline at end of file diff --git a/test/langtools/tools/javac/types/IsFunctionalInterfaceTest.java b/test/langtools/tools/javac/types/IsFunctionalInterfaceTest.java new file mode 100644 index 00000000000..a4fe4e470c7 --- /dev/null +++ b/test/langtools/tools/javac/types/IsFunctionalInterfaceTest.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2026, 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 8378906 + * @summary Check that Types.isFunctionalInterface() works for interface methods + * with ACC_PUBLIC, ACC_BRIDGE, ACC_ABSTRACT, ACC_SYNTHETIC flags. + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run junit IsFunctionalInterfaceTest + */ + +import java.lang.classfile.ClassFile; +import java.lang.classfile.MethodElement; +import java.lang.classfile.MethodModel; +import java.lang.reflect.AccessFlag; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; + +import toolbox.JavacTask; +import toolbox.ToolBox; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import toolbox.Task; + +public class IsFunctionalInterfaceTest { + + Path base; + ToolBox tb = new ToolBox(); + + @Test + void test8378906() throws Exception { + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + new JavacTask(tb) + .options("-d", classes.toString()) + .sources(""" + interface I { + @Deprecated + Object test(); + } + + final class Sub implements I { + public static final Sub INSTANCE = new Sub(); + public Object test() { return null; } + } + + class Util { + public static boolean foo(I a) { return true; } + public static boolean foo(Sub a) { return false; } + } + """) + .run() + .writeAll(); + + Path path = classes.resolve("I.class"); + ClassFile classFile = ClassFile.of(); + byte[] bytes = classFile.transformClass(classFile.parse(path), + (classBuilder, classElement) -> { + if (classElement instanceof MethodModel mm + && mm.methodName().equalsString("test")) { + int flags = mm.flags().flagsMask() | AccessFlag.BRIDGE.mask() | AccessFlag.SYNTHETIC.mask(); + classBuilder.withMethod(mm.methodName(), mm.methodType(), flags, (methodBuilder) -> { + mm.attributes().forEach(attr -> { + if (attr instanceof MethodElement me) { + methodBuilder.with(me); + } + }); + }); + } else { + classBuilder.with(classElement); + } + }); + Files.write(path, bytes); + + new JavacTask(tb) + .options("-d", classes.toString(), "-cp", classes.toString()) + .sources(""" + public class Test { + public void main() { Util.foo(Sub.INSTANCE); } + } + """) + .run() + .writeAll(); + + List out1 = new JavacTask(tb) + .options("-d", classes.toString(), "-cp", classes.toString(), "-XDrawDiagnostics", "-nowarn") + .sources(""" + public class Test { + public void main() { t(() -> null); } + private void t(I i) {} + } + """) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + tb.checkEqual(out1, List.of( + "Test.java:2:25: compiler.err.cant.apply.symbol: kindname.method, t, I, @27, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: I, (compiler.misc.no.abstracts: kindname.interface, I)))", + "1 error")); + + List out2 = new JavacTask(tb) + .options("-d", classes.toString(), "-cp", classes.toString(), "-XDrawDiagnostics", "-nowarn") + .sources(""" + public class Impl implements I { + } + """) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + tb.checkEqual(out2, List.of( + "Impl.java:1:8: compiler.err.does.not.override.abstract: Impl, test(), I", + "1 error")); + + new JavacTask(tb) + .options("-d", classes.toString(), "-cp", classes.toString()) + .sources(""" + public class Impl implements I { + public Object test() { return null; } + } + """) + .run() + .writeAll(); + } + + @BeforeEach + public void setUp(TestInfo info) { + base = Paths.get(".") + .resolve(info.getTestMethod() + .orElseThrow() + .getName()); + } +} diff --git a/test/langtools/tools/javap/T4975569.java b/test/langtools/tools/javap/T4975569.java index c43598b41db..ce75ba84586 100644 --- a/test/langtools/tools/javap/T4975569.java +++ b/test/langtools/tools/javap/T4975569.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, 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 @@ -105,4 +105,3 @@ public class T4975569 { protected class Prot { } private class Priv { int i; } } - diff --git a/test/lib-test/TEST.ROOT b/test/lib-test/TEST.ROOT index f23d38c1e66..33c9a9c2a43 100644 --- a/test/lib-test/TEST.ROOT +++ b/test/lib-test/TEST.ROOT @@ -31,6 +31,9 @@ keys=randomness # Minimum jtreg version requiredVersion=8.2.1+1 +# Prevent TestNG-based tests under this root, use @run junit actions instead +disallowedActions=testng + # Allow querying of various System properties in @requires clauses requires.extraPropDefns = ../jtreg-ext/requires/VMProps.java requires.extraPropDefns.bootlibs = ../lib/jdk/test/whitebox diff --git a/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java b/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java index 8047b81c1e6..801874f38c2 100644 --- a/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java +++ b/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java @@ -50,7 +50,7 @@ public class TestMutuallyExclusivePlatformPredicates { OS("isAix", "isLinux", "isOSX", "isWindows"), VM_TYPE("isClient", "isServer", "isMinimal", "isZero", "isEmbedded"), MODE("isInt", "isMixed", "isComp"), - IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isMusl", + IGNORED("isDebugBuild", "isFastDebugBuild", "isMusl", "isStatic", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported", "areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported", "isHardenedOSX", "hasOSXPlistEntries", "isOracleLinux7", "isOnWayland"); diff --git a/test/lib-test/jdk/test/lib/jittester/MethodTemplateTest.java b/test/lib-test/jdk/test/lib/jittester/MethodTemplateTest.java index 3cee24b4684..69751bc281c 100644 --- a/test/lib-test/jdk/test/lib/jittester/MethodTemplateTest.java +++ b/test/lib-test/jdk/test/lib/jittester/MethodTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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,8 @@ package jdk.test.lib.jittester; import java.lang.reflect.Executable; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /* * @test @@ -35,7 +35,7 @@ import static org.testng.Assert.*; * @library /test/lib * /test/hotspot/jtreg/testlibrary/jittester/src * - * @run testng jdk.test.lib.jittester.MethodTemplateTest + * @run junit jdk.test.lib.jittester.MethodTemplateTest */ public class MethodTemplateTest { diff --git a/test/lib-test/jdk/test/whitebox/vm_flags/Uint64Test.java b/test/lib-test/jdk/test/whitebox/vm_flags/Uint64Test.java index 64dd7544ebb..bf8bf0104ac 100644 --- a/test/lib-test/jdk/test/whitebox/vm_flags/Uint64Test.java +++ b/test/lib-test/jdk/test/whitebox/vm_flags/Uint64Test.java @@ -35,7 +35,7 @@ */ public class Uint64Test { - private static final String FLAG_NAME = "MaxRAM"; + private static final String FLAG_NAME = "StringDeduplicationHashSeed"; private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE, -1L, Long.MAX_VALUE, Long.MIN_VALUE}; diff --git a/test/lib/RedefineClassHelper.java b/test/lib/RedefineClassHelper.java index ce27fb33f44..064778b3a2a 100644 --- a/test/lib/RedefineClassHelper.java +++ b/test/lib/RedefineClassHelper.java @@ -107,7 +107,7 @@ public class RedefineClassHelper { * Main method to be invoked before test to create the redefineagent.jar */ public static void main(String[] args) throws Exception { - String manifest = "Premain-Class: RedefineClassHelper\nCan-Redefine-Classes: true\n"; + String manifest = "Premain-Class: RedefineClassHelper\nCan-Redefine-Classes: true\nCan-Retransform-Classes: true\n"; ClassFileInstaller.writeJar("redefineagent.jar", ClassFileInstaller.Manifest.fromString(manifest), "RedefineClassHelper"); } } diff --git a/test/lib/jdk/test/lib/Convert.java b/test/lib/jdk/test/lib/Convert.java index 7ed1112c94d..2738e04c2f0 100644 --- a/test/lib/jdk/test/lib/Convert.java +++ b/test/lib/jdk/test/lib/Convert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,26 +41,6 @@ public class Convert { return result; } - /* - * Convert a hexadecimal string to the corresponding little-ending number - * as a BigInteger. The clearHighBit argument determines whether the most - * significant bit of the highest byte should be set to 0 in the result. - */ - public static - BigInteger hexStringToBigInteger(boolean clearHighBit, String str) { - BigInteger result = BigInteger.ZERO; - for (int i = 0; i < str.length() / 2; i++) { - int curVal = Character.digit(str.charAt(2 * i), 16); - curVal <<= 4; - curVal += Character.digit(str.charAt(2 * i + 1), 16); - if (clearHighBit && i == str.length() / 2 - 1) { - curVal &= 0x7F; - } - result = result.add(BigInteger.valueOf(curVal).shiftLeft(8 * i)); - } - return result; - } - private static EdECPoint byteArrayToEdPoint(byte[] arr) { byte msb = arr[arr.length - 1]; boolean xOdd = (msb & 0x80) != 0; diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 75fdef048bc..892de2338e3 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; import static java.util.Locale.ROOT; public class Platform { @@ -74,10 +75,6 @@ public class Platform { return vmInfo.contains("static"); } - public static boolean isEmulatedClient() { - return vmInfo.contains(" emulated-client"); - } - public static boolean isTieredSupported() { return (compiler != null) && compiler.contains("Tiered Compilers"); } @@ -188,14 +185,17 @@ public class Platform { } public static boolean isMusl() { - try { - ProcessBuilder pb = new ProcessBuilder("ldd", "--version"); + var lddPath = Stream.of("/bin/ldd", "/usr/bin/ldd").filter(p -> Files.exists(Path.of(p))).findFirst(); + if (lddPath.isPresent()) { + ProcessBuilder pb = new ProcessBuilder(lddPath.get(), "--version"); pb.redirectErrorStream(true); - Process p = pb.start(); - BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); - String l = b.readLine(); - if (l != null && l.contains("musl")) { return true; } - } catch(Exception e) { + try (Process p = pb.start()) { + BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); + String l = b.readLine(); + return (l != null && l.contains("musl")); + } catch (Exception e) { + e.printStackTrace(); + } } return false; } diff --git a/test/lib/jdk/test/lib/SA/SATestUtils.java b/test/lib/jdk/test/lib/SA/SATestUtils.java index 63f522b3d62..754ef4c40dd 100644 --- a/test/lib/jdk/test/lib/SA/SATestUtils.java +++ b/test/lib/jdk/test/lib/SA/SATestUtils.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.concurrent.TimeUnit; import java.util.List; +import java.util.NoSuchElementException; public class SATestUtils { /** @@ -332,8 +333,11 @@ public class SATestUtils { .get(); String dir = buildID.substring(0, 2); String file = buildID.substring(2); - debuginfoPath = Path.of("/usr/lib/debug/.build_id", dir, file + ".debug"); + debuginfoPath = Path.of("/usr/lib/debug/.build-id", dir, file + ".debug"); exists = Files.exists(debuginfoPath); + } catch (NoSuchElementException _) { + // return null if vDSO not found. + return null; } } return exists ? debuginfoPath.toString() : null; diff --git a/test/lib/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java index 38ad9ae5b0e..9a8395d7879 100644 --- a/test/lib/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -46,6 +46,7 @@ import java.util.UUID; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputBuffer; +import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.StreamPumper; import jdk.test.lib.util.CoreUtils; @@ -451,6 +452,7 @@ public class LingeredApp { long t1 = System.currentTimeMillis(); theApp.createLock(); try { + ProcessTools.checkDuplicateAgentOpts(jvmOpts); theApp.runAppExactJvmOpts(jvmOpts); theApp.waitAppReadyOrCrashed(); } catch (Exception ex) { diff --git a/test/lib/jdk/test/lib/cds/CDSAppTester.java b/test/lib/jdk/test/lib/cds/CDSAppTester.java index 18356dd8aa9..3eac8a35a37 100644 --- a/test/lib/jdk/test/lib/cds/CDSAppTester.java +++ b/test/lib/jdk/test/lib/cds/CDSAppTester.java @@ -480,11 +480,20 @@ abstract public class CDSAppTester { // See JEP 483 public void runAOTWorkflow(String... args) throws Exception { this.workflow = Workflow.AOT; - boolean oneStepTraining = true; // by default use onestep trainning + + // By default use twostep training -- tests are much easier to write this way, as + // the stdout/stderr of the training run is clearly separated from the assembly phase. + // + // Many older test cases written before JEP 514 were not aware of one step treaining + // and may not check the stdout/stderr correctly. + boolean oneStepTraining = false; if (System.getProperty("CDSAppTester.two.step.training") != null) { oneStepTraining = false; } + if (System.getProperty("CDSAppTester.one.step.training") != null) { + oneStepTraining = true; + } if (args.length > 1) { // Tests such as test/hotspot/jtreg/runtime/cds/appcds/aotCache/SpecialCacheNames.java diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index 13ac2e4e97a..1c51a693907 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -696,11 +696,16 @@ public class CDSTestUtils { System.out.println("[STDOUT]\n" + output.getStdout()); if (output.getExitValue() != 0 && output.getStdout().contains("A fatal error has been detected")) { - throw new RuntimeException("Hotspot crashed"); + throw new RuntimeException(getCrashMessage(output.getStdout())); } return output; } + static String getCrashMessage(String stdOut) { + int start = stdOut.indexOf("# A fatal error has been detected by the Java Runtime Environment:"); + int end = stdOut.indexOf(".log", start) + 4; + return stdOut.substring(start, end); + } private static void writeFile(File file, String content) throws Exception { FileOutputStream fos = new FileOutputStream(file); diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java index 8e28ea08365..48738d4a0da 100644 --- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java +++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, 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 @@ -107,7 +107,6 @@ public abstract class CommandLineOptionTest { List finalOptions = new ArrayList<>(); if (addTestVMOptions) { Collections.addAll(finalOptions, InputArguments.getVmInputArgs()); - Collections.addAll(finalOptions, Utils.getTestJavaOpts()); } Collections.addAll(finalOptions, options); finalOptions.add("-version"); @@ -202,10 +201,6 @@ public abstract class CommandLineOptionTest { if (!Platform.isStatic()) { finalOptions.add(CommandLineOptionTest.getVMTypeOption()); } - String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated(); - if (extraFlagForEmulated != null) { - finalOptions.add(extraFlagForEmulated); - } Collections.addAll(finalOptions, options); CommandLineOptionTest.verifyJVMStartup(expectedMessages, @@ -402,10 +397,6 @@ public abstract class CommandLineOptionTest { if (!Platform.isStatic()) { finalOptions.add(CommandLineOptionTest.getVMTypeOption()); } - String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated(); - if (extraFlagForEmulated != null) { - finalOptions.add(extraFlagForEmulated); - } Collections.addAll(finalOptions, additionalVMOpts); CommandLineOptionTest.verifyOptionValue(optionName, expectedValue, @@ -513,18 +504,6 @@ public abstract class CommandLineOptionTest { throw new RuntimeException("Unknown VM mode."); } - /** - * @return addtional VMoptions(Emulated related) required to start a new VM with the same type as current. - */ - private static String getVMTypeOptionForEmulated() { - if (Platform.isServer() && !Platform.isEmulatedClient()) { - return "-XX:-NeverActAsServerClassMachine"; - } else if (Platform.isEmulatedClient()) { - return "-XX:+NeverActAsServerClassMachine"; - } - return null; - } - private final BooleanSupplier predicate; /** diff --git a/test/lib/jdk/test/lib/json/JSONValue.java b/test/lib/jdk/test/lib/json/JSONValue.java index f89d13b3bba..72ed2fd917c 100644 --- a/test/lib/jdk/test/lib/json/JSONValue.java +++ b/test/lib/jdk/test/lib/json/JSONValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Optional; public interface JSONValue { @@ -88,9 +89,6 @@ public interface JSONValue { @Override public String toString() { - if (value == null) { - return "null"; - } var builder = new StringBuilder(); builder.append("\""); @@ -172,6 +170,56 @@ public interface JSONValue { public Iterator iterator() { return values.iterator(); } + + @Override + public List elements() { + return List.copyOf(values); + } + } + + public final class JSONBoolean implements JSONValue { + private static JSONBoolean TRUE = new JSONBoolean(true); + private static JSONBoolean FALSE = new JSONBoolean(false); + + private final boolean value; + + private JSONBoolean(boolean value) { + this.value = value; + } + + @Override + public boolean asBoolean() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static JSONBoolean of(boolean value) { + return value ? TRUE : FALSE; + } + } + + public final class JSONNull implements JSONValue { + private static JSONNull NULL = new JSONNull(); + + private JSONNull() {} + + @Override + public Optional valueOrNull() { + return Optional.empty(); + } + + @Override + public String toString() { + return "null"; + } + + public static JSONNull of() { + return NULL; + } } class JSONParser { @@ -181,8 +229,8 @@ public interface JSONValue { JSONParser() { } - private IllegalStateException failure(String message) { - return new IllegalStateException(String.format("[%d]: %s : %s", pos, message, input)); + private IllegalArgumentException failure(String message) { + return new IllegalArgumentException(String.format("[%d]: %s : %s", pos, message, input)); } private char current() { @@ -220,13 +268,13 @@ public interface JSONValue { } } - private JSONString parseBoolean() { + private JSONBoolean parseBoolean() { if (current() == 't') { expect('r'); expect('u'); expect('e'); advance(); - return new JSONString("true"); + return JSONBoolean.of(true); } if (current() == 'f') { @@ -235,7 +283,7 @@ public interface JSONValue { expect('s'); expect('e'); advance(); - return new JSONString("false"); + return JSONBoolean.of(false); } throw failure("a boolean can only be 'true' or 'false'"); } @@ -400,12 +448,12 @@ public interface JSONValue { return new JSONArray(list); } - public JSONString parseNull() { + public JSONNull parseNull() { expect('u'); expect('l'); expect('l'); advance(); - return new JSONString(null); + return JSONNull.of(); } public JSONObject parseObject() { @@ -531,22 +579,38 @@ public interface JSONValue { } default int size() { - throw new IllegalStateException("Size operation unsupported"); + throw new UnsupportedOperationException("Size operation unsupported"); + } + + default List elements() { + throw new UnsupportedOperationException("Unsupported conversion to array"); } default String asString() { - throw new IllegalStateException("Unsupported conversion to String"); + throw new UnsupportedOperationException("Unsupported conversion to String"); } default JSONArray asArray() { - throw new IllegalStateException("Unsupported conversion to array"); + throw new UnsupportedOperationException("Unsupported conversion to array"); } default JSONObject asObject() { - throw new IllegalStateException("Unsupported conversion to object"); + throw new UnsupportedOperationException("Unsupported conversion to object"); + } + + default boolean asBoolean() { + throw new UnsupportedOperationException("Unsupported conversion to boolean"); } default JSONValue get(String field) { return asObject().get(field); } + + default Optional getOrAbsent(String field) { + return Optional.ofNullable(get(field)); + } + + default Optional valueOrNull() { + return Optional.of(this); + } } diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java index d8b3f470260..553e13b28ff 100644 --- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -56,8 +56,23 @@ public final class OutputAnalyzer { * @throws IOException If an I/O error occurs. */ public OutputAnalyzer(Process process, Charset cs) throws IOException { - buffer = OutputBuffer.of(process, cs); + this(process, cs, true); } + + /** + * Create an OutputAnalyzer, a utility class for verifying output and exit + * value from a Process, with a configurable verbosity level. + * + * @param process Process to analyze + * @param cs The charset used to convert stdout/stderr from bytes to chars + * or null for the default charset. + * @param verbose Set to false to limit logging to stdout. + * @throws IOException If an I/O error occurs. + */ + public OutputAnalyzer(Process process, Charset cs, boolean verbose) throws IOException { + buffer = OutputBuffer.of(process, cs, verbose); + } + /** * Create an OutputAnalyzer, a utility class for verifying output and exit * value from a Process @@ -66,7 +81,19 @@ public final class OutputAnalyzer { * @throws IOException If an I/O error occurs. */ public OutputAnalyzer(Process process) throws IOException { - buffer = OutputBuffer.of(process); + this(process, true); + } + + /** + * Create an OutputAnalyzer, a utility class for verifying output and exit + * value from a Process, with a configurable verbosity level. + * + * @param process Process to analyze + * @param verbose Set to false to limit logging to stdout. + * @throws IOException If an I/O error occurs. + */ + public OutputAnalyzer(Process process, boolean verbose) throws IOException { + buffer = OutputBuffer.of(process, verbose); } /** diff --git a/test/lib/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java index 0390535bf89..57e00aa73c7 100644 --- a/test/lib/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -89,12 +89,20 @@ public interface OutputBuffer { */ public long pid(); + public static OutputBuffer of(Process p, boolean quiet) { + return of(p, null, quiet); + } + public static OutputBuffer of(Process p, Charset cs) { - return new LazyOutputBuffer(p, cs); + return of(p, cs, false); } public static OutputBuffer of(Process p) { - return new LazyOutputBuffer(p, null); + return of(p, null, false); + } + + public static OutputBuffer of(Process p, Charset cs, boolean quiet) { + return new LazyOutputBuffer(p, cs, quiet); } public static OutputBuffer of(String stdout, String stderr, int exitValue) { @@ -130,19 +138,23 @@ public interface OutputBuffer { } } + private final boolean verbose; private final StreamTask outTask; private final StreamTask errTask; private final Process p; private volatile Integer exitValue; // null implies we don't yet know private final void logProgress(String state) { + if (verbose) { System.out.println("[" + Instant.now().toString() + "] " + state - + " for process " + p.pid()); + + " for process " + p.pid()); System.out.flush(); + } } - private LazyOutputBuffer(Process p, Charset cs) { + private LazyOutputBuffer(Process p, Charset cs, boolean verbose) { this.p = p; + this.verbose = verbose; logProgress("Gathering output"); outTask = new StreamTask(p.getInputStream(), cs); errTask = new StreamTask(p.getErrorStream(), cs); diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index 7d03268cac4..e7dd20c6286 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,8 +43,10 @@ import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; @@ -448,7 +450,7 @@ public final class ProcessTools { private static ProcessBuilder createJavaProcessBuilder(String... command) { String javapath = JDKToolFinder.getJDKTool("java"); - ArrayList args = new ArrayList<>(); + List args = new ArrayList<>(); args.add(javapath); String noCPString = System.getProperty("test.noclasspath", "false"); @@ -465,6 +467,8 @@ public final class ProcessTools { Collections.addAll(args, command); } + checkDuplicateAgentOpts(args); + // Reporting StringBuilder cmdLine = new StringBuilder(); for (String cmd : args) @@ -479,6 +483,30 @@ public final class ProcessTools { return pb; } + // 8377729: Check for duplicate VM JVMTI agent options, as it may + // cause test to fail + public static void checkDuplicateAgentOpts(List args) { + if (args == null || args.isEmpty()) { + return; + } + + Set seen = new HashSet<>(); + List dupArgs = args.stream() + .filter(arg -> (arg.startsWith("-agent") + || arg.startsWith("-javaagent:")) + && !seen.add(arg)) + .collect(Collectors.toList()); + + if (!dupArgs.isEmpty()) { + System.err.println("WARNING: Duplicate JVMTI agent options may" + + " cause test to fail:\n" + dupArgs); + } + } + + public static void checkDuplicateAgentOpts(String[] args) { + checkDuplicateAgentOpts(Arrays.asList(args)); + } + private static void printStack(Thread t, StackTraceElement[] stack) { System.out.println("\t" + t + " stack: (length = " + stack.length + ")"); if (t != null) { @@ -547,7 +575,7 @@ public final class ProcessTools { * "test.vm.opts" and "test.java.opts" and this method will * not do that. * - *

    If you still chose to use + *

    If you still choose to use * createLimitedTestJavaProcessBuilder() you should probably use * it in combination with @requires vm.flagless JTREG * anotation as to not waste energy and test resources. @@ -581,7 +609,7 @@ public final class ProcessTools { * "test.vm.opts" and "test.java.opts" and this method will * not do that. * - *

    If you still chose to use + *

    If you still choose to use * createLimitedTestJavaProcessBuilder() you should probably use * it in combination with @requires vm.flagless JTREG * anotation as to not waste energy and test resources. diff --git a/test/lib/jdk/test/lib/threaddump/ThreadDump.java b/test/lib/jdk/test/lib/threaddump/ThreadDump.java index ca728e625fc..972d46675f4 100644 --- a/test/lib/jdk/test/lib/threaddump/ThreadDump.java +++ b/test/lib/jdk/test/lib/threaddump/ThreadDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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,13 +32,17 @@ import java.util.Map; import java.util.Optional; import java.util.OptionalLong; import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.test.lib.json.JSONValue; /** * Represents a thread dump that is obtained by parsing JSON text. A thread dump in JSON * format is generated with the {@code com.sun.management.HotSpotDiagnosticMXBean} API or - * using {@code jcmd Thread.dump_to_file -format=json }. + * using {@code jcmd Thread.dump_to_file -format=json }. The thread dump + * format is documented in {@code + * src/jdk.management/share/classes/com/sun/management/doc-files/threadDump.schema.json}. * *

    The following is an example thread dump that is parsed by this class. Many of the * objects are collapsed to reduce the size. @@ -127,6 +131,20 @@ public final class ThreadDump { this.threadDumpObj = threadDumpObj; } + /** + * Assert that a JSONValue is a JSONString and parse the string as an int. + */ + private static int parseStringAsInt(JSONValue valueObj) { + return Integer.parseInt(valueObj.asString()); + } + + /** + * Assert that a JSONValue is a JSONString and parse the string as a long. + */ + private static long parseStringAsLong(JSONValue valueObj) { + return Long.parseLong(valueObj.asString()); + } + /** * Represents an element in the threadDump/threadContainers array. */ @@ -149,14 +167,6 @@ public final class ThreadDump { children.add(container); } - /** - * Returns the value of a property of this thread container, as a string. - */ - private String getStringProperty(String propertyName) { - JSONValue value = containerObj.get(propertyName); - return (value != null) ? value.asString() : null; - } - /** * Returns the thread container name. */ @@ -168,10 +178,10 @@ public final class ThreadDump { * Return the thread identifier of the owner or empty OptionalLong if not owned. */ public OptionalLong owner() { - String owner = getStringProperty("owner"); - return (owner != null) - ? OptionalLong.of(Long.parseLong(owner)) - : OptionalLong.empty(); + return containerObj.get("owner") // string or null + .valueOrNull() + .map(v -> OptionalLong.of(parseStringAsLong(v))) + .orElse(OptionalLong.empty()); } /** @@ -192,12 +202,10 @@ public final class ThreadDump { * Returns a stream of {@code ThreadInfo} objects for the threads in this container. */ public Stream threads() { - JSONValue.JSONArray threadsObj = containerObj.get("threads").asArray(); - Set threadInfos = new HashSet<>(); - for (JSONValue threadObj : threadsObj) { - threadInfos.add(new ThreadInfo(threadObj)); - } - return threadInfos.stream(); + return containerObj.get("threads") + .elements() + .stream() + .map(ThreadInfo::new); } /** @@ -237,29 +245,10 @@ public final class ThreadDump { private final JSONValue threadObj; ThreadInfo(JSONValue threadObj) { - this.tid = Long.parseLong(threadObj.get("tid").asString()); + this.tid = parseStringAsLong(threadObj.get("tid")); this.threadObj = threadObj; } - /** - * Returns the value of a property of this thread object, as a string. - */ - private String getStringProperty(String propertyName) { - JSONValue value = threadObj.get(propertyName); - return (value != null) ? value.asString() : null; - } - - /** - * Returns the value of a property of an object in this thread object, as a string. - */ - private String getStringProperty(String objectName, String propertyName) { - if (threadObj.get(objectName) instanceof JSONValue.JSONObject obj - && obj.get(propertyName) instanceof JSONValue value) { - return value.asString(); - } - return null; - } - /** * Returns the thread identifier. */ @@ -271,83 +260,92 @@ public final class ThreadDump { * Returns the thread name. */ public String name() { - return getStringProperty("name"); + return threadObj.get("name").asString(); } /** * Returns the thread state. */ public String state() { - return getStringProperty("state"); + return threadObj.get("state").asString(); } /** * Returns true if virtual thread. */ public boolean isVirtual() { - String s = getStringProperty("virtual"); - return (s != null) ? Boolean.parseBoolean(s) : false; + return threadObj.getOrAbsent("virtual") + .map(JSONValue::asBoolean) + .orElse(false); } /** - * Returns the thread's parkBlocker. + * Returns the thread's parkBlocker or null. */ public String parkBlocker() { - return getStringProperty("parkBlocker", "object"); + return threadObj.getOrAbsent("parkBlocker") + .map(v -> v.get("object").asString()) + .orElse(null); } /** * Returns the owner of the parkBlocker if the parkBlocker is an AbstractOwnableSynchronizer. */ public OptionalLong parkBlockerOwner() { - String owner = getStringProperty("parkBlocker", "owner"); - return (owner != null) - ? OptionalLong.of(Long.parseLong(owner)) - : OptionalLong.empty(); + return threadObj.getOrAbsent("parkBlocker") + .map(v -> OptionalLong.of(parseStringAsLong(v.get("owner")))) + .orElse(OptionalLong.empty()); } /** - * Returns the object that the thread is blocked entering its monitor. + * Returns the object that the thread is blocked entering its monitor or null. */ public String blockedOn() { - return getStringProperty("blockedOn"); + return threadObj.getOrAbsent("blockedOn") + .map(JSONValue::asString) + .orElse(null); } /** - * Return the object that is the therad is waiting on with Object.wait. + * Return the object that is the thread is waiting on with Object.wait or null. */ public String waitingOn() { - return getStringProperty("waitingOn"); + return threadObj.getOrAbsent("waitingOn") + .map(JSONValue::asString) + .orElse(null); } /** * Returns the thread stack. */ public Stream stack() { - JSONValue.JSONArray stackObj = threadObj.get("stack").asArray(); - List stack = new ArrayList<>(); - for (JSONValue steObject : stackObj) { - stack.add(steObject.asString()); - } - return stack.stream(); + return threadObj.get("stack") + .elements() + .stream() + .map(JSONValue::asString); } /** * Return a map of monitors owned. */ public Map> ownedMonitors() { - Map> ownedMonitors = new HashMap<>(); - JSONValue monitorsOwnedObj = threadObj.get("monitorsOwned"); - if (monitorsOwnedObj != null) { - for (JSONValue obj : monitorsOwnedObj.asArray()) { - int depth = Integer.parseInt(obj.get("depth").asString()); - for (JSONValue lock : obj.get("locks").asArray()) { - ownedMonitors.computeIfAbsent(depth, _ -> new ArrayList<>()) - .add(lock.asString()); - } - } - } - return ownedMonitors; + Map> result = new HashMap<>(); + threadObj.getOrAbsent("monitorsOwned") + .map(JSONValue::elements) + .orElse(List.of()) + .forEach(e -> { + int depth = parseStringAsInt(e.get("depth")); + List locks = e.get("locks") + .elements() + .stream() + .map(v -> v.valueOrNull() // string or null + .map(JSONValue::asString) + .orElse(null)) + .toList(); + result.computeIfAbsent(depth, _ -> new ArrayList<>()).addAll(locks); + }); + + return result; } /** @@ -355,10 +353,9 @@ public final class ThreadDump { * its carrier. */ public OptionalLong carrier() { - String s = getStringProperty("carrier"); - return (s != null) - ? OptionalLong.of(Long.parseLong(s)) - : OptionalLong.empty(); + return threadObj.getOrAbsent("carrier") + .map(s -> OptionalLong.of(parseStringAsLong(s))) + .orElse(OptionalLong.empty()); } @Override @@ -388,33 +385,25 @@ public final class ThreadDump { } } - /** - * Returns the value of a property of this thread dump, as a string. - */ - private String getStringProperty(String propertyName) { - JSONValue value = threadDumpObj.get(propertyName); - return (value != null) ? value.asString() : null; - } - /** * Returns the value of threadDump/processId. */ public long processId() { - return Long.parseLong(getStringProperty("processId")); + return parseStringAsLong(threadDumpObj.get("processId")); } /** * Returns the value of threadDump/time. */ public String time() { - return getStringProperty("time"); + return threadDumpObj.get("time").asString(); } /** * Returns the value of threadDump/runtimeVersion. */ public String runtimeVersion() { - return getStringProperty("runtimeVersion"); + return threadDumpObj.get("runtimeVersion").asString(); } /** @@ -449,24 +438,31 @@ public final class ThreadDump { JSONValue threadDumpObj = JSONValue.parse(json).get("threadDump"); // threadContainers array, preserve insertion order (parents are added before children) - Map containerObjs = new LinkedHashMap<>(); - JSONValue threadContainersObj = threadDumpObj.get("threadContainers"); - for (JSONValue containerObj : threadContainersObj.asArray()) { - String name = containerObj.get("container").asString(); - containerObjs.put(name, containerObj); - } + Map containerObjs = threadDumpObj.get("threadContainers") + .elements() + .stream() + .collect(Collectors.toMap( + c -> c.get("container").asString(), + Function.identity(), + (a, b) -> { throw new RuntimeException("Duplicate container"); }, + LinkedHashMap::new + )); // find root and create tree of thread containers ThreadContainer root = null; Map map = new HashMap<>(); for (String name : containerObjs.keySet()) { JSONValue containerObj = containerObjs.get(name); - String parentName = containerObj.get("parent").asString(); - if (parentName == null) { + JSONValue parentObj = containerObj.get("parent"); + if (parentObj instanceof JSONValue.JSONNull) { + if (root != null) { + throw new RuntimeException("More than one root container"); + } root = new ThreadContainer(name, null, containerObj); map.put(name, root); } else { - var parent = map.get(parentName); + String parentName = parentObj.asString(); + ThreadContainer parent = map.get(parentName); if (parent == null) { throw new RuntimeException("Thread container " + name + " found before " + parentName); } @@ -475,7 +471,10 @@ public final class ThreadDump { map.put(name, container); } } + if (root == null) { + throw new RuntimeException("No root container"); + } return new ThreadDump(root, map, threadDumpObj); } -} \ No newline at end of file +} diff --git a/test/lib/jdk/test/lib/util/ZipUtils.java b/test/lib/jdk/test/lib/util/ZipUtils.java new file mode 100644 index 00000000000..a1568e51cc1 --- /dev/null +++ b/test/lib/jdk/test/lib/util/ZipUtils.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2023, 2026, 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 jdk.test.lib.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.EnumSet; +import java.util.HexFormat; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +/** + * This class consists exclusively of static utility methods that are useful + * for creating and manipulating ZIP files. + */ +public final class ZipUtils { + // Some ZipFile constants for manipulating the 'End of central directory record' (END header) + private static final int ENDHDR = ZipFile.ENDHDR; // End of central directory record size + private static final int ENDSIZ = ZipFile.ENDSIZ; // Offset of CEN size field within ENDHDR + private static final int ENDOFF = ZipFile.ENDOFF; // Offset of CEN offset field within ENDHDR + // Expected message when CEN size does not match file size + public static final String INVALID_CEN_BAD_SIZE = "invalid END header (bad central directory size)"; + // Expected message when CEN offset is too large + public static final String INVALID_CEN_BAD_OFFSET = "invalid END header (bad central directory offset)"; + // Expected message when CEN size is too large + public static final String INVALID_CEN_SIZE_TOO_LARGE = "invalid END header (central directory size too large)"; + // Expected message when total entry count is too large + public static final String INVALID_BAD_ENTRY_COUNT = "invalid END header (total entries count too large)"; + + private ZipUtils() { } + + /** + * Create an ZIP file with a single entry, then modify the CEN size + * in the 'End of central directory record' (END header) to the given size. + * + * The CEN is optionally "inflated" with trailing zero bytes such that + * its actual size matches the one stated in the END header. + * + * The CEN offset is optiontially adjusted by the given amount + * + * The resulting ZIP is technically not valid, but it does allow us + * to test that large or invalid CEN sizes are rejected + * @param cenSize the CEN size to put in the END record + * @param inflateCen if true, zero-pad the CEN to the desired size + * @param cenOffAdjust Adjust the CEN offset field of the END record with this amount + * @throws IOException if an error occurs + */ + public static Path zipWithModifiedEndRecord(int cenSize, + boolean inflateCen, + int cenOffAdjust, + Path zip) throws IOException { + // A byte buffer for reading the END + ByteBuffer buffer = ByteBuffer.wrap(templateZip()).order(ByteOrder.LITTLE_ENDIAN); + + // Offset of the END header + int endOffset = buffer.limit() - ENDHDR; + + // Modify the CEN size + int sizeOffset = endOffset + ENDSIZ; + int currentCenSize = buffer.getInt(sizeOffset); + buffer.putInt(sizeOffset, cenSize); + + // Optionally modify the CEN offset + if (cenOffAdjust != 0) { + int offOffset = endOffset + ENDOFF; + int currentCenOff = buffer.getInt(offOffset); + buffer.putInt(offOffset, currentCenOff + cenOffAdjust); + } + // When creating a sparse file, the file must not already exit + Files.deleteIfExists(zip); + + // Open a FileChannel for writing a sparse file + EnumSet options = EnumSet.of(StandardOpenOption.CREATE_NEW, + StandardOpenOption.WRITE, + StandardOpenOption.SPARSE); + + try (FileChannel channel = FileChannel.open(zip, options)) { + // Write everything up to END + channel.write(buffer.slice(0, buffer.limit() - ENDHDR)); + if (inflateCen) { + // Inject "empty bytes" to make the actual CEN size match the END + int injectBytes = cenSize - currentCenSize; + channel.position(channel.position() + injectBytes); + } + // Write the modified END + channel.write(buffer.slice(buffer.limit() - ENDHDR, ENDHDR)); + } + return zip; + } + + /** + * Create a small Zip64 ZIP file, then modify the Zip64 END header + * with a possibly very large total entry count + * + * @param zip file to write to + * @param totalEntries the number of entries wanted in the Zip64 END header + * @return the modified ZIP file + * @throws IOException if an unexpeced IO error occurs + */ + public static Path zip64WithModifiedTotalEntries(Path zip, long totalEntries) throws IOException { + /** + * A small ZIP using the ZIP64 format. + * + * ZIP created using: "echo -n hello | zip zip64.zip -" + * Hex encoded using: "cat zip64.zip | xxd -ps" + * + * The file has the following structure: + * + * 0000 LOCAL HEADER #1 04034B50 + * 0004 Extract Zip Spec 2D '4.5' + * 0005 Extract OS 00 'MS-DOS' + * 0006 General Purpose Flag 0000 + * 0008 Compression Method 0000 'Stored' + * 000A Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' + * 000E CRC 363A3020 + * 0012 Compressed Length FFFFFFFF + * 0016 Uncompressed Length FFFFFFFF + * 001A Filename Length 0001 + * 001C Extra Length 0014 + * 001E Filename '-' + * 001F Extra ID #0001 0001 'ZIP64' + * 0021 Length 0010 + * 0023 Uncompressed Size 0000000000000006 + * 002B Compressed Size 0000000000000006 + * 0033 PAYLOAD hello. + * + * 0039 CENTRAL HEADER #1 02014B50 + * 003D Created Zip Spec 1E '3.0' + * 003E Created OS 03 'Unix' + * 003F Extract Zip Spec 2D '4.5' + * 0040 Extract OS 00 'MS-DOS' + * 0041 General Purpose Flag 0000 + * 0043 Compression Method 0000 'Stored' + * 0045 Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' + * 0049 CRC 363A3020 + * 004D Compressed Length 00000006 + * 0051 Uncompressed Length FFFFFFFF + * 0055 Filename Length 0001 + * 0057 Extra Length 000C + * 0059 Comment Length 0000 + * 005B Disk Start 0000 + * 005D Int File Attributes 0001 + * [Bit 0] 1 Text Data + * 005F Ext File Attributes 11B00000 + * 0063 Local Header Offset 00000000 + * 0067 Filename '-' + * 0068 Extra ID #0001 0001 'ZIP64' + * 006A Length 0008 + * 006C Uncompressed Size 0000000000000006 + * + * 0074 ZIP64 END CENTRAL DIR 06064B50 + * RECORD + * 0078 Size of record 000000000000002C + * 0080 Created Zip Spec 1E '3.0' + * 0081 Created OS 03 'Unix' + * 0082 Extract Zip Spec 2D '4.5' + * 0083 Extract OS 00 'MS-DOS' + * 0084 Number of this disk 00000000 + * 0088 Central Dir Disk no 00000000 + * 008C Entries in this disk 0000000000000001 + * 0094 Total Entries 0000000000000001 + * 009C Size of Central Dir 000000000000003B + * 00A4 Offset to Central dir 0000000000000039 + * + * 00AC ZIP64 END CENTRAL DIR 07064B50 + * LOCATOR + * 00B0 Central Dir Disk no 00000000 + * 00B4 Offset to Central dir 0000000000000074 + * 00BC Total no of Disks 00000001 + * + * 00C0 END CENTRAL HEADER 06054B50 + * 00C4 Number of this disk 0000 + * 00C6 Central Dir Disk no 0000 + * 00C8 Entries in this disk 0001 + * 00CA Total Entries 0001 + * 00CC Size of Central Dir 0000003B + * 00D0 Offset to Central Dir FFFFFFFF + * 00D4 Comment Length 0000 + */ + + byte[] zipBytes = HexFormat.of().parseHex(""" + 504b03042d000000000078ab475920303a36ffffffffffffffff01001400 + 2d010010000600000000000000060000000000000068656c6c6f0a504b01 + 021e032d000000000078ab475920303a3606000000ffffffff01000c0000 + 00000001000000b011000000002d010008000600000000000000504b0606 + 2c000000000000001e032d00000000000000000001000000000000000100 + 0000000000003b000000000000003900000000000000504b060700000000 + 740000000000000001000000504b050600000000010001003b000000ffff + ffff0000 + """.replaceAll("\n","")); + + // Buffer to manipulate the above ZIP + ByteBuffer buf = ByteBuffer.wrap(zipBytes).order(ByteOrder.LITTLE_ENDIAN); + // Offset of the 'total entries' in the 'ZIP64 END CENTRAL DIR' record + // Update ZIP64 entry count to a value which cannot possibly fit in the small CEN + buf.putLong(0x94, totalEntries); + // The corresponding END field needs the ZIP64 magic value + buf.putShort(0xCA, (short) 0xFFFF); + // Write the ZIP to disk + Files.write(zip, zipBytes); + return zip; + } + + /** + * Produce a byte array of a ZIP with a single entry + * + * @throws IOException if an error occurs + */ + private static byte[] templateZip() throws IOException { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + try (ZipOutputStream zo = new ZipOutputStream(bout)) { + ZipEntry entry = new ZipEntry("duke.txt"); + zo.putNextEntry(entry); + zo.write("duke".getBytes(StandardCharsets.UTF_8)); + } + return bout.toByteArray(); + } +} diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index cc570caef7c..c915cee41b0 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -799,8 +799,6 @@ public class WhiteBox { public native boolean cdsMemoryMappingFailed(); public native boolean isSharingEnabled(); public native boolean isSharedClass(Class c); - public native boolean areSharedStringsMapped(); - public native boolean isSharedInternedString(String s); public native boolean isCDSIncluded(); public native boolean isJFRIncluded(); public native boolean isDTraceIncluded(); diff --git a/test/lib/native/testlib_thread_barriers.h b/test/lib/native/testlib_thread_barriers.h new file mode 100644 index 00000000000..8e0b717b57a --- /dev/null +++ b/test/lib/native/testlib_thread_barriers.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026, IBM Corp. + * 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. + */ + +#ifndef TESTLIB_THREAD_BARRIERS_H +#define TESTLIB_THREAD_BARRIERS_H + +/* MacOS does not have pthread barriers; implement a fallback using condvars. */ + +#ifndef _WIN32 +#if !defined _POSIX_BARRIERS || _POSIX_BARRIERS < 0 + +#include + +#define PTHREAD_BARRIER_SERIAL_THREAD 1 + +#define pthread_barrier_t barr_t +#define pthread_barrier_init(barr, attr, need) barr_init(barr, attr, need) +#define pthread_barrier_destroy(barr) barr_destroy(barr) +#define pthread_barrier_wait(barr) barr_wait(barr) + +typedef struct { + pthread_mutex_t mutex; + pthread_cond_t cond; + int have, need, trigger_count; +} barr_t; + +int barr_init(barr_t* b, void* ignored, int need) { + b->have = b->trigger_count = 0; + b->need = need; + pthread_mutex_init(&b->mutex, NULL); + pthread_cond_init(&b->cond, NULL); + return 0; +} + +int barr_destroy(barr_t* b) { + pthread_mutex_destroy(&b->mutex); + pthread_cond_destroy(&b->cond); + return 0; +} + +int barr_wait(barr_t* b) { + pthread_mutex_lock(&b->mutex); + int my_trigger_count = b->trigger_count; + b->have++; + if (b->have == b->need) { + b->have = 0; + b->trigger_count++; + pthread_cond_broadcast(&b->cond); + pthread_mutex_unlock(&b->mutex); + return PTHREAD_BARRIER_SERIAL_THREAD; + } + while (my_trigger_count == b->trigger_count) { // no spurious wakeups + pthread_cond_wait(&b->cond, &b->mutex); + } + pthread_mutex_unlock(&b->mutex); + return 0; +} + +#endif // !_POSIX_BARRIERS +#endif // !_WIN32 + +#endif // TESTLIB_THREAD_BARRIERS_H diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java b/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java new file mode 100644 index 00000000000..1733b73886e --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2026, Google LLC. 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.foreign; + +import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; +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.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.annotations.State; + +@Warmup(time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +@State(Scope.Benchmark) +public class StringLoopJmhBenchmark { + @Param({"10", "100", "1000", "100000"}) + int stringLength; + + @Param({"ASCII", "LATIN1", "UTF16"}) + String encoding; + + String stringData; + + @Setup + public void setUp() { + stringData = ""; + + // Character at the _end_ to affect if we hit + // - ASCII = compact strings and compatible with UTF-8 + // - LATIN1 = compact strings but not compatible with UTF-8 + // - UTF16 = 2-byte char storage and not compatible with UTF-8 + String c; + if (encoding.equals("ASCII")) { + c = "a"; + } else if (encoding.equals("LATIN1")) { + c = "\u00C4"; + } else if (encoding.equals("UTF16")) { + c = "\u2603"; + } else { + throw new IllegalArgumentException("Unknown encoding: " + encoding); + } + + var stringDataBuilder = new StringBuilder(stringLength + 1); + while (stringDataBuilder.length() < stringLength) { + stringDataBuilder.append((char) (Math.random() * 26) + 'a'); + } + stringData = stringDataBuilder.append(c).toString(); + } + + @Benchmark + public int utf8LenByLoop() { + final String s = stringData; + final int len = s.length(); + + // ASCII prefix strings. + int idx = 0; + for (char c; idx < len && (c = s.charAt(idx)) < 0x80; ++idx) {} + + // Entire string was ASCII. + if (idx == len) { + return len; + } + + int utf8Len = len; + for (char c; idx < len; ++idx) { + c = s.charAt(idx); + if (c < 0x80) { + utf8Len++; + } else if (c < 0x800) { + utf8Len += 2; + } else { + utf8Len += 3; + if (Character.isSurrogate(c)) { + int cp = Character.codePointAt(s, idx); + if (cp < Character.MIN_SUPPLEMENTARY_CODE_POINT) { + throw new RuntimeException("Unpaired surrogate"); + } + idx++; + } + } + } + return utf8Len; + } + + @Benchmark + public int getBytes() throws Exception { + return stringData.getBytes(StandardCharsets.UTF_8).length; + } + + @Benchmark + public int encodedLength() throws Exception { + return stringData.encodedLength(StandardCharsets.UTF_8); + } +} diff --git a/test/micro/org/openjdk/bench/java/net/URLToString.java b/test/micro/org/openjdk/bench/java/net/URLToString.java new file mode 100644 index 00000000000..38f6500c573 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/net/URLToString.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2026, 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.net; + +import org.openjdk.jmh.annotations.*; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.concurrent.TimeUnit; + +/** + * Tests java.net.URL.toString performance + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(value = 3) +public class URLToString { + + @Param({"false", "true"}) + boolean auth; + + @Param({"false", "true"}) + boolean query; + + @Param({"false", "true"}) + boolean ref; + + private URL url; + + @Setup() + public void setup() throws MalformedURLException { + StringBuilder sb = new StringBuilder(); + if (auth) { + sb.append("http://hostname"); + } else { + sb.append("file:"); + } + sb.append("/some/long/path/to/jar/app-1.0.jar!/org/summerframework/samples/horseclinic/HorseClinicApplication.class"); + if (query) { + sb.append("?param=value"); + } + if (ref) { + sb.append("#fragment"); + } + + url = URI.create(sb.toString()).toURL(); + } + + @Benchmark + public String urlToString() { + return url.toString(); + } +} diff --git a/test/micro/org/openjdk/bench/java/nio/file/FilesCopy.java b/test/micro/org/openjdk/bench/java/nio/file/FilesCopy.java new file mode 100644 index 00000000000..9472920f071 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/nio/file/FilesCopy.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026, 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.nio.file; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import static java.nio.file.StandardOpenOption.*; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; + +@State(Scope.Benchmark) +public class FilesCopy { + + private static final int SIZE = Integer.MAX_VALUE; + private static final Path FILE = Path.of("file.dat"); + private static final Path COPY = Path.of("copy.dat"); + + @Setup + public void init() throws IOException { + Files.deleteIfExists(FILE); + Files.deleteIfExists(COPY); + try (FileChannel fc = FileChannel.open(FILE, CREATE_NEW, READ, WRITE)) { + fc.position(SIZE); + fc.write(ByteBuffer.wrap(new byte[] {(byte)27})); + } + } + + @TearDown + public void cleanup() throws IOException { + Files.deleteIfExists(FILE); + Files.deleteIfExists(COPY); + } + + @Benchmark + public void copyFile() throws IOException { + Files.copy(FILE, COPY); + Files.delete(COPY); + } + +} diff --git a/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java b/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java new file mode 100644 index 00000000000..5b259230341 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2026, 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.micro.bench.java.util; + +import org.openjdk.jmh.annotations.*; + +import java.util.Base64; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +@Warmup(iterations = 5, time = 2) +@Measurement(iterations = 5, time = 2) +@Fork(value = 2) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +public class Base64EncodeToString { + + private byte[] input; + + @Param({"10", "100", "1000", "10000"}) + private int inputSize; + + @Setup + public void setup() { + Random r = new Random(1123); + input = new byte[inputSize]; + r.nextBytes(input); + } + + @Benchmark + public String testEncodeToString() { + return Base64.getEncoder().encodeToString(input); + } +} + diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/Float16OperationsBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/Float16OperationsBenchmark.java index ebbfbb01cc6..cbfe9958924 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/Float16OperationsBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/Float16OperationsBenchmark.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.bench.java.lang; +package org.openjdk.bench.jdk.incubator.vector; import java.util.stream.IntStream; import java.util.concurrent.TimeUnit; diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java index 911494cb022..f60dfcb2d7c 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithms.java @@ -51,13 +51,20 @@ import org.openjdk.jmh.annotations.*; @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 3, time = 1) -@Fork(value = 5, jvmArgs = {"--add-modules=jdk.incubator.vector", "-XX:CompileCommand=inline,*VectorAlgorithmsImpl*::*"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector", "-XX:CompileCommand=inline,*VectorAlgorithmsImpl*::*"}) public class VectorAlgorithms { @Param({"640000"}) public int SIZE; + // Specifies the length of the arrays / number of elements in the container. @Param({"10000"}) public int NUM_X_OBJECTS; + // Number of simulated "objects" in the "reduceAddIFieldsX4" benchmark. + + @Param({"0.5"}) + public float BRANCH_PROBABILITY; + // Branch probability for the following benchmarks: + // - filterI @Param({"0"}) public int SEED; @@ -66,7 +73,7 @@ public class VectorAlgorithms { @Setup public void init() { - d = new VectorAlgorithmsImpl.Data(SIZE, SEED, NUM_X_OBJECTS); + d = new VectorAlgorithmsImpl.Data(SIZE, SEED, NUM_X_OBJECTS, BRANCH_PROBABILITY); } // ------------------------------------------------------------------------------------------ @@ -208,15 +215,15 @@ public class VectorAlgorithms { // Every invocation should have a different value for e, so that // we don't get branch-prediction that is too good. And also so // that the position where we exit is more evenly distributed. - d.eI_idx = (d.eI_idx + 1) & 0xffff; - int e = d.eI[d.eI_idx]; + d.eI_findI_idx = (d.eI_findI_idx + 1) & 0xffff; + int e = d.eI_findI[d.eI_findI_idx]; return VectorAlgorithmsImpl.findI_loop(d.aI, e); } @Benchmark public int findI_VectorAPI() { - d.eI_idx = (d.eI_idx + 1) & 0xffff; - int e = d.eI[d.eI_idx]; + d.eI_findI_idx = (d.eI_findI_idx + 1) & 0xffff; + int e = d.eI_findI[d.eI_findI_idx]; return VectorAlgorithmsImpl.findI_VectorAPI(d.aI, e); } @@ -235,16 +242,27 @@ public class VectorAlgorithms { // Every invocation should have a different value for e, so that // we don't get branch-prediction that is too good. And also so // That the length of the resulting data is more evenly distributed. - d.eI_idx = (d.eI_idx + 1) & 0xffff; - int e = d.eI[d.eI_idx]; - return VectorAlgorithmsImpl.filterI_loop(d.aI, d.rI1, e); + return VectorAlgorithmsImpl.filterI_loop(d.aI_filterI, d.rI1, d.eI_filterI); } @Benchmark - public Object filterI_VectorAPI() { - d.eI_idx = (d.eI_idx + 1) & 0xffff; - int e = d.eI[d.eI_idx]; - return VectorAlgorithmsImpl.filterI_VectorAPI(d.aI, d.rI1, e); + public Object filterI_VectorAPI_v1() { + return VectorAlgorithmsImpl.filterI_VectorAPI_v1(d.aI_filterI, d.rI1, d.eI_filterI); + } + + @Benchmark + public Object filterI_VectorAPI_v2_l2() { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l2(d.aI_filterI, d.rI1, d.eI_filterI); + } + + @Benchmark + public Object filterI_VectorAPI_v2_l4() { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l4(d.aI_filterI, d.rI1, d.eI_filterI); + } + + @Benchmark + public Object filterI_VectorAPI_v2_l8() { + return VectorAlgorithmsImpl.filterI_VectorAPI_v2_l8(d.aI_filterI, d.rI1, d.eI_filterI); } @Benchmark @@ -271,4 +289,34 @@ public class VectorAlgorithms { public Object lowerCaseB_VectorAPI_v2() { return VectorAlgorithmsImpl.lowerCaseB_VectorAPI_v2(d.strB, d.rB1); } + + @Benchmark + public Object conditionalSumB_loop() { + return VectorAlgorithmsImpl.conditionalSumB_loop(d.strB); + } + + @Benchmark + public Object conditionalSumB_VectorAPI_v1() { + return VectorAlgorithmsImpl.conditionalSumB_VectorAPI_v1(d.strB); + } + + @Benchmark + public Object conditionalSumB_VectorAPI_v2() { + return VectorAlgorithmsImpl.conditionalSumB_VectorAPI_v2(d.strB); + } + + @Benchmark + public float[] pieceWise2FunctionF_loop() { + return VectorAlgorithmsImpl.pieceWise2FunctionF_loop(d.xF, d.rF1); + } + + @Benchmark + public float[] pieceWise2FunctionF_VectorAPI_v1() { + return VectorAlgorithmsImpl.pieceWise2FunctionF_VectorAPI_v1(d.xF, d.rF1); + } + + @Benchmark + public float[] pieceWise2FunctionF_VectorAPI_v2() { + return VectorAlgorithmsImpl.pieceWise2FunctionF_VectorAPI_v2(d.xF, d.rF1); + } } diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithmsImpl.java b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithmsImpl.java index 5ab057329d3..3ae4ed81634 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithmsImpl.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorAlgorithmsImpl.java @@ -36,6 +36,8 @@ public class VectorAlgorithmsImpl { private static final VectorSpecies SPECIES_I = IntVector.SPECIES_PREFERRED; private static final VectorSpecies SPECIES_I512 = IntVector.SPECIES_512; private static final VectorSpecies SPECIES_I256 = IntVector.SPECIES_256; + private static final VectorSpecies SPECIES_I128 = IntVector.SPECIES_128; + private static final VectorSpecies SPECIES_I64 = IntVector.SPECIES_64; private static final VectorSpecies SPECIES_B = ByteVector.SPECIES_PREFERRED; private static final VectorSpecies SPECIES_B64 = ByteVector.SPECIES_64; private static final VectorSpecies SPECIES_F = FloatVector.SPECIES_PREFERRED; @@ -58,15 +60,31 @@ public class VectorAlgorithmsImpl { public int[] rI2; public int[] rI3; public int[] rI4; - public int[] eI; + public int[] rI5; + + // Search element for "findI" + public int[] eI_findI; // The test has to use the same index into eI for all implementations. But in the // benchmark, we'd like to use random indices, so we use the index to advance through // the array. - public int eI_idx = 0; + public int eI_findI_idx = 0; + + // Data and threshold eI value for "filterI". + // We create the data in a range, and then pick a threshold scaled to that range, + // so that the branch in the filter is branchProbability. + public int[] aI_filterI; + public int eI_filterI; public float[] aF; public float[] bF; + // Input for piece-wise functions. + // Uniform [0..1[ with probability p and Uniform [1..2[ with probability (1-p) + public float[] xF; + public float[] rF1; + public float[] rF2; + public float[] rF3; + public byte[] aB; public byte[] strB; public byte[] rB1; @@ -76,7 +94,7 @@ public class VectorAlgorithmsImpl { public int[] oopsX4; public int[] memX4; - public Data(int size, int seed, int numX4Objects) { + public Data(int size, int seed, int numX4Objects, float branchProbability) { Random random = new Random(seed); // int: one input array and multiple output arrays so different implementations can @@ -86,14 +104,20 @@ public class VectorAlgorithmsImpl { rI2 = new int[size]; rI3 = new int[size]; rI4 = new int[size]; + rI5 = new int[size]; Arrays.setAll(aI, i -> random.nextInt()); // Populate with some random values from aI, and some totally random values. - eI = new int[0x10000]; - for (int i = 0; i < eI.length; i++) { - eI[i] = (random.nextInt(10) == 0) ? random.nextInt() : aI[random.nextInt(size)]; + eI_findI = new int[0x10000]; + for (int i = 0; i < eI_findI.length; i++) { + eI_findI[i] = (random.nextInt(10) == 0) ? random.nextInt() : aI[random.nextInt(size)]; } + int filterI_range = 1000_000; + aI_filterI = new int[size]; + Arrays.setAll(aI_filterI, i -> random.nextInt(filterI_range)); + eI_filterI = (int)(filterI_range * (1.0f - branchProbability)); + // X4 oop setup. // oopsX4 holds "addresses" (i.e. indices), that point to the 16-byte objects in memX4. oopsX4 = new int[size]; @@ -117,14 +141,30 @@ public class VectorAlgorithmsImpl { bF[i] = random.nextInt(32) - 16; } + xF = new float[size]; + rF1 = new float[size]; + rF2 = new float[size]; + rF3 = new float[size]; + for (int i = 0; i < size; i++) { + xF[i] = (random.nextFloat() < branchProbability) + ? 0f + random.nextFloat() + : 1f + random.nextFloat(); + } + // byte: just random data. aB = new byte[size]; - strB = new byte[size]; rB1 = new byte[size]; rB2 = new byte[size]; rB3 = new byte[size]; random.nextBytes(aB); - random.nextBytes(strB); // TODO: special data! + + // byte string: for lowerCase benchmark. + strB = new byte[size]; + for (int i = 0; i < size; i++) { + strB[i] = (random.nextFloat() < branchProbability) + ? (byte)(random.nextInt(16) + 'A') + : (byte)(random.nextInt(16) + 'a'); + } } } @@ -651,13 +691,12 @@ public class VectorAlgorithmsImpl { return r; } - public static Object filterI_VectorAPI(int[] a, int[] r, int threshold) { - var thresholds = IntVector.broadcast(SPECIES_I, threshold); + public static Object filterI_VectorAPI_v1(int[] a, int[] r, int threshold) { int j = 0; int i = 0; for (; i < SPECIES_I.loopBound(a.length); i += SPECIES_I.length()) { IntVector v = IntVector.fromArray(SPECIES_I, a, i); - var mask = v.compare(VectorOperators.GE, thresholds); + var mask = v.compare(VectorOperators.GE, threshold); v = v.compress(mask); int trueCount = mask.trueCount(); var prefixMask = mask.compress(); @@ -676,6 +715,98 @@ public class VectorAlgorithmsImpl { return r; } + // Idea: on platforms that do not support the "v1" solution with "compress" and + // masked stores, we struggle to deal with the loop-carried dependency of j. + // But we can still use dynamic uniformity to enable some vectorized performance. + public static Object filterI_VectorAPI_v2_l2(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I64.loopBound(a.length); i += SPECIES_I64.length()) { + IntVector v = IntVector.fromArray(SPECIES_I64, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 2; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + + public static Object filterI_VectorAPI_v2_l4(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I128.loopBound(a.length); i += SPECIES_I128.length()) { + IntVector v = IntVector.fromArray(SPECIES_I128, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 4; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + if (mask.laneIsSet(2)) { r[j++] = v.lane(2); } + if (mask.laneIsSet(3)) { r[j++] = v.lane(3); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + + public static Object filterI_VectorAPI_v2_l8(int[] a, int[] r, int threshold) { + int j = 0; + int i = 0; + for (; i < SPECIES_I256.loopBound(a.length); i += SPECIES_I256.length()) { + IntVector v = IntVector.fromArray(SPECIES_I256, a, i); + var mask = v.compare(VectorOperators.GE, threshold); + if (mask.allTrue()) { + v.intoArray(r, j); + j += 8; + } else if (mask.anyTrue()) { + if (mask.laneIsSet(0)) { r[j++] = v.lane(0); } + if (mask.laneIsSet(1)) { r[j++] = v.lane(1); } + if (mask.laneIsSet(2)) { r[j++] = v.lane(2); } + if (mask.laneIsSet(3)) { r[j++] = v.lane(3); } + if (mask.laneIsSet(4)) { r[j++] = v.lane(4); } + if (mask.laneIsSet(5)) { r[j++] = v.lane(5); } + if (mask.laneIsSet(6)) { r[j++] = v.lane(6); } + if (mask.laneIsSet(7)) { r[j++] = v.lane(7); } + } else { + // nothing + } + } + for (; i < a.length; i++) { + int ai = a[i]; + if (ai >= threshold) { + r[j++] = ai; + } + } + // Just force the resulting length onto the same array. + r[r.length - 1] = j; + return r; + } + // X4: ints simulate 4-byte oops. // oops: if non-zero (= non-null), every entry simulates a 4-byte oop, pointing into mem. // mem: an int array that simulates the memory. @@ -771,5 +902,176 @@ public class VectorAlgorithmsImpl { } return r; } -} + public static int conditionalSumB_loop(byte[] a) { + int sum = 0; + for (int i = 0; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + + public static int conditionalSumB_VectorAPI_v1(byte[] a) { + return ConditionalSumB_VectorAPI_V1.compute(a); + } + + private static class ConditionalSumB_VectorAPI_V1 { + // Pick I species to be a full vector, and the B vector a quarter its bit length. + // However, we have to get at least 64bits for the B vector, so at least 256bits + // for the int vector - a sad restriction by the currently very narrow range of + // supported shapes. + private static final int BITS_I = Math.max(256, IntVector.SPECIES_PREFERRED.vectorBitSize()); + private static final int BITS_B = BITS_I / 4; + private static final VectorShape SHAPE_I = VectorShape.forBitSize(BITS_I); + private static final VectorShape SHAPE_B = VectorShape.forBitSize(BITS_B); + private static final VectorSpecies SPECIES_I = SHAPE_I.withLanes(int.class); + private static final VectorSpecies SPECIES_B = SHAPE_B.withLanes(byte.class); + + public static int compute(byte[] a) { + var zeroB = ByteVector.zero(SPECIES_B); + var accI = IntVector.zero(SPECIES_I); + int i; + for (i = 0; i < SPECIES_B.loopBound(a.length); i += SPECIES_B.length()) { + var vB = ByteVector.fromArray(SPECIES_B, a, i); + var maskA = vB.compare(VectorOperators.GE, (byte)'A'); + var maskZ = vB.compare(VectorOperators.LE, (byte)'Z'); + var mask = maskA.and(maskZ); + vB = zeroB.blend(vB, mask); + var vI = vB.castShape(SPECIES_I, 0); + accI = accI.add(vI); + } + int sum = accI.reduceLanes(VectorOperators.ADD); + for (; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + } + + public static int conditionalSumB_VectorAPI_v2(byte[] a) { + return ConditionalSumB_VectorAPI_V2.compute(a); + } + + private static class ConditionalSumB_VectorAPI_V2 { + // Pick B species to be a full vector, and use 4 I vectors of the same bit size. + private static final VectorSpecies SPECIES_B = ByteVector.SPECIES_PREFERRED; + private static final VectorSpecies SPECIES_I = SPECIES_B.vectorShape().withLanes(int.class); + + public static int compute(byte[] a) { + var zeroB = ByteVector.zero(SPECIES_B); + var accI = IntVector.zero(SPECIES_I); + int i; + for (i = 0; i < SPECIES_B.loopBound(a.length); i += SPECIES_B.length()) { + var vB = ByteVector.fromArray(SPECIES_B, a, i); + var maskA = vB.compare(VectorOperators.GE, (byte)'A'); + var maskZ = vB.compare(VectorOperators.LE, (byte)'Z'); + var mask = maskA.and(maskZ); + vB = zeroB.blend(vB, mask); + // When casting byte->int, we get 4x the bits, and split them into 4 parts. + var vI0 = vB.castShape(SPECIES_I, 0); + var vI1 = vB.castShape(SPECIES_I, 1); + var vI2 = vB.castShape(SPECIES_I, 2); + var vI3 = vB.castShape(SPECIES_I, 3); + accI = accI.add(vI0.add(vI1).add(vI2).add(vI3)); + } + int sum = accI.reduceLanes(VectorOperators.ADD); + for (; i < a.length; i++) { + byte c = a[i]; + if (c >= 'A' && c <= 'Z') { + sum += c; + } + } + return sum; + } + } + + public static float[] pieceWise2FunctionF_loop(float[] a, float[] r) { + for (int i = 0; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } + + public static float[] pieceWise2FunctionF_VectorAPI_v1(float[] a, float[] r) { + int i; + for (i = 0; i < SPECIES_F.loopBound(a.length); i += SPECIES_F.length()) { + var ai = FloatVector.fromArray(SPECIES_F, a, i); + var mask = ai.compare(VectorOperators.LT, 1f); + var a2 = ai.lanewise(VectorOperators.MUL, ai); + var a4 = a2.lanewise(VectorOperators.MUL, a2); + var a8 = a4.lanewise(VectorOperators.MUL, a4); + var s2 = ai.lanewise(VectorOperators.SQRT); + var s4 = s2.lanewise(VectorOperators.SQRT); + var s8 = s4.lanewise(VectorOperators.SQRT); + var v = s8.blend(a8, mask); + v.intoArray(r, i); + } + for (; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } + + public static float[] pieceWise2FunctionF_VectorAPI_v2(float[] a, float[] r) { + int i; + for (i = 0; i < SPECIES_F.loopBound(a.length); i += SPECIES_F.length()) { + var ai = FloatVector.fromArray(SPECIES_F, a, i); + var mask = ai.compare(VectorOperators.LT, 1f); + var a2 = ai.lanewise(VectorOperators.MUL, ai); + var a4 = a2.lanewise(VectorOperators.MUL, a2); + var a8 = a4.lanewise(VectorOperators.MUL, a4); + var v = a8; + // SQRT is expensive, so only call if it necessary + if (!mask.allTrue()) { + var s2 = ai.lanewise(VectorOperators.SQRT); + var s4 = s2.lanewise(VectorOperators.SQRT); + var s8 = s4.lanewise(VectorOperators.SQRT); + v = s8.blend(a8, mask); + } + v.intoArray(r, i); + } + for (; i < a.length; i++) { + float ai = a[i]; + if (ai < 1f) { + float a2 = ai * ai; + float a4 = a2 * a2; + float a8 = a4 * a4; + r[i] = a8; + } else { + float s2 = (float)Math.sqrt(ai); + float s4 = (float)Math.sqrt(s2); + float s8 = (float)Math.sqrt(s4); + r[i] = s8; + } + } + return r; + } +} diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorSubword.java b/test/micro/org/openjdk/bench/vm/compiler/VectorSubword.java new file mode 100644 index 00000000000..5ade452b875 --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorSubword.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2026, 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.vm.compiler; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.*; + +import java.util.concurrent.TimeUnit; +import java.util.Random; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3) +public class VectorSubword { + @Param({"1024"}) + public int SIZE; + + private byte[] bytes; + private short[] shorts; + private char[] chars; + private int[] ints; + private long[] longs; + + @Setup + public void init() { + bytes = new byte[SIZE]; + shorts = new short[SIZE]; + chars = new char[SIZE]; + ints = new int[SIZE]; + longs = new long[SIZE]; + } + + // Narrowing + + @Benchmark + public void shortToByte() { + for (int i = 0; i < SIZE; i++) { + bytes[i] = (byte) shorts[i]; + } + } + + @Benchmark + public void shortToChar() { + for (int i = 0; i < SIZE; i++) { + chars[i] = (char) shorts[i]; + } + } + + @Benchmark + public void charToByte() { + for (int i = 0; i < SIZE; i++) { + bytes[i] = (byte) chars[i]; + } + } + + @Benchmark + public void charToShort() { + for (int i = 0; i < SIZE; i++) { + shorts[i] = (short) chars[i]; + } + } + + @Benchmark + public void intToByte() { + for (int i = 0; i < SIZE; i++) { + bytes[i] = (byte) ints[i]; + } + } + + @Benchmark + public void intToShort() { + for (int i = 0; i < SIZE; i++) { + shorts[i] = (short) ints[i]; + } + } + + @Benchmark + public void intToChar() { + for (int i = 0; i < SIZE; i++) { + chars[i] = (char) ints[i]; + } + } + + @Benchmark + public void longToByte() { + for (int i = 0; i < SIZE; i++) { + bytes[i] = (byte) longs[i]; + } + } + + @Benchmark + public void longToShort() { + for (int i = 0; i < SIZE; i++) { + shorts[i] = (short) longs[i]; + } + } + + @Benchmark + public void longToChar() { + for (int i = 0; i < SIZE; i++) { + chars[i] = (char) longs[i]; + } + } + + @Benchmark + public void longToInt() { + for (int i = 0; i < SIZE; i++) { + ints[i] = (int) longs[i]; + } + } + + // Widening + + @Benchmark + public void byteToShort() { + for (int i = 0; i < SIZE; i++) { + shorts[i] = bytes[i]; + } + } + + @Benchmark + public void byteToChar() { + for (int i = 0; i < SIZE; i++) { + chars[i] = (char) bytes[i]; + } + } + + @Benchmark + public void byteToInt() { + for (int i = 0; i < SIZE; i++) { + ints[i] = bytes[i]; + } + } + + @Benchmark + public void byteToLong() { + for (int i = 0; i < SIZE; i++) { + longs[i] = bytes[i]; + } + } + + @Benchmark + public void shortToInt() { + for (int i = 0; i < SIZE; i++) { + ints[i] = shorts[i]; + } + } + + @Benchmark + public void shortToLong() { + for (int i = 0; i < SIZE; i++) { + longs[i] = shorts[i]; + } + } + + @Benchmark + public void charToInt() { + for (int i = 0; i < SIZE; i++) { + ints[i] = chars[i]; + } + } + + @Benchmark + public void charToLong() { + for (int i = 0; i < SIZE; i++) { + longs[i] = chars[i]; + } + } + + @Benchmark + public void intToLong() { + for (int i = 0; i < SIZE; i++) { + longs[i] = ints[i]; + } + } + +}